agjan 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/bin/agjan.mjs +10 -2
- package/dist/adapters/claude-code.js +33 -2
- package/dist/adapters/copilot.js +31 -1
- package/dist/cli.js +15 -3
- package/dist/commands/check.js +4 -0
- package/dist/commands/gates.js +39 -14
- package/dist/commands/log.js +4 -2
- package/dist/commands/models.js +144 -0
- package/dist/commands/pr-summary.js +8 -0
- package/dist/commands/review.js +7 -4
- package/dist/commands/setup.js +115 -20
- package/dist/commands/status.js +38 -2
- package/dist/config.js +5 -1
- package/dist/context.js +14 -3
- package/dist/fix.js +1 -1
- package/dist/launcher.js +81 -0
- package/dist/mcp.js +47 -2
- package/dist/package-manager.js +21 -0
- package/dist/progress-view.js +13 -13
- package/dist/qa.js +77 -0
- package/dist/review-policy.js +3 -2
- package/dist/review.js +120 -21
- package/dist/scope.js +4 -0
- package/dist/terminal.js +27 -0
- package/docs/guide.md +40 -8
- 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/kit/skills/solution-reviewer/SKILL.md +3 -3
- package/kit/templates/progress.html +8 -8
- package/package.json +1 -1
- package/schemas/config.schema.json +3 -2
- package/schemas/reviews.schema.json +3 -1
package/README.md
CHANGED
|
@@ -51,11 +51,19 @@ Requirements: Node.js 22 or later, git, and Claude Code and/or the GitHub Copilo
|
|
|
51
51
|
Linux, macOS or Windows.
|
|
52
52
|
|
|
53
53
|
```sh
|
|
54
|
-
npm install --
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
npm install --global agjan
|
|
55
|
+
agjan init my-project --hosts claude-code,copilot # or "agjan init ." in an existing folder
|
|
56
|
+
cd my-project
|
|
57
|
+
agjan doctor
|
|
57
58
|
```
|
|
58
59
|
|
|
60
|
+
`agjan init my-project` creates the folder, the git repository (branch `main`) and a
|
|
61
|
+
`package.json`, pins this version of agjan in its `devDependencies` and installs it, then
|
|
62
|
+
sets the project up. Without `--hosts` it asks which hosts to set up. The global `agjan`
|
|
63
|
+
only starts things: `init`, `--help` and `--version` run in it, and every other command
|
|
64
|
+
runs in the version the project pins, so a project never depends on the global version.
|
|
65
|
+
After cloning a project, the first command offers to install the pinned version.
|
|
66
|
+
|
|
59
67
|
Open the project in your agent host, trust the folder, and start a feature:
|
|
60
68
|
|
|
61
69
|
```text
|
package/bin/agjan.mjs
CHANGED
|
@@ -5,8 +5,16 @@ import { existsSync } from 'node:fs';
|
|
|
5
5
|
// In the agjan repository Node runs the TypeScript sources directly; the npm package
|
|
6
6
|
// ships them compiled to dist/ (Node does not strip types inside node_modules).
|
|
7
7
|
const source = new URL('../src/cli.ts', import.meta.url);
|
|
8
|
+
const load = (/** @type {string} */ name) => (existsSync(source) ? new URL(`../src/${name}.ts`, import.meta.url) : new URL(`../dist/${name}.js`, import.meta.url)).href;
|
|
9
|
+
|
|
10
|
+
// The global agjan only launches: project commands run in the version the project pins.
|
|
11
|
+
/** @type {typeof import('../src/launcher.ts')} */
|
|
12
|
+
const { launch } = await import(load('launcher'));
|
|
13
|
+
const launched = await launch(process.argv.slice(2));
|
|
14
|
+
if ('code' in launched) process.exit(launched.code);
|
|
15
|
+
|
|
8
16
|
/** @type {typeof import('../src/cli.ts')} */
|
|
9
|
-
const { main } = await import(
|
|
17
|
+
const { main } = await import(load('cli'));
|
|
10
18
|
|
|
11
19
|
// A reader that stops early (`agjan status | head`) is not an error.
|
|
12
20
|
for (const stream of [process.stdout, process.stderr]) {
|
|
@@ -16,4 +24,4 @@ for (const stream of [process.stdout, process.stderr]) {
|
|
|
16
24
|
});
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
process.exitCode = await main(
|
|
27
|
+
process.exitCode = await main(launched.run);
|
|
@@ -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,
|
|
@@ -60,7 +90,7 @@ function reviewerAgent(name, tier, model, skill) {
|
|
|
60
90
|
'review of a step; it records its result itself.',
|
|
61
91
|
tools: 'Read, Grep, Glob, mcp__agjan__review_context, mcp__agjan__review_record',
|
|
62
92
|
...(model ? { model } : {}),
|
|
63
|
-
// Scoped to this agent only: the
|
|
93
|
+
// Scoped to this agent only: the main agent session must not have review_record.
|
|
64
94
|
mcpServers: [
|
|
65
95
|
{
|
|
66
96
|
agjan: {
|
|
@@ -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,
|
|
@@ -27,7 +56,7 @@ function reviewerAgent(name, tier, model, skill) {
|
|
|
27
56
|
'review of a step; it records its result itself.',
|
|
28
57
|
tools: ['read', 'search', 'agjan/review_context', 'agjan/review_record'],
|
|
29
58
|
...(model ? { model } : {}),
|
|
30
|
-
// Scoped to this agent only: the
|
|
59
|
+
// Scoped to this agent only: the main agent session must not have review_record.
|
|
31
60
|
'mcp-servers': {
|
|
32
61
|
agjan: {
|
|
33
62
|
type: 'local',
|
|
@@ -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,
|
|
@@ -53,13 +55,19 @@ and a read-only reviewer at every step. Closed beta (0.x); the user guide is\nin
|
|
|
53
55
|
Usage: agjan <command> [options]
|
|
54
56
|
|
|
55
57
|
Setup (human):
|
|
56
|
-
init
|
|
58
|
+
init <folder | .> [--hosts claude-code,copilot] [--domains btp] [--base <ref>]
|
|
57
59
|
[--no-hook] [--no-ci] [--prepare] [--copilot-mcp | --no-copilot-mcp]
|
|
58
|
-
|
|
60
|
+
[--no-install] [--pm npm|pnpm|yarn|bun] [--dry-run]
|
|
61
|
+
set up agjan: <folder> is created (git init, package.json,
|
|
62
|
+
agjan pinned and installed), . is the current folder; without
|
|
63
|
+
--hosts it asks which hosts (claude-code, copilot) to set up
|
|
59
64
|
sync [--force] [--copilot-mcp]
|
|
60
65
|
regenerate managed files (skills, agents, blocks, settings);
|
|
61
66
|
--copilot-mcp adds missing MCP servers to Copilot
|
|
62
67
|
hook install install the pre-commit hook
|
|
68
|
+
models [set <balanced|deep|qa> <model> [--host <h>]]
|
|
69
|
+
show the reviewers' models, or choose one (the deep reviewer
|
|
70
|
+
on another model family than the main agent catches other things)
|
|
63
71
|
doctor check the environment and the project setup
|
|
64
72
|
|
|
65
73
|
Agent and human:
|
|
@@ -96,8 +104,9 @@ Agent and human:
|
|
|
96
104
|
report write report.md: durations, gate waits, models and tokens
|
|
97
105
|
|
|
98
106
|
Reviewer agent (through the host's MCP configuration):
|
|
99
|
-
mcp [--host <h>] [--isolation agent|shared|fork|none]
|
|
107
|
+
mcp [--host <h>] [--isolation agent|shared|fork|none] [--role review|qa]
|
|
100
108
|
agjan MCP server on stdio: review_context, review_record
|
|
109
|
+
(--role qa: qa_context, qa_record for the agjan-qa agent)
|
|
101
110
|
|
|
102
111
|
Human only, in a terminal:
|
|
103
112
|
approve spec | design | spec design | verify | amendment <id>
|
|
@@ -111,6 +120,9 @@ Human only, in a terminal:
|
|
|
111
120
|
|
|
112
121
|
Other:
|
|
113
122
|
--version, --help
|
|
123
|
+
--yes <command> install the project's pinned agjan without asking, then run
|
|
124
|
+
the command (the global agjan runs project commands in the
|
|
125
|
+
version the project pins in node_modules)
|
|
114
126
|
`;
|
|
115
127
|
/**
|
|
116
128
|
* Runs the CLI and returns the process exit code.
|
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')) {
|
|
@@ -366,18 +378,31 @@ export async function auto(ctx, argv) {
|
|
|
366
378
|
throw new UsageError(usage);
|
|
367
379
|
return autoDefault(ctx, what === 'on');
|
|
368
380
|
}
|
|
369
|
-
|
|
381
|
+
let slug;
|
|
382
|
+
try {
|
|
383
|
+
slug = selectFeature(ctx.root, ctx.config, values.feature);
|
|
384
|
+
}
|
|
385
|
+
catch (error) {
|
|
386
|
+
if (!(error instanceof UsageError))
|
|
387
|
+
throw error;
|
|
388
|
+
// No single feature to act on: name both ways, the feature and the default.
|
|
389
|
+
throw new UsageError(`${error.message.replace(/; pass --feature <slug>$/, '')}.\n` +
|
|
390
|
+
` every new feature in this checkout: npx agjan auto ${what} --default\n` +
|
|
391
|
+
` one feature: npx agjan auto ${what} --feature <slug>, or run it on the feature's branch after /agjan-spec has created it`);
|
|
392
|
+
}
|
|
393
|
+
const feature = loadFeature(ctx.root, slug);
|
|
370
394
|
if (feature.kind !== 'feature')
|
|
371
395
|
throw new AgjanError(`auto mode is for features; ${feature.slug} is a ${feature.kind}`);
|
|
372
396
|
const current = feature.approvals.auto;
|
|
373
397
|
if (what === 'on') {
|
|
374
398
|
if (current)
|
|
375
399
|
throw new AgjanError(`auto mode of ${feature.slug} is already on (since ${current.at_utc}, by ${current.by})`);
|
|
400
|
+
const s = ctx.style;
|
|
376
401
|
const lines = [
|
|
377
|
-
|
|
402
|
+
`auto spec and design are ${s.yellow('approved automatically')} once their reviews pass;`,
|
|
378
403
|
' the agent goes on to the next step without waiting for you',
|
|
379
|
-
|
|
380
|
-
|
|
404
|
+
`yours ${s.bold('approve verify')} (the acceptance), accepting findings, amendments, the merge`,
|
|
405
|
+
`off ${s.cyan('npx agjan auto off')}, at any time`,
|
|
381
406
|
];
|
|
382
407
|
if (!(await confirmGate(ctx, feature, 'switch auto mode on for this feature', lines)))
|
|
383
408
|
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,144 @@
|
|
|
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 { markLine, pad } from '../ui.js';
|
|
8
|
+
import { DEFAULT_TIERS, reviewerFor } from '../review-policy.js';
|
|
9
|
+
import { sync } from './setup.js';
|
|
10
|
+
/**
|
|
11
|
+
* The models GitHub Copilot CLI accepts, from `copilot help config` (its `model` setting
|
|
12
|
+
* lists them). Null when copilot cannot be run; AGJAN_COPILOT names a stand-in (tests).
|
|
13
|
+
*/
|
|
14
|
+
export function copilotModels() {
|
|
15
|
+
const fake = process.env.AGJAN_COPILOT;
|
|
16
|
+
const run = fake
|
|
17
|
+
? spawnSync(process.execPath, [fake, 'help', 'config'], { encoding: 'utf8', timeout: 30_000 })
|
|
18
|
+
: spawnSync('copilot', ['help', 'config'], { encoding: 'utf8', timeout: 30_000, shell: process.platform === 'win32' });
|
|
19
|
+
if (run.error || run.status !== 0)
|
|
20
|
+
return null;
|
|
21
|
+
const section = /`model`:[^\n]*\n((?:\s+- "[^"]+"\n?)+)/.exec(run.stdout ?? '');
|
|
22
|
+
return section ? [...section[1].matchAll(/- "([^"]+)"/g)].map((m) => m[1]) : null;
|
|
23
|
+
}
|
|
24
|
+
/** The agent of each tier, and what it does. */
|
|
25
|
+
const AGENTS = {
|
|
26
|
+
balanced: { agent: 'agjan-reviewer', label: 'reviewer' },
|
|
27
|
+
deep: { agent: 'agjan-reviewer-deep', label: 'deep reviewer' },
|
|
28
|
+
qa: { agent: 'agjan-qa', label: 'QA' },
|
|
29
|
+
};
|
|
30
|
+
/** The steps a tier runs, from the step tiers (`review.tiers` over the defaults). */
|
|
31
|
+
function stepsOf(config, tier) {
|
|
32
|
+
if (tier === 'qa')
|
|
33
|
+
return 'tests from the spec in Verify';
|
|
34
|
+
const kinds = Object.keys(DEFAULT_TIERS).filter((kind) => kind !== 'qa' && reviewerFor(config, kind) === AGENTS[tier].agent);
|
|
35
|
+
return kinds.length ? `reviews ${kinds.join(', ')}` : 'no steps (review.tiers)';
|
|
36
|
+
}
|
|
37
|
+
/** Model names grouped by family, for reading: Claude, GPT, Gemini, the others. */
|
|
38
|
+
function families(models) {
|
|
39
|
+
const groups = [['Claude', /^claude-/], ['GPT', /^gpt-/], ['Gemini', /^gemini-/]];
|
|
40
|
+
const out = groups.map(([name, re]) => [name, models.filter((m) => re.test(m))]);
|
|
41
|
+
out.push(['Others', models.filter((m) => !groups.some(([, re]) => re.test(m)))]);
|
|
42
|
+
return out.filter(([, list]) => list.length);
|
|
43
|
+
}
|
|
44
|
+
/** Joins words into lines of at most `width` characters after an indent. */
|
|
45
|
+
function wrap(words, indent, width = 92) {
|
|
46
|
+
const lines = [];
|
|
47
|
+
let line = '';
|
|
48
|
+
for (const word of words) {
|
|
49
|
+
if (line && indent.length + line.length + word.length + 2 > width) {
|
|
50
|
+
lines.push(`${line},`);
|
|
51
|
+
line = word;
|
|
52
|
+
}
|
|
53
|
+
else
|
|
54
|
+
line = line ? `${line}, ${word}` : word;
|
|
55
|
+
}
|
|
56
|
+
if (line)
|
|
57
|
+
lines.push(line);
|
|
58
|
+
return lines.map((l, i) => (i ? `${indent}${l}` : l));
|
|
59
|
+
}
|
|
60
|
+
/** What each agent runs on, per host, how to change it, and the models the host offers. */
|
|
61
|
+
function show(ctx) {
|
|
62
|
+
const s = ctx.style;
|
|
63
|
+
const config = ctx.config;
|
|
64
|
+
for (const line of markLine(s, ctx.kit, 'models'))
|
|
65
|
+
ctx.out(line);
|
|
66
|
+
for (const host of config.hosts) {
|
|
67
|
+
ctx.out('', s.bold(host));
|
|
68
|
+
for (const tier of AGENT_TIERS) {
|
|
69
|
+
const { agent, label } = AGENTS[tier];
|
|
70
|
+
const model = agentModel(config, host, tier);
|
|
71
|
+
const shown = model ? s.cyan(model) : s.gray('session model');
|
|
72
|
+
const plain = model ?? 'session model';
|
|
73
|
+
const follows = tier === 'qa' && !config.models?.[host]?.qa ? s.gray(' (follows the deep reviewer)') : '';
|
|
74
|
+
ctx.out(` ${pad(label, label, 15)}${pad(s.gray(agent), agent, 21)}${pad(shown, plain, 19)}${s.gray(stepsOf(config, tier))}${follows}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
ctx.out('', s.bold('Change, in your terminal:'));
|
|
78
|
+
const change = [
|
|
79
|
+
['npx agjan models set deep <model>', 'tip: another model family than the main agent finds other things'],
|
|
80
|
+
['npx agjan models set qa <model>', 'QA gets its own model'],
|
|
81
|
+
[`npx agjan models set <tier> ${SESSION_MODEL}`, "back to the session's model"],
|
|
82
|
+
];
|
|
83
|
+
for (const [command, why] of change)
|
|
84
|
+
ctx.out(` ${pad(s.cyan(command), command, 38)}${s.gray(why)}`);
|
|
85
|
+
if (config.hosts.length > 1)
|
|
86
|
+
ctx.out(s.gray(' add --host <host> for one host only'));
|
|
87
|
+
if (config.hosts.includes('copilot')) {
|
|
88
|
+
const models = copilotModels();
|
|
89
|
+
if (models) {
|
|
90
|
+
ctx.out('', s.bold('Models GitHub Copilot offers:'));
|
|
91
|
+
for (const [family, list] of families(models))
|
|
92
|
+
ctx.out(` ${pad(s.gray(family), family, 9)}${wrap(list, ' '.repeat(11)).join('\n')}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (config.hosts.includes('claude-code'))
|
|
96
|
+
ctx.out('', s.bold('Models Claude Code takes:'), ' an alias (sonnet, opus, haiku, fable) or a full model id');
|
|
97
|
+
return 0;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* agjan models set <tier> <model> [--host <host>] (decision 80): the reviewer's model is a
|
|
101
|
+
* quality decision of the person, not of the agent it reviews: asked on the terminal (the
|
|
102
|
+
* guard denies it to agents), written to agjan.config.json, then `agjan sync` rewrites the
|
|
103
|
+
* reviewer agent files.
|
|
104
|
+
*/
|
|
105
|
+
function set(ctx, tier, model, host) {
|
|
106
|
+
const config = ctx.config;
|
|
107
|
+
if (!AGENT_TIERS.includes(tier))
|
|
108
|
+
throw new UsageError(`tier must be one of: ${AGENT_TIERS.join(', ')}`);
|
|
109
|
+
const hosts = host ? [host] : config.hosts;
|
|
110
|
+
for (const h of hosts)
|
|
111
|
+
if (!config.hosts.includes(h))
|
|
112
|
+
throw new UsageError(`host '${h}' is not configured (hosts: ${config.hosts.join(', ')})`);
|
|
113
|
+
if (model !== SESSION_MODEL && hosts.includes('copilot')) {
|
|
114
|
+
const models = copilotModels();
|
|
115
|
+
if (models && !models.includes(model))
|
|
116
|
+
throw new AgjanError(`GitHub Copilot does not offer '${model}'; its models: ${models.join(', ')}`);
|
|
117
|
+
}
|
|
118
|
+
const answer = ctx.ask(`Let the ${tier} reviewer run on ${model === SESSION_MODEL ? "the session's model" : model} (${hosts.join(', ')})?`, { defaultYes: true });
|
|
119
|
+
if (answer === null)
|
|
120
|
+
throw new AgjanError('choosing the reviewer model needs a human at a terminal; agents must not run it. Run it yourself in a terminal.');
|
|
121
|
+
if (!answer) {
|
|
122
|
+
ctx.out(ctx.style.yellow('cancelled, nothing changed'));
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
const file = join(ctx.root, CONFIG_FILE);
|
|
126
|
+
const raw = readJson(file);
|
|
127
|
+
if (!raw)
|
|
128
|
+
throw new AgjanError(`no ${CONFIG_FILE}; run 'agjan init' first`);
|
|
129
|
+
raw.models = raw.models ?? {};
|
|
130
|
+
for (const h of hosts)
|
|
131
|
+
raw.models[h] = { ...(raw.models[h] ?? {}), [tier]: model };
|
|
132
|
+
writeJson(file, raw);
|
|
133
|
+
ctx.out(`${ctx.style.green('set')} models.${hosts.length === 1 ? hosts[0] : `{${hosts.join(',')}}`}.${tier} = ${model}`);
|
|
134
|
+
return sync(ctx, []);
|
|
135
|
+
}
|
|
136
|
+
/** agjan models [set <tier> <model> [--host <host>]] */
|
|
137
|
+
export function run(ctx, argv) {
|
|
138
|
+
const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { host: { type: 'string' } } });
|
|
139
|
+
if (positionals.length === 0 && !values.host)
|
|
140
|
+
return show(ctx);
|
|
141
|
+
if (positionals[0] === 'set' && positionals.length === 3)
|
|
142
|
+
return set(ctx, positionals[1], positionals[2], values.host);
|
|
143
|
+
throw new UsageError('usage: agjan models | agjan models set <balanced|deep|qa> <model> [--host <host>]');
|
|
144
|
+
}
|
|
@@ -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) {
|
|
@@ -33,7 +36,7 @@ function oneLine(text, max = 140) {
|
|
|
33
36
|
const line = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
34
37
|
return line.length > max ? `${line.slice(0, max - 1)}…` : line;
|
|
35
38
|
}
|
|
36
|
-
/** What the
|
|
39
|
+
/** What the main agent does after this review (design 7.4), in the user's words. */
|
|
37
40
|
function nextAfter(feature, config, record) {
|
|
38
41
|
const state = roundState(feature, config, record.step);
|
|
39
42
|
const status = new Map(feature.findings.map((f) => [f.id, f.status]));
|