@rigour-labs/core 1.7.0 → 2.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/discovery.js +12 -19
- package/dist/gates/ast-handlers/base.d.ts +12 -0
- package/dist/gates/ast-handlers/base.js +6 -0
- package/dist/gates/ast-handlers/python.d.ts +6 -0
- package/dist/gates/ast-handlers/python.js +64 -0
- package/dist/gates/ast-handlers/typescript.d.ts +9 -0
- package/dist/gates/ast-handlers/typescript.js +110 -0
- package/dist/gates/ast-handlers/universal.d.ts +8 -0
- package/dist/gates/ast-handlers/universal.js +156 -0
- package/dist/gates/ast.d.ts +1 -3
- package/dist/gates/ast.js +30 -109
- package/dist/gates/base.js +1 -5
- package/dist/gates/content.js +5 -9
- package/dist/gates/coverage.d.ts +8 -0
- package/dist/gates/coverage.js +62 -0
- package/dist/gates/dependency.js +7 -14
- package/dist/gates/file.js +5 -9
- package/dist/gates/runner.js +22 -22
- package/dist/gates/safety.js +4 -8
- package/dist/gates/structure.js +6 -13
- package/dist/index.js +8 -26
- package/dist/services/fix-packet-service.js +3 -7
- package/dist/services/state-service.js +9 -16
- package/dist/smoke.test.js +6 -8
- package/dist/templates/index.js +3 -6
- package/dist/types/fix-packet.js +22 -25
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.js +54 -56
- package/dist/utils/logger.js +8 -15
- package/dist/utils/scanner.js +7 -14
- package/package.json +3 -1
- package/src/gates/ast-handlers/base.ts +13 -0
- package/src/gates/ast-handlers/python.ts +71 -0
- package/src/gates/ast-handlers/python_parser.py +60 -0
- package/src/gates/ast-handlers/typescript.ts +125 -0
- package/src/gates/ast-handlers/universal.ts +184 -0
- package/src/gates/ast.ts +27 -127
- package/src/gates/coverage.ts +70 -0
- package/src/gates/runner.ts +4 -0
- package/src/types/index.ts +1 -0
package/dist/gates/content.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const base_js_1 = require("./base.js");
|
|
5
|
-
const scanner_js_1 = require("../utils/scanner.js");
|
|
6
|
-
class ContentGate extends base_js_1.Gate {
|
|
1
|
+
import { Gate } from './base.js';
|
|
2
|
+
import { FileScanner } from '../utils/scanner.js';
|
|
3
|
+
export class ContentGate extends Gate {
|
|
7
4
|
config;
|
|
8
5
|
constructor(config) {
|
|
9
6
|
super('content-check', 'Forbidden Content');
|
|
@@ -17,8 +14,8 @@ class ContentGate extends base_js_1.Gate {
|
|
|
17
14
|
patterns.push(/FIXME/i);
|
|
18
15
|
if (patterns.length === 0)
|
|
19
16
|
return [];
|
|
20
|
-
const files = await
|
|
21
|
-
const contents = await
|
|
17
|
+
const files = await FileScanner.findFiles({ cwd: context.cwd });
|
|
18
|
+
const contents = await FileScanner.readFiles(context.cwd, files);
|
|
22
19
|
const violations = [];
|
|
23
20
|
for (const [file, content] of contents) {
|
|
24
21
|
for (const pattern of patterns) {
|
|
@@ -36,4 +33,3 @@ class ContentGate extends base_js_1.Gate {
|
|
|
36
33
|
return [];
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
exports.ContentGate = ContentGate;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Gate, GateContext } from './base.js';
|
|
2
|
+
import { Failure, Gates } from '../types/index.js';
|
|
3
|
+
export declare class CoverageGate extends Gate {
|
|
4
|
+
private config;
|
|
5
|
+
constructor(config: Gates);
|
|
6
|
+
run(context: GateContext): Promise<Failure[]>;
|
|
7
|
+
private parseLcov;
|
|
8
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Gate } from './base.js';
|
|
4
|
+
import { globby } from 'globby';
|
|
5
|
+
export class CoverageGate extends Gate {
|
|
6
|
+
config;
|
|
7
|
+
constructor(config) {
|
|
8
|
+
super('coverage-guard', 'Dynamic Coverage Guard');
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
async run(context) {
|
|
12
|
+
const failures = [];
|
|
13
|
+
// 1. Locate coverage report (lcov.info is standard)
|
|
14
|
+
const reports = await globby(['**/lcov.info', '**/coverage-final.json'], {
|
|
15
|
+
cwd: context.cwd,
|
|
16
|
+
ignore: ['node_modules/**']
|
|
17
|
+
});
|
|
18
|
+
if (reports.length === 0) {
|
|
19
|
+
// If no reports found, and coverage is required, we could flag it.
|
|
20
|
+
// But for now, we'll just skip silently if not configured.
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
// 2. Parse coverage (Simplified LCOV parser for demonstration)
|
|
24
|
+
const coverageData = await this.parseLcov(path.join(context.cwd, reports[0]));
|
|
25
|
+
// 3. Quality Handshake: SME SME LOGIC
|
|
26
|
+
// We look for files that have high complexity but low coverage.
|
|
27
|
+
// In a real implementation, we would share data between ASTGate and CoverageGate.
|
|
28
|
+
// For this demo, we'll implement a standalone check.
|
|
29
|
+
for (const [file, stats] of Object.entries(coverageData)) {
|
|
30
|
+
const coverage = (stats.hit / stats.found) * 100;
|
|
31
|
+
const threshold = stats.isComplex ? 80 : 50; // SME logic: Complex files need higher coverage
|
|
32
|
+
if (coverage < threshold) {
|
|
33
|
+
failures.push({
|
|
34
|
+
id: 'DYNAMIC_COVERAGE_LOW',
|
|
35
|
+
title: `Low coverage for high-risk file: ${file}`,
|
|
36
|
+
details: `Current coverage: ${coverage.toFixed(2)}%. Required: ${threshold}% due to structural risk.`,
|
|
37
|
+
files: [file],
|
|
38
|
+
hint: `Add dynamic tests to cover complex logical branches in this file.`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return failures;
|
|
43
|
+
}
|
|
44
|
+
async parseLcov(reportPath) {
|
|
45
|
+
const content = await fs.readFile(reportPath, 'utf-8');
|
|
46
|
+
const results = {};
|
|
47
|
+
let currentFile = '';
|
|
48
|
+
for (const line of content.split('\n')) {
|
|
49
|
+
if (line.startsWith('SF:')) {
|
|
50
|
+
currentFile = line.substring(3);
|
|
51
|
+
results[currentFile] = { found: 0, hit: 0, isComplex: false };
|
|
52
|
+
}
|
|
53
|
+
else if (line.startsWith('LF:')) {
|
|
54
|
+
results[currentFile].found = parseInt(line.substring(3));
|
|
55
|
+
}
|
|
56
|
+
else if (line.startsWith('LH:')) {
|
|
57
|
+
results[currentFile].hit = parseInt(line.substring(3));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return results;
|
|
61
|
+
}
|
|
62
|
+
}
|
package/dist/gates/dependency.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DependencyGate = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const base_js_1 = require("./base.js");
|
|
10
|
-
class DependencyGate extends base_js_1.Gate {
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Gate } from './base.js';
|
|
4
|
+
export class DependencyGate extends Gate {
|
|
11
5
|
config;
|
|
12
6
|
constructor(config) {
|
|
13
7
|
super('dependency-guardian', 'Dependency Guardian');
|
|
@@ -20,10 +14,10 @@ class DependencyGate extends base_js_1.Gate {
|
|
|
20
14
|
return [];
|
|
21
15
|
const { cwd } = context;
|
|
22
16
|
// 1. Scan Node.js (package.json)
|
|
23
|
-
const pkgPath =
|
|
24
|
-
if (await
|
|
17
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
18
|
+
if (await fs.pathExists(pkgPath)) {
|
|
25
19
|
try {
|
|
26
|
-
const pkg = await
|
|
20
|
+
const pkg = await fs.readJson(pkgPath);
|
|
27
21
|
const allDeps = {
|
|
28
22
|
...(pkg.dependencies || {}),
|
|
29
23
|
...(pkg.devDependencies || {}),
|
|
@@ -40,4 +34,3 @@ class DependencyGate extends base_js_1.Gate {
|
|
|
40
34
|
return failures;
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
|
-
exports.DependencyGate = DependencyGate;
|
package/dist/gates/file.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const base_js_1 = require("./base.js");
|
|
5
|
-
const scanner_js_1 = require("../utils/scanner.js");
|
|
6
|
-
class FileGate extends base_js_1.Gate {
|
|
1
|
+
import { Gate } from './base.js';
|
|
2
|
+
import { FileScanner } from '../utils/scanner.js';
|
|
3
|
+
export class FileGate extends Gate {
|
|
7
4
|
config;
|
|
8
5
|
constructor(config) {
|
|
9
6
|
super('file-size', 'File Size Limit');
|
|
10
7
|
this.config = config;
|
|
11
8
|
}
|
|
12
9
|
async run(context) {
|
|
13
|
-
const files = await
|
|
14
|
-
const contents = await
|
|
10
|
+
const files = await FileScanner.findFiles({ cwd: context.cwd });
|
|
11
|
+
const contents = await FileScanner.readFiles(context.cwd, files);
|
|
15
12
|
const violations = [];
|
|
16
13
|
for (const [file, content] of contents) {
|
|
17
14
|
const lines = content.split('\n').length;
|
|
@@ -27,4 +24,3 @@ class FileGate extends base_js_1.Gate {
|
|
|
27
24
|
return [];
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
exports.FileGate = FileGate;
|
package/dist/gates/runner.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const logger_js_1 = require("../utils/logger.js");
|
|
12
|
-
class GateRunner {
|
|
1
|
+
import { FileGate } from './file.js';
|
|
2
|
+
import { ContentGate } from './content.js';
|
|
3
|
+
import { StructureGate } from './structure.js';
|
|
4
|
+
import { ASTGate } from './ast.js';
|
|
5
|
+
import { SafetyGate } from './safety.js';
|
|
6
|
+
import { DependencyGate } from './dependency.js';
|
|
7
|
+
import { CoverageGate } from './coverage.js';
|
|
8
|
+
import { execa } from 'execa';
|
|
9
|
+
import { Logger } from '../utils/logger.js';
|
|
10
|
+
export class GateRunner {
|
|
13
11
|
config;
|
|
14
12
|
gates = [];
|
|
15
13
|
constructor(config) {
|
|
@@ -18,18 +16,19 @@ class GateRunner {
|
|
|
18
16
|
}
|
|
19
17
|
initializeGates() {
|
|
20
18
|
if (this.config.gates.max_file_lines) {
|
|
21
|
-
this.gates.push(new
|
|
19
|
+
this.gates.push(new FileGate({ maxLines: this.config.gates.max_file_lines }));
|
|
22
20
|
}
|
|
23
|
-
this.gates.push(new
|
|
21
|
+
this.gates.push(new ContentGate({
|
|
24
22
|
forbidTodos: !!this.config.gates.forbid_todos,
|
|
25
23
|
forbidFixme: !!this.config.gates.forbid_fixme,
|
|
26
24
|
}));
|
|
27
25
|
if (this.config.gates.required_files) {
|
|
28
|
-
this.gates.push(new
|
|
26
|
+
this.gates.push(new StructureGate({ requiredFiles: this.config.gates.required_files }));
|
|
29
27
|
}
|
|
30
|
-
this.gates.push(new
|
|
31
|
-
this.gates.push(new
|
|
32
|
-
this.gates.push(new
|
|
28
|
+
this.gates.push(new ASTGate(this.config.gates));
|
|
29
|
+
this.gates.push(new DependencyGate(this.config));
|
|
30
|
+
this.gates.push(new SafetyGate(this.config.gates));
|
|
31
|
+
this.gates.push(new CoverageGate(this.config.gates));
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
35
34
|
* Allows adding custom gates dynamically (SOLID - Open/Closed Principle)
|
|
@@ -54,7 +53,7 @@ class GateRunner {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
catch (error) {
|
|
57
|
-
|
|
56
|
+
Logger.error(`Gate ${gate.id} failed with error: ${error.message}`);
|
|
58
57
|
summary[gate.id] = 'ERROR';
|
|
59
58
|
failures.push({
|
|
60
59
|
id: gate.id,
|
|
@@ -73,8 +72,8 @@ class GateRunner {
|
|
|
73
72
|
continue;
|
|
74
73
|
}
|
|
75
74
|
try {
|
|
76
|
-
|
|
77
|
-
await
|
|
75
|
+
Logger.info(`Running command gate: ${key} (${cmd})`);
|
|
76
|
+
await execa(cmd, { shell: true, cwd });
|
|
78
77
|
summary[key] = 'PASS';
|
|
79
78
|
}
|
|
80
79
|
catch (error) {
|
|
@@ -89,14 +88,15 @@ class GateRunner {
|
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
90
|
const status = failures.length > 0 ? 'FAIL' : 'PASS';
|
|
91
|
+
const score = Math.max(0, 100 - (failures.length * 5)); // Basic SME scoring logic
|
|
92
92
|
return {
|
|
93
93
|
status,
|
|
94
94
|
summary,
|
|
95
95
|
failures,
|
|
96
96
|
stats: {
|
|
97
97
|
duration_ms: Date.now() - start,
|
|
98
|
+
score,
|
|
98
99
|
},
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
|
-
exports.GateRunner = GateRunner;
|
package/dist/gates/safety.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const base_js_1 = require("./base.js");
|
|
5
|
-
const execa_1 = require("execa");
|
|
6
|
-
class SafetyGate extends base_js_1.Gate {
|
|
1
|
+
import { Gate } from './base.js';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
export class SafetyGate extends Gate {
|
|
7
4
|
config;
|
|
8
5
|
constructor(config) {
|
|
9
6
|
super('safety-rail', 'Safety & Protection Rails');
|
|
@@ -18,7 +15,7 @@ class SafetyGate extends base_js_1.Gate {
|
|
|
18
15
|
try {
|
|
19
16
|
// Check for modified files in protected paths using git
|
|
20
17
|
// This is a "Safety Rail" - if an agent touched these, we fail.
|
|
21
|
-
const { stdout } = await
|
|
18
|
+
const { stdout } = await execa('git', ['status', '--porcelain'], { cwd: context.cwd });
|
|
22
19
|
const modifiedFiles = stdout.split('\n')
|
|
23
20
|
.filter(line => line.trim().length > 0)
|
|
24
21
|
.map(line => line.slice(3));
|
|
@@ -44,4 +41,3 @@ class SafetyGate extends base_js_1.Gate {
|
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
|
-
exports.SafetyGate = SafetyGate;
|
package/dist/gates/structure.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.StructureGate = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const base_js_1 = require("./base.js");
|
|
10
|
-
class StructureGate extends base_js_1.Gate {
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { Gate } from './base.js';
|
|
4
|
+
export class StructureGate extends Gate {
|
|
11
5
|
config;
|
|
12
6
|
constructor(config) {
|
|
13
7
|
super('structure-check', 'Project Structure');
|
|
@@ -16,8 +10,8 @@ class StructureGate extends base_js_1.Gate {
|
|
|
16
10
|
async run(context) {
|
|
17
11
|
const missing = [];
|
|
18
12
|
for (const file of this.config.requiredFiles) {
|
|
19
|
-
const filePath =
|
|
20
|
-
if (!(await
|
|
13
|
+
const filePath = path.join(context.cwd, file);
|
|
14
|
+
if (!(await fs.pathExists(filePath))) {
|
|
21
15
|
missing.push(file);
|
|
22
16
|
}
|
|
23
17
|
}
|
|
@@ -29,4 +23,3 @@ class StructureGate extends base_js_1.Gate {
|
|
|
29
23
|
return [];
|
|
30
24
|
}
|
|
31
25
|
}
|
|
32
|
-
exports.StructureGate = StructureGate;
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Gate = void 0;
|
|
18
|
-
__exportStar(require("./types/index.js"), exports);
|
|
19
|
-
__exportStar(require("./gates/runner.js"), exports);
|
|
20
|
-
__exportStar(require("./discovery.js"), exports);
|
|
21
|
-
__exportStar(require("./services/fix-packet-service.js"), exports);
|
|
22
|
-
__exportStar(require("./templates/index.js"), exports);
|
|
23
|
-
__exportStar(require("./types/fix-packet.js"), exports);
|
|
24
|
-
var base_js_1 = require("./gates/base.js");
|
|
25
|
-
Object.defineProperty(exports, "Gate", { enumerable: true, get: function () { return base_js_1.Gate; } });
|
|
26
|
-
__exportStar(require("./utils/logger.js"), exports);
|
|
1
|
+
export * from './types/index.js';
|
|
2
|
+
export * from './gates/runner.js';
|
|
3
|
+
export * from './discovery.js';
|
|
4
|
+
export * from './services/fix-packet-service.js';
|
|
5
|
+
export * from './templates/index.js';
|
|
6
|
+
export * from './types/fix-packet.js';
|
|
7
|
+
export { Gate } from './gates/base.js';
|
|
8
|
+
export * from './utils/logger.js';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FixPacketService = void 0;
|
|
4
|
-
const fix_packet_js_1 = require("../types/fix-packet.js");
|
|
5
|
-
class FixPacketService {
|
|
1
|
+
import { FixPacketV2Schema } from '../types/fix-packet.js';
|
|
2
|
+
export class FixPacketService {
|
|
6
3
|
generate(report, config) {
|
|
7
4
|
const violations = report.failures.map(f => ({
|
|
8
5
|
id: f.id,
|
|
@@ -27,7 +24,7 @@ class FixPacketService {
|
|
|
27
24
|
no_new_deps: true,
|
|
28
25
|
},
|
|
29
26
|
};
|
|
30
|
-
return
|
|
27
|
+
return FixPacketV2Schema.parse(packet);
|
|
31
28
|
}
|
|
32
29
|
inferSeverity(f) {
|
|
33
30
|
// High complexity or God objects are usually High severity
|
|
@@ -40,4 +37,3 @@ class FixPacketService {
|
|
|
40
37
|
return 'medium';
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.FixPacketService = FixPacketService;
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.StateService = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
9
3
|
const STATE_DIR = '.rigour';
|
|
10
4
|
const STATE_FILE = 'state.json';
|
|
11
5
|
const CURRENT_VERSION = 1;
|
|
12
|
-
class StateService {
|
|
6
|
+
export class StateService {
|
|
13
7
|
statePath;
|
|
14
8
|
state;
|
|
15
9
|
constructor(cwd) {
|
|
16
|
-
this.statePath =
|
|
10
|
+
this.statePath = path.join(cwd, STATE_DIR, STATE_FILE);
|
|
17
11
|
this.state = this.load();
|
|
18
12
|
}
|
|
19
13
|
load() {
|
|
20
14
|
try {
|
|
21
|
-
if (
|
|
22
|
-
const content =
|
|
15
|
+
if (fs.existsSync(this.statePath)) {
|
|
16
|
+
const content = fs.readFileSync(this.statePath, 'utf-8');
|
|
23
17
|
return JSON.parse(content);
|
|
24
18
|
}
|
|
25
19
|
}
|
|
@@ -89,8 +83,8 @@ class StateService {
|
|
|
89
83
|
}
|
|
90
84
|
save() {
|
|
91
85
|
try {
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
fs.ensureDirSync(path.dirname(this.statePath));
|
|
87
|
+
fs.writeFileSync(this.statePath, JSON.stringify(this.state, null, 2));
|
|
94
88
|
}
|
|
95
89
|
catch {
|
|
96
90
|
// Silent fail - state is optional
|
|
@@ -102,11 +96,10 @@ class StateService {
|
|
|
102
96
|
clear() {
|
|
103
97
|
this.state = this.createEmpty();
|
|
104
98
|
try {
|
|
105
|
-
|
|
99
|
+
fs.removeSync(this.statePath);
|
|
106
100
|
}
|
|
107
101
|
catch {
|
|
108
102
|
// Silent fail
|
|
109
103
|
}
|
|
110
104
|
}
|
|
111
105
|
}
|
|
112
|
-
exports.StateService = StateService;
|
package/dist/smoke.test.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
(0, vitest_1.describe)('GateRunner Smoke Test', () => {
|
|
6
|
-
(0, vitest_1.it)('should initialize with empty config', async () => {
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { GateRunner } from '../src/gates/runner.js';
|
|
3
|
+
describe('GateRunner Smoke Test', () => {
|
|
4
|
+
it('should initialize with empty config', async () => {
|
|
7
5
|
const config = {
|
|
8
6
|
version: 1,
|
|
9
7
|
commands: {},
|
|
@@ -13,7 +11,7 @@ const runner_js_1 = require("../src/gates/runner.js");
|
|
|
13
11
|
forbid_fixme: true,
|
|
14
12
|
},
|
|
15
13
|
};
|
|
16
|
-
const runner = new
|
|
17
|
-
|
|
14
|
+
const runner = new GateRunner(config);
|
|
15
|
+
expect(runner).toBeDefined();
|
|
18
16
|
});
|
|
19
17
|
});
|
package/dist/templates/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UNIVERSAL_CONFIG = exports.PARADIGM_TEMPLATES = exports.TEMPLATES = void 0;
|
|
4
|
-
exports.TEMPLATES = [
|
|
1
|
+
export const TEMPLATES = [
|
|
5
2
|
{
|
|
6
3
|
name: 'ui',
|
|
7
4
|
markers: [
|
|
@@ -92,7 +89,7 @@ exports.TEMPLATES = [
|
|
|
92
89
|
},
|
|
93
90
|
},
|
|
94
91
|
];
|
|
95
|
-
|
|
92
|
+
export const PARADIGM_TEMPLATES = [
|
|
96
93
|
{
|
|
97
94
|
name: 'oop',
|
|
98
95
|
markers: [
|
|
@@ -149,7 +146,7 @@ exports.PARADIGM_TEMPLATES = [
|
|
|
149
146
|
},
|
|
150
147
|
},
|
|
151
148
|
];
|
|
152
|
-
|
|
149
|
+
export const UNIVERSAL_CONFIG = {
|
|
153
150
|
version: 1,
|
|
154
151
|
commands: {},
|
|
155
152
|
gates: {
|
package/dist/types/fix-packet.js
CHANGED
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FixPacketV2Schema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
1
|
+
import { z } from 'zod';
|
|
5
2
|
/**
|
|
6
3
|
* Fix Packet v2 Schema
|
|
7
4
|
* Designed for high-fidelity communication with AI agents during the refinement loop.
|
|
8
5
|
*/
|
|
9
|
-
|
|
10
|
-
version:
|
|
11
|
-
goal:
|
|
12
|
-
violations:
|
|
13
|
-
id:
|
|
14
|
-
gate:
|
|
15
|
-
severity:
|
|
16
|
-
category:
|
|
17
|
-
title:
|
|
18
|
-
details:
|
|
19
|
-
files:
|
|
20
|
-
hint:
|
|
21
|
-
instructions:
|
|
22
|
-
metrics:
|
|
6
|
+
export const FixPacketV2Schema = z.object({
|
|
7
|
+
version: z.literal(2),
|
|
8
|
+
goal: z.string().default('Achieve PASS state for all quality gates'),
|
|
9
|
+
violations: z.array(z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
gate: z.string(),
|
|
12
|
+
severity: z.enum(['low', 'medium', 'high', 'critical']).default('medium'),
|
|
13
|
+
category: z.string().optional(),
|
|
14
|
+
title: z.string(),
|
|
15
|
+
details: z.string(),
|
|
16
|
+
files: z.array(z.string()).optional(),
|
|
17
|
+
hint: z.string().optional(),
|
|
18
|
+
instructions: z.array(z.string()).optional(), // Step-by-step fix instructions
|
|
19
|
+
metrics: z.record(z.any()).optional(), // e.g., { complexity: 15, max: 10 }
|
|
23
20
|
})),
|
|
24
|
-
constraints:
|
|
25
|
-
protected_paths:
|
|
26
|
-
do_not_touch:
|
|
27
|
-
max_files_changed:
|
|
28
|
-
no_new_deps:
|
|
29
|
-
allowed_dependencies:
|
|
30
|
-
paradigm:
|
|
21
|
+
constraints: z.object({
|
|
22
|
+
protected_paths: z.array(z.string()).optional(),
|
|
23
|
+
do_not_touch: z.array(z.string()).optional(), // Alias for protected_paths
|
|
24
|
+
max_files_changed: z.number().optional(),
|
|
25
|
+
no_new_deps: z.boolean().optional().default(true),
|
|
26
|
+
allowed_dependencies: z.array(z.string()).optional(),
|
|
27
|
+
paradigm: z.string().optional(), // 'oop', 'functional'
|
|
31
28
|
}).optional().default({}),
|
|
32
29
|
});
|
package/dist/types/index.d.ts
CHANGED
|
@@ -461,10 +461,13 @@ export declare const ReportSchema: z.ZodObject<{
|
|
|
461
461
|
}>, "many">;
|
|
462
462
|
stats: z.ZodObject<{
|
|
463
463
|
duration_ms: z.ZodNumber;
|
|
464
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
464
465
|
}, "strip", z.ZodTypeAny, {
|
|
465
466
|
duration_ms: number;
|
|
467
|
+
score?: number | undefined;
|
|
466
468
|
}, {
|
|
467
469
|
duration_ms: number;
|
|
470
|
+
score?: number | undefined;
|
|
468
471
|
}>;
|
|
469
472
|
}, "strip", z.ZodTypeAny, {
|
|
470
473
|
status: "PASS" | "FAIL" | "SKIP" | "ERROR";
|
|
@@ -478,6 +481,7 @@ export declare const ReportSchema: z.ZodObject<{
|
|
|
478
481
|
}[];
|
|
479
482
|
stats: {
|
|
480
483
|
duration_ms: number;
|
|
484
|
+
score?: number | undefined;
|
|
481
485
|
};
|
|
482
486
|
}, {
|
|
483
487
|
status: "PASS" | "FAIL" | "SKIP" | "ERROR";
|
|
@@ -491,6 +495,7 @@ export declare const ReportSchema: z.ZodObject<{
|
|
|
491
495
|
}[];
|
|
492
496
|
stats: {
|
|
493
497
|
duration_ms: number;
|
|
498
|
+
score?: number | undefined;
|
|
494
499
|
};
|
|
495
500
|
}>;
|
|
496
501
|
export type Report = z.infer<typeof ReportSchema>;
|