@cleocode/cleo 2026.3.10 → 2026.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp/index.js CHANGED
@@ -15696,9 +15696,9 @@ async function systemLog(projectRoot, filters) {
15696
15696
  }
15697
15697
  async function queryAuditLogSqlite(projectRoot, filters) {
15698
15698
  try {
15699
- const { join: join57 } = await import("node:path");
15699
+ const { join: join56 } = await import("node:path");
15700
15700
  const { existsSync: existsSync54 } = await import("node:fs");
15701
- const dbPath = join57(projectRoot, ".cleo", "tasks.db");
15701
+ const dbPath = join56(projectRoot, ".cleo", "tasks.db");
15702
15702
  if (!existsSync54(dbPath)) return null;
15703
15703
  const { getDb: getDb2 } = await Promise.resolve().then(() => (init_sqlite(), sqlite_exports));
15704
15704
  const { auditLog: auditLog2 } = await Promise.resolve().then(() => (init_schema(), schema_exports));
@@ -16159,77 +16159,6 @@ var init_config_engine = __esm({
16159
16159
  }
16160
16160
  });
16161
16161
 
16162
- // src/core/mcp/index.ts
16163
- var mcp_exports = {};
16164
- __export(mcp_exports, {
16165
- detectEnvMode: () => detectEnvMode,
16166
- generateMcpServerEntry: () => generateMcpServerEntry,
16167
- getMcpServerName: () => getMcpServerName
16168
- });
16169
- import { readFileSync as readFileSync20 } from "node:fs";
16170
- import { join as join30 } from "node:path";
16171
- import { homedir as homedir6 } from "node:os";
16172
- function getMcpServerName(env) {
16173
- if (env.channel === "dev") return "cleo-dev";
16174
- if (env.channel === "beta") return "cleo-beta";
16175
- return "cleo";
16176
- }
16177
- function detectEnvMode() {
16178
- const versionPath = join30(
16179
- process.env["CLEO_HOME"] ?? join30(homedir6(), ".cleo"),
16180
- "VERSION"
16181
- );
16182
- let content;
16183
- try {
16184
- content = readFileSync20(versionPath, "utf-8");
16185
- } catch {
16186
- return { mode: "unknown", source: null, channel: "unknown" };
16187
- }
16188
- const kvPairs = {};
16189
- const lines = content.trim().split("\n");
16190
- const installedVersion = lines[0]?.trim() ?? "";
16191
- for (let i = 1; i < lines.length; i++) {
16192
- const eqIdx = lines[i].indexOf("=");
16193
- if (eqIdx > 0) {
16194
- kvPairs[lines[i].slice(0, eqIdx).trim()] = lines[i].slice(eqIdx + 1).trim();
16195
- }
16196
- }
16197
- const rawMode = kvPairs["mode"] ?? "unknown";
16198
- const mode = rawMode === "dev-ts" ? "dev-ts" : rawMode === "prod-npm" ? "prod-npm" : "unknown";
16199
- const channel = mode === "dev-ts" ? "dev" : installedVersion.includes("-beta") ? "beta" : mode === "prod-npm" ? "stable" : "unknown";
16200
- return {
16201
- mode,
16202
- source: mode === "dev-ts" ? kvPairs["source"] ?? null : null,
16203
- channel
16204
- };
16205
- }
16206
- function generateMcpServerEntry(env) {
16207
- if (env.mode === "dev-ts" && env.source) {
16208
- return {
16209
- command: "node",
16210
- args: [join30(env.source, "dist", "mcp", "index.js")],
16211
- env: {}
16212
- };
16213
- }
16214
- if (env.channel === "beta") {
16215
- return {
16216
- command: "npx",
16217
- args: ["-y", "@cleocode/cleo@beta", "mcp"],
16218
- env: {}
16219
- };
16220
- }
16221
- return {
16222
- command: "npx",
16223
- args: ["-y", "@cleocode/cleo@latest", "mcp"],
16224
- env: {}
16225
- };
16226
- }
16227
- var init_mcp = __esm({
16228
- "src/core/mcp/index.ts"() {
16229
- "use strict";
16230
- }
16231
- });
16232
-
16233
16162
  // src/core/nexus/registry.ts
16234
16163
  var registry_exports = {};
16235
16164
  __export(registry_exports, {
@@ -16253,17 +16182,17 @@ __export(registry_exports, {
16253
16182
  readRegistryRequired: () => readRegistryRequired
16254
16183
  });
16255
16184
  import { createHash as createHash6 } from "node:crypto";
16256
- import { join as join31 } from "node:path";
16185
+ import { join as join30 } from "node:path";
16257
16186
  import { mkdir as mkdir7, access as access2, readFile as readFile6 } from "node:fs/promises";
16258
16187
  import { z } from "zod";
16259
16188
  function getNexusHome() {
16260
- return process.env["NEXUS_HOME"] ?? join31(getCleoHome(), "nexus");
16189
+ return process.env["NEXUS_HOME"] ?? join30(getCleoHome(), "nexus");
16261
16190
  }
16262
16191
  function getNexusCacheDir() {
16263
- return process.env["NEXUS_CACHE_DIR"] ?? join31(getNexusHome(), "cache");
16192
+ return process.env["NEXUS_CACHE_DIR"] ?? join30(getNexusHome(), "cache");
16264
16193
  }
16265
16194
  function getRegistryPath() {
16266
- return process.env["NEXUS_REGISTRY_FILE"] ?? join31(getCleoHome(), "projects-registry.json");
16195
+ return process.env["NEXUS_REGISTRY_FILE"] ?? join30(getCleoHome(), "projects-registry.json");
16267
16196
  }
16268
16197
  function generateProjectHash2(projectPath) {
16269
16198
  const hash = createHash6("sha256").update(projectPath).digest("hex");
@@ -16305,7 +16234,7 @@ async function nexusInit() {
16305
16234
  }
16306
16235
  async function isCleoProject(projectPath) {
16307
16236
  try {
16308
- await access2(join31(projectPath, ".cleo", "todo.json"));
16237
+ await access2(join30(projectPath, ".cleo", "todo.json"));
16309
16238
  return true;
16310
16239
  } catch {
16311
16240
  return false;
@@ -16315,9 +16244,9 @@ async function readProjectMeta(projectPath) {
16315
16244
  try {
16316
16245
  let raw;
16317
16246
  try {
16318
- raw = await readFile6(join31(projectPath, ".cleo", "tasks.json"), "utf-8");
16247
+ raw = await readFile6(join30(projectPath, ".cleo", "tasks.json"), "utf-8");
16319
16248
  } catch {
16320
- raw = await readFile6(join31(projectPath, ".cleo", "todo.json"), "utf-8");
16249
+ raw = await readFile6(join30(projectPath, ".cleo", "todo.json"), "utf-8");
16321
16250
  }
16322
16251
  const data = JSON.parse(raw);
16323
16252
  const tasks2 = data.tasks ?? [];
@@ -16500,18 +16429,18 @@ var init_registry2 = __esm({
16500
16429
 
16501
16430
  // src/core/init.ts
16502
16431
  import { mkdir as mkdir8, copyFile as copyFile3, symlink, lstat, unlink as unlink3 } from "node:fs/promises";
16503
- import { existsSync as existsSync29, readFileSync as readFileSync21, readdirSync as readdirSync8 } from "node:fs";
16504
- import { join as join32, dirname as dirname8, basename as basename6 } from "node:path";
16432
+ import { existsSync as existsSync29, readFileSync as readFileSync20, readdirSync as readdirSync8 } from "node:fs";
16433
+ import { join as join31, dirname as dirname8, basename as basename6 } from "node:path";
16505
16434
  import { readFile as readFile7 } from "node:fs/promises";
16506
- import { homedir as homedir7 } from "node:os";
16435
+ import { homedir as homedir6 } from "node:os";
16507
16436
  async function initAgentDefinition(created, warnings) {
16508
16437
  const packageRoot = getPackageRoot();
16509
- const agentSourceDir = join32(packageRoot, "agents", "cleo-subagent");
16438
+ const agentSourceDir = join31(packageRoot, "agents", "cleo-subagent");
16510
16439
  if (!existsSync29(agentSourceDir)) {
16511
16440
  warnings.push("agents/cleo-subagent/ not found in package, skipping agent definition install");
16512
16441
  return;
16513
16442
  }
16514
- const globalAgentsDir = join32(homedir7(), ".agents", "agents", "cleo-subagent");
16443
+ const globalAgentsDir = join31(homedir6(), ".agents", "agents", "cleo-subagent");
16515
16444
  await mkdir8(dirname8(globalAgentsDir), { recursive: true });
16516
16445
  try {
16517
16446
  try {
@@ -16528,7 +16457,7 @@ async function initAgentDefinition(created, warnings) {
16528
16457
  await mkdir8(globalAgentsDir, { recursive: true });
16529
16458
  const files = readdirSync8(agentSourceDir);
16530
16459
  for (const file of files) {
16531
- await copyFile3(join32(agentSourceDir, file), join32(globalAgentsDir, file));
16460
+ await copyFile3(join31(agentSourceDir, file), join31(globalAgentsDir, file));
16532
16461
  }
16533
16462
  created.push("agent: cleo-subagent (copied)");
16534
16463
  } catch (copyErr) {
@@ -16536,41 +16465,6 @@ async function initAgentDefinition(created, warnings) {
16536
16465
  }
16537
16466
  }
16538
16467
  }
16539
- async function initMcpServer(projectRoot, created, warnings) {
16540
- try {
16541
- const { detectEnvMode: detectEnvMode2, generateMcpServerEntry: generateMcpServerEntry2, getMcpServerName: getMcpServerName2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
16542
- const {
16543
- getInstalledProviders: getInstalledProviders2,
16544
- installMcpServerToAll
16545
- } = await import("@cleocode/caamp");
16546
- const env = detectEnvMode2();
16547
- const serverEntry = generateMcpServerEntry2(env);
16548
- const serverName = getMcpServerName2(env);
16549
- const providers = getInstalledProviders2();
16550
- if (providers.length === 0) {
16551
- return;
16552
- }
16553
- const results = await installMcpServerToAll(
16554
- providers,
16555
- serverName,
16556
- serverEntry,
16557
- "project",
16558
- projectRoot
16559
- );
16560
- const successes = results.filter((r) => r.success);
16561
- const failures = results.filter((r) => !r.success);
16562
- if (successes.length > 0) {
16563
- created.push(`MCP server: ${successes.map((r) => r.provider.id).join(", ")}`);
16564
- }
16565
- for (const f of failures) {
16566
- if (f.error) {
16567
- warnings.push(`MCP install to ${f.provider.id}: ${f.error}`);
16568
- }
16569
- }
16570
- } catch (err) {
16571
- warnings.push(`MCP server install: ${err instanceof Error ? err.message : String(err)}`);
16572
- }
16573
- }
16574
16468
  async function initCoreSkills(created, warnings) {
16575
16469
  try {
16576
16470
  const { getInstalledProviders: getInstalledProviders2, installSkill: installSkill2, registerSkillLibraryFromPath } = await import("@cleocode/caamp");
@@ -16581,12 +16475,12 @@ async function initCoreSkills(created, warnings) {
16581
16475
  const packageRoot = getPackageRoot();
16582
16476
  let ctSkillsRoot = null;
16583
16477
  try {
16584
- const bundledPath = join32(packageRoot, "packages", "ct-skills");
16585
- if (existsSync29(join32(bundledPath, "skills.json"))) {
16478
+ const bundledPath = join31(packageRoot, "packages", "ct-skills");
16479
+ if (existsSync29(join31(bundledPath, "skills.json"))) {
16586
16480
  ctSkillsRoot = bundledPath;
16587
16481
  } else {
16588
- const ctSkillsPath = join32(packageRoot, "node_modules", "@cleocode", "ct-skills");
16589
- if (existsSync29(join32(ctSkillsPath, "skills.json"))) {
16482
+ const ctSkillsPath = join31(packageRoot, "node_modules", "@cleocode", "ct-skills");
16483
+ if (existsSync29(join31(ctSkillsPath, "skills.json"))) {
16590
16484
  ctSkillsRoot = ctSkillsPath;
16591
16485
  }
16592
16486
  }
@@ -16601,13 +16495,13 @@ async function initCoreSkills(created, warnings) {
16601
16495
  } catch {
16602
16496
  warnings.push("Failed to register skill library with CAAMP");
16603
16497
  }
16604
- const catalogPath = join32(ctSkillsRoot, "skills.json");
16605
- const catalog2 = JSON.parse(readFileSync21(catalogPath, "utf-8"));
16498
+ const catalogPath = join31(ctSkillsRoot, "skills.json");
16499
+ const catalog2 = JSON.parse(readFileSync20(catalogPath, "utf-8"));
16606
16500
  const skills = catalog2.skills ?? [];
16607
16501
  const coreSkills = skills.filter((s) => s.tier <= 2);
16608
16502
  const installed = [];
16609
16503
  for (const skill of coreSkills) {
16610
- const skillSourceDir = dirname8(join32(ctSkillsRoot, skill.path));
16504
+ const skillSourceDir = dirname8(join31(ctSkillsRoot, skill.path));
16611
16505
  if (!existsSync29(skillSourceDir)) {
16612
16506
  continue;
16613
16507
  }
@@ -16684,7 +16578,7 @@ async function initProject(opts = {}) {
16684
16578
  }
16685
16579
  try {
16686
16580
  const { getDb: getDb2 } = await Promise.resolve().then(() => (init_sqlite(), sqlite_exports));
16687
- await getDb2(join32(cleoDir, ".."));
16581
+ await getDb2(join31(cleoDir, ".."));
16688
16582
  created.push("tasks.db");
16689
16583
  } catch (err) {
16690
16584
  created.push(`tasks.db (deferred: ${err instanceof Error ? err.message : String(err)})`);
@@ -16697,7 +16591,7 @@ async function initProject(opts = {}) {
16697
16591
  created.push(".gitignore");
16698
16592
  }
16699
16593
  } else {
16700
- const gitignorePath = join32(cleoDir, ".gitignore");
16594
+ const gitignorePath = join31(cleoDir, ".gitignore");
16701
16595
  if (existsSync29(gitignorePath)) {
16702
16596
  skipped.push(".gitignore");
16703
16597
  } else {
@@ -16709,12 +16603,12 @@ async function initProject(opts = {}) {
16709
16603
  }
16710
16604
  }
16711
16605
  }
16712
- const legacySequencePath = join32(cleoDir, ".sequence");
16606
+ const legacySequencePath = join31(cleoDir, ".sequence");
16713
16607
  try {
16714
16608
  await unlink3(legacySequencePath);
16715
16609
  } catch {
16716
16610
  }
16717
- const legacySequenceJsonPath = join32(cleoDir, ".sequence.json");
16611
+ const legacySequenceJsonPath = join31(cleoDir, ".sequence.json");
16718
16612
  try {
16719
16613
  await unlink3(legacySequenceJsonPath);
16720
16614
  } catch {
@@ -16781,7 +16675,6 @@ async function initProject(opts = {}) {
16781
16675
  warnings.push(`CAAMP injection: ${err instanceof Error ? err.message : String(err)}`);
16782
16676
  }
16783
16677
  await initAgentDefinition(created, warnings);
16784
- await initMcpServer(projRoot, created, warnings);
16785
16678
  await initCoreSkills(created, warnings);
16786
16679
  await initNexusRegistration(projRoot, projectName, created, warnings);
16787
16680
  const rootGitignoreResult = await removeCleoFromRootGitignore(projRoot);
@@ -16809,8 +16702,8 @@ async function initProject(opts = {}) {
16809
16702
  async function getVersion(projectRoot) {
16810
16703
  const root = projectRoot ?? getProjectRoot();
16811
16704
  const versionPaths = [
16812
- join32(root, "VERSION"),
16813
- join32(root, "..", "VERSION")
16705
+ join31(root, "VERSION"),
16706
+ join31(root, "..", "VERSION")
16814
16707
  ];
16815
16708
  for (const versionPath of versionPaths) {
16816
16709
  try {
@@ -16822,7 +16715,7 @@ async function getVersion(projectRoot) {
16822
16715
  } catch {
16823
16716
  }
16824
16717
  }
16825
- const pkg = await readJson(join32(root, "package.json"));
16718
+ const pkg = await readJson(join31(root, "package.json"));
16826
16719
  if (pkg?.version) {
16827
16720
  return { version: pkg.version };
16828
16721
  }
@@ -16881,7 +16774,7 @@ var init_init_engine = __esm({
16881
16774
  });
16882
16775
 
16883
16776
  // src/core/lifecycle/rcasd-paths.ts
16884
- import { join as join33 } from "node:path";
16777
+ import { join as join32 } from "node:path";
16885
16778
  import { existsSync as existsSync30, mkdirSync as mkdirSync10, readdirSync as readdirSync9 } from "node:fs";
16886
16779
  function normalizeEpicId(dirName) {
16887
16780
  const match = dirName.match(EPIC_ID_PATTERN);
@@ -16889,11 +16782,11 @@ function normalizeEpicId(dirName) {
16889
16782
  }
16890
16783
  function getEpicDir(epicId, cwd) {
16891
16784
  const normalized = normalizeEpicId(epicId);
16892
- return join33(getCleoDirAbsolute(cwd), DEFAULT_DIR, normalized);
16785
+ return join32(getCleoDirAbsolute(cwd), DEFAULT_DIR, normalized);
16893
16786
  }
16894
16787
  function getStagePath(epicId, stage, cwd) {
16895
16788
  const subdir = STAGE_SUBDIRS[stage] ?? stage;
16896
- return join33(getEpicDir(epicId, cwd), subdir);
16789
+ return join32(getEpicDir(epicId, cwd), subdir);
16897
16790
  }
16898
16791
  function ensureStagePath(epicId, stage, cwd) {
16899
16792
  const path = getStagePath(epicId, stage, cwd);
@@ -17268,7 +17161,7 @@ var init_stages = __esm({
17268
17161
  // src/core/lifecycle/stage-artifacts.ts
17269
17162
  import { existsSync as existsSync31 } from "node:fs";
17270
17163
  import { readFile as readFile8, writeFile as writeFile5 } from "node:fs/promises";
17271
- import { dirname as dirname9, join as join34, relative } from "node:path";
17164
+ import { dirname as dirname9, join as join33, relative } from "node:path";
17272
17165
  function stageSlug(stage) {
17273
17166
  return stage.replace(/_/g, "-");
17274
17167
  }
@@ -17309,7 +17202,7 @@ function buildRelatedLinks(epicId, stage, absolutePath, cwd) {
17309
17202
  const artifactDir = dirname9(absolutePath);
17310
17203
  for (const prereq of prereqs) {
17311
17204
  const prereqDir = getStagePath(epicId, prereq, cwd);
17312
- const prereqFile = join34(prereqDir, `${epicId}-${stageSlug(prereq)}.md`);
17205
+ const prereqFile = join33(prereqDir, `${epicId}-${stageSlug(prereq)}.md`);
17313
17206
  if (!existsSync31(prereqFile)) {
17314
17207
  continue;
17315
17208
  }
@@ -17323,7 +17216,7 @@ function buildRelatedLinks(epicId, stage, absolutePath, cwd) {
17323
17216
  async function ensureStageArtifact(epicId, stage, cwd) {
17324
17217
  const stageDir = ensureStagePath(epicId, stage, cwd);
17325
17218
  const fileName = `${epicId}-${stageSlug(stage)}.md`;
17326
- const absolutePath = join34(stageDir, fileName);
17219
+ const absolutePath = join33(stageDir, fileName);
17327
17220
  const outputFile = toWorkspaceRelative(absolutePath, cwd);
17328
17221
  const currentContent = existsSync31(absolutePath) ? await readFile8(absolutePath, "utf-8") : buildDefaultBody(epicId, stage);
17329
17222
  const related = buildRelatedLinks(epicId, stage, absolutePath, cwd);
@@ -17400,8 +17293,8 @@ var init_evidence = __esm({
17400
17293
  });
17401
17294
 
17402
17295
  // src/core/adrs/parse.ts
17403
- import { readFileSync as readFileSync22 } from "node:fs";
17404
- import { join as join35 } from "node:path";
17296
+ import { readFileSync as readFileSync21 } from "node:fs";
17297
+ import { join as join34 } from "node:path";
17405
17298
  function extractAdrId(filename) {
17406
17299
  const match = filename.match(/^(ADR-\d+)/);
17407
17300
  return match ? match[1] : filename.replace(".md", "");
@@ -17423,8 +17316,8 @@ function extractTitle(content) {
17423
17316
  return match ? match[1].trim() : "Untitled";
17424
17317
  }
17425
17318
  function parseAdrFile(filePath, projectRoot) {
17426
- const absolutePath = filePath.startsWith("/") ? filePath : join35(projectRoot, filePath);
17427
- const content = readFileSync22(absolutePath, "utf-8");
17319
+ const absolutePath = filePath.startsWith("/") ? filePath : join34(projectRoot, filePath);
17320
+ const content = readFileSync21(absolutePath, "utf-8");
17428
17321
  const filename = filePath.split("/").pop();
17429
17322
  return {
17430
17323
  id: extractAdrId(filename),
@@ -17440,8 +17333,8 @@ var init_parse = __esm({
17440
17333
  });
17441
17334
 
17442
17335
  // src/core/adrs/sync.ts
17443
- import { readFileSync as readFileSync23, readdirSync as readdirSync10, writeFileSync as writeFileSync6, existsSync as existsSync32 } from "node:fs";
17444
- import { join as join36 } from "node:path";
17336
+ import { readFileSync as readFileSync22, readdirSync as readdirSync10, writeFileSync as writeFileSync6, existsSync as existsSync32 } from "node:fs";
17337
+ import { join as join35 } from "node:path";
17445
17338
  import { eq as eq9 } from "drizzle-orm";
17446
17339
  function extractAdrIdFromRef(ref) {
17447
17340
  const m = ref.match(/^(ADR-\d+)/);
@@ -17454,7 +17347,7 @@ function collectAdrFiles(dir) {
17454
17347
  const results = [];
17455
17348
  for (const entry of readdirSync10(dir, { withFileTypes: true })) {
17456
17349
  if (entry.isDirectory()) {
17457
- const sub = join36(dir, entry.name);
17350
+ const sub = join35(dir, entry.name);
17458
17351
  for (const f of readdirSync10(sub)) {
17459
17352
  if (f.endsWith(".md") && /^ADR-\d+/.test(f)) {
17460
17353
  results.push({ file: f, relPath: `${entry.name}/${f}` });
@@ -17467,7 +17360,7 @@ function collectAdrFiles(dir) {
17467
17360
  return results.sort((a, b) => a.file.localeCompare(b.file));
17468
17361
  }
17469
17362
  async function syncAdrsToDb(projectRoot) {
17470
- const adrsDir = join36(projectRoot, ".cleo", "adrs");
17363
+ const adrsDir = join35(projectRoot, ".cleo", "adrs");
17471
17364
  const result = { inserted: 0, updated: 0, skipped: 0, errors: [] };
17472
17365
  if (!existsSync32(adrsDir)) {
17473
17366
  return result;
@@ -17479,11 +17372,11 @@ async function syncAdrsToDb(projectRoot) {
17479
17372
  const manifestEntries2 = [];
17480
17373
  for (const { file, relPath } of activeFiles) {
17481
17374
  try {
17482
- const filePath = join36(adrsDir, relPath);
17375
+ const filePath = join35(adrsDir, relPath);
17483
17376
  const record = parseAdrFile(filePath, projectRoot);
17484
17377
  const fm = record.frontmatter;
17485
17378
  const dbRelPath = `.cleo/adrs/${relPath}`;
17486
- const content = readFileSync23(filePath, "utf-8");
17379
+ const content = readFileSync22(filePath, "utf-8");
17487
17380
  const supersedesId = fm.Supersedes ? extractAdrIdFromRef(fm.Supersedes) : null;
17488
17381
  const supersededById = fm["Superseded By"] ? extractAdrIdFromRef(fm["Superseded By"]) : null;
17489
17382
  const amendsId = fm.Amends ? extractAdrIdFromRef(fm.Amends) : null;
@@ -17525,7 +17418,7 @@ async function syncAdrsToDb(projectRoot) {
17525
17418
  }
17526
17419
  for (const { relPath } of allFiles) {
17527
17420
  try {
17528
- const filePath = join36(adrsDir, relPath);
17421
+ const filePath = join35(adrsDir, relPath);
17529
17422
  const record = parseAdrFile(filePath, projectRoot);
17530
17423
  const fm = record.frontmatter;
17531
17424
  const entry = {
@@ -17553,7 +17446,7 @@ async function syncAdrsToDb(projectRoot) {
17553
17446
  }
17554
17447
  }
17555
17448
  writeFileSync6(
17556
- join36(adrsDir, "MANIFEST.jsonl"),
17449
+ join35(adrsDir, "MANIFEST.jsonl"),
17557
17450
  manifestEntries2.map((e) => JSON.stringify(e)).join("\n") + "\n",
17558
17451
  "utf-8"
17559
17452
  );
@@ -17569,8 +17462,8 @@ var init_sync = __esm({
17569
17462
  });
17570
17463
 
17571
17464
  // src/core/adrs/link-pipeline.ts
17572
- import { readdirSync as readdirSync11, readFileSync as readFileSync24, existsSync as existsSync33 } from "node:fs";
17573
- import { join as join37 } from "node:path";
17465
+ import { readdirSync as readdirSync11, readFileSync as readFileSync23, existsSync as existsSync33 } from "node:fs";
17466
+ import { join as join36 } from "node:path";
17574
17467
  import { eq as eq10, and as and3 } from "drizzle-orm";
17575
17468
  function parseTaskIds2(raw) {
17576
17469
  if (!raw) return [];
@@ -17580,7 +17473,7 @@ function findAdrsForTask(adrsDir, taskId) {
17580
17473
  if (!existsSync33(adrsDir)) return [];
17581
17474
  return readdirSync11(adrsDir).filter((f) => f.endsWith(".md") && /^ADR-\d+/.test(f)).filter((file) => {
17582
17475
  try {
17583
- const content = readFileSync24(join37(adrsDir, file), "utf-8");
17476
+ const content = readFileSync23(join36(adrsDir, file), "utf-8");
17584
17477
  const relatedTasksMatch = content.match(/^\*\*Related Tasks\*\*:\s*(.+)$/m);
17585
17478
  if (!relatedTasksMatch) return false;
17586
17479
  const taskIds = parseTaskIds2(relatedTasksMatch[1]);
@@ -17588,7 +17481,7 @@ function findAdrsForTask(adrsDir, taskId) {
17588
17481
  } catch {
17589
17482
  return false;
17590
17483
  }
17591
- }).map((f) => join37(adrsDir, f));
17484
+ }).map((f) => join36(adrsDir, f));
17592
17485
  }
17593
17486
  async function linkPipelineAdr(projectRoot, taskId) {
17594
17487
  const result = {
@@ -17597,7 +17490,7 @@ async function linkPipelineAdr(projectRoot, taskId) {
17597
17490
  skipped: 0,
17598
17491
  errors: []
17599
17492
  };
17600
- const adrsDir = join37(projectRoot, ".cleo", "adrs");
17493
+ const adrsDir = join36(projectRoot, ".cleo", "adrs");
17601
17494
  const matchingFiles = findAdrsForTask(adrsDir, taskId);
17602
17495
  if (matchingFiles.length === 0) {
17603
17496
  return result;
@@ -17609,7 +17502,7 @@ async function linkPipelineAdr(projectRoot, taskId) {
17609
17502
  try {
17610
17503
  const record = parseAdrFile(filePath, projectRoot);
17611
17504
  const fm = record.frontmatter;
17612
- const content = readFileSync24(filePath, "utf-8");
17505
+ const content = readFileSync23(filePath, "utf-8");
17613
17506
  const relativePath = `.cleo/adrs/${filename}`;
17614
17507
  const existing = await db.select({ id: architectureDecisions.id }).from(architectureDecisions).where(eq10(architectureDecisions.id, record.id)).all();
17615
17508
  const rowBase = {
@@ -18375,7 +18268,7 @@ var init_validation_schemas = __esm({
18375
18268
  // src/core/validation/schema-validator.ts
18376
18269
  import AjvModule2 from "ajv";
18377
18270
  import addFormatsModule2 from "ajv-formats";
18378
- import { readFileSync as readFileSync25 } from "fs";
18271
+ import { readFileSync as readFileSync24 } from "fs";
18379
18272
  function createAjv() {
18380
18273
  const ajv = new Ajv2({
18381
18274
  allErrors: true,
@@ -18404,7 +18297,7 @@ function getValidator(schemaType) {
18404
18297
  return null;
18405
18298
  }
18406
18299
  try {
18407
- const schemaContent = readFileSync25(schemaPath, "utf-8");
18300
+ const schemaContent = readFileSync24(schemaPath, "utf-8");
18408
18301
  const schema = JSON.parse(schemaContent);
18409
18302
  const ajv = getAjv2();
18410
18303
  const validate = ajv.compile(schema);
@@ -18602,12 +18495,12 @@ var init_repair = __esm({
18602
18495
  });
18603
18496
 
18604
18497
  // src/core/validation/validate-ops.ts
18605
- import { readFileSync as readFileSync26, existsSync as existsSync34, appendFileSync as appendFileSync3, mkdirSync as mkdirSync11 } from "node:fs";
18498
+ import { readFileSync as readFileSync25, existsSync as existsSync34, appendFileSync as appendFileSync3, mkdirSync as mkdirSync11 } from "node:fs";
18606
18499
  import { execFileSync as execFileSync3 } from "node:child_process";
18607
- import { join as join38, dirname as dirname10, resolve as resolve6 } from "node:path";
18500
+ import { join as join37, dirname as dirname10, resolve as resolve6 } from "node:path";
18608
18501
  function readJsonFile2(filePath) {
18609
18502
  try {
18610
- const raw = readFileSync26(filePath, "utf-8");
18503
+ const raw = readFileSync25(filePath, "utf-8");
18611
18504
  return JSON.parse(raw);
18612
18505
  } catch {
18613
18506
  return null;
@@ -18622,7 +18515,7 @@ async function coreValidateSchema(type, data, projectRoot) {
18622
18515
  throw new Error(`Unknown schema type: ${type}. Valid types: ${validTypes.join(", ")}`);
18623
18516
  }
18624
18517
  if (type === "config") {
18625
- const filePath = join38(projectRoot, ".cleo", "config.json");
18518
+ const filePath = join37(projectRoot, ".cleo", "config.json");
18626
18519
  if (!existsSync34(filePath)) {
18627
18520
  throw new Error("File not found: .cleo/config.json");
18628
18521
  }
@@ -18770,7 +18663,7 @@ function coreValidateManifest(projectRoot) {
18770
18663
  message: "No manifest file found"
18771
18664
  };
18772
18665
  }
18773
- const content = readFileSync26(manifestPath, "utf-8");
18666
+ const content = readFileSync25(manifestPath, "utf-8");
18774
18667
  const lines = content.split("\n").filter((l) => l.trim());
18775
18668
  let validCount = 0;
18776
18669
  let invalidCount = 0;
@@ -18814,7 +18707,7 @@ function coreValidateOutput(filePath, taskId, projectRoot) {
18814
18707
  if (!existsSync34(fullPath)) {
18815
18708
  throw new Error(`Output file not found: ${filePath}`);
18816
18709
  }
18817
- const content = readFileSync26(fullPath, "utf-8");
18710
+ const content = readFileSync25(fullPath, "utf-8");
18818
18711
  const issues = [];
18819
18712
  if (!content.includes("# ")) {
18820
18713
  issues.push({ code: "O_MISSING_TITLE", message: "Output file should have a markdown title", severity: "warning" });
@@ -18834,11 +18727,11 @@ function coreValidateOutput(filePath, taskId, projectRoot) {
18834
18727
  };
18835
18728
  }
18836
18729
  function parseComplianceEntries(projectRoot) {
18837
- const compliancePath = join38(projectRoot, ".cleo", "metrics", "COMPLIANCE.jsonl");
18730
+ const compliancePath = join37(projectRoot, ".cleo", "metrics", "COMPLIANCE.jsonl");
18838
18731
  if (!existsSync34(compliancePath)) {
18839
18732
  return [];
18840
18733
  }
18841
- const content = readFileSync26(compliancePath, "utf-8");
18734
+ const content = readFileSync25(compliancePath, "utf-8");
18842
18735
  const entries = [];
18843
18736
  for (const line of content.split("\n")) {
18844
18737
  const trimmed = line.trim();
@@ -18898,7 +18791,7 @@ function coreComplianceRecord(taskId, result, protocol, violations, projectRoot)
18898
18791
  if (!validResults.includes(result)) {
18899
18792
  throw new Error(`Invalid result: ${result}. Valid: ${validResults.join(", ")}`);
18900
18793
  }
18901
- const compliancePath = join38(projectRoot, ".cleo", "metrics", "COMPLIANCE.jsonl");
18794
+ const compliancePath = join37(projectRoot, ".cleo", "metrics", "COMPLIANCE.jsonl");
18902
18795
  const dir = dirname10(compliancePath);
18903
18796
  if (!existsSync34(dir)) {
18904
18797
  mkdirSync11(dir, { recursive: true });
@@ -18920,8 +18813,8 @@ function coreComplianceRecord(taskId, result, protocol, violations, projectRoot)
18920
18813
  };
18921
18814
  }
18922
18815
  function coreTestStatus(projectRoot) {
18923
- const testDir = join38(projectRoot, "tests");
18924
- const mcpTestDir = join38(projectRoot, "src", "mcp", "__tests__");
18816
+ const testDir = join37(projectRoot, "tests");
18817
+ const mcpTestDir = join37(projectRoot, "src", "mcp", "__tests__");
18925
18818
  const hasBatsTests = existsSync34(testDir);
18926
18819
  const hasMcpTests = existsSync34(mcpTestDir);
18927
18820
  return {
@@ -19065,8 +18958,8 @@ async function coreCoherenceCheck(projectRoot) {
19065
18958
  };
19066
18959
  }
19067
18960
  function coreTestRun(params, projectRoot) {
19068
- const hasVitest = existsSync34(join38(projectRoot, "node_modules", ".bin", "vitest"));
19069
- const hasBats = existsSync34(join38(projectRoot, "tests"));
18961
+ const hasVitest = existsSync34(join37(projectRoot, "node_modules", ".bin", "vitest"));
18962
+ const hasBats = existsSync34(join37(projectRoot, "tests"));
19070
18963
  if (!hasVitest && !hasBats) {
19071
18964
  return {
19072
18965
  ran: false,
@@ -19112,7 +19005,7 @@ function coreTestRun(params, projectRoot) {
19112
19005
  }
19113
19006
  }
19114
19007
  function coreTestCoverage(projectRoot) {
19115
- const coveragePath = join38(projectRoot, "coverage", "coverage-summary.json");
19008
+ const coveragePath = join37(projectRoot, "coverage", "coverage-summary.json");
19116
19009
  if (!existsSync34(coveragePath)) {
19117
19010
  return {
19118
19011
  available: false,
@@ -19800,16 +19693,16 @@ var init_unblock = __esm({
19800
19693
  });
19801
19694
 
19802
19695
  // src/core/orchestration/parallel.ts
19803
- import { readFileSync as readFileSync27, writeFileSync as writeFileSync7, existsSync as existsSync35, mkdirSync as mkdirSync12 } from "node:fs";
19804
- import { join as join39, dirname as dirname11 } from "node:path";
19696
+ import { readFileSync as readFileSync26, writeFileSync as writeFileSync7, existsSync as existsSync35, mkdirSync as mkdirSync12 } from "node:fs";
19697
+ import { join as join38, dirname as dirname11 } from "node:path";
19805
19698
  function getParallelStatePath(projectRoot) {
19806
- return join39(projectRoot, ".cleo", "parallel-state.json");
19699
+ return join38(projectRoot, ".cleo", "parallel-state.json");
19807
19700
  }
19808
19701
  function readParallelState(projectRoot) {
19809
19702
  const statePath = getParallelStatePath(projectRoot);
19810
19703
  if (!existsSync35(statePath)) return { active: false };
19811
19704
  try {
19812
- return JSON.parse(readFileSync27(statePath, "utf-8"));
19705
+ return JSON.parse(readFileSync26(statePath, "utf-8"));
19813
19706
  } catch {
19814
19707
  return { active: false };
19815
19708
  }
@@ -19971,8 +19864,8 @@ var init_validate_spawn = __esm({
19971
19864
  });
19972
19865
 
19973
19866
  // src/core/orchestration/bootstrap.ts
19974
- import { readFileSync as readFileSync28, existsSync as existsSync36 } from "node:fs";
19975
- import { join as join40 } from "node:path";
19867
+ import { readFileSync as readFileSync27, existsSync as existsSync36 } from "node:fs";
19868
+ import { join as join39 } from "node:path";
19976
19869
  async function buildBrainState(projectRoot, opts, accessor) {
19977
19870
  const speed = opts?.speed || "fast";
19978
19871
  const brain = {
@@ -19985,7 +19878,7 @@ async function buildBrainState(projectRoot, opts, accessor) {
19985
19878
  try {
19986
19879
  const sessionsPath = getSessionsPath(projectRoot);
19987
19880
  if (existsSync36(sessionsPath)) {
19988
- const sessionsData = JSON.parse(readFileSync28(sessionsPath, "utf-8"));
19881
+ const sessionsData = JSON.parse(readFileSync27(sessionsPath, "utf-8"));
19989
19882
  const activeSession = (sessionsData.sessions ?? []).find(
19990
19883
  (s) => s.status === "active"
19991
19884
  );
@@ -20040,9 +19933,9 @@ async function buildBrainState(projectRoot, opts, accessor) {
20040
19933
  blockedBy: b.depends || []
20041
19934
  }));
20042
19935
  try {
20043
- const decisionLogPath = join40(projectRoot, ".cleo", "decision-log.jsonl");
19936
+ const decisionLogPath = join39(projectRoot, ".cleo", "decision-log.jsonl");
20044
19937
  if (existsSync36(decisionLogPath)) {
20045
- const content = readFileSync28(decisionLogPath, "utf-8").trim();
19938
+ const content = readFileSync27(decisionLogPath, "utf-8").trim();
20046
19939
  if (content) {
20047
19940
  const entries = content.split("\n").filter((l) => l.trim()).map((l) => {
20048
19941
  try {
@@ -20062,9 +19955,9 @@ async function buildBrainState(projectRoot, opts, accessor) {
20062
19955
  } catch {
20063
19956
  }
20064
19957
  try {
20065
- const contextStatePath = join40(projectRoot, ".cleo", ".context-state.json");
19958
+ const contextStatePath = join39(projectRoot, ".cleo", ".context-state.json");
20066
19959
  if (existsSync36(contextStatePath)) {
20067
- const state = JSON.parse(readFileSync28(contextStatePath, "utf-8"));
19960
+ const state = JSON.parse(readFileSync27(contextStatePath, "utf-8"));
20068
19961
  const percentage = state.contextWindow?.percentage ?? 0;
20069
19962
  const factors = [];
20070
19963
  if (percentage > 80) factors.push("high_context_usage");
@@ -20085,7 +19978,7 @@ var init_bootstrap = __esm({
20085
19978
  });
20086
19979
 
20087
19980
  // src/dispatch/engines/orchestrate-engine.ts
20088
- import { readFileSync as readFileSync29, existsSync as existsSync37 } from "node:fs";
19981
+ import { readFileSync as readFileSync28, existsSync as existsSync37 } from "node:fs";
20089
19982
  async function loadTasks(projectRoot) {
20090
19983
  const root = projectRoot || resolveProjectRoot();
20091
19984
  try {
@@ -20303,7 +20196,7 @@ async function orchestrateContext(epicId, projectRoot) {
20303
20196
  let manifestEntries2 = 0;
20304
20197
  if (existsSync37(manifestPath)) {
20305
20198
  try {
20306
- const content = readFileSync29(manifestPath, "utf-8");
20199
+ const content = readFileSync28(manifestPath, "utf-8");
20307
20200
  manifestEntries2 = content.split("\n").filter((l) => l.trim()).length;
20308
20201
  } catch {
20309
20202
  }
@@ -20560,17 +20453,17 @@ var init_brain_migration = __esm({
20560
20453
 
20561
20454
  // src/core/memory/patterns.ts
20562
20455
  import { randomBytes as randomBytes7 } from "node:crypto";
20563
- import { readFileSync as readFileSync30, writeFileSync as writeFileSync8, appendFileSync as appendFileSync4, mkdirSync as mkdirSync13, existsSync as existsSync38 } from "node:fs";
20564
- import { join as join41 } from "node:path";
20456
+ import { readFileSync as readFileSync29, writeFileSync as writeFileSync8, appendFileSync as appendFileSync4, mkdirSync as mkdirSync13, existsSync as existsSync38 } from "node:fs";
20457
+ import { join as join40 } from "node:path";
20565
20458
  function getMemoryDir(projectRoot) {
20566
- const memDir = join41(projectRoot, ".cleo", "memory");
20459
+ const memDir = join40(projectRoot, ".cleo", "memory");
20567
20460
  if (!existsSync38(memDir)) {
20568
20461
  mkdirSync13(memDir, { recursive: true });
20569
20462
  }
20570
20463
  return memDir;
20571
20464
  }
20572
20465
  function getPatternsPath(projectRoot) {
20573
- return join41(getMemoryDir(projectRoot), "patterns.jsonl");
20466
+ return join40(getMemoryDir(projectRoot), "patterns.jsonl");
20574
20467
  }
20575
20468
  function generatePatternId() {
20576
20469
  return `P${randomBytes7(4).toString("hex")}`;
@@ -20578,7 +20471,7 @@ function generatePatternId() {
20578
20471
  function readPatterns(projectRoot) {
20579
20472
  const path = getPatternsPath(projectRoot);
20580
20473
  if (!existsSync38(path)) return [];
20581
- const content = readFileSync30(path, "utf-8").trim();
20474
+ const content = readFileSync29(path, "utf-8").trim();
20582
20475
  if (!content) return [];
20583
20476
  const entries = [];
20584
20477
  for (const line of content.split("\n")) {
@@ -20692,17 +20585,17 @@ var init_patterns = __esm({
20692
20585
 
20693
20586
  // src/core/memory/learnings.ts
20694
20587
  import { randomBytes as randomBytes8 } from "node:crypto";
20695
- import { readFileSync as readFileSync31, writeFileSync as writeFileSync9, appendFileSync as appendFileSync5, mkdirSync as mkdirSync14, existsSync as existsSync39 } from "node:fs";
20696
- import { join as join42 } from "node:path";
20588
+ import { readFileSync as readFileSync30, writeFileSync as writeFileSync9, appendFileSync as appendFileSync5, mkdirSync as mkdirSync14, existsSync as existsSync39 } from "node:fs";
20589
+ import { join as join41 } from "node:path";
20697
20590
  function getMemoryDir2(projectRoot) {
20698
- const memDir = join42(projectRoot, ".cleo", "memory");
20591
+ const memDir = join41(projectRoot, ".cleo", "memory");
20699
20592
  if (!existsSync39(memDir)) {
20700
20593
  mkdirSync14(memDir, { recursive: true });
20701
20594
  }
20702
20595
  return memDir;
20703
20596
  }
20704
20597
  function getLearningsPath(projectRoot) {
20705
- return join42(getMemoryDir2(projectRoot), "learnings.jsonl");
20598
+ return join41(getMemoryDir2(projectRoot), "learnings.jsonl");
20706
20599
  }
20707
20600
  function generateLearningId() {
20708
20601
  return `L${randomBytes8(4).toString("hex")}`;
@@ -20710,7 +20603,7 @@ function generateLearningId() {
20710
20603
  function readLearnings(projectRoot) {
20711
20604
  const path = getLearningsPath(projectRoot);
20712
20605
  if (!existsSync39(path)) return [];
20713
- const content = readFileSync31(path, "utf-8").trim();
20606
+ const content = readFileSync30(path, "utf-8").trim();
20714
20607
  if (!content) return [];
20715
20608
  const entries = [];
20716
20609
  for (const line of content.split("\n")) {
@@ -20871,7 +20764,7 @@ var init_memory = __esm({
20871
20764
  });
20872
20765
 
20873
20766
  // src/core/memory/engine-compat.ts
20874
- import { readFileSync as readFileSync32, writeFileSync as writeFileSync10, appendFileSync as appendFileSync6, existsSync as existsSync40, mkdirSync as mkdirSync15 } from "node:fs";
20767
+ import { readFileSync as readFileSync31, writeFileSync as writeFileSync10, appendFileSync as appendFileSync6, existsSync as existsSync40, mkdirSync as mkdirSync15 } from "node:fs";
20875
20768
  import { resolve as resolve7, dirname as dirname12 } from "node:path";
20876
20769
  function getManifestPath2(projectRoot) {
20877
20770
  return getManifestPath(projectRoot);
@@ -20882,7 +20775,7 @@ function resolveRoot(projectRoot) {
20882
20775
  function readManifestEntries(projectRoot) {
20883
20776
  const manifestPath = getManifestPath2(projectRoot);
20884
20777
  try {
20885
- const content = readFileSync32(manifestPath, "utf-8");
20778
+ const content = readFileSync31(manifestPath, "utf-8");
20886
20779
  const entries = [];
20887
20780
  const lines = content.split("\n");
20888
20781
  for (const line of lines) {
@@ -20919,7 +20812,7 @@ function memoryShow(researchId, projectRoot) {
20919
20812
  try {
20920
20813
  const filePath = resolve7(root, entry.file);
20921
20814
  if (existsSync40(filePath)) {
20922
- fileContent = readFileSync32(filePath, "utf-8");
20815
+ fileContent = readFileSync31(filePath, "utf-8");
20923
20816
  }
20924
20817
  } catch {
20925
20818
  }
@@ -21186,7 +21079,7 @@ function memoryInject(protocolType, params, projectRoot) {
21186
21079
  for (const loc of protocolLocations) {
21187
21080
  if (existsSync40(loc)) {
21188
21081
  try {
21189
- protocolContent = readFileSync32(loc, "utf-8");
21082
+ protocolContent = readFileSync31(loc, "utf-8");
21190
21083
  protocolPath = loc.replace(root + "/", "");
21191
21084
  break;
21192
21085
  } catch {
@@ -21334,9 +21227,9 @@ var init_engine_compat = __esm({
21334
21227
  // src/core/release/release-manifest.ts
21335
21228
  import { existsSync as existsSync41, mkdirSync as mkdirSync16 } from "node:fs";
21336
21229
  import { execFileSync as execFileSync4 } from "node:child_process";
21337
- import { dirname as dirname13, join as join43 } from "node:path";
21230
+ import { dirname as dirname13, join as join42 } from "node:path";
21338
21231
  function getReleasesPath(cwd) {
21339
- return join43(getCleoDirAbsolute(cwd), "releases.json");
21232
+ return join42(getCleoDirAbsolute(cwd), "releases.json");
21340
21233
  }
21341
21234
  async function readReleases(cwd) {
21342
21235
  const data = await readJson(getReleasesPath(cwd));
@@ -21613,7 +21506,7 @@ async function rollbackRelease(version, reason, cwd) {
21613
21506
  };
21614
21507
  }
21615
21508
  async function readPushPolicy(cwd) {
21616
- const configPath = join43(getCleoDirAbsolute(cwd), "config.json");
21509
+ const configPath = join42(getCleoDirAbsolute(cwd), "config.json");
21617
21510
  const config = await readJson(configPath);
21618
21511
  if (!config) return void 0;
21619
21512
  const release2 = config.release;
@@ -21843,8 +21736,8 @@ var init_release_engine = __esm({
21843
21736
  });
21844
21737
 
21845
21738
  // src/dispatch/engines/template-parser.ts
21846
- import { readFileSync as readFileSync33, readdirSync as readdirSync12, existsSync as existsSync42 } from "fs";
21847
- import { join as join44 } from "path";
21739
+ import { readFileSync as readFileSync32, readdirSync as readdirSync12, existsSync as existsSync42 } from "fs";
21740
+ import { join as join43 } from "path";
21848
21741
  import { parse as parseYaml } from "yaml";
21849
21742
  function deriveSubcommand(filename) {
21850
21743
  let stem = filename.replace(/\.ya?ml$/i, "");
@@ -21858,8 +21751,8 @@ function deriveSubcommand(filename) {
21858
21751
  return firstWord.toLowerCase();
21859
21752
  }
21860
21753
  function parseTemplateFile(templateDir, filename) {
21861
- const filePath = join44(templateDir, filename);
21862
- const raw = readFileSync33(filePath, "utf-8");
21754
+ const filePath = join43(templateDir, filename);
21755
+ const raw = readFileSync32(filePath, "utf-8");
21863
21756
  const parsed = parseYaml(raw);
21864
21757
  const name = typeof parsed.name === "string" ? parsed.name : filename;
21865
21758
  const titlePrefix = typeof parsed.title === "string" ? parsed.title : "";
@@ -21908,7 +21801,7 @@ function parseTemplateFile(templateDir, filename) {
21908
21801
  };
21909
21802
  }
21910
21803
  function parseIssueTemplates(projectRoot) {
21911
- const templateDir = join44(projectRoot, ".github", "ISSUE_TEMPLATE");
21804
+ const templateDir = join43(projectRoot, ".github", "ISSUE_TEMPLATE");
21912
21805
  if (!existsSync42(templateDir)) {
21913
21806
  return engineError("E_NOT_FOUND", `Issue template directory not found: ${templateDir}`);
21914
21807
  }
@@ -22961,12 +22854,12 @@ var init_check = __esm({
22961
22854
  });
22962
22855
 
22963
22856
  // src/core/adrs/validate.ts
22964
- import { readFileSync as readFileSync34, readdirSync as readdirSync13, existsSync as existsSync43 } from "node:fs";
22965
- import { join as join45 } from "node:path";
22857
+ import { readFileSync as readFileSync33, readdirSync as readdirSync13, existsSync as existsSync43 } from "node:fs";
22858
+ import { join as join44 } from "node:path";
22966
22859
  import AjvModule3 from "ajv";
22967
22860
  async function validateAllAdrs(projectRoot) {
22968
- const adrsDir = join45(projectRoot, ".cleo", "adrs");
22969
- const schemaPath = join45(projectRoot, "schemas", "adr-frontmatter.schema.json");
22861
+ const adrsDir = join44(projectRoot, ".cleo", "adrs");
22862
+ const schemaPath = join44(projectRoot, "schemas", "adr-frontmatter.schema.json");
22970
22863
  if (!existsSync43(schemaPath)) {
22971
22864
  return {
22972
22865
  valid: false,
@@ -22977,10 +22870,10 @@ async function validateAllAdrs(projectRoot) {
22977
22870
  if (!existsSync43(adrsDir)) {
22978
22871
  return { valid: true, errors: [], checked: 0 };
22979
22872
  }
22980
- const schema = JSON.parse(readFileSync34(schemaPath, "utf-8"));
22873
+ const schema = JSON.parse(readFileSync33(schemaPath, "utf-8"));
22981
22874
  const ajv = new Ajv3({ allErrors: true });
22982
22875
  const validate = ajv.compile(schema);
22983
- const files = readdirSync13(adrsDir).filter((f) => f.endsWith(".md") && f.startsWith("ADR-")).map((f) => join45(adrsDir, f));
22876
+ const files = readdirSync13(adrsDir).filter((f) => f.endsWith(".md") && f.startsWith("ADR-")).map((f) => join44(adrsDir, f));
22984
22877
  const errors = [];
22985
22878
  for (const filePath of files) {
22986
22879
  const record = parseAdrFile(filePath, projectRoot);
@@ -23008,14 +22901,14 @@ var init_validate = __esm({
23008
22901
 
23009
22902
  // src/core/adrs/list.ts
23010
22903
  import { readdirSync as readdirSync14, existsSync as existsSync44 } from "node:fs";
23011
- import { join as join46 } from "node:path";
22904
+ import { join as join45 } from "node:path";
23012
22905
  async function listAdrs(projectRoot, opts) {
23013
- const adrsDir = join46(projectRoot, ".cleo", "adrs");
22906
+ const adrsDir = join45(projectRoot, ".cleo", "adrs");
23014
22907
  if (!existsSync44(adrsDir)) {
23015
22908
  return { adrs: [], total: 0 };
23016
22909
  }
23017
22910
  const files = readdirSync14(adrsDir).filter((f) => f.endsWith(".md") && f.startsWith("ADR-")).sort();
23018
- const records = files.map((f) => parseAdrFile(join46(adrsDir, f), projectRoot));
22911
+ const records = files.map((f) => parseAdrFile(join45(adrsDir, f), projectRoot));
23019
22912
  const filtered = records.filter((r) => {
23020
22913
  if (opts?.status && r.frontmatter.Status !== opts.status) return false;
23021
22914
  if (opts?.since && r.frontmatter.Date < opts.since) return false;
@@ -23041,13 +22934,13 @@ var init_list2 = __esm({
23041
22934
 
23042
22935
  // src/core/adrs/show.ts
23043
22936
  import { existsSync as existsSync45, readdirSync as readdirSync15 } from "node:fs";
23044
- import { join as join47 } from "node:path";
22937
+ import { join as join46 } from "node:path";
23045
22938
  async function showAdr(projectRoot, adrId) {
23046
- const adrsDir = join47(projectRoot, ".cleo", "adrs");
22939
+ const adrsDir = join46(projectRoot, ".cleo", "adrs");
23047
22940
  if (!existsSync45(adrsDir)) return null;
23048
22941
  const files = readdirSync15(adrsDir).filter((f) => f.startsWith(adrId) && f.endsWith(".md"));
23049
22942
  if (files.length === 0) return null;
23050
- const filePath = join47(adrsDir, files[0]);
22943
+ const filePath = join46(adrsDir, files[0]);
23051
22944
  return parseAdrFile(filePath, projectRoot);
23052
22945
  }
23053
22946
  var init_show2 = __esm({
@@ -23059,7 +22952,7 @@ var init_show2 = __esm({
23059
22952
 
23060
22953
  // src/core/adrs/find.ts
23061
22954
  import { readdirSync as readdirSync16, existsSync as existsSync46 } from "node:fs";
23062
- import { join as join48 } from "node:path";
22955
+ import { join as join47 } from "node:path";
23063
22956
  function normalise(s) {
23064
22957
  return s.toLowerCase().replace(/[^a-z0-9\s]/g, " ").replace(/\s+/g, " ").trim();
23065
22958
  }
@@ -23076,7 +22969,7 @@ function matchedTerms(target, terms) {
23076
22969
  return terms.filter((term) => t.includes(term));
23077
22970
  }
23078
22971
  async function findAdrs(projectRoot, query, opts) {
23079
- const adrsDir = join48(projectRoot, ".cleo", "adrs");
22972
+ const adrsDir = join47(projectRoot, ".cleo", "adrs");
23080
22973
  if (!existsSync46(adrsDir)) {
23081
22974
  return { adrs: [], query, total: 0 };
23082
22975
  }
@@ -23086,7 +22979,7 @@ async function findAdrs(projectRoot, query, opts) {
23086
22979
  const filterKeywords = opts?.keywords ? parseTags(opts.keywords) : null;
23087
22980
  const results = [];
23088
22981
  for (const file of files) {
23089
- const record = parseAdrFile(join48(adrsDir, file), projectRoot);
22982
+ const record = parseAdrFile(join47(adrsDir, file), projectRoot);
23090
22983
  const fm = record.frontmatter;
23091
22984
  if (opts?.status && fm.Status !== opts.status) continue;
23092
22985
  if (filterTopics && filterTopics.length > 0) {
@@ -23709,13 +23602,13 @@ var init_field_context = __esm({
23709
23602
  });
23710
23603
 
23711
23604
  // src/core/sessions/context-alert.ts
23712
- import { existsSync as existsSync47, readFileSync as readFileSync35, writeFileSync as writeFileSync11 } from "node:fs";
23713
- import { join as join49 } from "node:path";
23605
+ import { existsSync as existsSync47, readFileSync as readFileSync34, writeFileSync as writeFileSync11 } from "node:fs";
23606
+ import { join as join48 } from "node:path";
23714
23607
  function getCurrentSessionId(cwd) {
23715
23608
  if (process.env.CLEO_SESSION) return process.env.CLEO_SESSION;
23716
- const sessionFile = join49(getCleoDir(cwd), ".current-session");
23609
+ const sessionFile = join48(getCleoDir(cwd), ".current-session");
23717
23610
  if (existsSync47(sessionFile)) {
23718
- return readFileSync35(sessionFile, "utf-8").trim() || null;
23611
+ return readFileSync34(sessionFile, "utf-8").trim() || null;
23719
23612
  }
23720
23613
  return null;
23721
23614
  }
@@ -25116,7 +25009,7 @@ __export(session_grade_exports, {
25116
25009
  gradeSession: () => gradeSession,
25117
25010
  readGrades: () => readGrades
25118
25011
  });
25119
- import { join as join50 } from "node:path";
25012
+ import { join as join49 } from "node:path";
25120
25013
  import { existsSync as existsSync48 } from "node:fs";
25121
25014
  import { readFile as readFile9, appendFile, mkdir as mkdir9 } from "node:fs/promises";
25122
25015
  async function gradeSession(sessionId, cwd) {
@@ -25297,9 +25190,9 @@ function detectDuplicateCreates(entries) {
25297
25190
  async function appendGradeResult(result, cwd) {
25298
25191
  try {
25299
25192
  const cleoDir = getCleoDirAbsolute(cwd);
25300
- const metricsDir = join50(cleoDir, "metrics");
25193
+ const metricsDir = join49(cleoDir, "metrics");
25301
25194
  await mkdir9(metricsDir, { recursive: true });
25302
- const gradesPath = join50(metricsDir, "GRADES.jsonl");
25195
+ const gradesPath = join49(metricsDir, "GRADES.jsonl");
25303
25196
  const line = JSON.stringify({ ...result, evaluator: "auto" }) + "\n";
25304
25197
  await appendFile(gradesPath, line, "utf8");
25305
25198
  } catch {
@@ -25308,7 +25201,7 @@ async function appendGradeResult(result, cwd) {
25308
25201
  async function readGrades(sessionId, cwd) {
25309
25202
  try {
25310
25203
  const cleoDir = getCleoDirAbsolute(cwd);
25311
- const gradesPath = join50(cleoDir, "metrics", "GRADES.jsonl");
25204
+ const gradesPath = join49(cleoDir, "metrics", "GRADES.jsonl");
25312
25205
  if (!existsSync48(gradesPath)) return [];
25313
25206
  const content = await readFile9(gradesPath, "utf8");
25314
25207
  const results = content.split("\n").filter((l) => l.trim()).map((l) => JSON.parse(l));
@@ -26831,8 +26724,8 @@ var init_diagnostics = __esm({
26831
26724
  });
26832
26725
 
26833
26726
  // src/core/issue/template-parser.ts
26834
- import { existsSync as existsSync49, readFileSync as readFileSync36, readdirSync as readdirSync17, writeFileSync as writeFileSync12 } from "node:fs";
26835
- import { join as join51, basename as basename8 } from "node:path";
26727
+ import { existsSync as existsSync49, readFileSync as readFileSync35, readdirSync as readdirSync17, writeFileSync as writeFileSync12 } from "node:fs";
26728
+ import { join as join50, basename as basename8 } from "node:path";
26836
26729
  function extractYamlField(content, field) {
26837
26730
  const regex = new RegExp(`^${field}:\\s*["']?(.+?)["']?\\s*$`, "m");
26838
26731
  const match = content.match(regex);
@@ -26866,7 +26759,7 @@ function extractYamlArray(content, field) {
26866
26759
  function parseTemplateFile2(filePath) {
26867
26760
  if (!existsSync49(filePath)) return null;
26868
26761
  try {
26869
- const content = readFileSync36(filePath, "utf-8");
26762
+ const content = readFileSync35(filePath, "utf-8");
26870
26763
  const fileName = basename8(filePath);
26871
26764
  const stem = fileName.replace(/\.ya?ml$/, "");
26872
26765
  const name = extractYamlField(content, "name");
@@ -26882,12 +26775,12 @@ function parseTemplateFile2(filePath) {
26882
26775
  }
26883
26776
  function parseIssueTemplates2(projectDir) {
26884
26777
  const dir = projectDir ?? getProjectRoot();
26885
- const templateDir = join51(dir, TEMPLATE_DIR);
26778
+ const templateDir = join50(dir, TEMPLATE_DIR);
26886
26779
  if (!existsSync49(templateDir)) return [];
26887
26780
  const templates = [];
26888
26781
  for (const file of readdirSync17(templateDir)) {
26889
26782
  if (!file.endsWith(".yml") && !file.endsWith(".yaml")) continue;
26890
- const template = parseTemplateFile2(join51(templateDir, file));
26783
+ const template = parseTemplateFile2(join50(templateDir, file));
26891
26784
  if (template) templates.push(template);
26892
26785
  }
26893
26786
  return templates;
@@ -26896,10 +26789,10 @@ function getTemplateConfig(cwd) {
26896
26789
  const projectDir = cwd ?? getProjectRoot();
26897
26790
  const liveTemplates = parseIssueTemplates2(projectDir);
26898
26791
  if (liveTemplates.length > 0) return liveTemplates;
26899
- const cachePath = join51(getCleoDir(cwd), CACHE_FILE);
26792
+ const cachePath = join50(getCleoDir(cwd), CACHE_FILE);
26900
26793
  if (existsSync49(cachePath)) {
26901
26794
  try {
26902
- const cached = JSON.parse(readFileSync36(cachePath, "utf-8"));
26795
+ const cached = JSON.parse(readFileSync35(cachePath, "utf-8"));
26903
26796
  if (cached.templates?.length > 0) return cached.templates;
26904
26797
  } catch {
26905
26798
  }
@@ -27729,8 +27622,8 @@ var init_tools = __esm({
27729
27622
  });
27730
27623
 
27731
27624
  // src/core/nexus/query.ts
27732
- import { join as join52, basename as basename9 } from "node:path";
27733
- import { existsSync as existsSync50, readFileSync as readFileSync37 } from "node:fs";
27625
+ import { join as join51, basename as basename9 } from "node:path";
27626
+ import { existsSync as existsSync50, readFileSync as readFileSync36 } from "node:fs";
27734
27627
  import { readFile as readFile10, access as access3 } from "node:fs/promises";
27735
27628
  import { z as z3 } from "zod";
27736
27629
  function validateSyntax(query) {
@@ -27767,9 +27660,9 @@ function getCurrentProject() {
27767
27660
  return process.env["NEXUS_CURRENT_PROJECT"];
27768
27661
  }
27769
27662
  try {
27770
- const infoPath = join52(process.cwd(), ".cleo", "project-info.json");
27663
+ const infoPath = join51(process.cwd(), ".cleo", "project-info.json");
27771
27664
  if (existsSync50(infoPath)) {
27772
- const data = JSON.parse(readFileSync37(infoPath, "utf-8"));
27665
+ const data = JSON.parse(readFileSync36(infoPath, "utf-8"));
27773
27666
  if (typeof data.name === "string" && data.name.length > 0) {
27774
27667
  return data.name;
27775
27668
  }
@@ -27784,12 +27677,12 @@ async function resolveProjectPath(projectName) {
27784
27677
  }
27785
27678
  if (projectName === ".") {
27786
27679
  try {
27787
- await access3(join52(process.cwd(), ".cleo", "tasks.json"));
27680
+ await access3(join51(process.cwd(), ".cleo", "tasks.json"));
27788
27681
  return process.cwd();
27789
27682
  } catch {
27790
27683
  }
27791
27684
  try {
27792
- await access3(join52(process.cwd(), ".cleo", "todo.json"));
27685
+ await access3(join51(process.cwd(), ".cleo", "todo.json"));
27793
27686
  return process.cwd();
27794
27687
  } catch {
27795
27688
  throw new CleoError(
@@ -27809,8 +27702,8 @@ async function resolveProjectPath(projectName) {
27809
27702
  return project.path;
27810
27703
  }
27811
27704
  async function readProjectTasks(projectPath) {
27812
- const tasksPath = join52(projectPath, ".cleo", "tasks.json");
27813
- const legacyPath = join52(projectPath, ".cleo", "todo.json");
27705
+ const tasksPath = join51(projectPath, ".cleo", "tasks.json");
27706
+ const legacyPath = join51(projectPath, ".cleo", "todo.json");
27814
27707
  try {
27815
27708
  let raw;
27816
27709
  try {
@@ -27940,7 +27833,7 @@ var init_permissions = __esm({
27940
27833
  });
27941
27834
 
27942
27835
  // src/core/nexus/deps.ts
27943
- import { join as join53 } from "node:path";
27836
+ import { join as join52 } from "node:path";
27944
27837
  import { readFile as readFile11 } from "node:fs/promises";
27945
27838
  import { createHash as createHash7 } from "node:crypto";
27946
27839
  import { z as z5 } from "zod";
@@ -27948,9 +27841,9 @@ async function readProjectTasks2(projectPath) {
27948
27841
  try {
27949
27842
  let raw;
27950
27843
  try {
27951
- raw = await readFile11(join53(projectPath, ".cleo", "tasks.json"), "utf-8");
27844
+ raw = await readFile11(join52(projectPath, ".cleo", "tasks.json"), "utf-8");
27952
27845
  } catch {
27953
- raw = await readFile11(join53(projectPath, ".cleo", "todo.json"), "utf-8");
27846
+ raw = await readFile11(join52(projectPath, ".cleo", "todo.json"), "utf-8");
27954
27847
  }
27955
27848
  const data = JSON.parse(raw);
27956
27849
  return data.tasks ?? [];
@@ -27964,9 +27857,9 @@ async function computeGlobalChecksum(registry) {
27964
27857
  try {
27965
27858
  let content;
27966
27859
  try {
27967
- content = await readFile11(join53(project.path, ".cleo", "tasks.json"), "utf-8");
27860
+ content = await readFile11(join52(project.path, ".cleo", "tasks.json"), "utf-8");
27968
27861
  } catch {
27969
- content = await readFile11(join53(project.path, ".cleo", "todo.json"), "utf-8");
27862
+ content = await readFile11(join52(project.path, ".cleo", "todo.json"), "utf-8");
27970
27863
  }
27971
27864
  hash.update(content);
27972
27865
  } catch {
@@ -28336,7 +28229,7 @@ var init_nexus = __esm({
28336
28229
  // src/core/sharing/index.ts
28337
28230
  import { readFile as readFile12, writeFile as writeFile6 } from "node:fs/promises";
28338
28231
  import { existsSync as existsSync51, readdirSync as readdirSync18, statSync as statSync9 } from "node:fs";
28339
- import { join as join54, relative as relative4 } from "node:path";
28232
+ import { join as join53, relative as relative4 } from "node:path";
28340
28233
  function matchesPattern(filePath, pattern) {
28341
28234
  const normalizedPath = filePath.replace(/^\/+|\/+$/g, "");
28342
28235
  const normalizedPattern = pattern.replace(/^\/+|\/+$/g, "");
@@ -28361,7 +28254,7 @@ function collectCleoFiles(cleoDir) {
28361
28254
  const entries = readdirSync18(dir);
28362
28255
  for (const entry of entries) {
28363
28256
  if (entry === ".git") continue;
28364
- const fullPath = join54(dir, entry);
28257
+ const fullPath = join53(dir, entry);
28365
28258
  const relPath = relative4(cleoDir, fullPath);
28366
28259
  try {
28367
28260
  const stat2 = statSync9(fullPath);
@@ -28421,7 +28314,7 @@ function generateGitignoreEntries(sharing) {
28421
28314
  async function syncGitignore(cwd) {
28422
28315
  const config = await loadConfig2(cwd);
28423
28316
  const projectRoot = getProjectRoot(cwd);
28424
- const gitignorePath = join54(projectRoot, ".gitignore");
28317
+ const gitignorePath = join53(projectRoot, ".gitignore");
28425
28318
  const entries = generateGitignoreEntries(config.sharing);
28426
28319
  const managedSection = [
28427
28320
  "",
@@ -28465,7 +28358,7 @@ var init_sharing = __esm({
28465
28358
  import { createHash as createHash8 } from "node:crypto";
28466
28359
  import { readFile as readFile13, writeFile as writeFile7, mkdir as mkdir10 } from "node:fs/promises";
28467
28360
  import { existsSync as existsSync52 } from "node:fs";
28468
- import { join as join55, dirname as dirname14 } from "node:path";
28361
+ import { join as join54, dirname as dirname14 } from "node:path";
28469
28362
  function toSnapshotTask(task) {
28470
28363
  return {
28471
28364
  id: task.id,
@@ -28534,7 +28427,7 @@ async function readSnapshot(inputPath) {
28534
28427
  function getDefaultSnapshotPath(cwd) {
28535
28428
  const cleoDir = getCleoDirAbsolute(cwd);
28536
28429
  const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-").slice(0, 19);
28537
- return join55(cleoDir, "snapshots", `snapshot-${timestamp}.json`);
28430
+ return join54(cleoDir, "snapshots", `snapshot-${timestamp}.json`);
28538
28431
  }
28539
28432
  async function importSnapshot(snapshot, cwd) {
28540
28433
  const accessor = await getAccessor(cwd);
@@ -29048,7 +28941,7 @@ __export(global_bootstrap_exports, {
29048
28941
  ensureGlobalBootstrap: () => ensureGlobalBootstrap
29049
28942
  });
29050
28943
  import { existsSync as existsSync53, mkdirSync as mkdirSync17, writeFileSync as writeFileSync13 } from "node:fs";
29051
- import { join as join56 } from "node:path";
28944
+ import { join as join55 } from "node:path";
29052
28945
  function ensureGlobalBootstrap() {
29053
28946
  const details = [];
29054
28947
  const cleoHome = getCleoHome();
@@ -29060,14 +28953,14 @@ function ensureGlobalBootstrap() {
29060
28953
  if (schemaResult.installed > 0 || schemaResult.updated > 0) {
29061
28954
  details.push(`schemas installed=${schemaResult.installed} updated=${schemaResult.updated}`);
29062
28955
  }
29063
- const templatesDir = join56(cleoHome, "templates");
28956
+ const templatesDir = join55(cleoHome, "templates");
29064
28957
  if (!existsSync53(templatesDir)) {
29065
28958
  mkdirSync17(templatesDir, { recursive: true });
29066
28959
  details.push("created templates dir");
29067
28960
  }
29068
28961
  const injectionTemplate = getInjectionTemplateContent();
29069
28962
  if (injectionTemplate) {
29070
- const injectionPath = join56(templatesDir, "CLEO-INJECTION.md");
28963
+ const injectionPath = join55(templatesDir, "CLEO-INJECTION.md");
29071
28964
  if (!existsSync53(injectionPath)) {
29072
28965
  writeFileSync13(injectionPath, injectionTemplate, "utf-8");
29073
28966
  details.push("installed CLEO-INJECTION.md");