← Back to PRs

#6694: fix: Cache completion install

by s0up4200 open 2026-02-01 23:34 View on GitHub →
cli
## Summary - cache generated completion scripts under ~/.openclaw/completions and source them - migrate legacy process-substitution lines during install - add install/migration/idempotency tests ## Why Running `openclaw completion --shell zsh` on every shell startup costs ~1–2s; this makes completion load instant after the first install. ## Testing - pnpm vitest src/cli/completion-cli.test.ts <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR adds a completion install flow that caches generated completion scripts under `~/.openclaw/completions/<bin>.<shell>` and updates shell profile files to `source` the cached file, including migration from legacy process-substitution / pipe-to-source lines. It also adds Vitest coverage for install, legacy migration, binName handling, fish/bash variants, and idempotency. The change fits into the CLI by extending the existing `completion` subcommand in `src/cli/completion-cli.ts` to optionally install completions and by introducing helpers for generating scripts, writing cached files, and updating profile contents. <h3>Confidence Score: 3/5</h3> - Mostly safe to merge, but install idempotency has an unintended side effect (rewriting cached scripts even when no profile changes are needed). - The change is localized to the completion CLI and is covered by tests, but the current install flow writes the cached completion file before the early-return checks, which can cause unexpected overwrites/timestamps and contradicts the intended no-op behavior. - src/cli/completion-cli.ts <!-- greptile_other_comments_section --> **Context used:** - Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8)) - Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13)) <!-- /greptile_comment -->

Most Similar PRs