causantic 0.9.4 → 0.10.1
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 +70 -56
- package/dist/cli/skill-templates.d.ts.map +1 -1
- package/dist/cli/skill-templates.js +11 -8
- package/dist/cli/skill-templates.js.map +1 -1
- package/dist/clusters/cluster-manager.d.ts +16 -0
- package/dist/clusters/cluster-manager.d.ts.map +1 -1
- package/dist/clusters/cluster-manager.js +119 -1
- package/dist/clusters/cluster-manager.js.map +1 -1
- package/dist/config/loader.d.ts +16 -0
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +51 -0
- package/dist/config/loader.js.map +1 -1
- package/dist/config/memory-config.d.ts +26 -0
- package/dist/config/memory-config.d.ts.map +1 -1
- package/dist/config/memory-config.js +40 -0
- package/dist/config/memory-config.js.map +1 -1
- package/dist/eval/experiments/embedding-model-comparison/run-experiment.d.ts +20 -0
- package/dist/eval/experiments/embedding-model-comparison/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/embedding-model-comparison/run-experiment.js +289 -0
- package/dist/eval/experiments/embedding-model-comparison/run-experiment.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/alignment-analysis.d.ts +53 -0
- package/dist/eval/experiments/index-differentiation/alignment-analysis.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/alignment-analysis.js +85 -0
- package/dist/eval/experiments/index-differentiation/alignment-analysis.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/discrimination-test.d.ts +24 -0
- package/dist/eval/experiments/index-differentiation/discrimination-test.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/discrimination-test.js +79 -0
- package/dist/eval/experiments/index-differentiation/discrimination-test.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/index.d.ts +11 -0
- package/dist/eval/experiments/index-differentiation/index.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/index.js +8 -0
- package/dist/eval/experiments/index-differentiation/index.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/refinement-test.d.ts +32 -0
- package/dist/eval/experiments/index-differentiation/refinement-test.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/refinement-test.js +201 -0
- package/dist/eval/experiments/index-differentiation/refinement-test.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/run-experiment.d.ts +20 -0
- package/dist/eval/experiments/index-differentiation/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/run-experiment.js +336 -0
- package/dist/eval/experiments/index-differentiation/run-experiment.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/similarity-analysis.d.ts +31 -0
- package/dist/eval/experiments/index-differentiation/similarity-analysis.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/similarity-analysis.js +60 -0
- package/dist/eval/experiments/index-differentiation/similarity-analysis.js.map +1 -0
- package/dist/eval/experiments/index-differentiation/types.d.ts +114 -0
- package/dist/eval/experiments/index-differentiation/types.d.ts.map +1 -0
- package/dist/eval/experiments/index-differentiation/types.js +8 -0
- package/dist/eval/experiments/index-differentiation/types.js.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-experiment.d.ts +19 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-experiment.js +326 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-experiment.js.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-generator.d.ts +27 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-generator.d.ts.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-generator.js +154 -0
- package/dist/eval/experiments/index-vs-chunk/jeopardy-generator.js.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/query-generator.d.ts +23 -0
- package/dist/eval/experiments/index-vs-chunk/query-generator.d.ts.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/query-generator.js +113 -0
- package/dist/eval/experiments/index-vs-chunk/query-generator.js.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/run-experiment.d.ts +17 -0
- package/dist/eval/experiments/index-vs-chunk/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/run-experiment.js +331 -0
- package/dist/eval/experiments/index-vs-chunk/run-experiment.js.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/types.d.ts +71 -0
- package/dist/eval/experiments/index-vs-chunk/types.d.ts.map +1 -0
- package/dist/eval/experiments/index-vs-chunk/types.js +8 -0
- package/dist/eval/experiments/index-vs-chunk/types.js.map +1 -0
- package/dist/eval/experiments/pipeline-dropout/run-experiment.d.ts +18 -0
- package/dist/eval/experiments/pipeline-dropout/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/pipeline-dropout/run-experiment.js +355 -0
- package/dist/eval/experiments/pipeline-dropout/run-experiment.js.map +1 -0
- package/dist/eval/experiments/rescorer-ceiling/analyze-misses.d.ts +17 -0
- package/dist/eval/experiments/rescorer-ceiling/analyze-misses.d.ts.map +1 -0
- package/dist/eval/experiments/rescorer-ceiling/analyze-misses.js +247 -0
- package/dist/eval/experiments/rescorer-ceiling/analyze-misses.js.map +1 -0
- package/dist/eval/experiments/rescorer-ceiling/benchmark-rescorers.d.ts +18 -0
- package/dist/eval/experiments/rescorer-ceiling/benchmark-rescorers.d.ts.map +1 -0
- package/dist/eval/experiments/rescorer-ceiling/benchmark-rescorers.js +457 -0
- package/dist/eval/experiments/rescorer-ceiling/benchmark-rescorers.js.map +1 -0
- package/dist/eval/experiments/rescorer-ceiling/run-experiment.d.ts +16 -0
- package/dist/eval/experiments/rescorer-ceiling/run-experiment.d.ts.map +1 -0
- package/dist/eval/experiments/rescorer-ceiling/run-experiment.js +226 -0
- package/dist/eval/experiments/rescorer-ceiling/run-experiment.js.map +1 -0
- package/dist/index-entries/index-generator.d.ts +74 -0
- package/dist/index-entries/index-generator.d.ts.map +1 -0
- package/dist/index-entries/index-generator.js +321 -0
- package/dist/index-entries/index-generator.js.map +1 -0
- package/dist/index-entries/index-refresher.d.ts +54 -0
- package/dist/index-entries/index-refresher.d.ts.map +1 -0
- package/dist/index-entries/index-refresher.js +203 -0
- package/dist/index-entries/index-refresher.js.map +1 -0
- package/dist/index-entries/index.d.ts +6 -0
- package/dist/index-entries/index.d.ts.map +1 -0
- package/dist/index-entries/index.js +6 -0
- package/dist/index-entries/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/ingest/entity-extractor.d.ts +23 -0
- package/dist/ingest/entity-extractor.d.ts.map +1 -0
- package/dist/ingest/entity-extractor.js +233 -0
- package/dist/ingest/entity-extractor.js.map +1 -0
- package/dist/ingest/index-entry-hook.d.ts +15 -0
- package/dist/ingest/index-entry-hook.d.ts.map +1 -0
- package/dist/ingest/index-entry-hook.js +84 -0
- package/dist/ingest/index-entry-hook.js.map +1 -0
- package/dist/ingest/ingest-session.d.ts.map +1 -1
- package/dist/ingest/ingest-session.js +89 -17
- package/dist/ingest/ingest-session.js.map +1 -1
- package/dist/ingest/session-state.d.ts +49 -0
- package/dist/ingest/session-state.d.ts.map +1 -0
- package/dist/ingest/session-state.js +146 -0
- package/dist/ingest/session-state.js.map +1 -0
- package/dist/maintenance/scheduler.d.ts.map +1 -1
- package/dist/maintenance/scheduler.js +25 -0
- package/dist/maintenance/scheduler.js.map +1 -1
- package/dist/maintenance/tasks/backfill-index.d.ts +27 -0
- package/dist/maintenance/tasks/backfill-index.d.ts.map +1 -0
- package/dist/maintenance/tasks/backfill-index.js +44 -0
- package/dist/maintenance/tasks/backfill-index.js.map +1 -0
- package/dist/mcp/services.d.ts.map +1 -1
- package/dist/mcp/services.js +9 -0
- package/dist/mcp/services.js.map +1 -1
- package/dist/mcp/tools.d.ts +4 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +113 -7
- package/dist/mcp/tools.js.map +1 -1
- package/dist/models/embedder.js +2 -2
- package/dist/models/embedder.js.map +1 -1
- package/dist/models/model-registry.d.ts +2 -0
- package/dist/models/model-registry.d.ts.map +1 -1
- package/dist/models/model-registry.js +15 -0
- package/dist/models/model-registry.js.map +1 -1
- package/dist/repomap/cache.d.ts +58 -0
- package/dist/repomap/cache.d.ts.map +1 -0
- package/dist/repomap/cache.js +101 -0
- package/dist/repomap/cache.js.map +1 -0
- package/dist/repomap/graph.d.ts +54 -0
- package/dist/repomap/graph.d.ts.map +1 -0
- package/dist/repomap/graph.js +113 -0
- package/dist/repomap/graph.js.map +1 -0
- package/dist/repomap/index.d.ts +83 -0
- package/dist/repomap/index.d.ts.map +1 -0
- package/dist/repomap/index.js +99 -0
- package/dist/repomap/index.js.map +1 -0
- package/dist/repomap/parser.d.ts +43 -0
- package/dist/repomap/parser.d.ts.map +1 -0
- package/dist/repomap/parser.js +1043 -0
- package/dist/repomap/parser.js.map +1 -0
- package/dist/repomap/regex-parser.d.ts +24 -0
- package/dist/repomap/regex-parser.d.ts.map +1 -0
- package/dist/repomap/regex-parser.js +214 -0
- package/dist/repomap/regex-parser.js.map +1 -0
- package/dist/repomap/renderer.d.ts +40 -0
- package/dist/repomap/renderer.d.ts.map +1 -0
- package/dist/repomap/renderer.js +163 -0
- package/dist/repomap/renderer.js.map +1 -0
- package/dist/repomap/scanner.d.ts +32 -0
- package/dist/repomap/scanner.d.ts.map +1 -0
- package/dist/repomap/scanner.js +190 -0
- package/dist/repomap/scanner.js.map +1 -0
- package/dist/retrieval/chain-assembler.d.ts.map +1 -1
- package/dist/retrieval/chain-assembler.js +22 -3
- package/dist/retrieval/chain-assembler.js.map +1 -1
- package/dist/retrieval/context-assembler.d.ts +1 -1
- package/dist/retrieval/context-assembler.d.ts.map +1 -1
- package/dist/retrieval/index.d.ts +2 -0
- package/dist/retrieval/index.d.ts.map +1 -1
- package/dist/retrieval/index.js +2 -0
- package/dist/retrieval/index.js.map +1 -1
- package/dist/retrieval/mmr.d.ts +1 -0
- package/dist/retrieval/mmr.d.ts.map +1 -1
- package/dist/retrieval/mmr.js +35 -1
- package/dist/retrieval/mmr.js.map +1 -1
- package/dist/retrieval/rrf.d.ts +1 -1
- package/dist/retrieval/rrf.d.ts.map +1 -1
- package/dist/retrieval/rrf.js +1 -1
- package/dist/retrieval/rrf.js.map +1 -1
- package/dist/retrieval/search-assembler.d.ts +11 -2
- package/dist/retrieval/search-assembler.d.ts.map +1 -1
- package/dist/retrieval/search-assembler.js +305 -81
- package/dist/retrieval/search-assembler.js.map +1 -1
- package/dist/retrieval/session-reconstructor.d.ts +36 -0
- package/dist/retrieval/session-reconstructor.d.ts.map +1 -1
- package/dist/retrieval/session-reconstructor.js +128 -0
- package/dist/retrieval/session-reconstructor.js.map +1 -1
- package/dist/storage/db.d.ts.map +1 -1
- package/dist/storage/db.js +24 -0
- package/dist/storage/db.js.map +1 -1
- package/dist/storage/entity-store.d.ts +48 -0
- package/dist/storage/entity-store.d.ts.map +1 -0
- package/dist/storage/entity-store.js +111 -0
- package/dist/storage/entity-store.js.map +1 -0
- package/dist/storage/index-entry-store.d.ts +71 -0
- package/dist/storage/index-entry-store.d.ts.map +1 -0
- package/dist/storage/index-entry-store.js +277 -0
- package/dist/storage/index-entry-store.js.map +1 -0
- package/dist/storage/index.d.ts +5 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +5 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/migrations.d.ts.map +1 -1
- package/dist/storage/migrations.js +147 -0
- package/dist/storage/migrations.js.map +1 -1
- package/dist/storage/schema.sql +104 -2
- package/dist/storage/session-state-store.d.ts +61 -0
- package/dist/storage/session-state-store.d.ts.map +1 -0
- package/dist/storage/session-state-store.js +157 -0
- package/dist/storage/session-state-store.js.map +1 -0
- package/dist/storage/types.d.ts +50 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/vector-store.d.ts +17 -2
- package/dist/storage/vector-store.d.ts.map +1 -1
- package/dist/storage/vector-store.js +104 -36
- package/dist/storage/vector-store.js.map +1 -1
- package/package.json +4 -2
|
@@ -7,16 +7,29 @@ export const MODEL_REGISTRY = {
|
|
|
7
7
|
hfId: 'nomic-ai/nomic-embed-text-v1.5',
|
|
8
8
|
dims: 768,
|
|
9
9
|
contextTokens: 8192,
|
|
10
|
+
pooling: 'mean',
|
|
10
11
|
usesPrefix: true,
|
|
11
12
|
documentPrefix: 'search_document: ',
|
|
12
13
|
queryPrefix: 'search_query: ',
|
|
13
14
|
notes: 'Matryoshka dimensions (768/512/384/256/128). Needs task prefixes.',
|
|
14
15
|
},
|
|
16
|
+
'arctic-embed-m': {
|
|
17
|
+
id: 'arctic-embed-m',
|
|
18
|
+
hfId: 'Snowflake/snowflake-arctic-embed-m-v1.5',
|
|
19
|
+
dims: 768,
|
|
20
|
+
contextTokens: 512,
|
|
21
|
+
pooling: 'cls',
|
|
22
|
+
usesPrefix: true,
|
|
23
|
+
documentPrefix: '',
|
|
24
|
+
queryPrefix: 'Represent this sentence for searching relevant passages: ',
|
|
25
|
+
notes: 'BertModel, CLS pooling. Matryoshka (768/256). MTEB retrieval 55.1. 512 token context.',
|
|
26
|
+
},
|
|
15
27
|
'jina-code': {
|
|
16
28
|
id: 'jina-code',
|
|
17
29
|
hfId: 'jinaai/jina-embeddings-v2-base-code',
|
|
18
30
|
dims: 768,
|
|
19
31
|
contextTokens: 8192,
|
|
32
|
+
pooling: 'mean',
|
|
20
33
|
usesPrefix: false,
|
|
21
34
|
documentPrefix: '',
|
|
22
35
|
queryPrefix: '',
|
|
@@ -27,6 +40,7 @@ export const MODEL_REGISTRY = {
|
|
|
27
40
|
hfId: 'Xenova/jina-embeddings-v2-small-en',
|
|
28
41
|
dims: 512,
|
|
29
42
|
contextTokens: 8192,
|
|
43
|
+
pooling: 'mean',
|
|
30
44
|
usesPrefix: false,
|
|
31
45
|
documentPrefix: '',
|
|
32
46
|
queryPrefix: '',
|
|
@@ -37,6 +51,7 @@ export const MODEL_REGISTRY = {
|
|
|
37
51
|
hfId: 'Xenova/bge-small-en-v1.5',
|
|
38
52
|
dims: 384,
|
|
39
53
|
contextTokens: 512,
|
|
54
|
+
pooling: 'cls',
|
|
40
55
|
usesPrefix: false,
|
|
41
56
|
documentPrefix: '',
|
|
42
57
|
queryPrefix: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/models/model-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/models/model-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAuBH,MAAM,CAAC,MAAM,cAAc,GAAgC;IACzD,YAAY,EAAE;QACZ,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,gCAAgC;QACtC,IAAI,EAAE,GAAG;QACT,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,MAAM;QAEf,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,gBAAgB;QAC7B,KAAK,EAAE,mEAAmE;KAC3E;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,yCAAyC;QAC/C,IAAI,EAAE,GAAG;QACT,aAAa,EAAE,GAAG;QAClB,OAAO,EAAE,KAAK;QAEd,UAAU,EAAE,IAAI;QAChB,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,2DAA2D;QACxE,KAAK,EAAE,uFAAuF;KAC/F;IACD,WAAW,EAAE;QACX,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,qCAAqC;QAC3C,IAAI,EAAE,GAAG;QACT,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,MAAM;QAEf,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,uDAAuD;KAC/D;IACD,YAAY,EAAE;QACZ,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,oCAAoC;QAC1C,IAAI,EAAE,GAAG;QACT,aAAa,EAAE,IAAI;QACnB,OAAO,EAAE,MAAM;QAEf,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,4BAA4B;KACpC;IACD,WAAW,EAAE;QACX,EAAE,EAAE,WAAW;QACf,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,GAAG;QACT,aAAa,EAAE,GAAG;QAClB,OAAO,EAAE,KAAK;QAEd,UAAU,EAAE,KAAK;QACjB,cAAc,EAAE,EAAE;QAClB,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,oDAAoD;KAC5D;CACF,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,EAAU;IACjC,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,gBAAgB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-level cache for parsed tags.
|
|
3
|
+
*
|
|
4
|
+
* Stores parsed tags per file, keyed by file path + mtime.
|
|
5
|
+
* When a file's mtime changes, only that file is re-parsed.
|
|
6
|
+
* When the file list changes (new/deleted files), the file list hash
|
|
7
|
+
* is invalidated and a full rescan is triggered.
|
|
8
|
+
*/
|
|
9
|
+
import type { Tag } from './parser.js';
|
|
10
|
+
import type { ScannedFile } from './scanner.js';
|
|
11
|
+
/** In-memory tag cache for a project. */
|
|
12
|
+
export declare class TagCache {
|
|
13
|
+
/** Cache keyed by relative file path → cached tags. */
|
|
14
|
+
private fileCache;
|
|
15
|
+
/** Hash of the file list for staleness detection. */
|
|
16
|
+
private fileListHash;
|
|
17
|
+
/**
|
|
18
|
+
* Compute a hash of the file list (just paths, sorted).
|
|
19
|
+
* Used to detect when files are added or removed.
|
|
20
|
+
*/
|
|
21
|
+
private computeFileListHash;
|
|
22
|
+
/**
|
|
23
|
+
* Get cached tags for files that haven't changed.
|
|
24
|
+
* Returns which files need re-parsing.
|
|
25
|
+
*
|
|
26
|
+
* @param files - Current list of scanned files
|
|
27
|
+
* @returns Object with cached tags and files needing re-parse
|
|
28
|
+
*/
|
|
29
|
+
resolve(files: ScannedFile[]): {
|
|
30
|
+
/** Tags from cache (file hasn't changed). */
|
|
31
|
+
cached: Map<string, Tag[]>;
|
|
32
|
+
/** Files that need re-parsing (new or modified). */
|
|
33
|
+
stale: ScannedFile[];
|
|
34
|
+
/** Whether the file list itself changed (files added/removed). */
|
|
35
|
+
fileListChanged: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Update the cache with newly parsed tags.
|
|
39
|
+
*/
|
|
40
|
+
update(file: ScannedFile, tags: Tag[]): void;
|
|
41
|
+
/**
|
|
42
|
+
* Get total number of cached files.
|
|
43
|
+
*/
|
|
44
|
+
get size(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Clear the entire cache.
|
|
47
|
+
*/
|
|
48
|
+
clear(): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get or create a cache for a project.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getProjectCache(projectPath: string): TagCache;
|
|
54
|
+
/**
|
|
55
|
+
* Clear all project caches.
|
|
56
|
+
*/
|
|
57
|
+
export declare function clearAllCaches(): void;
|
|
58
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/repomap/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAUhD,yCAAyC;AACzC,qBAAa,QAAQ;IACnB,uDAAuD;IACvD,OAAO,CAAC,SAAS,CAAqC;IACtD,qDAAqD;IACrD,OAAO,CAAC,YAAY,CAAc;IAElC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAK3B;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG;QAC7B,6CAA6C;QAC7C,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3B,oDAAoD;QACpD,KAAK,EAAE,WAAW,EAAE,CAAC;QACrB,kEAAkE;QAClE,eAAe,EAAE,OAAO,CAAC;KAC1B;IAiCD;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAO5C;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;CAId;AAKD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,CAO7D;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-level cache for parsed tags.
|
|
3
|
+
*
|
|
4
|
+
* Stores parsed tags per file, keyed by file path + mtime.
|
|
5
|
+
* When a file's mtime changes, only that file is re-parsed.
|
|
6
|
+
* When the file list changes (new/deleted files), the file list hash
|
|
7
|
+
* is invalidated and a full rescan is triggered.
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from 'crypto';
|
|
10
|
+
/** In-memory tag cache for a project. */
|
|
11
|
+
export class TagCache {
|
|
12
|
+
/** Cache keyed by relative file path → cached tags. */
|
|
13
|
+
fileCache = new Map();
|
|
14
|
+
/** Hash of the file list for staleness detection. */
|
|
15
|
+
fileListHash = '';
|
|
16
|
+
/**
|
|
17
|
+
* Compute a hash of the file list (just paths, sorted).
|
|
18
|
+
* Used to detect when files are added or removed.
|
|
19
|
+
*/
|
|
20
|
+
computeFileListHash(files) {
|
|
21
|
+
const paths = files.map((f) => f.relativePath).join('\n');
|
|
22
|
+
return createHash('md5').update(paths).digest('hex');
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get cached tags for files that haven't changed.
|
|
26
|
+
* Returns which files need re-parsing.
|
|
27
|
+
*
|
|
28
|
+
* @param files - Current list of scanned files
|
|
29
|
+
* @returns Object with cached tags and files needing re-parse
|
|
30
|
+
*/
|
|
31
|
+
resolve(files) {
|
|
32
|
+
const newHash = this.computeFileListHash(files);
|
|
33
|
+
const fileListChanged = newHash !== this.fileListHash;
|
|
34
|
+
if (fileListChanged) {
|
|
35
|
+
// File list changed — keep per-file cache entries that still exist,
|
|
36
|
+
// but mark the list as changed so the graph is rebuilt
|
|
37
|
+
this.fileListHash = newHash;
|
|
38
|
+
// Remove entries for files no longer in the list
|
|
39
|
+
const currentPaths = new Set(files.map((f) => f.relativePath));
|
|
40
|
+
for (const path of this.fileCache.keys()) {
|
|
41
|
+
if (!currentPaths.has(path)) {
|
|
42
|
+
this.fileCache.delete(path);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const cached = new Map();
|
|
47
|
+
const stale = [];
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
const entry = this.fileCache.get(file.relativePath);
|
|
50
|
+
if (entry && entry.mtimeMs === file.mtimeMs) {
|
|
51
|
+
cached.set(file.relativePath, entry.tags);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
stale.push(file);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { cached, stale, fileListChanged };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Update the cache with newly parsed tags.
|
|
61
|
+
*/
|
|
62
|
+
update(file, tags) {
|
|
63
|
+
this.fileCache.set(file.relativePath, {
|
|
64
|
+
mtimeMs: file.mtimeMs,
|
|
65
|
+
tags,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get total number of cached files.
|
|
70
|
+
*/
|
|
71
|
+
get size() {
|
|
72
|
+
return this.fileCache.size;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Clear the entire cache.
|
|
76
|
+
*/
|
|
77
|
+
clear() {
|
|
78
|
+
this.fileCache.clear();
|
|
79
|
+
this.fileListHash = '';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** Global cache instances per project path. */
|
|
83
|
+
const projectCaches = new Map();
|
|
84
|
+
/**
|
|
85
|
+
* Get or create a cache for a project.
|
|
86
|
+
*/
|
|
87
|
+
export function getProjectCache(projectPath) {
|
|
88
|
+
let cache = projectCaches.get(projectPath);
|
|
89
|
+
if (!cache) {
|
|
90
|
+
cache = new TagCache();
|
|
91
|
+
projectCaches.set(projectPath, cache);
|
|
92
|
+
}
|
|
93
|
+
return cache;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Clear all project caches.
|
|
97
|
+
*/
|
|
98
|
+
export function clearAllCaches() {
|
|
99
|
+
projectCaches.clear();
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/repomap/cache.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAYpC,yCAAyC;AACzC,MAAM,OAAO,QAAQ;IACnB,uDAAuD;IAC/C,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IACtD,qDAAqD;IAC7C,YAAY,GAAW,EAAE,CAAC;IAElC;;;OAGG;IACK,mBAAmB,CAAC,KAAoB;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C,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAiB,EAAE,IAAW;QACnC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE;YACpC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;CACF;AAED,+CAA+C;AAC/C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,IAAI,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,IAAI,QAAQ,EAAE,CAAC;QACvB,aAAa,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,aAAa,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File dependency graph construction and importance ranking.
|
|
3
|
+
*
|
|
4
|
+
* Builds a graph where files are nodes and cross-file references are edges.
|
|
5
|
+
* Ranks files by importance using degree-weighted scoring.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tag } from './parser.js';
|
|
8
|
+
/** A node in the dependency graph (one per file). */
|
|
9
|
+
export interface FileNode {
|
|
10
|
+
/** Relative file path. */
|
|
11
|
+
path: string;
|
|
12
|
+
/** Definitions in this file. */
|
|
13
|
+
definitions: Tag[];
|
|
14
|
+
/** All tags (definitions + references). */
|
|
15
|
+
tags: Tag[];
|
|
16
|
+
/** Importance score (higher = more important). */
|
|
17
|
+
score: number;
|
|
18
|
+
}
|
|
19
|
+
/** An edge in the dependency graph. */
|
|
20
|
+
export interface FileEdge {
|
|
21
|
+
/** File that references a symbol. */
|
|
22
|
+
from: string;
|
|
23
|
+
/** File that defines the symbol. */
|
|
24
|
+
to: string;
|
|
25
|
+
/** Total weight of this edge. */
|
|
26
|
+
weight: number;
|
|
27
|
+
/** Symbol names that create this link. */
|
|
28
|
+
symbols: string[];
|
|
29
|
+
}
|
|
30
|
+
/** The complete dependency graph. */
|
|
31
|
+
export interface DependencyGraph {
|
|
32
|
+
/** All file nodes, keyed by relative path. */
|
|
33
|
+
nodes: Map<string, FileNode>;
|
|
34
|
+
/** All edges between files. */
|
|
35
|
+
edges: FileEdge[];
|
|
36
|
+
/** Files ranked by importance (descending). */
|
|
37
|
+
rankedFiles: FileNode[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a dependency graph from parsed tags.
|
|
41
|
+
*
|
|
42
|
+
* @param tagsByFile - Map from relative file path to tags extracted from that file
|
|
43
|
+
* @returns The complete dependency graph with importance ranking
|
|
44
|
+
*/
|
|
45
|
+
export declare function buildGraph(tagsByFile: Map<string, Tag[]>): DependencyGraph;
|
|
46
|
+
/**
|
|
47
|
+
* Get the most important definitions across all files,
|
|
48
|
+
* respecting file ranking order.
|
|
49
|
+
*
|
|
50
|
+
* Returns definitions from the most important files first,
|
|
51
|
+
* with definitions within each file ordered by type priority.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getRankedDefinitions(graph: DependencyGraph): Tag[];
|
|
54
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/repomap/graph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,qDAAqD;AACrD,MAAM,WAAW,QAAQ;IACvB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,2CAA2C;IAC3C,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uCAAuC;AACvC,MAAM,WAAW,QAAQ;IACvB,qCAAqC;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,qCAAqC;AACrC,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC7B,+BAA+B;IAC/B,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,+CAA+C;IAC/C,WAAW,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,CA+E1E;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,EAAE,CA2BlE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File dependency graph construction and importance ranking.
|
|
3
|
+
*
|
|
4
|
+
* Builds a graph where files are nodes and cross-file references are edges.
|
|
5
|
+
* Ranks files by importance using degree-weighted scoring.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Build a dependency graph from parsed tags.
|
|
9
|
+
*
|
|
10
|
+
* @param tagsByFile - Map from relative file path to tags extracted from that file
|
|
11
|
+
* @returns The complete dependency graph with importance ranking
|
|
12
|
+
*/
|
|
13
|
+
export function buildGraph(tagsByFile) {
|
|
14
|
+
// Build index of definitions: symbol name → file paths
|
|
15
|
+
const definitionIndex = new Map();
|
|
16
|
+
const nodes = new Map();
|
|
17
|
+
for (const [filePath, tags] of tagsByFile) {
|
|
18
|
+
const definitions = tags.filter((t) => t.kind === 'def');
|
|
19
|
+
nodes.set(filePath, {
|
|
20
|
+
path: filePath,
|
|
21
|
+
definitions,
|
|
22
|
+
tags,
|
|
23
|
+
score: 0,
|
|
24
|
+
});
|
|
25
|
+
for (const def of definitions) {
|
|
26
|
+
const files = definitionIndex.get(def.name) ?? new Set();
|
|
27
|
+
files.add(filePath);
|
|
28
|
+
definitionIndex.set(def.name, files);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// Build edges: file A references a symbol defined in file B
|
|
32
|
+
const edgeMap = new Map();
|
|
33
|
+
for (const [filePath, tags] of tagsByFile) {
|
|
34
|
+
const references = tags.filter((t) => t.kind === 'ref');
|
|
35
|
+
for (const ref of references) {
|
|
36
|
+
const defFiles = definitionIndex.get(ref.name);
|
|
37
|
+
if (!defFiles)
|
|
38
|
+
continue;
|
|
39
|
+
for (const defFile of defFiles) {
|
|
40
|
+
if (defFile === filePath)
|
|
41
|
+
continue; // Skip self-references
|
|
42
|
+
const edgeKey = `${filePath}→${defFile}`;
|
|
43
|
+
const existing = edgeMap.get(edgeKey);
|
|
44
|
+
// Weight bonus for specific identifier names (longer names = more specific)
|
|
45
|
+
const nameWeight = Math.max(1, Math.log2(ref.name.length));
|
|
46
|
+
if (existing) {
|
|
47
|
+
existing.weight += nameWeight;
|
|
48
|
+
existing.symbols.add(ref.name);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
edgeMap.set(edgeKey, {
|
|
52
|
+
weight: nameWeight,
|
|
53
|
+
symbols: new Set([ref.name]),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const edges = [];
|
|
60
|
+
for (const [key, { weight, symbols }] of edgeMap) {
|
|
61
|
+
const [from, to] = key.split('→');
|
|
62
|
+
edges.push({ from, to, weight, symbols: [...symbols] });
|
|
63
|
+
}
|
|
64
|
+
// Compute importance: sum of weighted in-edges (files that are referenced most)
|
|
65
|
+
for (const edge of edges) {
|
|
66
|
+
const targetNode = nodes.get(edge.to);
|
|
67
|
+
if (targetNode) {
|
|
68
|
+
targetNode.score += edge.weight;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Also give a small base score based on definition count
|
|
72
|
+
// (files with many definitions are structurally important even if not referenced)
|
|
73
|
+
for (const node of nodes.values()) {
|
|
74
|
+
node.score += node.definitions.length * 0.1;
|
|
75
|
+
}
|
|
76
|
+
// Rank by score descending
|
|
77
|
+
const rankedFiles = [...nodes.values()].sort((a, b) => b.score - a.score);
|
|
78
|
+
return { nodes, edges, rankedFiles };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get the most important definitions across all files,
|
|
82
|
+
* respecting file ranking order.
|
|
83
|
+
*
|
|
84
|
+
* Returns definitions from the most important files first,
|
|
85
|
+
* with definitions within each file ordered by type priority.
|
|
86
|
+
*/
|
|
87
|
+
export function getRankedDefinitions(graph) {
|
|
88
|
+
const typePriority = {
|
|
89
|
+
class: 0,
|
|
90
|
+
interface: 1,
|
|
91
|
+
type: 2,
|
|
92
|
+
enum: 3,
|
|
93
|
+
function: 4,
|
|
94
|
+
variable: 5,
|
|
95
|
+
method: 6,
|
|
96
|
+
export: 7,
|
|
97
|
+
import: 8,
|
|
98
|
+
identifier: 9,
|
|
99
|
+
};
|
|
100
|
+
const result = [];
|
|
101
|
+
for (const node of graph.rankedFiles) {
|
|
102
|
+
const sorted = [...node.definitions].sort((a, b) => {
|
|
103
|
+
const pa = typePriority[a.type] ?? 99;
|
|
104
|
+
const pb = typePriority[b.type] ?? 99;
|
|
105
|
+
if (pa !== pb)
|
|
106
|
+
return pa - pb;
|
|
107
|
+
return a.line - b.line;
|
|
108
|
+
});
|
|
109
|
+
result.push(...sorted);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/repomap/graph.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAsCH;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,UAA8B;IACvD,uDAAuD;IACvD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEvD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAoB,CAAC;IAE1C,KAAK,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,UAAU,EAAE,CAAC;QAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;QAEzD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE;YAClB,IAAI,EAAE,QAAQ;YACd,WAAW;YACX,IAAI;YACJ,KAAK,EAAE,CAAC;SACT,CAAC,CAAC;QAEH,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;YACzD,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACpB,eAAe,CAAC,GAAG,CAAC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QACZ,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,CAAC;QACP,QAAQ,EAAE,CAAC;QACX,QAAQ,EAAE,CAAC;QACX,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,CAAC;QACT,MAAM,EAAE,CAAC;QACT,UAAU,EAAE,CAAC;KACd,CAAC;IAEF,MAAM,MAAM,GAAU,EAAE,CAAC;IAEzB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACjD,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACtC,MAAM,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACtC,IAAI,EAAE,KAAK,EAAE;gBAAE,OAAO,EAAE,GAAG,EAAE,CAAC;YAC9B,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;QACzB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo Map: structural codebase summary.
|
|
3
|
+
*
|
|
4
|
+
* Provides a compact overview of a project's structure — files, definitions,
|
|
5
|
+
* and cross-file relationships — within a token budget. Designed to give
|
|
6
|
+
* Claude Code the structural context it needs without reading individual files.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const map = await buildRepoMap('/path/to/project', { maxTokens: 1024 });
|
|
11
|
+
* console.log(map.text); // Compact structural summary
|
|
12
|
+
* console.log(map.fileCount); // Number of files scanned
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
import { type DependencyGraph } from './graph.js';
|
|
18
|
+
export type { Tag } from './parser.js';
|
|
19
|
+
export type { DependencyGraph, FileNode, FileEdge } from './graph.js';
|
|
20
|
+
export type { ScannedFile, ScanOptions } from './scanner.js';
|
|
21
|
+
export type { RenderOptions } from './renderer.js';
|
|
22
|
+
export { scanProject } from './scanner.js';
|
|
23
|
+
export { parseFile, isSupportedExtension, getLanguageForExtension } from './parser.js';
|
|
24
|
+
export { parseFileRegex, isRegexSupportedExtension } from './regex-parser.js';
|
|
25
|
+
export { buildGraph, getRankedDefinitions } from './graph.js';
|
|
26
|
+
export { renderMap, renderMinimalSummary } from './renderer.js';
|
|
27
|
+
export { getProjectCache, clearAllCaches, TagCache } from './cache.js';
|
|
28
|
+
/** Options for building a repo map. */
|
|
29
|
+
export interface RepoMapOptions {
|
|
30
|
+
/** Maximum tokens for the output. Default: 1024. */
|
|
31
|
+
maxTokens?: number;
|
|
32
|
+
/** Files to boost to the top of the output. */
|
|
33
|
+
focusFiles?: string[];
|
|
34
|
+
/** Additional extensions to include. */
|
|
35
|
+
extraExtensions?: string[];
|
|
36
|
+
/** Additional directories to skip. */
|
|
37
|
+
skipDirs?: string[];
|
|
38
|
+
/** Whether to show line numbers. Default: true. */
|
|
39
|
+
showLineNumbers?: boolean;
|
|
40
|
+
/** Maximum files to scan. Default: 10000. */
|
|
41
|
+
maxFiles?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Result of building a repo map. */
|
|
44
|
+
export interface RepoMapResult {
|
|
45
|
+
/** The rendered text map. */
|
|
46
|
+
text: string;
|
|
47
|
+
/** Number of source files found. */
|
|
48
|
+
fileCount: number;
|
|
49
|
+
/** Number of definitions extracted. */
|
|
50
|
+
definitionCount: number;
|
|
51
|
+
/** Number of cross-file edges. */
|
|
52
|
+
edgeCount: number;
|
|
53
|
+
/** Number of files that were re-parsed (cache misses). */
|
|
54
|
+
parsedCount: number;
|
|
55
|
+
/** Duration in milliseconds. */
|
|
56
|
+
durationMs: number;
|
|
57
|
+
/** The dependency graph (for programmatic access). */
|
|
58
|
+
graph: DependencyGraph;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Build a structural repo map for a project.
|
|
62
|
+
*
|
|
63
|
+
* Pipeline:
|
|
64
|
+
* 1. Scan directory for source files (filtered by gitignore)
|
|
65
|
+
* 2. Parse files with tree-sitter (cached by mtime)
|
|
66
|
+
* 3. Build dependency graph (files → edges → importance ranking)
|
|
67
|
+
* 4. Render ranked definitions within token budget
|
|
68
|
+
*
|
|
69
|
+
* @param projectPath - Absolute path to the project root
|
|
70
|
+
* @param options - Configuration options
|
|
71
|
+
* @returns Repo map result with text and metadata
|
|
72
|
+
*/
|
|
73
|
+
export declare function buildRepoMap(projectPath: string, options?: RepoMapOptions): Promise<RepoMapResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Look up which file defines a given symbol name.
|
|
76
|
+
* Returns the file path and line number, or null if not found.
|
|
77
|
+
*/
|
|
78
|
+
export declare function findSymbol(graph: DependencyGraph, symbolName: string): {
|
|
79
|
+
file: string;
|
|
80
|
+
line: number;
|
|
81
|
+
type: string;
|
|
82
|
+
} | null;
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repomap/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAc,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAI9D,YAAY,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACvC,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,W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mDxB;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,MAAM,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASrD"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo Map: structural codebase summary.
|
|
3
|
+
*
|
|
4
|
+
* Provides a compact overview of a project's structure — files, definitions,
|
|
5
|
+
* and cross-file relationships — within a token budget. Designed to give
|
|
6
|
+
* Claude Code the structural context it needs without reading individual files.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const map = await buildRepoMap('/path/to/project', { maxTokens: 1024 });
|
|
11
|
+
* console.log(map.text); // Compact structural summary
|
|
12
|
+
* console.log(map.fileCount); // Number of files scanned
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @packageDocumentation
|
|
16
|
+
*/
|
|
17
|
+
import { scanProject } from './scanner.js';
|
|
18
|
+
import { parseFile } from './parser.js';
|
|
19
|
+
import { buildGraph } from './graph.js';
|
|
20
|
+
import { renderMap } from './renderer.js';
|
|
21
|
+
import { getProjectCache } from './cache.js';
|
|
22
|
+
export { scanProject } from './scanner.js';
|
|
23
|
+
export { parseFile, isSupportedExtension, getLanguageForExtension } from './parser.js';
|
|
24
|
+
export { parseFileRegex, isRegexSupportedExtension } from './regex-parser.js';
|
|
25
|
+
export { buildGraph, getRankedDefinitions } from './graph.js';
|
|
26
|
+
export { renderMap, renderMinimalSummary } from './renderer.js';
|
|
27
|
+
export { getProjectCache, clearAllCaches, TagCache } from './cache.js';
|
|
28
|
+
/**
|
|
29
|
+
* Build a structural repo map for a project.
|
|
30
|
+
*
|
|
31
|
+
* Pipeline:
|
|
32
|
+
* 1. Scan directory for source files (filtered by gitignore)
|
|
33
|
+
* 2. Parse files with tree-sitter (cached by mtime)
|
|
34
|
+
* 3. Build dependency graph (files → edges → importance ranking)
|
|
35
|
+
* 4. Render ranked definitions within token budget
|
|
36
|
+
*
|
|
37
|
+
* @param projectPath - Absolute path to the project root
|
|
38
|
+
* @param options - Configuration options
|
|
39
|
+
* @returns Repo map result with text and metadata
|
|
40
|
+
*/
|
|
41
|
+
export async function buildRepoMap(projectPath, options = {}) {
|
|
42
|
+
const start = performance.now();
|
|
43
|
+
// 1. Scan
|
|
44
|
+
const scanOptions = {
|
|
45
|
+
extraExtensions: options.extraExtensions,
|
|
46
|
+
skipDirs: options.skipDirs,
|
|
47
|
+
maxFiles: options.maxFiles,
|
|
48
|
+
};
|
|
49
|
+
const files = scanProject(projectPath, scanOptions);
|
|
50
|
+
// 2. Parse (with caching)
|
|
51
|
+
const cache = getProjectCache(projectPath);
|
|
52
|
+
const { cached, stale } = cache.resolve(files);
|
|
53
|
+
// Parse stale files
|
|
54
|
+
const tagsByFile = new Map(cached);
|
|
55
|
+
for (const file of stale) {
|
|
56
|
+
const tags = await parseFile(file.absolutePath, file.relativePath);
|
|
57
|
+
tagsByFile.set(file.relativePath, tags);
|
|
58
|
+
cache.update(file, tags);
|
|
59
|
+
}
|
|
60
|
+
// 3. Build graph
|
|
61
|
+
const graph = buildGraph(tagsByFile);
|
|
62
|
+
// 4. Render
|
|
63
|
+
const renderOptions = {
|
|
64
|
+
maxTokens: options.maxTokens ?? 1024,
|
|
65
|
+
focusFiles: options.focusFiles,
|
|
66
|
+
showLineNumbers: options.showLineNumbers,
|
|
67
|
+
};
|
|
68
|
+
const text = renderMap(graph, renderOptions);
|
|
69
|
+
const durationMs = performance.now() - start;
|
|
70
|
+
// Count definitions
|
|
71
|
+
let definitionCount = 0;
|
|
72
|
+
for (const node of graph.nodes.values()) {
|
|
73
|
+
definitionCount += node.definitions.length;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
text,
|
|
77
|
+
fileCount: files.length,
|
|
78
|
+
definitionCount,
|
|
79
|
+
edgeCount: graph.edges.length,
|
|
80
|
+
parsedCount: stale.length,
|
|
81
|
+
durationMs,
|
|
82
|
+
graph,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Look up which file defines a given symbol name.
|
|
87
|
+
* Returns the file path and line number, or null if not found.
|
|
88
|
+
*/
|
|
89
|
+
export function findSymbol(graph, symbolName) {
|
|
90
|
+
for (const node of graph.rankedFiles) {
|
|
91
|
+
for (const def of node.definitions) {
|
|
92
|
+
if (def.name === symbolName) {
|
|
93
|
+
return { file: def.file, line: def.line, type: def.type };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/repomap/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,WAAW,EAAoB,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAY,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,UAAU,EAAwB,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAsB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAM7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,QAAQ,EAAE,M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AE7C,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAE7C,oBAAoB;IACpB,IAAI,eAAe,GAAG,CAAC,CAAC;IACxB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACxC,eAAe,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,MAAM;QACvB,eAAe;QACf,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM;QAC7B,WAAW,EAAE,KAAK,CAAC,MAAM;QACzB,UAAU;QACV,KAAK;KACN,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB,EACtB,UAAkB;IAElB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnC,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC5B,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC;YAC5D,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-sitter AST parser for extracting definitions and references.
|
|
3
|
+
*
|
|
4
|
+
* Uses web-tree-sitter (WASM) to parse source files and extract:
|
|
5
|
+
* - Definitions: classes, functions, methods, interfaces, type aliases, exports
|
|
6
|
+
* - References: imports, identifiers used in code
|
|
7
|
+
*
|
|
8
|
+
* Supported languages: TypeScript, JavaScript, Python, Java, C, C++,
|
|
9
|
+
* Rust, Go, Ruby, C#, PHP, Bash (tree-sitter).
|
|
10
|
+
* Fallback regex parsing: Scala, Kotlin, Swift, Haskell, Lua, Dart,
|
|
11
|
+
* Zig, Elixir, Perl, R.
|
|
12
|
+
*/
|
|
13
|
+
/** A tag extracted from a source file. */
|
|
14
|
+
export interface Tag {
|
|
15
|
+
/** The symbol name (e.g., 'MyClass', 'myFunction'). */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Whether this is a definition or reference. */
|
|
18
|
+
kind: 'def' | 'ref';
|
|
19
|
+
/** Line number (1-based). */
|
|
20
|
+
line: number;
|
|
21
|
+
/** The file this tag belongs to (relative path). */
|
|
22
|
+
file: string;
|
|
23
|
+
/** Specific type of definition/reference. */
|
|
24
|
+
type: 'class' | 'function' | 'method' | 'interface' | 'type' | 'enum' | 'variable' | 'export' | 'import' | 'identifier';
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parse a source file and extract tags (definitions + references).
|
|
28
|
+
*
|
|
29
|
+
* @param filePath - Absolute path to the source file
|
|
30
|
+
* @param relativePath - Relative path for tag metadata
|
|
31
|
+
* @returns Array of tags extracted from the file
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseFile(filePath: string, relativePath: string): Promise<Tag[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Get the language name for a file extension.
|
|
36
|
+
* Checks tree-sitter languages first, then regex-based fallback languages.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getLanguageForExtension(ext: string): string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a file extension is supported (tree-sitter or regex fallback).
|
|
41
|
+
*/
|
|
42
|
+
export declare function isSupportedExtension(ext: string): boolean;
|
|
43
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/repomap/parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAcH,0CAA0C;AAC1C,MAAM,WAAW,GAAG;IAClB,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,IAAI,EACA,OAAO,GACP,UAAU,GACV,QAAQ,GACR,WAAW,GACX,MAAM,GACN,MAAM,GACN,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,YAAY,CAAC;CAClB;AA4gBD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAqStF;AAmSD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|