@optave/codegraph 3.1.0 → 3.1.2

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 (83) hide show
  1. package/README.md +5 -5
  2. package/grammars/tree-sitter-go.wasm +0 -0
  3. package/package.json +8 -9
  4. package/src/ast-analysis/engine.js +365 -0
  5. package/src/ast-analysis/metrics.js +118 -0
  6. package/src/ast-analysis/rules/csharp.js +201 -0
  7. package/src/ast-analysis/rules/go.js +182 -0
  8. package/src/ast-analysis/rules/index.js +82 -0
  9. package/src/ast-analysis/rules/java.js +175 -0
  10. package/src/ast-analysis/rules/javascript.js +246 -0
  11. package/src/ast-analysis/rules/php.js +219 -0
  12. package/src/ast-analysis/rules/python.js +196 -0
  13. package/src/ast-analysis/rules/ruby.js +204 -0
  14. package/src/ast-analysis/rules/rust.js +173 -0
  15. package/src/ast-analysis/shared.js +223 -0
  16. package/src/ast-analysis/visitor-utils.js +176 -0
  17. package/src/ast-analysis/visitor.js +162 -0
  18. package/src/ast-analysis/visitors/ast-store-visitor.js +150 -0
  19. package/src/ast-analysis/visitors/cfg-visitor.js +792 -0
  20. package/src/ast-analysis/visitors/complexity-visitor.js +243 -0
  21. package/src/ast-analysis/visitors/dataflow-visitor.js +358 -0
  22. package/src/ast.js +26 -166
  23. package/src/audit.js +2 -88
  24. package/src/batch.js +0 -25
  25. package/src/boundaries.js +1 -1
  26. package/src/branch-compare.js +82 -172
  27. package/src/builder.js +48 -184
  28. package/src/cfg.js +148 -1174
  29. package/src/check.js +1 -84
  30. package/src/cli.js +118 -197
  31. package/src/cochange.js +1 -39
  32. package/src/commands/audit.js +88 -0
  33. package/src/commands/batch.js +26 -0
  34. package/src/commands/branch-compare.js +97 -0
  35. package/src/commands/cfg.js +55 -0
  36. package/src/commands/check.js +82 -0
  37. package/src/commands/cochange.js +37 -0
  38. package/src/commands/communities.js +69 -0
  39. package/src/commands/complexity.js +77 -0
  40. package/src/commands/dataflow.js +110 -0
  41. package/src/commands/flow.js +70 -0
  42. package/src/commands/manifesto.js +77 -0
  43. package/src/commands/owners.js +52 -0
  44. package/src/commands/query.js +21 -0
  45. package/src/commands/sequence.js +33 -0
  46. package/src/commands/structure.js +64 -0
  47. package/src/commands/triage.js +49 -0
  48. package/src/communities.js +22 -96
  49. package/src/complexity.js +234 -1591
  50. package/src/cycles.js +1 -1
  51. package/src/dataflow.js +274 -1352
  52. package/src/db/connection.js +88 -0
  53. package/src/db/migrations.js +312 -0
  54. package/src/db/query-builder.js +280 -0
  55. package/src/db/repository/build-stmts.js +104 -0
  56. package/src/db/repository/cfg.js +83 -0
  57. package/src/db/repository/cochange.js +41 -0
  58. package/src/db/repository/complexity.js +15 -0
  59. package/src/db/repository/dataflow.js +12 -0
  60. package/src/db/repository/edges.js +259 -0
  61. package/src/db/repository/embeddings.js +40 -0
  62. package/src/db/repository/graph-read.js +39 -0
  63. package/src/db/repository/index.js +42 -0
  64. package/src/db/repository/nodes.js +236 -0
  65. package/src/db.js +58 -399
  66. package/src/embedder.js +158 -174
  67. package/src/export.js +1 -1
  68. package/src/extractors/javascript.js +130 -5
  69. package/src/flow.js +153 -222
  70. package/src/index.js +53 -16
  71. package/src/infrastructure/result-formatter.js +21 -0
  72. package/src/infrastructure/test-filter.js +7 -0
  73. package/src/kinds.js +50 -0
  74. package/src/manifesto.js +1 -82
  75. package/src/mcp.js +37 -20
  76. package/src/owners.js +127 -182
  77. package/src/queries-cli.js +866 -0
  78. package/src/queries.js +1271 -2416
  79. package/src/sequence.js +179 -223
  80. package/src/structure.js +211 -269
  81. package/src/triage.js +117 -212
  82. package/src/viewer.js +1 -1
  83. package/src/watcher.js +7 -4
package/src/check.js CHANGED
@@ -4,8 +4,8 @@ import path from 'node:path';
4
4
  import { loadConfig } from './config.js';
5
5
  import { findCycles } from './cycles.js';
6
6
  import { findDbPath, openReadonlyOrFail } from './db.js';
7
+ import { isTestFile } from './infrastructure/test-filter.js';
7
8
  import { matchOwners, parseCodeowners } from './owners.js';
8
- import { isTestFile } from './queries.js';
9
9
 
10
10
  // ─── Diff Parser ──────────────────────────────────────────────────────
11
11
 
@@ -347,86 +347,3 @@ export function checkData(customDbPath, opts = {}) {
347
347
  db.close();
348
348
  }
349
349
  }
350
-
351
- // ─── CLI Display ──────────────────────────────────────────────────────
352
-
353
- /**
354
- * CLI formatter — prints check results and exits with code 1 on failure.
355
- */
356
- export function check(customDbPath, opts = {}) {
357
- const data = checkData(customDbPath, opts);
358
-
359
- if (data.error) {
360
- console.error(data.error);
361
- process.exit(1);
362
- }
363
-
364
- if (opts.json) {
365
- console.log(JSON.stringify(data, null, 2));
366
- if (!data.passed) process.exit(1);
367
- return;
368
- }
369
-
370
- console.log('\n# Check Results\n');
371
-
372
- if (data.predicates.length === 0) {
373
- console.log(' No changes detected.\n');
374
- return;
375
- }
376
-
377
- console.log(
378
- ` Changed files: ${data.summary.changedFiles} New files: ${data.summary.newFiles}\n`,
379
- );
380
-
381
- for (const pred of data.predicates) {
382
- const icon = pred.passed ? 'PASS' : 'FAIL';
383
- console.log(` [${icon}] ${pred.name}`);
384
-
385
- if (!pred.passed) {
386
- if (pred.name === 'cycles' && pred.cycles) {
387
- for (const cycle of pred.cycles.slice(0, 10)) {
388
- console.log(` ${cycle.join(' -> ')}`);
389
- }
390
- if (pred.cycles.length > 10) {
391
- console.log(` ... and ${pred.cycles.length - 10} more`);
392
- }
393
- }
394
- if (pred.name === 'blast-radius' && pred.violations) {
395
- for (const v of pred.violations.slice(0, 10)) {
396
- console.log(
397
- ` ${v.name} (${v.kind}) at ${v.file}:${v.line} — ${v.transitiveCallers} callers (max: ${pred.threshold})`,
398
- );
399
- }
400
- if (pred.violations.length > 10) {
401
- console.log(` ... and ${pred.violations.length - 10} more`);
402
- }
403
- }
404
- if (pred.name === 'signatures' && pred.violations) {
405
- for (const v of pred.violations.slice(0, 10)) {
406
- console.log(` ${v.name} (${v.kind}) at ${v.file}:${v.line}`);
407
- }
408
- if (pred.violations.length > 10) {
409
- console.log(` ... and ${pred.violations.length - 10} more`);
410
- }
411
- }
412
- if (pred.name === 'boundaries' && pred.violations) {
413
- for (const v of pred.violations.slice(0, 10)) {
414
- console.log(` ${v.from} -> ${v.to} (${v.edgeKind})`);
415
- }
416
- if (pred.violations.length > 10) {
417
- console.log(` ... and ${pred.violations.length - 10} more`);
418
- }
419
- }
420
- }
421
- if (pred.note) {
422
- console.log(` ${pred.note}`);
423
- }
424
- }
425
-
426
- const s = data.summary;
427
- console.log(`\n ${s.total} predicates | ${s.passed} passed | ${s.failed} failed\n`);
428
-
429
- if (!data.passed) {
430
- process.exit(1);
431
- }
432
- }