agjan 0.0.6 โ 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.
- package/docs/guide.md +20 -7
- package/kit/hooks/guard.mjs +124 -15
- package/kit/skills/agjan-verify/SKILL.md +9 -6
- package/kit/skills/cap-developer/SKILL.md +4 -0
- package/kit/skills/cap-developer/references/handlers.md +61 -4
- package/kit/skills/cap-developer/references/modeling.md +33 -1
- package/kit/skills/cap-developer/references/project-setup.md +87 -0
- package/kit/skills/cap-developer/references/services.md +32 -1
- package/kit/skills/cap-developer/references/testing.md +46 -14
- package/kit/skills/cap-developer/references/validation-security.md +66 -2
- package/kit/skills/fiori-developer/SKILL.md +1 -0
- package/kit/skills/fiori-developer/references/app-setup.md +127 -0
- package/kit/skills/fiori-developer/references/elements.md +109 -11
- package/kit/skills/fiori-developer/references/ui5-basics.md +3 -2
- package/kit/templates/progress.html +14 -9
- package/kit/templates/project.md +5 -0
- package/package.json +1 -1
- package/src/adapters/claude-code.mjs +16 -12
- package/src/commands/setup.mjs +116 -23
- package/src/commands/status.mjs +36 -10
- package/src/plan.mjs +8 -4
- package/src/progress-view.mjs +32 -11
- package/src/review.mjs +1 -1
- package/src/terminal.mjs +5 -3
package/src/commands/setup.mjs
CHANGED
|
@@ -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
|
-
|
|
74
|
-
|
|
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
|
-
|
|
130
|
-
for (const line of mark(s, ctx.kit, 'setting up this repository')) 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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -263,7 +350,9 @@ export function doctor(ctx) {
|
|
|
263
350
|
else ok('local install', local.version);
|
|
264
351
|
|
|
265
352
|
const base = resolveBase(root, config.git?.base);
|
|
266
|
-
|
|
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}`);
|
|
267
356
|
else if (!mergeBase(root, base)) warn('base branch', `${base} has no common history with HEAD (fetch it?)`);
|
|
268
357
|
else ok('base branch', base);
|
|
269
358
|
|
|
@@ -298,7 +387,11 @@ export function doctor(ctx) {
|
|
|
298
387
|
const allow = config.agent?.allow ?? [];
|
|
299
388
|
ok('agent allow list', allow.length ? `${allow.length} command(s) without a prompt: ${allow.join(', ')}` : 'none (the hosts ask for every command)');
|
|
300
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}` : ''}`);
|
|
301
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"');
|
|
302
395
|
const ignored = git(root, ['check-ignore', '-q', '.agjan/x'], { allowFail: true }) !== null;
|
|
303
396
|
if (!ignored) warn('.gitignore', '.agjan/ is not ignored; run: npx agjan sync');
|
|
304
397
|
}
|
package/src/commands/status.mjs
CHANGED
|
@@ -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';
|
|
@@ -11,6 +11,8 @@ import { mark, markLine, pad, tone } from '../ui.mjs';
|
|
|
11
11
|
import { acTestFiles } from '../tests-map.mjs';
|
|
12
12
|
import { acResults, loadResults } from '../test-results.mjs';
|
|
13
13
|
import { runChecks } from './check.mjs';
|
|
14
|
+
import { readLog } from '../log.mjs';
|
|
15
|
+
import { optionalSteps } from '../progress-view.mjs';
|
|
14
16
|
|
|
15
17
|
/** One indented row: a label column, then the value. `next` and `blocks` stand out. */
|
|
16
18
|
function row(ctx, label, value) {
|
|
@@ -43,13 +45,21 @@ function gateStep(feature) {
|
|
|
43
45
|
|
|
44
46
|
/** The next action in Build: a due review first, then the next task, then Verify, then the PR. */
|
|
45
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
|
+
}
|
|
46
56
|
if (progress.due.length) return reviewNext(ctx, feature, progress.due[0].step);
|
|
47
57
|
if (progress.next) return `task ${progress.next.id}: ${progress.next.title} (commit as '<KEY>-${progress.next.id}: โฆ')`;
|
|
48
58
|
const { state, record } = verifyState(ctx.root, ctx.config, feature);
|
|
49
59
|
if (state === 'blocked') return `the verify review ${record.id} is blocked: resolve its findings, then /agjan-verify again`;
|
|
50
60
|
if (state === 'stale') return `files changed after the verify review ${record.id}: /agjan-verify again`;
|
|
51
|
-
if (state === 'current') return `${ctx.style.green('
|
|
52
|
-
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';
|
|
53
63
|
}
|
|
54
64
|
|
|
55
65
|
/** "2 open, 1 blocker(s)", red when a blocker is open. */
|
|
@@ -135,17 +145,17 @@ function completion(ctx, feature, progress) {
|
|
|
135
145
|
report.errors ? bad(`check --ci: ${report.errors} error(s)`) : ok('check --ci clean')].join(' '),
|
|
136
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(' '),
|
|
137
147
|
];
|
|
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
148
|
ctx.out();
|
|
142
149
|
if (s.brand) {
|
|
143
150
|
const stars = `${s.teal('โฆ')} ${s.violet('โฆ')} ${s.teal('โฆ')}`;
|
|
144
|
-
for (const line of mark(s, ctx.kit, `${stars} ${s.bold(`${feature.key} is
|
|
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);
|
|
145
152
|
} else {
|
|
146
|
-
ctx.out(`โ ${feature.key} is
|
|
153
|
+
ctx.out(`โ ${feature.key} is done: development finished and verified (${feature.slug})`);
|
|
147
154
|
}
|
|
148
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}`);
|
|
149
159
|
}
|
|
150
160
|
|
|
151
161
|
function describe(ctx, feature, onBase = false) {
|
|
@@ -193,10 +203,26 @@ function describe(ctx, feature, onBase = false) {
|
|
|
193
203
|
}
|
|
194
204
|
}
|
|
195
205
|
|
|
196
|
-
/**
|
|
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] */
|
|
197
222
|
export function run(ctx, argv) {
|
|
198
|
-
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' } } });
|
|
199
224
|
const root = ctx.root;
|
|
225
|
+
if (values.done) return done(ctx, selectFeature(root, ctx.config, values.feature));
|
|
200
226
|
let slugs;
|
|
201
227
|
if (values.feature) {
|
|
202
228
|
if (!listFeatures(root).includes(values.feature)) throw new UsageError(`no feature '${values.feature}'`);
|
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
|
-
|
|
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
|
|
34
|
+
for (const host of hosts) {
|
|
31
35
|
const adapter = ADAPTERS[host];
|
|
32
36
|
if (adapter) items.push(...adapter.plan(config, skills));
|
|
33
37
|
}
|
package/src/progress-view.mjs
CHANGED
|
@@ -72,25 +72,46 @@ function stageOf(ctx, unit, onBase, extra) {
|
|
|
72
72
|
return { names, at: 0, turn: 'agent', now: unit.kind === 'fix' ? 'making the change' : 'writing docs/agjan/project.md' };
|
|
73
73
|
}
|
|
74
74
|
const mode = unit.design?.parsed.mode;
|
|
75
|
-
const names = ['Spec', mode === 'light' ? 'Design (light)' : 'Design', 'Build', 'Verify', onBase ? 'Merged' : '
|
|
75
|
+
const names = ['Spec', mode === 'light' ? 'Design (light)' : 'Design', 'Build', 'Verify', onBase ? 'Merged' : 'Done'];
|
|
76
76
|
const events = readLog(unit.dir);
|
|
77
77
|
const lastGate = events.filter((e) => ['gate-requested', 'approved', 'rejected'].includes(e.event)).at(-1);
|
|
78
78
|
const waiting = lastGate?.event === 'gate-requested';
|
|
79
|
+
// A step runs once the skill logged its start after the approval it builds on; until then
|
|
80
|
+
// the agent has stopped and the human starts the next skill (design decision 70).
|
|
81
|
+
const startedSince = (stage, at) => events.some((e) => e.event === 'step' && e.stage === stage && (!at || e.at_utc >= at));
|
|
82
|
+
const lastStep = events.filter((e) => e.event === 'step').at(-1);
|
|
79
83
|
if (unit.stage === 'spec') {
|
|
80
84
|
return { names, at: 0, turn: waiting ? 'you' : 'agent', now: waiting ? `approve ${lastGate.gate} in a terminal (npx agjan approve ${lastGate.gate})` : 'writing and reviewing the spec' };
|
|
81
85
|
}
|
|
82
86
|
if (unit.stage === 'design') {
|
|
83
|
-
return { names, at: 1, turn:
|
|
87
|
+
if (waiting) return { names, at: 1, turn: 'you', now: 'approve the design in a terminal (npx agjan approve design)' };
|
|
88
|
+
if (!startedSince('design', unit.approvals.approvals.spec?.at_utc)) return { names, at: 1, turn: 'you', now: 'start the design: /agjan-design' };
|
|
89
|
+
return { names, at: 1, turn: 'agent', now: 'writing and reviewing the design' };
|
|
84
90
|
}
|
|
85
91
|
const pending = unit.amendments.filter((a) => a.status === 'pending');
|
|
92
|
+
const verified = progress.complete && progress.due.length === 0 && verify.state === 'current';
|
|
86
93
|
if (onBase && progress.complete && verify.record && !stillBlocked(unit, verify.record)) return { names, at: 5, turn: 'merged', now: 'merged' };
|
|
94
|
+
if (verified) return { names, at: 5, turn: 'done', now: 'development finished and verified' };
|
|
87
95
|
if (pending.length) return { names, at: 2, turn: 'you', now: `approve amendment ${pending[0].id} (npx agjan approve amendment ${pending[0].id})` };
|
|
88
|
-
|
|
89
|
-
if (progress.
|
|
90
|
-
|
|
96
|
+
const building = startedSince('build', unit.approvals.approvals.design?.at_utc);
|
|
97
|
+
if (!progress.complete || progress.due.length) {
|
|
98
|
+
if (!building) return { names, at: 2, turn: 'you', now: 'start the build: /agjan-build' };
|
|
99
|
+
return { names, at: 2, turn: 'agent', now: progress.next ? `task ${progress.next.id}: ${progress.next.title}` : `review ${progress.due[0].step}` };
|
|
100
|
+
}
|
|
101
|
+
if (lastStep?.stage !== 'verify') return { names, at: 3, turn: 'you', now: 'start the verification: /agjan-verify' };
|
|
91
102
|
return { names, at: 3, turn: 'agent', now: verify.state === 'none' ? 'verify' : `verify (${verify.state})` };
|
|
92
103
|
}
|
|
93
104
|
|
|
105
|
+
/** What the human may do after "done" (design decision 70): all of it optional. */
|
|
106
|
+
export function optionalSteps(root, unit, acs) {
|
|
107
|
+
const steps = [];
|
|
108
|
+
const project = readFileSyncSafe(join(root, FEATURES_DIR, 'project.md'));
|
|
109
|
+
steps.push(/^## Run locally\s*$/m.test(project) ? 'try it locally: docs/agjan/project.md, section "Run locally" (start command, URL, users)' : 'try it locally');
|
|
110
|
+
if (acs?.manual.length) steps.push(`check by hand: ${acs.manual.join(', ')}`);
|
|
111
|
+
steps.push('open a pull request (ask the agent: "open the PR"), review it, merge it');
|
|
112
|
+
return steps;
|
|
113
|
+
}
|
|
114
|
+
|
|
94
115
|
/** The data of one unit for the progress pages. */
|
|
95
116
|
export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {}) {
|
|
96
117
|
const unit = loadFeature(ctx.root, slug);
|
|
@@ -108,12 +129,10 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {})
|
|
|
108
129
|
const last = times.length ? Math.max(...times) : now;
|
|
109
130
|
// An open step runs until now only while the agent works; when it is a human's turn,
|
|
110
131
|
// the agent's work ended with the last activity and the rest is waiting.
|
|
111
|
-
const end = stage.turn === 'merged' ? last : Math.max(last, now);
|
|
132
|
+
const end = stage.turn === 'merged' || stage.turn === 'done' ? last : Math.max(last, now);
|
|
112
133
|
const list = spans(events, stage.turn === 'agent' ? end : last).map((s) => (s.kind === 'gate' && s.open ? { ...s, to: end } : s));
|
|
113
134
|
const steps = list.filter((s) => s.kind === 'step');
|
|
114
135
|
const gates = list.filter((s) => s.kind === 'gate');
|
|
115
|
-
// Gate 3 (review and merge) has no event of its own: the wait since the verified state.
|
|
116
|
-
if (isFeature && stage.turn === 'you' && stage.at === 4) gates.push({ kind: 'gate', label: 'gate Gate 3', from: last, to: end, open: true });
|
|
117
136
|
|
|
118
137
|
const host = unit.reviews.records.find((r) => r.reviewer?.host)?.reviewer.host ?? events.find((e) => e.host)?.host ?? null;
|
|
119
138
|
const reviews = unit.reviews.records.map((r) => ({
|
|
@@ -217,6 +236,7 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {})
|
|
|
217
236
|
at: stage.at,
|
|
218
237
|
turn: stage.turn,
|
|
219
238
|
now: stage.now,
|
|
239
|
+
optional: stage.turn === 'done' ? optionalSteps(ctx.root, unit, acs) : [],
|
|
220
240
|
start: iso(start),
|
|
221
241
|
end: iso(end),
|
|
222
242
|
last: iso(last),
|
|
@@ -257,14 +277,14 @@ export function projectModels(ctx, { now = Date.now() } = {}) {
|
|
|
257
277
|
// A damaged unit must not stop the pages; check reports it.
|
|
258
278
|
}
|
|
259
279
|
}
|
|
260
|
-
const order = { you: 0, agent: 1,
|
|
280
|
+
const order = { you: 0, agent: 1, done: 2, idle: 3, merged: 4 };
|
|
261
281
|
return models.sort((a, b) => order[a.turn] - order[b.turn] || b.last.localeCompare(a.last));
|
|
262
282
|
}
|
|
263
283
|
|
|
264
284
|
// ---------------------------------------------------------------- Markdown
|
|
265
285
|
|
|
266
286
|
const VERDICT_MD = { pass: 'โ
pass', 'pass-with-notes': '๐ก notes', blocked: 'โ blocked' };
|
|
267
|
-
const TURN_MD = { you: '๐ค your turn', agent: '๐ค agent working', merged: 'โ
merged', idle: 'โธ idle' };
|
|
287
|
+
const TURN_MD = { you: '๐ค your turn', agent: '๐ค agent working', done: 'โ
done', merged: 'โ
merged', idle: 'โธ idle' };
|
|
268
288
|
|
|
269
289
|
function duration(ms) {
|
|
270
290
|
if (ms < 60_000) return `${Math.max(Math.round(ms / 1000), 0)} s`;
|
|
@@ -278,7 +298,7 @@ const hm = (at) => `${at.slice(5, 10)} ${at.slice(11, 16)}`;
|
|
|
278
298
|
|
|
279
299
|
function track(model) {
|
|
280
300
|
return model.stages
|
|
281
|
-
.map((name, i) => (i < model.at ? `โ
${name}` : i === model.at ? (model.turn === 'you' ? `โณ **${name}**` : `๐ **${name}**`) : `โฌ ${name}`))
|
|
301
|
+
.map((name, i) => (i < model.at || model.turn === 'done' || model.turn === 'merged' ? `โ
${name}` : i === model.at ? (model.turn === 'you' ? `โณ **${name}**` : `๐ **${name}**`) : `โฌ ${name}`))
|
|
282
302
|
.join(' โโ ');
|
|
283
303
|
}
|
|
284
304
|
|
|
@@ -314,6 +334,7 @@ export function unitMarkdown(model, { generatedAt }) {
|
|
|
314
334
|
out.push(`> ${md(model.title)}`, '');
|
|
315
335
|
out.push(track(model), '');
|
|
316
336
|
out.push(`**Now:** ${TURN_MD[model.turn]} ยท ${md(model.now)}`, '');
|
|
337
|
+
if (model.optional.length) out.push('Optional next steps:', '', ...model.optional.map((step) => `- ${md(step)}`), '');
|
|
317
338
|
const s = model.stats;
|
|
318
339
|
out.push('| | |', '|---|---|');
|
|
319
340
|
out.push(`| Time | ${duration(s.activeMs)} agent work ยท ${duration(s.waitingMs)} waiting for a human |`);
|
package/src/review.mjs
CHANGED
|
@@ -143,7 +143,7 @@ const CHECKLISTS = {
|
|
|
143
143
|
build: 'Each covered AC is met by the diff. Tests exist and carry the AC id in their names. 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. 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.',
|
|
144
144
|
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).',
|
|
145
145
|
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.',
|
|
146
|
-
verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. 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. Do not re-review each task.',
|
|
146
|
+
verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. 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.',
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
/**
|
package/src/terminal.mjs
CHANGED
|
@@ -62,12 +62,14 @@ export function confirmOnTerminal(summary, expected) {
|
|
|
62
62
|
* Asks a yes/no question on the controlling terminal. Returns true or false, or null when
|
|
63
63
|
* there is no terminal (a script, CI or an agent): the caller then keeps its default.
|
|
64
64
|
*/
|
|
65
|
-
export function askOnTerminal(question) {
|
|
65
|
+
export function askOnTerminal(question, { defaultYes = false } = {}) {
|
|
66
66
|
const tty = openTerminal();
|
|
67
67
|
if (!tty) return null;
|
|
68
68
|
try {
|
|
69
|
-
writeSync(tty.output, `${question} [y/N] `);
|
|
70
|
-
|
|
69
|
+
writeSync(tty.output, `${question} ${defaultYes ? '[Y/n]' : '[y/N]'} `);
|
|
70
|
+
const answer = readLine(tty.input).trim();
|
|
71
|
+
if (answer === '') return defaultYes;
|
|
72
|
+
return /^y(es)?$/i.test(answer);
|
|
71
73
|
} finally {
|
|
72
74
|
closeSync(tty.input);
|
|
73
75
|
if (tty.output !== tty.input) closeSync(tty.output);
|