ai-engineering-loop 1.10.0 → 1.11.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.
@@ -0,0 +1,130 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { atomicWriteJson, getCurrentRun, loadRun, runsDir } = require('./run-state.js');
6
+
7
+ function verificationSummaryError(message, code = 'VERIFICATION_SUMMARY_ERROR') {
8
+ const err = new Error(message);
9
+ err.code = code;
10
+ return err;
11
+ }
12
+
13
+ function resolveRun(rootDir, runId) {
14
+ if (runId) return loadRun(rootDir, runId);
15
+ const current = getCurrentRun(rootDir);
16
+ if (!current) throw verificationSummaryError('No current run. Pass --run <id>.', 'NO_CURRENT_RUN');
17
+ return current;
18
+ }
19
+
20
+ function parseCount(patterns, text) {
21
+ for (const pattern of patterns) {
22
+ const match = String(text || '').match(pattern);
23
+ if (match) return Number(match[1]);
24
+ }
25
+ return null;
26
+ }
27
+
28
+ function testCountsFromText(text) {
29
+ const total = parseCount([
30
+ /\btests?\s+(\d+)\b/i,
31
+ /\b(\d+)\s+tests?\b/i,
32
+ /\btotal[:=\s]+(\d+)\b/i
33
+ ], text);
34
+ const passed = parseCount([
35
+ /\bpass(?:ed)?\s+(\d+)\b/i,
36
+ /\b(\d+)\s+pass(?:ed)?\b/i
37
+ ], text);
38
+ const failed = parseCount([
39
+ /\bfail(?:ed)?\s+(\d+)\b/i,
40
+ /\b(\d+)\s+fail(?:ed)?\b/i
41
+ ], text);
42
+ return {
43
+ passed: passed ?? null,
44
+ failed: failed ?? null,
45
+ total: total ?? (passed != null && failed != null ? passed + failed : null)
46
+ };
47
+ }
48
+
49
+ function mergeCounts(left, right) {
50
+ const sumOrNull = (a, b) => (a == null && b == null ? null : (a || 0) + (b || 0));
51
+ return {
52
+ passed: sumOrNull(left.passed, right.passed),
53
+ failed: sumOrNull(left.failed, right.failed),
54
+ total: sumOrNull(left.total, right.total)
55
+ };
56
+ }
57
+
58
+ function failureExcerpt(command) {
59
+ if (Number(command.exitCode || 0) === 0 && !command.timedOut) return null;
60
+ const source = [command.stderr, command.stdout].map((value) => String(value || '').trim()).find(Boolean);
61
+ if (!source) return command.timedOut ? 'Command timed out' : `Command exited ${command.exitCode}`;
62
+ return source.split('\n').map((line) => line.trim()).filter(Boolean).slice(0, 3).join('\n').slice(0, 800);
63
+ }
64
+
65
+ function summarizeCommand(command) {
66
+ const output = `${command.stdout || ''}\n${command.stderr || ''}`;
67
+ return {
68
+ command: String(command.command || ''),
69
+ exitCode: Number(command.exitCode || 0),
70
+ timedOut: Boolean(command.timedOut || command.timeoutStatus === 'TIMED_OUT'),
71
+ durationMs: Number.isFinite(command.durationMs) ? command.durationMs : null,
72
+ startedAt: command.startedAt || null,
73
+ finishedAt: command.finishedAt || null,
74
+ testCounts: testCountsFromText(output),
75
+ failureExcerpt: failureExcerpt(command)
76
+ };
77
+ }
78
+
79
+ function summarizeVerificationBundle(bundle) {
80
+ if (!bundle || typeof bundle !== 'object' || Array.isArray(bundle)) {
81
+ throw verificationSummaryError('verification bundle must be a JSON object', 'INVALID_VERIFICATION');
82
+ }
83
+ const commands = (bundle.commands || []).map(summarizeCommand);
84
+ const testCounts = commands
85
+ .map((command) => command.testCounts)
86
+ .reduce(mergeCounts, { passed: null, failed: null, total: null });
87
+ const exitCode = commands.some((command) => command.timedOut)
88
+ ? 1
89
+ : commands.reduce((highest, command) => Math.max(highest, command.exitCode), 0);
90
+ return {
91
+ schemaVersion: 1,
92
+ runId: bundle.runId || null,
93
+ generatedAt: new Date().toISOString(),
94
+ gitRevision: bundle.gitRevision || bundle.revision || null,
95
+ diffHash: bundle.diffHash || null,
96
+ commandCount: commands.length,
97
+ exitCode,
98
+ passed: exitCode === 0,
99
+ testCounts,
100
+ commands
101
+ };
102
+ }
103
+
104
+ function readVerificationBundle(rootDir, runId) {
105
+ const run = resolveRun(rootDir, runId);
106
+ const filePath = path.join(runsDir(rootDir), run.runId, 'verification.json');
107
+ let parsed;
108
+ try {
109
+ parsed = JSON.parse(fs.readFileSync(filePath, 'utf8'));
110
+ } catch (cause) {
111
+ throw verificationSummaryError(`Unable to read verification.json: ${cause.message}`, 'INVALID_VERIFICATION');
112
+ }
113
+ return { run, filePath, bundle: parsed };
114
+ }
115
+
116
+ function writeVerificationSummary(rootDir, { runId } = {}) {
117
+ const { run, bundle } = readVerificationBundle(rootDir, runId);
118
+ const summary = summarizeVerificationBundle({ ...bundle, runId: bundle.runId || run.runId });
119
+ const filePath = path.join(runsDir(rootDir), run.runId, 'verification-summary.json');
120
+ atomicWriteJson(filePath, summary);
121
+ return {
122
+ summary,
123
+ path: path.relative(rootDir, filePath).split(path.sep).join('/')
124
+ };
125
+ }
126
+
127
+ module.exports = {
128
+ summarizeVerificationBundle,
129
+ writeVerificationSummary
130
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-engineering-loop",
3
- "version": "1.10.0",
3
+ "version": "1.11.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": {
@@ -13,15 +13,26 @@ Host files (`.claude/agents/`, `.grok/agents/`, `.agents/`) may differ only in Y
13
13
 
14
14
  - Write `git diff` to `.ai-engineering-loop/tasks/current.diff` before review.
15
15
  - Pass artifact **paths**, not Maker chat.
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
+ - 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.
18
+ - Run `npx ai-engineering-loop verification summarize --run <run-id>` after writing `verification.json`; pass the summary path to Judge before raw logs.
16
19
  - Spawn DA and Judge as siblings. Do not nest.
17
20
  - Prefer named types `devil-advocate` and `judge`. Use `general-purpose` only if the named type is rejected.
18
21
  - Skip `*.css`, `*report-css*`, generated/vendor. Do not run `git log`.
19
22
 
23
+ | Profile | Intended use | Context behavior |
24
+ |---|---|---|
25
+ | `lean` | Default for normal paid-agent sessions | Smaller packs, compact findings, iteration-delta review |
26
+ | `standard` | Broader routine changes | Moderate packs; still path-first and hunk-first |
27
+ | `thorough` | Explicit human opt-in for expensive review | Previous larger limits; use only when risk justifies cost |
28
+
20
29
  ## Devil's Advocate
21
30
 
22
31
  - At most **8** tool calls, then emit the Finding Ledger.
23
32
  - Read the diff file first. Do not run `git diff` if that path was given.
24
33
  - Open at most **8** files that appear in the diff. Prefer quoting a hunk over opening the whole file.
34
+ - Emit at most **5** findings unless another finding is a BLOCKER. Keep evidence fields short and concrete.
35
+ - On iteration 2+, review only the smart diff-hunk pack's new hunks plus unresolved findings unless the changed evidence reopens an accepted finding.
25
36
  - Report Spec and Standards as separate findings. Do not spawn children to split axes. Do not merge the two axes.
26
37
 
27
38
  ## Judge
@@ -30,3 +41,4 @@ Host files (`.claude/agents/`, `.grok/agents/`, `.agents/`) may differ only in Y
30
41
  - Read the Finding Ledger and Goal Contract first.
31
42
  - Open source only to fact-check a `location` the ledger already cited.
32
43
  - Do not re-review the whole diff. Do not roam the repo.
44
+ - Keep the verdict compact: blocking IDs, accepted tradeoff IDs, and the shortest action that unblocks the next step.