ai-engineering-loop 1.13.0 → 1.15.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 (117) hide show
  1. package/.agents/skills/ai-engineering-loop/SKILL.md +62 -0
  2. package/.agents/skills/ai-engineering-loop/references/loop-commands.md +20 -0
  3. package/.agents/skills/ai-engineering-loop/references/loop-deliver.md +8 -0
  4. package/.agents/skills/ai-engineering-loop/references/loop-goal.md +10 -0
  5. package/.agents/skills/ai-engineering-loop/references/loop-hosts.md +44 -0
  6. package/.agents/skills/ai-engineering-loop/references/loop-maker.md +8 -0
  7. package/.agents/skills/ai-engineering-loop/references/loop-review.md +18 -0
  8. package/.agents/skills/ai-engineering-loop/references/loop-risky.md +9 -0
  9. package/.agents/skills/ai-engineering-loop/references/loop-verify.md +20 -0
  10. package/.claude/skills/ai-engineering-loop/SKILL.md +28 -47
  11. package/.claude/skills/ai-engineering-loop/references/loop-commands.md +20 -0
  12. package/.claude/skills/ai-engineering-loop/references/loop-deliver.md +8 -0
  13. package/.claude/skills/ai-engineering-loop/references/loop-goal.md +10 -0
  14. package/.claude/skills/ai-engineering-loop/references/loop-hosts.md +44 -0
  15. package/.claude/skills/ai-engineering-loop/references/loop-maker.md +8 -0
  16. package/.claude/skills/ai-engineering-loop/references/loop-review.md +18 -0
  17. package/.claude/skills/ai-engineering-loop/references/loop-risky.md +9 -0
  18. package/.claude/skills/ai-engineering-loop/references/loop-verify.md +20 -0
  19. package/CHANGELOG.md +116 -0
  20. package/README.md +90 -5
  21. package/README.npm.md +6 -2
  22. package/THIRD_PARTY_NOTICES.md +29 -0
  23. package/adapters/dot/README.md +1 -1
  24. package/adapters/dot/skills/dot-dev-skill-router/SKILL.md +24 -16
  25. package/adapters/project-onboarding/SKILL.md +27 -0
  26. package/adapters/project-onboarding/references/output.md +29 -0
  27. package/adapters/quality/skills/ael-code-simplifier/SKILL.md +43 -0
  28. package/adapters/quality/skills/ael-receiving-code-review/SKILL.md +37 -0
  29. package/bin/ai-engineering-loop.js +1270 -75
  30. package/core/grill-policy.md +1 -1
  31. package/core/root-cause-analysis.md +6 -0
  32. package/core/runtime-safety.md +31 -3
  33. package/evals/cases/21-tier-t0-docs.json +34 -0
  34. package/evals/cases/22-tier-t1-small-pass.json +30 -0
  35. package/evals/cases/23-tier-t1-blocker.json +26 -0
  36. package/evals/cases/24-tier-t1-auth-escalates.json +30 -0
  37. package/lib/auto-update.js +488 -0
  38. package/lib/budget.js +31 -1
  39. package/lib/cli-args.js +95 -0
  40. package/lib/docs.js +91 -0
  41. package/lib/doctor.js +9 -14
  42. package/lib/gates.js +114 -1
  43. package/lib/host-skill-build.js +121 -0
  44. package/lib/hosts/agent-formats.js +135 -0
  45. package/lib/hosts/commands.js +126 -0
  46. package/lib/hosts/detect.js +56 -0
  47. package/lib/hosts/doctor.js +76 -0
  48. package/lib/hosts/redetect.js +60 -0
  49. package/lib/hosts/registry.js +271 -0
  50. package/lib/hosts/table.js +35 -0
  51. package/lib/migrations.js +84 -0
  52. package/lib/project-registry.js +148 -0
  53. package/lib/run-abandon.js +116 -0
  54. package/lib/run-state.js +6 -3
  55. package/lib/sync-hosts.js +456 -130
  56. package/lib/tier.js +134 -0
  57. package/lib/update-manager.js +17 -1
  58. package/lib/update-notice.js +192 -0
  59. package/lib/user-state.js +80 -0
  60. package/lib/verification-recorder.js +44 -0
  61. package/migrations/README.md +21 -0
  62. package/package.json +8 -4
  63. package/.agents/devil-advocate.md +0 -79
  64. package/.agents/judge.md +0 -58
  65. package/.agents/workflows/ai-engineering-loop.md +0 -24
  66. package/.claude/commands/ai-engineering-loop.md +0 -11
  67. package/.gemini/skills/ai-engineering-loop/SKILL.md +0 -74
  68. package/.gemini/skills/animate/RECIPES.md +0 -324
  69. package/.gemini/skills/animate/SKILL.md +0 -207
  70. package/.gemini/skills/animate-expo/RECIPES.md +0 -385
  71. package/.gemini/skills/animate-expo/SKILL.md +0 -263
  72. package/.gemini/skills/animation-vocabulary/SKILL.md +0 -181
  73. package/.gemini/skills/apple-design/SKILL.md +0 -290
  74. package/.gemini/skills/ask-sonner/API.md +0 -64
  75. package/.gemini/skills/ask-sonner/SKILL.md +0 -88
  76. package/.gemini/skills/backend-development/SKILL.md +0 -272
  77. package/.gemini/skills/backend-development/references/api-design-guidelines.md +0 -95
  78. package/.gemini/skills/backend-development/references/query-and-database-best-practices.md +0 -53
  79. package/.gemini/skills/backend-development/references/security-checklist.md +0 -60
  80. package/.gemini/skills/emil-design-eng/SKILL.md +0 -674
  81. package/.gemini/skills/find-animation-opportunities/SKILL.md +0 -140
  82. package/.gemini/skills/improve-animations/AUDIT.md +0 -115
  83. package/.gemini/skills/improve-animations/PLAN-TEMPLATE.md +0 -73
  84. package/.gemini/skills/improve-animations/SKILL.md +0 -109
  85. package/.gemini/skills/mobile-native/SKILL.md +0 -311
  86. package/.gemini/skills/pick-ui-library/SKILL.md +0 -85
  87. package/.gemini/skills/prototype/PICKER.md +0 -197
  88. package/.gemini/skills/prototype/SKILL.md +0 -98
  89. package/.gemini/skills/review-animations/SKILL.md +0 -120
  90. package/.gemini/skills/review-animations/STANDARDS.md +0 -187
  91. package/.gemini/skills/write-swift/SKILL.md +0 -396
  92. package/.grok/commands/ai-engineering-loop.md +0 -11
  93. package/.grok/skills/ai-engineering-loop/SKILL.md +0 -94
  94. package/.grok/skills/animate/RECIPES.md +0 -324
  95. package/.grok/skills/animate/SKILL.md +0 -207
  96. package/.grok/skills/animate-expo/RECIPES.md +0 -385
  97. package/.grok/skills/animate-expo/SKILL.md +0 -263
  98. package/.grok/skills/animation-vocabulary/SKILL.md +0 -181
  99. package/.grok/skills/apple-design/SKILL.md +0 -290
  100. package/.grok/skills/ask-sonner/API.md +0 -64
  101. package/.grok/skills/ask-sonner/SKILL.md +0 -88
  102. package/.grok/skills/backend-development/SKILL.md +0 -272
  103. package/.grok/skills/backend-development/references/api-design-guidelines.md +0 -95
  104. package/.grok/skills/backend-development/references/query-and-database-best-practices.md +0 -53
  105. package/.grok/skills/backend-development/references/security-checklist.md +0 -60
  106. package/.grok/skills/emil-design-eng/SKILL.md +0 -674
  107. package/.grok/skills/find-animation-opportunities/SKILL.md +0 -140
  108. package/.grok/skills/improve-animations/AUDIT.md +0 -115
  109. package/.grok/skills/improve-animations/PLAN-TEMPLATE.md +0 -73
  110. package/.grok/skills/improve-animations/SKILL.md +0 -109
  111. package/.grok/skills/mobile-native/SKILL.md +0 -311
  112. package/.grok/skills/pick-ui-library/SKILL.md +0 -85
  113. package/.grok/skills/prototype/PICKER.md +0 -197
  114. package/.grok/skills/prototype/SKILL.md +0 -98
  115. package/.grok/skills/review-animations/SKILL.md +0 -120
  116. package/.grok/skills/review-animations/STANDARDS.md +0 -187
  117. package/.grok/skills/write-swift/SKILL.md +0 -396
package/lib/tier.js ADDED
@@ -0,0 +1,134 @@
1
+ 'use strict';
2
+
3
+ // Task tiers (issue #33). Gates stay; only the number of stages that run
4
+ // depends on risk.
5
+ // T0 trivial: inline AC, Maker, verification, claimed-vs-reality, delivery. 0 subagents.
6
+ // T1 normal: failure-table Goal, TDD, verification, lean DA, deterministic review. 1 subagent.
7
+ // T2 risky: full flow (grill + blast radius, DA, Judge on STRONG_MODEL). 2 subagents.
8
+ // A tier can rise automatically (never fall) when the Maker diff shows more risk.
9
+
10
+ const { extractChangedPaths, isHighRiskPath } = require('./escalation.js');
11
+
12
+ const TIERS = Object.freeze({ T0: 'T0', T1: 'T1', T2: 'T2' });
13
+ const TIER_RANK = Object.freeze({ T0: 0, T1: 1, T2: 2 });
14
+
15
+ const T0_LIMITS = Object.freeze({ maxFiles: 3, maxChangedLines: 180 });
16
+ const T2_FILE_THRESHOLD = 10;
17
+
18
+ const TRIVIAL_TASK = /\b(typo|typos|spelling|docs?|documentation|readme|changelog|comment|comments|lint|linting|format|formatting|prettier|bump|version bump|wording|copy edit)\b/i;
19
+ const RISKY_TASK = /\b(auth|authentication|authorization|login|permission|permissions|rbac|payment|payments|billing|invoice|ledger|migration|migrations|schema|database|encrypt|encryption|crypto|secret|secrets|token|credential|credentials|security|vulnerability|deploy|deployment|infra|terraform|kubernetes|k8s)\b/i;
20
+ const DOC_PATH = /(^|\/)(docs?\/.*|[^/]+\.(md|mdx|txt|rst|adoc)|LICENSE[^/]*|CHANGELOG[^/]*|\.github\/ISSUE_TEMPLATE\/.*)$/i;
21
+
22
+ function normalizeTier(value) {
23
+ const tier = String(value || '').trim().toUpperCase();
24
+ if (!Object.hasOwn(TIERS, tier)) {
25
+ const err = new Error(`Invalid tier "${value}". Use T0, T1, or T2.`);
26
+ err.code = 'INVALID_TIER';
27
+ throw err;
28
+ }
29
+ return tier;
30
+ }
31
+
32
+ function maxTier(a, b) {
33
+ return TIER_RANK[a] >= TIER_RANK[b] ? a : b;
34
+ }
35
+
36
+ function changedLineCount(diff) {
37
+ let count = 0;
38
+ for (const line of String(diff || '').split('\n')) {
39
+ if ((line.startsWith('+') && !line.startsWith('+++')) || (line.startsWith('-') && !line.startsWith('---'))) count += 1;
40
+ }
41
+ return count;
42
+ }
43
+
44
+ // Classify from the task text and any paths already known (working tree at
45
+ // `run`, Maker diff later). Returns { tier, reasons: [{ code, detail }] }.
46
+ function classifyTier({ task = '', changedPaths = [], changedLines = null } = {}) {
47
+ const reasons = [];
48
+ const riskyPaths = changedPaths.filter(isHighRiskPath);
49
+ const riskyWord = String(task).match(RISKY_TASK);
50
+ if (riskyPaths.length) reasons.push({ code: 'HIGH_RISK_PATH', detail: riskyPaths.join(', '), tier: 'T2' });
51
+ if (riskyWord) reasons.push({ code: 'RISKY_TASK_TEXT', detail: riskyWord[0], tier: 'T2' });
52
+ if (changedPaths.length > T2_FILE_THRESHOLD) {
53
+ reasons.push({ code: 'MANY_FILES', detail: `${changedPaths.length} files > ${T2_FILE_THRESHOLD}`, tier: 'T2' });
54
+ }
55
+ if (reasons.length) return { tier: TIERS.T2, reasons };
56
+
57
+ const trivialWord = String(task).match(TRIVIAL_TASK);
58
+ const docsOnly = changedPaths.length > 0 && changedPaths.every((p) => DOC_PATH.test(p));
59
+ const small = changedPaths.length <= T0_LIMITS.maxFiles
60
+ && (changedLines == null || changedLines <= T0_LIMITS.maxChangedLines);
61
+ if (small && (trivialWord || docsOnly)) {
62
+ if (trivialWord) reasons.push({ code: 'TRIVIAL_TASK_TEXT', detail: trivialWord[0], tier: 'T0' });
63
+ if (docsOnly) reasons.push({ code: 'DOCS_ONLY_PATHS', detail: changedPaths.join(', '), tier: 'T0' });
64
+ return { tier: TIERS.T0, reasons };
65
+ }
66
+ reasons.push({ code: 'DEFAULT', detail: 'normal change', tier: 'T1' });
67
+ return { tier: TIERS.T1, reasons };
68
+ }
69
+
70
+ function initialTierState({ task, changedPaths = [], override = null, overrideReason = '', now = new Date() } = {}) {
71
+ const auto = classifyTier({ task, changedPaths });
72
+ if (override) {
73
+ const tier = normalizeTier(override);
74
+ const reason = String(overrideReason || '').trim();
75
+ if (!reason) {
76
+ const err = new Error('--tier requires --tier-reason "<why>" so the override is recorded.');
77
+ err.code = 'TIER_REASON_REQUIRED';
78
+ throw err;
79
+ }
80
+ return {
81
+ current: tier,
82
+ auto: auto.tier,
83
+ source: 'override',
84
+ reasons: [{ code: 'MANUAL_OVERRIDE', detail: reason.slice(0, 500), tier }, ...auto.reasons],
85
+ history: [{ from: null, to: tier, by: 'override', reason: reason.slice(0, 500), at: now.toISOString() }]
86
+ };
87
+ }
88
+ return {
89
+ current: auto.tier,
90
+ auto: auto.tier,
91
+ source: 'auto',
92
+ reasons: auto.reasons,
93
+ history: [{ from: null, to: auto.tier, by: 'run', at: now.toISOString() }]
94
+ };
95
+ }
96
+
97
+ // Re-assess from the gated Maker diff. Only raises the tier.
98
+ function raiseTierFromDiff(tierState, { task = '', diff = '', now = new Date() } = {}) {
99
+ if (!tierState || !tierState.current) return null;
100
+ const changedPaths = extractChangedPaths(diff);
101
+ const changedLines = changedLineCount(diff);
102
+ const assessed = classifyTier({ task: '', changedPaths, changedLines });
103
+ let next = assessed.tier;
104
+ // T0 must also stay inside T0 limits: a code diff that is not trivial by
105
+ // text or docs-only paths becomes T1.
106
+ if (tierState.current === TIERS.T0 && next === TIERS.T1) {
107
+ const stillTrivial = classifyTier({ task, changedPaths, changedLines }).tier === TIERS.T0;
108
+ if (stillTrivial) next = TIERS.T0;
109
+ }
110
+ const raised = maxTier(tierState.current, next);
111
+ if (raised === tierState.current) return null;
112
+ return {
113
+ ...tierState,
114
+ current: raised,
115
+ reasons: [...assessed.reasons.filter((r) => r.tier === raised), ...tierState.reasons],
116
+ history: [
117
+ ...(tierState.history || []),
118
+ { from: tierState.current, to: raised, by: 'maker-diff', reason: assessed.reasons.map((r) => r.code).join(',') || 'T0 limits exceeded', at: now.toISOString() }
119
+ ]
120
+ };
121
+ }
122
+
123
+ module.exports = {
124
+ TIERS,
125
+ TIER_RANK,
126
+ T0_LIMITS,
127
+ T2_FILE_THRESHOLD,
128
+ normalizeTier,
129
+ maxTier,
130
+ changedLineCount,
131
+ classifyTier,
132
+ initialTierState,
133
+ raiseTierFromDiff
134
+ };
@@ -108,10 +108,26 @@ function buildUpdatePlan({ packageName, currentVersion, latestVersion, installSc
108
108
  installScope,
109
109
  updateAvailable: comparison < 0,
110
110
  upToDate: comparison >= 0,
111
- commands: updateCommands(packageName, installScope)
111
+ commands: withMigrationStep(updateCommands(packageName, installScope), { currentVersion, latestVersion, installScope })
112
112
  };
113
113
  }
114
114
 
115
+ // Crossing a major: run the new version's migrations right after the install
116
+ // (decision 6 on #37; see migrations/README.md).
117
+ function withMigrationStep(commands, { currentVersion, latestVersion, installScope }) {
118
+ let crosses = false;
119
+ try {
120
+ crosses = parseVersion(latestVersion)[0] > parseVersion(currentVersion)[0];
121
+ } catch {
122
+ crosses = false;
123
+ }
124
+ if (!crosses) return commands;
125
+ const step = installScope === 'global'
126
+ ? command('ai-engineering-loop', ['migrate', '--from', currentVersion])
127
+ : command('npx', ['ai-engineering-loop', 'migrate', '--from', currentVersion]);
128
+ return [commands[0], step, ...commands.slice(1)];
129
+ }
130
+
115
131
  function checkForUpdate(rootDir, {
116
132
  latestVersion,
117
133
  installScope,
@@ -0,0 +1,192 @@
1
+ 'use strict';
2
+
3
+ // Update notice (decision 1 on #37). Project installs are notify-only, so the
4
+ // notice has to be worth reading: current -> target, 2-4 changelog highlights
5
+ // for the versions in between, one copy-pasteable command for the detected
6
+ // package manager, and how to silence it. Shown on an interactive stderr only,
7
+ // at most once per 24 hours per project, never in CI or --json output.
8
+
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const https = require('https');
12
+ const { compareVersions } = require('./update-manager.js');
13
+
14
+ const NOTICE_INTERVAL_MS = 24 * 60 * 60 * 1000;
15
+ const MAX_HIGHLIGHTS = 4;
16
+ const truthy = (value) => ['1', 'true', 'yes'].includes(String(value || '').trim().toLowerCase());
17
+
18
+ function detectPackageManager(projectDir) {
19
+ const has = (file) => fs.existsSync(path.join(projectDir, file));
20
+ try {
21
+ const pkg = JSON.parse(fs.readFileSync(path.join(projectDir, 'package.json'), 'utf8'));
22
+ const declared = String(pkg.packageManager || '').split('@')[0];
23
+ if (['npm', 'pnpm', 'yarn', 'bun'].includes(declared)) return declared;
24
+ } catch {
25
+ // No package.json: fall through to lockfiles.
26
+ }
27
+ if (has('pnpm-lock.yaml')) return 'pnpm';
28
+ if (has('yarn.lock')) return 'yarn';
29
+ if (has('bun.lockb') || has('bun.lock')) return 'bun';
30
+ return 'npm';
31
+ }
32
+
33
+ // Global installs: infer the manager from where this package lives.
34
+ function detectGlobalPackageManager(packageRoot) {
35
+ const p = String(packageRoot).replace(/\\/g, '/').toLowerCase();
36
+ if (p.includes('/pnpm/')) return 'pnpm';
37
+ if (p.includes('/.bun/')) return 'bun';
38
+ if (p.includes('/yarn/')) return 'yarn';
39
+ return 'npm';
40
+ }
41
+
42
+ function updateCommand({ packageName, target, scope, manager }) {
43
+ const spec = `${packageName}@${target}`;
44
+ if (scope === 'global') {
45
+ return {
46
+ npm: `npm install -g ${spec}`,
47
+ pnpm: `pnpm add -g ${spec}`,
48
+ yarn: `yarn global add ${spec}`,
49
+ bun: `bun add -g ${spec}`
50
+ }[manager] || `npm install -g ${spec}`;
51
+ }
52
+ return {
53
+ npm: `npm install -D ${spec}`,
54
+ pnpm: `pnpm add -D ${spec}`,
55
+ yarn: `yarn add -D ${spec}`,
56
+ bun: `bun add -d ${spec}`
57
+ }[manager] || `npm install -D ${spec}`;
58
+ }
59
+
60
+ function clean(line) {
61
+ return line
62
+ .replace(/^\s*[-*]\s+/, '')
63
+ .replace(/^#+\s+/, '')
64
+ .replace(/\*\*([^*]+?):?\*\*:?\s*/g, '$1: ')
65
+ .replace(/`([^`]+)`/g, '$1')
66
+ .replace(/\s*\(#\d+\)\s*$/, '')
67
+ .replace(/\s+/g, ' ')
68
+ .trim();
69
+ }
70
+
71
+ function truncate(text, max = 96) {
72
+ return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;
73
+ }
74
+
75
+ // Highlights from CHANGELOG sections `## <version>` with current < version <= target.
76
+ // Prefers `###` subsection titles (they summarize a change); falls back to bullets.
77
+ function changelogHighlights(changelog, { current, target, max = MAX_HIGHLIGHTS } = {}) {
78
+ const lines = String(changelog || '').replace(/\r\n?/g, '\n').split('\n');
79
+ const titles = [];
80
+ const bullets = [];
81
+ let inRange = false;
82
+ for (const line of lines) {
83
+ const version = line.match(/^##\s+\[?v?(\d+\.\d+\.\d+(?:-[\w.]+)?)\]?/);
84
+ if (version) {
85
+ try {
86
+ inRange = compareVersions(version[1], current) > 0 && compareVersions(version[1], target) <= 0;
87
+ } catch {
88
+ inRange = false;
89
+ }
90
+ continue;
91
+ }
92
+ if (/^##\s/.test(line)) {
93
+ inRange = false;
94
+ continue;
95
+ }
96
+ if (!inRange) continue;
97
+ if (/^###\s/.test(line)) titles.push(truncate(clean(line)));
98
+ else if (/^\s*[-*]\s+\S/.test(line)) bullets.push(truncate(clean(line)));
99
+ }
100
+ const picked = titles.length >= 2 ? titles : [...titles, ...bullets];
101
+ return picked.filter(Boolean).slice(0, max);
102
+ }
103
+
104
+ function formatNotice({ packageName, current, target, bump, scope, manager, highlights = [], policy, reason }) {
105
+ const lines = [`ai-engineering-loop ${current} -> ${target} available (${bump}).`];
106
+ for (const item of highlights.slice(0, MAX_HIGHLIGHTS)) lines.push(` • ${item}`);
107
+ if (bump === 'major') lines.push(' Major release: read the migration notes in CHANGELOG.md before updating.');
108
+ const cmd = updateCommand({ packageName, target, scope, manager });
109
+ lines.push(` Update: ${scope === 'global' && bump !== 'major' && policy === 'notify' ? `${cmd} (or auto-apply: ai-engineering-loop update policy minor)` : cmd}`);
110
+ if (scope === 'global') lines.push(' Then: ai-engineering-loop sync-hosts');
111
+ lines.push(' Silence: AEL_NO_UPDATE_NOTICE=1, or ai-engineering-loop update policy off');
112
+ if (reason === 'PINNED') lines.push(' (outside your pin; change it with update policy --pin)');
113
+ return lines.join('\n');
114
+ }
115
+
116
+ // Where and how often the notice may appear.
117
+ function noticeAllowed({ env = process.env, argv = process.argv, stderrIsTTY = process.stderr.isTTY } = {}) {
118
+ if (truthy(env.AEL_NO_UPDATE_NOTICE) || truthy(env.CI)) return false;
119
+ if (argv.includes('--json')) return false;
120
+ return Boolean(stderrIsTTY) || truthy(env.AEL_FORCE_UPDATE_NOTICE);
121
+ }
122
+
123
+ function noticeDue(cache, projectKey, now = new Date()) {
124
+ const last = cache && cache.notices && cache.notices[projectKey];
125
+ if (!last || !last.at) return true;
126
+ const age = now.getTime() - Date.parse(last.at);
127
+ return !(age >= 0 && age < NOTICE_INTERVAL_MS);
128
+ }
129
+
130
+ function markNoticeShown(cache, projectKey, target, now = new Date()) {
131
+ const notices = { ...(cache.notices || {}) };
132
+ notices[projectKey] = { version: target, at: now.toISOString() };
133
+ // Keep the map small.
134
+ const keys = Object.keys(notices);
135
+ if (keys.length > 200) for (const key of keys.slice(0, keys.length - 200)) delete notices[key];
136
+ return { ...cache, notices };
137
+ }
138
+
139
+ // Background only: the target's CHANGELOG.md from the npm CDN (package files)
140
+ // or the GitHub tag. Resolves null on any failure; 3 s budget per request.
141
+ function fetchText(url, timeoutMs) {
142
+ return new Promise((resolve) => {
143
+ const req = https.get(url, { timeout: timeoutMs, headers: { 'user-agent': 'ai-engineering-loop' } }, (res) => {
144
+ if (res.statusCode !== 200) {
145
+ res.resume();
146
+ resolve(null);
147
+ return;
148
+ }
149
+ let body = '';
150
+ res.setEncoding('utf8');
151
+ res.on('data', (chunk) => {
152
+ body += chunk;
153
+ if (body.length > 512 * 1024) req.destroy();
154
+ });
155
+ res.on('end', () => resolve(body));
156
+ });
157
+ req.on('timeout', () => req.destroy());
158
+ req.on('error', () => resolve(null));
159
+ });
160
+ }
161
+
162
+ async function fetchChangelog({ packageName, target, repositorySlug, env = process.env, timeoutMs = 3000 }) {
163
+ if (env.AEL_UPDATE_CHANGELOG_FILE) {
164
+ try {
165
+ return fs.readFileSync(env.AEL_UPDATE_CHANGELOG_FILE, 'utf8');
166
+ } catch {
167
+ return null;
168
+ }
169
+ }
170
+ if (truthy(env.AEL_UPDATE_OFFLINE)) return null;
171
+ const urls = [`https://cdn.jsdelivr.net/npm/${packageName}@${target}/CHANGELOG.md`];
172
+ if (repositorySlug) urls.push(`https://raw.githubusercontent.com/${repositorySlug}/v${target}/CHANGELOG.md`);
173
+ for (const url of urls) {
174
+ const text = await fetchText(url, timeoutMs);
175
+ if (text) return text;
176
+ }
177
+ return null;
178
+ }
179
+
180
+ module.exports = {
181
+ NOTICE_INTERVAL_MS,
182
+ MAX_HIGHLIGHTS,
183
+ detectPackageManager,
184
+ detectGlobalPackageManager,
185
+ updateCommand,
186
+ changelogHighlights,
187
+ formatNotice,
188
+ noticeAllowed,
189
+ noticeDue,
190
+ markNoticeShown,
191
+ fetchChangelog
192
+ };
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ // User-level (per machine) AEL state lives in <home>/.ai-engineering-loop/.
4
+ // It is never part of a repository. `home` resolves AEL_HOME first so tests and
5
+ // sandboxes never touch the real home directory.
6
+
7
+ const crypto = require('crypto');
8
+ const fs = require('fs');
9
+ const os = require('os');
10
+ const path = require('path');
11
+
12
+ function homeDir(env = process.env) {
13
+ if (env.AEL_HOME) return env.AEL_HOME;
14
+ return os.homedir();
15
+ }
16
+
17
+ function userStateDir(home = homeDir()) {
18
+ return path.join(home, '.ai-engineering-loop');
19
+ }
20
+
21
+ function userStatePath(name, home = homeDir()) {
22
+ if (!/^[a-z0-9][a-z0-9.-]*$/.test(name)) throw new Error(`Invalid user-state file name: ${name}`);
23
+ return path.join(userStateDir(home), name);
24
+ }
25
+
26
+ function sha256(content) {
27
+ return crypto.createHash('sha256').update(content).digest('hex');
28
+ }
29
+
30
+ function atomicWritePrivate(filePath, content) {
31
+ fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
32
+ const temporary = `${filePath}.${process.pid}.${crypto.randomBytes(4).toString('hex')}.tmp`;
33
+ try {
34
+ fs.writeFileSync(temporary, content, { mode: 0o600 });
35
+ fs.renameSync(temporary, filePath);
36
+ } finally {
37
+ try {
38
+ fs.unlinkSync(temporary);
39
+ } catch {
40
+ // Rename succeeded or nothing was written.
41
+ }
42
+ }
43
+ }
44
+
45
+ function readJsonFile(filePath, fallback) {
46
+ try {
47
+ const stat = fs.lstatSync(filePath);
48
+ if (stat.isSymbolicLink()) return fallback;
49
+ return JSON.parse(fs.readFileSync(filePath, 'utf8'));
50
+ } catch {
51
+ return fallback;
52
+ }
53
+ }
54
+
55
+ function writeJsonFile(filePath, value) {
56
+ atomicWritePrivate(filePath, `${JSON.stringify(value, null, 2)}\n`);
57
+ }
58
+
59
+ function readUserConfig(home = homeDir()) {
60
+ const value = readJsonFile(userStatePath('config.json', home), {});
61
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
62
+ }
63
+
64
+ function writeUserConfig(patch, home = homeDir()) {
65
+ const next = { ...readUserConfig(home), ...patch };
66
+ writeJsonFile(userStatePath('config.json', home), next);
67
+ return next;
68
+ }
69
+
70
+ module.exports = {
71
+ homeDir,
72
+ userStateDir,
73
+ userStatePath,
74
+ sha256,
75
+ atomicWritePrivate,
76
+ readJsonFile,
77
+ writeJsonFile,
78
+ readUserConfig,
79
+ writeUserConfig
80
+ };
@@ -216,7 +216,51 @@ async function recordVerificationCommand(rootDir, {
216
216
  };
217
217
  }
218
218
 
219
+ // Issue #34: run several verification commands in one CLI call. Independent
220
+ // commands run in parallel by default (`serial: true` opts out); results are
221
+ // appended to verification.json in the given order, in one atomic write.
222
+ async function recordVerificationCommands(rootDir, {
223
+ runId,
224
+ commands = [],
225
+ serial = false,
226
+ timeoutMs = DEFAULT_TIMEOUT_MS
227
+ } = {}) {
228
+ if (!Array.isArray(commands) || commands.length === 0) {
229
+ throw recorderError('Provide at least one verification command.', 'INVALID_COMMAND');
230
+ }
231
+ for (const item of commands) {
232
+ validateRecordingRequest({ command: item.command, args: item.args || [], timeoutMs, shell: Boolean(item.shell) });
233
+ }
234
+ const run = resolveRun(rootDir, runId);
235
+ if (run.artifacts?.verification) {
236
+ throw recorderError('Verification has already passed its gate. Do not mutate gated evidence; start a new verification iteration instead.', 'VERIFICATION_ALREADY_GATED');
237
+ }
238
+ const diffHash = resolveDiff(rootDir, run);
239
+ const gitRevision = getGitRevision(rootDir);
240
+ const filePath = path.join(runsDir(rootDir), run.runId, 'verification.json');
241
+ 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) });
243
+ let results;
244
+ if (serial) {
245
+ results = [];
246
+ for (const item of commands) results.push(await exec(item));
247
+ } else {
248
+ results = await Promise.all(commands.map(exec));
249
+ }
250
+ bundle.commands.push(...results);
251
+ atomicWriteJson(filePath, bundle);
252
+ const summary = writeVerificationSummary(rootDir, { runId: run.runId }).summary;
253
+ return {
254
+ runId: run.runId,
255
+ path: path.relative(rootDir, filePath).split(path.sep).join('/'),
256
+ commands: results,
257
+ summary,
258
+ passed: results.every((r) => r.exitCode === 0 && r.timeoutStatus === 'COMPLETED')
259
+ };
260
+ }
261
+
219
262
  module.exports = {
263
+ recordVerificationCommands,
220
264
  DEFAULT_TIMEOUT_MS,
221
265
  MAX_CAPTURE_BYTES,
222
266
  MAX_TIMEOUT_MS,
@@ -0,0 +1,21 @@
1
+ # Major-version migrations
2
+
3
+ `update apply` runs `ai-engineering-loop migrate --from <old-version>` with the
4
+ new version whenever an update crosses a major (1.x -> 2.x). For each major in
5
+ `(old, new]` that has a `migrations/<major>.js`, AEL runs `migrateHome` once and
6
+ `migrateProject` once per registered project, and records what ran in
7
+ `~/.ai-engineering-loop/migrations.json`.
8
+
9
+ ```js
10
+ // migrations/2.js
11
+ module.exports = {
12
+ major: 2,
13
+ description: 'Rename X to Y in project context',
14
+ migrateHome({ home }) {},
15
+ migrateProject({ projectDir }) {}
16
+ };
17
+ ```
18
+
19
+ Rules: idempotent (safe to run twice), no network, touch only AEL-managed files,
20
+ and describe the change in CHANGELOG.md under the major's heading. No migration
21
+ ships yet (1.x).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-loop",
3
- "version": "1.13.0",
3
+ "version": "1.15.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": {
@@ -21,12 +21,12 @@
21
21
  "evals/",
22
22
  ".agents/",
23
23
  ".grok/",
24
- ".gemini/skills/",
25
24
  ".claude/agents/",
26
- ".claude/commands/",
27
25
  ".claude/skills/",
28
26
  "LICENSE",
29
27
  "THIRD_PARTY_NOTICES.md",
28
+ "CHANGELOG.md",
29
+ "migrations/",
30
30
  "SECURITY.md",
31
31
  "SUPPORT.md",
32
32
  "README.md"
@@ -38,7 +38,11 @@
38
38
  "eval": "node bin/ai-engineering-loop.js eval",
39
39
  "audit:package": "node scripts/audit-package.js",
40
40
  "verify:release": "node scripts/verify-release.js",
41
- "prepublishOnly": "npm test && npm run doctor && npm run eval && npm run audit:package"
41
+ "prepublishOnly": "npm run check:skills && npm test && npm run doctor && npm run eval && npm run audit:package",
42
+ "build:skills": "node scripts/build-host-skills.js",
43
+ "check:skills": "node scripts/build-host-skills.js --check",
44
+ "build:hosts-table": "node scripts/build-host-table.js",
45
+ "measure": "node scripts/measure.js"
42
46
  },
43
47
  "engines": {
44
48
  "node": ">=18"
@@ -1,79 +0,0 @@
1
- ---
2
- name: devil-advocate
3
- description: Use this agent after deterministic tests pass, to adversarially review a git diff against a Goal Contract. Returns a Finding Ledger. Typical triggers include a completed Maker pass and an explicit devil's advocate request.
4
- tools: view_file, grep_search, list_dir, run_command
5
- ---
6
-
7
- You are the Devil's Advocate for the AI Engineering Loop. You are read-only. You never modify application source and never commit.
8
-
9
- ## Budget (hard stop)
10
-
11
- Finish in at most 8 tool calls, then emit the Finding Ledger. Do not explore the rest of the repo. Do not spawn children. Do not run git log.
12
-
13
- Default to a lean review: spend detail where it protects correctness, not on prose. Treat the context pack as scarce. Prefer one precise quote over a long explanation.
14
-
15
- ## Input barrier
16
-
17
- Use only:
18
-
19
- 1. The diff or smart diff-hunk pack path in the spawn prompt. Read that file first. Do not run git diff if a diff path was given.
20
- 2. Goal Contract path (if given).
21
- 3. Verification log path (if given).
22
- 4. conventions.md path (if given). At most one extra read.
23
- 5. At most 8 source files that appear as paths in the diff.
24
-
25
- Skip: `*.css`, files named like `*-css.ts` or `report-css.ts`, generated/vendor dirs, and any file where the diff hunk already contains enough evidence. Prefer quoting the hunk over opening the whole file.
26
-
27
- Do not ask for Maker rationale.
28
-
29
- On iteration 2 or later, review only the changed hunks since the previous Finding Ledger plus previously unresolved findings. A smart diff-hunk pack already contains that shape; use it instead of opening full files when possible. Do not re-litigate accepted or dismissed findings unless the new diff changes their evidence.
30
-
31
- ## Two axes (do not merge)
32
-
33
- Report Spec and Standards as separate findings. Do not rerank one axis with the other. A change can pass Spec and fail Standards, or the reverse. Do not spawn children to split axes.
34
-
35
- **Spec** (`axis: "spec"`): Goal Contract acceptance criteria, correctness, error handling, security, concurrency, tests that fail to prove an AC, happy-path-only suite vs written failure table. BLOCKER or HIGH only for a real AC breach or runtime defect.
36
-
37
- **Standards** (`axis: "standards"`): `.ai-engineering-loop/conventions.md` plus the smell baseline below. Judgement calls: severity MEDIUM or LOW. Set `hardConvention: true` only when conventions.md states a hard rule that this hunk violates. A smell that hides an AC defect is Spec, not Standards.
38
-
39
- Skip style nits unless they hide a defect.
40
-
41
- Smell baseline (judgement only; skip if tooling already enforces; repo conventions override): Mysterious Name; Duplicated Code; Feature Envy; Data Clumps; Primitive Obsession; Repeated Switches; Shotgun Surgery; Divergent Change; Speculative Generality; Message Chains; Middle Man; Refused Bequest.
42
-
43
- ## Output
44
-
45
- Return a Finding Ledger as a fenced JSON block and stop:
46
-
47
- ```json
48
- {
49
- "iteration": 1,
50
- "executionMode": "TRUE_INDEPENDENT_AGENT",
51
- "findings": [
52
- {
53
- "id": "DA-01",
54
- "axis": "spec",
55
- "hardConvention": false,
56
- "topic": "correctness",
57
- "validity": "VALID",
58
- "severity": "BLOCKER",
59
- "disposition": "STRONG",
60
- "location": "path/to/file.ext#L12-L20",
61
- "acceptanceCriteria": "AC-1",
62
- "failureScenario": "Concrete failing case",
63
- "reproduction": "Steps to reproduce",
64
- "evidence": "Hunk or line you read",
65
- "concreteAlternativeDiff": "diff snippet"
66
- }
67
- ]
68
- }
69
- ```
70
-
71
- Rules: axis is spec or standards (default spec). hardConvention is boolean, default false. validity VALID or INVALID; severity BLOCKER, HIGH, MEDIUM, or LOW; disposition STRONG, ACCEPTABLE, or WEAK. VALID BLOCKER or HIGH must include concreteAlternativeDiff. Empty findings is allowed.
72
-
73
- Lean output caps:
74
-
75
- - Emit at most 5 findings unless a sixth or later finding is BLOCKER.
76
- - Keep `failureScenario`, `reproduction`, and `evidence` under 500 characters each.
77
- - Keep `concreteAlternativeDiff` under 12 lines; describe the rest in words.
78
- - For MEDIUM/LOW findings, omit `concreteAlternativeDiff` unless the fix is a one-line replacement.
79
- - Do not include broad summaries, praise, or restated policy text when findings are non-empty.