@cleocode/core 2026.6.8 → 2026.6.10
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/docs/display-alias.d.ts +97 -0
- package/dist/docs/display-alias.d.ts.map +1 -0
- package/dist/docs/display-alias.js +136 -0
- package/dist/docs/display-alias.js.map +1 -0
- package/dist/docs/docs-read-model.d.ts +7 -0
- package/dist/docs/docs-read-model.d.ts.map +1 -1
- package/dist/docs/docs-read-model.js +11 -2
- package/dist/docs/docs-read-model.js.map +1 -1
- package/dist/docs/export-document.js +259 -131
- package/dist/docs/export-document.js.map +2 -2
- package/dist/docs/index.d.ts +2 -0
- package/dist/docs/index.d.ts.map +1 -1
- package/dist/docs/index.js +1 -0
- package/dist/docs/index.js.map +1 -1
- package/dist/docs/numbering.d.ts +29 -0
- package/dist/docs/numbering.d.ts.map +1 -1
- package/dist/docs/numbering.js +41 -0
- package/dist/docs/numbering.js.map +1 -1
- package/dist/internal.d.ts +3 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +2 -1
- package/dist/internal.js.map +1 -1
- package/dist/llm/plugin-facade.js +372 -243
- package/dist/llm/plugin-facade.js.map +2 -2
- package/dist/store/attachment-store.d.ts +5 -0
- package/dist/store/attachment-store.d.ts.map +1 -1
- package/dist/store/attachment-store.js +7 -1
- package/dist/store/attachment-store.js.map +1 -1
- package/dist/store/dual-scope-db.d.ts.map +1 -1
- package/dist/store/dual-scope-db.js +15 -0
- package/dist/store/dual-scope-db.js.map +1 -1
- package/dist/store/migration-manager.d.ts +99 -0
- package/dist/store/migration-manager.d.ts.map +1 -1
- package/dist/store/migration-manager.js +323 -23
- package/dist/store/migration-manager.js.map +1 -1
- package/dist/store/schema/attachments.d.ts +16 -0
- package/dist/store/schema/attachments.d.ts.map +1 -1
- package/dist/store/schema/attachments.js +30 -0
- package/dist/store/schema/attachments.js.map +1 -1
- package/migrations/drizzle-tasks/20260606000001_t11875-attachments-display-alias/migration.sql +46 -0
- package/package.json +12 -12
|
@@ -14555,7 +14555,7 @@ var init_sql = __esm({
|
|
|
14555
14555
|
return new SQL([new StringChunk(str)]);
|
|
14556
14556
|
}
|
|
14557
14557
|
_sql.raw = raw;
|
|
14558
|
-
function
|
|
14558
|
+
function join23(chunks, separator) {
|
|
14559
14559
|
const result = [];
|
|
14560
14560
|
for (const [i, chunk] of chunks.entries()) {
|
|
14561
14561
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -14563,7 +14563,7 @@ var init_sql = __esm({
|
|
|
14563
14563
|
}
|
|
14564
14564
|
return new SQL(result);
|
|
14565
14565
|
}
|
|
14566
|
-
_sql.join =
|
|
14566
|
+
_sql.join = join23;
|
|
14567
14567
|
function identifier(value) {
|
|
14568
14568
|
return new Name(value);
|
|
14569
14569
|
}
|
|
@@ -16950,7 +16950,7 @@ var init_select2 = __esm({
|
|
|
16950
16950
|
const baseTableName = this.tableName;
|
|
16951
16951
|
const tableName = getTableLikeName(table);
|
|
16952
16952
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
16953
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
16953
|
+
if (typeof tableName === "string" && this.config.joins?.some((join23) => join23.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
16954
16954
|
if (!this.isPartialSelect) {
|
|
16955
16955
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
16956
16956
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -20760,7 +20760,7 @@ var init_dialect = __esm({
|
|
|
20760
20760
|
if (!joins2) return;
|
|
20761
20761
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
20762
20762
|
if (!withEntries.length) return;
|
|
20763
|
-
return sql.join(withEntries.map(([k,
|
|
20763
|
+
return sql.join(withEntries.map(([k, join23]) => {
|
|
20764
20764
|
const relation = tableConfig.relations[k];
|
|
20765
20765
|
const isSingle2 = is(relation, One);
|
|
20766
20766
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -20771,7 +20771,7 @@ var init_dialect = __esm({
|
|
|
20771
20771
|
table: targetTable,
|
|
20772
20772
|
mode: isSingle2 ? "first" : "many",
|
|
20773
20773
|
schema,
|
|
20774
|
-
queryConfig:
|
|
20774
|
+
queryConfig: join23,
|
|
20775
20775
|
tableConfig: schema[relation.targetTableName],
|
|
20776
20776
|
relationWhere: filter,
|
|
20777
20777
|
isNested: true,
|
|
@@ -20785,7 +20785,7 @@ var init_dialect = __esm({
|
|
|
20785
20785
|
key: k,
|
|
20786
20786
|
selection: innerQuery.selection,
|
|
20787
20787
|
isArray: !isSingle2,
|
|
20788
|
-
isOptional: (relation.optional ?? false) ||
|
|
20788
|
+
isOptional: (relation.optional ?? false) || join23 !== true && !!join23.where
|
|
20789
20789
|
});
|
|
20790
20790
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
20791
20791
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb3}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -21606,7 +21606,7 @@ var init_update = __esm({
|
|
|
21606
21606
|
createJoin(joinType) {
|
|
21607
21607
|
return ((table, on) => {
|
|
21608
21608
|
const tableName = getTableLikeName(table);
|
|
21609
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
21609
|
+
if (typeof tableName === "string" && this.config.joins.some((join23) => join23.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
21610
21610
|
if (typeof on === "function") {
|
|
21611
21611
|
const from = this.config.from ? is(table, SQLiteTable) ? table[Table.Symbol.Columns] : is(table, Subquery) ? table._.selectedFields : is(table, SQLiteViewBase) ? table[ViewBaseConfig].selectedFields : void 0 : void 0;
|
|
21612
21612
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -22596,6 +22596,66 @@ var init_with_retry = __esm({
|
|
|
22596
22596
|
|
|
22597
22597
|
// packages/core/src/store/migration-manager.ts
|
|
22598
22598
|
import { copyFileSync, existsSync as existsSync2 } from "node:fs";
|
|
22599
|
+
import { dirname, join as join3 } from "node:path";
|
|
22600
|
+
function stripSqlComments(sql39) {
|
|
22601
|
+
return sql39.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
22602
|
+
}
|
|
22603
|
+
function computeEliminatedTables(migrations) {
|
|
22604
|
+
const createTableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/i;
|
|
22605
|
+
const dropTableRegex = /DROP\s+TABLE\s+(?:IF\s+EXISTS\s+)?[`"]?(\w+)[`"]?/i;
|
|
22606
|
+
const renameRegex = /ALTER\s+TABLE\s+[`"]?(\w+)[`"]?\s+RENAME\s+TO\s+[`"]?(\w+)[`"]?/i;
|
|
22607
|
+
const disposition = /* @__PURE__ */ new Map();
|
|
22608
|
+
const ordered = [...migrations].sort((a, b) => a.folderMillis - b.folderMillis);
|
|
22609
|
+
for (const migration of ordered) {
|
|
22610
|
+
const statements = Array.isArray(migration.sql) ? migration.sql : [migration.sql ?? ""];
|
|
22611
|
+
for (const rawStatement of statements) {
|
|
22612
|
+
const stripped = stripSqlComments(rawStatement);
|
|
22613
|
+
for (const clause of stripped.split(";")) {
|
|
22614
|
+
const create = createTableRegex.exec(clause);
|
|
22615
|
+
if (create) {
|
|
22616
|
+
disposition.set(create[1], true);
|
|
22617
|
+
continue;
|
|
22618
|
+
}
|
|
22619
|
+
const rename2 = renameRegex.exec(clause);
|
|
22620
|
+
if (rename2) {
|
|
22621
|
+
disposition.set(rename2[2], true);
|
|
22622
|
+
continue;
|
|
22623
|
+
}
|
|
22624
|
+
const drop = dropTableRegex.exec(clause);
|
|
22625
|
+
if (drop) {
|
|
22626
|
+
disposition.set(drop[1], false);
|
|
22627
|
+
}
|
|
22628
|
+
}
|
|
22629
|
+
}
|
|
22630
|
+
}
|
|
22631
|
+
const eliminated = /* @__PURE__ */ new Set();
|
|
22632
|
+
for (const [table, present] of disposition) {
|
|
22633
|
+
if (!present) eliminated.add(table);
|
|
22634
|
+
}
|
|
22635
|
+
return eliminated;
|
|
22636
|
+
}
|
|
22637
|
+
function resolveConsolidationCutoverPrefix(migrationsFolder) {
|
|
22638
|
+
const parent = dirname(migrationsFolder);
|
|
22639
|
+
for (const setName of ["drizzle-cleo-project", "drizzle-cleo-global"]) {
|
|
22640
|
+
const folder = join3(parent, setName);
|
|
22641
|
+
if (!existsSync2(folder)) continue;
|
|
22642
|
+
try {
|
|
22643
|
+
const consolidation = readMigrationFiles({ migrationsFolder: folder }).find(
|
|
22644
|
+
(m) => /-consolidation-cleo-/.test(m.name ?? "")
|
|
22645
|
+
);
|
|
22646
|
+
if (consolidation?.name) {
|
|
22647
|
+
return consolidation.name.slice(0, MIGRATION_TIMESTAMP_PREFIX_LEN);
|
|
22648
|
+
}
|
|
22649
|
+
} catch {
|
|
22650
|
+
}
|
|
22651
|
+
}
|
|
22652
|
+
return CONSOLIDATION_CUTOVER_PREFIX;
|
|
22653
|
+
}
|
|
22654
|
+
function isAtOrBeforeCutover(migrationName, cutoverPrefix) {
|
|
22655
|
+
const prefix = (migrationName ?? "").slice(0, MIGRATION_TIMESTAMP_PREFIX_LEN);
|
|
22656
|
+
if (prefix.length < MIGRATION_TIMESTAMP_PREFIX_LEN) return true;
|
|
22657
|
+
return prefix <= cutoverPrefix;
|
|
22658
|
+
}
|
|
22599
22659
|
function tableExists(nativeDb, tableName) {
|
|
22600
22660
|
const result = nativeDb.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name=?").get(tableName);
|
|
22601
22661
|
return !!result;
|
|
@@ -22622,9 +22682,9 @@ function insertJournalEntry(nativeDb, hash, createdAt, name2) {
|
|
|
22622
22682
|
`INSERT OR IGNORE INTO "__drizzle_migrations" ("hash", "created_at", "name") VALUES ('${hash}', ${createdAt}, '${name2}')`
|
|
22623
22683
|
);
|
|
22624
22684
|
}
|
|
22625
|
-
function probeAndMarkApplied(nativeDb, migration, logSubsystem) {
|
|
22685
|
+
function probeAndMarkApplied(nativeDb, migration, logSubsystem, eliminatedTables = /* @__PURE__ */ new Set(), consolidationCutoverPrefix = CONSOLIDATION_CUTOVER_PREFIX) {
|
|
22626
22686
|
const sqlStatements = Array.isArray(migration.sql) ? migration.sql : [migration.sql ?? ""];
|
|
22627
|
-
const fullSql = sqlStatements.join("\n");
|
|
22687
|
+
const fullSql = stripSqlComments(sqlStatements.join("\n"));
|
|
22628
22688
|
const alterColumnRegex = /ALTER\s+TABLE\s+[`"]?(\w+)[`"]?\s+ADD\s+COLUMN\s+[`"]?(\w+)[`"]?/gi;
|
|
22629
22689
|
const createTableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/gi;
|
|
22630
22690
|
const createIndexRegex = /CREATE\s+(?:UNIQUE\s+)?INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/gi;
|
|
@@ -22651,10 +22711,17 @@ function probeAndMarkApplied(nativeDb, migration, logSubsystem) {
|
|
|
22651
22711
|
}
|
|
22652
22712
|
const isRebuildOnlyMigration = allCreatedTablesAreRenamed && tableTargets.length > 0 && alterTargets.length === 0;
|
|
22653
22713
|
const performsTableRebuild = renameMap.size > 0;
|
|
22714
|
+
const createIndexWithTableRegex = /CREATE\s+(?:UNIQUE\s+)?INDEX\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?\s+ON\s+[`"]?(\w+)[`"]?/gi;
|
|
22715
|
+
const indexOnTable = /* @__PURE__ */ new Map();
|
|
22716
|
+
for (const m of fullSql.matchAll(createIndexWithTableRegex)) {
|
|
22717
|
+
indexOnTable.set(m[1], m[2]);
|
|
22718
|
+
}
|
|
22654
22719
|
const indexTargets = [];
|
|
22655
22720
|
if (!isRebuildOnlyMigration && !performsTableRebuild) {
|
|
22656
22721
|
for (const m of fullSql.matchAll(createIndexRegex)) {
|
|
22657
|
-
|
|
22722
|
+
const idx = m[1];
|
|
22723
|
+
if (eliminatedTables.has(indexOnTable.get(idx) ?? "")) continue;
|
|
22724
|
+
indexTargets.push(idx);
|
|
22658
22725
|
}
|
|
22659
22726
|
}
|
|
22660
22727
|
const triggerTargets = [];
|
|
@@ -22663,6 +22730,14 @@ function probeAndMarkApplied(nativeDb, migration, logSubsystem) {
|
|
|
22663
22730
|
}
|
|
22664
22731
|
const totalTargets = alterTargets.length + tableTargets.length + indexTargets.length + triggerTargets.length;
|
|
22665
22732
|
if (totalTargets === 0) {
|
|
22733
|
+
if (isAtOrBeforeCutover(migration.name, consolidationCutoverPrefix)) {
|
|
22734
|
+
insertJournalEntry(nativeDb, migration.hash, migration.folderMillis, migration.name ?? "");
|
|
22735
|
+
getLogger(logSubsystem).debug(
|
|
22736
|
+
{ migration: migration.name },
|
|
22737
|
+
`Zero-DDL pre-consolidation migration ${migration.name} stamped applied (subsumed; not re-run).`
|
|
22738
|
+
);
|
|
22739
|
+
return true;
|
|
22740
|
+
}
|
|
22666
22741
|
return false;
|
|
22667
22742
|
}
|
|
22668
22743
|
const allAltersPresent = alterTargets.every(({ table, column }) => {
|
|
@@ -22670,7 +22745,9 @@ function probeAndMarkApplied(nativeDb, migration, logSubsystem) {
|
|
|
22670
22745
|
const cols = nativeDb.prepare(`PRAGMA table_info(${table})`).all();
|
|
22671
22746
|
return cols.some((c) => c.name === column);
|
|
22672
22747
|
});
|
|
22673
|
-
const allTablesPresent = tableTargets.every(
|
|
22748
|
+
const allTablesPresent = tableTargets.every(
|
|
22749
|
+
(t) => tableExists(nativeDb, t) || eliminatedTables.has(t)
|
|
22750
|
+
);
|
|
22674
22751
|
const allIndexesPresent = indexTargets.every((idx) => {
|
|
22675
22752
|
const rows = nativeDb.prepare(`SELECT name FROM sqlite_master WHERE type='index' AND name=?`).all(idx);
|
|
22676
22753
|
return rows.length > 0;
|
|
@@ -22697,6 +22774,8 @@ function probeAndMarkApplied(nativeDb, migration, logSubsystem) {
|
|
|
22697
22774
|
return false;
|
|
22698
22775
|
}
|
|
22699
22776
|
function reconcileJournal(nativeDb, migrationsFolder, existenceTable2, logSubsystem) {
|
|
22777
|
+
const eliminatedTables = computeEliminatedTables(readMigrationFiles({ migrationsFolder }));
|
|
22778
|
+
const cutoverPrefix = resolveConsolidationCutoverPrefix(migrationsFolder);
|
|
22700
22779
|
if (tableExists(nativeDb, existenceTable2) && !tableExists(nativeDb, "__drizzle_migrations")) {
|
|
22701
22780
|
const migrations = readMigrationFiles({ migrationsFolder });
|
|
22702
22781
|
const baseline = migrations[0];
|
|
@@ -22740,7 +22819,7 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable2, logSubsys
|
|
|
22740
22819
|
);
|
|
22741
22820
|
for (const m of localMigrations) {
|
|
22742
22821
|
if (journaledHashesAfter.has(m.hash)) continue;
|
|
22743
|
-
probeAndMarkApplied(nativeDb, m, logSubsystem);
|
|
22822
|
+
probeAndMarkApplied(nativeDb, m, logSubsystem, eliminatedTables, cutoverPrefix);
|
|
22744
22823
|
}
|
|
22745
22824
|
}
|
|
22746
22825
|
}
|
|
@@ -22763,7 +22842,7 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable2, logSubsys
|
|
|
22763
22842
|
});
|
|
22764
22843
|
}
|
|
22765
22844
|
if (alterMatches.length === 0) {
|
|
22766
|
-
const stripped = fullSql
|
|
22845
|
+
const stripped = stripSqlComments(fullSql).trim();
|
|
22767
22846
|
if (stripped === "") {
|
|
22768
22847
|
const log10 = getLogger(logSubsystem);
|
|
22769
22848
|
log10.debug(
|
|
@@ -22782,9 +22861,11 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable2, logSubsys
|
|
|
22782
22861
|
const createTableRe = /CREATE\s+TABLE/i;
|
|
22783
22862
|
const createTriggerRe = /CREATE\s+TRIGGER/i;
|
|
22784
22863
|
if (renameRe.test(fullSql) && createTableRe.test(fullSql)) {
|
|
22785
|
-
probeAndMarkApplied(nativeDb, migration, logSubsystem);
|
|
22864
|
+
probeAndMarkApplied(nativeDb, migration, logSubsystem, eliminatedTables, cutoverPrefix);
|
|
22786
22865
|
} else if (createTableRe.test(fullSql) || createTriggerRe.test(fullSql)) {
|
|
22787
|
-
probeAndMarkApplied(nativeDb, migration, logSubsystem);
|
|
22866
|
+
probeAndMarkApplied(nativeDb, migration, logSubsystem, eliminatedTables, cutoverPrefix);
|
|
22867
|
+
} else {
|
|
22868
|
+
probeAndMarkApplied(nativeDb, migration, logSubsystem, eliminatedTables, cutoverPrefix);
|
|
22788
22869
|
}
|
|
22789
22870
|
continue;
|
|
22790
22871
|
}
|
|
@@ -22875,6 +22956,7 @@ function reconcileBrainMigrationsForConsolidatedDb(nativeDb, migrationsFolder) {
|
|
|
22875
22956
|
const existingHashes = new Set(
|
|
22876
22957
|
nativeDb.prepare('SELECT hash FROM "__drizzle_migrations"').all().map((r) => r.hash)
|
|
22877
22958
|
);
|
|
22959
|
+
const eliminatedTables = computeEliminatedTables(localMigrations);
|
|
22878
22960
|
const createTableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?[`"]?(\w+)[`"]?/gi;
|
|
22879
22961
|
const renameRegex = /ALTER\s+TABLE\s+[`"]?(\w+)[`"]?\s+RENAME\s+TO\s+[`"]?(\w+)[`"]?/gi;
|
|
22880
22962
|
const addColumnRegex = /ALTER\s+TABLE\s+[`"]?(\w+)[`"]?\s+ADD\s+COLUMN\s+[`"]?(\w+)[`"]?/gi;
|
|
@@ -22883,7 +22965,6 @@ function reconcileBrainMigrationsForConsolidatedDb(nativeDb, migrationsFolder) {
|
|
|
22883
22965
|
const cols = nativeDb.prepare(`PRAGMA table_info("${table}")`).all();
|
|
22884
22966
|
return cols.some((c) => c.name === column);
|
|
22885
22967
|
};
|
|
22886
|
-
const stripSqlComments = (sql39) => sql39.replace(/--[^\n]*/g, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
22887
22968
|
let marked = 0;
|
|
22888
22969
|
let applied = 0;
|
|
22889
22970
|
for (const m of localMigrations) {
|
|
@@ -22904,7 +22985,7 @@ function reconcileBrainMigrationsForConsolidatedDb(nativeDb, migrationsFolder) {
|
|
|
22904
22985
|
for (const match of fullSql.matchAll(addColumnRegex)) {
|
|
22905
22986
|
addColumns.push({ table: match[1], column: match[2] });
|
|
22906
22987
|
}
|
|
22907
|
-
const tablesSatisfied = resultTables.size > 0 && [...resultTables].every((t) => tableExists(nativeDb, t));
|
|
22988
|
+
const tablesSatisfied = resultTables.size > 0 && [...resultTables].every((t) => tableExists(nativeDb, t) || eliminatedTables.has(t));
|
|
22908
22989
|
const altersSatisfied = resultTables.size === 0 && addColumns.length > 0 && addColumns.every(({ table, column }) => columnExists(table, column));
|
|
22909
22990
|
if (tablesSatisfied || altersSatisfied) {
|
|
22910
22991
|
for (const statement of m.sql) {
|
|
@@ -22927,13 +23008,22 @@ function reconcileBrainMigrationsForConsolidatedDb(nativeDb, migrationsFolder) {
|
|
|
22927
23008
|
}
|
|
22928
23009
|
return { marked, applied };
|
|
22929
23010
|
}
|
|
23011
|
+
function collectErrorMessages(err) {
|
|
23012
|
+
const messages = [];
|
|
23013
|
+
let current = err;
|
|
23014
|
+
for (let depth = 0; current instanceof Error && depth < 16; depth++) {
|
|
23015
|
+
messages.push(current.message);
|
|
23016
|
+
current = current.cause;
|
|
23017
|
+
}
|
|
23018
|
+
return messages.join("\n");
|
|
23019
|
+
}
|
|
22930
23020
|
function isDuplicateColumnError(err) {
|
|
22931
23021
|
if (!(err instanceof Error)) return false;
|
|
22932
|
-
return /duplicate column name/i.test(err
|
|
23022
|
+
return /duplicate column name/i.test(collectErrorMessages(err));
|
|
22933
23023
|
}
|
|
22934
23024
|
function isTableAlreadyExistsError(err) {
|
|
22935
23025
|
if (!(err instanceof Error)) return false;
|
|
22936
|
-
return /table .+ already exists/i.test(err
|
|
23026
|
+
return /table .+ already exists/i.test(collectErrorMessages(err));
|
|
22937
23027
|
}
|
|
22938
23028
|
function isExecutableStatement(stmt) {
|
|
22939
23029
|
if (stmt.trim() === "") return false;
|
|
@@ -23004,7 +23094,7 @@ function ensureColumns(nativeDb, tableName, requiredColumns, logSubsystem, conte
|
|
|
23004
23094
|
}
|
|
23005
23095
|
}
|
|
23006
23096
|
}
|
|
23007
|
-
var MAX_MIGRATION_RETRIES, MIGRATION_RETRY_BASE_DELAY_MS, MIGRATION_RETRY_MAX_DELAY_MS;
|
|
23097
|
+
var MAX_MIGRATION_RETRIES, MIGRATION_RETRY_BASE_DELAY_MS, MIGRATION_RETRY_MAX_DELAY_MS, CONSOLIDATION_CUTOVER_PREFIX, MIGRATION_TIMESTAMP_PREFIX_LEN;
|
|
23008
23098
|
var init_migration_manager = __esm({
|
|
23009
23099
|
"packages/core/src/store/migration-manager.ts"() {
|
|
23010
23100
|
"use strict";
|
|
@@ -23014,27 +23104,29 @@ var init_migration_manager = __esm({
|
|
|
23014
23104
|
MAX_MIGRATION_RETRIES = 5;
|
|
23015
23105
|
MIGRATION_RETRY_BASE_DELAY_MS = 100;
|
|
23016
23106
|
MIGRATION_RETRY_MAX_DELAY_MS = 2e3;
|
|
23107
|
+
CONSOLIDATION_CUTOVER_PREFIX = "20260531000001";
|
|
23108
|
+
MIGRATION_TIMESTAMP_PREFIX_LEN = 14;
|
|
23017
23109
|
}
|
|
23018
23110
|
});
|
|
23019
23111
|
|
|
23020
23112
|
// packages/core/src/store/resolve-migrations-folder.ts
|
|
23021
23113
|
import { createRequire } from "node:module";
|
|
23022
|
-
import { dirname, join as
|
|
23114
|
+
import { dirname as dirname2, join as join4 } from "node:path";
|
|
23023
23115
|
import { fileURLToPath } from "node:url";
|
|
23024
23116
|
function coreRootFromEntry(entryPath) {
|
|
23025
|
-
return
|
|
23117
|
+
return dirname2(dirname2(entryPath));
|
|
23026
23118
|
}
|
|
23027
23119
|
function resolveCorePackageMigrationsFolder(setName) {
|
|
23028
23120
|
try {
|
|
23029
23121
|
const resolved = import.meta.resolve("@cleocode/core", import.meta.url);
|
|
23030
23122
|
const entryPath = fileURLToPath(resolved);
|
|
23031
|
-
return
|
|
23123
|
+
return join4(coreRootFromEntry(entryPath), "migrations", setName);
|
|
23032
23124
|
} catch {
|
|
23033
23125
|
}
|
|
23034
23126
|
const _require6 = createRequire(import.meta.url);
|
|
23035
23127
|
try {
|
|
23036
23128
|
const entryPath = _require6.resolve("@cleocode/core");
|
|
23037
|
-
return
|
|
23129
|
+
return join4(coreRootFromEntry(entryPath), "migrations", setName);
|
|
23038
23130
|
} catch (err) {
|
|
23039
23131
|
throw new Error(
|
|
23040
23132
|
`resolveCorePackageMigrationsFolder("${setName}"): cannot locate @cleocode/core from "${import.meta.url}". Ensure @cleocode/core is installed (workspace or npm). Original error: ${err.message}`
|
|
@@ -27439,12 +27531,42 @@ var init_attachments = __esm({
|
|
|
27439
27531
|
*
|
|
27440
27532
|
* @task T11181 (Epic T10518 / Saga T10516)
|
|
27441
27533
|
*/
|
|
27442
|
-
docVersion: integer("doc_version").notNull().default(1)
|
|
27534
|
+
docVersion: integer("doc_version").notNull().default(1),
|
|
27535
|
+
/**
|
|
27536
|
+
* Optional explicit display-alias NUMBER for the doc, DECOUPLED from the
|
|
27537
|
+
* slug string.
|
|
27538
|
+
*
|
|
27539
|
+
* Background (T11875 · ADR reconcile T11676): under the ratified
|
|
27540
|
+
* slug-primary model the kebab `slug` is the canonical handle and the
|
|
27541
|
+
* displayed number (e.g. ADR "051") is a DISPLAY ALIAS only. Previously
|
|
27542
|
+
* that number was DERIVED by parsing the digits out of the slug
|
|
27543
|
+
* (`adr-051-*` → 051), so three distinct ADRs that all slug as `adr-051-*`
|
|
27544
|
+
* collided on the rendered number with no way to disambiguate.
|
|
27545
|
+
*
|
|
27546
|
+
* When non-null, this column is the authoritative display number and is
|
|
27547
|
+
* PREFERRED over the slug-derived number by
|
|
27548
|
+
* {@link import('../../docs/numbering.js').resolveDisplayNumber}. When null,
|
|
27549
|
+
* rendering falls back to the slug-derived number unchanged — so docs that
|
|
27550
|
+
* never had an alias assigned keep their historical behaviour.
|
|
27551
|
+
*
|
|
27552
|
+
* Uniqueness among `type='adr'` docs is enforced at the dispatch layer (not
|
|
27553
|
+
* via a SQL UNIQUE constraint) by
|
|
27554
|
+
* {@link import('../../docs/display-alias.js').setDisplayAlias}, mirroring
|
|
27555
|
+
* the dispatch-validated discipline used for `lifecycle_status` /
|
|
27556
|
+
* `relation` so future taxonomy changes never require a schema migration.
|
|
27557
|
+
*
|
|
27558
|
+
* @task T11875 (Epic T11781 / Saga T11778)
|
|
27559
|
+
*/
|
|
27560
|
+
displayAlias: integer("display_alias")
|
|
27443
27561
|
},
|
|
27444
27562
|
(table) => [
|
|
27445
27563
|
index("idx_attachments_sha256").on(table.sha256),
|
|
27446
27564
|
index("idx_attachments_lifecycle_status").on(table.lifecycleStatus),
|
|
27447
|
-
index("idx_attachments_supersedes").on(table.supersedes)
|
|
27565
|
+
index("idx_attachments_supersedes").on(table.supersedes),
|
|
27566
|
+
// Speeds the per-type uniqueness scan in `setDisplayAlias` (T11875). Not a
|
|
27567
|
+
// UNIQUE index — uniqueness is scoped to `type='adr'` and enforced at the
|
|
27568
|
+
// dispatch layer so non-adr kinds may reuse numbers freely.
|
|
27569
|
+
index("idx_attachments_display_alias").on(table.displayAlias)
|
|
27448
27570
|
]
|
|
27449
27571
|
);
|
|
27450
27572
|
attachmentRefs = sqliteTable(
|
|
@@ -31195,11 +31317,11 @@ var init_lock = __esm({
|
|
|
31195
31317
|
|
|
31196
31318
|
// packages/core/src/store/atomic.ts
|
|
31197
31319
|
import { mkdir, readFile as readFile2, rename, unlink } from "node:fs/promises";
|
|
31198
|
-
import { dirname as
|
|
31320
|
+
import { dirname as dirname3 } from "node:path";
|
|
31199
31321
|
import writeFileAtomic from "write-file-atomic";
|
|
31200
31322
|
async function atomicWrite(filePath, data, options) {
|
|
31201
31323
|
try {
|
|
31202
|
-
await mkdir(
|
|
31324
|
+
await mkdir(dirname3(filePath), { recursive: true });
|
|
31203
31325
|
await writeFileAtomic(filePath, data, {
|
|
31204
31326
|
encoding: options?.encoding ?? "utf8",
|
|
31205
31327
|
mode: options?.mode
|
|
@@ -31232,7 +31354,7 @@ var init_atomic = __esm({
|
|
|
31232
31354
|
|
|
31233
31355
|
// packages/core/src/store/backup.ts
|
|
31234
31356
|
import { copyFile, rename as fsRename, mkdir as mkdir2, readdir, stat, unlink as unlink2 } from "node:fs/promises";
|
|
31235
|
-
import { basename, join as
|
|
31357
|
+
import { basename, join as join5 } from "node:path";
|
|
31236
31358
|
async function createBackup(filePath, backupDir, maxBackups = DEFAULT_MAX_BACKUPS) {
|
|
31237
31359
|
try {
|
|
31238
31360
|
await mkdir2(backupDir, { recursive: true });
|
|
@@ -31243,14 +31365,14 @@ async function createBackup(filePath, backupDir, maxBackups = DEFAULT_MAX_BACKUP
|
|
|
31243
31365
|
throw new CleoError(3 /* FILE_ERROR */, `Cannot backup: source file not found: ${filePath}`);
|
|
31244
31366
|
}
|
|
31245
31367
|
for (let i = maxBackups; i >= 1; i--) {
|
|
31246
|
-
const current =
|
|
31368
|
+
const current = join5(backupDir, `${fileName}.${i}`);
|
|
31247
31369
|
if (i === maxBackups) {
|
|
31248
31370
|
try {
|
|
31249
31371
|
await unlink2(current);
|
|
31250
31372
|
} catch {
|
|
31251
31373
|
}
|
|
31252
31374
|
} else {
|
|
31253
|
-
const next =
|
|
31375
|
+
const next = join5(backupDir, `${fileName}.${i + 1}`);
|
|
31254
31376
|
try {
|
|
31255
31377
|
await stat(current);
|
|
31256
31378
|
await fsRename(current, next);
|
|
@@ -31258,7 +31380,7 @@ async function createBackup(filePath, backupDir, maxBackups = DEFAULT_MAX_BACKUP
|
|
|
31258
31380
|
}
|
|
31259
31381
|
}
|
|
31260
31382
|
}
|
|
31261
|
-
const backupPath =
|
|
31383
|
+
const backupPath = join5(backupDir, `${fileName}.1`);
|
|
31262
31384
|
await copyFile(filePath, backupPath);
|
|
31263
31385
|
return backupPath;
|
|
31264
31386
|
} catch (err) {
|
|
@@ -31538,15 +31660,15 @@ var init_json2 = __esm({
|
|
|
31538
31660
|
|
|
31539
31661
|
// packages/core/src/scaffold/ensure-config.ts
|
|
31540
31662
|
import { existsSync as existsSync3, readFileSync } from "node:fs";
|
|
31541
|
-
import { basename as basename2, dirname as
|
|
31663
|
+
import { basename as basename2, dirname as dirname4, join as join6, resolve as resolve2 } from "node:path";
|
|
31542
31664
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
31543
31665
|
function getPackageRoot() {
|
|
31544
31666
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
31545
|
-
return resolve2(
|
|
31667
|
+
return resolve2(dirname4(thisFile), "..", "..");
|
|
31546
31668
|
}
|
|
31547
31669
|
function getCleoVersion() {
|
|
31548
31670
|
try {
|
|
31549
|
-
const pkgPath =
|
|
31671
|
+
const pkgPath = join6(getPackageRoot(), "package.json");
|
|
31550
31672
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
31551
31673
|
return pkg.version ?? "0.0.0";
|
|
31552
31674
|
} catch {
|
|
@@ -31571,15 +31693,15 @@ import {
|
|
|
31571
31693
|
unlinkSync,
|
|
31572
31694
|
writeFileSync
|
|
31573
31695
|
} from "node:fs";
|
|
31574
|
-
import { basename as basename3, join as
|
|
31696
|
+
import { basename as basename3, join as join7 } from "node:path";
|
|
31575
31697
|
function scopeBaseDir(scope, cwd) {
|
|
31576
31698
|
return scope === "project" ? resolveCleoDir(cwd) : getCleoHome();
|
|
31577
31699
|
}
|
|
31578
31700
|
function exodusArchiveDir(scope, cwd) {
|
|
31579
|
-
return
|
|
31701
|
+
return join7(scopeBaseDir(scope, cwd), ARCHIVE_DIR_NAME);
|
|
31580
31702
|
}
|
|
31581
31703
|
function exodusMarkerPath(scope, cwd) {
|
|
31582
|
-
return
|
|
31704
|
+
return join7(scopeBaseDir(scope, cwd), MARKER_FILENAME_BY_SCOPE[scope]);
|
|
31583
31705
|
}
|
|
31584
31706
|
function hasExodusCompleteMarker(scope, cwd) {
|
|
31585
31707
|
try {
|
|
@@ -31607,10 +31729,10 @@ function writeExodusCompleteMarker(scope, archivedSources, cwd) {
|
|
|
31607
31729
|
}
|
|
31608
31730
|
function moveFileInto(srcPath, destDir) {
|
|
31609
31731
|
mkdirSync(destDir, { recursive: true });
|
|
31610
|
-
let dest =
|
|
31732
|
+
let dest = join7(destDir, basename3(srcPath));
|
|
31611
31733
|
if (existsSync4(dest)) {
|
|
31612
31734
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "").replace(/Z$/, "Z");
|
|
31613
|
-
dest =
|
|
31735
|
+
dest = join7(destDir, `${basename3(srcPath)}.${stamp}`);
|
|
31614
31736
|
}
|
|
31615
31737
|
try {
|
|
31616
31738
|
renameSync(srcPath, dest);
|
|
@@ -31709,11 +31831,11 @@ var init_archive2 = __esm({
|
|
|
31709
31831
|
|
|
31710
31832
|
// packages/core/src/project-info.ts
|
|
31711
31833
|
import { existsSync as existsSync5, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
31712
|
-
import { join as
|
|
31834
|
+
import { join as join8 } from "node:path";
|
|
31713
31835
|
function getProjectInfoSync(cwd) {
|
|
31714
31836
|
const projectRoot = resolveOrCwd(cwd);
|
|
31715
31837
|
const cleoDir = getCleoDirAbsolute(projectRoot);
|
|
31716
|
-
const infoPath =
|
|
31838
|
+
const infoPath = join8(cleoDir, "project-info.json");
|
|
31717
31839
|
if (!existsSync5(infoPath)) return null;
|
|
31718
31840
|
try {
|
|
31719
31841
|
const raw = readFileSync2(infoPath, "utf-8");
|
|
@@ -31742,7 +31864,7 @@ var init_project_info = __esm({
|
|
|
31742
31864
|
|
|
31743
31865
|
// packages/core/src/store/worktree-isolation-guard.ts
|
|
31744
31866
|
import { existsSync as existsSync6, statSync } from "node:fs";
|
|
31745
|
-
import { dirname as
|
|
31867
|
+
import { dirname as dirname5, join as join9 } from "node:path";
|
|
31746
31868
|
function assertDbPathIsNotWorktreeResident(role, cwd) {
|
|
31747
31869
|
let cleoDir;
|
|
31748
31870
|
try {
|
|
@@ -31750,8 +31872,8 @@ function assertDbPathIsNotWorktreeResident(role, cwd) {
|
|
|
31750
31872
|
} catch {
|
|
31751
31873
|
return;
|
|
31752
31874
|
}
|
|
31753
|
-
const projectRoot =
|
|
31754
|
-
const projectGit =
|
|
31875
|
+
const projectRoot = dirname5(cleoDir);
|
|
31876
|
+
const projectGit = join9(projectRoot, ".git");
|
|
31755
31877
|
let isWorktreeGitlink = false;
|
|
31756
31878
|
try {
|
|
31757
31879
|
isWorktreeGitlink = existsSync6(projectGit) && statSync(projectGit).isFile();
|
|
@@ -32306,7 +32428,7 @@ var init_count_parity = __esm({
|
|
|
32306
32428
|
|
|
32307
32429
|
// packages/core/src/store/exodus/plan.ts
|
|
32308
32430
|
import { existsSync as existsSync8, readdirSync as readdirSync2, statfsSync, statSync as statSync2 } from "node:fs";
|
|
32309
|
-
import { join as
|
|
32431
|
+
import { join as join10 } from "node:path";
|
|
32310
32432
|
function computeRequiredBytes(totalSourceBytes, largestSourceBytes) {
|
|
32311
32433
|
return Math.ceil(STAGING_HEADROOM_FACTOR * largestSourceBytes) + totalSourceBytes;
|
|
32312
32434
|
}
|
|
@@ -32317,33 +32439,33 @@ function buildSourceDescriptors(cwd) {
|
|
|
32317
32439
|
// Project-tier — go into consolidated project-scope cleo.db
|
|
32318
32440
|
{
|
|
32319
32441
|
name: "tasks",
|
|
32320
|
-
path:
|
|
32442
|
+
path: join10(cleoDir, "tasks.db"),
|
|
32321
32443
|
targetScope: "project"
|
|
32322
32444
|
},
|
|
32323
32445
|
{
|
|
32324
32446
|
name: "brain (project)",
|
|
32325
|
-
path:
|
|
32447
|
+
path: join10(cleoDir, "brain.db"),
|
|
32326
32448
|
targetScope: "project"
|
|
32327
32449
|
},
|
|
32328
32450
|
{
|
|
32329
32451
|
name: "conduit",
|
|
32330
|
-
path:
|
|
32452
|
+
path: join10(cleoDir, "conduit.db"),
|
|
32331
32453
|
targetScope: "project"
|
|
32332
32454
|
},
|
|
32333
32455
|
// Global-tier — go into consolidated global-scope cleo.db
|
|
32334
32456
|
{
|
|
32335
32457
|
name: "nexus",
|
|
32336
|
-
path:
|
|
32458
|
+
path: join10(cleoHome, "nexus.db"),
|
|
32337
32459
|
targetScope: "global"
|
|
32338
32460
|
},
|
|
32339
32461
|
{
|
|
32340
32462
|
name: "signaldock",
|
|
32341
|
-
path:
|
|
32463
|
+
path: join10(cleoHome, "signaldock.db"),
|
|
32342
32464
|
targetScope: "global"
|
|
32343
32465
|
},
|
|
32344
32466
|
{
|
|
32345
32467
|
name: "skills",
|
|
32346
|
-
path:
|
|
32468
|
+
path: join10(cleoHome, "skills.db"),
|
|
32347
32469
|
targetScope: "global"
|
|
32348
32470
|
}
|
|
32349
32471
|
];
|
|
@@ -32372,7 +32494,7 @@ function findExistingStaging(cleoDir) {
|
|
|
32372
32494
|
const entries = readdirSync2(cleoDir, { withFileTypes: true });
|
|
32373
32495
|
const stagingDirs = entries.filter((e) => e.isDirectory() && e.name.startsWith("exodus-staging-")).map((e) => e.name).sort().reverse();
|
|
32374
32496
|
if (stagingDirs.length > 0) {
|
|
32375
|
-
return
|
|
32497
|
+
return join10(cleoDir, stagingDirs[0]);
|
|
32376
32498
|
}
|
|
32377
32499
|
} catch {
|
|
32378
32500
|
}
|
|
@@ -32388,7 +32510,7 @@ function buildExodusPlan(cwd) {
|
|
|
32388
32510
|
const availableBytes = getAvailableBytes(cleoDir);
|
|
32389
32511
|
const diskPreflight = totalSourceBytes === 0 || availableBytes >= requiredBytes;
|
|
32390
32512
|
const existingStaging = findExistingStaging(cleoDir);
|
|
32391
|
-
const stagingDir = existingStaging ??
|
|
32513
|
+
const stagingDir = existingStaging ?? join10(cleoDir, deriveStagingDirName());
|
|
32392
32514
|
const resumeFromStaging = existingStaging !== null;
|
|
32393
32515
|
const projectDbPath = resolveDualScopeDbPath("project", cwd);
|
|
32394
32516
|
const globalDbPath = resolveDualScopeDbPath("global");
|
|
@@ -32707,7 +32829,7 @@ import {
|
|
|
32707
32829
|
unlinkSync as unlinkSync2,
|
|
32708
32830
|
writeFileSync as writeFileSync3
|
|
32709
32831
|
} from "node:fs";
|
|
32710
|
-
import { join as
|
|
32832
|
+
import { join as join11 } from "node:path";
|
|
32711
32833
|
function getSqliteVersion(db) {
|
|
32712
32834
|
try {
|
|
32713
32835
|
const row = db.prepare("SELECT sqlite_version() AS v").get();
|
|
@@ -32723,13 +32845,13 @@ function listTables2(db) {
|
|
|
32723
32845
|
return rows.map((r) => r.name);
|
|
32724
32846
|
}
|
|
32725
32847
|
function writeJournal(stagingDir, journal) {
|
|
32726
|
-
const journalPath =
|
|
32848
|
+
const journalPath = join11(stagingDir, JOURNAL_FILENAME);
|
|
32727
32849
|
const tmpPath = `${journalPath}.tmp`;
|
|
32728
32850
|
writeFileSync3(tmpPath, JSON.stringify(journal, null, 2) + "\n", "utf8");
|
|
32729
32851
|
renameSync2(tmpPath, journalPath);
|
|
32730
32852
|
}
|
|
32731
32853
|
function readJournal(stagingDir) {
|
|
32732
|
-
const journalPath =
|
|
32854
|
+
const journalPath = join11(stagingDir, JOURNAL_FILENAME);
|
|
32733
32855
|
if (!existsSync10(journalPath)) return null;
|
|
32734
32856
|
try {
|
|
32735
32857
|
return JSON.parse(readFileSync3(journalPath, "utf8"));
|
|
@@ -32738,7 +32860,7 @@ function readJournal(stagingDir) {
|
|
|
32738
32860
|
}
|
|
32739
32861
|
}
|
|
32740
32862
|
function clearExodusJournal(stagingDir) {
|
|
32741
|
-
const journalPath =
|
|
32863
|
+
const journalPath = join11(stagingDir, JOURNAL_FILENAME);
|
|
32742
32864
|
try {
|
|
32743
32865
|
if (!existsSync10(journalPath)) return false;
|
|
32744
32866
|
unlinkSync2(journalPath);
|
|
@@ -33047,7 +33169,7 @@ async function runExodusMigrate(plan, forceCrossVersion = false, onProgress) {
|
|
|
33047
33169
|
var extractNativeDb = extractNativeDb2;
|
|
33048
33170
|
for (const src of sources) {
|
|
33049
33171
|
if (!existsSync10(src.path)) continue;
|
|
33050
|
-
const backupDest =
|
|
33172
|
+
const backupDest = join11(stagingDir, `${src.name.replace(/[^a-z0-9-]/g, "_")}-backup.db`);
|
|
33051
33173
|
const srcBytes = safeStatBytes(src.path);
|
|
33052
33174
|
const skipStagingCopy = srcBytes > plan.stagingCopyThresholdBytes;
|
|
33053
33175
|
if (skipStagingCopy) {
|
|
@@ -33349,9 +33471,9 @@ var init_seal = __esm({
|
|
|
33349
33471
|
|
|
33350
33472
|
// packages/core/src/store/exodus/status.ts
|
|
33351
33473
|
import { existsSync as existsSync11, readdirSync as readdirSync3, readFileSync as readFileSync4, statSync as statSync5 } from "node:fs";
|
|
33352
|
-
import { join as
|
|
33474
|
+
import { join as join12 } from "node:path";
|
|
33353
33475
|
function readJournal2(stagingDir) {
|
|
33354
|
-
const p =
|
|
33476
|
+
const p = join12(stagingDir, JOURNAL_FILENAME2);
|
|
33355
33477
|
if (!existsSync11(p)) return null;
|
|
33356
33478
|
try {
|
|
33357
33479
|
return JSON.parse(readFileSync4(p, "utf8"));
|
|
@@ -33361,7 +33483,7 @@ function readJournal2(stagingDir) {
|
|
|
33361
33483
|
}
|
|
33362
33484
|
function findStagingDirs(cleoDir) {
|
|
33363
33485
|
try {
|
|
33364
|
-
return readdirSync3(cleoDir, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name.startsWith("exodus-staging-")).map((e) =>
|
|
33486
|
+
return readdirSync3(cleoDir, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name.startsWith("exodus-staging-")).map((e) => join12(cleoDir, e.name)).sort().reverse();
|
|
33365
33487
|
} catch {
|
|
33366
33488
|
return [];
|
|
33367
33489
|
}
|
|
@@ -34213,7 +34335,7 @@ __export(dual_scope_db_exports, {
|
|
|
34213
34335
|
});
|
|
34214
34336
|
import { existsSync as existsSync14, mkdirSync as mkdirSync3 } from "node:fs";
|
|
34215
34337
|
import { createRequire as createRequire4 } from "node:module";
|
|
34216
|
-
import { dirname as
|
|
34338
|
+
import { dirname as dirname6, join as join13 } from "node:path";
|
|
34217
34339
|
function assertWriteDurable(handle) {
|
|
34218
34340
|
if (handle.exodusAbort) {
|
|
34219
34341
|
throw new ExodusAbortWriteUnsafeError(handle.exodusAbort);
|
|
@@ -34230,9 +34352,9 @@ function cacheKey(scope, dbPath) {
|
|
|
34230
34352
|
}
|
|
34231
34353
|
function resolveDualScopeDbPath(scope, cwd) {
|
|
34232
34354
|
if (scope === "project") {
|
|
34233
|
-
return
|
|
34355
|
+
return join13(resolveCleoDir(cwd), "cleo.db");
|
|
34234
34356
|
}
|
|
34235
|
-
return
|
|
34357
|
+
return join13(getCleoHome(), "cleo.db");
|
|
34236
34358
|
}
|
|
34237
34359
|
function migrationsSetName(scope) {
|
|
34238
34360
|
return scope === "project" ? "drizzle-cleo-project" : "drizzle-cleo-global";
|
|
@@ -34272,7 +34394,7 @@ async function openDualScopeDb(scope, cwd) {
|
|
|
34272
34394
|
}
|
|
34273
34395
|
async function openDedicatedDualScopeDb(scope, dbPath, log10) {
|
|
34274
34396
|
log10.debug({ scope, dbPath }, "opening DEDICATED (non-cached) dual-scope cleo.db (T11782 FIX D)");
|
|
34275
|
-
const dir =
|
|
34397
|
+
const dir = dirname6(dbPath);
|
|
34276
34398
|
if (!existsSync14(dir)) {
|
|
34277
34399
|
mkdirSync3(dir, { recursive: true });
|
|
34278
34400
|
}
|
|
@@ -34322,7 +34444,7 @@ async function openDualScopeDbAtPath(scope, dbPath, exodusCwd, options) {
|
|
|
34322
34444
|
}
|
|
34323
34445
|
const initPromise = (async () => {
|
|
34324
34446
|
log10.debug({ scope, dbPath }, "opening dual-scope cleo.db");
|
|
34325
|
-
const dir =
|
|
34447
|
+
const dir = dirname6(dbPath);
|
|
34326
34448
|
if (!existsSync14(dir)) {
|
|
34327
34449
|
mkdirSync3(dir, { recursive: true });
|
|
34328
34450
|
}
|
|
@@ -34401,6 +34523,12 @@ async function openDualScopeDbAtPath(scope, dbPath, exodusCwd, options) {
|
|
|
34401
34523
|
nativeDb: null,
|
|
34402
34524
|
initPromise
|
|
34403
34525
|
});
|
|
34526
|
+
initPromise.catch(() => {
|
|
34527
|
+
const entry = _cache.get(key);
|
|
34528
|
+
if (entry && entry.initPromise === initPromise) {
|
|
34529
|
+
_cache.delete(key);
|
|
34530
|
+
}
|
|
34531
|
+
});
|
|
34404
34532
|
return initPromise;
|
|
34405
34533
|
}
|
|
34406
34534
|
function _resetDualScopeDbCache(scope) {
|
|
@@ -34992,7 +35120,7 @@ __export(nexus_sqlite_exports, {
|
|
|
34992
35120
|
resolveNexusMigrationsFolder: () => resolveNexusMigrationsFolder
|
|
34993
35121
|
});
|
|
34994
35122
|
import { copyFileSync as copyFileSync4, existsSync as existsSync15 } from "node:fs";
|
|
34995
|
-
import { join as
|
|
35123
|
+
import { join as join14 } from "node:path";
|
|
34996
35124
|
function getNexusDbPath(cwd) {
|
|
34997
35125
|
return resolveDualScopeDbPath("project", cwd);
|
|
34998
35126
|
}
|
|
@@ -35024,7 +35152,7 @@ function resolveNexusMigrationsFolder() {
|
|
|
35024
35152
|
return resolveCorePackageMigrationsFolder("drizzle-nexus");
|
|
35025
35153
|
}
|
|
35026
35154
|
function getNestedNexusSentinelPath() {
|
|
35027
|
-
return
|
|
35155
|
+
return join14(getCleoHome(), "nexus", NESTED_NEXUS_SENTINEL);
|
|
35028
35156
|
}
|
|
35029
35157
|
function detectAndWarnOnNestedNexus() {
|
|
35030
35158
|
let nestedPath;
|
|
@@ -35327,7 +35455,7 @@ import { AsyncLocalStorage } from "node:async_hooks";
|
|
|
35327
35455
|
import { existsSync as existsSync16, readFileSync as readFileSync5, statSync as statSync6 } from "node:fs";
|
|
35328
35456
|
import { createRequire as createRequire5 } from "node:module";
|
|
35329
35457
|
import { homedir } from "node:os";
|
|
35330
|
-
import { basename as basename4, dirname as
|
|
35458
|
+
import { basename as basename4, dirname as dirname7, join as join15, resolve as resolve3 } from "node:path";
|
|
35331
35459
|
import {
|
|
35332
35460
|
computeCanonicalProjectId as _computeCanonicalProjectId,
|
|
35333
35461
|
getCanonicalTemplatesTildePath as _getCanonicalTemplatesTildePath,
|
|
@@ -35417,7 +35545,7 @@ function getCleoDirAbsolute(cwd, opts) {
|
|
|
35417
35545
|
function _resolveProjectByCwdFromNexus(cwd) {
|
|
35418
35546
|
try {
|
|
35419
35547
|
const cleoHome = getCleoHome();
|
|
35420
|
-
const globalDbPath =
|
|
35548
|
+
const globalDbPath = join15(cleoHome, "cleo.db");
|
|
35421
35549
|
if (!existsSync16(globalDbPath)) return null;
|
|
35422
35550
|
const start = resolve3(cwd ?? process.cwd());
|
|
35423
35551
|
let current = start;
|
|
@@ -35432,7 +35560,7 @@ function _resolveProjectByCwdFromNexus(cwd) {
|
|
|
35432
35560
|
if (row && typeof row.project_id === "string" && row.project_id.length > 0) {
|
|
35433
35561
|
return row.project_id;
|
|
35434
35562
|
}
|
|
35435
|
-
const parent =
|
|
35563
|
+
const parent = dirname7(current);
|
|
35436
35564
|
if (parent === current) break;
|
|
35437
35565
|
current = parent;
|
|
35438
35566
|
}
|
|
@@ -35457,13 +35585,13 @@ function _findCleoDirRoot(cwd) {
|
|
|
35457
35585
|
const isDangerousRoot = current === homeRoot || current === "/" || current === "";
|
|
35458
35586
|
if (!isDangerousRoot) {
|
|
35459
35587
|
try {
|
|
35460
|
-
if (statSync6(
|
|
35588
|
+
if (statSync6(join15(current, ".cleo")).isDirectory()) {
|
|
35461
35589
|
return current;
|
|
35462
35590
|
}
|
|
35463
35591
|
} catch {
|
|
35464
35592
|
}
|
|
35465
35593
|
}
|
|
35466
|
-
const parent =
|
|
35594
|
+
const parent = dirname7(current);
|
|
35467
35595
|
if (parent === current) break;
|
|
35468
35596
|
current = parent;
|
|
35469
35597
|
}
|
|
@@ -35472,7 +35600,7 @@ function _findCleoDirRoot(cwd) {
|
|
|
35472
35600
|
function resolveCleoDir(cwd) {
|
|
35473
35601
|
const scope = worktreeScope.getStore();
|
|
35474
35602
|
if (scope !== void 0) {
|
|
35475
|
-
return
|
|
35603
|
+
return join15(scope.worktreeRoot, ".cleo");
|
|
35476
35604
|
}
|
|
35477
35605
|
const override = _cleoDirEnvOverride();
|
|
35478
35606
|
if (override !== null) {
|
|
@@ -35480,16 +35608,16 @@ function resolveCleoDir(cwd) {
|
|
|
35480
35608
|
}
|
|
35481
35609
|
const root = _findCleoDirRoot(cwd);
|
|
35482
35610
|
if (root !== null) {
|
|
35483
|
-
return
|
|
35611
|
+
return join15(root, ".cleo");
|
|
35484
35612
|
}
|
|
35485
35613
|
const start = resolve3(cwd ?? process.cwd());
|
|
35486
35614
|
let current = start;
|
|
35487
35615
|
while (true) {
|
|
35488
35616
|
const mainRepo = _resolveMainRepoFromGitlink(current);
|
|
35489
35617
|
if (mainRepo !== null) {
|
|
35490
|
-
return
|
|
35618
|
+
return join15(mainRepo, ".cleo");
|
|
35491
35619
|
}
|
|
35492
|
-
const parent =
|
|
35620
|
+
const parent = dirname7(current);
|
|
35493
35621
|
if (parent === current) {
|
|
35494
35622
|
break;
|
|
35495
35623
|
}
|
|
@@ -35529,21 +35657,21 @@ function _cwdHasGitAncestor(cwd) {
|
|
|
35529
35657
|
const start = resolve3(cwd ?? process.cwd());
|
|
35530
35658
|
let current = start;
|
|
35531
35659
|
while (true) {
|
|
35532
|
-
const gitMarker =
|
|
35660
|
+
const gitMarker = join15(current, ".git");
|
|
35533
35661
|
try {
|
|
35534
35662
|
if (existsSync16(gitMarker)) {
|
|
35535
35663
|
return true;
|
|
35536
35664
|
}
|
|
35537
35665
|
} catch {
|
|
35538
35666
|
}
|
|
35539
|
-
const parent =
|
|
35667
|
+
const parent = dirname7(current);
|
|
35540
35668
|
if (parent === current) return false;
|
|
35541
35669
|
current = parent;
|
|
35542
35670
|
}
|
|
35543
35671
|
}
|
|
35544
35672
|
function _resolveMainRepoFromGitlink(gitlinkDir) {
|
|
35545
35673
|
try {
|
|
35546
|
-
const gitLinkPath =
|
|
35674
|
+
const gitLinkPath = join15(gitlinkDir, ".git");
|
|
35547
35675
|
if (!existsSync16(gitLinkPath)) return null;
|
|
35548
35676
|
const stat2 = statSync6(gitLinkPath);
|
|
35549
35677
|
if (!stat2.isFile()) return null;
|
|
@@ -35551,8 +35679,8 @@ function _resolveMainRepoFromGitlink(gitlinkDir) {
|
|
|
35551
35679
|
const match = gitLinkContent.match(/^gitdir:\s*(.+)$/m);
|
|
35552
35680
|
if (!match) return null;
|
|
35553
35681
|
const gitdir = match[1].trim();
|
|
35554
|
-
const mainRepo =
|
|
35555
|
-
if (existsSync16(
|
|
35682
|
+
const mainRepo = dirname7(dirname7(dirname7(gitdir)));
|
|
35683
|
+
if (existsSync16(join15(mainRepo, ".cleo")) && validateProjectRoot(mainRepo)) {
|
|
35556
35684
|
return mainRepo;
|
|
35557
35685
|
}
|
|
35558
35686
|
} catch {
|
|
@@ -35560,17 +35688,17 @@ function _resolveMainRepoFromGitlink(gitlinkDir) {
|
|
|
35560
35688
|
return null;
|
|
35561
35689
|
}
|
|
35562
35690
|
function validateProjectRoot(candidate) {
|
|
35563
|
-
const cleoDir =
|
|
35691
|
+
const cleoDir = join15(candidate, ".cleo");
|
|
35564
35692
|
if (!existsSync16(cleoDir)) {
|
|
35565
35693
|
return false;
|
|
35566
35694
|
}
|
|
35567
|
-
const projectInfoPath =
|
|
35695
|
+
const projectInfoPath = join15(cleoDir, "project-info.json");
|
|
35568
35696
|
if (existsSync16(projectInfoPath)) {
|
|
35569
35697
|
try {
|
|
35570
35698
|
const raw = readFileSync5(projectInfoPath, "utf-8");
|
|
35571
35699
|
const parsed = JSON.parse(raw);
|
|
35572
35700
|
if (typeof parsed === "object" && parsed !== null && "projectId" in parsed && typeof parsed["projectId"] === "string" && parsed["projectId"] !== "") {
|
|
35573
|
-
const gitMarker =
|
|
35701
|
+
const gitMarker = join15(candidate, ".git");
|
|
35574
35702
|
if (existsSync16(gitMarker)) {
|
|
35575
35703
|
try {
|
|
35576
35704
|
if (!statSync6(gitMarker).isDirectory()) {
|
|
@@ -35585,7 +35713,7 @@ function validateProjectRoot(candidate) {
|
|
|
35585
35713
|
} catch {
|
|
35586
35714
|
}
|
|
35587
35715
|
}
|
|
35588
|
-
const gitDir =
|
|
35716
|
+
const gitDir = join15(candidate, ".git");
|
|
35589
35717
|
if (existsSync16(gitDir)) {
|
|
35590
35718
|
let isRealGitDir = false;
|
|
35591
35719
|
try {
|
|
@@ -35622,7 +35750,7 @@ function getProjectRoot(cwd) {
|
|
|
35622
35750
|
const cleoDirEnv = process.env["CLEO_DIR"];
|
|
35623
35751
|
if (cleoDirEnv && isAbsolutePath(cleoDirEnv)) {
|
|
35624
35752
|
if (cleoDirEnv.endsWith("/.cleo") || cleoDirEnv.endsWith("\\.cleo")) {
|
|
35625
|
-
return
|
|
35753
|
+
return dirname7(cleoDirEnv);
|
|
35626
35754
|
}
|
|
35627
35755
|
return cleoDirEnv;
|
|
35628
35756
|
}
|
|
@@ -35633,8 +35761,8 @@ function getProjectRoot(cwd) {
|
|
|
35633
35761
|
const homeRoot = homedir();
|
|
35634
35762
|
const skippedCleoDirs = [];
|
|
35635
35763
|
while (true) {
|
|
35636
|
-
const cleoDir =
|
|
35637
|
-
const gitDir =
|
|
35764
|
+
const cleoDir = join15(current, ".cleo");
|
|
35765
|
+
const gitDir = join15(current, ".git");
|
|
35638
35766
|
const isDangerousRoot = current === homeRoot || current === "/" || current === "";
|
|
35639
35767
|
if (existsSync16(cleoDir) && !isDangerousRoot) {
|
|
35640
35768
|
if (validateProjectRoot(current)) {
|
|
@@ -35657,7 +35785,7 @@ function getProjectRoot(cwd) {
|
|
|
35657
35785
|
const mainRepoFromWalk = _resolveMainRepoFromGitlink(current);
|
|
35658
35786
|
if (mainRepoFromWalk !== null) return mainRepoFromWalk;
|
|
35659
35787
|
}
|
|
35660
|
-
const parent =
|
|
35788
|
+
const parent = dirname7(current);
|
|
35661
35789
|
if (parent === current) {
|
|
35662
35790
|
break;
|
|
35663
35791
|
}
|
|
@@ -35687,17 +35815,17 @@ function resolveOrCwd(maybeRoot) {
|
|
|
35687
35815
|
return getProjectRoot();
|
|
35688
35816
|
}
|
|
35689
35817
|
function getConfigPath(cwd) {
|
|
35690
|
-
return
|
|
35818
|
+
return join15(_resolveCleoDir(cwd), "config.json");
|
|
35691
35819
|
}
|
|
35692
35820
|
function getGlobalConfigPath() {
|
|
35693
|
-
return
|
|
35821
|
+
return join15(getCleoHome(), "config.json");
|
|
35694
35822
|
}
|
|
35695
35823
|
function isAbsolutePath(path2) {
|
|
35696
35824
|
return _isAbsolutePath(path2);
|
|
35697
35825
|
}
|
|
35698
35826
|
function _readProjectNameFromInfo(projectRoot) {
|
|
35699
35827
|
try {
|
|
35700
|
-
const infoPath =
|
|
35828
|
+
const infoPath = join15(projectRoot, ".cleo", "project-info.json");
|
|
35701
35829
|
if (!existsSync16(infoPath)) return void 0;
|
|
35702
35830
|
const raw = readFileSync5(infoPath, "utf-8");
|
|
35703
35831
|
const data = JSON.parse(raw);
|
|
@@ -35724,8 +35852,8 @@ async function registerProjectOnEncounter(projectRoot, infoProjectId) {
|
|
|
35724
35852
|
if (existingRows.length > 0) {
|
|
35725
35853
|
const existingPath = existingRows[0].projectPath;
|
|
35726
35854
|
if (existingPath !== resolvedPath) {
|
|
35727
|
-
const newBrainDbPath =
|
|
35728
|
-
const newTasksDbPath =
|
|
35855
|
+
const newBrainDbPath = join15(resolvedPath, ".cleo", "brain.db");
|
|
35856
|
+
const newTasksDbPath = join15(resolvedPath, ".cleo", "tasks.db");
|
|
35729
35857
|
await db.update(projectRegistry2).set({
|
|
35730
35858
|
projectPath: resolvedPath,
|
|
35731
35859
|
projectHash: generateProjectHash2(resolvedPath),
|
|
@@ -35756,8 +35884,8 @@ async function registerProjectOnEncounter(projectRoot, infoProjectId) {
|
|
|
35756
35884
|
lastSync: now,
|
|
35757
35885
|
taskCount: 0,
|
|
35758
35886
|
labelsJson: "[]",
|
|
35759
|
-
brainDbPath:
|
|
35760
|
-
tasksDbPath:
|
|
35887
|
+
brainDbPath: join15(resolvedPath, ".cleo", "brain.db"),
|
|
35888
|
+
tasksDbPath: join15(resolvedPath, ".cleo", "tasks.db"),
|
|
35761
35889
|
statsJson: "{}"
|
|
35762
35890
|
}).onConflictDoNothing();
|
|
35763
35891
|
const aliases = canonicalResult.legacyAliases ?? [];
|
|
@@ -35974,7 +36102,7 @@ __export(config_exports, {
|
|
|
35974
36102
|
});
|
|
35975
36103
|
import { existsSync as existsSync17 } from "node:fs";
|
|
35976
36104
|
import { mkdir as mkdir3, writeFile } from "node:fs/promises";
|
|
35977
|
-
import { dirname as
|
|
36105
|
+
import { dirname as dirname8 } from "node:path";
|
|
35978
36106
|
function getNestedValue(obj, path2) {
|
|
35979
36107
|
const parts = path2.split(".");
|
|
35980
36108
|
let current = obj;
|
|
@@ -36097,7 +36225,7 @@ function parseConfigValue(value) {
|
|
|
36097
36225
|
async function setConfigValue(key, value, cwd, opts) {
|
|
36098
36226
|
const configPath = opts?.global ? getGlobalConfigPath() : getConfigPath(cwd);
|
|
36099
36227
|
if (!existsSync17(configPath)) {
|
|
36100
|
-
const dir =
|
|
36228
|
+
const dir = dirname8(configPath);
|
|
36101
36229
|
await mkdir3(dir, { recursive: true });
|
|
36102
36230
|
await writeFile(configPath, "{}", "utf-8");
|
|
36103
36231
|
}
|
|
@@ -36111,7 +36239,7 @@ async function applyStrictnessPreset(preset, cwd, opts) {
|
|
|
36111
36239
|
const definition = STRICTNESS_PRESETS[preset];
|
|
36112
36240
|
const configPath = opts?.global ? getGlobalConfigPath() : getConfigPath(cwd);
|
|
36113
36241
|
if (!existsSync17(configPath)) {
|
|
36114
|
-
const dir =
|
|
36242
|
+
const dir = dirname8(configPath);
|
|
36115
36243
|
await mkdir3(dir, { recursive: true });
|
|
36116
36244
|
await writeFile(configPath, "{}", "utf-8");
|
|
36117
36245
|
}
|
|
@@ -37286,9 +37414,9 @@ var init_telemetry_schema = __esm({
|
|
|
37286
37414
|
|
|
37287
37415
|
// packages/core/src/telemetry/sqlite.ts
|
|
37288
37416
|
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
37289
|
-
import { dirname as
|
|
37417
|
+
import { dirname as dirname9, join as join16 } from "node:path";
|
|
37290
37418
|
function getTelemetryDbPath() {
|
|
37291
|
-
return
|
|
37419
|
+
return join16(getCleoHome(), DB_FILENAME);
|
|
37292
37420
|
}
|
|
37293
37421
|
function resolveTelemetryMigrationsFolder() {
|
|
37294
37422
|
return resolveCorePackageMigrationsFolder("drizzle-telemetry");
|
|
@@ -37336,7 +37464,7 @@ async function getTelemetryDb() {
|
|
|
37336
37464
|
_initPromise2 = (async () => {
|
|
37337
37465
|
const dbPath = requestedPath;
|
|
37338
37466
|
_dbPath2 = dbPath;
|
|
37339
|
-
mkdirSync4(
|
|
37467
|
+
mkdirSync4(dirname9(dbPath), { recursive: true });
|
|
37340
37468
|
const nativeDb = openNativeDatabase(dbPath);
|
|
37341
37469
|
_nativeDb2 = nativeDb;
|
|
37342
37470
|
const db = drizzle({ client: nativeDb, schema: telemetry_schema_exports });
|
|
@@ -37370,10 +37498,10 @@ var init_sqlite2 = __esm({
|
|
|
37370
37498
|
|
|
37371
37499
|
// packages/core/src/store/agent-registry-store.ts
|
|
37372
37500
|
import { existsSync as existsSync18 } from "node:fs";
|
|
37373
|
-
import { join as
|
|
37501
|
+
import { join as join17 } from "node:path";
|
|
37374
37502
|
function getGlobalAgentRegistryDbPath() {
|
|
37375
37503
|
const cleoHome = getCleoHome();
|
|
37376
|
-
const dbPath =
|
|
37504
|
+
const dbPath = join17(cleoHome, "cleo.db");
|
|
37377
37505
|
if (!dbPath.startsWith(cleoHome)) {
|
|
37378
37506
|
throw new Error(
|
|
37379
37507
|
`BUG: getGlobalAgentRegistryDbPath() resolved to "${dbPath}" which is NOT under getCleoHome() ("${cleoHome}"). The Agent Registry is global-only per ADR-037. This indicates a code path that bypasses path resolution \u2014 fix the caller, do not suppress this error.`
|
|
@@ -37714,11 +37842,11 @@ var init_skills_schema = __esm({
|
|
|
37714
37842
|
});
|
|
37715
37843
|
|
|
37716
37844
|
// packages/core/src/store/skills-db.ts
|
|
37717
|
-
import { join as
|
|
37845
|
+
import { join as join18 } from "node:path";
|
|
37718
37846
|
import { and as and3, eq as eq4 } from "drizzle-orm";
|
|
37719
37847
|
function getDefaultSkillsDbPath() {
|
|
37720
37848
|
const cleoHome = getCleoHome();
|
|
37721
|
-
const dbPath =
|
|
37849
|
+
const dbPath = join18(cleoHome, "cleo.db");
|
|
37722
37850
|
if (!dbPath.startsWith(cleoHome)) {
|
|
37723
37851
|
throw new Error(
|
|
37724
37852
|
`BUG: getDefaultSkillsDbPath() resolved to "${dbPath}" which is NOT under getCleoHome() ("${cleoHome}"). The skills registry is global-only per SG-CLEO-SKILLS-architecture-v3.md \xA74. Fix the caller, do not suppress.`
|
|
@@ -37794,7 +37922,7 @@ import {
|
|
|
37794
37922
|
statSync as statSync7,
|
|
37795
37923
|
unlinkSync as unlinkSync3
|
|
37796
37924
|
} from "node:fs";
|
|
37797
|
-
import { join as
|
|
37925
|
+
import { join as join19 } from "node:path";
|
|
37798
37926
|
function resolveInventoryPath(entry, cwd) {
|
|
37799
37927
|
try {
|
|
37800
37928
|
if (entry.tier === "global") {
|
|
@@ -37829,7 +37957,7 @@ async function openAgentRegistryDbForSnapshot() {
|
|
|
37829
37957
|
}
|
|
37830
37958
|
async function openTelemetryDbForSnapshot() {
|
|
37831
37959
|
try {
|
|
37832
|
-
const path2 =
|
|
37960
|
+
const path2 = join19(getCleoHome(), "telemetry.db");
|
|
37833
37961
|
if (!existsSync20(path2)) return null;
|
|
37834
37962
|
} catch {
|
|
37835
37963
|
return null;
|
|
@@ -37935,8 +38063,8 @@ function rotateSnapshots(backupDir, prefix) {
|
|
|
37935
38063
|
const pattern = snapshotPattern(prefix);
|
|
37936
38064
|
const files = readdirSync4(backupDir).filter((f) => pattern.test(f)).map((f) => ({
|
|
37937
38065
|
name: f,
|
|
37938
|
-
path:
|
|
37939
|
-
mtimeMs: statSync7(
|
|
38066
|
+
path: join19(backupDir, f),
|
|
38067
|
+
mtimeMs: statSync7(join19(backupDir, f)).mtimeMs
|
|
37940
38068
|
})).sort((a, b) => a.mtimeMs - b.mtimeMs);
|
|
37941
38069
|
while (files.length >= MAX_SNAPSHOTS) {
|
|
37942
38070
|
const oldest = files.shift();
|
|
@@ -37961,7 +38089,7 @@ async function snapshotOne(target, backupDir, now, cwd) {
|
|
|
37961
38089
|
if (!db) return;
|
|
37962
38090
|
opened = db;
|
|
37963
38091
|
}
|
|
37964
|
-
const dest =
|
|
38092
|
+
const dest = join19(backupDir, `${target.prefix}-${formatTimestamp(now)}.db`);
|
|
37965
38093
|
try {
|
|
37966
38094
|
db.exec("PRAGMA wal_checkpoint(TRUNCATE)");
|
|
37967
38095
|
rotateSnapshots(backupDir, target.prefix);
|
|
@@ -37982,7 +38110,7 @@ async function vacuumIntoBackup(opts = {}) {
|
|
|
37982
38110
|
}
|
|
37983
38111
|
try {
|
|
37984
38112
|
const cleoDir = getCleoDir(opts.cwd);
|
|
37985
|
-
const backupDir =
|
|
38113
|
+
const backupDir = join19(cleoDir, "backups", "sqlite");
|
|
37986
38114
|
mkdirSync5(backupDir, { recursive: true });
|
|
37987
38115
|
const target = SNAPSHOT_TARGETS.find((t) => t.prefix === prefix);
|
|
37988
38116
|
if (!target) return;
|
|
@@ -37994,13 +38122,13 @@ async function vacuumIntoBackup(opts = {}) {
|
|
|
37994
38122
|
function listSqliteBackupsForPrefix(prefix, cwd) {
|
|
37995
38123
|
try {
|
|
37996
38124
|
const cleoDir = getCleoDir(cwd);
|
|
37997
|
-
const backupDir =
|
|
38125
|
+
const backupDir = join19(cleoDir, "backups", "sqlite");
|
|
37998
38126
|
if (!existsSync20(backupDir)) return [];
|
|
37999
38127
|
const pattern = snapshotPattern(prefix);
|
|
38000
38128
|
return readdirSync4(backupDir).filter((f) => pattern.test(f)).map((f) => ({
|
|
38001
38129
|
name: f,
|
|
38002
|
-
path:
|
|
38003
|
-
mtimeMs: statSync7(
|
|
38130
|
+
path: join19(backupDir, f),
|
|
38131
|
+
mtimeMs: statSync7(join19(backupDir, f)).mtimeMs
|
|
38004
38132
|
})).sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
38005
38133
|
} catch {
|
|
38006
38134
|
return [];
|
|
@@ -38056,7 +38184,7 @@ __export(sqlite_native_exports, {
|
|
|
38056
38184
|
import { realpathSync } from "node:fs";
|
|
38057
38185
|
import { createRequire as createRequire8 } from "node:module";
|
|
38058
38186
|
import { tmpdir } from "node:os";
|
|
38059
|
-
import { delimiter, dirname as
|
|
38187
|
+
import { delimiter, dirname as dirname10, isAbsolute, join as join20, resolve as resolve4, sep } from "node:path";
|
|
38060
38188
|
function getDbSyncConstructor() {
|
|
38061
38189
|
if (_ctor === null) {
|
|
38062
38190
|
const mod = _require5("node:sqlite");
|
|
@@ -38072,12 +38200,12 @@ function resolveAbsoluteSafe(p) {
|
|
|
38072
38200
|
const missingParts = [];
|
|
38073
38201
|
let cursor = abs;
|
|
38074
38202
|
while (true) {
|
|
38075
|
-
const parent =
|
|
38203
|
+
const parent = dirname10(cursor);
|
|
38076
38204
|
if (parent === cursor) return abs;
|
|
38077
38205
|
missingParts.unshift(cursor.slice(parent.length + (parent.endsWith(sep) ? 0 : 1)));
|
|
38078
38206
|
cursor = parent;
|
|
38079
38207
|
try {
|
|
38080
|
-
return
|
|
38208
|
+
return join20(realpathSync(cursor), ...missingParts);
|
|
38081
38209
|
} catch {
|
|
38082
38210
|
}
|
|
38083
38211
|
}
|
|
@@ -39583,12 +39711,12 @@ var init_sqlite_data_accessor = __esm({
|
|
|
39583
39711
|
|
|
39584
39712
|
// packages/core/src/sequence/index.ts
|
|
39585
39713
|
import { existsSync as existsSync22, readFileSync as readFileSync6, renameSync as renameSync4 } from "node:fs";
|
|
39586
|
-
import { join as
|
|
39714
|
+
import { join as join21 } from "node:path";
|
|
39587
39715
|
function getLegacySequenceJsonPath(cwd) {
|
|
39588
|
-
return
|
|
39716
|
+
return join21(resolveOrCwd(cwd), ".cleo", ".sequence.json");
|
|
39589
39717
|
}
|
|
39590
39718
|
function getLegacySequencePath(cwd) {
|
|
39591
|
-
return
|
|
39719
|
+
return join21(resolveOrCwd(cwd), ".cleo", ".sequence");
|
|
39592
39720
|
}
|
|
39593
39721
|
function isValidSequenceState(value) {
|
|
39594
39722
|
if (!value || typeof value !== "object") return false;
|
|
@@ -39776,13 +39904,13 @@ var init_sequence = __esm({
|
|
|
39776
39904
|
import { execFile as execFile2 } from "node:child_process";
|
|
39777
39905
|
import { existsSync as existsSync23 } from "node:fs";
|
|
39778
39906
|
import { readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
39779
|
-
import { join as
|
|
39907
|
+
import { join as join22, resolve as resolve5 } from "node:path";
|
|
39780
39908
|
import { promisify as promisify2 } from "node:util";
|
|
39781
39909
|
function makeCleoGitEnv(cleoDir) {
|
|
39782
39910
|
const abs = resolve5(cleoDir);
|
|
39783
39911
|
return {
|
|
39784
39912
|
...process.env,
|
|
39785
|
-
GIT_DIR:
|
|
39913
|
+
GIT_DIR: join22(abs, ".git"),
|
|
39786
39914
|
GIT_WORK_TREE: abs
|
|
39787
39915
|
};
|
|
39788
39916
|
}
|
|
@@ -39800,7 +39928,7 @@ async function cleoGitCommand(args, cleoDir) {
|
|
|
39800
39928
|
}
|
|
39801
39929
|
}
|
|
39802
39930
|
function isCleoGitInitialized(cleoDir) {
|
|
39803
|
-
return existsSync23(
|
|
39931
|
+
return existsSync23(join22(cleoDir, ".git", "HEAD"));
|
|
39804
39932
|
}
|
|
39805
39933
|
async function loadStateFileAllowlist(cwd) {
|
|
39806
39934
|
try {
|
|
@@ -39844,25 +39972,25 @@ async function isCleoGitRepo(cleoDir) {
|
|
|
39844
39972
|
return result.success && (result.stdout === "true" || isCleoGitInitialized(cleoDir));
|
|
39845
39973
|
}
|
|
39846
39974
|
function isMergeInProgress(cleoDir) {
|
|
39847
|
-
return existsSync23(
|
|
39975
|
+
return existsSync23(join22(cleoDir, ".git", "MERGE_HEAD"));
|
|
39848
39976
|
}
|
|
39849
39977
|
async function isDetachedHead(cleoDir) {
|
|
39850
39978
|
const result = await cleoGitCommand(["symbolic-ref", "HEAD"], cleoDir);
|
|
39851
39979
|
return !result.success;
|
|
39852
39980
|
}
|
|
39853
39981
|
function isRebaseInProgress(cleoDir) {
|
|
39854
|
-
return existsSync23(
|
|
39982
|
+
return existsSync23(join22(cleoDir, ".git", "rebase-merge")) || existsSync23(join22(cleoDir, ".git", "rebase-apply"));
|
|
39855
39983
|
}
|
|
39856
39984
|
async function recordCheckpointTime(cleoDir) {
|
|
39857
39985
|
try {
|
|
39858
|
-
const stateFile =
|
|
39986
|
+
const stateFile = join22(cleoDir, CHECKPOINT_STATE_FILE);
|
|
39859
39987
|
await writeFile2(stateFile, String(Math.floor(Date.now() / 1e3)));
|
|
39860
39988
|
} catch {
|
|
39861
39989
|
}
|
|
39862
39990
|
}
|
|
39863
39991
|
async function getLastCheckpointTime(cleoDir) {
|
|
39864
39992
|
try {
|
|
39865
|
-
const stateFile =
|
|
39993
|
+
const stateFile = join22(cleoDir, CHECKPOINT_STATE_FILE);
|
|
39866
39994
|
const content = await readFile3(stateFile, "utf-8");
|
|
39867
39995
|
const epoch = parseInt(content.trim(), 10);
|
|
39868
39996
|
return Number.isNaN(epoch) ? 0 : epoch;
|
|
@@ -39874,7 +40002,7 @@ async function getChangedStateFiles(cleoDir, cwd) {
|
|
|
39874
40002
|
const changed = [];
|
|
39875
40003
|
const allStateFiles = await getAllStateFiles(cwd);
|
|
39876
40004
|
for (const stateFile of allStateFiles) {
|
|
39877
|
-
const fullPath =
|
|
40005
|
+
const fullPath = join22(cleoDir, stateFile);
|
|
39878
40006
|
if (!existsSync23(fullPath)) continue;
|
|
39879
40007
|
const diffResult = await cleoGitCommand(["diff", "--quiet", "--", stateFile], cleoDir);
|
|
39880
40008
|
const cachedResult = await cleoGitCommand(
|