Skip to content

feat(coding): generate detectSupportedImageMimeType via fluessig (bytes path)#338

Draft
zmaril wants to merge 1 commit into
napi-fluessig/float-fuzzyfrom
napi-fluessig/bytes-image-mime
Draft

feat(coding): generate detectSupportedImageMimeType via fluessig (bytes path)#338
zmaril wants to merge 1 commit into
napi-fluessig/float-fuzzyfrom
napi-fluessig/bytes-image-mime

Conversation

@zmaril

@zmaril zmaril commented Jul 21, 2026

Copy link
Copy Markdown
Owner

What

Swaps the hand-written detectSupportedImageMimeType napi export (utils/mime.ts) for a fluessig-generated op, proving the fluessig #74 bytes path at the bumped pin (e056bb9): a bytes param lowers to Uint8Array in the node .d.ts (position-aware; a bytes return would lower to Buffer).

Stacked on napi-fluessig/float-fuzzy (the f64/uint32 fuzzy swap).

The bytes question (the point of this PR)

bytes byte-matched the hand-written .d.ts exactly. The image buffer arg — hand-written as napi::bindgen_prelude::Uint8Array — is authored in schema/api.json as the bytes scalar, and the node backend spells it Uint8Array for a PARAM. The generated .d.ts block, .js export, and nativeBinding entry are byte-identical to a pre-swap build of the base; the symbol only changes position (moving into the generated block), exactly as the prior fuzzy swap did.

export declare function detectSupportedImageMimeType(buffer: Uint8Array): string | null

Changes

  • schema/api.json: add the op to the Pidgin interface (bytes param, nullable string return, infallible/readonly).
  • src/core_impl.rs: delegate into pidgin_coding::utils::mime — the same logic the hand-written export called.
  • src/generated.rs: regenerated (fluessig e056bb9).
  • src/lib.rs: delete the hand-written #[napi] export; keep pub mod generated;.

Verification

  • Byte-diff vs pre-swap build of base: .d.ts block + .js export + nativeBinding entry byte-identical (only position moves).
  • 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 on git archive HEAD: 0 errors (1 unrelated pre-existing warning in conformance/STEWARD.md).
  • Oracle: the conformance manifest marks mime.ts native with tests: [] (pi's upstream tests aren't vendored in-repo, and the roadmap's image-process.test.ts is mixed / not separable here), so the separable detectSupportedImageMimeType case is checked directly against the locally-built addon — all 6 magic-byte cases (PNG / JPEG / JPEG-fractional-null / GIF / non-image-null / empty-null) pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xL2W7dkhPsTSRuXQNCDeY


Generated by Claude Code

…es path)

Swap the hand-written `detectSupportedImageMimeType` napi export
(utils/mime.ts) for a fluessig-generated op, proving the #74 bytes path:
the image buffer arg is authored as the `bytes` scalar and lowers to
`Uint8Array` in the node `.d.ts` (a read-only view over the JS bytes),
byte-matching the deleted hand-written `Uint8Array` param. The sniffed
MIME type crosses back as `string | null`.

- schema/api.json: add the op to the Pidgin interface (bytes param,
  nullable string return, infallible/readonly).
- core_impl: delegate into `pidgin_coding::utils::mime`, the same logic
  the hand-written export called.
- regen src/generated.rs (fluessig e056bb9); delete the hand-written
  `#[napi]` export from lib.rs; keep `pub mod generated;`.

The generated `.d.ts` block, `.js` export, and nativeBinding entry are
byte-identical to the pre-swap build.

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/1295 (5.7%) 8 553/1295 3 739
tui 375/678 (55.3%) 14 678/678 0 0
smoke total 504/2153 (23.4%) 27 1411/2153 3 739

agent: 55/180 (30.6%) · ai: 74/1295 (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