Skip to content

feat(routes): CLI projection input: 'json' takes canonical tool input through --input (#746) - #760

Merged
ScriptedAlchemy merged 3 commits into
mainfrom
feat/746-cli-json-input
Sep 8, 2026
Merged

feat(routes): CLI projection input: 'json' takes canonical tool input through --input (#746)#760
ScriptedAlchemy merged 3 commits into
mainfrom
feat/746-cli-json-input

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Closes #746.

Stacked on #757 (branch contains its commits; rebases onto main once #757 lands).

What

A <tool>.cli.ts projection may declare input: 'json'. The command then takes the tool's canonical input as one JSON object through --input '<json>' — exactly the path the bulk routes.mcpCommands projection already runs (parseMcpCommandInput is shared) — and never reads the tool's argv grammar. This is the mode for a schema the bounded grammar cannot express (nested object, union, transform): the object reaches the tool's own inputSchema unchanged, so the tool contract is not weakened, schema issues are spelled under --input.<path>, a non-object --input exits 2 before the tool runs, and command, aliases, description, confirm (--yes) and exitCode behave as for a flag-bound projection.

  • AB4814 on a projected tool now recovers with this mode.
  • Combining input: 'json' with flags, positionals, or a mapInput export is AB4844 (no merge precedence to define).
  • Help, inspect --routes, and agent-bundle.manifest.json record projection.input: "json"; the closed artifact contract advances to manifestVersion 5 (schema, lean web reader, key inventory v5).

Tests

  • New fixture route-harness tool select (discriminated union under a nested object) + select.cli.tsx JSON projection.
  • tests/projection/cli-dispatch-json-projection.test.ts: compiled command shape, CLI ≡ MCP result with nested defaults, non-object --input refusal, --input.<path> issue spelling, --yes confirmation, help text.
  • tests/packed-stdio-projection.test.ts: the same command from the source-free packed bin.
  • cli-projection.test.ts, manifest-schema.test.ts, web-manifest.test.ts, manifest-key-inventory.test.ts, contract matrix, in-memory MCP, harness manifest updated.

Docs

en+zh: guide/authoring/package-entries.mdx (JSON mode), reference/artifact-manifest.mdx and guide/concepts/architecture.mdx (manifestVersion 5, projection.input), docs/diagnostics.md (AB4814/AB4844/AB7001), docs/entry-conventions.md. Changeset: .changeset/746-cli-projection-json-input.md (agent-bundle minor — manifest contract bump).

Local gate (current main + #757)

  • pnpm build && pnpm typecheck && pnpm lint — pass
  • pnpm test:unit — 4479 pass; 4 timeout-driven failures under concurrent load pass when rerun alone (106/106)
  • pnpm test:projection — 197 pass; pnpm test:route-unit — 90 pass
  • integration pool + packed pool + pnpm docs:site:build — in progress, results appended below

Deslop: Claude Fable, 2 edits (helper placement in cli-entry.ts, issue ref in a type comment).

Self-review

Pending.

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf01e9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
agent-bundle Minor
create-agent-bundle Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T00:49:23.854997Z 58a4504 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@760
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@760
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/rsc-markdown-stream@760
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@760

commit: 48853fc

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58a45045d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

* full parser in `build/manifest.ts` refuse the same set of documents.
*/
export const artifactManifestVersion = 4;
export const artifactManifestVersion = 5;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Update every manifest-version consumer to v5

With this bump, inspect renders v5 from the built manifest, but packages/agent-bundle/tests/cli.test.ts:634 still expects Built manifest: v4, so the required unit-test gate fails whenever that case runs. The public target/artifact references also still advertise version 4 in both locales (website/docs/en/reference/targets-artifacts.mdx:59,161,169 and the corresponding Chinese lines 54, 144, and 151); update these consumers as part of the version bump.

AGENTS.md reference: AGENTS.md:L128-L142

Useful? React with 👍 / 👎.

Comment on lines +1 to +3
---
"agent-bundle": minor
"create-agent-bundle": patch

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Split the stacked release into one changeset per PR

This commit adds this #757 changeset alongside .changeset/746-cli-projection-json-input.md, while changing the publishable agent-bundle and create-agent-bundle packages. The repository requires exactly one changeset per PR, so the stacked base must be separated before this change is merged rather than carrying two independent release records.

AGENTS.md reference: AGENTS.md:L159-L164

Useful? React with 👍 / 👎.

Comment on lines +80 to +81
const consumesRegistration = (fileNames: readonly string[]): boolean =>
fileNames.some((fileName) => !fileName.endsWith('.d.ts') && consumerImport.test(ts.sys.readFile(fileName) ?? ''));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Check authored declaration consumers for AB4834

When a program consumes the registration only from an authored declaration file—for example, types/routes.d.ts imports AppRouteInput or ProviderValue to expose an application type—this predicate unconditionally skips that file. If the program omits .agent-bundle/routes.d.ts, validate therefore emits no AB4834 even though those exported types silently degrade to unknown; distinguish external/generated declarations from authored .d.ts inputs instead of excluding all declaration files.

Useful? React with 👍 / 👎.

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

Codex first-pass findings, addressed locally:

  1. Manifest-version consumers still at v4cli.test.ts:634 now expects Built manifest: v5; reference/targets-artifacts.mdx (en 59/161/169, zh 54/144/151) advanced to 5 (eec9852). Swept the rest of website/docs, docs/, tests, and Workbench for manifestVersion 4 — only the historical audit note and the retained manifest-keys.v4.json inventory fixture remain, by design.
  2. Two changesets — the branch is stacked on feat(routes): type callers by schema input; per-program AB4834; validate before typecheck (#748, #752) #757, whose changeset rides along; once feat(routes): type callers by schema input; per-program AB4834; validate before typecheck (#748, #752) #757 lands this branch rebases onto main and carries only .changeset/746-cli-projection-json-input.md. Merge order is feat(routes): type callers by schema input; per-program AB4834; validate before typecheck (#748, #752) #757feat(routes): CLI projection input: 'json' takes canonical tool input through --input (#746) #760.
  3. AB4834 skipped authored .d.ts — that predicate is feat(routes): type callers by schema input; per-program AB4834; validate before typecheck (#748, #752) #757's first commit; feat(routes): type callers by schema input; per-program AB4834; validate before typecheck (#748, #752) #757 already replaced it (ts.preProcessFile over every file of the program, including authored .d.ts, and now the program's full import closure). This branch inherits the fix on rebase.

The failed Examples check (host-test slow probe rendered with tickMs: 40 against a min(50) schema) and integration-1 (cli.test.ts v4) are those same two root causes; the first is fixed on #757 (17924a5).

@ScriptedAlchemy

Copy link
Copy Markdown
Owner Author

Rebased onto main after #757 merged (bf01e9e); the tree is byte-identical to the gated tip 48853fc (git diff 48853fc bf01e9e is empty), so the recorded gate stands: pnpm build, pnpm typecheck, pnpm lint, pnpm test:unit, projection pool, packed stdio projection, pnpm docs:site:build, cli.test.ts (v5 manifest summary) — all green. Only this PR's changeset remains now that #757's landed. Independent local review (Fable): nothing blocks.

@ScriptedAlchemy
ScriptedAlchemy merged commit 810f56f into main Sep 8, 2026
3 checks passed
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.

[P2] Let a named CLI projection accept canonical JSON when its tool schema cannot map to flags; do not make authors weaken the tool contract

1 participant