Skip to content
This repository was archived by the owner on Apr 21, 2026. It is now read-only.

fix: forge-patterns bin entry pointed at non-existent dist/cli.js#202

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
fix/forge-patterns-bin
Apr 7, 2026
Merged

fix: forge-patterns bin entry pointed at non-existent dist/cli.js#202
LucasSantana-Dev merged 1 commit into
mainfrom
fix/forge-patterns-bin

Conversation

@LucasSantana-Dev
Copy link
Copy Markdown
Member

@LucasSantana-Dev LucasSantana-Dev commented Apr 7, 2026

Summary

  • package.json declared bin.forge-patterns: "dist/cli.js", but src/cli.ts was never created and dist/cli.js was never built. Every npm consumer of v1.4.0–v1.14.0 that ran npx @forgespace/core forge-patterns got an ENOENT — a silent breakage that has been live since March 6, 2026 (commit f0d1aa3).
  • Repointed bin.forge-patterns at the existing scripts/forge-patterns-cli.js (already shipped under pkg.files, has a #!/usr/bin/env node shebang). Marked the script executable.
  • Added src/bin-entries.test.js (parameterised over pkg.bin, 19 generated tests) that asserts every bin entry resolves to a real file, has a node shebang, and lives under a path declared in pkg.files. Verified locally that this test fails when bin.forge-patterns points back at the missing dist/cli.js, so it would have caught the original regression.
  • Patch release: 1.14.01.14.1. Regenerated etc/core.api.md (api-extractor picked up the VERSION constant change).

How the bug slipped in

PR #76 (March 6) added three new bin entries (forge-scorecard, forge-policy, …) but kept the pre-existing forge-patterns: dist/cli.js line untouched. That line had been pointing at a non-existent target since the very first commit. There was no test asserting bin entries resolved, so npm published happily for a year.

Test plan

  • npm run build — green
  • npm test — 29 suites, 674 tests pass (19 of which are the new bin-entries assertions)
  • npm run lint:check — no errors (9 pre-existing magic-number warnings, untouched)
  • npm run format:check — green
  • npm run api:check — green
  • Mutation test: locally reverted bin.forge-patterns to dist/cli.js, ran the new test, confirmed it fails on the existence assertion. Restored.

Summary by CodeRabbit

  • Bug Fixes

    • Corrected the forge-patterns CLI command resolution, which was pointing to a non-existent target file and is now properly configured.
  • Tests

    • Added regression tests to validate that all CLI binary entries resolve correctly and are properly included in the package.

The package.json bin block declared
  "forge-patterns": "dist/cli.js"
but no src/cli.ts ever existed and dist/cli.js was never built. Every
npm consumer of v1.4.0..v1.14.0 that ran 'npx @forgespace/core
forge-patterns' got an ENOENT — a silent breakage that has been live
for over a month.

The actual implementation is scripts/forge-patterns-cli.js, which is
already published via pkg.files and has a node shebang. This commit:

- points bin.forge-patterns at scripts/forge-patterns-cli.js
- marks scripts/forge-patterns-cli.js as executable
- adds src/bin-entries.test.js (parameterised over pkg.bin) to assert
  that every bin entry resolves to a real file, has a node shebang,
  and lives under a path declared in pkg.files
- bumps VERSION + package.json to 1.14.1
- regenerates etc/core.api.md (api-extractor picked up VERSION change)
- CHANGELOG entry under [1.14.1]
@LucasSantana-Dev LucasSantana-Dev requested a review from a team as a code owner April 7, 2026 22:03
@github-actions github-actions Bot added the size/S label Apr 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b719e1b-b817-49e1-af02-6277402f7888

📥 Commits

Reviewing files that changed from the base of the PR and between 28cea54 and e1b4bb7.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • etc/core.api.md
  • package.json
  • scripts/forge-patterns-cli.js
  • src/bin-entries.test.js
  • src/index.ts

📝 Walkthrough

Walkthrough

Version 1.14.1 fixes a regression in the forge-patterns npm bin entry, pointing it to an existing shipped script instead of a non-existent distributed file. A new test suite validates that all bin entries reference real files with proper Node shebangs within packaged directories.

Changes

Cohort / File(s) Summary
Version Updates
CHANGELOG.md, etc/core.api.md, src/index.ts
Bumped version from 1.14.0 to 1.14.1 across documentation and source files.
npm Binary Fix
package.json
Updated forge-patterns bin entry from dist/cli.js to scripts/forge-patterns-cli.js; version bumped to 1.14.1.
Bin Validation Test
src/bin-entries.test.js
New regression test suite that validates all pkg.bin entries resolve to existing files, contain Node shebang, and reside within packaged directories.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A script was lost in dist so deep,
The patterns CLI couldn't leap,
But scripts/ held the answer true,
With tests to catch what breaks anew!
One-fourteen-one, the fix is baked! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary fix: correcting the forge-patterns bin entry that pointed to a non-existent dist/cli.js file, which is the main regression addressed in this changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/forge-patterns-bin

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.17.0)
package.json

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

src/bin-entries.test.js

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m

src/index.ts

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Project Scorecard


Scorecard: 84/100 (B)
────────────────────────────────────────
  security: 100/100 (A)
  quality: 80/100 (B) — 1 violations
  performance: 67/100 (D) — 1 violations
  compliance: 75/100 (C) — 1 violations
  dependency: 100/100 (A)

Recommendations:
  - Increase test coverage to meet the 80% threshold
  - Extend log retention to at least 90 days for compliance

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 7, 2026

Forge AI Quality Gate

Passed — Score 100/100 (A+) · Delta +0 · 0 new findings

Category scores
Category Score
test-autogen 100

Powered by Forge AI Action · forgespace.co

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 7, 2026

@LucasSantana-Dev LucasSantana-Dev merged commit e0ed34a into main Apr 7, 2026
32 checks passed
@LucasSantana-Dev LucasSantana-Dev deleted the fix/forge-patterns-bin branch April 7, 2026 22:10
LucasSantana-Dev added a commit to Forge-Space/forge-ai-init that referenced this pull request Apr 7, 2026
Parameterised test (tests/bin-entries.test.ts) that iterates over
every pkg.bin entry and asserts:
- target file exists on disk
- target starts with a node shebang
- target lives under a directory declared in pkg.files

This prevents the regression class that shipped in @forgespace/core
v1.4.0-v1.14.0, where bin.forge-patterns pointed at a non-existent
dist/cli.js for over a year. See Forge-Space/core#202 for the
original incident.

Mutation-tested locally: reverting bin.forge-ai-init to point at a
non-existent path makes the test fail on the existence assertion,
proving the guard catches real breakage.
LucasSantana-Dev added a commit to Forge-Space/branding-mcp that referenced this pull request Apr 7, 2026
Parameterised test (src/__tests__/bin-entries.test.ts) iterating over
every pkg.bin entry to assert target existence, node shebang, and
pkg.files coverage. Prevents the regression class that shipped in
@forgespace/core v1.4.0-v1.14.0. See Forge-Space/core#202.

Mutation-tested locally.
LucasSantana-Dev added a commit to Forge-Space/ui-mcp that referenced this pull request Apr 7, 2026
Parameterised test (src/__tests__/bin-entries.unit.test.ts) that
iterates over every pkg.bin entry and asserts:
- target file exists on disk
- target starts with a node shebang
- target lives under a directory declared in pkg.files

Prevents the regression class that shipped in @forgespace/core
v1.4.0-v1.14.0 where bin.forge-patterns pointed at a non-existent
dist/cli.js for over a year. See Forge-Space/core#202.

Mutation-tested locally: reverting the bin to point at a non-existent
path makes the test fail, proving the guard catches real breakage.
LucasSantana-Dev added a commit to Forge-Space/forge-ai-init that referenced this pull request Apr 8, 2026
* test: add bin-entries regression guard

Parameterised test (tests/bin-entries.test.ts) that iterates over
every pkg.bin entry and asserts:
- target file exists on disk
- target starts with a node shebang
- target lives under a directory declared in pkg.files

This prevents the regression class that shipped in @forgespace/core
v1.4.0-v1.14.0, where bin.forge-patterns pointed at a non-existent
dist/cli.js for over a year. See Forge-Space/core#202 for the
original incident.

Mutation-tested locally: reverting bin.forge-ai-init to point at a
non-existent path makes the test fail on the existence assertion,
proving the guard catches real breakage.

* ci: build dist before jest so bin-entries test can resolve files

Without pretest=build, bin-entries.test.ts asserts against dist/index.js
that does not exist yet in CI (jest runs before the build step), producing
a false-positive failure. A pretest hook guarantees dist/ exists in every
invocation path (CI, local, validate).
LucasSantana-Dev added a commit to Forge-Space/branding-mcp that referenced this pull request Apr 8, 2026
* test: add bin-entries regression guard

Parameterised test (src/__tests__/bin-entries.test.ts) iterating over
every pkg.bin entry to assert target existence, node shebang, and
pkg.files coverage. Prevents the regression class that shipped in
@forgespace/core v1.4.0-v1.14.0. See Forge-Space/core#202.

Mutation-tested locally.

* ci: build dist before jest so bin-entries test can resolve files

Without pretest=build, bin-entries.test.ts asserts against dist/index.js
that does not exist yet in CI (jest runs before the build step), producing
a false-positive failure. A pretest hook guarantees dist/ exists in every
invocation path (CI, local, validate).

* ci: also build before test:coverage so bin-entries resolves dist/

CI runs `npm run test:coverage` (not `npm test`) so the pretest hook
did not fire and dist/ was still missing when bin-entries.test.ts asserted
on dist/index.js. Add matching pretest:coverage hook to cover every test
lifecycle invocation path.
LucasSantana-Dev added a commit to Forge-Space/ui-mcp that referenced this pull request Apr 8, 2026
* test: add bin-entries regression guard

Parameterised test (src/__tests__/bin-entries.unit.test.ts) that
iterates over every pkg.bin entry and asserts:
- target file exists on disk
- target starts with a node shebang
- target lives under a directory declared in pkg.files

Prevents the regression class that shipped in @forgespace/core
v1.4.0-v1.14.0 where bin.forge-patterns pointed at a non-existent
dist/cli.js for over a year. See Forge-Space/core#202.

Mutation-tested locally: reverting the bin to point at a non-existent
path makes the test fail, proving the guard catches real breakage.

* ci: build dist before jest so bin-entries test can resolve files

Without pretest=build, bin-entries.test.ts asserts against dist/index.js
that does not exist yet in CI (jest runs before the build step), producing
a false-positive failure. A pretest hook guarantees dist/ exists in every
invocation path (CI, local, validate).

* ci: also build before test:coverage so bin-entries resolves dist/

CI runs `npm run test:coverage` (not `npm test`) so the pretest hook
did not fire and dist/ was still missing when bin-entries.unit.test.ts
asserted on dist/index.js. Add matching pretest:coverage hook to cover
every test lifecycle invocation path.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant