@cleocode/cleo 2026.5.72 → 2026.5.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -12054,6 +12054,25 @@ var init_registry = __esm({
12054
12054
  }
12055
12055
  ]
12056
12056
  },
12057
+ // llm query: auxiliary-status — show configured auxiliary fallback chain
12058
+ {
12059
+ gateway: "query",
12060
+ domain: "llm",
12061
+ operation: "auxiliary-status",
12062
+ description: "llm.auxiliary-status (query) \u2014 show the active multi-provider auxiliary fallback chain and how to configure it (T9319)",
12063
+ tier: 2,
12064
+ idempotent: true,
12065
+ sessionRequired: false,
12066
+ requiredParams: [],
12067
+ params: [
12068
+ {
12069
+ name: "projectRoot",
12070
+ type: "string",
12071
+ required: false,
12072
+ description: "Optional project root for config resolution"
12073
+ }
12074
+ ]
12075
+ },
12057
12076
  // llm mutate: add — upsert credential into the pool
12058
12077
  {
12059
12078
  gateway: "mutate",
@@ -16691,6 +16710,7 @@ var init_intelligence2 = __esm({
16691
16710
  // packages/cleo/src/dispatch/domains/llm/index.ts
16692
16711
  import {
16693
16712
  llmAdd,
16713
+ llmAuxiliaryStatus,
16694
16714
  llmList,
16695
16715
  llmProfile,
16696
16716
  llmRemove,
@@ -16717,6 +16737,7 @@ var init_llm2 = __esm({
16717
16737
  list: llmList,
16718
16738
  test: llmTest,
16719
16739
  whoami: llmWhoami,
16740
+ "auxiliary-status": llmAuxiliaryStatus,
16720
16741
  add: llmAdd,
16721
16742
  remove: llmRemove,
16722
16743
  use: llmUse,
@@ -16729,6 +16750,7 @@ var init_llm2 = __esm({
16729
16750
  list: async (params) => wrap(coreOps["list"], params, "list"),
16730
16751
  test: async (params) => wrap(coreOps["test"], params, "test"),
16731
16752
  whoami: async (params) => wrap(coreOps["whoami"], params, "whoami"),
16753
+ "auxiliary-status": async (params) => wrap(coreOps["auxiliary-status"], params, "auxiliary-status"),
16732
16754
  // -------------------------------------------------------------------------
16733
16755
  // Mutate ops
16734
16756
  // -------------------------------------------------------------------------
@@ -16737,13 +16759,13 @@ var init_llm2 = __esm({
16737
16759
  use: async (params) => wrap(coreOps["use"], params, "use"),
16738
16760
  profile: async (params) => wrap(coreOps["profile"], params, "profile")
16739
16761
  });
16740
- QUERY_OPS4 = /* @__PURE__ */ new Set(["list", "test", "whoami"]);
16762
+ QUERY_OPS4 = /* @__PURE__ */ new Set(["list", "test", "whoami", "auxiliary-status"]);
16741
16763
  MUTATE_OPS4 = /* @__PURE__ */ new Set(["add", "remove", "use", "profile"]);
16742
16764
  LlmHandler = class {
16743
16765
  /** Declared operations for introspection and validation. */
16744
16766
  getSupportedOperations() {
16745
16767
  return {
16746
- query: ["list", "test", "whoami"],
16768
+ query: ["list", "test", "whoami", "auxiliary-status"],
16747
16769
  mutate: ["add", "remove", "use", "profile"]
16748
16770
  };
16749
16771
  }
@@ -24311,8 +24333,8 @@ async function loadPlaybookByName(name) {
24311
24333
  return null;
24312
24334
  }
24313
24335
  try {
24314
- const { getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
24315
- const projectRoot = __playbookRuntimeOverrides.projectRoot ?? getProjectRoot33();
24336
+ const { getProjectRoot: getProjectRoot34 } = await import("@cleocode/core/internal");
24337
+ const projectRoot = __playbookRuntimeOverrides.projectRoot ?? getProjectRoot34();
24316
24338
  const resolved = resolvePlaybook(name, {
24317
24339
  projectRoot,
24318
24340
  globalPlaybooksDir: __playbookRuntimeOverrides.globalPlaybooksDir,
@@ -24356,8 +24378,8 @@ async function acquireDb() {
24356
24378
  async function buildDefaultDispatcher() {
24357
24379
  if (__playbookRuntimeOverrides.dispatcher) return __playbookRuntimeOverrides.dispatcher;
24358
24380
  const { orchestrateSpawnExecute: orchestrateSpawnExecute2 } = await Promise.resolve().then(() => (init_engine(), engine_exports));
24359
- const { getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
24360
- const projectRoot = getProjectRoot33();
24381
+ const { getProjectRoot: getProjectRoot34 } = await import("@cleocode/core/internal");
24382
+ const projectRoot = getProjectRoot34();
24361
24383
  return {
24362
24384
  async dispatch(input) {
24363
24385
  try {
@@ -24547,8 +24569,8 @@ var init_playbook2 = __esm({
24547
24569
  projectRoot = __playbookRuntimeOverrides.projectRoot;
24548
24570
  } else {
24549
24571
  try {
24550
- const { getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
24551
- projectRoot = getProjectRoot33();
24572
+ const { getProjectRoot: getProjectRoot34 } = await import("@cleocode/core/internal");
24573
+ projectRoot = getProjectRoot34();
24552
24574
  } catch {
24553
24575
  projectRoot = void 0;
24554
24576
  }
@@ -24612,14 +24634,14 @@ var init_playbook2 = __esm({
24612
24634
  const dispatcher = await buildDefaultDispatcher();
24613
24635
  let result;
24614
24636
  try {
24615
- const { getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
24637
+ const { getProjectRoot: getProjectRoot34 } = await import("@cleocode/core/internal");
24616
24638
  const opts = {
24617
24639
  db,
24618
24640
  playbook: parsed.definition,
24619
24641
  playbookHash: parsed.sourceHash,
24620
24642
  initialContext,
24621
24643
  dispatcher,
24622
- projectRoot: getProjectRoot33()
24644
+ projectRoot: getProjectRoot34()
24623
24645
  };
24624
24646
  if (__playbookRuntimeOverrides.approvalSecret !== void 0) {
24625
24647
  opts.approvalSecret = __playbookRuntimeOverrides.approvalSecret;
@@ -29530,11 +29552,11 @@ var init_security = __esm({
29530
29552
  });
29531
29553
 
29532
29554
  // packages/cleo/src/dispatch/middleware/sanitizer.ts
29533
- function createSanitizer(getProjectRoot33) {
29555
+ function createSanitizer(getProjectRoot34) {
29534
29556
  return async (req, next) => {
29535
29557
  if (req.params) {
29536
29558
  try {
29537
- const root = getProjectRoot33 ? getProjectRoot33() : void 0;
29559
+ const root = getProjectRoot34 ? getProjectRoot34() : void 0;
29538
29560
  req.params = sanitizeParams(req.params, root, {
29539
29561
  domain: req.domain,
29540
29562
  operation: req.operation
@@ -34129,6 +34151,144 @@ var init_audit2 = __esm({
34129
34151
  }
34130
34152
  });
34131
34153
 
34154
+ // packages/cleo/src/cli/commands/backfill.ts
34155
+ var backfill_exports = {};
34156
+ __export(backfill_exports, {
34157
+ backfillCommand: () => backfillCommand
34158
+ });
34159
+ import { backfillTasks, getProjectRoot as getProjectRoot20, populateEmbeddings } from "@cleocode/core/internal";
34160
+ var backfillCommand;
34161
+ var init_backfill = __esm({
34162
+ "packages/cleo/src/cli/commands/backfill.ts"() {
34163
+ "use strict";
34164
+ init_dist();
34165
+ init_renderers();
34166
+ backfillCommand = defineCommand({
34167
+ meta: {
34168
+ name: "backfill",
34169
+ description: "Retroactively add acceptance criteria and verification metadata to existing tasks"
34170
+ },
34171
+ args: {
34172
+ "dry-run": {
34173
+ type: "boolean",
34174
+ description: "Show what would be changed without modifying any tasks",
34175
+ default: false
34176
+ },
34177
+ rollback: {
34178
+ type: "boolean",
34179
+ description: "Revert a previous backfill (clear auto-generated AC and verification)",
34180
+ default: false
34181
+ },
34182
+ tasks: {
34183
+ type: "string",
34184
+ description: "Comma-separated list of task IDs to restrict backfill to (e.g. T001,T002)"
34185
+ },
34186
+ embeddings: {
34187
+ type: "boolean",
34188
+ description: "Retroactively generate embeddings for brain observations that lack them",
34189
+ default: false
34190
+ }
34191
+ },
34192
+ async run({ args }) {
34193
+ const root = getProjectRoot20();
34194
+ if (args.embeddings) {
34195
+ try {
34196
+ let lastLine = "";
34197
+ const result = await populateEmbeddings(root, {
34198
+ onProgress: (current, total) => {
34199
+ if (process.stdout.isTTY) {
34200
+ humanProgress(`\rEmbedding ${current}/${total}...`);
34201
+ } else {
34202
+ const line = `Embedding ${current}/${total}...`;
34203
+ if (line !== lastLine) {
34204
+ humanLine(line);
34205
+ lastLine = line;
34206
+ }
34207
+ }
34208
+ }
34209
+ });
34210
+ if (process.stdout.isTTY && result.processed + result.skipped + result.errors > 0) {
34211
+ humanProgress("\n");
34212
+ }
34213
+ if (result.processed === 0 && result.skipped === 0 && result.errors === 0) {
34214
+ cliOutput(
34215
+ {
34216
+ processed: 0,
34217
+ skipped: 0,
34218
+ errors: 0,
34219
+ message: "No observations to embed (provider unavailable or nothing to backfill)."
34220
+ },
34221
+ { command: "backfill", operation: "admin.backfill", message: "Nothing to embed" }
34222
+ );
34223
+ return;
34224
+ }
34225
+ cliOutput(
34226
+ { processed: result.processed, skipped: result.skipped, errors: result.errors },
34227
+ {
34228
+ command: "backfill",
34229
+ operation: "admin.backfill",
34230
+ message: `Processed ${result.processed}, skipped ${result.skipped}, errors ${result.errors}`
34231
+ }
34232
+ );
34233
+ } catch (err) {
34234
+ const message = err instanceof Error ? err.message : String(err);
34235
+ cliError(
34236
+ `Embedding backfill failed: ${message}`,
34237
+ "E_INTERNAL",
34238
+ {
34239
+ name: "E_INTERNAL"
34240
+ },
34241
+ { operation: "admin.backfill" }
34242
+ );
34243
+ process.exit(1);
34244
+ }
34245
+ return;
34246
+ }
34247
+ const dryRun = !!args["dry-run"];
34248
+ const rollback = !!args.rollback;
34249
+ const taskIds = args.tasks?.trim() ? args.tasks.split(",").map((s) => s.trim()).filter(Boolean) : void 0;
34250
+ if (!dryRun && !rollback && !process.env["CLEO_NONINTERACTIVE"]) {
34251
+ humanWarn(
34252
+ "Warning: Backfill will modify tasks in-place. Run with --dry-run first to preview changes.\n Set CLEO_NONINTERACTIVE=1 or pass --dry-run to suppress this warning.\n"
34253
+ );
34254
+ }
34255
+ try {
34256
+ const result = await backfillTasks(root, { dryRun, rollback, taskIds });
34257
+ const output = {
34258
+ dryRun,
34259
+ rollback,
34260
+ tasksScanned: result.tasksScanned,
34261
+ tasksChanged: result.tasksChanged,
34262
+ changes: result.changes
34263
+ };
34264
+ if (!rollback) {
34265
+ output["acAdded"] = result.acAdded;
34266
+ output["verificationAdded"] = result.verificationAdded;
34267
+ }
34268
+ const messagePrefix = dryRun ? "[dry run] " : rollback ? "[rollback] " : "";
34269
+ const messageSuffix = result.changes.length === 0 ? "Nothing to do \u2014 all tasks already have AC and verification metadata." : `Scanned ${result.tasksScanned}, changed ${result.tasksChanged} task(s).`;
34270
+ cliOutput(output, {
34271
+ command: "backfill",
34272
+ operation: "admin.backfill",
34273
+ message: `${messagePrefix}${messageSuffix}`
34274
+ });
34275
+ } catch (err) {
34276
+ const message = err instanceof Error ? err.message : String(err);
34277
+ cliError(
34278
+ `Backfill failed: ${message}`,
34279
+ "E_INTERNAL",
34280
+ {
34281
+ name: "E_INTERNAL"
34282
+ },
34283
+ { operation: "admin.backfill" }
34284
+ );
34285
+ process.exit(1);
34286
+ }
34287
+ }
34288
+ });
34289
+ }
34290
+ });
34291
+
34132
34292
  // packages/cleo/src/cli/commands/backup-inspect.ts
34133
34293
  var backup_inspect_exports = {};
34134
34294
  __export(backup_inspect_exports, {
@@ -34547,9 +34707,9 @@ var init_backup = __esm({
34547
34707
  },
34548
34708
  async run({ args }) {
34549
34709
  const scope = args.scope;
34550
- const { packBundle, getProjectRoot: getProjectRoot33 } = await import("@cleocode/core/internal");
34710
+ const { packBundle, getProjectRoot: getProjectRoot34 } = await import("@cleocode/core/internal");
34551
34711
  const includesProject = scope === "project" || scope === "all";
34552
- const projectRoot = includesProject ? getProjectRoot33() : void 0;
34712
+ const projectRoot = includesProject ? getProjectRoot34() : void 0;
34553
34713
  let passphrase;
34554
34714
  if (args.encrypt === true) {
34555
34715
  passphrase = process.env["CLEO_BACKUP_PASSPHRASE"];
@@ -34850,7 +35010,7 @@ import {
34850
35010
  exportBrainAsJson,
34851
35011
  getMemoryQualityReport,
34852
35012
  getPlasticityStats,
34853
- getProjectRoot as getProjectRoot20,
35013
+ getProjectRoot as getProjectRoot21,
34854
35014
  purgeBrainNoise,
34855
35015
  runBrainMaintenance
34856
35016
  } from "@cleocode/core/internal";
@@ -34889,7 +35049,7 @@ var init_brain2 = __esm({
34889
35049
  json: { type: "boolean", description: "Output results as JSON" }
34890
35050
  },
34891
35051
  async run({ args }) {
34892
- const root = getProjectRoot20();
35052
+ const root = getProjectRoot21();
34893
35053
  try {
34894
35054
  const result = await runBrainMaintenance(root, {
34895
35055
  skipDecay: !!args["skip-decay"],
@@ -34960,7 +35120,7 @@ var init_brain2 = __esm({
34960
35120
  json: { type: "boolean", description: "Output results as JSON" }
34961
35121
  },
34962
35122
  async run({ args: _args }) {
34963
- const root = getProjectRoot20();
35123
+ const root = getProjectRoot21();
34964
35124
  try {
34965
35125
  const result = await backfillBrainGraph(root);
34966
35126
  cliOutput(
@@ -35001,7 +35161,7 @@ var init_brain2 = __esm({
35001
35161
  json: { type: "boolean", description: "Output results as JSON" }
35002
35162
  },
35003
35163
  async run({ args: _args }) {
35004
- const root = getProjectRoot20();
35164
+ const root = getProjectRoot21();
35005
35165
  try {
35006
35166
  const result = await purgeBrainNoise(root);
35007
35167
  cliOutput(
@@ -35047,7 +35207,7 @@ var init_brain2 = __esm({
35047
35207
  json: { type: "boolean", description: "Output results as JSON" }
35048
35208
  },
35049
35209
  async run({ args }) {
35050
- const root = getProjectRoot20();
35210
+ const root = getProjectRoot21();
35051
35211
  const limit = Number.parseInt(args.limit, 10) || 20;
35052
35212
  try {
35053
35213
  const stats = await getPlasticityStats(root, limit);
@@ -35097,7 +35257,7 @@ var init_brain2 = __esm({
35097
35257
  json: { type: "boolean", description: "Output results as JSON" }
35098
35258
  },
35099
35259
  async run({ args: _args }) {
35100
- const root = getProjectRoot20();
35260
+ const root = getProjectRoot21();
35101
35261
  try {
35102
35262
  const report = await getMemoryQualityReport(root);
35103
35263
  cliOutput(
@@ -35146,7 +35306,7 @@ var init_brain2 = __esm({
35146
35306
  }
35147
35307
  },
35148
35308
  async run({ args }) {
35149
- const root = getProjectRoot20();
35309
+ const root = getProjectRoot21();
35150
35310
  const format = args.format ?? "gexf";
35151
35311
  if (format !== "gexf" && format !== "json") {
35152
35312
  cliError(`Invalid format: ${format}. Use 'gexf' or 'json'.`, "E_VALIDATION", {
@@ -39023,7 +39183,7 @@ import {
39023
39183
  exportDocument,
39024
39184
  formatError as formatError5,
39025
39185
  getAgentOutputsAbsolute,
39026
- getProjectRoot as getProjectRoot21,
39186
+ getProjectRoot as getProjectRoot22,
39027
39187
  listDocVersions,
39028
39188
  mergeDocs,
39029
39189
  publishDocs,
@@ -39319,7 +39479,7 @@ var init_docs3 = __esm({
39319
39479
  const taskId = String(args.task);
39320
39480
  const includeAttachments = args["include-attachments"] !== false;
39321
39481
  const includeMemoryRefs = args["include-memory-refs"] === true;
39322
- const projectRoot = getProjectRoot21();
39482
+ const projectRoot = getProjectRoot22();
39323
39483
  try {
39324
39484
  const result = await exportDocument({
39325
39485
  taskId,
@@ -39382,7 +39542,7 @@ var init_docs3 = __esm({
39382
39542
  }
39383
39543
  },
39384
39544
  async run({ args }) {
39385
- const projectRoot = getProjectRoot21();
39545
+ const projectRoot = getProjectRoot22();
39386
39546
  try {
39387
39547
  const result = await searchDocs2(String(args.query), {
39388
39548
  ownerId: args.owner ?? void 0,
@@ -39434,7 +39594,7 @@ var init_docs3 = __esm({
39434
39594
  }
39435
39595
  },
39436
39596
  async run({ args }) {
39437
- const projectRoot = getProjectRoot21();
39597
+ const projectRoot = getProjectRoot22();
39438
39598
  const rawStrategy = args.strategy ?? "three-way";
39439
39599
  const strategy = rawStrategy === "cherry-pick" || rawStrategy === "multi-diff" ? rawStrategy : "three-way";
39440
39600
  try {
@@ -39484,7 +39644,7 @@ var init_docs3 = __esm({
39484
39644
  }
39485
39645
  },
39486
39646
  async run({ args }) {
39487
- const projectRoot = getProjectRoot21();
39647
+ const projectRoot = getProjectRoot22();
39488
39648
  const fmt = args.format ?? "mermaid";
39489
39649
  try {
39490
39650
  const result = await buildDocsGraph({ ownerId: String(args.for), projectRoot });
@@ -39554,7 +39714,7 @@ var init_docs3 = __esm({
39554
39714
  }
39555
39715
  },
39556
39716
  async run({ args }) {
39557
- const projectRoot = getProjectRoot21();
39717
+ const projectRoot = getProjectRoot22();
39558
39718
  try {
39559
39719
  const result = await rankDocs({
39560
39720
  ownerId: String(args.for),
@@ -39593,7 +39753,7 @@ var init_docs3 = __esm({
39593
39753
  }
39594
39754
  },
39595
39755
  async run({ args }) {
39596
- const projectRoot = getProjectRoot21();
39756
+ const projectRoot = getProjectRoot22();
39597
39757
  try {
39598
39758
  const result = await listDocVersions({
39599
39759
  ownerId: String(args.for),
@@ -39637,7 +39797,7 @@ var init_docs3 = __esm({
39637
39797
  }
39638
39798
  },
39639
39799
  async run({ args }) {
39640
- const projectRoot = getProjectRoot21();
39800
+ const projectRoot = getProjectRoot22();
39641
39801
  try {
39642
39802
  const result = await publishDocs({
39643
39803
  ownerId: String(args.for),
@@ -40042,7 +40202,7 @@ __export(migrate_agents_v2_exports, {
40042
40202
  import { createHash as createHash2 } from "node:crypto";
40043
40203
  import { appendFileSync as appendFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync3, readdirSync as readdirSync2, readFileSync as readFileSync11 } from "node:fs";
40044
40204
  import { join as join13 } from "node:path";
40045
- import { getProjectRoot as getProjectRoot22, installAgentFromCant } from "@cleocode/core/internal";
40205
+ import { getProjectRoot as getProjectRoot23, installAgentFromCant } from "@cleocode/core/internal";
40046
40206
  import { openCleoDb } from "@cleocode/core/store/open-cleo-db";
40047
40207
  function sha256Hex(bytes) {
40048
40208
  return createHash2("sha256").update(bytes).digest("hex");
@@ -40229,7 +40389,7 @@ var init_migrate_agents_v2 = __esm({
40229
40389
  }
40230
40390
  },
40231
40391
  async run({ args }) {
40232
- const projectRoot = getProjectRoot22();
40392
+ const projectRoot = getProjectRoot23();
40233
40393
  const verbose = args.quiet !== true;
40234
40394
  if (verbose) {
40235
40395
  humanInfo("Scanning .cleo/cant/agents/ and .cleo/agents/ for unregistered agents...");
@@ -40273,7 +40433,7 @@ __export(doctor_exports, {
40273
40433
  });
40274
40434
  import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "node:fs";
40275
40435
  import { join as join14 } from "node:path";
40276
- import { getProjectRoot as getProjectRoot23, quarantineRogueCleoDir, scanRogueCleoDirs } from "@cleocode/core/internal";
40436
+ import { getProjectRoot as getProjectRoot24, quarantineRogueCleoDir, scanRogueCleoDirs } from "@cleocode/core/internal";
40277
40437
  async function scanTestFixturesInProd(projectRoot) {
40278
40438
  const { getDb: getDb3, getNativeDb } = await import("@cleocode/core/internal");
40279
40439
  await getDb3(projectRoot);
@@ -40495,7 +40655,7 @@ var init_doctor = __esm({
40495
40655
  try {
40496
40656
  if (args.brain) {
40497
40657
  const { computeBrainHealthDashboard } = await import("@cleocode/core/internal");
40498
- const projectRoot = getProjectRoot23();
40658
+ const projectRoot = getProjectRoot24();
40499
40659
  const dashboard = await computeBrainHealthDashboard(projectRoot);
40500
40660
  cliOutput(dashboard, { command: "doctor", operation: "doctor.brain" });
40501
40661
  if (dashboard.hasP0Failure) {
@@ -40504,7 +40664,7 @@ var init_doctor = __esm({
40504
40664
  return;
40505
40665
  }
40506
40666
  if (args["scan-test-fixtures-in-prod"]) {
40507
- const projectRoot = getProjectRoot23();
40667
+ const projectRoot = getProjectRoot24();
40508
40668
  const matches = await scanTestFixturesInProd(projectRoot);
40509
40669
  const dryRun = args["dry-run"] !== false && args.quarantine !== true;
40510
40670
  const quarantined = !dryRun && matches.length > 0 ? await quarantineTestFixtures(projectRoot, matches) : void 0;
@@ -40592,7 +40752,7 @@ var init_doctor = __esm({
40592
40752
  progress.complete("Comprehensive diagnostics complete");
40593
40753
  } else if (args["scan-rogue-cleo-dirs"]) {
40594
40754
  progress.step(0, "Scanning for rogue .cleo/ directories");
40595
- const projectRoot = getProjectRoot23();
40755
+ const projectRoot = getProjectRoot24();
40596
40756
  const reports = scanRogueCleoDirs(projectRoot);
40597
40757
  progress.complete(
40598
40758
  `Found ${reports.length} rogue .cleo/ director${reports.length === 1 ? "y" : "ies"}`
@@ -40601,7 +40761,7 @@ var init_doctor = __esm({
40601
40761
  } else if (args["quarantine-rogue-cleo-dirs"]) {
40602
40762
  const isDryRun = args["dry-run"] === true;
40603
40763
  progress.step(0, `${isDryRun ? "[DRY RUN] " : ""}Scanning for rogue .cleo/ directories`);
40604
- const projectRoot = getProjectRoot23();
40764
+ const projectRoot = getProjectRoot24();
40605
40765
  const reports = scanRogueCleoDirs(projectRoot);
40606
40766
  if (reports.length === 0) {
40607
40767
  progress.complete("No rogue .cleo/ directories found \u2014 nothing to quarantine");
@@ -40655,7 +40815,7 @@ var init_doctor = __esm({
40655
40815
  const { detectAndRemoveLegacyGlobalFiles, detectAndRemoveStrayProjectNexus } = await import("@cleocode/core/internal");
40656
40816
  const { getCleoHome: getCleoHome3 } = await import("@cleocode/core/internal");
40657
40817
  const cleoHome = getCleoHome3();
40658
- const projectRoot = getProjectRoot23();
40818
+ const projectRoot = getProjectRoot24();
40659
40819
  const legacyResult = detectAndRemoveLegacyGlobalFiles(cleoHome);
40660
40820
  const strayResult = detectAndRemoveStrayProjectNexus(projectRoot);
40661
40821
  const isDryRun = args["dry-run"] === true;
@@ -40704,7 +40864,7 @@ var init_doctor = __esm({
40704
40864
  { command: "doctor", operation: "admin.health" }
40705
40865
  );
40706
40866
  try {
40707
- const projectRoot = getProjectRoot23();
40867
+ const projectRoot = getProjectRoot24();
40708
40868
  const conflicts = readMigrationConflicts(projectRoot);
40709
40869
  if (conflicts.length > 0) {
40710
40870
  progress.complete(
@@ -41649,7 +41809,7 @@ __export(generate_changelog_exports, {
41649
41809
  import { execFileSync as execFileSync2 } from "node:child_process";
41650
41810
  import { existsSync as existsSync11, mkdirSync as mkdirSync5, readFileSync as readFileSync12, writeFileSync as writeFileSync4 } from "node:fs";
41651
41811
  import { dirname as dirname7, join as join17 } from "node:path";
41652
- import { CleoError as CleoError4, formatError as formatError6, getConfigPath, getProjectRoot as getProjectRoot24 } from "@cleocode/core";
41812
+ import { CleoError as CleoError4, formatError as formatError6, getConfigPath, getProjectRoot as getProjectRoot25 } from "@cleocode/core";
41653
41813
  function getChangelogSource(cwd) {
41654
41814
  const configPath = getConfigPath(cwd);
41655
41815
  try {
@@ -41680,7 +41840,7 @@ function getDefaultOutputPath(platform) {
41680
41840
  }
41681
41841
  }
41682
41842
  function getGitHubRepoSlug(cwd) {
41683
- const projectRoot = getProjectRoot24(cwd);
41843
+ const projectRoot = getProjectRoot25(cwd);
41684
41844
  try {
41685
41845
  const remoteUrl = execFileSync2("git", ["remote", "get-url", "origin"], {
41686
41846
  cwd: projectRoot,
@@ -41813,7 +41973,7 @@ var init_generate_changelog = __esm({
41813
41973
  const targetPlatform = args.platform;
41814
41974
  const dryRun = args["dry-run"] === true;
41815
41975
  const sourceFile = getChangelogSource();
41816
- const sourcePath = join17(getProjectRoot24(), sourceFile);
41976
+ const sourcePath = join17(getProjectRoot25(), sourceFile);
41817
41977
  if (!existsSync11(sourcePath)) {
41818
41978
  throw new CleoError4(4 /* NOT_FOUND */, `Changelog source not found: ${sourcePath}`);
41819
41979
  }
@@ -41826,7 +41986,7 @@ var init_generate_changelog = __esm({
41826
41986
  const outputPath = platformConfig?.path ?? getDefaultOutputPath(targetPlatform);
41827
41987
  const content = generateForPlatform(targetPlatform, sourceContent, repoSlug, limit);
41828
41988
  if (!dryRun) {
41829
- const fullPath = join17(getProjectRoot24(), outputPath);
41989
+ const fullPath = join17(getProjectRoot25(), outputPath);
41830
41990
  mkdirSync5(dirname7(fullPath), { recursive: true });
41831
41991
  writeFileSync4(fullPath, content, "utf-8");
41832
41992
  }
@@ -41847,7 +42007,7 @@ var init_generate_changelog = __esm({
41847
42007
  limit
41848
42008
  );
41849
42009
  if (!dryRun) {
41850
- const fullPath = join17(getProjectRoot24(), platformConfig.path);
42010
+ const fullPath = join17(getProjectRoot25(), platformConfig.path);
41851
42011
  mkdirSync5(dirname7(fullPath), { recursive: true });
41852
42012
  writeFileSync4(fullPath, content, "utf-8");
41853
42013
  }
@@ -43884,7 +44044,7 @@ var llm_cost_exports = {};
43884
44044
  __export(llm_cost_exports, {
43885
44045
  costCommand: () => costCommand
43886
44046
  });
43887
- import { getProjectRoot as getProjectRoot25 } from "@cleocode/core/internal";
44047
+ import { getProjectRoot as getProjectRoot26 } from "@cleocode/core/internal";
43888
44048
  import { computeCost } from "@cleocode/core/llm/usage-pricing";
43889
44049
  function resolveSessionId(raw) {
43890
44050
  if (raw === "current") {
@@ -43957,7 +44117,7 @@ var init_llm_cost = __esm({
43957
44117
  process.exit(6);
43958
44118
  }
43959
44119
  const sessionId = resolveSessionId(rawSessionId);
43960
- const projectRoot = getProjectRoot25(process.cwd());
44120
+ const projectRoot = getProjectRoot26(process.cwd());
43961
44121
  let breakdown;
43962
44122
  try {
43963
44123
  breakdown = await loadSessionCostBreakdown(projectRoot, sessionId);
@@ -43988,6 +44148,199 @@ var init_llm_cost = __esm({
43988
44148
  }
43989
44149
  });
43990
44150
 
44151
+ // packages/cleo/src/cli/commands/llm-stream.ts
44152
+ var llm_stream_exports = {};
44153
+ __export(llm_stream_exports, {
44154
+ runLlmStream: () => runLlmStream,
44155
+ streamCommand: () => streamCommand
44156
+ });
44157
+ async function buildSession(provider, model) {
44158
+ const [
44159
+ { resolveCredentials: resolveCredentials2 },
44160
+ { ConcreteSession },
44161
+ { AnthropicTransport },
44162
+ { ChatCompletionsTransport },
44163
+ { GeminiTransport }
44164
+ ] = await Promise.all([
44165
+ import(
44166
+ /* webpackIgnore: true */
44167
+ "@cleocode/core/llm/credentials.js"
44168
+ ),
44169
+ import(
44170
+ /* webpackIgnore: true */
44171
+ "@cleocode/core/llm/concrete-session.js"
44172
+ ),
44173
+ import(
44174
+ /* webpackIgnore: true */
44175
+ "@cleocode/core/llm/transports/anthropic.js"
44176
+ ),
44177
+ import(
44178
+ /* webpackIgnore: true */
44179
+ "@cleocode/core/llm/transports/chat-completions.js"
44180
+ ),
44181
+ import(
44182
+ /* webpackIgnore: true */
44183
+ "@cleocode/core/llm/transports/gemini.js"
44184
+ )
44185
+ ]);
44186
+ const cred = resolveCredentials2(provider);
44187
+ if (!cred.apiKey) {
44188
+ throw new Error(
44189
+ `No credential found for provider '${provider}'. Set the appropriate environment variable or run 'cleo llm add ${provider}'.`
44190
+ );
44191
+ }
44192
+ let transport;
44193
+ if (provider === "anthropic") {
44194
+ transport = cred.authType === "oauth" ? new AnthropicTransport({ authToken: cred.apiKey }) : new AnthropicTransport({ apiKey: cred.apiKey });
44195
+ } else if (provider === "gemini") {
44196
+ transport = new GeminiTransport({ apiKey: cred.apiKey });
44197
+ } else {
44198
+ transport = new ChatCompletionsTransport({ provider, apiKey: cred.apiKey });
44199
+ }
44200
+ const resolvedCredential = {
44201
+ provider,
44202
+ label: "default",
44203
+ token: cred.apiKey,
44204
+ authType: cred.authType,
44205
+ expiresAt: null,
44206
+ refreshToken: null,
44207
+ extraHeaders: {},
44208
+ baseUrl: null,
44209
+ awsProfile: null
44210
+ };
44211
+ return new ConcreteSession({ transport, model, credential: resolvedCredential });
44212
+ }
44213
+ async function getComputeCost() {
44214
+ const { computeCost: computeCost2 } = await import(
44215
+ /* webpackIgnore: true */
44216
+ "@cleocode/core/llm/usage-pricing"
44217
+ );
44218
+ return computeCost2;
44219
+ }
44220
+ async function resolveDefaultModel(provider) {
44221
+ const [{ getProviderProfile: getProviderProfile2 }, { IMPLICIT_FALLBACK_MODEL }] = await Promise.all([
44222
+ import(
44223
+ /* webpackIgnore: true */
44224
+ "@cleocode/core/llm/provider-registry/index.js"
44225
+ ),
44226
+ import(
44227
+ /* webpackIgnore: true */
44228
+ "@cleocode/core/llm/role-resolver.js"
44229
+ )
44230
+ ]);
44231
+ const profile = await getProviderProfile2(provider);
44232
+ return profile?.defaultModel ?? IMPLICIT_FALLBACK_MODEL;
44233
+ }
44234
+ async function runLlmStream(opts) {
44235
+ const stdout = opts.stdout ?? process.stdout;
44236
+ const stderr2 = opts.stderr ?? process.stderr;
44237
+ const session = opts._sessionOverride ?? await buildSession(opts.provider, opts.model ?? await resolveDefaultModel(opts.provider));
44238
+ const sendOpts = {
44239
+ ...opts.system != null ? { systemSuffix: opts.system } : {}
44240
+ };
44241
+ const messages = [{ role: "user", content: opts.prompt }];
44242
+ let finalUsage = { inputTokens: 0, outputTokens: 0, costUsd: null };
44243
+ const stream = session.stream(messages, sendOpts);
44244
+ for await (const delta of stream) {
44245
+ if (delta.text) {
44246
+ stdout.write(delta.text);
44247
+ }
44248
+ if (delta.reasoning && opts.showThink) {
44249
+ stderr2.write(delta.reasoning);
44250
+ }
44251
+ if (delta.usage !== null) {
44252
+ const { inputTokens, outputTokens } = delta.usage;
44253
+ let costUsd = null;
44254
+ try {
44255
+ const computeCost2 = await getComputeCost();
44256
+ const raw = computeCost2({ inputTokens, outputTokens }, session.model);
44257
+ costUsd = raw === 0 ? null : raw;
44258
+ } catch {
44259
+ }
44260
+ finalUsage = { inputTokens, outputTokens, costUsd };
44261
+ }
44262
+ }
44263
+ stderr2.write(`${JSON.stringify(finalUsage)}
44264
+ `);
44265
+ return finalUsage;
44266
+ }
44267
+ var streamCommand;
44268
+ var init_llm_stream = __esm({
44269
+ "packages/cleo/src/cli/commands/llm-stream.ts"() {
44270
+ "use strict";
44271
+ init_dist();
44272
+ streamCommand = defineCommand({
44273
+ meta: {
44274
+ name: "stream",
44275
+ description: "Stream a single-prompt completion via LlmTransport.stream(). Text deltas are written to stdout incrementally. Reasoning/think blocks go to stderr (requires --think). A JSON usage summary is printed to stderr at stream end."
44276
+ },
44277
+ args: {
44278
+ provider: {
44279
+ type: "positional",
44280
+ description: "Provider transport (anthropic | openai | gemini | moonshot | openrouter | \u2026)",
44281
+ required: true
44282
+ },
44283
+ prompt: {
44284
+ type: "positional",
44285
+ description: "Prompt text to send to the model.",
44286
+ required: true
44287
+ },
44288
+ model: {
44289
+ type: "string",
44290
+ description: "Model identifier override (e.g. 'claude-sonnet-4-6'). Uses provider default when omitted."
44291
+ },
44292
+ "max-tokens": {
44293
+ type: "string",
44294
+ description: "Maximum output tokens (default: 4096)."
44295
+ },
44296
+ temperature: {
44297
+ type: "string",
44298
+ description: "Sampling temperature in 0.0\u20131.0 (default: 0.7)."
44299
+ },
44300
+ think: {
44301
+ type: "boolean",
44302
+ description: "Emit reasoning/think blocks to stderr (default: off).",
44303
+ default: false
44304
+ },
44305
+ system: {
44306
+ type: "string",
44307
+ description: "Optional system prompt prepended to the conversation."
44308
+ }
44309
+ },
44310
+ async run({ args }) {
44311
+ const a = args;
44312
+ const provider = String(a["provider"] ?? "").trim();
44313
+ const prompt = String(a["prompt"] ?? "").trim();
44314
+ if (!provider) {
44315
+ process.stderr.write("[error] cleo llm stream: <provider> is required.\n");
44316
+ process.exit(2);
44317
+ }
44318
+ if (!prompt) {
44319
+ process.stderr.write("[error] cleo llm stream: <prompt> is required.\n");
44320
+ process.exit(2);
44321
+ }
44322
+ const model = typeof a["model"] === "string" && a["model"] ? a["model"] : void 0;
44323
+ const maxTokensRaw = typeof a["max-tokens"] === "string" ? Number(a["max-tokens"]) : void 0;
44324
+ const maxTokens = maxTokensRaw !== void 0 && !Number.isNaN(maxTokensRaw) ? maxTokensRaw : void 0;
44325
+ const tempRaw = typeof a["temperature"] === "string" ? parseFloat(a["temperature"]) : void 0;
44326
+ const temperature = tempRaw !== void 0 && !Number.isNaN(tempRaw) ? tempRaw : void 0;
44327
+ const showThink = a["think"] === true;
44328
+ const system = typeof a["system"] === "string" && a["system"] ? a["system"] : void 0;
44329
+ void maxTokens;
44330
+ void temperature;
44331
+ try {
44332
+ await runLlmStream({ provider, prompt, model, maxTokens, temperature, showThink, system });
44333
+ } catch (err) {
44334
+ const msg = err instanceof Error ? err.message : String(err);
44335
+ process.stderr.write(`[error] cleo llm stream: ${msg}
44336
+ `);
44337
+ process.exit(1);
44338
+ }
44339
+ }
44340
+ });
44341
+ }
44342
+ });
44343
+
43991
44344
  // packages/cleo/src/cli/commands/llm-login.ts
43992
44345
  import { spawn } from "node:child_process";
43993
44346
  import { createServer } from "node:http";
@@ -44334,6 +44687,57 @@ var init_llm_login = __esm({
44334
44687
  }
44335
44688
  });
44336
44689
 
44690
+ // packages/cleo/src/cli/commands/llm-refresh-catalog.ts
44691
+ import {
44692
+ buildContextIndex,
44693
+ fetchAndCacheCatalog,
44694
+ findLatestCacheFile,
44695
+ getCatalogDir,
44696
+ readCacheFile
44697
+ } from "@cleocode/core/llm/catalog-cache";
44698
+ async function runLlmRefreshCatalog(dir) {
44699
+ const cacheDir = dir ?? getCatalogDir();
44700
+ try {
44701
+ const { filePath, catalog: catalog2 } = await fetchAndCacheCatalog(cacheDir);
44702
+ const index = buildContextIndex(catalog2);
44703
+ const providerCount = Object.keys(catalog2).length;
44704
+ const modelCount = Object.keys(index).length;
44705
+ return {
44706
+ success: true,
44707
+ data: { providers: providerCount, models: modelCount, filePath, source: "live" }
44708
+ };
44709
+ } catch {
44710
+ }
44711
+ const latestPath = findLatestCacheFile(cacheDir);
44712
+ if (latestPath) {
44713
+ const catalog2 = readCacheFile(latestPath);
44714
+ if (catalog2) {
44715
+ const index = buildContextIndex(catalog2);
44716
+ return {
44717
+ success: true,
44718
+ data: {
44719
+ providers: Object.keys(catalog2).length,
44720
+ models: Object.keys(index).length,
44721
+ filePath: latestPath,
44722
+ source: "stale-cache"
44723
+ }
44724
+ };
44725
+ }
44726
+ }
44727
+ return {
44728
+ success: false,
44729
+ error: {
44730
+ message: "Failed to fetch model catalog and no cached snapshot found.",
44731
+ code: "E_CATALOG_UNAVAILABLE"
44732
+ }
44733
+ };
44734
+ }
44735
+ var init_llm_refresh_catalog = __esm({
44736
+ "packages/cleo/src/cli/commands/llm-refresh-catalog.ts"() {
44737
+ "use strict";
44738
+ }
44739
+ });
44740
+
44337
44741
  // packages/cleo/src/cli/commands/llm.ts
44338
44742
  var llm_exports = {};
44339
44743
  __export(llm_exports, {
@@ -44372,7 +44776,7 @@ function makeLlmSubcommand(opts) {
44372
44776
  }
44373
44777
  });
44374
44778
  }
44375
- var API_KEY_FLAG_DEPRECATION, addCommand5, listCommand10, removeCommand3, useCommand, profileCommand, testCommand, whoamiCommand, listProvidersCommand, loginCommand, llmCommand;
44779
+ var API_KEY_FLAG_DEPRECATION, addCommand5, listCommand10, removeCommand3, useCommand, profileCommand, testCommand, whoamiCommand, listProvidersCommand, contextEnginesListCommand, contextEnginesCommand, loginCommand, refreshCatalogCommand, llmCommand;
44376
44780
  var init_llm3 = __esm({
44377
44781
  "packages/cleo/src/cli/commands/llm.ts"() {
44378
44782
  "use strict";
@@ -44381,6 +44785,8 @@ var init_llm3 = __esm({
44381
44785
  init_renderers();
44382
44786
  init_llm_cost();
44383
44787
  init_llm_login();
44788
+ init_llm_refresh_catalog();
44789
+ init_llm_stream();
44384
44790
  API_KEY_FLAG_DEPRECATION = "[warning] --api-key exposes the secret to 'ps' listings and shell history. Prefer --api-key-stdin or --api-key-env=NAME for production use.";
44385
44791
  addCommand5 = defineCommand({
44386
44792
  meta: {
@@ -44651,6 +45057,46 @@ var init_llm3 = __esm({
44651
45057
  );
44652
45058
  }
44653
45059
  });
45060
+ contextEnginesListCommand = defineCommand({
45061
+ meta: {
45062
+ name: "list",
45063
+ description: "List all registered ContextEngine names (builtins + user plugins)."
45064
+ },
45065
+ args: {
45066
+ json: {
45067
+ type: "boolean",
45068
+ description: "Output as JSON"
45069
+ }
45070
+ },
45071
+ async run() {
45072
+ const { listContextEngines } = await import(
45073
+ /* webpackIgnore: true */
45074
+ "@cleocode/core/llm/executor-factory"
45075
+ );
45076
+ const engines = listContextEngines();
45077
+ cliOutput(
45078
+ { engines: [...engines] },
45079
+ {
45080
+ command: "llm-context-engines-list",
45081
+ operation: "llm.contextEngines.list"
45082
+ }
45083
+ );
45084
+ }
45085
+ });
45086
+ contextEnginesCommand = defineCommand({
45087
+ meta: {
45088
+ name: "context-engines",
45089
+ description: "Manage registered ContextEngine plugins."
45090
+ },
45091
+ subCommands: {
45092
+ list: contextEnginesListCommand
45093
+ },
45094
+ async run({ cmd, rawArgs }) {
45095
+ const firstArg = rawArgs?.find((a) => !a.startsWith("-"));
45096
+ if (firstArg && cmd.subCommands && firstArg in cmd.subCommands) return;
45097
+ await showUsage(cmd);
45098
+ }
45099
+ });
44654
45100
  loginCommand = defineCommand({
44655
45101
  meta: {
44656
45102
  name: "login",
@@ -44686,6 +45132,36 @@ var init_llm3 = __esm({
44686
45132
  );
44687
45133
  } else if (result.error) {
44688
45134
  process.stderr.write(`[error] ${result.error.message}
45135
+ `);
45136
+ process.exit(1);
45137
+ }
45138
+ }
45139
+ });
45140
+ refreshCatalogCommand = defineCommand({
45141
+ meta: {
45142
+ name: "refresh-catalog",
45143
+ description: "Fetch the live model catalog from models.dev and persist it to disk. Falls back to the most-recent cached snapshot on network failure."
45144
+ },
45145
+ args: {
45146
+ json: {
45147
+ type: "boolean",
45148
+ description: "Output result as JSON"
45149
+ }
45150
+ },
45151
+ async run({ args }) {
45152
+ const jsonOutput = args["json"] === true;
45153
+ const result = await runLlmRefreshCatalog();
45154
+ if (jsonOutput) {
45155
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
45156
+ `);
45157
+ } else if (result.success && result.data) {
45158
+ const d = result.data;
45159
+ process.stdout.write(
45160
+ `Catalog refreshed: ${d.providers} providers, ${d.models} models written to ${d.filePath}
45161
+ `
45162
+ );
45163
+ } else if (!result.success) {
45164
+ process.stderr.write(`[error] ${result.error?.message ?? "refresh failed"}
44689
45165
  `);
44690
45166
  process.exit(1);
44691
45167
  }
@@ -44698,12 +45174,15 @@ var init_llm3 = __esm({
44698
45174
  },
44699
45175
  subCommands: {
44700
45176
  add: addCommand5,
45177
+ "context-engines": contextEnginesCommand,
44701
45178
  cost: costCommand,
44702
45179
  list: listCommand10,
44703
45180
  login: loginCommand,
44704
45181
  remove: removeCommand3,
45182
+ stream: streamCommand,
44705
45183
  use: useCommand,
44706
45184
  profile: profileCommand,
45185
+ "refresh-catalog": refreshCatalogCommand,
44707
45186
  test: testCommand,
44708
45187
  whoami: whoamiCommand,
44709
45188
  "list-providers": listProvidersCommand
@@ -45149,7 +45628,7 @@ import {
45149
45628
  getBrainDb as getBrainDb2,
45150
45629
  getBrainNativeDb as getBrainNativeDb3,
45151
45630
  getDreamStatus,
45152
- getProjectRoot as getProjectRoot26,
45631
+ getProjectRoot as getProjectRoot27,
45153
45632
  runConsolidation,
45154
45633
  triggerManualDream
45155
45634
  } from "@cleocode/core/internal";
@@ -45215,7 +45694,7 @@ function makeMemorySubcommand(opts) {
45215
45694
  }
45216
45695
  });
45217
45696
  }
45218
- var storeCommand, findCommand5, statsCommand4, observeCommand, timelineCommand, fetchCommand2, decisionFindCommand, decisionStoreCommand, linkCommand, traceCommand, relatedCommand, contextCommand3, graphStatsCommand, graphShowCommand, graphNeighborsCommand, graphAddCommand, graphRemoveCommand, reasonWhyCommand, reasonSimilarCommand, searchHybridCommand, codeLinksCommand, codeAutoLinkCommand, codeMemoriesForCodeCommand, codeForMemoryCommand, consolidateCommand, dreamCommand, reflectCommand, dedupScanCommand, importCommand3, doctorCommand3, llmStatusCommand, verifyCommand, pendingVerifyCommand, tierStatsCommand, tierPromoteCommand, tierDemoteCommand, precompactFlushCommand, backfillRunCommand, backfillApproveCommand, backfillRollbackCommand, backfillCommand, digestCommand, recentCommand, diaryReadCommand, diaryWriteCommand, diaryCommand, watchCommand2, tierCommand, sweepCommand, memoryCommand;
45697
+ var storeCommand, findCommand5, statsCommand4, observeCommand, timelineCommand, fetchCommand2, decisionFindCommand, decisionStoreCommand, linkCommand, traceCommand, relatedCommand, contextCommand3, graphStatsCommand, graphShowCommand, graphNeighborsCommand, graphAddCommand, graphRemoveCommand, reasonWhyCommand, reasonSimilarCommand, searchHybridCommand, codeLinksCommand, codeAutoLinkCommand, codeMemoriesForCodeCommand, codeForMemoryCommand, consolidateCommand, dreamCommand, reflectCommand, dedupScanCommand, importCommand3, doctorCommand3, llmStatusCommand, verifyCommand, pendingVerifyCommand, tierStatsCommand, tierPromoteCommand, tierDemoteCommand, precompactFlushCommand, backfillRunCommand, backfillApproveCommand, backfillRollbackCommand, backfillCommand2, digestCommand, recentCommand, diaryReadCommand, diaryWriteCommand, diaryCommand, watchCommand2, tierCommand, sweepCommand, memoryCommand;
45219
45698
  var init_memory3 = __esm({
45220
45699
  "packages/cleo/src/cli/commands/memory.ts"() {
45221
45700
  "use strict";
@@ -46110,7 +46589,7 @@ var init_memory3 = __esm({
46110
46589
  },
46111
46590
  args: {},
46112
46591
  async run() {
46113
- const root = getProjectRoot26();
46592
+ const root = getProjectRoot27();
46114
46593
  try {
46115
46594
  const result = await runConsolidation(root);
46116
46595
  cliOutput(result, { command: "memory-consolidate", operation: "memory.consolidate" });
@@ -46134,7 +46613,7 @@ var init_memory3 = __esm({
46134
46613
  }
46135
46614
  },
46136
46615
  async run({ args }) {
46137
- const root = getProjectRoot26();
46616
+ const root = getProjectRoot27();
46138
46617
  if (args.status) {
46139
46618
  try {
46140
46619
  const status = await getDreamStatus(root);
@@ -46171,7 +46650,7 @@ var init_memory3 = __esm({
46171
46650
  }
46172
46651
  },
46173
46652
  async run({ args }) {
46174
- const root = getProjectRoot26();
46653
+ const root = getProjectRoot27();
46175
46654
  try {
46176
46655
  const { runObserver, runReflector } = await import("@cleocode/core/internal");
46177
46656
  const observerResult = await runObserver(root, args.session, {
@@ -46211,7 +46690,7 @@ var init_memory3 = __esm({
46211
46690
  }
46212
46691
  },
46213
46692
  async run({ args }) {
46214
- const root = getProjectRoot26();
46693
+ const root = getProjectRoot27();
46215
46694
  try {
46216
46695
  const { getBrainDb: getBrainDbInner, getBrainNativeDb: getBrainNativeDbInner } = await import("@cleocode/core/internal");
46217
46696
  await getBrainDbInner(root);
@@ -46309,7 +46788,7 @@ var init_memory3 = __esm({
46309
46788
  async run({ args }) {
46310
46789
  const sourceDir = args.from ?? join19(homedir6(), ".claude", "projects", "-mnt-projects-cleocode", "memory");
46311
46790
  const isDryRun = !!args["dry-run"];
46312
- const projectRoot = getProjectRoot26();
46791
+ const projectRoot = getProjectRoot27();
46313
46792
  const stateFile = join19(projectRoot, CLEO_DIR_NAME, MIGRATE_MEMORY_HASHES_JSON);
46314
46793
  if (!existsSync13(sourceDir)) {
46315
46794
  cliError(`Source directory not found: ${sourceDir}`, "E_NOT_FOUND", { name: "E_NOT_FOUND" });
@@ -46522,7 +47001,7 @@ var init_memory3 = __esm({
46522
47001
  },
46523
47002
  args: {},
46524
47003
  async run() {
46525
- const root = getProjectRoot26();
47004
+ const root = getProjectRoot27();
46526
47005
  try {
46527
47006
  await getBrainDb2(root);
46528
47007
  const nativeDb = getBrainNativeDb3();
@@ -46621,7 +47100,7 @@ var init_memory3 = __esm({
46621
47100
  }
46622
47101
  },
46623
47102
  async run({ args }) {
46624
- const root = getProjectRoot26();
47103
+ const root = getProjectRoot27();
46625
47104
  const targetTier = args.to;
46626
47105
  const reason = args.reason;
46627
47106
  const validTiers = ["medium", "long"];
@@ -46725,7 +47204,7 @@ var init_memory3 = __esm({
46725
47204
  }
46726
47205
  },
46727
47206
  async run({ args }) {
46728
- const root = getProjectRoot26();
47207
+ const root = getProjectRoot27();
46729
47208
  const targetTier = args.to;
46730
47209
  const reason = args.reason;
46731
47210
  const validTiers = ["short", "medium"];
@@ -46884,7 +47363,7 @@ var init_memory3 = __esm({
46884
47363
  runId: args["runId"]
46885
47364
  })
46886
47365
  });
46887
- backfillCommand = defineCommand({
47366
+ backfillCommand2 = defineCommand({
46888
47367
  meta: {
46889
47368
  name: "backfill",
46890
47369
  description: "Staged brain-graph backfill operations: run, approve, rollback (T1003)."
@@ -47217,7 +47696,7 @@ data: ${JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString() })}
47217
47696
  tier: tierCommand,
47218
47697
  // T1013 — new memory subcommands
47219
47698
  "precompact-flush": precompactFlushCommand,
47220
- backfill: backfillCommand,
47699
+ backfill: backfillCommand2,
47221
47700
  digest: digestCommand,
47222
47701
  recent: recentCommand,
47223
47702
  diary: diaryCommand,
@@ -47239,7 +47718,7 @@ var migrate_claude_mem_exports = {};
47239
47718
  __export(migrate_claude_mem_exports, {
47240
47719
  migrateClaudeMemCommand: () => migrateClaudeMemCommand
47241
47720
  });
47242
- import { getProjectRoot as getProjectRoot27, migrateClaudeMem } from "@cleocode/core/internal";
47721
+ import { getProjectRoot as getProjectRoot28, migrateClaudeMem } from "@cleocode/core/internal";
47243
47722
  import { ingestLooseAgentOutputs, ingestRcasdDirectories } from "@cleocode/core/memory";
47244
47723
  import { getDb as getDb2 } from "@cleocode/core/store/sqlite";
47245
47724
  var storageCommand, claudeMemCommand, manifestIngestCommand, migrateClaudeMemCommand;
@@ -47302,7 +47781,7 @@ var init_migrate_claude_mem = __esm({
47302
47781
  }
47303
47782
  },
47304
47783
  async run({ args }) {
47305
- const root = getProjectRoot27();
47784
+ const root = getProjectRoot28();
47306
47785
  try {
47307
47786
  const result = await migrateClaudeMem(root, {
47308
47787
  sourcePath: args.source,
@@ -47351,7 +47830,7 @@ var init_migrate_claude_mem = __esm({
47351
47830
  }
47352
47831
  },
47353
47832
  async run({ args }) {
47354
- const projectRoot = getProjectRoot27();
47833
+ const projectRoot = getProjectRoot28();
47355
47834
  try {
47356
47835
  const db = await getDb2(projectRoot);
47357
47836
  const rcasdFlag = Boolean(args.rcasd);
@@ -48296,7 +48775,7 @@ var init_nexus4 = __esm({
48296
48775
  const repoPath = args.path ? path4.resolve(args.path) : process.cwd();
48297
48776
  humanInfo(`[nexus] Analyzing: ${repoPath}${isIncremental ? " (incremental)" : ""}`);
48298
48777
  try {
48299
- const [{ getNexusDb, nexusSchema }, { runPipeline }, { getProjectRoot: getProjectRoot33 }, { eq: eq2 }] = await Promise.all([
48778
+ const [{ getNexusDb, nexusSchema }, { runPipeline }, { getProjectRoot: getProjectRoot34 }, { eq: eq2 }] = await Promise.all([
48300
48779
  import("@cleocode/core/store/nexus-sqlite"),
48301
48780
  import("@cleocode/nexus/pipeline"),
48302
48781
  import("@cleocode/core/internal"),
@@ -48376,7 +48855,7 @@ var init_nexus4 = __esm({
48376
48855
  extensions: { duration_ms: durationMs }
48377
48856
  }
48378
48857
  );
48379
- void getProjectRoot33;
48858
+ void getProjectRoot34;
48380
48859
  } catch (err) {
48381
48860
  const msg = err instanceof Error ? err.message : String(err);
48382
48861
  cliError(
@@ -51978,7 +52457,7 @@ var refresh_memory_exports = {};
51978
52457
  __export(refresh_memory_exports, {
51979
52458
  refreshMemoryCommand: () => refreshMemoryCommand
51980
52459
  });
51981
- import { getProjectRoot as getProjectRoot28 } from "@cleocode/core";
52460
+ import { getProjectRoot as getProjectRoot29 } from "@cleocode/core";
51982
52461
  var refreshMemoryCommand;
51983
52462
  var init_refresh_memory = __esm({
51984
52463
  "packages/cleo/src/cli/commands/refresh-memory.ts"() {
@@ -51991,7 +52470,7 @@ var init_refresh_memory = __esm({
51991
52470
  description: "Regenerate .cleo/memory-bridge.md from brain.db"
51992
52471
  },
51993
52472
  async run() {
51994
- const projectDir = getProjectRoot28();
52473
+ const projectDir = getProjectRoot29();
51995
52474
  const { writeMemoryBridge } = await import("@cleocode/core/internal");
51996
52475
  const result = await writeMemoryBridge(projectDir);
51997
52476
  if (result.written) {
@@ -53301,7 +53780,7 @@ __export(restore_exports, {
53301
53780
  import fs3 from "node:fs";
53302
53781
  import path5 from "node:path";
53303
53782
  import { CleoError as CleoError8, getTaskAccessor as getTaskAccessor3 } from "@cleocode/core";
53304
- import { getProjectRoot as getProjectRoot29 } from "@cleocode/core/internal";
53783
+ import { getProjectRoot as getProjectRoot30 } from "@cleocode/core/internal";
53305
53784
  function parseMarkdownValue(raw) {
53306
53785
  const trimmed = raw.trim();
53307
53786
  if (trimmed === "_(not present)_" || trimmed === "") return void 0;
@@ -53421,7 +53900,7 @@ var init_restore = __esm({
53421
53900
  description: "Apply manually-resolved conflicts from .cleo/restore-conflicts.md"
53422
53901
  },
53423
53902
  async run() {
53424
- const projectRoot = getProjectRoot29();
53903
+ const projectRoot = getProjectRoot30();
53425
53904
  const reportPath = path5.join(projectRoot, CLEO_DIR_NAME, RESTORE_CONFLICTS_MD);
53426
53905
  if (!fs3.existsSync(reportPath)) {
53427
53906
  humanLine("No pending restore conflicts. Nothing to finalize.");
@@ -55396,7 +55875,7 @@ var sequence_exports = {};
55396
55875
  __export(sequence_exports, {
55397
55876
  sequenceCommand: () => sequenceCommand
55398
55877
  });
55399
- import { getProjectRoot as getProjectRoot30 } from "@cleocode/core/internal";
55878
+ import { getProjectRoot as getProjectRoot31 } from "@cleocode/core/internal";
55400
55879
  var showCommand12, checkCommand6, repairCommand, sequenceCommand;
55401
55880
  var init_sequence = __esm({
55402
55881
  "packages/cleo/src/cli/commands/sequence.ts"() {
@@ -55432,7 +55911,7 @@ var init_sequence = __esm({
55432
55911
  meta: { name: "repair", description: "Reset counter to max + 1 if behind" },
55433
55912
  async run() {
55434
55913
  const { repairSequence } = await import("@cleocode/core/internal");
55435
- const projectRoot = getProjectRoot30();
55914
+ const projectRoot = getProjectRoot31();
55436
55915
  const repair = await repairSequence(projectRoot);
55437
55916
  const result = {
55438
55917
  repaired: repair.repaired,
@@ -55875,8 +56354,8 @@ var init_session4 = __esm({
55875
56354
  "audit-scope": { type: "string", description: "Audit log scope (global|local)" }
55876
56355
  },
55877
56356
  async run({ args }) {
55878
- const { detectSessionDrift, getProjectRoot: getProjectRoot33 } = await import("@cleocode/core");
55879
- const projectRoot = await getProjectRoot33();
56357
+ const { detectSessionDrift, getProjectRoot: getProjectRoot34 } = await import("@cleocode/core");
56358
+ const projectRoot = await getProjectRoot34();
55880
56359
  const scope = args["audit-scope"] === "local" ? "local" : "global";
55881
56360
  const report = await detectSessionDrift({ projectRoot, auditScope: scope });
55882
56361
  cliOutput(report, { command: "session drift", operation: "session.drift" });
@@ -57384,7 +57863,7 @@ __export(token_exports, {
57384
57863
  tokenCommand: () => tokenCommand
57385
57864
  });
57386
57865
  import { readFileSync as readFileSync15 } from "node:fs";
57387
- import { getProjectRoot as getProjectRoot31, measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
57866
+ import { getProjectRoot as getProjectRoot32, measureTokenExchange, recordTokenExchange as recordTokenExchange2 } from "@cleocode/core/internal";
57388
57867
  function readPayload(args, textKey, fileKey) {
57389
57868
  const text = args[textKey];
57390
57869
  const file = args[fileKey];
@@ -57548,7 +58027,7 @@ var init_token = __esm({
57548
58027
  domain: args.domain,
57549
58028
  operation: args.operation
57550
58029
  };
57551
- const result = args.record ? await recordTokenExchange2(getProjectRoot31(), input) : await measureTokenExchange(input);
58030
+ const result = args.record ? await recordTokenExchange2(getProjectRoot32(), input) : await measureTokenExchange(input);
57552
58031
  cliOutput(result, {
57553
58032
  command: "token",
57554
58033
  operation: args.record ? "admin.token.record" : "token.estimate"
@@ -57584,7 +58063,7 @@ __export(transcript_exports, {
57584
58063
  });
57585
58064
  import { homedir as homedir8 } from "node:os";
57586
58065
  import { join as join23 } from "node:path";
57587
- import { getProjectRoot as getProjectRoot32 } from "@cleocode/core";
58066
+ import { getProjectRoot as getProjectRoot33 } from "@cleocode/core";
57588
58067
  import {
57589
58068
  parseDurationMs,
57590
58069
  pruneTranscripts,
@@ -57614,7 +58093,7 @@ var init_transcript = __esm({
57614
58093
  async run({ args }) {
57615
58094
  if (args.pending) {
57616
58095
  try {
57617
- const projectRoot = getProjectRoot32();
58096
+ const projectRoot = getProjectRoot33();
57618
58097
  const { scanPendingTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
57619
58098
  const pending = await scanPendingTranscripts(projectRoot);
57620
58099
  cliOutput(
@@ -57711,7 +58190,7 @@ var init_transcript = __esm({
57711
58190
  async run({ args }) {
57712
58191
  const tier = args.tier ?? "warm";
57713
58192
  const dryRun = args["dry-run"] ?? false;
57714
- const projectRoot = getProjectRoot32();
58193
+ const projectRoot = getProjectRoot33();
57715
58194
  try {
57716
58195
  const { extractTranscript } = await import("@cleocode/core/memory/transcript-extractor.js");
57717
58196
  const { findSessionTranscriptPath, listAllTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
@@ -57823,7 +58302,7 @@ var init_transcript = __esm({
57823
58302
  const dryRun = args["dry-run"] ?? false;
57824
58303
  const olderThanHours = args["older-than-hours"] ? Number.parseInt(args["older-than-hours"], 10) : 24;
57825
58304
  const limit = args.limit ? Number.parseInt(args.limit, 10) : void 0;
57826
- const projectRoot = getProjectRoot32();
58305
+ const projectRoot = getProjectRoot33();
57827
58306
  try {
57828
58307
  const { extractTranscript } = await import("@cleocode/core/memory/transcript-extractor.js");
57829
58308
  const { listAllTranscripts } = await import("@cleocode/core/memory/transcript-scanner.js");
@@ -58935,6 +59414,12 @@ var COMMAND_MANIFEST = [
58935
59414
  description: "Git-backed audit tooling (lineage reconstruction, integrity checks). ",
58936
59415
  load: async () => (await Promise.resolve().then(() => (init_audit2(), audit_exports))).auditCommand
58937
59416
  },
59417
+ {
59418
+ exportName: "backfillCommand",
59419
+ name: "backfill",
59420
+ description: "Retroactively add acceptance criteria and verification metadata to existing tasks",
59421
+ load: async () => (await Promise.resolve().then(() => (init_backfill(), backfill_exports))).backfillCommand
59422
+ },
58938
59423
  {
58939
59424
  exportName: "backupInspectSubCommand",
58940
59425
  name: "inspect",
@@ -59283,6 +59768,12 @@ var COMMAND_MANIFEST = [
59283
59768
  description: "Compute cumulative USD cost for an LLM session from recorded token_usage entries. ",
59284
59769
  load: async () => (await Promise.resolve().then(() => (init_llm_cost(), llm_cost_exports))).costCommand
59285
59770
  },
59771
+ {
59772
+ exportName: "streamCommand",
59773
+ name: "stream",
59774
+ description: "Stream a single-prompt completion via LlmTransport.stream(). ",
59775
+ load: async () => (await Promise.resolve().then(() => (init_llm_stream(), llm_stream_exports))).streamCommand
59776
+ },
59286
59777
  {
59287
59778
  exportName: "llmCommand",
59288
59779
  name: "llm",
@@ -60050,7 +60541,7 @@ async function runStartupMaintenance() {
60050
60541
  detectAndRemoveStrayProjectNexus,
60051
60542
  getGlobalSalt,
60052
60543
  getLogger: getLogger17,
60053
- getProjectRoot: getProjectRoot33,
60544
+ getProjectRoot: getProjectRoot34,
60054
60545
  isCleanupMarkerSet,
60055
60546
  migrateSignaldockToConduit,
60056
60547
  needsSignaldockToConduitMigration,
@@ -60059,7 +60550,7 @@ async function runStartupMaintenance() {
60059
60550
  } = await import("@cleocode/core/internal");
60060
60551
  let projectRootForCleanup = "";
60061
60552
  try {
60062
- projectRootForCleanup = getProjectRoot33();
60553
+ projectRootForCleanup = getProjectRoot34();
60063
60554
  } catch {
60064
60555
  }
60065
60556
  if (!isCleanupMarkerSet(CLI_VERSION, projectRootForCleanup)) {
@@ -60079,7 +60570,7 @@ async function runStartupMaintenance() {
60079
60570
  const isInitInvocation = process.argv.slice(2).some((a) => a === "init");
60080
60571
  if (!isInitInvocation) {
60081
60572
  try {
60082
- const _projectRootForMigration = getProjectRoot33();
60573
+ const _projectRootForMigration = getProjectRoot34();
60083
60574
  if (needsSignaldockToConduitMigration(_projectRootForMigration)) {
60084
60575
  const migrationResult = migrateSignaldockToConduit(_projectRootForMigration);
60085
60576
  if (migrationResult.status === "failed") {