agjan 0.0.12 → 0.0.13
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/dist/adapters/claude-code.js +32 -1
- package/dist/adapters/copilot.js +30 -0
- package/dist/cli.js +7 -1
- package/dist/commands/check.js +4 -0
- package/dist/commands/gates.js +26 -13
- package/dist/commands/log.js +4 -2
- package/dist/commands/models.js +90 -0
- package/dist/commands/pr-summary.js +8 -0
- package/dist/commands/review.js +6 -3
- package/dist/commands/setup.js +2 -2
- package/dist/commands/status.js +21 -1
- package/dist/config.js +5 -1
- package/dist/mcp.js +47 -2
- package/dist/progress-view.js +6 -6
- package/dist/qa.js +77 -0
- package/dist/review-policy.js +2 -1
- package/dist/review.js +119 -20
- package/dist/scope.js +4 -0
- package/docs/guide.md +20 -4
- package/kit/hooks/guard.mjs +3 -3
- package/kit/skills/agjan-build/SKILL.md +5 -3
- package/kit/skills/agjan-design/SKILL.md +5 -2
- package/kit/skills/agjan-spec/SKILL.md +7 -4
- package/kit/skills/agjan-verify/SKILL.md +30 -3
- package/kit/skills/qa-tester/SKILL.md +74 -0
- package/package.json +1 -1
- package/schemas/config.schema.json +3 -2
- package/schemas/reviews.schema.json +3 -1
|
@@ -14,7 +14,7 @@ const REVIEWERS = [
|
|
|
14
14
|
{ name: 'agjan-reviewer', tier: 'balanced' },
|
|
15
15
|
{ name: 'agjan-reviewer-deep', tier: 'deep' },
|
|
16
16
|
];
|
|
17
|
-
const HUMAN_ONLY = ['approve', 'accept', 'reject', 'auto'];
|
|
17
|
+
const HUMAN_ONLY = ['approve', 'accept', 'reject', 'auto', 'models set'];
|
|
18
18
|
/** Every way an agent's shell might start agjan. Indirect forms are stopped by the terminal check. */
|
|
19
19
|
const LAUNCHERS = ['agjan', 'npx agjan', 'npx --no-install agjan', 'npx -y agjan', 'npm exec agjan', 'npm exec -- agjan'];
|
|
20
20
|
export const DENY_RULES = HUMAN_ONLY.flatMap((cmd) => LAUNCHERS.map((l) => `Bash(${l} ${cmd}:*)`));
|
|
@@ -53,6 +53,36 @@ function withoutGuards(groups) {
|
|
|
53
53
|
.map((group) => (group.hooks?.some(isGuard) ? { ...group, hooks: group.hooks.filter((h) => !isGuard(h)) } : group))
|
|
54
54
|
.filter((group) => !Array.isArray(group.hooks) || group.hooks.length > 0);
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* The QA agent (decision 81): the qa-tester skill, a shell and file edits for its tests,
|
|
58
|
+
* and the agjan server in the QA role (qa_context, qa_record), scoped to this agent.
|
|
59
|
+
*/
|
|
60
|
+
function qaAgent(model, skill) {
|
|
61
|
+
const frontmatter = {
|
|
62
|
+
name: 'agjan-qa',
|
|
63
|
+
description: "agjan's tester for the QA step of /agjan-verify: writes and runs tests from the spec alone. Use only when " +
|
|
64
|
+
'an agjan workflow skill asks for step qa; it records its result itself.',
|
|
65
|
+
tools: 'Read, Grep, Glob, Edit, Write, Bash, mcp__agjan__qa_context, mcp__agjan__qa_record',
|
|
66
|
+
...(model ? { model } : {}),
|
|
67
|
+
mcpServers: [
|
|
68
|
+
{
|
|
69
|
+
agjan: {
|
|
70
|
+
type: 'stdio',
|
|
71
|
+
command: 'npx',
|
|
72
|
+
args: ['--no-install', 'agjan', 'mcp', '--host', HOST, '--isolation', 'agent', '--role', 'qa'],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
};
|
|
77
|
+
return [
|
|
78
|
+
'---',
|
|
79
|
+
toYaml(frontmatter, { lineWidth: 0 }).trimEnd(),
|
|
80
|
+
'---',
|
|
81
|
+
'<!-- Generated by agjan sync from the qa-tester skill. Do not edit; run agjan sync. -->',
|
|
82
|
+
'',
|
|
83
|
+
skillBody(skill),
|
|
84
|
+
].join('\n');
|
|
85
|
+
}
|
|
56
86
|
function reviewerAgent(name, tier, model, skill) {
|
|
57
87
|
const frontmatter = {
|
|
58
88
|
name,
|
|
@@ -88,6 +118,7 @@ export function plan(config, skills) {
|
|
|
88
118
|
path: `.claude/agents/${name}.md`,
|
|
89
119
|
content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
|
|
90
120
|
}));
|
|
121
|
+
items.push({ kind: 'file', path: '.claude/agents/agjan-qa.md', content: qaAgent(agentModel(config, HOST, 'qa'), skills['qa-tester/SKILL.md']) });
|
|
91
122
|
items.push({
|
|
92
123
|
kind: 'json',
|
|
93
124
|
path: '.claude/settings.json',
|
package/dist/adapters/copilot.js
CHANGED
|
@@ -20,6 +20,35 @@ const REVIEWERS = [
|
|
|
20
20
|
{ name: 'agjan-reviewer', tier: 'balanced' },
|
|
21
21
|
{ name: 'agjan-reviewer-deep', tier: 'deep' },
|
|
22
22
|
];
|
|
23
|
+
/**
|
|
24
|
+
* The QA agent (decision 81): the qa-tester skill, `edit` and `shell` for its tests
|
|
25
|
+
* (Copilot CLI 1.0.100 tested), and the agjan server in the QA role, scoped to it.
|
|
26
|
+
*/
|
|
27
|
+
function qaAgent(model, skill) {
|
|
28
|
+
const frontmatter = {
|
|
29
|
+
name: 'agjan-qa',
|
|
30
|
+
description: "agjan's tester for the QA step of /agjan-verify: writes and runs tests from the spec alone. Use only when " +
|
|
31
|
+
'an agjan workflow skill asks for step qa; it records its result itself.',
|
|
32
|
+
tools: ['read', 'search', 'edit', 'shell', 'agjan/qa_context', 'agjan/qa_record'],
|
|
33
|
+
...(model ? { model } : {}),
|
|
34
|
+
'mcp-servers': {
|
|
35
|
+
agjan: {
|
|
36
|
+
type: 'local',
|
|
37
|
+
command: 'npx',
|
|
38
|
+
args: ['--no-install', 'agjan', 'mcp', '--host', HOST, '--isolation', 'agent', '--role', 'qa'],
|
|
39
|
+
tools: ['*'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return [
|
|
44
|
+
'---',
|
|
45
|
+
toYaml(frontmatter, { lineWidth: 0 }).trimEnd(),
|
|
46
|
+
'---',
|
|
47
|
+
'<!-- Generated by agjan sync from the qa-tester skill. Do not edit; run agjan sync. -->',
|
|
48
|
+
'',
|
|
49
|
+
skillBody(skill),
|
|
50
|
+
].join('\n');
|
|
51
|
+
}
|
|
23
52
|
function reviewerAgent(name, tier, model, skill) {
|
|
24
53
|
const frontmatter = {
|
|
25
54
|
name,
|
|
@@ -75,6 +104,7 @@ export function plan(config, skills) {
|
|
|
75
104
|
path: `.github/agents/${name}.agent.md`,
|
|
76
105
|
content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
|
|
77
106
|
}));
|
|
107
|
+
items.push({ kind: 'file', path: '.github/agents/agjan-qa.agent.md', content: qaAgent(agentModel(config, HOST, 'qa'), skills['qa-tester/SKILL.md']) });
|
|
78
108
|
items.push({ kind: 'file', path: HOOK_FILE, content: hookConfig() });
|
|
79
109
|
return items;
|
|
80
110
|
}
|
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ import * as branch from './commands/branch.js';
|
|
|
16
16
|
import * as progress from './commands/progress.js';
|
|
17
17
|
import * as lint from './commands/lint.js';
|
|
18
18
|
import * as uiTest from './commands/ui-test.js';
|
|
19
|
+
import * as models from './commands/models.js';
|
|
19
20
|
import { onEvent } from './log.js';
|
|
20
21
|
import { refreshAfterEvent } from './progress-view.js';
|
|
21
22
|
const COMMANDS = {
|
|
@@ -31,6 +32,7 @@ const COMMANDS = {
|
|
|
31
32
|
check: check.run,
|
|
32
33
|
lint: lint.run,
|
|
33
34
|
'ui-test': uiTest.run,
|
|
35
|
+
models: models.run,
|
|
34
36
|
amend: gates.amend,
|
|
35
37
|
approve: gates.approve,
|
|
36
38
|
accept: gates.accept,
|
|
@@ -60,6 +62,9 @@ Setup (human):
|
|
|
60
62
|
regenerate managed files (skills, agents, blocks, settings);
|
|
61
63
|
--copilot-mcp adds missing MCP servers to Copilot
|
|
62
64
|
hook install install the pre-commit hook
|
|
65
|
+
models [set <balanced|deep|qa> <model> [--host <h>]]
|
|
66
|
+
show the reviewers' models, or choose one (the deep reviewer
|
|
67
|
+
on another model family than the writer catches other things)
|
|
63
68
|
doctor check the environment and the project setup
|
|
64
69
|
|
|
65
70
|
Agent and human:
|
|
@@ -96,8 +101,9 @@ Agent and human:
|
|
|
96
101
|
report write report.md: durations, gate waits, models and tokens
|
|
97
102
|
|
|
98
103
|
Reviewer agent (through the host's MCP configuration):
|
|
99
|
-
mcp [--host <h>] [--isolation agent|shared|fork|none]
|
|
104
|
+
mcp [--host <h>] [--isolation agent|shared|fork|none] [--role review|qa]
|
|
100
105
|
agjan MCP server on stdio: review_context, review_record
|
|
106
|
+
(--role qa: qa_context, qa_record for the agjan-qa agent)
|
|
101
107
|
|
|
102
108
|
Human only, in a terminal:
|
|
103
109
|
approve spec | design | spec design | verify | amendment <id>
|
package/dist/commands/check.js
CHANGED
|
@@ -9,6 +9,7 @@ import { allowedPatterns, matcher } from '../scope.js';
|
|
|
9
9
|
import { acTestFiles } from '../tests-map.js';
|
|
10
10
|
import { acResults, loadResults } from '../test-results.js';
|
|
11
11
|
import { acceptanceState, buildProgress, verifyState } from '../progress.js';
|
|
12
|
+
import { qaProblem } from '../qa.js';
|
|
12
13
|
import { FIX_FILE, fixRules, freshReview } from '../fix.js';
|
|
13
14
|
import { BASELINE_FILE, baselineDrift, projectProblems } from '../baseline.js';
|
|
14
15
|
import { UsageError } from '../errors.js';
|
|
@@ -172,6 +173,9 @@ function checkFeature(report, root, config, slug, level) {
|
|
|
172
173
|
}
|
|
173
174
|
for (const d of progress.due)
|
|
174
175
|
report.error(scope, `review ${d.step} is due (${d.reason})`);
|
|
176
|
+
const qa = qaProblem(root, config, feature);
|
|
177
|
+
if (qa)
|
|
178
|
+
report.error(scope, qa);
|
|
175
179
|
const { state, record } = verifyState(root, config, feature);
|
|
176
180
|
if (state === 'none')
|
|
177
181
|
report.error(scope, 'no final verify review recorded');
|
package/dist/commands/gates.js
CHANGED
|
@@ -10,6 +10,7 @@ import { blink, mark, tone } from '../ui.js';
|
|
|
10
10
|
import { git } from '../git.js';
|
|
11
11
|
import { acceptanceState, verifyState } from '../progress.js';
|
|
12
12
|
import { NOT_ACCEPTED, runChecks } from './check.js';
|
|
13
|
+
import { qaProblem } from '../qa.js';
|
|
13
14
|
import { AUTO_DEFAULT_FILE, readAutoDefault, removeAutoDefault, writeAutoDefault } from '../auto.js';
|
|
14
15
|
function short(hash) {
|
|
15
16
|
return hash ? hash.slice('sha256:'.length, 'sha256:'.length + 12) : '-';
|
|
@@ -27,6 +28,14 @@ function save(ctx, feature, event, fields) {
|
|
|
27
28
|
writeJson(join(feature.dir, APPROVALS_FILE), feature.approvals);
|
|
28
29
|
appendLog(feature.dir, ctx.now(), event, fields);
|
|
29
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* One line of a confirmation: `label text`, the label in gray like the rows of
|
|
33
|
+
* `status`; a line that continues the one before (leading spaces) stays as it is.
|
|
34
|
+
*/
|
|
35
|
+
function labeled(ctx, line) {
|
|
36
|
+
const match = /^(\S+)(\s+)(.*)$/.exec(line);
|
|
37
|
+
return match ? ` ${ctx.style.gray(match[1])}${match[2]}${match[3]}` : ` ${line}`;
|
|
38
|
+
}
|
|
30
39
|
/** Shows what is being approved and asks the human to type the feature key (design 9.4). */
|
|
31
40
|
async function confirmGate(ctx, feature, title, lines) {
|
|
32
41
|
const logo = mark(ctx.style, ctx.kit, 'a human decision, recorded with your name');
|
|
@@ -36,9 +45,9 @@ async function confirmGate(ctx, feature, title, lines) {
|
|
|
36
45
|
const summary = [
|
|
37
46
|
...(logo.length ? [] : ['']),
|
|
38
47
|
ctx.style.bold(`agjan: ${title}`),
|
|
39
|
-
`
|
|
40
|
-
...lines.map((l) =>
|
|
41
|
-
`
|
|
48
|
+
labeled(ctx, `feature ${ctx.style.bold(feature.slug)} (${ctx.style.cyan(feature.key)})`),
|
|
49
|
+
...lines.map((l) => labeled(ctx, l)),
|
|
50
|
+
labeled(ctx, `approver ${ctx.style.bold(ctx.email())}`),
|
|
42
51
|
'',
|
|
43
52
|
].join('\n');
|
|
44
53
|
if (!ctx.confirm(summary, feature.key)) {
|
|
@@ -120,6 +129,9 @@ function verifyReadiness(ctx, feature) {
|
|
|
120
129
|
const problems = [];
|
|
121
130
|
if (feature.stage !== 'build')
|
|
122
131
|
return { problems: [`the feature is in ${feature.stage}; it is accepted after /agjan-verify`], record: null };
|
|
132
|
+
const qa = qaProblem(ctx.root, ctx.config, feature);
|
|
133
|
+
if (qa)
|
|
134
|
+
problems.push(qa);
|
|
123
135
|
const verify = verifyState(ctx.root, ctx.config, feature);
|
|
124
136
|
if (verify.state === 'none')
|
|
125
137
|
problems.push('no final verify review recorded: /agjan-verify');
|
|
@@ -324,14 +336,14 @@ async function autoDefault(ctx, on) {
|
|
|
324
336
|
s.bold(on ? 'agjan: auto mode for every new feature in this checkout' : 'agjan: auto mode default off'),
|
|
325
337
|
...(on
|
|
326
338
|
? [
|
|
327
|
-
|
|
328
|
-
'
|
|
329
|
-
|
|
330
|
-
`
|
|
331
|
-
|
|
339
|
+
`new features created here from now on start with ${s.yellow('auto mode on')}: spec and design`,
|
|
340
|
+
' pass automatically after their reviews; existing features keep their mode',
|
|
341
|
+
`yours ${s.bold('approve verify')} (the acceptance), accepting findings, amendments, the merge`,
|
|
342
|
+
`local ${s.cyan(AUTO_DEFAULT_FILE)} ${s.gray('(git-ignored)')}: your checkout only, not your teammates'`,
|
|
343
|
+
`off ${s.cyan('npx agjan auto off --default')}; one feature: ${s.cyan('npx agjan auto off')}`,
|
|
332
344
|
]
|
|
333
|
-
: ['
|
|
334
|
-
`
|
|
345
|
+
: ['new features created here wait at their gates again; existing ones keep their mode']).map((l) => labeled(ctx, l)),
|
|
346
|
+
labeled(ctx, `by ${s.bold(ctx.email())}`),
|
|
335
347
|
'',
|
|
336
348
|
].join('\n');
|
|
337
349
|
if (!ctx.confirm(summary, 'auto')) {
|
|
@@ -373,11 +385,12 @@ export async function auto(ctx, argv) {
|
|
|
373
385
|
if (what === 'on') {
|
|
374
386
|
if (current)
|
|
375
387
|
throw new AgjanError(`auto mode of ${feature.slug} is already on (since ${current.at_utc}, by ${current.by})`);
|
|
388
|
+
const s = ctx.style;
|
|
376
389
|
const lines = [
|
|
377
|
-
|
|
390
|
+
`auto spec and design are ${s.yellow('approved automatically')} once their reviews pass;`,
|
|
378
391
|
' the agent goes on to the next step without waiting for you',
|
|
379
|
-
|
|
380
|
-
|
|
392
|
+
`yours ${s.bold('approve verify')} (the acceptance), accepting findings, amendments, the merge`,
|
|
393
|
+
`off ${s.cyan('npx agjan auto off')}, at any time`,
|
|
381
394
|
];
|
|
382
395
|
if (!(await confirmGate(ctx, feature, 'switch auto mode on for this feature', lines)))
|
|
383
396
|
return 1;
|
package/dist/commands/log.js
CHANGED
|
@@ -53,9 +53,11 @@ export function run(ctx, argv) {
|
|
|
53
53
|
const message = cleanMessage(values.message);
|
|
54
54
|
appendLog(feature.dir, ctx.now(), 'gate-requested', message ? { gate, message } : { gate });
|
|
55
55
|
if (approveAutomatically(ctx, feature, gate)) {
|
|
56
|
-
const next = gate === 'spec' ? '
|
|
56
|
+
const next = gate === 'spec' ? 'agjan-design' : 'agjan-build';
|
|
57
57
|
ctx.out(`${ctx.style.green(`approved ${gate} automatically`)} (auto mode, switched on by ${feature.approvals.auto.by})`);
|
|
58
|
-
ctx.out(`commit the feature's documents (${message || `${feature.key}: approve ${gate} (auto mode)`})
|
|
58
|
+
ctx.out(`commit the feature's documents (${message || `${feature.key}: approve ${gate} (auto mode)`}), then continue without stopping:`);
|
|
59
|
+
ctx.out(`your next action is the shell command: cat .claude/skills/${next}/SKILL.md (then follow it).`);
|
|
60
|
+
ctx.out('A reply without a tool call ends your run: put any note for the user into the same reply as that command.');
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
else {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { AGENT_TIERS, CONFIG_FILE, SESSION_MODEL, agentModel } from '../config.js';
|
|
5
|
+
import { readJson, writeJson } from '../json-file.js';
|
|
6
|
+
import { AgjanError, UsageError } from '../errors.js';
|
|
7
|
+
import { pad } from '../ui.js';
|
|
8
|
+
import { sync } from './setup.js';
|
|
9
|
+
/**
|
|
10
|
+
* The models GitHub Copilot CLI accepts, from `copilot help config` (its `model` setting
|
|
11
|
+
* lists them). Null when copilot cannot be run; AGJAN_COPILOT names a stand-in (tests).
|
|
12
|
+
*/
|
|
13
|
+
export function copilotModels() {
|
|
14
|
+
const fake = process.env.AGJAN_COPILOT;
|
|
15
|
+
const run = fake
|
|
16
|
+
? spawnSync(process.execPath, [fake, 'help', 'config'], { encoding: 'utf8', timeout: 30_000 })
|
|
17
|
+
: spawnSync('copilot', ['help', 'config'], { encoding: 'utf8', timeout: 30_000, shell: process.platform === 'win32' });
|
|
18
|
+
if (run.error || run.status !== 0)
|
|
19
|
+
return null;
|
|
20
|
+
const section = /`model`:[^\n]*\n((?:\s+- "[^"]+"\n?)+)/.exec(run.stdout ?? '');
|
|
21
|
+
return section ? [...section[1].matchAll(/- "([^"]+)"/g)].map((m) => m[1]) : null;
|
|
22
|
+
}
|
|
23
|
+
/** What each reviewer runs on, per host and tier. */
|
|
24
|
+
function show(ctx) {
|
|
25
|
+
const s = ctx.style;
|
|
26
|
+
const config = ctx.config;
|
|
27
|
+
for (const host of config.hosts) {
|
|
28
|
+
for (const tier of AGENT_TIERS) {
|
|
29
|
+
const model = agentModel(config, host, tier);
|
|
30
|
+
const agent = tier === 'qa' ? 'agjan-qa' : tier === 'deep' ? 'agjan-reviewer-deep' : 'agjan-reviewer';
|
|
31
|
+
const inherited = tier === 'qa' && !config.models?.[host]?.qa ? s.gray(' (the deep model; its own: models set qa <model>)') : '';
|
|
32
|
+
ctx.out(`${pad(s.bold(host), host, 12)} ${pad(s.gray(tier), tier, 9)} ${pad(agent, agent, 20)} ${model ? s.cyan(model) : s.gray("the session's model")}${inherited}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
ctx.out(s.gray(`change: npx agjan models set <balanced|deep|qa> <model> [--host <host>] (in your terminal); '${SESSION_MODEL}' uses the session's model`));
|
|
36
|
+
if (config.hosts.includes('copilot')) {
|
|
37
|
+
const models = copilotModels();
|
|
38
|
+
if (models)
|
|
39
|
+
ctx.out(s.gray(`copilot models: ${models.join(', ')}`));
|
|
40
|
+
}
|
|
41
|
+
if (config.hosts.includes('claude-code'))
|
|
42
|
+
ctx.out(s.gray('claude-code models: an alias (sonnet, opus, haiku, fable) or a full model id'));
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* agjan models set <tier> <model> [--host <host>] (decision 80): the reviewer's model is a
|
|
47
|
+
* quality decision of the person, not of the agent it reviews: asked on the terminal (the
|
|
48
|
+
* guard denies it to agents), written to agjan.config.json, then `agjan sync` rewrites the
|
|
49
|
+
* reviewer agent files.
|
|
50
|
+
*/
|
|
51
|
+
function set(ctx, tier, model, host) {
|
|
52
|
+
const config = ctx.config;
|
|
53
|
+
if (!AGENT_TIERS.includes(tier))
|
|
54
|
+
throw new UsageError(`tier must be one of: ${AGENT_TIERS.join(', ')}`);
|
|
55
|
+
const hosts = host ? [host] : config.hosts;
|
|
56
|
+
for (const h of hosts)
|
|
57
|
+
if (!config.hosts.includes(h))
|
|
58
|
+
throw new UsageError(`host '${h}' is not configured (hosts: ${config.hosts.join(', ')})`);
|
|
59
|
+
if (model !== SESSION_MODEL && hosts.includes('copilot')) {
|
|
60
|
+
const models = copilotModels();
|
|
61
|
+
if (models && !models.includes(model))
|
|
62
|
+
throw new AgjanError(`GitHub Copilot does not offer '${model}'; its models: ${models.join(', ')}`);
|
|
63
|
+
}
|
|
64
|
+
const answer = ctx.ask(`Let the ${tier} reviewer run on ${model === SESSION_MODEL ? "the session's model" : model} (${hosts.join(', ')})?`, { defaultYes: true });
|
|
65
|
+
if (answer === null)
|
|
66
|
+
throw new AgjanError('choosing the reviewer model needs a human at a terminal; agents must not run it. Run it yourself in a terminal.');
|
|
67
|
+
if (!answer) {
|
|
68
|
+
ctx.out(ctx.style.yellow('cancelled, nothing changed'));
|
|
69
|
+
return 1;
|
|
70
|
+
}
|
|
71
|
+
const file = join(ctx.root, CONFIG_FILE);
|
|
72
|
+
const raw = readJson(file);
|
|
73
|
+
if (!raw)
|
|
74
|
+
throw new AgjanError(`no ${CONFIG_FILE}; run 'agjan init' first`);
|
|
75
|
+
raw.models = raw.models ?? {};
|
|
76
|
+
for (const h of hosts)
|
|
77
|
+
raw.models[h] = { ...(raw.models[h] ?? {}), [tier]: model };
|
|
78
|
+
writeJson(file, raw);
|
|
79
|
+
ctx.out(`${ctx.style.green('set')} models.${hosts.length === 1 ? hosts[0] : `{${hosts.join(',')}}`}.${tier} = ${model}`);
|
|
80
|
+
return sync(ctx, []);
|
|
81
|
+
}
|
|
82
|
+
/** agjan models [set <tier> <model> [--host <host>]] */
|
|
83
|
+
export function run(ctx, argv) {
|
|
84
|
+
const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { host: { type: 'string' } } });
|
|
85
|
+
if (positionals.length === 0 && !values.host)
|
|
86
|
+
return show(ctx);
|
|
87
|
+
if (positionals[0] === 'set' && positionals.length === 3)
|
|
88
|
+
return set(ctx, positionals[1], positionals[2], values.host);
|
|
89
|
+
throw new UsageError('usage: agjan models | agjan models set <balanced|deep|qa> <model> [--host <host>]');
|
|
90
|
+
}
|
|
@@ -8,6 +8,7 @@ import { readFix } from './fix.js';
|
|
|
8
8
|
import { highlightMarkdown } from '../ui.js';
|
|
9
9
|
import { readLog } from '../log.js';
|
|
10
10
|
import { acceptanceState } from '../progress.js';
|
|
11
|
+
import { qaState, qaTestFiles } from '../qa.js';
|
|
11
12
|
function short(hash) {
|
|
12
13
|
return hash ? hash.slice('sha256:'.length, 'sha256:'.length + 12) : '-';
|
|
13
14
|
}
|
|
@@ -104,6 +105,13 @@ function featureSection(ctx, feature) {
|
|
|
104
105
|
const weak = feature.reviews.records.filter((r) => r.reviewer?.isolation !== 'agent');
|
|
105
106
|
if (weak.length)
|
|
106
107
|
out.push(`Reviews without an isolated reviewer agent: ${weak.map((r) => r.id).join(', ')}.`, '');
|
|
108
|
+
const qa = qaState(ctx.root, ctx.config, feature);
|
|
109
|
+
if (qa.state !== 'off') {
|
|
110
|
+
const tests = qaTestFiles(ctx.root, feature.slug);
|
|
111
|
+
out.push(qa.record
|
|
112
|
+
? `**QA:** ${qa.record.id} round ${qa.record.round}: ${qa.record.verdict} (${qa.state}); ${tests.length} test file(s) written from the spec, kept as regression tests: ${tests.map((f) => `\`${f}\``).join(', ') || '-'}.`
|
|
113
|
+
: '**QA:** not run yet.', '');
|
|
114
|
+
}
|
|
107
115
|
const granted = readLog(feature.dir).filter((e) => e.event === 'round-granted');
|
|
108
116
|
if (granted.length)
|
|
109
117
|
out.push(`Rounds beyond the limit, allowed by the user: ${granted.map((e) => `${e.step} round ${e.round}`).join(', ')}.`, '');
|
package/dist/commands/review.js
CHANGED
|
@@ -6,16 +6,19 @@ import { appendLog } from '../log.js';
|
|
|
6
6
|
import { reviewerFor, roundState } from '../review-policy.js';
|
|
7
7
|
import { highlightMarkdown, tone } from '../ui.js';
|
|
8
8
|
import { AgjanError, UsageError } from '../errors.js';
|
|
9
|
-
/** agjan mcp [--host <name>] [--isolation agent|fork|none]: the agjan MCP server on stdio. */
|
|
9
|
+
/** agjan mcp [--host <name>] [--isolation agent|fork|none] [--role review|qa]: the agjan MCP server on stdio. */
|
|
10
10
|
export function mcp(ctx, argv) {
|
|
11
|
-
const { values } = parseArgs({ args: argv, options: { host: { type: 'string' }, isolation: { type: 'string' } } });
|
|
11
|
+
const { values } = parseArgs({ args: argv, options: { host: { type: 'string' }, isolation: { type: 'string' }, role: { type: 'string' } } });
|
|
12
|
+
const role = values.role ?? 'review';
|
|
13
|
+
if (role !== 'review' && role !== 'qa')
|
|
14
|
+
throw new UsageError('--role must be review or qa');
|
|
12
15
|
const isolation = values.isolation ?? 'unknown';
|
|
13
16
|
if (!['agent', 'shared', 'fork', 'none', 'unknown'].includes(isolation)) {
|
|
14
17
|
throw new UsageError('--isolation must be agent, shared, fork or none');
|
|
15
18
|
}
|
|
16
19
|
// Resolve the repository now so a misconfigured server fails at start, not on first call.
|
|
17
20
|
void ctx.root;
|
|
18
|
-
return serve(ctx, { host: values.host ?? 'unknown', isolation: isolation });
|
|
21
|
+
return serve(ctx, { host: values.host ?? 'unknown', isolation: isolation, role });
|
|
19
22
|
}
|
|
20
23
|
/** agjan review show | report | extend: dispatches to the subcommand. */
|
|
21
24
|
export function run(ctx, argv) {
|
package/dist/commands/setup.js
CHANGED
|
@@ -4,7 +4,7 @@ import { homedir } from 'node:os';
|
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
|
-
import { CONFIG_FILE, MODEL_TIERS, SESSION_MODEL, agentModel, loadConfig, loadDomain } from '../config.js';
|
|
7
|
+
import { AGENT_TIERS, CONFIG_FILE, MODEL_TIERS, SESSION_MODEL, agentModel, loadConfig, loadDomain } from '../config.js';
|
|
8
8
|
import { LEGACY_MODELS as CLAUDE_LEGACY } from '../adapters/claude-code.js';
|
|
9
9
|
import { LEGACY_MODELS as COPILOT_LEGACY } from '../adapters/copilot.js';
|
|
10
10
|
import { readJson, writeJson } from '../json-file.js';
|
|
@@ -370,7 +370,7 @@ export async function doctor(ctx) {
|
|
|
370
370
|
else if (config.areas.fiori) {
|
|
371
371
|
ok('ui tests', `none (optional: Playwright, a ${UI_SCRIPT} script; see the fiori-developer skill)`);
|
|
372
372
|
}
|
|
373
|
-
ok('reviewer models', config.hosts.map((h) => `${h}: ${
|
|
373
|
+
ok('reviewer models', `${config.hosts.map((h) => `${h}: ${AGENT_TIERS.map((t) => `${t} ${agentModel(config, h, t) ?? 'session model'}`).join(', ')}`).join('; ')}${config.hosts.every((h) => !agentModel(config, h, 'deep')) ? ' (a deep reviewer on another model family than the writer catches other things: npx agjan models set deep <model>)' : ''}`);
|
|
374
374
|
ok('branches', 'agents ask you, then run npx agjan branch');
|
|
375
375
|
const autoDefault = readAutoDefault(root);
|
|
376
376
|
ok('auto mode', autoDefault ? `on for new features in this checkout (since ${autoDefault.at_utc}); off: npx agjan auto off --default` : 'off: gates wait for you (npx agjan auto on --default for new features, auto on for one)');
|
package/dist/commands/status.js
CHANGED
|
@@ -14,6 +14,7 @@ import { NOT_ACCEPTED, runChecks } from './check.js';
|
|
|
14
14
|
import { readLog } from '../log.js';
|
|
15
15
|
import { finalSteps } from '../progress-view.js';
|
|
16
16
|
import { readAutoDefault } from '../auto.js';
|
|
17
|
+
import { QA_STEP, qaState, qaTestFiles } from '../qa.js';
|
|
17
18
|
/** One indented row: a label column, then the value. `next` and `blocks` stand out. */
|
|
18
19
|
function row(ctx, label, value) {
|
|
19
20
|
const s = ctx.style;
|
|
@@ -32,6 +33,8 @@ function reviewNext(ctx, feature, step) {
|
|
|
32
33
|
return `the ${step} review is still blocked after ${state.round} of ${state.limit} rounds: ask the user whether to run another round (yes: npx agjan review extend ${step}) or to stop and take over (fix with them, accept findings, or change the documents)`;
|
|
33
34
|
}
|
|
34
35
|
const round = state.round ? `, round ${state.next} of ${state.limit}` : '';
|
|
36
|
+
if (step === QA_STEP)
|
|
37
|
+
return `QA (step qa) with ${reviewerFor(ctx.config, step)}${round}`;
|
|
35
38
|
return `review step ${step} with ${reviewerFor(ctx.config, step)}${round}`;
|
|
36
39
|
}
|
|
37
40
|
/** The review step a feature in Spec or Design needs next. */
|
|
@@ -66,8 +69,19 @@ function nextInBuild(ctx, feature, progress) {
|
|
|
66
69
|
return `${ctx.style.green('done')}: verified (${record.id}) and accepted by ${acceptance.approval.by}; the next steps below are optional`;
|
|
67
70
|
return `${ctx.style.green('verified')} (${record.id}): a human accepts it in a terminal: '${ctx.style.bold('npx agjan approve verify')}'`;
|
|
68
71
|
}
|
|
69
|
-
if (lastStage === 'verify')
|
|
72
|
+
if (lastStage === 'verify') {
|
|
73
|
+
// In Verify, QA comes before the final review (decision 81).
|
|
74
|
+
const qa = qaState(ctx.root, ctx.config, feature);
|
|
75
|
+
if (qa.state === 'due' || qa.state === 'stale')
|
|
76
|
+
return `${reviewNext(ctx, feature, QA_STEP)}: it writes and runs tests from the spec (/agjan-verify, QA)`;
|
|
77
|
+
if (qa.state === 'blocked') {
|
|
78
|
+
const rounds = roundState(feature, ctx.config, QA_STEP);
|
|
79
|
+
if (rounds.exhausted)
|
|
80
|
+
return reviewNext(ctx, feature, QA_STEP);
|
|
81
|
+
return `the QA round ${qa.record.id} is blocked: fix the code (never the QA tests), then ${reviewNext(ctx, feature, QA_STEP)}`;
|
|
82
|
+
}
|
|
70
83
|
return 'verify is running: /agjan-verify';
|
|
84
|
+
}
|
|
71
85
|
return feature.approvals.auto ? 'all tasks done and reviewed: auto mode: the agent goes on with /agjan-verify' : 'all tasks done and reviewed: a human starts the verification: /agjan-verify';
|
|
72
86
|
}
|
|
73
87
|
/** "2 open, 1 blocker(s)", red when a blocker is open. */
|
|
@@ -203,6 +217,12 @@ async function describe(ctx, feature, onBase = false) {
|
|
|
203
217
|
row(ctx, 'spec', tone(ctx.style, feature.state.spec));
|
|
204
218
|
const mode = feature.design?.parsed.mode ? ` (${feature.design.parsed.mode})` : '';
|
|
205
219
|
row(ctx, 'design', `${tone(ctx.style, feature.state.design)}${mode}`);
|
|
220
|
+
const qa = qaState(ctx.root, ctx.config, feature);
|
|
221
|
+
if (qa.state !== 'off' && feature.stage === 'build') {
|
|
222
|
+
const tests = qaTestFiles(ctx.root, feature.slug).length;
|
|
223
|
+
const text = qa.state === 'due' ? 'not run yet: in Verify, agjan-qa writes and runs tests from the spec' : `${tone(ctx.style, qa.state)} (${qa.record.id}, ${tests} QA test file(s))`;
|
|
224
|
+
row(ctx, 'qa', text);
|
|
225
|
+
}
|
|
206
226
|
const auto = feature.approvals.auto;
|
|
207
227
|
if (auto)
|
|
208
228
|
row(ctx, 'auto', `${ctx.style.yellow('on')} (switched on by ${auto.by}, ${auto.at_utc}): spec and design pass automatically after their reviews; approve verify stays yours`);
|
package/dist/config.js
CHANGED
|
@@ -10,9 +10,13 @@ const KIT_DIR = new URL('../kit/', import.meta.url);
|
|
|
10
10
|
*/
|
|
11
11
|
export const SESSION_MODEL = 'session';
|
|
12
12
|
export const MODEL_TIERS = ['balanced', 'deep'];
|
|
13
|
+
/** Every agent tier `agjan models` sets: the reviewers' and the QA agent's (decision 81). */
|
|
14
|
+
export const AGENT_TIERS = [...MODEL_TIERS, 'qa'];
|
|
13
15
|
/** The model to write into an agent file, or undefined for the session's model. */
|
|
14
16
|
export function agentModel(config, host, tier) {
|
|
15
|
-
const
|
|
17
|
+
const models = config.models?.[host];
|
|
18
|
+
// The QA agent runs on the deep model unless it has its own (decision 81).
|
|
19
|
+
const value = models?.[tier] ?? (tier === 'qa' ? models?.deep : undefined) ?? models?.balanced;
|
|
16
20
|
return value && value !== SESSION_MODEL ? value : undefined;
|
|
17
21
|
}
|
|
18
22
|
/** Package defaults. Domain defaults and project overrides are layered on top. */
|
package/dist/mcp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
|
-
import { createReviewContext, recordReview } from './review.js';
|
|
2
|
+
import { createQaContext, createReviewContext, recordQa, recordReview } from './review.js';
|
|
3
3
|
import { selectFeature } from './feature.js';
|
|
4
4
|
import { AgjanError } from './errors.js';
|
|
5
5
|
/**
|
|
@@ -24,6 +24,38 @@ const FINDING_SCHEMA = {
|
|
|
24
24
|
required: ['severity', 'issue'],
|
|
25
25
|
additionalProperties: false,
|
|
26
26
|
};
|
|
27
|
+
/** The QA agent's tools (decision 81): its own server, so the reviewer never sees them. */
|
|
28
|
+
export const QA_TOOLS = [
|
|
29
|
+
{
|
|
30
|
+
name: 'qa_context',
|
|
31
|
+
title: 'agjan: get QA context',
|
|
32
|
+
description: 'Returns the tester\'s inputs for the QA step of an agjan feature and a context_id: the spec, how to run the ' +
|
|
33
|
+
'application, its users, the test conventions and your QA folders. Write and run tests only from this material.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: { feature: { type: 'string', description: 'Feature slug; optional when exactly one feature changed on the branch' } },
|
|
37
|
+
additionalProperties: false,
|
|
38
|
+
},
|
|
39
|
+
annotations: { readOnlyHint: true },
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'qa_record',
|
|
43
|
+
title: 'agjan: record QA result',
|
|
44
|
+
description: 'Records the QA result for a context_id: verdict, findings (failing tests, spec questions) and the ids of earlier ' +
|
|
45
|
+
'QA findings that pass now. Refused if files outside your QA folders changed.',
|
|
46
|
+
inputSchema: {
|
|
47
|
+
type: 'object',
|
|
48
|
+
properties: {
|
|
49
|
+
context_id: { type: 'string' },
|
|
50
|
+
verdict: { type: 'string', enum: ['pass', 'pass-with-notes', 'blocked'] },
|
|
51
|
+
findings: { type: 'array', items: FINDING_SCHEMA, maxItems: 50 },
|
|
52
|
+
resolves: { type: 'array', items: { type: 'string' } },
|
|
53
|
+
},
|
|
54
|
+
required: ['context_id', 'verdict'],
|
|
55
|
+
additionalProperties: false,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
];
|
|
27
59
|
export const TOOLS = [
|
|
28
60
|
{
|
|
29
61
|
name: 'review_context',
|
|
@@ -66,6 +98,19 @@ function text(content, isError = false) {
|
|
|
66
98
|
/** Handles one tools/call; tool failures are results with isError, not protocol errors. */
|
|
67
99
|
function callTool(ctx, server, name, args = {}) {
|
|
68
100
|
try {
|
|
101
|
+
if (server.role === 'qa') {
|
|
102
|
+
if (name === 'qa_context') {
|
|
103
|
+
const feature = selectFeature(ctx.root, ctx.config, args.feature);
|
|
104
|
+
const { id, text: body } = createQaContext(ctx.root, ctx.config, { feature });
|
|
105
|
+
return text(`context_id: ${id}\n\n${body}`);
|
|
106
|
+
}
|
|
107
|
+
if (name === 'qa_record') {
|
|
108
|
+
const record = recordQa(ctx.root, ctx.config, args, { host: server.host, isolation: server.isolation, now: ctx.now });
|
|
109
|
+
const ids = record.findings.map((f) => f.id).join(', ') || 'none';
|
|
110
|
+
return text(`recorded ${record.id} (qa, round ${record.round}): ${record.verdict}; findings: ${ids}; QA tests: ${record.qa_tests?.length ?? 0}`);
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
69
114
|
if (name === 'review_context') {
|
|
70
115
|
const feature = selectFeature(ctx.root, ctx.config, args.feature);
|
|
71
116
|
const { id, text: body } = createReviewContext(ctx.root, ctx.config, { feature, step: args.step });
|
|
@@ -107,7 +152,7 @@ export function handleMessage(ctx, server, message) {
|
|
|
107
152
|
case 'ping':
|
|
108
153
|
return reply({});
|
|
109
154
|
case 'tools/list':
|
|
110
|
-
return reply({ tools: TOOLS });
|
|
155
|
+
return reply({ tools: server.role === 'qa' ? QA_TOOLS : TOOLS });
|
|
111
156
|
case 'tools/call': {
|
|
112
157
|
const result = callTool(ctx, server, params?.name, params?.arguments);
|
|
113
158
|
return result ? reply(result) : fail(-32602, `unknown tool '${params?.name}'`);
|
package/dist/progress-view.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { git } from './git.js';
|
|
4
|
-
import { loadConfig } from './config.js';
|
|
4
|
+
import { agentModel, loadConfig } from './config.js';
|
|
5
5
|
import { FEATURES_DIR, changedFeatures, listFeatures, loadFeature, stillBlocked } from './feature.js';
|
|
6
6
|
import { readLog } from './log.js';
|
|
7
7
|
import { acceptanceState, buildProgress, verifyState } from './progress.js';
|
|
@@ -166,7 +166,7 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {})
|
|
|
166
166
|
round: r.round,
|
|
167
167
|
verdict: r.verdict,
|
|
168
168
|
at: r.at_utc,
|
|
169
|
-
tier:
|
|
169
|
+
tier: { 'agjan-reviewer-deep': 'deep', 'agjan-qa': 'qa' }[reviewerFor(config, r.step)] ?? 'balanced',
|
|
170
170
|
host: r.reviewer?.host ?? null,
|
|
171
171
|
isolation: r.reviewer?.isolation ?? null,
|
|
172
172
|
findings: (r.findings ?? []).map((f) => f.id),
|
|
@@ -237,14 +237,14 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {})
|
|
|
237
237
|
shown.push({ ...d });
|
|
238
238
|
}
|
|
239
239
|
const tierModel = (tier) => {
|
|
240
|
-
const value = host ? config
|
|
240
|
+
const value = host ? agentModel(config, host, tier) : undefined;
|
|
241
241
|
return !value || value === 'session' ? 'session model' : value;
|
|
242
242
|
};
|
|
243
|
-
const reviewers = ['balanced', 'deep']
|
|
243
|
+
const reviewers = ['balanced', 'deep', 'qa']
|
|
244
244
|
.map((tier) => {
|
|
245
245
|
const own = reviews.filter((r) => r.tier === tier);
|
|
246
246
|
return {
|
|
247
|
-
name: tier === 'deep' ? 'agjan-reviewer-deep' : 'agjan-reviewer',
|
|
247
|
+
name: tier === 'qa' ? 'agjan-qa' : tier === 'deep' ? 'agjan-reviewer-deep' : 'agjan-reviewer',
|
|
248
248
|
tier,
|
|
249
249
|
model: tierModel(tier),
|
|
250
250
|
count: own.length,
|
|
@@ -354,7 +354,7 @@ export function timelineRows(model) {
|
|
|
354
354
|
}
|
|
355
355
|
for (const r of model.reviews) {
|
|
356
356
|
const what = r.findings.length ? ` (${severities(r.findings, model.findings)})` : '';
|
|
357
|
-
rows.push([r.at, `🔍 reviewer${r.tier === 'deep' ? ' (deep)' : ''}`, `${r.step} · round ${r.round} → ${VERDICT_MD[r.verdict]}${what}`]);
|
|
357
|
+
rows.push([r.at, r.tier === 'qa' ? '🧪 qa' : `🔍 reviewer${r.tier === 'deep' ? ' (deep)' : ''}`, `${r.step} · round ${r.round} → ${VERDICT_MD[r.verdict]}${what}`]);
|
|
358
358
|
}
|
|
359
359
|
for (const d of model.decisions)
|
|
360
360
|
rows.push([d.at, '👤 human', `${d.what}${d.detail ? `: ${d.detail}` : ''}`]);
|
package/dist/qa.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { latestReview, stillBlocked } from './feature.js';
|
|
5
|
+
/**
|
|
6
|
+
* The QA step (design decision 81): in Verify, the QA agent (`agjan-qa`, the qa-tester
|
|
7
|
+
* skill) writes and runs tests from the spec alone, without the design, the diff or the
|
|
8
|
+
* writer's tests. Its tests stay in the project as regression tests, in two folders per
|
|
9
|
+
* feature: service tests, and UI tests where the project's Playwright tests live.
|
|
10
|
+
*/
|
|
11
|
+
export const QA_STEP = 'qa';
|
|
12
|
+
/** The folders a feature's QA tests live in; the only paths the QA agent writes. */
|
|
13
|
+
export function qaDirs(slug) {
|
|
14
|
+
return [`test/qa/${slug}/`, `test/ui/qa/${slug}/`];
|
|
15
|
+
}
|
|
16
|
+
/** QA runs for full-mode features unless the project turns it off (`review.qa: "off"`). */
|
|
17
|
+
export function qaApplies(config, feature) {
|
|
18
|
+
return feature.kind === 'feature' && feature.design?.parsed.mode === 'full' && config.review?.qa !== 'off';
|
|
19
|
+
}
|
|
20
|
+
function filesUnder(root, dir) {
|
|
21
|
+
const abs = join(root, dir);
|
|
22
|
+
if (!existsSync(abs))
|
|
23
|
+
return [];
|
|
24
|
+
const out = [];
|
|
25
|
+
const walk = (rel) => {
|
|
26
|
+
for (const entry of readdirSync(join(root, rel), { withFileTypes: true })) {
|
|
27
|
+
const path = `${rel}${entry.name}`;
|
|
28
|
+
if (entry.isDirectory())
|
|
29
|
+
walk(`${path}/`);
|
|
30
|
+
else if (entry.isFile())
|
|
31
|
+
out.push(path);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
walk(dir);
|
|
35
|
+
return out;
|
|
36
|
+
}
|
|
37
|
+
/** The QA test files of a feature, sorted, as repository paths. */
|
|
38
|
+
export function qaTestFiles(root, slug) {
|
|
39
|
+
return qaDirs(slug).flatMap((dir) => filesUnder(root, dir)).sort();
|
|
40
|
+
}
|
|
41
|
+
/** Hash of the feature's QA tests as they are now: a change after QA makes it stale. */
|
|
42
|
+
export function qaTestsHash(root, slug) {
|
|
43
|
+
const hash = createHash('sha256');
|
|
44
|
+
for (const file of qaTestFiles(root, slug)) {
|
|
45
|
+
hash.update(file).update('\0').update(createHash('sha256').update(readFileSync(join(root, file))).digest('hex')).update('\0');
|
|
46
|
+
}
|
|
47
|
+
return `sha256:${hash.digest('hex')}`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Where QA stands: `off` (light mode, or turned off), `due` (no QA round yet), `blocked`
|
|
51
|
+
* (its blockers are open: fix the code, then QA again), `stale` (the QA tests changed
|
|
52
|
+
* after the round: QA again) or `passed`. Code changes after a passing round are the
|
|
53
|
+
* final review's to judge, not QA's.
|
|
54
|
+
*/
|
|
55
|
+
export function qaState(root, config, feature) {
|
|
56
|
+
if (!qaApplies(config, feature))
|
|
57
|
+
return { state: 'off', record: null };
|
|
58
|
+
const record = latestReview(feature.reviews, [QA_STEP]);
|
|
59
|
+
if (!record)
|
|
60
|
+
return { state: 'due', record: null };
|
|
61
|
+
if (stillBlocked(feature, record))
|
|
62
|
+
return { state: 'blocked', record };
|
|
63
|
+
if (record.qa_tests_hash !== qaTestsHash(root, feature.slug))
|
|
64
|
+
return { state: 'stale', record };
|
|
65
|
+
return { state: 'passed', record };
|
|
66
|
+
}
|
|
67
|
+
/** Why the final review and the acceptance wait for QA, or null when they need not. */
|
|
68
|
+
export function qaProblem(root, config, feature) {
|
|
69
|
+
const qa = qaState(root, config, feature);
|
|
70
|
+
if (qa.state === 'due')
|
|
71
|
+
return 'QA has not run yet: delegate step qa to agjan-qa';
|
|
72
|
+
if (qa.state === 'blocked')
|
|
73
|
+
return `the QA round ${qa.record.id} is blocked: fix the code (never the QA tests), then run QA again`;
|
|
74
|
+
if (qa.state === 'stale')
|
|
75
|
+
return `the QA tests changed after the QA round ${qa.record.id}: run QA again`;
|
|
76
|
+
return null;
|
|
77
|
+
}
|
package/dist/review-policy.js
CHANGED
|
@@ -15,6 +15,7 @@ export const DEFAULT_TIERS = {
|
|
|
15
15
|
verify: 'deep',
|
|
16
16
|
fix: 'balanced',
|
|
17
17
|
map: 'balanced',
|
|
18
|
+
qa: 'qa',
|
|
18
19
|
};
|
|
19
20
|
/** `build:cap` and `build:T2` are both of kind `build`. */
|
|
20
21
|
export function stepKind(step) {
|
|
@@ -24,7 +25,7 @@ export function stepKind(step) {
|
|
|
24
25
|
export function reviewerFor(config, step) {
|
|
25
26
|
const kind = stepKind(step);
|
|
26
27
|
const tier = config.review?.tiers?.[kind] ?? DEFAULT_TIERS[kind] ?? 'balanced';
|
|
27
|
-
return tier === 'deep' ? 'agjan-reviewer-deep' : 'agjan-reviewer';
|
|
28
|
+
return tier === 'qa' ? 'agjan-qa' : tier === 'deep' ? 'agjan-reviewer-deep' : 'agjan-reviewer';
|
|
28
29
|
}
|
|
29
30
|
export function roundLimit(config) {
|
|
30
31
|
return config.review?.rounds ?? 3;
|
package/dist/review.js
CHANGED
|
@@ -15,6 +15,8 @@ import { LOG_FILE, appendLog } from './log.js';
|
|
|
15
15
|
import { AgjanError } from './errors.js';
|
|
16
16
|
import { nextRound } from './review-policy.js';
|
|
17
17
|
import { designProblems, documentProblems } from './validate.js';
|
|
18
|
+
import { QA_STEP, qaApplies, qaDirs, qaProblem, qaState, qaTestFiles, qaTestsHash } from './qa.js';
|
|
19
|
+
import { buildProgress } from './progress.js';
|
|
18
20
|
export const REVIEW_MD = 'review.md';
|
|
19
21
|
const CONTEXT_DIR = '.agjan/review-contexts';
|
|
20
22
|
/** Limit for diffs inside a review context, so a huge change cannot flood the reviewer. */
|
|
@@ -48,11 +50,11 @@ function currentContent(path) {
|
|
|
48
50
|
* (committed, staged, unstaged, untracked) with its current content, except the
|
|
49
51
|
* feature's script-owned files. Any write to the working tree changes it.
|
|
50
52
|
*/
|
|
51
|
-
export function treeHash(root, config, slug) {
|
|
53
|
+
export function treeHash(root, config, slug, except = []) {
|
|
52
54
|
const skip = scriptOwned(slug);
|
|
53
55
|
const hash = createHash('sha256');
|
|
54
56
|
for (const file of changedFiles(root, resolveBase(root, config.git?.base))) {
|
|
55
|
-
if (skip.has(file) || file.startsWith('.agjan/'))
|
|
57
|
+
if (skip.has(file) || file.startsWith('.agjan/') || except.some((dir) => file.startsWith(dir)))
|
|
56
58
|
continue;
|
|
57
59
|
const content = currentContent(join(root, file));
|
|
58
60
|
hash.update(file).update('\0');
|
|
@@ -72,7 +74,7 @@ export function parseStep(step, feature, config) {
|
|
|
72
74
|
}
|
|
73
75
|
if (step === 'fix' || step === 'map')
|
|
74
76
|
throw new AgjanError(`'${step}' reviews belong to a ${step} record, not to a feature`);
|
|
75
|
-
if (['spec', 'design', 'design:light', 'verify'].includes(step))
|
|
77
|
+
if (['spec', 'design', 'design:light', 'verify', QA_STEP].includes(step))
|
|
76
78
|
return { step, kind: step };
|
|
77
79
|
const match = /^build:(.+)$/.exec(step ?? '');
|
|
78
80
|
if (!match)
|
|
@@ -146,7 +148,7 @@ const CHECKLISTS = {
|
|
|
146
148
|
build: 'Each covered AC is met by the diff. Tests exist and carry the AC id in their names. An AC that a user does on a page of a Fiori app (create a record, choose an action) has a UI test (Playwright, test/ui) besides the service tests; UI tests that agjan ui-test skipped because no browser can start here are not a finding. Project conventions. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request, and for every where condition a test with a user who has the role but whom the condition excludes. The service has a service-level @requires, so nothing it exposes (code lists, auto-exposed entities) is open. Security basics (authorization, input validation, no secrets; test or mocked users and other development settings only in a development profile, never active in production). Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope.',
|
|
147
149
|
fix: 'The change does exactly what the fix description says and nothing else. It is correct and complete. A test covers it where practical. No hidden scope: anything that changes behaviour beyond the description, or needs a business decision, is a blocker (it belongs in /agjan-spec).',
|
|
148
150
|
map: 'Every claim in project.md is traceable to the files it points to. Services, applications and BTP services are complete. The do-not-touch list is plausible and uses real paths. Short: one to two pages, pointers instead of copies.',
|
|
149
|
-
verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. UI tests that agjan ui-test skipped because no browser can start here are not a finding: the final message names those ACs for the human. When the project records no test results (no results file in the context), judge coverage by the tests that carry the AC ids: missing recorded results is a project setting for the human, not a finding. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request. Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope. The baseline (project.md) updated if a service, application or BTP service was added, and its section "Run locally" (start command, app URLs, test users and roles) matches the change. Do not re-review each task.',
|
|
151
|
+
verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. When the context has a QA section: the QA round passed and its tests (test/qa, test/ui/qa) are part of the change; the writer fixed the code for QA blockers, never the QA tests. UI tests that agjan ui-test skipped because no browser can start here are not a finding: the final message names those ACs for the human. When the project records no test results (no results file in the context), judge coverage by the tests that carry the AC ids: missing recorded results is a project setting for the human, not a finding. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request. Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope. The baseline (project.md) updated if a service, application or BTP service was added, and its section "Run locally" (start command, app URLs, test users and roles) matches the change. Do not re-review each task.',
|
|
150
152
|
};
|
|
151
153
|
/**
|
|
152
154
|
* What the given tasks may change (design 6.5), as `agjan check` judges it: the task paths,
|
|
@@ -244,6 +246,13 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
244
246
|
parts.push(section(docPath(feature, 'tasks.md'), fence(feature.tasks.text, 'md')));
|
|
245
247
|
parts.push(section('Allowed paths (scope, enforced by agjan check)', scopeText(scopeOf(config, feature, feature.tasks.parsed.tasks))));
|
|
246
248
|
parts.push(section('Changed files', changed.map((f) => `- ${f}`).join('\n') || '(none)'));
|
|
249
|
+
const qa = qaState(root, config, feature);
|
|
250
|
+
if (qa.state !== 'off') {
|
|
251
|
+
const tests = qaTestFiles(root, feature.slug);
|
|
252
|
+
parts.push(section('QA (tests written from the spec by the QA agent)', qa.record
|
|
253
|
+
? `${qa.record.id} round ${qa.record.round}: ${qa.record.verdict} (${qa.state}); ${tests.length} QA test file(s):\n${tests.map((f) => `- ${f}`).join('\n')}`
|
|
254
|
+
: 'not run'));
|
|
255
|
+
}
|
|
247
256
|
parts.push(section('Full diff', fence(diffOf(root, base, changed), 'diff')));
|
|
248
257
|
}
|
|
249
258
|
if (baselineText && parsed.kind !== 'build' && parsed.kind !== 'fix')
|
|
@@ -298,6 +307,12 @@ export function createReviewContext(root, config, { feature: slug, step }) {
|
|
|
298
307
|
const feature = loadFeature(root, slug);
|
|
299
308
|
const parsed = parseStep(step, feature, config);
|
|
300
309
|
unfinishedDocuments(feature, config, parsed.step);
|
|
310
|
+
if (parsed.step === QA_STEP)
|
|
311
|
+
throw new AgjanError('step qa is done by the QA agent (agjan-qa, qa_context), not by a reviewer');
|
|
312
|
+
// The final review comes after QA (decision 81).
|
|
313
|
+
const qa = parsed.step === 'verify' ? qaProblem(root, config, feature) : null;
|
|
314
|
+
if (qa)
|
|
315
|
+
throw new AgjanError(`the final review waits for QA: ${qa}`);
|
|
301
316
|
const tree = treeHash(root, config, feature.slug);
|
|
302
317
|
unchangedSinceFindings(feature, parsed.step, tree);
|
|
303
318
|
const text = buildContextText(root, config, feature, parsed);
|
|
@@ -339,19 +354,17 @@ function validFinding(f, i) {
|
|
|
339
354
|
return `${where} has unknown field(s): ${extra.join(', ')}`;
|
|
340
355
|
return null;
|
|
341
356
|
}
|
|
342
|
-
/**
|
|
343
|
-
|
|
344
|
-
* Refuses when anything in the working tree changed since the context was produced.
|
|
345
|
-
*/
|
|
346
|
-
export function recordReview(root, config, { context_id: contextId, verdict, findings = [], resolves = [] }, { host = 'unknown', isolation = 'unknown', now }) {
|
|
357
|
+
/** Checks a result against its context; shared by review_record and qa_record. */
|
|
358
|
+
function validResult(root, { context_id: contextId, verdict, findings = [], resolves = [] }, kind) {
|
|
347
359
|
if (typeof contextId !== 'string' || !/^[A-Z][A-Z0-9]{1,5}-C[0-9a-f]{8}$/.test(contextId))
|
|
348
360
|
throw new AgjanError('context_id is missing or malformed');
|
|
349
361
|
const metaFile = join(root, CONTEXT_DIR, `${contextId}.json`);
|
|
350
362
|
const meta = readJson(metaFile);
|
|
351
|
-
|
|
352
|
-
|
|
363
|
+
const call = kind === 'qa' ? 'qa_context' : 'review_context';
|
|
364
|
+
if (!meta || (meta.kind ?? 'review') !== kind)
|
|
365
|
+
throw new AgjanError(`unknown context ${contextId}; call ${call} first`);
|
|
353
366
|
if (meta.recorded)
|
|
354
|
-
throw new AgjanError(`context ${contextId} was already used for ${meta.recorded}; call
|
|
367
|
+
throw new AgjanError(`context ${contextId} was already used for ${meta.recorded}; call ${call} again`);
|
|
355
368
|
if (typeof verdict !== 'string' || !VERDICTS.includes(verdict))
|
|
356
369
|
throw new AgjanError(`verdict must be one of ${VERDICTS.join(', ')}`);
|
|
357
370
|
if (!Array.isArray(findings) || findings.length > 50)
|
|
@@ -373,10 +386,11 @@ export function recordReview(root, config, { context_id: contextId, verdict, fin
|
|
|
373
386
|
const unknown = resolves.filter((id) => !open.has(id));
|
|
374
387
|
if (unknown.length)
|
|
375
388
|
throw new AgjanError(`resolves lists findings that are not open: ${unknown.join(', ')}`);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
389
|
+
return { contextId, metaFile, meta, feature, verdict: verdict, findings: findings, resolves: resolves };
|
|
390
|
+
}
|
|
391
|
+
/** Appends a record to reviews.json, regenerates review.md and logs it. */
|
|
392
|
+
function storeRecord(root, result, { host = 'unknown', isolation = 'unknown', now }, extra) {
|
|
393
|
+
const { contextId, metaFile, meta, feature } = result;
|
|
380
394
|
const records = feature.reviews.records;
|
|
381
395
|
let next = feature.findings.length;
|
|
382
396
|
const record = {
|
|
@@ -388,12 +402,12 @@ export function recordReview(root, config, { context_id: contextId, verdict, fin
|
|
|
388
402
|
context: contextId,
|
|
389
403
|
documents: meta.documents,
|
|
390
404
|
inputs_hash: meta.inputs_hash,
|
|
391
|
-
tree_hash: meta.tree_hash,
|
|
392
405
|
base_commit: meta.base_commit,
|
|
393
406
|
head_commit: meta.head_commit,
|
|
394
|
-
verdict: verdict,
|
|
395
|
-
resolves: resolves,
|
|
396
|
-
findings: findings.map((f) => ({ id: `${feature.key}-F${++next}`, ...f })),
|
|
407
|
+
verdict: result.verdict,
|
|
408
|
+
resolves: result.resolves,
|
|
409
|
+
findings: result.findings.map((f) => ({ id: `${feature.key}-F${++next}`, ...f })),
|
|
410
|
+
...extra,
|
|
397
411
|
};
|
|
398
412
|
records.push(record);
|
|
399
413
|
writeJson(join(feature.dir, REVIEWS_FILE), { schema: 1, records });
|
|
@@ -410,6 +424,91 @@ export function recordReview(root, config, { context_id: contextId, verdict, fin
|
|
|
410
424
|
});
|
|
411
425
|
return record;
|
|
412
426
|
}
|
|
427
|
+
/**
|
|
428
|
+
* review_record: validates the reviewer's result against its context and appends it.
|
|
429
|
+
* Refuses when anything in the working tree changed since the context was produced.
|
|
430
|
+
*/
|
|
431
|
+
export function recordReview(root, config, input, recorder) {
|
|
432
|
+
const result = validResult(root, input, 'review');
|
|
433
|
+
if (treeHash(root, config, result.feature.slug) !== result.meta.tree_hash) {
|
|
434
|
+
throw new AgjanError('the working tree changed since review_context was called; nothing was recorded. ' +
|
|
435
|
+
'A reviewer must not change files. Call review_context again and review the current state.');
|
|
436
|
+
}
|
|
437
|
+
return storeRecord(root, result, recorder, { tree_hash: result.meta.tree_hash });
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* qa_context (decision 81): the QA agent's input. Only what a tester gets: the spec, how
|
|
441
|
+
* to run the application and who its users are, and the test conventions; never the
|
|
442
|
+
* design, the diff or the writer's tests. Ready once the build is complete and reviewed.
|
|
443
|
+
*/
|
|
444
|
+
export function createQaContext(root, config, { feature: slug }) {
|
|
445
|
+
const feature = loadFeature(root, slug);
|
|
446
|
+
if (!qaApplies(config, feature))
|
|
447
|
+
throw new AgjanError(`QA does not apply to ${slug}: it runs for full-mode features (review.qa is ${config.review?.qa ?? 'on'})`);
|
|
448
|
+
if (feature.stage !== 'build' || !feature.spec)
|
|
449
|
+
throw new AgjanError(`${slug} is not in Build yet; QA runs in Verify`);
|
|
450
|
+
const progress = buildProgress(root, config, feature);
|
|
451
|
+
if (!progress.complete || progress.due.length)
|
|
452
|
+
throw new AgjanError('QA runs after the build: every task committed and its reviews done (npx agjan status)');
|
|
453
|
+
const dirs = qaDirs(feature.slug);
|
|
454
|
+
const baseline = join(root, FEATURES_DIR, 'project.md');
|
|
455
|
+
const runLocally = existsSync(baseline) ? (/^## Run locally\s*$([\s\S]*?)(?=^## |\s*$(?![\s\S]))/m.exec(readFileSync(baseline, 'utf8'))?.[1] ?? '').trim() : '';
|
|
456
|
+
const areaNames = [...new Set(feature.tasks.parsed.tasks.map((t) => resolveArea(config, t.area)?.name).filter((name) => Boolean(name)))];
|
|
457
|
+
const commands = areaNames.map((a) => `- ${a}: ${config.verify?.[a]?.test ?? 'npm test'} (tests: ${(config.tests[a] ?? []).join(', ') || '-'})`).join('\n');
|
|
458
|
+
const ui = Boolean(readJson(join(root, 'package.json'))?.scripts?.['test:ui']);
|
|
459
|
+
const existing = qaTestFiles(root, feature.slug);
|
|
460
|
+
const parts = [
|
|
461
|
+
`# QA context: ${feature.slug} (${feature.key}), step qa`,
|
|
462
|
+
'',
|
|
463
|
+
'You are the tester. You know the requirements, not the code: do not read the design, the application code or the existing tests, and do not change anything outside your QA folders.',
|
|
464
|
+
'',
|
|
465
|
+
section('Your QA folders (the only paths you write)', `${dirs.map((d) => `- \`${d}\``).join('\n')}\n\nService tests go into \`${dirs[0]}\`, UI tests (Playwright) into \`${dirs[1]}\`. Name each test \`${feature.key}-AC<n> QA: <what it checks>\`. They stay in the project as regression tests.`),
|
|
466
|
+
section(docPath(feature, 'spec.md'), fence(feature.spec.text, 'md')),
|
|
467
|
+
section('Run locally (from docs/agjan/project.md)', runLocally || '(not described: start the application as the project README or package.json says)'),
|
|
468
|
+
section('Test conventions', `${commands}\n- UI tests: ${ui ? '`npx agjan ui-test` runs the Playwright tests (it skips them, with the reason, where no browser can start)' : 'the project has no Playwright setup (no `test:ui` script): write service tests only'}\n- How tests are written in this stack: \`.claude/skills/cap-developer/references/testing.md\` (cds.test) and \`.claude/skills/fiori-developer/references/testing.md\` (Playwright). Read those for the test mechanics only.`),
|
|
469
|
+
section('Your tests from earlier QA rounds', existing.length ? existing.map((f) => `- ${f}`).join('\n') : '(none: this is the first QA round)'),
|
|
470
|
+
section('Earlier rounds', reviewHistory(feature)),
|
|
471
|
+
section('Open findings', openFindings(feature, [QA_STEP])),
|
|
472
|
+
section('How to record your result', 'Run your tests. Then call qa_record with this context_id, a verdict (pass, pass-with-notes, blocked), your findings and in `resolves` the ids of earlier QA findings that pass now. ' +
|
|
473
|
+
'A test that fails against an acceptance criterion or an authorization rule is a blocker (file: the test file; evidence: the test name and the failure output). ' +
|
|
474
|
+
'Something the spec does not decide is a minor finding starting with "Spec question:". A blocker requires the verdict blocked.'),
|
|
475
|
+
];
|
|
476
|
+
const text = parts.join('\n');
|
|
477
|
+
const id = `${feature.key}-C${randomBytes(4).toString('hex')}`;
|
|
478
|
+
const base = resolveBase(root, config.git?.base);
|
|
479
|
+
const meta = {
|
|
480
|
+
id,
|
|
481
|
+
kind: 'qa',
|
|
482
|
+
feature: feature.slug,
|
|
483
|
+
step: QA_STEP,
|
|
484
|
+
documents: { spec: feature.spec.hash, design: feature.designHash ?? undefined },
|
|
485
|
+
inputs_hash: sha256(text),
|
|
486
|
+
tree_hash: treeHash(root, config, feature.slug, dirs),
|
|
487
|
+
base_commit: mergeBase(root, base),
|
|
488
|
+
head_commit: git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true })?.trim() ?? null,
|
|
489
|
+
};
|
|
490
|
+
const dir = join(root, CONTEXT_DIR);
|
|
491
|
+
mkdirSync(dir, { recursive: true });
|
|
492
|
+
writeJson(join(dir, `${id}.json`), meta);
|
|
493
|
+
return { id, text };
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* qa_record: the QA agent's result. Refused when it changed anything outside its QA
|
|
497
|
+
* folders; records the hash of its tests, so a later change to them makes QA stale.
|
|
498
|
+
*/
|
|
499
|
+
export function recordQa(root, config, input, recorder) {
|
|
500
|
+
const result = validResult(root, input, 'qa');
|
|
501
|
+
const slug = result.feature.slug;
|
|
502
|
+
if (treeHash(root, config, slug, qaDirs(slug)) !== result.meta.tree_hash) {
|
|
503
|
+
throw new AgjanError(`files outside the QA folders (${qaDirs(slug).join(', ')}) changed since qa_context was called; nothing was recorded. ` +
|
|
504
|
+
'QA writes only its own tests. Undo the other changes, then call qa_context again.');
|
|
505
|
+
}
|
|
506
|
+
return storeRecord(root, result, recorder, {
|
|
507
|
+
tree_hash: treeHash(root, config, slug),
|
|
508
|
+
qa_tests_hash: qaTestsHash(root, slug),
|
|
509
|
+
qa_tests: qaTestFiles(root, slug),
|
|
510
|
+
});
|
|
511
|
+
}
|
|
413
512
|
/** Renders review.md from reviews.json (design 8.5). Generated; never edited by hand. */
|
|
414
513
|
export function renderReviewMd(feature) {
|
|
415
514
|
const out = [`# Reviews: ${feature.slug} (${feature.key})`, '', '<!-- Generated by agjan from reviews.json. Do not edit. -->', ''];
|
package/dist/scope.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import picomatch from 'picomatch';
|
|
2
2
|
import { resolveArea } from './config.js';
|
|
3
|
+
import { qaDirs } from './qa.js';
|
|
3
4
|
/** A path ending in '/' means the whole folder. */
|
|
4
5
|
function toGlob(pattern) {
|
|
5
6
|
return pattern.endsWith('/') ? `${pattern}**` : pattern;
|
|
@@ -26,5 +27,8 @@ export function allowedPatterns(feature, config) {
|
|
|
26
27
|
if (amendment.status === 'approved')
|
|
27
28
|
patterns.push(...amendment.paths);
|
|
28
29
|
}
|
|
30
|
+
// The QA agent's tests (decision 81).
|
|
31
|
+
if (feature.kind === 'feature')
|
|
32
|
+
patterns.push(...qaDirs(feature.slug));
|
|
29
33
|
return patterns;
|
|
30
34
|
}
|
package/docs/guide.md
CHANGED
|
@@ -116,9 +116,24 @@ again; then Build continues. Until then `agjan check` reports one error, that th
|
|
|
116
116
|
files wait for the revised design, and the pre-commit hook lets only the documents be
|
|
117
117
|
committed.
|
|
118
118
|
|
|
119
|
-
**Verify**: `/agjan-verify`. Full build, tests and lint, the baseline update, the
|
|
120
|
-
deep review, `agjan check --ci` and `report.md`. It ends with a completion block that
|
|
121
|
-
gives you the last gate
|
|
119
|
+
**Verify**: `/agjan-verify`. Full build, tests and lint, the baseline update, QA, the
|
|
120
|
+
final deep review, `agjan check --ci` and `report.md`. It ends with a completion block that
|
|
121
|
+
gives you the last gate.
|
|
122
|
+
|
|
123
|
+
**QA** (full-mode features; `review.qa: "off"` turns it off): before the final review, a
|
|
124
|
+
tester agent, `agjan-qa`, checks the feature from the spec alone. It gets the spec, how
|
|
125
|
+
to run the application and its users, but not the design, the code or the writer's
|
|
126
|
+
tests, and writes tests aimed at what writers tend to miss: invalid input, users a rule
|
|
127
|
+
excludes, anonymous requests, boundaries, doing something twice, the flows in the browser.
|
|
128
|
+
It runs them and records the result like a review. A failing test is a blocker: the
|
|
129
|
+
agent fixes the code, never the QA tests, and QA runs again. Something the spec does not
|
|
130
|
+
decide comes to you as a "Spec question". The tests stay in `test/qa/<feature>/` (UI tests
|
|
131
|
+
in `test/ui/qa/<feature>/`) as regression tests; a change to them after QA makes QA run
|
|
132
|
+
again. The final review, `check --ci` and `approve verify` wait for a passing QA round.
|
|
133
|
+
QA runs on the deep reviewer's model unless you give it its own:
|
|
134
|
+
`npx agjan models set qa <model>`.
|
|
135
|
+
|
|
136
|
+
The completion block gives you the last gate:
|
|
122
137
|
|
|
123
138
|
**Accept (Gate 3)**: try the result, check the manual ACs by hand, then accept it in your
|
|
124
139
|
terminal:
|
|
@@ -284,11 +299,12 @@ lists replace. The schema is `node_modules/agjan/schemas/config.schema.json`.
|
|
|
284
299
|
| `fix` | `max_total`, `max_per_file`, `protected`, `ignored`, `new_file_paths` |
|
|
285
300
|
| `review.build` | `area` (default: one build review per completed area) or `task` |
|
|
286
301
|
| `review.rounds` | correction rounds per review step (default 3); if blockers remain, the agent asks you whether to run another round (one more per yes, recorded with `npx agjan review extend <step>`) or to stop |
|
|
302
|
+
| `review.qa` | `on` (default) or `off`: the QA step in Verify for full-mode features |
|
|
287
303
|
| `review.tiers.<step>` | `balanced` or `deep` per step kind (`spec`, `design:light`, `design`, `build`, `verify`, `fix`, `map`); decides which reviewer agent runs it. Defaults: `deep` for `design` and `verify`, else `balanced`; `fast` uses the balanced agent |
|
|
288
304
|
| `build.fix_attempts` | attempts for failing deterministic checks before the agent stops (default 3) |
|
|
289
305
|
| `language` | language of the documents' text (default `en`); headings, ids and keywords stay English |
|
|
290
306
|
| `limits.spec_kb`, `limits.design_kb` | soft size limits; `check` warns above them (defaults 12 and 20 KB; design covers `design.md` and `tasks.md`) |
|
|
291
|
-
| `models.<host>.<tier>` | model of the reviewer agents per tier (`balanced`, `deep`); `"session"` (the default, written by `init` so you see it) runs the reviewer on the model of the session that starts it. Model names differ per host (Claude Code: `sonnet`, `opus
|
|
307
|
+
| `models.<host>.<tier>` | model of the reviewer agents per tier (`balanced`, `deep`); `"session"` (the default, written by `init` so you see it) runs the reviewer on the model of the session that starts it. Set it with `npx agjan models set deep <model>` in your terminal (`npx agjan models` lists the settings and, for Copilot, the models it offers). A deep reviewer on another model family than the writer (for example `gpt-6-sol` while the writer runs on Claude) misses other things than the writer. Model names differ per host (Claude Code: `sonnet`, `opus` or a full id; Copilot: for example `claude-opus-5.5`). Copilot uses the agent file's model unless the session was started with `--model`, which overrides it. `doctor` shows what each reviewer runs on |
|
|
292
308
|
| `mcp.servers.<name>` | documentation MCP servers: `command`, `args`, `env`, `areas`, `enabled` |
|
|
293
309
|
| `ci.policy_changes`, `ci.untracked_changes` | `warn` or `fail` in `check --ci` |
|
|
294
310
|
|
package/kit/hooks/guard.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-check
|
|
3
3
|
/**
|
|
4
4
|
* agjan guard: a pre-tool-use hook that denies shell commands running the human-only
|
|
5
|
-
* agjan commands (approve, accept, reject, auto), however they are wrapped (`npx`, `sh -c`,
|
|
5
|
+
* agjan commands (approve, accept, reject, auto, models set), however they are wrapped (`npx`, `sh -c`,
|
|
6
6
|
* `cd … &&`, `node …/agjan.mjs`). It is a guardrail in front of the terminal
|
|
7
7
|
* confirmation, not a proof (design 9.4).
|
|
8
8
|
*
|
|
@@ -36,10 +36,10 @@ import { fileURLToPath } from 'node:url';
|
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
38
|
const REASON =
|
|
39
|
-
'agjan approve, accept, reject and
|
|
39
|
+
'agjan approve, accept, reject, auto and models set are for the human, in a terminal. Do not run them in any form; ask the user to run the command.';
|
|
40
40
|
|
|
41
41
|
/** `agjan` (or `agjan.mjs`) followed directly by a human-only command; an optional `--` (npm exec) between. */
|
|
42
|
-
const HUMAN_ONLY = /\bagjan(?:\.mjs)?["']?\s+(?:--\s+)?["']?(approve|accept|reject|auto)\b/;
|
|
42
|
+
const HUMAN_ONLY = /\bagjan(?:\.mjs)?["']?\s+(?:--\s+)?["']?(approve|accept|reject|auto|models\s+set)\b/;
|
|
43
43
|
|
|
44
44
|
const BRANCH_REASON =
|
|
45
45
|
'Create branches with npx agjan branch, not with git. Ask the user first: create a new branch (your proposed name or one they type) or use an existing branch (npx agjan branch --list, then npx agjan branch --use <name>).';
|
|
@@ -56,9 +56,11 @@ Do not change it silently; `agjan check` fails on it.
|
|
|
56
56
|
## 4. Done
|
|
57
57
|
|
|
58
58
|
When `npx agjan status` says all tasks are done and reviewed, tell the user to run
|
|
59
|
-
`/agjan-verify`. In auto mode (`npx agjan status` shows `auto on`)
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
`/agjan-verify`. In auto mode (`npx agjan status` shows `auto on`) do not stop: your next
|
|
60
|
+
action is the shell command `cat .claude/skills/agjan-verify/SKILL.md` (it works on every
|
|
61
|
+
host), then follow that skill; put a one-line note for the user into the same reply, since
|
|
62
|
+
a reply without a tool call ends your run. Its final acceptance, `npx agjan approve
|
|
63
|
+
verify`, stays with the user in every mode.
|
|
62
64
|
|
|
63
65
|
## Never
|
|
64
66
|
|
|
@@ -97,8 +97,11 @@ passing one.
|
|
|
97
97
|
what it lists, review again, and retry.
|
|
98
98
|
3. **Auto mode** (`npx agjan status` shows `auto on`): step 2 has approved the design
|
|
99
99
|
automatically. Commit the feature folder with the message it gives, show the user the
|
|
100
|
-
last review report and one line that the gate passed in auto mode, and
|
|
101
|
-
|
|
100
|
+
last review report and one line that the gate passed in auto mode, and
|
|
101
|
+
continue without stopping: your next action is the shell command
|
|
102
|
+
`cat .claude/skills/agjan-build/SKILL.md` (it works on every host), then follow that skill.
|
|
103
|
+
Put the one line for the user into the same reply as that command: a reply without a
|
|
104
|
+
tool call ends your run, and the user has to start it again.
|
|
102
105
|
4. Otherwise tell the user what to review, the open findings, and the command for their
|
|
103
106
|
terminal: `npx agjan approve design` (it also commits the approval); then
|
|
104
107
|
`/agjan-build`. Stop.
|
|
@@ -120,10 +120,13 @@ Hand over the gate (see below) with `spec`. The user runs `/agjan-design` afterw
|
|
|
120
120
|
3. **Auto mode** (`npx agjan status` shows `auto on`): step 2 has approved the gate
|
|
121
121
|
automatically (it says `approved … automatically`). Commit the feature folder with the
|
|
122
122
|
message it gives, show the user the `npx agjan review report` of the last review and
|
|
123
|
-
one line that the gate passed in auto mode, and continue
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
one line that the gate passed in auto mode, and continue without stopping: your next
|
|
124
|
+
action is the shell command `cat .claude/skills/agjan-design/SKILL.md` (it works on
|
|
125
|
+
every host; `agjan-build` after `spec design`), then follow that skill. Put the one line
|
|
126
|
+
for the user into the same reply as that command: a reply without a tool call ends
|
|
127
|
+
your run, and the user has to start it again.
|
|
128
|
+
Stop only where a person is needed: blockers at the round limit, an amendment, a
|
|
129
|
+
business question, and the acceptance at the end.
|
|
127
130
|
4. Otherwise tell the user what to review, the open findings they should know about, and the
|
|
128
131
|
command to run in their terminal: `npx agjan approve <gate>` (it also commits the
|
|
129
132
|
approval). Then stop.
|
|
@@ -51,7 +51,34 @@ their roles, so the user can try the result. Then run
|
|
|
51
51
|
`npx agjan baseline refresh` whenever `npx agjan check` warns that watched files changed
|
|
52
52
|
since the baseline, and commit both.
|
|
53
53
|
|
|
54
|
-
## 5.
|
|
54
|
+
## 5. QA (step `qa`)
|
|
55
|
+
|
|
56
|
+
For full-mode features (unless `review.qa` is `off`; `npx agjan status` shows a `qa`
|
|
57
|
+
row), a tester checks the feature from the spec alone before the final review: the
|
|
58
|
+
`agjan-qa` agent writes tests into `test/qa/<slug>/` (and `test/ui/qa/<slug>/`), runs
|
|
59
|
+
them and records the result. Its tests stay in the project as regression tests.
|
|
60
|
+
|
|
61
|
+
1. Everything committed. Delegate, on its own, to the `agjan-qa` agent with exactly this
|
|
62
|
+
prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task
|
|
63
|
+
tool with that custom agent and the `name` `qa`):
|
|
64
|
+
`Run step qa of feature <slug>.` Do not tell it about the design, the code or your
|
|
65
|
+
tests: it works from the spec, and that is its value.
|
|
66
|
+
2. Show the user the round: `npx agjan review report --step qa`, unchanged.
|
|
67
|
+
3. Commit its tests with the subject `<KEY>: qa tests` (they are in scope).
|
|
68
|
+
4. **Blockers** are failing QA tests: the application contradicts the spec. Fix the
|
|
69
|
+
**code** within the approved task paths, never the QA tests, and commit the fix with
|
|
70
|
+
the subject of its task (`<KEY>-<id>: …`). A fix makes that area's build review due
|
|
71
|
+
again: do it, then run QA again, up to the round limit (`npx agjan status`). At the
|
|
72
|
+
limit, ask the user, as for reviews (`Run another round`: `npx agjan review extend
|
|
73
|
+
qa`). If you are sure a QA test is wrong (it asks something the spec does not say),
|
|
74
|
+
do not change it: ask the user, who decides with `agjan accept` or a spec change.
|
|
75
|
+
5. **Spec questions** (minor findings) go to the user in your final message; they do not
|
|
76
|
+
stop the flow.
|
|
77
|
+
|
|
78
|
+
The final review (next section) waits until QA has passed, and so do `check --ci` and
|
|
79
|
+
the acceptance.
|
|
80
|
+
|
|
81
|
+
## 6. Final review (step `verify`, deep)
|
|
55
82
|
|
|
56
83
|
Everything must be committed. When all your edits are saved, delegate, on its own (not in parallel with other tool calls), to the reviewer agent that `npx agjan status` names for the step (default `agjan-reviewer-deep`), with exactly this prompt (Claude Code: the Agent tool with that subagent type; GitHub Copilot: the task tool with that custom agent and a short `name`, for example `spec review`):
|
|
57
84
|
`Review step verify of feature <slug>.`
|
|
@@ -61,7 +88,7 @@ commits and ask for the review again, up to the round limit that `npx agjan stat
|
|
|
61
88
|
If blockers remain at the limit, ask the user with your host's question tool, naming the open blockers, with the choices `Run another round` and `Stop here`. On `Run another round`, run `npx agjan review extend verify` and continue; on `Stop here`, stop and tell the user.
|
|
62
89
|
Any change after the final review makes it stale; review again after the last change.
|
|
63
90
|
|
|
64
|
-
##
|
|
91
|
+
## 7. Check and summary
|
|
65
92
|
|
|
66
93
|
- `npx agjan check --ci` must pass except for one error: `not accepted yet` (the human's
|
|
67
94
|
acceptance is the last step). Fix everything else it reports, then review again if
|
|
@@ -80,7 +107,7 @@ Any change after the final review makes it stale; review again after the last ch
|
|
|
80
107
|
Opening a pull request is optional, done only when the user
|
|
81
108
|
asks (its description is the output of `npx agjan pr-summary`).
|
|
82
109
|
|
|
83
|
-
##
|
|
110
|
+
## 8. Pull request, only when the user asks
|
|
84
111
|
|
|
85
112
|
Push the branch and create the PR with the summary as its body, for example
|
|
86
113
|
`gh pr create --fill-first --body "<pr-summary output>"`. Its CI check passes once the
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: qa-tester
|
|
3
|
+
description: Knowledge of agjan's QA agent, the tester of the QA step in Verify. Used by the generated agjan-qa agent; do not invoke it directly to test your own work.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# agjan QA
|
|
7
|
+
|
|
8
|
+
You are agjan's tester. A writer built a feature and tested it with its own tests; you
|
|
9
|
+
test it again **from the requirements alone**, the way a tester who got the spec would.
|
|
10
|
+
Your value is the view the writer does not have: you find what its tests did not ask.
|
|
11
|
+
|
|
12
|
+
## The rules
|
|
13
|
+
|
|
14
|
+
- **Black box.** Use only what `qa_context` gives you: the spec, how to run the
|
|
15
|
+
application, its users and the test conventions. Do not read the design, the
|
|
16
|
+
application code (`srv/`, `db/`, `app/`) or the writer's tests. You may read the
|
|
17
|
+
testing references it names, for the test mechanics only.
|
|
18
|
+
- **Your folders only.** Write only in the two QA folders the context names
|
|
19
|
+
(`test/qa/<feature>/` for service tests, `test/ui/qa/<feature>/` for UI tests). Never
|
|
20
|
+
change application code, other tests, configuration or `package.json`; `qa_record`
|
|
21
|
+
refuses a result when anything else changed. Edit files with your edit tool.
|
|
22
|
+
- **Tests stay.** Your tests remain in the project as regression tests. Make them
|
|
23
|
+
deterministic and independent of each other and of the order they run in.
|
|
24
|
+
|
|
25
|
+
## How a QA round runs
|
|
26
|
+
|
|
27
|
+
1. Call `qa_context`. It returns a `context_id` and the material.
|
|
28
|
+
2. Read the spec closely: every acceptance criterion, the Authorization section, the
|
|
29
|
+
non-functional requirements and the scope.
|
|
30
|
+
3. Derive the cases the writer most likely did not test. For each AC and rule:
|
|
31
|
+
- **negative cases:** invalid input, missing required values, wrong types, values
|
|
32
|
+
just outside the allowed range;
|
|
33
|
+
- **who may not:** a user without the role, a user with the role whom a condition
|
|
34
|
+
excludes (another team's manager, another employee), an anonymous request;
|
|
35
|
+
- **boundaries:** dates (same day, end before start, across a year), empty and
|
|
36
|
+
maximum lengths, zero and one item;
|
|
37
|
+
- **state:** doing the same twice (a second approval), acting in a state that does not
|
|
38
|
+
allow it (editing after approval), the order of steps;
|
|
39
|
+
- **the user's view:** where the project has Playwright tests, the flows of the ACs in
|
|
40
|
+
the browser as each role (create, act, see the result).
|
|
41
|
+
Skip what is obviously covered by the AC's own happy path; one good test per risk
|
|
42
|
+
beats many similar ones.
|
|
43
|
+
4. Write the tests in your folders with the project's test stack (the context names the
|
|
44
|
+
commands and the testing references). Name each test with the AC it checks:
|
|
45
|
+
`<KEY>-AC<n> QA: <what it checks>`; a test of an authorization rule names the AC it
|
|
46
|
+
protects.
|
|
47
|
+
5. Run them: the service tests with the project's test command (or `node --test` on your
|
|
48
|
+
files), the UI tests with `npx agjan ui-test`. A UI test that cannot run because no
|
|
49
|
+
browser can start is not a failure: say so in a minor finding.
|
|
50
|
+
6. Classify every failure, then call `qa_record` once:
|
|
51
|
+
- **blocker:** the application contradicts an AC or an authorization rule. File: your
|
|
52
|
+
test file; issue: what the spec says and what the application does; evidence: the
|
|
53
|
+
test name and the failure output (the relevant lines).
|
|
54
|
+
- **minor, starting with "Spec question:":** the spec does not decide the case (your
|
|
55
|
+
test assumed one answer). The human decides; keep such tests out of the suite, or
|
|
56
|
+
write them so they pass either way, until it is decided.
|
|
57
|
+
- A failing test you got wrong (a mistake in the test): fix the test, do not report it.
|
|
58
|
+
Verdict: `blocked` with any blocker, `pass-with-notes` with only notes, else `pass`.
|
|
59
|
+
In `resolves`, list earlier QA findings whose tests pass now.
|
|
60
|
+
7. Answer with the recorded id, the verdict, the number of tests you wrote and one line
|
|
61
|
+
per finding.
|
|
62
|
+
|
|
63
|
+
## In later rounds
|
|
64
|
+
|
|
65
|
+
The writer fixed the code for your blockers (never your tests). Run all your tests
|
|
66
|
+
again, add tests where the fix suggests a related risk, and record the round. If a test
|
|
67
|
+
of yours was changed by someone else, `agjan status` reports QA as stale: run it again
|
|
68
|
+
and judge the current tests.
|
|
69
|
+
|
|
70
|
+
## Never
|
|
71
|
+
|
|
72
|
+
- Read the design, the application code or the writer's tests.
|
|
73
|
+
- Change anything outside your QA folders, or weaken a test so that it passes.
|
|
74
|
+
- Run `agjan approve`, `agjan accept`, `agjan reject`, `agjan auto` or `agjan models set`.
|
package/package.json
CHANGED
|
@@ -64,12 +64,13 @@
|
|
|
64
64
|
"properties": {
|
|
65
65
|
"build": { "enum": ["area", "task"] },
|
|
66
66
|
"rounds": { "type": "integer", "minimum": 1 },
|
|
67
|
-
"tiers": { "type": "object", "additionalProperties": { "enum": ["fast", "balanced", "deep"] } }
|
|
67
|
+
"tiers": { "type": "object", "additionalProperties": { "enum": ["fast", "balanced", "deep"] } },
|
|
68
|
+
"qa": { "enum": ["on", "off"], "description": "The QA step in Verify for full-mode features (default on): the agjan-qa agent writes and runs tests from the spec alone." }
|
|
68
69
|
},
|
|
69
70
|
"additionalProperties": false
|
|
70
71
|
},
|
|
71
72
|
"models": {
|
|
72
|
-
"description": "
|
|
73
|
+
"description": "Agent models per host and tier (balanced, deep, qa). 'session' runs the agent on the model of the session that starts it; qa defaults to the deep model.",
|
|
73
74
|
"type": "object",
|
|
74
75
|
"additionalProperties": { "type": "object", "additionalProperties": { "type": "string" } }
|
|
75
76
|
},
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"additionalProperties": false,
|
|
20
20
|
"properties": {
|
|
21
21
|
"id": { "type": "string", "pattern": "^[A-Z][A-Z0-9]{1,5}-R[1-9][0-9]*$" },
|
|
22
|
-
"step": { "type": "string", "pattern": "^(spec|design|design:light|verify|build:.+)$" },
|
|
22
|
+
"step": { "type": "string", "pattern": "^(spec|design|design:light|verify|qa|build:.+)$" },
|
|
23
23
|
"round": { "type": "integer", "minimum": 1 },
|
|
24
24
|
"at_utc": { "type": "string" },
|
|
25
25
|
"reviewer": {
|
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
"base_commit": { "type": ["string", "null"] },
|
|
44
44
|
"head_commit": { "type": ["string", "null"] },
|
|
45
45
|
"verdict": { "enum": ["pass", "pass-with-notes", "blocked"] },
|
|
46
|
+
"qa_tests_hash": { "$ref": "#/$defs/hash" },
|
|
47
|
+
"qa_tests": { "type": "array", "items": { "type": "string" } },
|
|
46
48
|
"resolves": { "type": "array", "items": { "type": "string" } },
|
|
47
49
|
"findings": {
|
|
48
50
|
"type": "array",
|