Files
msd-core/tests/review-reviewer-instances-config.test.cjs
Tom Boucher b0d5ca3379 feat(#1517): support custom reviewer instances for /gsd:review (#1766)
* feat(#1517): support custom reviewer instances for /gsd:review

Add a bounded review.reviewer_instances config surface so one model-capable
adapter (e.g. opencode) can run as several independent reviewer identities in a
single /gsd:review pass. Instances participate only via review.default_reviewers,
expand before built-in slugs, are available iff their cli is detected, and a
non-matching entry is a hard error (typo must be loud). >=2 same-cli instances
emit a shared-adapter caveat in REVIEWS.md. Default path with no instances is
byte-for-byte unchanged.

Single-source instance->cli resolution lives in resolveReviewerSelection /
normalizeReviewerInstances (parity-locked in
tests/review-reviewer-instances.test.cjs). cli validated against
KNOWN_REVIEWER_SLUGS only (never arbitrary shell); model/agent opaque, never
shell-interpolated.

Closes #1517

* chore(#1517): backfill changeset pr:1766

---------

Co-authored-by: review-bot <review-bot@gsd>
2026-06-26 23:35:04 -04:00

49 lines
2.3 KiB
JavaScript

'use strict';
/**
* Config whitelist gate for review.reviewer_instances (#1517).
*
* Behavioral test (not source-grep): proves `config-set` accepts the
* review.reviewer_instances.<name>.{cli,model,agent} paths. Without the
* dynamicKeyPatterns entry in config-schema.manifest.json, config-set rejects
* the key and this test fails — that is the regression-must-fail-first signal.
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const path = require('node:path');
const fs = require('node:fs');
const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs');
describe('config-set review.reviewer_instances (#1517)', () => {
test('accepts a known-adapter cli for an instance', (t) => {
const tmpDir = createTempProject('reviewer-instances-cli');
t.after(() => cleanup(tmpDir));
const result = runGsdTools('config-set review.reviewer_instances.opencode-deepseek.cli opencode', tmpDir);
assert.ok(result.success, `config-set should accept the instance cli path: ${result.error || JSON.stringify(result)}`);
const configPath = path.join(tmpDir, '.planning', 'config.json');
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
assert.strictEqual(
config.review?.reviewer_instances?.['opencode-deepseek']?.cli,
'opencode',
'instance cli must persist',
);
});
test('accepts model and agent fields for an instance', (t) => {
const tmpDir = createTempProject('reviewer-instances-model');
t.after(() => cleanup(tmpDir));
const modelRes = runGsdTools('config-set review.reviewer_instances.opencode-deepseek.model deepseek/deepseek-v4-pro', tmpDir);
assert.ok(modelRes.success, `model set failed: ${modelRes.error}`);
const agentRes = runGsdTools('config-set review.reviewer_instances.opencode-deepseek.agent review', tmpDir);
assert.ok(agentRes.success, `agent set failed: ${agentRes.error}`);
const configPath = path.join(tmpDir, '.planning', 'config.json');
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
assert.strictEqual(config.review.reviewer_instances['opencode-deepseek'].model, 'deepseek/deepseek-v4-pro');
assert.strictEqual(config.review.reviewer_instances['opencode-deepseek'].agent, 'review');
});
});