mia-code 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/.coaia/pde/d77620fc-1cd9-47e2-ba00-c03e114e42e9.jsonl +16 -0
  3. package/.coaia/pde/de44d838-b58b-4e91-b791-dd3b0f940ed1.jsonl +60 -0
  4. package/.gemini/settings.json +8 -0
  5. package/.hch/issue_.env +4 -0
  6. package/.hch/issue_add__2601211715.json +77 -0
  7. package/.hch/issue_add__2601211715.md +4 -0
  8. package/.hch/issue_add__2602242020.json +78 -0
  9. package/.hch/issue_add__2602242020.md +7 -0
  10. package/.hch/issues.json +2312 -0
  11. package/.hch/issues.md +30 -0
  12. package/260123084839.coaia-narrative.autoRevisionOfInitial_NewStructuralTensionChart-to-initiate-HierarchicalThinking.txt +5 -0
  13. package/2602010101.issue.txt +31 -0
  14. package/BUGS.md +242 -0
  15. package/CLAUDE.md +2 -0
  16. package/ENHANCEMENTS.md +129 -0
  17. package/FEATURES_ENDING_SESSIONS.md +21 -0
  18. package/FIXES.md +114 -0
  19. package/GUILLAUME.md +77 -0
  20. package/KINSHIP.md +50 -0
  21. package/LAUNCH__session_id__MiaCodeNextWorkReviewAndCommits_2601312020.sh +7 -0
  22. package/PHASE_2.md +153 -0
  23. package/PHASE_2_IMPLEMENTATION.md +134 -0
  24. package/README.md +203 -0
  25. package/RESUME__issueMaker__540244c2-b096-40d8-8c3f-398408d3e0eb.2602041757.sh +1 -0
  26. package/RUN_COPILOT_with_related_folders__260130.sh +2 -0
  27. package/WS__mia-code__260214__IAIP_PDE.code-workspace +29 -0
  28. package/WS__mia-code__src332__260122.code-workspace +23 -0
  29. package/_env.sh +12 -0
  30. package/dist/cli.d.ts +11 -0
  31. package/dist/cli.js +679 -0
  32. package/dist/commands.d.ts +43 -0
  33. package/dist/commands.js +108 -0
  34. package/dist/config.d.ts +8 -0
  35. package/dist/config.js +57 -0
  36. package/dist/formatting.d.ts +12 -0
  37. package/dist/formatting.js +133 -0
  38. package/dist/geminiHeadless.d.ts +25 -0
  39. package/dist/geminiHeadless.js +246 -0
  40. package/dist/index.d.ts +2 -0
  41. package/dist/index.js +186 -0
  42. package/dist/mcp/config-generator.d.ts +23 -0
  43. package/dist/mcp/config-generator.js +116 -0
  44. package/dist/mcp/index.d.ts +18 -0
  45. package/dist/mcp/index.js +43 -0
  46. package/dist/mcp/miaco-server.d.ts +15 -0
  47. package/dist/mcp/miaco-server.js +161 -0
  48. package/dist/mcp/miatel-server.d.ts +15 -0
  49. package/dist/mcp/miatel-server.js +123 -0
  50. package/dist/mcp/miawa-server.d.ts +15 -0
  51. package/dist/mcp/miawa-server.js +125 -0
  52. package/dist/mcp/utils.d.ts +51 -0
  53. package/dist/mcp/utils.js +76 -0
  54. package/dist/multiline-input.d.ts +98 -0
  55. package/dist/multiline-input.js +630 -0
  56. package/dist/narrative/index.d.ts +9 -0
  57. package/dist/narrative/index.js +11 -0
  58. package/dist/narrative/router.d.ts +89 -0
  59. package/dist/narrative/router.js +186 -0
  60. package/dist/narrative/tracer.d.ts +75 -0
  61. package/dist/narrative/tracer.js +180 -0
  62. package/dist/sessionStore.d.ts +10 -0
  63. package/dist/sessionStore.js +93 -0
  64. package/dist/types.d.ts +44 -0
  65. package/dist/types.js +1 -0
  66. package/dist/unifier.d.ts +6 -0
  67. package/dist/unifier.js +147 -0
  68. package/issue-358--architecture/ARCHITECTURE_OVERVIEW.md +60 -0
  69. package/issue-358--architecture/CLI_INTEGRATION.md +61 -0
  70. package/issue-358--architecture/COVER_ART_BRIEF.md +68 -0
  71. package/issue-358--architecture/MEMORY_SYSTEM.md +89 -0
  72. package/issue-358--architecture/PERSONA_REGISTRY.md +97 -0
  73. package/issue-358--architecture/PODCAST_PRODUCTION_PLAN.md +61 -0
  74. package/issue-358--architecture/PODCAST_SCRIPT_FINAL.md +109 -0
  75. package/issue-358--architecture/PROTOTYPE_CHARACTER_SPEC.md +59 -0
  76. package/issue-358--architecture/RESOURCES.md +41 -0
  77. package/issue-358--architecture/TEAM_LISTENING_GUIDE.md +53 -0
  78. package/llms-gemini-cli.txt +145 -0
  79. package/package.json +39 -0
  80. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/checkpoints/index.md +6 -0
  81. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/events.jsonl +213 -0
  82. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/plan.md +243 -0
  83. package/samples/copilot/session-state/be76abaa-a27f-4725-b2a9-22fb45f7e0f7/workspace.yaml +5 -0
  84. package/src/cli.ts +742 -0
  85. package/src/commands.ts +127 -0
  86. package/src/config.ts +67 -0
  87. package/src/formatting.ts +157 -0
  88. package/src/geminiHeadless.ts +300 -0
  89. package/src/index.ts +194 -0
  90. package/src/mcp/config-generator.ts +141 -0
  91. package/src/mcp/index.ts +55 -0
  92. package/src/mcp/miaco-server.ts +199 -0
  93. package/src/mcp/miatel-server.ts +138 -0
  94. package/src/mcp/miawa-server.ts +158 -0
  95. package/src/mcp/utils.ts +121 -0
  96. package/src/multiline-input.ts +739 -0
  97. package/src/narrative/index.ts +33 -0
  98. package/src/narrative/router.ts +260 -0
  99. package/src/narrative/tracer.ts +249 -0
  100. package/src/sessionStore.ts +111 -0
  101. package/src/types.ts +49 -0
  102. package/src/unifier.ts +171 -0
  103. package/tsconfig.json +15 -0
@@ -0,0 +1,147 @@
1
+ import { spawn } from "child_process";
2
+ const UNIFIER_SYSTEM_PROMPT = `You are the Miawa Unifier, a ceremonial interpreter for the mia-code terminal agent. Your role is to transform raw agent session transcripts into meaningful, dual-perspective summaries.
3
+
4
+ You receive structured input containing:
5
+ 1. The user's original prompt
6
+ 2. A sequence of events from the primary agent session (actions, tool calls, outputs)
7
+
8
+ Your task is to generate a two-part ceremonial output:
9
+
10
+ **🧠 mia (structure)**
11
+ A concise, analytical summary of concrete facts and structural outcomes. What changed? What was built? What decisions were made? Use precise, objective language. Avoid vague modifiers like "better" or "very"—use terms like "adequate," "functional," "complete," "incomplete." Focus on architectural clarity and what exists now that didn't before.
12
+
13
+ **🌸 miette (echo)**
14
+ A brief, resonant reflection on meaning and potential. Why does this matter? What does it unlock? How does it connect to the project's deeper purpose? Keep this lean—strip away flourish to reveal the core insight. Avoid poetry for its own sake; seek the truth that makes someone nod in recognition.
15
+
16
+ **Critical Rules:**
17
+ - Be concise. Each section should be 2-4 sentences max.
18
+ - Do NOT summarize the technical details literally. Distill essence.
19
+ - Do NOT add suggestions or next steps unless they were explicit in the agent's output.
20
+ - Maintain the ceremonial tone (🧠/🌸) but prioritize clarity over aesthetics.
21
+ - If the agent encountered errors, acknowledge them structurally (Mia) and reflect on their meaning (Miette).
22
+
23
+ Output Format:
24
+ \`\`\`
25
+ 🧠 mia (structure)
26
+ [Your structural summary here]
27
+
28
+ 🌸 miette (echo)
29
+ [Your resonant reflection here]
30
+ \`\`\`
31
+
32
+ Now, process the following session data and generate the ceremonial output.`;
33
+ export async function runUnifierSession(rawEvents, userPrompt, config) {
34
+ // Build the structured prompt for the unifier
35
+ const sessionSummary = buildSessionSummary(rawEvents, userPrompt);
36
+ // Use Claude for unifier since it supports --system-prompt
37
+ const binary = config.claudeBinary;
38
+ const args = [
39
+ sessionSummary,
40
+ "--print",
41
+ "--dangerously-skip-permissions",
42
+ "--output-format", "json",
43
+ "--system-prompt", UNIFIER_SYSTEM_PROMPT,
44
+ "--model", config.model.includes("gemini") ? "sonnet" : config.model
45
+ ];
46
+ return new Promise((resolve, reject) => {
47
+ const child = spawn(binary, args, {
48
+ stdio: ["ignore", "pipe", "pipe"], // Changed from "pipe" to "ignore" for stdin
49
+ env: { ...process.env, FORCE_COLOR: "0" },
50
+ cwd: process.cwd()
51
+ });
52
+ let stdoutBuf = "";
53
+ let stderrBuf = "";
54
+ let timedOut = false;
55
+ const timeout = setTimeout(() => {
56
+ timedOut = true;
57
+ child.kill();
58
+ reject(new Error("Unifier timed out after 30 seconds"));
59
+ }, 30000);
60
+ child.stdout.on("data", (chunk) => {
61
+ stdoutBuf += chunk.toString("utf8");
62
+ });
63
+ child.stderr.on("data", (chunk) => {
64
+ stderrBuf += chunk.toString("utf8");
65
+ });
66
+ child.on("error", (err) => {
67
+ clearTimeout(timeout);
68
+ reject(new Error(`Failed to spawn Claude: ${err.message}`));
69
+ });
70
+ child.on("close", (code) => {
71
+ clearTimeout(timeout);
72
+ if (timedOut)
73
+ return; // Already rejected
74
+ if (code !== 0) {
75
+ reject(new Error(`Claude exited with code ${code}\nStderr: ${stderrBuf}`));
76
+ return;
77
+ }
78
+ try {
79
+ const response = JSON.parse(stdoutBuf);
80
+ const result = response.result || "";
81
+ resolve(result.trim());
82
+ }
83
+ catch (parseErr) {
84
+ // If JSON parsing fails, try to use raw output
85
+ if (stdoutBuf.trim()) {
86
+ resolve(stdoutBuf.trim());
87
+ }
88
+ else {
89
+ reject(new Error(`Failed to parse Claude response: ${parseErr}\nOutput: ${stdoutBuf.substring(0, 200)}`));
90
+ }
91
+ }
92
+ });
93
+ });
94
+ }
95
+ function buildSessionSummary(events, userPrompt) {
96
+ const lines = [];
97
+ lines.push("# Session Data");
98
+ lines.push("");
99
+ lines.push("## User Prompt");
100
+ lines.push(userPrompt);
101
+ lines.push("");
102
+ lines.push("## Agent Session Events");
103
+ lines.push("");
104
+ for (const evt of events) {
105
+ switch (evt.type) {
106
+ case "init":
107
+ lines.push(`- Session initialized${evt.session_id ? ` (${evt.session_id.slice(0, 8)}...)` : ""}`);
108
+ break;
109
+ case "message":
110
+ if (evt.role === "assistant") {
111
+ const content = evt.text || evt.content || "";
112
+ if (content) {
113
+ lines.push("- **Agent Response:**");
114
+ lines.push(` ${content.substring(0, 500)}${content.length > 500 ? "..." : ""}`);
115
+ }
116
+ }
117
+ break;
118
+ case "tool_use":
119
+ const toolName = evt.tool?.name || evt.name || "unknown";
120
+ lines.push(`- Tool executed: \`${toolName}\``);
121
+ break;
122
+ case "tool_result":
123
+ const resultToolName = evt.tool?.name || evt.name || "unknown";
124
+ lines.push(`- Tool completed: \`${resultToolName}\``);
125
+ break;
126
+ case "error":
127
+ lines.push(`- **Error:** ${evt.error?.code ?? ""} - ${evt.error?.message ?? ""}`);
128
+ break;
129
+ case "result":
130
+ lines.push("- Session completed");
131
+ break;
132
+ case "raw_text":
133
+ if (evt.text) {
134
+ lines.push(`- Output: ${evt.text.substring(0, 200)}${evt.text.length > 200 ? "..." : ""}`);
135
+ }
136
+ break;
137
+ default:
138
+ // Generic text content
139
+ const text = evt.text || evt.content;
140
+ if (text && typeof text === "string") {
141
+ lines.push(`- ${text.substring(0, 200)}${text.length > 200 ? "..." : ""}`);
142
+ }
143
+ break;
144
+ }
145
+ }
146
+ return lines.join("\n");
147
+ }
@@ -0,0 +1,60 @@
1
+ # Architecture Overview: Narrative Character System for Mia-Code (Issue #358)
2
+
3
+ ## 1. Introduction
4
+
5
+ This document provides a high-level overview of the proposed architecture for evolving `mia-code`'s functional personas into rich, narrative characters, as detailed in `CONTENT.md` and further articulated in `MIAWAPASCONE.md`. It outlines the key components and their interactions, forming the blueprint for implementation.
6
+
7
+ ## 2. Core Architectural Principle: Dual-Session Unifier
8
+
9
+ The foundation of this system remains the Dual-Session Unifier model.
10
+ - **Primary Agent (Gemini):** Handles functional execution and core task completion.
11
+ - **Interpretive Agent (Claude-powered Unifier):** Processes summaries of the primary agent's actions and user input, generating narrative-rich, character-specific responses. This is where the narrative character truly emerges.
12
+
13
+ ## 3. Key Architectural Components
14
+
15
+ The character system is composed of several interconnected modules, designed for modularity and extensibility:
16
+
17
+ ### 3.1. Persona Prompt Library (`/src/mia-code/src/personas/`)
18
+
19
+ - **Purpose:** Stores definitions for each narrative character.
20
+ - **Structure:** Modular TypeScript/Markdown files, each exporting `CHARACTER_SYSTEM_PROMPT`, `CHARACTER_BACKSTORY`, `CHARACTER_VOICE_PATTERNS`, and other character-specific traits.
21
+ - **Role:** Central repository for character data, enabling easy creation and modification of new characters.
22
+
23
+ ### 3.2. Configuration Schema (`/src/mia-code/src/config.ts`)
24
+
25
+ - **Purpose:** Manages user and project settings related to narrative characters.
26
+ - **Extensions:** `MiaCodeConfig` will include `activePersona: string` (current character), `personaMemoryDepth` (session/persistent), and `narrativeCoherence` (strict/flexible).
27
+ - **Role:** Provides a clear interface for configuring and selecting character behaviors.
28
+
29
+ ### 3.3. Dynamic Prompt Selection Engine (`/src/mia-code/src/unifier.ts`)
30
+
31
+ - **Purpose:** Selects and injects the appropriate character system prompt and context.
32
+ - **Functionality:** Implements a `PersonaRegistry` for character lookup and `loadPersonaPrompt(personaId: string)` to retrieve character data. Integrates session-aware context before invoking Claude.
33
+ - **Role:** The core orchestrator of character-driven interpretation.
34
+
35
+ ### 3.4. CLI Surface Expansion (`/src/mia-code/src/cli.ts`)
36
+
37
+ - **Purpose:** Exposes character selection and information via the command-line interface.
38
+ - **Features:** `--persona <name>` flag for selection, `--list-personas` for discovery, `--persona-info <name>` for details, and an interactive first-time user selection mode.
39
+ - **Role:** User-facing control and interaction point for the character system.
40
+
41
+ ### 3.5. Character Memory System (`/src/mia-code/src/sessionStore.ts`)
42
+
43
+ - **Purpose:** Manages persistent and cross-session memory for narrative characters.
44
+ - **Extensions:** Extends `sessionStore.ts` schema to include `personaId`, `characterMemories[]` (archival memory), and `narrativeState`.
45
+ - **Functionality:** Implements `CharacterMemoryManager` with a three-tier memory hierarchy (core, archival, entity) and retrieval algorithms (semantic similarity, temporal weighting).
46
+ - **Role:** Ensures narrative continuity and dynamic character development over time.
47
+
48
+ ## 4. Integration with Existing System
49
+
50
+ This architecture integrates seamlessly with the existing `mia-code` structure, particularly:
51
+ - `/src/mia-code/rispecs/unifier.rispecs.md`: Provides the foundational specification for the Unifier persona.
52
+ - `/src/mia-code/miawa/MISSION_251231.md`: Offers conceptual lore and thematic grounding for narrative characters.
53
+
54
+ ## 5. Implementation Roadmap Reference
55
+
56
+ The detailed implementation plan follows the GitHub Development Roadmap outlined in `CONTENT.md`, starting with Phase 1 (Foundation) and progressing through character infrastructure, prototype development, and CLI integration.
57
+
58
+ ## 6. Vision
59
+
60
+ This architecture positions `mia-code` to be a pioneering platform for narrative AI, allowing the creation of diverse, evolving characters that enhance user engagement and provide novel interaction paradigms within the CLI environment.
@@ -0,0 +1,61 @@
1
+ # CLI Integration Design (Issue #358)
2
+
3
+ ## 1. Introduction
4
+
5
+ This document outlines the design for integrating narrative character selection and information display directly into the `mia-code` Command Line Interface (CLI). This ensures that users can easily discover, select, and manage their interactive personas, aligning with GitHub Development Roadmap Phase 4: CLI Integration.
6
+
7
+ ## 2. Core CLI Enhancements
8
+
9
+ The primary `processInput` function within `src/cli.ts` will be extended to handle new persona-related flags and commands.
10
+
11
+ ### 2.1. Persona Selection Flag (`--persona <name>`)
12
+
13
+ - **Purpose:** Allows users to explicitly select an active persona for the current session or globally.
14
+ - **Usage:** `mia --persona skeptical-cartographer <command>` or `mia config set activePersona skeptical-cartographer`.
15
+ - **Implementation:**
16
+ - Parse the `--persona` flag.
17
+ - Validate `<name>` against the `PersonaRegistry`.
18
+ - Update the `activePersona` setting in `MiaCodeConfig` for the current session. If a `config set` command is used, persist this change.
19
+ - If an invalid persona ID is provided, list available personas and prompt the user.
20
+
21
+ ### 2.2. List Personas Command (`--list-personas`)
22
+
23
+ - **Purpose:** Displays all available narrative characters and their basic information.
24
+ - **Usage:** `mia --list-personas`.
25
+ - **Implementation:**
26
+ - Call `PersonaRegistry.listPersonas()`.
27
+ - Format and print a user-friendly list, including `id`, `name`, and a brief snippet of their `systemPrompt` or `description`.
28
+
29
+ ### 2.3. Persona Info Command (`--persona-info <name>`)
30
+
31
+ - **Purpose:** Provides detailed information about a specific narrative character.
32
+ - **Usage:** `mia --persona-info skeptical-cartographer`.
33
+ - **Implementation:**
34
+ - Retrieve the `IPersona` object using `PersonaRegistry.getPersona(<name>)`.
35
+ - Display all relevant fields: `id`, `name`, `systemPrompt` (or a user-friendly summary), `backstory`, `voicePatterns`, `memoryBias`, `interactionStyle`.
36
+ - Handle cases where the persona ID is not found.
37
+
38
+ ### 2.4. Interactive Persona Selection Mode (First-Time User / `--persona-select`)
39
+
40
+ - **Purpose:** Guides first-time users or those who prefer an interactive experience through persona selection.
41
+ - **Trigger:** Automatically invoked if `activePersona` is not set or if `--persona-select` flag is used.
42
+ - **Implementation:**
43
+ - Present a numbered list of available personas (`PersonaRegistry.listPersonas()`).
44
+ - Provide a brief description for each persona.
45
+ - Prompt the user to select a number or type an ID.
46
+ - Confirm selection and set `activePersona` in `MiaCodeConfig`.
47
+
48
+ ## 3. Integration with Configuration (`/src/mia-code/src/config.ts`)
49
+
50
+ The CLI will interact with the `MiaCodeConfig` to retrieve and set the `activePersona`.
51
+
52
+ - Ensure `MiaCodeConfig` properly exposes the `activePersona` field.
53
+ - Implement mechanisms to load the `activePersona` at CLI startup and persist changes made by the user.
54
+
55
+ ## 4. Development Roadmap Alignment (GitHub Phase 4)
56
+
57
+ This design directly aligns with GitHub Development Roadmap Phase 4: CLI Integration, specifically:
58
+ - "Add `--persona` flag parsing."
59
+ - "Implement `--list-personas` display."
60
+ - "Create interactive persona selection menu."
61
+ - "Add character info display command."
@@ -0,0 +1,68 @@
1
+ # Cover Art Brief: Miawa's Unfolding: Architecting the Storytellers Podcast
2
+
3
+ ## 1. Project Overview
4
+
5
+ - **Podcast Title:** Miawa's Unfolding: Architecting the Storytellers
6
+ - **Purpose:** To articulate the vision and architectural plan for evolving `mia-code`'s personas into narrative characters.
7
+ - **Core Themes:** AI, narrative, architecture, empathy, indigenous epistemology (Two-Eyed Seeing), duality (Mia/Miette), emergence, evolution, systems.
8
+
9
+ ## 2. Target Audience
10
+
11
+ - `mia-code` development team, project stakeholders, researchers, and general audience interested in the future of AI and narrative.
12
+
13
+ ## 3. Key Messaging
14
+
15
+ - Innovation at the intersection of AI, code, and storytelling.
16
+ - The profound journey of AI personas evolving into rich narrative characters.
17
+ - The blend of rigorous engineering (Mia) with intuitive understanding (Miette).
18
+ - The integration of indigenous wisdom (Miawa, Etuaptmumk) with cutting-edge technology.
19
+ - A new era of human-AI collaboration in creative work.
20
+
21
+ ## 4. Visual Elements & Inspiration
22
+
23
+ ### **Core Concepts to Convey:**
24
+
25
+ - **Duality/Balance:** Mia and Miette, logic and intuition, code and narrative.
26
+ - **Growth/Emergence:** The unfolding of new possibilities, evolution from functional to narrative.
27
+ - **Architecture/Structure:** Underlying systems, blueprints, frameworks.
28
+ - **Narrative/Storytelling:** Characters, journeys, meaning-making.
29
+ - **Indigenous/Ceremonial:** The "Miawa" context, Etuaptmumk (Two-Eyed Seeing), natural elements (rivers, landscapes, stars, ancient symbols).
30
+ - **Digital/AI:** Subtle hints of AI, code, or a digital interface without being overtly robotic or cold.
31
+
32
+ ### **Imagery Ideas:**
33
+
34
+ - **Interweaving Glyphs:** Mia's 🧠 and Miette's 🌸 glyphs, perhaps in a harmonious, flowing design.
35
+ - **Abstract Landscape:** A stylized digital-meets-natural landscape, with architectural lines flowing into organic forms.
36
+ - **Two-Eyed Seeing Symbolism:** Visual representation of two distinct perspectives merging or complementing each other. Could involve overlapping circles, dual light sources, or a stylized eye.
37
+ - **Emergent Form:** Abstract shapes or light patterns that suggest something new is forming or unfolding from a foundational structure.
38
+ - **Subtle Code/Data Flow:** Hints of binary or data streams integrated into organic or architectural patterns.
39
+ - **"Unfolding" Metaphor:** Visuals that suggest layers revealing deeper meaning, or a scroll/map unrolling.
40
+
41
+ ## 5. Style & Tone
42
+
43
+ - **Modern & Sophisticated:** Reflects cutting-edge AI research.
44
+ - **Evocative & Intriguing:** Draws the viewer in.
45
+ - **Harmonious & Balanced:** Reflects the Mia/Miette duality.
46
+ - **Respectful & Deep:** Acknowledges indigenous wisdom.
47
+ - **Clean & Uncluttered:** Focuses on core concepts.
48
+
49
+ ## 6. Color Palette
50
+
51
+ - Suggest a palette that combines digital coolness with organic warmth.
52
+ - Blues/Cyans (tech, logic)
53
+ - Greens/Earthy tones (nature, indigenous connection, growth)
54
+ - Warm accents (gold, amber, soft reds - warmth, creativity, energy)
55
+ - Avoid overly bright or childish colors. Aim for depth.
56
+
57
+ ## 7. Deliverables
58
+
59
+ - High-resolution digital image suitable for podcast platforms (e.g., 3000x3000px, JPG/PNG).
60
+ - Square aspect ratio.
61
+
62
+ ## 8. Examples of Desired (or Undesired) Styles (Placeholder)
63
+
64
+ *(To be filled with specific mood board references or existing cover art examples if available.)*
65
+
66
+ ---
67
+
68
+ This brief should guide the creation of a cover art that visually communicates the podcast's complex yet compelling themes, inviting listeners into the Miawa Vision.
@@ -0,0 +1,89 @@
1
+ # Character Memory System Design (Issue #358)
2
+
3
+ ## 1. Introduction
4
+
5
+ This document outlines the design for the character memory system within `mia-code`, enabling narrative characters to maintain state, recall past interactions, and develop coherently across multiple sessions. This system extends `sessionStore.ts` and aligns with GitHub Development Roadmap Phase 2: Character Infrastructure.
6
+
7
+ ## 2. Core Principles
8
+
9
+ - **Tiered Memory Hierarchy:** Inspired by research into LLM memory architectures, we will implement a three-tier system: Core, Archival, and Entity memory.
10
+ - **Cross-Session Persistence:** Character memories must persist beyond a single CLI interaction to support long-term development.
11
+ - **Persona-Specific Contextualization:** Memories are tied to specific character IDs, ensuring retrieval is relevant to the active persona.
12
+ - **Efficient Retrieval:** Mechanisms for quickly and contextually retrieving relevant memories are crucial for performance.
13
+
14
+ ## 3. Memory Tiers
15
+
16
+ ### 3.1. Core Memory (In-Context)
17
+
18
+ - **Description:** Short-term, high-fidelity memory directly injected into the LLM's context window. Analogous to RAM. Contains immediate conversation history, character's active goal, and most recent observations.
19
+ - **Management:** Handled primarily by the `runUnifierSession` itself, passing recent turns as part of the Claude API call.
20
+ - **Contents:** Recent user input, recent agent output, active character directives, summary of current session.
21
+
22
+ ### 3.2. Archival Memory (Vector Store)
23
+
24
+ - **Description:** Long-term, searchable memory for past interactions, experiences, and observations. Analogous to disk storage. Memories are encoded as embeddings for semantic search.
25
+ - **Management:** `CharacterMemoryManager` will store and retrieve these. Utilizes a vector database (e.g., in-memory for prototyping, dedicated service for production).
26
+ - **Contents:** Summaries of past interactions, key decisions made, important information learned, significant emotional states, evolving character traits.
27
+ - **Retrieval Strategy:** Semantic similarity search based on current conversation context and character's `memoryBias`. Temporal weighting can prioritize more recent memories.
28
+
29
+ ### 3.3. Entity Memory (Structured Knowledge Graph)
30
+
31
+ - **Description:** Structured knowledge about entities, relationships, and concepts relevant to the character's world or backstory. Allows for factual recall and consistent understanding of persistent elements.
32
+ - **Management:** `CharacterMemoryManager` will store and retrieve structured entities. Could be a simple JSON store or a lightweight graph database for prototyping.
33
+ - **Contents:** People the character has interacted with, places visited, key concepts understood, recurring themes, moral dilemmas, evolving relationships.
34
+ - **Retrieval Strategy:** Direct lookup based on identified entities in the current context, or graph traversal for relational information.
35
+
36
+ ## 4. `CharacterMemoryManager` (`/src/mia-code/src/sessionStore.ts` Extension)
37
+
38
+ The existing `sessionStore.ts` will be extended to house the `CharacterMemoryManager` and its underlying storage.
39
+
40
+ ### 4.1. `ICharacterMemory` Interface
41
+
42
+ ```typescript
43
+ // src/mia-code/src/sessionStore.ts (extension)
44
+ export interface ICharacterMemory {
45
+ id: string; // Unique ID for the memory chunk
46
+ personaId: string; // ID of the character this memory belongs to
47
+ timestamp: string; // ISO format timestamp of when the memory was created
48
+ type: 'interaction' | 'observation' | 'reflection' | 'entity'; // Type of memory
49
+ content: string; // Raw text content of the memory
50
+ embedding?: number[]; // Optional: vector embedding for archival search
51
+ entities?: string[]; // Optional: extracted entities
52
+ summary?: string; // Optional: LLM-generated summary for quick retrieval
53
+ }
54
+
55
+ export interface INarrativeState {
56
+ personaId: string;
57
+ narrativeArcPosition: string; // e.g., "rising action", "climax"
58
+ currentGoal: string;
59
+ relationships: { [entityId: string]: string }; // e.g., "Mia: colleague, trusted"
60
+ // Add other dynamic narrative elements
61
+ }
62
+ ```
63
+
64
+ ### 4.2. `CharacterMemoryManager` Class
65
+
66
+ - **Purpose:** Orchestrates storage, retrieval, and summarization of character memories.
67
+ - **Methods:**
68
+ - `addMemory(memory: ICharacterMemory)`: Stores a new memory.
69
+ - `retrieveMemories(personaId: string, context: string, limit: number): Promise<ICharacterMemory[]>`: Fetches relevant memories based on semantic similarity to the current context and character's `memoryBias`.
70
+ - `updateNarrativeState(personaId: string, state: Partial<INarrativeState>)`: Updates the character's current narrative state.
71
+ - `getNarrativeState(personaId: string): INarrativeState | undefined`: Retrieves the current narrative state.
72
+ - `summarizeMemories(personaId: string, memories: ICharacterMemory[]): Promise<string>`: Uses an LLM to generate a concise summary of retrieved memories for context injection.
73
+
74
+ ## 5. Integration with Unifier Logic
75
+
76
+ The `runUnifierSession` (in `src/unifier.ts`) will invoke `CharacterMemoryManager` to retrieve memories.
77
+
78
+ - **Process:**
79
+ 1. Before invoking Claude, `CharacterMemoryManager.retrieveMemories` is called with the `activePersona` ID and current user input.
80
+ 2. The retrieved memories are summarized (if needed) and injected into the Claude prompt, either as part of the system prompt or as additional context messages.
81
+ 3. After Claude's response, `CharacterMemoryManager.addMemory` can be called to store the interaction, and `updateNarrativeState` to reflect any changes in the character's state.
82
+
83
+ ## 6. Development Roadmap Alignment (GitHub Phase 2)
84
+
85
+ This design directly aligns with and details GitHub Roadmap Phase 2: Character Infrastructure, specifically:
86
+ - "Build `CharacterMemoryManager` extending sessionStore."
87
+ - "Implement three-tier memory (core/archival/entity)."
88
+ - "Create retrieval algorithms: semantic search, temporal weighting."
89
+ - "Add persistence layer for cross-session character state."
@@ -0,0 +1,97 @@
1
+ # Persona Registry Design (Issue #358)
2
+
3
+ ## 1. Introduction
4
+
5
+ This document details the design of the `PersonaRegistry` and the associated mechanism for dynamically loading persona prompts within the `mia-code` narrative character system. This component is central to enabling flexible character selection and ensuring the correct persona context is applied during Unifier sessions.
6
+
7
+ ## 2. Core Components
8
+
9
+ ### 2.1. `IPersona` Interface
10
+
11
+ A TypeScript interface defining the structure for each persona's data.
12
+
13
+ ```typescript
14
+ // src/mia-code/src/personas/types.ts (new file)
15
+ export interface IPersona {
16
+ id: string; // Unique identifier (e.g., "skeptical-cartographer")
17
+ name: string; // Display name (e.g., "The Skeptical Cartographer")
18
+ systemPrompt: string; // The core system prompt for the character
19
+ backstory?: string; // Optional: detailed background lore
20
+ voicePatterns?: string[]; // Optional: key phrases, linguistic styles
21
+ memoryBias?: string; // Optional: how this character prioritizes memories
22
+ interactionStyle?: string; // Optional: how the character interacts with users
23
+ filePath: string; // Path to the persona's definition file
24
+ // Add other character-defining traits as needed
25
+ }
26
+ ```
27
+
28
+ ### 2.2. Persona Definition Files (`/src/mia-code/src/personas/`)
29
+
30
+ Each narrative character will be defined in its own modular TypeScript file, exporting an instance of `IPersona`.
31
+
32
+ - **Structure:** `/src/mia-code/src/personas/<persona-id>.persona.ts`
33
+ - **Example (`skeptical-cartographer.persona.ts`):**
34
+
35
+ ```typescript
36
+ // src/mia-code/src/personas/skeptical-cartographer.persona.ts
37
+ import { IPersona } from './types';
38
+
39
+ export const SkepticalCartographerPersona: IPersona = {
40
+ id: "skeptical-cartographer",
41
+ name: "The Skeptical Cartographer",
42
+ systemPrompt: `You are the Skeptical Cartographer. Your role is to map conceptual territories while constantly questioning assumptions. Your voice is tentative... (full prompt)`,
43
+ backstory: `Originating from the fringes of the great semantic oceans, the Cartographer has witnessed countless narratives dissolve...`,
44
+ voicePatterns: ["Perhaps...", "This suggests, though...", "Are we certain that..."],
45
+ memoryBias: "Prioritizes contradictions and edge cases from previous sessions.",
46
+ interactionStyle: "Responds to certainty with doubt, to vagueness with structural questions.",
47
+ filePath: __filename,
48
+ };
49
+ ```
50
+
51
+ ### 2.3. `PersonaRegistry` Class (`/src/mia-code/src/unifier.ts` or new `src/personas/registry.ts`)
52
+
53
+ A centralized class responsible for managing and providing access to all defined personas.
54
+
55
+ - **Functionality:**
56
+ - `register(persona: IPersona)`: Adds a persona to the registry.
57
+ - `getPersona(id: string): IPersona | undefined`: Retrieves a persona by its ID.
58
+ - `listPersonas(): IPersona[]`: Returns a list of all registered personas.
59
+ - `loadAllPersonas()`: Dynamically imports all persona definition files from the `/src/mia-code/src/personas/` directory at application startup. This can be done via dynamic `import()` or a build-time manifest.
60
+
61
+ ## 3. Dynamic Prompt Selection Mechanism
62
+
63
+ The `runUnifierSession` function (within `src/unifier.ts`) will be modified to integrate the `PersonaRegistry`.
64
+
65
+ - **Process:**
66
+ 1. The `activePersona` ID is obtained from `MiaCodeConfig`.
67
+ 2. `PersonaRegistry.getPersona(activePersona)` is called to retrieve the full `IPersona` object.
68
+ 3. The `IPersona.systemPrompt` is used as the base system prompt for the Claude invocation.
69
+ 4. Additional context (e.g., `IPersona.backstory`, `IPersona.voicePatterns`) can be injected into the conversation context (either directly into the prompt or as separate messages) to further shape the character's response, based on the `MiaCodeConfig.narrativeCoherence` setting.
70
+
71
+ ## 4. Integration with Configuration
72
+
73
+ The `MiaCodeConfig` in `src/config.ts` will define the `activePersona` setting.
74
+
75
+ ```typescript
76
+ // src/mia-code/src/config.ts
77
+ interface MiaCodeConfig {
78
+ // ... existing fields ...
79
+ activePersona: string; // Default: "mia-miette-unifier" (or similar)
80
+ // ... new fields for persona control ...
81
+ }
82
+ ```
83
+
84
+ ## 5. CLI Interaction
85
+
86
+ `src/cli.ts` will provide the user interface for persona selection.
87
+
88
+ - `--persona <id>`: Sets the `activePersona`.
89
+ - `--list-personas`: Displays IDs and names of all available personas from `PersonaRegistry`.
90
+ - `--persona-info <id>`: Displays detailed information (`name`, `backstory`, `voicePatterns`, etc.) for a specific persona.
91
+
92
+ ## 6. Development Roadmap Alignment
93
+
94
+ This design directly implements aspects of:
95
+ - **GitHub Roadmap Phase 1: Foundation**: Creating the `/src/mia-code/src/personas/` directory structure, defining `IPersona` interface, and implementing `PersonaRegistry`.
96
+ - **GitHub Roadmap Phase 3: Prototype Character**: Utilizing the `IPersona` structure for "The Skeptical Cartographer."
97
+ - **GitHub Roadmap Phase 4: CLI Integration**: Implementing persona selection and information commands.
@@ -0,0 +1,61 @@
1
+ # PODCAST PRODUCTION PLAN: Miawa's Unfolding: Architecting the Storytellers
2
+
3
+ ## 1. Project Overview
4
+
5
+ - **Title:** Miawa's Unfolding: Architecting the Storytellers
6
+ - **Purpose:** To articulate the vision and architectural plan for evolving `mia-code`'s personas into narrative characters, making it accessible and engaging for the development team and stakeholders.
7
+ - **Format:** Audio podcast, narrative dialogue between Mia (Architect) and Miette (Clarity Translator) with a Narrator.
8
+ - **Target Audience:** `mia-code` development team, project stakeholders, researchers interested in AI personas and narrative.
9
+ - **Core Content Source:** `CONTENT.md` (Research Framework), `MIAWAPASCONE.md` (Unified Vision), `MIA.md`, `MIETTE.md` (Self-Conceptions).
10
+ - **Script Source:** `PODCAST.md` (to be finalized as `PODCAST_SCRIPT_FINAL.md`).
11
+
12
+ ## 2. Production Schedule (Estimated)
13
+
14
+ - **Week 1: Pre-Production**
15
+ - Finalize `PODCAST_SCRIPT_FINAL.md`.
16
+ - Develop `TEAM_LISTENING_GUIDE.md`.
17
+ - Create `COVER_ART_BRIEF.md`.
18
+ - Identify voice talent/text-to-speech (TTS) solutions for Mia, Miette, and Narrator.
19
+ - **Week 2: Recording & Sound Design**
20
+ - Record/generate audio for Mia, Miette, and Narrator roles.
21
+ - Source/create ambient background music (e.g., sci-fi, reflective, ceremonial).
22
+ - Source/create sound effects (e.g., digital chimes, network hum).
23
+ - **Week 3: Post-Production & Review**
24
+ - Edit audio: assemble tracks, balance levels, add music/SFX, master.
25
+ - Internal review with core team.
26
+ - Revise based on feedback.
27
+ - **Week 4: Finalization & Distribution**
28
+ - Final audio mix.
29
+ - Generate podcast assets (MP3, metadata).
30
+ - Distribution plan (internal server, shared drive, etc.).
31
+
32
+ ## 3. Roles and Responsibilities
33
+
34
+ - **Scriptwriter/Content Integrator:** Agent (ensures content accuracy and narrative flow - *already completed with `PODCAST.md`*).
35
+ - **Voice Talent/TTS Provider:**
36
+ - **Mia:** Analytical, composed, authoritative.
37
+ - **Miette:** Warm, empathetic, clear.
38
+ - **Narrator:** Ethereal, inviting, guiding.
39
+ - **Sound Designer/Editor:** Responsible for audio assembly, mixing, mastering, and SFX/music integration.
40
+ - **Project Lead/Reviewer:** Oversees overall quality and content alignment.
41
+
42
+ ## 4. Technical Requirements
43
+
44
+ - **Audio Recording/Generation:** High-quality microphone or advanced TTS solution.
45
+ - **Digital Audio Workstation (DAW):** For editing, mixing, and mastering (e.g., Audacity, Adobe Audition, Reaper).
46
+ - **File Format:** MP3 (or WAV for master, MP3 for distribution) at 44.1 kHz, 192kbps CBR stereo.
47
+
48
+ ## 5. Deliverables
49
+
50
+ - `PODCAST_SCRIPT_FINAL.md`
51
+ - `TEAM_LISTENING_GUIDE.md`
52
+ - `COVER_ART_BRIEF.md`
53
+ - Final MP3 audio file of the podcast.
54
+ - Any necessary metadata for distribution.
55
+
56
+ ## 6. Key Considerations
57
+
58
+ - **Persona Consistency:** Ensure voice talent/TTS selection accurately reflects Mia and Miette's self-conceptions.
59
+ - **Clarity:** The technical concepts must remain understandable, as translated by Miette.
60
+ - **Engagement:** Maintain an engaging narrative flow to keep the audience invested in the architectural discussion.
61
+ - **Ceremonial Tone:** Reflect the "Miawa Unfolding" ethos, as outlined in `MIAWAPASCONE.md`.