@edihasaj/recall 1.4.1 → 1.4.15
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/README.md +17 -7
- package/dist/{chunk-WZWXYBP6.js → chunk-2E7UCWNS.js} +6 -3
- package/dist/{chunk-WZWXYBP6.js.map → chunk-2E7UCWNS.js.map} +1 -1
- package/dist/{chunk-JYWURG5T.js → chunk-5W3CDNJ6.js} +12 -2
- package/dist/chunk-5W3CDNJ6.js.map +1 -0
- package/dist/chunk-ADWOKDF6.js +23 -0
- package/dist/chunk-ADWOKDF6.js.map +1 -0
- package/dist/{chunk-CW3XJDH7.js → chunk-FDIV6YFT.js} +6 -2
- package/dist/{chunk-CW3XJDH7.js.map → chunk-FDIV6YFT.js.map} +1 -1
- package/dist/{chunk-EAFRT7RX.js → chunk-GMRT5DJZ.js} +7 -2
- package/dist/{chunk-EAFRT7RX.js.map → chunk-GMRT5DJZ.js.map} +1 -1
- package/dist/{chunk-PUMEMKGF.js → chunk-IMCI2CLJ.js} +7 -1
- package/dist/{chunk-PUMEMKGF.js.map → chunk-IMCI2CLJ.js.map} +1 -1
- package/dist/{chunk-ZBQGZCFL.js → chunk-KF3EGZWM.js} +99 -9
- package/dist/chunk-KF3EGZWM.js.map +1 -0
- package/dist/{chunk-NAYFAUSM.js → chunk-LCIVSUQO.js} +61 -21
- package/dist/chunk-LCIVSUQO.js.map +1 -0
- package/dist/{chunk-LWY4Z626.js → chunk-MESKBXZZ.js} +8 -4
- package/dist/{chunk-LWY4Z626.js.map → chunk-MESKBXZZ.js.map} +1 -1
- package/dist/{chunk-FHEH6QDU.js → chunk-PQOGHXET.js} +6 -1
- package/dist/{chunk-FHEH6QDU.js.map → chunk-PQOGHXET.js.map} +1 -1
- package/dist/{chunk-ZXCKMEJA.js → chunk-RRNELZJV.js} +11 -6
- package/dist/{chunk-ZXCKMEJA.js.map → chunk-RRNELZJV.js.map} +1 -1
- package/dist/{chunk-7CFX774S.js → chunk-SWPXUPMX.js} +306 -167
- package/dist/chunk-SWPXUPMX.js.map +1 -0
- package/dist/{chunk-T274LVWB.js → chunk-TZ4EU4SW.js} +15 -11
- package/dist/chunk-TZ4EU4SW.js.map +1 -0
- package/dist/chunk-UTOM43G2.js +594 -0
- package/dist/chunk-UTOM43G2.js.map +1 -0
- package/dist/{chunk-AFD43EOE.js → chunk-UZ4GFLH6.js} +8 -4
- package/dist/{chunk-AFD43EOE.js.map → chunk-UZ4GFLH6.js.map} +1 -1
- package/dist/{chunk-LUIYWYOT.js → chunk-VI6NOUXB.js} +51 -3
- package/dist/chunk-VI6NOUXB.js.map +1 -0
- package/dist/{chunk-TA4WSV6A.js → chunk-VZ456OCO.js} +204 -13
- package/dist/chunk-VZ456OCO.js.map +1 -0
- package/dist/{chunk-4UHRAQFG.js → chunk-ZECQ2LQB.js} +376 -58
- package/dist/chunk-ZECQ2LQB.js.map +1 -0
- package/dist/{cleanup-RTL2UETA.js → cleanup-KXCEVJ7V.js} +11 -10
- package/dist/cli.js +639 -784
- package/dist/cli.js.map +1 -1
- package/dist/codex-trust-H7VKP4G3.js +74 -0
- package/dist/codex-trust-H7VKP4G3.js.map +1 -0
- package/dist/daemon.js +174 -54
- package/dist/daemon.js.map +1 -1
- package/dist/dispatcher-GHC6RX54.js +22 -0
- package/dist/{embeddings-MILTROKW.js → embeddings-GYQBZWBD.js} +7 -5
- package/dist/ingest-6GDZNYCY.js +20 -0
- package/dist/{keychain-5KXUHKMF.js → keychain-TKPVUZCH.js} +3 -3
- package/dist/mcp.js +18 -14
- package/dist/mcp.js.map +1 -1
- package/dist/{memory-value-WXI2Q6TO.js → memory-value-A4UCC3DY.js} +11 -10
- package/dist/provenance-M5YFD6DO.js +50 -0
- package/dist/provenance-M5YFD6DO.js.map +1 -0
- package/dist/quality-TQ7CVPRO.js +25 -0
- package/dist/retrieval-7R5LKJAM.js +15 -0
- package/dist/{store-5C7ZKKZF.js → store-QKP6HQ45.js} +4 -4
- package/dist/sync-server.js +5 -2
- package/dist/sync-server.js.map +1 -1
- package/dist/{tasks-7SE6VHSQ.js → tasks-M5HSQSWK.js} +11 -10
- package/dist/{usage-VQ5LJCNH.js → usage-TQTOHPL7.js} +7 -4
- package/dist/{usage-VQ5LJCNH.js.map → usage-TQTOHPL7.js.map} +1 -1
- package/drizzle/0011_compact_telemetry_dedupe_keys.sql +25 -0
- package/drizzle/meta/_journal.json +7 -0
- package/package.json +15 -12
- package/dist/chunk-4UHRAQFG.js.map +0 -1
- package/dist/chunk-7CFX774S.js.map +0 -1
- package/dist/chunk-LUIYWYOT.js.map +0 -1
- package/dist/chunk-NAYFAUSM.js.map +0 -1
- package/dist/chunk-T274LVWB.js.map +0 -1
- package/dist/chunk-TA4WSV6A.js.map +0 -1
- package/dist/chunk-ZBQGZCFL.js.map +0 -1
- package/dist/dispatcher-PP5OKOLS.js +0 -21
- package/dist/ingest-HEXVIAL6.js +0 -19
- package/dist/quality-VKQUCL66.js +0 -24
- package/dist/retrieval-4MEIABHC.js +0 -14
- package/dist/tasks-7SE6VHSQ.js.map +0 -1
- /package/dist/{chunk-JYWURG5T.js.map → cleanup-KXCEVJ7V.js.map} +0 -0
- /package/dist/{cleanup-RTL2UETA.js.map → dispatcher-GHC6RX54.js.map} +0 -0
- /package/dist/{dispatcher-PP5OKOLS.js.map → embeddings-GYQBZWBD.js.map} +0 -0
- /package/dist/{embeddings-MILTROKW.js.map → ingest-6GDZNYCY.js.map} +0 -0
- /package/dist/{ingest-HEXVIAL6.js.map → keychain-TKPVUZCH.js.map} +0 -0
- /package/dist/{keychain-5KXUHKMF.js.map → memory-value-A4UCC3DY.js.map} +0 -0
- /package/dist/{memory-value-WXI2Q6TO.js.map → quality-TQ7CVPRO.js.map} +0 -0
- /package/dist/{quality-VKQUCL66.js.map → retrieval-7R5LKJAM.js.map} +0 -0
- /package/dist/{retrieval-4MEIABHC.js.map → store-QKP6HQ45.js.map} +0 -0
- /package/dist/{store-5C7ZKKZF.js.map → tasks-M5HSQSWK.js.map} +0 -0
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import {
|
|
2
|
+
applySupersession,
|
|
2
3
|
computeHealthScore,
|
|
3
4
|
evaluateScannedMemory,
|
|
4
5
|
getRepoQualityProfile,
|
|
6
|
+
isEphemeralTaskConstraint,
|
|
7
|
+
isHighRiskRule,
|
|
8
|
+
isNonUserCaptureContext,
|
|
5
9
|
processCorrection,
|
|
6
10
|
redactSensitiveValue,
|
|
7
11
|
seedScannedConfidence
|
|
8
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-VZ456OCO.js";
|
|
9
13
|
import {
|
|
10
14
|
recordInjectionValueEvents,
|
|
11
15
|
recordMemoryInjections,
|
|
12
16
|
recordOutcomeValueEvent,
|
|
13
17
|
resolveMemoryInjectionOutcome
|
|
14
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-RRNELZJV.js";
|
|
15
19
|
import {
|
|
16
20
|
textMatchScore
|
|
17
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PQOGHXET.js";
|
|
18
22
|
import {
|
|
19
23
|
activityEventDedupeKey,
|
|
20
24
|
confirmMemory,
|
|
25
|
+
containsGeneratedHistory,
|
|
21
26
|
createMemory,
|
|
22
27
|
demoteMemory,
|
|
23
28
|
feedbackWeightedScore,
|
|
24
29
|
getMemory,
|
|
25
30
|
getMemoryFeedbackSummaries,
|
|
31
|
+
hasDirectCorrectionEvidence,
|
|
32
|
+
hasNonDurableProvenance,
|
|
26
33
|
historySnippetDedupeKey,
|
|
27
34
|
promoteMemory,
|
|
28
35
|
queryMemories,
|
|
@@ -30,11 +37,11 @@ import {
|
|
|
30
37
|
recordFeedback,
|
|
31
38
|
rejectMemory,
|
|
32
39
|
statusFromConfidence
|
|
33
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-LCIVSUQO.js";
|
|
34
41
|
import {
|
|
35
42
|
asc,
|
|
36
43
|
desc
|
|
37
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-FDIV6YFT.js";
|
|
38
45
|
import {
|
|
39
46
|
BACKGROUND_INDEX_BATCH_SIZE,
|
|
40
47
|
CONFIDENCE,
|
|
@@ -47,6 +54,7 @@ import {
|
|
|
47
54
|
getEmbeddingCacheRoot,
|
|
48
55
|
getSynonyms,
|
|
49
56
|
hybridSearch,
|
|
57
|
+
load,
|
|
50
58
|
loadEmbeddingConfigFromEnv,
|
|
51
59
|
processInResponsiveBatches,
|
|
52
60
|
projectEmbeddingToIndex,
|
|
@@ -54,7 +62,7 @@ import {
|
|
|
54
62
|
readUtf8FileIfExists,
|
|
55
63
|
resolveProvider,
|
|
56
64
|
tagActivitySource
|
|
57
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-KF3EGZWM.js";
|
|
58
66
|
import {
|
|
59
67
|
Column,
|
|
60
68
|
Columns,
|
|
@@ -118,15 +126,22 @@ import {
|
|
|
118
126
|
policyRules,
|
|
119
127
|
schema_exports,
|
|
120
128
|
sql
|
|
121
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-VI6NOUXB.js";
|
|
130
|
+
import {
|
|
131
|
+
init_define_RECALL_BUILD_INFO
|
|
132
|
+
} from "./chunk-5W3CDNJ6.js";
|
|
122
133
|
|
|
123
134
|
// src/db/client.ts
|
|
135
|
+
init_define_RECALL_BUILD_INFO();
|
|
124
136
|
import Database from "better-sqlite3";
|
|
137
|
+
import { createHash } from "crypto";
|
|
125
138
|
|
|
126
139
|
// node_modules/drizzle-orm/better-sqlite3/driver.js
|
|
140
|
+
init_define_RECALL_BUILD_INFO();
|
|
127
141
|
import Client from "better-sqlite3";
|
|
128
142
|
|
|
129
143
|
// node_modules/drizzle-orm/logger.js
|
|
144
|
+
init_define_RECALL_BUILD_INFO();
|
|
130
145
|
var ConsoleLogWriter = class {
|
|
131
146
|
static [entityKind] = "ConsoleLogWriter";
|
|
132
147
|
write(message) {
|
|
@@ -157,7 +172,14 @@ var NoopLogger = class {
|
|
|
157
172
|
}
|
|
158
173
|
};
|
|
159
174
|
|
|
175
|
+
// node_modules/drizzle-orm/relations.js
|
|
176
|
+
init_define_RECALL_BUILD_INFO();
|
|
177
|
+
|
|
178
|
+
// node_modules/drizzle-orm/pg-core/primary-keys.js
|
|
179
|
+
init_define_RECALL_BUILD_INFO();
|
|
180
|
+
|
|
160
181
|
// node_modules/drizzle-orm/pg-core/table.js
|
|
182
|
+
init_define_RECALL_BUILD_INFO();
|
|
161
183
|
var InlineForeignKeys = /* @__PURE__ */ Symbol.for("drizzle:PgInlineForeignKeys");
|
|
162
184
|
var EnableRLS = /* @__PURE__ */ Symbol.for("drizzle:EnableRLS");
|
|
163
185
|
var PgTable = class extends Table {
|
|
@@ -468,7 +490,14 @@ function mapRelationalRow(tablesConfig, tableConfig, row, buildQueryResultSelect
|
|
|
468
490
|
return result;
|
|
469
491
|
}
|
|
470
492
|
|
|
493
|
+
// node_modules/drizzle-orm/sqlite-core/db.js
|
|
494
|
+
init_define_RECALL_BUILD_INFO();
|
|
495
|
+
|
|
496
|
+
// node_modules/drizzle-orm/selection-proxy.js
|
|
497
|
+
init_define_RECALL_BUILD_INFO();
|
|
498
|
+
|
|
471
499
|
// node_modules/drizzle-orm/alias.js
|
|
500
|
+
init_define_RECALL_BUILD_INFO();
|
|
472
501
|
var ColumnAliasProxyHandler = class {
|
|
473
502
|
constructor(table) {
|
|
474
503
|
this.table = table;
|
|
@@ -632,7 +661,11 @@ var SelectionProxyHandler = class _SelectionProxyHandler {
|
|
|
632
661
|
}
|
|
633
662
|
};
|
|
634
663
|
|
|
664
|
+
// node_modules/drizzle-orm/sqlite-core/query-builders/delete.js
|
|
665
|
+
init_define_RECALL_BUILD_INFO();
|
|
666
|
+
|
|
635
667
|
// node_modules/drizzle-orm/query-promise.js
|
|
668
|
+
init_define_RECALL_BUILD_INFO();
|
|
636
669
|
var QueryPromise = class {
|
|
637
670
|
static [entityKind] = "QueryPromise";
|
|
638
671
|
[Symbol.toStringTag] = "QueryPromise";
|
|
@@ -657,6 +690,7 @@ var QueryPromise = class {
|
|
|
657
690
|
};
|
|
658
691
|
|
|
659
692
|
// node_modules/drizzle-orm/sqlite-core/utils.js
|
|
693
|
+
init_define_RECALL_BUILD_INFO();
|
|
660
694
|
function extractUsedTable(table) {
|
|
661
695
|
if (is(table, SQLiteTable)) {
|
|
662
696
|
return [`${table[Table.Symbol.BaseName]}`];
|
|
@@ -784,7 +818,17 @@ var SQLiteDeleteBase = class extends QueryPromise {
|
|
|
784
818
|
}
|
|
785
819
|
};
|
|
786
820
|
|
|
821
|
+
// node_modules/drizzle-orm/sqlite-core/query-builders/insert.js
|
|
822
|
+
init_define_RECALL_BUILD_INFO();
|
|
823
|
+
|
|
824
|
+
// node_modules/drizzle-orm/sqlite-core/query-builders/query-builder.js
|
|
825
|
+
init_define_RECALL_BUILD_INFO();
|
|
826
|
+
|
|
827
|
+
// node_modules/drizzle-orm/sqlite-core/dialect.js
|
|
828
|
+
init_define_RECALL_BUILD_INFO();
|
|
829
|
+
|
|
787
830
|
// node_modules/drizzle-orm/casing.js
|
|
831
|
+
init_define_RECALL_BUILD_INFO();
|
|
788
832
|
function toSnakeCase(input) {
|
|
789
833
|
const words = input.replace(/['\u2019]/g, "").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g) ?? [];
|
|
790
834
|
return words.map((word) => word.toLowerCase()).join("_");
|
|
@@ -837,6 +881,7 @@ var CasingCache = class {
|
|
|
837
881
|
};
|
|
838
882
|
|
|
839
883
|
// node_modules/drizzle-orm/errors.js
|
|
884
|
+
init_define_RECALL_BUILD_INFO();
|
|
840
885
|
var DrizzleError = class extends Error {
|
|
841
886
|
static [entityKind] = "DrizzleError";
|
|
842
887
|
constructor({ message, cause }) {
|
|
@@ -864,6 +909,7 @@ var TransactionRollbackError = class extends DrizzleError {
|
|
|
864
909
|
};
|
|
865
910
|
|
|
866
911
|
// node_modules/drizzle-orm/sqlite-core/view-base.js
|
|
912
|
+
init_define_RECALL_BUILD_INFO();
|
|
867
913
|
var SQLiteViewBase = class extends View {
|
|
868
914
|
static [entityKind] = "SQLiteViewBase";
|
|
869
915
|
};
|
|
@@ -1558,7 +1604,11 @@ var SQLiteAsyncDialect = class extends SQLiteDialect {
|
|
|
1558
1604
|
}
|
|
1559
1605
|
};
|
|
1560
1606
|
|
|
1607
|
+
// node_modules/drizzle-orm/sqlite-core/query-builders/select.js
|
|
1608
|
+
init_define_RECALL_BUILD_INFO();
|
|
1609
|
+
|
|
1561
1610
|
// node_modules/drizzle-orm/query-builders/query-builder.js
|
|
1611
|
+
init_define_RECALL_BUILD_INFO();
|
|
1562
1612
|
var TypedQueryBuilder = class {
|
|
1563
1613
|
static [entityKind] = "TypedQueryBuilder";
|
|
1564
1614
|
/** @internal */
|
|
@@ -2474,6 +2524,7 @@ var SQLiteInsertBase = class extends QueryPromise {
|
|
|
2474
2524
|
};
|
|
2475
2525
|
|
|
2476
2526
|
// node_modules/drizzle-orm/sqlite-core/query-builders/update.js
|
|
2527
|
+
init_define_RECALL_BUILD_INFO();
|
|
2477
2528
|
var SQLiteUpdateBuilder = class {
|
|
2478
2529
|
constructor(table, session, dialect, withList) {
|
|
2479
2530
|
this.table = table;
|
|
@@ -2640,6 +2691,7 @@ var SQLiteUpdateBase = class extends QueryPromise {
|
|
|
2640
2691
|
};
|
|
2641
2692
|
|
|
2642
2693
|
// node_modules/drizzle-orm/sqlite-core/query-builders/count.js
|
|
2694
|
+
init_define_RECALL_BUILD_INFO();
|
|
2643
2695
|
var SQLiteCountBuilder = class _SQLiteCountBuilder extends SQL {
|
|
2644
2696
|
constructor(params) {
|
|
2645
2697
|
super(_SQLiteCountBuilder.buildEmbeddedCount(params.source, params.filters).queryChunks);
|
|
@@ -2684,6 +2736,7 @@ var SQLiteCountBuilder = class _SQLiteCountBuilder extends SQL {
|
|
|
2684
2736
|
};
|
|
2685
2737
|
|
|
2686
2738
|
// node_modules/drizzle-orm/sqlite-core/query-builders/query.js
|
|
2739
|
+
init_define_RECALL_BUILD_INFO();
|
|
2687
2740
|
var RelationalQueryBuilder = class {
|
|
2688
2741
|
constructor(mode, fullSchema, schema, tableNamesMap, table, tableConfig, dialect, session) {
|
|
2689
2742
|
this.mode = mode;
|
|
@@ -2828,6 +2881,7 @@ var SQLiteSyncRelationalQuery = class extends SQLiteRelationalQuery {
|
|
|
2828
2881
|
};
|
|
2829
2882
|
|
|
2830
2883
|
// node_modules/drizzle-orm/sqlite-core/query-builders/raw.js
|
|
2884
|
+
init_define_RECALL_BUILD_INFO();
|
|
2831
2885
|
var SQLiteRaw = class extends QueryPromise {
|
|
2832
2886
|
constructor(execute, getSQL, action, dialect, mapBatchResult) {
|
|
2833
2887
|
super();
|
|
@@ -3146,7 +3200,11 @@ var BaseSQLiteDatabase = class {
|
|
|
3146
3200
|
}
|
|
3147
3201
|
};
|
|
3148
3202
|
|
|
3203
|
+
// node_modules/drizzle-orm/better-sqlite3/session.js
|
|
3204
|
+
init_define_RECALL_BUILD_INFO();
|
|
3205
|
+
|
|
3149
3206
|
// node_modules/drizzle-orm/cache/core/cache.js
|
|
3207
|
+
init_define_RECALL_BUILD_INFO();
|
|
3150
3208
|
var Cache = class {
|
|
3151
3209
|
static [entityKind] = "Cache";
|
|
3152
3210
|
};
|
|
@@ -3174,6 +3232,7 @@ async function hashQuery(sql2, params) {
|
|
|
3174
3232
|
}
|
|
3175
3233
|
|
|
3176
3234
|
// node_modules/drizzle-orm/sqlite-core/session.js
|
|
3235
|
+
init_define_RECALL_BUILD_INFO();
|
|
3177
3236
|
var ExecuteResultSync = class extends QueryPromise {
|
|
3178
3237
|
constructor(resultCb) {
|
|
3179
3238
|
super();
|
|
@@ -3527,7 +3586,11 @@ function drizzle(...params) {
|
|
|
3527
3586
|
drizzle2.mock = mock;
|
|
3528
3587
|
})(drizzle || (drizzle = {}));
|
|
3529
3588
|
|
|
3589
|
+
// node_modules/drizzle-orm/better-sqlite3/migrator.js
|
|
3590
|
+
init_define_RECALL_BUILD_INFO();
|
|
3591
|
+
|
|
3530
3592
|
// node_modules/drizzle-orm/migrator.js
|
|
3593
|
+
init_define_RECALL_BUILD_INFO();
|
|
3531
3594
|
import crypto2 from "crypto";
|
|
3532
3595
|
import fs from "fs";
|
|
3533
3596
|
function readMigrationFiles(config) {
|
|
@@ -3570,7 +3633,7 @@ import { join, dirname } from "path";
|
|
|
3570
3633
|
import { mkdirSync, existsSync, rmSync, statSync } from "fs";
|
|
3571
3634
|
import { fileURLToPath } from "url";
|
|
3572
3635
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
3573
|
-
var RECALL_DB_USER_VERSION =
|
|
3636
|
+
var RECALL_DB_USER_VERSION = 12;
|
|
3574
3637
|
function getDbPath() {
|
|
3575
3638
|
const dataDir = process.env.RECALL_DATA_DIR ?? join(
|
|
3576
3639
|
process.env.HOME ?? process.env.USERPROFILE ?? ".",
|
|
@@ -3602,8 +3665,14 @@ var STARTUP_WAL_TRUNCATE_BYTES = (() => {
|
|
|
3602
3665
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
3603
3666
|
})();
|
|
3604
3667
|
function applyPragmas(sqlite) {
|
|
3668
|
+
sqlite.pragma("busy_timeout = 15000");
|
|
3605
3669
|
sqlite.pragma("journal_mode = WAL");
|
|
3606
3670
|
sqlite.pragma("foreign_keys = ON");
|
|
3671
|
+
sqlite.function(
|
|
3672
|
+
"recall_sha256",
|
|
3673
|
+
{ deterministic: true },
|
|
3674
|
+
(value) => createHash("sha256").update(value).digest("hex")
|
|
3675
|
+
);
|
|
3607
3676
|
truncateWalIfLarge(sqlite);
|
|
3608
3677
|
}
|
|
3609
3678
|
function truncateWalIfLarge(sqlite) {
|
|
@@ -3629,6 +3698,12 @@ function getDb(dbPath) {
|
|
|
3629
3698
|
}
|
|
3630
3699
|
return _db;
|
|
3631
3700
|
}
|
|
3701
|
+
function createStandaloneDb(dbPath) {
|
|
3702
|
+
const sqlite = new Database(dbPath);
|
|
3703
|
+
applyPragmas(sqlite);
|
|
3704
|
+
const db = makeDb(sqlite);
|
|
3705
|
+
return { db, sqlite };
|
|
3706
|
+
}
|
|
3632
3707
|
function migrateIfNeeded(db) {
|
|
3633
3708
|
const current = Number(db.$client.pragma("user_version", { simple: true }) ?? 0);
|
|
3634
3709
|
if (current >= RECALL_DB_USER_VERSION) return;
|
|
@@ -3640,6 +3715,11 @@ function initDb(dbPath) {
|
|
|
3640
3715
|
migrateIfNeeded(db);
|
|
3641
3716
|
return db;
|
|
3642
3717
|
}
|
|
3718
|
+
function initStandaloneDb(dbPath) {
|
|
3719
|
+
const { db } = createStandaloneDb(dbPath);
|
|
3720
|
+
migrateIfNeeded(db);
|
|
3721
|
+
return db;
|
|
3722
|
+
}
|
|
3643
3723
|
function closeDb() {
|
|
3644
3724
|
if (_sqlite) {
|
|
3645
3725
|
_sqlite.close();
|
|
@@ -3675,6 +3755,7 @@ function resetDb(dbPath, options = {}) {
|
|
|
3675
3755
|
}
|
|
3676
3756
|
|
|
3677
3757
|
// src/models/activity.ts
|
|
3758
|
+
init_define_RECALL_BUILD_INFO();
|
|
3678
3759
|
import { randomUUID } from "crypto";
|
|
3679
3760
|
function createActivityEvent(db, input) {
|
|
3680
3761
|
const safeInput = {
|
|
@@ -3793,6 +3874,7 @@ function rowToActivityEvent(row) {
|
|
|
3793
3874
|
}
|
|
3794
3875
|
|
|
3795
3876
|
// src/scanner/repo.ts
|
|
3877
|
+
init_define_RECALL_BUILD_INFO();
|
|
3796
3878
|
import { existsSync as existsSync2 } from "fs";
|
|
3797
3879
|
import { join as join2, basename } from "path";
|
|
3798
3880
|
import { execFileSync } from "child_process";
|
|
@@ -3808,10 +3890,11 @@ function scanRepo(repoPath) {
|
|
|
3808
3890
|
candidates.push(...scanPythonProject(repoPath, repoName));
|
|
3809
3891
|
return { candidates, repo: repoName };
|
|
3810
3892
|
}
|
|
3811
|
-
function scanAndStore(db, repoPath) {
|
|
3812
|
-
const { candidates, repo } =
|
|
3893
|
+
function scanAndStore(db, repoPath, scan = scanRepo(repoPath)) {
|
|
3894
|
+
const { candidates, repo } = scan;
|
|
3813
3895
|
const profile = getRepoQualityProfile(db, repo);
|
|
3814
3896
|
const existing = queryMemories(db, { repo }).filter((mem) => mem.status !== "rejected");
|
|
3897
|
+
const declined = declinedScanTexts(db, repo);
|
|
3815
3898
|
const ids = [];
|
|
3816
3899
|
for (const candidate of candidates) {
|
|
3817
3900
|
const evaluated = evaluateScannedMemory({
|
|
@@ -3826,6 +3909,7 @@ function scanAndStore(db, repoPath) {
|
|
|
3826
3909
|
if (evaluated.action === "reject") {
|
|
3827
3910
|
continue;
|
|
3828
3911
|
}
|
|
3912
|
+
if (declined.has(evaluated.text)) continue;
|
|
3829
3913
|
const seededConfidence = evaluated.confidence;
|
|
3830
3914
|
const normalizedCandidate = {
|
|
3831
3915
|
...candidate,
|
|
@@ -3850,14 +3934,154 @@ function scanAndStore(db, repoPath) {
|
|
|
3850
3934
|
normalizedCandidate.confidence = seededConfidence;
|
|
3851
3935
|
const id = createMemory(db, normalizedCandidate);
|
|
3852
3936
|
ids.push(id);
|
|
3937
|
+
applySupersession(db, id);
|
|
3853
3938
|
existing.push({
|
|
3854
3939
|
...queryMemories(db, { repo }).find((mem) => mem.id === id),
|
|
3855
3940
|
confidence: seededConfidence,
|
|
3856
3941
|
status: statusFromConfidence(seededConfidence)
|
|
3857
3942
|
});
|
|
3858
3943
|
}
|
|
3944
|
+
retractUnsupportedScanFacts(db, repoPath, repo, candidates);
|
|
3859
3945
|
return ids;
|
|
3860
3946
|
}
|
|
3947
|
+
function derivedScan(scan) {
|
|
3948
|
+
return {
|
|
3949
|
+
...scan,
|
|
3950
|
+
candidates: scan.candidates.filter((candidate) => !(candidate.evidence ?? []).some((entry) => "file" in entry && INSTRUCTION_FILES.includes(String(entry.file))))
|
|
3951
|
+
};
|
|
3952
|
+
}
|
|
3953
|
+
function declinedScanTexts(db, repo) {
|
|
3954
|
+
const rejected = db.select({ id: memories.id, text: memories.text }).from(memories).where(and(
|
|
3955
|
+
eq(memories.repo, repo),
|
|
3956
|
+
eq(memories.status, "rejected"),
|
|
3957
|
+
inArray(memories.source, ["repo_scan", "config_parse"])
|
|
3958
|
+
)).all();
|
|
3959
|
+
if (rejected.length === 0) return /* @__PURE__ */ new Set();
|
|
3960
|
+
const retracted = new Set(
|
|
3961
|
+
db.select({ id: auditTrail.memory_id }).from(auditTrail).where(and(
|
|
3962
|
+
inArray(auditTrail.memory_id, rejected.map((row) => row.id)),
|
|
3963
|
+
eq(auditTrail.actor, "scan_retraction")
|
|
3964
|
+
)).all().map((row) => row.id)
|
|
3965
|
+
);
|
|
3966
|
+
return new Set(rejected.filter((row) => !retracted.has(row.id)).map((row) => row.text));
|
|
3967
|
+
}
|
|
3968
|
+
function scanDiffersFromStore(db, scan) {
|
|
3969
|
+
const live = new Set(
|
|
3970
|
+
db.select({ text: memories.text }).from(memories).where(and(
|
|
3971
|
+
eq(memories.repo, scan.repo),
|
|
3972
|
+
inArray(memories.status, ["active", "candidate"]),
|
|
3973
|
+
inArray(memories.source, ["repo_scan", "config_parse"])
|
|
3974
|
+
)).all().map((row) => row.text)
|
|
3975
|
+
);
|
|
3976
|
+
const declined = declinedScanTexts(db, scan.repo);
|
|
3977
|
+
const produced = /* @__PURE__ */ new Set();
|
|
3978
|
+
for (const candidate of scan.candidates) {
|
|
3979
|
+
produced.add(candidate.text);
|
|
3980
|
+
const evaluated = evaluateScannedMemory({
|
|
3981
|
+
text: candidate.text,
|
|
3982
|
+
type: candidate.type,
|
|
3983
|
+
source: candidate.source,
|
|
3984
|
+
confidence: candidate.confidence ?? 0.5
|
|
3985
|
+
});
|
|
3986
|
+
if (evaluated.action === "reject") continue;
|
|
3987
|
+
produced.add(evaluated.text);
|
|
3988
|
+
if (declined.has(evaluated.text)) continue;
|
|
3989
|
+
if (!live.has(evaluated.text) && !live.has(candidate.text)) return true;
|
|
3990
|
+
}
|
|
3991
|
+
for (const text of live) {
|
|
3992
|
+
if (!produced.has(text) && SCAN_TEMPLATES.some((template) => template.test(text))) return true;
|
|
3993
|
+
}
|
|
3994
|
+
return false;
|
|
3995
|
+
}
|
|
3996
|
+
var SCAN_SOURCES = /* @__PURE__ */ new Set(["repo_scan", "config_parse"]);
|
|
3997
|
+
var SCAN_TEMPLATES = [
|
|
3998
|
+
/^Use (?:npm|pnpm|yarn|bun) as the package manager(?: \(lockfile: [\w.-]+\))?$/,
|
|
3999
|
+
/^(?:test|build|lint|dev|start|typecheck|check): `[^`]*`$/,
|
|
4000
|
+
/^Makefile targets: /,
|
|
4001
|
+
/^CI: /,
|
|
4002
|
+
/^(?:Next\.js|Vue\.js|Svelte) project$/,
|
|
4003
|
+
/^React project \(no Next\.js\)$/,
|
|
4004
|
+
/^Server framework: \w+$/,
|
|
4005
|
+
/^Linting\/formatting: /,
|
|
4006
|
+
/^Setup commands from README:/,
|
|
4007
|
+
/^Use `(?:uv|poetry)` for Python dependency management$/,
|
|
4008
|
+
/^Uses Alembic for database migrations$/
|
|
4009
|
+
];
|
|
4010
|
+
var HUMAN_TOUCH_ACTIONS = ["confirmed", "edited", "reactivated", "rolled_back"];
|
|
4011
|
+
function retractUnsupportedScanFacts(db, repoPath, repo, candidates) {
|
|
4012
|
+
const supported = /* @__PURE__ */ new Set();
|
|
4013
|
+
for (const candidate of candidates) {
|
|
4014
|
+
supported.add(candidate.text);
|
|
4015
|
+
const evaluated = evaluateScannedMemory({
|
|
4016
|
+
text: candidate.text,
|
|
4017
|
+
type: candidate.type,
|
|
4018
|
+
source: candidate.source,
|
|
4019
|
+
confidence: candidate.confidence ?? 0.5
|
|
4020
|
+
});
|
|
4021
|
+
supported.add(evaluated.text);
|
|
4022
|
+
}
|
|
4023
|
+
const packageJsonBroken = isUnparseableJson(join2(repoPath, "package.json"));
|
|
4024
|
+
const producedManager = candidates.some((candidate) => /^Use (?:npm|pnpm|yarn|bun) as the package manager/.test(candidate.text));
|
|
4025
|
+
const retracted = [];
|
|
4026
|
+
for (const mem of queryMemories(db, { repo })) {
|
|
4027
|
+
if (mem.status !== "active" && mem.status !== "candidate") continue;
|
|
4028
|
+
if (!SCAN_SOURCES.has(mem.source) || mem.scope !== "repo") continue;
|
|
4029
|
+
if (supported.has(mem.text)) continue;
|
|
4030
|
+
if (!SCAN_TEMPLATES.some((template) => template.test(mem.text))) continue;
|
|
4031
|
+
const named = mem.text.match(/^Use (npm|pnpm|yarn|bun) as the package manager/)?.[1];
|
|
4032
|
+
if (named && !producedManager && LOCKFILES.some(([manager, file]) => manager === named && existsSync2(join2(repoPath, file)))) continue;
|
|
4033
|
+
if (mem.evidence.length === 0 || mem.evidence.some((e) => e.type !== "repo_scan")) continue;
|
|
4034
|
+
const files = new Set(mem.evidence.map((e) => "file" in e ? String(e.file ?? "") : ""));
|
|
4035
|
+
if (packageJsonBroken && files.has("package.json")) continue;
|
|
4036
|
+
if ([...files].some((file) => INSTRUCTION_FILES.includes(file))) continue;
|
|
4037
|
+
const touched = db.select({ id: auditTrail.id }).from(auditTrail).where(and(eq(auditTrail.memory_id, mem.id), inArray(auditTrail.action, [...HUMAN_TOUCH_ACTIONS]))).get();
|
|
4038
|
+
if (touched) continue;
|
|
4039
|
+
rejectMemory(db, mem.id, "scan_retraction");
|
|
4040
|
+
recordAudit(
|
|
4041
|
+
db,
|
|
4042
|
+
mem.id,
|
|
4043
|
+
"pruned",
|
|
4044
|
+
"scan_retraction",
|
|
4045
|
+
`no longer found by repo scan in ${[...files].filter(Boolean).join(", ") || "repo files"}`
|
|
4046
|
+
);
|
|
4047
|
+
retracted.push(mem.id);
|
|
4048
|
+
}
|
|
4049
|
+
return retracted;
|
|
4050
|
+
}
|
|
4051
|
+
var LOCKFILES = [
|
|
4052
|
+
["pnpm", "pnpm-lock.yaml"],
|
|
4053
|
+
["yarn", "yarn.lock"],
|
|
4054
|
+
["bun", "bun.lockb"],
|
|
4055
|
+
["bun", "bun.lock"],
|
|
4056
|
+
["npm", "package-lock.json"]
|
|
4057
|
+
];
|
|
4058
|
+
function lockfileManager(repoPath) {
|
|
4059
|
+
const present = LOCKFILES.filter(([, file]) => existsSync2(join2(repoPath, file)));
|
|
4060
|
+
const managers = (files) => [...new Set(files.map(([manager]) => manager))];
|
|
4061
|
+
if (managers(present).length <= 1) return managers(present)[0] ?? null;
|
|
4062
|
+
let tracked;
|
|
4063
|
+
try {
|
|
4064
|
+
tracked = new Set(execFileSync("git", ["ls-files", "--", ...present.map(([, file]) => file)], {
|
|
4065
|
+
cwd: repoPath,
|
|
4066
|
+
encoding: "utf-8",
|
|
4067
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
4068
|
+
}).split("\n").filter(Boolean));
|
|
4069
|
+
} catch {
|
|
4070
|
+
return null;
|
|
4071
|
+
}
|
|
4072
|
+
const trackedManagers = managers(present.filter(([, file]) => tracked.has(file)));
|
|
4073
|
+
return trackedManagers.length === 1 ? trackedManagers[0] : null;
|
|
4074
|
+
}
|
|
4075
|
+
function isUnparseableJson(path) {
|
|
4076
|
+
try {
|
|
4077
|
+
const raw = readUtf8FileIfExists(path);
|
|
4078
|
+
if (raw === null) return false;
|
|
4079
|
+
JSON.parse(raw);
|
|
4080
|
+
return false;
|
|
4081
|
+
} catch {
|
|
4082
|
+
return true;
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
3861
4085
|
function scanPackageJson(repoPath, repo) {
|
|
3862
4086
|
const pkgPath = join2(repoPath, "package.json");
|
|
3863
4087
|
const results = [];
|
|
@@ -3872,12 +4096,9 @@ function scanPackageJson(repoPath, repo) {
|
|
|
3872
4096
|
repo,
|
|
3873
4097
|
"package.json"
|
|
3874
4098
|
));
|
|
3875
|
-
} else
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
results.push(makeCommand("Use yarn as the package manager", repo, "package.json"));
|
|
3879
|
-
} else if (existsSync2(join2(repoPath, "bun.lockb")) || existsSync2(join2(repoPath, "bun.lock"))) {
|
|
3880
|
-
results.push(makeCommand("Use bun as the package manager", repo, "package.json"));
|
|
4099
|
+
} else {
|
|
4100
|
+
const manager = lockfileManager(repoPath);
|
|
4101
|
+
if (manager) results.push(makeCommand(`Use ${manager} as the package manager`, repo, "package.json"));
|
|
3881
4102
|
}
|
|
3882
4103
|
const scripts = pkg.scripts ?? {};
|
|
3883
4104
|
const importantScripts = ["test", "build", "lint", "dev", "start", "typecheck", "check"];
|
|
@@ -3956,15 +4177,15 @@ function scanCIConfig(repoPath, repo) {
|
|
|
3956
4177
|
}
|
|
3957
4178
|
return results;
|
|
3958
4179
|
}
|
|
4180
|
+
var INSTRUCTION_FILES = [
|
|
4181
|
+
"CLAUDE.md",
|
|
4182
|
+
"AGENTS.md",
|
|
4183
|
+
".github/copilot-instructions.md",
|
|
4184
|
+
".cursorrules"
|
|
4185
|
+
];
|
|
3959
4186
|
function scanInstructionFiles(repoPath, repo) {
|
|
3960
4187
|
const results = [];
|
|
3961
|
-
const
|
|
3962
|
-
"CLAUDE.md",
|
|
3963
|
-
"AGENTS.md",
|
|
3964
|
-
".github/copilot-instructions.md",
|
|
3965
|
-
".cursorrules"
|
|
3966
|
-
];
|
|
3967
|
-
for (const file of instructionFiles) {
|
|
4188
|
+
for (const file of INSTRUCTION_FILES) {
|
|
3968
4189
|
const fPath = join2(repoPath, file);
|
|
3969
4190
|
try {
|
|
3970
4191
|
const content = readUtf8FileIfExists(fPath);
|
|
@@ -4115,10 +4336,23 @@ function makeGotcha(text, repo, file) {
|
|
|
4115
4336
|
}
|
|
4116
4337
|
|
|
4117
4338
|
// src/repo/discovery.ts
|
|
4339
|
+
init_define_RECALL_BUILD_INFO();
|
|
4118
4340
|
import { existsSync as existsSync3, readdirSync } from "fs";
|
|
4119
4341
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
4120
4342
|
import { join as join3, resolve } from "path";
|
|
4121
4343
|
var repoPathCache = /* @__PURE__ */ new Map();
|
|
4344
|
+
function runGit(args) {
|
|
4345
|
+
const binaries = ["git", ...process.platform === "darwin" && existsSync3("/opt/homebrew/bin/git") ? ["/opt/homebrew/bin/git"] : []];
|
|
4346
|
+
let failure;
|
|
4347
|
+
for (const binary of binaries) {
|
|
4348
|
+
try {
|
|
4349
|
+
return execFileSync2(binary, args, { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 5e3 }).trim();
|
|
4350
|
+
} catch (error) {
|
|
4351
|
+
failure = error;
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
4354
|
+
throw failure;
|
|
4355
|
+
}
|
|
4122
4356
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
4123
4357
|
".git",
|
|
4124
4358
|
"node_modules",
|
|
@@ -4205,15 +4439,19 @@ function resolveLocalRepoPath(repo, opts = {}) {
|
|
|
4205
4439
|
repoPathCache.set(normalizedRepo, fallback);
|
|
4206
4440
|
return fallback;
|
|
4207
4441
|
}
|
|
4442
|
+
function refreshKnownRepoScan(db, repo, repoPathHint) {
|
|
4443
|
+
const normalizedRepo = normalizeRepoSlug(repo);
|
|
4444
|
+
const root = normalizeRepoPathHint(repoPathHint);
|
|
4445
|
+
if (!normalizedRepo || !root || !pathMatchesRepo(root, normalizedRepo)) return null;
|
|
4446
|
+
const scan = derivedScan(scanRepo(root));
|
|
4447
|
+
if (!scanDiffersFromStore(db, scan)) return { repo_path: root, ids: [] };
|
|
4448
|
+
return { repo_path: root, ids: scanAndStore(db, root, scan) };
|
|
4449
|
+
}
|
|
4208
4450
|
function inferRepoSlugFromPath(repoPath) {
|
|
4209
4451
|
const root = normalizeRepoPathHint(repoPath);
|
|
4210
4452
|
if (!root) return null;
|
|
4211
4453
|
try {
|
|
4212
|
-
const remote =
|
|
4213
|
-
"git",
|
|
4214
|
-
["-C", root, "remote", "get-url", "origin"],
|
|
4215
|
-
{ encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
|
|
4216
|
-
).trim();
|
|
4454
|
+
const remote = runGit(["-C", root, "remote", "get-url", "origin"]);
|
|
4217
4455
|
return extractRepoSlugFromRemote2(remote);
|
|
4218
4456
|
} catch {
|
|
4219
4457
|
const parts = root.split("/").filter(Boolean);
|
|
@@ -4253,11 +4491,7 @@ function normalizeRepoPathHint(repoPath) {
|
|
|
4253
4491
|
if (!repoPath) return null;
|
|
4254
4492
|
const expanded = repoPath.trim().replace(/^~(?=\/)/, process.env.HOME ?? "~");
|
|
4255
4493
|
try {
|
|
4256
|
-
const root =
|
|
4257
|
-
"git",
|
|
4258
|
-
["-C", expanded, "rev-parse", "--show-toplevel"],
|
|
4259
|
-
{ encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }
|
|
4260
|
-
).trim();
|
|
4494
|
+
const root = runGit(["-C", expanded, "rev-parse", "--show-toplevel"]);
|
|
4261
4495
|
return root || null;
|
|
4262
4496
|
} catch {
|
|
4263
4497
|
const resolved = resolve(expanded);
|
|
@@ -4299,6 +4533,7 @@ function walkRepos(dir, depthRemaining, seen, repos) {
|
|
|
4299
4533
|
}
|
|
4300
4534
|
|
|
4301
4535
|
// src/history/snippets.ts
|
|
4536
|
+
init_define_RECALL_BUILD_INFO();
|
|
4302
4537
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
4303
4538
|
function createHistorySnippet(db, input) {
|
|
4304
4539
|
const dedupeKey = historySnippetDedupeKey(input);
|
|
@@ -4386,10 +4621,11 @@ function rowToHistorySnippet(row) {
|
|
|
4386
4621
|
}
|
|
4387
4622
|
|
|
4388
4623
|
// src/history/retrieval.ts
|
|
4389
|
-
|
|
4624
|
+
init_define_RECALL_BUILD_INFO();
|
|
4625
|
+
import { createHash as createHash2 } from "crypto";
|
|
4390
4626
|
|
|
4391
4627
|
// src/vector/sqlite-vec-history.ts
|
|
4392
|
-
|
|
4628
|
+
init_define_RECALL_BUILD_INFO();
|
|
4393
4629
|
var VEC_HISTORY_INDEX = "vec_history_index";
|
|
4394
4630
|
var loadedClients = /* @__PURE__ */ new WeakSet();
|
|
4395
4631
|
function getSqlite(db) {
|
|
@@ -4403,7 +4639,7 @@ function hasHistoryVecIndex(db) {
|
|
|
4403
4639
|
function ensureLoaded(db) {
|
|
4404
4640
|
const sqlite = getSqlite(db);
|
|
4405
4641
|
if (loadedClients.has(sqlite)) return;
|
|
4406
|
-
|
|
4642
|
+
load(sqlite);
|
|
4407
4643
|
loadedClients.add(sqlite);
|
|
4408
4644
|
}
|
|
4409
4645
|
function getHistoryVecDimension(rows) {
|
|
@@ -4436,8 +4672,8 @@ function ensureHistoryVecIndex(db, dimensions) {
|
|
|
4436
4672
|
`);
|
|
4437
4673
|
}
|
|
4438
4674
|
function removeHistoryVecRow(db, snippetId) {
|
|
4439
|
-
ensureLoaded(db);
|
|
4440
4675
|
if (!hasHistoryVecIndex(db)) return;
|
|
4676
|
+
ensureLoaded(db);
|
|
4441
4677
|
getSqlite(db).prepare(`delete from ${VEC_HISTORY_INDEX} where snippet_id = ?`).run(snippetId);
|
|
4442
4678
|
}
|
|
4443
4679
|
async function rebuildHistoryVecIndexResponsive(db, config, options = {}) {
|
|
@@ -4540,6 +4776,7 @@ function searchHistoryVecIndex(db, queryEmbedding, options = {}) {
|
|
|
4540
4776
|
}
|
|
4541
4777
|
|
|
4542
4778
|
// src/vector/sqlite-fts-history.ts
|
|
4779
|
+
init_define_RECALL_BUILD_INFO();
|
|
4543
4780
|
var FTS_HISTORY_INDEX = "fts_history_index";
|
|
4544
4781
|
var FTS_TOKENIZER = `porter unicode61 remove_diacritics 2`;
|
|
4545
4782
|
function getSqlite2(db) {
|
|
@@ -4708,7 +4945,7 @@ function searchHistoryFtsIndex(db, query, options = {}) {
|
|
|
4708
4945
|
|
|
4709
4946
|
// src/history/retrieval.ts
|
|
4710
4947
|
function hashText(text) {
|
|
4711
|
-
return
|
|
4948
|
+
return createHash2("sha256").update(text).digest("hex");
|
|
4712
4949
|
}
|
|
4713
4950
|
function version(config) {
|
|
4714
4951
|
return config.version || `${config.provider}:${config.model}:${config.dimensions}`;
|
|
@@ -4779,8 +5016,19 @@ async function bootstrapHistoryEmbeddings(db, config, options = {}) {
|
|
|
4779
5016
|
return total;
|
|
4780
5017
|
}
|
|
4781
5018
|
function verifyHistoryEmbeddings(db, config, options = {}) {
|
|
4782
|
-
const rows = db.select(
|
|
4783
|
-
|
|
5019
|
+
const rows = db.select({
|
|
5020
|
+
id: historySnippets.id,
|
|
5021
|
+
repo: historySnippets.repo,
|
|
5022
|
+
text: historySnippets.text
|
|
5023
|
+
}).from(historySnippets).all().filter((row) => !options.repo || row.repo === options.repo);
|
|
5024
|
+
const embeddings = db.select({
|
|
5025
|
+
snippet_id: historySnippetEmbeddings.snippet_id,
|
|
5026
|
+
model: historySnippetEmbeddings.model,
|
|
5027
|
+
embedding_dimensions: historySnippetEmbeddings.embedding_dimensions,
|
|
5028
|
+
index_dimensions: historySnippetEmbeddings.index_dimensions,
|
|
5029
|
+
version: historySnippetEmbeddings.version,
|
|
5030
|
+
content_hash: historySnippetEmbeddings.content_hash
|
|
5031
|
+
}).from(historySnippetEmbeddings).all();
|
|
4784
5032
|
const byId = new Map(embeddings.map((row) => [row.snippet_id, row]));
|
|
4785
5033
|
let eligible = 0;
|
|
4786
5034
|
let stale = 0;
|
|
@@ -4858,7 +5106,11 @@ async function searchHistorySnippets(db, query, options = {}) {
|
|
|
4858
5106
|
return [...merged.values()].sort((a, b) => b.score - a.score).slice(0, limit);
|
|
4859
5107
|
}
|
|
4860
5108
|
|
|
5109
|
+
// src/compiler/context.ts
|
|
5110
|
+
init_define_RECALL_BUILD_INFO();
|
|
5111
|
+
|
|
4861
5112
|
// src/models/history-injections.ts
|
|
5113
|
+
init_define_RECALL_BUILD_INFO();
|
|
4862
5114
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
4863
5115
|
function recordHistoryInjections(db, input) {
|
|
4864
5116
|
if (!input.session_id || input.snippet_ids.length === 0) return 0;
|
|
@@ -4883,6 +5135,18 @@ function listInjectedHistoryIdsForSession(db, sessionId) {
|
|
|
4883
5135
|
return new Set(rows.map((row) => row.snippet_id));
|
|
4884
5136
|
}
|
|
4885
5137
|
|
|
5138
|
+
// src/repo/aliases.ts
|
|
5139
|
+
init_define_RECALL_BUILD_INFO();
|
|
5140
|
+
function memoryRepoAliases(db, repo) {
|
|
5141
|
+
if (!repo) return [repo];
|
|
5142
|
+
const known = db.selectDistinct({ repo: memories.repo }).from(memories).all().map((row) => row.repo).filter((name) => Boolean(name));
|
|
5143
|
+
const basename2 = repo.split("/").at(-1);
|
|
5144
|
+
const qualified = known.filter((name) => name.includes("/") && name.split("/").at(-1) === basename2);
|
|
5145
|
+
if (repo.includes("/") && !qualified.includes(repo)) qualified.push(repo);
|
|
5146
|
+
if (qualified.length !== 1) return [repo];
|
|
5147
|
+
return [.../* @__PURE__ */ new Set([repo, basename2, qualified[0]])];
|
|
5148
|
+
}
|
|
5149
|
+
|
|
4886
5150
|
// src/compiler/context.ts
|
|
4887
5151
|
var DEFAULT_CONFIG = {
|
|
4888
5152
|
confidence_threshold: CONFIDENCE.ACTIVE_MIN,
|
|
@@ -4984,17 +5248,17 @@ function compileContext(db, req) {
|
|
|
4984
5248
|
confidence_threshold: req.config?.confidence_threshold ?? profile.compile_confidence_threshold
|
|
4985
5249
|
};
|
|
4986
5250
|
const selectedHistory = selectRepoHistory(db, req.repo, config.max_history_snippets);
|
|
4987
|
-
const repoActive = queryMemories(db, {
|
|
4988
|
-
repo
|
|
5251
|
+
const repoActive = memoryRepoAliases(db, req.repo).flatMap((repo) => queryMemories(db, {
|
|
5252
|
+
repo,
|
|
4989
5253
|
status: "active",
|
|
4990
5254
|
auto_inject: true
|
|
4991
|
-
});
|
|
5255
|
+
}));
|
|
4992
5256
|
const globalActive = queryMemories(db, {
|
|
4993
5257
|
scope: "global",
|
|
4994
5258
|
status: "active",
|
|
4995
5259
|
auto_inject: true
|
|
4996
5260
|
});
|
|
4997
|
-
const allActive = dedupeById([...repoActive, ...globalActive]);
|
|
5261
|
+
const allActive = dedupeById([...repoActive, ...globalActive]).filter((m) => !hasNonDurableProvenance(m));
|
|
4998
5262
|
const sessionScoped = filterSessionScoped(allActive, req.session_id);
|
|
4999
5263
|
const scoped = req.path ? sessionScoped.filter((m) => pathMatches(m, req.path)) : sessionScoped;
|
|
5000
5264
|
const passing = scoped.filter(
|
|
@@ -5095,29 +5359,39 @@ async function compileContextHybrid(db, req) {
|
|
|
5095
5359
|
const normalizedQuery = req.query_text ? normalizeQueryForRetrieval(req.query_text) : "";
|
|
5096
5360
|
const effectiveQuery = normalizedQuery.length > 0 ? normalizedQuery : void 0;
|
|
5097
5361
|
const selectedHistory = effectiveQuery ? await selectRelevantHistory(db, req.repo, effectiveQuery, config.max_history_snippets) : selectRepoHistory(db, req.repo, config.max_history_snippets);
|
|
5098
|
-
const repoMemories = queryMemories(db, { repo
|
|
5362
|
+
const repoMemories = memoryRepoAliases(db, req.repo).flatMap((repo) => queryMemories(db, { repo }));
|
|
5099
5363
|
const globalMemories = queryMemories(db, { scope: "global" });
|
|
5364
|
+
const eligibleCandidate = (memory) => {
|
|
5365
|
+
if (req.config?.include_candidates === false) return false;
|
|
5366
|
+
if (isHighRiskRule(memory.text)) return false;
|
|
5367
|
+
if (req.config?.include_candidates === true) return true;
|
|
5368
|
+
return Boolean(effectiveQuery) && hasDirectCorrectionEvidence(memory) && memory.evidence.some((entry) => entry.type === "session_correction" && Boolean(entry.context) && !isNonUserCaptureContext(entry.context ?? "") && !isEphemeralTaskConstraint(memory.text, entry.context ?? ""));
|
|
5369
|
+
};
|
|
5100
5370
|
const allMemories = dedupeById([...repoMemories, ...globalMemories]).filter((memory) => {
|
|
5101
|
-
|
|
5371
|
+
if (hasNonDurableProvenance(memory)) return false;
|
|
5372
|
+
const statusEligible = memory.status === "active" || memory.status === "candidate" && eligibleCandidate(memory);
|
|
5102
5373
|
if (!statusEligible) return false;
|
|
5103
5374
|
if (memory.auto_inject) return true;
|
|
5104
|
-
return Boolean(effectiveQuery) && memory.status === "active";
|
|
5375
|
+
return Boolean(effectiveQuery) && (memory.status === "active" || eligibleCandidate(memory));
|
|
5105
5376
|
});
|
|
5106
5377
|
const sessionScoped = filterSessionScoped(allMemories, req.session_id);
|
|
5107
5378
|
const scoped = req.path ? sessionScoped.filter((memory) => pathMatches(memory, req.path)) : sessionScoped;
|
|
5108
|
-
const candidateConfidenceFloor = Math.min(config.confidence_threshold, 0.
|
|
5379
|
+
const candidateConfidenceFloor = Math.min(config.confidence_threshold, 0.35);
|
|
5109
5380
|
const passing = scoped.filter((memory) => {
|
|
5110
5381
|
if (memory.status === "active") {
|
|
5111
5382
|
return memory.confidence + CONFIDENCE_EPSILON >= config.confidence_threshold;
|
|
5112
5383
|
}
|
|
5113
|
-
if (memory.status === "candidate" &&
|
|
5384
|
+
if (memory.status === "candidate" && eligibleCandidate(memory)) {
|
|
5114
5385
|
return memory.confidence >= candidateConfidenceFloor;
|
|
5115
5386
|
}
|
|
5116
5387
|
return false;
|
|
5117
5388
|
});
|
|
5118
5389
|
const passingIds = new Set(passing.map((memory) => memory.id));
|
|
5119
5390
|
const dropped = scoped.filter((memory) => !passingIds.has(memory.id));
|
|
5120
|
-
const hybridNearMisses = collectNearMisses(
|
|
5391
|
+
const hybridNearMisses = collectNearMisses(
|
|
5392
|
+
dropped.filter((memory) => !effectiveQuery || textMatchScore(effectiveQuery, memory.text).score >= QUERY_TEXT_MATCH_FLOOR),
|
|
5393
|
+
config.confidence_threshold
|
|
5394
|
+
);
|
|
5121
5395
|
if (passing.length === 0 && selectedHistory.length === 0) {
|
|
5122
5396
|
return {
|
|
5123
5397
|
confidence_threshold: config.confidence_threshold,
|
|
@@ -5291,7 +5565,8 @@ ${sections.join("\n\n")}
|
|
|
5291
5565
|
}
|
|
5292
5566
|
function renderMemoryBullet(memory) {
|
|
5293
5567
|
const prefix = memory.scope === "global" ? "[global] " : "";
|
|
5294
|
-
|
|
5568
|
+
const pending = memory.status === "candidate" ? "[unconfirmed preference; not authorization] " : "";
|
|
5569
|
+
return `- ${prefix}${pending}${renderMemoryText(memory)}`;
|
|
5295
5570
|
}
|
|
5296
5571
|
function renderMemoryText(memory) {
|
|
5297
5572
|
const text = memory.text.replace(/\r\n/g, "\n").trim();
|
|
@@ -5343,7 +5618,7 @@ var HISTORY_KINDS = /* @__PURE__ */ new Set([
|
|
|
5343
5618
|
]);
|
|
5344
5619
|
function selectRepoHistory(db, repo, limit) {
|
|
5345
5620
|
if (limit <= 0) return [];
|
|
5346
|
-
return listHistorySnippets(db, { repo, limit: Math.max(limit * 3, 6) }).filter((snippet) => !snippet.session_id && HISTORY_KINDS.has(snippet.kind)).slice(0, limit);
|
|
5621
|
+
return listHistorySnippets(db, { repo, limit: Math.max(limit * 3, 6) }).filter((snippet) => !snippet.session_id && HISTORY_KINDS.has(snippet.kind) && !containsGeneratedHistory(snippet.text)).slice(0, limit);
|
|
5347
5622
|
}
|
|
5348
5623
|
async function selectRelevantHistory(db, repo, query, limit) {
|
|
5349
5624
|
if (limit <= 0) return [];
|
|
@@ -5353,7 +5628,7 @@ async function selectRelevantHistory(db, repo, query, limit) {
|
|
|
5353
5628
|
});
|
|
5354
5629
|
return results.filter(
|
|
5355
5630
|
(result) => result.lexical_score >= HISTORY_LEXICAL_RELEVANCE_FLOOR || result.similarity >= HISTORY_VECTOR_RELEVANCE_FLOOR
|
|
5356
|
-
).map((result) => result.snippet).filter((snippet) => HISTORY_KINDS.has(snippet.kind)).slice(0, limit);
|
|
5631
|
+
).map((result) => result.snippet).filter((snippet) => HISTORY_KINDS.has(snippet.kind) && !containsGeneratedHistory(snippet.text)).slice(0, limit);
|
|
5357
5632
|
}
|
|
5358
5633
|
var HISTORY_ENTRY_MAX_CHARS = 120;
|
|
5359
5634
|
var HISTORY_MAX_ENTRIES_PER_SNIPPET = 2;
|
|
@@ -5449,6 +5724,7 @@ function filterSessionScoped(memories4, sessionId) {
|
|
|
5449
5724
|
}
|
|
5450
5725
|
|
|
5451
5726
|
// src/adapters/markdown.ts
|
|
5727
|
+
init_define_RECALL_BUILD_INFO();
|
|
5452
5728
|
function exportMarkdown(db, repo) {
|
|
5453
5729
|
const result = compileContext(db, { repo });
|
|
5454
5730
|
if (!result.text) {
|
|
@@ -5477,6 +5753,7 @@ ${result.text}`;
|
|
|
5477
5753
|
}
|
|
5478
5754
|
|
|
5479
5755
|
// src/artifacts/context.ts
|
|
5756
|
+
init_define_RECALL_BUILD_INFO();
|
|
5480
5757
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
5481
5758
|
import { isAbsolute, join as join4, resolve as resolve2 } from "path";
|
|
5482
5759
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
@@ -5549,12 +5826,13 @@ function ensureRepoContextExcluded(repoPath) {
|
|
|
5549
5826
|
}
|
|
5550
5827
|
|
|
5551
5828
|
// src/session/lifecycle.ts
|
|
5829
|
+
init_define_RECALL_BUILD_INFO();
|
|
5552
5830
|
function resolveLifecycleSource(input) {
|
|
5553
5831
|
if (input.source) return input.source;
|
|
5554
5832
|
return input.client ? tagActivitySource("hook", input.client) : "daemon";
|
|
5555
5833
|
}
|
|
5556
5834
|
function startSessionLifecycle(db, input) {
|
|
5557
|
-
const repo = input.repo ?? inferRepoSlugFromPath(input.repo_path) ?? null;
|
|
5835
|
+
const repo = input.repo ?? process.env.RECALL_REPO_OVERRIDE?.trim() ?? inferRepoSlugFromPath(input.repo_path) ?? null;
|
|
5558
5836
|
const bootstrap = ensureRepoBootstrapped(db, {
|
|
5559
5837
|
repo,
|
|
5560
5838
|
repoPathHint: input.repo_path
|
|
@@ -5578,6 +5856,12 @@ function startSessionLifecycle(db, input) {
|
|
|
5578
5856
|
}
|
|
5579
5857
|
});
|
|
5580
5858
|
}
|
|
5859
|
+
if (bootstrap.status === "already_known" && bootstrap.repo && input.repo_path) {
|
|
5860
|
+
try {
|
|
5861
|
+
refreshKnownRepoScan(db, bootstrap.repo, input.repo_path);
|
|
5862
|
+
} catch {
|
|
5863
|
+
}
|
|
5864
|
+
}
|
|
5581
5865
|
const artifact = writeRepoContextArtifact(db, {
|
|
5582
5866
|
repo: bootstrap.repo,
|
|
5583
5867
|
repo_path: bootstrap.repo_path ?? input.repo_path ?? null
|
|
@@ -5609,7 +5893,7 @@ function startSessionLifecycle(db, input) {
|
|
|
5609
5893
|
};
|
|
5610
5894
|
}
|
|
5611
5895
|
function recordSessionLifecycleEvent(db, input) {
|
|
5612
|
-
const repo = input.repo ?? inferRepoSlugFromPath(input.repo_path) ?? null;
|
|
5896
|
+
const repo = input.repo ?? process.env.RECALL_REPO_OVERRIDE?.trim() ?? inferRepoSlugFromPath(input.repo_path) ?? null;
|
|
5613
5897
|
createActivityEvent(db, {
|
|
5614
5898
|
session_id: input.session_id,
|
|
5615
5899
|
repo,
|
|
@@ -5633,7 +5917,7 @@ function recordSessionLifecycleEvent(db, input) {
|
|
|
5633
5917
|
};
|
|
5634
5918
|
}
|
|
5635
5919
|
function endSessionLifecycle(db, input) {
|
|
5636
|
-
const repo = input.repo ?? inferRepoSlugFromPath(input.repo_path) ?? null;
|
|
5920
|
+
const repo = input.repo ?? process.env.RECALL_REPO_OVERRIDE?.trim() ?? inferRepoSlugFromPath(input.repo_path) ?? null;
|
|
5637
5921
|
createActivityEvent(db, {
|
|
5638
5922
|
session_id: input.session_id,
|
|
5639
5923
|
repo,
|
|
@@ -5657,6 +5941,7 @@ function endSessionLifecycle(db, input) {
|
|
|
5657
5941
|
}
|
|
5658
5942
|
|
|
5659
5943
|
// src/eval/harness.ts
|
|
5944
|
+
init_define_RECALL_BUILD_INFO();
|
|
5660
5945
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
5661
5946
|
function startEvalSession(db, repo) {
|
|
5662
5947
|
const id = randomUUID4();
|
|
@@ -5836,6 +6121,7 @@ function formatMetricsReport(metrics) {
|
|
|
5836
6121
|
}
|
|
5837
6122
|
|
|
5838
6123
|
// src/eval/retrieval.ts
|
|
6124
|
+
init_define_RECALL_BUILD_INFO();
|
|
5839
6125
|
import { readFileSync } from "fs";
|
|
5840
6126
|
function loadRetrievalEvalFile(path) {
|
|
5841
6127
|
return RetrievalEvalFile.parse(JSON.parse(readFileSync(path, "utf8")));
|
|
@@ -6173,6 +6459,7 @@ function embeddingConfigForProvider(provider) {
|
|
|
6173
6459
|
}
|
|
6174
6460
|
|
|
6175
6461
|
// src/feedback/implicit.ts
|
|
6462
|
+
init_define_RECALL_BUILD_INFO();
|
|
6176
6463
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
6177
6464
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
6178
6465
|
var SIGNAL_WEIGHTS = {
|
|
@@ -6221,6 +6508,7 @@ function getSignalStats(db, memoryId) {
|
|
|
6221
6508
|
}
|
|
6222
6509
|
|
|
6223
6510
|
// src/policy/engine.ts
|
|
6511
|
+
init_define_RECALL_BUILD_INFO();
|
|
6224
6512
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
6225
6513
|
function createPolicy(db, orgId, ruleType, config) {
|
|
6226
6514
|
const id = randomUUID6();
|
|
@@ -6382,7 +6670,9 @@ function rowToPolicy(row) {
|
|
|
6382
6670
|
}
|
|
6383
6671
|
|
|
6384
6672
|
// src/pruning/pruner.ts
|
|
6673
|
+
init_define_RECALL_BUILD_INFO();
|
|
6385
6674
|
var DEFAULT_CONFIG2 = {
|
|
6675
|
+
candidate_unconfirmed_days: 30,
|
|
6386
6676
|
stale_days: 90,
|
|
6387
6677
|
rejected_retention_days: 30,
|
|
6388
6678
|
transient_retention_days: 7,
|
|
@@ -6397,18 +6687,43 @@ function pruneMemories(db, config = {}) {
|
|
|
6397
6687
|
const now2 = Date.now();
|
|
6398
6688
|
const dayMs = 864e5;
|
|
6399
6689
|
const result = {
|
|
6690
|
+
unconfirmed_archived: [],
|
|
6400
6691
|
stale_archived: [],
|
|
6401
6692
|
rejected_pruned: [],
|
|
6402
6693
|
transient_pruned: [],
|
|
6403
6694
|
unhealthy_demoted: [],
|
|
6404
6695
|
total: 0
|
|
6405
6696
|
};
|
|
6697
|
+
const unconfirmedCutoff = new Date(
|
|
6698
|
+
now2 - cfg.candidate_unconfirmed_days * dayMs
|
|
6699
|
+
).toISOString();
|
|
6700
|
+
const unconfirmed = queryMemories(db, {
|
|
6701
|
+
repo: cfg.repo,
|
|
6702
|
+
status: "candidate",
|
|
6703
|
+
auto_inject: true
|
|
6704
|
+
}).filter(
|
|
6705
|
+
(mem) => mem.created_at < unconfirmedCutoff && mem.repetition_count < 2 && mem.injection_count === 0
|
|
6706
|
+
);
|
|
6707
|
+
for (const mem of unconfirmed) {
|
|
6708
|
+
if (!cfg.dry_run) {
|
|
6709
|
+
db.update(memories).set({ auto_inject: false, updated_at: (/* @__PURE__ */ new Date()).toISOString() }).where(eq(memories.id, mem.id)).run();
|
|
6710
|
+
recordAudit(
|
|
6711
|
+
db,
|
|
6712
|
+
mem.id,
|
|
6713
|
+
"demoted",
|
|
6714
|
+
"auto-pruner",
|
|
6715
|
+
`Archived unconfirmed candidate after ${cfg.candidate_unconfirmed_days}d without selection or repetition`
|
|
6716
|
+
);
|
|
6717
|
+
}
|
|
6718
|
+
result.unconfirmed_archived.push(mem.id);
|
|
6719
|
+
}
|
|
6406
6720
|
const staleCutoff = new Date(now2 - cfg.stale_days * dayMs).toISOString();
|
|
6407
6721
|
const staleCandidates = queryMemories(db, {
|
|
6408
6722
|
repo: cfg.repo,
|
|
6409
6723
|
limit: void 0
|
|
6410
6724
|
}).filter((mem) => mem.status !== "rejected" && mem.status !== "transient");
|
|
6411
6725
|
for (const mem of staleCandidates) {
|
|
6726
|
+
if (result.unconfirmed_archived.includes(mem.id)) continue;
|
|
6412
6727
|
const lastActivity = mem.last_validated_at ?? mem.last_injected_at ?? mem.updated_at;
|
|
6413
6728
|
if (lastActivity < staleCutoff && mem.auto_inject) {
|
|
6414
6729
|
if (!cfg.dry_run) {
|
|
@@ -6479,7 +6794,7 @@ function pruneMemories(db, config = {}) {
|
|
|
6479
6794
|
result.unhealthy_demoted.push(mem.id);
|
|
6480
6795
|
}
|
|
6481
6796
|
}
|
|
6482
|
-
result.total = result.stale_archived.length + result.rejected_pruned.length + result.transient_pruned.length + result.unhealthy_demoted.length;
|
|
6797
|
+
result.total = result.unconfirmed_archived.length + result.stale_archived.length + result.rejected_pruned.length + result.transient_pruned.length + result.unhealthy_demoted.length;
|
|
6483
6798
|
return result;
|
|
6484
6799
|
}
|
|
6485
6800
|
function deleteMemoryAndDependents(db, memoryId) {
|
|
@@ -6500,6 +6815,7 @@ function formatPruneReport(result, dryRun) {
|
|
|
6500
6815
|
const lines = [
|
|
6501
6816
|
`${prefix}Prune Report`,
|
|
6502
6817
|
``,
|
|
6818
|
+
`Unconfirmed archived:${String(result.unconfirmed_archived.length).padStart(5)}`,
|
|
6503
6819
|
`Stale archived: ${result.stale_archived.length}`,
|
|
6504
6820
|
`Rejected pruned: ${result.rejected_pruned.length}`,
|
|
6505
6821
|
`Transient pruned: ${result.transient_pruned.length}`,
|
|
@@ -6522,6 +6838,7 @@ function formatPruneReport(result, dryRun) {
|
|
|
6522
6838
|
}
|
|
6523
6839
|
|
|
6524
6840
|
// src/mcp/fallback.ts
|
|
6841
|
+
init_define_RECALL_BUILD_INFO();
|
|
6525
6842
|
async function captureCorrectionFallback(db, input, source) {
|
|
6526
6843
|
const sessionId = input.session_id ?? `${source}-capture`;
|
|
6527
6844
|
const { ids, pendingTaskId, blockedByRejectedExemplar } = await processCorrection(db, input.text, {
|
|
@@ -6629,6 +6946,7 @@ export {
|
|
|
6629
6946
|
RECALL_DB_USER_VERSION,
|
|
6630
6947
|
getDbPath,
|
|
6631
6948
|
initDb,
|
|
6949
|
+
initStandaloneDb,
|
|
6632
6950
|
closeDb,
|
|
6633
6951
|
getDbUserVersion,
|
|
6634
6952
|
resetDb,
|
|
@@ -6688,4 +7006,4 @@ export {
|
|
|
6688
7006
|
pruneMemories,
|
|
6689
7007
|
formatPruneReport
|
|
6690
7008
|
};
|
|
6691
|
-
//# sourceMappingURL=chunk-
|
|
7009
|
+
//# sourceMappingURL=chunk-ZECQ2LQB.js.map
|