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,123 @@
1
+ /**
2
+ * MCP Server for miatel - Story World CLI
3
+ *
4
+ * Exposes beat/arc/theme tools as MCP tools
5
+ */
6
+ import { runCLI, parseJSONOutput, createToolResult, buildArgs } from "./utils.js";
7
+ import { dirname, join } from "path";
8
+ import { fileURLToPath } from "url";
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const CLI_PATH = join(__dirname, "../../miatel/dist/index.js");
11
+ export const miatelTools = [
12
+ {
13
+ name: "miatel_beat_create",
14
+ description: "Create a story beat in the narrative intelligence system",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ text: { type: "string", description: "Story beat content" },
19
+ character: { type: "string", description: "Character ID" },
20
+ tone: {
21
+ type: "string",
22
+ description: "Emotional tone",
23
+ enum: ["joy", "fear", "anticipation", "surprise", "sadness", "anger", "disgust", "trust", "neutral"]
24
+ },
25
+ phase: {
26
+ type: "string",
27
+ description: "Narrative phase",
28
+ enum: ["setup", "confrontation", "resolution", "unspecified"]
29
+ },
30
+ session: { type: "string", description: "Session ID" }
31
+ },
32
+ required: ["text"]
33
+ }
34
+ },
35
+ {
36
+ name: "miatel_beat_list",
37
+ description: "List story beats in current session",
38
+ inputSchema: {
39
+ type: "object",
40
+ properties: {
41
+ limit: { type: "string", description: "Maximum number of results" },
42
+ character: { type: "string", description: "Filter by character ID" },
43
+ session: { type: "string", description: "Session ID" }
44
+ }
45
+ }
46
+ },
47
+ {
48
+ name: "miatel_beat_analyze",
49
+ description: "Analyze a specific story beat",
50
+ inputSchema: {
51
+ type: "object",
52
+ properties: {
53
+ beatId: { type: "string", description: "Beat ID to analyze" },
54
+ universe: {
55
+ type: "string",
56
+ description: "Universe lens for analysis",
57
+ enum: ["engineer", "ceremony", "story_engine", "all"]
58
+ },
59
+ session: { type: "string", description: "Session ID" }
60
+ },
61
+ required: ["beatId"]
62
+ }
63
+ },
64
+ {
65
+ name: "miatel_beat_enrich",
66
+ description: "Apply emotional enrichment to a beat",
67
+ inputSchema: {
68
+ type: "object",
69
+ properties: {
70
+ beatId: { type: "string", description: "Beat ID to enrich" },
71
+ technique: {
72
+ type: "string",
73
+ description: "Enrichment technique",
74
+ enum: ["sensory", "stakes", "dialogue", "auto-detect"]
75
+ },
76
+ session: { type: "string", description: "Session ID" }
77
+ },
78
+ required: ["beatId"]
79
+ }
80
+ }
81
+ ];
82
+ export async function handleMiatelTool(name, args) {
83
+ try {
84
+ let cliArgs;
85
+ switch (name) {
86
+ case "miatel_beat_create":
87
+ cliArgs = buildArgs(["beat", "create"], args, { text: "-t", character: "--character", tone: "--tone", phase: "--phase" });
88
+ break;
89
+ case "miatel_beat_list":
90
+ cliArgs = buildArgs(["beat", "list"], args, { limit: "-n", character: "--character" });
91
+ break;
92
+ case "miatel_beat_analyze":
93
+ cliArgs = ["beat", "analyze", args.beatId];
94
+ if (args.universe)
95
+ cliArgs.push("--universe", args.universe);
96
+ if (args.session)
97
+ cliArgs.push("--session", args.session);
98
+ break;
99
+ case "miatel_beat_enrich":
100
+ cliArgs = ["beat", "enrich", args.beatId];
101
+ if (args.technique)
102
+ cliArgs.push("--technique", args.technique);
103
+ if (args.session)
104
+ cliArgs.push("--session", args.session);
105
+ break;
106
+ default:
107
+ return createToolResult({ error: `Unknown tool: ${name}` }, true);
108
+ }
109
+ const output = await runCLI(CLI_PATH, cliArgs);
110
+ const result = parseJSONOutput(output);
111
+ return createToolResult(result);
112
+ }
113
+ catch (err) {
114
+ return createToolResult({ error: err.message }, true);
115
+ }
116
+ }
117
+ export const miatelServerConfig = {
118
+ name: "miatel",
119
+ version: "0.1.0",
120
+ description: "Story World MCP Server - Beats, arcs, themes, narrative analysis",
121
+ tools: miatelTools,
122
+ handleTool: handleMiatelTool
123
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MCP Server for miawa - Ceremony World CLI
3
+ *
4
+ * Exposes ceremony/wound/eva tools as MCP tools
5
+ */
6
+ import { MCPTool, MCPToolResult } from "./utils.js";
7
+ export declare const miawaTools: MCPTool[];
8
+ export declare function handleMiawaTool(name: string, args: Record<string, any>): Promise<MCPToolResult>;
9
+ export declare const miawaServerConfig: {
10
+ name: string;
11
+ version: string;
12
+ description: string;
13
+ tools: MCPTool[];
14
+ handleTool: typeof handleMiawaTool;
15
+ };
@@ -0,0 +1,125 @@
1
+ /**
2
+ * MCP Server for miawa - Ceremony World CLI
3
+ *
4
+ * Exposes ceremony/wound/eva tools as MCP tools
5
+ */
6
+ import { runCLI, parseJSONOutput, createToolResult, buildArgs } from "./utils.js";
7
+ import { dirname, join } from "path";
8
+ import { fileURLToPath } from "url";
9
+ const __dirname = dirname(fileURLToPath(import.meta.url));
10
+ const CLI_PATH = join(__dirname, "../../miawa/dist/index.js");
11
+ export const miawaTools = [
12
+ {
13
+ name: "miawa_ceremony_init",
14
+ description: "Initiate a new ceremony session with intention",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ title: { type: "string", description: "Ceremony title" },
19
+ type: {
20
+ type: "string",
21
+ description: "Type of ceremony",
22
+ enum: ["group_reflection", "seasonal", "healing_circle", "wisdom_sharing"]
23
+ },
24
+ intention: { type: "string", description: "Ceremony intention" },
25
+ session: { type: "string", description: "Session ID" }
26
+ },
27
+ required: ["title", "type"]
28
+ }
29
+ },
30
+ {
31
+ name: "miawa_ceremony_list",
32
+ description: "List ceremonies in current session",
33
+ inputSchema: {
34
+ type: "object",
35
+ properties: {
36
+ session: { type: "string", description: "Session ID" }
37
+ }
38
+ }
39
+ },
40
+ {
41
+ name: "miawa_ceremony_advance",
42
+ description: "Advance ceremony to next movement (1-4)",
43
+ inputSchema: {
44
+ type: "object",
45
+ properties: {
46
+ ceremony: { type: "string", description: "Ceremony ID" },
47
+ session: { type: "string", description: "Session ID" }
48
+ },
49
+ required: ["ceremony"]
50
+ }
51
+ },
52
+ {
53
+ name: "miawa_ceremony_close",
54
+ description: "Close ceremony with wisdom archiving",
55
+ inputSchema: {
56
+ type: "object",
57
+ properties: {
58
+ ceremony: { type: "string", description: "Ceremony ID (uses active if not provided)" },
59
+ session: { type: "string", description: "Session ID" }
60
+ }
61
+ }
62
+ },
63
+ {
64
+ name: "miawa_ceremony_wisdom",
65
+ description: "Retrieve wisdom from completed ceremonies",
66
+ inputSchema: {
67
+ type: "object",
68
+ properties: {
69
+ ceremony: { type: "string", description: "Specific ceremony ID" },
70
+ session: { type: "string", description: "Session ID" }
71
+ }
72
+ }
73
+ },
74
+ {
75
+ name: "miawa_ceremony_stage",
76
+ description: "Check current ceremony stage and Four Movements",
77
+ inputSchema: {
78
+ type: "object",
79
+ properties: {
80
+ ceremony: { type: "string", description: "Ceremony ID" },
81
+ session: { type: "string", description: "Session ID" }
82
+ }
83
+ }
84
+ }
85
+ ];
86
+ export async function handleMiawaTool(name, args) {
87
+ try {
88
+ let cliArgs;
89
+ switch (name) {
90
+ case "miawa_ceremony_init":
91
+ cliArgs = buildArgs(["ceremony", "init"], args, { title: "-t", type: "--type", intention: "-i" });
92
+ break;
93
+ case "miawa_ceremony_list":
94
+ cliArgs = buildArgs(["ceremony", "list"], args, {});
95
+ break;
96
+ case "miawa_ceremony_advance":
97
+ cliArgs = buildArgs(["ceremony", "advance"], args, { ceremony: "--ceremony" });
98
+ break;
99
+ case "miawa_ceremony_close":
100
+ cliArgs = buildArgs(["ceremony", "close"], args, { ceremony: "--ceremony" });
101
+ break;
102
+ case "miawa_ceremony_wisdom":
103
+ cliArgs = buildArgs(["ceremony", "wisdom"], args, { ceremony: "--ceremony" });
104
+ break;
105
+ case "miawa_ceremony_stage":
106
+ cliArgs = buildArgs(["ceremony", "stage"], args, { ceremony: "--ceremony" });
107
+ break;
108
+ default:
109
+ return createToolResult({ error: `Unknown tool: ${name}` }, true);
110
+ }
111
+ const output = await runCLI(CLI_PATH, cliArgs);
112
+ const result = parseJSONOutput(output);
113
+ return createToolResult(result);
114
+ }
115
+ catch (err) {
116
+ return createToolResult({ error: err.message }, true);
117
+ }
118
+ }
119
+ export const miawaServerConfig = {
120
+ name: "miawa",
121
+ version: "0.1.0",
122
+ description: "Ceremony World MCP Server - Ceremonies, wounds, circles, Eva integration",
123
+ tools: miawaTools,
124
+ handleTool: handleMiawaTool
125
+ };
@@ -0,0 +1,51 @@
1
+ /**
2
+ * MCP Server base utilities for mia-code sub-CLIs
3
+ */
4
+ export interface MCPTool {
5
+ name: string;
6
+ description: string;
7
+ inputSchema: {
8
+ type: "object";
9
+ properties: Record<string, {
10
+ type: string;
11
+ description: string;
12
+ enum?: string[];
13
+ }>;
14
+ required?: string[];
15
+ };
16
+ }
17
+ export interface MCPToolResult {
18
+ content: Array<{
19
+ type: "text";
20
+ text: string;
21
+ }>;
22
+ isError?: boolean;
23
+ }
24
+ export interface MCPServerConfig {
25
+ name: string;
26
+ version: string;
27
+ cliPath: string;
28
+ tools: MCPTool[];
29
+ }
30
+ /**
31
+ * Run a CLI command and return parsed JSON output
32
+ */
33
+ export declare function runCLI(cliPath: string, args: string[]): Promise<string>;
34
+ /**
35
+ * Parse JSON output from CLI, handling errors gracefully
36
+ */
37
+ export declare function parseJSONOutput(output: string): any;
38
+ /**
39
+ * Create MCP tool result from parsed data
40
+ */
41
+ export declare function createToolResult(data: any, isError?: boolean): MCPToolResult;
42
+ /**
43
+ * Get session ID from args or environment
44
+ */
45
+ export declare function getSessionId(args: {
46
+ session?: string;
47
+ }): string | undefined;
48
+ /**
49
+ * Build CLI arguments from tool input
50
+ */
51
+ export declare function buildArgs(command: string[], args: Record<string, any>, mapping: Record<string, string>): string[];
@@ -0,0 +1,76 @@
1
+ /**
2
+ * MCP Server base utilities for mia-code sub-CLIs
3
+ */
4
+ import { spawn } from "child_process";
5
+ import { dirname } from "path";
6
+ import { fileURLToPath } from "url";
7
+ const __dirname = dirname(fileURLToPath(import.meta.url));
8
+ /**
9
+ * Run a CLI command and return parsed JSON output
10
+ */
11
+ export function runCLI(cliPath, args) {
12
+ return new Promise((resolve, reject) => {
13
+ const child = spawn("node", [cliPath, ...args, "--json"], {
14
+ cwd: process.cwd(),
15
+ env: { ...process.env, FORCE_COLOR: "0" }
16
+ });
17
+ let stdout = "";
18
+ let stderr = "";
19
+ child.stdout?.on("data", (chunk) => stdout += chunk.toString());
20
+ child.stderr?.on("data", (chunk) => stderr += chunk.toString());
21
+ child.on("close", (code) => {
22
+ if (code === 0) {
23
+ resolve(stdout.trim());
24
+ }
25
+ else {
26
+ reject(new Error(`CLI exited with code ${code}: ${stderr}`));
27
+ }
28
+ });
29
+ child.on("error", reject);
30
+ });
31
+ }
32
+ /**
33
+ * Parse JSON output from CLI, handling errors gracefully
34
+ */
35
+ export function parseJSONOutput(output) {
36
+ try {
37
+ return JSON.parse(output);
38
+ }
39
+ catch {
40
+ return { success: false, error: "Failed to parse CLI output", raw: output };
41
+ }
42
+ }
43
+ /**
44
+ * Create MCP tool result from parsed data
45
+ */
46
+ export function createToolResult(data, isError = false) {
47
+ return {
48
+ content: [{
49
+ type: "text",
50
+ text: typeof data === "string" ? data : JSON.stringify(data, null, 2)
51
+ }],
52
+ isError
53
+ };
54
+ }
55
+ /**
56
+ * Get session ID from args or environment
57
+ */
58
+ export function getSessionId(args) {
59
+ return args.session || process.env.MIA_SESSION_ID;
60
+ }
61
+ /**
62
+ * Build CLI arguments from tool input
63
+ */
64
+ export function buildArgs(command, args, mapping) {
65
+ const result = [...command];
66
+ for (const [key, flag] of Object.entries(mapping)) {
67
+ const value = args[key];
68
+ if (value !== undefined && value !== null && value !== "") {
69
+ result.push(flag, String(value));
70
+ }
71
+ }
72
+ if (args.session) {
73
+ result.push("--session", args.session);
74
+ }
75
+ return result;
76
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * MultilineInput - Multiline input handler for terminal CLIs
3
+ *
4
+ * Supports:
5
+ * - Ctrl+J to add new lines without submitting
6
+ * - Enter to submit the complete input
7
+ * - Pasting multiline content
8
+ * - Arrow key navigation
9
+ * - Interactive dropdown completion for / commands and @ file paths
10
+ * - TTY detection with readline fallback
11
+ */
12
+ import { EventEmitter } from "events";
13
+ export interface TabCompletion {
14
+ matches: string[];
15
+ /** Display labels (shown in dropdown). Falls back to matches if not provided. */
16
+ labels?: string[];
17
+ prefix: string;
18
+ /** Position in the input line where the completable token starts */
19
+ tokenStart: number;
20
+ /** Character to prepend to each match for display (e.g. "/" or "@") */
21
+ triggerChar: string;
22
+ /** If true, append "/" to directories instead of " " */
23
+ isFilePath?: boolean;
24
+ }
25
+ export interface MultilineInputOptions {
26
+ prompt: string;
27
+ continuationPrompt?: string;
28
+ maxLines?: number;
29
+ onSubmit: (input: string) => Promise<void>;
30
+ onClose?: () => void;
31
+ onTabComplete?: (input: string) => TabCompletion | null;
32
+ }
33
+ /**
34
+ * Check if environment supports raw mode multiline input
35
+ */
36
+ export declare function supportsMultilineInput(): boolean;
37
+ export declare class MultilineInput extends EventEmitter {
38
+ private prompt;
39
+ private continuationPrompt;
40
+ private maxLines;
41
+ private onSubmit;
42
+ private onClose?;
43
+ private onTabComplete?;
44
+ private lines;
45
+ private currentLine;
46
+ private cursorPos;
47
+ private isRunning;
48
+ private isPaused;
49
+ private isProcessing;
50
+ private dropdown;
51
+ private static readonly MAX_DROPDOWN_ITEMS;
52
+ private static stripAnsi;
53
+ private visibleLength;
54
+ private getColumns;
55
+ private getRows;
56
+ private wrappedRows;
57
+ constructor(options: MultilineInputOptions);
58
+ start(): void;
59
+ stop(): void;
60
+ pause(): void;
61
+ resume(): void;
62
+ reset(): void;
63
+ private showPrompt;
64
+ private redraw;
65
+ /**
66
+ * Calculate how many rows down from the cursor to the start of the dropdown
67
+ */
68
+ private rowsFromCursorToDropdown;
69
+ /**
70
+ * Reposition cursor back to the input editing position (absolute)
71
+ */
72
+ private repositionCursor;
73
+ private eraseDropdownRows;
74
+ private renderDropdown;
75
+ private clearDropdown;
76
+ /**
77
+ * Query the completion handler and update dropdown state
78
+ */
79
+ private updateDropdown;
80
+ /**
81
+ * Accept the currently selected dropdown item
82
+ */
83
+ private acceptDropdownSelection;
84
+ private handleData;
85
+ /**
86
+ * Check if the current input context should trigger a live dropdown.
87
+ * "/" commands: always live (few items, instant feedback).
88
+ * "@" files: only update if dropdown is already open (Tab to initiate).
89
+ */
90
+ private maybeShowDropdown;
91
+ /**
92
+ * Check if text ends with an active @path context (no space after @)
93
+ */
94
+ private isInAtContext;
95
+ private handlePaste;
96
+ private handleEscapeSequence;
97
+ private redrawAll;
98
+ }