@martinloop/mcp 0.2.0 → 0.2.7

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 (96) hide show
  1. package/README.md +118 -182
  2. package/dist/discovery-metadata.d.ts +21 -0
  3. package/dist/discovery-metadata.js +152 -0
  4. package/dist/discovery-support.d.ts +62 -0
  5. package/dist/discovery-support.js +224 -0
  6. package/dist/package-version.d.ts +1 -0
  7. package/dist/package-version.js +3 -0
  8. package/dist/prompts.d.ts +13 -3
  9. package/dist/prompts.js +537 -74
  10. package/dist/resources.d.ts +35 -5
  11. package/dist/resources.js +788 -71
  12. package/dist/server-validation.d.ts +2 -3
  13. package/dist/server-validation.js +375 -119
  14. package/dist/server.d.ts +76 -7
  15. package/dist/server.js +1478 -394
  16. package/dist/tools/doctor.d.ts +2 -0
  17. package/dist/tools/doctor.js +18 -6
  18. package/dist/tools/eval.d.ts +24 -0
  19. package/dist/tools/eval.js +65 -0
  20. package/dist/tools/get-attempt.d.ts +13 -6
  21. package/dist/tools/get-attempt.js +14 -5
  22. package/dist/tools/get-run.d.ts +19 -12
  23. package/dist/tools/get-run.js +20 -11
  24. package/dist/tools/get-status.d.ts +19 -0
  25. package/dist/tools/get-status.js +30 -2
  26. package/dist/tools/get-verification-results.d.ts +10 -7
  27. package/dist/tools/get-verification-results.js +11 -6
  28. package/dist/tools/inspect-loop.d.ts +9 -0
  29. package/dist/tools/inspect-loop.js +11 -2
  30. package/dist/tools/list-runs.d.ts +25 -5
  31. package/dist/tools/list-runs.js +21 -4
  32. package/dist/tools/logs.d.ts +25 -0
  33. package/dist/tools/logs.js +49 -0
  34. package/dist/tools/plan.d.ts +20 -0
  35. package/dist/tools/plan.js +10 -0
  36. package/dist/tools/pr-tools.d.ts +31 -0
  37. package/dist/tools/pr-tools.js +111 -0
  38. package/dist/tools/preflight.d.ts +10 -0
  39. package/dist/tools/preflight.js +18 -4
  40. package/dist/tools/run-controls.d.ts +36 -0
  41. package/dist/tools/run-controls.js +88 -0
  42. package/dist/tools/run-dossier.d.ts +51 -4
  43. package/dist/tools/run-dossier.js +100 -5
  44. package/dist/tools/run-loop.d.ts +19 -0
  45. package/dist/tools/run-loop.js +61 -4
  46. package/dist/tools/run-store.d.ts +57 -3
  47. package/dist/tools/run-store.js +404 -53
  48. package/dist/tools/tool-errors.d.ts +37 -0
  49. package/dist/tools/tool-errors.js +170 -0
  50. package/dist/tools/tool-response.d.ts +16 -0
  51. package/dist/tools/tool-response.js +34 -0
  52. package/dist/tools/tool-support.d.ts +92 -2
  53. package/dist/tools/tool-support.js +385 -63
  54. package/dist/tools/triage-runs.d.ts +33 -0
  55. package/dist/tools/triage-runs.js +138 -0
  56. package/dist/tools/workflow-governance.d.ts +133 -0
  57. package/dist/tools/workflow-governance.js +581 -0
  58. package/dist/vendor/adapters/claude-cli.js +0 -1
  59. package/dist/vendor/adapters/cli-bridge.d.ts +5 -0
  60. package/dist/vendor/adapters/cli-bridge.js +16 -9
  61. package/dist/vendor/adapters/direct-provider.js +0 -1
  62. package/dist/vendor/adapters/index.d.ts +2 -1
  63. package/dist/vendor/adapters/index.js +2 -1
  64. package/dist/vendor/adapters/openai-compatible.d.ts +47 -0
  65. package/dist/vendor/adapters/openai-compatible.js +242 -0
  66. package/dist/vendor/adapters/runtime-support.js +0 -1
  67. package/dist/vendor/adapters/stub-agent-cli.js +0 -1
  68. package/dist/vendor/adapters/stub-direct-provider.js +0 -1
  69. package/dist/vendor/adapters/verifier-only.js +0 -1
  70. package/dist/vendor/contracts/governance.js +0 -1
  71. package/dist/vendor/contracts/index.d.ts +2 -0
  72. package/dist/vendor/contracts/index.js +1 -1
  73. package/dist/vendor/contracts/operator.d.ts +19 -0
  74. package/dist/vendor/contracts/operator.js +11 -0
  75. package/dist/vendor/core/compiler.js +0 -1
  76. package/dist/vendor/core/context-integrity.js +0 -1
  77. package/dist/vendor/core/grounding.js +0 -1
  78. package/dist/vendor/core/index.js +1 -2
  79. package/dist/vendor/core/leash.js +19 -12
  80. package/dist/vendor/core/persistence/compiler.js +0 -1
  81. package/dist/vendor/core/persistence/index.js +0 -1
  82. package/dist/vendor/core/persistence/ledger.js +0 -1
  83. package/dist/vendor/core/persistence/runs-reader.js +0 -1
  84. package/dist/vendor/core/persistence/store.js +0 -1
  85. package/dist/vendor/core/policy.js +0 -1
  86. package/dist/vendor/core/red-blue/red-phase.d.ts +64 -0
  87. package/dist/vendor/core/red-blue/red-phase.js +135 -0
  88. package/dist/vendor/core/red-blue/risk-tiers.d.ts +22 -0
  89. package/dist/vendor/core/red-blue/risk-tiers.js +32 -0
  90. package/dist/vendor/core/rollback.js +2 -3
  91. package/dist/workflow-state.d.ts +25 -0
  92. package/dist/workflow-state.js +102 -0
  93. package/package.json +12 -7
  94. package/server.json +2 -2
  95. package/dist/tools/cockpit-support.d.ts +0 -69
  96. package/dist/tools/cockpit-support.js +0 -108
package/README.md CHANGED
@@ -1,43 +1,26 @@
1
1
  # @martinloop/mcp
2
2
 
3
- Governed MCP server for AI coding agents that need hard spend limits, verifier gates, scoped file edits, and inspectable run records.
3
+ Governed MCP server for AI coding agents with budgets, receipts, and review-ready evidence.
4
4
 
5
- `@martinloop/mcp@0.2.0` exposes ten stdio tools plus read-only MCP resources, resource templates, and prompts:
5
+ `@martinloop/mcp` is the standalone MartinLoop server for MCP hosts. It stays local-first and stdio-first, and it gives hosts one clear execution path: check readiness, plan the work, preflight the contract, run it, and inspect the result with enough evidence to decide what happens next.
6
6
 
7
- - `martin_doctor`
8
- - `martin_preflight`
9
- - `martin_run`
10
- - `martin_inspect`
11
- - `martin_status`
12
- - `martin_list_runs`
13
- - `martin_get_run`
14
- - `martin_get_attempt`
15
- - `martin_get_verification_results`
16
- - `martin_run_dossier`
17
-
18
- Recommended flow:
19
-
20
- 1. `martin_doctor`
21
- 2. `martin_preflight`
22
- 3. `martin_run`
23
- 4. `martin_list_runs`, `martin_run_dossier`, `martin_inspect`, or `martin_status`
24
-
25
- ## What This Server Is For
7
+ The root `martin-loop` package and the standalone `@martinloop/mcp` package move on separate version lines. For the current root release, see [MartinLoop 0.2.8 release notes](../../docs/release/OSS-0.2.8-RELEASE-NOTES.md).
26
8
 
27
- Use this MCP when a host already knows how to delegate coding work, but you want Martin Loop to bound that work with:
9
+ ## What is new in 0.2.7
28
10
 
29
- - a hard budget ceiling (`maxUsd`)
30
- - an attempt ceiling (`maxIterations`)
31
- - a total token ceiling (`maxTokens`)
32
- - verifier commands (`verificationPlan`)
33
- - allowed and denied file globs
34
- - persisted run records you can inspect afterward
11
+ - better onboarding inside MCP, including guide resources for command mapping, IDE setup, and operating rules
12
+ - a stricter governed run sequence, so `martin_run` refuses to start until matching `martin_doctor`, `martin_plan`, and `martin_preflight` receipts exist for the same task
13
+ - cleaner review and handoff surfaces, especially around dossier, eval, and publish-readiness guidance
35
14
 
36
- It is a good fit for Claude Code, Codex-oriented hosts, and other MCP clients that want governed code-change execution instead of open-ended retry behavior.
15
+ If you are installing MartinLoop for the first time, start with the root CLI first:
37
16
 
38
- For host-facing integration guidance, see [MCP for AI Agents](https://github.com/Keesan12/martin-loop/blob/main/docs/oss/MCP-FOR-AI-AGENTS.md).
17
+ ```sh
18
+ npx martin-loop start
19
+ npx martin-loop tour
20
+ npx martin-loop doctor
21
+ ```
39
22
 
40
- ## Quickstart
23
+ ## Install
41
24
 
42
25
  Run the packaged server directly:
43
26
 
@@ -54,176 +37,136 @@ codex mcp add martin-loop -- npx -y @martinloop/mcp
54
37
  Add it to Claude Code:
55
38
 
56
39
  ```sh
57
- # macOS/Linux
58
40
  claude mcp add --transport stdio --scope user martin-loop -- npx -y @martinloop/mcp
59
-
60
- # Windows PowerShell/cmd
61
41
  claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
62
42
  ```
63
43
 
64
- Generic stdio configuration:
44
+ Generate host config from the root CLI:
65
45
 
66
- ```json
67
- {
68
- "type": "stdio",
69
- "command": "npx",
70
- "args": ["-y", "@martinloop/mcp"]
71
- }
72
- ```
73
-
74
- Codex host configuration in `~/.codex/config.toml`:
75
-
76
- ```toml
77
- [mcp_servers.martin-loop]
78
- command = "npx"
79
- args = ["-y", "@martinloop/mcp"]
46
+ ```sh
47
+ npx martin-loop mcp print-config --host codex --transport stdio --profile minimal
48
+ npx martin-loop mcp print-config --host claude --transport stdio --profile diagnostic
49
+ npx martin-loop mcp print-config --host gemini --transport stdio --profile full-local
50
+ npx martin-loop mcp print-config --host generic --transport stdio --profile github-review
80
51
  ```
81
52
 
82
- ## Requirements
53
+ Registry/server identifier: `io.github.Keesan12/martin-loop`
83
54
 
84
- - Node 20+
85
- - For live `martin_run` usage, either the `claude` CLI or the `codex` CLI must be available on `PATH`
86
- - For stub or smoke flows, set `MARTIN_LIVE=false`
55
+ ## Recommended Flow
87
56
 
88
- Example stub launch:
57
+ 1. `martin_doctor`
58
+ 2. `martin_plan`
59
+ 3. `martin_preflight`
60
+ 4. `martin_run`
61
+ 5. `martin_status` or `martin_logs`
62
+ 6. `martin_dossier` or the `martin_get_*` tools
63
+ 7. `martin_eval`
64
+ 8. `martin_pr_summary` or `martin_review_pr` when a host is preparing GitHub review output
89
65
 
90
- ```sh
91
- MARTIN_LIVE=false npx -y @martinloop/mcp
92
- ```
66
+ `martin_run` is the primary coding execution entrypoint. In `0.2.7`, it hard-blocks until the matching readiness, planning, and preflight receipts exist for the same task. That keeps the default flow honest for both humans and agents.
93
67
 
94
- ## Tool Contract
68
+ ## Profiles
95
69
 
96
- | Tool | Purpose | Required input | Important optional input | Notes |
97
- | --- | --- | --- | --- | --- |
98
- | `martin_doctor` | Inspect local readiness and run-store health | none | `workingDirectory`, `runsDir`, `engine` | Read-only setup lane before execution. |
99
- | `martin_preflight` | Normalize and validate a proposed run contract | `objective` | `workingDirectory`, `engine`, `model`, `maxUsd`, `maxIterations`, `maxTokens`, `verificationPlan`, `allowedPaths`, `deniedPaths`, `workspaceId`, `projectId` | Read-only contract check; does not execute work. |
100
- | `martin_run` | Run a governed coding loop | `objective` | `workingDirectory`, `engine`, `model`, `maxUsd`, `maxIterations`, `maxTokens`, `verificationPlan`, `allowedPaths`, `deniedPaths`, `workspaceId`, `projectId` | Unknown arguments are rejected. |
101
- | `martin_inspect` | Read a saved run record or run folder | none | `file`, `runsDir` | `file` may point to a `loop-record.json`, legacy `.jsonl`, or a run directory under the runs root. |
102
- | `martin_status` | Report budget pressure and stop conditions | exactly one of `loopJson`, `file`, `loopId`, or `latest` | `runsDir` | `latest` must be `true` when used. |
103
- | `martin_list_runs` | List recent run summaries | none | `runsDir`, `limit` | Read-only cockpit view over local run records. |
104
- | `martin_get_run` | Load a run dossier | exactly one of `loopId` or `latest` | `runsDir` | Read-only task, budget, cost, and attempt details. |
105
- | `martin_get_attempt` | Load one attempt | `loopId`, `attemptIndex` | `runsDir` | Read-only attempt evidence. |
106
- | `martin_get_verification_results` | Extract verifier events | exactly one of `loopId` or `latest` | `runsDir` | Read-only verifier completion summaries. |
107
- | `martin_run_dossier` | Build a compact review dossier | exactly one of `loopId` or `latest` | `runsDir` | Summary, budget, attempts, and verification evidence. |
70
+ - `minimal`: read-heavy default for safe host setup
71
+ - `diagnostic`: deeper inspection and evaluator support
72
+ - `full-local`: includes execution and run-control helpers for local workflows
73
+ - `github-review`: adds PR review helpers for GitHub-oriented hosts
74
+ - `starter` and `full`: compatibility aliases that map onto the same discovery surface
108
75
 
109
- ## Discovery Surface
76
+ ## Tools
110
77
 
111
- `0.2.0` adds read-only cockpit discovery for MCP hosts that support resources and prompts.
78
+ - `martin_doctor`
79
+ - `martin_plan`
80
+ - `martin_preflight`
81
+ - `martin_run`
82
+ - `martin_inspect`
83
+ - `martin_status`
84
+ - `martin_logs`
85
+ - `martin_pause`
86
+ - `martin_cancel`
87
+ - `martin_continue`
88
+ - `martin_list_runs`
89
+ - `martin_triage_runs`
90
+ - `martin_get_run`
91
+ - `martin_get_attempt`
92
+ - `martin_get_verification_results`
93
+ - `martin_run_dossier`
94
+ - `martin_dossier`
95
+ - `martin_eval`
96
+ - `martin_pr_summary`
97
+ - `martin_create_pr`
98
+ - `martin_review_pr`
112
99
 
113
- Resources:
100
+ ## Resources
114
101
 
115
- - `martin://runs/summary`
102
+ - `martin://server/health`
103
+ - `martin://runs/recent`
104
+ - `martin://runs/triage`
116
105
  - `martin://runs/latest`
117
-
118
- Resource templates:
106
+ - `martin://runs/latest/summary`
107
+ - `martin://runs/latest/proof-card`
108
+ - `martin://runs/latest/budget-status`
109
+ - `martin://runs/latest/verifier-evidence`
110
+ - `martin://runs/latest/rollback-evidence`
111
+ - `martin://policies/current`
112
+ - `martin://repo/risk-map`
113
+ - `martin://verifiers/results`
114
+ - `martin://agent/next-step`
115
+ - `martin://guides/mcp-usage`
116
+ - `martin://guides/agent-start`
117
+ - `martin://guides/command-map`
118
+ - `martin://guides/ide-onboarding`
119
+ - `martin://guides/operating-rules`
120
+ - `martin://guides/publish-readiness`
121
+
122
+ ## Resource Templates
119
123
 
120
124
  - `martin://runs/{loopId}`
125
+ - `martin://runs/{loopId}/dossier`
121
126
  - `martin://runs/{loopId}/attempts/{attemptIndex}`
122
127
  - `martin://runs/{loopId}/verification`
123
128
 
124
- Prompts:
129
+ ## Prompts
125
130
 
126
- - `martin_review_run`
127
- - `martin_triage_failures`
128
-
129
- ## Safe-Root Path Model
130
-
131
- This MCP does not let tool callers point at arbitrary filesystem locations. The server resolves tool paths against safe roots chosen when the server starts.
132
-
133
- - `workingDirectory`
134
- Defaults to `MARTIN_MCP_WORKSPACE_ROOT` or the server process current directory. If you pass a value, it must still resolve inside that workspace root. `.` and repo-relative subpaths are the safest choices.
135
- - `file`
136
- For `martin_inspect` and `martin_status`, `file` resolves under the runs root, not the whole machine. Direct file targets must end in `.json` or `.jsonl`; run directories are also accepted where the tool supports them.
137
- - `runsDir`
138
- Defaults to `MARTIN_RUNS_DIR` or `~/.martin/runs`. Passing `runsDir` only re-states or narrows that safe runs root; it does not grant access outside it.
139
- - `allowedPaths` and `deniedPaths`
140
- These are relative glob patterns only. Absolute paths, drive-qualified paths, and patterns containing `..` are rejected.
141
-
142
- Absolute paths can work only when they still resolve inside the corresponding safe root. Escapes above the workspace or runs root are rejected.
143
-
144
- ## Tool Examples
145
-
146
- ### `martin_run`
147
-
148
- ```json
149
- {
150
- "objective": "Fix the auth regression and prove it with tests",
151
- "engine": "codex",
152
- "maxUsd": 3,
153
- "maxIterations": 3,
154
- "maxTokens": 20000,
155
- "verificationPlan": ["pnpm test --filter auth"],
156
- "workingDirectory": ".",
157
- "allowedPaths": ["src/**", "tests/**"],
158
- "deniedPaths": [".env*", "secrets/**"]
159
- }
160
- ```
161
-
162
- ### `martin_inspect`
163
-
164
- Inspect the default runs root:
165
-
166
- ```json
167
- {}
168
- ```
169
-
170
- Inspect a specific saved loop record under the runs root:
171
-
172
- ```json
173
- {
174
- "file": "loop-123/loop-record.json"
175
- }
176
- ```
177
-
178
- Inspect a subdirectory under the configured runs root:
179
-
180
- ```json
181
- {
182
- "runsDir": "team-a"
183
- }
184
- ```
185
-
186
- ### `martin_status`
187
-
188
- Status for the latest saved run:
189
-
190
- ```json
191
- {
192
- "latest": true
193
- }
194
- ```
195
-
196
- Status for a specific persisted loop:
197
-
198
- ```json
199
- {
200
- "loopId": "loop-123"
201
- }
202
- ```
203
-
204
- Status from inline JSON:
131
+ - `martin_start`
132
+ - `martin_preflight`
133
+ - `martin_triage`
134
+ - `martin_resume`
135
+ - `martin_prove`
136
+ - `martin_release_check`
137
+ - `martin_governed_coding_kickoff`
138
+ - `martin_debug_failed_run`
139
+ - `martin_publish_readiness_review`
140
+ - `martin_triage_run_store`
141
+ - `safe_bug_fix`
142
+ - `write_tests_first`
143
+ - `small_refactor`
144
+ - `security_review`
145
+ - `pr_review`
146
+ - `release_check`
147
+
148
+ ## Runtime Model
149
+
150
+ - `martin_run` is the primary coding execution entrypoint.
151
+ - `martin_run` now blocks until the same task has matching `martin_doctor`, `martin_plan`, and `martin_preflight` receipts.
152
+ - `martin_plan`, `martin_doctor`, `martin_preflight`, `martin_status`, `martin_logs`, `martin_dossier`, `martin_eval`, and the `martin_get_*` family are planning or inspection surfaces.
153
+ - `martin_pause`, `martin_cancel`, `martin_continue`, and `martin_create_pr` are explicit follow-on control helpers and stay out of the default `minimal` profile.
154
+ - Live runs require `claude` or `codex` on `PATH`.
155
+ - Stub or smoke flows use `MARTIN_LIVE=false`.
156
+ - Paths stay bounded to the configured workspace root and runs root.
157
+
158
+ ## Debugging
159
+
160
+ Use the live handshake inspector before you blame a host config:
205
161
 
206
- ```json
207
- {
208
- "loopJson": "{\"loopId\":\"loop-123\",\"status\":\"completed\",\"lifecycleState\":\"completed\",\"attempts\":[],\"budget\":{\"maxUsd\":5,\"softLimitUsd\":3,\"maxIterations\":2,\"maxTokens\":1000},\"cost\":{\"actualUsd\":1.25,\"avoidedUsd\":0,\"tokensIn\":20,\"tokensOut\":10}}"
209
- }
162
+ ```sh
163
+ pnpm --filter @martinloop/mcp inspect:live
210
164
  ```
211
165
 
212
- ## Registry Metadata
213
-
214
- The registry manifest artifact for this package is `server.json`. In this repository, that manifest is authored at `packages/mcp/server.json`.
215
-
216
- Current metadata:
217
-
218
- - npm package: `@martinloop/mcp`
219
- - registry server name: `io.github.Keesan12/martin-loop`
220
- - manifest artifact name: `server.json`
221
-
222
- Official MCP Registry publication is separate from npm publication. After publishing the package to npm, run the publisher from `packages/mcp`:
166
+ If you want the official MCP Inspector UI, point it at the same stdio launch command:
223
167
 
224
168
  ```sh
225
- mcp-publisher login github
226
- mcp-publisher publish
169
+ npx @modelcontextprotocol/inspector --command npx --args "-y,@martinloop/mcp"
227
170
  ```
228
171
 
229
172
  ## Verification
@@ -237,14 +180,7 @@ pnpm --filter @martinloop/mcp build
237
180
  pnpm --filter @martinloop/mcp smoke:pack
238
181
  pnpm --filter @martinloop/mcp smoke:published:pack
239
182
  pnpm --filter @martinloop/mcp verify:release
240
- pnpm --filter @martinloop/mcp smoke:published
183
+ pnpm --filter @martin/cli verify:hosts:live
241
184
  ```
242
185
 
243
- - `smoke:pack` verifies the packed tarball shape and a stdio MCP launch
244
- - `smoke:published:pack` verifies install-and-run behavior from a freshly packed local tarball before npm publish
245
- - `verify:release` checks metadata parity, release-note presence, and public MCP doc accuracy for the current package version
246
- - `smoke:published` verifies the npm-installed artifact through `npm install` plus live MCP tool calls
247
-
248
- ## Version Notes
249
-
250
- The root `CHANGELOG.md` is repo-wide and includes non-MCP changes. For the `@martinloop/mcp` surface, prefer this README and `server.json`.
186
+ See [MCP setup](../../docs/getting-started/mcp.md), [MCP tool reference](../../docs/reference/mcp-tools.md), and [MCP compatibility](../../docs/reference/mcp-compatibility.md).
@@ -0,0 +1,21 @@
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"];
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"];
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
+ 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
+ export interface MartinDiscoveryMetadata {
11
+ serverVersion: string;
12
+ discoveryRevision: string;
13
+ generatedAt: string;
14
+ toolCount: number;
15
+ resourceCount: number;
16
+ resourceTemplateCount: number;
17
+ promptCount: number;
18
+ starterTools: string[];
19
+ profiles: Record<string, string[]>;
20
+ }
21
+ export declare function buildMartinDiscoveryMetadata(serverVersion: string): MartinDiscoveryMetadata;
@@ -0,0 +1,152 @@
1
+ import { createHash } from "node:crypto";
2
+ export const MARTIN_TOOL_NAMES = [
3
+ "martin_run",
4
+ "martin_inspect",
5
+ "martin_status",
6
+ "martin_doctor",
7
+ "martin_plan",
8
+ "martin_preflight",
9
+ "martin_logs",
10
+ "martin_pause",
11
+ "martin_cancel",
12
+ "martin_continue",
13
+ "martin_list_runs",
14
+ "martin_triage_runs",
15
+ "martin_get_run",
16
+ "martin_get_attempt",
17
+ "martin_get_verification_results",
18
+ "martin_run_dossier",
19
+ "martin_dossier",
20
+ "martin_eval",
21
+ "martin_pr_summary",
22
+ "martin_create_pr",
23
+ "martin_review_pr"
24
+ ];
25
+ export const MARTIN_STARTER_TOOL_NAMES = [
26
+ "martin_doctor",
27
+ "martin_plan",
28
+ "martin_preflight",
29
+ "martin_run",
30
+ "martin_triage_runs",
31
+ "martin_dossier"
32
+ ];
33
+ export const MARTIN_MINIMAL_TOOL_NAMES = [
34
+ "martin_doctor",
35
+ "martin_plan",
36
+ "martin_preflight",
37
+ "martin_list_runs",
38
+ "martin_triage_runs",
39
+ "martin_dossier"
40
+ ];
41
+ export const MARTIN_DIAGNOSTIC_TOOL_NAMES = [
42
+ "martin_doctor",
43
+ "martin_plan",
44
+ "martin_preflight",
45
+ "martin_logs",
46
+ "martin_list_runs",
47
+ "martin_triage_runs",
48
+ "martin_get_run",
49
+ "martin_get_attempt",
50
+ "martin_get_verification_results",
51
+ "martin_dossier",
52
+ "martin_eval"
53
+ ];
54
+ export const MARTIN_GITHUB_REVIEW_TOOL_NAMES = [
55
+ "martin_doctor",
56
+ "martin_plan",
57
+ "martin_preflight",
58
+ "martin_dossier",
59
+ "martin_eval",
60
+ "martin_pr_summary",
61
+ "martin_create_pr",
62
+ "martin_review_pr"
63
+ ];
64
+ export const MARTIN_PAID_REMOTE_TOOL_NAMES = [
65
+ "martin_doctor",
66
+ "martin_plan",
67
+ "martin_preflight",
68
+ "martin_run",
69
+ "martin_list_runs",
70
+ "martin_triage_runs",
71
+ "martin_get_run",
72
+ "martin_get_verification_results",
73
+ "martin_dossier",
74
+ "martin_eval"
75
+ ];
76
+ export const MARTIN_RESOURCE_URIS = [
77
+ "martin://server/health",
78
+ "martin://runs/recent",
79
+ "martin://runs/triage",
80
+ "martin://runs/latest",
81
+ "martin://runs/latest/summary",
82
+ "martin://runs/latest/proof-card",
83
+ "martin://runs/latest/budget-status",
84
+ "martin://runs/latest/verifier-evidence",
85
+ "martin://runs/latest/rollback-evidence",
86
+ "martin://policies/current",
87
+ "martin://repo/risk-map",
88
+ "martin://verifiers/results",
89
+ "martin://agent/next-step",
90
+ "martin://guides/mcp-usage",
91
+ "martin://guides/agent-start",
92
+ "martin://guides/command-map",
93
+ "martin://guides/ide-onboarding",
94
+ "martin://guides/operating-rules",
95
+ "martin://guides/publish-readiness"
96
+ ];
97
+ export const MARTIN_RESOURCE_TEMPLATE_URIS = [
98
+ "martin://runs/{loopId}",
99
+ "martin://runs/{loopId}/dossier",
100
+ "martin://runs/{loopId}/attempts/{attemptIndex}",
101
+ "martin://runs/{loopId}/verification"
102
+ ];
103
+ export const MARTIN_PROMPT_NAMES = [
104
+ "martin_start",
105
+ "martin_preflight",
106
+ "martin_triage",
107
+ "martin_resume",
108
+ "martin_prove",
109
+ "martin_release_check",
110
+ "martin_governed_coding_kickoff",
111
+ "martin_debug_failed_run",
112
+ "martin_publish_readiness_review",
113
+ "martin_triage_run_store",
114
+ "safe_bug_fix",
115
+ "write_tests_first",
116
+ "small_refactor",
117
+ "security_review",
118
+ "pr_review",
119
+ "release_check"
120
+ ];
121
+ export function buildMartinDiscoveryMetadata(serverVersion) {
122
+ const surface = {
123
+ tools: [...MARTIN_TOOL_NAMES],
124
+ resources: [...MARTIN_RESOURCE_URIS],
125
+ resourceTemplates: [...MARTIN_RESOURCE_TEMPLATE_URIS],
126
+ prompts: [...MARTIN_PROMPT_NAMES],
127
+ starterTools: [...MARTIN_STARTER_TOOL_NAMES],
128
+ profiles: {
129
+ minimal: [...MARTIN_MINIMAL_TOOL_NAMES],
130
+ diagnostic: [...MARTIN_DIAGNOSTIC_TOOL_NAMES],
131
+ "github-review": [...MARTIN_GITHUB_REVIEW_TOOL_NAMES],
132
+ "full-local": [...MARTIN_TOOL_NAMES],
133
+ starter: [...MARTIN_STARTER_TOOL_NAMES],
134
+ full: [...MARTIN_TOOL_NAMES]
135
+ }
136
+ };
137
+ const discoveryRevision = createHash("sha256")
138
+ .update(JSON.stringify({ serverVersion, surface }))
139
+ .digest("hex")
140
+ .slice(0, 12);
141
+ return {
142
+ serverVersion,
143
+ discoveryRevision,
144
+ generatedAt: new Date().toISOString(),
145
+ toolCount: surface.tools.length,
146
+ resourceCount: surface.resources.length,
147
+ resourceTemplateCount: surface.resourceTemplates.length,
148
+ promptCount: surface.prompts.length,
149
+ starterTools: [...surface.starterTools],
150
+ profiles: surface.profiles
151
+ };
152
+ }
@@ -0,0 +1,62 @@
1
+ import { type LedgerEvent, type LoopAttemptRecord, type LoopRunRecord } from "./vendor/core/index.js";
2
+ import type { LoopArtifact, LoopAttempt, LoopEvent, LoopTask } from "./vendor/contracts/index.js";
3
+ import { type LoopPreview, type MartinEngine } from "./tools/tool-support.js";
4
+ type PersistedLoopTask = LoopRunRecord["task"] & Partial<Pick<LoopTask, "verificationPlan" | "verificationStack" | "repoRoot" | "allowedPaths" | "deniedPaths" | "acceptanceCriteria" | "mutationMode" | "executionProfile" | "allowedNetworkDomains" | "approvalPolicy">>;
5
+ export type PersistedLoopAttemptRecord = LoopAttemptRecord & Partial<Pick<LoopAttempt, "attemptId" | "summary">>;
6
+ export interface PersistedLoopRecord extends LoopRunRecord {
7
+ workspaceId?: string;
8
+ projectId?: string;
9
+ teamId?: string;
10
+ task: PersistedLoopTask;
11
+ attempts: PersistedLoopAttemptRecord[];
12
+ artifacts?: LoopArtifact[];
13
+ events?: LoopEvent[];
14
+ metadata?: Record<string, string>;
15
+ }
16
+ export interface MartinDiscoveryContext {
17
+ runsRoot: string;
18
+ workingDirectory: string;
19
+ engine?: MartinEngine;
20
+ }
21
+ export interface MartinVerificationSnapshot {
22
+ attemptId?: string;
23
+ attemptIndex?: number;
24
+ timestamp: string;
25
+ lifecycleState: string;
26
+ passed?: boolean;
27
+ summary?: string;
28
+ }
29
+ export interface MartinAttemptSnapshot {
30
+ loopId: string;
31
+ attemptIndex: number;
32
+ loop: LoopPreview;
33
+ attempt: PersistedLoopAttemptRecord;
34
+ verification?: MartinVerificationSnapshot;
35
+ warnings: string[];
36
+ }
37
+ export interface MartinVerificationHistorySnapshot {
38
+ loopId: string;
39
+ loop: LoopPreview;
40
+ verificationCount: number;
41
+ latestVerification?: MartinVerificationSnapshot;
42
+ verificationHistory: MartinVerificationSnapshot[];
43
+ warnings: string[];
44
+ }
45
+ export declare function resolveMartinDiscoveryContext(input?: {
46
+ runsDir?: string;
47
+ workingDirectory?: string;
48
+ engine?: MartinEngine;
49
+ }): MartinDiscoveryContext;
50
+ export declare function loadPersistedLoopRecord(input: {
51
+ loopId: string;
52
+ runsDir?: string;
53
+ }): Promise<{
54
+ source: string;
55
+ loop: PersistedLoopRecord;
56
+ }>;
57
+ export declare function buildAttemptSnapshot(loop: PersistedLoopRecord, requestedAttemptIndex?: number, ledgerEvents?: LedgerEvent[]): MartinAttemptSnapshot;
58
+ export declare function buildVerificationHistorySnapshot(loop: PersistedLoopRecord, ledgerEvents?: LedgerEvent[]): MartinVerificationHistorySnapshot;
59
+ export declare function buildPersistedLoopPreview(loop: PersistedLoopRecord): LoopPreview;
60
+ export declare function parseAttemptIndex(value: string): number;
61
+ export declare function toPrettyJson(value: unknown): string;
62
+ export {};