agjan 0.0.6 โ†’ 0.0.8

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 (35) hide show
  1. package/README.md +3 -2
  2. package/docs/guide.md +81 -29
  3. package/kit/hooks/guard.mjs +129 -19
  4. package/kit/skills/agjan-fix/SKILL.md +11 -3
  5. package/kit/skills/agjan-map/SKILL.md +12 -3
  6. package/kit/skills/agjan-spec/SKILL.md +12 -5
  7. package/kit/skills/agjan-verify/SKILL.md +9 -6
  8. package/kit/skills/cap-developer/SKILL.md +4 -0
  9. package/kit/skills/cap-developer/references/handlers.md +61 -4
  10. package/kit/skills/cap-developer/references/modeling.md +33 -1
  11. package/kit/skills/cap-developer/references/project-setup.md +87 -0
  12. package/kit/skills/cap-developer/references/services.md +32 -1
  13. package/kit/skills/cap-developer/references/testing.md +46 -14
  14. package/kit/skills/cap-developer/references/validation-security.md +66 -2
  15. package/kit/skills/fiori-developer/SKILL.md +1 -0
  16. package/kit/skills/fiori-developer/references/app-setup.md +127 -0
  17. package/kit/skills/fiori-developer/references/elements.md +109 -11
  18. package/kit/skills/fiori-developer/references/ui5-basics.md +3 -2
  19. package/kit/templates/agents-block.md +3 -2
  20. package/kit/templates/progress.html +14 -9
  21. package/kit/templates/project.md +5 -0
  22. package/package.json +1 -1
  23. package/schemas/config.schema.json +1 -15
  24. package/src/adapters/claude-code.mjs +16 -12
  25. package/src/cli.mjs +3 -2
  26. package/src/commands/branch.mjs +34 -24
  27. package/src/commands/check.mjs +1 -17
  28. package/src/commands/setup.mjs +73 -35
  29. package/src/commands/status.mjs +38 -13
  30. package/src/context.mjs +6 -0
  31. package/src/plan.mjs +8 -4
  32. package/src/progress-view.mjs +32 -11
  33. package/src/review.mjs +1 -1
  34. package/src/terminal.mjs +7 -3
  35. package/src/ui.mjs +22 -0
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
  }
@@ -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' : 'Gate 3'];
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: waiting ? 'you' : 'agent', now: waiting ? 'approve the design in a terminal (npx agjan approve design)' : 'writing and reviewing the design' };
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
- if (!progress.complete) return { names, at: 2, turn: 'agent', now: progress.next ? `task ${progress.next.id}: ${progress.next.title}` : 'building' };
89
- if (progress.due.length) return { names, at: 2, turn: 'agent', now: `review ${progress.due[0].step}` };
90
- if (verify.state === 'current') return { names, at: 4, turn: 'you', now: 'review and merge the pull request (Gate 3)' };
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, idle: 2, merged: 3 };
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,16 @@ 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
- return /^y(es)?$/i.test(readLine(tty.input).trim());
69
+ // The capital letter is the default (Enter), also in bold.
70
+ const bold = (t) => (process.env.NO_COLOR !== undefined ? t : `\x1b[1m\x1b[36m${t}\x1b[0m`);
71
+ writeSync(tty.output, `${question} ${defaultYes ? `[${bold('Y')}/n]` : `[y/${bold('N')}]`} `);
72
+ const answer = readLine(tty.input).trim();
73
+ if (answer === '') return defaultYes;
74
+ return /^y(es)?$/i.test(answer);
71
75
  } finally {
72
76
  closeSync(tty.input);
73
77
  if (tty.output !== tty.input) closeSync(tty.output);
package/src/ui.mjs CHANGED
@@ -107,6 +107,28 @@ export function mark(style, version, line2 = 'spec-driven work with AI agents, g
107
107
  ];
108
108
  }
109
109
 
110
+ /**
111
+ * The mark blinks twice (its two bowls close and open), on a real terminal only: not in
112
+ * CI, not when the brand is off, not for streams that tests pass. `lines` is what
113
+ * mark() returned and was just written.
114
+ */
115
+ export async function blink(ctx, lines) {
116
+ if (!lines.length || !ctx.isTTY || process.env.CI) return;
117
+ const open = [lines[1], lines[2]];
118
+ const closed = [lines[1].replace(/โ•ญโ”€โ•ฎ/g, ' '), lines[2].replace(/โ•ฐโ”€โ•ฏ/g, 'โ•ถโ”€โ•ด')];
119
+ const draw = ([top, bottom]) => ctx.write(`\x1b[${lines.length - 1}A\r\x1b[2K${top}\n\x1b[2K${bottom}\n\x1b[${lines.length - 3}B`);
120
+ const wait = (ms) => new Promise((done) => setTimeout(done, ms));
121
+ ctx.write('\x1b[?25l');
122
+ try {
123
+ for (const [frame, ms] of [[closed, 120], [open, 220], [closed, 120], [open, 0]]) {
124
+ draw(frame);
125
+ await wait(ms);
126
+ }
127
+ } finally {
128
+ ctx.write('\x1b[?25h');
129
+ }
130
+ }
131
+
110
132
  /** The one-line mark for frequent commands: `โ”ƒ agjan 0.0.6 ยท status`. Empty when the brand is off. */
111
133
  export function markLine(style, version, what) {
112
134
  if (!style.brand) return [];