Skip to content

feat(agent): generate parseCommandArgs and substituteArgs via fluessig#324

Draft
zmaril wants to merge 1 commit into
napi-fluessig/session-cwdfrom
napi-fluessig/prompt-templates
Draft

feat(agent): generate parseCommandArgs and substituteArgs via fluessig#324
zmaril wants to merge 1 commit into
napi-fluessig/session-cwdfrom
napi-fluessig/prompt-templates

Conversation

@zmaril

@zmaril zmaril commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Swap the hand-written #[napi] prompt-template helpers (agent harness/prompt-templates.ts) to the fluessig-generated path.

Module 13 of the pidgin-napi → fluessig campaign (module 3 of this stacked batch of 3, and the first swap in the agent package). Stacked on napi-fluessig/session-cwd (#323).

What changed

  • Author parseCommandArgs + substituteArgs ops in schema/api.json.
  • Add the 2 core_impl delegations reaching the same pidgin_agent::harness::prompt_templates functions the hand-written exports called.
  • Regenerate src/generated.rs; delete the hand-written exports from src/agent.rs.

Signatures

  • parseCommandArgs(argsString: string) -> Array<string> (string → list).
  • substituteArgs(content: string, args: Array<string>) -> stringargs is the first Vec<String> param in the schema; fluessig lowers the list param to args: Vec<String> with no gap.

Gates

  • Byte-diff vs a pre-swap build of the base: each swapped symbol's .d.ts JSDoc+signature block, .js module.exports line, and nativeBinding destructure entry are byte-identical (only file position moves into the generated cluster).
  • cargo build -p pidgin-napi, cargo fmt --all --check, cargo clippy -p pidgin-napi --all-targets -- -D warnings clean; codespell 0.
  • straitjacket v0.2.3: 0 errors.
  • Oracle slice agent/test/harness/prompt-templates.test.ts: 5/5 pass against the locally-built generated addon.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xL2W7dkhPsTSRuXQNCDeY


Generated by Claude Code

Swap the hand-written `#[napi]` prompt-template helpers (agent
harness/prompt-templates.ts: `parseCommandArgs`, `substituteArgs`) to the
fluessig-generated path: author the two ops in schema/api.json, add the two
`core_impl` delegations to core_impl.rs, regenerate src/generated.rs, and delete
the hand-written exports from src/agent.rs.

This is the first swap in the `agent` package. Both ops are proven primitive
shapes: `parseCommandArgs(argsString: string) -> Array<string>` (string ->
list) and `substituteArgs(content: string, args: Array<string>) -> string`,
where `args` is the first `Vec<String>` PARAM in the schema — fluessig lowers the
`list` param to `args: Vec<String>` with no gap. The `core_impl` methods reach the
SAME `pidgin_agent::harness::prompt_templates` functions the hand-written exports
called (`parse_command_args` and `substitute_args`, the latter borrowing the args
as `&[&str]`), so JS-visible behavior is byte-for-byte unchanged.

Verified: each swapped symbol's generated `.d.ts` JSDoc+signature block, its `.js`
`module.exports` line, and its nativeBinding destructure entry are byte-identical
to a pre-swap build of the base (only file position moves into the generated
cluster). cargo build/fmt/clippy clean; codespell 0; straitjacket 0 errors; the
prompt-templates oracle slice (agent/test/harness/prompt-templates.test.ts, 5
tests) passes 5/5 against the locally-built generated addon.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017xL2W7dkhPsTSRuXQNCDeY
@github-actions

Copy link
Copy Markdown

Conformance smoke: agent + ai + tui

  • pi_sha: 3da591ab74ab9ab407e72ed882600b2c851fae21
  • manifest_native_modules: 45

Headline is rust-backed: passing cases in files whose module-under-test is a native (Rust addon) module. Raw all-pass is shown secondary — it is inflated by unflipped TypeScript that passes without touching any Rust.

Package rust-backed Native modules raw pass (secondary) Failing Skipped
agent 55/180 (30.6%) 5 180/180 0 0
ai 74/1293 (5.7%) 8 553/1293 3 737
tui 375/678 (55.3%) 14 678/678 0 0
smoke total 504/2151 (23.4%) 27 1411/2151 3 737

agent: 55/180 (30.6%) · ai: 74/1293 (5.7%) · tui: 375/678 (55.3%)

rust-backed = passing / total tests run, per the manifest's per-native-row tests lists. The Native modules column counts modules served by the Rust addon. This is the agent+ai+tui smoke subset; the full baseline lives in committed conformance.json.

Attribution

A pi test file is rust-backed iff the module it primarily exercises — its module-under-test — is status=native in conformance/manifest.json. A package's rust-backed count is the passing cases in its rust-backed files. Transitive or infrastructure use does not count (e.g. ~30 ai files construct the native faux provider but test other things — only faux-provider.test.ts, whose subject is faux, counts). A file that substantially tests both a native and an original module is excluded rather than counted, so the number under-reports rather than over-claims.

Per-file decisions (from each native manifest row's tests list):

Native module Test file Decision
ai/api/anthropic-messages.ts test/anthropic-sse-parsing.test.ts counted
ai/providers/faux.ts test/faux-provider.test.ts counted
coding-agent/utils/ansi.ts test/ansi-utils.test.ts counted
coding-agent/utils/changelog.ts test/changelog.test.ts counted
coding-agent/utils/git.ts test/git-ssh-url.test.ts counted
coding-agent/core/tools/path-utils.ts test/path-utils.test.ts counted
tui/keys.ts test/keys.test.ts counted
tui/utils.ts test/truncate-to-width.test.ts, test/regression-regional-indicator-width.test.ts counted
coding-agent/utils/mime.ts test/image-process.test.ts mixed — excluded (2 of 3 cases test processImage/original)
coding-agent/utils/version-check.ts test/version-check.test.ts mixed — excluded (fetch cases mock the original; not separable per-file)
coding-agent/core/export-html/ansi-to-html.ts test/export-html-whitespace.test.ts mixed — excluded (asset-grep + tool-renderer/original dominate)
coding-agent/core/tools/truncate.ts no dedicated test (exercised via tools.test.ts, subject is the read/edit factory/original)
coding-agent/core/tools/edit-diff.ts no dedicated test (edit-tool tests' subject is the edit tool/original)

CLI conformance (black-box, against the pidgin binary)

  • CLI conformance: 15/15 pass against target/release/pidgin (pass delta ±0, fail delta ±0).
File Passing Failing Skipped
packages/coding-agent/test/session-file-invalid.test.ts 1 0 0
packages/coding-agent/test/session-id-readonly.test.ts 7 0 0
packages/coding-agent/test/startup-session-name.test.ts 2 0 0
packages/coding-agent/test/stdout-cleanliness.test.ts 5 0 0

The four repointed coding-agent CLI test files spawn the compiled pidgin binary via $PIDGIN_BIN instead of pi's own cli.ts. This is a separate signal from the module smoke table and is never folded into the per-package Native count.

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