mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 07:41:52 +08:00
Persist CLI conversation history across sessions
The Rust CLI now stores managed sessions under ~/.claude/sessions, records additive session metadata in the canonical JSON transcript, and exposes a /sessions listing alias alongside ID-or-path resume. Inactive oversized sessions are compacted automatically so old transcripts remain resumable without growing unchecked. Constraint: Session JSON must stay backward-compatible with legacy files that lack metadata Constraint: Managed sessions must use a single canonical JSON file per session without new dependencies Rejected: Sidecar metadata/index files | duplicated state and diverged from the requested single-file persistence model Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep CLI policy in the CLI; only add transcript-adjacent metadata to runtime::Session unless another consumer truly needs more Tested: cargo fmt; cargo clippy --workspace --all-targets -- -D warnings; cargo test --workspace Not-tested: Manual interactive REPL smoke test against the live Anthropic API
This commit is contained in:
@@ -133,6 +133,7 @@ Inside the REPL, useful commands include:
|
||||
/diff
|
||||
/version
|
||||
/export notes.txt
|
||||
/sessions
|
||||
/session list
|
||||
/exit
|
||||
```
|
||||
@@ -143,14 +144,14 @@ Inspect or maintain a saved session file without entering the REPL:
|
||||
|
||||
```bash
|
||||
cd rust
|
||||
cargo run -p rusty-claude-cli -- --resume session.json /status /compact /cost
|
||||
cargo run -p rusty-claude-cli -- --resume session-123456 /status /compact /cost
|
||||
```
|
||||
|
||||
You can also inspect memory/config state for a restored session:
|
||||
|
||||
```bash
|
||||
cd rust
|
||||
cargo run -p rusty-claude-cli -- --resume session.json /memory /config
|
||||
cargo run -p rusty-claude-cli -- --resume ~/.claude/sessions/session-123456.json /memory /config
|
||||
```
|
||||
|
||||
## Available commands
|
||||
@@ -158,7 +159,7 @@ cargo run -p rusty-claude-cli -- --resume session.json /memory /config
|
||||
### Top-level CLI commands
|
||||
|
||||
- `prompt <text...>` — run one prompt non-interactively
|
||||
- `--resume <session.json> [/commands...]` — inspect or maintain a saved session
|
||||
- `--resume <session-id-or-path> [/commands...]` — inspect or maintain a saved session stored under `~/.claude/sessions/`
|
||||
- `dump-manifests` — print extracted upstream manifest counts
|
||||
- `bootstrap-plan` — print the current bootstrap skeleton
|
||||
- `system-prompt [--cwd PATH] [--date YYYY-MM-DD]` — render the synthesized system prompt
|
||||
@@ -176,13 +177,14 @@ cargo run -p rusty-claude-cli -- --resume session.json /memory /config
|
||||
- `/permissions [read-only|workspace-write|danger-full-access]` — inspect or switch permissions
|
||||
- `/clear [--confirm]` — clear the current local session
|
||||
- `/cost` — show token usage totals
|
||||
- `/resume <session-path>` — load a saved session into the REPL
|
||||
- `/resume <session-id-or-path>` — load a saved session into the REPL
|
||||
- `/config [env|hooks|model]` — inspect discovered Claude config
|
||||
- `/memory` — inspect loaded instruction memory files
|
||||
- `/init` — create a starter `CLAUDE.md`
|
||||
- `/diff` — show the current git diff for the workspace
|
||||
- `/version` — print version and build metadata locally
|
||||
- `/export [file]` — export the current conversation transcript
|
||||
- `/sessions` — list recent managed local sessions from `~/.claude/sessions/`
|
||||
- `/session [list|switch <session-id>]` — inspect or switch managed local sessions
|
||||
- `/exit` — leave the REPL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user