@@ -2,15 +2,29 @@
22
33 ## Phase 1 — Foundation (no UI, no LLM)
44
5-- [ ] `session.ts` — SQLite schema, CRUD, turn numbering, undo, fork, cumulative stats
6-- [ ] `tools.ts` — edit (exact-text replace, new file creation) and shell (exec, output truncation)
5+- [x] `session.ts` — SQLite schema, CRUD, turn numbering, undo, fork, cumulative stats
6+- [x] `session.test.ts` — 20 tests against real in-memory bun:sqlite
7+- [ ] `tools.ts` — `edit` (exact-text replace, new file creation) and `shell` (exec, output truncation)
8+- [ ] `tools.test.ts` — pure function tests per AGENTS.md testing strategy
79 - [ ] `git.ts` — branch, dirty counts, ahead/behind, repo root detection
810
11+### Notes from Phase 1
12+
13+- `session.ts` exports: `openDatabase`, `createSession`, `getSession`, `listSessions`, `deleteSession`, `appendMessage`, `loadMessages`, `undoLastTurn`, `forkSession`, `computeStats`.
14+- Internal row types (`SessionRow`, `MaxTurnRow`, `DataRow`) and a `SQL` constants object keep queries centralized and avoid formatter conflicts.
15+- `@mariozechner/pi-ai` is the only runtime dependency so far. Its `Message`, `AssistantMessage`, `UserMessage`, `ToolResultMessage` types are used for session persistence.
16+
917 ## Phase 2 — Context assembly
1018
1119 - [ ] `skills.ts` — SKILL.md discovery, frontmatter parsing, catalog generation, name collision resolution
1220 - [ ] `prompt.ts` — AGENTS.md discovery, system prompt construction (base + AGENTS.md + skills + plugins + git footer)
1321
22+### Phase 2 entry points
23+
24+- `skills.ts` depends on nothing from Phase 1. It scans directories for `SKILL.md` files, parses YAML frontmatter (name, description), resolves name collisions (project-level wins over user-level), and generates the XML catalog string for the system prompt. See spec.md "Agent Skills" section.
25+- `prompt.ts` depends on `skills.ts` and `git.ts`. It walks from CWD to scan root collecting `AGENTS.md`/`CLAUDE.md` files, assembles the full system prompt in construction order (base → AGENTS.md → skills catalog → plugin suffixes → session footer with date/cwd/git). See spec.md "System prompt" section.
26+- `git.ts` (from Phase 1) is needed by `prompt.ts` for the session footer git line.
27+
1428 ## Phase 3 — Agent loop
1529
1630 - [ ] `agent.ts` — core loop: stream → handle events → execute tools → loop. Interrupt handling. Context limit / compaction.