@optave/codegraph 3.12.0 → 3.13.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/README.md +71 -35
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +2 -1
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/batch.d.ts.map +1 -1
- package/dist/cli/commands/batch.js +1 -0
- package/dist/cli/commands/batch.js.map +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +6 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +272 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/triage.js +1 -1
- package/dist/cli/commands/triage.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/shared/options.d.ts +2 -1
- package/dist/cli/shared/options.d.ts.map +1 -1
- package/dist/cli/shared/options.js +11 -1
- package/dist/cli/shared/options.js.map +1 -1
- package/dist/cli/types.d.ts +2 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/db/migrations.js +1 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/domain/graph/builder/call-resolver.d.ts +12 -8
- package/dist/domain/graph/builder/call-resolver.d.ts.map +1 -1
- package/dist/domain/graph/builder/call-resolver.js +93 -38
- package/dist/domain/graph/builder/call-resolver.js.map +1 -1
- package/dist/domain/graph/builder/cha.d.ts +9 -1
- package/dist/domain/graph/builder/cha.d.ts.map +1 -1
- package/dist/domain/graph/builder/cha.js +17 -2
- package/dist/domain/graph/builder/cha.js.map +1 -1
- package/dist/domain/graph/builder/helpers.d.ts +8 -0
- package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
- package/dist/domain/graph/builder/helpers.js +22 -3
- package/dist/domain/graph/builder/helpers.js.map +1 -1
- package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
- package/dist/domain/graph/builder/incremental.js +1 -1
- package/dist/domain/graph/builder/incremental.js.map +1 -1
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
- package/dist/domain/graph/builder/pipeline.js +37 -2
- package/dist/domain/graph/builder/pipeline.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.d.ts +0 -2
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.js +88 -318
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.js +4 -0
- package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
- package/dist/domain/graph/builder/stages/native-orchestrator.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/native-orchestrator.js +341 -82
- package/dist/domain/graph/builder/stages/native-orchestrator.js.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
- package/dist/domain/parser.d.ts +4 -5
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +46 -15
- package/dist/domain/parser.js.map +1 -1
- package/dist/domain/wasm-worker-entry.js +10 -2
- package/dist/domain/wasm-worker-entry.js.map +1 -1
- package/dist/domain/wasm-worker-pool.d.ts.map +1 -1
- package/dist/domain/wasm-worker-pool.js +2 -0
- package/dist/domain/wasm-worker-pool.js.map +1 -1
- package/dist/domain/wasm-worker-protocol.d.ts +1 -0
- package/dist/domain/wasm-worker-protocol.d.ts.map +1 -1
- package/dist/extractors/cpp.d.ts.map +1 -1
- package/dist/extractors/cpp.js +42 -1
- package/dist/extractors/cpp.js.map +1 -1
- package/dist/extractors/cuda.d.ts.map +1 -1
- package/dist/extractors/cuda.js +42 -1
- package/dist/extractors/cuda.js.map +1 -1
- package/dist/extractors/helpers.d.ts +11 -0
- package/dist/extractors/helpers.d.ts.map +1 -1
- package/dist/extractors/helpers.js +40 -0
- package/dist/extractors/helpers.js.map +1 -1
- package/dist/extractors/java.d.ts.map +1 -1
- package/dist/extractors/java.js +8 -7
- package/dist/extractors/java.js.map +1 -1
- package/dist/extractors/javascript.js +137 -6
- package/dist/extractors/javascript.js.map +1 -1
- package/dist/features/structure-query.d.ts +1 -1
- package/dist/features/structure-query.d.ts.map +1 -1
- package/dist/features/structure-query.js +6 -6
- package/dist/features/structure-query.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/config.d.ts +77 -4
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +395 -21
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/infrastructure/registry.d.ts +27 -0
- package/dist/infrastructure/registry.d.ts.map +1 -1
- package/dist/infrastructure/registry.js +59 -1
- package/dist/infrastructure/registry.js.map +1 -1
- package/dist/presentation/structure.d.ts +1 -1
- package/dist/presentation/structure.d.ts.map +1 -1
- package/dist/presentation/structure.js +2 -2
- package/dist/presentation/structure.js.map +1 -1
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -1
- package/grammars/tree-sitter-gleam.wasm +0 -0
- package/package.json +7 -8
- package/src/cli/commands/audit.ts +2 -1
- package/src/cli/commands/batch.ts +1 -0
- package/src/cli/commands/build.ts +6 -1
- package/src/cli/commands/config.ts +353 -0
- package/src/cli/commands/triage.ts +1 -1
- package/src/cli/index.ts +10 -0
- package/src/cli/shared/options.ts +11 -1
- package/src/cli/types.ts +2 -0
- package/src/db/migrations.ts +1 -1
- package/src/domain/graph/builder/call-resolver.ts +99 -41
- package/src/domain/graph/builder/cha.ts +18 -1
- package/src/domain/graph/builder/helpers.ts +24 -4
- package/src/domain/graph/builder/incremental.ts +1 -0
- package/src/domain/graph/builder/pipeline.ts +49 -2
- package/src/domain/graph/builder/stages/build-edges.ts +130 -399
- package/src/domain/graph/builder/stages/detect-changes.ts +1 -1
- package/src/domain/graph/builder/stages/finalize.ts +4 -0
- package/src/domain/graph/builder/stages/native-orchestrator.ts +396 -92
- package/src/domain/graph/builder/stages/resolve-imports.ts +1 -1
- package/src/domain/parser.ts +45 -14
- package/src/domain/wasm-worker-entry.ts +10 -2
- package/src/domain/wasm-worker-pool.ts +1 -0
- package/src/domain/wasm-worker-protocol.ts +1 -0
- package/src/extractors/cpp.ts +44 -1
- package/src/extractors/cuda.ts +44 -1
- package/src/extractors/helpers.ts +43 -0
- package/src/extractors/java.ts +8 -7
- package/src/extractors/javascript.ts +127 -6
- package/src/features/structure-query.ts +7 -7
- package/src/index.ts +5 -1
- package/src/infrastructure/config.ts +481 -22
- package/src/infrastructure/registry.ts +82 -1
- package/src/presentation/structure.ts +3 -3
- package/src/types.ts +41 -0
- package/grammars/tree-sitter-erlang.wasm +0 -0
|
@@ -48,6 +48,13 @@ export const BUILTIN_RECEIVERS: Set<string> = new Set([
|
|
|
48
48
|
'require',
|
|
49
49
|
]);
|
|
50
50
|
|
|
51
|
+
/** Phase 8.6: confidence penalty applied to CHA-dispatch edges. */
|
|
52
|
+
export const CHA_DISPATCH_PENALTY = 0.1;
|
|
53
|
+
/** Phase 8.6: fixed confidence for typed-receiver (interface/CHA) dispatch edges.
|
|
54
|
+
* File proximity is not meaningful for virtual dispatch — all three engine paths
|
|
55
|
+
* (WASM inline, WASM post-pass, native post-pass) must agree on this value. */
|
|
56
|
+
export const CHA_TYPED_DISPATCH_CONFIDENCE = 0.8;
|
|
57
|
+
|
|
51
58
|
/** Check if a directory entry should be skipped (ignored dirs, dotfiles). */
|
|
52
59
|
function shouldSkipEntry(entry: fs.Dirent, extraIgnore: Set<string> | null): boolean {
|
|
53
60
|
if (entry.name.startsWith('.') && entry.name !== '.') {
|
|
@@ -361,6 +368,9 @@ export function batchInsertEdges(db: BetterSqlite3Database, rows: unknown[][]):
|
|
|
361
368
|
}
|
|
362
369
|
}
|
|
363
370
|
|
|
371
|
+
/** Confidence assigned to CHA-expanded interface/abstract dispatch edges. */
|
|
372
|
+
export const CHA_DISPATCH_CONFIDENCE = 0.8;
|
|
373
|
+
|
|
364
374
|
/**
|
|
365
375
|
* CHA (Class Hierarchy Analysis) post-pass.
|
|
366
376
|
*
|
|
@@ -454,13 +464,15 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
454
464
|
|
|
455
465
|
const callToMethods = db
|
|
456
466
|
.prepare(
|
|
457
|
-
`SELECT e.source_id, tgt.name AS method_name
|
|
467
|
+
`SELECT e.source_id, src.name AS caller_name, tgt.name AS method_name
|
|
458
468
|
FROM edges e
|
|
459
469
|
JOIN nodes tgt ON e.target_id = tgt.id
|
|
470
|
+
JOIN nodes src ON e.source_id = src.id
|
|
460
471
|
WHERE e.kind = 'calls' AND tgt.kind = 'method'
|
|
461
|
-
AND INSTR(tgt.name, '.') > 0
|
|
472
|
+
AND INSTR(tgt.name, '.') > 0
|
|
473
|
+
AND (e.technique IS NULL OR e.technique != 'cha-expanded')`,
|
|
462
474
|
)
|
|
463
|
-
.all() as Array<{ source_id: number; method_name: string }>;
|
|
475
|
+
.all() as Array<{ source_id: number; caller_name: string; method_name: string }>;
|
|
464
476
|
|
|
465
477
|
const seen = new Set<string>();
|
|
466
478
|
// Scope deduplication to only the source_ids we are about to expand, avoiding
|
|
@@ -511,10 +523,18 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
511
523
|
const qualifiedName = `${cls}.${methodSuffix}`;
|
|
512
524
|
const methodNodes = findMethodStmt.all(qualifiedName) as Array<{ id: number }>;
|
|
513
525
|
for (const methodNode of methodNodes) {
|
|
526
|
+
if (methodNode.id === source_id) continue; // skip self-loops
|
|
514
527
|
const key = `${source_id}|${methodNode.id}`;
|
|
515
528
|
if (seen.has(key)) continue;
|
|
516
529
|
seen.add(key);
|
|
517
|
-
newEdges.push([
|
|
530
|
+
newEdges.push([
|
|
531
|
+
source_id,
|
|
532
|
+
methodNode.id,
|
|
533
|
+
'calls',
|
|
534
|
+
CHA_TYPED_DISPATCH_CONFIDENCE,
|
|
535
|
+
0,
|
|
536
|
+
'cha-expanded',
|
|
537
|
+
]);
|
|
518
538
|
}
|
|
519
539
|
}
|
|
520
540
|
|
|
@@ -15,7 +15,14 @@ import {
|
|
|
15
15
|
MIGRATIONS,
|
|
16
16
|
openDb,
|
|
17
17
|
} from '../../../db/index.js';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
computeConfigHash,
|
|
20
|
+
detectWorkspaces,
|
|
21
|
+
getLastAppliedGlobalConfig,
|
|
22
|
+
getLastAppliedGlobalPath,
|
|
23
|
+
loadConfig,
|
|
24
|
+
promptForConsentIfNeeded,
|
|
25
|
+
} from '../../../infrastructure/config.js';
|
|
19
26
|
import { debug, info, warn } from '../../../infrastructure/logger.js';
|
|
20
27
|
import { loadNative } from '../../../infrastructure/native.js';
|
|
21
28
|
import { toErrorMessage } from '../../../shared/errors.js';
|
|
@@ -114,6 +121,16 @@ function checkEngineSchemaMismatch(ctx: PipelineContext): void {
|
|
|
114
121
|
);
|
|
115
122
|
ctx.forceFullRebuild = true;
|
|
116
123
|
}
|
|
124
|
+
|
|
125
|
+
// Config hash — promotes to full rebuild when build-relevant config changes
|
|
126
|
+
// (include/exclude/ignoreDirs/extensions/aliases/build.*).
|
|
127
|
+
// This closes the pre-existing config-change gap and covers the new global-config layer.
|
|
128
|
+
const currentConfigHash = computeConfigHash(ctx.config);
|
|
129
|
+
const prevConfigHash = meta('config_hash');
|
|
130
|
+
if (prevConfigHash && prevConfigHash !== currentConfigHash) {
|
|
131
|
+
info('Build-relevant config changed, promoting to full rebuild.');
|
|
132
|
+
ctx.forceFullRebuild = true;
|
|
133
|
+
}
|
|
117
134
|
}
|
|
118
135
|
|
|
119
136
|
function warnOnEmbeddingsWipe(ctx: PipelineContext): void {
|
|
@@ -172,7 +189,7 @@ function setupPipeline(ctx: PipelineContext): void {
|
|
|
172
189
|
ctx.db = openDb(ctx.dbPath);
|
|
173
190
|
initSchema(ctx.db);
|
|
174
191
|
|
|
175
|
-
ctx.config = loadConfig(ctx.rootDir);
|
|
192
|
+
ctx.config = loadConfig(ctx.rootDir, { userConfig: ctx.opts.userConfig });
|
|
176
193
|
// Merge caller-supplied excludes on top of the file-config excludes so
|
|
177
194
|
// programmatic callers (e.g. benchmark scripts) can extend exclusion
|
|
178
195
|
// without mutating .codegraphrc.json. Native orchestrator picks this up
|
|
@@ -186,6 +203,30 @@ function setupPipeline(ctx: PipelineContext): void {
|
|
|
186
203
|
ctx.incremental =
|
|
187
204
|
ctx.opts.incremental !== false && ctx.config.build && ctx.config.build.incremental !== false;
|
|
188
205
|
|
|
206
|
+
// ── Build-time global-config notice ──────────────────────────────
|
|
207
|
+
// Use the already-parsed and sanitized global config cached by loadConfig —
|
|
208
|
+
// avoids a second disk read and the TOCTOU window between loadConfig and here.
|
|
209
|
+
const appliedGlobalPath = getLastAppliedGlobalPath();
|
|
210
|
+
if (appliedGlobalPath) {
|
|
211
|
+
const buildAffectingKeys = [
|
|
212
|
+
'include',
|
|
213
|
+
'exclude',
|
|
214
|
+
'ignoreDirs',
|
|
215
|
+
'extensions',
|
|
216
|
+
'aliases',
|
|
217
|
+
'build',
|
|
218
|
+
];
|
|
219
|
+
const globalData = getLastAppliedGlobalConfig();
|
|
220
|
+
if (globalData) {
|
|
221
|
+
const injectedKeys = buildAffectingKeys.filter((k) => k in globalData);
|
|
222
|
+
if (injectedKeys.length > 0) {
|
|
223
|
+
process.stderr.write(
|
|
224
|
+
`ℹ global config applied (${appliedGlobalPath}) — injecting: ${injectedKeys.join(', ')} · --no-user-config to ignore\n`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
189
230
|
initializeEngine(ctx);
|
|
190
231
|
checkEngineSchemaMismatch(ctx);
|
|
191
232
|
warnOnEmbeddingsWipe(ctx);
|
|
@@ -348,6 +389,12 @@ export async function buildGraph(
|
|
|
348
389
|
ctx.rootDir = rootDir;
|
|
349
390
|
|
|
350
391
|
try {
|
|
392
|
+
// Interactive consent prompt — only fires when the caller opts in (build
|
|
393
|
+
// command with TTY), a global file exists, and the repo is undecided.
|
|
394
|
+
if (opts.promptForConsent) {
|
|
395
|
+
await promptForConsentIfNeeded(rootDir);
|
|
396
|
+
}
|
|
397
|
+
|
|
351
398
|
setupPipeline(ctx);
|
|
352
399
|
|
|
353
400
|
// ── JS-side fast-skip for native incremental (#1054) ──────────────
|