squeze-cli 2.2.1 → 3.0.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/CHANGELOG.md +24 -0
- package/README.md +81 -21
- package/dist/cli.cjs +185 -62
- package/dist/extension.cjs +825 -113
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/GRAPH.md +1 -1
- package/docs/SCALE_EVALUATION.md +19 -1
- package/docs/STANDARD.md +27 -0
- package/media/explorer.css +317 -0
- package/media/explorer.js +869 -0
- package/package.json +23 -2
package/dist/cli.cjs
CHANGED
|
@@ -14573,7 +14573,7 @@ var import_node_url3 = require("node:url");
|
|
|
14573
14573
|
var import_node_zlib = require("node:zlib");
|
|
14574
14574
|
var PARSER_VERSION = 1;
|
|
14575
14575
|
var TEXT_PIPELINE_VERSION = 2;
|
|
14576
|
-
var CACHE_FORMAT_VERSION =
|
|
14576
|
+
var CACHE_FORMAT_VERSION = 2;
|
|
14577
14577
|
var MAX_CACHE_FILE_BYTES = 1024 * 1024 * 1024;
|
|
14578
14578
|
var MAX_TEMP_AGE_MS = 60 * 60 * 1e3;
|
|
14579
14579
|
var LITTLE_ENDIAN = new Uint8Array(new Uint32Array([1]).buffer)[0] === 1;
|
|
@@ -14961,6 +14961,9 @@ var StringTable = class _StringTable {
|
|
|
14961
14961
|
return table;
|
|
14962
14962
|
}
|
|
14963
14963
|
};
|
|
14964
|
+
function holdsStamp(columns, file2, stamp) {
|
|
14965
|
+
return columns.sizes[file2] === stamp.size && columns.mtimes[file2] === stamp.mtimeMs && columns.ctimes[file2] === stamp.ctimeMs && columns.inodes[file2] === stamp.ino;
|
|
14966
|
+
}
|
|
14964
14967
|
var FileTable = class _FileTable {
|
|
14965
14968
|
constructor(dictionary, strings) {
|
|
14966
14969
|
this.dictionary = dictionary;
|
|
@@ -14970,6 +14973,8 @@ var FileTable = class _FileTable {
|
|
|
14970
14973
|
hashes = new Uint8Array(0);
|
|
14971
14974
|
sizes = new Float64Array(0);
|
|
14972
14975
|
mtimes = new Float64Array(0);
|
|
14976
|
+
ctimes = new Float64Array(0);
|
|
14977
|
+
inodes = new Float64Array(0);
|
|
14973
14978
|
languages = new Uint32Array(0);
|
|
14974
14979
|
lines = new Uint32Array(0);
|
|
14975
14980
|
flags = new Uint8Array(0);
|
|
@@ -15035,6 +15040,8 @@ var FileTable = class _FileTable {
|
|
|
15035
15040
|
table.hashes = new Uint8Array(files * 32);
|
|
15036
15041
|
table.sizes = new Float64Array(files);
|
|
15037
15042
|
table.mtimes = new Float64Array(files);
|
|
15043
|
+
table.ctimes = new Float64Array(files);
|
|
15044
|
+
table.inodes = new Float64Array(files);
|
|
15038
15045
|
table.languages = new Uint32Array(files);
|
|
15039
15046
|
table.lines = new Uint32Array(files);
|
|
15040
15047
|
table.flags = new Uint8Array(files);
|
|
@@ -15060,6 +15067,8 @@ var FileTable = class _FileTable {
|
|
|
15060
15067
|
table.hashes.set(block.hash, file2 * 32);
|
|
15061
15068
|
table.sizes[file2] = block.size;
|
|
15062
15069
|
table.mtimes[file2] = block.mtimeMs;
|
|
15070
|
+
table.ctimes[file2] = block.ctimeMs;
|
|
15071
|
+
table.inodes[file2] = block.ino;
|
|
15063
15072
|
table.languages[file2] = block.language;
|
|
15064
15073
|
table.lines[file2] = block.lines;
|
|
15065
15074
|
table.flags[file2] = block.flags;
|
|
@@ -15194,6 +15203,8 @@ var FileTable = class _FileTable {
|
|
|
15194
15203
|
["fHash", this.hashes],
|
|
15195
15204
|
["fSize", this.sizes],
|
|
15196
15205
|
["fMtime", this.mtimes],
|
|
15206
|
+
["fCtime", this.ctimes],
|
|
15207
|
+
["fIno", this.inodes],
|
|
15197
15208
|
["fLang", this.languages],
|
|
15198
15209
|
["fLines", this.lines],
|
|
15199
15210
|
["fFlags", this.flags],
|
|
@@ -15267,6 +15278,8 @@ function blockFromTable(table, file2, dictionary, strings) {
|
|
|
15267
15278
|
hash: table.hashes.subarray(file2 * 32, file2 * 32 + 32),
|
|
15268
15279
|
size: table.sizes[file2],
|
|
15269
15280
|
mtimeMs: table.mtimes[file2],
|
|
15281
|
+
ctimeMs: table.ctimes[file2],
|
|
15282
|
+
ino: table.inodes[file2],
|
|
15270
15283
|
language: table.languages[file2],
|
|
15271
15284
|
lines: table.lines[file2],
|
|
15272
15285
|
flags: table.flags[file2],
|
|
@@ -15306,6 +15319,8 @@ function blockFromResult(meta3, result, dictionary, strings) {
|
|
|
15306
15319
|
hash: new Uint8Array(hash3),
|
|
15307
15320
|
size: meta3.size,
|
|
15308
15321
|
mtimeMs: meta3.mtimeMs,
|
|
15322
|
+
ctimeMs: meta3.ctimeMs,
|
|
15323
|
+
ino: meta3.ino,
|
|
15309
15324
|
language: strings.add(result.language),
|
|
15310
15325
|
lines: result.lines,
|
|
15311
15326
|
flags: result.parsed ? 1 : 0,
|
|
@@ -15355,6 +15370,8 @@ function readTable(container, header2) {
|
|
|
15355
15370
|
table.hashes = container.array("fHash", Uint8Array);
|
|
15356
15371
|
table.sizes = container.array("fSize", Float64Array);
|
|
15357
15372
|
table.mtimes = container.array("fMtime", Float64Array);
|
|
15373
|
+
table.ctimes = container.array("fCtime", Float64Array);
|
|
15374
|
+
table.inodes = container.array("fIno", Float64Array);
|
|
15358
15375
|
table.languages = container.array("fLang", Uint32Array);
|
|
15359
15376
|
table.lines = container.array("fLines", Uint32Array);
|
|
15360
15377
|
table.flags = container.array("fFlags", Uint8Array);
|
|
@@ -15376,6 +15393,7 @@ function readTable(container, header2) {
|
|
|
15376
15393
|
table.refStart = container.array("refS", Uint32Array);
|
|
15377
15394
|
table.refIds = container.array("refI", Uint32Array);
|
|
15378
15395
|
expect(table.hashes.length === files * 32 && table.sizes.length === files && table.mtimes.length === files && table.languages.length === files, "file column length");
|
|
15396
|
+
expect(table.ctimes.length === files && table.inodes.length === files, "file stamp length");
|
|
15379
15397
|
expect(table.lines.length === files && table.flags.length === files && table.tokenCounts.length === files, "file column length");
|
|
15380
15398
|
expect(table.chunkFirst.length === files + 1 && table.pathTermStart.length === files + 1 && table.pathTerms.length === pathTerms, "file offsets length");
|
|
15381
15399
|
for (const column of [table.starts, table.ends, table.idStrings, table.nameStrings, table.kindStrings, table.chunkLen]) expect(column.length === chunks, "chunk column length");
|
|
@@ -15401,6 +15419,7 @@ function readTable(container, header2) {
|
|
|
15401
15419
|
for (let i2 = 0; i2 < entries; i2++) if (table.rowTf[i2] === 0) throw new CacheCorruptError("zero term frequency");
|
|
15402
15420
|
for (let file2 = 0; file2 < files; file2++) {
|
|
15403
15421
|
expect(table.flags[file2] <= 1 && Number.isFinite(table.sizes[file2]) && table.sizes[file2] >= 0 && Number.isFinite(table.mtimes[file2]) && Number.isFinite(table.tokenCounts[file2]), "file fields");
|
|
15422
|
+
expect(Number.isFinite(table.ctimes[file2]) && Number.isFinite(table.inodes[file2]), "file stamp fields");
|
|
15404
15423
|
for (let c = table.chunkFirst[file2]; c < table.chunkFirst[file2 + 1]; c++) expect(table.starts[c] >= 1 && table.starts[c] <= table.ends[c] && table.ends[c] <= table.lines[file2], "chunk range");
|
|
15405
15424
|
}
|
|
15406
15425
|
const records = (name2) => {
|
|
@@ -15670,7 +15689,7 @@ var import_node_crypto3 = require("node:crypto");
|
|
|
15670
15689
|
var SKETCH_MAGIC = "RSQSKTCH";
|
|
15671
15690
|
var MAX_TERM_HASHES = 8192;
|
|
15672
15691
|
var collator = new Intl.Collator();
|
|
15673
|
-
function makeSketch(path, text,
|
|
15692
|
+
function makeSketch(path, text, stamp, digest, tokenCount = -1) {
|
|
15674
15693
|
const pathTerms = new Set(terms(path));
|
|
15675
15694
|
const unique2 = /* @__PURE__ */ new Set();
|
|
15676
15695
|
for (const term of pathTerms) unique2.add(termHash(term));
|
|
@@ -15681,7 +15700,7 @@ function makeSketch(path, text, size, mtimeMs, digest, tokenCount = -1) {
|
|
|
15681
15700
|
let lines = 1;
|
|
15682
15701
|
for (let at = text.indexOf("\n"); at !== -1; at = text.indexOf("\n", at + 1)) lines++;
|
|
15683
15702
|
const pathHashes = Uint32Array.from(new Set([...pathTerms].map(termHash))).sort();
|
|
15684
|
-
return { path, size, mtimeMs, digest, language: languageFor(path), lines, tokenCount, termHashes, pathHashes };
|
|
15703
|
+
return { path, size: stamp.size, mtimeMs: stamp.mtimeMs, ctimeMs: stamp.ctimeMs, ino: stamp.ino, digest, language: languageFor(path), lines, tokenCount, termHashes, pathHashes };
|
|
15685
15704
|
}
|
|
15686
15705
|
function contains(sorted, from, to, value) {
|
|
15687
15706
|
let low = from, high = to - 1;
|
|
@@ -15697,6 +15716,8 @@ var SketchTable = class _SketchTable {
|
|
|
15697
15716
|
paths = [];
|
|
15698
15717
|
sizes = new Float64Array(0);
|
|
15699
15718
|
mtimes = new Float64Array(0);
|
|
15719
|
+
ctimes = new Float64Array(0);
|
|
15720
|
+
inodes = new Float64Array(0);
|
|
15700
15721
|
digests = new Uint8Array(0);
|
|
15701
15722
|
languageIds = new Uint32Array(0);
|
|
15702
15723
|
languageNames = [];
|
|
@@ -15733,6 +15754,8 @@ var SketchTable = class _SketchTable {
|
|
|
15733
15754
|
path: this.paths[file2],
|
|
15734
15755
|
size: this.sizes[file2],
|
|
15735
15756
|
mtimeMs: this.mtimes[file2],
|
|
15757
|
+
ctimeMs: this.ctimes[file2],
|
|
15758
|
+
ino: this.inodes[file2],
|
|
15736
15759
|
digest: this.digestHex(file2),
|
|
15737
15760
|
language: this.languageNames[this.languageIds[file2]],
|
|
15738
15761
|
lines: this.lines[file2],
|
|
@@ -15747,6 +15770,8 @@ var SketchTable = class _SketchTable {
|
|
|
15747
15770
|
table.paths = sketches.map((sketch) => sketch.path);
|
|
15748
15771
|
table.sizes = Float64Array.from(sketches, (sketch) => sketch.size);
|
|
15749
15772
|
table.mtimes = Float64Array.from(sketches, (sketch) => sketch.mtimeMs);
|
|
15773
|
+
table.ctimes = Float64Array.from(sketches, (sketch) => sketch.ctimeMs);
|
|
15774
|
+
table.inodes = Float64Array.from(sketches, (sketch) => sketch.ino);
|
|
15750
15775
|
table.digests = new Uint8Array(count * 32);
|
|
15751
15776
|
table.languageIds = new Uint32Array(count);
|
|
15752
15777
|
table.lines = Uint32Array.from(sketches, (sketch) => sketch.lines);
|
|
@@ -15780,6 +15805,8 @@ var SketchTable = class _SketchTable {
|
|
|
15780
15805
|
["paths", Buffer.from(this.paths.join("\n"), "utf8")],
|
|
15781
15806
|
["sSize", this.sizes],
|
|
15782
15807
|
["sMtime", this.mtimes],
|
|
15808
|
+
["sCtime", this.ctimes],
|
|
15809
|
+
["sIno", this.inodes],
|
|
15783
15810
|
["sDigest", this.digests],
|
|
15784
15811
|
["sLang", this.languageIds],
|
|
15785
15812
|
["sLines", this.lines],
|
|
@@ -15810,6 +15837,8 @@ var SketchTable = class _SketchTable {
|
|
|
15810
15837
|
table.paths = files ? text.split("\n") : [];
|
|
15811
15838
|
table.sizes = container.array("sSize", Float64Array);
|
|
15812
15839
|
table.mtimes = container.array("sMtime", Float64Array);
|
|
15840
|
+
table.ctimes = container.array("sCtime", Float64Array);
|
|
15841
|
+
table.inodes = container.array("sIno", Float64Array);
|
|
15813
15842
|
table.digests = container.array("sDigest", Uint8Array);
|
|
15814
15843
|
table.languageIds = container.array("sLang", Uint32Array);
|
|
15815
15844
|
table.lines = container.array("sLines", Uint32Array);
|
|
@@ -15820,6 +15849,7 @@ var SketchTable = class _SketchTable {
|
|
|
15820
15849
|
table.pathHashes = container.array("pHashes", Uint32Array);
|
|
15821
15850
|
table.pathOrder = container.array("order", Uint32Array);
|
|
15822
15851
|
expect(table.paths.length === files && table.sizes.length === files && table.mtimes.length === files && table.digests.length === files * 32, "column length");
|
|
15852
|
+
expect(table.ctimes.length === files && table.inodes.length === files, "column length");
|
|
15823
15853
|
expect(table.languageIds.length === files && table.lines.length === files && table.tokenCounts.length === files && table.pathOrder.length === files, "column length");
|
|
15824
15854
|
expect(table.hashStart.length === files + 1 && table.pathHashStart.length === files + 1, "offset length");
|
|
15825
15855
|
for (const [offsets, total] of [[table.hashStart, table.hashes.length], [table.pathHashStart, table.pathHashes.length]]) {
|
|
@@ -15829,6 +15859,7 @@ var SketchTable = class _SketchTable {
|
|
|
15829
15859
|
const seen = new Uint8Array(files);
|
|
15830
15860
|
for (let i2 = 0; i2 < files; i2++) {
|
|
15831
15861
|
expect(table.languageIds[i2] < table.languageNames.length && Number.isFinite(table.sizes[i2]) && Number.isFinite(table.mtimes[i2]) && Number.isFinite(table.tokenCounts[i2]), "file fields");
|
|
15862
|
+
expect(Number.isFinite(table.ctimes[i2]) && Number.isFinite(table.inodes[i2]), "file stamp fields");
|
|
15832
15863
|
expect(table.pathOrder[i2] < files && seen[table.pathOrder[i2]] === 0, "bad path order");
|
|
15833
15864
|
seen[table.pathOrder[i2]] = 1;
|
|
15834
15865
|
}
|
|
@@ -16632,9 +16663,17 @@ var SKETCH_FILE = "sketch-v1.bin";
|
|
|
16632
16663
|
var STATS_FILE = "stats-v1.json";
|
|
16633
16664
|
var VERIFY_FILE_LIMIT = 5e3;
|
|
16634
16665
|
var VERIFY_MAX_BYTES = 256 * 1024 * 1024;
|
|
16666
|
+
var RACY_WINDOW_MS = 2e3;
|
|
16635
16667
|
var MAX_PARSED_FILES = 6e3;
|
|
16636
16668
|
var NOT_EXPANDABLE = "Path is excluded, absent, outside repository, or beyond scan limits";
|
|
16637
16669
|
var NO_FOLLOW2 = import_node_fs4.constants.O_NOFOLLOW ?? 0;
|
|
16670
|
+
function candidateMeta(path, stat2, scanStart) {
|
|
16671
|
+
const racy = Math.max(stat2.mtimeMs, stat2.ctimeMs) >= scanStart - RACY_WINDOW_MS;
|
|
16672
|
+
return { path, size: stat2.size, mtimeMs: Math.trunc(stat2.mtimeMs), ctimeMs: stat2.ctimeMs, ino: stat2.ino, racy };
|
|
16673
|
+
}
|
|
16674
|
+
function recordedStamp(meta3) {
|
|
16675
|
+
return { size: meta3.size, mtimeMs: meta3.mtimeMs, ctimeMs: meta3.racy ? -1 : meta3.ctimeMs, ino: meta3.ino };
|
|
16676
|
+
}
|
|
16638
16677
|
var SourceChangedError = class extends Error {
|
|
16639
16678
|
};
|
|
16640
16679
|
var sha256 = (bytes) => (0, import_node_crypto4.createHash)("sha256").update(bytes).digest("hex");
|
|
@@ -16656,6 +16695,7 @@ var IgnoreRules = class {
|
|
|
16656
16695
|
custom = (0, import_ignore.default)();
|
|
16657
16696
|
hasCustom = false;
|
|
16658
16697
|
cache = /* @__PURE__ */ new Map();
|
|
16698
|
+
dirVerdicts = /* @__PURE__ */ new Map();
|
|
16659
16699
|
async load() {
|
|
16660
16700
|
try {
|
|
16661
16701
|
const text = await (0, import_promises2.readFile)((0, import_node_path4.resolve)(this.root, ".reposqueeze-v2ignore"), "utf8");
|
|
@@ -16676,16 +16716,37 @@ var IgnoreRules = class {
|
|
|
16676
16716
|
}
|
|
16677
16717
|
return rules;
|
|
16678
16718
|
}
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
const parts2 = path.
|
|
16682
|
-
for (let depth =
|
|
16719
|
+
/** Git's precedence: the deepest .gitignore with a matching pattern decides, and a negation there can re-include. */
|
|
16720
|
+
async verdict(path, directory) {
|
|
16721
|
+
const parts2 = path.split("/");
|
|
16722
|
+
for (let depth = parts2.length - 1; depth >= 0; depth--) {
|
|
16683
16723
|
const dir = parts2.slice(0, depth).join("/");
|
|
16684
16724
|
const rules = await this.rulesIn(dir);
|
|
16685
|
-
if (rules
|
|
16725
|
+
if (!rules) continue;
|
|
16726
|
+
const result = rules.test((dir ? path.slice(dir.length + 1) : path) + (directory ? "/" : ""));
|
|
16727
|
+
if (result.ignored || result.unignored) return result.ignored;
|
|
16686
16728
|
}
|
|
16687
16729
|
return false;
|
|
16688
16730
|
}
|
|
16731
|
+
excludedDirectory(dir) {
|
|
16732
|
+
let verdict = this.dirVerdicts.get(dir);
|
|
16733
|
+
if (!verdict) {
|
|
16734
|
+
verdict = this.verdict(dir, true);
|
|
16735
|
+
this.dirVerdicts.set(dir, verdict);
|
|
16736
|
+
}
|
|
16737
|
+
return verdict;
|
|
16738
|
+
}
|
|
16739
|
+
/** Git never re-includes a file beneath an excluded directory, so ancestors are decided before the path itself. */
|
|
16740
|
+
async ignores(path) {
|
|
16741
|
+
if (this.hasCustom && this.custom.ignores(path)) return true;
|
|
16742
|
+
const directory = path.endsWith("/");
|
|
16743
|
+
const trimmed = directory ? path.slice(0, -1) : path;
|
|
16744
|
+
const parts2 = trimmed.split("/");
|
|
16745
|
+
for (let depth = 1; depth < parts2.length; depth++) {
|
|
16746
|
+
if (await this.excludedDirectory(parts2.slice(0, depth).join("/"))) return true;
|
|
16747
|
+
}
|
|
16748
|
+
return this.verdict(trimmed, directory);
|
|
16749
|
+
}
|
|
16689
16750
|
};
|
|
16690
16751
|
var Repository = class {
|
|
16691
16752
|
root;
|
|
@@ -16823,10 +16884,11 @@ var Repository = class {
|
|
|
16823
16884
|
} catch (error62) {
|
|
16824
16885
|
if (error62 instanceof Error && error62.message === NOT_EXPANDABLE) throw error62;
|
|
16825
16886
|
}
|
|
16887
|
+
const scanStart = Date.now();
|
|
16826
16888
|
try {
|
|
16827
16889
|
const stats = await (0, import_promises2.lstat)((0, import_node_path4.resolve)(root, path));
|
|
16828
16890
|
if (!stats.isFile() || stats.isSymbolicLink() || stats.size > MAX_FILE_BYTES) throw new Error(NOT_EXPANDABLE);
|
|
16829
|
-
return
|
|
16891
|
+
return candidateMeta(path, stats, scanStart);
|
|
16830
16892
|
} catch {
|
|
16831
16893
|
throw new Error(NOT_EXPANDABLE);
|
|
16832
16894
|
}
|
|
@@ -16881,12 +16943,13 @@ var Repository = class {
|
|
|
16881
16943
|
async eligibleFiles(root, scan) {
|
|
16882
16944
|
let skipped = 0, totalBytes = 0, truncated = scan.truncated;
|
|
16883
16945
|
const metadata2 = [];
|
|
16946
|
+
const scanStart = Date.now();
|
|
16884
16947
|
const stats = await mapLimit(scan.paths, STAT_CONCURRENCY, async (path) => {
|
|
16885
16948
|
if (!allowedPath(path) || !scan.rules.trivial && await scan.rules.ignores(path)) return null;
|
|
16886
16949
|
try {
|
|
16887
16950
|
const stat2 = await (0, import_promises2.lstat)((0, import_node_path4.resolve)(root, path));
|
|
16888
16951
|
if (!stat2.isFile() || stat2.isSymbolicLink() || stat2.size > MAX_FILE_BYTES) return null;
|
|
16889
|
-
return
|
|
16952
|
+
return candidateMeta(path, stat2, scanStart);
|
|
16890
16953
|
} catch {
|
|
16891
16954
|
return null;
|
|
16892
16955
|
}
|
|
@@ -16940,7 +17003,7 @@ var Repository = class {
|
|
|
16940
17003
|
this.lap(state, "assemble+save");
|
|
16941
17004
|
const truncated = eligible.truncated;
|
|
16942
17005
|
if (truncated) warnings.push("Repository exceeds safety limits (100,000 files / 2 GiB indexed text / 2 MiB per file / depth 60); index is incomplete.");
|
|
16943
|
-
if (!verify) warnings.push("Index reuse trusts file size
|
|
17006
|
+
if (!verify) warnings.push("Index reuse trusts file size, modification time, change time and inode above 5,000 files or 256 MiB; REPOSQUEEZE_REFRESH_INDEX=1 forces a full re-read.");
|
|
16944
17007
|
const fallback = this.fallbackCount(table);
|
|
16945
17008
|
if (fallback) warnings.push(`${fallback} source files have parse errors or unavailable grammars; line-window search remains active.`);
|
|
16946
17009
|
const { files, chunks, rows } = table.materialize(state.text);
|
|
@@ -16990,7 +17053,7 @@ var Repository = class {
|
|
|
16990
17053
|
let reused = 0, refreshed = 0;
|
|
16991
17054
|
const built = await mapLimit(metadata2, READ_CONCURRENCY, async (meta3) => {
|
|
16992
17055
|
const known = previous.fileOf(meta3.path);
|
|
16993
|
-
if (!force && known >= 0 &&
|
|
17056
|
+
if (!force && known >= 0 && !meta3.racy && holdsStamp(previous, known, meta3) && !(exact && previous.tokenCounts[known] < 0)) {
|
|
16994
17057
|
reused++;
|
|
16995
17058
|
return known;
|
|
16996
17059
|
}
|
|
@@ -16998,7 +17061,7 @@ var Repository = class {
|
|
|
16998
17061
|
const bytes = await this.readBytes(state.root, meta3, directories);
|
|
16999
17062
|
const text = await this.readText(state.root, meta3, bytes);
|
|
17000
17063
|
refreshed++;
|
|
17001
|
-
return makeSketch(meta3.path, text, meta3
|
|
17064
|
+
return makeSketch(meta3.path, text, recordedStamp(meta3), sha256(bytes), exact ? fileTokens(meta3.path, text) : -1);
|
|
17002
17065
|
} catch {
|
|
17003
17066
|
skipped++;
|
|
17004
17067
|
return null;
|
|
@@ -17035,7 +17098,7 @@ var Repository = class {
|
|
|
17035
17098
|
const { files, chunks, rows } = table.materialize(state.text);
|
|
17036
17099
|
this.lap(state, "materialize");
|
|
17037
17100
|
warnings.push(`Large-repository cascade: ${files.length.toLocaleString()} candidates parsed from ${sketches.count.toLocaleString()} eligible files.`);
|
|
17038
|
-
warnings.push("File sketches contain hashes, counts and term fingerprints only; returned evidence is re-read verbatim from current source.
|
|
17101
|
+
warnings.push("File sketches contain hashes, counts and term fingerprints only; returned evidence is re-read verbatim from current source. Files are trusted by size, modification time, change time and inode; REPOSQUEEZE_REFRESH_INDEX=1 forces a full re-read.");
|
|
17039
17102
|
if (!scan.git) warnings.push("Use a Git working tree for the strongest change detection and ignore behavior at this scale.");
|
|
17040
17103
|
if (eligible.truncated) warnings.push("Repository exceeds safety limits (100,000 files / 2 GiB indexed text / 2 MiB per file / depth 60); index is incomplete.");
|
|
17041
17104
|
const fallback = this.fallbackCount(table);
|
|
@@ -17081,7 +17144,7 @@ var Repository = class {
|
|
|
17081
17144
|
results = await mapLimit(metas, READ_CONCURRENCY, async (meta3) => {
|
|
17082
17145
|
const known = old.fileOf(meta3.path);
|
|
17083
17146
|
const needsCount = exact && known >= 0 && old.tokenCounts[known] < 0;
|
|
17084
|
-
if (known >= 0 && !force && !verify && !needsCount &&
|
|
17147
|
+
if (known >= 0 && !force && !verify && !needsCount && !meta3.racy && holdsStamp(old, known, meta3)) {
|
|
17085
17148
|
reused++;
|
|
17086
17149
|
return { source: old, file: known };
|
|
17087
17150
|
}
|
|
@@ -17094,9 +17157,12 @@ var Repository = class {
|
|
|
17094
17157
|
}
|
|
17095
17158
|
const digest = sha256(bytes);
|
|
17096
17159
|
if (known >= 0 && !force && old.hashHex(known) === digest) {
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
old.
|
|
17160
|
+
const stamp = recordedStamp(meta3);
|
|
17161
|
+
if (!holdsStamp(old, known, stamp)) {
|
|
17162
|
+
old.sizes[known] = stamp.size;
|
|
17163
|
+
old.mtimes[known] = stamp.mtimeMs;
|
|
17164
|
+
old.ctimes[known] = stamp.ctimeMs;
|
|
17165
|
+
old.inodes[known] = stamp.ino;
|
|
17100
17166
|
touched = true;
|
|
17101
17167
|
}
|
|
17102
17168
|
if (needsCount) {
|
|
@@ -17124,7 +17190,7 @@ var Repository = class {
|
|
|
17124
17190
|
return null;
|
|
17125
17191
|
}
|
|
17126
17192
|
parsed++;
|
|
17127
|
-
return { meta: { path: meta3.path, hash: digest,
|
|
17193
|
+
return { meta: { path: meta3.path, hash: digest, ...recordedStamp(meta3), tokenCount: exact ? fileTokens(meta3.path, text) : -1 }, result };
|
|
17128
17194
|
});
|
|
17129
17195
|
} finally {
|
|
17130
17196
|
await indexer.close();
|
|
@@ -17201,7 +17267,7 @@ var Repository = class {
|
|
|
17201
17267
|
const directories = /* @__PURE__ */ new Map();
|
|
17202
17268
|
const texts = await mapLimit(sample, 16, async (file2) => {
|
|
17203
17269
|
try {
|
|
17204
|
-
const meta3 = { path: file2.path
|
|
17270
|
+
const meta3 = { path: file2.path };
|
|
17205
17271
|
return { path: file2.path, text: await this.readText(state.root, meta3, await this.readBytes(state.root, meta3, directories)) };
|
|
17206
17272
|
} catch {
|
|
17207
17273
|
return null;
|
|
@@ -22130,6 +22196,7 @@ async function collectSignals(root, options) {
|
|
|
22130
22196
|
// src/engine.ts
|
|
22131
22197
|
var MAX_QUERY_CHARS2 = 8e3;
|
|
22132
22198
|
var HARD_QUERY_LIMIT = 1e6;
|
|
22199
|
+
var MAX_PACK_ATTEMPTS = 3;
|
|
22133
22200
|
var Engine = class extends Repository {
|
|
22134
22201
|
features;
|
|
22135
22202
|
semantic;
|
|
@@ -22147,6 +22214,17 @@ var Engine = class extends Repository {
|
|
|
22147
22214
|
if (raw.length > HARD_QUERY_LIMIT) throw new Error("query is longer than 1,000,000 characters");
|
|
22148
22215
|
if (raw.length > MAX_QUERY_CHARS2 && !this.features.has("condense")) throw new Error("query must contain 1\u20138000 characters");
|
|
22149
22216
|
const text = raw.length > MAX_QUERY_CHARS2 ? condenseQuery(raw, 6e3) : raw;
|
|
22217
|
+
for (let attempt = 1; ; attempt++) {
|
|
22218
|
+
try {
|
|
22219
|
+
const pack = await this.buildPack(text, budget, known);
|
|
22220
|
+
pack.stats.elapsedMs = performance.now() - started;
|
|
22221
|
+
return pack;
|
|
22222
|
+
} catch (error62) {
|
|
22223
|
+
if (!(error62 instanceof SourceChangedError) || attempt >= MAX_PACK_ATTEMPTS) throw error62;
|
|
22224
|
+
}
|
|
22225
|
+
}
|
|
22226
|
+
}
|
|
22227
|
+
async buildPack(text, budget, known) {
|
|
22150
22228
|
const snapshot = await this.snapshot(text);
|
|
22151
22229
|
let semanticScores;
|
|
22152
22230
|
if (this.semantic) {
|
|
@@ -22154,9 +22232,7 @@ var Engine = class extends Repository {
|
|
|
22154
22232
|
semanticScores = await this.semantic.scores(snapshot, text, candidates);
|
|
22155
22233
|
}
|
|
22156
22234
|
const git = this.features.has("git") ? await loadGitSignals(this.root) : void 0;
|
|
22157
|
-
|
|
22158
|
-
pack.stats.elapsedMs = performance.now() - started;
|
|
22159
|
-
return pack;
|
|
22235
|
+
return contextPackV2(snapshot, text, budget, known, void 0, semanticScores, this.features, git);
|
|
22160
22236
|
}
|
|
22161
22237
|
async expandRange(path, start2, end, budget = 3e3) {
|
|
22162
22238
|
return this.expand(path, start2, end, budget);
|
|
@@ -56490,13 +56566,16 @@ function levels(csr, source, depth) {
|
|
|
56490
56566
|
|
|
56491
56567
|
// src/graph.ts
|
|
56492
56568
|
var GRAPH_FORMAT = "reposqueeze-graph";
|
|
56493
|
-
var GRAPH_VERSION =
|
|
56569
|
+
var GRAPH_VERSION = 3;
|
|
56494
56570
|
var NODE_KINDS = ["file", "def", "external"];
|
|
56495
|
-
var EDGE_KINDS = ["imports", "defines", "references", "contains"];
|
|
56571
|
+
var EDGE_KINDS = ["imports", "defines", "references", "contains", "calls"];
|
|
56496
56572
|
var CONFIDENCES = ["EXTRACTED", "INFERRED"];
|
|
56497
56573
|
var IMPORT_WEIGHT = 3;
|
|
56498
56574
|
var MAX_REFERENCE_TARGETS = 24;
|
|
56499
56575
|
var MIN_REFERENCE_WEIGHT = 0.04;
|
|
56576
|
+
var CALL_SITE = /\b([A-Za-z_$][\w$]*)\s*\(/g;
|
|
56577
|
+
var NOT_CALLS = /* @__PURE__ */ new Set(["if", "for", "while", "switch", "catch", "return", "function", "def", "func", "fn", "elif", "with", "sizeof", "typeof", "super", "this", "new", "await", "yield", "assert", "print", "len", "range", "make", "append", "cap", "delete", "panic", "require", "import", "export", "and", "or", "not", "in", "is", "lambda", "pass", "raise"]);
|
|
56578
|
+
var MAX_CALL_TARGETS = 8;
|
|
56500
56579
|
var MAX_DEFINERS = 40;
|
|
56501
56580
|
var FREE_DEFINERS = 3;
|
|
56502
56581
|
var COMMON_NAME_FILES = 8;
|
|
@@ -56614,7 +56693,7 @@ function buildGraph(snapshot, options = {}) {
|
|
|
56614
56693
|
});
|
|
56615
56694
|
const importTargets = files.map(() => /* @__PURE__ */ new Map());
|
|
56616
56695
|
const externalUsers = /* @__PURE__ */ new Map();
|
|
56617
|
-
const stats = { files: files.length, definitions: definitionCount, externals: 0, importEdges: 0, referenceEdges: 0, importStatements: 0, importsResolved: 0, importsExternal: 0, importsUnresolved: 0, externalsOmitted: 0, languages };
|
|
56696
|
+
const stats = { files: files.length, definitions: definitionCount, externals: 0, importEdges: 0, referenceEdges: 0, callEdges: 0, importStatements: 0, importsResolved: 0, importsExternal: 0, importsUnresolved: 0, externalsOmitted: 0, languages };
|
|
56618
56697
|
const textOnly = /* @__PURE__ */ new Set();
|
|
56619
56698
|
files.forEach((info3, f) => {
|
|
56620
56699
|
const source = info3.source;
|
|
@@ -56646,7 +56725,7 @@ function buildGraph(snapshot, options = {}) {
|
|
|
56646
56725
|
refs ??= referenced();
|
|
56647
56726
|
const members2 = info3.language === "go" ? qualifiedMembers(source.text, ref.spec.split("/").pop()) : void 0;
|
|
56648
56727
|
const mentioned = targets.filter((path) => topLevelNames(fileId.get(path)).some((name2) => (members2 ?? refs).has(name2)));
|
|
56649
|
-
targets =
|
|
56728
|
+
targets = mentioned.slice(0, MAX_PACKAGE_FILES);
|
|
56650
56729
|
confidence = "INFERRED";
|
|
56651
56730
|
}
|
|
56652
56731
|
for (const path of targets) {
|
|
@@ -56749,6 +56828,29 @@ function addReferenceEdges(files, importTargets, columns, stats) {
|
|
|
56749
56828
|
const defChunks = new Set(info3.defs.map((def) => def.chunk));
|
|
56750
56829
|
for (const root of analysis.roots) if (!defChunks.has(root)) sources.push({ node: g, refs: root.refs, exclude: allDefRefs });
|
|
56751
56830
|
const imported = importTargets[g];
|
|
56831
|
+
info3.defs.forEach((def, index) => {
|
|
56832
|
+
const node2 = info3.nodeOf.get(index);
|
|
56833
|
+
if (node2 === void 0 || !def.chunk.text) return;
|
|
56834
|
+
const seen = /* @__PURE__ */ new Set();
|
|
56835
|
+
const targets = /* @__PURE__ */ new Map();
|
|
56836
|
+
for (const match of def.chunk.text.matchAll(CALL_SITE)) {
|
|
56837
|
+
const name2 = match[1];
|
|
56838
|
+
if (seen.has(name2) || name2 === def.chunk.name || NOT_CALLS.has(name2)) continue;
|
|
56839
|
+
seen.add(name2);
|
|
56840
|
+
const list = definers.get(name2);
|
|
56841
|
+
if (!list || list.length > MAX_DEFINERS) continue;
|
|
56842
|
+
const local = list.filter((definer) => definer.file === g && definer.node !== node2);
|
|
56843
|
+
const backed = list.filter((definer) => definer.file !== g && imported.has(definer.file));
|
|
56844
|
+
const unique2 = !local.length && !backed.length && list.length === 1 && list[0].node !== node2 && isDistinctive(name2) ? list : [];
|
|
56845
|
+
const pick2 = local.length ? local : backed.length ? backed : unique2;
|
|
56846
|
+
for (const definer of pick2.slice(0, 3)) targets.set(definer.node, { weight: 1 / pick2.length, exact: pick2.length === 1 });
|
|
56847
|
+
if (targets.size >= MAX_CALL_TARGETS) break;
|
|
56848
|
+
}
|
|
56849
|
+
for (const [target, { weight, exact }] of [...targets].slice(0, MAX_CALL_TARGETS)) {
|
|
56850
|
+
columns.edge(node2, target, "calls", Math.round(weight * 1e3) / 1e3, exact ? "EXTRACTED" : "INFERRED");
|
|
56851
|
+
stats.callEdges++;
|
|
56852
|
+
}
|
|
56853
|
+
});
|
|
56752
56854
|
for (const { node: node2, refs, exclude } of sources) {
|
|
56753
56855
|
const scored = /* @__PURE__ */ new Map();
|
|
56754
56856
|
for (const name2 of refs) {
|
|
@@ -57138,12 +57240,21 @@ function dominantDirectory(paths) {
|
|
|
57138
57240
|
// src/graph-html.ts
|
|
57139
57241
|
init_import_meta();
|
|
57140
57242
|
var import_node_crypto6 = require("node:crypto");
|
|
57141
|
-
|
|
57142
|
-
|
|
57143
|
-
|
|
57144
|
-
var
|
|
57145
|
-
var
|
|
57146
|
-
|
|
57243
|
+
|
|
57244
|
+
// src/graph-layout.ts
|
|
57245
|
+
init_import_meta();
|
|
57246
|
+
var LAYOUT_WIDTH = 1200;
|
|
57247
|
+
var LAYOUT_HEIGHT = 800;
|
|
57248
|
+
var communityColor = (id) => `hsl(${Math.round(id * 137.508 % 360)},62%,52%)`;
|
|
57249
|
+
function ringSeeds(communities, width = LAYOUT_WIDTH, height = LAYOUT_HEIGHT) {
|
|
57250
|
+
const seeds = /* @__PURE__ */ new Map();
|
|
57251
|
+
communities.forEach((c, i2) => {
|
|
57252
|
+
const angle = i2 / communities.length * Math.PI * 2;
|
|
57253
|
+
seeds.set(c, { x: width / 2 + 0.33 * width * Math.cos(angle), y: height / 2 + 0.33 * height * Math.sin(angle) });
|
|
57254
|
+
});
|
|
57255
|
+
return seeds;
|
|
57256
|
+
}
|
|
57257
|
+
function layout(count, community, links, seeds, width = LAYOUT_WIDTH, height = LAYOUT_HEIGHT) {
|
|
57147
57258
|
const members2 = /* @__PURE__ */ new Map();
|
|
57148
57259
|
community.forEach((c, i2) => {
|
|
57149
57260
|
const list = members2.get(c);
|
|
@@ -57159,10 +57270,10 @@ function layout(count, community, links, seeds) {
|
|
|
57159
57270
|
points[node2] = { x: center.x + radius * Math.cos(angle), y: center.y + radius * Math.sin(angle) };
|
|
57160
57271
|
});
|
|
57161
57272
|
}
|
|
57162
|
-
const area =
|
|
57273
|
+
const area = width * height;
|
|
57163
57274
|
const spring = Math.sqrt(area / Math.max(1, count)) * 0.9;
|
|
57164
57275
|
const iterations = count > 800 ? 40 : count > 300 ? 80 : 150;
|
|
57165
|
-
let temperature =
|
|
57276
|
+
let temperature = width / 10;
|
|
57166
57277
|
const dx = new Float64Array(count);
|
|
57167
57278
|
const dy = new Float64Array(count);
|
|
57168
57279
|
for (let step = 0; step < iterations; step++) {
|
|
@@ -57208,6 +57319,12 @@ function layout(count, community, links, seeds) {
|
|
|
57208
57319
|
}
|
|
57209
57320
|
return points;
|
|
57210
57321
|
}
|
|
57322
|
+
|
|
57323
|
+
// src/graph-html.ts
|
|
57324
|
+
var WIDTH = 1200;
|
|
57325
|
+
var HEIGHT = 800;
|
|
57326
|
+
var MAX_EDGES = 4e3;
|
|
57327
|
+
var escapeHtml = (text) => text.replace(/[&<>"']/g, (ch) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[ch]);
|
|
57211
57328
|
var SCRIPT = `(function(){var svg=document.getElementById('g');var nodes=svg.querySelectorAll('circle');var lines=svg.querySelectorAll('line');
|
|
57212
57329
|
function clear(){svg.classList.remove('focus');nodes.forEach(function(n){n.classList.remove('hot')});lines.forEach(function(l){l.classList.remove('hot')});}
|
|
57213
57330
|
svg.addEventListener('click',function(ev){var t=ev.target;if(t.tagName!=='circle'){clear();return;}clear();svg.classList.add('focus');var id=t.getAttribute('data-i');t.classList.add('hot');
|
|
@@ -57223,11 +57340,7 @@ function renderHtml(graph, options = {}) {
|
|
|
57223
57340
|
const index = new Map(shown.map((f, i2) => [f, i2]));
|
|
57224
57341
|
const community = shown.map((f) => graph.community[f]);
|
|
57225
57342
|
const usedCommunities = [...new Set(community)].sort((a, b) => a - b);
|
|
57226
|
-
const seeds =
|
|
57227
|
-
usedCommunities.forEach((c, i2) => {
|
|
57228
|
-
const angle = i2 / usedCommunities.length * Math.PI * 2;
|
|
57229
|
-
seeds.set(c, { x: WIDTH / 2 + 0.33 * WIDTH * Math.cos(angle), y: HEIGHT / 2 + 0.33 * HEIGHT * Math.sin(angle) });
|
|
57230
|
-
});
|
|
57343
|
+
const seeds = ringSeeds(usedCommunities, WIDTH, HEIGHT);
|
|
57231
57344
|
const edges = [];
|
|
57232
57345
|
for (const f of shown) {
|
|
57233
57346
|
for (let e = graph.fileOut.start[f]; e < graph.fileOut.start[f + 1]; e++) {
|
|
@@ -57237,7 +57350,7 @@ function renderHtml(graph, options = {}) {
|
|
|
57237
57350
|
}
|
|
57238
57351
|
edges.sort((x, y) => y.weight - x.weight || x.a - y.a || x.b - y.b);
|
|
57239
57352
|
const kept = edges.slice(0, MAX_EDGES).sort((x, y) => x.a - y.a || x.b - y.b);
|
|
57240
|
-
const points = layout(shown.length, community, kept.map((edge) => [edge.a, edge.b, Math.log2(1 + edge.weight)]), seeds);
|
|
57353
|
+
const points = layout(shown.length, community, kept.map((edge) => [edge.a, edge.b, Math.log2(1 + edge.weight)]), seeds, WIDTH, HEIGHT);
|
|
57241
57354
|
const xs = points.map((p) => p.x);
|
|
57242
57355
|
const ys = points.map((p) => p.y);
|
|
57243
57356
|
const minX = Math.min(...xs, 0) - 20;
|
|
@@ -57250,11 +57363,11 @@ function renderHtml(graph, options = {}) {
|
|
|
57250
57363
|
for (const edge of kept) parts2.push(`<line class="${edge.imports ? "imp" : "ref"}" data-a="${edge.a}" data-b="${edge.b}" x1="${round(points[edge.a].x)}" y1="${round(points[edge.a].y)}" x2="${round(points[edge.b].x)}" y2="${round(points[edge.b].y)}"/>`);
|
|
57251
57364
|
shown.forEach((f, i2) => {
|
|
57252
57365
|
const radius = 3 + 11 * Math.sqrt(graph.rank[f] / maxRank);
|
|
57253
|
-
parts2.push(`<circle data-i="${i2}" cx="${round(points[i2].x)}" cy="${round(points[i2].y)}" r="${radius.toFixed(1)}" fill="${
|
|
57366
|
+
parts2.push(`<circle data-i="${i2}" cx="${round(points[i2].x)}" cy="${round(points[i2].y)}" r="${radius.toFixed(1)}" fill="${communityColor(graph.community[f])}"><title>${escapeHtml(graph.label[f])} \xB7 S${graph.community[f]} \xB7 in ${graph.inDegree[f]} out ${graph.outDegree[f]}</title></circle>`);
|
|
57254
57367
|
});
|
|
57255
57368
|
shown.slice(0, 25).forEach((f, i2) => parts2.push(`<text x="${round(points[i2].x + 6)}" y="${round(points[i2].y - 6)}">${escapeHtml(graph.label[f].split("/").pop() ?? "")}</text>`));
|
|
57256
57369
|
const legend = usedCommunities.slice(0, 20).map((c) => `<p><span class="sw s${c}"></span>S${c} ${escapeHtml(graph.subsystems[c].name)} (${graph.subsystems[c].files.length})</p>`).join("");
|
|
57257
|
-
const swatchStyle = usedCommunities.slice(0, 20).map((c) => `.s${c}{background:${
|
|
57370
|
+
const swatchStyle = usedCommunities.slice(0, 20).map((c) => `.s${c}{background:${communityColor(c)}}`).join("");
|
|
57258
57371
|
const title = escapeHtml(options.title ?? "Code graph");
|
|
57259
57372
|
const style = STYLE + swatchStyle;
|
|
57260
57373
|
const csp = `default-src 'none'; style-src ${sha(style)}; script-src ${sha(SCRIPT)}; base-uri 'none'; form-action 'none'`;
|
|
@@ -57306,7 +57419,7 @@ function references(graph) {
|
|
|
57306
57419
|
const to = [];
|
|
57307
57420
|
const counts = new Uint32Array(graph.nodeCount);
|
|
57308
57421
|
for (let e = 0; e < graph.edgeFrom.length; e++) {
|
|
57309
|
-
if (graph.edgeKind[e] !== 2) continue;
|
|
57422
|
+
if (graph.edgeKind[e] !== 2 && graph.edgeKind[e] !== 4) continue;
|
|
57310
57423
|
from.push(graph.edgeFrom[e]);
|
|
57311
57424
|
to.push(graph.edgeTo[e]);
|
|
57312
57425
|
counts[graph.edgeTo[e]]++;
|
|
@@ -57404,18 +57517,18 @@ function listFiles(graph, nodes, cap, directory = "") {
|
|
|
57404
57517
|
const sorted = [...nodes].sort(byImportance(graph));
|
|
57405
57518
|
return sorted.slice(0, cap).map((n) => short(graph, n, directory)).join(", ") + more(nodes.length, cap);
|
|
57406
57519
|
}
|
|
57407
|
-
function renderNeighbors(graph, target, depth, budget) {
|
|
57520
|
+
function renderNeighbors(graph, target, depth, budget, style = "full") {
|
|
57408
57521
|
const picked = pickTarget(graph, target);
|
|
57409
57522
|
if ("message" in picked) return clamp(picked.message, budget);
|
|
57410
57523
|
const node2 = picked.node;
|
|
57411
57524
|
const steps = Math.max(1, Math.min(3, Math.floor(depth) || 1));
|
|
57412
|
-
const render = (cap) => graph.nodeKind(node2) === "file" ? fileNeighbors(graph, node2, steps, cap) : graph.nodeKind(node2) === "def" ? defNeighbors(graph, node2, steps, cap) : externalNeighbors(graph, node2, cap);
|
|
57525
|
+
const render = (cap) => graph.nodeKind(node2) === "file" ? fileNeighbors(graph, node2, steps, cap, style) : graph.nodeKind(node2) === "def" ? defNeighbors(graph, node2, steps, cap) : externalNeighbors(graph, node2, cap);
|
|
57413
57526
|
return richest([40, 25, 15, 8, 4, 2, 1], render, budget);
|
|
57414
57527
|
}
|
|
57415
|
-
function fileNeighbors(graph, file2, depth, cap) {
|
|
57528
|
+
function fileNeighbors(graph, file2, depth, cap, style = "full") {
|
|
57416
57529
|
const sub = graph.subsystems[graph.community[file2]];
|
|
57417
57530
|
const rankPosition = graph.filesByRank().indexOf(file2) + 1;
|
|
57418
|
-
const lines = [`file ${graph.label[file2]} [S${sub.id} ${sub.name}] \xB7 ${graph.detail[file2]} \xB7 rank #${rankPosition}/${graph.fileCount}`];
|
|
57531
|
+
const lines = [style === "caveman" ? `${graph.label[file2]} [S${sub.id}] #${rankPosition}/${graph.fileCount}` : `file ${graph.label[file2]} [S${sub.id} ${sub.name}] \xB7 ${graph.detail[file2]} \xB7 rank #${rankPosition}/${graph.fileCount}`];
|
|
57419
57532
|
const split = (csr, wanted) => {
|
|
57420
57533
|
const out2 = [];
|
|
57421
57534
|
for (let e = csr.start[file2]; e < csr.start[file2 + 1]; e++) if (wanted(graph.fileMask[csr.edge[e]])) out2.push(csr.to[e]);
|
|
@@ -57429,7 +57542,7 @@ function fileNeighbors(graph, file2, depth, cap) {
|
|
|
57429
57542
|
for (let e = graph.out.start[file2]; e < graph.out.start[file2 + 1]; e++) if (graph.kind[graph.out.to[e]] === 2) externals.push(graph.label[graph.out.to[e]].replace(/^external:/, ""));
|
|
57430
57543
|
if (imports.length) lines.push(`imports (${imports.length}): ${listFiles(graph, imports, cap)}`);
|
|
57431
57544
|
if (externals.length) lines.push(`external (${externals.length}): ${externals.slice(0, cap).join(", ")}${more(externals.length, cap)}`);
|
|
57432
|
-
if (uses.length) lines.push(
|
|
57545
|
+
if (uses.length) lines.push(`${style === "caveman" ? "uses" : "uses without import"} (${uses.length}${style === "caveman" ? ", name" : ", name-based"}): ${listFiles(graph, uses, cap)}`);
|
|
57433
57546
|
if (importedBy.length) lines.push(`imported by (${importedBy.length}): ${listFiles(graph, importedBy, cap)}`);
|
|
57434
57547
|
if (usedBy.length) lines.push(`used by (${usedBy.length}, name-based): ${listFiles(graph, usedBy, cap)}`);
|
|
57435
57548
|
const defs = [];
|
|
@@ -57501,7 +57614,7 @@ function findPath(graph, from, to) {
|
|
|
57501
57614
|
const hops = shortestPath(graph.out, graph.into, from, to, true, isExternal);
|
|
57502
57615
|
return hops ? { hops, directed: false, kind: "full" } : void 0;
|
|
57503
57616
|
}
|
|
57504
|
-
function renderPath(graph, a, b, budget) {
|
|
57617
|
+
function renderPath(graph, a, b, budget, style = "full") {
|
|
57505
57618
|
const first = pickTarget(graph, a, "from");
|
|
57506
57619
|
if ("message" in first) return clamp(first.message, budget);
|
|
57507
57620
|
const second = pickTarget(graph, b, "to");
|
|
@@ -57512,12 +57625,12 @@ function renderPath(graph, a, b, budget) {
|
|
|
57512
57625
|
}
|
|
57513
57626
|
const kindOf = (edge) => found.kind === "imports" ? "imports" : found.kind === "file" ? graph.fileMask[edge] & 1 ? "imports" : "references~" : mark(graph, edge);
|
|
57514
57627
|
const quality = found.hops.every((hop) => kindOf(hop.edge) === "imports") ? "imports only" : "uses name-based references (~)";
|
|
57515
|
-
const lines = [`path ${graph.describe(first.node)} \u2192 ${graph.describe(second.node)}: ${found.hops.length} hops${found.directed ? "" : ", edge direction ignored"} \xB7 ${quality}`, graph.describe(first.node)];
|
|
57628
|
+
const lines = style === "caveman" ? [`${graph.describe(first.node)} \u2192 ${graph.describe(second.node)}: ${found.hops.length} hops${found.directed ? "" : " (undirected)"}, ${found.hops.every((hop) => kindOf(hop.edge) === "imports") ? "imports" : "name-based"}`] : [`path ${graph.describe(first.node)} \u2192 ${graph.describe(second.node)}: ${found.hops.length} hops${found.directed ? "" : ", edge direction ignored"} \xB7 ${quality}`, graph.describe(first.node)];
|
|
57516
57629
|
found.hops.forEach((hop) => lines.push(` ${hopText(graph, hop, kindOf)}`));
|
|
57517
57630
|
if (!found.hops.length) lines.push(" (same node)");
|
|
57518
57631
|
return clamp(lines.join("\n"), budget);
|
|
57519
57632
|
}
|
|
57520
|
-
function renderImpact(graph, target, depth, budget) {
|
|
57633
|
+
function renderImpact(graph, target, depth, budget, style = "full") {
|
|
57521
57634
|
const picked = pickTarget(graph, target);
|
|
57522
57635
|
if ("message" in picked) return clamp(picked.message, budget);
|
|
57523
57636
|
const node2 = picked.node;
|
|
@@ -57534,11 +57647,11 @@ function renderImpact(graph, target, depth, budget) {
|
|
|
57534
57647
|
const tests = [...files].filter((f) => isTestPath(graph.label[f])).length;
|
|
57535
57648
|
const render = (cap) => {
|
|
57536
57649
|
const via = isFile ? "via imports" : "via references";
|
|
57537
|
-
const lines = [`impact of ${graph.describe(node2)}: ${strongSet.size} ${isFile ? "files" : "definitions/files"} ${via} within ${steps} hops (direct ${strong[0]?.length ?? 0})${weak.length ? `, +${weak.length} only via name-based references` : ""} \xB7 ${files.size} files total, ${tests} test files${graph.partial ? " \xB7 partial graph" : ""}`];
|
|
57650
|
+
const lines = style === "caveman" ? [`${graph.describe(node2)} \u2190 ${strong[0]?.length ?? 0} direct, ${files.size} total${weak.length ? `, ${weak.length} name-only` : ""}${tests ? `, ${tests} tests` : ""}${graph.partial ? " (partial)" : ""}`] : [`impact of ${graph.describe(node2)}: ${strongSet.size} ${isFile ? "files" : "definitions/files"} ${via} within ${steps} hops (direct ${strong[0]?.length ?? 0})${weak.length ? `, +${weak.length} only via name-based references` : ""} \xB7 ${files.size} files total, ${tests} test files${graph.partial ? " \xB7 partial graph" : ""}`];
|
|
57538
57651
|
strong.forEach((level, d) => {
|
|
57539
57652
|
if (level.length) lines.push(`d${d + 1} (${level.length}): ${listFiles(graph, level, cap)}`);
|
|
57540
57653
|
});
|
|
57541
|
-
if (weak.length) lines.push(
|
|
57654
|
+
if (weak.length) lines.push(`${style === "caveman" ? "name-only" : "name-based only"} (${weak.length}): ${listFiles(graph, weak, Math.max(1, Math.floor(cap / 2)))}`);
|
|
57542
57655
|
if (!strongSet.size && !weak.length) lines.push("nothing in the graph depends on it");
|
|
57543
57656
|
return lines.join("\n");
|
|
57544
57657
|
};
|
|
@@ -57658,6 +57771,7 @@ async function loadGraph(repo) {
|
|
|
57658
57771
|
async function runGraph(repo, request = {}) {
|
|
57659
57772
|
const mode = request.mode ?? "overview";
|
|
57660
57773
|
const budget = request.budget === void 0 ? DEFAULT_GRAPH_BUDGET : checkBudget(request.budget);
|
|
57774
|
+
const style = request.style === "caveman" ? "caveman" : "full";
|
|
57661
57775
|
const { graph } = await loadGraph(repo);
|
|
57662
57776
|
const need = (value, name2) => {
|
|
57663
57777
|
if (!value?.trim()) throw new Error(`${name2} is required for mode ${mode}`);
|
|
@@ -57667,11 +57781,11 @@ async function runGraph(repo, request = {}) {
|
|
|
57667
57781
|
case "overview":
|
|
57668
57782
|
return renderOverview(graph, budget);
|
|
57669
57783
|
case "neighbors":
|
|
57670
|
-
return renderNeighbors(graph, need(request.target, "target"), request.depth ?? 1, budget);
|
|
57784
|
+
return renderNeighbors(graph, need(request.target, "target"), request.depth ?? 1, budget, style);
|
|
57671
57785
|
case "path":
|
|
57672
|
-
return renderPath(graph, need(request.target, "target"), need(request.to, "to"), budget);
|
|
57786
|
+
return renderPath(graph, need(request.target, "target"), need(request.to, "to"), budget, style);
|
|
57673
57787
|
case "impact":
|
|
57674
|
-
return renderImpact(graph, need(request.target, "target"), request.depth ?? 3, budget);
|
|
57788
|
+
return renderImpact(graph, need(request.target, "target"), request.depth ?? 3, budget, style);
|
|
57675
57789
|
case "mermaid":
|
|
57676
57790
|
return renderMermaid(graph, request.target?.trim() || void 0, budget);
|
|
57677
57791
|
case "json":
|
|
@@ -57684,7 +57798,7 @@ async function runGraph(repo, request = {}) {
|
|
|
57684
57798
|
}
|
|
57685
57799
|
|
|
57686
57800
|
// src/mcp.ts
|
|
57687
|
-
var VERSION2 = "
|
|
57801
|
+
var VERSION2 = "3.0.0";
|
|
57688
57802
|
async function serve(root, options = {}) {
|
|
57689
57803
|
const { semanticModel, tools = "core", features } = typeof options === "string" ? { semanticModel: options } : options;
|
|
57690
57804
|
const repo = new Engine(root, { semanticModel, features });
|
|
@@ -57743,11 +57857,12 @@ async function serve(root, options = {}) {
|
|
|
57743
57857
|
target: external_exports.string().optional().describe("File, path suffix or symbol."),
|
|
57744
57858
|
to: external_exports.string().optional().describe("Path end point."),
|
|
57745
57859
|
depth: external_exports.number().optional(),
|
|
57860
|
+
style: external_exports.enum(["full", "caveman"]).optional().describe("caveman: terse, fewer tokens; same paths."),
|
|
57746
57861
|
budget
|
|
57747
57862
|
},
|
|
57748
57863
|
annotations
|
|
57749
57864
|
},
|
|
57750
|
-
async ({ mode, target, to, depth, budget: budget2 }) => result(await runGraph(repo, { mode, target, to, depth, budget: limit(budget2, 1500) }))
|
|
57865
|
+
async ({ mode, target, to, depth, style, budget: budget2 }) => result(await runGraph(repo, { mode, target, to, depth, style, budget: limit(budget2, 1500) }))
|
|
57751
57866
|
);
|
|
57752
57867
|
if (tools === "all") {
|
|
57753
57868
|
server.registerTool(
|
|
@@ -57781,6 +57896,11 @@ For repository questions, call squeze_context (#squeze) with the task and identi
|
|
|
57781
57896
|
|
|
57782
57897
|
Answer concisely: outcome, evidence, verification, limitations. Keep exact code, identifiers and errors; never skip required tests. Reuse evidence ids only while that excerpt is still visible; clear them after context compaction or in a new chat. Do not claim token savings unless measured.
|
|
57783
57898
|
`;
|
|
57899
|
+
var CAVEMAN_RULES = `
|
|
57900
|
+
## Terse replies (caveman style)
|
|
57901
|
+
|
|
57902
|
+
Answer in short fragments. Drop articles, filler, pleasantries and restated questions. Lead with the result, then evidence, then verification and limits. Keep exact code, paths, line ranges, identifiers, error text, warnings and every required step; never shorten those. Use "\u2192" for flows and "\u2190" for dependents. Do not narrate tool calls.
|
|
57903
|
+
`;
|
|
57784
57904
|
|
|
57785
57905
|
// src/cli.ts
|
|
57786
57906
|
var HELP = `Squeze ${VERSION2} \u2014 local, deterministic, token-budgeted repository context
|
|
@@ -57800,7 +57920,7 @@ squeze graph --root REPO --json | --html out.html full export (versioned JSO
|
|
|
57800
57920
|
squeze compact --budget 2000 < test-output.log fold repeated log lines, keep diagnostics
|
|
57801
57921
|
squeze json < data.json smallest verified lossless JSON form
|
|
57802
57922
|
squeze mcp --root REPO [--tools core|all] stdio MCP server (core = context, expand, map, graph)
|
|
57803
|
-
squeze init --root REPO
|
|
57923
|
+
squeze init --root REPO [--style caveman] write .github/instructions/squeze.instructions.md (caveman: terse replies)
|
|
57804
57924
|
|
|
57805
57925
|
Options: --semantic-model all-minilm (opt-in local Ollama embeddings, localhost only)
|
|
57806
57926
|
--features "-prf,-git" | none switch retrieval features off for ablations (also RSQ_FEATURES)
|
|
@@ -57817,7 +57937,8 @@ async function readStdin(limit = 2 * 1024 * 1024) {
|
|
|
57817
57937
|
}
|
|
57818
57938
|
function graphRequest(values, positionals) {
|
|
57819
57939
|
const depth = values.depth === void 0 ? void 0 : Number(values.depth);
|
|
57820
|
-
const
|
|
57940
|
+
const style = values.style === "caveman" ? "caveman" : void 0;
|
|
57941
|
+
const request = { mode: "overview", depth, style };
|
|
57821
57942
|
if (values.neighbors !== void 0) Object.assign(request, { mode: "neighbors", target: values.neighbors });
|
|
57822
57943
|
else if (values.impact !== void 0) Object.assign(request, { mode: "impact", target: values.impact });
|
|
57823
57944
|
else if (values.path !== void 0) Object.assign(request, { mode: "path", target: values.path, to: positionals[1] });
|
|
@@ -57845,6 +57966,7 @@ async function main() {
|
|
|
57845
57966
|
mermaid: { type: "boolean" },
|
|
57846
57967
|
html: { type: "string" },
|
|
57847
57968
|
depth: { type: "string" },
|
|
57969
|
+
style: { type: "string" },
|
|
57848
57970
|
start: { type: "string", default: "1" },
|
|
57849
57971
|
end: { type: "string", default: "100" },
|
|
57850
57972
|
version: { type: "boolean", short: "v" },
|
|
@@ -57870,10 +57992,11 @@ async function main() {
|
|
|
57870
57992
|
if (command === "init") {
|
|
57871
57993
|
const path = (0, import_node_path7.join)(root, ".github/instructions/squeze.instructions.md");
|
|
57872
57994
|
await (0, import_promises6.mkdir)((0, import_node_path7.dirname)(path), { recursive: true });
|
|
57995
|
+
const style = values.style === "caveman" ? CAVEMAN_RULES : "";
|
|
57873
57996
|
await (0, import_promises6.writeFile)(path, `---
|
|
57874
57997
|
applyTo: "**"
|
|
57875
57998
|
---
|
|
57876
|
-
${INSTRUCTIONS}`, { flag: "wx" });
|
|
57999
|
+
${INSTRUCTIONS}${style}`, { flag: "wx" });
|
|
57877
58000
|
console.log(`Created ${path}`);
|
|
57878
58001
|
return;
|
|
57879
58002
|
}
|