feat(shell): add interactive cya shell session (CYA-WP-0007)

Implement the full interactive shell REPL with session persistence,
opt-in capped/redacted shell history, State Hub orientation and
explicit slash-command writes, orchestrator/safety wiring, end-session
learning hooks, weakness hints, docs, and tests.
This commit is contained in:
2026-06-24 14:53:18 +02:00
parent a6266f7e2c
commit f15d253e64
14 changed files with 1819 additions and 31 deletions

View File

@@ -109,6 +109,60 @@ cya --explain-context "explain the changes in the last commit"
The output includes a structured suggestion, rationale, and (when relevant) a
clear preview + confirmation prompt. Nothing executes without your explicit yes.
## Interactive Shell Sessions
Start a stateful console session when you want continuity across turns:
```bash
cya shell
cya shell --offline --no-hub # local smoke / air-gapped mode
cya shell --with-history # opt in to capped, redacted shell history
```
Each session writes a user-owned JSONL artifact under:
```text
~/.config/cya/sessions/<session-id>.jsonl
```
Useful slash commands:
```text
/help show shell commands
/explain show last turn context, risk, history, hub, hints
/hub show State Hub workstreams and inbox orientation
/hub log "summary" post a progress note after confirmation
/inbox show unread State Hub messages
/export-session write a redacted JSON session summary
/learn capture Profile 1 reflections now
/exit close the session
```
Shell history is off by default. `--with-history` or `[shell_history]` config
includes at most 50 recent lines from `$HISTFILE` or common shell history files,
redacts secret-like values, and exposes provenance in `/explain`. One-shot
`cya "..."` requests remain history-free by default.
Example transcript:
```text
$ cya shell --offline --no-hub
cya> summarize recent git changes
... standard orchestrator response ...
cya> /explain
... context envelope, memory, shell history status, hub summary, and hints ...
cya> /export-session
Exported session summary: ~/.config/cya/sessions/cya-...-summary.json
cya> /exit
Session saved: ~/.config/cya/sessions/cya-...jsonl
```
State Hub writes never happen automatically. `/hub log` and `/inbox read` are
explicit operator actions; `/hub log` also asks for confirmation.
See `docs/cya-interactive-shell-session-design.md` and
`docs/cya-shell-operator-session.md` for the full design and operator example.
## Safety (core product behavior)
- Genuine rule-based assessment is the primary mechanism.