agent-nuvira 1.19.0 → 1.21.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.
- package/dist/agents/inspect-module.d.ts +134 -0
- package/dist/agents/inspect-module.d.ts.map +1 -0
- package/dist/agents/inspect-module.js +266 -0
- package/dist/agents/inspect-module.js.map +1 -0
- package/dist/agents/orchestrator.d.ts +4 -1
- package/dist/agents/orchestrator.d.ts.map +1 -1
- package/dist/agents/orchestrator.js +23 -9
- package/dist/agents/orchestrator.js.map +1 -1
- package/dist/agents/report-module.d.ts +152 -0
- package/dist/agents/report-module.d.ts.map +1 -0
- package/dist/agents/report-module.js +365 -0
- package/dist/agents/report-module.js.map +1 -0
- package/dist/agents/utils/file-tree.d.ts +4 -0
- package/dist/agents/utils/file-tree.d.ts.map +1 -1
- package/dist/agents/utils/file-tree.js +2 -2
- package/dist/agents/utils/file-tree.js.map +1 -1
- package/dist/agents/verify-module.d.ts +110 -0
- package/dist/agents/verify-module.d.ts.map +1 -0
- package/dist/agents/verify-module.js +261 -0
- package/dist/agents/verify-module.js.map +1 -0
- package/dist/cli/execute.d.ts.map +1 -1
- package/dist/cli/execute.js +24 -4
- package/dist/cli/execute.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/observability/event-bus.d.ts.map +1 -1
- package/dist/observability/event-bus.js +32 -0
- package/dist/observability/event-bus.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InspectModule — Scans the codebase to discover relevant files, extract
|
|
3
|
+
* structural context, and identify dependencies. Phase 6 adds LLM-based
|
|
4
|
+
* file classification with keyword-scanning fallback.
|
|
5
|
+
*
|
|
6
|
+
* @see ARCHITECTURE.md §3.2 — Inspect Module specification
|
|
7
|
+
*/
|
|
8
|
+
import type { EventBus } from '../observability/event-bus.js';
|
|
9
|
+
import type { LLMCallFn } from './agent.js';
|
|
10
|
+
/**
|
|
11
|
+
* A discovered file artifact with its content.
|
|
12
|
+
* Prefixed with "Inspect" to avoid collision with agent.ts's Artifact type.
|
|
13
|
+
*/
|
|
14
|
+
export interface InspectArtifact {
|
|
15
|
+
/** Relative path from the project root */
|
|
16
|
+
path: string;
|
|
17
|
+
/** Full file contents */
|
|
18
|
+
content: string;
|
|
19
|
+
/** Human-readable description (e.g. 'src/index.ts (12.5k characters)') */
|
|
20
|
+
description: string;
|
|
21
|
+
}
|
|
22
|
+
/** Statistics about the inspection run */
|
|
23
|
+
export interface InspectionStats {
|
|
24
|
+
/** Total files in the project */
|
|
25
|
+
totalFiles: number;
|
|
26
|
+
/** Files that were inspected / read */
|
|
27
|
+
inspectedFiles: number;
|
|
28
|
+
/** Number of errors encountered during inspection */
|
|
29
|
+
errors: number;
|
|
30
|
+
/** Whether the LLM-based classification fell back to keyword scanning */
|
|
31
|
+
llmFallbackUsed: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** Result of a codebase inspection */
|
|
34
|
+
export interface InspectionResult {
|
|
35
|
+
/** Discovered file artifacts with full contents */
|
|
36
|
+
artifacts: InspectArtifact[];
|
|
37
|
+
/** Text representation of the project file tree */
|
|
38
|
+
fileTree: string;
|
|
39
|
+
/** File paths that are relevant to the goal */
|
|
40
|
+
relevantPaths: string[];
|
|
41
|
+
/** Inspection statistics */
|
|
42
|
+
stats: InspectionStats;
|
|
43
|
+
}
|
|
44
|
+
/** Parameters for the InspectModule.inspect() method */
|
|
45
|
+
export interface InspectParams {
|
|
46
|
+
/** The user's goal / task description */
|
|
47
|
+
goal: string;
|
|
48
|
+
/** Working directory of the project */
|
|
49
|
+
workingDirectory: string;
|
|
50
|
+
/** Optional list of task plan descriptions for context */
|
|
51
|
+
taskDescriptions?: string[];
|
|
52
|
+
/** Maximum number of files to inspect (default: 10) */
|
|
53
|
+
maxFiles?: number;
|
|
54
|
+
/**
|
|
55
|
+
* Optional LLM call function for LLM-based file classification.
|
|
56
|
+
* When provided, the module first asks the LLM to identify relevant
|
|
57
|
+
* files. Falls back to keyword scanning if the LLM call fails.
|
|
58
|
+
* When omitted, only keyword scanning is used.
|
|
59
|
+
*/
|
|
60
|
+
callLLM?: LLMCallFn;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* PlanStep-like interface for dependency-aware planning.
|
|
64
|
+
* A minimal version of what the PlanModule produces.
|
|
65
|
+
*/
|
|
66
|
+
export interface PlanStepRef {
|
|
67
|
+
id: string;
|
|
68
|
+
description: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* InspectModule — Scan the codebase to discover relevant files, extract
|
|
72
|
+
* structural context, and identify dependencies.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const module = new DefaultInspectModule();
|
|
77
|
+
* const result = await module.inspect({
|
|
78
|
+
* goal: 'Add JWT auth',
|
|
79
|
+
* workingDirectory: '/project',
|
|
80
|
+
* });
|
|
81
|
+
* console.log(result.artifacts.length); // Files discovered
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
export interface InspectModule {
|
|
85
|
+
/**
|
|
86
|
+
* Scan the codebase for files relevant to the given goal.
|
|
87
|
+
* Uses LLM-based classification with keyword fallback.
|
|
88
|
+
*/
|
|
89
|
+
inspect(params: InspectParams): Promise<InspectionResult>;
|
|
90
|
+
/**
|
|
91
|
+
* Synchronous fallback — scans files by keyword matching against the goal.
|
|
92
|
+
* Used when the LLM call fails or times out.
|
|
93
|
+
*/
|
|
94
|
+
scanByKeywords(goal: string, workingDir: string): string[];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* DefaultInspectModule — Built-in inspect module implementation.
|
|
98
|
+
*
|
|
99
|
+
* Wraps the existing keyword-scanning logic (previously private to
|
|
100
|
+
* ContextGathererAgent) into the modular InspectModule interface.
|
|
101
|
+
* The LLM-based file identification is delegated to the agent system
|
|
102
|
+
* via the callLLM parameter — when no callLLM is provided, only
|
|
103
|
+
* keyword-based scanning is used.
|
|
104
|
+
*/
|
|
105
|
+
export declare class DefaultInspectModule implements InspectModule {
|
|
106
|
+
/** The event bus for emitting observability events */
|
|
107
|
+
private eventBus;
|
|
108
|
+
constructor(eventBus?: EventBus);
|
|
109
|
+
/**
|
|
110
|
+
* Scan the codebase for files relevant to the given goal.
|
|
111
|
+
* Phase 6: Uses LLM-based classification with keyword-scanning fallback.
|
|
112
|
+
*/
|
|
113
|
+
inspect(params: InspectParams): Promise<InspectionResult>;
|
|
114
|
+
/**
|
|
115
|
+
* Synchronous fallback — scan files by keyword matching against the goal.
|
|
116
|
+
* Used when the LLM call fails or as the base implementation.
|
|
117
|
+
*/
|
|
118
|
+
scanByKeywords(goal: string, workingDir: string): string[];
|
|
119
|
+
/**
|
|
120
|
+
* Use the LLM to identify files relevant to the goal.
|
|
121
|
+
* Parses the LLM response as a JSON array of file paths.
|
|
122
|
+
* Throws if parsing fails or file list is empty.
|
|
123
|
+
*/
|
|
124
|
+
private classifyFiles;
|
|
125
|
+
/** Build the prompt for LLM-based file classification */
|
|
126
|
+
private buildClassifyPrompt;
|
|
127
|
+
/** Parse the LLM response into an array of file paths. Throws on failure. */
|
|
128
|
+
private parseClassifyResponse;
|
|
129
|
+
/** Walk the directory tree and score files by keyword relevance */
|
|
130
|
+
private walkAndScore;
|
|
131
|
+
/** Format byte count to human-readable string */
|
|
132
|
+
private formatSize;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=inspect-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-module.d.ts","sourceRoot":"","sources":["../../src/agents/inspect-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C;;;GAGG;AACH,MAAM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M,GAAG,MAAM,EAAE,CAAC;CAC5D;AAYD;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,YAAW,aAAa;IACxD,sDAAsD;IACtD,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,CAAC,EAAE,QAAQ;IAI/B;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAkH/D;;;OAGG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;IAwB1D;;;;OAIG;YACW,aAAa;IAY3B,yDAAyD;IACzD,OAAO,CAAC,mBAAmB;IA8B3B,6EAA6E;IAC7E,OAAO,CAAC,qBAAqB;IA8B7B,mEAAmE;IACnE,OAAO,CAAC,YAAY;IAgDpB,iDAAiD;IACjD,OAAO,CAAC,UAAU;CAKnB"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InspectModule — Scans the codebase to discover relevant files, extract
|
|
3
|
+
* structural context, and identify dependencies. Phase 6 adds LLM-based
|
|
4
|
+
* file classification with keyword-scanning fallback.
|
|
5
|
+
*
|
|
6
|
+
* @see ARCHITECTURE.md §3.2 — Inspect Module specification
|
|
7
|
+
*/
|
|
8
|
+
import { join, relative } from 'node:path';
|
|
9
|
+
import { existsSync, readFileSync, statSync, readdirSync } from 'node:fs';
|
|
10
|
+
import { getEventBus, EventNames } from '../observability/event-bus.js';
|
|
11
|
+
import { buildProjectFileTree } from './utils/file-tree.js';
|
|
12
|
+
// ─── Constants ──────────────────────────────────────────────────────────────
|
|
13
|
+
// Reuse constants from the shared file-tree utility to avoid duplication
|
|
14
|
+
import { SOURCE_EXTENSIONS, IGNORE_DIRS } from './utils/file-tree.js';
|
|
15
|
+
/** Maximum characters per file when reading */
|
|
16
|
+
const MAX_FILE_CHARS = 100_000;
|
|
17
|
+
// ─── Default InspectModule ─────────────────────────────────────────────────
|
|
18
|
+
/**
|
|
19
|
+
* DefaultInspectModule — Built-in inspect module implementation.
|
|
20
|
+
*
|
|
21
|
+
* Wraps the existing keyword-scanning logic (previously private to
|
|
22
|
+
* ContextGathererAgent) into the modular InspectModule interface.
|
|
23
|
+
* The LLM-based file identification is delegated to the agent system
|
|
24
|
+
* via the callLLM parameter — when no callLLM is provided, only
|
|
25
|
+
* keyword-based scanning is used.
|
|
26
|
+
*/
|
|
27
|
+
export class DefaultInspectModule {
|
|
28
|
+
/** The event bus for emitting observability events */
|
|
29
|
+
eventBus;
|
|
30
|
+
constructor(eventBus) {
|
|
31
|
+
this.eventBus = eventBus ?? getEventBus();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Scan the codebase for files relevant to the given goal.
|
|
35
|
+
* Phase 6: Uses LLM-based classification with keyword-scanning fallback.
|
|
36
|
+
*/
|
|
37
|
+
async inspect(params) {
|
|
38
|
+
const { goal, workingDirectory, taskDescriptions, maxFiles = 10, callLLM } = params;
|
|
39
|
+
// ── Emit: scanning started ───────────────────────────────────────
|
|
40
|
+
this.eventBus.emit(EventNames.INSPECT_SCANNING, {
|
|
41
|
+
directory: workingDirectory,
|
|
42
|
+
goal,
|
|
43
|
+
}, 'inspect-module');
|
|
44
|
+
// 1. Build the project file tree
|
|
45
|
+
const fileTree = await buildProjectFileTree(workingDirectory);
|
|
46
|
+
const totalFiles = fileTree.split('\n').filter((l) => l.includes('📄')).length;
|
|
47
|
+
// 2. Identify relevant paths — try LLM first, fall back to keywords
|
|
48
|
+
let usedLlm = false;
|
|
49
|
+
let relevantPaths;
|
|
50
|
+
if (callLLM) {
|
|
51
|
+
try {
|
|
52
|
+
relevantPaths = await this.classifyFiles({
|
|
53
|
+
goal,
|
|
54
|
+
workingDirectory,
|
|
55
|
+
fileTree,
|
|
56
|
+
callLLM,
|
|
57
|
+
taskDescriptions,
|
|
58
|
+
});
|
|
59
|
+
usedLlm = true;
|
|
60
|
+
// ── Emit: LLM classification completed ───────────────────────
|
|
61
|
+
this.eventBus.emit(EventNames.INSPECT_LLM_CLASSIFY, {
|
|
62
|
+
fileCount: relevantPaths.length,
|
|
63
|
+
method: 'llm',
|
|
64
|
+
}, 'inspect-module');
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// LLM call failed — fall back to keyword scanning
|
|
68
|
+
relevantPaths = this.scanByKeywords(goal, workingDirectory);
|
|
69
|
+
// ── Emit: LLM classification failed, using fallback ──────────
|
|
70
|
+
this.eventBus.emit(EventNames.INSPECT_LLM_CLASSIFY, {
|
|
71
|
+
fileCount: relevantPaths.length,
|
|
72
|
+
method: 'keyword-fallback',
|
|
73
|
+
}, 'inspect-module');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
// No callLLM provided — use keyword scanning directly
|
|
78
|
+
relevantPaths = this.scanByKeywords(goal, workingDirectory);
|
|
79
|
+
}
|
|
80
|
+
// Limit to maxFiles
|
|
81
|
+
const limitedPaths = relevantPaths.slice(0, maxFiles);
|
|
82
|
+
// 3. Read the identified files
|
|
83
|
+
const artifacts = [];
|
|
84
|
+
const errors = [];
|
|
85
|
+
for (const filePath of limitedPaths) {
|
|
86
|
+
const absolutePath = join(workingDirectory, filePath);
|
|
87
|
+
if (!existsSync(absolutePath) || !statSync(absolutePath).isFile()) {
|
|
88
|
+
errors.push(`File not found: ${filePath}`);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const size = statSync(absolutePath).size;
|
|
93
|
+
if (size > MAX_FILE_CHARS) {
|
|
94
|
+
errors.push(`File too large: ${filePath} (${this.formatSize(size)})`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const content = readFileSync(absolutePath, 'utf-8');
|
|
98
|
+
// ── Emit: file found event ───────────────────────────────────
|
|
99
|
+
this.eventBus.emit(EventNames.INSPECT_FILE_FOUND, {
|
|
100
|
+
path: filePath,
|
|
101
|
+
extension: filePath.slice(filePath.lastIndexOf('.')),
|
|
102
|
+
size,
|
|
103
|
+
}, 'inspect-module');
|
|
104
|
+
artifacts.push({
|
|
105
|
+
path: filePath,
|
|
106
|
+
content,
|
|
107
|
+
description: `${filePath} (${this.formatSize(content.length)} characters)`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
errors.push(`Could not read: ${filePath}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const stats = {
|
|
115
|
+
totalFiles,
|
|
116
|
+
inspectedFiles: artifacts.length,
|
|
117
|
+
errors: errors.length,
|
|
118
|
+
// When callLLM was provided and succeeded, LLM was used (no fallback).
|
|
119
|
+
// When callLLM was provided but failed, or when no callLLM was given,
|
|
120
|
+
// keyword scanning was used (the fallback).
|
|
121
|
+
llmFallbackUsed: !usedLlm,
|
|
122
|
+
};
|
|
123
|
+
// ── Emit: completed event ────────────────────────────────────────
|
|
124
|
+
this.eventBus.emit(EventNames.INSPECT_COMPLETED, {
|
|
125
|
+
artifactCount: artifacts.length,
|
|
126
|
+
errors: errors.length,
|
|
127
|
+
totalFiles,
|
|
128
|
+
}, 'inspect-module');
|
|
129
|
+
return {
|
|
130
|
+
artifacts,
|
|
131
|
+
fileTree,
|
|
132
|
+
relevantPaths: limitedPaths,
|
|
133
|
+
stats,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Synchronous fallback — scan files by keyword matching against the goal.
|
|
138
|
+
* Used when the LLM call fails or as the base implementation.
|
|
139
|
+
*/
|
|
140
|
+
scanByKeywords(goal, workingDir) {
|
|
141
|
+
const stopWords = new Set([
|
|
142
|
+
'the', 'a', 'an', 'in', 'to', 'for', 'of', 'and', 'or', 'is',
|
|
143
|
+
'add', 'fix', 'update', 'change', 'remove', 'create', 'implement',
|
|
144
|
+
'with', 'on', 'at', 'by', 'from', 'as', 'be', 'this', 'that',
|
|
145
|
+
]);
|
|
146
|
+
const keywords = goal
|
|
147
|
+
.toLowerCase()
|
|
148
|
+
.split(/[\s,.-]+/)
|
|
149
|
+
.filter((w) => w.length > 2 && !stopWords.has(w));
|
|
150
|
+
if (keywords.length === 0)
|
|
151
|
+
return [];
|
|
152
|
+
const scored = this.walkAndScore(workingDir, keywords, 0);
|
|
153
|
+
return scored
|
|
154
|
+
.sort((a, b) => b.score - a.score)
|
|
155
|
+
.filter((s) => s.score > 0)
|
|
156
|
+
.slice(0, 10)
|
|
157
|
+
.map((s) => s.path);
|
|
158
|
+
}
|
|
159
|
+
// ─── LLM-Based Classification ─────────────────────────────────────────
|
|
160
|
+
/**
|
|
161
|
+
* Use the LLM to identify files relevant to the goal.
|
|
162
|
+
* Parses the LLM response as a JSON array of file paths.
|
|
163
|
+
* Throws if parsing fails or file list is empty.
|
|
164
|
+
*/
|
|
165
|
+
async classifyFiles(params) {
|
|
166
|
+
const prompt = this.buildClassifyPrompt(params);
|
|
167
|
+
const response = await params.callLLM(prompt);
|
|
168
|
+
return this.parseClassifyResponse(response);
|
|
169
|
+
}
|
|
170
|
+
/** Build the prompt for LLM-based file classification */
|
|
171
|
+
buildClassifyPrompt(params) {
|
|
172
|
+
let prompt = `You are a codebase inspector. Given a project goal and its file tree, identify which files are most relevant to accomplish the goal.
|
|
173
|
+
|
|
174
|
+
Goal: ${params.goal}
|
|
175
|
+
|
|
176
|
+
Project file tree:
|
|
177
|
+
${params.fileTree.slice(0, 2000)}
|
|
178
|
+
`;
|
|
179
|
+
if (params.taskDescriptions && params.taskDescriptions.length > 0) {
|
|
180
|
+
prompt += `\nAdditional context — task plan steps:
|
|
181
|
+
${params.taskDescriptions.map((d, i) => ` ${i + 1}. ${d}`).join('\n')}
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
prompt += `
|
|
185
|
+
Respond with ONLY a JSON array of file paths (relative to the project root) that are most relevant to this goal. Limit to 10 files. Use the exact paths as shown in the file tree.
|
|
186
|
+
|
|
187
|
+
Example: ["src/auth/login.ts", "src/auth/middleware.ts"]
|
|
188
|
+
|
|
189
|
+
JSON array:`;
|
|
190
|
+
return prompt;
|
|
191
|
+
}
|
|
192
|
+
/** Parse the LLM response into an array of file paths. Throws on failure. */
|
|
193
|
+
parseClassifyResponse(response) {
|
|
194
|
+
// Try to extract a JSON array from the response
|
|
195
|
+
const trimmed = response.trim();
|
|
196
|
+
// Find the first `[` and last `]` to extract the JSON array
|
|
197
|
+
const start = trimmed.indexOf('[');
|
|
198
|
+
const end = trimmed.lastIndexOf(']');
|
|
199
|
+
if (start === -1 || end === -1 || end <= start) {
|
|
200
|
+
throw new Error('LLM response did not contain a JSON array');
|
|
201
|
+
}
|
|
202
|
+
const jsonStr = trimmed.slice(start, end + 1);
|
|
203
|
+
const paths = JSON.parse(jsonStr);
|
|
204
|
+
if (!Array.isArray(paths) || paths.length === 0) {
|
|
205
|
+
throw new Error('LLM returned empty or invalid file list');
|
|
206
|
+
}
|
|
207
|
+
// Validate all entries are strings
|
|
208
|
+
const filePaths = paths.filter((p) => typeof p === 'string');
|
|
209
|
+
if (filePaths.length === 0) {
|
|
210
|
+
throw new Error('LLM returned no valid file paths');
|
|
211
|
+
}
|
|
212
|
+
return filePaths;
|
|
213
|
+
}
|
|
214
|
+
// ─── Private Helpers ─────────────────────────────────────────────────
|
|
215
|
+
/** Walk the directory tree and score files by keyword relevance */
|
|
216
|
+
walkAndScore(dir, keywords, depth, baseDir) {
|
|
217
|
+
const root = baseDir ?? dir;
|
|
218
|
+
if (depth > 5)
|
|
219
|
+
return [];
|
|
220
|
+
const results = [];
|
|
221
|
+
let entries;
|
|
222
|
+
try {
|
|
223
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
return [];
|
|
227
|
+
}
|
|
228
|
+
for (const entry of entries) {
|
|
229
|
+
if (IGNORE_DIRS.has(entry.name))
|
|
230
|
+
continue;
|
|
231
|
+
const entryPath = join(dir, entry.name);
|
|
232
|
+
if (entry.isDirectory()) {
|
|
233
|
+
const subResults = this.walkAndScore(entryPath, keywords, depth + 1, root);
|
|
234
|
+
results.push(...subResults);
|
|
235
|
+
}
|
|
236
|
+
else if (entry.isFile()) {
|
|
237
|
+
const ext = entry.name.slice(entry.name.lastIndexOf('.'));
|
|
238
|
+
if (!SOURCE_EXTENSIONS.has(ext))
|
|
239
|
+
continue;
|
|
240
|
+
let score = 0;
|
|
241
|
+
const lowerName = entry.name.toLowerCase();
|
|
242
|
+
const lowerPath = entryPath.toLowerCase();
|
|
243
|
+
for (const kw of keywords) {
|
|
244
|
+
if (lowerName.includes(kw))
|
|
245
|
+
score += 3;
|
|
246
|
+
else if (lowerPath.includes(kw))
|
|
247
|
+
score += 1;
|
|
248
|
+
}
|
|
249
|
+
if (score > 0) {
|
|
250
|
+
const relPath = relative(root, entryPath);
|
|
251
|
+
results.push({ path: relPath, score });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return results;
|
|
256
|
+
}
|
|
257
|
+
/** Format byte count to human-readable string */
|
|
258
|
+
formatSize(bytes) {
|
|
259
|
+
if (bytes < 1024)
|
|
260
|
+
return String(bytes);
|
|
261
|
+
if (bytes < 1024 * 1024)
|
|
262
|
+
return `${(bytes / 1024).toFixed(1)}k`;
|
|
263
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
//# sourceMappingURL=inspect-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-module.js","sourceRoot":"","sources":["../../src/agents/inspect-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,oBAAoB,EAAgB,M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GAAG,IAAI,GAAG,IAAI;YAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;QAChE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IAClD,CAAC;CACF"}
|
|
@@ -20,6 +20,7 @@ import { ConfigManager } from '../config/manager.js';
|
|
|
20
20
|
import type { TaskStep } from './agent.js';
|
|
21
21
|
import { type ModuleRegistry } from './module-registry.js';
|
|
22
22
|
import type { EventBus } from '../observability/event-bus.js';
|
|
23
|
+
import { type ReportModule } from './report-module.js';
|
|
23
24
|
/** Configuration for an orchestration session */
|
|
24
25
|
export interface OrchestratorOptions {
|
|
25
26
|
/** Inference provider type (default: from configManager) */
|
|
@@ -130,7 +131,9 @@ export declare class Orchestrator {
|
|
|
130
131
|
private moduleRegistry;
|
|
131
132
|
/** The event bus for emitting observability events */
|
|
132
133
|
private eventBus;
|
|
133
|
-
|
|
134
|
+
/** The report module for generating structured execution reports */
|
|
135
|
+
private reportModule;
|
|
136
|
+
constructor(configManager?: ConfigManager, moduleRegistry?: ModuleRegistry, eventBus?: EventBus, reportModule?: ReportModule);
|
|
134
137
|
/**
|
|
135
138
|
* Execute a multi-agent pipeline for the given goal.
|
|
136
139
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/agents/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAOrD,OAAO,KAAK,EAA0B,QAAQ,EAAe,MAAM,YAAY,CAAC;AAOhF,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;
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AAc,CAAC,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,YAAY;IAO5H;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAma5F,OAAO,CAAC,iBAAiB;YA6BX,QAAQ;IActB;;;OAGG;IACH,OAAO,CAAC,sBAAsB;YAkGhB,iBAAiB;IAgO/B;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAqBpB,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,WAAW;CAuBpB"}
|
|
@@ -30,6 +30,7 @@ import { getMCPManager, resetMCPManager } from '../mcp/manager.js';
|
|
|
30
30
|
import { formatMcpToolsForPrompt } from './agents/mcp-agent.js';
|
|
31
31
|
import { getModuleRegistry } from './module-registry.js';
|
|
32
32
|
import { getEventBus, EventNames } from '../observability/event-bus.js';
|
|
33
|
+
import { DefaultReportModule } from './report-module.js';
|
|
33
34
|
import { ContextPruner } from '../learning/context-pruner.js';
|
|
34
35
|
import { ErrorRepairEngine } from '../learning/error-repair.js';
|
|
35
36
|
import { scanForInjections, formatScanReport } from '../security/scanner.js';
|
|
@@ -87,10 +88,13 @@ export class Orchestrator {
|
|
|
87
88
|
moduleRegistry;
|
|
88
89
|
/** The event bus for emitting observability events */
|
|
89
90
|
eventBus;
|
|
90
|
-
|
|
91
|
+
/** The report module for generating structured execution reports */
|
|
92
|
+
reportModule;
|
|
93
|
+
constructor(configManager, moduleRegistry, eventBus, reportModule) {
|
|
91
94
|
this.configManager = configManager ?? new ConfigManager();
|
|
92
95
|
this.moduleRegistry = moduleRegistry ?? getModuleRegistry();
|
|
93
96
|
this.eventBus = eventBus ?? getEventBus();
|
|
97
|
+
this.reportModule = reportModule ?? new DefaultReportModule(this.eventBus);
|
|
94
98
|
}
|
|
95
99
|
/**
|
|
96
100
|
* Execute a multi-agent pipeline for the given goal.
|
|
@@ -444,15 +448,25 @@ export class Orchestrator {
|
|
|
444
448
|
tasksTotal: total,
|
|
445
449
|
durationMs: Date.now() - startTime,
|
|
446
450
|
}, 'orchestrator');
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
// ── Generate structured report via ReportModule ──────────────────
|
|
452
|
+
const report = await this.reportModule.generate({
|
|
453
|
+
goal,
|
|
454
|
+
agentResults,
|
|
455
|
+
fileChanges: vault.context.fileChanges.map((c) => ({
|
|
456
|
+
path: c.path,
|
|
457
|
+
status: c.status,
|
|
458
|
+
})),
|
|
459
|
+
hasFailures,
|
|
460
|
+
durationMs: Date.now() - startTime,
|
|
461
|
+
runOutput,
|
|
462
|
+
error: undefined,
|
|
463
|
+
trajectoryId,
|
|
464
|
+
reviewId,
|
|
465
|
+
});
|
|
466
|
+
// Format as text for the result summary
|
|
467
|
+
const reportText = this.reportModule.format(report, 'text');
|
|
454
468
|
return this.buildResult(!hasFailures, goal, agentResults, vault, {
|
|
455
|
-
summary:
|
|
469
|
+
summary: reportText,
|
|
456
470
|
tasksCompleted: completed,
|
|
457
471
|
tasksTotal: total,
|
|
458
472
|
trajectoryId,
|