Skip to content

Commit fa6c607

Browse files
feat(capabilities): turn cass capabilities into a first-stop agent self-description
Reframes `cass capabilities --json` from "feature discovery" to a single self-describing entry point that hands an agent everything it needs to drive cass without reading help text or external docs. Payload additions (the schema is additive — old keys are preserved): - `workflows[]` — named recipes (`bounded-search`, etc.) showing the canonical command sequence for an intent, plus the exit codes and output shapes a caller should branch on. - `mistake_recoveries[]` — paired "common mistake" → "what to do next" entries, lifted from the existing `get_common_mistakes` table so an agent can recover without re-querying. - `commands[]` — full command list with `name`, `summary`, `arguments[]` (positional vs option, required, value_type, default, possible_values), and `subcommands[]` for two-level paths like `robot-docs guide`. - `global_flags[]` — typed schemas for `--robot-help`, `--color`, `--no-color`, `--quiet`, `--max-tokens`, etc., with `value_type` ("enum" | "string" | …) and defaults so callers don't guess. - `exit_codes[]` — every exit code the binary can return, with `meaning`, `retryable` ("yes" | "no" | "after-recovery"), and `agent_action` text the caller can act on (e.g. exit 2 → "Fix argv and retry"; exit 15 → semantic-fallback guidance). - `env_vars[]` — `CASS_DATA_DIR`, `CASS_OUTPUT_FORMAT`, `CASS_TRACE_FILE`, etc. with default values. - New feature flag `self_describing_capabilities` advertises the upgrade so callers can detect it. Argv recovery improvements (in `heuristic_parse_recovery` / `normalize_args`): - New `CANONICAL_TOP_LEVEL_COMMANDS` table backs a Levenshtein typo corrector (`closest_top_level_command`) so a misspelt subcommand like `cass searh` is rewritten to `cass search` with a structured correction note rather than re-routing through the generic "implicit search" fallback. Distance ≤2; minimum length 3. - `cass robot-docs` (no subtopic) now defaults to `robot-docs guide` with a recorded correction; redundant `--robot` / `--json` flags on robot-docs are stripped (those outputs are already machine-readable). Surface adjustments: - `Commands::Capabilities` doc string updated from "Discover features, versions, and limits" to "First-stop agent self-description: workflows, mistake recoveries, commands, flags, env vars, exit codes, and limits". - `print_robot_help` section header renamed `Subcommands:` → `Core subcommands:` so the help output matches the new `commands[]` framing. - README + docs/ROBOT_MODE.md prose updated to the new framing. Tests + goldens: - `capabilities_are_self_describing_for_agents` exercises every new section: features list contains the new flag, global_flags has typed entries, commands include arguments/subcommands, exit_codes include retryability + agent_action, env_vars cover the documented list, and the `bounded-search` workflow is present. - New helper `recommended_command(json, id)` for asserting recommended-command shape across cli_robot tests. - Goldens regenerated: - `tests/golden/robot/capabilities.json.golden` (full payload, ~2882 lines) - `tests/golden/robot/capabilities_shape.json.golden` (new shape-only snapshot — order-insensitive structure) - `tests/golden/robot/introspect{,_shape}.json.golden` - `tests/golden/robot/diag*.json.golden` (api_version field threaded through) - `tests/golden/robot_docs/{commands,examples,guide,robot_help,schemas}.txt.golden` - `tests/golden_robot_docs.rs` / `tests/golden_robot_json.rs` drivers refreshed for the new sections. Drive-by formatting: - `src/connectors/codex.rs`: re-ordered the `super::*` import list alphabetically (rustfmt drift; no behaviour change). - `src/ui/app.rs`: collapsed three multi-line method-chain Paragraph styles per rustfmt; also a single `paragraph.style(...).render(...)` flattened. No behaviour change. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a0ac607 commit fa6c607

20 files changed

Lines changed: 5204 additions & 158 deletions

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ This cross-pollination of knowledge across different AI agents is transformative
727727
`cass` teaches agents how to use it—no external documentation required:
728728

729729
```bash
730-
# Quick capability check: what features exist?
730+
# First-stop capability contract for agents
731731
cass capabilities --json
732-
# → {"features": ["json_output", "cursor_pagination", "highlight_matches", ...], "connectors": [...], "limits": {...}}
732+
# → {"version": "...", "workflows": [...], "mistake_recoveries": [...], "commands": [...], "exit_codes": [...], "env_vars": [...]}
733733

734734
# Full API schema with argument types, defaults, and response shapes
735735
cass introspect --json
@@ -1158,7 +1158,7 @@ cass introspect --json
11581158
cass expand /path/to/session.jsonl -n 42 -C 3 --json
11591159
11601160
# Learn the full API
1161-
cass capabilities --json # Feature discovery
1161+
cass capabilities --json # First-stop agent self-description
11621162
cass robot-docs guide # LLM-optimized docs
11631163
11641164
Why Use It
@@ -2425,7 +2425,7 @@ cass pack "query" --robot --max-tokens 4000 --max-evidence 8 --max-sessions 3 --
24252425
# Inspection & Health
24262426
cass status --json # Quick health snapshot
24272427
cass health # Minimal pre-flight check (<50ms)
2428-
cass capabilities --json # Feature discovery
2428+
cass capabilities --json # First-stop agent self-description
24292429
cass introspect --json # Full API schema
24302430
cass context /path/to/session --json # Find related sessions
24312431
cass view /path/to/file -n 42 --json # View source at line
@@ -2458,7 +2458,7 @@ cass completions bash > ~/.bash_completion.d/cass
24582458
| `pack --robot` | Deterministic cited answer packs for agent/human handoffs; reports health, freshness, privacy, and warnings |
24592459
| `status` / `state` | Health snapshot: index freshness, DB stats, recommended action |
24602460
| `health` | Minimal health check (<50ms), exit 0=healthy, 1=unhealthy |
2461-
| `capabilities` | Discover features, versions, limits (for agent introspection) |
2461+
| `capabilities` | First-stop agent self-description: workflow recipes, mistake recoveries, commands, global flags, exit codes, env vars, and limits |
24622462
| `introspect` | Full API schema: commands, arguments, response shapes |
24632463
| `sessions [--workspace DIR] [--current]` | Discover recent session files for follow-up actions |
24642464
| `context <path>` | Find related sessions by workspace, day, or agent |

docs/ROBOT_MODE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Updated: 2026-04-22
2727
| Truncate content | `--max-content-length 400` or budgeted `--max-tokens 200` |
2828
| Metadata | `--robot-meta` (elapsed_ms, cache stats, index freshness, cursor, warnings) |
2929
| Health snapshot | `cass state --json` (alias `status`) |
30-
| Capabilities | `cass capabilities --json` |
30+
| Capabilities | `cass capabilities --json` (first-stop workflows, mistake recoveries, commands, flags, env vars, exit codes, limits) |
3131
| Introspection | `cass introspect --json` (schemas for responses) |
3232

3333
## Search asset contract
@@ -177,4 +177,4 @@ cass search "panic" --robot --fields minimal --robot-meta \
177177
- 0.1.30: `_meta.index_freshness` + `_warning` in search robot output; capabilities limits enforced; cursor/request-id exposed.
178178

179179
---
180-
For deeper schemas: `cass introspect --json` and `cass capabilities --json`.
180+
For first-stop discovery use `cass capabilities --json`; for deeper response schemas use `cass introspect --json`.

src/connectors/codex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use anyhow::Result;
55
use serde_json::Value;
66

77
use super::{
8-
parse_timestamp, reindex_messages, Connector, DetectionResult, DiscoveredSourceFile,
9-
NormalizedConversation, NormalizedMessage, ScanContext,
8+
Connector, DetectionResult, DiscoveredSourceFile, NormalizedConversation, NormalizedMessage,
9+
ScanContext, parse_timestamp, reindex_messages,
1010
};
1111

1212
const MAX_INDEXED_TOOL_OUTPUT_CHARS: usize = 128 * 1024;

0 commit comments

Comments
 (0)