Skip to content

fix(cli): honor shell-owned completion profile locations - #117002

Merged
steipete merged 3 commits into
mainfrom
codex/wave3-cli-shell-profile-owner
Jul 31, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/wave3-cli-shell-profile-owner

Conversation

@steipete

@steipete steipete commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Two operator-visible root causes affected shell-completion installation and recovery:

  1. Installation, installed-state checks, onboarding, and Doctor disagreed about the startup file owned by Zsh $ZDOTDIR, Fish $XDG_CONFIG_HOME, Bash, or PowerShell. The wizard could install completion into the correct custom profile and immediately instruct the operator to reload a different file.
  2. Reload instructions interpolated shell-profile paths unsafely, so spaces, apostrophes, history-expansion characters, literal relative paths, or symlink traversal could prevent completion from loading.

Why This Change Was Made

  • Use one canonical profile-path owner and one canonical display hint for the installer, installed-state checks, onboarding, and Doctor.
  • Preserve Zsh's explicitly empty $ZDOTDIR, shell-owned relative directories, and filesystem symlink-before-.. traversal.
  • Honor absolute Fish $XDG_CONFIG_HOME values verbatim, including meaningful whitespace; ignore invalid relative values as required by the XDG Base Directory Specification.
  • Generate shell-correct quoted reload commands while preserving executable ~/ expansion, existing localized onboarding text, Bash profile selection, and PowerShell dot sourcing.
  • Delete installer shell switches, the wizard's duplicated async profile lookup, Doctor's parallel path resolver, and single-use formatting wrappers.

User Impact

Completion is written into the file the actual shell reads. Direct installation, onboarding, and Doctor all display an executable reload command for that same file. No CLI flags, configuration keys, migrations, storage, or security behavior are added.

Inspectable Real-Behavior Proof

Exact tested head: 0048d0527156fd4161028b91dde50910ab0b5437.

The following is redacted output captured from the actual production onboarding function, production completion installer, production Doctor repair, and a real interactive /bin/zsh process. The run used temporary HOME, USERPROFILE, state, and profile directories; all temporary state was removed. Completion caches were prewritten and verified instead of invoking the unrelated cache-generation subprocess.

HEAD=0048d0527156fd4161028b91dde50910ab0b5437

ZDOTDIR profile=<TEMP>/zsh/Ada's !42 startup/.zshrc
Zsh expected reload=source '<TEMP>/zsh/Ada'\''s !42 startup/.zshrc'
Zsh actual wizard=Shell completion installed. Restart your shell or run: source '<TEMP>/zsh/Ada'\''s !42 startup/.zshrc'
Zsh actual Doctor=Shell completion upgraded. Restart your shell or run: source '<TEMP>/zsh/Ada'\''s !42 startup/.zshrc'
Zsh actual wizard wrote canonical profile=true
Zsh actual Doctor repaired slow profile=true
Zsh real interactive startup=true

XDG_CONFIG_HOME profile=<TEMP>/fish/Ada's !42 startup/fish/config.fish
Fish expected reload=source '<TEMP>/fish/Ada\'s !42 startup/fish/config.fish'
Fish actual wizard=Shell completion installed. Restart your shell or run: source '<TEMP>/fish/Ada\'s !42 startup/fish/config.fish'
Fish actual Doctor=Shell completion upgraded. Restart your shell or run: source '<TEMP>/fish/Ada\'s !42 startup/fish/config.fish'
Fish actual wizard wrote canonical profile=true
Fish actual Doctor repaired slow profile=true

RESULT=PASS

The Fish installer, startup-profile contents, onboarding output, and Doctor repair were exercised directly; a native Fish shell executable was not available, so native Fish execution is not claimed.

Focused Verification

node scripts/run-vitest.mjs src/cli/completion-runtime.test.ts src/cli/completion-cli.write-state.test.ts src/cli/completion-cli.test.ts
node scripts/run-vitest.mjs src/wizard/setup.completion.test.ts
node scripts/run-vitest.mjs src/commands/doctor-completion.test.ts
  • macOS with real interactive Zsh: 92 CLI tests passed.
  • Linux-style environment where launching Zsh genuinely returns ENOENT: the same 92 CLI tests passed; Bash execution remains mandatory.
  • Actual-installer-backed onboarding: 10 wizard tests passed, including custom Zsh and Fish roots containing spaces, apostrophes, and !.
  • Doctor completion and recovery: 19 tests passed.
  • Real filesystem regressions cover symlink/.. traversal for Zsh, Bash, Fish, and PowerShell; explicit empty $ZDOTDIR; valid whitespace-bearing XDG roots; rejected relative XDG roots; Windows drive and UNC paths; literal relative Zsh roots; and consistent direct-install reload output.
  • Existing Chinese localization and concrete PowerShell reload instructions remain unchanged.
  • Whole-branch production delta: +76/-79 (net -3); tests are counted separately.
  • Independent owner-boundary reviews found no remaining P0/P1/P2/P3 issues.
  • Exact-head structured whole-branch Codex Sol/high --max-priority P3 review: zero findings; patch correct; confidence 0.92; real TruffleHog clean.

ClawSweeper Rank-Up Moves

  • Canonical owner: installation, status, onboarding, direct CLI reload output, and Doctor now all consume the canonical shell-profile resolver and display hint.
  • Real behavior proof: the redacted transcript above shows actual custom Zsh/Fish installation, actual wizard and Doctor reload guidance, and a real interactive Zsh startup on the exact candidate head.
  • Current-head / merge-result freshness: evidence is tied to the exact SHA shown above. If GitHub requires a merge-result refresh, perform it during the normal maintainer prepare/merge flow; no unnecessary rebase is claimed.

Explicit Exclusions

No public CLI/setup flags, configuration or environment-variable surface, persisted state, SQLite/schema, authentication/security policy, plugin SDK, Gateway protocol, dependency, locale-catalog, or release-note changes.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: S maintainer Maintainer-authored PR labels Jul 31, 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 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 6:37 PM ET / 22:37 UTC.

ClawSweeper review

What this changes

The PR centralizes shell-completion profile discovery and reload hints so installation, setup, and Doctor honor shell-owned Zsh, Fish, Bash, and PowerShell locations and quote reload commands safely.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

The PR addresses a source-proven completion-profile mismatch and now includes credible exact-head terminal proof. Keep it open for the protected maintainer review and completed merge-result checks; this sandbox could not retrieve the complete PR objects for an independent full-diff pass because its promisor fetch could not resolve GitHub.

Priority: P2
Reviewed head: 0048d0527156fd4161028b91dde50910ab0b5437
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has credible root-cause coverage and real terminal proof; final readiness depends on the protected maintainer decision, completed checks, and an exact-head merge-result review.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body now contains redacted exact-head terminal output showing custom Zsh and Fish installer/onboarding/Doctor behavior plus a real interactive Zsh startup; it appropriately does not claim a native Fish run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body now contains redacted exact-head terminal output showing custom Zsh and Fish installer/onboarding/Doctor behavior plus a real interactive Zsh startup; it appropriately does not claim a native Fish run.
Evidence reviewed 5 items Current-main root cause: Current main resolves Zsh and Fish profiles from fixed HOME-based defaults, so ZDOTDIR and XDG_CONFIG_HOME are not represented by the canonical profile owner.
Current-main consumer mismatch: The setup wizard separately hard-codes Zsh and Fish reload hints, while the runtime formatter emits an unquoted POSIX source command; shell-significant profile paths can therefore yield incorrect guidance.
Feature provenance: Current-main history and blame attribute the completion resolver, installed-state checks, and installer path to Peter Steinberger's completion implementation commit.
Findings None None.
Security None None.

How this fits together

OpenClaw writes generated completion scripts into each shell's startup profile, then its setup wizard and Doctor tell operators how to reload that profile. The resolver feeds installation and status checks, while the user-facing guidance follows afterward.

flowchart LR
  A[Shell environment] --> B[Profile resolver]
  B --> C[Completion installer]
  B --> D[Installed-state check]
  C --> E[Setup wizard guidance]
  D --> F[Doctor repair guidance]
  E --> G[Operator reload command]
  F --> G
Loading

Decision needed

Question Recommendation
After CI finishes, should the maintainer accept this exact-head compatibility repair for shell completion profiles and reload commands? Approve after merge-result review: Inspect the exact merge result and completed checks, then merge if the intended profile behavior is preserved for all supported shells.

Why: The protected maintainer label requires explicit human handling, and this environment could not inspect the complete PR object set or final merge result.

Before merge

  • Resolve merge risk (P1) - Changing profile resolution and reload commands can affect existing Bash, Zsh, Fish, and PowerShell completion setups, so the exact merge result needs compatibility review.
  • Resolve merge risk (P1) - GitHub reports the branch is behind main and required checks are still in progress; review the refreshed merge result before landing.
  • Resolve merge risk (P1) - The complete PR objects were unavailable in this sandbox after its promisor fetch failed on DNS, preventing an independent full-diff and history pass.
Agent review details

Security

None.

PR surface

Source -3, Tests +362. Total +359 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 76 79 -3
Tests 4 402 40 +362
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 478 119 +359

Review metrics

None.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor-completion.test.ts, migration/backfill/repair: src/commands/doctor-completion.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Verify all shell upgrade paths (recommended)
    Before merge, inspect the exact merge result and completed CI for default and custom Bash, Zsh, Fish, and PowerShell profile selection.
  2. Pause pending complete source access
    Leave the PR open until a reviewer can retrieve and inspect the complete branch objects and final merge result.

Technical review

Best possible solution:

Use one canonical profile resolver and display hint, then merge only after exact-head review confirms default and shell-owned profile behavior remains compatible across Bash, Zsh, Fish, and PowerShell.

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

Yes. Current source shows that the profile resolver omits ZDOTDIR and XDG_CONFIG_HOME, while setup independently hard-codes default paths; the supplied exact-head terminal transcript demonstrates the repaired behavior.

Is this the best way to solve the issue?

Yes, provisionally. Reusing one canonical resolver and display hint repairs the owner boundary instead of compensating in the wizard or Doctor, but the full branch still needs an exact merge-result review.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: Profile-resolution and reload-command changes can alter behavior for existing shell and environment setups.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body now contains redacted exact-head terminal output showing custom Zsh and Fish installer/onboarding/Doctor behavior plus a real interactive Zsh startup; it appropriately does not claim a native Fish run.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body now contains redacted exact-head terminal output showing custom Zsh and Fish installer/onboarding/Doctor behavior plus a real interactive Zsh startup; it appropriately does not claim a native Fish run.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This fixes a bounded but operator-visible CLI completion installation and recovery workflow.
  • merge-risk: 🚨 compatibility: Profile-resolution and reload-command changes can alter behavior for existing shell and environment setups.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 now contains redacted exact-head terminal output showing custom Zsh and Fish installer/onboarding/Doctor behavior plus a real interactive Zsh startup; it appropriately does not claim a native Fish run.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body now contains redacted exact-head terminal output showing custom Zsh and Fish installer/onboarding/Doctor behavior plus a real interactive Zsh startup; it appropriately does not claim a native Fish run.

Evidence

What I checked:

  • Current-main root cause: Current main resolves Zsh and Fish profiles from fixed HOME-based defaults, so ZDOTDIR and XDG_CONFIG_HOME are not represented by the canonical profile owner. (src/cli/completion-runtime.ts:265, 61fb29e90a59)
  • Current-main consumer mismatch: The setup wizard separately hard-codes Zsh and Fish reload hints, while the runtime formatter emits an unquoted POSIX source command; shell-significant profile paths can therefore yield incorrect guidance. (src/wizard/setup.completion.ts:33, 61fb29e90a59)
  • Feature provenance: Current-main history and blame attribute the completion resolver, installed-state checks, and installer path to Peter Steinberger's completion implementation commit. (src/cli/completion-runtime.ts:299, 8978ef44f302)
  • After-fix behavior proof: The PR body includes a redacted terminal transcript at head 0048d0527156fd4161028b91dde50910ab0b5437 showing installer, setup wizard, Doctor, and an interactive Zsh process use the same custom profile; it appropriately does not claim native Fish-shell execution. (0048d0527156)
  • Review infrastructure gap: Resolving the base-to-head diff required a missing promisor object, but the checkout could not fetch it because DNS resolution for GitHub failed. The full exact-head diff and branch-history pass could not be completed in this environment.

Likely related people:

  • Peter Steinberger: Current-main history and blame attribute the completion resolver, installer, and status behavior to this author. (role: current implementation author and recent area contributor; confidence: high; commits: 8978ef44f302; files: src/cli/completion-runtime.ts, src/wizard/setup.completion.ts, src/commands/doctor-completion.ts)

Rank-up moves

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

  • Review the final GitHub merge result after the in-progress checks finish.

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 (3 earlier review cycles)
  • reviewed 2026-07-31T19:14:15.465Z sha 058eb61 :: needs real behavior proof before merge. :: [P2] Route setup-wizard reload guidance through the resolver
  • reviewed 2026-07-31T20:02:58.659Z sha 058eb61 :: needs real behavior proof before merge. :: [P2] Use the canonical resolver for setup-wizard profile hints
  • reviewed 2026-07-31T21:18:55.959Z sha 0dc3f2b :: needs real behavior proof before merge. :: none

@steipete
steipete marked this pull request as ready for review July 31, 2026 19:26
@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. and removed 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. labels Jul 31, 2026
@steipete
steipete merged commit 6b40ad6 into main Jul 31, 2026
126 of 136 checks passed
@clawsweeper clawsweeper Bot added the status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. label Jul 31, 2026
@steipete
steipete deleted the codex/wave3-cli-shell-profile-owner branch July 31, 2026 22:41
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jul 31, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…7002)

* fix(cli): honor shell-owned completion profile locations

* test(cli): isolate completion profiles across platforms

* fix(wizard): reuse canonical completion profile hints

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: L 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