@cleocode/cleo 2026.3.44 → 2026.3.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mcp/index.js CHANGED
@@ -9123,7 +9123,7 @@ var init_tasks_schema = __esm({
9123
9123
  "supersedes"
9124
9124
  ];
9125
9125
  LIFECYCLE_TRANSITION_TYPES = ["automatic", "manual", "forced"];
9126
- EXTERNAL_LINK_TYPES = ["created", "matched", "manual"];
9126
+ EXTERNAL_LINK_TYPES = ["created", "matched", "manual", "transferred"];
9127
9127
  SYNC_DIRECTIONS = ["inbound", "outbound", "bidirectional"];
9128
9128
  tasks = sqliteTable(
9129
9129
  "tasks",
@@ -10583,7 +10583,9 @@ function getBrainDbPath(cwd) {
10583
10583
  function resolveBrainMigrationsFolder() {
10584
10584
  const __filename = fileURLToPath(import.meta.url);
10585
10585
  const __dirname = dirname3(__filename);
10586
- return join7(__dirname, "..", "..", "migrations", "drizzle-brain");
10586
+ const isBundled = __dirname.endsWith("/dist") || __dirname.endsWith("\\dist");
10587
+ const pkgRoot = isBundled ? join7(__dirname, "..") : join7(__dirname, "..", "..");
10588
+ return join7(pkgRoot, "migrations", "drizzle-brain");
10587
10589
  }
10588
10590
  function tableExists(nativeDb, tableName) {
10589
10591
  const result = nativeDb.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(tableName);
@@ -10827,7 +10829,9 @@ function getNexusDbPath() {
10827
10829
  function resolveNexusMigrationsFolder() {
10828
10830
  const __filename = fileURLToPath2(import.meta.url);
10829
10831
  const __dirname = dirname4(__filename);
10830
- return join8(__dirname, "..", "..", "migrations", "drizzle-nexus");
10832
+ const isBundled = __dirname.endsWith("/dist") || __dirname.endsWith("\\dist");
10833
+ const pkgRoot = isBundled ? join8(__dirname, "..") : join8(__dirname, "..", "..");
10834
+ return join8(pkgRoot, "migrations", "drizzle-nexus");
10831
10835
  }
10832
10836
  function tableExists2(nativeDb, tableName) {
10833
10837
  const result = nativeDb.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(tableName);
@@ -11018,7 +11022,7 @@ function getDbPath(cwd) {
11018
11022
  return join9(getCleoDirAbsolute(cwd), DB_FILENAME3);
11019
11023
  }
11020
11024
  async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
11021
- const log9 = getLogger("sqlite");
11025
+ const log10 = getLogger("sqlite");
11022
11026
  try {
11023
11027
  const countResult = nativeDb.prepare("SELECT COUNT(*) as cnt FROM tasks").get();
11024
11028
  const taskCount = countResult?.cnt ?? 0;
@@ -11039,7 +11043,7 @@ async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
11039
11043
  if (backupTaskCount < MIN_BACKUP_TASK_COUNT) {
11040
11044
  return;
11041
11045
  }
11042
- log9.warn(
11046
+ log10.warn(
11043
11047
  { dbPath, backupPath: newestBackup.path, backupTasks: backupTaskCount },
11044
11048
  `Empty database detected with ${backupTaskCount}-task backup available. Auto-recovering from backup. This likely happened because git-tracked WAL/SHM files were overwritten during a branch switch (T5188).`
11045
11049
  );
@@ -11057,7 +11061,7 @@ async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
11057
11061
  const tempPath = dbPath + ".recovery-tmp";
11058
11062
  copyFileSync3(newestBackup.path, tempPath);
11059
11063
  renameSync(tempPath, dbPath);
11060
- log9.info(
11064
+ log10.info(
11061
11065
  { dbPath, backupPath: newestBackup.path, restoredTasks: backupTaskCount },
11062
11066
  "Database auto-recovered from backup successfully."
11063
11067
  );
@@ -11067,7 +11071,7 @@ async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
11067
11071
  runMigrations(restoredNativeDb, restoredDb);
11068
11072
  _db2 = restoredDb;
11069
11073
  } catch (err) {
11070
- log9.error({ err, dbPath }, "Auto-recovery from backup failed. Continuing with empty database.");
11074
+ log10.error({ err, dbPath }, "Auto-recovery from backup failed. Continuing with empty database.");
11071
11075
  }
11072
11076
  }
11073
11077
  async function getDb(cwd) {
@@ -11098,7 +11102,7 @@ async function getDb(cwd) {
11098
11102
  const { execFileSync: execFileSync14 } = await import("node:child_process");
11099
11103
  const gitCwd = resolve3(dbPath, "..", "..");
11100
11104
  const filesToCheck = [dbPath, dbPath + "-wal", dbPath + "-shm"];
11101
- const log9 = getLogger("sqlite");
11105
+ const log10 = getLogger("sqlite");
11102
11106
  for (const fileToCheck of filesToCheck) {
11103
11107
  try {
11104
11108
  execFileSync14("git", ["ls-files", "--error-unmatch", fileToCheck], {
@@ -11106,7 +11110,7 @@ async function getDb(cwd) {
11106
11110
  stdio: "pipe"
11107
11111
  });
11108
11112
  const basename19 = fileToCheck.split(/[\\/]/).pop();
11109
- log9.warn(
11113
+ log10.warn(
11110
11114
  { path: fileToCheck },
11111
11115
  `${basename19} is tracked by project git \u2014 this risks data loss on branch switch. Run: git rm --cached ${fileToCheck.replace(gitCwd + sep, "")} (see ADR-013, T5188)`
11112
11116
  );
@@ -11128,7 +11132,9 @@ async function getDb(cwd) {
11128
11132
  function resolveMigrationsFolder() {
11129
11133
  const __filename = fileURLToPath3(import.meta.url);
11130
11134
  const __dirname = dirname5(__filename);
11131
- return join9(__dirname, "..", "..", "migrations", "drizzle-tasks");
11135
+ const isBundled = __dirname.endsWith("/dist") || __dirname.endsWith("\\dist");
11136
+ const pkgRoot = isBundled ? join9(__dirname, "..") : join9(__dirname, "..", "..");
11137
+ return join9(pkgRoot, "migrations", "drizzle-tasks");
11132
11138
  }
11133
11139
  function tableExists3(nativeDb, tableName) {
11134
11140
  const result = nativeDb.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(tableName);
@@ -14396,6 +14402,37 @@ function buildExportPackage(tasks2, options) {
14396
14402
  relationshipGraph
14397
14403
  };
14398
14404
  }
14405
+ function exportSingle(taskId, allTasks, projectName) {
14406
+ const task = allTasks.find((t) => t.id === taskId);
14407
+ if (!task) return null;
14408
+ return buildExportPackage([task], {
14409
+ mode: "single",
14410
+ rootTaskIds: [taskId],
14411
+ includeChildren: false,
14412
+ projectName
14413
+ });
14414
+ }
14415
+ function exportSubtree(rootId, allTasks, projectName) {
14416
+ const root = allTasks.find((t) => t.id === rootId);
14417
+ if (!root) return null;
14418
+ const collected = /* @__PURE__ */ new Map();
14419
+ const queue = [rootId];
14420
+ while (queue.length > 0) {
14421
+ const id = queue.shift();
14422
+ const task = allTasks.find((t) => t.id === id);
14423
+ if (!task || collected.has(id)) continue;
14424
+ collected.set(id, task);
14425
+ const children = allTasks.filter((t) => t.parentId === id);
14426
+ queue.push(...children.map((c) => c.id));
14427
+ }
14428
+ const tasks2 = [...collected.values()];
14429
+ return buildExportPackage(tasks2, {
14430
+ mode: "subtree",
14431
+ rootTaskIds: [rootId],
14432
+ includeChildren: true,
14433
+ projectName
14434
+ });
14435
+ }
14399
14436
  var EXPORT_FORMAT_VERSION;
14400
14437
  var init_export2 = __esm({
14401
14438
  "packages/core/src/store/export.ts"() {
@@ -14856,20 +14893,7 @@ function topologicalSort(tasks2) {
14856
14893
  }
14857
14894
  return sorted;
14858
14895
  }
14859
- async function importTasksPackage(params) {
14860
- const { file: file2 } = params;
14861
- try {
14862
- await access2(file2, fsConstants2.R_OK);
14863
- } catch {
14864
- throw new Error(`Export file not found: ${file2}`);
14865
- }
14866
- const content = await readFile4(file2, "utf-8");
14867
- let exportPkg;
14868
- try {
14869
- exportPkg = JSON.parse(content);
14870
- } catch {
14871
- throw new Error(`Invalid JSON in: ${file2}`);
14872
- }
14896
+ async function importFromPackage(exportPkg, options = {}) {
14873
14897
  if (exportPkg._meta?.format !== "cleo-export") {
14874
14898
  throw new Error(
14875
14899
  `Invalid export format (expected 'cleo-export', got '${exportPkg._meta?.format}')`
@@ -14878,16 +14902,16 @@ async function importTasksPackage(params) {
14878
14902
  if (!exportPkg.tasks?.length) {
14879
14903
  throw new Error("Export package contains no tasks");
14880
14904
  }
14881
- const accessor = await getAccessor(params.cwd);
14905
+ const accessor = await getAccessor(options.cwd);
14882
14906
  const { tasks: existingTasks } = await accessor.queryTasks({});
14883
- const onConflict = params.onConflict ?? "fail";
14884
- const onMissingDep = params.onMissingDep ?? "strip";
14885
- const force = params.force ?? false;
14886
- const parentId = params.parent;
14887
- const phaseOverride = params.phase;
14888
- const addLabel = params.addLabel;
14889
- const resetStatus = params.resetStatus;
14890
- const addProvenance = params.provenance !== false;
14907
+ const onConflict = options.onConflict ?? "fail";
14908
+ const onMissingDep = options.onMissingDep === "fail" ? "fail" : "strip";
14909
+ const force = options.force ?? false;
14910
+ const parentId = options.parent;
14911
+ const phaseOverride = options.phase;
14912
+ const addLabel = options.addLabel;
14913
+ const resetStatus = options.resetStatus;
14914
+ const addProvenance = options.provenance !== false;
14891
14915
  if (parentId) {
14892
14916
  const parentExists = existingTasks.some((t) => t.id === parentId);
14893
14917
  if (!parentExists) {
@@ -14956,7 +14980,7 @@ async function importTasksPackage(params) {
14956
14980
  existingTitles.add(remapped.title.toLowerCase());
14957
14981
  existingIds.add(remapped.id);
14958
14982
  }
14959
- if (params.dryRun) {
14983
+ if (options.dryRun) {
14960
14984
  return {
14961
14985
  imported: transformed.length,
14962
14986
  skipped: skipped.length,
@@ -14976,6 +15000,33 @@ async function importTasksPackage(params) {
14976
15000
  idRemap: idRemapJson
14977
15001
  };
14978
15002
  }
15003
+ async function importTasksPackage(params) {
15004
+ const { file: file2 } = params;
15005
+ try {
15006
+ await access2(file2, fsConstants2.R_OK);
15007
+ } catch {
15008
+ throw new Error(`Export file not found: ${file2}`);
15009
+ }
15010
+ const content = await readFile4(file2, "utf-8");
15011
+ let exportPkg;
15012
+ try {
15013
+ exportPkg = JSON.parse(content);
15014
+ } catch {
15015
+ throw new Error(`Invalid JSON in: ${file2}`);
15016
+ }
15017
+ return importFromPackage(exportPkg, {
15018
+ cwd: params.cwd,
15019
+ dryRun: params.dryRun,
15020
+ parent: params.parent,
15021
+ phase: params.phase,
15022
+ addLabel: params.addLabel,
15023
+ provenance: params.provenance,
15024
+ resetStatus: params.resetStatus,
15025
+ onConflict: params.onConflict,
15026
+ onMissingDep: params.onMissingDep === "placeholder" ? "strip" : params.onMissingDep,
15027
+ force: params.force
15028
+ });
15029
+ }
14979
15030
  var init_import_tasks = __esm({
14980
15031
  "packages/core/src/admin/import-tasks.ts"() {
14981
15032
  "use strict";
@@ -34542,7 +34593,7 @@ async function ensureInjection(projectRoot) {
34542
34593
  }
34543
34594
  }
34544
34595
  const agentsMdPath = join36(projectRoot, "AGENTS.md");
34545
- const agentsMdLines = ["@~/.cleo/templates/CLEO-INJECTION.md"];
34596
+ const agentsMdLines = ["@~/.agents/AGENTS.md"];
34546
34597
  const projectContextPath = join36(projectRoot, ".cleo", "project-context.json");
34547
34598
  if (existsSync33(projectContextPath)) {
34548
34599
  agentsMdLines.push("@.cleo/project-context.json");
@@ -34555,7 +34606,8 @@ async function ensureInjection(projectRoot) {
34555
34606
  if (contributorBlock) {
34556
34607
  agentsMdLines.push(contributorBlock);
34557
34608
  }
34558
- const agentsAction = await inject2(agentsMdPath, agentsMdLines.join("\n"));
34609
+ const agentsMdContent = agentsMdLines.join("\n");
34610
+ const agentsAction = await inject2(agentsMdPath, agentsMdContent);
34559
34611
  actions.push(`AGENTS.md CLEO content (${agentsAction})`);
34560
34612
  const content = getInjectionTemplateContent();
34561
34613
  if (content) {
@@ -34570,8 +34622,9 @@ async function ensureInjection(projectRoot) {
34570
34622
  try {
34571
34623
  const globalAgentsDir = getAgentsHome();
34572
34624
  const globalAgentsMd = join36(globalAgentsDir, "AGENTS.md");
34625
+ const globalHubContent = "@~/.cleo/templates/CLEO-INJECTION.md";
34573
34626
  await mkdir4(globalAgentsDir, { recursive: true });
34574
- await inject2(globalAgentsMd, "@~/.cleo/templates/CLEO-INJECTION.md");
34627
+ await inject2(globalAgentsMd, globalHubContent);
34575
34628
  } catch {
34576
34629
  }
34577
34630
  return {
@@ -35079,7 +35132,7 @@ async function ensureProjectContext(projectRoot, opts) {
35079
35132
  try {
35080
35133
  const schemaPath = join37(
35081
35134
  dirname8(fileURLToPath4(import.meta.url)),
35082
- "../../schemas/project-context.schema.json"
35135
+ "../schemas/project-context.schema.json"
35083
35136
  );
35084
35137
  if (existsSync34(schemaPath)) {
35085
35138
  const AjvModule2 = await import("ajv");
@@ -35520,11 +35573,9 @@ async function ensureGlobalTemplates() {
35520
35573
  return { action: "created", path: injectionPath };
35521
35574
  }
35522
35575
  async function ensureGlobalScaffold() {
35523
- const { ensureGlobalSchemas: ensureGlobalSchemas2 } = await Promise.resolve().then(() => (init_schema_management(), schema_management_exports));
35524
35576
  const home = await ensureGlobalHome();
35525
- const schemas = ensureGlobalSchemas2();
35526
35577
  const templates2 = await ensureGlobalTemplates();
35527
- return { home, schemas, templates: templates2 };
35578
+ return { home, templates: templates2 };
35528
35579
  }
35529
35580
  function checkGlobalHome() {
35530
35581
  const cleoHome = getCleoHome();
@@ -35658,7 +35709,7 @@ metrics/
35658
35709
  .backups/
35659
35710
  backups/
35660
35711
  `;
35661
- REQUIRED_GLOBAL_SUBDIRS = ["schemas", "templates"];
35712
+ REQUIRED_GLOBAL_SUBDIRS = ["logs", "templates"];
35662
35713
  }
35663
35714
  });
35664
35715
 
@@ -43370,6 +43421,338 @@ var init_sharing = __esm({
43370
43421
  }
43371
43422
  });
43372
43423
 
43424
+ // packages/core/src/reconciliation/link-store.ts
43425
+ import { randomUUID as randomUUID4 } from "node:crypto";
43426
+ import { and as and5, eq as eq8 } from "drizzle-orm";
43427
+ async function getLinksByProvider(providerId, cwd) {
43428
+ const db = await getDb(cwd);
43429
+ const rows = await db.select().from(externalTaskLinks).where(eq8(externalTaskLinks.providerId, providerId));
43430
+ return rows.map(rowToLink);
43431
+ }
43432
+ async function getLinkByExternalId(providerId, externalId, cwd) {
43433
+ const db = await getDb(cwd);
43434
+ const rows = await db.select().from(externalTaskLinks).where(
43435
+ and5(
43436
+ eq8(externalTaskLinks.providerId, providerId),
43437
+ eq8(externalTaskLinks.externalId, externalId)
43438
+ )
43439
+ );
43440
+ return rows.length > 0 ? rowToLink(rows[0]) : null;
43441
+ }
43442
+ async function getLinksByTaskId(taskId, cwd) {
43443
+ const db = await getDb(cwd);
43444
+ const rows = await db.select().from(externalTaskLinks).where(eq8(externalTaskLinks.taskId, taskId));
43445
+ return rows.map(rowToLink);
43446
+ }
43447
+ async function createLink(params, cwd) {
43448
+ const db = await getDb(cwd);
43449
+ const now2 = (/* @__PURE__ */ new Date()).toISOString();
43450
+ const id = randomUUID4();
43451
+ await db.insert(externalTaskLinks).values({
43452
+ id,
43453
+ taskId: params.taskId,
43454
+ providerId: params.providerId,
43455
+ externalId: params.externalId,
43456
+ externalUrl: params.externalUrl ?? null,
43457
+ externalTitle: params.externalTitle ?? null,
43458
+ linkType: params.linkType,
43459
+ syncDirection: params.syncDirection ?? "inbound",
43460
+ metadataJson: params.metadata ? JSON.stringify(params.metadata) : "{}",
43461
+ linkedAt: now2,
43462
+ lastSyncAt: now2
43463
+ });
43464
+ return {
43465
+ id,
43466
+ taskId: params.taskId,
43467
+ providerId: params.providerId,
43468
+ externalId: params.externalId,
43469
+ externalUrl: params.externalUrl ?? null,
43470
+ externalTitle: params.externalTitle ?? null,
43471
+ linkType: params.linkType,
43472
+ syncDirection: params.syncDirection ?? "inbound",
43473
+ metadata: params.metadata,
43474
+ linkedAt: now2,
43475
+ lastSyncAt: now2
43476
+ };
43477
+ }
43478
+ async function touchLink(linkId, updates, cwd) {
43479
+ const db = await getDb(cwd);
43480
+ const now2 = (/* @__PURE__ */ new Date()).toISOString();
43481
+ const values = { lastSyncAt: now2 };
43482
+ if (updates?.externalTitle !== void 0) {
43483
+ values.externalTitle = updates.externalTitle;
43484
+ }
43485
+ if (updates?.metadata !== void 0) {
43486
+ values.metadataJson = JSON.stringify(updates.metadata);
43487
+ }
43488
+ await db.update(externalTaskLinks).set(values).where(eq8(externalTaskLinks.id, linkId));
43489
+ }
43490
+ async function removeLinksByProvider(providerId, cwd) {
43491
+ const db = await getDb(cwd);
43492
+ const result = await db.delete(externalTaskLinks).where(eq8(externalTaskLinks.providerId, providerId));
43493
+ return Number(result.changes);
43494
+ }
43495
+ function rowToLink(row) {
43496
+ return {
43497
+ id: row.id,
43498
+ taskId: row.taskId,
43499
+ providerId: row.providerId,
43500
+ externalId: row.externalId,
43501
+ externalUrl: row.externalUrl,
43502
+ externalTitle: row.externalTitle,
43503
+ linkType: row.linkType,
43504
+ syncDirection: row.syncDirection,
43505
+ metadata: row.metadataJson ? JSON.parse(row.metadataJson) : void 0,
43506
+ linkedAt: row.linkedAt,
43507
+ lastSyncAt: row.lastSyncAt
43508
+ };
43509
+ }
43510
+ var init_link_store = __esm({
43511
+ "packages/core/src/reconciliation/link-store.ts"() {
43512
+ "use strict";
43513
+ init_sqlite2();
43514
+ init_tasks_schema();
43515
+ }
43516
+ });
43517
+
43518
+ // packages/core/src/nexus/transfer.ts
43519
+ import { randomUUID as randomUUID5 } from "node:crypto";
43520
+ async function previewTransfer(params) {
43521
+ return executeTransferInternal({ ...params, dryRun: true });
43522
+ }
43523
+ async function executeTransfer(params) {
43524
+ return executeTransferInternal(params);
43525
+ }
43526
+ async function executeTransferInternal(params) {
43527
+ const {
43528
+ taskIds,
43529
+ sourceProject: sourceProjectRef,
43530
+ targetProject: targetProjectRef,
43531
+ mode = "copy",
43532
+ scope = "subtree",
43533
+ onConflict = "rename",
43534
+ onMissingDep = "strip",
43535
+ provenance = true,
43536
+ targetParent,
43537
+ transferBrain = false,
43538
+ dryRun = false
43539
+ } = params;
43540
+ if (!taskIds.length) {
43541
+ throw new Error("No task IDs specified for transfer");
43542
+ }
43543
+ const sourceProject = await nexusGetProject(sourceProjectRef);
43544
+ if (!sourceProject) {
43545
+ throw new Error(`Source project not found: ${sourceProjectRef}`);
43546
+ }
43547
+ const targetProject = await nexusGetProject(targetProjectRef);
43548
+ if (!targetProject) {
43549
+ throw new Error(`Target project not found: ${targetProjectRef}`);
43550
+ }
43551
+ if (sourceProject.hash === targetProject.hash) {
43552
+ throw new Error("Source and target projects must be different");
43553
+ }
43554
+ await requirePermission(sourceProject.hash, "read", "nexus.transfer");
43555
+ await requirePermission(targetProject.hash, "write", "nexus.transfer");
43556
+ const sourceAccessor = await getAccessor(sourceProject.path);
43557
+ const { tasks: allSourceTasks } = await sourceAccessor.queryTasks({});
43558
+ const exportPackages = [];
43559
+ for (const taskId of taskIds) {
43560
+ const pkg = scope === "subtree" ? exportSubtree(taskId, allSourceTasks, sourceProject.name) : exportSingle(taskId, allSourceTasks, sourceProject.name);
43561
+ if (!pkg) {
43562
+ throw new Error(`Task not found in source project: ${taskId}`);
43563
+ }
43564
+ exportPackages.push(pkg);
43565
+ }
43566
+ const seenIds = /* @__PURE__ */ new Set();
43567
+ const mergedTasks = [];
43568
+ for (const pkg of exportPackages) {
43569
+ for (const task of pkg.tasks) {
43570
+ if (!seenIds.has(task.id)) {
43571
+ seenIds.add(task.id);
43572
+ mergedTasks.push(task);
43573
+ }
43574
+ }
43575
+ }
43576
+ const mergedPkg = { ...exportPackages[0] };
43577
+ mergedPkg.tasks = mergedTasks;
43578
+ mergedPkg._meta = { ...mergedPkg._meta, taskCount: mergedTasks.length };
43579
+ const importResult = await importFromPackage(mergedPkg, {
43580
+ cwd: targetProject.path,
43581
+ dryRun,
43582
+ parent: targetParent,
43583
+ provenance,
43584
+ onConflict,
43585
+ onMissingDep
43586
+ });
43587
+ const entries = mergedTasks.map((t) => ({
43588
+ sourceId: t.id,
43589
+ targetId: importResult.idRemap[t.id] ?? t.id,
43590
+ title: t.title,
43591
+ type: t.type ?? "task"
43592
+ }));
43593
+ const manifest = {
43594
+ sourceProject: sourceProject.name,
43595
+ targetProject: targetProject.name,
43596
+ mode,
43597
+ scope,
43598
+ entries,
43599
+ idRemap: importResult.idRemap,
43600
+ brainObservationsTransferred: 0
43601
+ };
43602
+ const result = {
43603
+ dryRun,
43604
+ transferred: importResult.imported,
43605
+ skipped: importResult.skipped,
43606
+ archived: 0,
43607
+ linksCreated: 0,
43608
+ brainObservationsTransferred: 0,
43609
+ manifest
43610
+ };
43611
+ if (dryRun) {
43612
+ return result;
43613
+ }
43614
+ let linksCreated = 0;
43615
+ const targetAccessor = await getAccessor(targetProject.path);
43616
+ const { tasks: targetTasks } = await targetAccessor.queryTasks({});
43617
+ const targetTaskIds = new Set(targetTasks.map((t) => t.id));
43618
+ for (const entry of entries) {
43619
+ if (importResult.idRemap[entry.sourceId] && targetTaskIds.has(entry.targetId)) {
43620
+ await createLink(
43621
+ {
43622
+ taskId: entry.targetId,
43623
+ providerId: `nexus:${sourceProject.name}`,
43624
+ externalId: entry.sourceId,
43625
+ externalTitle: entry.title,
43626
+ linkType: "transferred",
43627
+ syncDirection: "inbound",
43628
+ metadata: {
43629
+ transferMode: mode,
43630
+ transferScope: scope,
43631
+ sourceProject: sourceProject.name,
43632
+ transferredAt: (/* @__PURE__ */ new Date()).toISOString()
43633
+ }
43634
+ },
43635
+ targetProject.path
43636
+ );
43637
+ linksCreated++;
43638
+ await createLink(
43639
+ {
43640
+ taskId: entry.sourceId,
43641
+ providerId: `nexus:${targetProject.name}`,
43642
+ externalId: entry.targetId,
43643
+ externalTitle: entry.title,
43644
+ linkType: "transferred",
43645
+ syncDirection: "outbound",
43646
+ metadata: {
43647
+ transferMode: mode,
43648
+ transferScope: scope,
43649
+ targetProject: targetProject.name,
43650
+ transferredAt: (/* @__PURE__ */ new Date()).toISOString()
43651
+ }
43652
+ },
43653
+ sourceProject.path
43654
+ );
43655
+ linksCreated++;
43656
+ }
43657
+ }
43658
+ result.linksCreated = linksCreated;
43659
+ try {
43660
+ const { getNexusDb: getNexusDb2 } = await Promise.resolve().then(() => (init_nexus_sqlite(), nexus_sqlite_exports));
43661
+ const { nexusAuditLog: nexusAuditLog2 } = await Promise.resolve().then(() => (init_nexus_schema(), nexus_schema_exports));
43662
+ const db = await getNexusDb2();
43663
+ await db.insert(nexusAuditLog2).values({
43664
+ id: randomUUID5(),
43665
+ action: "transfer",
43666
+ projectHash: sourceProject.hash,
43667
+ projectId: sourceProject.projectId,
43668
+ domain: "nexus",
43669
+ operation: "transfer",
43670
+ success: 1,
43671
+ detailsJson: JSON.stringify({
43672
+ sourceProject: sourceProject.name,
43673
+ targetProject: targetProject.name,
43674
+ mode,
43675
+ scope,
43676
+ taskCount: result.transferred,
43677
+ idRemap: importResult.idRemap
43678
+ })
43679
+ });
43680
+ } catch (err) {
43681
+ log6.warn({ err }, "nexus transfer audit write failed");
43682
+ }
43683
+ if (mode === "move") {
43684
+ let archived = 0;
43685
+ for (const entry of entries) {
43686
+ if (importResult.idRemap[entry.sourceId]) {
43687
+ try {
43688
+ await sourceAccessor.archiveSingleTask(entry.sourceId, {
43689
+ archivedAt: (/* @__PURE__ */ new Date()).toISOString(),
43690
+ archiveReason: `Transferred to ${targetProject.name} as ${entry.targetId}`
43691
+ });
43692
+ archived++;
43693
+ } catch (err) {
43694
+ log6.warn({ err, taskId: entry.sourceId }, "failed to archive source task after transfer");
43695
+ }
43696
+ }
43697
+ }
43698
+ result.archived = archived;
43699
+ }
43700
+ if (transferBrain) {
43701
+ let brainTransferred = 0;
43702
+ try {
43703
+ const sourceBrainDb = await getBrainDb(sourceProject.path);
43704
+ const targetBrainDb = await getBrainDb(targetProject.path);
43705
+ const sourceBrain = new BrainDataAccessor(sourceBrainDb);
43706
+ const targetBrain = new BrainDataAccessor(targetBrainDb);
43707
+ for (const entry of entries) {
43708
+ if (!importResult.idRemap[entry.sourceId]) continue;
43709
+ const links = await sourceBrain.getLinksForTask(entry.sourceId);
43710
+ for (const link of links) {
43711
+ if (link.memoryType !== "observation") continue;
43712
+ const observation = await sourceBrain.getObservation(link.memoryId);
43713
+ if (!observation) continue;
43714
+ const newObsId = `O-${randomUUID5().slice(0, 8)}`;
43715
+ await targetBrain.addObservation({
43716
+ ...observation,
43717
+ id: newObsId,
43718
+ createdAt: observation.createdAt,
43719
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19)
43720
+ });
43721
+ await targetBrain.addLink({
43722
+ memoryType: "observation",
43723
+ memoryId: newObsId,
43724
+ taskId: entry.targetId,
43725
+ linkType: "applies_to",
43726
+ createdAt: (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").slice(0, 19)
43727
+ });
43728
+ brainTransferred++;
43729
+ }
43730
+ }
43731
+ } catch (err) {
43732
+ log6.warn({ err }, "brain observation transfer failed");
43733
+ }
43734
+ result.brainObservationsTransferred = brainTransferred;
43735
+ result.manifest.brainObservationsTransferred = brainTransferred;
43736
+ }
43737
+ return result;
43738
+ }
43739
+ var log6;
43740
+ var init_transfer = __esm({
43741
+ "packages/core/src/nexus/transfer.ts"() {
43742
+ "use strict";
43743
+ init_import_tasks();
43744
+ init_logger();
43745
+ init_link_store();
43746
+ init_brain_accessor();
43747
+ init_brain_sqlite();
43748
+ init_data_accessor();
43749
+ init_export2();
43750
+ init_permissions();
43751
+ init_registry3();
43752
+ log6 = getLogger("nexus:transfer");
43753
+ }
43754
+ });
43755
+
43373
43756
  // packages/core/src/nexus/index.ts
43374
43757
  var nexus_exports = {};
43375
43758
  __export(nexus_exports, {
@@ -43382,6 +43765,7 @@ __export(nexus_exports, {
43382
43765
  checkPermissionDetail: () => checkPermissionDetail,
43383
43766
  criticalPath: () => criticalPath,
43384
43767
  discoverRelated: () => discoverRelated,
43768
+ executeTransfer: () => executeTransfer,
43385
43769
  extractKeywords: () => extractKeywords2,
43386
43770
  generateProjectHash: () => generateProjectHash,
43387
43771
  getCurrentProject: () => getCurrentProject,
@@ -43405,6 +43789,7 @@ __export(nexus_exports, {
43405
43789
  orphanDetection: () => orphanDetection,
43406
43790
  parseQuery: () => parseQuery,
43407
43791
  permissionLevel: () => permissionLevel,
43792
+ previewTransfer: () => previewTransfer,
43408
43793
  readRegistry: () => readRegistry,
43409
43794
  readRegistryRequired: () => readRegistryRequired,
43410
43795
  requirePermission: () => requirePermission,
@@ -43427,6 +43812,7 @@ var init_nexus = __esm({
43427
43812
  init_query3();
43428
43813
  init_registry3();
43429
43814
  init_sharing();
43815
+ init_transfer();
43430
43816
  }
43431
43817
  });
43432
43818
 
@@ -44927,100 +45313,6 @@ var init_pipeline = __esm({
44927
45313
  }
44928
45314
  });
44929
45315
 
44930
- // packages/core/src/reconciliation/link-store.ts
44931
- import { randomUUID as randomUUID4 } from "node:crypto";
44932
- import { and as and5, eq as eq8 } from "drizzle-orm";
44933
- async function getLinksByProvider(providerId, cwd) {
44934
- const db = await getDb(cwd);
44935
- const rows = await db.select().from(externalTaskLinks).where(eq8(externalTaskLinks.providerId, providerId));
44936
- return rows.map(rowToLink);
44937
- }
44938
- async function getLinkByExternalId(providerId, externalId, cwd) {
44939
- const db = await getDb(cwd);
44940
- const rows = await db.select().from(externalTaskLinks).where(
44941
- and5(
44942
- eq8(externalTaskLinks.providerId, providerId),
44943
- eq8(externalTaskLinks.externalId, externalId)
44944
- )
44945
- );
44946
- return rows.length > 0 ? rowToLink(rows[0]) : null;
44947
- }
44948
- async function getLinksByTaskId(taskId, cwd) {
44949
- const db = await getDb(cwd);
44950
- const rows = await db.select().from(externalTaskLinks).where(eq8(externalTaskLinks.taskId, taskId));
44951
- return rows.map(rowToLink);
44952
- }
44953
- async function createLink(params, cwd) {
44954
- const db = await getDb(cwd);
44955
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
44956
- const id = randomUUID4();
44957
- await db.insert(externalTaskLinks).values({
44958
- id,
44959
- taskId: params.taskId,
44960
- providerId: params.providerId,
44961
- externalId: params.externalId,
44962
- externalUrl: params.externalUrl ?? null,
44963
- externalTitle: params.externalTitle ?? null,
44964
- linkType: params.linkType,
44965
- syncDirection: params.syncDirection ?? "inbound",
44966
- metadataJson: params.metadata ? JSON.stringify(params.metadata) : "{}",
44967
- linkedAt: now2,
44968
- lastSyncAt: now2
44969
- });
44970
- return {
44971
- id,
44972
- taskId: params.taskId,
44973
- providerId: params.providerId,
44974
- externalId: params.externalId,
44975
- externalUrl: params.externalUrl ?? null,
44976
- externalTitle: params.externalTitle ?? null,
44977
- linkType: params.linkType,
44978
- syncDirection: params.syncDirection ?? "inbound",
44979
- metadata: params.metadata,
44980
- linkedAt: now2,
44981
- lastSyncAt: now2
44982
- };
44983
- }
44984
- async function touchLink(linkId, updates, cwd) {
44985
- const db = await getDb(cwd);
44986
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
44987
- const values = { lastSyncAt: now2 };
44988
- if (updates?.externalTitle !== void 0) {
44989
- values.externalTitle = updates.externalTitle;
44990
- }
44991
- if (updates?.metadata !== void 0) {
44992
- values.metadataJson = JSON.stringify(updates.metadata);
44993
- }
44994
- await db.update(externalTaskLinks).set(values).where(eq8(externalTaskLinks.id, linkId));
44995
- }
44996
- async function removeLinksByProvider(providerId, cwd) {
44997
- const db = await getDb(cwd);
44998
- const result = await db.delete(externalTaskLinks).where(eq8(externalTaskLinks.providerId, providerId));
44999
- return Number(result.changes);
45000
- }
45001
- function rowToLink(row) {
45002
- return {
45003
- id: row.id,
45004
- taskId: row.taskId,
45005
- providerId: row.providerId,
45006
- externalId: row.externalId,
45007
- externalUrl: row.externalUrl,
45008
- externalTitle: row.externalTitle,
45009
- linkType: row.linkType,
45010
- syncDirection: row.syncDirection,
45011
- metadata: row.metadataJson ? JSON.parse(row.metadataJson) : void 0,
45012
- linkedAt: row.linkedAt,
45013
- lastSyncAt: row.lastSyncAt
45014
- };
45015
- }
45016
- var init_link_store = __esm({
45017
- "packages/core/src/reconciliation/link-store.ts"() {
45018
- "use strict";
45019
- init_sqlite2();
45020
- init_tasks_schema();
45021
- }
45022
- });
45023
-
45024
45316
  // packages/core/src/memory/auto-extract.ts
45025
45317
  var auto_extract_exports = {};
45026
45318
  __export(auto_extract_exports, {
@@ -46587,8 +46879,8 @@ var init_release_config = __esm({
46587
46879
  // packages/core/src/release/ci.ts
46588
46880
  import { existsSync as existsSync60, mkdirSync as mkdirSync12, readFileSync as readFileSync42, writeFileSync as writeFileSync6 } from "node:fs";
46589
46881
  import { dirname as dirname13, join as join63 } from "node:path";
46590
- function getPlatformPath(platform3) {
46591
- return PLATFORM_PATHS[platform3];
46882
+ function getPlatformPath(platform5) {
46883
+ return PLATFORM_PATHS[platform5];
46592
46884
  }
46593
46885
  function detectCIPlatform(projectDir) {
46594
46886
  const dir = projectDir ?? process.cwd();
@@ -46682,10 +46974,10 @@ workflows:
46682
46974
  only: /^v.*/
46683
46975
  `;
46684
46976
  }
46685
- function generateCIConfig(platform3, cwd) {
46977
+ function generateCIConfig(platform5, cwd) {
46686
46978
  const releaseConfig = loadReleaseConfig(cwd);
46687
46979
  const gates = releaseConfig.gates.map((g) => ({ name: g.name, command: g.command }));
46688
- switch (platform3) {
46980
+ switch (platform5) {
46689
46981
  case "github-actions":
46690
46982
  return generateGitHubActions({ gates });
46691
46983
  case "gitlab-ci":
@@ -46694,10 +46986,10 @@ function generateCIConfig(platform3, cwd) {
46694
46986
  return generateCircleCI({ gates });
46695
46987
  }
46696
46988
  }
46697
- function writeCIConfig(platform3, options = {}) {
46989
+ function writeCIConfig(platform5, options = {}) {
46698
46990
  const projectDir = options.projectDir ?? process.cwd();
46699
- const outputPath = join63(projectDir, getPlatformPath(platform3));
46700
- const content = generateCIConfig(platform3, projectDir);
46991
+ const outputPath = join63(projectDir, getPlatformPath(platform5));
46992
+ const content = generateCIConfig(platform5, projectDir);
46701
46993
  if (options.dryRun) {
46702
46994
  return { action: "would_write", path: outputPath, content };
46703
46995
  }
@@ -46705,9 +46997,9 @@ function writeCIConfig(platform3, options = {}) {
46705
46997
  writeFileSync6(outputPath, content, "utf-8");
46706
46998
  return { action: "wrote", path: outputPath, content };
46707
46999
  }
46708
- function validateCIConfig(platform3, projectDir) {
47000
+ function validateCIConfig(platform5, projectDir) {
46709
47001
  const dir = projectDir ?? process.cwd();
46710
- const configPath = join63(dir, getPlatformPath(platform3));
47002
+ const configPath = join63(dir, getPlatformPath(platform5));
46711
47003
  if (!existsSync60(configPath)) {
46712
47004
  return { valid: false, exists: false, errors: ["Config file not found"] };
46713
47005
  }
@@ -48410,239 +48702,1463 @@ var init_capability_matrix = __esm({
48410
48702
  CAPABILITY_MATRIX = [
48411
48703
  // === Tasks Domain ===
48412
48704
  // Query operations
48413
- { domain: "tasks", operation: "show", gateway: "query", mode: "native" },
48414
- { domain: "tasks", operation: "list", gateway: "query", mode: "native" },
48415
- { domain: "tasks", operation: "find", gateway: "query", mode: "native" },
48416
- { domain: "tasks", operation: "tree", gateway: "query", mode: "native" },
48417
- { domain: "tasks", operation: "blockers", gateway: "query", mode: "native" },
48418
- { domain: "tasks", operation: "depends", gateway: "query", mode: "native" },
48419
- { domain: "tasks", operation: "analyze", gateway: "query", mode: "native" },
48420
- { domain: "tasks", operation: "next", gateway: "query", mode: "native" },
48421
- { domain: "tasks", operation: "plan", gateway: "query", mode: "native" },
48422
- { domain: "tasks", operation: "relates", gateway: "query", mode: "native" },
48423
- { domain: "tasks", operation: "complexity.estimate", gateway: "query", mode: "native" },
48424
- { domain: "tasks", operation: "history", gateway: "query", mode: "native" },
48425
- { domain: "tasks", operation: "current", gateway: "query", mode: "native" },
48426
- { domain: "tasks", operation: "label.list", gateway: "query", mode: "native" },
48705
+ { domain: "tasks", operation: "show", gateway: "query", mode: "native", preferredChannel: "mcp" },
48706
+ { domain: "tasks", operation: "list", gateway: "query", mode: "native", preferredChannel: "mcp" },
48707
+ { domain: "tasks", operation: "find", gateway: "query", mode: "native", preferredChannel: "mcp" },
48708
+ {
48709
+ domain: "tasks",
48710
+ operation: "tree",
48711
+ gateway: "query",
48712
+ mode: "native",
48713
+ preferredChannel: "either"
48714
+ },
48715
+ {
48716
+ domain: "tasks",
48717
+ operation: "blockers",
48718
+ gateway: "query",
48719
+ mode: "native",
48720
+ preferredChannel: "either"
48721
+ },
48722
+ {
48723
+ domain: "tasks",
48724
+ operation: "depends",
48725
+ gateway: "query",
48726
+ mode: "native",
48727
+ preferredChannel: "either"
48728
+ },
48729
+ {
48730
+ domain: "tasks",
48731
+ operation: "analyze",
48732
+ gateway: "query",
48733
+ mode: "native",
48734
+ preferredChannel: "either"
48735
+ },
48736
+ { domain: "tasks", operation: "next", gateway: "query", mode: "native", preferredChannel: "mcp" },
48737
+ { domain: "tasks", operation: "plan", gateway: "query", mode: "native", preferredChannel: "mcp" },
48738
+ {
48739
+ domain: "tasks",
48740
+ operation: "relates",
48741
+ gateway: "query",
48742
+ mode: "native",
48743
+ preferredChannel: "either"
48744
+ },
48745
+ {
48746
+ domain: "tasks",
48747
+ operation: "complexity.estimate",
48748
+ gateway: "query",
48749
+ mode: "native",
48750
+ preferredChannel: "either"
48751
+ },
48752
+ {
48753
+ domain: "tasks",
48754
+ operation: "history",
48755
+ gateway: "query",
48756
+ mode: "native",
48757
+ preferredChannel: "either"
48758
+ },
48759
+ {
48760
+ domain: "tasks",
48761
+ operation: "current",
48762
+ gateway: "query",
48763
+ mode: "native",
48764
+ preferredChannel: "mcp"
48765
+ },
48766
+ {
48767
+ domain: "tasks",
48768
+ operation: "label.list",
48769
+ gateway: "query",
48770
+ mode: "native",
48771
+ preferredChannel: "either"
48772
+ },
48427
48773
  // Mutate operations
48428
- { domain: "tasks", operation: "add", gateway: "mutate", mode: "native" },
48429
- { domain: "tasks", operation: "update", gateway: "mutate", mode: "native" },
48430
- { domain: "tasks", operation: "complete", gateway: "mutate", mode: "native" },
48431
- { domain: "tasks", operation: "cancel", gateway: "mutate", mode: "native" },
48432
- { domain: "tasks", operation: "delete", gateway: "mutate", mode: "native" },
48433
- { domain: "tasks", operation: "archive", gateway: "mutate", mode: "native" },
48434
- { domain: "tasks", operation: "restore", gateway: "mutate", mode: "native" },
48435
- { domain: "tasks", operation: "reparent", gateway: "mutate", mode: "native" },
48436
- { domain: "tasks", operation: "reorder", gateway: "mutate", mode: "native" },
48437
- { domain: "tasks", operation: "relates.add", gateway: "mutate", mode: "native" },
48438
- { domain: "tasks", operation: "start", gateway: "mutate", mode: "native" },
48439
- { domain: "tasks", operation: "stop", gateway: "mutate", mode: "native" },
48774
+ { domain: "tasks", operation: "add", gateway: "mutate", mode: "native", preferredChannel: "mcp" },
48775
+ {
48776
+ domain: "tasks",
48777
+ operation: "update",
48778
+ gateway: "mutate",
48779
+ mode: "native",
48780
+ preferredChannel: "mcp"
48781
+ },
48782
+ {
48783
+ domain: "tasks",
48784
+ operation: "complete",
48785
+ gateway: "mutate",
48786
+ mode: "native",
48787
+ preferredChannel: "mcp"
48788
+ },
48789
+ {
48790
+ domain: "tasks",
48791
+ operation: "cancel",
48792
+ gateway: "mutate",
48793
+ mode: "native",
48794
+ preferredChannel: "either"
48795
+ },
48796
+ {
48797
+ domain: "tasks",
48798
+ operation: "delete",
48799
+ gateway: "mutate",
48800
+ mode: "native",
48801
+ preferredChannel: "either"
48802
+ },
48803
+ {
48804
+ domain: "tasks",
48805
+ operation: "archive",
48806
+ gateway: "mutate",
48807
+ mode: "native",
48808
+ preferredChannel: "either"
48809
+ },
48810
+ {
48811
+ domain: "tasks",
48812
+ operation: "restore",
48813
+ gateway: "mutate",
48814
+ mode: "native",
48815
+ preferredChannel: "either"
48816
+ },
48817
+ {
48818
+ domain: "tasks",
48819
+ operation: "reparent",
48820
+ gateway: "mutate",
48821
+ mode: "native",
48822
+ preferredChannel: "either"
48823
+ },
48824
+ {
48825
+ domain: "tasks",
48826
+ operation: "reorder",
48827
+ gateway: "mutate",
48828
+ mode: "native",
48829
+ preferredChannel: "either"
48830
+ },
48831
+ {
48832
+ domain: "tasks",
48833
+ operation: "relates.add",
48834
+ gateway: "mutate",
48835
+ mode: "native",
48836
+ preferredChannel: "either"
48837
+ },
48838
+ {
48839
+ domain: "tasks",
48840
+ operation: "start",
48841
+ gateway: "mutate",
48842
+ mode: "native",
48843
+ preferredChannel: "mcp"
48844
+ },
48845
+ {
48846
+ domain: "tasks",
48847
+ operation: "stop",
48848
+ gateway: "mutate",
48849
+ mode: "native",
48850
+ preferredChannel: "mcp"
48851
+ },
48440
48852
  // Sync sub-domain (provider-agnostic task reconciliation)
48441
- { domain: "tasks", operation: "sync.reconcile", gateway: "mutate", mode: "native" },
48442
- { domain: "tasks", operation: "sync.links", gateway: "query", mode: "native" },
48443
- { domain: "tasks", operation: "sync.links.remove", gateway: "mutate", mode: "native" },
48853
+ {
48854
+ domain: "tasks",
48855
+ operation: "sync.reconcile",
48856
+ gateway: "mutate",
48857
+ mode: "native",
48858
+ preferredChannel: "either"
48859
+ },
48860
+ {
48861
+ domain: "tasks",
48862
+ operation: "sync.links",
48863
+ gateway: "query",
48864
+ mode: "native",
48865
+ preferredChannel: "either"
48866
+ },
48867
+ {
48868
+ domain: "tasks",
48869
+ operation: "sync.links.remove",
48870
+ gateway: "mutate",
48871
+ mode: "native",
48872
+ preferredChannel: "either"
48873
+ },
48444
48874
  // === Session Domain ===
48445
48875
  // Query operations
48446
- { domain: "session", operation: "status", gateway: "query", mode: "native" },
48447
- { domain: "session", operation: "list", gateway: "query", mode: "native" },
48448
- { domain: "session", operation: "show", gateway: "query", mode: "native" },
48449
- { domain: "session", operation: "decision.log", gateway: "query", mode: "native" },
48450
- { domain: "session", operation: "context.drift", gateway: "query", mode: "native" },
48451
- { domain: "session", operation: "handoff.show", gateway: "query", mode: "native" },
48452
- { domain: "session", operation: "briefing.show", gateway: "query", mode: "native" },
48453
- { domain: "session", operation: "find", gateway: "query", mode: "native" },
48876
+ {
48877
+ domain: "session",
48878
+ operation: "status",
48879
+ gateway: "query",
48880
+ mode: "native",
48881
+ preferredChannel: "mcp"
48882
+ },
48883
+ {
48884
+ domain: "session",
48885
+ operation: "list",
48886
+ gateway: "query",
48887
+ mode: "native",
48888
+ preferredChannel: "either"
48889
+ },
48890
+ {
48891
+ domain: "session",
48892
+ operation: "show",
48893
+ gateway: "query",
48894
+ mode: "native",
48895
+ preferredChannel: "either"
48896
+ },
48897
+ {
48898
+ domain: "session",
48899
+ operation: "decision.log",
48900
+ gateway: "query",
48901
+ mode: "native",
48902
+ preferredChannel: "either"
48903
+ },
48904
+ {
48905
+ domain: "session",
48906
+ operation: "context.drift",
48907
+ gateway: "query",
48908
+ mode: "native",
48909
+ preferredChannel: "either"
48910
+ },
48911
+ {
48912
+ domain: "session",
48913
+ operation: "handoff.show",
48914
+ gateway: "query",
48915
+ mode: "native",
48916
+ preferredChannel: "mcp"
48917
+ },
48918
+ {
48919
+ domain: "session",
48920
+ operation: "briefing.show",
48921
+ gateway: "query",
48922
+ mode: "native",
48923
+ preferredChannel: "mcp"
48924
+ },
48925
+ {
48926
+ domain: "session",
48927
+ operation: "find",
48928
+ gateway: "query",
48929
+ mode: "native",
48930
+ preferredChannel: "either"
48931
+ },
48454
48932
  // Mutate operations
48455
- { domain: "session", operation: "start", gateway: "mutate", mode: "native" },
48456
- { domain: "session", operation: "end", gateway: "mutate", mode: "native" },
48457
- { domain: "session", operation: "resume", gateway: "mutate", mode: "native" },
48458
- { domain: "session", operation: "suspend", gateway: "mutate", mode: "native" },
48459
- { domain: "session", operation: "gc", gateway: "mutate", mode: "native" },
48460
- { domain: "session", operation: "record.decision", gateway: "mutate", mode: "native" },
48461
- { domain: "session", operation: "record.assumption", gateway: "mutate", mode: "native" },
48933
+ {
48934
+ domain: "session",
48935
+ operation: "start",
48936
+ gateway: "mutate",
48937
+ mode: "native",
48938
+ preferredChannel: "mcp"
48939
+ },
48940
+ {
48941
+ domain: "session",
48942
+ operation: "end",
48943
+ gateway: "mutate",
48944
+ mode: "native",
48945
+ preferredChannel: "mcp"
48946
+ },
48947
+ {
48948
+ domain: "session",
48949
+ operation: "resume",
48950
+ gateway: "mutate",
48951
+ mode: "native",
48952
+ preferredChannel: "either"
48953
+ },
48954
+ {
48955
+ domain: "session",
48956
+ operation: "suspend",
48957
+ gateway: "mutate",
48958
+ mode: "native",
48959
+ preferredChannel: "either"
48960
+ },
48961
+ {
48962
+ domain: "session",
48963
+ operation: "gc",
48964
+ gateway: "mutate",
48965
+ mode: "native",
48966
+ preferredChannel: "either"
48967
+ },
48968
+ {
48969
+ domain: "session",
48970
+ operation: "record.decision",
48971
+ gateway: "mutate",
48972
+ mode: "native",
48973
+ preferredChannel: "either"
48974
+ },
48975
+ {
48976
+ domain: "session",
48977
+ operation: "record.assumption",
48978
+ gateway: "mutate",
48979
+ mode: "native",
48980
+ preferredChannel: "either"
48981
+ },
48462
48982
  // === Admin Domain ===
48463
48983
  // Query operations
48464
- { domain: "admin", operation: "version", gateway: "query", mode: "native" },
48465
- { domain: "admin", operation: "health", gateway: "query", mode: "native" },
48466
- { domain: "admin", operation: "config.show", gateway: "query", mode: "native" },
48467
- { domain: "admin", operation: "stats", gateway: "query", mode: "native" },
48468
- { domain: "admin", operation: "context", gateway: "query", mode: "native" },
48469
- { domain: "admin", operation: "runtime", gateway: "query", mode: "native" },
48470
- { domain: "admin", operation: "job", gateway: "query", mode: "native" },
48471
- { domain: "admin", operation: "dash", gateway: "query", mode: "native" },
48472
- { domain: "admin", operation: "log", gateway: "query", mode: "native" },
48473
- { domain: "admin", operation: "sequence", gateway: "query", mode: "native" },
48474
- { domain: "admin", operation: "help", gateway: "query", mode: "native" },
48475
- { domain: "admin", operation: "token", gateway: "query", mode: "native" },
48476
- { domain: "admin", operation: "export", gateway: "query", mode: "native" },
48477
- { domain: "admin", operation: "adr.show", gateway: "query", mode: "native" },
48478
- { domain: "admin", operation: "adr.find", gateway: "query", mode: "native" },
48984
+ {
48985
+ domain: "admin",
48986
+ operation: "version",
48987
+ gateway: "query",
48988
+ mode: "native",
48989
+ preferredChannel: "either"
48990
+ },
48991
+ {
48992
+ domain: "admin",
48993
+ operation: "health",
48994
+ gateway: "query",
48995
+ mode: "native",
48996
+ preferredChannel: "either"
48997
+ },
48998
+ {
48999
+ domain: "admin",
49000
+ operation: "config.show",
49001
+ gateway: "query",
49002
+ mode: "native",
49003
+ preferredChannel: "either"
49004
+ },
49005
+ {
49006
+ domain: "admin",
49007
+ operation: "stats",
49008
+ gateway: "query",
49009
+ mode: "native",
49010
+ preferredChannel: "either"
49011
+ },
49012
+ {
49013
+ domain: "admin",
49014
+ operation: "context",
49015
+ gateway: "query",
49016
+ mode: "native",
49017
+ preferredChannel: "either"
49018
+ },
49019
+ {
49020
+ domain: "admin",
49021
+ operation: "runtime",
49022
+ gateway: "query",
49023
+ mode: "native",
49024
+ preferredChannel: "either"
49025
+ },
49026
+ {
49027
+ domain: "admin",
49028
+ operation: "job",
49029
+ gateway: "query",
49030
+ mode: "native",
49031
+ preferredChannel: "either"
49032
+ },
49033
+ { domain: "admin", operation: "dash", gateway: "query", mode: "native", preferredChannel: "mcp" },
49034
+ {
49035
+ domain: "admin",
49036
+ operation: "log",
49037
+ gateway: "query",
49038
+ mode: "native",
49039
+ preferredChannel: "either"
49040
+ },
49041
+ {
49042
+ domain: "admin",
49043
+ operation: "sequence",
49044
+ gateway: "query",
49045
+ mode: "native",
49046
+ preferredChannel: "either"
49047
+ },
49048
+ { domain: "admin", operation: "help", gateway: "query", mode: "native", preferredChannel: "mcp" },
49049
+ {
49050
+ domain: "admin",
49051
+ operation: "token",
49052
+ gateway: "query",
49053
+ mode: "native",
49054
+ preferredChannel: "either"
49055
+ },
49056
+ {
49057
+ domain: "admin",
49058
+ operation: "export",
49059
+ gateway: "query",
49060
+ mode: "native",
49061
+ preferredChannel: "either"
49062
+ },
49063
+ {
49064
+ domain: "admin",
49065
+ operation: "adr.show",
49066
+ gateway: "query",
49067
+ mode: "native",
49068
+ preferredChannel: "either"
49069
+ },
49070
+ {
49071
+ domain: "admin",
49072
+ operation: "adr.find",
49073
+ gateway: "query",
49074
+ mode: "native",
49075
+ preferredChannel: "either"
49076
+ },
49077
+ { domain: "admin", operation: "map", gateway: "query", mode: "native", preferredChannel: "mcp" },
48479
49078
  // Mutate operations
48480
- { domain: "admin", operation: "init", gateway: "mutate", mode: "native" },
48481
- { domain: "admin", operation: "config.set", gateway: "mutate", mode: "native" },
48482
- { domain: "admin", operation: "backup", gateway: "mutate", mode: "native" },
48483
- { domain: "admin", operation: "migrate", gateway: "mutate", mode: "native" },
48484
- { domain: "admin", operation: "cleanup", gateway: "mutate", mode: "native" },
48485
- { domain: "admin", operation: "safestop", gateway: "mutate", mode: "native" },
48486
- { domain: "admin", operation: "inject.generate", gateway: "mutate", mode: "native" },
48487
- { domain: "admin", operation: "job.cancel", gateway: "mutate", mode: "native" },
48488
- { domain: "admin", operation: "install.global", gateway: "mutate", mode: "native" },
48489
- { domain: "admin", operation: "token", gateway: "mutate", mode: "native" },
48490
- { domain: "admin", operation: "health", gateway: "mutate", mode: "native" },
48491
- { domain: "admin", operation: "detect", gateway: "mutate", mode: "native" },
48492
- { domain: "admin", operation: "import", gateway: "mutate", mode: "native" },
48493
- { domain: "admin", operation: "context.inject", gateway: "mutate", mode: "native" },
48494
- { domain: "admin", operation: "adr.sync", gateway: "mutate", mode: "native" },
49079
+ {
49080
+ domain: "admin",
49081
+ operation: "init",
49082
+ gateway: "mutate",
49083
+ mode: "native",
49084
+ preferredChannel: "either"
49085
+ },
49086
+ {
49087
+ domain: "admin",
49088
+ operation: "config.set",
49089
+ gateway: "mutate",
49090
+ mode: "native",
49091
+ preferredChannel: "either"
49092
+ },
49093
+ {
49094
+ domain: "admin",
49095
+ operation: "backup",
49096
+ gateway: "mutate",
49097
+ mode: "native",
49098
+ preferredChannel: "either"
49099
+ },
49100
+ {
49101
+ domain: "admin",
49102
+ operation: "migrate",
49103
+ gateway: "mutate",
49104
+ mode: "native",
49105
+ preferredChannel: "either"
49106
+ },
49107
+ {
49108
+ domain: "admin",
49109
+ operation: "cleanup",
49110
+ gateway: "mutate",
49111
+ mode: "native",
49112
+ preferredChannel: "either"
49113
+ },
49114
+ {
49115
+ domain: "admin",
49116
+ operation: "safestop",
49117
+ gateway: "mutate",
49118
+ mode: "native",
49119
+ preferredChannel: "either"
49120
+ },
49121
+ {
49122
+ domain: "admin",
49123
+ operation: "inject.generate",
49124
+ gateway: "mutate",
49125
+ mode: "native",
49126
+ preferredChannel: "either"
49127
+ },
49128
+ {
49129
+ domain: "admin",
49130
+ operation: "job.cancel",
49131
+ gateway: "mutate",
49132
+ mode: "native",
49133
+ preferredChannel: "either"
49134
+ },
49135
+ {
49136
+ domain: "admin",
49137
+ operation: "install.global",
49138
+ gateway: "mutate",
49139
+ mode: "native",
49140
+ preferredChannel: "either"
49141
+ },
49142
+ {
49143
+ domain: "admin",
49144
+ operation: "token",
49145
+ gateway: "mutate",
49146
+ mode: "native",
49147
+ preferredChannel: "either"
49148
+ },
49149
+ {
49150
+ domain: "admin",
49151
+ operation: "health",
49152
+ gateway: "mutate",
49153
+ mode: "native",
49154
+ preferredChannel: "either"
49155
+ },
49156
+ {
49157
+ domain: "admin",
49158
+ operation: "detect",
49159
+ gateway: "mutate",
49160
+ mode: "native",
49161
+ preferredChannel: "either"
49162
+ },
49163
+ {
49164
+ domain: "admin",
49165
+ operation: "import",
49166
+ gateway: "mutate",
49167
+ mode: "native",
49168
+ preferredChannel: "either"
49169
+ },
49170
+ {
49171
+ domain: "admin",
49172
+ operation: "context.inject",
49173
+ gateway: "mutate",
49174
+ mode: "native",
49175
+ preferredChannel: "either"
49176
+ },
49177
+ {
49178
+ domain: "admin",
49179
+ operation: "adr.sync",
49180
+ gateway: "mutate",
49181
+ mode: "native",
49182
+ preferredChannel: "either"
49183
+ },
49184
+ {
49185
+ domain: "admin",
49186
+ operation: "map",
49187
+ gateway: "mutate",
49188
+ mode: "native",
49189
+ preferredChannel: "either"
49190
+ },
48495
49191
  // === Check Domain ===
48496
49192
  // Query operations
48497
- { domain: "check", operation: "schema", gateway: "query", mode: "native" },
48498
- { domain: "check", operation: "protocol", gateway: "query", mode: "native" },
48499
- { domain: "check", operation: "task", gateway: "query", mode: "native" },
48500
- { domain: "check", operation: "manifest", gateway: "query", mode: "native" },
48501
- { domain: "check", operation: "output", gateway: "query", mode: "native" },
48502
- { domain: "check", operation: "compliance.summary", gateway: "query", mode: "native" },
48503
- { domain: "check", operation: "test", gateway: "query", mode: "native" },
48504
- { domain: "check", operation: "coherence", gateway: "query", mode: "native" },
48505
- { domain: "check", operation: "gate.status", gateway: "query", mode: "native" },
48506
- { domain: "check", operation: "archive.stats", gateway: "query", mode: "native" },
48507
- { domain: "check", operation: "grade", gateway: "query", mode: "native" },
48508
- { domain: "check", operation: "grade.list", gateway: "query", mode: "native" },
48509
- { domain: "check", operation: "chain.validate", gateway: "query", mode: "native" },
49193
+ {
49194
+ domain: "check",
49195
+ operation: "schema",
49196
+ gateway: "query",
49197
+ mode: "native",
49198
+ preferredChannel: "either"
49199
+ },
49200
+ {
49201
+ domain: "check",
49202
+ operation: "protocol",
49203
+ gateway: "query",
49204
+ mode: "native",
49205
+ preferredChannel: "either"
49206
+ },
49207
+ {
49208
+ domain: "check",
49209
+ operation: "task",
49210
+ gateway: "query",
49211
+ mode: "native",
49212
+ preferredChannel: "either"
49213
+ },
49214
+ {
49215
+ domain: "check",
49216
+ operation: "manifest",
49217
+ gateway: "query",
49218
+ mode: "native",
49219
+ preferredChannel: "either"
49220
+ },
49221
+ {
49222
+ domain: "check",
49223
+ operation: "output",
49224
+ gateway: "query",
49225
+ mode: "native",
49226
+ preferredChannel: "either"
49227
+ },
49228
+ {
49229
+ domain: "check",
49230
+ operation: "compliance.summary",
49231
+ gateway: "query",
49232
+ mode: "native",
49233
+ preferredChannel: "mcp"
49234
+ },
49235
+ {
49236
+ domain: "check",
49237
+ operation: "test",
49238
+ gateway: "query",
49239
+ mode: "native",
49240
+ preferredChannel: "either"
49241
+ },
49242
+ {
49243
+ domain: "check",
49244
+ operation: "coherence",
49245
+ gateway: "query",
49246
+ mode: "native",
49247
+ preferredChannel: "either"
49248
+ },
49249
+ {
49250
+ domain: "check",
49251
+ operation: "gate.status",
49252
+ gateway: "query",
49253
+ mode: "native",
49254
+ preferredChannel: "either"
49255
+ },
49256
+ {
49257
+ domain: "check",
49258
+ operation: "archive.stats",
49259
+ gateway: "query",
49260
+ mode: "native",
49261
+ preferredChannel: "either"
49262
+ },
49263
+ {
49264
+ domain: "check",
49265
+ operation: "grade",
49266
+ gateway: "query",
49267
+ mode: "native",
49268
+ preferredChannel: "either"
49269
+ },
49270
+ {
49271
+ domain: "check",
49272
+ operation: "grade.list",
49273
+ gateway: "query",
49274
+ mode: "native",
49275
+ preferredChannel: "either"
49276
+ },
49277
+ {
49278
+ domain: "check",
49279
+ operation: "chain.validate",
49280
+ gateway: "query",
49281
+ mode: "native",
49282
+ preferredChannel: "either"
49283
+ },
48510
49284
  // Mutate operations
48511
- { domain: "check", operation: "compliance.record", gateway: "mutate", mode: "native" },
48512
- { domain: "check", operation: "test.run", gateway: "mutate", mode: "native" },
48513
- { domain: "check", operation: "gate.set", gateway: "mutate", mode: "native" },
49285
+ {
49286
+ domain: "check",
49287
+ operation: "compliance.record",
49288
+ gateway: "mutate",
49289
+ mode: "native",
49290
+ preferredChannel: "mcp"
49291
+ },
49292
+ {
49293
+ domain: "check",
49294
+ operation: "test.run",
49295
+ gateway: "mutate",
49296
+ mode: "native",
49297
+ preferredChannel: "either"
49298
+ },
49299
+ {
49300
+ domain: "check",
49301
+ operation: "gate.set",
49302
+ gateway: "mutate",
49303
+ mode: "native",
49304
+ preferredChannel: "either"
49305
+ },
49306
+ {
49307
+ domain: "check",
49308
+ operation: "compliance.sync",
49309
+ gateway: "mutate",
49310
+ mode: "native",
49311
+ preferredChannel: "either"
49312
+ },
48514
49313
  // === Orchestrate Domain ===
48515
49314
  // Query operations
48516
- { domain: "orchestrate", operation: "status", gateway: "query", mode: "native" },
48517
- { domain: "orchestrate", operation: "next", gateway: "query", mode: "native" },
48518
- { domain: "orchestrate", operation: "ready", gateway: "query", mode: "native" },
48519
- { domain: "orchestrate", operation: "analyze", gateway: "query", mode: "native" },
48520
- { domain: "orchestrate", operation: "context", gateway: "query", mode: "native" },
48521
- { domain: "orchestrate", operation: "waves", gateway: "query", mode: "native" },
48522
- { domain: "orchestrate", operation: "bootstrap", gateway: "query", mode: "native" },
48523
- { domain: "orchestrate", operation: "unblock.opportunities", gateway: "query", mode: "native" },
48524
- { domain: "orchestrate", operation: "tessera.list", gateway: "query", mode: "native" },
49315
+ {
49316
+ domain: "orchestrate",
49317
+ operation: "status",
49318
+ gateway: "query",
49319
+ mode: "native",
49320
+ preferredChannel: "either"
49321
+ },
49322
+ {
49323
+ domain: "orchestrate",
49324
+ operation: "next",
49325
+ gateway: "query",
49326
+ mode: "native",
49327
+ preferredChannel: "either"
49328
+ },
49329
+ {
49330
+ domain: "orchestrate",
49331
+ operation: "ready",
49332
+ gateway: "query",
49333
+ mode: "native",
49334
+ preferredChannel: "either"
49335
+ },
49336
+ {
49337
+ domain: "orchestrate",
49338
+ operation: "analyze",
49339
+ gateway: "query",
49340
+ mode: "native",
49341
+ preferredChannel: "either"
49342
+ },
49343
+ {
49344
+ domain: "orchestrate",
49345
+ operation: "context",
49346
+ gateway: "query",
49347
+ mode: "native",
49348
+ preferredChannel: "either"
49349
+ },
49350
+ {
49351
+ domain: "orchestrate",
49352
+ operation: "waves",
49353
+ gateway: "query",
49354
+ mode: "native",
49355
+ preferredChannel: "either"
49356
+ },
49357
+ {
49358
+ domain: "orchestrate",
49359
+ operation: "bootstrap",
49360
+ gateway: "query",
49361
+ mode: "native",
49362
+ preferredChannel: "either"
49363
+ },
49364
+ {
49365
+ domain: "orchestrate",
49366
+ operation: "unblock.opportunities",
49367
+ gateway: "query",
49368
+ mode: "native",
49369
+ preferredChannel: "either"
49370
+ },
49371
+ {
49372
+ domain: "orchestrate",
49373
+ operation: "tessera.list",
49374
+ gateway: "query",
49375
+ mode: "native",
49376
+ preferredChannel: "either"
49377
+ },
48525
49378
  // Mutate operations
48526
- { domain: "orchestrate", operation: "start", gateway: "mutate", mode: "native" },
48527
- { domain: "orchestrate", operation: "spawn", gateway: "mutate", mode: "native" },
48528
- { domain: "orchestrate", operation: "handoff", gateway: "mutate", mode: "native" },
48529
- { domain: "orchestrate", operation: "spawn.execute", gateway: "mutate", mode: "native" },
48530
- { domain: "orchestrate", operation: "validate", gateway: "mutate", mode: "native" },
48531
- { domain: "orchestrate", operation: "parallel", gateway: "mutate", mode: "native" },
48532
- { domain: "orchestrate", operation: "tessera.instantiate", gateway: "mutate", mode: "native" },
49379
+ {
49380
+ domain: "orchestrate",
49381
+ operation: "start",
49382
+ gateway: "mutate",
49383
+ mode: "native",
49384
+ preferredChannel: "either"
49385
+ },
49386
+ {
49387
+ domain: "orchestrate",
49388
+ operation: "spawn",
49389
+ gateway: "mutate",
49390
+ mode: "native",
49391
+ preferredChannel: "mcp"
49392
+ },
49393
+ {
49394
+ domain: "orchestrate",
49395
+ operation: "handoff",
49396
+ gateway: "mutate",
49397
+ mode: "native",
49398
+ preferredChannel: "either"
49399
+ },
49400
+ {
49401
+ domain: "orchestrate",
49402
+ operation: "spawn.execute",
49403
+ gateway: "mutate",
49404
+ mode: "native",
49405
+ preferredChannel: "either"
49406
+ },
49407
+ {
49408
+ domain: "orchestrate",
49409
+ operation: "validate",
49410
+ gateway: "mutate",
49411
+ mode: "native",
49412
+ preferredChannel: "either"
49413
+ },
49414
+ {
49415
+ domain: "orchestrate",
49416
+ operation: "parallel",
49417
+ gateway: "mutate",
49418
+ mode: "native",
49419
+ preferredChannel: "either"
49420
+ },
49421
+ {
49422
+ domain: "orchestrate",
49423
+ operation: "tessera.instantiate",
49424
+ gateway: "mutate",
49425
+ mode: "native",
49426
+ preferredChannel: "either"
49427
+ },
48533
49428
  // === Memory Domain (brain.db cognitive memory -- T5241) ===
48534
49429
  // Query operations
48535
- { domain: "memory", operation: "find", gateway: "query", mode: "native" },
48536
- { domain: "memory", operation: "timeline", gateway: "query", mode: "native" },
48537
- { domain: "memory", operation: "fetch", gateway: "query", mode: "native" },
48538
- { domain: "memory", operation: "decision.find", gateway: "query", mode: "native" },
48539
- { domain: "memory", operation: "pattern.find", gateway: "query", mode: "native" },
48540
- { domain: "memory", operation: "learning.find", gateway: "query", mode: "native" },
48541
- { domain: "memory", operation: "graph.show", gateway: "query", mode: "native" },
48542
- { domain: "memory", operation: "graph.neighbors", gateway: "query", mode: "native" },
48543
- { domain: "memory", operation: "reason.why", gateway: "query", mode: "native" },
48544
- { domain: "memory", operation: "reason.similar", gateway: "query", mode: "native" },
48545
- { domain: "memory", operation: "search.hybrid", gateway: "query", mode: "native" },
49430
+ {
49431
+ domain: "memory",
49432
+ operation: "find",
49433
+ gateway: "query",
49434
+ mode: "native",
49435
+ preferredChannel: "mcp"
49436
+ },
49437
+ {
49438
+ domain: "memory",
49439
+ operation: "timeline",
49440
+ gateway: "query",
49441
+ mode: "native",
49442
+ preferredChannel: "mcp"
49443
+ },
49444
+ {
49445
+ domain: "memory",
49446
+ operation: "fetch",
49447
+ gateway: "query",
49448
+ mode: "native",
49449
+ preferredChannel: "mcp"
49450
+ },
49451
+ {
49452
+ domain: "memory",
49453
+ operation: "decision.find",
49454
+ gateway: "query",
49455
+ mode: "native",
49456
+ preferredChannel: "mcp"
49457
+ },
49458
+ {
49459
+ domain: "memory",
49460
+ operation: "pattern.find",
49461
+ gateway: "query",
49462
+ mode: "native",
49463
+ preferredChannel: "mcp"
49464
+ },
49465
+ {
49466
+ domain: "memory",
49467
+ operation: "learning.find",
49468
+ gateway: "query",
49469
+ mode: "native",
49470
+ preferredChannel: "mcp"
49471
+ },
49472
+ {
49473
+ domain: "memory",
49474
+ operation: "graph.show",
49475
+ gateway: "query",
49476
+ mode: "native",
49477
+ preferredChannel: "either"
49478
+ },
49479
+ {
49480
+ domain: "memory",
49481
+ operation: "graph.neighbors",
49482
+ gateway: "query",
49483
+ mode: "native",
49484
+ preferredChannel: "either"
49485
+ },
49486
+ {
49487
+ domain: "memory",
49488
+ operation: "reason.why",
49489
+ gateway: "query",
49490
+ mode: "native",
49491
+ preferredChannel: "either"
49492
+ },
49493
+ {
49494
+ domain: "memory",
49495
+ operation: "reason.similar",
49496
+ gateway: "query",
49497
+ mode: "native",
49498
+ preferredChannel: "either"
49499
+ },
49500
+ {
49501
+ domain: "memory",
49502
+ operation: "search.hybrid",
49503
+ gateway: "query",
49504
+ mode: "native",
49505
+ preferredChannel: "either"
49506
+ },
48546
49507
  // Mutate operations
48547
- { domain: "memory", operation: "observe", gateway: "mutate", mode: "native" },
48548
- { domain: "memory", operation: "decision.store", gateway: "mutate", mode: "native" },
48549
- { domain: "memory", operation: "pattern.store", gateway: "mutate", mode: "native" },
48550
- { domain: "memory", operation: "learning.store", gateway: "mutate", mode: "native" },
48551
- { domain: "memory", operation: "link", gateway: "mutate", mode: "native" },
48552
- { domain: "memory", operation: "graph.add", gateway: "mutate", mode: "native" },
48553
- { domain: "memory", operation: "graph.remove", gateway: "mutate", mode: "native" },
49508
+ {
49509
+ domain: "memory",
49510
+ operation: "observe",
49511
+ gateway: "mutate",
49512
+ mode: "native",
49513
+ preferredChannel: "mcp"
49514
+ },
49515
+ {
49516
+ domain: "memory",
49517
+ operation: "decision.store",
49518
+ gateway: "mutate",
49519
+ mode: "native",
49520
+ preferredChannel: "mcp"
49521
+ },
49522
+ {
49523
+ domain: "memory",
49524
+ operation: "pattern.store",
49525
+ gateway: "mutate",
49526
+ mode: "native",
49527
+ preferredChannel: "mcp"
49528
+ },
49529
+ {
49530
+ domain: "memory",
49531
+ operation: "learning.store",
49532
+ gateway: "mutate",
49533
+ mode: "native",
49534
+ preferredChannel: "mcp"
49535
+ },
49536
+ {
49537
+ domain: "memory",
49538
+ operation: "link",
49539
+ gateway: "mutate",
49540
+ mode: "native",
49541
+ preferredChannel: "either"
49542
+ },
49543
+ {
49544
+ domain: "memory",
49545
+ operation: "graph.add",
49546
+ gateway: "mutate",
49547
+ mode: "native",
49548
+ preferredChannel: "either"
49549
+ },
49550
+ {
49551
+ domain: "memory",
49552
+ operation: "graph.remove",
49553
+ gateway: "mutate",
49554
+ mode: "native",
49555
+ preferredChannel: "either"
49556
+ },
48554
49557
  // === Pipeline Domain ===
48555
49558
  // Stage sub-domain (RCASD lifecycle)
48556
- { domain: "pipeline", operation: "stage.validate", gateway: "query", mode: "native" },
48557
- { domain: "pipeline", operation: "stage.status", gateway: "query", mode: "native" },
48558
- { domain: "pipeline", operation: "stage.history", gateway: "query", mode: "native" },
48559
- { domain: "pipeline", operation: "stage.record", gateway: "mutate", mode: "native" },
48560
- { domain: "pipeline", operation: "stage.skip", gateway: "mutate", mode: "native" },
48561
- { domain: "pipeline", operation: "stage.reset", gateway: "mutate", mode: "native" },
48562
- { domain: "pipeline", operation: "stage.gate.pass", gateway: "mutate", mode: "native" },
48563
- { domain: "pipeline", operation: "stage.gate.fail", gateway: "mutate", mode: "native" },
49559
+ {
49560
+ domain: "pipeline",
49561
+ operation: "stage.validate",
49562
+ gateway: "query",
49563
+ mode: "native",
49564
+ preferredChannel: "mcp"
49565
+ },
49566
+ {
49567
+ domain: "pipeline",
49568
+ operation: "stage.status",
49569
+ gateway: "query",
49570
+ mode: "native",
49571
+ preferredChannel: "mcp"
49572
+ },
49573
+ {
49574
+ domain: "pipeline",
49575
+ operation: "stage.history",
49576
+ gateway: "query",
49577
+ mode: "native",
49578
+ preferredChannel: "either"
49579
+ },
49580
+ {
49581
+ domain: "pipeline",
49582
+ operation: "stage.record",
49583
+ gateway: "mutate",
49584
+ mode: "native",
49585
+ preferredChannel: "either"
49586
+ },
49587
+ {
49588
+ domain: "pipeline",
49589
+ operation: "stage.skip",
49590
+ gateway: "mutate",
49591
+ mode: "native",
49592
+ preferredChannel: "either"
49593
+ },
49594
+ {
49595
+ domain: "pipeline",
49596
+ operation: "stage.reset",
49597
+ gateway: "mutate",
49598
+ mode: "native",
49599
+ preferredChannel: "either"
49600
+ },
49601
+ {
49602
+ domain: "pipeline",
49603
+ operation: "stage.gate.pass",
49604
+ gateway: "mutate",
49605
+ mode: "native",
49606
+ preferredChannel: "either"
49607
+ },
49608
+ {
49609
+ domain: "pipeline",
49610
+ operation: "stage.gate.fail",
49611
+ gateway: "mutate",
49612
+ mode: "native",
49613
+ preferredChannel: "either"
49614
+ },
48564
49615
  // Manifest sub-domain (T5241)
48565
- { domain: "pipeline", operation: "manifest.show", gateway: "query", mode: "native" },
48566
- { domain: "pipeline", operation: "manifest.list", gateway: "query", mode: "native" },
48567
- { domain: "pipeline", operation: "manifest.find", gateway: "query", mode: "native" },
48568
- { domain: "pipeline", operation: "manifest.stats", gateway: "query", mode: "native" },
48569
- { domain: "pipeline", operation: "manifest.append", gateway: "mutate", mode: "native" },
48570
- { domain: "pipeline", operation: "manifest.archive", gateway: "mutate", mode: "native" },
49616
+ {
49617
+ domain: "pipeline",
49618
+ operation: "manifest.show",
49619
+ gateway: "query",
49620
+ mode: "native",
49621
+ preferredChannel: "either"
49622
+ },
49623
+ {
49624
+ domain: "pipeline",
49625
+ operation: "manifest.list",
49626
+ gateway: "query",
49627
+ mode: "native",
49628
+ preferredChannel: "either"
49629
+ },
49630
+ {
49631
+ domain: "pipeline",
49632
+ operation: "manifest.find",
49633
+ gateway: "query",
49634
+ mode: "native",
49635
+ preferredChannel: "either"
49636
+ },
49637
+ {
49638
+ domain: "pipeline",
49639
+ operation: "manifest.stats",
49640
+ gateway: "query",
49641
+ mode: "native",
49642
+ preferredChannel: "either"
49643
+ },
49644
+ {
49645
+ domain: "pipeline",
49646
+ operation: "manifest.append",
49647
+ gateway: "mutate",
49648
+ mode: "native",
49649
+ preferredChannel: "either"
49650
+ },
49651
+ {
49652
+ domain: "pipeline",
49653
+ operation: "manifest.archive",
49654
+ gateway: "mutate",
49655
+ mode: "native",
49656
+ preferredChannel: "either"
49657
+ },
48571
49658
  // Phase sub-domain (T5326)
48572
- { domain: "pipeline", operation: "phase.show", gateway: "query", mode: "native" },
48573
- { domain: "pipeline", operation: "phase.list", gateway: "query", mode: "native" },
48574
- { domain: "pipeline", operation: "phase.set", gateway: "mutate", mode: "native" },
48575
- { domain: "pipeline", operation: "phase.advance", gateway: "mutate", mode: "native" },
48576
- { domain: "pipeline", operation: "phase.rename", gateway: "mutate", mode: "native" },
48577
- { domain: "pipeline", operation: "phase.delete", gateway: "mutate", mode: "native" },
49659
+ {
49660
+ domain: "pipeline",
49661
+ operation: "phase.show",
49662
+ gateway: "query",
49663
+ mode: "native",
49664
+ preferredChannel: "either"
49665
+ },
49666
+ {
49667
+ domain: "pipeline",
49668
+ operation: "phase.list",
49669
+ gateway: "query",
49670
+ mode: "native",
49671
+ preferredChannel: "either"
49672
+ },
49673
+ {
49674
+ domain: "pipeline",
49675
+ operation: "phase.set",
49676
+ gateway: "mutate",
49677
+ mode: "native",
49678
+ preferredChannel: "either"
49679
+ },
49680
+ {
49681
+ domain: "pipeline",
49682
+ operation: "phase.advance",
49683
+ gateway: "mutate",
49684
+ mode: "native",
49685
+ preferredChannel: "either"
49686
+ },
49687
+ {
49688
+ domain: "pipeline",
49689
+ operation: "phase.rename",
49690
+ gateway: "mutate",
49691
+ mode: "native",
49692
+ preferredChannel: "either"
49693
+ },
49694
+ {
49695
+ domain: "pipeline",
49696
+ operation: "phase.delete",
49697
+ gateway: "mutate",
49698
+ mode: "native",
49699
+ preferredChannel: "either"
49700
+ },
48578
49701
  // Chain sub-domain (T5405)
48579
- { domain: "pipeline", operation: "chain.show", gateway: "query", mode: "native" },
48580
- { domain: "pipeline", operation: "chain.list", gateway: "query", mode: "native" },
48581
- { domain: "pipeline", operation: "chain.add", gateway: "mutate", mode: "native" },
48582
- { domain: "pipeline", operation: "chain.instantiate", gateway: "mutate", mode: "native" },
48583
- { domain: "pipeline", operation: "chain.advance", gateway: "mutate", mode: "native" },
49702
+ {
49703
+ domain: "pipeline",
49704
+ operation: "chain.show",
49705
+ gateway: "query",
49706
+ mode: "native",
49707
+ preferredChannel: "either"
49708
+ },
49709
+ {
49710
+ domain: "pipeline",
49711
+ operation: "chain.list",
49712
+ gateway: "query",
49713
+ mode: "native",
49714
+ preferredChannel: "either"
49715
+ },
49716
+ {
49717
+ domain: "pipeline",
49718
+ operation: "chain.add",
49719
+ gateway: "mutate",
49720
+ mode: "native",
49721
+ preferredChannel: "either"
49722
+ },
49723
+ {
49724
+ domain: "pipeline",
49725
+ operation: "chain.instantiate",
49726
+ gateway: "mutate",
49727
+ mode: "native",
49728
+ preferredChannel: "either"
49729
+ },
49730
+ {
49731
+ domain: "pipeline",
49732
+ operation: "chain.advance",
49733
+ gateway: "mutate",
49734
+ mode: "native",
49735
+ preferredChannel: "either"
49736
+ },
48584
49737
  // Release sub-domain (T5615 consolidated)
48585
- { domain: "pipeline", operation: "release.list", gateway: "query", mode: "native" },
48586
- { domain: "pipeline", operation: "release.show", gateway: "query", mode: "native" },
48587
- { domain: "pipeline", operation: "release.channel.show", gateway: "query", mode: "native" },
48588
- { domain: "pipeline", operation: "release.ship", gateway: "mutate", mode: "native" },
48589
- { domain: "pipeline", operation: "release.cancel", gateway: "mutate", mode: "native" },
48590
- { domain: "pipeline", operation: "release.rollback", gateway: "mutate", mode: "native" },
49738
+ {
49739
+ domain: "pipeline",
49740
+ operation: "release.list",
49741
+ gateway: "query",
49742
+ mode: "native",
49743
+ preferredChannel: "either"
49744
+ },
49745
+ {
49746
+ domain: "pipeline",
49747
+ operation: "release.show",
49748
+ gateway: "query",
49749
+ mode: "native",
49750
+ preferredChannel: "either"
49751
+ },
49752
+ {
49753
+ domain: "pipeline",
49754
+ operation: "release.channel.show",
49755
+ gateway: "query",
49756
+ mode: "native",
49757
+ preferredChannel: "either"
49758
+ },
49759
+ {
49760
+ domain: "pipeline",
49761
+ operation: "release.ship",
49762
+ gateway: "mutate",
49763
+ mode: "native",
49764
+ preferredChannel: "cli"
49765
+ },
49766
+ {
49767
+ domain: "pipeline",
49768
+ operation: "release.cancel",
49769
+ gateway: "mutate",
49770
+ mode: "native",
49771
+ preferredChannel: "either"
49772
+ },
49773
+ {
49774
+ domain: "pipeline",
49775
+ operation: "release.rollback",
49776
+ gateway: "mutate",
49777
+ mode: "native",
49778
+ preferredChannel: "either"
49779
+ },
48591
49780
  // === Tools Domain ===
48592
49781
  // Issue operations
48593
- { domain: "tools", operation: "issue.diagnostics", gateway: "query", mode: "native" },
49782
+ {
49783
+ domain: "tools",
49784
+ operation: "issue.diagnostics",
49785
+ gateway: "query",
49786
+ mode: "native",
49787
+ preferredChannel: "either"
49788
+ },
48594
49789
  // Skill operations
48595
- { domain: "tools", operation: "skill.list", gateway: "query", mode: "native" },
48596
- { domain: "tools", operation: "skill.show", gateway: "query", mode: "native" },
48597
- { domain: "tools", operation: "skill.find", gateway: "query", mode: "native" },
48598
- { domain: "tools", operation: "skill.dispatch", gateway: "query", mode: "native" },
48599
- { domain: "tools", operation: "skill.verify", gateway: "query", mode: "native" },
48600
- { domain: "tools", operation: "skill.dependencies", gateway: "query", mode: "native" },
48601
- { domain: "tools", operation: "skill.spawn.providers", gateway: "query", mode: "native" },
48602
- { domain: "tools", operation: "skill.catalog", gateway: "query", mode: "native" },
48603
- { domain: "tools", operation: "skill.precedence", gateway: "query", mode: "native" },
48604
- { domain: "tools", operation: "skill.install", gateway: "mutate", mode: "native" },
48605
- { domain: "tools", operation: "skill.uninstall", gateway: "mutate", mode: "native" },
48606
- { domain: "tools", operation: "skill.refresh", gateway: "mutate", mode: "native" },
49790
+ {
49791
+ domain: "tools",
49792
+ operation: "skill.list",
49793
+ gateway: "query",
49794
+ mode: "native",
49795
+ preferredChannel: "mcp"
49796
+ },
49797
+ {
49798
+ domain: "tools",
49799
+ operation: "skill.show",
49800
+ gateway: "query",
49801
+ mode: "native",
49802
+ preferredChannel: "mcp"
49803
+ },
49804
+ {
49805
+ domain: "tools",
49806
+ operation: "skill.find",
49807
+ gateway: "query",
49808
+ mode: "native",
49809
+ preferredChannel: "mcp"
49810
+ },
49811
+ {
49812
+ domain: "tools",
49813
+ operation: "skill.dispatch",
49814
+ gateway: "query",
49815
+ mode: "native",
49816
+ preferredChannel: "either"
49817
+ },
49818
+ {
49819
+ domain: "tools",
49820
+ operation: "skill.verify",
49821
+ gateway: "query",
49822
+ mode: "native",
49823
+ preferredChannel: "either"
49824
+ },
49825
+ {
49826
+ domain: "tools",
49827
+ operation: "skill.dependencies",
49828
+ gateway: "query",
49829
+ mode: "native",
49830
+ preferredChannel: "either"
49831
+ },
49832
+ {
49833
+ domain: "tools",
49834
+ operation: "skill.spawn.providers",
49835
+ gateway: "query",
49836
+ mode: "native",
49837
+ preferredChannel: "either"
49838
+ },
49839
+ {
49840
+ domain: "tools",
49841
+ operation: "skill.catalog",
49842
+ gateway: "query",
49843
+ mode: "native",
49844
+ preferredChannel: "either"
49845
+ },
49846
+ {
49847
+ domain: "tools",
49848
+ operation: "skill.precedence",
49849
+ gateway: "query",
49850
+ mode: "native",
49851
+ preferredChannel: "either"
49852
+ },
49853
+ {
49854
+ domain: "tools",
49855
+ operation: "skill.install",
49856
+ gateway: "mutate",
49857
+ mode: "native",
49858
+ preferredChannel: "either"
49859
+ },
49860
+ {
49861
+ domain: "tools",
49862
+ operation: "skill.uninstall",
49863
+ gateway: "mutate",
49864
+ mode: "native",
49865
+ preferredChannel: "either"
49866
+ },
49867
+ {
49868
+ domain: "tools",
49869
+ operation: "skill.refresh",
49870
+ gateway: "mutate",
49871
+ mode: "native",
49872
+ preferredChannel: "either"
49873
+ },
48607
49874
  // Provider operations
48608
- { domain: "tools", operation: "provider.list", gateway: "query", mode: "native" },
48609
- { domain: "tools", operation: "provider.detect", gateway: "query", mode: "native" },
48610
- { domain: "tools", operation: "provider.inject.status", gateway: "query", mode: "native" },
48611
- { domain: "tools", operation: "provider.supports", gateway: "query", mode: "native" },
48612
- { domain: "tools", operation: "provider.hooks", gateway: "query", mode: "native" },
48613
- { domain: "tools", operation: "provider.inject", gateway: "mutate", mode: "native" },
49875
+ {
49876
+ domain: "tools",
49877
+ operation: "provider.list",
49878
+ gateway: "query",
49879
+ mode: "native",
49880
+ preferredChannel: "mcp"
49881
+ },
49882
+ {
49883
+ domain: "tools",
49884
+ operation: "provider.detect",
49885
+ gateway: "query",
49886
+ mode: "native",
49887
+ preferredChannel: "mcp"
49888
+ },
49889
+ {
49890
+ domain: "tools",
49891
+ operation: "provider.inject.status",
49892
+ gateway: "query",
49893
+ mode: "native",
49894
+ preferredChannel: "either"
49895
+ },
49896
+ {
49897
+ domain: "tools",
49898
+ operation: "provider.supports",
49899
+ gateway: "query",
49900
+ mode: "native",
49901
+ preferredChannel: "either"
49902
+ },
49903
+ {
49904
+ domain: "tools",
49905
+ operation: "provider.hooks",
49906
+ gateway: "query",
49907
+ mode: "native",
49908
+ preferredChannel: "either"
49909
+ },
49910
+ {
49911
+ domain: "tools",
49912
+ operation: "provider.inject",
49913
+ gateway: "mutate",
49914
+ mode: "native",
49915
+ preferredChannel: "either"
49916
+ },
49917
+ // Adapter sub-domain (T5240)
49918
+ {
49919
+ domain: "tools",
49920
+ operation: "adapter.list",
49921
+ gateway: "query",
49922
+ mode: "native",
49923
+ preferredChannel: "mcp"
49924
+ },
49925
+ {
49926
+ domain: "tools",
49927
+ operation: "adapter.show",
49928
+ gateway: "query",
49929
+ mode: "native",
49930
+ preferredChannel: "mcp"
49931
+ },
49932
+ {
49933
+ domain: "tools",
49934
+ operation: "adapter.detect",
49935
+ gateway: "query",
49936
+ mode: "native",
49937
+ preferredChannel: "either"
49938
+ },
49939
+ {
49940
+ domain: "tools",
49941
+ operation: "adapter.health",
49942
+ gateway: "query",
49943
+ mode: "native",
49944
+ preferredChannel: "either"
49945
+ },
49946
+ {
49947
+ domain: "tools",
49948
+ operation: "adapter.activate",
49949
+ gateway: "mutate",
49950
+ mode: "native",
49951
+ preferredChannel: "mcp"
49952
+ },
49953
+ {
49954
+ domain: "tools",
49955
+ operation: "adapter.dispose",
49956
+ gateway: "mutate",
49957
+ mode: "native",
49958
+ preferredChannel: "either"
49959
+ },
48614
49960
  // === Nexus Domain ===
48615
49961
  // Query operations
48616
- { domain: "nexus", operation: "status", gateway: "query", mode: "native" },
48617
- { domain: "nexus", operation: "list", gateway: "query", mode: "native" },
48618
- { domain: "nexus", operation: "show", gateway: "query", mode: "native" },
48619
- { domain: "nexus", operation: "search", gateway: "query", mode: "native" },
48620
- { domain: "nexus", operation: "graph", gateway: "query", mode: "native" },
48621
- { domain: "nexus", operation: "deps", gateway: "query", mode: "native" },
48622
- { domain: "nexus", operation: "resolve", gateway: "query", mode: "native" },
48623
- { domain: "nexus", operation: "discover", gateway: "query", mode: "native" },
48624
- { domain: "nexus", operation: "orphans.list", gateway: "query", mode: "native" },
48625
- { domain: "nexus", operation: "blockers.show", gateway: "query", mode: "native" },
48626
- { domain: "nexus", operation: "path.show", gateway: "query", mode: "native" },
48627
- { domain: "nexus", operation: "share.status", gateway: "query", mode: "native" },
49962
+ {
49963
+ domain: "nexus",
49964
+ operation: "status",
49965
+ gateway: "query",
49966
+ mode: "native",
49967
+ preferredChannel: "either"
49968
+ },
49969
+ {
49970
+ domain: "nexus",
49971
+ operation: "list",
49972
+ gateway: "query",
49973
+ mode: "native",
49974
+ preferredChannel: "either"
49975
+ },
49976
+ {
49977
+ domain: "nexus",
49978
+ operation: "show",
49979
+ gateway: "query",
49980
+ mode: "native",
49981
+ preferredChannel: "either"
49982
+ },
49983
+ {
49984
+ domain: "nexus",
49985
+ operation: "search",
49986
+ gateway: "query",
49987
+ mode: "native",
49988
+ preferredChannel: "either"
49989
+ },
49990
+ {
49991
+ domain: "nexus",
49992
+ operation: "graph",
49993
+ gateway: "query",
49994
+ mode: "native",
49995
+ preferredChannel: "either"
49996
+ },
49997
+ {
49998
+ domain: "nexus",
49999
+ operation: "deps",
50000
+ gateway: "query",
50001
+ mode: "native",
50002
+ preferredChannel: "either"
50003
+ },
50004
+ {
50005
+ domain: "nexus",
50006
+ operation: "resolve",
50007
+ gateway: "query",
50008
+ mode: "native",
50009
+ preferredChannel: "either"
50010
+ },
50011
+ {
50012
+ domain: "nexus",
50013
+ operation: "discover",
50014
+ gateway: "query",
50015
+ mode: "native",
50016
+ preferredChannel: "either"
50017
+ },
50018
+ {
50019
+ domain: "nexus",
50020
+ operation: "orphans.list",
50021
+ gateway: "query",
50022
+ mode: "native",
50023
+ preferredChannel: "either"
50024
+ },
50025
+ {
50026
+ domain: "nexus",
50027
+ operation: "blockers.show",
50028
+ gateway: "query",
50029
+ mode: "native",
50030
+ preferredChannel: "either"
50031
+ },
50032
+ {
50033
+ domain: "nexus",
50034
+ operation: "path.show",
50035
+ gateway: "query",
50036
+ mode: "native",
50037
+ preferredChannel: "either"
50038
+ },
50039
+ {
50040
+ domain: "nexus",
50041
+ operation: "share.status",
50042
+ gateway: "query",
50043
+ mode: "native",
50044
+ preferredChannel: "either"
50045
+ },
50046
+ {
50047
+ domain: "nexus",
50048
+ operation: "transfer.preview",
50049
+ gateway: "query",
50050
+ mode: "native",
50051
+ preferredChannel: "either"
50052
+ },
48628
50053
  // Mutate operations
48629
- { domain: "nexus", operation: "init", gateway: "mutate", mode: "native" },
48630
- { domain: "nexus", operation: "register", gateway: "mutate", mode: "native" },
48631
- { domain: "nexus", operation: "unregister", gateway: "mutate", mode: "native" },
48632
- { domain: "nexus", operation: "sync", gateway: "mutate", mode: "native" },
48633
- { domain: "nexus", operation: "reconcile", gateway: "mutate", mode: "native" },
48634
- { domain: "nexus", operation: "permission.set", gateway: "mutate", mode: "native" },
48635
- { domain: "nexus", operation: "share.snapshot.export", gateway: "mutate", mode: "native" },
48636
- { domain: "nexus", operation: "share.snapshot.import", gateway: "mutate", mode: "native" },
50054
+ {
50055
+ domain: "nexus",
50056
+ operation: "init",
50057
+ gateway: "mutate",
50058
+ mode: "native",
50059
+ preferredChannel: "either"
50060
+ },
50061
+ {
50062
+ domain: "nexus",
50063
+ operation: "register",
50064
+ gateway: "mutate",
50065
+ mode: "native",
50066
+ preferredChannel: "either"
50067
+ },
50068
+ {
50069
+ domain: "nexus",
50070
+ operation: "unregister",
50071
+ gateway: "mutate",
50072
+ mode: "native",
50073
+ preferredChannel: "either"
50074
+ },
50075
+ {
50076
+ domain: "nexus",
50077
+ operation: "sync",
50078
+ gateway: "mutate",
50079
+ mode: "native",
50080
+ preferredChannel: "either"
50081
+ },
50082
+ {
50083
+ domain: "nexus",
50084
+ operation: "reconcile",
50085
+ gateway: "mutate",
50086
+ mode: "native",
50087
+ preferredChannel: "either"
50088
+ },
50089
+ {
50090
+ domain: "nexus",
50091
+ operation: "permission.set",
50092
+ gateway: "mutate",
50093
+ mode: "native",
50094
+ preferredChannel: "either"
50095
+ },
50096
+ {
50097
+ domain: "nexus",
50098
+ operation: "share.snapshot.export",
50099
+ gateway: "mutate",
50100
+ mode: "native",
50101
+ preferredChannel: "either"
50102
+ },
50103
+ {
50104
+ domain: "nexus",
50105
+ operation: "share.snapshot.import",
50106
+ gateway: "mutate",
50107
+ mode: "native",
50108
+ preferredChannel: "either"
50109
+ },
50110
+ {
50111
+ domain: "nexus",
50112
+ operation: "transfer",
50113
+ gateway: "mutate",
50114
+ mode: "native",
50115
+ preferredChannel: "either"
50116
+ },
48637
50117
  // === Sticky Domain ===
48638
50118
  // Query operations
48639
- { domain: "sticky", operation: "list", gateway: "query", mode: "native" },
48640
- { domain: "sticky", operation: "show", gateway: "query", mode: "native" },
50119
+ {
50120
+ domain: "sticky",
50121
+ operation: "list",
50122
+ gateway: "query",
50123
+ mode: "native",
50124
+ preferredChannel: "mcp"
50125
+ },
50126
+ {
50127
+ domain: "sticky",
50128
+ operation: "show",
50129
+ gateway: "query",
50130
+ mode: "native",
50131
+ preferredChannel: "mcp"
50132
+ },
48641
50133
  // Mutate operations
48642
- { domain: "sticky", operation: "add", gateway: "mutate", mode: "native" },
48643
- { domain: "sticky", operation: "archive", gateway: "mutate", mode: "native" },
48644
- { domain: "sticky", operation: "convert", gateway: "mutate", mode: "native" },
48645
- { domain: "sticky", operation: "purge", gateway: "mutate", mode: "native" }
50134
+ {
50135
+ domain: "sticky",
50136
+ operation: "add",
50137
+ gateway: "mutate",
50138
+ mode: "native",
50139
+ preferredChannel: "mcp"
50140
+ },
50141
+ {
50142
+ domain: "sticky",
50143
+ operation: "archive",
50144
+ gateway: "mutate",
50145
+ mode: "native",
50146
+ preferredChannel: "either"
50147
+ },
50148
+ {
50149
+ domain: "sticky",
50150
+ operation: "convert",
50151
+ gateway: "mutate",
50152
+ mode: "native",
50153
+ preferredChannel: "either"
50154
+ },
50155
+ {
50156
+ domain: "sticky",
50157
+ operation: "purge",
50158
+ gateway: "mutate",
50159
+ mode: "native",
50160
+ preferredChannel: "either"
50161
+ }
48646
50162
  ];
48647
50163
  }
48648
50164
  });
@@ -51405,6 +52921,7 @@ var init_config2 = __esm({
51405
52921
 
51406
52922
  // packages/core/src/skills/agents/install.ts
51407
52923
  import { existsSync as existsSync67, mkdirSync as mkdirSync14, readdirSync as readdirSync25, readlinkSync, symlinkSync, unlinkSync as unlinkSync4 } from "node:fs";
52924
+ import { platform as platform2 } from "node:os";
51408
52925
  import { basename as basename12, join as join70 } from "node:path";
51409
52926
  function getAgentInstallDir() {
51410
52927
  return getClaudeAgentsDir();
@@ -51435,7 +52952,7 @@ function installAgent(agentDir) {
51435
52952
  }
51436
52953
  }
51437
52954
  try {
51438
- symlinkSync(agentDir, targetPath, "dir");
52955
+ symlinkSync(agentDir, targetPath, DIR_SYMLINK_TYPE);
51439
52956
  return { installed: true, path: targetPath };
51440
52957
  } catch (err) {
51441
52958
  return { installed: false, path: targetPath, error: `Symlink failed: ${err}` };
@@ -51475,11 +52992,13 @@ function uninstallAgent(agentName) {
51475
52992
  return false;
51476
52993
  }
51477
52994
  }
52995
+ var DIR_SYMLINK_TYPE;
51478
52996
  var init_install = __esm({
51479
52997
  "packages/core/src/skills/agents/install.ts"() {
51480
52998
  "use strict";
51481
52999
  init_paths();
51482
53000
  init_config2();
53001
+ DIR_SYMLINK_TYPE = platform2() === "win32" ? "junction" : "dir";
51483
53002
  }
51484
53003
  });
51485
53004
 
@@ -53412,8 +54931,9 @@ var init_validator = __esm({
53412
54931
  // packages/core/src/skills/skill-paths.ts
53413
54932
  import { existsSync as existsSync77, lstatSync, readlinkSync as readlinkSync2, realpathSync as realpathSync2 } from "node:fs";
53414
54933
  import { delimiter, join as join79, resolve as resolve9 } from "node:path";
54934
+ import { getCanonicalSkillsDir as getCanonicalSkillsDir2 } from "@cleocode/caamp";
53415
54935
  function getCaampCanonical() {
53416
- return join79(getAgentsHome(), "skills");
54936
+ return getCanonicalSkillsDir2();
53417
54937
  }
53418
54938
  function getProjectEmbedded(projectRoot) {
53419
54939
  const root = projectRoot ?? process.cwd();
@@ -53533,7 +55053,6 @@ function getSkillSourceType(skillDir, projectRoot) {
53533
55053
  var init_skill_paths = __esm({
53534
55054
  "packages/core/src/skills/skill-paths.ts"() {
53535
55055
  "use strict";
53536
- init_paths();
53537
55056
  }
53538
55057
  });
53539
55058
 
@@ -55464,7 +56983,7 @@ import { createGzip } from "node:zlib";
55464
56983
  async function pruneAuditLog(cleoDir, config2) {
55465
56984
  try {
55466
56985
  if (!config2.auditRetentionDays || config2.auditRetentionDays <= 0) {
55467
- log6.debug("auditRetentionDays is 0 or unset; skipping audit prune");
56986
+ log7.debug("auditRetentionDays is 0 or unset; skipping audit prune");
55468
56987
  return { rowsArchived: 0, rowsDeleted: 0 };
55469
56988
  }
55470
56989
  const cutoff = new Date(Date.now() - config2.auditRetentionDays * 864e5).toISOString();
@@ -55475,7 +56994,7 @@ async function pruneAuditLog(cleoDir, config2) {
55475
56994
  const db = await getDb4(projectRoot);
55476
56995
  const oldRows = await db.select().from(auditLog2).where(lt3(auditLog2.timestamp, cutoff));
55477
56996
  if (oldRows.length === 0) {
55478
- log6.debug("No audit_log rows older than cutoff; nothing to prune");
56997
+ log7.debug("No audit_log rows older than cutoff; nothing to prune");
55479
56998
  return { rowsArchived: 0, rowsDeleted: 0 };
55480
56999
  }
55481
57000
  let archivePath;
@@ -55493,17 +57012,17 @@ async function pruneAuditLog(cleoDir, config2) {
55493
57012
  const inStream = Readable.from([jsonlContent]);
55494
57013
  await pipeline(inStream, gzip, outStream);
55495
57014
  rowsArchived = oldRows.length;
55496
- log6.info(
57015
+ log7.info(
55497
57016
  { archivePath, rowsArchived },
55498
57017
  `Archived ${rowsArchived} audit rows to ${archivePath}`
55499
57018
  );
55500
57019
  } catch (archiveErr) {
55501
- log6.warn({ err: archiveErr }, "Failed to archive audit rows; continuing with deletion");
57020
+ log7.warn({ err: archiveErr }, "Failed to archive audit rows; continuing with deletion");
55502
57021
  archivePath = void 0;
55503
57022
  }
55504
57023
  }
55505
57024
  await db.delete(auditLog2).where(lt3(auditLog2.timestamp, cutoff)).run();
55506
- log6.info(
57025
+ log7.info(
55507
57026
  { rowsDeleted: oldRows.length, cutoff },
55508
57027
  `Pruned ${oldRows.length} audit_log rows older than ${cutoff}`
55509
57028
  );
@@ -55513,16 +57032,16 @@ async function pruneAuditLog(cleoDir, config2) {
55513
57032
  archivePath
55514
57033
  };
55515
57034
  } catch (err) {
55516
- log6.warn({ err }, "audit log pruning failed");
57035
+ log7.warn({ err }, "audit log pruning failed");
55517
57036
  return { rowsArchived: 0, rowsDeleted: 0 };
55518
57037
  }
55519
57038
  }
55520
- var log6;
57039
+ var log7;
55521
57040
  var init_audit_prune = __esm({
55522
57041
  "packages/core/src/audit-prune.ts"() {
55523
57042
  "use strict";
55524
57043
  init_logger();
55525
- log6 = getLogger("prune");
57044
+ log7 = getLogger("prune");
55526
57045
  }
55527
57046
  });
55528
57047
 
@@ -55914,7 +57433,7 @@ function getNodeVersionInfo() {
55914
57433
  };
55915
57434
  }
55916
57435
  function getNodeUpgradeInstructions() {
55917
- const platform3 = detectPlatform();
57436
+ const platform5 = detectPlatform();
55918
57437
  const arch2 = process.arch;
55919
57438
  const instructions = [];
55920
57439
  const hasFnm = commandExists2("fnm");
@@ -55929,7 +57448,7 @@ function getNodeUpgradeInstructions() {
55929
57448
  if (hasVolta) {
55930
57449
  instructions.push(`volta install node@${MINIMUM_NODE_MAJOR}`);
55931
57450
  }
55932
- switch (platform3) {
57451
+ switch (platform5) {
55933
57452
  case "linux":
55934
57453
  if (commandExists2("dnf")) {
55935
57454
  instructions.push(
@@ -55961,7 +57480,7 @@ function getNodeUpgradeInstructions() {
55961
57480
  }
55962
57481
  instructions.push(`https://nodejs.org/en/download/`);
55963
57482
  const recommended = instructions[0] ?? `https://nodejs.org/en/download/`;
55964
- return { platform: platform3, arch: arch2, instructions, recommended };
57483
+ return { platform: platform5, arch: arch2, instructions, recommended };
55965
57484
  }
55966
57485
  function getSystemInfo2() {
55967
57486
  return {
@@ -57496,12 +59015,22 @@ async function startupHealthCheck(projectRoot) {
57496
59015
  message: scaffoldResult.home.action === "skipped" ? "Global home already current" : `Global home ${scaffoldResult.home.action}: ${scaffoldResult.home.details ?? ""}`,
57497
59016
  repaired: scaffoldResult.home.action !== "skipped"
57498
59017
  });
57499
- checks.push({
57500
- check: "global_schemas",
57501
- status: "pass",
57502
- message: `Schemas: ${scaffoldResult.schemas.installed} installed, ${scaffoldResult.schemas.updated} updated of ${scaffoldResult.schemas.total}`,
57503
- repaired: scaffoldResult.schemas.installed > 0 || scaffoldResult.schemas.updated > 0
57504
- });
59018
+ if (!globalSchemaCheck.ok) {
59019
+ const { ensureGlobalSchemas: ensureGlobalSchemas2 } = await Promise.resolve().then(() => (init_schema_management(), schema_management_exports));
59020
+ const schemaResult = ensureGlobalSchemas2();
59021
+ checks.push({
59022
+ check: "global_schemas",
59023
+ status: "pass",
59024
+ message: `Schemas: ${schemaResult.installed} installed, ${schemaResult.updated} updated of ${schemaResult.total}`,
59025
+ repaired: schemaResult.installed > 0 || schemaResult.updated > 0
59026
+ });
59027
+ } else {
59028
+ checks.push({
59029
+ check: "global_schemas",
59030
+ status: "pass",
59031
+ message: `All ${globalSchemaCheck.installed} schemas current`
59032
+ });
59033
+ }
57505
59034
  checks.push({
57506
59035
  check: "global_templates",
57507
59036
  status: "pass",
@@ -59010,13 +60539,13 @@ var init_templates = __esm({
59010
60539
 
59011
60540
  // packages/core/src/ui/aliases.ts
59012
60541
  import { existsSync as existsSync93, readFileSync as readFileSync67, writeFileSync as writeFileSync15 } from "node:fs";
59013
- import { homedir as homedir5, platform as platform2 } from "node:os";
60542
+ import { homedir as homedir5, platform as platform3 } from "node:os";
59014
60543
  import { join as join96 } from "node:path";
59015
60544
  function getCurrentShell() {
59016
60545
  const shell = process.env.SHELL ?? "";
59017
60546
  if (shell.includes("zsh")) return "zsh";
59018
60547
  if (shell.includes("bash")) return "bash";
59019
- if (platform2() === "win32") return "powershell";
60548
+ if (platform3() === "win32") return "powershell";
59020
60549
  return "bash";
59021
60550
  }
59022
60551
  function getRcFilePath(shell) {
@@ -59040,7 +60569,7 @@ function detectAvailableShells() {
59040
60569
  const shells = [];
59041
60570
  if (existsSync93(getRcFilePath("bash")) || existsSync93("/bin/bash")) shells.push("bash");
59042
60571
  if (existsSync93(getRcFilePath("zsh")) || existsSync93("/bin/zsh")) shells.push("zsh");
59043
- if (platform2() === "win32") shells.push("powershell");
60572
+ if (platform3() === "win32") shells.push("powershell");
59044
60573
  return shells;
59045
60574
  }
59046
60575
  function generateBashAliases(cleoPath) {
@@ -59504,27 +61033,10 @@ var init_flags = __esm({
59504
61033
  }
59505
61034
  });
59506
61035
 
59507
- // packages/core/src/ui/injection-legacy.ts
59508
- function getValidationKey(target) {
59509
- return INJECTION_VALIDATION_KEYS[target] ?? target.toLowerCase().replace(/[^a-z0-9]/g, "_");
59510
- }
59511
- var INJECTION_VALIDATION_KEYS;
59512
- var init_injection_legacy = __esm({
59513
- "packages/core/src/ui/injection-legacy.ts"() {
59514
- "use strict";
59515
- INJECTION_VALIDATION_KEYS = {
59516
- "CLAUDE.md": "claude_md",
59517
- "AGENTS.md": "agents_md",
59518
- "GEMINI.md": "gemini_md"
59519
- };
59520
- }
59521
- });
59522
-
59523
61036
  // packages/core/src/ui/index.ts
59524
61037
  var ui_exports = {};
59525
61038
  __export(ui_exports, {
59526
61039
  ALIASES_VERSION: () => ALIASES_VERSION,
59527
- INJECTION_VALIDATION_KEYS: () => INJECTION_VALIDATION_KEYS,
59528
61040
  appendToChangelog: () => appendToChangelog,
59529
61041
  checkAliasesStatus: () => checkAliasesStatus,
59530
61042
  defaultFlags: () => defaultFlags,
@@ -59541,7 +61053,6 @@ __export(ui_exports, {
59541
61053
  getCurrentShell: () => getCurrentShell,
59542
61054
  getInstalledVersion: () => getInstalledVersion,
59543
61055
  getRcFilePath: () => getRcFilePath,
59544
- getValidationKey: () => getValidationKey,
59545
61056
  groupTasksIntoSections: () => groupTasksIntoSections,
59546
61057
  hasAliasBlock: () => hasAliasBlock,
59547
61058
  injectAliases: () => injectAliases,
@@ -59561,7 +61072,6 @@ var init_ui = __esm({
59561
61072
  init_changelog();
59562
61073
  init_command_registry();
59563
61074
  init_flags();
59564
- init_injection_legacy();
59565
61075
  }
59566
61076
  });
59567
61077
 
@@ -62736,11 +64246,29 @@ __export(init_exports, {
62736
64246
  });
62737
64247
  import { existsSync as existsSync100, readdirSync as readdirSync33, readFileSync as readFileSync73 } from "node:fs";
62738
64248
  import { copyFile as copyFile3, lstat, mkdir as mkdir16, readFile as readFile17, symlink, unlink as unlink4, writeFile as writeFile11 } from "node:fs/promises";
64249
+ import { platform as platform4 } from "node:os";
62739
64250
  import { basename as basename17, dirname as dirname19, join as join100 } from "node:path";
62740
64251
  async function initAgentDefinition(created, warnings) {
62741
- const packageRoot = getPackageRoot();
62742
- const agentSourceDir = join100(packageRoot, "agents", "cleo-subagent");
62743
- if (!existsSync100(agentSourceDir)) {
64252
+ let agentSourceDir = null;
64253
+ try {
64254
+ const { createRequire: createRequire6 } = await import("node:module");
64255
+ const req = createRequire6(import.meta.url);
64256
+ const agentsPkgMain = req.resolve("@cleocode/agents/package.json");
64257
+ const agentsPkgRoot = dirname19(agentsPkgMain);
64258
+ const candidate = join100(agentsPkgRoot, "cleo-subagent");
64259
+ if (existsSync100(candidate)) {
64260
+ agentSourceDir = candidate;
64261
+ }
64262
+ } catch {
64263
+ }
64264
+ if (!agentSourceDir) {
64265
+ const packageRoot = getPackageRoot();
64266
+ const bundled = join100(packageRoot, "agents", "cleo-subagent");
64267
+ if (existsSync100(bundled)) {
64268
+ agentSourceDir = bundled;
64269
+ }
64270
+ }
64271
+ if (!agentSourceDir) {
62744
64272
  warnings.push("agents/cleo-subagent/ not found in package, skipping agent definition install");
62745
64273
  return;
62746
64274
  }
@@ -62754,7 +64282,7 @@ async function initAgentDefinition(created, warnings) {
62754
64282
  }
62755
64283
  } catch {
62756
64284
  }
62757
- await symlink(agentSourceDir, globalAgentsDir, "dir");
64285
+ await symlink(agentSourceDir, globalAgentsDir, DIR_SYMLINK_TYPE2);
62758
64286
  created.push("agent: cleo-subagent (symlinked)");
62759
64287
  } catch (_err) {
62760
64288
  try {
@@ -62813,17 +64341,29 @@ async function initCoreSkills(created, warnings) {
62813
64341
  const packageRoot = getPackageRoot();
62814
64342
  let ctSkillsRoot = null;
62815
64343
  try {
62816
- const bundledPath = join100(packageRoot, "packages", "skills");
62817
- if (existsSync100(join100(bundledPath, "skills.json"))) {
62818
- ctSkillsRoot = bundledPath;
62819
- } else {
62820
- const ctSkillsPath = join100(packageRoot, "node_modules", "@cleocode", "skills");
62821
- if (existsSync100(join100(ctSkillsPath, "skills.json"))) {
62822
- ctSkillsRoot = ctSkillsPath;
62823
- }
64344
+ const { createRequire: createRequire6 } = await import("node:module");
64345
+ const req = createRequire6(import.meta.url);
64346
+ const skillsPkgMain = req.resolve("@cleocode/skills/package.json");
64347
+ const skillsPkgRoot = dirname19(skillsPkgMain);
64348
+ if (existsSync100(join100(skillsPkgRoot, "skills.json"))) {
64349
+ ctSkillsRoot = skillsPkgRoot;
62824
64350
  }
62825
64351
  } catch {
62826
64352
  }
64353
+ if (!ctSkillsRoot) {
64354
+ try {
64355
+ const bundledPath = join100(packageRoot, "packages", "skills");
64356
+ if (existsSync100(join100(bundledPath, "skills.json"))) {
64357
+ ctSkillsRoot = bundledPath;
64358
+ } else {
64359
+ const ctSkillsPath = join100(packageRoot, "node_modules", "@cleocode", "skills");
64360
+ if (existsSync100(join100(ctSkillsPath, "skills.json"))) {
64361
+ ctSkillsRoot = ctSkillsPath;
64362
+ }
64363
+ }
64364
+ } catch {
64365
+ }
64366
+ }
62827
64367
  if (!ctSkillsRoot) {
62828
64368
  warnings.push("skills package not found, skipping core skill installation");
62829
64369
  return;
@@ -63115,7 +64655,6 @@ async function initProject(opts = {}) {
63115
64655
  warnings.push(`Contributor MCP setup: ${err instanceof Error ? err.message : String(err)}`);
63116
64656
  }
63117
64657
  await initAgentDefinition(created, warnings);
63118
- await initCoreSkills(created, warnings);
63119
64658
  await initNexusRegistration(projRoot, created, warnings);
63120
64659
  try {
63121
64660
  const { AdapterManager: AdapterManager2 } = await Promise.resolve().then(() => (init_adapters(), adapters_exports));
@@ -63202,6 +64741,7 @@ async function getVersion2(projectRoot) {
63202
64741
  }
63203
64742
  return { version: "0.0.0" };
63204
64743
  }
64744
+ var DIR_SYMLINK_TYPE2;
63205
64745
  var init_init = __esm({
63206
64746
  "packages/core/src/init.ts"() {
63207
64747
  "use strict";
@@ -63215,6 +64755,7 @@ var init_init = __esm({
63215
64755
  init_scaffold();
63216
64756
  init_schema_management();
63217
64757
  init_json2();
64758
+ DIR_SYMLINK_TYPE2 = platform4() === "win32" ? "junction" : "dir";
63218
64759
  }
63219
64760
  });
63220
64761
 
@@ -63237,7 +64778,7 @@ var init_context_alert = __esm({
63237
64778
  });
63238
64779
 
63239
64780
  // packages/core/src/output.ts
63240
- import { randomUUID as randomUUID5 } from "node:crypto";
64781
+ import { randomUUID as randomUUID6 } from "node:crypto";
63241
64782
  function pushWarning(warning) {
63242
64783
  pendingWarnings.push(warning);
63243
64784
  }
@@ -63254,7 +64795,7 @@ function createCliMeta(operation, mvi = "standard") {
63254
64795
  schemaVersion: "2026.2.1",
63255
64796
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
63256
64797
  operation,
63257
- requestId: randomUUID5(),
64798
+ requestId: randomUUID6(),
63258
64799
  transport: "cli",
63259
64800
  strict: true,
63260
64801
  mvi,
@@ -63630,6 +65171,7 @@ var init_cleo = __esm({
63630
65171
  // packages/core/src/index.ts
63631
65172
  var init_src2 = __esm({
63632
65173
  "packages/core/src/index.ts"() {
65174
+ "use strict";
63633
65175
  init_src();
63634
65176
  init_adapters();
63635
65177
  init_admin();
@@ -63786,7 +65328,8 @@ async function injectAgentsHub(ctx) {
63786
65328
  await writeFile12(globalAgentsMd, stripped, "utf8");
63787
65329
  }
63788
65330
  }
63789
- const action = await inject2(globalAgentsMd, "@~/.cleo/templates/CLEO-INJECTION.md");
65331
+ const expectedContent = "@~/.cleo/templates/CLEO-INJECTION.md";
65332
+ const action = await inject2(globalAgentsMd, expectedContent);
63790
65333
  ctx.created.push(`~/.agents/AGENTS.md (${action})`);
63791
65334
  } else {
63792
65335
  ctx.created.push("~/.agents/AGENTS.md (would create/update CAAMP block)");
@@ -65048,7 +66591,7 @@ var init_chain_validation = __esm({
65048
66591
  });
65049
66592
 
65050
66593
  // packages/core/src/lifecycle/chain-store.ts
65051
- import { randomUUID as randomUUID6 } from "node:crypto";
66594
+ import { randomUUID as randomUUID7 } from "node:crypto";
65052
66595
  async function addChain(chain, projectRoot) {
65053
66596
  const validation = validateChain(chain);
65054
66597
  if (validation.errors.length > 0) {
@@ -65087,7 +66630,7 @@ async function createInstance(params, projectRoot) {
65087
66630
  if (!chain) {
65088
66631
  throw new Error(`Chain "${params.chainId}" not found`);
65089
66632
  }
65090
- const id = `wci-${randomUUID6().slice(0, 8)}`;
66633
+ const id = `wci-${randomUUID7().slice(0, 8)}`;
65091
66634
  const now2 = (/* @__PURE__ */ new Date()).toISOString();
65092
66635
  const variables = params.variables ?? {};
65093
66636
  const stageToTask = params.stageToTask ?? {};
@@ -67392,7 +68935,7 @@ var init_model_provider_registry = __esm({
67392
68935
  });
67393
68936
 
67394
68937
  // packages/core/src/metrics/token-service.ts
67395
- import { createHash as createHash13, randomUUID as randomUUID7 } from "node:crypto";
68938
+ import { createHash as createHash13, randomUUID as randomUUID8 } from "node:crypto";
67396
68939
  import { existsSync as existsSync106, readdirSync as readdirSync34, readFileSync as readFileSync78 } from "node:fs";
67397
68940
  import { join as join105 } from "node:path";
67398
68941
  function normalizeProvider(provider, model, runtimeProvider) {
@@ -67645,7 +69188,7 @@ async function recordTokenExchange(input) {
67645
69188
  const measurement = await measureTokenExchange(input);
67646
69189
  const db = await getDb4(input.cwd);
67647
69190
  const row = {
67648
- id: randomUUID7(),
69191
+ id: randomUUID8(),
67649
69192
  provider: measurement.provider,
67650
69193
  model: measurement.model,
67651
69194
  transport: input.transport ?? "unknown",
@@ -67872,13 +69415,13 @@ var init_parallel = __esm({
67872
69415
  // packages/core/src/orchestration/skill-ops.ts
67873
69416
  import { existsSync as existsSync107, readdirSync as readdirSync35, readFileSync as readFileSync79 } from "node:fs";
67874
69417
  import { join as join106 } from "node:path";
67875
- import { getCanonicalSkillsDir as getCanonicalSkillsDir2 } from "@cleocode/caamp";
69418
+ import { getCanonicalSkillsDir as getCanonicalSkillsDir3 } from "@cleocode/caamp";
67876
69419
  function getSkillContent(skillName, projectRoot) {
67877
69420
  if (!skillName) {
67878
69421
  throw new CleoError(2 /* INVALID_INPUT */, "skill name is required");
67879
69422
  }
67880
69423
  const projectSkillDir = join106(projectRoot, ".cleo", "skills", skillName);
67881
- const canonicalSkillDir = join106(getCanonicalSkillsDir2(), skillName);
69424
+ const canonicalSkillDir = join106(getCanonicalSkillsDir3(), skillName);
67882
69425
  const skillDir = existsSync107(projectSkillDir) ? projectSkillDir : canonicalSkillDir;
67883
69426
  if (!existsSync107(skillDir)) {
67884
69427
  throw new CleoError(
@@ -68338,7 +69881,7 @@ async function validateAndRepairSequence(cwd, config2 = {}) {
68338
69881
  }
68339
69882
  const repair = await repairSequence(cwd);
68340
69883
  if (repair.repaired) {
68341
- log7.warn(
69884
+ log8.warn(
68342
69885
  { oldCounter: repair.oldCounter, newCounter: repair.newCounter },
68343
69886
  "Sequence repaired"
68344
69887
  );
@@ -68367,7 +69910,7 @@ async function triggerCheckpoint(context, cwd, config2 = {}) {
68367
69910
  try {
68368
69911
  await gitCheckpoint("auto", context, cwd);
68369
69912
  } catch (err) {
68370
- log7.warn({ err }, "Checkpoint failed (non-fatal)");
69913
+ log8.warn({ err }, "Checkpoint failed (non-fatal)");
68371
69914
  }
68372
69915
  vacuumIntoBackup({ cwd }).catch(() => {
68373
69916
  });
@@ -68405,16 +69948,16 @@ async function safeDeleteTask(deleteFn, taskId, cwd, config2 = {}) {
68405
69948
  return result;
68406
69949
  }
68407
69950
  async function forceCheckpointBeforeOperation(operation, cwd) {
68408
- log7.info({ operation }, "Forcing checkpoint before operation");
69951
+ log8.info({ operation }, "Forcing checkpoint before operation");
68409
69952
  try {
68410
69953
  await gitCheckpoint("manual", `pre-${operation}`, cwd);
68411
69954
  } catch (err) {
68412
- log7.error({ err }, "Failed to create pre-operation checkpoint");
69955
+ log8.error({ err }, "Failed to create pre-operation checkpoint");
68413
69956
  }
68414
69957
  vacuumIntoBackup({ cwd, force: true }).catch(() => {
68415
69958
  });
68416
69959
  }
68417
- var log7, DEFAULT_CONFIG2, SafetyError;
69960
+ var log8, DEFAULT_CONFIG2, SafetyError;
68418
69961
  var init_data_safety = __esm({
68419
69962
  "packages/core/src/store/data-safety.ts"() {
68420
69963
  "use strict";
@@ -68424,7 +69967,7 @@ var init_data_safety = __esm({
68424
69967
  init_sqlite2();
68425
69968
  init_sqlite_backup();
68426
69969
  init_tasks_schema();
68427
- log7 = getLogger("data-safety");
69970
+ log8 = getLogger("data-safety");
68428
69971
  DEFAULT_CONFIG2 = {
68429
69972
  verifyWrites: true,
68430
69973
  detectCollisions: true,
@@ -71949,7 +73492,7 @@ async function validateLayer2Semantic(context) {
71949
73492
  }
71950
73493
  if (context.domain === "session" && context.operation === "start") {
71951
73494
  const scope = context.params?.scope;
71952
- if (scope && !scope.match(/^(epic|task|global):/)) {
73495
+ if (scope && scope !== "global" && !scope.match(/^(epic|task):/)) {
71953
73496
  violations.push({
71954
73497
  layer: 2 /* SEMANTIC */,
71955
73498
  severity: "error" /* ERROR */,
@@ -71957,7 +73500,7 @@ async function validateLayer2Semantic(context) {
71957
73500
  message: `Invalid session scope format: ${scope}`,
71958
73501
  field: "scope",
71959
73502
  constraint: "Must be epic:<id>, task:<id>, or global",
71960
- fix: "Use format: epic:T1234, task:T5678, or global"
73503
+ fix: 'Provide scope as "global" or "epic:TXXX"'
71961
73504
  });
71962
73505
  }
71963
73506
  }
@@ -74283,6 +75826,7 @@ __export(internal_exports, {
74283
75826
  ensureProjectContext: () => ensureProjectContext,
74284
75827
  ensureSqliteDb: () => ensureSqliteDb,
74285
75828
  estimateContext: () => estimateContext,
75829
+ executeTransfer: () => executeTransfer,
74286
75830
  exportSnapshot: () => exportSnapshot,
74287
75831
  exportTasks: () => exportTasks,
74288
75832
  exportTasksPackage: () => exportTasksPackage,
@@ -74409,6 +75953,7 @@ __export(internal_exports, {
74409
75953
  gradeSession: () => gradeSession,
74410
75954
  heartbeat: () => heartbeat,
74411
75955
  hooks: () => hooks,
75956
+ importFromPackage: () => importFromPackage,
74412
75957
  importSnapshot: () => importSnapshot,
74413
75958
  importTasks: () => importTasks,
74414
75959
  importTasksPackage: () => importTasksPackage,
@@ -74552,6 +76097,7 @@ __export(internal_exports, {
74552
76097
  predictValidationOutcome: () => predictValidationOutcome,
74553
76098
  prepareRelease: () => prepareRelease,
74554
76099
  prepareSpawn: () => prepareSpawn,
76100
+ previewTransfer: () => previewTransfer,
74555
76101
  protocolEnforcer: () => protocolEnforcer,
74556
76102
  pruneAuditLog: () => pruneAuditLog,
74557
76103
  pull: () => pull,
@@ -74842,6 +76388,7 @@ var init_internal = __esm({
74842
76388
  init_session_memory();
74843
76389
  init_discover();
74844
76390
  init_registry3();
76391
+ init_transfer();
74845
76392
  init_analyze();
74846
76393
  init_critical_path();
74847
76394
  init_orchestration();
@@ -78461,10 +80008,10 @@ var StdioServerTransport = class {
78461
80008
 
78462
80009
  // packages/cleo/src/dispatch/adapters/mcp.ts
78463
80010
  init_src2();
78464
- import { randomUUID as randomUUID9 } from "node:crypto";
80011
+ import { randomUUID as randomUUID10 } from "node:crypto";
78465
80012
 
78466
80013
  // packages/cleo/src/dispatch/lib/meta.ts
78467
- import { randomUUID as randomUUID8 } from "node:crypto";
80014
+ import { randomUUID as randomUUID9 } from "node:crypto";
78468
80015
  function createDispatchMeta(gateway, domain2, operation, startTime, source = "mcp", requestId, sessionId) {
78469
80016
  return {
78470
80017
  gateway,
@@ -78473,7 +80020,7 @@ function createDispatchMeta(gateway, domain2, operation, startTime, source = "mc
78473
80020
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
78474
80021
  duration_ms: Date.now() - startTime,
78475
80022
  source,
78476
- requestId: requestId ?? randomUUID8(),
80023
+ requestId: requestId ?? randomUUID9(),
78477
80024
  ...sessionId != null && { sessionId }
78478
80025
  };
78479
80026
  }
@@ -81029,6 +82576,95 @@ var OPERATIONS = [
81029
82576
  requiredParams: []
81030
82577
  },
81031
82578
  // ---------------------------------------------------------------------------
82579
+ // nexus.transfer — Cross-project task transfer (T046)
82580
+ // ---------------------------------------------------------------------------
82581
+ {
82582
+ gateway: "query",
82583
+ domain: "nexus",
82584
+ operation: "transfer.preview",
82585
+ description: "nexus.transfer.preview (query) \u2014 preview a cross-project task transfer",
82586
+ tier: 2,
82587
+ idempotent: true,
82588
+ sessionRequired: false,
82589
+ requiredParams: ["taskIds", "sourceProject", "targetProject"],
82590
+ params: [
82591
+ { name: "taskIds", type: "array", required: true, description: "Task IDs to transfer" },
82592
+ {
82593
+ name: "sourceProject",
82594
+ type: "string",
82595
+ required: true,
82596
+ description: "Source project name or hash"
82597
+ },
82598
+ {
82599
+ name: "targetProject",
82600
+ type: "string",
82601
+ required: true,
82602
+ description: "Target project name or hash"
82603
+ },
82604
+ {
82605
+ name: "mode",
82606
+ type: "string",
82607
+ required: false,
82608
+ description: "Transfer mode: 'copy' (default) or 'move'"
82609
+ },
82610
+ {
82611
+ name: "scope",
82612
+ type: "string",
82613
+ required: false,
82614
+ description: "Transfer scope: 'subtree' (default) or 'single'"
82615
+ }
82616
+ ]
82617
+ },
82618
+ {
82619
+ gateway: "mutate",
82620
+ domain: "nexus",
82621
+ operation: "transfer",
82622
+ description: "nexus.transfer (mutate) \u2014 transfer tasks between NEXUS projects",
82623
+ tier: 2,
82624
+ idempotent: false,
82625
+ sessionRequired: false,
82626
+ requiredParams: ["taskIds", "sourceProject", "targetProject"],
82627
+ params: [
82628
+ { name: "taskIds", type: "array", required: true, description: "Task IDs to transfer" },
82629
+ {
82630
+ name: "sourceProject",
82631
+ type: "string",
82632
+ required: true,
82633
+ description: "Source project name or hash"
82634
+ },
82635
+ {
82636
+ name: "targetProject",
82637
+ type: "string",
82638
+ required: true,
82639
+ description: "Target project name or hash"
82640
+ },
82641
+ {
82642
+ name: "mode",
82643
+ type: "string",
82644
+ required: false,
82645
+ description: "Transfer mode: 'copy' (default) or 'move'"
82646
+ },
82647
+ {
82648
+ name: "scope",
82649
+ type: "string",
82650
+ required: false,
82651
+ description: "Transfer scope: 'subtree' (default) or 'single'"
82652
+ },
82653
+ {
82654
+ name: "onConflict",
82655
+ type: "string",
82656
+ required: false,
82657
+ description: "Conflict strategy: 'rename' (default), 'skip', 'duplicate', 'fail'"
82658
+ },
82659
+ {
82660
+ name: "transferBrain",
82661
+ type: "boolean",
82662
+ required: false,
82663
+ description: "Whether to transfer brain observations (default: false)"
82664
+ }
82665
+ ]
82666
+ },
82667
+ // ---------------------------------------------------------------------------
81032
82668
  // sticky — Ephemeral notes for quick capture (T5282)
81033
82669
  // ---------------------------------------------------------------------------
81034
82670
  // Query operations
@@ -83755,8 +85391,15 @@ async function taskList(projectRoot, params) {
83755
85391
  data: { tasks: tasks2, total: result.total, filtered: result.filtered },
83756
85392
  page: result.page
83757
85393
  };
83758
- } catch {
83759
- return engineError("E_NOT_INITIALIZED", "Task database not initialized");
85394
+ } catch (err) {
85395
+ const code = err?.code;
85396
+ if (code === 4) return engineError("E_NOT_FOUND", err.message || "Task not found");
85397
+ if (code === 2)
85398
+ return engineError("E_INVALID_INPUT", err.message || "Invalid input");
85399
+ return engineError(
85400
+ "E_NOT_INITIALIZED",
85401
+ err.message || "Task database not initialized"
85402
+ );
83760
85403
  }
83761
85404
  }
83762
85405
  async function taskFind(projectRoot, query, limit, options) {
@@ -83783,8 +85426,15 @@ async function taskFind(projectRoot, query, limit, options) {
83783
85426
  parentId: r.parentId
83784
85427
  }));
83785
85428
  return { success: true, data: { results, total: results.length } };
83786
- } catch {
83787
- return engineError("E_NOT_INITIALIZED", "Task database not initialized");
85429
+ } catch (err) {
85430
+ const code = err?.code;
85431
+ if (code === 4) return engineError("E_NOT_FOUND", err.message || "Task not found");
85432
+ if (code === 2)
85433
+ return engineError("E_INVALID_INPUT", err.message || "Invalid input");
85434
+ return engineError(
85435
+ "E_NOT_INITIALIZED",
85436
+ err.message || "Task database not initialized"
85437
+ );
83788
85438
  }
83789
85439
  }
83790
85440
  async function taskCreate(projectRoot, params) {
@@ -84715,54 +86365,42 @@ function routeByParam(params, paramName, routes, defaultRoute) {
84715
86365
 
84716
86366
  // packages/cleo/src/dispatch/domains/admin.ts
84717
86367
  var AdminHandler = class {
84718
- projectRoot;
84719
- constructor() {
84720
- this.projectRoot = getProjectRoot();
84721
- }
84722
86368
  // -----------------------------------------------------------------------
84723
86369
  // Query
84724
86370
  // -----------------------------------------------------------------------
84725
86371
  async query(operation, params) {
86372
+ const projectRoot = getProjectRoot();
84726
86373
  const startTime = Date.now();
84727
86374
  try {
84728
86375
  switch (operation) {
84729
86376
  case "version": {
84730
- const result = await getVersion3(this.projectRoot);
86377
+ const result = await getVersion3(projectRoot);
84731
86378
  return wrapResult(result, "query", "admin", operation, startTime);
84732
86379
  }
84733
86380
  case "health": {
84734
86381
  const mode = params?.mode;
84735
86382
  if (mode === "diagnose") {
84736
- const result2 = await systemDoctor(this.projectRoot);
86383
+ const result2 = await systemDoctor(projectRoot);
84737
86384
  return wrapResult(result2, "query", "admin", operation, startTime);
84738
86385
  }
84739
- const result = systemHealth(
84740
- this.projectRoot,
84741
- params
84742
- );
86386
+ const result = systemHealth(projectRoot, params);
84743
86387
  return wrapResult(result, "query", "admin", operation, startTime);
84744
86388
  }
84745
86389
  case "config.show": {
84746
- const result = await configGet(this.projectRoot, params?.key);
86390
+ const result = await configGet(projectRoot, params?.key);
84747
86391
  return wrapResult(result, "query", "admin", operation, startTime);
84748
86392
  }
84749
86393
  case "stats": {
84750
- const result = await systemStats(
84751
- this.projectRoot,
84752
- params
84753
- );
86394
+ const result = await systemStats(projectRoot, params);
84754
86395
  return wrapResult(result, "query", "admin", operation, startTime);
84755
86396
  }
84756
86397
  case "context": {
84757
- const result = systemContext(
84758
- this.projectRoot,
84759
- params
84760
- );
86398
+ const result = systemContext(projectRoot, params);
84761
86399
  return wrapResult(result, "query", "admin", operation, startTime);
84762
86400
  }
84763
86401
  case "runtime": {
84764
86402
  const result = await systemRuntime(
84765
- this.projectRoot,
86403
+ projectRoot,
84766
86404
  params
84767
86405
  );
84768
86406
  return wrapResult(result, "query", "admin", operation, startTime);
@@ -84857,12 +86495,12 @@ var AdminHandler = class {
84857
86495
  }
84858
86496
  case "dash": {
84859
86497
  const blockedTasksLimit = typeof params?.blockedTasksLimit === "number" ? params.blockedTasksLimit : void 0;
84860
- const result = await systemDash(this.projectRoot, { blockedTasksLimit });
86498
+ const result = await systemDash(projectRoot, { blockedTasksLimit });
84861
86499
  return wrapResult(result, "query", "admin", operation, startTime);
84862
86500
  }
84863
86501
  case "log": {
84864
86502
  const result = await systemLog(
84865
- this.projectRoot,
86503
+ projectRoot,
84866
86504
  params
84867
86505
  );
84868
86506
  return wrapResult(result, "query", "admin", operation, startTime);
@@ -84879,7 +86517,7 @@ var AdminHandler = class {
84879
86517
  startTime
84880
86518
  );
84881
86519
  }
84882
- const result = await systemSequence(this.projectRoot, {
86520
+ const result = await systemSequence(projectRoot, {
84883
86521
  action
84884
86522
  });
84885
86523
  return wrapResult(result, "query", "admin", operation, startTime);
@@ -84897,7 +86535,7 @@ var AdminHandler = class {
84897
86535
  case "adr.find": {
84898
86536
  const query = params?.query;
84899
86537
  if (query) {
84900
- const result2 = await findAdrs(this.projectRoot, query, {
86538
+ const result2 = await findAdrs(projectRoot, query, {
84901
86539
  topics: params?.topics,
84902
86540
  keywords: params?.keywords,
84903
86541
  status: params?.status
@@ -84909,7 +86547,7 @@ var AdminHandler = class {
84909
86547
  };
84910
86548
  }
84911
86549
  const { limit, offset } = getListParams(params);
84912
- const result = await listAdrs(this.projectRoot, {
86550
+ const result = await listAdrs(projectRoot, {
84913
86551
  status: params?.status,
84914
86552
  since: params?.since,
84915
86553
  limit,
@@ -84934,7 +86572,7 @@ var AdminHandler = class {
84934
86572
  startTime
84935
86573
  );
84936
86574
  }
84937
- const adr = await showAdr(this.projectRoot, adrId);
86575
+ const adr = await showAdr(projectRoot, adrId);
84938
86576
  if (!adr) {
84939
86577
  return errorResult(
84940
86578
  "query",
@@ -84973,7 +86611,7 @@ var AdminHandler = class {
84973
86611
  since: params?.since,
84974
86612
  until: params?.until
84975
86613
  },
84976
- this.projectRoot
86614
+ projectRoot
84977
86615
  );
84978
86616
  return {
84979
86617
  _meta: dispatchMeta("query", "admin", operation, startTime),
@@ -85000,7 +86638,7 @@ var AdminHandler = class {
85000
86638
  limit,
85001
86639
  offset
85002
86640
  },
85003
- this.projectRoot
86641
+ projectRoot
85004
86642
  );
85005
86643
  return {
85006
86644
  _meta: dispatchMeta("query", "admin", operation, startTime),
@@ -85025,7 +86663,7 @@ var AdminHandler = class {
85025
86663
  startTime
85026
86664
  );
85027
86665
  }
85028
- const result = await showTokenUsage(tokenId, this.projectRoot);
86666
+ const result = await showTokenUsage(tokenId, projectRoot);
85029
86667
  if (!result) {
85030
86668
  return errorResult(
85031
86669
  "query",
@@ -85050,8 +86688,8 @@ var AdminHandler = class {
85050
86688
  case "export": {
85051
86689
  const scope = params?.scope;
85052
86690
  if (scope === "snapshot") {
85053
- const snapshot = await exportSnapshot(this.projectRoot);
85054
- const outputPath = params?.output ?? getDefaultSnapshotPath(this.projectRoot);
86691
+ const snapshot = await exportSnapshot(projectRoot);
86692
+ const outputPath = params?.output ?? getDefaultSnapshotPath(projectRoot);
85055
86693
  await writeSnapshot(snapshot, outputPath);
85056
86694
  return {
85057
86695
  _meta: dispatchMeta("query", "admin", operation, startTime),
@@ -85072,7 +86710,7 @@ var AdminHandler = class {
85072
86710
  filter: params?.filter,
85073
86711
  includeDeps: params?.includeDeps,
85074
86712
  dryRun: params?.dryRun,
85075
- cwd: this.projectRoot
86713
+ cwd: projectRoot
85076
86714
  });
85077
86715
  return {
85078
86716
  _meta: dispatchMeta("query", "admin", operation, startTime),
@@ -85086,7 +86724,7 @@ var AdminHandler = class {
85086
86724
  status: params?.status,
85087
86725
  parent: params?.parent,
85088
86726
  phase: params?.phase,
85089
- cwd: this.projectRoot
86727
+ cwd: projectRoot
85090
86728
  });
85091
86729
  return {
85092
86730
  _meta: dispatchMeta("query", "admin", operation, startTime),
@@ -85096,7 +86734,7 @@ var AdminHandler = class {
85096
86734
  }
85097
86735
  case "map": {
85098
86736
  const { mapCodebase: mapCodebase3 } = await Promise.resolve().then(() => (init_codebase_map_engine(), codebase_map_engine_exports));
85099
- const result = await mapCodebase3(this.projectRoot, {
86737
+ const result = await mapCodebase3(projectRoot, {
85100
86738
  focus: params?.focus,
85101
86739
  storeToBrain: false
85102
86740
  });
@@ -85117,12 +86755,13 @@ var AdminHandler = class {
85117
86755
  // Mutate
85118
86756
  // -----------------------------------------------------------------------
85119
86757
  async mutate(operation, params) {
86758
+ const projectRoot = getProjectRoot();
85120
86759
  const startTime = Date.now();
85121
86760
  try {
85122
86761
  switch (operation) {
85123
86762
  case "init": {
85124
86763
  const result = await initProject2(
85125
- this.projectRoot,
86764
+ projectRoot,
85126
86765
  params
85127
86766
  );
85128
86767
  return wrapResult(result, "mutate", "admin", operation, startTime);
@@ -85131,10 +86770,10 @@ var AdminHandler = class {
85131
86770
  case "health": {
85132
86771
  const mode = params?.mode;
85133
86772
  if (mode === "diagnose") {
85134
- const result2 = await systemDoctor(this.projectRoot);
86773
+ const result2 = await systemDoctor(projectRoot);
85135
86774
  return wrapResult(result2, "mutate", "admin", operation, startTime);
85136
86775
  }
85137
- const result = await systemFix(this.projectRoot);
86776
+ const result = await systemFix(projectRoot);
85138
86777
  return wrapResult(result, "mutate", "admin", operation, startTime);
85139
86778
  }
85140
86779
  case "config.set": {
@@ -85149,7 +86788,7 @@ var AdminHandler = class {
85149
86788
  startTime
85150
86789
  );
85151
86790
  }
85152
- const result = await configSet(this.projectRoot, key, params?.value);
86791
+ const result = await configSet(projectRoot, key, params?.value);
85153
86792
  return wrapResult(result, "mutate", "admin", operation, startTime);
85154
86793
  }
85155
86794
  // Merged: backup absorbs restore and backup.restore via action param (T5615)
@@ -85167,7 +86806,7 @@ var AdminHandler = class {
85167
86806
  startTime
85168
86807
  );
85169
86808
  }
85170
- const result2 = systemRestore(this.projectRoot, {
86809
+ const result2 = systemRestore(projectRoot, {
85171
86810
  backupId,
85172
86811
  force: params?.force
85173
86812
  });
@@ -85185,20 +86824,20 @@ var AdminHandler = class {
85185
86824
  startTime
85186
86825
  );
85187
86826
  }
85188
- const result2 = await backupRestore(this.projectRoot, file2, {
86827
+ const result2 = await backupRestore(projectRoot, file2, {
85189
86828
  dryRun: params?.dryRun
85190
86829
  });
85191
86830
  return wrapResult(result2, "mutate", "admin", operation, startTime);
85192
86831
  }
85193
86832
  const result = systemBackup(
85194
- this.projectRoot,
86833
+ projectRoot,
85195
86834
  params
85196
86835
  );
85197
86836
  return wrapResult(result, "mutate", "admin", operation, startTime);
85198
86837
  }
85199
86838
  case "migrate": {
85200
86839
  const result = await systemMigrate(
85201
- this.projectRoot,
86840
+ projectRoot,
85202
86841
  params
85203
86842
  );
85204
86843
  return wrapResult(result, "mutate", "admin", operation, startTime);
@@ -85215,7 +86854,7 @@ var AdminHandler = class {
85215
86854
  startTime
85216
86855
  );
85217
86856
  }
85218
- const result = await systemCleanup(this.projectRoot, {
86857
+ const result = await systemCleanup(projectRoot, {
85219
86858
  target,
85220
86859
  olderThan: params?.olderThan,
85221
86860
  dryRun: params?.dryRun
@@ -85267,20 +86906,20 @@ var AdminHandler = class {
85267
86906
  }
85268
86907
  case "safestop": {
85269
86908
  const result = systemSafestop(
85270
- this.projectRoot,
86909
+ projectRoot,
85271
86910
  params
85272
86911
  );
85273
86912
  return wrapResult(result, "mutate", "admin", operation, startTime);
85274
86913
  }
85275
86914
  case "inject.generate": {
85276
- const result = await systemInjectGenerate(this.projectRoot);
86915
+ const result = await systemInjectGenerate(projectRoot);
85277
86916
  return wrapResult(result, "mutate", "admin", operation, startTime);
85278
86917
  }
85279
86918
  // adr.sync absorbs adr.validate via validate flag (T5615)
85280
86919
  case "adr.sync": {
85281
86920
  const validate = params?.validate;
85282
86921
  if (validate) {
85283
- const result2 = await validateAllAdrs(this.projectRoot);
86922
+ const result2 = await validateAllAdrs(projectRoot);
85284
86923
  return {
85285
86924
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
85286
86925
  success: result2.valid,
@@ -85293,7 +86932,7 @@ var AdminHandler = class {
85293
86932
  }
85294
86933
  };
85295
86934
  }
85296
- const result = await syncAdrsToDb(this.projectRoot);
86935
+ const result = await syncAdrsToDb(projectRoot);
85297
86936
  return {
85298
86937
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
85299
86938
  success: true,
@@ -85328,7 +86967,7 @@ var AdminHandler = class {
85328
86967
  }
85329
86968
  };
85330
86969
  }
85331
- const result2 = await importSnapshot(snapshot, this.projectRoot);
86970
+ const result2 = await importSnapshot(snapshot, projectRoot);
85332
86971
  return {
85333
86972
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
85334
86973
  success: true,
@@ -85364,7 +87003,7 @@ var AdminHandler = class {
85364
87003
  onConflict: params?.onConflict,
85365
87004
  onMissingDep: params?.onMissingDep,
85366
87005
  force: params?.force,
85367
- cwd: this.projectRoot
87006
+ cwd: projectRoot
85368
87007
  });
85369
87008
  return {
85370
87009
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
@@ -85390,7 +87029,7 @@ var AdminHandler = class {
85390
87029
  onDuplicate: params?.onDuplicate,
85391
87030
  addLabel: params?.addLabel,
85392
87031
  dryRun: params?.dryRun,
85393
- cwd: this.projectRoot
87032
+ cwd: projectRoot
85394
87033
  });
85395
87034
  return {
85396
87035
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
@@ -85400,8 +87039,8 @@ var AdminHandler = class {
85400
87039
  }
85401
87040
  case "detect": {
85402
87041
  const { ensureProjectContext: ensureProjectContext2, ensureContributorMcp: ensureContributorMcp2 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
85403
- const contextResult = await ensureProjectContext2(this.projectRoot, { force: true });
85404
- const mcpResult = await ensureContributorMcp2(this.projectRoot);
87042
+ const contextResult = await ensureProjectContext2(projectRoot, { force: true });
87043
+ const mcpResult = await ensureContributorMcp2(projectRoot);
85405
87044
  return wrapResult(
85406
87045
  {
85407
87046
  success: true,
@@ -85433,7 +87072,7 @@ var AdminHandler = class {
85433
87072
  requestPayload: params?.requestPayload,
85434
87073
  responsePayload: params?.responsePayload,
85435
87074
  metadata: params?.metadata,
85436
- cwd: this.projectRoot
87075
+ cwd: projectRoot
85437
87076
  });
85438
87077
  return {
85439
87078
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
@@ -85453,7 +87092,7 @@ var AdminHandler = class {
85453
87092
  startTime
85454
87093
  );
85455
87094
  }
85456
- const result = await deleteTokenUsage(tokenId, this.projectRoot);
87095
+ const result = await deleteTokenUsage(tokenId, projectRoot);
85457
87096
  return {
85458
87097
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
85459
87098
  success: true,
@@ -85476,7 +87115,7 @@ var AdminHandler = class {
85476
87115
  since: params?.since,
85477
87116
  until: params?.until
85478
87117
  },
85479
- this.projectRoot
87118
+ projectRoot
85480
87119
  );
85481
87120
  return {
85482
87121
  _meta: dispatchMeta("mutate", "admin", operation, startTime),
@@ -85507,13 +87146,13 @@ var AdminHandler = class {
85507
87146
  taskId: params?.taskId,
85508
87147
  variant: params?.variant
85509
87148
  },
85510
- this.projectRoot
87149
+ projectRoot
85511
87150
  );
85512
87151
  return wrapResult(result, "mutate", "admin", operation, startTime);
85513
87152
  }
85514
87153
  case "map": {
85515
87154
  const { mapCodebase: mapCodebase3 } = await Promise.resolve().then(() => (init_codebase_map_engine(), codebase_map_engine_exports));
85516
- const result = await mapCodebase3(this.projectRoot, {
87155
+ const result = await mapCodebase3(projectRoot, {
85517
87156
  focus: params?.focus,
85518
87157
  storeToBrain: true
85519
87158
  });
@@ -85594,14 +87233,11 @@ var AdminHandler = class {
85594
87233
  // packages/cleo/src/dispatch/domains/check.ts
85595
87234
  init_internal();
85596
87235
  var CheckHandler = class {
85597
- projectRoot;
85598
- constructor() {
85599
- this.projectRoot = getProjectRoot();
85600
- }
85601
87236
  // -----------------------------------------------------------------------
85602
87237
  // Query
85603
87238
  // -----------------------------------------------------------------------
85604
87239
  async query(operation, params) {
87240
+ const projectRoot = getProjectRoot();
85605
87241
  const startTime = Date.now();
85606
87242
  try {
85607
87243
  switch (operation) {
@@ -85617,7 +87253,7 @@ var CheckHandler = class {
85617
87253
  startTime
85618
87254
  );
85619
87255
  }
85620
- const result = validateSchemaOp(type, params?.data, this.projectRoot);
87256
+ const result = validateSchemaOp(type, params?.data, projectRoot);
85621
87257
  return wrapResult(result, "query", "check", operation, startTime);
85622
87258
  }
85623
87259
  case "task": {
@@ -85632,11 +87268,11 @@ var CheckHandler = class {
85632
87268
  startTime
85633
87269
  );
85634
87270
  }
85635
- const result = await validateTask2(taskId, this.projectRoot);
87271
+ const result = await validateTask2(taskId, projectRoot);
85636
87272
  return wrapResult(result, "query", "check", operation, startTime);
85637
87273
  }
85638
87274
  case "manifest": {
85639
- const result = validateManifest(this.projectRoot);
87275
+ const result = validateManifest(projectRoot);
85640
87276
  return wrapResult(result, "query", "check", operation, startTime);
85641
87277
  }
85642
87278
  case "output": {
@@ -85654,7 +87290,7 @@ var CheckHandler = class {
85654
87290
  const result = validateOutput(
85655
87291
  filePath,
85656
87292
  params?.taskId,
85657
- this.projectRoot
87293
+ projectRoot
85658
87294
  );
85659
87295
  return wrapResult(result, "query", "check", operation, startTime);
85660
87296
  }
@@ -85662,23 +87298,23 @@ var CheckHandler = class {
85662
87298
  const detail = params?.detail;
85663
87299
  const limit = params?.limit;
85664
87300
  if (detail) {
85665
- const result2 = validateComplianceViolations(limit, this.projectRoot);
87301
+ const result2 = validateComplianceViolations(limit, projectRoot);
85666
87302
  return wrapResult(result2, "query", "check", operation, startTime);
85667
87303
  }
85668
- const result = validateComplianceSummary(this.projectRoot);
87304
+ const result = validateComplianceSummary(projectRoot);
85669
87305
  return wrapResult(result, "query", "check", operation, startTime);
85670
87306
  }
85671
87307
  case "test": {
85672
87308
  const format = params?.format;
85673
87309
  if (format === "coverage") {
85674
- const result2 = validateTestCoverage(this.projectRoot);
87310
+ const result2 = validateTestCoverage(projectRoot);
85675
87311
  return wrapResult(result2, "query", "check", operation, startTime);
85676
87312
  }
85677
- const result = validateTestStatus(this.projectRoot);
87313
+ const result = validateTestStatus(projectRoot);
85678
87314
  return wrapResult(result, "query", "check", operation, startTime);
85679
87315
  }
85680
87316
  case "coherence": {
85681
- const result = await validateCoherenceCheck(this.projectRoot);
87317
+ const result = await validateCoherenceCheck(projectRoot);
85682
87318
  return wrapResult(result, "query", "check", operation, startTime);
85683
87319
  }
85684
87320
  case "protocol": {
@@ -85697,12 +87333,12 @@ var CheckHandler = class {
85697
87333
  ...protocolParams,
85698
87334
  votingMatrixFile: params?.votingMatrixFile
85699
87335
  },
85700
- this.projectRoot
87336
+ projectRoot
85701
87337
  );
85702
87338
  return wrapResult(result, "query", "check", operation, startTime);
85703
87339
  }
85704
87340
  case "contribution": {
85705
- const result = await validateProtocolContribution(protocolParams, this.projectRoot);
87341
+ const result = await validateProtocolContribution(protocolParams, projectRoot);
85706
87342
  return wrapResult(result, "query", "check", operation, startTime);
85707
87343
  }
85708
87344
  case "decomposition": {
@@ -85711,12 +87347,12 @@ var CheckHandler = class {
85711
87347
  ...protocolParams,
85712
87348
  epicId: params?.epicId
85713
87349
  },
85714
- this.projectRoot
87350
+ projectRoot
85715
87351
  );
85716
87352
  return wrapResult(result, "query", "check", operation, startTime);
85717
87353
  }
85718
87354
  case "implementation": {
85719
- const result = await validateProtocolImplementation(protocolParams, this.projectRoot);
87355
+ const result = await validateProtocolImplementation(protocolParams, projectRoot);
85720
87356
  return wrapResult(result, "query", "check", operation, startTime);
85721
87357
  }
85722
87358
  case "specification": {
@@ -85725,7 +87361,7 @@ var CheckHandler = class {
85725
87361
  ...protocolParams,
85726
87362
  specFile: params?.specFile
85727
87363
  },
85728
- this.projectRoot
87364
+ projectRoot
85729
87365
  );
85730
87366
  return wrapResult(result, "query", "check", operation, startTime);
85731
87367
  }
@@ -85741,7 +87377,7 @@ var CheckHandler = class {
85741
87377
  startTime
85742
87378
  );
85743
87379
  }
85744
- const result = await validateProtocol(taskId, protocolType, this.projectRoot);
87380
+ const result = await validateProtocol(taskId, protocolType, projectRoot);
85745
87381
  return wrapResult(result, "query", "check", operation, startTime);
85746
87382
  }
85747
87383
  }
@@ -85758,11 +87394,11 @@ var CheckHandler = class {
85758
87394
  startTime
85759
87395
  );
85760
87396
  }
85761
- const result = await validateGateVerify({ taskId }, this.projectRoot);
87397
+ const result = await validateGateVerify({ taskId }, projectRoot);
85762
87398
  return wrapResult(result, "query", "check", operation, startTime);
85763
87399
  }
85764
87400
  case "archive.stats": {
85765
- const result = await systemArchiveStats(this.projectRoot);
87401
+ const result = await systemArchiveStats(projectRoot);
85766
87402
  return wrapResult(result, "query", "check", operation, startTime);
85767
87403
  }
85768
87404
  // T5405: WarpChain validation
@@ -85801,7 +87437,7 @@ var CheckHandler = class {
85801
87437
  startTime
85802
87438
  );
85803
87439
  }
85804
- const gradeResult = await gradeSession2(sessionId, this.projectRoot);
87440
+ const gradeResult = await gradeSession2(sessionId, projectRoot);
85805
87441
  return wrapResult(
85806
87442
  { success: true, data: gradeResult },
85807
87443
  "query",
@@ -85814,7 +87450,7 @@ var CheckHandler = class {
85814
87450
  const { readGrades: readGrades2 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
85815
87451
  const limit = typeof params?.limit === "number" ? params.limit : void 0;
85816
87452
  const offset = typeof params?.offset === "number" ? params.offset : void 0;
85817
- const allGrades = await readGrades2(void 0, this.projectRoot);
87453
+ const allGrades = await readGrades2(void 0, projectRoot);
85818
87454
  const sessionId = params?.sessionId;
85819
87455
  const filteredGrades = sessionId ? allGrades.filter((g) => g.sessionId === sessionId) : allGrades;
85820
87456
  const page = paginate(filteredGrades, limit, offset);
@@ -85845,6 +87481,7 @@ var CheckHandler = class {
85845
87481
  // Mutate
85846
87482
  // -----------------------------------------------------------------------
85847
87483
  async mutate(operation, params) {
87484
+ const projectRoot = getProjectRoot();
85848
87485
  const startTime = Date.now();
85849
87486
  try {
85850
87487
  switch (operation) {
@@ -85866,14 +87503,14 @@ var CheckHandler = class {
85866
87503
  result,
85867
87504
  params?.protocol,
85868
87505
  params?.violations,
85869
- this.projectRoot
87506
+ projectRoot
85870
87507
  );
85871
87508
  return wrapResult(engineResult, "mutate", "check", operation, startTime);
85872
87509
  }
85873
87510
  case "test.run": {
85874
87511
  const result = validateTestRun(
85875
87512
  params,
85876
- this.projectRoot
87513
+ projectRoot
85877
87514
  );
85878
87515
  return wrapResult(result, "mutate", "check", operation, startTime);
85879
87516
  }
@@ -85881,7 +87518,7 @@ var CheckHandler = class {
85881
87518
  const { syncComplianceMetrics: syncComplianceMetrics2 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
85882
87519
  const result = await syncComplianceMetrics2({
85883
87520
  force: params?.force,
85884
- cwd: this.projectRoot
87521
+ cwd: projectRoot
85885
87522
  });
85886
87523
  return {
85887
87524
  _meta: dispatchMeta("mutate", "check", operation, startTime),
@@ -85909,7 +87546,7 @@ var CheckHandler = class {
85909
87546
  all: params?.all,
85910
87547
  reset: params?.reset
85911
87548
  };
85912
- const result = await validateGateVerify(gateParams, this.projectRoot);
87549
+ const result = await validateGateVerify(gateParams, projectRoot);
85913
87550
  return wrapResult(result, "mutate", "check", operation, startTime);
85914
87551
  }
85915
87552
  default:
@@ -85952,14 +87589,11 @@ var CheckHandler = class {
85952
87589
  // packages/cleo/src/dispatch/domains/memory.ts
85953
87590
  init_src2();
85954
87591
  var MemoryHandler = class {
85955
- projectRoot;
85956
- constructor() {
85957
- this.projectRoot = getProjectRoot();
85958
- }
85959
87592
  // -----------------------------------------------------------------------
85960
87593
  // Query
85961
87594
  // -----------------------------------------------------------------------
85962
87595
  async query(operation, params) {
87596
+ const projectRoot = getProjectRoot();
85963
87597
  const startTime = Date.now();
85964
87598
  try {
85965
87599
  switch (operation) {
@@ -85983,7 +87617,7 @@ var MemoryHandler = class {
85983
87617
  dateStart: params?.dateStart,
85984
87618
  dateEnd: params?.dateEnd
85985
87619
  },
85986
- this.projectRoot
87620
+ projectRoot
85987
87621
  );
85988
87622
  return wrapResult(result, "query", "memory", operation, startTime);
85989
87623
  }
@@ -86005,7 +87639,7 @@ var MemoryHandler = class {
86005
87639
  depthBefore: params?.depthBefore,
86006
87640
  depthAfter: params?.depthAfter
86007
87641
  },
86008
- this.projectRoot
87642
+ projectRoot
86009
87643
  );
86010
87644
  return wrapResult(result, "query", "memory", operation, startTime);
86011
87645
  }
@@ -86021,7 +87655,7 @@ var MemoryHandler = class {
86021
87655
  startTime
86022
87656
  );
86023
87657
  }
86024
- const result = await memoryFetch({ ids }, this.projectRoot);
87658
+ const result = await memoryFetch({ ids }, projectRoot);
86025
87659
  return wrapResult(result, "query", "memory", operation, startTime);
86026
87660
  }
86027
87661
  case "decision.find": {
@@ -86031,7 +87665,7 @@ var MemoryHandler = class {
86031
87665
  taskId: params?.taskId,
86032
87666
  limit: params?.limit
86033
87667
  },
86034
- this.projectRoot
87668
+ projectRoot
86035
87669
  );
86036
87670
  return wrapResult(result, "query", "memory", operation, startTime);
86037
87671
  }
@@ -86044,7 +87678,7 @@ var MemoryHandler = class {
86044
87678
  minFrequency: params?.minFrequency,
86045
87679
  limit: params?.limit
86046
87680
  },
86047
- this.projectRoot
87681
+ projectRoot
86048
87682
  );
86049
87683
  return wrapResult(result, "query", "memory", operation, startTime);
86050
87684
  }
@@ -86057,7 +87691,7 @@ var MemoryHandler = class {
86057
87691
  applicableType: params?.applicableType,
86058
87692
  limit: params?.limit
86059
87693
  },
86060
- this.projectRoot
87694
+ projectRoot
86061
87695
  );
86062
87696
  return wrapResult(result, "query", "memory", operation, startTime);
86063
87697
  }
@@ -86073,7 +87707,7 @@ var MemoryHandler = class {
86073
87707
  startTime
86074
87708
  );
86075
87709
  }
86076
- const result = await memoryGraphShow({ nodeId }, this.projectRoot);
87710
+ const result = await memoryGraphShow({ nodeId }, projectRoot);
86077
87711
  return wrapResult(result, "query", "memory", operation, startTime);
86078
87712
  }
86079
87713
  case "graph.neighbors": {
@@ -86090,7 +87724,7 @@ var MemoryHandler = class {
86090
87724
  }
86091
87725
  const result = await memoryGraphNeighbors(
86092
87726
  { nodeId, edgeType: params?.edgeType },
86093
- this.projectRoot
87727
+ projectRoot
86094
87728
  );
86095
87729
  return wrapResult(result, "query", "memory", operation, startTime);
86096
87730
  }
@@ -86106,7 +87740,7 @@ var MemoryHandler = class {
86106
87740
  startTime
86107
87741
  );
86108
87742
  }
86109
- const result = await memoryReasonWhy({ taskId }, this.projectRoot);
87743
+ const result = await memoryReasonWhy({ taskId }, projectRoot);
86110
87744
  return wrapResult(result, "query", "memory", operation, startTime);
86111
87745
  }
86112
87746
  case "reason.similar": {
@@ -86123,7 +87757,7 @@ var MemoryHandler = class {
86123
87757
  }
86124
87758
  const result = await memoryReasonSimilar(
86125
87759
  { entryId, limit: params?.limit },
86126
- this.projectRoot
87760
+ projectRoot
86127
87761
  );
86128
87762
  return wrapResult(result, "query", "memory", operation, startTime);
86129
87763
  }
@@ -86147,7 +87781,7 @@ var MemoryHandler = class {
86147
87781
  graphWeight: params?.graphWeight,
86148
87782
  limit: params?.limit
86149
87783
  },
86150
- this.projectRoot
87784
+ projectRoot
86151
87785
  );
86152
87786
  return wrapResult(result, "query", "memory", operation, startTime);
86153
87787
  }
@@ -86167,6 +87801,7 @@ var MemoryHandler = class {
86167
87801
  // Mutate
86168
87802
  // -----------------------------------------------------------------------
86169
87803
  async mutate(operation, params) {
87804
+ const projectRoot = getProjectRoot();
86170
87805
  const startTime = Date.now();
86171
87806
  try {
86172
87807
  switch (operation) {
@@ -86191,7 +87826,7 @@ var MemoryHandler = class {
86191
87826
  sourceSessionId: params?.sourceSessionId,
86192
87827
  sourceType: params?.sourceType
86193
87828
  },
86194
- this.projectRoot
87829
+ projectRoot
86195
87830
  );
86196
87831
  return wrapResult(result, "mutate", "memory", operation, startTime);
86197
87832
  }
@@ -86216,7 +87851,7 @@ var MemoryHandler = class {
86216
87851
  taskId: params?.taskId,
86217
87852
  sessionId: params?.sessionId
86218
87853
  },
86219
- this.projectRoot
87854
+ projectRoot
86220
87855
  );
86221
87856
  return wrapResult(result, "mutate", "memory", operation, startTime);
86222
87857
  }
@@ -86244,7 +87879,7 @@ var MemoryHandler = class {
86244
87879
  examples: params?.examples,
86245
87880
  successRate: params?.successRate
86246
87881
  },
86247
- this.projectRoot
87882
+ projectRoot
86248
87883
  );
86249
87884
  return wrapResult(result, "mutate", "memory", operation, startTime);
86250
87885
  }
@@ -86270,7 +87905,7 @@ var MemoryHandler = class {
86270
87905
  application: params?.application,
86271
87906
  applicableTypes: params?.applicableTypes
86272
87907
  },
86273
- this.projectRoot
87908
+ projectRoot
86274
87909
  );
86275
87910
  return wrapResult(result, "mutate", "memory", operation, startTime);
86276
87911
  }
@@ -86287,7 +87922,7 @@ var MemoryHandler = class {
86287
87922
  startTime
86288
87923
  );
86289
87924
  }
86290
- const result = await memoryLink({ taskId, entryId }, this.projectRoot);
87925
+ const result = await memoryLink({ taskId, entryId }, projectRoot);
86291
87926
  return wrapResult(result, "mutate", "memory", operation, startTime);
86292
87927
  }
86293
87928
  case "graph.add": {
@@ -86302,7 +87937,7 @@ var MemoryHandler = class {
86302
87937
  edgeType: params?.edgeType,
86303
87938
  weight: params?.weight
86304
87939
  },
86305
- this.projectRoot
87940
+ projectRoot
86306
87941
  );
86307
87942
  return wrapResult(result, "mutate", "memory", operation, startTime);
86308
87943
  }
@@ -86314,7 +87949,7 @@ var MemoryHandler = class {
86314
87949
  toId: params?.toId,
86315
87950
  edgeType: params?.edgeType
86316
87951
  },
86317
- this.projectRoot
87952
+ projectRoot
86318
87953
  );
86319
87954
  return wrapResult(result, "mutate", "memory", operation, startTime);
86320
87955
  }
@@ -86584,17 +88219,30 @@ async function nexusShareSnapshotImport(projectRoot, inputPath) {
86584
88219
  return engineError("E_INTERNAL", error40 instanceof Error ? error40.message : String(error40));
86585
88220
  }
86586
88221
  }
88222
+ async function nexusTransferPreview(params) {
88223
+ try {
88224
+ const result = await previewTransfer(params);
88225
+ return engineSuccess(result);
88226
+ } catch (error40) {
88227
+ return engineError("E_INTERNAL", error40 instanceof Error ? error40.message : String(error40));
88228
+ }
88229
+ }
88230
+ async function nexusTransferExecute(params) {
88231
+ try {
88232
+ const result = await executeTransfer(params);
88233
+ return engineSuccess(result);
88234
+ } catch (error40) {
88235
+ return engineError("E_INTERNAL", error40 instanceof Error ? error40.message : String(error40));
88236
+ }
88237
+ }
86587
88238
 
86588
88239
  // packages/cleo/src/dispatch/domains/nexus.ts
86589
88240
  var NexusHandler = class {
86590
- projectRoot;
86591
- constructor() {
86592
- this.projectRoot = getProjectRoot();
86593
- }
86594
88241
  // -----------------------------------------------------------------------
86595
88242
  // Query
86596
88243
  // -----------------------------------------------------------------------
86597
88244
  async query(operation, params) {
88245
+ const projectRoot = getProjectRoot();
86598
88246
  const startTime = Date.now();
86599
88247
  try {
86600
88248
  switch (operation) {
@@ -86742,9 +88390,32 @@ var NexusHandler = class {
86742
88390
  return wrapResult(result, "query", "nexus", operation, startTime);
86743
88391
  }
86744
88392
  case "share.status": {
86745
- const result = await nexusShareStatus(this.projectRoot);
88393
+ const result = await nexusShareStatus(projectRoot);
86746
88394
  return wrapResult(result, "query", "nexus", "share.status", startTime);
86747
88395
  }
88396
+ case "transfer.preview": {
88397
+ const taskIds = params?.taskIds;
88398
+ const sourceProject = params?.sourceProject;
88399
+ const targetProject = params?.targetProject;
88400
+ if (!taskIds?.length || !sourceProject || !targetProject) {
88401
+ return errorResult(
88402
+ "query",
88403
+ "nexus",
88404
+ operation,
88405
+ "E_INVALID_INPUT",
88406
+ "taskIds, sourceProject, and targetProject are required",
88407
+ startTime
88408
+ );
88409
+ }
88410
+ const result = await nexusTransferPreview({
88411
+ taskIds,
88412
+ sourceProject,
88413
+ targetProject,
88414
+ mode: params?.mode ?? "copy",
88415
+ scope: params?.scope ?? "subtree"
88416
+ });
88417
+ return wrapResult(result, "query", "nexus", operation, startTime);
88418
+ }
86748
88419
  default:
86749
88420
  return unsupportedOp("query", "nexus", operation, startTime);
86750
88421
  }
@@ -86760,6 +88431,7 @@ var NexusHandler = class {
86760
88431
  // Mutate
86761
88432
  // -----------------------------------------------------------------------
86762
88433
  async mutate(operation, params) {
88434
+ const projectRoot = getProjectRoot();
86763
88435
  const startTime = Date.now();
86764
88436
  try {
86765
88437
  switch (operation) {
@@ -86843,13 +88515,13 @@ var NexusHandler = class {
86843
88515
  return wrapResult(result, "mutate", "nexus", operation, startTime);
86844
88516
  }
86845
88517
  case "reconcile": {
86846
- const projectRoot = params?.projectRoot || process.cwd();
86847
- const result = await nexusReconcileProject(projectRoot);
88518
+ const projectRoot2 = params?.projectRoot || process.cwd();
88519
+ const result = await nexusReconcileProject(projectRoot2);
86848
88520
  return wrapResult(result, "mutate", "nexus", operation, startTime);
86849
88521
  }
86850
88522
  case "share.snapshot.export": {
86851
88523
  const outputPath = params?.outputPath;
86852
- const result = await nexusShareSnapshotExport(this.projectRoot, outputPath);
88524
+ const result = await nexusShareSnapshotExport(projectRoot, outputPath);
86853
88525
  return wrapResult(result, "mutate", "nexus", "share.snapshot.export", startTime);
86854
88526
  }
86855
88527
  case "share.snapshot.import": {
@@ -86864,9 +88536,34 @@ var NexusHandler = class {
86864
88536
  startTime
86865
88537
  );
86866
88538
  }
86867
- const result = await nexusShareSnapshotImport(this.projectRoot, inputPath);
88539
+ const result = await nexusShareSnapshotImport(projectRoot, inputPath);
86868
88540
  return wrapResult(result, "mutate", "nexus", "share.snapshot.import", startTime);
86869
88541
  }
88542
+ case "transfer": {
88543
+ const taskIds = params?.taskIds;
88544
+ const sourceProject = params?.sourceProject;
88545
+ const targetProject = params?.targetProject;
88546
+ if (!taskIds?.length || !sourceProject || !targetProject) {
88547
+ return errorResult(
88548
+ "mutate",
88549
+ "nexus",
88550
+ operation,
88551
+ "E_INVALID_INPUT",
88552
+ "taskIds, sourceProject, and targetProject are required",
88553
+ startTime
88554
+ );
88555
+ }
88556
+ const result = await nexusTransferExecute({
88557
+ taskIds,
88558
+ sourceProject,
88559
+ targetProject,
88560
+ mode: params?.mode ?? "copy",
88561
+ scope: params?.scope ?? "subtree",
88562
+ onConflict: params?.onConflict ?? "rename",
88563
+ transferBrain: params?.transferBrain ?? false
88564
+ });
88565
+ return wrapResult(result, "mutate", "nexus", operation, startTime);
88566
+ }
86870
88567
  default:
86871
88568
  return unsupportedOp("mutate", "nexus", operation, startTime);
86872
88569
  }
@@ -86895,7 +88592,8 @@ var NexusHandler = class {
86895
88592
  "blockers.show",
86896
88593
  "orphans.list",
86897
88594
  "discover",
86898
- "search"
88595
+ "search",
88596
+ "transfer.preview"
86899
88597
  ],
86900
88598
  mutate: [
86901
88599
  "share.snapshot.export",
@@ -86905,7 +88603,8 @@ var NexusHandler = class {
86905
88603
  "unregister",
86906
88604
  "sync",
86907
88605
  "permission.set",
86908
- "reconcile"
88606
+ "reconcile",
88607
+ "transfer"
86909
88608
  ]
86910
88609
  };
86911
88610
  }
@@ -86914,20 +88613,17 @@ var NexusHandler = class {
86914
88613
  // packages/cleo/src/dispatch/domains/orchestrate.ts
86915
88614
  init_internal();
86916
88615
  var OrchestrateHandler = class {
86917
- projectRoot;
86918
- constructor() {
86919
- this.projectRoot = getProjectRoot();
86920
- }
86921
88616
  // -----------------------------------------------------------------------
86922
88617
  // DomainHandler interface
86923
88618
  // -----------------------------------------------------------------------
86924
88619
  async query(operation, params) {
88620
+ const projectRoot = getProjectRoot();
86925
88621
  const startTime = Date.now();
86926
88622
  try {
86927
88623
  switch (operation) {
86928
88624
  case "status": {
86929
88625
  const epicId = params?.epicId;
86930
- const result = await orchestrateStatus(epicId, this.projectRoot);
88626
+ const result = await orchestrateStatus(epicId, projectRoot);
86931
88627
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86932
88628
  }
86933
88629
  case "next": {
@@ -86942,7 +88638,7 @@ var OrchestrateHandler = class {
86942
88638
  startTime
86943
88639
  );
86944
88640
  }
86945
- const result = await orchestrateNext(epicId, this.projectRoot);
88641
+ const result = await orchestrateNext(epicId, projectRoot);
86946
88642
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86947
88643
  }
86948
88644
  case "ready": {
@@ -86957,18 +88653,18 @@ var OrchestrateHandler = class {
86957
88653
  startTime
86958
88654
  );
86959
88655
  }
86960
- const result = await orchestrateReady(epicId, this.projectRoot);
88656
+ const result = await orchestrateReady(epicId, projectRoot);
86961
88657
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86962
88658
  }
86963
88659
  case "analyze": {
86964
88660
  const epicId = params?.epicId;
86965
88661
  const mode = params?.mode;
86966
- const result = await orchestrateAnalyze(epicId, this.projectRoot, mode);
88662
+ const result = await orchestrateAnalyze(epicId, projectRoot, mode);
86967
88663
  return wrapResult(result, "query", "orchestrate", "analyze", startTime);
86968
88664
  }
86969
88665
  case "context": {
86970
88666
  const epicId = params?.epicId;
86971
- const result = await orchestrateContext(epicId, this.projectRoot);
88667
+ const result = await orchestrateContext(epicId, projectRoot);
86972
88668
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86973
88669
  }
86974
88670
  case "waves": {
@@ -86983,16 +88679,16 @@ var OrchestrateHandler = class {
86983
88679
  startTime
86984
88680
  );
86985
88681
  }
86986
- const result = await orchestrateWaves(epicId, this.projectRoot);
88682
+ const result = await orchestrateWaves(epicId, projectRoot);
86987
88683
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86988
88684
  }
86989
88685
  case "bootstrap": {
86990
88686
  const speed = params?.speed;
86991
- const result = await orchestrateBootstrap(this.projectRoot, { speed });
88687
+ const result = await orchestrateBootstrap(projectRoot, { speed });
86992
88688
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86993
88689
  }
86994
88690
  case "unblock.opportunities": {
86995
- const result = await orchestrateUnblockOpportunities(this.projectRoot);
88691
+ const result = await orchestrateUnblockOpportunities(projectRoot);
86996
88692
  return wrapResult(result, "query", "orchestrate", operation, startTime);
86997
88693
  }
86998
88694
  case "tessera.list": {
@@ -87049,6 +88745,7 @@ var OrchestrateHandler = class {
87049
88745
  }
87050
88746
  }
87051
88747
  async mutate(operation, params) {
88748
+ const projectRoot = getProjectRoot();
87052
88749
  const startTime = Date.now();
87053
88750
  try {
87054
88751
  switch (operation) {
@@ -87064,7 +88761,7 @@ var OrchestrateHandler = class {
87064
88761
  startTime
87065
88762
  );
87066
88763
  }
87067
- const result = await orchestrateStartup(epicId, this.projectRoot);
88764
+ const result = await orchestrateStartup(epicId, projectRoot);
87068
88765
  return wrapResult(result, "mutate", "orchestrate", operation, startTime);
87069
88766
  }
87070
88767
  case "spawn": {
@@ -87081,7 +88778,7 @@ var OrchestrateHandler = class {
87081
88778
  }
87082
88779
  const protocolType = params?.protocolType;
87083
88780
  const tier = params?.tier;
87084
- const result = await orchestrateSpawn(taskId, protocolType, this.projectRoot, tier);
88781
+ const result = await orchestrateSpawn(taskId, protocolType, projectRoot, tier);
87085
88782
  return wrapResult(result, "mutate", "orchestrate", operation, startTime);
87086
88783
  }
87087
88784
  case "handoff": {
@@ -87118,7 +88815,7 @@ var OrchestrateHandler = class {
87118
88815
  tier,
87119
88816
  idempotencyKey: params?.idempotencyKey
87120
88817
  },
87121
- this.projectRoot
88818
+ projectRoot
87122
88819
  );
87123
88820
  return wrapResult(result, "mutate", "orchestrate", operation, startTime);
87124
88821
  }
@@ -87141,7 +88838,7 @@ var OrchestrateHandler = class {
87141
88838
  taskId,
87142
88839
  adapterId,
87143
88840
  protocolType,
87144
- this.projectRoot,
88841
+ projectRoot,
87145
88842
  tier
87146
88843
  );
87147
88844
  return wrapResult(result, "mutate", "orchestrate", operation, startTime);
@@ -87158,7 +88855,7 @@ var OrchestrateHandler = class {
87158
88855
  startTime
87159
88856
  );
87160
88857
  }
87161
- const result = await orchestrateValidate(taskId, this.projectRoot);
88858
+ const result = await orchestrateValidate(taskId, projectRoot);
87162
88859
  return wrapResult(result, "mutate", "orchestrate", operation, startTime);
87163
88860
  }
87164
88861
  case "parallel": {
@@ -87186,7 +88883,7 @@ var OrchestrateHandler = class {
87186
88883
  startTime
87187
88884
  );
87188
88885
  }
87189
- const result = await orchestrateParallelStart(epicId, wave, this.projectRoot);
88886
+ const result = await orchestrateParallelStart(epicId, wave, projectRoot);
87190
88887
  return wrapResult(result, "mutate", "orchestrate", "parallel", startTime);
87191
88888
  },
87192
88889
  end: async () => {
@@ -87212,7 +88909,7 @@ var OrchestrateHandler = class {
87212
88909
  startTime
87213
88910
  );
87214
88911
  }
87215
- const result = await orchestrateParallelEnd(epicId, wave, this.projectRoot);
88912
+ const result = await orchestrateParallelEnd(epicId, wave, projectRoot);
87216
88913
  return wrapResult(result, "mutate", "orchestrate", "parallel", startTime);
87217
88914
  }
87218
88915
  });
@@ -87255,7 +88952,7 @@ var OrchestrateHandler = class {
87255
88952
  const instance = await instantiateTessera(
87256
88953
  template,
87257
88954
  { templateId, epicId, variables: { epicId, ...variables } },
87258
- this.projectRoot
88955
+ projectRoot
87259
88956
  );
87260
88957
  return {
87261
88958
  _meta: dispatchMeta("mutate", "orchestrate", operation, startTime),
@@ -87311,9 +89008,8 @@ var OrchestrateHandler = class {
87311
89008
  init_internal();
87312
89009
  import { execFileSync as execFileSync13 } from "node:child_process";
87313
89010
  var PipelineHandler = class {
87314
- projectRoot;
87315
- constructor() {
87316
- this.projectRoot = getProjectRoot();
89011
+ get projectRoot() {
89012
+ return getProjectRoot();
87317
89013
  }
87318
89014
  // -----------------------------------------------------------------------
87319
89015
  // DomainHandler interface
@@ -88186,24 +89882,21 @@ function unbindSession() {
88186
89882
 
88187
89883
  // packages/cleo/src/dispatch/domains/session.ts
88188
89884
  var SessionHandler = class {
88189
- projectRoot;
88190
- constructor() {
88191
- this.projectRoot = getProjectRoot();
88192
- }
88193
89885
  // -----------------------------------------------------------------------
88194
89886
  // Query
88195
89887
  // -----------------------------------------------------------------------
88196
89888
  async query(operation, params) {
89889
+ const projectRoot = getProjectRoot();
88197
89890
  const startTime = Date.now();
88198
89891
  try {
88199
89892
  switch (operation) {
88200
89893
  case "status": {
88201
- const result = await sessionStatus2(this.projectRoot);
89894
+ const result = await sessionStatus2(projectRoot);
88202
89895
  return wrapResult(result, "query", "session", operation, startTime);
88203
89896
  }
88204
89897
  case "list": {
88205
89898
  const result = await sessionList(
88206
- this.projectRoot,
89899
+ projectRoot,
88207
89900
  params
88208
89901
  );
88209
89902
  return wrapResult(result, "query", "session", operation, startTime);
@@ -88223,24 +89916,21 @@ var SessionHandler = class {
88223
89916
  }
88224
89917
  const include = params?.include;
88225
89918
  if (include === "debrief") {
88226
- const result2 = await sessionDebriefShow(this.projectRoot, sessionId);
89919
+ const result2 = await sessionDebriefShow(projectRoot, sessionId);
88227
89920
  return wrapResult(result2, "query", "session", operation, startTime);
88228
89921
  }
88229
- const result = await sessionShow(this.projectRoot, sessionId);
89922
+ const result = await sessionShow(projectRoot, sessionId);
88230
89923
  return wrapResult(result, "query", "session", operation, startTime);
88231
89924
  }
88232
89925
  case "decision.log": {
88233
89926
  const result = await sessionDecisionLog(
88234
- this.projectRoot,
89927
+ projectRoot,
88235
89928
  params
88236
89929
  );
88237
89930
  return wrapResult(result, "query", "session", operation, startTime);
88238
89931
  }
88239
89932
  case "context.drift": {
88240
- const result = await sessionContextDrift(
88241
- this.projectRoot,
88242
- params
88243
- );
89933
+ const result = await sessionContextDrift(projectRoot, params);
88244
89934
  return wrapResult(result, "query", "session", operation, startTime);
88245
89935
  }
88246
89936
  case "handoff.show": {
@@ -88253,11 +89943,11 @@ var SessionHandler = class {
88253
89943
  scopeFilter = { type: "epic", epicId: scope.replace("epic:", "") };
88254
89944
  }
88255
89945
  }
88256
- const result = await sessionHandoff(this.projectRoot, scopeFilter);
89946
+ const result = await sessionHandoff(projectRoot, scopeFilter);
88257
89947
  return wrapResult(result, "query", "session", operation, startTime);
88258
89948
  }
88259
89949
  case "briefing.show": {
88260
- const result = await sessionBriefing(this.projectRoot, {
89950
+ const result = await sessionBriefing(projectRoot, {
88261
89951
  maxNextTasks: params?.maxNextTasks,
88262
89952
  maxBugs: params?.maxBugs,
88263
89953
  maxBlocked: params?.maxBlocked,
@@ -88268,7 +89958,7 @@ var SessionHandler = class {
88268
89958
  }
88269
89959
  case "find": {
88270
89960
  const result = await sessionFind(
88271
- this.projectRoot,
89961
+ projectRoot,
88272
89962
  params
88273
89963
  );
88274
89964
  return wrapResult(result, "query", "session", operation, startTime);
@@ -88288,6 +89978,7 @@ var SessionHandler = class {
88288
89978
  // Mutate
88289
89979
  // -----------------------------------------------------------------------
88290
89980
  async mutate(operation, params) {
89981
+ const projectRoot = getProjectRoot();
88291
89982
  const startTime = Date.now();
88292
89983
  try {
88293
89984
  switch (operation) {
@@ -88303,7 +89994,7 @@ var SessionHandler = class {
88303
89994
  startTime
88304
89995
  );
88305
89996
  }
88306
- const result = await sessionStart(this.projectRoot, {
89997
+ const result = await sessionStart(projectRoot, {
88307
89998
  scope,
88308
89999
  name: params?.name,
88309
90000
  autoStart: params?.autoStart,
@@ -88334,19 +90025,19 @@ var SessionHandler = class {
88334
90025
  return wrapResult(result, "mutate", "session", operation, startTime);
88335
90026
  }
88336
90027
  case "end": {
88337
- const endResult = await sessionEnd(this.projectRoot, params?.note);
90028
+ const endResult = await sessionEnd(projectRoot, params?.note);
88338
90029
  if (endResult.success && endResult.data) {
88339
90030
  const sessionId = endResult.data.sessionId;
88340
90031
  if (sessionId) {
88341
90032
  let debriefResult = null;
88342
90033
  try {
88343
- debriefResult = await sessionComputeDebrief(this.projectRoot, sessionId, {
90034
+ debriefResult = await sessionComputeDebrief(projectRoot, sessionId, {
88344
90035
  note: params?.note,
88345
90036
  nextAction: params?.nextAction
88346
90037
  });
88347
90038
  } catch {
88348
90039
  try {
88349
- await sessionComputeHandoff(this.projectRoot, sessionId, {
90040
+ await sessionComputeHandoff(projectRoot, sessionId, {
88350
90041
  note: params?.note,
88351
90042
  nextAction: params?.nextAction
88352
90043
  });
@@ -88356,7 +90047,7 @@ var SessionHandler = class {
88356
90047
  if (debriefResult?.success && debriefResult.data) {
88357
90048
  try {
88358
90049
  const { persistSessionMemory: persistSessionMemory2 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
88359
- await persistSessionMemory2(this.projectRoot, sessionId, debriefResult.data);
90050
+ await persistSessionMemory2(projectRoot, sessionId, debriefResult.data);
88360
90051
  } catch {
88361
90052
  }
88362
90053
  }
@@ -88377,7 +90068,7 @@ var SessionHandler = class {
88377
90068
  startTime
88378
90069
  );
88379
90070
  }
88380
- const result = await sessionResume(this.projectRoot, sessionId);
90071
+ const result = await sessionResume(projectRoot, sessionId);
88381
90072
  return wrapResult(result, "mutate", "session", operation, startTime);
88382
90073
  }
88383
90074
  case "suspend": {
@@ -88393,21 +90084,18 @@ var SessionHandler = class {
88393
90084
  );
88394
90085
  }
88395
90086
  const result = await sessionSuspend(
88396
- this.projectRoot,
90087
+ projectRoot,
88397
90088
  sessionId,
88398
90089
  params?.reason
88399
90090
  );
88400
90091
  return wrapResult(result, "mutate", "session", operation, startTime);
88401
90092
  }
88402
90093
  case "gc": {
88403
- const result = await sessionGc(
88404
- this.projectRoot,
88405
- params?.maxAgeDays
88406
- );
90094
+ const result = await sessionGc(projectRoot, params?.maxAgeDays);
88407
90095
  return wrapResult(result, "mutate", "session", operation, startTime);
88408
90096
  }
88409
90097
  case "record.decision": {
88410
- const result = await sessionRecordDecision(this.projectRoot, {
90098
+ const result = await sessionRecordDecision(projectRoot, {
88411
90099
  sessionId: params?.sessionId,
88412
90100
  taskId: params?.taskId,
88413
90101
  decision: params?.decision,
@@ -88417,7 +90105,7 @@ var SessionHandler = class {
88417
90105
  return wrapResult(result, "mutate", "session", operation, startTime);
88418
90106
  }
88419
90107
  case "record.assumption": {
88420
- const result = await sessionRecordAssumption(this.projectRoot, {
90108
+ const result = await sessionRecordAssumption(projectRoot, {
88421
90109
  sessionId: params?.sessionId,
88422
90110
  taskId: params?.taskId,
88423
90111
  assumption: params?.assumption,
@@ -88558,14 +90246,11 @@ async function stickyPurge(projectRoot, id) {
88558
90246
 
88559
90247
  // packages/cleo/src/dispatch/domains/sticky.ts
88560
90248
  var StickyHandler = class {
88561
- projectRoot;
88562
- constructor() {
88563
- this.projectRoot = getProjectRoot();
88564
- }
88565
90249
  // -----------------------------------------------------------------------
88566
90250
  // Query
88567
90251
  // -----------------------------------------------------------------------
88568
90252
  async query(operation, params) {
90253
+ const projectRoot = getProjectRoot();
88569
90254
  const startTime = Date.now();
88570
90255
  try {
88571
90256
  switch (operation) {
@@ -88575,13 +90260,13 @@ var StickyHandler = class {
88575
90260
  color: params?.color,
88576
90261
  priority: params?.priority
88577
90262
  };
88578
- const result = await stickyList(this.projectRoot, filters);
90263
+ const result = await stickyList(projectRoot, filters);
88579
90264
  if (!result.success) {
88580
90265
  return wrapResult(result, "query", "sticky", operation, startTime);
88581
90266
  }
88582
90267
  const filteredStickies = result.data?.stickies ?? [];
88583
90268
  const hasFilter = filters.status !== void 0 || filters.color !== void 0 || filters.priority !== void 0;
88584
- const totalResult = hasFilter ? await stickyList(this.projectRoot, {}) : result;
90269
+ const totalResult = hasFilter ? await stickyList(projectRoot, {}) : result;
88585
90270
  if (!totalResult.success) {
88586
90271
  return wrapResult(totalResult, "query", "sticky", operation, startTime);
88587
90272
  }
@@ -88611,7 +90296,7 @@ var StickyHandler = class {
88611
90296
  startTime
88612
90297
  );
88613
90298
  }
88614
- const result = await stickyShow(this.projectRoot, stickyId);
90299
+ const result = await stickyShow(projectRoot, stickyId);
88615
90300
  return wrapResult(result, "query", "sticky", operation, startTime);
88616
90301
  }
88617
90302
  default:
@@ -88630,6 +90315,7 @@ var StickyHandler = class {
88630
90315
  // Mutate
88631
90316
  // -----------------------------------------------------------------------
88632
90317
  async mutate(operation, params) {
90318
+ const projectRoot = getProjectRoot();
88633
90319
  const startTime = Date.now();
88634
90320
  try {
88635
90321
  switch (operation) {
@@ -88645,7 +90331,7 @@ var StickyHandler = class {
88645
90331
  startTime
88646
90332
  );
88647
90333
  }
88648
- const result = await stickyAdd(this.projectRoot, {
90334
+ const result = await stickyAdd(projectRoot, {
88649
90335
  content,
88650
90336
  tags: params?.tags,
88651
90337
  color: params?.color,
@@ -88678,7 +90364,7 @@ var StickyHandler = class {
88678
90364
  }
88679
90365
  if (targetType === "task") {
88680
90366
  const result = await stickyConvertToTask(
88681
- this.projectRoot,
90367
+ projectRoot,
88682
90368
  stickyId,
88683
90369
  params?.title
88684
90370
  );
@@ -88695,18 +90381,18 @@ var StickyHandler = class {
88695
90381
  startTime
88696
90382
  );
88697
90383
  }
88698
- const result = await stickyConvertToTaskNote(this.projectRoot, stickyId, taskId);
90384
+ const result = await stickyConvertToTaskNote(projectRoot, stickyId, taskId);
88699
90385
  return wrapResult(result, "mutate", "sticky", operation, startTime);
88700
90386
  } else if (targetType === "session_note") {
88701
90387
  const result = await stickyConvertToSessionNote(
88702
- this.projectRoot,
90388
+ projectRoot,
88703
90389
  stickyId,
88704
90390
  params?.sessionId
88705
90391
  );
88706
90392
  return wrapResult(result, "mutate", "sticky", operation, startTime);
88707
90393
  } else {
88708
90394
  const result = await stickyConvertToMemory(
88709
- this.projectRoot,
90395
+ projectRoot,
88710
90396
  stickyId,
88711
90397
  params?.memoryType
88712
90398
  );
@@ -88725,7 +90411,7 @@ var StickyHandler = class {
88725
90411
  startTime
88726
90412
  );
88727
90413
  }
88728
- const result = await stickyArchive(this.projectRoot, stickyId);
90414
+ const result = await stickyArchive(projectRoot, stickyId);
88729
90415
  return wrapResult(result, "mutate", "sticky", operation, startTime);
88730
90416
  }
88731
90417
  case "purge": {
@@ -88740,7 +90426,7 @@ var StickyHandler = class {
88740
90426
  startTime
88741
90427
  );
88742
90428
  }
88743
- const result = await stickyPurge(this.projectRoot, stickyId);
90429
+ const result = await stickyPurge(projectRoot, stickyId);
88744
90430
  return wrapResult(result, "mutate", "sticky", operation, startTime);
88745
90431
  }
88746
90432
  default:
@@ -88769,23 +90455,20 @@ var StickyHandler = class {
88769
90455
  // packages/cleo/src/dispatch/domains/tasks.ts
88770
90456
  init_src2();
88771
90457
  var TasksHandler = class {
88772
- projectRoot;
88773
- constructor() {
88774
- this.projectRoot = getProjectRoot();
88775
- }
88776
90458
  // -----------------------------------------------------------------------
88777
90459
  // Query
88778
90460
  // -----------------------------------------------------------------------
88779
90461
  async query(operation, params) {
90462
+ const projectRoot = getProjectRoot();
88780
90463
  const startTime = Date.now();
88781
90464
  try {
88782
90465
  switch (operation) {
88783
90466
  case "show": {
88784
- const result = await taskShow(this.projectRoot, params.taskId);
90467
+ const result = await taskShow(projectRoot, params.taskId);
88785
90468
  return wrapResult(result, "query", "tasks", operation, startTime);
88786
90469
  }
88787
90470
  case "list": {
88788
- const result = await taskList(this.projectRoot, {
90471
+ const result = await taskList(projectRoot, {
88789
90472
  parent: params?.parent,
88790
90473
  status: params?.status,
88791
90474
  priority: params?.priority,
@@ -88801,7 +90484,7 @@ var TasksHandler = class {
88801
90484
  }
88802
90485
  case "find": {
88803
90486
  const result = await taskFind(
88804
- this.projectRoot,
90487
+ projectRoot,
88805
90488
  params?.query,
88806
90489
  params?.limit,
88807
90490
  {
@@ -88816,12 +90499,12 @@ var TasksHandler = class {
88816
90499
  }
88817
90500
  case "tree": {
88818
90501
  const taskId = params?.taskId;
88819
- const result = await taskTree(this.projectRoot, taskId);
90502
+ const result = await taskTree(projectRoot, taskId);
88820
90503
  return wrapResult(result, "query", "tasks", operation, startTime);
88821
90504
  }
88822
90505
  case "blockers": {
88823
90506
  const result = await taskBlockers(
88824
- this.projectRoot,
90507
+ projectRoot,
88825
90508
  params
88826
90509
  );
88827
90510
  return wrapResult(result, "query", "tasks", operation, startTime);
@@ -88829,11 +90512,11 @@ var TasksHandler = class {
88829
90512
  case "depends": {
88830
90513
  const action = params?.action;
88831
90514
  if (action === "overview") {
88832
- const result2 = await taskDepsOverview(this.projectRoot);
90515
+ const result2 = await taskDepsOverview(projectRoot);
88833
90516
  return wrapResult(result2, "query", "tasks", operation, startTime);
88834
90517
  }
88835
90518
  if (action === "cycles") {
88836
- const result2 = await taskDepsCycles(this.projectRoot);
90519
+ const result2 = await taskDepsCycles(projectRoot);
88837
90520
  return wrapResult(result2, "query", "tasks", operation, startTime);
88838
90521
  }
88839
90522
  const taskId = params?.taskId;
@@ -88849,64 +90532,64 @@ var TasksHandler = class {
88849
90532
  }
88850
90533
  const direction = params?.direction;
88851
90534
  const tree = params?.tree;
88852
- const result = await taskDepends(this.projectRoot, taskId, direction, tree);
90535
+ const result = await taskDepends(projectRoot, taskId, direction, tree);
88853
90536
  return wrapResult(result, "query", "tasks", operation, startTime);
88854
90537
  }
88855
90538
  case "analyze": {
88856
90539
  const taskId = params?.taskId;
88857
90540
  const tierLimit = params?.tierLimit;
88858
- const result = await taskAnalyze(this.projectRoot, taskId, { tierLimit });
90541
+ const result = await taskAnalyze(projectRoot, taskId, { tierLimit });
88859
90542
  return wrapResult(result, "query", "tasks", operation, startTime);
88860
90543
  }
88861
90544
  case "next": {
88862
90545
  const result = await taskNext(
88863
- this.projectRoot,
90546
+ projectRoot,
88864
90547
  params
88865
90548
  );
88866
90549
  return wrapResult(result, "query", "tasks", operation, startTime);
88867
90550
  }
88868
90551
  case "plan": {
88869
- const result = await taskPlan(this.projectRoot);
90552
+ const result = await taskPlan(projectRoot);
88870
90553
  return wrapResult(result, "query", "tasks", operation, startTime);
88871
90554
  }
88872
90555
  case "relates": {
88873
90556
  const taskId = params.taskId;
88874
90557
  if (params?.mode) {
88875
- const result2 = await taskRelatesFind(this.projectRoot, taskId, {
90558
+ const result2 = await taskRelatesFind(projectRoot, taskId, {
88876
90559
  mode: params.mode,
88877
90560
  threshold: params?.threshold ? Number(params.threshold) : void 0
88878
90561
  });
88879
90562
  return wrapResult(result2, "query", "tasks", operation, startTime);
88880
90563
  }
88881
- const result = await taskRelates(this.projectRoot, taskId);
90564
+ const result = await taskRelates(projectRoot, taskId);
88882
90565
  return wrapResult(result, "query", "tasks", operation, startTime);
88883
90566
  }
88884
90567
  case "complexity.estimate": {
88885
- const result = await taskComplexityEstimate(this.projectRoot, {
90568
+ const result = await taskComplexityEstimate(projectRoot, {
88886
90569
  taskId: params.taskId
88887
90570
  });
88888
90571
  return wrapResult(result, "query", "tasks", operation, startTime);
88889
90572
  }
88890
90573
  case "current": {
88891
- const result = await taskCurrentGet(this.projectRoot);
90574
+ const result = await taskCurrentGet(projectRoot);
88892
90575
  return wrapResult(result, "query", "tasks", operation, startTime);
88893
90576
  }
88894
90577
  case "history": {
88895
90578
  const taskId = params?.taskId;
88896
90579
  if (taskId) {
88897
- const result2 = await taskHistory(this.projectRoot, taskId, params?.limit);
90580
+ const result2 = await taskHistory(projectRoot, taskId, params?.limit);
88898
90581
  return wrapResult(result2, "query", "tasks", operation, startTime);
88899
90582
  }
88900
- const result = await taskWorkHistory2(this.projectRoot);
90583
+ const result = await taskWorkHistory2(projectRoot);
88901
90584
  return wrapResult(result, "query", "tasks", operation, startTime);
88902
90585
  }
88903
90586
  case "label.list": {
88904
- const result = await taskLabelList(this.projectRoot);
90587
+ const result = await taskLabelList(projectRoot);
88905
90588
  return wrapResult(result, "query", "tasks", operation, startTime);
88906
90589
  }
88907
90590
  case "sync.links": {
88908
90591
  const result = await taskSyncLinks(
88909
- this.projectRoot,
90592
+ projectRoot,
88910
90593
  params
88911
90594
  );
88912
90595
  return wrapResult(result, "query", "tasks", operation, startTime);
@@ -88926,11 +90609,12 @@ var TasksHandler = class {
88926
90609
  // Mutate
88927
90610
  // -----------------------------------------------------------------------
88928
90611
  async mutate(operation, params) {
90612
+ const projectRoot = getProjectRoot();
88929
90613
  const startTime = Date.now();
88930
90614
  try {
88931
90615
  switch (operation) {
88932
90616
  case "add": {
88933
- const result = await taskCreate(this.projectRoot, {
90617
+ const result = await taskCreate(projectRoot, {
88934
90618
  title: params.title,
88935
90619
  description: params?.description ?? params.title,
88936
90620
  parent: params?.parent ?? params?.parentId,
@@ -88942,7 +90626,7 @@ var TasksHandler = class {
88942
90626
  return wrapResult(result, "mutate", "tasks", operation, startTime);
88943
90627
  }
88944
90628
  case "update": {
88945
- const result = await taskUpdate(this.projectRoot, params.taskId, {
90629
+ const result = await taskUpdate(projectRoot, params.taskId, {
88946
90630
  title: params?.title,
88947
90631
  description: params?.description,
88948
90632
  status: params?.status,
@@ -88963,7 +90647,7 @@ var TasksHandler = class {
88963
90647
  }
88964
90648
  case "complete": {
88965
90649
  const result = await taskComplete(
88966
- this.projectRoot,
90650
+ projectRoot,
88967
90651
  params.taskId,
88968
90652
  params?.notes
88969
90653
  );
@@ -88971,7 +90655,7 @@ var TasksHandler = class {
88971
90655
  }
88972
90656
  case "delete": {
88973
90657
  const result = await taskDelete(
88974
- this.projectRoot,
90658
+ projectRoot,
88975
90659
  params.taskId,
88976
90660
  params?.force
88977
90661
  );
@@ -88979,7 +90663,7 @@ var TasksHandler = class {
88979
90663
  }
88980
90664
  case "archive": {
88981
90665
  const result = await taskArchive(
88982
- this.projectRoot,
90666
+ projectRoot,
88983
90667
  params?.taskId,
88984
90668
  params?.before
88985
90669
  );
@@ -88989,20 +90673,20 @@ var TasksHandler = class {
88989
90673
  const taskId = params.taskId;
88990
90674
  const from = params?.from;
88991
90675
  if (from === "done") {
88992
- const result2 = await taskReopen(this.projectRoot, taskId, {
90676
+ const result2 = await taskReopen(projectRoot, taskId, {
88993
90677
  status: params?.status,
88994
90678
  reason: params?.reason
88995
90679
  });
88996
90680
  return wrapResult(result2, "mutate", "tasks", operation, startTime);
88997
90681
  }
88998
90682
  if (from === "archived") {
88999
- const result2 = await taskUnarchive(this.projectRoot, taskId, {
90683
+ const result2 = await taskUnarchive(projectRoot, taskId, {
89000
90684
  status: params?.status,
89001
90685
  preserveStatus: params?.preserveStatus
89002
90686
  });
89003
90687
  return wrapResult(result2, "mutate", "tasks", operation, startTime);
89004
90688
  }
89005
- const result = await taskRestore(this.projectRoot, taskId, {
90689
+ const result = await taskRestore(projectRoot, taskId, {
89006
90690
  cascade: params?.cascade,
89007
90691
  notes: params?.notes
89008
90692
  });
@@ -89010,7 +90694,7 @@ var TasksHandler = class {
89010
90694
  }
89011
90695
  case "cancel": {
89012
90696
  const result = await taskCancel(
89013
- this.projectRoot,
90697
+ projectRoot,
89014
90698
  params.taskId,
89015
90699
  params?.reason
89016
90700
  );
@@ -89018,7 +90702,7 @@ var TasksHandler = class {
89018
90702
  }
89019
90703
  case "reparent": {
89020
90704
  const result = await taskReparent(
89021
- this.projectRoot,
90705
+ projectRoot,
89022
90706
  params.taskId,
89023
90707
  params?.newParentId ?? null
89024
90708
  );
@@ -89026,7 +90710,7 @@ var TasksHandler = class {
89026
90710
  }
89027
90711
  case "reorder": {
89028
90712
  const result = await taskReorder(
89029
- this.projectRoot,
90713
+ projectRoot,
89030
90714
  params.taskId,
89031
90715
  params.position
89032
90716
  );
@@ -89045,7 +90729,7 @@ var TasksHandler = class {
89045
90729
  );
89046
90730
  }
89047
90731
  const result = await taskRelatesAdd(
89048
- this.projectRoot,
90732
+ projectRoot,
89049
90733
  params.taskId,
89050
90734
  relatedId,
89051
90735
  params.type,
@@ -89054,15 +90738,15 @@ var TasksHandler = class {
89054
90738
  return wrapResult(result, "mutate", "tasks", operation, startTime);
89055
90739
  }
89056
90740
  case "start": {
89057
- const result = await taskStart(this.projectRoot, params.taskId);
90741
+ const result = await taskStart(projectRoot, params.taskId);
89058
90742
  return wrapResult(result, "mutate", "tasks", operation, startTime);
89059
90743
  }
89060
90744
  case "stop": {
89061
- const result = await taskStop(this.projectRoot);
90745
+ const result = await taskStop(projectRoot);
89062
90746
  return wrapResult(result, "mutate", "tasks", operation, startTime);
89063
90747
  }
89064
90748
  case "sync.reconcile": {
89065
- const result = await taskSyncReconcile(this.projectRoot, {
90749
+ const result = await taskSyncReconcile(projectRoot, {
89066
90750
  providerId: params.providerId,
89067
90751
  externalTasks: params.externalTasks,
89068
90752
  dryRun: params?.dryRun,
@@ -89073,7 +90757,7 @@ var TasksHandler = class {
89073
90757
  return wrapResult(result, "mutate", "tasks", operation, startTime);
89074
90758
  }
89075
90759
  case "sync.links.remove": {
89076
- const result = await taskSyncLinksRemove(this.projectRoot, params.providerId);
90760
+ const result = await taskSyncLinksRemove(projectRoot, params.providerId);
89077
90761
  return wrapResult(result, "mutate", "tasks", operation, startTime);
89078
90762
  }
89079
90763
  default:
@@ -89144,7 +90828,7 @@ import {
89144
90828
  discoverSkill as discoverSkill2,
89145
90829
  discoverSkills,
89146
90830
  getAllProviders as getAllProviders2,
89147
- getCanonicalSkillsDir as getCanonicalSkillsDir3,
90831
+ getCanonicalSkillsDir as getCanonicalSkillsDir4,
89148
90832
  getInstalledProviders as getInstalledProviders3,
89149
90833
  getTrackedSkills,
89150
90834
  injectAll as injectAll2,
@@ -89161,7 +90845,7 @@ function toolsIssueDiagnostics() {
89161
90845
  }
89162
90846
  async function toolsSkillList(limit, offset) {
89163
90847
  try {
89164
- const skills = await discoverSkills(getCanonicalSkillsDir3());
90848
+ const skills = await discoverSkills(getCanonicalSkillsDir4());
89165
90849
  const page = paginate(skills, limit, offset);
89166
90850
  return {
89167
90851
  success: true,
@@ -89180,7 +90864,7 @@ async function toolsSkillList(limit, offset) {
89180
90864
  }
89181
90865
  async function toolsSkillShow(name2) {
89182
90866
  try {
89183
- const skill = await discoverSkill2(`${getCanonicalSkillsDir3()}/${name2}`);
90867
+ const skill = await discoverSkill2(`${getCanonicalSkillsDir4()}/${name2}`);
89184
90868
  if (!skill) {
89185
90869
  return engineError("E_NOT_FOUND", `Skill not found: ${name2}`);
89186
90870
  }
@@ -89192,7 +90876,7 @@ async function toolsSkillShow(name2) {
89192
90876
  async function toolsSkillFind(query) {
89193
90877
  try {
89194
90878
  const q = (query ?? "").toLowerCase();
89195
- const skills = await discoverSkills(getCanonicalSkillsDir3());
90879
+ const skills = await discoverSkills(getCanonicalSkillsDir4());
89196
90880
  const filtered = q ? skills.filter(
89197
90881
  (s) => s.name.toLowerCase().includes(q) || s.metadata.description.toLowerCase().includes(q)
89198
90882
  ) : skills;
@@ -89216,13 +90900,13 @@ function toolsSkillDispatch(name2) {
89216
90900
  }
89217
90901
  async function toolsSkillVerify(name2) {
89218
90902
  try {
89219
- const installed = await discoverSkill2(`${getCanonicalSkillsDir3()}/${name2}`);
90903
+ const installed = await discoverSkill2(`${getCanonicalSkillsDir4()}/${name2}`);
89220
90904
  const catalogEntry = catalog3.getSkill(name2);
89221
90905
  return engineSuccess({
89222
90906
  skill: name2,
89223
90907
  installed: !!installed,
89224
90908
  inCatalog: !!catalogEntry,
89225
- installPath: installed ? `${getCanonicalSkillsDir3()}/${name2}` : null
90909
+ installPath: installed ? `${getCanonicalSkillsDir4()}/${name2}` : null
89226
90910
  });
89227
90911
  } catch (error40) {
89228
90912
  return engineError("E_INTERNAL", error40 instanceof Error ? error40.message : String(error40));
@@ -89627,9 +91311,8 @@ async function toolsAdapterDispose(projectRoot, id) {
89627
91311
 
89628
91312
  // packages/cleo/src/dispatch/domains/tools.ts
89629
91313
  var ToolsHandler = class {
89630
- projectRoot;
89631
- constructor() {
89632
- this.projectRoot = getProjectRoot();
91314
+ get projectRoot() {
91315
+ return getProjectRoot();
89633
91316
  }
89634
91317
  // -----------------------------------------------------------------------
89635
91318
  // DomainHandler interface
@@ -90362,7 +92045,7 @@ function getConfig() {
90362
92045
 
90363
92046
  // packages/cleo/src/dispatch/middleware/audit.ts
90364
92047
  init_internal();
90365
- var log8 = getLogger("audit");
92048
+ var log9 = getLogger("audit");
90366
92049
  var cachedProjectHash;
90367
92050
  function resolveProjectHash() {
90368
92051
  if (cachedProjectHash !== void 0) return cachedProjectHash;
@@ -90393,9 +92076,9 @@ async function writeToSqlite(entry, requestId) {
90393
92076
  const { getDb: getDb4 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
90394
92077
  const { auditLog: auditLog2 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
90395
92078
  const { AuditLogInsertSchema: AuditLogInsertSchema2 } = await Promise.resolve().then(() => (init_internal(), internal_exports));
90396
- const { randomUUID: randomUUID11 } = await import("node:crypto");
92079
+ const { randomUUID: randomUUID12 } = await import("node:crypto");
90397
92080
  const payload = {
90398
- id: randomUUID11(),
92081
+ id: randomUUID12(),
90399
92082
  timestamp: entry.timestamp,
90400
92083
  action: entry.operation,
90401
92084
  taskId: entry.metadata.taskId ?? "system",
@@ -90416,7 +92099,7 @@ async function writeToSqlite(entry, requestId) {
90416
92099
  };
90417
92100
  const parsed = AuditLogInsertSchema2.safeParse(payload);
90418
92101
  if (!parsed.success) {
90419
- log8.warn(
92102
+ log9.warn(
90420
92103
  { issues: parsed.error.issues },
90421
92104
  "Audit payload failed Zod validation; skipping insert"
90422
92105
  );
@@ -90425,7 +92108,7 @@ async function writeToSqlite(entry, requestId) {
90425
92108
  const db = await getDb4(process.cwd());
90426
92109
  await db.insert(auditLog2).values(parsed.data).run();
90427
92110
  } catch (err) {
90428
- log8.warn({ err }, "Failed to write audit entry to SQLite");
92111
+ log9.warn({ err }, "Failed to write audit entry to SQLite");
90429
92112
  }
90430
92113
  }
90431
92114
  function createAudit() {
@@ -90456,7 +92139,7 @@ function createAudit() {
90456
92139
  },
90457
92140
  error: response.error?.message
90458
92141
  };
90459
- log8.info(
92142
+ log9.info(
90460
92143
  {
90461
92144
  domain: entry.domain,
90462
92145
  operation: entry.operation,
@@ -90473,7 +92156,7 @@ function createAudit() {
90473
92156
  await writeToSqlite(entry, req.requestId);
90474
92157
  } else {
90475
92158
  writeToSqlite(entry, req.requestId).catch((err) => {
90476
- log8.error({ err }, "Failed to persist audit entry to SQLite");
92159
+ log9.error({ err }, "Failed to persist audit entry to SQLite");
90477
92160
  });
90478
92161
  }
90479
92162
  return response;
@@ -90954,7 +92637,7 @@ async function handleMcpToolCall(gateway, domain2, operation, params, requestId)
90954
92637
  operation,
90955
92638
  params,
90956
92639
  source: "mcp",
90957
- requestId: requestId || randomUUID9()
92640
+ requestId: requestId || randomUUID10()
90958
92641
  };
90959
92642
  return dispatcher.dispatch(req);
90960
92643
  }
@@ -91045,7 +92728,7 @@ function registerQueryTool() {
91045
92728
  }
91046
92729
 
91047
92730
  // packages/cleo/src/mcp/lib/background-jobs.ts
91048
- import { randomUUID as randomUUID10 } from "crypto";
92731
+ import { randomUUID as randomUUID11 } from "crypto";
91049
92732
  var BackgroundJobManager = class {
91050
92733
  jobs;
91051
92734
  abortControllers;
@@ -91078,7 +92761,7 @@ var BackgroundJobManager = class {
91078
92761
  `Maximum concurrent jobs reached (${this.maxJobs}). Cancel or wait for existing jobs to complete.`
91079
92762
  );
91080
92763
  }
91081
- const jobId = randomUUID10();
92764
+ const jobId = randomUUID11();
91082
92765
  const abortController = new AbortController();
91083
92766
  const job = {
91084
92767
  id: jobId,
@@ -91770,30 +93453,30 @@ async function main() {
91770
93453
  projectInfo?.projectHash
91771
93454
  );
91772
93455
  startupLog = getLogger("mcp:startup");
91773
- const log9 = startupLog;
93456
+ const log10 = startupLog;
91774
93457
  const cleoVersion = getCleoVersion();
91775
- log9.info(
93458
+ log10.info(
91776
93459
  { version: cleoVersion, projectHash: projectInfo?.projectHash, logLevel: config2.logLevel },
91777
93460
  "CLEO MCP server starting"
91778
93461
  );
91779
- log9.info(
93462
+ log10.info(
91780
93463
  { enableMetrics: config2.enableMetrics },
91781
93464
  `Metrics: ${config2.enableMetrics ? "enabled" : "disabled"}`
91782
93465
  );
91783
93466
  Promise.resolve().then(() => (init_internal(), internal_exports)).then(
91784
93467
  ({ loadConfig: loadCoreConfig }) => loadCoreConfig().then((coreConfig) => pruneAuditLog(cleoDir, coreConfig.logging))
91785
- ).catch((err) => log9.warn({ err }, "audit log pruning failed"));
91786
- log9.info("Initializing dispatch layer");
93468
+ ).catch((err) => log10.warn({ err }, "audit log pruning failed"));
93469
+ log10.info("Initializing dispatch layer");
91787
93470
  initMcpDispatcher({
91788
93471
  rateLimiting: config2.rateLimiting,
91789
93472
  strictMode: true
91790
93473
  });
91791
- log9.info("Dispatch layer initialized");
93474
+ log10.info("Dispatch layer initialized");
91792
93475
  const jobManager = new BackgroundJobManager({ maxJobs: 10, retentionMs: 36e5 });
91793
93476
  setJobManager(jobManager);
91794
- log9.info({ maxJobs: 10, retentionMs: 36e5 }, "Background job manager initialized");
93477
+ log10.info({ maxJobs: 10, retentionMs: 36e5 }, "Background job manager initialized");
91795
93478
  const cache = new QueryCache(config2.queryCacheTtl, config2.queryCache);
91796
- log9.info(
93479
+ log10.info(
91797
93480
  { enabled: config2.queryCache, ttlMs: config2.queryCacheTtl },
91798
93481
  `Query cache: ${config2.queryCache ? "enabled" : "disabled"}`
91799
93482
  );
@@ -91810,7 +93493,7 @@ async function main() {
91810
93493
  }
91811
93494
  );
91812
93495
  registerMemoryResources(server);
91813
- log9.info("Memory resources registered");
93496
+ log10.info("Memory resources registered");
91814
93497
  server.setRequestHandler(ListToolsRequestSchema, async () => {
91815
93498
  return {
91816
93499
  tools: [registerQueryTool(), registerMutateTool()]
@@ -92005,11 +93688,11 @@ async function main() {
92005
93688
  cache,
92006
93689
  jobManager
92007
93690
  };
92008
- log9.info("Connecting to stdio transport");
93691
+ log10.info("Connecting to stdio transport");
92009
93692
  const transport = new StdioServerTransport();
92010
93693
  await server.connect(transport);
92011
- log9.info({ transport: "stdio" }, "Server started successfully");
92012
- log9.info("Ready for requests");
93694
+ log10.info({ transport: "stdio" }, "Server started successfully");
93695
+ log10.info("Ready for requests");
92013
93696
  } catch (error40) {
92014
93697
  startupLog.fatal({ err: error40 }, "Failed to start server");
92015
93698
  process.exit(1);