ai-engineering-loop 1.11.0 → 1.11.1

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 (32) hide show
  1. package/.agents/skills/backend-development/SKILL.md +272 -0
  2. package/.agents/skills/backend-development/references/api-design-guidelines.md +95 -0
  3. package/.agents/skills/backend-development/references/query-and-database-best-practices.md +53 -0
  4. package/.agents/skills/backend-development/references/security-checklist.md +60 -0
  5. package/.agents/workflows/ai-engineering-loop.md +4 -4
  6. package/.claude/skills/ai-engineering-loop/SKILL.md +4 -4
  7. package/.claude/skills/backend-development/SKILL.md +272 -0
  8. package/.claude/skills/backend-development/references/api-design-guidelines.md +95 -0
  9. package/.claude/skills/backend-development/references/query-and-database-best-practices.md +53 -0
  10. package/.claude/skills/backend-development/references/security-checklist.md +60 -0
  11. package/.gemini/skills/ai-engineering-loop/SKILL.md +4 -4
  12. package/.gemini/skills/backend-development/SKILL.md +272 -0
  13. package/.gemini/skills/backend-development/references/api-design-guidelines.md +95 -0
  14. package/.gemini/skills/backend-development/references/query-and-database-best-practices.md +53 -0
  15. package/.gemini/skills/backend-development/references/security-checklist.md +60 -0
  16. package/.grok/skills/ai-engineering-loop/SKILL.md +4 -4
  17. package/.grok/skills/backend-development/SKILL.md +272 -0
  18. package/.grok/skills/backend-development/references/api-design-guidelines.md +95 -0
  19. package/.grok/skills/backend-development/references/query-and-database-best-practices.md +53 -0
  20. package/.grok/skills/backend-development/references/security-checklist.md +60 -0
  21. package/README.md +11 -1
  22. package/README.npm.md +4 -0
  23. package/bin/ai-engineering-loop.js +129 -3
  24. package/core/runtime-safety.md +18 -1
  25. package/lib/doctor.js +4 -0
  26. package/lib/run-compaction.js +170 -0
  27. package/lib/smart-context.js +267 -8
  28. package/lib/studio-server.js +19 -2
  29. package/lib/sync-hosts.js +20 -0
  30. package/lib/update-manager.js +147 -0
  31. package/package.json +1 -1
  32. package/studio/app.js +5 -2
@@ -22,6 +22,44 @@ const DIFF_PACK_LIMITS = Object.freeze({
22
22
  thorough: Object.freeze({ maxFiles: 60, maxHunksPerFile: 20, maxHunkBytes: 12_000, maxTotalBytes: 128_000 })
23
23
  });
24
24
 
25
+ const REVIEW_BUDGETS = Object.freeze({
26
+ lean: Object.freeze({ devilAdvocateToolCalls: 8, devilAdvocateMaxFindings: 5, judgeToolCalls: 4, judgeMayReadFullDiff: false }),
27
+ standard: Object.freeze({ devilAdvocateToolCalls: 10, devilAdvocateMaxFindings: 8, judgeToolCalls: 4, judgeMayReadFullDiff: false }),
28
+ thorough: Object.freeze({ devilAdvocateToolCalls: 14, devilAdvocateMaxFindings: 12, judgeToolCalls: 6, judgeMayReadFullDiff: true })
29
+ });
30
+
31
+ const SMALL_TASK_LIMITS = Object.freeze({
32
+ maxFiles: 3,
33
+ maxChangedLines: 180
34
+ });
35
+
36
+ const SMALL_TASK_HIGH_RISK_PATTERNS = Object.freeze([
37
+ /(^|\/)(auth|authorization|permissions?|access-control)(\/|[._-])/i,
38
+ /(^|\/)(payments?|billing|invoices?|ledger)(\/|[._-])/i,
39
+ /(^|\/)(migrations?|schema)(\/|[._-])/i,
40
+ /(^|\/)(infra|terraform|k8s|kubernetes|deploy)(\/|[._-])/i,
41
+ /(^|\/)(crypto|encryption|secrets?)(\/|[._-])/i,
42
+ /(^|\/)(package-lock|pnpm-lock|yarn\.lock)$/i
43
+ ]);
44
+
45
+ const DEFAULT_CONTEXT_IGNORE_PATTERNS = Object.freeze([
46
+ '*.css',
47
+ '*.map',
48
+ '*.min.js',
49
+ 'package-lock.json',
50
+ 'pnpm-lock.yaml',
51
+ 'yarn.lock',
52
+ 'bun.lockb',
53
+ 'dist/',
54
+ 'build/',
55
+ 'coverage/',
56
+ 'node_modules/',
57
+ 'studio/styles.css',
58
+ 'studio/assets/',
59
+ 'docs/images/',
60
+ '.ai-engineering-loop/'
61
+ ]);
62
+
25
63
  function smartContextError(message, code = 'SMART_CONTEXT_ERROR') {
26
64
  const err = new Error(message);
27
65
  err.code = code;
@@ -48,12 +86,63 @@ function git(rootDir, args) {
48
86
  });
49
87
  }
50
88
 
51
- function listTrackedFiles(rootDir) {
89
+ function normalizeRepoPath(relativePath) {
90
+ return String(relativePath || '').replace(/\\/g, '/').replace(/^\.\/+/, '');
91
+ }
92
+
93
+ function escapeRegExp(value) {
94
+ return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
95
+ }
96
+
97
+ function globToRegExp(pattern) {
98
+ const parts = String(pattern).split('*').map(escapeRegExp);
99
+ return new RegExp(`^${parts.join('.*')}$`);
100
+ }
101
+
102
+ function readContextIgnorePatterns(rootDir) {
103
+ const ignorePath = path.join(rootDir, '.aelcontextignore');
104
+ if (!fs.existsSync(ignorePath)) return [];
105
+ return fs.readFileSync(ignorePath, 'utf8')
106
+ .split('\n')
107
+ .map((line) => line.trim())
108
+ .filter((line) => line && !line.startsWith('#'));
109
+ }
110
+
111
+ function matchesContextIgnorePattern(relativePath, pattern) {
112
+ const candidate = normalizeRepoPath(relativePath);
113
+ const normalizedPattern = normalizeRepoPath(pattern);
114
+ if (!normalizedPattern) return false;
115
+ if (normalizedPattern.endsWith('/')) {
116
+ return candidate === normalizedPattern.slice(0, -1) || candidate.startsWith(normalizedPattern);
117
+ }
118
+ if (!normalizedPattern.includes('/')) {
119
+ const basename = path.posix.basename(candidate);
120
+ return normalizedPattern.includes('*')
121
+ ? globToRegExp(normalizedPattern).test(basename)
122
+ : basename === normalizedPattern;
123
+ }
124
+ return normalizedPattern.includes('*')
125
+ ? globToRegExp(normalizedPattern).test(candidate)
126
+ : candidate === normalizedPattern;
127
+ }
128
+
129
+ function contextIgnorePatterns(rootDir) {
130
+ return [...DEFAULT_CONTEXT_IGNORE_PATTERNS, ...readContextIgnorePatterns(rootDir)];
131
+ }
132
+
133
+ function isReviewContextIgnored(rootDir, relativePath, { includeIgnored = false } = {}) {
134
+ if (includeIgnored) return false;
135
+ const candidate = normalizeRepoPath(relativePath);
136
+ return contextIgnorePatterns(rootDir).some((pattern) => matchesContextIgnorePattern(candidate, pattern));
137
+ }
138
+
139
+ function listTrackedFiles(rootDir, { includeIgnored = false } = {}) {
52
140
  return git(rootDir, ['ls-files'])
53
141
  .split('\n')
54
142
  .map((line) => line.trim())
55
143
  .filter(Boolean)
56
- .filter((relativePath) => !isSensitivePath(relativePath));
144
+ .filter((relativePath) => !isSensitivePath(relativePath))
145
+ .filter((relativePath) => !isReviewContextIgnored(rootDir, relativePath, { includeIgnored }));
57
146
  }
58
147
 
59
148
  function languageFor(relativePath) {
@@ -143,11 +232,13 @@ function writeCachedSummary(rootDir, summary) {
143
232
  });
144
233
  }
145
234
 
146
- function buildContextIndex(rootDir, { files } = {}) {
235
+ function buildContextIndex(rootDir, { files, includeIgnored = false } = {}) {
147
236
  ensurePrivateRuntimeIgnores(rootDir);
148
- const candidates = (files && files.length ? files : listTrackedFiles(rootDir))
237
+ const hasExplicitFiles = files && files.length;
238
+ const candidates = (hasExplicitFiles ? files : listTrackedFiles(rootDir, { includeIgnored }))
149
239
  .map((file) => String(file).trim())
150
- .filter(Boolean);
240
+ .filter(Boolean)
241
+ .filter((file) => hasExplicitFiles || !isReviewContextIgnored(rootDir, file, { includeIgnored }));
151
242
  const summaries = [];
152
243
  const cache = { hits: 0, misses: 0 };
153
244
  for (const candidate of [...new Set(candidates)]) {
@@ -176,6 +267,100 @@ function buildContextIndex(rootDir, { files } = {}) {
176
267
  };
177
268
  }
178
269
 
270
+ function readOrBuildContextIndex(rootDir) {
271
+ const indexPath = path.join(contextRoot(rootDir), 'index.json');
272
+ if (fs.existsSync(indexPath)) {
273
+ try {
274
+ const index = JSON.parse(fs.readFileSync(indexPath, 'utf8'));
275
+ if (index?.schemaVersion === 1 && Array.isArray(index.files)) {
276
+ return {
277
+ index,
278
+ path: path.relative(rootDir, indexPath).split(path.sep).join('/'),
279
+ cacheStatus: 'existing'
280
+ };
281
+ }
282
+ } catch {
283
+ // Optional cache corruption should not make metadata-only context queries fail.
284
+ }
285
+ }
286
+ return { ...buildContextIndex(rootDir), cacheStatus: 'rebuilt' };
287
+ }
288
+
289
+ function queryContextIndex(rootDir, { query, limit = 10 } = {}) {
290
+ const needle = String(query || '').trim().toLowerCase();
291
+ if (!needle) throw smartContextError('Context query requires a non-empty search term', 'EMPTY_CONTEXT_QUERY');
292
+ const result = readOrBuildContextIndex(rootDir);
293
+ const matches = result.index.files
294
+ .map((file) => {
295
+ const pathScore = file.path.toLowerCase().includes(needle) ? 2 : 0;
296
+ const matchedSymbols = (file.symbols || []).filter((symbol) => String(symbol).toLowerCase().includes(needle));
297
+ const symbolScore = matchedSymbols.length ? 3 : 0;
298
+ return {
299
+ path: file.path,
300
+ language: file.language,
301
+ lines: file.lines,
302
+ sourceBytes: file.sourceBytes,
303
+ symbols: matchedSymbols.slice(0, 8),
304
+ score: pathScore + symbolScore
305
+ };
306
+ })
307
+ .filter((match) => match.score > 0)
308
+ .sort((left, right) => right.score - left.score || left.path.localeCompare(right.path))
309
+ .slice(0, Number(limit) || 10)
310
+ .map(({ score: _score, ...match }) => match);
311
+ return {
312
+ schemaVersion: 1,
313
+ query: needle,
314
+ indexPath: result.path,
315
+ cacheStatus: result.cacheStatus,
316
+ matches
317
+ };
318
+ }
319
+
320
+ function pathTokens(relativePath) {
321
+ return new Set(String(relativePath || '')
322
+ .toLowerCase()
323
+ .split(/[^a-z0-9]+/)
324
+ .filter((token) => token.length >= 3));
325
+ }
326
+
327
+ function relatedContextIndex(rootDir, { file, limit = 10 } = {}) {
328
+ const target = String(file || '').trim();
329
+ if (!target) throw smartContextError('Related context requires a repository-relative file path', 'EMPTY_RELATED_FILE');
330
+ const result = readOrBuildContextIndex(rootDir);
331
+ const source = result.index.files.find((entry) => entry.path === target);
332
+ if (!source) throw smartContextError(`File is not present in the context index: ${target}`, 'FILE_NOT_INDEXED');
333
+ const sourceTokens = pathTokens(source.path);
334
+ const sourceSymbols = new Set((source.symbols || []).map((symbol) => String(symbol).toLowerCase()));
335
+ const matches = result.index.files
336
+ .filter((entry) => entry.path !== source.path)
337
+ .map((entry) => {
338
+ const tokens = pathTokens(entry.path);
339
+ const tokenOverlap = [...tokens].filter((token) => sourceTokens.has(token)).length;
340
+ const symbolOverlap = (entry.symbols || []).filter((symbol) => sourceSymbols.has(String(symbol).toLowerCase())).length;
341
+ const sameLanguage = entry.language === source.language ? 1 : 0;
342
+ return {
343
+ path: entry.path,
344
+ language: entry.language,
345
+ lines: entry.lines,
346
+ sourceBytes: entry.sourceBytes,
347
+ symbols: (entry.symbols || []).slice(0, 8),
348
+ score: tokenOverlap * 3 + symbolOverlap * 2 + sameLanguage
349
+ };
350
+ })
351
+ .filter((match) => match.score > 0)
352
+ .sort((left, right) => right.score - left.score || left.path.localeCompare(right.path))
353
+ .slice(0, Number(limit) || 10)
354
+ .map(({ score: _score, ...match }) => match);
355
+ return {
356
+ schemaVersion: 1,
357
+ file: source.path,
358
+ indexPath: result.path,
359
+ cacheStatus: result.cacheStatus,
360
+ matches
361
+ };
362
+ }
363
+
179
364
  function parseDiff(diff) {
180
365
  const files = [];
181
366
  let currentFile = null;
@@ -288,14 +473,19 @@ function boundedHunks(file, limits, remainingBytes) {
288
473
  return { hunks, includedBytes, truncated };
289
474
  }
290
475
 
291
- function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile } = {}) {
476
+ function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile, includeIgnored = false } = {}) {
292
477
  const run = resolveRun(rootDir, runId);
293
478
  const policy = loadPolicy(rootDir);
294
479
  const reviewProfile = normalizeReviewProfile(profile || policy.reviewProfile);
295
480
  const limits = DIFF_PACK_LIMITS[reviewProfile];
296
481
  const contextLimits = CONTEXT_PROFILE_LIMITS[reviewProfile]['devil-advocate'];
297
482
  const diff = git(rootDir, ['diff', '--no-ext-diff', '--unified=3', base, '--']);
298
- const allParsedFiles = parseDiff(diff).filter((file) => !isSensitivePath(file.path));
483
+ const parsedDiffFiles = parseDiff(diff).filter((file) => !isSensitivePath(file.path));
484
+ const ignoredPaths = parsedDiffFiles
485
+ .filter((file) => isReviewContextIgnored(rootDir, file.path, { includeIgnored }))
486
+ .map((file) => file.path);
487
+ const allParsedFiles = parsedDiffFiles
488
+ .filter((file) => !isReviewContextIgnored(rootDir, file.path, { includeIgnored }));
299
489
  const parsedFiles = allParsedFiles.slice(0, limits.maxFiles);
300
490
  const totalFilesTruncated = allParsedFiles.length > parsedFiles.length;
301
491
  const unresolved = unresolvedFindings(rootDir, run.runId);
@@ -333,6 +523,7 @@ function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile } = {}) {
333
523
  createdAt: new Date().toISOString(),
334
524
  mode: 'diff-hunks',
335
525
  limits,
526
+ reviewBudget: REVIEW_BUDGETS[reviewProfile],
336
527
  totalBytes,
337
528
  estimatedTokens,
338
529
  truncated: totalFilesTruncated || files.some((file) => file.truncated),
@@ -340,6 +531,7 @@ function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile } = {}) {
340
531
  previousDiffHash: run.artifacts?.diff?.sha256 || null,
341
532
  currentDiffHash: sha256(diff),
342
533
  changedPaths,
534
+ ignoredPaths,
343
535
  unresolvedFindingIds: unresolved.map((finding) => finding.id),
344
536
  focusPaths
345
537
  },
@@ -354,6 +546,64 @@ function createDiffHunkPack(rootDir, { runId, base = 'HEAD', profile } = {}) {
354
546
  };
355
547
  }
356
548
 
549
+ function changedLineCount(diff) {
550
+ let count = 0;
551
+ for (const line of String(diff || '').split('\n')) {
552
+ if ((line.startsWith('+') && !line.startsWith('+++')) || (line.startsWith('-') && !line.startsWith('---'))) count += 1;
553
+ }
554
+ return count;
555
+ }
556
+
557
+ function assessSmallTaskFastPath(rootDir, { base = 'HEAD', includeIgnored = false } = {}) {
558
+ const diff = git(rootDir, ['diff', '--no-ext-diff', '--unified=0', base, '--']);
559
+ const parsedFiles = parseDiff(diff).filter((file) => !isSensitivePath(file.path));
560
+ const ignoredDiffPaths = parsedFiles
561
+ .filter((file) => isReviewContextIgnored(rootDir, file.path, { includeIgnored }))
562
+ .map((file) => file.path);
563
+ const files = parsedFiles
564
+ .filter((file) => !isReviewContextIgnored(rootDir, file.path, { includeIgnored }));
565
+ const allUntrackedPaths = git(rootDir, ['ls-files', '--others', '--exclude-standard'])
566
+ .split('\n')
567
+ .map((line) => line.trim())
568
+ .filter(Boolean)
569
+ .filter((filePath) => !filePath.startsWith('.ai-engineering-loop/'))
570
+ .filter((filePath) => !isSensitivePath(filePath));
571
+ const ignoredUntrackedPaths = allUntrackedPaths
572
+ .filter((filePath) => isReviewContextIgnored(rootDir, filePath, { includeIgnored }));
573
+ const untrackedPaths = allUntrackedPaths
574
+ .filter((filePath) => !isReviewContextIgnored(rootDir, filePath, { includeIgnored }));
575
+ const changedPaths = [...new Set([...files.map((file) => file.path), ...untrackedPaths])];
576
+ const ignoredPaths = [...new Set([...ignoredDiffPaths, ...ignoredUntrackedPaths])];
577
+ const untrackedLines = untrackedPaths.reduce((sum, filePath) => {
578
+ try {
579
+ const file = resolveSafeRepoFile(rootDir, filePath);
580
+ const raw = fs.readFileSync(file.absolute);
581
+ if (raw.includes(0)) return sum + SMALL_TASK_LIMITS.maxChangedLines + 1;
582
+ return sum + raw.toString('utf8').split('\n').length;
583
+ } catch {
584
+ return sum;
585
+ }
586
+ }, 0);
587
+ const changedLines = changedLineCount(diff) + untrackedLines;
588
+ const riskyPaths = changedPaths.filter((filePath) => SMALL_TASK_HIGH_RISK_PATTERNS.some((pattern) => pattern.test(filePath)));
589
+ const reasons = [];
590
+ if (changedPaths.length === 0) reasons.push('NO_DIFF');
591
+ if (changedPaths.length > SMALL_TASK_LIMITS.maxFiles) reasons.push('TOO_MANY_FILES');
592
+ if (changedLines > SMALL_TASK_LIMITS.maxChangedLines) reasons.push('TOO_MANY_CHANGED_LINES');
593
+ if (riskyPaths.length) reasons.push('HIGH_RISK_PATH');
594
+ return {
595
+ schemaVersion: 1,
596
+ eligible: reasons.length === 0,
597
+ recommendedProfile: reasons.length === 0 ? 'lean' : 'standard',
598
+ limits: SMALL_TASK_LIMITS,
599
+ changedPaths,
600
+ ignoredPaths,
601
+ changedLines,
602
+ riskyPaths,
603
+ reasons
604
+ };
605
+ }
606
+
357
607
  function smartContextSummary(result) {
358
608
  if (result.pack) {
359
609
  return {
@@ -365,7 +615,9 @@ function smartContextSummary(result) {
365
615
  totalBytes: result.pack.totalBytes,
366
616
  estimatedTokens: result.pack.estimatedTokens,
367
617
  truncated: result.pack.truncated,
368
- unresolvedFindings: result.pack.unresolvedFindings.length
618
+ unresolvedFindings: result.pack.unresolvedFindings.length,
619
+ ignoredPaths: result.pack.reviewDelta?.ignoredPaths?.length || 0,
620
+ reviewBudget: result.pack.reviewBudget
369
621
  };
370
622
  }
371
623
  return {
@@ -377,8 +629,15 @@ function smartContextSummary(result) {
377
629
 
378
630
  module.exports = {
379
631
  DIFF_PACK_LIMITS,
632
+ DEFAULT_CONTEXT_IGNORE_PATTERNS,
633
+ REVIEW_BUDGETS,
634
+ SMALL_TASK_LIMITS,
635
+ assessSmallTaskFastPath,
380
636
  buildContextIndex,
381
637
  createDiffHunkPack,
638
+ isReviewContextIgnored,
639
+ queryContextIndex,
640
+ relatedContextIndex,
382
641
  parseDiff,
383
642
  smartContextSummary
384
643
  };
@@ -54,6 +54,7 @@ const {
54
54
 
55
55
  const MAX_BODY = 256 * 1024;
56
56
  const ASSET_DIR = path.join(__dirname, '..', 'studio');
57
+ const LIVE_WORKFLOW_EVENT_LIMIT = 12;
57
58
 
58
59
  function json(response, status, value) {
59
60
  response.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
@@ -108,11 +109,27 @@ function liveSnapshot(rootDir) {
108
109
  const run = getCurrentRun(rootDir);
109
110
  if (!run?.workflow) return null;
110
111
  const workflow = workflowStatus(rootDir, { runId: run.runId });
112
+ const eventTail = workflow.events.slice(-LIVE_WORKFLOW_EVENT_LIMIT);
113
+ const edges = edgesFromPlan(workflow.plan, workflow.state);
111
114
  return redactedValue({
112
115
  run,
116
+ summary: {
117
+ runId: run.runId,
118
+ state: run.state,
119
+ nodeCount: workflow.plan.nodes.length,
120
+ edgeCount: edges.length,
121
+ workflowEventCount: workflow.events.length,
122
+ workflowEventLimit: LIVE_WORKFLOW_EVENT_LIMIT,
123
+ eventsTruncated: workflow.events.length > eventTail.length,
124
+ details: {
125
+ nodeIo: `/api/runs/${encodeURIComponent(run.runId)}/nodes/{nodeId}`,
126
+ artifacts: `/api/runs/${encodeURIComponent(run.runId)}/artifacts?path={path}`,
127
+ lifecycle: `/api/runs/${encodeURIComponent(run.runId)}/lifecycle?after={sequence}`
128
+ }
129
+ },
113
130
  plan: workflow.plan,
114
131
  nodes: workflow.state.nodes,
115
- edges: edgesFromPlan(workflow.plan, workflow.state),
132
+ edges,
116
133
  loopGroups: workflow.state.loopGroups,
117
134
  journey: (() => {
118
135
  try {
@@ -128,7 +145,7 @@ function liveSnapshot(rootDir) {
128
145
  }
129
146
  })(),
130
147
  budget: budgetStatus(rootDir, { runId: run.runId }),
131
- events: workflow.events.slice(-50).map(({ initialNodes, changes, ...event }) => ({
148
+ events: eventTail.map(({ initialNodes, changes, ...event }) => ({
132
149
  ...event,
133
150
  changedNodes: (changes || []).map((change) => change.nodeId)
134
151
  }))
package/lib/sync-hosts.js CHANGED
@@ -23,6 +23,22 @@ function applyGrokSkillOverlay(content) {
23
23
  return `---\n${nextYaml}\n---\n${normalized.slice(match[0].length)}`;
24
24
  }
25
25
 
26
+ const BACKEND_SKILL_FILES = [
27
+ 'SKILL.md',
28
+ 'references/api-design-guidelines.md',
29
+ 'references/query-and-database-best-practices.md',
30
+ 'references/security-checklist.md'
31
+ ];
32
+
33
+ function backendSkillFiles(srcRoot, destRoot, { grokSkillOverlay = false } = {}) {
34
+ return BACKEND_SKILL_FILES.map((file) => ({
35
+ src: path.posix.join(srcRoot, file),
36
+ dest: path.join(destRoot, file),
37
+ mode: 'upsert',
38
+ ...(grokSkillOverlay && file === 'SKILL.md' ? { grokSkillOverlay: true } : {})
39
+ }));
40
+ }
41
+
26
42
  function hostFileMap(home) {
27
43
  const claude = path.join(home, '.claude');
28
44
  const grok = path.join(home, '.grok');
@@ -34,6 +50,7 @@ function hostFileMap(home) {
34
50
  root: claude,
35
51
  files: [
36
52
  { src: '.claude/skills/ai-engineering-loop/SKILL.md', dest: path.join(claude, 'skills/ai-engineering-loop/SKILL.md'), mode: 'upsert' },
53
+ ...backendSkillFiles('.claude/skills/backend-development', path.join(claude, 'skills/backend-development')),
37
54
  { src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(claude, 'skills/task-impact-inquiry/SKILL.md'), mode: 'upsert' },
38
55
  { src: 'adapters/generate-adapter/SKILL.md', dest: path.join(claude, 'skills/generate-adapter/SKILL.md'), mode: 'upsert' },
39
56
  { src: 'adapters/generate-workflow/SKILL.md', dest: path.join(claude, 'skills/generate-workflow/SKILL.md'), mode: 'upsert' },
@@ -47,6 +64,7 @@ function hostFileMap(home) {
47
64
  root: grok,
48
65
  files: [
49
66
  { src: '.grok/skills/ai-engineering-loop/SKILL.md', dest: path.join(grok, 'skills/ai-engineering-loop/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
67
+ ...backendSkillFiles('.grok/skills/backend-development', path.join(grok, 'skills/backend-development'), { grokSkillOverlay: true }),
50
68
  { src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(grok, 'skills/task-impact-inquiry/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
51
69
  { src: 'adapters/generate-adapter/SKILL.md', dest: path.join(grok, 'skills/generate-adapter/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
52
70
  { src: 'adapters/generate-workflow/SKILL.md', dest: path.join(grok, 'skills/generate-workflow/SKILL.md'), mode: 'upsert', grokSkillOverlay: true },
@@ -60,6 +78,7 @@ function hostFileMap(home) {
60
78
  root: gemini,
61
79
  files: [
62
80
  { src: '.gemini/skills/ai-engineering-loop/SKILL.md', dest: path.join(gemini, 'config/skills/ai-engineering-loop/SKILL.md'), mode: 'upsert' },
81
+ ...backendSkillFiles('.gemini/skills/backend-development', path.join(gemini, 'config/skills/backend-development')),
63
82
  { src: 'adapters/dot/skills/task-impact-inquiry/SKILL.md', dest: path.join(gemini, 'config/skills/task-impact-inquiry/SKILL.md'), mode: 'upsert' },
64
83
  { src: 'adapters/generate-adapter/SKILL.md', dest: path.join(gemini, 'config/skills/generate-adapter/SKILL.md'), mode: 'upsert' },
65
84
  { src: 'adapters/generate-workflow/SKILL.md', dest: path.join(gemini, 'config/skills/generate-workflow/SKILL.md'), mode: 'upsert' }
@@ -69,6 +88,7 @@ function hostFileMap(home) {
69
88
  id: 'antigravity',
70
89
  root: agents,
71
90
  files: [
91
+ ...backendSkillFiles('.agents/skills/backend-development', path.join(agents, 'skills/backend-development')),
72
92
  { src: '.agents/devil-advocate.md', dest: path.join(agents, 'devil-advocate.md'), mode: 'upsert' },
73
93
  { src: '.agents/judge.md', dest: path.join(agents, 'judge.md'), mode: 'upsert' },
74
94
  { src: '.agents/workflows/ai-engineering-loop.md', dest: path.join(agents, 'workflows/ai-engineering-loop.md'), mode: 'upsert' }
@@ -0,0 +1,147 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { execFileSync } = require('child_process');
6
+
7
+ const DEFAULT_UPDATE_TIMEOUT_MS = 8_000;
8
+
9
+ function updateError(message, code = 'UPDATE_ERROR') {
10
+ const err = new Error(message);
11
+ err.code = code;
12
+ return err;
13
+ }
14
+
15
+ function loadPackageMetadata(rootDir) {
16
+ const packagePath = path.join(rootDir, 'package.json');
17
+ const metadata = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
18
+ if (!metadata.name || !metadata.version) {
19
+ throw updateError('package.json must include name and version', 'INVALID_PACKAGE_METADATA');
20
+ }
21
+ return {
22
+ name: metadata.name,
23
+ version: metadata.version
24
+ };
25
+ }
26
+
27
+ function parseVersion(version) {
28
+ const match = String(version || '').trim().match(/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/);
29
+ if (!match) throw updateError(`Invalid semantic version: ${version || '(empty)'}`, 'INVALID_VERSION');
30
+ return match.slice(1).map((part) => Number(part));
31
+ }
32
+
33
+ function compareVersions(leftVersion, rightVersion) {
34
+ const left = parseVersion(leftVersion);
35
+ const right = parseVersion(rightVersion);
36
+ for (let index = 0; index < left.length; index++) {
37
+ if (left[index] > right[index]) return 1;
38
+ if (left[index] < right[index]) return -1;
39
+ }
40
+ return 0;
41
+ }
42
+
43
+ function npmViewLatestVersion(packageName, { timeoutMs = DEFAULT_UPDATE_TIMEOUT_MS } = {}) {
44
+ if (process.env.AEL_UPDATE_LATEST_VERSION) return process.env.AEL_UPDATE_LATEST_VERSION;
45
+ try {
46
+ const output = execFileSync('npm', ['view', `${packageName}@latest`, 'version', '--json'], {
47
+ encoding: 'utf8',
48
+ stdio: ['ignore', 'pipe', 'pipe'],
49
+ timeout: timeoutMs
50
+ }).trim();
51
+ return JSON.parse(output);
52
+ } catch (cause) {
53
+ throw updateError(`Unable to check npm for ${packageName}@latest: ${cause.message}`, 'UPDATE_CHECK_FAILED');
54
+ }
55
+ }
56
+
57
+ function detectInstallScope(rootDir) {
58
+ const override = process.env.AEL_INSTALL_SCOPE;
59
+ if (override === 'global' || override === 'project') return override;
60
+ try {
61
+ const globalRoot = execFileSync('npm', ['root', '--global'], {
62
+ encoding: 'utf8',
63
+ stdio: ['ignore', 'pipe', 'ignore'],
64
+ timeout: 3_000
65
+ }).trim();
66
+ const packageRoot = fs.realpathSync(rootDir);
67
+ const realGlobalRoot = fs.realpathSync(globalRoot);
68
+ const relative = path.relative(realGlobalRoot, packageRoot);
69
+ const isGlobalPackage = relative && !relative.startsWith('..') && !path.isAbsolute(relative);
70
+ return isGlobalPackage ? 'global' : 'project';
71
+ } catch {
72
+ return 'project';
73
+ }
74
+ }
75
+
76
+ function command(cmd, args) {
77
+ return {
78
+ cmd,
79
+ args,
80
+ display: [cmd, ...args].join(' ')
81
+ };
82
+ }
83
+
84
+ function updateCommands(packageName, installScope) {
85
+ if (installScope === 'global') {
86
+ return [
87
+ command('npm', ['install', '--global', `${packageName}@latest`]),
88
+ command('ai-engineering-loop', ['sync-hosts']),
89
+ command('ai-engineering-loop', ['refresh']),
90
+ command('ai-engineering-loop', ['doctor'])
91
+ ];
92
+ }
93
+ return [
94
+ command('npm', ['install', `${packageName}@latest`, '--save-dev']),
95
+ command('npx', ['ai-engineering-loop', 'sync-hosts']),
96
+ command('npx', ['ai-engineering-loop', 'refresh']),
97
+ command('npx', ['ai-engineering-loop', 'doctor'])
98
+ ];
99
+ }
100
+
101
+ function buildUpdatePlan({ packageName, currentVersion, latestVersion, installScope }) {
102
+ const comparison = compareVersions(currentVersion, latestVersion);
103
+ return {
104
+ schemaVersion: 1,
105
+ packageName,
106
+ currentVersion,
107
+ latestVersion,
108
+ installScope,
109
+ updateAvailable: comparison < 0,
110
+ upToDate: comparison >= 0,
111
+ commands: updateCommands(packageName, installScope)
112
+ };
113
+ }
114
+
115
+ function checkForUpdate(rootDir, {
116
+ latestVersion,
117
+ installScope,
118
+ timeoutMs = DEFAULT_UPDATE_TIMEOUT_MS
119
+ } = {}) {
120
+ const metadata = loadPackageMetadata(rootDir);
121
+ const resolvedLatestVersion = latestVersion || npmViewLatestVersion(metadata.name, { timeoutMs });
122
+ const resolvedInstallScope = installScope || detectInstallScope(rootDir);
123
+ return buildUpdatePlan({
124
+ packageName: metadata.name,
125
+ currentVersion: metadata.version,
126
+ latestVersion: resolvedLatestVersion,
127
+ installScope: resolvedInstallScope
128
+ });
129
+ }
130
+
131
+ function executeUpdatePlan(plan, { stdio = 'inherit' } = {}) {
132
+ for (const item of plan.commands) {
133
+ execFileSync(item.cmd, item.args, { stdio });
134
+ }
135
+ }
136
+
137
+ module.exports = {
138
+ DEFAULT_UPDATE_TIMEOUT_MS,
139
+ buildUpdatePlan,
140
+ checkForUpdate,
141
+ compareVersions,
142
+ detectInstallScope,
143
+ executeUpdatePlan,
144
+ npmViewLatestVersion,
145
+ parseVersion,
146
+ updateCommands
147
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-loop",
3
- "version": "1.11.0",
3
+ "version": "1.11.1",
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": {
package/studio/app.js CHANGED
@@ -2077,7 +2077,6 @@ function renderLive() {
2077
2077
  (active ? runtimeNode.activity || `${runtimeNode.status} · attempt ${runtimeNode.attempts}` : `Final state: ${live.run.state}`);
2078
2078
  const journeyStatuses = new Set(['pending', 'active', 'complete']);
2079
2079
  const degradedSources = live.journey?.degradedSources || [];
2080
- byId('run-journey').dataset.degraded = degradedSources.join(', ');
2081
2080
  byId('run-journey').innerHTML = (live.journey?.steps || []).map((step) => {
2082
2081
  const status = String(step?.status || '').toLowerCase();
2083
2082
  const safeStatus = journeyStatuses.has(status) ? status : 'unknown';
@@ -2104,13 +2103,17 @@ function renderLive() {
2104
2103
  const limit = live.budget.perRunTokenLimit;
2105
2104
  byId('meter').style.width = `${Math.min(100, limit ? (spent / limit) * 100 : 0)}%`;
2106
2105
  byId('budget').textContent = `${spent.toLocaleString()} / ${limit.toLocaleString()} TOKENS`;
2107
- byId('events').innerHTML = lifecycleEvents.slice(-7).reverse().map((event) => `
2106
+ const liveEventsHtml = lifecycleEvents.slice(-7).reverse().map((event) => `
2108
2107
  <p class="${event.type === 'NODE_ACTIVITY' || event.type.includes('START') ? 'event-active' : ''}">
2109
2108
  ${escapeHtml(event.at.slice(11, 19))} · ${escapeHtml(event.type)} · ${escapeHtml(event.message)}
2110
2109
  </p>
2111
2110
  `).join('') || live.events.slice(-7).reverse().map((event) => `
2112
2111
  <p>${escapeHtml(event.at.slice(11, 19))} · ${escapeHtml(event.type)}</p>
2113
2112
  `).join('');
2113
+ const eventsDetailNote = live.summary?.eventsTruncated
2114
+ ? '<p class="muted">Older workflow events are kept out of live polling; node detail and lifecycle stream load them on demand.</p>'
2115
+ : '';
2116
+ byId('events').innerHTML = liveEventsHtml + eventsDetailNote;
2114
2117
  renderRunActivityDock(live, active, runtimeNode, lifecycle);
2115
2118
  updateRuntimePresentation();
2116
2119
  followActiveNode();