@jstn-sdk/ma 0.1.11 → 0.1.13

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 (159) hide show
  1. package/.codex/agents/Architect.toml +0 -2
  2. package/.codex/agents/Auditor.toml +0 -2
  3. package/.codex/agents/Builder.toml +0 -2
  4. package/.codex/agents/Flow.toml +0 -2
  5. package/.codex/agents/Sage.toml +0 -2
  6. package/.codex/agents/Vibe.toml +0 -2
  7. package/.codex/hooks.json +14 -13
  8. package/.codex/prompts/enforcement.md +4 -0
  9. package/.codex/prompts/skill-contract.md +4 -0
  10. package/COVERAGE.md +211 -0
  11. package/DEMO.md +265 -0
  12. package/README.md +287 -37
  13. package/bin/ma.js +232 -71
  14. package/data/clone-data.ledger.json +41 -0
  15. package/data/clone-data.proof.json +50 -0
  16. package/data/clone-data.rvf +37 -0
  17. package/docs/README.md +7 -1
  18. package/docs/getting-started.md +108 -37
  19. package/docs/installed-sdk.md +23 -0
  20. package/docs/mcp-setup.md +65 -1
  21. package/docs/onboarding.md +18 -2
  22. package/docs/prompt-guidance-contract.md +17 -0
  23. package/docs/prompt-guidance-fragments/active-autonomy-core.md +7 -0
  24. package/docs/qa/release-issue-gates-0.1.13.json +644 -0
  25. package/docs/qa/release-readiness-0.1.13.md +116 -0
  26. package/docs/qa/release-readiness-0.1.5.md +1 -1
  27. package/docs/reference/native-engineering-patterns.md +35 -0
  28. package/docs/reference/native-security-playbooks.md +27 -0
  29. package/docs/reference/native-source-selection.md +27 -0
  30. package/docs/reference/native-style-and-deslop.md +20 -0
  31. package/docs/release-spec.md +37 -10
  32. package/docs/skills-publishing.md +25 -1
  33. package/docs/skills.md +37 -12
  34. package/index.js +222 -2
  35. package/mcp/collections.json +23 -6
  36. package/mcp/local/code-intel.js +113 -0
  37. package/mcp/local/memory.js +46 -0
  38. package/mcp/local/playbooks.js +168 -0
  39. package/mcp/local/state.js +71 -0
  40. package/mcp/local/team-run.js +113 -0
  41. package/mcp/local/trace.js +60 -0
  42. package/mcp/local-capabilities.json +56 -0
  43. package/mcp/native-playbooks.json +117 -0
  44. package/mcp/servers.json +34 -0
  45. package/package.json +8 -2
  46. package/plugins/meta-architect/.app.json +1 -1
  47. package/plugins/meta-architect/.codex-plugin/plugin.json +4 -4
  48. package/plugins/meta-architect/.mcp.json +1 -1
  49. package/plugins/meta-architect/README.md +34 -1
  50. package/plugins/meta-architect/obsidian/main.js +401 -0
  51. package/plugins/meta-architect/obsidian/manifest.json +9 -0
  52. package/plugins/meta-architect/obsidian/styles.css +7 -0
  53. package/plugins/meta-architect/skills/align/SKILL.md +24 -0
  54. package/plugins/meta-architect/skills/align/agents/openai.yaml +4 -0
  55. package/plugins/meta-architect/skills/align/references/shared-language.md +24 -0
  56. package/plugins/meta-architect/skills/arch/SKILL.md +2 -0
  57. package/plugins/meta-architect/skills/build/SKILL.md +3 -0
  58. package/plugins/meta-architect/skills/cleanup/SKILL.md +23 -0
  59. package/plugins/meta-architect/skills/cleanup/agents/openai.yaml +4 -0
  60. package/plugins/meta-architect/skills/cleanup/references/style-and-deslop.md +18 -0
  61. package/plugins/meta-architect/skills/diagnose/SKILL.md +24 -0
  62. package/plugins/meta-architect/skills/diagnose/agents/openai.yaml +4 -0
  63. package/plugins/meta-architect/skills/flow/SKILL.md +2 -0
  64. package/plugins/meta-architect/skills/maestro/SKILL.md +36 -3
  65. package/plugins/meta-architect/skills/maestro/agents/openai.yaml +2 -2
  66. package/plugins/meta-architect/skills/maestro/references/native-ingest-map.md +44 -0
  67. package/plugins/meta-architect/skills/sage/SKILL.md +5 -1
  68. package/plugins/meta-architect/skills/sage/references/source-selection.md +36 -0
  69. package/plugins/meta-architect/skills/tdd/SKILL.md +24 -0
  70. package/plugins/meta-architect/skills/tdd/agents/openai.yaml +4 -0
  71. package/plugins/meta-architect/skills/vet/SKILL.md +5 -1
  72. package/plugins/meta-architect/skills/vet/references/security-playbooks.md +30 -0
  73. package/plugins/meta-architect/skills/vibe/SKILL.md +2 -0
  74. package/scripts/active-autonomy-hook.mjs +96 -0
  75. package/scripts/build-linux-packages.mjs +328 -0
  76. package/scripts/doctor.js +36 -4
  77. package/scripts/install.sh +28 -0
  78. package/scripts/linux-package-lib.mjs +40 -0
  79. package/scripts/linux-package-smoke.mjs +103 -0
  80. package/scripts/ralph/prompt.md +35 -0
  81. package/scripts/release-sync.js +13 -6
  82. package/scripts/release-verify.js +166 -1
  83. package/skills/align/SKILL.md +24 -0
  84. package/skills/align/agents/openai.yaml +4 -0
  85. package/skills/align/references/shared-language.md +24 -0
  86. package/skills/arch/SKILL.md +2 -0
  87. package/skills/build/SKILL.md +3 -0
  88. package/skills/cleanup/SKILL.md +23 -0
  89. package/skills/cleanup/agents/openai.yaml +4 -0
  90. package/skills/cleanup/references/style-and-deslop.md +18 -0
  91. package/skills/diagnose/SKILL.md +24 -0
  92. package/skills/diagnose/agents/openai.yaml +4 -0
  93. package/skills/flow/SKILL.md +2 -0
  94. package/skills/index.json +21 -6
  95. package/skills/maestro/SKILL.md +36 -3
  96. package/skills/maestro/agents/openai.yaml +2 -2
  97. package/skills/maestro/references/native-ingest-map.md +44 -0
  98. package/skills/sage/SKILL.md +5 -1
  99. package/skills/sage/references/source-selection.md +36 -0
  100. package/skills/tdd/SKILL.md +24 -0
  101. package/skills/tdd/agents/openai.yaml +4 -0
  102. package/skills/vet/SKILL.md +5 -1
  103. package/skills/vet/references/security-playbooks.md +30 -0
  104. package/skills/vibe/SKILL.md +2 -0
  105. package/src/bootstrap.js +141 -24
  106. package/src/build-gate.js +2 -2
  107. package/src/decision-log.js +12 -9
  108. package/src/launcher.js +4 -0
  109. package/src/mcp-config.js +130 -8
  110. package/src/mcp-live-client.js +289 -3
  111. package/src/paths.js +37 -1
  112. package/src/policy.js +1 -1
  113. package/src/release-issue-gates.js +190 -0
  114. package/src/release-state.js +30 -1
  115. package/src/runtime/active-autonomy-core.js +208 -0
  116. package/src/runtime/alignment-sentinel.js +165 -0
  117. package/src/runtime/architect-review.js +88 -0
  118. package/src/runtime/build-readiness.js +62 -0
  119. package/src/runtime/code-graph-rehearse.js +113 -0
  120. package/src/runtime/context-economy-core.js +276 -0
  121. package/src/runtime/continuity-notes.js +79 -0
  122. package/src/runtime/core-source-ingest.js +379 -0
  123. package/src/runtime/detached-provider.js +74 -0
  124. package/src/runtime/environment-awareness-core.js +460 -0
  125. package/src/runtime/exposure-catalog.js +276 -0
  126. package/src/runtime/guidance-stack.js +42 -0
  127. package/src/runtime/helper-orchestration-core.js +307 -0
  128. package/src/runtime/learning-loop-core.js +238 -0
  129. package/src/runtime/maestro-events.js +18 -0
  130. package/src/runtime/maestro-manager.js +605 -0
  131. package/src/runtime/maestro-state.js +125 -0
  132. package/src/runtime/mcp-policy.js +192 -0
  133. package/src/runtime/obsidian-integration-core.js +851 -0
  134. package/src/runtime/obsidian-plugin-bridge.js +739 -0
  135. package/src/runtime/orchestrator.js +158 -0
  136. package/src/runtime/prompt-strategy-core.js +230 -0
  137. package/src/runtime/quorum-review.js +90 -0
  138. package/src/runtime/ralph-execution-core.js +217 -0
  139. package/src/runtime/redaction-gateway.js +174 -0
  140. package/src/runtime/runtime-state.js +1223 -0
  141. package/src/runtime/semantic-recording-core.js +147 -0
  142. package/src/runtime/signal-hooks.js +67 -0
  143. package/src/runtime/skills-registry-export.js +670 -0
  144. package/src/runtime/startup-path.js +14 -0
  145. package/src/runtime/universal-plugin-broker-core.js +575 -0
  146. package/src/runtime/workspace-intelligence-runtime.js +674 -0
  147. package/src/runtime/workspace-virtualizer.js +102 -0
  148. package/src/runtime/workspaces.js +25 -0
  149. package/src/runtime-artifacts.js +407 -84
  150. package/src/skill-installer.js +53 -5
  151. package/src/skills.js +1454 -78
  152. package/src/state-sync.js +51 -8
  153. package/docs/qa/release-readiness-0.1.11.md +0 -79
  154. package/plugins/meta-architect/skills/meta-architect/SKILL.md +0 -32
  155. package/plugins/meta-architect/skills/meta-architect/agents/openai.yaml +0 -4
  156. package/skills/meta-architect/SKILL.md +0 -32
  157. package/skills/meta-architect/agents/openai.yaml +0 -4
  158. /package/plugins/meta-architect/skills/{meta-architect → maestro}/references/core-release-rules.md +0 -0
  159. /package/skills/{meta-architect → maestro}/references/core-release-rules.md +0 -0
package/index.js CHANGED
@@ -6,9 +6,16 @@ export {
6
6
  export {
7
7
  appendDecision,
8
8
  loadDecisionLog,
9
- updateDecisionStatuses,
10
9
  } from "./src/decision-log.js";
11
- export { isValidGitMcpEndpoint, loadMcpServers, validateMcpServers } from "./src/mcp-config.js";
10
+ export {
11
+ getSupportedLocalCapabilities,
12
+ isValidGitMcpEndpoint,
13
+ loadLocalCapabilities,
14
+ loadMcpServers,
15
+ runLocalCapabilityReadinessChecks,
16
+ validateLocalCapabilities,
17
+ validateMcpServers,
18
+ } from "./src/mcp-config.js";
12
19
  export {
13
20
  canMarkBuildDone,
14
21
  rejectsDirectProdPromotion,
@@ -16,6 +23,218 @@ export {
16
23
  validateReleaseOrigin,
17
24
  } from "./src/policy.js";
18
25
  export { loadReleaseState, saveReleaseState, validateReleaseState } from "./src/release-state.js";
26
+ export {
27
+ classifyAutonomyBranch,
28
+ createDefaultActiveAutonomyCore,
29
+ detectPassivePermissionHandoff,
30
+ loadActiveAutonomyCore,
31
+ validateActiveAutonomyCore,
32
+ } from "./src/runtime/active-autonomy-core.js";
33
+ export {
34
+ createAlignmentRecoveryPlan,
35
+ createDefaultAlignmentSentinelReport,
36
+ evaluateAlignmentDrift,
37
+ loadAlignmentSentinelReportOrDefault,
38
+ saveAlignmentSentinelReport,
39
+ } from "./src/runtime/alignment-sentinel.js";
40
+ export {
41
+ createCodeGraphTouchpoint,
42
+ createCodeGraphTouchpointFromFile,
43
+ createDefaultCodeGraphRehearse,
44
+ createRehearsalTrace,
45
+ extractStaticImports,
46
+ loadCodeGraphRehearse,
47
+ validateCodeGraphRehearse,
48
+ } from "./src/runtime/code-graph-rehearse.js";
49
+ export {
50
+ createContextEconomyPayload,
51
+ createContextEconomyView,
52
+ createDefaultContextEconomyCore,
53
+ createMcpDescriptorEconomy,
54
+ loadContextEconomyCore,
55
+ shouldBypassContextEconomy,
56
+ validateContextEconomyCore,
57
+ } from "./src/runtime/context-economy-core.js";
58
+ export {
59
+ coreSourceDefinitions,
60
+ createDefaultCoreSourceIngest,
61
+ findIngestedCoreSourceForRepo,
62
+ ingestCoreSources,
63
+ loadCoreSourceIngest,
64
+ validateCoreSourceIngest,
65
+ } from "./src/runtime/core-source-ingest.js";
66
+ export {
67
+ createDefaultEnvironmentAwarenessCore,
68
+ createDiscoveredEnvironmentAwarenessCore,
69
+ createEnvironmentCapability,
70
+ discoverEnvironmentCapabilities,
71
+ loadEnvironmentAwarenessCore,
72
+ refreshEnvironmentAwarenessCore,
73
+ selectEnvironmentCapabilitiesForTask,
74
+ validateEnvironmentAwarenessCore,
75
+ } from "./src/runtime/environment-awareness-core.js";
76
+ export {
77
+ scanExposureProfile,
78
+ scanLockfilePackageExposure,
79
+ scanPackageExposureFromLockfile,
80
+ scanPackageExposureFromManifest,
81
+ validateMcpPolicyExposure,
82
+ } from "./src/runtime/exposure-catalog.js";
83
+ export {
84
+ chooseHelperRoute,
85
+ createDefaultHelperOrchestrationCore,
86
+ createHelperReceipt,
87
+ evaluateHelperCoreCoverage,
88
+ helperSkillNames,
89
+ loadHelperOrchestrationCore,
90
+ resolveHelperContract,
91
+ validateHelperOrchestrationCore,
92
+ } from "./src/runtime/helper-orchestration-core.js";
93
+ export {
94
+ addLearningRecord,
95
+ createDefaultLearningLoopCore,
96
+ createLearningRecord,
97
+ evaluateLearningLoopReadiness,
98
+ learningLoopDomains,
99
+ loadLearningLoopCore,
100
+ validateLearningLoopCore,
101
+ } from "./src/runtime/learning-loop-core.js";
102
+ export {
103
+ validateRuntimeMcpPolicy,
104
+ validateRuntimeMcpPolicyFile,
105
+ } from "./src/runtime/mcp-policy.js";
106
+ export {
107
+ appendObsidianOperationReceipt,
108
+ createDefaultObsidianBridge,
109
+ createDefaultObsidianVaultOperations,
110
+ createObsidianIntakeContext,
111
+ createObsidianNote,
112
+ createObsidianPluginRequest,
113
+ createObsidianVaultContext,
114
+ createObsidianVaultSnapshotExport,
115
+ deleteObsidianNote,
116
+ ensureObsidianGraphLinks,
117
+ indexObsidianVault,
118
+ listObsidianNotes,
119
+ loadObsidianBridge,
120
+ loadObsidianVaultIndex,
121
+ loadObsidianVaultOperations,
122
+ obsidianGraphMapNotePath,
123
+ readObsidianNote,
124
+ updateObsidianNote,
125
+ validateObsidianBridge,
126
+ validateObsidianVaultIndex,
127
+ validateObsidianVaultOperations,
128
+ writeObsidianVaultIndex,
129
+ } from "./src/runtime/obsidian-integration-core.js";
130
+ export {
131
+ applyObsidianFrontmatterAuthority,
132
+ createDefaultObsidianPluginBridgeManifest,
133
+ createObsidianMetadataGraph,
134
+ createObsidianSelectionContext,
135
+ drainObsidianPluginRequestQueue,
136
+ extractObsidianCanvasContext,
137
+ generateObsidianMarkdownLink,
138
+ installObsidianPlugin,
139
+ obsidianPluginActiveContextPath,
140
+ obsidianPluginAttachmentDir,
141
+ obsidianPluginId,
142
+ obsidianPluginName,
143
+ obsidianPluginQueuePath,
144
+ registerMetaArchitectObsidianPluginRuntime,
145
+ registerObsidianEventWatchers,
146
+ registerObsidianProtocolHandlers,
147
+ renameObsidianFileSafely,
148
+ writeObsidianAttachment,
149
+ } from "./src/runtime/obsidian-plugin-bridge.js";
150
+ export {
151
+ createDefaultPromptStrategyCore,
152
+ loadPromptStrategyCore,
153
+ resolvePromptStrategyForRole,
154
+ resolvePromptStrategyForSurface,
155
+ validatePromptStrategyCore,
156
+ } from "./src/runtime/prompt-strategy-core.js";
157
+ export {
158
+ createQuorumReviewReceipt,
159
+ evaluateQuorumVotes,
160
+ quorumDecisions,
161
+ } from "./src/runtime/quorum-review.js";
162
+ export {
163
+ appendRalphProgressEntry,
164
+ completeRalphStory,
165
+ createRalphIterationPlan,
166
+ createRalphPrdContract,
167
+ selectNextRalphStory,
168
+ validateRalphPrdContract,
169
+ writeRalphExecutionContract,
170
+ } from "./src/runtime/ralph-execution-core.js";
171
+ export {
172
+ loadRedactionVaultOrDefault,
173
+ maskSensitiveText,
174
+ redactProviderBoundPayload,
175
+ redactProviderBoundText,
176
+ seedRedactionVault,
177
+ } from "./src/runtime/redaction-gateway.js";
178
+ export {
179
+ createDefaultSemanticRecordingCore,
180
+ loadSemanticRecordingCore,
181
+ validateSemanticRecordingCore,
182
+ } from "./src/runtime/semantic-recording-core.js";
183
+ export {
184
+ agentRegistry,
185
+ createDefaultSkillsRegistryExport,
186
+ createHostInstallReceipt,
187
+ createSkillCompatibilityPayload,
188
+ createSkillLockEntry,
189
+ inspectSkillCompatibilityInstall,
190
+ isUniversalAgent,
191
+ loadSkillsRegistryExport,
192
+ renderSkillCompatibilitySkillMd,
193
+ resolveSkillInstallPlan,
194
+ validateSkillLockEntry,
195
+ validateSkillsRegistryExport,
196
+ verifyCrossAgentInstallMatrix,
197
+ writeSkillCompatibilityExport,
198
+ } from "./src/runtime/skills-registry-export.js";
199
+ export {
200
+ createDefaultUniversalPluginBrokerCore,
201
+ createUniversalPluginManifest,
202
+ detectInstalledPluginHosts,
203
+ injectAntigravityMcpServer,
204
+ injectClaudeCodeMcpServer,
205
+ injectCodexMcpServer,
206
+ injectCursorMcpServer,
207
+ injectPluginToVendors,
208
+ installUniversalPlugin,
209
+ loadUniversalPluginBrokerCore,
210
+ loadUniversalPluginManifest,
211
+ renderPluginContextSkillMd,
212
+ renderUniversalMcpServerTemplate,
213
+ validateUniversalPluginBrokerCore,
214
+ validateUniversalPluginManifest,
215
+ writePluginContextSkill,
216
+ } from "./src/runtime/universal-plugin-broker-core.js";
217
+ export {
218
+ addSemanticReceipt,
219
+ createDefaultCapabilityComposition,
220
+ createDefaultSemanticReceiptIndex,
221
+ createDefaultWorkspaceContextPack,
222
+ createDefaultWorkspaceEffectiveness,
223
+ createSemanticReceipt,
224
+ evaluateWorkspaceEffectiveness,
225
+ loadWorkspaceIntelligenceArtifacts,
226
+ validateCapabilityComposition,
227
+ validateSemanticReceiptIndex,
228
+ validateWorkspaceContextPack,
229
+ validateWorkspaceEffectiveness,
230
+ } from "./src/runtime/workspace-intelligence-runtime.js";
231
+ export {
232
+ createDefaultWorkspaceVirtualizer,
233
+ createVirtualVerificationReceipt,
234
+ createVirtualWorkspacePlan,
235
+ loadWorkspaceVirtualizer,
236
+ validateWorkspaceVirtualizer,
237
+ } from "./src/runtime/workspace-virtualizer.js";
19
238
  export {
20
239
  listSkills,
21
240
  runArch,
@@ -26,3 +245,4 @@ export {
26
245
  runVet,
27
246
  runVibe,
28
247
  } from "./src/skills.js";
248
+ export { loadCombinedState, syncStatusUpdates } from "./src/state-sync.js";
@@ -10,12 +10,29 @@
10
10
  "java",
11
11
  "dotnet",
12
12
  "self-hosted",
13
- "system-design"
13
+ "system-design",
14
+ "obsidian-api-docs",
15
+ "obsidian-plugin-scaffold",
16
+ "prompt-techniques"
14
17
  ],
15
- "sage": ["meta-list", "typescript", "rust", "go", "python", "java", "dotnet", "self-hosted"],
16
- "vet": ["security"],
17
- "flow": [],
18
- "vibe": [],
19
- "build": []
18
+ "sage": [
19
+ "meta-list",
20
+ "typescript",
21
+ "rust",
22
+ "go",
23
+ "python",
24
+ "java",
25
+ "dotnet",
26
+ "self-hosted",
27
+ "system-design",
28
+ "obsidian-api-docs",
29
+ "obsidian-plugin-scaffold",
30
+ "context-economy",
31
+ "prompt-techniques"
32
+ ],
33
+ "vet": ["security", "context-economy", "prompt-techniques"],
34
+ "flow": ["system-design", "prompt-techniques"],
35
+ "vibe": ["obsidian-api-docs", "context-economy", "prompt-techniques"],
36
+ "build": ["system-design", "context-economy", "prompt-techniques"]
20
37
  }
21
38
  }
@@ -0,0 +1,113 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { getRepoRoot } from "../../src/paths.js";
4
+
5
+ const ignoredDirs = new Set([".git", ".ma", ".omx", "node_modules"]);
6
+ const codeIntelTools = [
7
+ "code_intel.list_files",
8
+ "code_intel.search_text",
9
+ "code_intel.read_excerpt",
10
+ ];
11
+
12
+ async function walk(rootDir, currentDir = rootDir, files = [], limit = Number.POSITIVE_INFINITY) {
13
+ if (files.length >= limit) {
14
+ return files;
15
+ }
16
+
17
+ const entries = await fs.readdir(currentDir, { withFileTypes: true });
18
+ for (const entry of entries) {
19
+ if (files.length >= limit) {
20
+ break;
21
+ }
22
+
23
+ if (entry.isDirectory()) {
24
+ if (ignoredDirs.has(entry.name)) {
25
+ continue;
26
+ }
27
+ await walk(rootDir, path.join(currentDir, entry.name), files, limit);
28
+ continue;
29
+ }
30
+
31
+ if (!entry.isFile()) {
32
+ continue;
33
+ }
34
+ files.push(path.relative(rootDir, path.join(currentDir, entry.name)));
35
+ }
36
+
37
+ return files;
38
+ }
39
+
40
+ export function listCodeIntelTools() {
41
+ return [...codeIntelTools];
42
+ }
43
+
44
+ export async function listRepoFiles(limit = 200) {
45
+ const repoRoot = getRepoRoot();
46
+ return walk(repoRoot, repoRoot, [], limit);
47
+ }
48
+
49
+ export async function searchRepoText(query, limit = 20) {
50
+ const repoRoot = getRepoRoot();
51
+ const files = await listRepoFiles(500);
52
+ const matches = [];
53
+
54
+ for (const relativePath of files) {
55
+ if (matches.length >= limit) {
56
+ break;
57
+ }
58
+
59
+ try {
60
+ const content = await fs.readFile(path.join(repoRoot, relativePath), "utf8");
61
+ const lines = content.split("\n");
62
+ lines.forEach((line, index) => {
63
+ if (matches.length < limit && line.includes(query)) {
64
+ matches.push({ file: relativePath, line: index + 1, text: line.trim() });
65
+ }
66
+ });
67
+ } catch {
68
+ // Skip non-text files.
69
+ }
70
+ }
71
+
72
+ return matches;
73
+ }
74
+
75
+ export async function readRepoExcerpt(relativePath, line = 1, context = 2) {
76
+ const repoRoot = getRepoRoot();
77
+ const content = await fs.readFile(path.join(repoRoot, relativePath), "utf8");
78
+ const lines = content.split("\n");
79
+ const start = Math.max(0, line - context - 1);
80
+ const end = Math.min(lines.length, line + context);
81
+ return lines.slice(start, end).map((text, index) => ({
82
+ line: start + index + 1,
83
+ text,
84
+ }));
85
+ }
86
+
87
+ export async function callCodeIntelTool(name, args = {}) {
88
+ if (name === "code_intel.list_files") {
89
+ return listRepoFiles(args.limit);
90
+ }
91
+ if (name === "code_intel.search_text") {
92
+ if (typeof args.query !== "string" || args.query.trim() === "") {
93
+ throw new Error("code_intel.search_text requires a non-empty query");
94
+ }
95
+ return searchRepoText(args.query, args.limit);
96
+ }
97
+ if (name === "code_intel.read_excerpt") {
98
+ if (typeof args.file !== "string" || args.file.trim() === "") {
99
+ throw new Error("code_intel.read_excerpt requires a file path");
100
+ }
101
+ return readRepoExcerpt(args.file, args.line, args.context);
102
+ }
103
+
104
+ throw new Error(`Unknown code_intel tool: ${name}`);
105
+ }
106
+
107
+ export async function checkCodeIntelCapability() {
108
+ const files = await listRepoFiles(10);
109
+ return {
110
+ ready: files.length > 0,
111
+ detail: `code intel indexed ${files.length} repo file(s) in the readiness sample`,
112
+ };
113
+ }
@@ -0,0 +1,46 @@
1
+ import {
2
+ loadContinuityIndex,
3
+ loadContinuityNotes,
4
+ storeContinuityNote,
5
+ } from "../../src/runtime/continuity-notes.js";
6
+
7
+ const memoryResources = ["memory://notes", "memory://index"];
8
+ const memoryTools = ["memory.store_note"];
9
+
10
+ export function listMemoryResources() {
11
+ return [...memoryResources];
12
+ }
13
+
14
+ export function listMemoryTools() {
15
+ return [...memoryTools];
16
+ }
17
+
18
+ export async function readMemoryResource(uri) {
19
+ if (uri === "memory://notes") {
20
+ return loadContinuityNotes();
21
+ }
22
+ if (uri === "memory://index") {
23
+ return loadContinuityIndex();
24
+ }
25
+
26
+ throw new Error(`Unknown memory resource: ${uri}`);
27
+ }
28
+
29
+ export async function callMemoryTool(name, args = {}, options = {}) {
30
+ if (name !== "memory.store_note") {
31
+ throw new Error(`Unknown memory tool: ${name}`);
32
+ }
33
+
34
+ return storeContinuityNote(args.content ?? "", {
35
+ ...options,
36
+ actor: "local-capability:memory",
37
+ });
38
+ }
39
+
40
+ export async function checkMemoryCapability() {
41
+ const index = await readMemoryResource("memory://index");
42
+ return {
43
+ ready: typeof index.sessionCount === "number",
44
+ detail: `continuity index loaded with sessionCount=${index.sessionCount}`,
45
+ };
46
+ }
@@ -0,0 +1,168 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import {
4
+ getBundledDocsPath,
5
+ getBundledMcpPath,
6
+ getBundledNativePlaybooksPath,
7
+ getBundledSkillsPath,
8
+ } from "../../src/paths.js";
9
+
10
+ const playbookRoots = [getBundledDocsPath(), getBundledSkillsPath(), getBundledMcpPath()];
11
+
12
+ function validateObjectWithArray(parsed, field, label) {
13
+ if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed[field])) {
14
+ throw new Error(`${label} must be an object with a ${field} array`);
15
+ }
16
+
17
+ return parsed;
18
+ }
19
+
20
+ function resolveAllowlistedResourcePath(relativePath) {
21
+ if (typeof relativePath !== "string" || relativePath.trim() === "") {
22
+ throw new Error("Playbook references require a non-empty relative path");
23
+ }
24
+ if (path.isAbsolute(relativePath)) {
25
+ throw new Error(`Playbook reference cannot use an absolute path: ${relativePath}`);
26
+ }
27
+
28
+ const resolved = path.resolve(
29
+ path.join(path.dirname(getBundledNativePlaybooksPath()), "..", relativePath),
30
+ );
31
+ const isAllowlisted = playbookRoots.some((root) => {
32
+ const normalizedRoot = path.resolve(root);
33
+ return resolved === normalizedRoot || resolved.startsWith(`${normalizedRoot}${path.sep}`);
34
+ });
35
+
36
+ if (!isAllowlisted) {
37
+ throw new Error(
38
+ `Playbook reference must resolve inside bundled docs, skills, or mcp: ${relativePath}`,
39
+ );
40
+ }
41
+
42
+ return resolved;
43
+ }
44
+
45
+ function findPack(manifest, packId) {
46
+ return manifest.packs.find((pack) => pack.id === packId) ?? null;
47
+ }
48
+
49
+ function findPackReference(manifest, packId, referenceId) {
50
+ const pack = findPack(manifest, packId);
51
+ if (!pack) {
52
+ return { pack: null, reference: null };
53
+ }
54
+
55
+ return {
56
+ pack,
57
+ reference: pack.references.find((item) => item.id === referenceId) ?? null,
58
+ };
59
+ }
60
+
61
+ export async function loadNativePlaybooks() {
62
+ const raw = await fs.readFile(getBundledNativePlaybooksPath(), "utf8");
63
+ const parsed = validateObjectWithArray(JSON.parse(raw), "packs", "mcp/native-playbooks.json");
64
+ const seen = new Set();
65
+
66
+ for (const pack of parsed.packs) {
67
+ if (typeof pack.id !== "string" || pack.id.trim() === "") {
68
+ throw new Error("Each native playbook pack requires a non-empty id");
69
+ }
70
+ if (seen.has(pack.id)) {
71
+ throw new Error(`Duplicate native playbook pack: ${pack.id}`);
72
+ }
73
+ if (typeof pack.title !== "string" || pack.title.trim() === "") {
74
+ throw new Error(`Native playbook pack ${pack.id} requires a title`);
75
+ }
76
+ if (!Array.isArray(pack.references)) {
77
+ throw new Error(`Native playbook pack ${pack.id} requires a references array`);
78
+ }
79
+
80
+ const referenceIds = new Set();
81
+ for (const reference of pack.references) {
82
+ if (typeof reference.id !== "string" || reference.id.trim() === "") {
83
+ throw new Error(`Native playbook pack ${pack.id} has a reference without an id`);
84
+ }
85
+ if (referenceIds.has(reference.id)) {
86
+ throw new Error(`Duplicate reference ${reference.id} in native playbook pack ${pack.id}`);
87
+ }
88
+ resolveAllowlistedResourcePath(reference.path);
89
+ referenceIds.add(reference.id);
90
+ }
91
+
92
+ seen.add(pack.id);
93
+ }
94
+
95
+ return parsed;
96
+ }
97
+
98
+ export async function listPlaybookResources() {
99
+ const manifest = await loadNativePlaybooks();
100
+ const resources = ["playbooks://manifest"];
101
+
102
+ for (const pack of manifest.packs) {
103
+ resources.push(`playbooks://packs/${pack.id}`);
104
+ for (const reference of pack.references) {
105
+ resources.push(`playbooks://references/${pack.id}/${reference.id}`);
106
+ }
107
+ }
108
+
109
+ return resources;
110
+ }
111
+
112
+ export function listPlaybookTools() {
113
+ return [];
114
+ }
115
+
116
+ export async function readPlaybookResource(uri) {
117
+ const manifest = await loadNativePlaybooks();
118
+
119
+ if (uri === "playbooks://manifest") {
120
+ return manifest;
121
+ }
122
+
123
+ const packMatch = /^playbooks:\/\/packs\/([^/]+)$/.exec(uri);
124
+ if (packMatch) {
125
+ const pack = findPack(manifest, packMatch[1]);
126
+ if (!pack) {
127
+ throw new Error(`Unknown playbooks pack: ${packMatch[1]}`);
128
+ }
129
+ return pack;
130
+ }
131
+
132
+ const referenceMatch = /^playbooks:\/\/references\/([^/]+)\/([^/]+)$/.exec(uri);
133
+ if (referenceMatch) {
134
+ const { pack, reference } = findPackReference(manifest, referenceMatch[1], referenceMatch[2]);
135
+ if (!pack || !reference) {
136
+ throw new Error(`Unknown playbooks reference: ${referenceMatch[1]}/${referenceMatch[2]}`);
137
+ }
138
+
139
+ const resolvedPath = resolveAllowlistedResourcePath(reference.path);
140
+ const content = await fs.readFile(resolvedPath, "utf8");
141
+ return {
142
+ packId: pack.id,
143
+ referenceId: reference.id,
144
+ title: reference.title,
145
+ path: reference.path,
146
+ content,
147
+ };
148
+ }
149
+
150
+ throw new Error(`Unknown playbooks resource: ${uri}`);
151
+ }
152
+
153
+ export async function checkPlaybooksCapability() {
154
+ const manifest = await loadNativePlaybooks();
155
+ let referenceCount = 0;
156
+
157
+ for (const pack of manifest.packs) {
158
+ for (const reference of pack.references) {
159
+ await fs.access(resolveAllowlistedResourcePath(reference.path));
160
+ referenceCount += 1;
161
+ }
162
+ }
163
+
164
+ return {
165
+ ready: manifest.packs.length > 0,
166
+ detail: `loaded ${manifest.packs.length} playbook pack(s) and ${referenceCount} referenced resource(s)`,
167
+ };
168
+ }
@@ -0,0 +1,71 @@
1
+ import { appendDecision } from "../../src/decision-log.js";
2
+ import { loadManagerRunRegistryOrDefault } from "../../src/runtime/maestro-manager.js";
3
+ import { createRuntimeSummary, loadRuntimeSnapshot } from "../../src/runtime/runtime-state.js";
4
+ import { loadCombinedState, syncStatusUpdates } from "../../src/state-sync.js";
5
+
6
+ const stateResources = [
7
+ "state://runtime/snapshot",
8
+ "state://manager/runs",
9
+ "state://release",
10
+ "state://decisions",
11
+ "state://combined",
12
+ ];
13
+ const stateTools = ["state.sync_release_status", "state.append_decision"];
14
+
15
+ export function listStateResources() {
16
+ return [...stateResources];
17
+ }
18
+
19
+ export function listStateTools() {
20
+ return [...stateTools];
21
+ }
22
+
23
+ export async function readStateResource(uri) {
24
+ if (uri === "state://runtime/snapshot") {
25
+ const snapshot = await loadRuntimeSnapshot();
26
+ return { snapshot, summary: createRuntimeSummary(snapshot) };
27
+ }
28
+
29
+ if (uri === "state://manager/runs") {
30
+ return loadManagerRunRegistryOrDefault();
31
+ }
32
+
33
+ const combined = await loadCombinedState();
34
+ if (uri === "state://release") {
35
+ return combined.release;
36
+ }
37
+ if (uri === "state://decisions") {
38
+ return combined.decisions;
39
+ }
40
+ if (uri === "state://combined") {
41
+ return combined;
42
+ }
43
+
44
+ throw new Error(`Unknown _state resource: ${uri}`);
45
+ }
46
+
47
+ export async function callStateTool(name, args = {}, options = {}) {
48
+ const localOptions = { ...options, actor: "local-capability:_state" };
49
+ if (name === "state.sync_release_status") {
50
+ const statusUpdates = args.statusUpdates ?? args;
51
+ return syncStatusUpdates(statusUpdates, localOptions);
52
+ }
53
+
54
+ if (name === "state.append_decision") {
55
+ const entry = args.entry ?? args;
56
+ return appendDecision(entry, localOptions);
57
+ }
58
+
59
+ throw new Error(`Unknown _state tool: ${name}`);
60
+ }
61
+
62
+ export async function checkStateCapability() {
63
+ const [snapshot, managerRuns] = await Promise.all([
64
+ readStateResource("state://runtime/snapshot"),
65
+ readStateResource("state://manager/runs"),
66
+ ]);
67
+ return {
68
+ ready: true,
69
+ detail: `runtime summary loaded with ${snapshot.summary.decisionCount} recorded decision(s) and ${managerRuns.runs.length} manager run(s)`,
70
+ };
71
+ }