agjan 0.0.4 → 0.0.6
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/docs/guide.md +25 -3
- package/kit/skills/agjan-build/SKILL.md +1 -1
- package/kit/skills/agjan-design/SKILL.md +4 -3
- package/kit/skills/agjan-fix/SKILL.md +1 -1
- package/kit/skills/agjan-map/SKILL.md +1 -1
- package/kit/skills/agjan-spec/SKILL.md +4 -1
- package/kit/skills/agjan-verify/SKILL.md +6 -3
- package/kit/skills/fiori-developer/references/elements.md +8 -1
- package/kit/skills/solution-reviewer/SKILL.md +13 -3
- package/kit/templates/agents-block.md +5 -1
- package/kit/templates/progress.html +338 -0
- package/package.json +1 -1
- package/schemas/config.schema.json +5 -1
- package/schemas/reviews.schema.json +2 -1
- package/src/adapters/claude-code.mjs +6 -4
- package/src/adapters/copilot.mjs +5 -4
- package/src/cli.mjs +12 -4
- package/src/commands/check.mjs +3 -1
- package/src/commands/gates.mjs +2 -2
- package/src/commands/progress.mjs +40 -0
- package/src/commands/setup.mjs +38 -7
- package/src/commands/status.mjs +45 -1
- package/src/config.mjs +14 -0
- package/src/log.mjs +12 -0
- package/src/mcp.mjs +5 -0
- package/src/progress-view.mjs +434 -0
- package/src/review.mjs +25 -12
- package/src/ui.mjs +26 -22
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stringify as toYaml } from 'yaml';
|
|
2
2
|
import { skillBody } from '../managed.mjs';
|
|
3
|
+
import { agentModel } from '../config.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Claude Code adapter (design 13): the generated reviewer agents and the deny rules for
|
|
@@ -8,7 +9,8 @@ import { skillBody } from '../managed.mjs';
|
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
export const HOST = 'claude-code';
|
|
11
|
-
|
|
12
|
+
/** The models earlier versions used when none were configured; `sync` writes them for such projects. */
|
|
13
|
+
export const LEGACY_MODELS = { balanced: 'sonnet', deep: 'opus' };
|
|
12
14
|
|
|
13
15
|
/** One agent per reviewer tier; workflow skills pick the tier per step (design 7.3). */
|
|
14
16
|
const REVIEWERS = [
|
|
@@ -65,7 +67,7 @@ function reviewerAgent(name, tier, model, skill) {
|
|
|
65
67
|
`agjan's read-only reviewer (${tier} tier). Use only when an agjan workflow skill asks for the ` +
|
|
66
68
|
'review of a step; it records its result itself.',
|
|
67
69
|
tools: 'Read, Grep, Glob, mcp__agjan__review_context, mcp__agjan__review_record',
|
|
68
|
-
model,
|
|
70
|
+
...(model ? { model } : {}),
|
|
69
71
|
// Scoped to this agent only: the writer session must not have review_record.
|
|
70
72
|
mcpServers: [
|
|
71
73
|
{
|
|
@@ -89,12 +91,12 @@ function reviewerAgent(name, tier, model, skill) {
|
|
|
89
91
|
|
|
90
92
|
/** The plan items this adapter contributes. */
|
|
91
93
|
export function plan(config, skills) {
|
|
92
|
-
|
|
94
|
+
|
|
93
95
|
const skill = skills['solution-reviewer/SKILL.md'];
|
|
94
96
|
const items = REVIEWERS.map(({ name, tier }) => ({
|
|
95
97
|
kind: 'file',
|
|
96
98
|
path: `.claude/agents/${name}.md`,
|
|
97
|
-
content: reviewerAgent(name, tier,
|
|
99
|
+
content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
|
|
98
100
|
}));
|
|
99
101
|
items.push({
|
|
100
102
|
kind: 'json',
|
package/src/adapters/copilot.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stringify as toYaml } from 'yaml';
|
|
2
2
|
import { skillBody } from '../managed.mjs';
|
|
3
|
+
import { agentModel } from '../config.mjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* GitHub Copilot adapter (design 13), verified with the Copilot CLI
|
|
@@ -16,8 +17,8 @@ export const HOST = 'copilot';
|
|
|
16
17
|
export const HOOK_FILE = '.github/hooks/agjan-guard.json';
|
|
17
18
|
export const GUARD = 'node_modules/agjan/kit/hooks/guard.mjs';
|
|
18
19
|
|
|
19
|
-
/**
|
|
20
|
-
export const
|
|
20
|
+
/** The models earlier versions used when none were configured: the session's model. */
|
|
21
|
+
export const LEGACY_MODELS = {};
|
|
21
22
|
|
|
22
23
|
const REVIEWERS = [
|
|
23
24
|
{ name: 'agjan-reviewer', tier: 'balanced' },
|
|
@@ -76,12 +77,12 @@ export function hookConfig() {
|
|
|
76
77
|
|
|
77
78
|
/** The plan items this adapter contributes. */
|
|
78
79
|
export function plan(config, skills) {
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
const skill = skills['solution-reviewer/SKILL.md'];
|
|
81
82
|
const items = REVIEWERS.map(({ name, tier }) => ({
|
|
82
83
|
kind: 'file',
|
|
83
84
|
path: `.github/agents/${name}.agent.md`,
|
|
84
|
-
content: reviewerAgent(name, tier,
|
|
85
|
+
content: reviewerAgent(name, tier, agentModel(config, HOST, tier), skill),
|
|
85
86
|
}));
|
|
86
87
|
items.push({ kind: 'file', path: HOOK_FILE, content: hookConfig() });
|
|
87
88
|
return items;
|
package/src/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, pkg } from './context.mjs';
|
|
2
2
|
import { AgjanError } from './errors.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { createStyle, mark } from './ui.mjs';
|
|
4
4
|
import * as newCommand from './commands/new.mjs';
|
|
5
5
|
import * as gates from './commands/gates.mjs';
|
|
6
6
|
import * as check from './commands/check.mjs';
|
|
@@ -13,6 +13,9 @@ import * as report from './commands/report.mjs';
|
|
|
13
13
|
import * as fix from './commands/fix.mjs';
|
|
14
14
|
import * as mapCommand from './commands/map.mjs';
|
|
15
15
|
import * as branch from './commands/branch.mjs';
|
|
16
|
+
import * as progress from './commands/progress.mjs';
|
|
17
|
+
import { onEvent } from './log.mjs';
|
|
18
|
+
import { refreshAfterEvent } from './progress-view.mjs';
|
|
16
19
|
|
|
17
20
|
const COMMANDS = {
|
|
18
21
|
init: setup.init,
|
|
@@ -20,6 +23,7 @@ const COMMANDS = {
|
|
|
20
23
|
doctor: setup.doctor,
|
|
21
24
|
hook: setup.hook,
|
|
22
25
|
branch: branch.run,
|
|
26
|
+
progress: progress.run,
|
|
23
27
|
new: newCommand.run,
|
|
24
28
|
scaffold: newCommand.scaffold,
|
|
25
29
|
status: status.run,
|
|
@@ -58,6 +62,8 @@ Agent and human:
|
|
|
58
62
|
git.branch.create "confirm": a human, who may edit the name)
|
|
59
63
|
new <slug> --key <KEY> create a feature folder with approvals.json and spec.md
|
|
60
64
|
scaffold design create design.md and tasks.md from the templates
|
|
65
|
+
progress [--open] regenerate the progress pages and show the overview
|
|
66
|
+
(.agjan/progress.html, docs/agjan/<unit>/progress.md)
|
|
61
67
|
status [--feature <s> | --all]
|
|
62
68
|
show the state of the changed (or every) feature
|
|
63
69
|
check [--staged | --ci] [--base <ref>]
|
|
@@ -101,13 +107,13 @@ export async function main(args, options = {}) {
|
|
|
101
107
|
|
|
102
108
|
if (command === undefined || command === '--help' || command === '-h' || command === 'help') {
|
|
103
109
|
const s = createStyle(stdout);
|
|
104
|
-
if (!s.
|
|
110
|
+
if (!s.brand) {
|
|
105
111
|
stdout.write(HELP);
|
|
106
112
|
return 0;
|
|
107
113
|
}
|
|
108
|
-
// On a terminal: the
|
|
114
|
+
// On a terminal: the agjan mark instead of the first line, and bold section headings.
|
|
109
115
|
const body = HELP.split('\n').slice(1).map((l) => (/^\S.*:$/.test(l) ? s.bold(l) : l));
|
|
110
|
-
stdout.write(`${[...
|
|
116
|
+
stdout.write(`${[...mark(s, pkg.version), ...body.slice(1)].join('\n')}`);
|
|
111
117
|
return 0;
|
|
112
118
|
}
|
|
113
119
|
if (command === '--version' || command === '-v' || command === 'version') {
|
|
@@ -115,6 +121,8 @@ export async function main(args, options = {}) {
|
|
|
115
121
|
return 0;
|
|
116
122
|
}
|
|
117
123
|
|
|
124
|
+
// Every recorded event regenerates the progress pages (docs/agjan/<unit>/progress.md, .agjan/).
|
|
125
|
+
onEvent((unitDir) => refreshAfterEvent(unitDir, pkg.version));
|
|
118
126
|
const handler = COMMANDS[command];
|
|
119
127
|
if (!handler) {
|
|
120
128
|
stderr.write(`agjan: unknown command '${command}'. Run 'agjan --help'.\n`);
|
package/src/commands/check.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { FIX_FILE, fixRules, freshReview } from '../fix.mjs';
|
|
|
13
13
|
import { BASELINE_FILE, baselineDrift, projectProblems } from '../baseline.mjs';
|
|
14
14
|
import { UsageError } from '../errors.mjs';
|
|
15
15
|
import { readJson } from '../json-file.mjs';
|
|
16
|
-
import { verdictColor } from '../ui.mjs';
|
|
16
|
+
import { markLine, verdictColor } from '../ui.mjs';
|
|
17
17
|
import { planStatus } from '../managed.mjs';
|
|
18
18
|
import { buildPlan } from '../plan.mjs';
|
|
19
19
|
|
|
@@ -290,6 +290,8 @@ function checkPolicy(report, root, config, files, base) {
|
|
|
290
290
|
|
|
291
291
|
function print(ctx, report, level, slugs) {
|
|
292
292
|
const s = ctx.style;
|
|
293
|
+
// Not in the pre-commit hook (--staged): it runs on every commit.
|
|
294
|
+
if (level !== 'staged') for (const line of markLine(s, ctx.kit, level === 'ci' ? 'check --ci' : 'check')) ctx.out(line);
|
|
293
295
|
for (const item of report.items) {
|
|
294
296
|
const label = item.level === 'error' ? s.bold(s.red('error')) : s.bold(s.yellow('warn '));
|
|
295
297
|
ctx.out(`${label} ${s.cyan(item.scope)}: ${item.message}`);
|
package/src/commands/gates.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { appendLog, readLog } from '../log.mjs';
|
|
|
6
6
|
import { APPROVALS_FILE, FEATURES_DIR, gateReview, loadFeature, selectFeature } from '../feature.mjs';
|
|
7
7
|
import { documentProblems, designProblems } from '../validate.mjs';
|
|
8
8
|
import { AgjanError, UsageError } from '../errors.mjs';
|
|
9
|
-
import { tone } from '../ui.mjs';
|
|
9
|
+
import { mark, tone } from '../ui.mjs';
|
|
10
10
|
import { git } from '../git.mjs';
|
|
11
11
|
|
|
12
12
|
function short(hash) {
|
|
@@ -25,7 +25,7 @@ function save(ctx, feature, event, fields) {
|
|
|
25
25
|
/** Shows what is being approved and asks the human to type the feature key (design 9.4). */
|
|
26
26
|
function confirmGate(ctx, feature, title, lines) {
|
|
27
27
|
const summary = [
|
|
28
|
-
'',
|
|
28
|
+
...(ctx.style.brand ? mark(ctx.style, ctx.kit, 'a human decision, recorded with your name') : ['']),
|
|
29
29
|
ctx.style.bold(`agjan: ${title}`),
|
|
30
30
|
` feature ${ctx.style.bold(feature.slug)} (${ctx.style.cyan(feature.key)})`,
|
|
31
31
|
...lines.map((l) => ` ${l}`),
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { relative } from 'node:path';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { writeProgress } from '../progress-view.mjs';
|
|
5
|
+
import { markLine, tone } from '../ui.mjs';
|
|
6
|
+
|
|
7
|
+
/** Opens a file with the system's default application; failures are reported, not thrown. */
|
|
8
|
+
function openFile(file) {
|
|
9
|
+
const [cmd, args] = process.platform === 'win32' ? ['cmd', ['/c', 'start', '""', file]] : [process.platform === 'darwin' ? 'open' : 'xdg-open', [file]];
|
|
10
|
+
try {
|
|
11
|
+
const child = spawn(cmd, args, { stdio: 'ignore', detached: true });
|
|
12
|
+
child.on('error', () => {});
|
|
13
|
+
child.unref();
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** agjan progress [--open]: regenerates the progress pages and prints the overview. */
|
|
21
|
+
export function run(ctx, argv) {
|
|
22
|
+
const { values } = parseArgs({ args: argv, options: { open: { type: 'boolean' } } });
|
|
23
|
+
const s = ctx.style;
|
|
24
|
+
const result = writeProgress(ctx, { now: Date.parse(ctx.now()) });
|
|
25
|
+
for (const line of markLine(s, ctx.kit, 'progress')) ctx.out(line);
|
|
26
|
+
if (!result) {
|
|
27
|
+
ctx.err('agjan progress: the pages could not be generated; run npx agjan check for details');
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
if (!result.models.length) ctx.out('no features, fixes or map runs yet');
|
|
31
|
+
for (const m of result.models) {
|
|
32
|
+
const turn = m.turn === 'you' ? s.violet('your turn') : m.turn === 'merged' ? tone(s, 'merged') : s.cyan('agent working');
|
|
33
|
+
const stage = m.stages[Math.min(m.at, m.stages.length - 1)];
|
|
34
|
+
ctx.out(`${s.bold(m.key.padEnd(6))} ${m.slug.padEnd(34)} ${stage.padEnd(15)} ${turn}${m.turn === 'merged' ? '' : s.gray(` · ${m.now}`)}`);
|
|
35
|
+
}
|
|
36
|
+
const html = relative(ctx.root, result.html).split('\\').join('/');
|
|
37
|
+
ctx.out('', `${s.gray('overview')} ${html} ${s.gray('· per unit: docs/agjan/<unit>/progress.md')}`);
|
|
38
|
+
if (values.open && !openFile(result.html)) ctx.out(`open ${html} in a browser`);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
package/src/commands/setup.mjs
CHANGED
|
@@ -4,7 +4,9 @@ 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, RECOMMENDED_ALLOW, loadConfig, loadDomain } from '../config.mjs';
|
|
7
|
+
import { CONFIG_FILE, MODEL_TIERS, RECOMMENDED_ALLOW, SESSION_MODEL, agentModel, loadConfig, loadDomain } from '../config.mjs';
|
|
8
|
+
import { LEGACY_MODELS as CLAUDE_LEGACY } from '../adapters/claude-code.mjs';
|
|
9
|
+
import { LEGACY_MODELS as COPILOT_LEGACY } from '../adapters/copilot.mjs';
|
|
8
10
|
import { readJson, writeJson } from '../json-file.mjs';
|
|
9
11
|
import { applyPlan, planStatus } from '../managed.mjs';
|
|
10
12
|
import { ADAPTERS, buildPlan, unsupportedHosts } from '../plan.mjs';
|
|
@@ -12,7 +14,7 @@ import { hookStatus, installHook } from '../hook.mjs';
|
|
|
12
14
|
import { GUARD } from '../adapters/copilot.mjs';
|
|
13
15
|
import { git, mergeBase, resolveBase } from '../git.mjs';
|
|
14
16
|
import { AgjanError, UsageError } from '../errors.mjs';
|
|
15
|
-
import {
|
|
17
|
+
import { mark, pad, tone, verdictColor } from '../ui.mjs';
|
|
16
18
|
|
|
17
19
|
const CI_FILE = '.github/workflows/agjan.yml';
|
|
18
20
|
const CI_TEMPLATE = new URL('../../kit/templates/agjan-ci.yml', import.meta.url);
|
|
@@ -44,16 +46,42 @@ function printResults(ctx, results) {
|
|
|
44
46
|
if (unchanged) ctx.out(s.gray(` ${unchanged} file(s) unchanged`));
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
const ADAPTER_LEGACY_MODELS = { 'claude-code': CLAUDE_LEGACY, copilot: COPILOT_LEGACY };
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Missing `models.<host>` entries for the configured hosts, so the reviewer models are
|
|
53
|
+
* visible in agjan.config.json. New projects get "session"; a project from an earlier
|
|
54
|
+
* version gets what it used implicitly (Claude Code: sonnet and opus), so nothing changes.
|
|
55
|
+
*/
|
|
56
|
+
function missingModels(raw, hosts, { existing }) {
|
|
57
|
+
const added = {};
|
|
58
|
+
for (const host of hosts) {
|
|
59
|
+
if (raw.models?.[host]) continue;
|
|
60
|
+
const legacy = existing ? ADAPTER_LEGACY_MODELS[host] ?? {} : {};
|
|
61
|
+
added[host] = Object.fromEntries(MODEL_TIERS.map((tier) => [tier, legacy[tier] ?? SESSION_MODEL]));
|
|
62
|
+
}
|
|
63
|
+
return added;
|
|
64
|
+
}
|
|
65
|
+
|
|
47
66
|
/** Writes the managed files for the current configuration and updates the recorded kit version. */
|
|
48
67
|
function doSync(ctx, { force }) {
|
|
49
68
|
const config = loadConfig(ctx.root);
|
|
50
69
|
for (const host of unsupportedHosts(config)) ctx.err(`agjan: host '${host}' has no adapter in this version; skipped`);
|
|
51
|
-
const results = applyPlan(ctx.root, buildPlan(config), { kit: ctx.kit, force });
|
|
52
70
|
const file = join(ctx.root, CONFIG_FILE);
|
|
53
71
|
const raw = readJson(file) ?? {};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
72
|
+
const added = missingModels(raw, config.hosts, { existing: Boolean(raw.models) || raw.kit !== ctx.kit });
|
|
73
|
+
if (Object.keys(added).length) {
|
|
74
|
+
writeJson(file, { ...raw, models: { ...(raw.models ?? {}), ...added } });
|
|
75
|
+
config.models = { ...(config.models ?? {}), ...added };
|
|
76
|
+
}
|
|
77
|
+
const results = applyPlan(ctx.root, buildPlan(config), { kit: ctx.kit, force });
|
|
78
|
+
for (const [host, tiers] of Object.entries(added)) {
|
|
79
|
+
results.push({ path: CONFIG_FILE, action: `models.${host}: ${MODEL_TIERS.map((t) => `${t}=${tiers[t]}`).join(', ')}` });
|
|
80
|
+
}
|
|
81
|
+
const current = readJson(file) ?? {};
|
|
82
|
+
if (current.kit !== ctx.kit) {
|
|
83
|
+
writeJson(file, { ...current, kit: ctx.kit });
|
|
84
|
+
results.push({ path: CONFIG_FILE, action: current.kit ? `kit ${current.kit} -> ${ctx.kit}` : `kit ${ctx.kit}` });
|
|
57
85
|
}
|
|
58
86
|
return results;
|
|
59
87
|
}
|
|
@@ -90,6 +118,7 @@ export async function init(ctx, argv) {
|
|
|
90
118
|
domains,
|
|
91
119
|
hosts,
|
|
92
120
|
language: values.language ?? 'en',
|
|
121
|
+
models: missingModels({}, hosts, { existing: false }),
|
|
93
122
|
};
|
|
94
123
|
if (values.base) config.git = { base: values.base };
|
|
95
124
|
// Opt-in (design decision 61): asked once; without a terminal, nothing is allowed.
|
|
@@ -98,7 +127,7 @@ export async function init(ctx, argv) {
|
|
|
98
127
|
if (agentAllow) config.agent = { allow: RECOMMENDED_ALLOW };
|
|
99
128
|
writeJson(join(root, CONFIG_FILE), config);
|
|
100
129
|
const s = ctx.style;
|
|
101
|
-
for (const line of
|
|
130
|
+
for (const line of mark(s, ctx.kit, 'setting up this repository')) ctx.out(line);
|
|
102
131
|
ctx.out(`${s.bold('agjan init')}: ${CONFIG_FILE} (domains ${domains.join(', ')}; hosts ${hosts.join(', ')})`);
|
|
103
132
|
|
|
104
133
|
printResults(ctx, doSync(ctx, { force: false }));
|
|
@@ -200,6 +229,7 @@ function claudeTrust(root) {
|
|
|
200
229
|
|
|
201
230
|
/** agjan doctor: checks the environment and the project setup; exit 1 on any failure. */
|
|
202
231
|
export function doctor(ctx) {
|
|
232
|
+
for (const line of mark(ctx.style, ctx.kit, 'doctor: environment and project setup')) ctx.out(line);
|
|
203
233
|
const rows = [];
|
|
204
234
|
const ok = (what, detail = '') => rows.push(['ok', what, detail]);
|
|
205
235
|
const warn = (what, detail) => rows.push(['warn', what, detail]);
|
|
@@ -267,6 +297,7 @@ export function doctor(ctx) {
|
|
|
267
297
|
}
|
|
268
298
|
const allow = config.agent?.allow ?? [];
|
|
269
299
|
ok('agent allow list', allow.length ? `${allow.length} command(s) without a prompt: ${allow.join(', ')}` : 'none (the hosts ask for every command)');
|
|
300
|
+
ok('reviewer models', config.hosts.map((h) => `${h}: ${MODEL_TIERS.map((t) => `${t} ${agentModel(config, h, t) ?? 'session model'}`).join(', ')}`).join('; '));
|
|
270
301
|
ok('script edits', config.agent?.script_edits === 'allow' ? 'allowed (agent.script_edits)' : 'denied by the guard: agents edit files with their edit tool');
|
|
271
302
|
const ignored = git(root, ['check-ignore', '-q', '.agjan/x'], { allowFail: true }) !== null;
|
|
272
303
|
if (!ignored) warn('.gitignore', '.agjan/ is not ignored; run: npx agjan sync');
|
package/src/commands/status.mjs
CHANGED
|
@@ -7,7 +7,10 @@ import { fixRules, freshReview } from '../fix.mjs';
|
|
|
7
7
|
import { projectProblems } from '../baseline.mjs';
|
|
8
8
|
import { readFix } from './fix.mjs';
|
|
9
9
|
import { fixAttempts, reviewerFor, roundLimit, roundState } from '../review-policy.mjs';
|
|
10
|
-
import { pad, tone } from '../ui.mjs';
|
|
10
|
+
import { mark, markLine, pad, tone } from '../ui.mjs';
|
|
11
|
+
import { acTestFiles } from '../tests-map.mjs';
|
|
12
|
+
import { acResults, loadResults } from '../test-results.mjs';
|
|
13
|
+
import { runChecks } from './check.mjs';
|
|
11
14
|
|
|
12
15
|
/** One indented row: a label column, then the value. `next` and `blocks` stand out. */
|
|
13
16
|
function row(ctx, label, value) {
|
|
@@ -107,6 +110,44 @@ function describeRecordOnBase(ctx, unit) {
|
|
|
107
110
|
if (!merged) row(ctx, 'next', `start follow-up work on a branch (/agjan-${unit.kind === 'fix' ? 'fix' : 'map'})`);
|
|
108
111
|
}
|
|
109
112
|
|
|
113
|
+
/**
|
|
114
|
+
* The end of a feature's agent work (verified, CI check clean or not): a screen that says
|
|
115
|
+
* so unmistakably, what was met, what is open, and what the human does next (Gate 3).
|
|
116
|
+
* Colored with the agjan mark on a terminal; the same content as plain text for agents,
|
|
117
|
+
* who end /agjan-verify with it.
|
|
118
|
+
*/
|
|
119
|
+
function completion(ctx, feature, progress) {
|
|
120
|
+
const s = ctx.style;
|
|
121
|
+
const areaNames = [...new Set(progress.tasks.map((t) => t.areaName))];
|
|
122
|
+
const automated = feature.spec.parsed.acs.filter((ac) => ac.verification !== 'manual');
|
|
123
|
+
const manual = feature.spec.parsed.acs.filter((ac) => ac.verification === 'manual');
|
|
124
|
+
const loaded = loadResults(ctx.root, ctx.config, areaNames);
|
|
125
|
+
const results = loaded.files.length ? acResults(loaded, feature.key) : null;
|
|
126
|
+
const tests = acTestFiles(ctx.root, ctx.config, areaNames, feature.key);
|
|
127
|
+
const covered = automated.filter((ac) => (results ? results.get(ac.id)?.passed && !results.get(ac.id)?.failed : tests.has(ac.id))).length;
|
|
128
|
+
const { report } = runChecks(ctx, 'ci', feature.slug);
|
|
129
|
+
const open = feature.findings.filter((f) => f.status === 'open');
|
|
130
|
+
const blockers = open.filter((f) => f.severity === 'blocker').length;
|
|
131
|
+
const ok = (text) => `${s.teal('✔')} ${text}`;
|
|
132
|
+
const bad = (text) => `${s.red('✖')} ${text}`;
|
|
133
|
+
const lines = [
|
|
134
|
+
[ok(`tasks ${progress.tasks.length}/${progress.tasks.length}`), (covered === automated.length ? ok : bad)(`ACs ${covered}/${automated.length} ${results ? 'with passing tests' : 'with tests'}`),
|
|
135
|
+
report.errors ? bad(`check --ci: ${report.errors} error(s)`) : ok('check --ci clean')].join(' '),
|
|
136
|
+
[(blockers ? bad : ok)(`reviews ${feature.reviews.records.length}, ${blockers} blocker(s) open`), open.length - blockers ? `${s.gray('●')} ${open.length - blockers} note(s) open` : ok('no open notes')].join(' '),
|
|
137
|
+
];
|
|
138
|
+
if (manual.length) lines.push(`${s.violet('▸')} before merging, check by hand: ${manual.map((ac) => ac.id).join(', ')}`);
|
|
139
|
+
if (areaNames.includes('fiori')) lines.push(`${s.violet('▸')} before merging: open the app and try the changed screens`);
|
|
140
|
+
lines.push(`${s.violet('▸')} next: open the PR (description: npx agjan pr-summary), review it, merge it`);
|
|
141
|
+
ctx.out();
|
|
142
|
+
if (s.brand) {
|
|
143
|
+
const stars = `${s.teal('✦')} ${s.violet('✦')} ${s.teal('✦')}`;
|
|
144
|
+
for (const line of mark(s, ctx.kit, `${stars} ${s.bold(`${feature.key} is verified`)} ${stars}`, `${feature.slug} · ready for your review (Gate 3)`)) ctx.out(line);
|
|
145
|
+
} else {
|
|
146
|
+
ctx.out(`✔ ${feature.key} is verified: ${feature.slug} is ready for your review (Gate 3)`);
|
|
147
|
+
}
|
|
148
|
+
for (const line of lines) ctx.out(` ${line}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
110
151
|
function describe(ctx, feature, onBase = false) {
|
|
111
152
|
if (feature.kind !== 'feature') return describeRecord(ctx, feature, onBase);
|
|
112
153
|
if (onBase) return describeOnBase(ctx, feature);
|
|
@@ -134,6 +175,8 @@ function describe(ctx, feature, onBase = false) {
|
|
|
134
175
|
}
|
|
135
176
|
for (const d of progress.due) row(ctx, 'due', ctx.style.yellow(`review ${d.step} (${d.reason})`));
|
|
136
177
|
row(ctx, 'next', nextInBuild(ctx, feature, progress).replace('<KEY>', feature.key));
|
|
178
|
+
const verify = verifyState(ctx.root, ctx.config, feature);
|
|
179
|
+
if (progress.complete && progress.due.length === 0 && verify.state === 'current') completion(ctx, feature, progress);
|
|
137
180
|
} else {
|
|
138
181
|
// Spec and Design: either the gate is ready for the human, or what blocks it.
|
|
139
182
|
const gate = pendingGate(feature);
|
|
@@ -164,6 +207,7 @@ export function run(ctx, argv) {
|
|
|
164
207
|
const c = ctx.config;
|
|
165
208
|
const branches = c.git?.branch?.create === 'confirm' ? 'a human creates branches (npx agjan branch, name proposed by the agent)' : 'the agent creates branches with npx agjan branch';
|
|
166
209
|
const pattern = c.git?.branch?.pattern ? `, names matching ${c.git.branch.pattern}` : '';
|
|
210
|
+
for (const line of markLine(ctx.style, ctx.kit, 'status')) ctx.out(line);
|
|
167
211
|
ctx.out(ctx.style.gray(`settings: documents in '${c.language ?? 'en'}' (headings in English); reviews up to ${roundLimit(c)} rounds; ${fixAttempts(c)} attempts for failing checks; ${branches}${pattern}`));
|
|
168
212
|
if (slugs.length === 0) {
|
|
169
213
|
ctx.out(values.all ? `no features in ${FEATURES_DIR}` : 'no changed feature on this branch (agjan status --all lists every feature)');
|
package/src/config.mjs
CHANGED
|
@@ -12,6 +12,20 @@ const KIT_DIR = new URL('../kit/', import.meta.url);
|
|
|
12
12
|
*/
|
|
13
13
|
export const RECOMMENDED_ALLOW = ['npx agjan', 'npm test', 'git status', 'git diff', 'git log', 'git add', 'git commit'];
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Reviewer models (`models.<host>.<tier>`). "session" means the reviewer agent runs on the
|
|
17
|
+
* model of the session that starts it: no model is written into the agent file. `init`
|
|
18
|
+
* writes this default visibly for every host, so users notice it and can change it.
|
|
19
|
+
*/
|
|
20
|
+
export const SESSION_MODEL = 'session';
|
|
21
|
+
export const MODEL_TIERS = ['balanced', 'deep'];
|
|
22
|
+
|
|
23
|
+
/** The model to write into an agent file, or undefined for the session's model. */
|
|
24
|
+
export function agentModel(config, host, tier) {
|
|
25
|
+
const value = config.models?.[host]?.[tier] ?? config.models?.[host]?.balanced;
|
|
26
|
+
return value && value !== SESSION_MODEL ? value : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
15
29
|
/** Package defaults. Domain defaults and project overrides are layered on top. */
|
|
16
30
|
const DEFAULTS = {
|
|
17
31
|
domains: ['btp'],
|
package/src/log.mjs
CHANGED
|
@@ -14,10 +14,22 @@ export const EVENTS = [
|
|
|
14
14
|
'review-recorded',
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
+
let listener = null;
|
|
18
|
+
|
|
19
|
+
/** Called after every appended event (the CLI regenerates the progress pages with it). */
|
|
20
|
+
export function onEvent(fn) {
|
|
21
|
+
listener = fn;
|
|
22
|
+
}
|
|
23
|
+
|
|
17
24
|
/** Appends one event to the feature's log.jsonl. The time is always set by the script. */
|
|
18
25
|
export function appendLog(featureDir, at, event, fields = {}) {
|
|
19
26
|
const entry = { at_utc: at, event, ...fields };
|
|
20
27
|
appendFileSync(join(featureDir, LOG_FILE), `${JSON.stringify(entry)}\n`);
|
|
28
|
+
try {
|
|
29
|
+
listener?.(featureDir);
|
|
30
|
+
} catch {
|
|
31
|
+
// the progress pages never break the command that recorded the event
|
|
32
|
+
}
|
|
21
33
|
return entry;
|
|
22
34
|
}
|
|
23
35
|
|
package/src/mcp.mjs
CHANGED
|
@@ -19,6 +19,11 @@ const FINDING_SCHEMA = {
|
|
|
19
19
|
line: { type: 'integer', minimum: 1 },
|
|
20
20
|
issue: { type: 'string' },
|
|
21
21
|
suggestion: { type: 'string' },
|
|
22
|
+
evidence: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
description:
|
|
25
|
+
'Where the claim is confirmed: a skill reference (path and section) or project file. Required when the finding says an API, annotation or syntax is wrong.',
|
|
26
|
+
},
|
|
22
27
|
},
|
|
23
28
|
required: ['severity', 'issue'],
|
|
24
29
|
additionalProperties: false,
|