fix(cli): tolerate the -- separator pnpm injects when forwarding script args (#3114)#3118
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
…ript args (#3114) The AGENTS.md-documented `pnpm dev -- --fresh -p <port>` failed at the repo root with an opaque `Unexpected arguments: -p, 44637` (exit 2 + a help dump). pnpm appends forwarded args to a script verbatim, *including the `--`*, and each nested `pnpm --filter` hop preserves it, so the showcase's `objectstack dev --seed-admin` ran as `objectstack dev --seed-admin -- --fresh -p 44637`. oclif reads `--` as POSIX end-of-flags, so everything after it became positional: `--fresh` was silently swallowed as the `package` arg and `-p 44637` overflowed the arg list. Every flag the user asked for was dropped. A `preparse` hook now drops `--` separators before oclif parses argv, so the npm-style `-- <flags>` form and the bare form behave identically, for every command and both bins. No `os` command takes passthrough args (none sets `strict = false`, none reads raw argv), so a `--` is always a package-manager artifact here. Not fixable via oclif's `'--': false` option: that keeps flag-parsing on past the separator but re-appends the `--` into argv, so strict commands fail with `Unexpected argument: --` instead. Verified end-to-end: `pnpm dev -- --fresh -p 44639` now boots the showcase on :44639 with an ephemeral tempdir and a seeded admin. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
xuyushun441-sys
force-pushed
the
fix/cli-pnpm-dashdash-3114
branch
from
July 17, 2026 11:58
d4db2a1 to
28adf34
Compare
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.
Fixes #3114.
The bug
The AGENTS.md-documented backend-debug flow fails at the repo root:
This is the canonical multi-agent flow, so every agent following AGENTS.md hits it.
Root cause
pnpm appends forwarded args to a script verbatim, including the
--, and each nestedpnpm --filterhop preserves it. Confirmed by isolating each hop:pnpm run x -- --fresh -p N-- --fresh -p N← pnpm keeps the--pnpm run x --fresh -p N--fresh -p Npnpm --filter c dev --fresh -p Npnpm --filter c dev -- --fresh -p N--preserved verbatimSo the showcase's
objectstack dev --seed-adminruns as:oclif reads
--as POSIX end-of-flags, so everything after it becomes positional. The failure is worse than the issue reports:--freshis silently swallowed as thepackagearg (note the error only names-p, 44637), so even the flags oclif accepts are dropped. It's opaque precisely because the--looks inert.Fix
A
preparsehook drops--separators before oclif parses argv — a single choke point covering every command and both bins (run.js,run-dev.js), including future commands.No
oscommand takes passthrough args (none setsstrict = false, none reads raw argv), so a--carries no meaning here and is always a package-manager artifact.Why not the fix suggested in the issue
The issue proposed oclif's
'--'passthrough option. I tested it against the real parser — it does not work, it just trades one error for another:'--': falsekeeps flag-parsing on past the separator but then re-appends the--into argv (parse.js#L188), so strict commands fail on it instead.The docs need no change — this makes the documented row true. Keeping the
--form is also the safer pnpm form: it guarantees pnpm forwards flags verbatim rather than eating ones that collide with its own.Tradeoff
A
--prefixed token can no longer be forced to parse as a positional value. Everyospositional is a config path, a metadata/datasource/package name, or an id — none start with-. Noted in the hook for whoever adds a passthrough command later.Verification
Ran the exact documented command end-to-end. It is still invoked with the
--present (objectstack dev --seed-admin -- --fresh -p 44639), yet all three flags now take effect:Live probe returned HTTP 401 from
/api/v1/meta/object(server up, auth enforced); server torn down after.Devcommand's flags through oclif's actual parser — including a regression test proving the failure without the hook.@objectstack/cli: build/typecheck ✅ · lint ✅ · 538 tests ✅dev:crm/dev:todouse the sameobjectstack devpath and are fixed by the same change.🤖 Generated with Claude Code