Skip to content

fix(cli): expose hunkdiff npm exec alias#295

Merged
benvinegar merged 1 commit into
modem-dev:mainfrom
zerone0x:fix/npx-exec-alias
May 12, 2026
Merged

fix(cli): expose hunkdiff npm exec alias#295
benvinegar merged 1 commit into
modem-dev:mainfrom
zerone0x:fix/npx-exec-alias

Conversation

@zerone0x
Copy link
Copy Markdown
Contributor

Summary

  • add hunkdiff as a second bin alias pointing at the existing wrapper
  • keep the staged prebuilt meta-package manifest in sync so published release artifacts expose the same alias
  • add a regression test that locks the package manifest to both hunk and hunkdiff

Fixes #276.

Verification

  • npx -y hunkdiff@0.11.1 --version currently fails with sh: 1: hunk: not found (reproduced locally against the published package)
  • packed a minimal local tarball with the updated manifest and confirmed npm exec --package=./hunkdiff-0.12.0-beta.2.tgz hunkdiff -- skill path resolves successfully
  • full Bun test suite not run here because Bun is not installed in this environment

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 12, 2026

Greptile Summary

This PR fixes issue #276 by adding hunkdiff as a second bin alias in both the root package.json and the staged meta-package manifest generated by scripts/stage-prebuilt-npm.ts, so npx hunkdiff resolves to the same ./bin/hunk.cjs wrapper as hunk.

  • package.json: hunkdiff entry added to bin — straightforward and correct.
  • scripts/stage-prebuilt-npm.ts: matching entry added to the hardcoded bin block in stageMetaPackage; the block is written literally rather than derived from rootPackage, so it will need a manual two-file update if further aliases are added.
  • test/cli/entrypoint.test.ts: regression test added that reads package.json at runtime and asserts both aliases are present; the staged manifest produced by stage-prebuilt-npm.ts is not covered by this test.

Confidence Score: 4/5

Safe to merge — the core fix is a minimal, correct two-line addition across package.json and the staging script; the only concern is structural and affects future maintainability.

The bin block in stageMetaPackage is hardcoded rather than derived from the root package.json, and the new regression test only guards the root manifest — not the staged artifact that actually gets published. A future alias addition that updates only package.json would silently omit the alias from the prebuilt release, reproducing the original bug.

scripts/stage-prebuilt-npm.ts — the hardcoded bin block is the place where drift is most likely to recur.

Important Files Changed

Filename Overview
package.json Adds hunkdiff as a second bin entry pointing to the same ./bin/hunk.cjs wrapper — minimal, correct change.
scripts/stage-prebuilt-npm.ts Adds hunkdiff to the hardcoded bin block in stageMetaPackage; the block is not derived from rootPackage, so future aliases will need a manual two-file update.
test/cli/entrypoint.test.ts New regression test locks package.json's bin field to both aliases, but does not exercise the staged meta-package produced by stage-prebuilt-npm.ts.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["npm exec hunkdiff\n/ npx hunkdiff"] --> B["npm resolves 'hunkdiff'\nbin alias in package.json"]
    C["npm exec hunk\n/ npx hunk"] --> D["npm resolves 'hunk'\nbin alias in package.json"]
    B --> E["./bin/hunk.cjs\n(CJS wrapper)"]
    D --> E
    E --> F["Launches Bun +\nsrc/main.tsx"]

    G["build:prebuilt:npm script"] --> H["stage-prebuilt-npm.ts"]
    H --> I["Staged meta-package\npackage.json\n(bin: hunk + hunkdiff)"]
    I --> J["Published npm artifact\nhunkdiff@x.y.z"]
Loading

Comments Outside Diff (1)

  1. scripts/stage-prebuilt-npm.ts, line 92-99 (link)

    P2 Hardcoded bin block won't track future aliases

    The bin field in the staged meta-package manifest is written out literally rather than derived from the root package.json. The RootPackageJson type doesn't include bin, so any new alias added to package.json in the future has to be mirrored here by hand. The regression test added in this PR guards package.json only — not the staged artifact — so a future divergence would slip through the same way issue Make it run with npx #276 originally did.

    Adding bin?: Record<string, string> to RootPackageJson and replacing the literal object with bin: rootPackage.bin would make the staging script self-healing and remove the need to keep both files in sync manually.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: scripts/stage-prebuilt-npm.ts
    Line: 92-99
    
    Comment:
    **Hardcoded `bin` block won't track future aliases**
    
    The `bin` field in the staged meta-package manifest is written out literally rather than derived from the root `package.json`. The `RootPackageJson` type doesn't include `bin`, so any new alias added to `package.json` in the future has to be mirrored here by hand. The regression test added in this PR guards `package.json` only — not the staged artifact — so a future divergence would slip through the same way issue #276 originally did.
    
    Adding `bin?: Record<string, string>` to `RootPackageJson` and replacing the literal object with `bin: rootPackage.bin` would make the staging script self-healing and remove the need to keep both files in sync manually.
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
scripts/stage-prebuilt-npm.ts:92-99
**Hardcoded `bin` block won't track future aliases**

The `bin` field in the staged meta-package manifest is written out literally rather than derived from the root `package.json`. The `RootPackageJson` type doesn't include `bin`, so any new alias added to `package.json` in the future has to be mirrored here by hand. The regression test added in this PR guards `package.json` only — not the staged artifact — so a future divergence would slip through the same way issue #276 originally did.

Adding `bin?: Record<string, string>` to `RootPackageJson` and replacing the literal object with `bin: rootPackage.bin` would make the staging script self-healing and remove the need to keep both files in sync manually.

Reviews (1): Last reviewed commit: "fix(cli): expose hunkdiff npm exec alias" | Re-trigger Greptile

@benvinegar benvinegar merged commit fcd6b83 into modem-dev:main May 12, 2026
6 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.

Make it run with npx

2 participants