@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.
Files changed (40) hide show
  1. package/dist/discovery.js +12 -19
  2. package/dist/gates/ast-handlers/base.d.ts +12 -0
  3. package/dist/gates/ast-handlers/base.js +6 -0
  4. package/dist/gates/ast-handlers/python.d.ts +6 -0
  5. package/dist/gates/ast-handlers/python.js +64 -0
  6. package/dist/gates/ast-handlers/typescript.d.ts +9 -0
  7. package/dist/gates/ast-handlers/typescript.js +110 -0
  8. package/dist/gates/ast-handlers/universal.d.ts +8 -0
  9. package/dist/gates/ast-handlers/universal.js +156 -0
  10. package/dist/gates/ast.d.ts +1 -3
  11. package/dist/gates/ast.js +30 -109
  12. package/dist/gates/base.js +1 -5
  13. package/dist/gates/content.js +5 -9
  14. package/dist/gates/coverage.d.ts +8 -0
  15. package/dist/gates/coverage.js +62 -0
  16. package/dist/gates/dependency.js +7 -14
  17. package/dist/gates/file.js +5 -9
  18. package/dist/gates/runner.js +22 -22
  19. package/dist/gates/safety.js +4 -8
  20. package/dist/gates/structure.js +6 -13
  21. package/dist/index.js +8 -26
  22. package/dist/services/fix-packet-service.js +3 -7
  23. package/dist/services/state-service.js +9 -16
  24. package/dist/smoke.test.js +6 -8
  25. package/dist/templates/index.js +3 -6
  26. package/dist/types/fix-packet.js +22 -25
  27. package/dist/types/index.d.ts +5 -0
  28. package/dist/types/index.js +54 -56
  29. package/dist/utils/logger.js +8 -15
  30. package/dist/utils/scanner.js +7 -14
  31. package/package.json +3 -1
  32. package/src/gates/ast-handlers/base.ts +13 -0
  33. package/src/gates/ast-handlers/python.ts +71 -0
  34. package/src/gates/ast-handlers/python_parser.py +60 -0
  35. package/src/gates/ast-handlers/typescript.ts +125 -0
  36. package/src/gates/ast-handlers/universal.ts +184 -0
  37. package/src/gates/ast.ts +27 -127
  38. package/src/gates/coverage.ts +70 -0
  39. package/src/gates/runner.ts +4 -0
  40. package/src/types/index.ts +1 -0
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContentGate = void 0;
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 scanner_js_1.FileScanner.findFiles({ cwd: context.cwd });
21
- const contents = await scanner_js_1.FileScanner.readFiles(context.cwd, files);
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
+ }
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 = path_1.default.join(cwd, 'package.json');
24
- if (await fs_extra_1.default.pathExists(pkgPath)) {
17
+ const pkgPath = path.join(cwd, 'package.json');
18
+ if (await fs.pathExists(pkgPath)) {
25
19
  try {
26
- const pkg = await fs_extra_1.default.readJson(pkgPath);
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;
@@ -1,17 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileGate = void 0;
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 scanner_js_1.FileScanner.findFiles({ cwd: context.cwd });
14
- const contents = await scanner_js_1.FileScanner.readFiles(context.cwd, files);
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;
@@ -1,15 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GateRunner = void 0;
4
- const file_js_1 = require("./file.js");
5
- const content_js_1 = require("./content.js");
6
- const structure_js_1 = require("./structure.js");
7
- const ast_js_1 = require("./ast.js");
8
- const safety_js_1 = require("./safety.js");
9
- const dependency_js_1 = require("./dependency.js");
10
- const execa_1 = require("execa");
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 file_js_1.FileGate({ maxLines: this.config.gates.max_file_lines }));
19
+ this.gates.push(new FileGate({ maxLines: this.config.gates.max_file_lines }));
22
20
  }
23
- this.gates.push(new content_js_1.ContentGate({
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 structure_js_1.StructureGate({ requiredFiles: this.config.gates.required_files }));
26
+ this.gates.push(new StructureGate({ requiredFiles: this.config.gates.required_files }));
29
27
  }
30
- this.gates.push(new ast_js_1.ASTGate(this.config.gates));
31
- this.gates.push(new dependency_js_1.DependencyGate(this.config));
32
- this.gates.push(new safety_js_1.SafetyGate(this.config.gates));
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
- logger_js_1.Logger.error(`Gate ${gate.id} failed with error: ${error.message}`);
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
- logger_js_1.Logger.info(`Running command gate: ${key} (${cmd})`);
77
- await (0, execa_1.execa)(cmd, { shell: true, cwd });
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;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SafetyGate = void 0;
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 (0, execa_1.execa)('git', ['status', '--porcelain'], { cwd: context.cwd });
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;
@@ -1,13 +1,7 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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 = path_1.default.join(context.cwd, file);
20
- if (!(await fs_extra_1.default.pathExists(filePath))) {
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
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 fix_packet_js_1.FixPacketV2Schema.parse(packet);
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
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
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 = path_1.default.join(cwd, STATE_DIR, STATE_FILE);
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 (fs_extra_1.default.existsSync(this.statePath)) {
22
- const content = fs_extra_1.default.readFileSync(this.statePath, 'utf-8');
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
- fs_extra_1.default.ensureDirSync(path_1.default.dirname(this.statePath));
93
- fs_extra_1.default.writeFileSync(this.statePath, JSON.stringify(this.state, null, 2));
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
- fs_extra_1.default.removeSync(this.statePath);
99
+ fs.removeSync(this.statePath);
106
100
  }
107
101
  catch {
108
102
  // Silent fail
109
103
  }
110
104
  }
111
105
  }
112
- exports.StateService = StateService;
@@ -1,9 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const runner_js_1 = require("../src/gates/runner.js");
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 runner_js_1.GateRunner(config);
17
- (0, vitest_1.expect)(runner).toBeDefined();
14
+ const runner = new GateRunner(config);
15
+ expect(runner).toBeDefined();
18
16
  });
19
17
  });
@@ -1,7 +1,4 @@
1
- "use strict";
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
- exports.PARADIGM_TEMPLATES = [
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
- exports.UNIVERSAL_CONFIG = {
149
+ export const UNIVERSAL_CONFIG = {
153
150
  version: 1,
154
151
  commands: {},
155
152
  gates: {
@@ -1,32 +1,29 @@
1
- "use strict";
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
- exports.FixPacketV2Schema = zod_1.z.object({
10
- version: zod_1.z.literal(2),
11
- goal: zod_1.z.string().default('Achieve PASS state for all quality gates'),
12
- violations: zod_1.z.array(zod_1.z.object({
13
- id: zod_1.z.string(),
14
- gate: zod_1.z.string(),
15
- severity: zod_1.z.enum(['low', 'medium', 'high', 'critical']).default('medium'),
16
- category: zod_1.z.string().optional(),
17
- title: zod_1.z.string(),
18
- details: zod_1.z.string(),
19
- files: zod_1.z.array(zod_1.z.string()).optional(),
20
- hint: zod_1.z.string().optional(),
21
- instructions: zod_1.z.array(zod_1.z.string()).optional(), // Step-by-step fix instructions
22
- metrics: zod_1.z.record(zod_1.z.any()).optional(), // e.g., { complexity: 15, max: 10 }
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: zod_1.z.object({
25
- protected_paths: zod_1.z.array(zod_1.z.string()).optional(),
26
- do_not_touch: zod_1.z.array(zod_1.z.string()).optional(), // Alias for protected_paths
27
- max_files_changed: zod_1.z.number().optional(),
28
- no_new_deps: zod_1.z.boolean().optional().default(true),
29
- allowed_dependencies: zod_1.z.array(zod_1.z.string()).optional(),
30
- paradigm: zod_1.z.string().optional(), // 'oop', 'functional'
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
  });
@@ -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>;