ai-engineering-loop 2.1.0 → 2.3.0

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 (108) hide show
  1. package/.agents/skills/ai-engineering-loop/SKILL.md +4 -4
  2. package/.agents/skills/ai-engineering-loop/references/loop-deliver.md +2 -2
  3. package/.agents/skills/ai-engineering-loop/references/loop-goal.md +3 -3
  4. package/.agents/skills/ai-engineering-loop/references/loop-maker.md +1 -0
  5. package/.agents/skills/ai-engineering-loop/references/loop-review.md +3 -4
  6. package/.agents/skills/ai-engineering-loop/references/loop-verify.md +3 -3
  7. package/.claude/agents/judge.md +5 -2
  8. package/.grok/agents/judge.md +5 -2
  9. package/CHANGELOG.md +46 -0
  10. package/agents/maker.md +1 -1
  11. package/agents/shared/judge.body.md +5 -2
  12. package/bin/ai-engineering-loop.js +303 -77
  13. package/core/definition-of-done.md +2 -2
  14. package/core/escalation-policy.md +1 -1
  15. package/core/goal-contract.md +1 -1
  16. package/core/iteration-policy.md +2 -1
  17. package/core/judge-policy.md +10 -4
  18. package/core/local-workflow-studio.md +12 -7
  19. package/core/orchestration-model.md +8 -7
  20. package/core/repo-config-schema.md +2 -2
  21. package/core/runtime-safety.md +3 -3
  22. package/lib/auto-update.js +8 -14
  23. package/lib/claimed-vs-reality.js +2 -2
  24. package/lib/cli-args.js +3 -1
  25. package/lib/docs.js +1 -1
  26. package/lib/doctor.js +0 -6
  27. package/lib/escalation.js +1 -1
  28. package/lib/fsutil.js +88 -0
  29. package/lib/gates.js +69 -27
  30. package/lib/generate-workflow.js +0 -29
  31. package/lib/goal-runtime.js +3 -2
  32. package/lib/guard-hooks.js +26 -7
  33. package/lib/guard.js +100 -10
  34. package/lib/hosts/doctor.js +1 -5
  35. package/lib/impact-map.js +4 -9
  36. package/lib/jsonl-ledger.js +104 -0
  37. package/lib/learn.js +4 -9
  38. package/lib/loop-groups.js +0 -25
  39. package/lib/migrations.js +1 -5
  40. package/lib/no-progress.js +119 -0
  41. package/lib/node-evidence.js +873 -0
  42. package/lib/orchestration.js +5 -361
  43. package/lib/personal-workflow.js +1 -1
  44. package/lib/quick.js +152 -0
  45. package/lib/receipt.js +1 -5
  46. package/lib/recipe-builder.js +3 -35
  47. package/lib/recipe-graph.js +2 -63
  48. package/lib/recipe.js +2 -4
  49. package/lib/review-ingest.js +116 -0
  50. package/lib/run-abandon.js +2 -1
  51. package/lib/run-checkout.js +8 -13
  52. package/lib/run-compaction.js +4 -12
  53. package/lib/run-interactions.js +16 -71
  54. package/lib/run-lifecycle.js +25 -77
  55. package/lib/run-state.js +68 -17
  56. package/lib/run-watcher.js +11 -14
  57. package/lib/runtime-files.js +45 -1
  58. package/lib/safe-context.js +17 -6
  59. package/lib/sandbox.js +2 -1
  60. package/lib/smart-context.js +3 -13
  61. package/lib/spawn-command.js +94 -0
  62. package/lib/studio-layout.js +2 -8
  63. package/lib/studio-runtime.js +2 -1
  64. package/lib/studio-server.js +25 -5
  65. package/lib/tier.js +36 -10
  66. package/lib/user-state.js +2 -17
  67. package/lib/verification-lanes.js +115 -0
  68. package/lib/verification-recorder.js +110 -22
  69. package/lib/workflow-runtime.js +7 -4
  70. package/package.json +1 -2
  71. package/policies/review-budget.md +1 -1
  72. package/studio/app.js +734 -132
  73. package/studio/index.html +13 -4
  74. package/studio/styles.css +75 -20
  75. package/.claude/skills/ai-engineering-loop/SKILL.md +0 -62
  76. package/.claude/skills/ai-engineering-loop/references/loop-commands.md +0 -24
  77. package/.claude/skills/ai-engineering-loop/references/loop-deliver.md +0 -10
  78. package/.claude/skills/ai-engineering-loop/references/loop-goal.md +0 -11
  79. package/.claude/skills/ai-engineering-loop/references/loop-hosts.md +0 -48
  80. package/.claude/skills/ai-engineering-loop/references/loop-maker.md +0 -14
  81. package/.claude/skills/ai-engineering-loop/references/loop-review.md +0 -20
  82. package/.claude/skills/ai-engineering-loop/references/loop-risky.md +0 -9
  83. package/.claude/skills/ai-engineering-loop/references/loop-verify.md +0 -20
  84. package/.claude/skills/animate/RECIPES.md +0 -324
  85. package/.claude/skills/animate/SKILL.md +0 -207
  86. package/.claude/skills/animate-expo/RECIPES.md +0 -385
  87. package/.claude/skills/animate-expo/SKILL.md +0 -263
  88. package/.claude/skills/animation-vocabulary/SKILL.md +0 -181
  89. package/.claude/skills/apple-design/SKILL.md +0 -290
  90. package/.claude/skills/ask-sonner/API.md +0 -64
  91. package/.claude/skills/ask-sonner/SKILL.md +0 -88
  92. package/.claude/skills/backend-development/SKILL.md +0 -272
  93. package/.claude/skills/backend-development/references/api-design-guidelines.md +0 -95
  94. package/.claude/skills/backend-development/references/query-and-database-best-practices.md +0 -53
  95. package/.claude/skills/backend-development/references/security-checklist.md +0 -60
  96. package/.claude/skills/emil-design-eng/SKILL.md +0 -674
  97. package/.claude/skills/find-animation-opportunities/SKILL.md +0 -140
  98. package/.claude/skills/improve-animations/AUDIT.md +0 -115
  99. package/.claude/skills/improve-animations/PLAN-TEMPLATE.md +0 -73
  100. package/.claude/skills/improve-animations/SKILL.md +0 -109
  101. package/.claude/skills/mobile-native/SKILL.md +0 -311
  102. package/.claude/skills/pick-ui-library/SKILL.md +0 -85
  103. package/.claude/skills/prototype/PICKER.md +0 -197
  104. package/.claude/skills/prototype/SKILL.md +0 -98
  105. package/.claude/skills/review-animations/SKILL.md +0 -120
  106. package/.claude/skills/review-animations/STANDARDS.md +0 -187
  107. package/.claude/skills/write-swift/SKILL.md +0 -396
  108. package/lib/intern-catalog.js +0 -53
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ // Verification lanes: a fast `related` lane for iterations and one `final`
4
+ // full run before delivery when the gated verification was related-only.
5
+
6
+ const fs = require('fs');
7
+ const path = require('path');
8
+ const { runsDir } = require('./run-state.js');
9
+ const { extractChangedPaths } = require('./escalation.js');
10
+
11
+ const FINAL_FILE = 'final-verification.json';
12
+ const FILES_TOKEN = '{files}';
13
+
14
+ function laneError(message, code) {
15
+ return Object.assign(new Error(message), { code });
16
+ }
17
+
18
+ // `- **key**: `command`` lines from .ai-engineering-loop/verification.md.
19
+ function verificationCommands(rootDir) {
20
+ let text = '';
21
+ try {
22
+ text = fs.readFileSync(path.join(rootDir, '.ai-engineering-loop', 'verification.md'), 'utf8');
23
+ } catch {
24
+ return {};
25
+ }
26
+ const commands = {};
27
+ for (const match of text.matchAll(/\*\*([a-z0-9_]+)\*\*:\s*`([^`]+)`/gi)) {
28
+ if (!Object.hasOwn(commands, match[1])) commands[match[1]] = match[2].trim();
29
+ }
30
+ return commands;
31
+ }
32
+
33
+ // Changed files of the gated Maker diff that still exist (deleted files have
34
+ // no tests to relate to).
35
+ function relatedFiles(rootDir, run) {
36
+ const artifact = run.artifacts?.diff;
37
+ if (!artifact?.path) throw laneError('Maker evidence is not gated yet. Run `gate maker` first.', 'MAKER_NOT_GATED');
38
+ const diff = fs.readFileSync(path.join(rootDir, artifact.path), 'utf8');
39
+ return [...new Set(extractChangedPaths(diff))]
40
+ .filter((file) => !file.startsWith('.ai-engineering-loop/'))
41
+ .filter((file) => {
42
+ try {
43
+ return fs.statSync(path.join(rootDir, file)).isFile();
44
+ } catch {
45
+ return false;
46
+ }
47
+ });
48
+ }
49
+
50
+ // Expand `{files}` in the project's test_related command. `split` is the
51
+ // CLI's command splitter so quoting rules stay identical to `--cmd`.
52
+ function relatedCommand(rootDir, run, { split, shell = false } = {}) {
53
+ const template = verificationCommands(rootDir).test_related;
54
+ if (!template) {
55
+ throw laneError(
56
+ 'No test_related command in .ai-engineering-loop/verification.md. Add e.g. - **test_related**: `npx jest --findRelatedTests {files}`, or pass --cmd.',
57
+ 'NO_RELATED_COMMAND'
58
+ );
59
+ }
60
+ if (!template.includes(FILES_TOKEN)) {
61
+ throw laneError(`test_related must contain ${FILES_TOKEN}`, 'INVALID_RELATED_COMMAND');
62
+ }
63
+ const files = relatedFiles(rootDir, run);
64
+ if (!files.length) {
65
+ throw laneError('The gated diff has no existing files to relate tests to; run the full `verify`.', 'NO_RELATED_FILES');
66
+ }
67
+ if (shell) {
68
+ const quoted = files.map((file) => `'${file.replace(/'/g, `'\\''`)}'`).join(' ');
69
+ return { ...split(template.split(FILES_TOKEN).join(quoted), true), files };
70
+ }
71
+ const parsed = split(template.replace(FILES_TOKEN, 'AEL_FILES_PLACEHOLDER'), false);
72
+ const args = parsed.args.flatMap((arg) => (arg === 'AEL_FILES_PLACEHOLDER' ? files : [arg]));
73
+ return { ...parsed, args, files };
74
+ }
75
+
76
+ function readJson(filePath) {
77
+ try {
78
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+
84
+ const passed = (record) => record && record.exitCode === 0 && record.timeoutStatus === 'COMPLETED';
85
+ const isFull = (record) => (record.scope || 'full') !== 'related';
86
+
87
+ // Whether delivery needs (or already has) a full run for the gated diff.
88
+ function finalVerificationStatus(rootDir, run) {
89
+ const dir = path.join(runsDir(rootDir), run.runId);
90
+ const bundle = readJson(path.join(dir, 'verification.json'));
91
+ const commands = bundle?.commands || [];
92
+ if (!commands.length || commands.some(isFull)) {
93
+ return { required: false, satisfied: true, reason: 'gated verification already ran full scope' };
94
+ }
95
+ const final = readJson(path.join(dir, FINAL_FILE));
96
+ const diffHash = run.artifacts?.diff?.sha256;
97
+ if (!final) return { required: true, satisfied: false, reason: `missing ${FINAL_FILE}; run \`verify --final --run ${run.runId}\`` };
98
+ if (final.runId !== run.runId || final.diffHash !== diffHash) {
99
+ return { required: true, satisfied: false, reason: `${FINAL_FILE} is not bound to the gated Maker diff` };
100
+ }
101
+ const records = final.commands || [];
102
+ if (!records.length || !records.every(passed)) {
103
+ return { required: true, satisfied: false, reason: `${FINAL_FILE} has a failing or missing command` };
104
+ }
105
+ return { required: true, satisfied: true, reason: 'final full verification passed' };
106
+ }
107
+
108
+ module.exports = {
109
+ FINAL_FILE,
110
+ FILES_TOKEN,
111
+ verificationCommands,
112
+ relatedFiles,
113
+ relatedCommand,
114
+ finalVerificationStatus
115
+ };
@@ -8,16 +8,19 @@ const {
8
8
  getCurrentRun,
9
9
  getGitRevision,
10
10
  loadRun,
11
- runsDir
11
+ runsDir,
12
+ withFileLock
12
13
  } = require('./run-state.js');
13
14
  const { hashFile } = require('./gates.js');
14
15
  const { redactHomePaths, redactSecrets } = require('./safe-context.js');
15
16
  const { writeVerificationSummary } = require('./verification-summary.js');
17
+ const { killProcessTree, resolveSpawn } = require('./spawn-command.js');
16
18
 
17
19
  const MAX_CAPTURE_BYTES = 256 * 1024;
18
20
  const DEFAULT_TIMEOUT_MS = 30 * 60 * 1000;
19
21
  const MAX_TIMEOUT_MS = 60 * 60 * 1000;
20
22
  const KILL_GRACE_MS = 2_000;
23
+ const PIPE_DRAIN_MS = 10_000;
21
24
 
22
25
  function recorderError(message, code = 'VERIFICATION_RECORD_FAILED') {
23
26
  const error = new Error(message);
@@ -137,29 +140,54 @@ function runCommand(command, args, { cwd, timeoutMs, shell }) {
137
140
  let timedOut = false;
138
141
  let launchError = null;
139
142
  let forceKillTimer = null;
140
- const child = spawn(command, shell ? [] : args, {
143
+ let pipeTimer = null;
144
+ let settled = false;
145
+ const target = shell ? { command, args: [], options: {} } : resolveSpawn(command, args);
146
+ // POSIX: lead a process group so a timeout can stop grandchildren too.
147
+ const detached = process.platform !== 'win32';
148
+ const child = spawn(target.command, target.args, {
141
149
  cwd,
142
150
  env: process.env,
143
151
  shell: Boolean(shell),
144
- stdio: ['ignore', 'pipe', 'pipe']
152
+ detached,
153
+ windowsHide: true,
154
+ stdio: ['ignore', 'pipe', 'pipe'],
155
+ ...target.options
145
156
  });
146
157
  const stdout = captureStream(child.stdout);
147
158
  const stderr = captureStream(child.stderr);
159
+ // A detached group no longer receives the terminal's Ctrl-C; forward it.
160
+ const forward = (signal) => {
161
+ killProcessTree(child, 'SIGKILL');
162
+ process.removeListener('SIGINT', onSigint);
163
+ process.removeListener('SIGTERM', onSigterm);
164
+ process.kill(process.pid, signal);
165
+ };
166
+ const onSigint = () => forward('SIGINT');
167
+ const onSigterm = () => forward('SIGTERM');
168
+ if (detached) {
169
+ process.once('SIGINT', onSigint);
170
+ process.once('SIGTERM', onSigterm);
171
+ }
148
172
 
149
173
  const timeout = setTimeout(() => {
150
174
  timedOut = true;
151
- child.kill('SIGTERM');
152
- forceKillTimer = setTimeout(() => child.kill('SIGKILL'), KILL_GRACE_MS);
175
+ killProcessTree(child, 'SIGTERM');
176
+ forceKillTimer = setTimeout(() => killProcessTree(child, 'SIGKILL'), KILL_GRACE_MS);
153
177
  forceKillTimer.unref?.();
154
178
  }, timeoutMs);
155
179
  timeout.unref?.();
156
180
 
157
- child.once('error', (error) => {
158
- launchError = error;
159
- });
160
- child.once('close', (code, signal) => {
181
+ const finish = (code, signal) => {
182
+ if (settled) return;
183
+ settled = true;
161
184
  clearTimeout(timeout);
162
185
  if (forceKillTimer) clearTimeout(forceKillTimer);
186
+ if (pipeTimer) clearTimeout(pipeTimer);
187
+ process.removeListener('SIGINT', onSigint);
188
+ process.removeListener('SIGTERM', onSigterm);
189
+ child.stdout?.destroy();
190
+ child.stderr?.destroy();
163
191
  const finished = new Date();
164
192
  const rawStdout = stdout.value();
165
193
  const rawStderr = launchError ? launchError.message : stderr.value();
@@ -182,7 +210,55 @@ function runCommand(command, args, { cwd, timeoutMs, shell }) {
182
210
  ...(launchError ? { launchError: true } : {}),
183
211
  ...(timedOut ? { summary: `Command timed out after ${timeoutMs} ms.` } : {})
184
212
  });
213
+ };
214
+
215
+ child.once('error', (error) => {
216
+ launchError = error;
217
+ if (!child.pid) finish(null, null);
218
+ });
219
+ // 'close' waits for the pipes; a grandchild that escaped the group can
220
+ // hold them open forever. After the child exits, give the pipes a grace
221
+ // period to drain and then stop waiting.
222
+ child.once('exit', (code, signal) => {
223
+ pipeTimer = setTimeout(() => {
224
+ killProcessTree(child, 'SIGKILL');
225
+ finish(code, signal);
226
+ }, timedOut ? KILL_GRACE_MS : PIPE_DRAIN_MS);
227
+ pipeTimer.unref?.();
185
228
  });
229
+ child.once('close', (code, signal) => finish(code, signal));
230
+ });
231
+ }
232
+
233
+ // Commands can run for minutes, and other recorders may finish meanwhile.
234
+ // Re-read the Run and the bundle under a lock right before writing so no
235
+ // result is lost and nothing lands after the verification gate.
236
+ const passedRecord = (record) => record.exitCode === 0 && record.timeoutStatus === 'COMPLETED';
237
+
238
+ // Re-read under a lock right before writing so concurrent recorders never
239
+ // drop each other's results. `final` writes final-verification.json, which is
240
+ // recorded after the verification gate and has no summary.
241
+ function appendRecordedCommands(rootDir, runId, results, { filePath, gitRevision, diffHash, final = false }) {
242
+ return withFileLock(`${filePath}.lock`, () => {
243
+ const run = loadRun(rootDir, runId);
244
+ if (!final && run.artifacts?.verification) {
245
+ throw recorderError('Verification passed its gate while the command ran. Do not mutate gated evidence; start a new verification iteration instead.', 'VERIFICATION_ALREADY_GATED');
246
+ }
247
+ if (resolveDiff(rootDir, run) !== diffHash) {
248
+ throw recorderError('The gated Maker diff changed while the command ran. Re-run the Maker gate.', 'STALE_DIFF');
249
+ }
250
+ const bundle = readExistingBundle(filePath, { runId, gitRevision, diffHash });
251
+ // A re-run on the same diff supersedes that command's earlier failure; the
252
+ // failure stays on record under `superseded` and the gate sees the latest.
253
+ const rerun = new Set(results.map((result) => result.command));
254
+ const stale = bundle.commands.filter((record) => rerun.has(record.command) && !passedRecord(record));
255
+ if (stale.length) {
256
+ bundle.superseded = [...(bundle.superseded || []), ...stale];
257
+ bundle.commands = bundle.commands.filter((record) => !stale.includes(record));
258
+ }
259
+ bundle.commands.push(...results);
260
+ atomicWriteJson(filePath, bundle);
261
+ return final ? null : writeVerificationSummary(rootDir, { runId }).summary;
186
262
  });
187
263
  }
188
264
 
@@ -202,12 +278,9 @@ async function recordVerificationCommand(rootDir, {
202
278
  const diffHash = resolveDiff(rootDir, run);
203
279
  const gitRevision = getGitRevision(rootDir);
204
280
  const filePath = path.join(runsDir(rootDir), run.runId, 'verification.json');
205
- const bundle = readExistingBundle(filePath, { runId: run.runId, gitRevision, diffHash });
281
+ readExistingBundle(filePath, { runId: run.runId, gitRevision, diffHash });
206
282
  const result = await runCommand(command, args, { cwd: rootDir, timeoutMs, shell });
207
- bundle.commands.push(result);
208
- atomicWriteJson(filePath, bundle);
209
-
210
- const summary = writeVerificationSummary(rootDir, { runId: run.runId }).summary;
283
+ const summary = appendRecordedCommands(rootDir, run.runId, [result], { filePath, gitRevision, diffHash });
211
284
  return {
212
285
  runId: run.runId,
213
286
  path: path.relative(rootDir, filePath).split(path.sep).join('/'),
@@ -219,11 +292,18 @@ async function recordVerificationCommand(rootDir, {
219
292
  // Issue #34: run several verification commands in one CLI call. Independent
220
293
  // commands run in parallel by default (`serial: true` opts out); results are
221
294
  // appended to verification.json in the given order, in one atomic write.
295
+ // `scope` tags records ('related' for the fast lane, 'full' otherwise).
296
+ // `target: 'final'` writes final-verification.json for a run whose gated
297
+ // verification was related-only. A passing record for the same command, diff,
298
+ // and revision is reused unless `fresh` is set.
222
299
  async function recordVerificationCommands(rootDir, {
223
300
  runId,
224
301
  commands = [],
225
302
  serial = false,
226
- timeoutMs = DEFAULT_TIMEOUT_MS
303
+ timeoutMs = DEFAULT_TIMEOUT_MS,
304
+ scope = null,
305
+ target = 'verification',
306
+ fresh = false
227
307
  } = {}) {
228
308
  if (!Array.isArray(commands) || commands.length === 0) {
229
309
  throw recorderError('Provide at least one verification command.', 'INVALID_COMMAND');
@@ -232,14 +312,22 @@ async function recordVerificationCommands(rootDir, {
232
312
  validateRecordingRequest({ command: item.command, args: item.args || [], timeoutMs, shell: Boolean(item.shell) });
233
313
  }
234
314
  const run = resolveRun(rootDir, runId);
235
- if (run.artifacts?.verification) {
315
+ const final = target === 'final';
316
+ if (!final && run.artifacts?.verification) {
236
317
  throw recorderError('Verification has already passed its gate. Do not mutate gated evidence; start a new verification iteration instead.', 'VERIFICATION_ALREADY_GATED');
237
318
  }
238
319
  const diffHash = resolveDiff(rootDir, run);
239
320
  const gitRevision = getGitRevision(rootDir);
240
- const filePath = path.join(runsDir(rootDir), run.runId, 'verification.json');
321
+ const filePath = path.join(runsDir(rootDir), run.runId, final ? 'final-verification.json' : 'verification.json');
241
322
  const bundle = readExistingBundle(filePath, { runId: run.runId, gitRevision, diffHash });
242
- const exec = (item) => runCommand(item.command, item.args || [], { cwd: rootDir, timeoutMs, shell: Boolean(item.shell) });
323
+ const exec = async (item) => {
324
+ const display = displayCommand(item.command, item.args || []);
325
+ const previous = fresh ? null : bundle.commands.find((record) => record.command === display && passedRecord(record)
326
+ && (record.scope || 'full') === (scope || 'full'));
327
+ if (previous) return { ...previous, reused: true };
328
+ const result = await runCommand(item.command, item.args || [], { cwd: rootDir, timeoutMs, shell: Boolean(item.shell) });
329
+ return scope ? { ...result, scope } : result;
330
+ };
243
331
  let results;
244
332
  if (serial) {
245
333
  results = [];
@@ -247,15 +335,15 @@ async function recordVerificationCommands(rootDir, {
247
335
  } else {
248
336
  results = await Promise.all(commands.map(exec));
249
337
  }
250
- bundle.commands.push(...results);
251
- atomicWriteJson(filePath, bundle);
252
- const summary = writeVerificationSummary(rootDir, { runId: run.runId }).summary;
338
+ const summary = appendRecordedCommands(rootDir, run.runId, results.filter((result) => !result.reused), {
339
+ filePath, gitRevision, diffHash, final
340
+ });
253
341
  return {
254
342
  runId: run.runId,
255
343
  path: path.relative(rootDir, filePath).split(path.sep).join('/'),
256
344
  commands: results,
257
345
  summary,
258
- passed: results.every((r) => r.exitCode === 0 && r.timeoutStatus === 'COMPLETED')
346
+ passed: results.every(passedRecord)
259
347
  };
260
348
  }
261
349
 
@@ -2,8 +2,10 @@
2
2
 
3
3
  const fs = require('fs');
4
4
  const path = require('path');
5
+ const { ACTOR_ID } = require('./fsutil.js');
5
6
  const { sha256 } = require('./recipe.js');
6
7
  const { redactSecrets } = require('./safe-context.js');
8
+ const { repairJsonlTail, splitJsonlLines } = require('./runtime-files.js');
7
9
  const {
8
10
  RUN_STATES,
9
11
  atomicWriteJson,
@@ -205,7 +207,7 @@ function readEvents(filePath, runId, graphHash) {
205
207
  throw runtimeError('Workflow event log must be a regular file', 'INVALID_WORKFLOW_EVENTS');
206
208
  }
207
209
  const text = fs.readFileSync(filePath, 'utf8');
208
- const events = text.split('\n').filter(Boolean).map((line, index) => {
210
+ const events = splitJsonlLines(text).lines.map((line, index) => {
209
211
  try {
210
212
  return JSON.parse(line);
211
213
  } catch (cause) {
@@ -286,6 +288,7 @@ function appendEvent(filePath, event) {
286
288
  const noFollow = fs.constants.O_NOFOLLOW || 0;
287
289
  let descriptor;
288
290
  try {
291
+ repairJsonlTail(filePath);
289
292
  descriptor = fs.openSync(
290
293
  filePath,
291
294
  fs.constants.O_APPEND | fs.constants.O_WRONLY | noFollow
@@ -431,7 +434,7 @@ function resetLoopNodes(workflow, group, iteration, now) {
431
434
  }
432
435
 
433
436
  function assertDecisionActor(actor) {
434
- if (!/^[A-Za-z0-9@._-]{1,64}$/.test(String(actor || ''))) {
437
+ if (!ACTOR_ID.test(String(actor || ''))) {
435
438
  throw runtimeError('actor must be a short account identifier', 'INVALID_LOOP_ACTOR');
436
439
  }
437
440
  }
@@ -950,7 +953,7 @@ function retryWorkflowNode(rootDir, nodeId, { runId, now = new Date() } = {}) {
950
953
  function approveWorkflowNode(rootDir, nodeId, { runId, approvedBy = 'human', now = new Date() } = {}) {
951
954
  const resolved = resolveRunId(rootDir, runId);
952
955
  return withWorkflowLock(rootDir, resolved, () => {
953
- if (!/^[A-Za-z0-9@._-]{1,64}$/.test(approvedBy)) {
956
+ if (!ACTOR_ID.test(approvedBy)) {
954
957
  throw runtimeError('approvedBy must be a short account identifier', 'INVALID_APPROVER');
955
958
  }
956
959
  const workflow = loadWorkflow(rootDir, resolved);
@@ -1080,7 +1083,7 @@ function cancelWorkflowRun(
1080
1083
  const resolved = resolveRunId(rootDir, runId);
1081
1084
  return withWorkflowLock(rootDir, resolved, () => {
1082
1085
  let workflow = loadWorkflow(rootDir, resolved);
1083
- if (!/^[A-Za-z0-9@._-]{1,64}$/.test(String(actor))) {
1086
+ if (!ACTOR_ID.test(String(actor))) {
1084
1087
  throw runtimeError('Cancellation actor must be a short account identifier', 'INVALID_RUN_ACTOR');
1085
1088
  }
1086
1089
  const cleanReason = redactSecrets(String(reason || '').trim()).text;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-loop",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "description": "A visual workspace that helps AI coding agents plan, build, review, and ship reliable software.",
5
5
  "main": "bin/ai-engineering-loop.js",
6
6
  "bin": {
@@ -22,7 +22,6 @@
22
22
  ".agents/",
23
23
  ".grok/",
24
24
  ".claude/agents/",
25
- ".claude/skills/",
26
25
  "LICENSE",
27
26
  "THIRD_PARTY_NOTICES.md",
28
27
  "CHANGELOG.md",
@@ -11,7 +11,7 @@ Host files (`.claude/agents/`, `.grok/agents/`, `.agents/`) may differ only in Y
11
11
 
12
12
  ## Shared spawn rules
13
13
 
14
- - Write `git diff` to `.ai-engineering-loop/tasks/current.diff` before review.
14
+ - Reviewers read the `review-pack` output or `RUN_DIR/diff.patch`; do not write a separate `tasks/current.diff`.
15
15
  - Pass artifact **paths**, not Maker chat.
16
16
  - Use the runtime policy `reviewProfile` to size context packs. Default `lean` protects Codex/GPT Plus-style sessions from repeated full-file prompts while keeping all gates intact.
17
17
  - Prefer `npx ai-engineering-loop context diff-hunks --run <run-id>` for review. It writes a private hunk-only pack with file summaries and unresolved findings, so reviewers do not need full source bodies unless a cited hunk is insufficient.