@grainulation/wheat 1.0.11 → 1.0.13
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.
- package/bin/wheat.js +11 -0
- package/lib/serve-mcp.js +35 -17
- package/package.json +2 -2
package/bin/wheat.js
CHANGED
|
@@ -104,6 +104,16 @@ if (subcommand === "--version" || subcommand === "-v") {
|
|
|
104
104
|
process.exit(0);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// ─── Fast MCP dispatch ──────────────────────────────────────────────────────
|
|
108
|
+
// MCP is machine-invoked via stdio — skip install-prompt and arg parsing.
|
|
109
|
+
// This matches mill/silo's pattern of early bail-out before any overhead.
|
|
110
|
+
if (subcommand === "mcp") {
|
|
111
|
+
const { startServer } = await import(
|
|
112
|
+
new URL("../lib/serve-mcp.js", import.meta.url).href
|
|
113
|
+
);
|
|
114
|
+
startServer(targetDir);
|
|
115
|
+
} else {
|
|
116
|
+
|
|
107
117
|
// ─── Install prompt tracking ─────────────────────────────────────────────────
|
|
108
118
|
// Track npx usage and maybe suggest installing. Both calls are sync, <5ms,
|
|
109
119
|
// and fail silently. Only fires for real subcommands (not --help/--version).
|
|
@@ -215,3 +225,4 @@ handler.run(targetDir, subArgs).catch((err) => {
|
|
|
215
225
|
if (process.env.WHEAT_DEBUG) console.error(err.stack);
|
|
216
226
|
process.exit(1);
|
|
217
227
|
});
|
|
228
|
+
} // end else (non-mcp subcommands)
|
package/lib/serve-mcp.js
CHANGED
|
@@ -170,7 +170,8 @@ function toolAddClaim(dir, args) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// Check for duplicate ID
|
|
173
|
-
|
|
173
|
+
const claims = data.claims || [];
|
|
174
|
+
if (claims.some((c) => c.id === id)) {
|
|
174
175
|
return { status: "error", message: `Claim ID "${id}" already exists.` };
|
|
175
176
|
}
|
|
176
177
|
|
|
@@ -182,15 +183,19 @@ function toolAddClaim(dir, args) {
|
|
|
182
183
|
source: { origin: "mcp", artifact: null, connector: null },
|
|
183
184
|
evidence: evidence || "stated",
|
|
184
185
|
status: "active",
|
|
185
|
-
phase_added: data.meta.phase || "research",
|
|
186
|
+
phase_added: (data.meta || {}).phase || "research",
|
|
186
187
|
timestamp: new Date().toISOString(),
|
|
187
188
|
conflicts_with: [],
|
|
188
189
|
resolved_by: null,
|
|
189
190
|
tags: tags || [],
|
|
190
191
|
};
|
|
191
192
|
|
|
192
|
-
data.claims.push(claim);
|
|
193
|
-
|
|
193
|
+
(data.claims || (data.claims = [])).push(claim);
|
|
194
|
+
try {
|
|
195
|
+
fs.writeFileSync(paths.claims, JSON.stringify(data, null, 2) + "\n");
|
|
196
|
+
} catch (err) {
|
|
197
|
+
return { status: "error", message: `Failed to write claims.json: ${err.message}` };
|
|
198
|
+
}
|
|
194
199
|
|
|
195
200
|
return { status: "ok", message: `Claim ${id} added.`, claim };
|
|
196
201
|
}
|
|
@@ -238,7 +243,11 @@ function toolResolve(dir, args) {
|
|
|
238
243
|
loserClaim.status = "superseded";
|
|
239
244
|
loserClaim.resolved_by = winner;
|
|
240
245
|
|
|
241
|
-
|
|
246
|
+
try {
|
|
247
|
+
fs.writeFileSync(paths.claims, JSON.stringify(data, null, 2) + "\n");
|
|
248
|
+
} catch (err) {
|
|
249
|
+
return { status: "error", message: `Failed to write claims.json: ${err.message}` };
|
|
250
|
+
}
|
|
242
251
|
|
|
243
252
|
return {
|
|
244
253
|
status: "ok",
|
|
@@ -324,8 +333,8 @@ function toolStatus(dir) {
|
|
|
324
333
|
|
|
325
334
|
return {
|
|
326
335
|
status: "ok",
|
|
327
|
-
question: data.meta.question,
|
|
328
|
-
phase: data.meta.phase,
|
|
336
|
+
question: (data.meta || {}).question || "(no question set)",
|
|
337
|
+
phase: (data.meta || {}).phase || "unknown",
|
|
329
338
|
total_claims: claims.length,
|
|
330
339
|
active_claims: active.length,
|
|
331
340
|
conflicted_claims: conflicted.length,
|
|
@@ -828,16 +837,25 @@ function startServer(dir) {
|
|
|
828
837
|
return;
|
|
829
838
|
}
|
|
830
839
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
840
|
+
try {
|
|
841
|
+
const response = await handleRequest(
|
|
842
|
+
dir,
|
|
843
|
+
msg.method,
|
|
844
|
+
msg.params || {},
|
|
845
|
+
msg.id
|
|
846
|
+
);
|
|
847
|
+
|
|
848
|
+
// Notifications don't get responses
|
|
849
|
+
if (response !== null) {
|
|
850
|
+
process.stdout.write(response + "\n");
|
|
851
|
+
}
|
|
852
|
+
} catch (err) {
|
|
853
|
+
const resp = jsonRpcError(
|
|
854
|
+
msg.id ?? null,
|
|
855
|
+
-32603,
|
|
856
|
+
`Internal error: ${err.message}`
|
|
857
|
+
);
|
|
858
|
+
process.stdout.write(resp + "\n");
|
|
841
859
|
}
|
|
842
860
|
});
|
|
843
861
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grainulation/wheat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "Research-driven development framework — structured claims, compiled evidence, deterministic output",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "grainulation contributors",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"bin": {
|
|
39
39
|
"wheat": "bin/wheat.js",
|
|
40
|
-
"wheat-mcp": "bin/wheat-mcp.
|
|
40
|
+
"wheat-mcp": "bin/wheat-mcp.cjs"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"bin/",
|