zelari-code 2.38.0 → 2.39.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.
@@ -3482,10 +3482,10 @@ function mergeDefs(...defs) {
3482
3482
  function cloneDef(schema) {
3483
3483
  return mergeDefs(schema._zod.def);
3484
3484
  }
3485
- function getElementAtPath(obj, path101) {
3486
- if (!path101)
3485
+ function getElementAtPath(obj, path102) {
3486
+ if (!path102)
3487
3487
  return obj;
3488
- return path101.reduce((acc, key) => acc?.[key], obj);
3488
+ return path102.reduce((acc, key) => acc?.[key], obj);
3489
3489
  }
3490
3490
  function promiseAllObject(promisesObj) {
3491
3491
  const keys = Object.keys(promisesObj);
@@ -3813,11 +3813,11 @@ function explicitlyAborted(x, startIndex = 0) {
3813
3813
  }
3814
3814
  return false;
3815
3815
  }
3816
- function prefixIssues(path101, issues) {
3816
+ function prefixIssues(path102, issues) {
3817
3817
  return issues.map((iss) => {
3818
3818
  var _a3;
3819
3819
  (_a3 = iss).path ?? (_a3.path = []);
3820
- iss.path.unshift(path101);
3820
+ iss.path.unshift(path102);
3821
3821
  return iss;
3822
3822
  });
3823
3823
  }
@@ -4035,16 +4035,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
4035
4035
  }
4036
4036
  function formatError(error51, mapper = (issue2) => issue2.message) {
4037
4037
  const fieldErrors = { _errors: [] };
4038
- const processError = (error52, path101 = []) => {
4038
+ const processError = (error52, path102 = []) => {
4039
4039
  for (const issue2 of error52.issues) {
4040
4040
  if (issue2.code === "invalid_union" && issue2.errors.length) {
4041
- issue2.errors.map((issues) => processError({ issues }, [...path101, ...issue2.path]));
4041
+ issue2.errors.map((issues) => processError({ issues }, [...path102, ...issue2.path]));
4042
4042
  } else if (issue2.code === "invalid_key") {
4043
- processError({ issues: issue2.issues }, [...path101, ...issue2.path]);
4043
+ processError({ issues: issue2.issues }, [...path102, ...issue2.path]);
4044
4044
  } else if (issue2.code === "invalid_element") {
4045
- processError({ issues: issue2.issues }, [...path101, ...issue2.path]);
4045
+ processError({ issues: issue2.issues }, [...path102, ...issue2.path]);
4046
4046
  } else {
4047
- const fullpath = [...path101, ...issue2.path];
4047
+ const fullpath = [...path102, ...issue2.path];
4048
4048
  if (fullpath.length === 0) {
4049
4049
  fieldErrors._errors.push(mapper(issue2));
4050
4050
  } else {
@@ -4071,17 +4071,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
4071
4071
  }
4072
4072
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
4073
4073
  const result = { errors: [] };
4074
- const processError = (error52, path101 = []) => {
4074
+ const processError = (error52, path102 = []) => {
4075
4075
  var _a3, _b;
4076
4076
  for (const issue2 of error52.issues) {
4077
4077
  if (issue2.code === "invalid_union" && issue2.errors.length) {
4078
- issue2.errors.map((issues) => processError({ issues }, [...path101, ...issue2.path]));
4078
+ issue2.errors.map((issues) => processError({ issues }, [...path102, ...issue2.path]));
4079
4079
  } else if (issue2.code === "invalid_key") {
4080
- processError({ issues: issue2.issues }, [...path101, ...issue2.path]);
4080
+ processError({ issues: issue2.issues }, [...path102, ...issue2.path]);
4081
4081
  } else if (issue2.code === "invalid_element") {
4082
- processError({ issues: issue2.issues }, [...path101, ...issue2.path]);
4082
+ processError({ issues: issue2.issues }, [...path102, ...issue2.path]);
4083
4083
  } else {
4084
- const fullpath = [...path101, ...issue2.path];
4084
+ const fullpath = [...path102, ...issue2.path];
4085
4085
  if (fullpath.length === 0) {
4086
4086
  result.errors.push(mapper(issue2));
4087
4087
  continue;
@@ -4113,8 +4113,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
4113
4113
  }
4114
4114
  function toDotPath(_path) {
4115
4115
  const segs = [];
4116
- const path101 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
4117
- for (const seg of path101) {
4116
+ const path102 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
4117
+ for (const seg of path102) {
4118
4118
  if (typeof seg === "number")
4119
4119
  segs.push(`[${seg}]`);
4120
4120
  else if (typeof seg === "symbol")
@@ -17617,13 +17617,13 @@ function resolveRef(ref, ctx) {
17617
17617
  if (!ref.startsWith("#")) {
17618
17618
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
17619
17619
  }
17620
- const path101 = ref.slice(1).split("/").filter(Boolean);
17621
- if (path101.length === 0) {
17620
+ const path102 = ref.slice(1).split("/").filter(Boolean);
17621
+ if (path102.length === 0) {
17622
17622
  return ctx.rootSchema;
17623
17623
  }
17624
17624
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
17625
- if (path101[0] === defsKey) {
17626
- const key = path101[1];
17625
+ if (path102[0] === defsKey) {
17626
+ const key = path102[1];
17627
17627
  if (!key || !ctx.defs[key]) {
17628
17628
  throw new Error(`Reference not found: ${ref}`);
17629
17629
  }
@@ -18457,17 +18457,17 @@ var init_newlines = __esm({
18457
18457
  });
18458
18458
 
18459
18459
  // packages/core/dist/core/tools/builtin/fileEvents.js
18460
- function fileReadEvent(path101, snapshotId) {
18461
- return { kind: "file.read", actor: { type: "tool" }, data: { path: path101, snapshotId } };
18460
+ function fileReadEvent(path102, snapshotId) {
18461
+ return { kind: "file.read", actor: { type: "tool" }, data: { path: path102, snapshotId } };
18462
18462
  }
18463
- function fileAppliedEvent(path101, snapshotId, bytes) {
18464
- return { kind: "file.applied", actor: { type: "tool" }, data: { path: path101, snapshotId, bytes } };
18463
+ function fileAppliedEvent(path102, snapshotId, bytes) {
18464
+ return { kind: "file.applied", actor: { type: "tool" }, data: { path: path102, snapshotId, bytes } };
18465
18465
  }
18466
- function fileRejectedEvent(path101, reason, hint) {
18466
+ function fileRejectedEvent(path102, reason, hint) {
18467
18467
  return {
18468
18468
  kind: "file.rejected",
18469
18469
  actor: { type: "tool" },
18470
- data: hint === void 0 ? { path: path101, reason } : { path: path101, reason, hint }
18470
+ data: hint === void 0 ? { path: path102, reason } : { path: path102, reason, hint }
18471
18471
  };
18472
18472
  }
18473
18473
  function reReadHint(reject) {
@@ -20336,11 +20336,11 @@ var init_tools = __esm({
20336
20336
  if (!ctx.addDocument)
20337
20337
  return "Knowledge vault tool not available.";
20338
20338
  const title = args["title"] || "New Document";
20339
- const path101 = args["path"] || `notes/${title.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
20339
+ const path102 = args["path"] || `notes/${title.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
20340
20340
  const content = args["content"] || "";
20341
20341
  const tags = args["tags"] || [];
20342
20342
  ctx.addDocument({
20343
- path: path101,
20343
+ path: path102,
20344
20344
  title,
20345
20345
  content,
20346
20346
  format: "markdown",
@@ -20349,7 +20349,7 @@ var init_tools = __esm({
20349
20349
  workspaceId: ctx.workspaceId
20350
20350
  });
20351
20351
  ctx.addActivity("vault", "created document", title);
20352
- return `Document "${title}" created at "${path101}".`;
20352
+ return `Document "${title}" created at "${path102}".`;
20353
20353
  }
20354
20354
  }
20355
20355
  ];
@@ -25287,16 +25287,16 @@ function runRetentionFromEnv() {
25287
25287
  maxTotalBytes: Number.isFinite(parseMb) && parseMb > 0 ? Math.round(parseMb * 1024 * 1024) : DEFAULT_RUN_RETENTION_MAX_MB * 1024 * 1024
25288
25288
  };
25289
25289
  }
25290
- async function dirSize(path101) {
25290
+ async function dirSize(path102) {
25291
25291
  let total = 0;
25292
25292
  let entries;
25293
25293
  try {
25294
- entries = await readdir(path101, { withFileTypes: true });
25294
+ entries = await readdir(path102, { withFileTypes: true });
25295
25295
  } catch {
25296
25296
  return 0;
25297
25297
  }
25298
25298
  for (const entry of entries) {
25299
- const child = join3(path101, entry.name);
25299
+ const child = join3(path102, entry.name);
25300
25300
  if (entry.isDirectory())
25301
25301
  total += await dirSize(child);
25302
25302
  else {
@@ -25323,19 +25323,19 @@ async function enforceRunRetention(runsDir, options = {}) {
25323
25323
  for (const entry of entries) {
25324
25324
  if (!entry.isDirectory())
25325
25325
  continue;
25326
- const path101 = join3(runsDir, entry.name);
25326
+ const path102 = join3(runsDir, entry.name);
25327
25327
  let startedAt = 0;
25328
25328
  let endedAt;
25329
25329
  let completed = false;
25330
25330
  try {
25331
- const manifest = JSON.parse(await readFile(join3(path101, "manifest.json"), "utf8"));
25331
+ const manifest = JSON.parse(await readFile(join3(path102, "manifest.json"), "utf8"));
25332
25332
  startedAt = manifest.startedAt ?? 0;
25333
25333
  endedAt = manifest.endedAt;
25334
25334
  completed = Boolean(endedAt) && manifest.status !== "running";
25335
25335
  } catch {
25336
25336
  completed = false;
25337
25337
  }
25338
- infos.push({ name: entry.name, path: path101, startedAt, endedAt, completed, bytes: await dirSize(path101) });
25338
+ infos.push({ name: entry.name, path: path102, startedAt, endedAt, completed, bytes: await dirSize(path102) });
25339
25339
  }
25340
25340
  const remove = async (info) => {
25341
25341
  await rm(info.path, { recursive: true, force: true });
@@ -25893,12 +25893,12 @@ var init_engine = __esm({
25893
25893
  * content digest) and the returned ref carries the event seq when the
25894
25894
  * emitter resolved one.
25895
25895
  */
25896
- async fsEvidence(observation, path101, sha2562, content, extra = {}) {
25896
+ async fsEvidence(observation, path102, sha2562, content, extra = {}) {
25897
25897
  const digest = sha2562 && content !== void 0 ? sha2562(content) : void 0;
25898
- const seq = await this.emitEvidence({ observation, path: path101, ...extra, ...digest ? { digest } : {} });
25898
+ const seq = await this.emitEvidence({ observation, path: path102, ...extra, ...digest ? { digest } : {} });
25899
25899
  return {
25900
25900
  tier: "fs-observation",
25901
- ref: path101,
25901
+ ref: path102,
25902
25902
  capturedAt: Date.now(),
25903
25903
  ...digest ? { digest } : {},
25904
25904
  ...seq !== void 0 ? { seq } : {}
@@ -32107,11 +32107,11 @@ var init_synthesisAudit = __esm({
32107
32107
  import { existsSync as existsSync10, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "node:fs";
32108
32108
  import { join as join5 } from "node:path";
32109
32109
  function loadNfrSpec(zelariRoot) {
32110
- const path101 = join5(zelariRoot, "nfr-spec.json");
32111
- if (!existsSync10(path101))
32110
+ const path102 = join5(zelariRoot, "nfr-spec.json");
32111
+ if (!existsSync10(path102))
32112
32112
  return null;
32113
32113
  try {
32114
- const raw = JSON.parse(readFileSync9(path101, "utf8"));
32114
+ const raw = JSON.parse(readFileSync9(path102, "utf8"));
32115
32115
  if (raw.version !== 1 || !Array.isArray(raw.targets))
32116
32116
  return null;
32117
32117
  return raw;
@@ -34512,9 +34512,9 @@ var init_types9 = __esm({
34512
34512
  import { readFileSync as readFileSync14 } from "node:fs";
34513
34513
  import { join as join11 } from "node:path";
34514
34514
  function readLessonsDeduped(zelariRoot) {
34515
- const path101 = join11(zelariRoot, LESSONS_FILE);
34515
+ const path102 = join11(zelariRoot, LESSONS_FILE);
34516
34516
  try {
34517
- const raw = readFileSync14(path101, "utf8");
34517
+ const raw = readFileSync14(path102, "utf8");
34518
34518
  const byId = /* @__PURE__ */ new Map();
34519
34519
  for (const line of raw.split(/\r?\n/)) {
34520
34520
  if (!line.trim())
@@ -34615,8 +34615,8 @@ function keywordsFrom(check2, signature) {
34615
34615
  return [.../* @__PURE__ */ new Set([...fromId, ...words])].slice(0, 12);
34616
34616
  }
34617
34617
  function writeLesson(zelariRoot, lesson) {
34618
- const path101 = join12(zelariRoot, LESSONS_FILE);
34619
- appendFileSync(path101, `${JSON.stringify(lesson)}
34618
+ const path102 = join12(zelariRoot, LESSONS_FILE);
34619
+ appendFileSync(path102, `${JSON.stringify(lesson)}
34620
34620
  `, "utf8");
34621
34621
  }
34622
34622
  function findSimilar(lessons, signature) {
@@ -36584,9 +36584,9 @@ function findCycle(nodes) {
36584
36584
  if (color.get(start) !== WHITE)
36585
36585
  continue;
36586
36586
  const stack = [[start, 0]];
36587
- const path101 = [];
36587
+ const path102 = [];
36588
36588
  color.set(start, GRAY);
36589
- path101.push(start);
36589
+ path102.push(start);
36590
36590
  while (stack.length > 0) {
36591
36591
  const top = stack[stack.length - 1];
36592
36592
  const [id3, idx] = top;
@@ -36599,17 +36599,17 @@ function findCycle(nodes) {
36599
36599
  continue;
36600
36600
  const c = color.get(dep);
36601
36601
  if (c === GRAY) {
36602
- const at = path101.indexOf(dep);
36603
- return [...path101.slice(at), dep];
36602
+ const at = path102.indexOf(dep);
36603
+ return [...path102.slice(at), dep];
36604
36604
  }
36605
36605
  if (c === WHITE) {
36606
36606
  color.set(dep, GRAY);
36607
- path101.push(dep);
36607
+ path102.push(dep);
36608
36608
  stack.push([dep, 0]);
36609
36609
  }
36610
36610
  } else {
36611
36611
  color.set(id3, BLACK);
36612
- path101.pop();
36612
+ path102.pop();
36613
36613
  stack.pop();
36614
36614
  }
36615
36615
  }
@@ -37529,8 +37529,8 @@ var init_runner = __esm({
37529
37529
  failed: [...this.tentaclesById.values()].filter((r) => r.status === "error"),
37530
37530
  pending: []
37531
37531
  };
37532
- const path101 = await this.host.saveSnapshot(snapshot, ".zelari/kraken/snapshots");
37533
- this.host.log(`checkpoint: ${label ?? "auto"} \u2192 ${path101}`);
37532
+ const path102 = await this.host.saveSnapshot(snapshot, ".zelari/kraken/snapshots");
37533
+ this.host.log(`checkpoint: ${label ?? "auto"} \u2192 ${path102}`);
37534
37534
  return snapshot;
37535
37535
  }
37536
37536
  callLog(msg, data) {
@@ -37559,18 +37559,22 @@ var init_runner = __esm({
37559
37559
  if (opts.cancelled)
37560
37560
  this.cancelled = true;
37561
37561
  const failed = [...this.tentaclesById.values()].filter((r) => r.status === "error");
37562
+ const unresolvedFindings = failed.map((r) => ({
37563
+ nodeId: r.id,
37564
+ label: r.label,
37565
+ reason: r.status === "error" ? "fail" : "unknown",
37566
+ findings: r.findings
37567
+ }));
37562
37568
  return {
37563
37569
  tentacles: this.tentaclesById,
37564
37570
  mergeCount: this.mergeCount,
37565
37571
  converged: opts.converged,
37572
+ // t55: distinguish "converged clean" from "converged degraded" — the
37573
+ // merge/exit semantics stay on `converged`; this is presentation data.
37574
+ convergedClean: opts.converged && unresolvedFindings.length === 0,
37566
37575
  cancelled: this.cancelled,
37567
37576
  durationMs: Date.now() - this.startTime,
37568
- unresolvedFindings: failed.map((r) => ({
37569
- nodeId: r.id,
37570
- label: r.label,
37571
- reason: r.status === "error" ? "fail" : "unknown",
37572
- findings: r.findings
37573
- }))
37577
+ unresolvedFindings
37574
37578
  };
37575
37579
  }
37576
37580
  };
@@ -38822,7 +38826,7 @@ var CORE_VERSION;
38822
38826
  var init_version = __esm({
38823
38827
  "packages/core/dist/version.js"() {
38824
38828
  "use strict";
38825
- CORE_VERSION = "2.38.0";
38829
+ CORE_VERSION = "2.39.0";
38826
38830
  }
38827
38831
  });
38828
38832
 
@@ -41304,9 +41308,9 @@ function spillToolOutput(fullText, meta3) {
41304
41308
  const rnd = randomBytes3(3).toString("hex");
41305
41309
  const safeTool = (meta3?.toolName ?? "tool").replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 32);
41306
41310
  const file2 = `${stamp}-${safeTool}-${hash3}-${rnd}.txt`;
41307
- const path101 = join14(dir, file2);
41308
- writeFileSync12(path101, fullText, "utf8");
41309
- return path101;
41311
+ const path102 = join14(dir, file2);
41312
+ writeFileSync12(path102, fullText, "utf8");
41313
+ return path102;
41310
41314
  } catch {
41311
41315
  return null;
41312
41316
  }
@@ -41352,10 +41356,10 @@ function truncateToolResult(text, capOrOpts = TOOL_RESULT_LINE_CAP) {
41352
41356
  ${tail2}`;
41353
41357
  }
41354
41358
  if (doSpill) {
41355
- const path101 = spillToolOutput(text, { toolName: opts.toolName });
41356
- if (path101) {
41359
+ const path102 = spillToolOutput(text, { toolName: opts.toolName });
41360
+ if (path102) {
41357
41361
  const spillNote = `
41358
- \u2026 [full output spilled to: ${path101} \u2014 re-read with read_file if you need the complete text] \u2026`;
41362
+ \u2026 [full output spilled to: ${path102} \u2014 re-read with read_file if you need the complete text] \u2026`;
41359
41363
  if (preview.includes("] \u2026\n")) {
41360
41364
  preview = preview.replace("] \u2026\n", `] \u2026${spillNote}
41361
41365
  `);
@@ -42158,28 +42162,28 @@ var init_storage = __esm({
42158
42162
  VALID_SCALARS = /^(true|false|null|~)$/i;
42159
42163
  Storage = class {
42160
42164
  /** Read a Markdown file with frontmatter. Throws if not found. */
42161
- read(path101) {
42162
- if (!existsSync19(path101)) {
42163
- throw new Error(`File not found: ${path101}`);
42165
+ read(path102) {
42166
+ if (!existsSync19(path102)) {
42167
+ throw new Error(`File not found: ${path102}`);
42164
42168
  }
42165
- const md = readFileSync17(path101, "utf8");
42169
+ const md = readFileSync17(path102, "utf8");
42166
42170
  return parseFrontmatter(md);
42167
42171
  }
42168
42172
  /** Read a Markdown file; returns null if not found. */
42169
- readIfExists(path101) {
42170
- if (!existsSync19(path101)) return null;
42171
- return this.read(path101);
42173
+ readIfExists(path102) {
42174
+ if (!existsSync19(path102)) return null;
42175
+ return this.read(path102);
42172
42176
  }
42173
42177
  /**
42174
42178
  * Write a Markdown file atomically (tmp + rename). Creates parent dirs.
42175
42179
  * The meta object is serialized as YAML frontmatter; body as Markdown.
42176
42180
  */
42177
- write(path101, meta3, body) {
42178
- mkdirSync10(dirname2(path101), { recursive: true });
42179
- const tmp = path101 + ".tmp-" + process.pid;
42181
+ write(path102, meta3, body) {
42182
+ mkdirSync10(dirname2(path102), { recursive: true });
42183
+ const tmp = path102 + ".tmp-" + process.pid;
42180
42184
  const md = serializeFrontmatter(meta3, body);
42181
42185
  writeFileSync14(tmp, md, "utf8");
42182
- renameSync2(tmp, path101);
42186
+ renameSync2(tmp, path102);
42183
42187
  }
42184
42188
  /** List all .md files in a directory (non-recursive). */
42185
42189
  listMarkdown(dir) {
@@ -42290,8 +42294,8 @@ function nextPlanTaskId(store6) {
42290
42294
  return `t${store6.counter}`;
42291
42295
  }
42292
42296
  function writePlanTaskArtifact(rootDir, task) {
42293
- const path101 = join17(rootDir, "plan-tasks", `${task.id}.md`);
42294
- mkdirSync11(dirname3(path101), { recursive: true });
42297
+ const path102 = join17(rootDir, "plan-tasks", `${task.id}.md`);
42298
+ mkdirSync11(dirname3(path102), { recursive: true });
42295
42299
  const meta3 = {
42296
42300
  kind: "task",
42297
42301
  id: task.id,
@@ -42312,7 +42316,7 @@ function writePlanTaskArtifact(rootDir, task) {
42312
42316
  task.notes?.trim() ? task.notes.trim() : "_(no notes)_",
42313
42317
  ""
42314
42318
  ].filter((l) => l !== null).join("\n");
42315
- new Storage().write(path101, meta3, body);
42319
+ new Storage().write(path102, meta3, body);
42316
42320
  }
42317
42321
  function loadHandle(rootDir) {
42318
42322
  const jsonPath = join17(rootDir, "plan.json");
@@ -45422,6 +45426,220 @@ var init_verifierRouting = __esm({
45422
45426
  }
45423
45427
  });
45424
45428
 
45429
+ // src/cli/kraken/exploreCoverage.ts
45430
+ var exploreCoverage_exports = {};
45431
+ __export(exploreCoverage_exports, {
45432
+ TENTACLE_SIDECAR_SEGMENTS: () => TENTACLE_SIDECAR_SEGMENTS,
45433
+ computeAndStoreExploreCoverage: () => computeAndStoreExploreCoverage,
45434
+ computeCoverage: () => computeCoverage,
45435
+ extractMentionedPaths: () => extractMentionedPaths,
45436
+ normalizePathToken: () => normalizePathToken,
45437
+ sanitizeNodeId: () => sanitizeNodeId,
45438
+ writeTentacleSidecar: () => writeTentacleSidecar
45439
+ });
45440
+ import { mkdir as mkdir3, readdir as readdir3, readFile as readFile7, writeFile as writeFile3 } from "node:fs/promises";
45441
+ import path48 from "node:path";
45442
+ function sanitizeNodeId(id3) {
45443
+ return id3.replace(/[^A-Za-z0-9._-]+/g, "-").slice(0, 80) || "node";
45444
+ }
45445
+ async function writeTentacleSidecar(cwd, sessionId2, nodeId, info) {
45446
+ try {
45447
+ const dir = sidecarDir(cwd, sessionId2);
45448
+ await mkdir3(dir, { recursive: true });
45449
+ const header = [
45450
+ `# tentacle ${nodeId}`,
45451
+ `agent: ${info.agent}`,
45452
+ info.thoroughness ? `thoroughness: ${info.thoroughness}` : null,
45453
+ info.model ? `model: ${info.model}` : null,
45454
+ typeof info.durationMs === "number" ? `durationMs: ${info.durationMs}` : null,
45455
+ info.worktree ? `worktree: ${info.worktree}` : null,
45456
+ ""
45457
+ ].filter((line) => line !== null).join("\n");
45458
+ const body = info.result.length > SIDECAR_CAP_CHARS ? info.result.slice(0, SIDECAR_CAP_CHARS) : info.result;
45459
+ await writeFile3(path48.join(dir, `${sanitizeNodeId(nodeId)}.md`), `${header}
45460
+ ${body}
45461
+ `, "utf8");
45462
+ } catch {
45463
+ }
45464
+ }
45465
+ function sidecarDir(cwd, sessionId2) {
45466
+ return path48.join(cwd, ...TENTACLE_SIDECAR_SEGMENTS, sanitizeNodeId(sessionId2));
45467
+ }
45468
+ function normalizePathToken(token, cwd) {
45469
+ if (!token) return null;
45470
+ let p3 = token.replace(/^[(`'"<[{]+/, "").replace(/[)`'"\]}>.,:;]+$/, "");
45471
+ p3 = p3.replace(/\\/g, "/");
45472
+ if (p3.length === 0) return null;
45473
+ if (p3.includes("://")) return null;
45474
+ if (!/\.[A-Za-z0-9]{1,8}$/.test(p3)) return null;
45475
+ const low = p3.toLowerCase();
45476
+ if (low.startsWith("node_modules/") || low.includes("/node_modules/")) return null;
45477
+ if (path48.isAbsolute(p3)) {
45478
+ const rel2 = path48.relative(cwd, p3);
45479
+ if (!rel2 || rel2.startsWith("..") || path48.isAbsolute(rel2)) return null;
45480
+ return rel2.split(path48.sep).join("/").toLowerCase();
45481
+ }
45482
+ return low.replace(/^[./]+/, "");
45483
+ }
45484
+ function extractMentionedPaths(text, cwd) {
45485
+ const out = /* @__PURE__ */ new Set();
45486
+ for (const match of text.match(PATH_TOKEN_RE) ?? []) {
45487
+ const normalized = normalizePathToken(match, cwd);
45488
+ if (normalized) out.add(normalized);
45489
+ }
45490
+ return out;
45491
+ }
45492
+ function computeCoverage(mentioned, touched) {
45493
+ if (touched.size === 0) return null;
45494
+ let covered = 0;
45495
+ for (const t of touched) if (mentioned.has(t)) covered += 1;
45496
+ return {
45497
+ mentionedCount: mentioned.size,
45498
+ touchedCount: touched.size,
45499
+ coveredCount: covered,
45500
+ ratio: covered / touched.size
45501
+ };
45502
+ }
45503
+ function declaredThoroughness(raw) {
45504
+ return /^thoroughness:\s*(\S+)/m.exec(raw)?.[1]?.trim().toLowerCase() ?? null;
45505
+ }
45506
+ async function computeAndStoreExploreCoverage(cwd, sessionId2) {
45507
+ try {
45508
+ const dir = sidecarDir(cwd, sessionId2);
45509
+ const files = await readdir3(dir).catch(() => []);
45510
+ const mentioned = /* @__PURE__ */ new Set();
45511
+ const touched = /* @__PURE__ */ new Set();
45512
+ const exploreModes = /* @__PURE__ */ new Set();
45513
+ let exploreModesUnknown = 0;
45514
+ for (const file2 of files) {
45515
+ if (!file2.endsWith(".md")) continue;
45516
+ const raw = await readFile7(path48.join(dir, file2), "utf8");
45517
+ const agent = /^agent:\s*(\S+)/m.exec(raw)?.[1] ?? "unknown";
45518
+ const paths = extractMentionedPaths(raw, cwd);
45519
+ if (agent === "explore") {
45520
+ for (const p3 of paths) mentioned.add(p3);
45521
+ const mode = declaredThoroughness(raw);
45522
+ if (mode) exploreModes.add(mode);
45523
+ else exploreModesUnknown += 1;
45524
+ } else if (agent === "general" || agent === "fix" || agent === "verify") {
45525
+ for (const p3 of paths) touched.add(p3);
45526
+ }
45527
+ }
45528
+ const coverage = computeCoverage(mentioned, touched);
45529
+ if (!coverage) return null;
45530
+ const report = {
45531
+ sessionId: sessionId2,
45532
+ mentioned: [...mentioned].sort(),
45533
+ touched: [...touched].sort(),
45534
+ covered: [...touched].filter((t) => mentioned.has(t)).sort(),
45535
+ ratio: coverage.ratio,
45536
+ computedAt: (/* @__PURE__ */ new Date()).toISOString(),
45537
+ // Additive: absent when nothing was declared (legacy sidecar headers).
45538
+ ...exploreModes.size > 0 ? { exploreModes: [...exploreModes].sort() } : {},
45539
+ ...exploreModesUnknown > 0 ? { exploreModesUnknown } : {}
45540
+ };
45541
+ await writeFile3(path48.join(dir, "coverage.json"), JSON.stringify(report, null, 2), "utf8");
45542
+ return report;
45543
+ } catch {
45544
+ return null;
45545
+ }
45546
+ }
45547
+ var TENTACLE_SIDECAR_SEGMENTS, SIDECAR_CAP_CHARS, PATH_TOKEN_RE;
45548
+ var init_exploreCoverage = __esm({
45549
+ "src/cli/kraken/exploreCoverage.ts"() {
45550
+ "use strict";
45551
+ TENTACLE_SIDECAR_SEGMENTS = [".zelari", "radio", "tentacles"];
45552
+ SIDECAR_CAP_CHARS = 16 * 1024;
45553
+ PATH_TOKEN_RE = /(?:[A-Za-z]:)?(?:[\w.-]*\/)+[\w.-]+\.[A-Za-z0-9]{1,8}/g;
45554
+ }
45555
+ });
45556
+
45557
+ // src/cli/kraken/verifyReask.ts
45558
+ var verifyReask_exports = {};
45559
+ __export(verifyReask_exports, {
45560
+ VERIFY_REASK_ENV: () => VERIFY_REASK_ENV,
45561
+ isVerifyReaskEnabled: () => isVerifyReaskEnabled,
45562
+ reaskVerifyTrailer: () => reaskVerifyTrailer
45563
+ });
45564
+ function isVerifyReaskEnabled(env = process.env) {
45565
+ const raw = env[VERIFY_REASK_ENV];
45566
+ if (raw === void 0 || raw === "") return true;
45567
+ return !(raw === "0" || raw === "false" || raw === "no");
45568
+ }
45569
+ async function reaskVerifyTrailer(priorOutput, options = {}) {
45570
+ const env = options.env ?? process.env;
45571
+ if (!isVerifyReaskEnabled(env)) return null;
45572
+ if (typeof priorOutput !== "string" || priorOutput.trim() === "") return null;
45573
+ const provider = options.providerOverride ?? await resolveActiveProvider(env);
45574
+ if (!provider) return null;
45575
+ const capped = priorOutput.length > PRIOR_OUTPUT_CAP_CHARS ? priorOutput.slice(priorOutput.length - PRIOR_OUTPUT_CAP_CHARS) : priorOutput;
45576
+ try {
45577
+ const fetchImpl = options.fetchImpl ?? fetch;
45578
+ const ac = new AbortController();
45579
+ const timer = setTimeout(() => ac.abort(), REASK_TIMEOUT_MS);
45580
+ let response;
45581
+ try {
45582
+ response = await fetchImpl(provider.endpoint, {
45583
+ method: "POST",
45584
+ headers: {
45585
+ "Content-Type": "application/json",
45586
+ Authorization: `Bearer ${provider.apiKey}`
45587
+ },
45588
+ body: JSON.stringify({
45589
+ model: provider.model,
45590
+ messages: [
45591
+ { role: "system", content: REASK_SYSTEM_PROMPT },
45592
+ { role: "user", content: capped }
45593
+ ],
45594
+ temperature: 0,
45595
+ stream: false
45596
+ }),
45597
+ signal: ac.signal
45598
+ });
45599
+ } finally {
45600
+ clearTimeout(timer);
45601
+ }
45602
+ if (!response.ok) return null;
45603
+ const json3 = await response.json();
45604
+ const raw = json3.choices?.[0]?.message?.content;
45605
+ if (typeof raw !== "string") return null;
45606
+ const { verdict } = parseVerifyVerdict(raw);
45607
+ return verdict === "pass" || verdict === "fail" ? verdict : null;
45608
+ } catch {
45609
+ return null;
45610
+ }
45611
+ }
45612
+ async function resolveActiveProvider(env) {
45613
+ const cfg = await getProviderConfig();
45614
+ if (!cfg) return null;
45615
+ const providerId = cfg.activeProviderId;
45616
+ const key = await resolveApiKeyWithMeta(providerId, env);
45617
+ if (!key?.apiKey) return null;
45618
+ const model = getModelForProvider(providerId) ?? cfg.modelByProvider[providerId] ?? "";
45619
+ const endpoint = getCustomEndpoint(providerId) ?? `https://api.openai.com/v1/chat/completions`;
45620
+ return { providerId, model, endpoint, apiKey: key.apiKey };
45621
+ }
45622
+ var VERIFY_REASK_ENV, REASK_TIMEOUT_MS, PRIOR_OUTPUT_CAP_CHARS, REASK_SYSTEM_PROMPT;
45623
+ var init_verifyReask = __esm({
45624
+ "src/cli/kraken/verifyReask.ts"() {
45625
+ "use strict";
45626
+ init_dist();
45627
+ init_providerConfig();
45628
+ init_keyStore();
45629
+ VERIFY_REASK_ENV = "ZELARI_KRAKEN_VERIFY_REASK";
45630
+ REASK_TIMEOUT_MS = 12e3;
45631
+ PRIOR_OUTPUT_CAP_CHARS = 8e3;
45632
+ REASK_SYSTEM_PROMPT = [
45633
+ "You are a verdict-normalization helper.",
45634
+ "The message below is a code-review verify report whose final verdict trailer line is missing or malformed.",
45635
+ "Re-read the report and emit, as the LAST line, ONLY the verdict the report already supports:",
45636
+ "`VERDICT: PASS` or `VERDICT: FAIL`.",
45637
+ "Do not re-review the work, do not add commentary.",
45638
+ "If the report genuinely supports neither verdict, emit `VERDICT: UNKNOWN`."
45639
+ ].join(" ");
45640
+ }
45641
+ });
45642
+
45425
45643
  // src/cli/kraken/weaknessMeter.ts
45426
45644
  var weaknessMeter_exports = {};
45427
45645
  __export(weaknessMeter_exports, {
@@ -45449,7 +45667,7 @@ async function measureWeaknessViaLLM(text, options = {}) {
45449
45667
  const env = options.env ?? process.env;
45450
45668
  if (!isWeaknessMeterEnabled(env)) return null;
45451
45669
  if (typeof text !== "string" || text.trim() === "") return null;
45452
- const provider = options.providerOverride ?? await resolveActiveProvider(env);
45670
+ const provider = options.providerOverride ?? await resolveActiveProvider2(env);
45453
45671
  if (!provider) return null;
45454
45672
  const model = options.modelOverride ?? resolveMeterModel(env, provider.model);
45455
45673
  const userPayload = JSON.stringify({
@@ -45515,7 +45733,7 @@ function parseMeterContent(raw, model, durationMs) {
45515
45733
  model
45516
45734
  };
45517
45735
  }
45518
- async function resolveActiveProvider(env) {
45736
+ async function resolveActiveProvider2(env) {
45519
45737
  const cfg = await getProviderConfig();
45520
45738
  if (!cfg) return null;
45521
45739
  const providerId = cfg.activeProviderId;
@@ -45569,7 +45787,7 @@ __export(executor_exports, {
45569
45787
  thoroughnessForKind: () => thoroughnessForKind
45570
45788
  });
45571
45789
  import { existsSync as existsSync25 } from "node:fs";
45572
- import path48 from "node:path";
45790
+ import path49 from "node:path";
45573
45791
  async function defaultSymbolExtractor(file2) {
45574
45792
  if (!isAstSupported(file2)) return null;
45575
45793
  const r = await parseFileSymbolsDiag(file2);
@@ -45635,7 +45853,7 @@ function isWorldModelGateEnabled(cwd, env = process.env, checksExists = defaultC
45635
45853
  }
45636
45854
  function defaultChecksExists(cwd) {
45637
45855
  try {
45638
- return existsSync25(path48.join(cwd, ".zelari", "world", "checks.json"));
45856
+ return existsSync25(path49.join(cwd, ".zelari", "world", "checks.json"));
45639
45857
  } catch {
45640
45858
  return false;
45641
45859
  }
@@ -45921,13 +46139,13 @@ var init_executor = __esm({
45921
46139
  const { id: id3, res } = await Promise.race(inFlight.values());
45922
46140
  inFlight.delete(id3);
45923
46141
  const settledNode = graph.nodes.get(id3);
45924
- if (settledNode) this.applyResult(graph, settledNode, res);
46142
+ if (settledNode) await this.applyResultWithReask(graph, settledNode, res);
45925
46143
  updateKrakenGraphLive(graph);
45926
46144
  }
45927
46145
  if (inFlight.size > 0) {
45928
46146
  for (const { id: id3, res } of await Promise.all(inFlight.values())) {
45929
46147
  const node = graph.nodes.get(id3);
45930
- if (node) this.applyResult(graph, node, res);
46148
+ if (node) await this.applyResultWithReask(graph, node, res);
45931
46149
  }
45932
46150
  inFlight.clear();
45933
46151
  }
@@ -45939,6 +46157,8 @@ var init_executor = __esm({
45939
46157
  }
45940
46158
  let backtest;
45941
46159
  const converged = !this.aborted && isConverged(graph);
46160
+ const unresolvedCount = this.unresolved.length;
46161
+ const convergedClean = converged && unresolvedCount === 0;
45942
46162
  if (converged) {
45943
46163
  const gateOn = this.worldModelGateOverride ?? isWorldModelGateEnabled(this.parentCwd);
45944
46164
  if (gateOn) {
@@ -45946,7 +46166,10 @@ var init_executor = __esm({
45946
46166
  }
45947
46167
  this.radio("graph_converged", {
45948
46168
  description: "graph executor",
45949
- detail: backtest ? `backtest: ${backtest.passed}/${backtest.total} passed` : void 0,
46169
+ detail: [
46170
+ backtest ? `backtest: ${backtest.passed}/${backtest.total} passed` : void 0,
46171
+ convergedClean ? void 0 : `degraded: ${unresolvedCount} unresolved`
46172
+ ].filter((part) => part !== void 0).join(" \u2014 ") || void 0,
45950
46173
  ok: backtest ? backtest.ok : true
45951
46174
  });
45952
46175
  } else {
@@ -45958,7 +46181,7 @@ var init_executor = __esm({
45958
46181
  }
45959
46182
  endKrakenGraphLive(graph, converged);
45960
46183
  this.wb?.logEvent(
45961
- converged ? "graph_converged" : `graph_failed: ${this.aborted ? "cancelled" : failedNodeIds(graph).join(", ") || "none"}`
46184
+ converged ? convergedClean ? "graph_converged" : `graph_converged (degraded: ${unresolvedCount} unresolved)` : `graph_failed: ${this.aborted ? "cancelled" : failedNodeIds(graph).join(", ") || "none"}`
45962
46185
  );
45963
46186
  await this.wb?.flush();
45964
46187
  this.wb?.close();
@@ -45971,9 +46194,25 @@ var init_executor = __esm({
45971
46194
  unresolvedFindings: this.unresolved
45972
46195
  })
45973
46196
  );
46197
+ void (async () => {
46198
+ try {
46199
+ const { computeAndStoreExploreCoverage: computeAndStoreExploreCoverage2 } = await Promise.resolve().then(() => (init_exploreCoverage(), exploreCoverage_exports));
46200
+ const report = await computeAndStoreExploreCoverage2(this.parentCwd, this.sessionId);
46201
+ if (report) {
46202
+ this.radio("node_meter", {
46203
+ description: "explore coverage",
46204
+ agent: "coverage",
46205
+ detail: `touched=${report.touched.length} covered=${report.covered.length} ratio=${report.ratio.toFixed(2)}`,
46206
+ ok: true
46207
+ });
46208
+ }
46209
+ } catch {
46210
+ }
46211
+ })();
45974
46212
  return {
45975
46213
  graph,
45976
46214
  converged,
46215
+ convergedClean,
45977
46216
  failedNodeIds: failedNodeIds(graph),
45978
46217
  counts: countByStatus(graph),
45979
46218
  durationsMs: Object.fromEntries(this.durationsMs),
@@ -46146,7 +46385,7 @@ var init_executor = __esm({
46146
46385
  try {
46147
46386
  const summary = aggregate(
46148
46387
  records,
46149
- { repo: path48.basename(this.parentCwd), role: agentForNode(node) },
46388
+ { repo: path49.basename(this.parentCwd), role: agentForNode(node) },
46150
46389
  now
46151
46390
  );
46152
46391
  sample = summary.sample;
@@ -46507,12 +46746,29 @@ ${upstream}` : node.prompt,
46507
46746
  worktreeHandle: null
46508
46747
  };
46509
46748
  }
46749
+ /**
46750
+ * t56: settle a node, running the minimal one-shot trailer re-ask FIRST
46751
+ * when a verify's verdict failed to parse. The re-ask is a single
46752
+ * no-tools completion on the reviewer's own prior output (weaknessMeter
46753
+ * pattern), so "one re-ask" costs a trailer line, not a second verify.
46754
+ * Every non-unknown path is byte-identical to the old `applyResult`.
46755
+ */
46756
+ async applyResultWithReask(graph, node, res) {
46757
+ let verifyOverride;
46758
+ if (node.kind === "verify" && res.ok && typeof res.result === "string") {
46759
+ const pre = parseVerifyVerdict(res.result);
46760
+ if (pre.verdict === "unknown") {
46761
+ verifyOverride = await this.maybeReaskUnknownVerdict(node);
46762
+ }
46763
+ }
46764
+ this.applyResult(graph, node, res, verifyOverride);
46765
+ }
46510
46766
  /** Apply a tentacle result to its node: success, retry, fix-spawn, or terminal failure. */
46511
- applyResult(graph, node, res) {
46512
- this.applyResultInner(graph, node, res);
46767
+ applyResult(graph, node, res, verifyOverride) {
46768
+ this.applyResultInner(graph, node, res, verifyOverride);
46513
46769
  this.recordNodeReputation(node, res);
46514
46770
  }
46515
- applyResultInner(graph, node, res) {
46771
+ applyResultInner(graph, node, res, verifyOverride) {
46516
46772
  if (res.ok) {
46517
46773
  if (res.memoryId) this.memoryIds.set(node.id, res.memoryId);
46518
46774
  node.status = "done";
@@ -46526,7 +46782,7 @@ ${upstream}` : node.prompt,
46526
46782
  ...res.model && res.model !== "n/a" ? { model: res.model } : {}
46527
46783
  });
46528
46784
  this.reconcileRepairedNode(graph, node);
46529
- if (node.kind === "verify") this.applyVerifyVerdict(graph, node);
46785
+ if (node.kind === "verify") this.applyVerifyVerdict(graph, node, verifyOverride);
46530
46786
  return;
46531
46787
  }
46532
46788
  node.error = res.error;
@@ -46623,7 +46879,7 @@ ${upstream}` : node.prompt,
46623
46879
  const model = res.ok && res.model && res.model !== "n/a" ? res.model : null;
46624
46880
  const reviewerVerdict = res.ok && this.isReviewerKind(node.kind) && typeof node.result === "string" && node.result.length > 0 ? parseVerifyVerdict(node.result).verdict : null;
46625
46881
  const record2 = reputationRecordFromNodeRun({
46626
- repo: path48.basename(this.parentCwd),
46882
+ repo: path49.basename(this.parentCwd),
46627
46883
  role: agentForNode(node),
46628
46884
  kind: node.kind,
46629
46885
  ok: res.ok,
@@ -46763,8 +47019,37 @@ ${upstream}` : node.prompt,
46763
47019
  * every graph — but it is recorded, because a gate that has silently stopped
46764
47020
  * working is worse than no gate.
46765
47021
  */
46766
- applyVerifyVerdict(graph, verify) {
46767
- const { verdict, findings } = parseVerifyVerdict(verify.result);
47022
+ /**
47023
+ * t56 ONE minimal re-ask for an `unknown` verify verdict: a single
47024
+ * no-tools completion on the reviewer's own prior output (weaknessMeter
47025
+ * pattern), parsed with the SAME single-source parser. Default ON,
47026
+ * opt-out ZELARI_KRAKEN_VERIFY_REASK=0. Returns undefined when disabled
47027
+ * or failed — the existing unknown-flow is then unchanged. The node's
47028
+ * raw result is never rewritten; audit sees the original verbatim.
47029
+ */
47030
+ async maybeReaskUnknownVerdict(verify) {
47031
+ let reask;
47032
+ try {
47033
+ reask = await Promise.resolve().then(() => (init_verifyReask(), verifyReask_exports));
47034
+ } catch {
47035
+ return void 0;
47036
+ }
47037
+ const text = typeof verify.result === "string" ? verify.result : "";
47038
+ if (text.length === 0) return void 0;
47039
+ const verdict = await reask.reaskVerifyTrailer(text);
47040
+ if (verdict !== "pass" && verdict !== "fail") return void 0;
47041
+ this.radio("node_end", {
47042
+ description: verify.label,
47043
+ agent: "verify",
47044
+ detail: `unknown verdict recovered via one-shot re-ask \u2192 ${verdict.toUpperCase()}`,
47045
+ ok: true
47046
+ });
47047
+ return verdict;
47048
+ }
47049
+ applyVerifyVerdict(graph, verify, reaskedVerdict) {
47050
+ const parsed = parseVerifyVerdict(verify.result);
47051
+ const verdict = parsed.verdict === "unknown" && (reaskedVerdict === "pass" || reaskedVerdict === "fail") ? reaskedVerdict : parsed.verdict;
47052
+ const findings = parsed.findings;
46768
47053
  if (verdict === "pass") return;
46769
47054
  const writer = this.writerBehind(verify, graph);
46770
47055
  if (!writer) return;
@@ -47653,6 +47938,18 @@ ${verifyHintForGeneral(args.acceptance)}`;
47653
47938
  durationMs,
47654
47939
  ok: true
47655
47940
  });
47941
+ try {
47942
+ const { writeTentacleSidecar: writeTentacleSidecar2 } = await Promise.resolve().then(() => (init_exploreCoverage(), exploreCoverage_exports));
47943
+ await writeTentacleSidecar2(parentCwd, sessionId2, opts.nodeId ?? liveId, {
47944
+ agent,
47945
+ thoroughness,
47946
+ model: sub.model,
47947
+ durationMs,
47948
+ result,
47949
+ worktree: worktree?.path ?? null
47950
+ });
47951
+ } catch {
47952
+ }
47656
47953
  let memoryId;
47657
47954
  if (deps.memoryService && deps.memoryAutoWrite !== false) {
47658
47955
  try {
@@ -49792,7 +50089,7 @@ var init_planTaskTools = __esm({
49792
50089
 
49793
50090
  // src/cli/tools/inspectTypecheckSafety.ts
49794
50091
  import { promises as fs21 } from "node:fs";
49795
- import path49 from "node:path";
50092
+ import path50 from "node:path";
49796
50093
  import { spawn as spawn9 } from "node:child_process";
49797
50094
  async function scanTsbuildinfo(root) {
49798
50095
  const found = [];
@@ -49806,11 +50103,11 @@ async function scanTsbuildinfo(root) {
49806
50103
  continue;
49807
50104
  }
49808
50105
  for (const entry of entries) {
49809
- const p3 = path49.join(dir, entry.name);
50106
+ const p3 = path50.join(dir, entry.name);
49810
50107
  if (entry.isDirectory()) {
49811
50108
  if (!SCAN_SKIP.has(entry.name)) stack.push(p3);
49812
50109
  } else if (entry.name.endsWith(".tsbuildinfo")) {
49813
- found.push(path49.relative(root, p3).split(path49.sep).join("/"));
50110
+ found.push(path50.relative(root, p3).split(path50.sep).join("/"));
49814
50111
  }
49815
50112
  }
49816
50113
  }
@@ -49846,7 +50143,7 @@ async function cleanupArtifacts(root, relPaths) {
49846
50143
  const failed = [];
49847
50144
  for (const rel2 of relPaths) {
49848
50145
  try {
49849
- await fs21.unlink(path49.join(root, rel2));
50146
+ await fs21.unlink(path50.join(root, rel2));
49850
50147
  cleaned.push(rel2);
49851
50148
  } catch {
49852
50149
  failed.push(rel2);
@@ -49873,13 +50170,13 @@ import { spawn as spawn10 } from "node:child_process";
49873
50170
  import { createHash as createHash14 } from "node:crypto";
49874
50171
  import { existsSync as existsSync28, promises as fs22 } from "node:fs";
49875
50172
  import os2 from "node:os";
49876
- import path50 from "node:path";
50173
+ import path51 from "node:path";
49877
50174
  function resolveNodeModuleBin(start, rel2) {
49878
- let dir = path50.resolve(start);
50175
+ let dir = path51.resolve(start);
49879
50176
  for (; ; ) {
49880
- const candidate = path50.join(dir, "node_modules", rel2);
50177
+ const candidate = path51.join(dir, "node_modules", rel2);
49881
50178
  if (existsSync28(candidate)) return candidate;
49882
- const parent = path50.dirname(dir);
50179
+ const parent = path51.dirname(dir);
49883
50180
  if (parent === dir) return void 0;
49884
50181
  dir = parent;
49885
50182
  }
@@ -49947,7 +50244,7 @@ function buildInspectCommand(op, ctx) {
49947
50244
  case "npm_ls":
49948
50245
  case "npm_outdated":
49949
50246
  case "npm_view": {
49950
- const npmCli = ctx.npmCliPath ?? resolveNodeModuleBin(ctx.root, path50.join("npm", "bin", "npm-cli.js")) ?? path50.join(ctx.root, "node_modules", "npm", "bin", "npm-cli.js");
50247
+ const npmCli = ctx.npmCliPath ?? resolveNodeModuleBin(ctx.root, path51.join("npm", "bin", "npm-cli.js")) ?? path51.join(ctx.root, "node_modules", "npm", "bin", "npm-cli.js");
49951
50248
  if (op.operation === "npm_view") {
49952
50249
  const err = rejectFlagLike("package", op.package);
49953
50250
  if (err) return { ok: false, reason: err };
@@ -49956,14 +50253,14 @@ function buildInspectCommand(op, ctx) {
49956
50253
  return { ok: true, command: process.execPath, argv: [npmCli, ...sub], inspectionClass: "env-info" };
49957
50254
  }
49958
50255
  case "typecheck": {
49959
- const project = path50.resolve(ctx.cwd, op.project ?? "tsconfig.json");
50256
+ const project = path51.resolve(ctx.cwd, op.project ?? "tsconfig.json");
49960
50257
  const hash3 = createHash14("sha256").update(project).digest("hex").slice(0, 16);
49961
- const tsBuildInfoFile = path50.join(os2.tmpdir(), "zelari-inspect", `${hash3}.tsbuildinfo`);
50258
+ const tsBuildInfoFile = path51.join(os2.tmpdir(), "zelari-inspect", `${hash3}.tsbuildinfo`);
49962
50259
  return {
49963
50260
  ok: true,
49964
50261
  command: process.execPath,
49965
50262
  argv: [
49966
- ctx.tscPath ?? resolveNodeModuleBin(ctx.root, path50.join("typescript", "bin", "tsc")) ?? resolveNodeModuleBin(ctx.cwd, path50.join("typescript", "bin", "tsc")) ?? path50.join(ctx.root, "node_modules", "typescript", "bin", "tsc"),
50263
+ ctx.tscPath ?? resolveNodeModuleBin(ctx.root, path51.join("typescript", "bin", "tsc")) ?? resolveNodeModuleBin(ctx.cwd, path51.join("typescript", "bin", "tsc")) ?? path51.join(ctx.root, "node_modules", "typescript", "bin", "tsc"),
49967
50264
  "--noEmit",
49968
50265
  // S3.5 primary mechanism: redirect, never disable — composite forces
49969
50266
  // incremental (TS#30661), so --incremental false would break on the
@@ -50931,9 +51228,9 @@ var init_client = __esm({
50931
51228
  });
50932
51229
 
50933
51230
  // src/cli/lsp/servers.ts
50934
- import path51 from "node:path";
51231
+ import path52 from "node:path";
50935
51232
  function languageIdForFile(file2) {
50936
- const ext = path51.extname(file2).toLowerCase();
51233
+ const ext = path52.extname(file2).toLowerCase();
50937
51234
  const map2 = {
50938
51235
  ".ts": "typescript",
50939
51236
  ".tsx": "typescriptreact",
@@ -50948,7 +51245,7 @@ function languageIdForFile(file2) {
50948
51245
  return map2[ext] ?? "plaintext";
50949
51246
  }
50950
51247
  function serverForFile(file2, servers = LSP_SERVERS) {
50951
- const ext = path51.extname(file2).toLowerCase();
51248
+ const ext = path52.extname(file2).toLowerCase();
50952
51249
  return servers.find((s) => s.extensions.includes(ext)) ?? null;
50953
51250
  }
50954
51251
  function resolveServerCommand(file2, cwd, servers = LSP_SERVERS) {
@@ -50999,7 +51296,7 @@ var init_servers = __esm({
50999
51296
  // src/cli/lsp/manager.ts
51000
51297
  import { spawn as spawn11 } from "node:child_process";
51001
51298
  import { readFileSync as readFileSync20 } from "node:fs";
51002
- import path52 from "node:path";
51299
+ import path53 from "node:path";
51003
51300
  function processTransport(child) {
51004
51301
  return {
51005
51302
  send: (data) => {
@@ -51016,7 +51313,7 @@ function processTransport(child) {
51016
51313
  };
51017
51314
  }
51018
51315
  function getSharedLspManager(cwd = process.cwd()) {
51019
- const key = path52.resolve(cwd);
51316
+ const key = path53.resolve(cwd);
51020
51317
  const existing = sharedByRoot.get(key);
51021
51318
  if (existing) return existing;
51022
51319
  const manager = new LspManager({ cwd });
@@ -51493,11 +51790,11 @@ var init_store2 = __esm({
51493
51790
 
51494
51791
  // src/cli/semantic/index.ts
51495
51792
  import { promises as fs23, existsSync as existsSync29, readFileSync as readFileSync21 } from "node:fs";
51496
- import path53 from "node:path";
51793
+ import path54 from "node:path";
51497
51794
  import { createHash as createHash15 } from "node:crypto";
51498
51795
  function getIndexPath(root) {
51499
- const hash3 = createHash15("sha1").update(path53.resolve(root)).digest("hex").slice(0, 16);
51500
- return process.env.ZELARI_SEMANTIC_FILE ?? path53.join(semanticStateDir(), `${hash3}.json`);
51796
+ const hash3 = createHash15("sha1").update(path54.resolve(root)).digest("hex").slice(0, 16);
51797
+ return process.env.ZELARI_SEMANTIC_FILE ?? path54.join(semanticStateDir(), `${hash3}.json`);
51501
51798
  }
51502
51799
  async function collectSourceFiles(root, maxFiles = 1500) {
51503
51800
  const out = [];
@@ -51515,11 +51812,11 @@ async function collectSourceFiles(root, maxFiles = 1500) {
51515
51812
  if (entry.isDirectory() && IGNORE_DIRS.has(entry.name)) continue;
51516
51813
  if (entry.isDirectory()) continue;
51517
51814
  }
51518
- const full = path53.join(dir, entry.name);
51815
+ const full = path54.join(dir, entry.name);
51519
51816
  if (entry.isDirectory()) {
51520
51817
  if (IGNORE_DIRS.has(entry.name)) continue;
51521
51818
  await walk2(full);
51522
- } else if (SOURCE_EXTENSIONS.has(path53.extname(entry.name).toLowerCase())) {
51819
+ } else if (SOURCE_EXTENSIONS.has(path54.extname(entry.name).toLowerCase())) {
51523
51820
  out.push(full);
51524
51821
  }
51525
51822
  }
@@ -51568,7 +51865,7 @@ async function buildIndex(files, embed, options) {
51568
51865
  }
51569
51866
  async function saveIndex(root, data) {
51570
51867
  const file2 = getIndexPath(root);
51571
- await fs23.mkdir(path53.dirname(file2), { recursive: true });
51868
+ await fs23.mkdir(path54.dirname(file2), { recursive: true });
51572
51869
  const tmp = `${file2}.tmp-${process.pid}`;
51573
51870
  await fs23.writeFile(tmp, JSON.stringify(data), "utf8");
51574
51871
  await fs23.rename(tmp, file2);
@@ -51661,7 +51958,7 @@ __export(openai_compatible_exports, {
51661
51958
  providerFromEnv: () => providerFromEnv,
51662
51959
  readChunkWithTimeout: () => readChunkWithTimeout,
51663
51960
  resetTextOnlyVisionMemory: () => resetTextOnlyVisionMemory,
51664
- resolveActiveProvider: () => resolveActiveProvider2,
51961
+ resolveActiveProvider: () => resolveActiveProvider3,
51665
51962
  resolveBaseUrl: () => resolveBaseUrl,
51666
51963
  resolveStreamTimeouts: () => resolveStreamTimeouts
51667
51964
  });
@@ -51801,7 +52098,7 @@ function modelSupportsVision(model, probe) {
51801
52098
  function dataUriFromImage(img) {
51802
52099
  return `data:${img.mime};base64,${img.dataBase64}`;
51803
52100
  }
51804
- function resolveActiveProvider2() {
52101
+ function resolveActiveProvider3() {
51805
52102
  return getProviderConfig().activeProviderId;
51806
52103
  }
51807
52104
  function parseCachedPromptTokens(usage) {
@@ -52273,7 +52570,7 @@ function extraFromStored(providerId) {
52273
52570
  };
52274
52571
  }
52275
52572
  async function providerFromEnv() {
52276
- const providerId = resolveActiveProvider2();
52573
+ const providerId = resolveActiveProvider3();
52277
52574
  const apiKey = await resolveApiKeyWithMeta(providerId);
52278
52575
  if (!apiKey) return null;
52279
52576
  return {
@@ -52450,7 +52747,7 @@ var init_provider = __esm({
52450
52747
  });
52451
52748
 
52452
52749
  // src/cli/semantic/tools.ts
52453
- import path54 from "node:path";
52750
+ import path55 from "node:path";
52454
52751
  function createSemanticTool(deps) {
52455
52752
  const buildEmbedFn = deps.buildEmbedFn ?? buildProviderEmbedFn;
52456
52753
  return {
@@ -52477,7 +52774,7 @@ function createSemanticTool(deps) {
52477
52774
  return typedOk({
52478
52775
  count: res.hits.length,
52479
52776
  results: res.hits.map((h) => ({
52480
- location: `${path54.relative(deps.root, h.file) || h.file}:${h.startLine}-${h.endLine}`,
52777
+ location: `${path55.relative(deps.root, h.file) || h.file}:${h.startLine}-${h.endLine}`,
52481
52778
  score: Number(h.score.toFixed(3)),
52482
52779
  preview: h.text.length > 400 ? `${h.text.slice(0, 400)}\u2026` : h.text
52483
52780
  }))
@@ -52497,7 +52794,7 @@ var init_tools4 = __esm({
52497
52794
 
52498
52795
  // src/cli/browser/driver.ts
52499
52796
  import { createRequire as createRequire2 } from "node:module";
52500
- import path55 from "node:path";
52797
+ import path56 from "node:path";
52501
52798
  import { pathToFileURL } from "node:url";
52502
52799
  function asPlaywright(mod) {
52503
52800
  if (!mod || typeof mod !== "object") return null;
@@ -52508,10 +52805,10 @@ function asPlaywright(mod) {
52508
52805
  return null;
52509
52806
  }
52510
52807
  async function loadPlaywright(cwd) {
52511
- const base2 = cwd && cwd.length > 0 ? path55.resolve(cwd) : void 0;
52808
+ const base2 = cwd && cwd.length > 0 ? path56.resolve(cwd) : void 0;
52512
52809
  if (base2) {
52513
52810
  try {
52514
- const req = createRequire2(path55.join(base2, "package.json"));
52811
+ const req = createRequire2(path56.join(base2, "package.json"));
52515
52812
  const resolved = req.resolve("playwright");
52516
52813
  const mod = await import(pathToFileURL(resolved).href);
52517
52814
  const pw = asPlaywright(mod);
@@ -52726,14 +53023,14 @@ var init_driver = __esm({
52726
53023
  });
52727
53024
 
52728
53025
  // src/cli/browser/tools.ts
52729
- import path56 from "node:path";
53026
+ import path57 from "node:path";
52730
53027
  import os3 from "node:os";
52731
- import { readFile as readFile7 } from "node:fs/promises";
53028
+ import { readFile as readFile8 } from "node:fs/promises";
52732
53029
  async function loadImageBlock(filePath) {
52733
53030
  try {
52734
- const buf = await readFile7(filePath);
53031
+ const buf = await readFile8(filePath);
52735
53032
  if (buf.byteLength > SCREENSHOT_MAX_BYTES) return void 0;
52736
- return { mime: "image/png", dataBase64: buf.toString("base64"), alt: path56.basename(filePath) };
53033
+ return { mime: "image/png", dataBase64: buf.toString("base64"), alt: path57.basename(filePath) };
52737
53034
  } catch {
52738
53035
  return void 0;
52739
53036
  }
@@ -52755,7 +53052,7 @@ function createBrowserTool(deps = {}) {
52755
53052
  execute: async (args, ctx) => {
52756
53053
  const a = args;
52757
53054
  const dir = deps.screenshotDir ?? os3.tmpdir();
52758
- const screenshotPath = a.screenshot === false ? void 0 : path56.join(dir, `zelari-browser-${Date.now()}.png`);
53055
+ const screenshotPath = a.screenshot === false ? void 0 : path57.join(dir, `zelari-browser-${Date.now()}.png`);
52759
53056
  const result = await runBrowserCheck(
52760
53057
  {
52761
53058
  url: a.url,
@@ -52833,8 +53130,8 @@ var init_tools5 = __esm({
52833
53130
 
52834
53131
  // src/cli/tools/screenshotTool.ts
52835
53132
  import { execFile as execFile6 } from "node:child_process";
52836
- import { mkdir as mkdir3, readFile as readFile8, stat as stat7 } from "node:fs/promises";
52837
- import path57 from "node:path";
53133
+ import { mkdir as mkdir4, readFile as readFile9, stat as stat7 } from "node:fs/promises";
53134
+ import path58 from "node:path";
52838
53135
  import { promisify as promisify5 } from "node:util";
52839
53136
  async function captureWindows(target) {
52840
53137
  const script = `Add-Type -AssemblyName System.Windows.Forms,System.Drawing;$b=[System.Windows.Forms.SystemInformation]::VirtualScreen;$bmp=New-Object System.Drawing.Bitmap $b.Width,$b.Height;$g=[System.Drawing.Graphics]::FromImage($bmp);$g.CopyFromScreen($b.Left,$b.Top,0,0,$bmp.Size);$g.Dispose(); $bmp.Save('${target.replace(/'/g, "''")}'); $bmp.Dispose();`;
@@ -52871,20 +53168,20 @@ function createScreenshotTool(deps = {}) {
52871
53168
  }),
52872
53169
  execute: async (args, ctx) => {
52873
53170
  const a = args;
52874
- const dir = deps.outDir ?? path57.join(ctx.cwd ?? process.cwd(), ".zelari", "screenshots");
53171
+ const dir = deps.outDir ?? path58.join(ctx.cwd ?? process.cwd(), ".zelari", "screenshots");
52875
53172
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
52876
- const target = path57.join(dir, `screenshot-${stamp}.png`);
53173
+ const target = path58.join(dir, `screenshot-${stamp}.png`);
52877
53174
  const capture = deps.capture ?? (process.platform === "win32" ? captureWindows : captureUnixLike);
52878
53175
  try {
52879
- await mkdir3(dir, { recursive: true });
53176
+ await mkdir4(dir, { recursive: true });
52880
53177
  await capture(target);
52881
53178
  const meta3 = await stat7(target);
52882
53179
  if (meta3.size === 0) return typedErr(`capture produced an empty file: ${target}`);
52883
- const buf = await readFile8(target);
53180
+ const buf = await readFile9(target);
52884
53181
  const image = {
52885
53182
  mime: "image/png",
52886
53183
  dataBase64: buf.toString("base64"),
52887
- alt: path57.basename(target)
53184
+ alt: path58.basename(target)
52888
53185
  };
52889
53186
  const attachable = meta3.size <= SCREENSHOT_MAX_BYTES2;
52890
53187
  return typedOk(
@@ -52958,21 +53255,21 @@ function normalizeAuth(auth) {
52958
53255
  return "agent";
52959
53256
  }
52960
53257
  function readSecrets() {
52961
- const path101 = getSshSecretsPath();
52962
- if (!existsSync30(path101)) return {};
53258
+ const path102 = getSshSecretsPath();
53259
+ if (!existsSync30(path102)) return {};
52963
53260
  try {
52964
- return JSON.parse(readFileSync22(path101, "utf8"));
53261
+ return JSON.parse(readFileSync22(path102, "utf8"));
52965
53262
  } catch {
52966
53263
  return {};
52967
53264
  }
52968
53265
  }
52969
53266
  function writeSecrets(data) {
52970
- const path101 = getSshSecretsPath();
52971
- mkdirSync13(dirname4(path101), { recursive: true });
52972
- writeFileSync16(path101, `${JSON.stringify(data, null, 2)}
53267
+ const path102 = getSshSecretsPath();
53268
+ mkdirSync13(dirname4(path102), { recursive: true });
53269
+ writeFileSync16(path102, `${JSON.stringify(data, null, 2)}
52973
53270
  `, "utf8");
52974
53271
  try {
52975
- chmodSync(path101, 384);
53272
+ chmodSync(path102, 384);
52976
53273
  } catch {
52977
53274
  }
52978
53275
  }
@@ -53001,10 +53298,10 @@ function deleteSshPassword(id3) {
53001
53298
  writeSecrets({ passwords });
53002
53299
  }
53003
53300
  function readStore2() {
53004
- const path101 = getSshTargetsPath();
53005
- if (!existsSync30(path101)) return [];
53301
+ const path102 = getSshTargetsPath();
53302
+ if (!existsSync30(path102)) return [];
53006
53303
  try {
53007
- const parsed = JSON.parse(readFileSync22(path101, "utf8"));
53304
+ const parsed = JSON.parse(readFileSync22(path102, "utf8"));
53008
53305
  const list = Array.isArray(parsed.targets) ? parsed.targets : [];
53009
53306
  return list.filter(
53010
53307
  (t) => t && typeof t.id === "string" && typeof t.host === "string" && typeof t.user === "string"
@@ -53019,11 +53316,11 @@ function readStore2() {
53019
53316
  }
53020
53317
  }
53021
53318
  function writeStore2(targets) {
53022
- const path101 = getSshTargetsPath();
53023
- mkdirSync13(dirname4(path101), { recursive: true });
53319
+ const path102 = getSshTargetsPath();
53320
+ mkdirSync13(dirname4(path102), { recursive: true });
53024
53321
  const clean = targets.map(({ hasPassword: _hp, ...t }) => t);
53025
53322
  writeFileSync16(
53026
- path101,
53323
+ path102,
53027
53324
  `${JSON.stringify({ targets: clean }, null, 2)}
53028
53325
  `,
53029
53326
  "utf8"
@@ -53269,11 +53566,11 @@ function formatSshTargetsForPrompt() {
53269
53566
  ];
53270
53567
  for (const t of targets) {
53271
53568
  const tags = t.tags?.length ? ` tags=[${t.tags.join(",")}]` : "";
53272
- const path101 = t.defaultRemotePath ? ` remotePath=${t.defaultRemotePath}` : "";
53569
+ const path102 = t.defaultRemotePath ? ` remotePath=${t.defaultRemotePath}` : "";
53273
53570
  const allow = t.allowedCommands?.length ? ` allowed=${t.allowedCommands.join("|")}` : " allowed=status-only";
53274
53571
  const auth = t.auth === "password" ? " auth=password" : t.auth === "keyPath" ? " auth=key" : " auth=agent";
53275
53572
  lines.push(
53276
- `- id=${t.id} name=${t.name} ${t.user}@${t.host}:${t.port ?? 22}${auth}${path101}${tags}${allow}`
53573
+ `- id=${t.id} name=${t.name} ${t.user}@${t.host}:${t.port ?? 22}${auth}${path102}${tags}${allow}`
53277
53574
  );
53278
53575
  }
53279
53576
  return lines.join("\n");
@@ -54659,12 +54956,12 @@ __export(folderTrust_exports, {
54659
54956
  untrustFolder: () => untrustFolder
54660
54957
  });
54661
54958
  import { existsSync as existsSync31, mkdirSync as mkdirSync14, readFileSync as readFileSync23, writeFileSync as writeFileSync17 } from "node:fs";
54662
- import path58 from "node:path";
54959
+ import path59 from "node:path";
54663
54960
  function trustStorePath() {
54664
54961
  return _overrideStorePath ?? trustConfigPath();
54665
54962
  }
54666
54963
  function normalize6(p3) {
54667
- const resolved = path58.resolve(p3);
54964
+ const resolved = path59.resolve(p3);
54668
54965
  return process.platform === "win32" ? resolved.toLowerCase() : resolved;
54669
54966
  }
54670
54967
  function readStore3() {
@@ -54680,7 +54977,7 @@ function readStore3() {
54680
54977
  function writeStore3(store6) {
54681
54978
  const p3 = trustStorePath();
54682
54979
  try {
54683
- mkdirSync14(path58.dirname(p3), { recursive: true });
54980
+ mkdirSync14(path59.dirname(p3), { recursive: true });
54684
54981
  writeFileSync17(p3, JSON.stringify(store6, null, 2), "utf8");
54685
54982
  } catch (err) {
54686
54983
  throw new Error(
@@ -54706,7 +55003,7 @@ function isFolderTrusted(folderPath) {
54706
55003
  }
54707
55004
  function trustFolder(folderPath) {
54708
55005
  const store6 = readStore3();
54709
- const normalized = path58.resolve(folderPath);
55006
+ const normalized = path59.resolve(folderPath);
54710
55007
  if (!store6.folders.some((f) => normalize6(f.path) === normalize6(normalized))) {
54711
55008
  store6.folders.push({ path: normalized, trustedAt: (/* @__PURE__ */ new Date()).toISOString() });
54712
55009
  writeStore3(store6);
@@ -54832,7 +55129,7 @@ var init_lifecycleHooks = __esm({
54832
55129
 
54833
55130
  // src/cli/safety/astGate.ts
54834
55131
  import { promises as fs24 } from "node:fs";
54835
- import path59 from "node:path";
55132
+ import path60 from "node:path";
54836
55133
  function astGateEnabled() {
54837
55134
  return process.env.ZELARI_AST_GATE !== "0";
54838
55135
  }
@@ -54867,9 +55164,9 @@ function wrapWithAstGate(original, opts) {
54867
55164
  const containedPathOf = (args) => {
54868
55165
  const raw = args["path"];
54869
55166
  if (typeof raw !== "string" || raw.length === 0) return null;
54870
- const absPath = path59.isAbsolute(raw) ? raw : path59.join(opts.root, raw);
54871
- const rel2 = path59.relative(opts.root, absPath);
54872
- if (rel2.startsWith("..") || path59.isAbsolute(rel2)) return null;
55167
+ const absPath = path60.isAbsolute(raw) ? raw : path60.join(opts.root, raw);
55168
+ const rel2 = path60.relative(opts.root, absPath);
55169
+ if (rel2.startsWith("..") || path60.isAbsolute(rel2)) return null;
54873
55170
  return absPath;
54874
55171
  };
54875
55172
  return {
@@ -54894,7 +55191,7 @@ function wrapWithAstGate(original, opts) {
54894
55191
  if (!result.ok) return result;
54895
55192
  if (gateTarget !== null && !isAstSupported(gateTarget)) {
54896
55193
  process.stderr.write(
54897
- `[ast_gate] LOUD SKIP (unsupported-extension): ${original.name} ${gateTarget} \u2014 ${path59.extname(gateTarget) || "(no extension)"} is outside the AST surface; write KEPT, NOT syntax-gated.
55194
+ `[ast_gate] LOUD SKIP (unsupported-extension): ${original.name} ${gateTarget} \u2014 ${path60.extname(gateTarget) || "(no extension)"} is outside the AST surface; write KEPT, NOT syntax-gated.
54898
55195
  `
54899
55196
  );
54900
55197
  return result;
@@ -54911,7 +55208,7 @@ function wrapWithAstGate(original, opts) {
54911
55208
  return result;
54912
55209
  }
54913
55210
  const post = await fs24.readFile(absPath, "utf8");
54914
- const syntaxError = firstSyntaxError(ts, path59.basename(absPath), post);
55211
+ const syntaxError = firstSyntaxError(ts, path60.basename(absPath), post);
54915
55212
  if (!syntaxError) return result;
54916
55213
  const parseError = `${syntaxError.message} (line ${syntaxError.line}, col ${syntaxError.character})`;
54917
55214
  let revertedTo;
@@ -54922,7 +55219,7 @@ function wrapWithAstGate(original, opts) {
54922
55219
  await fs24.writeFile(absPath, preContent, "utf8");
54923
55220
  revertedTo = snapshotIdOf(preContent);
54924
55221
  }
54925
- const relLabel = path59.relative(opts.root, absPath) || path59.basename(absPath);
55222
+ const relLabel = path60.relative(opts.root, absPath) || path60.basename(absPath);
54926
55223
  return typedErr(
54927
55224
  `[ast_gate_reverted] ${original.name}: ${absPath} written but the file no longer parses \u2014 write REVERTED (revertedTo=${revertedTo}). ${parseError}. Fix the syntax and re-apply (read_file first for a fresh snapshotId).`,
54928
55225
  {
@@ -55347,7 +55644,7 @@ var init_resourceClaims = __esm({
55347
55644
  // src/cli/toolResultCache.ts
55348
55645
  import { createHash as createHash16 } from "node:crypto";
55349
55646
  import { promises as fs25 } from "node:fs";
55350
- import path60 from "node:path";
55647
+ import path61 from "node:path";
55351
55648
  function isToolCacheEnabled() {
55352
55649
  const raw = process.env.ZELARI_TOOL_CACHE;
55353
55650
  return raw !== "0" && raw !== "false" && raw !== "off";
@@ -55432,7 +55729,7 @@ async function statKey(toolName, input, ctx) {
55432
55729
  if (!input || typeof input !== "object") return null;
55433
55730
  const rawPath = input.path;
55434
55731
  if (typeof rawPath !== "string" || rawPath.length === 0) return null;
55435
- const abs = path60.isAbsolute(rawPath) ? rawPath : path60.join(ctx.cwd, rawPath);
55732
+ const abs = path61.isAbsolute(rawPath) ? rawPath : path61.join(ctx.cwd, rawPath);
55436
55733
  try {
55437
55734
  const st = await fs25.stat(abs);
55438
55735
  return hashKey({
@@ -55488,7 +55785,7 @@ __export(toolRegistry_exports, {
55488
55785
  wrapWithSandbox: () => wrapWithSandbox
55489
55786
  });
55490
55787
  import { existsSync as existsSync32 } from "node:fs";
55491
- import path61 from "node:path";
55788
+ import path62 from "node:path";
55492
55789
  function createBuiltinToolRegistry(options = {}) {
55493
55790
  const root = options.root ?? process.cwd();
55494
55791
  const audit = options.audit ?? new AuditLogger();
@@ -56124,14 +56421,14 @@ function wrapWithDiagnostics(original, root, runner) {
56124
56421
  function claimedSourcePath(token, args, root) {
56125
56422
  const cleaned = token.replace(/^["']|["']$/g, "");
56126
56423
  if (!cleaned || cleaned.startsWith("-")) return null;
56127
- if (!DIAG_SOURCE_EXTENSIONS.has(path61.extname(cleaned).toLowerCase())) return null;
56424
+ if (!DIAG_SOURCE_EXTENSIONS.has(path62.extname(cleaned).toLowerCase())) return null;
56128
56425
  const bases = [root];
56129
56426
  const cwd = args["cwd"];
56130
56427
  if (typeof cwd === "string" && cwd.length > 0) {
56131
- bases.unshift(path61.isAbsolute(cwd) ? cwd : path61.resolve(root, cwd));
56428
+ bases.unshift(path62.isAbsolute(cwd) ? cwd : path62.resolve(root, cwd));
56132
56429
  }
56133
56430
  for (const base2 of bases) {
56134
- const candidate = path61.isAbsolute(cleaned) ? path61.normalize(cleaned) : path61.resolve(base2, cleaned);
56431
+ const candidate = path62.isAbsolute(cleaned) ? path62.normalize(cleaned) : path62.resolve(base2, cleaned);
56135
56432
  try {
56136
56433
  const contained = resolveSandboxedPath(candidate, { root });
56137
56434
  if (existsSync32(contained)) return contained;
@@ -56450,7 +56747,7 @@ var init_toolRegistry = __esm({
56450
56747
 
56451
56748
  // src/cli/metrics.ts
56452
56749
  import { promises as fs26, existsSync as existsSync33, statSync as statSync4, renameSync as renameSync4, appendFileSync as appendFileSync3, mkdirSync as mkdirSync15 } from "node:fs";
56453
- import path62 from "node:path";
56750
+ import path63 from "node:path";
56454
56751
  async function readMetrics(file2) {
56455
56752
  let raw = "";
56456
56753
  try {
@@ -56500,7 +56797,7 @@ var init_metrics3 = __esm({
56500
56797
  writeQueue = Promise.resolve();
56501
56798
  constructor(file2) {
56502
56799
  this.file = file2 ?? metricsPath();
56503
- mkdirSync15(path62.dirname(this.file), { recursive: true });
56800
+ mkdirSync15(path63.dirname(this.file), { recursive: true });
56504
56801
  }
56505
56802
  /** Metrics file path — doctor/summary readers use this. */
56506
56803
  get filePath() {
@@ -56837,10 +57134,10 @@ import { promisify as promisify6 } from "node:util";
56837
57134
  async function readHarnessVersion() {
56838
57135
  if (cachedHarnessVersion !== null) return cachedHarnessVersion;
56839
57136
  try {
56840
- const { readFile: readFile11 } = await import("node:fs/promises");
57137
+ const { readFile: readFile12 } = await import("node:fs/promises");
56841
57138
  const { fileURLToPath: fileURLToPath4 } = await import("node:url");
56842
57139
  const pkgPath = fileURLToPath4(new URL("../../../package.json", import.meta.url));
56843
- const parsed = JSON.parse(await readFile11(pkgPath, "utf8"));
57140
+ const parsed = JSON.parse(await readFile12(pkgPath, "utf8"));
56844
57141
  if (typeof parsed.version === "string" && parsed.version.length > 0) {
56845
57142
  return cachedHarnessVersion = parsed.version;
56846
57143
  }
@@ -57018,7 +57315,7 @@ var init_completionProofAttestation = __esm({
57018
57315
  // src/cli/kraken/completionProofPersist.ts
57019
57316
  import { open, rename as rename2, rm as rm2 } from "node:fs/promises";
57020
57317
  import { randomBytes as randomBytes5 } from "node:crypto";
57021
- import path63 from "node:path";
57318
+ import path64 from "node:path";
57022
57319
  function isTruthyFlag2(v) {
57023
57320
  const n = v?.trim().toLowerCase();
57024
57321
  return n === "1" || n === "true" || n === "yes" || n === "on";
@@ -57060,8 +57357,8 @@ function isWindowsRenameBlock(err) {
57060
57357
  return code === "EPERM" || code === "ENOTEMPTY" || code === "EEXIST";
57061
57358
  }
57062
57359
  async function writeFileAtomic(target, data) {
57063
- const dir = path63.dirname(target);
57064
- const tmp = path63.join(dir, `.${path63.basename(target)}.${randomBytes5(6).toString("hex")}.tmp`);
57360
+ const dir = path64.dirname(target);
57361
+ const tmp = path64.join(dir, `.${path64.basename(target)}.${randomBytes5(6).toString("hex")}.tmp`);
57065
57362
  let fh = null;
57066
57363
  try {
57067
57364
  fh = await open(tmp, "w");
@@ -57106,8 +57403,8 @@ var init_completionProofPersist = __esm({
57106
57403
  });
57107
57404
 
57108
57405
  // src/cli/kraken/completionProof.ts
57109
- import { mkdir as mkdir4 } from "node:fs/promises";
57110
- import path64 from "node:path";
57406
+ import { mkdir as mkdir5 } from "node:fs/promises";
57407
+ import path65 from "node:path";
57111
57408
  function verdictOf(evaluation) {
57112
57409
  return evaluation.evaluation?.verdict ?? (evaluation.blocked ? "BLOCKED" : "PASS");
57113
57410
  }
@@ -57252,8 +57549,8 @@ async function writeCompletionProofDetailed(evaluation, options = {}) {
57252
57549
  const mode = options.persistenceMode ?? activeProofPersistenceMode();
57253
57550
  try {
57254
57551
  const baseDir = options.baseDir ?? process.cwd();
57255
- const dir = path64.join(baseDir, ".zelari");
57256
- await mkdir4(dir, { recursive: true });
57552
+ const dir = path65.join(baseDir, ".zelari");
57553
+ await mkdir5(dir, { recursive: true });
57257
57554
  const requested = options.attestation ?? {};
57258
57555
  const plan = requested.skipProbes || requested.verificationPlan !== void 0 ? void 0 : await defaultVerificationPlanSnapshot(baseDir);
57259
57556
  const wrapper = await buildAttestedWrapper(
@@ -57272,8 +57569,8 @@ async function writeCompletionProofDetailed(evaluation, options = {}) {
57272
57569
  baseDir
57273
57570
  );
57274
57571
  const rendered = renderCompletionProof(evaluation, options.meta ?? {}, wrapper.attestation);
57275
- const markdownPath = path64.join(dir, "completion-proof.md");
57276
- const jsonPath = path64.join(dir, "completion-proof.json");
57572
+ const markdownPath = path65.join(dir, "completion-proof.md");
57573
+ const jsonPath = path65.join(dir, "completion-proof.json");
57277
57574
  await writeFileAtomic(markdownPath, rendered.markdown);
57278
57575
  await writeFileAtomic(jsonPath, rendered.json);
57279
57576
  return { paths: { markdownPath, jsonPath }, mode, requiredBlockReason: null };
@@ -57383,12 +57680,12 @@ var init_askUserTimeout = __esm({
57383
57680
  // src/cli/state/fileStateStore.ts
57384
57681
  import { createHash as createHash18, randomUUID as randomUUID5 } from "node:crypto";
57385
57682
  import { promises as fs27 } from "node:fs";
57386
- import * as path65 from "node:path";
57683
+ import * as path66 from "node:path";
57387
57684
  function shortId() {
57388
57685
  return randomUUID5().replace(/-/g, "").slice(0, 12);
57389
57686
  }
57390
57687
  async function writeJsonAtomic(filePath, data) {
57391
- await fs27.mkdir(path65.dirname(filePath), { recursive: true });
57688
+ await fs27.mkdir(path66.dirname(filePath), { recursive: true });
57392
57689
  const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
57393
57690
  await fs27.writeFile(tmp, JSON.stringify(data, null, 2) + "\n", "utf8");
57394
57691
  await fs27.rename(tmp, filePath);
@@ -57449,11 +57746,11 @@ var init_fileStateStore = __esm({
57449
57746
  indexPath = "";
57450
57747
  async init(projectRoot) {
57451
57748
  this.root = projectRoot;
57452
- this.stateDir = path65.join(projectRoot, ".zelari", "state");
57453
- this.commitsDir = path65.join(this.stateDir, "commits");
57454
- this.artifactsDir = path65.join(this.stateDir, "artifacts");
57455
- this.headPath = path65.join(this.stateDir, "HEAD.json");
57456
- this.indexPath = path65.join(this.stateDir, "index.jsonl");
57749
+ this.stateDir = path66.join(projectRoot, ".zelari", "state");
57750
+ this.commitsDir = path66.join(this.stateDir, "commits");
57751
+ this.artifactsDir = path66.join(this.stateDir, "artifacts");
57752
+ this.headPath = path66.join(this.stateDir, "HEAD.json");
57753
+ this.indexPath = path66.join(this.stateDir, "index.jsonl");
57457
57754
  await fs27.mkdir(this.commitsDir, { recursive: true });
57458
57755
  await fs27.mkdir(this.artifactsDir, { recursive: true });
57459
57756
  }
@@ -57466,13 +57763,13 @@ var init_fileStateStore = __esm({
57466
57763
  const discoveries = input.discoveries ?? [];
57467
57764
  const parent = await this.head();
57468
57765
  const id3 = shortId();
57469
- const artifactRel = path65.join("artifacts", id3);
57470
- const artifactAbs = path65.join(this.artifactsDir, id3);
57766
+ const artifactRel = path66.join("artifacts", id3);
57767
+ const artifactAbs = path66.join(this.artifactsDir, id3);
57471
57768
  await fs27.mkdir(artifactAbs, { recursive: true });
57472
57769
  const summary = defaultSummary(input, discoveries);
57473
- await fs27.writeFile(path65.join(artifactAbs, "summary.md"), summary + "\n", "utf8");
57474
- await writeJsonAtomic(path65.join(artifactAbs, "discoveries.json"), discoveries);
57475
- await writeJsonAtomic(path65.join(artifactAbs, "verification.json"), input.verification);
57770
+ await fs27.writeFile(path66.join(artifactAbs, "summary.md"), summary + "\n", "utf8");
57771
+ await writeJsonAtomic(path66.join(artifactAbs, "discoveries.json"), discoveries);
57772
+ await writeJsonAtomic(path66.join(artifactAbs, "verification.json"), input.verification);
57476
57773
  const meta3 = {
57477
57774
  id: id3,
57478
57775
  parentId: parent?.id ?? null,
@@ -57484,14 +57781,14 @@ var init_fileStateStore = __esm({
57484
57781
  workspaceCheckpointId: input.workspaceCheckpointId,
57485
57782
  verification: {
57486
57783
  ...input.verification,
57487
- reportPath: input.verification.reportPath ?? path65.join(".zelari", "state", artifactRel, "verification.json").replace(/\\/g, "/")
57784
+ reportPath: input.verification.reportPath ?? path66.join(".zelari", "state", artifactRel, "verification.json").replace(/\\/g, "/")
57488
57785
  },
57489
57786
  changedPaths: input.changedPaths ?? [],
57490
57787
  stablePromptHash: input.stablePromptHash,
57491
57788
  discoveryCount: discoveries.length,
57492
57789
  artifactDir: artifactRel.replace(/\\/g, "/")
57493
57790
  };
57494
- await writeJsonAtomic(path65.join(this.commitsDir, `${id3}.json`), meta3);
57791
+ await writeJsonAtomic(path66.join(this.commitsDir, `${id3}.json`), meta3);
57495
57792
  await writeJsonAtomic(this.headPath, { id: id3, updatedAt: meta3.createdAt });
57496
57793
  await fs27.appendFile(this.indexPath, JSON.stringify({ id: id3, createdAt: meta3.createdAt, label: meta3.label }) + "\n", "utf8");
57497
57794
  return stripStored(meta3);
@@ -57502,7 +57799,7 @@ var init_fileStateStore = __esm({
57502
57799
  return this.get(head.id);
57503
57800
  }
57504
57801
  async get(id3) {
57505
- const stored = await readJsonFile(path65.join(this.commitsDir, `${id3}.json`));
57802
+ const stored = await readJsonFile(path66.join(this.commitsDir, `${id3}.json`));
57506
57803
  return stored ? stripStored(stored) : null;
57507
57804
  }
57508
57805
  async list(limit = 20) {
@@ -57541,9 +57838,9 @@ var init_fileStateStore = __esm({
57541
57838
  async loadDiscoveries(id3) {
57542
57839
  const meta3 = id3 ? await this.get(id3) : await this.head();
57543
57840
  if (!meta3) return [];
57544
- const stored = await readJsonFile(path65.join(this.commitsDir, `${meta3.id}.json`));
57841
+ const stored = await readJsonFile(path66.join(this.commitsDir, `${meta3.id}.json`));
57545
57842
  if (!stored?.artifactDir) return [];
57546
- const discPath = path65.join(this.stateDir, stored.artifactDir, "discoveries.json");
57843
+ const discPath = path66.join(this.stateDir, stored.artifactDir, "discoveries.json");
57547
57844
  return await readJsonFile(discPath) ?? [];
57548
57845
  }
57549
57846
  async materializeContext(id3, maxChars = DEFAULT_MATERIALIZE_CHARS) {
@@ -58146,10 +58443,10 @@ var init_mode = __esm({
58146
58443
 
58147
58444
  // src/cli/headless.ts
58148
58445
  import { readFileSync as readFileSync24 } from "node:fs";
58149
- import path66 from "node:path";
58446
+ import path67 from "node:path";
58150
58447
  function resolveHeadlessCwd(opts) {
58151
58448
  const raw = typeof opts.cwd === "string" ? opts.cwd.trim() : "";
58152
- return path66.resolve(raw.length > 0 ? raw : process.cwd());
58449
+ return path67.resolve(raw.length > 0 ? raw : process.cwd());
58153
58450
  }
58154
58451
  function defaultProfileForMode(mode) {
58155
58452
  switch (mode) {
@@ -58465,7 +58762,7 @@ __export(headlessSpine_exports, {
58465
58762
  seedHeadlessModelHistory: () => seedHeadlessModelHistory,
58466
58763
  sessionStartedEvent: () => sessionStartedEvent
58467
58764
  });
58468
- import path67 from "node:path";
58765
+ import path68 from "node:path";
58469
58766
  function sessionStartedEvent(handle) {
58470
58767
  return {
58471
58768
  type: "session_started",
@@ -58482,7 +58779,7 @@ async function countVerificationEvidenceInLog(mirror, sessionId2) {
58482
58779
  try {
58483
58780
  await mirror.flush().catch(() => void 0);
58484
58781
  const report = await readSessionLogCached(
58485
- path67.join(mirror.sessionsDir, sessionId2, "events.jsonl"),
58782
+ path68.join(mirror.sessionsDir, sessionId2, "events.jsonl"),
58486
58783
  mirror.replayCache
58487
58784
  );
58488
58785
  return report.events.filter((e) => e.kind === "verification.evidence").length;
@@ -59279,7 +59576,7 @@ var init_planDetect = __esm({
59279
59576
  // src/cli/memory/legacyImport.ts
59280
59577
  import { createHash as createHash19 } from "node:crypto";
59281
59578
  import { promises as fs28 } from "node:fs";
59282
- import * as path68 from "node:path";
59579
+ import * as path69 from "node:path";
59283
59580
  function sourceId(fact, line) {
59284
59581
  return `jsonl:${fact.id ?? createHash19("sha256").update(line).digest("hex")}`;
59285
59582
  }
@@ -59317,12 +59614,12 @@ async function markImportComplete(markerPath, found) {
59317
59614
  }
59318
59615
  async function importLegacyMemoryLog(backend, service) {
59319
59616
  const result = { found: 0, imported: 0, skipped: 0, corrupt: 0 };
59320
- const memoryDir = path68.dirname(backend.databasePath);
59321
- const markerPath = path68.join(memoryDir, LEGACY_IMPORT_MARKER);
59617
+ const memoryDir = path69.dirname(backend.databasePath);
59618
+ const markerPath = path69.join(memoryDir, LEGACY_IMPORT_MARKER);
59322
59619
  if (await isImportComplete(markerPath)) return result;
59323
59620
  let raw;
59324
59621
  try {
59325
- raw = await fs28.readFile(path68.join(memoryDir, "log.jsonl"), "utf8");
59622
+ raw = await fs28.readFile(path69.join(memoryDir, "log.jsonl"), "utf8");
59326
59623
  } catch {
59327
59624
  return result;
59328
59625
  }
@@ -59514,7 +59811,7 @@ var init_sqliteCodec = __esm({
59514
59811
  // src/cli/memory/sqliteRpc.ts
59515
59812
  import { existsSync as existsSync36 } from "node:fs";
59516
59813
  import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "node:url";
59517
- import * as path69 from "node:path";
59814
+ import * as path70 from "node:path";
59518
59815
  import { Worker } from "node:worker_threads";
59519
59816
  function isBusy(error51) {
59520
59817
  const candidate = error51;
@@ -59523,10 +59820,10 @@ function isBusy(error51) {
59523
59820
  );
59524
59821
  }
59525
59822
  function resolveWorkerUrl() {
59526
- const here = path69.dirname(fileURLToPath2(import.meta.url));
59527
- const direct = path69.join(here, "sqliteWorker.mjs");
59823
+ const here = path70.dirname(fileURLToPath2(import.meta.url));
59824
+ const direct = path70.join(here, "sqliteWorker.mjs");
59528
59825
  if (existsSync36(direct)) return pathToFileURL2(direct);
59529
- return pathToFileURL2(path69.join(here, "memory", "sqliteWorker.mjs"));
59826
+ return pathToFileURL2(path70.join(here, "memory", "sqliteWorker.mjs"));
59530
59827
  }
59531
59828
  var SqliteWorkerRpc;
59532
59829
  var init_sqliteRpc = __esm({
@@ -59815,7 +60112,7 @@ WHERE NOT EXISTS (SELECT 1 FROM memory_fts f WHERE f.node_id = n.id);
59815
60112
  // src/cli/memory/sqliteBackend.ts
59816
60113
  import { createHash as createHash20, randomUUID as randomUUID6 } from "node:crypto";
59817
60114
  import { promises as fs29 } from "node:fs";
59818
- import * as path70 from "node:path";
60115
+ import * as path71 from "node:path";
59819
60116
  function boundedLimit(value, fallback = 50) {
59820
60117
  return Math.max(1, Math.min(Math.floor(value ?? fallback), 1e5));
59821
60118
  }
@@ -59878,16 +60175,16 @@ VALUES (${Array.from({ length: 19 }, () => "?").join(",")})`;
59878
60175
  try {
59879
60176
  resolved = await fs29.realpath(projectRoot);
59880
60177
  } catch {
59881
- resolved = path70.resolve(projectRoot);
60178
+ resolved = path71.resolve(projectRoot);
59882
60179
  }
59883
60180
  if (this.initialized && resolved === this.projectRoot) return;
59884
60181
  if (this.initialized) await this.close();
59885
60182
  const filename = this.options.filename ?? "memory.db";
59886
- if (path70.basename(filename) !== filename || filename === "." || filename === "..") {
60183
+ if (path71.basename(filename) !== filename || filename === "." || filename === "..") {
59887
60184
  throw new Error("SQLite memory filename must not contain a path.");
59888
60185
  }
59889
- const zelariDirectory = path70.join(resolved, ".zelari");
59890
- const directory = path70.join(zelariDirectory, "memory");
60186
+ const zelariDirectory = path71.join(resolved, ".zelari");
60187
+ const directory = path71.join(zelariDirectory, "memory");
59891
60188
  for (const candidate of [zelariDirectory, directory]) {
59892
60189
  let stat8;
59893
60190
  try {
@@ -59906,12 +60203,12 @@ VALUES (${Array.from({ length: 19 }, () => "?").join(",")})`;
59906
60203
  }
59907
60204
  }
59908
60205
  const canonicalDirectory = await fs29.realpath(directory);
59909
- const relativeDirectory = path70.relative(resolved, canonicalDirectory);
59910
- if (relativeDirectory.startsWith("..") || path70.isAbsolute(relativeDirectory)) {
60206
+ const relativeDirectory = path71.relative(resolved, canonicalDirectory);
60207
+ if (relativeDirectory.startsWith("..") || path71.isAbsolute(relativeDirectory)) {
59911
60208
  throw new Error("SQLite memory directory resolves outside the active project.");
59912
60209
  }
59913
60210
  this.projectRoot = resolved;
59914
- this.databasePath = path70.join(canonicalDirectory, filename);
60211
+ this.databasePath = path71.join(canonicalDirectory, filename);
59915
60212
  const opened = await this.rpc.open({
59916
60213
  dbPath: this.databasePath,
59917
60214
  schemaSql: SQLITE_MEMORY_BASE_SCHEMA,
@@ -60454,7 +60751,7 @@ __export(serviceFactory_exports, {
60454
60751
  });
60455
60752
  import { createHash as createHash21 } from "node:crypto";
60456
60753
  import { promises as fs30 } from "node:fs";
60457
- import * as path71 from "node:path";
60754
+ import * as path72 from "node:path";
60458
60755
  function isMemoryV2Enabled(env = process.env) {
60459
60756
  if (env.ZELARI_MEMORY === "0") return false;
60460
60757
  if (env.ZELARI_MEMORY_BACKEND === "file" || env.ZELARI_MEMORY_BACKEND === "jsonl") return false;
@@ -60475,7 +60772,7 @@ async function canonicalProjectId(projectRoot) {
60475
60772
  try {
60476
60773
  canonical = await fs30.realpath(projectRoot);
60477
60774
  } catch {
60478
- canonical = path71.resolve(projectRoot);
60775
+ canonical = path72.resolve(projectRoot);
60479
60776
  }
60480
60777
  canonical = canonical.replace(/\\/g, "/").replace(/\/$/, "");
60481
60778
  if (process.platform === "win32") canonical = canonical.toLocaleLowerCase("en-US");
@@ -61177,8 +61474,8 @@ function readPlan(ctx) {
61177
61474
  } catch {
61178
61475
  }
61179
61476
  }
61180
- const path101 = workspaceFile(ctx.rootDir, "plan");
61181
- const doc = ctx.storage.readIfExists(path101);
61477
+ const path102 = workspaceFile(ctx.rootDir, "plan");
61478
+ const doc = ctx.storage.readIfExists(path102);
61182
61479
  if (!doc) return { phases: [], tasks: [], milestones: [] };
61183
61480
  const meta3 = doc.meta;
61184
61481
  return {
@@ -61359,7 +61656,7 @@ function addMilestoneRecord(ctx, summary, input) {
61359
61656
  dueDate: input.dueDate,
61360
61657
  targetVersion: version2
61361
61658
  });
61362
- const path101 = join31(ctx.rootDir, "milestones", `${id3}.md`);
61659
+ const path102 = join31(ctx.rootDir, "milestones", `${id3}.md`);
61363
61660
  const meta3 = {
61364
61661
  kind: "milestone",
61365
61662
  id: id3,
@@ -61376,7 +61673,7 @@ function addMilestoneRecord(ctx, summary, input) {
61376
61673
  `Target version: ${version2}`,
61377
61674
  ""
61378
61675
  ].join("\n");
61379
- ctx.storage.write(path101, meta3, body);
61676
+ ctx.storage.write(path102, meta3, body);
61380
61677
  return { id: id3, created: true };
61381
61678
  }
61382
61679
  function readPlanSummary(ctx) {
@@ -61580,7 +61877,7 @@ function addIdeaStub(ctx) {
61580
61877
  const tags = args["tags"] ?? [];
61581
61878
  const category = args["category"] ?? "General";
61582
61879
  const id3 = `${nextAdrId(ctx)}-${slugify3(title)}`;
61583
- const path101 = workspaceArtifact(ctx.rootDir, "decisions", id3);
61880
+ const path102 = workspaceArtifact(ctx.rootDir, "decisions", id3);
61584
61881
  const meta3 = {
61585
61882
  kind: "adr",
61586
61883
  status: "proposed",
@@ -61606,7 +61903,7 @@ function addIdeaStub(ctx) {
61606
61903
  ...consequences.map((c) => `- ${c}`),
61607
61904
  ""
61608
61905
  ].join("\n");
61609
- ctx.storage.write(path101, meta3, body);
61906
+ ctx.storage.write(path102, meta3, body);
61610
61907
  return `ADR ${id3} created: "${title}". Status: proposed. Promote to accepted via /update ADR or manual edit.`;
61611
61908
  });
61612
61909
  }
@@ -61688,14 +61985,14 @@ function createDocumentStub(ctx) {
61688
61985
  ctx.storage.write(risksPath, riskMeta, content);
61689
61986
  return `Document "${title}" created at risks.md (workspace root).`;
61690
61987
  }
61691
- const path101 = workspaceArtifact(ctx.rootDir, "docs", slug);
61988
+ const path102 = workspaceArtifact(ctx.rootDir, "docs", slug);
61692
61989
  const meta3 = {
61693
61990
  kind: "doc",
61694
61991
  id: slug,
61695
61992
  date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
61696
61993
  tags
61697
61994
  };
61698
- ctx.storage.write(path101, meta3, content);
61995
+ ctx.storage.write(path102, meta3, content);
61699
61996
  return `Document "${title}" created at docs/${slug}.md.`;
61700
61997
  });
61701
61998
  }
@@ -62320,10 +62617,10 @@ function getUserMcpPath() {
62320
62617
  function getProjectMcpPath(projectRoot) {
62321
62618
  return join32(projectRoot, ".zelari", "mcp.json");
62322
62619
  }
62323
- function readFile9(path101) {
62324
- if (!existsSync42(path101)) return {};
62620
+ function readFile10(path102) {
62621
+ if (!existsSync42(path102)) return {};
62325
62622
  try {
62326
- const parsed = JSON.parse(readFileSync30(path101, "utf8"));
62623
+ const parsed = JSON.parse(readFileSync30(path102, "utf8"));
62327
62624
  const out = {};
62328
62625
  for (const [name, cfg] of Object.entries(parsed.mcpServers ?? {})) {
62329
62626
  const hasCommand = !!cfg && typeof cfg.command === "string" && !!cfg.command.trim();
@@ -62345,17 +62642,17 @@ function readFile9(path101) {
62345
62642
  return {};
62346
62643
  }
62347
62644
  }
62348
- function writeFile3(path101, servers) {
62349
- mkdirSync17(dirname9(path101), { recursive: true });
62645
+ function writeFile4(path102, servers) {
62646
+ mkdirSync17(dirname9(path102), { recursive: true });
62350
62647
  const body = { mcpServers: servers };
62351
- writeFileSync19(path101, `${JSON.stringify(body, null, 2)}
62648
+ writeFileSync19(path102, `${JSON.stringify(body, null, 2)}
62352
62649
  `, "utf8");
62353
62650
  }
62354
62651
  function listMcpServers(projectRoot) {
62355
62652
  const userPath = getUserMcpPath();
62356
- const userServers = readFile9(userPath);
62653
+ const userServers = readFile10(userPath);
62357
62654
  const projectPath = projectRoot && projectRoot.trim() ? getProjectMcpPath(projectRoot.trim()) : null;
62358
- const projectServers = projectPath ? readFile9(projectPath) : {};
62655
+ const projectServers = projectPath ? readFile10(projectPath) : {};
62359
62656
  const servers = [];
62360
62657
  for (const [name, cfg] of Object.entries(userServers)) {
62361
62658
  servers.push({ name, ...cfg, scope: "user", path: userPath });
@@ -62386,9 +62683,9 @@ function upsertMcpServer(opts) {
62386
62683
  error: "either command (stdio) or url (http) is required"
62387
62684
  };
62388
62685
  }
62389
- let path101;
62686
+ let path102;
62390
62687
  if (opts.scope === "user") {
62391
- path101 = getUserMcpPath();
62688
+ path102 = getUserMcpPath();
62392
62689
  } else {
62393
62690
  const root = opts.projectRoot?.trim();
62394
62691
  if (!root) {
@@ -62397,9 +62694,9 @@ function upsertMcpServer(opts) {
62397
62694
  error: "projectRoot required for project scope (Open Folder first)"
62398
62695
  };
62399
62696
  }
62400
- path101 = getProjectMcpPath(root);
62697
+ path102 = getProjectMcpPath(root);
62401
62698
  }
62402
- const current = readFile9(path101);
62699
+ const current = readFile10(path102);
62403
62700
  current[name] = {
62404
62701
  command: hasCommand ? opts.config.command.trim() : void 0,
62405
62702
  args: opts.config.args,
@@ -62410,21 +62707,21 @@ function upsertMcpServer(opts) {
62410
62707
  serial: opts.config.serial,
62411
62708
  enabled: opts.config.enabled !== false
62412
62709
  };
62413
- writeFile3(path101, current);
62414
- return { ok: true, path: path101 };
62710
+ writeFile4(path102, current);
62711
+ return { ok: true, path: path102 };
62415
62712
  }
62416
62713
  function removeMcpServer(opts) {
62417
- const path101 = opts.scope === "user" ? getUserMcpPath() : opts.projectRoot ? getProjectMcpPath(opts.projectRoot) : null;
62418
- if (!path101) {
62714
+ const path102 = opts.scope === "user" ? getUserMcpPath() : opts.projectRoot ? getProjectMcpPath(opts.projectRoot) : null;
62715
+ if (!path102) {
62419
62716
  return { ok: false, error: "projectRoot required for project scope" };
62420
62717
  }
62421
- const current = readFile9(path101);
62718
+ const current = readFile10(path102);
62422
62719
  if (!(opts.name in current)) {
62423
- return { ok: false, error: `Server "${opts.name}" not found in ${path101}` };
62720
+ return { ok: false, error: `Server "${opts.name}" not found in ${path102}` };
62424
62721
  }
62425
62722
  delete current[opts.name];
62426
- writeFile3(path101, current);
62427
- return { ok: true, path: path101 };
62723
+ writeFile4(path102, current);
62724
+ return { ok: true, path: path102 };
62428
62725
  }
62429
62726
  var init_mcpConfigIo = __esm({
62430
62727
  "src/cli/mcp/mcpConfigIo.ts"() {
@@ -62893,12 +63190,12 @@ __export(agentsMd_exports, {
62893
63190
  import { existsSync as existsSync44, readFileSync as readFileSync32, writeFileSync as writeFileSync20 } from "node:fs";
62894
63191
  import { createHash as createHash22 } from "node:crypto";
62895
63192
  import { join as join34 } from "node:path";
62896
- import { readFile as readFile10 } from "node:fs/promises";
63193
+ import { readFile as readFile11 } from "node:fs/promises";
62897
63194
  async function readPackageJson3(projectRoot) {
62898
- const path101 = join34(projectRoot, "package.json");
62899
- if (!existsSync44(path101)) return null;
63195
+ const path102 = join34(projectRoot, "package.json");
63196
+ if (!existsSync44(path102)) return null;
62900
63197
  try {
62901
- return JSON.parse(await readFile10(path101, "utf8"));
63198
+ return JSON.parse(await readFile11(path102, "utf8"));
62902
63199
  } catch {
62903
63200
  return null;
62904
63201
  }
@@ -62980,9 +63277,9 @@ async function genBuild(ctx) {
62980
63277
  ].join("\n");
62981
63278
  }
62982
63279
  async function genOpenQuestions(ctx) {
62983
- const path101 = join34(ctx.rootDir, "risks.md");
62984
- if (!existsSync44(path101)) return "_No open questions._";
62985
- const content = readFileSync32(path101, "utf8");
63280
+ const path102 = join34(ctx.rootDir, "risks.md");
63281
+ if (!existsSync44(path102)) return "_No open questions._";
63282
+ const content = readFileSync32(path102, "utf8");
62986
63283
  const lines = content.split("\n");
62987
63284
  const questions = [];
62988
63285
  let currentTitle = "";
@@ -63256,9 +63553,9 @@ function versionKey(value) {
63256
63553
  function firstString2(v) {
63257
63554
  return typeof v === "string" && v.trim().length > 0 ? v : null;
63258
63555
  }
63259
- function readFileSyncSafe(path101) {
63556
+ function readFileSyncSafe(path102) {
63260
63557
  try {
63261
- return readFileSync33(path101, "utf8");
63558
+ return readFileSync33(path102, "utf8");
63262
63559
  } catch {
63263
63560
  return null;
63264
63561
  }
@@ -63506,7 +63803,7 @@ __export(evidenceFromSpine_exports, {
63506
63803
  evidenceRefsFromEventLines: () => evidenceRefsFromEventLines
63507
63804
  });
63508
63805
  import { existsSync as existsSync47, readFileSync as readFileSync35 } from "node:fs";
63509
- import path72 from "node:path";
63806
+ import path73 from "node:path";
63510
63807
  function asRecord2(v) {
63511
63808
  return v && typeof v === "object" && !Array.isArray(v) ? v : void 0;
63512
63809
  }
@@ -63544,7 +63841,7 @@ function evidenceRefsFromEventLines(lines) {
63544
63841
  }
63545
63842
  function collectSessionEvidenceRefs(sessionId2) {
63546
63843
  try {
63547
- const file2 = path72.join(sessionsDir(), sessionId2, "events.jsonl");
63844
+ const file2 = path73.join(sessionsDir(), sessionId2, "events.jsonl");
63548
63845
  if (!existsSync47(file2)) return [];
63549
63846
  return evidenceRefsFromEventLines(readFileSync35(file2, "utf8").split("\n"));
63550
63847
  } catch {
@@ -63794,8 +64091,8 @@ async function runPostCouncilHook(ctx, options) {
63794
64091
  sources: scope.sources
63795
64092
  } : void 0
63796
64093
  });
63797
- const path101 = writeCouncilCompletion(ctx.rootDir, completion);
63798
- completionHook = { ran: true, path: path101, completion };
64094
+ const path102 = writeCouncilCompletion(ctx.rootDir, completion);
64095
+ completionHook = { ran: true, path: path102, completion };
63799
64096
  } catch (err) {
63800
64097
  completionHook = {
63801
64098
  ran: true,
@@ -63840,7 +64137,7 @@ import {
63840
64137
  writeFileSync as writeFileSync22,
63841
64138
  mkdirSync as mkdirSync18
63842
64139
  } from "node:fs";
63843
- import path73 from "node:path";
64140
+ import path74 from "node:path";
63844
64141
  var FeedbackStore;
63845
64142
  var init_councilFeedback = __esm({
63846
64143
  "src/cli/councilFeedback.ts"() {
@@ -63957,7 +64254,7 @@ var init_councilFeedback = __esm({
63957
64254
  }
63958
64255
  }
63959
64256
  save() {
63960
- mkdirSync18(path73.dirname(this.file), { recursive: true });
64257
+ mkdirSync18(path74.dirname(this.file), { recursive: true });
63961
64258
  writeFileSync22(
63962
64259
  this.file,
63963
64260
  JSON.stringify({ entries: this.entries }, null, 2),
@@ -64032,12 +64329,12 @@ __export(ledger_exports, {
64032
64329
  readLedger: () => readLedger
64033
64330
  });
64034
64331
  import { appendFileSync as appendFileSync4, existsSync as existsSync50, mkdirSync as mkdirSync19, readFileSync as readFileSync38 } from "node:fs";
64035
- import path74 from "node:path";
64332
+ import path75 from "node:path";
64036
64333
  function evolutionMode(env = process.env) {
64037
64334
  return env[EVOLUTION_ENV] === "shadow" ? "shadow" : "0";
64038
64335
  }
64039
64336
  function ledgerPath(cwd) {
64040
- return path74.join(cwd, LEDGER_REL);
64337
+ return path75.join(cwd, LEDGER_REL);
64041
64338
  }
64042
64339
  function appendLedgerEntry(cwd, entry) {
64043
64340
  if (evolutionMode() === "0") {
@@ -64045,7 +64342,7 @@ function appendLedgerEntry(cwd, entry) {
64045
64342
  }
64046
64343
  try {
64047
64344
  const file2 = ledgerPath(cwd);
64048
- mkdirSync19(path74.dirname(file2), { recursive: true });
64345
+ mkdirSync19(path75.dirname(file2), { recursive: true });
64049
64346
  appendFileSync4(file2, `${JSON.stringify(entry)}
64050
64347
  `, "utf8");
64051
64348
  return { written: true, path: file2 };
@@ -64146,7 +64443,7 @@ var init_ledger = __esm({
64146
64443
  "src/cli/evolution/ledger.ts"() {
64147
64444
  "use strict";
64148
64445
  EVOLUTION_ENV = "ZELARI_EVOLUTION";
64149
- LEDGER_REL = path74.join(".zelari", "evolution", "ledger.jsonl");
64446
+ LEDGER_REL = path75.join(".zelari", "evolution", "ledger.jsonl");
64150
64447
  TIER_WEIGHTS = {
64151
64448
  build: 1,
64152
64449
  "tool-output": 1,
@@ -64288,7 +64585,7 @@ __export(fileBackend_exports, {
64288
64585
  });
64289
64586
  import { randomUUID as randomUUID7 } from "node:crypto";
64290
64587
  import { promises as fs32 } from "node:fs";
64291
- import * as path75 from "node:path";
64588
+ import * as path76 from "node:path";
64292
64589
  function tokenize2(text) {
64293
64590
  return text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((t) => t.length >= 3);
64294
64591
  }
@@ -64341,8 +64638,8 @@ var init_fileBackend = __esm({
64341
64638
  logPath = "";
64342
64639
  memoryDir = "";
64343
64640
  async init(projectRoot) {
64344
- this.memoryDir = path75.join(projectRoot, ".zelari", "memory");
64345
- this.logPath = path75.join(this.memoryDir, "log.jsonl");
64641
+ this.memoryDir = path76.join(projectRoot, ".zelari", "memory");
64642
+ this.logPath = path76.join(this.memoryDir, "log.jsonl");
64346
64643
  await fs32.mkdir(this.memoryDir, { recursive: true });
64347
64644
  }
64348
64645
  async add(content, metadata2 = {}, graph) {
@@ -64415,12 +64712,12 @@ var init_fileBackend = __esm({
64415
64712
 
64416
64713
  // src/cli/traceStore.ts
64417
64714
  import { promises as fs33 } from "node:fs";
64418
- import * as path76 from "node:path";
64715
+ import * as path77 from "node:path";
64419
64716
  function traceDir(projectRoot) {
64420
- return path76.join(projectRoot, ".zelari", "trace");
64717
+ return path77.join(projectRoot, ".zelari", "trace");
64421
64718
  }
64422
64719
  function tracePath(projectRoot, missionId) {
64423
- return path76.join(traceDir(projectRoot), `${missionId}.json`);
64720
+ return path77.join(traceDir(projectRoot), `${missionId}.json`);
64424
64721
  }
64425
64722
  async function saveTrace(projectRoot, missionId, entries) {
64426
64723
  const dir = traceDir(projectRoot);
@@ -64462,7 +64759,7 @@ __export(zelariMission_exports, {
64462
64759
  });
64463
64760
  import { randomUUID as randomUUID8 } from "node:crypto";
64464
64761
  import { promises as fs34 } from "node:fs";
64465
- import * as path77 from "node:path";
64762
+ import * as path78 from "node:path";
64466
64763
  function resolveMaxIterations(env = process.env) {
64467
64764
  const raw = env.ZELARI_MISSION_MAX_ITER;
64468
64765
  const n = raw ? Number.parseInt(raw, 10) : DEFAULT_MAX_ITER;
@@ -64505,10 +64802,10 @@ function isMissionAutoStart(env = process.env) {
64505
64802
  return env.ZELARI_MISSION_AUTO === "1";
64506
64803
  }
64507
64804
  async function writeMissionState(projectRoot, state3) {
64508
- const dir = path77.join(projectRoot, ".zelari");
64805
+ const dir = path78.join(projectRoot, ".zelari");
64509
64806
  await fs34.mkdir(dir, { recursive: true });
64510
64807
  await fs34.writeFile(
64511
- path77.join(dir, "mission-state.json"),
64808
+ path78.join(dir, "mission-state.json"),
64512
64809
  JSON.stringify(state3, null, 2) + "\n",
64513
64810
  "utf8"
64514
64811
  );
@@ -64522,7 +64819,7 @@ async function writeMissionState(projectRoot, state3) {
64522
64819
  async function loadMissionState(projectRoot) {
64523
64820
  try {
64524
64821
  const raw = await fs34.readFile(
64525
- path77.join(projectRoot, ".zelari", "mission-state.json"),
64822
+ path78.join(projectRoot, ".zelari", "mission-state.json"),
64526
64823
  "utf8"
64527
64824
  );
64528
64825
  const parsed = JSON.parse(raw);
@@ -65281,7 +65578,7 @@ function safeSocketPath(socketPath) {
65281
65578
  return socketPath.trim();
65282
65579
  }
65283
65580
  function startPermissionBroker(socketPath, handlers, opts) {
65284
- const path101 = safeSocketPath(socketPath);
65581
+ const path102 = safeSocketPath(socketPath);
65285
65582
  const requestTimeoutMs = opts?.requestTimeoutMs ?? PERMISSION_BROKER_DEFAULT_TIMEOUT_MS;
65286
65583
  const sockets = /* @__PURE__ */ new Set();
65287
65584
  const server = createServer2((socket) => {
@@ -65381,10 +65678,10 @@ function startPermissionBroker(socketPath, handlers, opts) {
65381
65678
  return new Promise((resolve9, reject) => {
65382
65679
  const onError = (err) => reject(err);
65383
65680
  server.once("error", onError);
65384
- server.listen(path101, () => {
65681
+ server.listen(path102, () => {
65385
65682
  server.removeListener("error", onError);
65386
65683
  resolve9({
65387
- socketPath: path101,
65684
+ socketPath: path102,
65388
65685
  stop: () => new Promise((res) => {
65389
65686
  for (const s of sockets) s.destroy();
65390
65687
  sockets.clear();
@@ -65395,7 +65692,7 @@ function startPermissionBroker(socketPath, handlers, opts) {
65395
65692
  if (done) return;
65396
65693
  done = true;
65397
65694
  if (process.platform !== "win32") {
65398
- unlink(path101, () => res());
65695
+ unlink(path102, () => res());
65399
65696
  } else {
65400
65697
  res();
65401
65698
  }
@@ -65408,11 +65705,11 @@ function startPermissionBroker(socketPath, handlers, opts) {
65408
65705
  });
65409
65706
  }
65410
65707
  function requestBrokerAsk(socketPath, ask, opts) {
65411
- const path101 = safeSocketPath(socketPath);
65708
+ const path102 = safeSocketPath(socketPath);
65412
65709
  const requestTimeoutMs = opts?.requestTimeoutMs ?? PERMISSION_BROKER_DEFAULT_TIMEOUT_MS;
65413
65710
  const connectTimeoutMs = opts?.connectTimeoutMs ?? PERMISSION_BROKER_DEFAULT_CONNECT_TIMEOUT_MS;
65414
65711
  return new Promise((resolve9, reject) => {
65415
- const socket = connect(path101);
65712
+ const socket = connect(path102);
65416
65713
  let buffer = "";
65417
65714
  let settled = false;
65418
65715
  const settle = (fn) => {
@@ -65427,7 +65724,7 @@ function requestBrokerAsk(socketPath, ask, opts) {
65427
65724
  settle(
65428
65725
  () => reject(
65429
65726
  new Error(
65430
- `permission broker unavailable at "${path101}" (connect timed out after ${connectTimeoutMs}ms)`
65727
+ `permission broker unavailable at "${path102}" (connect timed out after ${connectTimeoutMs}ms)`
65431
65728
  )
65432
65729
  )
65433
65730
  );
@@ -66616,7 +66913,7 @@ var init_prereqChecks = __esm({
66616
66913
 
66617
66914
  // src/cli/plugins/prefs.ts
66618
66915
  import { existsSync as existsSync53, readFileSync as readFileSync40, writeFileSync as writeFileSync23, mkdirSync as mkdirSync20 } from "node:fs";
66619
- import path83 from "node:path";
66916
+ import path84 from "node:path";
66620
66917
  function getPluginPrefsPath() {
66621
66918
  return pluginsPrefsPath();
66622
66919
  }
@@ -66639,7 +66936,7 @@ function getPluginPrefs() {
66639
66936
  }
66640
66937
  function writePluginPrefs(prefs) {
66641
66938
  const file2 = getPluginPrefsPath();
66642
- mkdirSync20(path83.dirname(file2), { recursive: true });
66939
+ mkdirSync20(path84.dirname(file2), { recursive: true });
66643
66940
  writeFileSync23(file2, JSON.stringify(prefs, null, 2), {
66644
66941
  encoding: "utf-8",
66645
66942
  mode: 384
@@ -66677,7 +66974,7 @@ __export(registry_exports, {
66677
66974
  isBinaryOnPath: () => isBinaryOnPath
66678
66975
  });
66679
66976
  import { existsSync as existsSync54 } from "node:fs";
66680
- import path84 from "node:path";
66977
+ import path85 from "node:path";
66681
66978
  function detectLocalBin(bin) {
66682
66979
  return (cwd) => {
66683
66980
  try {
@@ -66695,7 +66992,7 @@ function isBinaryOnPath(bin, opts = {}) {
66695
66992
  const platform = opts.platform ?? process.platform;
66696
66993
  const exists = opts.exists ?? existsSync54;
66697
66994
  const pathEnv = opts.pathEnv ?? process.env.PATH ?? "";
66698
- const pathMod = platform === "win32" ? path84.win32 : path84.posix;
66995
+ const pathMod = platform === "win32" ? path85.win32 : path85.posix;
66699
66996
  const sep4 = platform === "win32" ? ";" : ":";
66700
66997
  const dirs = pathEnv.split(sep4).filter((d) => d.length > 0);
66701
66998
  const candidates = [bin];
@@ -67800,7 +68097,7 @@ var init_policy = __esm({
67800
68097
 
67801
68098
  // src/cli/orchestration/facts.ts
67802
68099
  import { promises as fs44 } from "node:fs";
67803
- import path88 from "node:path";
68100
+ import path89 from "node:path";
67804
68101
  async function collectRepoFileCount(root = process.cwd()) {
67805
68102
  try {
67806
68103
  await fs44.readdir(root);
@@ -67820,7 +68117,7 @@ async function collectRepoFileCount(root = process.cwd()) {
67820
68117
  }
67821
68118
  for (const e of entries) {
67822
68119
  if (e.isDirectory()) {
67823
- if (!SKIP_DIRS.has(e.name)) queue.push(path88.join(dir, e.name));
68120
+ if (!SKIP_DIRS.has(e.name)) queue.push(path89.join(dir, e.name));
67824
68121
  } else if (e.isFile()) {
67825
68122
  count++;
67826
68123
  if (count > MAX_WALK_FILES) return count;
@@ -67918,7 +68215,7 @@ var init_streamScrub = __esm({
67918
68215
  });
67919
68216
 
67920
68217
  // src/cli/harnessState.ts
67921
- import path89 from "node:path";
68218
+ import path90 from "node:path";
67922
68219
  function asString4(v) {
67923
68220
  return typeof v === "string" ? v : "";
67924
68221
  }
@@ -68093,7 +68390,7 @@ function contractFor(t) {
68093
68390
  };
68094
68391
  }
68095
68392
  async function readHarnessState(sessionDir, cache4) {
68096
- const report = await readSessionLogCached(path89.join(sessionDir, "events.jsonl"), cache4);
68393
+ const report = await readSessionLogCached(path90.join(sessionDir, "events.jsonl"), cache4);
68097
68394
  return deriveHarnessState(report.events);
68098
68395
  }
68099
68396
  var init_harnessState = __esm({
@@ -68104,12 +68401,12 @@ var init_harnessState = __esm({
68104
68401
  });
68105
68402
 
68106
68403
  // src/cli/headless/harnessStateEmit.ts
68107
- import path90 from "node:path";
68404
+ import path91 from "node:path";
68108
68405
  async function emitHarnessStateEvent(opts) {
68109
68406
  if (opts.output !== "json") return;
68110
68407
  try {
68111
68408
  const sessionsDir2 = resolveSessionsDir({ workspaceRoot: opts.workspaceRoot });
68112
- const state3 = await readHarnessState(path90.join(sessionsDir2, opts.spine.sessionId));
68409
+ const state3 = await readHarnessState(path91.join(sessionsDir2, opts.spine.sessionId));
68113
68410
  opts.emitEvent({ type: "harness_state", ...state3 });
68114
68411
  } catch (err) {
68115
68412
  const msg = err instanceof Error ? err.message : String(err);
@@ -68666,13 +68963,13 @@ var init_verifierLifecycle = __esm({
68666
68963
 
68667
68964
  // src/cli/extensions/sandboxedFs.ts
68668
68965
  import { promises as fsp } from "node:fs";
68669
- import path91 from "node:path";
68966
+ import path92 from "node:path";
68670
68967
  function errText(prefix, p3, err) {
68671
68968
  const msg = err instanceof Error ? err.message : String(err);
68672
68969
  return `[extension-fs] ${prefix} "${p3}": ${msg}`;
68673
68970
  }
68674
68971
  function bindSandboxedFs(root) {
68675
- const resolvedRoot = path91.resolve(root);
68972
+ const resolvedRoot = path92.resolve(root);
68676
68973
  return {
68677
68974
  root: resolvedRoot,
68678
68975
  async readFile(relativePath) {
@@ -68688,7 +68985,7 @@ function bindSandboxedFs(root) {
68688
68985
  try {
68689
68986
  const target = resolveSandboxedPath(relativePath, { root: resolvedRoot });
68690
68987
  verifyContainment(target, { root: resolvedRoot });
68691
- await fsp.mkdir(path91.dirname(target), { recursive: true });
68988
+ await fsp.mkdir(path92.dirname(target), { recursive: true });
68692
68989
  await fsp.writeFile(target, data, "utf8");
68693
68990
  return typedOk({ path: target });
68694
68991
  } catch (err) {
@@ -68873,7 +69170,7 @@ var init_loader = __esm({
68873
69170
 
68874
69171
  // src/cli/headless/runOneTurn.ts
68875
69172
  import { promises as fs45 } from "node:fs";
68876
- import path92 from "node:path";
69173
+ import path93 from "node:path";
68877
69174
  function planModeFromOpts(opts) {
68878
69175
  return (opts.phase ?? "build") === "plan";
68879
69176
  }
@@ -69443,7 +69740,7 @@ async function runOneTurn(opts, provider, model, providerStream, extras) {
69443
69740
  if (json3) {
69444
69741
  if (opts.exportSessionPath === "-") process.stdout.write(json3 + "\n");
69445
69742
  else {
69446
- await fs45.mkdir(path92.dirname(opts.exportSessionPath), { recursive: true }).catch(() => void 0);
69743
+ await fs45.mkdir(path93.dirname(opts.exportSessionPath), { recursive: true }).catch(() => void 0);
69447
69744
  await fs45.writeFile(opts.exportSessionPath, json3, "utf8");
69448
69745
  }
69449
69746
  }
@@ -70492,9 +70789,9 @@ __export(triggerLock_exports, {
70492
70789
  releaseLock: () => releaseLock
70493
70790
  });
70494
70791
  import { promises as fs46 } from "node:fs";
70495
- import * as path93 from "node:path";
70792
+ import * as path94 from "node:path";
70496
70793
  function lockPath(projectRoot) {
70497
- return path93.join(projectRoot, ".zelari", "trigger.lock");
70794
+ return path94.join(projectRoot, ".zelari", "trigger.lock");
70498
70795
  }
70499
70796
  function isPidAlive(pid) {
70500
70797
  try {
@@ -70507,7 +70804,7 @@ function isPidAlive(pid) {
70507
70804
  }
70508
70805
  async function acquireLock(projectRoot, now = () => /* @__PURE__ */ new Date()) {
70509
70806
  const lp = lockPath(projectRoot);
70510
- const dir = path93.dirname(lp);
70807
+ const dir = path94.dirname(lp);
70511
70808
  await fs46.mkdir(dir, { recursive: true });
70512
70809
  try {
70513
70810
  const raw = await fs46.readFile(lp, "utf8");
@@ -70539,7 +70836,7 @@ var init_triggerLock = __esm({
70539
70836
 
70540
70837
  // src/cli/runHeadless.ts
70541
70838
  import { promises as fs47 } from "node:fs";
70542
- import path94 from "node:path";
70839
+ import path95 from "node:path";
70543
70840
  import { randomUUID as randomUUID10 } from "node:crypto";
70544
70841
  async function runHeadless(opts) {
70545
70842
  resetTaskSpawnCount();
@@ -70813,7 +71110,7 @@ async function runHeadlessKrakenGraph(opts, provider, model) {
70813
71110
  try {
70814
71111
  let preflightGraph;
70815
71112
  if (opts.runPlan && opts.runPlan.trim() !== "") {
70816
- const planPath = path94.join(cwd, ".zelari", "radio", `plan-${opts.runPlan}.json`);
71113
+ const planPath = path95.join(cwd, ".zelari", "radio", `plan-${opts.runPlan}.json`);
70817
71114
  log(`loading pre-flight plan: ${planPath}`);
70818
71115
  let raw;
70819
71116
  try {
@@ -70856,8 +71153,8 @@ async function runHeadlessKrakenGraph(opts, provider, model) {
70856
71153
  log(formatKrakenGraphAscii2(graph));
70857
71154
  if (opts.planOnly) {
70858
71155
  const planId = randomUUID10();
70859
- const planDir = path94.join(cwd, ".zelari", "radio");
70860
- const planPath = path94.join(planDir, `plan-${planId}.json`);
71156
+ const planDir = path95.join(cwd, ".zelari", "radio");
71157
+ const planPath = path95.join(planDir, `plan-${planId}.json`);
70861
71158
  await fs47.mkdir(planDir, { recursive: true });
70862
71159
  await fs47.writeFile(
70863
71160
  planPath,
@@ -71248,7 +71545,7 @@ async function runHeadlessCouncilBody(opts, provider, model, providerStream, ext
71248
71545
  if (json3) {
71249
71546
  if (opts.exportSessionPath === "-") process.stdout.write(json3 + "\n");
71250
71547
  else {
71251
- await fs47.mkdir(path94.dirname(opts.exportSessionPath), { recursive: true }).catch(() => void 0);
71548
+ await fs47.mkdir(path95.dirname(opts.exportSessionPath), { recursive: true }).catch(() => void 0);
71252
71549
  await fs47.writeFile(opts.exportSessionPath, json3, "utf8");
71253
71550
  }
71254
71551
  }
@@ -71720,7 +72017,7 @@ ${ragContext}` : slicePrompt;
71720
72017
  if (json3) {
71721
72018
  if (opts.exportSessionPath === "-") process.stdout.write(json3 + "\n");
71722
72019
  else {
71723
- await fs47.mkdir(path94.dirname(opts.exportSessionPath), { recursive: true }).catch(() => void 0);
72020
+ await fs47.mkdir(path95.dirname(opts.exportSessionPath), { recursive: true }).catch(() => void 0);
71724
72021
  await fs47.writeFile(opts.exportSessionPath, json3, "utf8");
71725
72022
  }
71726
72023
  }
@@ -72345,7 +72642,7 @@ function upsertSkill(opts) {
72345
72642
  }
72346
72643
  dir = getProjectSkillsDir(root);
72347
72644
  }
72348
- const path101 = skillFilePath(dir, name);
72645
+ const path102 = skillFilePath(dir, name);
72349
72646
  const content = serializeSkillMd({
72350
72647
  name,
72351
72648
  description,
@@ -72354,13 +72651,13 @@ function upsertSkill(opts) {
72354
72651
  tools: opts.tools,
72355
72652
  cost: opts.cost
72356
72653
  });
72357
- const parsed = parseSkillMd(content, path101);
72654
+ const parsed = parseSkillMd(content, path102);
72358
72655
  if (!parsed) {
72359
72656
  return { ok: false, error: "Generated SKILL.md failed validation" };
72360
72657
  }
72361
- mkdirSync23(dirname13(path101), { recursive: true });
72362
- writeFileSync25(path101, content, "utf8");
72363
- return { ok: true, path: path101 };
72658
+ mkdirSync23(dirname13(path102), { recursive: true });
72659
+ writeFileSync25(path102, content, "utf8");
72660
+ return { ok: true, path: path102 };
72364
72661
  }
72365
72662
  function removeSkill(opts) {
72366
72663
  const name = opts.name.trim().toLowerCase();
@@ -72378,8 +72675,8 @@ function removeSkill(opts) {
72378
72675
  dir = getProjectSkillsDir(root);
72379
72676
  }
72380
72677
  const skillDir = join46(dir, name);
72381
- const path101 = skillFilePath(dir, name);
72382
- if (!existsSync59(path101) && !existsSync59(skillDir)) {
72678
+ const path102 = skillFilePath(dir, name);
72679
+ if (!existsSync59(path102) && !existsSync59(skillDir)) {
72383
72680
  return { ok: false, error: `Skill "${name}" not found in ${dir}` };
72384
72681
  }
72385
72682
  try {
@@ -72390,7 +72687,7 @@ function removeSkill(opts) {
72390
72687
  error: err instanceof Error ? err.message : String(err)
72391
72688
  };
72392
72689
  }
72393
- return { ok: true, path: path101 };
72690
+ return { ok: true, path: path102 };
72394
72691
  }
72395
72692
  var NAME_RE, BUILTIN_SKILL_MODULES, builtinsLoaded;
72396
72693
  var init_skillConfigIo = __esm({
@@ -72511,7 +72808,7 @@ var init_jsonApi = __esm({
72511
72808
  });
72512
72809
 
72513
72810
  // src/cli/memory/mcpAdapter.ts
72514
- import * as path95 from "node:path";
72811
+ import * as path96 from "node:path";
72515
72812
  var id2, projectId, source, SearchSchema, AddSchema, LinkSchema, RetractSchema, MEMORY_MCP_TOOLS, MemoryMcpAdapter;
72516
72813
  var init_mcpAdapter = __esm({
72517
72814
  "src/cli/memory/mcpAdapter.ts"() {
@@ -72681,8 +72978,8 @@ var init_mcpAdapter = __esm({
72681
72978
  this.takeWrite();
72682
72979
  const externalFile = args.source?.file;
72683
72980
  if (externalFile) {
72684
- const normalized = path95.normalize(externalFile);
72685
- if (path95.isAbsolute(normalized) || normalized === ".." || normalized.startsWith(`..${path95.sep}`)) {
72981
+ const normalized = path96.normalize(externalFile);
72982
+ if (path96.isAbsolute(normalized) || normalized === ".." || normalized.startsWith(`..${path96.sep}`)) {
72686
72983
  throw new Error("source.file must be project-relative and cannot escape the project");
72687
72984
  }
72688
72985
  }
@@ -73209,12 +73506,12 @@ function ensureHome() {
73209
73506
  }
73210
73507
  }
73211
73508
  function loadCompanionConfig() {
73212
- const path101 = getCompanionConfigPath();
73213
- if (!existsSync60(path101)) {
73509
+ const path102 = getCompanionConfigPath();
73510
+ if (!existsSync60(path102)) {
73214
73511
  return { projects: [] };
73215
73512
  }
73216
73513
  try {
73217
- const raw = JSON.parse(readFileSync45(path101, "utf8"));
73514
+ const raw = JSON.parse(readFileSync45(path102, "utf8"));
73218
73515
  const projects = Array.isArray(raw.projects) ? raw.projects.filter(
73219
73516
  (p3) => p3 && typeof p3.path === "string" && p3.path.trim() && typeof (p3.id ?? p3.name) === "string"
73220
73517
  ).map((p3) => ({
@@ -73252,16 +73549,16 @@ function loadOrCreateToken(explicit) {
73252
73549
  return { token: explicit.trim(), created: false };
73253
73550
  }
73254
73551
  ensureHome();
73255
- const path101 = getCompanionTokenPath();
73256
- if (existsSync60(path101)) {
73257
- const t = readFileSync45(path101, "utf8").trim();
73552
+ const path102 = getCompanionTokenPath();
73553
+ if (existsSync60(path102)) {
73554
+ const t = readFileSync45(path102, "utf8").trim();
73258
73555
  if (t) return { token: t, created: false };
73259
73556
  }
73260
73557
  const token = randomBytes7(24).toString("base64url");
73261
- writeFileSync26(path101, token + "\n", "utf8");
73558
+ writeFileSync26(path102, token + "\n", "utf8");
73262
73559
  try {
73263
73560
  const fs49 = __require("node:fs");
73264
- fs49.chmodSync?.(path101, 384);
73561
+ fs49.chmodSync?.(path102, 384);
73265
73562
  } catch {
73266
73563
  }
73267
73564
  return { token, created: true };
@@ -73286,17 +73583,17 @@ function mergeProjects(cfg, extraPaths) {
73286
73583
  byId.set(p3.id, p3);
73287
73584
  }
73288
73585
  for (const raw of extraPaths) {
73289
- const path101 = raw.trim();
73290
- if (!path101) continue;
73291
- let id3 = slugFromPath(path101);
73586
+ const path102 = raw.trim();
73587
+ if (!path102) continue;
73588
+ let id3 = slugFromPath(path102);
73292
73589
  let n = 2;
73293
- while (byId.has(id3) && byId.get(id3).path !== path101) {
73294
- id3 = `${slugFromPath(path101)}-${n++}`;
73590
+ while (byId.has(id3) && byId.get(id3).path !== path102) {
73591
+ id3 = `${slugFromPath(path102)}-${n++}`;
73295
73592
  }
73296
73593
  byId.set(id3, {
73297
73594
  id: id3,
73298
- name: slugFromPath(path101),
73299
- path: path101
73595
+ name: slugFromPath(path102),
73596
+ path: path102
73300
73597
  });
73301
73598
  }
73302
73599
  return [...byId.values()];
@@ -73539,7 +73836,7 @@ var init_askUserBridge = __esm({
73539
73836
 
73540
73837
  // src/cli/serve/spineLockSweep.ts
73541
73838
  import { promises as fs48 } from "node:fs";
73542
- import path96 from "node:path";
73839
+ import path97 from "node:path";
73543
73840
  async function sweepOrphanSpineLocks(sessionsDir2, options = {}) {
73544
73841
  const dir = sessionsDir2 ?? resolveSessionsDir();
73545
73842
  const onSwept = options.onSwept ?? ((sessionId2, reason) => {
@@ -73557,7 +73854,7 @@ async function sweepOrphanSpineLocks(sessionsDir2, options = {}) {
73557
73854
  return result;
73558
73855
  }
73559
73856
  for (const sessionId2 of entries) {
73560
- const lockPath2 = path96.join(dir, sessionId2, "writer.lock");
73857
+ const lockPath2 = path97.join(dir, sessionId2, "writer.lock");
73561
73858
  try {
73562
73859
  const raw = await fs48.readFile(lockPath2, "utf-8");
73563
73860
  let lockInfo = {};
@@ -74555,9 +74852,9 @@ async function runCompanionServe(opts = {}) {
74555
74852
  return;
74556
74853
  }
74557
74854
  const url2 = parseUrl(req);
74558
- const path101 = url2.pathname.replace(/\/+$/, "") || "/";
74855
+ const path102 = url2.pathname.replace(/\/+$/, "") || "/";
74559
74856
  try {
74560
- if (req.method === "GET" && (path101 === "/health" || path101 === "/v1/health")) {
74857
+ if (req.method === "GET" && (path102 === "/health" || path102 === "/v1/health")) {
74561
74858
  sendJson2(res, 200, {
74562
74859
  ok: true,
74563
74860
  service: "zelari-companion",
@@ -74569,18 +74866,18 @@ async function runCompanionServe(opts = {}) {
74569
74866
  });
74570
74867
  return;
74571
74868
  }
74572
- if (path101.startsWith("/v1")) {
74869
+ if (path102.startsWith("/v1")) {
74573
74870
  if (!tokenMatches(token, getBearer(req))) {
74574
74871
  sendJson2(res, 401, { ok: false, error: "unauthorized" });
74575
74872
  return;
74576
74873
  }
74577
74874
  }
74578
- if (req.method === "GET" && path101 === "/v1/config") {
74875
+ if (req.method === "GET" && path102 === "/v1/config") {
74579
74876
  const snap = buildDesktopConfigSnapshot();
74580
74877
  sendJson2(res, 200, { ok: true, ...snap });
74581
74878
  return;
74582
74879
  }
74583
- if (req.method === "GET" && path101 === "/v1/projects") {
74880
+ if (req.method === "GET" && path102 === "/v1/projects") {
74584
74881
  sendJson2(res, 200, {
74585
74882
  ok: true,
74586
74883
  projects: projects.map((p3) => ({
@@ -74591,7 +74888,7 @@ async function runCompanionServe(opts = {}) {
74591
74888
  });
74592
74889
  return;
74593
74890
  }
74594
- if (req.method === "GET" && path101 === "/v1/runs") {
74891
+ if (req.method === "GET" && path102 === "/v1/runs") {
74595
74892
  sendJson2(res, 200, {
74596
74893
  ok: true,
74597
74894
  active: runs.getActive(),
@@ -74609,7 +74906,7 @@ async function runCompanionServe(opts = {}) {
74609
74906
  });
74610
74907
  return;
74611
74908
  }
74612
- if (req.method === "POST" && path101 === "/v1/runs") {
74909
+ if (req.method === "POST" && path102 === "/v1/runs") {
74613
74910
  const raw = await readBody(req);
74614
74911
  let body = {};
74615
74912
  try {
@@ -74657,7 +74954,7 @@ async function runCompanionServe(opts = {}) {
74657
74954
  });
74658
74955
  return;
74659
74956
  }
74660
- const eventsMatch = /^\/v1\/runs\/([^/]+)\/events$/.exec(path101);
74957
+ const eventsMatch = /^\/v1\/runs\/([^/]+)\/events$/.exec(path102);
74661
74958
  if (req.method === "GET" && eventsMatch) {
74662
74959
  const runId = eventsMatch[1];
74663
74960
  const run = runs.getRun(runId);
@@ -74722,7 +75019,7 @@ async function runCompanionServe(opts = {}) {
74722
75019
  }, 500);
74723
75020
  return;
74724
75021
  }
74725
- const cancelMatch = /^\/v1\/runs\/([^/]+)\/cancel$/.exec(path101);
75022
+ const cancelMatch = /^\/v1\/runs\/([^/]+)\/cancel$/.exec(path102);
74726
75023
  if (req.method === "POST" && cancelMatch) {
74727
75024
  const runId = cancelMatch[1];
74728
75025
  const result = runs.cancel(runId);
@@ -74733,7 +75030,7 @@ async function runCompanionServe(opts = {}) {
74733
75030
  sendJson2(res, 200, { ok: true, cancelled: runId });
74734
75031
  return;
74735
75032
  }
74736
- const steerMatch = /^\/v1\/runs\/([^/]+)\/steer$/.exec(path101);
75033
+ const steerMatch = /^\/v1\/runs\/([^/]+)\/steer$/.exec(path102);
74737
75034
  if (req.method === "POST" && steerMatch) {
74738
75035
  const runId = steerMatch[1];
74739
75036
  const raw = await readBody(req);
@@ -74902,11 +75199,11 @@ import { execSync as execSync2 } from "node:child_process";
74902
75199
  import { existsSync as existsSync62, readFileSync as readFileSync46, readlinkSync, statSync as statSync10 } from "node:fs";
74903
75200
  import { createRequire as createRequire3 } from "node:module";
74904
75201
  import { fileURLToPath as fileURLToPath3 } from "node:url";
74905
- import path97 from "node:path";
75202
+ import path98 from "node:path";
74906
75203
  function findPackageRoot(start) {
74907
75204
  let dir = start;
74908
75205
  for (let i = 0; i < 6; i += 1) {
74909
- const candidate = path97.join(dir, "package.json");
75206
+ const candidate = path98.join(dir, "package.json");
74910
75207
  if (existsSync62(candidate)) {
74911
75208
  try {
74912
75209
  const pkg = JSON.parse(readFileSync46(candidate, "utf8"));
@@ -74914,11 +75211,11 @@ function findPackageRoot(start) {
74914
75211
  } catch {
74915
75212
  }
74916
75213
  }
74917
- const parent = path97.dirname(dir);
75214
+ const parent = path98.dirname(dir);
74918
75215
  if (parent === dir) break;
74919
75216
  dir = parent;
74920
75217
  }
74921
- return path97.resolve(__dirname3, "..", "..", "..");
75218
+ return path98.resolve(__dirname3, "..", "..", "..");
74922
75219
  }
74923
75220
  function tryExec(cmd) {
74924
75221
  try {
@@ -74932,7 +75229,7 @@ function tryExec(cmd) {
74932
75229
  }
74933
75230
  function readPackageJson4() {
74934
75231
  try {
74935
- const pkgPath = path97.join(packageRoot, "package.json");
75232
+ const pkgPath = path98.join(packageRoot, "package.json");
74936
75233
  return JSON.parse(readFileSync46(pkgPath, "utf8"));
74937
75234
  } catch {
74938
75235
  return null;
@@ -74944,7 +75241,7 @@ function getGlobalPrefix() {
74944
75241
  return (process.env.npm_config_prefix || process.env.NPM_CONFIG_PREFIX || "").trim();
74945
75242
  }
74946
75243
  function isSourceCheckout() {
74947
- return existsSync62(path97.join(packageRoot, "src", "cli", "main.ts")) && existsSync62(path97.join(packageRoot, "apps", "desktop", "package.json"));
75244
+ return existsSync62(path98.join(packageRoot, "src", "cli", "main.ts")) && existsSync62(path98.join(packageRoot, "apps", "desktop", "package.json"));
74948
75245
  }
74949
75246
  function checkShim(pkgName) {
74950
75247
  const prefix = getGlobalPrefix();
@@ -74953,9 +75250,9 @@ function checkShim(pkgName) {
74953
75250
  }
74954
75251
  const isWin = process.platform === "win32";
74955
75252
  const shimName = isWin ? "zelari-code.cmd" : "zelari-code";
74956
- const shimPath = path97.join(prefix, shimName);
75253
+ const shimPath = path98.join(prefix, shimName);
74957
75254
  if (!existsSync62(shimPath)) {
74958
- const localBin = path97.join(packageRoot, "bin", "zelari-code.js");
75255
+ const localBin = path98.join(packageRoot, "bin", "zelari-code.js");
74959
75256
  if (isSourceCheckout() && existsSync62(localBin)) {
74960
75257
  return WARN(
74961
75258
  `global shim not found at ${shimPath}
@@ -74989,8 +75286,8 @@ function checkShim(pkgName) {
74989
75286
  fix: npm install -g ${pkgName}@latest --force`
74990
75287
  );
74991
75288
  }
74992
- const resolved = path97.resolve(path97.dirname(shimPath), target);
74993
- const expected = path97.join(
75289
+ const resolved = path98.resolve(path98.dirname(shimPath), target);
75290
+ const expected = path98.join(
74994
75291
  prefix,
74995
75292
  "node_modules",
74996
75293
  pkgName,
@@ -75032,7 +75329,7 @@ function checkNode(pkg) {
75032
75329
  return OK(`node ${raw} (engines.node ${enginesNode ?? ">= 20.0.0"})`);
75033
75330
  }
75034
75331
  function checkBundle() {
75035
- const bundle = path97.join(packageRoot, "dist", "cli", "main.bundled.js");
75332
+ const bundle = path98.join(packageRoot, "dist", "cli", "main.bundled.js");
75036
75333
  if (!existsSync62(bundle)) {
75037
75334
  return FAIL(
75038
75335
  `dist/cli/main.bundled.js missing at ${bundle}
@@ -75053,7 +75350,7 @@ function checkRuntimeDeps() {
75053
75350
  const missing = [];
75054
75351
  for (const dep of required2) {
75055
75352
  try {
75056
- const localReq = createRequire3(path97.join(packageRoot, "package.json"));
75353
+ const localReq = createRequire3(path98.join(packageRoot, "package.json"));
75057
75354
  localReq.resolve(dep);
75058
75355
  } catch {
75059
75356
  missing.push(dep);
@@ -75330,7 +75627,7 @@ var init_doctor = __esm({
75330
75627
  init_metrics3();
75331
75628
  init_contextGrowthSummary();
75332
75629
  require3 = createRequire3(import.meta.url);
75333
- __dirname3 = path97.dirname(fileURLToPath3(import.meta.url));
75630
+ __dirname3 = path98.dirname(fileURLToPath3(import.meta.url));
75334
75631
  packageRoot = findPackageRoot(__dirname3);
75335
75632
  OK = (message) => ({
75336
75633
  ok: true,
@@ -75439,7 +75736,7 @@ __export(userSettings_exports, {
75439
75736
  settingsOverrides: () => settingsOverrides
75440
75737
  });
75441
75738
  import { existsSync as existsSync63, readFileSync as readFileSync47 } from "node:fs";
75442
- import path98 from "node:path";
75739
+ import path99 from "node:path";
75443
75740
  function parseBool(raw) {
75444
75741
  const v = raw.trim().toLowerCase();
75445
75742
  if (["1", "true", "yes", "on"].includes(v)) return true;
@@ -75506,8 +75803,8 @@ function envValueFor(key, env) {
75506
75803
  function resolveUserSettings(opts = {}) {
75507
75804
  const cwd = opts.cwd ?? process.cwd();
75508
75805
  const env = opts.env ?? process.env;
75509
- const userPath = path98.join(zelariHome(), SETTINGS_FILE_NAME);
75510
- const projectPath = path98.join(cwd, ".zelari", SETTINGS_FILE_NAME);
75806
+ const userPath = path99.join(zelariHome(), SETTINGS_FILE_NAME);
75807
+ const projectPath = path99.join(cwd, ".zelari", SETTINGS_FILE_NAME);
75511
75808
  const warnings = [];
75512
75809
  const userLayer = loadFileLayer(userPath, "user", warnings);
75513
75810
  const projectLayer = loadFileLayer(projectPath, "project", warnings);
@@ -75721,7 +76018,7 @@ __export(inspectSession_exports, {
75721
76018
  renderInspectReport: () => renderInspectReport,
75722
76019
  runInspectSession: () => runInspectSession
75723
76020
  });
75724
- import path99 from "node:path";
76021
+ import path100 from "node:path";
75725
76022
  import { existsSync as existsSync64 } from "node:fs";
75726
76023
  function formatLimit(limit) {
75727
76024
  return `${Math.round(limit / 1e3)}k`;
@@ -75755,8 +76052,8 @@ function renderInspectReport(state3) {
75755
76052
  }
75756
76053
  async function runInspectSession(opts) {
75757
76054
  const sessionsDir2 = resolveSessionsDir({ workspaceRoot: opts.cwd ?? process.cwd() });
75758
- const sessionDir = path99.join(sessionsDir2, opts.sessionId);
75759
- const eventsPath = path99.join(sessionDir, "events.jsonl");
76055
+ const sessionDir = path100.join(sessionsDir2, opts.sessionId);
76056
+ const eventsPath = path100.join(sessionDir, "events.jsonl");
75760
76057
  if (!existsSync64(sessionDir)) {
75761
76058
  console.error(`zelari-code inspect: no session directory at ${sessionDir}`);
75762
76059
  return 1;
@@ -75790,14 +76087,14 @@ __export(inspect_exports, {
75790
76087
  collectInspectReport: () => collectInspectReport,
75791
76088
  runInspect: () => runInspect
75792
76089
  });
75793
- import path100 from "node:path";
76090
+ import path101 from "node:path";
75794
76091
  import { existsSync as existsSync65, readFileSync as readFileSync48, readdirSync as readdirSync13 } from "node:fs";
75795
76092
  async function collectInspectReport(cwd = process.cwd()) {
75796
76093
  ensureBuiltinSkillsLoadedSync();
75797
76094
  const snap = listSkillsSnapshot(cwd);
75798
76095
  const mcp = listMcpServers(cwd);
75799
- const userMcpPath = path100.join(zelariHome(), "mcp.json");
75800
- const projectMcpPath = path100.join(cwd, ".zelari", "mcp.json");
76096
+ const userMcpPath = path101.join(zelariHome(), "mcp.json");
76097
+ const projectMcpPath = path101.join(cwd, ".zelari", "mcp.json");
75801
76098
  const globalHooks = globalHooksDir();
75802
76099
  const projectHooks = projectHooksDir(cwd);
75803
76100
  const projectTrusted = isFolderTrusted(cwd);
@@ -75825,9 +76122,9 @@ async function collectInspectReport(cwd = process.cwd()) {
75825
76122
  configSources: [
75826
76123
  { path: userMcpPath, exists: existsSync65(userMcpPath) },
75827
76124
  { path: projectMcpPath, exists: existsSync65(projectMcpPath) },
75828
- { path: path100.join(zelariHome(), "provider.json"), exists: existsSync65(path100.join(zelariHome(), "provider.json")) },
75829
- { path: path100.join(cwd, ".zelari", "AGENTS.md"), exists: existsSync65(path100.join(cwd, ".zelari", "AGENTS.md")) },
75830
- { path: path100.join(cwd, "AGENTS.md"), exists: existsSync65(path100.join(cwd, "AGENTS.md")) }
76125
+ { path: path101.join(zelariHome(), "provider.json"), exists: existsSync65(path101.join(zelariHome(), "provider.json")) },
76126
+ { path: path101.join(cwd, ".zelari", "AGENTS.md"), exists: existsSync65(path101.join(cwd, ".zelari", "AGENTS.md")) },
76127
+ { path: path101.join(cwd, "AGENTS.md"), exists: existsSync65(path101.join(cwd, "AGENTS.md")) }
75831
76128
  ],
75832
76129
  skills: {
75833
76130
  total: snap.skills.length,
@@ -75867,8 +76164,8 @@ function listJsonFiles(dir) {
75867
76164
  }
75868
76165
  function findAgentsMd(cwd) {
75869
76166
  const candidates = [
75870
- path100.join(cwd, "AGENTS.md"),
75871
- path100.join(cwd, ".zelari", "AGENTS.md")
76167
+ path101.join(cwd, "AGENTS.md"),
76168
+ path101.join(cwd, ".zelari", "AGENTS.md")
75872
76169
  ];
75873
76170
  const found = [];
75874
76171
  for (const c of candidates) {
@@ -79085,7 +79382,7 @@ function useChatTurn(params) {
79085
79382
  } else {
79086
79383
  envConfig = await providerFromEnv();
79087
79384
  if (!envConfig) {
79088
- const active = resolveActiveProvider2();
79385
+ const active = resolveActiveProvider3();
79089
79386
  const spec = PROVIDERS.find((p3) => p3.id === active);
79090
79387
  appendSystem(
79091
79388
  setMessages,
@@ -79999,7 +80296,7 @@ async function dispatchCouncilPromptImpl(text, deps, overrides = {}) {
79999
80296
  const useLiveModel = !!(setLive && liveRef);
80000
80297
  const envConfig = await providerFromEnv();
80001
80298
  if (!envConfig) {
80002
- const active = resolveActiveProvider2();
80299
+ const active = resolveActiveProvider3();
80003
80300
  const spec = PROVIDERS.find((p3) => p3.id === active);
80004
80301
  appendSystem(
80005
80302
  setMessages,
@@ -80761,7 +81058,7 @@ async function runZelariMissionInTui(userMessage, deps, emit) {
80761
81058
  const { setMessages } = deps;
80762
81059
  const envConfig = await providerFromEnv();
80763
81060
  if (!envConfig) {
80764
- const active = resolveActiveProvider2();
81061
+ const active = resolveActiveProvider3();
80765
81062
  const spec = PROVIDERS.find((p3) => p3.id === active);
80766
81063
  emit(
80767
81064
  `No API key for the active provider "${active}". Set ${spec?.envVar ?? "the provider API key env var"} or run /login ${active} before starting a Zelari mission.`
@@ -81036,10 +81333,10 @@ init_ledger();
81036
81333
 
81037
81334
  // src/cli/evolution/proposals.ts
81038
81335
  import { existsSync as existsSync51, readFileSync as readFileSync39 } from "node:fs";
81039
- import path78 from "node:path";
81040
- var PROPOSALS_REL = path78.join(".zelari", "evolution", "proposals.jsonl");
81336
+ import path79 from "node:path";
81337
+ var PROPOSALS_REL = path79.join(".zelari", "evolution", "proposals.jsonl");
81041
81338
  function proposalsPath(cwd) {
81042
- return path78.join(cwd, PROPOSALS_REL);
81339
+ return path79.join(cwd, PROPOSALS_REL);
81043
81340
  }
81044
81341
  function readProposalStore(cwd) {
81045
81342
  const file2 = proposalsPath(cwd);
@@ -82149,11 +82446,11 @@ function handleCacheStats(ctx) {
82149
82446
  init_messageHelpers();
82150
82447
  init_serviceFactory();
82151
82448
  import { promises as fs36 } from "node:fs";
82152
- import * as path80 from "node:path";
82449
+ import * as path81 from "node:path";
82153
82450
 
82154
82451
  // src/cli/memory/promotion.ts
82155
82452
  import { promises as fs35 } from "node:fs";
82156
- import * as path79 from "node:path";
82453
+ import * as path80 from "node:path";
82157
82454
  var START = "<!-- zelari:memory-promotions:start -->";
82158
82455
  var END = "<!-- zelari:memory-promotions:end -->";
82159
82456
  var DURABLE_KINDS = /* @__PURE__ */ new Set(["fact", "decision", "constraint", "preference", "procedure"]);
@@ -82164,13 +82461,13 @@ function lineFor(node) {
82164
82461
  }
82165
82462
  async function promoteMemoryToAgentsMd(projectRoot, node) {
82166
82463
  if (node.status !== "active") {
82167
- return { added: false, path: path79.join(projectRoot, "AGENTS.md"), reason: `memory is ${node.status}` };
82464
+ return { added: false, path: path80.join(projectRoot, "AGENTS.md"), reason: `memory is ${node.status}` };
82168
82465
  }
82169
82466
  if (!DURABLE_KINDS.has(node.kind)) {
82170
- return { added: false, path: path79.join(projectRoot, "AGENTS.md"), reason: `${node.kind} is not a durable instruction kind` };
82467
+ return { added: false, path: path80.join(projectRoot, "AGENTS.md"), reason: `${node.kind} is not a durable instruction kind` };
82171
82468
  }
82172
- const root = await fs35.realpath(projectRoot).catch(() => path79.resolve(projectRoot));
82173
- const target = path79.join(root, "AGENTS.md");
82469
+ const root = await fs35.realpath(projectRoot).catch(() => path80.resolve(projectRoot));
82470
+ const target = path80.join(root, "AGENTS.md");
82174
82471
  try {
82175
82472
  const stat8 = await fs35.lstat(target);
82176
82473
  if (stat8.isSymbolicLink() || !stat8.isFile()) throw new Error("AGENTS.md must be a regular project file.");
@@ -82235,22 +82532,22 @@ function sourceLine(source2) {
82235
82532
  return entries.length ? entries.map(([key, value]) => `${key}=${value}`).join(" \xB7 ") : "unknown";
82236
82533
  }
82237
82534
  function isInside(root, target) {
82238
- const relative6 = path80.relative(root, target);
82239
- return relative6 === "" || !relative6.startsWith("..") && !path80.isAbsolute(relative6);
82535
+ const relative6 = path81.relative(root, target);
82536
+ return relative6 === "" || !relative6.startsWith("..") && !path81.isAbsolute(relative6);
82240
82537
  }
82241
82538
  async function safeExportPath(cwd, requested) {
82242
- const lexicalRoot = path80.resolve(cwd);
82539
+ const lexicalRoot = path81.resolve(cwd);
82243
82540
  const root = await fs36.realpath(lexicalRoot).catch(() => lexicalRoot);
82244
- const fallback = path80.join(root, ".zelari", "memory", `export-${Date.now()}.json`);
82245
- const target = requested?.trim() ? path80.resolve(root, requested.trim()) : fallback;
82541
+ const fallback = path81.join(root, ".zelari", "memory", `export-${Date.now()}.json`);
82542
+ const target = requested?.trim() ? path81.resolve(root, requested.trim()) : fallback;
82246
82543
  if (!isInside(root, target)) {
82247
82544
  throw new Error("Export path must stay inside the active project.");
82248
82545
  }
82249
- const parent = path80.dirname(target);
82250
- const relativeParent = path80.relative(root, parent);
82546
+ const parent = path81.dirname(target);
82547
+ const relativeParent = path81.relative(root, parent);
82251
82548
  let cursor = root;
82252
- for (const segment of relativeParent.split(path80.sep).filter(Boolean)) {
82253
- cursor = path80.join(cursor, segment);
82549
+ for (const segment of relativeParent.split(path81.sep).filter(Boolean)) {
82550
+ cursor = path81.join(cursor, segment);
82254
82551
  try {
82255
82552
  const stat8 = await fs36.lstat(cursor);
82256
82553
  if (stat8.isSymbolicLink()) {
@@ -82422,9 +82719,9 @@ ${message}` : message
82422
82719
  }
82423
82720
  case "export": {
82424
82721
  const target = await safeExportPath(ctx.cwd, args.join(" ").trim() || void 0);
82425
- await fs36.mkdir(path80.dirname(target), { recursive: true });
82426
- const root = await fs36.realpath(ctx.cwd).catch(() => path80.resolve(ctx.cwd));
82427
- const realParent = await fs36.realpath(path80.dirname(target));
82722
+ await fs36.mkdir(path81.dirname(target), { recursive: true });
82723
+ const root = await fs36.realpath(ctx.cwd).catch(() => path81.resolve(ctx.cwd));
82724
+ const realParent = await fs36.realpath(path81.dirname(target));
82428
82725
  if (!isInside(root, realParent)) {
82429
82726
  throw new Error("Export path resolves outside the active project.");
82430
82727
  }
@@ -82639,7 +82936,7 @@ import { promises as fs38 } from "node:fs";
82639
82936
  init_zod();
82640
82937
  init_taskTool();
82641
82938
  import { promises as fs37 } from "node:fs";
82642
- import path81 from "node:path";
82939
+ import path82 from "node:path";
82643
82940
  import { randomBytes as randomBytes6 } from "node:crypto";
82644
82941
  var CsvFanoutArgsSchema = external_exports.object({
82645
82942
  csv_path: external_exports.string().min(1),
@@ -82733,8 +83030,8 @@ function resolveMaxConcurrency(env = process.env) {
82733
83030
  }
82734
83031
  async function runCsvFanout(args, deps, opts) {
82735
83032
  const start = Date.now();
82736
- const absCsv = path81.isAbsolute(args.csv_path) ? args.csv_path : path81.join(opts.parentCwd, args.csv_path);
82737
- const absOut = path81.isAbsolute(args.output_csv_path) ? args.output_csv_path : path81.join(opts.parentCwd, args.output_csv_path);
83033
+ const absCsv = path82.isAbsolute(args.csv_path) ? args.csv_path : path82.join(opts.parentCwd, args.csv_path);
83034
+ const absOut = path82.isAbsolute(args.output_csv_path) ? args.output_csv_path : path82.join(opts.parentCwd, args.output_csv_path);
82738
83035
  const { headers: headers3, rows } = await readCsv(absCsv);
82739
83036
  if (headers3.length === 0) {
82740
83037
  throw new Error(`kraken_csv_fanout: ${absCsv} is empty`);
@@ -82790,7 +83087,7 @@ async function runCsvFanout(args, deps, opts) {
82790
83087
  errored += 1;
82791
83088
  errors.push(`${row[args.id_column] ?? i}: ${res.error}`);
82792
83089
  }
82793
- await fs37.mkdir(path81.dirname(absOut), { recursive: true });
83090
+ await fs37.mkdir(path82.dirname(absOut), { recursive: true });
82794
83091
  await queueWrite(serializeCsv(outHeaders, outputRecords));
82795
83092
  }
82796
83093
  }
@@ -82985,7 +83282,7 @@ function splitArgs(s) {
82985
83282
  // src/cli/slashHandlers/krakenWorkbench.ts
82986
83283
  init_messageHelpers();
82987
83284
  import { promises as fs39 } from "node:fs";
82988
- import path82 from "node:path";
83285
+ import path83 from "node:path";
82989
83286
 
82990
83287
  // src/cli/kraken/workbenchView.ts
82991
83288
  var EMPTY = {
@@ -83102,14 +83399,14 @@ function formatWorkbenchForTerminal(p3) {
83102
83399
 
83103
83400
  // src/cli/slashHandlers/krakenWorkbench.ts
83104
83401
  async function handleKrakenWorkbench(ctx) {
83105
- const dir = path82.join(ctx.cwd, ".zelari", "radio");
83402
+ const dir = path83.join(ctx.cwd, ".zelari", "radio");
83106
83403
  let latest = null;
83107
83404
  let latestMtime = 0;
83108
83405
  try {
83109
83406
  const files = await fs39.readdir(dir);
83110
83407
  for (const f of files) {
83111
83408
  if (!f.startsWith("workbench-") || !f.endsWith(".md")) continue;
83112
- const full = path82.join(dir, f);
83409
+ const full = path83.join(dir, f);
83113
83410
  const stat8 = await fs39.stat(full);
83114
83411
  if (stat8.mtimeMs > latestMtime) {
83115
83412
  latestMtime = stat8.mtimeMs;
@@ -83126,10 +83423,10 @@ async function handleKrakenWorkbench(ctx) {
83126
83423
  const parsed = parseWorkbench(content);
83127
83424
  const rendered = formatWorkbenchForTerminal(parsed);
83128
83425
  if (!rendered.trim()) {
83129
- appendSystem(ctx.setMessages, `[kraken workbench] ${path82.basename(latest)}: (no nodes / no events yet)`);
83426
+ appendSystem(ctx.setMessages, `[kraken workbench] ${path83.basename(latest)}: (no nodes / no events yet)`);
83130
83427
  return;
83131
83428
  }
83132
- appendSystem(ctx.setMessages, `[kraken workbench] ${path82.basename(latest)}:
83429
+ appendSystem(ctx.setMessages, `[kraken workbench] ${path83.basename(latest)}:
83133
83430
  ${rendered}`);
83134
83431
  }
83135
83432
 
@@ -83437,14 +83734,14 @@ ${result.output.split("\n").slice(-8).join("\n")}` : "";
83437
83734
  init_messageHelpers();
83438
83735
  init_paths();
83439
83736
  import { promises as fs40 } from "node:fs";
83440
- import path85 from "node:path";
83737
+ import path86 from "node:path";
83441
83738
  async function handlePromoteMember(ctx, memberId) {
83442
83739
  try {
83443
83740
  const { promoteMember: promoteMember2 } = await Promise.resolve().then(() => (init_council(), council_exports));
83444
83741
  const { skill, markdown } = promoteMember2(memberId);
83445
83742
  const skillDir = skillsDir();
83446
83743
  await fs40.mkdir(skillDir, { recursive: true });
83447
- const filePath = path85.join(skillDir, `${skill.id}.md`);
83744
+ const filePath = path86.join(skillDir, `${skill.id}.md`);
83448
83745
  const previous = await fs40.readFile(filePath, "utf8").catch(() => null);
83449
83746
  const { createHash: createHash25 } = await import("node:crypto");
83450
83747
  const sha = (s) => createHash25("sha256").update(s, "utf8").digest("hex");
@@ -83470,7 +83767,7 @@ ${lineage}
83470
83767
  // src/cli/branchManager.ts
83471
83768
  init_paths();
83472
83769
  import { promises as fs41, existsSync as existsSync55, readFileSync as readFileSync41, writeFileSync as writeFileSync24, mkdirSync as mkdirSync21, statSync as statSync7, rmSync as rmSync3 } from "node:fs";
83473
- import path86 from "node:path";
83770
+ import path87 from "node:path";
83474
83771
  var META_FILENAME = "meta.json";
83475
83772
  var SESSIONS_SUBDIR = "sessions";
83476
83773
  function getBranchesBaseDir() {
@@ -83480,13 +83777,13 @@ function getSessionsBaseDir() {
83480
83777
  return sessionsDir();
83481
83778
  }
83482
83779
  function branchPathFor(name, baseDir) {
83483
- return path86.join(baseDir, name);
83780
+ return path87.join(baseDir, name);
83484
83781
  }
83485
83782
  function metaPathFor(name, baseDir) {
83486
- return path86.join(baseDir, name, META_FILENAME);
83783
+ return path87.join(baseDir, name, META_FILENAME);
83487
83784
  }
83488
83785
  function sessionsPathFor(name, baseDir) {
83489
- return path86.join(baseDir, name, SESSIONS_SUBDIR);
83786
+ return path87.join(baseDir, name, SESSIONS_SUBDIR);
83490
83787
  }
83491
83788
  function readBranchMeta(name, baseDir) {
83492
83789
  const metaPath = metaPathFor(name, baseDir);
@@ -83511,7 +83808,7 @@ function readBranchMeta(name, baseDir) {
83511
83808
  }
83512
83809
  function writeBranchMeta(name, baseDir, meta3) {
83513
83810
  const metaPath = metaPathFor(name, baseDir);
83514
- mkdirSync21(path86.dirname(metaPath), { recursive: true });
83811
+ mkdirSync21(path87.dirname(metaPath), { recursive: true });
83515
83812
  writeFileSync24(metaPath, JSON.stringify(meta3, null, 2), "utf-8");
83516
83813
  }
83517
83814
  async function countSessions(name, baseDir) {
@@ -83562,14 +83859,14 @@ async function createBranch(name, fromSessionId, baseDir = getBranchesBaseDir(),
83562
83859
  if (branchExists(name, baseDir)) {
83563
83860
  throw new BranchAlreadyExistsError(name);
83564
83861
  }
83565
- const sourcePath = path86.join(sessionsBaseDir, `${fromSessionId}.jsonl`);
83862
+ const sourcePath = path87.join(sessionsBaseDir, `${fromSessionId}.jsonl`);
83566
83863
  if (!existsSync55(sourcePath)) {
83567
83864
  throw new SessionNotFoundError(`Source session "${fromSessionId}" not found at ${sourcePath}`);
83568
83865
  }
83569
83866
  const branchPath = branchPathFor(name, baseDir);
83570
83867
  const branchSessionsPath = sessionsPathFor(name, baseDir);
83571
83868
  mkdirSync21(branchSessionsPath, { recursive: true });
83572
- const destPath = path86.join(branchSessionsPath, `${fromSessionId}.jsonl`);
83869
+ const destPath = path87.join(branchSessionsPath, `${fromSessionId}.jsonl`);
83573
83870
  await fs41.copyFile(sourcePath, destPath);
83574
83871
  const meta3 = {
83575
83872
  name,
@@ -83673,14 +83970,14 @@ async function handleBranchCheckout(ctx, branchName) {
83673
83970
  // src/cli/slashHandlers/workspace.ts
83674
83971
  init_messageHelpers();
83675
83972
  import { promises as fs42 } from "node:fs";
83676
- import path87 from "node:path";
83973
+ import path88 from "node:path";
83677
83974
  async function handleWorkspaceShow(ctx, what) {
83678
83975
  try {
83679
- const zelari = path87.join(process.cwd(), ".zelari");
83976
+ const zelari = path88.join(process.cwd(), ".zelari");
83680
83977
  let content;
83681
83978
  switch (what) {
83682
83979
  case "plan": {
83683
- const planPath = path87.join(zelari, "plan.md");
83980
+ const planPath = path88.join(zelari, "plan.md");
83684
83981
  try {
83685
83982
  content = await fs42.readFile(planPath, "utf-8");
83686
83983
  } catch {
@@ -83689,7 +83986,7 @@ async function handleWorkspaceShow(ctx, what) {
83689
83986
  break;
83690
83987
  }
83691
83988
  case "decisions": {
83692
- const decisionsDir = path87.join(zelari, "decisions");
83989
+ const decisionsDir = path88.join(zelari, "decisions");
83693
83990
  try {
83694
83991
  const files = (await fs42.readdir(decisionsDir)).filter((f) => f.endsWith(".md")).sort();
83695
83992
  if (files.length === 0) {
@@ -83699,7 +83996,7 @@ async function handleWorkspaceShow(ctx, what) {
83699
83996
  `];
83700
83997
  const { parseFrontmatter: parseFrontmatter2 } = await Promise.resolve().then(() => (init_storage(), storage_exports));
83701
83998
  for (const f of files) {
83702
- const raw = await fs42.readFile(path87.join(decisionsDir, f), "utf-8");
83999
+ const raw = await fs42.readFile(path88.join(decisionsDir, f), "utf-8");
83703
84000
  const { meta: meta3, body } = parseFrontmatter2(raw);
83704
84001
  const title = meta3.title ?? body.split("\n")[0]?.replace(/^#\s*/, "").trim() ?? f;
83705
84002
  lines.push(`- **${f.replace(/\.md$/, "")}** [${meta3.status ?? "unknown"}] ${title}`);
@@ -83712,7 +84009,7 @@ async function handleWorkspaceShow(ctx, what) {
83712
84009
  break;
83713
84010
  }
83714
84011
  case "risks": {
83715
- const risksPath = path87.join(zelari, "risks.md");
84012
+ const risksPath = path88.join(zelari, "risks.md");
83716
84013
  try {
83717
84014
  content = await fs42.readFile(risksPath, "utf-8");
83718
84015
  } catch {
@@ -83721,7 +84018,7 @@ async function handleWorkspaceShow(ctx, what) {
83721
84018
  break;
83722
84019
  }
83723
84020
  case "agents": {
83724
- const agentsPath = path87.join(process.cwd(), "AGENTS.MD");
84021
+ const agentsPath = path88.join(process.cwd(), "AGENTS.MD");
83725
84022
  try {
83726
84023
  content = await fs42.readFile(agentsPath, "utf-8");
83727
84024
  } catch {
@@ -83730,7 +84027,7 @@ async function handleWorkspaceShow(ctx, what) {
83730
84027
  break;
83731
84028
  }
83732
84029
  case "docs": {
83733
- const docsDir = path87.join(zelari, "docs");
84030
+ const docsDir = path88.join(zelari, "docs");
83734
84031
  try {
83735
84032
  const files = (await fs42.readdir(docsDir)).filter((f) => f.endsWith(".md")).sort();
83736
84033
  content = files.length ? `# Docs (${files.length})
@@ -83772,7 +84069,7 @@ async function handleWorkspaceReset(ctx, force) {
83772
84069
  return;
83773
84070
  }
83774
84071
  try {
83775
- const target = path87.join(process.cwd(), ".zelari");
84072
+ const target = path88.join(process.cwd(), ".zelari");
83776
84073
  await fs42.rm(target, { recursive: true, force: true });
83777
84074
  appendSystem(ctx.setMessages, "[workspace] .zelari/ removed");
83778
84075
  } catch (err) {
@@ -85656,8 +85953,8 @@ function normalizeDraft(raw, sourceUrl, provider, model) {
85656
85953
  let name = String(o.name ?? "").trim().toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 64);
85657
85954
  if (!name || !/^[a-z0-9][a-z0-9-]{0,63}$/.test(name)) {
85658
85955
  try {
85659
- const path101 = new URL(sourceUrl).pathname.split("/").filter(Boolean).pop()?.replace(/\.[a-z0-9]+$/i, "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
85660
- name = path101 && /^[a-z0-9]/.test(path101) ? path101 : "imported-skill";
85956
+ const path102 = new URL(sourceUrl).pathname.split("/").filter(Boolean).pop()?.replace(/\.[a-z0-9]+$/i, "").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 48);
85957
+ name = path102 && /^[a-z0-9]/.test(path102) ? path102 : "imported-skill";
85661
85958
  } catch {
85662
85959
  name = "imported-skill";
85663
85960
  }