Skip to content

Commit 29d2c47

Browse files
committed
Rename recall export to import, add CLI command groups
Rename `ctx recall export` to `ctx recall import` across the entire codebase. From ctx's perspective, pulling Claude Code sessions into the journal is an import, not an export. Rename touches source code, entity types, config constants, YAML text, hook templates, tests, docs, recipes, skills, specs, and context files. Add Cobra command groups to organize `ctx --help` into labeled sections: Getting Started, Context, Artifacts, Sessions, Runtime, Integration, Diagnostics, and Utilities. Presentation-only change using Cobra's AddGroup API -- zero command path or routing changes. Add preamble box to root help output with ceremony instructions and maintenance cadence. Hide site, serve, and system commands from help. Update zero-silent-error-discard convention and add rename/refactor documentation checklist to CONVENTIONS.md. Signed-off-by: Jose Alekhinne <jose@ctx.ist>
1 parent fda3c82 commit 29d2c47

117 files changed

Lines changed: 1461 additions & 1016 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.context/ARCHITECTURE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ upward from them. The `rc` package mediates config resolution;
114114
| `notify` | Send fire-and-forget webhook notifications |
115115
| `pad` | Encrypted scratchpad CRUD with blob support and merge |
116116
| `permissions` | Permission snapshot/restore (golden images) for Claude Code |
117-
| `recall` | Browse, export, lock/unlock AI session history |
117+
| `recall` | Browse, import, lock/unlock AI session history |
118118
| `reindex` | Regenerate indices for DECISIONS.md and LEARNINGS.md |
119119
| `remind` | Session-scoped reminders surfaced at start |
120120
| `serve` | Serve static journal site locally via zensical |
@@ -145,11 +145,11 @@ Five core flows define how data moves through the system:
145145
constitution compliance, required files, file age, entry count,
146146
missing packages) → returns report with warnings and violations.
147147

148-
4. **`ctx recall export`**: User invokes with `--all``cli/recall`
148+
4. **`ctx recall import`**: User invokes with `--all``cli/recall`
149149
calls `parser.FindSessionsForCWD()` which scans
150150
`~/.claude/projects/` → parses JSONL transcripts → loads journal
151151
state → plans each session (new/regen/skip/locked) → formats as
152-
Markdown → writes to `.context/journal/` → marks exported in state.
152+
Markdown → writes to `.context/journal/` → marks imported in state.
153153

154154
<!-- drift-check: grep -c 'ctx system check-' internal/assets/claude/hooks/hooks.json -->
155155
5. **Hook lifecycle**: Claude Code plugin fires hooks at 3 lifecycle
@@ -178,7 +178,7 @@ Five state machines govern lifecycle transitions:
178178
pending children remain) → Archived (via `ctx task archive` to
179179
`.context/archive/`).
180180

181-
3. **Journal pipeline**: Exported (JSONL→MD via `recall export`) →
181+
3. **Journal pipeline**: Imported (JSONL→MD via `recall import`) →
182182
Enriched (YAML frontmatter, tags) → Normalized (soft-wrap, clean
183183
JSON) → Fences Verified (fence balance check) → Locked (prevent
184184
overwrite). Each stage tracked in `.context/journal/.state.json`;

.context/CONVENTIONS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,11 @@ DO NOT UPDATE FOR:
163163

164164
- New CLI subcommand documentation checklist: When adding a new CLI subcommand, update docs in at least three places: (1) Feature page (e.g., docs/scratchpad.md) — commands table, usage section, skill/NL table. (2) CLI reference (docs/cli-reference.md) — full reference entry with args, flags, examples. (3) Relevant recipes — any recipe that covers the feature area. (4) zensical.toml — only if adding a new page.
165165

166+
- Rename/refactor documentation checklist: When renaming a command, flag, function, or concept, scope ALL documentation impact before implementation. The project has three documentation anchors plus one tangential: (1) Docstrings in source code. (2) User-facing docs (`docs/`). (3) Recipes (`docs/recipes/`). (4) Blog posts and release notes — update command names but preserve historical prose. Also check: skills (`internal/assets/claude/skills/`), hook messages (`internal/assets/hooks/messages/`), YAML text files (`internal/assets/`), `.context/` files, and specs (`specs/`).
167+
166168
- Always stage site/ when committing docs/ changes — the generated HTML is tracked in git with no CI build step.
167169

168-
- Zero //nolint:errcheck policy — handle errors, don't suppress them. In test code: use t.Fatal(err) for setup errors, _ = os.Chdir(orig) for cleanup. In production code: use defer func() { _ = f.Close() }() for best-effort close. For gosec false positives: prefer config-level exclusions in .golangci.yml.
170+
- Zero silent error discard policy — handle every error, never suppress with `_ =` or `//nolint:errcheck`. In test code: use `t.Fatal(err)` for setup errors, use `t.Log(err)` for cleanup errors (not `_ =`). In production code: defer-close must log failures to stderr (`if err := f.Close(); err != nil { fmt.Fprintf(os.Stderr, "ctx: close %s: %v\n", path, err) }`), never `_ = f.Close()`. For write/read errors: return the error or log to stderr. For os.Remove/Rename: log to stderr at minimum. For gosec false positives: fix the code to satisfy the linter rather than adding nolint markers or config-level exclusions — the goal is zero golangci-lint suppressions. See TASKS.md EH.0–EH.5 for the full error handling cleanup plan.
169171

170172
- Error constructors belong in internal/err, never in per-package err.go files — eliminates the broken-window pattern where agents add local errors when they see a local err.go exists.
171173

.context/DECISIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ See: `specs/injection-oversize-nudge.md`.
971971

972972
**Status**: Accepted
973973

974-
**Context**: The session/recall/journal system had three overlapping storage layers: `~/.claude/projects/` (raw JSONL transcripts, owned by Claude Code), `.context/sessions/` (JSONL copies + context snapshots), and `.context/journal/` (enriched markdown from `ctx recall export`). The recall pipeline reads directly from `~/.claude/projects/`, making `.context/sessions/` a dead-end write sink that nothing reads from. The auto-save hook copied transcripts to a directory nobody consumed. The `ctx session save` command created context snapshots that git already provides through version history. This was ~15 Go source files, a shell hook, ~20 config constants, and 30+ doc references supporting infrastructure with no consumers.
974+
**Context**: The session/recall/journal system had three overlapping storage layers: `~/.claude/projects/` (raw JSONL transcripts, owned by Claude Code), `.context/sessions/` (JSONL copies + context snapshots), and `.context/journal/` (enriched markdown from `ctx recall import`). The recall pipeline reads directly from `~/.claude/projects/`, making `.context/sessions/` a dead-end write sink that nothing reads from. The auto-save hook copied transcripts to a directory nobody consumed. The `ctx session save` command created context snapshots that git already provides through version history. This was ~15 Go source files, a shell hook, ~20 config constants, and 30+ doc references supporting infrastructure with no consumers.
975975

976976
**Decision**: Remove `.context/sessions/` entirely. Two stores remain: raw transcripts (global, tool-owned in `~/.claude/projects/`) and enriched journal (project-local in `.context/journal/`).
977977

.context/DETAILED_DESIGN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ Consult specific sections when working on a module.
534534

535535
## internal/cli/journal
536536

537-
**Purpose**: Analyze and publish exported AI session files to static sites or Obsidian vaults. Largest package in the codebase (24 source files).
537+
**Purpose**: Analyze and publish imported AI session files to static sites or Obsidian vaults. Largest package in the codebase (24 source files).
538538

539539
**Key types**: `journalFrontmatter` (YAML: title, date, time, project, session_id, model, tokens, type, outcome, topics, key_files, summary), `journalEntry` (parsed file metadata), `groupedIndex` (aggregated entries by key with popularity flag), `topicData`, `keyFileData`, `typeData` (index structures)
540540

@@ -851,14 +851,14 @@ Consult specific sections when working on a module.
851851
| `check-context-size` | UserPromptSubmit | (all) | Adaptive counter: silent 1–15, every 5th 16–30, every 3rd 30+. Per-session counter in temp file | Per-session |
852852
| `check-persistence` | UserPromptSubmit | (all) | Track .context/ mtime; silent 1–10, nudge at #20 if no modifications, then every 15 prompts since last mod | Per-session |
853853
| `check-ceremonies` | UserPromptSubmit | (all) | Scan last 3 journal entries for "ctx-remember" and "ctx-wrap-up" strings; nudge missing ceremonies | Daily |
854-
| `check-journal` | UserPromptSubmit | (all) | Stage 1: count .jsonl files newer than latest journal export. Stage 2: count unenriched entries via journal/state. Suggest `ctx recall export --all` and `/ctx-journal-enrich-all` | Daily |
854+
| `check-journal` | UserPromptSubmit | (all) | Stage 1: count .jsonl files newer than latest journal export. Stage 2: count unenriched entries via journal/state. Suggest `ctx recall import --all` and `/ctx-journal-enrich-all` | Daily |
855855
| `check-reminders` | UserPromptSubmit | (all) | Surface due reminders (After ≤ today) from reminders.json with dismiss commands | None (until dismissed) |
856856
| `check-version` | UserPromptSubmit | (all) | Compare binary version (ldflags) vs plugin.json major.minor; skip "dev" builds. Piggyback: check encryption key age vs `rc.KeyRotationDays()` | Daily |
857857
| `check-resources` | UserPromptSubmit | (all) | `sysinfo.Collect()` + `Evaluate()`; output ONLY at DANGER severity (mem≥90%, swap≥75%, disk≥95%, load≥1.5x CPUs) | None |
858858
| `check-knowledge` | UserPromptSubmit | (all) | DECISIONS entry count vs `rc.EntryCountDecisions()` (default 20), LEARNINGS vs `rc.EntryCountLearnings()` (default 30), CONVENTIONS lines vs `rc.ConventionLineCount()` (default 200). Suggest /ctx-consolidate | Daily |
859859
| `check-map-staleness` | UserPromptSubmit | (all) | Two conditions (both required): map-tracking.json `last_run` >30 days AND `git log --since=<last_run> -- internal/` has commits. Suggest /ctx-architecture | Daily |
860860
| `check-backup-age` | UserPromptSubmit | (all) | Check SMB mount (via GVFS path from `CTX_BACKUP_SMB_URL` env) + backup marker mtime (>2 days). Suggest `ctx system backup` | Daily |
861-
| `mark-journal` | (plumbing) || `ctx system mark-journal <file> <stage> [--check]`. Valid stages: exported, enriched, normalized, fences_verified, locked | N/A |
861+
| `mark-journal` | (plumbing) || `ctx system mark-journal <file> <stage> [--check]`. Valid stages: imported, enriched, normalized, fences_verified, locked | N/A |
862862
| `cleanup-tmp` | SessionEnd | (all) | Remove files >15 days old from `secureTempDir()`. Silent side-effect, no output | N/A |
863863

864864
**Hook output protocol**:

.context/GLOSSARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ DO NOT UPDATE FOR:
2828
| Read order | The priority sequence in which context files are loaded and presented to agents. Defined by `config.FileReadOrder`. Higher priority files are loaded first and survive token budget cuts. |
2929
| Token budget | Maximum estimated token count for assembled context. Default 8000. Configurable via `CTX_TOKEN_BUDGET`, `.ctxrc`, or `--budget` flag. Uses 4-chars-per-token heuristic. |
3030
| Curated tier | The `.context/*.md` files: manually maintained, token-budgeted, loaded by `ctx agent`. Contrast with full-dump tier. |
31-
| Full-dump tier | The `.context/journal/` directory: exported session transcripts. Not auto-loaded; used for archaeology when curated context is insufficient. Browse with `ctx recall`. |
31+
| Full-dump tier | The `.context/journal/` directory: imported session transcripts. Not auto-loaded; used for archaeology when curated context is insufficient. Browse with `ctx recall`. |
3232
| Compaction | The process of archiving completed tasks and cleaning up context files. Run via `ctx compact`. Moves completed tasks to archive; preserves phase structure. |
3333
| Entry header | The timestamped heading format used in DECISIONS.md and LEARNINGS.md: `## [YYYY-MM-DD-HHMMSS] Title`. Parsed by `config.RegExEntryHeader`. |
3434
| Index table | The auto-generated markdown table at the top of DECISIONS.md and LEARNINGS.md (between `<!-- INDEX:START -->` and `<!-- INDEX:END -->` markers). Updated by `ctx add` and `ctx decision/learnings reindex`. |

.context/architecture-dia-data-flows.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ User cli/drift context drift.Detect
9191
│ Formatted report│ │ │ │
9292
```
9393

94-
## 4. `ctx recall export` — Session Export Pipeline
94+
## 4. `ctx recall import` — Session Import Pipeline
9595

9696
```
9797
User cli/recall recall/parser journal/state FS
9898
│ │ │ │ │
9999
│ ctx recall │ │ │ │
100-
export --all │ │ │ │
100+
import --all │ │ │ │
101101
│ ─────────────► │ │ │ │
102102
│ │ FindSessionsFor │ │ │
103103
│ │ CWD(cwd) │ │ │
@@ -120,10 +120,10 @@ User cli/recall recall/parser journal/state FS
120120
│ │ Format as Markdown │ │
121121
│ │ Write to .context/journal/ │ │
122122
│ │ ──────────────────────────────────────────────────────────►│
123-
│ │ MarkExported() │ │
123+
│ │ MarkImported() │ │
124124
│ │ ──────────────────────────────────────► │ │
125125
│ ◄──────────── │ │
126-
│ "Exported N" │ │ │ │
126+
│ "Imported N" │ │ │ │
127127
```
128128

129129
## 5. Hook Lifecycle (Claude Code Plugin)

.context/archive/decisions-consolidated-2026-02-22.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ lost if not captured.
6363

6464
## [2026-01-20-140000] Session Filename Format: YYYY-MM-DD-HHMMSS-topic.md
6565

66-
**Status**: Superseded (removed in v0.4.0 — `.context/sessions/` eliminated; journal entries use `ctx recall export` naming)
66+
**Status**: Superseded (removed in v0.4.0 — `.context/sessions/` eliminated; journal entries use `ctx recall import` naming)
6767

6868
**Context**: Multiple sessions per day would overwrite each other.
6969
Also, multiple compacts in the same minute could collide.
@@ -302,7 +302,7 @@ what can be loaded. But nothing should be truly lost.
302302

303303
**Status**: Accepted
304304

305-
**Context**: T2.1 requested ctx recall export --update to preserve enrichments during re-export
305+
**Context**: T2.1 requested ctx recall import --update to preserve enrichments during re-import
306306

307307
**Decision**: No --update flag needed for export — default is the update mode
308308

.context/archive/learnings-consolidated-2026-02-22.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ and an agentId field.
381381

382382
## [2026-02-03-063337] Claude Code JSONL format changed: slug field removed in v2.1.29+
383383

384-
**Context**: ctx recall export --all --force was skipping February 2026 sessions.
384+
**Context**: ctx recall import --all --force was skipping February 2026 sessions.
385385
Investigation revealed sessions like c9f12373 had 0 slug fields but 19
386386
sessionId fields.
387387

@@ -502,13 +502,13 @@ passes command args.
502502

503503
**Lesson**: Use `YYYY-MM-DD-HHMM-<topic>.md` format to prevent overwrites.
504504

505-
**Application**: Historical reference only. Journal entries now use `ctx recall export` naming.
505+
**Application**: Historical reference only. Journal entries now use `ctx recall import` naming.
506506

507507
---
508508

509509
## [2026-01-20-120000] Two Tiers of Persistence
510510

511-
> **Note**: `.context/sessions/` removed in v0.4.0. Two tiers remain but the full-dump tier is now `~/.claude/projects/` (raw JSONL) + `.context/journal/` (enriched markdown via `ctx recall export`).
511+
> **Note**: `.context/sessions/` removed in v0.4.0. Two tiers remain but the full-dump tier is now `~/.claude/projects/` (raw JSONL) + `.context/journal/` (enriched markdown via `ctx recall import`).
512512
513513
**Context**: User wanted to ensure nothing is lost when session ends.
514514

@@ -533,7 +533,7 @@ passes command args.
533533
- **Auto-load**: Works via `PreToolUse` hook running `ctx agent`
534534
- **Auto-save**: Did NOT exist
535535

536-
**Original solution**: `SessionEnd` hook that copies transcript to `.context/sessions/`. Removed in v0.4.0 because Claude Code already retains transcripts and `ctx recall export` reads them directly.
536+
**Original solution**: `SessionEnd` hook that copies transcript to `.context/sessions/`. Removed in v0.4.0 because Claude Code already retains transcripts and `ctx recall import` reads them directly.
537537

538538
---
539539

.context/archive/tasks-2026-02-03.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Archived from TASKS.md
1515
#priority:low #added:2026-01-28
1616
- [x] Write AST-based test that warns if CLI functions use fmt.Print* instead of
1717
cmd.Print* #added:2026-01-29-171351 #done:2026-01-31
18-
- [x] feat: `ctx recall export` - export sessions to editable journal files
19-
- `ctx recall export <session-id>` - export one session
20-
- `ctx recall export --all` - export all sessions
18+
- [x] feat: `ctx recall import` - import sessions to editable journal files
19+
- `ctx recall import <session-id>` - import one session
20+
- `ctx recall import --all` - import all sessions
2121
- Skip existing files (user may have edited), `--force` to overwrite
2222
- Output to `.context/journal/YYYY-MM-DD-slug-shortid.md`
2323
#added:2026-01-28 #done:2026-01-31

.context/archive/tasks-2026-02-21.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@
5454
`--keep-frontmatter=false` implies `--regenerate`.
5555
Files: `internal/cli/recall/cmd.go`, `run.go`
5656
#priority:medium #added:2026-02-20 #done:2026-02-21
57-
- [x] T2.8: Ergonomics — bare `ctx recall export` prints help (not error).
57+
- [x] T2.8: Ergonomics — bare `ctx recall import` prints help (not error).
5858
Files: `internal/cli/recall/cmd.go`, `run.go`
5959
#priority:medium #added:2026-02-20 #done:2026-02-21
6060
- [x] T2.9: Tests — safe-default, --regenerate, confirmation, --yes,
61-
--dry-run, lock/export integration (locked skipped by default, by
61+
--dry-run, lock/import integration (locked skipped by default, by
6262
--force, dry-run shows locked), --keep-frontmatter=false, default
63-
preservation. 16 lock tests in `lock_test.go`, 7 new export tests
63+
preservation. 16 lock tests in `lock_test.go`, 7 new import tests
6464
in `run_test.go`, 4 `discardFrontmatter()` unit tests.
6565
Files: `internal/cli/recall/run_test.go`, `lock_test.go`, `recall_test.go`
6666
#priority:medium #added:2026-02-21 #done:2026-02-21

0 commit comments

Comments
 (0)