Repository navigation
feat: add cf cli search keywords for common agent queries - #623
Conversation
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.
|
LGTM |
commit: |
|
| 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
✅ 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
|
LGTM! |
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 inpackages/cli/src/commands/cli/search-keywords.ts.search.tsmerges them with any sidecar keywords when it builds the index.Hand-written commands.
cf deployandcf workers versions createget a "secrets file" keyword in theirmeta.ts, following feat: let hand-written commands tune cf cli search results #448.Entries:
cf workers secrets updatecf workers secrets list,delete,bulkcf workers scripts searchcf workers get,cf workers versions getcf accounts listcf d1 list,cf d1 createcf zero-trust organization getcf o11y telemetry queryHow 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 returnedsecrets listinstead ofcf workers list.Every entry was checked against the search code from the published bundle, three ways:
The one deliberate change: "get worker settings" moves from Workers for Platforms
scripts settings gettocf workers get. That is the right answer for a plain Worker.Tests
cli-search.test.tsnow checks four things:Not covered
Keywords cannot fix these:
cf workers scripts searchcloses the gap.cf workers versions getsecond.cf previews deployfirst. This was already the case onmainand is unchanged here.Testing
pnpm check(generation, lint, format, types) passes.pnpm --filter cf testandpnpm --filter @cloudflare/wrangler-tests testpass.Three existing tests fail on
mainwhen 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.