Skip to content

refactor(cli): simplify message command action registration - #129122

Merged
steipete merged 1 commit into
mainfrom
codex/refactor-cli-commands-dedupe
Aug 25, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/refactor-cli-commands-dedupe

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Maintainer-requested cleanup: message command registration repeated the same redundant async wrapper for nearly every subcommand, while pin registration built and discarded an unused array. The extra ceremony made the command family noisier without owning any distinct behavior.

Why This Change Was Made

Return the existing canonical message-action Promise directly from 31 Commander action callbacks and register the three pin commands directly. Preserve the meaningful thread-create normalization boundary, every command option/action mapping, execution order, and failure behavior. Production code decreases by 64 lines without adding an abstraction.

User Impact

No user-visible behavior change. Message commands, options, asynchronous completion, errors, and post-action hooks retain their existing behavior.

Evidence

  • Focused existing coverage: node scripts/run-vitest.mjs src/cli/program/message/helpers.test.ts src/cli/program/message/register.thread.test.ts src/cli/program/register.message.test.ts src/cli/program/command-tree.test.ts src/cli/program/root-command-descriptions.test.ts src/commands/message.test.ts — six files, 74 passing tests.
  • Full applicable core/core-test changed gate passed: OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 node scripts/check-changed.mjs -- src/cli/program/message/register.broadcast.ts src/cli/program/message/register.discord-admin.ts src/cli/program/message/register.emoji-sticker.ts src/cli/program/message/register.permissions-search.ts src/cli/program/message/register.pins.ts src/cli/program/message/register.poll.ts src/cli/program/message/register.reactions.ts src/cli/program/message/register.read-edit-delete.ts src/cli/program/message/register.send.ts src/cli/program/message/register.thread.ts. The identical unchanged patch had already passed the production, full-tree, and script dead-export scans separately.
  • Actual Commander 15 parser exercised all 32 message leaf commands before and after the change with identical action mappings; delayed Promise actions completed before post-action hooks, and rejected Promises/synchronous failures propagated identically without running post-action hooks.
  • Commander source and TypeScript declarations directly confirm action callbacks may return Promises and that parseAsync awaits the action chain.
  • Independent source review and automated precommit Codex review reported no actionable findings.

AI-assisted maintainer-requested refactor.

@clawsweeper

clawsweeper Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 25, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 25, 2026
@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 4:06 AM ET / 08:06 UTC.

ClawSweeper review

What this changes

The PR returns the shared message-action Promise directly from message-command callbacks and removes the unused pin-command array.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No concrete regression was found in this behavior-neutral cleanup, but the exact Commander 15 action-awaiting contract remains unverified locally; keep this maintainer PR open through exact-head validation.

Priority: P3
Reviewed head: 670fd2a3fc360add2e814ccd632b76550a35e1d1

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is lean and internally coherent, but independent confirmation of the pinned Commander contract is unavailable in this review environment.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored, behavior-neutral CLI refactor is exempt from the external-contributor proof gate; exact-head dependency and smoke validation remain merge checks.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored, behavior-neutral CLI refactor is exempt from the external-contributor proof gate; exact-head dependency and smoke validation remain merge checks.
Evidence reviewed 6 items Changed callback owner: All simplified callbacks return runMessageAction, whose declared contract is Promise<void> and whose implementation owns validation, dispatch, stop hooks, and exit behavior.
Entry point and retained special case: The message registrar wires all changed modules into one command tree, while thread creation retains its async wrapper because it first normalizes a channel-specific request.
Current main comparison: Current main still contains the prior async wrappers and unused pin array, so this PR is not already implemented or superseded.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw message send --help

Result: PASS (completed)

pnpm openclaw message send --helprunner@runnervm76f27:/tmp/clawsweeper-live-proof-129122-01bOHb/target$ pnpm openclaw message send --help
pnpm openclaw message send --help
$ node scripts/run-node.mjs message send --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 128.43 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.8s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 15.2s
[plugin-control-plane-loads] verified 35 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4518ms (slowest: built plugin control-plane loads 3712ms)
│
◇

OpenClaw 2026.8.1 (670fd2a) — All your chats, one OpenClaw.

Usage: openclaw message send [options]

Send a message

Options:
  --account ‹id›         Channel account id (accountId)
  --channel ‹channel›    Channel:
  --delivery ‹json›      Shared delivery preferences as JSON
  --dry-run              Print payload and skip sending (default: false)
  --force-document       Preserve original image bytes on Slack, or send images, G
… output truncated …

Assertions:

  • PASS expect_output: Message body (required unless --media or --presentation is set)

How this fits together

The CLI registers message subcommands with Commander, which invokes each callback after parsing options. Each callback delegates to the shared message-action runner, which loads any required plugin context and executes the channel operation.

flowchart LR
  A[CLI arguments] --> B[Message command tree]
  B --> C[Commander action callback]
  C --> D[Shared message action runner]
  D --> E[Plugin and channel operation]
  E --> F[CLI exit result]
Loading

Before merge

  • Resolve merge risk (P1) - Directly returning the Promise relies on Commander 15 awaiting action callbacks; dependency source/types could not be independently inspected in this node_modules-less checkout while network access was unavailable.
  • Complete next step (P2) - Normal exact-head maintainer validation is needed for the Commander dependency contract; there is no discrete code repair to dispatch.
Agent review details

Security

None.

PR surface

Source -64. Total -64 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 10 53 117 -64
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 53 117 -64

Review metrics

Metric Value Why it matters
Production versus test delta production −64, tests 0 The PR removes callback ceremony without adding behavior, test-support, or configuration surface.

Merge-risk options

Maintainer options:

  1. Verify the Commander callback contract (recommended)
    Confirm from [email protected] source or types and an exact-head CLI smoke that returned action Promises are awaited before merging.

Technical review

Best possible solution:

Validate the exact Commander 15 action-chain contract and the message command smoke path on the PR head, then retain this smaller direct-delegation shape.

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

Not applicable: this is a behavior-neutral refactor, and the relevant question is whether Commander preserves returned-Promise action semantics. The source path is clear, but this read-only node_modules-less checkout could not run or inspect the pinned dependency.

Is this the best way to solve the issue?

Unclear: direct delegation is the simplest canonical shape because the shared helper already returns a Promise, but exact Commander 15 contract proof is still needed before calling it the best validated solution.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Callback completion and error propagation depend on the pinned Commander action contract, which was not locally verifiable.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P3: This is a small maintainer-requested CLI cleanup with no intended user-visible behavior change.
  • merge-risk: 🚨 compatibility: Callback completion and error propagation depend on the pinned Commander action contract, which was not locally verifiable.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored, behavior-neutral CLI refactor is exempt from the external-contributor proof gate; exact-head dependency and smoke validation remain merge checks.

Evidence

What I checked:

  • Changed callback owner: All simplified callbacks return runMessageAction, whose declared contract is Promise<void> and whose implementation owns validation, dispatch, stop hooks, and exit behavior. (src/cli/program/message/helpers.ts:37, 670fd2a3fc36)
  • Entry point and retained special case: The message registrar wires all changed modules into one command tree, while thread creation retains its async wrapper because it first normalizes a channel-specific request. (src/cli/program/register.message.ts:55, 670fd2a3fc36)
  • Current main comparison: Current main still contains the prior async wrappers and unused pin array, so this PR is not already implemented or superseded. (src/cli/program/message/register.pins.ts:13, 203024eb33ee)
  • Existing registration coverage: Existing tests cover message registrar wiring and the thread-create normalization boundary, but no checked-in test directly establishes Commander’s returned-Promise action contract. (src/cli/program/register.message.test.ts:104, 670fd2a3fc36)
  • Dependency-contract gap: The patch directly depends on Commander action callback semantics; [email protected] is pinned, but neither its installed source nor upstream source was available because this worktree has no dependency tree and GitHub DNS requests failed. (package.json:2051, 670fd2a3fc36)
  • Feature provenance: Blame on the pre-PR version attributes the pin registration structure to the current main lineage rooted at commit 7bcd8ac; history beyond that object could not be traversed in the partial clone without network. (src/cli/program/message/register.pins.ts:7, 7bcd8accdfde)

Likely related people:

  • Alix-007: Pre-PR blame attributes the affected registration structure to the current main lineage rooted at this author’s commit. (role: prior message-registration contributor; confidence: medium; commits: 7bcd8accdfde; files: src/cli/program/message/register.pins.ts, src/cli/program/message/register.thread.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm [email protected] action/parseAsync behavior from installed source or types and record an exact-head CLI smoke result.

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 (1 earlier review cycle)
  • reviewed 2026-08-25T07:45:56.598Z sha 670fd2a :: needs maintainer review before merge. :: none

@steipete
steipete marked this pull request as ready for review August 25, 2026 08:02
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 25, 2026
@steipete
steipete merged commit 15e8a60 into main Aug 25, 2026
249 checks passed
@steipete
steipete deleted the codex/refactor-cli-commands-dedupe branch August 25, 2026 08:35
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

cli CLI command changes maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

1 participant