@medicine-wheel/app 0.23.0 → 0.24.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 (2) hide show
  1. package/dist/cli/mw.js +49 -6
  2. package/package.json +28 -28
package/dist/cli/mw.js CHANGED
@@ -180,22 +180,60 @@ async function checkApi() {
180
180
  }
181
181
  }
182
182
  // ── MCP JSON-RPC ──────────────────────────────────────────────────
183
+ // One MCP session per command, over the server's stdio. The stdio transport
184
+ // reads newline-delimited JSON-RPC messages, and a client opens the session
185
+ // with `initialize` and the `notifications/initialized` notification before
186
+ // any request.
187
+ //
188
+ // Until 0.24.0 this sent a lone request with no handshake and no trailing
189
+ // newline. The server never read a complete message, answered nothing, and
190
+ // every `mw chart` and `mw tools` command printed nothing and exited 0
191
+ // (Miadi Chronicle Episode 297, finding F1).
192
+ const MCP_PROTOCOL_VERSION = '2025-06-18';
193
+ const MCP_REQUEST_ID = 2;
183
194
  function mcpRaw(rpcMethod, params) {
184
195
  if (!MW_MCP_PATH) {
185
196
  console.error('Error: MCP server path not found. Set MW_MCP_PATH or use the HTTP server via MW_API_URL.');
186
197
  process.exit(1);
187
198
  }
188
- const req = JSON.stringify({ jsonrpc: '2.0', method: rpcMethod, params, id: 1 });
199
+ const messages = [
200
+ {
201
+ jsonrpc: '2.0',
202
+ id: 1,
203
+ method: 'initialize',
204
+ params: { protocolVersion: MCP_PROTOCOL_VERSION, capabilities: {}, clientInfo: { name: 'mw', version: '1' } },
205
+ },
206
+ { jsonrpc: '2.0', method: 'notifications/initialized' },
207
+ { jsonrpc: '2.0', id: MCP_REQUEST_ID, method: rpcMethod, params },
208
+ ];
189
209
  const result = (0, child_process_1.spawnSync)('node', [MW_MCP_PATH], {
190
- input: req,
210
+ input: messages.map((m) => JSON.stringify(m) + '\n').join(''),
191
211
  encoding: 'utf8',
192
212
  timeout: 10000,
213
+ maxBuffer: 64 * 1024 * 1024,
193
214
  });
194
215
  if (result.error) {
195
216
  console.error('MCP error:', result.error.message);
217
+ process.exitCode = 1;
196
218
  return '';
197
219
  }
198
- return result.stdout?.trim() ?? '';
220
+ // One JSON line per response; keep the one that answers the request.
221
+ for (const line of (result.stdout ?? '').split('\n')) {
222
+ const text = line.trim();
223
+ if (!text)
224
+ continue;
225
+ try {
226
+ if (JSON.parse(text)?.id === MCP_REQUEST_ID)
227
+ return text;
228
+ }
229
+ catch { /* not a JSON-RPC line */ }
230
+ }
231
+ const stderrTail = (result.stderr ?? '').trim().split('\n').slice(-5).join('\n');
232
+ console.error(`MCP error: no response to ${rpcMethod} from ${MW_MCP_PATH} (exit ${result.status ?? result.signal})`);
233
+ if (stderrTail)
234
+ console.error(stderrTail);
235
+ process.exitCode = 1;
236
+ return '';
199
237
  }
200
238
  function mcpCall(toolName, args) {
201
239
  const raw = mcpRaw('tools/call', { name: toolName, arguments: args });
@@ -284,6 +322,7 @@ ${C.bold}🌿 mw — Medicine Wheel CLI${C.reset}
284
322
  mw chart delay <chart> <step> <resolve_by> <reason> --by <who>
285
323
  [--primary <text>] [--wake-on <cue>] Choose to delay a step's resolution
286
324
  [--session <id> --cwd <dir> --resume <cmd>] ...with the session to rehydrate
325
+ [--trace <miadi-...> --rehydrate-with <miadi-...>] ...its LLMOps trace and rehydrating prompt
287
326
  mw chart delayed [--within <days>] [--all] Delays by resolve_by, owed first
288
327
  mw chart end-delay <chart> <step> <rehydrated|released> --by <who> [--note <text>]
289
328
  mw mmot <chart_id> <expected> <actual> <analysis> MMOT review
@@ -706,11 +745,13 @@ function cmdChart(positional, flags = {}) {
706
745
  case 'delay': {
707
746
  const [, chartId, stepId, resolveBy, reason] = positional;
708
747
  const by = flagText(flags, 'by');
709
- if (!chartId || !stepId || !resolveBy || !reason || !by) {
710
- chartUsage('mw chart delay <chart_id> <step_id> <resolve_by> <reason> --by <who> [--primary <text>] [--wake-on <cue>] [--session <id>] [--cwd <dir>] [--resume <command>]');
748
+ const sessionId = flagText(flags, 'session');
749
+ const trace = flagText(flags, 'trace');
750
+ const rehydrateWith = flagText(flags, 'rehydrate-with');
751
+ if (!chartId || !stepId || !resolveBy || !reason || !by || ((trace || rehydrateWith) && !sessionId)) {
752
+ chartUsage('mw chart delay <chart_id> <step_id> <resolve_by> <reason> --by <who> [--primary <text>] [--wake-on <cue>] [--session <id>] [--cwd <dir>] [--resume <command>] [--host <host>] [--trace <miadi-...>] [--rehydrate-with <miadi-...>] (--trace and --rehydrate-with need --session)');
711
753
  return;
712
754
  }
713
- const sessionId = flagText(flags, 'session');
714
755
  const wakeOn = flagText(flags, 'wake-on');
715
756
  mcpCall('delay_resolution', {
716
757
  chart_id: chartId,
@@ -727,6 +768,8 @@ function cmdChart(positional, flags = {}) {
727
768
  ...(flagText(flags, 'cwd') ? { cwd: flagText(flags, 'cwd') } : {}),
728
769
  ...(flagText(flags, 'resume') ? { resume_command: flagText(flags, 'resume') } : {}),
729
770
  ...(flagText(flags, 'host') ? { host: flagText(flags, 'host') } : {}),
771
+ ...(trace ? { trace } : {}),
772
+ ...(rehydrateWith ? { rehydrate_with: rehydrateWith } : {}),
730
773
  },
731
774
  }
732
775
  : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medicine-wheel/app",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Medicine Wheel — Interactive visual layer for Indigenous relational research with Four Directions, ceremonies, and narrative arcs",
5
5
  "bin": {
6
6
  "mw": "dist/cli/mw.js",
@@ -94,33 +94,33 @@
94
94
  "release:major": "npm run version:major && npm run publish:all && npm run release:commit"
95
95
  },
96
96
  "dependencies": {
97
- "@medicine-wheel/ceremonial-diary": "^0.23.0",
98
- "@medicine-wheel/ceremony-protocol": "^0.23.0",
99
- "@medicine-wheel/community-identity": "^0.23.0",
100
- "@medicine-wheel/community-review": "^0.23.0",
101
- "@medicine-wheel/consent-lifecycle": "^0.23.0",
102
- "@medicine-wheel/creative-orientation": "^0.23.0",
103
- "@medicine-wheel/data-store": "^0.23.0",
104
- "@medicine-wheel/data-store-postgres": "^0.23.0",
105
- "@medicine-wheel/events": "^0.23.0",
106
- "@medicine-wheel/fire-keeper": "^0.23.0",
107
- "@medicine-wheel/github-ceremony": "^0.23.0",
108
- "@medicine-wheel/graph-viz": "^0.23.0",
109
- "@medicine-wheel/honcho": "^0.23.0",
110
- "@medicine-wheel/importance-unit": "^0.23.0",
111
- "@medicine-wheel/mcp": "^4.23.0",
112
- "@medicine-wheel/memory": "^0.23.0",
113
- "@medicine-wheel/narrative-cluster": "^0.23.0",
114
- "@medicine-wheel/narrative-engine": "^0.23.0",
115
- "@medicine-wheel/ontology-core": "^0.23.0",
116
- "@medicine-wheel/perception-layer": "^0.23.0",
117
- "@medicine-wheel/prompt-decomposition": "^0.23.0",
118
- "@medicine-wheel/relational-index": "^0.23.0",
119
- "@medicine-wheel/relational-query": "^0.23.0",
120
- "@medicine-wheel/session-reader": "^0.23.0",
121
- "@medicine-wheel/storage-provider": "^0.23.0",
122
- "@medicine-wheel/transformation-tracker": "^0.23.0",
123
- "@medicine-wheel/ui-components": "^0.23.0",
97
+ "@medicine-wheel/ceremonial-diary": "^0.24.0",
98
+ "@medicine-wheel/ceremony-protocol": "^0.24.0",
99
+ "@medicine-wheel/community-identity": "^0.24.0",
100
+ "@medicine-wheel/community-review": "^0.24.0",
101
+ "@medicine-wheel/consent-lifecycle": "^0.24.0",
102
+ "@medicine-wheel/creative-orientation": "^0.24.0",
103
+ "@medicine-wheel/data-store": "^0.24.0",
104
+ "@medicine-wheel/data-store-postgres": "^0.24.0",
105
+ "@medicine-wheel/events": "^0.24.0",
106
+ "@medicine-wheel/fire-keeper": "^0.24.0",
107
+ "@medicine-wheel/github-ceremony": "^0.24.0",
108
+ "@medicine-wheel/graph-viz": "^0.24.0",
109
+ "@medicine-wheel/honcho": "^0.24.0",
110
+ "@medicine-wheel/importance-unit": "^0.24.0",
111
+ "@medicine-wheel/mcp": "^4.24.0",
112
+ "@medicine-wheel/memory": "^0.24.0",
113
+ "@medicine-wheel/narrative-cluster": "^0.24.0",
114
+ "@medicine-wheel/narrative-engine": "^0.24.0",
115
+ "@medicine-wheel/ontology-core": "^0.24.0",
116
+ "@medicine-wheel/perception-layer": "^0.24.0",
117
+ "@medicine-wheel/prompt-decomposition": "^0.24.0",
118
+ "@medicine-wheel/relational-index": "^0.24.0",
119
+ "@medicine-wheel/relational-query": "^0.24.0",
120
+ "@medicine-wheel/session-reader": "^0.24.0",
121
+ "@medicine-wheel/storage-provider": "^0.24.0",
122
+ "@medicine-wheel/transformation-tracker": "^0.24.0",
123
+ "@medicine-wheel/ui-components": "^0.24.0",
124
124
  "@miadi/episode-vessel": "^0.2.1",
125
125
  "@neondatabase/serverless": "^0.10.0",
126
126
  "@xyflow/react": "^12.3.0",