agjan 0.0.5 → 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 +23 -1
- 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/reviews.schema.json +2 -1
- 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 +3 -2
- package/src/commands/status.mjs +45 -1
- 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
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
|
@@ -14,7 +14,7 @@ import { hookStatus, installHook } from '../hook.mjs';
|
|
|
14
14
|
import { GUARD } from '../adapters/copilot.mjs';
|
|
15
15
|
import { git, mergeBase, resolveBase } from '../git.mjs';
|
|
16
16
|
import { AgjanError, UsageError } from '../errors.mjs';
|
|
17
|
-
import {
|
|
17
|
+
import { mark, pad, tone, verdictColor } from '../ui.mjs';
|
|
18
18
|
|
|
19
19
|
const CI_FILE = '.github/workflows/agjan.yml';
|
|
20
20
|
const CI_TEMPLATE = new URL('../../kit/templates/agjan-ci.yml', import.meta.url);
|
|
@@ -127,7 +127,7 @@ export async function init(ctx, argv) {
|
|
|
127
127
|
if (agentAllow) config.agent = { allow: RECOMMENDED_ALLOW };
|
|
128
128
|
writeJson(join(root, CONFIG_FILE), config);
|
|
129
129
|
const s = ctx.style;
|
|
130
|
-
for (const line of
|
|
130
|
+
for (const line of mark(s, ctx.kit, 'setting up this repository')) ctx.out(line);
|
|
131
131
|
ctx.out(`${s.bold('agjan init')}: ${CONFIG_FILE} (domains ${domains.join(', ')}; hosts ${hosts.join(', ')})`);
|
|
132
132
|
|
|
133
133
|
printResults(ctx, doSync(ctx, { force: false }));
|
|
@@ -229,6 +229,7 @@ function claudeTrust(root) {
|
|
|
229
229
|
|
|
230
230
|
/** agjan doctor: checks the environment and the project setup; exit 1 on any failure. */
|
|
231
231
|
export function doctor(ctx) {
|
|
232
|
+
for (const line of mark(ctx.style, ctx.kit, 'doctor: environment and project setup')) ctx.out(line);
|
|
232
233
|
const rows = [];
|
|
233
234
|
const ok = (what, detail = '') => rows.push(['ok', what, detail]);
|
|
234
235
|
const warn = (what, detail) => rows.push(['warn', what, detail]);
|
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/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,
|