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,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit system type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Zod schemas and TypeScript types for the post-build audit/review feature.
|
|
5
|
+
* Covers scanning, analysis, reporting, and recovery.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Enums
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
export const AuditSeveritySchema = z.enum(['critical', 'major', 'minor', 'info']);
|
|
14
|
+
export type AuditSeverity = z.infer<typeof AuditSeveritySchema>;
|
|
15
|
+
|
|
16
|
+
export const AuditCategorySchema = z.enum([
|
|
17
|
+
'feature-completeness',
|
|
18
|
+
'integration-wiring',
|
|
19
|
+
'test-coverage',
|
|
20
|
+
'config-deployment',
|
|
21
|
+
'dependency-sanity',
|
|
22
|
+
'consistency',
|
|
23
|
+
'security',
|
|
24
|
+
'documentation',
|
|
25
|
+
]);
|
|
26
|
+
export type AuditCategory = z.infer<typeof AuditCategorySchema>;
|
|
27
|
+
|
|
28
|
+
export const ComponentKindSchema = z.enum([
|
|
29
|
+
'frontend',
|
|
30
|
+
'backend',
|
|
31
|
+
'website',
|
|
32
|
+
'shared',
|
|
33
|
+
'infra',
|
|
34
|
+
]);
|
|
35
|
+
export type ComponentKind = z.infer<typeof ComponentKindSchema>;
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Evidence
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
export const AuditEvidenceSchema = z.object({
|
|
42
|
+
file: z.string(),
|
|
43
|
+
line: z.number().optional(),
|
|
44
|
+
snippet: z.string().optional(),
|
|
45
|
+
description: z.string().optional(),
|
|
46
|
+
});
|
|
47
|
+
export type AuditEvidence = z.infer<typeof AuditEvidenceSchema>;
|
|
48
|
+
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Dependency manifest
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
export const DependencyManifestSchema = z.object({
|
|
54
|
+
file: z.string(),
|
|
55
|
+
type: z.enum(['package.json', 'requirements.txt', 'pyproject.toml', 'other']),
|
|
56
|
+
dependencies: z.record(z.string(), z.string()).optional(),
|
|
57
|
+
devDependencies: z.record(z.string(), z.string()).optional(),
|
|
58
|
+
});
|
|
59
|
+
export type DependencyManifest = z.infer<typeof DependencyManifestSchema>;
|
|
60
|
+
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// File entry
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
|
|
65
|
+
export const FileEntrySchema = z.object({
|
|
66
|
+
path: z.string(),
|
|
67
|
+
lines: z.number().optional(),
|
|
68
|
+
extension: z.string().optional(),
|
|
69
|
+
});
|
|
70
|
+
export type FileEntry = z.infer<typeof FileEntrySchema>;
|
|
71
|
+
|
|
72
|
+
export const FileExcerptSchema = z.object({
|
|
73
|
+
path: z.string(),
|
|
74
|
+
content: z.string(),
|
|
75
|
+
});
|
|
76
|
+
export type FileExcerpt = z.infer<typeof FileExcerptSchema>;
|
|
77
|
+
|
|
78
|
+
// ---------------------------------------------------------------------------
|
|
79
|
+
// Component scan (per-component scanning for upgrade safety)
|
|
80
|
+
// ---------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
export const ComponentScanSchema = z.object({
|
|
83
|
+
kind: ComponentKindSchema,
|
|
84
|
+
rootDir: z.string(),
|
|
85
|
+
language: z.enum(['typescript', 'python', 'mixed']),
|
|
86
|
+
framework: z.string().optional(),
|
|
87
|
+
entryPoints: z.array(z.string()),
|
|
88
|
+
routeFiles: z.array(z.string()),
|
|
89
|
+
testFiles: z.array(FileEntrySchema),
|
|
90
|
+
sourceFiles: z.array(FileEntrySchema),
|
|
91
|
+
dependencyManifests: z.array(DependencyManifestSchema),
|
|
92
|
+
});
|
|
93
|
+
export type ComponentScan = z.infer<typeof ComponentScanSchema>;
|
|
94
|
+
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
// Wiring matrix (deterministic FE<->BE wiring check)
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
export const WiringMismatchSchema = z.object({
|
|
100
|
+
type: z.string(),
|
|
101
|
+
details: z.string(),
|
|
102
|
+
evidence: z.array(AuditEvidenceSchema),
|
|
103
|
+
});
|
|
104
|
+
export type WiringMismatch = z.infer<typeof WiringMismatchSchema>;
|
|
105
|
+
|
|
106
|
+
export const WiringMatrixSchema = z.object({
|
|
107
|
+
frontendApiBaseEnvKeys: z.array(z.string()),
|
|
108
|
+
frontendApiBaseResolved: z.string().optional(),
|
|
109
|
+
backendCorsOrigins: z.array(z.string()).optional(),
|
|
110
|
+
backendApiPrefix: z.string().optional(),
|
|
111
|
+
potentialMismatches: z.array(WiringMismatchSchema),
|
|
112
|
+
});
|
|
113
|
+
export type WiringMatrix = z.infer<typeof WiringMatrixSchema>;
|
|
114
|
+
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// Project scan result
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
export const ProjectScanResultSchema = z.object({
|
|
120
|
+
tree: z.string(),
|
|
121
|
+
// Component-based scanning (upgrade-safe)
|
|
122
|
+
components: z.array(ComponentScanSchema),
|
|
123
|
+
detectedComposition: z.array(ComponentKindSchema),
|
|
124
|
+
stateLanguage: z.string(),
|
|
125
|
+
compositionMismatch: z.boolean(),
|
|
126
|
+
// Aggregated totals
|
|
127
|
+
sourceFiles: z.array(FileEntrySchema),
|
|
128
|
+
testFiles: z.array(FileEntrySchema),
|
|
129
|
+
configFiles: z.array(z.string()),
|
|
130
|
+
entryPoints: z.array(z.string()),
|
|
131
|
+
routeFiles: z.array(z.string()),
|
|
132
|
+
dependencies: z.array(DependencyManifestSchema),
|
|
133
|
+
totalSourceFiles: z.number(),
|
|
134
|
+
totalTestFiles: z.number(),
|
|
135
|
+
totalLinesOfCode: z.number(),
|
|
136
|
+
totalLinesOfTests: z.number(),
|
|
137
|
+
language: z.string(),
|
|
138
|
+
// Priority doc reads
|
|
139
|
+
claudeMdContent: z.string().optional(),
|
|
140
|
+
readmeContent: z.string().optional(),
|
|
141
|
+
docsIndex: z.array(z.string()),
|
|
142
|
+
keyFileSnippets: z.array(FileExcerptSchema),
|
|
143
|
+
// Wiring matrix
|
|
144
|
+
wiring: WiringMatrixSchema.optional(),
|
|
145
|
+
// Config
|
|
146
|
+
envExampleContent: z.string().optional(),
|
|
147
|
+
dockerComposeContent: z.string().optional(),
|
|
148
|
+
});
|
|
149
|
+
export type ProjectScanResult = z.infer<typeof ProjectScanResultSchema>;
|
|
150
|
+
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
// Search metadata (Serena tracking)
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
export const SearchMetadataSchema = z.object({
|
|
156
|
+
serenaUsed: z.boolean(),
|
|
157
|
+
serenaRetries: z.number(),
|
|
158
|
+
serenaErrors: z.array(z.string()),
|
|
159
|
+
fallbackUsed: z.boolean(),
|
|
160
|
+
fallbackTool: z.string(),
|
|
161
|
+
searchQueries: z.array(z.string()),
|
|
162
|
+
});
|
|
163
|
+
export type SearchMetadata = z.infer<typeof SearchMetadataSchema>;
|
|
164
|
+
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
// Audit finding
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
|
|
169
|
+
export const AuditFindingSchema = z.object({
|
|
170
|
+
id: z.string(),
|
|
171
|
+
category: AuditCategorySchema,
|
|
172
|
+
severity: AuditSeveritySchema,
|
|
173
|
+
title: z.string(),
|
|
174
|
+
description: z.string(),
|
|
175
|
+
evidence: z.array(AuditEvidenceSchema),
|
|
176
|
+
recommendation: z.string(),
|
|
177
|
+
autoFixable: z.boolean(),
|
|
178
|
+
});
|
|
179
|
+
export type AuditFinding = z.infer<typeof AuditFindingSchema>;
|
|
180
|
+
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// Summary report
|
|
183
|
+
// ---------------------------------------------------------------------------
|
|
184
|
+
|
|
185
|
+
export const ProjectSummaryReportSchema = z.object({
|
|
186
|
+
projectName: z.string(),
|
|
187
|
+
language: z.string(),
|
|
188
|
+
totalSourceFiles: z.number(),
|
|
189
|
+
totalTestFiles: z.number(),
|
|
190
|
+
totalLinesOfCode: z.number(),
|
|
191
|
+
totalLinesOfTests: z.number(),
|
|
192
|
+
componentCount: z.number(),
|
|
193
|
+
detectedComposition: z.array(ComponentKindSchema),
|
|
194
|
+
entryPointCount: z.number(),
|
|
195
|
+
routeCount: z.number(),
|
|
196
|
+
dependencyCount: z.number(),
|
|
197
|
+
hasDocker: z.boolean(),
|
|
198
|
+
hasEnvExample: z.boolean(),
|
|
199
|
+
hasCiConfig: z.boolean(),
|
|
200
|
+
aiOverview: z.string().optional(),
|
|
201
|
+
});
|
|
202
|
+
export type ProjectSummaryReport = z.infer<typeof ProjectSummaryReportSchema>;
|
|
203
|
+
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// Audit report
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
export const AuditRecommendationSchema = z.enum([
|
|
209
|
+
'pass',
|
|
210
|
+
'fix-and-recheck',
|
|
211
|
+
'major-rework',
|
|
212
|
+
]);
|
|
213
|
+
export type AuditRecommendation = z.infer<typeof AuditRecommendationSchema>;
|
|
214
|
+
|
|
215
|
+
export const ProjectAuditReportSchema = z.object({
|
|
216
|
+
projectName: z.string(),
|
|
217
|
+
language: z.string(),
|
|
218
|
+
auditedAt: z.string(),
|
|
219
|
+
auditRunId: z.string(),
|
|
220
|
+
summary: ProjectSummaryReportSchema,
|
|
221
|
+
findings: z.array(AuditFindingSchema),
|
|
222
|
+
overallScore: z.number(),
|
|
223
|
+
categoryScores: z.record(AuditCategorySchema, z.number()),
|
|
224
|
+
criticalCount: z.number(),
|
|
225
|
+
majorCount: z.number(),
|
|
226
|
+
minorCount: z.number(),
|
|
227
|
+
infoCount: z.number(),
|
|
228
|
+
passedChecks: z.array(z.string()),
|
|
229
|
+
searchMetadata: SearchMetadataSchema,
|
|
230
|
+
recommendation: AuditRecommendationSchema,
|
|
231
|
+
});
|
|
232
|
+
export type ProjectAuditReport = z.infer<typeof ProjectAuditReportSchema>;
|
|
233
|
+
|
|
234
|
+
// ---------------------------------------------------------------------------
|
|
235
|
+
// Recovery
|
|
236
|
+
// ---------------------------------------------------------------------------
|
|
237
|
+
|
|
238
|
+
export const RecoveryTaskSchema = z.object({
|
|
239
|
+
name: z.string(),
|
|
240
|
+
description: z.string(),
|
|
241
|
+
findingIds: z.array(z.string()),
|
|
242
|
+
acceptanceCriteria: z.array(z.string()),
|
|
243
|
+
testPlan: z.string().optional(),
|
|
244
|
+
appTarget: ComponentKindSchema,
|
|
245
|
+
});
|
|
246
|
+
export type RecoveryTask = z.infer<typeof RecoveryTaskSchema>;
|
|
247
|
+
|
|
248
|
+
export const RecoveryMilestoneSchema = z.object({
|
|
249
|
+
name: z.string(),
|
|
250
|
+
description: z.string(),
|
|
251
|
+
tasks: z.array(RecoveryTaskSchema),
|
|
252
|
+
});
|
|
253
|
+
export type RecoveryMilestone = z.infer<typeof RecoveryMilestoneSchema>;
|
|
254
|
+
|
|
255
|
+
export const RecoveryPlanSchema = z.object({
|
|
256
|
+
generatedAt: z.string(),
|
|
257
|
+
auditScore: z.number(),
|
|
258
|
+
auditRunId: z.string(),
|
|
259
|
+
totalFindings: z.number(),
|
|
260
|
+
criticalFindings: z.number(),
|
|
261
|
+
milestones: z.array(RecoveryMilestoneSchema),
|
|
262
|
+
estimatedEffort: z.string(),
|
|
263
|
+
});
|
|
264
|
+
export type RecoveryPlan = z.infer<typeof RecoveryPlanSchema>;
|
|
265
|
+
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
// Options & result
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
|
|
270
|
+
export const AuditModeOptionsSchema = z.object({
|
|
271
|
+
projectDir: z.string(),
|
|
272
|
+
depth: z.number().min(1).max(3).default(2),
|
|
273
|
+
runTests: z.boolean().default(true),
|
|
274
|
+
strict: z.boolean().default(false),
|
|
275
|
+
format: z.enum(['json', 'md', 'both']).default('both'),
|
|
276
|
+
autoRecover: z.boolean().default(true),
|
|
277
|
+
target: z.union([z.literal('all'), ComponentKindSchema]).default('all'),
|
|
278
|
+
});
|
|
279
|
+
export type AuditModeOptions = z.infer<typeof AuditModeOptionsSchema>;
|
|
280
|
+
|
|
281
|
+
export const AuditModeResultSchema = z.object({
|
|
282
|
+
success: z.boolean(),
|
|
283
|
+
summary: ProjectSummaryReportSchema,
|
|
284
|
+
audit: ProjectAuditReportSchema,
|
|
285
|
+
recovery: RecoveryPlanSchema.optional(),
|
|
286
|
+
reportPaths: z.object({
|
|
287
|
+
auditMd: z.string().optional(),
|
|
288
|
+
auditJson: z.string().optional(),
|
|
289
|
+
recoveryMd: z.string().optional(),
|
|
290
|
+
recoveryJson: z.string().optional(),
|
|
291
|
+
}),
|
|
292
|
+
error: z.string().optional(),
|
|
293
|
+
});
|
|
294
|
+
export type AuditModeResult = z.infer<typeof AuditModeResultSchema>;
|
package/src/types/workflow.ts
CHANGED
|
@@ -234,6 +234,16 @@ export interface ProjectState {
|
|
|
234
234
|
qaEnabled?: boolean;
|
|
235
235
|
/** Database configuration tracking (workspace projects only) */
|
|
236
236
|
dbConfig?: DbConfig;
|
|
237
|
+
/** Path to most recent audit report JSON (relative to .popeye/) */
|
|
238
|
+
auditReportPath?: string;
|
|
239
|
+
/** Path to most recent audit summary JSON */
|
|
240
|
+
auditSummaryPath?: string;
|
|
241
|
+
/** Whether recovery milestones from audit are being executed */
|
|
242
|
+
auditRecoveryInProgress?: boolean;
|
|
243
|
+
/** ISO timestamp of last audit run */
|
|
244
|
+
auditLastRunAt?: string;
|
|
245
|
+
/** Unique identifier for the audit run */
|
|
246
|
+
auditRunId?: string;
|
|
237
247
|
}
|
|
238
248
|
|
|
239
249
|
/**
|
|
@@ -281,6 +291,11 @@ export const ProjectStateSchema = z.object({
|
|
|
281
291
|
sourceDocPaths: z.array(z.string()).optional(),
|
|
282
292
|
qaEnabled: z.boolean().optional(),
|
|
283
293
|
dbConfig: DbConfigSchema.optional(),
|
|
294
|
+
auditReportPath: z.string().optional(),
|
|
295
|
+
auditSummaryPath: z.string().optional(),
|
|
296
|
+
auditRecoveryInProgress: z.boolean().optional(),
|
|
297
|
+
auditLastRunAt: z.string().optional(),
|
|
298
|
+
auditRunId: z.string().optional(),
|
|
284
299
|
});
|
|
285
300
|
|
|
286
301
|
/**
|