opencode-rag-plugin 2.3.1 → 2.4.1
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/ReadMe.md +71 -8
- package/dist/chunker/skeleton.js +1 -1
- package/dist/cli/commands/decide.d.ts +25 -0
- package/dist/cli/commands/decide.js +160 -0
- package/dist/cli/commands/eval.d.ts +23 -0
- package/dist/cli/commands/eval.js +331 -1
- package/dist/cli/commands/index-command.js +28 -10
- package/dist/cli/commands/index.d.ts +2 -1
- package/dist/cli/commands/index.js +2 -1
- package/dist/cli/commands/init-helpers.d.ts +16 -1
- package/dist/cli/commands/init-helpers.js +84 -2
- package/dist/cli/commands/init.js +29 -4
- package/dist/cli/commands/status.js +14 -8
- package/dist/cli/format.d.ts +50 -0
- package/dist/cli/format.js +122 -0
- package/dist/cli/index.js +4 -1
- package/dist/cli/types.d.ts +2 -0
- package/dist/core/bootstrap.js +1 -0
- package/dist/core/config.d.ts +47 -0
- package/dist/core/config.js +34 -1
- package/dist/core/interfaces.d.ts +69 -0
- package/dist/decision/factory.d.ts +17 -0
- package/dist/decision/factory.js +17 -0
- package/dist/decision/format.d.ts +14 -0
- package/dist/decision/format.js +53 -0
- package/dist/decision/systemone.d.ts +76 -0
- package/dist/decision/systemone.js +234 -0
- package/dist/decision/validate.d.ts +26 -0
- package/dist/decision/validate.js +74 -0
- package/dist/eval/decide-calibration.d.ts +112 -0
- package/dist/eval/decide-calibration.js +185 -0
- package/dist/eval/golden-gate.d.ts +65 -0
- package/dist/eval/golden-gate.js +61 -0
- package/dist/eval/golden-set.d.ts +81 -0
- package/dist/eval/golden-set.js +155 -0
- package/dist/eval/rerank-eval.js +10 -125
- package/dist/index.d.ts +6 -2
- package/dist/index.js +4 -0
- package/dist/indexer/pipeline.d.ts +0 -10
- package/dist/indexer/pipeline.js +1 -0
- package/dist/mcp/handlers.d.ts +17 -1
- package/dist/mcp/handlers.js +30 -0
- package/dist/mcp/server.d.ts +9 -1
- package/dist/mcp/server.js +47 -3
- package/dist/opencode/system-guidance.d.ts +11 -0
- package/dist/opencode/system-guidance.js +53 -0
- package/dist/opencode/tools.d.ts +24 -1
- package/dist/opencode/tools.js +101 -0
- package/dist/plugin.js +21 -3
- package/dist/quirks/quirk-store.d.ts +2 -0
- package/dist/quirks/quirk-store.js +33 -4
- package/dist/tui.js +21 -2
- package/dist/v2/v2-adapter.d.ts +20 -0
- package/dist/v2/v2-adapter.js +36 -8
- package/dist/vectorstore/lancedb.js +54 -5
- package/dist/watcher.d.ts +26 -1
- package/dist/watcher.js +71 -9
- package/dist/web/ui/assets/index-CWcp0jNf.css +2 -0
- package/dist/web/ui/index.html +2 -2
- package/package.json +5 -2
- package/dist/web/ui/assets/index-Dp009QCQ.css +0 -1
- /package/dist/web/ui/assets/{index-C0QXKA-b.js → index-DbXFrn53.js} +0 -0
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* `eval:sessions`, `eval:analyze`, `eval:compare` commands —
|
|
6
6
|
* evaluation session listing, per-session token analysis, and cross-session comparison.
|
|
7
7
|
*/
|
|
8
|
+
import { writeFileSync } from "node:fs";
|
|
8
9
|
import path from "node:path";
|
|
9
|
-
import { c, resolveCliContext } from "../format.js";
|
|
10
|
+
import { c, resolveCliContext, cleanupContext } from "../format.js";
|
|
10
11
|
/**
|
|
11
12
|
* Register the `eval:sessions` command on the given Commander program.
|
|
12
13
|
*
|
|
@@ -158,4 +159,333 @@ export function registerEvalCompareCommand(program) {
|
|
|
158
159
|
}
|
|
159
160
|
});
|
|
160
161
|
}
|
|
162
|
+
/** Parse a `0..1` ratio CLI option, or undefined when absent. */
|
|
163
|
+
function parseRatioOption(raw, name) {
|
|
164
|
+
if (raw === undefined || raw === "")
|
|
165
|
+
return undefined;
|
|
166
|
+
const value = Number(raw);
|
|
167
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
168
|
+
throw new Error(`${name} must be a number between 0 and 1 (got "${raw}")`);
|
|
169
|
+
}
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Register the `eval:gate` command on the given Commander program.
|
|
174
|
+
*
|
|
175
|
+
* Runs the labelled golden set through the real retrieval pipeline (fusion only —
|
|
176
|
+
* the rerank stage is intentionally not active) and exits non-zero when Hit@5,
|
|
177
|
+
* MRR, or nDCG@10 drop below the documented floors. Exit contract:
|
|
178
|
+
* `0` = passed, `1` = gate failed (quality regression), `2` = could not run
|
|
179
|
+
* (missing labels/index, provider down, invalid options).
|
|
180
|
+
*
|
|
181
|
+
* @param program - The Commander `Command` instance to register on.
|
|
182
|
+
*/
|
|
183
|
+
export function registerEvalGateCommand(program) {
|
|
184
|
+
program
|
|
185
|
+
.command("eval:gate")
|
|
186
|
+
.description("Run the retrieval golden set and fail when Hit@5 / MRR / nDCG@10 drop below the thresholds")
|
|
187
|
+
.option("-c, --config <path>", "path to config file")
|
|
188
|
+
.option("--labels <path>", "golden-set label file (default: src/eval/rerank-labels.json)")
|
|
189
|
+
.option("--topk <n>", "top-K retrieved per query (default: retrieval.topK)")
|
|
190
|
+
.option("--category <name>", "only run labels of this category")
|
|
191
|
+
.option("--limit <n>", "only run the first N labels")
|
|
192
|
+
.option("--min-hit5 <ratio>", "minimum Hit@5, 0-1 (default 0.35)")
|
|
193
|
+
.option("--min-mrr <ratio>", "minimum MRR, 0-1 (default 0.25)")
|
|
194
|
+
.option("--min-ndcg10 <ratio>", "minimum nDCG@10, 0-1 (default 0.32)")
|
|
195
|
+
.option("--json", "print a machine-readable result as the last stdout line")
|
|
196
|
+
.action(async (options) => {
|
|
197
|
+
const cwd = process.cwd();
|
|
198
|
+
const logFilePath = path.resolve(cwd, ".opencode", "opencode-rag.log");
|
|
199
|
+
const started = Date.now();
|
|
200
|
+
let ctx;
|
|
201
|
+
let exitCode = 0;
|
|
202
|
+
try {
|
|
203
|
+
const { loadGoldenLabels } = await import("../../eval/golden-set.js");
|
|
204
|
+
const { DEFAULT_GATE_THRESHOLDS, evaluateGate, runGoldenGate } = await import("../../eval/golden-gate.js");
|
|
205
|
+
const labelsPath = options.labels
|
|
206
|
+
? path.resolve(cwd, options.labels)
|
|
207
|
+
: path.join(cwd, "src", "eval", "rerank-labels.json");
|
|
208
|
+
let labels = loadGoldenLabels(labelsPath);
|
|
209
|
+
if (options.category)
|
|
210
|
+
labels = labels.filter((label) => label.category === options.category);
|
|
211
|
+
if (options.limit !== undefined) {
|
|
212
|
+
const limit = Number(options.limit);
|
|
213
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
214
|
+
throw new Error(`--limit must be a positive integer (got "${options.limit}")`);
|
|
215
|
+
}
|
|
216
|
+
labels = labels.slice(0, limit);
|
|
217
|
+
}
|
|
218
|
+
if (labels.length === 0) {
|
|
219
|
+
throw new Error("No labels selected (check --category/--limit).");
|
|
220
|
+
}
|
|
221
|
+
const thresholds = {
|
|
222
|
+
hit5: parseRatioOption(options.minHit5, "--min-hit5") ?? DEFAULT_GATE_THRESHOLDS.hit5,
|
|
223
|
+
mrr: parseRatioOption(options.minMrr, "--min-mrr") ?? DEFAULT_GATE_THRESHOLDS.mrr,
|
|
224
|
+
ndcg10: parseRatioOption(options.minNdcg10, "--min-ndcg10") ?? DEFAULT_GATE_THRESHOLDS.ndcg10,
|
|
225
|
+
};
|
|
226
|
+
ctx = await resolveCliContext(options, logFilePath);
|
|
227
|
+
const indexedCount = await ctx.store.count();
|
|
228
|
+
if (indexedCount === 0) {
|
|
229
|
+
console.error(c.error(`\nGate cannot run: the index is empty. Run 'opencode-rag index' first.\n`));
|
|
230
|
+
await cleanupContext(ctx);
|
|
231
|
+
process.exit(2);
|
|
232
|
+
}
|
|
233
|
+
const topK = options.topk !== undefined ? Number(options.topk) : ctx.config.retrieval.topK;
|
|
234
|
+
if (!Number.isInteger(topK) || topK <= 0) {
|
|
235
|
+
throw new Error(`--topk must be a positive integer (got "${options.topk}")`);
|
|
236
|
+
}
|
|
237
|
+
// Mirror the production retrieval options from the resolved config — the
|
|
238
|
+
// gate must measure the shipped pipeline, not a bespoke one.
|
|
239
|
+
const hybrid = ctx.config.retrieval.hybridSearch;
|
|
240
|
+
const retrieveOptions = {
|
|
241
|
+
topK,
|
|
242
|
+
minScore: ctx.config.retrieval.minScore,
|
|
243
|
+
keywordIndex: ctx.keywordIndex,
|
|
244
|
+
keywordWeight: hybrid?.keywordWeight,
|
|
245
|
+
symbolKeywordWeight: hybrid?.symbolKeywordWeight,
|
|
246
|
+
docKeywordDemotion: hybrid?.docKeywordDemotion,
|
|
247
|
+
testKeywordDemotion: hybrid?.testKeywordDemotion,
|
|
248
|
+
hybridEnabled: hybrid?.enabled,
|
|
249
|
+
queryPrefix: ctx.config.embedding.queryPrefix,
|
|
250
|
+
};
|
|
251
|
+
const { retrieve } = await import("../../retriever/retriever.js");
|
|
252
|
+
console.log(`\n${c.heading("Retrieval Golden-Set Gate")}\n`);
|
|
253
|
+
console.log(` Indexed chunks: ${c.num(indexedCount)}`);
|
|
254
|
+
console.log(` Embedder: ${c.value(`${ctx.config.embedding.provider}/${ctx.config.embedding.model}`)} (dim ${c.num(ctx.dimension)})`);
|
|
255
|
+
console.log(` Retrieval: topK=${c.num(topK)}, minScore=${c.num(ctx.config.retrieval.minScore)}, hybrid=${c.value(String(hybrid?.enabled ?? false))}`);
|
|
256
|
+
console.log(` Labels: ${c.num(labels.length)} from ${c.file(path.relative(cwd, labelsPath).replace(/\\/g, "/"))}`);
|
|
257
|
+
console.log(` Note: fusion-only measurement — the rerank stage is intentionally not active.\n`);
|
|
258
|
+
const { summary } = await runGoldenGate({
|
|
259
|
+
labels,
|
|
260
|
+
root: cwd,
|
|
261
|
+
retrieve: (label) => retrieve(label.query, ctx.embedder, ctx.store, retrieveOptions),
|
|
262
|
+
});
|
|
263
|
+
const { pass, rows } = evaluateGate(summary, thresholds);
|
|
264
|
+
console.log(`\n ${c.heading("Gate")}`);
|
|
265
|
+
for (const row of rows) {
|
|
266
|
+
const mark = row.pass ? c.success("PASS") : c.error("FAIL");
|
|
267
|
+
console.log(` ${mark} ${row.metric.padEnd(8)} ${(row.actual * 100).toFixed(1).padStart(6)}% (required ≥ ${(row.required * 100).toFixed(1)}%)`);
|
|
268
|
+
}
|
|
269
|
+
console.log(`\n All metrics: Hit@1 ${(summary.hit1 * 100).toFixed(1)}% · Hit@3 ${(summary.hit3 * 100).toFixed(1)}% · ` +
|
|
270
|
+
`Hit@5 ${(summary.hit5 * 100).toFixed(1)}% · Hit@10 ${(summary.hit10 * 100).toFixed(1)}% · ` +
|
|
271
|
+
`MRR ${summary.mrr.toFixed(3)} · nDCG@10 ${summary.ndcg10.toFixed(3)}\n`);
|
|
272
|
+
if (options.json) {
|
|
273
|
+
console.log(JSON.stringify({
|
|
274
|
+
schema: 1,
|
|
275
|
+
status: pass ? "pass" : "fail",
|
|
276
|
+
durationMs: Date.now() - started,
|
|
277
|
+
labels: labels.length,
|
|
278
|
+
labelsPath: path.relative(cwd, labelsPath).replace(/\\/g, "/"),
|
|
279
|
+
topK,
|
|
280
|
+
indexedChunks: indexedCount,
|
|
281
|
+
metrics: {
|
|
282
|
+
hit1: summary.hit1,
|
|
283
|
+
hit3: summary.hit3,
|
|
284
|
+
hit5: summary.hit5,
|
|
285
|
+
hit10: summary.hit10,
|
|
286
|
+
mrr: summary.mrr,
|
|
287
|
+
ndcg10: summary.ndcg10,
|
|
288
|
+
symbolRate: summary.symbolRate,
|
|
289
|
+
},
|
|
290
|
+
thresholds,
|
|
291
|
+
rows,
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
if (!pass) {
|
|
295
|
+
console.error(c.error("\nGate FAILED — ranking regressed below the documented floors.\n"));
|
|
296
|
+
exitCode = 1;
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
console.log(c.success("Gate passed."));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (err) {
|
|
303
|
+
const message = err.message || String(err);
|
|
304
|
+
console.error(c.error(`\nGate could not run: ${message}\n`));
|
|
305
|
+
if (message.toLowerCase().includes("fetch") || message.toLowerCase().includes("econnrefused")) {
|
|
306
|
+
console.error(c.warn("Hint: Is your embedding provider running?\n"));
|
|
307
|
+
}
|
|
308
|
+
exitCode = 2;
|
|
309
|
+
}
|
|
310
|
+
finally {
|
|
311
|
+
if (ctx)
|
|
312
|
+
await cleanupContext(ctx);
|
|
313
|
+
}
|
|
314
|
+
process.exit(exitCode);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Register the `eval:decide` command on the given Commander program.
|
|
319
|
+
*
|
|
320
|
+
* Measures accuracy, ECE (10 bins) and Brier score of the tev1 decision model against
|
|
321
|
+
* the labelled calibration set. Unlike `eval:gate` this is a measurement, not a threshold
|
|
322
|
+
* check — it exits `0` when the run completed, `2` when it could not run (no decision
|
|
323
|
+
* config, Ollama unreachable, model missing).
|
|
324
|
+
*
|
|
325
|
+
* @param program - The Commander `Command` instance to register on.
|
|
326
|
+
*/
|
|
327
|
+
export function registerEvalDecideCommand(program) {
|
|
328
|
+
program
|
|
329
|
+
.command("eval:decide")
|
|
330
|
+
.description("Measure accuracy, ECE, and Brier score of the tev1 decision model on the labelled calibration set")
|
|
331
|
+
.option("-c, --config <path>", "path to config file")
|
|
332
|
+
.option("--labels <path>", "calibration label file (default: src/eval/decide-labels.json)")
|
|
333
|
+
.option("--model <name>", "decision model override (synthesizes an enabled decision config)")
|
|
334
|
+
.option("--base-url <url>", "Ollama base URL override (e.g. http://127.0.0.1:11434)")
|
|
335
|
+
.option("--category <name>", "only run items of this category")
|
|
336
|
+
.option("--limit <n>", "only run the first N items")
|
|
337
|
+
.option("--report <path>", "write a markdown calibration report to this path")
|
|
338
|
+
.option("--json", "print a machine-readable result as the last stdout line")
|
|
339
|
+
.action(async (options) => {
|
|
340
|
+
const cwd = process.cwd();
|
|
341
|
+
const logFilePath = path.resolve(cwd, ".opencode", "opencode-rag.log");
|
|
342
|
+
let ctx;
|
|
343
|
+
let exitCode = 0;
|
|
344
|
+
try {
|
|
345
|
+
const { loadDecideCalibration, runDecideCalibration } = await import("../../eval/decide-calibration.js");
|
|
346
|
+
const labelsPath = options.labels
|
|
347
|
+
? path.resolve(cwd, options.labels)
|
|
348
|
+
: path.join(cwd, "src", "eval", "decide-labels.json");
|
|
349
|
+
let items = loadDecideCalibration(labelsPath);
|
|
350
|
+
if (options.category)
|
|
351
|
+
items = items.filter((item) => item.category === options.category);
|
|
352
|
+
if (options.limit !== undefined) {
|
|
353
|
+
const limit = Number(options.limit);
|
|
354
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
355
|
+
throw new Error(`--limit must be a positive integer (got "${options.limit}")`);
|
|
356
|
+
}
|
|
357
|
+
items = items.slice(0, limit);
|
|
358
|
+
}
|
|
359
|
+
if (items.length === 0) {
|
|
360
|
+
throw new Error("No calibration items selected (check --category/--limit).");
|
|
361
|
+
}
|
|
362
|
+
ctx = await resolveCliContext(options, logFilePath);
|
|
363
|
+
const configured = ctx.config.decision;
|
|
364
|
+
let decisionCfg;
|
|
365
|
+
if (configured?.enabled) {
|
|
366
|
+
decisionCfg = { ...configured };
|
|
367
|
+
}
|
|
368
|
+
else if (options.baseUrl || options.model) {
|
|
369
|
+
// CLI-only override, like the rerank harness — never touches the config file.
|
|
370
|
+
decisionCfg = {
|
|
371
|
+
enabled: true,
|
|
372
|
+
provider: "ollama",
|
|
373
|
+
baseUrl: options.baseUrl ?? "http://127.0.0.1:11434",
|
|
374
|
+
model: options.model ?? "tev1:0.8b",
|
|
375
|
+
timeoutMs: 30000,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
if (!decisionCfg) {
|
|
379
|
+
console.error(c.error("\nNo enabled decision config. Set `decision.enabled` in opencode-rag.json or pass --base-url/--model.\n"));
|
|
380
|
+
await cleanupContext(ctx);
|
|
381
|
+
process.exit(2);
|
|
382
|
+
}
|
|
383
|
+
if (options.model)
|
|
384
|
+
decisionCfg.model = options.model;
|
|
385
|
+
if (options.baseUrl)
|
|
386
|
+
decisionCfg.baseUrl = options.baseUrl;
|
|
387
|
+
const { createDecisionProvider } = await import("../../decision/factory.js");
|
|
388
|
+
const provider = createDecisionProvider(decisionCfg);
|
|
389
|
+
console.log(`\n${c.heading("Decision-Model Calibration")}\n`);
|
|
390
|
+
console.log(` Model: ${c.value(decisionCfg.model)} (${c.value(decisionCfg.baseUrl)})`);
|
|
391
|
+
console.log(` Items: ${c.num(items.length)} from ${c.file(path.relative(cwd, labelsPath).replace(/\\/g, "/"))}`);
|
|
392
|
+
console.log(` Note: 'confidence' is probability concentration — this run measures how close it is to correctness.\n`);
|
|
393
|
+
const { scored, summary } = await runDecideCalibration({ items, provider });
|
|
394
|
+
console.log(`\n ${c.heading("Calibration")}`);
|
|
395
|
+
console.log(` Accuracy: ${c.num(`${(summary.accuracy * 100).toFixed(1)}%`)} (${summary.n} items, ${summary.answered} answered)`);
|
|
396
|
+
console.log(` ECE (10 bins): ${c.num(summary.ece.toFixed(3))}`);
|
|
397
|
+
console.log(` Brier score: ${c.num(summary.brier.toFixed(3))}`);
|
|
398
|
+
console.log(` Mean confidence: ${c.num(summary.meanConfidence.toFixed(3))}`);
|
|
399
|
+
if (summary.meanPExpected !== null) {
|
|
400
|
+
console.log(` Mean p(expected): ${c.num(summary.meanPExpected.toFixed(3))}`);
|
|
401
|
+
}
|
|
402
|
+
console.log();
|
|
403
|
+
console.log(` ${c.heading("Reliability")} (bin, n, mean confidence, accuracy, gap)`);
|
|
404
|
+
for (const bin of summary.bins) {
|
|
405
|
+
if (bin.count === 0)
|
|
406
|
+
continue;
|
|
407
|
+
const gap = (bin.accuracy - bin.confidence) * 100;
|
|
408
|
+
console.log(` ${(bin.lo).toFixed(1)}–${(bin.hi).toFixed(1)} n=${String(bin.count).padStart(2)} ` +
|
|
409
|
+
`conf=${bin.confidence.toFixed(2)} acc=${bin.accuracy.toFixed(2)} gap=${gap >= 0 ? "+" : ""}${gap.toFixed(0)}%`);
|
|
410
|
+
}
|
|
411
|
+
console.log();
|
|
412
|
+
if (options.report) {
|
|
413
|
+
const reportPath = path.resolve(cwd, options.report);
|
|
414
|
+
const lines = [
|
|
415
|
+
"# Decision-Model Calibration",
|
|
416
|
+
"",
|
|
417
|
+
`**Date:** ${new Date().toISOString()}`,
|
|
418
|
+
`**Model:** ${decisionCfg.model} (${decisionCfg.baseUrl})`,
|
|
419
|
+
`**Labels:** ${items.length} from \`${path.relative(cwd, labelsPath).replace(/\\/g, "/")}\``,
|
|
420
|
+
"",
|
|
421
|
+
"## Metrics",
|
|
422
|
+
"",
|
|
423
|
+
"| Metric | Value |",
|
|
424
|
+
"|--------|-------|",
|
|
425
|
+
`| Accuracy | ${(summary.accuracy * 100).toFixed(1)}% (${summary.n} items, ${summary.answered} answered) |`,
|
|
426
|
+
`| ECE (10 bins) | ${summary.ece.toFixed(3)} |`,
|
|
427
|
+
`| Brier score | ${summary.brier.toFixed(3)} |`,
|
|
428
|
+
`| Mean confidence | ${summary.meanConfidence.toFixed(3)} |`,
|
|
429
|
+
`| Mean p(expected) | ${summary.meanPExpected !== null ? summary.meanPExpected.toFixed(3) : "-"} |`,
|
|
430
|
+
"",
|
|
431
|
+
"## Reliability (10 bins)",
|
|
432
|
+
"",
|
|
433
|
+
"| Bin | n | Mean confidence | Accuracy | Gap |",
|
|
434
|
+
"|-----|---|-----------------|----------|-----|",
|
|
435
|
+
];
|
|
436
|
+
for (const bin of summary.bins) {
|
|
437
|
+
if (bin.count === 0)
|
|
438
|
+
continue;
|
|
439
|
+
const gap = (bin.accuracy - bin.confidence) * 100;
|
|
440
|
+
lines.push(`| ${bin.lo.toFixed(1)}–${bin.hi.toFixed(1)} | ${bin.count} | ${bin.confidence.toFixed(2)} | ${bin.accuracy.toFixed(2)} | ${gap >= 0 ? "+" : ""}${gap.toFixed(0)}% |`);
|
|
441
|
+
}
|
|
442
|
+
lines.push("", "## Per-item", "", "| ID | Category | Expected | Predicted | Correct | Confidence |", "|----|----------|----------|-----------|---------|------------|");
|
|
443
|
+
for (const entry of scored) {
|
|
444
|
+
lines.push(`| ${entry.item.id} | ${entry.item.category} | ${entry.item.expected} | ${entry.predicted ?? "-"} | ${entry.correct ? "yes" : "no"} | ${entry.confidence.toFixed(2)} |`);
|
|
445
|
+
}
|
|
446
|
+
lines.push("");
|
|
447
|
+
writeFileSync(reportPath, lines.join("\n"), "utf-8");
|
|
448
|
+
console.log(` Report written: ${c.file(reportPath)}\n`);
|
|
449
|
+
}
|
|
450
|
+
if (options.json) {
|
|
451
|
+
console.log(JSON.stringify({
|
|
452
|
+
schema: 1,
|
|
453
|
+
status: "ok",
|
|
454
|
+
model: decisionCfg.model,
|
|
455
|
+
labels: items.length,
|
|
456
|
+
labelsPath: path.relative(cwd, labelsPath).replace(/\\/g, "/"),
|
|
457
|
+
metrics: {
|
|
458
|
+
accuracy: summary.accuracy,
|
|
459
|
+
answered: summary.answered,
|
|
460
|
+
ece: summary.ece,
|
|
461
|
+
brier: summary.brier,
|
|
462
|
+
meanConfidence: summary.meanConfidence,
|
|
463
|
+
meanPExpected: summary.meanPExpected,
|
|
464
|
+
},
|
|
465
|
+
bins: summary.bins,
|
|
466
|
+
items: scored.map((entry) => ({
|
|
467
|
+
id: entry.item.id,
|
|
468
|
+
expected: entry.item.expected,
|
|
469
|
+
predicted: entry.predicted ?? null,
|
|
470
|
+
correct: entry.correct,
|
|
471
|
+
confidence: entry.confidence,
|
|
472
|
+
})),
|
|
473
|
+
}));
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
catch (err) {
|
|
477
|
+
const message = err.message || String(err);
|
|
478
|
+
console.error(c.error(`\nCalibration could not run: ${message}\n`));
|
|
479
|
+
if (message.toLowerCase().includes("econnrefused") || message.toLowerCase().includes("fetch")) {
|
|
480
|
+
console.error(c.warn("Hint: decision calibration requires Ollama >= 0.35 with a pulled tev1 model (`ollama pull tev1:0.8b`).\n"));
|
|
481
|
+
}
|
|
482
|
+
exitCode = 2;
|
|
483
|
+
}
|
|
484
|
+
finally {
|
|
485
|
+
if (ctx)
|
|
486
|
+
await cleanupContext(ctx);
|
|
487
|
+
}
|
|
488
|
+
process.exit(exitCode);
|
|
489
|
+
});
|
|
490
|
+
}
|
|
161
491
|
//# sourceMappingURL=eval.js.map
|
|
@@ -14,7 +14,7 @@ import chokidar from "chokidar";
|
|
|
14
14
|
import { appendDebugLog } from "../../core/fileLogger.js";
|
|
15
15
|
import { createWatchPassScheduler, createWatchIgnore, runIndexPass, } from "../../indexer.js";
|
|
16
16
|
import { tryAcquireWatcherLock, releaseWatcherLock } from "../../watcher.js";
|
|
17
|
-
import { c, resolveCliContext, cleanupContext, logCliError, logCliInfo, logIndexSummary, formatDuration, } from "../format.js";
|
|
17
|
+
import { c, resolveCliContext, cleanupContext, logCliError, logCliInfo, logIndexSummary, formatDuration, classifyIndexRun, describeIndexProblems, buildIndexSummaryJson, } from "../format.js";
|
|
18
18
|
/**
|
|
19
19
|
* Build a logger that suppresses console output when watchTriggered is true.
|
|
20
20
|
*/
|
|
@@ -52,6 +52,7 @@ export function registerIndexCommand(program) {
|
|
|
52
52
|
.option("-f, --force", "force full re-index")
|
|
53
53
|
.option("-y, --yes", "skip confirmation prompt for full rebuild")
|
|
54
54
|
.option("-w, --watch", "watch workspace and incrementally re-index on changes")
|
|
55
|
+
.option("--json", "print a machine-readable JSON summary as the last stdout line of the initial pass")
|
|
55
56
|
.action(async (options) => {
|
|
56
57
|
const started = Date.now();
|
|
57
58
|
try {
|
|
@@ -99,7 +100,8 @@ export function registerIndexCommand(program) {
|
|
|
99
100
|
}
|
|
100
101
|
logCliInfo(logFilePath, "index", `${c.label("Scanning:")} ${c.file(cwd)}`);
|
|
101
102
|
let incomplete = false;
|
|
102
|
-
|
|
103
|
+
let partial = false;
|
|
104
|
+
const runPass = async (watchTriggered = false, abortSignal) => {
|
|
103
105
|
const passStarted = Date.now();
|
|
104
106
|
const stats = await runIndexPass({
|
|
105
107
|
cwd,
|
|
@@ -112,20 +114,34 @@ export function registerIndexCommand(program) {
|
|
|
112
114
|
force: !!(options.force && !watchTriggered),
|
|
113
115
|
abortSignal,
|
|
114
116
|
dimension,
|
|
115
|
-
filterPaths,
|
|
116
117
|
logger: watchAwareLogger(logFilePath, watchTriggered ? "watch" : "index", watchTriggered),
|
|
117
118
|
});
|
|
118
119
|
if (!watchTriggered) {
|
|
119
120
|
logIndexSummary(logFilePath, stats);
|
|
120
|
-
|
|
121
|
+
const status = classifyIndexRun(stats);
|
|
122
|
+
if (status === "incomplete") {
|
|
121
123
|
incomplete = true;
|
|
122
|
-
|
|
124
|
+
if (stats.embeddingUnavailable) {
|
|
125
|
+
logCliInfo(logFilePath, "index", `\n${c.error("Indexing incomplete:")} the embedding provider was unavailable — nothing was stored. Fix the provider and run the index again.`);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
logCliInfo(logFilePath, "index", `\n${c.warn("Indexing incomplete:")} files were processed but no chunks were stored. Check the log for details.`);
|
|
129
|
+
}
|
|
123
130
|
}
|
|
124
|
-
else if (
|
|
125
|
-
|
|
126
|
-
logCliInfo(logFilePath, "index", `\n${c.warn("Indexing
|
|
131
|
+
else if (status === "partial") {
|
|
132
|
+
partial = true;
|
|
133
|
+
logCliInfo(logFilePath, "index", `\n${c.warn("Indexing completed with problems:")} ${describeIndexProblems(stats).join("; ")} — see .opencode/opencode-rag.log.`);
|
|
127
134
|
}
|
|
128
135
|
logCliInfo(logFilePath, "index", `\n${c.success("Indexing complete.")} ${c.num(stats.finalCount)} chunks stored (${formatDuration(Date.now() - passStarted)}).`);
|
|
136
|
+
if (options.json) {
|
|
137
|
+
// Machine-readable summary: exactly one JSON object on the last line.
|
|
138
|
+
console.log(JSON.stringify(buildIndexSummaryJson(stats, {
|
|
139
|
+
cwd,
|
|
140
|
+
startedAt: started,
|
|
141
|
+
durationMs: Date.now() - passStarted,
|
|
142
|
+
interrupted: sigReceived,
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
129
145
|
}
|
|
130
146
|
if (sigReceived && !watchTriggered) {
|
|
131
147
|
logCliInfo(logFilePath, "index", `\n${c.warn("Indexing was interrupted.")} ${c.num(stats.finalCount)} chunks saved. Run again to index remaining files.`);
|
|
@@ -137,7 +153,9 @@ export function registerIndexCommand(program) {
|
|
|
137
153
|
process.removeListener("SIGTERM", handleSigint);
|
|
138
154
|
if (!options.watch) {
|
|
139
155
|
await cleanupContext(ctx);
|
|
140
|
-
|
|
156
|
+
// Exit contract: 0 = complete, 3 = completed with problems (retried next pass),
|
|
157
|
+
// 1 = incomplete (nothing stored / hard failure), 130 = interrupted.
|
|
158
|
+
process.exit(sigReceived ? 130 : incomplete ? 1 : partial ? 3 : 0);
|
|
141
159
|
}
|
|
142
160
|
// Only one watcher may run per workspace — a background auto-indexer
|
|
143
161
|
// in an OpenCode session (or another `index --watch`) may already own
|
|
@@ -149,7 +167,7 @@ export function registerIndexCommand(program) {
|
|
|
149
167
|
process.exit(0);
|
|
150
168
|
}
|
|
151
169
|
logCliInfo(logFilePath, "index", `\n${c.heading("Watching for changes...")}`);
|
|
152
|
-
const scheduler = createWatchPassScheduler(async (
|
|
170
|
+
const scheduler = createWatchPassScheduler(async () => { await runPass(true); }, (error) => {
|
|
153
171
|
const message = error.message || String(error);
|
|
154
172
|
logCliError(logFilePath, "watch", `\nWatch reindex failed: ${message}`, error);
|
|
155
173
|
}, 300);
|
|
@@ -13,6 +13,7 @@ export { registerUiCommand } from "./ui.js";
|
|
|
13
13
|
export { registerMcpCommand } from "./mcp.js";
|
|
14
14
|
export { registerSetupCommand } from "./setup.js";
|
|
15
15
|
export { registerUpdateCommand } from "./update.js";
|
|
16
|
-
export { registerEvalSessionsCommand, registerEvalAnalyzeCommand, registerEvalCompareCommand } from "./eval.js";
|
|
16
|
+
export { registerEvalSessionsCommand, registerEvalAnalyzeCommand, registerEvalCompareCommand, registerEvalGateCommand, registerEvalDecideCommand } from "./eval.js";
|
|
17
17
|
export { registerDescribeImageCommand } from "./describe-image.js";
|
|
18
|
+
export { registerDecideCommand } from "./decide.js";
|
|
18
19
|
export { registerQuirkCommand } from "./quirk.js";
|
|
@@ -13,7 +13,8 @@ export { registerUiCommand } from "./ui.js";
|
|
|
13
13
|
export { registerMcpCommand } from "./mcp.js";
|
|
14
14
|
export { registerSetupCommand } from "./setup.js";
|
|
15
15
|
export { registerUpdateCommand } from "./update.js";
|
|
16
|
-
export { registerEvalSessionsCommand, registerEvalAnalyzeCommand, registerEvalCompareCommand } from "./eval.js";
|
|
16
|
+
export { registerEvalSessionsCommand, registerEvalAnalyzeCommand, registerEvalCompareCommand, registerEvalGateCommand, registerEvalDecideCommand } from "./eval.js";
|
|
17
17
|
export { registerDescribeImageCommand } from "./describe-image.js";
|
|
18
|
+
export { registerDecideCommand } from "./decide.js";
|
|
18
19
|
export { registerQuirkCommand } from "./quirk.js";
|
|
19
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -70,6 +70,15 @@ export declare function generateWorkspaceTuiPluginFile(packageName: string): str
|
|
|
70
70
|
* @returns The full Markdown content of the skill file.
|
|
71
71
|
*/
|
|
72
72
|
export declare function generateSkillFile(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Generate the content for `.opencode/skills/make-decision/SKILL.md`.
|
|
75
|
+
*
|
|
76
|
+
* Provides decision-model usage guidance for AI assistants: when to reach for
|
|
77
|
+
* `make_decision`, the three question types, prerequisites, and limits.
|
|
78
|
+
*
|
|
79
|
+
* @returns The full Markdown content of the decision skill file.
|
|
80
|
+
*/
|
|
81
|
+
export declare function generateDecisionSkillFile(): string;
|
|
73
82
|
/**
|
|
74
83
|
* Merge required entries into an existing `.gitignore` content string.
|
|
75
84
|
*
|
|
@@ -90,11 +99,17 @@ export declare function mergeGitignoreContent(existingContent?: string): string;
|
|
|
90
99
|
*
|
|
91
100
|
* @param existingContent - The current `AGENTS.md` content, or `undefined` if absent.
|
|
92
101
|
* @param opts - Optional settings. `promptEnforcement` controls whether the
|
|
93
|
-
* quirk-capture enforcement rules are included (default `true`)
|
|
102
|
+
* quirk-capture enforcement rules are included (default `true`);
|
|
103
|
+
* `decisionEnabled` controls whether the `make_decision` guidance section is
|
|
104
|
+
* included (default `false` — the tool is not registered when disabled);
|
|
105
|
+
* `routeBeforeAsking` adds the optional pre-ask decision-routing rule
|
|
106
|
+
* (default `false`).
|
|
94
107
|
* @returns The merged `AGENTS.md` content with a trailing newline.
|
|
95
108
|
*/
|
|
96
109
|
export declare function mergeAgentsMdContent(existingContent?: string, opts?: {
|
|
97
110
|
promptEnforcement?: boolean;
|
|
111
|
+
decisionEnabled?: boolean;
|
|
112
|
+
routeBeforeAsking?: boolean;
|
|
98
113
|
}): string;
|
|
99
114
|
/**
|
|
100
115
|
* Get the runtime directory path (`~/.opencode`).
|
|
@@ -247,6 +247,71 @@ export function generateSkillFile() {
|
|
|
247
247
|
"",
|
|
248
248
|
].join("\n");
|
|
249
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Generate the content for `.opencode/skills/make-decision/SKILL.md`.
|
|
252
|
+
*
|
|
253
|
+
* Provides decision-model usage guidance for AI assistants: when to reach for
|
|
254
|
+
* `make_decision`, the three question types, prerequisites, and limits.
|
|
255
|
+
*
|
|
256
|
+
* @returns The full Markdown content of the decision skill file.
|
|
257
|
+
*/
|
|
258
|
+
export function generateDecisionSkillFile() {
|
|
259
|
+
return [
|
|
260
|
+
"---",
|
|
261
|
+
"name: make-decision",
|
|
262
|
+
"description: Classify, route, or score short text with the local tev1 decision model via the make_decision tool (Ollama /v1/systemone)",
|
|
263
|
+
"---",
|
|
264
|
+
"",
|
|
265
|
+
"## Decision Model (`make_decision`)",
|
|
266
|
+
"",
|
|
267
|
+
"Use `make_decision(state, questions)` when a task reduces to a fast classification, routing choice, policy check, or rubric score over short text — e.g. \"which module owns this error?\", \"is this request within policy?\", \"rate the severity\". It calls a local decision model (tev1) that returns the chosen option with probabilities.",
|
|
268
|
+
"",
|
|
269
|
+
"### Prerequisites",
|
|
270
|
+
"",
|
|
271
|
+
"- `decision.enabled` must be `true` in `opencode-rag.json` (off by default).",
|
|
272
|
+
"- Requires Ollama >= 0.35 with a pulled tev1 model (`ollama pull tev1` or `ollama pull tev1:0.8b`).",
|
|
273
|
+
"- Keep `state` short — the effective context is ~2k tokens. Pass the relevant excerpt, not a whole file.",
|
|
274
|
+
"",
|
|
275
|
+
"### Questions",
|
|
276
|
+
"",
|
|
277
|
+
"Each question needs `id`, `type`, and `instructions`:",
|
|
278
|
+
"",
|
|
279
|
+
"- `choice` — pick one of 2-24 options. `criteria` maps option → description. Add a `none` option when no listed option may fit.",
|
|
280
|
+
"- `noul` — true/false probability. Optional criteria `{ \"true\": \"...\", \"false\": \"...\" }` describe each side.",
|
|
281
|
+
"- `score` — place the state on a rubric. `criteria` is an ordered array of 2-24 level descriptions, lowest first.",
|
|
282
|
+
"",
|
|
283
|
+
"### Example",
|
|
284
|
+
"",
|
|
285
|
+
"```json",
|
|
286
|
+
"{",
|
|
287
|
+
" \"state\": \"Customer says they were charged twice for the October subscription.\",",
|
|
288
|
+
" \"questions\": [",
|
|
289
|
+
" {",
|
|
290
|
+
" \"id\": \"intent\",",
|
|
291
|
+
" \"type\": \"choice\",",
|
|
292
|
+
" \"instructions\": \"Which support intent best matches the message?\",",
|
|
293
|
+
" \"criteria\": {",
|
|
294
|
+
" \"duplicate_charge\": \"Charged more than once.\",",
|
|
295
|
+
" \"cancel\": \"Wants to end the subscription.\",",
|
|
296
|
+
" \"none\": \"None of the listed intents matches.\"",
|
|
297
|
+
" }",
|
|
298
|
+
" }",
|
|
299
|
+
" ]",
|
|
300
|
+
"}",
|
|
301
|
+
"```",
|
|
302
|
+
"",
|
|
303
|
+
"### Optional: route decisions before asking the user",
|
|
304
|
+
"",
|
|
305
|
+
"- When `decision.routeBeforeAsking` is `true`, route option choices through `make_decision` before interrupting the user: proceed when the model is confident, and ask the user only when it is undecided (low `confidence`) or the choice depends on personal preference.",
|
|
306
|
+
"",
|
|
307
|
+
"### Limits",
|
|
308
|
+
"",
|
|
309
|
+
"- 1-64 questions per call; 2-24 options/levels per question.",
|
|
310
|
+
"- `confidence` is probability concentration, NOT the chance the answer is correct.",
|
|
311
|
+
"- Never rely on it as the only check for a high-stakes decision; treat low-confidence answers as undecided.",
|
|
312
|
+
"",
|
|
313
|
+
].join("\n");
|
|
314
|
+
}
|
|
250
315
|
/**
|
|
251
316
|
* Merge required entries into an existing `.gitignore` content string.
|
|
252
317
|
*
|
|
@@ -296,11 +361,19 @@ export function mergeGitignoreContent(existingContent) {
|
|
|
296
361
|
*
|
|
297
362
|
* @param existingContent - The current `AGENTS.md` content, or `undefined` if absent.
|
|
298
363
|
* @param opts - Optional settings. `promptEnforcement` controls whether the
|
|
299
|
-
* quirk-capture enforcement rules are included (default `true`)
|
|
364
|
+
* quirk-capture enforcement rules are included (default `true`);
|
|
365
|
+
* `decisionEnabled` controls whether the `make_decision` guidance section is
|
|
366
|
+
* included (default `false` — the tool is not registered when disabled);
|
|
367
|
+
* `routeBeforeAsking` adds the optional pre-ask decision-routing rule
|
|
368
|
+
* (default `false`).
|
|
300
369
|
* @returns The merged `AGENTS.md` content with a trailing newline.
|
|
301
370
|
*/
|
|
302
371
|
export function mergeAgentsMdContent(existingContent, opts) {
|
|
303
|
-
const section = buildAgentsMdDirective({
|
|
372
|
+
const section = buildAgentsMdDirective({
|
|
373
|
+
promptEnforcement: opts?.promptEnforcement ?? true,
|
|
374
|
+
decisionEnabled: opts?.decisionEnabled ?? false,
|
|
375
|
+
routeBeforeAsking: opts?.routeBeforeAsking ?? false,
|
|
376
|
+
});
|
|
304
377
|
if (!existingContent) {
|
|
305
378
|
return `${section}\n`;
|
|
306
379
|
}
|
|
@@ -528,6 +601,15 @@ export function generateDefaultConfigJson(tuning, existingConfigRaw) {
|
|
|
528
601
|
think: DEFAULT_CONFIG.imageDescription.think,
|
|
529
602
|
numCtx: DEFAULT_CONFIG.imageDescription.numCtx,
|
|
530
603
|
},
|
|
604
|
+
decision: {
|
|
605
|
+
enabled: DEFAULT_CONFIG.decision.enabled,
|
|
606
|
+
provider: DEFAULT_CONFIG.decision.provider,
|
|
607
|
+
baseUrl: DEFAULT_CONFIG.decision.baseUrl,
|
|
608
|
+
model: DEFAULT_CONFIG.decision.model,
|
|
609
|
+
timeoutMs: DEFAULT_CONFIG.decision.timeoutMs,
|
|
610
|
+
keepAlive: DEFAULT_CONFIG.decision.keepAlive,
|
|
611
|
+
routeBeforeAsking: DEFAULT_CONFIG.decision.routeBeforeAsking,
|
|
612
|
+
},
|
|
531
613
|
description: {
|
|
532
614
|
enabled: DEFAULT_CONFIG.description.enabled,
|
|
533
615
|
provider: DEFAULT_CONFIG.description.provider,
|
|
@@ -16,7 +16,7 @@ import { checkProviderHealth, pullOllamaModels } from "../../embedder/health.js"
|
|
|
16
16
|
import { destroyAllPooledConnections } from "../../embedder/http.js";
|
|
17
17
|
import { c } from "../format.js";
|
|
18
18
|
import { getPackageMetadata, readJsonObject, writeJsonFile } from "../helpers.js";
|
|
19
|
-
import { buildOpencodeConfig, buildWorkspacePackageJson, generateDefaultConfigJson, generateSkillFile, generateWorkspacePluginFile, generateWorkspaceTuiPluginFile, installPluginFromGlobal, mergeAgentsMdContent, mergeGitignoreContent, } from "./init-helpers.js";
|
|
19
|
+
import { buildOpencodeConfig, buildWorkspacePackageJson, generateDefaultConfigJson, generateSkillFile, generateDecisionSkillFile, generateWorkspacePluginFile, generateWorkspaceTuiPluginFile, installPluginFromGlobal, mergeAgentsMdContent, mergeGitignoreContent, } from "./init-helpers.js";
|
|
20
20
|
import { detectOllamaBackend } from "./backend-detect.js";
|
|
21
21
|
/**
|
|
22
22
|
* Register the `init` command on the given Commander program.
|
|
@@ -170,20 +170,45 @@ export async function runWorkspaceInit(options = {}) {
|
|
|
170
170
|
else {
|
|
171
171
|
console.log(` ${c.exists("Exists:")} .opencode/skills/opencode-rag/SKILL.md`);
|
|
172
172
|
}
|
|
173
|
+
// Separate decision-model skill — loaded on demand when a task needs
|
|
174
|
+
// classification/routing/scoring via `make_decision`.
|
|
175
|
+
const decisionSkillDir = path.join(skillsDir, "make-decision");
|
|
176
|
+
const decisionSkillPath = path.join(decisionSkillDir, "SKILL.md");
|
|
177
|
+
if (!existsSync(decisionSkillDir)) {
|
|
178
|
+
mkdirSync(decisionSkillDir, { recursive: true });
|
|
179
|
+
console.log(` ${c.created("Created:")} .opencode/skills/make-decision/`);
|
|
180
|
+
}
|
|
181
|
+
const decisionSkillContent = generateDecisionSkillFile();
|
|
182
|
+
const decisionSkillExists = existsSync(decisionSkillPath);
|
|
183
|
+
if (!decisionSkillExists || options.force) {
|
|
184
|
+
writeFileSync(decisionSkillPath, decisionSkillContent, "utf-8");
|
|
185
|
+
console.log(` ${decisionSkillExists ? c.updated("Updated:") : c.created("Created:")} .opencode/skills/make-decision/SKILL.md`);
|
|
186
|
+
}
|
|
187
|
+
else if (readFileSync(decisionSkillPath, "utf-8") !== decisionSkillContent) {
|
|
188
|
+
writeFileSync(decisionSkillPath, decisionSkillContent, "utf-8");
|
|
189
|
+
console.log(` ${c.updated("Updated:")} .opencode/skills/make-decision/SKILL.md`);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
console.log(` ${c.exists("Exists:")} .opencode/skills/make-decision/SKILL.md`);
|
|
193
|
+
}
|
|
173
194
|
const agentsMdPath = path.join(cwd, "AGENTS.md");
|
|
174
195
|
const agentsMdExists = existsSync(agentsMdPath);
|
|
175
|
-
// Read effective
|
|
196
|
+
// Read effective memory/decision flags from existing config (if present)
|
|
176
197
|
let promptEnforcement = true;
|
|
198
|
+
let decisionEnabled = false;
|
|
199
|
+
let routeBeforeAsking = false;
|
|
177
200
|
try {
|
|
178
201
|
if (existsSync(configPath)) {
|
|
179
202
|
const existingCfg = loadConfig(configPath, false);
|
|
180
203
|
promptEnforcement = existingCfg.memory?.promptEnforcement ?? true;
|
|
204
|
+
decisionEnabled = existingCfg.decision?.enabled ?? false;
|
|
205
|
+
routeBeforeAsking = existingCfg.decision?.routeBeforeAsking ?? false;
|
|
181
206
|
}
|
|
182
207
|
}
|
|
183
208
|
catch {
|
|
184
|
-
// Malformed or missing config — use
|
|
209
|
+
// Malformed or missing config — use defaults
|
|
185
210
|
}
|
|
186
|
-
const nextAgentsMd = mergeAgentsMdContent(agentsMdExists ? readFileSync(agentsMdPath, "utf-8") : undefined, { promptEnforcement });
|
|
211
|
+
const nextAgentsMd = mergeAgentsMdContent(agentsMdExists ? readFileSync(agentsMdPath, "utf-8") : undefined, { promptEnforcement, decisionEnabled, routeBeforeAsking });
|
|
187
212
|
if (!agentsMdExists || options.force) {
|
|
188
213
|
writeFileSync(agentsMdPath, nextAgentsMd, "utf-8");
|
|
189
214
|
console.log(` ${agentsMdExists ? c.updated("Updated:") : c.created("Created:")} AGENTS.md`);
|