@omacode/micromanager 0.0.0-stage → 1.0.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 (146) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +30 -2
  3. package/THIRD_PARTY.md +100 -0
  4. package/decider/.python-version +1 -0
  5. package/decider/README.md +35 -0
  6. package/decider/decider/__init__.py +1 -0
  7. package/decider/decider/server.py +327 -0
  8. package/decider/pyproject.toml +34 -0
  9. package/decider/uv.lock +1255 -0
  10. package/dist/agenda.js +51 -0
  11. package/dist/agents.js +58 -0
  12. package/dist/artifact/handoff.js +281 -0
  13. package/dist/ask.js +200 -0
  14. package/dist/backends.js +219 -0
  15. package/dist/backlog.js +414 -0
  16. package/dist/bench.js +427 -0
  17. package/dist/board.js +1 -0
  18. package/dist/brief.js +202 -0
  19. package/dist/browser.js +679 -0
  20. package/dist/budget.js +61 -0
  21. package/dist/catalog.js +187 -0
  22. package/dist/checkchange.js +145 -0
  23. package/dist/checkpoint.js +94 -0
  24. package/dist/cli.js +764 -0
  25. package/dist/comfy-gate.js +258 -0
  26. package/dist/compact.js +142 -0
  27. package/dist/config.js +344 -0
  28. package/dist/context/capture.js +1 -0
  29. package/dist/context/digest.js +1 -0
  30. package/dist/context/embed.js +1 -0
  31. package/dist/context/index.js +2 -0
  32. package/dist/context/ledger.js +1 -0
  33. package/dist/context/manager.js +1 -0
  34. package/dist/context/memory.js +1 -0
  35. package/dist/context/policy.js +1 -0
  36. package/dist/context/prices.js +1 -0
  37. package/dist/context/recall.js +1 -0
  38. package/dist/context/rules.js +1 -0
  39. package/dist/context/search.js +1 -0
  40. package/dist/context/status.js +1 -0
  41. package/dist/context/store.js +1 -0
  42. package/dist/context/summary.js +1 -0
  43. package/dist/context/tokens.js +1 -0
  44. package/dist/context/tools.js +1 -0
  45. package/dist/continuation.js +184 -0
  46. package/dist/contract.js +294 -0
  47. package/dist/contractround.js +178 -0
  48. package/dist/control.js +1 -0
  49. package/dist/creative-tools.js +237 -0
  50. package/dist/dataset.js +175 -0
  51. package/dist/decide.js +676 -0
  52. package/dist/decider.js +171 -0
  53. package/dist/design-shell.js +448 -0
  54. package/dist/design.js +1410 -0
  55. package/dist/desktop.js +44 -0
  56. package/dist/egress.js +156 -0
  57. package/dist/eval.js +60 -0
  58. package/dist/evolver.js +302 -0
  59. package/dist/features.js +193 -0
  60. package/dist/followups.js +32 -0
  61. package/dist/forms.js +195 -0
  62. package/dist/gate.js +108 -0
  63. package/dist/gatebox.js +46 -0
  64. package/dist/grants.js +189 -0
  65. package/dist/graph.js +65 -0
  66. package/dist/guard/index.js +1 -0
  67. package/dist/guard/wire.js +1 -0
  68. package/dist/helpers.js +85 -0
  69. package/dist/hooks.js +158 -0
  70. package/dist/image-models.js +117 -0
  71. package/dist/integration.js +3 -0
  72. package/dist/journal.js +1 -0
  73. package/dist/look.js +363 -0
  74. package/dist/memory.js +1 -0
  75. package/dist/mode.js +97 -0
  76. package/dist/native.js +3348 -0
  77. package/dist/nogit.js +259 -0
  78. package/dist/outcomes.js +148 -0
  79. package/dist/permission.js +35 -0
  80. package/dist/pick.js +89 -0
  81. package/dist/pipelines.js +262 -0
  82. package/dist/plan.js +641 -0
  83. package/dist/plandoc.js +211 -0
  84. package/dist/plugin.js +4736 -0
  85. package/dist/policy.js +58 -0
  86. package/dist/pools.js +1 -0
  87. package/dist/preview.js +274 -0
  88. package/dist/profile.js +165 -0
  89. package/dist/progress.js +1 -0
  90. package/dist/promote.js +313 -0
  91. package/dist/redact.js +1 -0
  92. package/dist/registry.js +179 -0
  93. package/dist/riskscore.js +126 -0
  94. package/dist/roles.js +1 -0
  95. package/dist/routing.js +1 -0
  96. package/dist/runner.js +1892 -0
  97. package/dist/sandbox.js +3 -0
  98. package/dist/sandboxgate.js +90 -0
  99. package/dist/scheduler.js +170 -0
  100. package/dist/services-main.js +131 -0
  101. package/dist/services.js +265 -0
  102. package/dist/session.js +241 -0
  103. package/dist/setup.js +423 -0
  104. package/dist/shell/decide.js +1 -0
  105. package/dist/shell/index.js +2 -0
  106. package/dist/shell/sandbox.js +1 -0
  107. package/dist/shell/wire.js +1 -0
  108. package/dist/skills.js +103 -0
  109. package/dist/state.js +1 -0
  110. package/dist/store.js +1 -0
  111. package/dist/switcher.js +1 -0
  112. package/dist/synth.js +418 -0
  113. package/dist/tools.js +477 -0
  114. package/dist/trials.js +223 -0
  115. package/dist/usage.js +1 -0
  116. package/dist/wait.js +167 -0
  117. package/dist/watchdog.js +476 -0
  118. package/dist/web-guidance.js +43 -0
  119. package/dist/which.js +20 -0
  120. package/dist/worktree/git.js +545 -0
  121. package/dist/writeguard.js +311 -0
  122. package/evolver/mm_evolve/__init__.py +1 -0
  123. package/evolver/mm_evolve/entry.py +3 -0
  124. package/evolver/mm_evolve/evaluator.py +119 -0
  125. package/evolver/mm_evolve/llm.py +76 -0
  126. package/evolver/mm_evolve/run.py +89 -0
  127. package/evolver/mm_evolve/spec.py +62 -0
  128. package/evolver/pyproject.toml +21 -0
  129. package/evolver/uv.lock +772 -0
  130. package/package.json +74 -4
  131. package/skills/THIRD_PARTY.md +58 -0
  132. package/skills/code-review/SKILL.md +46 -0
  133. package/skills/deck/SKILL.md +98 -0
  134. package/skills/deliberate/SKILL.md +39 -0
  135. package/skills/design/SKILL.md +150 -0
  136. package/skills/diagnosing-bugs/SKILL.md +75 -0
  137. package/skills/image/SKILL.md +66 -0
  138. package/skills/orchestrator/SKILL.md +107 -0
  139. package/skills/receiving-code-review/SKILL.md +36 -0
  140. package/skills/research/SKILL.md +18 -0
  141. package/skills/tdd/SKILL.md +56 -0
  142. package/skills/tdd/mocking.md +59 -0
  143. package/skills/tdd/tests.md +77 -0
  144. package/skills/verification-before-completion/SKILL.md +50 -0
  145. package/skills/video/SKILL.md +97 -0
  146. package/skills/web/SKILL.md +60 -0
package/dist/setup.js ADDED
@@ -0,0 +1,423 @@
1
+ // The host install around the plugin (roadmap A6, slimmed for 1.0): a preflight before anything is written, the
2
+ // profiles install.sh offers, `doctor` for a machine that already has omacode, and the uninstall plan. install.sh is the
3
+ // front door and only calls these through the CLI, so every decision here is plain data a test can read.
4
+ //
5
+ // omacode preflight what this machine has and lacks, before an install
6
+ // omacode setup <profile> install what a profile names (services, creative tools); `setup ask` asks which
7
+ // omacode doctor the installed state, each finding with its fix
8
+ // omacode uninstall [--purge] [--dry-run] remove what the install made, and say what stays
9
+ //
10
+ // Nothing here downloads on its own: a profile says what it would fetch and how large it is before it runs.
11
+ import { existsSync, lstatSync, readFileSync, readlinkSync, statfsSync } from "node:fs";
12
+ import { totalmem } from "node:os";
13
+ import { join } from "node:path";
14
+ import { findChromium } from "@omacode/core/chromium";
15
+ import { stripComments } from "@omacode/core/jsonc";
16
+ import { configFilePath, userConfigDir, userDataDir, userStateDir } from "@omacode/core/paths";
17
+ import { TELEMETRY_OFF } from "@omacode/core/telemetry";
18
+ import { comfyMcpConfigured } from "./comfy-gate.js";
19
+ import { PINS, TOOL_INFO } from "./creative-tools.js";
20
+ export function realProbe(run, env = process.env) {
21
+ return {
22
+ platform: process.platform,
23
+ arch: process.arch,
24
+ node: process.versions.node,
25
+ totalMem: totalmem(),
26
+ env,
27
+ run,
28
+ freeBytes(dir) {
29
+ try {
30
+ const s = statfsSync(dir);
31
+ return s.bavail * s.bsize;
32
+ }
33
+ catch {
34
+ return undefined;
35
+ }
36
+ },
37
+ which(name) {
38
+ for (const d of (env["PATH"] ?? "").split(":").filter(Boolean)) {
39
+ const file = join(d, name);
40
+ try {
41
+ if (lstatSync(file))
42
+ return file;
43
+ }
44
+ catch {
45
+ // not here
46
+ }
47
+ }
48
+ return undefined;
49
+ },
50
+ };
51
+ }
52
+ // The Node the plugin's packages declare (engines), and the OpenCode it is tested against.
53
+ export const MIN_NODE = "22.18.0";
54
+ export const TESTED_OPENCODE = "2.2.5";
55
+ const GB = 1024 ** 3;
56
+ const newer = (a, b) => {
57
+ const pa = a.split(/[.-]/).map(Number);
58
+ const pb = b.split(/[.-]/).map(Number);
59
+ for (let i = 0; i < 3; i++)
60
+ if ((pa[i] ?? 0) !== (pb[i] ?? 0))
61
+ return (pa[i] ?? 0) - (pb[i] ?? 0);
62
+ return 0;
63
+ };
64
+ const versionOf = async (p, cmd, args) => {
65
+ const r = await p.run(cmd, args, { cwd: p.env["HOME"] ?? "/", timeoutMs: 20_000 }).catch(() => undefined);
66
+ return r && r.code === 0 ? /\bv?(\d+\.\d+(?:\.\d+)?)/.exec(`${r.stdout}\n${r.stderr}`)?.[1] : undefined;
67
+ };
68
+ // What the machine has before an install. A "fail" stops install.sh; a "warn" names what will not work.
69
+ export async function preflight(p) {
70
+ const out = [];
71
+ if (p.platform === "linux")
72
+ out.push({ area: "system", level: "ok", text: `Linux ${p.arch}` });
73
+ else if (p.platform === "darwin")
74
+ out.push({ area: "system", level: "warn", text: `macOS ${p.arch}: the plugin and the services run; the sandbox for plan mode and the artifact runner need Linux (bubblewrap)` });
75
+ else
76
+ out.push({ area: "system", level: "fail", text: `${p.platform} is not supported (Linux, or macOS with limits)` });
77
+ out.push(newer(p.node, MIN_NODE) >= 0
78
+ ? { area: "node", level: "ok", text: `Node ${p.node}` }
79
+ : { area: "node", level: "fail", text: `Node ${p.node} is older than ${MIN_NODE}`, fix: `install Node ${MIN_NODE} or newer` });
80
+ const oc = await versionOf(p, "opencode", ["--version"]);
81
+ if (!oc)
82
+ out.push({ area: "opencode", level: "fail", text: "OpenCode is not installed", fix: "install it: https://opencode.ai" });
83
+ else if (Number(oc.split(".")[0]) < 2)
84
+ out.push({ area: "opencode", level: "fail", text: `OpenCode ${oc} is OpenCode 1, which cannot load omacode (a plugin for OpenCode 2)`, fix: `install OpenCode 2: curl -fsSL https://opencode.ai/v2/install | bash -s -- --version ${TESTED_OPENCODE}` });
85
+ else if (newer(oc, TESTED_OPENCODE) < 0)
86
+ out.push({ area: "opencode", level: "warn", text: `OpenCode ${oc} is older than ${TESTED_OPENCODE}, the version omacode is tested with`, fix: "opencode upgrade" });
87
+ else
88
+ out.push({ area: "opencode", level: "ok", text: `OpenCode ${oc}` });
89
+ const tools = [
90
+ { name: "git", area: "git", why: "micromanager jobs work in git worktrees", level: "warn" },
91
+ { name: "uv", area: "uv", why: "the decider service, ComfyUI, Manim and comfy-mcp are installed with it", level: "warn" },
92
+ { name: "ffmpeg", area: "ffmpeg", why: "videos are encoded with it", level: "info" },
93
+ ];
94
+ if (p.platform === "linux")
95
+ tools.push({ name: "bwrap", area: "bwrap", why: "plan mode's sandbox and the artifact runner use bubblewrap", level: "warn" });
96
+ for (const t of tools) {
97
+ const where = p.which(t.name);
98
+ out.push(where ? { area: t.area, level: "ok", text: `${t.name} found` } : { area: t.area, level: t.level, text: `${t.name} not found: ${t.why}`, fix: `install ${t.name === "bwrap" ? "bubblewrap" : t.name}` });
99
+ }
100
+ const chromium = findChromium(p.env);
101
+ out.push(chromium ? { area: "browser", level: "ok", text: `Chromium found (${chromium})` } : { area: "browser", level: "warn", text: "no Chromium: the deck and site checks that open a browser are skipped", fix: "install chromium" });
102
+ const ram = p.totalMem / GB;
103
+ out.push(ram >= 8 ? { area: "memory", level: "ok", text: `${ram.toFixed(0)} GB RAM` } : { area: "memory", level: "warn", text: `${ram.toFixed(1)} GB RAM: the local services want about 4 GB free` });
104
+ const free = p.freeBytes(existsSync(userDataDir()) ? userDataDir() : (p.env["HOME"] ?? "/"));
105
+ if (free !== undefined)
106
+ out.push(free >= 5 * GB ? { area: "disk", level: "ok", text: `${(free / GB).toFixed(0)} GB free` } : { area: "disk", level: "warn", text: `${(free / GB).toFixed(1)} GB free: the Coding profile needs about 3 GB, Creator about 10 GB` });
107
+ return out;
108
+ }
109
+ // The package of each need per package manager. A need a manager does not carry is installed another way (uv) or
110
+ // named for the user to install (Node on apt, whose nodejs is older than the plugin needs).
111
+ export const PACKAGES = {
112
+ pacman: { git: "git", bubblewrap: "bubblewrap", chromium: "chromium", ffmpeg: "ffmpeg", uv: "uv", node: "nodejs npm", "cairo-build": "cairo pango pkgconf gcc" },
113
+ apt: { git: "git", bubblewrap: "bubblewrap", chromium: "chromium", ffmpeg: "ffmpeg", "cairo-build": "libcairo2-dev libpango1.0-dev pkg-config build-essential" },
114
+ dnf: { git: "git", bubblewrap: "bubblewrap", chromium: "chromium", ffmpeg: "ffmpeg-free", uv: "uv", node: "nodejs", "cairo-build": "cairo-devel pango-devel pkgconf gcc" },
115
+ brew: { git: "git", ffmpeg: "ffmpeg", uv: "uv", node: "node", "cairo-build": "cairo pango pkgconf" },
116
+ };
117
+ // uv's own installer where the package manager has no uv, pinned to a release older than two weeks (2026-10-20).
118
+ export const UV_PIN = "0.13.4";
119
+ export function packageManager(p) {
120
+ if (p.platform === "darwin")
121
+ return p.which("brew") ? "brew" : undefined;
122
+ if (p.which("pacman"))
123
+ return "pacman";
124
+ if (p.which("apt-get"))
125
+ return "apt";
126
+ if (p.which("dnf"))
127
+ return "dnf";
128
+ return undefined;
129
+ }
130
+ // The commands that install system needs, and what is left for the user to install by hand.
131
+ export function systemInstall(manager, needs, root = process.getuid?.() === 0,
132
+ // pacman's database never synced (a fresh container): -Syu, since a bare -Sy would be a partial upgrade
133
+ unsynced = !existsSync("/var/lib/pacman/sync/core.db")) {
134
+ const commands = [];
135
+ const manual = [];
136
+ const packages = [];
137
+ for (const need of [...new Set(needs)]) {
138
+ const pkg = manager ? PACKAGES[manager][need] : undefined;
139
+ if (pkg)
140
+ packages.push(...pkg.split(" "));
141
+ else if (need === "uv")
142
+ commands.push({ say: `uv ${UV_PIN} with its own installer (astral.sh)`, cmd: "sh", args: ["-c", `curl -LsSf https://astral.sh/uv/${UV_PIN}/install.sh | sh`] });
143
+ else if (need === "node")
144
+ manual.push("Node 22.18 or newer: https://nodejs.org (your package manager's is older)");
145
+ else
146
+ manual.push(`${need}: install it with your package manager`);
147
+ }
148
+ if (packages.length) {
149
+ // root (a bare container) has no sudo and needs none
150
+ const sudo = (cmd, args) => ({ say: `${manager}: ${packages.join(" ")}`, ...(root ? { cmd, args } : { cmd: "sudo", args: [cmd, ...args] }) });
151
+ if (manager === "pacman")
152
+ commands.unshift(sudo("pacman", [unsynced ? "-Syu" : "-S", "--needed", "--noconfirm", ...packages]));
153
+ else if (manager === "apt")
154
+ commands.unshift(sudo("apt-get", ["install", "-y", ...packages]));
155
+ else if (manager === "dnf")
156
+ commands.unshift(sudo("dnf", ["install", "-y", ...packages]));
157
+ else if (manager === "brew")
158
+ commands.unshift({ say: `brew: ${packages.join(" ")}`, cmd: "brew", args: ["install", ...packages] });
159
+ }
160
+ return { commands, manual };
161
+ }
162
+ // OpenCode 2 has its own installer: opencode.ai/install installs OpenCode 1 only, which cannot load omacode (it is a v2
163
+ // plugin). Pinned to the version omacode is tested with; it replaces an OpenCode 1 in ~/.opencode/bin.
164
+ export const OPENCODE_INSTALL = { say: `OpenCode ${TESTED_OPENCODE} with its own installer (opencode.ai/v2)`, cmd: "sh", args: ["-c", `curl -fsSL https://opencode.ai/v2/install | bash -s -- --version ${TESTED_OPENCODE}`] };
165
+ // What the plugin cannot run without (Node is checked by install.sh itself, before any of this runs).
166
+ export function requiredNeeds(p) {
167
+ const needs = [];
168
+ if (!p.which("git"))
169
+ needs.push("git");
170
+ if (p.platform === "linux" && !p.which("bwrap"))
171
+ needs.push("bubblewrap");
172
+ return needs;
173
+ }
174
+ export const OFFER_IDS = ["services", "chromium", "ffmpeg", "hyperframes", "comfyui", "comfy-mcp", "manim", "web-guidance"];
175
+ export const OFFERS = {
176
+ services: { title: "Local services", what: "a decider on this machine answers the guards' questions, and memory searches by meaning (omacode-services)", size: "about 2 GB now, the models on first use", licence: "Apache-2.0 (decider and models)", needsUv: true },
177
+ chromium: { title: "Chromium", what: "the deck and site checks open the result in a real browser", size: "about 300 MB", licence: "BSD-3-Clause and others", system: "chromium" },
178
+ ffmpeg: { title: "ffmpeg", what: "videos are encoded with it", size: "about 100 MB", licence: "LGPL-2.1-or-later or GPL, by build", system: "ffmpeg" },
179
+ hyperframes: { title: TOOL_INFO.hyperframes.title, what: TOOL_INFO.hyperframes.what, size: TOOL_INFO.hyperframes.size, licence: "Apache-2.0", tool: "hyperframes" },
180
+ comfyui: { title: TOOL_INFO.comfyui.title, what: TOOL_INFO.comfyui.what, size: TOOL_INFO.comfyui.size, licence: "GPL-3.0-only", tool: "comfyui", needsUv: true },
181
+ "comfy-mcp": { title: TOOL_INFO["comfy-mcp"].title, what: TOOL_INFO["comfy-mcp"].what, size: TOOL_INFO["comfy-mcp"].size, licence: "AGPL-3.0-or-later OR LicenseRef-Comfy-Commercial", tool: "comfy-mcp", needsUv: true, after: "comfyui" },
182
+ manim: { title: TOOL_INFO.manim.title, what: TOOL_INFO.manim.what, size: TOOL_INFO.manim.size, licence: "MIT", tool: "manim", needsUv: true, buildNeeds: "cairo-build" },
183
+ "web-guidance": { title: TOOL_INFO["web-guidance"].title, what: TOOL_INFO["web-guidance"].what, size: TOOL_INFO["web-guidance"].size, licence: "Apache-2.0", tool: "web-guidance" },
184
+ };
185
+ export function isPresent(id, there) {
186
+ const offer = OFFERS[id];
187
+ if (id === "services")
188
+ return there.services;
189
+ if (id === "chromium")
190
+ return there.chromium;
191
+ if (offer.system)
192
+ return Boolean(there.which(offer.system));
193
+ return there.tools.some((t) => t.name === offer.tool && t.found);
194
+ }
195
+ // The answers turned into what to install: parts already there are dropped, a part offered only after another one is
196
+ // dropped without it, and uv is added when a chosen part needs it and it is missing.
197
+ export function planFor(chosen, there) {
198
+ const wanted = OFFER_IDS.filter((id) => chosen.includes(id) && !isPresent(id, there));
199
+ const kept = wanted.filter((id) => {
200
+ const after = OFFERS[id].after;
201
+ return !after || isPresent(after, there) || wanted.includes(after);
202
+ });
203
+ const system = kept.map((id) => OFFERS[id].system).filter((x) => Boolean(x));
204
+ if (kept.some((id) => OFFERS[id].needsUv) && !there.which("uv"))
205
+ system.unshift("uv");
206
+ for (const id of kept) {
207
+ const need = OFFERS[id].buildNeeds;
208
+ if (need && !there.which("pkg-config") && !system.includes(need))
209
+ system.push(need);
210
+ }
211
+ return {
212
+ system,
213
+ services: kept.includes("services"),
214
+ tools: kept.map((id) => OFFERS[id].tool).filter((x) => Boolean(x)),
215
+ };
216
+ }
217
+ // What an artifact kind cannot be made without, found on PATH only (fast, before a build). A deck and a video are made by
218
+ // HyperFrames; a video is also encoded with ffmpeg. Sites and images have fallbacks (a skipped browser check, the cloud
219
+ // image tool), so they are not blocked here.
220
+ export const NEEDS_BY_KIND = { deck: ["hyperframes"], video: ["hyperframes", "ffmpeg"] };
221
+ export function missingForKind(kind, which) {
222
+ return (NEEDS_BY_KIND[kind] ?? []).filter((id) => !which(OFFERS[id].system ?? OFFERS[id].tool ?? id));
223
+ }
224
+ // What the agent is told when a part is missing: ask the user, then install_feature for a part in user space; the
225
+ // terminal command for a system package, which needs sudo.
226
+ export function missingNote(what, missing) {
227
+ const lines = missing.map((id) => {
228
+ const o = OFFERS[id];
229
+ return o.system
230
+ ? `- ${o.title} (${o.what}) is a system package: ask the user to run ./install.sh --with ${id} in a terminal (it needs sudo), then build again.`
231
+ : `- ${o.title} (${o.what}; ${o.size}): ask the user whether to install it; if yes, call install_feature with part "${id}", then build again.`;
232
+ });
233
+ return [`${what} cannot be made yet; missing:`, ...lines].join("\n");
234
+ }
235
+ // Profiles: the same answers given up front (install.sh --profile).
236
+ export const PROFILE_IDS = ["minimal", "coding", "creator", "full"];
237
+ export const PROFILES = {
238
+ minimal: { title: "Minimal", offers: [], download: "nothing" },
239
+ coding: { title: "Coding", offers: ["services"], download: "about 2 GB, models on first use" },
240
+ creator: { title: "Creator", offers: ["services", "chromium", "ffmpeg", "hyperframes", "comfyui", "comfy-mcp", "web-guidance"], download: "about 8–12 GB" },
241
+ full: { title: "Full", offers: ["services", "chromium", "ffmpeg", "hyperframes", "comfyui", "comfy-mcp", "web-guidance", "manim"], download: "about 8–12 GB" },
242
+ };
243
+ export function paths(unit, opencodeDir = userConfigDir()) {
244
+ return {
245
+ opencodeDir,
246
+ pluginLink: join(opencodeDir, "plugins", "omacode.ts"),
247
+ tuiDir: join(opencodeDir, "omacode-tui"),
248
+ cliJson: join(opencodeDir, "cli.json"),
249
+ opencodeJson: join(opencodeDir, "opencode.json"),
250
+ config: configFilePath(opencodeDir),
251
+ data: userDataDir(),
252
+ state: userStateDir(),
253
+ unit,
254
+ };
255
+ }
256
+ const readJson = (file) => {
257
+ try {
258
+ return JSON.parse(stripComments(readFileSync(file, "utf8")));
259
+ }
260
+ catch {
261
+ return undefined;
262
+ }
263
+ };
264
+ const pluginEntries = (config) => {
265
+ const list = config?.["plugins"] ?? config?.["plugin"];
266
+ return Array.isArray(list) ? list.filter((x) => typeof x === "string") : [];
267
+ };
268
+ export function pluginChecks(at) {
269
+ const out = [];
270
+ let linked;
271
+ try {
272
+ if (lstatSync(at.pluginLink).isSymbolicLink())
273
+ linked = readlinkSync(at.pluginLink);
274
+ }
275
+ catch {
276
+ linked = undefined;
277
+ }
278
+ const packages = pluginEntries(readJson(at.opencodeJson)).filter((p) => /omacode|micromanager/i.test(p));
279
+ if (linked !== undefined) {
280
+ out.push(existsSync(at.pluginLink)
281
+ ? { area: "plugin", level: "ok", text: `linked from a checkout: ${linked}` }
282
+ : { area: "plugin", level: "fail", text: `${at.pluginLink} points at ${linked}, which is gone`, fix: "run ./install.sh in the checkout again, or ./install.sh --remove" });
283
+ }
284
+ for (const p of packages) {
285
+ out.push(linked !== undefined
286
+ ? { area: "plugin", level: "info", text: `also listed in opencode.json: ${p} (each part registers once, so this is harmless)` }
287
+ : { area: "plugin", level: "ok", text: `installed as a package: ${p}` });
288
+ }
289
+ if (linked === undefined && packages.length === 0)
290
+ out.push({ area: "plugin", level: "fail", text: "the plugin is not installed", fix: "./install.sh in a checkout, or: opencode plugin add @omacode/full" });
291
+ const tui = pluginEntries(readJson(at.cliJson)).includes(at.tuiDir) && existsSync(join(at.tuiDir, "tui.tsx"));
292
+ // From npm, @omacode/full brings the TUI itself: OpenCode loads its ./tui export beside the server plugin.
293
+ const full = packages.find((p) => /(^|[/@])omacode[/-]full$|\/full$/.test(p.replace(/@[\d.]+(-[\w.]+)?$/, "")));
294
+ out.push(tui
295
+ ? { area: "tui", level: "ok", text: "the TUI package is installed" }
296
+ : full
297
+ ? { area: "tui", level: "ok", text: `the TUI comes with ${full}` }
298
+ : { area: "tui", level: "warn", text: "the TUI is not installed: no progress line, sidebar sections or /setup", fix: "opencode plugin add @omacode/full, or ./install.sh in a checkout" });
299
+ const raw = existsSync(at.config) ? readFileSync(at.config, "utf8") : undefined;
300
+ if (raw === undefined)
301
+ out.push({ area: "config", level: "info", text: `no ${at.config}: the defaults apply` });
302
+ else {
303
+ try {
304
+ JSON.parse(stripComments(raw));
305
+ out.push({ area: "config", level: "ok", text: `${at.config} reads` });
306
+ }
307
+ catch (err) {
308
+ out.push({ area: "config", level: "fail", text: `${at.config} does not parse: ${err instanceof Error ? err.message : String(err)}`, fix: "fix the file; until then the plugin runs on its defaults" });
309
+ }
310
+ }
311
+ return out;
312
+ }
313
+ export function toolChecks(found, opencodeJson) {
314
+ const pin = { hyperframes: PINS.hyperframes, manim: PINS.manim, comfyui: PINS.comfyui, "comfy-mcp": PINS.comfyMcp, "web-guidance": PINS.webGuidance };
315
+ const out = [];
316
+ for (const f of found) {
317
+ const title = TOOL_INFO[f.name].title;
318
+ if (!f.found) {
319
+ out.push({ area: f.name, level: "info", text: `${title} not installed: ${TOOL_INFO[f.name].what}`, fix: `./install.sh --with ${f.name}` });
320
+ continue;
321
+ }
322
+ const want = pin[f.name];
323
+ out.push(want && f.version && f.version !== want
324
+ ? { area: f.name, level: "warn", text: `${title} ${f.version}; omacode is tested with ${want}`, fix: `./install.sh --with ${f.name}` }
325
+ : { area: f.name, level: "ok", text: `${title} ${f.version ?? ""}${f.where ? ` in ${f.where}` : ""}`.trim() });
326
+ }
327
+ const mcp = found.find((f) => f.name === "comfy-mcp");
328
+ if (mcp?.found && !comfyMcpConfigured(readJson(opencodeJson))) {
329
+ out.push({ area: "comfy-mcp", level: "warn", text: "comfy-mcp is installed but OpenCode does not start it", fix: "./install.sh --with comfy-mcp adds it to opencode.json" });
330
+ }
331
+ return out;
332
+ }
333
+ // The services unit and the sandbox, asked of the machine.
334
+ export async function machineChecks(p, at) {
335
+ const out = [];
336
+ const cwd = p.env["HOME"] ?? "/";
337
+ if (!existsSync(at.unit)) {
338
+ out.push({ area: "services", level: "info", text: "omacode-services is not installed: questions go to you (or a cloud decider), memory searches by keywords", fix: "npm run services -- install" });
339
+ }
340
+ else if (p.platform === "linux") {
341
+ const active = await p.run("systemctl", ["--user", "is-active", "omacode-services.service"], { cwd }).catch(() => undefined);
342
+ out.push(active?.stdout.trim() === "active"
343
+ ? { area: "services", level: "ok", text: "omacode-services runs (/services in the TUI switches each service)" }
344
+ : { area: "services", level: "warn", text: `omacode-services is installed but ${active?.stdout.trim() || "not running"}`, fix: "systemctl --user restart omacode-services; journalctl --user -u omacode-services says why it stopped" });
345
+ }
346
+ else {
347
+ out.push({ area: "services", level: "ok", text: `omacode-services is installed (${at.unit})` });
348
+ }
349
+ if (p.platform === "linux" && !p.which("bwrap")) {
350
+ out.push({ area: "sandbox", level: "fail", text: "bubblewrap is not installed: plan mode falls back to asking, and decks, videos and sites cannot be built", fix: "omacode setup required (installs it with your package manager)" });
351
+ }
352
+ else if (p.platform === "linux") {
353
+ const box = await p.run("bwrap", ["--ro-bind", "/", "/", "--dev", "/dev", "true"], { cwd, timeoutMs: 15_000 }).catch(() => undefined);
354
+ out.push(box?.code === 0
355
+ ? { area: "sandbox", level: "ok", text: "bubblewrap runs: plan mode and the artifact runner can sandbox" }
356
+ : { area: "sandbox", level: "fail", text: `bubblewrap does not run here${box?.stderr ? `: ${box.stderr.trim().slice(0, 200)}` : ""}; plan mode falls back to asking`, fix: "install bubblewrap and allow unprivileged user namespaces" });
357
+ }
358
+ const hf = p.which("hyperframes");
359
+ if (hf) {
360
+ const doc = await p.run("hyperframes", ["doctor"], { cwd, timeoutMs: 60_000, env: TELEMETRY_OFF }).catch(() => undefined);
361
+ // Only the checks a deck or a video needs. The rest of HyperFrames' doctor is optional (a transcriber, a local
362
+ // voice, music, Docker for `render --docker`) or a newer release, which omacode does not want: it pins the version
363
+ // it is tested with. Its exit code counts those too, so the lines are read instead.
364
+ const tail = (doc ? `${doc.stdout}\n${doc.stderr}` : "").replace(/\x1b\[[0-9;]*m/g, "").split("\n").map((l) => l.trim())
365
+ .filter((l) => /^✗\s*(CLI binary|Node\.js|Memory|Disk|Frames cache|\/dev\/shm|FFmpeg|FFprobe|Chrome)\b/.test(l))
366
+ .slice(0, 4);
367
+ out.push(doc && tail.length === 0
368
+ ? { area: "hyperframes", level: "ok", text: "hyperframes doctor: everything decks and videos need is there" }
369
+ : { area: "hyperframes", level: "warn", text: `hyperframes doctor: ${tail.join("; ") || `exited with ${doc?.code ?? "no answer"}`}`, fix: "hyperframes doctor (optional extras such as a transcriber are not needed for decks)" });
370
+ }
371
+ return out;
372
+ }
373
+ export function uninstallPlan(at, o = {}) {
374
+ const remove = [];
375
+ const keep = [];
376
+ const exists = (p) => {
377
+ try {
378
+ lstatSync(p);
379
+ return true;
380
+ }
381
+ catch {
382
+ return false;
383
+ }
384
+ };
385
+ if (exists(at.pluginLink))
386
+ remove.push({ path: at.pluginLink, what: "the plugin link" });
387
+ if (exists(at.tuiDir))
388
+ remove.push({ path: at.tuiDir, what: "the TUI package (and its entry in cli.json)" });
389
+ if (exists(at.unit))
390
+ remove.push({ path: at.unit, what: "the omacode-services unit (stopped first)" });
391
+ const tools = join(at.data, "tools");
392
+ const services = join(at.data, "services");
393
+ if (o.purge) {
394
+ if (exists(tools))
395
+ remove.push({ path: tools, what: "the creative tools omacode installed (HyperFrames, ComfyUI)" });
396
+ if (exists(services))
397
+ remove.push({ path: services, what: "the services' decider, settings and downloaded models" });
398
+ }
399
+ else {
400
+ if (exists(tools))
401
+ keep.push({ path: tools, what: "the creative tools (HyperFrames, ComfyUI); --purge removes them" });
402
+ if (exists(services))
403
+ keep.push({ path: services, what: "the services' decider and downloaded models; --purge removes them" });
404
+ }
405
+ if (exists(at.state))
406
+ keep.push({ path: at.state, what: "journal, memory and model registry: your data, never removed here" });
407
+ if (exists(at.config))
408
+ keep.push({ path: at.config, what: "your settings" });
409
+ for (const p of pluginEntries(readJson(at.opencodeJson)).filter((x) => /omacode|micromanager/i.test(x))) {
410
+ keep.push({ path: at.opencodeJson, what: `the plugin entry ${p}; opencode plugin remove takes it out` });
411
+ }
412
+ if (comfyMcpConfigured(readJson(at.opencodeJson)))
413
+ keep.push({ path: at.opencodeJson, what: "the comfy MCP server entry; remove mcp.servers.comfy by hand if you want it gone" });
414
+ keep.push({ path: "uv tool list", what: "comfy-cli, comfy-mcp and Manim as uv tools: uv tool uninstall <name>" });
415
+ return { remove, keep };
416
+ }
417
+ // ---------------------------------------------------------------------------------------------------------------------
418
+ const MARK = { ok: "✓", warn: "!", fail: "✗", info: "·" };
419
+ export function formatChecks(checks) {
420
+ const width = Math.max(...checks.map((c) => c.area.length), 4);
421
+ return checks.map((c) => `${MARK[c.level]} ${c.area.padEnd(width)} ${c.text}${c.fix ? `\n ${" ".repeat(width)} → ${c.fix}` : ""}`).join("\n");
422
+ }
423
+ export const failed = (checks) => checks.some((c) => c.level === "fail");
@@ -0,0 +1 @@
1
+ export * from "@omacode/sandbox/decide";
@@ -0,0 +1,2 @@
1
+ export { default } from "@omacode/sandbox";
2
+ export * from "@omacode/sandbox";
@@ -0,0 +1 @@
1
+ export * from "@omacode/sandbox/sandbox";
@@ -0,0 +1 @@
1
+ export * from "@omacode/sandbox/wire";
package/dist/skills.js ADDED
@@ -0,0 +1,103 @@
1
+ // The leaf skills workers load (design.md §13.1): adapted copies in skills/. Workflow logic stays in the plugin; a
2
+ // skill only says how to do the work.
3
+ //
4
+ // They are registered through ctx.skill at setup, not linked into the OpenCode config directory. A package install
5
+ // (`opencode plugin add`) has no checkout to link from, and the files ship inside this package, so the plugin reads
6
+ // its own skills/ directory and adds them itself. That also makes the set identical on every platform: a link is a
7
+ // filesystem feature, a registration is not.
8
+ //
9
+ // Some skills come by rule (every writer verifies, P3 works test-first, a reviewer reviews), the others are offered
10
+ // to the decision model per task (N5's skill.<name> nouls). A skill is named in a brief only when the skill in
11
+ // OpenCode is this package's copy, so a user's own skill of the same name is never loaded by mistake.
12
+ //
13
+ // The second set is for sessions the user starts, not for their workers: a session skill is registered the same way so
14
+ // OpenCode has it, but it never enters the set a worker brief draws from. The orchestrator coordinates a session the
15
+ // user started; it is not a leaf skill a child writer or tester should load.
16
+ import { readFileSync, realpathSync } from "node:fs";
17
+ import { dirname, join } from "node:path";
18
+ import { fileURLToPath } from "node:url";
19
+ const WRITER_ROLES = ["code", "test", "visual", "write", "debug"];
20
+ export const SKILLS = [
21
+ { name: "verification-before-completion", description: "run the checks and read their output before claiming the task is done", roles: WRITER_ROLES, asked: false },
22
+ { name: "tdd", description: "test-driven development: tests at the public seams, red before green", roles: ["code", "test"], asked: true },
23
+ { name: "diagnosing-bugs", description: "a disciplined loop for bugs with an unknown cause: feedback loop, hypotheses, instrumentation", roles: ["code", "debug"], asked: true },
24
+ { name: "receiving-code-review", description: "check review findings against the code before changing anything", roles: ["code", "test", "visual", "write", "debug"], asked: false },
25
+ { name: "code-review", description: "review a change on two axes: what the task asked, and the repo's standards", roles: ["review"], asked: false },
26
+ { name: "research", description: "answer a question from primary sources and cite every claim", roles: ["research"], asked: false },
27
+ { name: "deck", description: "build and check an HTML deck: the spec, what the checks mean, and a placeholder instead of a missing picture", roles: ["code", "visual"], asked: true },
28
+ { name: "image", description: "build and check an image set: the spec, the checkpoint hash policy, split files versus a full checkpoint, and placeholders", roles: ["code", "visual"], asked: true },
29
+ { name: "web", description: "build and check a website: the spec's build contract, the browser checks at three widths, axe, and the weight budget", roles: ["code", "visual"], asked: true },
30
+ { name: "video", description: "build and check a short video with HyperFrames: the spec, Manim animations as scene clips, the frame and sound checks, and a film on a website", roles: ["code", "visual"], asked: true },
31
+ { name: "design", description: "edit the user's website, deck, media or 3D scene through the design canvas: drain the intents, edit the parts, commit only them", roles: ["code", "visual"], asked: true },
32
+ ];
33
+ // Skills a user-started session loads by name, never a role's worker skill: no worker role lists one, `skillsFor` never
34
+ // names one, and `registerSkills` keeps them out of the set a brief draws from.
35
+ export const SESSION_SKILLS = [
36
+ { name: "orchestrator", description: "run a pure multi-agent orchestration session using the research-backed agent patterns, complexity-tiered model routing, background parallel lanes, and optional post-green optimization", roles: [], asked: false },
37
+ ];
38
+ // Everything that ships in skills/ and is added to ctx.skill at setup, in registration order.
39
+ export const REGISTERED_SKILLS = [...SKILLS, ...SESSION_SKILLS];
40
+ // The skills a stage gets by rule, plus the ones the decision model picked for the task.
41
+ export function skillsFor(stage, profile, pipeline, installed) {
42
+ const out = [];
43
+ if (stage === "implement" || stage === "red" || stage === "review_fix") {
44
+ if (profile && WRITER_ROLES.includes(profile.role))
45
+ out.push("verification-before-completion");
46
+ if (stage === "red" || pipeline === "P3")
47
+ out.push("tdd");
48
+ if (profile?.bugUnknownCause)
49
+ out.push("diagnosing-bugs");
50
+ if (stage === "review_fix")
51
+ out.push("receiving-code-review");
52
+ out.push(...(profile?.skills ?? []));
53
+ }
54
+ if (stage === "review")
55
+ out.push("code-review");
56
+ if (stage === "reader")
57
+ out.push("research");
58
+ return [...new Set(out)].filter((s) => installed.has(s));
59
+ }
60
+ // Next to this module, so a package install (node_modules/…) and a symlinked dev checkout both resolve to the copy
61
+ // that belongs to the running code. realpath, because the dev install is a symlink into the repo.
62
+ export const SKILLS_DIR = join(dirname(realpathSync(fileURLToPath(import.meta.url))), "..", "skills");
63
+ // The catalog's files on disk, in catalog order. A missing file is reported and left out rather than thrown: an
64
+ // install that lost its skills/ directory must still start, with its workers getting no skill.
65
+ export function skillFiles(dir = SKILLS_DIR, missing = () => { }) {
66
+ const out = [];
67
+ for (const skill of REGISTERED_SKILLS) {
68
+ const path = join(dir, skill.name, "SKILL.md");
69
+ try {
70
+ out.push({ name: skill.name, description: skill.description, path, content: readFileSync(path, "utf8") });
71
+ }
72
+ catch {
73
+ missing(skill.name);
74
+ }
75
+ }
76
+ return out;
77
+ }
78
+ // Registers the catalog into OpenCode and answers with the names that are ours and now in place: exactly what a
79
+ // brief may say, because skillsFor filters on this set. A skill the user wrote under the same name keeps its place;
80
+ // ours is not added over it, and the name stays out of the set, so no worker is told to load a skill that would
81
+ // turn out to be someone else's. A session skill is registered but stays out of that set: a brief never names the
82
+ // orchestrator, even if a profile were to carry its name.
83
+ export async function registerSkills(domain, dir = SKILLS_DIR, missing,
84
+ // skills that are not shipped with the plugin but installed as an optional part (src/web-guidance.ts)
85
+ extra = []) {
86
+ const files = [...skillFiles(dir, missing), ...extra];
87
+ const session = new Set(SESSION_SKILLS.map((skill) => skill.name));
88
+ const added = new Set();
89
+ if (!domain || files.length === 0)
90
+ return added;
91
+ await domain.transform((editor) => {
92
+ const present = new Map(editor.list().map((skill) => [skill.id, skill]));
93
+ for (const file of files) {
94
+ const seen = present.get(file.name);
95
+ if (seen && seen.path !== file.path)
96
+ continue;
97
+ editor.add({ id: file.name, name: file.name, description: file.description, path: file.path, content: file.content });
98
+ if (!session.has(file.name))
99
+ added.add(file.name);
100
+ }
101
+ });
102
+ return added;
103
+ }
package/dist/state.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@omacode/state";
package/dist/store.js ADDED
@@ -0,0 +1 @@
1
+ export * from "@omacode/state/store";
@@ -0,0 +1 @@
1
+ export * from "@omacode/tui/switcher";