Skip to content

fix(cli): 空关键词回退本地搜索;SDK 复用 FederatedSearchParams 与 limit 校验#13

Merged
chenchenchenchencj merged 4 commits into
masterfrom
cccc
Mar 7, 2026
Merged

fix(cli): 空关键词回退本地搜索;SDK 复用 FederatedSearchParams 与 limit 校验#13
chenchenchenchencj merged 4 commits into
masterfrom
cccc

Conversation

@chenchenchenchencj

Copy link
Copy Markdown
Collaborator
  • CLI search: 非 --local 且无 keyword 时回退到 searchGenes,避免空串请求联邦搜索
  • SDK: federatedSearch 参数改用 FederatedSearchParams 类型
  • SDK: limit 仅当正有限数时写入 URL

Made-with: Cursor

- CLI search: 非 --local 且无 keyword 时回退到 searchGenes,避免空串请求联邦搜索
- SDK: federatedSearch 参数改用 FederatedSearchParams 类型
- SDK: limit 仅当正有限数时写入 URL

Made-with: Cursor
Copilot AI review requested due to automatic review settings March 6, 2026 13:20

Copilot AI 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.

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 of federatedSearch when no meaningful keyword is provided.
  • SDK: federatedSearch signature now uses the shared FederatedSearchParams type instead of an inline object type.
  • SDK: limit is only added to the query string when it is a positive finite number, instead of the previous != null check.

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.

Comment thread packages/cli/src/commands/search.ts
Comment on lines +81 to +83
if (Number.isFinite(params.limit) && (params.limit as number) > 0) {
qs.set('limit', String(params.limit));
}

Copilot AI Mar 6, 2026

Copy link

Choose a reason for hiding this comment

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

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 uses AI. Check for mistakes.
Comment thread packages/cli/src/commands/search.ts
@chenchenchenchencj

Copy link
Copy Markdown
Collaborator Author

@copilot open a new pull request to apply changes based on the comments in this thread

Copilot AI commented Mar 6, 2026

Copy link
Copy Markdown

@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.

chenchenchenchencj and others added 2 commits March 6, 2026 21:28
[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
@chenchenchenchencj chenchenchenchencj merged commit b74662c into master Mar 7, 2026
2 checks passed
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