@martinloop/mcp 0.3.3 → 0.3.5

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 (60) hide show
  1. package/README.md +112 -107
  2. package/dist/discovery-metadata.d.ts +6 -6
  3. package/dist/discovery-metadata.js +6 -0
  4. package/dist/discovery-support.js +2 -2
  5. package/dist/resources.d.ts +1 -0
  6. package/dist/resources.js +210 -148
  7. package/dist/server-validation.js +2 -0
  8. package/dist/server.js +87 -1
  9. package/dist/tools/eval.js +29 -5
  10. package/dist/tools/execution-policy.d.ts +11 -0
  11. package/dist/tools/execution-policy.js +47 -0
  12. package/dist/tools/run-dossier.js +2 -2
  13. package/dist/tools/run-loop.d.ts +1 -0
  14. package/dist/tools/run-loop.js +15 -2
  15. package/dist/tools/tool-support.d.ts +3 -1
  16. package/dist/tools/tool-support.js +127 -19
  17. package/dist/tools/triage-runs.js +31 -6
  18. package/dist/vendor/adapters/claude-cli.js +100 -21
  19. package/dist/vendor/adapters/cli-bridge.d.ts +16 -0
  20. package/dist/vendor/adapters/cli-bridge.js +92 -2
  21. package/dist/vendor/adapters/codex-launcher.d.ts +2 -0
  22. package/dist/vendor/adapters/codex-launcher.js +124 -10
  23. package/dist/vendor/adapters/openai-compatible.js +6 -6
  24. package/dist/vendor/contracts/adapter-capabilities.d.ts +17 -0
  25. package/dist/vendor/contracts/adapter-capabilities.js +35 -0
  26. package/dist/vendor/contracts/context-graph.d.ts +48 -0
  27. package/dist/vendor/contracts/context-graph.js +26 -0
  28. package/dist/vendor/contracts/execution-policy.d.ts +78 -0
  29. package/dist/vendor/contracts/execution-policy.js +43 -0
  30. package/dist/vendor/contracts/governance.d.ts +6 -3
  31. package/dist/vendor/contracts/identity.d.ts +29 -0
  32. package/dist/vendor/contracts/identity.js +30 -0
  33. package/dist/vendor/contracts/index.d.ts +40 -2
  34. package/dist/vendor/contracts/index.js +5 -0
  35. package/dist/vendor/contracts/observation.d.ts +21 -0
  36. package/dist/vendor/contracts/observation.js +27 -0
  37. package/dist/vendor/contracts/trajectory.d.ts +26 -0
  38. package/dist/vendor/contracts/trajectory.js +27 -0
  39. package/dist/vendor/contracts/verification.d.ts +28 -0
  40. package/dist/vendor/contracts/verification.js +7 -0
  41. package/dist/vendor/core/context-graph.d.ts +3 -0
  42. package/dist/vendor/core/context-graph.js +371 -0
  43. package/dist/vendor/core/identity.d.ts +20 -0
  44. package/dist/vendor/core/identity.js +86 -0
  45. package/dist/vendor/core/index.d.ts +10 -1
  46. package/dist/vendor/core/index.js +131 -10
  47. package/dist/vendor/core/persistence/integrity.js +2 -2
  48. package/dist/vendor/core/policy-compiler.d.ts +2 -0
  49. package/dist/vendor/core/policy-compiler.js +195 -0
  50. package/dist/vendor/core/policy.d.ts +15 -0
  51. package/dist/vendor/core/policy.js +84 -4
  52. package/dist/vendor/core/rollback.js +32 -12
  53. package/dist/vendor/core/routing.d.ts +40 -0
  54. package/dist/vendor/core/routing.js +185 -0
  55. package/dist/vendor/core/trajectory.d.ts +18 -0
  56. package/dist/vendor/core/trajectory.js +295 -0
  57. package/dist/workflow-state.d.ts +16 -0
  58. package/dist/workflow-state.js +1 -1
  59. package/package.json +76 -75
  60. package/server.json +21 -21
package/README.md CHANGED
@@ -1,132 +1,137 @@
1
1
  # @martinloop/mcp
2
2
 
3
- Governed MCP server for AI coding agents over local stdio.
4
-
5
- `@martinloop/mcp@0.3.2` is the live public baseline today. `0.3.3` is the next planned public cut.
6
-
7
- This package stays local-first and stdio-first in the public OSS lane.
8
-
9
- ## Public release train
10
-
11
- - `0.2.7` made the guided MCP workflow easier to adopt and harder to misuse.
12
- - `0.3.0` is the live adoption baseline that made host setup and onboarding clearer.
13
- - `0.3.1` is the live review and handoff release.
14
- - `0.3.2` is the live engine-validation hotfix that fixes spend-limit requests for Gemini-backed runs.
15
- - `0.3.3` is the planned follow-on for opt-in execution controls.
16
-
17
- ## What ships today
18
-
19
- ### Tools
20
-
21
- - `martin_doctor`
22
- - `martin_plan`
23
- - `martin_preflight`
24
- - `martin_run`
25
- - `martin_inspect`
26
- - `martin_status`
27
- - `martin_logs`
28
- - `martin_pause`
29
- - `martin_cancel`
30
- - `martin_continue`
31
- - `martin_list_runs`
32
- - `martin_triage_runs`
33
- - `martin_get_run`
34
- - `martin_get_attempt`
35
- - `martin_get_verification_results`
36
- - `martin_run_dossier`
37
- - `martin_dossier`
38
- - `martin_eval`
39
- - `martin_pr_summary`
40
- - `martin_create_pr`
41
- - `martin_review_pr`
42
-
43
- ### Resources
44
-
45
- - `martin://server/health`
46
- - `martin://runs/recent`
47
- - `martin://runs/triage`
48
- - `martin://runs/latest`
49
- - `martin://runs/latest/summary`
50
- - `martin://runs/latest/proof-card`
51
- - `martin://runs/latest/budget-status`
52
- - `martin://runs/latest/verifier-evidence`
53
- - `martin://runs/latest/rollback-evidence`
54
- - `martin://policies/current`
55
- - `martin://repo/risk-map`
56
- - `martin://verifiers/results`
57
- - `martin://agent/next-step`
58
- - `martin://guides/mcp-usage`
59
- - `martin://guides/agent-start`
60
- - `martin://guides/publish-readiness`
61
-
62
- ### Prompts
63
-
64
- - `martin_start`
65
- - `martin_preflight`
66
- - `martin_triage`
67
- - `martin_resume`
68
- - `martin_prove`
69
- - `martin_release_check`
70
- - `martin_governed_coding_kickoff`
71
- - `martin_debug_failed_run`
72
- - `martin_publish_readiness_review`
73
- - `martin_triage_run_store`
74
-
75
- ## Recommended flow
76
-
77
- 1. `martin_doctor`
78
- 2. `martin_plan`
79
- 3. `martin_preflight`
80
- 4. `martin_run`
81
- 5. `martin_status` or `martin_logs`
82
- 6. `martin_dossier`
83
- 7. `martin_eval`
3
+ You give an AI agent a coding task. It runs. You get a bill.
4
+
5
+ But did it actually work? Did it pass your tests? How much did it spend? What files did it touch? Did it loop 47 times trying the same broken approach?
6
+
7
+ You don't know. And that's the problem.
8
+
9
+ ## What This Does
10
+
11
+ MartinLoop is a governed loop for AI coding agents. You tell it what to do, set a budget, and point it at your test suite. It runs the agent, checks your tests after every attempt, and stops when either the tests pass or the money runs out.
12
+
13
+ When it's done, you get a receipt — not a vague summary, but a structured record: dollars spent, attempts made, verification results, files changed, and whether you got what you asked for.
14
+
15
+ **One line to connect it:**
16
+
17
+ ```sh
18
+ claude mcp add martin-loop -- npx -y @martinloop/mcp
19
+ ```
20
+
21
+ That's it. Your agent now runs governed.
22
+
23
+ ## Real Numbers From Real Runs
24
+
25
+ We tested this against live repos with real API spend:
26
+
27
+ | What happened | Without MartinLoop | With MartinLoop |
28
+ |---|---|---|
29
+ | Budget: $1.50 task | Agent spent **$28.42** | Agent stopped at **$1.20** |
30
+ | Failing verifier | Retried indefinitely | Stopped after 3 attempts with diagnosis |
31
+ | CLI not on PATH | "not available on PATH" (dead stop) | Auto-discovered in AppData, kept running |
32
+ | `bun run lint && bun run test` | Passed `&&` as a literal arg (always fails) | Routed through shell, worked |
33
+
34
+ These aren't hypotheticals. The $28 overshoot happened in production testing. We fixed the circuit breaker in `0.3.8`.
84
35
 
85
36
  ## Install
86
37
 
38
+ ### Claude Code
87
39
  ```sh
88
- npx -y @martinloop/mcp
40
+ claude mcp add martin-loop -- npx -y @martinloop/mcp
89
41
  ```
90
42
 
91
- Codex:
43
+ Windows:
44
+ ```sh
45
+ claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
46
+ ```
92
47
 
48
+ ### Codex
93
49
  ```sh
94
50
  codex mcp add martin-loop -- npx -y @martinloop/mcp
95
51
  ```
96
52
 
97
- Claude Code:
98
-
53
+ ### Gemini CLI
99
54
  ```sh
100
- # macOS/Linux
101
- claude mcp add --transport stdio --scope user martin-loop -- npx -y @martinloop/mcp
55
+ gemini mcp add martin-loop -- npx -y @martinloop/mcp
56
+ ```
102
57
 
103
- # Windows PowerShell or cmd.exe
104
- claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
58
+ ### Any MCP Host
59
+ ```sh
60
+ npx -y @martinloop/mcp
105
61
  ```
106
62
 
107
- If you want generated host config, use the MartinLoop CLI:
63
+ ## How a Governed Run Works
108
64
 
109
- ```sh
110
- martin mcp print-config --host codex --transport stdio --profile minimal
111
- martin mcp print-config --host claude --transport stdio --profile diagnostic
112
- martin mcp print-config --host gemini --transport stdio --profile full-local
113
- martin mcp print-config --host generic --transport stdio --profile github-review
114
65
  ```
66
+ You: "Fix the auth bug. Budget $3. Verify: npm test"
67
+
68
+ martin_doctor → checks CLI, auth, environment
69
+ martin_plan → scopes the task, sets constraints
70
+ martin_preflight → validates before any spend
71
+ martin_run → agent works inside budget + verifier gates
72
+ martin_dossier → receipt: $1.40 spent, 2 attempts, tests pass
73
+ ```
74
+
75
+ Every attempt runs your verifier. Every dollar is tracked. If the agent drifts off-task, the scope contract catches it. If it blows the budget, the circuit breaker kills the subprocess mid-stream — not after the bill arrives.
76
+
77
+ ## What Your Agent Gets
78
+
79
+ ### 21 Tools
80
+
81
+ **Run the loop:**
82
+ `martin_doctor` `martin_plan` `martin_preflight` `martin_run` `martin_pause` `martin_continue` `martin_cancel`
83
+
84
+ **Inspect results:**
85
+ `martin_status` `martin_logs` `martin_dossier` `martin_eval` `martin_inspect` `martin_list_runs` `martin_get_run` `martin_get_attempt` `martin_get_verification_results` `martin_triage_runs`
86
+
87
+ **Ship the work:**
88
+ `martin_pr_summary` `martin_create_pr` `martin_review_pr`
89
+
90
+ ### 11 Read-Only Resources
91
+
92
+ Your agent can pull context without side effects:
115
93
 
116
- ## Compatibility posture
94
+ `martin://runs/latest` · `martin://runs/latest/proof-card` · `martin://runs/latest/budget-status` · `martin://runs/latest/verifier-evidence` · `martin://runs/recent` · `martin://server/health` · `martin://policies/current` · `martin://agent/next-step` · `martin://guides/mcp-usage` · `martin://guides/agent-start` · `martin://repo/risk-map`
117
95
 
118
- - `martin_run` remains the single execution entrypoint.
119
- - Read-only inspection stays available without execution-capable profiles.
120
- - The OSS package stays focused on local stdio workflows. Hosted and team features live on a separate product track.
121
- - Later `0.3.x` releases should widen adoption and guidance without blurring those boundaries.
96
+ ### Configuration Profiles
122
97
 
123
- ## Verification
98
+ Generate host config tuned to your workflow:
124
99
 
125
100
  ```sh
126
- pnpm --filter @martinloop/mcp lint
127
- pnpm --filter @martinloop/mcp test
128
- pnpm --filter @martinloop/mcp build
129
- pnpm --filter @martinloop/mcp smoke:pack
130
- pnpm --filter @martinloop/mcp smoke:published:pack
131
- pnpm --filter @martinloop/mcp verify:release
101
+ npx martin-loop mcp print-config --host claude --profile minimal # run + inspect
102
+ npx martin-loop mcp print-config --host claude --profile diagnostic # + doctor + triage
103
+ npx martin-loop mcp print-config --host claude --profile full-local # all local tools
104
+ npx martin-loop mcp print-config --host claude --profile github-review # + PR workflow
132
105
  ```
106
+
107
+ ## What Happens When Things Go Wrong
108
+
109
+ MartinLoop doesn't just report failures — it tries to fix them:
110
+
111
+ | Failure | Old behavior | Now |
112
+ |---|---|---|
113
+ | CLI not on PATH | Error message, dead stop | Searches npm global, homebrew, nvm, scoop — uses what it finds |
114
+ | Verifier says "command not found" | Generic "verification failed" | Tells the next attempt: "bun is missing, install with `npm i -g bun`" |
115
+ | `git restore` fails mid-rollback | Throws, leaves dirty state | Retries once, falls back to `git checkout`, cleans up |
116
+ | Invalid `--profile` flag | Crashes | Warns, falls back to `minimal`, keeps running |
117
+
118
+ ## Who Uses This
119
+
120
+ - **Engineers running overnight agent loops** — you need a kill switch that actually works, and a receipt in the morning
121
+ - **Teams with shared API budgets** — you need per-task spend caps, not org-wide prayer
122
+ - **Anyone reviewing agent-generated PRs** — the dossier shows what the agent tried, what passed, and what didn't
123
+
124
+ ## Requirements
125
+
126
+ - Node.js 20+
127
+ - One AI coding CLI: [Claude Code](https://docs.anthropic.com/claude-code), [Codex](https://github.com/openai/codex), or [Gemini CLI](https://github.com/google/gemini-cli)
128
+
129
+ ## Links
130
+
131
+ - [martin-loop](https://www.npmjs.com/package/martin-loop) — the standalone CLI
132
+ - [GitHub](https://github.com/Keesan12/martin-loop) — source and issues
133
+ - [martinloop.com](https://martinloop.com)
134
+
135
+ ## License
136
+
137
+ Apache-2.0
@@ -1,10 +1,10 @@
1
- export declare const MARTIN_TOOL_NAMES: readonly ["martin_run", "martin_inspect", "martin_status", "martin_doctor", "martin_plan", "martin_preflight", "martin_logs", "martin_pause", "martin_cancel", "martin_continue", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_attempt", "martin_get_verification_results", "martin_run_dossier", "martin_dossier", "martin_eval", "martin_pr_summary", "martin_create_pr", "martin_review_pr"];
2
- export declare const MARTIN_STARTER_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_run", "martin_triage_runs", "martin_dossier"];
3
- export declare const MARTIN_MINIMAL_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_list_runs", "martin_triage_runs", "martin_dossier"];
4
- export declare const MARTIN_DIAGNOSTIC_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_logs", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_attempt", "martin_get_verification_results", "martin_dossier", "martin_eval"];
1
+ export declare const MARTIN_TOOL_NAMES: readonly ["martin_run", "martin_inspect", "martin_status", "martin_doctor", "martin_plan", "martin_preflight", "martin_estimate", "martin_logs", "martin_pause", "martin_cancel", "martin_continue", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_attempt", "martin_get_verification_results", "martin_run_dossier", "martin_dossier", "martin_eval", "martin_pr_summary", "martin_create_pr", "martin_review_pr"];
2
+ export declare const MARTIN_STARTER_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_estimate", "martin_run", "martin_triage_runs", "martin_dossier"];
3
+ export declare const MARTIN_MINIMAL_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_estimate", "martin_list_runs", "martin_triage_runs", "martin_dossier"];
4
+ export declare const MARTIN_DIAGNOSTIC_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_estimate", "martin_logs", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_attempt", "martin_get_verification_results", "martin_dossier", "martin_eval"];
5
5
  export declare const MARTIN_GITHUB_REVIEW_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_dossier", "martin_eval", "martin_pr_summary", "martin_create_pr", "martin_review_pr"];
6
- export declare const MARTIN_PAID_REMOTE_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_run", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_verification_results", "martin_dossier", "martin_eval"];
7
- export declare const MARTIN_RESOURCE_URIS: readonly ["martin://server/health", "martin://runs/recent", "martin://runs/triage", "martin://runs/latest", "martin://runs/latest/summary", "martin://runs/latest/proof-card", "martin://runs/latest/budget-status", "martin://runs/latest/verifier-evidence", "martin://runs/latest/rollback-evidence", "martin://policies/current", "martin://repo/risk-map", "martin://verifiers/results", "martin://agent/next-step", "martin://guides/mcp-usage", "martin://guides/agent-start", "martin://guides/command-map", "martin://guides/ide-onboarding", "martin://guides/operating-rules", "martin://guides/publish-readiness"];
6
+ export declare const MARTIN_PAID_REMOTE_TOOL_NAMES: readonly ["martin_doctor", "martin_plan", "martin_preflight", "martin_estimate", "martin_run", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_verification_results", "martin_dossier", "martin_eval"];
7
+ export declare const MARTIN_RESOURCE_URIS: readonly ["martin://server/health", "martin://runs/recent", "martin://runs/triage", "martin://runs/latest", "martin://runs/latest/summary", "martin://runs/latest/proof-card", "martin://runs/latest/budget-status", "martin://runs/latest/verifier-evidence", "martin://runs/latest/rollback-evidence", "martin://policies/current", "martin://repo/risk-map", "martin://verifiers/results", "martin://agent/next-step", "martin://agent/governance-status", "martin://guides/mcp-usage", "martin://guides/agent-start", "martin://guides/command-map", "martin://guides/ide-onboarding", "martin://guides/operating-rules", "martin://guides/publish-readiness"];
8
8
  export declare const MARTIN_RESOURCE_TEMPLATE_URIS: readonly ["martin://runs/{loopId}", "martin://runs/{loopId}/dossier", "martin://runs/{loopId}/attempts/{attemptIndex}", "martin://runs/{loopId}/verification"];
9
9
  export declare const MARTIN_PROMPT_NAMES: readonly ["martin_start", "martin_preflight", "martin_triage", "martin_resume", "martin_prove", "martin_release_check", "martin_governed_coding_kickoff", "martin_debug_failed_run", "martin_publish_readiness_review", "martin_triage_run_store", "safe_bug_fix", "write_tests_first", "small_refactor", "security_review", "pr_review", "release_check"];
10
10
  export interface MartinDiscoveryMetadata {
@@ -6,6 +6,7 @@ export const MARTIN_TOOL_NAMES = [
6
6
  "martin_doctor",
7
7
  "martin_plan",
8
8
  "martin_preflight",
9
+ "martin_estimate",
9
10
  "martin_logs",
10
11
  "martin_pause",
11
12
  "martin_cancel",
@@ -26,6 +27,7 @@ export const MARTIN_STARTER_TOOL_NAMES = [
26
27
  "martin_doctor",
27
28
  "martin_plan",
28
29
  "martin_preflight",
30
+ "martin_estimate",
29
31
  "martin_run",
30
32
  "martin_triage_runs",
31
33
  "martin_dossier"
@@ -34,6 +36,7 @@ export const MARTIN_MINIMAL_TOOL_NAMES = [
34
36
  "martin_doctor",
35
37
  "martin_plan",
36
38
  "martin_preflight",
39
+ "martin_estimate",
37
40
  "martin_list_runs",
38
41
  "martin_triage_runs",
39
42
  "martin_dossier"
@@ -42,6 +45,7 @@ export const MARTIN_DIAGNOSTIC_TOOL_NAMES = [
42
45
  "martin_doctor",
43
46
  "martin_plan",
44
47
  "martin_preflight",
48
+ "martin_estimate",
45
49
  "martin_logs",
46
50
  "martin_list_runs",
47
51
  "martin_triage_runs",
@@ -65,6 +69,7 @@ export const MARTIN_PAID_REMOTE_TOOL_NAMES = [
65
69
  "martin_doctor",
66
70
  "martin_plan",
67
71
  "martin_preflight",
72
+ "martin_estimate",
68
73
  "martin_run",
69
74
  "martin_list_runs",
70
75
  "martin_triage_runs",
@@ -87,6 +92,7 @@ export const MARTIN_RESOURCE_URIS = [
87
92
  "martin://repo/risk-map",
88
93
  "martin://verifiers/results",
89
94
  "martin://agent/next-step",
95
+ "martin://agent/governance-status",
90
96
  "martin://guides/mcp-usage",
91
97
  "martin://guides/agent-start",
92
98
  "martin://guides/command-map",
@@ -143,7 +143,7 @@ function collectVerificationSnapshots(loop, ledgerEvents) {
143
143
  }
144
144
  snapshots.sort((left, right) => new Date(left.timestamp).getTime() - new Date(right.timestamp).getTime());
145
145
  if (hasConflictingStatusesForLatestAttempt(snapshots)) {
146
- warnings.push("Verification evidence conflicts for the latest attempt; reporting status as unavailable.");
146
+ warnings.push("Verification evidence conflicts for the latest attempt; marking verification as contradicted.");
147
147
  }
148
148
  return { snapshots, warnings };
149
149
  }
@@ -176,7 +176,7 @@ function verificationSnapshotKey(snapshot) {
176
176
  ].join(":");
177
177
  }
178
178
  function selectLatestVerificationSnapshot(snapshots, warnings) {
179
- if (warnings.includes("Verification evidence conflicts for the latest attempt; reporting status as unavailable.")) {
179
+ if (warnings.includes("Verification evidence conflicts for the latest attempt; marking verification as contradicted.")) {
180
180
  return undefined;
181
181
  }
182
182
  return snapshots.at(-1);
@@ -20,6 +20,7 @@ export declare const MARTIN_STATIC_RESOURCE_URIS: {
20
20
  readonly ideOnboardingGuide: "martin://guides/ide-onboarding";
21
21
  readonly operatingRulesGuide: "martin://guides/operating-rules";
22
22
  readonly publishReadinessGuide: "martin://guides/publish-readiness";
23
+ readonly governanceStatus: "martin://agent/governance-status";
23
24
  };
24
25
  export declare const MARTIN_RESOURCE_TEMPLATES: ResourceTemplate[];
25
26
  export declare const MARTIN_STATIC_RESOURCES: Resource[];