agjan 0.0.5 → 0.0.7

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.
Files changed (39) hide show
  1. package/docs/guide.md +42 -7
  2. package/kit/hooks/guard.mjs +124 -15
  3. package/kit/skills/agjan-build/SKILL.md +1 -1
  4. package/kit/skills/agjan-design/SKILL.md +4 -3
  5. package/kit/skills/agjan-fix/SKILL.md +1 -1
  6. package/kit/skills/agjan-map/SKILL.md +1 -1
  7. package/kit/skills/agjan-spec/SKILL.md +4 -1
  8. package/kit/skills/agjan-verify/SKILL.md +10 -4
  9. package/kit/skills/cap-developer/SKILL.md +4 -0
  10. package/kit/skills/cap-developer/references/handlers.md +61 -4
  11. package/kit/skills/cap-developer/references/modeling.md +33 -1
  12. package/kit/skills/cap-developer/references/project-setup.md +87 -0
  13. package/kit/skills/cap-developer/references/services.md +32 -1
  14. package/kit/skills/cap-developer/references/testing.md +46 -14
  15. package/kit/skills/cap-developer/references/validation-security.md +66 -2
  16. package/kit/skills/fiori-developer/SKILL.md +1 -0
  17. package/kit/skills/fiori-developer/references/app-setup.md +127 -0
  18. package/kit/skills/fiori-developer/references/elements.md +110 -5
  19. package/kit/skills/fiori-developer/references/ui5-basics.md +3 -2
  20. package/kit/skills/solution-reviewer/SKILL.md +13 -3
  21. package/kit/templates/agents-block.md +5 -1
  22. package/kit/templates/progress.html +343 -0
  23. package/kit/templates/project.md +5 -0
  24. package/package.json +1 -1
  25. package/schemas/reviews.schema.json +2 -1
  26. package/src/adapters/claude-code.mjs +16 -12
  27. package/src/cli.mjs +12 -4
  28. package/src/commands/check.mjs +3 -1
  29. package/src/commands/gates.mjs +2 -2
  30. package/src/commands/progress.mjs +40 -0
  31. package/src/commands/setup.mjs +118 -24
  32. package/src/commands/status.mjs +76 -6
  33. package/src/log.mjs +12 -0
  34. package/src/mcp.mjs +5 -0
  35. package/src/plan.mjs +8 -4
  36. package/src/progress-view.mjs +455 -0
  37. package/src/review.mjs +26 -13
  38. package/src/terminal.mjs +5 -3
  39. package/src/ui.mjs +26 -22
@@ -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 { banner, pad, tone, verdictColor } from '../ui.mjs';
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);
@@ -63,6 +63,17 @@ function missingModels(raw, hosts, { existing }) {
63
63
  return added;
64
64
  }
65
65
 
66
+ /**
67
+ * Settings that decide what agents may do without asking, written visibly into an
68
+ * existing configuration that lacks them, with the behavior it had (design decision 69).
69
+ */
70
+ function missingSettings(raw) {
71
+ const out = [];
72
+ if (raw.git?.branch?.create === undefined) out.push('git.branch.create');
73
+ if (raw.agent?.allow === undefined || raw.agent?.allow_edits === undefined) out.push('agent');
74
+ return out;
75
+ }
76
+
66
77
  /** Writes the managed files for the current configuration and updates the recorded kit version. */
67
78
  function doSync(ctx, { force }) {
68
79
  const config = loadConfig(ctx.root);
@@ -70,14 +81,20 @@ function doSync(ctx, { force }) {
70
81
  const file = join(ctx.root, CONFIG_FILE);
71
82
  const raw = readJson(file) ?? {};
72
83
  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 } });
84
+ const visible = missingSettings(raw);
85
+ if (Object.keys(added).length || visible.length) {
86
+ const next = { ...raw, models: { ...(raw.models ?? {}), ...added } };
87
+ if (visible.includes('git.branch.create')) next.git = { ...(raw.git ?? {}), branch: { ...(raw.git?.branch ?? {}), create: 'agent' } };
88
+ if (visible.includes('agent')) next.agent = { allow: raw.agent?.allow ?? [], allow_edits: raw.agent?.allow_edits ?? false, ...(raw.agent ?? {}) };
89
+ writeJson(file, next);
75
90
  config.models = { ...(config.models ?? {}), ...added };
76
91
  }
77
92
  const results = applyPlan(ctx.root, buildPlan(config), { kit: ctx.kit, force });
78
93
  for (const [host, tiers] of Object.entries(added)) {
79
94
  results.push({ path: CONFIG_FILE, action: `models.${host}: ${MODEL_TIERS.map((t) => `${t}=${tiers[t]}`).join(', ')}` });
80
95
  }
96
+ if (visible.includes('git.branch.create')) results.push({ path: CONFIG_FILE, action: 'git.branch.create: agent' });
97
+ if (visible.includes('agent')) results.push({ path: CONFIG_FILE, action: 'agent: allow, allow_edits' });
81
98
  const current = readJson(file) ?? {};
82
99
  if (current.kit !== ctx.kit) {
83
100
  writeJson(file, { ...current, kit: ctx.kit });
@@ -86,9 +103,59 @@ function doSync(ctx, { force }) {
86
103
  return results;
87
104
  }
88
105
 
106
+ /** Asks a yes/no question; null without a terminal (scripts, CI, agents). */
107
+ function ask(ctx, question, options) {
108
+ return ctx.ask(question, options);
109
+ }
110
+
111
+ /** Asks for one line with a prefilled answer; '' without a terminal. */
112
+ async function askLine(ctx, prompt, initial = '') {
113
+ try {
114
+ return String((await ctx.edit(prompt, initial)) ?? '').trim();
115
+ } catch {
116
+ return '';
117
+ }
118
+ }
119
+
120
+ /** The branch pattern: asked until it is a valid regular expression (or left empty). */
121
+ async function askPattern(ctx) {
122
+ for (let i = 0; i < 3; i++) {
123
+ const answer = await askLine(ctx, 'Branch name pattern (regular expression, Enter for none): ');
124
+ if (!answer) return null;
125
+ try {
126
+ new RegExp(answer);
127
+ return answer;
128
+ } catch (error) {
129
+ ctx.out(ctx.style.yellow(`not a valid regular expression: ${error.message}`));
130
+ }
131
+ }
132
+ return null;
133
+ }
134
+
135
+ /** The next steps after init, for the configured hosts (design decision 69). */
136
+ function nextSteps(ctx, hosts, firstCommit) {
137
+ const s = ctx.style;
138
+ const steps = [
139
+ firstCommit
140
+ ? `Commit the setup: ${s.cyan('git add -A && git commit -m "chore: set up agjan"')}`
141
+ : `Commit the setup on a branch of its own and merge it with a PR: ${s.cyan('git add -A && git commit -m "chore: set up agjan"')}`,
142
+ ];
143
+ if (hosts.includes('claude-code')) {
144
+ steps.push("Open this folder once in Claude Code and trust it: the reviewer's agjan tools load only in trusted folders.");
145
+ }
146
+ if (hosts.includes('copilot')) {
147
+ steps.push(`Start ${s.cyan('copilot')} in this folder and trust it. Without agent.allow_edits, answer the first file edit prompt with "don't ask again for file operations", or start ${s.cyan('copilot --allow-tool write')}.`);
148
+ }
149
+ steps.push('Protect the base branch: require the "agjan-check" status check and a review.');
150
+ steps.push(['Add this to .github/CODEOWNERS (replace @<owner>):', ...CODEOWNERS.split('\n')].join('\n '));
151
+ steps.push(`Run: ${s.cyan('npx agjan doctor')}`);
152
+ return ['', s.bold('Next steps:'), ...steps.map((text, i) => ` ${i + 1}. ${text}`)];
153
+ }
154
+
89
155
  /**
90
156
  * agjan init [--domains btp] [--hosts claude-code] [--language en] [--base <ref>] [--no-hook] [--no-ci]
91
- * [--prepare] [--agent-allow | --no-agent-allow]
157
+ * [--prepare] [--agent-allow | --no-agent-allow] [--agent-allow-edits | --no-agent-allow-edits]
158
+ * [--branch-create agent|confirm] [--branch-pattern <regex>]
92
159
  */
93
160
  export async function init(ctx, argv) {
94
161
  const { values } = parseArgs({
@@ -103,6 +170,10 @@ export async function init(ctx, argv) {
103
170
  prepare: { type: 'boolean' },
104
171
  'agent-allow': { type: 'boolean' },
105
172
  'no-agent-allow': { type: 'boolean' },
173
+ 'agent-allow-edits': { type: 'boolean' },
174
+ 'no-agent-allow-edits': { type: 'boolean' },
175
+ 'branch-create': { type: 'string' },
176
+ 'branch-pattern': { type: 'string' },
106
177
  },
107
178
  });
108
179
  const root = ctx.root;
@@ -111,6 +182,32 @@ export async function init(ctx, argv) {
111
182
  for (const d of domains) loadDomain(d);
112
183
  const hosts = list(values.hosts) ?? ['claude-code'];
113
184
  for (const h of hosts) if (!ADAPTERS[h]) throw new UsageError(`host '${h}' is not supported in this version (supported: ${Object.keys(ADAPTERS).join(', ')})`);
185
+ if (values['branch-create'] && !['agent', 'confirm'].includes(values['branch-create'])) throw new UsageError('--branch-create must be agent or confirm');
186
+ if (values['branch-pattern']) {
187
+ try {
188
+ new RegExp(values['branch-pattern']);
189
+ } catch (error) {
190
+ throw new UsageError(`--branch-pattern is not a valid regular expression: ${error.message}`);
191
+ }
192
+ }
193
+
194
+ // The mark first, then the questions (design decision 69).
195
+ const s = ctx.style;
196
+ for (const line of mark(s, ctx.kit, 'setting up this repository')) ctx.out(line);
197
+
198
+ // Opt-in decisions, asked once; without a terminal the safe defaults apply. They are
199
+ // written visibly, defaults included, so the team sees and can change them.
200
+ const flag = (yes, no) => (values[yes] ? true : values[no] ? false : null);
201
+ const agentAllow = flag('agent-allow', 'no-agent-allow') ??
202
+ ask(ctx, `Let agents run these commands without a prompt: ${RECOMMENDED_ALLOW.join(', ')}?\n(agjan approve, accept and reject stay blocked; change agent.allow in ${CONFIG_FILE} later.)`) ?? false;
203
+ const allowEdits = flag('agent-allow-edits', 'no-agent-allow-edits') ??
204
+ ask(ctx, 'Let agents change files in this project without a prompt?\n(agjan records and policy files excluded; agjan checks the scope of every change.)') ?? false;
205
+ let branchCreate = values['branch-create'] ?? null;
206
+ if (!branchCreate) {
207
+ const own = ask(ctx, 'Should agents create branches themselves? (no: they propose a name, you create it with npx agjan branch)', { defaultYes: true });
208
+ branchCreate = own === false ? 'confirm' : 'agent';
209
+ }
210
+ const branchPattern = values['branch-pattern'] ?? (values['branch-create'] ? null : await askPattern(ctx));
114
211
 
115
212
  const config = {
116
213
  $schema: './node_modules/agjan/schemas/config.schema.json',
@@ -119,19 +216,17 @@ export async function init(ctx, argv) {
119
216
  hosts,
120
217
  language: values.language ?? 'en',
121
218
  models: missingModels({}, hosts, { existing: false }),
219
+ git: { ...(values.base ? { base: values.base } : {}), branch: { create: branchCreate, ...(branchPattern ? { pattern: branchPattern } : {}) } },
220
+ agent: { allow: agentAllow ? RECOMMENDED_ALLOW : [], allow_edits: allowEdits },
122
221
  };
123
- if (values.base) config.git = { base: values.base };
124
- // Opt-in (design decision 61): asked once; without a terminal, nothing is allowed.
125
- let agentAllow = values['agent-allow'] ? true : values['no-agent-allow'] ? false : null;
126
- agentAllow ??= ctx.ask(`Let agents run these commands without a prompt: ${RECOMMENDED_ALLOW.join(', ')}?\n(agjan approve, accept and reject stay blocked; edit agent.allow in ${CONFIG_FILE} later.)`) ?? false;
127
- if (agentAllow) config.agent = { allow: RECOMMENDED_ALLOW };
128
222
  writeJson(join(root, CONFIG_FILE), config);
129
- const s = ctx.style;
130
- for (const line of banner(s, ctx.kit)) ctx.out(line);
131
- ctx.out(`${s.bold('agjan init')}: ${CONFIG_FILE} (domains ${domains.join(', ')}; hosts ${hosts.join(', ')})`);
223
+ ctx.out('', `${s.bold('agjan init')}: ${CONFIG_FILE} (domains ${domains.join(', ')}; hosts ${hosts.join(', ')})`);
132
224
 
133
225
  printResults(ctx, doSync(ctx, { force: false }));
134
- ctx.out(` ${pad(agentAllow ? tone(s, 'created') : s.gray('none'), agentAllow ? 'created' : 'none', 14)} agent.allow${agentAllow ? ` (${RECOMMENDED_ALLOW.length} commands)` : ''}`);
226
+ const setting = (on, text) => ` ${pad(on ? tone(s, 'created') : s.gray('none'), on ? 'created' : 'none', 14)} ${text}`;
227
+ ctx.out(setting(agentAllow, `agent.allow${agentAllow ? ` (${RECOMMENDED_ALLOW.length} commands)` : ''}`));
228
+ ctx.out(setting(allowEdits, `agent.allow_edits${allowEdits ? ' (file changes without a prompt)' : ''}`));
229
+ ctx.out(` ${pad(tone(s, 'created'), 'created', 14)} git.branch: ${branchCreate === 'confirm' ? 'you create branches' : 'agents create branches'}${branchPattern ? `, pattern ${branchPattern}` : ''}`);
135
230
 
136
231
  if (!values['no-hook']) {
137
232
  const hook = installHook(root);
@@ -153,16 +248,8 @@ export async function init(ctx, argv) {
153
248
  if (!pkg?.devDependencies?.agjan && !pkg?.dependencies?.agjan) {
154
249
  ctx.out('', s.yellow('Pin agjan in this project so every developer and CI use the same version:'), ` ${s.cyan('npm install --save-dev agjan')}`);
155
250
  }
156
- ctx.out(
157
- '',
158
- s.bold('Next steps:'),
159
- ' 1. Open this folder once in Claude Code and trust it: the reviewer agent\'s',
160
- ' agjan MCP server loads only in trusted folders.',
161
- ' 2. Protect the base branch: require the "agjan-check" status check and a review.',
162
- ' 3. Add this to .github/CODEOWNERS (replace @<owner>):',
163
- ...CODEOWNERS.split('\n').map((l) => ` ${l}`),
164
- ` 4. Run: ${s.cyan('npx agjan doctor')}`,
165
- );
251
+ const firstCommit = git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true }) === null;
252
+ ctx.out(...nextSteps(ctx, hosts, firstCommit));
166
253
  return 0;
167
254
  }
168
255
 
@@ -229,6 +316,7 @@ function claudeTrust(root) {
229
316
 
230
317
  /** agjan doctor: checks the environment and the project setup; exit 1 on any failure. */
231
318
  export function doctor(ctx) {
319
+ for (const line of mark(ctx.style, ctx.kit, 'doctor: environment and project setup')) ctx.out(line);
232
320
  const rows = [];
233
321
  const ok = (what, detail = '') => rows.push(['ok', what, detail]);
234
322
  const warn = (what, detail) => rows.push(['warn', what, detail]);
@@ -262,7 +350,9 @@ export function doctor(ctx) {
262
350
  else ok('local install', local.version);
263
351
 
264
352
  const base = resolveBase(root, config.git?.base);
265
- if (!base) warn('base branch', `none found; set git.base in ${CONFIG_FILE}`);
353
+ const commits = git(root, ['rev-parse', '--verify', '--quiet', 'HEAD'], { allowFail: true }) !== null;
354
+ if (!commits) warn('base branch', 'no commits yet: commit the setup first (git add -A && git commit -m "chore: set up agjan"); main exists after that');
355
+ else if (!base) warn('base branch', `none found; set git.base in ${CONFIG_FILE}`);
266
356
  else if (!mergeBase(root, base)) warn('base branch', `${base} has no common history with HEAD (fetch it?)`);
267
357
  else ok('base branch', base);
268
358
 
@@ -297,7 +387,11 @@ export function doctor(ctx) {
297
387
  const allow = config.agent?.allow ?? [];
298
388
  ok('agent allow list', allow.length ? `${allow.length} command(s) without a prompt: ${allow.join(', ')}` : 'none (the hosts ask for every command)');
299
389
  ok('reviewer models', config.hosts.map((h) => `${h}: ${MODEL_TIERS.map((t) => `${t} ${agentModel(config, h, t) ?? 'session model'}`).join(', ')}`).join('; '));
390
+ ok('file edits', config.agent?.allow_edits === true ? 'without a prompt inside the project (agjan records denied, policy files ask)' : 'the host asks for every file change (agent.allow_edits)');
391
+ ok('branches', `${config.git?.branch?.create === 'confirm' ? 'you create them (npx agjan branch)' : 'agents create them (npx agjan branch)'}${config.git?.branch?.pattern ? `, pattern ${config.git.branch.pattern}` : ''}`);
300
392
  ok('script edits', config.agent?.script_edits === 'allow' ? 'allowed (agent.script_edits)' : 'denied by the guard: agents edit files with their edit tool');
393
+ const tracked = (git(root, ['ls-files', '--', 'node_modules'], { allowFail: true }) ?? '').trim();
394
+ if (tracked) warn('node_modules', 'is committed; remove it: git rm -r -q --cached node_modules && git commit -m "chore: stop tracking node_modules"');
301
395
  const ignored = git(root, ['check-ignore', '-q', '.agjan/x'], { allowFail: true }) !== null;
302
396
  if (!ignored) warn('.gitignore', '.agjan/ is not ignored; run: npx agjan sync');
303
397
  }
@@ -1,5 +1,5 @@
1
1
  import { parseArgs } from 'node:util';
2
- import { FEATURES_DIR, changedFeatures, listFeatures, loadFeature, stillBlocked } from '../feature.mjs';
2
+ import { FEATURES_DIR, changedFeatures, listFeatures, loadFeature, selectFeature, stillBlocked } from '../feature.mjs';
3
3
  import { UsageError } from '../errors.mjs';
4
4
  import { buildProgress, verifyState } from '../progress.mjs';
5
5
  import { gateReadiness, pendingGate } from './gates.mjs';
@@ -7,7 +7,12 @@ 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';
14
+ import { readLog } from '../log.mjs';
15
+ import { optionalSteps } from '../progress-view.mjs';
11
16
 
12
17
  /** One indented row: a label column, then the value. `next` and `blocks` stand out. */
13
18
  function row(ctx, label, value) {
@@ -40,13 +45,21 @@ function gateStep(feature) {
40
45
 
41
46
  /** The next action in Build: a due review first, then the next task, then Verify, then the PR. */
42
47
  function nextInBuild(ctx, feature, progress) {
48
+ // The same rule as the progress pages: a skill runs once it logged its start (decision 70).
49
+ const events = readLog(feature.dir);
50
+ const since = feature.approvals.approvals.design?.at_utc;
51
+ const building = events.some((e) => e.event === 'step' && e.stage === 'build' && (!since || e.at_utc >= since));
52
+ const lastStage = events.filter((e) => e.event === 'step').at(-1)?.stage;
53
+ if (!building && (progress.next || progress.due.length)) {
54
+ return `a human starts the build: /agjan-build${progress.next ? ` (first task ${progress.next.id}: ${progress.next.title})` : ''}`;
55
+ }
43
56
  if (progress.due.length) return reviewNext(ctx, feature, progress.due[0].step);
44
57
  if (progress.next) return `task ${progress.next.id}: ${progress.next.title} (commit as '<KEY>-${progress.next.id}: …')`;
45
58
  const { state, record } = verifyState(ctx.root, ctx.config, feature);
46
59
  if (state === 'blocked') return `the verify review ${record.id} is blocked: resolve its findings, then /agjan-verify again`;
47
60
  if (state === 'stale') return `files changed after the verify review ${record.id}: /agjan-verify again`;
48
- if (state === 'current') return `${ctx.style.green('verified')} (${record.id}): open the PR with 'npx agjan pr-summary' as its description; a human reviews and merges (Gate 3)`;
49
- return 'all tasks done and reviewed: /agjan-verify';
61
+ if (state === 'current') return `${ctx.style.green('done')}: development finished and verified (${record.id}); the next steps below are optional`;
62
+ return lastStage === 'verify' ? 'verify is running: /agjan-verify' : 'all tasks done and reviewed: a human starts the verification: /agjan-verify';
50
63
  }
51
64
 
52
65
  /** "2 open, 1 blocker(s)", red when a blocker is open. */
@@ -107,6 +120,44 @@ function describeRecordOnBase(ctx, unit) {
107
120
  if (!merged) row(ctx, 'next', `start follow-up work on a branch (/agjan-${unit.kind === 'fix' ? 'fix' : 'map'})`);
108
121
  }
109
122
 
123
+ /**
124
+ * The end of a feature's agent work (verified, CI check clean or not): a screen that says
125
+ * so unmistakably, what was met, what is open, and what the human does next (Gate 3).
126
+ * Colored with the agjan mark on a terminal; the same content as plain text for agents,
127
+ * who end /agjan-verify with it.
128
+ */
129
+ function completion(ctx, feature, progress) {
130
+ const s = ctx.style;
131
+ const areaNames = [...new Set(progress.tasks.map((t) => t.areaName))];
132
+ const automated = feature.spec.parsed.acs.filter((ac) => ac.verification !== 'manual');
133
+ const manual = feature.spec.parsed.acs.filter((ac) => ac.verification === 'manual');
134
+ const loaded = loadResults(ctx.root, ctx.config, areaNames);
135
+ const results = loaded.files.length ? acResults(loaded, feature.key) : null;
136
+ const tests = acTestFiles(ctx.root, ctx.config, areaNames, feature.key);
137
+ const covered = automated.filter((ac) => (results ? results.get(ac.id)?.passed && !results.get(ac.id)?.failed : tests.has(ac.id))).length;
138
+ const { report } = runChecks(ctx, 'ci', feature.slug);
139
+ const open = feature.findings.filter((f) => f.status === 'open');
140
+ const blockers = open.filter((f) => f.severity === 'blocker').length;
141
+ const ok = (text) => `${s.teal('✔')} ${text}`;
142
+ const bad = (text) => `${s.red('✖')} ${text}`;
143
+ const lines = [
144
+ [ok(`tasks ${progress.tasks.length}/${progress.tasks.length}`), (covered === automated.length ? ok : bad)(`ACs ${covered}/${automated.length} ${results ? 'with passing tests' : 'with tests'}`),
145
+ report.errors ? bad(`check --ci: ${report.errors} error(s)`) : ok('check --ci clean')].join(' '),
146
+ [(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(' '),
147
+ ];
148
+ ctx.out();
149
+ if (s.brand) {
150
+ const stars = `${s.teal('✦')} ${s.violet('✦')} ${s.teal('✦')}`;
151
+ for (const line of mark(s, ctx.kit, `${stars} ${s.bold(`${feature.key} is done`)} ${stars}`, `${feature.slug} · development finished and verified`)) ctx.out(line);
152
+ } else {
153
+ ctx.out(`✔ ${feature.key} is done: development finished and verified (${feature.slug})`);
154
+ }
155
+ for (const line of lines) ctx.out(` ${line}`);
156
+ ctx.out(` ${s.bold('Optional next steps:')}`);
157
+ const steps = optionalSteps(ctx.root, feature, { manual: manual.map((ac) => ac.id) });
158
+ for (const step of steps) ctx.out(` ${s.violet('▸')} ${step}`);
159
+ }
160
+
110
161
  function describe(ctx, feature, onBase = false) {
111
162
  if (feature.kind !== 'feature') return describeRecord(ctx, feature, onBase);
112
163
  if (onBase) return describeOnBase(ctx, feature);
@@ -134,6 +185,8 @@ function describe(ctx, feature, onBase = false) {
134
185
  }
135
186
  for (const d of progress.due) row(ctx, 'due', ctx.style.yellow(`review ${d.step} (${d.reason})`));
136
187
  row(ctx, 'next', nextInBuild(ctx, feature, progress).replace('<KEY>', feature.key));
188
+ const verify = verifyState(ctx.root, ctx.config, feature);
189
+ if (progress.complete && progress.due.length === 0 && verify.state === 'current') completion(ctx, feature, progress);
137
190
  } else {
138
191
  // Spec and Design: either the gate is ready for the human, or what blocks it.
139
192
  const gate = pendingGate(feature);
@@ -150,10 +203,26 @@ function describe(ctx, feature, onBase = false) {
150
203
  }
151
204
  }
152
205
 
153
- /** agjan status [--feature <slug> | --all] */
206
+ /**
207
+ * agjan status --done [--feature <slug>]: only the completion block of a verified feature,
208
+ * for the agent's final message (exit 1 with the next step while it is not done).
209
+ */
210
+ function done(ctx, slug) {
211
+ const feature = loadFeature(ctx.root, slug);
212
+ const progress = feature.kind === 'feature' && feature.stage === 'build' ? buildProgress(ctx.root, ctx.config, feature) : null;
213
+ if (progress?.complete && progress.due.length === 0 && verifyState(ctx.root, ctx.config, feature).state === 'current') {
214
+ completion(ctx, feature, progress);
215
+ return 0;
216
+ }
217
+ ctx.out(`${feature.key} is not done yet: ${progress ? nextInBuild(ctx, feature, progress).replace('<KEY>', feature.key) : `stage ${feature.stage}`}`);
218
+ return 1;
219
+ }
220
+
221
+ /** agjan status [--feature <slug> | --all | --done] */
154
222
  export function run(ctx, argv) {
155
- const { values } = parseArgs({ args: argv, options: { feature: { type: 'string' }, all: { type: 'boolean' } } });
223
+ const { values } = parseArgs({ args: argv, options: { feature: { type: 'string' }, all: { type: 'boolean' }, done: { type: 'boolean' } } });
156
224
  const root = ctx.root;
225
+ if (values.done) return done(ctx, selectFeature(root, ctx.config, values.feature));
157
226
  let slugs;
158
227
  if (values.feature) {
159
228
  if (!listFeatures(root).includes(values.feature)) throw new UsageError(`no feature '${values.feature}'`);
@@ -164,6 +233,7 @@ export function run(ctx, argv) {
164
233
  const c = ctx.config;
165
234
  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
235
  const pattern = c.git?.branch?.pattern ? `, names matching ${c.git.branch.pattern}` : '';
236
+ for (const line of markLine(ctx.style, ctx.kit, 'status')) ctx.out(line);
167
237
  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
238
  if (slugs.length === 0) {
169
239
  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,
package/src/plan.mjs CHANGED
@@ -21,13 +21,17 @@ function importsAgents(text) {
21
21
  export function buildPlan(config) {
22
22
  const skills = kitSkillFiles();
23
23
  const items = Object.entries(skills).map(([path, content]) => ({ kind: 'file', path: `${SKILLS_DIR}/${path}`, content }));
24
+ const hosts = config.hosts ?? [claudeCode.HOST];
25
+ items.push({ kind: 'block', path: 'AGENTS.md', style: 'md', content: AGENTS_BLOCK });
26
+ // Claude Code reads CLAUDE.md; Copilot reads AGENTS.md itself. The skills stay in
27
+ // .claude/skills/ for every host: both read them from there.
28
+ if (hosts.includes(claudeCode.HOST)) items.push({ kind: 'block', path: 'CLAUDE.md', style: 'md', content: '@AGENTS.md', skip: importsAgents });
24
29
  items.push(
25
- { kind: 'block', path: 'AGENTS.md', style: 'md', content: AGENTS_BLOCK },
26
- { kind: 'block', path: 'CLAUDE.md', style: 'md', content: '@AGENTS.md', skip: importsAgents },
27
30
  { kind: 'block', path: '.gitattributes', style: 'hash', content: 'docs/agjan/** text eol=lf\nagjan.lock.json text eol=lf' },
28
- { kind: 'block', path: '.gitignore', style: 'hash', content: '.agjan/' },
31
+ // node_modules too: a new project often has no .gitignore of its own (design decision 69).
32
+ { kind: 'block', path: '.gitignore', style: 'hash', content: '.agjan/\nnode_modules/' },
29
33
  );
30
- for (const host of config.hosts ?? [claudeCode.HOST]) {
34
+ for (const host of hosts) {
31
35
  const adapter = ADAPTERS[host];
32
36
  if (adapter) items.push(...adapter.plan(config, skills));
33
37
  }