@blamechris/repo-memory 0.12.0 → 0.13.0
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/cache/generation.d.ts +50 -0
- package/dist/cache/generation.d.ts.map +1 -0
- package/dist/cache/generation.js +62 -0
- package/dist/cache/generation.js.map +1 -0
- package/dist/cache/invalidation.d.ts +3 -1
- package/dist/cache/invalidation.d.ts.map +1 -1
- package/dist/cache/invalidation.js +4 -5
- package/dist/cache/invalidation.js.map +1 -1
- package/dist/cache/ranking.d.ts +51 -6
- package/dist/cache/ranking.d.ts.map +1 -1
- package/dist/cache/ranking.js +92 -18
- package/dist/cache/ranking.js.map +1 -1
- package/dist/cache/store.d.ts +32 -0
- package/dist/cache/store.d.ts.map +1 -1
- package/dist/cache/store.js +110 -19
- package/dist/cache/store.js.map +1 -1
- package/dist/graph/dependency-graph.d.ts +14 -0
- package/dist/graph/dependency-graph.d.ts.map +1 -1
- package/dist/graph/dependency-graph.js +70 -5
- package/dist/graph/dependency-graph.js.map +1 -1
- package/dist/graph/refresh.d.ts +21 -0
- package/dist/graph/refresh.d.ts.map +1 -0
- package/dist/graph/refresh.js +101 -0
- package/dist/graph/refresh.js.map +1 -0
- package/dist/indexer/imports.d.ts.map +1 -1
- package/dist/indexer/imports.js +152 -86
- package/dist/indexer/imports.js.map +1 -1
- package/dist/indexer/project-map.d.ts +0 -2
- package/dist/indexer/project-map.d.ts.map +1 -1
- package/dist/indexer/project-map.js +0 -3
- package/dist/indexer/project-map.js.map +1 -1
- package/dist/indexer/source-extensions.d.ts +10 -0
- package/dist/indexer/source-extensions.d.ts.map +1 -0
- package/dist/indexer/source-extensions.js +28 -0
- package/dist/indexer/source-extensions.js.map +1 -0
- package/dist/indexer/summarize.d.ts +16 -1
- package/dist/indexer/summarize.d.ts.map +1 -1
- package/dist/indexer/summarize.js +38 -23
- package/dist/indexer/summarize.js.map +1 -1
- package/dist/persistence/db.d.ts.map +1 -1
- package/dist/persistence/db.js +78 -13
- package/dist/persistence/db.js.map +1 -1
- package/dist/server.js +18 -11
- package/dist/server.js.map +1 -1
- package/dist/tools/batch-file-summaries.d.ts +0 -1
- package/dist/tools/batch-file-summaries.d.ts.map +1 -1
- package/dist/tools/batch-file-summaries.js +1 -1
- package/dist/tools/batch-file-summaries.js.map +1 -1
- package/dist/tools/force-reread.d.ts.map +1 -1
- package/dist/tools/force-reread.js +7 -0
- package/dist/tools/force-reread.js.map +1 -1
- package/dist/tools/get-changed-files.d.ts.map +1 -1
- package/dist/tools/get-changed-files.js +23 -5
- package/dist/tools/get-changed-files.js.map +1 -1
- package/dist/tools/get-dependency-graph.d.ts +9 -7
- package/dist/tools/get-dependency-graph.d.ts.map +1 -1
- package/dist/tools/get-dependency-graph.js +51 -74
- package/dist/tools/get-dependency-graph.js.map +1 -1
- package/dist/tools/get-file-summary.d.ts +2 -3
- package/dist/tools/get-file-summary.d.ts.map +1 -1
- package/dist/tools/get-file-summary.js +11 -19
- package/dist/tools/get-file-summary.js.map +1 -1
- package/dist/tools/get-project-map.d.ts.map +1 -1
- package/dist/tools/get-project-map.js +9 -1
- package/dist/tools/get-project-map.js.map +1 -1
- package/dist/tools/get-related-files.d.ts.map +1 -1
- package/dist/tools/get-related-files.js +19 -71
- package/dist/tools/get-related-files.js.map +1 -1
- package/dist/tools/search-by-purpose.d.ts +2 -3
- package/dist/tools/search-by-purpose.d.ts.map +1 -1
- package/dist/tools/search-by-purpose.js +103 -44
- package/dist/tools/search-by-purpose.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Summarizer generation bookkeeping, shared by the cache store and the
|
|
3
|
+
* indexer. This lives below both layers so `CacheStore` can enforce the
|
|
4
|
+
* generation rules on summary writes without importing the indexer (which
|
|
5
|
+
* itself imports the store).
|
|
6
|
+
*
|
|
7
|
+
* The generation tag stored in the meta table has the form `<mode>:<N>`
|
|
8
|
+
* (e.g. `ast:3`). Two rules govern it:
|
|
9
|
+
*
|
|
10
|
+
* - **Numeric monotonicity.** The numeric generation `N` may only increase.
|
|
11
|
+
* A process running an older package version than the one that last tagged
|
|
12
|
+
* the database must never clear summaries, never write summaries, and never
|
|
13
|
+
* regress the tag. Real workflows hit this: a long-running MCP server and an
|
|
14
|
+
* `npx` post-merge hook can share one cache at different package versions.
|
|
15
|
+
* - **Mode is last-writer-wins.** A mode difference (regex vs ast) at the same
|
|
16
|
+
* `N` means per-process configuration disagrees, which is a user
|
|
17
|
+
* misconfiguration; flipping the mode legitimately clears and re-tags, so
|
|
18
|
+
* the monotonicity rule applies to the numeric generation only.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Bump when summary output changes in a way that should invalidate previously
|
|
22
|
+
* cached summaries (combined with the mode into the generation tag).
|
|
23
|
+
*
|
|
24
|
+
* Generation 2: the AST summarizer gained Python/Go/Rust support, so summaries
|
|
25
|
+
* for those languages cached under ast mode (which were regex-produced
|
|
26
|
+
* fallbacks at generation 1) must lazily regenerate.
|
|
27
|
+
*
|
|
28
|
+
* Generation 3: the AST summarizer gained Kotlin/Java support, so summaries
|
|
29
|
+
* for those languages cached under ast mode (regex-produced generic
|
|
30
|
+
* classifications at earlier generations) must lazily regenerate.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SUMMARIZER_GENERATION = 3;
|
|
33
|
+
/** Meta table key holding the generation tag (`<mode>:<N>`). */
|
|
34
|
+
export declare const GENERATION_META_KEY = "summarizer_generation";
|
|
35
|
+
/** Test hook: pretend this process runs a different package generation. */
|
|
36
|
+
export declare function setSummarizerGenerationForTests(generation: number | null): void;
|
|
37
|
+
/** The summarizer generation this process writes. */
|
|
38
|
+
export declare function currentSummarizerGeneration(): number;
|
|
39
|
+
/** Parse a stored `<mode>:<N>` tag. Returns null for missing or unparseable tags. */
|
|
40
|
+
export declare function parseGenerationTag(tag: string | null): {
|
|
41
|
+
mode: string;
|
|
42
|
+
generation: number;
|
|
43
|
+
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* True when the stored tag was written by a strictly newer generation than
|
|
46
|
+
* this process — in which case this process must not persist summaries or
|
|
47
|
+
* touch the tag (see module doc).
|
|
48
|
+
*/
|
|
49
|
+
export declare function isStoredGenerationNewer(storedTag: string | null): boolean;
|
|
50
|
+
//# sourceMappingURL=generation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation.d.ts","sourceRoot":"","sources":["../../src/cache/generation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,gEAAgE;AAChE,eAAO,MAAM,mBAAmB,0BAA0B,CAAC;AAI3D,2EAA2E;AAC3E,wBAAgB,+BAA+B,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAE/E;AAED,qDAAqD;AACrD,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,IAAI,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAK7C;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAGzE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Summarizer generation bookkeeping, shared by the cache store and the
|
|
3
|
+
* indexer. This lives below both layers so `CacheStore` can enforce the
|
|
4
|
+
* generation rules on summary writes without importing the indexer (which
|
|
5
|
+
* itself imports the store).
|
|
6
|
+
*
|
|
7
|
+
* The generation tag stored in the meta table has the form `<mode>:<N>`
|
|
8
|
+
* (e.g. `ast:3`). Two rules govern it:
|
|
9
|
+
*
|
|
10
|
+
* - **Numeric monotonicity.** The numeric generation `N` may only increase.
|
|
11
|
+
* A process running an older package version than the one that last tagged
|
|
12
|
+
* the database must never clear summaries, never write summaries, and never
|
|
13
|
+
* regress the tag. Real workflows hit this: a long-running MCP server and an
|
|
14
|
+
* `npx` post-merge hook can share one cache at different package versions.
|
|
15
|
+
* - **Mode is last-writer-wins.** A mode difference (regex vs ast) at the same
|
|
16
|
+
* `N` means per-process configuration disagrees, which is a user
|
|
17
|
+
* misconfiguration; flipping the mode legitimately clears and re-tags, so
|
|
18
|
+
* the monotonicity rule applies to the numeric generation only.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Bump when summary output changes in a way that should invalidate previously
|
|
22
|
+
* cached summaries (combined with the mode into the generation tag).
|
|
23
|
+
*
|
|
24
|
+
* Generation 2: the AST summarizer gained Python/Go/Rust support, so summaries
|
|
25
|
+
* for those languages cached under ast mode (which were regex-produced
|
|
26
|
+
* fallbacks at generation 1) must lazily regenerate.
|
|
27
|
+
*
|
|
28
|
+
* Generation 3: the AST summarizer gained Kotlin/Java support, so summaries
|
|
29
|
+
* for those languages cached under ast mode (regex-produced generic
|
|
30
|
+
* classifications at earlier generations) must lazily regenerate.
|
|
31
|
+
*/
|
|
32
|
+
export const SUMMARIZER_GENERATION = 3;
|
|
33
|
+
/** Meta table key holding the generation tag (`<mode>:<N>`). */
|
|
34
|
+
export const GENERATION_META_KEY = 'summarizer_generation';
|
|
35
|
+
let generationOverride = null;
|
|
36
|
+
/** Test hook: pretend this process runs a different package generation. */
|
|
37
|
+
export function setSummarizerGenerationForTests(generation) {
|
|
38
|
+
generationOverride = generation;
|
|
39
|
+
}
|
|
40
|
+
/** The summarizer generation this process writes. */
|
|
41
|
+
export function currentSummarizerGeneration() {
|
|
42
|
+
return generationOverride ?? SUMMARIZER_GENERATION;
|
|
43
|
+
}
|
|
44
|
+
/** Parse a stored `<mode>:<N>` tag. Returns null for missing or unparseable tags. */
|
|
45
|
+
export function parseGenerationTag(tag) {
|
|
46
|
+
if (tag === null)
|
|
47
|
+
return null;
|
|
48
|
+
const match = /^([a-z]+):(\d+)$/.exec(tag);
|
|
49
|
+
if (!match)
|
|
50
|
+
return null;
|
|
51
|
+
return { mode: match[1], generation: Number(match[2]) };
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* True when the stored tag was written by a strictly newer generation than
|
|
55
|
+
* this process — in which case this process must not persist summaries or
|
|
56
|
+
* touch the tag (see module doc).
|
|
57
|
+
*/
|
|
58
|
+
export function isStoredGenerationNewer(storedTag) {
|
|
59
|
+
const parsed = parseGenerationTag(storedTag);
|
|
60
|
+
return parsed !== null && parsed.generation > currentSummarizerGeneration();
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=generation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generation.js","sourceRoot":"","sources":["../../src/cache/generation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,gEAAgE;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAE3D,IAAI,kBAAkB,GAAkB,IAAI,CAAC;AAE7C,2EAA2E;AAC3E,MAAM,UAAU,+BAA+B,CAAC,UAAyB;IACvE,kBAAkB,GAAG,UAAU,CAAC;AAClC,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,2BAA2B;IACzC,OAAO,kBAAkB,IAAI,qBAAqB,CAAC;AACrD,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,kBAAkB,CAChC,GAAkB;IAElB,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC9B,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAwB;IAC9D,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC7C,OAAO,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,UAAU,GAAG,2BAA2B,EAAE,CAAC;AAC9E,CAAC"}
|
|
@@ -16,7 +16,9 @@ export declare class CacheInvalidator {
|
|
|
16
16
|
*/
|
|
17
17
|
invalidate(relativePath: string): void;
|
|
18
18
|
/**
|
|
19
|
-
* Delete all cache entries
|
|
19
|
+
* Delete all cache entries in one atomic statement — entries written by a
|
|
20
|
+
* concurrent process cannot slip through the way they could with a
|
|
21
|
+
* snapshot-then-delete loop.
|
|
20
22
|
*/
|
|
21
23
|
invalidateAll(): void;
|
|
22
24
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalidation.d.ts","sourceRoot":"","sources":["../../src/cache/invalidation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;gBAEvB,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IAKlD;;;OAGG;IACG,aAAa,CACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAe1D;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAItC
|
|
1
|
+
{"version":3,"file":"invalidation.d.ts","sourceRoot":"","sources":["../../src/cache/invalidation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;gBAEvB,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU;IAKlD;;;OAGG;IACG,aAAa,CACjB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAe1D;;OAEG;IACH,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI;IAItC;;;;OAIG;IACH,aAAa,IAAI,IAAI;IAIrB;;;;OAIG;IACG,gBAAgB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAelE"}
|
|
@@ -29,13 +29,12 @@ export class CacheInvalidator {
|
|
|
29
29
|
this.store.deleteEntry(relativePath);
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
|
-
* Delete all cache entries
|
|
32
|
+
* Delete all cache entries in one atomic statement — entries written by a
|
|
33
|
+
* concurrent process cannot slip through the way they could with a
|
|
34
|
+
* snapshot-then-delete loop.
|
|
33
35
|
*/
|
|
34
36
|
invalidateAll() {
|
|
35
|
-
|
|
36
|
-
for (const entry of entries) {
|
|
37
|
-
this.store.deleteEntry(entry.path);
|
|
38
|
-
}
|
|
37
|
+
this.store.deleteAllEntries();
|
|
39
38
|
}
|
|
40
39
|
/**
|
|
41
40
|
* Given a list of relative paths, return those whose current hash
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalidation.js","sourceRoot":"","sources":["../../src/cache/invalidation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAG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,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YAEhD,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,KAAK,IAAI,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACzE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
package/dist/cache/ranking.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { DependencyGraph } from '../graph/dependency-graph.js';
|
|
2
2
|
import type { CacheStore } from './store.js';
|
|
3
3
|
export interface RankingSignals {
|
|
4
|
+
relationship: number;
|
|
4
5
|
dependencyProximity: number;
|
|
5
6
|
recency: number;
|
|
6
7
|
fileTypeRelevance: number;
|
|
7
8
|
taskContextRelevance: number;
|
|
8
|
-
|
|
9
|
+
centrality: number;
|
|
9
10
|
}
|
|
10
11
|
export interface RankingWeights {
|
|
12
|
+
relationship: number;
|
|
11
13
|
dependencyProximity: number;
|
|
12
14
|
recency: number;
|
|
13
15
|
fileTypeRelevance: number;
|
|
14
16
|
taskContextRelevance: number;
|
|
15
|
-
|
|
17
|
+
centrality: number;
|
|
16
18
|
}
|
|
17
19
|
export interface RankedFile {
|
|
18
20
|
path: string;
|
|
@@ -26,23 +28,66 @@ export interface RankingOptions {
|
|
|
26
28
|
flaggedFiles?: string[];
|
|
27
29
|
graph?: DependencyGraph;
|
|
28
30
|
cacheStore?: CacheStore;
|
|
31
|
+
/**
|
|
32
|
+
* The file the caller asked about. Used as a proximity anchor so
|
|
33
|
+
* dependencyProximity works even without task-explored files.
|
|
34
|
+
*/
|
|
35
|
+
queryFile?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Pre-classified relationship of each candidate to the query file
|
|
38
|
+
* (e.g. 'imports', 'imported-by', 'transitive-dependency', 'same-directory').
|
|
39
|
+
* Candidates absent from the map get a relationship score of 0.
|
|
40
|
+
*/
|
|
41
|
+
relationships?: ReadonlyMap<string, string>;
|
|
29
42
|
limit?: number;
|
|
30
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Default signal weights (sum to 1.0 so composite scores stay in [0, 1]).
|
|
46
|
+
*
|
|
47
|
+
* Rationale:
|
|
48
|
+
* - relationship (0.30): the strongest evidence available — *why* the
|
|
49
|
+
* candidate is in the result set. Direct imports/dependents beat
|
|
50
|
+
* transitive links beat same-directory bystanders.
|
|
51
|
+
* - dependencyProximity (0.25): hop distance in the import graph from the
|
|
52
|
+
* query file (and from task-explored files when a task is active).
|
|
53
|
+
* Reinforces relationship and differentiates within the transitive bucket.
|
|
54
|
+
* - recency (0.15): files indexed/seen recently in this session are more
|
|
55
|
+
* likely part of the current working set (4-hour half-life decay).
|
|
56
|
+
* - taskContextRelevance (0.15): directory adjacency to the active task's
|
|
57
|
+
* explored/flagged files; constant when no task is active.
|
|
58
|
+
* - fileTypeRelevance (0.10): mild prior for source over config over tests.
|
|
59
|
+
* - centrality (0.05): log-scaled degree centrality — a deliberate
|
|
60
|
+
* tiebreaker so hub files edge out leaf files when structural signals
|
|
61
|
+
* tie, without importance ever outranking a direct relationship.
|
|
62
|
+
*/
|
|
31
63
|
export declare const DEFAULT_WEIGHTS: RankingWeights;
|
|
32
64
|
/** Score file type relevance: source=1.0, config=0.5, test=0.3, other=0.2 */
|
|
33
65
|
export declare function computeFileTypeRelevance(filePath: string): number;
|
|
34
66
|
/**
|
|
35
67
|
* Exponential decay based on how recently the file was checked.
|
|
36
68
|
* Files checked in the last hour get ~1.0, files checked days ago get ~0.0.
|
|
37
|
-
* Uses a half-life of 4 hours.
|
|
69
|
+
* Uses a half-life of 4 hours. Age is quantized to whole minutes so scores
|
|
70
|
+
* are deterministic across back-to-back calls (sub-minute age differences
|
|
71
|
+
* are noise at a 4-hour half-life).
|
|
38
72
|
*/
|
|
39
73
|
export declare function computeRecency(lastChecked: number, now?: number): number;
|
|
74
|
+
/** Score the candidate's classified relationship to the query file. */
|
|
75
|
+
export declare function computeRelationshipScore(relationship: string | undefined): number;
|
|
76
|
+
/**
|
|
77
|
+
* Log-scaled degree centrality relative to the most-connected candidate.
|
|
78
|
+
* Returns 0 when the file has no connections or no maximum is known, 1.0
|
|
79
|
+
* for the best-connected candidate. Log scaling compresses the range so a
|
|
80
|
+
* 50-edge hub does not score 50x a 1-edge leaf — it is a tiebreaker prior,
|
|
81
|
+
* not a dominator.
|
|
82
|
+
*/
|
|
83
|
+
export declare function computeCentrality(degree: number, maxDegree: number): number;
|
|
40
84
|
/**
|
|
41
|
-
* Score based on distance in the dependency graph from
|
|
85
|
+
* Score based on distance in the dependency graph from anchor files (the
|
|
86
|
+
* query file and/or task-explored files).
|
|
42
87
|
* 1.0 if directly connected, 0.5 if 2 hops away, decaying by 1/2^(distance-1).
|
|
43
|
-
* Returns 0 if no graph or no
|
|
88
|
+
* Returns 0 if no graph or no anchor files.
|
|
44
89
|
*/
|
|
45
|
-
export declare function computeDependencyProximity(filePath: string,
|
|
90
|
+
export declare function computeDependencyProximity(filePath: string, anchorFiles: string[], graph: DependencyGraph): number;
|
|
46
91
|
/**
|
|
47
92
|
* Score based on directory proximity to flagged and explored files.
|
|
48
93
|
* 1.0 if in same directory as flagged files, 0.7 if in same directory as explored files,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ranking.d.ts","sourceRoot":"","sources":["../../src/cache/ranking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,
|
|
1
|
+
{"version":3,"file":"ranking.d.ts","sourceRo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6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAoBjE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAUxE;AAED,uEAAuE;AACvE,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAGjF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAG3E;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EAAE,EACrB,KAAK,EAAE,eAAe,GACrB,MAAM,CA0CR;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,EACvB,YAAY,EAAE,MAAM,EAAE,GACrB,MAAM,CA+BR;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,cAAc,GAAG,UAAU,EAAE,CAkFhF"}
|
package/dist/cache/ranking.js
CHANGED
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import { dirname } from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Default signal weights (sum to 1.0 so composite scores stay in [0, 1]).
|
|
4
|
+
*
|
|
5
|
+
* Rationale:
|
|
6
|
+
* - relationship (0.30): the strongest evidence available — *why* the
|
|
7
|
+
* candidate is in the result set. Direct imports/dependents beat
|
|
8
|
+
* transitive links beat same-directory bystanders.
|
|
9
|
+
* - dependencyProximity (0.25): hop distance in the import graph from the
|
|
10
|
+
* query file (and from task-explored files when a task is active).
|
|
11
|
+
* Reinforces relationship and differentiates within the transitive bucket.
|
|
12
|
+
* - recency (0.15): files indexed/seen recently in this session are more
|
|
13
|
+
* likely part of the current working set (4-hour half-life decay).
|
|
14
|
+
* - taskContextRelevance (0.15): directory adjacency to the active task's
|
|
15
|
+
* explored/flagged files; constant when no task is active.
|
|
16
|
+
* - fileTypeRelevance (0.10): mild prior for source over config over tests.
|
|
17
|
+
* - centrality (0.05): log-scaled degree centrality — a deliberate
|
|
18
|
+
* tiebreaker so hub files edge out leaf files when structural signals
|
|
19
|
+
* tie, without importance ever outranking a direct relationship.
|
|
20
|
+
*/
|
|
2
21
|
export const DEFAULT_WEIGHTS = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
22
|
+
relationship: 0.3,
|
|
23
|
+
dependencyProximity: 0.25,
|
|
24
|
+
recency: 0.15,
|
|
25
|
+
fileTypeRelevance: 0.1,
|
|
26
|
+
taskContextRelevance: 0.15,
|
|
27
|
+
centrality: 0.05,
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Relationship-type ordering: direct edges (imports/imported-by) are the
|
|
31
|
+
* strongest relevance evidence, transitive links weaker, directory
|
|
32
|
+
* neighbors weakest. Unknown/unclassified relationships score 0.
|
|
33
|
+
*/
|
|
34
|
+
const RELATIONSHIP_SCORES = {
|
|
35
|
+
'imports': 1.0,
|
|
36
|
+
'imported-by': 1.0,
|
|
37
|
+
'transitive-dependency': 0.5,
|
|
38
|
+
'same-directory': 0.25,
|
|
8
39
|
};
|
|
9
40
|
const SOURCE_EXTENSIONS = new Set(['.ts', '.js', '.tsx', '.jsx']);
|
|
10
41
|
const CONFIG_BASENAMES = new Set([
|
|
@@ -56,26 +87,49 @@ export function computeFileTypeRelevance(filePath) {
|
|
|
56
87
|
/**
|
|
57
88
|
* Exponential decay based on how recently the file was checked.
|
|
58
89
|
* Files checked in the last hour get ~1.0, files checked days ago get ~0.0.
|
|
59
|
-
* Uses a half-life of 4 hours.
|
|
90
|
+
* Uses a half-life of 4 hours. Age is quantized to whole minutes so scores
|
|
91
|
+
* are deterministic across back-to-back calls (sub-minute age differences
|
|
92
|
+
* are noise at a 4-hour half-life).
|
|
60
93
|
*/
|
|
61
94
|
export function computeRecency(lastChecked, now) {
|
|
62
95
|
const currentTime = now ?? Date.now();
|
|
63
96
|
const ageMs = currentTime - lastChecked;
|
|
64
97
|
if (ageMs <= 0)
|
|
65
98
|
return 1.0;
|
|
99
|
+
const MINUTE_MS = 60 * 1000;
|
|
66
100
|
const HALF_LIFE_MS = 4 * 60 * 60 * 1000; // 4 hours
|
|
67
|
-
|
|
101
|
+
const quantizedAgeMs = Math.floor(ageMs / MINUTE_MS) * MINUTE_MS;
|
|
102
|
+
return Math.pow(2, -quantizedAgeMs / HALF_LIFE_MS);
|
|
103
|
+
}
|
|
104
|
+
/** Score the candidate's classified relationship to the query file. */
|
|
105
|
+
export function computeRelationshipScore(relationship) {
|
|
106
|
+
if (!relationship)
|
|
107
|
+
return 0;
|
|
108
|
+
return RELATIONSHIP_SCORES[relationship] ?? 0;
|
|
68
109
|
}
|
|
69
110
|
/**
|
|
70
|
-
*
|
|
111
|
+
* Log-scaled degree centrality relative to the most-connected candidate.
|
|
112
|
+
* Returns 0 when the file has no connections or no maximum is known, 1.0
|
|
113
|
+
* for the best-connected candidate. Log scaling compresses the range so a
|
|
114
|
+
* 50-edge hub does not score 50x a 1-edge leaf — it is a tiebreaker prior,
|
|
115
|
+
* not a dominator.
|
|
116
|
+
*/
|
|
117
|
+
export function computeCentrality(degree, maxDegree) {
|
|
118
|
+
if (degree <= 0 || maxDegree <= 0)
|
|
119
|
+
return 0;
|
|
120
|
+
return Math.log1p(degree) / Math.log1p(maxDegree);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Score based on distance in the dependency graph from anchor files (the
|
|
124
|
+
* query file and/or task-explored files).
|
|
71
125
|
* 1.0 if directly connected, 0.5 if 2 hops away, decaying by 1/2^(distance-1).
|
|
72
|
-
* Returns 0 if no graph or no
|
|
126
|
+
* Returns 0 if no graph or no anchor files.
|
|
73
127
|
*/
|
|
74
|
-
export function computeDependencyProximity(filePath,
|
|
75
|
-
if (
|
|
128
|
+
export function computeDependencyProximity(filePath, anchorFiles, graph) {
|
|
129
|
+
if (anchorFiles.length === 0)
|
|
76
130
|
return 0;
|
|
77
131
|
let bestScore = 0;
|
|
78
|
-
for (const explored of
|
|
132
|
+
for (const explored of anchorFiles) {
|
|
79
133
|
// Check direct connection (1 hop)
|
|
80
134
|
const deps = graph.getDependencies(explored);
|
|
81
135
|
const dependents = graph.getDependents(explored);
|
|
@@ -151,6 +205,24 @@ export function rankFiles(files, options) {
|
|
|
151
205
|
const exploredFiles = options.exploredFiles ?? [];
|
|
152
206
|
const flaggedFiles = options.flaggedFiles ?? [];
|
|
153
207
|
const now = Date.now();
|
|
208
|
+
// Proximity anchors: the query file (so the signal works without a task)
|
|
209
|
+
// plus any task-explored files.
|
|
210
|
+
const anchorFiles = options.queryFile
|
|
211
|
+
? [options.queryFile, ...exploredFiles]
|
|
212
|
+
: exploredFiles;
|
|
213
|
+
// Degree centrality, normalized against the best-connected candidate so
|
|
214
|
+
// the signal is relative to the result set being ranked.
|
|
215
|
+
const degrees = new Map();
|
|
216
|
+
let maxDegree = 0;
|
|
217
|
+
if (options.graph) {
|
|
218
|
+
for (const filePath of files) {
|
|
219
|
+
const degree = options.graph.getDependencies(filePath).length +
|
|
220
|
+
options.graph.getDependents(filePath).length;
|
|
221
|
+
degrees.set(filePath, degree);
|
|
222
|
+
if (degree > maxDegree)
|
|
223
|
+
maxDegree = degree;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
154
226
|
const results = files.map((filePath) => {
|
|
155
227
|
const fileTypeRelevance = computeFileTypeRelevance(filePath);
|
|
156
228
|
let recency = 0.5; // default if no cache store
|
|
@@ -162,23 +234,25 @@ export function rankFiles(files, options) {
|
|
|
162
234
|
}
|
|
163
235
|
let dependencyProximity = 0;
|
|
164
236
|
if (options.graph) {
|
|
165
|
-
dependencyProximity = computeDependencyProximity(filePath,
|
|
237
|
+
dependencyProximity = computeDependencyProximity(filePath, anchorFiles, options.graph);
|
|
166
238
|
}
|
|
167
239
|
const taskContextRelevance = computeTaskContextRelevance(filePath, exploredFiles, flaggedFiles);
|
|
168
|
-
|
|
169
|
-
const
|
|
240
|
+
const relationship = computeRelationshipScore(options.relationships?.get(filePath));
|
|
241
|
+
const centrality = computeCentrality(degrees.get(filePath) ?? 0, maxDegree);
|
|
170
242
|
const signals = {
|
|
243
|
+
relationship,
|
|
171
244
|
dependencyProximity,
|
|
172
245
|
recency,
|
|
173
246
|
fileTypeRelevance,
|
|
174
247
|
taskContextRelevance,
|
|
175
|
-
|
|
248
|
+
centrality,
|
|
176
249
|
};
|
|
177
|
-
const score = signals.
|
|
250
|
+
const score = signals.relationship * weights.relationship +
|
|
251
|
+
signals.dependencyProximity * weights.dependencyProximity +
|
|
178
252
|
signals.recency * weights.recency +
|
|
179
253
|
signals.fileTypeRelevance * weights.fileTypeRelevance +
|
|
180
254
|
signals.taskContextRelevance * weights.taskContextRelevance +
|
|
181
|
-
signals.
|
|
255
|
+
signals.centrality * weights.centrality;
|
|
182
256
|
return { path: filePath, score, signals };
|
|
183
257
|
});
|
|
184
258
|
results.sort((a, b) => b.score - a.score);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ranking.js","sourceRoot":"","sources":["../../src/cache/ranking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ranking.js","sourceRoot":"","sources":["../../src/cache/ranking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAiD/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmB;IAC7C,YAAY,EAAE,GAAG;IACjB,mBAAmB,EAAE,IAAI;IACzB,OAAO,EAAE,IAAI;IACb,iBAAiB,EAAE,GAAG;IACtB,oBAAoB,EAAE,IAAI;IAC1B,UAAU,E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EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC3C,IAAI,QAAQ,KAAK,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
|
package/dist/cache/store.d.ts
CHANGED
|
@@ -5,12 +5,28 @@ export declare class CacheStore {
|
|
|
5
5
|
getEntry(path: string): CacheEntry | null;
|
|
6
6
|
setEntry(path: string, hash: string, summary: FileSummary | null): void;
|
|
7
7
|
getAllEntries(): CacheEntry[];
|
|
8
|
+
/**
|
|
9
|
+
* Remove a cache entry and the dependency-graph edges extracted from it, in
|
|
10
|
+
* one transaction. Edges derive from the file's contents, so they share the
|
|
11
|
+
* entry's lifetime — leaving them behind would serve stale graph data until
|
|
12
|
+
* the next GC pass. (Incoming edges from other files are left alone: those
|
|
13
|
+
* files' contents still declare the import.)
|
|
14
|
+
*/
|
|
8
15
|
deleteEntry(path: string): void;
|
|
16
|
+
/** Refresh last_checked for an entry without altering its hash or summary. */
|
|
17
|
+
touchEntry(path: string): void;
|
|
9
18
|
setEntries(entries: Array<{
|
|
10
19
|
path: string;
|
|
11
20
|
hash: string;
|
|
12
21
|
summary?: FileSummary | null;
|
|
13
22
|
}>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the stored generation tag belongs to a strictly newer package
|
|
25
|
+
* generation than this process, in which case summary writes from this
|
|
26
|
+
* process must not be persisted (Guardian I3). Must be called while the
|
|
27
|
+
* write lock is held so the answer cannot change before the write lands.
|
|
28
|
+
*/
|
|
29
|
+
private summaryWritesBlocked;
|
|
14
30
|
/** Read a value from the meta key/value table. */
|
|
15
31
|
getMeta(key: string): string | null;
|
|
16
32
|
/** Write a value to the meta key/value table. */
|
|
@@ -21,6 +37,22 @@ export declare class CacheStore {
|
|
|
21
37
|
* summaries regenerate lazily on next access.
|
|
22
38
|
*/
|
|
23
39
|
clearAllSummaries(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Atomically drop all summaries and write a meta value in one IMMEDIATE
|
|
42
|
+
* transaction (Guardian I4). Used for generation bumps: no other process
|
|
43
|
+
* can insert an old-generation summary between the clear and the tag write,
|
|
44
|
+
* and a crash between the two is unobservable.
|
|
45
|
+
*/
|
|
46
|
+
clearAllSummariesAndSetMeta(key: string, value: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Run `fn` while holding the database write lock (BEGIN IMMEDIATE). Use for
|
|
49
|
+
* read-decide-write sequences that must not interleave with writes from
|
|
50
|
+
* other processes. Nested store calls that open their own transactions
|
|
51
|
+
* collapse into savepoints inside this one.
|
|
52
|
+
*/
|
|
53
|
+
withWriteLock<T>(fn: () => T): T;
|
|
54
|
+
/** Delete every cache entry in a single atomic statement. */
|
|
55
|
+
deleteAllEntries(): void;
|
|
24
56
|
getStaleEntries(maxAge: number): CacheEntry[];
|
|
25
57
|
}
|
|
26
58
|
//# sourceMappingURL=store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/cache/store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/cache/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAuC3D,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,WAAW,C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