@cleocode/cleo 2026.9.22 → 2026.9.23

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.
Files changed (79) hide show
  1. package/dist/cli/index.js +680 -171
  2. package/package.json +13 -13
  3. package/studio-dist/client/_app/immutable/chunks/CyNL2FJl.js +1 -0
  4. package/studio-dist/client/_app/immutable/chunks/{0tcsbE6D.js → DJ4ceMnt.js} +1 -1
  5. package/studio-dist/client/_app/immutable/chunks/{BKjRqkYg.js → DlnXUEcN.js} +1 -1
  6. package/studio-dist/client/_app/immutable/chunks/{BzdFEK5o.js → VqMa-FR_.js} +1 -1
  7. package/studio-dist/client/_app/immutable/entry/{app.CT-LXuds.js → app.CXLixB0X.js} +2 -2
  8. package/studio-dist/client/_app/immutable/entry/start.C_VLyotS.js +1 -0
  9. package/studio-dist/client/_app/immutable/nodes/{0.CJNVG-lR.js → 0.D34GfsBr.js} +1 -1
  10. package/studio-dist/client/_app/immutable/nodes/{1.C7ULqnrP.js → 1.COzO-K-Z.js} +1 -1
  11. package/studio-dist/client/_app/immutable/nodes/{15.BNOT6L5f.js → 15.CkLwS1y2.js} +1 -1
  12. package/studio-dist/client/_app/immutable/nodes/{16.D5aa4hwV.js → 16.C2MFh329.js} +1 -1
  13. package/studio-dist/client/_app/immutable/nodes/{17.WSqtVr_-.js → 17.CLdLJ6ju.js} +1 -1
  14. package/studio-dist/client/_app/immutable/nodes/{18.Lyg3PWST.js → 18.ClGsX0an.js} +1 -1
  15. package/studio-dist/client/_app/immutable/nodes/{20.zTYVKImv.js → 20.vQtazQa0.js} +1 -1
  16. package/studio-dist/client/_app/immutable/nodes/{24.B2cU3PXS.js → 24.DLwR4-7S.js} +1 -1
  17. package/studio-dist/client/_app/immutable/nodes/25.DUuYls4x.js +39 -0
  18. package/studio-dist/client/_app/immutable/nodes/{26.eXqGXEyv.js → 26.BZ-Sb3tl.js} +1 -1
  19. package/studio-dist/client/_app/immutable/nodes/{3.C5vwxSyN.js → 3.CYwLXdQ4.js} +1 -1
  20. package/studio-dist/client/_app/version.json +1 -1
  21. package/studio-dist/server/chunks/{0-g-9QBgTv.js → 0-BlM3YDpC.js} +3 -3
  22. package/studio-dist/server/chunks/1-DROdkBtZ.js +9 -0
  23. package/studio-dist/server/chunks/{15-5CTacdmx.js → 15-D4Y9me2S.js} +3 -3
  24. package/studio-dist/server/chunks/{16-DIJruZT8.js → 16-BNVAfz5X.js} +3 -3
  25. package/studio-dist/server/chunks/{17-yv-WCUot.js → 17-ByJg8VAI.js} +5 -4
  26. package/studio-dist/server/chunks/{18-qo45V8TJ.js → 18-mcGKywiH.js} +3 -3
  27. package/studio-dist/server/chunks/{2-DXSVVaej.js → 2-DQaIET_o.js} +3 -2
  28. package/studio-dist/server/chunks/{20-BImtok4E.js → 20-D4RXMRdA.js} +3 -3
  29. package/studio-dist/server/chunks/{23-CZpFrGp4.js → 23-D2H9OSJf.js} +4 -3
  30. package/studio-dist/server/chunks/{24-JR2XU8Zk.js → 24-BZesRs_l.js} +6 -5
  31. package/studio-dist/server/chunks/{25-FQ-ABq7g.js → 25-BPtkcHWk.js} +7 -6
  32. package/studio-dist/server/chunks/{26-C0EfiL70.js → 26-D7qW4CZ3.js} +5 -4
  33. package/studio-dist/server/chunks/{29-6pjLM0Z1.js → 29-d_lZvJg3.js} +3 -2
  34. package/studio-dist/server/chunks/{3-YulKrPK4.js → 3-Csrn9tNa.js} +3 -3
  35. package/studio-dist/server/chunks/{30-Dw317sSW.js → 30-BHsj4oeh.js} +3 -2
  36. package/studio-dist/server/chunks/{_layout.svelte-DFY_t32i.js → _layout.svelte-DtqTR50-.js} +4 -4
  37. package/studio-dist/server/chunks/{_page.svelte-B1-qqkuN.js → _page.svelte-BkrxW4NS.js} +3 -3
  38. package/studio-dist/server/chunks/{_page.svelte-BY7VnsnD.js → _page.svelte-BlDOqWK_.js} +3 -3
  39. package/studio-dist/server/chunks/{_page.svelte-DLPbtByz.js → _page.svelte-C9lhMoUX.js} +5 -5
  40. package/studio-dist/server/chunks/{_page.svelte-DfLMLIQh.js → _page.svelte-Ce2_fPzl.js} +4 -4
  41. package/studio-dist/server/chunks/{_page.svelte-DbctFR26.js → _page.svelte-CyGNoYGs.js} +3 -3
  42. package/studio-dist/server/chunks/{_page.svelte-BKGofZjs.js → _page.svelte-DESqb1iT.js} +3 -3
  43. package/studio-dist/server/chunks/{_page.svelte-Drj7fNS_.js → _page.svelte-DTqKOclg.js} +3 -3
  44. package/studio-dist/server/chunks/{_page.svelte-DoMZFgyT.js → _page.svelte-Dj05GrDh.js} +3 -3
  45. package/studio-dist/server/chunks/{_page.svelte-B2iUE3vx.js → _page.svelte-DxctlP-t.js} +3 -3
  46. package/studio-dist/server/chunks/{_server.ts-DQiTiY3E.js → _server.ts-6A72NyG7.js} +3 -2
  47. package/studio-dist/server/chunks/{_server.ts-BX1KvJuM.js → _server.ts-B23PRUg6.js} +5 -4
  48. package/studio-dist/server/chunks/{_server.ts--2m_U4SL.js → _server.ts-BCPpAOST.js} +3 -2
  49. package/studio-dist/server/chunks/{_server.ts-C6IDM_3I.js → _server.ts-BKZlM7rp.js} +3 -2
  50. package/studio-dist/server/chunks/{_server.ts-BMYX3KLE.js → _server.ts-BLEs7rDo.js} +5 -4
  51. package/studio-dist/server/chunks/{_server.ts-D8P3mren.js → _server.ts-BPzV5a4O.js} +3 -3
  52. package/studio-dist/server/chunks/{_server.ts-J17j25VG.js → _server.ts-BRoSUvbn.js} +3 -2
  53. package/studio-dist/server/chunks/{_server.ts-Bl9tMqwZ.js → _server.ts-Bhp29rqm.js} +4 -1
  54. package/studio-dist/server/chunks/{_server.ts--sGLmBsz.js → _server.ts-Br_GCegg.js} +3 -2
  55. package/studio-dist/server/chunks/{_server.ts-BlYsd_GD.js → _server.ts-BtgcmXG8.js} +4 -3
  56. package/studio-dist/server/chunks/{_server.ts-DKFJdXPK.js → _server.ts-CFb-INiV.js} +4 -3
  57. package/studio-dist/server/chunks/{_server.ts-3LzqLzt0.js → _server.ts-CcQ0AQoo.js} +3 -2
  58. package/studio-dist/server/chunks/{_server.ts-BA8Xdegq.js → _server.ts-CqO357sV.js} +3 -2
  59. package/studio-dist/server/chunks/{_server.ts-Ba7uukQ7.js → _server.ts-D9JYb9Nh.js} +3 -3
  60. package/studio-dist/server/chunks/{_server.ts-CeQolQOK.js → _server.ts-DAJiZh2M.js} +3 -2
  61. package/studio-dist/server/chunks/{_server.ts-C2nYqbd9.js → _server.ts-DJALLGi_.js} +3 -2
  62. package/studio-dist/server/chunks/{_server.ts-C8Z32vuL.js → _server.ts-DQ7VnW5Q.js} +3 -2
  63. package/studio-dist/server/chunks/{_server.ts-DUyeSXbV.js → _server.ts-O5iKqt5Z.js} +3 -2
  64. package/studio-dist/server/chunks/{_server.ts-D6wP5bCh.js → _server.ts-OPrTc7WI.js} +3 -2
  65. package/studio-dist/server/chunks/{client-BqWu1TLm.js → client-D4Rhd5ed.js} +2 -2
  66. package/studio-dist/server/chunks/{connections-CWLPjwBP.js → connections-CAJ4ZeCq.js} +3 -2
  67. package/studio-dist/server/chunks/{connections2-DHVs5ytW.js → connections2-DyYEcX2h.js} +6 -1
  68. package/studio-dist/server/chunks/{dist-DPV5iK3m.js → dist-DafBXQH9.js} +73 -5
  69. package/studio-dist/server/chunks/{error.svelte-CvROslRV.js → error.svelte-BLd3ZRbJ.js} +3 -3
  70. package/studio-dist/server/chunks/{explorer-loader-B_uCSs9_.js → explorer-loader-CP09K03H.js} +2 -2
  71. package/studio-dist/server/chunks/{http-BVzADggg.js → http-C-8-8Oq_.js} +2 -2
  72. package/studio-dist/server/chunks/{internal-BlXMjztN.js → internal-DxboZxyS.js} +2 -2
  73. package/studio-dist/server/chunks/{stores-C8kmowVZ.js → stores-DFVE4LvP.js} +2 -2
  74. package/studio-dist/server/index.js +1 -1
  75. package/studio-dist/server/manifest.js +35 -35
  76. package/studio-dist/client/_app/immutable/chunks/D2e9iItv.js +0 -1
  77. package/studio-dist/client/_app/immutable/entry/start.SG-NqdSp.js +0 -1
  78. package/studio-dist/client/_app/immutable/nodes/25.CKddYoS3.js +0 -39
  79. package/studio-dist/server/chunks/1-BkPP00YN.js +0 -9
package/dist/cli/index.js CHANGED
@@ -1815,7 +1815,7 @@ var init_acceptance_gate_schema = __esm({
1815
1815
  message: "Result cannot precede input capture"
1816
1816
  });
1817
1817
  const executable = ["test", "command", "lint"].includes(result.kind);
1818
- if (executable && !binding.invocation)
1818
+ if (executable && !binding.invocation && result.result !== "error")
1819
1819
  context.addIssue({
1820
1820
  code: "custom",
1821
1821
  path: ["binding", "invocation"],
@@ -6330,12 +6330,21 @@ var init_operations_registry = __esm({
6330
6330
  gateway: "query",
6331
6331
  domain: "tasks",
6332
6332
  operation: "history",
6333
- description: "Show task work history (time tracked per task)",
6333
+ description: "Show task work history; with taskId, the task audit trail; with ranking, who changed its priority/severity/kind/depends and why (T12693)",
6334
6334
  tier: 1,
6335
6335
  idempotent: true,
6336
6336
  sessionRequired: false,
6337
6337
  requiredParams: [],
6338
- params: []
6338
+ params: [
6339
+ { name: "taskId", type: "string", required: false, description: "Task to show history for" },
6340
+ { name: "limit", type: "number", required: false, description: "Maximum entries" },
6341
+ {
6342
+ name: "ranking",
6343
+ type: "boolean",
6344
+ required: false,
6345
+ description: "Only ranking-input changes (actor, session, reason, before/after)"
6346
+ }
6347
+ ]
6339
6348
  },
6340
6349
  {
6341
6350
  gateway: "query",
@@ -8830,6 +8839,32 @@ var init_operations_registry = __esm({
8830
8839
  ],
8831
8840
  outputSchema: OUTPUT_CONTRACTS["tasks.assignee"]
8832
8841
  },
8842
+ {
8843
+ gateway: "mutate",
8844
+ domain: "tasks",
8845
+ operation: "ranking.revert",
8846
+ description: "tasks.ranking.revert (mutate) \u2014 undo one recorded ranking change (priority/severity/kind/depends) as a new audited change (T12693, D11161)",
8847
+ tier: 1,
8848
+ idempotent: false,
8849
+ sessionRequired: false,
8850
+ requiredParams: ["entryId"],
8851
+ params: [
8852
+ {
8853
+ name: "entryId",
8854
+ type: "string",
8855
+ required: true,
8856
+ description: "ranking_changed audit row id (cleo history ranking <taskId>)",
8857
+ cli: { positional: true }
8858
+ },
8859
+ { name: "reason", type: "string", required: false, description: "Why it is reverted" },
8860
+ {
8861
+ name: "force",
8862
+ type: "boolean",
8863
+ required: false,
8864
+ description: "Revert even though a field changed again since"
8865
+ }
8866
+ ]
8867
+ },
8833
8868
  {
8834
8869
  gateway: "mutate",
8835
8870
  domain: "tasks",
@@ -16866,7 +16901,10 @@ var init_evidence_atom_schema = __esm({
16866
16901
  ["commit", "note"],
16867
16902
  ["decision", "files"],
16868
16903
  ["decision", "note"],
16869
- ["pr", "files"]
16904
+ ["pr", "files"],
16905
+ // T12689: a deletion-only PR (no bytes to hash). Contextual validation
16906
+ // accepts this only when every change the PR made is a deletion.
16907
+ ["pr", "note"]
16870
16908
  ]
16871
16909
  },
16872
16910
  testsPassed: { oneOf: [["test-run"], ["tool"], ["ci"]] },
@@ -22280,7 +22318,7 @@ var init_collection_keys = __esm({
22280
22318
 
22281
22319
  // packages/contracts/src/decide.ts
22282
22320
  import { z as z24 } from "zod";
22283
- var DECISION_QUESTION_TYPES, DECISION_OUTCOME_SOURCES, DECISION_REQUEST_LIMITS, decisionQuestionTypeSchema, decisionOutcomeSourceSchema, decisionInstructionsSchema, unitIntervalSchema, decisionStateSchema, noulDecisionQuestionSchema, choiceDecisionQuestionSchema, scoreDecisionQuestionSchema, decisionQuestionSchema, decisionRequestSchema, noulDecisionAnswerSchema, choiceDecisionAnswerSchema, scoreDecisionAnswerSchema, decisionAnswerSchema, decisionOutcomeSchema, decisionProviderConfigSchema;
22321
+ var DECISION_QUESTION_TYPES, DECISION_OUTCOME_SOURCES, DECISION_REQUEST_LIMITS, DECISION_PROVIDER_KINDS, LAYAHOST_BASE_URL, LAYAHOST_DEFAULT_MODEL, JEV_MINIMUM_CAPABILITIES, decisionQuestionTypeSchema, decisionOutcomeSourceSchema, decisionInstructionsSchema, unitIntervalSchema, decisionStateSchema, noulDecisionQuestionSchema, choiceDecisionQuestionSchema, scoreDecisionQuestionSchema, decisionQuestionSchema, decisionRequestSchema, noulDecisionAnswerSchema, choiceDecisionAnswerSchema, scoreDecisionAnswerSchema, decisionAnswerSchema, decisionOutcomeSchema, decisionProviderKindSchema, decisionProviderConfigSchema;
22284
22322
  var init_decide = __esm({
22285
22323
  "packages/contracts/src/decide.ts"() {
22286
22324
  "use strict";
@@ -22304,6 +22342,15 @@ var init_decide = __esm({
22304
22342
  /** Maximum number of levels on a `score` question's scale. */
22305
22343
  maxScoreLevels: 10
22306
22344
  };
22345
+ DECISION_PROVIDER_KINDS = ["layahost", "jev"];
22346
+ LAYAHOST_BASE_URL = "https://layahost.com";
22347
+ LAYAHOST_DEFAULT_MODEL = "laya-auto";
22348
+ JEV_MINIMUM_CAPABILITIES = {
22349
+ wire: "jev-systemone/1",
22350
+ maxQuestionsPerRequest: 32,
22351
+ maxStateChars: 32e3,
22352
+ reportsCost: "usd"
22353
+ };
22307
22354
  decisionQuestionTypeSchema = z24.enum(DECISION_QUESTION_TYPES);
22308
22355
  decisionOutcomeSourceSchema = z24.enum(DECISION_OUTCOME_SOURCES);
22309
22356
  decisionInstructionsSchema = z24.union([z24.string(), z24.record(z24.string(), z24.json())]);
@@ -22341,6 +22388,8 @@ var init_decide = __esm({
22341
22388
  ]);
22342
22389
  decisionRequestSchema = z24.object({
22343
22390
  model: z24.string().min(1).optional(),
22391
+ lang: z24.string().regex(/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})?$/).optional(),
22392
+ cache: z24.boolean().optional(),
22344
22393
  state: decisionStateSchema,
22345
22394
  questions: z24.record(z24.string().min(1), decisionQuestionSchema).refine(
22346
22395
  (questions) => {
@@ -22381,14 +22430,29 @@ var init_decide = __esm({
22381
22430
  requestId: z24.string().min(1).optional(),
22382
22431
  latencyMs: z24.number().nonnegative(),
22383
22432
  costUsd: z24.number().nonnegative().optional(),
22433
+ costMicros: z24.number().int().nonnegative().optional(),
22434
+ balanceMicros: z24.number().int().optional(),
22435
+ checkpoint: z24.string().min(1).optional(),
22384
22436
  inputTokens: z24.number().int().nonnegative().optional()
22385
22437
  });
22438
+ decisionProviderKindSchema = z24.enum(DECISION_PROVIDER_KINDS);
22386
22439
  decisionProviderConfigSchema = z24.object({
22387
- baseUrl: z24.url()
22440
+ baseUrl: z24.url(),
22441
+ provider: decisionProviderKindSchema.optional()
22388
22442
  });
22389
22443
  }
22390
22444
  });
22391
22445
 
22446
+ // packages/contracts/src/decide-sites.ts
22447
+ var DECISION_RUNGS, DECISION_SITE_MODES;
22448
+ var init_decide_sites = __esm({
22449
+ "packages/contracts/src/decide-sites.ts"() {
22450
+ "use strict";
22451
+ DECISION_RUNGS = ["rule", "system-one", "generative", "agent", "owner"];
22452
+ DECISION_SITE_MODES = ["off", "shadow", "on"];
22453
+ }
22454
+ });
22455
+
22392
22456
  // packages/contracts/src/task-id.ts
22393
22457
  function isTaskId(value) {
22394
22458
  return typeof value === "string" && TASK_ID_REGEX.test(value);
@@ -22468,8 +22532,11 @@ __export(src_exports, {
22468
22532
  DAEMON_IPC_PROTOCOL_VERSION: () => SUPERVISOR_IPC_PROTOCOL_VERSION,
22469
22533
  DB_INVENTORY: () => DB_INVENTORY,
22470
22534
  DECISION_OUTCOME_SOURCES: () => DECISION_OUTCOME_SOURCES,
22535
+ DECISION_PROVIDER_KINDS: () => DECISION_PROVIDER_KINDS,
22471
22536
  DECISION_QUESTION_TYPES: () => DECISION_QUESTION_TYPES,
22472
22537
  DECISION_REQUEST_LIMITS: () => DECISION_REQUEST_LIMITS,
22538
+ DECISION_RUNGS: () => DECISION_RUNGS,
22539
+ DECISION_SITE_MODES: () => DECISION_SITE_MODES,
22473
22540
  DEFAULT_IDENTITY_FIELD: () => DEFAULT_IDENTITY_FIELD,
22474
22541
  DEFAULT_RESOURCE_RETRY_AFTER_MS: () => DEFAULT_RESOURCE_RETRY_AFTER_MS,
22475
22542
  DOCS_LIFECYCLE_STATUSES: () => DOCS_LIFECYCLE_STATUSES,
@@ -22527,7 +22594,10 @@ __export(src_exports, {
22527
22594
  INVARIANTS_REGISTRY: () => INVARIANTS_REGISTRY,
22528
22595
  ISOLATION_ENV_KEYS: () => ISOLATION_ENV_KEYS,
22529
22596
  ImpactSchema: () => ImpactSchema,
22597
+ JEV_MINIMUM_CAPABILITIES: () => JEV_MINIMUM_CAPABILITIES,
22530
22598
  KIND_LIFECYCLE_REQUIREMENTS: () => KIND_LIFECYCLE_REQUIREMENTS,
22599
+ LAYAHOST_BASE_URL: () => LAYAHOST_BASE_URL,
22600
+ LAYAHOST_DEFAULT_MODEL: () => LAYAHOST_DEFAULT_MODEL,
22531
22601
  LEASE_IPC_MESSAGE_KINDS: () => LEASE_IPC_MESSAGE_KINDS,
22532
22602
  LEASE_IPC_PROTOCOL_VERSION: () => LEASE_IPC_PROTOCOL_VERSION,
22533
22603
  LEASE_IPC_REQUEST_KINDS: () => LEASE_IPC_REQUEST_KINDS,
@@ -22733,6 +22803,7 @@ __export(src_exports, {
22733
22803
  decisionOutcomeSchema: () => decisionOutcomeSchema,
22734
22804
  decisionOutcomeSourceSchema: () => decisionOutcomeSourceSchema,
22735
22805
  decisionProviderConfigSchema: () => decisionProviderConfigSchema,
22806
+ decisionProviderKindSchema: () => decisionProviderKindSchema,
22736
22807
  decisionQuestionSchema: () => decisionQuestionSchema,
22737
22808
  decisionQuestionTypeSchema: () => decisionQuestionTypeSchema,
22738
22809
  decisionRequestSchema: () => decisionRequestSchema,
@@ -23011,6 +23082,7 @@ var init_src2 = __esm({
23011
23082
  init_caamp_markers();
23012
23083
  init_collection_keys();
23013
23084
  init_decide();
23085
+ init_decide_sites();
23014
23086
  init_task_id();
23015
23087
  }
23016
23088
  });
@@ -25254,7 +25326,13 @@ var init_admin2 = __esm({
25254
25326
  return lafsError("E_INVALID_INPUT", "backupId is required", "backup.mutate");
25255
25327
  }
25256
25328
  try {
25257
- const data = restoreBackup(projectRoot, { backupId, force: params.force });
25329
+ const data = restoreBackup(projectRoot, {
25330
+ backupId,
25331
+ force: params.force,
25332
+ confirmOwnerStore: params.confirmOwnerStore,
25333
+ // T12680: the invocation directory; core never falls back to it.
25334
+ cwd: process.cwd()
25335
+ });
25258
25336
  return lafsSuccess(data, "backup.mutate");
25259
25337
  } catch (err) {
25260
25338
  return lafsError(
@@ -25270,7 +25348,12 @@ var init_admin2 = __esm({
25270
25348
  return lafsError("E_INVALID_INPUT", "file is required", "backup.mutate");
25271
25349
  }
25272
25350
  try {
25273
- const data = await fileRestore(projectRoot, file, { dryRun: params.dryRun });
25351
+ const data = await fileRestore(projectRoot, file, {
25352
+ dryRun: params.dryRun,
25353
+ confirmOwnerStore: params.confirmOwnerStore,
25354
+ // T12680: the invocation directory; core never falls back to it.
25355
+ cwd: process.cwd()
25356
+ });
25274
25357
  return lafsSuccess(data, "backup.mutate");
25275
25358
  } catch (err) {
25276
25359
  return lafsError(
@@ -37587,8 +37670,8 @@ async function loadPlaybookByName(name) {
37587
37670
  return null;
37588
37671
  }
37589
37672
  try {
37590
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core/internal");
37591
- const projectRoot = __playbookRuntimeOverrides.projectRoot ?? getProjectRoot72();
37673
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core/internal");
37674
+ const projectRoot = __playbookRuntimeOverrides.projectRoot ?? getProjectRoot73();
37592
37675
  const resolved = resolvePlaybook(name, {
37593
37676
  projectRoot,
37594
37677
  globalPlaybooksDir: __playbookRuntimeOverrides.globalPlaybooksDir,
@@ -37633,7 +37716,7 @@ async function buildDefaultDispatcher() {
37633
37716
  if (__playbookRuntimeOverrides.dispatcher) return __playbookRuntimeOverrides.dispatcher;
37634
37717
  const { orchestrateSpawnExecute: orchestrateSpawnExecute2 } = await import("@cleocode/runtime/gateway");
37635
37718
  const {
37636
- getProjectRoot: getProjectRoot72,
37719
+ getProjectRoot: getProjectRoot73,
37637
37720
  createToolGuard,
37638
37721
  runSkillNodeOrSpawn,
37639
37722
  maybeCreatePiRunner,
@@ -37641,7 +37724,7 @@ async function buildDefaultDispatcher() {
37641
37724
  hasCantbookProfilePin,
37642
37725
  DEFAULT_DETERMINISTIC_DENIED_COMMANDS
37643
37726
  } = await import("@cleocode/core/internal");
37644
- const projectRoot = getProjectRoot72();
37727
+ const projectRoot = getProjectRoot73();
37645
37728
  const tools = createToolGuard({
37646
37729
  allowedRoots: [projectRoot],
37647
37730
  deniedCommands: DEFAULT_DETERMINISTIC_DENIED_COMMANDS,
@@ -37734,12 +37817,12 @@ async function buildDefaultDeterministicRunner() {
37734
37817
  return void 0;
37735
37818
  }
37736
37819
  const {
37737
- getProjectRoot: getProjectRoot72,
37820
+ getProjectRoot: getProjectRoot73,
37738
37821
  createToolGuard,
37739
37822
  createGuardedDeterministicRunner,
37740
37823
  DEFAULT_DETERMINISTIC_DENIED_COMMANDS
37741
37824
  } = await import("@cleocode/core/internal");
37742
- const projectRoot = getProjectRoot72();
37825
+ const projectRoot = getProjectRoot73();
37743
37826
  const tools = createToolGuard({
37744
37827
  allowedRoots: [projectRoot],
37745
37828
  deniedCommands: DEFAULT_DETERMINISTIC_DENIED_COMMANDS,
@@ -37897,8 +37980,8 @@ var init_playbook2 = __esm({
37897
37980
  projectRoot = __playbookRuntimeOverrides.projectRoot;
37898
37981
  } else {
37899
37982
  try {
37900
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core/internal");
37901
- projectRoot = getProjectRoot72();
37983
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core/internal");
37984
+ projectRoot = getProjectRoot73();
37902
37985
  } catch {
37903
37986
  projectRoot = void 0;
37904
37987
  }
@@ -37963,14 +38046,14 @@ var init_playbook2 = __esm({
37963
38046
  const deterministicRunner = await buildDefaultDeterministicRunner();
37964
38047
  let result;
37965
38048
  try {
37966
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core/internal");
38049
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core/internal");
37967
38050
  const opts = {
37968
38051
  db,
37969
38052
  playbook: parsed.definition,
37970
38053
  playbookHash: parsed.sourceHash,
37971
38054
  initialContext,
37972
38055
  dispatcher,
37973
- projectRoot: getProjectRoot72()
38056
+ projectRoot: getProjectRoot73()
37974
38057
  };
37975
38058
  if (deterministicRunner !== void 0) opts.deterministicRunner = deterministicRunner;
37976
38059
  if (__playbookRuntimeOverrides.approvalSecret !== void 0) {
@@ -42167,6 +42250,8 @@ import {
42167
42250
  taskList,
42168
42251
  taskNext,
42169
42252
  taskPlan,
42253
+ taskRankingHistory,
42254
+ taskRankingRevert,
42170
42255
  taskReconcileScope,
42171
42256
  taskRelates as taskRelates2,
42172
42257
  taskRelatesAdd,
@@ -42444,6 +42529,12 @@ var init_tasks3 = __esm({
42444
42529
  },
42445
42530
  history: async (params) => {
42446
42531
  const projectRoot = getProjectRoot19();
42532
+ if (params.taskId && params.ranking) {
42533
+ return wrapCoreResult(
42534
+ await taskRankingHistory(projectRoot, params.taskId, params.limit),
42535
+ "history"
42536
+ );
42537
+ }
42447
42538
  if (params.taskId) {
42448
42539
  return wrapCoreResult(await taskHistory(projectRoot, params.taskId, params.limit), "history");
42449
42540
  }
@@ -42655,6 +42746,19 @@ var init_tasks3 = __esm({
42655
42746
  "relates.add"
42656
42747
  );
42657
42748
  },
42749
+ "ranking.revert": async (params) => {
42750
+ if (!params.entryId) {
42751
+ return lafsError("E_INVALID_INPUT", "entryId is required", "ranking.revert");
42752
+ }
42753
+ return wrapCoreResult(
42754
+ await taskRankingRevert(getProjectRoot19(), {
42755
+ entryId: params.entryId,
42756
+ ...params.reason !== void 0 ? { reason: params.reason } : {},
42757
+ ...params.force ? { force: true } : {}
42758
+ }),
42759
+ "ranking.revert"
42760
+ );
42761
+ },
42658
42762
  "relates.add-batch": async (params) => {
42659
42763
  const projectRoot = getProjectRoot19();
42660
42764
  return wrapCoreResult(await taskRelatesAddBatch(projectRoot, params), "relates.add-batch");
@@ -42762,6 +42866,8 @@ var init_tasks3 = __esm({
42762
42866
  // OperationDef registered in @cleocode/contracts operations-registry.
42763
42867
  "relates.add-batch",
42764
42868
  "relates.remove",
42869
+ // T12693 (D11161) — undo one audited ranking change.
42870
+ "ranking.revert",
42765
42871
  "start",
42766
42872
  "stop",
42767
42873
  "sync.reconcile",
@@ -43056,6 +43162,7 @@ var init_tasks3 = __esm({
43056
43162
  "assignee",
43057
43163
  "relates.add",
43058
43164
  "relates.remove",
43165
+ "ranking.revert",
43059
43166
  "start",
43060
43167
  "stop",
43061
43168
  "sync.reconcile",
@@ -45237,11 +45344,11 @@ var init_security = __esm({
45237
45344
  });
45238
45345
 
45239
45346
  // packages/cleo/src/dispatch/middleware/sanitizer.ts
45240
- function createSanitizer(getProjectRoot72) {
45347
+ function createSanitizer(getProjectRoot73) {
45241
45348
  return async (req, next) => {
45242
45349
  if (req.params) {
45243
45350
  try {
45244
- const root = getProjectRoot72 ? getProjectRoot72() : void 0;
45351
+ const root = getProjectRoot73 ? getProjectRoot73() : void 0;
45245
45352
  req.params = sanitizeParams(req.params, root, {
45246
45353
  domain: req.domain,
45247
45354
  operation: req.operation
@@ -45343,14 +45450,14 @@ var init_session_resolver = __esm({
45343
45450
  });
45344
45451
 
45345
45452
  // packages/cleo/src/dispatch/middleware/store-write-guard.ts
45346
- function createStoreWriteGuard(getProjectRoot72) {
45453
+ function createStoreWriteGuard(getProjectRoot73) {
45347
45454
  return async (req, next) => {
45348
45455
  if (req.gateway !== "mutate" || ALLOWED_WHILE_READ_ONLY.has(`${req.domain}.${req.operation}`)) {
45349
45456
  return next();
45350
45457
  }
45351
45458
  let projectRoot;
45352
45459
  try {
45353
- projectRoot = getProjectRoot72();
45460
+ projectRoot = getProjectRoot73();
45354
45461
  } catch {
45355
45462
  return next();
45356
45463
  }
@@ -50066,11 +50173,15 @@ var init_list2 = __esm({
50066
50173
  // packages/cleo/src/cli/lib/readline-wizard-io.ts
50067
50174
  import { stdin as input, stdout as output } from "node:process";
50068
50175
  import * as readline from "node:readline/promises";
50176
+ import { Writable } from "node:stream";
50069
50177
  import { WizardFatalError, WizardInterruptError } from "@cleocode/core/setup";
50070
50178
  function stripBracketedPaste(raw) {
50071
50179
  return raw.replace(/\x1b\[200~/g, "").replace(/\x1b\[201~/g, "").trim();
50072
50180
  }
50073
- var SETUP_STDIN_CLOSED_CODE, StdinClosedError, ReadlineWizardIO;
50181
+ function streamIsTTY(stream) {
50182
+ return "isTTY" in stream && stream.isTTY === true;
50183
+ }
50184
+ var SETUP_STDIN_CLOSED_CODE, StdinClosedError, SECRET_ECHO_REFUSED_MESSAGE, MutableOutput, ReadlineWizardIO;
50074
50185
  var init_readline_wizard_io = __esm({
50075
50186
  "packages/cleo/src/cli/lib/readline-wizard-io.ts"() {
50076
50187
  "use strict";
@@ -50090,6 +50201,38 @@ var init_readline_wizard_io = __esm({
50090
50201
  return err instanceof _StdinClosedError;
50091
50202
  }
50092
50203
  };
50204
+ SECRET_ECHO_REFUSED_MESSAGE = 'Refusing to read a secret: stdin is a terminal but terminal mode is off, so the key would be echoed. Pipe it instead: printf %s "$KEY" | cleo decide config --provider layahost --key-stdin (or cleo llm add <provider> --api-key-stdin).';
50205
+ MutableOutput = class extends Writable {
50206
+ /** @param target - Stream that receives writes while unmuted. */
50207
+ constructor(target) {
50208
+ super();
50209
+ this.target = target;
50210
+ this.isTTY = "isTTY" in target && target.isTTY === true;
50211
+ }
50212
+ target;
50213
+ /** When true, writes are dropped. */
50214
+ muted = false;
50215
+ /** Mirrors the wrapped stream: readline enables terminal mode (and echo) from it. */
50216
+ isTTY;
50217
+ /** Terminal width of the wrapped stream, when it reports one. */
50218
+ get columns() {
50219
+ return "columns" in this.target && typeof this.target.columns === "number" ? this.target.columns : void 0;
50220
+ }
50221
+ /** Forward a chunk unless muted. */
50222
+ _write(chunk, encoding, callback) {
50223
+ if (this.muted) {
50224
+ callback();
50225
+ return;
50226
+ }
50227
+ const done = () => callback();
50228
+ if (typeof chunk === "string") this.target.write(chunk, encoding, done);
50229
+ else this.target.write(chunk, done);
50230
+ }
50231
+ /** Write straight to the wrapped stream, bypassing the mute. */
50232
+ writeUnmuted(text) {
50233
+ this.target.write(text);
50234
+ }
50235
+ };
50093
50236
  ReadlineWizardIO = class {
50094
50237
  /**
50095
50238
  * Underlying readline interface.
@@ -50101,6 +50244,10 @@ var init_readline_wizard_io = __esm({
50101
50244
  * @internal
50102
50245
  */
50103
50246
  rl;
50247
+ /** The stream readline echoes into; muted while a secret is typed. */
50248
+ output;
50249
+ /** Whether the input stream is a TTY (the terminal echoes unless readline owns it). */
50250
+ inputIsTTY;
50104
50251
  /** AbortController aborted when stdin closes — surfaced as {@link StdinClosedError}. */
50105
50252
  eofController;
50106
50253
  /**
@@ -50116,11 +50263,22 @@ var init_readline_wizard_io = __esm({
50116
50263
  *
50117
50264
  * @param inStream - Input stream; defaults to `process.stdin`.
50118
50265
  * @param outStream - Output stream passed to readline for terminal-echo
50119
- * purposes only; informational output goes to stderr.
50266
+ * purposes only; informational output goes to stderr. CLI commands pass
50267
+ * `process.stderr` so prompts never reach a redirected stdout.
50268
+ * @param options - See {@link ReadlineWizardIOOptions}; terminal mode
50269
+ * defaults to the input stream's `isTTY`.
50120
50270
  */
50121
- constructor(inStream = input, outStream = output) {
50271
+ constructor(inStream = input, outStream = output, options = {}) {
50122
50272
  this.eofController = new AbortController();
50123
- this.rl = readline.createInterface({ input: inStream, output: outStream });
50273
+ this.output = new MutableOutput(outStream);
50274
+ this.inputIsTTY = streamIsTTY(inStream);
50275
+ this.rl = readline.createInterface({
50276
+ input: inStream,
50277
+ output: this.output,
50278
+ terminal: options.terminal ?? this.inputIsTTY,
50279
+ // No history: a secret must never be recallable with Up-arrow.
50280
+ historySize: 0
50281
+ });
50124
50282
  this.rl.on("close", () => {
50125
50283
  if (!this.eofController.signal.aborted) {
50126
50284
  this.eofController.abort(new StdinClosedError());
@@ -50171,6 +50329,48 @@ var init_readline_wizard_io = __esm({
50171
50329
  this.rethrowEof(err);
50172
50330
  }
50173
50331
  }
50332
+ /**
50333
+ * Ask for a secret without echoing it: the question is written, then the
50334
+ * output stream is muted until the answer is submitted. Bracketed-paste
50335
+ * markers are stripped like {@link prompt}. The answer is removed from
50336
+ * readline's history afterwards.
50337
+ *
50338
+ * @param question - The question, e.g. `API key:`.
50339
+ * @returns The trimmed answer; `''` when none was given.
50340
+ * @throws Error with {@link SECRET_ECHO_REFUSED_MESSAGE} when stdin is a
50341
+ * terminal but terminal mode is off (the terminal would echo the key).
50342
+ * @task T12714
50343
+ */
50344
+ async secret(question) {
50345
+ if (this.inputIsTTY && !this.rl.terminal) throw new Error(SECRET_ECHO_REFUSED_MESSAGE);
50346
+ this.output.writeUnmuted(`${question} `);
50347
+ this.output.muted = true;
50348
+ let raw;
50349
+ try {
50350
+ raw = await this.rl.question("", { signal: this.eofController.signal });
50351
+ return stripBracketedPaste(raw);
50352
+ } catch (err) {
50353
+ return this.rethrowEof(err);
50354
+ } finally {
50355
+ this.output.muted = false;
50356
+ this.output.writeUnmuted("\n");
50357
+ if (raw !== void 0) this.scrubHistory(raw);
50358
+ }
50359
+ }
50360
+ /**
50361
+ * Remove every history entry equal to `line`. `history` is a runtime field
50362
+ * of `readline.Interface` that `@types/node` does not declare, so it is
50363
+ * read reflectively and checked before use.
50364
+ *
50365
+ * @param line - The exact line readline recorded.
50366
+ */
50367
+ scrubHistory(line) {
50368
+ const history = Reflect.get(this.rl, "history");
50369
+ if (!Array.isArray(history)) return;
50370
+ for (let i = history.length - 1; i >= 0; i--) {
50371
+ if (history[i] === line) history.splice(i, 1);
50372
+ }
50373
+ }
50174
50374
  async confirm(question, defaultValue) {
50175
50375
  const hint = defaultValue === void 0 ? "[y/n]" : defaultValue ? "[Y/n]" : "[y/N]";
50176
50376
  let raw;
@@ -50713,7 +50913,7 @@ async function resolveApiKey(args, io) {
50713
50913
  return args["api-key"];
50714
50914
  }
50715
50915
  if (process.stdin.isTTY) {
50716
- return (await io.prompt("API key:")).trim();
50916
+ return (await io.secret("API key (input hidden):")).trim();
50717
50917
  }
50718
50918
  return "";
50719
50919
  }
@@ -52134,14 +52334,14 @@ var init_backup = __esm({
52134
52334
  return;
52135
52335
  }
52136
52336
  const { exportPortableBundle, PortableBundleError } = await import("@cleocode/core/store/portable-bundle.js");
52137
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core");
52337
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core");
52138
52338
  const passphrase = args.encrypt === true ? await resolvePassphrase() : void 0;
52139
52339
  if (args.encrypt === true && passphrase === void 0) return;
52140
52340
  const encSuffix = args.encrypt === true ? "enc." : "";
52141
52341
  try {
52142
52342
  const result = await exportPortableBundle({
52143
52343
  scope,
52144
- projectRoot: scope === "project" || scope === "all" ? getProjectRoot72() : void 0,
52344
+ projectRoot: scope === "project" || scope === "all" ? getProjectRoot73() : void 0,
52145
52345
  outputPath: args.out ?? `./${args.name}.${encSuffix}cleobundle.tar.gz`,
52146
52346
  encrypt: args.encrypt === true,
52147
52347
  passphrase,
@@ -52186,12 +52386,12 @@ var init_backup = __esm({
52186
52386
  await portableImport(bundlePath, args.target, collectFlagValues(rawArgs, "map"), args.force);
52187
52387
  return;
52188
52388
  }
52189
- const { getProjectRoot: getProjectRoot72, getCleoHome: getCleoHome8, getCleoVersion } = await import("@cleocode/core");
52389
+ const { getProjectRoot: getProjectRoot73, getCleoHome: getCleoHome8, getCleoVersion } = await import("@cleocode/core");
52190
52390
  const { BundleError, cleanupStaging, unpackBundle } = await import("@cleocode/core/store/backup-unpack.js");
52191
52391
  const { regenerateConfigJson, regenerateProjectContextJson, regenerateProjectInfoJson } = await import("@cleocode/core/store/regenerators.js");
52192
52392
  const { regenerateAndCompare } = await import("@cleocode/core/store/restore-json-merge.js");
52193
52393
  const { buildConflictReport, writeConflictReport } = await import("@cleocode/core/store/restore-conflict-report.js");
52194
- const projectRoot = getProjectRoot72();
52394
+ const projectRoot = getProjectRoot73();
52195
52395
  if (args.force !== true) {
52196
52396
  const existing = checkForExistingData(projectRoot, getCleoHome8());
52197
52397
  if (existing.length > 0) {
@@ -54360,6 +54560,28 @@ var init_check3 = __esm({
54360
54560
  task: "T12124",
54361
54561
  script: "scripts/check-ct-cleo-thin.mjs",
54362
54562
  description: "ct-cleo SKILL.md does not grow (thin-pointer ratchet)"
54563
+ },
54564
+ {
54565
+ // T12704: an ES module has no `require`. A bare `require()` throws
54566
+ // under Node while vitest supplies one, so tests stay green and the
54567
+ // shipped build fails, usually inside a swallowing `try`: the docs
54568
+ // audit wrote nothing, two doctor checks never ran, and no
54569
+ // .worktreeinclude glob ever copied.
54570
+ id: "gate-34",
54571
+ task: "T12704",
54572
+ script: "scripts/lint-no-esm-bare-require.mjs",
54573
+ description: "No bare require() in ESM package sources"
54574
+ },
54575
+ {
54576
+ // T12663: every model call site is a registered decision site
54577
+ // (spec system-one-integration §3.5, D11158): decide()/askSiteDecision
54578
+ // name a registry id, LLM entry points live in registered files of a
54579
+ // generative/agent rung, a System One site runs `on` only with go-live
54580
+ // evidence, and chokepoint bypasses are baselined per file.
54581
+ id: "gate-35",
54582
+ task: "T12663",
54583
+ script: "scripts/lint-model-call-sites.mjs",
54584
+ description: "Every model call site is a registered decision site (ratchet)"
54363
54585
  }
54364
54586
  ];
54365
54587
  const scriptArgs = strict ? ["--strict"] : ["--check"];
@@ -57382,8 +57604,14 @@ import {
57382
57604
  clearDecideConfig,
57383
57605
  configureDecide,
57384
57606
  describeDecideCredentials,
57385
- probeDecideProvider
57607
+ listDecisionSites,
57608
+ parseDecisionProviderKind,
57609
+ probeDecideProvider,
57610
+ resetDecideBudget,
57611
+ runDecideWizard,
57612
+ SpendResetRefusedError
57386
57613
  } from "@cleocode/core/decide/index.js";
57614
+ import { WizardInterruptError as WizardInterruptError2 } from "@cleocode/core/setup";
57387
57615
  async function readSecretFromStdin() {
57388
57616
  if (process.stdin.isTTY) return "";
57389
57617
  process.stdin.setEncoding("utf-8");
@@ -57395,41 +57623,81 @@ function failValidation(message, operation, fix) {
57395
57623
  cliError(message, 6 /* VALIDATION_ERROR */, { name: "E_VALIDATION", fix }, { operation });
57396
57624
  process.exitCode = 6 /* VALIDATION_ERROR */;
57397
57625
  }
57398
- var CONFIG_FIX, decideConfigCommand, decideStatusCommand, decideAskCommand, decideCommand;
57626
+ async function runConfigWizard(op) {
57627
+ const io = new ReadlineWizardIO(process.stdin, process.stderr);
57628
+ try {
57629
+ cliOutput(await runDecideWizard(io), { command: "decide", operation: op });
57630
+ } catch (err) {
57631
+ if (err instanceof WizardInterruptError2) {
57632
+ process.stderr.write("System One setup cancelled.\n");
57633
+ process.exitCode = 130;
57634
+ return;
57635
+ }
57636
+ failValidation(err instanceof Error ? err.message : "setup failed", op, CONFIG_FIX);
57637
+ } finally {
57638
+ io.close();
57639
+ }
57640
+ }
57641
+ function oneOf(value, allowed) {
57642
+ return allowed.find((a) => a === value);
57643
+ }
57644
+ var CONFIG_FIX, decideConfigCommand, decideStatusCommand, decideAskCommand, decideSitesCommand, decideBudgetResetCommand, decideBudgetCommand, decideCommand;
57399
57645
  var init_decide2 = __esm({
57400
57646
  "packages/cleo/src/cli/commands/decide.ts"() {
57401
57647
  "use strict";
57402
57648
  init_src2();
57403
57649
  init_define_cli_command();
57650
+ init_readline_wizard_io();
57404
57651
  init_renderers();
57405
- CONFIG_FIX = 'printf %s "$KEY" | cleo decide config --url https://provider.example --key-stdin';
57652
+ CONFIG_FIX = 'printf %s "$KEY" | cleo decide config --provider layahost --key-stdin';
57406
57653
  decideConfigCommand = defineCommand({
57407
57654
  meta: {
57408
57655
  name: "config",
57409
- description: "Store the decision provider API URL and key (0600 file in the CLEO home). Prefer --key-stdin so the key stays out of shell history. No flags shows the current settings (key masked)."
57656
+ description: "Store the decision provider, API key and model (0600 file in the CLEO home), then probe it and detect its capabilities. --provider layahost (default) needs only the key; --provider jev needs --url. Prefer --key-stdin so the key stays out of shell history. No flags on a terminal runs the setup wizard (the key is typed hidden); no flags without a terminal shows the current settings (key masked)."
57410
57657
  },
57411
57658
  args: {
57412
- url: { type: "string", description: "Provider API base URL, e.g. https://layahost.com" },
57659
+ provider: {
57660
+ type: "string",
57661
+ description: `Provider: ${DECISION_PROVIDER_KINDS.join("|")} (layahost: fixed URL, model laya-auto; jev: custom URL, required)`
57662
+ },
57663
+ url: {
57664
+ type: "string",
57665
+ description: "Provider API base URL: overrides the layahost default; required for jev"
57666
+ },
57413
57667
  key: {
57414
57668
  type: "string",
57415
57669
  description: "API key. Visible in the process list (ps) and shell history; prefer --key-stdin"
57416
57670
  },
57417
57671
  "key-stdin": { type: "boolean", description: "Read the API key from stdin (recommended)" },
57418
- model: { type: "string", description: "Optional default model; omitted \u2192 provider listing" },
57672
+ model: {
57673
+ type: "string",
57674
+ description: "Default model; omitted \u2192 the stored model, the preset (layahost: laya-auto) or the first listed (jev)"
57675
+ },
57419
57676
  clear: { type: "boolean", description: "Remove the stored URL, key and model" }
57420
57677
  },
57421
57678
  async run({ args }) {
57422
57679
  const op = "decide.config";
57423
57680
  if (args.clear === true)
57424
57681
  return cliOutput(await clearDecideConfig(), { command: "decide", operation: op });
57682
+ const provider = parseDecisionProviderKind(args.provider);
57683
+ if (args.provider !== void 0 && provider === void 0) {
57684
+ return failValidation(`unknown provider '${args.provider}'`, op, CONFIG_FIX);
57685
+ }
57425
57686
  const apiKey = args["key-stdin"] === true ? await readSecretFromStdin() : args.key;
57426
57687
  if (args["key-stdin"] === true && !apiKey)
57427
57688
  return failValidation("--key-stdin set but stdin is empty or a TTY", op, CONFIG_FIX);
57428
- if (args.url === void 0 && apiKey === void 0 && args.model === void 0) {
57689
+ const noSettings = provider === void 0 && args.url === void 0 && apiKey === void 0 && args.model === void 0;
57690
+ if (noSettings && process.stdin.isTTY && process.stderr.isTTY) return runConfigWizard(op);
57691
+ if (noSettings) {
57429
57692
  return cliOutput(describeDecideCredentials(), { command: "decide", operation: op });
57430
57693
  }
57431
57694
  try {
57432
- const result = await configureDecide({ baseUrl: args.url, apiKey, model: args.model });
57695
+ const result = await configureDecide({
57696
+ provider,
57697
+ baseUrl: args.url,
57698
+ apiKey,
57699
+ model: args.model
57700
+ });
57433
57701
  cliOutput(result, { command: "decide", operation: op });
57434
57702
  } catch (err) {
57435
57703
  failValidation(err instanceof Error ? err.message : "invalid settings", op, CONFIG_FIX);
@@ -57439,7 +57707,7 @@ var init_decide2 = __esm({
57439
57707
  decideStatusCommand = defineCommand({
57440
57708
  meta: {
57441
57709
  name: "status",
57442
- description: "Probe the decision provider (GET {url}/v1/models, short timeout): reachable, unauthorized, unconfigured or unreachable. Exits 1 unless reachable."
57710
+ description: "Probe the decision provider (GET {url}/v1/models, short timeout): reachable, unauthorized, key_limit_reached (the key monthly limit), unconfigured or unreachable. Also reports the registered sites count, the provider capabilities and balance (GET /v1/usage, refreshed at most every 10 minutes) and month-to-date spend against decide.budget.monthlyMicros. Exits 1 unless reachable."
57443
57711
  },
57444
57712
  args: {
57445
57713
  "timeout-ms": { type: "string", description: "Probe timeout in ms (default 3000)" }
@@ -57467,15 +57735,95 @@ var init_decide2 = __esm({
57467
57735
  cliOutput(result, { command: "decide", operation: "decide.ask" });
57468
57736
  }
57469
57737
  });
57738
+ decideSitesCommand = defineCommand({
57739
+ meta: {
57740
+ name: "sites",
57741
+ description: "List the System One integration decision sites: rung, ladder, fallback, owner escalation, configured and effective mode, go-live evidence and last-7-day activity. A site that uses System One is effectively off while no provider is configured."
57742
+ },
57743
+ args: {
57744
+ rung: {
57745
+ type: "string",
57746
+ description: `Only sites with this primary rung (${DECISION_RUNGS.join("|")})`
57747
+ },
57748
+ mode: {
57749
+ type: "string",
57750
+ description: `Only sites with this effective mode (${DECISION_SITE_MODES.join("|")})`
57751
+ },
57752
+ id: { type: "string", description: "Only the site with this id" },
57753
+ evidence: { type: "boolean", description: "Only sites with recorded go-live evidence" }
57754
+ },
57755
+ async run({ args }) {
57756
+ const op = "decide.sites";
57757
+ const rung = oneOf(args.rung, DECISION_RUNGS);
57758
+ if (args.rung !== void 0 && rung === void 0) {
57759
+ return failValidation(
57760
+ `unknown rung '${args.rung}'`,
57761
+ op,
57762
+ `--rung ${DECISION_RUNGS.join("|")}`
57763
+ );
57764
+ }
57765
+ const mode = oneOf(args.mode, DECISION_SITE_MODES);
57766
+ if (args.mode !== void 0 && mode === void 0) {
57767
+ return failValidation(
57768
+ `unknown mode '${args.mode}'`,
57769
+ op,
57770
+ `--mode ${DECISION_SITE_MODES.join("|")}`
57771
+ );
57772
+ }
57773
+ const result = await listDecisionSites({
57774
+ rung,
57775
+ mode,
57776
+ id: args.id,
57777
+ evidenceOnly: args.evidence === true
57778
+ });
57779
+ cliOutput(result, { command: "decide", operation: op });
57780
+ }
57781
+ });
57782
+ decideBudgetResetCommand = defineCommand({
57783
+ meta: {
57784
+ name: "reset",
57785
+ description: "Repair a corrupt System One spend ledger (<cleoHome>/decide/spend.json): start a fresh one for this month, moving the old file aside as a receipt. Refuses a readable ledger unless --force; month-to-date spend is always kept when readable, so a reset never lifts a reached cap."
57786
+ },
57787
+ args: {
57788
+ force: {
57789
+ type: "boolean",
57790
+ description: "Reset a ledger that is not corrupt (keeps month-to-date spend; clears in-flight reservations and the key-limit stop)"
57791
+ }
57792
+ },
57793
+ async run({ args }) {
57794
+ const op = "decide.budget.reset";
57795
+ try {
57796
+ const receipt = await resetDecideBudget(void 0, { force: args.force === true });
57797
+ cliOutput(receipt, { command: "decide", operation: op });
57798
+ } catch (err) {
57799
+ if (!(err instanceof SpendResetRefusedError)) throw err;
57800
+ failValidation(err.message, op, "cleo decide status");
57801
+ }
57802
+ }
57803
+ });
57804
+ decideBudgetCommand = defineCommand({
57805
+ meta: {
57806
+ name: "budget",
57807
+ description: "System One monthly spend cap (decide.budget.monthlyMicros): budget reset"
57808
+ },
57809
+ subCommands: { reset: decideBudgetResetCommand },
57810
+ async run({ cmd, rawArgs }) {
57811
+ const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
57812
+ if (firstArg && cmd.subCommands && firstArg in cmd.subCommands) return;
57813
+ await showUsage(cmd);
57814
+ }
57815
+ });
57470
57816
  decideCommand = defineCommand({
57471
57817
  meta: {
57472
57818
  name: "decide",
57473
- description: "Typed-decision (System One) provider: decide config (API URL + key), decide status (reachability probe), decide ask (one debug question). Unconfigured means heuristics answer."
57819
+ description: "System One integration (typed decisions): decide config (provider + API key; wizard on a terminal), decide status (reachability probe), decide ask (one debug question), decide sites (the registered decision sites). Unconfigured means heuristics answer."
57474
57820
  },
57475
57821
  subCommands: {
57476
57822
  config: decideConfigCommand,
57477
57823
  status: decideStatusCommand,
57478
- ask: decideAskCommand
57824
+ ask: decideAskCommand,
57825
+ sites: decideSitesCommand,
57826
+ budget: decideBudgetCommand
57479
57827
  },
57480
57828
  async run({ cmd, rawArgs }) {
57481
57829
  const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
@@ -62769,6 +63117,80 @@ var init_doctor_malformed_ids = __esm({
62769
63117
  }
62770
63118
  });
62771
63119
 
63120
+ // packages/cleo/src/cli/commands/doctor-manifest-rows.ts
63121
+ var doctor_manifest_rows_exports = {};
63122
+ __export(doctor_manifest_rows_exports, {
63123
+ doctorManifestRowsCommand: () => doctorManifestRowsCommand
63124
+ });
63125
+ import {
63126
+ listMalformedManifestRows,
63127
+ MANIFEST_ROW_APPLY_COMMAND,
63128
+ MANIFEST_ROW_REPAIR_COMMAND,
63129
+ repairMalformedManifestRows,
63130
+ rollbackManifestRepair
63131
+ } from "@cleocode/core/memory/pipeline-manifest-sqlite.js";
63132
+ import { getProjectRoot as getProjectRoot46 } from "@cleocode/core/paths.js";
63133
+ var doctorManifestRowsCommand;
63134
+ var init_doctor_manifest_rows = __esm({
63135
+ "packages/cleo/src/cli/commands/doctor-manifest-rows.ts"() {
63136
+ "use strict";
63137
+ init_define_cli_command();
63138
+ init_renderers();
63139
+ doctorManifestRowsCommand = defineCommand({
63140
+ meta: {
63141
+ name: "manifest-rows",
63142
+ description: "List manifest rows whose metadata violates the stored field contract. --repair shows the plan (writes nothing); --repair --apply moves each bad field under _malformed (nothing lost) with a receipt; --rollback <receipt> undoes it."
63143
+ },
63144
+ args: {
63145
+ repair: {
63146
+ type: "boolean",
63147
+ description: "Plan the repair of every malformed row; writes nothing"
63148
+ },
63149
+ apply: {
63150
+ type: "boolean",
63151
+ description: "Write the repair (writes a receipt first); implies --repair"
63152
+ },
63153
+ "dry-run": {
63154
+ type: "boolean",
63155
+ description: "Plan only (the default for --repair); overrides --apply"
63156
+ },
63157
+ rollback: { type: "string", description: "Undo a repair from its receipt file" },
63158
+ json: { type: "boolean", description: "Output as JSON" },
63159
+ human: { type: "boolean", description: "Force human-readable output" },
63160
+ quiet: { type: "boolean", description: "Suppress non-essential output" }
63161
+ },
63162
+ async run({ args }) {
63163
+ const projectRoot = getProjectRoot46();
63164
+ if (typeof args.rollback === "string" && args.rollback !== "") {
63165
+ const result = await rollbackManifestRepair(args.rollback, projectRoot);
63166
+ cliOutput(result, { command: "doctor", operation: "doctor.manifest-rows.rollback" });
63167
+ return;
63168
+ }
63169
+ if (args.repair === true || args.apply === true) {
63170
+ const apply = args.apply === true && args["dry-run"] !== true;
63171
+ const receipt = await repairMalformedManifestRows(projectRoot, { dryRun: !apply });
63172
+ cliOutput(
63173
+ apply ? receipt : { ...receipt, apply: receipt.changes.length > 0 ? MANIFEST_ROW_APPLY_COMMAND : null },
63174
+ {
63175
+ command: "doctor",
63176
+ operation: apply ? "doctor.manifest-rows.apply" : "doctor.manifest-rows.plan"
63177
+ }
63178
+ );
63179
+ return;
63180
+ }
63181
+ const rows = await listMalformedManifestRows(projectRoot);
63182
+ cliOutput(
63183
+ { rows, repair: rows.length > 0 ? MANIFEST_ROW_REPAIR_COMMAND : null },
63184
+ { command: "doctor", operation: "doctor.manifest-rows.run" }
63185
+ );
63186
+ if (rows.length > 0 && (process.exitCode === void 0 || process.exitCode === 0)) {
63187
+ process.exitCode = 1;
63188
+ }
63189
+ }
63190
+ });
63191
+ }
63192
+ });
63193
+
62772
63194
  // packages/cleo/src/cli/commands/doctor-memory-guard.ts
62773
63195
  var doctor_memory_guard_exports = {};
62774
63196
  __export(doctor_memory_guard_exports, {
@@ -62838,7 +63260,7 @@ var doctor_nexus_residency_exports = {};
62838
63260
  __export(doctor_nexus_residency_exports, {
62839
63261
  doctorNexusResidencyCommand: () => doctorNexusResidencyCommand
62840
63262
  });
62841
- import { getCleoHome as getCleoHome6, getProjectRoot as getProjectRoot46 } from "@cleocode/core";
63263
+ import { getCleoHome as getCleoHome6, getProjectRoot as getProjectRoot47 } from "@cleocode/core";
62842
63264
  import { scanNexusSchemaResidency } from "@cleocode/core/doctor/nexus-schema-residency.js";
62843
63265
  var doctorNexusResidencyCommand;
62844
63266
  var init_doctor_nexus_residency = __esm({
@@ -62857,7 +63279,7 @@ var init_doctor_nexus_residency = __esm({
62857
63279
  quiet: { type: "boolean", description: "Suppress non-essential output" }
62858
63280
  },
62859
63281
  async run() {
62860
- const result = scanNexusSchemaResidency(getProjectRoot46(), getCleoHome6());
63282
+ const result = scanNexusSchemaResidency(getProjectRoot47(), getCleoHome6());
62861
63283
  cliOutput(result, {
62862
63284
  command: "doctor",
62863
63285
  operation: "doctor.nexus-residency.run"
@@ -62875,7 +63297,7 @@ var doctor_project_identity_exports = {};
62875
63297
  __export(doctor_project_identity_exports, {
62876
63298
  doctorProjectIdentityCommand: () => doctorProjectIdentityCommand
62877
63299
  });
62878
- import { getProjectRoot as getProjectRoot47 } from "@cleocode/core";
63300
+ import { getProjectRoot as getProjectRoot48 } from "@cleocode/core";
62879
63301
  import {
62880
63302
  inspectProjectIdentity,
62881
63303
  resolveProjectIdentity
@@ -62899,7 +63321,7 @@ var init_doctor_project_identity = __esm({
62899
63321
  quiet: { type: "boolean", description: "Suppress non-essential output" }
62900
63322
  },
62901
63323
  async run({ args }) {
62902
- const projectRoot = getProjectRoot47();
63324
+ const projectRoot = getProjectRoot48();
62903
63325
  if (!args.resolve) {
62904
63326
  const report = inspectProjectIdentity(projectRoot);
62905
63327
  cliOutput(report, { command: "doctor", operation: "doctor.project-identity.inspect" });
@@ -63409,7 +63831,7 @@ var doctor_repair_exports = {};
63409
63831
  __export(doctor_repair_exports, {
63410
63832
  doctorRepairCommand: () => doctorRepairCommand
63411
63833
  });
63412
- import { getLogger as getLogger21, getProjectRoot as getProjectRoot48 } from "@cleocode/core";
63834
+ import { getLogger as getLogger21, getProjectRoot as getProjectRoot49 } from "@cleocode/core";
63413
63835
  import { repairMalformedDbs } from "@cleocode/core/store/repair-malformed-dbs.js";
63414
63836
  var doctorRepairCommand;
63415
63837
  var init_doctor_repair = __esm({
@@ -63453,7 +63875,7 @@ var init_doctor_repair = __esm({
63453
63875
  return;
63454
63876
  }
63455
63877
  const result = repairMalformedDbs({
63456
- projectRoot: getProjectRoot48(),
63878
+ projectRoot: getProjectRoot49(),
63457
63879
  roles: roleArg.length > 0 ? [roleArg] : void 0,
63458
63880
  dryRun,
63459
63881
  logger: getLogger21("doctor-repair")
@@ -63652,7 +64074,7 @@ var doctor_superseded_store_exports = {};
63652
64074
  __export(doctor_superseded_store_exports, {
63653
64075
  doctorSupersededStoreCommand: () => doctorSupersededStoreCommand
63654
64076
  });
63655
- import { getProjectRoot as getProjectRoot49 } from "@cleocode/core";
64077
+ import { getProjectRoot as getProjectRoot50 } from "@cleocode/core";
63656
64078
  import { scanSupersededStores } from "@cleocode/core/doctor/superseded-store.js";
63657
64079
  import { reconcileSupersededStores } from "@cleocode/core/store/exodus/index.js";
63658
64080
  var doctorSupersededStoreCommand;
@@ -63685,7 +64107,7 @@ var init_doctor_superseded_store = __esm({
63685
64107
  },
63686
64108
  async run({ args }) {
63687
64109
  if (args.reconcile === true) {
63688
- const receipt = await reconcileSupersededStores(getProjectRoot49(), {
64110
+ const receipt = await reconcileSupersededStores(getProjectRoot50(), {
63689
64111
  dryRun: args["dry-run"] === true,
63690
64112
  additive: args.additive === true
63691
64113
  });
@@ -63707,7 +64129,7 @@ var init_doctor_superseded_store = __esm({
63707
64129
  );
63708
64130
  return;
63709
64131
  }
63710
- const result = scanSupersededStores(getProjectRoot49());
64132
+ const result = scanSupersededStores(getProjectRoot50());
63711
64133
  cliOutput(result, {
63712
64134
  command: "doctor",
63713
64135
  operation: "doctor.superseded-store.run"
@@ -63805,7 +64227,7 @@ import {
63805
64227
  retryTwinCollapse
63806
64228
  } from "@cleocode/core/doctor/twin-collapse.js";
63807
64229
  import { CleoError as CleoError7 } from "@cleocode/core/errors";
63808
- import { getProjectRoot as getProjectRoot50 } from "@cleocode/core/paths.js";
64230
+ import { getProjectRoot as getProjectRoot51 } from "@cleocode/core/paths.js";
63809
64231
  var doctorTwinCollapseCommand;
63810
64232
  var init_doctor_twin_collapse = __esm({
63811
64233
  "packages/cleo/src/cli/commands/doctor-twin-collapse.ts"() {
@@ -63827,7 +64249,7 @@ var init_doctor_twin_collapse = __esm({
63827
64249
  quiet: { type: "boolean", description: "Suppress non-essential output" }
63828
64250
  },
63829
64251
  async run({ args }) {
63830
- const projectRoot = getProjectRoot50();
64252
+ const projectRoot = getProjectRoot51();
63831
64253
  if (args.retry === true) {
63832
64254
  try {
63833
64255
  const receipts = await retryTwinCollapse(projectRoot);
@@ -63863,7 +64285,7 @@ __export(doctor_worktree_stores_exports, {
63863
64285
  doctorWorktreeStoresCommand: () => doctorWorktreeStoresCommand
63864
64286
  });
63865
64287
  import { scanWorktreeStores } from "@cleocode/core/doctor/worktree-stores.js";
63866
- import { getProjectRoot as getProjectRoot51, resolveStoreOwnerRoot } from "@cleocode/core/paths.js";
64288
+ import { getProjectRoot as getProjectRoot52, resolveStoreOwnerRoot } from "@cleocode/core/paths.js";
63867
64289
  var doctorWorktreeStoresCommand;
63868
64290
  var init_doctor_worktree_stores = __esm({
63869
64291
  "packages/cleo/src/cli/commands/doctor-worktree-stores.ts"() {
@@ -63885,7 +64307,7 @@ var init_doctor_worktree_stores = __esm({
63885
64307
  quiet: { type: "boolean", description: "Suppress non-essential output" }
63886
64308
  },
63887
64309
  async run({ args }) {
63888
- const projectRoot = resolveStoreOwnerRoot(getProjectRoot51());
64310
+ const projectRoot = resolveStoreOwnerRoot(getProjectRoot52());
63889
64311
  const result = scanWorktreeStores(projectRoot, { skipCompare: args["skip-compare"] === true });
63890
64312
  cliOutput(result, {
63891
64313
  command: "doctor",
@@ -64037,7 +64459,7 @@ import {
64037
64459
  resumePreparedKnowledgeRepair,
64038
64460
  runKnowledgeDoctor as runKnowledgeDoctor2
64039
64461
  } from "@cleocode/core/doctor/knowledge.js";
64040
- import { getProjectRoot as getProjectRoot52 } from "@cleocode/core/paths.js";
64462
+ import { getProjectRoot as getProjectRoot53 } from "@cleocode/core/paths.js";
64041
64463
  var doctorKnowledgeSubcommand;
64042
64464
  var init_doctor_knowledge = __esm({
64043
64465
  "packages/cleo/src/cli/commands/doctor-knowledge.ts"() {
@@ -64112,7 +64534,7 @@ var init_doctor_knowledge = __esm({
64112
64534
  },
64113
64535
  async run({ args }) {
64114
64536
  const startedAt = Date.now();
64115
- const root = getProjectRoot52();
64537
+ const root = getProjectRoot53();
64116
64538
  let context;
64117
64539
  let pending;
64118
64540
  try {
@@ -64280,7 +64702,7 @@ import { join as join24 } from "node:path";
64280
64702
  import {
64281
64703
  ensureGlobalAgentRegistryDb,
64282
64704
  getGlobalAgentRegistryNativeDb,
64283
- getProjectRoot as getProjectRoot53,
64705
+ getProjectRoot as getProjectRoot54,
64284
64706
  installAgentFromCant
64285
64707
  } from "@cleocode/core/internal";
64286
64708
  function sha256Hex(bytes) {
@@ -64468,7 +64890,7 @@ var init_migrate_agents_v2 = __esm({
64468
64890
  }
64469
64891
  },
64470
64892
  async run({ args }) {
64471
- const projectRoot = getProjectRoot53();
64893
+ const projectRoot = getProjectRoot54();
64472
64894
  const verbose = args.quiet !== true;
64473
64895
  if (verbose) {
64474
64896
  humanInfo("Scanning .cleo/cant/agents/ and .cleo/agents/ for unregistered agents...");
@@ -64512,7 +64934,7 @@ __export(doctor_exports, {
64512
64934
  });
64513
64935
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync5 } from "node:fs";
64514
64936
  import { join as join25 } from "node:path";
64515
- import { getProjectRoot as getProjectRoot54, pushWarning as pushWarning5 } from "@cleocode/core";
64937
+ import { getProjectRoot as getProjectRoot55, pushWarning as pushWarning5 } from "@cleocode/core";
64516
64938
  import { renderInvariantAuditLines } from "@cleocode/core/doctor/invariant-audit-render.js";
64517
64939
  import {
64518
64940
  quarantineRogueCleoDir,
@@ -64639,6 +65061,7 @@ var init_doctor = __esm({
64639
65061
  init_doctor_legacy_backups();
64640
65062
  init_doctor_legacy_reaper();
64641
65063
  init_doctor_malformed_ids();
65064
+ init_doctor_manifest_rows();
64642
65065
  init_doctor_memory_guard();
64643
65066
  init_doctor_nexus_residency();
64644
65067
  init_doctor_project_identity();
@@ -64672,6 +65095,8 @@ var init_doctor = __esm({
64672
65095
  "legacy-reaper": doctorLegacyReaperCommand,
64673
65096
  // T12128 — task ids that fail the write-path validator
64674
65097
  "malformed-ids": doctorMalformedIdsCommand,
65098
+ // T12686 — manifest rows whose metadata violates the stored field contract (+ --repair/--rollback)
65099
+ "manifest-rows": doctorManifestRowsCommand,
64675
65100
  // T12095 — pre-dual-scope store files still on disk under their old LIVE names
64676
65101
  "superseded-store": doctorSupersededStoreCommand,
64677
65102
  // T12535 — twin collapses (bare schema_meta / sticky_tags → prefixed twins): report + --retry
@@ -64910,7 +65335,7 @@ var init_doctor = __esm({
64910
65335
  const { join: pathJoin } = await import("node:path");
64911
65336
  const { existsSync: existsSync22 } = await import("node:fs");
64912
65337
  const { detectAndHealCoreWorktreeLeak } = await import("@cleocode/worktree");
64913
- const projectRoot = getProjectRoot54();
65338
+ const projectRoot = getProjectRoot55();
64914
65339
  let gitRoot = projectRoot;
64915
65340
  try {
64916
65341
  gitRoot = execFile2("git", ["rev-parse", "--show-toplevel"], {
@@ -64962,7 +65387,7 @@ var init_doctor = __esm({
64962
65387
  }
64963
65388
  if (args.brain) {
64964
65389
  const { computeBrainHealthDashboard } = await import("@cleocode/core/memory/brain-health-dashboard.js");
64965
- const projectRoot = getProjectRoot54();
65390
+ const projectRoot = getProjectRoot55();
64966
65391
  const dashboard = await computeBrainHealthDashboard(projectRoot);
64967
65392
  cliOutput(dashboard, { command: "doctor", operation: "doctor.brain" });
64968
65393
  if (dashboard.hasP0Failure) {
@@ -64971,7 +65396,7 @@ var init_doctor = __esm({
64971
65396
  return;
64972
65397
  }
64973
65398
  if (args["scan-test-fixtures-in-prod"]) {
64974
- const projectRoot = getProjectRoot54();
65399
+ const projectRoot = getProjectRoot55();
64975
65400
  const matches = await scanTestFixturesInProd(projectRoot);
64976
65401
  const dryRun = args["dry-run"] !== false && args.quarantine !== true;
64977
65402
  const quarantined = !dryRun && matches.length > 0 ? await quarantineTestFixtures(projectRoot, matches) : void 0;
@@ -65059,7 +65484,7 @@ var init_doctor = __esm({
65059
65484
  progress.complete("Comprehensive diagnostics complete");
65060
65485
  } else if (args["scan-rogue-cleo-dirs"]) {
65061
65486
  progress.step(0, "Scanning for rogue .cleo/ directories");
65062
- const projectRoot = getProjectRoot54();
65487
+ const projectRoot = getProjectRoot55();
65063
65488
  const reports = scanRogueCleoDirs(projectRoot);
65064
65489
  progress.complete(
65065
65490
  `Found ${reports.length} rogue .cleo/ director${reports.length === 1 ? "y" : "ies"}`
@@ -65068,7 +65493,7 @@ var init_doctor = __esm({
65068
65493
  } else if (args["quarantine-rogue-cleo-dirs"]) {
65069
65494
  const isDryRun = args["dry-run"] === true;
65070
65495
  progress.step(0, `${isDryRun ? "[DRY RUN] " : ""}Scanning for rogue .cleo/ directories`);
65071
- const projectRoot = getProjectRoot54();
65496
+ const projectRoot = getProjectRoot55();
65072
65497
  const reports = scanRogueCleoDirs(projectRoot);
65073
65498
  if (reports.length === 0) {
65074
65499
  progress.complete("No rogue .cleo/ directories found \u2014 nothing to quarantine");
@@ -65122,7 +65547,7 @@ var init_doctor = __esm({
65122
65547
  const { detectAndRemoveLegacyGlobalFiles, detectAndRemoveStrayProjectNexus } = await import("@cleocode/core/store/cleanup-legacy.js");
65123
65548
  const { getCleoHome: getCleoHome8 } = await import("@cleocode/core");
65124
65549
  const cleoHome = getCleoHome8();
65125
- const projectRoot = getProjectRoot54();
65550
+ const projectRoot = getProjectRoot55();
65126
65551
  const legacyResult = detectAndRemoveLegacyGlobalFiles(cleoHome);
65127
65552
  const strayResult = detectAndRemoveStrayProjectNexus(projectRoot);
65128
65553
  const isDryRun = args["dry-run"] === true;
@@ -65155,7 +65580,7 @@ var init_doctor = __esm({
65155
65580
  } else if (args["audit-worktree-orphans"]) {
65156
65581
  progress.step(0, "Comprehensive worktree anomaly audit (T9808 / council D009)");
65157
65582
  const { auditWorktreeOrphansComprehensive, scanWorktreeOrphansBudgeted } = await import("@cleocode/core/doctor/worktree-orphans.js");
65158
- const projectRoot = getProjectRoot54();
65583
+ const projectRoot = getProjectRoot55();
65159
65584
  const timeoutSecs = args["timeout"] !== void 0 ? Number.parseInt(String(args["timeout"]), 10) : 30;
65160
65585
  const timeoutMs = Number.isFinite(timeoutSecs) && timeoutSecs > 0 ? timeoutSecs * 1e3 : 3e4;
65161
65586
  const maxEntriesPerLevel = args["max-entries-per-level"] !== void 0 ? Number.parseInt(String(args["max-entries-per-level"]), 10) : 500;
@@ -65212,7 +65637,7 @@ var init_doctor = __esm({
65212
65637
  `${isDryRun ? "[DRY RUN] " : ""}Scanning + pruning worktree-orphan .cleo/ directories`
65213
65638
  );
65214
65639
  const { pruneWorktreeOrphans, scanWorktreeOrphansBudgeted } = await import("@cleocode/core/doctor/worktree-orphans.js");
65215
- const projectRoot = getProjectRoot54();
65640
+ const projectRoot = getProjectRoot55();
65216
65641
  const timeoutSecs = args["timeout"] !== void 0 ? Number.parseInt(String(args["timeout"]), 10) : 30;
65217
65642
  const timeoutMs = Number.isFinite(timeoutSecs) && timeoutSecs > 0 ? timeoutSecs * 1e3 : 3e4;
65218
65643
  const maxEntriesPerLevel = args["max-entries-per-level"] !== void 0 ? Number.parseInt(String(args["max-entries-per-level"]), 10) : 500;
@@ -65291,7 +65716,7 @@ var init_doctor = __esm({
65291
65716
  `${isDryRun ? "[DRY RUN] " : ""}Migrating .cleo/worktree-include \u2192 .worktreeinclude`
65292
65717
  );
65293
65718
  const { migrateWorktreeIncludeFile } = await import("@cleocode/core");
65294
- const projectRoot = getProjectRoot54();
65719
+ const projectRoot = getProjectRoot55();
65295
65720
  const result = await migrateWorktreeIncludeFile(projectRoot, { dryRun: isDryRun });
65296
65721
  progress.complete(`Migration ${result.action}`);
65297
65722
  cliOutput(result, { command: "doctor", operation: "doctor.migrate-worktree-include" });
@@ -65310,7 +65735,7 @@ var init_doctor = __esm({
65310
65735
  const stepLabel = isFocusedAlias ? "Auditing Saga hierarchy for ADR-073 invariants" : "Walking central INVARIANTS_REGISTRY";
65311
65736
  progress.step(0, stepLabel);
65312
65737
  const { auditInvariantRegistry } = await import("@cleocode/core/doctor/invariant-audit.js");
65313
- const projectRoot = getProjectRoot54();
65738
+ const projectRoot = getProjectRoot55();
65314
65739
  const result = await auditInvariantRegistry(projectRoot, { adrFilter });
65315
65740
  const operation = isFocusedAlias ? "doctor.audit-sagas" : "doctor.audit-invariants";
65316
65741
  const summary = `Invariant audit complete \u2014 ${result.totalCount} entries walked, ${result.errorCount} error / ${result.warningCount} warning / ${result.infoCount} info violation(s), ${result.notApplicableCount} not-applicable, ${result.documentedCount} documented`;
@@ -65332,7 +65757,7 @@ var init_doctor = __esm({
65332
65757
  { command: "doctor", operation: "admin.health" }
65333
65758
  );
65334
65759
  try {
65335
- const projectRoot = getProjectRoot54();
65760
+ const projectRoot = getProjectRoot55();
65336
65761
  const conflicts = readMigrationConflicts(projectRoot);
65337
65762
  if (conflicts.length > 0) {
65338
65763
  progress.complete(
@@ -65363,7 +65788,7 @@ var init_doctor = __esm({
65363
65788
  progress.complete("Health check complete");
65364
65789
  }
65365
65790
  try {
65366
- const projectRoot = getProjectRoot54();
65791
+ const projectRoot = getProjectRoot55();
65367
65792
  const { auditSagaHierarchy } = await import("@cleocode/core/doctor/saga-audit.js");
65368
65793
  const sagaAudit = await auditSagaHierarchy(projectRoot);
65369
65794
  if (sagaAudit.sagas.length === 0) {
@@ -65478,8 +65903,8 @@ var init_done = __esm({
65478
65903
  process.exitCode = 2;
65479
65904
  return;
65480
65905
  }
65481
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core/paths.js");
65482
- const options = { projectRoot: getProjectRoot72(), ...parsed.options };
65906
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core/paths.js");
65907
+ const options = { projectRoot: getProjectRoot73(), ...parsed.options };
65483
65908
  const requested = [
65484
65909
  ...new Set([args.taskId, ...args._ ?? []].map(String))
65485
65910
  ];
@@ -66824,7 +67249,7 @@ __export(gateway_exports, {
66824
67249
  gatewayOpenapiSubCommand: () => gatewayOpenapiSubCommand
66825
67250
  });
66826
67251
  import { resolve as resolve8 } from "node:path";
66827
- import { generateOpenApi, getProjectRoot as getProjectRoot55 } from "@cleocode/core";
67252
+ import { generateOpenApi, getProjectRoot as getProjectRoot56 } from "@cleocode/core";
66828
67253
  var gatewayOpenapiSubCommand, gatewayCommand;
66829
67254
  var init_gateway = __esm({
66830
67255
  "packages/cleo/src/cli/commands/gateway.ts"() {
@@ -66856,7 +67281,7 @@ var init_gateway = __esm({
66856
67281
  const pathCount = Object.keys(doc.paths).length;
66857
67282
  if (typeof args.out === "string" && args.out.length > 0) {
66858
67283
  const { writeFileSync: writeFileSync8 } = await import("node:fs");
66859
- const target = resolve8(getProjectRoot55(), args.out);
67284
+ const target = resolve8(getProjectRoot56(), args.out);
66860
67285
  writeFileSync8(target, json2, "utf8");
66861
67286
  cliOutput(
66862
67287
  { out: target, pathCount, version: doc.info.version, openapi: doc.openapi },
@@ -67317,7 +67742,7 @@ var go_exports = {};
67317
67742
  __export(go_exports, {
67318
67743
  goCommand: () => goCommand
67319
67744
  });
67320
- import { getProjectRoot as getProjectRoot56, go } from "@cleocode/core";
67745
+ import { getProjectRoot as getProjectRoot57, go } from "@cleocode/core";
67321
67746
  var goCommand;
67322
67747
  var init_go = __esm({
67323
67748
  "packages/cleo/src/cli/commands/go.ts"() {
@@ -67343,7 +67768,7 @@ var init_go = __esm({
67343
67768
  }
67344
67769
  },
67345
67770
  async run({ args }) {
67346
- const projectRoot = getProjectRoot56();
67771
+ const projectRoot = getProjectRoot57();
67347
67772
  const { getCurrentSessionId, resolveBoundSessionId } = await import("@cleocode/core/internal");
67348
67773
  let sessionId = getCurrentSessionId(projectRoot) ?? void 0;
67349
67774
  if (sessionId === void 0) {
@@ -67371,7 +67796,7 @@ var goal_exports = {};
67371
67796
  __export(goal_exports, {
67372
67797
  goalCommand: () => goalCommand
67373
67798
  });
67374
- import { getProjectRoot as getProjectRoot57, goal } from "@cleocode/core";
67799
+ import { getProjectRoot as getProjectRoot58, goal } from "@cleocode/core";
67375
67800
  function resolveGoalKind(task) {
67376
67801
  if (typeof task === "string" && task.length > 0) {
67377
67802
  if (!isValidGoalTargetTaskId(task)) {
@@ -67418,7 +67843,7 @@ var init_goal2 = __esm({
67418
67843
  }
67419
67844
  const record = await goal.createGoal(
67420
67845
  { goalKind: kindResult.kind, intent, turnBudget: resolveTurnBudget(args.turns) },
67421
- getProjectRoot57()
67846
+ getProjectRoot58()
67422
67847
  );
67423
67848
  cliOutput(record, { command: "goal set", operation: "goal.set" });
67424
67849
  }
@@ -67429,7 +67854,7 @@ var init_goal2 = __esm({
67429
67854
  description: "Show the current agent's active goal (per-agent scoped)."
67430
67855
  },
67431
67856
  async run() {
67432
- const record = await goal.getActiveGoal(getProjectRoot57());
67857
+ const record = await goal.getActiveGoal(getProjectRoot58());
67433
67858
  cliOutput(record ?? { active: null }, { command: "goal status", operation: "goal.status" });
67434
67859
  }
67435
67860
  });
@@ -67451,7 +67876,7 @@ var init_goal2 = __esm({
67451
67876
  });
67452
67877
  return;
67453
67878
  }
67454
- const cwd = getProjectRoot57();
67879
+ const cwd = getProjectRoot58();
67455
67880
  const parent = await goal.getActiveGoal(cwd);
67456
67881
  if (!parent) {
67457
67882
  cliError(
@@ -67499,7 +67924,7 @@ var init_goal2 = __esm({
67499
67924
  });
67500
67925
  return;
67501
67926
  }
67502
- const cwd = getProjectRoot57();
67927
+ const cwd = getProjectRoot58();
67503
67928
  const result = await goal.advanceGoalWithPersist(goalId, { cwd });
67504
67929
  if (!result) {
67505
67930
  cliError(`Goal '${goalId}' not found.`, 4 /* NOT_FOUND */, { name: "E_NOT_FOUND" });
@@ -67524,7 +67949,7 @@ var init_goal2 = __esm({
67524
67949
  });
67525
67950
  return;
67526
67951
  }
67527
- const cwd = getProjectRoot57();
67952
+ const cwd = getProjectRoot58();
67528
67953
  const active = await goal.getActiveGoal(cwd);
67529
67954
  if (!active) {
67530
67955
  cliError(
@@ -68454,7 +68879,7 @@ var history_exports = {};
68454
68879
  __export(history_exports, {
68455
68880
  historyCommand: () => historyCommand
68456
68881
  });
68457
- var logCommand, workCommand2, historyCommand;
68882
+ var logCommand, workCommand2, rankingCommand, revertCommand, historyCommand;
68458
68883
  var init_history = __esm({
68459
68884
  "packages/cleo/src/cli/commands/history.ts"() {
68460
68885
  "use strict";
@@ -68502,11 +68927,60 @@ var init_history = __esm({
68502
68927
  await dispatchFromCli("query", "tasks", "history", {}, { command: "history" });
68503
68928
  }
68504
68929
  });
68930
+ rankingCommand = defineCommand({
68931
+ meta: {
68932
+ name: "ranking",
68933
+ description: "Who changed a task's priority, severity, kind or depends \u2014 actor, session, reason, before/after (D11161)"
68934
+ },
68935
+ args: {
68936
+ taskId: { type: "positional", description: "Task ID", required: true },
68937
+ limit: { type: "string", description: "Maximum entries (default 50)" }
68938
+ },
68939
+ async run({ args }) {
68940
+ await dispatchFromCli(
68941
+ "query",
68942
+ "tasks",
68943
+ "history",
68944
+ {
68945
+ taskId: String(args.taskId),
68946
+ ranking: true,
68947
+ ...args.limit !== void 0 ? { limit: Number.parseInt(String(args.limit), 10) } : {}
68948
+ },
68949
+ { command: "history" }
68950
+ );
68951
+ }
68952
+ });
68953
+ revertCommand = defineCommand({
68954
+ meta: {
68955
+ name: "revert",
68956
+ description: "Undo one ranking change (an entry id from `cleo history ranking`); refused if a field changed again since, unless --force"
68957
+ },
68958
+ args: {
68959
+ entryId: { type: "positional", description: "ranking_changed entry id", required: true },
68960
+ reason: { type: "string", description: "Why it is reverted (recorded)" },
68961
+ force: { type: "boolean", description: "Revert even though a field changed again since" }
68962
+ },
68963
+ async run({ args }) {
68964
+ await dispatchFromCli(
68965
+ "mutate",
68966
+ "tasks",
68967
+ "ranking.revert",
68968
+ {
68969
+ entryId: String(args.entryId),
68970
+ ...args.reason !== void 0 ? { reason: String(args.reason) } : {},
68971
+ ...args.force === true ? { force: true } : {}
68972
+ },
68973
+ { command: "history" }
68974
+ );
68975
+ }
68976
+ });
68505
68977
  historyCommand = defineCommand({
68506
68978
  meta: { name: "history", description: "Completion timeline and productivity analytics" },
68507
68979
  subCommands: {
68508
68980
  log: logCommand,
68509
- work: workCommand2
68981
+ work: workCommand2,
68982
+ ranking: rankingCommand,
68983
+ revert: revertCommand
68510
68984
  },
68511
68985
  async run({ cmd, rawArgs }) {
68512
68986
  const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
@@ -68522,7 +68996,7 @@ var hygiene_exports = {};
68522
68996
  __export(hygiene_exports, {
68523
68997
  hygieneCommand: () => hygieneCommand
68524
68998
  });
68525
- import { getProjectRoot as getProjectRoot58 } from "@cleocode/core";
68999
+ import { getProjectRoot as getProjectRoot59 } from "@cleocode/core";
68526
69000
  import { runSpawnReadinessHygieneCli } from "@cleocode/core/hygiene/validate-spawn-readiness.js";
68527
69001
  var hygieneCommand;
68528
69002
  var init_hygiene = __esm({
@@ -68551,7 +69025,7 @@ var init_hygiene = __esm({
68551
69025
  }
68552
69026
  },
68553
69027
  async run({ args }) {
68554
- const projectRoot = args["project-root"] || getProjectRoot58() || process.cwd();
69028
+ const projectRoot = args["project-root"] || getProjectRoot59() || process.cwd();
68555
69029
  const worktreePath = args["worktree-path"];
68556
69030
  await runSpawnReadinessHygieneCli(projectRoot, worktreePath);
68557
69031
  }
@@ -69894,7 +70368,7 @@ var llm_cost_exports = {};
69894
70368
  __export(llm_cost_exports, {
69895
70369
  costCommand: () => costCommand
69896
70370
  });
69897
- import { getProjectRoot as getProjectRoot59 } from "@cleocode/core/internal";
70371
+ import { getProjectRoot as getProjectRoot60 } from "@cleocode/core/internal";
69898
70372
  import { computeCost } from "@cleocode/core/llm/usage-pricing";
69899
70373
  function resolveSessionId(raw) {
69900
70374
  if (raw === "current") {
@@ -69967,7 +70441,7 @@ var init_llm_cost = __esm({
69967
70441
  process.exit(6);
69968
70442
  }
69969
70443
  const sessionId = resolveSessionId(rawSessionId);
69970
- const projectRoot = getProjectRoot59(process.cwd());
70444
+ const projectRoot = getProjectRoot60(process.cwd());
69971
70445
  let breakdown;
69972
70446
  try {
69973
70447
  breakdown = await loadSessionCostBreakdown(projectRoot, sessionId);
@@ -71302,7 +71776,7 @@ var memory_exports = {};
71302
71776
  __export(memory_exports, {
71303
71777
  memoryCommand: () => memoryCommand
71304
71778
  });
71305
- import { getProjectRoot as getProjectRoot60 } from "@cleocode/core";
71779
+ import { getProjectRoot as getProjectRoot61 } from "@cleocode/core";
71306
71780
  import {
71307
71781
  getBrainDb as getBrainDb2,
71308
71782
  getDreamStatus,
@@ -72260,7 +72734,7 @@ var init_memory3 = __esm({
72260
72734
  },
72261
72735
  args: {},
72262
72736
  async run() {
72263
- const root = getProjectRoot60();
72737
+ const root = getProjectRoot61();
72264
72738
  try {
72265
72739
  const result = await runConsolidation(root);
72266
72740
  cliOutput(result, { command: "memory-consolidate", operation: "memory.consolidate" });
@@ -72284,7 +72758,7 @@ var init_memory3 = __esm({
72284
72758
  }
72285
72759
  },
72286
72760
  async run({ args }) {
72287
- const root = getProjectRoot60();
72761
+ const root = getProjectRoot61();
72288
72762
  if (args.status) {
72289
72763
  try {
72290
72764
  const status = await getDreamStatus(root);
@@ -72321,7 +72795,7 @@ var init_memory3 = __esm({
72321
72795
  }
72322
72796
  },
72323
72797
  async run({ args }) {
72324
- const root = getProjectRoot60();
72798
+ const root = getProjectRoot61();
72325
72799
  try {
72326
72800
  const { runObserver, runReflector } = await import("@cleocode/core/memory");
72327
72801
  const observerResult = await runObserver(root, args.session, {
@@ -72361,7 +72835,7 @@ var init_memory3 = __esm({
72361
72835
  }
72362
72836
  },
72363
72837
  async run({ args }) {
72364
- const root = getProjectRoot60();
72838
+ const root = getProjectRoot61();
72365
72839
  await getBrainDb2(root);
72366
72840
  const { getBrainNativeDb: getBrainNativeDb3 } = await import("@cleocode/core/internal");
72367
72841
  const nativeDb = getBrainNativeDb3();
@@ -72399,7 +72873,7 @@ var init_memory3 = __esm({
72399
72873
  },
72400
72874
  async run({ args }) {
72401
72875
  const core2 = await import("@cleocode/core/internal");
72402
- const nexusDb = await core2.getNexusDb(getProjectRoot60());
72876
+ const nexusDb = await core2.getNexusDb(getProjectRoot61());
72403
72877
  const result = args.restore ? await core2.restorePrunedTraits(
72404
72878
  nexusDb,
72405
72879
  String(args.restore),
@@ -72429,7 +72903,7 @@ var init_memory3 = __esm({
72429
72903
  return;
72430
72904
  }
72431
72905
  const core2 = await import("@cleocode/core/internal");
72432
- const nexusDb = await core2.getNexusDb(getProjectRoot60());
72906
+ const nexusDb = await core2.getNexusDb(getProjectRoot61());
72433
72907
  const previous = await core2.setUserProfileTraitScope(nexusDb, String(args.key), scope);
72434
72908
  if (previous === null) {
72435
72909
  cliError(`No user-profile trait "${args.key}"`, "E_NOT_FOUND", { name: "E_NOT_FOUND" });
@@ -72453,7 +72927,7 @@ var init_memory3 = __esm({
72453
72927
  }
72454
72928
  },
72455
72929
  async run({ args }) {
72456
- const root = getProjectRoot60();
72930
+ const root = getProjectRoot61();
72457
72931
  try {
72458
72932
  await getBrainDb2(root);
72459
72933
  const { totalDuplicateRows, groups } = await scanDuplicateEntries();
@@ -72499,7 +72973,7 @@ var init_memory3 = __esm({
72499
72973
  async run({ args }) {
72500
72974
  const sourceDir = args.from;
72501
72975
  const isDryRun = !!args["dry-run"];
72502
- const projectRoot = getProjectRoot60();
72976
+ const projectRoot = getProjectRoot61();
72503
72977
  try {
72504
72978
  const result = await importMemoryFiles({
72505
72979
  sourceDir,
@@ -72650,7 +73124,7 @@ var init_memory3 = __esm({
72650
73124
  },
72651
73125
  args: {},
72652
73126
  async run() {
72653
- const root = getProjectRoot60();
73127
+ const root = getProjectRoot61();
72654
73128
  try {
72655
73129
  await getBrainDb2(root);
72656
73130
  const result = await getTierStats(root);
@@ -72693,7 +73167,7 @@ var init_memory3 = __esm({
72693
73167
  }
72694
73168
  },
72695
73169
  async run({ args }) {
72696
- const root = getProjectRoot60();
73170
+ const root = getProjectRoot61();
72697
73171
  const targetTier = args.to;
72698
73172
  const reason = args.reason;
72699
73173
  const validTiers = ["medium", "long"];
@@ -72759,7 +73233,7 @@ var init_memory3 = __esm({
72759
73233
  }
72760
73234
  },
72761
73235
  async run({ args }) {
72762
- const root = getProjectRoot60();
73236
+ const root = getProjectRoot61();
72763
73237
  const targetTier = args.to;
72764
73238
  const reason = args.reason;
72765
73239
  const validTiers = ["short", "medium"];
@@ -73232,7 +73706,7 @@ var migrate_claude_mem_exports = {};
73232
73706
  __export(migrate_claude_mem_exports, {
73233
73707
  migrateClaudeMemCommand: () => migrateClaudeMemCommand
73234
73708
  });
73235
- import { getProjectRoot as getProjectRoot61, migrateClaudeMem } from "@cleocode/core/internal";
73709
+ import { getProjectRoot as getProjectRoot62, migrateClaudeMem } from "@cleocode/core/internal";
73236
73710
  import { ingestLooseAgentOutputs, ingestRcasdDirectories } from "@cleocode/core/memory";
73237
73711
  import { getDb as getDb2 } from "@cleocode/core/store/sqlite";
73238
73712
  var storageCommand, claudeMemCommand, manifestIngestCommand, migrateClaudeMemCommand;
@@ -73295,7 +73769,7 @@ var init_migrate_claude_mem = __esm({
73295
73769
  }
73296
73770
  },
73297
73771
  async run({ args }) {
73298
- const root = getProjectRoot61();
73772
+ const root = getProjectRoot62();
73299
73773
  try {
73300
73774
  const result = await migrateClaudeMem(root, {
73301
73775
  sourcePath: args.source,
@@ -73344,7 +73818,7 @@ var init_migrate_claude_mem = __esm({
73344
73818
  }
73345
73819
  },
73346
73820
  async run({ args }) {
73347
- const projectRoot = getProjectRoot61();
73821
+ const projectRoot = getProjectRoot62();
73348
73822
  try {
73349
73823
  const db = await getDb2(projectRoot);
73350
73824
  const rcasdFlag = Boolean(args.rcasd);
@@ -73462,7 +73936,7 @@ __export(nexus_exports, {
73462
73936
  import { statSync as statSync2 } from "node:fs";
73463
73937
  import { appendFile as appendFile2, mkdir as mkdir5 } from "node:fs/promises";
73464
73938
  import path4 from "node:path";
73465
- import { getProjectRoot as getProjectRoot62 } from "@cleocode/core";
73939
+ import { getProjectRoot as getProjectRoot63 } from "@cleocode/core";
73466
73940
  import { getSymbolImpact } from "@cleocode/core/nexus";
73467
73941
  import { runNexusAnalysis } from "@cleocode/core/nexus/analyze-orchestrator.js";
73468
73942
  import {
@@ -73633,7 +74107,7 @@ var init_nexus3 = __esm({
73633
74107
  async run({ args }) {
73634
74108
  applyJsonFlag2(args.json);
73635
74109
  const projectIdOverride = args["project-id"];
73636
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
74110
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
73637
74111
  const startTime = Date.now();
73638
74112
  if (args.path) {
73639
74113
  let isDir = false;
@@ -73693,7 +74167,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648), so the coun
73693
74167
  process.exitCode = 2 /* INVALID_INPUT */;
73694
74168
  return;
73695
74169
  }
73696
- const currentRoot = getProjectRoot62();
74170
+ const currentRoot = getProjectRoot63();
73697
74171
  if (args.path && path4.resolve(repoPath) !== path4.resolve(currentRoot)) {
73698
74172
  cliError(
73699
74173
  `nexus status cannot report on '${repoPath}' from this project.
@@ -74247,7 +74721,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
74247
74721
  applyJsonFlag2(args.json);
74248
74722
  const startTime = Date.now();
74249
74723
  const projectIdOverride = args["project-id"];
74250
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
74724
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
74251
74725
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
74252
74726
  const response = await dispatchRaw("query", "nexus", "clusters", { projectId, repoPath });
74253
74727
  const durationMs = Date.now() - startTime;
@@ -74291,7 +74765,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
74291
74765
  applyJsonFlag2(args.json);
74292
74766
  const startTime = Date.now();
74293
74767
  const projectIdOverride = args["project-id"];
74294
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
74768
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
74295
74769
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
74296
74770
  const response = await dispatchRaw("query", "nexus", "flows", { projectId, repoPath });
74297
74771
  const durationMs = Date.now() - startTime;
@@ -74334,7 +74808,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
74334
74808
  void appendDeprecationTelemetry("nexus.context", "cleo graph context");
74335
74809
  const startTime = Date.now();
74336
74810
  const projectIdOverride = args["project-id"];
74337
- const repoPath = getProjectRoot62();
74811
+ const repoPath = getProjectRoot63();
74338
74812
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
74339
74813
  const limit = parseInt(args.limit, 10);
74340
74814
  const symbolName = args.symbol;
@@ -74397,7 +74871,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
74397
74871
  const startTime = Date.now();
74398
74872
  const whyFlag = !!args.why;
74399
74873
  const projectIdOverride = args["project-id"];
74400
- const repoPath = getProjectRoot62();
74874
+ const repoPath = getProjectRoot63();
74401
74875
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
74402
74876
  const maxDepth = Math.min(parseInt(args.depth, 10), 5);
74403
74877
  const symbolName = args.symbol;
@@ -74501,7 +74975,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
74501
74975
  const projectIdOverride = args["project-id"];
74502
74976
  const full = !!args.full;
74503
74977
  const ctx = getFormatContext();
74504
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
74978
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
74505
74979
  if (args.incremental)
74506
74980
  humanWarn(
74507
74981
  "[nexus] --incremental is deprecated and has no effect: incremental is the default."
@@ -74631,7 +75105,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
74631
75105
  async run({ args }) {
74632
75106
  applyJsonFlag2(args.json);
74633
75107
  const startTime = Date.now();
74634
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
75108
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
74635
75109
  const name = args.name;
74636
75110
  const response = await dispatchRaw("mutate", "nexus", "projects.register", {
74637
75111
  path: repoPath,
@@ -75083,7 +75557,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75083
75557
  applyJsonFlag2(args.json);
75084
75558
  const startTime = Date.now();
75085
75559
  const projectIdOverride = args["project-id"];
75086
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
75560
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
75087
75561
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
75088
75562
  const response = await dispatchRaw("mutate", "nexus", "refresh-bridge", {
75089
75563
  repoPath,
@@ -75189,7 +75663,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75189
75663
  async run({ args }) {
75190
75664
  applyJsonFlag2(args.json);
75191
75665
  const startTime = Date.now();
75192
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
75666
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
75193
75667
  const projectIdOverride = args["project-id"];
75194
75668
  const beforeRef = args.before ?? "HEAD~1";
75195
75669
  const afterRef = args.after ?? "HEAD";
@@ -75307,7 +75781,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75307
75781
  applyJsonFlag2(args.json);
75308
75782
  const startTime = Date.now();
75309
75783
  const projectIdOverride = args["project-id"];
75310
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
75784
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
75311
75785
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
75312
75786
  const response = await dispatchRaw("query", "nexus", "route-map", { projectId });
75313
75787
  const durationMs = Date.now() - startTime;
@@ -75363,7 +75837,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75363
75837
  const startTime = Date.now();
75364
75838
  const routeSymbol = args.routeSymbol;
75365
75839
  const projectIdOverride = args["project-id"];
75366
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
75840
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
75367
75841
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
75368
75842
  const response = await dispatchRaw("query", "nexus", "shape-check", { routeSymbol, projectId });
75369
75843
  const durationMs = Date.now() - startTime;
@@ -75759,7 +76233,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75759
76233
  async run({ args }) {
75760
76234
  applyJsonFlag2(args.json);
75761
76235
  const startTime = Date.now();
75762
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
76236
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
75763
76237
  const projectIdOverride = args["project-id"];
75764
76238
  const projectId = projectIdOverride ?? Buffer.from(repoPath).toString("base64url").slice(0, 32);
75765
76239
  const response = await dispatchRaw("mutate", "nexus", "contracts-sync", {
@@ -75869,7 +76343,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75869
76343
  async run({ args }) {
75870
76344
  applyJsonFlag2(args.json);
75871
76345
  const startTime = Date.now();
75872
- const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot62();
76346
+ const repoPath = args.path ? path4.resolve(args.path) : getProjectRoot63();
75873
76347
  const projectId = Buffer.from(repoPath).toString("base64url").slice(0, 32);
75874
76348
  const response = await dispatchRaw("mutate", "nexus", "contracts-link-tasks", {
75875
76349
  projectId,
@@ -75953,7 +76427,7 @@ The code-intelligence graph is project-scoped (ADR-090 \xB7 T11648): one store p
75953
76427
  const isIncremental = !!args.incremental;
75954
76428
  try {
75955
76429
  const result = await runNexusWiki({
75956
- projectRoot: getProjectRoot62(),
76430
+ projectRoot: getProjectRoot63(),
75957
76431
  outputDir,
75958
76432
  communityFilter,
75959
76433
  incremental: isIncremental
@@ -76303,7 +76777,7 @@ __export(orchestrate_exports, {
76303
76777
  });
76304
76778
  import { execFileSync as execFileSync5 } from "node:child_process";
76305
76779
  import { orchestration } from "@cleocode/core";
76306
- import { BUILD_CONFIG as BUILD_CONFIG2, getProjectRoot as getProjectRoot63 } from "@cleocode/core/internal";
76780
+ import { BUILD_CONFIG as BUILD_CONFIG2, getProjectRoot as getProjectRoot64 } from "@cleocode/core/internal";
76307
76781
  function formatRollupTable(rollup) {
76308
76782
  const waves = "waves" in rollup ? rollup.waves : [rollup];
76309
76783
  const lines = [];
@@ -76446,7 +76920,7 @@ var init_orchestrate3 = __esm({
76446
76920
  },
76447
76921
  async run({ args }) {
76448
76922
  const rateWindowHours = args.window !== void 0 ? Number.parseFloat(String(args.window)) : void 0;
76449
- const metrics = await orchestration.collectOrchestrateDashboard(getProjectRoot63(), {
76923
+ const metrics = await orchestration.collectOrchestrateDashboard(getProjectRoot64(), {
76450
76924
  ...rateWindowHours !== void 0 && Number.isFinite(rateWindowHours) && rateWindowHours > 0 ? { rateWindowHours } : {}
76451
76925
  });
76452
76926
  cliOutput(metrics, {
@@ -77896,7 +78370,7 @@ __export(project_exports, {
77896
78370
  import { resolve as resolve9 } from "node:path";
77897
78371
  import {
77898
78372
  CleoError as CleoError10,
77899
- getProjectRoot as getProjectRoot64,
78373
+ getProjectRoot as getProjectRoot65,
77900
78374
  moveProject,
77901
78375
  projectLifecycle,
77902
78376
  renameProject,
@@ -77918,7 +78392,7 @@ function emitEngineFailure(error, operation) {
77918
78392
  }
77919
78393
  function resolveRootOrFail(operation) {
77920
78394
  try {
77921
- return getProjectRoot64();
78395
+ return getProjectRoot65();
77922
78396
  } catch (err) {
77923
78397
  const code = err instanceof CleoError10 && typeof err.details?.["code"] === "string" ? err.details["code"] : "E_NOT_CLEO_PROJECT";
77924
78398
  emitEngineFailure(
@@ -78704,7 +79178,7 @@ var refresh_memory_exports = {};
78704
79178
  __export(refresh_memory_exports, {
78705
79179
  refreshMemoryCommand: () => refreshMemoryCommand
78706
79180
  });
78707
- import { getProjectRoot as getProjectRoot65 } from "@cleocode/core";
79181
+ import { getProjectRoot as getProjectRoot66 } from "@cleocode/core";
78708
79182
  var refreshMemoryCommand;
78709
79183
  var init_refresh_memory = __esm({
78710
79184
  "packages/cleo/src/cli/commands/refresh-memory.ts"() {
@@ -78717,7 +79191,7 @@ var init_refresh_memory = __esm({
78717
79191
  description: "Regenerate .cleo/memory-bridge.md from brain.db"
78718
79192
  },
78719
79193
  async run() {
78720
- const projectDir = getProjectRoot65();
79194
+ const projectDir = getProjectRoot66();
78721
79195
  const { writeMemoryBridge } = await import("@cleocode/core/internal");
78722
79196
  const result = await writeMemoryBridge(projectDir);
78723
79197
  if (result.written) {
@@ -80303,7 +80777,7 @@ import fs3 from "node:fs";
80303
80777
  import path5 from "node:path";
80304
80778
  import {
80305
80779
  CleoError as CleoError12,
80306
- getProjectRoot as getProjectRoot66,
80780
+ getProjectRoot as getProjectRoot67,
80307
80781
  getTaskAccessor as getTaskAccessor3,
80308
80782
  parseConflictReport,
80309
80783
  setAtPath
@@ -80324,7 +80798,7 @@ var init_restore = __esm({
80324
80798
  description: "Apply manually-resolved conflicts from .cleo/restore-conflicts.md"
80325
80799
  },
80326
80800
  async run() {
80327
- const projectRoot = getProjectRoot66();
80801
+ const projectRoot = getProjectRoot67();
80328
80802
  const reportPath = path5.join(projectRoot, CLEO_DIR_NAME3, RESTORE_CONFLICTS_MD);
80329
80803
  if (!fs3.existsSync(reportPath)) {
80330
80804
  humanLine("No pending restore conflicts. Nothing to finalize.");
@@ -80413,6 +80887,11 @@ var init_restore = __esm({
80413
80887
  type: "string",
80414
80888
  description: "Backup scope to restore from: project or global (default: project)",
80415
80889
  default: "project"
80890
+ },
80891
+ "confirm-owner-store": {
80892
+ type: "boolean",
80893
+ description: "From inside a git worktree: allow overwriting the owning project's LIVE store (refused without it)",
80894
+ default: false
80416
80895
  }
80417
80896
  },
80418
80897
  async run({ args }) {
@@ -80423,7 +80902,8 @@ var init_restore = __esm({
80423
80902
  action: "restore.file",
80424
80903
  file: fileName,
80425
80904
  dryRun: args["dry-run"] || void 0,
80426
- scope
80905
+ scope,
80906
+ confirmOwnerStore: args["confirm-owner-store"] || void 0
80427
80907
  });
80428
80908
  if (!response.success) {
80429
80909
  const code = ExitCode[response.error?.code] ?? 1 /* GENERAL_ERROR */;
@@ -80687,7 +81167,7 @@ var init_restore = __esm({
80687
81167
  // packages/cleo/src/cli/commands/revert.ts
80688
81168
  var revert_exports = {};
80689
81169
  __export(revert_exports, {
80690
- revertCommand: () => revertCommand
81170
+ revertCommand: () => revertCommand2
80691
81171
  });
80692
81172
  import { readFile as readFile8 } from "node:fs/promises";
80693
81173
  import { join as join29 } from "node:path";
@@ -80755,14 +81235,14 @@ async function loadOwnerPubkeys(projectRoot) {
80755
81235
  return /* @__PURE__ */ new Set();
80756
81236
  }
80757
81237
  }
80758
- var OWNER_PUBKEYS_FILE, revertCommand;
81238
+ var OWNER_PUBKEYS_FILE, revertCommand2;
80759
81239
  var init_revert = __esm({
80760
81240
  "packages/cleo/src/cli/commands/revert.ts"() {
80761
81241
  "use strict";
80762
81242
  init_dist();
80763
81243
  init_renderers();
80764
81244
  OWNER_PUBKEYS_FILE = ".cleo/owner-pubkeys.json";
80765
- revertCommand = defineCommand({
81245
+ revertCommand2 = defineCommand({
80766
81246
  meta: {
80767
81247
  name: "revert",
80768
81248
  description: "Owner kill-switch: squash-revert all sentient merge commits from a receipt ID"
@@ -81247,8 +81727,8 @@ var init_saga = __esm({
81247
81727
  }
81248
81728
  },
81249
81729
  async run({ args }) {
81250
- const { sagas: sagas2, getProjectRoot: getProjectRoot72 } = await import("@cleocode/core");
81251
- const projectRoot = getProjectRoot72();
81730
+ const { sagas: sagas2, getProjectRoot: getProjectRoot73 } = await import("@cleocode/core");
81731
+ const projectRoot = getProjectRoot73();
81252
81732
  const sagaId = typeof args.sagaId === "string" && args.sagaId.length > 0 ? args.sagaId : void 0;
81253
81733
  const result = await sagas2.sagaNext(projectRoot, { sagaId });
81254
81734
  cliOutput(result.success ? result.data : result, { command: "saga", operation: "saga.next" });
@@ -83079,7 +83559,7 @@ var sequence_exports = {};
83079
83559
  __export(sequence_exports, {
83080
83560
  sequenceCommand: () => sequenceCommand
83081
83561
  });
83082
- import { getProjectRoot as getProjectRoot67 } from "@cleocode/core/internal";
83562
+ import { getProjectRoot as getProjectRoot68 } from "@cleocode/core/internal";
83083
83563
  var showCommand12, checkCommand7, repairCommand3, sequenceCommand;
83084
83564
  var init_sequence = __esm({
83085
83565
  "packages/cleo/src/cli/commands/sequence.ts"() {
@@ -83115,7 +83595,7 @@ var init_sequence = __esm({
83115
83595
  meta: { name: "repair", description: "Reset counter to max + 1 if behind" },
83116
83596
  async run() {
83117
83597
  const { repairSequence } = await import("@cleocode/core/internal");
83118
- const projectRoot = getProjectRoot67();
83598
+ const projectRoot = getProjectRoot68();
83119
83599
  const repair = await repairSequence(projectRoot);
83120
83600
  const result = {
83121
83601
  repaired: repair.repaired,
@@ -83712,8 +84192,8 @@ var init_session4 = __esm({
83712
84192
  "audit-scope": { type: "string", description: "Audit log scope (global|local)" }
83713
84193
  },
83714
84194
  async run({ args }) {
83715
- const { detectSessionDrift, getProjectRoot: getProjectRoot72 } = await import("@cleocode/core");
83716
- const projectRoot = await getProjectRoot72();
84195
+ const { detectSessionDrift, getProjectRoot: getProjectRoot73 } = await import("@cleocode/core");
84196
+ const projectRoot = await getProjectRoot73();
83717
84197
  const scope = args["audit-scope"] === "local" ? "local" : "global";
83718
84198
  const report = await detectSessionDrift({ projectRoot, auditScope: scope });
83719
84199
  cliOutput(report, { command: "session drift", operation: "session.drift" });
@@ -83973,7 +84453,8 @@ import {
83973
84453
  createDefaultWizardRunner,
83974
84454
  mergeConfigJson,
83975
84455
  printWhoamiSummaryAndOfferTui,
83976
- WizardInterruptError as WizardInterruptError2
84456
+ SetupConfigJsonError,
84457
+ WizardInterruptError as WizardInterruptError3
83977
84458
  } from "@cleocode/core/setup";
83978
84459
  function buildWizardOptions(args) {
83979
84460
  const out = {};
@@ -84131,12 +84612,12 @@ var init_setup = __esm({
84131
84612
  setupCommand2 = defineCommand({
84132
84613
  meta: {
84133
84614
  name: "setup",
84134
- description: "Interactive setup wizard \u2014 runs all 8 sections in canonical order (identity \u2192 llm \u2192 sentient \u2192 harness \u2192 brain \u2192 project-conventions \u2192 integrations \u2192 verification). Use --section <name> for a single section, --non-interactive with section-specific flags to configure without prompts, --config-json for fully scripted setup, or --reset to reconfigure already-set sections."
84615
+ description: "Interactive setup wizard \u2014 runs every section in canonical order (llm \u2192 system-one \u2192 models-roles \u2192 identity \u2192 sentient \u2192 project-conventions \u2192 harness \u2192 brain \u2192 integrations \u2192 telemetry \u2192 verification); system-one is optional. Use --section <name> for a single section, --non-interactive with section-specific flags to configure without prompts, --config-json for fully scripted setup, or --reset to reconfigure already-set sections."
84135
84616
  },
84136
84617
  args: {
84137
84618
  section: {
84138
84619
  type: "string",
84139
- description: "Run only one named section. Valid: llm | models-roles | identity | sentient | harness | brain | project-conventions | integrations | verification"
84620
+ description: "Run only one named section. Valid: llm | system-one | models-roles | identity | sentient | harness | brain | project-conventions | integrations | telemetry | verification"
84140
84621
  },
84141
84622
  "non-interactive": {
84142
84623
  type: "boolean",
@@ -84216,20 +84697,24 @@ var init_setup = __esm({
84216
84697
  }
84217
84698
  },
84218
84699
  async run({ args }) {
84219
- const io = new ReadlineWizardIO();
84700
+ const io = new ReadlineWizardIO(process.stdin, process.stderr);
84220
84701
  let result;
84221
84702
  try {
84222
84703
  result = await runSetup(args, io);
84223
84704
  } catch (err) {
84224
84705
  io.close();
84225
- if (err instanceof WizardInterruptError2 || err?.isWizardInterruptError) {
84706
+ if (err instanceof WizardInterruptError3 || err?.isWizardInterruptError) {
84226
84707
  process.stderr.write("Setup interrupted. Run 'cleo setup' to continue.\n");
84227
84708
  process.exit(130);
84228
84709
  }
84229
- if (err instanceof WizardInterruptError2) {
84710
+ if (err instanceof WizardInterruptError3) {
84230
84711
  process.stderr.write("Setup interrupted. Run 'cleo setup' to continue.\n");
84231
84712
  process.exit(130);
84232
84713
  }
84714
+ if (err instanceof SetupConfigJsonError) {
84715
+ cliError(err.message, 6, { name: err.codeName, fix: err.fix });
84716
+ process.exit(6);
84717
+ }
84233
84718
  if (StdinClosedError.is(err)) {
84234
84719
  cliError(err.message, 1, {
84235
84720
  name: err.codeName,
@@ -84433,7 +84918,8 @@ import {
84433
84918
  restoreBundledSkillQuarantine,
84434
84919
  runBundledSkillPrune,
84435
84920
  runDoctorAdopt,
84436
- runDoctorBridge
84921
+ runDoctorBridge,
84922
+ unkeepBundledSkill
84437
84923
  } from "@cleocode/core";
84438
84924
  function buildSkillsDoctorAdoptAdapters() {
84439
84925
  return {
@@ -84465,6 +84951,7 @@ var listCommand24, searchCommand4, findCommand8, validateCommand8, infoCommand,
84465
84951
  var init_skills2 = __esm({
84466
84952
  "packages/cleo/src/cli/commands/skills.ts"() {
84467
84953
  "use strict";
84954
+ init_src2();
84468
84955
  init_dist();
84469
84956
  init_cli();
84470
84957
  init_subcommand_guard();
@@ -84942,15 +85429,31 @@ var init_skills2 = __esm({
84942
85429
  doctorRestoreCommand = defineCommand({
84943
85430
  meta: {
84944
85431
  name: "restore",
84945
- description: "List skill quarantines, or restore one by id (reverses cleo skills doctor prune)"
85432
+ description: "List skill quarantines, or restore one by id (reverses cleo skills doctor prune). A restored skill is kept: prune never takes it again. --unkeep <name> hands it back to CLEO only when its files still hash exactly to the copy that was restored; a changed copy stays kept."
84946
85433
  },
84947
85434
  args: {
84948
85435
  id: { type: "positional", required: false, description: "Quarantine id (omit to list)" },
85436
+ unkeep: {
85437
+ type: "string",
85438
+ description: "Kept skill name to hand back to CLEO (only if unchanged since it was restored)"
85439
+ },
84949
85440
  json: { type: "boolean", description: "Output as JSON (default)" },
84950
85441
  human: { type: "boolean", description: "Output in human-readable format" }
84951
85442
  },
84952
85443
  async run({ args }) {
84953
85444
  try {
85445
+ if (typeof args.unkeep === "string" && args.unkeep !== "") {
85446
+ const outcome = await unkeepBundledSkill(args.unkeep);
85447
+ if (!outcome.unkept) {
85448
+ cliError(outcome.reason, 6 /* VALIDATION_ERROR */, {
85449
+ name: "E_VALIDATION",
85450
+ details: outcome
85451
+ });
85452
+ process.exit(6 /* VALIDATION_ERROR */);
85453
+ }
85454
+ cliOutput(outcome, { command: "skills doctor restore", operation: "skills.doctor.unkeep" });
85455
+ return;
85456
+ }
84954
85457
  const id = typeof args.id === "string" && args.id !== "" ? args.id : void 0;
84955
85458
  const result = await restoreBundledSkillQuarantine(id);
84956
85459
  cliOutput(result, { command: "skills doctor restore", operation: "skills.doctor.restore" });
@@ -86373,13 +86876,13 @@ var init_telemetry2 = __esm({
86373
86876
  // packages/cleo/src/cli/commands/templates/lib.ts
86374
86877
  import { readFileSync as readFileSync13 } from "node:fs";
86375
86878
  import { isAbsolute as isAbsolute3, resolve as resolve10 } from "node:path";
86376
- import { getProjectRoot as getProjectRoot68 } from "@cleocode/core";
86879
+ import { getProjectRoot as getProjectRoot69 } from "@cleocode/core";
86377
86880
  import { resolveSourcePathAbsolute } from "@cleocode/core/templates/registry";
86378
86881
  function resolveProjectRoot6(raw) {
86379
86882
  if (typeof raw === "string" && raw.length > 0) {
86380
86883
  return isAbsolute3(raw) ? raw : resolve10(process.cwd(), raw);
86381
86884
  }
86382
- return getProjectRoot68();
86885
+ return getProjectRoot69();
86383
86886
  }
86384
86887
  function readTemplateSource(entry) {
86385
86888
  const sourceAbsolute = resolveSourcePathAbsolute(entry);
@@ -87163,7 +87666,7 @@ __export(token_exports, {
87163
87666
  tokenCommand: () => tokenCommand
87164
87667
  });
87165
87668
  import { readFileSync as readFileSync17 } from "node:fs";
87166
- import { getProjectRoot as getProjectRoot69, measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
87669
+ import { getProjectRoot as getProjectRoot70, measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
87167
87670
  function readPayload(args, textKey, fileKey) {
87168
87671
  const text = args[textKey];
87169
87672
  const file = args[fileKey];
@@ -87327,7 +87830,7 @@ var init_token = __esm({
87327
87830
  domain: args.domain,
87328
87831
  operation: args.operation
87329
87832
  };
87330
- const result = args.record ? await recordTokenExchange2(getProjectRoot69(), input2) : await measureTokenExchange(input2);
87833
+ const result = args.record ? await recordTokenExchange2(getProjectRoot70(), input2) : await measureTokenExchange(input2);
87331
87834
  cliOutput(result, {
87332
87835
  command: "token",
87333
87836
  operation: args.record ? "admin.token.record" : "token.estimate"
@@ -87363,7 +87866,7 @@ __export(transcript_exports, {
87363
87866
  });
87364
87867
  import { homedir as homedir3 } from "node:os";
87365
87868
  import { join as join35 } from "node:path";
87366
- import { getProjectRoot as getProjectRoot70 } from "@cleocode/core";
87869
+ import { getProjectRoot as getProjectRoot71 } from "@cleocode/core";
87367
87870
  import {
87368
87871
  parseDurationMs,
87369
87872
  pruneTranscripts,
@@ -87393,7 +87896,7 @@ var init_transcript = __esm({
87393
87896
  async run({ args }) {
87394
87897
  if (args.pending) {
87395
87898
  try {
87396
- const projectRoot = getProjectRoot70();
87899
+ const projectRoot = getProjectRoot71();
87397
87900
  const { scanPendingTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
87398
87901
  const pending = await scanPendingTranscripts(projectRoot);
87399
87902
  cliOutput(
@@ -87490,7 +87993,7 @@ var init_transcript = __esm({
87490
87993
  async run({ args }) {
87491
87994
  const tier = args.tier ?? "warm";
87492
87995
  const dryRun = args["dry-run"] ?? false;
87493
- const projectRoot = getProjectRoot70();
87996
+ const projectRoot = getProjectRoot71();
87494
87997
  try {
87495
87998
  const { extractTranscript } = await import("@cleocode/core/memory/transcript-extractor.js");
87496
87999
  const { findSessionTranscriptPath, listAllTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
@@ -87606,7 +88109,7 @@ var init_transcript = __esm({
87606
88109
  const dryRun = args["dry-run"] ?? false;
87607
88110
  const olderThanHours = args["older-than-hours"] ? Number.parseInt(args["older-than-hours"], 10) : 24;
87608
88111
  const limit = args.limit ? Number.parseInt(args.limit, 10) : void 0;
87609
- const projectRoot = getProjectRoot70();
88112
+ const projectRoot = getProjectRoot71();
87610
88113
  try {
87611
88114
  const { extractTranscript } = await import("@cleocode/core/memory/transcript-extractor.js");
87612
88115
  const { listAllTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
@@ -88985,7 +89488,7 @@ var init_update = __esm({
88985
89488
  */
88986
89489
  reason: {
88987
89490
  type: "string",
88988
- description: "Operator override reason for AC-immutability guard (required to mutate --acceptance once stage >= implementation; T1590)"
89491
+ description: "Why this change is made. Recorded on the audit row of any priority/severity/kind/depends change (D11161; see `cleo history ranking <id>`), and required to mutate --acceptance once stage >= implementation (T1590)"
88989
89492
  },
88990
89493
  /**
88991
89494
  * Waiver for the critical-priority dependency declaration requirement.
@@ -89540,9 +90043,9 @@ var init_verify = __esm({
89540
90043
  return;
89541
90044
  }
89542
90045
  const { recordTaskDone } = await import("@cleocode/core/tasks/done-record.js");
89543
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core/paths.js");
90046
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core/paths.js");
89544
90047
  const r = await recordTaskDone(args.taskId, {
89545
- projectRoot: getProjectRoot72(),
90048
+ projectRoot: getProjectRoot73(),
89546
90049
  ...parsed.options,
89547
90050
  ...args.agent ? { agent: args.agent } : {}
89548
90051
  });
@@ -89965,9 +90468,9 @@ var init_workgraph2 = __esm({
89965
90468
  },
89966
90469
  async run({ args }) {
89967
90470
  const { generatePlanningDoc } = await import("@cleocode/core/workgraph");
89968
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core");
90471
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core");
89969
90472
  const { cliOutput: cliOutput2 } = await Promise.resolve().then(() => (init_renderers(), renderers_exports));
89970
- const projectRoot = getProjectRoot72();
90473
+ const projectRoot = getProjectRoot73();
89971
90474
  const audience = String(args.audience) === "agent" ? "agent" : "maintainer";
89972
90475
  const result = await generatePlanningDoc(projectRoot, {
89973
90476
  sagaId: String(args.sagaId),
@@ -89984,9 +90487,9 @@ var init_workgraph2 = __esm({
89984
90487
  async run() {
89985
90488
  const { validateWorkGraphStructure } = await import("@cleocode/core/workgraph");
89986
90489
  const { taskList: taskList2 } = await import("@cleocode/core/internal");
89987
- const { getProjectRoot: getProjectRoot72 } = await import("@cleocode/core");
90490
+ const { getProjectRoot: getProjectRoot73 } = await import("@cleocode/core");
89988
90491
  const { cliOutput: cliOutput2 } = await Promise.resolve().then(() => (init_renderers(), renderers_exports));
89989
- const projectRoot = getProjectRoot72();
90492
+ const projectRoot = getProjectRoot73();
89990
90493
  const listResult = await taskList2(projectRoot, { limit: 5e3 });
89991
90494
  const tasks = listResult.success ? listResult.data?.tasks ?? [] : [];
89992
90495
  const nodes = tasks.map((t) => ({
@@ -90005,9 +90508,9 @@ var init_workgraph2 = __esm({
90005
90508
  description: "One-shot saga-to-saga workgraph dashboard (tracking checklist)"
90006
90509
  },
90007
90510
  async run() {
90008
- const { sagas: sagas2, getProjectRoot: getProjectRoot72 } = await import("@cleocode/core");
90511
+ const { sagas: sagas2, getProjectRoot: getProjectRoot73 } = await import("@cleocode/core");
90009
90512
  const { cliOutput: cliOutput2 } = await Promise.resolve().then(() => (init_renderers(), renderers_exports));
90010
- const projectRoot = getProjectRoot72();
90513
+ const projectRoot = getProjectRoot73();
90011
90514
  const listResult = await sagas2.sagaList(projectRoot);
90012
90515
  if (!listResult.success) {
90013
90516
  cliOutput2(listResult, { command: "workgraph", operation: "workgraph.status" });
@@ -90073,7 +90576,7 @@ __export(worktree_exports, {
90073
90576
  worktreeCommand: () => worktreeCommand
90074
90577
  });
90075
90578
  import readline4 from "node:readline";
90076
- import { getProjectRoot as getProjectRoot71, listWorktrees as listWorktrees2 } from "@cleocode/core/internal";
90579
+ import { getProjectRoot as getProjectRoot72, listWorktrees as listWorktrees2 } from "@cleocode/core/internal";
90077
90580
  async function promptYesNo2(question) {
90078
90581
  return new Promise((resolve13) => {
90079
90582
  const rl = readline4.createInterface({ input: process.stdin, output: process.stdout });
@@ -90178,7 +90681,7 @@ var init_worktree3 = __esm({
90178
90681
  const staleDays = staleDaysRaw !== void 0 ? Number.parseInt(staleDaysRaw, 10) : void 0;
90179
90682
  const idleDaysRaw = typeof args["idle-days"] === "string" ? args["idle-days"] : void 0;
90180
90683
  const idleDays = idleDaysRaw !== void 0 ? Number.parseInt(idleDaysRaw, 10) : void 0;
90181
- const projectRoot = getProjectRoot71();
90684
+ const projectRoot = getProjectRoot72();
90182
90685
  const listResult = await listWorktrees2({
90183
90686
  projectRoot,
90184
90687
  ...staleDays !== void 0 && !Number.isNaN(staleDays) ? { staleDays } : {}
@@ -90699,7 +91202,7 @@ var COMMAND_MANIFEST = [
90699
91202
  {
90700
91203
  exportName: "decideCommand",
90701
91204
  name: "decide",
90702
- description: "Typed-decision (System One) provider: decide config (API URL + key), decide status (reachability probe), decide ask (one debug question). Unconfigured means heuristics answer.",
91205
+ description: "System One integration (typed decisions): decide config (provider + API key; wizard on a terminal), decide status (reachability probe), decide ask (one debug question), decide sites (the registered decision sites). Unconfigured means heuristics answer.",
90703
91206
  load: async () => (await Promise.resolve().then(() => (init_decide2(), decide_exports))).decideCommand
90704
91207
  },
90705
91208
  {
@@ -90822,6 +91325,12 @@ var COMMAND_MANIFEST = [
90822
91325
  description: "Report task rows whose id is not a valid task identifier \u2014 rows that `cleo list` returns ",
90823
91326
  load: async () => (await Promise.resolve().then(() => (init_doctor_malformed_ids(), doctor_malformed_ids_exports))).doctorMalformedIdsCommand
90824
91327
  },
91328
+ {
91329
+ exportName: "doctorManifestRowsCommand",
91330
+ name: "manifest-rows",
91331
+ description: "List manifest rows whose metadata violates the stored field contract. --repair shows the plan (writes nothing); --repair --apply moves each bad field under _malformed (nothing lost) with a receipt; --rollback <receipt> undoes it.",
91332
+ load: async () => (await Promise.resolve().then(() => (init_doctor_manifest_rows(), doctor_manifest_rows_exports))).doctorManifestRowsCommand
91333
+ },
90825
91334
  {
90826
91335
  exportName: "doctorMemoryGuardCommand",
90827
91336
  name: "memory-guard",
@@ -91377,7 +91886,7 @@ var COMMAND_MANIFEST = [
91377
91886
  {
91378
91887
  exportName: "setupCommand",
91379
91888
  name: "setup",
91380
- description: "Interactive setup wizard \u2014 runs all 8 sections in canonical order (identity \u2192 llm \u2192 sentient \u2192 harness \u2192 brain \u2192 project-conventions \u2192 integrations \u2192 verification). Use --section <name> for a single section, --non-interactive with section-specific flags to configure without prompts, --config-json for fully scripted setup, or --reset to reconfigure already-set sections.",
91889
+ description: "Interactive setup wizard \u2014 runs every section in canonical order (llm \u2192 system-one \u2192 models-roles \u2192 identity \u2192 sentient \u2192 project-conventions \u2192 harness \u2192 brain \u2192 integrations \u2192 telemetry \u2192 verification); system-one is optional. Use --section <name> for a single section, --non-interactive with section-specific flags to configure without prompts, --config-json for fully scripted setup, or --reset to reconfigure already-set sections.",
91381
91890
  load: async () => (await Promise.resolve().then(() => (init_setup(), setup_exports))).setupCommand
91382
91891
  },
91383
91892
  {
@@ -92113,7 +92622,7 @@ async function runStartupMaintenance() {
92113
92622
  detectAndRemoveStrayProjectNexus,
92114
92623
  getGlobalSalt,
92115
92624
  getLogger: getLogger22,
92116
- getProjectRoot: getProjectRoot72,
92625
+ getProjectRoot: getProjectRoot73,
92117
92626
  isCleanupMarkerSet,
92118
92627
  migrateSignaldockToConduit,
92119
92628
  needsSignaldockToConduitMigration,
@@ -92122,7 +92631,7 @@ async function runStartupMaintenance() {
92122
92631
  } = await import("@cleocode/core/internal");
92123
92632
  let projectRootForCleanup = "";
92124
92633
  try {
92125
- projectRootForCleanup = getProjectRoot72();
92634
+ projectRootForCleanup = getProjectRoot73();
92126
92635
  } catch {
92127
92636
  }
92128
92637
  if (!isCleanupMarkerSet(CLI_VERSION, projectRootForCleanup)) {
@@ -92142,7 +92651,7 @@ async function runStartupMaintenance() {
92142
92651
  const isInitInvocation = process.argv.slice(2).some((a) => a === "init");
92143
92652
  if (!isInitInvocation) {
92144
92653
  try {
92145
- const _projectRootForMigration = getProjectRoot72();
92654
+ const _projectRootForMigration = getProjectRoot73();
92146
92655
  if (needsSignaldockToConduitMigration(_projectRootForMigration)) {
92147
92656
  const migrationResult = await migrateSignaldockToConduit(_projectRootForMigration);
92148
92657
  if (migrationResult.status === "failed") {