Skip to content

feat: US-04-05 CLI Search Command#28

Merged
olexmal merged 13 commits into
mainfrom
feature/US-04-05-cli-search-command
Mar 6, 2026
Merged

feat: US-04-05 CLI Search Command#28
olexmal merged 13 commits into
mainfrom
feature/US-04-05-cli-search-command

Conversation

@olexmal

@olexmal olexmal commented Mar 6, 2026

Copy link
Copy Markdown
Owner

Implements all tasks from US-04-05-cli-search-command-tasks.md.

  • T1: SearchCommand Picocli class
  • T2: Filter options (--language, --repo, --type, --limit, --json, --quiet)
  • T3: Human-readable result formatting
  • T4: Syntax highlighting (Jansi, --no-color)
  • T5: JSON output mode (full / --quiet results array)
  • T6: Command tests, >80% coverage

Resolves US-04-05.

Made with Cursor

olexmal added 13 commits March 6, 2026 22:16
- Add IngestCommand in io.megabrain.cli with @command(name = "ingest")
- Add MegaBrainCommand as @topcommand with ingest subcommand
- IngestCommandTest: command name, --help, no-args run
- Docs: api-reference, cli-reference, getting-started, implemented-features

Resolves T1: US-04-04 CLI Ingest Command

Made-with: Cursor
- Add --source, --repo, --branch, --token, --incremental with validation
- Reuse IngestionResource.SourceType; validate source and repo non-blank
- Extend IngestCommandTest for options, defaults, help, validation
- Update cli-reference, api-reference, implemented-features

Resolves T2: US-04-04 CLI Ingest Command

Made-with: Cursor
- Inject IngestionService into IngestCommand; subscribe to Multi<ProgressEvent>
- Single-line \r updates for TTY, line-by-line for non-TTY; cap message length
- Tests: mock IngestionService, assert progress messages and full/incremental routing
- Docs: cli-reference progress subsection, api-reference, implemented-features T3

Resolves T3: US-04-04 CLI Ingest Command

Made-with: Cursor
- @command(exitCodeOnInvalidInput=2, exitCodeOnExecutionException=1)
- Throw ExecutionException on ingestion failure; ParameterException for invalid args
- Tests: assert execute() returns 0, 1, 2 for success, failure, invalid args
- Docs: cli-reference exit codes subsection, implemented-features

Resolves T4: US-04-04 CLI Ingest Command

Made-with: Cursor
- Add --verbose option; set io.megabrain logger to DEBUG when true
- Fuller progress and stack traces on errors when verbose
- Tests: help contains --verbose; optional verbose behavior
- Docs: cli-reference options and Verbose subsection, implemented-features

Resolves T5: US-04-04 CLI Ingest Command

Made-with: Cursor
- Step 1: Parse task file; stop if all completed
- Step 2: Create feature branch (git checkout -b feature/<story-slug>)
- Steps 3-4: Per-task council/implement/commit, then full test suite
- Step 5: Commit any remaining changes, push branch, gh pr create

Documents exact gh commands: gh pr create --title/--body or --fill.
Prerequisite: gh installed and authenticated (gh auth status).

Made-with: Cursor
- Token never in output; repo trim; exit-code spec; branch default in help
- Non-verbose truncation; null progress message; missing --repo exit 2
- MegaBrainCommand help test; io.megabrain.cli >80% coverage (84% line, 80% branch)
- Docs: implemented-features Done, development-guide CLI testing note

Resolves T6: US-04-04 CLI Ingest Command

Made-with: Cursor
- SearchCommand with @command(name = "search"), query @parameters, help mixin
- Register SearchCommand in MegaBrainCommand subcommands
- SearchCommandTest: command name, --help, query parsing, blank query exit 2
- docs: cli-reference megabrain search, getting-started, implemented-features US-04-05

Resolves T1: Create SearchCommand Picocli class

Made-with: Cursor
- --language, --repo, --type (repeatable), --limit (default 10), --json, --quiet
- Validate language and entity_type against allowed sets; limit 1-100
- Build SearchRequest in run(); ParameterException for invalid options
- SearchCommandTest: option parsing, defaults, multi-value, validation, help
- docs: cli-reference options table and examples, implemented-features T2

Resolves T2: Add filter options

Made-with: Cursor
- SearchResultMapper (MergedResult -> SearchResult) shared by SearchResource and CLI
- SearchResultFormatter interface and HumanReadableSearchResultFormatter
- Format: File, Entity, Score, snippet, ---; truncation; quiet one-line per result
- SearchCommand injects SearchOrchestrator, formatter, config; runs search and prints formatted output
- SearchResultFormatterTest and SearchCommandTest updates
- docs: cli-reference format description, implemented-features T3

Resolves T3: Implement result formatting

Made-with: Cursor
- Jansi dependency; SyntaxHighlighter interface and CliSyntaxHighlighter (Java, Python, JS, TS)
- HumanReadableSearchResultFormatter uses highlighter; format(response, quiet, useColor)
- SearchCommand --no-color; resolve useColor (NO_COLOR env, TTY)
- CliSyntaxHighlighterTest, SearchResultFormatterTest, SearchCommandTest updates
- docs: cli-reference --no-color and highlighting, implemented-features T4

Resolves T4: Add syntax highlighting

Made-with: Cursor
- Inject ObjectMapper; when --json serialize SearchResponse or results only (--quiet)
- Pretty when TTY and not quiet; compact otherwise; write to getOut() and flush
- SearchCommandTest: full JSON shape, --json --quiet array, empty results
- docs: cli-reference JSON subsection, implemented-features T5, getting-started --json

Resolves T5: Add JSON output mode

Made-with: Cursor
- Orchestrator failure, JSON null ObjectMapper, JSON serialization failure
- NO_COLOR env (SystemStubs), filter normalization, --quiet human-readable
- JSON with facets; CaptureUseColorFormatter lastQuiet
- implemented-features US-04-05 Done, T6 completed, >80% coverage

Resolves T6: Write command tests

Made-with: Cursor
@sonarqubecloud

sonarqubecloud Bot commented Mar 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
74.7% Coverage on New Code (required ≥ 80%)
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@olexmal olexmal self-assigned this Mar 6, 2026
@olexmal olexmal merged commit 878c191 into main Mar 6, 2026
6 of 7 checks passed
@olexmal olexmal deleted the feature/US-04-05-cli-search-command branch March 6, 2026 23:59
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.

1 participant