Repository navigation
feat: let hand-written commands tune cf cli search results - #448
Conversation
Agents searching for how to deploy a page or static site were led to `cf pages deploy`, an advisory stub that only points to `cf deploy`, while `cf deploy` itself did not mention static sites or Pages. Command metadata gains an optional `search` field with extra keywords and an `exclude` flag. Search skips excluded commands and commands hidden from help, matching completions. `cf pages deploy` is excluded, and `cf deploy` gains keywords and a description covering Workers, static sites, and full-stack applications.
commit: |
|
LGTM |
|
| mean | stddev | min | max | |
|---|---|---|---|---|
| PR | 282.2 ms | 4.4 ms | 276.0 ms | 291.6 ms |
| base | 281.1 ms | 3.5 ms | 277.4 ms | 288.5 ms |
Δ (PR vs base): ↑ +1.1 ms (+0.4%)
Measured with hyperfine on ubuntu-latest (3 warmup runs, 20 timed runs). CI numbers carry ±a few ms of runner jitter; treat small deltas as noise.
|
💬 Approved with comments — The change is clean and well tested. The only note is optional: an earlier, still-pending changeset says search includes hidden commands, which this pull request reverses. Findings: 1 suggestion The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 📝 Documentation: 💬 1 suggestionA pending changeset from an earlier pull request still says search includes hidden commands Recommendation: 💬 Optional Nits
View full review
✅ All other checks passed🚀 Release: ✅ LGTMRisk: Low. A 🔒 Security: ✅ LGTMNo security concerns. The change only affects local search ranking over bundled command metadata. 📖 AGENTS.md: ✅ LGTMThe changes follow the repository conventions: the sidecar metadata is kept in sync, a conventional commit is used, and a changeset is present. 📋 Code Quality: ✅ LGTMThe ⚡ Performance: ✅ LGTMFiltering before indexing shrinks the search index. The extra keywords field adds negligible cost. Reviewed commit: |
What
cf cli searchrankedcf pages deployfirst for queries such as "deploy a page", "deploy static site" and "deploy full stack app". That command is an advisory stub that only points tocf deploy. Meanwhilecf deploydescribed itself as "Deploy a worker to Cloudflare", so it ranked second or dropped out of the top five.This change:
searchfield to command metadata:{ keywords?: string[]; exclude?: boolean }. Hand-writtenmeta.tssidecars set it, and the generator copies it into_meta/commands.jsonlike any other sidecar field. Keywords are indexed with the same weight as the summary and are never displayed.search.excludeor are markedhideCommand. Completions already skip hidden commands, so search now matches them. On the current OpenAPI pin this removes 177 hidden commands, including internal routes such ascf ready getandcf signed-url get.cf pages deploy. It still runs and still redirects tocf deploy.cf deploykeywords for Pages, static sites and full-stack apps, and changes its description to "Deploy a Worker, static site, or full-stack application to Cloudflare". The same wording replaces the two older descriptions inhand-written.ts(top-level help) anddeploy/index.ts.Generated commands are out of scope for now. Tuning them would need a Forge annotation.
Ranking notes
I also tried promoting
cf deploywith a score multiplier. Its one-word name already scores highly on "deploy", so the multiplier put it first for unrelated queries such as "deploy firewall rule", "deploy origin certificate" and "deploy snippets". Keywords alone rank it first for every target query, so this PR has no promote or demote option.Two queries still return
cf deployfirst because the new description contains "application": "deploy access application" and "deploy realtime app". "deploy worker version" also returnscf deployfirst, as it does onmain.Testing
cli-search.test.ts:cf deployranks first for seven deploy queries, andcf pages deploynever appears.cf deployfirst.excludeand keyword matching.abuse-reportswas hidden; that command is visible now.pnpm checkpasses in a clean worktree.telemetry/dispatchertests fail only when run from inside an AI agent session and pass without the agent environment variables.auth/profiles"warns that login and logout target default in a bound directory" also fails onmainlocally.Includes a minor changeset.