@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,167 @@
1
+ # Coding Agent Workflow
2
+
3
+ OrangePro builds the local evidence graph. Your coding agent writes files, runs
4
+ tests, and reports results.
5
+
6
+ ## Setup
7
+
8
+ For Codex, prefer the plugin when it is available:
9
+
10
+ ```bash
11
+ codex plugin add orangepro
12
+ ```
13
+
14
+ Until OrangePro is accepted into a default marketplace, add this repo as a Codex marketplace:
15
+
16
+ ```bash
17
+ codex plugin marketplace add OrangeproAI/orangepro-mcp --sparse .agents/plugins --sparse plugins/orangepro
18
+ codex plugin add orangepro@orangepro
19
+ ```
20
+
21
+ For maintainer-local development before npm publishing:
22
+
23
+ ```bash
24
+ codex plugin add orangepro@personal
25
+ ```
26
+
27
+ For Claude Code, add this repo as a Claude plugin marketplace and install the bundled MCP plugin:
28
+
29
+ ```text
30
+ /plugin marketplace add OrangeproAI/orangepro-mcp
31
+ /plugin install orangepro@orangepro
32
+ /reload-plugins
33
+ ```
34
+
35
+ For Cursor, install OrangePro from the Cursor Marketplace when available. Until then, use the bundled plugin directory at `plugins/orangepro` for local testing, or add the MCP server manually from the Cursor doc.
36
+
37
+ ## Publishing Checklist
38
+
39
+ Before public plugin launch:
40
+
41
+ 1. Publish `@orangepro/orangepro-mcp` to npm so plugin MCP configs can run `npx -y -p @orangepro/orangepro-mcp@latest opro mcp`.
42
+ 2. Create and verify the fresh-history public export; do not publish a repo with private history.
43
+ 3. Codex: ship `.agents/plugins/marketplace.json` and `plugins/orangepro`; bare `codex plugin add orangepro` needs a configured/default marketplace listing.
44
+ 4. Claude Code: ship `.claude-plugin/marketplace.json` and `plugins/orangepro`; directory discovery is a separate marketplace/listing step.
45
+ 5. Cursor: submit `plugins/orangepro` to the Cursor Marketplace when ready; local testing uses that same directory.
46
+ 6. OpenCode / VS Code: keep the MCP snippets current until they expose a plugin marketplace path for this style of local server.
47
+ 7. Smoke every path in a clean checkout and verify no config pins a model or commits a provider key.
48
+
49
+ Build the CLI and print a client-ready MCP block:
50
+
51
+ ```bash
52
+ npm run build
53
+ opro
54
+ opro agent --client claude-code
55
+ opro agent --client cursor
56
+ opro agent --client codex
57
+ opro agent --client opencode
58
+ ```
59
+
60
+ Use `--json` if your setup script wants structured output:
61
+
62
+ ```bash
63
+ opro agent --client generic --json
64
+ ```
65
+
66
+ The generated MCP config points at the local `opro mcp` server and intentionally
67
+ does not pin a model. If your MCP client does not inherit shell environment
68
+ variables, add provider keys/model defaults to that client's local config, or
69
+ place provider values in a local `.env.provider.local` file in the
70
+ repo/workspace. Do not commit client config files or env files that contain keys.
71
+
72
+ ## Agent Instruction
73
+
74
+ Use this as the short instruction for Codex, Claude Code, Cursor, OpenCode, Windsurf, or
75
+ any MCP-capable coding agent:
76
+
77
+ ```text
78
+ Use OrangePro before writing tests.
79
+
80
+ Start:
81
+ 1. Call orangepro_start for the local checkout.
82
+ 2. If it reports a large-repo scope breakdown, prefer the suggested focused scope for AI/generation; full deterministic analysis is still allowed.
83
+ 3. Use its graph_html_path, rtm path, and next_actions as the test plan.
84
+ 4. If AI grounding is skipped, continue with the deterministic graph instead of asking the user for extra commands.
85
+
86
+ For PR work:
87
+ 1. Call orangepro_generate_tests with base_ref=main.
88
+ 2. Use the changed behaviors returned by orangepro_start as context.
89
+ 3. Use only generated tests that include run_hints.
90
+ 4. Write each body to its suggested_path.
91
+ 5. Run the run_command from the owning package directory.
92
+ 6. After a pass, call the returned prove_run args to attempt public Proven; use record_run only for static diagnostics.
93
+ 7. Report pass/fail with stack traces and exact setup problems.
94
+
95
+ For baseline work:
96
+ 1. Call orangepro_find_test_gaps.
97
+ 2. Pick one high-priority gap.
98
+ 3. Call orangepro_generate_tests for that target.
99
+ 4. Write, run, and report only runnable tests.
100
+ 5. After a pass, call the returned prove_run args to attempt public Proven; use record_run only for static diagnostics.
101
+
102
+ Do not treat drafts as runnable tests. Drafts are context.
103
+ Do not claim coverage changed unless OrangePro reports Proven, Reproven, Runtime-covered, Associated signal, or No integration signal changed.
104
+ ```
105
+
106
+ ## CLI Fallback
107
+
108
+ If the agent has shell access but no MCP client, use the CLI:
109
+
110
+ ```bash
111
+ opro
112
+ opro start . --generate-coverage
113
+ opro gaps --limit 10
114
+ opro generate --base main --single --limit 3
115
+ opro generate --target <target-id> --single --limit 1
116
+ opro explain <generated-test-id>
117
+ opro export --format graph-html --out .orangepro/graph.html
118
+ ```
119
+
120
+ `generate --base main` is read-only: it uses `git diff` and does not check out a
121
+ PR. `generate --pr <n>` is the mutating escape hatch and should only be used when
122
+ the developer explicitly allows the working tree to switch.
123
+
124
+ ## What Counts
125
+
126
+ - **Runnable**: the generated test has `run_hints`, the agent writes it to
127
+ `suggested_path`, and the repo's test runner executes it.
128
+ - **Draft**: grounded context with no run command. Useful for a developer, but
129
+ not a runnable-test claim.
130
+ - **Proven**: dynamic targeted-proof ledger certificate closed for the behavior; no LLM judgment or static-only match is involved.
131
+ - **Reproven**: this run produced the dynamic proof certificate. Older static re-analysis records are associated diagnostics until that certificate exists.
132
+ - **Runtime-covered**: the repo's own coverage tool executed the code; this is runtime observation, not assertion-level proof.
133
+ - **Associated signal**: OrangePro found a name, path, import, or structural test signal, but not semantic proof.
134
+ - **No integration signal**: no static test signal was found.
135
+
136
+ Generated-test promotion numbers should count only tests that run in the target
137
+ repo, reference real product symbols, and contain non-vacuous assertions.
138
+
139
+ ## AGENTS.md Snippet
140
+
141
+ For repos that use an `AGENTS.md`, keep the OrangePro instruction short:
142
+
143
+ ```markdown
144
+ ## OrangePro Test Workflow
145
+
146
+ - Run `opro` before adding tests. It writes graph, RTM, optional AI weak grounding when configured, and next actions.
147
+ - For PR work, run `opro generate --base main --single --limit 3`.
148
+ - For baseline gaps, run `opro gaps --limit 10`, pick one target, then run
149
+ `opro generate --target <target-id> --single --limit 1`.
150
+ - Write only tests that include `run_hints`; drafts are context, not runnable claims.
151
+ - Write each generated body to `suggested_path`, run `run_command`, call the returned `prove_run` args after a pass to attempt public Proven. Use `record_run` only for static diagnostics.
152
+ - Report coverage status as Proven / Reproven / Runtime-covered / Associated signal / No integration signal. Do not promote Associated signal or AI links to Proven.
153
+ ```
154
+
155
+ ## Verification Loop
156
+
157
+ After the agent writes a passing test:
158
+
159
+ ```bash
160
+ opro
161
+ opro start . --generate-coverage
162
+ opro status
163
+ opro gaps --limit 10
164
+ ```
165
+
166
+ Report what changed. If nothing moved from No integration signal or Associated signal to Proven, say so
167
+ plainly.
@@ -0,0 +1,43 @@
1
+ # OrangePro With Claude Code
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g @orangepro/orangepro-mcp
7
+ cd /path/to/your/repo
8
+ opro
9
+ ```
10
+
11
+ `opro` prepares the behavior report, RTM, and agent next actions. If your shell has a model key, weak AI grounding and AI-suggested candidate flows run automatically. AI lanes are suggestions only; Proven remains dynamic targeted proof only.
12
+
13
+ ## Claude Plugin
14
+
15
+ Install the bundled plugin from this repo marketplace:
16
+
17
+ ```text
18
+ /plugin marketplace add OrangeproAI/orangepro-mcp
19
+ /plugin install orangepro@orangepro
20
+ /reload-plugins
21
+ ```
22
+
23
+ The plugin starts the `orangepro-local` MCP server automatically and exposes the `/orangepro:opro` skill. It does not pin a model; OrangePro uses provider/model values from the environment, `.env.provider.local`, `.env.local`, `.env`, or `opro setup`.
24
+
25
+ ## MCP Setup
26
+
27
+ Print the Claude Code config:
28
+
29
+ ```bash
30
+ opro agent --client claude-code
31
+ ```
32
+
33
+ Paste the printed `mcpServers.orangepro-local` block into the project `.mcp.json` or your Claude Code MCP config. If Claude Code does not inherit shell variables, add the provider key to that local config, or keep it in a repo-local `.env.provider.local` file that is not committed.
34
+
35
+ The printed config intentionally does not pin a model. OrangePro uses the provider/model configured in the process environment, `.env.provider.local`, `.env.local`, `.env`, or `opro setup`.
36
+
37
+ If your Claude Code setup supports custom slash commands, map `/opro` to: call `orangepro_start` for the current checkout, then follow the returned `next_actions`. The command should call the MCP tool; it should not run a separate source-writing script.
38
+
39
+ ## Agent Prompt
40
+
41
+ ```text
42
+ Use OrangePro first. Call orangepro_start, then use orangepro_generate_tests for the returned PR or gap target. Write each runnable test to suggested_path, run run_command, and call prove_run with the result for public Proven. Use record_run only for static diagnostics. Do not treat drafts as runnable tests.
43
+ ```
@@ -0,0 +1,52 @@
1
+ # OrangePro With Codex
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g @orangepro/orangepro-mcp
7
+ cd /path/to/your/repo
8
+ opro
9
+ ```
10
+
11
+ `opro` writes `.orangepro/behavior-coverage.html` and `.orangepro/rtm.md`. If a model key is available in the environment, it also applies weak AI grounding and AI-suggested candidate flows automatically. Proven coverage still comes only from dynamic targeted proof.
12
+
13
+ ## Codex Plugin
14
+
15
+ When OrangePro is available in your configured Codex marketplace, install it like any other plugin:
16
+
17
+ ```bash
18
+ codex plugin add orangepro
19
+ ```
20
+
21
+ Until OrangePro is accepted into a default marketplace, add this repo as a Codex marketplace and install from it:
22
+
23
+ ```bash
24
+ codex plugin marketplace add OrangeproAI/orangepro-mcp --sparse .agents/plugins --sparse plugins/orangepro
25
+ codex plugin add orangepro@orangepro
26
+ ```
27
+
28
+ For maintainer-local development before npm publishing, install the personal marketplace plugin:
29
+
30
+ ```bash
31
+ codex plugin add orangepro@personal
32
+ ```
33
+
34
+ The plugin starts the `orangepro-local` MCP server. It does not pin an LLM model; OrangePro uses the provider/model configured in your environment, `.env.provider.local`, `.env.local`, `.env`, or `opro setup`.
35
+
36
+ ## MCP Setup
37
+
38
+ Print a Codex-ready config block:
39
+
40
+ ```bash
41
+ opro agent --client codex
42
+ ```
43
+
44
+ Add the printed `mcpServers.orangepro-local` block to the MCP settings your Codex environment uses. The printed config intentionally omits model settings. If Codex does not inherit your shell environment, put `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, or `OLLAMA_BASE_URL` in the local client config, or keep them in a repo-local `.env.provider.local` file that is not committed.
45
+
46
+ If your Codex build supports plugin/shortcut commands, map `$opro` (or `/opro`) to: call `orangepro_start` for the current checkout, then follow the returned `next_actions`. The MCP tool is the source of truth; the shortcut is just a convenience wrapper.
47
+
48
+ ## Agent Prompt
49
+
50
+ ```text
51
+ Use OrangePro first. Call orangepro_start for this checkout, inspect the returned next_actions, then generate tests only through orangepro_generate_tests. Write only runnable tests with run_hints. After running them, call prove_run with the provided args for public Proven. Use record_run only for static diagnostics.
52
+ ```
@@ -0,0 +1,39 @@
1
+ # OrangePro With Cursor
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g @orangepro/orangepro-mcp
7
+ cd /path/to/your/repo
8
+ opro
9
+ ```
10
+
11
+ The first `opro` run creates `.orangepro/behavior-coverage.html`, `.orangepro/rtm.md`, and an agent-ready plan. With a configured model key, weak AI grounding and AI-suggested candidate flows are applied automatically and stay out of Proven coverage.
12
+
13
+ ## Cursor Plugin
14
+
15
+ Install OrangePro from the Cursor Marketplace when it is listed. Until then, use the bundled plugin directory for local testing:
16
+
17
+ ```text
18
+ plugins/orangepro
19
+ ```
20
+
21
+ The plugin starts the `orangepro-local` MCP server through `npx -y -p @orangepro/orangepro-mcp@latest opro mcp` and applies OrangePro rules for gap/test workflows. It does not pin a model; provider keys and model defaults come from your environment, `.env.provider.local`, `.env.local`, `.env`, or `opro setup`.
22
+
23
+ ## MCP Setup
24
+
25
+ Print the Cursor MCP block:
26
+
27
+ ```bash
28
+ opro agent --client cursor
29
+ ```
30
+
31
+ Paste the printed block into Cursor Settings -> MCP or `~/.cursor/mcp.json`. If Cursor does not inherit your shell environment, add the provider key to the local MCP config, or keep it in a repo-local `.env.provider.local` file that is not committed.
32
+
33
+ If your Cursor setup supports custom commands, map `/opro` to: call `orangepro_start` for the current checkout, then follow the returned `next_actions`. The shortcut should use the MCP tool so Proven / Associated signal / No integration signal semantics stay intact.
34
+
35
+ ## Agent Prompt
36
+
37
+ ```text
38
+ Use OrangePro first. Call orangepro_start in this repo, then follow its next_actions. Generate tests with orangepro_generate_tests, write only runnable outputs with run_hints, run the suggested command, and call prove_run after a passing run for public Proven. Use record_run only for static diagnostics.
39
+ ```
@@ -0,0 +1,43 @@
1
+ # OrangePro With OpenCode
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g @orangepro/orangepro-mcp
7
+ cd /path/to/your/repo
8
+ opro
9
+ ```
10
+
11
+ `opro` is the one-command preparation step: behavior report, RTM, optional weak AI grounding and AI-suggested candidate flows when a provider key is configured, and next actions for the agent.
12
+
13
+ ## MCP Setup
14
+
15
+ Print the OpenCode MCP block:
16
+
17
+ ```bash
18
+ opro agent --client opencode
19
+ ```
20
+
21
+ Add the printed `mcpServers.orangepro-local` block to your OpenCode MCP settings. If OpenCode does not inherit your shell environment, put the model provider key in the local MCP config, or keep it in a repo-local `.env.provider.local` file that is not committed.
22
+
23
+ For a direct OpenCode config, add this server under `mcp`:
24
+
25
+ ```jsonc
26
+ {
27
+ "mcp": {
28
+ "orangepro-local": {
29
+ "enabled": true,
30
+ "command": "npx",
31
+ "args": ["-y", "-p", "@orangepro/orangepro-mcp@latest", "opro", "mcp"]
32
+ }
33
+ }
34
+ }
35
+ ```
36
+
37
+ If your OpenCode setup supports slash or dollar commands, map `/opro` or `$opro` to: call `orangepro_start` for the current checkout, then follow the returned `next_actions`. The shortcut should call the MCP tool; it is not a separate graph builder.
38
+
39
+ ## Agent Prompt
40
+
41
+ ```text
42
+ Use OrangePro first. Call orangepro_start, generate tests only through orangepro_generate_tests, write runnable tests with run_hints, run the command, and call prove_run after a pass for public Proven. Use record_run only for static diagnostics. Report setup failures plainly.
43
+ ```
@@ -0,0 +1,34 @@
1
+ # OrangePro With VS Code / Copilot
2
+
3
+ ## Install
4
+
5
+ ```bash
6
+ npm install -g @orangepro/orangepro-mcp
7
+ cd /path/to/your/repo
8
+ opro
9
+ ```
10
+
11
+ `opro` writes `.orangepro/behavior-coverage.html`, `.orangepro/rtm.md`, and next actions. With a configured provider key, weak AI grounding and AI-suggested candidate flows run automatically and stay out of Proven coverage.
12
+
13
+ ## MCP Setup
14
+
15
+ Add OrangePro as an MCP server in your user or workspace MCP config:
16
+
17
+ ```json
18
+ {
19
+ "servers": {
20
+ "orangepro-local": {
21
+ "command": "npx",
22
+ "args": ["-y", "-p", "@orangepro/orangepro-mcp@latest", "opro", "mcp"]
23
+ }
24
+ }
25
+ }
26
+ ```
27
+
28
+ Do not hardcode provider keys in a committed workspace config. Prefer your shell environment, `.env.provider.local`, `.env.local`, `.env`, or `opro setup`.
29
+
30
+ ## Agent Prompt
31
+
32
+ ```text
33
+ Use OrangePro first. Call orangepro_start for this repo, then follow next_actions. Generate tests with orangepro_generate_tests, write only runnable outputs with run_hints, run the suggested command, and call prove_run after a pass for public Proven. Use record_run only for static diagnostics.
34
+ ```
@@ -0,0 +1,269 @@
1
+ # OrangePro (`opro`)
2
+
3
+ Try graph-grounded test generation **on your own machine, before creating a tenant
4
+ or granting repo access.** OrangePro builds an evidence graph from a
5
+ local checkout, scores its readiness, generates a few grounded tests with **your own
6
+ model key**, and exports a portable evidence pack you can inspect — and later promote
7
+ into a hosted OrangePro tenant.
8
+
9
+ ## Privacy first
10
+
11
+ - **No stored source.** Source is read in-process. When model generation is enabled,
12
+ redacted source excerpts may be sent to your configured BYOK provider; OrangePro does
13
+ not upload repos to an OrangePro tenant and does not store raw source in local artifacts.
14
+ - **Metadata-only artifacts.** `metadata_only` means **no source code** in the graph,
15
+ manifest, or evidence pack — only file paths, names, hashes, frameworks, and provenance.
16
+ Source files are read in-process only to ground generation, and obvious secrets are
17
+ redacted first. **Generated test bodies are model output kept in the local graph; the
18
+ exported pack and graph HTML exclude them by default — embed bodies in the pack only with
19
+ `--include-generated-bodies`.** *Text you explicitly supply via a CSV/Markdown template* (requirement
20
+ titles, descriptions, acceptance criteria) **is** included in the pack — that text is the
21
+ reviewed evidence you chose to provide, so keep templates to releasable business metadata.
22
+ - **Your keys stay yours.** Model API keys are read from the environment at call time
23
+ and are never written into the graph, config, or pack.
24
+ - **Local only.** All workspace-local writes live under `.orangepro/`; no source or test files in your repo are written. Add
25
+ `.orangeproignore` (same spirit as `.gitignore`) to exclude paths from analysis.
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ npm ci && npm run build
31
+ npm link # one-time: exposes the short `opro` command on your PATH
32
+ # CLI is then available as: opro … (equivalently node dist/local/cli.js …, or `npm run local -- …` in dev)
33
+ ```
34
+
35
+ ## Demo (one reproducible run)
36
+
37
+ ```bash
38
+ node scripts/demo-local-proof-kit.mjs --repo /path/to/repo --provider deterministic
39
+ ```
40
+
41
+ Runs analyze → score → doctor → gaps → generate (Local KG vs raw prompt) → export
42
+ end-to-end in a throwaway workspace and prints a readable report when running from a
43
+ source checkout. npm users can run the CLI commands below directly.
44
+
45
+ ## CLI
46
+
47
+ ```bash
48
+ opro # one-command start: analyze, optional AI weak links, graph, RTM, next actions
49
+ opro init # create the .orangepro/ workspace
50
+ opro analyze . # build the local evidence graph + write .orangepro/graph.html (scan-all by default)
51
+ opro status # fresh / stale / missing + score + privacy
52
+ opro doctor # smallest next source that improves test quality
53
+ opro score # readiness score + breakdown + "why not higher"
54
+ opro gaps --limit 10 # behaviors with weak/missing test evidence
55
+ opro generate --target REQ-001 --framework playwright --limit 3 # default: A/B (prompt-only vs Local KG), scored + report
56
+ opro generate --single --limit 3 # one arm only — persists the tests to the graph
57
+ opro generate --base main # PR-scoped: target only behaviors the diff vs main touches
58
+ opro generate --pr 123 # advanced: checks out PR #123 (changes your working tree), re-analyzes, targets its diff
59
+ opro generate --base main --background # PR-scoped + detached; poll with `opro jobs`
60
+ opro jobs [<id>] # list background jobs, or show one (status + outputs + log)
61
+ opro explain <generated_test_id># which evidence anchors grounded a test
62
+ opro update # incremental, non-destructive refresh
63
+ opro changed --base main # changed files + affected behaviors/tests
64
+ opro export --out orangepro-evidence-pack.json
65
+ opro analyze . --no-graph-html # skip the explorer (it is written by default)
66
+ opro export --format graph-html # write just the explorer (orangepro-graph.html)
67
+ opro mcp # run the MCP server (stdio)
68
+ ```
69
+
70
+ Report commands default to `.orangepro/`. When you are collecting a public
71
+ validation bundle, pass an explicit local path such as
72
+ `opro rtm --format json --out /tmp/orangepro-run/rtm.json`.
73
+
74
+ Runnable Python and Go generation uses local syntax validators before OrangePro
75
+ returns a run command: `python3` for pytest bodies and `gofmt` for Go bodies. If
76
+ the toolchain is missing or the generated body is not valid for that language,
77
+ the test is returned as a grounded draft with no run hint.
78
+
79
+ Scan-all is the default: `analyze` no longer caps inferred behavior anchors at a low
80
+ number (lower it with `ORANGEPRO_MAX_FLOWS` / `ORANGEPRO_MAX_FILES` only to bound a
81
+ huge run), and it prints `files scanned: N` plus any cap that was hit.
82
+
83
+ ### Evidence graph explorer
84
+
85
+ `analyze` writes a **self-contained, offline** HTML explorer to `.orangepro/graph.html`
86
+ **by default** (`--no-graph-html` to skip; or `export --format graph-html` for a
87
+ standalone copy) — no CDN, no network, metadata-only (never source, bodies, or prompts).
88
+ It opens
89
+ score-first, shows a *summarized* evidence layer (not a 3k-node hairball), and lets you
90
+ search a symbol (e.g. `useScaledAmount`), click it, and see the connected files, tests,
91
+ behaviors, and provenance — the visual half of "here's *why* the generated tests are
92
+ grounded." Tabs: Overview · Coverage (behavior → test → file/symbol) · Gaps. Deep-link with
93
+ `?select=<id|label>&view=<overview|coverage|gaps>`.
94
+
95
+ Add `--json` to any read command for machine-readable output. Optional enrichers:
96
+ point `analyze` at a small CSV requirements template or Markdown docs to raise the
97
+ score and test specificity (`analyze . --paths payments-template.csv`).
98
+
99
+ ## BYOK (bring your own model key)
100
+
101
+ Provider adapters, auto-detected in order **OpenAI-compatible → Ollama → Anthropic**:
102
+
103
+ | Provider | Env |
104
+ |---|---|
105
+ | OpenAI-compatible | `OPENAI_API_KEY`, optional `OPENAI_BASE_URL`, `OPENAI_MODEL` |
106
+ | Ollama (local) | `OLLAMA_BASE_URL`, optional `OLLAMA_MODEL` |
107
+ | Anthropic | `ANTHROPIC_API_KEY`, optional `ANTHROPIC_MODEL` |
108
+
109
+ With **no model key set, no tests are generated** — `generate` returns setup guidance
110
+ instead (the BYOK contract never silently degrades to a non-model output). To run fully
111
+ offline, opt in explicitly with `--provider deterministic` (CLI) or
112
+ `ORANGEPRO_ALLOW_DETERMINISTIC=1`, which uses a clearly-labeled deterministic stand-in.
113
+ Static analysis, scoring, gaps, and pack export never need a model.
114
+
115
+ ## Scenario buckets (generation diversity)
116
+
117
+ `generate` is **target-focused**: it picks the top-gap behavior (or your `--target`)
118
+ and produces up to `--limit` tests for that one behavior, each covering a different
119
+ lightweight **local scenario bucket** when the evidence supports it:
120
+
121
+ `happy_path` · `validation_error` · `edge_case` · `integration_flow` · `security_privacy` · `regression`
122
+
123
+ Buckets are chosen from the behavior's own evidence (acceptance criteria, code
124
+ context, related tests, weak/candidate edges) and are **never padded** — an
125
+ unjustified bucket is skipped rather than filled with a generic smoke test. Each
126
+ generated test reports its bucket, cites the evidence anchors it used, and discloses
127
+ any weak evidence. Passing several `--target` ids splits the budget across them (each
128
+ gets a test when the budget allows, in priority order). Total caps are unchanged
129
+ (default 3, max 5).
130
+ These are the local kit's own categories — the hosted platform owns full bucket
131
+ orchestration, caps, and lifecycle coverage.
132
+
133
+ ## MCP (any agent: Cursor, Codex, Claude, Copilot, …)
134
+
135
+ Run `opro agent --client claude-code|cursor|codex|opencode` to print a client-ready MCP
136
+ config plus the write/run/report loop. The shipped guide is
137
+ [agent-workflow.md](agent-workflow.md), with per-agent setup notes for
138
+ [Codex](agents/codex.md), [Claude Code](agents/claude-code.md),
139
+ [Cursor](agents/cursor.md), and [OpenCode](agents/opencode.md).
140
+
141
+ ```json
142
+ {
143
+ "mcpServers": {
144
+ "orangepro-local": {
145
+ "command": "node",
146
+ "args": ["/absolute/path/to/orangepro-mcp/dist/local/cli.js", "mcp"],
147
+ "env": { "OPENAI_API_KEY": "<your local key>" }
148
+ }
149
+ }
150
+ }
151
+ ```
152
+
153
+ First-slice MCP tools (same behavior as the CLI, same core): `orangepro_start`, `orangepro_analyze_sources`,
154
+ `orangepro_graph_score`, `orangepro_status`, `orangepro_doctor`, `orangepro_find_test_gaps`,
155
+ `orangepro_record_run`, `orangepro_prove`, `orangepro_stats`, `orangepro_rtm`, `orangepro_update_graph`,
156
+ `orangepro_changed_impact`, `orangepro_ai_links`, `orangepro_ai_flows`, `orangepro_generate_tests`,
157
+ `orangepro_explain_test`, `orangepro_export_evidence_pack`. **No upload or repo-write tools.**
158
+
159
+ ### Tool modes (baseline vs diff/PR)
160
+
161
+ Two explicit classes, so an agent never fabricates PR analysis when there is no PR:
162
+
163
+ - **Baseline tools** — the *"try OrangePro on any repo"* entry point. They run on the
164
+ current local graph/checkout and need **no diff or PR**: `orangepro_start`,
165
+ `orangepro_analyze_sources`, `orangepro_status`, `orangepro_graph_score`,
166
+ `orangepro_doctor`, `orangepro_find_test_gaps`, `orangepro_rtm`,
167
+ `orangepro_generate_tests`, `orangepro_record_run`, `orangepro_prove`, `orangepro_stats`,
168
+ `orangepro_explain_test`, `orangepro_export_evidence_pack`.
169
+ - **Diff/PR tools** — only for **real code-review situations**. They require a git repo
170
+ and a real diff vs a base ref (default `main`). Today: `orangepro_changed_impact`
171
+ (future helpers may split risk and test-plan output, but they are not separate MCP
172
+ tools today). When there is nothing to
173
+ analyze they return a structured `status` + `guidance` instead of fabricated output:
174
+ - `not_a_git_repo` — the checkout is not a git repository.
175
+ - `missing_base_ref` — the base ref does not exist; pass an existing `base_ref`.
176
+ - `no_diff` — no changed files; run on a feature branch, pass `base_ref`, or use
177
+ `orangepro_find_test_gaps` for baseline opportunities.
178
+
179
+ Still no source/test file writes and no repo upload to an OrangePro tenant — and no hallucinated impact when there is no diff.
180
+
181
+ ## The evidence graph
182
+
183
+ OrangePro-shaped, test-generation-oriented — **not** a generic code graph. Every node and
184
+ edge carries an **evidence strength** (`hard` / `reviewed` / `candidate` / `weak`) and
185
+ **provenance**. Explicit source refs, exact ids/paths, and reviewed template rows are hard
186
+ evidence; LLM/similarity inference is candidate-only and never counts as proof. Generated
187
+ tests link back to the graph evidence that grounded them, and disclose any weak evidence used.
188
+
189
+ For coverage scoring, OrangePro uses one public glossary:
190
+
191
+ - **Dynamically Proven** (labeled "Dynamically Proven" in the report/CLI/RTM) means a dynamic
192
+ targeted-proof ledger certificate closed for the behavior: baseline green, target mutated, same
193
+ test failed at an assertion, and the target was not mocked. The static map covers the whole repo;
194
+ the dynamic pass proves only the top few eligible behaviors per run (default 5, `--auto-limit` to raise).
195
+ - **Runtime-covered** means the repo's own coverage tool executed the code, but not that an
196
+ assertion checked the behavior.
197
+ - **Associated signal** means name, path, import, or structural matches suggest a useful link,
198
+ but not semantic proof.
199
+ - **No integration signal** means no direct static test signal was found yet. It does not mean “untested.”
200
+
201
+ The HTML report presents these as four display tiers: **Dynamically Proven**, **Statically Linked**
202
+ (the report's label for an Associated signal — a test file appears to import or call the behavior,
203
+ not dynamically verified), **Reachable Untested** (a behavior that appears in a static flow from an
204
+ entry point but has no test signal), and **No Signal** (no test or static-flow signal yet). These are
205
+ presentation labels over the same statuses above; they change no classification, count, or ledger record.
206
+
207
+ LLM, similarity inference, and static hard TESTED_BY/COVERS edges are candidate or
208
+ associated signals until a dynamic targeted proof closes.
209
+
210
+ ### Dynamic proof is TS/JS-only today (language-profiled)
211
+
212
+ Dynamic targeted proof currently runs for **TypeScript/JavaScript only** — the oracle drives
213
+ `vitest`/`jest`, and only TS/JS files are eligible for a proof target. The static map is
214
+ multi-language: **Java, Go, Rust, and Python monorepos still get the full static picture today**
215
+ (behaviors, flows, Statically Linked, Reachable Untested, and any ingested runtime coverage).
216
+
217
+ Monorepo-aware dynamic proof is delivered as per-ecosystem **profiles**. The **`ts_js` profile**
218
+ (handling `tsconfig` `extends`/`paths` monorepos) is the first and currently the only implemented
219
+ profile — the M-1/M-2 sandboxing work improves TS/JS monorepo proof only. Dynamic proof for
220
+ Java/Go/Rust/Python is future work: each needs its own test runner plus a workspace-config profile.
221
+ Until a language's profile exists, dynamic proof does **not** pretend the TS/JS fixes apply — it
222
+ reports "not supported for this language/ecosystem yet" or a precise `<lang>_workspace_config_missing`
223
+ reason, and those behaviors simply stay in their static tiers.
224
+
225
+ The local ledger is a trusted local artifact, not a cryptographic attestation. A
226
+ hosted/product proof path must bind each dynamic certificate to witnessed run artifacts
227
+ before accepting it from an untrusted client or edited checkout.
228
+
229
+ Runtime coverage is reported separately when local coverage-tool artifacts are present. The
230
+ local kit ingests Go coverprofiles, JS/TS `lcov.info`, Python coverage.py XML, and Java JaCoCo
231
+ XML. These artifacts show executed lines inside symbols; they are not assertion-level proof and
232
+ never promote Associated signal or No integration signal rows to Proven.
233
+
234
+ ## Readiness score
235
+
236
+ A 0–100 **readiness** signal (not a proof of lift), in bands: `thin` (0–39),
237
+ `usable` (40–59), `good` (60–74), `strong` (75+). The report always explains *why the
238
+ score is not higher* — that is the trust feature. Exact weights and the formula stay
239
+ internal; only the per-dimension breakdown, band, and missing-evidence are exposed.
240
+
241
+ ## Evidence pack
242
+
243
+ `export` writes a JSON pack (validated against `orangepro.local_evidence_pack.v0`) plus a
244
+ Markdown summary. The pack includes facts, provenance, evidence strength, generated outputs,
245
+ and high-level score metadata. It **excludes** prompts, prompt templates, ranking traces,
246
+ hidden weights, traversal traces, and raw source — promotion-ready, not
247
+ reverse-engineering-ready. The strict schema validator enforces this boundary.
248
+
249
+ ## Validation
250
+
251
+ Before release, the local kit is checked against representative real repositories for
252
+ broken graph edges, parser downgrades, symbol truncation, and source-leak regressions.
253
+ The public contract is simple: graph construction is deterministic and local; generated
254
+ tests cite the file paths, symbols, tests, and evidence labels that grounded them.
255
+
256
+ ### Why graph grounding helps
257
+
258
+ The headline claim is not "a graph beats a weak prompt." The useful comparison is:
259
+ same selected model, same target behavior, but one run receives concrete graph evidence
260
+ and the other does not. The graph-grounded run can cite real symbols, nearby tests,
261
+ imports, and evidence strength, so it is less likely to invent modules and easier for a
262
+ developer to verify.
263
+
264
+ ## What's deferred (hosted/premium or later phases)
265
+
266
+ Hosted upload/promotion, Docker, watch mode, PDF/DOCX, Jira/Confluence/TestRail/OpenAPI
267
+ enrichers, repo file writing (safe patch workflow), continuous coverage intelligence, and
268
+ third-party graph import. The hosted KG remains the system of record; this kit is the local
269
+ adoption surface.