@cleocode/cleo 2026.5.53 → 2026.5.56

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/cli/index.js CHANGED
@@ -6466,7 +6466,7 @@ var init_registry = __esm({
6466
6466
  type: "string",
6467
6467
  required: false,
6468
6468
  description: "Task type",
6469
- enum: ["epic", "task", "subtask", "bug"],
6469
+ enum: ["epic", "task", "subtask"],
6470
6470
  cli: { flag: "type", short: "-t" }
6471
6471
  },
6472
6472
  {
@@ -12685,7 +12685,6 @@ import {
12685
12685
  fileRestore,
12686
12686
  findAdrs,
12687
12687
  generateInjection,
12688
- getAccessor,
12689
12688
  getContextWindow,
12690
12689
  getDashboard,
12691
12690
  getDefaultSnapshotPath,
@@ -12697,6 +12696,7 @@ import {
12697
12696
  getRuntimeDiagnostics,
12698
12697
  getSystemHealth,
12699
12698
  getSystemPaths,
12699
+ getTaskAccessor,
12700
12700
  importSnapshot,
12701
12701
  importTasks,
12702
12702
  importTasksPackage,
@@ -12985,8 +12985,8 @@ var init_admin2 = __esm({
12985
12985
  const projectRoot = getProjectRoot2();
12986
12986
  const taskId = params.taskId;
12987
12987
  try {
12988
- const { getAccessor: getAccessor4, getLastHandoff, retrieveWithBudget } = await import("@cleocode/core/internal");
12989
- const accessor = await getAccessor4(projectRoot);
12988
+ const { getTaskAccessor: getTaskAccessor4, getLastHandoff, retrieveWithBudget } = await import("@cleocode/core/internal");
12989
+ const accessor = await getTaskAccessor4(projectRoot);
12990
12990
  const task = await accessor.loadSingleTask(taskId);
12991
12991
  if (!task) {
12992
12992
  return lafsError("E_NOT_FOUND", `Task ${taskId} not found`, "context.pull");
@@ -13103,7 +13103,7 @@ var init_admin2 = __esm({
13103
13103
  dash: async (params) => {
13104
13104
  const projectRoot = getProjectRoot2();
13105
13105
  try {
13106
- const accessor = await getAccessor(projectRoot);
13106
+ const accessor = await getTaskAccessor(projectRoot);
13107
13107
  const raw = await getDashboard(
13108
13108
  { cwd: projectRoot, blockedTasksLimit: params.blockedTasksLimit },
13109
13109
  accessor
@@ -13313,7 +13313,7 @@ var init_admin2 = __esm({
13313
13313
  roadmap: async (params) => {
13314
13314
  const projectRoot = getProjectRoot2();
13315
13315
  try {
13316
- const accessor = await getAccessor(projectRoot);
13316
+ const accessor = await getTaskAccessor(projectRoot);
13317
13317
  const data = await getRoadmap(
13318
13318
  {
13319
13319
  includeHistory: params.includeHistory,
@@ -13570,7 +13570,7 @@ var init_admin2 = __esm({
13570
13570
  "inject.generate": async (_params) => {
13571
13571
  const projectRoot = getProjectRoot2();
13572
13572
  try {
13573
- const accessor = await getAccessor(projectRoot);
13573
+ const accessor = await getTaskAccessor(projectRoot);
13574
13574
  const data = await generateInjection(projectRoot, accessor);
13575
13575
  return lafsSuccess(data, "inject.generate");
13576
13576
  } catch (err) {
@@ -15701,7 +15701,7 @@ var init_docs2 = __esm({
15701
15701
  });
15702
15702
 
15703
15703
  // packages/cleo/src/dispatch/domains/intelligence.ts
15704
- import { getAccessor as getAccessor2, getLogger as getLogger5, getProjectRoot as getProjectRoot5 } from "@cleocode/core";
15704
+ import { getLogger as getLogger5, getProjectRoot as getProjectRoot5, getTaskAccessor as getTaskAccessor2 } from "@cleocode/core";
15705
15705
  import {
15706
15706
  calculateTaskRisk,
15707
15707
  extractPatternsFromHistory,
@@ -15741,7 +15741,7 @@ var init_intelligence2 = __esm({
15741
15741
  );
15742
15742
  }
15743
15743
  const [accessor, brain] = await Promise.all([
15744
- getAccessor2(projectRoot),
15744
+ getTaskAccessor2(projectRoot),
15745
15745
  getBrainAccessor(projectRoot)
15746
15746
  ]);
15747
15747
  const stage = params?.stage;
@@ -15780,7 +15780,7 @@ var init_intelligence2 = __esm({
15780
15780
  );
15781
15781
  }
15782
15782
  const [accessor, brain] = await Promise.all([
15783
- getAccessor2(projectRoot),
15783
+ getTaskAccessor2(projectRoot),
15784
15784
  getBrainAccessor(projectRoot)
15785
15785
  ]);
15786
15786
  const result = await suggestGateFocus(taskId, accessor, brain);
@@ -15797,7 +15797,7 @@ var init_intelligence2 = __esm({
15797
15797
  // ------------------------------------------------------------------
15798
15798
  case "learn-errors": {
15799
15799
  const [accessor, brain] = await Promise.all([
15800
- getAccessor2(projectRoot),
15800
+ getTaskAccessor2(projectRoot),
15801
15801
  getBrainAccessor(projectRoot)
15802
15802
  ]);
15803
15803
  const limit = typeof params?.limit === "number" ? params.limit : void 0;
@@ -15826,7 +15826,7 @@ var init_intelligence2 = __esm({
15826
15826
  );
15827
15827
  }
15828
15828
  const [accessor, brain] = await Promise.all([
15829
- getAccessor2(projectRoot),
15829
+ getTaskAccessor2(projectRoot),
15830
15830
  getBrainAccessor(projectRoot)
15831
15831
  ]);
15832
15832
  const task = await accessor.loadSingleTask(taskId);
@@ -15876,7 +15876,7 @@ var init_intelligence2 = __esm({
15876
15876
  );
15877
15877
  }
15878
15878
  const [accessor, brain] = await Promise.all([
15879
- getAccessor2(projectRoot),
15879
+ getTaskAccessor2(projectRoot),
15880
15880
  getBrainAccessor(projectRoot)
15881
15881
  ]);
15882
15882
  const result = await matchPatterns(taskId, accessor, brain);
@@ -24010,16 +24010,16 @@ async function orchestrateRejectOp(params) {
24010
24010
  async function orchestrateClassify(request, context, projectRoot) {
24011
24011
  try {
24012
24012
  const { getCleoCantWorkflowsDir } = await import("@cleocode/core/internal");
24013
- const { readFileSync: readFileSync16, readdirSync: readdirSync4, existsSync: existsSync14 } = await import("node:fs");
24014
- const { join: join24 } = await import("node:path");
24013
+ const { readFileSync: readFileSync16, readdirSync: readdirSync4, existsSync: existsSync13 } = await import("node:fs");
24014
+ const { join: join23 } = await import("node:path");
24015
24015
  const workflowsDir = getCleoCantWorkflowsDir();
24016
24016
  const combined = `${request} ${context ?? ""}`.toLowerCase();
24017
24017
  const matches = [];
24018
- if (existsSync14(workflowsDir)) {
24018
+ if (existsSync13(workflowsDir)) {
24019
24019
  const files = readdirSync4(workflowsDir).filter((f) => f.endsWith(".cant"));
24020
24020
  for (const file of files) {
24021
24021
  try {
24022
- const src = readFileSync16(join24(workflowsDir, file), "utf-8");
24022
+ const src = readFileSync16(join23(workflowsDir, file), "utf-8");
24023
24023
  const teamMatch = /^team\s+(\S+):/m.exec(src);
24024
24024
  if (!teamMatch) continue;
24025
24025
  const teamName = teamMatch[1];
@@ -24034,12 +24034,12 @@ async function orchestrateClassify(request, context, projectRoot) {
24034
24034
  }
24035
24035
  }
24036
24036
  }
24037
- const localCantDir = join24(projectRoot, CLEO_DIR_NAME, WORKFLOWS_SUBDIR);
24038
- if (existsSync14(localCantDir)) {
24037
+ const localCantDir = join23(projectRoot, CLEO_DIR_NAME, WORKFLOWS_SUBDIR);
24038
+ if (existsSync13(localCantDir)) {
24039
24039
  const files = readdirSync4(localCantDir).filter((f) => f.endsWith(".cant"));
24040
24040
  for (const file of files) {
24041
24041
  try {
24042
- const src = readFileSync16(join24(localCantDir, file), "utf-8");
24042
+ const src = readFileSync16(join23(localCantDir, file), "utf-8");
24043
24043
  const teamMatch = /^team\s+(\S+):/m.exec(src);
24044
24044
  if (!teamMatch) continue;
24045
24045
  const teamName = teamMatch[1];
@@ -24181,8 +24181,8 @@ async function orchestrateAnalyzeParallelSafety(taskIds, projectRoot) {
24181
24181
  return !closureA.has(b) && !closureB.has(a);
24182
24182
  };
24183
24183
  var transitiveClose = transitiveClose2, parallelSafe = parallelSafe2;
24184
- const { getAccessor: getAccessor4 } = await import("@cleocode/core/internal");
24185
- const accessor = await getAccessor4(projectRoot);
24184
+ const { getTaskAccessor: getTaskAccessor4 } = await import("@cleocode/core/internal");
24185
+ const accessor = await getTaskAccessor4(projectRoot);
24186
24186
  const result = await accessor.queryTasks({});
24187
24187
  const allTasks = result?.tasks ?? [];
24188
24188
  const depMap = /* @__PURE__ */ new Map();
@@ -27025,8 +27025,8 @@ var init_tasks3 = __esm({
27025
27025
  offset: params.offset,
27026
27026
  fields: params.fields,
27027
27027
  verbose: params.verbose,
27028
- // T944: role filter
27029
- role: params.role
27028
+ // T944/T9072: kind filter
27029
+ kind: params.kind
27030
27030
  }),
27031
27031
  "find"
27032
27032
  );
@@ -27158,8 +27158,8 @@ var init_tasks3 = __esm({
27158
27158
  files: params.files,
27159
27159
  dryRun: params.dryRun,
27160
27160
  parentSearch: params.parentSearch,
27161
- // T944: orthogonal axes — role is the canonical wire field (ADR-057 D2)
27162
- role: params.role,
27161
+ // T944/T9072: orthogonal axes — kind is the canonical wire field
27162
+ kind: params.kind,
27163
27163
  scope: params.scope,
27164
27164
  severity: params.severity,
27165
27165
  // T1633: BRAIN duplicate-bypass flag
@@ -27191,7 +27191,14 @@ var init_tasks3 = __esm({
27191
27191
  // T1014: wire --files through dispatch to engine (parity with add).
27192
27192
  files: params.files,
27193
27193
  // T834 / ADR-051 Decision 4: wire --pipelineStage end-to-end.
27194
- pipelineStage: params.pipelineStage
27194
+ pipelineStage: params.pipelineStage,
27195
+ // T944/T9072: kind axis (renamed from role)
27196
+ kind: params.kind,
27197
+ scope: params.scope,
27198
+ // T9073: severity — orthogonal to priority, valid for any kind
27199
+ severity: params.severity,
27200
+ // T1590: AC-immutability override reason
27201
+ reason: params.reason
27195
27202
  }),
27196
27203
  "update"
27197
27204
  );
@@ -29221,7 +29228,11 @@ var add_exports = {};
29221
29228
  __export(add_exports, {
29222
29229
  addCommand: () => addCommand
29223
29230
  });
29224
- import { getProjectRoot as getProjectRoot18, inferTaskAddParams } from "@cleocode/core";
29231
+ import {
29232
+ appendSignedSeverityAttestation,
29233
+ getProjectRoot as getProjectRoot18,
29234
+ inferTaskAddParams
29235
+ } from "@cleocode/core";
29225
29236
  var addCommand;
29226
29237
  var init_add = __esm({
29227
29238
  "packages/cleo/src/cli/commands/add.ts"() {
@@ -29253,7 +29264,7 @@ var init_add = __esm({
29253
29264
  type: {
29254
29265
  type: "string",
29255
29266
  alias: "t",
29256
- description: "Task type (epic | task | subtask | bug)"
29267
+ description: "Task type (epic | task | subtask)"
29257
29268
  },
29258
29269
  parent: {
29259
29270
  type: "string",
@@ -29328,21 +29339,14 @@ var init_add = __esm({
29328
29339
  description: "Show what would be created without making changes"
29329
29340
  },
29330
29341
  /**
29331
- * Task role axis — intent of work.
29342
+ * Task kind axis — intent of work.
29332
29343
  * Values: work | research | experiment | bug | spike | release
29333
29344
  * @task T944
29334
- */
29335
- role: {
29336
- type: "string",
29337
- description: "Task role / intent axis (work|research|experiment|bug|spike|release) \u2014 orthogonal to --type (T944)"
29338
- },
29339
- /**
29340
- * Backward-compatible alias for --role (fractal-ontology spec used "kind").
29341
- * @task T944
29345
+ * @task T9072
29342
29346
  */
29343
29347
  kind: {
29344
29348
  type: "string",
29345
- description: "Alias for --role (T944 fractal-ontology compat)"
29349
+ description: "Task kind / intent axis (work|research|experiment|bug|spike|release) \u2014 orthogonal to --type (T944)"
29346
29350
  },
29347
29351
  /**
29348
29352
  * Task scope axis — granularity of work.
@@ -29354,13 +29358,16 @@ var init_add = __esm({
29354
29358
  description: "Task scope / granularity axis (project|feature|unit) \u2014 orthogonal to --type (T944)"
29355
29359
  },
29356
29360
  /**
29357
- * Bug severity. Only valid when --role bug.
29361
+ * Severity level for any task kind (not just bug).
29358
29362
  * Values: P0 | P1 | P2 | P3
29363
+ * Orthogonal to --priority — does NOT auto-map priority.
29364
+ * Appends a signed attestation to .cleo/audit/severity-attestation.jsonl (T9071/T9073).
29359
29365
  * @task T944
29366
+ * @task T9073
29360
29367
  */
29361
29368
  severity: {
29362
29369
  type: "string",
29363
- description: "Bug severity (P0|P1|P2|P3) \u2014 only valid with --role bug (T944)"
29370
+ description: "Severity level (P0|P1|P2|P3) \u2014 valid for any --kind (T9073). Orthogonal to priority. Appends signed attestation."
29364
29371
  },
29365
29372
  /**
29366
29373
  * Bypass the E_DUPLICATE_TASK_LIKELY rejection guard.
@@ -29418,9 +29425,7 @@ var init_add = __esm({
29418
29425
  params["position"] = Number.parseInt(args.position, 10);
29419
29426
  if (args["dry-run"] !== void 0) params["dryRun"] = args["dry-run"];
29420
29427
  if (args["parent-search"] !== void 0) params["parentSearch"] = args["parent-search"];
29421
- if (args.role !== void 0) params["role"] = args.role;
29422
- if (args.kind !== void 0)
29423
- params["role"] = params["role"] ?? args.kind;
29428
+ if (args.kind !== void 0) params["kind"] = args.kind;
29424
29429
  if (args.scope !== void 0) params["scope"] = args.scope;
29425
29430
  if (args.severity !== void 0) params["severity"] = args.severity;
29426
29431
  if (args["force-duplicate"] !== void 0) params["forceDuplicate"] = args["force-duplicate"];
@@ -29458,6 +29463,23 @@ var init_add = __esm({
29458
29463
  params["parent"] = inferred.inferredParent;
29459
29464
  humanInfo(`[cleo add] inferred --parent from current task: ${inferred.inferredParent}`);
29460
29465
  }
29466
+ if (args.severity !== void 0 && !args["dry-run"]) {
29467
+ try {
29468
+ await appendSignedSeverityAttestation({
29469
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
29470
+ title: args.title,
29471
+ severity: args.severity,
29472
+ ...params["parent"] !== void 0 ? { epic: params["parent"] } : {}
29473
+ });
29474
+ } catch (err) {
29475
+ const code = err.code;
29476
+ if (code === "E_OWNER_ONLY") {
29477
+ cliError(err.message, 72, { name: "E_OWNER_ONLY" });
29478
+ process.exit(72);
29479
+ return;
29480
+ }
29481
+ }
29482
+ }
29461
29483
  const response = await dispatchRaw("mutate", "tasks", "add", params);
29462
29484
  if (!response.success) {
29463
29485
  handleRawError(response, { command: "add", operation: "tasks.add" });
@@ -29978,6 +30000,7 @@ __export(agent_exports, {
29978
30000
  agentCommand: () => agentCommand
29979
30001
  });
29980
30002
  import {
30003
+ applyPerfPragmas,
29981
30004
  checkAgentHealth,
29982
30005
  detectCrashedAgents,
29983
30006
  detectStaleAgents,
@@ -30385,12 +30408,12 @@ var init_agent = __esm({
30385
30408
  transportConfig: {},
30386
30409
  isActive: true
30387
30410
  });
30388
- const { existsSync: existsSync14, mkdirSync: mkdirSync6, writeFileSync: writeFileSync5 } = await import("node:fs");
30389
- const { join: join24 } = await import("node:path");
30390
- const cantDir = join24(CLEO_DIR_NAME, AGENTS_SUBDIR);
30391
- const cantPath = join24(cantDir, `${agentId}.cant`);
30411
+ const { existsSync: existsSync13, mkdirSync: mkdirSync6, writeFileSync: writeFileSync5 } = await import("node:fs");
30412
+ const { join: join23 } = await import("node:path");
30413
+ const cantDir = join23(CLEO_DIR_NAME, AGENTS_SUBDIR);
30414
+ const cantPath = join23(cantDir, `${agentId}.cant`);
30392
30415
  let cantScaffolded = false;
30393
- if (!existsSync14(cantPath)) {
30416
+ if (!existsSync13(cantPath)) {
30394
30417
  mkdirSync6(cantDir, { recursive: true });
30395
30418
  const role = classification ?? "specialist";
30396
30419
  const cantContent = `---
@@ -30450,7 +30473,7 @@ agent ${agentId}:
30450
30473
  data: {
30451
30474
  agentId: credential.agentId,
30452
30475
  displayName: credential.displayName,
30453
- cantFile: cantScaffolded ? cantPath : existsSync14(cantPath) ? cantPath : null,
30476
+ cantFile: cantScaffolded ? cantPath : existsSync13(cantPath) ? cantPath : null,
30454
30477
  cantScaffolded
30455
30478
  }
30456
30479
  },
@@ -30569,8 +30592,8 @@ agent ${agentId}:
30569
30592
  try {
30570
30593
  const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
30571
30594
  const { createRuntime } = await import("@cleocode/runtime");
30572
- const { existsSync: existsSync14, readFileSync: readFileSync16 } = await import("node:fs");
30573
- const { join: join24 } = await import("node:path");
30595
+ const { existsSync: existsSync13, readFileSync: readFileSync16 } = await import("node:fs");
30596
+ const { join: join23 } = await import("node:path");
30574
30597
  await getDb3();
30575
30598
  const registry = new AgentRegistryAccessor(process.cwd());
30576
30599
  const credential = await registry.get(args.agentId);
@@ -30590,8 +30613,8 @@ agent ${agentId}:
30590
30613
  }
30591
30614
  let profile = null;
30592
30615
  let cantValidation = null;
30593
- const cantPath = args.cant ?? join24(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
30594
- if (existsSync14(cantPath)) {
30616
+ const cantPath = args.cant ?? join23(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
30617
+ if (existsSync13(cantPath)) {
30595
30618
  profile = readFileSync16(cantPath, "utf-8");
30596
30619
  try {
30597
30620
  const cantModule = await import("@cleocode/cant");
@@ -31115,8 +31138,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
31115
31138
  try {
31116
31139
  const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
31117
31140
  const { createRuntime } = await import("@cleocode/runtime");
31118
- const { existsSync: existsSync14 } = await import("node:fs");
31119
- const { join: join24 } = await import("node:path");
31141
+ const { existsSync: existsSync13 } = await import("node:fs");
31142
+ const { join: join23 } = await import("node:path");
31120
31143
  const { execFile: execFile2 } = await import("node:child_process");
31121
31144
  const { promisify: promisify2 } = await import("node:util");
31122
31145
  const execFileAsync = promisify2(execFile2);
@@ -31136,8 +31159,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
31136
31159
  }
31137
31160
  await registry.update(args.agentId, { isActive: true });
31138
31161
  await registry.markUsed(args.agentId);
31139
- const cantPath = join24(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
31140
- const hasProfile = existsSync14(cantPath);
31162
+ const cantPath = join23(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
31163
+ const hasProfile = existsSync13(cantPath);
31141
31164
  const runtime = await createRuntime(registry, {
31142
31165
  agentId: args.agentId,
31143
31166
  pollIntervalMs: 5e3,
@@ -31985,11 +32008,11 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
31985
32008
  async run({ args }) {
31986
32009
  let tempDir = null;
31987
32010
  try {
31988
- const { existsSync: existsSync14, mkdirSync: mkdirSync6, statSync, readdirSync: readdirSync4, copyFileSync } = await import("node:fs");
31989
- const { join: join24, basename, resolve: resolve5, extname } = await import("node:path");
31990
- const { tmpdir } = await import("node:os");
32011
+ const { existsSync: existsSync13, mkdirSync: mkdirSync6, statSync, readdirSync: readdirSync4, copyFileSync } = await import("node:fs");
32012
+ const { join: join23, basename, resolve: resolve5, extname } = await import("node:path");
32013
+ const { tmpdir: tmpdir2 } = await import("node:os");
31991
32014
  const resolvedPath = resolve5(args.path);
31992
- if (!existsSync14(resolvedPath)) {
32015
+ if (!existsSync13(resolvedPath)) {
31993
32016
  cliOutput(
31994
32017
  {
31995
32018
  success: false,
@@ -32010,7 +32033,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32010
32033
  cantPath = resolvedPath;
32011
32034
  } else if (stat2.isFile() && ext === ".cantz") {
32012
32035
  const { execFileSync: execFileSync5 } = await import("node:child_process");
32013
- tempDir = join24(tmpdir(), `cleo-agent-install-${Date.now()}`);
32036
+ tempDir = join23(tmpdir2(), `cleo-agent-install-${Date.now()}`);
32014
32037
  mkdirSync6(tempDir, { recursive: true });
32015
32038
  try {
32016
32039
  execFileSync5("unzip", ["-o", "-q", resolvedPath, "-d", tempDir], {
@@ -32032,7 +32055,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32032
32055
  return;
32033
32056
  }
32034
32057
  const topLevel = readdirSync4(tempDir).filter(
32035
- (entry) => statSync(join24(tempDir, entry)).isDirectory()
32058
+ (entry) => statSync(join23(tempDir, entry)).isDirectory()
32036
32059
  );
32037
32060
  if (topLevel.length !== 1) {
32038
32061
  cliOutput(
@@ -32049,8 +32072,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32049
32072
  return;
32050
32073
  }
32051
32074
  const agentName = topLevel[0];
32052
- const personaPath = join24(tempDir, agentName, "persona.cant");
32053
- if (!existsSync14(personaPath)) {
32075
+ const personaPath = join23(tempDir, agentName, "persona.cant");
32076
+ if (!existsSync13(personaPath)) {
32054
32077
  cliOutput(
32055
32078
  {
32056
32079
  success: false,
@@ -32064,12 +32087,12 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32064
32087
  process.exitCode = 6;
32065
32088
  return;
32066
32089
  }
32067
- cantPath = join24(tempDir, `${agentName}.cant`);
32090
+ cantPath = join23(tempDir, `${agentName}.cant`);
32068
32091
  copyFileSync(personaPath, cantPath);
32069
32092
  } else if (stat2.isDirectory()) {
32070
32093
  const agentName = basename(resolvedPath);
32071
- const personaPath = join24(resolvedPath, "persona.cant");
32072
- if (!existsSync14(personaPath)) {
32094
+ const personaPath = join23(resolvedPath, "persona.cant");
32095
+ if (!existsSync13(personaPath)) {
32073
32096
  cliOutput(
32074
32097
  {
32075
32098
  success: false,
@@ -32083,9 +32106,9 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32083
32106
  process.exitCode = 6;
32084
32107
  return;
32085
32108
  }
32086
- tempDir = join24(tmpdir(), `cleo-agent-install-${Date.now()}`);
32109
+ tempDir = join23(tmpdir2(), `cleo-agent-install-${Date.now()}`);
32087
32110
  mkdirSync6(tempDir, { recursive: true });
32088
- cantPath = join24(tempDir, `${agentName}.cant`);
32111
+ cantPath = join23(tempDir, `${agentName}.cant`);
32089
32112
  copyFileSync(personaPath, cantPath);
32090
32113
  } else {
32091
32114
  cliOutput(
@@ -32111,8 +32134,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32111
32134
  ensureGlobalSignaldockDb2();
32112
32135
  const dbPath = getGlobalSignaldockDbPath2();
32113
32136
  const db = new DatabaseSync2(dbPath);
32114
- db.exec("PRAGMA foreign_keys = ON");
32115
- db.exec("PRAGMA journal_mode = WAL");
32137
+ applyPerfPragmas(db);
32116
32138
  const isGlobal = args.global === true;
32117
32139
  const targetTier = isGlobal ? "global" : "project";
32118
32140
  const projectRoot = process.cwd();
@@ -32212,11 +32234,11 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32212
32234
  },
32213
32235
  async run({ args }) {
32214
32236
  try {
32215
- const { existsSync: existsSync14, statSync } = await import("node:fs");
32216
- const { resolve: resolve5, basename, dirname: dirname10 } = await import("node:path");
32237
+ const { existsSync: existsSync13, statSync } = await import("node:fs");
32238
+ const { resolve: resolve5, basename, dirname: dirname9 } = await import("node:path");
32217
32239
  const { execFileSync: execFileSync5 } = await import("node:child_process");
32218
32240
  const resolvedDir = resolve5(args.dir);
32219
- if (!existsSync14(resolvedDir) || !statSync(resolvedDir).isDirectory()) {
32241
+ if (!existsSync13(resolvedDir) || !statSync(resolvedDir).isDirectory()) {
32220
32242
  cliOutput(
32221
32243
  {
32222
32244
  success: false,
@@ -32230,9 +32252,9 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32230
32252
  process.exitCode = 4;
32231
32253
  return;
32232
32254
  }
32233
- const { join: join24 } = await import("node:path");
32234
- const personaPath = join24(resolvedDir, "persona.cant");
32235
- if (!existsSync14(personaPath)) {
32255
+ const { join: join23 } = await import("node:path");
32256
+ const personaPath = join23(resolvedDir, "persona.cant");
32257
+ if (!existsSync13(personaPath)) {
32236
32258
  cliOutput(
32237
32259
  {
32238
32260
  success: false,
@@ -32249,7 +32271,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32249
32271
  const agentName = basename(resolvedDir);
32250
32272
  const archiveName = `${agentName}.cantz`;
32251
32273
  const archivePath = resolve5(archiveName);
32252
- const parentDir = dirname10(resolvedDir);
32274
+ const parentDir = dirname9(resolvedDir);
32253
32275
  try {
32254
32276
  execFileSync5("zip", ["-r", archivePath, agentName], {
32255
32277
  cwd: parentDir,
@@ -32279,7 +32301,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32279
32301
  if (entry.isFile()) {
32280
32302
  fileCount++;
32281
32303
  } else if (entry.isDirectory()) {
32282
- countFiles(join24(dirPath, entry.name));
32304
+ countFiles(join23(dirPath, entry.name));
32283
32305
  }
32284
32306
  }
32285
32307
  };
@@ -32348,8 +32370,8 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32348
32370
  },
32349
32371
  async run({ args }) {
32350
32372
  try {
32351
- const { existsSync: existsSync14, mkdirSync: mkdirSync6, writeFileSync: writeFileSync5 } = await import("node:fs");
32352
- const { join: join24 } = await import("node:path");
32373
+ const { existsSync: existsSync13, mkdirSync: mkdirSync6, writeFileSync: writeFileSync5 } = await import("node:fs");
32374
+ const { join: join23 } = await import("node:path");
32353
32375
  const { homedir: homedir7 } = await import("node:os");
32354
32376
  const name = args.name;
32355
32377
  const role = args.role;
@@ -32409,13 +32431,13 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32409
32431
  let targetRoot;
32410
32432
  if (isGlobal) {
32411
32433
  const home = homedir7();
32412
- const xdgData = process.env["XDG_DATA_HOME"] ?? join24(home, ".local", "share");
32413
- targetRoot = join24(xdgData, "cleo", "cant", "agents");
32434
+ const xdgData = process.env["XDG_DATA_HOME"] ?? join23(home, ".local", "share");
32435
+ targetRoot = join23(xdgData, "cleo", "cant", "agents");
32414
32436
  } else {
32415
- targetRoot = join24(process.cwd(), CLEO_DIR_NAME, CANT_AGENTS_SUBDIR);
32437
+ targetRoot = join23(process.cwd(), CLEO_DIR_NAME, CANT_AGENTS_SUBDIR);
32416
32438
  }
32417
- const agentDir = join24(targetRoot, name);
32418
- if (existsSync14(agentDir)) {
32439
+ const agentDir = join23(targetRoot, name);
32440
+ if (existsSync13(agentDir)) {
32419
32441
  cliOutput(
32420
32442
  {
32421
32443
  success: false,
@@ -32439,29 +32461,29 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32439
32461
  domain,
32440
32462
  parent
32441
32463
  });
32442
- writeFileSync5(join24(agentDir, "persona.cant"), personaContent, "utf-8");
32464
+ writeFileSync5(join23(agentDir, "persona.cant"), personaContent, "utf-8");
32443
32465
  const manifest = generateManifest({ name, role, tier, domain });
32444
32466
  writeFileSync5(
32445
- join24(agentDir, "manifest.json"),
32467
+ join23(agentDir, "manifest.json"),
32446
32468
  `${JSON.stringify(manifest, null, 2)}
32447
32469
  `,
32448
32470
  "utf-8"
32449
32471
  );
32450
32472
  const createdFiles = [
32451
- join24(agentDir, "persona.cant"),
32452
- join24(agentDir, "manifest.json")
32473
+ join23(agentDir, "persona.cant"),
32474
+ join23(agentDir, "manifest.json")
32453
32475
  ];
32454
32476
  if (team) {
32455
32477
  const teamConfigContent = generateTeamConfig(name, role, team);
32456
- writeFileSync5(join24(agentDir, "team-config.cant"), teamConfigContent, "utf-8");
32457
- createdFiles.push(join24(agentDir, "team-config.cant"));
32478
+ writeFileSync5(join23(agentDir, "team-config.cant"), teamConfigContent, "utf-8");
32479
+ createdFiles.push(join23(agentDir, "team-config.cant"));
32458
32480
  }
32459
32481
  if (seedBrain) {
32460
- const expertiseDir = join24(agentDir, "expertise");
32482
+ const expertiseDir = join23(agentDir, "expertise");
32461
32483
  mkdirSync6(expertiseDir, { recursive: true });
32462
32484
  const seedContent = generateMentalModelSeed(name, role, domain);
32463
- writeFileSync5(join24(expertiseDir, "mental-model-seed.md"), seedContent, "utf-8");
32464
- createdFiles.push(join24(expertiseDir, "mental-model-seed.md"));
32485
+ writeFileSync5(join23(expertiseDir, "mental-model-seed.md"), seedContent, "utf-8");
32486
+ createdFiles.push(join23(expertiseDir, "mental-model-seed.md"));
32465
32487
  try {
32466
32488
  const { execFile: execFile2 } = await import("node:child_process");
32467
32489
  const { promisify: promisify2 } = await import("node:util");
@@ -32559,10 +32581,10 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32559
32581
  },
32560
32582
  async run({ args }) {
32561
32583
  try {
32562
- const { existsSync: existsSync14, readFileSync: readFileSync16, mkdirSync: mkdirSync6 } = await import("node:fs");
32563
- const { resolve: resolve5, join: join24 } = await import("node:path");
32584
+ const { existsSync: existsSync13, readFileSync: readFileSync16, mkdirSync: mkdirSync6 } = await import("node:fs");
32585
+ const { resolve: resolve5, join: join23 } = await import("node:path");
32564
32586
  const specPath = resolve5(args.spec);
32565
- if (!existsSync14(specPath)) {
32587
+ if (!existsSync13(specPath)) {
32566
32588
  if (args.json) {
32567
32589
  const errEnv = {
32568
32590
  success: false,
@@ -32578,7 +32600,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32578
32600
  }
32579
32601
  const specContent = readFileSync16(specPath, "utf-8");
32580
32602
  const projectRoot = process.cwd();
32581
- const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join24(projectRoot, ".cleo", "cant", "agents");
32603
+ const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join23(projectRoot, ".cleo", "cant", "agents");
32582
32604
  mkdirSync6(outputDir, { recursive: true });
32583
32605
  if (args["dry-run"]) {
32584
32606
  const preview = {
@@ -32669,7 +32691,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32669
32691
  );
32670
32692
  await ensureGlobalSignaldockDb2();
32671
32693
  const db = new DatabaseSync2(getGlobalSignaldockDbPath2());
32672
- db.exec("PRAGMA foreign_keys = ON");
32694
+ applyPerfPragmas(db);
32673
32695
  try {
32674
32696
  const report = await buildDoctorReport(db, {});
32675
32697
  const d002 = report.findings.filter((f) => f.code === "D-002");
@@ -32746,7 +32768,7 @@ Task ${args.taskId} reassigned to you by ${active.agentId}. Run: cleo show ${arg
32746
32768
  await ensureGlobalSignaldockDb2();
32747
32769
  const dbPath = getGlobalSignaldockDbPath2();
32748
32770
  const db = new DatabaseSync2(dbPath);
32749
- db.exec("PRAGMA foreign_keys = ON");
32771
+ applyPerfPragmas(db);
32750
32772
  try {
32751
32773
  const report = await buildDoctorReport(db, { projectRoot: process.cwd() });
32752
32774
  const repairFlag = args.repair === true;
@@ -34389,57 +34411,7 @@ var bug_exports = {};
34389
34411
  __export(bug_exports, {
34390
34412
  bugCommand: () => bugCommand
34391
34413
  });
34392
- import { existsSync as existsSync6 } from "node:fs";
34393
- import { appendFile, mkdir, readFile as readFile2 } from "node:fs/promises";
34394
- import { dirname as dirname4, join as join7 } from "node:path";
34395
- import { getCleoDirAbsolute as getCleoDirAbsolute2, getCleoIdentity, getConfigPath, signAuditLine } from "@cleocode/core";
34396
- async function loadOwnerPubkeys() {
34397
- const configPath = getConfigPath();
34398
- if (!existsSync6(configPath)) {
34399
- return [];
34400
- }
34401
- try {
34402
- const raw = await readFile2(configPath, "utf-8");
34403
- const parsed = JSON.parse(raw);
34404
- if (typeof parsed !== "object" || parsed === null) {
34405
- return [];
34406
- }
34407
- const list = parsed.ownerPubkeys;
34408
- if (!Array.isArray(list)) {
34409
- return [];
34410
- }
34411
- return list.filter((v) => typeof v === "string" && v.length === 64);
34412
- } catch {
34413
- return [];
34414
- }
34415
- }
34416
- function canonicalAttestationJson(record) {
34417
- const sortedKeys = Object.keys(record).sort();
34418
- const ordered = {};
34419
- for (const key of sortedKeys) {
34420
- ordered[key] = record[key];
34421
- }
34422
- return JSON.stringify(ordered);
34423
- }
34424
- async function appendSignedBugSeverity(record) {
34425
- const id = await getCleoIdentity();
34426
- const owners = await loadOwnerPubkeys();
34427
- if (owners.length > 0 && !owners.includes(id.pubkeyHex)) {
34428
- const err = new Error(
34429
- `E_OWNER_ONLY: severity attestation requires an owner-allowlisted identity (pub=${id.pubkeyHex.slice(0, 8)}\u2026). Add your public key to .cleo/config.json "ownerPubkeys" array to authorise.`
34430
- );
34431
- err.code = "E_OWNER_ONLY";
34432
- throw err;
34433
- }
34434
- const full = { ...record, signerPub: id.pubkeyHex };
34435
- const canonical = canonicalAttestationJson(full);
34436
- const sig = await signAuditLine(id, canonical);
34437
- const line = `${JSON.stringify({ ...full, _sig: sig })}
34438
- `;
34439
- const auditPath = join7(getCleoDirAbsolute2(), "audit", "bug-severity.jsonl");
34440
- await mkdir(dirname4(auditPath), { recursive: true });
34441
- await appendFile(auditPath, line, { encoding: "utf-8" });
34442
- }
34414
+ import { appendSignedSeverityAttestation as appendSignedSeverityAttestation2 } from "@cleocode/core";
34443
34415
  var SEVERITY_MAP, VALID_SEVERITIES, bugCommand;
34444
34416
  var init_bug = __esm({
34445
34417
  "packages/cleo/src/cli/commands/bug.ts"() {
@@ -34514,7 +34486,7 @@ var init_bug = __esm({
34514
34486
  }
34515
34487
  if (!args["dry-run"]) {
34516
34488
  try {
34517
- await appendSignedBugSeverity({
34489
+ await appendSignedSeverityAttestation2({
34518
34490
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
34519
34491
  title: args.title,
34520
34492
  severity,
@@ -34540,7 +34512,7 @@ __export(caamp_exports, {
34540
34512
  caampCommand: () => caampCommand
34541
34513
  });
34542
34514
  import { homedir as homedir2 } from "node:os";
34543
- import { join as join8 } from "node:path";
34515
+ import { join as join7 } from "node:path";
34544
34516
  var dedupeCommand, caampCommand;
34545
34517
  var init_caamp = __esm({
34546
34518
  "packages/cleo/src/cli/commands/caamp.ts"() {
@@ -34577,22 +34549,22 @@ var init_caamp = __esm({
34577
34549
  } else {
34578
34550
  const home = homedir2();
34579
34551
  filePaths = [
34580
- join8(home, ".agents", "AGENTS.md"),
34552
+ join7(home, ".agents", "AGENTS.md"),
34581
34553
  // project-level AGENTS.md in cwd
34582
- join8(process.cwd(), "AGENTS.md")
34554
+ join7(process.cwd(), "AGENTS.md")
34583
34555
  ];
34584
34556
  }
34585
34557
  if (args["dry-run"]) {
34586
34558
  const { parseCaampBlocks } = await import("@cleocode/caamp");
34587
- const { existsSync: existsSync14 } = await import("node:fs");
34588
- const { readFile: readFile7 } = await import("node:fs/promises");
34559
+ const { existsSync: existsSync13 } = await import("node:fs");
34560
+ const { readFile: readFile6 } = await import("node:fs/promises");
34589
34561
  const dryResults = [];
34590
34562
  for (const filePath of filePaths) {
34591
- if (!existsSync14(filePath)) {
34563
+ if (!existsSync13(filePath)) {
34592
34564
  dryResults.push({ filePath, exists: false, blockCount: 0, wouldRemove: 0 });
34593
34565
  continue;
34594
34566
  }
34595
- const content = await readFile7(filePath, "utf-8");
34567
+ const content = await readFile6(filePath, "utf-8");
34596
34568
  const blocks = parseCaampBlocks(content);
34597
34569
  const uniqueContents = new Set(blocks.map((b) => b.content));
34598
34570
  const wouldRemove = blocks.length - uniqueContents.size;
@@ -34722,13 +34694,13 @@ var cant_exports = {};
34722
34694
  __export(cant_exports, {
34723
34695
  cantCommand: () => cantCommand
34724
34696
  });
34725
- import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "node:fs";
34726
- import { dirname as dirname5, isAbsolute, join as join9, resolve as resolve3 } from "node:path";
34697
+ import { existsSync as existsSync6, mkdirSync as mkdirSync2, readFileSync as readFileSync7, writeFileSync as writeFileSync2 } from "node:fs";
34698
+ import { dirname as dirname4, isAbsolute, join as join8, resolve as resolve3 } from "node:path";
34727
34699
  function resolveFilePath(file) {
34728
34700
  return isAbsolute(file) ? file : resolve3(process.cwd(), file);
34729
34701
  }
34730
34702
  function ensureExists(filePath, operation) {
34731
- if (existsSync7(filePath)) return true;
34703
+ if (existsSync6(filePath)) return true;
34732
34704
  cliError(`File not found: ${filePath}`, "E_FILE_READ");
34733
34705
  process.exitCode = 3;
34734
34706
  if (process.env["CLEO_DEBUG"]) humanWarn(`(operation: ${operation})`);
@@ -34888,8 +34860,8 @@ var init_cant = __esm({
34888
34860
  const projectRoot = process.cwd();
34889
34861
  let written = 0;
34890
34862
  for (const outputFile of result.outputFiles) {
34891
- const outputPath = isAbsolute(outputFile.path) ? outputFile.path : join9(projectRoot, outputFile.path);
34892
- mkdirSync2(dirname5(outputPath), { recursive: true });
34863
+ const outputPath = isAbsolute(outputFile.path) ? outputFile.path : join8(projectRoot, outputFile.path);
34864
+ mkdirSync2(dirname4(outputPath), { recursive: true });
34893
34865
  writeFileSync2(outputPath, outputFile.content, "utf-8");
34894
34866
  written++;
34895
34867
  }
@@ -35562,9 +35534,9 @@ var init_code = __esm({
35562
35534
  async run({ args }) {
35563
35535
  await requireTreeSitter();
35564
35536
  const { smartOutline } = await import("@cleocode/core/internal");
35565
- const { join: join24 } = await import("node:path");
35537
+ const { join: join23 } = await import("node:path");
35566
35538
  const root = process.cwd();
35567
- const absPath = args.file.startsWith("/") ? args.file : join24(root, args.file);
35539
+ const absPath = args.file.startsWith("/") ? args.file : join23(root, args.file);
35568
35540
  const result = smartOutline(absPath, root);
35569
35541
  if (result.errors.length > 0 && result.symbols.length === 0) {
35570
35542
  cliError(result.errors.join(", "), 1, { name: "E_OUTLINE_FAILED" });
@@ -35655,9 +35627,9 @@ var init_code = __esm({
35655
35627
  async run({ args }) {
35656
35628
  await requireTreeSitter();
35657
35629
  const { smartUnfold } = await import("@cleocode/core/internal");
35658
- const { join: join24 } = await import("node:path");
35630
+ const { join: join23 } = await import("node:path");
35659
35631
  const root = process.cwd();
35660
- const absPath = args.file.startsWith("/") ? args.file : join24(root, args.file);
35632
+ const absPath = args.file.startsWith("/") ? args.file : join23(root, args.file);
35661
35633
  const result = smartUnfold(absPath, args.symbol, root);
35662
35634
  if (!result.found) {
35663
35635
  const errs = result.errors.length > 0 ? `: ${result.errors.join(", ")}` : "";
@@ -36799,9 +36771,9 @@ var daemon_exports = {};
36799
36771
  __export(daemon_exports, {
36800
36772
  daemonCommand: () => daemonCommand
36801
36773
  });
36802
- import { existsSync as existsSync8 } from "node:fs";
36774
+ import { existsSync as existsSync7 } from "node:fs";
36803
36775
  import { homedir as homedir3 } from "node:os";
36804
- import { join as join10 } from "node:path";
36776
+ import { join as join9 } from "node:path";
36805
36777
  import { fileURLToPath as fileURLToPath3 } from "node:url";
36806
36778
  import { getGCDaemonStatus, spawnGCDaemon, stopGCDaemon } from "@cleocode/core/gc/daemon.js";
36807
36779
  import {
@@ -36866,9 +36838,9 @@ async function showDaemonStatus(cleoDir, projectRoot) {
36866
36838
  }
36867
36839
  function resolveDaemonInstallerScript() {
36868
36840
  const filePath = fileURLToPath3(import.meta.url);
36869
- const candidate1 = join10(filePath, "..", "..", "..", "scripts", "install-daemon-service.mjs");
36870
- if (existsSync8(candidate1)) return candidate1;
36871
- const candidate2 = join10(
36841
+ const candidate1 = join9(filePath, "..", "..", "..", "scripts", "install-daemon-service.mjs");
36842
+ if (existsSync7(candidate1)) return candidate1;
36843
+ const candidate2 = join9(
36872
36844
  filePath,
36873
36845
  "..",
36874
36846
  "..",
@@ -36903,7 +36875,7 @@ var init_daemon = __esm({
36903
36875
  }
36904
36876
  },
36905
36877
  async run({ args }) {
36906
- const cleoDir = args["cleo-dir"] ?? join10(homedir3(), ".cleo");
36878
+ const cleoDir = args["cleo-dir"] ?? join9(homedir3(), ".cleo");
36907
36879
  const foreground = args.foreground ?? false;
36908
36880
  if (foreground) {
36909
36881
  const projectRoot = process.cwd();
@@ -36940,13 +36912,13 @@ var init_daemon = __esm({
36940
36912
  {
36941
36913
  pid,
36942
36914
  cleoDir,
36943
- logs: join10(cleoDir, "logs", "gc.log"),
36915
+ logs: join9(cleoDir, "logs", "gc.log"),
36944
36916
  message: `GC daemon started (PID ${pid})`
36945
36917
  },
36946
36918
  {
36947
36919
  command: "daemon",
36948
36920
  operation: "daemon.start",
36949
- message: `GC daemon started (PID ${pid}) \u2014 Logs: ${join10(cleoDir, "logs", "gc.log")}`
36921
+ message: `GC daemon started (PID ${pid}) \u2014 Logs: ${join9(cleoDir, "logs", "gc.log")}`
36950
36922
  }
36951
36923
  );
36952
36924
  } catch (err) {
@@ -36976,7 +36948,7 @@ var init_daemon = __esm({
36976
36948
  }
36977
36949
  },
36978
36950
  async run({ args }) {
36979
- const cleoDir = args["cleo-dir"] ?? join10(homedir3(), ".cleo");
36951
+ const cleoDir = args["cleo-dir"] ?? join9(homedir3(), ".cleo");
36980
36952
  try {
36981
36953
  const stopResult = await stopGCDaemon(cleoDir);
36982
36954
  cliOutput(stopResult, {
@@ -37014,7 +36986,7 @@ var init_daemon = __esm({
37014
36986
  }
37015
36987
  },
37016
36988
  async run({ args }) {
37017
- const cleoDir = args["cleo-dir"] ?? join10(homedir3(), ".cleo");
36989
+ const cleoDir = args["cleo-dir"] ?? join9(homedir3(), ".cleo");
37018
36990
  await showDaemonStatus(cleoDir, process.cwd());
37019
36991
  }
37020
36992
  });
@@ -37112,7 +37084,7 @@ var init_daemon = __esm({
37112
37084
  },
37113
37085
  async run({ args, cmd, rawArgs }) {
37114
37086
  if (isSubCommandDispatch(rawArgs, cmd.subCommands)) return;
37115
- const cleoDir = args["cleo-dir"] ?? join10(homedir3(), ".cleo");
37087
+ const cleoDir = args["cleo-dir"] ?? join9(homedir3(), ".cleo");
37116
37088
  await showDaemonStatus(cleoDir, process.cwd());
37117
37089
  }
37118
37090
  });
@@ -37575,15 +37547,15 @@ var detect_drift_exports = {};
37575
37547
  __export(detect_drift_exports, {
37576
37548
  detectDriftCommand: () => detectDriftCommand
37577
37549
  });
37578
- import { existsSync as existsSync9, readdirSync, readFileSync as readFileSync9 } from "node:fs";
37579
- import { dirname as dirname6, join as join11 } from "node:path";
37550
+ import { existsSync as existsSync8, readdirSync, readFileSync as readFileSync9 } from "node:fs";
37551
+ import { dirname as dirname5, join as join10 } from "node:path";
37580
37552
  function findProjectRoot() {
37581
37553
  let currentDir = process.cwd();
37582
37554
  while (currentDir !== "/") {
37583
- if (existsSync9(join11(currentDir, "package.json"))) {
37555
+ if (existsSync8(join10(currentDir, "package.json"))) {
37584
37556
  return currentDir;
37585
37557
  }
37586
- const parent = dirname6(currentDir);
37558
+ const parent = dirname5(currentDir);
37587
37559
  if (parent === currentDir) break;
37588
37560
  currentDir = parent;
37589
37561
  }
@@ -37604,8 +37576,8 @@ var init_detect_drift = __esm({
37604
37576
  },
37605
37577
  async run() {
37606
37578
  const projectRoot = findProjectRoot();
37607
- const isCleoRepo = existsSync9(join11(projectRoot, "packages", "cleo", "src"));
37608
- const cleoSrcRoot = isCleoRepo ? join11(projectRoot, "packages", "cleo", "src") : join11(projectRoot, "src");
37579
+ const isCleoRepo = existsSync8(join10(projectRoot, "packages", "cleo", "src"));
37580
+ const cleoSrcRoot = isCleoRepo ? join10(projectRoot, "packages", "cleo", "src") : join10(projectRoot, "src");
37609
37581
  const safeRead = (filePath) => {
37610
37582
  try {
37611
37583
  return readFileSync9(filePath, "utf-8");
@@ -37619,8 +37591,8 @@ var init_detect_drift = __esm({
37619
37591
  checks: [],
37620
37592
  recommendations: []
37621
37593
  };
37622
- const injPath = join11(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
37623
- if (existsSync9(injPath)) {
37594
+ const injPath = join10(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
37595
+ if (existsSync8(injPath)) {
37624
37596
  const content = safeRead(injPath);
37625
37597
  userResult.checks.push({
37626
37598
  name: "Agent injection",
@@ -37671,10 +37643,10 @@ var init_detect_drift = __esm({
37671
37643
  }
37672
37644
  };
37673
37645
  try {
37674
- const specPath = join11(projectRoot, "docs", "specs", "CLEO-OPERATION-CONSTITUTION.md");
37675
- const registryPath = join11(cleoSrcRoot, "dispatch", "registry.ts");
37676
- const dispatchDomainsDir = join11(cleoSrcRoot, "dispatch", "domains");
37677
- if (!existsSync9(specPath)) {
37646
+ const specPath = join10(projectRoot, "docs", "specs", "CLEO-OPERATION-CONSTITUTION.md");
37647
+ const registryPath = join10(cleoSrcRoot, "dispatch", "registry.ts");
37648
+ const dispatchDomainsDir = join10(cleoSrcRoot, "dispatch", "domains");
37649
+ if (!existsSync8(specPath)) {
37678
37650
  addCheck("Gateway-to-spec sync", "fail", "CLEO-OPERATION-CONSTITUTION.md missing", [
37679
37651
  {
37680
37652
  severity: "error",
@@ -37684,7 +37656,7 @@ var init_detect_drift = __esm({
37684
37656
  recommendation: "Create docs/specs/CLEO-OPERATION-CONSTITUTION.md with canonical operation definitions"
37685
37657
  }
37686
37658
  ]);
37687
- } else if (!existsSync9(registryPath) || !existsSync9(dispatchDomainsDir)) {
37659
+ } else if (!existsSync8(registryPath) || !existsSync8(dispatchDomainsDir)) {
37688
37660
  addCheck("Gateway-to-spec sync", "fail", "Dispatch registry or domains missing", [
37689
37661
  {
37690
37662
  severity: "error",
@@ -37742,9 +37714,9 @@ var init_detect_drift = __esm({
37742
37714
  ]);
37743
37715
  }
37744
37716
  try {
37745
- const cliDir = join11(cleoSrcRoot, "cli", "commands");
37746
- const coreDir = isCleoRepo ? join11(projectRoot, "packages", "core", "src") : join11(projectRoot, "src", "core");
37747
- if (!existsSync9(cliDir)) {
37717
+ const cliDir = join10(cleoSrcRoot, "cli", "commands");
37718
+ const coreDir = isCleoRepo ? join10(projectRoot, "packages", "core", "src") : join10(projectRoot, "src", "core");
37719
+ if (!existsSync8(cliDir)) {
37748
37720
  addCheck("CLI-to-core sync", "fail", "CLI commands directory missing", [
37749
37721
  {
37750
37722
  severity: "error",
@@ -37753,7 +37725,7 @@ var init_detect_drift = __esm({
37753
37725
  recommendation: "Verify TypeScript source structure is intact"
37754
37726
  }
37755
37727
  ]);
37756
- } else if (!existsSync9(coreDir)) {
37728
+ } else if (!existsSync8(coreDir)) {
37757
37729
  addCheck("CLI-to-core sync", "fail", "Core directory missing", [
37758
37730
  {
37759
37731
  severity: "error",
@@ -37770,8 +37742,8 @@ var init_detect_drift = __esm({
37770
37742
  addCheck("CLI-to-core sync", "fail", `Error: ${getErrorMessage(e)}`);
37771
37743
  }
37772
37744
  try {
37773
- const domainsDir = join11(cleoSrcRoot, "dispatch", "domains");
37774
- if (!existsSync9(domainsDir)) {
37745
+ const domainsDir = join10(cleoSrcRoot, "dispatch", "domains");
37746
+ if (!existsSync8(domainsDir)) {
37775
37747
  addCheck("Domain handler coverage", "fail", "Dispatch domains directory missing", [
37776
37748
  {
37777
37749
  severity: "error",
@@ -37788,8 +37760,8 @@ var init_detect_drift = __esm({
37788
37760
  addCheck("Domain handler coverage", "fail", `Error: ${getErrorMessage(e)}`);
37789
37761
  }
37790
37762
  try {
37791
- const matrixPath = join11(cleoSrcRoot, "dispatch", "lib", "capability-matrix.ts");
37792
- if (!existsSync9(matrixPath)) {
37763
+ const matrixPath = join10(cleoSrcRoot, "dispatch", "lib", "capability-matrix.ts");
37764
+ if (!existsSync8(matrixPath)) {
37793
37765
  addCheck("Capability matrix", "fail", "Capability matrix missing", [
37794
37766
  {
37795
37767
  severity: "error",
@@ -37805,8 +37777,8 @@ var init_detect_drift = __esm({
37805
37777
  addCheck("Capability matrix", "fail", `Error: ${getErrorMessage(e)}`);
37806
37778
  }
37807
37779
  try {
37808
- const schemaPath = join11(projectRoot, "src", "store", "schema.ts");
37809
- if (!existsSync9(schemaPath)) {
37780
+ const schemaPath = join10(projectRoot, "src", "store", "schema.ts");
37781
+ if (!existsSync8(schemaPath)) {
37810
37782
  addCheck("Schema validation", "fail", "Schema definition missing", [
37811
37783
  {
37812
37784
  severity: "error",
@@ -37840,10 +37812,10 @@ var init_detect_drift = __esm({
37840
37812
  addCheck("Schema validation", "fail", `Error: ${getErrorMessage(e)}`);
37841
37813
  }
37842
37814
  try {
37843
- const visionPath = join11(projectRoot, "docs", "concepts", "CLEO-VISION.md");
37844
- const specPath = join11(projectRoot, "docs", "specs", "CLEO-PORTABLE-PROJECT-BRAIN-SPEC.md");
37815
+ const visionPath = join10(projectRoot, "docs", "concepts", "CLEO-VISION.md");
37816
+ const specPath = join10(projectRoot, "docs", "specs", "CLEO-PORTABLE-PROJECT-BRAIN-SPEC.md");
37845
37817
  const issues = [];
37846
- if (!existsSync9(visionPath)) {
37818
+ if (!existsSync8(visionPath)) {
37847
37819
  issues.push({
37848
37820
  severity: "error",
37849
37821
  category: "vision",
@@ -37852,7 +37824,7 @@ var init_detect_drift = __esm({
37852
37824
  recommendation: "Create docs/concepts/CLEO-VISION.md with project vision"
37853
37825
  });
37854
37826
  }
37855
- if (!existsSync9(specPath)) {
37827
+ if (!existsSync8(specPath)) {
37856
37828
  issues.push({
37857
37829
  severity: "error",
37858
37830
  category: "spec",
@@ -37896,8 +37868,8 @@ var init_detect_drift = __esm({
37896
37868
  addCheck("Canonical identity", "fail", `Error: ${getErrorMessage(e)}`);
37897
37869
  }
37898
37870
  try {
37899
- const injectionPath = join11(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
37900
- if (!existsSync9(injectionPath)) {
37871
+ const injectionPath = join10(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
37872
+ if (!existsSync8(injectionPath)) {
37901
37873
  addCheck("Agent injection", "fail", "Agent injection template missing", [
37902
37874
  {
37903
37875
  severity: "error",
@@ -37926,8 +37898,8 @@ var init_detect_drift = __esm({
37926
37898
  addCheck("Agent injection", "fail", `Error: ${getErrorMessage(e)}`);
37927
37899
  }
37928
37900
  try {
37929
- const exitCodesPath = join11(cleoSrcRoot, "dispatch", "lib", "exit-codes.ts");
37930
- if (!existsSync9(exitCodesPath)) {
37901
+ const exitCodesPath = join10(cleoSrcRoot, "dispatch", "lib", "exit-codes.ts");
37902
+ if (!existsSync8(exitCodesPath)) {
37931
37903
  addCheck("Exit codes", "fail", "Exit codes definition missing", [
37932
37904
  {
37933
37905
  severity: "error",
@@ -38100,8 +38072,8 @@ var docs_exports = {};
38100
38072
  __export(docs_exports, {
38101
38073
  docsCommand: () => docsCommand
38102
38074
  });
38103
- import { mkdir as mkdir2, readdir, readFile as readFile3, writeFile } from "node:fs/promises";
38104
- import { dirname as dirname7, isAbsolute as isAbsolute2, join as join12, resolve as resolve4 } from "node:path";
38075
+ import { mkdir, readdir, readFile as readFile2, writeFile } from "node:fs/promises";
38076
+ import { dirname as dirname6, isAbsolute as isAbsolute2, join as join11, resolve as resolve4 } from "node:path";
38105
38077
  import {
38106
38078
  buildDocsGraph,
38107
38079
  CleoError as CleoError3,
@@ -38117,7 +38089,7 @@ import {
38117
38089
  searchDocs
38118
38090
  } from "@cleocode/core/internal";
38119
38091
  async function getScriptNames(projectRoot) {
38120
- const scriptsDir = join12(projectRoot, "scripts");
38092
+ const scriptsDir = join11(projectRoot, "scripts");
38121
38093
  try {
38122
38094
  const files = await readdir(scriptsDir);
38123
38095
  return files.filter((f) => f.endsWith(".sh")).map((f) => f.replace(".sh", "")).sort();
@@ -38126,7 +38098,7 @@ async function getScriptNames(projectRoot) {
38126
38098
  }
38127
38099
  }
38128
38100
  async function getIndexedCommands(projectRoot) {
38129
- const indexPath = join12(projectRoot, "docs", "commands", "COMMANDS-INDEX.json");
38101
+ const indexPath = join11(projectRoot, "docs", "commands", "COMMANDS-INDEX.json");
38130
38102
  const index = await readJson(indexPath);
38131
38103
  if (!index) return [];
38132
38104
  return index.commands.map((c) => c.name).sort();
@@ -38159,8 +38131,8 @@ async function runGapCheck(_projectRoot, filterId) {
38159
38131
  const reviewFiles = files.filter((f) => f.endsWith(".md"));
38160
38132
  for (const file of reviewFiles) {
38161
38133
  if (filterId && !file.includes(filterId)) continue;
38162
- const filePath = join12(reviewDir, file);
38163
- const content = await readFile3(filePath, "utf-8");
38134
+ const filePath = join11(reviewDir, file);
38135
+ const content = await readFile2(filePath, "utf-8");
38164
38136
  const taskMatch = file.match(/^(T\d+)/);
38165
38137
  const taskId = taskMatch ? taskMatch[1] : "UNKNOWN";
38166
38138
  const gaps = [];
@@ -38415,7 +38387,7 @@ var init_docs3 = __esm({
38415
38387
  let writtenPath;
38416
38388
  if (typeof args.out === "string" && args.out.length > 0) {
38417
38389
  const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
38418
- await mkdir2(dirname7(outPath), { recursive: true });
38390
+ await mkdir(dirname6(outPath), { recursive: true });
38419
38391
  await writeFile(outPath, result.markdown, "utf8");
38420
38392
  writtenPath = outPath;
38421
38393
  }
@@ -38529,7 +38501,7 @@ var init_docs3 = __esm({
38529
38501
  });
38530
38502
  if (typeof args.out === "string" && args.out.length > 0) {
38531
38503
  const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
38532
- await mkdir2(dirname7(outPath), { recursive: true });
38504
+ await mkdir(dirname6(outPath), { recursive: true });
38533
38505
  await writeFile(outPath, result.merged, "utf8");
38534
38506
  humanInfo(`Wrote merged content to ${outPath}`);
38535
38507
  }
@@ -38600,7 +38572,7 @@ var init_docs3 = __esm({
38600
38572
  }
38601
38573
  if (typeof args.out === "string" && args.out.length > 0) {
38602
38574
  const outPath = isAbsolute2(args.out) ? args.out : resolve4(projectRoot, args.out);
38603
- await mkdir2(dirname7(outPath), { recursive: true });
38575
+ await mkdir(dirname6(outPath), { recursive: true });
38604
38576
  await writeFile(outPath, output, "utf8");
38605
38577
  humanInfo(`Wrote graph to ${outPath}`);
38606
38578
  }
@@ -39123,10 +39095,11 @@ __export(migrate_agents_v2_exports, {
39123
39095
  walkAgentsDir: () => walkAgentsDir
39124
39096
  });
39125
39097
  import { createHash as createHash2 } from "node:crypto";
39126
- import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync10 } from "node:fs";
39127
- import { join as join13 } from "node:path";
39098
+ import { appendFileSync as appendFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync10 } from "node:fs";
39099
+ import { join as join12 } from "node:path";
39128
39100
  import { DatabaseSync } from "node:sqlite";
39129
39101
  import {
39102
+ applyPerfPragmas as applyPerfPragmas2,
39130
39103
  ensureGlobalSignaldockDb,
39131
39104
  getGlobalSignaldockDbPath,
39132
39105
  getProjectRoot as getProjectRoot23,
@@ -39149,15 +39122,15 @@ function extractAgentName(source) {
39149
39122
  return headerMatch[1] ?? null;
39150
39123
  }
39151
39124
  function appendAuditLog(projectRoot, entry) {
39152
- const auditPath = join13(projectRoot, AUDIT_LOG_RELATIVE);
39153
- const auditDir = join13(auditPath, "..");
39154
- if (!existsSync10(auditDir)) {
39125
+ const auditPath = join12(projectRoot, AUDIT_LOG_RELATIVE);
39126
+ const auditDir = join12(auditPath, "..");
39127
+ if (!existsSync9(auditDir)) {
39155
39128
  mkdirSync3(auditDir, { recursive: true });
39156
39129
  }
39157
39130
  appendFileSync2(auditPath, JSON.stringify(entry) + "\n", "utf8");
39158
39131
  }
39159
39132
  function walkAgentsDir(db, scanDir, projectRoot, summary, verbose) {
39160
- if (!existsSync10(scanDir)) return;
39133
+ if (!existsSync9(scanDir)) return;
39161
39134
  let files;
39162
39135
  try {
39163
39136
  files = readdirSync2(scanDir).filter((f) => f.endsWith(".cant"));
@@ -39168,7 +39141,7 @@ function walkAgentsDir(db, scanDir, projectRoot, summary, verbose) {
39168
39141
  return;
39169
39142
  }
39170
39143
  for (const filename of files) {
39171
- const cantPath = join13(scanDir, filename);
39144
+ const cantPath = join12(scanDir, filename);
39172
39145
  const relPath = cantPath.replace(`${projectRoot}/`, "");
39173
39146
  let sourceBytes;
39174
39147
  let sourceText;
@@ -39264,12 +39237,11 @@ async function runMigrateAgentsV2(projectRoot, verbose = true) {
39264
39237
  const summary = { registered: 0, skipped: 0, conflicts: 0, errors: 0 };
39265
39238
  await ensureGlobalSignaldockDb();
39266
39239
  const db = new DatabaseSync(getGlobalSignaldockDbPath());
39267
- db.exec("PRAGMA foreign_keys = ON");
39268
- db.exec("PRAGMA journal_mode = WAL");
39240
+ applyPerfPragmas2(db);
39269
39241
  try {
39270
- const canonicalDir = join13(projectRoot, ".cleo", "cant", "agents");
39242
+ const canonicalDir = join12(projectRoot, ".cleo", "cant", "agents");
39271
39243
  walkAgentsDir(db, canonicalDir, projectRoot, summary, verbose);
39272
- const legacyDir = join13(projectRoot, ".cleo", "agents");
39244
+ const legacyDir = join12(projectRoot, ".cleo", "agents");
39273
39245
  walkAgentsDir(db, legacyDir, projectRoot, summary, verbose);
39274
39246
  } finally {
39275
39247
  db.close();
@@ -39277,8 +39249,8 @@ async function runMigrateAgentsV2(projectRoot, verbose = true) {
39277
39249
  return summary;
39278
39250
  }
39279
39251
  function readMigrationConflicts(projectRoot) {
39280
- const auditPath = join13(projectRoot, AUDIT_LOG_RELATIVE);
39281
- if (!existsSync10(auditPath)) return [];
39252
+ const auditPath = join12(projectRoot, AUDIT_LOG_RELATIVE);
39253
+ if (!existsSync9(auditPath)) return [];
39282
39254
  let raw;
39283
39255
  try {
39284
39256
  raw = readFileSync10(auditPath, "utf8");
@@ -39480,6 +39452,14 @@ var init_doctor = __esm({
39480
39452
  type: "boolean",
39481
39453
  description: "Scan ~/.local/share/cleo/ for orphaned nexus.db files and print report (T9052)"
39482
39454
  },
39455
+ "audit-worktrees": {
39456
+ type: "boolean",
39457
+ description: "Audit orphaned agent worktree directories and report what cleo gc --worktrees would remove (T9043)"
39458
+ },
39459
+ "audit-temp": {
39460
+ type: "boolean",
39461
+ description: "Audit orphaned CLEO-generated temp directories and report what cleo gc --temp would remove (T9043)"
39462
+ },
39483
39463
  "dry-run": {
39484
39464
  type: "boolean",
39485
39465
  description: "With --quarantine-rogue-cleo-dirs or --scan-stray-nexus-dbs: print what would be done without acting"
@@ -39717,6 +39697,56 @@ Stray nexus.db scan (${isDryRun ? "DRY RUN \u2014 no files touched" : "live"})`)
39717
39697
  );
39718
39698
  humanLine("");
39719
39699
  }
39700
+ } else if (args["audit-worktrees"]) {
39701
+ progress.step(0, "Auditing orphaned agent worktrees");
39702
+ const { auditOrphanWorktrees } = await import("@cleocode/core/internal");
39703
+ const checkResult = auditOrphanWorktrees();
39704
+ progress.complete(`Worktree audit complete \u2014 ${checkResult.status}`);
39705
+ if (args.json) {
39706
+ process.stdout.write(
39707
+ JSON.stringify({ success: true, data: checkResult }, null, 2) + "\n"
39708
+ );
39709
+ } else {
39710
+ humanLine(`
39711
+ Worktree orphan audit: ${checkResult.message}`);
39712
+ const orphans = checkResult.details?.["orphans"];
39713
+ if (orphans && orphans.length > 0) {
39714
+ for (const o of orphans) {
39715
+ humanLine(` ${o.path} (${o.ageLabel} old)`);
39716
+ }
39717
+ humanLine("\nRun: cleo gc --worktrees to remove orphaned worktrees.\n");
39718
+ if (process.exitCode === void 0 || process.exitCode === 0) {
39719
+ process.exitCode = 2;
39720
+ }
39721
+ } else {
39722
+ humanLine(" No orphaned worktrees found.\n");
39723
+ }
39724
+ }
39725
+ } else if (args["audit-temp"]) {
39726
+ progress.step(0, "Auditing orphaned CLEO temp directories");
39727
+ const { auditOrphanTempDirs } = await import("@cleocode/core/internal");
39728
+ const checkResult = await auditOrphanTempDirs();
39729
+ progress.complete(`Temp audit complete \u2014 ${checkResult.status}`);
39730
+ if (args.json) {
39731
+ process.stdout.write(
39732
+ JSON.stringify({ success: true, data: checkResult }, null, 2) + "\n"
39733
+ );
39734
+ } else {
39735
+ humanLine(`
39736
+ Temp dir orphan audit: ${checkResult.message}`);
39737
+ const orphans = checkResult.details?.["orphans"];
39738
+ if (orphans && orphans.length > 0) {
39739
+ for (const o of orphans) {
39740
+ humanLine(` ${o.path} (${o.age} old)`);
39741
+ }
39742
+ humanLine("\nRun: cleo gc --temp to remove orphaned temp directories.\n");
39743
+ if (process.exitCode === void 0 || process.exitCode === 0) {
39744
+ process.exitCode = 2;
39745
+ }
39746
+ } else {
39747
+ humanLine(" No orphaned CLEO temp directories found.\n");
39748
+ }
39749
+ }
39720
39750
  } else {
39721
39751
  progress.step(0, "Checking CLEO directory");
39722
39752
  await dispatchFromCli(
@@ -40016,12 +40046,12 @@ var init_find = __esm({
40016
40046
  fields: { type: "string", description: "Comma-separated additional fields to include" },
40017
40047
  verbose: { type: "boolean", description: "Include all task fields", alias: "v" },
40018
40048
  /**
40019
- * Filter by task role axis (T944).
40049
+ * Filter by task kind axis (T944/T9072).
40020
40050
  * Values: work | research | experiment | bug | spike | release
40021
40051
  */
40022
- role: {
40052
+ kind: {
40023
40053
  type: "string",
40024
- description: "Filter by role axis (work|research|experiment|bug|spike|release) \u2014 T944"
40054
+ description: "Filter by kind axis (work|research|experiment|bug|spike|release) \u2014 T944"
40025
40055
  }
40026
40056
  },
40027
40057
  async run({ args }) {
@@ -40038,7 +40068,7 @@ var init_find = __esm({
40038
40068
  if (offset !== void 0) params["offset"] = offset;
40039
40069
  if (args.fields !== void 0) params["fields"] = args.fields;
40040
40070
  if (args.verbose !== void 0) params["verbose"] = args.verbose;
40041
- if (args.role !== void 0) params["role"] = args.role;
40071
+ if (args.kind !== void 0) params["kind"] = args.kind;
40042
40072
  const response = await dispatchRaw("query", "tasks", "find", params);
40043
40073
  if (!response.success) {
40044
40074
  handleRawError(response, { command: "find", operation: "tasks.find" });
@@ -40068,8 +40098,9 @@ var gc_exports = {};
40068
40098
  __export(gc_exports, {
40069
40099
  gcCommand: () => gcCommand
40070
40100
  });
40071
- import { homedir as homedir4 } from "node:os";
40072
- import { join as join14 } from "node:path";
40101
+ import { homedir as homedir4, tmpdir } from "node:os";
40102
+ import { join as join13 } from "node:path";
40103
+ import { pruneOrphanTempDirs, pruneOrphanWorktrees } from "@cleocode/core/gc/cleanup.js";
40073
40104
  import { runGC } from "@cleocode/core/gc/runner.js";
40074
40105
  import { readGCState } from "@cleocode/core/gc/state.js";
40075
40106
  function formatBytes(bytes) {
@@ -40079,7 +40110,7 @@ function formatBytes(bytes) {
40079
40110
  const value = bytes / 1024 ** exp;
40080
40111
  return `${value.toFixed(exp === 0 ? 0 : 1)} ${units[exp] ?? "B"}`;
40081
40112
  }
40082
- var runCommand2, statusCommand6, gcCommand;
40113
+ var runCommand2, statusCommand6, worktreesCommand, tempCommand, gcCommand;
40083
40114
  var init_gc = __esm({
40084
40115
  "packages/cleo/src/cli/commands/gc.ts"() {
40085
40116
  "use strict";
@@ -40107,7 +40138,7 @@ var init_gc = __esm({
40107
40138
  }
40108
40139
  },
40109
40140
  async run({ args }) {
40110
- const cleoDir = args["cleo-dir"] ?? join14(homedir4(), ".cleo");
40141
+ const cleoDir = args["cleo-dir"] ?? join13(homedir4(), ".cleo");
40111
40142
  const dryRun = args["dry-run"];
40112
40143
  try {
40113
40144
  const gcResult = await runGC({ cleoDir, dryRun });
@@ -40149,8 +40180,8 @@ var init_gc = __esm({
40149
40180
  }
40150
40181
  },
40151
40182
  async run({ args }) {
40152
- const cleoDir = args["cleo-dir"] ?? join14(homedir4(), ".cleo");
40153
- const statePath = join14(cleoDir, "gc-state.json");
40183
+ const cleoDir = args["cleo-dir"] ?? join13(homedir4(), ".cleo");
40184
+ const statePath = join13(cleoDir, "gc-state.json");
40154
40185
  try {
40155
40186
  const state = await readGCState(statePath);
40156
40187
  const diskStr = state.lastDiskUsedPct !== null ? `${state.lastDiskUsedPct.toFixed(1)}%` : "unknown";
@@ -40173,6 +40204,121 @@ var init_gc = __esm({
40173
40204
  }
40174
40205
  }
40175
40206
  });
40207
+ worktreesCommand = defineCommand({
40208
+ meta: {
40209
+ name: "worktrees",
40210
+ description: "Prune orphaned agent worktree directories (task IDs no longer active)"
40211
+ },
40212
+ args: {
40213
+ "worktrees-root": {
40214
+ type: "string",
40215
+ description: "Override the worktrees root directory"
40216
+ },
40217
+ "project-hash": {
40218
+ type: "string",
40219
+ description: "Scope pruning to a single project hash"
40220
+ },
40221
+ "preserve-tasks": {
40222
+ type: "string",
40223
+ description: "Comma-separated list of task IDs to preserve (default: none)"
40224
+ },
40225
+ "dry-run": {
40226
+ type: "boolean",
40227
+ description: "Report what would be pruned without deleting anything",
40228
+ default: false
40229
+ },
40230
+ json: {
40231
+ type: "boolean",
40232
+ description: "Output result as JSON",
40233
+ default: false
40234
+ }
40235
+ },
40236
+ async run({ args }) {
40237
+ const xdgData = process.env["XDG_DATA_HOME"] ?? join13(homedir4(), ".local", "share");
40238
+ const worktreesRoot = args["worktrees-root"] ?? join13(xdgData, "cleo", "worktrees");
40239
+ const projectHash = args["project-hash"];
40240
+ const dryRun = args["dry-run"];
40241
+ const preserveRaw = args["preserve-tasks"];
40242
+ const activeTaskIds = new Set(
40243
+ preserveRaw ? preserveRaw.split(",").map((s) => s.trim()).filter(Boolean) : []
40244
+ );
40245
+ try {
40246
+ const result = pruneOrphanWorktrees({
40247
+ worktreesRoot,
40248
+ projectHash,
40249
+ activeTaskIds,
40250
+ dryRun
40251
+ });
40252
+ const dryLabel = dryRun ? " (dry run)" : "";
40253
+ const humanMsg = `GC worktrees${dryLabel} \u2014 ${dryRun ? "Would remove" : "Removed"}: ${result.removed} director${result.removed === 1 ? "y" : "ies"}` + (result.errors.length > 0 ? `, ${result.errors.length} error(s)` : "");
40254
+ cliOutput(result, {
40255
+ command: "gc",
40256
+ operation: "gc.worktrees",
40257
+ message: humanMsg
40258
+ });
40259
+ } catch (err) {
40260
+ const message = err instanceof Error ? err.message : String(err);
40261
+ cliError(
40262
+ `GC worktrees failed: ${message}`,
40263
+ "E_INTERNAL",
40264
+ { name: "E_INTERNAL" },
40265
+ { operation: "gc.worktrees" }
40266
+ );
40267
+ process.exit(1);
40268
+ }
40269
+ }
40270
+ });
40271
+ tempCommand = defineCommand({
40272
+ meta: {
40273
+ name: "temp",
40274
+ description: "Prune orphaned CLEO-generated temp directories from os.tmpdir()"
40275
+ },
40276
+ args: {
40277
+ "max-age-hours": {
40278
+ type: "string",
40279
+ description: "Maximum age (hours) before a temp dir is eligible for pruning (default: 2)"
40280
+ },
40281
+ "dry-run": {
40282
+ type: "boolean",
40283
+ description: "Report what would be pruned without deleting anything",
40284
+ default: false
40285
+ },
40286
+ json: {
40287
+ type: "boolean",
40288
+ description: "Output result as JSON",
40289
+ default: false
40290
+ }
40291
+ },
40292
+ async run({ args }) {
40293
+ const maxAgeHoursRaw = args["max-age-hours"];
40294
+ const maxAgeHours = maxAgeHoursRaw !== void 0 ? Number(maxAgeHoursRaw) : 2;
40295
+ const maxAgeMs = maxAgeHours * 60 * 60 * 1e3;
40296
+ const dryRun = args["dry-run"];
40297
+ try {
40298
+ const result = pruneOrphanTempDirs({
40299
+ maxAgeMs,
40300
+ tempDir: tmpdir(),
40301
+ dryRun
40302
+ });
40303
+ const dryLabel = dryRun ? " (dry run)" : "";
40304
+ const humanMsg = `GC temp${dryLabel} \u2014 ${dryRun ? "Would remove" : "Removed"}: ${result.removed} director${result.removed === 1 ? "y" : "ies"}, skipped: ${result.skipped}` + (result.errors.length > 0 ? `, ${result.errors.length} error(s)` : "");
40305
+ cliOutput(result, {
40306
+ command: "gc",
40307
+ operation: "gc.temp",
40308
+ message: humanMsg
40309
+ });
40310
+ } catch (err) {
40311
+ const message = err instanceof Error ? err.message : String(err);
40312
+ cliError(
40313
+ `GC temp failed: ${message}`,
40314
+ "E_INTERNAL",
40315
+ { name: "E_INTERNAL" },
40316
+ { operation: "gc.temp" }
40317
+ );
40318
+ process.exit(1);
40319
+ }
40320
+ }
40321
+ });
40176
40322
  gcCommand = defineCommand({
40177
40323
  meta: {
40178
40324
  name: "gc",
@@ -40180,7 +40326,9 @@ var init_gc = __esm({
40180
40326
  },
40181
40327
  subCommands: {
40182
40328
  run: runCommand2,
40183
- status: statusCommand6
40329
+ status: statusCommand6,
40330
+ worktrees: worktreesCommand,
40331
+ temp: tempCommand
40184
40332
  },
40185
40333
  async run({ cmd, rawArgs }) {
40186
40334
  const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
@@ -40197,11 +40345,11 @@ __export(generate_changelog_exports, {
40197
40345
  generateChangelogCommand: () => generateChangelogCommand
40198
40346
  });
40199
40347
  import { execFileSync as execFileSync2 } from "node:child_process";
40200
- import { existsSync as existsSync11, mkdirSync as mkdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync3 } from "node:fs";
40201
- import { dirname as dirname8, join as join15 } from "node:path";
40202
- import { CleoError as CleoError4, formatError as formatError6, getConfigPath as getConfigPath2, getProjectRoot as getProjectRoot25 } from "@cleocode/core";
40348
+ import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync11, writeFileSync as writeFileSync3 } from "node:fs";
40349
+ import { dirname as dirname7, join as join14 } from "node:path";
40350
+ import { CleoError as CleoError4, formatError as formatError6, getConfigPath, getProjectRoot as getProjectRoot25 } from "@cleocode/core";
40203
40351
  function getChangelogSource(cwd) {
40204
- const configPath = getConfigPath2(cwd);
40352
+ const configPath = getConfigPath(cwd);
40205
40353
  try {
40206
40354
  const config = JSON.parse(readFileSync11(configPath, "utf-8"));
40207
40355
  return config?.release?.changelog?.source ?? "CHANGELOG.md";
@@ -40210,7 +40358,7 @@ function getChangelogSource(cwd) {
40210
40358
  }
40211
40359
  }
40212
40360
  function getEnabledPlatforms(cwd) {
40213
- const configPath = getConfigPath2(cwd);
40361
+ const configPath = getConfigPath(cwd);
40214
40362
  try {
40215
40363
  const config = JSON.parse(readFileSync11(configPath, "utf-8"));
40216
40364
  const outputs = config?.release?.changelog?.outputs ?? [];
@@ -40363,8 +40511,8 @@ var init_generate_changelog = __esm({
40363
40511
  const targetPlatform = args.platform;
40364
40512
  const dryRun = args["dry-run"] === true;
40365
40513
  const sourceFile = getChangelogSource();
40366
- const sourcePath = join15(getProjectRoot25(), sourceFile);
40367
- if (!existsSync11(sourcePath)) {
40514
+ const sourcePath = join14(getProjectRoot25(), sourceFile);
40515
+ if (!existsSync10(sourcePath)) {
40368
40516
  throw new CleoError4(4 /* NOT_FOUND */, `Changelog source not found: ${sourcePath}`);
40369
40517
  }
40370
40518
  const sourceContent = readFileSync11(sourcePath, "utf-8");
@@ -40376,8 +40524,8 @@ var init_generate_changelog = __esm({
40376
40524
  const outputPath = platformConfig?.path ?? getDefaultOutputPath(targetPlatform);
40377
40525
  const content = generateForPlatform(targetPlatform, sourceContent, repoSlug, limit);
40378
40526
  if (!dryRun) {
40379
- const fullPath = join15(getProjectRoot25(), outputPath);
40380
- mkdirSync4(dirname8(fullPath), { recursive: true });
40527
+ const fullPath = join14(getProjectRoot25(), outputPath);
40528
+ mkdirSync4(dirname7(fullPath), { recursive: true });
40381
40529
  writeFileSync3(fullPath, content, "utf-8");
40382
40530
  }
40383
40531
  results.push({ platform: targetPlatform, path: outputPath, written: !dryRun });
@@ -40397,8 +40545,8 @@ var init_generate_changelog = __esm({
40397
40545
  limit
40398
40546
  );
40399
40547
  if (!dryRun) {
40400
- const fullPath = join15(getProjectRoot25(), platformConfig.path);
40401
- mkdirSync4(dirname8(fullPath), { recursive: true });
40548
+ const fullPath = join14(getProjectRoot25(), platformConfig.path);
40549
+ mkdirSync4(dirname7(fullPath), { recursive: true });
40402
40550
  writeFileSync3(fullPath, content, "utf-8");
40403
40551
  }
40404
40552
  results.push({
@@ -40694,18 +40842,18 @@ __export(init_exports, {
40694
40842
  getGitignoreTemplate: () => getGitignoreTemplate,
40695
40843
  initCommand: () => initCommand
40696
40844
  });
40697
- import { existsSync as existsSync12, readFileSync as readFileSync12 } from "node:fs";
40698
- import { join as join16 } from "node:path";
40845
+ import { existsSync as existsSync11, readFileSync as readFileSync12 } from "node:fs";
40846
+ import { join as join15 } from "node:path";
40699
40847
  import { fileURLToPath as fileURLToPath4 } from "node:url";
40700
40848
  import { CleoError as CleoError5, formatError as formatError7, initProject as initProject2 } from "@cleocode/core";
40701
40849
  function getGitignoreTemplate() {
40702
40850
  try {
40703
40851
  const thisFile = fileURLToPath4(import.meta.url);
40704
- const packageRoot = join16(thisFile, "..", "..", "..", "..");
40705
- const localTemplatePath = join16(packageRoot, "templates", "cleo-gitignore");
40706
- const monorepoTemplatePath = join16(packageRoot, "..", "..", "templates", "cleo-gitignore");
40707
- const templatePath = existsSync12(localTemplatePath) ? localTemplatePath : monorepoTemplatePath;
40708
- if (existsSync12(templatePath)) {
40852
+ const packageRoot = join15(thisFile, "..", "..", "..", "..");
40853
+ const localTemplatePath = join15(packageRoot, "templates", "cleo-gitignore");
40854
+ const monorepoTemplatePath = join15(packageRoot, "..", "..", "templates", "cleo-gitignore");
40855
+ const templatePath = existsSync11(localTemplatePath) ? localTemplatePath : monorepoTemplatePath;
40856
+ if (existsSync11(templatePath)) {
40709
40857
  return readFileSync12(templatePath, "utf-8");
40710
40858
  }
40711
40859
  } catch {
@@ -42012,9 +42160,9 @@ __export(memory_exports, {
42012
42160
  memoryCommand: () => memoryCommand
42013
42161
  });
42014
42162
  import { createHash as createHash3 } from "node:crypto";
42015
- import { existsSync as existsSync13, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync4 } from "node:fs";
42163
+ import { existsSync as existsSync12, mkdirSync as mkdirSync5, readdirSync as readdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync4 } from "node:fs";
42016
42164
  import { homedir as homedir5 } from "node:os";
42017
- import { join as join17 } from "node:path";
42165
+ import { join as join16 } from "node:path";
42018
42166
  import {
42019
42167
  getBrainDb as getBrainDb2,
42020
42168
  getBrainNativeDb as getBrainNativeDb3,
@@ -42054,7 +42202,7 @@ ${body}`).digest("hex").slice(0, 16);
42054
42202
  }
42055
42203
  function loadImportHashes(stateFile) {
42056
42204
  try {
42057
- if (!existsSync13(stateFile)) return /* @__PURE__ */ new Set();
42205
+ if (!existsSync12(stateFile)) return /* @__PURE__ */ new Set();
42058
42206
  const raw = readFileSync13(stateFile, "utf-8");
42059
42207
  const parsed = JSON.parse(raw);
42060
42208
  return new Set(parsed.hashes);
@@ -42064,7 +42212,7 @@ function loadImportHashes(stateFile) {
42064
42212
  }
42065
42213
  function saveImportHashes(stateFile, hashes) {
42066
42214
  const dir = stateFile.slice(0, stateFile.lastIndexOf("/"));
42067
- if (!existsSync13(dir)) mkdirSync5(dir, { recursive: true });
42215
+ if (!existsSync12(dir)) mkdirSync5(dir, { recursive: true });
42068
42216
  writeFileSync4(stateFile, JSON.stringify({ hashes: [...hashes] }, null, 2), "utf-8");
42069
42217
  }
42070
42218
  function makeMemorySubcommand(opts) {
@@ -43156,16 +43304,16 @@ var init_memory3 = __esm({
43156
43304
  }
43157
43305
  },
43158
43306
  async run({ args }) {
43159
- const sourceDir = args.from ?? join17(homedir5(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
43307
+ const sourceDir = args.from ?? join16(homedir5(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
43160
43308
  const isDryRun = !!args["dry-run"];
43161
43309
  const projectRoot = getProjectRoot26();
43162
- const stateFile = join17(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
43163
- if (!existsSync13(sourceDir)) {
43310
+ const stateFile = join16(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
43311
+ if (!existsSync12(sourceDir)) {
43164
43312
  cliError(`Source directory not found: ${sourceDir}`, "E_NOT_FOUND", { name: "E_NOT_FOUND" });
43165
43313
  process.exit(1);
43166
43314
  return;
43167
43315
  }
43168
- const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) => join17(sourceDir, f));
43316
+ const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) => join16(sourceDir, f));
43169
43317
  const importedHashes = isDryRun ? /* @__PURE__ */ new Set() : loadImportHashes(stateFile);
43170
43318
  const stats = { total: files.length, imported: 0, skipped: 0, errors: 0 };
43171
43319
  const importedEntries = [];
@@ -50123,7 +50271,7 @@ __export(restore_exports, {
50123
50271
  });
50124
50272
  import fs3 from "node:fs";
50125
50273
  import path4 from "node:path";
50126
- import { CleoError as CleoError8, getAccessor as getAccessor3 } from "@cleocode/core";
50274
+ import { CleoError as CleoError8, getTaskAccessor as getTaskAccessor3 } from "@cleocode/core";
50127
50275
  import { getProjectRoot as getProjectRoot29 } from "@cleocode/core/internal";
50128
50276
  function parseMarkdownValue(raw) {
50129
50277
  const trimmed = raw.trim();
@@ -50422,7 +50570,7 @@ var init_restore = __esm({
50422
50570
  if (!idPattern.test(taskId)) {
50423
50571
  throw new CleoError8(2 /* INVALID_INPUT */, `Invalid task ID: ${taskId}`);
50424
50572
  }
50425
- const accessor = await getAccessor3();
50573
+ const accessor = await getTaskAccessor3();
50426
50574
  const activeTask = await accessor.loadSingleTask(taskId);
50427
50575
  if (activeTask) {
50428
50576
  if (activeTask.status === "cancelled") {
@@ -50609,8 +50757,8 @@ var revert_exports = {};
50609
50757
  __export(revert_exports, {
50610
50758
  revertCommand: () => revertCommand
50611
50759
  });
50612
- import { readFile as readFile4 } from "node:fs/promises";
50613
- import { join as join18 } from "node:path";
50760
+ import { readFile as readFile3 } from "node:fs/promises";
50761
+ import { join as join17 } from "node:path";
50614
50762
  import { cwd as processCwd } from "node:process";
50615
50763
  import { E_RECEIPT_NOT_FOUND } from "@cleocode/core/sentient/chain-walker.js";
50616
50764
  import { SENTIENT_STATE_FILE } from "@cleocode/core/sentient/daemon.js";
@@ -50647,7 +50795,7 @@ async function loadOwnerAttestation(attestationFilePath) {
50647
50795
  let raw;
50648
50796
  if (attestationFilePath) {
50649
50797
  try {
50650
- raw = await readFile4(attestationFilePath, "utf-8");
50798
+ raw = await readFile3(attestationFilePath, "utf-8");
50651
50799
  } catch (err) {
50652
50800
  const message = err instanceof Error ? err.message : String(err);
50653
50801
  throw new Error(`Failed to read attestation file "${attestationFilePath}": ${message}`);
@@ -50674,10 +50822,10 @@ async function loadOwnerAttestation(attestationFilePath) {
50674
50822
  }
50675
50823
  return obj;
50676
50824
  }
50677
- async function loadOwnerPubkeys2(projectRoot) {
50678
- const path5 = join18(projectRoot, OWNER_PUBKEYS_FILE);
50825
+ async function loadOwnerPubkeys(projectRoot) {
50826
+ const path5 = join17(projectRoot, OWNER_PUBKEYS_FILE);
50679
50827
  try {
50680
- const raw = await readFile4(path5, "utf-8");
50828
+ const raw = await readFile3(path5, "utf-8");
50681
50829
  const parsed = JSON.parse(raw);
50682
50830
  if (Array.isArray(parsed)) {
50683
50831
  return new Set(parsed.filter((k) => typeof k === "string"));
@@ -50754,11 +50902,11 @@ var init_revert = __esm({
50754
50902
  jsonMode
50755
50903
  );
50756
50904
  }
50757
- const allowedPubkeys = await loadOwnerPubkeys2(projectRoot);
50905
+ const allowedPubkeys = await loadOwnerPubkeys(projectRoot);
50758
50906
  if (attestation && allowedPubkeys.size > 0 && !allowedPubkeys.has(attestation.ownerPubkey)) {
50759
50907
  emitFailure2(
50760
50908
  E_OWNER_ATTESTATION_REQUIRED,
50761
- `Attestation pubkey "${attestation.ownerPubkey}" is not in the owner allowlist at ${join18(projectRoot, OWNER_PUBKEYS_FILE)}`,
50909
+ `Attestation pubkey "${attestation.ownerPubkey}" is not in the owner allowlist at ${join17(projectRoot, OWNER_PUBKEYS_FILE)}`,
50762
50910
  jsonMode
50763
50911
  );
50764
50912
  }
@@ -50811,7 +50959,7 @@ ${lines}`
50811
50959
  identity,
50812
50960
  includeHuman
50813
50961
  });
50814
- const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
50962
+ const statePath = join17(projectRoot, SENTIENT_STATE_FILE);
50815
50963
  const state = await readSentientState(statePath);
50816
50964
  emitSuccess(
50817
50965
  {
@@ -51045,8 +51193,8 @@ __export(self_update_exports, {
51045
51193
  selfUpdateCommand: () => selfUpdateCommand
51046
51194
  });
51047
51195
  import { execFile } from "node:child_process";
51048
- import { readFile as readFile5 } from "node:fs/promises";
51049
- import { join as join19 } from "node:path";
51196
+ import { readFile as readFile4 } from "node:fs/promises";
51197
+ import { join as join18 } from "node:path";
51050
51198
  import * as readline2 from "node:readline";
51051
51199
  import { promisify } from "node:util";
51052
51200
  import {
@@ -51061,7 +51209,7 @@ import {
51061
51209
  async function getCurrentVersion() {
51062
51210
  const cleoHome = getCleoHome();
51063
51211
  try {
51064
- const content = await readFile5(join19(cleoHome, "VERSION"), "utf-8");
51212
+ const content = await readFile4(join18(cleoHome, "VERSION"), "utf-8");
51065
51213
  return (content.split("\n")[0] ?? "unknown").trim();
51066
51214
  } catch {
51067
51215
  return "unknown";
@@ -51114,8 +51262,8 @@ async function writeRuntimeVersionMetadata(mode, source, version) {
51114
51262
  `installed=${(/* @__PURE__ */ new Date()).toISOString()}`
51115
51263
  ];
51116
51264
  await import("node:fs/promises").then(
51117
- ({ writeFile: writeFile3, mkdir: mkdir4 }) => mkdir4(cleoHome, { recursive: true }).then(
51118
- () => writeFile3(join19(cleoHome, "VERSION"), `${lines.join("\n")}
51265
+ ({ writeFile: writeFile3, mkdir: mkdir3 }) => mkdir3(cleoHome, { recursive: true }).then(
51266
+ () => writeFile3(join18(cleoHome, "VERSION"), `${lines.join("\n")}
51119
51267
  `, "utf-8")
51120
51268
  )
51121
51269
  );
@@ -51526,7 +51674,7 @@ var sentient_exports = {};
51526
51674
  __export(sentient_exports, {
51527
51675
  sentientCommand: () => sentientCommand
51528
51676
  });
51529
- import { join as join20 } from "node:path";
51677
+ import { join as join19 } from "node:path";
51530
51678
  import { cwd as processCwd2 } from "node:process";
51531
51679
  import {
51532
51680
  getSentientDaemonStatus as getSentientDaemonStatus2,
@@ -51592,7 +51740,7 @@ var init_sentient3 = __esm({
51592
51740
  return;
51593
51741
  }
51594
51742
  if (dryRun) {
51595
- const statePath2 = join20(projectRoot, SENTIENT_STATE_FILE2);
51743
+ const statePath2 = join19(projectRoot, SENTIENT_STATE_FILE2);
51596
51744
  const outcome = await safeRunTick({ projectRoot, statePath: statePath2, dryRun: true });
51597
51745
  emitSuccess2(
51598
51746
  { dryRun: true, outcome },
@@ -51708,7 +51856,7 @@ Logs: ${logPath}`
51708
51856
  const jsonMode = args.json === true;
51709
51857
  const dryRun = args["dry-run"] === true;
51710
51858
  try {
51711
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
51859
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51712
51860
  const outcome = await safeRunTick({ projectRoot, statePath, dryRun });
51713
51861
  emitSuccess2(
51714
51862
  { outcome, dryRun },
@@ -51777,7 +51925,7 @@ Logs: ${logPath}`
51777
51925
  return;
51778
51926
  }
51779
51927
  await db.update(tasks).set({ status: "pending", updatedAt: now }).where(eq2(tasks.id, id)).run();
51780
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
51928
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51781
51929
  const state = await readSentientState2(statePath);
51782
51930
  await patchSentientState(statePath, {
51783
51931
  tier2Stats: {
@@ -51829,7 +51977,7 @@ Logs: ${logPath}`
51829
51977
  return;
51830
51978
  }
51831
51979
  await db.update(tasks).set({ status: "cancelled", cancellationReason: reason, cancelledAt: now, updatedAt: now }).where(eq2(tasks.id, id)).run();
51832
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
51980
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51833
51981
  const state = await readSentientState2(statePath);
51834
51982
  await patchSentientState(statePath, {
51835
51983
  tier2Stats: {
@@ -51874,7 +52022,7 @@ Logs: ${logPath}`
51874
52022
  const projectRoot = resolveProjectRoot5(args.project);
51875
52023
  const jsonMode = args.json === true;
51876
52024
  try {
51877
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
52025
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51878
52026
  const outcome = await safeRunProposeTick({ projectRoot, statePath });
51879
52027
  emitSuccess2(
51880
52028
  { outcome },
@@ -51894,7 +52042,7 @@ Logs: ${logPath}`
51894
52042
  const projectRoot = resolveProjectRoot5(args.project);
51895
52043
  const jsonMode = args.json === true;
51896
52044
  try {
51897
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
52045
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51898
52046
  const updated = await patchSentientState(statePath, { tier2Enabled: true });
51899
52047
  emitSuccess2({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals enabled");
51900
52048
  } catch (err) {
@@ -51913,7 +52061,7 @@ Logs: ${logPath}`
51913
52061
  const projectRoot = resolveProjectRoot5(args.project);
51914
52062
  const jsonMode = args.json === true;
51915
52063
  try {
51916
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
52064
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51917
52065
  const updated = await patchSentientState(statePath, { tier2Enabled: false });
51918
52066
  emitSuccess2({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals disabled");
51919
52067
  } catch (err) {
@@ -51944,7 +52092,7 @@ Logs: ${logPath}`
51944
52092
  const projectRoot = resolveProjectRoot5(args.project);
51945
52093
  const jsonMode = args.json === true;
51946
52094
  try {
51947
- const statePath = join20(projectRoot, SENTIENT_STATE_FILE2);
52095
+ const statePath = join19(projectRoot, SENTIENT_STATE_FILE2);
51948
52096
  const state = await readSentientState2(statePath);
51949
52097
  emitSuccess2(
51950
52098
  {
@@ -53264,8 +53412,8 @@ var init_snapshot = __esm({
53264
53412
  handleRawError(response, { command: "snapshot", operation: "admin.export" });
53265
53413
  const data = response.data;
53266
53414
  if (data?.outputPath) {
53267
- const { readFile: readFile7 } = await import("node:fs/promises");
53268
- const content = await readFile7(data.outputPath, "utf-8");
53415
+ const { readFile: readFile6 } = await import("node:fs/promises");
53416
+ const content = await readFile6(data.outputPath, "utf-8");
53269
53417
  process.stdout.write(content);
53270
53418
  if (!content.endsWith("\n")) process.stdout.write("\n");
53271
53419
  }
@@ -54242,7 +54390,7 @@ __export(transcript_exports, {
54242
54390
  transcriptCommand: () => transcriptCommand
54243
54391
  });
54244
54392
  import { homedir as homedir6 } from "node:os";
54245
- import { join as join21 } from "node:path";
54393
+ import { join as join20 } from "node:path";
54246
54394
  import { getProjectRoot as getProjectRoot32 } from "@cleocode/core";
54247
54395
  import {
54248
54396
  parseDurationMs,
@@ -54296,7 +54444,7 @@ var init_transcript = __esm({
54296
54444
  }
54297
54445
  return;
54298
54446
  }
54299
- const projectsDir = args["projects-dir"] ?? join21(homedir6(), ".claude", "projects");
54447
+ const projectsDir = args["projects-dir"] ?? join20(homedir6(), ".claude", "projects");
54300
54448
  try {
54301
54449
  const result = await scanTranscripts(projectsDir);
54302
54450
  cliOutput(
@@ -54602,7 +54750,7 @@ var init_transcript = __esm({
54602
54750
  process.exit(2);
54603
54751
  return;
54604
54752
  }
54605
- const projectsDir = args["projects-dir"] ?? join21(homedir6(), ".claude", "projects");
54753
+ const projectsDir = args["projects-dir"] ?? join20(homedir6(), ".claude", "projects");
54606
54754
  try {
54607
54755
  const pruneResult = await pruneTranscripts({
54608
54756
  olderThanMs,
@@ -54661,6 +54809,7 @@ var update_exports = {};
54661
54809
  __export(update_exports, {
54662
54810
  updateCommand: () => updateCommand2
54663
54811
  });
54812
+ import { appendSignedSeverityAttestation as appendSignedSeverityAttestation3 } from "@cleocode/core";
54664
54813
  var updateCommand2;
54665
54814
  var init_update = __esm({
54666
54815
  "packages/cleo/src/cli/commands/update.ts"() {
@@ -54692,7 +54841,7 @@ var init_update = __esm({
54692
54841
  },
54693
54842
  type: {
54694
54843
  type: "string",
54695
- description: "New type (task|epic|subtask|bug)",
54844
+ description: "New type (task|epic|subtask)",
54696
54845
  alias: "t"
54697
54846
  },
54698
54847
  size: {
@@ -54772,21 +54921,14 @@ var init_update = __esm({
54772
54921
  description: "Set pipeline stage (forward-only: research|consensus|architecture_decision|specification|decomposition|implementation|validation|testing|release|contribution)"
54773
54922
  },
54774
54923
  /**
54775
- * Task role axis — intent of work.
54924
+ * Task kind axis — intent of work.
54776
54925
  * Values: work | research | experiment | bug | spike | release
54777
54926
  * @task T944
54778
- */
54779
- role: {
54780
- type: "string",
54781
- description: "Task role / intent axis (work|research|experiment|bug|spike|release) \u2014 orthogonal to --type (T944)"
54782
- },
54783
- /**
54784
- * Backward-compatible alias for --role (fractal-ontology spec used "kind").
54785
- * @task T1472
54927
+ * @task T9072
54786
54928
  */
54787
54929
  kind: {
54788
54930
  type: "string",
54789
- description: "Alias for --role (T944 fractal-ontology compat)"
54931
+ description: "Task kind / intent axis (work|research|experiment|bug|spike|release) \u2014 orthogonal to --type (T944)"
54790
54932
  },
54791
54933
  /**
54792
54934
  * Task scope axis — granularity of work.
@@ -54797,6 +54939,17 @@ var init_update = __esm({
54797
54939
  type: "string",
54798
54940
  description: "Task scope / granularity axis (project|feature|unit) \u2014 orthogonal to --type (T944)"
54799
54941
  },
54942
+ /**
54943
+ * Severity level — valid for any role (not just bug).
54944
+ * Values: P0 | P1 | P2 | P3
54945
+ * Orthogonal to --priority — does NOT auto-map priority.
54946
+ * Appends a signed attestation to .cleo/audit/severity-attestation.jsonl (T9071/T9073).
54947
+ * @task T9073
54948
+ */
54949
+ severity: {
54950
+ type: "string",
54951
+ description: "Severity level (P0|P1|P2|P3) \u2014 valid for any --role (T9073). Orthogonal to priority. Appends signed attestation."
54952
+ },
54800
54953
  /**
54801
54954
  * Operator-supplied justification required to override the
54802
54955
  * acceptance-criteria immutability guard once a task has entered the
@@ -54858,9 +55011,9 @@ var init_update = __esm({
54858
55011
  if (args["parent-id"] !== void 0) params["parent"] = params["parent"] ?? args["parent-id"];
54859
55012
  if (args["no-auto-complete"] === true) params["noAutoComplete"] = true;
54860
55013
  if (args["pipeline-stage"] !== void 0) params["pipelineStage"] = args["pipeline-stage"];
54861
- if (args.role !== void 0) params["role"] = args.role;
54862
- if (args.kind !== void 0) params["role"] = params["role"] ?? args.kind;
55014
+ if (args.kind !== void 0) params["kind"] = args.kind;
54863
55015
  if (args.scope !== void 0) params["scope"] = args.scope;
55016
+ if (args.severity !== void 0) params["severity"] = args.severity;
54864
55017
  if (args.reason !== void 0) params["reason"] = args.reason;
54865
55018
  if (args.priority === "critical" && !args.depends && !args["add-depends"] && args["depends-waiver"] === void 0) {
54866
55019
  const showResponse = await dispatchRaw("query", "tasks", "show", {
@@ -54884,6 +55037,23 @@ var init_update = __esm({
54884
55037
  }
54885
55038
  }
54886
55039
  if (args["depends-waiver"] !== void 0) params["dependsWaiver"] = args["depends-waiver"];
55040
+ if (args.severity !== void 0) {
55041
+ try {
55042
+ await appendSignedSeverityAttestation3({
55043
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
55044
+ title: String(args.taskId),
55045
+ severity: args.severity,
55046
+ taskId: String(args.taskId)
55047
+ });
55048
+ } catch (err) {
55049
+ const code = err.code;
55050
+ if (code === "E_OWNER_ONLY") {
55051
+ cliError(err.message, 72, { name: "E_OWNER_ONLY" });
55052
+ process.exit(72);
55053
+ return;
55054
+ }
55055
+ }
55056
+ }
54887
55057
  await dispatchFromCli("mutate", "tasks", "update", params, { command: "update" });
54888
55058
  }
54889
55059
  });
@@ -55122,16 +55292,16 @@ __export(web_exports, {
55122
55292
  webCommand: () => webCommand
55123
55293
  });
55124
55294
  import { execFileSync as execFileSync4, spawn } from "node:child_process";
55125
- import { mkdir as mkdir3, open, readFile as readFile6, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
55126
- import { join as join22 } from "node:path";
55295
+ import { mkdir as mkdir2, open, readFile as readFile5, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
55296
+ import { join as join21 } from "node:path";
55127
55297
  import { CleoError as CleoError12, formatError as formatError9, getCleoHome as getCleoHome2 } from "@cleocode/core";
55128
55298
  function getWebPaths() {
55129
55299
  const cleoHome = getCleoHome2();
55130
55300
  return {
55131
- pidFile: join22(cleoHome, "web-server.pid"),
55132
- configFile: join22(cleoHome, "web-server.json"),
55133
- logDir: join22(cleoHome, "logs"),
55134
- logFile: join22(cleoHome, "logs", "web-server.log")
55301
+ pidFile: join21(cleoHome, "web-server.pid"),
55302
+ configFile: join21(cleoHome, "web-server.json"),
55303
+ logDir: join21(cleoHome, "logs"),
55304
+ logFile: join21(cleoHome, "logs", "web-server.log")
55135
55305
  };
55136
55306
  }
55137
55307
  function isProcessRunning(pid) {
@@ -55145,7 +55315,7 @@ function isProcessRunning(pid) {
55145
55315
  async function getStatus() {
55146
55316
  const { pidFile, configFile } = getWebPaths();
55147
55317
  try {
55148
- const pidStr = (await readFile6(pidFile, "utf-8")).trim();
55318
+ const pidStr = (await readFile5(pidFile, "utf-8")).trim();
55149
55319
  const pid = Number.parseInt(pidStr, 10);
55150
55320
  if (Number.isNaN(pid) || !isProcessRunning(pid)) {
55151
55321
  return { running: false, pid: null, port: null, host: null, url: null };
@@ -55153,7 +55323,7 @@ async function getStatus() {
55153
55323
  let port = DEFAULT_PORT;
55154
55324
  let host = DEFAULT_HOST;
55155
55325
  try {
55156
- const config = JSON.parse(await readFile6(configFile, "utf-8"));
55326
+ const config = JSON.parse(await readFile5(configFile, "utf-8"));
55157
55327
  port = config.port ?? DEFAULT_PORT;
55158
55328
  host = config.host ?? DEFAULT_HOST;
55159
55329
  } catch {
@@ -55170,8 +55340,8 @@ async function startWebServer(port, host) {
55170
55340
  throw new CleoError12(1 /* GENERAL_ERROR */, `Server already running (PID: ${status.pid})`);
55171
55341
  }
55172
55342
  const projectRoot = process.env["CLEO_ROOT"] ?? process.cwd();
55173
- const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join22(projectRoot, "packages", "studio", "build");
55174
- await mkdir3(logDir, { recursive: true });
55343
+ const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join21(projectRoot, "packages", "studio", "build");
55344
+ await mkdir2(logDir, { recursive: true });
55175
55345
  await writeFile2(
55176
55346
  configFile,
55177
55347
  JSON.stringify({
@@ -55180,7 +55350,7 @@ async function startWebServer(port, host) {
55180
55350
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
55181
55351
  })
55182
55352
  );
55183
- const webIndexPath = join22(studioDir, "index.js");
55353
+ const webIndexPath = join21(studioDir, "index.js");
55184
55354
  try {
55185
55355
  await stat(webIndexPath);
55186
55356
  } catch {
@@ -55452,7 +55622,7 @@ init_dist();
55452
55622
  init_field_context();
55453
55623
  init_format_context();
55454
55624
  import { readFileSync as readFileSync15 } from "node:fs";
55455
- import { dirname as dirname9, join as join23 } from "node:path";
55625
+ import { dirname as dirname8, join as join22 } from "node:path";
55456
55626
  import { fileURLToPath as fileURLToPath5 } from "node:url";
55457
55627
 
55458
55628
  // packages/cleo/src/cli/generated/command-manifest.ts
@@ -56511,7 +56681,7 @@ Or via NodeSource: https://github.com/nodesource/distributions
56511
56681
  }
56512
56682
  }
56513
56683
  function getPackageVersion() {
56514
- const pkgPath = join23(dirname9(fileURLToPath5(import.meta.url)), "../../package.json");
56684
+ const pkgPath = join22(dirname8(fileURLToPath5(import.meta.url)), "../../package.json");
56515
56685
  const pkg = JSON.parse(readFileSync15(pkgPath, "utf-8"));
56516
56686
  return pkg.version;
56517
56687
  }