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
@@ -0,0 +1,148 @@
1
+ 'use strict';
2
+
3
+ // Project registry (issue #37): ~/.ai-engineering-loop/projects.json lists local
4
+ // repositories that contain `.ai-engineering-loop/`, so a CLI update can refresh
5
+ // every project. It only holds local paths and is never sent anywhere.
6
+
7
+ const fs = require('fs');
8
+ const path = require('path');
9
+ const { homeDir, userStatePath, readJsonFile, writeJsonFile } = require('./user-state.js');
10
+
11
+ const REGISTRY_FILE = 'projects.json';
12
+ const CONTEXT_DIR = '.ai-engineering-loop';
13
+ const SCAN_EXCLUDES = new Set(['node_modules', '.git', '.hg', '.svn', 'vendor', 'dist', 'build', '.next', '.cache', 'Library', 'AppData']);
14
+
15
+ // Automatic writes to the user's home are disabled by AEL_NO_REGISTRY and,
16
+ // as a safety net, inside the Node test runner unless a sandbox AEL_HOME is set.
17
+ function registryEnabled(env = process.env) {
18
+ if (env.AEL_NO_REGISTRY === '1') return false;
19
+ if (env.NODE_TEST_CONTEXT && !env.AEL_HOME) return false;
20
+ return true;
21
+ }
22
+
23
+ function registryPath(home = homeDir()) {
24
+ return userStatePath(REGISTRY_FILE, home);
25
+ }
26
+
27
+ function hasContext(dir) {
28
+ try {
29
+ return fs.statSync(path.join(dir, CONTEXT_DIR)).isDirectory();
30
+ } catch {
31
+ return false;
32
+ }
33
+ }
34
+
35
+ function readContextVersion(dir) {
36
+ const metadata = readJsonFile(path.join(dir, CONTEXT_DIR, 'metadata.json'), null);
37
+ return metadata && metadata.contextVersion ? String(metadata.contextVersion) : null;
38
+ }
39
+
40
+ function readRegistry(home = homeDir()) {
41
+ const value = readJsonFile(registryPath(home), null);
42
+ const projects = value && Array.isArray(value.projects) ? value.projects.filter((p) => p && typeof p.path === 'string') : [];
43
+ return { schemaVersion: 1, projects };
44
+ }
45
+
46
+ function writeRegistry(registry, home = homeDir()) {
47
+ const projects = [...registry.projects].sort((a, b) => a.path.localeCompare(b.path));
48
+ writeJsonFile(registryPath(home), { schemaVersion: 1, projects });
49
+ }
50
+
51
+ function canonical(dir) {
52
+ const abs = path.resolve(dir);
53
+ try {
54
+ return fs.realpathSync(abs);
55
+ } catch {
56
+ return abs;
57
+ }
58
+ }
59
+
60
+ function upsert(registry, dir, now) {
61
+ const abs = canonical(dir);
62
+ const entry = { path: abs, contextVersion: readContextVersion(abs), lastSeen: now.toISOString() };
63
+ const index = registry.projects.findIndex((p) => p.path === abs);
64
+ if (index === -1) registry.projects.push(entry);
65
+ else registry.projects[index] = { ...registry.projects[index], ...entry };
66
+ return entry;
67
+ }
68
+
69
+ // Called by init/run/status/refresh. Never throws: the registry is a convenience.
70
+ function registerProject(dir, { home = homeDir(), env = process.env, now = new Date() } = {}) {
71
+ if (!registryEnabled(env) || !hasContext(dir)) return null;
72
+ try {
73
+ const registry = readRegistry(home);
74
+ const entry = upsert(registry, dir, now);
75
+ writeRegistry(registry, home);
76
+ return entry;
77
+ } catch {
78
+ return null;
79
+ }
80
+ }
81
+
82
+ function addProject(dir, { home = homeDir(), now = new Date() } = {}) {
83
+ if (!hasContext(dir)) {
84
+ const err = new Error(`${path.resolve(dir)} has no ${CONTEXT_DIR}/ (run init there first)`);
85
+ err.code = 'NO_CONTEXT';
86
+ throw err;
87
+ }
88
+ const registry = readRegistry(home);
89
+ const entry = upsert(registry, dir, now);
90
+ writeRegistry(registry, home);
91
+ return entry;
92
+ }
93
+
94
+ function removeProject(dir, { home = homeDir() } = {}) {
95
+ const abs = canonical(dir);
96
+ const registry = readRegistry(home);
97
+ const before = registry.projects.length;
98
+ registry.projects = registry.projects.filter((p) => p.path !== abs && p.path !== path.resolve(dir));
99
+ writeRegistry(registry, home);
100
+ return before !== registry.projects.length;
101
+ }
102
+
103
+ // Lists projects and drops entries whose folder or context directory is gone.
104
+ function listProjects({ home = homeDir(), prune = true } = {}) {
105
+ const registry = readRegistry(home);
106
+ const kept = registry.projects.filter((p) => hasContext(p.path));
107
+ const removed = registry.projects.filter((p) => !kept.includes(p));
108
+ if (prune && removed.length) writeRegistry({ projects: kept }, home);
109
+ return { projects: kept.map((p) => ({ ...p, contextVersion: readContextVersion(p.path) || p.contextVersion || null })), removed: removed.map((p) => p.path) };
110
+ }
111
+
112
+ // Manual, bounded scan. Does not follow symlinks or descend into excluded dirs.
113
+ function scanProjects(root, { home = homeDir(), maxDepth = 4, now = new Date() } = {}) {
114
+ const found = [];
115
+ const walk = (dir, depth) => {
116
+ if (hasContext(dir)) found.push(dir);
117
+ if (depth >= maxDepth) return;
118
+ let entries;
119
+ try {
120
+ entries = fs.readdirSync(dir, { withFileTypes: true });
121
+ } catch {
122
+ return;
123
+ }
124
+ for (const entry of entries) {
125
+ if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
126
+ if (SCAN_EXCLUDES.has(entry.name) || entry.name === CONTEXT_DIR) continue;
127
+ walk(path.join(dir, entry.name), depth + 1);
128
+ }
129
+ };
130
+ walk(path.resolve(root), 0);
131
+ const registry = readRegistry(home);
132
+ const entries = found.map((dir) => upsert(registry, dir, now));
133
+ writeRegistry(registry, home);
134
+ return { root: path.resolve(root), maxDepth, found: entries };
135
+ }
136
+
137
+ module.exports = {
138
+ REGISTRY_FILE,
139
+ SCAN_EXCLUDES,
140
+ registryEnabled,
141
+ registryPath,
142
+ readRegistry,
143
+ registerProject,
144
+ addProject,
145
+ removeProject,
146
+ listProjects,
147
+ scanProjects
148
+ };
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ // `run --abandon` (issue #46): close a run that will never finish so it stops
4
+ // holding `refresh --non-destructive` and `update auto` back. The run moves to
5
+ // CANCELLED with reason, actor, and time in its history ledger (workflow runs
6
+ // also get a RUN_CANCELLED event in events.jsonl). Run data is never deleted.
7
+ // The current.json pointer is released only when it pointed at that run.
8
+
9
+ const fs = require('fs');
10
+ const {
11
+ RUN_STATES,
12
+ TERMINAL_STATES,
13
+ assertRunId,
14
+ atomicWriteJson,
15
+ currentRunPath,
16
+ loadRun,
17
+ transitionRun
18
+ } = require('./run-state.js');
19
+ const { redactSecrets } = require('./safe-context.js');
20
+
21
+ const STALE_RUN_DAYS = 7;
22
+ const DAY_MS = 24 * 60 * 60 * 1000;
23
+
24
+ function abandonError(message, code, exitCode = 1) {
25
+ const err = new Error(message);
26
+ err.code = code;
27
+ err.exitCode = exitCode;
28
+ return err;
29
+ }
30
+
31
+ function currentPointerRunId(rootDir) {
32
+ try {
33
+ const { runId } = JSON.parse(fs.readFileSync(currentRunPath(rootDir), 'utf8'));
34
+ return assertRunId(runId);
35
+ } catch {
36
+ return null;
37
+ }
38
+ }
39
+
40
+ // { stale, idleDays } for an active run; terminal runs are never stale.
41
+ function staleRunInfo(run, { now = new Date(), days = STALE_RUN_DAYS } = {}) {
42
+ if (!run || TERMINAL_STATES.has(run.state)) return { stale: false, idleDays: 0 };
43
+ const last = Date.parse(run.updatedAt || run.createdAt);
44
+ if (!Number.isFinite(last)) return { stale: false, idleDays: 0 };
45
+ const idleDays = Math.floor((now.getTime() - last) / DAY_MS);
46
+ return { stale: idleDays >= days, idleDays };
47
+ }
48
+
49
+ function abandonCommand(runId) {
50
+ return `ai-engineering-loop run --abandon${runId ? ` --run ${runId}` : ''} --reason "<why>" --by <name>`;
51
+ }
52
+
53
+ // Validates everything before writing anything.
54
+ function planAbandon(rootDir, { runId = null, reason, by } = {}) {
55
+ const pointer = currentPointerRunId(rootDir);
56
+ const target = runId || pointer;
57
+ if (!target) {
58
+ throw abandonError('No current run to abandon. Pass --run <id> (see `ai-engineering-loop history`).', 'NO_ACTIVE_RUN', 2);
59
+ }
60
+ const run = loadRun(rootDir, assertRunId(target));
61
+ if (TERMINAL_STATES.has(run.state)) {
62
+ throw abandonError(`Run ${run.runId} is already finished (${run.state}); nothing to abandon.`, 'RUN_ALREADY_FINISHED', 2);
63
+ }
64
+ const actor = String(by || '').trim();
65
+ if (!/^[A-Za-z0-9@._-]{1,64}$/.test(actor)) {
66
+ throw abandonError('--by <name> is required (letters, digits, @._-; max 64).', 'INVALID_RUN_ACTOR');
67
+ }
68
+ const cleanReason = redactSecrets(String(reason || '').trim()).text;
69
+ if (!cleanReason || cleanReason.length > 500) {
70
+ throw abandonError('--reason "<text>" is required (1-500 characters).', 'INVALID_ABANDON_REASON');
71
+ }
72
+ return { run, pointer, actor, reason: cleanReason };
73
+ }
74
+
75
+ function abandonRun(rootDir, { runId = null, reason, by, now = new Date() } = {}) {
76
+ const plan = planAbandon(rootDir, { runId, reason, by });
77
+ const { run, pointer, actor } = plan;
78
+ const fromState = run.state;
79
+ let next;
80
+ if (run.workflow) {
81
+ next = require('./workflow-runtime.js').cancelWorkflowRun(rootDir, {
82
+ runId: run.runId,
83
+ actor,
84
+ reason: `Abandoned: ${plan.reason}`,
85
+ now
86
+ }).run;
87
+ } else {
88
+ next = transitionRun(rootDir, run.runId, RUN_STATES.CANCELLED, {
89
+ gate: 'run-abandoned',
90
+ reason: plan.reason,
91
+ historyMetadata: { actor, action: 'abandon' },
92
+ now
93
+ });
94
+ }
95
+ // transitionRun rewrote current.json to this run. Release it, or put back
96
+ // the pointer to the other run that was current before.
97
+ let released = false;
98
+ if (pointer && pointer !== run.runId) {
99
+ atomicWriteJson(currentRunPath(rootDir), { schemaVersion: 1, runId: pointer });
100
+ } else {
101
+ fs.rmSync(currentRunPath(rootDir), { force: true });
102
+ released = Boolean(pointer);
103
+ }
104
+ return {
105
+ runId: run.runId,
106
+ from: fromState,
107
+ state: next.state,
108
+ reason: plan.reason,
109
+ by: actor,
110
+ at: now.toISOString(),
111
+ released,
112
+ current: pointer && pointer !== run.runId ? pointer : null
113
+ };
114
+ }
115
+
116
+ module.exports = { STALE_RUN_DAYS, staleRunInfo, abandonCommand, planAbandon, abandonRun, currentPointerRunId };
package/lib/run-state.js CHANGED
@@ -207,7 +207,8 @@ function createRun(
207
207
  now = new Date(),
208
208
  workflow = null,
209
209
  displayName = '',
210
- constraints = ''
210
+ constraints = '',
211
+ tier = null
211
212
  } = {}
212
213
  ) {
213
214
  assertRunId(runId);
@@ -241,6 +242,7 @@ function createRun(
241
242
  createdAt: timestamp,
242
243
  updatedAt: timestamp,
243
244
  artifacts: {},
245
+ ...(tier ? { tier } : {}),
244
246
  ...(workflowMetadata ? { workflow: workflowMetadata } : {}),
245
247
  history: [
246
248
  {
@@ -259,7 +261,7 @@ function createRun(
259
261
 
260
262
  function createOrResumeRun(
261
263
  rootDir,
262
- { task = '', runId, mode = null, forceNew = false, now = new Date(), workflow = null } = {}
264
+ { task = '', runId, mode = null, forceNew = false, now = new Date(), workflow = null, tier = null } = {}
263
265
  ) {
264
266
  const current = getCurrentRun(rootDir);
265
267
  const requestedTask = String(task || '').trim();
@@ -289,7 +291,8 @@ function createOrResumeRun(
289
291
  ...(runId ? { runId } : {}),
290
292
  mode: mode || RUN_MODES.ASSISTED,
291
293
  now,
292
- workflow
294
+ workflow,
295
+ tier
293
296
  }),
294
297
  resumed: false
295
298
  };