@orangepro/orangepro-mcp 0.1.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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +328 -0
  3. package/dist/local/agentWorkflow.js +81 -0
  4. package/dist/local/aiGraph/links.js +635 -0
  5. package/dist/local/analyze/analyzer.js +2129 -0
  6. package/dist/local/analyze/behaviorContracts.js +169 -0
  7. package/dist/local/analyze/boilerplate.js +42 -0
  8. package/dist/local/analyze/callGraph.js +458 -0
  9. package/dist/local/analyze/classify.js +219 -0
  10. package/dist/local/analyze/clustering.js +357 -0
  11. package/dist/local/analyze/confirm.js +2422 -0
  12. package/dist/local/analyze/coverage.js +518 -0
  13. package/dist/local/analyze/coverageArtifacts.js +607 -0
  14. package/dist/local/analyze/frameworks.js +115 -0
  15. package/dist/local/analyze/linkage/conventions.js +160 -0
  16. package/dist/local/analyze/parseCache.js +164 -0
  17. package/dist/local/analyze/selfAssert.js +53 -0
  18. package/dist/local/analyze/symbols.js +430 -0
  19. package/dist/local/analyze/testLayer.js +135 -0
  20. package/dist/local/analyze/treeSitter/engine.js +1253 -0
  21. package/dist/local/analyze/treeSitter/languages.js +101 -0
  22. package/dist/local/autoProve.js +620 -0
  23. package/dist/local/cli.js +1468 -0
  24. package/dist/local/cliArgs.js +112 -0
  25. package/dist/local/corpusScope.js +162 -0
  26. package/dist/local/enrich/csv.js +348 -0
  27. package/dist/local/enrich/index.js +43 -0
  28. package/dist/local/enrich/markdown.js +193 -0
  29. package/dist/local/explain/explain.js +91 -0
  30. package/dist/local/exportCli.js +26 -0
  31. package/dist/local/flows/flowWalker.js +215 -0
  32. package/dist/local/flows/llmFlowDiscovery.js +567 -0
  33. package/dist/local/freshness/changed.js +280 -0
  34. package/dist/local/freshness/manifest.js +35 -0
  35. package/dist/local/freshness/status.js +30 -0
  36. package/dist/local/gaps/gaps.js +114 -0
  37. package/dist/local/generate/buckets.js +73 -0
  38. package/dist/local/generate/compareJudge.js +124 -0
  39. package/dist/local/generate/compareReport.js +538 -0
  40. package/dist/local/generate/compareScore.js +105 -0
  41. package/dist/local/generate/deriveImports.js +91 -0
  42. package/dist/local/generate/generator.js +2586 -0
  43. package/dist/local/generate/prompt.js +144 -0
  44. package/dist/local/generate/promptV5.js +438 -0
  45. package/dist/local/generate/providers.js +400 -0
  46. package/dist/local/generate/runHints.js +304 -0
  47. package/dist/local/graph/citations.js +73 -0
  48. package/dist/local/graph/confirmable.js +72 -0
  49. package/dist/local/graph/factories.js +210 -0
  50. package/dist/local/graph/ontology.js +18 -0
  51. package/dist/local/interactive.js +53 -0
  52. package/dist/local/jobs/jobStore.js +80 -0
  53. package/dist/local/jobs/notify.js +29 -0
  54. package/dist/local/jobs/runner.js +75 -0
  55. package/dist/local/ledger.js +117 -0
  56. package/dist/local/localConfig.js +112 -0
  57. package/dist/local/mcp.js +548 -0
  58. package/dist/local/operations.js +1749 -0
  59. package/dist/local/pack/coverageReport.js +192 -0
  60. package/dist/local/pack/exporter.js +195 -0
  61. package/dist/local/pack/schema.js +128 -0
  62. package/dist/local/pack/summary.js +127 -0
  63. package/dist/local/pack/validate.js +25 -0
  64. package/dist/local/proofRunnability.js +366 -0
  65. package/dist/local/recipe/dbSqljs.js +255 -0
  66. package/dist/local/reprove/paths.js +13 -0
  67. package/dist/local/reprove/scoped.js +136 -0
  68. package/dist/local/resolve/barrelWalker.js +178 -0
  69. package/dist/local/resolve/exportIndex.js +270 -0
  70. package/dist/local/resolve/importGraph.js +347 -0
  71. package/dist/local/resolve/resolver.js +122 -0
  72. package/dist/local/resolve/resolverCache.js +117 -0
  73. package/dist/local/rtm.js +413 -0
  74. package/dist/local/score/coverage.js +99 -0
  75. package/dist/local/score/doctor.js +67 -0
  76. package/dist/local/score/risk.js +362 -0
  77. package/dist/local/score/score.js +182 -0
  78. package/dist/local/types.js +1 -0
  79. package/dist/local/util/hash.js +16 -0
  80. package/dist/local/util/ids.js +16 -0
  81. package/dist/local/util/progress.js +8 -0
  82. package/dist/local/util/redact.js +39 -0
  83. package/dist/local/util/time.js +1 -0
  84. package/dist/local/util/walk.js +174 -0
  85. package/dist/local/viz/behaviorReportData.js +367 -0
  86. package/dist/local/viz/behaviorReportHtml.js +664 -0
  87. package/dist/local/viz/d3.bundle.js +3 -0
  88. package/dist/local/viz/html.js +1152 -0
  89. package/dist/local/viz/payload.js +525 -0
  90. package/dist/local/workspace.js +99 -0
  91. package/docs/agent-workflow.md +167 -0
  92. package/docs/agents/claude-code.md +43 -0
  93. package/docs/agents/codex.md +52 -0
  94. package/docs/agents/cursor.md +39 -0
  95. package/docs/agents/opencode.md +43 -0
  96. package/docs/agents/vscode.md +34 -0
  97. package/docs/local-proof-kit.md +269 -0
  98. package/package.json +92 -0
  99. package/scripts/spikes/dynamic-proof-jest-reporter.cjs +66 -0
  100. package/scripts/spikes/dynamic-proof-mocha-reporter.cjs +105 -0
  101. package/scripts/spikes/dynamic-proof-spike.mjs +2335 -0
  102. package/scripts/spikes/dynamic-proof-vitest-reporter.mjs +81 -0
  103. package/scripts/spikes/failure-summary.mjs +29 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Resolver-derived subject imports for generated tests.
3
+ *
4
+ * When a generated test has NO import to reuse from a linked existing test, the
5
+ * kit must NOT guess a module specifier from the behavior name (the old
6
+ * `synthesizeImports` slug-guess produced `./feature-slug`, which rarely resolves).
7
+ * Instead, derive the import from the import graph + resolver and emit it ONLY when:
8
+ * 1. a related SOURCE file with a real exported symbol exists, and
9
+ * 2. a relative specifier from the generated test's location is confirmed by the
10
+ * resolver to point back at that source file.
11
+ * Otherwise return null — the caller marks the test a non-runnable grounded draft
12
+ * rather than fabricate an import.
13
+ *
14
+ * Metadata only: reads export NAMES + resolves specifiers; never copies source text.
15
+ */
16
+ import path from "node:path";
17
+ import { resolveImport } from "../resolve/resolver.js";
18
+ import { buildExportIndex } from "../resolve/exportIndex.js";
19
+ const TS_JS = /\.(ts|tsx|js|jsx|mjs|cjs|mts|cts)$/i;
20
+ const TEST_FILE = /(\.(test|spec)\.[cm]?[jt]sx?$)|(_test\.[a-z]+$)|(_spec\.[a-z]+$)|((^|\/)test_[^/]+\.[a-z]+$)/i;
21
+ /** Drop a TS/JS extension so a relative specifier can be rebuilt with the right one. */
22
+ function stripExt(p) {
23
+ return p.replace(/\.(tsx?|jsx?|mjs|cjs|mts|cts)$/i, "");
24
+ }
25
+ /**
26
+ * Choose a real exported symbol to import: prefer a named export whose name relates
27
+ * to the behavior feature, else the first named (non-type) export, else a default
28
+ * export. Returns null when the file exposes no importable runtime binding.
29
+ */
30
+ function pickSymbol(local, feature) {
31
+ const runtime = [...local].filter(([, k]) => k !== "type"); // type-only exports aren't runnable subjects
32
+ if (runtime.length === 0)
33
+ return null;
34
+ const nonDefault = runtime.filter(([, k]) => k !== "default").map(([n]) => n);
35
+ const hasDefault = runtime.some(([, k]) => k === "default");
36
+ const feat = feature.toLowerCase().replace(/[^a-z0-9]/g, "");
37
+ if (feat) {
38
+ const match = nonDefault.find((n) => {
39
+ const ln = n.toLowerCase();
40
+ return ln.includes(feat) || feat.includes(ln);
41
+ });
42
+ if (match)
43
+ return { name: match, isDefault: false };
44
+ }
45
+ if (nonDefault.length > 0)
46
+ return { name: nonDefault[0], isDefault: false };
47
+ if (hasDefault)
48
+ return { name: "Subject", isDefault: true };
49
+ return null;
50
+ }
51
+ function importLine(symbol, specifier) {
52
+ const spec = JSON.stringify(specifier);
53
+ return symbol.isDefault ? `import ${symbol.name} from ${spec};` : `import { ${symbol.name} } from ${spec};`;
54
+ }
55
+ /**
56
+ * Derive a VALIDATED subject import for a generated test, or null if none can be
57
+ * derived without guessing. TS/JS only (the resolver does not handle Python/Go
58
+ * import systems). `candidateSourceFiles` are the behavior's related source files,
59
+ * import-resolved first (see `relatedFilePaths`).
60
+ */
61
+ export function deriveSubjectImport(graph, behavior, candidateSourceFiles, generatedTestRelPath, framework) {
62
+ const fw = framework.toLowerCase();
63
+ if (fw.includes("pytest") || fw.includes("python") || fw.includes("go"))
64
+ return null;
65
+ const root = graph.workspace.root;
66
+ const testAbs = path.join(root, generatedTestRelPath);
67
+ const testDir = path.dirname(testAbs);
68
+ const feature = String(behavior.properties.feature ?? behavior.title ?? "");
69
+ for (const rel of candidateSourceFiles) {
70
+ if (!TS_JS.test(rel) || TEST_FILE.test(rel))
71
+ continue; // source modules only
72
+ const abs = path.join(root, rel);
73
+ const symbol = pickSymbol(buildExportIndex(abs).local, feature);
74
+ if (!symbol)
75
+ continue;
76
+ // Build a relative specifier from the generated test's directory to the source.
77
+ let relSpec = path.relative(testDir, stripExt(abs)).split(path.sep).join("/");
78
+ if (!relSpec.startsWith("."))
79
+ relSpec = "./" + relSpec;
80
+ // Try the NodeNext `.js` extension first, then extensionless (bundler/classic).
81
+ // The RESOLVER decides which actually points back at the source file, so we
82
+ // never emit a specifier the repo's own config cannot resolve.
83
+ for (const spec of [`${relSpec}.js`, relSpec]) {
84
+ const r = resolveImport(spec, testAbs);
85
+ if (r.resolved && r.resolvedFileName && path.resolve(r.resolvedFileName) === path.resolve(abs)) {
86
+ return { line: importLine(symbol, spec), symbol: symbol.name, source_file: rel };
87
+ }
88
+ }
89
+ }
90
+ return null;
91
+ }