Skip to content

fix(cli): accept --log-level after subcommands#93455

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
ooiuuii:fix/cli-log-level-subcommands
Jun 16, 2026
Merged

fix(cli): accept --log-level after subcommands#93455
vincentkoc merged 1 commit into
openclaw:mainfrom
ooiuuii:fix/cli-log-level-subcommands

Conversation

@ooiuuii

@ooiuuii ooiuuii commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Root --log-level <level> is accepted before a subcommand, but Commander-owned command paths can reject it when callers append it after the subcommand, for example openclaw doctor --lint --json --log-level debug.
  • This is the value-option sibling of the already-landed --no-color normalization in fix(cli): accept --no-color after subcommands #93324.
  • This PR normalizes valid trailing --log-level <level> and --log-level=<level> tokens back into the root option prefix before the final Commander parse.
  • Out of scope: changing log rendering, route-first logging behavior, or broadly reordering every root value option after subcommands.
  • Success looks like real subcommands accepting trailing --log-level while command-owned --log-level, required option values, missing values, and -- positionals stay command-scoped.
  • Reviewer focus: value-option normalization around --, required option values such as agent --message --log-level, and the final Commander-metadata pass that avoids stealing command-owned --log-level options.

Linked context

No separate issue. This is a small follow-up to the CLI parser behavior fixed in #93324.

Real behavior proof (required for external PRs)

  • Behavior addressed: root --log-level <level> after a subcommand could be parsed as an unknown command option instead of the root log-level override on final Commander command paths.
  • Real environment tested: Windows source checkout on branch fix/cli-log-level-subcommands, commit 6d39dd1760, Node v22.22.0, pnpm 11.2.2, source rebuilt through scripts/run-node.mjs.
  • Exact steps or command run after this patch:
node scripts/run-node.mjs doctor --lint --json --log-level debug --severity-min error
  • Evidence after fix:
{"ok":true,"checksRun":22,"checksSkipped":0,"findings":[]}
  • Observed result after fix: the command accepts --log-level debug after doctor boolean flags and reaches doctor lint JSON output; Commander no longer rejects it as an unknown command option.
  • What was not tested: full CLI suite, packaged npm install, route-first log-level application, every subcommand/plugin command combination.
  • Proof limitations or environment constraints: source checkout proof only, not a packaged release artifact. The source checkout warned that the local config was written by 2026.6.8-beta.1 while the source package version is 2026.6.2; the doctor lint proof still completed successfully.

Tests and validation

Commands run:

node scripts/run-vitest.mjs src/cli/argv.test.ts
node scripts/run-oxlint.mjs src\cli\argv.ts src\cli\run-main.ts src\cli\argv.test.ts
node_modules\.bin\oxfmt.cmd --check --threads=1 src\cli\argv.ts src\cli\run-main.ts src\cli\argv.test.ts
node_modules\.bin\oxlint.cmd src\cli\argv.ts src\cli\run-main.ts src\cli\argv.test.ts --threads=1
git diff --check
node scripts/run-node.mjs doctor --lint --json --log-level debug --severity-min error
python -X utf8 .agents\skills\autoreview\scripts\autoreview --mode local

Results:

argv focused Vitest: 125 passed
run-oxlint: passed
oxfmt --check: passed
plain oxlint: passed
git diff --check: passed
doctor real CLI proof: {"ok":true,"checksRun":22,"checksSkipped":0,"findings":[]}
autoreview: clean, no accepted/actionable findings

Regression coverage added:

  • Moves --log-level <level> and --log-level=<level> from unambiguous subcommand positions to the root option prefix.
  • Preserves existing root option prefixes such as --profile work.
  • Leaves --log-level after -- positional.
  • Leaves missing-value --log-level command-scoped.
  • Preserves literal required-option values such as agent --message --log-level debug.
  • Lets final Commander command metadata lift --log-level after boolean command flags without stealing command-owned --log-level options.

Risk checklist

Did user-visible behavior change? (Yes/No)

Yes. The CLI now accepts root --log-level <level> after subcommands in valid unambiguous positions.

Did config, environment, or migration behavior change? (Yes/No)

No.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

No.

What is the highest-risk area?

Accidentally treating a command-owned --log-level or a required option value as the root log-level override.

How is that risk mitigated?

The early normalization remains conservative, the final parse uses Commander command metadata, and tests cover required-option values, command-owned option preservation, missing values, and the -- terminator.

Current review state

What is the next action?

Wait for CI, ClawSweeper, and maintainer review.

What is still waiting on author, maintainer, CI, or external proof?

CI and ClawSweeper are pending after PR creation.

Which bot or reviewer comments were addressed?

Local autoreview was run before opening and reported no accepted/actionable findings.

@ooiuuii

ooiuuii commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@vincentkoc vincentkoc self-assigned this Jun 16, 2026
@vincentkoc
vincentkoc requested a review from a team as a code owner June 16, 2026 07:40
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core security Security documentation scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: qa-lab extensions: codex plugin: migrate-hermes labels Jun 16, 2026
@openclaw-barnacle openclaw-barnacle Bot removed docs Improvements or additions to documentation channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram app: web-ui App: web-ui gateway Gateway runtime extensions: memory-core Extension: memory-core security Security documentation scripts Repository scripts commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: feishu Channel integration: feishu extensions: qa-lab extensions: codex plugin: migrate-hermes extensions: ollama extensions: openshell plugin: workboard labels Jun 16, 2026
@vincentkoc

Copy link
Copy Markdown
Member

land-ready verification:

  • prepared head: b6d3aa57190a85ec86f822822e7996a75ae5f4d1
  • focused proof: node scripts/run-vitest.mjs src/cli/program.preaction.test.ts src/cli/program.test.ts (297 passed)
  • fresh autoreview: clean
  • local broad gate gap: pnpm build passed; pnpm check is blocked by the unrelated database-first legacy-store guard heap OOM (reproduced at 4 GB and 8 GB); Testbox CLI unavailable
  • exact-head repo merge verification: passed; no required checks configured

@vincentkoc
vincentkoc merged commit 042ebb4 into openclaw:main Jun 16, 2026
175 of 188 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @ooiuuii!

1 similar comment
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @ooiuuii!

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 17, 2026
Merged via squash.

Prepared head SHA: b6d3aa5
Co-authored-by: ooiuuii <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Reviewed-by: @vincentkoc
crh-code pushed a commit to crh-code/openclaw that referenced this pull request Jun 18, 2026
Merged via squash.

Prepared head SHA: b6d3aa5
Co-authored-by: ooiuuii <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
Reviewed-by: @vincentkoc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes proof: supplied External PR includes structured after-fix real behavior proof. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants