@olegkoval/agent-skills 1.88.0 → 1.90.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/adapters/claude/olko-github-pr/skills/lekker-review/SKILL.md +112 -20
- package/adapters/claude/olko-github-pr/skills/lekker-review/references/codex-workflow.md +12 -0
- package/adapters/claude/olko-github-pr/skills/lekker-review/references/github-post.md +3 -2
- package/adapters/claude/olko-github-pr/skills/lekker-review/references/output-format.md +23 -2
- package/adapters/claude/olko-github-pr/skills/lekker-review/references/traces.md +1 -1
- package/adapters/claude/olko-github-pr/skills/lekker-review/scripts/lekker-progress.mjs +106 -0
- package/adapters/claude/olko-github-pr/skills/lekker-review/scripts/model-matrix.mjs +152 -0
- package/adapters/claude/olko-github-pr/skills/lekker-review/scripts/run-log.mjs +27 -2
- package/adapters/claude/olko-github-pr/skills/lekker-review/scripts/selftest.mjs +1 -1
- package/package.json +1 -1
- package/plugins/olko-apple-kit/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-creative/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-garmin-kit/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-git-tools/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-github-pr/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-github-pr/skills/lekker-review/README.md +53 -0
- package/plugins/olko-github-pr/skills/lekker-review/SKILL.md +112 -20
- package/plugins/olko-github-pr/skills/lekker-review/fix-workflow.js +21 -8
- package/plugins/olko-github-pr/skills/lekker-review/references/codex-workflow.md +12 -0
- package/plugins/olko-github-pr/skills/lekker-review/references/github-post.md +3 -2
- package/plugins/olko-github-pr/skills/lekker-review/references/output-format.md +23 -2
- package/plugins/olko-github-pr/skills/lekker-review/references/traces.md +1 -1
- package/plugins/olko-github-pr/skills/lekker-review/scripts/lekker-progress.mjs +106 -0
- package/plugins/olko-github-pr/skills/lekker-review/scripts/model-matrix.mjs +152 -0
- package/plugins/olko-github-pr/skills/lekker-review/scripts/run-log.mjs +27 -2
- package/plugins/olko-github-pr/skills/lekker-review/scripts/selftest.mjs +1 -1
- package/plugins/olko-github-pr/skills/lekker-review/workflow.js +79 -23
- package/plugins/olko-obsidian/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-product/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-reflection/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-release/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-skill-meta/.claude-plugin/plugin.json +1 -1
- package/plugins/olko-web-ops/.claude-plugin/plugin.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// One-line progress status for lekker-review: a boat drifts over a tide line toward a lighthouse.
|
|
3
|
+
//
|
|
4
|
+
// Usage: node lekker-progress.mjs --stage <stage> --message "<short fact>" [--ascii]
|
|
5
|
+
//
|
|
6
|
+
// Each call prints exactly one line and exits 0, even on bad arguments. On a TTY it first animates
|
|
7
|
+
// the drift on that line (at most 10 fps, under a second); anywhere else (captured tool output, a
|
|
8
|
+
// log) or with NO_COLOR or --ascii it prints the final frame only, with no escape codes.
|
|
9
|
+
// The `decision` stage prints a compass line and leaves the boat where it was.
|
|
10
|
+
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
12
|
+
|
|
13
|
+
export const SLOTS = 8;
|
|
14
|
+
export const MAX_WIDTH = 72;
|
|
15
|
+
const FRAME_MS = 100;
|
|
16
|
+
|
|
17
|
+
// stage -> [slot the boat reaches, mood, default message]
|
|
18
|
+
export const STAGES = {
|
|
19
|
+
start: [0, 'neutral', 'parsed the request'],
|
|
20
|
+
context: [1, 'neutral', 'context ready'],
|
|
21
|
+
review: [2, 'neutral', 'review agents started'],
|
|
22
|
+
verify: [3, 'neutral', 'verifying findings'],
|
|
23
|
+
critic: [4, 'neutral', 'completeness critic'],
|
|
24
|
+
prove: [5, 'neutral', 'proving bugs with tests'],
|
|
25
|
+
fix: [6, 'neutral', 'applying fixes'],
|
|
26
|
+
post: [7, 'neutral', 'posting the review'],
|
|
27
|
+
success: [SLOTS, 'happy', 'review saved'],
|
|
28
|
+
failure: [4, 'sad', 'review stopped'],
|
|
29
|
+
decision: [null, 'neutral', 'decision'],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const GLYPHS = {
|
|
33
|
+
false: { boat: '⛵', light: '🗼', tide: ' ~', compass: '🧭 ', neutral: '', happy: '😌', sad: '🌧️' },
|
|
34
|
+
true: { boat: '^', light: 'I', tide: '.', compass: '> ', neutral: '', happy: '(^o^)', sad: '(T.T)' },
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const WIDE = [[0x1100, 0x115f], [0x231a, 0x231b], [0x23e9, 0x23ec], [0x25fd, 0x25fe], [0x2614, 0x2615],
|
|
38
|
+
[0x2693, 0x2693], [0x26a1, 0x26a1], [0x26f5, 0x26f5], [0x2e80, 0xa4cf], [0xac00, 0xd7a3],
|
|
39
|
+
[0xf900, 0xfaff], [0xfe30, 0xfe6f], [0xff00, 0xff60], [0xffe0, 0xffe6], [0x1f000, 0x1ffff]];
|
|
40
|
+
|
|
41
|
+
function cellWidth(ch) {
|
|
42
|
+
const cp = ch.codePointAt(0);
|
|
43
|
+
if (/\p{M}/u.test(ch) || cp === 0x200d || cp === 0xfe0f) return 0;
|
|
44
|
+
return WIDE.some(([lo, hi]) => cp >= lo && cp <= hi) ? 2 : 1;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const width = (text) => [...text].reduce((n, ch) => n + cellWidth(ch), 0);
|
|
48
|
+
|
|
49
|
+
export function truncate(text, limit) {
|
|
50
|
+
const { out, done } = [...text].reduce((acc, ch) => {
|
|
51
|
+
if (acc.done) return acc;
|
|
52
|
+
const next = acc.used + cellWidth(ch);
|
|
53
|
+
return next > limit - 1 ? { ...acc, done: true } : { out: acc.out + ch, used: next, done: false };
|
|
54
|
+
}, { out: '', used: 0, done: false });
|
|
55
|
+
return done ? `${out}…` : out;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const oneLine = (text) => String(text ?? '').split(/\s+/).filter(Boolean).join(' ');
|
|
59
|
+
const fit = (line) => (width(line) <= MAX_WIDTH ? line : truncate(line, MAX_WIDTH));
|
|
60
|
+
|
|
61
|
+
function track(slot, glyphs) {
|
|
62
|
+
const cells = Array.from({ length: SLOTS + 1 }, (_, i) => (i === SLOTS ? glyphs.light : glyphs.tide));
|
|
63
|
+
return cells.map((cell, i) => (i === Math.min(slot, SLOTS) ? glyphs.boat : cell)).join('');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Pure: `tick` is the boat's slot. The mood face shows once the boat has arrived.
|
|
67
|
+
export function frame(stage, tick, { message, ascii = false } = {}) {
|
|
68
|
+
const spec = STAGES[stage];
|
|
69
|
+
const glyphs = GLYPHS[ascii === true];
|
|
70
|
+
const text = oneLine(message ?? spec?.[2] ?? '');
|
|
71
|
+
if (!spec) return fit(`lekker: ${text || stage || 'progress'}`);
|
|
72
|
+
const [target, mood] = spec;
|
|
73
|
+
if (target === null) return fit(`${glyphs.compass}${text || spec[2]}`);
|
|
74
|
+
const face = tick >= target ? glyphs[mood] : '';
|
|
75
|
+
return fit(`${`${track(tick, glyphs)} ${face}`.trimEnd()} ${stage}: ${text}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const arg = (argv, name) => {
|
|
79
|
+
const i = argv.indexOf(`--${name}`);
|
|
80
|
+
return i === -1 ? undefined : argv[i + 1];
|
|
81
|
+
};
|
|
82
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
83
|
+
|
|
84
|
+
async function main(argv) {
|
|
85
|
+
const stage = arg(argv, 'stage') ?? '';
|
|
86
|
+
const message = arg(argv, 'message');
|
|
87
|
+
const ascii = argv.includes('--ascii') || Boolean(process.env.LEKKER_PROGRESS_ASCII);
|
|
88
|
+
const spec = STAGES[stage];
|
|
89
|
+
const animate = process.stdout.isTTY === true && !process.env.NO_COLOR && !ascii && Array.isArray(spec) && spec[0] !== null;
|
|
90
|
+
if (animate) {
|
|
91
|
+
const target = spec[0];
|
|
92
|
+
const slots = Array.from({ length: Math.min(3, target) }, (_, i) => target - 3 + i).filter((s) => s >= 0);
|
|
93
|
+
for (const slot of slots) {
|
|
94
|
+
process.stdout.write(`\r\x1b[2K${frame(stage, slot, { message, ascii })}`);
|
|
95
|
+
await sleep(FRAME_MS);
|
|
96
|
+
}
|
|
97
|
+
process.stdout.write('\r\x1b[2K');
|
|
98
|
+
}
|
|
99
|
+
const target = spec && spec[0] !== null ? spec[0] : 0;
|
|
100
|
+
process.stdout.write(`${frame(stage, target, { message, ascii })}\n`);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
104
|
+
try { await main(process.argv.slice(2)); } catch { /* decoration must never fail a review */ }
|
|
105
|
+
process.exitCode = 0;
|
|
106
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Model and effort per lekker agent, picked from the PR's risk tier.
|
|
3
|
+
//
|
|
4
|
+
// Depth decides how many agents run; the tier decides how strong each one is.
|
|
5
|
+
// Effort comes before model size: a tier escalates effort first and moves to a
|
|
6
|
+
// bigger model only for risky changes. Finders stay one step below the gate
|
|
7
|
+
// (verifier), because the verifier decides what survives. The fast models
|
|
8
|
+
// (haiku, luna) only ever do first-pass triage or housekeeping.
|
|
9
|
+
//
|
|
10
|
+
// node model-matrix.mjs --host claude|codex [--risk <tier>] [--lines <n>]
|
|
11
|
+
// [--categories auth,billing,...] -- <changed-file>...
|
|
12
|
+
//
|
|
13
|
+
// `--categories` is the comma-joined `categories[].category` list from
|
|
14
|
+
// risk-paths.mjs. `--lines` is additions+deletions without lockfiles.
|
|
15
|
+
// Prints {host, tier, tierSource, reasons, visual, routing}.
|
|
16
|
+
import { pathToFileURL } from 'node:url'
|
|
17
|
+
|
|
18
|
+
export const TIERS = ['routine', 'standard', 'elevated', 'critical']
|
|
19
|
+
export const HOSTS = ['claude', 'codex']
|
|
20
|
+
export const EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max']
|
|
21
|
+
|
|
22
|
+
// Roles that decide whether a finding survives. Never a fast model.
|
|
23
|
+
export const GATE_ROLES = ['verifier', 'critic']
|
|
24
|
+
|
|
25
|
+
const r = (model, effort) => ({ model, effort })
|
|
26
|
+
const same = cell => [cell, cell, cell, cell]
|
|
27
|
+
|
|
28
|
+
// One row per role: [routine, standard, elevated, critical].
|
|
29
|
+
export const MATRIX = {
|
|
30
|
+
claude: {
|
|
31
|
+
triage: same(r('haiku', 'medium')),
|
|
32
|
+
specialist: [r('sonnet', 'medium'), r('sonnet', 'high'), r('opus', 'high'), r('opus', 'xhigh')],
|
|
33
|
+
rules: [r('sonnet', 'medium'), r('sonnet', 'medium'), r('sonnet', 'high'), r('sonnet', 'high')],
|
|
34
|
+
verifier: [r('sonnet', 'high'), r('sonnet', 'high'), r('opus', 'high'), r('fable', 'high')],
|
|
35
|
+
critic: [r('sonnet', 'medium'), r('sonnet', 'high'), r('opus', 'high'), r('fable', 'xhigh')],
|
|
36
|
+
prover: [r('sonnet', 'high'), r('sonnet', 'high'), r('sonnet', 'high'), r('opus', 'high')],
|
|
37
|
+
fixer: [r('sonnet', 'high'), r('sonnet', 'high'), r('sonnet', 'high'), r('opus', 'high')],
|
|
38
|
+
polish: same(r('sonnet', 'medium')),
|
|
39
|
+
housekeeping: same(r('haiku', 'low')),
|
|
40
|
+
},
|
|
41
|
+
codex: {
|
|
42
|
+
triage: same(r('gpt-6-luna', 'medium')),
|
|
43
|
+
specialist: [r('gpt-6.2-sol', 'medium'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-astra', 'high'), r('gpt-6.2-astra', 'xhigh')],
|
|
44
|
+
rules: [r('gpt-6.2-sol', 'medium'), r('gpt-6.2-sol', 'medium'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-sol', 'high')],
|
|
45
|
+
verifier: [r('gpt-6.2-sol', 'high'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-astra', 'high'), r('gpt-6.2-astra', 'high')],
|
|
46
|
+
critic: [r('gpt-6.2-sol', 'medium'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-astra', 'high'), r('gpt-6.2-astra', 'xhigh')],
|
|
47
|
+
prover: [r('gpt-6.2-sol', 'high'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-astra', 'high')],
|
|
48
|
+
fixer: [r('gpt-6.2-sol', 'high'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-sol', 'high'), r('gpt-6.2-astra', 'high')],
|
|
49
|
+
polish: same(r('gpt-6.2-sol', 'medium')),
|
|
50
|
+
housekeeping: same(r('gpt-6-luna', 'low')),
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// A UI-only diff: Codex has a model positioned for visual reasoning.
|
|
55
|
+
const VISUAL_SPECIALIST = { codex: r('gpt-6.1-terra', 'high') }
|
|
56
|
+
|
|
57
|
+
export const FAST_MODELS = ['haiku', 'gpt-6-luna']
|
|
58
|
+
|
|
59
|
+
const DOC_FILE = /(^|\/)(docs?\/.*|[^/]+\.(md|mdx|txt|rst)|LICENSE[^/]*)$/i
|
|
60
|
+
const UI_FILE = /\.(tsx|jsx|vue|svelte|css|scss|sass|less|liquid|html)$/i
|
|
61
|
+
const TEST_FILE = /(^|\/)(__tests__|tests?|spec)\/|\.(test|spec)\.[a-z]+$/i
|
|
62
|
+
const MIGRATION_FILE = /(^|\/)migrations?\/|\.sql$/i
|
|
63
|
+
|
|
64
|
+
const CRITICAL_CATEGORIES = ['auth', 'billing']
|
|
65
|
+
const ELEVATED_CATEGORIES = ['ci-workflow', 'installer']
|
|
66
|
+
const DEEP_LINES = 800
|
|
67
|
+
const DEEP_FILES = 25
|
|
68
|
+
|
|
69
|
+
// Each rule: [tier, reason, test]. First match wins, so order is severity order.
|
|
70
|
+
const TIER_RULES = [
|
|
71
|
+
['critical', 'auth or billing paths', s => s.categories.some(c => CRITICAL_CATEGORIES.includes(c))],
|
|
72
|
+
['elevated', 'CI workflow or installer paths', s => s.categories.some(c => ELEVATED_CATEGORIES.includes(c))],
|
|
73
|
+
['elevated', 'migrations or SQL', s => s.files.some(f => MIGRATION_FILE.test(f))],
|
|
74
|
+
['elevated', `more than ${DEEP_LINES} changed lines or ${DEEP_FILES} files`, s => s.lines > DEEP_LINES || s.files.length > DEEP_FILES],
|
|
75
|
+
['routine', 'documentation only', s => s.files.length > 0 && s.files.every(f => DOC_FILE.test(f))],
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
export function tierFor({ files = [], categories = [], lines = 0, override } = {}) {
|
|
79
|
+
if (override !== undefined) {
|
|
80
|
+
if (!TIERS.includes(override)) throw new Error(`unknown risk tier "${override}"; use one of ${TIERS.join(', ')}`)
|
|
81
|
+
return { tier: override, tierSource: 'override', reasons: ['--risk flag'] }
|
|
82
|
+
}
|
|
83
|
+
const signals = { files, categories, lines }
|
|
84
|
+
const hit = TIER_RULES.find(([, , test]) => test(signals))
|
|
85
|
+
return hit
|
|
86
|
+
? { tier: hit[0], tierSource: 'auto', reasons: [hit[1]] }
|
|
87
|
+
: { tier: 'standard', tierSource: 'auto', reasons: ['default'] }
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function isVisual(files = []) {
|
|
91
|
+
const code = files.filter(f => !TEST_FILE.test(f) && !DOC_FILE.test(f))
|
|
92
|
+
return code.length > 0 && code.every(f => UI_FILE.test(f))
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function routingFor(host, tier, { visual = false } = {}) {
|
|
96
|
+
if (!HOSTS.includes(host)) throw new Error(`unknown host "${host}"; use one of ${HOSTS.join(', ')}`)
|
|
97
|
+
if (!TIERS.includes(tier)) throw new Error(`unknown risk tier "${tier}"`)
|
|
98
|
+
const column = TIERS.indexOf(tier)
|
|
99
|
+
const routing = Object.fromEntries(Object.entries(MATRIX[host]).map(([role, row]) => [role, row[column]]))
|
|
100
|
+
return visual && VISUAL_SPECIALIST[host] ? { ...routing, specialist: VISUAL_SPECIALIST[host] } : routing
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ROLE_LABELS = {
|
|
104
|
+
triage: 'Triage (scan depth, first pass only)',
|
|
105
|
+
specialist: 'Specialists x5 (quality, implementation, simplification, conventions, test-quality)',
|
|
106
|
+
rules: 'Project rules, deps checklist',
|
|
107
|
+
verifier: 'Verifier, critic re-examine, fix verifier',
|
|
108
|
+
critic: 'Completeness critic (deep)',
|
|
109
|
+
prover: 'Prover (writes the failing test)',
|
|
110
|
+
fixer: 'Fixer (--fix)',
|
|
111
|
+
polish: 'Comment polish (--post)',
|
|
112
|
+
housekeeping: 'Housekeeping',
|
|
113
|
+
}
|
|
114
|
+
const MODEL_NAMES = {
|
|
115
|
+
haiku: 'Haiku', sonnet: 'Sonnet', opus: 'Opus', fable: 'Fable',
|
|
116
|
+
'gpt-6-luna': 'Luna', 'gpt-6.2-sol': 'Sol', 'gpt-6.2-astra': 'Astra', 'gpt-6.1-terra': 'Terra',
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// The README table, rendered from MATRIX so the two cannot drift
|
|
120
|
+
// (tests/lekker-model-matrix.test.mjs asserts README contains it).
|
|
121
|
+
export function matrixMarkdown() {
|
|
122
|
+
const cell = (c, x) => `${MODEL_NAMES[c.model]} ${c.effort} / ${MODEL_NAMES[x.model]} ${x.effort}`
|
|
123
|
+
const rows = Object.keys(MATRIX.claude).map(role =>
|
|
124
|
+
`| ${ROLE_LABELS[role]} | ${TIERS.map((_, i) => cell(MATRIX.claude[role][i], MATRIX.codex[role][i])).join(' | ')} |`)
|
|
125
|
+
return [`| Agent | ${TIERS.join(' | ')} |`, `| --- |${TIERS.map(() => ' --- |').join('')}`, ...rows].join('\n')
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function parseArgs(argv) {
|
|
129
|
+
const sep = argv.indexOf('--')
|
|
130
|
+
const flags = sep === -1 ? argv : argv.slice(0, sep)
|
|
131
|
+
const files = sep === -1 ? [] : argv.slice(sep + 1)
|
|
132
|
+
const value = name => {
|
|
133
|
+
const i = flags.indexOf(name)
|
|
134
|
+
return i === -1 ? undefined : flags[i + 1]
|
|
135
|
+
}
|
|
136
|
+
const categories = (value('--categories') ?? '').split(',').map(s => s.trim()).filter(Boolean)
|
|
137
|
+
return { host: value('--host'), override: value('--risk'), lines: Number(value('--lines') ?? 0), categories, files }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function main(argv) {
|
|
141
|
+
const { host, override, lines, categories, files } = parseArgs(argv)
|
|
142
|
+
try {
|
|
143
|
+
const { tier, tierSource, reasons } = tierFor({ files, categories, lines, override })
|
|
144
|
+
const visual = isVisual(files)
|
|
145
|
+
console.log(JSON.stringify({ host, tier, tierSource, reasons, visual, routing: routingFor(host, tier, { visual }) }))
|
|
146
|
+
} catch (error) {
|
|
147
|
+
console.error(`model-matrix: ${error.message}`)
|
|
148
|
+
process.exit(2)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) main(process.argv.slice(2))
|
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
// node run-log.mjs start --repo <slug> --target <pr-N|branch-x> --mode pr|branch \
|
|
12
12
|
// --depth <d> --engine workflow|revmux [--fix] [--host claude]
|
|
13
13
|
// node run-log.mjs mark <runId> <phase> [--note <text>]
|
|
14
|
+
// node run-log.mjs decide <runId> --kind depth|tier|route|finding|fix|post --what <text> --why <text>
|
|
15
|
+
// node run-log.mjs decide <runId> --from-json <file> array of {kind, what, why}
|
|
14
16
|
// node run-log.mjs attach <runId> <file>...
|
|
15
17
|
// node run-log.mjs finish <runId> --status ok|failed|aborted [--verdict lgtm|lgtm-with-changes|needs-work]
|
|
16
18
|
// [--review-file <path>] [--artifact-url <url>] [--wf <wf_id>]... [--note <text>]
|
|
@@ -37,6 +39,7 @@ const LEDGER = join(STATE_DIR, 'runs.jsonl');
|
|
|
37
39
|
const PROJECTS_DIR = process.env.LEKKER_CLAUDE_PROJECTS || join(homedir(), '.claude', 'projects');
|
|
38
40
|
const REVMUX_TASKS = process.env.LEKKER_REVMUX_TASKS_DIR || join(homedir(), 'code-reviews', 'revmux-tasks');
|
|
39
41
|
|
|
42
|
+
const DECISION_KINDS = ['depth', 'tier', 'route', 'finding', 'fix', 'post'];
|
|
40
43
|
const argv = process.argv.slice(2);
|
|
41
44
|
const cmd = argv[0];
|
|
42
45
|
|
|
@@ -171,6 +174,25 @@ if (cmd === 'start') {
|
|
|
171
174
|
if (!existsSync(dir)) fail(`no run ${runId}`);
|
|
172
175
|
appendFileSync(join(dir, 'timeline.jsonl'), JSON.stringify({ phase, at: new Date().toISOString(), note: flag('note') ?? undefined }) + '\n');
|
|
173
176
|
console.log(JSON.stringify({ runId, phase }));
|
|
177
|
+
} else if (cmd === 'decide') {
|
|
178
|
+
const runId = argv[1];
|
|
179
|
+
const dir = runDir(runId);
|
|
180
|
+
if (!existsSync(dir)) fail(`no run ${runId}`);
|
|
181
|
+
const fromJson = flag('from-json');
|
|
182
|
+
const raw = fromJson ? readJson(fromJson) : [{ kind: flag('kind'), what: flag('what'), why: flag('why') }];
|
|
183
|
+
if (!Array.isArray(raw)) fail(`--from-json ${fromJson} must hold an array of {kind, what, why}`);
|
|
184
|
+
const text = (v) => (typeof v === 'string' ? v.replace(/\s+/g, ' ').trim() : '');
|
|
185
|
+
const rows = raw.map((d, i) => ({ kind: text(d?.kind), what: text(d?.what), why: text(d?.why), i }));
|
|
186
|
+
const bad = rows.find((r) => !DECISION_KINDS.includes(r.kind) || !r.what || !r.why);
|
|
187
|
+
if (bad) {
|
|
188
|
+
fail(!DECISION_KINDS.includes(bad.kind)
|
|
189
|
+
? `decision ${bad.i}: unknown kind "${bad.kind}" (use ${DECISION_KINDS.join('|')})`
|
|
190
|
+
: `decision ${bad.i}: --what and --why must be non-empty`);
|
|
191
|
+
}
|
|
192
|
+
const at = new Date().toISOString();
|
|
193
|
+
const lines = rows.map(({ kind, what, why }) => JSON.stringify({ at, kind, what, why }) + '\n').join('');
|
|
194
|
+
appendFileSync(join(dir, 'timeline.jsonl'), lines);
|
|
195
|
+
console.log(JSON.stringify({ runId, decisions: rows.length }));
|
|
174
196
|
} else if (cmd === 'attach') {
|
|
175
197
|
const runId = argv[1];
|
|
176
198
|
const dir = runDir(runId);
|
|
@@ -188,7 +210,10 @@ if (cmd === 'start') {
|
|
|
188
210
|
const meta = readJson(join(dir, 'run.json'));
|
|
189
211
|
if (!meta) fail(`no run ${runId}`);
|
|
190
212
|
const finishedAt = new Date().toISOString();
|
|
191
|
-
const
|
|
213
|
+
const rows = readJsonl(join(dir, 'timeline.jsonl'));
|
|
214
|
+
// Decision rows have no phase; keeping them out of the timeline keeps phaseDurations exact.
|
|
215
|
+
const timeline = [...rows.filter((r) => r.phase && r.phase !== 'finish'), { phase: 'finish', at: finishedAt }];
|
|
216
|
+
const decisions = rows.filter((r) => r.kind);
|
|
192
217
|
const workflows = flags('wf').map((id) => summariseWorkflow(findWorkflowRecord(id) || { runId: id }));
|
|
193
218
|
const reviewWf = workflows.find((w) => w.name === 'lekker-review-core') || null;
|
|
194
219
|
const row = {
|
|
@@ -206,7 +231,7 @@ if (cmd === 'start') {
|
|
|
206
231
|
artifactUrl: flag('artifact-url'),
|
|
207
232
|
note: flag('note', meta.note ?? null),
|
|
208
233
|
};
|
|
209
|
-
writeFileSync(join(dir, 'run.json'), JSON.stringify({ ...row, timeline }, null, 2) + '\n');
|
|
234
|
+
writeFileSync(join(dir, 'run.json'), JSON.stringify({ ...row, timeline, decisions }, null, 2) + '\n');
|
|
210
235
|
append(row);
|
|
211
236
|
const unresolved = workflows.filter((w) => w.durationS == null).map((w) => w.wfId);
|
|
212
237
|
console.log(JSON.stringify({ runId, ledger: LEDGER, wallS: row.wallS, tokensTotal: row.tokensTotal, unresolvedWorkflows: unresolved }));
|
|
@@ -333,7 +333,7 @@ console.log('\ndeps depth: routing, classifier, line validation')
|
|
|
333
333
|
check('workflow.js defines dimensionsFor', Boolean(dimsSrc), true)
|
|
334
334
|
if (dimsSrc) {
|
|
335
335
|
const dimensionsFor = new Function(dimsSrc + '\nreturn dimensionsFor')()
|
|
336
|
-
const M = {
|
|
336
|
+
const M = { specialist: { model: 's' }, triage: { model: 't' }, rules: { model: 'r' } }
|
|
337
337
|
check('deps runs exactly one agent', dimensionsFor('deps', M).map(d => d.file), ['deps.md'])
|
|
338
338
|
check('scan runs the triage pair plus project-rules', dimensionsFor('scan', M).map(d => d.key), ['triage-quality', 'triage-logic', 'project-rules'])
|
|
339
339
|
check('medium runs five specialists plus project-rules', dimensionsFor('medium', M).length, 6)
|
|
@@ -416,27 +416,43 @@ function shouldVerify(finding, depth) {
|
|
|
416
416
|
// a large rules file was missed when the check was only a side duty of generalist
|
|
417
417
|
// agents. It always runs because the script cannot cheaply tell whether the
|
|
418
418
|
// context holds rules; its prompt returns no findings when they are absent.
|
|
419
|
-
function dimensionsFor(depth,
|
|
419
|
+
function dimensionsFor(depth, ROUTE) {
|
|
420
420
|
if (depth === 'deps') {
|
|
421
|
-
return [{ key: 'deps', file: 'deps.md',
|
|
421
|
+
return [{ key: 'deps', file: 'deps.md', route: ROUTE.rules }]
|
|
422
422
|
}
|
|
423
423
|
if (depth === 'scan') {
|
|
424
424
|
return [
|
|
425
|
-
{ key: 'triage-quality', file: 'triage-quality.md',
|
|
426
|
-
{ key: 'triage-logic', file: 'triage-logic.md',
|
|
427
|
-
{ key: 'project-rules', file: 'project-rules.md',
|
|
425
|
+
{ key: 'triage-quality', file: 'triage-quality.md', route: ROUTE.triage },
|
|
426
|
+
{ key: 'triage-logic', file: 'triage-logic.md', route: ROUTE.triage },
|
|
427
|
+
{ key: 'project-rules', file: 'project-rules.md', route: ROUTE.rules },
|
|
428
428
|
]
|
|
429
429
|
}
|
|
430
430
|
return [
|
|
431
|
-
{ key: 'quality', file: 'quality.md',
|
|
432
|
-
{ key: 'implementation', file: 'implementation.md',
|
|
433
|
-
{ key: 'simplification', file: 'simplification.md',
|
|
434
|
-
{ key: 'conventions', file: 'conventions.md',
|
|
435
|
-
{ key: 'test-quality', file: 'test-quality.md',
|
|
436
|
-
{ key: 'project-rules', file: 'project-rules.md',
|
|
431
|
+
{ key: 'quality', file: 'quality.md', route: ROUTE.specialist },
|
|
432
|
+
{ key: 'implementation', file: 'implementation.md', route: ROUTE.specialist },
|
|
433
|
+
{ key: 'simplification', file: 'simplification.md', route: ROUTE.specialist },
|
|
434
|
+
{ key: 'conventions', file: 'conventions.md', route: ROUTE.specialist },
|
|
435
|
+
{ key: 'test-quality', file: 'test-quality.md', route: ROUTE.specialist },
|
|
436
|
+
{ key: 'project-rules', file: 'project-rules.md', route: ROUTE.rules },
|
|
437
437
|
]
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
+
function isBlockingSeverity(severity) {
|
|
441
|
+
return severity === 'critical' || severity === 'important'
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Model and effort for one role, from the `routing` arg that
|
|
445
|
+
// scripts/model-matrix.mjs builds from the PR's risk tier. An absent or
|
|
446
|
+
// malformed cell keeps the historical default, so an older caller runs exactly
|
|
447
|
+
// as before.
|
|
448
|
+
const VALID_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max']
|
|
449
|
+
function routeOf(routing, role, fallback) {
|
|
450
|
+
const cell = routing && routing[role]
|
|
451
|
+
const valid = Boolean(cell) && typeof cell.model === 'string' && cell.model.length > 0
|
|
452
|
+
&& (cell.effort === undefined || VALID_EFFORTS.includes(cell.effort))
|
|
453
|
+
return valid ? { model: cell.model, effort: cell.effort } : fallback
|
|
454
|
+
}
|
|
455
|
+
|
|
440
456
|
/**
|
|
441
457
|
* Does the finding carry enough of a composed boundary map to attempt a
|
|
442
458
|
* proof? Requires an entry point and a consumer, plus at least one of a
|
|
@@ -588,6 +604,7 @@ const {
|
|
|
588
604
|
engine: engineArg,
|
|
589
605
|
findingsFile,
|
|
590
606
|
testRunner,
|
|
607
|
+
routing,
|
|
591
608
|
} = input
|
|
592
609
|
|
|
593
610
|
// 'revmux' skips straight to Prove on pre-computed findings, so Prove's
|
|
@@ -596,6 +613,18 @@ const ENGINE = (engineArg === 'revmux') ? 'revmux' : 'workflow'
|
|
|
596
613
|
|
|
597
614
|
const targetLabel = targetLabelArg || `PR #${prNumber}`
|
|
598
615
|
|
|
616
|
+
const ROUTE = {
|
|
617
|
+
specialist: routeOf(routing, 'specialist', { model: 'sonnet' }),
|
|
618
|
+
triage: routeOf(routing, 'triage', { model: 'haiku' }),
|
|
619
|
+
rules: routeOf(routing, 'rules', { model: 'sonnet' }),
|
|
620
|
+
verifier: routeOf(routing, 'verifier', { model: 'sonnet', effort: 'high' }),
|
|
621
|
+
critic: routeOf(routing, 'critic', { model: 'sonnet' }),
|
|
622
|
+
prover: routeOf(routing, 'prover', { model: 'sonnet', effort: 'high' }),
|
|
623
|
+
}
|
|
624
|
+
const routeLabel = Object.keys(ROUTE).map(function(role) {
|
|
625
|
+
return `${role}=${ROUTE[role].model}${ROUTE[role].effort ? '/' + ROUTE[role].effort : ''}`
|
|
626
|
+
}).join(' ')
|
|
627
|
+
|
|
599
628
|
if (!repoSlug || (!prNumber && !targetLabelArg) || !depth || !diffFile || !contextFile || !promptDir) {
|
|
600
629
|
throw new Error(
|
|
601
630
|
'lekker-review workflow: missing required args (got type ' + typeof args +
|
|
@@ -650,12 +679,31 @@ const budgetAtStart = budget.spent()
|
|
|
650
679
|
let suppressedCount = 0
|
|
651
680
|
let proveAttemptCount = 0
|
|
652
681
|
|
|
682
|
+
// The harness has no filesystem, so decisions are logged as they happen and
|
|
683
|
+
// returned; the main loop writes them to the run timeline with run-log.mjs.
|
|
684
|
+
let decisions = []
|
|
685
|
+
const DECISION_WHY_MAX = 160
|
|
686
|
+
function decide(kind, what, why) {
|
|
687
|
+
const entry = { kind, what, why: String(why).replace(/\s+/g, ' ').trim().slice(0, DECISION_WHY_MAX) }
|
|
688
|
+
decisions = decisions.concat([entry])
|
|
689
|
+
log(`decision ${kind}: ${entry.what} (${entry.why})`)
|
|
690
|
+
}
|
|
691
|
+
// Only blocking-severity findings get a line; observations would drown the log.
|
|
692
|
+
function decideFinding(finding, outcome, reasoning) {
|
|
693
|
+
if (!isBlockingSeverity(finding.severity)) return
|
|
694
|
+
decide('finding', `${finding.file}:${finding.line} ${finding.title}`, `${outcome}: ${reasoning || 'no reason given'}`)
|
|
695
|
+
}
|
|
696
|
+
|
|
653
697
|
// -------------------------------------------------------------------------
|
|
654
698
|
// Dimensions by depth
|
|
655
699
|
// -------------------------------------------------------------------------
|
|
656
700
|
|
|
657
|
-
|
|
658
|
-
|
|
701
|
+
log(`routing: ${routing ? 'tiered' : 'defaults'} ${routeLabel}`)
|
|
702
|
+
Object.keys(ROUTE).forEach(function(role) {
|
|
703
|
+
decide('route', `${role} -> ${ROUTE[role].model}${ROUTE[role].effort ? ' ' + ROUTE[role].effort : ''}`,
|
|
704
|
+
routing ? 'risk tier routing' : 'default model')
|
|
705
|
+
})
|
|
706
|
+
const dimensions = dimensionsFor(depth, ROUTE)
|
|
659
707
|
|
|
660
708
|
const wtDisplay = worktreePath || 'null (scan mode: diff only)'
|
|
661
709
|
|
|
@@ -758,7 +806,8 @@ const budgetAtStart = budget.spent()
|
|
|
758
806
|
label: `review:${dim.key}`,
|
|
759
807
|
phase: 'Review',
|
|
760
808
|
schema,
|
|
761
|
-
model: dim.model,
|
|
809
|
+
model: dim.route.model,
|
|
810
|
+
effort: dim.route.effort,
|
|
762
811
|
})
|
|
763
812
|
|
|
764
813
|
if (!result) {
|
|
@@ -839,15 +888,16 @@ const budgetAtStart = budget.spent()
|
|
|
839
888
|
|
|
840
889
|
const verdict = await agent(verifierPrompt(finding), {
|
|
841
890
|
label: `verify:${finding.file}:${finding.line}`,
|
|
842
|
-
model:
|
|
891
|
+
model: ROUTE.verifier.model,
|
|
843
892
|
phase: 'Verify',
|
|
844
893
|
schema: VERDICT_SCHEMA,
|
|
845
|
-
effort:
|
|
894
|
+
effort: ROUTE.verifier.effort,
|
|
846
895
|
})
|
|
847
896
|
|
|
848
897
|
if (!verdict) {
|
|
849
898
|
// Missing verification cannot support a blocking finding.
|
|
850
899
|
downgradedCount++
|
|
900
|
+
decideFinding(finding, 'downgraded', 'verifier returned no usable result')
|
|
851
901
|
const kept = Object.assign({}, finding)
|
|
852
902
|
kept.severity = 'observation'
|
|
853
903
|
kept.verificationStatus = 'unavailable'
|
|
@@ -862,11 +912,13 @@ const budgetAtStart = budget.spent()
|
|
|
862
912
|
|
|
863
913
|
if (verdict.verdict === 'dropped') {
|
|
864
914
|
droppedCount++
|
|
915
|
+
decideFinding(finding, 'dropped', verdict.reasoning)
|
|
865
916
|
return null
|
|
866
917
|
}
|
|
867
918
|
|
|
868
919
|
if (verdict.verdict === 'downgraded') {
|
|
869
920
|
downgradedCount++
|
|
921
|
+
decideFinding(finding, 'downgraded', verdict.reasoning)
|
|
870
922
|
const downgraded = Object.assign({}, finding)
|
|
871
923
|
downgraded.severity = verdict.newSeverity || 'observation'
|
|
872
924
|
downgraded.verificationStatus = 'downgraded'
|
|
@@ -875,6 +927,7 @@ const budgetAtStart = budget.spent()
|
|
|
875
927
|
}
|
|
876
928
|
|
|
877
929
|
// confirmed
|
|
930
|
+
decideFinding(finding, 'kept', verdict.reasoning)
|
|
878
931
|
const confirmed = Object.assign({}, finding)
|
|
879
932
|
confirmed.severity = weakenedRuleSeverity(finding, confirmed.severity)
|
|
880
933
|
confirmed.verificationStatus = isHardRule(finding) ? 'hard-rule-confirmed' : 'confirmed'
|
|
@@ -978,9 +1031,10 @@ const budgetAtStart = budget.spent()
|
|
|
978
1031
|
].join(' '),
|
|
979
1032
|
{
|
|
980
1033
|
label: 'critic',
|
|
981
|
-
model:
|
|
1034
|
+
model: ROUTE.critic.model,
|
|
982
1035
|
phase: 'Critic',
|
|
983
1036
|
schema: CRITIC_SCHEMA,
|
|
1037
|
+
effort: ROUTE.critic.effort,
|
|
984
1038
|
}
|
|
985
1039
|
)
|
|
986
1040
|
|
|
@@ -1003,10 +1057,10 @@ const budgetAtStart = budget.spent()
|
|
|
1003
1057
|
].join(' '),
|
|
1004
1058
|
{
|
|
1005
1059
|
label: `critic-reexamine:${angle.file}:${angle.line}`,
|
|
1006
|
-
model:
|
|
1060
|
+
model: ROUTE.verifier.model,
|
|
1007
1061
|
phase: 'Critic',
|
|
1008
1062
|
schema: FINDINGS_SCHEMA,
|
|
1009
|
-
effort:
|
|
1063
|
+
effort: ROUTE.verifier.effort,
|
|
1010
1064
|
}
|
|
1011
1065
|
)
|
|
1012
1066
|
|
|
@@ -1022,10 +1076,10 @@ const budgetAtStart = budget.spent()
|
|
|
1022
1076
|
agentCount++
|
|
1023
1077
|
const verdict = await agent(verifierPrompt(newFinding), {
|
|
1024
1078
|
label: `critic-verify:${newFinding.file}:${newFinding.line}`,
|
|
1025
|
-
model:
|
|
1079
|
+
model: ROUTE.verifier.model,
|
|
1026
1080
|
phase: 'Critic',
|
|
1027
1081
|
schema: VERDICT_SCHEMA,
|
|
1028
|
-
effort:
|
|
1082
|
+
effort: ROUTE.verifier.effort,
|
|
1029
1083
|
})
|
|
1030
1084
|
|
|
1031
1085
|
if (!verdict || verdict.verdict === 'dropped') {
|
|
@@ -1121,8 +1175,8 @@ const budgetAtStart = budget.spent()
|
|
|
1121
1175
|
label: 'prove:' + finding.file + ':' + finding.line,
|
|
1122
1176
|
phase: 'Prove',
|
|
1123
1177
|
schema: PROOF_SCHEMA,
|
|
1124
|
-
model:
|
|
1125
|
-
effort:
|
|
1178
|
+
model: ROUTE.prover.model,
|
|
1179
|
+
effort: ROUTE.prover.effort,
|
|
1126
1180
|
})
|
|
1127
1181
|
|
|
1128
1182
|
if (!result) {
|
|
@@ -1195,4 +1249,6 @@ const budgetAtStart = budget.spent()
|
|
|
1195
1249
|
mockSmells: Array.isArray(testQualityResult.mockSmells) ? testQualityResult.mockSmells : [],
|
|
1196
1250
|
outputTokens: budget.spent() - budgetAtStart,
|
|
1197
1251
|
turnTokensTotal: budget.spent(),
|
|
1252
|
+
routing: ROUTE,
|
|
1253
|
+
decisions,
|
|
1198
1254
|
}, Object.assign({ engine: ENGINE }, revmuxPassthrough || {}))
|