@proxysoul/soulforge 2.16.5 → 2.17.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.
@@ -18648,10 +18648,165 @@ var init_file_tree = __esm(() => {
18648
18648
  IGNORED_DIRS = new Set(["node_modules", ".git", "dist", "build", ".next", ".nuxt", "target", "__pycache__", ".cache", ".soulforge", "coverage"]);
18649
18649
  });
18650
18650
 
18651
+ // src/core/intelligence/types.ts
18652
+ function detectLanguageFromPath(file) {
18653
+ const slash = file.lastIndexOf("/");
18654
+ const base = (slash === -1 ? file : file.slice(slash + 1)).toLowerCase();
18655
+ const bare = BARE_FILENAME_TO_LANGUAGE[base];
18656
+ if (bare)
18657
+ return bare;
18658
+ if (base.startsWith("dockerfile."))
18659
+ return "dockerfile";
18660
+ if (base.startsWith("containerfile."))
18661
+ return "dockerfile";
18662
+ if (base.startsWith("makefile."))
18663
+ return "makefile";
18664
+ if (base.startsWith("justfile."))
18665
+ return "just";
18666
+ const dot = base.lastIndexOf(".");
18667
+ if (dot === -1)
18668
+ return "unknown";
18669
+ return EXT_TO_LANGUAGE[base.slice(dot)] ?? "unknown";
18670
+ }
18671
+ var EXT_TO_LANGUAGE, BARE_FILENAME_TO_LANGUAGE;
18672
+ var init_types2 = __esm(() => {
18673
+ EXT_TO_LANGUAGE = {
18674
+ ".ts": "typescript",
18675
+ ".tsx": "typescript",
18676
+ ".mts": "typescript",
18677
+ ".cts": "typescript",
18678
+ ".js": "javascript",
18679
+ ".jsx": "javascript",
18680
+ ".mjs": "javascript",
18681
+ ".cjs": "javascript",
18682
+ ".py": "python",
18683
+ ".pyw": "python",
18684
+ ".go": "go",
18685
+ ".rs": "rust",
18686
+ ".java": "java",
18687
+ ".c": "c",
18688
+ ".h": "c",
18689
+ ".cpp": "cpp",
18690
+ ".cc": "cpp",
18691
+ ".cxx": "cpp",
18692
+ ".hpp": "cpp",
18693
+ ".hh": "cpp",
18694
+ ".hxx": "cpp",
18695
+ ".cs": "csharp",
18696
+ ".rb": "ruby",
18697
+ ".erb": "ruby",
18698
+ ".php": "php",
18699
+ ".swift": "swift",
18700
+ ".kt": "kotlin",
18701
+ ".kts": "kotlin",
18702
+ ".scala": "scala",
18703
+ ".sc": "scala",
18704
+ ".lua": "lua",
18705
+ ".ex": "elixir",
18706
+ ".exs": "elixir",
18707
+ ".dart": "dart",
18708
+ ".zig": "zig",
18709
+ ".sh": "bash",
18710
+ ".bash": "bash",
18711
+ ".zsh": "bash",
18712
+ ".ml": "ocaml",
18713
+ ".mli": "ocaml",
18714
+ ".m": "objc",
18715
+ ".css": "css",
18716
+ ".scss": "css",
18717
+ ".less": "css",
18718
+ ".html": "html",
18719
+ ".htm": "html",
18720
+ ".json": "json",
18721
+ ".jsonc": "json",
18722
+ ".toml": "toml",
18723
+ ".yaml": "yaml",
18724
+ ".yml": "yaml",
18725
+ ".xml": "xml",
18726
+ ".md": "markdown",
18727
+ ".markdown": "markdown",
18728
+ ".mdx": "mdx",
18729
+ ".sql": "sql",
18730
+ ".graphql": "graphql",
18731
+ ".gql": "graphql",
18732
+ ".proto": "proto",
18733
+ ".env": "env",
18734
+ ".ini": "ini",
18735
+ ".cfg": "ini",
18736
+ ".conf": "ini",
18737
+ ".properties": "properties",
18738
+ ".dockerfile": "dockerfile",
18739
+ ".mk": "makefile",
18740
+ ".nix": "nix",
18741
+ ".hcl": "hcl",
18742
+ ".tf": "hcl",
18743
+ ".tfvars": "hcl",
18744
+ ".bzl": "bazel",
18745
+ ".star": "bazel",
18746
+ ".bazel": "bazel",
18747
+ ".jsonnet": "jsonnet",
18748
+ ".libsonnet": "jsonnet",
18749
+ ".svg": "svg",
18750
+ ".csv": "csv",
18751
+ ".tsv": "csv",
18752
+ ".lock": "lockfile",
18753
+ ".lockb": "lockfile",
18754
+ ".vue": "vue",
18755
+ ".res": "rescript",
18756
+ ".resi": "rescript",
18757
+ ".sol": "solidity",
18758
+ ".tla": "tlaplus",
18759
+ ".el": "elisp"
18760
+ };
18761
+ BARE_FILENAME_TO_LANGUAGE = {
18762
+ dockerfile: "dockerfile",
18763
+ containerfile: "dockerfile",
18764
+ makefile: "makefile",
18765
+ gnumakefile: "makefile",
18766
+ justfile: "just",
18767
+ ".justfile": "just",
18768
+ build: "bazel",
18769
+ "build.bazel": "bazel",
18770
+ workspace: "bazel",
18771
+ "workspace.bazel": "bazel",
18772
+ "module.bazel": "bazel",
18773
+ ".env": "env",
18774
+ ".gitignore": "ignore",
18775
+ ".dockerignore": "ignore",
18776
+ ".npmignore": "ignore",
18777
+ ".prettierignore": "ignore",
18778
+ ".eslintignore": "ignore",
18779
+ ".editorconfig": "ini",
18780
+ "bun.lock": "lockfile",
18781
+ "bun.lockb": "lockfile",
18782
+ "package-lock.json": "lockfile",
18783
+ "pnpm-lock.yaml": "lockfile",
18784
+ "yarn.lock": "lockfile",
18785
+ "cargo.lock": "lockfile",
18786
+ "poetry.lock": "lockfile",
18787
+ "composer.lock": "lockfile",
18788
+ "gemfile.lock": "lockfile",
18789
+ "go.sum": "lockfile",
18790
+ gemfile: "ruby",
18791
+ rakefile: "ruby",
18792
+ podfile: "ruby"
18793
+ };
18794
+ });
18795
+
18651
18796
  // src/core/intelligence/repo-map-utils.ts
18652
18797
  import { readdir, stat } from "fs/promises";
18653
18798
  import { homedir as homedir2 } from "os";
18654
- import { extname, join as join4, resolve as resolve2 } from "path";
18799
+ import { join as join4, resolve as resolve2 } from "path";
18800
+ function isIndexablePath(file) {
18801
+ return detectLanguageFromPath(file) !== "unknown" || isBareIndexable(file);
18802
+ }
18803
+ function isBareIndexable(file) {
18804
+ const slash = file.lastIndexOf("/");
18805
+ const base = (slash === -1 ? file : file.slice(slash + 1)).toLowerCase();
18806
+ if (BARE_FILENAME_TO_LANGUAGE[base])
18807
+ return true;
18808
+ return base.startsWith("dockerfile.") || base.startsWith("containerfile.") || base.startsWith("makefile.") || base.startsWith("justfile.");
18809
+ }
18655
18810
  function barrelToDir(barrelPath) {
18656
18811
  return barrelPath.replace(BARREL_RE, "");
18657
18812
  }
@@ -18863,8 +19018,7 @@ async function collectFilesViaGit(dir) {
18863
19018
  `)) {
18864
19019
  if (!line)
18865
19020
  continue;
18866
- const ext = extname(line).toLowerCase();
18867
- if (!(ext in INDEXABLE_EXTENSIONS))
19021
+ if (!isIndexablePath(line))
18868
19022
  continue;
18869
19023
  const fullPath = join4(dir, line);
18870
19024
  if (isForbidden(fullPath))
@@ -18898,8 +19052,10 @@ async function collectFilesWalk(dir, depth, counter, out2) {
18898
19052
  })) {
18899
19053
  if (ctx.n >= WALK_FILE_CAP)
18900
19054
  break;
18901
- if (entry.name.startsWith(".") && entry.name !== ".")
18902
- continue;
19055
+ if (entry.name.startsWith(".") && entry.name !== ".") {
19056
+ if (!entry.isFile() || !isIndexablePath(entry.name))
19057
+ continue;
19058
+ }
18903
19059
  const fullPath = join4(dir, entry.name);
18904
19060
  if (entry.isDirectory()) {
18905
19061
  if (!IGNORED_DIRS.has(entry.name)) {
@@ -18908,8 +19064,7 @@ async function collectFilesWalk(dir, depth, counter, out2) {
18908
19064
  } else if (entry.isFile()) {
18909
19065
  if (isForbidden(fullPath))
18910
19066
  continue;
18911
- const ext = extname(entry.name).toLowerCase();
18912
- if (ext in INDEXABLE_EXTENSIONS) {
19067
+ if (isIndexablePath(entry.name)) {
18913
19068
  try {
18914
19069
  const s2 = await stat(fullPath);
18915
19070
  if (s2.size < MAX_FILE_SIZE) {
@@ -18932,157 +19087,14 @@ var INDEXABLE_EXTENSIONS, NON_CODE_LANGUAGES, IMPORT_TRACKABLE_LANGUAGES, BARREL
18932
19087
  var init_repo_map_utils = __esm(() => {
18933
19088
  init_file_tree();
18934
19089
  init_forbidden();
18935
- INDEXABLE_EXTENSIONS = {
18936
- ".ts": "typescript",
18937
- ".tsx": "typescript",
18938
- ".mts": "typescript",
18939
- ".cts": "typescript",
18940
- ".js": "javascript",
18941
- ".jsx": "javascript",
18942
- ".mjs": "javascript",
18943
- ".cjs": "javascript",
18944
- ".py": "python",
18945
- ".go": "go",
18946
- ".rs": "rust",
18947
- ".java": "java",
18948
- ".c": "c",
18949
- ".h": "c",
18950
- ".cpp": "cpp",
18951
- ".cc": "cpp",
18952
- ".cxx": "cpp",
18953
- ".hpp": "cpp",
18954
- ".hh": "cpp",
18955
- ".hxx": "cpp",
18956
- ".cs": "csharp",
18957
- ".rb": "ruby",
18958
- ".php": "php",
18959
- ".swift": "swift",
18960
- ".kt": "kotlin",
18961
- ".kts": "kotlin",
18962
- ".scala": "scala",
18963
- ".sc": "scala",
18964
- ".lua": "lua",
18965
- ".ex": "elixir",
18966
- ".exs": "elixir",
18967
- ".dart": "dart",
18968
- ".zig": "zig",
18969
- ".sh": "bash",
18970
- ".bash": "bash",
18971
- ".zsh": "bash",
18972
- ".ml": "ocaml",
18973
- ".mli": "ocaml",
18974
- ".m": "objc",
18975
- ".el": "elisp",
18976
- ".res": "rescript",
18977
- ".resi": "rescript",
18978
- ".sol": "solidity",
18979
- ".tla": "tlaplus",
18980
- ".vue": "vue",
18981
- ".pyw": "python",
18982
- ".erb": "ruby",
18983
- ".json": "unknown",
18984
- ".jsonc": "unknown",
18985
- ".yaml": "unknown",
18986
- ".yml": "unknown",
18987
- ".toml": "unknown",
18988
- ".xml": "unknown",
18989
- ".md": "unknown",
18990
- ".css": "css",
18991
- ".scss": "css",
18992
- ".less": "css",
18993
- ".html": "html",
18994
- ".htm": "html",
18995
- ".sql": "unknown",
18996
- ".graphql": "unknown",
18997
- ".gql": "unknown",
18998
- ".proto": "unknown",
18999
- ".env": "unknown",
19000
- ".conf": "unknown",
19001
- ".ini": "unknown",
19002
- ".cfg": "unknown",
19003
- ".dockerfile": "unknown"
19004
- };
19005
- NON_CODE_LANGUAGES = new Set(["unknown", "css", "html", "json", "toml", "yaml", "dockerfile"]);
19090
+ init_types2();
19091
+ INDEXABLE_EXTENSIONS = EXT_TO_LANGUAGE;
19092
+ NON_CODE_LANGUAGES = new Set(["unknown", "css", "html", "json", "jsonnet", "toml", "yaml", "xml", "markdown", "mdx", "sql", "graphql", "proto", "properties", "ini", "env", "dockerfile", "makefile", "nix", "hcl", "bazel", "just", "svg", "csv", "ignore", "lockfile"]);
19006
19093
  IMPORT_TRACKABLE_LANGUAGES = new Set(["typescript", "javascript", "python", "go", "rust", "java", "c", "cpp", "csharp", "ruby", "php", "swift", "kotlin", "scala", "dart", "ocaml", "objc", "solidity"]);
19007
19094
  BARREL_RE = /\/(index\.(ts|js|tsx|mts|mjs)|__init__\.py|mod\.rs)$/;
19008
19095
  DANGEROUS_ROOTS = new Set([resolve2(homedir2()), "/", "/tmp", "/var", "/usr", "/opt", "/home", "/Users"]);
19009
19096
  });
19010
19097
 
19011
- // src/core/intelligence/types.ts
19012
- function detectLanguageFromPath(file) {
19013
- const dot = file.lastIndexOf(".");
19014
- if (dot === -1) {
19015
- const name2 = file.slice(file.lastIndexOf("/") + 1);
19016
- if (name2 === "Dockerfile" || name2.startsWith("Dockerfile."))
19017
- return "dockerfile";
19018
- return "unknown";
19019
- }
19020
- return EXT_TO_LANGUAGE[file.slice(dot).toLowerCase()] ?? "unknown";
19021
- }
19022
- var EXT_TO_LANGUAGE;
19023
- var init_types2 = __esm(() => {
19024
- EXT_TO_LANGUAGE = {
19025
- ".ts": "typescript",
19026
- ".tsx": "typescript",
19027
- ".mts": "typescript",
19028
- ".cts": "typescript",
19029
- ".js": "javascript",
19030
- ".jsx": "javascript",
19031
- ".mjs": "javascript",
19032
- ".cjs": "javascript",
19033
- ".py": "python",
19034
- ".pyw": "python",
19035
- ".go": "go",
19036
- ".rs": "rust",
19037
- ".java": "java",
19038
- ".c": "c",
19039
- ".h": "c",
19040
- ".cpp": "cpp",
19041
- ".cc": "cpp",
19042
- ".cxx": "cpp",
19043
- ".hpp": "cpp",
19044
- ".hh": "cpp",
19045
- ".hxx": "cpp",
19046
- ".cs": "csharp",
19047
- ".rb": "ruby",
19048
- ".erb": "ruby",
19049
- ".php": "php",
19050
- ".swift": "swift",
19051
- ".kt": "kotlin",
19052
- ".kts": "kotlin",
19053
- ".scala": "scala",
19054
- ".sc": "scala",
19055
- ".lua": "lua",
19056
- ".ex": "elixir",
19057
- ".exs": "elixir",
19058
- ".dart": "dart",
19059
- ".zig": "zig",
19060
- ".sh": "bash",
19061
- ".bash": "bash",
19062
- ".zsh": "bash",
19063
- ".ml": "ocaml",
19064
- ".mli": "ocaml",
19065
- ".m": "objc",
19066
- ".css": "css",
19067
- ".scss": "css",
19068
- ".less": "css",
19069
- ".html": "html",
19070
- ".htm": "html",
19071
- ".json": "json",
19072
- ".jsonc": "json",
19073
- ".toml": "toml",
19074
- ".yaml": "yaml",
19075
- ".yml": "yaml",
19076
- ".dockerfile": "dockerfile",
19077
- ".vue": "vue",
19078
- ".res": "rescript",
19079
- ".resi": "rescript",
19080
- ".sol": "solidity",
19081
- ".tla": "tlaplus",
19082
- ".el": "elisp"
19083
- };
19084
- });
19085
-
19086
19098
  // node_modules/web-tree-sitter/tree-sitter.js
19087
19099
  var exports_tree_sitter = {};
19088
19100
  __export(exports_tree_sitter, {
@@ -24204,9 +24216,9 @@ __export(exports_repo_map, {
24204
24216
  });
24205
24217
  import { Database } from "bun:sqlite";
24206
24218
  import { execSync as execSync2 } from "child_process";
24207
- import { chmodSync, existsSync as existsSync4, readFileSync as readFileSync3, statSync } from "fs";
24219
+ import { chmodSync, existsSync as existsSync4, readdirSync as readdirSync2, readFileSync as readFileSync3, statSync } from "fs";
24208
24220
  import { stat as statAsync } from "fs/promises";
24209
- import { dirname as dirname2, extname as extname2, join as join6, relative, resolve as resolve4 } from "path";
24221
+ import { dirname as dirname2, extname, join as join6, relative, resolve as resolve4 } from "path";
24210
24222
 
24211
24223
  class RepoMap {
24212
24224
  static testFileMatch(alias = "f") {
@@ -24303,6 +24315,7 @@ class RepoMap {
24303
24315
  weight REAL NOT NULL DEFAULT 1.0,
24304
24316
  PRIMARY KEY (source_file_id, target_file_id)
24305
24317
  );
24318
+ CREATE INDEX IF NOT EXISTS idx_edges_target ON edges(target_file_id);
24306
24319
  `);
24307
24320
  this.db.run(`
24308
24321
  CREATE TABLE IF NOT EXISTS refs (
@@ -24539,8 +24552,7 @@ class RepoMap {
24539
24552
  const existing = existingFiles.get(relPath);
24540
24553
  if (existing && existing.mtime_ms === file.mtimeMs)
24541
24554
  continue;
24542
- const ext = extname2(file.path).toLowerCase();
24543
- const language = INDEXABLE_EXTENSIONS[ext] ?? "unknown";
24555
+ const language = detectLanguageFromPath(file.path);
24544
24556
  toIndex.push({
24545
24557
  absPath: file.path,
24546
24558
  relPath,
@@ -25059,7 +25071,7 @@ class RepoMap {
25059
25071
  const candidates = [base];
25060
25072
  if (stripped !== relBase)
25061
25073
  candidates.push(join6(this.cwd, relBase));
25062
- const ext = extname2(stripped);
25074
+ const ext = extname(stripped);
25063
25075
  if (!ext) {
25064
25076
  for (const tryExt of Object.keys(INDEXABLE_EXTENSIONS)) {
25065
25077
  candidates.push(base + tryExt);
@@ -25498,15 +25510,18 @@ class RepoMap {
25498
25510
  }
25499
25511
  async computePageRank(personalization) {
25500
25512
  const tick = () => new Promise((r4) => setTimeout(r4, 1));
25501
- const files = this.db.query("SELECT id FROM files").all();
25513
+ const files = this.db.query("SELECT id, pagerank, language FROM files").all();
25502
25514
  if (files.length === 0)
25503
25515
  return;
25504
25516
  const n = files.length;
25505
25517
  const idToIdx = new Map;
25506
25518
  const ids = [];
25519
+ const isCode = new Array(n);
25507
25520
  for (const file of files) {
25508
- idToIdx.set(file.id, ids.length);
25521
+ const idx = ids.length;
25522
+ idToIdx.set(file.id, idx);
25509
25523
  ids.push(file.id);
25524
+ isCode[idx] = !NON_CODE_LANGUAGES.has(file.language);
25510
25525
  }
25511
25526
  const outWeight = new Array(n).fill(0);
25512
25527
  const adj = [];
@@ -25526,34 +25541,51 @@ class RepoMap {
25526
25541
  }
25527
25542
  }
25528
25543
  const pv = new Float64Array(n);
25529
- const uniform = 1 / n;
25544
+ let codeCount = 0;
25545
+ for (let i4 = 0;i4 < n; i4++)
25546
+ if (isCode[i4])
25547
+ codeCount++;
25548
+ const uniform = codeCount > 0 ? 1 / codeCount : 1 / n;
25530
25549
  if (personalization && personalization.size > 0) {
25531
25550
  let boostSum = 0;
25532
25551
  for (const [fileId, boost] of personalization) {
25533
25552
  const idx = idToIdx.get(fileId);
25534
- if (idx !== undefined) {
25553
+ if (idx !== undefined && isCode[idx]) {
25535
25554
  pv[idx] = boost;
25536
25555
  boostSum += boost;
25537
25556
  }
25538
25557
  }
25539
25558
  if (boostSum > 0) {
25540
25559
  for (let i4 = 0;i4 < n; i4++) {
25541
- pv[i4] = 0.7 * uniform + 0.3 * ((pv[i4] ?? 0) / boostSum);
25560
+ pv[i4] = isCode[i4] ? 0.7 * uniform + 0.3 * ((pv[i4] ?? 0) / boostSum) : 0;
25542
25561
  }
25543
25562
  } else {
25544
- pv.fill(uniform);
25563
+ for (let i4 = 0;i4 < n; i4++)
25564
+ pv[i4] = isCode[i4] ? uniform : 0;
25545
25565
  }
25546
25566
  } else {
25547
- pv.fill(uniform);
25567
+ for (let i4 = 0;i4 < n; i4++)
25568
+ pv[i4] = isCode[i4] ? uniform : 0;
25569
+ }
25570
+ let priorSum = 0;
25571
+ for (let i4 = 0;i4 < n; i4++)
25572
+ if (isCode[i4])
25573
+ priorSum += files[i4]?.pagerank || 0;
25574
+ let rank = new Float64Array(n);
25575
+ if (priorSum > 0.5 && priorSum < 1.5) {
25576
+ for (let i4 = 0;i4 < n; i4++)
25577
+ rank[i4] = isCode[i4] ? files[i4]?.pagerank ?? uniform : 0;
25578
+ } else {
25579
+ for (let i4 = 0;i4 < n; i4++)
25580
+ rank[i4] = isCode[i4] ? uniform : 0;
25548
25581
  }
25549
- let rank = new Float64Array(n).fill(1 / n);
25550
25582
  let next = new Float64Array(n);
25551
25583
  for (let iter = 0;iter < PAGERANK_ITERATIONS; iter++) {
25552
25584
  for (let j2 = 0;j2 < n; j2++)
25553
25585
  next[j2] = (1 - PAGERANK_DAMPING) * (pv[j2] ?? 0);
25554
25586
  let danglingSum = 0;
25555
25587
  for (let i4 = 0;i4 < n; i4++) {
25556
- if ((outWeight[i4] ?? 0) === 0)
25588
+ if (isCode[i4] && (outWeight[i4] ?? 0) === 0)
25557
25589
  danglingSum += rank[i4] ?? 0;
25558
25590
  }
25559
25591
  for (let j2 = 0;j2 < n; j2++) {
@@ -25567,9 +25599,14 @@ class RepoMap {
25567
25599
  const contribution = PAGERANK_DAMPING * (rank[from] ?? 0) * weight / (outWeight[from] ?? 1);
25568
25600
  next[to] = (next[to] ?? 0) + contribution;
25569
25601
  }
25602
+ let delta = 0;
25603
+ for (let i4 = 0;i4 < n; i4++)
25604
+ delta += Math.abs((next[i4] ?? 0) - (rank[i4] ?? 0));
25570
25605
  [rank, next] = [next, rank];
25571
25606
  if (iter % 5 === 4)
25572
25607
  await tick();
25608
+ if (delta < 0.000001)
25609
+ break;
25573
25610
  }
25574
25611
  const update = this.db.prepare("UPDATE files SET pagerank = ? WHERE id = ?");
25575
25612
  const tx = this.db.transaction(() => {
@@ -25582,15 +25619,18 @@ class RepoMap {
25582
25619
  } catch {}
25583
25620
  }
25584
25621
  computePageRankSync(personalization) {
25585
- const files = this.db.query("SELECT id FROM files").all();
25622
+ const files = this.db.query("SELECT id, pagerank, language FROM files").all();
25586
25623
  if (files.length === 0)
25587
25624
  return;
25588
25625
  const n = files.length;
25589
25626
  const idToIdx = new Map;
25590
25627
  const ids = [];
25628
+ const isCode = new Array(n);
25591
25629
  for (const file of files) {
25592
- idToIdx.set(file.id, ids.length);
25630
+ const idx = ids.length;
25631
+ idToIdx.set(file.id, idx);
25593
25632
  ids.push(file.id);
25633
+ isCode[idx] = !NON_CODE_LANGUAGES.has(file.language);
25594
25634
  }
25595
25635
  const outWeight = new Array(n).fill(0);
25596
25636
  const adj = [];
@@ -25610,34 +25650,51 @@ class RepoMap {
25610
25650
  }
25611
25651
  }
25612
25652
  const pv = new Float64Array(n);
25613
- const uniform = 1 / n;
25653
+ let codeCount = 0;
25654
+ for (let i4 = 0;i4 < n; i4++)
25655
+ if (isCode[i4])
25656
+ codeCount++;
25657
+ const uniform = codeCount > 0 ? 1 / codeCount : 1 / n;
25614
25658
  if (personalization && personalization.size > 0) {
25615
25659
  let boostSum = 0;
25616
25660
  for (const [fileId, boost] of personalization) {
25617
25661
  const idx = idToIdx.get(fileId);
25618
- if (idx !== undefined) {
25662
+ if (idx !== undefined && isCode[idx]) {
25619
25663
  pv[idx] = boost;
25620
25664
  boostSum += boost;
25621
25665
  }
25622
25666
  }
25623
25667
  if (boostSum > 0) {
25624
25668
  for (let i4 = 0;i4 < n; i4++) {
25625
- pv[i4] = 0.7 * uniform + 0.3 * ((pv[i4] ?? 0) / boostSum);
25669
+ pv[i4] = isCode[i4] ? 0.7 * uniform + 0.3 * ((pv[i4] ?? 0) / boostSum) : 0;
25626
25670
  }
25627
25671
  } else {
25628
- pv.fill(uniform);
25672
+ for (let i4 = 0;i4 < n; i4++)
25673
+ pv[i4] = isCode[i4] ? uniform : 0;
25629
25674
  }
25630
25675
  } else {
25631
- pv.fill(uniform);
25676
+ for (let i4 = 0;i4 < n; i4++)
25677
+ pv[i4] = isCode[i4] ? uniform : 0;
25678
+ }
25679
+ let priorSum = 0;
25680
+ for (let i4 = 0;i4 < n; i4++)
25681
+ if (isCode[i4])
25682
+ priorSum += files[i4]?.pagerank || 0;
25683
+ let rank = new Float64Array(n);
25684
+ if (priorSum > 0.5 && priorSum < 1.5) {
25685
+ for (let i4 = 0;i4 < n; i4++)
25686
+ rank[i4] = isCode[i4] ? files[i4]?.pagerank ?? uniform : 0;
25687
+ } else {
25688
+ for (let i4 = 0;i4 < n; i4++)
25689
+ rank[i4] = isCode[i4] ? uniform : 0;
25632
25690
  }
25633
- let rank = new Float64Array(n).fill(1 / n);
25634
25691
  let next = new Float64Array(n);
25635
25692
  for (let iter = 0;iter < PAGERANK_ITERATIONS; iter++) {
25636
25693
  for (let j2 = 0;j2 < n; j2++)
25637
25694
  next[j2] = (1 - PAGERANK_DAMPING) * (pv[j2] ?? 0);
25638
25695
  let danglingSum = 0;
25639
25696
  for (let i4 = 0;i4 < n; i4++) {
25640
- if ((outWeight[i4] ?? 0) === 0)
25697
+ if (isCode[i4] && (outWeight[i4] ?? 0) === 0)
25641
25698
  danglingSum += rank[i4] ?? 0;
25642
25699
  }
25643
25700
  for (let j2 = 0;j2 < n; j2++) {
@@ -25651,7 +25708,12 @@ class RepoMap {
25651
25708
  const contribution = PAGERANK_DAMPING * (rank[from] ?? 0) * weight / (outWeight[from] ?? 1);
25652
25709
  next[to] = (next[to] ?? 0) + contribution;
25653
25710
  }
25711
+ let delta = 0;
25712
+ for (let i4 = 0;i4 < n; i4++)
25713
+ delta += Math.abs((next[i4] ?? 0) - (rank[i4] ?? 0));
25654
25714
  [rank, next] = [next, rank];
25715
+ if (delta < 0.000001)
25716
+ break;
25655
25717
  }
25656
25718
  const update = this.db.prepare("UPDATE files SET pagerank = ? WHERE id = ?");
25657
25719
  const tx = this.db.transaction(() => {
@@ -25820,15 +25882,36 @@ class RepoMap {
25820
25882
  "manage.py",
25821
25883
  "src/main/java/Main.java",
25822
25884
  "src/main/kotlin/Main.kt",
25885
+ "src/main/scala/Main.scala",
25823
25886
  "Sources/main.swift",
25824
25887
  "Sources/App.swift",
25825
25888
  "src/main.c",
25826
25889
  "src/main.cpp",
25890
+ "Program.cs",
25827
25891
  "lib/main.dart",
25828
25892
  "lib/application.ex",
25829
25893
  "app.rb",
25830
- "config.ru"
25894
+ "config.ru",
25895
+ "public/index.php",
25896
+ "artisan",
25897
+ "bin/console",
25898
+ "index.php",
25899
+ "src/main.zig",
25900
+ "build.zig",
25901
+ "app/Main.hs",
25902
+ "src/Main.hs",
25903
+ "Main.hs",
25904
+ "src/Main.elm"
25831
25905
  ];
25906
+ try {
25907
+ const binsDir = join6(this.cwd, "src", "bin");
25908
+ if (existsSync4(binsDir)) {
25909
+ for (const entry of readdirSync2(binsDir)) {
25910
+ if (entry.endsWith(".rs"))
25911
+ commonEntryPoints.push(`src/bin/${entry}`);
25912
+ }
25913
+ }
25914
+ } catch {}
25832
25915
  for (const p2 of commonEntryPoints) {
25833
25916
  if (existsSync4(join6(this.cwd, p2)))
25834
25917
  this.entryPointsCache.push(p2);
@@ -26164,7 +26247,7 @@ class RepoMap {
26164
26247
  if (relPath === "package.json" || relPath === "Cargo.toml" || relPath === "go.mod") {
26165
26248
  this.entryPointsCache = null;
26166
26249
  }
26167
- const ext = extname2(absPath).toLowerCase();
26250
+ const ext = extname(absPath).toLowerCase();
26168
26251
  const language = INDEXABLE_EXTENSIONS[ext];
26169
26252
  if (!language)
26170
26253
  return;
@@ -26777,10 +26860,14 @@ class RepoMap {
26777
26860
  const blastRadius = this.db.query("SELECT COUNT(DISTINCT source_file_id) AS c FROM edges WHERE target_file_id = ?").get(fileRow.id)?.c ?? 0;
26778
26861
  const symbols = this.db.query(`SELECT s.name, s.kind, s.signature, s.line
26779
26862
  FROM symbols s
26863
+ LEFT JOIN (
26864
+ SELECT callee_symbol_id, COUNT(*) AS c FROM calls
26865
+ WHERE callee_symbol_id IS NOT NULL GROUP BY callee_symbol_id
26866
+ ) cc ON cc.callee_symbol_id = s.id
26780
26867
  WHERE s.file_id = ?
26781
26868
  AND s.is_exported = 1
26782
26869
  AND s.kind IN ('interface','type','class','function','enum','method')
26783
- ORDER BY s.line
26870
+ ORDER BY COALESCE(cc.c, 0) DESC, s.line ASC
26784
26871
  LIMIT 10`).all(fileRow.id);
26785
26872
  return {
26786
26873
  blastRadius,
@@ -26949,7 +27036,7 @@ class RepoMap {
26949
27036
  ORDER BY f.pagerank DESC
26950
27037
  LIMIT ?`).all(limit);
26951
27038
  const trackable = rows.filter((row) => {
26952
- const ext = extname2(row.path).toLowerCase();
27039
+ const ext = extname(row.path).toLowerCase();
26953
27040
  const lang254 = INDEXABLE_EXTENSIONS[ext];
26954
27041
  return lang254 != null && IMPORT_TRACKABLE_LANGUAGES.has(lang254);
26955
27042
  });
@@ -27713,6 +27800,9 @@ class RepoMap {
27713
27800
  this.onError?.(`error awaiting pending flush during close: ${e instanceof Error ? e.message : String(e)}`);
27714
27801
  }
27715
27802
  }
27803
+ try {
27804
+ this.db.run("PRAGMA optimize");
27805
+ } catch {}
27716
27806
  this.db.close();
27717
27807
  }
27718
27808
  metaGet(key2) {
@@ -27769,6 +27859,7 @@ var init_repo_map = __esm(() => {
27769
27859
  init_clone_detection();
27770
27860
  init_repo_map_constants();
27771
27861
  init_repo_map_utils();
27862
+ init_types2();
27772
27863
  });
27773
27864
 
27774
27865
  // src/core/intelligence/cache.ts
@@ -27823,8 +27914,8 @@ var exports_router = {};
27823
27914
  __export(exports_router, {
27824
27915
  CodeIntelligenceRouter: () => CodeIntelligenceRouter
27825
27916
  });
27826
- import { existsSync as existsSync5, readdirSync as readdirSync2 } from "fs";
27827
- import { extname as extname3, join as join7 } from "path";
27917
+ import { existsSync as existsSync5, readdirSync as readdirSync3 } from "fs";
27918
+ import { extname as extname2, join as join7 } from "path";
27828
27919
 
27829
27920
  class CodeIntelligenceRouter {
27830
27921
  backends = [];
@@ -27849,7 +27940,7 @@ class CodeIntelligenceRouter {
27849
27940
  return lang254;
27850
27941
  }
27851
27942
  if (file) {
27852
- const ext = extname3(file).toLowerCase();
27943
+ const ext = extname2(file).toLowerCase();
27853
27944
  const lang254 = EXT_TO_LANGUAGE[ext];
27854
27945
  if (lang254)
27855
27946
  return lang254;
@@ -28000,7 +28091,7 @@ class CodeIntelligenceRouter {
28000
28091
  break;
28001
28092
  visited++;
28002
28093
  try {
28003
- const entries = readdirSync2(item.dir, {
28094
+ const entries = readdirSync3(item.dir, {
28004
28095
  withFileTypes: true
28005
28096
  });
28006
28097
  for (const entry of entries) {
@@ -28050,7 +28141,7 @@ class CodeIntelligenceRouter {
28050
28141
  break;
28051
28142
  visited++;
28052
28143
  try {
28053
- const entries = readdirSync2(item.dir, {
28144
+ const entries = readdirSync3(item.dir, {
28054
28145
  withFileTypes: true
28055
28146
  });
28056
28147
  for (const entry of entries) {
@@ -30482,7 +30573,7 @@ var exports_lsp = {};
30482
30573
  __export(exports_lsp, {
30483
30574
  LspBackend: () => LspBackend
30484
30575
  });
30485
- import { existsSync as existsSync9, readdirSync as readdirSync3 } from "fs";
30576
+ import { existsSync as existsSync9, readdirSync as readdirSync4 } from "fs";
30486
30577
  import { readdir as readdir2, readFile as readFile4 } from "fs/promises";
30487
30578
  import { dirname as dirname3, join as join11, resolve as resolve5 } from "path";
30488
30579
  function getNvimBridge() {
@@ -31665,7 +31756,7 @@ function findProjectRootForLanguage(file, language) {
31665
31756
  const nameMarkers = markers.filter((m3) => !m3.startsWith(".") || m3.includes("/"));
31666
31757
  if (extMarkers.length > 0) {
31667
31758
  try {
31668
- const entries = readdirSync3(dir);
31759
+ const entries = readdirSync4(dir);
31669
31760
  for (const marker of extMarkers) {
31670
31761
  if (entries.some((e) => e.endsWith(marker)))
31671
31762
  return dir;
@@ -203204,7 +203295,7 @@ var require_path_browserify = __commonJS((exports, module2) => {
203204
203295
  return path.slice(start2, end);
203205
203296
  }
203206
203297
  },
203207
- extname: function extname4(path) {
203298
+ extname: function extname3(path) {
203208
203299
  assertPath(path);
203209
203300
  var startDot = -1;
203210
203301
  var startPart = 0;
@@ -280965,6 +281056,7 @@ var handlers = {
280965
281056
  },
280966
281057
  onFileChanged: (absPath) => requireRepoMap().onFileChanged(absPath),
280967
281058
  recheckModifiedFiles: () => requireRepoMap().recheckModifiedFiles(),
281059
+ getEntryPoints: () => requireRepoMap().getEntryPoints(),
280968
281060
  render: (opts) => {
280969
281061
  const repoMap2 = requireRepoMap();
280970
281062
  const content = repoMap2.render(opts);