Merge branch 'pi'

# Conflicts:
#	CONTEXT.md
#	PRD.md
#	docs/AGENTS.md
This commit is contained in:
AlexKucera committed 2026-08-27 14:40:11 +02:00
commit e466870303
5 files changed
+101 -51

No files matched your search

+23 -16
View File
@@ -11,7 +11,7 @@
- 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/<type>/<id>/<id>.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.
@@ -21,9 +21,11 @@
- **Writing tools host (G6, ADR-0006):** the Museion binary doubles as the stdio MCP server `museion-tools`, registered into the profile at provisioning. Fix cards travel as its typed tool calls (ADR-0005) — the tool's argument schema is the fix-card schema; anchors are quote-based (exact substring + occurrence + context), so edits between issue and accept degrade to a loud no-match, never a wrong-span patch.
- **Critique memory home (ADR-0004):** writer learnings live in the project's `learnings/` (no dot — hand-editable, git-diffable), scoped per writing type (`learnings/posts/`, …), one markdown file per learning with decay state in frontmatter. The mentor's own automated memory stays in the profile; Museion never reads or writes it.
- **Model/provider:** user-managed by editing the `museion` profile's config (currently `zai/glm-5.3`); Museion never touches it.
- **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):** `<home>/learnings/<type>/` — per-writer, per-content-type, plain markdown, Museion-owned. Fresh start in v1; nothing to import.
## Problem
@@ -48,13 +50,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.* |
@@ -69,17 +71,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 (`posts/<id>/post.md`; folders created lazily on first write); new/rename/delete round-trip to the file system; a new post's folder is named from its first line's slug at first save.
- **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 (`<postid>/<postid>.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:* served by the Museion binary itself over stdio MCP (`museion-tools`), registered into the `museion` profile at provisioning (ADR-0006); 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. Defaults: file mutation outside card apply = ask-before; card apply = per-card accept; publish = ask-before; everything else = inform-after. No settings UI in v1.
- **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)
@@ -90,13 +93,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:* a dismissed learning resurfaces after 3 posts of its writing type; each further dismissal doubles the interval (3 → 6 → 12 …); per-learning `resurface_after` frontmatter overrides.
- **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 the project's `learnings/<writing type>/` (ADR-0004) — one file per learning, human-readable and git-diffable.
- **S4.4 — Mine alone.** As the writer, my memory is per-writer and portable. *AC:* lives in the project 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 `<home>/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)
@@ -145,7 +148,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)
@@ -155,9 +159,12 @@ 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 — Project layout → lazy post-folder convention (this session).** `posts/<post id>/` holding `post.md`, `research/`, `assets/`, created on first write; new writing types copy the shape. Post id = slug of the first line at first save.
- **G6 — Writing tools → in-app Swift MCP server (this session, ADR-0006).** One artifact serves the tools and the UI; fix cards travel as typed tool calls (ADR-0005) with quote-based anchors. Trust defaults fixed (S2.5); model/provider user-managed in the profile config.
- **G7 — Learnings scope → global per writing type (this session).** `learnings/posts/` etc., one file per learning; decay = resurface after 3 posts, doubling per dismissal, per-learning override. Micropub token → Keychain, no OAuth in v1.
- **G5 — Project layout → lazy post-folder convention (main grill session).** `posts/<post id>/` holding `post.md`, `research/`, `assets/`, created on first write; new writing types copy the shape. Post id = slug of the first line at first save.
- **G6 — Writing tools → in-app Swift MCP server (main grill session, ADR-0006).** One artifact serves the tools and the UI; fix cards travel as typed tool calls (ADR-0005) with quote-based anchors. Trust defaults fixed (S2.5); model/provider user-managed in the profile config.
- **G7 — Learnings scope → global per writing type (main grill session).** `learnings/posts/` etc., one file per learning; decay = resurface after 3 posts, doubling per dismissal, per-learning override. Micropub token → Keychain, no OAuth in v1.
- **G5 — Museion Home + folder-shaped content (pi grill session).** One Home (`~/Museion` default, Settings-editable, repoint-only); pieces are folders `content/<type>/<id>/<id>.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 (pi grill session).** `<home>/learnings/<type>/` — per-writer, per-content-type, plain markdown, fresh start. ADR-0005.
- **G7 — Origin wall, session drafting, decay clock (pi 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)