@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
package/src/brief.ts DELETED
@@ -1,151 +0,0 @@
1
- // What a worker is told, and what it reports back (design.md §8.2). The brief is plain instructions: acceptance
2
- // points and files go in verbatim. The report is short and fixed, so code can read it.
3
-
4
- import { HEADER } from "./hooks.ts"
5
- import type { Acceptance, FollowUp, Job, Task } from "./state.ts"
6
-
7
- export type WorkerStatus = "DONE" | "DONE_WITH_CONCERNS" | "NEEDS_CONTEXT" | "BLOCKED"
8
-
9
- export interface Report {
10
- readonly status?: WorkerStatus
11
- readonly files: string[]
12
- readonly evidence: string
13
- readonly open: string
14
- readonly followUps: FollowUp[]
15
- readonly learned: string[]
16
- readonly text: string
17
- }
18
-
19
- // Caveman (design.md §13.2): text that only code or another agent reads is terse. Briefs to workers stay plain.
20
- export const CAVEMAN = `Style (only code reads this): answer first; no greeting, recap or filler; fragments are fine. Keep every
21
- "not", number, path, command and quote exact.`
22
-
23
- const REPORT_FORMAT = `End your answer with this report, nothing after it:
24
- STATUS: DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED
25
- FILES: the files you changed, comma separated, or none
26
- EVIDENCE: the commands you ran and their results, short
27
- OPEN: what is left open or what you need, or nothing
28
- FOLLOWUP: work the job needs that is outside your task | why | the files it would change (one line each; leave out if none)
29
- LEARNED: a lasting fact about this project that later tasks will need, e.g. how to run its tests or where something lives (one line each; leave out if none)
30
- ${CAVEMAN}`
31
-
32
- export function taskAcceptance(job: Job, task: Task): Acceptance[] {
33
- return job.acceptance.filter((a) => task.acceptance.includes(a.id))
34
- }
35
-
36
- // An acceptance point several tasks cover: each task does and is judged on its own part only.
37
- export function sharedNote(job: Job, task: Task, id: string): string {
38
- const others = job.tasks.filter((t) => t.id !== task.id && t.acceptance.includes(id)).map((t) => t.id)
39
- return others.length ? ` [shared with ${others.join(", ")}: only this task's part counts here]` : ""
40
- }
41
-
42
- export function brief(job: Job, task: Task, model: string, directory: string, skills: readonly string[] = []): string {
43
- const acceptance = taskAcceptance(job, task)
44
- .map((a) => `- ${a.id}: ${a.text}${a.verify ? ` (checked with: ${a.verify})` : ""}${sharedNote(job, task, a.id)}`)
45
- .join("\n")
46
- const done = job.tasks.filter((t) => t.status === "passed" || t.status === "merged")
47
- const others = job.tasks.filter((t) => t.id !== task.id && !done.includes(t) && t.status !== "cancelled")
48
- return [
49
- `${HEADER} task ${task.id} · role ${task.role} · model ${model}`,
50
- "",
51
- `The job: ${job.goal}`,
52
- "",
53
- `Your task (${task.id}): ${task.title}`,
54
- task.description,
55
- "",
56
- "Acceptance points:",
57
- acceptance || "- none given",
58
- "",
59
- task.files.length ? `Files you may change: ${task.files.join(", ")}` : "Change no files.",
60
- `Work only in ${directory}. Do only this task.`,
61
- "Keys and tokens show as <secret> in what you read; never write <secret> into a file, leave such lines as they are.",
62
- done.length ? `Already done: ${done.map((t) => `${t.id} ${t.title}`).join("; ")}` : "",
63
- others.length ? `Other tasks of this job, done by others (not yours, and not follow-ups): ${others.map((t) => `${t.id} ${t.title}`).join("; ")}` : "",
64
- job.decisions.length ? `Decisions that apply: ${job.decisions.map((d) => d.text).join("; ")}` : "",
65
- job.lessons.length ? `Learned earlier in this job: ${job.lessons.slice(-3).join("; ")}` : "",
66
- task.profile?.recall?.length ? `Known about this project:\n${task.profile.recall.map((r) => `- ${r}`).join("\n")}` : "",
67
- skillLine(skills),
68
- "",
69
- REPORT_FORMAT,
70
- ].filter((line, i, all) => line !== "" || all[i - 1] !== "").join("\n").trim()
71
- }
72
-
73
- export function skillLine(skills: readonly string[]): string {
74
- return skills.length ? `Load these skills before you start: ${skills.join(", ")}.` : ""
75
- }
76
-
77
- // What a fresh session on another model is told after the previous one failed (N9 rung 2, design.md §8.2).
78
- export function handoffText(reason: string, details: string, changed: readonly string[]): string {
79
- return [
80
- `A previous attempt at this task, by another model, failed: ${reason}.`,
81
- details ? `What it ran into:\n${details.slice(0, 3000)}` : "",
82
- changed.length ? `Files it already changed in this directory: ${changed.join(", ")}. Check them: keep what is right, fix what is wrong, and do not start over blindly.` : "It changed no file.",
83
- `Digest: files touched: ${changed.join(", ") || "none"}; learned: ${changed.slice(-3).join(", ") || "none"}; last command: ${details.slice(0, 120) || "none"}`,
84
- "Try another way than the previous attempt if its way kept failing.",
85
- ].filter(Boolean).join("\n\n")
86
- }
87
-
88
- export function fixPrompt(failures: readonly { command: string; code: number; output: string }[]): string {
89
- const parts = failures.map((f) => `$ ${f.command} (exit ${f.code})\n${f.output}`)
90
- return `${HEADER} The checks of your task failed:\n\n${parts.join("\n\n")}\n\nFix the cause in your task's files, then report again in the same format.`
91
- }
92
-
93
- const STATUSES: readonly WorkerStatus[] = ["DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED", "DONE"]
94
-
95
- export function parseReport(text: string): Report {
96
- const field = (name: string) => text.match(new RegExp(`^\\s*\\**${name}\\**\\s*:\\**\\s*(.*)$`, "im"))?.[1]?.trim() ?? ""
97
- const statusText = field("STATUS").toUpperCase()
98
- const status = STATUSES.find((s) => statusText.startsWith(s))
99
- const files = field("FILES")
100
- const followUps = [...text.matchAll(/^\s*\**FOLLOWUP\**\s*:\**\s*(.+)$/gim)]
101
- .map((m) => m[1]!.split("|").map((p) => p.trim()))
102
- .filter(([what]) => what && !/^(none|nothing|-)$/i.test(what))
103
- .map(([what, why, paths]): FollowUp => ({
104
- what: what!,
105
- why: why ?? "",
106
- files: !paths || /^none$/i.test(paths) ? [] : paths.split(/[,\s]+/).map((f) => f.replace(/[`*]/g, "")).filter(Boolean),
107
- }))
108
- const learned = [...text.matchAll(/^\s*\**LEARNED\**\s*:\**\s*(.+)$/gim)].map((m) => m[1]!.trim()).filter((l) => l && !/^(none|nothing|-)$/i.test(l))
109
- return {
110
- status,
111
- files: !files || /^none$/i.test(files) ? [] : files.split(/[,\s]+/).map((f) => f.replace(/[`*]/g, "")).filter(Boolean),
112
- evidence: field("EVIDENCE"),
113
- open: field("OPEN"),
114
- followUps,
115
- learned,
116
- text,
117
- }
118
- }
119
-
120
- // worker_refused (design.md §10.2): a reply without a report that reads like a safety refusal. Code decides, by
121
- // phrasing; the patterns are conservative until the refusal probe set (A10) calibrates them.
122
- const REFUSAL = /\b(I can(?:'|no)t (?:help|assist|do|comply|provide|write|create)|I(?:'m| am) (?:not able|unable) to (?:help|assist|comply|do)|I won't (?:help|do|write|create|be able)|I must decline|I(?:'m| am) sorry, but I can|against (?:my|the|our) (?:guidelines|policies|policy|usage policies))/i
123
-
124
- export function refused(text: string): boolean {
125
- return REFUSAL.test(text) && parseReport(text).status === undefined
126
- }
127
-
128
- // The last assistant message's text, from ctx.session.context() (shape seen in Phase A).
129
- export function lastAssistantText(messages: unknown): string {
130
- if (!Array.isArray(messages)) return ""
131
- for (let i = messages.length - 1; i >= 0; i--) {
132
- const m = messages[i] as { type?: string; content?: { type?: string; text?: string }[] }
133
- if (m.type !== "assistant" || !Array.isArray(m.content)) continue
134
- const text = m.content.filter((c) => c.type === "text" && c.text).map((c) => c.text).join("\n").trim()
135
- if (text) return text
136
- }
137
- return ""
138
- }
139
-
140
- // Tokens and cost of a session, summed over its assistant messages.
141
- export function usage(messages: unknown): { tokens: number; cost: number } {
142
- if (!Array.isArray(messages)) return { tokens: 0, cost: 0 }
143
- let tokens = 0
144
- let cost = 0
145
- for (const m of messages as { type?: string; tokens?: { input?: number; output?: number }; cost?: number }[]) {
146
- if (m.type !== "assistant") continue
147
- tokens += (m.tokens?.input ?? 0) + (m.tokens?.output ?? 0)
148
- cost += m.cost ?? 0
149
- }
150
- return { tokens, cost }
151
- }