fix(cli): 空关键词回退本地搜索;SDK 复用 FederatedSearchParams 与 limit 校验#13
Conversation
- CLI search: 非 --local 且无 keyword 时回退到 searchGenes,避免空串请求联邦搜索 - SDK: federatedSearch 参数改用 FederatedSearchParams 类型 - SDK: limit 仅当正有限数时写入 URL Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR fixes the CLI search command so that when no keyword is provided (and --local is not set), it falls back to the local searchGenes API instead of issuing a federated search with an empty string. It also refactors the SDK to reuse the shared FederatedSearchParams type and improves the limit parameter guard to only append it when the value is a positive finite number.
Changes:
- CLI: Adds an empty/blank keyword check; routes to
searchGenes(local DB) instead offederatedSearchwhen no meaningful keyword is provided. - SDK:
federatedSearchsignature now uses the sharedFederatedSearchParamstype instead of an inline object type. - SDK:
limitis only added to the query string when it is a positive finite number, instead of the previous!= nullcheck.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
packages/cli/src/commands/search.ts |
Adds trimmedKeyword check and a new searchGenes fallback path for empty keyword |
packages/sdk/typescript/src/client.ts |
Adopts FederatedSearchParams type and strengthens limit guard |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (Number.isFinite(params.limit) && (params.limit as number) > 0) { | ||
| qs.set('limit', String(params.limit)); | ||
| } |
There was a problem hiding this comment.
The new Number.isFinite(params.limit) && (params.limit as number) > 0 guard means that a limit of 0 or a negative value will silently be omitted from the query string, which changes the previous behavior (previously limit: 0 would have been sent as limit=0). There is no test covering this new boundary condition — passing limit: 0 or limit: -1 should be verified to not append a limit parameter. A test case for this would make the new behavior explicit and prevent regressions.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@chenchenchenchencj I've opened a new pull request, #14, to work on those changes. Once the pull request is ready, I'll request review from you. |
[WIP] Fix CLI to fallback to local search without keyword
- info.ts: loadConfig + getGene,formatGene 输出,支持 --json - index.ts: 注册 infoCommand - commands.test.ts: 预期列表加入 info Made-with: Cursor
Made-with: Cursor