Skip to content

feat(v3.0): Phase 52 Simple CLI API#29

Merged
RichardHightower merged 17 commits into
mainfrom
feature/v3.0-phase-52-cli-api
May 14, 2026
Merged

feat(v3.0): Phase 52 Simple CLI API#29
RichardHightower merged 17 commits into
mainfrom
feature/v3.0-phase-52-cli-api

Conversation

@RichardHightower
Copy link
Copy Markdown
Contributor

Summary

Phase 52 of v3.0 Competitive Parity & Benchmarks — adds the memory binary, a dead-simple CLI that talks to the daemon over gRPC. All commands route through existing RPCs; no direct RocksDB access from the CLI.

Commands

Command Purpose
memory search <query> Orchestrated hybrid search (BM25 + vector + TOC + topic, optional rerank)
memory context <query> Build a context window for the current conversation
memory recall <query> Alias for search --rerank=llm (heavier, slower, higher quality)
memory add <text> Ingest a new memory event
memory timeline Browse the memory timeline
memory summary Summary of recent memory

Global args: --format, --endpoint, plus TTY-aware output (JSON when piped, human-friendly when interactive).

Design decisions

  • gRPC-only — every command goes through memory-daemon RPCs; the CLI never opens RocksDB directly. Keeps the daemon as the single source of truth and works with remote stores.
  • JsonEnvelope outputok / error / context_ok constructors with TTY detection via IsTerminal. Scripted callers get parseable JSON; humans get prose.
  • New cratecrates/memory-cli/ (binary name memory) added to the workspace alongside memory-daemon. Each binary stays focused.
  • Recall as alias — rather than a separate flag, recall is an explicit subcommand that maps to search --rerank=llm. Discoverable in --help.

Files added

  • crates/memory-cli/ — new binary crate (12 files, ~1500 LOC)
    • cli.rs — clap derive Parser/Subcommand
    • client.rs — gRPC client helper
    • output.rsJsonEnvelope and TTY detection
    • commands/{add,context,recall,search,summary,timeline}.rs — one file per subcommand
  • .planning/phases/52-simple-cli-api/ — 3 plans + 3 summaries + context/research/validation/verification

Touched: crates/memory-client/src/lib.rs (added a couple of helpers used by the CLI).

Tests

  • All workspace tests pass (task test): 54 test result blocks, 0 failures
  • Clippy clean (task clippy): zero warnings on --workspace --all-targets --all-features -- -D warnings
  • Docs clean (task doc): zero rustdoc warnings under RUSTDOCFLAGS=-D warnings
  • task fmt passes

Rebase notes (2026-05-12)

Rebased from gsd/phase-52-simple-cli-api (local stack, 36 commits ahead of an old main) onto post-Phase-51 origin/main. Used git rebase --onto to drop the Phase 51 commits already absorbed via PR #28. The 15 commits in this PR are Phase 52's own work plus a final clean planning-doc update.

Next in v3.0

Phase 53 (Benchmark Suite) is the remaining v3.0 work — stacked on this branch locally at gsd/phase-53-benchmark-suite. PR #25 (cross-project federation, Phase 53.5) is also open.

RichardHightower and others added 17 commits May 12, 2026 08:37
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add route_query() method to MemoryClient for orchestrated retrieval
- Re-export RouteQueryResponse from memory-client lib
- Create memory-cli crate with memory binary (6 subcommands)
- Implement clap derive structs: Cli, GlobalArgs, Commands enum
- Add 11 unit tests for CLI argument parsing
- Create command stubs for search, context, add, timeline, summary, recall
- Add placeholder output.rs (JsonEnvelope) and client.rs (connect_client)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add JsonEnvelope::ok, context_ok, error constructors with builder pattern
- Implement TTY-aware print_output using std::io::IsTerminal
- Add estimate_tokens heuristic (chars * 0.75 + 50)
- Add should_force_json for global/command format detection
- Finalize connect_client with actionable daemon-not-running error
- Add 14 unit tests for output module (serialization, skip_none, meta, tokens)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 52-01-SUMMARY.md with execution results
- Update STATE.md: advance to plan 2 of 3, add decisions
- Update ROADMAP.md and REQUIREMENTS.md progress

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Map CLI kind strings to EventType (episodic, tool_result, etc.)
- Build Event with ULID-generated IDs and User role
- Connect to daemon via gRPC and ingest event
- Return event_id in JsonEnvelope with tokens_estimated
- Exit non-zero with error envelope when daemon is down
- Unit tests for kind_to_event_type and build_event helpers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Map RouteQueryResponse results to JSON array with doc_id, score, source_layer
- Build meta with retrieval_ms, tokens_estimated, confidence from response
- Re-export RetrievalResult and ExplainabilityPayload from memory-client
- Add 7 unit tests for map_retrieval_result, build_meta, layer_to_string

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Recall delegates to search with rerank=llm, top=10
- Context builds structured MemoryContext-shaped JSON with summary, relevant_events, key_entities
- Fix timeline.rs import to use memory_client::ProtoEvent re-export (Rule 3)
- Add 4 unit tests for recall args construction and context JSON shape

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Timeline: parse_range for "Nd"/"Nw" formats, get_events RPC, entity filtering
- Summary: parse_summary_range for named ranges, get_toc_root + browse_toc RPCs
- Map ProtoEvent fields to human-readable JSON (event_type, role strings)
- TOC node overlap filtering for time-range-based summary navigation
- Both commands include tokens_estimated in meta envelope
- Add memory-service dependency for ProtoTocNode type access
- Unit tests for parse_range, parse_summary_range, map_proto_event, node_overlaps

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 52-02-SUMMARY.md with search/context/recall implementation details
- Update STATE.md: advance to plan 3 of 3, add decisions
- Update ROADMAP.md with plan progress
- Mark CLI-02, CLI-03, CLI-06, CLI-08 requirements complete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove #[allow(dead_code)] from output and client modules (now used)
- Apply cargo fmt formatting fixes
- Full pr-precheck passes (fmt + clippy + test + doc)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add 52-03-SUMMARY.md with task commits and deviation docs
- Update STATE.md: phase 52 complete, decisions recorded
- Update ROADMAP.md: phase 52 progress 3/3
- Mark CLI-04, CLI-07 requirements complete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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