@martinloop/mcp 0.2.0 → 0.2.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 (76) hide show
  1. package/README.md +131 -158
  2. package/dist/discovery-metadata.d.ts +16 -0
  3. package/dist/discovery-metadata.js +62 -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 +445 -74
  10. package/dist/resources.d.ts +27 -5
  11. package/dist/resources.js +557 -71
  12. package/dist/server-validation.d.ts +2 -3
  13. package/dist/server-validation.js +262 -122
  14. package/dist/server.d.ts +76 -7
  15. package/dist/server.js +1126 -400
  16. package/dist/tools/doctor.js +14 -6
  17. package/dist/tools/get-attempt.d.ts +13 -6
  18. package/dist/tools/get-attempt.js +14 -5
  19. package/dist/tools/get-run.d.ts +19 -12
  20. package/dist/tools/get-run.js +20 -11
  21. package/dist/tools/get-status.d.ts +11 -0
  22. package/dist/tools/get-status.js +12 -2
  23. package/dist/tools/get-verification-results.d.ts +10 -7
  24. package/dist/tools/get-verification-results.js +11 -6
  25. package/dist/tools/inspect-loop.d.ts +9 -0
  26. package/dist/tools/inspect-loop.js +11 -2
  27. package/dist/tools/list-runs.d.ts +25 -5
  28. package/dist/tools/list-runs.js +21 -4
  29. package/dist/tools/preflight.js +7 -2
  30. package/dist/tools/run-dossier.d.ts +37 -4
  31. package/dist/tools/run-dossier.js +40 -5
  32. package/dist/tools/run-loop.d.ts +19 -0
  33. package/dist/tools/run-loop.js +41 -3
  34. package/dist/tools/run-store.d.ts +57 -3
  35. package/dist/tools/run-store.js +404 -53
  36. package/dist/tools/tool-errors.d.ts +37 -0
  37. package/dist/tools/tool-errors.js +170 -0
  38. package/dist/tools/tool-response.d.ts +16 -0
  39. package/dist/tools/tool-response.js +34 -0
  40. package/dist/tools/tool-support.d.ts +92 -2
  41. package/dist/tools/tool-support.js +358 -63
  42. package/dist/tools/triage-runs.d.ts +33 -0
  43. package/dist/tools/triage-runs.js +138 -0
  44. package/dist/vendor/adapters/claude-cli.js +0 -1
  45. package/dist/vendor/adapters/cli-bridge.js +0 -1
  46. package/dist/vendor/adapters/direct-provider.js +0 -1
  47. package/dist/vendor/adapters/index.js +0 -1
  48. package/dist/vendor/adapters/runtime-support.js +0 -1
  49. package/dist/vendor/adapters/stub-agent-cli.js +0 -1
  50. package/dist/vendor/adapters/stub-direct-provider.js +0 -1
  51. package/dist/vendor/adapters/verifier-only.js +0 -1
  52. package/dist/vendor/contracts/governance.js +0 -1
  53. package/dist/vendor/contracts/index.d.ts +2 -0
  54. package/dist/vendor/contracts/index.js +1 -1
  55. package/dist/vendor/contracts/operator.d.ts +19 -0
  56. package/dist/vendor/contracts/operator.js +11 -0
  57. package/dist/vendor/core/compiler.js +0 -1
  58. package/dist/vendor/core/context-integrity.js +0 -1
  59. package/dist/vendor/core/grounding.js +0 -1
  60. package/dist/vendor/core/index.js +1 -2
  61. package/dist/vendor/core/leash.js +19 -12
  62. package/dist/vendor/core/persistence/compiler.js +0 -1
  63. package/dist/vendor/core/persistence/index.js +0 -1
  64. package/dist/vendor/core/persistence/ledger.js +0 -1
  65. package/dist/vendor/core/persistence/runs-reader.js +0 -1
  66. package/dist/vendor/core/persistence/store.js +0 -1
  67. package/dist/vendor/core/policy.js +0 -1
  68. package/dist/vendor/core/red-blue/red-phase.d.ts +64 -0
  69. package/dist/vendor/core/red-blue/red-phase.js +135 -0
  70. package/dist/vendor/core/red-blue/risk-tiers.d.ts +22 -0
  71. package/dist/vendor/core/red-blue/risk-tiers.js +32 -0
  72. package/dist/vendor/core/rollback.js +2 -3
  73. package/package.json +10 -5
  74. package/server.json +2 -2
  75. package/dist/tools/cockpit-support.d.ts +0 -69
  76. package/dist/tools/cockpit-support.js +0 -108
package/README.md CHANGED
@@ -1,8 +1,22 @@
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 execution cockpit for AI coding agents over MCP stdio.
4
4
 
5
- `@martinloop/mcp@0.2.0` exposes ten stdio tools plus read-only MCP resources, resource templates, and prompts:
5
+ The standalone `@martinloop/mcp` release train is documented through `0.1.4`, `0.2.0`, and the later `0.2.5` stable cockpit line. It gives hosts one bounded execution entrypoint, rich read-only inspection tools, discoverable resources, run triage, and operator prompts on top of Martin Loop’s persisted run records.
6
+
7
+ This package stays local-first and stdio-first in public packaging today.
8
+
9
+ For host-facing guidance, see [MCP for AI Agents](https://github.com/Keesan12/martin-loop/blob/main/docs/oss/MCP-FOR-AI-AGENTS.md).
10
+
11
+ ## Public Release Train
12
+
13
+ - 0.1.4 operator foundation.
14
+ - 0.2.0 cockpit expansion. 0.2.0 adds resources, resource templates, prompts, and read-only cockpit inspection.
15
+ - 0.2.5 stable cockpit line with local triage and degraded run-store hardening.
16
+
17
+ ## What Ships
18
+
19
+ ### Tools
6
20
 
7
21
  - `martin_doctor`
8
22
  - `martin_preflight`
@@ -10,34 +24,56 @@ Governed MCP server for AI coding agents that need hard spend limits, verifier g
10
24
  - `martin_inspect`
11
25
  - `martin_status`
12
26
  - `martin_list_runs`
27
+ - `martin_triage_runs`
13
28
  - `martin_get_run`
14
29
  - `martin_get_attempt`
15
30
  - `martin_get_verification_results`
16
31
  - `martin_run_dossier`
17
32
 
18
- Recommended flow:
33
+ ### Resources
19
34
 
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`
35
+ - `martin://server/health`
36
+ - `martin://runs/recent`
37
+ - `martin://runs/triage`
38
+ - `martin://runs/latest/summary`
39
+ - `martin://runs/latest/proof-card`
40
+ - `martin://runs/latest/budget-status`
41
+ - `martin://runs/latest/verifier-evidence`
42
+ - `martin://runs/latest/rollback-evidence`
43
+ - `martin://agent/next-step`
44
+ - `martin://guides/mcp-usage`
45
+ - `martin://guides/publish-readiness`
24
46
 
25
- ## What This Server Is For
47
+ ### Resource templates
26
48
 
27
- Use this MCP when a host already knows how to delegate coding work, but you want Martin Loop to bound that work with:
49
+ - `martin://runs/{loopId}`
50
+ - `martin://runs/{loopId}/attempts/{attemptIndex}`
51
+ - `martin://runs/{loopId}/verification`
52
+
53
+ ### Prompts
28
54
 
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
55
+ - `martin_start`
56
+ - `martin_preflight`
57
+ - `martin_triage`
58
+ - `martin_resume`
59
+ - `martin_prove`
60
+ - `martin_release_check`
61
+ - `martin_governed_coding_kickoff`
62
+ - `martin_debug_failed_run`
63
+ - `martin_publish_readiness_review`
64
+ - `martin_triage_run_store`
35
65
 
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.
66
+ ## Recommended Flow
37
67
 
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).
68
+ 1. `martin_doctor`
69
+ 2. `martin_preflight`
70
+ 3. `martin_run`
71
+ 4. `martin_triage_runs`
72
+ 5. `martin://agent/next-step` or `martin://runs/latest/summary`
73
+ 6. `martin_run_dossier` or `martin_get_*` when compact evidence says the full record is needed
74
+ 7. `martin://runs/latest/proof-card` or `martin_prove` for a shareable receipt
39
75
 
40
- ## Quickstart
76
+ ## Install
41
77
 
42
78
  Run the packaged server directly:
43
79
 
@@ -57,174 +93,102 @@ Add it to Claude Code:
57
93
  # macOS/Linux
58
94
  claude mcp add --transport stdio --scope user martin-loop -- npx -y @martinloop/mcp
59
95
 
60
- # Windows PowerShell/cmd
96
+ # Windows PowerShell or cmd.exe
61
97
  claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
62
98
  ```
63
99
 
64
- Generic stdio configuration:
100
+ Generate host config from the CLI when you want minimal, diagnostic, or full-local profiles:
65
101
 
66
- ```json
67
- {
68
- "type": "stdio",
69
- "command": "npx",
70
- "args": ["-y", "@martinloop/mcp"]
71
- }
102
+ ```sh
103
+ martin mcp print-config --host codex --transport stdio --profile minimal
104
+ martin mcp print-config --host claude --transport stdio --profile diagnostic
105
+ martin mcp print-config --host gemini --transport stdio --profile full-local
72
106
  ```
73
107
 
74
- Codex host configuration in `~/.codex/config.toml`:
108
+ `martin mcp install` supports the same host set and only writes when the target file is absent or already contains a Martin Loop block.
109
+
110
+ Codex also supports `~/.codex/config.toml` and project-scoped `.codex/config.toml`:
75
111
 
76
112
  ```toml
77
- [mcp_servers.martin-loop]
113
+ [mcp_servers."martin-loop"]
78
114
  command = "npx"
79
115
  args = ["-y", "@martinloop/mcp"]
116
+ cwd = "C:\\path\\to\\repo"
117
+ startup_timeout_sec = 20
118
+ tool_timeout_sec = 180
119
+ enabled_tools = [
120
+ "martin_doctor",
121
+ "martin_preflight",
122
+ "martin_list_runs",
123
+ "martin_triage_runs",
124
+ "martin_run_dossier",
125
+ ]
126
+ env = { MARTIN_RUNS_DIR = "C:\\path\\to\\runs" }
80
127
  ```
81
128
 
82
- ## Requirements
83
-
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`
87
-
88
- Example stub launch:
89
-
90
- ```sh
91
- MARTIN_LIVE=false npx -y @martinloop/mcp
92
- ```
93
-
94
- ## Tool Contract
129
+ If you use `martin mcp install`, it will only write a starter host config when the target file is absent, or when it detects an existing Martin Loop block and can remain idempotent. Otherwise it refuses to overwrite mixed host config so you can merge safely.
95
130
 
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. |
131
+ When `CODEX_HOME` is set, Codex user-scope installs target `CODEX_HOME\\config.toml` instead of the default user path.
108
132
 
109
- ## Discovery Surface
133
+ Registry/server identifier: `io.github.Keesan12/martin-loop`
110
134
 
111
- `0.2.0` adds read-only cockpit discovery for MCP hosts that support resources and prompts.
135
+ ## Host coverage
112
136
 
113
- Resources:
137
+ - `codex`: local stdio profiles
138
+ - `claude`: local, user, and project scopes
139
+ - `gemini`: local `settings.json` snippets with `includeTools`
140
+ - `generic`: JSON config for MCP-aware wrappers
114
141
 
115
- - `martin://runs/summary`
116
- - `martin://runs/latest`
142
+ Operating-system launcher behavior is explicit:
117
143
 
118
- Resource templates:
144
+ - Windows: `cmd /c npx -y @martinloop/mcp`
145
+ - macOS/Linux: `npx -y @martinloop/mcp`
119
146
 
120
- - `martin://runs/{loopId}`
121
- - `martin://runs/{loopId}/attempts/{attemptIndex}`
122
- - `martin://runs/{loopId}/verification`
147
+ Claude `--scope local` remains CLI-managed. `martin mcp install --host claude --scope local` shells out to Claude Code directly instead of fabricating a repo config file for that scope.
123
148
 
124
- Prompts:
149
+ ## Discovery metadata
125
150
 
126
- - `martin_review_run`
127
- - `martin_triage_failures`
151
+ - JSON resources now carry `metadata.serverVersion` and `metadata.discoveryRevision`.
152
+ - Environment-specific path details stay in `martin://server/health` instead of low-context discovery metadata.
153
+ - Compact resources expose low-token latest-run summaries, proof cards, budget status, verifier evidence, rollback evidence, and a single recommended next step.
154
+ - Prompts stamp the current server version and discovery revision into their descriptions so hosts can confirm which surface they discovered.
155
+ - The server does **not** advertise `listChanged` yet. That is deliberate: the current discovery surface is stable and versioned, but it does not yet emit authoritative change notifications.
128
156
 
129
- ## Safe-Root Path Model
157
+ ## Runtime Model
130
158
 
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.
159
+ - `martin_run` is the only execution entrypoint.
160
+ - All other Martin MCP tools are read-only.
161
+ - Live runs require `claude` or `codex` on `PATH`.
162
+ - Stub or smoke flows use `MARTIN_LIVE=false`.
163
+ - Paths stay bounded to the configured workspace root and runs root.
164
+ - Direct raw-model compatibility is not the target. Martin Loop supports hosts and wrappers that speak MCP; open-source model families such as Gemma or Nemotron should use the `generic` host path through an MCP-capable shell or runtime.
132
165
 
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.
166
+ ## Operator Notes
141
167
 
142
- Absolute paths can work only when they still resolve inside the corresponding safe root. Escapes above the workspace or runs root are rejected.
168
+ - `martin_get_verification_results` only reports persisted verification evidence. If evidence is missing, it returns `unavailable` with warnings.
169
+ - `martin_triage_runs` is the fastest way to decide which persisted run deserves attention first.
170
+ - `martin://agent/next-step`, `martin://runs/latest/summary`, and `martin://runs/latest/proof-card` are the best default follow-ups for context-constrained agents.
171
+ - `martin_run_dossier` is the richest single-run inspection surface and is best when a compact receipt says deeper evidence is needed.
172
+ - Resources and prompts reuse the same run-store selectors as the tools; they are discovery surfaces, not a second data model.
173
+ - The recommended host default is the `minimal` profile: `martin_doctor`, `martin_preflight`, `martin_list_runs`, `martin_triage_runs`, and `martin_run_dossier`. Use `diagnostic` for read-only archaeology and `full-local` only when the host should execute runs.
143
174
 
144
- ## Tool Examples
175
+ ## Debugging
145
176
 
146
- ### `martin_run`
177
+ Use the live handshake inspector before you blame the host:
147
178
 
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
- }
179
+ ```sh
180
+ pnpm --filter @martinloop/mcp inspect:live
202
181
  ```
203
182
 
204
- Status from inline JSON:
183
+ If you want the official MCP Inspector UI, point it at the same stdio launch command:
205
184
 
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
- }
185
+ ```sh
186
+ npx @modelcontextprotocol/inspector --command npx --args "-y,@martinloop/mcp"
210
187
  ```
211
188
 
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:
189
+ The stdio server keeps protocol output on stdout and diagnostic logging on stderr. When a host integration goes sideways, confirm the live discovery surface first, then move on to the host config.
217
190
 
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`:
223
-
224
- ```sh
225
- mcp-publisher login github
226
- mcp-publisher publish
227
- ```
191
+ For WSL or Linux validation, do a native install on that platform before you smoke the package. Reusing Windows-installed `node_modules` across WSL will fail on native dependencies such as `esbuild`, which looks like a transport failure but is really a cross-platform install mismatch.
228
192
 
229
193
  ## Verification
230
194
 
@@ -237,14 +201,23 @@ pnpm --filter @martinloop/mcp build
237
201
  pnpm --filter @martinloop/mcp smoke:pack
238
202
  pnpm --filter @martinloop/mcp smoke:published:pack
239
203
  pnpm --filter @martinloop/mcp verify:release
204
+ pnpm --filter @martin/cli verify:hosts:live
240
205
  pnpm --filter @martinloop/mcp smoke:published
206
+ pnpm --filter @martinloop/mcp inspect:live
241
207
  ```
242
208
 
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
209
+ - `smoke:pack` verifies the packed tarball and stdio launch path.
210
+ - `smoke:published:pack` verifies install-and-run behavior from a freshly packed local tarball through the installed `mcp` bin before npm publish.
211
+ - `verify:release` checks metadata parity, release-note presence, install docs, and discovery-surface claims.
212
+ - `@martin/cli verify:hosts:live` proves the generated host config against the real Codex, Claude, and Gemini CLIs on this machine.
213
+ - `smoke:published` remains a post-publish npm gate.
214
+
215
+ ## Compatibility
216
+
217
+ `0.2.5` is the current integrated governed execution cockpit line:
247
218
 
248
- ## Version Notes
219
+ - `martin_run`, `martin_inspect`, `martin_status`, `martin_doctor`, and `martin_preflight` remain backward-compatible.
220
+ - New read-only surfaces are additive.
221
+ - No new write-capable MCP tools are introduced in `0.2.5`.
249
222
 
250
- The root `CHANGELOG.md` is repo-wide and includes non-MCP changes. For the `@martinloop/mcp` surface, prefer this README and `server.json`.
223
+ See `docs/release/MCP-COMPATIBILITY.md`, `docs/release/MCP-0.2.0-RELEASE-NOTES.md`, and `docs/release/MCP-0.2.5-RELEASE-NOTES.md` for the public release contract and delivery sequence.
@@ -0,0 +1,16 @@
1
+ export declare const MARTIN_TOOL_NAMES: readonly ["martin_run", "martin_inspect", "martin_status", "martin_doctor", "martin_preflight", "martin_list_runs", "martin_triage_runs", "martin_get_run", "martin_get_attempt", "martin_get_verification_results", "martin_run_dossier"];
2
+ export declare const MARTIN_STARTER_TOOL_NAMES: readonly ["martin_doctor", "martin_preflight", "martin_run", "martin_triage_runs", "martin_run_dossier"];
3
+ export declare const MARTIN_RESOURCE_URIS: readonly ["martin://server/health", "martin://runs/recent", "martin://runs/triage", "martin://guides/mcp-usage", "martin://guides/publish-readiness"];
4
+ export declare const MARTIN_RESOURCE_TEMPLATE_URIS: readonly ["martin://runs/{loopId}", "martin://runs/{loopId}/attempts/{attemptIndex}", "martin://runs/{loopId}/verification"];
5
+ export declare const MARTIN_PROMPT_NAMES: readonly ["martin_governed_coding_kickoff", "martin_debug_failed_run", "martin_publish_readiness_review", "martin_triage_run_store"];
6
+ export interface MartinDiscoveryMetadata {
7
+ serverVersion: string;
8
+ discoveryRevision: string;
9
+ generatedAt: string;
10
+ toolCount: number;
11
+ resourceCount: number;
12
+ resourceTemplateCount: number;
13
+ promptCount: number;
14
+ starterTools: string[];
15
+ }
16
+ export declare function buildMartinDiscoveryMetadata(serverVersion: string): MartinDiscoveryMetadata;
@@ -0,0 +1,62 @@
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_preflight",
8
+ "martin_list_runs",
9
+ "martin_triage_runs",
10
+ "martin_get_run",
11
+ "martin_get_attempt",
12
+ "martin_get_verification_results",
13
+ "martin_run_dossier"
14
+ ];
15
+ export const MARTIN_STARTER_TOOL_NAMES = [
16
+ "martin_doctor",
17
+ "martin_preflight",
18
+ "martin_run",
19
+ "martin_triage_runs",
20
+ "martin_run_dossier"
21
+ ];
22
+ export const MARTIN_RESOURCE_URIS = [
23
+ "martin://server/health",
24
+ "martin://runs/recent",
25
+ "martin://runs/triage",
26
+ "martin://guides/mcp-usage",
27
+ "martin://guides/publish-readiness"
28
+ ];
29
+ export const MARTIN_RESOURCE_TEMPLATE_URIS = [
30
+ "martin://runs/{loopId}",
31
+ "martin://runs/{loopId}/attempts/{attemptIndex}",
32
+ "martin://runs/{loopId}/verification"
33
+ ];
34
+ export const MARTIN_PROMPT_NAMES = [
35
+ "martin_governed_coding_kickoff",
36
+ "martin_debug_failed_run",
37
+ "martin_publish_readiness_review",
38
+ "martin_triage_run_store"
39
+ ];
40
+ export function buildMartinDiscoveryMetadata(serverVersion) {
41
+ const surface = {
42
+ tools: [...MARTIN_TOOL_NAMES],
43
+ resources: [...MARTIN_RESOURCE_URIS],
44
+ resourceTemplates: [...MARTIN_RESOURCE_TEMPLATE_URIS],
45
+ prompts: [...MARTIN_PROMPT_NAMES],
46
+ starterTools: [...MARTIN_STARTER_TOOL_NAMES]
47
+ };
48
+ const discoveryRevision = createHash("sha256")
49
+ .update(JSON.stringify({ serverVersion, surface }))
50
+ .digest("hex")
51
+ .slice(0, 12);
52
+ return {
53
+ serverVersion,
54
+ discoveryRevision,
55
+ generatedAt: new Date().toISOString(),
56
+ toolCount: surface.tools.length,
57
+ resourceCount: surface.resources.length,
58
+ resourceTemplateCount: surface.resourceTemplates.length,
59
+ promptCount: surface.prompts.length,
60
+ starterTools: [...surface.starterTools]
61
+ };
62
+ }
@@ -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 {};