guardrail-core 1.0.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/__tests__/autopilot.test.d.ts +7 -0
- package/dist/__tests__/autopilot.test.d.ts.map +1 -0
- package/dist/__tests__/autopilot.test.js +156 -0
- package/dist/__tests__/tier-config.test.d.ts +9 -0
- package/dist/__tests__/tier-config.test.d.ts.map +1 -0
- package/dist/__tests__/tier-config.test.js +230 -0
- package/dist/__tests__/utils/hash-inline.test.d.ts +2 -0
- package/dist/__tests__/utils/hash-inline.test.d.ts.map +1 -0
- package/dist/__tests__/utils/hash-inline.test.js +62 -0
- package/dist/__tests__/utils/hash.test.d.ts +3 -0
- package/dist/__tests__/utils/hash.test.d.ts.map +1 -0
- package/dist/__tests__/utils/hash.test.js +95 -0
- package/dist/__tests__/utils/simple.test.d.ts +1 -0
- package/dist/__tests__/utils/simple.test.d.ts.map +1 -0
- package/dist/__tests__/utils/simple.test.js +10 -0
- package/dist/__tests__/utils/utils-simple.test.d.ts +1 -0
- package/dist/__tests__/utils/utils-simple.test.d.ts.map +1 -0
- package/dist/__tests__/utils/utils-simple.test.js +6 -0
- package/dist/__tests__/utils/utils.test.d.ts +15 -0
- package/dist/__tests__/utils/utils.test.d.ts.map +1 -0
- package/dist/__tests__/utils/utils.test.js +172 -0
- package/dist/autopilot/autopilot-runner.d.ts +33 -0
- package/dist/autopilot/autopilot-runner.d.ts.map +1 -0
- package/dist/autopilot/autopilot-runner.js +479 -0
- package/dist/autopilot/index.d.ts +6 -0
- package/dist/autopilot/index.d.ts.map +1 -0
- package/dist/autopilot/index.js +25 -0
- package/dist/autopilot/types.d.ts +102 -0
- package/dist/autopilot/types.d.ts.map +1 -0
- package/dist/autopilot/types.js +18 -0
- package/dist/cache/index.d.ts +7 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +22 -0
- package/dist/cache/redis-cache.d.ts +145 -0
- package/dist/cache/redis-cache.d.ts.map +1 -0
- package/dist/cache/redis-cache.js +459 -0
- package/dist/ci/github-actions.d.ts +77 -0
- package/dist/ci/github-actions.d.ts.map +1 -0
- package/dist/ci/github-actions.js +277 -0
- package/dist/ci/index.d.ts +12 -0
- package/dist/ci/index.d.ts.map +1 -0
- package/dist/ci/index.js +27 -0
- package/dist/ci/pre-commit.d.ts +65 -0
- package/dist/ci/pre-commit.d.ts.map +1 -0
- package/dist/ci/pre-commit.js +286 -0
- package/dist/entitlements.d.ts +149 -0
- package/dist/entitlements.d.ts.map +1 -0
- package/dist/entitlements.js +464 -0
- package/dist/env.d.ts +113 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +204 -0
- package/dist/fix-packs/__tests__/generate-fix-packs.test.d.ts +7 -0
- package/dist/fix-packs/__tests__/generate-fix-packs.test.d.ts.map +1 -0
- package/dist/fix-packs/__tests__/generate-fix-packs.test.js +250 -0
- package/dist/fix-packs/generate-fix-packs.d.ts +15 -0
- package/dist/fix-packs/generate-fix-packs.d.ts.map +1 -0
- package/dist/fix-packs/generate-fix-packs.js +505 -0
- package/dist/fix-packs/index.d.ts +8 -0
- package/dist/fix-packs/index.d.ts.map +1 -0
- package/dist/fix-packs/index.js +23 -0
- package/dist/fix-packs/types.d.ts +113 -0
- package/dist/fix-packs/types.d.ts.map +1 -0
- package/dist/fix-packs/types.js +71 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/metrics/prometheus.d.ts +99 -0
- package/dist/metrics/prometheus.d.ts.map +1 -0
- package/dist/metrics/prometheus.js +306 -0
- package/dist/quota-ledger.d.ts +119 -0
- package/dist/quota-ledger.d.ts.map +1 -0
- package/dist/quota-ledger.js +462 -0
- package/dist/rbac/__tests__/permissions.test.d.ts +8 -0
- package/dist/rbac/__tests__/permissions.test.d.ts.map +1 -0
- package/dist/rbac/__tests__/permissions.test.js +350 -0
- package/dist/rbac/index.d.ts +9 -0
- package/dist/rbac/index.d.ts.map +1 -0
- package/dist/rbac/index.js +32 -0
- package/dist/rbac/permissions.d.ts +71 -0
- package/dist/rbac/permissions.d.ts.map +1 -0
- package/dist/rbac/permissions.js +247 -0
- package/dist/rbac/types.d.ts +69 -0
- package/dist/rbac/types.d.ts.map +1 -0
- package/dist/rbac/types.js +213 -0
- package/dist/tier-config.d.ts +203 -0
- package/dist/tier-config.d.ts.map +1 -0
- package/dist/tier-config.js +675 -0
- package/dist/types.d.ts +365 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/utils.d.ts +36 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +127 -0
- package/dist/verified-autofix/__tests__/format-validator.test.d.ts +11 -0
- package/dist/verified-autofix/__tests__/format-validator.test.d.ts.map +1 -0
- package/dist/verified-autofix/__tests__/format-validator.test.js +285 -0
- package/dist/verified-autofix/__tests__/pipeline.test.d.ts +11 -0
- package/dist/verified-autofix/__tests__/pipeline.test.d.ts.map +1 -0
- package/dist/verified-autofix/__tests__/pipeline.test.js +389 -0
- package/dist/verified-autofix/__tests__/repo-fingerprint.test.d.ts +11 -0
- package/dist/verified-autofix/__tests__/repo-fingerprint.test.d.ts.map +1 -0
- package/dist/verified-autofix/__tests__/repo-fingerprint.test.js +236 -0
- package/dist/verified-autofix/__tests__/workspace.test.d.ts +11 -0
- package/dist/verified-autofix/__tests__/workspace.test.d.ts.map +1 -0
- package/dist/verified-autofix/__tests__/workspace.test.js +314 -0
- package/dist/verified-autofix/format-validator.d.ts +101 -0
- package/dist/verified-autofix/format-validator.d.ts.map +1 -0
- package/dist/verified-autofix/format-validator.js +446 -0
- package/dist/verified-autofix/index.d.ts +14 -0
- package/dist/verified-autofix/index.d.ts.map +1 -0
- package/dist/verified-autofix/index.js +39 -0
- package/dist/verified-autofix/pipeline.d.ts +68 -0
- package/dist/verified-autofix/pipeline.d.ts.map +1 -0
- package/dist/verified-autofix/pipeline.js +330 -0
- package/dist/verified-autofix/repo-fingerprint.d.ts +56 -0
- package/dist/verified-autofix/repo-fingerprint.d.ts.map +1 -0
- package/dist/verified-autofix/repo-fingerprint.js +396 -0
- package/dist/verified-autofix/workspace.d.ts +83 -0
- package/dist/verified-autofix/workspace.d.ts.map +1 -0
- package/dist/verified-autofix/workspace.js +454 -0
- package/dist/verified-autofix.d.ts +182 -0
- package/dist/verified-autofix.d.ts.map +1 -0
- package/dist/verified-autofix.js +1021 -0
- package/dist/visualization/dependency-graph.d.ts +79 -0
- package/dist/visualization/dependency-graph.d.ts.map +1 -0
- package/dist/visualization/dependency-graph.js +399 -0
- package/dist/visualization/index.d.ts +5 -0
- package/dist/visualization/index.d.ts.map +1 -0
- package/dist/visualization/index.js +20 -0
- package/package.json +29 -0
- package/src/__tests__/autopilot.test.ts +196 -0
- package/src/__tests__/tier-config.test.ts +289 -0
- package/src/__tests__/utils/hash-inline.test.ts +76 -0
- package/src/__tests__/utils/hash.test.ts +119 -0
- package/src/__tests__/utils/simple.test.ts +10 -0
- package/src/__tests__/utils/utils-simple.test.ts +5 -0
- package/src/__tests__/utils/utils.test.ts +203 -0
- package/src/autopilot/autopilot-runner.ts +503 -0
- package/src/autopilot/index.ts +6 -0
- package/src/autopilot/types.ts +119 -0
- package/src/cache/index.ts +7 -0
- package/src/cache/redis-cache.d.ts +155 -0
- package/src/cache/redis-cache.d.ts.map +1 -0
- package/src/cache/redis-cache.ts +517 -0
- package/src/ci/github-actions.ts +335 -0
- package/src/ci/index.ts +12 -0
- package/src/ci/pre-commit.ts +338 -0
- package/src/db/usage-schema.prisma +114 -0
- package/src/entitlements.ts +570 -0
- package/src/env.d.ts +68 -0
- package/src/env.d.ts.map +1 -0
- package/src/env.ts +247 -0
- package/src/fix-packs/__tests__/generate-fix-packs.test.ts +317 -0
- package/src/fix-packs/generate-fix-packs.ts +577 -0
- package/src/fix-packs/index.ts +8 -0
- package/src/fix-packs/types.ts +206 -0
- package/src/index.d.ts +7 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +12 -0
- package/src/metrics/prometheus.d.ts +104 -0
- package/src/metrics/prometheus.d.ts.map +1 -0
- package/src/metrics/prometheus.ts +446 -0
- package/src/quota-ledger.ts +548 -0
- package/src/rbac/__tests__/permissions.test.ts +446 -0
- package/src/rbac/index.ts +46 -0
- package/src/rbac/permissions.ts +301 -0
- package/src/rbac/types.ts +298 -0
- package/src/tier-config.json +157 -0
- package/src/tier-config.ts +815 -0
- package/src/types.d.ts +365 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +441 -0
- package/src/utils.d.ts +36 -0
- package/src/utils.d.ts.map +1 -0
- package/src/utils.ts +140 -0
- package/src/verified-autofix/__tests__/format-validator.test.ts +335 -0
- package/src/verified-autofix/__tests__/pipeline.test.ts +419 -0
- package/src/verified-autofix/__tests__/repo-fingerprint.test.ts +241 -0
- package/src/verified-autofix/__tests__/workspace.test.ts +373 -0
- package/src/verified-autofix/format-validator.ts +517 -0
- package/src/verified-autofix/index.ts +63 -0
- package/src/verified-autofix/pipeline.ts +403 -0
- package/src/verified-autofix/repo-fingerprint.ts +459 -0
- package/src/verified-autofix/workspace.ts +531 -0
- package/src/verified-autofix.ts +1187 -0
- package/src/visualization/dependency-graph.d.ts +85 -0
- package/src/visualization/dependency-graph.d.ts.map +1 -0
- package/src/visualization/dependency-graph.ts +495 -0
- package/src/visualization/index.ts +5 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Verified AutoFix Pipeline - Orchestration Layer
|
|
4
|
+
*
|
|
5
|
+
* Pipeline order:
|
|
6
|
+
* 1. format → validate JSON shape + strip markdown
|
|
7
|
+
* 2. diff/path safety → validate unified diff + paths within project
|
|
8
|
+
* 3. command safety → warn on risky commands
|
|
9
|
+
* 4. stub detection → block TODO/placeholder in production
|
|
10
|
+
* 5. apply diff → git apply --check then git apply
|
|
11
|
+
* 6. typecheck → tsc --noEmit
|
|
12
|
+
* 7. build (ship) → npm run build
|
|
13
|
+
* 8. tests → npm test
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.verifiedAutofixPipeline = exports.VerifiedAutofixPipeline = void 0;
|
|
50
|
+
exports.formatPipelineResult = formatPipelineResult;
|
|
51
|
+
exports.formatPipelineResultJson = formatPipelineResultJson;
|
|
52
|
+
const fs = __importStar(require("fs"));
|
|
53
|
+
const format_validator_1 = require("./format-validator");
|
|
54
|
+
const workspace_1 = require("./workspace");
|
|
55
|
+
const repo_fingerprint_1 = require("./repo-fingerprint");
|
|
56
|
+
const entitlements_1 = require("../entitlements");
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// PIPELINE CLASS
|
|
59
|
+
// ============================================================================
|
|
60
|
+
class VerifiedAutofixPipeline {
|
|
61
|
+
workspace;
|
|
62
|
+
constructor() {
|
|
63
|
+
this.workspace = new workspace_1.TempWorkspace();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Run the full verification pipeline
|
|
67
|
+
*/
|
|
68
|
+
async run(options) {
|
|
69
|
+
const startTime = Date.now();
|
|
70
|
+
const result = {
|
|
71
|
+
success: false,
|
|
72
|
+
stage: 'init',
|
|
73
|
+
duration: 0,
|
|
74
|
+
filesModified: [],
|
|
75
|
+
errors: [],
|
|
76
|
+
warnings: [],
|
|
77
|
+
failureContext: [],
|
|
78
|
+
};
|
|
79
|
+
let workspaceId = null;
|
|
80
|
+
try {
|
|
81
|
+
// Enforce feature entitlement (Pro+ required) unless skipped
|
|
82
|
+
if (!options.skipEntitlements && process.env['GUARDRAIL_SKIP_ENTITLEMENTS'] !== '1') {
|
|
83
|
+
await (0, entitlements_1.enforceFeature)('fix:auto');
|
|
84
|
+
}
|
|
85
|
+
options.onProgress?.('init', 'Starting verified autofix pipeline');
|
|
86
|
+
// Step 1: Read agent output
|
|
87
|
+
result.stage = 'validate';
|
|
88
|
+
options.onProgress?.('validate', 'Reading agent output');
|
|
89
|
+
let rawOutput;
|
|
90
|
+
if (options.agentOutputFile) {
|
|
91
|
+
if (!fs.existsSync(options.agentOutputFile)) {
|
|
92
|
+
throw new Error(`Agent output file not found: ${options.agentOutputFile}`);
|
|
93
|
+
}
|
|
94
|
+
rawOutput = await fs.promises.readFile(options.agentOutputFile, 'utf8');
|
|
95
|
+
}
|
|
96
|
+
else if (options.agentOutputRaw) {
|
|
97
|
+
rawOutput = options.agentOutputRaw;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
throw new Error('Either agentOutputFile or agentOutputRaw must be provided');
|
|
101
|
+
}
|
|
102
|
+
// Step 2: Validate format
|
|
103
|
+
options.onProgress?.('validate', 'Validating output format');
|
|
104
|
+
const validation = (0, format_validator_1.validateAgentOutput)(rawOutput, options.projectPath, {
|
|
105
|
+
strictMarkdown: options.strictMarkdown,
|
|
106
|
+
});
|
|
107
|
+
result.validation = validation;
|
|
108
|
+
if (!validation.valid || !validation.output) {
|
|
109
|
+
result.errors.push(...validation.errors);
|
|
110
|
+
result.warnings.push(...validation.warnings);
|
|
111
|
+
throw new Error(`Validation failed: ${validation.errors.join('; ')}`);
|
|
112
|
+
}
|
|
113
|
+
result.output = validation.output;
|
|
114
|
+
result.warnings.push(...validation.warnings);
|
|
115
|
+
result.filesModified = validation.diffValidation?.filesAffected || [];
|
|
116
|
+
options.onProgress?.('validate', `Validated ${result.filesModified.length} file(s)`, {
|
|
117
|
+
files: result.filesModified,
|
|
118
|
+
});
|
|
119
|
+
// Empty diff is a no-op success
|
|
120
|
+
if (!validation.output.diff || validation.output.diff.trim() === '') {
|
|
121
|
+
options.onProgress?.('done', 'No changes to apply');
|
|
122
|
+
result.success = true;
|
|
123
|
+
result.stage = 'done';
|
|
124
|
+
result.duration = Date.now() - startTime;
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
// Step 3: Fingerprint repo
|
|
128
|
+
result.stage = 'fingerprint';
|
|
129
|
+
options.onProgress?.('fingerprint', 'Analyzing project structure');
|
|
130
|
+
const { fingerprint, detectionNotes } = (0, repo_fingerprint_1.fingerprintRepo)(options.projectPath);
|
|
131
|
+
result.fingerprint = fingerprint;
|
|
132
|
+
result.warnings.push(...detectionNotes);
|
|
133
|
+
options.onProgress?.('fingerprint', `Detected ${fingerprint.framework} + ${fingerprint.packageManager}`, {
|
|
134
|
+
fingerprint,
|
|
135
|
+
});
|
|
136
|
+
// Dry run: stop here and report what would happen
|
|
137
|
+
if (options.dryRun) {
|
|
138
|
+
options.onProgress?.('done', 'Dry run complete - no changes applied');
|
|
139
|
+
result.success = true;
|
|
140
|
+
result.stage = 'done';
|
|
141
|
+
result.duration = Date.now() - startTime;
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
// Step 4: Create temp workspace
|
|
145
|
+
result.stage = 'workspace';
|
|
146
|
+
options.onProgress?.('workspace', 'Creating isolated workspace');
|
|
147
|
+
const workspaceInfo = await this.workspace.create({
|
|
148
|
+
projectPath: options.projectPath,
|
|
149
|
+
useWorktree: true,
|
|
150
|
+
installDeps: false, // Don't install deps in workspace for speed
|
|
151
|
+
timeout: options.timeout,
|
|
152
|
+
});
|
|
153
|
+
workspaceId = workspaceInfo.id;
|
|
154
|
+
options.onProgress?.('workspace', `Created ${workspaceInfo.type} workspace`, {
|
|
155
|
+
path: workspaceInfo.path,
|
|
156
|
+
});
|
|
157
|
+
// Step 5: Apply diff
|
|
158
|
+
result.stage = 'apply';
|
|
159
|
+
options.onProgress?.('apply', 'Applying diff to workspace');
|
|
160
|
+
const applyResult = await this.workspace.applyDiff(workspaceInfo.path, validation.output.diff, validation.diffValidation?.hunks || []);
|
|
161
|
+
if (!applyResult.success) {
|
|
162
|
+
result.errors.push(...applyResult.errors);
|
|
163
|
+
throw new Error(`Diff application failed: ${applyResult.errors.join('; ')}`);
|
|
164
|
+
}
|
|
165
|
+
options.onProgress?.('apply', `Applied ${applyResult.applied} hunk(s)`);
|
|
166
|
+
// Step 6-8: Run verification (typecheck, build, tests)
|
|
167
|
+
result.stage = 'typecheck';
|
|
168
|
+
options.onProgress?.('typecheck', 'Running verification checks');
|
|
169
|
+
const verification = await this.workspace.verify(workspaceInfo.path, fingerprint, {
|
|
170
|
+
skipTests: options.skipTests,
|
|
171
|
+
timeout: options.timeout,
|
|
172
|
+
});
|
|
173
|
+
result.verification = verification;
|
|
174
|
+
result.failureContext = verification.failureContext;
|
|
175
|
+
// Report check progress
|
|
176
|
+
for (const check of verification.checks) {
|
|
177
|
+
const status = check.passed ? '✓' : '✗';
|
|
178
|
+
const stage = check.name.toLowerCase().includes('build') ? 'build' :
|
|
179
|
+
check.name.toLowerCase().includes('test') ? 'test' : 'typecheck';
|
|
180
|
+
options.onProgress?.(stage, `${status} ${check.name} (${check.duration}ms)`);
|
|
181
|
+
}
|
|
182
|
+
if (!verification.passed) {
|
|
183
|
+
result.errors.push('Verification failed');
|
|
184
|
+
result.errors.push(...verification.failureContext);
|
|
185
|
+
throw new Error(`Verification failed: ${verification.failureContext.slice(0, 3).join('; ')}`);
|
|
186
|
+
}
|
|
187
|
+
// Step 9: Copy verified changes back to project
|
|
188
|
+
result.stage = 'commit';
|
|
189
|
+
options.onProgress?.('commit', 'Applying verified changes to project');
|
|
190
|
+
await this.workspace.copyBack(workspaceInfo.path, options.projectPath, result.filesModified);
|
|
191
|
+
// Track usage
|
|
192
|
+
await (0, entitlements_1.trackUsage)('fixRuns', 1);
|
|
193
|
+
// Success!
|
|
194
|
+
result.success = true;
|
|
195
|
+
result.stage = 'done';
|
|
196
|
+
options.onProgress?.('done', `Successfully modified ${result.filesModified.length} file(s)`);
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
const error = e;
|
|
200
|
+
result.errors.push(error.message);
|
|
201
|
+
// Handle entitlement errors
|
|
202
|
+
if (error.code === 'FEATURE_NOT_AVAILABLE') {
|
|
203
|
+
result.stage = 'error';
|
|
204
|
+
result.errors = [`Feature requires upgrade: ${error.message}`];
|
|
205
|
+
}
|
|
206
|
+
options.onProgress?.('error', error.message);
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
// Cleanup workspace
|
|
210
|
+
if (workspaceId) {
|
|
211
|
+
try {
|
|
212
|
+
await this.workspace.cleanup(workspaceId);
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// Ignore cleanup errors
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
result.duration = Date.now() - startTime;
|
|
219
|
+
}
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Run from a file (CLI convenience method)
|
|
224
|
+
*/
|
|
225
|
+
async runFromFile(agentOutputFile, projectPath, options) {
|
|
226
|
+
return this.run({
|
|
227
|
+
projectPath,
|
|
228
|
+
agentOutputFile,
|
|
229
|
+
...options,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Validate only (no apply) - for checking output format
|
|
234
|
+
*/
|
|
235
|
+
validateOnly(raw, projectPath) {
|
|
236
|
+
return (0, format_validator_1.validateAgentOutput)(raw, projectPath);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.VerifiedAutofixPipeline = VerifiedAutofixPipeline;
|
|
240
|
+
// ============================================================================
|
|
241
|
+
// RESULT FORMATTING
|
|
242
|
+
// ============================================================================
|
|
243
|
+
/**
|
|
244
|
+
* Format pipeline result for CLI output
|
|
245
|
+
*/
|
|
246
|
+
function formatPipelineResult(result) {
|
|
247
|
+
const lines = [];
|
|
248
|
+
// Header
|
|
249
|
+
if (result.success) {
|
|
250
|
+
lines.push('✓ VERIFIED AUTOFIX SUCCESSFUL');
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
lines.push('✗ VERIFIED AUTOFIX FAILED');
|
|
254
|
+
}
|
|
255
|
+
lines.push('');
|
|
256
|
+
// Stage info
|
|
257
|
+
lines.push(`Stage: ${result.stage}`);
|
|
258
|
+
lines.push(`Duration: ${result.duration}ms`);
|
|
259
|
+
lines.push('');
|
|
260
|
+
// Files modified
|
|
261
|
+
if (result.filesModified.length > 0) {
|
|
262
|
+
lines.push('Files modified:');
|
|
263
|
+
for (const file of result.filesModified.slice(0, 10)) {
|
|
264
|
+
lines.push(` • ${file}`);
|
|
265
|
+
}
|
|
266
|
+
if (result.filesModified.length > 10) {
|
|
267
|
+
lines.push(` ... and ${result.filesModified.length - 10} more`);
|
|
268
|
+
}
|
|
269
|
+
lines.push('');
|
|
270
|
+
}
|
|
271
|
+
// Verification results
|
|
272
|
+
if (result.verification) {
|
|
273
|
+
lines.push('Verification:');
|
|
274
|
+
for (const check of result.verification.checks) {
|
|
275
|
+
const icon = check.passed ? '✓' : '✗';
|
|
276
|
+
lines.push(` ${icon} ${check.name} (${check.duration}ms)`);
|
|
277
|
+
}
|
|
278
|
+
lines.push('');
|
|
279
|
+
}
|
|
280
|
+
// Errors
|
|
281
|
+
if (result.errors.length > 0) {
|
|
282
|
+
lines.push('Errors:');
|
|
283
|
+
for (const err of result.errors.slice(0, 5)) {
|
|
284
|
+
lines.push(` • ${err}`);
|
|
285
|
+
}
|
|
286
|
+
lines.push('');
|
|
287
|
+
}
|
|
288
|
+
// Failure context (top 3)
|
|
289
|
+
if (result.failureContext.length > 0) {
|
|
290
|
+
lines.push('Top failures:');
|
|
291
|
+
for (const ctx of result.failureContext) {
|
|
292
|
+
lines.push(` 1. ${ctx}`);
|
|
293
|
+
}
|
|
294
|
+
lines.push('');
|
|
295
|
+
}
|
|
296
|
+
// Warnings
|
|
297
|
+
if (result.warnings.length > 0) {
|
|
298
|
+
lines.push('Warnings:');
|
|
299
|
+
for (const warn of result.warnings.slice(0, 5)) {
|
|
300
|
+
lines.push(` ⚠ ${warn}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return lines.join('\n');
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Format result as JSON for machine consumption
|
|
307
|
+
*/
|
|
308
|
+
function formatPipelineResultJson(result) {
|
|
309
|
+
return JSON.stringify({
|
|
310
|
+
success: result.success,
|
|
311
|
+
stage: result.stage,
|
|
312
|
+
duration: result.duration,
|
|
313
|
+
filesModified: result.filesModified,
|
|
314
|
+
errors: result.errors,
|
|
315
|
+
warnings: result.warnings,
|
|
316
|
+
failureContext: result.failureContext,
|
|
317
|
+
verification: result.verification ? {
|
|
318
|
+
passed: result.verification.passed,
|
|
319
|
+
checks: result.verification.checks.map(c => ({
|
|
320
|
+
name: c.name,
|
|
321
|
+
passed: c.passed,
|
|
322
|
+
duration: c.duration,
|
|
323
|
+
})),
|
|
324
|
+
} : null,
|
|
325
|
+
}, null, 2);
|
|
326
|
+
}
|
|
327
|
+
// ============================================================================
|
|
328
|
+
// EXPORTS
|
|
329
|
+
// ============================================================================
|
|
330
|
+
exports.verifiedAutofixPipeline = new VerifiedAutofixPipeline();
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repo Fingerprint - Project Detection & Configuration
|
|
3
|
+
*
|
|
4
|
+
* Detects project characteristics:
|
|
5
|
+
* 1. Package manager (pnpm, yarn, npm)
|
|
6
|
+
* 2. Build tool (turbo, nx, none)
|
|
7
|
+
* 3. Framework (next, vite, cra, etc.)
|
|
8
|
+
* 4. Test runner (jest, vitest, mocha, etc.)
|
|
9
|
+
* 5. Language features (TypeScript, ESLint, etc.)
|
|
10
|
+
*/
|
|
11
|
+
export type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun' | 'unknown';
|
|
12
|
+
export type BuildTool = 'turbo' | 'nx' | 'lerna' | 'none';
|
|
13
|
+
export type Framework = 'next' | 'vite' | 'cra' | 'remix' | 'gatsby' | 'nuxt' | 'svelte' | 'angular' | 'express' | 'fastify' | 'none';
|
|
14
|
+
export type TestRunner = 'jest' | 'vitest' | 'mocha' | 'ava' | 'playwright' | 'cypress' | 'none';
|
|
15
|
+
export interface RepoFingerprint {
|
|
16
|
+
packageManager: PackageManager;
|
|
17
|
+
buildTool: BuildTool;
|
|
18
|
+
framework: Framework;
|
|
19
|
+
testRunner: TestRunner;
|
|
20
|
+
hasTypeScript: boolean;
|
|
21
|
+
hasESLint: boolean;
|
|
22
|
+
hasPrettier: boolean;
|
|
23
|
+
hasBuildScript: boolean;
|
|
24
|
+
hasTestScript: boolean;
|
|
25
|
+
isMonorepo: boolean;
|
|
26
|
+
workspaces: string[];
|
|
27
|
+
nodeVersion?: string;
|
|
28
|
+
dependencies: Record<string, string>;
|
|
29
|
+
devDependencies: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
export interface FingerprintResult {
|
|
32
|
+
fingerprint: RepoFingerprint;
|
|
33
|
+
confidence: number;
|
|
34
|
+
detectionNotes: string[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Analyze a project and return its fingerprint
|
|
38
|
+
*/
|
|
39
|
+
export declare function fingerprintRepo(projectPath: string): FingerprintResult;
|
|
40
|
+
/**
|
|
41
|
+
* Get appropriate install command for package manager
|
|
42
|
+
*/
|
|
43
|
+
export declare function getInstallCommand(packageManager: PackageManager): string;
|
|
44
|
+
/**
|
|
45
|
+
* Get appropriate build command
|
|
46
|
+
*/
|
|
47
|
+
export declare function getBuildCommand(fingerprint: RepoFingerprint): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get appropriate test command
|
|
50
|
+
*/
|
|
51
|
+
export declare function getTestCommand(fingerprint: RepoFingerprint): string;
|
|
52
|
+
/**
|
|
53
|
+
* Get typecheck command if TypeScript is present
|
|
54
|
+
*/
|
|
55
|
+
export declare function getTypecheckCommand(fingerprint: RepoFingerprint): string | null;
|
|
56
|
+
//# sourceMappingURL=repo-fingerprint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-fingerprint.d.ts","sourceRoot":"","sources":["../../src/verified-autofix/repo-fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;AACzE,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,CAAC;AAC1D,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AACtI,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjG,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AA8PD;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,iBAAiB,CA4FtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,cAAc,GAAG,MAAM,CAYxE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAWpE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,CAiBnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAK/E"}
|