Skip to content

feat(tools): every built-in becomes a registry tool, and the CLI derives from them - #250

Merged
omridevk merged 12 commits into
mainfrom
builtin-tools-229
Aug 5, 2026
Merged

omridevk merged 12 commits into
mainfrom
builtin-tools-229

Conversation

@omridevk

@omridevk omridevk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Closes #229.

Migration steps 2–3 of the one-tool-registry design: 37 page verbs, 7 dev-server operations and open are each declared once via defineTool (input/output schemas, catalog meta, declared errors), registered into the #228 registry, and every consumer derives from the declarations.

What

  • @conciv/tools/builtins (+ a widget-safe page-only subpath): one declaration per capability; server ops declare NO_BUNDLER.
  • One page path: the model-facing tool no longer bypasses runVerb — agent-driven mutations are journaled and agent locate is symbolicated exactly like the CLI path (intended behavior change, proven by a dedicated MCP integration test + a two-surfaces/two-journal-entries guard).
  • CLI derives its command tree from the declarations: PAGE_VERBS, FIELD, flagArg, argsFor, REACT_VERBS, USER_FACING_VERBS deleted; react command = category: 'react'. Three long-standing drifts fixed en route (--effect reaches the server, --action accepts all seven values, name/attribute split), each with its own test.
  • mutating/mirrors read from declarations (runVerb journal + widget cursor mirror), set-equality-guarded against the protocol lists until step 4 deletes them.
  • defineTool gains a UI-free @conciv/extension/tool subpath so the published CLI closure stays free of Solid/Ark/lucide; registry gains has/call for dispatch-by-name (guarded against prototype members).
  • Review wave (opus adversarial + codex, 17+ findings) folded in: --value '' clears fields again, session identity threads through built-in calls, HANDLER_ERROR declared for agent/CLI error parity, rpc layer reads schemas off the declarations instead of restating them, widget bundle carries page declarations only.

Verification

Whole-suite green locally (whiteboard CI-only), lint/format/fallow clean, index-browser-safe + mount-externals guards extended. Final codex re-verdict pending the last fix commits — will comment when it lands.

🤖 Generated with Claude Code

omridevk and others added 11 commits August 5, 2026 19:12
The 37 page verbs, the seven dev-server operations and open now carry their
own input schema, output schema, catalog metadata and declared errors, so the
CLI, the catalog and the sandbox can read one declaration instead of keeping
parallel lists. defineTool's client binding no longer demands a handler: a
built-in page tool declares that it runs in the widget, where the driver holds
the body. The registry gains has()/call() so consumers dispatch by name
without each package pulling in its own oRPC client. The attribute name splits
off the React component name in the page query.

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

The model-facing page tool went around runVerb through pageBus.ask, so an
agent-driven mutation left no journal entry and an agent-driven locate was
never symbolicated. Both entry points now converge on runVerb: the built-in
registry's page caller runs it, and the extension verb path stops asking the
bus itself. Whether a verb is journaled comes from the tool's own mutating
metadata rather than a protocol list. The seven dev-server operations and open
run their declared handlers through the registry, so the rpc layer no longer
holds a second copy of them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Every page verb, dev-server operation and open builds its citty command from
the tool it belongs to: names, arguments, enum values, requiredness, help text
and validation all come from one declaration, and the hand-kept verb table,
flag list and field map are gone. Three drifts go with them: --effect now
reaches the server, --action takes all seven values the protocol declares, and
the attribute of an edit is named by --attribute so --name only ever means a
React component. The widget reads the attribute under its own name and decides
whether to mirror a verb from that verb's declaration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@conciv/page decides whether a verb mirrors the cursor from that verb's own
declaration, so the mount bundle has to carry @conciv/tools rather than leave
it as a bare import its consumers cannot resolve.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…the test session

fallow flagged three exports nobody imports and the preamble the two argument
suites had copied; the derivation keeps one public entry, and the embed's
externals decision reads one inlined-prefix list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… lives in the widget

The rebase onto the widened defineTool kept the immutable builder; a client
binding without a handler now returns a new builder that carries the binding
alone, which is what a built-in page tool declares.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tops loading Solid

The published conciv CLI does not bundle its dependencies, so importing
@conciv/tools/builtins pulled the @conciv/extension package index — and with it
solid-js and solid-js/web — into the CLI's runtime module graph.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…itional off the declaration

`--value ''` was stripped alongside absent flags, so clearing a form field failed
validation for a required value. Absence alone now means "not supplied". Dev-server
commands take the positional their declaration names instead of whichever required
field zod happened to list first.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…er failure, and reads its own schemas

The registry now refuses inherited router members instead of echoing the input
back, forwards the caller request to the page seam, and maps a page
handler-error onto the declared HANDLER_ERROR transport code. A built-in page
failure names the tool that failed rather than a fictional "page" extension.
The rpc layer reads each dev-server output schema off its declaration instead of
restating it, and the mutating/mirroring flags are looked up by page kind so a
renamed verb cannot answer false in silence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The page declarations and their mutating/mirroring lookup now live behind
@conciv/tools/page-tools, which the widget reads; the dev-server and editor
declarations no longer ride along into the browser. Every page handler result is
checked against its declared output schema in the driver browser test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 5, 2026 17:43
@omridevk

omridevk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Local adversarial round complete: opus review (17 findings) + codex review → fix wave (5 commits through c08b2ff) → codex re-verdict APPROVE (all closures verified against resolved library sources; supplied() semantics checked against citty 0.2.2; extension-verb error path unaffected by the total-Record mapping). Orchestrator full gates green (typecheck/build/whole suite minus whiteboard/lint/format/fallow). Known deferred item with ruling: npm-fetch closure still lists @ark-ui/solid + lucide-solid via @conciv/extension's ui-kit-system dependency — runtime loading is fixed and guarded; follow-up ticket to inline TOKENS and demote the dep.

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.

🟡 Changes recommended

Compile-time field exactness, editor validation, release metadata, and repository style violations remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Centralizes built-in page, server, and editor capabilities in the tool registry, then derives CLI behavior and page metadata from those declarations.

Changes:

  • Adds schemas and registry declarations for all built-in tools.
  • Derives CLI commands, arguments, help, mutation, and mirroring metadata.
  • Routes agent and RPC page operations through shared dispatch and journaling.
File summaries
File Description
pnpm-lock.yaml Updates workspace links.
packages/tools/tsdown.config.ts Builds new tool entries.
packages/tools/test/builtins.test.ts Tests built-in declarations.
packages/tools/test/builtins.test-d.ts Adds page-input type coverage.
packages/tools/src/builtins/shared.ts Defines shared schemas and categories.
packages/tools/src/builtins/server-tools.ts Declares server and editor tools.
packages/tools/src/builtins/page-tools.ts Declares page tools and metadata.
packages/tools/src/builtins.ts Exports built-in registry APIs.
packages/tools/package.json Publishes built-in subpaths.
packages/protocol/src/page-types.ts Separates attribute and component names.
packages/page/test/page-driver.browser.test.tsx Validates declared outputs and attributes.
packages/page/src/page-mirror.ts Reads mirroring metadata from tools.
packages/page/src/page-handlers.ts Uses the new attribute field.
packages/page/package.json Adds the tools dependency.
packages/extension/tsdown.config.ts Builds the UI-free tool entry.
packages/extension/test/tool-registry.test.ts Tests dispatch, safety, and requests.
packages/extension/test/define-tool.test.ts Tests handler-free client bindings.
packages/extension/src/tool-registry.ts Adds registry lookup and invocation.
packages/extension/src/define-tool.ts Supports forwarded client bindings.
packages/extension/package.json Exports the tool declaration API.
packages/embed/vite.config.ts Inlines tool declarations.
packages/embed/test/mount-externals.test.ts Guards widget dependency closure.
packages/core/test/builtin-tool-calls.test.ts Tests request and error propagation.
packages/core/test/api/page/agent-page-tool.it.test.ts Tests shared agent/CLI page behavior.
packages/core/src/tool-registry.ts Constructs and dispatches built-ins.
packages/core/src/page-bus.ts Uses declaration mutation metadata.
packages/core/src/app.ts Integrates the built-in registry.
packages/core/src/api/rpc/router.ts Dispatches RPC through declarations.
packages/core/src/api/rpc/mount.ts Injects the registry into RPC.
packages/contract/src/contract.ts Exports editor input validation.
packages/cli/test/support/cli-session.ts Shares CLI test lifecycle setup.
packages/cli/test/dependency-closure.test.ts Guards browser-free CLI dependencies.
packages/cli/test/cli-derived-commands.test.ts Tests declaration-derived commands.
packages/cli/test/cli-arguments.test.ts Updates override argument coverage.
packages/cli/src/tool-command.ts Converts declarations into commands.
packages/cli/src/server.ts Derives server subcommands.
packages/cli/src/page.ts Derives page and React subcommands.
packages/cli/src/open.ts Derives the editor command.
packages/cli/package.json Adds required workspace dependencies.
apps/site/content/docs/cli.mdx Documents attribute and action changes.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (3)

packages/tools/src/builtins/server-tools.ts:122

  • This newly added assertion violates the repository's no-as TypeScript rule. Return the literal directly; the declared output schema already supplies the expected return type.
    packages/tools/src/builtins/server-tools.ts:134
  • The new as const assertion violates the repository's no-as TypeScript rule. The const binding already preserves the map's keys and tool value types without this assertion.
    apps/site/content/docs/cli.mdx:59
  • The newly added em dash violates the repository's punctuation rule.
`--target`. `track` records re-renders (`--action start | stop | report`); `--action` accepts every
value the page protocol declares — `start`, `stop`, `report`, `enable`, `disable`, `toggle`, `list`.
  • Files reviewed: 39/40 changed files
  • Comments generated: 9
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

type DeclaredPageInput = z.infer<BuiltinPageTool['inputSchema']>

test('every value a page tool declares is typed the way the page query carries it', () => {
expectTypeOf<DeclaredPageInput>().toExtend<PageQueryInput>()

const OpenInput = z.object({
file: z.string().min(1).describe('the file to open'),
line: z.coerce.number().optional().describe('line number to jump to'),
Comment thread packages/extension/src/define-tool.ts Resolved
Comment on lines +157 to +159
return input.line === undefined
? {ok: true as const, file: input.file}
: {ok: true as const, file: input.file, line: input.line}
insertTool,
cssTool,
evalTool,
] as const
Comment on lines +39 to +43
const state = {
kit: undefined as Kit | undefined,
widget: undefined as {end: () => void} | undefined,
close: undefined as (() => Promise<void>) | undefined,
}
Comment on lines +26 to +27
The attribute verbs — `attr`, `setattr`, `removeattr` — name the attribute with `--attribute`,
so `--name` always means the component.
Comment on lines +31 to +37
"./builtins": {
"types": "./dist/builtins.d.ts",
"import": "./dist/builtins.js"
},
"./page-tools": {
"types": "./dist/builtins/page-tools.d.ts",
"import": "./dist/builtins/page-tools.js"
@omridevk

omridevk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot triage: 7 of 9 being fixed (line-number contract alignment, the as-cast sites, the missing changeset — thanks, all real). Two refuted:

  1. Em-dashes in cli.mdx — no such repository rule exists: no lint rule matches punctuation in mdx, and main has counter-precedent throughout docs (same refutation verified on PR feat(extension): one tool registry — widened defineTool, runtime oRPC router, catalog walk #244's review round).
  2. builtins.test-d.ts extra-field criterion — verified unexpressible at the type level: TypeScript's structural assignability admits extra properties in every formulation we probed (including keyof-based variants, which collapse to string over the union of declared inputs; adding a bogus field to a declaration produced no diagnostic under any form). The drift is owned by the runtime orphans test in builtins.test.ts, which fails loudly on an undeclared field ('expected [ "page.find.bogus" ] to deeply equal []').

…, drop redundant casts

The declared `open` tool schema accepted zero/negative/fractional line numbers while
the editor.open RPC contract requires a positive integer; the declaration now mirrors
that constraint so the CLI and MCP surface reject bad input as a plain user mistake
instead of falling through to an uncaught ZodError deeper in the call chain.

Also removes genuine `as` casts flagged in review: server-tools.ts's mutating handlers
and the open handler now type their return explicitly instead of asserting, and
define-tool.ts's client-binding state gets an explicit type annotation. `as const` on
BUILTIN_SERVER_TOOL and BUILTIN_PAGE_TOOLS is left alone (allowed, not a genuine cast).

Adds a changeset for the built-in tool declarations, page-tools/extension-tool subpaths,
and CLI command derivation added on this branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@omridevk

omridevk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Copilot fixes landed in 494a57c: the open tool's line field now mirrors the editor contract (int, min 1 — bad input is a clean user error with three behavior tests), the genuine as-casts replaced with explicit annotations (the two flagged tuple sites verified as legitimate as const and left), and the changeset for the new public surface added. Em-dash + test-d comments refuted above with evidence.

Copilot AI review requested due to automatic review settings August 5, 2026 18:28

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.

🟡 Changes recommended

Several declarations reject valid nullable outputs or advertise target modes their handlers ignore.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (7)

apps/site/content/docs/cli.mdx:27

  • Replace the em dashes here to comply with the repository's no-em-dash style rule.
The attribute verbs — `attr`, `setattr`, `removeattr` — name the attribute with `--attribute`,
so `--name` always means the component.

apps/site/content/docs/cli.mdx:59

  • Replace the em dash here to comply with the repository's no-em-dash style rule.
value the page protocol declares — `start`, `stop`, `report`, `enable`, `disable`, `toggle`, `list`.

packages/tools/src/builtins/page-tools.ts:149

  • The declared output rejects a valid locate result. LocateResult.component is string | null (packages/protocol/src/page-introspect-types.ts:4-6), and react.locate returns null when no component name/frame is available, so registry output validation turns that successful result into an error.
    packages/tools/src/builtins/page-tools.ts:31
  • This shared target schema advertises ref and name for dom, query, exists, snapshot, tree, and wait, but their handlers only read selector (packages/page/src/page-handlers.ts:155-169, 208-230). Calls such as snapshot --name Foo therefore silently operate on the whole body, while query --ref v1 returns no matches. Split out a selector-only schema for those verbs or update the handlers to honor every declared target mode.
    packages/tools/src/builtins/page-tools.ts:165
  • The declared output rejects anonymous components. InspectResult.component is string | null (packages/protocol/src/page-introspect-types.ts:15-17), and react.inspect explicitly returns null when there is no display name, so agent/registry calls fail output validation for an otherwise valid inspection.
    packages/contract/src/contract.ts:50
  • This duplicate RPC schema is already looser than BUILTIN_OPEN_TOOL, whose file requires at least one character. A direct RPC call with file: '' passes contract validation and then fails inside the registry with an internal Zod error instead of being rejected at the RPC boundary.
export const EditorOpenInputSchema = z.object({file: z.string(), line: z.number().int().min(1).optional()})

.changeset/brave-tools-derive.md:5

  • The release note documents @conciv/tools/page, but the package exports only @conciv/tools/page-tools; consumers following this note will get ERR_PACKAGE_PATH_NOT_EXPORTED. Align the documented subpath with the package export.
Every built-in capability — page, server, and the `open` editor tool — is now declared as a registry tool with its own input/output schema and meta, importable from `@conciv/tools/builtins` and a UI-free `@conciv/tools/page` subpath for consumers that don't want Solid pulled in. `@conciv/extension` gains a matching `@conciv/extension/tool` subpath so the CLI and widget can share the same tool contract without loading the widget's rendering code. The CLI derives its command tree, flags, and help text directly from these declarations instead of hand-maintained argument parsing.
  • Files reviewed: 40/41 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@omridevk
omridevk merged commit b687236 into main Aug 5, 2026
23 checks passed
@omridevk
omridevk deleted the builtin-tools-229 branch August 5, 2026 18:40
@github-actions github-actions Bot mentioned this pull request Aug 7, 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.

registry: every built-in becomes a tool, and the CLI derives from them

2 participants