forked from cleveragents/cleveragents-core
4f950a1600
## Summary Add `agents repo index` and `agents repo status` CLI commands, wiring the existing `RepoIndexingService` backend to the CLI layer. ### Commands - **`agents repo index <resource_name>`** — Triggers full or incremental indexing of a repository resource. Options: `--full` (force full re-index), `--format text|json` - **`agents repo status <resource_name>`** — Displays indexing metadata: status, file count, token estimate, primary language, last indexed timestamp. Options: `--format text|json` ### Implementation - New CLI module `src/cleveragents/cli/commands/repo.py` (238 lines) - Registered as `repo` subcommand group in `cli/main.py` - Resolves resource by name via `ResourceRegistryService` - Calls `RepoIndexingService.index_resource()` / `refresh_index()` / `get_index_status()` - Both text (Rich panel) and JSON output formats ### Quality Gates | Session | Result | |---|---| | `nox -s lint` | PASS | | `nox -s typecheck` | PASS (0 errors) | | `nox -s unit_tests` | PASS (10,819 scenarios) | | `nox -s coverage_report` | 98% (>= 97%) | | Integration tests | 5/5 PASS | Closes #856 Reviewed-on: cleveragents/cleveragents-core#982 Co-authored-by: Brent Edwards <brent.edwards@cleverthis.com> Co-committed-by: Brent Edwards <brent.edwards@cleverthis.com>
104 lines
4.6 KiB
Gherkin
104 lines
4.6 KiB
Gherkin
Feature: Repository indexing CLI commands
|
|
As a developer
|
|
I want to index repository resources via the CLI
|
|
So that I can manage repository indexing through agents repo commands
|
|
|
|
Background:
|
|
Given a fresh in-memory repo indexing environment
|
|
|
|
# ---- agents repo index ----
|
|
|
|
Scenario: Index a valid repository resource
|
|
Given a registered git-checkout resource "local/test-repo" with a temp directory
|
|
When I run repo index on resource "local/test-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should contain "complete"
|
|
And the repo output should contain "local/test-repo"
|
|
|
|
Scenario: Index with --full forces full re-index
|
|
Given a registered git-checkout resource "local/full-repo" with a temp directory
|
|
When I run repo full-index on resource "local/full-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should contain "Full index complete"
|
|
|
|
Scenario: Incremental re-index after initial index
|
|
Given a registered git-checkout resource "local/incr-repo" with a temp directory
|
|
And I have already indexed "local/incr-repo"
|
|
When I run repo index on resource "local/incr-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should contain "Incremental refresh complete"
|
|
|
|
Scenario: Index with JSON output format
|
|
Given a registered git-checkout resource "local/json-repo" with a temp directory
|
|
When I run repo index-json on resource "local/json-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should be valid JSON
|
|
And the repo JSON output should contain key "status"
|
|
And the repo JSON output should contain key "file_count"
|
|
And the repo JSON output should contain key "primary_language"
|
|
|
|
Scenario: Index with non-existent resource shows error
|
|
When I run repo index on resource "local/nonexistent-resource"
|
|
Then the repo command should fail
|
|
And the repo output should contain "Resource not found"
|
|
|
|
# ---- agents repo status ----
|
|
|
|
Scenario: Status for an indexed resource
|
|
Given a registered git-checkout resource "local/status-repo" with a temp directory
|
|
And I have already indexed "local/status-repo"
|
|
When I run repo status on resource "local/status-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should contain "Status"
|
|
And the repo output should contain "Files"
|
|
And the repo output should contain "Tokens"
|
|
|
|
Scenario: Status with no index shows appropriate message
|
|
Given a registered git-checkout resource "local/noindex-repo" with a temp directory
|
|
When I run repo status on resource "local/noindex-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should contain "No index found"
|
|
|
|
Scenario: Status with JSON output format
|
|
Given a registered git-checkout resource "local/json-status-repo" with a temp directory
|
|
And I have already indexed "local/json-status-repo"
|
|
When I run repo status-json on resource "local/json-status-repo"
|
|
Then the repo command should succeed
|
|
And the repo output should be valid JSON
|
|
And the repo JSON output should contain key "status"
|
|
And the repo JSON output should contain key "file_count"
|
|
And the repo JSON output should contain key "token_estimate"
|
|
|
|
Scenario: Status for non-existent resource shows error
|
|
When I run repo status on resource "local/missing-resource"
|
|
Then the repo command should fail
|
|
And the repo output should contain "Resource not found"
|
|
|
|
Scenario: Status with no index in JSON format
|
|
Given a registered git-checkout resource "local/noindex-json" with a temp directory
|
|
When I run repo status-json on resource "local/noindex-json"
|
|
Then the repo command should succeed
|
|
And the repo output should be valid JSON
|
|
And the repo JSON output should contain key "status"
|
|
And the repo JSON output field "status" should equal "not_indexed"
|
|
|
|
# ---- edge cases for coverage ----
|
|
|
|
Scenario: Index resource with no filesystem path shows error
|
|
Given a registered resource "local/no-path" with no location
|
|
When I run repo index on resource "local/no-path"
|
|
Then the repo command should fail
|
|
And the repo output should contain "no filesystem path"
|
|
|
|
Scenario: Index resource with path only in properties
|
|
Given a registered resource "local/prop-path" with path in properties only
|
|
When I run repo index on resource "local/prop-path"
|
|
Then the repo command should succeed
|
|
And the repo output should contain "complete"
|
|
|
|
Scenario: Index with missing root path shows error
|
|
Given a registered resource "local/bad-path" with nonexistent path
|
|
When I run repo index on resource "local/bad-path"
|
|
Then the repo command should fail
|
|
And the repo output should contain "Error"
|