@oalo-ai/cli 0.5.1 → 0.7.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 +45 -10
- package/man/oalo.1 +359 -16
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +2 -2
- package/plugin/skills/oalo/SKILL.md +124 -30
- package/src/agents/harness.js +357 -0
- package/src/agents/roles.js +339 -0
- package/src/agents/worktree.js +155 -0
- package/src/commands/auto.js +239 -0
- package/src/commands/bots.js +2 -2
- package/src/commands/crm.js +114 -0
- package/src/commands/db.js +2 -1
- package/src/commands/heal.js +141 -0
- package/src/commands/inbox.js +127 -0
- package/src/commands/link.js +1 -1
- package/src/commands/race.js +390 -0
- package/src/commands/ralph.js +302 -0
- package/src/commands/review.js +233 -0
- package/src/commands/serve.js +1 -1
- package/src/commands/skill.js +15 -5
- package/src/commands/swarm.js +457 -0
- package/src/commands/switches.js +32 -1
- package/src/commands/usage.js +66 -0
- package/src/coord-release.json +9 -9
- package/src/help.js +225 -15
- package/src/index.js +36 -0
- package/src/mcp/describe.js +3 -2
- package/src/mcp/tools.js +84 -2
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strategy 4: `oalo review` — Independent adversarial / cross-model diff
|
|
3
|
+
* critic. Also imported by `oalo coord` (`mergeOne`) when `reviewer` is set
|
|
4
|
+
* in `.oalo/coord.json`.
|
|
5
|
+
*
|
|
6
|
+
* The critic sees ONLY the git diff and acceptance criteria (never the author's
|
|
7
|
+
* chat history or rationalizations) and runs in read-only mode.
|
|
8
|
+
*/
|
|
9
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
+
import { runAgent, parseHarnessList, detectDefaultHarness, extractJsonObject } from "../agents/harness.js";
|
|
11
|
+
import { requireProjectRoot, gitTry } from "../agents/worktree.js";
|
|
12
|
+
|
|
13
|
+
const USAGE = `usage:
|
|
14
|
+
oalo review [--against <ref>] [--models <spec1,spec2>] [--criteria <text|file>] [--working] [--strict] [--timeout <s>] [--json]
|
|
15
|
+
|
|
16
|
+
examples:
|
|
17
|
+
oalo review --against main --models claude:sonnet,opencode:openrouter/deepseek/deepseek-v4.1-flash
|
|
18
|
+
oalo review --working --strict`;
|
|
19
|
+
|
|
20
|
+
const MAX_DIFF_CHARS = 80_000;
|
|
21
|
+
|
|
22
|
+
function buildCriticPrompt({ title, diff, criteria, stat }) {
|
|
23
|
+
const critList = Array.isArray(criteria)
|
|
24
|
+
? criteria.filter(Boolean)
|
|
25
|
+
: typeof criteria === "string" && criteria.trim()
|
|
26
|
+
? [criteria.trim()]
|
|
27
|
+
: [];
|
|
28
|
+
|
|
29
|
+
return [
|
|
30
|
+
"# Independent Code Review (Adversarial Critic)",
|
|
31
|
+
"",
|
|
32
|
+
"You are an independent reviewer who did NOT write this change. Judge ONLY the diff and acceptance criteria below.",
|
|
33
|
+
"Do not modify any files.",
|
|
34
|
+
title ? `\n## Change Title\n${title}` : "",
|
|
35
|
+
critList.length ? `\n## Acceptance Criteria\n${critList.map((c) => `- ${c}`).join("\n")}` : "",
|
|
36
|
+
stat ? `\n## Diffstat\n\`\`\`\n${stat}\n\`\`\`` : "",
|
|
37
|
+
"\n## Git Diff",
|
|
38
|
+
"```diff",
|
|
39
|
+
diff.length > MAX_DIFF_CHARS ? `${diff.slice(0, MAX_DIFF_CHARS)}\n... [diff truncated at ${MAX_DIFF_CHARS} chars]` : diff,
|
|
40
|
+
"```",
|
|
41
|
+
"",
|
|
42
|
+
"## Output Format (STRICT JSON ONLY)",
|
|
43
|
+
"Return a single JSON object matching this exact schema (no prose outside the JSON):",
|
|
44
|
+
"```json",
|
|
45
|
+
JSON.stringify(
|
|
46
|
+
{
|
|
47
|
+
verdict: "approve | request_changes",
|
|
48
|
+
summary: "1-2 sentence overall assessment",
|
|
49
|
+
findings: [
|
|
50
|
+
{
|
|
51
|
+
severity: "blocker | major | minor",
|
|
52
|
+
file: "path/to/file",
|
|
53
|
+
line: 42,
|
|
54
|
+
issue: "Concrete defect or unmet criterion",
|
|
55
|
+
suggestion: "Specific fix",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
null,
|
|
60
|
+
2,
|
|
61
|
+
),
|
|
62
|
+
"```",
|
|
63
|
+
"Use `request_changes` if there is any bug, regression, security flaw, broken contract, or unmet acceptance criterion.",
|
|
64
|
+
]
|
|
65
|
+
.filter(Boolean)
|
|
66
|
+
.join("\n");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function normalizeCriticResult(res, strict) {
|
|
70
|
+
const obj = extractJsonObject(res.text) || (res.structured && typeof res.structured === "object" && "verdict" in res.structured ? res.structured : null);
|
|
71
|
+
if (!obj || !["approve", "request_changes"].includes(obj.verdict)) {
|
|
72
|
+
return {
|
|
73
|
+
label: res.label,
|
|
74
|
+
harness: res.harness,
|
|
75
|
+
model: res.model,
|
|
76
|
+
ok: res.ok,
|
|
77
|
+
verdict: strict || !res.ok ? "request_changes" : "approve",
|
|
78
|
+
parse_warning: "critic did not return structured JSON verdict",
|
|
79
|
+
summary: (res.text || res.stderr || "unparseable critic output").slice(0, 400),
|
|
80
|
+
findings: strict || !res.ok ? [{ severity: "major", file: "", line: null, issue: "unstructured or failed critic run", suggestion: (res.stderr || res.text || "").slice(0, 200) }] : [],
|
|
81
|
+
cost_usd: Number((res.costUsd || 0).toFixed(6)),
|
|
82
|
+
duration_ms: res.durationMs,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const findings = Array.isArray(obj.findings) ? obj.findings : [];
|
|
86
|
+
const hasBlocker = findings.some((f) => String(f?.severity || "").toLowerCase() === "blocker");
|
|
87
|
+
const verdict = hasBlocker ? "request_changes" : obj.verdict;
|
|
88
|
+
return {
|
|
89
|
+
label: res.label,
|
|
90
|
+
harness: res.harness,
|
|
91
|
+
model: res.model,
|
|
92
|
+
ok: res.ok,
|
|
93
|
+
verdict,
|
|
94
|
+
summary: String(obj.summary || "").trim(),
|
|
95
|
+
findings,
|
|
96
|
+
cost_usd: Number((res.costUsd || 0).toFixed(6)),
|
|
97
|
+
duration_ms: res.durationMs,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export async function runCriticReview({
|
|
102
|
+
cwd = process.cwd(),
|
|
103
|
+
against = null,
|
|
104
|
+
working = false,
|
|
105
|
+
diff = null,
|
|
106
|
+
stat = null,
|
|
107
|
+
title = "",
|
|
108
|
+
criteria = [],
|
|
109
|
+
models = null,
|
|
110
|
+
strict = false,
|
|
111
|
+
timeoutS = 300,
|
|
112
|
+
quiet = false,
|
|
113
|
+
} = {}) {
|
|
114
|
+
let diffText = diff;
|
|
115
|
+
let diffStat = stat;
|
|
116
|
+
|
|
117
|
+
if (diffText == null) {
|
|
118
|
+
const root = requireProjectRoot(cwd);
|
|
119
|
+
if (working) {
|
|
120
|
+
diffText = gitTry(root, ["diff", "HEAD"]).stdout;
|
|
121
|
+
diffStat = gitTry(root, ["diff", "--stat", "HEAD"]).stdout;
|
|
122
|
+
} else {
|
|
123
|
+
const ref = against || (gitTry(root, ["rev-parse", "--verify", "main"]).ok ? "main" : "HEAD~1");
|
|
124
|
+
diffText = gitTry(root, ["diff", `${ref}...HEAD`]).stdout;
|
|
125
|
+
diffStat = gitTry(root, ["diff", "--stat", `${ref}...HEAD`]).stdout;
|
|
126
|
+
if (!diffText) {
|
|
127
|
+
diffText = gitTry(root, ["diff", ref]).stdout;
|
|
128
|
+
diffStat = gitTry(root, ["diff", "--stat", ref]).stdout;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (!diffText || !diffText.trim()) {
|
|
134
|
+
return {
|
|
135
|
+
approved: true,
|
|
136
|
+
empty_diff: true,
|
|
137
|
+
verdict: "approve",
|
|
138
|
+
critics: [],
|
|
139
|
+
findings: [],
|
|
140
|
+
total_cost_usd: 0,
|
|
141
|
+
formatted_feedback: "No diff to review.",
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const specs = parseHarnessList(models);
|
|
146
|
+
if (!specs.length) specs.push(...parseHarnessList(detectDefaultHarness()));
|
|
147
|
+
|
|
148
|
+
const log = (msg) => {
|
|
149
|
+
if (!quiet) console.error(`[review] ${msg}`);
|
|
150
|
+
};
|
|
151
|
+
log(`running ${specs.length} independent critic(s): ${specs.map((s) => s.label).join(", ")}`);
|
|
152
|
+
|
|
153
|
+
const prompt = buildCriticPrompt({ title, diff: diffText, criteria, stat: diffStat });
|
|
154
|
+
const timeoutMs = Math.max(5, Number(timeoutS || 300)) * 1000;
|
|
155
|
+
|
|
156
|
+
const rawResults = await Promise.all(
|
|
157
|
+
specs.map((spec, idx) =>
|
|
158
|
+
runAgent({
|
|
159
|
+
harness: spec,
|
|
160
|
+
prompt,
|
|
161
|
+
cwd,
|
|
162
|
+
readonly: true,
|
|
163
|
+
timeoutMs,
|
|
164
|
+
env: {
|
|
165
|
+
OALO_REVIEW_CRITIC_INDEX: String(idx + 1),
|
|
166
|
+
OALO_REVIEW_TITLE: title || "",
|
|
167
|
+
},
|
|
168
|
+
}),
|
|
169
|
+
),
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const critics = rawResults.map((r) => normalizeCriticResult(r, strict));
|
|
173
|
+
const approved = critics.every((c) => c.verdict === "approve");
|
|
174
|
+
const allFindings = critics.flatMap((c) => c.findings.map((f) => ({ critic: c.label, ...f })));
|
|
175
|
+
const totalCost = critics.reduce((sum, c) => sum + (c.cost_usd || 0), 0);
|
|
176
|
+
|
|
177
|
+
const feedbackLines = [];
|
|
178
|
+
for (const c of critics) {
|
|
179
|
+
feedbackLines.push(`[${c.label}] ${c.verdict.toUpperCase()}: ${c.summary}`);
|
|
180
|
+
for (const f of c.findings) {
|
|
181
|
+
const loc = f.file ? `${f.file}${f.line ? `:${f.line}` : ""}` : "general";
|
|
182
|
+
feedbackLines.push(` - (${f.severity || "major"}) ${loc}: ${f.issue}${f.suggestion ? ` -> ${f.suggestion}` : ""}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
approved,
|
|
188
|
+
verdict: approved ? "approve" : "request_changes",
|
|
189
|
+
critics,
|
|
190
|
+
findings: allFindings,
|
|
191
|
+
total_cost_usd: Number(totalCost.toFixed(6)),
|
|
192
|
+
formatted_feedback: feedbackLines.join("\n"),
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export async function review(flags, rest) {
|
|
197
|
+
if (flags.help || rest[1] === "help") {
|
|
198
|
+
console.log(USAGE);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
let criteria = [];
|
|
202
|
+
if (typeof flags.criteria === "string") {
|
|
203
|
+
if (existsSync(flags.criteria)) {
|
|
204
|
+
criteria = readFileSync(flags.criteria, "utf8")
|
|
205
|
+
.split("\n")
|
|
206
|
+
.map((l) => l.replace(/^\s*[-*]\s*/, "").trim())
|
|
207
|
+
.filter(Boolean);
|
|
208
|
+
} else {
|
|
209
|
+
criteria = [flags.criteria];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const res = await runCriticReview({
|
|
214
|
+
cwd: process.cwd(),
|
|
215
|
+
against: typeof flags.against === "string" ? flags.against : null,
|
|
216
|
+
working: !!flags.working,
|
|
217
|
+
models: typeof flags.models === "string" ? flags.models : typeof flags.harness === "string" ? flags.harness : null,
|
|
218
|
+
criteria,
|
|
219
|
+
strict: !!flags.strict,
|
|
220
|
+
timeoutS: flags.timeout ? Number(flags.timeout) : 300,
|
|
221
|
+
quiet: !!flags.json,
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
if (flags.json) {
|
|
225
|
+
console.log(JSON.stringify(res, null, 2));
|
|
226
|
+
} else if (res.empty_diff) {
|
|
227
|
+
console.log("oalo review: no diff to review (approve)");
|
|
228
|
+
} else {
|
|
229
|
+
console.log(`\nReview Verdict: ${res.verdict.toUpperCase()} (cost $${res.total_cost_usd.toFixed(4)})`);
|
|
230
|
+
console.log(res.formatted_feedback);
|
|
231
|
+
}
|
|
232
|
+
if (!res.approved) process.exit(1);
|
|
233
|
+
}
|
package/src/commands/serve.js
CHANGED
|
@@ -357,7 +357,7 @@ async function test(cfg, name, json, flags, opts) {
|
|
|
357
357
|
return;
|
|
358
358
|
}
|
|
359
359
|
console.log(JSON.stringify(r.output, null, 2));
|
|
360
|
-
console.error(dim(`ok in ${ms} ms, ${size(Buffer.byteLength(JSON.stringify(r.output)))} (max
|
|
360
|
+
console.error(dim(`ok in ${ms} ms, ${size(Buffer.byteLength(JSON.stringify(r.output)))} (max 1 MB)`));
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
/**
|
package/src/commands/skill.js
CHANGED
|
@@ -38,9 +38,10 @@ export function skillHash() {
|
|
|
38
38
|
|
|
39
39
|
const body = (md) => md.replace(/^---\n[\s\S]*?\n---\n+/, "");
|
|
40
40
|
const skillPath = (cwd) => join(cwd, ".claude", "skills", "oalo", "SKILL.md");
|
|
41
|
+
const openSkillPath = (cwd) => join(cwd, ".agents", "skills", "oalo", "SKILL.md");
|
|
41
42
|
|
|
42
43
|
// The packaged skill with a stamp line after its front matter (the front matter
|
|
43
|
-
// must stay first for
|
|
44
|
+
// must stay first for agent harnesses to read it).
|
|
44
45
|
function stamped() {
|
|
45
46
|
const md = readFileSync(SKILL, "utf8");
|
|
46
47
|
const stamp = `<!-- oalo-cli ${CLI_VERSION} (skill ${skillHash()}) wrote this copy; \`oalo skill\` updates it. -->\n\n`;
|
|
@@ -49,8 +50,9 @@ function stamped() {
|
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
|
-
* Write the skill into `cwd`
|
|
53
|
-
*
|
|
53
|
+
* Write the skill into `cwd` for both the open cross-harness standard
|
|
54
|
+
* (`.agents/skills/oalo/SKILL.md`) and Claude Code (`.claude/skills/oalo/SKILL.md`),
|
|
55
|
+
* plus the `AGENTS.md` section when `agents` is true or `AGENTS.md` already has one.
|
|
54
56
|
*/
|
|
55
57
|
export function installSkill(cwd = process.cwd(), { agents = false } = {}) {
|
|
56
58
|
const md = stamped();
|
|
@@ -58,6 +60,10 @@ export function installSkill(cwd = process.cwd(), { agents = false } = {}) {
|
|
|
58
60
|
mkdirSync(dirname(target), { recursive: true });
|
|
59
61
|
writeFileSync(target, md);
|
|
60
62
|
|
|
63
|
+
const openTarget = openSkillPath(cwd);
|
|
64
|
+
mkdirSync(dirname(openTarget), { recursive: true });
|
|
65
|
+
writeFileSync(openTarget, md);
|
|
66
|
+
|
|
61
67
|
const agentsPath = join(cwd, "AGENTS.md");
|
|
62
68
|
const current = existsSync(agentsPath) ? readFileSync(agentsPath, "utf8") : "";
|
|
63
69
|
const at = current.indexOf(START);
|
|
@@ -74,7 +80,11 @@ export function installSkill(cwd = process.cwd(), { agents = false } = {}) {
|
|
|
74
80
|
agentsResult = at >= 0 ? "updated" : "added";
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
return {
|
|
83
|
+
return {
|
|
84
|
+
path: target.slice(cwd.length + 1),
|
|
85
|
+
openPath: openTarget.slice(cwd.length + 1),
|
|
86
|
+
agents: agentsResult,
|
|
87
|
+
};
|
|
78
88
|
}
|
|
79
89
|
|
|
80
90
|
/**
|
|
@@ -136,7 +146,7 @@ export async function skill(flags) {
|
|
|
136
146
|
}
|
|
137
147
|
|
|
138
148
|
const r = installSkill(process.cwd(), { agents: !!flags.agents });
|
|
139
|
-
console.log(`installed ${r.path}`);
|
|
149
|
+
console.log(`installed ${r.openPath} and ${r.path}`);
|
|
140
150
|
if (r.agents) console.log(`${r.agents} the Oalo section in AGENTS.md`);
|
|
141
151
|
console.log(dim(`From CLI ${CLI_VERSION}. Run \`oalo skill\` again after updating the CLI.`));
|
|
142
152
|
}
|