repositories / smith

smith

There are many coding harnesses - but this one is fast

owned by bugabinga

Cut plan drift and add the walking-skeleton entry point (#11)

a0363001e8525636918b586e17db65db01e6bfe1

Oliver Jan Krylow <oliver@bugabinga.net> ·

SSH signature · not checked

Browse filesCompare with HEAD

* Demote the plans to non-normative and cut their drift

The plans had started to contradict the spec they exist to serve — TASK-BREAKDOWN
hardcoded "17 widgets" while SPEC §8.6 now defines an open-ended set — because
they restated architecture and crate responsibilities the spec already owns.
Rather than maintain two copies, each plan now carries the same non-normative
banner research docs use and points at SPEC §2 for anything canonical, keeping
only what is genuinely plan-specific: the build waves and the doc-tooling
inventory.

A README indexes the two and states the coverage honestly — the set is
deliberately lopsided and omits a walking-skeleton plan and per-crate
breakdowns until implementation actually starts. Surface: docs/plans (three
files).

* Draft the walking-skeleton plan as the implementation entry point

The bottom-up crate order defers every integration risk to the final wave. This
plan inverts it: build one turn end-to-end through a scripted StreamFn — loop,
one tool, EngineEvents, TUI render, CBOR persist and reload — so the four
load-bearing seams are proven wired before any layer is built out. It leans on
the prototypes that already validated each seam in isolation (p05/p06/p07/p08),
uses a deterministic fixture so the whole slice is hermetic, and keeps a single
gated smoke test for a live provider.

One end-to-end test is the definition of done. Recorded as docs/plans/
WALKING-SKELETON.md and indexed as the ready-to-start entry point.

---------

Co-authored-by: Claude <noreply@anthropic.com>

Changed files (4)

+173 / −52 text lines

Diff layout

docs/plans/PLUGIN-DOC-PLAN.md

Modified

+6 / −5 text lines

11# Smith Plugin SDK Documentation Plan
3> Non-normative execution plan. `docs/SPEC.md` is canonical; where this file and
4> the spec disagree, the spec wins. The normative pieces already live in SPEC —
5> doc resolution order + `SMITH_DOCS_PATH` (§16), dotted `topic.function`
6> addressing (§10.2), the system-prompt self-learn bootstrap (§6.8). This file
7> is the execution plan for file inventories and tooling only.
8
39## Goal
511Smith must be able to extend itself when prompted by humans.
281287 └── doc_gen.rs -- generate man pages + docs bundle
282288```
284> Normative pieces of this plan are now canonical in SPEC: doc resolution
285> order + `SMITH_DOCS_PATH` (§16), `smith help <topic>.<function>` dotted
286> addressing (§10.2), system-prompt SDK self-learn bootstrap (§6.8). This
287> file remains the execution plan for file inventories and tooling.
289290## TODO
291292- [ ] Create SDK annotation files in `smith-harness/src/lua/sdk/`

docs/plans/README.md

Added
new file mode 100644

+23 / −0 text lines

1# Plans
2
3Non-normative execution plans — the bridge from `docs/SPEC.md` (what to build)
4to code (in what order). The spec is canonical; a plan never overrides it.
5
6| Plan | Covers | Status |
7|------|--------|--------|
8| `WALKING-SKELETON.md` | first vertical slice — one turn end-to-end, proving the four seams | ready to start |
9| `TASK-BREAKDOWN.md` | crate build order (SM-003→012), wave sequencing | pre-implementation |
10| `PLUGIN-DOC-PLAN.md` | plugin-SDK doc source, `smith help`, doc tooling/tests | pre-implementation |
12## Is this the whole set?
14`WALKING-SKELETON` is the entry point for implementation — a thin slice through
15every layer that proves the StreamFn, EngineEvent, session-codec, and TUI seams
16connect before any of them is built out. `TASK-BREAKDOWN` is the full crate
17sequencing that follows once the skeleton is green. One thing is still
18intentionally *not* written, to avoid speculative planning:
20- **Per-crate breakdowns.** Each SM-0xx task is crate-sized; it gets decomposed
21 into tested units at the start of its own wave, not now.
23Prototype evidence that de-risks all of this lives in `../../prototypes/PLAN.md`.

docs/plans/TASK-BREAKDOWN.md

Modified

+40 / −47 text lines

11# Smith Task Breakdown
3## Architecture
3> Non-normative execution plan. `docs/SPEC.md` is canonical; where this file and
4> the spec disagree, the spec wins. Architecture and crate responsibilities are
5> defined once in SPEC §2 and CLAUDE.md — this file only sequences the build.
5```
6smith/ (shared types + StreamFn + AgentTool trait)
7 ↑
8 ├── smith-ai/ (Provider implementations — parallel with smith-core)
9 ├── smith-core/ (Agent loop + session — parallel with smith-ai)
10 └── smith-tui/ (Widgets + layout — parallel with smith-core/ai)
7Top-level build order for the first implementation pass, at crate granularity.
8Each task is a whole crate; decomposition into buildable, tested units is
9deferred to that crate's own wave (see **Granularity**).
12smith-core + smith-ai + smith-tui
13 ↑
14smith-harness/ (Wiring: provider → StreamFn → agent, plugins, SDK)
15 ↑
16smith-cli/ (Binary entry point)
17```
19**Key design:** The agent loop lives in `smith-core`. It takes a `StreamFn` (from `smith/`),
20not a concrete provider. `smith-ai` implements providers and creates `StreamFn` instances.
21`smith-harness` wires them together. This enables `smith-core` and `smith-ai` to build in parallel.
23## Dependency Graph
11## Task dependency graph
2513```
2614SM-003 (scaffolding) ── SM-005 (smith/) ──┬── SM-006 (smith-core/) ──┐
3119 SM-012 (testing)
3220```
34## Execution Order
22The edges are the §2.2 boundary rules: `smith/` is the sole foundation;
23`smith-core` / `smith-ai` / `smith-tui` build in parallel and never depend on
24each other; `smith-harness` wires them; `smith-cli` sits on top.
26## Execution order
3628```
37Wave 0: SM-003 (scaffolding — jj repo, workspace, crate skeletons)
38Wave 1: SM-005 (sequential — foundation types)
39Wave 2: SM-006 + SM-007 + SM-008 (parallel)
40Wave 3: SM-009 (sequential — after wave 2)
41Wave 4: SM-010 + SM-011 (parallel — after SM-009)
42Wave 5: SM-012 (sequential — after wave 4)
29Wave 0: SM-003 scaffolding — jj repo, Cargo workspace, crate skeletons, xtask
30Wave 1: SM-005 smith/ — foundation types (sequential; everything blocks on it)
31Wave 2: SM-006 + SM-007 + SM-008 core / ai / tui (parallel)
32Wave 3: SM-009 smith-harness — wiring (after wave 2)
33Wave 4: SM-010 + SM-011 cli + workspace (parallel)
34Wave 5: SM-012 integration tests
4335```
45## Task List
37## Tasks
47| Task | Crate | Description | Blocked By | Blocks |
48|------|-------|-------------|------------|--------|
49| SM-003 | workspace/ | jj repo, Cargo workspace, crate skeletons, xtask | - | SM-005 |
50| SM-005 | smith/ | Shared types, StreamFn, AgentTool trait, Lua runtime, config | SM-003 | SM-006, 007, 008 |
51| SM-006 | smith-core/ | Agent loop, session, tools, hooks, events | SM-005 | SM-009 |
52| SM-007 | smith-ai/ | Provider trait, implementations, auth, OAuth | SM-005 | SM-009 |
53| SM-008 | smith-tui/ | Widgets, layout, themes, rendering | SM-005 | SM-009 |
54| SM-009 | smith-harness/ | Wiring, plugins, SDK, smith help | SM-006, 007, 008 | SM-010 |
55| SM-010 | smith-cli/ | Binary entry point, subcommands | SM-009 | SM-012 |
56| SM-011 | workspace/ | Cargo workspace, xtask | SM-009 | SM-012 |
57| SM-012 | testing/ | Integration tests | SM-010, SM-011 | - |
39| Task | Crate | Blocked by | Blocks |
40|------|-------|------------|--------|
41| SM-003 | workspace | — | SM-005 |
42| SM-005 | smith/ | SM-003 | SM-006/007/008 |
43| SM-006 | smith-core/ | SM-005 | SM-009 |
44| SM-007 | smith-ai/ | SM-005 | SM-009 |
45| SM-008 | smith-tui/ | SM-005 | SM-009 |
46| SM-009 | smith-harness/ | SM-006/007/008 | SM-010 |
47| SM-010 | smith-cli/ | SM-009 | SM-012 |
48| SM-011 | workspace | SM-009 | SM-012 |
49| SM-012 | testing | SM-010, SM-011 | — |
59## Crate Responsibilities
51What each crate owns and must not own is defined once in SPEC §2.2 — not
52repeated here, to avoid drift.
61| Crate | Owns | Does NOT own |
62|-------|------|-------------|
63| **smith/** | Shared types, StreamFn type, AgentTool trait, ProviderEvent, ProviderRequest, Lua runtime, config | No business logic, no I/O |
64| **smith-core/** | Agent loop (takes StreamFn), session, ToolRegistry, hooks, EngineEvent, AgentEvent, compaction, system prompt | No provider implementations, no I/O |
65| **smith-ai/** | Provider trait + impls, model registry, auth, OAuth, providers.json, provider_to_stream_fn | No agent loop, no session |
66| **smith-tui/** | 17 widgets, layout primitives, border layout, virtual scroll, themes | No business logic |
67| **smith-harness/** | Wiring (provider→StreamFn→agent), plugins, SDK, event bridge, built-in plugins, smith help | No new core logic |
68| **smith-cli/** | CLI subcommands (new, attach, continue, resume, eval, rpc, help) | No business logic |
54## Granularity
56These tasks are crate-sized, not buildable units: "SM-006 smith-core" is an
57entire agent loop plus session, tools, hooks, and events. Before a crate's wave
58starts it needs its own breakdown into vertical, tested slices. This file is
59top-level sequencing only; a pure bottom-up walk of it produces nothing runnable
60until SM-010, so the first implementation move should be a thin end-to-end slice
61(walking skeleton) rather than a full horizontal wave — see the plans index.

docs/plans/WALKING-SKELETON.md

Added
new file mode 100644

+104 / −0 text lines

1# Walking Skeleton — First Vertical Slice
2
3> Non-normative execution plan. `docs/SPEC.md` is canonical; where this file and
4> the spec disagree, the spec wins. This plan sequences the *first* code, not
5> the whole product — `TASK-BREAKDOWN.md` holds the full crate build order.
6
7## Why this exists
8
9`TASK-BREAKDOWN` is bottom-up: `smith/` → core/ai/tui → harness → cli. Built
10literally, nothing runs end-to-end until the last wave, so the first integration
11problem surfaces last — the most expensive place to find it. The walking
12skeleton inverts that: build the **thinnest possible slice through every layer**
13first, prove the seams connect, then widen. Each layer ships the minimum that
14lets the next one exist — no more.
16The slice is one agent turn, end to end, rendered and persisted:
18```
19input → agent loop → StreamFn → (scripted) ProviderEvents → one tool call
20 → assistant Message → EngineEvents → TUI render → session CBOR → reload
21```
23## The seams it proves (the entire point)
25The skeleton exists to exercise the four load-bearing boundaries once, together,
26before any of them is built out:
281. **StreamFn seam** (§5.4) — the agent loop consumes a `StreamFn`, never a
29 concrete provider. Proven in isolation by p07; proven *wired* here.
302. **EngineEvent seam** (§6.3) — the engine emits a UI-agnostic event stream;
31 the TUI is one consumer of it, not coupled to the loop.
323. **Session codec** (§6.6) — a turn round-trips through CBOR and reloads
33 identically. Proven in isolation by p06.
344. **TUI render loop** (§8) — EngineEvents render through `TestBackend` with no
35 TTY and no network. Proven in isolation by p08.
37If these four connect, the architecture holds. Everything else is widening.
39## In scope (the minimum per layer)
41| Crate | Ships only | Leans on |
42|-------|-----------|----------|
43| workspace (SM-003) | jj repo, Cargo workspace, crate skeletons, `xtask check` | — |
44| `smith/` (SM-005) | `Message`/`Id` (§5.1), `ProviderEvent`/`ProviderRequest` (§5.2), `AgentTool` (§5.3), `StreamFn` alias (§5.4), a minimal `Config` (§5.6) — and nothing else | — |
45| `smith-ai/` (SM-007) | one **scripted** `StreamFn` that replays a fixture `ProviderEvent` sequence (deterministic, hermetic) | p05, p29 |
46| `smith-core/` (SM-006) | one-turn agent loop (§6.1), `EngineEvent` emit (§6.3), one read-only tool via `ToolRegistry` (§6.10), session append + CBOR persist/reload (§6.5/§6.6) | p07, p06, p31 |
47| `smith-tui/` (SM-008) | message list + input area + status bar (subset of §8.6), driven by EngineEvents through `TestBackend` | p08, p22 |
48| `smith-harness/` (SM-009) | wire scripted StreamFn → loop → EngineEvent → TUI; register the one tool | p23 |
49| `smith-cli/` (SM-010) | `smith new` (run one turn, render, persist) and `smith attach` (reload + re-render the persisted session) | — |
51## Explicitly deferred (widening, not skeleton)
53Lua runtime and plugins (§5.5/§9); real providers, auth, OAuth (§7); compaction
54and cost (§6.9); session branching (§6.5 tree); the secret proxy (§6.7); the RPC
55frontend (§10.4); the remaining §8.6 widgets and layout; every CLI subcommand
56beyond `new`/`attach`. None of these block proving the seams.
58## Acceptance
60**One hermetic end-to-end test is the definition of done** (fast tier, §17.1;
61hermeticity rules, §17.10):
63> Given a scripted `StreamFn` whose fixture emits text then one tool call, when
64> `smith new` runs one turn, then the tool executes once, the assistant
65> `Message` is assembled from the `ProviderEvent` stream, the expected
66> `EngineEvent` sequence is observed, `TestBackend` renders the exchange, the
67> session is written as CBOR, and `smith attach` reloads it to a byte-identical
68> in-memory state.
70One additional **gated** smoke test (`network-tests` feature, off by default per
71§17.10) swaps the scripted StreamFn for a real Anthropic call, proving the same
72loop drives a live provider. It never runs in the default lane.
74## Build sequence
76Vertical, not the horizontal waves of `TASK-BREAKDOWN`:
78```
791. workspace skeleton + xtask green
802. smith/ minimal types (only what steps 3–7 consume)
813. scripted StreamFn (fixture in, ProviderEvents out)
824. agent loop: one turn over the StreamFn, EngineEvents out, one tool
835. session: append + CBOR persist/reload
846. TUI: render EngineEvents via TestBackend
857. harness wires 3–6; cli exposes `new` + `attach`
868. the acceptance test goes green → skeleton done
87```
89Each step is mergeable on its own and leaves the tree building.
91## Exit criteria
93- The acceptance test passes in the fast tier; the gated real-provider smoke
94 passes when explicitly run.
95- `cargo run -p xtask -- check` (fmt + clippy + arch + pup + test + doc) is
96 green on the slice.
97- No deferred subsystem was pulled in to make it work.
99## First widening steps after green
101Add a real provider normalizer behind the StreamFn (§7.2, p29); introduce the
102Lua runtime and the first built-in plugin (§5.5/§9); grow the widget set (§8.6);
103add `continue`/`resume` and the session tree (§6.5). Each rides the seams the
104skeleton already proved.