Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/review-benchmark/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Use when measuring a change to the kit reviewers in this repositor
user-invocable: true
metadata:
pattern: tool-wrapper
updated: "2026-11-24"
updated: "2026-12-02"
---

# Review benchmark
Expand Down Expand Up @@ -365,7 +365,7 @@ An assistant message from another model (for example after a usage fallback), a

## omp compatibility

`scripts/omp.mjs` is the one place for the omp facts that the scripts rely on: the project agent folder `.omp/agents/`, the project config `.omp/config.yml` and the legacy `.omp/settings.json`, the settings `task.agentServiceTierOverrides`, `task.enableEffort`, and `task.structured`, the agent frontmatter keys (`thinking-level` and its levels, the other model and effort keys, `autoload-skills`), the tier families, the tool names, the URI schemes, the installed-skill paths, the reply rule, the dispatch cap, and the transcript records and fields that `score.mjs` reads. These facts hold for the omp releases from the omp `floor` to the omp `verified` pin of `SoT/toolchain.json`. When an omp release changes one of them, change it in `omp.mjs`: `prepare.mjs` and `score.mjs` import each fact from there.
`scripts/omp.mjs` is the one place for the omp facts that the scripts rely on: the project agent folder `.omp/agents/`, the project config `.omp/config.yml` and the legacy `.omp/settings.json`, the settings `task.agentServiceTierOverrides`, `task.enableEffort`, and `task.structured`, the agent frontmatter keys (`thinking-level` and its levels, the other model and effort keys, and the skill keys `autoload-skills` and `autoloadSkills`; omp reads each key in kebab case and in camelCase, so a copied agent also loses `thinkingLevel`), the tier families, the tool names, the URI schemes, the installed-skill paths, the reply rule, the dispatch cap, and the transcript records and fields that `score.mjs` reads. These facts hold for the omp releases from the omp `floor` to the omp `verified` pin of `SoT/toolchain.json`. When an omp release changes one of them, change it in `omp.mjs`: `prepare.mjs` and `score.mjs` import each fact from there.

Three checks stop a run on an omp change that they can see:

Expand Down
10 changes: 6 additions & 4 deletions .agents/skills/review-benchmark/scripts/omp.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,12 @@ export const EFFORT_KEY = 'thinking-level';
export const EFFORT_LEVELS = ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
// An omp model selector can carry an effort suffix. The benchmark takes the effort from its own options only.
export const EFFORT_SUFFIX = /:(off|minimal|low|medium|high|xhigh|max|auto|inherit)$/;
// The frontmatter keys that set the model or the effort of an agent. A copied agent loses all of them.
export const MODEL_KEYS = ['model', 'thinking-level', 'thinking', 'effort'];
// The frontmatter key that loads a skill when the agent starts. omp resolves it to the installed skill.
export const AUTOLOAD_KEY = 'autoload-skills';
// The frontmatter keys that set the model or the effort of an agent. omp reads a key in kebab case and in camelCase,
// so the list also holds `thinkingLevel`. A copied agent loses all of them.
export const MODEL_KEYS = ['model', 'thinking-level', 'thinkingLevel', 'thinking', 'effort'];
// The frontmatter keys that load a skill when the agent starts, in both spellings. omp resolves them to the installed
// skill.
export const AUTOLOAD_KEYS = ['autoload-skills', 'autoloadSkills'];
// The frontmatter key that lists the tools of an agent (`tools: read, grep`), the key that lists the agents that it may
// spawn, and the key that gives it the REPLY_TOOL tool with its output schema (structured mode) also when
// SETTINGS.structured is false.
Expand Down
90 changes: 76 additions & 14 deletions .agents/skills/review-benchmark/scripts/prepare.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import {
} from './score.mjs';
import {
AGENT_DIR,
AUTOLOAD_KEY,
AUTOLOAD_KEYS,
COMMAND_TOOLS,
DISPATCH_CAP,
EFFORT_KEY,
Expand Down Expand Up @@ -754,31 +754,93 @@ export function pluginRootText(text, pluginRoot) {

// The frontmatter of an agent file; group 1 holds its lines. The text after it is the body, the prompt of the agent.
const AGENT_FRONTMATTER = /^---\n([\s\S]*?)\n---\n/;
// The key of a top-level frontmatter line, or undefined for another line, such as an indented line of a mapping.
const frontmatterKey = (line) => /^([\w-]+):/.exec(line)?.[1];
// A top-level mapping key of agent frontmatter, as YAML writes it: bare, double-quoted, or single-quoted.
const FRONTMATTER_KEY = /^(?:"((?:[^"\\]|\\.)*)"|'((?:[^']|'')*)'|([^\s#"'-][^:]*?|-[^\s:][^:]*?))[ \t]*:(?:[ \t]|$)/;
// The key of a top-level frontmatter line, unquoted, or undefined for another line, such as an indented line of a
// mapping. A double-quoted key keeps its text when its escapes are not JSON escapes; checkCopiedFrontmatter then
// catches a removed key that this reading missed.
function frontmatterKey(line) {
const match = FRONTMATTER_KEY.exec(line);
if (!match) return undefined;
if (match[1] !== undefined) {
try {
return JSON.parse(`"${match[1]}"`);
} catch {
return match[1];
}
}
return match[2] !== undefined ? match[2].replaceAll("''", "'") : match[3];
}
// The top-level entries of agent frontmatter lines, in order. An entry starts at a line with a key at the first
// column and holds each later line that is indented, empty, a comment, or starts a block sequence item (`- item`),
// so an entry holds the whole value of its key, also a block list with a comment between its items.
function frontmatterEntries(lines) {
const entries = [];
for (const line of lines) {
const continues = entries.length > 0 && /^(?:[ \t]|#|-(?:[ \t]|$)|$)/.test(line);
if (continues) entries.at(-1).lines.push(line);
else entries.push({ key: frontmatterKey(line), lines: [line] });
}
return entries;
}

// The frontmatter keys that renderAgent writes itself: the pins of the copy.
const PINNED_KEYS = ['name', 'model', EFFORT_KEY];

// Checks a copied frontmatter against its source with the Bun YAML parser, which reads keys as omp reads them: the
// copy holds no removed key, also one with escapes in its quoted text, its pins read as `pins`, and each other entry
// equals the entry of the source. The skill path rewrites of pluginRootText come after this check.
function checkCopiedFrontmatter(sourceText, copyText, removed, pins) {
const parse = (text, label) => {
try {
return Bun.YAML.parse(text) ?? {};
} catch (error) {
throw new Error(`the ${label} frontmatter of the agent is not valid YAML: ${error.message}`, { cause: error });
}
};
const source = parse(sourceText, 'source');
const copy = parse(copyText, 'copied');
const left = Object.keys(copy).filter((key) => removed(key) && !PINNED_KEYS.includes(key));
if (left.length > 0) {
throw new Error(`the agent copy still holds the removed frontmatter key ${left.join(', ')}; write the key bare`);
}
const wrongPins = PINNED_KEYS.filter((key) => copy[key] !== pins[key]);
if (wrongPins.length > 0) throw new Error(`the agent copy does not pin ${wrongPins.join(', ')}`);
const kept = (fields) => Object.entries(fields).filter(([key]) => !removed(key) && !PINNED_KEYS.includes(key));
const expected = Object.fromEntries(kept(source));
const actual = Object.fromEntries(kept(copy));
const changed = [...new Set([...Object.keys(expected), ...Object.keys(actual)])].filter(
(key) => !Bun.deepEquals(expected[key], actual[key]),
);
if (changed.length > 0) throw new Error(`the agent copy changed the frontmatter entry ${changed.join(', ')}`);
}

// Copies a plugin agent under `name` and pins its model and effort (EFFORT_KEY). It removes every model and effort key
// of the source (omp.mjs MODEL_KEYS), also the `effort` key that an agent at an old ref can have. With `pluginRoot`,
// the copy reads its skill from that plugin copy: it loses AUTOLOAD_KEY, which would load the installed skill, and
// each skill path names the plugin copy (pluginRootText).
// the copy reads its skill from that plugin copy: it loses AUTOLOAD_KEYS, which would load the installed skill, and
// each skill path names the plugin copy (pluginRootText). Each key goes with its whole value, and a quoted key counts
// as the same key; checkCopiedFrontmatter proves both with the YAML parser. The body stays byte for byte.
export function renderAgent(source, { name, model, effort, pluginRoot }) {
const frontmatter = AGENT_FRONTMATTER.exec(source);
if (!frontmatter) throw new Error('the agent file has no frontmatter');
const lines = frontmatter[1]
.split('\n')
.filter((line) => {
const key = frontmatterKey(line);
return !MODEL_KEYS.includes(key) && (pluginRoot === undefined || key !== AUTOLOAD_KEY);
});
const removed = (key) => MODEL_KEYS.includes(key) || (pluginRoot !== undefined && AUTOLOAD_KEYS.includes(key));
const lines = frontmatterEntries(frontmatter[1].split('\n'))
.filter(({ key }) => !removed(key))
.flatMap((entry) => entry.lines);
const nameAt = lines.findIndex((line) => line.startsWith('name:'));
if (nameAt < 0) throw new Error('the agent frontmatter has no name');
const modelValue = /^[A-Za-z0-9][\w./+-]*$/.test(model) ? model : JSON.stringify(model);
lines.splice(nameAt, 1, `name: ${name}`, `model: ${modelValue}`, `${EFFORT_KEY}: ${effort}`);
checkCopiedFrontmatter(frontmatter[1], lines.join('\n'), removed, { name, model, [EFFORT_KEY]: effort });
const body = source.slice(frontmatter[0].length);
const text = `---\n${lines.join('\n')}\n---\n${body}`;
return pluginRoot === undefined ? text : pluginRootText(text, pluginRoot);
}

// The key of a bare top-level frontmatter line of a bundled agent. The bundled reader slices the value after the key,
// so it accepts only this spelling and refuses a quoted key as a missing line.
const bareFrontmatterKey = (line) => /^([\w-]+):/.exec(line)?.[1];

// The source of a bundled agent for renderAgent, from the text of its vendored file `file` (see BUNDLED_AGENTS): its
// TOOLS_KEY line without the tools of COMMAND_TOOLS, no SPAWNS_KEY line, and `STRUCTURED_KEY: true` after its name
// line. The rest of the file stays byte for byte. A file without a frontmatter, a name line, or a tools line stops the
Expand All @@ -788,9 +850,9 @@ function bundledSource(text, file) {
if (!frontmatter) fail(`${file} has no frontmatter`);
const lines = frontmatter[1]
.split('\n')
.filter((line) => ![SPAWNS_KEY, STRUCTURED_KEY].includes(frontmatterKey(line)));
const toolsAt = lines.findIndex((line) => frontmatterKey(line) === TOOLS_KEY);
const nameAt = lines.findIndex((line) => frontmatterKey(line) === 'name');
.filter((line) => ![SPAWNS_KEY, STRUCTURED_KEY].includes(bareFrontmatterKey(line)));
const toolsAt = lines.findIndex((line) => bareFrontmatterKey(line) === TOOLS_KEY);
const nameAt = lines.findIndex((line) => bareFrontmatterKey(line) === 'name');
if (toolsAt < 0 || nameAt < 0) fail(`${file} has no ${toolsAt < 0 ? TOOLS_KEY : 'name'} line in its frontmatter`);
const tools = lines[toolsAt]
.slice(TOOLS_KEY.length + 1)
Expand Down
98 changes: 98 additions & 0 deletions .agents/skills/review-benchmark/tests/prepare-agents.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@ import {
BASELINE_PLUGIN,
CODE_KNOWN,
CONFIGS,
copyScripts,
fakeOmp,
FIXER_SETTING,
frontmatter,
gitIn,
gridFixture,
isolateGit,
isoAt,
jsonl,
judgedArm,
judgeLoop,
KIT_ROOT,
LIVE,
LIVE_PLUGIN,
loopRepo,
MODEL,
neutralScratch,
onBun,
POLICY_ARMS,
policyBlock,
policyLoops,
Expand Down Expand Up @@ -266,6 +273,97 @@ test('agents CLI rejects --runtime', () => {
assert.equal(result.stderr.split('\n')[0], "prepare.mjs: Unknown option '--runtime'");
}
});
// Plan #315: omp reads an agent frontmatter key in kebab case and in camelCase. A reviewer copy of the `agents` command
// reads the skill of its own plugin root, so it loses both spellings of the skill key, and it keeps only the pinned
// effort, so it loses `thinkingLevel` too. An agent at an old ref or in the work tree can hold each of them, as a bare
// or a quoted key, and with a block list as its value. The copy loses the whole entry and keeps the next key.
test('agents CLI drops both skill key spellings and thinkingLevel from the reviewer copies', () => {
isolateGit();
const root = neutralScratch();
const repo = path.join(root, 'repo');
const project = path.join(root, 'project');
const baselineDir = path.join(root, 'baseline-plugin');
fs.mkdirSync(project);
gitIn(root, 'init', '-q', '-b', 'main', repo);
const roles = ['code', 'plan'];
const agentText = (skill, keys) =>
['---', `name: ${skill}`, 'description: Reviews.', ...keys, 'tools: read, glob, grep', '---', '']
.concat([`Follow \`skill://${skill}/SKILL.md\`.`, ''])
.join('\n');
// The baseline ref: a bare kebab key, a quoted camelCase key with an indented block list that has a comment between
// its items, and an effort key with a YAML escape in its quoted text.
const atRef = (skill) => [
`autoload-skills: ${skill}`,
'"autoloadSkills":',
` - ${skill}`,
'# a comment between two items of the list',
` - ${skill}`,
'"thinking\\u004cevel": low',
];
// The work tree: a quoted camelCase key with a block list at the first column, a single-quoted kebab key, and a
// bare effort key.
const inTree = (skill) => ['"autoloadSkills":', `- ${skill}`, `'autoload-skills': ${skill}`, 'thinkingLevel: low'];
for (const role of roles) {
const skill = `${role}-reviewer`;
put(repo, `${KIT_ROOT}/agents/${skill}.md`, agentText(skill, atRef(skill)));
put(repo, `${KIT_ROOT}/skills/${skill}/SKILL.md`, `# ${skill}\n`);
}
gitIn(repo, 'add', '-A');
gitIn(repo, 'commit', '-q', '-m', 'agents');
for (const role of roles) {
const skill = `${role}-reviewer`;
put(repo, `${KIT_ROOT}/agents/${skill}.md`, agentText(skill, inTree(skill)));
}
const script = copyScripts(repo);
const args = ['agents', '--baseline-ref', 'HEAD', '--baseline-dir', baselineDir, '--model', MODEL, '--efforts', 'high'];
const result = spawnSync(BUN_RUNTIME, [script, ...args, '--tiers', 'default', '--project', project], {
encoding: 'utf8',
env: fakeOmp().env,
});
assert.equal(result.status, 0, result.stderr);
const agentDir = path.join(project, '.omp', 'agents');
const { configs } = readJson(path.join(agentDir, 'review-bench-configs.json'));
assert.ok(configs.length > 0);
const pluginRoots = { baseline: baselineDir, candidate: path.join(repo, KIT_ROOT) };
// The frontmatter of a written agent as omp's parser reads it: Bun.YAML runs in a Bun child.
const parsedFrontmatter = (file) => {
const code =
'const t = await Bun.file(process.argv[1]).text(); console.log(JSON.stringify(Bun.YAML.parse(/^---\\n([\\s\\S]*?)\\n---\\n/.exec(t)[1])))';
const child = spawnSync(BUN_RUNTIME, ['-e', code, file], { encoding: 'utf8' });
assert.equal(child.status, 0, child.stderr);
return JSON.parse(child.stdout);
};
for (const { name } of configs) {
for (const [side, pluginRoot] of Object.entries(pluginRoots)) {
for (const role of roles) {
const file = path.join(agentDir, `review-bench-${side}-${role}-${name}.md`);
const text = readText(file);
const fields = parsedFrontmatter(file);
assert.deepEqual(
['autoload-skills', 'autoloadSkills', 'thinkingLevel'].filter((key) => Object.hasOwn(fields, key)),
[],
file,
);
assert.equal(fields['thinking-level'], 'high', file);
assert.equal(fields.tools, 'read, glob, grep', `${file} keeps the tools after a removed block list`);
assert.doesNotMatch(text, /^\s*- |^# a comment/m, `${file} keeps a line of a removed block list`);
assert.ok(text.endsWith(`\n---\n\nFollow \`${pluginRoot}/skills/${role}-reviewer/SKILL.md\`.\n`), text);
}
}
}
});
// Plan #315: a removed key in a quoted spelling that the line reader does not decode (a YAML `\x` escape) still reads
// as the key in the YAML parser, so renderAgent refuses the copy instead of writing it.
test('renderAgent refuses a copy that keeps a removed key in a spelling that the line reader misses', () => {
const source = ['---', 'name: plan-reviewer', 'description: Reviews.', '"\\x61utoloadSkills": plan-reviewer', '---']
.concat(['', 'Body.', ''])
.join('\n');
const options = { name: 'review-bench-copy', model: MODEL, effort: 'high', pluginRoot: '/plugin' };
assert.throws(
() => onBun('prepare.mjs', 'renderAgent', [source, options]),
/the agent copy still holds the removed frontmatter key autoloadSkills/,
);
});
test('agents gives a fixer model in no tier family the tier null and refuses --fixer-tier for it', () => {
const fixture = selfReviewAgents('project', { 'fixer-model': NO_TIER_MODEL });
const { root, project, agentDir } = fixture;
Expand Down
38 changes: 31 additions & 7 deletions .agents/skills/review-benchmark/tests/prepare-variants.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
MODEL,
neutralScratch,
noContract,
onBun,
overlayFixture,
PASS_ROUND,
PLAN_BLOCK,
Expand Down Expand Up @@ -98,9 +99,32 @@ const VARIANT_REFS = { 16: 'v16', a: 'cand-a' };
const variantRoot = (root, name, sha) => path.join(root, `variant-${name}-${sha.slice(0, 12)}-plugin`);
// The agent of a variant at the commit `sha` and the configuration `config`.
const variantAgent = (name, sha, config) => `review-bench-variant-${name}-${sha.slice(0, 12)}-plan-${config}`;
// Plan #315: moves the tag `tag` of `repo` to a child commit whose plan-reviewer agent also holds the camelCase skill
// key and the camelCase effort key, which omp reads as the kebab-case keys, and returns the new commit.
function camelCaseVariant(repo, tag) {
const file = 'plugins/plan-lifecycle/agents/plan-reviewer.md';
const text = gitIn(repo, 'show', `${tag}:${file}`).replace(
'\n---\n',
'\nautoloadSkills: plan-reviewer\nthinkingLevel: low\n---\n',
);
const env = { ...process.env, GIT_INDEX_FILE: path.join(repo, '.git', 'camel-case-index') };
const identity = ['-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.com', '-c', 'commit.gpgSign=false'];
const git = (args, input) => {
const result = spawnSync('git', [...identity, ...args], { cwd: repo, encoding: 'utf8', env, input });
assert.equal(result.status, 0, `git ${args.join(' ')} failed: ${result.stderr}`);
return result.stdout.trim();
};
git(['read-tree', tag]);
const blob = git(['hash-object', '-w', '--stdin'], text);
git(['update-index', '--cacheinfo', `100644,${blob},${file}`]);
const commit = git(['commit-tree', git(['write-tree']), '-p', tag, '-m', 'camelCase keys'], '');
git(['tag', '-f', tag, commit]);
return commit;
}
test('agents --variants writes an agent per variant and configuration from the plan reviewer at its ref', () => {
const fixture = variantRepo();
const { root, repo, project, agentDir, shas } = fixture;
shas['cand-a'] = camelCaseVariant(repo, 'cand-a');
agentsOnBun(variantOptions(fixture), repo);
const list = readJson(path.join(agentDir, 'review-bench-configs.json'));
assert.deepEqual(
Expand Down Expand Up @@ -128,16 +152,16 @@ test('agents --variants writes an agent per variant and configuration from the p
const agent = variantAgent(name, shas[ref], config);
const text = readText(path.join(agentDir, `${agent}.md`));
// The agent text at the ref, with the model and the effort of the configuration and the variant plugin root.
const rendered = prepare.renderAgent(atRef('agents/plan-reviewer.md'), {
name: agent,
model,
effort,
pluginRoot,
});
// renderAgent checks the copy with the Bun YAML parser, so it runs in a Bun child.
const { result: rendered } = onBun('prepare.mjs', 'renderAgent', [
atRef('agents/plan-reviewer.md'),
{ name: agent, model, effort, pluginRoot },
]);
assert.equal(text, rendered);
assert.ok(text.includes(`\`${pluginRoot}/skills/plan-reviewer/SKILL.md\``));
// The copy reads the skill of its plugin root, not the installed skill.
assert.doesNotMatch(text, /skill:\/\/|^autoload-skills:/m);
assert.doesNotMatch(text, /skill:\/\/|^(?:autoload-skills|autoloadSkills|thinkingLevel):/m);
assert.match(text, new RegExp(`^thinking-level: ${effort}$`, 'm'));
assert.ok(!text.includes(LEGACY_PLUGIN_ROOT));
assert.equal(overrides[agent], tier);
}
Expand Down
Loading
Loading