Skip to content

feat: extension browser-verbs + TanStack inspection adapter + first-party extension install - #126

Merged
omridevk merged 116 commits into
mainfrom
framework-inspection-extensions
Jul 23, 2026
Merged

omridevk merged 116 commits into
mainfrom
framework-inspection-extensions

Conversation

@omridevk

@omridevk omridevk commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

What this is

Three stacked deliverables:

  1. Extension browser-verb capability (@conciv/extension + @conciv/page + core) — a general, typed, declarative way for any extension to expose browser-side "verbs" that its own server tools invoke over the existing page channel. Extensions declare zod-validated pageVerbs in .client(...); server tools call them via a scoped, fully-typed server.page.call(verb, args) that rejects with a typed PageVerbError. Core gains exactly one generic ext page-query kind — no framework-specific code.

  2. @conciv/extension-tanstack — a framework-inspection adapter giving agents live, devtools-grade read + act access to a running TanStack Router/Start app, built entirely on capability chore: version packages (0.0.2) #1 and assembled behind the cross-framework FrameworkAdapter contract.

  3. First-party extension install — published extensions become installable: npm i @conciv/extension-tanstack, one re-export file in conciv/extensions/, done — on Vite frameworks AND Next.js (Turbopack + webpack).

Landed and reviewed (each task: failing test → implement → spec+quality review → fix loop)

Browser-verb capability (complete):

  • Generic ext page-query wire; browser verb registry with zod-validated dispatch and structured errors.
  • Typed authoring surface: definePageVerbs / pageVerb(schema, handler) / PageCaller / PageVerbError.
  • The verb-map generic threaded through the extension builder so server.page.call is typed against each extension's own verbs.
  • PageBus-backed server.page.call end to end, with typed error mapping for every failure path (no-widget / unknown-verb / invalid-args / handler-error / timeout).
  • Robustness: full error-code coverage, a non-serializable-result guard, author docs, and extension mount-failure isolation (one bad extension can no longer abort app boot; name-collisions still fail loud).

TanStack adapter — client half (complete), all proven against a REAL running TanStack app (no mocks):

  • Fiber-walk router adapter (rootFibers → memoizedProps.router), payloads dehydrated.
  • Tools + Solid cards: tanstack_router_state, tanstack_route_tree, tanstack_loader_data (with a verified dehydrate depth-cap truncation proof), tanstack_query_cache, and the action tools tanstack_navigate / tanstack_invalidate / tanstack_back / tanstack_query_invalidate / tanstack_query_refetch.
  • The full vertical is exercised end to end: agent tool → server.page.call → page bus → fiber-walk on the live app → card.

TanStack adapter — server half (complete):

  • Generic BundlerBridge diagnostic stream (subscribe → build-error / hmr-update / request-trace), captured once in the conciv vite plugin and threaded to the extension ServerApi. Framework-agnostic: a future Next.js adapter reads the same stream.
  • tanstack_build_errors (fed by the diagnostic stream), tanstack_route_manifest (parses routeTree.gen off disk), and tanstack_server_fn_trace (generic request-trace filtered to /_serverFn/, base64-decoded to {file, export}, capped trace ring) — all tested against a real vite dev server.

FrameworkAdapter contract (complete — Task 9, executed redefined):

  • @conciv/protocol framework-types contract finalized: client-facing methods asyncified (the adapter lives server-side over async page.call), client.errors.subscribe dropped (push delivery is a separate cross-framework event-pipeline plan), routes.current() returns {location, matches}, server.errors.snapshot() added.
  • makeTanstackAdapter assembled via defineFrameworkAdapter with capabilities {queryCache: true, serverFunctions: true, rscPayload: false, isr: false, middleware: false}; every tool reads through the adapter object — no direct page calls or ring closures in tool handlers.
  • Contract gaps filled for real: client.detect(), client.data.* (router loader cache, per-route invalidate({filter}) verified against the dep source), client.errors.snapshot() (browser runtime-error ring). Honest minimal where the runtime has nothing: detect.version = null, server.logs.tail() = [] (flagged, not faked).
  • makeFakeFrameworkAdapter(overrides) in @conciv/extension-testkit — a complete, strictly-typed canned adapter for consumers testing against the contract.

First-party extension install (complete):

  • Conditional exports on the 5 published extensions: . resolves browser → client build, import → server build; ./client / ./server / ./package.json subpaths kept by convention.
  • Shared discovery primitives in @conciv/extension-compiler: dedupeExtensions / toSortedEntries (/dedupe subpath, resolved to the dist file in consumer apps so packed installs boot) and one listExtensionFiles fs primitive shared by the server loader and the Next generator.
  • Vite: the widget virtual module collects conciv/extensions/* via import.meta.glob and dedupes against builtins. Next.js: gate-proven that Turbopack cannot glob from node_modules, so withConciv writes an app-local generated entry (.conciv/extensions-client.gen.tsx) and aliases @conciv/app-extensions to it on both Turbopack and webpack; register() watches conciv/ and regenerates live.
  • Both halves proven e2e: Vite (real-browser composer-chip sentinel + real-engine server IT through callTool) and a packed GA Next 16.2 fixture (fresh tarball closure, both bundlers, dev + build, watcher-live regeneration, and a degradation probe proving the tanstack extension returns a clean typed miss in a router-less app).
  • Two product bugs found and fixed by the e2e: the generated module's bare @conciv/extension-compiler/dedupe specifier broke widget boot for all dist-mode consumers (now resolved to an absolute dist path), and Next compiled the node-only engine graph into the edge instrumentation build (withConciv now stubs the register entry when nextRuntime === 'edge').
  • Docs page (docs/extending/install-first-party), changeset covering the 8 touched packages, examples wired (tanstack-start + nextjs), follow-up issues filed: conciv extensions add <name> — shadcn-style CLI to install first-party extensions #136 (install CLI), Baked built-in extensions on Next.js (parity with Vite @conciv/it) #137 (Next builtin extensions), Detection-gated tool/surface visibility (only advertise framework tools when detected) #138 (detection-gated tool visibility), Workspace Next.js dev apps 500 on a clean .next — engine graph bundled into the instrumentation compile (serverExternalPackages ignores workspace symlinks) #139 (pre-existing workspace Next dev 500 — reproduced on main, not introduced here; packed/production installs are unaffected and proven green).

Testing posture

Every browser/adapter behavior is exercised against a real running app in real Chromium (or a real vite dev server for the server-half) — no mocks, no jsdom, no hand-rolled substitute apps. The extension-testkit was generalized so each consumer supplies and runs its own real app via a host callback (recorder/whiteboard/terminal migrated, all real-browser suites green).

Gates (full branch)

pnpm typecheck 83/83 · pnpm build 54/54 · pnpm lint 87/87 · turbo run test --force 94/94 · fallow audit --changed-since main verdict pass, 0 introduced findings · publint + attw 49/49 across the published set · changeset included.

The final whole-branch review completed; all must-fix findings are resolved on this branch.

Note on branch composition

This branch stacks the framework-inspection work (30 commits, from the FrameworkAdapter contract through the adapter assembly) on top of ~36 earlier commits of prior unmerged work that also aren't in main and are intended to merge together here:

  • Lazy discovery + Code Mode migration (core) — ~15 commits
  • Tool-UI cards phase 1 & 2 (ui-kit-chat-tools) — ~13 commits
  • Codex/Gemini harness findings + fixes — ~8 commits

The first-party extension install work adds a further 33 commits on top. The main-based diff therefore includes all ~99 commits, by intent.

🤖 Generated with Claude Code

omridevk and others added 30 commits July 19, 2026 21:09
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ry + Code Mode

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…te-firing proof

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Strip a leading mcp__<server>__ prefix before matching the risky set so
approval: 'ask' extension tools are gated on the in-process/scripted path
(codex permissionGate: 'none') and the mcp__tanstack__ bridge path, not
only the mcp__conciv__ form. Risky set now holds bare names.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…t + duration

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… cards

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 259 out of 262 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (6)

packages/protocol/src/page-types.ts:41

  • ext is now part of PageQueryKindSchema, which also feeds the public conciv_page tool. That tool uses its verb field as the outer query kind, so an ext call cannot also provide the inner extension verb: destructuring removes verb and dispatch always receives an empty verb. Keep this internal kind out of PageInput (as the CLI already does), or give the inner field a non-conflicting wire name.
    packages/page/src/page-verb-registry.ts:41
  • Malformed JSON is converted to {}. A verb whose schema accepts an empty object therefore executes successfully with different arguments instead of returning invalid-args, contradicting the typed failure contract. Preserve parse failure and return a structured invalid-args error before dispatch.
    packages/extension-compiler/src/extension-guard.ts:7
  • This structural check accepts {name: 'x'} as AnyExtension, although required builder members such as parseConfig are absent. dedupeExtensions then returns a value typed as mountable; server mounting fails later while the client silently treats it as an inert extension. Validate the required extension shape before narrowing.
    packages/page/src/page-verb-registry.ts:67
  • The serializer check accepts non-JSON collections such as new Map([['a', 1]]) because Object.values(map) is empty, but JSON transport silently changes that result to {}. Sparse arrays and symbol-keyed values have the same problem. Restrict objects to plain records and dense arrays so accepted values survive transport unchanged.
    apps/conciv/src/router.ts:45
  • Client factory execution is still outside any failure boundary. If one installed extension throws from __client, createConcivRouter throws and mountConciv suppresses the rejection, leaving the entire widget unmounted. Isolate each factory here just as server extension mounting is isolated.
    const dispose = bindExtensionPageVerbs(extension.name, result?.pageVerbs, result?.dispose)
    return {extension, clientValue: result?.value ?? {}, dispose}

packages/plugin/src/core/extensions-entry.ts:6

  • This generated TypeScript header violates the repository's no-comments rule and also contains a forbidden em dash. Remove the generated comment rather than excluding .conciv output from the checks.

@@ -0,0 +1,36 @@
import type {AnyExtension} from '@conciv/extension'
import {isExtension} from './extension-guard.js'
Copilot AI review requested due to automatic review settings July 22, 2026 23:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 259 out of 262 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (4)

packages/page/src/page-verb-registry.ts:41

  • A malformed argsJson is silently replaced with {}, so a corrupted request can execute any verb whose schema accepts an empty object instead of returning invalid-args. JSON decoding must fail closed before schema dispatch.
    packages/page/src/page-verb-registry.ts:45
  • Top-level undefined is silently converted to null, even though the page caller's inferred result remains undefined/void. This bypasses the non-serializable-result guard and changes the value across the wire; let the guard reject it instead.
    packages/page/src/page-verb-registry.ts:67
  • The serializability check accepts non-JSON objects such as Date, Map, and Set because Object.values() is empty. Those values then arrive as a string or {}, contradicting the inferred page-verb return type. Restrict accepted objects to arrays and plain records, and reject sparse/hidden properties that JSON would silently transform.
    packages/plugin/src/core/extensions-entry.ts:6
  • The repository's hard style rules prohibit em dashes. Replace this generated header punctuation with a hyphen; the matching test expectations must be updated as well.

Comment on lines +35 to +38
watcher.on('ready', () => writeExtensionsEntry(resolvedRoot))
watcher.on('all', (event, path) => {
writeExtensionsEntry(resolvedRoot)
if (event === 'unlinkDir' && path === watchDir) rearm()
'@conciv/core': patch
---

Tool cards render on every harness, and code-mode calls surface as real nested tool cards. Three fixes plus the phase-2 extension-owned cards: (1) tool names are normalized to their registered names before parts reach the widget — claude's `probe_ping`, opencode's `tanstack_probe_ping`, and transcript `mcp__<server>__` forms all map losslessly back to the registered dotted name, so a card written once matches everywhere. (2) codex bridged tools finally execute under `workspace-write`: codex was cancelling MCP tool calls awaiting an unanswerable approval prompt, fixed narrowly with `mcp_servers.tanstack.default_tools_approval_mode = "approve"` scoped to conciv's own bridge (conciv's approval gate still guards `approval: 'ask'` tools). (3) every extension tool invoked through code-mode `execute_typescript` now emits a real per-tool part carrying `metadata.parentToolCallId`, and the chat activity view nests those parts under the script run in a collapsible tool group — denies and throws render as errors, never green. New extension-owned cards: CanvasOpCard (op-aware `canvas.*` with thumbnails, count chips, red destructive ops), CommentOpCard (`comment.*` + `pin.setState`), RecordingToolCard (`recording_start/stop/pull` with action-log summary), and inline rows for `element.reference` / `anchor.resolve`.
Copilot AI review requested due to automatic review settings July 22, 2026 23:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 259 out of 262 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (4)

packages/core/src/chat/gate.ts:170

  • Bridge-visible names are sanitized (canvas.delete becomes canvas_delete, and may arrive as tanstack_canvas_delete or mcp__tanstack__canvas_delete), but this check only removes the MCP prefix. Those forms do not match the registered risky name, so an approval: 'ask' tool can execute without prompting. Normalize the wire name against registered names here, or conservatively treat any sanitized match as risky.
    packages/page/src/page-verb-registry.ts:67
  • This accepts class instances such as Date, Map, and Set because they have no enumerable values. JSON transport then converts them (Date to a string, Map/Set to {}), so server.page.call returns a runtime value that contradicts its inferred handler return type. Restrict results to JSON primitives, arrays, and plain objects (including ignored symbol/non-enumerable properties), or validate an actual lossless JSON round trip.
    packages/extensions/tanstack/src/client/query-adapter.ts:138
  • The selected cache entry is identified by its full serialized key, but invalidateQueries({queryKey}) uses TanStack Query's prefix matching by default. Invalidating ['todos'] therefore also invalidates entries such as ['todos', 1], despite the tool promising a specific query. Pass exact: true and update the local filter type.
    packages/extensions/tanstack/src/client/query-adapter.ts:145
  • refetchQueries also performs prefix matching by default, so choosing one displayed key can refetch multiple related cache entries. Pass exact: true so this action remains scoped to the exact entry the agent selected, and update the local filter type.

Copilot AI review requested due to automatic review settings July 22, 2026 23:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 259 out of 262 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (6)

packages/page/src/page-verb-registry.ts:45

  • This coerces a handler's undefined result to null, but PageCaller promises the handler's inferred return type. A pageVerb(..., () => undefined) is therefore typed as Promise<undefined> while resolving to null. Either reject/forbid undefined results in the authoring type or preserve the value through a wire representation that can round-trip it.
    packages/page/src/page-verb-registry.ts:67
  • The serializability check accepts non-plain objects because Object.values(new Date()), Object.values(new Map()), and Object.values(new Set()) are empty. RPC JSON encoding then converts these results to a string or {}, so the fully typed caller receives a different runtime type. It also accepts sparse arrays, which JSON converts by filling holes with null. Restrict accepted objects to plain records/dense arrays (including symbol/extra-property checks), or validate an actual round trip.
    packages/plugin/src/core/extensions-watch.ts:38
  • A generation error escapes this Chokidar event callback. For example, an editor rename can briefly leave both foo.ts and foo.tsx; assertUniqueStems throws, and the uncaught EventEmitter callback can terminate the Next dev process instead of reporting the invalid extension set and recovering on the next event. Catch generation failures inside watcher callbacks and log them while keeping the watcher alive.
    packages/plugin/src/core/vite.ts:33
  • Subscriber exceptions propagate through the Vite internals that call emit. A framework event handler that throws can prevent clientHot.send from forwarding an HMR/error payload, and a throw from the response finish listener can become an uncaught process exception. Isolate each diagnostic listener so one extension cannot disrupt Vite or other subscribers.
    packages/extensions/tanstack/src/client/router-adapter.ts:130
  • fullPath is the route pattern (for example /posts/$postId), while a live TanStack RouteMatch also exposes pathname (for example /posts/42). Since routeId already identifies the route pattern and the contract's fake adapter uses the concrete matched path, this currently loses the actual path the user is viewing.
    packages/plugin/src/core/extensions-entry.ts:6
  • The repository's hard style rules prohibit em dashes, including inside strings. Replace this generated header text with a hyphen and update its assertions in packages/plugin/test/extensions-entry.it.test.ts.

Comment on lines +21 to +24
function encodedSegment(url: string): string | null {
if (!url.startsWith(SERVER_FN_PREFIX)) return null
const rest = url.slice(SERVER_FN_PREFIX.length)
const end = rest.search(/[/?#]/)
Comment on lines +22 to +24
function resolveFile(baseDir: string, spec: string | undefined): string | null {
if (!spec) return null
return resolve(baseDir, spec)
Copilot AI review requested due to automatic review settings July 22, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 260 out of 263 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (2)

apps/conciv/src/router.ts:43

  • A client factory exception still escapes createInstances, so one broken folder-installed extension aborts router/widget boot and also strands disposers from any factories that ran earlier. The server side now isolates this failure, but the client path needs the same per-extension boundary.
    const result = extension.__client?.()

packages/page/src/page-verb-registry.ts:66

  • This accepts non-plain objects such as Date, Map, and Set: Object.values is empty for them, although JSON converts a Date to a string and Map/Set to {}. A typed page verb can therefore resolve to a different runtime type after the page-channel serialization. Reject non-plain object prototypes before traversing their values.

Copilot AI review requested due to automatic review settings July 23, 2026 00:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 260 out of 263 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (4)

packages/core/src/chat/gate.ts:169

  • Risky extension tools are registered under dotted names such as canvas.delete, but bridged calls arrive as mcp__tanstack__canvas_delete (and OpenCode-style tanstack_canvas_delete). Removing only the MCP prefix leaves canvas_delete, so this returns false and bypasses the approval gate; Codex now auto-approves the bridge, making this the only guard for these destructive tools. Resolve bridged names back to the registered tool name before testing the risky set.
    packages/extension-compiler/src/dedupe-extensions.ts:2
  • The release note advertises isExtension from the published @conciv/extension-compiler/dedupe subpath, but this entry only imports it for internal use and never re-exports it. Consumers following the advertised API get a missing-export error.
    packages/plugin/src/core/extensions-watch.ts:38
  • writeExtensionsEntry can throw synchronously (for example, when a live edit creates duplicate extension stems). Throwing from these chokidar callbacks is uncaught and can terminate the Next.js dev process instead of preserving the last valid generated entry. Catch and report regeneration failures in both callbacks.
    packages/plugin/src/core/extensions-entry.ts:6
  • The repository's text style disallows em dashes, including generated strings. Use a plain hyphen in this generated header.

Comment on lines +11 to +13
const dot = file.lastIndexOf('.')
return dot === -1 ? file : file.slice(0, dot)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive: the generator builds import specifiers from the string literal ../conciv/extensions/${stem} (extensions-entry.ts:38) — path.relative is not involved anywhere in this module, so no backslashes can appear on Windows. The other two findings (serverFn basepath, route-manifest extensionless file) were real and are fixed in f9a1c7a.

…nifest resolves real file extensions

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 23, 2026 00:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 262 out of 265 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Generated file
Comments suppressed due to low confidence (4)

packages/extensions/tanstack/src/client/router-adapter.ts:130

  • TanStack route matches expose the resolved URL as pathname, while fullPath belongs to route definitions. Reading match.fullPath therefore leaves every live match's path empty (the real-app test only asserts routeId), so FrameworkAdapter.client.routes.current() and RouterStateCard lose the matched path.
    packages/page/src/page-verb-registry.ts:45
  • This converts a valid handler result of undefined to null. PageCaller still infers Promise<undefined> from that handler, so the fully typed API resolves with a different value than its declared type. Keep the original value so the serializability guard rejects it; authors can explicitly return null for a void payload.
    packages/page/src/page-verb-registry.ts:67
  • Object.values treats non-plain objects such as Map and Date as serializable because they have no enumerable values. The page reply then JSON-converts them to {} or a string, so a caller typed as receiving Map/Date gets a different value. Reject non-array, non-plain objects here; verbs that need these values can return dehydrate(...) output.
    packages/page/src/page-verb-registry.ts:41
  • Malformed argsJson is silently replaced with {}. Consequently a no-argument or all-optional verb executes successfully even though the wire arguments are invalid, instead of returning the promised invalid-args error. Preserve JSON parse failure as an invalid-args dispatch result rather than coercing it.

@omridevk
omridevk merged commit 85ad5da into main Jul 23, 2026
63 checks passed
@omridevk
omridevk deleted the framework-inspection-extensions branch July 23, 2026 06:03
@github-actions github-actions Bot mentioned this pull request Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants