Skip to content

feat: add cf cli search keywords for common agent queries - #623

Merged
petebacondarwin merged 3 commits into
mainfrom
feat/cli-search-worker-secrets-keywords
Nov 17, 2026
Merged

petebacondarwin merged 3 commits into
mainfrom
feat/cli-search-worker-secrets-keywords

Conversation

@MattieTK

Copy link
Copy Markdown
Member

Agents find commands with cf cli search. For several of the phrasings they use most, the right command is not first. Usually a Workers for Platforms command, a D1 insights or migrations command, or another sibling wins.

Changes

  • Keywords for generated commands. Generated commands have no sidecar to carry search.keywords, so their keywords live in packages/cli/src/commands/cli/search-keywords.ts. search.ts merges them with any sidecar keywords when it builds the index.

  • Hand-written commands. cf deploy and cf workers versions create get a "secrets file" keyword in their meta.ts, following feat: let hand-written commands tune cf cli search results #448.

  • Entries:

    Command Fixes queries such as
    cf workers secrets update "set worker secret", "put worker secret", "wrangler secret put", "create worker secret"
    cf workers secrets list, delete, bulk "list worker secret names", "wrangler secret bulk"
    cf workers scripts search "list worker scripts", "list workers scripts in account"
    cf workers get, cf workers versions get "get worker script settings"
    cf accounts list "list accounts"
    cf d1 list, cf d1 create "list D1 databases", "create a D1 database"
    cf zero-trust organization get "get zero trust organization"
    cf o11y telemetry query "query worker logs"

How the keywords were chosen

Each entry adds only words that its command's path does not already contain.

A word repeated from the path, which has the highest boost, over-weights that command for that word. An early version added "secret list" to cf workers secrets list, and "list workers" then returned secrets list instead of cf workers list.

Every entry was checked against the search code from the published bundle, three ways:

  • Logged queries: the query that prompted the entry ranks the right command first.
  • Held-out phrasings: extra wordings, not used for tuning.
  • Regressions:
    • Top results: about 150 other queries keep the same top result, apart from the one deliberate change below.
    • Self-search: every command, searched by its own summary, ranks no worse than before.

The one deliberate change: "get worker settings" moves from Workers for Platforms scripts settings get to cf workers get. That is the right answer for a plain Worker.

Tests

cli-search.test.ts now checks four things:

  • Every table entry names a real command.
  • No keyword repeats a word from its command's path.
  • The queries each entry is for rank the right command first.
  • Guarded results do not move: Workers for Platforms, tenants, D1 insights and migrations, Secrets Store and Turnstile.

Not covered

Keywords cannot fix these:

  • No command exists for GraphQL Analytics queries, Worker custom domains, Worker routes, the workers.dev subdomain, or live Worker tail. Each currently returns an unrelated command first.
  • Workers for Platforms still wins "list workers scripts". Its path contains both "workers" and "scripts", and no new word on cf workers scripts search closes the gap.
  • "get worker script settings bindings" ranks cf workers versions get second.
  • "wrangler deploy" returns cf previews deploy first. This was already the case on main and is unchanged here.

Testing

  • pnpm check (generation, lint, format, types) passes.
  • pnpm --filter cf test and pnpm --filter @cloudflare/wrangler-tests test pass.

Three existing tests fail on main when run locally from inside a coding agent or under a non-US locale. The telemetry dispatcher tests detect the running agent, and the auth profiles snapshot formats dates by locale. With those variables unset they pass.

Agents find commands with `cf cli search`, and several of the phrasings
they use most rank a Workers for Platforms command, a D1 insights or
migrations command, or another sibling first. Setting a Worker secret is
the clearest case: "set worker secret" and "wrangler secret put" never
return `cf workers secrets update`, because its path and summary say
"update" and "add", and short query words fuzzy-match "get" and "delete".

Generated commands have no sidecar for `search.keywords`, so their
keywords now live in `commands/cli/search-keywords.ts`, merged into the
index next to sidecar keywords. Each entry adds only words its command's
path lacks; a word repeated from the path over-weights that command and
it starts winning unrelated searches. Tests check that every entry names
a real command, enforce the path rule, and pin the queries each entry is
for plus results that must not move. `cf deploy` and
`cf workers versions create` gain a "secrets file" keyword in their
sidecars.
@ask-bonk

ask-bonk Bot commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented Nov 14, 2026 •

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

commit: 8e01d52

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

cf --help startup

mean stddev min max
PR 286.4 ms 2.8 ms 281.9 ms 293.6 ms
base 285.6 ms 3.8 ms 280.4 ms 292.7 ms

Δ (PR vs base): — +0.8 ms (+0.3%)

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.

@MattieTK
MattieTK marked this pull request as ready for review November 16, 2026 16:47
@MattieTK
MattieTK requested a review from a team as a code owner November 16, 2026 16:47
@MattieTK
MattieTK requested a review from NuroDev November 16, 2026 16:47

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Superseded by the review of 8e01d52d.

This review, of 6cdcb07d

✅ Approved — The keyword table and its merge into the search index are small and well covered by the new tests, and I found no issues.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

The minor changeset fits a user-facing behaviour change before 1.0.


🔒 Security: ✅ LGTM

No security-relevant changes.


📖 AGENTS.md: ✅ LGTM

The meta.ts sidecars and the generated metadata change together, and a changeset is included.


📋 Code Quality: ✅ LGTM

The keyword merge in search.ts keeps search entries the same for commands without keywords. The new tests cover every table entry, the rule that keywords must not repeat path words, and the results that must not move.


⚡ Performance: ✅ LGTM

Looking up the table once per command while the index is built costs very little.


📝 Documentation: ✅ LGTM

The module comment and the inline comments explain why each keyword was chosen.


Reviewed commit: 6cdcb07d

@petebacondarwin
petebacondarwin added this pull request to the merge queue Nov 17, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 17, 2026

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — The only change since the last review renames the bulk secret command, and that name matches the generated command. No issues found.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🚀 Release: ✅ LGTM

The minor changeset fits a user-facing behaviour change before 1.0. The tests cover the new keyword queries and the search results that must not move.


🔒 Security: ✅ LGTM

No security-relevant changes.


📖 AGENTS.md: ✅ LGTM

The meta.ts sidecars and the generated metadata change together, and a changeset is included.


📋 Code Quality: ✅ LGTM

The bulk-edit rename in search-keywords.ts and in the test matches the generated cf workers secrets bulk-edit command. The keyword merge in search.ts gives commands without table keywords the same search document as before.


⚡ Performance: ✅ LGTM

Looking up the keyword table once per command while the index is built costs very little.


📝 Documentation: ✅ LGTM

The module comment and the inline comments explain why each keyword was chosen.


Reviewed commit: 8e01d52d

@ask-bonk

ask-bonk Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

LGTM!

github run

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.

2 participants