Skip to content

fix(cli): use flag terminator constant - #84438

Closed
humanbeingz-7 wants to merge 3 commits into
openclaw:mainfrom
humanbeingz-7:fix/issue-83902
Closed

humanbeingz-7 wants to merge 3 commits into
openclaw:mainfrom
humanbeingz-7:fix/issue-83902

Conversation

@humanbeingz-7

@humanbeingz-7 humanbeingz-7 commented May 20, 2026 •

Copy link
Copy Markdown

Summary

  • replace the hardcoded -- comparison in command path parsing with FLAG_TERMINATOR
  • update the argv terminator regression test to use the shared constant
  • add a CLI invocation regression test proving after-terminator tokens do not affect command-path resolution

Fixes #83902

Test plan

  • corepack pnpm exec vitest run src/cli/argv.test.ts src/cli/argv-invocation.test.ts --config vitest.config.ts
  • corepack pnpm exec oxfmt --check src/cli/argv.ts src/cli/argv.test.ts src/cli/argv-invocation.test.ts
  • git diff --check

Real behavior proof

behavior: CLI argv command-path resolution stops at the shared FLAG_TERMINATOR. Tokens after the terminator are ignored, so status -- ignored --help resolves as the status command and does not treat the trailing --help as root help.

environment: Real local OpenClaw checkout at /Users/abz/.openclaw/workspace/openclaw, branch fix/issue-83902, commit eaaea01644, Node.js 22.22.1, pnpm via Corepack, macOS Darwin arm64.

steps:

  1. Ran the CLI argv invocation resolver against an argv array containing FLAG_TERMINATOR between the command and extra tokens.
  2. Confirmed the resolver returned the status command path and did not classify the invocation as root help.
  3. Ran the focused argv regression tests.
  4. Ran formatting and whitespace checks.

evidence:

$ source ~/.nvm/nvm.sh && nvm use 22.22.1 >/dev/null && corepack pnpm exec tsx -e 'import { resolveCliArgvInvocation } from "./src/cli/argv-invocation.ts"; import { FLAG_TERMINATOR } from "./src/infra/cli-root-options.ts"; const argv = ["node", "openclaw", "status", FLAG_TERMINATOR, "ignored", "--help"]; const result = resolveCliArgvInvocation(argv); console.log(JSON.stringify({ argv, flagTerminator: FLAG_TERMINATOR, commandPath: result.commandPath, primary: result.primary, isRootHelpInvocation: result.isRootHelpInvocation }, null, 2));'
{
  "argv": [
    "node",
    "openclaw",
    "status",
    "--",
    "ignored",
    "--help"
  ],
  "flagTerminator": "--",
  "commandPath": [
    "status"
  ],
  "primary": "status",
  "isRootHelpInvocation": false
}

$ source ~/.nvm/nvm.sh && nvm use 22.22.1 >/dev/null && corepack pnpm exec vitest run src/cli/argv.test.ts src/cli/argv-invocation.test.ts --config vitest.config.ts

 RUN  v4.1.6 /Users/abz/.openclaw/workspace/openclaw

 Test Files  2 passed (2)
      Tests  89 passed (89)
   Start at  01:04:38
   Duration  110ms (transform 22ms, setup 0ms, import 37ms, tests 6ms, environment 0ms)

$ source ~/.nvm/nvm.sh && nvm use 22.22.1 >/dev/null && corepack pnpm exec oxfmt --check src/cli/argv.ts src/cli/argv.test.ts src/cli/argv-invocation.test.ts
Checking formatting...

All matched files use the correct format.
Finished in 26ms on 3 files using 12 threads.

$ git diff --check
# no output

observedResult: The resolver returned commandPath: ["status"], primary: "status", and isRootHelpInvocation: false. That proves the after-terminator ignored and --help tokens did not change command routing.

notTested: I did not run a packaged/installable OpenClaw binary with a modified non--- FLAG_TERMINATOR; the current shipped terminator is --. This PR covers the source-level bug by using the shared constant in implementation and exercising that constant through focused local runtime proof plus regression tests.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close as superseded: this PR is a correct duplicate candidate for the same CLI parser bug, and the remaining landing path is the newer open proof-backed PR at #89897.

Root-cause cluster
Relationship: superseded
Canonical: #89897
Summary: This PR and #89897 target the same canonical CLI parser bug; the newer open PR is the viable remaining landing path, while the canonical issue stays open until that fix merges.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Land #89897 as the canonical fix, optionally folding in this PR's invocation-level coverage if maintainers want that extra caller test.

So I’m closing this here and keeping the remaining discussion on #89897.

Review details

Best possible solution:

Land #89897 as the canonical fix, optionally folding in this PR's invocation-level coverage if maintainers want that extra caller test.

Do we have a high-confidence way to reproduce the issue?

Yes. Source inspection on current main and v2026.6.10 shows getCommandPathInternal still checks the literal -- while sibling argv helpers stop on FLAG_TERMINATOR; I did not mutate the constant in this read-only review.

Is this the best way to solve the issue?

No for this branch as the landing path. The production fix is the right one, but #89897 now owns the same remaining work as an open proof-backed canonical PR.

Security review:

Security review cleared: The diff only changes local CLI argv parsing and tests, with no dependency, workflow, package, permission, secret, download, or supply-chain surface.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read: Root AGENTS.md was read fully; no scoped AGENTS.md owns src/cli, and the only maintainer note present is Telegram-specific, so the root duplicate/PR-review guidance applied. (AGENTS.md:1, 96c8338d5bfa)
  • Current main still has the reported mismatch: Current main imports FLAG_TERMINATOR, but getCommandPathInternal still stops on the literal arg === "--", so the underlying issue is not implemented on main yet. (src/cli/argv.ts:461, 96c8338d5bfa)
  • Shared terminator contract checked: FLAG_TERMINATOR is the shared CLI terminator token and currently equals --. (src/infra/cli-root-options.ts:2, 96c8338d5bfa)
  • Runtime caller path checked: resolveCliArgvInvocation derives commandPath through getCommandPathWithRootOptions, so the touched helper feeds pre-dispatch CLI routing. (src/cli/argv-invocation.ts:21, 96c8338d5bfa)
  • This PR's diff is a narrow duplicate fix: The PR changes the outlier comparison to FLAG_TERMINATOR and adds argv plus invocation-level tests; it does not touch dependencies, workflows, package metadata, secrets, or install behavior. (src/cli/argv.ts:461, c6134e422bb7)
  • Canonical open PR is viable and proof-backed: The duplicate search shows fix(cli): replace hardcoded "--" with FLAG_TERMINATOR constant in getCommandPathInternal #89897 is the remaining open PR for the same FLAG_TERMINATOR/getCommandPathInternal fix; live PR metadata reports it open, mergeable, proof-sufficient, and closing the same canonical issue. (41ef0684e80a)

Likely related people:

  • gumadeiras: PR metadata for enhancement: 3x faster CLI invocation, unify boolean/env parsing, streamline CLI startup paths #1195 identifies gumadeiras as the routed CLI startup PR author, and commit f26853f14c9b extracted the shared CLI root-option helper while the command-path helper kept the literal comparison. (role: feature author and adjacent CLI root-option contributor; confidence: high; commits: d5c817219747, f26853f14c9b; files: src/cli/argv.ts, src/cli/argv.test.ts, src/infra/cli-root-options.ts)
  • steipete: Live PR metadata shows steipete merged the routed CLI startup PR, and commit d5c817219747 added the CLI argv helper and tests that this fix builds on. (role: merger and introduced-helper history; confidence: high; commits: d5c817219747; files: src/cli/argv.ts, src/cli/argv.test.ts)
  • vincentkoc: Recent available history shows broad CLI/parser-adjacent cleanup commits by vincentkoc touching the same argv and command-path area, so they are a plausible routing candidate for current-main follow-up. (role: recent area contributor; confidence: medium; commits: 8c0767ffa4de, 2800ce4e28bf; files: src/cli/argv.ts, src/cli/argv.test.ts, src/cli/command-path-policy.ts)

Codex review notes: model internal, reasoning high; reviewed against 96c8338d5bfa.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels May 20, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Velvet Clawlet

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: stacks clean commits.
Image traits: location workflow harbor; accessory shell-shaped keyboard; palette cobalt, lime, and pearl; mood watchful; pose holding its accessory up for inspection; shell frosted glass shell; lighting warm desk-lamp glow; background subtle branch markers.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Velvet Clawlet in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels May 20, 2026
@humanbeingz-7 humanbeingz-7 reopened this May 20, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 20, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 20, 2026
@giodl73-repo giodl73-repo removed the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 21, 2026
@RomneyDa

Copy link
Copy Markdown
Member

Heads up: this PR needs to be updated against current main before the new required Dependency Guard check can pass.

@clawsweeper

clawsweeper Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

🦞✅
ClawSweeper autoclose is complete.

Reason: structured ClawSweeper close marker: close-required (sha=c6134e422bb741833e304b70b3330ac7fed4d032)

Closed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getCommandPathInternal uses hardcoded "--" instead of FLAG_TERMINATOR constant

3 participants