feat: add comfy code-search (alias comfy cs) subcommand#386
feat: add comfy code-search (alias comfy cs) subcommand#386
comfy code-search (alias comfy cs) subcommand#386Conversation
Integrate with the comfy-codesearch Vercel API to search code across ComfyUI repositories powered by Sourcegraph. Supports repo filtering, result count limits, and JSON output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@ ## main #386 +/- ## ========================================== + Coverage 67.04% 67.87% +0.83% ========================================== Files 33 34 +1 Lines 3711 3807 +96 ========================================== + Hits 2488 2584 +96 Misses 1223 1223
🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a new comfy code-search CLI subcommand (with hidden alias comfy cs) that queries the comfy-codesearch (Sourcegraph-backed) API and prints either human-friendly Rich output or JSON for machine consumption.
Changes:
- Introduce
comfy_cli/command/code_search.pyimplementing query building, API fetch, result normalization, stats extraction, and output rendering. - Register the new
code-searchandcscommands in the main CLI app. - Add a comprehensive new unit test module covering query building, parsing, error handling, and Typer CLI invocation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
comfy_cli/command/code_search.py | New Typer subcommand for code search; includes API interaction, formatting, and error handling. |
comfy_cli/cmdline.py | Wires the new subcommand into the top-level CLI (plus hidden alias). |
tests/comfy_cli/command/test_code_search.py | New test suite validating query construction, formatting/stats parsing, error handling, and CLI behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address Copilot review: e.response can be None for some HTTPError cases. Fall back to "unknown" status instead of raising AttributeError. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Move `import json` to top-level (no reason to lazy-import stdlib) - Rename `json` parameter to `json_output` to avoid shadowing builtin - Hoist URL base string outside inner match loop - Remove redundant docstrings on self-explanatory private functions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| | ||
| if not results: | ||
| console.print("[yellow]No results found.[/yellow]") | ||
| return | ||
| |
There was a problem hiding this comment.
In --json mode, using Rich console.print() to emit the JSON string can break machine-readable output (Rich may wrap long lines based on terminal width, and any inserted line breaks inside long string values like URLs will produce invalid JSON). Prefer writing directly to stdout without Rich rendering (e.g., typer.echo(...) / print(...)), or explicitly disable wrapping/markup/highlighting when printing the JSON payload.
…alue Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
comfy code-searchsubcommand (aliascomfy cs) that searches code across ComfyUI repositories via the comfy-codesearch Vercel API (Sourcegraph-backed)--repo/-rto filter by repository,--count/-nto limit results, and--json/-jfor machine-readable outputUsage
Demo
Test plan
pytest tests/comfy_cli/command/test_code_search.py)comfy code-search "LoadImage"returns resultscomfy cs "LoadImage"alias workscomfy code-search --json "LoadImage"outputs valid JSONcomfy code-search --repo ComfyUI "SaveImage"filters correctly🤖 Generated with Claude Code