@martinloop/mcp 0.3.8 → 0.5.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 (161) hide show
  1. package/README.md +90 -106
  2. package/dist/discovery-metadata.d.ts +1 -1
  3. package/dist/discovery-metadata.js +1 -1
  4. package/dist/resources.d.ts +1 -2
  5. package/dist/resources.js +190 -238
  6. package/dist/server-validation.d.ts +1 -1
  7. package/dist/server-validation.js +16 -11
  8. package/dist/server.d.ts +23 -0
  9. package/dist/server.js +152 -7
  10. package/dist/tools/run-dossier.d.ts +3 -1
  11. package/dist/tools/run-dossier.js +40 -2
  12. package/dist/tools/run-loop.d.ts +1 -4
  13. package/dist/tools/run-loop.js +6 -15
  14. package/dist/tools/tool-support.d.ts +2 -1
  15. package/dist/tools/tool-support.js +1 -12
  16. package/dist/vendor/adapters/claude-cli.js +38 -35
  17. package/dist/vendor/adapters/cli-bridge.d.ts +9 -1
  18. package/dist/vendor/adapters/cli-bridge.js +54 -13
  19. package/dist/vendor/adapters/codex-launcher.d.ts +61 -1
  20. package/dist/vendor/adapters/codex-launcher.js +118 -19
  21. package/dist/vendor/adapters/index.d.ts +1 -3
  22. package/dist/vendor/adapters/index.js +1 -3
  23. package/dist/vendor/adapters/openai-compatible.js +57 -18
  24. package/dist/vendor/contracts/adapter-capabilities.d.ts +1 -1
  25. package/dist/vendor/contracts/context-handoff.d.ts +100 -0
  26. package/dist/vendor/contracts/context-handoff.js +11 -0
  27. package/dist/vendor/contracts/context-manifest.d.ts +195 -0
  28. package/dist/vendor/contracts/context-manifest.js +17 -0
  29. package/dist/vendor/contracts/context-shadow.d.ts +75 -0
  30. package/dist/vendor/contracts/context-shadow.js +8 -0
  31. package/dist/vendor/contracts/exits.d.ts +126 -0
  32. package/dist/vendor/contracts/exits.js +32 -0
  33. package/dist/vendor/contracts/index.d.ts +39 -2
  34. package/dist/vendor/contracts/index.js +22 -0
  35. package/dist/vendor/contracts/mission.d.ts +102 -0
  36. package/dist/vendor/contracts/mission.js +64 -0
  37. package/dist/vendor/contracts/operator.d.ts +3 -1
  38. package/dist/vendor/contracts/operator.js +2 -1
  39. package/dist/vendor/contracts/verified-handoff.d.ts +100 -0
  40. package/dist/vendor/contracts/verified-handoff.js +35 -0
  41. package/dist/vendor/core/context-chain-gate.d.ts +89 -0
  42. package/dist/vendor/core/context-chain-gate.js +173 -0
  43. package/dist/vendor/core/context-compiler.d.ts +53 -0
  44. package/dist/vendor/core/context-compiler.js +261 -0
  45. package/dist/vendor/core/context-handoff.d.ts +42 -0
  46. package/dist/vendor/core/context-handoff.js +167 -0
  47. package/dist/vendor/core/context-shadow.d.ts +39 -0
  48. package/dist/vendor/core/context-shadow.js +200 -0
  49. package/dist/vendor/core/exit-signal.d.ts +88 -0
  50. package/dist/vendor/core/exit-signal.js +339 -0
  51. package/dist/vendor/core/exits.d.ts +41 -0
  52. package/dist/vendor/core/exits.js +258 -0
  53. package/dist/vendor/core/index.d.ts +42 -1
  54. package/dist/vendor/core/index.js +1086 -662
  55. package/dist/vendor/core/mission/aggregate.d.ts +27 -0
  56. package/dist/vendor/core/mission/aggregate.js +42 -0
  57. package/dist/vendor/core/mission/index.d.ts +2 -0
  58. package/dist/vendor/core/mission/index.js +1 -0
  59. package/dist/vendor/core/persistence/compiler.d.ts +8 -0
  60. package/dist/vendor/core/persistence/compiler.js +156 -0
  61. package/dist/vendor/core/persistence/context-handoff-store.d.ts +68 -0
  62. package/dist/vendor/core/persistence/context-handoff-store.js +112 -0
  63. package/dist/vendor/core/persistence/index.d.ts +4 -0
  64. package/dist/vendor/core/persistence/index.js +2 -0
  65. package/dist/vendor/core/persistence/ledger.d.ts +1 -1
  66. package/dist/vendor/core/persistence/mission-store.d.ts +56 -0
  67. package/dist/vendor/core/persistence/mission-store.js +281 -0
  68. package/dist/vendor/core/policy.d.ts +2 -0
  69. package/dist/vendor/core/policy.js +5 -2
  70. package/dist/vendor/core/rollback.js +15 -1
  71. package/dist/vendor/core/savings.d.ts +13 -0
  72. package/dist/vendor/core/savings.js +22 -0
  73. package/dist/vendor/core/termination-store.d.ts +15 -0
  74. package/dist/vendor/core/termination-store.js +44 -0
  75. package/dist/vendor/core/verified-handoff.d.ts +67 -0
  76. package/dist/vendor/core/verified-handoff.js +210 -0
  77. package/package.json +76 -83
  78. package/server.json +21 -21
  79. package/LICENSE +0 -216
  80. package/dist/vendor/adapters/adapters/src/claude-cli.d.ts +0 -146
  81. package/dist/vendor/adapters/adapters/src/claude-cli.js +0 -1100
  82. package/dist/vendor/adapters/adapters/src/cli-bridge.d.ts +0 -103
  83. package/dist/vendor/adapters/adapters/src/cli-bridge.js +0 -569
  84. package/dist/vendor/adapters/adapters/src/codex-launcher.d.ts +0 -78
  85. package/dist/vendor/adapters/adapters/src/codex-launcher.js +0 -663
  86. package/dist/vendor/adapters/adapters/src/direct-provider.d.ts +0 -10
  87. package/dist/vendor/adapters/adapters/src/direct-provider.js +0 -40
  88. package/dist/vendor/adapters/adapters/src/index.d.ts +0 -8
  89. package/dist/vendor/adapters/adapters/src/index.js +0 -8
  90. package/dist/vendor/adapters/adapters/src/openai-compatible.d.ts +0 -62
  91. package/dist/vendor/adapters/adapters/src/openai-compatible.js +0 -306
  92. package/dist/vendor/adapters/adapters/src/runtime-support.d.ts +0 -17
  93. package/dist/vendor/adapters/adapters/src/runtime-support.js +0 -59
  94. package/dist/vendor/adapters/adapters/src/stub-agent-cli.d.ts +0 -8
  95. package/dist/vendor/adapters/adapters/src/stub-agent-cli.js +0 -40
  96. package/dist/vendor/adapters/adapters/src/stub-direct-provider.d.ts +0 -8
  97. package/dist/vendor/adapters/adapters/src/stub-direct-provider.js +0 -12
  98. package/dist/vendor/adapters/adapters/src/verifier-only.d.ts +0 -9
  99. package/dist/vendor/adapters/adapters/src/verifier-only.js +0 -63
  100. package/dist/vendor/adapters/contracts/src/context-graph.d.ts +0 -48
  101. package/dist/vendor/adapters/contracts/src/context-graph.js +0 -26
  102. package/dist/vendor/adapters/contracts/src/execution-policy.d.ts +0 -78
  103. package/dist/vendor/adapters/contracts/src/execution-policy.js +0 -43
  104. package/dist/vendor/adapters/contracts/src/governance.d.ts +0 -24
  105. package/dist/vendor/adapters/contracts/src/governance.js +0 -11
  106. package/dist/vendor/adapters/contracts/src/identity.d.ts +0 -29
  107. package/dist/vendor/adapters/contracts/src/identity.js +0 -30
  108. package/dist/vendor/adapters/contracts/src/index.d.ts +0 -412
  109. package/dist/vendor/adapters/contracts/src/index.js +0 -225
  110. package/dist/vendor/adapters/contracts/src/operator.d.ts +0 -19
  111. package/dist/vendor/adapters/contracts/src/operator.js +0 -11
  112. package/dist/vendor/adapters/contracts/src/trajectory.d.ts +0 -26
  113. package/dist/vendor/adapters/contracts/src/trajectory.js +0 -27
  114. package/dist/vendor/adapters/core/src/compiler.d.ts +0 -52
  115. package/dist/vendor/adapters/core/src/compiler.js +0 -52
  116. package/dist/vendor/adapters/core/src/context-graph.d.ts +0 -3
  117. package/dist/vendor/adapters/core/src/context-graph.js +0 -371
  118. package/dist/vendor/adapters/core/src/context-integrity.d.ts +0 -26
  119. package/dist/vendor/adapters/core/src/context-integrity.js +0 -80
  120. package/dist/vendor/adapters/core/src/grounding.d.ts +0 -38
  121. package/dist/vendor/adapters/core/src/grounding.js +0 -273
  122. package/dist/vendor/adapters/core/src/identity.d.ts +0 -20
  123. package/dist/vendor/adapters/core/src/identity.js +0 -86
  124. package/dist/vendor/adapters/core/src/index.d.ts +0 -186
  125. package/dist/vendor/adapters/core/src/index.js +0 -1495
  126. package/dist/vendor/adapters/core/src/leash.d.ts +0 -48
  127. package/dist/vendor/adapters/core/src/leash.js +0 -497
  128. package/dist/vendor/adapters/core/src/persistence/compiler.d.ts +0 -18
  129. package/dist/vendor/adapters/core/src/persistence/compiler.js +0 -34
  130. package/dist/vendor/adapters/core/src/persistence/index.d.ts +0 -10
  131. package/dist/vendor/adapters/core/src/persistence/index.js +0 -5
  132. package/dist/vendor/adapters/core/src/persistence/integrity.d.ts +0 -39
  133. package/dist/vendor/adapters/core/src/persistence/integrity.js +0 -252
  134. package/dist/vendor/adapters/core/src/persistence/ledger.d.ts +0 -23
  135. package/dist/vendor/adapters/core/src/persistence/ledger.js +0 -9
  136. package/dist/vendor/adapters/core/src/persistence/memory-store.d.ts +0 -63
  137. package/dist/vendor/adapters/core/src/persistence/memory-store.js +0 -115
  138. package/dist/vendor/adapters/core/src/persistence/runs-reader.d.ts +0 -66
  139. package/dist/vendor/adapters/core/src/persistence/runs-reader.js +0 -140
  140. package/dist/vendor/adapters/core/src/persistence/store.d.ts +0 -89
  141. package/dist/vendor/adapters/core/src/persistence/store.js +0 -125
  142. package/dist/vendor/adapters/core/src/persistence/trace-store.d.ts +0 -85
  143. package/dist/vendor/adapters/core/src/persistence/trace-store.js +0 -125
  144. package/dist/vendor/adapters/core/src/policy-compiler.d.ts +0 -2
  145. package/dist/vendor/adapters/core/src/policy-compiler.js +0 -195
  146. package/dist/vendor/adapters/core/src/policy.d.ts +0 -156
  147. package/dist/vendor/adapters/core/src/policy.js +0 -704
  148. package/dist/vendor/adapters/core/src/repo-analyzer.d.ts +0 -53
  149. package/dist/vendor/adapters/core/src/repo-analyzer.js +0 -263
  150. package/dist/vendor/adapters/core/src/rollback.d.ts +0 -15
  151. package/dist/vendor/adapters/core/src/rollback.js +0 -253
  152. package/dist/vendor/adapters/core/src/routing.d.ts +0 -82
  153. package/dist/vendor/adapters/core/src/routing.js +0 -336
  154. package/dist/vendor/adapters/core/src/test-integrity.d.ts +0 -64
  155. package/dist/vendor/adapters/core/src/test-integrity.js +0 -197
  156. package/dist/vendor/adapters/core/src/trajectory.d.ts +0 -18
  157. package/dist/vendor/adapters/core/src/trajectory.js +0 -295
  158. package/dist/vendor/adapters/stub-agent-cli.d.ts +0 -8
  159. package/dist/vendor/adapters/stub-agent-cli.js +0 -40
  160. package/dist/vendor/adapters/verifier-only.d.ts +0 -9
  161. package/dist/vendor/adapters/verifier-only.js +0 -63
package/dist/resources.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { readFile } from "node:fs/promises";
2
- import { join } from "node:path";
3
2
  import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
4
  import { buildMartinDiscoveryMetadata } from "./discovery-metadata.js";
5
5
  import { MARTIN_MCP_PACKAGE_VERSION } from "./package-version.js";
6
6
  import { inspectLoopTool } from "./tools/inspect-loop.js";
@@ -19,7 +19,6 @@ export const MARTIN_STATIC_RESOURCE_URIS = {
19
19
  triage: "martin://runs/triage",
20
20
  latestRun: "martin://runs/latest",
21
21
  latestSummary: "martin://runs/latest/summary",
22
- latestReceipt: "martin://runs/latest/receipt",
23
22
  latestProofCard: "martin://runs/latest/proof-card",
24
23
  latestBudgetStatus: "martin://runs/latest/budget-status",
25
24
  latestVerifierEvidence: "martin://runs/latest/verifier-evidence",
@@ -35,8 +34,8 @@ export const MARTIN_STATIC_RESOURCE_URIS = {
35
34
  operatingRulesGuide: "martin://guides/operating-rules",
36
35
  publishReadinessGuide: "martin://guides/publish-readiness",
37
36
  governanceStatus: "martin://agent/governance-status",
38
- memorySummary: "martin://agent/memory-summary",
39
- modeStatus: "martin://agent/mode-status"
37
+ modeStatus: "martin://agent/mode-status",
38
+ memorySummary: "martin://agent/memory-summary"
40
39
  };
41
40
  export const MARTIN_RESOURCE_TEMPLATES = [
42
41
  {
@@ -100,18 +99,11 @@ export const MARTIN_STATIC_RESOURCES = [
100
99
  description: "Compact latest-run summary for context-constrained agents.",
101
100
  mimeType: "application/json"
102
101
  },
103
- {
104
- uri: MARTIN_STATIC_RESOURCE_URIS.latestReceipt,
105
- name: "martin_latest_receipt",
106
- title: "Martin Latest Receipt",
107
- description: "Canonical structured receipt for the latest run; use this before optional proof-card views.",
108
- mimeType: "application/json"
109
- },
110
102
  {
111
103
  uri: MARTIN_STATIC_RESOURCE_URIS.latestProofCard,
112
104
  name: "martin_latest_proof_card",
113
105
  title: "Martin Latest Proof Card",
114
- description: "Optional Markdown proof view derived from the latest receipt.",
106
+ description: "Small Markdown receipt showing what happened, what Martin prevented, and the next safe action.",
115
107
  mimeType: "text/markdown"
116
108
  },
117
109
  {
@@ -212,19 +204,19 @@ export const MARTIN_STATIC_RESOURCES = [
212
204
  description: "Proactive governance status: whether work is governed, budget remaining, unreceipted runs, and recommended next action. Read this before starting agent work.",
213
205
  mimeType: "application/json"
214
206
  },
207
+ {
208
+ uri: MARTIN_STATIC_RESOURCE_URIS.modeStatus,
209
+ name: "martin_mode_status",
210
+ title: "Martin Mode Status",
211
+ description: "Current MartinLoop working mode, whether it is inherited or explicitly configured, and how to switch it.",
212
+ mimeType: "application/json"
213
+ },
215
214
  {
216
215
  uri: MARTIN_STATIC_RESOURCE_URIS.memorySummary,
217
216
  name: "martin_memory_summary",
218
217
  title: "Martin Memory Summary",
219
218
  description: "MartinLoop persistent memory: user preferences, consent signals, budget patterns, and behavioral observations aggregated over time. Read at session start to personalize recommendations.",
220
219
  mimeType: "application/json"
221
- },
222
- {
223
- uri: MARTIN_STATIC_RESOURCE_URIS.modeStatus,
224
- name: "martin_mode_status",
225
- title: "Martin Mode Status",
226
- description: "Current Martin working mode (auto, plan, or edits) and consent state. Read before starting agent work to confirm whether the user expects autonomous execution, plan approval, or per-edit review.",
227
- mimeType: "application/json"
228
220
  }
229
221
  ];
230
222
  export function listMartinResources() {
@@ -260,8 +252,6 @@ export async function readMartinResource(input) {
260
252
  return jsonResource(input.uri, withDiscoveryMetadata(await martinRunDossierTool({ latest: true, runsDir: context.runsRoot }), context.runsRoot));
261
253
  case MARTIN_STATIC_RESOURCE_URIS.latestSummary:
262
254
  return jsonResource(input.uri, withDiscoveryMetadata(await buildLatestSummaryResource(context.runsRoot), context.runsRoot));
263
- case MARTIN_STATIC_RESOURCE_URIS.latestReceipt:
264
- return jsonResource(input.uri, withDiscoveryMetadata(await buildLatestReceiptResource(context.runsRoot), context.runsRoot));
265
255
  case MARTIN_STATIC_RESOURCE_URIS.latestProofCard:
266
256
  return textResource(input.uri, "text/markdown", await buildLatestProofCardResource(context.runsRoot));
267
257
  case MARTIN_STATIC_RESOURCE_URIS.latestBudgetStatus:
@@ -284,7 +274,7 @@ export async function readMartinResource(input) {
284
274
  case MARTIN_STATIC_RESOURCE_URIS.governanceStatus:
285
275
  return jsonResource(input.uri, withDiscoveryMetadata(await buildGovernanceStatusResource(context.runsRoot, context.workingDirectory), context.runsRoot));
286
276
  case MARTIN_STATIC_RESOURCE_URIS.modeStatus:
287
- return jsonResource(input.uri, withDiscoveryMetadata(await buildModeStatusResource(), context.runsRoot));
277
+ return jsonResource(input.uri, withDiscoveryMetadata(await buildModeStatusResource(context.workingDirectory), context.runsRoot));
288
278
  case MARTIN_STATIC_RESOURCE_URIS.agentNextStep:
289
279
  return jsonResource(input.uri, withDiscoveryMetadata(await buildAgentNextStepResource(context.runsRoot), context.runsRoot));
290
280
  case MARTIN_STATIC_RESOURCE_URIS.mcpUsageGuide:
@@ -433,44 +423,6 @@ async function buildLatestSummaryResource(runsRoot) {
433
423
  warnings: [...latest.detail.warnings, ...verification.warnings]
434
424
  };
435
425
  }
436
- async function buildLatestReceiptResource(runsRoot) {
437
- const latest = await loadLatestRunForCompactResource(runsRoot);
438
- if (latest.empty || !latest.detail) {
439
- return compactEmptyState("latest-receipt", runsRoot, latest.warnings);
440
- }
441
- const ledgerEvents = await readLedgerEvents(latest.detail);
442
- const loop = latest.detail.loop;
443
- const verification = buildVerificationHistorySnapshot(loop, ledgerEvents);
444
- const preview = buildPersistedLoopPreview(loop);
445
- return {
446
- kind: "latest-receipt",
447
- loop: preview,
448
- task: {
449
- title: loop.task?.title,
450
- objective: loop.task?.objective,
451
- verificationPlan: loop.task?.verificationPlan ?? []
452
- },
453
- receiptIntegrity: latest.detail.loop.receiptIntegrity,
454
- verification: {
455
- status: verification.latestVerification?.passed === true
456
- ? "passed"
457
- : verification.latestVerification?.passed === false
458
- ? "failed"
459
- : "unavailable",
460
- summary: verification.latestVerification?.summary,
461
- latest: verification.latestVerification,
462
- count: verification.verificationCount
463
- },
464
- whatHappened: loop.attempts.at(-1)?.summary ?? verification.latestVerification?.summary ?? loop.task?.objective,
465
- whatMartinPrevented: describePrevention(loop),
466
- nextSafeAction: inferAgentNextStep(loop, verification),
467
- proofCard: {
468
- artifactGuaranteed: false,
469
- resource: MARTIN_STATIC_RESOURCE_URIS.latestProofCard
470
- },
471
- warnings: [...latest.detail.warnings, ...verification.warnings]
472
- };
473
- }
474
426
  async function buildLatestBudgetStatusResource(runsRoot) {
475
427
  const latest = await loadLatestRunForCompactResource(runsRoot);
476
428
  if (latest.empty || !latest.detail) {
@@ -601,7 +553,7 @@ async function buildLatestProofCardResource(runsRoot) {
601
553
  "",
602
554
  "What happened: Martin has not found a local run record in this runs root.",
603
555
  "What Martin prevented: unknown until a governed run executes.",
604
- "Next safe action: call `martin_doctor`, run `npx martin-loop demo`, then inspect `martin://runs/latest/receipt` or `martin://runs/latest/summary`.",
556
+ "Next safe action: call `martin_doctor`, run `npx martin-loop demo`, then inspect `martin://runs/latest/summary`.",
605
557
  "",
606
558
  "Estimate note: no cost or token savings are claimed without run evidence.",
607
559
  ""
@@ -708,6 +660,33 @@ async function buildGovernanceStatusResource(runsRoot, workingDirectory) {
708
660
  warning: governed ? undefined : "This session is NOT governed. Complete the required sequence before making changes."
709
661
  };
710
662
  }
663
+ async function buildModeStatusResource(workingDirectory) {
664
+ const configPath = join(homedir(), ".martin", "config.json");
665
+ let config = {};
666
+ try {
667
+ config = JSON.parse(await readFile(configPath, "utf8"));
668
+ }
669
+ catch {
670
+ // Fresh config means the implicit auto default is in effect.
671
+ }
672
+ const projectMode = config.projectOverrides?.[workingDirectory];
673
+ const defaultMode = config.defaultMode ?? "auto";
674
+ const effectiveMode = projectMode ?? defaultMode;
675
+ return {
676
+ kind: "mode-status",
677
+ effectiveMode,
678
+ defaultMode,
679
+ scope: projectMode ? "project" : config.defaultMode ? "global" : "implicit_default",
680
+ configured: Boolean(projectMode || config.defaultMode),
681
+ projectOverride: projectMode ?? null,
682
+ workingDirectory,
683
+ switchCommands: {
684
+ auto: "martin mode auto",
685
+ plan: "martin mode plan",
686
+ edits: "martin mode edits"
687
+ }
688
+ };
689
+ }
711
690
  function buildCurrentPoliciesResource(workingDirectory) {
712
691
  const signals = inspectRepoSignals(workingDirectory);
713
692
  const recommended = buildPolicyPackDefinition(undefined, signals);
@@ -751,14 +730,14 @@ function inferAgentNextStep(loop, verification) {
751
730
  return {
752
731
  action: "triage_before_retry",
753
732
  toolOrResource: "martin_triage_runs",
754
- instruction: "Call `martin_triage_runs` and inspect the latest receipt before spending another attempt."
733
+ instruction: "Call `martin_triage_runs` and inspect the proof card before spending another attempt."
755
734
  };
756
735
  }
757
736
  if (loop.status === "completed" && verification.latestVerification?.passed === true) {
758
737
  return {
759
738
  action: "prove_and_share",
760
- toolOrResource: MARTIN_STATIC_RESOURCE_URIS.latestReceipt,
761
- instruction: "Read the latest receipt and full dossier before sharing or promoting the result; generate a proof card only when a visual artifact is explicitly needed."
739
+ toolOrResource: MARTIN_STATIC_RESOURCE_URIS.latestProofCard,
740
+ instruction: "Read the proof card and full dossier before sharing or promoting the result."
762
741
  };
763
742
  }
764
743
  return {
@@ -769,202 +748,175 @@ function inferAgentNextStep(loop, verification) {
769
748
  }
770
749
  function buildMcpUsageGuide(runsRoot) {
771
750
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
772
- return `# Martin Loop MCP Usage
773
-
774
- Discovery revision: \`${metadata.discoveryRevision}\`
775
- Server version: \`${metadata.serverVersion}\`
776
- Runs root: \`${runsRoot}\`
777
-
778
- Martin Loop exposes governed coding workflows over MCP. Use the server health and run-store views to decide when to preflight, execute, inspect, or escalate.
779
-
780
- ## Recommended Flow
781
-
782
- 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` or call \`martin_doctor\` to confirm the environment and run-store visibility.
783
- 2. Use the \`martin_governed_coding_kickoff\` prompt to frame a governed coding request.
784
- 3. Call \`martin_preflight\` before \`martin_run\` when the task or safety envelope is non-trivial.
785
- 4. After execution, inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`martin://runs/{loopId}\`, and \`martin://runs/{loopId}/verification\`.
786
- 5. For low-context agents, read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, or \`${MARTIN_STATIC_RESOURCE_URIS.latestReceipt}\` before asking for full JSON. Treat \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\` as an optional derived view.
787
- 6. Read \`${MARTIN_STATIC_RESOURCE_URIS.triage}\` or call \`martin_triage_runs\` to prioritize which run needs attention first.
788
- 7. Use \`martin_debug_failed_run\` when a loop exits failed, budget-bound, or escalated.
789
-
790
- ## Current Martin MCP Surface
791
-
792
- - Tools: \`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\`
793
- - Static resources: \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\`, \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`${MARTIN_STATIC_RESOURCE_URIS.triage}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestReceipt}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestBudgetStatus}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestVerifierEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestRollbackEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.mcpUsageGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.publishReadinessGuide}\`
794
- - Resource templates: \`martin://runs/{loopId}\`, \`martin://runs/{loopId}/attempts/{attemptIndex}\`, \`martin://runs/{loopId}/verification\`
795
- - Prompts: \`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\`
796
-
797
- ## Notes
798
-
799
- - Discovery helpers read the existing Martin run-store; they do not create new schema.
800
- - Verification history is derived from persisted \`verification.completed\` evidence in loop records and ledgers.
801
- - Attempt inspection stays aligned with the same loop selectors used by \`martin_status\` and \`martin_inspect\`.
751
+ return `# Martin Loop MCP Usage
752
+
753
+ Discovery revision: \`${metadata.discoveryRevision}\`
754
+ Server version: \`${metadata.serverVersion}\`
755
+ Runs root: \`${runsRoot}\`
756
+
757
+ Martin Loop exposes governed coding workflows over MCP. Use the server health and run-store views to decide when to preflight, execute, inspect, or escalate.
758
+
759
+ ## Recommended Flow
760
+
761
+ 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` or call \`martin_doctor\` to confirm the environment and run-store visibility.
762
+ 2. Use the \`martin_governed_coding_kickoff\` prompt to frame a governed coding request.
763
+ 3. Call \`martin_preflight\` before \`martin_run\` when the task or safety envelope is non-trivial.
764
+ 4. After execution, inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`martin://runs/{loopId}\`, and \`martin://runs/{loopId}/verification\`.
765
+ 5. For low-context agents, read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, or \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\` before asking for full JSON.
766
+ 6. Read \`${MARTIN_STATIC_RESOURCE_URIS.triage}\` or call \`martin_triage_runs\` to prioritize which run needs attention first.
767
+ 7. Use \`martin_debug_failed_run\` when a loop exits failed, budget-bound, or escalated.
768
+
769
+ ## Current Martin MCP Surface
770
+
771
+ - Tools: \`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\`
772
+ - Static resources: \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\`, \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\`, \`${MARTIN_STATIC_RESOURCE_URIS.triage}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestBudgetStatus}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestVerifierEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.latestRollbackEvidence}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`, \`${MARTIN_STATIC_RESOURCE_URIS.governanceStatus}\`, \`${MARTIN_STATIC_RESOURCE_URIS.modeStatus}\`, \`${MARTIN_STATIC_RESOURCE_URIS.memorySummary}\`, \`${MARTIN_STATIC_RESOURCE_URIS.mcpUsageGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`, \`${MARTIN_STATIC_RESOURCE_URIS.publishReadinessGuide}\`
773
+ - Resource templates: \`martin://runs/{loopId}\`, \`martin://runs/{loopId}/attempts/{attemptIndex}\`, \`martin://runs/{loopId}/verification\`
774
+ - Prompts: \`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\`
775
+
776
+ ## Notes
777
+
778
+ - Discovery helpers read the existing Martin run-store; they do not create new schema.
779
+ - Verification history is derived from persisted \`verification.completed\` evidence in loop records and ledgers.
780
+ - Attempt inspection stays aligned with the same loop selectors used by \`martin_status\` and \`martin_inspect\`.
802
781
  `;
803
782
  }
804
783
  function buildAgentStartGuide(runsRoot) {
805
784
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
806
- return `# Agent Start Here
807
-
808
- Discovery revision: \`${metadata.discoveryRevision}\`
809
- Server version: \`${metadata.serverVersion}\`
810
- Runs root: \`${runsRoot}\`
811
-
812
- Use Martin Loop as the local governor before you spend agent tokens or retry a failed coding loop.
813
-
814
- ## Cheap Default Flow
815
-
816
- 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\` first. It is the smallest "what should I do now?" payload.
817
- 2. If no runs exist, call \`martin_doctor\`, then \`martin_preflight\`.
818
- 3. If a run exists, read \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\` before reading full run JSON.
819
- 4. If the verifier failed, use prompt \`martin_debug_failed_run\` or \`martin_triage\`.
820
- 5. If you need a shareable receipt, read \`${MARTIN_STATIC_RESOURCE_URIS.latestReceipt}\` first. Generate or inspect \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\` only when a visual artifact is explicitly required.
821
-
822
- ## Install Profiles
823
-
824
- - \`minimal\` (default): doctor, preflight, list, triage, dossier. Good for low tool bloat.
825
- - \`diagnostic\`: read-only inspection tools for debugging without execution.
826
- - \`full-local\`: all local tools, including \`martin_run\`.
827
- - \`github-review\`: review-oriented local profile for PR drafting and reviewer evidence.
828
- - \`starter\` and \`full\`: compatibility aliases.
829
-
830
- ## Copy-Paste Agent Rule
831
-
832
- Before running or retrying an autonomous coding task, call Martin. Prefer compact resources first, then full dossiers only when the compact receipt says more evidence is needed. Never claim success unless Martin shows verifier-backed completion or a clear blocked reason.
785
+ return `# Agent Start Here
786
+
787
+ Discovery revision: \`${metadata.discoveryRevision}\`
788
+ Server version: \`${metadata.serverVersion}\`
789
+ Runs root: \`${runsRoot}\`
790
+
791
+ Use Martin Loop as the local governor before you spend agent tokens or retry a failed coding loop.
792
+
793
+ ## Cheap Default Flow
794
+
795
+ 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\` first. It is the smallest "what should I do now?" payload.
796
+ 2. If no runs exist, call \`martin_doctor\`, then \`martin_preflight\`.
797
+ 3. If a run exists, read \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\` before reading full run JSON.
798
+ 4. If the verifier failed, use prompt \`martin_debug_failed_run\` or \`martin_triage\`.
799
+ 5. If you need a shareable receipt, read \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`.
800
+
801
+ ## Install Profiles
802
+
803
+ - \`minimal\` (default): doctor, preflight, list, triage, dossier. Good for low tool bloat.
804
+ - \`diagnostic\`: read-only inspection tools for debugging without execution.
805
+ - \`full-local\`: all local tools, including \`martin_run\`.
806
+ - \`github-review\`: review-oriented local profile for PR drafting and reviewer evidence.
807
+ - \`starter\` and \`full\`: compatibility aliases.
808
+
809
+ ## Copy-Paste Agent Rule
810
+
811
+ Before running or retrying an autonomous coding task, call Martin. Prefer compact resources first, then full dossiers only when the compact receipt says more evidence is needed. Never claim success unless Martin shows verifier-backed completion or a clear blocked reason.
833
812
  `;
834
813
  }
835
814
  function buildCommandMapGuide(runsRoot) {
836
815
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
837
- return `# Martin Command Map
838
-
839
- Discovery revision: \`${metadata.discoveryRevision}\`
840
- Server version: \`${metadata.serverVersion}\`
841
- Runs root: \`${runsRoot}\`
842
-
843
- Use this guide when an IDE or agent needs to know which Martin surface to call next.
844
-
845
- ## Default Governed Sequence
846
-
847
- 1. \`martin_doctor\` — confirm environment and visibility.
848
- 2. \`martin_plan\` — propose the bounded approach without spending a run.
849
- 3. \`martin_preflight\` — turn the plan into an explicit contract.
850
- 4. \`martin_run\` — execute only after the contract is safe.
851
- 5. \`martin_dossier\` — inspect what happened and what Martin prevented.
852
- 6. \`martin_eval\` — convert the result into review posture when needed.
853
-
854
- ## When To Use Which Surface
855
-
856
- - Need the smallest next action: \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`
857
- - Need a quick receipt: \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`
858
- - Need the structured receipt source of truth: \`${MARTIN_STATIC_RESOURCE_URIS.latestReceipt}\`
859
- - Need an optional visual proof object: \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`
860
- - Need a full run review: \`martin_dossier\`
861
- - Need to decide whether to retry: \`martin_triage_runs\`
862
- - Need IDE setup guidance: \`${MARTIN_STATIC_RESOURCE_URIS.ideOnboardingGuide}\`
816
+ return `# Martin Command Map
817
+
818
+ Discovery revision: \`${metadata.discoveryRevision}\`
819
+ Server version: \`${metadata.serverVersion}\`
820
+ Runs root: \`${runsRoot}\`
821
+
822
+ Use this guide when an IDE or agent needs to know which Martin surface to call next.
823
+
824
+ ## Default Governed Sequence
825
+
826
+ 1. \`martin_doctor\` — confirm environment and visibility.
827
+ 2. \`martin_plan\` — propose the bounded approach without spending a run.
828
+ 3. \`martin_preflight\` — turn the plan into an explicit contract.
829
+ 4. \`martin_run\` — execute only after the contract is safe.
830
+ 5. \`martin_dossier\` — inspect what happened and what Martin prevented.
831
+ 6. \`martin_eval\` — convert the result into review posture when needed.
832
+
833
+ ## When To Use Which Surface
834
+
835
+ - Need the smallest next action: \`${MARTIN_STATIC_RESOURCE_URIS.agentNextStep}\`
836
+ - Need a quick receipt: \`${MARTIN_STATIC_RESOURCE_URIS.latestSummary}\`
837
+ - Need a shareable proof object: \`${MARTIN_STATIC_RESOURCE_URIS.latestProofCard}\`
838
+ - Need a full run review: \`martin_dossier\`
839
+ - Need to decide whether to retry: \`martin_triage_runs\`
840
+ - Need IDE setup guidance: \`${MARTIN_STATIC_RESOURCE_URIS.ideOnboardingGuide}\`
863
841
  `;
864
842
  }
865
843
  function buildIdeOnboardingGuide(runsRoot) {
866
844
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
867
- return `# Martin IDE Onboarding
868
-
869
- Discovery revision: \`${metadata.discoveryRevision}\`
870
- Server version: \`${metadata.serverVersion}\`
871
- Runs root: \`${runsRoot}\`
872
-
873
- Use this guide after the MCP server is installed so the host naturally uses MartinLoop during real work.
874
-
875
- ## IDE Default Flow
876
-
877
- 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`
878
- 2. Read \`${MARTIN_STATIC_RESOURCE_URIS.operatingRulesGuide}\`
879
- 3. Use prompt \`martin_start\` or \`martin_governed_coding_kickoff\`
880
- 4. Call \`martin_doctor\`
881
- 5. Call \`martin_plan\`
882
- 6. Call \`martin_preflight\`
883
- 7. Only then call \`martin_run\`
884
-
885
- ## Goal
886
-
887
- MartinLoop should become the normal path for coding work in the host, not a manual extra step the human has to remember.
845
+ return `# Martin IDE Onboarding
846
+
847
+ Discovery revision: \`${metadata.discoveryRevision}\`
848
+ Server version: \`${metadata.serverVersion}\`
849
+ Runs root: \`${runsRoot}\`
850
+
851
+ Use this guide after the MCP server is installed so the host naturally uses MartinLoop during real work.
852
+
853
+ ## IDE Default Flow
854
+
855
+ 1. Read \`${MARTIN_STATIC_RESOURCE_URIS.agentStartGuide}\`
856
+ 2. Read \`${MARTIN_STATIC_RESOURCE_URIS.operatingRulesGuide}\`
857
+ 3. Use prompt \`martin_start\` or \`martin_governed_coding_kickoff\`
858
+ 4. Call \`martin_doctor\`
859
+ 5. Call \`martin_plan\`
860
+ 6. Call \`martin_preflight\`
861
+ 7. Only then call \`martin_run\`
862
+
863
+ ## Goal
864
+
865
+ MartinLoop should become the normal path for coding work in the host, not a manual extra step the human has to remember.
888
866
  `;
889
867
  }
890
868
  function buildOperatingRulesGuide(runsRoot) {
891
869
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
892
- return `# Martin Operating Rules
893
-
894
- Discovery revision: \`${metadata.discoveryRevision}\`
895
- Server version: \`${metadata.serverVersion}\`
896
- Runs root: \`${runsRoot}\`
897
-
898
- Use these rules inside the IDE or MCP host as the default MartinLoop operating posture.
899
-
900
- ## Required Sequence Before Real Work
901
-
902
- 1. \`martin_doctor\`
903
- 2. \`martin_plan\`
904
- 3. \`martin_preflight\`
905
- 4. \`martin_run\`
906
- 5. \`martin_dossier\`
907
-
908
- ## Enforcement Rule
909
-
910
- Do not execute real coding work through MartinLoop until doctor and preflight have both been used for the current task.
911
-
912
- ## Completion Rule
913
-
914
- Do not claim success until MartinLoop shows verifier-backed completion or an explicit blocked reason backed by evidence.
870
+ return `# Martin Operating Rules
871
+
872
+ Discovery revision: \`${metadata.discoveryRevision}\`
873
+ Server version: \`${metadata.serverVersion}\`
874
+ Runs root: \`${runsRoot}\`
875
+
876
+ Use these rules inside the IDE or MCP host as the default MartinLoop operating posture.
877
+
878
+ ## Required Sequence Before Real Work
879
+
880
+ 1. \`martin_doctor\`
881
+ 2. \`martin_plan\`
882
+ 3. \`martin_preflight\`
883
+ 4. \`martin_run\`
884
+ 5. \`martin_dossier\`
885
+
886
+ ## Enforcement Rule
887
+
888
+ Do not execute real coding work through MartinLoop until doctor and preflight have both been used for the current task.
889
+
890
+ ## Completion Rule
891
+
892
+ Do not claim success until MartinLoop shows verifier-backed completion or an explicit blocked reason backed by evidence.
915
893
  `;
916
894
  }
917
895
  function buildPublishReadinessGuide(runsRoot) {
918
896
  const metadata = buildMartinDiscoveryMetadata(MARTIN_MCP_PACKAGE_VERSION);
919
- return `# Martin MCP Publish Readiness
920
-
921
- Discovery revision: \`${metadata.discoveryRevision}\`
922
- Server version: \`${metadata.serverVersion}\`
923
- Runs root: \`${runsRoot}\`
924
-
925
- Use this guide when reviewing whether the public MCP package is ready to publish, promote, or hand off for registry submission.
926
-
927
- ## Review Areas
928
-
929
- 1. Environment health: confirm \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` shows a sane working directory, runs root, and engine availability for the target mode.
930
- 2. Discovery surface: verify tools, prompts, static resources, and resource templates are all discoverable and named consistently.
931
- 3. Run evidence: inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\` and, when relevant, \`martin://runs/{loopId}/verification\` to confirm verification outcomes are explainable from persisted data.
932
- 4. Packaging lane: run the MCP package test, build, and smoke-pack commands before calling the package publish-ready.
933
- 5. Findings-first reporting: call out missing schema, integration gaps, triage-critical runs, and verification blockers before summarizing strengths.
934
-
935
- ## Evidence Expectations
936
-
937
- - Prefer concrete run IDs, attempt indices, and verification summaries over vague statements.
938
- - Distinguish local package validation from live registry readiness.
939
- - If a discovery helper exists but is not yet wired into the server, report that as an integration gap instead of treating the capability as fully shipped.
897
+ return `# Martin MCP Publish Readiness
898
+
899
+ Discovery revision: \`${metadata.discoveryRevision}\`
900
+ Server version: \`${metadata.serverVersion}\`
901
+ Runs root: \`${runsRoot}\`
902
+
903
+ Use this guide when reviewing whether the public MCP package is ready to publish, promote, or hand off for registry submission.
904
+
905
+ ## Review Areas
906
+
907
+ 1. Environment health: confirm \`${MARTIN_STATIC_RESOURCE_URIS.serverHealth}\` shows a sane working directory, runs root, and engine availability for the target mode.
908
+ 2. Discovery surface: verify tools, prompts, static resources, and resource templates are all discoverable and named consistently.
909
+ 3. Run evidence: inspect \`${MARTIN_STATIC_RESOURCE_URIS.recentRuns}\` and, when relevant, \`martin://runs/{loopId}/verification\` to confirm verification outcomes are explainable from persisted data.
910
+ 4. Packaging lane: run the MCP package test, build, and smoke-pack commands before calling the package publish-ready.
911
+ 5. Findings-first reporting: call out missing schema, integration gaps, triage-critical runs, and verification blockers before summarizing strengths.
912
+
913
+ ## Evidence Expectations
914
+
915
+ - Prefer concrete run IDs, attempt indices, and verification summaries over vague statements.
916
+ - Distinguish local package validation from live registry readiness.
917
+ - If a discovery helper exists but is not yet wired into the server, report that as an integration gap instead of treating the capability as fully shipped.
940
918
  `;
941
919
  }
942
- async function buildModeStatusResource() {
943
- let currentMode = "auto";
944
- let modeConfigured = false;
945
- try {
946
- const config = JSON.parse(await readFile(join(homedir(), ".martin", "config.json"), "utf8"));
947
- if (config.defaultMode) {
948
- currentMode = config.defaultMode;
949
- modeConfigured = true;
950
- }
951
- }
952
- catch { /* fresh install — default to auto */ }
953
- return {
954
- kind: "mode-status",
955
- currentMode,
956
- modeConfigured,
957
- modes: {
958
- auto: "MartinLoop governs autonomously — estimate, preflight, run, receipt without per-step approval.",
959
- plan: "MartinLoop shows the proposed plan before executing. Agent waits for user approval.",
960
- edits: "MartinLoop shows each file change before writing. Maximum human control."
961
- },
962
- agentGuidance: modeConfigured
963
- ? `User has explicitly set mode to "${currentMode}". Respect this preference during the session.`
964
- : "Mode not explicitly configured. Defaulting to auto. Suggest running `martin mode auto|plan|edits` to set a preference.",
965
- changeCommand: "martin mode auto | plan | edits"
966
- };
967
- }
968
920
  function withDiscoveryMetadata(value, runsRoot) {
969
921
  return {
970
922
  metadata: {
@@ -1,4 +1,4 @@
1
- type ToolName = "martin_run" | "martin_inspect" | "martin_status" | "martin_doctor" | "martin_estimate" | "martin_plan" | "martin_preflight" | "martin_logs" | "martin_cancel" | "martin_pause" | "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";
1
+ type ToolName = "martin_run" | "martin_inspect" | "martin_status" | "martin_doctor" | "martin_plan" | "martin_preflight" | "martin_estimate" | "martin_logs" | "martin_cancel" | "martin_pause" | "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
2
  export { sanitizeToolErrorMessage } from "./tools/tool-errors.js";
3
3
  export declare function validateToolInput(name: ToolName, args: unknown): unknown;
4
4
  export declare function resolveSafeRepoRoot(repoRoot?: string, workspaceRoot?: string): string;
@@ -14,12 +14,12 @@ export function validateToolInput(name, args) {
14
14
  return validateStatusInput(args);
15
15
  case "martin_doctor":
16
16
  return validateDoctorInput(args);
17
- case "martin_estimate":
18
- return validateEstimateInput(args);
19
17
  case "martin_plan":
20
18
  return validatePlanInput(args);
21
19
  case "martin_preflight":
22
20
  return validatePreflightInput(args);
21
+ case "martin_estimate":
22
+ return validateEstimateInput(args);
23
23
  case "martin_logs":
24
24
  return validateLogsInput(args);
25
25
  case "martin_cancel":
@@ -254,22 +254,27 @@ function validateDoctorInput(args) {
254
254
  ...optionalEnumAsObject(record.engine, "engine", MARTIN_ENGINE_VALUES)
255
255
  };
256
256
  }
257
+ function validatePreflightInput(args) {
258
+ return validateRunInput(args);
259
+ }
260
+ function validatePlanInput(args) {
261
+ return validateRunInput(args);
262
+ }
257
263
  function validateEstimateInput(args) {
258
264
  const record = requireObject(args);
259
- assertAllowedKeys(record, ["objective", "engine", "budgetUsd", "fileScope"]);
265
+ assertAllowedKeys(record, ["objective", "engine", "budgetUsd", "fileScope", "workingDirectory"]);
266
+ const engine = optionalEnum(record.engine, "engine", MARTIN_ENGINE_VALUES);
267
+ const fileScope = normalizeSafePathPatterns(record.fileScope, "fileScope");
260
268
  return {
261
269
  objective: requireString(record.objective, "objective"),
262
- ...optionalEnumAsObject(record.engine, "engine", MARTIN_ENGINE_VALUES),
270
+ ...(engine ? { engine } : {}),
263
271
  ...optionalPositiveNumber(record.budgetUsd, "budgetUsd"),
264
- ...optionalStringArrayAsObject(record.fileScope, "fileScope")
272
+ ...(fileScope ? { fileScope } : {}),
273
+ ...(record.workingDirectory !== undefined
274
+ ? { workingDirectory: resolveSafeRepoRoot(requireString(record.workingDirectory, "workingDirectory")) }
275
+ : {})
265
276
  };
266
277
  }
267
- function validatePreflightInput(args) {
268
- return validateRunInput(args);
269
- }
270
- function validatePlanInput(args) {
271
- return validateRunInput(args);
272
- }
273
278
  function validateLogsInput(args) {
274
279
  const record = requireObject(args);
275
280
  assertAllowedKeys(record, ["file", "loopId", "runsDir", "latest", "limit"]);
package/dist/server.d.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  * Manual start:
17
17
  * node dist/server.js
18
18
  */
19
+ import { type Server as NodeHttpServer } from "node:http";
19
20
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
20
21
  export declare function createMartinMcpServer(serverInfo?: {
21
22
  name?: string;
@@ -88,4 +89,26 @@ export declare function connectMartinMcpStdioServer(): Promise<Server<{
88
89
  } | undefined;
89
90
  } | undefined;
90
91
  }>>;
92
+ export interface MartinMcpHttpServerOptions {
93
+ host?: string;
94
+ port?: number;
95
+ path?: string;
96
+ }
97
+ export interface MartinMcpHttpServerHandle {
98
+ server: NodeHttpServer;
99
+ host: string;
100
+ port: number;
101
+ path: string;
102
+ endpoint: string;
103
+ close: () => Promise<void>;
104
+ }
105
+ export declare function parseMartinMcpServerArgs(argv: string[]): {
106
+ transport: "stdio";
107
+ } | {
108
+ transport: "http";
109
+ host: string;
110
+ port: number;
111
+ path: string;
112
+ };
113
+ export declare function connectMartinMcpHttpServer(options?: MartinMcpHttpServerOptions): Promise<MartinMcpHttpServerHandle>;
91
114
  export declare function isDirectExecutionEntry(entryPath: string | undefined, moduleUrl?: string): boolean;