@cleocode/cleo 2026.4.148 → 2026.4.150

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
@@ -9296,7 +9296,7 @@ async function lifecycleStatus(epicId, projectRoot) {
9296
9296
  return engineError("E_INVALID_INPUT", "epicId is required");
9297
9297
  }
9298
9298
  try {
9299
- const data = await getLifecycleStatus(epicId, projectRoot);
9299
+ const data = await getLifecycleStatus(projectRoot, { epicId });
9300
9300
  return engineSuccess(data);
9301
9301
  } catch (err) {
9302
9302
  if (err instanceof Error) {
@@ -9307,7 +9307,7 @@ async function lifecycleStatus(epicId, projectRoot) {
9307
9307
  }
9308
9308
  async function lifecycleHistory(taskId, projectRoot) {
9309
9309
  try {
9310
- const data = await getLifecycleHistory(taskId, projectRoot);
9310
+ const data = await getLifecycleHistory(projectRoot ?? process.cwd(), { taskId });
9311
9311
  return engineSuccess(data);
9312
9312
  } catch (err) {
9313
9313
  if (err instanceof Error) {
@@ -9318,7 +9318,7 @@ async function lifecycleHistory(taskId, projectRoot) {
9318
9318
  }
9319
9319
  async function lifecycleGates(taskId, projectRoot) {
9320
9320
  try {
9321
- const data = await getLifecycleGates(taskId, projectRoot);
9321
+ const data = await getLifecycleGates(projectRoot ?? process.cwd(), { taskId });
9322
9322
  return engineSuccess(data);
9323
9323
  } catch (err) {
9324
9324
  if (err instanceof Error) {
@@ -9346,7 +9346,10 @@ async function lifecycleCheck(epicId, targetStage, projectRoot) {
9346
9346
  return engineError("E_INVALID_INPUT", "epicId and targetStage are required");
9347
9347
  }
9348
9348
  try {
9349
- const data = await checkStagePrerequisites(epicId, targetStage, projectRoot);
9349
+ const data = await checkStagePrerequisites(projectRoot ?? process.cwd(), {
9350
+ epicId,
9351
+ targetStage
9352
+ });
9350
9353
  return engineSuccess(data);
9351
9354
  } catch (err) {
9352
9355
  if (err instanceof Error) {
@@ -9365,7 +9368,7 @@ async function lifecycleProgress(taskId, stage, status, notes, projectRoot) {
9365
9368
  try {
9366
9369
  if (status === "in_progress" || status === "completed") {
9367
9370
  const { getLifecycleStatus: getLifecycleStatus4 } = await import("@cleocode/core/internal");
9368
- const current = await getLifecycleStatus4(taskId, projectRoot);
9371
+ const current = await getLifecycleStatus4(projectRoot ?? process.cwd(), { taskId });
9369
9372
  if (current.currentStage) {
9370
9373
  const { isPipelineTransitionForward, getPipelineStageOrder } = await import("@cleocode/core/internal");
9371
9374
  if (!isPipelineTransitionForward(current.currentStage, stage)) {
@@ -9382,7 +9385,12 @@ async function lifecycleProgress(taskId, stage, status, notes, projectRoot) {
9382
9385
  return engineError("E_LIFECYCLE_GATE_FAILED", gateResult.message);
9383
9386
  }
9384
9387
  }
9385
- const data = await recordStageProgress(taskId, stage, status, notes, projectRoot);
9388
+ const data = await recordStageProgress(projectRoot ?? process.cwd(), {
9389
+ taskId,
9390
+ stage,
9391
+ status,
9392
+ notes
9393
+ });
9386
9394
  return engineSuccess({ ...data, recorded: true });
9387
9395
  } catch (err) {
9388
9396
  if (err instanceof Error) {
@@ -9398,7 +9406,11 @@ async function lifecycleSkip(taskId, stage, reason, projectRoot) {
9398
9406
  const scopeDenied = await enforceScopeForLifecycleMutation(taskId, projectRoot);
9399
9407
  if (scopeDenied) return scopeDenied;
9400
9408
  try {
9401
- const data = await skipStageWithReason(taskId, stage, reason, projectRoot);
9409
+ const data = await skipStageWithReason(projectRoot ?? process.cwd(), {
9410
+ taskId,
9411
+ stage,
9412
+ reason
9413
+ });
9402
9414
  return engineSuccess({ ...data, skipped: true });
9403
9415
  } catch (err) {
9404
9416
  if (err instanceof Error) {
@@ -9414,7 +9426,11 @@ async function lifecycleReset(taskId, stage, reason, projectRoot) {
9414
9426
  const scopeDenied = await enforceScopeForLifecycleMutation(taskId, projectRoot);
9415
9427
  if (scopeDenied) return scopeDenied;
9416
9428
  try {
9417
- const data = await resetStage(taskId, stage, reason, projectRoot);
9429
+ const data = await resetStage(projectRoot ?? process.cwd(), {
9430
+ taskId,
9431
+ stage,
9432
+ reason
9433
+ });
9418
9434
  return engineSuccess({ ...data, reset: "pending" });
9419
9435
  } catch (err) {
9420
9436
  if (err instanceof Error) {
@@ -9428,7 +9444,12 @@ async function lifecycleGatePass(taskId, gateName, agent, notes, projectRoot) {
9428
9444
  return engineError("E_INVALID_INPUT", "taskId and gateName are required");
9429
9445
  }
9430
9446
  try {
9431
- const data = await passGate(taskId, gateName, agent, notes, projectRoot);
9447
+ const data = await passGate(projectRoot ?? process.cwd(), {
9448
+ taskId,
9449
+ gateName,
9450
+ agent: agent ?? "system",
9451
+ notes
9452
+ });
9432
9453
  return engineSuccess({ ...data, status: "passed" });
9433
9454
  } catch (err) {
9434
9455
  if (err instanceof Error) {
@@ -9442,7 +9463,11 @@ async function lifecycleGateFail(taskId, gateName, reason, projectRoot) {
9442
9463
  return engineError("E_INVALID_INPUT", "taskId and gateName are required");
9443
9464
  }
9444
9465
  try {
9445
- const data = await failGate(taskId, gateName, reason, projectRoot);
9466
+ const data = await failGate(projectRoot ?? process.cwd(), {
9467
+ taskId,
9468
+ gateName,
9469
+ reason: reason ?? ""
9470
+ });
9446
9471
  return engineSuccess({ ...data, status: "failed" });
9447
9472
  } catch (err) {
9448
9473
  if (err instanceof Error) {
@@ -9610,8 +9635,7 @@ async function sessionList(projectRoot, params) {
9610
9635
  }
9611
9636
  async function sessionFind(projectRoot, params) {
9612
9637
  try {
9613
- const accessor = await getAccessor(projectRoot);
9614
- const result = await findSessions(accessor, params);
9638
+ const result = await findSessions(projectRoot, params);
9615
9639
  return { success: true, data: result };
9616
9640
  } catch {
9617
9641
  return engineError("E_NOT_INITIALIZED", "Task database not initialized");
@@ -9619,7 +9643,7 @@ async function sessionFind(projectRoot, params) {
9619
9643
  }
9620
9644
  async function sessionShow(projectRoot, sessionId) {
9621
9645
  try {
9622
- const result = await showSession(projectRoot, sessionId);
9646
+ const result = await showSession(projectRoot, { sessionId });
9623
9647
  return { success: true, data: result };
9624
9648
  } catch (err) {
9625
9649
  return cleoErrorToEngineError(err, "E_NOT_INITIALIZED", "Session not initialized");
@@ -10014,7 +10038,7 @@ async function sessionGc(projectRoot, maxAgeDays = 1) {
10014
10038
  }
10015
10039
  async function sessionSuspend(projectRoot, sessionId, reason) {
10016
10040
  try {
10017
- const result = await suspendSession(projectRoot, sessionId, reason);
10041
+ const result = await suspendSession(projectRoot, { sessionId, reason });
10018
10042
  return { success: true, data: result };
10019
10043
  } catch (err) {
10020
10044
  return cleoErrorToEngineError(err, "E_NOT_INITIALIZED", "Failed to end session");
@@ -10055,7 +10079,7 @@ async function sessionRecordDecision(projectRoot, params) {
10055
10079
  }
10056
10080
  async function sessionDecisionLog(projectRoot, params) {
10057
10081
  try {
10058
- const result = await getDecisionLog(projectRoot, params);
10082
+ const result = await getDecisionLog(projectRoot, params ?? {});
10059
10083
  return { success: true, data: result };
10060
10084
  } catch {
10061
10085
  return { success: true, data: [] };
@@ -10063,7 +10087,7 @@ async function sessionDecisionLog(projectRoot, params) {
10063
10087
  }
10064
10088
  async function sessionContextDrift(projectRoot, params) {
10065
10089
  try {
10066
- const result = await getContextDrift(projectRoot, params);
10090
+ const result = await getContextDrift(projectRoot, params ?? {});
10067
10091
  return { success: true, data: result };
10068
10092
  } catch (err) {
10069
10093
  return cleoErrorToEngineError(err, "E_NOT_INITIALIZED", "Failed to read decision log");
@@ -10890,11 +10914,11 @@ async function orchestrateStartup(epicId, projectRoot) {
10890
10914
  const children = tasks.filter((t) => t.parentId === epicId);
10891
10915
  const readyTasks = await getReadyTasks(epicId, root, accessor);
10892
10916
  const ready = readyTasks.filter((t) => t.ready);
10893
- const lifecycleStatus2 = await getLifecycleStatus2(epicId, root);
10917
+ const lifecycleStatus2 = await getLifecycleStatus2(root, { epicId });
10894
10918
  let autoInitialized = false;
10895
10919
  let currentStage;
10896
10920
  if (!lifecycleStatus2.initialized) {
10897
- await recordStageProgress2(epicId, "research", "in_progress", void 0, root);
10921
+ await recordStageProgress2(root, { taskId: epicId, stage: "research", status: "in_progress" });
10898
10922
  autoInitialized = true;
10899
10923
  currentStage = "research";
10900
10924
  } else {
@@ -12748,9 +12772,9 @@ async function systemLog(projectRoot, filters) {
12748
12772
  }
12749
12773
  async function queryAuditLogSqlite(projectRoot, filters) {
12750
12774
  try {
12751
- const { join: join23 } = await import("node:path");
12775
+ const { join: join22 } = await import("node:path");
12752
12776
  const { existsSync: existsSync12 } = await import("node:fs");
12753
- const dbPath = join23(projectRoot, CLEO_DIR_NAME, TASKS_DB_FILENAME);
12777
+ const dbPath = join22(projectRoot, CLEO_DIR_NAME, TASKS_DB_FILENAME);
12754
12778
  if (!existsSync12(dbPath)) {
12755
12779
  const offset = filters?.offset ?? 0;
12756
12780
  const limit = filters?.limit ?? 20;
@@ -13727,7 +13751,7 @@ async function taskShowWithHistory(projectRoot, taskId, includeHistory) {
13727
13751
  }
13728
13752
  let history = [];
13729
13753
  try {
13730
- const status = await getLifecycleStatus3(taskId, projectRoot);
13754
+ const status = await getLifecycleStatus3(projectRoot ?? process.cwd(), { taskId });
13731
13755
  history = status.stages.map(
13732
13756
  (s) => ({
13733
13757
  stage: s.stage,
@@ -13984,12 +14008,12 @@ async function taskCompleteStrict(projectRoot, taskId, notes) {
13984
14008
  const accessor = await getAccessor6(projectRoot);
13985
14009
  const task = await accessor.loadSingleTask(taskId);
13986
14010
  if (task?.verification?.evidence) {
13987
- const { revalidateEvidence: revalidateEvidence2 } = await import("@cleocode/core/internal");
14011
+ const { revalidateEvidence } = await import("@cleocode/core/internal");
13988
14012
  const evidenceEntries = Object.entries(task.verification.evidence);
13989
14013
  const staleGates = [];
13990
14014
  for (const [gate, ev] of evidenceEntries) {
13991
14015
  if (!ev) continue;
13992
- const check = await revalidateEvidence2(ev, projectRoot);
14016
+ const check = await revalidateEvidence(ev, projectRoot);
13993
14017
  if (!check.stillValid) {
13994
14018
  staleGates.push({
13995
14019
  gate,
@@ -16176,20 +16200,11 @@ var init_admin = __esm({
16176
16200
  "adr.find": async (params) => {
16177
16201
  const projectRoot = getProjectRoot2();
16178
16202
  if (params.query) {
16179
- const result2 = await findAdrs(projectRoot, params.query, {
16180
- topics: params.topics,
16181
- keywords: params.keywords,
16182
- status: params.status
16183
- });
16203
+ const result2 = await findAdrs(projectRoot, params);
16184
16204
  return lafsSuccess(result2, "adr.find");
16185
16205
  }
16186
16206
  const { limit, offset } = getListParams({ limit: params.limit, offset: params.offset });
16187
- const result = await listAdrs(projectRoot, {
16188
- status: params.status,
16189
- since: params.since,
16190
- limit,
16191
- offset
16192
- });
16207
+ const result = await listAdrs(projectRoot, { ...params, limit, offset });
16193
16208
  return lafsSuccess(
16194
16209
  {
16195
16210
  ...result,
@@ -16200,7 +16215,7 @@ var init_admin = __esm({
16200
16215
  },
16201
16216
  "adr.show": async (params) => {
16202
16217
  const projectRoot = getProjectRoot2();
16203
- const adr = await showAdr(projectRoot, params.adrId);
16218
+ const adr = await showAdr(projectRoot, params);
16204
16219
  if (!adr) {
16205
16220
  return lafsError("E_NOT_FOUND", `ADR not found: ${params.adrId}`, "adr.show");
16206
16221
  }
@@ -16214,7 +16229,7 @@ var init_admin = __esm({
16214
16229
  if (!tokenId) {
16215
16230
  return lafsError("E_INVALID_INPUT", "tokenId is required", "token");
16216
16231
  }
16217
- const result2 = await showTokenUsage(tokenId, projectRoot);
16232
+ const result2 = await showTokenUsage(projectRoot, { id: tokenId });
16218
16233
  if (!result2) {
16219
16234
  return lafsError("E_NOT_FOUND", `Token usage record not found: ${tokenId}`, "token");
16220
16235
  }
@@ -16222,36 +16237,7 @@ var init_admin = __esm({
16222
16237
  }
16223
16238
  if (action === "list") {
16224
16239
  const { limit, offset } = getListParams({ limit: params.limit, offset: params.offset });
16225
- const result2 = await listTokenUsage(
16226
- {
16227
- provider: params.provider,
16228
- transport: params.transport,
16229
- gateway: params.gateway,
16230
- domain: params.domain,
16231
- operation: params.operationName,
16232
- sessionId: params.sessionId,
16233
- taskId: params.taskId,
16234
- method: params.method,
16235
- confidence: params.confidence,
16236
- requestId: params.requestId,
16237
- since: params.since,
16238
- until: params.until,
16239
- limit,
16240
- offset
16241
- },
16242
- projectRoot
16243
- );
16244
- return lafsSuccess(
16245
- {
16246
- records: result2.records,
16247
- total: result2.total,
16248
- filtered: result2.filtered
16249
- },
16250
- "token"
16251
- );
16252
- }
16253
- const result = await summarizeTokenUsage(
16254
- {
16240
+ const result2 = await listTokenUsage(projectRoot, {
16255
16241
  provider: params.provider,
16256
16242
  transport: params.transport,
16257
16243
  gateway: params.gateway,
@@ -16263,10 +16249,33 @@ var init_admin = __esm({
16263
16249
  confidence: params.confidence,
16264
16250
  requestId: params.requestId,
16265
16251
  since: params.since,
16266
- until: params.until
16267
- },
16268
- projectRoot
16269
- );
16252
+ until: params.until,
16253
+ limit,
16254
+ offset
16255
+ });
16256
+ return lafsSuccess(
16257
+ {
16258
+ records: result2.records,
16259
+ total: result2.total,
16260
+ filtered: result2.filtered
16261
+ },
16262
+ "token"
16263
+ );
16264
+ }
16265
+ const result = await summarizeTokenUsage(projectRoot, {
16266
+ provider: params.provider,
16267
+ transport: params.transport,
16268
+ gateway: params.gateway,
16269
+ domain: params.domain,
16270
+ operation: params.operationName,
16271
+ sessionId: params.sessionId,
16272
+ taskId: params.taskId,
16273
+ method: params.method,
16274
+ confidence: params.confidence,
16275
+ requestId: params.requestId,
16276
+ since: params.since,
16277
+ until: params.until
16278
+ });
16270
16279
  return lafsSuccess(result, "token");
16271
16280
  },
16272
16281
  backup: async (_params) => {
@@ -16299,25 +16308,10 @@ var init_admin = __esm({
16299
16308
  );
16300
16309
  }
16301
16310
  if (params.scope === "tasks") {
16302
- const result2 = await exportTasksPackage({
16303
- taskIds: params.taskIds,
16304
- output: params.output,
16305
- subtree: params.subtree,
16306
- filter: params.filter,
16307
- includeDeps: params.includeDeps,
16308
- dryRun: params.dryRun,
16309
- cwd: projectRoot
16310
- });
16311
+ const result2 = await exportTasksPackage(projectRoot, params);
16311
16312
  return lafsSuccess(result2, "export");
16312
16313
  }
16313
- const result = await exportTasks({
16314
- format: params.format,
16315
- output: params.output,
16316
- status: params.status,
16317
- parent: params.parent,
16318
- phase: params.phase,
16319
- cwd: projectRoot
16320
- });
16314
+ const result = await exportTasks(projectRoot, params);
16321
16315
  return lafsSuccess(result, "export");
16322
16316
  },
16323
16317
  map: async (params) => {
@@ -16640,30 +16634,10 @@ var init_admin = __esm({
16640
16634
  );
16641
16635
  }
16642
16636
  if (params.scope === "tasks") {
16643
- const result2 = await importTasksPackage({
16644
- file,
16645
- dryRun: params.dryRun,
16646
- parent: params.parent,
16647
- phase: params.phase,
16648
- addLabel: params.addLabel,
16649
- provenance: params.provenance,
16650
- resetStatus: params.resetStatus,
16651
- onConflict: params.onConflict,
16652
- onMissingDep: params.onMissingDep,
16653
- force: params.force,
16654
- cwd: projectRoot
16655
- });
16637
+ const result2 = await importTasksPackage(projectRoot, params);
16656
16638
  return lafsSuccess(result2, "import");
16657
16639
  }
16658
- const result = await importTasks({
16659
- file,
16660
- parent: params.parent,
16661
- phase: params.phase,
16662
- onDuplicate: params.onDuplicate,
16663
- addLabel: params.addLabel,
16664
- dryRun: params.dryRun,
16665
- cwd: projectRoot
16666
- });
16640
+ const result = await importTasks(projectRoot, params);
16667
16641
  return lafsSuccess(result, "import");
16668
16642
  },
16669
16643
  detect: async (_params) => {
@@ -16681,30 +16655,27 @@ var init_admin = __esm({
16681
16655
  if (!tokenId) {
16682
16656
  return lafsError("E_INVALID_INPUT", "tokenId is required", "token.mutate");
16683
16657
  }
16684
- const result2 = await deleteTokenUsage(tokenId, projectRoot);
16658
+ const result2 = await deleteTokenUsage(projectRoot, { id: tokenId });
16685
16659
  return lafsSuccess(result2, "token.mutate");
16686
16660
  }
16687
16661
  if (action === "clear") {
16688
- const result2 = await clearTokenUsage(
16689
- {
16690
- provider: params.provider,
16691
- transport: params.transport,
16692
- gateway: params.gateway,
16693
- domain: params.domain,
16694
- operation: params.operationName,
16695
- sessionId: params.sessionId,
16696
- taskId: params.taskId,
16697
- method: params.method,
16698
- confidence: params.confidence,
16699
- requestId: params.requestId,
16700
- since: params.since,
16701
- until: params.until
16702
- },
16703
- projectRoot
16704
- );
16662
+ const result2 = await clearTokenUsage(projectRoot, {
16663
+ provider: params.provider,
16664
+ transport: params.transport,
16665
+ gateway: params.gateway,
16666
+ domain: params.domain,
16667
+ operation: params.operationName,
16668
+ sessionId: params.sessionId,
16669
+ taskId: params.taskId,
16670
+ method: params.method,
16671
+ confidence: params.confidence,
16672
+ requestId: params.requestId,
16673
+ since: params.since,
16674
+ until: params.until
16675
+ });
16705
16676
  return lafsSuccess(result2, "token.mutate");
16706
16677
  }
16707
- const result = await recordTokenExchange({
16678
+ const result = await recordTokenExchange(projectRoot, {
16708
16679
  provider: params.provider,
16709
16680
  model: params.model,
16710
16681
  transport: params.transport,
@@ -16716,8 +16687,7 @@ var init_admin = __esm({
16716
16687
  requestId: params.requestId,
16717
16688
  requestPayload: params.requestPayload,
16718
16689
  responsePayload: params.responsePayload,
16719
- metadata: params.metadata,
16720
- cwd: projectRoot
16690
+ metadata: params.metadata
16721
16691
  });
16722
16692
  return lafsSuccess(result, "token.mutate");
16723
16693
  },
@@ -17079,12 +17049,26 @@ var init_canon = __esm({
17079
17049
 
17080
17050
  // packages/cleo/src/dispatch/domains/check.ts
17081
17051
  import {
17052
+ checkArchiveStats,
17053
+ checkCoherence,
17054
+ checkComplianceRecord,
17055
+ checkComplianceSummary,
17056
+ checkComplianceSync,
17057
+ checkGradeSession,
17058
+ checkReadGrades,
17059
+ checkRevalidateEvidence,
17060
+ checkTestCoverage,
17061
+ checkTestRun,
17062
+ checkTestStatus,
17063
+ checkValidateChain,
17064
+ checkValidateManifest,
17065
+ checkValidateOutput,
17066
+ checkValidateProtocol,
17067
+ checkValidateSchema,
17068
+ checkValidateTask,
17069
+ checkWorkflowCompliance,
17082
17070
  getLogger as getLogger6,
17083
- getProjectRoot as getProjectRoot3,
17084
- getWorkflowComplianceReport,
17085
- paginate as paginate3,
17086
- revalidateEvidence,
17087
- validateChain
17071
+ getProjectRoot as getProjectRoot3
17088
17072
  } from "@cleocode/core/internal";
17089
17073
  var _checkTypedHandler, CheckHandler;
17090
17074
  var init_check = __esm({
@@ -17103,135 +17087,105 @@ var init_check = __esm({
17103
17087
  if (!params.type) {
17104
17088
  return lafsError("E_INVALID_INPUT", "type is required", "schema");
17105
17089
  }
17106
- const result = await validateSchemaOp(params.type, params.data, projectRoot);
17107
- if (!result.success) {
17108
- return lafsError(
17109
- String(result.error?.code ?? "E_INTERNAL"),
17110
- result.error?.message ?? "Unknown error",
17111
- "schema"
17112
- );
17090
+ try {
17091
+ const result = await checkValidateSchema(projectRoot, params);
17092
+ return lafsSuccess(result, "schema");
17093
+ } catch (err) {
17094
+ const message = err instanceof Error ? err.message : String(err);
17095
+ const code = message.includes("not found") ? "E_NOT_FOUND" : message.includes("Unknown schema") ? "E_INVALID_TYPE" : message.includes("required") ? "E_INVALID_INPUT" : "E_VALIDATION_ERROR";
17096
+ return lafsError(code, message, "schema");
17113
17097
  }
17114
- return lafsSuccess(result.data ?? { valid: false, violations: [] }, "schema");
17115
17098
  },
17116
17099
  task: async (params) => {
17117
17100
  const projectRoot = getProjectRoot3();
17118
17101
  if (!params.taskId) {
17119
17102
  return lafsError("E_INVALID_INPUT", "taskId is required", "task");
17120
17103
  }
17121
- const result = await validateTask(params.taskId, projectRoot);
17122
- if (!result.success) {
17123
- return lafsError(
17124
- String(result.error?.code ?? "E_INTERNAL"),
17125
- result.error?.message ?? "Unknown error",
17126
- "task"
17127
- );
17104
+ try {
17105
+ const result = await checkValidateTask(projectRoot, params);
17106
+ return lafsSuccess(result, "task");
17107
+ } catch (err) {
17108
+ const message = err instanceof Error ? err.message : String(err);
17109
+ const code = message.includes("not found") ? "E_NOT_FOUND" : "E_INVALID_INPUT";
17110
+ return lafsError(code, message, "task");
17128
17111
  }
17129
- return lafsSuccess(
17130
- result.data ?? { taskId: params.taskId, valid: false, violations: [], checks: {} },
17131
- "task"
17132
- );
17133
17112
  },
17134
- manifest: async (_params) => {
17113
+ manifest: async (params) => {
17135
17114
  const projectRoot = getProjectRoot3();
17136
- const result = validateManifest(projectRoot);
17137
- if (!result.success) {
17115
+ try {
17116
+ const result = checkValidateManifest(projectRoot, params);
17117
+ return lafsSuccess(result, "manifest");
17118
+ } catch (err) {
17138
17119
  return lafsError(
17139
- String(result.error?.code ?? "E_INTERNAL"),
17140
- result.error?.message ?? "Unknown error",
17120
+ "E_FILE_ERROR",
17121
+ err instanceof Error ? err.message : String(err),
17141
17122
  "manifest"
17142
17123
  );
17143
17124
  }
17144
- return lafsSuccess(result.data ?? { valid: false, entry: {}, violations: [] }, "manifest");
17145
17125
  },
17146
17126
  output: async (params) => {
17147
17127
  const projectRoot = getProjectRoot3();
17148
17128
  if (!params.filePath) {
17149
17129
  return lafsError("E_INVALID_INPUT", "filePath is required", "output");
17150
17130
  }
17151
- const result = validateOutput(params.filePath, params.taskId, projectRoot);
17152
- if (!result.success) {
17153
- return lafsError(
17154
- String(result.error?.code ?? "E_INTERNAL"),
17155
- result.error?.message ?? "Unknown error",
17156
- "output"
17157
- );
17131
+ try {
17132
+ const result = checkValidateOutput(projectRoot, params);
17133
+ return lafsSuccess(result, "output");
17134
+ } catch (err) {
17135
+ const message = err instanceof Error ? err.message : String(err);
17136
+ const code = message.includes("not found") ? "E_NOT_FOUND" : "E_INVALID_INPUT";
17137
+ return lafsError(code, message, "output");
17158
17138
  }
17159
- return lafsSuccess(
17160
- result.data ?? { taskId: "", filePath: "", valid: false, checks: {}, violations: [] },
17161
- "output"
17162
- );
17163
17139
  },
17164
17140
  "compliance.summary": async (params) => {
17165
17141
  const projectRoot = getProjectRoot3();
17166
- if (params?.detail) {
17167
- const result2 = validateComplianceViolations(params.limit, projectRoot);
17168
- if (!result2.success) {
17169
- return lafsError(
17170
- String(result2.error?.code ?? "E_INTERNAL"),
17171
- result2.error?.message ?? "Unknown error",
17172
- "compliance.summary"
17173
- );
17174
- }
17175
- return lafsSuccess(result2.data ?? { violations: [], total: 0 }, "compliance.summary");
17176
- }
17177
- const result = validateComplianceSummary(projectRoot);
17178
- if (!result.success) {
17142
+ try {
17143
+ const summary = checkComplianceSummary(projectRoot, params);
17144
+ const enrichedData = {
17145
+ ...summary,
17146
+ view: params.type ?? "summary",
17147
+ ...params.taskId ? { taskId: params.taskId } : {},
17148
+ ...params.days ? { days: params.days } : {},
17149
+ ...params.global ? { global: params.global } : {}
17150
+ };
17151
+ return lafsSuccess(enrichedData, "compliance.summary");
17152
+ } catch (err) {
17179
17153
  return lafsError(
17180
- String(result.error?.code ?? "E_INTERNAL"),
17181
- result.error?.message ?? "Unknown error",
17154
+ "E_FILE_ERROR",
17155
+ err instanceof Error ? err.message : String(err),
17182
17156
  "compliance.summary"
17183
17157
  );
17184
17158
  }
17185
- const data = result.data ?? {};
17186
- const enrichedData = {
17187
- ...data,
17188
- view: params.type ?? "summary",
17189
- ...params.taskId ? { taskId: params.taskId } : {},
17190
- ...params.days ? { days: params.days } : {},
17191
- ...params.global ? { global: params.global } : {}
17192
- };
17193
- return lafsSuccess(enrichedData, "compliance.summary");
17194
17159
  },
17195
17160
  test: async (params) => {
17196
17161
  const projectRoot = getProjectRoot3();
17197
17162
  if (params?.format === "coverage") {
17198
- const result2 = validateTestCoverage(projectRoot);
17199
- if (!result2.success) {
17200
- return lafsError(
17201
- String(result2.error?.code ?? "E_INTERNAL"),
17202
- result2.error?.message ?? "Unknown error",
17203
- "test"
17204
- );
17163
+ try {
17164
+ const result = checkTestCoverage(projectRoot, {});
17165
+ return lafsSuccess(result, "test");
17166
+ } catch (err) {
17167
+ return lafsError("E_FILE_ERROR", err instanceof Error ? err.message : String(err), "test");
17205
17168
  }
17206
- return lafsSuccess(
17207
- result2.data ?? { lineCoverage: 0, branchCoverage: 0, functionCoverage: 0, threshold: 0 },
17208
- "test"
17209
- );
17210
17169
  }
17211
- const result = validateTestStatus(projectRoot);
17212
- if (!result.success) {
17213
- return lafsError(
17214
- String(result.error?.code ?? "E_INTERNAL"),
17215
- result.error?.message ?? "Unknown error",
17216
- "test"
17217
- );
17170
+ try {
17171
+ const result = checkTestStatus(projectRoot, params);
17172
+ return lafsSuccess(result, "test");
17173
+ } catch (err) {
17174
+ return lafsError("E_GENERAL", err instanceof Error ? err.message : String(err), "test");
17218
17175
  }
17219
- return lafsSuccess(
17220
- result.data ?? { total: 0, passed: 0, failed: 0, skipped: 0, passRate: 0 },
17221
- "test"
17222
- );
17223
17176
  },
17224
- coherence: async (_params) => {
17177
+ coherence: async (params) => {
17225
17178
  const projectRoot = getProjectRoot3();
17226
- const result = await validateCoherenceCheck(projectRoot);
17227
- if (!result.success) {
17179
+ try {
17180
+ const result = await checkCoherence(projectRoot, params);
17181
+ return lafsSuccess(result, "coherence");
17182
+ } catch (err) {
17228
17183
  return lafsError(
17229
- String(result.error?.code ?? "E_INTERNAL"),
17230
- result.error?.message ?? "Unknown error",
17184
+ "E_NOT_INITIALIZED",
17185
+ err instanceof Error ? err.message : String(err),
17231
17186
  "coherence"
17232
17187
  );
17233
17188
  }
17234
- return lafsSuccess(result.data ?? { passed: false, issues: [], warnings: [] }, "coherence");
17235
17189
  },
17236
17190
  protocol: async (params) => {
17237
17191
  const projectRoot = getProjectRoot3();
@@ -17462,15 +17416,14 @@ var init_check = __esm({
17462
17416
  "protocol"
17463
17417
  );
17464
17418
  }
17465
- const result = await validateProtocol(params.taskId, protocolType, projectRoot);
17466
- if (!result.success) {
17467
- return lafsError(
17468
- String(result.error?.code ?? "E_INTERNAL"),
17469
- result.error?.message ?? "Unknown error",
17470
- "protocol"
17471
- );
17419
+ try {
17420
+ const result = await checkValidateProtocol(projectRoot, params);
17421
+ return lafsSuccess(result, "protocol");
17422
+ } catch (err) {
17423
+ const message = err instanceof Error ? err.message : String(err);
17424
+ const code = message.includes("not found") ? "E_NOT_FOUND" : "E_INVALID_INPUT";
17425
+ return lafsError(code, message, "protocol");
17472
17426
  }
17473
- return lafsSuccess(result.data ?? { taskId: "", protocol: "", passed: false }, "protocol");
17474
17427
  }
17475
17428
  }
17476
17429
  },
@@ -17549,15 +17502,14 @@ var init_check = __esm({
17549
17502
  let stillValid = true;
17550
17503
  let failedAtoms = [];
17551
17504
  try {
17552
- const reval = await revalidateEvidence(
17553
- {
17505
+ const reval = await checkRevalidateEvidence(projectRoot, {
17506
+ evidence: {
17554
17507
  atoms: normalised.atoms,
17555
17508
  capturedAt: normalised.capturedAt,
17556
17509
  capturedBy: normalised.capturedBy,
17557
17510
  override: normalised.override
17558
- },
17559
- projectRoot
17560
- );
17511
+ }
17512
+ });
17561
17513
  stillValid = reval.stillValid;
17562
17514
  failedAtoms = reval.failedAtoms.map((f) => ({
17563
17515
  kind: f.atom.kind,
@@ -17639,51 +17591,48 @@ var init_check = __esm({
17639
17591
  },
17640
17592
  "archive.stats": async (params) => {
17641
17593
  const projectRoot = getProjectRoot3();
17642
- const result = await systemArchiveStats(projectRoot, {
17643
- period: params?.period,
17644
- report: params?.report,
17645
- since: params?.since,
17646
- until: params?.until
17647
- });
17648
- if (!result.success) {
17594
+ try {
17595
+ const result = await checkArchiveStats(projectRoot, params);
17596
+ return lafsSuccess(result, "archive.stats");
17597
+ } catch (err) {
17649
17598
  return lafsError(
17650
- String(result.error?.code ?? "E_INTERNAL"),
17651
- result.error?.message ?? "Unknown error",
17599
+ "E_NOT_INITIALIZED",
17600
+ err instanceof Error ? err.message : String(err),
17652
17601
  "archive.stats"
17653
17602
  );
17654
17603
  }
17655
- return lafsSuccess(result.data ?? {}, "archive.stats");
17656
17604
  },
17657
17605
  "chain.validate": async (params) => {
17658
17606
  if (!params.chain) {
17659
17607
  return lafsError("E_INVALID_INPUT", "chain is required", "chain.validate");
17660
17608
  }
17661
- const chainResult = validateChain(params.chain);
17609
+ const chainResult = checkValidateChain("", params);
17662
17610
  return lafsSuccess(chainResult, "chain.validate");
17663
17611
  },
17664
17612
  grade: async (params) => {
17665
17613
  const projectRoot = getProjectRoot3();
17666
- const { gradeSession } = await import("@cleocode/core/internal");
17667
17614
  if (!params.sessionId) {
17668
17615
  return lafsError("E_INVALID_INPUT", "sessionId required", "grade");
17669
17616
  }
17670
- const gradeResult = await gradeSession(params.sessionId, projectRoot);
17671
- return lafsSuccess(gradeResult, "grade");
17617
+ try {
17618
+ const gradeResult = await checkGradeSession(projectRoot, params);
17619
+ return lafsSuccess(gradeResult, "grade");
17620
+ } catch (err) {
17621
+ return lafsError("E_NOT_FOUND", err instanceof Error ? err.message : String(err), "grade");
17622
+ }
17672
17623
  },
17673
17624
  "grade.list": async (params) => {
17674
17625
  const projectRoot = getProjectRoot3();
17675
- const { readGrades } = await import("@cleocode/core/internal");
17676
- const allGrades = await readGrades(void 0, projectRoot);
17677
- const filteredGrades = params.sessionId ? allGrades.filter((g) => g.sessionId === params.sessionId) : allGrades;
17678
- const page = paginate3(filteredGrades, params.limit, params.offset);
17679
- return lafsSuccess(
17680
- {
17681
- grades: page.items,
17682
- total: allGrades.length,
17683
- filtered: filteredGrades.length
17684
- },
17685
- "grade.list"
17686
- );
17626
+ try {
17627
+ const result = await checkReadGrades(projectRoot, params);
17628
+ return lafsSuccess(result, "grade.list");
17629
+ } catch (err) {
17630
+ return lafsError(
17631
+ "E_NOT_FOUND",
17632
+ err instanceof Error ? err.message : String(err),
17633
+ "grade.list"
17634
+ );
17635
+ }
17687
17636
  },
17688
17637
  canon: async (_params) => {
17689
17638
  const projectRoot = getProjectRoot3();
@@ -17693,11 +17642,16 @@ var init_check = __esm({
17693
17642
  },
17694
17643
  "workflow.compliance": async (params) => {
17695
17644
  const projectRoot = getProjectRoot3();
17696
- const result = await getWorkflowComplianceReport({
17697
- since: params.since,
17698
- cwd: projectRoot
17699
- });
17700
- return lafsSuccess(result, "workflow.compliance");
17645
+ try {
17646
+ const result = await checkWorkflowCompliance(projectRoot, params);
17647
+ return lafsSuccess(result, "workflow.compliance");
17648
+ } catch (err) {
17649
+ return lafsError(
17650
+ "E_GENERAL",
17651
+ err instanceof Error ? err.message : String(err),
17652
+ "workflow.compliance"
17653
+ );
17654
+ }
17701
17655
  },
17702
17656
  // -----------------------------------------------------------------------
17703
17657
  // Mutate ops
@@ -17707,66 +17661,51 @@ var init_check = __esm({
17707
17661
  if (!params.taskId || !params.result) {
17708
17662
  return lafsError("E_INVALID_INPUT", "taskId and result are required", "compliance.record");
17709
17663
  }
17710
- const engineResult = validateComplianceRecord(
17711
- params.taskId,
17712
- params.result,
17713
- params.protocol,
17714
- params.violations,
17715
- projectRoot
17716
- );
17717
- if (!engineResult.success) {
17664
+ try {
17665
+ const result = checkComplianceRecord(projectRoot, params);
17666
+ return lafsSuccess(result, "compliance.record");
17667
+ } catch (err) {
17718
17668
  return lafsError(
17719
- String(engineResult.error?.code ?? "E_INTERNAL"),
17720
- engineResult.error?.message ?? "Unknown error",
17669
+ "E_INVALID_INPUT",
17670
+ err instanceof Error ? err.message : String(err),
17721
17671
  "compliance.record"
17722
17672
  );
17723
17673
  }
17724
- return lafsSuccess(
17725
- engineResult.data ?? { taskId: params.taskId, recorded: "" },
17726
- "compliance.record"
17727
- );
17728
17674
  },
17729
17675
  "test.run": async (params) => {
17730
17676
  const projectRoot = getProjectRoot3();
17731
- const result = validateTestRun(
17732
- { scope: params.scope, pattern: params.pattern, parallel: params.parallel },
17733
- projectRoot
17734
- );
17735
- if (!result.success) {
17736
- return lafsError(
17737
- String(result.error?.code ?? "E_INTERNAL"),
17738
- result.error?.message ?? "Unknown error",
17739
- "test.run"
17740
- );
17677
+ try {
17678
+ const result = checkTestRun(projectRoot, params);
17679
+ return lafsSuccess(result, "test.run");
17680
+ } catch (err) {
17681
+ return lafsError("E_GENERAL", err instanceof Error ? err.message : String(err), "test.run");
17741
17682
  }
17742
- return lafsSuccess(
17743
- result.data ?? { status: { total: 0, passed: 0, failed: 0, skipped: 0, passRate: 0 } },
17744
- "test.run"
17745
- );
17746
17683
  },
17747
- "test.coverage": async (_params) => {
17684
+ "test.coverage": async (params) => {
17748
17685
  const projectRoot = getProjectRoot3();
17749
- const result = validateTestCoverage(projectRoot);
17750
- if (!result.success) {
17686
+ try {
17687
+ const result = checkTestCoverage(projectRoot, params ?? {});
17688
+ return lafsSuccess(result, "test.coverage");
17689
+ } catch (err) {
17751
17690
  return lafsError(
17752
- String(result.error?.code ?? "E_INTERNAL"),
17753
- result.error?.message ?? "Unknown error",
17691
+ "E_FILE_ERROR",
17692
+ err instanceof Error ? err.message : String(err),
17754
17693
  "test.coverage"
17755
17694
  );
17756
17695
  }
17757
- return lafsSuccess(
17758
- result.data ?? { lineCoverage: 0, branchCoverage: 0, functionCoverage: 0, threshold: 0 },
17759
- "test.coverage"
17760
- );
17761
17696
  },
17762
17697
  "compliance.sync": async (params) => {
17763
17698
  const projectRoot = getProjectRoot3();
17764
- const { syncComplianceMetrics } = await import("@cleocode/core/internal");
17765
- const result = await syncComplianceMetrics({
17766
- force: params.force,
17767
- cwd: projectRoot
17768
- });
17769
- return lafsSuccess(result, "compliance.sync");
17699
+ try {
17700
+ const result = await checkComplianceSync(projectRoot, params);
17701
+ return lafsSuccess(result, "compliance.sync");
17702
+ } catch (err) {
17703
+ return lafsError(
17704
+ "E_GENERAL",
17705
+ err instanceof Error ? err.message : String(err),
17706
+ "compliance.sync"
17707
+ );
17708
+ }
17770
17709
  },
17771
17710
  "gate.set": async (params) => {
17772
17711
  const projectRoot = getProjectRoot3();
@@ -21087,7 +21026,7 @@ import {
21087
21026
  nexusSyncAll,
21088
21027
  nexusUnregister,
21089
21028
  orphanDetection,
21090
- paginate as paginate4,
21029
+ paginate as paginate3,
21091
21030
  previewTransfer,
21092
21031
  nexusReadRegistry as readRegistry,
21093
21032
  readSnapshot as readSnapshot2,
@@ -21117,8 +21056,8 @@ async function nexusStatus() {
21117
21056
  }
21118
21057
  async function nexusListProjects(limit, offset) {
21119
21058
  try {
21120
- const projects = await nexusList();
21121
- const page = paginate4(projects, limit, offset);
21059
+ const projects = await nexusList("", {});
21060
+ const page = paginate3(projects, limit, offset);
21122
21061
  return {
21123
21062
  success: true,
21124
21063
  data: {
@@ -21136,7 +21075,7 @@ async function nexusListProjects(limit, offset) {
21136
21075
  }
21137
21076
  async function nexusShowProject(name) {
21138
21077
  try {
21139
- const project = await nexusGetProject(name);
21078
+ const project = await nexusGetProject("", { name });
21140
21079
  if (!project) {
21141
21080
  return engineError("E_NOT_FOUND", `Project not found: ${name}`);
21142
21081
  }
@@ -21153,7 +21092,7 @@ async function nexusResolve(query, currentProject) {
21153
21092
  `Invalid query syntax: ${query}. Expected: T001, project:T001, .:T001, or *:T001`
21154
21093
  );
21155
21094
  }
21156
- const result = await resolveTask(query, currentProject);
21095
+ const result = await resolveTask("", { query, currentProject });
21157
21096
  return engineSuccess(result);
21158
21097
  } catch (error) {
21159
21098
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21161,7 +21100,7 @@ async function nexusResolve(query, currentProject) {
21161
21100
  }
21162
21101
  async function nexusDepsQuery(query, direction = "forward") {
21163
21102
  try {
21164
- const result = await nexusDeps(query, direction);
21103
+ const result = await nexusDeps("", { query, direction });
21165
21104
  return engineSuccess(result);
21166
21105
  } catch (error) {
21167
21106
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21169,7 +21108,7 @@ async function nexusDepsQuery(query, direction = "forward") {
21169
21108
  }
21170
21109
  async function nexusGraph() {
21171
21110
  try {
21172
- const graph = await buildGlobalGraph();
21111
+ const graph = await buildGlobalGraph("", {});
21173
21112
  return engineSuccess(graph);
21174
21113
  } catch (error) {
21175
21114
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21177,7 +21116,7 @@ async function nexusGraph() {
21177
21116
  }
21178
21117
  async function nexusCriticalPath() {
21179
21118
  try {
21180
- const path5 = await criticalPath();
21119
+ const path5 = await criticalPath("", {});
21181
21120
  return engineSuccess(path5);
21182
21121
  } catch (error) {
21183
21122
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21406,7 +21345,7 @@ async function nexusTopEntries(params) {
21406
21345
  }
21407
21346
  async function nexusBlockers(query) {
21408
21347
  try {
21409
- const analysis = await blockingAnalysis(query);
21348
+ const analysis = await blockingAnalysis("", { query });
21410
21349
  return engineSuccess(analysis);
21411
21350
  } catch (error) {
21412
21351
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21414,8 +21353,8 @@ async function nexusBlockers(query) {
21414
21353
  }
21415
21354
  async function nexusOrphans(limit, offset) {
21416
21355
  try {
21417
- const orphans = await orphanDetection();
21418
- const page = paginate4(orphans, limit, offset);
21356
+ const orphans = await orphanDetection("", {});
21357
+ const page = paginate3(orphans, limit, offset);
21419
21358
  return {
21420
21359
  success: true,
21421
21360
  data: {
@@ -21433,7 +21372,7 @@ async function nexusOrphans(limit, offset) {
21433
21372
  }
21434
21373
  async function nexusDiscover(taskQuery, method = "auto", limit = 10) {
21435
21374
  try {
21436
- const result = await discoverRelated(taskQuery, method, limit);
21375
+ const result = await discoverRelated("", { query: taskQuery, method, limit });
21437
21376
  if ("error" in result) {
21438
21377
  return engineError(result.error.code, result.error.message);
21439
21378
  }
@@ -21444,7 +21383,7 @@ async function nexusDiscover(taskQuery, method = "auto", limit = 10) {
21444
21383
  }
21445
21384
  async function nexusSearch(pattern, projectFilter, limit = 20) {
21446
21385
  try {
21447
- const result = await searchAcrossProjects(pattern, projectFilter, limit);
21386
+ const result = await searchAcrossProjects("", { pattern, project: projectFilter, limit });
21448
21387
  if ("error" in result) {
21449
21388
  return engineError(
21450
21389
  result.error.code,
@@ -21458,7 +21397,7 @@ async function nexusSearch(pattern, projectFilter, limit = 20) {
21458
21397
  }
21459
21398
  async function nexusInitialize() {
21460
21399
  try {
21461
- await nexusInit();
21400
+ await nexusInit("", {});
21462
21401
  return engineSuccess({ message: "NEXUS initialized successfully" });
21463
21402
  } catch (error) {
21464
21403
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21466,7 +21405,7 @@ async function nexusInitialize() {
21466
21405
  }
21467
21406
  async function nexusRegisterProject(path5, name, permission = "read") {
21468
21407
  try {
21469
- const hash = await nexusRegister(path5, name, permission);
21408
+ const hash = await nexusRegister("", { path: path5, name, permission });
21470
21409
  return engineSuccess({ hash, message: `Project registered with hash: ${hash}` });
21471
21410
  } catch (error) {
21472
21411
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21474,7 +21413,7 @@ async function nexusRegisterProject(path5, name, permission = "read") {
21474
21413
  }
21475
21414
  async function nexusUnregisterProject(name) {
21476
21415
  try {
21477
- await nexusUnregister(name);
21416
+ await nexusUnregister("", { name });
21478
21417
  return engineSuccess({ message: `Project unregistered: ${name}` });
21479
21418
  } catch (error) {
21480
21419
  return cleoErrorToEngineError(error, "E_INTERNAL", `Failed to unregister project: ${name}`);
@@ -21483,7 +21422,7 @@ async function nexusUnregisterProject(name) {
21483
21422
  async function nexusSyncProject(name) {
21484
21423
  try {
21485
21424
  if (name) {
21486
- await nexusSync(name);
21425
+ await nexusSync("", { name });
21487
21426
  return engineSuccess({ message: `Project synced: ${name}` });
21488
21427
  }
21489
21428
  const result = await nexusSyncAll();
@@ -21494,7 +21433,7 @@ async function nexusSyncProject(name) {
21494
21433
  }
21495
21434
  async function nexusSetPermission(name, level) {
21496
21435
  try {
21497
- await setPermission(name, level);
21436
+ await setPermission("", { name, level });
21498
21437
  return engineSuccess({ message: `Permission for '${name}' set to '${level}'` });
21499
21438
  } catch (error) {
21500
21439
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21502,7 +21441,7 @@ async function nexusSetPermission(name, level) {
21502
21441
  }
21503
21442
  async function nexusReconcileProject(projectRoot) {
21504
21443
  try {
21505
- const result = await nexusReconcile(projectRoot);
21444
+ const result = await nexusReconcile(projectRoot, {});
21506
21445
  return engineSuccess(result);
21507
21446
  } catch (error) {
21508
21447
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -21510,7 +21449,7 @@ async function nexusReconcileProject(projectRoot) {
21510
21449
  }
21511
21450
  async function nexusShareStatus(projectRoot) {
21512
21451
  try {
21513
- const result = await getSharingStatus(projectRoot);
21452
+ const result = await getSharingStatus(projectRoot, {});
21514
21453
  return engineSuccess(result);
21515
21454
  } catch (error) {
21516
21455
  return engineError("E_INTERNAL", error instanceof Error ? error.message : String(error));
@@ -27918,8 +27857,8 @@ async function acquireDb() {
27918
27857
  async function buildDefaultDispatcher() {
27919
27858
  if (__playbookRuntimeOverrides.dispatcher) return __playbookRuntimeOverrides.dispatcher;
27920
27859
  const { orchestrateSpawnExecute: orchestrateSpawnExecute2 } = await Promise.resolve().then(() => (init_engine(), engine_exports));
27921
- const { getProjectRoot: getProjectRoot32 } = await import("@cleocode/core/internal");
27922
- const projectRoot = getProjectRoot32();
27860
+ const { getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
27861
+ const projectRoot = getProjectRoot33();
27923
27862
  return {
27924
27863
  async dispatch(input) {
27925
27864
  try {
@@ -28272,14 +28211,14 @@ var init_playbook = __esm({
28272
28211
  const dispatcher = await buildDefaultDispatcher();
28273
28212
  let result;
28274
28213
  try {
28275
- const { getProjectRoot: getProjectRoot32 } = await import("@cleocode/core/internal");
28214
+ const { getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
28276
28215
  const opts = {
28277
28216
  db,
28278
28217
  playbook: parsed.definition,
28279
28218
  playbookHash: parsed.sourceHash,
28280
28219
  initialContext,
28281
28220
  dispatcher,
28282
- projectRoot: getProjectRoot32()
28221
+ projectRoot: getProjectRoot33()
28283
28222
  };
28284
28223
  if (__playbookRuntimeOverrides.approvalSecret !== void 0) {
28285
28224
  opts.approvalSecret = __playbookRuntimeOverrides.approvalSecret;
@@ -28436,14 +28375,14 @@ import {
28436
28375
  getProjectRoot as getProjectRoot9,
28437
28376
  instantiateTessera,
28438
28377
  listTesseraTemplates,
28439
- paginate as paginate5,
28378
+ paginate as paginate4,
28440
28379
  showTessera
28441
28380
  } from "@cleocode/core/internal";
28442
28381
  async function orchestrateClassify(request, context, projectRoot) {
28443
28382
  try {
28444
28383
  const { getCleoCantWorkflowsDir: getCleoCantWorkflowsDir2 } = await import("@cleocode/core/internal");
28445
28384
  const { readFileSync: readFileSync16, readdirSync: readdirSync4, existsSync: existsSync12 } = await import("node:fs");
28446
- const { join: join23 } = await import("node:path");
28385
+ const { join: join22 } = await import("node:path");
28447
28386
  const workflowsDir = getCleoCantWorkflowsDir2();
28448
28387
  const combined = `${request} ${context ?? ""}`.toLowerCase();
28449
28388
  const matches = [];
@@ -28451,7 +28390,7 @@ async function orchestrateClassify(request, context, projectRoot) {
28451
28390
  const files = readdirSync4(workflowsDir).filter((f) => f.endsWith(".cant"));
28452
28391
  for (const file of files) {
28453
28392
  try {
28454
- const src = readFileSync16(join23(workflowsDir, file), "utf-8");
28393
+ const src = readFileSync16(join22(workflowsDir, file), "utf-8");
28455
28394
  const teamMatch = /^team\s+(\S+):/m.exec(src);
28456
28395
  if (!teamMatch) continue;
28457
28396
  const teamName = teamMatch[1];
@@ -28466,12 +28405,12 @@ async function orchestrateClassify(request, context, projectRoot) {
28466
28405
  }
28467
28406
  }
28468
28407
  }
28469
- const localCantDir = join23(projectRoot, CLEO_DIR_NAME, WORKFLOWS_SUBDIR);
28408
+ const localCantDir = join22(projectRoot, CLEO_DIR_NAME, WORKFLOWS_SUBDIR);
28470
28409
  if (existsSync12(localCantDir)) {
28471
28410
  const files = readdirSync4(localCantDir).filter((f) => f.endsWith(".cant"));
28472
28411
  for (const file of files) {
28473
28412
  try {
28474
- const src = readFileSync16(join23(localCantDir, file), "utf-8");
28413
+ const src = readFileSync16(join22(localCantDir, file), "utf-8");
28475
28414
  const teamMatch = /^team\s+(\S+):/m.exec(src);
28476
28415
  if (!teamMatch) continue;
28477
28416
  const teamName = teamMatch[1];
@@ -29102,7 +29041,7 @@ var init_orchestrate2 = __esm({
29102
29041
  }
29103
29042
  const templates2 = listTesseraTemplates();
29104
29043
  const { limit, offset } = getListParams(params);
29105
- const page = paginate5(templates2, limit, offset);
29044
+ const page = paginate4(templates2, limit, offset);
29106
29045
  return {
29107
29046
  meta: dispatchMeta("query", "orchestrate", "tessera.list", startTime),
29108
29047
  success: true,
@@ -29494,7 +29433,7 @@ import {
29494
29433
  getProjectRoot as getProjectRoot10,
29495
29434
  isValidStage,
29496
29435
  listChains,
29497
- paginate as paginate6,
29436
+ paginate as paginate5,
29498
29437
  resolveChannelFromBranch as resolveChannelFromBranch2,
29499
29438
  showChain
29500
29439
  } from "@cleocode/core/internal";
@@ -30110,7 +30049,7 @@ var init_pipeline2 = __esm({
30110
30049
  const phases = listData.phases ?? [];
30111
30050
  const total = listData.summary?.total ?? phases.length;
30112
30051
  const { limit, offset } = getListParams(params);
30113
- const page = paginate6(phases, limit, offset);
30052
+ const page = paginate5(phases, limit, offset);
30114
30053
  return {
30115
30054
  meta: dispatchMeta("query", "pipeline", "phase.list", startTime),
30116
30055
  success: true,
@@ -30310,7 +30249,7 @@ var init_pipeline2 = __esm({
30310
30249
  case "list": {
30311
30250
  const chains = await listChains(this.projectRoot);
30312
30251
  const { limit, offset } = getListParams(params);
30313
- const page = paginate6(chains, limit, offset);
30252
+ const page = paginate5(chains, limit, offset);
30314
30253
  return wrapResult(
30315
30254
  {
30316
30255
  success: true,
@@ -30616,8 +30555,19 @@ var init_release2 = __esm({
30616
30555
  });
30617
30556
 
30618
30557
  // packages/cleo/src/dispatch/domains/sentient.ts
30619
- import { join as join6 } from "node:path";
30620
30558
  import { getProjectRoot as getProjectRoot12 } from "@cleocode/core";
30559
+ import {
30560
+ sentientAllowlistAdd,
30561
+ sentientAllowlistList,
30562
+ sentientAllowlistRemove,
30563
+ sentientProposeAccept,
30564
+ sentientProposeDiff,
30565
+ sentientProposeDisable,
30566
+ sentientProposeEnable,
30567
+ sentientProposeList,
30568
+ sentientProposeReject,
30569
+ sentientProposeRun
30570
+ } from "@cleocode/core/sentient";
30621
30571
  function envelopeToEngineResult3(envelope) {
30622
30572
  if (envelope.success) {
30623
30573
  return { success: true, data: envelope.data };
@@ -30630,324 +30580,122 @@ function envelopeToEngineResult3(envelope) {
30630
30580
  }
30631
30581
  };
30632
30582
  }
30633
- async function listProposals(projectRoot, params) {
30634
- const { getDb: getDb3 } = await import("@cleocode/core/internal");
30635
- const { tasks } = await import("@cleocode/core/store/tasks-schema");
30636
- const { and, eq: eq2, like } = await import("drizzle-orm");
30637
- const db = await getDb3(projectRoot);
30638
- const limit = params.limit && params.limit > 0 ? params.limit : 50;
30639
- const rows = await db.select().from(tasks).where(and(eq2(tasks.status, "proposed"), like(tasks.labelsJson, `%${TIER2_LABEL}%`))).limit(limit).all();
30640
- const proposals = rows.map((row) => ({
30641
- id: row.id,
30642
- title: row.title,
30643
- description: row.description,
30644
- status: row.status,
30645
- priority: row.priority,
30646
- labels: safeParseJsonArray(row.labelsJson),
30647
- createdAt: row.createdAt,
30648
- meta: safeParseProposalMeta(row.notesJson)
30649
- }));
30650
- proposals.sort((a, b) => {
30651
- const wa = typeof a.meta?.weight === "number" ? a.meta.weight : 0;
30652
- const wb = typeof b.meta?.weight === "number" ? b.meta.weight : 0;
30653
- return wb - wa;
30654
- });
30655
- return { success: true, data: { proposals, total: proposals.length } };
30656
- }
30657
- async function acceptProposal(projectRoot, id) {
30658
- const { getDb: getDb3 } = await import("@cleocode/core/internal");
30659
- const { tasks } = await import("@cleocode/core/store/tasks-schema");
30660
- const { and, eq: eq2, like } = await import("drizzle-orm");
30661
- const db = await getDb3(projectRoot);
30662
- const existing = await db.select().from(tasks).where(
30663
- and(
30664
- eq2(tasks.id, id),
30665
- eq2(tasks.status, "proposed"),
30666
- like(tasks.labelsJson, `%${TIER2_LABEL}%`)
30667
- )
30668
- ).get();
30669
- if (!existing) {
30670
- return {
30671
- success: false,
30672
- error: {
30673
- code: "E_NOT_FOUND",
30674
- message: `Task ${id} is not a pending proposal (status must be 'proposed' with label '${TIER2_LABEL}')`
30675
- }
30676
- };
30677
- }
30678
- const now = (/* @__PURE__ */ new Date()).toISOString();
30679
- await db.update(tasks).set({ status: "pending", updatedAt: now }).where(eq2(tasks.id, id)).run();
30680
- await incrementTier2Stat(projectRoot, "proposalsAccepted");
30681
- return { success: true, data: { id, status: "pending", acceptedAt: now } };
30682
- }
30683
- async function rejectProposal(projectRoot, id, reason) {
30684
- const { getDb: getDb3 } = await import("@cleocode/core/internal");
30685
- const { tasks } = await import("@cleocode/core/store/tasks-schema");
30686
- const { and, eq: eq2, like } = await import("drizzle-orm");
30687
- const db = await getDb3(projectRoot);
30688
- const existing = await db.select().from(tasks).where(
30689
- and(
30690
- eq2(tasks.id, id),
30691
- eq2(tasks.status, "proposed"),
30692
- like(tasks.labelsJson, `%${TIER2_LABEL}%`)
30693
- )
30694
- ).get();
30695
- if (!existing) {
30696
- return {
30697
- success: false,
30698
- error: {
30699
- code: "E_NOT_FOUND",
30700
- message: `Task ${id} is not a pending proposal (status must be 'proposed' with label '${TIER2_LABEL}')`
30701
- }
30702
- };
30703
- }
30704
- const now = (/* @__PURE__ */ new Date()).toISOString();
30705
- await db.update(tasks).set({
30706
- status: "cancelled",
30707
- cancellationReason: reason,
30708
- cancelledAt: now,
30709
- updatedAt: now
30710
- }).where(eq2(tasks.id, id)).run();
30711
- await incrementTier2Stat(projectRoot, "proposalsRejected");
30712
- return { success: true, data: { id, status: "cancelled", rejectedAt: now, reason } };
30713
- }
30714
- async function runProposeTick(projectRoot) {
30715
- const { safeRunProposeTick: safeRunProposeTick2 } = await import("@cleocode/core/sentient/propose-tick.js");
30716
- const { SENTIENT_STATE_FILE: SENTIENT_STATE_FILE2 } = await import("@cleocode/core/sentient/daemon.js");
30717
- const statePath = join6(projectRoot, SENTIENT_STATE_FILE2);
30718
- const outcome = await safeRunProposeTick2({ projectRoot, statePath });
30719
- return { success: true, data: { outcome } };
30720
- }
30721
- async function listAllowlist(projectRoot) {
30722
- const { getOwnerPubkeys } = await import("@cleocode/core/sentient/allowlist.js");
30723
- const pubkeys = await getOwnerPubkeys(projectRoot, { noCache: true });
30724
- const b64List = pubkeys.map((k) => Buffer.from(k).toString("base64"));
30725
- return { success: true, data: { ownerPubkeys: b64List, count: b64List.length } };
30726
- }
30727
- async function addAllowlistKey(projectRoot, pubkeyBase64) {
30728
- try {
30729
- const { addOwnerPubkey } = await import("@cleocode/core/sentient/allowlist.js");
30730
- await addOwnerPubkey(projectRoot, pubkeyBase64);
30731
- return { success: true, data: { added: pubkeyBase64 } };
30732
- } catch (err) {
30733
- const message = err instanceof Error ? err.message : String(err);
30734
- return { success: false, error: { code: "E_ALLOWLIST_ADD", message } };
30735
- }
30736
- }
30737
- async function removeAllowlistKey(projectRoot, pubkeyBase64) {
30738
- try {
30739
- const { removeOwnerPubkey } = await import("@cleocode/core/sentient/allowlist.js");
30740
- await removeOwnerPubkey(projectRoot, pubkeyBase64);
30741
- return { success: true, data: { removed: pubkeyBase64 } };
30742
- } catch (err) {
30743
- const code = err.code === "E_ALLOWLIST_KEY_NOT_FOUND" ? "E_ALLOWLIST_KEY_NOT_FOUND" : "E_ALLOWLIST_REMOVE";
30744
- const message = err instanceof Error ? err.message : String(err);
30745
- return { success: false, error: { code, message } };
30746
- }
30747
- }
30748
- async function setTier2Enabled(projectRoot, enabled) {
30749
- if (enabled) {
30750
- try {
30751
- const { scanBrainNoise } = await import("@cleocode/core/memory/brain-doctor.js");
30752
- const doctorResult = await scanBrainNoise(projectRoot);
30753
- if (!doctorResult.isClean) {
30754
- return {
30755
- success: false,
30756
- error: {
30757
- code: "E_M7_GATE_FAILED",
30758
- message: `M7 gate blocked: brain corpus has ${doctorResult.findings.length} noise pattern(s) across ${doctorResult.totalScanned} entries. Run \`cleo memory doctor\` for details, then \`cleo memory sweep --approve\` to clean before enabling Sentient v1.`,
30759
- details: { findings: doctorResult.findings, totalScanned: doctorResult.totalScanned }
30760
- }
30761
- };
30762
- }
30763
- } catch {
30764
- }
30765
- }
30766
- const { patchSentientState: patchSentientState2 } = await import("@cleocode/core/sentient/state.js");
30767
- const { SENTIENT_STATE_FILE: SENTIENT_STATE_FILE2 } = await import("@cleocode/core/sentient/daemon.js");
30768
- const statePath = join6(projectRoot, SENTIENT_STATE_FILE2);
30769
- const updated = await patchSentientState2(statePath, { tier2Enabled: enabled });
30770
- return {
30771
- success: true,
30772
- data: {
30773
- tier2Enabled: updated.tier2Enabled,
30774
- message: enabled ? "Tier-2 proposals enabled" : "Tier-2 proposals disabled"
30775
- }
30776
- };
30777
- }
30778
- function safeParseJsonArray(json2) {
30779
- if (!json2) return [];
30780
- try {
30781
- const parsed = JSON.parse(json2);
30782
- return Array.isArray(parsed) ? parsed : [];
30783
- } catch {
30784
- return [];
30785
- }
30786
- }
30787
- function safeParseProposalMeta(notesJson) {
30788
- if (!notesJson) return null;
30789
- try {
30790
- const notes = JSON.parse(notesJson);
30791
- if (!Array.isArray(notes) || notes.length === 0) return null;
30792
- const first = notes[0];
30793
- if (typeof first !== "string") return null;
30794
- const meta = JSON.parse(first);
30795
- if (meta.kind === "proposal-meta") return meta;
30796
- return null;
30797
- } catch {
30798
- return null;
30799
- }
30800
- }
30801
- async function incrementTier2Stat(projectRoot, field) {
30802
- try {
30803
- const { patchSentientState: patchSentientState2, readSentientState: readSentientState2 } = await import("@cleocode/core/sentient/state.js");
30804
- const { SENTIENT_STATE_FILE: SENTIENT_STATE_FILE2 } = await import("@cleocode/core/sentient/daemon.js");
30805
- const statePath = join6(projectRoot, SENTIENT_STATE_FILE2);
30806
- const state = await readSentientState2(statePath);
30807
- await patchSentientState2(statePath, {
30808
- tier2Stats: {
30809
- ...state.tier2Stats,
30810
- [field]: state.tier2Stats[field] + 1
30811
- }
30812
- });
30813
- } catch {
30814
- }
30815
- }
30816
- var TIER2_LABEL, _sentientTypedHandler, QUERY_OPS4, MUTATE_OPS4, SentientHandler;
30583
+ var _sentientTypedHandler, QUERY_OPS4, MUTATE_OPS4, SentientHandler;
30817
30584
  var init_sentient2 = __esm({
30818
30585
  "packages/cleo/src/dispatch/domains/sentient.ts"() {
30819
30586
  "use strict";
30820
30587
  init_typed();
30821
30588
  init_base();
30822
- TIER2_LABEL = "sentient-tier2";
30823
30589
  _sentientTypedHandler = defineTypedHandler("sentient", {
30824
30590
  // -------------------------------------------------------------------------
30825
30591
  // Query ops
30826
30592
  // -------------------------------------------------------------------------
30827
30593
  "propose.list": async (params) => {
30828
30594
  const projectRoot = getProjectRoot12();
30829
- const result = await listProposals(projectRoot, params);
30830
- if (!result.success) {
30831
- return lafsError(
30832
- result.error?.code ?? "E_INTERNAL",
30833
- result.error?.message ?? "Unknown error",
30834
- "propose.list"
30835
- );
30595
+ try {
30596
+ const data = await sentientProposeList(projectRoot, params);
30597
+ return lafsSuccess(data, "propose.list");
30598
+ } catch (err) {
30599
+ const message = err instanceof Error ? err.message : String(err);
30600
+ return lafsError("E_INTERNAL", message, "propose.list");
30836
30601
  }
30837
- return lafsSuccess(result.data ?? { proposals: [], total: 0 }, "propose.list");
30838
30602
  },
30839
30603
  "propose.diff": async (params) => {
30840
- return lafsSuccess(
30841
- {
30842
- id: params.id,
30843
- diff: null,
30844
- message: "Content diff is a Tier-3 feature (blocked on T992+T993+T995). This proposal is a task-creation suggestion; no diff is available."
30845
- },
30846
- "propose.diff"
30847
- );
30604
+ const projectRoot = getProjectRoot12();
30605
+ try {
30606
+ const data = await sentientProposeDiff(projectRoot, params);
30607
+ return lafsSuccess(data, "propose.diff");
30608
+ } catch (err) {
30609
+ const message = err instanceof Error ? err.message : String(err);
30610
+ return lafsError("E_INTERNAL", message, "propose.diff");
30611
+ }
30848
30612
  },
30849
30613
  "allowlist.list": async (_params) => {
30850
30614
  const projectRoot = getProjectRoot12();
30851
- const result = await listAllowlist(projectRoot);
30852
- if (!result.success) {
30853
- return lafsError(
30854
- result.error?.code ?? "E_INTERNAL",
30855
- result.error?.message ?? "Unknown error",
30856
- "allowlist.list"
30857
- );
30615
+ try {
30616
+ const data = await sentientAllowlistList(projectRoot, _params);
30617
+ return lafsSuccess(data, "allowlist.list");
30618
+ } catch (err) {
30619
+ const message = err instanceof Error ? err.message : String(err);
30620
+ return lafsError("E_INTERNAL", message, "allowlist.list");
30858
30621
  }
30859
- return lafsSuccess(result.data ?? { ownerPubkeys: [], count: 0 }, "allowlist.list");
30860
30622
  },
30861
30623
  // -------------------------------------------------------------------------
30862
30624
  // Mutate ops
30863
30625
  // -------------------------------------------------------------------------
30864
30626
  "propose.accept": async (params) => {
30865
30627
  const projectRoot = getProjectRoot12();
30866
- const result = await acceptProposal(projectRoot, params.id);
30867
- if (!result.success) {
30868
- return lafsError(
30869
- result.error?.code ?? "E_INTERNAL",
30870
- result.error?.message ?? "Unknown error",
30871
- "propose.accept"
30872
- );
30628
+ try {
30629
+ const data = await sentientProposeAccept(projectRoot, params);
30630
+ return lafsSuccess(data, "propose.accept");
30631
+ } catch (err) {
30632
+ const code = err.code ?? "E_INTERNAL";
30633
+ const message = err instanceof Error ? err.message : String(err);
30634
+ return lafsError(code, message, "propose.accept");
30873
30635
  }
30874
- return lafsSuccess(result.data ?? { id: "", status: "", acceptedAt: "" }, "propose.accept");
30875
30636
  },
30876
30637
  "propose.reject": async (params) => {
30877
30638
  const projectRoot = getProjectRoot12();
30878
- const reason = params.reason ?? "rejected by owner";
30879
- const result = await rejectProposal(projectRoot, params.id, reason);
30880
- if (!result.success) {
30881
- return lafsError(
30882
- result.error?.code ?? "E_INTERNAL",
30883
- result.error?.message ?? "Unknown error",
30884
- "propose.reject"
30885
- );
30639
+ try {
30640
+ const data = await sentientProposeReject(projectRoot, params);
30641
+ return lafsSuccess(data, "propose.reject");
30642
+ } catch (err) {
30643
+ const code = err.code ?? "E_INTERNAL";
30644
+ const message = err instanceof Error ? err.message : String(err);
30645
+ return lafsError(code, message, "propose.reject");
30886
30646
  }
30887
- return lafsSuccess(
30888
- result.data ?? { id: "", status: "", rejectedAt: "", reason: "" },
30889
- "propose.reject"
30890
- );
30891
30647
  },
30892
30648
  "propose.run": async (_params) => {
30893
30649
  const projectRoot = getProjectRoot12();
30894
- const result = await runProposeTick(projectRoot);
30895
- if (!result.success) {
30896
- return lafsError(
30897
- result.error?.code ?? "E_INTERNAL",
30898
- result.error?.message ?? "Unknown error",
30899
- "propose.run"
30900
- );
30650
+ try {
30651
+ const data = await sentientProposeRun(projectRoot, _params);
30652
+ return lafsSuccess(data, "propose.run");
30653
+ } catch (err) {
30654
+ const message = err instanceof Error ? err.message : String(err);
30655
+ return lafsError("E_INTERNAL", message, "propose.run");
30901
30656
  }
30902
- return lafsSuccess(result.data ?? { outcome: null }, "propose.run");
30903
30657
  },
30904
30658
  "propose.enable": async (_params) => {
30905
30659
  const projectRoot = getProjectRoot12();
30906
- const result = await setTier2Enabled(projectRoot, true);
30907
- if (!result.success) {
30908
- return lafsError(
30909
- result.error?.code ?? "E_INTERNAL",
30910
- result.error?.message ?? "Unknown error",
30911
- "propose.enable"
30912
- );
30660
+ try {
30661
+ const data = await sentientProposeEnable(projectRoot, _params);
30662
+ return lafsSuccess(data, "propose.enable");
30663
+ } catch (err) {
30664
+ const code = err.code ?? "E_INTERNAL";
30665
+ const message = err instanceof Error ? err.message : String(err);
30666
+ return lafsError(code, message, "propose.enable");
30913
30667
  }
30914
- return lafsSuccess(result.data ?? { tier2Enabled: false, message: "" }, "propose.enable");
30915
30668
  },
30916
30669
  "propose.disable": async (_params) => {
30917
30670
  const projectRoot = getProjectRoot12();
30918
- const result = await setTier2Enabled(projectRoot, false);
30919
- if (!result.success) {
30920
- return lafsError(
30921
- result.error?.code ?? "E_INTERNAL",
30922
- result.error?.message ?? "Unknown error",
30923
- "propose.disable"
30924
- );
30671
+ try {
30672
+ const data = await sentientProposeDisable(projectRoot, _params);
30673
+ return lafsSuccess(data, "propose.disable");
30674
+ } catch (err) {
30675
+ const message = err instanceof Error ? err.message : String(err);
30676
+ return lafsError("E_INTERNAL", message, "propose.disable");
30925
30677
  }
30926
- return lafsSuccess(result.data ?? { tier2Enabled: true, message: "" }, "propose.disable");
30927
30678
  },
30928
30679
  "allowlist.add": async (params) => {
30929
30680
  const projectRoot = getProjectRoot12();
30930
- const result = await addAllowlistKey(projectRoot, params.pubkey);
30931
- if (!result.success) {
30932
- return lafsError(
30933
- result.error?.code ?? "E_INTERNAL",
30934
- result.error?.message ?? "Unknown error",
30935
- "allowlist.add"
30936
- );
30681
+ try {
30682
+ const data = await sentientAllowlistAdd(projectRoot, params);
30683
+ return lafsSuccess(data, "allowlist.add");
30684
+ } catch (err) {
30685
+ const message = err instanceof Error ? err.message : String(err);
30686
+ return lafsError("E_ALLOWLIST_ADD", message, "allowlist.add");
30937
30687
  }
30938
- return lafsSuccess(result.data ?? { added: "" }, "allowlist.add");
30939
30688
  },
30940
30689
  "allowlist.remove": async (params) => {
30941
30690
  const projectRoot = getProjectRoot12();
30942
- const result = await removeAllowlistKey(projectRoot, params.pubkey);
30943
- if (!result.success) {
30944
- return lafsError(
30945
- result.error?.code ?? "E_INTERNAL",
30946
- result.error?.message ?? "Unknown error",
30947
- "allowlist.remove"
30948
- );
30691
+ try {
30692
+ const data = await sentientAllowlistRemove(projectRoot, params);
30693
+ return lafsSuccess(data, "allowlist.remove");
30694
+ } catch (err) {
30695
+ const code = err.code === "E_ALLOWLIST_KEY_NOT_FOUND" ? "E_ALLOWLIST_KEY_NOT_FOUND" : "E_ALLOWLIST_REMOVE";
30696
+ const message = err instanceof Error ? err.message : String(err);
30697
+ return lafsError(code, message, "allowlist.remove");
30949
30698
  }
30950
- return lafsSuccess(result.data ?? { removed: "" }, "allowlist.remove");
30951
30699
  }
30952
30700
  });
30953
30701
  QUERY_OPS4 = /* @__PURE__ */ new Set(["propose.list", "propose.diff", "allowlist.list"]);
@@ -30961,9 +30709,6 @@ var init_sentient2 = __esm({
30961
30709
  "allowlist.remove"
30962
30710
  ]);
30963
30711
  SentientHandler = class {
30964
- // -----------------------------------------------------------------------
30965
- // Supported operations
30966
- // -----------------------------------------------------------------------
30967
30712
  /** Declared operations for introspection and validation. */
30968
30713
  getSupportedOperations() {
30969
30714
  return {
@@ -30979,9 +30724,6 @@ var init_sentient2 = __esm({
30979
30724
  ]
30980
30725
  };
30981
30726
  }
30982
- // -----------------------------------------------------------------------
30983
- // Query
30984
- // -----------------------------------------------------------------------
30985
30727
  /**
30986
30728
  * Execute a read-only sentient query operation.
30987
30729
  *
@@ -31010,9 +30752,6 @@ var init_sentient2 = __esm({
31010
30752
  return handleErrorResult("query", "sentient", operation, error, startTime);
31011
30753
  }
31012
30754
  }
31013
- // -----------------------------------------------------------------------
31014
- // Mutate
31015
- // -----------------------------------------------------------------------
31016
30755
  /**
31017
30756
  * Execute a state-modifying sentient mutation operation.
31018
30757
  *
@@ -31274,7 +31013,7 @@ var init_session3 = __esm({
31274
31013
  scope: params.scope,
31275
31014
  name: params.name,
31276
31015
  autoStart: params.autoStart,
31277
- startTask: params.startTask ?? params.focus,
31016
+ startTask: params.startTask,
31278
31017
  grade: params.grade
31279
31018
  });
31280
31019
  if (!result.success) {
@@ -31678,7 +31417,7 @@ var init_sticky_engine = __esm({
31678
31417
  });
31679
31418
 
31680
31419
  // packages/cleo/src/dispatch/domains/sticky.ts
31681
- import { getLogger as getLogger15, getProjectRoot as getProjectRoot14, paginate as paginate7 } from "@cleocode/core";
31420
+ import { getLogger as getLogger15, getProjectRoot as getProjectRoot14, paginate as paginate6 } from "@cleocode/core";
31682
31421
  var StickyHandler;
31683
31422
  var init_sticky = __esm({
31684
31423
  "packages/cleo/src/dispatch/domains/sticky.ts"() {
@@ -31715,7 +31454,7 @@ var init_sticky = __esm({
31715
31454
  }
31716
31455
  const limit = params?.limit;
31717
31456
  const offset = params?.offset;
31718
- const page = paginate7(filteredStickies, limit, offset);
31457
+ const page = paginate6(filteredStickies, limit, offset);
31719
31458
  return {
31720
31459
  meta: dispatchMeta("query", "sticky", operation, startTime),
31721
31460
  success: true,
@@ -32227,7 +31966,7 @@ var init_tasks3 = __esm({
32227
31966
  const result = await taskCreate(projectRoot, {
32228
31967
  title: params.title,
32229
31968
  description: typeof params.description === "string" ? params.description : void 0,
32230
- parent: params.parent ?? params.parentId,
31969
+ parent: params.parent,
32231
31970
  depends: params.depends,
32232
31971
  priority: params.priority,
32233
31972
  labels: params.labels,
@@ -32239,8 +31978,8 @@ var init_tasks3 = __esm({
32239
31978
  files: params.files,
32240
31979
  dryRun: params.dryRun,
32241
31980
  parentSearch: params.parentSearch,
32242
- // T944: orthogonal axes — role accepts 'kind' alias for CLI compat
32243
- role: params.role ?? params.kind,
31981
+ // T944: orthogonal axes — role is the canonical wire field (ADR-057 D2)
31982
+ role: params.role,
32244
31983
  scope: params.scope,
32245
31984
  severity: params.severity
32246
31985
  });
@@ -32260,7 +31999,7 @@ var init_tasks3 = __esm({
32260
31999
  description: params.description,
32261
32000
  status: params.status,
32262
32001
  priority: params.priority,
32263
- notes: params.notes ?? params.note,
32002
+ notes: params.notes,
32264
32003
  labels: params.labels,
32265
32004
  addLabels: params.addLabels,
32266
32005
  removeLabels: params.removeLabels,
@@ -32268,7 +32007,8 @@ var init_tasks3 = __esm({
32268
32007
  addDepends: params.addDepends,
32269
32008
  removeDepends: params.removeDepends,
32270
32009
  acceptance: params.acceptance,
32271
- parent: params.parent ?? params.parentId,
32010
+ // ADR-057 D2: canonical wire field — no alias fallback
32011
+ parent: params.parent,
32272
32012
  type: params.type,
32273
32013
  size: params.size,
32274
32014
  // T1014: wire --files through dispatch to engine (parity with add).
@@ -32674,7 +32414,7 @@ var init_tasks3 = __esm({
32674
32414
  });
32675
32415
 
32676
32416
  // packages/cleo/src/dispatch/engines/code-engine.ts
32677
- import { join as join7 } from "node:path";
32417
+ import { join as join6 } from "node:path";
32678
32418
  import { getProjectRoot as getProjectRoot16 } from "@cleocode/core";
32679
32419
  async function codeOutline(params) {
32680
32420
  const { smartOutline } = await import("@cleocode/core/internal");
@@ -32685,7 +32425,7 @@ async function codeOutline(params) {
32685
32425
  error: { code: "E_INVALID_INPUT", message: "file parameter required" }
32686
32426
  };
32687
32427
  const root = getProjectRoot16();
32688
- const absPath = filePath.startsWith("/") ? filePath : join7(root, filePath);
32428
+ const absPath = filePath.startsWith("/") ? filePath : join6(root, filePath);
32689
32429
  return { success: true, data: smartOutline(absPath, root) };
32690
32430
  }
32691
32431
  async function codeSearch(params) {
@@ -32717,7 +32457,7 @@ async function codeUnfold(params) {
32717
32457
  error: { code: "E_INVALID_INPUT", message: "file and symbol parameters required" }
32718
32458
  };
32719
32459
  const root = getProjectRoot16();
32720
- const absPath = filePath.startsWith("/") ? filePath : join7(root, filePath);
32460
+ const absPath = filePath.startsWith("/") ? filePath : join6(root, filePath);
32721
32461
  return { success: true, data: smartUnfold(absPath, symbol, root) };
32722
32462
  }
32723
32463
  async function codeParse(params) {
@@ -32729,7 +32469,7 @@ async function codeParse(params) {
32729
32469
  error: { code: "E_INVALID_INPUT", message: "file parameter required" }
32730
32470
  };
32731
32471
  const root = getProjectRoot16();
32732
- const absPath = filePath.startsWith("/") ? filePath : join7(root, filePath);
32472
+ const absPath = filePath.startsWith("/") ? filePath : join6(root, filePath);
32733
32473
  return { success: true, data: parseFile(absPath, root) };
32734
32474
  }
32735
32475
  var init_code_engine = __esm({
@@ -32755,7 +32495,7 @@ import {
32755
32495
  installSkill,
32756
32496
  removeSkill
32757
32497
  } from "@cleocode/caamp";
32758
- import { AdapterManager, collectDiagnostics, paginate as paginate8 } from "@cleocode/core/internal";
32498
+ import { AdapterManager, collectDiagnostics, paginate as paginate7 } from "@cleocode/core/internal";
32759
32499
  function toolsIssueDiagnostics() {
32760
32500
  try {
32761
32501
  const diag = collectDiagnostics();
@@ -32767,7 +32507,7 @@ function toolsIssueDiagnostics() {
32767
32507
  async function toolsSkillList(limit, offset) {
32768
32508
  try {
32769
32509
  const skills = await discoverSkills(getCanonicalSkillsDir());
32770
- const page = paginate8(skills, limit, offset);
32510
+ const page = paginate7(skills, limit, offset);
32771
32511
  return {
32772
32512
  success: true,
32773
32513
  data: {
@@ -32888,7 +32628,7 @@ function toolsSkillCatalogProtocols(limit, offset) {
32888
32628
  name,
32889
32629
  path: catalog.getProtocolPath(name) ?? null
32890
32630
  }));
32891
- const page = paginate8(details, limit, offset);
32631
+ const page = paginate7(details, limit, offset);
32892
32632
  return {
32893
32633
  success: true,
32894
32634
  data: {
@@ -32917,7 +32657,7 @@ function toolsSkillCatalogProfiles(limit, offset) {
32917
32657
  skills: profile?.skills ?? []
32918
32658
  };
32919
32659
  });
32920
- const page = paginate8(profiles, limit, offset);
32660
+ const page = paginate7(profiles, limit, offset);
32921
32661
  return {
32922
32662
  success: true,
32923
32663
  data: {
@@ -32940,7 +32680,7 @@ function toolsSkillCatalogResources(limit, offset) {
32940
32680
  name,
32941
32681
  path: catalog.getSharedResourcePath(name) ?? null
32942
32682
  }));
32943
- const page = paginate8(details, limit, offset);
32683
+ const page = paginate7(details, limit, offset);
32944
32684
  return {
32945
32685
  success: true,
32946
32686
  data: {
@@ -33091,7 +32831,7 @@ async function toolsSkillRefresh(projectRoot) {
33091
32831
  function toolsProviderList(limit, offset) {
33092
32832
  try {
33093
32833
  const providers = getAllProviders();
33094
- const page = paginate8(providers, limit, offset);
32834
+ const page = paginate7(providers, limit, offset);
33095
32835
  return {
33096
32836
  success: true,
33097
32837
  data: {
@@ -33901,7 +33641,7 @@ var init_defaults = __esm({
33901
33641
 
33902
33642
  // packages/cleo/src/dispatch/lib/config-loader.ts
33903
33643
  import { existsSync as existsSync4, readFileSync as readFileSync7 } from "fs";
33904
- import { join as join8 } from "path";
33644
+ import { join as join7 } from "path";
33905
33645
  function loadFromEnv(key) {
33906
33646
  const envKey = `${ENV_PREFIX}${key.toUpperCase()}`;
33907
33647
  return process.env[envKey];
@@ -33922,7 +33662,7 @@ function parseEnvValue(key, value) {
33922
33662
  }
33923
33663
  function loadFromFile(projectRoot) {
33924
33664
  const root = projectRoot || process.cwd();
33925
- const configPath = join8(root, CLEO_DIR_NAME, CONFIG_JSON);
33665
+ const configPath = join7(root, CLEO_DIR_NAME, CONFIG_JSON);
33926
33666
  if (!existsSync4(configPath)) {
33927
33667
  return {};
33928
33668
  }
@@ -34270,11 +34010,11 @@ var init_security = __esm({
34270
34010
  });
34271
34011
 
34272
34012
  // packages/cleo/src/dispatch/middleware/sanitizer.ts
34273
- function createSanitizer(getProjectRoot32) {
34013
+ function createSanitizer(getProjectRoot33) {
34274
34014
  return async (req, next) => {
34275
34015
  if (req.params) {
34276
34016
  try {
34277
- const root = getProjectRoot32 ? getProjectRoot32() : void 0;
34017
+ const root = getProjectRoot33 ? getProjectRoot33() : void 0;
34278
34018
  req.params = sanitizeParams(req.params, root, {
34279
34019
  domain: req.domain,
34280
34020
  operation: req.operation
@@ -34396,7 +34136,7 @@ __export(cli_exports, {
34396
34136
  import { randomUUID as randomUUID5 } from "node:crypto";
34397
34137
  import { existsSync as existsSync5 } from "node:fs";
34398
34138
  import { createRequire as createRequire2 } from "node:module";
34399
- import { dirname as dirname4, join as join9 } from "node:path";
34139
+ import { dirname as dirname4, join as join8 } from "node:path";
34400
34140
  import { fileURLToPath as fileURLToPath2 } from "node:url";
34401
34141
  import { catalog as catalog2, registerSkillLibraryFromPath } from "@cleocode/caamp";
34402
34142
  import { autoRecordDispatchTokenUsage, getProjectRoot as getProjectRoot18, hooks } from "@cleocode/core/internal";
@@ -34408,16 +34148,16 @@ function ensureCaampLibrary() {
34408
34148
  const req = createRequire2(import.meta.url);
34409
34149
  const skillsPkgJson = req.resolve("@cleocode/skills/package.json");
34410
34150
  const candidate = dirname4(skillsPkgJson);
34411
- if (existsSync5(join9(candidate, "skills.json"))) {
34151
+ if (existsSync5(join8(candidate, "skills.json"))) {
34412
34152
  skillsRoot = candidate;
34413
34153
  }
34414
34154
  } catch {
34415
34155
  }
34416
34156
  if (!skillsRoot) {
34417
34157
  const thisFile = fileURLToPath2(import.meta.url);
34418
- const packageRoot = join9(dirname4(thisFile), "..", "..", "..", "..", "..");
34419
- const candidate = join9(packageRoot, "packages", "skills");
34420
- if (existsSync5(join9(candidate, "skills.json"))) {
34158
+ const packageRoot = join8(dirname4(thisFile), "..", "..", "..", "..", "..");
34159
+ const candidate = join8(packageRoot, "packages", "skills");
34160
+ if (existsSync5(join8(candidate, "skills.json"))) {
34421
34161
  skillsRoot = candidate;
34422
34162
  }
34423
34163
  }
@@ -34637,7 +34377,7 @@ var init_cli = __esm({
34637
34377
 
34638
34378
  // packages/cleo/src/cli/index.ts
34639
34379
  import { readFileSync as readFileSync15 } from "node:fs";
34640
- import { dirname as dirname10, join as join22 } from "node:path";
34380
+ import { dirname as dirname10, join as join21 } from "node:path";
34641
34381
  import { fileURLToPath as fileURLToPath3 } from "node:url";
34642
34382
  import {
34643
34383
  detectAndRemoveLegacyGlobalFiles,
@@ -34646,7 +34386,7 @@ import {
34646
34386
  ensureGlobalSignaldockDb as ensureGlobalSignaldockDb2,
34647
34387
  getGlobalSalt,
34648
34388
  getLogger as getLogger19,
34649
- getProjectRoot as getProjectRoot31,
34389
+ getProjectRoot as getProjectRoot32,
34650
34390
  migrateSignaldockToConduit,
34651
34391
  needsSignaldockToConduitMigration,
34652
34392
  validateGlobalSalt
@@ -35656,7 +35396,8 @@ var addCommand = defineCommand({
35656
35396
  if (args["dry-run"] !== void 0) params["dryRun"] = args["dry-run"];
35657
35397
  if (args["parent-search"] !== void 0) params["parentSearch"] = args["parent-search"];
35658
35398
  if (args.role !== void 0) params["role"] = args.role;
35659
- if (args.kind !== void 0) params["kind"] = args.kind;
35399
+ if (args.kind !== void 0)
35400
+ params["role"] = params["role"] ?? args.kind;
35660
35401
  if (args.scope !== void 0) params["scope"] = args.scope;
35661
35402
  if (args.severity !== void 0) params["severity"] = args.severity;
35662
35403
  if (!params["parent"] && params["type"] !== "epic") {
@@ -36373,9 +36114,9 @@ var registerCommand = defineCommand({
36373
36114
  isActive: true
36374
36115
  });
36375
36116
  const { existsSync: existsSync12, mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("node:fs");
36376
- const { join: join23 } = await import("node:path");
36377
- const cantDir = join23(CLEO_DIR_NAME, AGENTS_SUBDIR);
36378
- const cantPath = join23(cantDir, `${agentId}.cant`);
36117
+ const { join: join22 } = await import("node:path");
36118
+ const cantDir = join22(CLEO_DIR_NAME, AGENTS_SUBDIR);
36119
+ const cantPath = join22(cantDir, `${agentId}.cant`);
36379
36120
  let cantScaffolded = false;
36380
36121
  if (!existsSync12(cantPath)) {
36381
36122
  mkdirSync5(cantDir, { recursive: true });
@@ -36557,7 +36298,7 @@ var startCommand = defineCommand({
36557
36298
  const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
36558
36299
  const { createRuntime } = await import("@cleocode/runtime");
36559
36300
  const { existsSync: existsSync12, readFileSync: readFileSync16 } = await import("node:fs");
36560
- const { join: join23 } = await import("node:path");
36301
+ const { join: join22 } = await import("node:path");
36561
36302
  await getDb3();
36562
36303
  const registry = new AgentRegistryAccessor(process.cwd());
36563
36304
  const credential = await registry.get(args.agentId);
@@ -36577,7 +36318,7 @@ var startCommand = defineCommand({
36577
36318
  }
36578
36319
  let profile = null;
36579
36320
  let cantValidation = null;
36580
- const cantPath = args.cant ?? join23(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
36321
+ const cantPath = args.cant ?? join22(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
36581
36322
  if (existsSync12(cantPath)) {
36582
36323
  profile = readFileSync16(cantPath, "utf-8");
36583
36324
  try {
@@ -37103,7 +36844,7 @@ var workCommand = defineCommand({
37103
36844
  const { AgentRegistryAccessor, getDb: getDb3 } = await import("@cleocode/core/internal");
37104
36845
  const { createRuntime } = await import("@cleocode/runtime");
37105
36846
  const { existsSync: existsSync12 } = await import("node:fs");
37106
- const { join: join23 } = await import("node:path");
36847
+ const { join: join22 } = await import("node:path");
37107
36848
  const { execFile: execFile2 } = await import("node:child_process");
37108
36849
  const { promisify: promisify2 } = await import("node:util");
37109
36850
  const execFileAsync = promisify2(execFile2);
@@ -37123,7 +36864,7 @@ var workCommand = defineCommand({
37123
36864
  }
37124
36865
  await registry.update(args.agentId, { isActive: true });
37125
36866
  await registry.markUsed(args.agentId);
37126
- const cantPath = join23(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
36867
+ const cantPath = join22(CLEO_DIR_NAME, AGENTS_SUBDIR, `${args.agentId}.cant`);
37127
36868
  const hasProfile = existsSync12(cantPath);
37128
36869
  const runtime = await createRuntime(registry, {
37129
36870
  agentId: args.agentId,
@@ -37975,7 +37716,7 @@ var installCommand = defineCommand({
37975
37716
  let tempDir = null;
37976
37717
  try {
37977
37718
  const { existsSync: existsSync12, mkdirSync: mkdirSync5, statSync, readdirSync: readdirSync4, copyFileSync } = await import("node:fs");
37978
- const { join: join23, basename: basename2, resolve: resolve5, extname } = await import("node:path");
37719
+ const { join: join22, basename: basename2, resolve: resolve5, extname } = await import("node:path");
37979
37720
  const { tmpdir } = await import("node:os");
37980
37721
  const resolvedPath = resolve5(args.path);
37981
37722
  if (!existsSync12(resolvedPath)) {
@@ -37999,7 +37740,7 @@ var installCommand = defineCommand({
37999
37740
  cantPath = resolvedPath;
38000
37741
  } else if (stat2.isFile() && ext === ".cantz") {
38001
37742
  const { execFileSync: execFileSync7 } = await import("node:child_process");
38002
- tempDir = join23(tmpdir(), `cleo-agent-install-${Date.now()}`);
37743
+ tempDir = join22(tmpdir(), `cleo-agent-install-${Date.now()}`);
38003
37744
  mkdirSync5(tempDir, { recursive: true });
38004
37745
  try {
38005
37746
  execFileSync7("unzip", ["-o", "-q", resolvedPath, "-d", tempDir], {
@@ -38021,7 +37762,7 @@ var installCommand = defineCommand({
38021
37762
  return;
38022
37763
  }
38023
37764
  const topLevel = readdirSync4(tempDir).filter(
38024
- (entry) => statSync(join23(tempDir, entry)).isDirectory()
37765
+ (entry) => statSync(join22(tempDir, entry)).isDirectory()
38025
37766
  );
38026
37767
  if (topLevel.length !== 1) {
38027
37768
  cliOutput(
@@ -38038,7 +37779,7 @@ var installCommand = defineCommand({
38038
37779
  return;
38039
37780
  }
38040
37781
  const agentName = topLevel[0];
38041
- const personaPath = join23(tempDir, agentName, "persona.cant");
37782
+ const personaPath = join22(tempDir, agentName, "persona.cant");
38042
37783
  if (!existsSync12(personaPath)) {
38043
37784
  cliOutput(
38044
37785
  {
@@ -38053,11 +37794,11 @@ var installCommand = defineCommand({
38053
37794
  process.exitCode = 6;
38054
37795
  return;
38055
37796
  }
38056
- cantPath = join23(tempDir, `${agentName}.cant`);
37797
+ cantPath = join22(tempDir, `${agentName}.cant`);
38057
37798
  copyFileSync(personaPath, cantPath);
38058
37799
  } else if (stat2.isDirectory()) {
38059
37800
  const agentName = basename2(resolvedPath);
38060
- const personaPath = join23(resolvedPath, "persona.cant");
37801
+ const personaPath = join22(resolvedPath, "persona.cant");
38061
37802
  if (!existsSync12(personaPath)) {
38062
37803
  cliOutput(
38063
37804
  {
@@ -38072,9 +37813,9 @@ var installCommand = defineCommand({
38072
37813
  process.exitCode = 6;
38073
37814
  return;
38074
37815
  }
38075
- tempDir = join23(tmpdir(), `cleo-agent-install-${Date.now()}`);
37816
+ tempDir = join22(tmpdir(), `cleo-agent-install-${Date.now()}`);
38076
37817
  mkdirSync5(tempDir, { recursive: true });
38077
- cantPath = join23(tempDir, `${agentName}.cant`);
37818
+ cantPath = join22(tempDir, `${agentName}.cant`);
38078
37819
  copyFileSync(personaPath, cantPath);
38079
37820
  } else {
38080
37821
  cliOutput(
@@ -38219,8 +37960,8 @@ var packCommand = defineCommand({
38219
37960
  process.exitCode = 4;
38220
37961
  return;
38221
37962
  }
38222
- const { join: join23 } = await import("node:path");
38223
- const personaPath = join23(resolvedDir, "persona.cant");
37963
+ const { join: join22 } = await import("node:path");
37964
+ const personaPath = join22(resolvedDir, "persona.cant");
38224
37965
  if (!existsSync12(personaPath)) {
38225
37966
  cliOutput(
38226
37967
  {
@@ -38268,7 +38009,7 @@ var packCommand = defineCommand({
38268
38009
  if (entry.isFile()) {
38269
38010
  fileCount++;
38270
38011
  } else if (entry.isDirectory()) {
38271
- countFiles(join23(dirPath, entry.name));
38012
+ countFiles(join22(dirPath, entry.name));
38272
38013
  }
38273
38014
  }
38274
38015
  };
@@ -38338,7 +38079,7 @@ var createCommand = defineCommand({
38338
38079
  async run({ args }) {
38339
38080
  try {
38340
38081
  const { existsSync: existsSync12, mkdirSync: mkdirSync5, writeFileSync: writeFileSync5 } = await import("node:fs");
38341
- const { join: join23 } = await import("node:path");
38082
+ const { join: join22 } = await import("node:path");
38342
38083
  const { homedir: homedir6 } = await import("node:os");
38343
38084
  const name = args.name;
38344
38085
  const role = args.role;
@@ -38398,12 +38139,12 @@ var createCommand = defineCommand({
38398
38139
  let targetRoot;
38399
38140
  if (isGlobal) {
38400
38141
  const home = homedir6();
38401
- const xdgData = process.env["XDG_DATA_HOME"] ?? join23(home, ".local", "share");
38402
- targetRoot = join23(xdgData, "cleo", "cant", "agents");
38142
+ const xdgData = process.env["XDG_DATA_HOME"] ?? join22(home, ".local", "share");
38143
+ targetRoot = join22(xdgData, "cleo", "cant", "agents");
38403
38144
  } else {
38404
- targetRoot = join23(process.cwd(), CLEO_DIR_NAME, CANT_AGENTS_SUBDIR);
38145
+ targetRoot = join22(process.cwd(), CLEO_DIR_NAME, CANT_AGENTS_SUBDIR);
38405
38146
  }
38406
- const agentDir = join23(targetRoot, name);
38147
+ const agentDir = join22(targetRoot, name);
38407
38148
  if (existsSync12(agentDir)) {
38408
38149
  cliOutput(
38409
38150
  {
@@ -38428,29 +38169,29 @@ var createCommand = defineCommand({
38428
38169
  domain,
38429
38170
  parent
38430
38171
  });
38431
- writeFileSync5(join23(agentDir, "persona.cant"), personaContent, "utf-8");
38172
+ writeFileSync5(join22(agentDir, "persona.cant"), personaContent, "utf-8");
38432
38173
  const manifest = generateManifest({ name, role, tier, domain });
38433
38174
  writeFileSync5(
38434
- join23(agentDir, "manifest.json"),
38175
+ join22(agentDir, "manifest.json"),
38435
38176
  `${JSON.stringify(manifest, null, 2)}
38436
38177
  `,
38437
38178
  "utf-8"
38438
38179
  );
38439
38180
  const createdFiles = [
38440
- join23(agentDir, "persona.cant"),
38441
- join23(agentDir, "manifest.json")
38181
+ join22(agentDir, "persona.cant"),
38182
+ join22(agentDir, "manifest.json")
38442
38183
  ];
38443
38184
  if (team) {
38444
38185
  const teamConfigContent = generateTeamConfig(name, role, team);
38445
- writeFileSync5(join23(agentDir, "team-config.cant"), teamConfigContent, "utf-8");
38446
- createdFiles.push(join23(agentDir, "team-config.cant"));
38186
+ writeFileSync5(join22(agentDir, "team-config.cant"), teamConfigContent, "utf-8");
38187
+ createdFiles.push(join22(agentDir, "team-config.cant"));
38447
38188
  }
38448
38189
  if (seedBrain) {
38449
- const expertiseDir = join23(agentDir, "expertise");
38190
+ const expertiseDir = join22(agentDir, "expertise");
38450
38191
  mkdirSync5(expertiseDir, { recursive: true });
38451
38192
  const seedContent = generateMentalModelSeed(name, role, domain);
38452
- writeFileSync5(join23(expertiseDir, "mental-model-seed.md"), seedContent, "utf-8");
38453
- createdFiles.push(join23(expertiseDir, "mental-model-seed.md"));
38193
+ writeFileSync5(join22(expertiseDir, "mental-model-seed.md"), seedContent, "utf-8");
38194
+ createdFiles.push(join22(expertiseDir, "mental-model-seed.md"));
38454
38195
  try {
38455
38196
  const { execFile: execFile2 } = await import("node:child_process");
38456
38197
  const { promisify: promisify2 } = await import("node:util");
@@ -38549,7 +38290,7 @@ var mintCommand = defineCommand({
38549
38290
  async run({ args }) {
38550
38291
  try {
38551
38292
  const { existsSync: existsSync12, readFileSync: readFileSync16, mkdirSync: mkdirSync5 } = await import("node:fs");
38552
- const { resolve: resolve5, join: join23 } = await import("node:path");
38293
+ const { resolve: resolve5, join: join22 } = await import("node:path");
38553
38294
  const specPath = resolve5(args.spec);
38554
38295
  if (!existsSync12(specPath)) {
38555
38296
  const errEnv = {
@@ -38568,7 +38309,7 @@ var mintCommand = defineCommand({
38568
38309
  }
38569
38310
  const specContent = readFileSync16(specPath, "utf-8");
38570
38311
  const projectRoot = process.cwd();
38571
- const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join23(projectRoot, ".cleo", "cant", "agents");
38312
+ const outputDir = args["output-dir"] ? resolve5(args["output-dir"]) : join22(projectRoot, ".cleo", "cant", "agents");
38572
38313
  mkdirSync5(outputDir, { recursive: true });
38573
38314
  if (args["dry-run"]) {
38574
38315
  const preview = {
@@ -39867,9 +39608,9 @@ var exportCommand = defineCommand({
39867
39608
  },
39868
39609
  async run({ args }) {
39869
39610
  const scope = args.scope;
39870
- const { packBundle, getProjectRoot: getProjectRoot32 } = await import("@cleocode/core/internal");
39611
+ const { packBundle, getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
39871
39612
  const includesProject = scope === "project" || scope === "all";
39872
- const projectRoot = includesProject ? getProjectRoot32() : void 0;
39613
+ const projectRoot = includesProject ? getProjectRoot33() : void 0;
39873
39614
  let passphrase;
39874
39615
  if (args.encrypt === true) {
39875
39616
  passphrase = process.env["CLEO_BACKUP_PASSPHRASE"];
@@ -40681,7 +40422,7 @@ var briefingCommand = defineCommand({
40681
40422
  // packages/cleo/src/cli/commands/bug.ts
40682
40423
  import { existsSync as existsSync7 } from "node:fs";
40683
40424
  import { appendFile as appendFile2, mkdir as mkdir2, readFile as readFile2 } from "node:fs/promises";
40684
- import { dirname as dirname5, join as join10 } from "node:path";
40425
+ import { dirname as dirname5, join as join9 } from "node:path";
40685
40426
  import { getCleoDirAbsolute as getCleoDirAbsolute2, getCleoIdentity, getConfigPath, signAuditLine } from "@cleocode/core";
40686
40427
  init_cli();
40687
40428
  var SEVERITY_MAP = {
@@ -40734,7 +40475,7 @@ async function appendSignedBugSeverity(record) {
40734
40475
  const sig = await signAuditLine(id, canonical);
40735
40476
  const line = `${JSON.stringify({ ...full, _sig: sig })}
40736
40477
  `;
40737
- const auditPath = join10(getCleoDirAbsolute2(), "audit", "bug-severity.jsonl");
40478
+ const auditPath = join9(getCleoDirAbsolute2(), "audit", "bug-severity.jsonl");
40738
40479
  await mkdir2(dirname5(auditPath), { recursive: true });
40739
40480
  await appendFile2(auditPath, line, { encoding: "utf-8" });
40740
40481
  }
@@ -40848,7 +40589,7 @@ var cancelCommand = defineCommand({
40848
40589
 
40849
40590
  // packages/cleo/src/cli/commands/cant.ts
40850
40591
  import { existsSync as existsSync8, mkdirSync as mkdirSync2, readFileSync as readFileSync9, writeFileSync as writeFileSync2 } from "node:fs";
40851
- import { dirname as dirname6, isAbsolute, join as join11, resolve as resolve3 } from "node:path";
40592
+ import { dirname as dirname6, isAbsolute, join as join10, resolve as resolve3 } from "node:path";
40852
40593
  init_renderers();
40853
40594
  function resolveFilePath(file) {
40854
40595
  return isAbsolute(file) ? file : resolve3(process.cwd(), file);
@@ -41008,7 +40749,7 @@ var cantMigrateCommand = defineCommand({
41008
40749
  const projectRoot = process.cwd();
41009
40750
  let written = 0;
41010
40751
  for (const outputFile of result.outputFiles) {
41011
- const outputPath = isAbsolute(outputFile.path) ? outputFile.path : join11(projectRoot, outputFile.path);
40752
+ const outputPath = isAbsolute(outputFile.path) ? outputFile.path : join10(projectRoot, outputFile.path);
41012
40753
  mkdirSync2(dirname6(outputPath), { recursive: true });
41013
40754
  writeFileSync2(outputPath, outputFile.content, "utf-8");
41014
40755
  written++;
@@ -41607,9 +41348,9 @@ var codeCommand = defineCommand({
41607
41348
  async run({ args }) {
41608
41349
  await requireTreeSitter();
41609
41350
  const { smartOutline } = await import("@cleocode/core/internal");
41610
- const { join: join23 } = await import("node:path");
41351
+ const { join: join22 } = await import("node:path");
41611
41352
  const root = process.cwd();
41612
- const absPath = args.file.startsWith("/") ? args.file : join23(root, args.file);
41353
+ const absPath = args.file.startsWith("/") ? args.file : join22(root, args.file);
41613
41354
  const result = smartOutline(absPath, root);
41614
41355
  if (result.errors.length > 0 && result.symbols.length === 0) {
41615
41356
  console.error(`Error: ${result.errors.join(", ")}`);
@@ -41700,9 +41441,9 @@ var codeCommand = defineCommand({
41700
41441
  async run({ args }) {
41701
41442
  await requireTreeSitter();
41702
41443
  const { smartUnfold } = await import("@cleocode/core/internal");
41703
- const { join: join23 } = await import("node:path");
41444
+ const { join: join22 } = await import("node:path");
41704
41445
  const root = process.cwd();
41705
- const absPath = args.file.startsWith("/") ? args.file : join23(root, args.file);
41446
+ const absPath = args.file.startsWith("/") ? args.file : join22(root, args.file);
41706
41447
  const result = smartUnfold(absPath, args.symbol, root);
41707
41448
  if (!result.found) {
41708
41449
  console.error(`Symbol "${args.symbol}" not found in ${args.file}`);
@@ -42745,7 +42486,7 @@ var currentCommand = defineCommand({
42745
42486
 
42746
42487
  // packages/cleo/src/cli/commands/daemon.ts
42747
42488
  import { homedir as homedir2 } from "node:os";
42748
- import { join as join12 } from "node:path";
42489
+ import { join as join11 } from "node:path";
42749
42490
  import { getGCDaemonStatus, spawnGCDaemon, stopGCDaemon } from "@cleocode/core/gc/daemon.js";
42750
42491
  async function showDaemonStatus(cleoDir, json2) {
42751
42492
  try {
@@ -42798,7 +42539,7 @@ var startCommand3 = defineCommand({
42798
42539
  }
42799
42540
  },
42800
42541
  async run({ args }) {
42801
- const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
42542
+ const cleoDir = args["cleo-dir"] ?? join11(homedir2(), ".cleo");
42802
42543
  const jsonMode = args.json ?? false;
42803
42544
  try {
42804
42545
  const status = await getGCDaemonStatus(cleoDir);
@@ -42829,7 +42570,7 @@ var startCommand3 = defineCommand({
42829
42570
  } else {
42830
42571
  process.stdout.write(`GC daemon started (PID ${pid})
42831
42572
  `);
42832
- process.stdout.write(`Logs: ${join12(cleoDir, "logs", "gc.log")}
42573
+ process.stdout.write(`Logs: ${join11(cleoDir, "logs", "gc.log")}
42833
42574
  `);
42834
42575
  }
42835
42576
  } catch (err) {
@@ -42858,7 +42599,7 @@ var stopCommand3 = defineCommand({
42858
42599
  }
42859
42600
  },
42860
42601
  async run({ args }) {
42861
- const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
42602
+ const cleoDir = args["cleo-dir"] ?? join11(homedir2(), ".cleo");
42862
42603
  const jsonMode = args.json ?? false;
42863
42604
  try {
42864
42605
  const stopResult = await stopGCDaemon(cleoDir);
@@ -42904,7 +42645,7 @@ var statusCommand4 = defineCommand({
42904
42645
  }
42905
42646
  },
42906
42647
  async run({ args }) {
42907
- const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
42648
+ const cleoDir = args["cleo-dir"] ?? join11(homedir2(), ".cleo");
42908
42649
  await showDaemonStatus(cleoDir, args.json ?? false);
42909
42650
  }
42910
42651
  });
@@ -42930,7 +42671,7 @@ var daemonCommand = defineCommand({
42930
42671
  },
42931
42672
  async run({ args, cmd, rawArgs }) {
42932
42673
  if (isSubCommandDispatch(rawArgs, cmd.subCommands)) return;
42933
- const cleoDir = args["cleo-dir"] ?? join12(homedir2(), ".cleo");
42674
+ const cleoDir = args["cleo-dir"] ?? join11(homedir2(), ".cleo");
42934
42675
  await showDaemonStatus(cleoDir, args.json ?? false);
42935
42676
  }
42936
42677
  });
@@ -43282,13 +43023,13 @@ var detectCommand2 = defineCommand({
43282
43023
  // packages/cleo/src/cli/commands/detect-drift.ts
43283
43024
  init_src();
43284
43025
  import { existsSync as existsSync9, readdirSync as readdirSync2, readFileSync as readFileSync11 } from "node:fs";
43285
- import { dirname as dirname7, join as join13 } from "node:path";
43026
+ import { dirname as dirname7, join as join12 } from "node:path";
43286
43027
  init_paths();
43287
43028
  init_renderers();
43288
43029
  function findProjectRoot() {
43289
43030
  let currentDir = process.cwd();
43290
43031
  while (currentDir !== "/") {
43291
- if (existsSync9(join13(currentDir, "package.json"))) {
43032
+ if (existsSync9(join12(currentDir, "package.json"))) {
43292
43033
  return currentDir;
43293
43034
  }
43294
43035
  const parent = dirname7(currentDir);
@@ -43304,8 +43045,8 @@ var detectDriftCommand = defineCommand({
43304
43045
  },
43305
43046
  async run() {
43306
43047
  const projectRoot = findProjectRoot();
43307
- const isCleoRepo = existsSync9(join13(projectRoot, "packages", "cleo", "src"));
43308
- const cleoSrcRoot = isCleoRepo ? join13(projectRoot, "packages", "cleo", "src") : join13(projectRoot, "src");
43048
+ const isCleoRepo = existsSync9(join12(projectRoot, "packages", "cleo", "src"));
43049
+ const cleoSrcRoot = isCleoRepo ? join12(projectRoot, "packages", "cleo", "src") : join12(projectRoot, "src");
43309
43050
  const safeRead = (filePath) => {
43310
43051
  try {
43311
43052
  return readFileSync11(filePath, "utf-8");
@@ -43319,7 +43060,7 @@ var detectDriftCommand = defineCommand({
43319
43060
  checks: [],
43320
43061
  recommendations: []
43321
43062
  };
43322
- const injPath = join13(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
43063
+ const injPath = join12(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
43323
43064
  if (existsSync9(injPath)) {
43324
43065
  const content = safeRead(injPath);
43325
43066
  userResult.checks.push({
@@ -43371,9 +43112,9 @@ var detectDriftCommand = defineCommand({
43371
43112
  }
43372
43113
  };
43373
43114
  try {
43374
- const specPath = join13(projectRoot, "docs", "specs", "CLEO-OPERATION-CONSTITUTION.md");
43375
- const registryPath = join13(cleoSrcRoot, "dispatch", "registry.ts");
43376
- const dispatchDomainsDir = join13(cleoSrcRoot, "dispatch", "domains");
43115
+ const specPath = join12(projectRoot, "docs", "specs", "CLEO-OPERATION-CONSTITUTION.md");
43116
+ const registryPath = join12(cleoSrcRoot, "dispatch", "registry.ts");
43117
+ const dispatchDomainsDir = join12(cleoSrcRoot, "dispatch", "domains");
43377
43118
  if (!existsSync9(specPath)) {
43378
43119
  addCheck("Gateway-to-spec sync", "fail", "CLEO-OPERATION-CONSTITUTION.md missing", [
43379
43120
  {
@@ -43442,8 +43183,8 @@ var detectDriftCommand = defineCommand({
43442
43183
  ]);
43443
43184
  }
43444
43185
  try {
43445
- const cliDir = join13(cleoSrcRoot, "cli", "commands");
43446
- const coreDir = isCleoRepo ? join13(projectRoot, "packages", "core", "src") : join13(projectRoot, "src", "core");
43186
+ const cliDir = join12(cleoSrcRoot, "cli", "commands");
43187
+ const coreDir = isCleoRepo ? join12(projectRoot, "packages", "core", "src") : join12(projectRoot, "src", "core");
43447
43188
  if (!existsSync9(cliDir)) {
43448
43189
  addCheck("CLI-to-core sync", "fail", "CLI commands directory missing", [
43449
43190
  {
@@ -43470,7 +43211,7 @@ var detectDriftCommand = defineCommand({
43470
43211
  addCheck("CLI-to-core sync", "fail", `Error: ${getErrorMessage(e)}`);
43471
43212
  }
43472
43213
  try {
43473
- const domainsDir = join13(cleoSrcRoot, "dispatch", "domains");
43214
+ const domainsDir = join12(cleoSrcRoot, "dispatch", "domains");
43474
43215
  if (!existsSync9(domainsDir)) {
43475
43216
  addCheck("Domain handler coverage", "fail", "Dispatch domains directory missing", [
43476
43217
  {
@@ -43488,7 +43229,7 @@ var detectDriftCommand = defineCommand({
43488
43229
  addCheck("Domain handler coverage", "fail", `Error: ${getErrorMessage(e)}`);
43489
43230
  }
43490
43231
  try {
43491
- const matrixPath = join13(cleoSrcRoot, "dispatch", "lib", "capability-matrix.ts");
43232
+ const matrixPath = join12(cleoSrcRoot, "dispatch", "lib", "capability-matrix.ts");
43492
43233
  if (!existsSync9(matrixPath)) {
43493
43234
  addCheck("Capability matrix", "fail", "Capability matrix missing", [
43494
43235
  {
@@ -43505,7 +43246,7 @@ var detectDriftCommand = defineCommand({
43505
43246
  addCheck("Capability matrix", "fail", `Error: ${getErrorMessage(e)}`);
43506
43247
  }
43507
43248
  try {
43508
- const schemaPath = join13(projectRoot, "src", "store", "schema.ts");
43249
+ const schemaPath = join12(projectRoot, "src", "store", "schema.ts");
43509
43250
  if (!existsSync9(schemaPath)) {
43510
43251
  addCheck("Schema validation", "fail", "Schema definition missing", [
43511
43252
  {
@@ -43540,8 +43281,8 @@ var detectDriftCommand = defineCommand({
43540
43281
  addCheck("Schema validation", "fail", `Error: ${getErrorMessage(e)}`);
43541
43282
  }
43542
43283
  try {
43543
- const visionPath = join13(projectRoot, "docs", "concepts", "CLEO-VISION.md");
43544
- const specPath = join13(projectRoot, "docs", "specs", "CLEO-PORTABLE-PROJECT-BRAIN-SPEC.md");
43284
+ const visionPath = join12(projectRoot, "docs", "concepts", "CLEO-VISION.md");
43285
+ const specPath = join12(projectRoot, "docs", "specs", "CLEO-PORTABLE-PROJECT-BRAIN-SPEC.md");
43545
43286
  const issues = [];
43546
43287
  if (!existsSync9(visionPath)) {
43547
43288
  issues.push({
@@ -43596,7 +43337,7 @@ var detectDriftCommand = defineCommand({
43596
43337
  addCheck("Canonical identity", "fail", `Error: ${getErrorMessage(e)}`);
43597
43338
  }
43598
43339
  try {
43599
- const injectionPath = join13(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
43340
+ const injectionPath = join12(projectRoot, CLEO_DIR_NAME, TEMPLATES_SUBDIR, CLEO_INJECTION_MD);
43600
43341
  if (!existsSync9(injectionPath)) {
43601
43342
  addCheck("Agent injection", "fail", "Agent injection template missing", [
43602
43343
  {
@@ -43626,7 +43367,7 @@ var detectDriftCommand = defineCommand({
43626
43367
  addCheck("Agent injection", "fail", `Error: ${getErrorMessage(e)}`);
43627
43368
  }
43628
43369
  try {
43629
- const exitCodesPath = join13(cleoSrcRoot, "dispatch", "lib", "exit-codes.ts");
43370
+ const exitCodesPath = join12(cleoSrcRoot, "dispatch", "lib", "exit-codes.ts");
43630
43371
  if (!existsSync9(exitCodesPath)) {
43631
43372
  addCheck("Exit codes", "fail", "Exit codes definition missing", [
43632
43373
  {
@@ -43759,7 +43500,7 @@ var diagnosticsCommand = defineCommand({
43759
43500
  // packages/cleo/src/cli/commands/docs.ts
43760
43501
  init_src();
43761
43502
  import { mkdir as mkdir3, readdir, readFile as readFile3, writeFile } from "node:fs/promises";
43762
- import { dirname as dirname8, isAbsolute as isAbsolute2, join as join14, resolve as resolve4 } from "node:path";
43503
+ import { dirname as dirname8, isAbsolute as isAbsolute2, join as join13, resolve as resolve4 } from "node:path";
43763
43504
  import {
43764
43505
  buildDocsGraph,
43765
43506
  CleoError as CleoError3,
@@ -43777,7 +43518,7 @@ import {
43777
43518
  init_cli();
43778
43519
  init_renderers();
43779
43520
  async function getScriptNames(projectRoot) {
43780
- const scriptsDir = join14(projectRoot, "scripts");
43521
+ const scriptsDir = join13(projectRoot, "scripts");
43781
43522
  try {
43782
43523
  const files = await readdir(scriptsDir);
43783
43524
  return files.filter((f) => f.endsWith(".sh")).map((f) => f.replace(".sh", "")).sort();
@@ -43786,7 +43527,7 @@ async function getScriptNames(projectRoot) {
43786
43527
  }
43787
43528
  }
43788
43529
  async function getIndexedCommands(projectRoot) {
43789
- const indexPath = join14(projectRoot, "docs", "commands", "COMMANDS-INDEX.json");
43530
+ const indexPath = join13(projectRoot, "docs", "commands", "COMMANDS-INDEX.json");
43790
43531
  const index = await readJson(indexPath);
43791
43532
  if (!index) return [];
43792
43533
  return index.commands.map((c) => c.name).sort();
@@ -43819,7 +43560,7 @@ async function runGapCheck(_projectRoot, filterId) {
43819
43560
  const reviewFiles = files.filter((f) => f.endsWith(".md"));
43820
43561
  for (const file of reviewFiles) {
43821
43562
  if (filterId && !file.includes(filterId)) continue;
43822
- const filePath = join14(reviewDir, file);
43563
+ const filePath = join13(reviewDir, file);
43823
43564
  const content = await readFile3(filePath, "utf-8");
43824
43565
  const taskMatch = file.match(/^(T\d+)/);
43825
43566
  const taskId = taskMatch ? taskMatch[1] : "UNKNOWN";
@@ -45177,7 +44918,7 @@ var findCommand2 = defineCommand({
45177
44918
 
45178
44919
  // packages/cleo/src/cli/commands/gc.ts
45179
44920
  import { homedir as homedir3 } from "node:os";
45180
- import { join as join15 } from "node:path";
44921
+ import { join as join14 } from "node:path";
45181
44922
  import { runGC } from "@cleocode/core/gc/runner.js";
45182
44923
  import { readGCState } from "@cleocode/core/gc/state.js";
45183
44924
  function formatBytes(bytes) {
@@ -45209,7 +44950,7 @@ var runCommand2 = defineCommand({
45209
44950
  }
45210
44951
  },
45211
44952
  async run({ args }) {
45212
- const cleoDir = args["cleo-dir"] ?? join15(homedir3(), ".cleo");
44953
+ const cleoDir = args["cleo-dir"] ?? join14(homedir3(), ".cleo");
45213
44954
  const dryRun = args["dry-run"];
45214
44955
  try {
45215
44956
  const gcResult = await runGC({ cleoDir, dryRun });
@@ -45264,8 +45005,8 @@ var statusCommand6 = defineCommand({
45264
45005
  }
45265
45006
  },
45266
45007
  async run({ args }) {
45267
- const cleoDir = args["cleo-dir"] ?? join15(homedir3(), ".cleo");
45268
- const statePath = join15(cleoDir, "gc-state.json");
45008
+ const cleoDir = args["cleo-dir"] ?? join14(homedir3(), ".cleo");
45009
+ const statePath = join14(cleoDir, "gc-state.json");
45269
45010
  try {
45270
45011
  const state = await readGCState(statePath);
45271
45012
  const result = { success: true, data: state };
@@ -45325,7 +45066,7 @@ var gcCommand = defineCommand({
45325
45066
  init_src();
45326
45067
  import { execFileSync as execFileSync4 } from "node:child_process";
45327
45068
  import { existsSync as existsSync10, mkdirSync as mkdirSync3, readFileSync as readFileSync12, writeFileSync as writeFileSync3 } from "node:fs";
45328
- import { dirname as dirname9, join as join16 } from "node:path";
45069
+ import { dirname as dirname9, join as join15 } from "node:path";
45329
45070
  import { CleoError as CleoError4, formatError as formatError6, getConfigPath as getConfigPath2, getProjectRoot as getProjectRoot24 } from "@cleocode/core";
45330
45071
  init_renderers();
45331
45072
  function getChangelogSource(cwd) {
@@ -45484,7 +45225,7 @@ var generateChangelogCommand = defineCommand({
45484
45225
  const targetPlatform = args.platform;
45485
45226
  const dryRun = args["dry-run"] === true;
45486
45227
  const sourceFile = getChangelogSource();
45487
- const sourcePath = join16(getProjectRoot24(), sourceFile);
45228
+ const sourcePath = join15(getProjectRoot24(), sourceFile);
45488
45229
  if (!existsSync10(sourcePath)) {
45489
45230
  throw new CleoError4(4 /* NOT_FOUND */, `Changelog source not found: ${sourcePath}`);
45490
45231
  }
@@ -45497,7 +45238,7 @@ var generateChangelogCommand = defineCommand({
45497
45238
  const outputPath = platformConfig?.path ?? getDefaultOutputPath(targetPlatform);
45498
45239
  const content = generateForPlatform(targetPlatform, sourceContent, repoSlug, limit);
45499
45240
  if (!dryRun) {
45500
- const fullPath = join16(getProjectRoot24(), outputPath);
45241
+ const fullPath = join15(getProjectRoot24(), outputPath);
45501
45242
  mkdirSync3(dirname9(fullPath), { recursive: true });
45502
45243
  writeFileSync3(fullPath, content, "utf-8");
45503
45244
  }
@@ -45518,7 +45259,7 @@ var generateChangelogCommand = defineCommand({
45518
45259
  limit
45519
45260
  );
45520
45261
  if (!dryRun) {
45521
- const fullPath = join16(getProjectRoot24(), platformConfig.path);
45262
+ const fullPath = join15(getProjectRoot24(), platformConfig.path);
45522
45263
  mkdirSync3(dirname9(fullPath), { recursive: true });
45523
45264
  writeFileSync3(fullPath, content, "utf-8");
45524
45265
  }
@@ -46930,7 +46671,7 @@ var mapCommand = defineCommand({
46930
46671
  import { createHash as createHash3 } from "node:crypto";
46931
46672
  import { existsSync as existsSync11, mkdirSync as mkdirSync4, readdirSync as readdirSync3, readFileSync as readFileSync13, writeFileSync as writeFileSync4 } from "node:fs";
46932
46673
  import { homedir as homedir4 } from "node:os";
46933
- import { join as join17 } from "node:path";
46674
+ import { join as join16 } from "node:path";
46934
46675
  import {
46935
46676
  getBrainDb as getBrainDb2,
46936
46677
  getBrainNativeDb as getBrainNativeDb4,
@@ -48228,11 +47969,11 @@ var importCommand3 = defineCommand({
48228
47969
  }
48229
47970
  },
48230
47971
  async run({ args }) {
48231
- const sourceDir = args.from ?? join17(homedir4(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
47972
+ const sourceDir = args.from ?? join16(homedir4(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
48232
47973
  const isDryRun = !!args["dry-run"];
48233
47974
  const isJson = !!args.json;
48234
47975
  const projectRoot = getProjectRoot25();
48235
- const stateFile = join17(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
47976
+ const stateFile = join16(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
48236
47977
  if (!existsSync11(sourceDir)) {
48237
47978
  const msg = `Source directory not found: ${sourceDir}`;
48238
47979
  if (isJson) {
@@ -48242,7 +47983,7 @@ var importCommand3 = defineCommand({
48242
47983
  }
48243
47984
  process.exit(1);
48244
47985
  }
48245
- const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) => join17(sourceDir, f));
47986
+ const files = readdirSync3(sourceDir).filter((f) => f.endsWith(".md") && f !== "MEMORY.md").map((f) => join16(sourceDir, f));
48246
47987
  const importedHashes = isDryRun ? /* @__PURE__ */ new Set() : loadImportHashes(stateFile);
48247
47988
  const stats = { total: files.length, imported: 0, skipped: 0, errors: 0 };
48248
47989
  const importedEntries = [];
@@ -51150,7 +50891,7 @@ var analyzeCommand3 = defineCommand({
51150
50891
  );
51151
50892
  }
51152
50893
  try {
51153
- const [{ getNexusDb: getNexusDb2, nexusSchema }, { runPipeline }, { getProjectRoot: getProjectRoot32 }, { eq: eq2 }] = await Promise.all([
50894
+ const [{ getNexusDb: getNexusDb2, nexusSchema }, { runPipeline }, { getProjectRoot: getProjectRoot33 }, { eq: eq2 }] = await Promise.all([
51154
50895
  import("@cleocode/core/store/nexus-sqlite"),
51155
50896
  import("@cleocode/nexus/pipeline"),
51156
50897
  import("@cleocode/core/internal"),
@@ -51256,7 +50997,7 @@ var analyzeCommand3 = defineCommand({
51256
50997
  `
51257
50998
  );
51258
50999
  }
51259
- void getProjectRoot32;
51000
+ void getProjectRoot33;
51260
51001
  } catch (err) {
51261
51002
  const msg = err instanceof Error ? err.message : String(err);
51262
51003
  if (jsonOutput) {
@@ -57681,7 +57422,7 @@ var schemaCommand = defineCommand({
57681
57422
  init_src();
57682
57423
  import { execFile } from "node:child_process";
57683
57424
  import { readFile as readFile4 } from "node:fs/promises";
57684
- import { join as join18 } from "node:path";
57425
+ import { join as join17 } from "node:path";
57685
57426
  import * as readline2 from "node:readline";
57686
57427
  import { promisify } from "node:util";
57687
57428
  import {
@@ -57700,7 +57441,7 @@ var GITHUB_REPO = BUILD_CONFIG2.repository.fullName;
57700
57441
  async function getCurrentVersion() {
57701
57442
  const cleoHome = getCleoHome2();
57702
57443
  try {
57703
- const content = await readFile4(join18(cleoHome, "VERSION"), "utf-8");
57444
+ const content = await readFile4(join17(cleoHome, "VERSION"), "utf-8");
57704
57445
  return (content.split("\n")[0] ?? "unknown").trim();
57705
57446
  } catch {
57706
57447
  return "unknown";
@@ -57754,7 +57495,7 @@ async function writeRuntimeVersionMetadata(mode, source, version) {
57754
57495
  ];
57755
57496
  await import("node:fs/promises").then(
57756
57497
  ({ writeFile: writeFile3, mkdir: mkdir5 }) => mkdir5(cleoHome, { recursive: true }).then(
57757
- () => writeFile3(join18(cleoHome, "VERSION"), `${lines.join("\n")}
57498
+ () => writeFile3(join17(cleoHome, "VERSION"), `${lines.join("\n")}
57758
57499
  `, "utf-8")
57759
57500
  )
57760
57501
  );
@@ -58155,7 +57896,7 @@ async function runPostUpdateDiagnostics(opts) {
58155
57896
  }
58156
57897
 
58157
57898
  // packages/cleo/src/cli/commands/sentient.ts
58158
- import { join as join19 } from "node:path";
57899
+ import { join as join18 } from "node:path";
58159
57900
  import { cwd as processCwd } from "node:process";
58160
57901
  import {
58161
57902
  getSentientDaemonStatus,
@@ -58226,7 +57967,7 @@ var startSub = defineCommand({
58226
57967
  return;
58227
57968
  }
58228
57969
  if (dryRun) {
58229
- const statePath2 = join19(projectRoot, SENTIENT_STATE_FILE);
57970
+ const statePath2 = join18(projectRoot, SENTIENT_STATE_FILE);
58230
57971
  const outcome = await safeRunTick({ projectRoot, statePath: statePath2, dryRun: true });
58231
57972
  emitSuccess(
58232
57973
  { dryRun: true, outcome },
@@ -58360,7 +58101,7 @@ var tickSub = defineCommand({
58360
58101
  const jsonMode = args.json === true;
58361
58102
  const dryRun = args["dry-run"] === true;
58362
58103
  try {
58363
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58104
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58364
58105
  const outcome = await safeRunTick({ projectRoot, statePath, dryRun });
58365
58106
  emitSuccess(
58366
58107
  { outcome, dryRun },
@@ -58429,7 +58170,7 @@ var proposeAcceptSub = defineCommand({
58429
58170
  return;
58430
58171
  }
58431
58172
  await db.update(tasks).set({ status: "pending", updatedAt: now }).where(eq2(tasks.id, id)).run();
58432
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58173
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58433
58174
  const state = await readSentientState(statePath);
58434
58175
  await patchSentientState(statePath, {
58435
58176
  tier2Stats: {
@@ -58481,7 +58222,7 @@ var proposeRejectSub = defineCommand({
58481
58222
  return;
58482
58223
  }
58483
58224
  await db.update(tasks).set({ status: "cancelled", cancellationReason: reason, cancelledAt: now, updatedAt: now }).where(eq2(tasks.id, id)).run();
58484
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58225
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58485
58226
  const state = await readSentientState(statePath);
58486
58227
  await patchSentientState(statePath, {
58487
58228
  tier2Stats: {
@@ -58526,7 +58267,7 @@ var proposeRunSub = defineCommand({
58526
58267
  const projectRoot = resolveProjectRoot7(args.project);
58527
58268
  const jsonMode = args.json === true;
58528
58269
  try {
58529
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58270
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58530
58271
  const outcome = await safeRunProposeTick({ projectRoot, statePath });
58531
58272
  emitSuccess(
58532
58273
  { outcome },
@@ -58546,7 +58287,7 @@ var proposeEnableSub = defineCommand({
58546
58287
  const projectRoot = resolveProjectRoot7(args.project);
58547
58288
  const jsonMode = args.json === true;
58548
58289
  try {
58549
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58290
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58550
58291
  const updated = await patchSentientState(statePath, { tier2Enabled: true });
58551
58292
  emitSuccess({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals enabled");
58552
58293
  } catch (err) {
@@ -58565,7 +58306,7 @@ var proposeDisableSub = defineCommand({
58565
58306
  const projectRoot = resolveProjectRoot7(args.project);
58566
58307
  const jsonMode = args.json === true;
58567
58308
  try {
58568
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58309
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58569
58310
  const updated = await patchSentientState(statePath, { tier2Enabled: false });
58570
58311
  emitSuccess({ tier2Enabled: updated.tier2Enabled }, jsonMode, "Tier-2 proposals disabled");
58571
58312
  } catch (err) {
@@ -58596,7 +58337,7 @@ var proposeSub = defineCommand({
58596
58337
  const projectRoot = resolveProjectRoot7(args.project);
58597
58338
  const jsonMode = args.json === true;
58598
58339
  try {
58599
- const statePath = join19(projectRoot, SENTIENT_STATE_FILE);
58340
+ const statePath = join18(projectRoot, SENTIENT_STATE_FILE);
58600
58341
  const state = await readSentientState(statePath);
58601
58342
  emitSuccess(
58602
58343
  {
@@ -58893,6 +58634,10 @@ var startCommand7 = defineCommand({
58893
58634
  description: "Auto-focus on first available task (alias for --auto-start)"
58894
58635
  },
58895
58636
  focus: {
58637
+ type: "string",
58638
+ description: "Set initial task to work on (alias for --start-task)"
58639
+ },
58640
+ "start-task": {
58896
58641
  type: "string",
58897
58642
  description: "Set initial task to work on"
58898
58643
  },
@@ -58926,7 +58671,8 @@ var startCommand7 = defineCommand({
58926
58671
  scope: args.scope,
58927
58672
  name: args.name,
58928
58673
  autoStart: args["auto-start"] || args["auto-focus"],
58929
- focus: args.focus,
58674
+ // CLI-level alias normalization: --focus and --start-task both map to startTask (ADR-057 D2)
58675
+ startTask: args["start-task"] ?? args.focus,
58930
58676
  grade: args.grade,
58931
58677
  ownerAuthToken
58932
58678
  },
@@ -60483,7 +60229,7 @@ var testingCommand = defineCommand({
60483
60229
 
60484
60230
  // packages/cleo/src/cli/commands/token.ts
60485
60231
  import { readFileSync as readFileSync14 } from "node:fs";
60486
- import { measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
60232
+ import { getProjectRoot as getProjectRoot30, measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
60487
60233
  init_cli();
60488
60234
  init_renderers();
60489
60235
  function readPayload(args, textKey, fileKey) {
@@ -60642,7 +60388,7 @@ var estimateCommand = defineCommand({
60642
60388
  domain: args.domain,
60643
60389
  operation: args.operation
60644
60390
  };
60645
- const result = args.record ? await recordTokenExchange2(input) : await measureTokenExchange(input);
60391
+ const result = args.record ? await recordTokenExchange2(getProjectRoot30(), input) : await measureTokenExchange(input);
60646
60392
  cliOutput(result, {
60647
60393
  command: "token",
60648
60394
  operation: args.record ? "admin.token.record" : "token.estimate"
@@ -60671,8 +60417,8 @@ var tokenCommand = defineCommand({
60671
60417
 
60672
60418
  // packages/cleo/src/cli/commands/transcript.ts
60673
60419
  import { homedir as homedir5 } from "node:os";
60674
- import { join as join20 } from "node:path";
60675
- import { getProjectRoot as getProjectRoot30 } from "@cleocode/core";
60420
+ import { join as join19 } from "node:path";
60421
+ import { getProjectRoot as getProjectRoot31 } from "@cleocode/core";
60676
60422
  import {
60677
60423
  parseDurationMs,
60678
60424
  pruneTranscripts,
@@ -60700,7 +60446,7 @@ var scanCommand = defineCommand({
60700
60446
  async run({ args }) {
60701
60447
  if (args.pending) {
60702
60448
  try {
60703
- const projectRoot = getProjectRoot30();
60449
+ const projectRoot = getProjectRoot31();
60704
60450
  const { scanPendingTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
60705
60451
  const pending = await scanPendingTranscripts(projectRoot);
60706
60452
  const envelope = { success: true, data: { count: pending.length, pending } };
@@ -60729,7 +60475,7 @@ var scanCommand = defineCommand({
60729
60475
  }
60730
60476
  return;
60731
60477
  }
60732
- const projectsDir = args["projects-dir"] ?? join20(homedir5(), ".claude", "projects");
60478
+ const projectsDir = args["projects-dir"] ?? join19(homedir5(), ".claude", "projects");
60733
60479
  try {
60734
60480
  const result = await scanTranscripts(projectsDir);
60735
60481
  const envelope = {
@@ -60833,7 +60579,7 @@ var extractCommand = defineCommand({
60833
60579
  async run({ args }) {
60834
60580
  const tier = args.tier ?? "warm";
60835
60581
  const dryRun = args["dry-run"] ?? false;
60836
- const projectRoot = getProjectRoot30();
60582
+ const projectRoot = getProjectRoot31();
60837
60583
  try {
60838
60584
  const { extractTranscript } = await import("@cleocode/core/memory/transcript-extractor.js");
60839
60585
  const { findSessionTranscriptPath, listAllTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
@@ -60964,7 +60710,7 @@ var migrateCommand2 = defineCommand({
60964
60710
  const dryRun = args["dry-run"] ?? false;
60965
60711
  const olderThanHours = args["older-than-hours"] ? Number.parseInt(args["older-than-hours"], 10) : 24;
60966
60712
  const limit = args.limit ? Number.parseInt(args.limit, 10) : void 0;
60967
- const projectRoot = getProjectRoot30();
60713
+ const projectRoot = getProjectRoot31();
60968
60714
  try {
60969
60715
  const { extractTranscript } = await import("@cleocode/core/memory/transcript-extractor.js");
60970
60716
  const { listAllTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
@@ -61114,7 +60860,7 @@ var pruneCommand = defineCommand({
61114
60860
  process.exit(2);
61115
60861
  return;
61116
60862
  }
61117
- const projectsDir = args["projects-dir"] ?? join20(homedir5(), ".claude", "projects");
60863
+ const projectsDir = args["projects-dir"] ?? join19(homedir5(), ".claude", "projects");
61118
60864
  try {
61119
60865
  const pruneResult = await pruneTranscripts({
61120
60866
  olderThanMs,
@@ -61540,7 +61286,7 @@ var verifyCommand2 = defineCommand({
61540
61286
  init_src();
61541
61287
  import { execFileSync as execFileSync6, spawn } from "node:child_process";
61542
61288
  import { mkdir as mkdir4, open, readFile as readFile5, rm, stat, writeFile as writeFile2 } from "node:fs/promises";
61543
- import { join as join21 } from "node:path";
61289
+ import { join as join20 } from "node:path";
61544
61290
  import { CleoError as CleoError12, formatError as formatError14, getCleoHome as getCleoHome3 } from "@cleocode/core";
61545
61291
  init_renderers();
61546
61292
  var DEFAULT_PORT = 3456;
@@ -61548,10 +61294,10 @@ var DEFAULT_HOST = "127.0.0.1";
61548
61294
  function getWebPaths() {
61549
61295
  const cleoHome = getCleoHome3();
61550
61296
  return {
61551
- pidFile: join21(cleoHome, "web-server.pid"),
61552
- configFile: join21(cleoHome, "web-server.json"),
61553
- logDir: join21(cleoHome, "logs"),
61554
- logFile: join21(cleoHome, "logs", "web-server.log")
61297
+ pidFile: join20(cleoHome, "web-server.pid"),
61298
+ configFile: join20(cleoHome, "web-server.json"),
61299
+ logDir: join20(cleoHome, "logs"),
61300
+ logFile: join20(cleoHome, "logs", "web-server.log")
61555
61301
  };
61556
61302
  }
61557
61303
  function isProcessRunning(pid) {
@@ -61590,7 +61336,7 @@ async function startWebServer(port, host) {
61590
61336
  throw new CleoError12(1 /* GENERAL_ERROR */, `Server already running (PID: ${status.pid})`);
61591
61337
  }
61592
61338
  const projectRoot = process.env["CLEO_ROOT"] ?? process.cwd();
61593
- const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join21(projectRoot, "packages", "studio", "build");
61339
+ const studioDir = process.env["CLEO_STUDIO_DIR"] ?? join20(projectRoot, "packages", "studio", "build");
61594
61340
  await mkdir4(logDir, { recursive: true });
61595
61341
  await writeFile2(
61596
61342
  configFile,
@@ -61600,7 +61346,7 @@ async function startWebServer(port, host) {
61600
61346
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
61601
61347
  })
61602
61348
  );
61603
- const webIndexPath = join21(studioDir, "index.js");
61349
+ const webIndexPath = join20(studioDir, "index.js");
61604
61350
  try {
61605
61351
  await stat(webIndexPath);
61606
61352
  } catch {
@@ -61879,7 +61625,7 @@ Or via NodeSource: https://github.com/nodesource/distributions
61879
61625
  }
61880
61626
  }
61881
61627
  function getPackageVersion() {
61882
- const pkgPath = join22(dirname10(fileURLToPath3(import.meta.url)), "../../package.json");
61628
+ const pkgPath = join21(dirname10(fileURLToPath3(import.meta.url)), "../../package.json");
61883
61629
  const pkg = JSON.parse(readFileSync15(pkgPath, "utf-8"));
61884
61630
  return pkg.version;
61885
61631
  }
@@ -62034,12 +61780,12 @@ subCommands["pipeline"] = phaseCommand;
62034
61780
  } catch {
62035
61781
  }
62036
61782
  try {
62037
- detectAndRemoveStrayProjectNexus(getProjectRoot31());
61783
+ detectAndRemoveStrayProjectNexus(getProjectRoot32());
62038
61784
  } catch {
62039
61785
  }
62040
61786
  const _startupLog = getLogger19("cli-startup");
62041
61787
  try {
62042
- const _projectRootForMigration = getProjectRoot31();
61788
+ const _projectRootForMigration = getProjectRoot32();
62043
61789
  if (needsSignaldockToConduitMigration(_projectRootForMigration)) {
62044
61790
  const migrationResult = migrateSignaldockToConduit(_projectRootForMigration);
62045
61791
  if (migrationResult.status === "failed") {
@@ -62059,7 +61805,7 @@ subCommands["pipeline"] = phaseCommand;
62059
61805
  }
62060
61806
  }
62061
61807
  try {
62062
- ensureConduitDb(getProjectRoot31());
61808
+ ensureConduitDb(getProjectRoot32());
62063
61809
  } catch {
62064
61810
  }
62065
61811
  try {