agjan 0.0.7 โ†’ 0.0.9

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/src/git.mjs CHANGED
@@ -55,12 +55,20 @@ function lines(out) {
55
55
  return out ? out.split('\n').filter(Boolean) : [];
56
56
  }
57
57
 
58
+ /**
59
+ * Files the operating system writes on its own (macOS Finder, Windows Explorer). They are
60
+ * never part of a change: neither in scope checks nor in a review's working-tree hash,
61
+ * even when someone committed them.
62
+ */
63
+ const OS_FILES = new Set(['.DS_Store', 'Thumbs.db', 'desktop.ini']);
64
+ const osFile = (path) => OS_FILES.has(path.slice(path.lastIndexOf('/') + 1));
65
+
58
66
  /**
59
67
  * Files changed relative to the merge-base: committed, staged, unstaged and untracked.
60
68
  * With `staged`, only the files in the index. Paths are POSIX (git always uses '/').
61
69
  */
62
70
  export function changedFiles(root, base, { staged = false } = {}) {
63
- if (staged) return lines(git(root, ['diff', '--cached', '--name-only', '--no-renames']));
71
+ if (staged) return lines(git(root, ['diff', '--cached', '--name-only', '--no-renames'])).filter((f) => !osFile(f));
64
72
  const from = mergeBase(root, base);
65
73
  const files = new Set();
66
74
  if (from) {
@@ -71,5 +79,5 @@ export function changedFiles(root, base, { staged = false } = {}) {
71
79
  for (const f of lines(git(root, ['diff', '--cached', '--name-only', '--no-renames']))) files.add(f);
72
80
  }
73
81
  for (const f of lines(git(root, ['ls-files', '--others', '--exclude-standard']))) files.add(f);
74
- return [...files].sort();
82
+ return [...files].filter((f) => !osFile(f)).sort();
75
83
  }
package/src/log.mjs CHANGED
@@ -7,11 +7,13 @@ export const LOG_FILE = 'log.jsonl';
7
7
  export const EVENTS = [
8
8
  'step', // a skill starts a step (from `agjan log`)
9
9
  'gate-requested', // a skill hands a gate to the human (from `agjan log`)
10
+ 'waiting', // the agent stopped and waits for the user (from `agjan log --waiting`)
10
11
  'approved',
11
12
  'rejected',
12
13
  'accepted',
13
14
  'amendment-proposed',
14
15
  'review-recorded',
16
+ 'round-granted', // the user allowed one more review round (from `agjan review extend`)
15
17
  ];
16
18
 
17
19
  let listener = null;
package/src/plan.mjs CHANGED
@@ -29,7 +29,7 @@ export function buildPlan(config) {
29
29
  items.push(
30
30
  { kind: 'block', path: '.gitattributes', style: 'hash', content: 'docs/agjan/** text eol=lf\nagjan.lock.json text eol=lf' },
31
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/' },
32
+ { kind: 'block', path: '.gitignore', style: 'hash', content: '.agjan/\nnode_modules/\n.DS_Store\nThumbs.db' },
33
33
  );
34
34
  for (const host of hosts) {
35
35
  const adapter = ADAPTERS[host];
@@ -102,6 +102,16 @@ function stageOf(ctx, unit, onBase, extra) {
102
102
  return { names, at: 3, turn: 'agent', now: verify.state === 'none' ? 'verify' : `verify (${verify.state})` };
103
103
  }
104
104
 
105
+ /**
106
+ * While the agent would be working, a `waiting` event after its last step means it stopped
107
+ * for the user (an error it cannot resolve, a decision): their turn, with the reason.
108
+ */
109
+ function waitingFor(events, stage) {
110
+ if (stage.turn !== 'agent') return stage;
111
+ const last = events.filter((e) => ['step', 'waiting', 'gate-requested', 'approved', 'rejected'].includes(e.event)).at(-1);
112
+ return last?.event === 'waiting' ? { ...stage, turn: 'you', now: last.reason } : stage;
113
+ }
114
+
105
115
  /** What the human may do after "done" (design decision 70): all of it optional. */
106
116
  export function optionalSteps(root, unit, acs) {
107
117
  const steps = [];
@@ -121,7 +131,7 @@ export function unitModel(ctx, slug, { onBase = false, now = Date.now() } = {})
121
131
  const progress = isFeature && unit.tasks ? buildProgress(ctx.root, config, unit, { history: onBase }) : null;
122
132
  const verify = isFeature ? verifyState(ctx.root, config, unit) : null;
123
133
  const review = !isFeature ? freshReview(ctx.root, config, unit, unit.kind) : null;
124
- const stage = stageOf(ctx, unit, onBase, { progress, verify, review });
134
+ const stage = waitingFor(events, stageOf(ctx, unit, onBase, { progress, verify, review }));
125
135
  const commits = unitCommits(ctx.root, unit.key);
126
136
 
127
137
  const times = [...events.map((e) => Date.parse(e.at_utc)), ...commits.map((c) => Date.parse(c.at))].filter(Number.isFinite);
@@ -315,6 +325,7 @@ export function timelineRows(model) {
315
325
  if (e.event === 'step') rows.push([e.at, '๐Ÿค– writer', `${[e.stage, e.task, e.role].filter(Boolean).join(' ')} started`]);
316
326
  if (e.event === 'gate-requested') rows.push([e.at, '๐Ÿค– writer', `asks you to approve ${e.gate}`]);
317
327
  if (e.event === 'amendment-proposed') rows.push([e.at, '๐Ÿค– writer', `proposes amendment ${e.amendment ?? ''}`.trim()]);
328
+ if (e.event === 'round-granted') rows.push([e.at, '๐Ÿ‘ค human', `allows round ${e.round} for ${e.step}`]);
318
329
  }
319
330
  for (const r of model.reviews) {
320
331
  const what = r.findings.length ? ` (${severities(r.findings, model.findings)})` : '';
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import { stillBlocked } from './feature.mjs';
9
+ import { readLog } from './log.mjs';
9
10
 
10
11
  /** Default tier per kind of review step. */
11
12
  export const DEFAULT_TIERS = {
@@ -66,12 +67,25 @@ export function nextRound(feature, step) {
66
67
 
67
68
  /**
68
69
  * The state of one review step: its latest round and verdict, and whether the round limit
69
- * is reached with the step still blocked (design 7.4: stop and hand over to the human).
70
+ * (with the rounds the user granted) is reached with the step still blocked (design 7.4:
71
+ * ask the user for another round, or hand over).
70
72
  */
71
73
  export function roundState(feature, config, step) {
72
74
  const records = feature.reviews.records.filter((r) => r.step === step);
73
75
  const last = records.at(-1) ?? null;
74
- const limit = roundLimit(config);
76
+ const extra = extraRounds(feature, step);
77
+ const limit = roundLimit(config) + extra;
75
78
  const round = last?.round ?? 0;
76
- return { last, round, next: nextRound(feature, step), limit, exhausted: stillBlocked(feature, last) && round >= limit };
79
+ return { last, round, next: nextRound(feature, step), limit, extra, exhausted: stillBlocked(feature, last) && round >= limit };
80
+ }
81
+
82
+ /**
83
+ * Rounds the user granted beyond the limit in the current correction loop of `step`
84
+ * (`agjan review extend`, design 7.4): each grant adds one round. A new loop starts at
85
+ * round 1 with the configured limit again.
86
+ */
87
+ export function extraRounds(feature, step) {
88
+ const loopStart = feature.reviews.records.filter((r) => r.step === step && r.round === 1).at(-1)?.at_utc;
89
+ if (!loopStart) return 0;
90
+ return readLog(feature.dir).filter((e) => e.event === 'round-granted' && e.step === step && e.at_utc >= loopStart).length;
77
91
  }
package/src/terminal.mjs CHANGED
@@ -66,7 +66,9 @@ 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} ${defaultYes ? '[Y/n]' : '[y/N]'} `);
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')}]`} `);
70
72
  const answer = readLine(tty.input).trim();
71
73
  if (answer === '') return defaultYes;
72
74
  return /^y(es)?$/i.test(answer);
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 [];