Repository navigation
fix(setup): run Charter through the package manager in the generated workflow (#380) - #388
Merged
Merged
Conversation
…workflow (#380) The charter-governance.yml template ran a bare `npx charter`, which fetches the unrelated `charter` registry package when @stackbilt/cli is not installed. Steps now run `pnpm exec charter` (pnpm) or `npm exec --no --package=@stackbilt/cli -- charter` (npm). Neither fetches anything, and the npm form keeps `charter validate --ci` in the step so doctor's gate-enforcement check still recognizes it. The template has no Yarn form, so none is added. The new templates are the current safe KNOWN_WORKFLOWS entries. The 003ec8d templates move to the history fixture, still safe (same permissions and triggers) with a refreshChanges that says what changes; the guard tests now check that a safe historical template differs from the current one only in how Charter is run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egistry); qualify the devDependencies claim Review of #388: with no local CLI, npm exec --no still resolves @stackbilt/cli's metadata before refusing, so 'fetches nothing' was too strong. setup does not add the dependency under --no-dependency-sync or without a root package.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #380
Problem
The workflow that
charter setup --ci github/charter bootstrap --ci githubgenerates (getGithubWorkflowinsetup.ts) runs Charter as a barenpx charter …. If@stackbilt/cliis not installed,charterresolves to the unrelated registry package (0.0.2, which has no bin).Fix
New
workflowCharterCommand(pm)insetup.ts, used for all six steps:pnpm exec charter …npm exec --no --package=@stackbilt/cli -- charter …detectPackageManagerreturns'npm' | 'pnpm'), so I did not add Yarn support. A Yarn repo gets the npm form, as before.Why this npm form
I tested each candidate for real with npm 10.8.2 (what Node 20 ships in CI) and npm 11.17.0, using a clean
npm_config_prefix/npm_config_cacheand no global Charter.@stackbilt/cliinstalled locallynpx charter --version(old)charter, thencould not determine executable to runnpx --no-install @stackbilt/cli --versioncharter v2.1.0npx canceled due to missing packages and no YES option, exit 1npm exec --no -- @stackbilt/cli --versioncharter v2.1.0npm exec --no --package=@stackbilt/cli -- charter --versioncharter v2.1.0All three new forms behave the same. I picked the
--package=… -- charterone for two reasons:--no-installis the deprecated spelling. npm 11 warnsUnknown cli config "--install"when it is passed throughnpm exec.invokesCharterValidateindoctor-gate-enforcement.ts) looks forcharter validate … --ci.@stackbilt/cli validatewould not match, so doctor would warn that a repo using the generated workflow has no CI gate. This form keepscharter validatein the step, anddoctor-gate-enforcement.ts(being changed in fix(hook): resolve Charter through the repo package manager in the pre-commit hook (#366) #379) stays untouched.setupandbootstrapadd@stackbilt/clitodevDependencies(not under--no-dependency-sync, nor without a rootpackage.json), so the install step provides it. With no local CLI the npm form still queries the registry for@stackbilt/climetadata before refusing, but installs and runs nothing.Known-template table (#374)
safeentries inKNOWN_WORKFLOWS.safe: true(silent refresh), with an accurateoriginand arefreshChangesthat says what the refresh changes.fixtures/charter-governance-history.jsonwith"safe": true.jobs:and differs from it only in how Charter is run. Unsafe ones are checked as before.#380(the commit hash isn't known before merge), so the origin regex now also accepts#\d+.#379 (#366, the hook) is not merged. Its package-manager logic is resolved at runtime in the hook's shell script, and there was no shared TS helper to reuse.
Tests
setup.test.ts:run:line uses the package-manager form, and none usesnpx.checkGateEnforcement()returns PASS for the generated npm and pnpm workflows.workflow-mcp-backup.test.ts: the known-list and fixture checks above, and silent-refresh tests throughbootstrap --yesandsetupfor the 003ec8d npm and pnpm templates.setup --ci github --yeswritesnpm exec --no --package=@stackbilt/cli -- charter …steps.Docs:
docs/ci-integration.mdnotes how the steps run Charter and that the previous template is refreshed silently.🤖 Generated with Claude Code