Skip to content

fix(cli): accept inherited flags after nested subcommands - #116587

Merged
jalehman merged 4 commits into
mainfrom
openclaw-733/models-auth-agent-flag
Aug 15, 2026
Merged

jalehman merged 4 commits into
mainfrom
openclaw-733/models-auth-agent-flag

Conversation

@jalehman

@jalehman jalehman commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

What

Allow nested model-auth and skills commands to accept inherited flags after the leaf command. Both parent and leaf placements work, and a leaf --agent value takes precedence over the parent value.

Why

The root CLI enables Commander positional options. Under that parser mode, a flag declared only on a parent command is rejected after a nested leaf. This affected model-auth agent selection, Skill Workshop agent selection, and Skill Curator JSON output.

Changes

  • Declare inherited flags on applicable leaves
  • Resolve explicit leaf values before parent values
  • Cover every model-auth leaf parser path
  • Document both supported flag placements
  • Record the nested-option registration invariant

Testing

  • Exact-head installed package proof at 00d7a8df461cf63d10e230af9d12a5b6f8c80171
    • Built the canonical self-contained package and passed check-openclaw-package-tarball.mjs
    • Installed the tarball into a fresh temporary npm prefix
    • Verified the installed CLI reports OpenClaw 2026.8.1 (00d7a8d)
    • Created an isolated proof-agent and stored a synthetic openai:proof API-key profile with trailing --agent
    • Confirmed models auth list --agent proof-agent --json reads the selected agent profile without exposing credentials
    • Confirmed models auth login --provider openai --agent proof-agent reaches the expected non-interactive TTY guard, not an unknown-option error
    • Confirmed skills workshop list --agent proof-agent --json returns an empty proposal manifest
    • Confirmed skills curator status --json returns an empty curator status document
    • No provider request or live user state was used
  • node scripts/run-vitest.mjs src/cli/models-cli.test.ts src/cli/skills-cli.commands.test.ts src/cli/skills-cli.curator.test.ts src/cli/skills-cli.workshop.test.ts src/cli/program/root-command-descriptions.test.ts
    • 5 files passed
    • 129 tests passed
  • node scripts/check-changed.mjs
    • Remote Testbox was unavailable, so the repository wrapper ran the full changed lanes locally
    • Formatting, typechecks, changed-file lint, dependency, boundary, dead-code, database, and architecture guards passed
  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output
    • TruffleHog passed
    • No accepted or actionable findings

Remaining Risk

Commander requires repeated leaf declarations under positional parsing. Registration and action-forwarding tests cover every applicable model-auth leaf, every Workshop leaf, and every Curator leaf so future drift fails CI.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S maintainer Maintainer-authored PR labels Jul 30, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 15, 2026, 12:49 PM ET / 16:49 UTC.

ClawSweeper review

What this changes

The PR registers selected model-auth, Skills Workshop, and Skills Curator options on nested leaf commands so they work after the subcommand and leaf values take precedence.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. This maintainer-labeled PR addresses a current CLI parser gap, preserves the documented parent form, and has no blocking correctness or security finding.

Priority: P2
Reviewed head: 00d7a8df461cf63d10e230af9d12a5b6f8c80171

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Exact-head packaged CLI proof, focused parser coverage, and green CI support a clean bounded repair.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides exact-head installed-package terminal proof for the changed CLI forms and records the observed post-fix outcomes without credentials.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides exact-head installed-package terminal proof for the changed CLI forms and records the observed post-fix outcomes without credentials.
Evidence reviewed 6 items Current-main gap: Current main declares --agent on models auth but not on the add leaf; the PR adds the leaf declaration and passes the leaf command to the existing resolver.
Resolution owner: The existing model resolver walks from the leaf command through ancestors, so leaf values win while the established parent form remains available.
Skills option handling: The branch uses the existing source-aware parent-inheritance helper for Curator JSON and carries each Workshop leaf command to workspace resolution.
Findings None None.
Security None None.

How this fits together

The Commander-based CLI parses operator arguments before dispatching model authentication or skill-management actions. Agent selection determines the workspace/auth store, while JSON selection determines the response format.

flowchart LR
  A[Operator CLI arguments] --> B[Commander positional parsing]
  B --> C[Model auth and Skills commands]
  C --> D[Leaf and parent option resolution]
  D --> E[Selected agent workspace]
  D --> F[Selected JSON output]
  E --> G[Auth or skill operation]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Production code is +39 net lines; the growth is bounded to required leaf registrations and passing the actual leaf command into existing resolution owners.
  • Resolve merge risk (P1) - This checkout lacks the installed Commander source and cannot fetch it, so the dependency contract was not independently reread here; the PR discussion records direct Commander 15 source/type/README inspection and exact-head installed-package proof.
  • Complete next step (P2) - No repair lane is needed; this maintainer-labeled PR has no actionable findings and can proceed through the normal exact-head merge workflow.
Agent review details

Security

None.

PR surface

Source +39, Tests +187, Docs +3. Total +229 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 2 92 53 +39
Tests 5 226 39 +187
Docs 3 5 2 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 323 94 +229

Review metrics

Metric Value Why it matters
Production vs test LOC production +92/-53 (net +39); tests +226/-39 (net +187); docs/governance +5/-2 The positive production delta is limited to explicit leaf registration and routing the existing command context into established option resolvers.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the bounded leaf-registration repair with its parser-level invariants, keeping option inheritance explicit only on leaves where the option has the same semantics.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the bounded leaf-registration repair with its parser-level invariants, keeping option inheritance explicit only on leaves where the option has the same semantics.

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

Yes. Current main registers the affected option only on parents, while the exact-head installed-package proof demonstrates the repaired trailing-option paths; local execution was not run under the read-only review constraint.

Is this the best way to solve the issue?

Yes. Explicit leaf registration and source-aware inheritance fit Commander positional parsing without exposing the option on unrelated leaves or adding a competing resolver.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded repair to documented CLI agent-selection and machine-output behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-head installed-package terminal proof for the changed CLI forms and records the observed post-fix outcomes without credentials.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head installed-package terminal proof for the changed CLI forms and records the observed post-fix outcomes without credentials.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Introduced the current Skills CLI module that this PR updates. (role: current Skills CLI owner; confidence: high; commits: b1b06d12125b; files: src/cli/skills-cli.ts)
  • steipete: Auth-agent resolution is adjacent to the recently merged explicit model-agent repair in fix(cli): preserve explicit read-only agent targets #123868. (role: recent model-agent contributor; confidence: medium; commits: 1c055ba5e521; files: src/cli/models-cli.ts, src/cli/models-cli.runtime.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-03T09:17:12.611Z sha f1b0b1c :: found issues before merge. :: [P2] Make the nested-option rule default-aware
  • reviewed 2026-08-03T21:18:56.473Z sha f1b0b1c :: found issues before merge. :: [P2] Make the nested-option rule default-aware | [P3] Enumerate models-auth leaves from registration
  • reviewed 2026-08-03T22:04:33.199Z sha f1b0b1c :: found issues before merge. :: [P2] Make the nested-option rule default-aware | [P3] Enumerate models-auth leaves from registration
  • reviewed 2026-08-05T05:07:10.786Z sha f1b0b1c :: found issues before merge. :: [P2] Make inherited-option guidance default-aware | [P3] Enumerate model-auth leaves from registration
  • reviewed 2026-08-05T21:41:49.441Z sha 37e2d05 :: found issues before merge. :: [P3] Exercise the inherited-option invariant through each leaf parser
  • reviewed 2026-08-06T23:40:33.421Z sha e62dbd0 :: found issues before merge. :: [P3] Parse every applicable models-auth leaf
  • reviewed 2026-08-14T14:36:57.667Z sha e62dbd0 :: found issues before merge. :: [P3] Parse every applicable models-auth leaf
  • reviewed 2026-08-15T16:43:30.486Z sha 00d7a8d :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jul 31, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review clawbro

@clawsweeper clawsweeper Bot removed the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 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: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 31, 2026

@Yigtwxx Yigtwxx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at f1b0b1c. No correctness finding — I went looking for one and it didn't survive. Both comments below are about the convention this PR writes down for everyone else, not about the two families it fixes.

What I checked that came back clean. The sibling-parity question ("if models and skills were broken, what else is?") is genuinely closed. I walked every command family in src/cli/ where a parent declares options and has subcommands: agent/exec, acp/client, gateway/run, the daemon service commands, update, sessions, commitments, tasks, onboard. Each one either already declares the applicable option on the leaf or has no parent option at all — and sessions/commitments/tasks were already calling enablePositionalOptions() on the group, so the convention predates this change. These two families really were the stragglers.

The part of the diff that makes the tests able to fail is the harness change, not the assertions. Adding enablePositionalOptions() in models-cli.test.ts:101,107-112, skills-cli.curator.test.ts:64, skills-cli.workshop.test.ts:96, and skills-cli.commands.test.ts:677 is what aligns the harness with production (build-program.ts:12). Without it the harness builds a plain new Command(), positional parsing is off, and the parent quietly consumes --agent before dispatch — meaning the pre-PR tests would have passed against the broken code. Worth calling out because it's easy to read that as boilerplate.

Of the new cases, "resolves workshop --agent with $label" (skills-cli.workshop.test.ts:134-153) is the one that actually pins new logic: workshop list's action passes the parent command object plus leaf opts (skills-cli.ts:958), so the third case would return "parent-agent" without the :154 flip. The models-side precedence test pins pre-existing cli-utils.ts walk-order rather than anything this PR wrote, which is fine as a regression test — just not evidence for the new resolution.

Two comments inline:

  1. AGENTS.md:89 states "resolve the leaf value first, then ancestors" without the defaults caveat, and the pattern it implicitly points at (resolveOptionFromCommand) reads raw opts(). Two places in-tree already had to invert precedence for exactly that reason, one of them with the hazard in a comment, and the repo has a source-aware helper built for it. Nothing in this PR is affected — none of the touched leaf options has a default — but --json/--limit/--timeout leaves in this repo usually do.

  2. models-cli.test.ts:177-196 hardcodes the leaf list where its skills counterpart iterates workshop.commands. Complete today; won't catch a future auth leaf that forgets --agent.

Comment thread AGENTS.md Outdated
- OpenAI Codex is folded into `openai`. No new/live `openai-codex` provider/plugin/auth/model routes; treat them as legacy input only. Runtime/setup/auth/catalog use `openai` + `openai/*`; doctor/migrations repair stale `openai-codex/*` profiles/metadata.
- Config/env surface bar is high; `openclaw.json` and environment variables are already large. Before adding a config option or env var, first prove existing product behavior, provider selection, defaults, or doctor migration cannot solve it. Prefer removing or consolidating config/env options when touching these surfaces. Core supports only the latest config shape; `openclaw doctor --fix` migrates older shipped shapes into the current one.
- CLI setup flows are public API when external docs, installers, or integrations can copy them. Changes to `openclaw onboard`, `openclaw configure`, their documented flags, non-interactive behavior, or generated config shape are compatibility-sensitive API contract changes; prefer additive flags/aliases, deprecation windows, and backward-preserving migrations over breaking existing snippets.
- Nested CLI options: when a parent option semantically applies to a leaf subcommand, declare it on both the parent and every applicable leaf so positional parsing accepts the option before or after the subcommand. Resolve the leaf value first, then ancestors. Do not expose inherited options on leaves where the semantics differ. Add real-parser coverage that enumerates every applicable leaf.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Resolve the leaf value first, then ancestors" is correct for every option this PR touches, but as a repo-wide rule it inverts the moment a leaf option has a default — and the rule as written doesn't mention defaults or point at the helper that handles them.

The pattern a reader will copy is the one in the two files this PR changes, resolveOptionFromCommand (src/cli/cli-utils.ts:60-73), which walks leaf→root returning the first opts[key] !== undefined. In Commander a defaulted option is present in opts() whether or not the user typed it, so with a default on the leaf that walk returns the default and an explicitly typed ancestor flag never wins.

Two places in-tree already hit this and had to work around it:

src/cli/program/register.agent-turn.ts — parent --timeout has no default (:73-76), leaf agent exec --timeout defaults to "600" (:149), and the merge at :185 is deliberately ancestor-first:

messageFile: opts.messageFile ?? parentOpts?.messageFile,   // leaf-first
model: opts.model ?? parentOpts?.model,                     // leaf-first
thinking: opts.thinking ?? parentOpts?.thinking,            // leaf-first
timeout: parentOpts?.timeout ?? opts.timeout,               // ancestor-first — the one with a leaf default

src/cli/gateway-cli/run-options.ts:60-62 says it outright:

if (key === "wsLog") {
  // wsLog has a child default ("auto"), so prefer inherited parent CLI value when present.
  resolved[key] = inherited ?? resolved[key];

And the repo already has the primitive that makes the rule safe in both cases — inheritOptionFromParent (src/cli/command-options.ts:12-36) uses getOptionValueSource(name) and skips values whose source is "default". It's what acp-cli.ts:66, gateway-cli/register.ts:21, update-cli.ts:27,38, and daemon-cli/register-service-commands.ts use.

Since --json, --limit, and --timeout leaf options in this repo commonly carry defaults, the next person following this line is fairly likely to land in the inverted case. Naming the caveat and the helper would cost one clause:

Suggested change
- Nested CLI options: when a parent option semantically applies to a leaf subcommand, declare it on both the parent and every applicable leaf so positional parsing accepts the option before or after the subcommand. Resolve the leaf value first, then ancestors. Do not expose inherited options on leaves where the semantics differ. Add real-parser coverage that enumerates every applicable leaf.
- Nested CLI options: when a parent option semantically applies to a leaf subcommand, declare it on both the parent and every applicable leaf so positional parsing accepts the option before or after the subcommand. Resolve the leaf value first, then ancestors — but when the leaf option has a default, resolve by option source (`inheritOptionFromParent` in `src/cli/command-options.ts`) so a leaf default never beats an explicitly supplied ancestor value. Do not expose inherited options on leaves where the semantics differ. Add real-parser coverage that enumerates every applicable leaf.

To be explicit about scope: this is about the rule, not this PR's code. I checked every leaf option the branch declares — models-cli.ts:331,351,364,384,421,442,468,489,513,534,555 and the skills-cli.ts loops at :938-940 and :1291-1296 — and none of them has a default, so the leaf-first resolution here produces exactly the documented behavior.

Comment thread src/cli/models-cli.test.ts Outdated
it("declares --agent on every agent-aware auth leaf command", () => {
const models = requireCommand(createProgram(), "models");
const auth = requireCommand(models, "auth");
const authLeaves = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the one place where the two halves of the PR diverge on the invariant the new AGENTS.md line asks for ("coverage that enumerates every applicable leaf").

The skills counterpart iterates the registered commands, so it stays true as leaves are added — src/cli/skills-cli.commands.test.ts:676-694:

for (const command of workshop.commands) {
  expect(command.options.some((option) => option.long === "--agent"), command.name()).toBe(true);
}

Here the leaf set is a hardcoded list. I checked it against this head and it is complete today — those eight plus order get|set|clear are exactly auth's current leaves — so this isn't a coverage hole right now. The difference is what happens next: a new models auth <leaf> added without --agent fails the skills-shaped test and passes this one, which makes it a snapshot of today's tree rather than a guard on the rule.

Iterating would match the sibling and drop the maintenance burden:

Suggested change
const authLeaves = [
it("declares --agent on every agent-aware auth leaf command", () => {
const models = requireCommand(createProgram(), "models");
const auth = requireCommand(models, "auth");
const order = requireCommand(auth, "order");
for (const command of [...auth.commands, ...order.commands]) {
if (command === order) {
continue;
}
expect(command.options.some((option) => option.long === "--agent"), command.name()).toBe(true);
}
});

That skips the order group itself, which is a container rather than an agent-aware leaf (it declares no --agent at models-cli.ts:507) — worth confirming that's the only exclusion you'd want, since you know the intended semantics of each leaf better than the shape of the tree does.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed 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. labels Aug 2, 2026
@jalehman jalehman self-assigned this Aug 5, 2026
@jalehman
jalehman force-pushed the openclaw-733/models-auth-agent-flag branch from f1b0b1c to 37e2d05 Compare August 5, 2026 20:55
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 5, 2026
@Yigtwxx

Yigtwxx commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Follow-up review at e62dbd0, covering the new commit plus the two open before-merge items. No correctness finding; everything below is measured on that head rather than read.

The new commit is a tightening, not a loosening

test(cli): classify curator leaf JSON flags deletes JSON_OUTPUT_INHERITED_FROM_PARENT, hasAncestorJsonOption, and the staleInheritedSupport assertion. That reads like removed coverage, so I checked what it costs. It costs nothing, because the classifier is fail-closed: unclassified requires every registered path to either satisfy supportsJsonOutput or appear in JSON_NOT_APPLICABLE, so a leaf that inherits --json without declaring its own can no longer be quietly classified — it fails the suite by name.

Mutation, on e62dbd0, removing only the for (const command of curator.commands) loop in skills-cli.ts:963-965 so the four leaves lose their own flag:

× classifies every built-in command as JSON output or explicitly not applicable

AssertionError: commands missing a deliberate JSON output decision:
expected [ 'skills curator status', …(3) ] to deeply equal []
+   "skills curator status"
+   "skills curator pin"
+   "skills curator unpin"
+   "skills curator restore"

 Tests  1 failed | 2 passed (3)

So the old allowlist was the only thing that had been letting those four paths through without their own flag, and after this PR gives them one, deleting it raises the bar rather than lowering it. Unmutated the file is 3 passed (3).

The open P3: it is hardening, not a hidden bug — and it is still worth adding

First, a small correction to the finding's inventory, since it changes how much work is left. The two parser tables are missing different things:

leaf parent-form table (auth --agent … <leaf>) leaf-form table (auth <leaf> … --agent)
add, login, setup-token, paste-token, paste-api-key, login-github-copilot covered covered
list, logout covered missing
order get, order set, order clear missing missing

So login-github-copilot is already table-driven in both forms — the actual gap is five leaf-form rows, and the leaf form is the one this PR exists to fix.

I table-drove those five (list, logout, order get|set|clear, each with --agent placed after the leaf). All five pass unchanged on e62dbd0, so no currently-shipping leaf silently drops a trailing --agent; the gap is coverage, not a defect. models-cli.test.ts goes from 28 to 33 tests, all green.

The interesting part is whether those rows can catch anything the existing declares --agent on every agent-aware auth leaf command iteration cannot. They can, and the two mutations separate the halves:

mutation on models auth order get declaration test new parser row
drop .option("--agent <id>", …) fails fails (error: unknown option '--agent')
keep the option, resolve with resolveModelAgentOption(auth) instead of (command, opts) passes fails (expected undefined to deeply equal 'poe')

The second row is the case the review named — a leaf that registers the option but does not forward it — and it is structurally invisible to an options-enumeration test. That is the argument for adding the rows even though nothing is broken today.

Ready patch, test-only, oxfmt --check and oxlint clean:

src/cli/models-cli.test.ts — 3 dedicated order mocks + 5 table rows
@@ const mocks = vi.hoisted(() => ({
   modelsAuthSetupTokenCommand: vi.fn().mockResolvedValue(undefined),
+  modelsAuthOrderGetCommand: vi.fn().mockResolvedValue(undefined),
+  modelsAuthOrderSetCommand: vi.fn().mockResolvedValue(undefined),
+  modelsAuthOrderClearCommand: vi.fn().mockResolvedValue(undefined),
 }));
 
 const {
+  modelsAuthOrderGetCommand,
+  modelsAuthOrderSetCommand,
+  modelsAuthOrderClearCommand,
   modelsAuthAddCommand,
@@ vi.mock("../commands/models/auth-order.js", () => ({
-  modelsAuthOrderClearCommand: mocks.noopAsync,
-  modelsAuthOrderGetCommand: mocks.noopAsync,
-  modelsAuthOrderSetCommand: mocks.noopAsync,
+  modelsAuthOrderClearCommand: mocks.modelsAuthOrderClearCommand,
+  modelsAuthOrderGetCommand: mocks.modelsAuthOrderGetCommand,
+  modelsAuthOrderSetCommand: mocks.modelsAuthOrderSetCommand,
 }));
@@ beforeEach
     modelsStatusCommand.mockClear();
+    modelsAuthOrderGetCommand.mockClear();
+    modelsAuthOrderSetCommand.mockClear();
+    modelsAuthOrderClearCommand.mockClear();
@@ ])("passes leaf --agent to models auth $label"  <- append these rows to that table
+    {
+      label: "list",
+      args: ["models", "auth", "list", "--provider", "openai", "--agent", "poe"],
+      command: modelsAuthListCommand,
+      expected: { agent: "poe", provider: "openai" },
+    },
+    {
+      label: "logout",
+      args: ["models", "auth", "logout", "openai:manual", "--yes", "--agent", "poe"],
+      command: modelsAuthLogoutCommand,
+      expected: { agent: "poe", profileId: "openai:manual", yes: true },
+    },
+    {
+      label: "order get",
+      args: ["models", "auth", "order", "get", "--provider", "anthropic", "--agent", "poe"],
+      command: modelsAuthOrderGetCommand,
+      expected: { agent: "poe", provider: "anthropic" },
+    },
+    {
+      label: "order set",
+      args: [
+        "models",
+        "auth",
+        "order",
+        "set",
+        "--provider",
+        "anthropic",
+        "--agent",
+        "poe",
+        "anthropic:default",
+      ],
+      command: modelsAuthOrderSetCommand,
+      expected: { agent: "poe", provider: "anthropic", order: ["anthropic:default"] },
+    },
+    {
+      label: "order clear",
+      args: ["models", "auth", "order", "clear", "--provider", "anthropic", "--agent", "poe"],
+      command: modelsAuthOrderClearCommand,
+      expected: { agent: "poe", provider: "anthropic" },
+    },

The order mocks have to become distinct functions because all three currently share mocks.noopAsync, which cannot tell the three leaves apart.

I deliberately did not add the three missing parent-form order rows. The walk in resolveOptionFromCommand is depth-agnostic, so those would pin pre-existing ancestry behavior rather than anything this PR changes; the leaf-form rows are the ones that guard the new rule.

The merge-risk item, measured

main has moved since this head, but not under this PR in any way that matters:

path commits on main since branch base 2db3431f4aa
src/cli/models-cli.ts 0
src/cli/program/root-command-descriptions.test.ts 0
docs/cli/skills.md 0
src/cli/skills-cli.ts 1 — 90e39c49e46, a type-only narrowing of runWorkshopDraftAction's input parameter, no command registration touched
docs/cli/models.md 2
AGENTS.md 1

git merge-tree --write-tree pr-head main exits 0, and the merge is behaviourally clean too, not just textually — on a local merge of current main into e62dbd0, with the five rows above applied:

node scripts/run-vitest.mjs run --configLoader runner \
  src/cli/models-cli.test.ts src/cli/skills-cli.commands.test.ts \
  src/cli/skills-cli.curator.test.ts src/cli/skills-cli.workshop.test.ts \
  src/cli/program/root-command-descriptions.test.ts

 Test Files  5 passed (5)
      Tests  119 passed (119)

Windows 11, Node 24.15.0. Worth stating explicitly because a clean three-way merge does not by itself prove the fix still lands where the parser reads it — here it does.

On my earlier comment

The hardcoded-leaf-list point from my first review is resolved: declares --agent on every agent-aware auth leaf command now iterates auth.commands plus order.commands instead of listing them, so a future leaf that forgets the option fails without anyone editing the test. The AGENTS.md defaults caveat is still just a documentation nit and not a blocker.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 14, 2026
@Yigtwxx

Yigtwxx commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Re-measured against today's main (ee655614103), because the merge picture in my previous comment has changed and one of its claims is now stale.

The branch no longer merges cleanly

A week ago git merge-tree --write-tree exited 0 on this head. It no longer does: main has landed ten commits on src/cli/skills-cli.ts since the branch base, and the merge now stops on two conflicts.

The AGENTS.md one is adjacency only - main deleted the Fix shape: Repair Doctrine owns the default bullet that sits directly above the nested-CLI bullet this PR adds. Keep the new bullet, take main's deletion.

The src/cli/skills-cli.ts one is not incidental, which is why it is worth flagging rather than just resolving quietly. 2463ea0a5e6 (#123929) rewrote the body of the workshop propose-inspect action - String(err) became formatErrorMessage(err) - inside the exact callback this branch re-shapes, and main's rewritten copy still resolves the workspace from the parent:

// main, after 2463ea0a5e6
.action(async (proposalId: string, opts: { json?: boolean; agent?: string }) => {
  const { agentId, workspaceDir } = resolveSkillsWorkspaceForCommand(workshop, opts);

while this branch's whole point at that call site is the leaf:

.action(
  async (proposalId: string, opts: { json?: boolean; agent?: string }, command: Command) => {
    const { agentId, workspaceDir } = resolveSkillsWorkspaceForCommand(command, opts);

So neither side can be taken wholesale: the fix's command argument and third callback parameter have to be re-applied on top of main's new body. Resolution that builds and passes is main's body with workshop -> command, the command: Command parameter restored, and both conflicting imports kept (inheritOptionFromParent and resolveInstallPolicyWarningAcknowledgementCliOptions are simply adjacent lines).

On that resolution, Windows 11 / Node 24.15.0:

node scripts/run-vitest.mjs src/cli/models-cli.test.ts \
  src/cli/skills-cli.commands.test.ts src/cli/skills-cli.curator.test.ts \
  src/cli/skills-cli.workshop.test.ts src/cli/program/root-command-descriptions.test.ts

 Test Files  5 passed (5)
      Tests  124 passed (124)

tsgo -p test/tsconfig/tsconfig.core.test.json --noEmit -> exit 0, oxlint on both touched files -> exit 0.

A correction to my own earlier comment

I wrote that src/cli/models-cli.ts had zero commits on main since the branch base. That was true on 07 Aug and is not any more - 1c055ba5e52 (#123868) and dd1d151300c (#113953) have since touched it. Both are in models status / read-only agent-target handling rather than the auth leaves, but the number was wrong, so I re-ran the P3 patch with them in the tree instead of restating the old result.

The open P3 patch still applies and still earns its place

Same five leaf-form rows as before, applied on the resolved merge:

before  Tests  31 passed (31)
after   Tests  36 passed (36)

oxfmt --check clean. The mutation that was the argument for the rows still separates the two halves - keep --agent declared on order get but resolve from the parent, resolveModelAgentOption(auth) instead of (command, opts):

× passes leaf --agent to models auth 'order get'
AssertionError: expected undefined to deeply equal 'poe'

 Tests  1 failed | 35 passed (36)

Exactly one test fails, and the declares --agent on every agent-aware auth leaf command iteration is not it - a leaf that registers the option but drops the leaf value is still invisible to an options-enumeration test, and visible to these rows.

The full patch is in my previous comment; nothing in it needed changing for today's main.

@jalehman
jalehman force-pushed the openclaw-733/models-auth-agent-flag branch from e62dbd0 to 00d7a8d Compare August 15, 2026 16:37
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 15, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 15, 2026
@jalehman

Copy link
Copy Markdown
Contributor Author

Maintainer merge review for exact head 00d7a8df461cf63d10e230af9d12a5b6f8c80171:

  • Accept the +39 production LOC. Commander positional parsing requires applicable options to be registered on each leaf; the added action context carries the actual leaf into the existing resolution owner. No net-neutral alternative preserves explicit per-leaf semantics.
  • Exact-head openclaw/ci-gate is green: https://github.com/openclaw/openclaw/actions/runs/31896014930/job/95039837445
  • Inspected installed Commander 15.0.0 directly: lib/command.js option-source handling and positional-option parsing, typings/index.d.ts option-source contracts, and the README positional-options contract. These confirm that leaf registration is the supported boundary under enablePositionalOptions().
  • Exact-head installed-package proof and the full local validation summary are in the PR body.
  • Latest ClawSweeper review has no actionable findings and marks proof sufficient. Proceeding through the repository-native maintainer prepare and merge workflow.

@jalehman
jalehman merged commit 56798ae into main Aug 15, 2026
191 checks passed
@jalehman
jalehman deleted the openclaw-733/models-auth-agent-flag branch August 15, 2026 16:52
@jalehman

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 16, 2026
…16587)

* fix(cli): accept auth agent flag after subcommands

* openclaw-87a: normalize inherited skills options

* test(cli): classify curator leaf JSON flags

* test(cli): cover all auth agent leaves
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants