Skip to content

chore(src): one folder per part, and the prompts one module per Brain task - #211

Open
wine-fall wants to merge 2 commits into
mainfrom
zachg-0904--src-layout
Open

chore(src): one folder per part, and the prompts one module per Brain task#211
wine-fall wants to merge 2 commits into
mainfrom
zachg-0904--src-layout

Conversation

@wine-fall

Copy link
Copy Markdown
Owner

What

src/ was 49 modules laid flat, with no line between a part and its neighbours. They now sit by the part they serve, and the one-file prompt library is one module per Brain task.

src/
  main.ts  app.ts  config.ts  contracts.ts  paths.ts  locale.ts  warnings.ts   (the spine, still at the root)
  brain/     brain persona talk-tools steer-responder steer-tools rwt
  prompts/   talk reply music rwt cadence setup profile persona status report  + persona-seed.md
  director/  director cadence scene scheduler activity
  audio/     engine ffmpeg bed wav viz
  voice/     voice hosted-voice voice-config
  music/     music music-tools music-programmer music-policy listening-data
  memory/    memory recall compaction
  host/      host ipc ipc-host settings
  setup/     guide first-run startup cc-tools
  support/   dev-log diagnostics report deliver sentinel update

Folder assignment follows each module's own header (the spec it names) and the component table in specs/DESIGN.md §4. src/prompts.ts was split along its own // --- section --- markers; reply.ts (respond + steer) imports the shared ContextPack renderers from talk.ts, which is the only visibility change. specs/DESIGN.md §0 now states the per-task layout.

No behavior change

  • Pure git mv plus import rewrites (a script computed every relative path from the old and new locations; tsc is the proof).
  • import.meta-relative assets re-aimed (bed.ts, voice-config.ts../../assets/; the persona seed sits beside prompts/persona.ts). config.ts stays at the root, so its ../package.json / ../tui resolution is untouched.
  • Tarball whitelist: src/host/ipc.ts, src/director/activity.ts. npm pack --dry-run shows dist/prompts/*.js + persona-seed.md and dist/main.js where bin expects it.
  • The TUI's one reach-in is now ../../src/host/ipc.ts; test/front-end-isolation.test.ts reads src/ recursively and pins host/ipc.ts as the only crossing (changed first, red, then green).
  • Every src/<name>.ts mention in specs, README-adjacent docs, Makefile, CI and comments re-aimed by the same map. test/ stays flat; only its imports changed.

Left in place on purpose: tool descriptions beside their zod schemas (steer-tools, music-tools, cc-tools, voice-config) — a field and its description are one contract; only sentences shared across places (ANNOUNCE_FIELD_DESCRIPTION) are centralized. Prompts stay TS template literals rather than .md: most interpolate, and a slot engine plus prepack copies would be machinery for nothing.

Evidence

  • pnpm run typecheck, npx oxlint …, pre-commit run --all-files: green.
  • vitest: 69 files, 1425 passed, 1 skipped.
  • tui: bun run typecheck green.
  • Boot smoke (--brain stub --voice stub --no-music --no-bed --max-segments 1 --plain, throwaway MURMUR_HOME): one beat aired, stopped cleanly.
  • npm pack --dry-run: prepack builds the nested dist/, whitelist entries exist.
  • Not run: make pack (the global-install rehearsal). The tarball listing covers the files/prepack risk it exists for.

Peer review (codex gpt-5.6-sol, xhigh): 1 finding, 1 applied (spec03 ducking inventory now spells out each moved module's folder), 0 dismissed. Verdict: acceptable.

AI coding brief

Original request. "The file structure is messy: everything lies flat under src/ with no business/feature grouping — refactor it (ponytail)." Mid-task: "prompts/ holds one file — we surely have more than one system prompt; are they coupled inside the TS? Pull them out sensibly."

Manual interventions. The user asked to see the proposed tree before the PR was opened; no assignment was changed after that.

Retro. A pure-move refactor is best done as one scripted map (old path → new path) that drives git mv, import rewrites and the doc sed alike — the script is the spec, tsc is the test. Knowing up front which files compute paths from import.meta and which files the tarball/TUI reach into would have been the whole checklist.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V844VFWV8TcjrtHsvcpWP2

wine-fall and others added 2 commits September 4, 2026 18:58
…ain task

src/ was 49 modules laid flat. They now sit by the part they serve —
brain/ director/ audio/ voice/ music/ memory/ host/ setup/ support/ — with the
spine (main, app, config, contracts, paths, locale, warnings) left at the root.
src/prompts.ts split along its own section markers into src/prompts/<task>.ts:
talk, reply, music, rwt, cadence, setup, profile, persona, status, report; the
persona seed stays beside them. No behavior change: pure moves plus import
rewrites, every path mention in specs/comments re-aimed, the tarball whitelist
and the TUI's one reach-in (src/host/ipc.ts) updated with the isolation test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V844VFWV8TcjrtHsvcpWP2
Peer review (codex): a co-location shorthand now implied paths that do not exist.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V844VFWV8TcjrtHsvcpWP2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant