weavatrix 0.2.12 → 0.2.14

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.
Files changed (132) hide show
  1. package/README.md +90 -21
  2. package/SECURITY.md +2 -2
  3. package/docs/releases/v0.2.14.md +93 -0
  4. package/package.json +2 -2
  5. package/skill/SKILL.md +108 -43
  6. package/src/analysis/allowed-test-runner.js +20 -9
  7. package/src/analysis/architecture/contract-graph.js +119 -0
  8. package/src/analysis/architecture/contract-schema.js +110 -0
  9. package/src/analysis/architecture/contract-storage.js +35 -0
  10. package/src/analysis/architecture/contract-verification.js +168 -0
  11. package/src/analysis/architecture-contract.js +16 -343
  12. package/src/analysis/change-classification/diff-parser.js +103 -0
  13. package/src/analysis/change-classification/options.js +40 -0
  14. package/src/analysis/change-classification/symbol-classifier.js +177 -0
  15. package/src/analysis/change-classification.js +120 -519
  16. package/src/analysis/dead-code-review/policy.js +23 -0
  17. package/src/analysis/dead-code-review.js +9 -19
  18. package/src/analysis/dep-check.js +10 -57
  19. package/src/analysis/dep-rules.js +10 -303
  20. package/src/analysis/dependency/scoped-dependencies.js +40 -0
  21. package/src/analysis/endpoints/common.js +62 -0
  22. package/src/analysis/endpoints/extract.js +107 -0
  23. package/src/analysis/endpoints/inventory.js +84 -0
  24. package/src/analysis/endpoints/mounts.js +129 -0
  25. package/src/analysis/endpoints-java.js +80 -3
  26. package/src/analysis/endpoints.js +3 -448
  27. package/src/analysis/git-history/analytics.js +177 -0
  28. package/src/analysis/git-history/collector.js +109 -0
  29. package/src/analysis/git-history/options.js +68 -0
  30. package/src/analysis/git-history.js +128 -577
  31. package/src/analysis/health-capabilities.js +82 -0
  32. package/src/analysis/http-contracts/analysis.js +169 -0
  33. package/src/analysis/http-contracts/client-call-detection.js +81 -0
  34. package/src/analysis/http-contracts/client-call-parser.js +255 -0
  35. package/src/analysis/http-contracts/graph-context.js +143 -0
  36. package/src/analysis/http-contracts/matching.js +61 -0
  37. package/src/analysis/http-contracts/shared.js +86 -0
  38. package/src/analysis/http-contracts.js +6 -822
  39. package/src/analysis/internal-audit/dependency-health.js +111 -0
  40. package/src/analysis/internal-audit/python-manifests.js +65 -0
  41. package/src/analysis/internal-audit/repo-files.js +55 -0
  42. package/src/analysis/internal-audit/supply-chain.js +132 -0
  43. package/src/analysis/internal-audit.collect.js +5 -106
  44. package/src/analysis/internal-audit.run.js +113 -200
  45. package/src/analysis/jvm-dependency-evidence.js +69 -0
  46. package/src/analysis/source-correctness/retry-patterns.js +93 -0
  47. package/src/analysis/source-correctness.js +225 -0
  48. package/src/analysis/structure/dependency-graph.js +156 -0
  49. package/src/analysis/structure/findings.js +142 -0
  50. package/src/graph/builder/go-receiver-resolution.js +112 -0
  51. package/src/graph/builder/js/queries.js +48 -0
  52. package/src/graph/builder/lang-go.js +89 -4
  53. package/src/graph/builder/lang-js.js +4 -44
  54. package/src/graph/builder/pass2-resolution.js +68 -0
  55. package/src/graph/freshness-probe.js +2 -1
  56. package/src/graph/incremental-refresh.js +3 -2
  57. package/src/graph/internal-builder.build.js +22 -183
  58. package/src/graph/internal-builder.pass2.js +161 -0
  59. package/src/graph/internal-builder.resolvers.js +2 -105
  60. package/src/graph/resolvers/rust.js +117 -0
  61. package/src/mcp/actions/advisories.mjs +18 -0
  62. package/src/mcp/actions/graph-lifecycle.mjs +148 -0
  63. package/src/mcp/actions/graph-sync.mjs +195 -0
  64. package/src/mcp/actions/hosted-architecture.mjs +57 -0
  65. package/src/mcp/architecture-bootstrap.mjs +168 -0
  66. package/src/mcp/architecture-starter.mjs +234 -0
  67. package/src/mcp/catalog.mjs +22 -6
  68. package/src/mcp/evidence/bun-lock-graph.mjs +209 -0
  69. package/src/mcp/evidence/package-graph-common.mjs +115 -0
  70. package/src/mcp/evidence/package-lock-graph.mjs +92 -0
  71. package/src/mcp/evidence-snapshot.package-graph.mjs +5 -474
  72. package/src/mcp/graph/context-core.mjs +111 -0
  73. package/src/mcp/graph/context-seeds.mjs +208 -0
  74. package/src/mcp/graph/context-state.mjs +86 -0
  75. package/src/mcp/graph/tools-core.mjs +143 -0
  76. package/src/mcp/graph/tools-query.mjs +223 -0
  77. package/src/mcp/graph-context.mjs +4 -496
  78. package/src/mcp/health/audit-format.mjs +172 -0
  79. package/src/mcp/health/audit.mjs +171 -0
  80. package/src/mcp/health/dead-code.mjs +110 -0
  81. package/src/mcp/health/duplicates.mjs +83 -0
  82. package/src/mcp/health/endpoints.mjs +42 -0
  83. package/src/mcp/health/structure.mjs +219 -0
  84. package/src/mcp/runtime-version.mjs +32 -0
  85. package/src/mcp/server/auto-refresh.mjs +66 -0
  86. package/src/mcp/server/runtime-config.mjs +43 -0
  87. package/src/mcp/server/shutdown.mjs +40 -0
  88. package/src/mcp/sync/evidence-architecture.mjs +54 -0
  89. package/src/mcp/sync/evidence-common.mjs +88 -0
  90. package/src/mcp/sync/evidence-duplicates.mjs +100 -0
  91. package/src/mcp/sync/evidence-health.mjs +56 -0
  92. package/src/mcp/sync/evidence-packages.mjs +95 -0
  93. package/src/mcp/sync/payload-common.mjs +97 -0
  94. package/src/mcp/sync/payload-v2.mjs +53 -0
  95. package/src/mcp/sync/payload-v3.mjs +79 -0
  96. package/src/mcp/sync-evidence.mjs +7 -402
  97. package/src/mcp/sync-payload.mjs +10 -244
  98. package/src/mcp/tools-actions.mjs +18 -414
  99. package/src/mcp/tools-architecture.mjs +18 -70
  100. package/src/mcp/tools-context.mjs +56 -15
  101. package/src/mcp/tools-endpoints.mjs +4 -1
  102. package/src/mcp/tools-graph.mjs +17 -330
  103. package/src/mcp/tools-health.mjs +24 -705
  104. package/src/mcp/tools-verified-change.mjs +12 -4
  105. package/src/mcp-server.mjs +49 -146
  106. package/src/precision/lsp-client/constants.js +12 -0
  107. package/src/precision/lsp-client/environment.js +20 -0
  108. package/src/precision/lsp-client/errors.js +15 -0
  109. package/src/precision/lsp-client/lifecycle.js +127 -0
  110. package/src/precision/lsp-client/message-parser.js +81 -0
  111. package/src/precision/lsp-client/protocol.js +212 -0
  112. package/src/precision/lsp-client/registry.js +58 -0
  113. package/src/precision/lsp-client/repo-uri.js +60 -0
  114. package/src/precision/lsp-client/stdio-client.js +151 -0
  115. package/src/precision/lsp-client.js +10 -682
  116. package/src/precision/lsp-overlay/build.js +238 -0
  117. package/src/precision/lsp-overlay/contract.js +61 -0
  118. package/src/precision/lsp-overlay/reference-results.js +108 -0
  119. package/src/precision/lsp-overlay/semantic-inputs.js +62 -0
  120. package/src/precision/lsp-overlay/source-session.js +134 -0
  121. package/src/precision/lsp-overlay/store.js +150 -0
  122. package/src/precision/lsp-overlay/target-index.js +147 -0
  123. package/src/precision/lsp-overlay/target-query.js +55 -0
  124. package/src/precision/lsp-overlay.js +11 -868
  125. package/src/precision/typescript-lsp-provider.js +12 -682
  126. package/src/precision/typescript-provider/client.js +69 -0
  127. package/src/precision/typescript-provider/discovery.js +124 -0
  128. package/src/precision/typescript-provider/project-host.js +249 -0
  129. package/src/precision/typescript-provider/project-safety.js +161 -0
  130. package/src/precision/typescript-provider/reference-usage.js +53 -0
  131. package/src/version.js +7 -0
  132. package/docs/releases/v0.2.12.md +0 -45
@@ -0,0 +1,143 @@
1
+ import { folderModuleOf } from "../graph-analysis.edges.js";
2
+ import { isStructuralRelation } from "../../graph/relations.js";
3
+ import { endpointId, normalizeContractFile } from "./shared.js";
4
+
5
+ export function reverseRuntimeImports(graph = {}) {
6
+ const byId = new Map();
7
+ const files = new Set();
8
+ for (const node of graph.nodes || []) {
9
+ const file = normalizeContractFile(node?.source_file);
10
+ if (!file) continue;
11
+ byId.set(String(node.id), file);
12
+ files.add(file);
13
+ }
14
+ const reverse = new Map([...files].map((file) => [file, new Set()]));
15
+ for (const link of graph.links || []) {
16
+ if (isStructuralRelation(link?.relation) || !["imports", "re_exports"].includes(link?.relation) || link?.typeOnly === true || link?.compileOnly === true || link?.barrelProxy === true) continue;
17
+ const importer = byId.get(String(endpointId(link.source)));
18
+ const imported = byId.get(String(endpointId(link.target)));
19
+ if (!importer || !imported || importer === imported) continue;
20
+ reverse.get(imported)?.add(importer);
21
+ }
22
+ return reverse;
23
+ }
24
+
25
+ export function wrapperScopeFiles(sourceFile, graph) {
26
+ const source = normalizeContractFile(sourceFile);
27
+ if (!source || !Array.isArray(graph?.nodes)) return null;
28
+ const reverse = reverseRuntimeImports(graph);
29
+ const allowed = new Set([source]);
30
+ const queue = [{ file: source, depth: 0 }];
31
+ while (queue.length && allowed.size < 2_000) {
32
+ const current = queue.shift();
33
+ if (current.depth >= 4) continue;
34
+ for (const importer of [...(reverse.get(current.file) || [])].sort()) {
35
+ if (allowed.has(importer)) continue;
36
+ allowed.add(importer);
37
+ queue.push({ file: importer, depth: current.depth + 1 });
38
+ }
39
+ }
40
+ return allowed;
41
+ }
42
+
43
+ function isScreen(file) {
44
+ const path = normalizeContractFile(file);
45
+ const base = path.split("/").at(-1) || "";
46
+ return /(^|\/)(pages?|screens?|views?|routes?)(\/|$)/i.test(path)
47
+ || /(^|\/)(?:page|layout)\.[cm]?[jt]sx?$/i.test(path)
48
+ || /^(?:App|Root)\.[cm]?[jt]sx?$/i.test(base);
49
+ }
50
+
51
+ export function affectedForEndpoint(callsites, clientContexts, limits) {
52
+ const collected = new Map();
53
+ let traversalTruncated = false;
54
+ for (const context of clientContexts) {
55
+ const seeds = callsites.filter((call) => call.clientRepo === context.id).map((call) => call.file).sort();
56
+ if (!seeds.length) continue;
57
+ const queue = [];
58
+ const distance = new Map();
59
+ for (const seed of seeds) if (!distance.has(seed)) { distance.set(seed, 0); queue.push(seed); }
60
+ while (queue.length) {
61
+ const file = queue.shift();
62
+ const depth = distance.get(file);
63
+ const key = `${context.id}\0${file}`;
64
+ const previous = collected.get(key);
65
+ if (!previous || depth < previous.distance) collected.set(key, { client: context.id, file, distance: depth });
66
+ if (depth >= limits.maxImpactDepth) continue;
67
+ for (const importer of [...(context.reverse.get(file) || [])].sort()) {
68
+ if (distance.has(importer)) continue;
69
+ if (distance.size >= limits.maxAffectedFiles * 2) { traversalTruncated = true; continue; }
70
+ distance.set(importer, depth + 1);
71
+ queue.push(importer);
72
+ }
73
+ }
74
+ }
75
+ const allFiles = [...collected.values()].sort((left, right) => left.distance - right.distance || left.client.localeCompare(right.client) || left.file.localeCompare(right.file));
76
+ const filesTruncated = allFiles.length > limits.maxAffectedFiles;
77
+ const files = allFiles.slice(0, limits.maxAffectedFiles);
78
+ const allScreens = files.filter((entry) => isScreen(entry.file));
79
+ const screensTruncated = allScreens.length > limits.maxScreens;
80
+ const screens = allScreens.slice(0, limits.maxScreens);
81
+ const moduleMap = new Map();
82
+ for (const entry of files) {
83
+ const module = folderModuleOf(entry.file);
84
+ const key = `${entry.client}\0${module}`;
85
+ const item = moduleMap.get(key) || { client: entry.client, module, files: 0, nearestDistance: entry.distance };
86
+ item.files++;
87
+ item.nearestDistance = Math.min(item.nearestDistance, entry.distance);
88
+ moduleMap.set(key, item);
89
+ }
90
+ const allModules = [...moduleMap.values()].sort((left, right) => left.nearestDistance - right.nearestDistance || right.files - left.files || left.client.localeCompare(right.client) || left.module.localeCompare(right.module));
91
+ const modulesTruncated = allModules.length > limits.maxModules;
92
+ return {
93
+ complete: !(traversalTruncated || filesTruncated || screensTruncated || modulesTruncated),
94
+ files,
95
+ screens,
96
+ modules: allModules.slice(0, limits.maxModules),
97
+ truncated: { traversal: traversalTruncated, files: filesTruncated, screens: screensTruncated, modules: modulesTruncated },
98
+ };
99
+ }
100
+ const bareGraphLabel = (value) => String(value || "").replace(/\s*\(.*$/, "").replace(/[()]/g, "").trim();
101
+
102
+ export function handlerNodeEvidence(endpoint, graph) {
103
+ const handler = /^[A-Za-z_$][\w$]{0,127}$/.test(String(endpoint?.handler || "")) ? String(endpoint.handler) : null;
104
+ if (!handler) return { handler: null, handlerNodeId: null, handlerResolution: "inline-or-unresolved" };
105
+ const nodes = graph?.nodes || [];
106
+ const matches = nodes.filter((node) => normalizeContractFile(node?.source_file) && bareGraphLabel(node?.label) === handler && String(node?.id || "") !== normalizeContractFile(node?.source_file));
107
+ const endpointFile = normalizeContractFile(endpoint.file);
108
+ const sameFile = matches.filter((node) => normalizeContractFile(node?.source_file) === endpointFile);
109
+ const byId = new Map(nodes.map((node) => [endpointId(node?.id), node]));
110
+ const linkFile = (value) => {
111
+ const id = endpointId(value);
112
+ return normalizeContractFile(byId.get(id)?.source_file || String(id || "").split("#")[0]);
113
+ };
114
+ const directlyImportedFiles = new Set((graph?.links || [])
115
+ .filter((link) => ["imports", "re_exports"].includes(link?.relation) && linkFile(link?.source) === endpointFile)
116
+ .map((link) => linkFile(link?.target)).filter(Boolean));
117
+ const imported = matches.filter((node) => directlyImportedFiles.has(normalizeContractFile(node?.source_file)));
118
+ const resolved = sameFile.length === 1 ? sameFile[0] : imported.length === 1 ? imported[0] : matches.length === 1 ? matches[0] : null;
119
+ return {
120
+ handler,
121
+ handlerNodeId: resolved ? String(resolved.id) : null,
122
+ handlerResolution: resolved ? "resolved" : matches.length > 1 ? "ambiguous" : "unresolved",
123
+ };
124
+ }
125
+
126
+ export function externalUseLiveness(callsites, handlerEvidence) {
127
+ const proven = callsites.filter((call) => call.match?.confidence === "high" || call.match?.confidence === "medium");
128
+ const possible = callsites.filter((call) => call.match?.confidence === "low");
129
+ const status = proven.length ? "NOT_DEAD_EXTERNAL_USE" : possible.length ? "POSSIBLE_EXTERNAL_USE" : "UNKNOWN";
130
+ const evidence = proven.length ? proven : possible;
131
+ return {
132
+ status,
133
+ subject: handlerEvidence.handlerNodeId ? "handler-node" : handlerEvidence.handler ? "endpoint-handler" : "endpoint",
134
+ canSuppressDeadCandidate: proven.length > 0 && Boolean(handlerEvidence.handlerNodeId),
135
+ staticEvidence: evidence.length,
136
+ consumerRepositories: [...new Set(evidence.map((call) => call.clientRepo))].sort(),
137
+ reason: proven.length
138
+ ? "At least one selected external repository has a medium/high-confidence static HTTP contract match."
139
+ : possible.length
140
+ ? "Only low-confidence external HTTP contract matches were found; review before suppressing a dead-code candidate."
141
+ : "No selected external repository proved a static caller; absence of evidence is not a dead-code verdict.",
142
+ };
143
+ }
@@ -0,0 +1,61 @@
1
+ import { normalizeHttpContractPath } from "./shared.js";
2
+
3
+ export const pathSegments = (path) => String(path || "").split("/").filter(Boolean);
4
+ const parameter = (segment) => segment === ":param";
5
+ const wildcard = (segment) => segment === "*";
6
+
7
+ export function routeShapeMatches(endpointSegments, callSegments) {
8
+ const catchAll = wildcard(endpointSegments.at(-1));
9
+ if (catchAll ? callSegments.length < endpointSegments.length - 1 : endpointSegments.length !== callSegments.length) return false;
10
+ const compared = catchAll ? endpointSegments.length - 1 : endpointSegments.length;
11
+ for (let index = 0; index < compared; index++) {
12
+ const expected = endpointSegments[index], actual = callSegments[index];
13
+ if (parameter(expected)) continue;
14
+ if (parameter(actual) || wildcard(actual) || expected !== actual) return false;
15
+ }
16
+ return true;
17
+ }
18
+
19
+ export function suffixShapeMatch(endpointSegments, callSegments) {
20
+ if (endpointSegments.length === callSegments.length || Math.min(endpointSegments.length, callSegments.length) < 2) return false;
21
+ if (endpointSegments.length < callSegments.length) return routeShapeMatches(endpointSegments, callSegments.slice(callSegments.length - endpointSegments.length));
22
+ return routeShapeMatches(endpointSegments.slice(endpointSegments.length - callSegments.length), callSegments);
23
+ }
24
+
25
+ export function routeShapeContains(endpointSegments, requestedSegments) {
26
+ if (!requestedSegments.length || requestedSegments.length > endpointSegments.length) return false;
27
+ for (let start = 0; start <= endpointSegments.length - requestedSegments.length; start++) {
28
+ if (routeShapeMatches(endpointSegments.slice(start, start + requestedSegments.length), requestedSegments)) return true;
29
+ }
30
+ return false;
31
+ }
32
+
33
+ export function methodMatches(endpointMethod, callMethod) {
34
+ return endpointMethod === "ANY" || endpointMethod === "ALL" || endpointMethod === callMethod;
35
+ }
36
+
37
+ export function matchHttpContract(endpoint, call) {
38
+ if (!call?.path || !methodMatches(String(endpoint?.method || "").toUpperCase(), call.method)) return null;
39
+ const expected = pathSegments(normalizeHttpContractPath(endpoint.path));
40
+ const actual = pathSegments(call.path);
41
+ if (routeShapeMatches(expected, actual)) {
42
+ if (call.unknownPrefix || call.partialDynamic) return { kind: "exact-dynamic", confidence: "medium", score: 0.78, reason: "method and normalized route shape match, but the client URL retains a dynamic component" };
43
+ const concreteParameter = expected.some((segment, index) => parameter(segment) && !parameter(actual[index]));
44
+ return {
45
+ kind: "exact",
46
+ confidence: "high",
47
+ score: concreteParameter ? 0.96 : 1,
48
+ reason: concreteParameter ? "method matches and a backend parameter accepts the concrete client segment" : "method and normalized route shape match exactly",
49
+ };
50
+ }
51
+ if (suffixShapeMatch(expected, actual)) {
52
+ const dynamic = call.dynamic || call.unknownPrefix || call.partialDynamic;
53
+ return {
54
+ kind: "suffix",
55
+ confidence: dynamic ? "low" : "medium",
56
+ score: dynamic ? 0.55 : 0.72,
57
+ reason: dynamic ? "method matches and at least two trailing route segments match; the client prefix is dynamic" : "method matches and at least two trailing route segments match after a client/backend base-path difference",
58
+ };
59
+ }
60
+ return null;
61
+ }
@@ -0,0 +1,86 @@
1
+ export const HTTP_CONTRACTS_V = 2;
2
+ export const HTTP_CONTRACT_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
3
+
4
+ export const HTTP_CONTRACT_DEFAULTS = Object.freeze({
5
+ maxBackendFiles: 3_000,
6
+ maxClientFiles: 3_000,
7
+ maxEndpoints: 250,
8
+ maxCallsPerClient: 2_000,
9
+ maxMatches: 1_000,
10
+ maxCallsitesPerEndpoint: 100,
11
+ maxUncertain: 200,
12
+ maxImpactDepth: 2,
13
+ maxAffectedFiles: 100,
14
+ maxScreens: 50,
15
+ maxModules: 50,
16
+ });
17
+
18
+ export const HTTP_CONTRACT_HARD_LIMITS = Object.freeze({
19
+ maxBackendFiles: 3_000,
20
+ maxClientFiles: 10_000,
21
+ maxEndpoints: 500,
22
+ maxCallsPerClient: 5_000,
23
+ maxMatches: 5_000,
24
+ maxCallsitesPerEndpoint: 500,
25
+ maxUncertain: 1_000,
26
+ maxImpactDepth: 5,
27
+ maxAffectedFiles: 500,
28
+ maxScreens: 200,
29
+ maxModules: 200,
30
+ });
31
+
32
+ export const endpointId = (value) => value && typeof value === "object" ? value.id : value;
33
+
34
+ export function normalizeContractFile(value) {
35
+ const raw = String(value || "").replace(/\\/g, "/");
36
+ if (!raw || raw.startsWith("/") || /^[a-z]:\//i.test(raw) || /[\x00-\x1f\x7f]/.test(raw)) return "";
37
+ const normalized = raw.replace(/^\.\//, "");
38
+ return normalized.split("/").some((part) => !part || part === "." || part === "..") ? "" : normalized;
39
+ }
40
+
41
+ export function boundedInteger(value, fallback, min, max) {
42
+ const number = Number(value);
43
+ return Number.isInteger(number) ? Math.max(min, Math.min(max, number)) : fallback;
44
+ }
45
+
46
+ export function safeContractName(value, fallback) {
47
+ const text = String(value || "").trim();
48
+ return /^[a-z0-9][a-z0-9._-]{0,79}$/i.test(text) ? text : fallback;
49
+ }
50
+
51
+ export function contractLineAt(text, index) {
52
+ let line = 1;
53
+ for (let cursor = 0; cursor < index; cursor++) if (text.charCodeAt(cursor) === 10) line++;
54
+ return line;
55
+ }
56
+
57
+ export function normalizeHttpContractLimits(input = {}) {
58
+ const result = {};
59
+ for (const key of Object.keys(HTTP_CONTRACT_DEFAULTS)) {
60
+ result[key] = boundedInteger(input[key], HTTP_CONTRACT_DEFAULTS[key], key === "maxImpactDepth" ? 0 : 1, HTTP_CONTRACT_HARD_LIMITS[key]);
61
+ }
62
+ return result;
63
+ }
64
+
65
+ export function normalizeHttpContractPath(value) {
66
+ let path = String(value || "").trim();
67
+ if (!path || path.length > 2_048) return null;
68
+ try {
69
+ if (/^https?:\/\//i.test(path)) path = new URL(path).pathname;
70
+ else if (/^\/\//.test(path)) path = new URL(`http:${path}`).pathname;
71
+ } catch { return null; }
72
+ const queryAt = path.search(/[?#]/);
73
+ if (queryAt >= 0) path = path.slice(0, queryAt);
74
+ path = path.replace(/\\/g, "/").replace(/\/+/g, "/");
75
+ if (!path.startsWith("/")) path = `/${path}`;
76
+ path = path.replace(/\/\{[^/}]+\}/g, "/:param")
77
+ .replace(/\/:([A-Za-z_$][\w$-]*)(?:\?)?/g, "/:param")
78
+ .replace(/\/\*[^/]*/g, "/*")
79
+ .replace(/\[(?:\.\.\.)?[^\]]+\]/g, "/:param")
80
+ .replace(/\/+$/g, "") || "/";
81
+ return /[\x00-\x1f\x7f]/.test(path) || path.includes("..") ? null : path;
82
+ }
83
+
84
+ export function filesFromGraph(graph) {
85
+ return [...new Set((graph?.nodes || []).map((node) => normalizeContractFile(node?.source_file)).filter(Boolean))].sort();
86
+ }