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
package/dist/index.js ADDED
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { createInterface } from "readline";
4
+ import { runInteractiveCli, runSinglePrompt } from "./cli.js";
5
+ import { getConfigPath, loadConfig, saveConfig, ENGINE_MODELS, ENGINES } from "./config.js";
6
+ import { listSessions, clearSessions } from "./sessionStore.js";
7
+ import { generateClaudeConfig, generateToolManifest, generateServerInfo } from "./mcp/index.js";
8
+ import chalk from "chalk";
9
+ import { readFileSync } from "fs";
10
+ import { fileURLToPath } from "url";
11
+ import path from "path";
12
+ const program = new Command();
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = path.dirname(__filename);
15
+ const pkg = JSON.parse(readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
16
+ program
17
+ .name("mia-code")
18
+ .description("Mia/Miette/Miawa terminal coding agent wrapping Gemini CLI headless mode.")
19
+ .version(pkg.version);
20
+ program
21
+ .command("chat", { isDefault: true })
22
+ .description("Start interactive terminal session (default)")
23
+ .option("-p, --project <path>", "Project root directory (default: cwd)")
24
+ .option("-r, --resume [sessionId]", "Resume a session (interactive picker if no ID provided)")
25
+ .option("-y, --yolo", "Enable YOLO mode (auto-approve all actions)")
26
+ .option("--raw", "Skip unifier, show raw agent output")
27
+ .option("--claude", "Use Claude engine instead of Gemini")
28
+ .option("--copilot", "Use Copilot engine")
29
+ .option("--gemini", "Use Gemini engine (default)")
30
+ .option("--add-dir <dirs...>", "Additional directories to allow tool access to")
31
+ .action(async (opts) => {
32
+ await runInteractiveCli({
33
+ projectRoot: opts.project,
34
+ resume: opts.resume,
35
+ yolo: opts.yolo,
36
+ raw: opts.raw,
37
+ engine: opts.claude ? "claude" : opts.copilot ? "copilot" : opts.gemini ? "gemini" : undefined,
38
+ addDirs: opts.addDir
39
+ });
40
+ });
41
+ program
42
+ .command("prompt <text>")
43
+ .description("Run a single prompt and exit")
44
+ .option("-p, --project <path>", "Project root directory")
45
+ .option("-r, --resume <sessionId>", "Resume a specific session")
46
+ .option("-y, --yolo", "Enable YOLO mode")
47
+ .option("--raw", "Skip unifier, show raw agent output")
48
+ .option("--claude", "Use Claude engine instead of Gemini")
49
+ .option("--copilot", "Use Copilot engine")
50
+ .option("--gemini", "Use Gemini engine (default)")
51
+ .option("--add-dir <dirs...>", "Additional directories to allow tool access to")
52
+ .action(async (text, opts) => {
53
+ await runSinglePrompt(text, {
54
+ projectRoot: opts.project,
55
+ resume: opts.resume,
56
+ yolo: opts.yolo,
57
+ raw: opts.raw,
58
+ engine: opts.claude ? "claude" : opts.copilot ? "copilot" : opts.gemini ? "gemini" : undefined,
59
+ addDirs: opts.addDir
60
+ });
61
+ });
62
+ program
63
+ .command("config")
64
+ .description("View or update mia-code configuration")
65
+ .option("--set-engine <engine>", "Set default engine (gemini or claude)")
66
+ .option("--set-gemini-bin <path>", "Set path to gemini binary")
67
+ .option("--set-claude-bin <path>", "Set path to claude binary")
68
+ .option("--set-model <model>", "Set default model")
69
+ .option("--set-yolo <bool>", "Set default YOLO mode (true/false)")
70
+ .action(async (opts) => {
71
+ if (opts.setEngine || opts.setGeminiBin || opts.setClaudeBin || opts.setModel || opts.setYolo !== undefined) {
72
+ const partial = {};
73
+ if (opts.setEngine)
74
+ partial.engine = opts.setEngine;
75
+ if (opts.setGeminiBin)
76
+ partial.geminiBinary = opts.setGeminiBin;
77
+ if (opts.setClaudeBin)
78
+ partial.claudeBinary = opts.setClaudeBin;
79
+ if (opts.setModel)
80
+ partial.model = opts.setModel;
81
+ if (opts.setYolo !== undefined)
82
+ partial.yoloMode = opts.setYolo === "true";
83
+ saveConfig(partial);
84
+ console.log(chalk.green("✓ config updated"));
85
+ console.log(chalk.dim(`config file: ${getConfigPath()}`));
86
+ console.log(JSON.stringify(loadConfig(), null, 2));
87
+ }
88
+ else if (process.stdin.isTTY) {
89
+ // Interactive mode: pick engine → pick model
90
+ const config = loadConfig();
91
+ console.log(chalk.dim(`config file: ${getConfigPath()}`));
92
+ console.log(chalk.dim(`current: engine=${config.engine}, model=${config.model}\n`));
93
+ const ask = (question) => {
94
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
95
+ return new Promise(resolve => {
96
+ rl.question(question, (answer) => { rl.close(); resolve(answer.trim()); });
97
+ });
98
+ };
99
+ // Pick engine
100
+ console.log(chalk.bold("Select engine:"));
101
+ ENGINES.forEach((e, i) => {
102
+ const marker = e === config.engine ? chalk.green(" ◀ current") : "";
103
+ console.log(chalk.dim(` ${i + 1}. ${e}${marker}`));
104
+ });
105
+ const engineAnswer = await ask(chalk.cyan(` select (1-${ENGINES.length}): `));
106
+ const engineIdx = parseInt(engineAnswer, 10) - 1;
107
+ if (isNaN(engineIdx) || engineIdx < 0 || engineIdx >= ENGINES.length) {
108
+ console.log(chalk.yellow("cancelled"));
109
+ return;
110
+ }
111
+ const engine = ENGINES[engineIdx];
112
+ // Pick model
113
+ const models = ENGINE_MODELS[engine];
114
+ console.log(chalk.bold(`\nSelect model for ${engine}:`));
115
+ models.forEach((m, i) => {
116
+ const marker = m === config.model ? chalk.green(" ◀ current") : "";
117
+ console.log(chalk.dim(` ${i + 1}. ${m}${marker}`));
118
+ });
119
+ const modelAnswer = await ask(chalk.cyan(` select (1-${models.length}): `));
120
+ const modelIdx = parseInt(modelAnswer, 10) - 1;
121
+ if (isNaN(modelIdx) || modelIdx < 0 || modelIdx >= models.length) {
122
+ console.log(chalk.yellow("cancelled"));
123
+ return;
124
+ }
125
+ const model = models[modelIdx];
126
+ saveConfig({ engine, model });
127
+ console.log(chalk.green(`\n✓ config updated → engine: ${engine}, model: ${model}`));
128
+ }
129
+ else {
130
+ console.log(chalk.dim(`config file: ${getConfigPath()}`));
131
+ console.log(JSON.stringify(loadConfig(), null, 2));
132
+ }
133
+ });
134
+ program
135
+ .command("sessions")
136
+ .description("List saved sessions")
137
+ .option("--clear", "Clear all saved sessions")
138
+ .action((opts) => {
139
+ if (opts.clear) {
140
+ clearSessions();
141
+ console.log(chalk.green("✓ sessions cleared"));
142
+ return;
143
+ }
144
+ const sessions = listSessions();
145
+ if (sessions.length === 0) {
146
+ console.log(chalk.dim("no saved sessions"));
147
+ return;
148
+ }
149
+ console.log(chalk.dim(`saved sessions (${sessions.length}):`));
150
+ for (const s of sessions) {
151
+ console.log(chalk.dim(` ${s.id.slice(0, 12)}... | ${s.projectRoot || "unknown"} | ${s.startedAt}`));
152
+ }
153
+ });
154
+ program
155
+ .command("where-config")
156
+ .description("Show path to mia-code config file")
157
+ .action(() => {
158
+ console.log(getConfigPath());
159
+ });
160
+ program
161
+ .command("mcp-config")
162
+ .description("Generate MCP configuration for external engines")
163
+ .option("--miatel", "Include miatel (Story World) server")
164
+ .option("--miawa", "Include miawa (Ceremony World) server")
165
+ .option("--miaco", "Include miaco (Engineering World) server")
166
+ .option("--tools", "Output tool manifest instead of config")
167
+ .option("--info", "Output detailed server info")
168
+ .action((opts) => {
169
+ // If no specific server selected, enable all
170
+ const enableAll = !opts.miatel && !opts.miawa && !opts.miaco;
171
+ const options = {
172
+ enableMiatel: enableAll || opts.miatel,
173
+ enableMiawa: enableAll || opts.miawa,
174
+ enableMiaco: enableAll || opts.miaco
175
+ };
176
+ if (opts.tools) {
177
+ console.log(JSON.stringify(generateToolManifest(options), null, 2));
178
+ }
179
+ else if (opts.info) {
180
+ console.log(JSON.stringify(generateServerInfo(options), null, 2));
181
+ }
182
+ else {
183
+ console.log(JSON.stringify(generateClaudeConfig(options), null, 2));
184
+ }
185
+ });
186
+ program.parseAsync(process.argv);
@@ -0,0 +1,23 @@
1
+ /**
2
+ * MCP Config Generator
3
+ *
4
+ * Generates MCP configuration JSON for external engines (Claude Code, etc.)
5
+ */
6
+ export interface MCPConfigOptions {
7
+ enableMiatel?: boolean;
8
+ enableMiawa?: boolean;
9
+ enableMiaco?: boolean;
10
+ outputFormat?: "claude" | "generic";
11
+ }
12
+ /**
13
+ * Generate MCP configuration for Claude Desktop / Claude Code
14
+ */
15
+ export declare function generateClaudeConfig(options?: MCPConfigOptions): object;
16
+ /**
17
+ * Generate tool manifest for all enabled servers
18
+ */
19
+ export declare function generateToolManifest(options?: MCPConfigOptions): object[];
20
+ /**
21
+ * Generate full MCP server info
22
+ */
23
+ export declare function generateServerInfo(options?: MCPConfigOptions): object;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * MCP Config Generator
3
+ *
4
+ * Generates MCP configuration JSON for external engines (Claude Code, etc.)
5
+ */
6
+ import { dirname, resolve } from "path";
7
+ import { fileURLToPath } from "url";
8
+ import { miacoServerConfig, miacoTools } from "./miaco-server.js";
9
+ import { miatelServerConfig, miatelTools } from "./miatel-server.js";
10
+ import { miawaServerConfig, miawaTools } from "./miawa-server.js";
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ /**
13
+ * Generate MCP configuration for Claude Desktop / Claude Code
14
+ */
15
+ export function generateClaudeConfig(options = {}) {
16
+ const servers = {};
17
+ const basePath = resolve(__dirname, "..");
18
+ if (options.enableMiatel !== false) {
19
+ servers["miatel"] = {
20
+ command: "node",
21
+ args: [resolve(basePath, "mcp/miatel-server.js")],
22
+ env: {}
23
+ };
24
+ }
25
+ if (options.enableMiawa !== false) {
26
+ servers["miawa"] = {
27
+ command: "node",
28
+ args: [resolve(basePath, "mcp/miawa-server.js")],
29
+ env: {}
30
+ };
31
+ }
32
+ if (options.enableMiaco !== false) {
33
+ servers["miaco"] = {
34
+ command: "node",
35
+ args: [resolve(basePath, "mcp/miaco-server.js")],
36
+ env: {}
37
+ };
38
+ }
39
+ return {
40
+ mcpServers: servers
41
+ };
42
+ }
43
+ /**
44
+ * Generate tool manifest for all enabled servers
45
+ */
46
+ export function generateToolManifest(options = {}) {
47
+ const tools = [];
48
+ if (options.enableMiatel !== false) {
49
+ tools.push(...miatelTools.map(t => ({
50
+ ...t,
51
+ server: "miatel"
52
+ })));
53
+ }
54
+ if (options.enableMiawa !== false) {
55
+ tools.push(...miawaTools.map(t => ({
56
+ ...t,
57
+ server: "miawa"
58
+ })));
59
+ }
60
+ if (options.enableMiaco !== false) {
61
+ tools.push(...miacoTools.map(t => ({
62
+ ...t,
63
+ server: "miaco"
64
+ })));
65
+ }
66
+ return tools;
67
+ }
68
+ /**
69
+ * Generate full MCP server info
70
+ */
71
+ export function generateServerInfo(options = {}) {
72
+ const servers = [];
73
+ if (options.enableMiatel !== false) {
74
+ servers.push({
75
+ ...miatelServerConfig,
76
+ tools: miatelTools
77
+ });
78
+ }
79
+ if (options.enableMiawa !== false) {
80
+ servers.push({
81
+ ...miawaServerConfig,
82
+ tools: miawaTools
83
+ });
84
+ }
85
+ if (options.enableMiaco !== false) {
86
+ servers.push({
87
+ ...miacoServerConfig,
88
+ tools: miacoTools
89
+ });
90
+ }
91
+ return {
92
+ servers,
93
+ totalTools: servers.reduce((acc, s) => acc + s.tools.length, 0)
94
+ };
95
+ }
96
+ // CLI usage: node config-generator.js [--miatel] [--miawa] [--miaco] [--format claude|generic]
97
+ if (process.argv[1]?.endsWith("config-generator.js")) {
98
+ const args = process.argv.slice(2);
99
+ const options = {
100
+ enableMiatel: args.includes("--miatel") || !args.some(a => a.startsWith("--mia")),
101
+ enableMiawa: args.includes("--miawa") || !args.some(a => a.startsWith("--mia")),
102
+ enableMiaco: args.includes("--miaco") || !args.some(a => a.startsWith("--mia")),
103
+ outputFormat: args.includes("--format")
104
+ ? args[args.indexOf("--format") + 1]
105
+ : "claude"
106
+ };
107
+ if (args.includes("--tools")) {
108
+ console.log(JSON.stringify(generateToolManifest(options), null, 2));
109
+ }
110
+ else if (args.includes("--info")) {
111
+ console.log(JSON.stringify(generateServerInfo(options), null, 2));
112
+ }
113
+ else {
114
+ console.log(JSON.stringify(generateClaudeConfig(options), null, 2));
115
+ }
116
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * MCP Server Registry for mia-code
3
+ *
4
+ * Exports all MCP servers and utilities
5
+ */
6
+ export { miacoTools, handleMiacoTool, miacoServerConfig } from "./miaco-server.js";
7
+ export { miatelTools, handleMiatelTool, miatelServerConfig } from "./miatel-server.js";
8
+ export { miawaTools, handleMiawaTool, miawaServerConfig } from "./miawa-server.js";
9
+ export { generateClaudeConfig, generateToolManifest, generateServerInfo } from "./config-generator.js";
10
+ export type { MCPTool, MCPToolResult } from "./utils.js";
11
+ /**
12
+ * All available MCP tools across all servers
13
+ */
14
+ export declare function getAllTools(): any[];
15
+ /**
16
+ * Handle a tool call by routing to the appropriate server
17
+ */
18
+ export declare function handleTool(name: string, args: Record<string, any>): Promise<import("./utils.js").MCPToolResult>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * MCP Server Registry for mia-code
3
+ *
4
+ * Exports all MCP servers and utilities
5
+ */
6
+ export { miacoTools, handleMiacoTool, miacoServerConfig } from "./miaco-server.js";
7
+ export { miatelTools, handleMiatelTool, miatelServerConfig } from "./miatel-server.js";
8
+ export { miawaTools, handleMiawaTool, miawaServerConfig } from "./miawa-server.js";
9
+ export { generateClaudeConfig, generateToolManifest, generateServerInfo } from "./config-generator.js";
10
+ /**
11
+ * All available MCP tools across all servers
12
+ */
13
+ export function getAllTools() {
14
+ const { miacoTools } = require("./miaco-server.js");
15
+ const { miatelTools } = require("./miatel-server.js");
16
+ const { miawaTools } = require("./miawa-server.js");
17
+ return [
18
+ ...miacoTools.map((t) => ({ ...t, server: "miaco" })),
19
+ ...miatelTools.map((t) => ({ ...t, server: "miatel" })),
20
+ ...miawaTools.map((t) => ({ ...t, server: "miawa" }))
21
+ ];
22
+ }
23
+ /**
24
+ * Handle a tool call by routing to the appropriate server
25
+ */
26
+ export async function handleTool(name, args) {
27
+ if (name.startsWith("miaco_")) {
28
+ const { handleMiacoTool } = await import("./miaco-server.js");
29
+ return handleMiacoTool(name, args);
30
+ }
31
+ if (name.startsWith("miatel_")) {
32
+ const { handleMiatelTool } = await import("./miatel-server.js");
33
+ return handleMiatelTool(name, args);
34
+ }
35
+ if (name.startsWith("miawa_")) {
36
+ const { handleMiawaTool } = await import("./miawa-server.js");
37
+ return handleMiawaTool(name, args);
38
+ }
39
+ return {
40
+ content: [{ type: "text", text: JSON.stringify({ error: `Unknown tool: ${name}` }) }],
41
+ isError: true
42
+ };
43
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MCP Server for miaco - Engineering World CLI
3
+ *
4
+ * Exposes chart/schema/validate tools as MCP tools
5
+ */
6
+ import { MCPTool, MCPToolResult } from "./utils.js";
7
+ export declare const miacoTools: MCPTool[];
8
+ export declare function handleMiacoTool(name: string, args: Record<string, any>): Promise<MCPToolResult>;
9
+ export declare const miacoServerConfig: {
10
+ name: string;
11
+ version: string;
12
+ description: string;
13
+ tools: MCPTool[];
14
+ handleTool: typeof handleMiacoTool;
15
+ };
@@ -0,0 +1,161 @@
1
+ /**
2
+ * MCP Server for miaco - Engineering World CLI
3
+ *
4
+ * Exposes chart/schema/validate 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, "../../miaco/dist/index.js");
11
+ export const miacoTools = [
12
+ {
13
+ name: "miaco_chart_create",
14
+ description: "Create a structural tension chart with desired outcome and current reality",
15
+ inputSchema: {
16
+ type: "object",
17
+ properties: {
18
+ outcome: { type: "string", description: "Desired outcome (what you want to CREATE, not fix)" },
19
+ reality: { type: "string", description: "Current reality (factual assessment, not readiness)" },
20
+ due: { type: "string", description: "Due date (ISO format)" },
21
+ session: { type: "string", description: "Session ID" }
22
+ },
23
+ required: ["outcome", "reality"]
24
+ }
25
+ },
26
+ {
27
+ name: "miaco_chart_list",
28
+ description: "List active structural tension charts",
29
+ inputSchema: {
30
+ type: "object",
31
+ properties: {
32
+ session: { type: "string", description: "Session ID" }
33
+ }
34
+ }
35
+ },
36
+ {
37
+ name: "miaco_chart_add_step",
38
+ description: "Add an action step to an existing chart",
39
+ inputSchema: {
40
+ type: "object",
41
+ properties: {
42
+ chart: { type: "string", description: "Chart ID" },
43
+ title: { type: "string", description: "Action step title" },
44
+ reality: { type: "string", description: "Current reality for this step" },
45
+ session: { type: "string", description: "Session ID" }
46
+ },
47
+ required: ["chart", "title", "reality"]
48
+ }
49
+ },
50
+ {
51
+ name: "miaco_chart_complete",
52
+ description: "Mark an action step as complete",
53
+ inputSchema: {
54
+ type: "object",
55
+ properties: {
56
+ step: { type: "string", description: "Action step name or ID" },
57
+ session: { type: "string", description: "Session ID" }
58
+ },
59
+ required: ["step"]
60
+ }
61
+ },
62
+ {
63
+ name: "miaco_chart_review",
64
+ description: "Review chart progress using Creator Moment of Truth",
65
+ inputSchema: {
66
+ type: "object",
67
+ properties: {
68
+ chart: { type: "string", description: "Chart ID to review" },
69
+ session: { type: "string", description: "Session ID" }
70
+ },
71
+ required: ["chart"]
72
+ }
73
+ },
74
+ // PDE — Multi-engine Prompt Decomposition
75
+ {
76
+ name: "miaco_decompose",
77
+ description: "Decompose a prompt into structured Four Directions analysis using any engine (gemini, claude, copilot)",
78
+ inputSchema: {
79
+ type: "object",
80
+ properties: {
81
+ prompt: { type: "string", description: "The prompt to decompose" },
82
+ engine: { type: "string", description: "Engine: gemini | claude | copilot", enum: ["gemini", "claude", "copilot"] },
83
+ model: { type: "string", description: "Model override (e.g. gpt-5-mini, sonnet, gemini-2.5-flash)" },
84
+ workdir: { type: "string", description: "Working directory for .pde/ storage (default: cwd)" }
85
+ },
86
+ required: ["prompt"]
87
+ }
88
+ },
89
+ {
90
+ name: "miaco_decompose_list",
91
+ description: "List stored decompositions from .pde/ folder",
92
+ inputSchema: {
93
+ type: "object",
94
+ properties: {
95
+ workdir: { type: "string", description: "Working directory" },
96
+ limit: { type: "string", description: "Max results (default: 10)" }
97
+ }
98
+ }
99
+ },
100
+ {
101
+ name: "miaco_decompose_get",
102
+ description: "Retrieve a stored decomposition by ID",
103
+ inputSchema: {
104
+ type: "object",
105
+ properties: {
106
+ id: { type: "string", description: "Decomposition UUID" },
107
+ workdir: { type: "string", description: "Working directory" }
108
+ },
109
+ required: ["id"]
110
+ }
111
+ }
112
+ ];
113
+ export async function handleMiacoTool(name, args) {
114
+ try {
115
+ let cliArgs;
116
+ switch (name) {
117
+ case "miaco_chart_create":
118
+ cliArgs = buildArgs(["chart", "create"], args, { outcome: "--outcome", reality: "--reality", due: "--due" });
119
+ break;
120
+ case "miaco_chart_list":
121
+ cliArgs = buildArgs(["chart", "list"], args, {});
122
+ break;
123
+ case "miaco_chart_add_step":
124
+ cliArgs = buildArgs(["chart", "add-step"], args, { chart: "--chart", title: "--title", reality: "--reality" });
125
+ break;
126
+ case "miaco_chart_complete":
127
+ cliArgs = buildArgs(["chart", "complete"], args, { step: "--step" });
128
+ break;
129
+ case "miaco_chart_review":
130
+ cliArgs = buildArgs(["chart", "review"], args, { chart: "--chart" });
131
+ break;
132
+ // PDE tools — use CLI with --json flag
133
+ case "miaco_decompose":
134
+ cliArgs = buildArgs(["decompose", "run"], args, { prompt: "--prompt", engine: "--engine", model: "--model", workdir: "--workdir" });
135
+ break;
136
+ case "miaco_decompose_list":
137
+ cliArgs = buildArgs(["decompose", "list"], args, { workdir: "--workdir", limit: "--limit" });
138
+ break;
139
+ case "miaco_decompose_get":
140
+ cliArgs = ["decompose", "get", args.id || ""];
141
+ if (args.workdir)
142
+ cliArgs.push("--workdir", args.workdir);
143
+ break;
144
+ default:
145
+ return createToolResult({ error: `Unknown tool: ${name}` }, true);
146
+ }
147
+ const output = await runCLI(CLI_PATH, cliArgs);
148
+ const result = parseJSONOutput(output);
149
+ return createToolResult(result);
150
+ }
151
+ catch (err) {
152
+ return createToolResult({ error: err.message }, true);
153
+ }
154
+ }
155
+ export const miacoServerConfig = {
156
+ name: "miaco",
157
+ version: "0.1.0",
158
+ description: "Engineering World MCP Server - Structural tension charts, schemas, validation",
159
+ tools: miacoTools,
160
+ handleTool: handleMiacoTool
161
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MCP Server for miatel - Story World CLI
3
+ *
4
+ * Exposes beat/arc/theme tools as MCP tools
5
+ */
6
+ import { MCPTool, MCPToolResult } from "./utils.js";
7
+ export declare const miatelTools: MCPTool[];
8
+ export declare function handleMiatelTool(name: string, args: Record<string, any>): Promise<MCPToolResult>;
9
+ export declare const miatelServerConfig: {
10
+ name: string;
11
+ version: string;
12
+ description: string;
13
+ tools: MCPTool[];
14
+ handleTool: typeof handleMiatelTool;
15
+ };