@omacode/micromanager 0.1.1 → 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 (213) hide show
  1. package/README.md +7 -4
  2. package/THIRD_PARTY.md +100 -0
  3. package/decider/.python-version +1 -0
  4. package/decider/README.md +35 -0
  5. package/decider/decider/__init__.py +1 -0
  6. package/decider/decider/server.py +327 -0
  7. package/decider/pyproject.toml +34 -0
  8. package/decider/uv.lock +1255 -0
  9. package/dist/agenda.js +51 -0
  10. package/dist/agents.js +58 -0
  11. package/dist/artifact/handoff.js +281 -0
  12. package/dist/ask.js +200 -0
  13. package/dist/backends.js +219 -0
  14. package/dist/backlog.js +414 -0
  15. package/dist/bench.js +427 -0
  16. package/dist/board.js +1 -0
  17. package/dist/brief.js +202 -0
  18. package/dist/browser.js +679 -0
  19. package/dist/budget.js +61 -0
  20. package/dist/catalog.js +187 -0
  21. package/dist/checkchange.js +145 -0
  22. package/dist/checkpoint.js +94 -0
  23. package/dist/cli.js +764 -0
  24. package/dist/comfy-gate.js +258 -0
  25. package/dist/compact.js +142 -0
  26. package/dist/config.js +344 -0
  27. package/dist/context/capture.js +1 -0
  28. package/dist/context/digest.js +1 -0
  29. package/dist/context/embed.js +1 -0
  30. package/dist/context/index.js +2 -0
  31. package/dist/context/ledger.js +1 -0
  32. package/dist/context/manager.js +1 -0
  33. package/dist/context/memory.js +1 -0
  34. package/dist/context/policy.js +1 -0
  35. package/dist/context/prices.js +1 -0
  36. package/dist/context/recall.js +1 -0
  37. package/dist/context/rules.js +1 -0
  38. package/dist/context/search.js +1 -0
  39. package/dist/context/status.js +1 -0
  40. package/dist/context/store.js +1 -0
  41. package/dist/context/summary.js +1 -0
  42. package/dist/context/tokens.js +1 -0
  43. package/dist/context/tools.js +1 -0
  44. package/dist/continuation.js +184 -0
  45. package/dist/contract.js +294 -0
  46. package/dist/contractround.js +178 -0
  47. package/dist/control.js +1 -0
  48. package/dist/creative-tools.js +237 -0
  49. package/dist/dataset.js +175 -0
  50. package/dist/decide.js +676 -0
  51. package/dist/decider.js +171 -0
  52. package/dist/design-shell.js +448 -0
  53. package/dist/design.js +1410 -0
  54. package/dist/desktop.js +44 -0
  55. package/dist/egress.js +156 -0
  56. package/dist/eval.js +60 -0
  57. package/dist/evolver.js +302 -0
  58. package/dist/features.js +193 -0
  59. package/dist/followups.js +32 -0
  60. package/dist/forms.js +195 -0
  61. package/dist/gate.js +108 -0
  62. package/dist/gatebox.js +46 -0
  63. package/dist/grants.js +189 -0
  64. package/dist/graph.js +65 -0
  65. package/dist/guard/index.js +1 -0
  66. package/dist/guard/wire.js +1 -0
  67. package/dist/helpers.js +85 -0
  68. package/dist/hooks.js +158 -0
  69. package/dist/image-models.js +117 -0
  70. package/{src/integration.ts → dist/integration.js} +1 -2
  71. package/dist/journal.js +1 -0
  72. package/dist/look.js +363 -0
  73. package/dist/memory.js +1 -0
  74. package/dist/mode.js +97 -0
  75. package/dist/native.js +3348 -0
  76. package/dist/nogit.js +259 -0
  77. package/dist/outcomes.js +148 -0
  78. package/dist/permission.js +35 -0
  79. package/dist/pick.js +89 -0
  80. package/dist/pipelines.js +262 -0
  81. package/dist/plan.js +641 -0
  82. package/dist/plandoc.js +211 -0
  83. package/dist/plugin.js +4736 -0
  84. package/dist/policy.js +58 -0
  85. package/dist/pools.js +1 -0
  86. package/dist/preview.js +274 -0
  87. package/dist/profile.js +165 -0
  88. package/dist/progress.js +1 -0
  89. package/dist/promote.js +313 -0
  90. package/dist/redact.js +1 -0
  91. package/dist/registry.js +179 -0
  92. package/dist/riskscore.js +126 -0
  93. package/dist/roles.js +1 -0
  94. package/dist/routing.js +1 -0
  95. package/dist/runner.js +1892 -0
  96. package/{src/sandbox.ts → dist/sandbox.js} +1 -2
  97. package/dist/sandboxgate.js +90 -0
  98. package/dist/scheduler.js +170 -0
  99. package/dist/services-main.js +131 -0
  100. package/dist/services.js +265 -0
  101. package/dist/session.js +241 -0
  102. package/dist/setup.js +423 -0
  103. package/dist/shell/decide.js +1 -0
  104. package/dist/shell/index.js +2 -0
  105. package/dist/shell/sandbox.js +1 -0
  106. package/dist/shell/wire.js +1 -0
  107. package/dist/skills.js +103 -0
  108. package/dist/state.js +1 -0
  109. package/dist/store.js +1 -0
  110. package/dist/switcher.js +1 -0
  111. package/dist/synth.js +418 -0
  112. package/dist/tools.js +477 -0
  113. package/dist/trials.js +223 -0
  114. package/dist/usage.js +1 -0
  115. package/dist/wait.js +167 -0
  116. package/dist/watchdog.js +476 -0
  117. package/dist/web-guidance.js +43 -0
  118. package/dist/which.js +20 -0
  119. package/dist/worktree/git.js +545 -0
  120. package/dist/writeguard.js +311 -0
  121. package/package.json +36 -17
  122. package/skills/deck/SKILL.md +98 -0
  123. package/skills/design/SKILL.md +150 -0
  124. package/skills/image/SKILL.md +66 -0
  125. package/skills/orchestrator/SKILL.md +107 -0
  126. package/skills/video/SKILL.md +97 -0
  127. package/skills/web/SKILL.md +60 -0
  128. package/src/agenda.ts +0 -56
  129. package/src/agents.ts +0 -74
  130. package/src/ask.ts +0 -243
  131. package/src/backends.ts +0 -144
  132. package/src/backlog.ts +0 -436
  133. package/src/bench.ts +0 -163
  134. package/src/board.ts +0 -1
  135. package/src/brief.ts +0 -151
  136. package/src/browser.ts +0 -624
  137. package/src/budget.ts +0 -73
  138. package/src/catalog.ts +0 -214
  139. package/src/checkchange.ts +0 -180
  140. package/src/checkpoint.ts +0 -99
  141. package/src/cli.ts +0 -117
  142. package/src/compact.ts +0 -162
  143. package/src/config.ts +0 -340
  144. package/src/context/capture.ts +0 -1
  145. package/src/context/digest.ts +0 -1
  146. package/src/context/embed.ts +0 -1
  147. package/src/context/index.ts +0 -2
  148. package/src/context/ledger.ts +0 -1
  149. package/src/context/manager.ts +0 -1
  150. package/src/context/memory.ts +0 -1
  151. package/src/context/policy.ts +0 -1
  152. package/src/context/prices.ts +0 -1
  153. package/src/context/recall.ts +0 -1
  154. package/src/context/rules.ts +0 -1
  155. package/src/context/search.ts +0 -1
  156. package/src/context/status.ts +0 -1
  157. package/src/context/store.ts +0 -1
  158. package/src/context/summary.ts +0 -1
  159. package/src/context/tokens.ts +0 -1
  160. package/src/context/tools.ts +0 -1
  161. package/src/continuation.ts +0 -122
  162. package/src/contract.ts +0 -342
  163. package/src/contractround.ts +0 -225
  164. package/src/control.ts +0 -1
  165. package/src/dataset.ts +0 -133
  166. package/src/decide.ts +0 -690
  167. package/src/eval.ts +0 -66
  168. package/src/evolver.ts +0 -369
  169. package/src/followups.ts +0 -50
  170. package/src/forms.ts +0 -191
  171. package/src/gate.ts +0 -90
  172. package/src/grants.ts +0 -239
  173. package/src/graph.ts +0 -74
  174. package/src/guard/index.ts +0 -1
  175. package/src/guard/wire.ts +0 -1
  176. package/src/helpers.ts +0 -105
  177. package/src/hooks.ts +0 -199
  178. package/src/jev.ts +0 -141
  179. package/src/journal.ts +0 -1
  180. package/src/look.ts +0 -390
  181. package/src/memory.ts +0 -1
  182. package/src/native.ts +0 -2455
  183. package/src/nogit.ts +0 -112
  184. package/src/outcomes.ts +0 -210
  185. package/src/pick.ts +0 -112
  186. package/src/pipelines.ts +0 -252
  187. package/src/plan.ts +0 -449
  188. package/src/plugin.ts +0 -3187
  189. package/src/policy.ts +0 -84
  190. package/src/pools.ts +0 -1
  191. package/src/profile.ts +0 -186
  192. package/src/progress.ts +0 -1
  193. package/src/redact.ts +0 -1
  194. package/src/registry.ts +0 -207
  195. package/src/roles.ts +0 -1
  196. package/src/routing.ts +0 -1
  197. package/src/runner.ts +0 -1506
  198. package/src/scheduler.ts +0 -200
  199. package/src/session.ts +0 -269
  200. package/src/shell/decide.ts +0 -1
  201. package/src/shell/index.ts +0 -2
  202. package/src/shell/sandbox.ts +0 -1
  203. package/src/shell/wire.ts +0 -1
  204. package/src/skills.ts +0 -111
  205. package/src/state.ts +0 -1
  206. package/src/store.ts +0 -1
  207. package/src/switcher.ts +0 -1
  208. package/src/tools.ts +0 -480
  209. package/src/trials.ts +0 -247
  210. package/src/usage.ts +0 -1
  211. package/src/wait.ts +0 -180
  212. package/src/watchdog.ts +0 -498
  213. package/src/worktree/git.ts +0 -378
@@ -0,0 +1,211 @@
1
+ // The plan document (A1-T8): what a plan job writes down, and what Build mode reads before it starts at `execute` or
2
+ // decides it has to plan again. The headings are a contract, not decoration: the parser below reads exactly these, and
3
+ // the artifact contracts (B1-T6) will read them too, so a renamed heading is a changed format.
4
+ //
5
+ // The document always carries the same seven sections — goal, findings, decisions, open questions, recommended tasks,
6
+ // artifacts, risks — and, when A1-T7 applied, the line that says the job ran reader-only. An empty section says
7
+ // "(none)" rather than vanishing, so a reader can tell "nothing was found" from "the document was cut short".
8
+ //
9
+ // docFromJob is the document the plugin itself guarantees: the job's goal, decisions, tasks, promoted artifacts and
10
+ // lessons, in this shape, written where a plan job starts and rewritten when a task hands artifacts back. A plan agent
11
+ // may write a richer plan.md itself — that is its job — and the plugin leaves such a document alone (src/native.ts).
12
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
13
+ import { dirname, join } from "node:path";
14
+ import { planArea } from "./worktree/git.js";
15
+ // The heading text, once: the renderer and the parser read the same constants, so they cannot drift apart.
16
+ const HEADINGS = {
17
+ goal: "Goal",
18
+ findings: "Findings",
19
+ decisions: "Decisions",
20
+ openQuestions: "Open questions",
21
+ tasks: "Recommended tasks",
22
+ artifacts: "Artifacts",
23
+ risks: "Risks",
24
+ };
25
+ const NONE = "(none)";
26
+ const BULLET = /^- /;
27
+ const TASK_LINE = /^- \*\*(.*?)\*\* (.*?) · role (\S+) · files: (.*) · acceptance: (.*)$/;
28
+ const ARTIFACT_LINE = /^- (.*?): (.*) \((\d+) B, sha256 ([0-9a-f]{64})\)$/;
29
+ const MODE_LINE = /^\*\*Mode:\*\* reader-only(?: — ?(.*))?$/m;
30
+ const why = (err) => (err instanceof Error ? err.message : String(err));
31
+ // One comma-separated list inside a task bullet; "(none)" is how the renderer spells an empty one.
32
+ function listText(items) {
33
+ return items.length ? items.join(", ") : NONE;
34
+ }
35
+ function listOf(text) {
36
+ const t = text.trim();
37
+ return !t || t === NONE ? [] : t.split(",").map((p) => p.trim()).filter(Boolean);
38
+ }
39
+ function heading(name, body) {
40
+ return [`## ${name}`, "", body, ""];
41
+ }
42
+ export function renderPlanDoc(job, doc) {
43
+ const lines = (items) => (items.length ? items.map((item) => `- ${item}`).join("\n") : NONE);
44
+ const tasks = doc.tasks.length
45
+ ? doc.tasks.map((t) => `- **${t.id}** ${t.title} · role ${t.role} · files: ${listText(t.files)} · acceptance: ${listText(t.acceptance)}`).join("\n")
46
+ : NONE;
47
+ const artifacts = doc.artifacts.length
48
+ ? doc.artifacts.map((a) => `- ${a.task}: ${a.path} (${a.bytes} B, sha256 ${a.sha256})`).join("\n")
49
+ : NONE;
50
+ const mode = doc.readerOnly !== undefined ? [`**Mode:** reader-only — ${doc.readerOnly}`, ""] : [];
51
+ return [
52
+ `# ${job.id} — plan`,
53
+ "",
54
+ ...mode,
55
+ ...heading(HEADINGS.goal, doc.goal.trim() || NONE),
56
+ ...heading(HEADINGS.findings, lines(doc.findings)),
57
+ ...heading(HEADINGS.decisions, lines(doc.decisions)),
58
+ ...heading(HEADINGS.openQuestions, lines(doc.openQuestions)),
59
+ ...heading(HEADINGS.tasks, tasks),
60
+ ...heading(HEADINGS.artifacts, artifacts),
61
+ ...heading(HEADINGS.risks, lines(doc.risks)),
62
+ ].join("\n").trimEnd() + "\n";
63
+ }
64
+ // The `## ` sections of a document, by heading, as their lines. A heading repeated later merges its lines into the
65
+ // first, which is the lenient reading: the document still says what it says.
66
+ function sections(text) {
67
+ const out = new Map();
68
+ let current;
69
+ for (const line of text.split(/\r?\n/)) {
70
+ const found = /^##\s+(.*?)\s*$/.exec(line);
71
+ if (found) {
72
+ const name = found[1];
73
+ current = out.get(name) ?? [];
74
+ out.set(name, current);
75
+ continue;
76
+ }
77
+ current?.push(line);
78
+ }
79
+ return out;
80
+ }
81
+ // A section's lines without the blank padding the renderer puts around it.
82
+ function bodyLines(lines) {
83
+ let start = 0;
84
+ let end = lines.length;
85
+ while (start < end && !lines[start].trim())
86
+ start++;
87
+ while (end > start && !lines[end - 1].trim())
88
+ end--;
89
+ return lines.slice(start, end);
90
+ }
91
+ // A section of bullets. A line that is not a bullet continues the one above it, so a wrapped finding survives; text
92
+ // without any bullet is read as one item, which is how a hand-written paragraph in the agent's own document parses.
93
+ function bullets(lines) {
94
+ const out = [];
95
+ for (const line of bodyLines(lines)) {
96
+ if (BULLET.test(line))
97
+ out.push(line.slice(2));
98
+ else if (!line.trim())
99
+ continue;
100
+ else if (out.length)
101
+ out[out.length - 1] += `\n${line}`;
102
+ else
103
+ out.push(line);
104
+ }
105
+ return out.length === 1 && out[0] === NONE ? [] : out;
106
+ }
107
+ function tasksOf(lines, errors) {
108
+ const body = bodyLines(lines);
109
+ if (!body.length || (body.length === 1 && body[0] === NONE))
110
+ return [];
111
+ const out = [];
112
+ for (const line of body) {
113
+ const found = TASK_LINE.exec(line);
114
+ if (!found) {
115
+ errors.push(`a recommended task cannot be read: "${line}"`);
116
+ continue;
117
+ }
118
+ out.push({ id: found[1], title: found[2], role: found[3], files: listOf(found[4]), acceptance: listOf(found[5]) });
119
+ }
120
+ return out;
121
+ }
122
+ function artifactsOf(lines, errors) {
123
+ const body = bodyLines(lines);
124
+ if (!body.length || (body.length === 1 && body[0] === NONE))
125
+ return [];
126
+ const out = [];
127
+ for (const line of body) {
128
+ const found = ARTIFACT_LINE.exec(line);
129
+ if (!found) {
130
+ errors.push(`an artifact cannot be read: "${line}"`);
131
+ continue;
132
+ }
133
+ out.push({ task: found[1], path: found[2], bytes: Number(found[3]), sha256: found[4] });
134
+ }
135
+ return out;
136
+ }
137
+ // A document read back. A missing Goal or Recommended tasks heading is refused: the first is what the job is for, the
138
+ // second is what Build mode would start, and a file without them is not this contract's document.
139
+ export function parsePlanDoc(text) {
140
+ const errors = [];
141
+ const found = sections(text);
142
+ const goal = found.get(HEADINGS.goal);
143
+ const tasks = found.get(HEADINGS.tasks);
144
+ if (!goal)
145
+ errors.push(`the plan has no ## ${HEADINGS.goal} section`);
146
+ if (!tasks)
147
+ errors.push(`the plan has no ## ${HEADINGS.tasks} section`);
148
+ if (errors.length || !goal || !tasks)
149
+ return { errors };
150
+ const mode = MODE_LINE.exec(text);
151
+ const goalText = bodyLines(goal).join("\n");
152
+ const doc = {
153
+ goal: goalText === NONE ? "" : goalText,
154
+ findings: bullets(found.get(HEADINGS.findings) ?? []),
155
+ decisions: bullets(found.get(HEADINGS.decisions) ?? []),
156
+ openQuestions: bullets(found.get(HEADINGS.openQuestions) ?? []),
157
+ tasks: tasksOf(tasks, errors),
158
+ artifacts: artifactsOf(found.get(HEADINGS.artifacts) ?? [], errors),
159
+ risks: bullets(found.get(HEADINGS.risks) ?? []),
160
+ ...(mode ? { readerOnly: mode[1] ?? "" } : {}),
161
+ };
162
+ return errors.length ? { errors } : { doc, errors };
163
+ }
164
+ // Where the document lives: in the plan area, beside the worktrees, artifacts, findings and patches of the same job.
165
+ export function planDocPath(project, jobId) {
166
+ return join(planArea(project, jobId), "plan.md");
167
+ }
168
+ // Writes the document 0600 under a 0700 directory, like every other record of a plan job.
169
+ export function writePlanDoc(project, jobId, doc) {
170
+ const path = planDocPath(project, jobId);
171
+ mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
172
+ writeFileSync(path, renderPlanDoc({ id: jobId }, doc), { mode: 0o600 });
173
+ return path;
174
+ }
175
+ export function readPlanDoc(project, jobId) {
176
+ const path = planDocPath(project, jobId);
177
+ let text;
178
+ try {
179
+ text = readFileSync(path, "utf8");
180
+ }
181
+ catch (err) {
182
+ const missing = err.code === "ENOENT";
183
+ return { errors: [missing ? "no plan.md yet" : `plan.md cannot be read: ${why(err)}`], path };
184
+ }
185
+ const parsed = parsePlanDoc(text);
186
+ return parsed.doc ? { doc: parsed.doc, errors: parsed.errors, path } : { errors: parsed.errors, path };
187
+ }
188
+ // The document the plugin always guarantees, built from the job itself. A plan agent may write a richer document
189
+ // itself — findings it read, questions it has, tasks it recommends before they are `job.tasks`, a risk it noticed — and
190
+ // that one wins (src/native.ts keeps it and only replaces a missing or plugin-written document). This is the floor,
191
+ // not the ceiling. A cancelled task is left out: it is history, not a recommendation. The findings are the finished
192
+ // tasks' summary lines, the risks are the job's lessons, and the artifacts are exactly what the tasks promoted.
193
+ export function docFromJob(job) {
194
+ const tasks = job.tasks
195
+ .filter((t) => t.status !== "cancelled")
196
+ .map((t) => ({ id: t.id, title: t.title, role: t.role, files: [...t.files], acceptance: [...t.acceptance] }));
197
+ const findings = job.tasks
198
+ .filter((t) => t.status === "passed" || t.status === "merged")
199
+ .map((t) => t.summary?.split("\n")[0]?.trim())
200
+ .filter((line) => Boolean(line));
201
+ return {
202
+ goal: job.goal,
203
+ findings,
204
+ decisions: job.decisions.map((d) => d.text),
205
+ openQuestions: [],
206
+ tasks,
207
+ artifacts: job.tasks.flatMap((t) => (t.promoted ?? []).map((a) => ({ task: t.id, path: a.path, bytes: a.bytes, sha256: a.sha256 }))),
208
+ risks: [...job.lessons],
209
+ ...(job.planReaderOnly !== undefined ? { readerOnly: job.planReaderOnly } : {}),
210
+ };
211
+ }