@jstn-sdk/ma 0.1.13 → 0.14.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 (253) hide show
  1. package/.agents/plugins/marketplace.json +0 -0
  2. package/.codex/agents/Architect.toml +1 -0
  3. package/.codex/agents/Auditor.toml +1 -0
  4. package/.codex/agents/Builder.toml +1 -0
  5. package/.codex/agents/Flow.toml +1 -0
  6. package/.codex/agents/Sage.toml +1 -0
  7. package/.codex/agents/Vibe.toml +1 -0
  8. package/.codex/hooks.json +12 -2
  9. package/.codex/prompts/enforcement.md +0 -0
  10. package/.codex/prompts/onboarding.md +6 -1
  11. package/.codex/prompts/release-rules.md +0 -0
  12. package/.codex/prompts/skill-contract.md +0 -0
  13. package/COVERAGE.md +7 -7
  14. package/DEMO.md +15 -6
  15. package/LICENSE +0 -0
  16. package/README.md +126 -793
  17. package/bin/ma.js +585 -97
  18. package/data/clone-data.ledger.json +0 -0
  19. package/data/clone-data.proof.json +0 -0
  20. package/data/clone-data.rvf +0 -0
  21. package/docs/README.md +8 -2
  22. package/docs/autonomous-tasks.md +46 -0
  23. package/docs/codex-integration.md +16 -0
  24. package/docs/getting-started.md +28 -4
  25. package/docs/installed-sdk.md +0 -0
  26. package/docs/mcp-setup.md +30 -1
  27. package/docs/qa/{release-issue-gates-0.1.13.json → release-issue-gates-0.14.0.json} +77 -77
  28. package/docs/qa/release-readiness-0.1.5.md +0 -0
  29. package/docs/qa/{release-readiness-0.1.13.md → release-readiness-0.14.0.md} +12 -12
  30. package/docs/quality.md +24 -0
  31. package/docs/reference/native-engineering-patterns.md +0 -0
  32. package/docs/reference/native-security-playbooks.md +0 -0
  33. package/docs/reference/native-source-selection.md +0 -0
  34. package/docs/reference/native-style-and-deslop.md +0 -0
  35. package/docs/release-spec.md +27 -14
  36. package/docs/skills.md +1 -1
  37. package/index.js +73 -0
  38. package/mcp/collections.json +0 -0
  39. package/mcp/fallback.json +0 -0
  40. package/mcp/local/code-intel.js +179 -41
  41. package/mcp/local/context.js +180 -0
  42. package/mcp/local/memory.js +17 -6
  43. package/mcp/local/playbooks.js +0 -0
  44. package/mcp/local/quality.js +39 -0
  45. package/mcp/local/state.js +7 -3
  46. package/mcp/local/team-run.js +8 -3
  47. package/mcp/local/trace.js +0 -0
  48. package/mcp/local-capabilities.json +9 -0
  49. package/mcp/native-playbooks.json +0 -0
  50. package/mcp/servers.json +0 -0
  51. package/package.json +26 -4
  52. package/plugins/meta-architect/.app.json +1 -1
  53. package/plugins/meta-architect/.codex-plugin/plugin.json +1 -1
  54. package/plugins/meta-architect/.mcp.json +1 -1
  55. package/plugins/meta-architect/README.md +2 -2
  56. package/plugins/meta-architect/obsidian/main.js +137 -4
  57. package/plugins/meta-architect/obsidian/manifest.json +1 -1
  58. package/plugins/meta-architect/obsidian/styles.css +0 -0
  59. package/plugins/meta-architect/skills/align/SKILL.md +0 -0
  60. package/plugins/meta-architect/skills/align/agents/openai.yaml +0 -0
  61. package/plugins/meta-architect/skills/align/references/shared-language.md +0 -0
  62. package/plugins/meta-architect/skills/arch/SKILL.md +0 -0
  63. package/plugins/meta-architect/skills/arch/agents/openai.yaml +0 -0
  64. package/plugins/meta-architect/skills/build/SKILL.md +0 -0
  65. package/plugins/meta-architect/skills/build/agents/openai.yaml +0 -0
  66. package/plugins/meta-architect/skills/cleanup/SKILL.md +0 -0
  67. package/plugins/meta-architect/skills/cleanup/agents/openai.yaml +0 -0
  68. package/plugins/meta-architect/skills/cleanup/references/style-and-deslop.md +0 -0
  69. package/plugins/meta-architect/skills/diagnose/SKILL.md +0 -0
  70. package/plugins/meta-architect/skills/diagnose/agents/openai.yaml +0 -0
  71. package/plugins/meta-architect/skills/flow/SKILL.md +0 -0
  72. package/plugins/meta-architect/skills/flow/agents/openai.yaml +0 -0
  73. package/plugins/meta-architect/skills/maestro/SKILL.md +0 -0
  74. package/plugins/meta-architect/skills/maestro/agents/openai.yaml +0 -0
  75. package/plugins/meta-architect/skills/maestro/references/core-release-rules.md +0 -0
  76. package/plugins/meta-architect/skills/maestro/references/native-ingest-map.md +0 -0
  77. package/plugins/meta-architect/skills/sage/SKILL.md +0 -0
  78. package/plugins/meta-architect/skills/sage/agents/openai.yaml +0 -0
  79. package/plugins/meta-architect/skills/sage/references/source-selection.md +0 -0
  80. package/plugins/meta-architect/skills/tdd/SKILL.md +0 -0
  81. package/plugins/meta-architect/skills/tdd/agents/openai.yaml +0 -0
  82. package/plugins/meta-architect/skills/vet/SKILL.md +0 -0
  83. package/plugins/meta-architect/skills/vet/agents/openai.yaml +0 -0
  84. package/plugins/meta-architect/skills/vet/references/security-playbooks.md +0 -0
  85. package/plugins/meta-architect/skills/vibe/SKILL.md +0 -0
  86. package/plugins/meta-architect/skills/vibe/agents/openai.yaml +0 -0
  87. package/schemas/autonomous-task-queue.schema.json +56 -0
  88. package/schemas/handoff-packet.schema.json +36 -0
  89. package/schemas/setup-receipt.schema.json +28 -0
  90. package/schemas/skill-frontmatter.schema.json +20 -0
  91. package/schemas/support-bundle.schema.json +37 -0
  92. package/schemas/task-contract.schema.json +31 -0
  93. package/scripts/active-autonomy-hook.mjs +141 -11
  94. package/scripts/biome-staged.js +0 -0
  95. package/scripts/build-linux-packages.mjs +7 -3
  96. package/scripts/cleanup-test-fixtures.sh +55 -0
  97. package/scripts/context-hydration-hook.mjs +89 -0
  98. package/scripts/demo-smoke.js +285 -0
  99. package/scripts/doctor.js +10 -8
  100. package/scripts/install.sh +33 -4
  101. package/scripts/install.sh.sha256 +1 -0
  102. package/scripts/linux-package-lib.mjs +0 -0
  103. package/scripts/linux-package-smoke.mjs +2 -2
  104. package/scripts/package-size-check.mjs +26 -0
  105. package/scripts/plugin-sync.js +83 -17
  106. package/scripts/postinstall.js +17 -10
  107. package/scripts/prepack.js +9 -0
  108. package/scripts/ralph/prompt.md +0 -0
  109. package/scripts/release-metadata.js +0 -0
  110. package/scripts/release-sync.js +72 -7
  111. package/scripts/release-verify.js +100 -7
  112. package/scripts/setup-npmrc.js +48 -23
  113. package/scripts/skills-install.js +9 -2
  114. package/scripts/skills-manifest.js +2 -21
  115. package/scripts/skills-pack.js +2 -2
  116. package/scripts/skills-validate.js +5 -55
  117. package/skills/align/SKILL.md +0 -0
  118. package/skills/align/agents/openai.yaml +0 -0
  119. package/skills/align/references/shared-language.md +0 -0
  120. package/skills/arch/SKILL.md +0 -0
  121. package/skills/arch/agents/openai.yaml +0 -0
  122. package/skills/build/SKILL.md +0 -0
  123. package/skills/build/agents/openai.yaml +0 -0
  124. package/skills/cleanup/SKILL.md +0 -0
  125. package/skills/cleanup/agents/openai.yaml +0 -0
  126. package/skills/cleanup/references/style-and-deslop.md +0 -0
  127. package/skills/diagnose/SKILL.md +0 -0
  128. package/skills/diagnose/agents/openai.yaml +0 -0
  129. package/skills/flow/SKILL.md +0 -0
  130. package/skills/flow/agents/openai.yaml +0 -0
  131. package/skills/index.json +0 -0
  132. package/skills/maestro/SKILL.md +0 -0
  133. package/skills/maestro/agents/openai.yaml +0 -0
  134. package/skills/maestro/references/core-release-rules.md +0 -0
  135. package/skills/maestro/references/native-ingest-map.md +0 -0
  136. package/skills/sage/SKILL.md +0 -0
  137. package/skills/sage/agents/openai.yaml +0 -0
  138. package/skills/sage/references/source-selection.md +0 -0
  139. package/skills/tdd/SKILL.md +0 -0
  140. package/skills/tdd/agents/openai.yaml +0 -0
  141. package/skills/vet/SKILL.md +0 -0
  142. package/skills/vet/agents/openai.yaml +0 -0
  143. package/skills/vet/references/security-playbooks.md +0 -0
  144. package/skills/vibe/SKILL.md +0 -0
  145. package/skills/vibe/agents/openai.yaml +0 -0
  146. package/sprint/00-idea.md +0 -0
  147. package/sprint/01-architecture.md +0 -0
  148. package/sprint/02-oss-evidence.md +0 -0
  149. package/sprint/03-logic.md +0 -0
  150. package/sprint/04-security.md +0 -0
  151. package/sprint/05-dx-ux.md +0 -0
  152. package/sprint/06-build-plan.md +0 -0
  153. package/sprint/07-release.md +0 -0
  154. package/src/agents.js +279 -0
  155. package/src/bootstrap.js +252 -63
  156. package/src/build-gate.js +0 -0
  157. package/src/codex-app-server.js +291 -0
  158. package/src/decision-log.js +0 -0
  159. package/src/fs-utils.js +175 -4
  160. package/src/launcher.js +24 -21
  161. package/src/mcp-config.js +9 -1
  162. package/src/mcp-live-client.js +140 -7
  163. package/src/paths.js +6 -1
  164. package/src/policy.js +2 -2
  165. package/src/prelaunch.js +189 -0
  166. package/src/quality/ai-quality-orchestrator.js +328 -0
  167. package/src/release-issue-gates.js +62 -0
  168. package/src/release-operations.js +62 -0
  169. package/src/release-state.js +0 -0
  170. package/src/runtime/active-autonomy-core.js +0 -0
  171. package/src/runtime/agent-compat.js +31 -0
  172. package/src/runtime/alignment-sentinel.js +0 -0
  173. package/src/runtime/architect-review.js +248 -10
  174. package/src/runtime/autonomous-tasks.js +408 -0
  175. package/src/runtime/build-readiness.js +0 -0
  176. package/src/runtime/code-graph-rehearse.js +0 -0
  177. package/src/runtime/codeburn-core.js +112 -0
  178. package/src/runtime/context-authority.js +40 -0
  179. package/src/runtime/context-economy-core.js +40 -0
  180. package/src/runtime/continuity-graph.js +201 -0
  181. package/src/runtime/continuity-notes.js +71 -26
  182. package/src/runtime/core-source-ingest.js +0 -0
  183. package/src/runtime/detached-provider.js +82 -14
  184. package/src/runtime/doctor-report.js +18 -0
  185. package/src/runtime/environment-awareness-core.js +0 -0
  186. package/src/runtime/exposure-catalog.js +0 -0
  187. package/src/runtime/graphify-core.js +167 -0
  188. package/src/runtime/guidance-stack.js +9 -2
  189. package/src/runtime/handoff-packets.js +92 -0
  190. package/src/runtime/headroom-core.js +104 -0
  191. package/src/runtime/helper-orchestration-core.js +0 -0
  192. package/src/runtime/hook-profiles.js +20 -0
  193. package/src/runtime/learning-loop-core.js +110 -4
  194. package/src/runtime/live-agent-verification.js +122 -0
  195. package/src/runtime/maestro-events.js +0 -0
  196. package/src/runtime/maestro-manager.js +0 -0
  197. package/src/runtime/maestro-output.js +58 -0
  198. package/src/runtime/maestro-state.js +0 -0
  199. package/src/runtime/managed-markdown.js +29 -0
  200. package/src/runtime/mcp-authority.js +147 -0
  201. package/src/runtime/mcp-policy.js +0 -0
  202. package/src/runtime/obsidian-integration-core.js +255 -17
  203. package/src/runtime/obsidian-plugin-bridge.js +344 -38
  204. package/src/runtime/orchestrator.js +0 -0
  205. package/src/runtime/pi-maestro-core.js +89 -0
  206. package/src/runtime/preferences.js +79 -0
  207. package/src/runtime/project-context.js +636 -0
  208. package/src/runtime/prompt-strategy-core.js +0 -0
  209. package/src/runtime/quorum-review.js +0 -0
  210. package/src/runtime/ralph-execution-core.js +0 -0
  211. package/src/runtime/redaction-gateway.js +218 -19
  212. package/src/runtime/runtime-state.js +94 -2
  213. package/src/runtime/schema-migrations.js +162 -0
  214. package/src/runtime/semantic-recording-core.js +0 -0
  215. package/src/runtime/signal-hooks.js +13 -0
  216. package/src/runtime/skills-registry-export.js +92 -8
  217. package/src/runtime/startup-path.js +0 -0
  218. package/src/runtime/task-contracts.js +83 -0
  219. package/src/runtime/universal-plugin-broker-core.js +373 -50
  220. package/src/runtime/workspace-intelligence-runtime.js +0 -0
  221. package/src/runtime/workspace-virtualizer.js +0 -0
  222. package/src/runtime/workspaces.js +0 -0
  223. package/src/runtime-artifacts.js +0 -0
  224. package/src/setup-lifecycle.js +359 -0
  225. package/src/skill-frontmatter.js +78 -0
  226. package/src/skill-installer.js +226 -71
  227. package/src/skills.js +297 -19
  228. package/src/state-sync.js +0 -0
  229. package/src/test-fixtures.js +543 -0
  230. package/src/tui/grid.js +67 -0
  231. package/src/tui/status-grid.js +23 -0
  232. package/support-bundle.json +114 -0
  233. package/templates/AGENTS.md +6 -2
  234. package/templates/catalog-manifest.json +0 -0
  235. package/templates/model-instructions/core.md +0 -0
  236. package/templates/model-instructions/release.md +0 -0
  237. package/templates/model-instructions/security.md +0 -0
  238. package/templates/quality/ai-quality-rules.yml +37 -0
  239. package/docs/assets/image/Screenshot(1).png +0 -0
  240. package/docs/assets/image/Screenshot(2).png +0 -0
  241. package/docs/assets/image/Screenshot(3).png +0 -0
  242. package/docs/assets/image/Screenshot(4).png +0 -0
  243. package/docs/assets/image/Screenshot(5).png +0 -0
  244. package/docs/assets/image/Screenshot(6).png +0 -0
  245. package/docs/assets/image/Screenshot(7).png +0 -0
  246. package/docs/assets/image/Screenshot(8).png +0 -0
  247. package/docs/assets/image/Screenshot(9).png +0 -0
  248. package/docs/assets/meta-architect-logo.png +0 -0
  249. package/docs/assets/meta-architect-logo.svg +0 -8
  250. package/docs/onboarding.md +0 -81
  251. package/docs/prompt-guidance-contract.md +0 -17
  252. package/docs/prompt-guidance-fragments/active-autonomy-core.md +0 -7
  253. package/docs/skills-publishing.md +0 -255
package/bin/ma.js CHANGED
@@ -1,20 +1,43 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { spawnSync } from "node:child_process";
4
+ import fs from "node:fs/promises";
5
+ import path from "node:path";
6
+ import { resolveAgentCommand } from "../src/agents.js";
3
7
  import { runBootstrap, runDoctor } from "../src/bootstrap.js";
4
8
  import { appendDecision } from "../src/decision-log.js";
5
- import { runCodex, shouldDelegateToCodex } from "../src/launcher.js";
9
+ import { runAgent, shouldDelegateToCodex } from "../src/launcher.js";
10
+ import { getRepoRoot, packageRoot } from "../src/paths.js";
6
11
  import {
7
12
  canMarkBuildDone,
8
13
  rejectsDirectProdPromotion,
9
14
  validateMergeTarget,
10
15
  validateReleaseOrigin,
11
16
  } from "../src/policy.js";
17
+ import { choosePrelaunchInstall, installPrelaunchSelection } from "../src/prelaunch.js";
18
+ import { executeGitOperation, inspectGitOperation } from "../src/release-operations.js";
12
19
  import { loadReleaseState } from "../src/release-state.js";
20
+ import {
21
+ compileAgentIntegrations,
22
+ detectAgentEnvironments,
23
+ listAgentCompatAdapters,
24
+ validateAgentIntegrations,
25
+ } from "../src/runtime/agent-compat.js";
13
26
  import { runExternalArchitectReview } from "../src/runtime/architect-review.js";
27
+ import {
28
+ cancelAutonomousTask,
29
+ enqueueAutonomousTasks,
30
+ loadTaskQueue,
31
+ parseTaskInput,
32
+ runAutonomousTasks,
33
+ } from "../src/runtime/autonomous-tasks.js";
14
34
  import { evaluateRuntimeBuildReadiness } from "../src/runtime/build-readiness.js";
15
35
  import { ingestCoreSources } from "../src/runtime/core-source-ingest.js";
36
+ import { verifyLiveAgentMatrix } from "../src/runtime/live-agent-verification.js";
37
+ import { createMaestroView, formatMaestroView } from "../src/runtime/maestro-output.js";
16
38
  import {
17
39
  appendObsidianOperationReceipt,
40
+ configureObsidianVault,
18
41
  createObsidianNote,
19
42
  deleteObsidianNote,
20
43
  listObsidianNotes,
@@ -23,7 +46,11 @@ import {
23
46
  writeObsidianVaultIndex,
24
47
  } from "../src/runtime/obsidian-integration-core.js";
25
48
  import { installObsidianPlugin } from "../src/runtime/obsidian-plugin-bridge.js";
49
+ import { refreshProjectIndex } from "../src/runtime/project-context.js";
50
+ import { purgeRedactionVault } from "../src/runtime/redaction-gateway.js";
26
51
  import { createRuntimeSummary, loadRuntimeSnapshot } from "../src/runtime/runtime-state.js";
52
+ import { migrateSchemas } from "../src/runtime/schema-migrations.js";
53
+ import { rollbackSetup } from "../src/setup-lifecycle.js";
27
54
  import {
28
55
  ensureSkillsInstalled,
29
56
  ensureSupportBundleInstalled,
@@ -42,46 +69,278 @@ import {
42
69
  runVibe,
43
70
  } from "../src/skills.js";
44
71
  import { syncStatusUpdates } from "../src/state-sync.js";
72
+ import { renderReleaseGrid } from "../src/tui/status-grid.js";
45
73
 
46
74
  function printUsage() {
47
- console.error("Secondary helper commands:");
48
- console.error(" ma");
49
- console.error(" ma bootstrap [--init-mcp]");
50
- console.error(" ma doctor");
51
- console.error(" ma setup");
52
- console.error(" ma init");
53
- console.error(' ma idea "..."');
54
- console.error(" ma skills");
55
- console.error(" ma core-ingest [--refresh]");
56
- console.error(" ma obsidian-index [vault-path]");
57
- console.error(
75
+ console.log("Meta-Architect CLI");
76
+ console.log("Usage: ma <command> [options]");
77
+ console.log("\nCommands:");
78
+ console.log(" ma");
79
+ console.log(" ma bootstrap [--init-mcp]");
80
+ console.log(" ma doctor [--json]");
81
+ console.log(" ma welcome");
82
+ console.log(" ma context refresh [--full|--json]");
83
+ console.log(" ma migrate [--dry-run|--rollback|--json]");
84
+ console.log(" ma setup [--obsidian-vault <path>]");
85
+ console.log(" first interactive launch: choose project or user scope and detected hosts");
86
+ console.log(" ma setup --rollback");
87
+ console.log(" ma setup --rollback --dry-run");
88
+ console.log(" ma uninstall");
89
+ console.log(" ma init");
90
+ console.log(' ma idea "..."');
91
+ console.log(" ma skills");
92
+ console.log(" ma core-ingest [--refresh]");
93
+ console.log(" ma agent-compat adapters|detect|compile|validate [path]");
94
+ console.log(
95
+ " ma obsidian configure|list|read|create|update|delete|plugin-install [vault-path] [note-path] [content]",
96
+ );
97
+ console.log(" ma obsidian-index [vault-path]");
98
+ console.log(
58
99
  " ma obsidian list|read|create|update|delete|plugin-install <vault-path> [note-path] [content]",
59
100
  );
60
- console.error(" ma sdk-path");
61
- console.error(" ma status [--maestro-view]");
62
- console.error(" ma verify --architect");
63
- console.error(" ma run $maestro|$arch|$sage|$flow|$vet|$vibe|$build [--auto-heal] [--parallel]");
64
- console.error(" ma merge <source-branch> <target-branch>");
65
- console.error(" ma release <origin-branch> <target-branch>");
101
+ console.log(" ma sdk-path");
102
+ console.log(" ma status [--maestro-view]");
103
+ console.log(" ma verify --architect|--agents-live [--json]");
104
+ console.log(" ma run $maestro|$arch|$sage|$flow|$vet|$vibe|$build [--auto-heal] [--parallel]");
105
+ console.log(
106
+ " ma task add <goal> [--priority <level>] [--depends-on <id,...>] [--label <name>] [--deadline <ISO>]",
107
+ );
108
+ console.log(" ma task bulk <file|-> [--format json|yaml]");
109
+ console.log(" ma task list [--json]");
110
+ console.log(" ma task run [--concurrency <n>] [--max-tasks <n>] [--json]");
111
+ console.log(" ma task cancel <id> [reason]");
112
+ console.log(" ma hook active-autonomy|context-hydration");
113
+ console.log(" ma redaction purge [--dry-run]");
114
+ console.log(" ma merge <source-branch> <target-branch> [--dry-run|--execute]");
115
+ console.log(" ma release <origin-branch> <target-branch> [--dry-run|--execute]");
116
+ }
117
+
118
+ async function printVersion() {
119
+ const metadata = JSON.parse(await fs.readFile(path.join(packageRoot, "package.json"), "utf8"));
120
+ console.log(metadata.version);
121
+ }
122
+
123
+ function printCommandHelp(command) {
124
+ const help = {
125
+ setup: "ma setup [--json] [--obsidian-vault <path>] [--rollback] [--dry-run]",
126
+ doctor: "ma doctor [--json]",
127
+ status: "ma status [--json] [--maestro-view]",
128
+ context: "ma context refresh [--full] [--json]",
129
+ migrate: "ma migrate [--dry-run|--rollback] [--json]",
130
+ merge: "ma merge <source-branch> <target-branch> [--dry-run|--execute]",
131
+ release: "ma release <origin-branch> <target-branch> [--dry-run|--execute]",
132
+ "agent-compat": "ma agent-compat adapters|detect|compile|validate [path]",
133
+ verify: "ma verify --architect|--agents-live [--json]",
134
+ task: "ma task add|bulk|list|run|cancel ...",
135
+ };
136
+ console.log(help[command] ?? `No command-specific help is available for '${command}'.`);
137
+ }
138
+
139
+ function taskOption(rest, name) {
140
+ const value = getOptionValue(rest, name);
141
+ return value === undefined ? undefined : value;
142
+ }
143
+
144
+ async function runTaskCommand(rest) {
145
+ const action = rest[0] ?? "list";
146
+ if (action === "add") {
147
+ const flags = new Set([
148
+ "--priority",
149
+ "--depends-on",
150
+ "--label",
151
+ "--deadline",
152
+ "--id",
153
+ "--vendor",
154
+ ]);
155
+ const goal = rest
156
+ .slice(1)
157
+ .filter((value, index, values) => {
158
+ if (index > 0 && flags.has(values[index - 1])) return false;
159
+ return !value.startsWith("--") && !flags.has(value);
160
+ })
161
+ .join(" ");
162
+ if (!goal) throw new Error("Usage: ma task add <goal>");
163
+ const task = {
164
+ id: taskOption(rest, "--id"),
165
+ goal,
166
+ priority: taskOption(rest, "--priority"),
167
+ dependencies: taskOption(rest, "--depends-on")?.split(",").filter(Boolean),
168
+ labels: taskOption(rest, "--label")?.split(",").filter(Boolean),
169
+ deadline: taskOption(rest, "--deadline"),
170
+ vendor: taskOption(rest, "--vendor"),
171
+ };
172
+ const [added] = await enqueueAutonomousTasks(task);
173
+ console.log(
174
+ rest.includes("--json")
175
+ ? JSON.stringify(added, null, 2)
176
+ : `Queued ${added.id}: ${added.goal}`,
177
+ );
178
+ return;
179
+ }
180
+ if (action === "bulk") {
181
+ const source = rest[1];
182
+ if (!source) throw new Error("Usage: ma task bulk <file|-> [--format json|yaml]");
183
+ const raw =
184
+ source === "-"
185
+ ? await new Promise((resolve, reject) => {
186
+ const chunks = [];
187
+ process.stdin.on("data", (chunk) => chunks.push(chunk));
188
+ process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")));
189
+ process.stdin.on("error", reject);
190
+ })
191
+ : await fs.readFile(source, "utf8");
192
+ const format =
193
+ taskOption(rest, "--format") ??
194
+ (source.endsWith(".yaml") || source.endsWith(".yml") ? "yaml" : "json");
195
+ const added = await enqueueAutonomousTasks(await parseTaskInput(raw, format));
196
+ console.log(
197
+ rest.includes("--json") ? JSON.stringify(added, null, 2) : `Queued ${added.length} task(s)`,
198
+ );
199
+ return;
200
+ }
201
+ if (action === "list") {
202
+ const queue = await loadTaskQueue();
203
+ console.log(JSON.stringify(queue.tasks, null, 2));
204
+ return;
205
+ }
206
+ if (action === "cancel") {
207
+ if (!rest[1]) throw new Error("Usage: ma task cancel <id> [reason]");
208
+ const task = await cancelAutonomousTask(
209
+ rest[1],
210
+ rest
211
+ .slice(2)
212
+ .filter((value) => !value.startsWith("--"))
213
+ .join(" ") || undefined,
214
+ );
215
+ console.log(rest.includes("--json") ? JSON.stringify(task, null, 2) : `Cancelled ${task.id}`);
216
+ return;
217
+ }
218
+ if (action === "run") {
219
+ const result = await runAutonomousTasks({
220
+ concurrency: Number(taskOption(rest, "--concurrency") ?? 1),
221
+ maxTasks: Number(taskOption(rest, "--max-tasks") ?? Infinity),
222
+ });
223
+ if (rest.includes("--json")) console.log(JSON.stringify(result, null, 2));
224
+ else
225
+ console.log(
226
+ `Autonomous tasks: ${Object.entries(result.summary)
227
+ .map(([key, value]) => `${key}=${value}`)
228
+ .join(" ")}`,
229
+ );
230
+ if (result.summary.failed > 0 || result.summary.blocked > 0) process.exitCode = 1;
231
+ return;
232
+ }
233
+ throw new Error(`Unknown task action: ${action}`);
234
+ }
235
+
236
+ function getOptionValue(args, name) {
237
+ const index = args.indexOf(name);
238
+ return index === -1 ? undefined : args[index + 1];
239
+ }
240
+
241
+ function runHook(name) {
242
+ const scripts = {
243
+ "active-autonomy": "active-autonomy-hook.mjs",
244
+ "context-hydration": "context-hydration-hook.mjs",
245
+ };
246
+ const script = scripts[name];
247
+ if (!script) throw new Error(`Unknown hook: ${name}`);
248
+ const result = spawnSync(process.execPath, [path.join(packageRoot, "scripts", script)], {
249
+ cwd: process.cwd(),
250
+ env: process.env,
251
+ stdio: "inherit",
252
+ });
253
+ if (result.error) throw result.error;
254
+ process.exitCode = result.status ?? 1;
255
+ }
256
+
257
+ async function readObsidianContent(args, fallback) {
258
+ const filePath = getOptionValue(args, "--file");
259
+ if (filePath) return fs.readFile(filePath, "utf8");
260
+ if (args.includes("--stdin")) {
261
+ const chunks = [];
262
+ for await (const chunk of process.stdin) chunks.push(chunk);
263
+ return Buffer.concat(chunks).toString("utf8");
264
+ }
265
+ return fallback;
266
+ }
267
+
268
+ async function runAgentCompatCommand(rest) {
269
+ const [action = "adapters", firstArg, secondArg] = rest;
270
+ if (action === "adapters") {
271
+ console.log(JSON.stringify(listAgentCompatAdapters(), null, 2));
272
+ return;
273
+ }
274
+
275
+ if (action === "detect") {
276
+ console.log(JSON.stringify(await detectAgentEnvironments(firstArg ?? process.cwd()), null, 2));
277
+ return;
278
+ }
279
+
280
+ if (action === "validate") {
281
+ console.log(
282
+ JSON.stringify(await validateAgentIntegrations(firstArg ?? process.cwd()), null, 2),
283
+ );
284
+ return;
285
+ }
286
+
287
+ if (action === "compile") {
288
+ if (!firstArg) {
289
+ throw new Error("Usage: ma agent-compat compile <manifest.json> [output]");
290
+ }
291
+ const manifest = JSON.parse(await fs.readFile(firstArg, "utf8"));
292
+ const result = await compileAgentIntegrations(manifest, {
293
+ output: secondArg ?? process.cwd(),
294
+ });
295
+ console.log(JSON.stringify(result, null, 2));
296
+ if (!result.success) process.exitCode = 1;
297
+ return;
298
+ }
299
+
300
+ throw new Error(`Unknown Agent Compat action: ${action}`);
66
301
  }
67
302
 
68
- async function printStatus(releaseState) {
303
+ async function printStatus(releaseState, { json = false } = {}) {
304
+ const runtimeSummary = createRuntimeSummary(await loadRuntimeSnapshot());
305
+ const evaluation = evaluateRuntimeBuildReadiness(releaseState, runtimeSummary);
306
+ const payload = {
307
+ schemaVersion: "0.1.0",
308
+ scope: "status",
309
+ release: releaseState,
310
+ runtime: runtimeSummary,
311
+ nextTriggers: evaluation.nextTriggers,
312
+ };
313
+ if (json) {
314
+ console.log(JSON.stringify(payload, null, 2));
315
+ return payload;
316
+ }
69
317
  console.log("Meta-Architect Status");
70
318
  console.log("=====================");
71
- console.log(`Idea: ${releaseState.idea_status}`);
72
- console.log(`Architecture: ${releaseState.architecture_status}`);
73
- console.log(`Evidence: ${releaseState.evidence_status}`);
74
- console.log(`Logic: ${releaseState.logic_status}`);
75
- console.log(`Security: ${releaseState.security_status}`);
76
- console.log(`Experience: ${releaseState.experience_status}`);
77
- console.log(`Build: ${releaseState.build_status}`);
319
+ if (process.stdout.isTTY) {
320
+ console.log(renderReleaseGrid(releaseState, evaluation.nextTriggers));
321
+ }
322
+ if (process.stdout.isTTY) {
323
+ console.log(
324
+ `Core source snapshots: ${runtimeSummary.coreSourceIngestCount} (${runtimeSummary.coreSourceIngestStatus})`,
325
+ );
326
+ console.log(`Obsidian vault notes: ${runtimeSummary.obsidianVaultNoteCount}`);
327
+ console.log(`Obsidian CRUD receipts: ${runtimeSummary.obsidianVaultOperationCount}`);
328
+ }
329
+ if (!process.stdout.isTTY) {
330
+ console.log(`Idea: ${releaseState.idea_status}`);
331
+ console.log(`Architecture: ${releaseState.architecture_status}`);
332
+ console.log(`Evidence: ${releaseState.evidence_status}`);
333
+ console.log(`Logic: ${releaseState.logic_status}`);
334
+ console.log(`Security: ${releaseState.security_status}`);
335
+ console.log(`Experience: ${releaseState.experience_status}`);
336
+ console.log(`Build: ${releaseState.build_status}`);
78
337
 
79
- const runtimeSummary = createRuntimeSummary(await loadRuntimeSnapshot());
80
- console.log(
81
- `Core source snapshots: ${runtimeSummary.coreSourceIngestCount} (${runtimeSummary.coreSourceIngestStatus})`,
82
- );
83
- console.log(`Obsidian vault notes: ${runtimeSummary.obsidianVaultNoteCount}`);
84
- console.log(`Obsidian CRUD receipts: ${runtimeSummary.obsidianVaultOperationCount}`);
338
+ console.log(
339
+ `Core source snapshots: ${runtimeSummary.coreSourceIngestCount} (${runtimeSummary.coreSourceIngestStatus})`,
340
+ );
341
+ console.log(`Obsidian vault notes: ${runtimeSummary.obsidianVaultNoteCount}`);
342
+ console.log(`Obsidian CRUD receipts: ${runtimeSummary.obsidianVaultOperationCount}`);
343
+ }
85
344
  if (
86
345
  releaseState.build_status === "DONE" &&
87
346
  releaseState.merge_status !== "MERGED_TO_DEVELOPMENT"
@@ -90,7 +349,6 @@ async function printStatus(releaseState) {
90
349
  console.log("ma merge <feature/*> development");
91
350
  return;
92
351
  }
93
- const evaluation = evaluateRuntimeBuildReadiness(releaseState, runtimeSummary);
94
352
  console.log("Next allowed triggers:");
95
353
  const triggers = evaluation.nextTriggers;
96
354
  if (triggers.length === 0) {
@@ -103,41 +361,11 @@ async function printStatus(releaseState) {
103
361
  }
104
362
  }
105
363
 
106
- async function printMaestroView() {
107
- const snapshot = await loadRuntimeSnapshot();
108
- const trackEntries = Object.entries(snapshot.maestroState.runtime_tracks);
109
- console.log("Maestro View");
110
- console.log("============");
111
- console.log(`Global status: ${snapshot.maestroState.global_status}`);
112
- console.log(`Orchestration id: ${snapshot.maestroState.orchestration_id ?? "not started"}`);
113
- console.log("Runtime tracks:");
114
- if (trackEntries.length === 0) {
115
- console.log("- none");
116
- } else {
117
- for (const [trackId, track] of trackEntries) {
118
- console.log(`- ${trackId}: ${track.active_gate} [${track.status}]`);
119
- if (Array.isArray(track.blockers) && track.blockers.length > 0) {
120
- console.log(` blockers: ${track.blockers.join("; ")}`);
121
- }
122
- }
123
- }
124
-
125
- const lockEntries = Object.entries(snapshot.maestroState.downstream_lock_table);
126
- console.log("Downstream locks:");
127
- if (lockEntries.length === 0) {
128
- console.log("- none");
129
- return;
130
- }
131
-
132
- for (const [gate, lock] of lockEntries) {
133
- console.log(`- ${gate}: ${lock.is_locked ? "locked" : "unlocked"}`);
134
- if (Array.isArray(lock.locked_by) && lock.locked_by.length > 0) {
135
- console.log(` locked by: ${lock.locked_by.join(", ")}`);
136
- }
137
- if (lock.unlock_criteria) {
138
- console.log(` unlock criteria: ${lock.unlock_criteria}`);
139
- }
140
- }
364
+ async function printMaestroView({ json = false, snapshot = null } = {}) {
365
+ const currentSnapshot = snapshot ?? (await loadRuntimeSnapshot());
366
+ const view = createMaestroView(currentSnapshot.maestroState);
367
+ if (json) return view;
368
+ process.stdout.write(formatMaestroView(view));
141
369
  }
142
370
 
143
371
  async function runBuild() {
@@ -177,7 +405,7 @@ async function runBuild() {
177
405
  console.log("Next step: ma merge <feature/*> development");
178
406
  }
179
407
 
180
- async function runMerge(sourceBranch, targetBranch) {
408
+ async function runMerge(sourceBranch, targetBranch, mode = "approval") {
181
409
  const releaseState = await loadReleaseState();
182
410
 
183
411
  if (!validateMergeTarget(sourceBranch, targetBranch)) {
@@ -188,6 +416,25 @@ async function runMerge(sourceBranch, targetBranch) {
188
416
  throw new Error("Merge is blocked until build status is DONE");
189
417
  }
190
418
 
419
+ const operation = await inspectGitOperation(getRepoRoot(), sourceBranch, targetBranch);
420
+ if (!operation.available || !operation.sourceExists || !operation.clean) {
421
+ throw new Error(`Git preflight failed: ${operation.blockers.join("; ")}`);
422
+ }
423
+ if (mode === "dry-run") {
424
+ console.log(
425
+ `DRY RUN: approval state unchanged; would execute ${operation.display} on ${targetBranch}`,
426
+ );
427
+ return;
428
+ }
429
+ if (mode === "execute") {
430
+ if (operation.currentBranch !== targetBranch) {
431
+ throw new Error(
432
+ `Git execute requires current branch ${targetBranch}; found ${operation.currentBranch || "detached HEAD"}`,
433
+ );
434
+ }
435
+ await executeGitOperation(getRepoRoot(), operation);
436
+ }
437
+
191
438
  await appendDecision({
192
439
  kind: "merge",
193
440
  decision: `Merge approved from ${sourceBranch} to ${targetBranch}`,
@@ -201,10 +448,14 @@ async function runMerge(sourceBranch, targetBranch) {
201
448
  merge_status: "MERGED_TO_DEVELOPMENT",
202
449
  });
203
450
 
204
- console.log(`Merge approved: ${sourceBranch} -> ${targetBranch}`);
451
+ console.log(
452
+ mode === "execute"
453
+ ? `Merge executed and approved: ${sourceBranch} -> ${targetBranch}`
454
+ : `Merge approved only: ${sourceBranch} -> ${targetBranch}; no Git command executed. Run \`${operation.display}\` explicitly or use --execute.`,
455
+ );
205
456
  }
206
457
 
207
- async function runRelease(originBranch, targetBranch) {
458
+ async function runRelease(originBranch, targetBranch, mode = "approval") {
208
459
  const releaseState = await loadReleaseState();
209
460
 
210
461
  if (targetBranch !== "prod") {
@@ -221,6 +472,25 @@ async function runRelease(originBranch, targetBranch) {
221
472
  throw new Error("Release is blocked until merge_status is MERGED_TO_DEVELOPMENT");
222
473
  }
223
474
 
475
+ const operation = await inspectGitOperation(getRepoRoot(), originBranch, targetBranch);
476
+ if (!operation.available || !operation.sourceExists || !operation.clean) {
477
+ throw new Error(`Git preflight failed: ${operation.blockers.join("; ")}`);
478
+ }
479
+ if (mode === "dry-run") {
480
+ console.log(
481
+ `DRY RUN: approval state unchanged; would execute ${operation.display} on ${targetBranch}`,
482
+ );
483
+ return;
484
+ }
485
+ if (mode === "execute") {
486
+ if (operation.currentBranch !== targetBranch) {
487
+ throw new Error(
488
+ `Git execute requires current branch ${targetBranch}; found ${operation.currentBranch || "detached HEAD"}`,
489
+ );
490
+ }
491
+ await executeGitOperation(getRepoRoot(), operation);
492
+ }
493
+
224
494
  await appendDecision({
225
495
  kind: "release",
226
496
  decision: `Release approved from ${originBranch} to ${targetBranch}`,
@@ -234,7 +504,20 @@ async function runRelease(originBranch, targetBranch) {
234
504
  release_status: "SHIPPED_TO_PROD",
235
505
  });
236
506
 
237
- console.log(`Release approved: ${originBranch} -> ${targetBranch}`);
507
+ console.log(
508
+ mode === "execute"
509
+ ? `Release executed and approved: ${originBranch} -> ${targetBranch}`
510
+ : `Release approved only: ${originBranch} -> ${targetBranch}; no Git command executed. Run \`${operation.display}\` explicitly or use --execute.`,
511
+ );
512
+ }
513
+
514
+ function resolveGitMode(args) {
515
+ const modes = [
516
+ args.includes("--dry-run") && "dry-run",
517
+ args.includes("--execute") && "execute",
518
+ ].filter(Boolean);
519
+ if (modes.length > 1) throw new Error("Choose only one of --dry-run or --execute");
520
+ return modes[0] ?? "approval";
238
521
  }
239
522
 
240
523
  async function main() {
@@ -242,40 +525,179 @@ async function main() {
242
525
  const args = process.argv.slice(2);
243
526
  const arg = rest[0];
244
527
 
528
+ if (args[0] === "--help" || args[0] === "-h" || args[0] === "help") {
529
+ if (args[0] === "help" && args[1]) printCommandHelp(args[1]);
530
+ else printUsage();
531
+ return;
532
+ }
533
+ if (args[0] === "--version" || args[0] === "-v" || args[0] === "version") {
534
+ await printVersion();
535
+ return;
536
+ }
537
+ if (args.includes("--help")) {
538
+ printCommandHelp(command);
539
+ return;
540
+ }
541
+
542
+ if (command === "hook") {
543
+ runHook(arg);
544
+ return;
545
+ }
546
+
547
+ if (command === "task") {
548
+ await runTaskCommand(rest);
549
+ return;
550
+ }
551
+
552
+ if (command === "redaction" && rest[0] === "purge") {
553
+ const result = await purgeRedactionVault({ dryRun: rest.includes("--dry-run") });
554
+ console.log(JSON.stringify(result, null, 2));
555
+ return;
556
+ }
557
+
245
558
  if (shouldDelegateToCodex(args)) {
246
- await Promise.all([ensureSkillsInstalled(), ensureSupportBundleInstalled()]);
247
- process.exitCode = runCodex(args);
559
+ const selection = await choosePrelaunchInstall();
560
+ const agentType = process.env.MA_AGENT || selection?.targets?.[0] || "codex";
561
+ if (selection) {
562
+ await installPrelaunchSelection(selection);
563
+ } else if (process.env.MA_AGENT) {
564
+ await installPrelaunchSelection({
565
+ schemaVersion: "0.1.0",
566
+ scope: "project",
567
+ targets: [agentType],
568
+ });
569
+ } else {
570
+ await Promise.all([ensureSkillsInstalled(), ensureSupportBundleInstalled()]);
571
+ }
572
+ if (!resolveAgentCommand(agentType)) {
573
+ console.log(
574
+ `Installed ${agentType} compatibility files; no executable host command is registered, so delegation was skipped.`,
575
+ );
576
+ return;
577
+ }
578
+ process.exitCode = runAgent(args, agentType);
248
579
  return;
249
580
  }
250
581
 
251
582
  if (command === "setup") {
252
- const created = await runInit();
583
+ const jsonOutput = args.includes("--json");
584
+ if (args.includes("--rollback")) {
585
+ const result = await rollbackSetup(getRepoRoot(), { dryRun: args.includes("--dry-run") });
586
+ if (jsonOutput) console.log(JSON.stringify(result, null, 2));
587
+ else console.log(`${result.status}: ${result.removed.length} artifact(s) removed`);
588
+ return;
589
+ }
590
+ const report = await runInit({
591
+ refresh: args.includes("--refresh"),
592
+ obsidianVault: getOptionValue(args, "--obsidian-vault"),
593
+ });
594
+ if (
595
+ [...report.directories, ...report.files].some(
596
+ (entry) => entry.status === "warning" || entry.status === "warned" || entry.fatal === true,
597
+ )
598
+ ) {
599
+ process.exitCode = 1;
600
+ }
601
+ if (jsonOutput) {
602
+ console.log(JSON.stringify(report, null, 2));
603
+ return;
604
+ }
605
+
253
606
  console.log("meta-architect setup");
254
607
  console.log("====================");
255
- for (const item of created) {
256
- console.log(`ready: ${item}`);
608
+ for (const entry of [...report.directories, ...report.files]) {
609
+ const suffix = entry.warning ? `: ${entry.warning}` : "";
610
+ console.log(`${entry.status}: ${entry.path}${suffix}`);
611
+ }
612
+ for (const integration of report.integrations ?? []) {
613
+ console.log(`${integration.status}: ${integration.vaultPath}/${integration.notePath}`);
614
+ }
615
+ if (report.context) {
616
+ console.log(
617
+ `context: ${report.context.path} (${report.context.status}, ${report.context.completeness})`,
618
+ );
619
+ if (report.context.unknown.length > 0) {
620
+ console.log(`context unknown: ${report.context.unknown.join(", ")}`);
621
+ }
622
+ }
623
+ console.log("next: ma doctor | ma context refresh | ma setup --rollback");
624
+ return;
625
+ }
626
+
627
+ if (command === "welcome") {
628
+ const outcome = await runDoctor();
629
+ console.log("Meta-Architect welcome");
630
+ console.log("=======================");
631
+ console.log("Context: .ma/context/project-index.json");
632
+ console.log(
633
+ "Agents read: .ma/context/agent-brief.md, .ma/context/project-index.json, AGENTS.md",
634
+ );
635
+ console.log("Next: ma doctor | ma context refresh | ma setup --rollback");
636
+ process.exitCode = outcome.result === "BLOCKED" ? 1 : 0;
637
+ return;
638
+ }
639
+
640
+ if (command === "context" && rest[0] === "refresh") {
641
+ const result = await refreshProjectIndex(getRepoRoot(), {
642
+ mode: rest.includes("--full") ? "full" : "incremental",
643
+ });
644
+ const receipt = await fs.readFile(`${getRepoRoot()}/.ma/context/refresh-receipt.json`, "utf8");
645
+ if (rest.includes("--json")) console.log(receipt);
646
+ else {
647
+ console.log(`context refresh: ${result.freshness.status}`);
648
+ console.log(`changed: ${result.freshness.changedFiles.length}`);
649
+ console.log(`affected: ${JSON.parse(receipt).affectedArtifacts.join(", ") || "none"}`);
257
650
  }
258
651
  return;
259
652
  }
260
653
 
654
+ if (command === "uninstall") {
655
+ const result = await rollbackSetup(getRepoRoot());
656
+ console.log(JSON.stringify(result, null, 2));
657
+ return;
658
+ }
659
+
261
660
  if (command === "bootstrap") {
262
- const outcome = await runBootstrap({ initMcp: rest.includes("--init-mcp") });
661
+ const outcome = await runBootstrap({
662
+ initMcp: rest.includes("--init-mcp"),
663
+ json: rest.includes("--json"),
664
+ });
665
+ if (rest.includes("--json")) console.log(JSON.stringify(outcome, null, 2));
263
666
  process.exitCode = outcome.result === "BLOCKED" ? 1 : 0;
264
667
  return;
265
668
  }
266
669
 
267
670
  if (command === "doctor") {
268
- const outcome = await runDoctor();
671
+ const outcome = await runDoctor({ json: rest.includes("--json") });
672
+ if (rest.includes("--json")) console.log(JSON.stringify(outcome, null, 2));
269
673
  process.exitCode = outcome.result === "BLOCKED" ? 1 : 0;
270
674
  return;
271
675
  }
272
676
 
677
+ if (command === "migrate") {
678
+ const result = await migrateSchemas(getRepoRoot(), {
679
+ dryRun: rest.includes("--dry-run"),
680
+ rollback: rest.includes("--rollback"),
681
+ });
682
+ if (rest.includes("--json")) console.log(JSON.stringify(result, null, 2));
683
+ else
684
+ console.log(
685
+ `${result.status}: ${(result.migrated ?? result.restored ?? []).length} artifact(s)`,
686
+ );
687
+ process.exitCode = result.status === "failed" ? 1 : 0;
688
+ return;
689
+ }
690
+
273
691
  if (command === "init") {
274
- const created = await runInit();
692
+ const report = await runInit({
693
+ refresh: args.includes("--refresh"),
694
+ obsidianVault: getOptionValue(args, "--obsidian-vault"),
695
+ });
275
696
  console.log("meta-architect init");
276
697
  console.log("===================");
277
- for (const item of created) {
278
- console.log(`ready: ${item}`);
698
+ for (const entry of [...report.directories, ...report.files]) {
699
+ const suffix = entry.warning ? `: ${entry.warning}` : "";
700
+ console.log(`${entry.status}: ${entry.path}${suffix}`);
279
701
  }
280
702
  return;
281
703
  }
@@ -309,13 +731,14 @@ async function main() {
309
731
  return;
310
732
  }
311
733
 
734
+ if (command === "agent-compat") {
735
+ await runAgentCompatCommand(rest);
736
+ return;
737
+ }
738
+
312
739
  if (command === "obsidian-index") {
313
- const vaultPath = arg ?? process.env.MA_OBSIDIAN_VAULT;
314
- if (!vaultPath) {
315
- throw new Error("Obsidian vault path required: ma obsidian-index <vault-path>");
316
- }
317
740
  await runInit();
318
- const index = await writeObsidianVaultIndex({ vaultPath });
741
+ const index = await writeObsidianVaultIndex({ vaultPath: arg });
319
742
  console.log("Obsidian vault indexed");
320
743
  console.log(`Vault: ${index.vault_path}`);
321
744
  console.log(`Notes: ${index.note_count}`);
@@ -326,12 +749,17 @@ async function main() {
326
749
 
327
750
  if (command === "obsidian") {
328
751
  const [action, vaultPath, notePath, ...contentParts] = rest;
329
- if (!action || !vaultPath) {
752
+ if (!action) {
330
753
  throw new Error(
331
754
  "Usage: ma obsidian list|read|create|update|delete|plugin-install <vault-path> [note-path] [content]",
332
755
  );
333
756
  }
334
757
  await runInit();
758
+ if (action === "configure") {
759
+ const config = await configureObsidianVault(vaultPath);
760
+ console.log(`Obsidian vault configured: ${config.vaultPath}`);
761
+ return;
762
+ }
335
763
  if (action === "plugin-install") {
336
764
  const receipt = await installObsidianPlugin({ vaultPath });
337
765
  await appendObsidianOperationReceipt({
@@ -368,10 +796,21 @@ async function main() {
368
796
  return;
369
797
  }
370
798
  if (action === "create") {
799
+ const content = await readObsidianContent(rest, contentParts.join(" "));
800
+ if (rest.includes("--dry-run")) {
801
+ console.log(
802
+ JSON.stringify(
803
+ { schemaVersion: "0.1.0", status: "would_create", notePath, content },
804
+ null,
805
+ 2,
806
+ ),
807
+ );
808
+ return;
809
+ }
371
810
  const receipt = await createObsidianNote({
372
811
  vaultPath,
373
812
  notePath,
374
- content: contentParts.join(" "),
813
+ content,
375
814
  });
376
815
  await appendObsidianOperationReceipt(receipt);
377
816
  await writeObsidianVaultIndex({ vaultPath });
@@ -379,10 +818,27 @@ async function main() {
379
818
  return;
380
819
  }
381
820
  if (action === "update") {
821
+ const content = await readObsidianContent(rest, contentParts.join(" "));
822
+ if (rest.includes("--dry-run")) {
823
+ const existing = await readObsidianNote({ vaultPath, notePath });
824
+ console.log(
825
+ JSON.stringify(
826
+ {
827
+ schemaVersion: "0.1.0",
828
+ status: existing.content === content ? "unchanged" : "would_update",
829
+ notePath,
830
+ content,
831
+ },
832
+ null,
833
+ 2,
834
+ ),
835
+ );
836
+ return;
837
+ }
382
838
  const receipt = await updateObsidianNote({
383
839
  vaultPath,
384
840
  notePath,
385
- content: contentParts.join(" "),
841
+ content,
386
842
  });
387
843
  await appendObsidianOperationReceipt(receipt);
388
844
  await writeObsidianVaultIndex({ vaultPath });
@@ -406,9 +862,23 @@ async function main() {
406
862
 
407
863
  if (command === "status") {
408
864
  const releaseState = await loadReleaseState();
409
- await printStatus(releaseState);
410
- if (rest.includes("--maestro-view")) {
411
- await printMaestroView();
865
+ const json = rest.includes("--json");
866
+ const snapshot = rest.includes("--maestro-view") ? await loadRuntimeSnapshot() : null;
867
+ if (json && snapshot) {
868
+ const runtime = createRuntimeSummary(snapshot);
869
+ const evaluation = evaluateRuntimeBuildReadiness(releaseState, runtime);
870
+ const status = {
871
+ schemaVersion: "0.1.0",
872
+ scope: "status",
873
+ release: releaseState,
874
+ runtime,
875
+ nextTriggers: evaluation.nextTriggers,
876
+ maestro: createMaestroView(snapshot.maestroState),
877
+ };
878
+ process.stdout.write(`${JSON.stringify(status, null, 2)}\n`);
879
+ } else {
880
+ await printStatus(releaseState, { json });
881
+ if (snapshot) await printMaestroView({ snapshot });
412
882
  }
413
883
  return;
414
884
  }
@@ -425,15 +895,33 @@ async function main() {
425
895
  return;
426
896
  }
427
897
 
898
+ if (command === "verify" && rest.includes("--agents-live")) {
899
+ const report = await verifyLiveAgentMatrix({ cwd: process.cwd() });
900
+ if (rest.includes("--json")) {
901
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
902
+ } else {
903
+ console.log(`Agent live verification: ${report.target_count} targets`);
904
+ console.log(`Runtime verified: ${report.runtime_verified}`);
905
+ console.log(`Distribution only: ${report.distribution_only}`);
906
+ console.log(`Blocked: ${report.blocked}`);
907
+ for (const result of report.results) {
908
+ console.log(
909
+ `- ${result.target}: ${result.status}${result.reason ? ` (${result.reason})` : ""}`,
910
+ );
911
+ }
912
+ }
913
+ return;
914
+ }
915
+
428
916
  if (command === "merge") {
429
- const [sourceBranch, targetBranch] = rest;
430
- await runMerge(sourceBranch, targetBranch);
917
+ const [sourceBranch, targetBranch] = rest.filter((arg) => !arg.startsWith("--"));
918
+ await runMerge(sourceBranch, targetBranch, resolveGitMode(rest));
431
919
  return;
432
920
  }
433
921
 
434
922
  if (command === "release") {
435
- const [originBranch, targetBranch] = rest;
436
- await runRelease(originBranch, targetBranch);
923
+ const [originBranch, targetBranch] = rest.filter((arg) => !arg.startsWith("--"));
924
+ await runRelease(originBranch, targetBranch, resolveGitMode(rest));
437
925
  return;
438
926
  }
439
927