popeye-cli 1.8.0 → 1.9.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.
- package/README.md +47 -3
- package/cheatsheet.md +33 -0
- package/dist/cli/commands/index.d.ts +1 -0
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/review.d.ts +31 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +156 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/interactive.d.ts.map +1 -1
- package/dist/cli/interactive.js +122 -61
- package/dist/cli/interactive.js.map +1 -1
- package/dist/types/audit.d.ts +623 -0
- package/dist/types/audit.d.ts.map +1 -0
- package/dist/types/audit.js +240 -0
- package/dist/types/audit.js.map +1 -0
- package/dist/types/workflow.d.ts +15 -0
- package/dist/types/workflow.d.ts.map +1 -1
- package/dist/types/workflow.js +5 -0
- package/dist/types/workflow.js.map +1 -1
- package/dist/workflow/audit-analyzer.d.ts +58 -0
- package/dist/workflow/audit-analyzer.d.ts.map +1 -0
- package/dist/workflow/audit-analyzer.js +438 -0
- package/dist/workflow/audit-analyzer.js.map +1 -0
- package/dist/workflow/audit-mode.d.ts +28 -0
- package/dist/workflow/audit-mode.d.ts.map +1 -0
- package/dist/workflow/audit-mode.js +169 -0
- package/dist/workflow/audit-mode.js.map +1 -0
- package/dist/workflow/audit-recovery.d.ts +61 -0
- package/dist/workflow/audit-recovery.d.ts.map +1 -0
- package/dist/workflow/audit-recovery.js +242 -0
- package/dist/workflow/audit-recovery.js.map +1 -0
- package/dist/workflow/audit-reporter.d.ts +65 -0
- package/dist/workflow/audit-reporter.d.ts.map +1 -0
- package/dist/workflow/audit-reporter.js +301 -0
- package/dist/workflow/audit-reporter.js.map +1 -0
- package/dist/workflow/audit-scanner.d.ts +87 -0
- package/dist/workflow/audit-scanner.d.ts.map +1 -0
- package/dist/workflow/audit-scanner.js +768 -0
- package/dist/workflow/audit-scanner.js.map +1 -0
- package/dist/workflow/index.d.ts +5 -0
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +5 -0
- package/dist/workflow/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/index.ts +1 -0
- package/src/cli/commands/review.ts +187 -0
- package/src/cli/index.ts +2 -0
- package/src/cli/interactive.ts +72 -4
- package/src/types/audit.ts +294 -0
- package/src/types/workflow.ts +15 -0
- package/src/workflow/audit-analyzer.ts +510 -0
- package/src/workflow/audit-mode.ts +240 -0
- package/src/workflow/audit-recovery.ts +284 -0
- package/src/workflow/audit-reporter.ts +370 -0
- package/src/workflow/audit-scanner.ts +873 -0
- package/src/workflow/index.ts +5 -0
- package/tests/cli/commands/review.test.ts +52 -0
- package/tests/types/audit.test.ts +250 -0
- package/tests/workflow/audit-analyzer.test.ts +281 -0
- package/tests/workflow/audit-mode.test.ts +114 -0
- package/tests/workflow/audit-recovery.test.ts +237 -0
- package/tests/workflow/audit-reporter.test.ts +254 -0
- package/tests/workflow/audit-scanner.test.ts +270 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery system for the audit feature.
|
|
3
|
+
*
|
|
4
|
+
* Evidence-based trigger logic, finding-to-milestone conversion,
|
|
5
|
+
* and safe state injection for recovery execution.
|
|
6
|
+
*/
|
|
7
|
+
import type { Milestone, ProjectState } from '../types/workflow.js';
|
|
8
|
+
import type { ProjectAuditReport, RecoveryPlan } from '../types/audit.js';
|
|
9
|
+
/**
|
|
10
|
+
* Determine if recovery should be triggered based on evidence in the report.
|
|
11
|
+
*
|
|
12
|
+
* Trigger conditions (any one suffices):
|
|
13
|
+
* - criticalCount > 0
|
|
14
|
+
* - strict mode AND majorCount > 0
|
|
15
|
+
* - overallScore < threshold AND at least one finding is autoFixable
|
|
16
|
+
* or belongs to an actionable category
|
|
17
|
+
*
|
|
18
|
+
* Does NOT trigger on info-only or purely cosmetic issues.
|
|
19
|
+
*
|
|
20
|
+
* @param report - The audit report.
|
|
21
|
+
* @param strict - Whether strict mode is active.
|
|
22
|
+
* @returns True if recovery should be triggered.
|
|
23
|
+
*/
|
|
24
|
+
export declare function shouldTriggerRecovery(report: ProjectAuditReport, strict: boolean): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a recovery plan from audit report findings.
|
|
27
|
+
*
|
|
28
|
+
* Groups findings into milestones by severity:
|
|
29
|
+
* - Critical -> [RECOVERY] Critical Fixes
|
|
30
|
+
* - Major -> [RECOVERY] Major Improvements (grouped by category)
|
|
31
|
+
* - Minor + autoFixable -> [RECOVERY] Polish
|
|
32
|
+
*
|
|
33
|
+
* @param report - The audit report.
|
|
34
|
+
* @returns A structured recovery plan.
|
|
35
|
+
*/
|
|
36
|
+
export declare function generateRecoveryPlan(report: ProjectAuditReport): RecoveryPlan;
|
|
37
|
+
/**
|
|
38
|
+
* Convert a recovery plan into milestone objects compatible with addMilestones().
|
|
39
|
+
*
|
|
40
|
+
* Each recovery milestone becomes an Omit<Milestone, 'id'> with tasks
|
|
41
|
+
* that have the standard Task shape.
|
|
42
|
+
*
|
|
43
|
+
* @param recovery - The recovery plan.
|
|
44
|
+
* @param language - Project language (for task context).
|
|
45
|
+
* @returns Array of milestone objects ready for addMilestones().
|
|
46
|
+
*/
|
|
47
|
+
export declare function recoveryToMilestones(recovery: RecoveryPlan, _language: string): Omit<Milestone, 'id'>[];
|
|
48
|
+
/**
|
|
49
|
+
* Inject recovery milestones into the project state.
|
|
50
|
+
*
|
|
51
|
+
* This APPENDS recovery milestones — it never clobbers existing milestones.
|
|
52
|
+
* Milestone names are prefixed with [RECOVERY] for visibility.
|
|
53
|
+
* Sets audit tracking fields and switches phase to 'execution'.
|
|
54
|
+
*
|
|
55
|
+
* @param projectDir - Project root directory.
|
|
56
|
+
* @param milestones - Recovery milestones (without IDs).
|
|
57
|
+
* @param auditRunId - The audit run identifier for lineage.
|
|
58
|
+
* @returns Updated project state.
|
|
59
|
+
*/
|
|
60
|
+
export declare function injectRecoveryIntoState(projectDir: string, milestones: Omit<Milestone, 'id'>[], auditRunId: string): Promise<ProjectState>;
|
|
61
|
+
//# sourceMappingURL=audit-recovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-recovery.d.ts","sourceRoot":"","sources":["../../src/workflow/audit-recovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAQ,MAAM,sBAAsB,CAAC;AAC1E,OAAO,KAAK,EAGV,kBAAkB,EAElB,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAkB3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,OAAO,GACd,OAAO,CAYT;AAkDD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAiE7E;AAMD;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,MAAM,GAChB,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAYzB;AAiCD;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EACnC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,YAAY,CAAC,CAavB"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recovery system for the audit feature.
|
|
3
|
+
*
|
|
4
|
+
* Evidence-based trigger logic, finding-to-milestone conversion,
|
|
5
|
+
* and safe state injection for recovery execution.
|
|
6
|
+
*/
|
|
7
|
+
import { addMilestones, updateState } from '../state/index.js';
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Constants
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
const RECOVERY_PREFIX = '[RECOVERY]';
|
|
12
|
+
const ACTIONABLE_CATEGORIES = new Set([
|
|
13
|
+
'integration-wiring',
|
|
14
|
+
'test-coverage',
|
|
15
|
+
'config-deployment',
|
|
16
|
+
]);
|
|
17
|
+
const DEFAULT_SCORE_THRESHOLD = 70;
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// Trigger logic
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
/**
|
|
22
|
+
* Determine if recovery should be triggered based on evidence in the report.
|
|
23
|
+
*
|
|
24
|
+
* Trigger conditions (any one suffices):
|
|
25
|
+
* - criticalCount > 0
|
|
26
|
+
* - strict mode AND majorCount > 0
|
|
27
|
+
* - overallScore < threshold AND at least one finding is autoFixable
|
|
28
|
+
* or belongs to an actionable category
|
|
29
|
+
*
|
|
30
|
+
* Does NOT trigger on info-only or purely cosmetic issues.
|
|
31
|
+
*
|
|
32
|
+
* @param report - The audit report.
|
|
33
|
+
* @param strict - Whether strict mode is active.
|
|
34
|
+
* @returns True if recovery should be triggered.
|
|
35
|
+
*/
|
|
36
|
+
export function shouldTriggerRecovery(report, strict) {
|
|
37
|
+
if (report.criticalCount > 0)
|
|
38
|
+
return true;
|
|
39
|
+
if (strict && report.majorCount > 0)
|
|
40
|
+
return true;
|
|
41
|
+
if (report.overallScore < DEFAULT_SCORE_THRESHOLD) {
|
|
42
|
+
const hasActionable = report.findings.some((f) => f.autoFixable || ACTIONABLE_CATEGORIES.has(f.category));
|
|
43
|
+
if (hasActionable)
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Recovery plan generation
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Infer the target component from a finding's evidence file paths.
|
|
53
|
+
*
|
|
54
|
+
* @param finding - An audit finding.
|
|
55
|
+
* @returns The most likely component kind.
|
|
56
|
+
*/
|
|
57
|
+
function inferAppTarget(finding) {
|
|
58
|
+
const paths = finding.evidence.map((e) => e.file);
|
|
59
|
+
for (const p of paths) {
|
|
60
|
+
if (p.includes('frontend') || p.includes('web') || p.includes('client'))
|
|
61
|
+
return 'frontend';
|
|
62
|
+
if (p.includes('backend') || p.includes('api') || p.includes('server'))
|
|
63
|
+
return 'backend';
|
|
64
|
+
if (p.includes('website') || p.includes('landing'))
|
|
65
|
+
return 'website';
|
|
66
|
+
if (p.includes('infra') || p.includes('docker') || p.includes('deploy'))
|
|
67
|
+
return 'infra';
|
|
68
|
+
}
|
|
69
|
+
// Reason: Fall back based on category
|
|
70
|
+
if (finding.category === 'integration-wiring')
|
|
71
|
+
return 'backend';
|
|
72
|
+
if (finding.category === 'test-coverage')
|
|
73
|
+
return 'shared';
|
|
74
|
+
if (finding.category === 'config-deployment')
|
|
75
|
+
return 'infra';
|
|
76
|
+
return 'shared';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Convert a finding into a recovery task.
|
|
80
|
+
*
|
|
81
|
+
* @param finding - An audit finding.
|
|
82
|
+
* @returns A recovery task.
|
|
83
|
+
*/
|
|
84
|
+
function findingToRecoveryTask(finding) {
|
|
85
|
+
return {
|
|
86
|
+
name: finding.title,
|
|
87
|
+
description: `${finding.description}\n\nRecommendation: ${finding.recommendation}`,
|
|
88
|
+
findingIds: [finding.id],
|
|
89
|
+
acceptanceCriteria: [
|
|
90
|
+
finding.recommendation,
|
|
91
|
+
`Verify finding ${finding.id} is resolved`,
|
|
92
|
+
],
|
|
93
|
+
testPlan: finding.category === 'test-coverage'
|
|
94
|
+
? 'Add missing tests and verify they pass'
|
|
95
|
+
: undefined,
|
|
96
|
+
appTarget: inferAppTarget(finding),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Generate a recovery plan from audit report findings.
|
|
101
|
+
*
|
|
102
|
+
* Groups findings into milestones by severity:
|
|
103
|
+
* - Critical -> [RECOVERY] Critical Fixes
|
|
104
|
+
* - Major -> [RECOVERY] Major Improvements (grouped by category)
|
|
105
|
+
* - Minor + autoFixable -> [RECOVERY] Polish
|
|
106
|
+
*
|
|
107
|
+
* @param report - The audit report.
|
|
108
|
+
* @returns A structured recovery plan.
|
|
109
|
+
*/
|
|
110
|
+
export function generateRecoveryPlan(report) {
|
|
111
|
+
const milestones = [];
|
|
112
|
+
// Critical findings -> separate milestone
|
|
113
|
+
const criticalFindings = report.findings.filter((f) => f.severity === 'critical');
|
|
114
|
+
if (criticalFindings.length > 0) {
|
|
115
|
+
milestones.push({
|
|
116
|
+
name: `${RECOVERY_PREFIX} Critical Fixes`,
|
|
117
|
+
description: 'Address all critical audit findings that block production readiness.',
|
|
118
|
+
tasks: criticalFindings.map(findingToRecoveryTask),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// Major findings -> grouped by category
|
|
122
|
+
const majorFindings = report.findings.filter((f) => f.severity === 'major');
|
|
123
|
+
if (majorFindings.length > 0) {
|
|
124
|
+
// Group by category
|
|
125
|
+
const byCategory = new Map();
|
|
126
|
+
for (const f of majorFindings) {
|
|
127
|
+
const existing = byCategory.get(f.category) ?? [];
|
|
128
|
+
existing.push(f);
|
|
129
|
+
byCategory.set(f.category, existing);
|
|
130
|
+
}
|
|
131
|
+
const majorTasks = [];
|
|
132
|
+
for (const [, findings] of byCategory) {
|
|
133
|
+
majorTasks.push(...findings.map(findingToRecoveryTask));
|
|
134
|
+
}
|
|
135
|
+
milestones.push({
|
|
136
|
+
name: `${RECOVERY_PREFIX} Major Improvements`,
|
|
137
|
+
description: 'Address major audit findings that significantly affect quality.',
|
|
138
|
+
tasks: majorTasks,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
// Minor + autoFixable -> polish milestone
|
|
142
|
+
const polishFindings = report.findings.filter((f) => f.severity === 'minor' && f.autoFixable);
|
|
143
|
+
if (polishFindings.length > 0) {
|
|
144
|
+
milestones.push({
|
|
145
|
+
name: `${RECOVERY_PREFIX} Polish`,
|
|
146
|
+
description: 'Address minor auto-fixable findings for polish.',
|
|
147
|
+
tasks: polishFindings.map(findingToRecoveryTask),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
// Estimate effort based on finding count and severity
|
|
151
|
+
const effortHours = criticalFindings.length * 2 + majorFindings.length * 1 + polishFindings.length * 0.5;
|
|
152
|
+
const estimatedEffort = effortHours <= 2
|
|
153
|
+
? '1-2 hours'
|
|
154
|
+
: effortHours <= 8
|
|
155
|
+
? `${Math.ceil(effortHours / 2)}-${Math.ceil(effortHours)} hours`
|
|
156
|
+
: `${Math.ceil(effortHours / 8)} days`;
|
|
157
|
+
return {
|
|
158
|
+
generatedAt: new Date().toISOString(),
|
|
159
|
+
auditScore: report.overallScore,
|
|
160
|
+
auditRunId: report.auditRunId,
|
|
161
|
+
totalFindings: report.findings.length,
|
|
162
|
+
criticalFindings: report.criticalCount,
|
|
163
|
+
milestones,
|
|
164
|
+
estimatedEffort,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
// Recovery -> milestone conversion
|
|
169
|
+
// ---------------------------------------------------------------------------
|
|
170
|
+
/**
|
|
171
|
+
* Convert a recovery plan into milestone objects compatible with addMilestones().
|
|
172
|
+
*
|
|
173
|
+
* Each recovery milestone becomes an Omit<Milestone, 'id'> with tasks
|
|
174
|
+
* that have the standard Task shape.
|
|
175
|
+
*
|
|
176
|
+
* @param recovery - The recovery plan.
|
|
177
|
+
* @param language - Project language (for task context).
|
|
178
|
+
* @returns Array of milestone objects ready for addMilestones().
|
|
179
|
+
*/
|
|
180
|
+
export function recoveryToMilestones(recovery, _language) {
|
|
181
|
+
return recovery.milestones.map((rm) => ({
|
|
182
|
+
name: rm.name,
|
|
183
|
+
description: rm.description,
|
|
184
|
+
status: 'pending',
|
|
185
|
+
tasks: rm.tasks.map((rt) => ({
|
|
186
|
+
id: '', // Reason: addMilestones() auto-assigns IDs
|
|
187
|
+
name: rt.name,
|
|
188
|
+
description: buildTaskDescription(rt),
|
|
189
|
+
status: 'pending',
|
|
190
|
+
})),
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Build a detailed task description for execution.
|
|
195
|
+
*
|
|
196
|
+
* @param task - Recovery task.
|
|
197
|
+
* @param language - Project language.
|
|
198
|
+
* @returns Formatted description string.
|
|
199
|
+
*/
|
|
200
|
+
function buildTaskDescription(task) {
|
|
201
|
+
const parts = [task.description];
|
|
202
|
+
parts.push(`\nTarget component: ${task.appTarget}`);
|
|
203
|
+
parts.push(`Related findings: ${task.findingIds.join(', ')}`);
|
|
204
|
+
if (task.acceptanceCriteria.length > 0) {
|
|
205
|
+
parts.push('\nAcceptance criteria:');
|
|
206
|
+
for (const ac of task.acceptanceCriteria) {
|
|
207
|
+
parts.push(`- ${ac}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (task.testPlan) {
|
|
211
|
+
parts.push(`\nTest plan: ${task.testPlan}`);
|
|
212
|
+
}
|
|
213
|
+
return parts.join('\n');
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// State injection
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
/**
|
|
219
|
+
* Inject recovery milestones into the project state.
|
|
220
|
+
*
|
|
221
|
+
* This APPENDS recovery milestones — it never clobbers existing milestones.
|
|
222
|
+
* Milestone names are prefixed with [RECOVERY] for visibility.
|
|
223
|
+
* Sets audit tracking fields and switches phase to 'execution'.
|
|
224
|
+
*
|
|
225
|
+
* @param projectDir - Project root directory.
|
|
226
|
+
* @param milestones - Recovery milestones (without IDs).
|
|
227
|
+
* @param auditRunId - The audit run identifier for lineage.
|
|
228
|
+
* @returns Updated project state.
|
|
229
|
+
*/
|
|
230
|
+
export async function injectRecoveryIntoState(projectDir, milestones, auditRunId) {
|
|
231
|
+
// Reason: addMilestones appends to existing milestones, no clobbering
|
|
232
|
+
await addMilestones(projectDir, milestones);
|
|
233
|
+
const updatedState = await updateState(projectDir, {
|
|
234
|
+
phase: 'execution',
|
|
235
|
+
status: 'in-progress',
|
|
236
|
+
auditRecoveryInProgress: true,
|
|
237
|
+
auditRunId,
|
|
238
|
+
auditLastRunAt: new Date().toISOString(),
|
|
239
|
+
});
|
|
240
|
+
return updatedState;
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=audit-recovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-recovery.js","sourceRoot":"","sources":["../../src/workflow/audit-recovery.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAW/D,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,eAAe,GAAG,YAAY,CAAC;AACrC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,oBAAoB;IACpB,eAAe;IACf,mBAAmB;CACpB,CAAC,CAAC;AACH,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAEnC,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,qBAAqB,CACnC,MAA0B,EAC1B,MAAe;IAEf,IAAI,MAAM,CAAC,aAAa,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,MAAM,IAAI,MAAM,CAAC,UAAU,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAEjD,IAAI,MAAM,CAAC,YAAY,GAAG,uBAAuB,EAAE,CAAC;QAClD,MAAM,aAAa,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CACxC,CAAC,CAAC,EAAE,EAAE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 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report generation for the audit system.
|
|
3
|
+
*
|
|
4
|
+
* Builds summary + full reports, writes markdown and JSON artifacts
|
|
5
|
+
* to the project's .popeye/ directory.
|
|
6
|
+
*/
|
|
7
|
+
import type { ProjectState } from '../types/workflow.js';
|
|
8
|
+
import type { AuditCategory, AuditFinding, AuditModeOptions, ProjectAuditReport, ProjectScanResult, ProjectSummaryReport, RecoveryPlan, SearchMetadata } from '../types/audit.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build a summary report from the scan result and project state.
|
|
11
|
+
*
|
|
12
|
+
* @param scan - The project scan result.
|
|
13
|
+
* @param state - Current project state.
|
|
14
|
+
* @param aiOverview - Optional AI-generated overview text.
|
|
15
|
+
* @returns A structured summary report.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildSummaryReport(scan: ProjectScanResult, state: ProjectState, aiOverview?: string): ProjectSummaryReport;
|
|
18
|
+
/**
|
|
19
|
+
* Build the full audit report from all analysis results.
|
|
20
|
+
*
|
|
21
|
+
* @param summary - The summary report.
|
|
22
|
+
* @param findings - All audit findings.
|
|
23
|
+
* @param scores - Overall and category scores.
|
|
24
|
+
* @param searchMeta - Serena search tracking metadata.
|
|
25
|
+
* @param options - Audit options (for strict mode, etc.).
|
|
26
|
+
* @param auditRunId - Unique run identifier.
|
|
27
|
+
* @returns The complete audit report.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildAuditReport(summary: ProjectSummaryReport, findings: AuditFinding[], scores: {
|
|
30
|
+
overallScore: number;
|
|
31
|
+
categoryScores: Record<AuditCategory, number>;
|
|
32
|
+
}, searchMeta: SearchMetadata, options: Pick<AuditModeOptions, 'strict'>, auditRunId: string): ProjectAuditReport;
|
|
33
|
+
/**
|
|
34
|
+
* Write the audit report as markdown.
|
|
35
|
+
*
|
|
36
|
+
* @param projectDir - Project root directory.
|
|
37
|
+
* @param report - The audit report.
|
|
38
|
+
* @returns Path to the written file.
|
|
39
|
+
*/
|
|
40
|
+
export declare function writeAuditMarkdown(projectDir: string, report: ProjectAuditReport): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Write the audit report as JSON.
|
|
43
|
+
*
|
|
44
|
+
* @param projectDir - Project root directory.
|
|
45
|
+
* @param report - The audit report.
|
|
46
|
+
* @returns Path to the written file.
|
|
47
|
+
*/
|
|
48
|
+
export declare function writeAuditJson(projectDir: string, report: ProjectAuditReport): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Write the recovery plan as markdown.
|
|
51
|
+
*
|
|
52
|
+
* @param projectDir - Project root directory.
|
|
53
|
+
* @param recovery - The recovery plan.
|
|
54
|
+
* @returns Path to the written file.
|
|
55
|
+
*/
|
|
56
|
+
export declare function writeRecoveryMarkdown(projectDir: string, recovery: RecoveryPlan): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Write the recovery plan as JSON.
|
|
59
|
+
*
|
|
60
|
+
* @param projectDir - Project root directory.
|
|
61
|
+
* @param recovery - The recovery plan.
|
|
62
|
+
* @returns Path to the written file.
|
|
63
|
+
*/
|
|
64
|
+
export declare function writeRecoveryJson(projectDir: string, recovery: RecoveryPlan): Promise<string>;
|
|
65
|
+
//# sourceMappingURL=audit-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-reporter.d.ts","sourceRoot":"","sources":["../../src/workflow/audit-reporter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,gBAAgB,EAEhB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACf,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,YAAY,EACnB,UAAU,CAAC,EAAE,MAAM,GAClB,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