feat(mentor): museion-tools MCP server (#23)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Headless --serve-mcp role in the app binary: NDJSON JSON-RPC on stdio exposing query_learnings and submit_fix_cards (ADR-0006 cards, anchor-validated; stale lands flagged, never rejected), registered into the museion profile at provisioning. Cards persist per piece under <piece>/cards/ and surface in a floating Fix Cards palette with pass-stamped provenance. Live dogfood drove the shape: session/prompt waits pass length (the 15 s request default abandoned working turns), a liveness row and a persisted Debug checkbox (off) split writing sessions from debug chatter, the verdict references findings by title only while the cards carry the detail (persona v1.3 — tools work in silence), and the #24 pass rails (pass bar, TurnOutcome seam, snapshots) ride in. Three-reviewer audit round: piece-path shape guard closes the JSON-drop and substring-oracle holes, nested submit rawInput parsing (the flat parser never matched the live rail), missing stopReason never advances a pass, 1 MB stdin cap, card scan off MainActor. 296 tests green; every behavioral fix flip-verified. Closes #23
This commit is contained in:
1 parent
c2e94fd825
commit
683ddf8426
29 files changed
+2626
-169
No files matched your search
@@ -0,0 +1,70 @@
|
||||
//
|
||||
// Pass.swift
|
||||
// Museion
|
||||
//
|
||||
// #24 (S3.1): the pass substrate's shared vocabulary — PassKind (the app's
|
||||
// own Pass 1 / Pass 2 names; the skill stack's vocabulary stays engine-side,
|
||||
// CONTEXT.md) and PassContext, the minimal engine-facing prompt shape.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
/// One structured critique pass over a Piece (#24). Pass 1 = paragraph
|
||||
/// level and up; Pass 2 = sentence level and below. App vocabulary only —
|
||||
/// strictly 'Pass 1'/'Pass 2' (CONTEXT.md).
|
||||
nonisolated enum PassKind: String, CaseIterable {
|
||||
case pass1 = "Pass 1"
|
||||
case pass2 = "Pass 2"
|
||||
|
||||
/// What the pass critiques (CONTEXT.md).
|
||||
var level: String {
|
||||
switch self {
|
||||
case .pass1: "paragraph level and up"
|
||||
case .pass2: "sentence level and below"
|
||||
}
|
||||
}
|
||||
|
||||
/// The fixed pre-pass snapshot filename in `<piece>/passes/` — latest
|
||||
/// per pass type kept (a re-run overwrites in place).
|
||||
var snapshotFileName: String {
|
||||
switch self {
|
||||
case .pass1: "pass-1.md"
|
||||
case .pass2: "pass-2.md"
|
||||
}
|
||||
}
|
||||
|
||||
/// The Pass State a completed pass advances to.
|
||||
var doneState: Post.PassState {
|
||||
switch self {
|
||||
case .pass1: .pass1Done
|
||||
case .pass2: .pass2Done
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The engine-facing pass context (#24, PRD G6): pass name, piece path,
|
||||
/// tool reminders — the methodology itself lives engine-side and never
|
||||
/// travels through the app.
|
||||
nonisolated enum PassContext {
|
||||
/// The minimal engine-facing prompt for one pass over one piece.
|
||||
/// Pinned shape — keep it a small constant, not a template system.
|
||||
/// Restored contract (#23, museion-tools rail): findings travel as
|
||||
/// fix-card tool calls (submit_fix_cards) — the reply carries the
|
||||
/// verdict, never the findings.
|
||||
static func stub(kind: PassKind, pieceURL: URL, hasResearch: Bool) -> String {
|
||||
"Pass \(kind.rawValue) — \(kind.level).\nPiece: \(pieceURL.path)\n"
|
||||
+ (hasResearch
|
||||
? "Research notes: \(pieceURL.deletingLastPathComponent().appendingPathComponent("research").path)\n"
|
||||
: "")
|
||||
+ "Critique the piece for this pass. Deliver the verdict in your reply — "
|
||||
+ "findings travel as fix-card tool calls (submit_fix_cards). Do not write to the piece folder."
|
||||
}
|
||||
|
||||
/// Honest app-side token estimate BEFORE a pass runs (PRD: predictable,
|
||||
/// shown before, never a deterrent).
|
||||
static func estimateTokens(kind: PassKind, body: String, pieceURL: URL, hasResearch: Bool) -> Int {
|
||||
// chars/4 — the standard ~4-characters-per-token approximation, rounded up.
|
||||
let total = (stub(kind: kind, pieceURL: pieceURL, hasResearch: hasResearch) + body).count
|
||||
return (total + 3) / 4
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user