agents-reverse-engineer 0.4.3 → 0.4.4
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.
- package/dist/ai/service.d.ts +9 -0
- package/dist/ai/service.d.ts.map +1 -1
- package/dist/ai/service.js +41 -1
- package/dist/ai/service.js.map +1 -1
- package/dist/ai/subprocess.d.ts.map +1 -1
- package/dist/ai/subprocess.js +1 -0
- package/dist/ai/subprocess.js.map +1 -1
- package/dist/ai/types.d.ts +4 -0
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/types.js.map +1 -1
- package/dist/cli/generate.d.ts +2 -0
- package/dist/cli/generate.d.ts.map +1 -1
- package/dist/cli/generate.js +12 -1
- package/dist/cli/generate.js.map +1 -1
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/update.d.ts +2 -0
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +12 -1
- package/dist/cli/update.js.map +1 -1
- package/dist/config/schema.d.ts +6 -6
- package/dist/integration/templates.d.ts.map +1 -1
- package/dist/integration/templates.js +31 -8
- package/dist/integration/templates.js.map +1 -1
- package/dist/orchestration/index.d.ts +2 -0
- package/dist/orchestration/index.d.ts.map +1 -1
- package/dist/orchestration/index.js +1 -0
- package/dist/orchestration/index.js.map +1 -1
- package/dist/orchestration/pool.d.ts +8 -1
- package/dist/orchestration/pool.d.ts.map +1 -1
- package/dist/orchestration/pool.js +44 -3
- package/dist/orchestration/pool.js.map +1 -1
- package/dist/orchestration/runner.d.ts +2 -0
- package/dist/orchestration/runner.d.ts.map +1 -1
- package/dist/orchestration/runner.js +142 -4
- package/dist/orchestration/runner.js.map +1 -1
- package/dist/orchestration/trace.d.ts +142 -0
- package/dist/orchestration/trace.d.ts.map +1 -0
- package/dist/orchestration/trace.js +135 -0
- package/dist/orchestration/trace.js.map +1 -0
- package/dist/orchestration/types.d.ts +3 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
const COMMANDS = {
|
|
10
10
|
generate: {
|
|
11
11
|
description: 'Generate AI-friendly documentation for the entire codebase',
|
|
12
|
-
argumentHint: '[--budget N] [--dry-run] [--concurrency N] [--verbose] [--fail-fast]',
|
|
12
|
+
argumentHint: '[path] [--budget N] [--dry-run] [--concurrency N] [--verbose] [--quiet] [--fail-fast] [--debug] [--trace]',
|
|
13
13
|
content: `Generate comprehensive documentation for this codebase using agents-reverse-engineer.
|
|
14
14
|
|
|
15
15
|
<execution>
|
|
@@ -33,9 +33,12 @@ This executes a three-phase pipeline:
|
|
|
33
33
|
**Options:**
|
|
34
34
|
- \`--dry-run\`: Preview the plan without making AI calls
|
|
35
35
|
- \`--budget N\`: Override token budget
|
|
36
|
-
- \`--concurrency N\`: Control number of parallel AI calls
|
|
37
|
-
- \`--verbose\`: Show detailed task breakdown
|
|
36
|
+
- \`--concurrency N\`: Control number of parallel AI calls (default: 5)
|
|
38
37
|
- \`--fail-fast\`: Stop on first file analysis failure
|
|
38
|
+
- \`--debug\`: Show AI prompts and backend details
|
|
39
|
+
- \`--trace\`: Enable concurrency tracing to \`.agents-reverse-engineer/traces/\`
|
|
40
|
+
- \`--verbose\`: Show detailed task breakdown
|
|
41
|
+
- \`--quiet\`: Suppress output except errors
|
|
39
42
|
|
|
40
43
|
After completion, summarize:
|
|
41
44
|
- Number of files analyzed and any failures
|
|
@@ -45,7 +48,7 @@ After completion, summarize:
|
|
|
45
48
|
},
|
|
46
49
|
update: {
|
|
47
50
|
description: 'Incrementally update documentation for changed files',
|
|
48
|
-
argumentHint: '[--uncommitted] [--dry-run] [--verbose]',
|
|
51
|
+
argumentHint: '[path] [--uncommitted] [--dry-run] [--budget N] [--concurrency N] [--verbose] [--quiet] [--fail-fast] [--debug] [--trace]',
|
|
49
52
|
content: `Update documentation for files that changed since last run.
|
|
50
53
|
|
|
51
54
|
<execution>
|
|
@@ -55,12 +58,21 @@ Run the agents-reverse-engineer update command:
|
|
|
55
58
|
npx agents-reverse-engineer@latest update $ARGUMENTS
|
|
56
59
|
\`\`\`
|
|
57
60
|
|
|
61
|
+
**Options:**
|
|
62
|
+
- \`--uncommitted\`: Include staged but uncommitted changes
|
|
63
|
+
- \`--dry-run\`: Show what would be updated without writing
|
|
64
|
+
- \`--budget N\`: Override token budget
|
|
65
|
+
- \`--concurrency N\`: Control number of parallel AI calls (default: 5)
|
|
66
|
+
- \`--fail-fast\`: Stop on first file analysis failure
|
|
67
|
+
- \`--debug\`: Show AI prompts and backend details
|
|
68
|
+
- \`--trace\`: Enable concurrency tracing to \`.agents-reverse-engineer/traces/\`
|
|
69
|
+
- \`--verbose\`: Show detailed output
|
|
70
|
+
- \`--quiet\`: Suppress output except errors
|
|
71
|
+
|
|
58
72
|
After completion, summarize:
|
|
59
73
|
- Files updated
|
|
60
74
|
- Files unchanged
|
|
61
75
|
- Any orphaned docs cleaned up
|
|
62
|
-
|
|
63
|
-
Use \`--uncommitted\` to include staged but uncommitted changes.
|
|
64
76
|
</execution>`,
|
|
65
77
|
},
|
|
66
78
|
init: {
|
|
@@ -218,23 +230,28 @@ Generate comprehensive documentation for the codebase.
|
|
|
218
230
|
**Options:**
|
|
219
231
|
| Flag | Description |
|
|
220
232
|
|------|-------------|
|
|
233
|
+
| \`[path]\` | Target directory (default: current directory) |
|
|
221
234
|
| \`--budget N\` | Override token budget (default: from config) |
|
|
235
|
+
| \`--concurrency N\` | Number of concurrent AI calls (default: 5) |
|
|
222
236
|
| \`--dry-run\` | Show what would be generated without writing |
|
|
223
|
-
| \`--concurrency N\` | Control number of parallel AI calls |
|
|
224
237
|
| \`--fail-fast\` | Stop on first file analysis failure |
|
|
238
|
+
| \`--debug\` | Show AI prompts and backend details |
|
|
239
|
+
| \`--trace\` | Enable concurrency tracing to \`.agents-reverse-engineer/traces/\` |
|
|
225
240
|
| \`--verbose, -v\` | Show detailed task breakdown |
|
|
226
241
|
| \`--quiet, -q\` | Suppress output except errors |
|
|
227
242
|
|
|
228
243
|
**Usage:**
|
|
229
244
|
- \`COMMAND_PREFIXgenerate\` — Generate docs
|
|
230
245
|
- \`COMMAND_PREFIXgenerate --dry-run\` — Preview without writing
|
|
246
|
+
- \`COMMAND_PREFIXgenerate --concurrency 3\` — Limit parallel AI calls
|
|
231
247
|
|
|
232
248
|
**CLI:**
|
|
233
249
|
\`\`\`bash
|
|
234
250
|
npx are generate
|
|
235
251
|
npx are generate --dry-run
|
|
236
252
|
npx are generate --budget 50000
|
|
237
|
-
npx are generate --concurrency
|
|
253
|
+
npx are generate ./my-project --concurrency 3
|
|
254
|
+
npx are generate --debug --trace
|
|
238
255
|
\`\`\`
|
|
239
256
|
|
|
240
257
|
**How it works:**
|
|
@@ -252,9 +269,14 @@ Incrementally update documentation for changed files.
|
|
|
252
269
|
**Options:**
|
|
253
270
|
| Flag | Description |
|
|
254
271
|
|------|-------------|
|
|
272
|
+
| \`[path]\` | Target directory (default: current directory) |
|
|
255
273
|
| \`--uncommitted\` | Include staged but uncommitted changes |
|
|
256
274
|
| \`--dry-run\` | Show what would be updated without writing |
|
|
257
275
|
| \`--budget N\` | Override token budget |
|
|
276
|
+
| \`--concurrency N\` | Number of concurrent AI calls (default: 5) |
|
|
277
|
+
| \`--fail-fast\` | Stop on first file analysis failure |
|
|
278
|
+
| \`--debug\` | Show AI prompts and backend details |
|
|
279
|
+
| \`--trace\` | Enable concurrency tracing to \`.agents-reverse-engineer/traces/\` |
|
|
258
280
|
| \`--verbose, -v\` | Show detailed output |
|
|
259
281
|
| \`--quiet, -q\` | Suppress output except errors |
|
|
260
282
|
|
|
@@ -267,6 +289,7 @@ Incrementally update documentation for changed files.
|
|
|
267
289
|
npx are update
|
|
268
290
|
npx are update --uncommitted --verbose
|
|
269
291
|
npx are update --dry-run
|
|
292
|
+
npx are update ./my-project --concurrency 3
|
|
270
293
|
\`\`\`
|
|
271
294
|
|
|
272
295
|
---
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/integration/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE;QACR,WAAW,EAAE,4DAA4D;QACzE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/integration/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,gFAAgF;AAChF,yBAAyB;AACzB,gFAAgF;AAEhF,MAAM,QAAQ,GAAG;IACf,QAAQ,EAAE;QACR,WAAW,EAAE,4DAA4D;QACzE,YAAY,EAAE,2GAA2G;QACzH,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAkCA;KACV;IAED,MAAM,EAAE;QACN,WAAW,EAAE,sDAAsD;QACnE,YAAY,EAAE,2HAA2H;QACzI,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;aAwBA;KACV;IAED,IAAI,EAAE;QACJ,WAAW,EAAE,kDAAkD;QAC/D,YAAY,EAAE,EAAE;QAChB,OAAO,EAAE;;;;;;;;;;aAUA;KACV;IAED,QAAQ,EAAE;QACR,WAAW,EAAE,4BAA4B;QACzC,YAAY,EAAE,6CAA6C;QAC3D,OAAO,EAAE;;;;;;;;;;;;;;;aAeA;KACV;IAED,KAAK,EAAE;QACL,WAAW,EAAE,sEAAsE;QACnF,YAAY,EAAE,aAAa;QAC3B,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA+CA;KACV;IAED,IAAI,EAAE;QACJ,WAAW,EAAE,6CAA6C;QAC1D,YAAY,EAAE,EAAE;QAChB,iEAAiE;QACjE,OAAO,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Options, TaskResult } from './pool.js';
|
|
25
25
|
export { ProgressReporter } from './progress.js';
|
|
26
26
|
export { PlanTracker } from './plan-tracker.js';
|
|
27
|
+
export type { ITraceWriter, TraceEvent, TraceEventPayload } from './trace.js';
|
|
28
|
+
export { createTraceWriter, cleanupOldTraces } from './trace.js';
|
|
27
29
|
export { CommandRunner } from './runner.js';
|
|
28
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,YAAY,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAMzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,YAAY,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAMzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMhD,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMjE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -31,6 +31,7 @@ export { ProgressReporter } from './progress.js';
|
|
|
31
31
|
// Plan tracker
|
|
32
32
|
// ---------------------------------------------------------------------------
|
|
33
33
|
export { PlanTracker } from './plan-tracker.js';
|
|
34
|
+
export { createTraceWriter, cleanupOldTraces } from './trace.js';
|
|
34
35
|
// ---------------------------------------------------------------------------
|
|
35
36
|
// Command runner
|
|
36
37
|
// ---------------------------------------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAaH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAaH,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,8EAA8E;AAC9E,oBAAoB;AACpB,8EAA8E;AAE9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,8EAA8E;AAC9E,eAAe;AACf,8EAA8E;AAE9E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOhD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
|
+
import type { ITraceWriter } from './trace.js';
|
|
13
14
|
/**
|
|
14
15
|
* Options for the concurrency pool.
|
|
15
16
|
*/
|
|
@@ -18,6 +19,12 @@ export interface PoolOptions {
|
|
|
18
19
|
concurrency: number;
|
|
19
20
|
/** Stop pulling new tasks on first error */
|
|
20
21
|
failFast?: boolean;
|
|
22
|
+
/** Trace writer for concurrency debugging (no-op when tracing is off) */
|
|
23
|
+
tracer?: ITraceWriter;
|
|
24
|
+
/** Phase label for trace events (e.g., 'phase-1-files') */
|
|
25
|
+
phaseLabel?: string;
|
|
26
|
+
/** Labels for each task by index (e.g., file paths). Used in trace events. */
|
|
27
|
+
taskLabels?: string[];
|
|
21
28
|
}
|
|
22
29
|
/**
|
|
23
30
|
* Result of a single task execution within the pool.
|
|
@@ -45,7 +52,7 @@ export interface TaskResult<T> {
|
|
|
45
52
|
*
|
|
46
53
|
* @typeParam T - The resolved type of each task
|
|
47
54
|
* @param tasks - Array of zero-argument async functions to execute
|
|
48
|
-
* @param options - Pool configuration (concurrency, failFast)
|
|
55
|
+
* @param options - Pool configuration (concurrency, failFast, tracing)
|
|
49
56
|
* @param onComplete - Optional callback invoked after each task settles
|
|
50
57
|
* @returns Array of results indexed by original task position (may be sparse if aborted)
|
|
51
58
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/orchestration/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/orchestration/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAM/C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,yEAAyE;IACzE,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,gDAAgD;IAChD,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAMD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,KAAK,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC,EAC9B,OAAO,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,GAC3C,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAmG1B"}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*
|
|
24
24
|
* @typeParam T - The resolved type of each task
|
|
25
25
|
* @param tasks - Array of zero-argument async functions to execute
|
|
26
|
-
* @param options - Pool configuration (concurrency, failFast)
|
|
26
|
+
* @param options - Pool configuration (concurrency, failFast, tracing)
|
|
27
27
|
* @param onComplete - Optional callback invoked after each task settles
|
|
28
28
|
* @returns Array of results indexed by original task position (may be sparse if aborted)
|
|
29
29
|
*
|
|
@@ -41,20 +41,60 @@ export async function runPool(tasks, options, onComplete) {
|
|
|
41
41
|
if (tasks.length === 0) {
|
|
42
42
|
return results;
|
|
43
43
|
}
|
|
44
|
+
const tracer = options.tracer;
|
|
45
|
+
const phase = options.phaseLabel ?? 'unknown';
|
|
46
|
+
const taskLabels = options.taskLabels;
|
|
44
47
|
// Shared abort flag -- workers check before pulling next task
|
|
45
48
|
let aborted = false;
|
|
46
|
-
|
|
49
|
+
// Active task counter for trace snapshots
|
|
50
|
+
let activeTasks = 0;
|
|
51
|
+
async function worker(iterator, workerId) {
|
|
52
|
+
let tasksExecuted = 0;
|
|
53
|
+
tracer?.emit({ type: 'worker:start', workerId, phase });
|
|
47
54
|
for (const [index, task] of iterator) {
|
|
48
55
|
if (aborted)
|
|
49
56
|
break;
|
|
57
|
+
activeTasks++;
|
|
58
|
+
const taskStart = Date.now();
|
|
59
|
+
const label = taskLabels?.[index] ?? `task-${index}`;
|
|
60
|
+
tracer?.emit({
|
|
61
|
+
type: 'task:pickup',
|
|
62
|
+
workerId,
|
|
63
|
+
taskIndex: index,
|
|
64
|
+
taskLabel: label,
|
|
65
|
+
activeTasks,
|
|
66
|
+
});
|
|
50
67
|
try {
|
|
51
68
|
const value = await task();
|
|
69
|
+
activeTasks--;
|
|
70
|
+
tasksExecuted++;
|
|
71
|
+
tracer?.emit({
|
|
72
|
+
type: 'task:done',
|
|
73
|
+
workerId,
|
|
74
|
+
taskIndex: index,
|
|
75
|
+
taskLabel: label,
|
|
76
|
+
durationMs: Date.now() - taskStart,
|
|
77
|
+
success: true,
|
|
78
|
+
activeTasks,
|
|
79
|
+
});
|
|
52
80
|
const result = { index, success: true, value };
|
|
53
81
|
results[index] = result;
|
|
54
82
|
onComplete?.(result);
|
|
55
83
|
}
|
|
56
84
|
catch (err) {
|
|
85
|
+
activeTasks--;
|
|
86
|
+
tasksExecuted++;
|
|
57
87
|
const error = err instanceof Error ? err : new Error(String(err));
|
|
88
|
+
tracer?.emit({
|
|
89
|
+
type: 'task:done',
|
|
90
|
+
workerId,
|
|
91
|
+
taskIndex: index,
|
|
92
|
+
taskLabel: label,
|
|
93
|
+
durationMs: Date.now() - taskStart,
|
|
94
|
+
success: false,
|
|
95
|
+
error: error.message,
|
|
96
|
+
activeTasks,
|
|
97
|
+
});
|
|
58
98
|
const result = { index, success: false, error };
|
|
59
99
|
results[index] = result;
|
|
60
100
|
onComplete?.(result);
|
|
@@ -64,11 +104,12 @@ export async function runPool(tasks, options, onComplete) {
|
|
|
64
104
|
}
|
|
65
105
|
}
|
|
66
106
|
}
|
|
107
|
+
tracer?.emit({ type: 'worker:end', workerId, phase, tasksExecuted });
|
|
67
108
|
}
|
|
68
109
|
// Spawn workers, capped at the number of available tasks
|
|
69
110
|
const effectiveConcurrency = Math.min(options.concurrency, tasks.length);
|
|
70
111
|
const iterator = tasks.entries();
|
|
71
|
-
const workers = Array.from({ length: effectiveConcurrency }, () => worker(iterator));
|
|
112
|
+
const workers = Array.from({ length: effectiveConcurrency }, (_, workerId) => worker(iterator, workerId));
|
|
72
113
|
await Promise.allSettled(workers);
|
|
73
114
|
return results;
|
|
74
115
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/orchestration/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"pool.js","sourceRoot":"","sources":["../../src/orchestration/pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAyCH,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,KAA8B,EAC9B,OAAoB,EACpB,UAA4C;IAE5C,MAAM,OAAO,GAAoB,EAAE,CAAC;IAEpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,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,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,oBAAoB,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,CAC3E,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAC3B,CAAC;IAEF,MAAM,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/orchestration/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AAK9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/orchestration/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,KAAK,EAAE,aAAa,EAAiB,MAAM,2BAA2B,CAAC;AAK9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAG/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAalD,OAAO,KAAK,EAEV,UAAU,EACV,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAMpB;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAa;IACxB,2CAA2C;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAEtC,gCAAgC;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAE5C,6CAA6C;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2B;IAElD;;;;;OAKG;gBACS,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB;IAW5D;;;;;;;;;;OAUG;IACG,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC;IA2a/D;;;;;;;;;;;OAWG;IACG,aAAa,CACjB,cAAc,EAAE,UAAU,EAAE,EAC5B,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,CAAC;CA8QvB"}
|
|
@@ -50,6 +50,8 @@ export class CommandRunner {
|
|
|
50
50
|
aiService;
|
|
51
51
|
/** Command execution options */
|
|
52
52
|
options;
|
|
53
|
+
/** Trace writer for concurrency debugging */
|
|
54
|
+
tracer;
|
|
53
55
|
/**
|
|
54
56
|
* Create a new command runner.
|
|
55
57
|
*
|
|
@@ -59,6 +61,11 @@ export class CommandRunner {
|
|
|
59
61
|
constructor(aiService, options) {
|
|
60
62
|
this.aiService = aiService;
|
|
61
63
|
this.options = options;
|
|
64
|
+
this.tracer = options.tracer;
|
|
65
|
+
// Wire the tracer into the AI service for subprocess/retry events
|
|
66
|
+
if (this.tracer) {
|
|
67
|
+
this.aiService.setTracer(this.tracer);
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
/**
|
|
64
71
|
* Execute the `generate` command using a pre-built execution plan.
|
|
@@ -83,6 +90,13 @@ export class CommandRunner {
|
|
|
83
90
|
// Pre-Phase 1: Cache old .sum content for stale documentation detection
|
|
84
91
|
// Throttled to avoid opening too many file descriptors at once.
|
|
85
92
|
// -------------------------------------------------------------------
|
|
93
|
+
const prePhase1Start = Date.now();
|
|
94
|
+
this.tracer?.emit({
|
|
95
|
+
type: 'phase:start',
|
|
96
|
+
phase: 'pre-phase-1-cache',
|
|
97
|
+
taskCount: plan.fileTasks.length,
|
|
98
|
+
concurrency: 20,
|
|
99
|
+
});
|
|
86
100
|
const oldSumCache = new Map();
|
|
87
101
|
const sumReadTasks = plan.fileTasks.map((task) => async () => {
|
|
88
102
|
try {
|
|
@@ -95,10 +109,29 @@ export class CommandRunner {
|
|
|
95
109
|
// No old .sum to compare -- skip
|
|
96
110
|
}
|
|
97
111
|
});
|
|
98
|
-
await runPool(sumReadTasks, {
|
|
112
|
+
await runPool(sumReadTasks, {
|
|
113
|
+
concurrency: 20,
|
|
114
|
+
tracer: this.tracer,
|
|
115
|
+
phaseLabel: 'pre-phase-1-cache',
|
|
116
|
+
taskLabels: plan.fileTasks.map(t => t.path),
|
|
117
|
+
});
|
|
118
|
+
this.tracer?.emit({
|
|
119
|
+
type: 'phase:end',
|
|
120
|
+
phase: 'pre-phase-1-cache',
|
|
121
|
+
durationMs: Date.now() - prePhase1Start,
|
|
122
|
+
tasksCompleted: plan.fileTasks.length,
|
|
123
|
+
tasksFailed: 0,
|
|
124
|
+
});
|
|
99
125
|
// -------------------------------------------------------------------
|
|
100
126
|
// Phase 1: File analysis (concurrent)
|
|
101
127
|
// -------------------------------------------------------------------
|
|
128
|
+
const phase1Start = Date.now();
|
|
129
|
+
this.tracer?.emit({
|
|
130
|
+
type: 'phase:start',
|
|
131
|
+
phase: 'phase-1-files',
|
|
132
|
+
taskCount: plan.fileTasks.length,
|
|
133
|
+
concurrency: this.options.concurrency,
|
|
134
|
+
});
|
|
102
135
|
// Cache source content during Phase 1, reused for inconsistency detection
|
|
103
136
|
const sourceContentCache = new Map();
|
|
104
137
|
const fileTasks = plan.fileTasks.map((task, taskIndex) => async () => {
|
|
@@ -111,6 +144,7 @@ export class CommandRunner {
|
|
|
111
144
|
const response = await this.aiService.call({
|
|
112
145
|
prompt: task.userPrompt,
|
|
113
146
|
systemPrompt: task.systemPrompt,
|
|
147
|
+
taskLabel: task.path,
|
|
114
148
|
});
|
|
115
149
|
// Track file size for telemetry (from in-memory content, avoids stat syscall)
|
|
116
150
|
this.aiService.addFilesReadToLastEntry([{
|
|
@@ -147,6 +181,9 @@ export class CommandRunner {
|
|
|
147
181
|
const poolResults = await runPool(fileTasks, {
|
|
148
182
|
concurrency: this.options.concurrency,
|
|
149
183
|
failFast: this.options.failFast,
|
|
184
|
+
tracer: this.tracer,
|
|
185
|
+
phaseLabel: 'phase-1-files',
|
|
186
|
+
taskLabels: plan.fileTasks.map(t => t.path),
|
|
150
187
|
}, (result) => {
|
|
151
188
|
if (result.success && result.value) {
|
|
152
189
|
const v = result.value;
|
|
@@ -161,6 +198,13 @@ export class CommandRunner {
|
|
|
161
198
|
reporter.onFileError(taskPath, errorMsg);
|
|
162
199
|
}
|
|
163
200
|
});
|
|
201
|
+
this.tracer?.emit({
|
|
202
|
+
type: 'phase:end',
|
|
203
|
+
phase: 'phase-1-files',
|
|
204
|
+
durationMs: Date.now() - phase1Start,
|
|
205
|
+
tasksCompleted: filesProcessed,
|
|
206
|
+
tasksFailed: filesFailed,
|
|
207
|
+
});
|
|
164
208
|
// -------------------------------------------------------------------
|
|
165
209
|
// Post-Phase 1: Inconsistency detection (non-throwing)
|
|
166
210
|
// -------------------------------------------------------------------
|
|
@@ -191,6 +235,12 @@ export class CommandRunner {
|
|
|
191
235
|
}
|
|
192
236
|
// Run checks per directory group (throttled to avoid excessive parallel I/O)
|
|
193
237
|
const dirEntries = Array.from(dirGroups.entries());
|
|
238
|
+
this.tracer?.emit({
|
|
239
|
+
type: 'phase:start',
|
|
240
|
+
phase: 'post-phase-1-quality',
|
|
241
|
+
taskCount: dirEntries.length,
|
|
242
|
+
concurrency: 10,
|
|
243
|
+
});
|
|
194
244
|
const dirCheckResults = [];
|
|
195
245
|
const dirCheckTasks = dirEntries.map(([, groupPaths], groupIndex) => async () => {
|
|
196
246
|
const dirIssues = [];
|
|
@@ -237,7 +287,19 @@ export class CommandRunner {
|
|
|
237
287
|
dirIssues.push(...codeIssues);
|
|
238
288
|
dirCheckResults[groupIndex] = dirIssues;
|
|
239
289
|
});
|
|
240
|
-
await runPool(dirCheckTasks, {
|
|
290
|
+
await runPool(dirCheckTasks, {
|
|
291
|
+
concurrency: 10,
|
|
292
|
+
tracer: this.tracer,
|
|
293
|
+
phaseLabel: 'post-phase-1-quality',
|
|
294
|
+
taskLabels: dirEntries.map(([dirPath]) => dirPath),
|
|
295
|
+
});
|
|
296
|
+
this.tracer?.emit({
|
|
297
|
+
type: 'phase:end',
|
|
298
|
+
phase: 'post-phase-1-quality',
|
|
299
|
+
durationMs: Date.now() - inconsistencyStart,
|
|
300
|
+
tasksCompleted: dirEntries.length,
|
|
301
|
+
tasksFailed: 0,
|
|
302
|
+
});
|
|
241
303
|
const allIssuesFlat = dirCheckResults.filter(Boolean).flat();
|
|
242
304
|
allIssues.push(...allIssuesFlat);
|
|
243
305
|
// Release cached source content to free memory
|
|
@@ -278,33 +340,70 @@ export class CommandRunner {
|
|
|
278
340
|
const depthLevels = Array.from(dirsByDepth.keys()).sort((a, b) => b - a);
|
|
279
341
|
for (const depth of depthLevels) {
|
|
280
342
|
const dirsAtDepth = dirsByDepth.get(depth);
|
|
343
|
+
const phaseLabel = `phase-2-dirs-depth-${depth}`;
|
|
344
|
+
const dirConcurrency = Math.min(this.options.concurrency, dirsAtDepth.length);
|
|
345
|
+
const phase2Start = Date.now();
|
|
346
|
+
this.tracer?.emit({
|
|
347
|
+
type: 'phase:start',
|
|
348
|
+
phase: phaseLabel,
|
|
349
|
+
taskCount: dirsAtDepth.length,
|
|
350
|
+
concurrency: dirConcurrency,
|
|
351
|
+
});
|
|
281
352
|
const dirTasks = dirsAtDepth.map((dirTask) => async () => {
|
|
282
353
|
const prompt = await buildDirectoryPrompt(dirTask.absolutePath, plan.projectRoot);
|
|
283
354
|
const dirResponse = await this.aiService.call({
|
|
284
355
|
prompt: prompt.user,
|
|
285
356
|
systemPrompt: prompt.system,
|
|
357
|
+
taskLabel: `${dirTask.path}/AGENTS.md`,
|
|
286
358
|
});
|
|
287
359
|
await writeAgentsMd(dirTask.absolutePath, plan.projectRoot, dirResponse.text);
|
|
288
360
|
reporter.onDirectoryDone(dirTask.path);
|
|
289
361
|
planTracker.markDone(`${dirTask.path}/AGENTS.md`);
|
|
290
362
|
});
|
|
291
363
|
await runPool(dirTasks, {
|
|
292
|
-
concurrency:
|
|
364
|
+
concurrency: dirConcurrency,
|
|
293
365
|
failFast: this.options.failFast,
|
|
366
|
+
tracer: this.tracer,
|
|
367
|
+
phaseLabel,
|
|
368
|
+
taskLabels: dirsAtDepth.map(t => t.path),
|
|
369
|
+
});
|
|
370
|
+
this.tracer?.emit({
|
|
371
|
+
type: 'phase:end',
|
|
372
|
+
phase: phaseLabel,
|
|
373
|
+
durationMs: Date.now() - phase2Start,
|
|
374
|
+
tasksCompleted: dirsAtDepth.length,
|
|
375
|
+
tasksFailed: 0,
|
|
294
376
|
});
|
|
295
377
|
}
|
|
296
378
|
// -------------------------------------------------------------------
|
|
297
379
|
// Phase 3: Root documents (sequential)
|
|
298
380
|
// -------------------------------------------------------------------
|
|
381
|
+
const phase3Start = Date.now();
|
|
382
|
+
this.tracer?.emit({
|
|
383
|
+
type: 'phase:start',
|
|
384
|
+
phase: 'phase-3-root',
|
|
385
|
+
taskCount: plan.rootTasks.length,
|
|
386
|
+
concurrency: 1,
|
|
387
|
+
});
|
|
388
|
+
let rootTasksCompleted = 0;
|
|
299
389
|
for (const rootTask of plan.rootTasks) {
|
|
300
390
|
const response = await this.aiService.call({
|
|
301
391
|
prompt: rootTask.userPrompt,
|
|
302
392
|
systemPrompt: rootTask.systemPrompt,
|
|
393
|
+
taskLabel: rootTask.path,
|
|
303
394
|
});
|
|
304
395
|
await writeFile(rootTask.outputPath, response.text, 'utf-8');
|
|
305
396
|
reporter.onRootDone(rootTask.path);
|
|
306
397
|
planTracker.markDone(rootTask.path);
|
|
398
|
+
rootTasksCompleted++;
|
|
307
399
|
}
|
|
400
|
+
this.tracer?.emit({
|
|
401
|
+
type: 'phase:end',
|
|
402
|
+
phase: 'phase-3-root',
|
|
403
|
+
durationMs: Date.now() - phase3Start,
|
|
404
|
+
tasksCompleted: rootTasksCompleted,
|
|
405
|
+
tasksFailed: 0,
|
|
406
|
+
});
|
|
308
407
|
// Ensure all plan tracker writes are flushed
|
|
309
408
|
await planTracker.flush();
|
|
310
409
|
// -------------------------------------------------------------------
|
|
@@ -350,6 +449,16 @@ export class CommandRunner {
|
|
|
350
449
|
const runStart = Date.now();
|
|
351
450
|
let filesProcessed = 0;
|
|
352
451
|
let filesFailed = 0;
|
|
452
|
+
// -------------------------------------------------------------------
|
|
453
|
+
// Phase 1: File analysis (concurrent)
|
|
454
|
+
// -------------------------------------------------------------------
|
|
455
|
+
const phase1Start = Date.now();
|
|
456
|
+
this.tracer?.emit({
|
|
457
|
+
type: 'phase:start',
|
|
458
|
+
phase: 'update-phase-1-files',
|
|
459
|
+
taskCount: filesToAnalyze.length,
|
|
460
|
+
concurrency: this.options.concurrency,
|
|
461
|
+
});
|
|
353
462
|
// Cache source content during update, reused for inconsistency detection
|
|
354
463
|
const updateSourceCache = new Map();
|
|
355
464
|
const updateTasks = filesToAnalyze.map((file, fileIndex) => async () => {
|
|
@@ -370,6 +479,7 @@ export class CommandRunner {
|
|
|
370
479
|
const response = await this.aiService.call({
|
|
371
480
|
prompt: prompt.user,
|
|
372
481
|
systemPrompt: prompt.system,
|
|
482
|
+
taskLabel: file.path,
|
|
373
483
|
});
|
|
374
484
|
// Track file size for telemetry (from in-memory content, avoids stat syscall)
|
|
375
485
|
this.aiService.addFilesReadToLastEntry([{
|
|
@@ -406,6 +516,9 @@ export class CommandRunner {
|
|
|
406
516
|
const poolResults = await runPool(updateTasks, {
|
|
407
517
|
concurrency: this.options.concurrency,
|
|
408
518
|
failFast: this.options.failFast,
|
|
519
|
+
tracer: this.tracer,
|
|
520
|
+
phaseLabel: 'update-phase-1-files',
|
|
521
|
+
taskLabels: filesToAnalyze.map(f => f.path),
|
|
409
522
|
}, (result) => {
|
|
410
523
|
if (result.success && result.value) {
|
|
411
524
|
const v = result.value;
|
|
@@ -419,6 +532,13 @@ export class CommandRunner {
|
|
|
419
532
|
reporter.onFileError(filePath, errorMsg);
|
|
420
533
|
}
|
|
421
534
|
});
|
|
535
|
+
this.tracer?.emit({
|
|
536
|
+
type: 'phase:end',
|
|
537
|
+
phase: 'update-phase-1-files',
|
|
538
|
+
durationMs: Date.now() - phase1Start,
|
|
539
|
+
tasksCompleted: filesProcessed,
|
|
540
|
+
tasksFailed: filesFailed,
|
|
541
|
+
});
|
|
422
542
|
// -------------------------------------------------------------------
|
|
423
543
|
// Post-analysis: Inconsistency detection (non-throwing)
|
|
424
544
|
// -------------------------------------------------------------------
|
|
@@ -449,6 +569,12 @@ export class CommandRunner {
|
|
|
449
569
|
}
|
|
450
570
|
// Run checks per directory group (throttled to avoid excessive parallel I/O)
|
|
451
571
|
const updateDirEntries = Array.from(dirGroups.entries());
|
|
572
|
+
this.tracer?.emit({
|
|
573
|
+
type: 'phase:start',
|
|
574
|
+
phase: 'update-post-phase-1-quality',
|
|
575
|
+
taskCount: updateDirEntries.length,
|
|
576
|
+
concurrency: 10,
|
|
577
|
+
});
|
|
452
578
|
const updateDirResults = [];
|
|
453
579
|
const updateDirCheckTasks = updateDirEntries.map(([, groupPaths], groupIndex) => async () => {
|
|
454
580
|
const dirIssues = [];
|
|
@@ -485,7 +611,19 @@ export class CommandRunner {
|
|
|
485
611
|
dirIssues.push(...codeIssues);
|
|
486
612
|
updateDirResults[groupIndex] = dirIssues;
|
|
487
613
|
});
|
|
488
|
-
await runPool(updateDirCheckTasks, {
|
|
614
|
+
await runPool(updateDirCheckTasks, {
|
|
615
|
+
concurrency: 10,
|
|
616
|
+
tracer: this.tracer,
|
|
617
|
+
phaseLabel: 'update-post-phase-1-quality',
|
|
618
|
+
taskLabels: updateDirEntries.map(([dirPath]) => dirPath),
|
|
619
|
+
});
|
|
620
|
+
this.tracer?.emit({
|
|
621
|
+
type: 'phase:end',
|
|
622
|
+
phase: 'update-post-phase-1-quality',
|
|
623
|
+
durationMs: Date.now() - inconsistencyStart,
|
|
624
|
+
tasksCompleted: updateDirEntries.length,
|
|
625
|
+
tasksFailed: 0,
|
|
626
|
+
});
|
|
489
627
|
const allIssuesFlat = updateDirResults.filter(Boolean).flat();
|
|
490
628
|
allIssues.push(...allIssuesFlat);
|
|
491
629
|
// Release cached source content to free memory
|