agjan 0.0.9 → 0.0.11

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 (32) hide show
  1. package/docs/guide.md +47 -8
  2. package/kit/domains/btp/domain.json +4 -4
  3. package/kit/skills/agjan-build/SKILL.md +10 -6
  4. package/kit/skills/agjan-design/SKILL.md +36 -4
  5. package/kit/skills/agjan-fix/SKILL.md +11 -4
  6. package/kit/skills/agjan-map/SKILL.md +11 -4
  7. package/kit/skills/agjan-spec/SKILL.md +11 -4
  8. package/kit/skills/agjan-verify/SKILL.md +26 -6
  9. package/kit/skills/cap-developer/SKILL.md +10 -2
  10. package/kit/skills/cap-developer/references/handlers.md +11 -9
  11. package/kit/skills/cap-developer/references/project-setup.md +21 -8
  12. package/kit/skills/cap-developer/references/testing.md +38 -14
  13. package/kit/skills/cap-developer/references/typescript.md +143 -0
  14. package/kit/skills/cap-developer/references/validation-security.md +26 -8
  15. package/kit/skills/fiori-developer/SKILL.md +20 -5
  16. package/kit/skills/fiori-developer/references/app-setup.md +91 -16
  17. package/kit/skills/fiori-developer/references/elements.md +19 -5
  18. package/kit/skills/fiori-developer/references/freestyle-ts.md +5 -1
  19. package/kit/skills/fiori-developer/references/testing.md +109 -15
  20. package/kit/templates/agents-block.md +4 -0
  21. package/package.json +1 -1
  22. package/src/browser.mjs +49 -0
  23. package/src/cli.mjs +18 -5
  24. package/src/commands/branch.mjs +50 -15
  25. package/src/commands/check.mjs +17 -6
  26. package/src/commands/gates.mjs +12 -9
  27. package/src/commands/review.mjs +69 -4
  28. package/src/commands/setup.mjs +49 -43
  29. package/src/commands/status.mjs +13 -11
  30. package/src/commands/ui-test.mjs +38 -0
  31. package/src/copilot-mcp.mjs +56 -0
  32. package/src/review.mjs +9 -6
@@ -1,7 +1,7 @@
1
1
  import { spawnSync } from 'node:child_process';
2
- import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
2
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
- import { isAbsolute, join, relative, resolve } from 'node:path';
4
+ import { join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { parseArgs } from 'node:util';
7
7
  import { CONFIG_FILE, MODEL_TIERS, RECOMMENDED_ALLOW, SESSION_MODEL, agentModel, loadConfig, loadDomain } from '../config.mjs';
@@ -15,6 +15,9 @@ import { GUARD } from '../adapters/copilot.mjs';
15
15
  import { git, mergeBase, resolveBase } from '../git.mjs';
16
16
  import { AgjanError, UsageError } from '../errors.mjs';
17
17
  import { blink, mark, pad, tone, verdictColor } from '../ui.mjs';
18
+ import { mcpServers } from '../mcp-config.mjs';
19
+ import { addCommand, addCopilotServers, copilotServers } from '../copilot-mcp.mjs';
20
+ import { UI_SCRIPT, hasUiTests, probeBrowser } from '../browser.mjs';
18
21
 
19
22
  const CI_FILE = '.github/workflows/agjan.yml';
20
23
  const CI_TEMPLATE = new URL('../../kit/templates/agjan-ci.yml', import.meta.url);
@@ -106,7 +109,7 @@ function nextSteps(ctx, hosts, firstCommit) {
106
109
  steps.push("Open this folder once in Claude Code and trust it: the reviewer's agjan tools load only in trusted folders.");
107
110
  }
108
111
  if (hosts.includes('copilot')) {
109
- steps.push(`Start ${s.cyan('copilot')} in this folder and answer "Do you trust the files in this folder?" with "Yes, and remember this folder for future sessions": with plain "Yes", Copilot does not load the MCP servers in .mcp.json. 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')}.`);
112
+ 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')}.`);
110
113
  }
111
114
  steps.push(`Run: ${s.cyan('npx agjan doctor')}`);
112
115
  return ['', s.bold('Next steps:'), ...steps.map((text, i) => ` ${i + 1}. ${text}`)];
@@ -131,6 +134,8 @@ export async function init(ctx, argv) {
131
134
  'no-agent-allow': { type: 'boolean' },
132
135
  'agent-allow-edits': { type: 'boolean' },
133
136
  'no-agent-allow-edits': { type: 'boolean' },
137
+ 'copilot-mcp': { type: 'boolean' },
138
+ 'no-copilot-mcp': { type: 'boolean' },
134
139
  },
135
140
  });
136
141
  const root = ctx.root;
@@ -154,6 +159,12 @@ export async function init(ctx, argv) {
154
159
  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.)`, { defaultYes: true }) ?? false;
155
160
  const allowEdits = flag('agent-allow-edits', 'no-agent-allow-edits') ??
156
161
  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.)', { defaultYes: true }) ?? false;
162
+ // Copilot loads the project's .mcp.json only in folders it remembers as trusted; its
163
+ // user configuration loads everywhere (decision 72).
164
+ const areas = Object.fromEntries(domains.flatMap((d) => Object.keys(loadDomain(d).areas).flatMap((a) => [[a, {}], [`${d}:${a}`, {}]])));
165
+ const servers = Object.keys(mcpServers({ areas }).servers);
166
+ const copilotMcp = hosts.includes('copilot') && servers.length > 0 && (flag('copilot-mcp', 'no-copilot-mcp') ??
167
+ ask(ctx, `Add the documentation MCP servers ${servers.join(', ')} to your Copilot configuration (copilot mcp add)?\n(Copilot loads a project's .mcp.json only in folders it remembers as trusted; these then load in every Copilot session.)`, { defaultYes: true }) ?? false);
157
168
 
158
169
  const config = {
159
170
  $schema: './node_modules/agjan/schemas/config.schema.json',
@@ -172,6 +183,7 @@ export async function init(ctx, argv) {
172
183
  const setting = (on, text) => ` ${pad(on ? tone(s, 'created') : s.gray('none'), on ? 'created' : 'none', 14)} ${text}`;
173
184
  ctx.out(setting(agentAllow, `agent.allow${agentAllow ? ` (${RECOMMENDED_ALLOW.length} commands)` : ''}`));
174
185
  ctx.out(setting(allowEdits, `agent.allow_edits${allowEdits ? ' (file changes without a prompt)' : ''}`));
186
+ if (copilotMcp) addToCopilot(ctx, loadConfig(root));
175
187
 
176
188
  if (!values['no-hook']) {
177
189
  const hook = installHook(root);
@@ -210,13 +222,28 @@ function addPrepare(root) {
210
222
  return `added "prepare": "${command}"`;
211
223
  }
212
224
 
213
- /** agjan sync [--force]: regenerate managed files; edited ones are kept unless --force. */
225
+ /**
226
+ * Adds the documentation MCP servers to Copilot's user configuration and reports each:
227
+ * added, already there (left as it is), or failed with the command to run by hand.
228
+ */
229
+ function addToCopilot(ctx, config) {
230
+ const s = ctx.style;
231
+ const { servers } = mcpServers(config);
232
+ for (const r of addCopilotServers(servers)) {
233
+ const action = r.state === 'added' ? 'created' : r.state === 'exists' ? 'unchanged' : 'failed';
234
+ ctx.out(` ${pad(tone(s, action), action, 14)} copilot mcp ${r.name}: ${r.detail}`);
235
+ if (r.state === 'failed') ctx.out(` ${' '.repeat(14)} add it yourself: ${s.cyan(addCommand(r.name, servers[r.name]).join(' '))}`);
236
+ }
237
+ }
238
+
239
+ /** agjan sync [--force] [--copilot-mcp]: regenerate managed files; edited ones are kept unless --force. */
214
240
  export function sync(ctx, argv) {
215
- const { values } = parseArgs({ args: argv, options: { force: { type: 'boolean' } } });
241
+ const { values } = parseArgs({ args: argv, options: { force: { type: 'boolean' }, 'copilot-mcp': { type: 'boolean' } } });
216
242
  if (!existsSync(join(ctx.root, CONFIG_FILE))) throw new AgjanError(`no ${CONFIG_FILE}; run 'agjan init' first`);
217
243
  ctx.out(`${ctx.style.bold('agjan sync')}:`);
218
244
  const results = doSync(ctx, { force: values.force });
219
245
  printResults(ctx, results);
246
+ if (values['copilot-mcp']) addToCopilot(ctx, ctx.config);
220
247
  return results.some((r) => r.action.startsWith('kept')) ? 1 : 0;
221
248
  }
222
249
 
@@ -259,42 +286,11 @@ function claudeTrust(root) {
259
286
  return data.projects[root]?.hasTrustDialogAccepted === true ? 'trusted' : 'not trusted';
260
287
  }
261
288
 
262
- /**
263
- * Whether Copilot CLI trusts the project folder: the folder or a parent is in
264
- * `trustedFolders` of its config.json or settings.json (in COPILOT_HOME, default
265
- * ~/.copilot; read-only). Only a remembered folder loads the workspace's .mcp.json.
266
- */
267
- export function copilotTrust(root, dir = process.env.COPILOT_HOME || join(homedir(), '.copilot')) {
268
- const files = ['config.json', 'settings.json'].map((f) => join(dir, f)).filter((f) => existsSync(f));
269
- if (!files.length) return 'unknown';
270
- const folders = files.flatMap((f) => {
271
- try {
272
- // Copilot writes comment lines at the top of its config file.
273
- const list = JSON.parse(readFileSync(f, 'utf8').replace(/^\s*\/\/.*$/gm, '')).trustedFolders;
274
- return Array.isArray(list) ? list.filter((x) => typeof x === 'string') : [];
275
- } catch {
276
- return [];
277
- }
278
- });
279
- const fold = process.platform === 'darwin' || process.platform === 'win32' ? (p) => p.toLowerCase() : (p) => p;
280
- const real = (p) => {
281
- try {
282
- return fold(realpathSync(p));
283
- } catch {
284
- return fold(resolve(p));
285
- }
286
- };
287
- const here = real(root);
288
- const inside = (folder) => {
289
- const rel = relative(real(folder), here);
290
- return rel === '' || (!rel.startsWith('..') && !isAbsolute(rel));
291
- };
292
- return folders.some(inside) ? 'trusted' : 'not trusted';
293
- }
294
-
295
289
  /** agjan doctor: checks the environment and the project setup; exit 1 on any failure. */
296
- export function doctor(ctx) {
297
- for (const line of mark(ctx.style, ctx.kit, 'doctor: environment and project setup')) ctx.out(line);
290
+ export async function doctor(ctx) {
291
+ const lines = mark(ctx.style, ctx.kit, 'doctor: environment and project setup');
292
+ for (const line of lines) ctx.out(line);
293
+ await blink(ctx, lines);
298
294
  const rows = [];
299
295
  const ok = (what, detail = '') => rows.push(['ok', what, detail]);
300
296
  const warn = (what, detail) => rows.push(['warn', what, detail]);
@@ -356,15 +352,25 @@ export function doctor(ctx) {
356
352
  const guard = probeGuard(root);
357
353
  if (guard) warn('copilot guard', guard);
358
354
  else ok('copilot guard', 'denies agjan approve in a test payload');
359
- const trust = copilotTrust(root);
360
- if (trust === 'trusted') ok('copilot trust', 'project folder remembered as trusted');
361
- else warn('copilot trust', `${trust}; start copilot here and answer the trust question with "Yes, and remember this folder for future sessions", or Copilot does not load the MCP servers in .mcp.json`);
355
+ const names = Object.keys(mcpServers(config).servers);
356
+ const known = names.length ? copilotServers() : {};
357
+ const missing = names.filter((name) => !known?.[name]);
358
+ if (!known) warn('copilot mcp', 'copilot is not on PATH; its MCP servers were not checked');
359
+ else if (missing.length) warn('copilot mcp', `${missing.join(', ')} not in Copilot's configuration (removed?); add: npx agjan sync --copilot-mcp`);
360
+ else if (names.length) ok('copilot mcp', `${names.join(', ')} in Copilot's configuration`);
362
361
  }
363
362
  if (config.hosts.includes('claude-code')) {
364
363
  const trust = claudeTrust(root);
365
364
  if (trust === 'trusted') ok('claude code trust', 'project folder trusted');
366
365
  else warn('claude code trust', `${trust}; open the folder in Claude Code once and trust it, or the reviewer has no agjan tools`);
367
366
  }
367
+ if (hasUiTests(root)) {
368
+ const browser = probeBrowser(root);
369
+ if (browser.ready) ok('ui tests', `Chromium starts; npx agjan ui-test runs npm run ${UI_SCRIPT}`);
370
+ else warn('ui tests', `skipped (optional): ${browser.reason}; enable: ${browser.enable}`);
371
+ } else if (config.areas.fiori) {
372
+ ok('ui tests', `none (optional: Playwright, a ${UI_SCRIPT} script; see the fiori-developer skill)`);
373
+ }
368
374
  const allow = config.agent?.allow ?? [];
369
375
  ok('agent allow list', allow.length ? `${allow.length} command(s) without a prompt: ${allow.join(', ')}` : 'none (the hosts ask for every command)');
370
376
  ok('reviewer models', config.hosts.map((h) => `${h}: ${MODEL_TIERS.map((t) => `${t} ${agentModel(config, h, t) ?? 'session model'}`).join(', ')}`).join('; '));
@@ -7,7 +7,7 @@ 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 { mark, markLine, pad, tone } from '../ui.mjs';
10
+ import { blink, 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';
@@ -126,7 +126,7 @@ function describeRecordOnBase(ctx, unit) {
126
126
  * Colored with the agjan mark on a terminal; the same content as plain text for agents,
127
127
  * who end /agjan-verify with it.
128
128
  */
129
- function completion(ctx, feature, progress) {
129
+ async function completion(ctx, feature, progress) {
130
130
  const s = ctx.style;
131
131
  const areaNames = [...new Set(progress.tasks.map((t) => t.areaName))];
132
132
  const automated = feature.spec.parsed.acs.filter((ac) => ac.verification !== 'manual');
@@ -148,7 +148,9 @@ function completion(ctx, feature, progress) {
148
148
  ctx.out();
149
149
  if (s.brand) {
150
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);
151
+ const logo = mark(s, ctx.kit, `${stars} ${s.bold(`${feature.key} is done`)} ${stars}`, `${feature.slug} · development finished and verified`);
152
+ for (const line of logo) ctx.out(line);
153
+ await blink(ctx, logo);
152
154
  } else {
153
155
  ctx.out(`✔ ${feature.key} is done: development finished and verified (${feature.slug})`);
154
156
  }
@@ -158,7 +160,7 @@ function completion(ctx, feature, progress) {
158
160
  for (const step of steps) ctx.out(` ${s.violet('▸')} ${step}`);
159
161
  }
160
162
 
161
- function describe(ctx, feature, onBase = false) {
163
+ async function describe(ctx, feature, onBase = false) {
162
164
  if (feature.kind !== 'feature') return describeRecord(ctx, feature, onBase);
163
165
  if (onBase) return describeOnBase(ctx, feature);
164
166
  heading(ctx, feature, `stage: ${ctx.style.magenta(feature.stage)}`);
@@ -187,7 +189,7 @@ function describe(ctx, feature, onBase = false) {
187
189
  for (const d of progress.due) row(ctx, 'due', ctx.style.yellow(`review ${d.step} (${d.reason})`));
188
190
  row(ctx, 'next', nextInBuild(ctx, feature, progress).replace('<KEY>', feature.key));
189
191
  const verify = verifyState(ctx.root, ctx.config, feature);
190
- if (progress.complete && progress.due.length === 0 && verify.state === 'current') completion(ctx, feature, progress);
192
+ if (progress.complete && progress.due.length === 0 && verify.state === 'current') await completion(ctx, feature, progress);
191
193
  } else {
192
194
  // Spec and Design: either the gate is ready for the human, or what blocks it.
193
195
  const gate = pendingGate(feature);
@@ -208,11 +210,11 @@ function describe(ctx, feature, onBase = false) {
208
210
  * agjan status --done [--feature <slug>]: only the completion block of a verified feature,
209
211
  * for the agent's final message (exit 1 with the next step while it is not done).
210
212
  */
211
- function done(ctx, slug) {
213
+ async function done(ctx, slug) {
212
214
  const feature = loadFeature(ctx.root, slug);
213
215
  const progress = feature.kind === 'feature' && feature.stage === 'build' ? buildProgress(ctx.root, ctx.config, feature) : null;
214
216
  if (progress?.complete && progress.due.length === 0 && verifyState(ctx.root, ctx.config, feature).state === 'current') {
215
- completion(ctx, feature, progress);
217
+ await completion(ctx, feature, progress);
216
218
  return 0;
217
219
  }
218
220
  ctx.out(`${feature.key} is not done yet: ${progress ? nextInBuild(ctx, feature, progress).replace('<KEY>', feature.key) : `stage ${feature.stage}`}`);
@@ -220,7 +222,7 @@ function done(ctx, slug) {
220
222
  }
221
223
 
222
224
  /** agjan status [--feature <slug> | --all | --done] */
223
- export function run(ctx, argv) {
225
+ export async function run(ctx, argv) {
224
226
  const { values } = parseArgs({ args: argv, options: { feature: { type: 'string' }, all: { type: 'boolean' }, done: { type: 'boolean' } } });
225
227
  const root = ctx.root;
226
228
  if (values.done) return done(ctx, selectFeature(root, ctx.config, values.feature));
@@ -240,9 +242,9 @@ export function run(ctx, argv) {
240
242
  return 0;
241
243
  }
242
244
  const changed = new Set(changedFeatures(root, ctx.config));
243
- slugs.forEach((slug, i) => {
245
+ for (const [i, slug] of slugs.entries()) {
244
246
  if (i > 0) ctx.out();
245
- describe(ctx, loadFeature(root, slug), !changed.has(slug));
246
- });
247
+ await describe(ctx, loadFeature(root, slug), !changed.has(slug));
248
+ }
247
249
  return 0;
248
250
  }
@@ -0,0 +1,38 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import { parseArgs } from 'node:util';
3
+ import { UsageError } from '../errors.mjs';
4
+ import { UI_SCRIPT, hasUiTests, probeBrowser } from '../browser.mjs';
5
+
6
+ /**
7
+ * agjan ui-test [--require]: runs the project's UI tests (`npm run test:ui`, Playwright)
8
+ * when Chromium can start here. Where it cannot, it says why and how to enable them, and
9
+ * exits 0: UI tests are optional (design decision 75). --require makes a skip exit 1
10
+ * (for a CI job that installs the browser). Exit code 1 when the tests fail.
11
+ */
12
+ export function run(ctx, argv) {
13
+ const { values, positionals } = parseArgs({ args: argv, allowPositionals: true, options: { require: { type: 'boolean' } } });
14
+ if (positionals.length) throw new UsageError('usage: agjan ui-test [--require]');
15
+ const s = ctx.style;
16
+ const root = ctx.root;
17
+ if (!hasUiTests(root)) {
18
+ ctx.out(s.gray(`no UI tests: package.json has no ${UI_SCRIPT} script (the fiori-developer skill sets them up)`));
19
+ return values.require ? 1 : 0;
20
+ }
21
+ const browser = probeBrowser(root);
22
+ if (!browser.ready) {
23
+ ctx.out(`${s.bold('ui tests')} ${s.yellow('skipped')}: ${browser.reason}`);
24
+ ctx.out(` enable: ${browser.enable}`);
25
+ ctx.out(' The UI ACs were not tested in a browser: name them to the user, who tries them by hand.');
26
+ return values.require ? 1 : 0;
27
+ }
28
+ ctx.out(`${s.bold('ui tests')}: ${s.gray(`npm run ${UI_SCRIPT}`)}`);
29
+ const result = spawnSync(`npm run ${UI_SCRIPT}`, { cwd: root, shell: true, encoding: 'utf8', timeout: 1_800_000, maxBuffer: 64 * 1024 * 1024 });
30
+ const output = `${result.stdout ?? ''}${result.stderr ?? ''}`.trim();
31
+ if (output) ctx.out(output);
32
+ if (result.status === 0) {
33
+ ctx.out(` ${s.green('ok')}`);
34
+ return 0;
35
+ }
36
+ ctx.out(` ${s.red(result.status === null ? 'could not run (stopped)' : `failed (exit code ${result.status})`)}`);
37
+ return 1;
38
+ }
@@ -0,0 +1,56 @@
1
+ import { spawnSync } from 'node:child_process';
2
+
3
+ /**
4
+ * Copilot CLI loads a project's .mcp.json only in folders it remembers as trusted, so
5
+ * `init` also adds the documentation servers to Copilot's user configuration with
6
+ * `copilot mcp add` (design decision 72). Servers there load in every folder. agjan
7
+ * never removes or changes a server in that configuration: one that exists is reported
8
+ * and left as it is.
9
+ */
10
+
11
+ /** Runs the copilot command; AGJAN_COPILOT names a Node script that replaces it (tests). */
12
+ function copilot(args) {
13
+ const options = { encoding: 'utf8', timeout: 60_000 };
14
+ const fake = process.env.AGJAN_COPILOT;
15
+ if (fake) return spawnSync(process.execPath, [fake, ...args], options);
16
+ return spawnSync('copilot', args, { ...options, shell: process.platform === 'win32' });
17
+ }
18
+
19
+ /** The command line that adds one server, for messages and for doing it by hand. */
20
+ export function addCommand(name, server) {
21
+ const env = Object.entries(server.env ?? {}).flatMap(([k, v]) => ['--env', `${k}=${v}`]);
22
+ return ['copilot', 'mcp', 'add', ...env, name, '--', server.command, ...(server.args ?? [])];
23
+ }
24
+
25
+ /**
26
+ * The servers Copilot knows (user, workspace, plugin; not its built-in ones), as
27
+ * { name: { source, command, args } }, or null when copilot cannot be run.
28
+ */
29
+ export function copilotServers() {
30
+ const run = copilot(['mcp', 'list', '--json']);
31
+ if (run.error || run.status !== 0) return null;
32
+ try {
33
+ const list = JSON.parse(run.stdout).mcpServers ?? {};
34
+ return Object.fromEntries(Object.entries(list).filter(([, s]) => s.source !== 'builtin'));
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Adds each server that Copilot does not know yet. Returns one result per server:
42
+ * `added`, `exists` (left as it is), or `failed` with the reason.
43
+ */
44
+ export function addCopilotServers(servers) {
45
+ const known = copilotServers();
46
+ if (!known) return Object.keys(servers).map((name) => ({ name, state: 'failed', detail: 'copilot is not on PATH' }));
47
+ return Object.entries(servers).map(([name, server]) => {
48
+ if (known[name]) return { name, state: 'exists', detail: `already in Copilot's ${known[name].source} configuration; left as it is` };
49
+ const run = copilot(addCommand(name, server).slice(1));
50
+ const output = `${run.stdout ?? ''}${run.stderr ?? ''}`.trim();
51
+ if (run.error || run.status !== 0 || /^Error:/m.test(output)) {
52
+ return { name, state: 'failed', detail: (output.split('\n').find((l) => l.startsWith('Error:')) ?? output.split('\n')[0] ?? `exit code ${run.status}`).trim() };
53
+ }
54
+ return { name, state: 'added', detail: "Copilot's user configuration" };
55
+ });
56
+ }
package/src/review.mjs CHANGED
@@ -138,12 +138,12 @@ function openFindings(feature, steps) {
138
138
 
139
139
  const CHECKLISTS = {
140
140
  spec: 'No unrequested technical decisions. Technical questions listed under Open technical questions are expected and are not decisions: never ask to remove that section; Design answers them. Every AC testable and complete; an AC without a Verification line is automated, which is the default and not a finding; flag only ACs that cannot be tested automatically but are not marked manual. Non-functional and authorization requirements considered. Scope consistent.',
141
- 'design:light': 'The spec checks, plus: light mode is justified (nothing new: no new service, application, BTP service, authorization or deployment change). Tasks: paths plausible and including where the tests of their ACs go, every AC covered.',
142
- design: 'Every AC covered by tasks. Areas and app types justified with alternatives. Open technical questions answered. Every rule of the spec\'s Authorization section has a decision on how it is enforced. Every task\'s paths include where the tests of its ACs go (tests of Fiori annotations usually live in the CAP tests). Nothing beyond the spec.',
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.',
141
+ 'design:light': 'The spec checks, plus: light mode is justified (nothing new: no new service, application, BTP service, authorization or deployment change). Tasks: paths plausible and including where the tests of their ACs go, every AC covered. In a Fiori elements app, creating or editing records needs a draft-enabled entity.',
142
+ design: 'Every AC covered by tasks. Areas and app types justified with alternatives. Open technical questions answered. Every rule of the spec\'s Authorization section has a decision on how it is enforced. Every task\'s paths include where the tests of its ACs go (tests of Fiori annotations usually live in the CAP tests); a task covers an AC only if its paths include every file needed to implement and test it. The chosen service shape supports every interaction the ACs describe in the UI: in a Fiori elements app, creating or editing records needs a draft-enabled entity (@odata.draft.enabled), so "no draft" for such an app is a blocker. Nothing beyond the spec.',
143
+ build: 'Each covered AC is met by the diff. Tests exist and carry the AC id in their names. An AC that a user does on a page of a Fiori app (create a record, choose an action) has a UI test (Playwright, test/ui) besides the service tests; UI tests that agjan ui-test skipped because no browser can start here are not a finding. Project conventions. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request, and for every where condition a test with a user who has the role but whom the condition excludes. The service has a service-level @requires, so nothing it exposes (code lists, auto-exposed entities) is open. Security basics (authorization, input validation, no secrets; test or mocked users and other development settings only in a development profile, never active in production). Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope.',
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, and its section "Run locally" (start command, app URLs, test users and roles) matches the change. Do not re-review each task.',
146
+ verify: 'Cross-task consistency. Every AC covered by a passing test or marked manual. UI tests that agjan ui-test skipped because no browser can start here are not a finding: the final message names those ACs for the human. When the project records no test results (no results file in the context), judge coverage by the tests that carry the AC ids: missing recorded results is a project setting for the human, not a finding. The spec\'s Authorization section, rule by rule: each role and permission is enforced in the code (for example @requires or @restrict on every entity and operation it covers; anything without them is open to every user, anonymous requests included) and covered by tests, including a negative test for a user without the role and for an anonymous request. Scope is checked by agjan: a file under the allowed paths (task, implicit or amended) is in scope; do not report it as out of scope. The baseline (project.md) updated if a service, application or BTP service was added, and its section "Run locally" (start command, app URLs, test users and roles) matches the change. Do not re-review each task.',
147
147
  };
148
148
 
149
149
  /**
@@ -224,11 +224,14 @@ export function buildContextText(root, config, feature, parsed) {
224
224
  const loaded = loadResults(root, config, areaNames);
225
225
  const results = loaded.files.length ? acResults(loaded, feature.key) : null;
226
226
  const coverage = feature.spec.parsed.acs
227
- .map((ac) => `| ${ac.id} | ${ac.verification} | ${[...(tests.get(ac.id) ?? [])].join(', ') || '-'} | ${results ? resultLabel(results.get(ac.id)) : 'no results'} |`)
227
+ .map((ac) => `| ${ac.id} | ${ac.verification} | ${[...(tests.get(ac.id) ?? [])].join(', ') || '-'} | ${results ? resultLabel(results.get(ac.id)) : 'not recorded'} |`)
228
228
  .join('\n');
229
+ const unrecorded = results
230
+ ? ''
231
+ : '\n\nThis project records no test results (no `verify.<area>.results` in agjan.config.json, a setting for the human). Coverage here means a test names the AC; missing results are not a finding.';
229
232
  const changed = changedFiles(root, base).filter((f) => !scriptOwned(feature.slug).has(f) && !f.startsWith('.agjan/'));
230
233
  parts.push(section('Acceptance criteria', acsText(feature)));
231
- parts.push(section('AC coverage (test files mentioning the AC id, and test results)', `| AC | verification | test files | result |\n|---|---|---|---|\n${coverage}`));
234
+ parts.push(section('AC coverage (test files mentioning the AC id, and test results)', `| AC | verification | test files | result |\n|---|---|---|---|\n${coverage}${unrecorded}`));
232
235
  parts.push(section(docPath(feature, 'design.md'), fence(feature.design.text, 'md')));
233
236
  parts.push(section(docPath(feature, 'tasks.md'), fence(feature.tasks.text, 'md')));
234
237
  parts.push(section('Allowed paths (scope, enforced by agjan check)', scopeText(scopeOf(config, feature, feature.tasks.parsed.tasks))));