gitnexus 1.6.6-rc.25 → 1.6.6-rc.26
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.
|
@@ -15,12 +15,14 @@ import { getPluginForFile, HTTP_SCAN_GLOB } from './http-patterns/index.js';
|
|
|
15
15
|
* the preferred path because the graph has richer symbol metadata
|
|
16
16
|
* (real uids, class/method structure, etc.).
|
|
17
17
|
*
|
|
18
|
-
* 2. **Source-scan
|
|
19
|
-
* the per-language plugin registry in `./http-patterns/`. Used
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
18
|
+
* 2. **Source-scan supplement (Strategy B)** — parse files directly with
|
|
19
|
+
* the per-language plugin registry in `./http-patterns/`. Used to
|
|
20
|
+
* fill gaps when graph extraction only covers part of a polyglot repo
|
|
21
|
+
* (e.g. Java graph routes plus Go source-scan routes). Graph entries
|
|
22
|
+
* remain authoritative for duplicate contract IDs because they carry
|
|
23
|
+
* richer symbol metadata. Each plugin owns its tree-sitter grammar
|
|
24
|
+
* and query sources — this orchestrator imports NO grammars or query
|
|
25
|
+
* strings.
|
|
24
26
|
*
|
|
25
27
|
* Adding a new language for Strategy B is a one-file edit in
|
|
26
28
|
* `http-patterns/index.ts`: register a new `HttpLanguagePlugin` and
|
|
@@ -175,13 +177,11 @@ export class HttpRouteExtractor {
|
|
|
175
177
|
return scannedFiles;
|
|
176
178
|
};
|
|
177
179
|
const graphProviders = dbExecutor != null ? await this.extractProvidersGraph(dbExecutor, getDetections) : [];
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
// Source scan always runs to capture routes in languages/files not covered
|
|
181
|
+
// by graph edges; the glob and per-file parse results are cached above.
|
|
182
|
+
const providers = this.mergeGraphAndSourceContracts(graphProviders, this.extractProvidersSourceScan(await getScannedFiles(), getDetections));
|
|
181
183
|
const graphConsumers = dbExecutor != null ? await this.extractConsumersGraph(dbExecutor, getDetections) : [];
|
|
182
|
-
const consumers = graphConsumers.
|
|
183
|
-
? graphConsumers
|
|
184
|
-
: this.extractConsumersSourceScan(await getScannedFiles(), getDetections);
|
|
184
|
+
const consumers = this.mergeGraphAndSourceContracts(graphConsumers, this.extractConsumersSourceScan(await getScannedFiles(), getDetections));
|
|
185
185
|
return [...providers, ...consumers];
|
|
186
186
|
}
|
|
187
187
|
async scanFiles(repoPath) {
|
|
@@ -427,4 +427,15 @@ export class HttpRouteExtractor {
|
|
|
427
427
|
}
|
|
428
428
|
return out;
|
|
429
429
|
}
|
|
430
|
+
mergeGraphAndSourceContracts(graphContracts, sourceContracts) {
|
|
431
|
+
const seenContractIds = new Set(graphContracts.map((c) => c.contractId));
|
|
432
|
+
const out = [...graphContracts];
|
|
433
|
+
for (const contract of sourceContracts) {
|
|
434
|
+
if (seenContractIds.has(contract.contractId))
|
|
435
|
+
continue;
|
|
436
|
+
seenContractIds.add(contract.contractId);
|
|
437
|
+
out.push(contract);
|
|
438
|
+
}
|
|
439
|
+
return out;
|
|
440
|
+
}
|
|
430
441
|
}
|
package/package.json
CHANGED