Repository navigation
fix(cli): accept daemon --json before subcommands - #126447
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Land-ready proof for head
Known proof gap: only the read-only |
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 5:56 PM ET / 21:56 UTC. ClawSweeper reviewWhat this changesThe PR makes legacy daemon lifecycle commands accept the existing JSON-output flag before or after every lifecycle subcommand, with matching documentation and regression coverage. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep this maintainer-labeled PR open: it is the focused owner-boundary repair for the linked daemon parsing bug, with no blocking patch finding. Exact-head CI is still running, and this read-only checkout could not independently load current main because its promisor remote and GitHub DNS were unavailable. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherThe daemon CLI is the legacy service-management interface for the Gateway. Commander parses the nested command, then lifecycle handlers receive normalized options and emit either human-readable or JSON output. flowchart LR
A[Operator lifecycle command] --> B[Daemon command parser]
B --> C[Parent or leaf JSON flag]
C --> D[Source-aware option resolution]
D --> E[Service lifecycle handler]
E --> F[JSON or human output]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +9, Tests +21, Docs +2. Total +32 across 6 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the parent-and-leaf declaration pattern with one shared source-aware resolver, then merge after exact-head CI confirms the documented CLI contract. Do we have a high-confidence way to reproduce the issue? Yes—source and the PR’s parser matrix establish a deterministic reproduction: before this change the parent lacked the flag while every leaf declared it. This read-only review did not execute the command because the package-manager cache could not be created on the read-only host. Is this the best way to solve the issue? Yes—the parent declaration plus source-aware inheritance is the narrowest maintainable fix; argv scanning or changing the broader Gateway parent would duplicate policy or affect unrelated commands. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e00f86019827. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
ClawSweeper rank-up moves resolved for reviewed head
The review’s stored-data-model heuristic is not applicable: |
|
Merged via squash.
|
* fix(cli): accept daemon json before subcommands * test(cli): update doctor public-surface fixture * test(cli): classify daemon parent JSON output
Closes #126444
AI-assisted: Codex
What Problem This Solves
Fixes an issue where operators using the legacy
openclaw daemonlifecycle CLI could not place the universal--jsonflag before a subcommand. All six forms such asopenclaw daemon --json statusfailed during parsing withcommander.unknownOption, even though the corresponding after-subcommand forms worked.Why This Change Was Made
The daemon parent now declares
--json, while every existing lifecycle leaf keeps its own declaration. The shared registration owner resolves JSON mode source-aware: an explicit leaf CLI value wins; otherwise the leaf inherits only a CLI-sourced parent value throughinheritOptionFromParent. This preserves both placements without argv scanning, duplicate renderers, fallback paths, or service-runtime changes. The Gateway parent remains unchanged because JSON is not universal across its subcommands.The daemon CLI reference now documents both JSON placements and includes the already-registered
stop --forceoption. A one-line process-test fixture correction updates the Memory Core Doctor public artifact fromapi.jstodoctor-health-api.js, matching the split introduced byf8ba65636c23and allowing the requested CLI JSON process sibling to exercise its intended contract.User Impact
Scripts and operators can use
--jsonbefore or after any legacy daemon lifecycle subcommand. Existing human output, JSON envelopes, and after-subcommand behavior are unchanged.Release-note context: legacy daemon lifecycle automation now accepts
--jsonin either nested CLI position.Evidence
Before the fix, a real positional-parser table failed all six before-leaf cases with
commander.unknownOption; all six after-leaf cases passed.After the fix:
node scripts/run-vitest.mjs src/cli/daemon-cli/register-service-commands.test.ts --reporter=verbose— 19/19 passed, covering all six leaves and both placements with mocked runner assertions forjson: true.OPENCLAW_E2E_SKIP_BUILD=1 node scripts/run-vitest.mjs src/cli/command-options.test.ts test/cli-json-stdout.e2e.test.ts --reporter=verbose— 48/48 passed.daemon --json status --no-probeanddaemon status --json --no-probeexited 0 with parseable JSON. Mutating lifecycle leaves remained mocked to avoid touching a live service.pnpm check:docs— passed formatting, lint, MDX, glossary, 6,524 internal links, and config-example validation.node scripts/check-changed.mjs -- <five changed paths>— passed the selected core, core-test, root-test, docs, and tooling gates.32304925895found one attributable stale inventory entry:daemonremained inJSON_NOT_APPLICABLEafter gaining parent JSON support. Removing that obsolete exception maderoot-command-descriptions.test.tsand the parser suite pass 23/23 without weakening the guard.git diff --check— clean.505f2f00873a4adfe86101e54cd5ca85c7411b88f36bcb59fa2258eeefa569bb: no P1 findings; start/end guards matched.