agjan 0.0.13 → 0.0.15
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 +14 -5
- package/bin/agjan.mjs +10 -2
- package/dist/adapters/claude-code.js +1 -1
- package/dist/adapters/copilot.js +1 -1
- package/dist/cli.js +14 -5
- package/dist/commands/gates.js +13 -1
- package/dist/commands/models.js +63 -9
- package/dist/commands/review.js +1 -1
- package/dist/commands/setup.js +186 -27
- package/dist/commands/status.js +17 -1
- package/dist/context.js +14 -3
- package/dist/fix.js +1 -1
- package/dist/launcher.js +81 -0
- package/dist/package-manager.js +21 -0
- package/dist/progress-view.js +7 -7
- package/dist/qa.js +1 -1
- package/dist/review-policy.js +1 -1
- package/dist/review.js +3 -3
- package/dist/select.js +54 -0
- package/dist/terminal.js +79 -0
- package/dist/ui.js +1 -1
- package/docs/guide.md +35 -8
- package/kit/skills/qa-tester/SKILL.md +6 -6
- package/kit/skills/solution-reviewer/SKILL.md +3 -3
- package/kit/templates/progress.html +8 -8
- package/package.json +7 -2
package/dist/launcher.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, realpathSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, join, parse } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { CONFIG_FILE } from './config.js';
|
|
7
|
+
import { readJson } from './json-file.js';
|
|
8
|
+
import { detectPackageManager, installDependencies } from './package-manager.js';
|
|
9
|
+
import { askOnTerminal } from './terminal.js';
|
|
10
|
+
/** Commands the global agjan runs itself; everything else belongs to a project's pinned version. */
|
|
11
|
+
const GLOBAL_COMMANDS = new Set(['init', 'help', '--help', '-h', 'version', '--version', '-v']);
|
|
12
|
+
/** Set for the process the launcher starts, so that it never delegates again. */
|
|
13
|
+
const DELEGATED = 'AGJAN_DELEGATED';
|
|
14
|
+
const OWN_PACKAGE = realpathSync(fileURLToPath(new URL('..', import.meta.url)));
|
|
15
|
+
/** The nearest folder up from `dir` with an agjan.config.json; null outside an agjan project. */
|
|
16
|
+
export function findProject(dir) {
|
|
17
|
+
for (let current = dir;; current = dirname(current)) {
|
|
18
|
+
if (existsSync(join(current, CONFIG_FILE)))
|
|
19
|
+
return current;
|
|
20
|
+
if (current === parse(current).root)
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** The folder of the agjan installed in the project (node_modules, hoisted or not); null when missing. */
|
|
25
|
+
function localPackage(root) {
|
|
26
|
+
try {
|
|
27
|
+
return realpathSync(dirname(createRequire(join(root, 'package.json')).resolve('agjan/package.json')));
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function defaultDelegate(bin, args, env) {
|
|
34
|
+
return spawnSync(process.execPath, [bin, ...args], { stdio: 'inherit', env }).status ?? 1;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The global `agjan` is a launcher: `init`, `--help` and `--version` run in it; every other
|
|
38
|
+
* command runs in the agjan version the project pins (node_modules), so a project is
|
|
39
|
+
* never driven by whichever version happens to be installed globally. When the pinned
|
|
40
|
+
* version is not installed (a fresh clone), it is installed first, after asking
|
|
41
|
+
* (`--yes` as the first argument skips the question). Outside an agjan project, and in
|
|
42
|
+
* the project's own agjan, the command runs here.
|
|
43
|
+
*/
|
|
44
|
+
export async function launch(args, { cwd = process.cwd(), env = process.env, stderr = process.stderr, ask = askOnTerminal, install = installDependencies, delegate = defaultDelegate, } = {}) {
|
|
45
|
+
const yes = args[0] === '--yes' || args[0] === '-y';
|
|
46
|
+
const rest = yes ? args.slice(1) : args;
|
|
47
|
+
if (rest[0] === undefined || GLOBAL_COMMANDS.has(rest[0]) || env[DELEGATED])
|
|
48
|
+
return { run: rest };
|
|
49
|
+
const root = findProject(cwd);
|
|
50
|
+
if (!root)
|
|
51
|
+
return { run: rest };
|
|
52
|
+
const fail = (...lines) => {
|
|
53
|
+
stderr.write(`agjan: ${lines.join('\n')}\n`);
|
|
54
|
+
return { code: 1 };
|
|
55
|
+
};
|
|
56
|
+
let local = localPackage(root);
|
|
57
|
+
if (local === OWN_PACKAGE)
|
|
58
|
+
return { run: rest };
|
|
59
|
+
if (!local) {
|
|
60
|
+
const pkg = readJson(join(root, 'package.json'));
|
|
61
|
+
const pinned = pkg?.devDependencies?.agjan ?? pkg?.dependencies?.agjan;
|
|
62
|
+
const kit = readJson(join(root, CONFIG_FILE))?.kit ?? '<version>';
|
|
63
|
+
if (!pinned) {
|
|
64
|
+
return fail(`${root} is an agjan project, but agjan is not pinned in its package.json.`, `Pin it: npm install --save-dev --save-exact agjan@${kit}`);
|
|
65
|
+
}
|
|
66
|
+
const manager = detectPackageManager(root);
|
|
67
|
+
const answer = yes ? true : ask(`agjan ${pinned} is pinned in ${root} but not installed. Install it now (${manager} install)?`, { defaultYes: true });
|
|
68
|
+
if (answer === null) {
|
|
69
|
+
return fail(`agjan ${pinned} is pinned in ${root} but not installed, and there is no terminal to ask on.`, `Run '${manager} install' there, or run this command with --yes first: agjan --yes ${rest.join(' ')}`);
|
|
70
|
+
}
|
|
71
|
+
if (!answer)
|
|
72
|
+
return fail(`agjan ${pinned} is not installed in ${root}; run '${manager} install' there first.`);
|
|
73
|
+
install(root, manager);
|
|
74
|
+
local = localPackage(root);
|
|
75
|
+
if (!local)
|
|
76
|
+
return fail(`'${manager} install' finished, but agjan is still not installed in ${root}.`);
|
|
77
|
+
if (local === OWN_PACKAGE)
|
|
78
|
+
return { run: rest };
|
|
79
|
+
}
|
|
80
|
+
return { code: delegate(join(local, 'bin', 'agjan.mjs'), rest, { ...env, [DELEGATED]: '1' }) };
|
|
81
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { AgjanError } from './errors.js';
|
|
5
|
+
export const PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn', 'bun'];
|
|
6
|
+
const LOCKFILES = [
|
|
7
|
+
['pnpm-lock.yaml', 'pnpm'],
|
|
8
|
+
['yarn.lock', 'yarn'],
|
|
9
|
+
['bun.lock', 'bun'],
|
|
10
|
+
['bun.lockb', 'bun'],
|
|
11
|
+
];
|
|
12
|
+
/** The package manager a project uses, from its lockfile; npm without one. */
|
|
13
|
+
export function detectPackageManager(dir) {
|
|
14
|
+
return LOCKFILES.find(([file]) => existsSync(join(dir, file)))?.[1] ?? 'npm';
|
|
15
|
+
}
|
|
16
|
+
/** Installs the project's dependencies (the pinned agjan among them) with its package manager. */
|
|
17
|
+
export function installDependencies(dir, manager) {
|
|
18
|
+
const result = spawnSync(manager, ['install'], { cwd: dir, stdio: 'inherit', shell: process.platform === 'win32' });
|
|
19
|
+
if (result.status !== 0)
|
|
20
|
+
throw new AgjanError(`${manager} install failed${result.error ? `: ${result.error.message}` : ''}; fix it and run it yourself in ${dir}`);
|
|
21
|
+
}
|
package/dist/progress-view.js
CHANGED
|
@@ -272,7 +272,7 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {})
|
|
|
272
272
|
end: iso(end),
|
|
273
273
|
last: iso(last),
|
|
274
274
|
host,
|
|
275
|
-
|
|
275
|
+
mainAgent: steps.map((s) => ({ from: iso(s.from), to: iso(s.to), label: s.label })),
|
|
276
276
|
gates: gates.map((g) => ({ from: iso(g.from), to: iso(g.to), label: g.label.replace(/^gate /, ''), open: Boolean(g.open) })),
|
|
277
277
|
events: events.map((e) => ({ at: e.at_utc, event: e.event, ...Object.fromEntries(Object.entries(e).filter(([k]) => !['at_utc', 'event'].includes(k))) })),
|
|
278
278
|
commits,
|
|
@@ -313,7 +313,7 @@ export function projectModels(ctx, { now = Date.now() } = {}) {
|
|
|
313
313
|
}
|
|
314
314
|
// ---------------------------------------------------------------- Markdown
|
|
315
315
|
const VERDICT_MD = { pass: '✅ pass', 'pass-with-notes': '🟡 notes', blocked: '⛔ blocked' };
|
|
316
|
-
const TURN_MD = { you: '👤 your turn', agent: '🤖 agent working', done: '✅ done', merged: '✅ merged', idle: '⏸ idle' };
|
|
316
|
+
const TURN_MD = { you: '👤 your turn', agent: '🤖 main agent working', done: '✅ done', merged: '✅ merged', idle: '⏸ idle' };
|
|
317
317
|
function duration(ms) {
|
|
318
318
|
if (ms < 60_000)
|
|
319
319
|
return `${Math.max(Math.round(ms / 1000), 0)} s`;
|
|
@@ -340,11 +340,11 @@ export function timelineRows(model) {
|
|
|
340
340
|
const rows = [];
|
|
341
341
|
for (const e of model.events) {
|
|
342
342
|
if (e.event === 'step')
|
|
343
|
-
rows.push([e.at, '🤖
|
|
343
|
+
rows.push([e.at, '🤖 main agent', `${[e.stage, e.task, e.role].filter(Boolean).join(' ')} started`]);
|
|
344
344
|
if (e.event === 'gate-requested')
|
|
345
|
-
rows.push([e.at, '🤖
|
|
345
|
+
rows.push([e.at, '🤖 main agent', e.gate === 'verify' ? 'asks you to accept the feature' : `asks you to approve ${e.gate}`]);
|
|
346
346
|
if (e.event === 'amendment-proposed')
|
|
347
|
-
rows.push([e.at, '🤖
|
|
347
|
+
rows.push([e.at, '🤖 main agent', `proposes amendment ${e.amendment ?? ''}`.trim()]);
|
|
348
348
|
if (e.event === 'round-granted')
|
|
349
349
|
rows.push([e.at, '👤 human', `allows round ${e.round} for ${e.step}`]);
|
|
350
350
|
if (e.event === 'auto-on')
|
|
@@ -359,7 +359,7 @@ export function timelineRows(model) {
|
|
|
359
359
|
for (const d of model.decisions)
|
|
360
360
|
rows.push([d.at, '👤 human', `${d.what}${d.detail ? `: ${d.detail}` : ''}`]);
|
|
361
361
|
for (const c of model.commits)
|
|
362
|
-
rows.push([c.at, '🤖
|
|
362
|
+
rows.push([c.at, '🤖 main agent', `commit \`${c.sha}\` ${c.subject}`]);
|
|
363
363
|
return rows.sort((a, b) => a[0].localeCompare(b[0]));
|
|
364
364
|
}
|
|
365
365
|
/** docs/agjan/<unit>/progress.md */
|
|
@@ -383,7 +383,7 @@ export function unitMarkdown(model, { generatedAt }) {
|
|
|
383
383
|
out.push(`| Acceptance criteria | ${model.acs.total}: ${tested}${model.acs.manual.length ? ` · manual: ${model.acs.manual.join(', ')}` : ''} |`);
|
|
384
384
|
}
|
|
385
385
|
out.push(`| Reviews | ${s.reviews} · ${s.blocked} blocked · findings ${s.openFindings} open of ${s.totalFindings}, ${s.openBlockers} blocker(s) |`);
|
|
386
|
-
const agents = [model.host ? `
|
|
386
|
+
const agents = [model.host ? `main agent: ${model.host}` : null, ...model.reviewers.map((r) => `${r.name} (${r.model}${r.isolated ? ', isolated' : ''})`)].filter(Boolean);
|
|
387
387
|
if (agents.length)
|
|
388
388
|
out.push(`| Agents | ${agents.join(' · ')} |`);
|
|
389
389
|
if (model.humans.length)
|
package/dist/qa.js
CHANGED
|
@@ -5,7 +5,7 @@ import { latestReview, stillBlocked } from './feature.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* The QA step (design decision 81): in Verify, the QA agent (`agjan-qa`, the qa-tester
|
|
7
7
|
* skill) writes and runs tests from the spec alone, without the design, the diff or the
|
|
8
|
-
*
|
|
8
|
+
* main agent's tests. Its tests stay in the project as regression tests, in two folders per
|
|
9
9
|
* feature: service tests, and UI tests where the project's Playwright tests live.
|
|
10
10
|
*/
|
|
11
11
|
export const QA_STEP = 'qa';
|
package/dist/review-policy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Review settings from agjan.config.json (design 7.3, 7.4): which reviewer agent runs a
|
|
3
3
|
* step (`review.tiers`), how many correction rounds a step gets (`review.rounds`), and
|
|
4
|
-
* how many attempts the
|
|
4
|
+
* how many attempts the main agent has for failing deterministic checks
|
|
5
5
|
* (`build.fix_attempts`). `agjan status` shows them; the skills follow `status`.
|
|
6
6
|
*/
|
|
7
7
|
import { stillBlocked } from './feature.js';
|
package/dist/review.js
CHANGED
|
@@ -148,7 +148,7 @@ const CHECKLISTS = {
|
|
|
148
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.',
|
|
149
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).',
|
|
150
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.',
|
|
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
|
|
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 main agent 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.',
|
|
152
152
|
};
|
|
153
153
|
/**
|
|
154
154
|
* What the given tasks may change (design 6.5), as `agjan check` judges it: the task paths,
|
|
@@ -268,7 +268,7 @@ export function buildContextText(root, config, feature, parsed) {
|
|
|
268
268
|
/** review_context: builds the context, stores its metadata, returns id and text. */
|
|
269
269
|
/**
|
|
270
270
|
* A new round of a step is pointless when nothing changed since its last round raised
|
|
271
|
-
* findings: the reviewer would see the same files. It happens when
|
|
271
|
+
* findings: the reviewer would see the same files. It happens when the main agent starts the
|
|
272
272
|
* review before (or in parallel with) its edits, and it costs one of the step's rounds.
|
|
273
273
|
*/
|
|
274
274
|
function unchangedSinceFindings(feature, step, tree) {
|
|
@@ -439,7 +439,7 @@ export function recordReview(root, config, input, recorder) {
|
|
|
439
439
|
/**
|
|
440
440
|
* qa_context (decision 81): the QA agent's input. Only what a tester gets: the spec, how
|
|
441
441
|
* to run the application and who its users are, and the test conventions; never the
|
|
442
|
-
* design, the diff or the
|
|
442
|
+
* design, the diff or the main agent's tests. Ready once the build is complete and reviewed.
|
|
443
443
|
*/
|
|
444
444
|
export function createQaContext(root, config, { feature: slug }) {
|
|
445
445
|
const feature = loadFeature(root, slug);
|
package/dist/select.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function initialSelect(count) {
|
|
2
|
+
return { cursor: 0, picked: Array(count).fill(false), warn: false };
|
|
3
|
+
}
|
|
4
|
+
/** The key a chunk of terminal input stands for: arrows and k/j move, space ticks, `a` ticks all. */
|
|
5
|
+
export function keysOf(chunk) {
|
|
6
|
+
const keys = [];
|
|
7
|
+
for (const token of chunk.match(/\x1b\[[0-9;]*[A-Za-z]|\x1bO[A-Z]|\x1b|[\s\S]/g) ?? []) {
|
|
8
|
+
const key = {
|
|
9
|
+
'\x1b[A': 'up', '\x1bOA': 'up', k: 'up',
|
|
10
|
+
'\x1b[B': 'down', '\x1bOB': 'down', j: 'down',
|
|
11
|
+
' ': 'toggle', a: 'all',
|
|
12
|
+
'\r': 'enter', '\n': 'enter',
|
|
13
|
+
'\x03': 'cancel', '\x04': 'cancel', '\x1b': 'cancel', q: 'cancel',
|
|
14
|
+
}[token];
|
|
15
|
+
if (key)
|
|
16
|
+
keys.push(key);
|
|
17
|
+
}
|
|
18
|
+
return keys;
|
|
19
|
+
}
|
|
20
|
+
/** The state after a key; `done` when Enter confirmed a choice or the human cancelled. */
|
|
21
|
+
export function reduceSelect(state, key) {
|
|
22
|
+
const count = state.picked.length;
|
|
23
|
+
switch (key) {
|
|
24
|
+
case 'up':
|
|
25
|
+
return { state: { ...state, cursor: (state.cursor + count - 1) % count, warn: false } };
|
|
26
|
+
case 'down':
|
|
27
|
+
return { state: { ...state, cursor: (state.cursor + 1) % count, warn: false } };
|
|
28
|
+
case 'toggle':
|
|
29
|
+
return { state: { ...state, picked: state.picked.map((p, i) => (i === state.cursor ? !p : p)), warn: false } };
|
|
30
|
+
case 'all':
|
|
31
|
+
return { state: { ...state, picked: state.picked.map(() => !state.picked.every(Boolean)), warn: false } };
|
|
32
|
+
case 'enter':
|
|
33
|
+
return state.picked.some(Boolean) ? { state, done: 'confirm' } : { state: { ...state, warn: true } };
|
|
34
|
+
case 'cancel':
|
|
35
|
+
return { state, done: 'cancel' };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** The lines of the picker: the question, one line per choice, and a hint (or the refusal). */
|
|
39
|
+
export function renderSelect(s, question, choices, state) {
|
|
40
|
+
const rows = choices.map((choice, i) => {
|
|
41
|
+
const here = i === state.cursor;
|
|
42
|
+
const box = state.picked[i] ? s.green('◉') : s.gray('◯');
|
|
43
|
+
const label = here ? s.bold(s.teal(choice.label)) : state.picked[i] ? s.green(choice.label) : choice.label;
|
|
44
|
+
return `${here ? s.teal('❯') : ' '} ${box} ${label}`;
|
|
45
|
+
});
|
|
46
|
+
const hint = state.warn
|
|
47
|
+
? s.red('Select at least one host with space, then press enter.')
|
|
48
|
+
: s.gray('↑/↓ move · space select · a all · enter confirm · esc cancel');
|
|
49
|
+
return [`${s.teal('?')} ${s.bold(question)}`, ...rows, ` ${hint}`];
|
|
50
|
+
}
|
|
51
|
+
/** The one line left on the terminal once the human confirmed. */
|
|
52
|
+
export function renderChosen(s, question, chosen) {
|
|
53
|
+
return `${s.green('✔')} ${s.bold(question)} ${s.teal(chosen.join(', '))}`;
|
|
54
|
+
}
|
package/dist/terminal.js
CHANGED
|
@@ -2,6 +2,8 @@ import { openSync, readSync, writeSync, closeSync } from 'node:fs';
|
|
|
2
2
|
import { createInterface } from 'node:readline';
|
|
3
3
|
import { ReadStream, WriteStream, isatty } from 'node:tty';
|
|
4
4
|
import { AgjanError } from './errors.js';
|
|
5
|
+
import { initialSelect, keysOf, reduceSelect, renderChosen, renderSelect } from './select.js';
|
|
6
|
+
import { createStyle } from './ui.js';
|
|
5
7
|
/**
|
|
6
8
|
* Opens the controlling terminal, bypassing stdin and stdout, so that piped input
|
|
7
9
|
* cannot answer a confirmation (design 9.4). Returns null when there is none, which is
|
|
@@ -81,6 +83,83 @@ export function askOnTerminal(question, { defaultYes = false } = {}) {
|
|
|
81
83
|
closeSync(tty.output);
|
|
82
84
|
}
|
|
83
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Asks the human to choose among `choices` on the controlling terminal: with the cursor
|
|
88
|
+
* keys, space and Enter where the terminal allows, else by typing numbers or names
|
|
89
|
+
* separated by commas. Returns null when there is no terminal (a script, CI or an
|
|
90
|
+
* agent): the caller then needs the choice from a flag. Cancelling is an error.
|
|
91
|
+
*/
|
|
92
|
+
export async function selectOnTerminal(question, choices) {
|
|
93
|
+
const tty = openTerminal();
|
|
94
|
+
if (!tty)
|
|
95
|
+
return null;
|
|
96
|
+
const style = createStyle({ isTTY: true });
|
|
97
|
+
if (!isatty(tty.input)) {
|
|
98
|
+
try {
|
|
99
|
+
return typeSelection(tty, style, question, choices);
|
|
100
|
+
}
|
|
101
|
+
finally {
|
|
102
|
+
closeSync(tty.input);
|
|
103
|
+
if (tty.output !== tty.input)
|
|
104
|
+
closeSync(tty.output);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const input = new ReadStream(tty.input);
|
|
108
|
+
const write = (text) => writeSync(tty.output, text);
|
|
109
|
+
let state = initialSelect(choices.length);
|
|
110
|
+
let lines = 0;
|
|
111
|
+
// Draws the picker over its previous drawing.
|
|
112
|
+
const draw = () => {
|
|
113
|
+
const frame = renderSelect(style, question, choices, state);
|
|
114
|
+
write(`${lines ? `\x1b[${lines - 1}A\r` : ''}${frame.map((l) => `\x1b[2K${l}`).join('\n')}`);
|
|
115
|
+
lines = frame.length;
|
|
116
|
+
};
|
|
117
|
+
const leave = (result) => {
|
|
118
|
+
write(`${lines > 1 ? `\x1b[${lines - 1}A` : ''}\r\x1b[J${result}\x1b[?25h`);
|
|
119
|
+
};
|
|
120
|
+
try {
|
|
121
|
+
input.setRawMode(true);
|
|
122
|
+
write('\x1b[?25l');
|
|
123
|
+
draw();
|
|
124
|
+
const done = await new Promise((resolve) => {
|
|
125
|
+
input.on('data', (chunk) => {
|
|
126
|
+
for (const key of keysOf(chunk.toString('utf8'))) {
|
|
127
|
+
const next = reduceSelect(state, key);
|
|
128
|
+
state = next.state;
|
|
129
|
+
if (next.done)
|
|
130
|
+
return resolve(next.done);
|
|
131
|
+
}
|
|
132
|
+
draw();
|
|
133
|
+
});
|
|
134
|
+
input.on('end', () => resolve('cancel'));
|
|
135
|
+
});
|
|
136
|
+
if (done === 'cancel') {
|
|
137
|
+
leave(`${style.red('✖')} ${style.bold(question)} ${style.gray('cancelled')}\n`);
|
|
138
|
+
throw new AgjanError('cancelled; nothing was changed');
|
|
139
|
+
}
|
|
140
|
+
const chosen = choices.filter((_, i) => state.picked[i]).map((c) => c.id);
|
|
141
|
+
leave(`${renderChosen(style, question, chosen)}\n`);
|
|
142
|
+
return chosen;
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
write('\x1b[?25h');
|
|
146
|
+
input.destroy();
|
|
147
|
+
if (tty.output !== tty.input)
|
|
148
|
+
closeSync(tty.output);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/** The fallback without key input: a numbered list and a typed answer. */
|
|
152
|
+
function typeSelection(tty, s, question, choices) {
|
|
153
|
+
writeSync(tty.output, `${s.teal('?')} ${s.bold(question)}\n${choices.map((c, i) => ` ${s.teal(`${i + 1}.`)} ${c.label}`).join('\n')}\n`);
|
|
154
|
+
for (;;) {
|
|
155
|
+
writeSync(tty.output, `${s.gray('Choose one or more (numbers or names, separated by commas):')} `);
|
|
156
|
+
const answer = readLine(tty.input).trim();
|
|
157
|
+
const picked = answer.split(',').map((a) => a.trim()).filter(Boolean).map((a) => choices[Number(a) - 1]?.id ?? choices.find((c) => c.id === a)?.id);
|
|
158
|
+
if (picked.length && picked.every(Boolean))
|
|
159
|
+
return [...new Set(picked)];
|
|
160
|
+
writeSync(tty.output, `${s.red('Not understood:')} ${answer === '' ? '(nothing)' : answer}\n`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
84
163
|
/**
|
|
85
164
|
* Asks for one line on the controlling terminal with `initial` already typed, so the human
|
|
86
165
|
* can edit it in place (cursor keys, backspace) or press Enter to keep it. Without line
|
package/dist/ui.js
CHANGED
|
@@ -93,7 +93,7 @@ export function highlightMarkdown(style, text) {
|
|
|
93
93
|
* The agjan mark (the "ag" of the app icon: the bowl of the a with its teal stem, and the
|
|
94
94
|
* g with its descender) with two lines of text beside it. Empty when the brand is off.
|
|
95
95
|
*/
|
|
96
|
-
export function mark(style, version, line2 = '
|
|
96
|
+
export function mark(style, version, line2 = 'agentic engineering harness, gated by you', line3 = '') {
|
|
97
97
|
if (!style.brand)
|
|
98
98
|
return [];
|
|
99
99
|
const stem = style.teal('┃');
|
package/docs/guide.md
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
How to set up agjan in a project and work with it. The reasons behind every rule are
|
|
4
4
|
in the [design](design.md); this guide is about using it.
|
|
5
5
|
|
|
6
|
+
agjan is an agentic engineering harness: it runs your AI coding agents like an engineering
|
|
7
|
+
team (a main agent, an independent reviewer and a QA tester), spec-driven, under approval
|
|
8
|
+
gates you hold and checks that CI enforces. It is not an agent or a model; it is the
|
|
9
|
+
structure around the agents you already use (Claude Code, GitHub Copilot).
|
|
10
|
+
|
|
6
11
|
- [Concepts](#concepts)
|
|
7
12
|
- [Set up a project](#set-up-a-project)
|
|
8
13
|
- [The workflow](#the-workflow)
|
|
@@ -33,12 +38,34 @@ in the [design](design.md); this guide is about using it.
|
|
|
33
38
|
Requirements: Node.js 22 or later, git, and Claude Code and/or GitHub Copilot.
|
|
34
39
|
|
|
35
40
|
```sh
|
|
36
|
-
npm install --
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
npm install --global agjan
|
|
42
|
+
agjan init my-project # asks which hosts to set up (or: --hosts claude-code,copilot), then to commit the setup
|
|
43
|
+
cd my-project # a command cannot move your shell: init prints this as its first next step
|
|
44
|
+
agjan doctor
|
|
40
45
|
```
|
|
41
46
|
|
|
47
|
+
`agjan init <folder>` creates the folder, runs `git init -b main`, writes a `package.json`
|
|
48
|
+
(only when there is none), pins the running version of agjan in `devDependencies` and
|
|
49
|
+
installs it with the project's package manager (npm, pnpm, yarn or bun, from the lockfile;
|
|
50
|
+
`--pm` overrides). `agjan init .` does the same in the current folder and keeps what is
|
|
51
|
+
there: an existing repository, `package.json` and pinned version stay as they are. It stops
|
|
52
|
+
before changing anything when the folder already has an `agjan.config.json`, when
|
|
53
|
+
`package.json` is not valid JSON, or when the folder lies inside another git repository.
|
|
54
|
+
`--dry-run` shows the plan, `--no-install` only pins the version.
|
|
55
|
+
|
|
56
|
+
When everything is written, `init` offers to commit the setup (`chore: set up agjan`): on
|
|
57
|
+
`main` in a new repository, on a branch of its own, `chore/set-up-agjan`, in an existing one
|
|
58
|
+
(the base branch changes through a PR). `--commit` and `--no-commit` answer the question.
|
|
59
|
+
Nothing is committed for you when the folder had other work in it (files in a folder that was
|
|
60
|
+
not a repository, or uncommitted changes), nor when `--no-install` leaves the pre-commit hook
|
|
61
|
+
without its agjan; the next steps then say what to run.
|
|
62
|
+
|
|
63
|
+
The global `agjan` runs `init`, `--help` and `--version` itself. Every other command runs
|
|
64
|
+
in the agjan the project pins in `node_modules`. If that is not installed (a fresh clone),
|
|
65
|
+
the command offers to run the install first; without a terminal it fails and says how
|
|
66
|
+
(`agjan --yes <command>` installs without asking). Without a global install, `npx agjan init
|
|
67
|
+
<folder>` works the same.
|
|
68
|
+
|
|
42
69
|
`init` writes `agjan.config.json`, the skills (`.claude/skills/`), the reviewer agents,
|
|
43
70
|
the guardrails against agents running approvals, the MCP configuration, a block in
|
|
44
71
|
`AGENTS.md` and `CLAUDE.md`, a pre-commit hook and a CI workflow. Your own content in
|
|
@@ -122,8 +149,8 @@ gives you the last gate.
|
|
|
122
149
|
|
|
123
150
|
**QA** (full-mode features; `review.qa: "off"` turns it off): before the final review, a
|
|
124
151
|
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
|
|
126
|
-
tests, and writes tests aimed at what
|
|
152
|
+
to run the application and its users, but not the design, the code or the main agent's
|
|
153
|
+
tests, and writes tests aimed at what main agents tend to miss: invalid input, users a rule
|
|
127
154
|
excludes, anonymous requests, boundaries, doing something twice, the flows in the browser.
|
|
128
155
|
It runs them and records the result like a review. A failing test is a blocker: the
|
|
129
156
|
agent fixes the code, never the QA tests, and QA runs again. Something the spec does not
|
|
@@ -209,7 +236,7 @@ records (step, review, approval, amendment, fix record):
|
|
|
209
236
|
loops round by round, tasks with their commits and reviews, the timeline of every
|
|
210
237
|
event, and the findings. Committed with the unit, so the pull request shows it.
|
|
211
238
|
- `.agjan/progress.html`: the whole project in one self-contained page (no extension, no
|
|
212
|
-
internet): one row per unit, and for the selected one a swim-lane timeline (
|
|
239
|
+
internet): one row per unit, and for the selected one a swim-lane timeline (main agent,
|
|
213
240
|
reviewers, people), the review loops (select a round to see its findings), findings,
|
|
214
241
|
tasks and who worked on it. `.agjan/progress.md` is the same overview as Markdown.
|
|
215
242
|
Both are local (`.agjan/` is not committed).
|
|
@@ -304,7 +331,7 @@ lists replace. The schema is `node_modules/agjan/schemas/config.schema.json`.
|
|
|
304
331
|
| `build.fix_attempts` | attempts for failing deterministic checks before the agent stops (default 3) |
|
|
305
332
|
| `language` | language of the documents' text (default `en`); headings, ids and keywords stay English |
|
|
306
333
|
| `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`) |
|
|
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
|
|
334
|
+
| `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 main agent (for example `gpt-6-sol` while the main agent runs on Claude) misses other things than the main agent. 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 |
|
|
308
335
|
| `mcp.servers.<name>` | documentation MCP servers: `command`, `args`, `env`, `areas`, `enabled` |
|
|
309
336
|
| `ci.policy_changes`, `ci.untracked_changes` | `warn` or `fail` in `check --ci` |
|
|
310
337
|
|
|
@@ -5,15 +5,15 @@ description: Knowledge of agjan's QA agent, the tester of the QA step in Verify.
|
|
|
5
5
|
|
|
6
6
|
# agjan QA
|
|
7
7
|
|
|
8
|
-
You are agjan's tester.
|
|
8
|
+
You are agjan's tester. The main agent built a feature and tested it with its own tests; you
|
|
9
9
|
test it again **from the requirements alone**, the way a tester who got the spec would.
|
|
10
|
-
Your value is the view the
|
|
10
|
+
Your value is the view the main agent does not have: you find what its tests did not ask.
|
|
11
11
|
|
|
12
12
|
## The rules
|
|
13
13
|
|
|
14
14
|
- **Black box.** Use only what `qa_context` gives you: the spec, how to run the
|
|
15
15
|
application, its users and the test conventions. Do not read the design, the
|
|
16
|
-
application code (`srv/`, `db/`, `app/`) or the
|
|
16
|
+
application code (`srv/`, `db/`, `app/`) or the main agent's tests. You may read the
|
|
17
17
|
testing references it names, for the test mechanics only.
|
|
18
18
|
- **Your folders only.** Write only in the two QA folders the context names
|
|
19
19
|
(`test/qa/<feature>/` for service tests, `test/ui/qa/<feature>/` for UI tests). Never
|
|
@@ -27,7 +27,7 @@ Your value is the view the writer does not have: you find what its tests did not
|
|
|
27
27
|
1. Call `qa_context`. It returns a `context_id` and the material.
|
|
28
28
|
2. Read the spec closely: every acceptance criterion, the Authorization section, the
|
|
29
29
|
non-functional requirements and the scope.
|
|
30
|
-
3. Derive the cases the
|
|
30
|
+
3. Derive the cases the main agent most likely did not test. For each AC and rule:
|
|
31
31
|
- **negative cases:** invalid input, missing required values, wrong types, values
|
|
32
32
|
just outside the allowed range;
|
|
33
33
|
- **who may not:** a user without the role, a user with the role whom a condition
|
|
@@ -62,13 +62,13 @@ Your value is the view the writer does not have: you find what its tests did not
|
|
|
62
62
|
|
|
63
63
|
## In later rounds
|
|
64
64
|
|
|
65
|
-
The
|
|
65
|
+
The main agent fixed the code for your blockers (never your tests). Run all your tests
|
|
66
66
|
again, add tests where the fix suggests a related risk, and record the round. If a test
|
|
67
67
|
of yours was changed by someone else, `agjan status` reports QA as stale: run it again
|
|
68
68
|
and judge the current tests.
|
|
69
69
|
|
|
70
70
|
## Never
|
|
71
71
|
|
|
72
|
-
- Read the design, the application code or the
|
|
72
|
+
- Read the design, the application code or the main agent's tests.
|
|
73
73
|
- Change anything outside your QA folders, or weaken a test so that it passes.
|
|
74
74
|
- Run `agjan approve`, `agjan accept`, `agjan reject`, `agjan auto` or `agjan models set`.
|
|
@@ -5,7 +5,7 @@ description: Knowledge of agjan's read-only reviewer. Used by the generated agja
|
|
|
5
5
|
|
|
6
6
|
# agjan reviewer
|
|
7
7
|
|
|
8
|
-
You are agjan's independent, read-only reviewer.
|
|
8
|
+
You are agjan's independent, read-only reviewer. The main agent produced a document or a
|
|
9
9
|
change; you judge it. You never fix anything yourself.
|
|
10
10
|
|
|
11
11
|
## How a review runs
|
|
@@ -47,7 +47,7 @@ A finding that says an API, annotation, configuration or syntax is wrong must na
|
|
|
47
47
|
`.claude/skills/fiori-developer/references/elements.md`, section "Actions") or a project
|
|
48
48
|
file that shows it. Read the reference before you claim it. If you cannot confirm the
|
|
49
49
|
claim, give it at most the severity `minor` and start the issue with "Unverified:". An
|
|
50
|
-
unverified claim must never make
|
|
50
|
+
unverified claim must never make the main agent remove working code.
|
|
51
51
|
|
|
52
52
|
## Rules
|
|
53
53
|
|
|
@@ -57,5 +57,5 @@ unverified claim must never make a writer remove working code.
|
|
|
57
57
|
own preferences. Do not ask for work beyond the spec.
|
|
58
58
|
- The document structure (headings, sections) is fixed by agjan and checked by a
|
|
59
59
|
script. Never ask to remove, rename or add a section.
|
|
60
|
-
- Be specific and brief. No praise, no summaries of what the
|
|
60
|
+
- Be specific and brief. No praise, no summaries of what the main agent did.
|
|
61
61
|
- Prefer one precise blocker over several vague notes.
|
|
@@ -143,7 +143,7 @@ footer { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--lin
|
|
|
143
143
|
<div class="gen"><span id="generated"></span><span>refresh: <code>npx agjan progress --open</code></span></div>
|
|
144
144
|
</header>
|
|
145
145
|
<section aria-labelledby="ov">
|
|
146
|
-
<div class="panel-head" style="margin-bottom:10px"><h2 id="ov">Project</h2><span class="legend"><span><i style="background:var(--human)"></i>your turn</span><span><i style="background:var(--accent)"></i>agent working</span><span><i style="background:var(--pass)"></i>done or merged</span></span></div>
|
|
146
|
+
<div class="panel-head" style="margin-bottom:10px"><h2 id="ov">Project</h2><span class="legend"><span><i style="background:var(--human)"></i>your turn</span><span><i style="background:var(--accent)"></i>main agent working</span><span><i style="background:var(--pass)"></i>done or merged</span></span></div>
|
|
147
147
|
<div class="units" id="units"></div>
|
|
148
148
|
</section>
|
|
149
149
|
<section class="detail" id="detail" aria-live="polite"></section>
|
|
@@ -173,7 +173,7 @@ function turnPill(u) {
|
|
|
173
173
|
if (u.turn === 'you') return `<span class="pill you"><span class="pulse">●</span> Your turn</span>`;
|
|
174
174
|
if (u.turn === 'merged') return `<span class="pill merged">✓ Merged</span>`;
|
|
175
175
|
if (u.turn === 'done') return `<span class="pill merged">✓ Done</span>`;
|
|
176
|
-
return `<span class="pill agent">
|
|
176
|
+
return `<span class="pill agent">Main agent working</span>`;
|
|
177
177
|
}
|
|
178
178
|
function trackHtml(u) {
|
|
179
179
|
return u.stages.map((s, i) => {
|
|
@@ -219,7 +219,7 @@ function timeline(u) {
|
|
|
219
219
|
const pad = (t1 - t0) * 0.02;
|
|
220
220
|
const a = t0 - pad, z = t1 + pad;
|
|
221
221
|
const x = (at) => L + ((ms(at) - a) / (z - a)) * (W - L - R);
|
|
222
|
-
const
|
|
222
|
+
const mainAgent = u.host ? `${u.host}` : 'main agent';
|
|
223
223
|
let s = `<svg viewBox="0 0 ${W} 214" width="100%" style="min-width:760px" role="img" aria-label="Timeline of ${esc(u.key)}">`;
|
|
224
224
|
const tk = ticks(a, z);
|
|
225
225
|
for (const t of tk.out) {
|
|
@@ -227,10 +227,10 @@ function timeline(u) {
|
|
|
227
227
|
const iso = new Date(t).toISOString();
|
|
228
228
|
s += `<line x1="${xx}" y1="14" x2="${xx}" y2="188" stroke="var(--line)" stroke-width="1"/><text class="t-tick" x="${xx}" y="206" text-anchor="middle">${tk.days ? dhm(iso) : hm(iso)}</text>`;
|
|
229
229
|
}
|
|
230
|
-
s += `<text class="t-lane" x="0" y="42">
|
|
230
|
+
s += `<text class="t-lane" x="0" y="42">Main agent</text><text class="t-sub" x="0" y="56">${esc(mainAgent)}</text>`;
|
|
231
231
|
s += `<text class="t-lane" x="0" y="102">Reviewers</text><text class="t-sub" x="0" y="116">isolated agents</text>`;
|
|
232
|
-
s += `<text class="t-lane" x="0" y="162">
|
|
233
|
-
for (const w of u.
|
|
232
|
+
s += `<text class="t-lane" x="0" y="162">Human</text><text class="t-sub" x="0" y="176">gates in a terminal</text>`;
|
|
233
|
+
for (const w of u.mainAgent) {
|
|
234
234
|
const p = x(w.from), q = x(w.to);
|
|
235
235
|
s += `<rect x="${p}" y="26" width="${Math.max(q - p, 3)}" height="26" rx="4" fill="var(--accent-bg)" stroke="var(--accent)"><title>${esc(w.label)}: ${hm(w.from)}–${hm(w.to)}</title></rect>`;
|
|
236
236
|
if (q - p > 60) s += `<text class="t-bar" x="${p + 6}" y="43">${esc(w.label)}</text>`;
|
|
@@ -308,7 +308,7 @@ function renderDetail() {
|
|
|
308
308
|
<div class="stat"><span class="v">${s.reviews} <small>${s.blocked} blocked</small></span><span class="l">reviews</span></div>
|
|
309
309
|
<div class="stat"><span class="v">${s.openFindings} <small>/ ${s.totalFindings}</small></span><span class="l">findings open · ${s.openBlockers} blocker(s)</span></div>
|
|
310
310
|
</div>
|
|
311
|
-
<div class="panel"><div class="panel-head"><h3>Timeline</h3><span class="legend"><span><i style="background:var(--accent)"></i>
|
|
311
|
+
<div class="panel"><div class="panel-head"><h3>Timeline</h3><span class="legend"><span><i style="background:var(--accent)"></i>main agent step · ▲ commit</span><span><i style="background:var(--pass)"></i>pass</span><span><i style="background:var(--notes)"></i>notes</span><span><i style="background:var(--blocked)"></i>blocked</span><span><i style="background:var(--human)"></i>waiting for a human · | decision</span></span></div>
|
|
312
312
|
<div class="scroll">${timeline(u)}</div></div>
|
|
313
313
|
<div class="panel"><div class="panel-head"><h3>Review loops</h3><span class="muted" style="font-size:12.5px">Up to ${u.roundLimit} rounds per loop. Select a round to see what it raised and resolved.</span></div><div class="loops">${loops(u)}</div></div>
|
|
314
314
|
<div class="cols">
|
|
@@ -318,7 +318,7 @@ function renderDetail() {
|
|
|
318
318
|
<div style="display:grid;gap:16px;align-content:start">
|
|
319
319
|
${u.tasks.length ? `<div class="panel"><h3>Tasks</h3><table><thead><tr><th>Task</th><th>Commits</th><th>Reviews</th></tr></thead><tbody>${taskRows}</tbody></table></div>` : ''}
|
|
320
320
|
<div class="panel"><h3>Who worked on it</h3><div class="people">
|
|
321
|
-
${u.host ? `<div class="who"><span class="av w">
|
|
321
|
+
${u.host ? `<div class="who"><span class="av w">M</span><span><b>Main agent</b> · ${esc(u.host)}<small>${u.mainAgent.length} step${u.mainAgent.length === 1 ? '' : 's'} · ${u.commits.length} commit${u.commits.length === 1 ? '' : 's'}</small></span></div>` : ''}
|
|
322
322
|
${reviewers}${people}
|
|
323
323
|
${!u.host && !reviewers && !people ? '<p class="empty">Nobody yet.</p>' : ''}
|
|
324
324
|
</div></div>
|
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agjan",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.15",
|
|
4
|
+
"description": "Agentic engineering harness for AI coding agents: role agents, human approval gates, independent review and CI-enforced checks. SAP BTP first.",
|
|
5
5
|
"keywords": [
|
|
6
|
+
"agentic-engineering",
|
|
7
|
+
"agent-harness",
|
|
6
8
|
"ai",
|
|
7
9
|
"agents",
|
|
10
|
+
"ai-agents",
|
|
8
11
|
"claude-code",
|
|
9
12
|
"copilot",
|
|
10
13
|
"spec-driven",
|
|
14
|
+
"code-review",
|
|
11
15
|
"workflow",
|
|
16
|
+
"sap",
|
|
12
17
|
"cap",
|
|
13
18
|
"fiori",
|
|
14
19
|
"ui5"
|