@cleocode/core 2026.4.51 → 2026.4.53

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/index.js CHANGED
@@ -9575,11 +9575,14 @@ var init_brain_schema = __esm({
9575
9575
  source: text("source").notNull(),
9576
9576
  /** Estimated tokens consumed by this retrieval. */
9577
9577
  tokensUsed: integer("tokens_used"),
9578
+ /** Session ID (soft FK to tasks.db sessions). Enables grouping retrievals by session for STDP analysis. */
9579
+ sessionId: text("session_id"),
9578
9580
  createdAt: text("created_at").notNull().default(sql2`(datetime('now'))`)
9579
9581
  },
9580
9582
  (table) => [
9581
9583
  index("idx_retrieval_log_created").on(table.createdAt),
9582
- index("idx_retrieval_log_source").on(table.source)
9584
+ index("idx_retrieval_log_source").on(table.source),
9585
+ index("idx_retrieval_log_session").on(table.sessionId)
9583
9586
  ]
9584
9587
  );
9585
9588
  brainPlasticityEvents = sqliteTable(
@@ -11114,44 +11117,6 @@ var init_platform_paths = __esm({
11114
11117
  });
11115
11118
 
11116
11119
  // packages/core/src/paths.ts
11117
- var paths_exports = {};
11118
- __export(paths_exports, {
11119
- getAgentOutputsAbsolute: () => getAgentOutputsAbsolute,
11120
- getAgentOutputsDir: () => getAgentOutputsDir,
11121
- getAgentsHome: () => getAgentsHome,
11122
- getArchivePath: () => getArchivePath,
11123
- getBackupDir: () => getBackupDir,
11124
- getClaudeAgentsDir: () => getClaudeAgentsDir,
11125
- getClaudeMemDbPath: () => getClaudeMemDbPath,
11126
- getCleoCacheDir: () => getCleoCacheDir,
11127
- getCleoCantWorkflowsDir: () => getCleoCantWorkflowsDir,
11128
- getCleoConfigDir: () => getCleoConfigDir,
11129
- getCleoDir: () => getCleoDir,
11130
- getCleoDirAbsolute: () => getCleoDirAbsolute,
11131
- getCleoDocsDir: () => getCleoDocsDir,
11132
- getCleoGlobalAgentsDir: () => getCleoGlobalAgentsDir,
11133
- getCleoGlobalJustfilePath: () => getCleoGlobalJustfilePath,
11134
- getCleoGlobalRecipesDir: () => getCleoGlobalRecipesDir,
11135
- getCleoHome: () => getCleoHome,
11136
- getCleoLogDir: () => getCleoLogDir,
11137
- getCleoPiExtensionsDir: () => getCleoPiExtensionsDir,
11138
- getCleoSchemasDir: () => getCleoSchemasDir,
11139
- getCleoTempDir: () => getCleoTempDir,
11140
- getCleoTemplatesDir: () => getCleoTemplatesDir,
11141
- getCleoTemplatesTildePath: () => getCleoTemplatesTildePath,
11142
- getConfigPath: () => getConfigPath,
11143
- getGlobalConfigPath: () => getGlobalConfigPath,
11144
- getLogPath: () => getLogPath,
11145
- getManifestArchivePath: () => getManifestArchivePath,
11146
- getManifestPath: () => getManifestPath,
11147
- getProjectRoot: () => getProjectRoot,
11148
- getSessionsPath: () => getSessionsPath,
11149
- getTaskPath: () => getTaskPath,
11150
- isAbsolutePath: () => isAbsolutePath,
11151
- isProjectInitialized: () => isProjectInitialized,
11152
- resolveProjectPath: () => resolveProjectPath,
11153
- worktreeScope: () => worktreeScope
11154
- });
11155
11120
  import { AsyncLocalStorage } from "node:async_hooks";
11156
11121
  import { existsSync as existsSync3, readFileSync as readFileSync2 } from "node:fs";
11157
11122
  import { homedir } from "node:os";
@@ -11170,9 +11135,6 @@ function getCleoTemplatesDir() {
11170
11135
  function getCleoSchemasDir() {
11171
11136
  return join4(getCleoHome(), "schemas");
11172
11137
  }
11173
- function getCleoDocsDir() {
11174
- return join4(getCleoHome(), "docs");
11175
- }
11176
11138
  function getCleoDir(cwd) {
11177
11139
  if (cwd) {
11178
11140
  return getCleoDirAbsolute(cwd);
@@ -11244,15 +11206,6 @@ function getTaskPath(cwd) {
11244
11206
  function getConfigPath(cwd) {
11245
11207
  return join4(getCleoDirAbsolute(cwd), "config.json");
11246
11208
  }
11247
- function getSessionsPath(cwd) {
11248
- return join4(getCleoDirAbsolute(cwd), "sessions.json");
11249
- }
11250
- function getArchivePath(cwd) {
11251
- return join4(getCleoDirAbsolute(cwd), "tasks-archive.json");
11252
- }
11253
- function getLogPath(cwd) {
11254
- return join4(getCleoDirAbsolute(cwd), "logs", "cleo.log");
11255
- }
11256
11209
  function getBackupDir(cwd) {
11257
11210
  return join4(getCleoDirAbsolute(cwd), "backups", "operational");
11258
11211
  }
@@ -11360,9 +11313,6 @@ function getClaudeAgentsDir() {
11360
11313
  const claudeDir = process.env["CLAUDE_HOME"] ?? join4(homedir(), ".claude");
11361
11314
  return join4(claudeDir, "agents");
11362
11315
  }
11363
- function getClaudeMemDbPath() {
11364
- return process.env["CLAUDE_MEM_DB"] ?? join4(homedir(), ".claude-mem", "claude-mem.db");
11365
- }
11366
11316
  var worktreeScope, DEFAULT_AGENT_OUTPUTS_DIR;
11367
11317
  var init_paths = __esm({
11368
11318
  "packages/core/src/paths.ts"() {
@@ -14382,7 +14332,7 @@ function clearEmbeddingProvider() {
14382
14332
  currentProvider = null;
14383
14333
  }
14384
14334
  async function embedText(text3) {
14385
- if (!currentProvider || !currentProvider.isAvailable()) return null;
14335
+ if (!currentProvider?.isAvailable()) return null;
14386
14336
  return currentProvider.embed(text3);
14387
14337
  }
14388
14338
  function isEmbeddingAvailable() {
@@ -19364,7 +19314,7 @@ function parseIdPrefix(id) {
19364
19314
  return null;
19365
19315
  }
19366
19316
  async function searchSimilar(query, projectRoot, limit) {
19367
- if (!query || !query.trim()) return [];
19317
+ if (!query?.trim()) return [];
19368
19318
  if (!isEmbeddingAvailable()) return [];
19369
19319
  const maxResults = limit ?? 10;
19370
19320
  const queryVector = await embedText(query);
@@ -46911,7 +46861,7 @@ async function computeLastSession(projectRoot, scopeFilter) {
46911
46861
  const accessor = await getAccessor(projectRoot);
46912
46862
  const allSessions = await accessor.loadSessions();
46913
46863
  const session = allSessions.find((s) => s.id === sessionId);
46914
- if (!session || !session.endedAt) return null;
46864
+ if (!session?.endedAt) return null;
46915
46865
  let duration3 = 0;
46916
46866
  if (session.startedAt) {
46917
46867
  duration3 = Math.round(
@@ -48098,10 +48048,17 @@ async function searchBrainCompact(projectRoot, params) {
48098
48048
  setImmediate(() => {
48099
48049
  incrementCitationCounts(projectRoot, returnedIds).catch(() => {
48100
48050
  });
48101
- logRetrieval(projectRoot, query, returnedIds, "find-rrf", results2.length * 50).catch(
48102
- () => {
48103
- }
48104
- );
48051
+ getCurrentSessionId(projectRoot).then((sessionId) => {
48052
+ return logRetrieval(
48053
+ projectRoot,
48054
+ query,
48055
+ returnedIds,
48056
+ "find-rrf",
48057
+ results2.length * 50,
48058
+ sessionId
48059
+ );
48060
+ }).catch(() => {
48061
+ });
48105
48062
  });
48106
48063
  }
48107
48064
  return { results: results2, total: results2.length, tokensEstimated: results2.length * 50 };
@@ -48164,7 +48121,16 @@ async function searchBrainCompact(projectRoot, params) {
48164
48121
  setImmediate(() => {
48165
48122
  incrementCitationCounts(projectRoot, returnedIds).catch(() => {
48166
48123
  });
48167
- logRetrieval(projectRoot, query, returnedIds, "find", results.length * 50).catch(() => {
48124
+ getCurrentSessionId(projectRoot).then((sessionId) => {
48125
+ return logRetrieval(
48126
+ projectRoot,
48127
+ query,
48128
+ returnedIds,
48129
+ "find",
48130
+ results.length * 50,
48131
+ sessionId
48132
+ );
48133
+ }).catch(() => {
48168
48134
  });
48169
48135
  });
48170
48136
  }
@@ -48352,13 +48318,16 @@ async function fetchBrainEntries(projectRoot, params) {
48352
48318
  setImmediate(() => {
48353
48319
  incrementCitationCounts(projectRoot, fetchedIds).catch(() => {
48354
48320
  });
48355
- logRetrieval(
48356
- projectRoot,
48357
- fetchedIds.join(","),
48358
- fetchedIds,
48359
- "fetch",
48360
- results.length * 500
48361
- ).catch(() => {
48321
+ getCurrentSessionId(projectRoot).then((sessionId) => {
48322
+ return logRetrieval(
48323
+ projectRoot,
48324
+ fetchedIds.join(","),
48325
+ fetchedIds,
48326
+ "fetch",
48327
+ results.length * 500,
48328
+ sessionId
48329
+ );
48330
+ }).catch(() => {
48362
48331
  });
48363
48332
  });
48364
48333
  }
@@ -48776,6 +48745,15 @@ async function retrieveWithBudget(projectRoot, query, tokenBudget = 500, options
48776
48745
  excluded
48777
48746
  };
48778
48747
  }
48748
+ async function getCurrentSessionId(projectRoot) {
48749
+ try {
48750
+ const { sessionStatus: sessionStatus2 } = await Promise.resolve().then(() => (init_sessions2(), sessions_exports2));
48751
+ const session = await sessionStatus2(projectRoot);
48752
+ return session?.id;
48753
+ } catch {
48754
+ return void 0;
48755
+ }
48756
+ }
48779
48757
  async function incrementCitationCounts(projectRoot, ids) {
48780
48758
  if (ids.length === 0) return;
48781
48759
  const { getBrainDb: getBrainDb2, getBrainNativeDb: getBrainNativeDb2 } = await Promise.resolve().then(() => (init_brain_sqlite(), brain_sqlite_exports));
@@ -48802,13 +48780,13 @@ async function incrementCitationCounts(projectRoot, ids) {
48802
48780
  }
48803
48781
  }
48804
48782
  }
48805
- async function logRetrieval(projectRoot, query, entryIds, source, tokensUsed) {
48783
+ async function logRetrieval(projectRoot, query, entryIds, source, tokensUsed, sessionId) {
48806
48784
  if (entryIds.length === 0) return;
48807
48785
  const { getBrainDb: getBrainDb2, getBrainNativeDb: getBrainNativeDb2 } = await Promise.resolve().then(() => (init_brain_sqlite(), brain_sqlite_exports));
48808
48786
  await getBrainDb2(projectRoot);
48809
48787
  const nativeDb = getBrainNativeDb2();
48810
48788
  if (!nativeDb) return;
48811
- const createSql = "CREATE TABLE IF NOT EXISTS brain_retrieval_log (id INTEGER PRIMARY KEY AUTOINCREMENT,query TEXT NOT NULL,entry_ids TEXT NOT NULL,entry_count INTEGER NOT NULL,source TEXT NOT NULL,tokens_used INTEGER,created_at TEXT NOT NULL DEFAULT (datetime('now')))";
48789
+ const createSql = "CREATE TABLE IF NOT EXISTS brain_retrieval_log (id INTEGER PRIMARY KEY AUTOINCREMENT,query TEXT NOT NULL,entry_ids TEXT NOT NULL,entry_count INTEGER NOT NULL,source TEXT NOT NULL,tokens_used INTEGER,session_id TEXT,created_at TEXT NOT NULL DEFAULT (datetime('now')))";
48812
48790
  try {
48813
48791
  nativeDb.prepare(createSql).run();
48814
48792
  } catch {
@@ -48816,8 +48794,15 @@ async function logRetrieval(projectRoot, query, entryIds, source, tokensUsed) {
48816
48794
  }
48817
48795
  try {
48818
48796
  nativeDb.prepare(
48819
- "INSERT INTO brain_retrieval_log (query, entry_ids, entry_count, source, tokens_used) VALUES (?, ?, ?, ?, ?)"
48820
- ).run(query, entryIds.join(","), entryIds.length, source, tokensUsed ?? null);
48797
+ "INSERT INTO brain_retrieval_log (query, entry_ids, entry_count, source, tokens_used, session_id) VALUES (?, ?, ?, ?, ?, ?)"
48798
+ ).run(
48799
+ query,
48800
+ entryIds.join(","),
48801
+ entryIds.length,
48802
+ source,
48803
+ tokensUsed ?? null,
48804
+ sessionId ?? null
48805
+ );
48821
48806
  } catch {
48822
48807
  }
48823
48808
  }
@@ -49712,6 +49697,7 @@ __export(scaffold_exports, {
49712
49697
  checkConfig: () => checkConfig,
49713
49698
  checkGitignore: () => checkGitignore,
49714
49699
  checkGlobalHome: () => checkGlobalHome,
49700
+ checkGlobalIdentity: () => checkGlobalIdentity,
49715
49701
  checkGlobalTemplates: () => checkGlobalTemplates,
49716
49702
  checkLogDir: () => checkLogDir,
49717
49703
  checkMemoryBridge: () => checkMemoryBridge,
@@ -49728,6 +49714,7 @@ __export(scaffold_exports, {
49728
49714
  ensureContributorMcp: () => ensureContributorMcp,
49729
49715
  ensureGitignore: () => ensureGitignore,
49730
49716
  ensureGlobalHome: () => ensureGlobalHome,
49717
+ ensureGlobalIdentity: () => ensureGlobalIdentity,
49731
49718
  ensureGlobalScaffold: () => ensureGlobalScaffold,
49732
49719
  ensureGlobalTemplates: () => ensureGlobalTemplates,
49733
49720
  ensureProjectContext: () => ensureProjectContext,
@@ -49745,6 +49732,7 @@ import { execFile as execFile3 } from "node:child_process";
49745
49732
  import { randomUUID as randomUUID2 } from "node:crypto";
49746
49733
  import { existsSync as existsSync38, constants as fsConstants3, readFileSync as readFileSync23, statSync as statSync8 } from "node:fs";
49747
49734
  import { access as access3, copyFile as copyFile2, mkdir as mkdir6, readdir as readdir2, readFile as readFile7, rm as rm2, writeFile as writeFile6 } from "node:fs/promises";
49735
+ import { createRequire as createRequire6 } from "node:module";
49748
49736
  import { homedir as getHomedir } from "node:os";
49749
49737
  import { dirname as dirname10, join as join40, resolve as resolve5 } from "node:path";
49750
49738
  import { fileURLToPath as fileURLToPath4 } from "node:url";
@@ -50600,6 +50588,102 @@ async function ensureCleoOsHub() {
50600
50588
  details: `pi-extensions: ${piResult.copied} created/${piResult.kept} kept, global-recipes: ${recipesResult.copied} created/${recipesResult.kept} kept`
50601
50589
  };
50602
50590
  }
50591
+ function resolveIdentitySourcePath() {
50592
+ const monorepoPath = join40(
50593
+ process.cwd(),
50594
+ "packages",
50595
+ "cleo-os",
50596
+ "starter-bundle",
50597
+ "CLEOOS-IDENTITY.md"
50598
+ );
50599
+ if (existsSync38(monorepoPath)) return monorepoPath;
50600
+ try {
50601
+ const require2 = createRequire6(import.meta.url);
50602
+ const pkgJson = require2.resolve("@cleocode/cleo-os/package.json");
50603
+ const pkgDir = pkgJson.replace(/\/package\.json$/, "");
50604
+ const installedPath = join40(pkgDir, "starter-bundle", "CLEOOS-IDENTITY.md");
50605
+ if (existsSync38(installedPath)) return installedPath;
50606
+ } catch {
50607
+ }
50608
+ return null;
50609
+ }
50610
+ async function ensureGlobalIdentity(forceRefresh = false) {
50611
+ const sourcePath = resolveIdentitySourcePath();
50612
+ if (!sourcePath) {
50613
+ return {
50614
+ action: "skipped",
50615
+ path: "",
50616
+ details: "CLEOOS-IDENTITY.md source not found in monorepo or installed package"
50617
+ };
50618
+ }
50619
+ const cleoHome = getCleoHome();
50620
+ const dst = join40(cleoHome, "CLEOOS-IDENTITY.md");
50621
+ try {
50622
+ await mkdir6(cleoHome, { recursive: true });
50623
+ } catch (err) {
50624
+ return {
50625
+ action: "skipped",
50626
+ path: dst,
50627
+ details: `Failed to create global cleo home: ${err instanceof Error ? err.message : String(err)}`
50628
+ };
50629
+ }
50630
+ if (existsSync38(dst) && !forceRefresh) {
50631
+ return { action: "skipped", path: dst, details: "identity already present" };
50632
+ }
50633
+ const existedBefore = existsSync38(dst);
50634
+ try {
50635
+ const content = readFileSync23(sourcePath, "utf-8");
50636
+ await writeFile6(dst, content);
50637
+ return {
50638
+ action: existedBefore ? "repaired" : "created",
50639
+ path: dst,
50640
+ details: `from ${sourcePath}`
50641
+ };
50642
+ } catch (err) {
50643
+ return {
50644
+ action: "skipped",
50645
+ path: dst,
50646
+ details: `Failed to write identity: ${err instanceof Error ? err.message : String(err)}`
50647
+ };
50648
+ }
50649
+ }
50650
+ function checkGlobalIdentity() {
50651
+ const cleoHome = getCleoHome();
50652
+ const identityPath = join40(cleoHome, "CLEOOS-IDENTITY.md");
50653
+ if (!existsSync38(identityPath)) {
50654
+ return {
50655
+ id: "global_identity",
50656
+ category: "global",
50657
+ status: "failed",
50658
+ message: "Global CLEOOS-IDENTITY.md not found \u2014 orchestrator persona missing",
50659
+ details: { path: identityPath, exists: false },
50660
+ fix: "cleo upgrade (auto-deploys identity)"
50661
+ };
50662
+ }
50663
+ let size = 0;
50664
+ try {
50665
+ size = statSync8(identityPath).size;
50666
+ } catch {
50667
+ }
50668
+ if (size === 0) {
50669
+ return {
50670
+ id: "global_identity",
50671
+ category: "global",
50672
+ status: "failed",
50673
+ message: "Global CLEOOS-IDENTITY.md exists but is empty",
50674
+ details: { path: identityPath, exists: true, size: 0 },
50675
+ fix: "cleo upgrade --refresh-identity"
50676
+ };
50677
+ }
50678
+ return {
50679
+ id: "global_identity",
50680
+ category: "global",
50681
+ status: "passed",
50682
+ message: "Global CLEOOS-IDENTITY.md present",
50683
+ details: { path: identityPath, exists: true, size },
50684
+ fix: ""
50685
+ };
50686
+ }
50603
50687
  function checkGlobalHome() {
50604
50688
  const cleoHome = getCleoHome();
50605
50689
  if (!existsSync38(cleoHome)) {
@@ -54007,7 +54091,7 @@ __export(parser_exports, {
54007
54091
  parseFile: () => parseFile2
54008
54092
  });
54009
54093
  import { readFileSync as readFileSync64 } from "node:fs";
54010
- import { createRequire as createRequire7 } from "node:module";
54094
+ import { createRequire as createRequire8 } from "node:module";
54011
54095
  import { relative as relative7 } from "node:path";
54012
54096
  function tryRequire(id) {
54013
54097
  try {
@@ -54208,7 +54292,7 @@ var init_parser3 = __esm({
54208
54292
  "packages/core/src/code/parser.ts"() {
54209
54293
  "use strict";
54210
54294
  init_tree_sitter_languages();
54211
- _require7 = createRequire7(import.meta.url);
54295
+ _require7 = createRequire8(import.meta.url);
54212
54296
  _ParserClass = null;
54213
54297
  _QueryClass = null;
54214
54298
  _parserInstance = null;
@@ -54308,7 +54392,7 @@ var init_parser3 = __esm({
54308
54392
 
54309
54393
  // packages/core/src/system/dependencies.ts
54310
54394
  import { execFileSync as execFileSync10 } from "node:child_process";
54311
- import { createRequire as createRequire8 } from "node:module";
54395
+ import { createRequire as createRequire9 } from "node:module";
54312
54396
  import { dirname as dirname19 } from "node:path";
54313
54397
  import { fileURLToPath as fileURLToPath5 } from "node:url";
54314
54398
  function tryExec(cmd, args, timeoutMs = 3e3) {
@@ -54578,7 +54662,7 @@ var init_dependencies = __esm({
54578
54662
  "packages/core/src/system/dependencies.ts"() {
54579
54663
  "use strict";
54580
54664
  init_platform();
54581
- _require8 = createRequire8(import.meta.url);
54665
+ _require8 = createRequire9(import.meta.url);
54582
54666
  _dirname = dirname19(fileURLToPath5(import.meta.url));
54583
54667
  DEPENDENCY_SPECS = [
54584
54668
  // ── Required ────────────────────────────────────────────────────────────
@@ -54780,8 +54864,8 @@ import { platform as platform4 } from "node:os";
54780
54864
  import { basename as basename17, dirname as dirname23, join as join106 } from "node:path";
54781
54865
  async function resolveSeedAgentsDir() {
54782
54866
  try {
54783
- const { createRequire: createRequire10 } = await import("node:module");
54784
- const req = createRequire10(import.meta.url);
54867
+ const { createRequire: createRequire11 } = await import("node:module");
54868
+ const req = createRequire11(import.meta.url);
54785
54869
  const agentsPkgMain = req.resolve("@cleocode/agents/package.json");
54786
54870
  const agentsPkgRoot = dirname23(agentsPkgMain);
54787
54871
  const candidate = join106(agentsPkgRoot, "seed-agents");
@@ -54808,8 +54892,8 @@ async function resolveSeedAgentsDir() {
54808
54892
  async function initAgentDefinition(created, warnings) {
54809
54893
  let agentSourceDir = null;
54810
54894
  try {
54811
- const { createRequire: createRequire10 } = await import("node:module");
54812
- const req = createRequire10(import.meta.url);
54895
+ const { createRequire: createRequire11 } = await import("node:module");
54896
+ const req = createRequire11(import.meta.url);
54813
54897
  const agentsPkgMain = req.resolve("@cleocode/agents/package.json");
54814
54898
  const agentsPkgRoot = dirname23(agentsPkgMain);
54815
54899
  const candidate = join106(agentsPkgRoot, "cleo-subagent");
@@ -54875,8 +54959,8 @@ async function initCoreSkills(created, warnings) {
54875
54959
  const packageRoot = getPackageRoot();
54876
54960
  let ctSkillsRoot = null;
54877
54961
  try {
54878
- const { createRequire: createRequire10 } = await import("node:module");
54879
- const req = createRequire10(import.meta.url);
54962
+ const { createRequire: createRequire11 } = await import("node:module");
54963
+ const req = createRequire11(import.meta.url);
54880
54964
  const skillsPkgMain = req.resolve("@cleocode/skills/package.json");
54881
54965
  const skillsPkgRoot = dirname23(skillsPkgMain);
54882
54966
  if (existsSync106(join106(skillsPkgRoot, "skills.json"))) {
@@ -55384,8 +55468,8 @@ async function deployStarterBundle(cleoDir, created, warnings) {
55384
55468
  if (hasCantFiles) return;
55385
55469
  let starterBundleSrc = null;
55386
55470
  try {
55387
- const { createRequire: createRequire10 } = await import("node:module");
55388
- const req = createRequire10(import.meta.url);
55471
+ const { createRequire: createRequire11 } = await import("node:module");
55472
+ const req = createRequire11(import.meta.url);
55389
55473
  const cleoOsPkgMain = req.resolve("@cleocode/cleo-os/package.json");
55390
55474
  const cleoOsPkgRoot = dirname23(cleoOsPkgMain);
55391
55475
  const candidate = join106(cleoOsPkgRoot, "starter-bundle");
@@ -55425,20 +55509,20 @@ async function deployStarterBundle(cleoDir, created, warnings) {
55425
55509
  }
55426
55510
  }
55427
55511
  }
55428
- const identitySrc = join106(starterBundleSrc, "CLEOOS-IDENTITY.md");
55429
- const identityDst = join106(cleoDir, "CLEOOS-IDENTITY.md");
55430
- if (existsSync106(identitySrc) && !existsSync106(identityDst)) {
55431
- await copyFile4(identitySrc, identityDst);
55432
- }
55433
55512
  try {
55434
- const { getCleoHome: getCleoHome2 } = await Promise.resolve().then(() => (init_paths(), paths_exports));
55435
- const globalIdentityDst = join106(getCleoHome2(), "CLEOOS-IDENTITY.md");
55436
- if (existsSync106(identitySrc) && !existsSync106(globalIdentityDst)) {
55437
- await copyFile4(identitySrc, globalIdentityDst);
55513
+ const { ensureGlobalIdentity: ensureGlobalIdentity2 } = await Promise.resolve().then(() => (init_scaffold(), scaffold_exports));
55514
+ const identityResult = await ensureGlobalIdentity2();
55515
+ if (identityResult.action === "created") {
55516
+ created.push(`identity: ${identityResult.path}`);
55517
+ } else if (identityResult.action === "skipped" && identityResult.details) {
55518
+ warnings.push(`identity skipped: ${identityResult.details}`);
55438
55519
  }
55439
- } catch {
55520
+ } catch (err) {
55521
+ warnings.push(`identity deploy failed: ${err instanceof Error ? err.message : String(err)}`);
55440
55522
  }
55441
- created.push("starter-bundle: team + agent .cant files + identity deployed to .cleo/");
55523
+ created.push(
55524
+ "starter-bundle: team + agent .cant files deployed to .cleo/ (identity at global XDG)"
55525
+ );
55442
55526
  }
55443
55527
  var DIR_SYMLINK_TYPE2;
55444
55528
  var init_init = __esm({
@@ -61391,7 +61475,7 @@ function prepareSpawnMulti(skillNames, tokenValues, cwd) {
61391
61475
  const skillName = skillNames[i];
61392
61476
  const isPrimary = i === 0;
61393
61477
  const skill = findSkill(skillName, cwd);
61394
- if (!skill || !skill.content) {
61478
+ if (!skill?.content) {
61395
61479
  continue;
61396
61480
  }
61397
61481
  let content = isPrimary ? skill.content : loadProgressive(skill.content);
@@ -64352,8 +64436,8 @@ init_agent_outputs();
64352
64436
  // packages/core/src/migration/checksum.ts
64353
64437
  import { createHash as createHash7 } from "node:crypto";
64354
64438
  import { readFileSync as readFileSync34 } from "node:fs";
64355
- import { createRequire as createRequire6 } from "node:module";
64356
- var _require6 = createRequire6(import.meta.url);
64439
+ import { createRequire as createRequire7 } from "node:module";
64440
+ var _require6 = createRequire7(import.meta.url);
64357
64441
  var { DatabaseSync: DatabaseSync4 } = _require6("node:sqlite");
64358
64442
  async function computeChecksum(filePath) {
64359
64443
  const content = readFileSync34(filePath);
@@ -73560,7 +73644,7 @@ async function injectProtocol(skillContent, taskId, tokenValues, cwd, tier) {
73560
73644
  }
73561
73645
  async function orchestratorSpawnSkill(taskId, skillName, tokenValues, cwd, tier) {
73562
73646
  const skill = findSkill(skillName, cwd);
73563
- if (!skill || !skill.content) {
73647
+ if (!skill?.content) {
73564
73648
  throw new CleoError(4 /* NOT_FOUND */, `Skill not found: ${skillName}`, {
73565
73649
  fix: `Check skills directory for ${skillName}/SKILL.md`
73566
73650
  });
@@ -74096,7 +74180,7 @@ async function buildPrompt(taskId, templateName = "TASK-EXECUTOR", cwd, tier) {
74096
74180
  throw new CleoError(4 /* NOT_FOUND */, `Task ${taskId} not found`);
74097
74181
  }
74098
74182
  const skill = findSkill(templateName, cwd);
74099
- if (!skill || !skill.content) {
74183
+ if (!skill?.content) {
74100
74184
  const { canonical } = mapSkillName(templateName);
74101
74185
  throw new CleoError(4 /* NOT_FOUND */, `Skill template ${templateName} not found`, {
74102
74186
  fix: `Expected at skills/${canonical}/SKILL.md`
@@ -76654,7 +76738,7 @@ async function analyzeArchive(opts, accessor) {
76654
76738
  const acc = accessor ?? await getAccessor(opts.cwd);
76655
76739
  const data = await acc.loadArchive();
76656
76740
  const reportType = opts.report ?? "summary";
76657
- if (!data || !data.archivedTasks?.length) {
76741
+ if (!data?.archivedTasks?.length) {
76658
76742
  return {
76659
76743
  report: reportType,
76660
76744
  filters: null,
@@ -77239,7 +77323,7 @@ init_schema_management();
77239
77323
  init_data_accessor();
77240
77324
  import { execFileSync as execFileSync11 } from "node:child_process";
77241
77325
  import { existsSync as existsSync90, readFileSync as readFileSync65, statSync as statSync19 } from "node:fs";
77242
- import { createRequire as createRequire9 } from "node:module";
77326
+ import { createRequire as createRequire10 } from "node:module";
77243
77327
  import { join as join92 } from "node:path";
77244
77328
 
77245
77329
  // packages/core/src/validation/doctor/checks.ts
@@ -78053,7 +78137,7 @@ function calculateHealthStatus(checks) {
78053
78137
 
78054
78138
  // packages/core/src/system/health.ts
78055
78139
  init_dependencies();
78056
- var _require9 = createRequire9(import.meta.url);
78140
+ var _require9 = createRequire10(import.meta.url);
78057
78141
  var databaseSyncCtor = (() => {
78058
78142
  try {
78059
78143
  return _require9("node:sqlite").DatabaseSync;
@@ -78601,6 +78685,7 @@ async function coreDoctorReport(projectRoot) {
78601
78685
  });
78602
78686
  checks.push(mapCheckResult(checkGlobalHome()));
78603
78687
  checks.push(mapCheckResult(checkGlobalTemplates()));
78688
+ checks.push(mapCheckResult(checkGlobalIdentity()));
78604
78689
  checks.push(mapSchemaCheckResult(checkGlobalSchemas()));
78605
78690
  checks.push(mapCheckResult(checkLogDir(projectRoot)));
78606
78691
  const hookResults = await checkGitHooks(projectRoot);
@@ -83194,16 +83279,12 @@ function allEpicChildrenVerified(epicId, tasks2) {
83194
83279
  if (children.length === 0) return false;
83195
83280
  const incomplete = children.filter((t) => t.status !== "done");
83196
83281
  if (incomplete.length > 0) return false;
83197
- const unverified = children.filter(
83198
- (t) => t.status === "done" && (!t.verification || !t.verification.passed)
83199
- );
83282
+ const unverified = children.filter((t) => t.status === "done" && !t.verification?.passed);
83200
83283
  return unverified.length === 0;
83201
83284
  }
83202
83285
  function allSiblingsVerified(parentId, tasks2) {
83203
83286
  const siblings = tasks2.filter((t) => t.parentId === parentId);
83204
- const unverifiedDone = siblings.filter(
83205
- (t) => t.status === "done" && (!t.verification || !t.verification.passed)
83206
- );
83287
+ const unverifiedDone = siblings.filter((t) => t.status === "done" && !t.verification?.passed);
83207
83288
  const incomplete = siblings.filter(
83208
83289
  (t) => t.status === "pending" || t.status === "active" || t.status === "blocked"
83209
83290
  );
@@ -83580,7 +83661,7 @@ import { randomUUID as randomUUID8 } from "node:crypto";
83580
83661
  init_paths();
83581
83662
  import { existsSync as existsSync107, readFileSync as readFileSync77, writeFileSync as writeFileSync20 } from "node:fs";
83582
83663
  import { join as join107 } from "node:path";
83583
- function getCurrentSessionId(cwd) {
83664
+ function getCurrentSessionId2(cwd) {
83584
83665
  if (process.env.CLEO_SESSION) return process.env.CLEO_SESSION;
83585
83666
  const sessionFile = join107(getCleoDir(cwd), ".current-session");
83586
83667
  if (existsSync107(sessionFile)) {
@@ -83608,7 +83689,7 @@ function createCliMeta(operation, duration_ms = 0) {
83608
83689
  duration_ms,
83609
83690
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
83610
83691
  };
83611
- const sessionId = getCurrentSessionId();
83692
+ const sessionId = getCurrentSessionId2();
83612
83693
  if (sessionId) {
83613
83694
  meta3["sessionId"] = sessionId;
83614
83695
  }