diff --git a/CONTEXT.md b/CONTEXT.md new file mode 100644 index 0000000..e84d53b --- /dev/null +++ b/CONTEXT.md @@ -0,0 +1,98 @@ +# Museion + +The Agentic Writing Environment: a native macOS app where the writer, the text, and a resident AI mentor work on long-form content under one roof. This glossary pins the language of that domain. + +## Language + +### Content + +**Museion Home**: +The single root folder holding all Museion-owned content and learnings. One home per writer. +_Avoid_: workspace, vault, project + +**Piece**: +A unit of writing of one Content Type; structurally a folder in the home (`content///`) containing the markdown file and per-piece Assets. +_Avoid_: document, file, manuscript + +**Post**: +A short-form Piece intended for blog publishing. The only Content Type in v1. +_Avoid_: article, entry, draft + +**Content Type**: +The kind of Piece (Post today; Essay, Story, Book later). Determines the folder under `content/` and the partition of Learnings. +_Avoid_: category, kind + +**Assets**: +The per-Piece folder (`/assets/`) for illustrations and other media belonging to that Piece alone. + +**Import**: +Bringing external markdown into the home as a Piece. External files are editable as-is; becoming a Post requires it. +_Avoid_: convert, migrate + +**Origin**: +The authorship record of a Post: writer or ai. Immutable; only writer-origin First Drafts are ever stats-eligible. +_Avoid_: source, mode + +### The Mentor Loop + +**Mentor**: +The resident agent: fierce critic in Passes, collaborator in Sessions (drafting, brainstorming). The only mind in v1. +_Avoid_: assistant, copilot, chatbot + +**Engine**: +The external agent process hosting the Mentor (Hermes over ACP in v1). Swappable by design; never owns Museion state. +_Avoid_: backend, model + +**Session**: +A conversation with the Mentor — freeform by default, sometimes the container of a Pass. Carries the standard affordances: new, resume, compact, fork. May float free of any Piece or associate with one. +_Avoid_: chat, thread + +**Pass**: +A structured critique run over a Piece. Pass 1 critiques at paragraph level and up (structure, argument, flow); Pass 2 at sentence level and below (line edits). The mentor reads and critiques; it never composes. +_Avoid_: review, run, check + +**Pass State**: +The maturity of a Piece, recorded in its frontmatter: First Draft, Pass-1 Done, Pass-2 Done. Explicit, never inferred. +_Avoid_: status, draft state + +**Fix Card**: +One finding from a pass: pattern, problem, diagnostic question, fix, anchor, provenance, status. Anchored to a text span; applying it edits the file. +_Avoid_: suggestion, comment, annotation + +**Learnings**: +The per-writer, per-content-type store of promoted critique patterns (`learnings//` in the home). Plain markdown, owned by Museion, consulted on every pass. +_Avoid_: critique memory, memory (unqualified), .learnings + +**Learning**: +One promoted pattern in Learnings: a Fix Card's fields plus the provenance of its promotion. +_Avoid_: rule, note + +**Skip**: +Closing a Fix Card as "not this instance." Records nothing. +_Avoid_: reject, dismiss + +**Apply**: +Accepting a Fix Card so its edit lands in the file. +_Avoid_: accept, fix (verb) + +**Promote**: +The writer's explicit confirmation that a pattern enters Learnings. Never automatic, never a repetition counter. +_Avoid_: save, remember + +**Dismiss**: +Marking a Learning as unwelcome. It fades per Decay and may resurface later. +_Avoid_: delete, skip + +**Decay**: +The policy governing when dismissed Learnings may resurface. +_Avoid_: expiry, timeout + +### Trust + +**Trust Level**: +One of four permissions for mentor actions: Auto-act, Inform-after, Ask-before, Never-do. +_Avoid_: permission mode + +**Provenance**: +The origin record carried by a Fix Card or Learning (piece, date, engine). +_Avoid_: metadata diff --git a/PRD.md b/PRD.md index 0fea67b..4c0564e 100644 --- a/PRD.md +++ b/PRD.md @@ -11,15 +11,17 @@ - Native SwiftUI macOS app, macOS 26.5+, Swift 6 (ADR-0001) - GPL-3.0-or-later (ADR-0002) - Forge: Gitea at git.babylondreams.de (ADR-0003) -- Plain markdown files on disk — no bespoke store (Obsidian gravity wins otherwise) +- Plain markdown files on disk — no bespoke store. Content is folder-shaped (ADR-0004): `content///.md` + `assets/` per piece — still plain files, so Obsidian gravity weakens but holds. - v1 = the Mentor Loop + library-light; long-form structure, multi-mind, Paper-grade polish deferred to v2+ - **Engine (G1, resolved):** Museion is the shell; Hermes (Python, NousResearch, MIT) is the engine, driven over **ACP** — spawned as a child process `hermes acp -p museion` (stdio JSON-RPC). **User-installed Hermes** — no app-managed install, no bundled Python. First run gates on `hermes acp --check`. - **Profile isolation (G3, this session):** Museion always runs Hermes under the dedicated `museion` profile (`~/.hermes/profiles/museion/` — isolated config, memory, skills, credentials, chat history). Coding learnings and writing learnings never mix. Not configurable in v1. - **Provisioning (G3a):** first run creates the `museion` profile if missing, then seeds the writing skills bundled in the app (Serif stack) into `~/.hermes/profiles/museion/skills/`. Seeding is **additive only** — a bundled skill absent from the profile is copied; an existing one is never overwritten, because the mentor's self-improving skills live there. - **Profile backup (G4):** Museion snapshots `~/.hermes/profiles/museion/` to `~/Library/Application Support/Museion/Backups/` — timestamped, at most once per day on launch, keeping the last 7. Snapshot is a complete copy (credentials included) so restore is one Finder copy-back; backups stay user-local, never in the project or git. -- **Writing tools register Hermes-side as MCP tools** (ACP carries the editor↔agent channel; MCP carries the agent's tools): edit-pass runner, critique-memory query/promote, draft stats, research. The Serif methodology (SKILL.md files, agentskills.io-standard) stays the mentor's operating system. Fallbacks if ACP ever falls short: Hermes gateway JSON-RPC (every feature), HTTP+SSE API server. +- **Writing tools, Museion-hosted (ADR-0005):** Museion runs an MCP server; any MCP-capable engine registers it as a client (engine-swap seam — Hermes today, Pi the identified fallback). Tool surface: `query_learnings`, `submit_fix_cards`; research stays engine-native; draft stats are computed natively in Swift. The Serif methodology (SKILL.md files, agentskills.io-standard) stays the mentor's operating system. Fallbacks if ACP ever falls short: Hermes gateway JSON-RPC (every feature), HTTP+SSE API server. - **Publish (G2, resolved):** Micro.blog via Micropub. Media endpoint accepts PNG (also JPEG, GIF, WebP, SVG, JXL — verified) — ink-sketch illustrations upload as-is. - **Build order:** loop-first — bridge spike (M0) before editor polish; the differentiator (critique memory) lands in M3, not last. +- **Museion Home:** `~/Museion` by default, editable in Settings; repoint-only — Museion never moves content. +- **Learnings live in the Home (G6):** `/learnings//` — per-writer, per-content-type, plain markdown, Museion-owned. Fresh start in v1; nothing to import. ## Problem @@ -44,13 +46,13 @@ v1 delivers this as the Mentor Loop. The workflow is not hypothetical — it alr **In scope:** the eight features below, sequenced M0–M7 (loop-first). -**Non-goals (deferred to v2+ or never):** long-form structure tools (binder/compile), multi-mind agents, vault depth (backlinks, graph), native Swift agent loop, app-managed Hermes install/venv, publish targets beyond Micro.blog, platforms beyond macOS, App Store distribution (GPL-3 landmine — struck). +**Non-goals (deferred to v2+ or never):** long-form structure tools (binder/compile), multi-mind agents, vault depth (backlinks, graph), native Swift agent loop, app-managed Hermes install/venv, publish targets beyond Micro.blog, platforms beyond macOS, App Store distribution (GPL-3 landmine — struck), session↔Post link machinery, engine-swap transcript migration, AI-draft wizards/templates. **Milestones:** | # | Milestone | Ships when | |---|---|---| -| M0 | **Bridge spike** (the slice test on real rails) | SwiftUI app spawns `hermes acp -p museion`, opens a session, sends a prompt, renders the streamed reply in a debug pane. A fix-card-shaped message round-trips. First run provisions the profile (create if missing + seed bundled skills) and takes the first snapshot. | +| M0 | **Bridge spike** (the slice test on real rails) | SwiftUI app spawns `hermes acp -p museion`, opens a session, sends a prompt, renders the streamed reply in a debug pane. A fix-card-shaped message round-trips. First run provisions the profile (create if missing + seed bundled skills) and takes the first snapshot. Records the engine version in `~/Library/Application Support/Museion/state.json` (surfaced in the gate and About). | | M1 | **Editor surface** | A folder of markdown posts opens, edits in calm focus mode, autosaves to disk — nothing but plain files. | | M2 | **Edit passes & fix cards** | Pass 1/Pass 2 runs on the current draft through the bridge; fix cards render; applying a card writes the file under the trust model. | | M3 | **Critique memory** — the differentiator | Promote/dismiss/decay works on real posts; every pass consults memory. *This is the milestone that justifies the app.* | @@ -65,17 +67,18 @@ M0–M3 is the ~3-month differentiator core; M4–M7 are sheddable in that order ### Editor surface (M1) -- **S1.1 — Open a project.** As the writer, I open a folder and see my posts and drafts listed, so the folder is the project. *AC:* the list mirrors disk; new/rename/delete round-trip to `.md` files. +- **S1.1 — Open the Home.** As the writer, I open the Museion Home and see my Posts listed. *AC:* the list mirrors `content/posts/`; new/rename/delete round-trip to piece folders (`/.md`); postid = title slug, frozen at creation, explicit Rename moves folder+file; external markdown opens and edits as-is; Import (copy, never move) makes it a Post. - **S1.2 — Write in calm.** As the writer, I edit in a distraction-free focus mode, so the tool disappears. *AC:* centered focus mode; autosave to disk; no proprietary store — every state survives closing the app. ### Mentor agent over the bridge (M0, M2) - **S2.1 — First-run engine gate & provisioning.** As the writer, Museion tells me on first run whether Hermes is ready (`hermes acp --check`) and how to install it if not; it then provisions its engine. *AC:* explicit pass/fail, no silent failure; the `museion` profile is created if missing; bundled writing skills are seeded additively — missing ones copied, existing ones never overwritten (G3a). - **S2.2 — The resident mind.** As the writer, the mentor runs as a resident I don't manage. *AC:* app spawns `hermes acp -p museion` (stdio JSON-RPC child); memory/skills/credentials load from `~/.hermes/profiles/museion/`; app quit tears down the child; child crash surfaces a restart prompt, never data loss. -- **S2.3 — Session lifecycle.** As the writer, each work session is a conversation I control. *AC:* new/cancel/fork per session; cancel mid-pass stops the agent; streamed output renders live. -- **S2.4 — Writing tools, Hermes-side.** As the mentor, I have purpose-built tools: edit-pass runner, critique-memory query/promote, draft stats, research. *AC:* registered as MCP tools in the `museion` profile; callable mid-pass; outputs land in Museion's UI. -- **S2.5 — Trust model.** As the writer, the mentor acts only within trust levels: auto-act / inform-after / ask-before / never-do. *AC:* trust level maps to UI (dimmed inline edits vs blocking asks); never-do actions never auto-apply. +- **S2.3 — Session lifecycle.** As the writer, each session is a conversation with the standard affordances. *AC:* new/cancel/fork/resume/compact; every pass auto-creates its session; freeform sessions always allowed, free-floating or Piece-associated; sessions are engine-owned — Museion only UIs them (swap the engine, transcripts stay behind); cancel mid-pass stops the agent; streamed output renders live. +- **S2.4 — Writing tools, Museion-hosted.** As the mentor, I have purpose-built tools. *AC:* Museion hosts the MCP server (ADR-0005); surface = `query_learnings` + `submit_fix_cards`; callable mid-pass; outputs land in Museion's UI; research stays engine-native; draft stats are computed natively in Swift at capture time — not an agent tool. +- **S2.5 — Trust model.** As the writer, the mentor acts only within trust levels: auto-act / inform-after / ask-before / never-do. *AC:* trust level maps to UI (dimmed inline edits vs blocking asks); never-do actions never auto-apply. Defaults, not configurable in v1: research fetch = auto-act; candidate source-note = inform-after; apply any fix, promote, keep note, publish = ask-before; delete files, touch anything outside Home and profile, shell, git = never-do. - **S2.6 — The engine is backed up.** As the writer, the mentor's accumulated state (memory, skills, history) survives profile corruption or a bad update. *AC:* on launch, if the last snapshot is older than a day, Museion copies `~/.hermes/profiles/museion/` to a timestamped snapshot under `~/Library/Application Support/Museion/Backups/`, keeping the last 7 (G4); complete copy, credentials included; restore is manual copy-back in v1; snapshots never land in the project or git. +- **S2.7 — Draft from session.** As the writer, a freeform session can birth a Post. *AC:* "New Post from Session" creates the piece folder, writes the draft, stamps `origin: ai` (immutable — never stats-eligible); brainstorming is a session started with a brainstorm prompt — no separate machinery; session↔Post association stays by name/convention. ### Structured edit passes → fix cards (M2) @@ -86,13 +89,13 @@ M0–M3 is the ~3-month differentiator core; M4–M7 are sheddable in that order ### Persistent critique memory — the load-bearing feature (M3) - **S4.1 — Promote by confirmation.** As the writer, only my explicit confirmation promotes a fix card into persistent critique memory — never a raw repetition counter. *AC:* one confirm = one entry, carrying the fix-card fields plus provenance. -- **S4.2 — Dismiss with decay.** As the writer, dismissed patterns fade instead of haunting me. *AC:* dismissed entries resurface at most after a decay interval; repeated dismissal buries further; decay is configurable. -- **S4.3 — The mentor remembers.** As the writer, every future pass consults my critique memory, so recurring weaknesses surface as fix cards. *AC:* stored as plain markdown (formalized `.learnings/`), human-readable and git-diffable. -- **S4.4 — Mine alone.** As the writer, my memory is per-writer and portable. *AC:* lives under the project/profile as plain files; importable from today's hand-maintained MEMORY.md. +- **S4.2 — Dismiss with decay.** As the writer, dismissed patterns fade instead of haunting me. *AC:* dismissed entries resurface after 10 subsequent passes of that content type (output-clock, not calendar); each re-dismiss doubles the interval (10→20→40…); one config knob (the base number). +- **S4.3 — The mentor remembers.** As the writer, every future pass consults my critique memory, so recurring weaknesses surface as fix cards. *AC:* stored as plain markdown in `/learnings/posts/`, human-readable, diffable and exportable. +- **S4.4 — Mine alone.** As the writer, my memory is per-writer and portable. *AC:* lives in the Museion Home as plain files; fresh start in v1 — no legacy import (today's `serif` profile on the Pi carries no learnings). ### Measurable improvement (M4) -- **S5.1 — Measure the writer, not the text.** As the writer, stats (burstiness, type-token ratio, sentence-length variation, trigram repetition) are computed on **unaided first drafts only**. *AC:* edited text never feeds the trend; first-draft detection is explicit (pass state), not inferred. +- **S5.1 — Measure the writer, not the text.** As the writer, stats (burstiness, type-token ratio, sentence-length variation, trigram repetition) are computed on **unaided first drafts only**. *AC:* edited text never feeds the trend; first-draft detection is explicit (pass state), not inferred; capture fires at first Pass-1 invocation, before the engine sees anything; only `origin: writer` First Drafts qualify — `origin` (writer|ai) is immutable frontmatter; captured stats live in the `museion:` frontmatter block, so the trend view is a scan of `content/posts/`. - **S5.2 — See the arc.** As the writer, I see per-metric trends across drafts over time. *AC:* the view answers "am I getting better," not "is this draft good." ### Illustration pass (M6) @@ -141,7 +144,8 @@ M0–M3 is the ~3-month differentiator core; M4–M7 are sheddable in that order 5. **UX smothering fierceness** — friction is the product; polish that hides the critique kills it. *Mitigation:* critique stays visible and sharp in the UI (S3.2/S4 cards are first-class, never toasts). 6. **Stats validity** — measuring edited output proves the edits, not the writer. *Mitigation:* unaided-first-drafts-only is a hard rule (S5.1), not a setting. 7. **Profile leakage** — coding learnings contaminating the writing mentor. *Mitigation:* solved by design (G3) — `-p museion` always, not configurable in v1. -8. **Carried, personal-v1-moot:** macOS-only · n=1 design risk · category evangelism · Obsidian's gravity (the switch reason, if published, is mentor + memory, not "native and elegant"). +8. **Engine upstream death or drift** — Hermes could stall or turn unfavorable. *Mitigation:* ADR-0005 — Museion owns all durable state, tools run in a Museion-hosted MCP server, and sessions (the only engine-owned state) are expendable; Pi is the identified fallback. +9. **Carried, personal-v1-moot:** macOS-only · n=1 design risk · category evangelism · Obsidian's gravity (the switch reason, if published, is mentor + memory, not "native and elegant"). ## Decisions (audit trail) @@ -151,6 +155,9 @@ M0–M3 is the ~3-month differentiator core; M4–M7 are sheddable in that order - **G3a — Provisioning + skill seeding (this session).** User decision: Museion creates the `museion` profile if missing and copies its bundled writing skills (Serif stack, shipped as app resources) into the profile. Seeding is additive-only so it never clobbers the mentor's self-improved skills — a later Museion version adds new skills, never overwrites old ones. - **G4 — Profile backup (this session).** User decision: Museion keeps timestamped snapshots of the whole `museion` profile — the mentor's memory and improved skills are irreplaceable state, not reinstallable. Defaults: daily on launch, last 7 kept, complete copy including credentials (same-machine threat model), restore manual in v1. - **Build order → loop-first (this session).** M0 bridge spike before editor polish; differentiator (M3) before conveniences (M5–M7). +- **G5 — Museion Home + folder-shaped content (grill session).** One Home (`~/Museion` default, Settings-editable, repoint-only); pieces are folders `content///.md` + `assets/`; external markdown edits as-is, Import (copy) makes it a Post. Supersedes S1.1's folder-is-project. ADR-0004. +- **G6 — Learnings in the Home; the engine owns nothing (grill session).** `/learnings//` — per-writer, per-content-type, plain markdown, fresh start. ADR-0005. +- **G7 — Origin wall, session drafting, decay clock (grill session).** "New Post from Session" stamps immutable `origin: ai`; only writer-origin First Drafts feed stats; brainstorm = session flavor; decay is output-clock (10 passes, doubling on re-dismiss). ## Stress-test verdict № 1 (2026-08-26 — carried from MISSION.md) diff --git a/docs/AGENTS.md b/docs/AGENTS.md index 5505a8d..8a5e877 100644 --- a/docs/AGENTS.md +++ b/docs/AGENTS.md @@ -10,7 +10,7 @@ Owned by the root AGENTS.md contract. ## Local Contracts -- ADRs live in `docs/adr/`, sequentially numbered `NNNNN-slug.md` (currently `0001`–`0003`: stack, license, forge/CI). +- ADRs live in `docs/adr/`, sequentially numbered `NNNNN-slug.md` (currently `0001`–`0005`: stack, license, forge/CI, folder-shaped content, Museion-owned state). - ADR format follows the domain-modeling skill's `ADR-FORMAT.md`: short title + 1–3 sentences; optional Considered Options / Consequences only when they earn their place. ## Work Guidance diff --git a/docs/adr/0004-folder-shaped-content.md b/docs/adr/0004-folder-shaped-content.md new file mode 100644 index 0000000..95384c0 --- /dev/null +++ b/docs/adr/0004-folder-shaped-content.md @@ -0,0 +1,3 @@ +# 0004 — Content is folder-shaped under one Museion Home + +Content lives as per-piece folders (`content///.md` + `assets/`) under a single Museion Home (`~/Museion` by default, editable in Settings; repoint-only — Museion never moves content), not as loose files in an opened project folder. The Scrivener-shaped unit buys colocated assets and a growth path to long-form types at the cost of a post no longer being one file; external markdown is edited as-is, and Import (copy, never move) makes it a Post. diff --git a/docs/adr/0005-museion-owns-state-engine-swappable.md b/docs/adr/0005-museion-owns-state-engine-swappable.md new file mode 100644 index 0000000..76cc6b6 --- /dev/null +++ b/docs/adr/0005-museion-owns-state-engine-swappable.md @@ -0,0 +1,3 @@ +# 0005 — Museion owns all state; the engine is a swappable critic + +All durable state — content, Learnings, Pass State — lives in the Museion Home or app containers, never in engine-owned directories. Writing tools run in a Museion-hosted MCP server that any MCP-capable engine registers as a client (Hermes over ACP today; Pi is the identified fallback). Sessions are engine-owned by design — an engine swap leaves transcripts behind, never Learnings.