feat(skills): add search command for published skills#33
Conversation
Introduce `oo skills search <text>` (aliased as `find`) to query the skills search API with free-form text. Supports `--keywords` for comma-separated keyword filtering and `--format=json`/`--json` for structured output. Text output renders title, description, and source package reference per skill entry. Each invocation requests at most 5 results. Signed-off-by: Kevin Cui <bh@bugs.cc>
|
Caution Review failedPull request was closed or merged during review Summary by CodeRabbit
WalkthroughAdds a new CLI subcommand Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/application/commands/skills/search.ts (2)
15-30: Consider consolidating duplicate schemas.
skillSearchJsonResponseSchemaandskillSearchResponseSchemaare identical. Both schemas parse the same structure with identical field definitions. This duplication may cause maintenance burden if the schema needs to change.♻️ Proposed consolidation
-const skillSearchJsonResponseSchema = z.object({ - data: z.array(skillSearchItemSchema).optional().default([]), -}).passthrough(); - -const skillSearchResponseSchema = z.object({ - data: z.array(skillSearchItemSchema).optional().default([]), -}).passthrough(); +const skillSearchResponseSchema = z.object({ + data: z.array(skillSearchItemSchema).optional().default([]), +}).passthrough(); -type SkillSearchJsonResponse = z.output<typeof skillSearchJsonResponseSchema>; -type SkillSearchResponse = z.output<typeof skillSearchResponseSchema>; +type SkillSearchResponse = z.output<typeof skillSearchResponseSchema>;Then use
SkillSearchResponsefor bothjsonandtextinparseSkillsSearchResponse.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/application/commands/skills/search.ts` around lines 15 - 30, skillSearchJsonResponseSchema and skillSearchResponseSchema are duplicates; consolidate by keeping a single schema (e.g., skillSearchResponseSchema or rename to SkillSearchResponseSchema) built from skillSearchItemSchema and use that single schema everywhere (including where parseSkillsSearchResponse expects json and text parsing). Update any references/imports/exports and related type aliases so parseSkillsSearchResponse uses the consolidated schema for both `json` and `text` paths, and remove the now-unneeded duplicate declaration to avoid divergence.
64-68:mapInputErrormay not cover all validation failure scenarios.The
mapInputErrorfunction only produces an "invalid format" error, but theinputSchemavalidates bothtext(required string) andformat(enum). Iftextis somehow invalid (e.g., passed as a non-string in programmatic usage), the error message would incorrectly reference "format".However, since
missingArgumentBehavior: "showHelp"handles the missingtextcase and Commander handles argument type coercion, this is likely a non-issue in practice.Also applies to: 96-102
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/application/commands/skills/search.ts` around lines 64 - 68, The mapInputError currently always returns an "invalid format" message while inputSchema validates multiple fields (text, format, keywords); update mapInputError (used where inputSchema is parsed) to inspect the ZodError issues and return field-specific messages (e.g., "invalid text" when issue.path includes "text", "invalid format" when path includes "format") or a generic "invalid input" with the list of issue messages; reference the ZodError from parsing inputSchema and adjust mapInputError to switch on issue.path/issue.code so validation failures for text are reported correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/application/commands/skills/search.ts`:
- Around line 15-30: skillSearchJsonResponseSchema and skillSearchResponseSchema
are duplicates; consolidate by keeping a single schema (e.g.,
skillSearchResponseSchema or rename to SkillSearchResponseSchema) built from
skillSearchItemSchema and use that single schema everywhere (including where
parseSkillsSearchResponse expects json and text parsing). Update any
references/imports/exports and related type aliases so parseSkillsSearchResponse
uses the consolidated schema for both `json` and `text` paths, and remove the
now-unneeded duplicate declaration to avoid divergence.
- Around line 64-68: The mapInputError currently always returns an "invalid
format" message while inputSchema validates multiple fields (text, format,
keywords); update mapInputError (used where inputSchema is parsed) to inspect
the ZodError issues and return field-specific messages (e.g., "invalid text"
when issue.path includes "text", "invalid format" when path includes "format")
or a generic "invalid input" with the list of issue messages; reference the
ZodError from parsing inputSchema and adjust mapInputError to switch on
issue.path/issue.code so validation failures for text are reported correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e7423168-29df-4bfe-acb5-a112d637dce2
⛔ Files ignored due to path filters (1)
src/application/commands/skills/__snapshots__/search.cli.test.ts.snapis excluded by!**/*.snap
📒 Files selected for processing (7)
docs/commands.mddocs/commands.zh-CN.mdsrc/application/commands/skills/index.tssrc/application/commands/skills/search.cli.test.tssrc/application/commands/skills/search.test.tssrc/application/commands/skills/search.tssrc/i18n/catalog.ts
Apply field-specific terminal colors to skills search text output: title in green (#59F78D) and package label in purple (#CAA8FA). Color support is determined by the stdout writer capabilities. Signed-off-by: Kevin Cui <bh@bugs.cc>
Introduce
oo skills search <text>(aliased asfind) to query the skills search API with free-form text. Supports--keywordsfor comma-separated keyword filtering and--format=json/--jsonfor structured output. Text output renders title, description, and source package reference per skill entry. Each invocation requests at most 5 results.