@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.
- package/README.md +7 -4
- package/THIRD_PARTY.md +100 -0
- package/decider/.python-version +1 -0
- package/decider/README.md +35 -0
- package/decider/decider/__init__.py +1 -0
- package/decider/decider/server.py +327 -0
- package/decider/pyproject.toml +34 -0
- package/decider/uv.lock +1255 -0
- package/dist/agenda.js +51 -0
- package/dist/agents.js +58 -0
- package/dist/artifact/handoff.js +281 -0
- package/dist/ask.js +200 -0
- package/dist/backends.js +219 -0
- package/dist/backlog.js +414 -0
- package/dist/bench.js +427 -0
- package/dist/board.js +1 -0
- package/dist/brief.js +202 -0
- package/dist/browser.js +679 -0
- package/dist/budget.js +61 -0
- package/dist/catalog.js +187 -0
- package/dist/checkchange.js +145 -0
- package/dist/checkpoint.js +94 -0
- package/dist/cli.js +764 -0
- package/dist/comfy-gate.js +258 -0
- package/dist/compact.js +142 -0
- package/dist/config.js +344 -0
- package/dist/context/capture.js +1 -0
- package/dist/context/digest.js +1 -0
- package/dist/context/embed.js +1 -0
- package/dist/context/index.js +2 -0
- package/dist/context/ledger.js +1 -0
- package/dist/context/manager.js +1 -0
- package/dist/context/memory.js +1 -0
- package/dist/context/policy.js +1 -0
- package/dist/context/prices.js +1 -0
- package/dist/context/recall.js +1 -0
- package/dist/context/rules.js +1 -0
- package/dist/context/search.js +1 -0
- package/dist/context/status.js +1 -0
- package/dist/context/store.js +1 -0
- package/dist/context/summary.js +1 -0
- package/dist/context/tokens.js +1 -0
- package/dist/context/tools.js +1 -0
- package/dist/continuation.js +184 -0
- package/dist/contract.js +294 -0
- package/dist/contractround.js +178 -0
- package/dist/control.js +1 -0
- package/dist/creative-tools.js +237 -0
- package/dist/dataset.js +175 -0
- package/dist/decide.js +676 -0
- package/dist/decider.js +171 -0
- package/dist/design-shell.js +448 -0
- package/dist/design.js +1410 -0
- package/dist/desktop.js +44 -0
- package/dist/egress.js +156 -0
- package/dist/eval.js +60 -0
- package/dist/evolver.js +302 -0
- package/dist/features.js +193 -0
- package/dist/followups.js +32 -0
- package/dist/forms.js +195 -0
- package/dist/gate.js +108 -0
- package/dist/gatebox.js +46 -0
- package/dist/grants.js +189 -0
- package/dist/graph.js +65 -0
- package/dist/guard/index.js +1 -0
- package/dist/guard/wire.js +1 -0
- package/dist/helpers.js +85 -0
- package/dist/hooks.js +158 -0
- package/dist/image-models.js +117 -0
- package/{src/integration.ts → dist/integration.js} +1 -2
- package/dist/journal.js +1 -0
- package/dist/look.js +363 -0
- package/dist/memory.js +1 -0
- package/dist/mode.js +97 -0
- package/dist/native.js +3348 -0
- package/dist/nogit.js +259 -0
- package/dist/outcomes.js +148 -0
- package/dist/permission.js +35 -0
- package/dist/pick.js +89 -0
- package/dist/pipelines.js +262 -0
- package/dist/plan.js +641 -0
- package/dist/plandoc.js +211 -0
- package/dist/plugin.js +4736 -0
- package/dist/policy.js +58 -0
- package/dist/pools.js +1 -0
- package/dist/preview.js +274 -0
- package/dist/profile.js +165 -0
- package/dist/progress.js +1 -0
- package/dist/promote.js +313 -0
- package/dist/redact.js +1 -0
- package/dist/registry.js +179 -0
- package/dist/riskscore.js +126 -0
- package/dist/roles.js +1 -0
- package/dist/routing.js +1 -0
- package/dist/runner.js +1892 -0
- package/{src/sandbox.ts → dist/sandbox.js} +1 -2
- package/dist/sandboxgate.js +90 -0
- package/dist/scheduler.js +170 -0
- package/dist/services-main.js +131 -0
- package/dist/services.js +265 -0
- package/dist/session.js +241 -0
- package/dist/setup.js +423 -0
- package/dist/shell/decide.js +1 -0
- package/dist/shell/index.js +2 -0
- package/dist/shell/sandbox.js +1 -0
- package/dist/shell/wire.js +1 -0
- package/dist/skills.js +103 -0
- package/dist/state.js +1 -0
- package/dist/store.js +1 -0
- package/dist/switcher.js +1 -0
- package/dist/synth.js +418 -0
- package/dist/tools.js +477 -0
- package/dist/trials.js +223 -0
- package/dist/usage.js +1 -0
- package/dist/wait.js +167 -0
- package/dist/watchdog.js +476 -0
- package/dist/web-guidance.js +43 -0
- package/dist/which.js +20 -0
- package/dist/worktree/git.js +545 -0
- package/dist/writeguard.js +311 -0
- package/package.json +36 -17
- package/skills/deck/SKILL.md +98 -0
- package/skills/design/SKILL.md +150 -0
- package/skills/image/SKILL.md +66 -0
- package/skills/orchestrator/SKILL.md +107 -0
- package/skills/video/SKILL.md +97 -0
- package/skills/web/SKILL.md +60 -0
- package/src/agenda.ts +0 -56
- package/src/agents.ts +0 -74
- package/src/ask.ts +0 -243
- package/src/backends.ts +0 -144
- package/src/backlog.ts +0 -436
- package/src/bench.ts +0 -163
- package/src/board.ts +0 -1
- package/src/brief.ts +0 -151
- package/src/browser.ts +0 -624
- package/src/budget.ts +0 -73
- package/src/catalog.ts +0 -214
- package/src/checkchange.ts +0 -180
- package/src/checkpoint.ts +0 -99
- package/src/cli.ts +0 -117
- package/src/compact.ts +0 -162
- package/src/config.ts +0 -340
- package/src/context/capture.ts +0 -1
- package/src/context/digest.ts +0 -1
- package/src/context/embed.ts +0 -1
- package/src/context/index.ts +0 -2
- package/src/context/ledger.ts +0 -1
- package/src/context/manager.ts +0 -1
- package/src/context/memory.ts +0 -1
- package/src/context/policy.ts +0 -1
- package/src/context/prices.ts +0 -1
- package/src/context/recall.ts +0 -1
- package/src/context/rules.ts +0 -1
- package/src/context/search.ts +0 -1
- package/src/context/status.ts +0 -1
- package/src/context/store.ts +0 -1
- package/src/context/summary.ts +0 -1
- package/src/context/tokens.ts +0 -1
- package/src/context/tools.ts +0 -1
- package/src/continuation.ts +0 -122
- package/src/contract.ts +0 -342
- package/src/contractround.ts +0 -225
- package/src/control.ts +0 -1
- package/src/dataset.ts +0 -133
- package/src/decide.ts +0 -690
- package/src/eval.ts +0 -66
- package/src/evolver.ts +0 -369
- package/src/followups.ts +0 -50
- package/src/forms.ts +0 -191
- package/src/gate.ts +0 -90
- package/src/grants.ts +0 -239
- package/src/graph.ts +0 -74
- package/src/guard/index.ts +0 -1
- package/src/guard/wire.ts +0 -1
- package/src/helpers.ts +0 -105
- package/src/hooks.ts +0 -199
- package/src/jev.ts +0 -141
- package/src/journal.ts +0 -1
- package/src/look.ts +0 -390
- package/src/memory.ts +0 -1
- package/src/native.ts +0 -2455
- package/src/nogit.ts +0 -112
- package/src/outcomes.ts +0 -210
- package/src/pick.ts +0 -112
- package/src/pipelines.ts +0 -252
- package/src/plan.ts +0 -449
- package/src/plugin.ts +0 -3187
- package/src/policy.ts +0 -84
- package/src/pools.ts +0 -1
- package/src/profile.ts +0 -186
- package/src/progress.ts +0 -1
- package/src/redact.ts +0 -1
- package/src/registry.ts +0 -207
- package/src/roles.ts +0 -1
- package/src/routing.ts +0 -1
- package/src/runner.ts +0 -1506
- package/src/scheduler.ts +0 -200
- package/src/session.ts +0 -269
- package/src/shell/decide.ts +0 -1
- package/src/shell/index.ts +0 -2
- package/src/shell/sandbox.ts +0 -1
- package/src/shell/wire.ts +0 -1
- package/src/skills.ts +0 -111
- package/src/state.ts +0 -1
- package/src/store.ts +0 -1
- package/src/switcher.ts +0 -1
- package/src/tools.ts +0 -480
- package/src/trials.ts +0 -247
- package/src/usage.ts +0 -1
- package/src/wait.ts +0 -180
- package/src/watchdog.ts +0 -498
- package/src/worktree/git.ts +0 -378
package/src/pipelines.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
// N6: which loops a task passes (design.md §9). Rules over the N5 answers pick the pipeline, as §8.1 says
|
|
2
|
-
// ("pipeline = rules over the answers"); the user can pin one with "pipeline P2". The stages themselves are run by
|
|
3
|
-
// the runner; this file holds the choice and the pure parts: review and research prompts, their parsers, and the
|
|
4
|
-
// citation check.
|
|
5
|
-
|
|
6
|
-
import { CAVEMAN, sharedNote } from "./brief.ts"
|
|
7
|
-
import { CHOICE_FLOOR, type Risk } from "./catalog.ts"
|
|
8
|
-
import { HEADER } from "./hooks.ts"
|
|
9
|
-
import { resolvePolicy, type Policies } from "./policy.ts"
|
|
10
|
-
import { WRITERS, type Profile } from "./profile.ts"
|
|
11
|
-
import type { Acceptance, FollowUp, Job, Task } from "./state.ts"
|
|
12
|
-
|
|
13
|
-
export type PipelineId = "P1" | "P2" | "P3" | "P9"
|
|
14
|
-
export type Modifier = "user_confirm" | "oracle"
|
|
15
|
-
|
|
16
|
-
export interface Pipeline {
|
|
17
|
-
readonly id: PipelineId
|
|
18
|
-
readonly reason: string
|
|
19
|
-
readonly modifiers: readonly Modifier[]
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const PIPELINES: Record<PipelineId, string> = {
|
|
23
|
-
P1: "implement -> gate, fix at most twice",
|
|
24
|
-
P2: "implement -> gate -> review by another model family, at most 3 review rounds",
|
|
25
|
-
P3: "tests first (red, then frozen) -> implement (green) -> gate -> review",
|
|
26
|
-
P9: "research: parallel readers -> synthesis -> citation check",
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const RISK_RANK: Record<Risk, number> = { cosmetic: 0, internal: 1, public_api: 2, data_security: 3, destructive: 4 }
|
|
30
|
-
|
|
31
|
-
export const riskAtLeast = (risk: Risk, floor: Risk): boolean => RISK_RANK[risk] >= RISK_RANK[floor]
|
|
32
|
-
|
|
33
|
-
export function choosePipeline(task: Task, profile: Profile, policies: Policies): Pipeline {
|
|
34
|
-
const modifiers: Modifier[] = []
|
|
35
|
-
if (profile.risk === "destructive") modifiers.push("user_confirm")
|
|
36
|
-
if (riskAtLeast(profile.risk, "data_security")) modifiers.push("oracle")
|
|
37
|
-
const writer = WRITERS.has(profile.role) && task.files.length > 0
|
|
38
|
-
const pin = resolvePolicy("N6.pipeline", policies).policy
|
|
39
|
-
if (pin.kind === "fixed" && pin.value in PIPELINES) {
|
|
40
|
-
const id = pin.value as PipelineId
|
|
41
|
-
// A pin cannot make a reader write or a writer skip its gate into research.
|
|
42
|
-
if ((id === "P9") === (profile.role === "research") && (id !== "P3" || writer)) return { id, reason: "preset", modifiers }
|
|
43
|
-
}
|
|
44
|
-
if (profile.role === "research" && !writer) return { id: "P9", reason: "read-only research", modifiers }
|
|
45
|
-
if (!writer) return { id: "P1", reason: "a reader: one session, checks if any", modifiers }
|
|
46
|
-
let id: PipelineId
|
|
47
|
-
let reason: string
|
|
48
|
-
// omo-hybrid: lighter by default. Tests first only for a bug fix that can be shown red; a review only where the risk
|
|
49
|
-
// or a missing test oracle calls for one; everything else is P1 (checks and fix rounds).
|
|
50
|
-
if (profile.testFirst && profile.bugFix) [id, reason] = ["P3", "test first: a bug fix"]
|
|
51
|
-
else if (riskAtLeast(profile.risk, "public_api")) [id, reason] = ["P2", `risk ${profile.risk}`]
|
|
52
|
-
else if (!profile.testOracle) [id, reason] = ["P2", "no test oracle"]
|
|
53
|
-
else [id, reason] = ["P1", "small and clear, with a test oracle"]
|
|
54
|
-
return { id, reason, modifiers }
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// --- review (P2, P3) ---------------------------------------------------------------------------------------
|
|
58
|
-
|
|
59
|
-
export interface ReviewCheck {
|
|
60
|
-
readonly point: string
|
|
61
|
-
readonly met: boolean
|
|
62
|
-
readonly evidence: string
|
|
63
|
-
readonly confidence: number // 0..100; under BLOCKING_CONFIDENCE a finding is advisory (design.md §9)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export type ReviewAxis = "spec" | "standards"
|
|
67
|
-
|
|
68
|
-
export interface Review {
|
|
69
|
-
readonly verdict?: "PASS" | "FAIL"
|
|
70
|
-
readonly checks: readonly ReviewCheck[]
|
|
71
|
-
readonly fixes: readonly string[]
|
|
72
|
-
readonly blocking: readonly ReviewCheck[] // unmet points with evidence and confidence; the rest is advisory
|
|
73
|
-
readonly outside: readonly FollowUp[] // work the reviewer saw the job needs outside this task (N7 candidates)
|
|
74
|
-
readonly error?: string
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export const BLOCKING_CONFIDENCE = 80
|
|
78
|
-
|
|
79
|
-
const OUTSIDE_FORMAT = `"outside": [{"what": "work the job needs that is not this task's", "why": "...", "files": ["..."]}]`
|
|
80
|
-
|
|
81
|
-
const MAX_DIFF = 12000
|
|
82
|
-
|
|
83
|
-
export function reviewPrompt(job: Job, task: Task, acceptance: readonly Acceptance[], diff: string): string {
|
|
84
|
-
const shown = diff.length > MAX_DIFF ? `${diff.slice(0, MAX_DIFF)}\n… (cut; read the files for the rest)` : diff
|
|
85
|
-
return `${HEADER} review of task ${task.id}
|
|
86
|
-
|
|
87
|
-
The job: ${job.goal}
|
|
88
|
-
The task (${task.id}): ${task.title}
|
|
89
|
-
${task.description}
|
|
90
|
-
|
|
91
|
-
Acceptance points:
|
|
92
|
-
${acceptance.map((a) => `- ${a.id}: ${a.text}${a.verify ? ` (checked with: ${a.verify})` : ""}${sharedNote(job, task, a.id)}`).join("\n") || "- none given"}
|
|
93
|
-
|
|
94
|
-
The change (the plugin already ran the checks; they pass):
|
|
95
|
-
\`\`\`diff
|
|
96
|
-
${shown || "(no diff)"}
|
|
97
|
-
\`\`\`
|
|
98
|
-
|
|
99
|
-
Check the change against each acceptance point and the task. A point shared with other tasks counts as met when
|
|
100
|
-
this task's part of it is done; what belongs to the others is not this task's finding. Read the changed files if
|
|
101
|
-
you need more; stay in this directory. Report a point as not met only with evidence: a file and line, a failing command, or a concrete input that breaks it.
|
|
102
|
-
Answer only with JSON: {"verdict": "PASS" | "FAIL", "checks": [{"point": "A1", "met": true, "evidence": "...", "confidence": 0-100}],
|
|
103
|
-
"fixes": ["what to change, one per entry"], ${OUTSIDE_FORMAT}}`
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// The second axis (design.md §9: standards ∥ spec): not whether the task is done, but whether it is done well in this
|
|
107
|
-
// repository. Another reviewer, in parallel, so neither axis crowds out the other.
|
|
108
|
-
export function standardsPrompt(job: Job, task: Task, diff: string): string {
|
|
109
|
-
const shown = diff.length > MAX_DIFF ? `${diff.slice(0, MAX_DIFF)}\n… (cut; read the files for the rest)` : diff
|
|
110
|
-
return `${HEADER} standards review of task ${task.id}
|
|
111
|
-
|
|
112
|
-
The job: ${job.goal}
|
|
113
|
-
The task (${task.id}): ${task.title}
|
|
114
|
-
|
|
115
|
-
The change (the checks pass; another reviewer checks the acceptance points):
|
|
116
|
-
\`\`\`diff
|
|
117
|
-
${shown || "(no diff)"}
|
|
118
|
-
\`\`\`
|
|
119
|
-
|
|
120
|
-
Review the change against this repository's own standards, not your taste. Read neighbouring code first, then check:
|
|
121
|
-
- it follows the conventions around it: naming, structure, error handling, comment style;
|
|
122
|
-
- tests test behaviour through the public interface, not implementation details, and would fail if the code broke;
|
|
123
|
-
- inputs at the edges: empty, very large, non-ASCII text (umlauts, ß, emoji), missing files, concurrent calls;
|
|
124
|
-
- no dead code, debug output, commented-out code or needless new dependencies;
|
|
125
|
-
- nothing silently swallows an error, and nothing leaks a secret.
|
|
126
|
-
Only findings in this change count. Give each a confidence 0-100 that it is a real problem; below 80 it is a note.
|
|
127
|
-
Every finding needs evidence: a file and line, a command and its output, or a concrete input that breaks it.
|
|
128
|
-
Answer only with JSON: {"verdict": "PASS" | "FAIL", "checks": [{"point": "short name of the issue", "met": false, "evidence": "...", "confidence": 0-100}],
|
|
129
|
-
"fixes": ["what to change, one per entry"], ${OUTSIDE_FORMAT}}`
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// A spec finding without a confidence keeps the old meaning (evidence decides); a standards finding must give one.
|
|
133
|
-
export function parseReview(text: string, defaultConfidence = 100): Review {
|
|
134
|
-
const json = text.match(/```(?:json)?\s*\n([\s\S]*?)```/)?.[1] ?? text.slice(text.indexOf("{"), text.lastIndexOf("}") + 1)
|
|
135
|
-
let raw: { verdict?: unknown; checks?: unknown; fixes?: unknown; outside?: unknown }
|
|
136
|
-
try {
|
|
137
|
-
raw = JSON.parse(json)
|
|
138
|
-
} catch {
|
|
139
|
-
return { checks: [], fixes: [], blocking: [], outside: [], error: "the review is not JSON" }
|
|
140
|
-
}
|
|
141
|
-
const checks: ReviewCheck[] = (Array.isArray(raw.checks) ? raw.checks : [])
|
|
142
|
-
.filter((c): c is Record<string, unknown> => Boolean(c) && typeof c === "object")
|
|
143
|
-
.map((c) => ({
|
|
144
|
-
point: String(c.point ?? ""),
|
|
145
|
-
met: c.met !== false,
|
|
146
|
-
evidence: typeof c.evidence === "string" ? c.evidence.trim() : "",
|
|
147
|
-
confidence: typeof c.confidence === "number" ? Math.max(0, Math.min(100, c.confidence <= 1 ? c.confidence * 100 : c.confidence)) : defaultConfidence,
|
|
148
|
-
}))
|
|
149
|
-
const fixes = Array.isArray(raw.fixes) ? raw.fixes.filter((f): f is string => typeof f === "string" && f.trim() !== "") : []
|
|
150
|
-
const verdict = raw.verdict === "PASS" || raw.verdict === "FAIL" ? raw.verdict : undefined
|
|
151
|
-
const outside = (Array.isArray(raw.outside) ? raw.outside : [])
|
|
152
|
-
.filter((o): o is Record<string, unknown> => Boolean(o) && typeof o === "object" && typeof (o as { what?: unknown }).what === "string")
|
|
153
|
-
.map((o): FollowUp => ({ what: String(o.what), why: typeof o.why === "string" ? o.why : "", files: Array.isArray(o.files) ? o.files.filter((f): f is string => typeof f === "string") : [] }))
|
|
154
|
-
return { verdict, checks, fixes, outside, blocking: checks.filter((c) => !c.met && c.evidence.length > 0 && c.confidence >= BLOCKING_CONFIDENCE) }
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Both axes as one result: what blocks on either blocks, findings keep their axis in the point name.
|
|
158
|
-
export function mergeReviews(spec: Review, standards: Review): Review {
|
|
159
|
-
const tag = (r: Review, axis: ReviewAxis) => (c: ReviewCheck) => ({ ...c, point: axis === "spec" ? c.point : `standards: ${c.point}` })
|
|
160
|
-
const error = spec.error && standards.error ? `${spec.error}; ${standards.error}` : undefined
|
|
161
|
-
return {
|
|
162
|
-
verdict: spec.verdict === "FAIL" || standards.verdict === "FAIL" ? "FAIL" : spec.verdict ?? standards.verdict,
|
|
163
|
-
checks: [...spec.checks.map(tag(spec, "spec")), ...standards.checks.map(tag(standards, "standards"))],
|
|
164
|
-
fixes: [...spec.fixes, ...standards.fixes],
|
|
165
|
-
blocking: [...spec.blocking.map(tag(spec, "spec")), ...standards.blocking.map(tag(standards, "standards"))],
|
|
166
|
-
outside: [...spec.outside, ...standards.outside],
|
|
167
|
-
...(error ? { error } : {}),
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function reviewFixPrompt(review: Review): string {
|
|
172
|
-
const points = review.blocking.map((c) => `- ${c.point}: ${c.evidence}`).join("\n")
|
|
173
|
-
const fixes = review.fixes.length ? `\nSuggested fixes:\n${review.fixes.map((f) => `- ${f}`).join("\n")}` : ""
|
|
174
|
-
return `${HEADER} Reviewers of another model family found problems (acceptance points not met, or "standards:" findings about how it is done):\n${points}${fixes}\n\nFix them in your task's files, then report again in the same format.`
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// --- tests first (P3) --------------------------------------------------------------------------------------
|
|
178
|
-
|
|
179
|
-
export const TEST_FILE = /(^|\/)(tests?|__tests__|spec)\/|[._-](test|spec)\.[a-z]+$|(^|\/)test_[^/]+\.py$/
|
|
180
|
-
|
|
181
|
-
export function redPrompt(task: Task, testFiles: readonly string[]): string {
|
|
182
|
-
return `${HEADER} tests first for task ${task.id}
|
|
183
|
-
|
|
184
|
-
Before anything is implemented, write the tests for this task's acceptance points, and nothing else.
|
|
185
|
-
${testFiles.length ? `Write them in: ${testFiles.join(", ")}.` : "Put them in new test files next to the code, named like the project's existing tests."}
|
|
186
|
-
The tests must fail now, because the behaviour does not exist yet, and pass once it is built as described.
|
|
187
|
-
Do not write the implementation. Run the tests once and show that they fail for the right reason.`
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export function greenNote(frozen: readonly string[]): string {
|
|
191
|
-
return `Tests for this task already exist and are frozen: ${frozen.join(", ")}. Make them pass without changing them.`
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// --- research (P9) -----------------------------------------------------------------------------------------
|
|
195
|
-
|
|
196
|
-
const ANGLES = [
|
|
197
|
-
"the official documentation and specifications",
|
|
198
|
-
"source code and repositories",
|
|
199
|
-
"issue trackers, changelogs and discussions",
|
|
200
|
-
"papers, benchmarks and long-form articles",
|
|
201
|
-
"alternatives and how others solved it",
|
|
202
|
-
]
|
|
203
|
-
|
|
204
|
-
// 1 reader for an easy question, 3 for a moderate one, 5 for a hard one (design.md §13.3: 1 / 2–4 / 5+).
|
|
205
|
-
export function readerCount(difficulty: number): number {
|
|
206
|
-
return difficulty < 0.34 ? 1 : difficulty < 0.67 ? 3 : 5
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export function readerPrompt(job: Job, task: Task, i: number, n: number): string {
|
|
210
|
-
const angle = n > 1 ? `\nYou are reader ${i + 1} of ${n}. Look mainly at ${ANGLES[i % ANGLES.length]}; the others cover the rest.` : ""
|
|
211
|
-
return `${HEADER} research for task ${task.id}
|
|
212
|
-
|
|
213
|
-
The job: ${job.goal}
|
|
214
|
-
The question (${task.id}): ${task.title}
|
|
215
|
-
${task.description}${angle}
|
|
216
|
-
|
|
217
|
-
Use primary sources. For every finding give the URL it comes from. Change no files.
|
|
218
|
-
Answer with the findings as a list, each with its URL; then what stayed unclear.
|
|
219
|
-
${CAVEMAN}`
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export function synthesisPrompt(job: Job, task: Task, path: string, notes: readonly string[]): string {
|
|
223
|
-
return `${HEADER} synthesis for task ${task.id}
|
|
224
|
-
|
|
225
|
-
The job: ${job.goal}
|
|
226
|
-
The question (${task.id}): ${task.title}
|
|
227
|
-
${task.description}
|
|
228
|
-
|
|
229
|
-
Readers found the following:
|
|
230
|
-
${notes.map((n, i) => `--- reader ${i + 1} ---\n${n}`).join("\n\n")}
|
|
231
|
-
|
|
232
|
-
Write ${path} in clear English prose: the answer first, then the evidence. Cite every claim with the URL from the
|
|
233
|
-
readers' notes, inline as a Markdown link. Use only URLs the readers gave; leave out what no reader sourced.
|
|
234
|
-
Change no other file.`
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const URL = /https?:\/\/[^\s)<>\]"'`]+/g
|
|
238
|
-
|
|
239
|
-
const clean = (u: string) => u.replace(/[.,;:!?]+$/, "")
|
|
240
|
-
|
|
241
|
-
// Every URL in the synthesis must come from a reader; a synthesis without any URL cites nothing.
|
|
242
|
-
export function citationCheck(doc: string, notes: readonly string[]): { ok: boolean; unknown: string[]; cited: number } {
|
|
243
|
-
const known = new Set(notes.flatMap((n) => (n.match(URL) ?? []).map(clean)))
|
|
244
|
-
const cited = [...new Set((doc.match(URL) ?? []).map(clean))]
|
|
245
|
-
const unknown = cited.filter((u) => !known.has(u))
|
|
246
|
-
return { ok: cited.length > 0 && unknown.length === 0, unknown, cited: cited.length }
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function researchPath(task: Task): string {
|
|
250
|
-
const slug = task.title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 60) || task.id.toLowerCase()
|
|
251
|
-
return `docs/research/${slug}.md`
|
|
252
|
-
}
|