Skip to content

feat: let hand-written commands tune cf cli search results - #448

Merged
MattieTK merged 1 commit into
mainfrom
feat/cli-search-ranking
Oct 29, 2026
Merged

MattieTK merged 1 commit into
mainfrom
feat/cli-search-ranking

Conversation

@MattieTK

Copy link
Copy Markdown
Member

What

cf cli search ranked cf pages deploy first for queries such as "deploy a page", "deploy static site" and "deploy full stack app". That command is an advisory stub that only points to cf deploy. Meanwhile cf deploy described itself as "Deploy a worker to Cloudflare", so it ranked second or dropped out of the top five.

This change:

  • Adds an optional search field to command metadata: { keywords?: string[]; exclude?: boolean }. Hand-written meta.ts sidecars set it, and the generator copies it into _meta/commands.json like any other sidecar field. Keywords are indexed with the same weight as the summary and are never displayed.
  • Leaves out commands that set search.exclude or are marked hideCommand. Completions already skip hidden commands, so search now matches them. On the current OpenAPI pin this removes 177 hidden commands, including internal routes such as cf ready get and cf signed-url get.
  • Excludes cf pages deploy. It still runs and still redirects to cf deploy.
  • Gives cf deploy keywords 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 in hand-written.ts (top-level help) and deploy/index.ts.

Generated commands are out of scope for now. Tuning them would need a Forge annotation.

Ranking notes

I also tried promoting cf deploy with 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 deploy first because the new description contains "application": "deploy access application" and "deploy realtime app". "deploy worker version" also returns cf deploy first, as it does on main.

Testing

  • cli-search.test.ts:
    • cf deploy ranks first for seven deploy queries, and cf pages deploy never appears.
    • Six "deploy " guard queries do not return cf deploy first.
    • "create kv namespace" and "dns record" keep their top results.
    • Unit tests on a synthetic catalogue cover hidden-command filtering, exclude and keyword matching.
  • The existing "searches hidden commands" test is renamed to "matches commands by name and by description". It was added when abuse-reports was hidden; that command is visible now.
  • pnpm check passes in a clean worktree.
  • CLI suite: 3 failures, all unrelated to this change:
    • Two telemetry/dispatcher tests 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 on main locally.

Includes a minor changeset.

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.
@MattieTK
MattieTK requested a review from a team as a code owner October 29, 2026 18:45
@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/cf@448

commit: fbc7edb

@ask-bonk

ask-bonk Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@github-actions

Copy link
Copy Markdown
Contributor

cf --help startup

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.

@clanky-the-clanker

Copy link
Copy Markdown

💬 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 suggestion

A pending changeset from an earlier pull request still says search includes hidden commands

Recommendation: 💬 Optional Nits

  • [SUGGESTION] The pending changeset still says cf cli search includes hidden commands, which this pull request reverses. Consider rewording it so the stable release notes do not contradict cli-search-ranking.md. (.changeset/cli-command-search.md:7)
View full review

.changeset/cli-command-search.md:7 says that cf cli search searches "the complete CLI command catalogue, including hidden commands". The repository is in changeset pre mode, so this pending changeset will probably be included again in the stable release notes, where it would contradict this pull request. The new cli-search-ranking.md changeset does state the new behaviour, so readers can resolve the conflict. Consider rewording the older changeset anyway. The matching line in packages/cli/CHANGELOG.md records a beta release that has already shipped and can stay as it is.


✅ All other checks passed

🚀 Release: ✅ LGTM

Risk: Low. A minor changeset matches a pre-1.0 behaviour change.


🔒 Security: ✅ LGTM

No security concerns. The change only affects local search ranking over bundled command metadata.


📖 AGENTS.md: ✅ LGTM

The changes follow the repository conventions: the sidecar metadata is kept in sync, a conventional commit is used, and a changeset is present.


📋 Code Quality: ✅ LGTM

The search metadata type, the isSearchable filter and the keywords field with boost 5 are consistent. The ranking tests and the synthetic-catalogue unit tests cover hidden-command filtering, exclude and keyword matching.


⚡ Performance: ✅ LGTM

Filtering before indexing shrinks the search index. The extra keywords field adds negligible cost.


Reviewed commit: fbc7edb4

@MattieTK
MattieTK added this pull request to the merge queue Oct 29, 2026

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

Merged via the queue into main with commit 45e01e0 Oct 29, 2026
12 checks passed
@MattieTK
MattieTK deleted the feat/cli-search-ranking branch October 29, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants