coaiajs 0.1.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 (162) hide show
  1. package/CLAUDE.md +56 -0
  2. package/KINSHIP.md +63 -0
  3. package/README.md +148 -0
  4. package/articles/academic/creative-orientation-vs-problem-solving.md +177 -0
  5. package/articles/academic/jsonl-knowledge-graphs-agent-memory.md +142 -0
  6. package/articles/academic/langfuse-observability-llm-pipelines.md +144 -0
  7. package/articles/academic/medicine-wheel-software-architecture.md +163 -0
  8. package/articles/academic/mmot-autonomous-agents.md +156 -0
  9. package/articles/academic/model-context-protocol-interagent.md +161 -0
  10. package/articles/academic/pde-prompt-decomposition.md +186 -0
  11. package/articles/academic/structural-tension-in-ai-agents.md +134 -0
  12. package/articles/reviews/mcp-protocol-design-review.md +170 -0
  13. package/articles/reviews/observability-ai-systems-review.md +176 -0
  14. package/articles/reviews/prompt-engineering-decomposition-review.md +184 -0
  15. package/articles/surveys/agent-orchestration-survey.md +186 -0
  16. package/articles/surveys/knowledge-graph-storage-survey.md +204 -0
  17. package/articles/surveys/structural-tension-methodology-survey.md +154 -0
  18. package/articles/technical/aws-sdk-v3-polly.md +270 -0
  19. package/articles/technical/commander-cli-framework.md +262 -0
  20. package/articles/technical/dotenv-config-patterns.md +360 -0
  21. package/articles/technical/ioredis-vs-redis.md +142 -0
  22. package/articles/technical/langfuse-js-sdk-vs-rest.md +191 -0
  23. package/articles/technical/mcp-sdk-typescript.md +291 -0
  24. package/articles/technical/octokit-github-api.md +293 -0
  25. package/articles/technical/openai-sdk-modern.md +231 -0
  26. package/articles/technical/yaml-parsing-node.md +266 -0
  27. package/articles/technical/zod-runtime-validation.md +212 -0
  28. package/dist/mcp/config.d.ts +14 -0
  29. package/dist/mcp/config.js +185 -0
  30. package/dist/mcp/server.d.ts +3 -0
  31. package/dist/mcp/server.js +324 -0
  32. package/dist/mcp/tools/coaiapy-tools.d.ts +8 -0
  33. package/dist/mcp/tools/coaiapy-tools.js +326 -0
  34. package/dist/mcp/tools/index.d.ts +3 -0
  35. package/dist/mcp/tools/index.js +3 -0
  36. package/dist/src/audio.d.ts +12 -0
  37. package/dist/src/audio.js +57 -0
  38. package/dist/src/cli-helpers.d.ts +9 -0
  39. package/dist/src/cli-helpers.js +78 -0
  40. package/dist/src/cli.d.ts +3 -0
  41. package/dist/src/cli.js +1086 -0
  42. package/dist/src/config.d.ts +15 -0
  43. package/dist/src/config.js +145 -0
  44. package/dist/src/environment.d.ts +44 -0
  45. package/dist/src/environment.js +146 -0
  46. package/dist/src/github.d.ts +47 -0
  47. package/dist/src/github.js +79 -0
  48. package/dist/src/langfuse/client.d.ts +30 -0
  49. package/dist/src/langfuse/client.js +75 -0
  50. package/dist/src/langfuse/comments.d.ts +16 -0
  51. package/dist/src/langfuse/comments.js +36 -0
  52. package/dist/src/langfuse/datasets.d.ts +19 -0
  53. package/dist/src/langfuse/datasets.js +140 -0
  54. package/dist/src/langfuse/index.d.ts +13 -0
  55. package/dist/src/langfuse/index.js +10 -0
  56. package/dist/src/langfuse/media.d.ts +11 -0
  57. package/dist/src/langfuse/media.js +167 -0
  58. package/dist/src/langfuse/observations.d.ts +18 -0
  59. package/dist/src/langfuse/observations.js +113 -0
  60. package/dist/src/langfuse/prompts.d.ts +14 -0
  61. package/dist/src/langfuse/prompts.js +127 -0
  62. package/dist/src/langfuse/scores.d.ts +54 -0
  63. package/dist/src/langfuse/scores.js +366 -0
  64. package/dist/src/langfuse/traces.d.ts +29 -0
  65. package/dist/src/langfuse/traces.js +225 -0
  66. package/dist/src/llm.d.ts +23 -0
  67. package/dist/src/llm.js +76 -0
  68. package/dist/src/narrative/graph-manager.d.ts +106 -0
  69. package/dist/src/narrative/graph-manager.js +915 -0
  70. package/dist/src/narrative/index.d.ts +9 -0
  71. package/dist/src/narrative/index.js +7 -0
  72. package/dist/src/narrative/markdown-export.d.ts +21 -0
  73. package/dist/src/narrative/markdown-export.js +383 -0
  74. package/dist/src/narrative/tool-definitions.d.ts +21 -0
  75. package/dist/src/narrative/tool-definitions.js +588 -0
  76. package/dist/src/narrative/tool-handlers.d.ts +11 -0
  77. package/dist/src/narrative/tool-handlers.js +462 -0
  78. package/dist/src/narrative/types.d.ts +2 -0
  79. package/dist/src/narrative/types.js +2 -0
  80. package/dist/src/narrative/validation.d.ts +29 -0
  81. package/dist/src/narrative/validation.js +144 -0
  82. package/dist/src/pde/index.d.ts +8 -0
  83. package/dist/src/pde/index.js +8 -0
  84. package/dist/src/pde/mcp-handlers.d.ts +7 -0
  85. package/dist/src/pde/mcp-handlers.js +300 -0
  86. package/dist/src/pde/mcp-tools.d.ts +15 -0
  87. package/dist/src/pde/mcp-tools.js +191 -0
  88. package/dist/src/pde/session-manager.d.ts +32 -0
  89. package/dist/src/pde/session-manager.js +205 -0
  90. package/dist/src/pde/stc-mapper.d.ts +26 -0
  91. package/dist/src/pde/stc-mapper.js +234 -0
  92. package/dist/src/pipeline/index.d.ts +2 -0
  93. package/dist/src/pipeline/index.js +3 -0
  94. package/dist/src/pipeline/template-engine.d.ts +20 -0
  95. package/dist/src/pipeline/template-engine.js +361 -0
  96. package/dist/src/planning/index.d.ts +7 -0
  97. package/dist/src/planning/index.js +7 -0
  98. package/dist/src/planning/mcp-handlers.d.ts +7 -0
  99. package/dist/src/planning/mcp-handlers.js +310 -0
  100. package/dist/src/planning/mcp-tools.d.ts +15 -0
  101. package/dist/src/planning/mcp-tools.js +145 -0
  102. package/dist/src/planning/plan-parser.d.ts +35 -0
  103. package/dist/src/planning/plan-parser.js +506 -0
  104. package/dist/src/redis.d.ts +21 -0
  105. package/dist/src/redis.js +78 -0
  106. package/dist/src/types.d.ts +244 -0
  107. package/dist/src/types.js +8 -0
  108. package/mcp/config.ts +196 -0
  109. package/mcp/server.ts +402 -0
  110. package/mcp/tools/coaiapy-tools.ts +364 -0
  111. package/mcp/tools/index.ts +4 -0
  112. package/package.json +52 -0
  113. package/rispecs/00-coaiajs-platform.spec.md +102 -0
  114. package/rispecs/01-core-config.spec.md +89 -0
  115. package/rispecs/02-redis-module.spec.md +62 -0
  116. package/rispecs/03-langfuse-module.spec.md +101 -0
  117. package/rispecs/04-narrative-engine.spec.md +185 -0
  118. package/rispecs/05-pde-engine.spec.md +112 -0
  119. package/rispecs/06-planning-engine.spec.md +128 -0
  120. package/rispecs/07-pipeline-templates.spec.md +97 -0
  121. package/rispecs/08-cli-interface.spec.md +134 -0
  122. package/rispecs/09-mcp-server.spec.md +140 -0
  123. package/rispecs/10-audio-module.spec.md +63 -0
  124. package/rispecs/KINSHIP.md +56 -0
  125. package/rispecs/README.md +100 -0
  126. package/src/audio.ts +76 -0
  127. package/src/cli-helpers.ts +86 -0
  128. package/src/cli.ts +1223 -0
  129. package/src/config.ts +172 -0
  130. package/src/environment.ts +171 -0
  131. package/src/github.ts +143 -0
  132. package/src/langfuse/client.ts +105 -0
  133. package/src/langfuse/comments.ts +52 -0
  134. package/src/langfuse/datasets.ts +178 -0
  135. package/src/langfuse/index.ts +33 -0
  136. package/src/langfuse/media.ts +193 -0
  137. package/src/langfuse/observations.ts +131 -0
  138. package/src/langfuse/prompts.ts +157 -0
  139. package/src/langfuse/scores.ts +456 -0
  140. package/src/langfuse/traces.ts +276 -0
  141. package/src/llm.ts +106 -0
  142. package/src/narrative/graph-manager.ts +1358 -0
  143. package/src/narrative/index.ts +32 -0
  144. package/src/narrative/markdown-export.ts +535 -0
  145. package/src/narrative/tool-definitions.ts +635 -0
  146. package/src/narrative/tool-handlers.ts +528 -0
  147. package/src/narrative/types.ts +9 -0
  148. package/src/narrative/validation.ts +179 -0
  149. package/src/pde/index.ts +8 -0
  150. package/src/pde/mcp-handlers.ts +359 -0
  151. package/src/pde/mcp-tools.ts +201 -0
  152. package/src/pde/session-manager.ts +248 -0
  153. package/src/pde/stc-mapper.ts +298 -0
  154. package/src/pipeline/index.ts +7 -0
  155. package/src/pipeline/template-engine.ts +398 -0
  156. package/src/planning/index.ts +13 -0
  157. package/src/planning/mcp-handlers.ts +369 -0
  158. package/src/planning/mcp-tools.ts +155 -0
  159. package/src/planning/plan-parser.ts +587 -0
  160. package/src/redis.ts +97 -0
  161. package/src/types.ts +280 -0
  162. package/tsconfig.json +26 -0
@@ -0,0 +1,310 @@
1
+ /**
2
+ * Planning MCP tool dispatch — handles each tool by calling plan-parser functions
3
+ * Ported from coaia-planning/src/index.ts handler logic
4
+ */
5
+ import { promises as fs, readFileSync, existsSync } from 'fs';
6
+ import path from 'path';
7
+ import { parsePlan, parsePlanContent, planToSTC, exportToJSONL, decompositionResultToPlan, } from './plan-parser.js';
8
+ // Cache for parsed plans
9
+ const planCache = new Map();
10
+ function getCachedOrParse(planPath) {
11
+ if (planCache.has(planPath)) {
12
+ return Promise.resolve(planCache.get(planPath));
13
+ }
14
+ return parsePlan(planPath).then(parsed => {
15
+ planCache.set(planPath, parsed);
16
+ return parsed;
17
+ });
18
+ }
19
+ function loadExistingCharts(chartsPath) {
20
+ try {
21
+ if (!existsSync(chartsPath))
22
+ return [];
23
+ const content = readFileSync(chartsPath, 'utf-8');
24
+ return content
25
+ .split('\n')
26
+ .filter((line) => line.trim())
27
+ .map((line) => JSON.parse(line));
28
+ }
29
+ catch {
30
+ return [];
31
+ }
32
+ }
33
+ function detectPlanChanges(parsed, existingCharts) {
34
+ const changes = [];
35
+ const existingActions = existingCharts
36
+ .filter(c => c.entityType === 'action_step')
37
+ .map(c => c.observations[0]);
38
+ for (const step of parsed.actionSteps) {
39
+ if (!existingActions.includes(step.content)) {
40
+ changes.push({
41
+ type: 'new_action',
42
+ description: step.content,
43
+ details: `New action step detected: ${step.content}`,
44
+ });
45
+ }
46
+ }
47
+ return changes;
48
+ }
49
+ function chartsToPlan(charts) {
50
+ let md = '';
51
+ const chartEntity = charts.find(c => c.entityType === 'structural_tension_chart');
52
+ if (chartEntity) {
53
+ const title = chartEntity.name.replace(/_chart$/, '').replace(/_/g, ' ');
54
+ md += `# ${title}\n\n`;
55
+ }
56
+ const desiredOutcome = charts.find(c => c.entityType === 'desired_outcome');
57
+ if (desiredOutcome) {
58
+ md += `## Desired Outcome\n\n${desiredOutcome.observations[0]}\n\n`;
59
+ }
60
+ const currentReality = charts.find(c => c.entityType === 'current_reality');
61
+ if (currentReality) {
62
+ md += `## Current Reality\n\n${currentReality.observations[0]}\n\n`;
63
+ }
64
+ const actionSteps = charts
65
+ .filter(c => c.entityType === 'action_step')
66
+ .sort((a, b) => (a.metadata?.order || 0) - (b.metadata?.order || 0));
67
+ if (actionSteps.length > 0) {
68
+ md += `## Action Steps\n\n`;
69
+ for (const step of actionSteps) {
70
+ const completed = step.metadata?.completionStatus ? '[x]' : '[ ]';
71
+ md += `- ${completed} ${step.observations[0]}\n`;
72
+ }
73
+ }
74
+ return md;
75
+ }
76
+ export async function handlePlanningTool(name, args) {
77
+ try {
78
+ switch (name) {
79
+ case 'parse_plan_structural': {
80
+ let parsed;
81
+ if (args.planPath) {
82
+ const planPath = args.planPath;
83
+ parsed = await parsePlan(planPath);
84
+ planCache.set(planPath, parsed);
85
+ }
86
+ else if (args.planContent) {
87
+ parsed = parsePlanContent(args.planContent);
88
+ }
89
+ else {
90
+ throw new Error('Either planPath or planContent must be provided');
91
+ }
92
+ return {
93
+ content: [{
94
+ type: 'text',
95
+ text: JSON.stringify({
96
+ success: true,
97
+ structuralAnalysis: {
98
+ title: parsed.title,
99
+ filePath: parsed.filePath,
100
+ desiredOutcome: parsed.desiredOutcome ? {
101
+ content: parsed.desiredOutcome.content,
102
+ confidence: parsed.desiredOutcome.confidence,
103
+ } : null,
104
+ currentReality: parsed.currentReality ? {
105
+ content: parsed.currentReality.content,
106
+ confidence: parsed.currentReality.confidence,
107
+ } : null,
108
+ actionSteps: parsed.actionSteps.map(s => ({
109
+ content: s.content,
110
+ confidence: s.confidence,
111
+ canTelescope: !!s.telescopesInto,
112
+ })),
113
+ observations: parsed.observations,
114
+ },
115
+ }, null, 2),
116
+ }],
117
+ };
118
+ }
119
+ case 'plan_to_stc': {
120
+ const planPath = args.planPath;
121
+ const outputPath = args.outputPath ||
122
+ path.join(process.cwd(), `${path.basename(planPath, '.md')}.stc.jsonl`);
123
+ const parsed = await getCachedOrParse(planPath);
124
+ // Override current reality if provided
125
+ if (args.currentReality && parsed.currentReality) {
126
+ parsed.currentReality.content = args.currentReality;
127
+ }
128
+ else if (args.currentReality) {
129
+ parsed.currentReality = {
130
+ type: 'current_reality',
131
+ content: args.currentReality,
132
+ confidence: 1.0,
133
+ sourceLines: { start: 0, end: 0 },
134
+ };
135
+ }
136
+ const stc = planToSTC(parsed);
137
+ const jsonl = exportToJSONL(stc);
138
+ await fs.writeFile(outputPath, jsonl + '\n');
139
+ return {
140
+ content: [{
141
+ type: 'text',
142
+ text: JSON.stringify({
143
+ success: true,
144
+ chartCreated: {
145
+ title: parsed.title,
146
+ entitiesCount: stc.entities.length,
147
+ relationsCount: stc.relations.length,
148
+ outputPath,
149
+ hasDesiredOutcome: !!parsed.desiredOutcome,
150
+ hasCurrentReality: !!parsed.currentReality,
151
+ actionStepsCount: parsed.actionSteps.length,
152
+ telescopedCount: parsed.actionSteps.filter(s => s.telescopesInto).length,
153
+ },
154
+ }, null, 2),
155
+ }],
156
+ };
157
+ }
158
+ case 'sync_plan_to_chart': {
159
+ const planPath = args.planPath;
160
+ const chartsPath = args.chartsPath;
161
+ const dryRun = args.dryRun || false;
162
+ const parsed = await getCachedOrParse(planPath);
163
+ const existingCharts = loadExistingCharts(chartsPath);
164
+ const changes = detectPlanChanges(parsed, existingCharts);
165
+ if (dryRun) {
166
+ return {
167
+ content: [{
168
+ type: 'text',
169
+ text: JSON.stringify({ dryRun: true, changes }, null, 2),
170
+ }],
171
+ };
172
+ }
173
+ // Apply changes: regenerate STC and write
174
+ const stc = planToSTC(parsed);
175
+ const jsonl = exportToJSONL(stc);
176
+ await fs.writeFile(chartsPath, jsonl + '\n');
177
+ return {
178
+ content: [{
179
+ type: 'text',
180
+ text: JSON.stringify({ success: true, changesApplied: changes }, null, 2),
181
+ }],
182
+ };
183
+ }
184
+ case 'sync_chart_to_plan': {
185
+ const chartsPath = args.chartsPath;
186
+ const planPath = args.planPath;
187
+ const dryRun = args.dryRun || false;
188
+ const charts = loadExistingCharts(chartsPath);
189
+ const planContent = chartsToPlan(charts);
190
+ if (dryRun) {
191
+ return {
192
+ content: [{
193
+ type: 'text',
194
+ text: JSON.stringify({ dryRun: true, proposedPlanContent: planContent }, null, 2),
195
+ }],
196
+ };
197
+ }
198
+ await fs.writeFile(planPath, planContent);
199
+ return {
200
+ content: [{
201
+ type: 'text',
202
+ text: JSON.stringify({ success: true, planUpdated: planPath }, null, 2),
203
+ }],
204
+ };
205
+ }
206
+ case 'create_plan_trace': {
207
+ const planPath = args.planPath;
208
+ const chartsPath = args.chartsPath;
209
+ const sessionId = args.sessionId;
210
+ const metadata = args.metadata || {};
211
+ const parsed = await getCachedOrParse(planPath);
212
+ const charts = loadExistingCharts(chartsPath);
213
+ const traceData = {
214
+ trace_id: `plan-${Date.now()}`,
215
+ name: `📋 Plan→STC: ${parsed.title}`,
216
+ session_id: sessionId,
217
+ input_data: {
218
+ plan_title: parsed.title,
219
+ plan_path: planPath,
220
+ desired_outcome: parsed.desiredOutcome?.content,
221
+ current_reality: parsed.currentReality?.content,
222
+ action_steps: parsed.actionSteps.map(s => s.content),
223
+ },
224
+ output_data: {
225
+ charts_created: charts.length,
226
+ charts_path: chartsPath,
227
+ },
228
+ metadata: {
229
+ ...metadata,
230
+ transformation_timestamp: new Date().toISOString(),
231
+ tool: 'coaia-planning',
232
+ },
233
+ };
234
+ return {
235
+ content: [{
236
+ type: 'text',
237
+ text: JSON.stringify({
238
+ success: true,
239
+ traceData,
240
+ note: 'Use Langfuse MCP to create trace with this data',
241
+ }, null, 2),
242
+ }],
243
+ };
244
+ }
245
+ case 'pde_to_plan': {
246
+ const workdir = args.workdir || process.cwd();
247
+ let decomposition;
248
+ let originalPrompt = args.original_prompt;
249
+ if (args.pde_id) {
250
+ const pdeId = args.pde_id;
251
+ const pdePath = path.join(workdir, '.pde', `${pdeId}.json`);
252
+ let data;
253
+ try {
254
+ data = await fs.readFile(pdePath, 'utf-8');
255
+ }
256
+ catch {
257
+ throw new Error(`PDE decomposition not found: ${pdePath}`);
258
+ }
259
+ const stored = JSON.parse(data);
260
+ decomposition = stored.result;
261
+ originalPrompt = originalPrompt || stored.prompt;
262
+ }
263
+ else if (args.decomposition_result) {
264
+ decomposition = args.decomposition_result;
265
+ }
266
+ else {
267
+ throw new Error('Either pde_id or decomposition_result must be provided');
268
+ }
269
+ const stc = decompositionResultToPlan(decomposition, originalPrompt);
270
+ const jsonl = exportToJSONL(stc);
271
+ if (args.outputPath) {
272
+ const outPath = path.isAbsolute(args.outputPath)
273
+ ? args.outputPath
274
+ : path.resolve(args.outputPath);
275
+ await fs.writeFile(outPath, jsonl + '\n');
276
+ }
277
+ return {
278
+ content: [{
279
+ type: 'text',
280
+ text: JSON.stringify({
281
+ success: true,
282
+ chartCreated: {
283
+ entitiesCount: stc.entities.length,
284
+ relationsCount: stc.relations.length,
285
+ primaryIntent: `${decomposition.primary.action}: ${decomposition.primary.target}`,
286
+ actionStepsCount: decomposition.actionStack.length,
287
+ ambiguitiesCount: decomposition.ambiguities.length,
288
+ outputPath: args.outputPath || null,
289
+ },
290
+ jsonl,
291
+ }, null, 2),
292
+ }],
293
+ };
294
+ }
295
+ default:
296
+ throw new Error(`Unknown planning tool: ${name}`);
297
+ }
298
+ }
299
+ catch (error) {
300
+ const errorMessage = error instanceof Error ? error.message : String(error);
301
+ return {
302
+ content: [{
303
+ type: 'text',
304
+ text: `Error: ${errorMessage}`,
305
+ }],
306
+ isError: true,
307
+ };
308
+ }
309
+ }
310
+ //# sourceMappingURL=mcp-handlers.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MCP tool definitions for Planning module (6 tools)
3
+ * Ported from coaia-planning/src/tools/index.ts
4
+ */
5
+ export interface McpToolDef {
6
+ name: string;
7
+ description: string;
8
+ inputSchema: {
9
+ type: 'object';
10
+ properties: Record<string, unknown>;
11
+ required?: string[];
12
+ };
13
+ }
14
+ export declare const PLANNING_MCP_TOOLS: McpToolDef[];
15
+ //# sourceMappingURL=mcp-tools.d.ts.map
@@ -0,0 +1,145 @@
1
+ /**
2
+ * MCP tool definitions for Planning module (6 tools)
3
+ * Ported from coaia-planning/src/tools/index.ts
4
+ */
5
+ export const PLANNING_MCP_TOOLS = [
6
+ {
7
+ name: 'parse_plan_structural',
8
+ description: 'Parse a Claude plan as structural tension chart. Extracts desired outcome, current reality, and action steps (which telescope into sub-charts). Returns confidence scores.',
9
+ inputSchema: {
10
+ type: 'object',
11
+ properties: {
12
+ planPath: {
13
+ type: 'string',
14
+ description: 'Path to the Claude plan markdown file',
15
+ },
16
+ planContent: {
17
+ type: 'string',
18
+ description: 'Alternative: raw markdown content (if path not provided)',
19
+ },
20
+ },
21
+ },
22
+ },
23
+ {
24
+ name: 'plan_to_stc',
25
+ description: 'Convert plan to structural tension chart (JSONL). Action steps become telescoped STCs with their own desired outcome/current reality.',
26
+ inputSchema: {
27
+ type: 'object',
28
+ properties: {
29
+ planPath: {
30
+ type: 'string',
31
+ description: 'Path to the Claude plan markdown file',
32
+ },
33
+ currentReality: {
34
+ type: 'string',
35
+ description: 'Override: provide current reality if not detected in plan',
36
+ },
37
+ outputPath: {
38
+ type: 'string',
39
+ description: 'Path to write the STC JSONL (default: <planname>.stc.jsonl)',
40
+ },
41
+ },
42
+ required: ['planPath'],
43
+ },
44
+ },
45
+ {
46
+ name: 'sync_plan_to_chart',
47
+ description: 'Plan → Chart sync. When plan changes, update the structural tension chart.',
48
+ inputSchema: {
49
+ type: 'object',
50
+ properties: {
51
+ planPath: {
52
+ type: 'string',
53
+ description: 'Path to the Claude plan markdown file',
54
+ },
55
+ chartsPath: {
56
+ type: 'string',
57
+ description: 'Path to the charts JSONL file',
58
+ },
59
+ dryRun: {
60
+ type: 'boolean',
61
+ description: 'If true, show changes without applying',
62
+ },
63
+ },
64
+ required: ['planPath', 'chartsPath'],
65
+ },
66
+ },
67
+ {
68
+ name: 'sync_chart_to_plan',
69
+ description: 'Chart → Plan sync. When agents modify chart (observations, completions), regenerate plan markdown.',
70
+ inputSchema: {
71
+ type: 'object',
72
+ properties: {
73
+ chartsPath: {
74
+ type: 'string',
75
+ description: 'Path to the charts JSONL file',
76
+ },
77
+ planPath: {
78
+ type: 'string',
79
+ description: 'Path to write the updated plan markdown',
80
+ },
81
+ dryRun: {
82
+ type: 'boolean',
83
+ description: 'If true, show proposed plan without writing',
84
+ },
85
+ },
86
+ required: ['chartsPath', 'planPath'],
87
+ },
88
+ },
89
+ {
90
+ name: 'create_plan_trace',
91
+ description: 'Generate Langfuse trace data for plan→STC transformation.',
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ planPath: {
96
+ type: 'string',
97
+ description: 'Path to the source plan',
98
+ },
99
+ chartsPath: {
100
+ type: 'string',
101
+ description: 'Path to generated charts',
102
+ },
103
+ sessionId: {
104
+ type: 'string',
105
+ description: 'Optional Langfuse session ID',
106
+ },
107
+ metadata: {
108
+ type: 'object',
109
+ description: 'Additional trace metadata',
110
+ },
111
+ },
112
+ required: ['planPath', 'chartsPath'],
113
+ },
114
+ },
115
+ {
116
+ name: 'pde_to_plan',
117
+ description: 'Convert a PDE DecompositionResult to a structural tension chart (JSONL). Takes pre-decomposed PDE output and produces coaia-narrative compatible entities and relations.',
118
+ inputSchema: {
119
+ type: 'object',
120
+ properties: {
121
+ pde_id: {
122
+ type: 'string',
123
+ description: 'ID of a stored PDE decomposition in .pde/ folder',
124
+ },
125
+ decomposition_result: {
126
+ type: 'object',
127
+ description: 'Alternative: provide DecompositionResult JSON directly',
128
+ },
129
+ original_prompt: {
130
+ type: 'string',
131
+ description: 'The original prompt (required if providing decomposition_result)',
132
+ },
133
+ outputPath: {
134
+ type: 'string',
135
+ description: 'Path to write the STC JSONL output',
136
+ },
137
+ workdir: {
138
+ type: 'string',
139
+ description: 'Working directory containing .pde/ folder (default: cwd)',
140
+ },
141
+ },
142
+ },
143
+ },
144
+ ];
145
+ //# sourceMappingURL=mcp-tools.js.map
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Plan Parser — Transforms markdown plans into structural tension charts
3
+ * Ported from coaia-planning/src/plan-parser.ts
4
+ */
5
+ import type { Entity, Relation, StructuralTensionPlan, DecompositionResult } from '../types.js';
6
+ /**
7
+ * Parse a plan file as a structural tension chart
8
+ */
9
+ export declare function parsePlan(planPath: string): Promise<StructuralTensionPlan>;
10
+ /**
11
+ * Parse plan content directly
12
+ */
13
+ export declare function parsePlanContent(content: string, filePath?: string, telescopeLevel?: number): StructuralTensionPlan;
14
+ /**
15
+ * Convert structural tension plan to Entity[]/Relation[] (JSONL-compatible)
16
+ */
17
+ export declare function planToSTC(plan: StructuralTensionPlan, chartIdPrefix?: string): {
18
+ entities: Entity[];
19
+ relations: Relation[];
20
+ };
21
+ /**
22
+ * Export Entity[]/Relation[] to JSONL format
23
+ */
24
+ export declare function exportToJSONL(stc: {
25
+ entities: Entity[];
26
+ relations: Relation[];
27
+ }): string;
28
+ /**
29
+ * PDE bridge: Convert DecompositionResult into Entity[]/Relation[]
30
+ */
31
+ export declare function decompositionResultToPlan(decomposition: DecompositionResult, originalPrompt?: string): {
32
+ entities: Entity[];
33
+ relations: Relation[];
34
+ };
35
+ //# sourceMappingURL=plan-parser.d.ts.map