Repository navigation
feat(drive): search the whole Workspace with optional id and --path-prefix - #139
Merged
Merged
Conversation
Collaborator
Author
驗收報告
AC1–AC9 全部通過,Todo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
使用者遇到的問題
wspc drive search一定要先給 library ID,沒辦法一次搜整個 Workspace,也沒有--path-prefix可以限定資料夾。Backend 早就支援這兩件事,CLI 卻跟不上。更糟的是,
Releaseworkflow 現在每次都會中止:它會先同步 live OpenAPI 再 regenerate,接著跑 typecheck,結果失敗:背景
tod_01M4A59S2BYHGHEB5GWTCVCVCSdocs/superpowers/specs/2026-10-07-drive-search-workspace-scope-design.md(docs(spec): drive search workspace scope and --path-prefix [skip deploy] #138 merged)GET /drive/search(drive_workspace_search),兩個 search endpoint 都接受path_prefix。tools/cli-codegen依 OpenAPI 的x-climetadata 產生,src/generated/不手改。問題出在哪裡
Live spec 裡兩個 op 的
x-cli.command都是drive search,差別只在 per-library 那個有positional: ["id"]。codegen 把 command path 當檔名,每個 op 各寫一次:於是兩個 op 都寫進
drive/search.ts,後寫的蓋掉先寫的,index.ts卻仍 import 兩個名字,typecheck 因此失敗。以前所有 command 名都不重複,「一個 op 對應一個檔」跟「一個 command 對應一個檔」是同一件事,所以一直沒人發現。修法
main.ts新增groupCommands:先收集所有 op,再依x-cli.command分組。fallback。emitCommand收到fallback時:[id]有
id時走原本的driveSearch,kind: "drive_search"與 columns["path","snippet"]跟 0.14.0 相同。與 spec 的差異(已同步更新 spec): spec 原本寫死 argument 說明為
library ID; omit to search every library in the Workspace。但idpath param 在 OpenAPI 沒有 description,要做到這行字,就得在通用 codegen 裡寫死一段 drive 專屬文字。改成由 codegen 用<name>; omit to <fallback summary 首字小寫>產生,實際輸出為id; omit to search drive text across the Workspace。spec 的--help列在第一個 commit(e25d1b5)一併更新。這是設計判斷,請 reviewer 確認。最後執行
npm run sync-spec && npm run generate,提交 regenerated 結果。已知副作用
無。對 committed(舊)spec 重新跑
generate的 diff 為空,其他 78 個 command 的產物不變。測試
tools/cli-codegen/main.test.ts:pair、不同名、非 pair 重名 throw(含兩個 operationId)、三個同名 throw。改動前紅:groupCommands is not a function。tools/cli-codegen/emit.test.ts(AC4):[id]、--path-prefix <value>、兩個 operation、兩個 kind、id === undefined分支、fallback summary。改動前 2 個測試紅(輸出沒有[id],也沒有第二個 operation)。test/generated/drive.test.ts(AC1–AC3、AC5):省略 id 時只呼叫driveWorkspaceSearch、給 id 時只呼叫driveSearch(未被呼叫的那個斷言 0 次)、path/query/kind/columns、--path-prefix與--cursor原樣送出、helpInformation()含[id]、--path-prefix <value>、--cursor說明含path_prefix。把drive/search.ts換回 0.14.0 的產物後,4 個測試全紅:process.exit unexpectedly called with "1"(缺<id>/未知 option)、expected 'Usage: search [options] <id>…' to contain '[id]'。npm run typecheck、npm test(68 files / 826 tests)、npm run build全綠。AC5(
npm run build後node dist/cli.js drive search --help,採自動化,另貼輸出):AC6:
spec/openapi.json含/drive/search;src/generated/cli/index.ts只有一行import { driveSearchCommand } from "./drive/search.js"。AC7 readback(乾淨 working tree):
Live spec 與先前 committed spec 的 path 差異只有新增
/drive/search,沒有 search 以外的 drift。AC8 live transcript(
node dist/cli.js,已登入帳號;只留欄位與 status,查詢詞與內容省略):drive search --query <term> --limit 2 --jsonlibrary_id, path, snippet,有next_cursordrive search <lib> --query <term> --path-prefix <folder>/ --jsonnext_cursor加--cursor續頁--cursor old-string-cursorHTTP 400,bodyerror.code = "VALIDATION_ERROR"Review 結果
src/generated/只由 pipeline 產生、未碰 spec 列為「不要碰」的檔案。未完成驗收
npx -y -p @wspc/cli@latest wspc drive search --help應顯示[id]與--path-prefix。屬 post-release 手動驗收,Releaseworkflow 由使用者手動觸發(spec Out of Scope),不是 merge gate。🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.