@dommaker/harness 0.1.4 → 0.2.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/dist/cli/commands/check.d.ts +5 -5
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +65 -42
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +84 -0
- package/dist/core/constraints/checker.d.ts.map +1 -0
- package/dist/core/constraints/checker.js +375 -0
- package/dist/core/constraints/checker.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts +42 -0
- package/dist/core/constraints/definitions.d.ts.map +1 -0
- package/dist/core/constraints/definitions.js +438 -0
- package/dist/core/constraints/definitions.js.map +1 -0
- package/dist/core/constraints/index.d.ts +8 -0
- package/dist/core/constraints/index.d.ts.map +1 -0
- package/dist/core/constraints/index.js +36 -0
- package/dist/core/constraints/index.js.map +1 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/validators/checkpoint.d.ts +13 -1
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +51 -0
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -7
- package/dist/index.js.map +1 -1
- package/dist/presets/index.d.ts +3 -11
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +9 -19
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/standard.d.ts +44 -2
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +71 -41
- package/dist/presets/standard.js.map +1 -1
- package/dist/types/constraint.d.ts +184 -0
- package/dist/types/constraint.d.ts.map +1 -0
- package/dist/types/constraint.js +34 -0
- package/dist/types/constraint.js.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/iron-law.d.ts +15 -103
- package/dist/types/iron-law.d.ts.map +1 -1
- package/dist/types/iron-law.js +8 -13
- package/dist/types/iron-law.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/iron-laws/checker.d.ts +0 -61
- package/dist/core/iron-laws/checker.d.ts.map +0 -1
- package/dist/core/iron-laws/checker.js +0 -175
- package/dist/core/iron-laws/checker.js.map +0 -1
- package/dist/core/iron-laws/definitions.d.ts +0 -28
- package/dist/core/iron-laws/definitions.d.ts.map +0 -1
- package/dist/core/iron-laws/definitions.js +0 -189
- package/dist/core/iron-laws/definitions.js.map +0 -1
- package/dist/core/iron-laws/index.d.ts +0 -6
- package/dist/core/iron-laws/index.d.ts.map +0 -1
- package/dist/core/iron-laws/index.js +0 -22
- package/dist/core/iron-laws/index.js.map +0 -1
- package/dist/presets/relaxed.d.ts +0 -8
- package/dist/presets/relaxed.d.ts.map +0 -1
- package/dist/presets/relaxed.js +0 -24
- package/dist/presets/relaxed.js.map +0 -1
- package/dist/presets/strict.d.ts +0 -8
- package/dist/presets/strict.d.ts.map +0 -1
- package/dist/presets/strict.js +0 -51
- package/dist/presets/strict.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constraint.js","sourceRoot":"","sources":["../../src/types/constraint.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AA2OH;;GAEG;AACH,MAAa,wBAAyB,SAAQ,KAAK;IACjC,MAAM,CAAmB;IAEzC,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,sBAAsB,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AARD,4DAQC;AAED;;GAEG;AACH,MAAa,qBAAsB,SAAQ,wBAAwB;IACjE,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AALD,sDAKC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,cAAc,cAAc,CAAC;AAE7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AAGtB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,cAAc,EACd,WAAW,GACZ,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,WAAW,IAAI,mBAAmB,EAAE,cAAc,IAAI,sBAAsB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -17,7 +17,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
17
17
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
|
|
20
|
+
// 约束类型(三层体系)
|
|
21
|
+
__exportStar(require("./constraint"), exports);
|
|
21
22
|
__exportStar(require("./checkpoint"), exports);
|
|
22
23
|
__exportStar(require("./passes-gate"), exports);
|
|
23
24
|
__exportStar(require("./cso"), exports);
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,aAAa;AACb,+CAA6B;AAE7B,+CAA6B;AAC7B,gDAA8B;AAC9B,wCAAsB"}
|
package/dist/types/iron-law.d.ts
CHANGED
|
@@ -1,113 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 铁律类型定义
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
* @deprecated 请使用 './constraint' 代替
|
|
5
|
+
*
|
|
6
|
+
* 此模块保留用于向后兼容。
|
|
7
|
+
* 新代码应使用三层约束类型:
|
|
8
|
+
* - Constraint
|
|
9
|
+
* - ConstraintLevel ('iron_law' | 'guideline' | 'tip')
|
|
10
|
+
*/
|
|
11
|
+
import type { Constraint } from './constraint';
|
|
12
|
+
export type { ConstraintId as IronLawId, ConstraintLevel, ConstraintTrigger as IronLawTrigger, Constraint as IronLaw, ConstraintResult as IronLawResult, ConstraintContext as IronLawContext, } from './constraint';
|
|
13
|
+
export { ConstraintViolationError as IronLawViolationError, } from './constraint';
|
|
13
14
|
export type IronLawSeverity = 'error' | 'warning' | 'info';
|
|
14
|
-
/**
|
|
15
|
-
* 铁律触发条件
|
|
16
|
-
*/
|
|
17
|
-
export type IronLawTrigger = 'bug_fix_attempt' | 'task_completion_claim' | 'skill_creation' | 'code_implementation' | 'test_creation' | 'workflow_execution' | 'step_execution' | 'step_creation' | 'tool_creation' | 'workflow_creation' | 'module_creation' | 'module_modification' | 'module_deletion' | 'api_change' | 'export_change' | 'file_creation' | 'file_modification' | 'file_deletion' | 'commit' | 'push' | 'merge';
|
|
18
|
-
/**
|
|
19
|
-
* 铁律定义
|
|
20
|
-
*/
|
|
21
|
-
export interface IronLaw {
|
|
22
|
-
/** 铁律 ID */
|
|
23
|
-
id: IronLawId;
|
|
24
|
-
/** 铁律规则(英文) */
|
|
25
|
-
rule: string;
|
|
26
|
-
/** 铁律消息(中文) */
|
|
27
|
-
message: string;
|
|
28
|
-
/** 触发条件 */
|
|
29
|
-
trigger: IronLawTrigger;
|
|
30
|
-
/** 强制执行的技能/步骤 */
|
|
31
|
-
enforcement: string;
|
|
32
|
-
/** 铁律严重级别 */
|
|
33
|
-
severity: IronLawSeverity;
|
|
34
|
-
/** 铁律描述 */
|
|
35
|
-
description?: string;
|
|
36
|
-
/** 是否启用 */
|
|
37
|
-
enabled?: boolean;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 铁律检查结果
|
|
41
|
-
*/
|
|
42
|
-
export interface IronLawResult {
|
|
43
|
-
/** 是否满足铁律 */
|
|
44
|
-
satisfied: boolean;
|
|
45
|
-
/** 铁律定义 */
|
|
46
|
-
law?: IronLaw;
|
|
47
|
-
/** 错误消息 */
|
|
48
|
-
message?: string;
|
|
49
|
-
/** 建议操作 */
|
|
50
|
-
requiredAction?: string;
|
|
51
|
-
/** 检查时间 */
|
|
52
|
-
checkedAt: Date;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* 铁律检查上下文
|
|
56
|
-
*/
|
|
57
|
-
export interface IronLawContext {
|
|
58
|
-
/** 当前操作类型 */
|
|
59
|
-
operation: IronLawTrigger;
|
|
60
|
-
/** 工作流 ID */
|
|
61
|
-
workflowId?: string;
|
|
62
|
-
/** 步骤 ID */
|
|
63
|
-
stepId?: string;
|
|
64
|
-
/** 任务描述 */
|
|
65
|
-
taskDescription?: string;
|
|
66
|
-
/** 项目路径 */
|
|
67
|
-
projectPath?: string;
|
|
68
|
-
/** 变更的文件列表 */
|
|
69
|
-
changedFiles?: string[];
|
|
70
|
-
/** 提交信息 */
|
|
71
|
-
commitMessage?: string;
|
|
72
|
-
/** 分支名称 */
|
|
73
|
-
branch?: string;
|
|
74
|
-
/** 是否有根本原因调查 */
|
|
75
|
-
hasRootCauseInvestigation?: boolean;
|
|
76
|
-
/** 是否有验证证据 */
|
|
77
|
-
hasVerificationEvidence?: boolean;
|
|
78
|
-
/** 是否有测试 */
|
|
79
|
-
hasTest?: boolean;
|
|
80
|
-
/** 是否有失败的测试 */
|
|
81
|
-
hasFailingTest?: boolean;
|
|
82
|
-
/** 是否已进行复用检查 */
|
|
83
|
-
hasReuseCheck?: boolean;
|
|
84
|
-
/** 复用检查结果 */
|
|
85
|
-
reuseCheckResult?: {
|
|
86
|
-
existingCapabilities: string[];
|
|
87
|
-
canReuse: boolean;
|
|
88
|
-
reuseRecommendation: string;
|
|
89
|
-
};
|
|
90
|
-
/** 执行上下文 */
|
|
91
|
-
executionContext?: any;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* 铁律违规错误
|
|
95
|
-
*/
|
|
96
|
-
export declare class IronLawViolationError extends Error {
|
|
97
|
-
readonly result: IronLawResult;
|
|
98
|
-
constructor(result: IronLawResult);
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* 铁律配置
|
|
102
|
-
*/
|
|
103
15
|
export interface IronLawConfig {
|
|
104
|
-
/**
|
|
105
|
-
ironLaws:
|
|
106
|
-
/**
|
|
16
|
+
/** @deprecated */
|
|
17
|
+
ironLaws: Constraint[];
|
|
18
|
+
/** @deprecated */
|
|
107
19
|
preset?: 'strict' | 'standard' | 'relaxed';
|
|
108
|
-
/**
|
|
20
|
+
/** @deprecated */
|
|
109
21
|
enabled?: boolean;
|
|
110
|
-
/**
|
|
22
|
+
/** @deprecated */
|
|
111
23
|
configPath?: string;
|
|
112
24
|
}
|
|
113
25
|
//# sourceMappingURL=iron-law.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iron-law.d.ts","sourceRoot":"","sources":["../../src/types/iron-law.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"iron-law.d.ts","sourceRoot":"","sources":["../../src/types/iron-law.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAIV,UAAU,EAGX,MAAM,cAAc,CAAC;AAKtB,YAAY,EACV,YAAY,IAAI,SAAS,EACzB,eAAe,EACf,iBAAiB,IAAI,cAAc,EACnC,UAAU,IAAI,OAAO,EACrB,gBAAgB,IAAI,aAAa,EACjC,iBAAiB,IAAI,cAAc,GACpC,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,IAAI,qBAAqB,GAClD,MAAM,cAAc,CAAC;AAGtB,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;AAG3D,MAAM,WAAW,aAAa;IAC5B,kBAAkB;IAClB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,kBAAkB;IAClB,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAC3C,kBAAkB;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,kBAAkB;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/types/iron-law.js
CHANGED
|
@@ -2,20 +2,15 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* 铁律类型定义
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* @deprecated 请使用 './constraint' 代替
|
|
6
|
+
*
|
|
7
|
+
* 此模块保留用于向后兼容。
|
|
8
|
+
* 新代码应使用三层约束类型:
|
|
9
|
+
* - Constraint
|
|
10
|
+
* - ConstraintLevel ('iron_law' | 'guideline' | 'tip')
|
|
6
11
|
*/
|
|
7
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
13
|
exports.IronLawViolationError = void 0;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
class IronLawViolationError extends Error {
|
|
13
|
-
result;
|
|
14
|
-
constructor(result) {
|
|
15
|
-
super(result.message || 'Iron law violation');
|
|
16
|
-
this.name = 'IronLawViolationError';
|
|
17
|
-
this.result = result;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.IronLawViolationError = IronLawViolationError;
|
|
14
|
+
var constraint_1 = require("./constraint");
|
|
15
|
+
Object.defineProperty(exports, "IronLawViolationError", { enumerable: true, get: function () { return constraint_1.ConstraintViolationError; } });
|
|
21
16
|
//# sourceMappingURL=iron-law.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iron-law.js","sourceRoot":"","sources":["../../src/types/iron-law.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"iron-law.js","sourceRoot":"","sources":["../../src/types/iron-law.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAuBH,2CAEsB;AADpB,mHAAA,wBAAwB,OAAyB"}
|
package/package.json
CHANGED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 铁律检查引擎
|
|
3
|
-
*
|
|
4
|
-
* 在执行关键操作前,强制检查铁律是否满足
|
|
5
|
-
*/
|
|
6
|
-
import type { IronLaw, IronLawResult, IronLawContext } from '../../types/iron-law';
|
|
7
|
-
/**
|
|
8
|
-
* 铁律检查器
|
|
9
|
-
*/
|
|
10
|
-
export declare class IronLawChecker {
|
|
11
|
-
private static instance;
|
|
12
|
-
private constructor();
|
|
13
|
-
/**
|
|
14
|
-
* 获取单例实例
|
|
15
|
-
*/
|
|
16
|
-
static getInstance(): IronLawChecker;
|
|
17
|
-
/**
|
|
18
|
-
* 检查单个铁律
|
|
19
|
-
*/
|
|
20
|
-
check(lawId: string, context: IronLawContext): Promise<IronLawResult>;
|
|
21
|
-
/**
|
|
22
|
-
* 检查铁律前置条件
|
|
23
|
-
*/
|
|
24
|
-
private checkPrecondition;
|
|
25
|
-
/**
|
|
26
|
-
* 查找适用于当前操作的铁律
|
|
27
|
-
*/
|
|
28
|
-
findApplicableLaws(context: IronLawContext): string[];
|
|
29
|
-
/**
|
|
30
|
-
* 在执行前自动检查所有适用的铁律
|
|
31
|
-
*
|
|
32
|
-
* @throws IronLawViolationError 如果有 error 级别的铁律违规
|
|
33
|
-
*/
|
|
34
|
-
beforeExecution(context: IronLawContext): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* 检查并返回所有铁律状态(用于 UI 显示)
|
|
37
|
-
*/
|
|
38
|
-
checkAll(context: IronLawContext): Promise<IronLawResult[]>;
|
|
39
|
-
/**
|
|
40
|
-
* 获取所有铁律定义
|
|
41
|
-
*/
|
|
42
|
-
getAllLaws(): IronLaw[];
|
|
43
|
-
/**
|
|
44
|
-
* 获取单个铁律定义
|
|
45
|
-
*/
|
|
46
|
-
getLaw(lawId: string): IronLaw | null;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* 快捷函数:检查铁律
|
|
50
|
-
*/
|
|
51
|
-
export declare function checkIronLaw(lawId: string, context: IronLawContext): Promise<IronLawResult>;
|
|
52
|
-
/**
|
|
53
|
-
* 快捷函数:执行前检查
|
|
54
|
-
*/
|
|
55
|
-
export declare function checkBeforeExecution(context: IronLawContext): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* 快捷函数:检查所有铁律
|
|
58
|
-
*/
|
|
59
|
-
export declare function checkAllIronLaws(context: IronLawContext): Promise<IronLawResult[]>;
|
|
60
|
-
export declare const ironLawChecker: IronLawChecker;
|
|
61
|
-
//# sourceMappingURL=checker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checker.d.ts","sourceRoot":"","sources":["../../../src/core/iron-laws/checker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,cAAc,EAEf,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IAExC,OAAO;IAEP;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,cAAc;IAOpC;;OAEG;IACG,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IA+B3E;;OAEG;YACW,iBAAiB;IAwD/B;;OAEG;IACH,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,EAAE;IAYrD;;;;OAIG;IACG,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAY7D;;OAEG;IACG,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAYjE;;OAEG;IACH,UAAU,IAAI,OAAO,EAAE;IAIvB;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;CAGtC;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,aAAa,CAAC,CAExB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAExF;AAGD,eAAO,MAAM,cAAc,gBAA+B,CAAC"}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* 铁律检查引擎
|
|
4
|
-
*
|
|
5
|
-
* 在执行关键操作前,强制检查铁律是否满足
|
|
6
|
-
*/
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.ironLawChecker = exports.IronLawChecker = void 0;
|
|
9
|
-
exports.checkIronLaw = checkIronLaw;
|
|
10
|
-
exports.checkBeforeExecution = checkBeforeExecution;
|
|
11
|
-
exports.checkAllIronLaws = checkAllIronLaws;
|
|
12
|
-
const definitions_1 = require("./definitions");
|
|
13
|
-
/**
|
|
14
|
-
* 铁律检查器
|
|
15
|
-
*/
|
|
16
|
-
class IronLawChecker {
|
|
17
|
-
static instance;
|
|
18
|
-
constructor() { }
|
|
19
|
-
/**
|
|
20
|
-
* 获取单例实例
|
|
21
|
-
*/
|
|
22
|
-
static getInstance() {
|
|
23
|
-
if (!IronLawChecker.instance) {
|
|
24
|
-
IronLawChecker.instance = new IronLawChecker();
|
|
25
|
-
}
|
|
26
|
-
return IronLawChecker.instance;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* 检查单个铁律
|
|
30
|
-
*/
|
|
31
|
-
async check(lawId, context) {
|
|
32
|
-
const law = definitions_1.IRON_LAWS[lawId];
|
|
33
|
-
if (!law) {
|
|
34
|
-
return {
|
|
35
|
-
satisfied: false,
|
|
36
|
-
message: `未知的铁律: ${lawId}`,
|
|
37
|
-
checkedAt: new Date(),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// 检查是否满足铁律前置条件
|
|
41
|
-
const satisfied = await this.checkPrecondition(law, context);
|
|
42
|
-
if (!satisfied) {
|
|
43
|
-
return {
|
|
44
|
-
satisfied: false,
|
|
45
|
-
law,
|
|
46
|
-
message: law.message,
|
|
47
|
-
requiredAction: law.enforcement,
|
|
48
|
-
checkedAt: new Date(),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
satisfied: true,
|
|
53
|
-
law,
|
|
54
|
-
checkedAt: new Date(),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 检查铁律前置条件
|
|
59
|
-
*/
|
|
60
|
-
async checkPrecondition(law, context) {
|
|
61
|
-
switch (law.id) {
|
|
62
|
-
case 'no_fix_without_root_cause':
|
|
63
|
-
// 检查是否有根本原因调查
|
|
64
|
-
return context.hasRootCauseInvestigation === true;
|
|
65
|
-
case 'no_completion_without_verification':
|
|
66
|
-
// 检查是否有验证证据
|
|
67
|
-
return context.hasVerificationEvidence === true;
|
|
68
|
-
case 'no_skill_without_test':
|
|
69
|
-
// 检查是否有压力场景测试
|
|
70
|
-
return context.hasTest === true;
|
|
71
|
-
case 'no_code_without_test':
|
|
72
|
-
// 检查是否有失败的测试
|
|
73
|
-
return context.hasFailingTest === true;
|
|
74
|
-
case 'no_creation_without_reuse_check':
|
|
75
|
-
// 检查是否已进行复用检查
|
|
76
|
-
return context.hasReuseCheck === true;
|
|
77
|
-
case 'no_self_approval':
|
|
78
|
-
// 检查是否有测试证据
|
|
79
|
-
return context.hasTest === true;
|
|
80
|
-
case 'test_coverage_required':
|
|
81
|
-
// TODO: 检查测试覆盖率
|
|
82
|
-
return true;
|
|
83
|
-
case 'capability_sync':
|
|
84
|
-
// TODO: 检查 CAPABILITIES.md 是否更新
|
|
85
|
-
return true;
|
|
86
|
-
case 'no_any_type':
|
|
87
|
-
// TODO: 检查代码中是否有 any 类型
|
|
88
|
-
return true;
|
|
89
|
-
case 'no_bypass_checkpoint':
|
|
90
|
-
// TODO: 检查是否跳过了检查点
|
|
91
|
-
return true;
|
|
92
|
-
case 'doc_required_for_public_api':
|
|
93
|
-
// TODO: 检查公共 API 是否有文档
|
|
94
|
-
return true;
|
|
95
|
-
case 'readme_required':
|
|
96
|
-
// TODO: 检查是否有 README
|
|
97
|
-
return true;
|
|
98
|
-
default:
|
|
99
|
-
// 未知铁律,默认通过
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* 查找适用于当前操作的铁律
|
|
105
|
-
*/
|
|
106
|
-
findApplicableLaws(context) {
|
|
107
|
-
const applicableLaws = [];
|
|
108
|
-
for (const [lawId, law] of Object.entries(definitions_1.IRON_LAWS)) {
|
|
109
|
-
if (law.trigger === context.operation) {
|
|
110
|
-
applicableLaws.push(lawId);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return applicableLaws;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* 在执行前自动检查所有适用的铁律
|
|
117
|
-
*
|
|
118
|
-
* @throws IronLawViolationError 如果有 error 级别的铁律违规
|
|
119
|
-
*/
|
|
120
|
-
async beforeExecution(context) {
|
|
121
|
-
const applicableLaws = this.findApplicableLaws(context);
|
|
122
|
-
for (const lawId of applicableLaws) {
|
|
123
|
-
const result = await this.check(lawId, context);
|
|
124
|
-
if (!result.satisfied && result.law?.severity === 'error') {
|
|
125
|
-
throw new definitions_1.IronLawViolationError(result);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* 检查并返回所有铁律状态(用于 UI 显示)
|
|
131
|
-
*/
|
|
132
|
-
async checkAll(context) {
|
|
133
|
-
const applicableLaws = this.findApplicableLaws(context);
|
|
134
|
-
const results = [];
|
|
135
|
-
for (const lawId of applicableLaws) {
|
|
136
|
-
const result = await this.check(lawId, context);
|
|
137
|
-
results.push(result);
|
|
138
|
-
}
|
|
139
|
-
return results;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* 获取所有铁律定义
|
|
143
|
-
*/
|
|
144
|
-
getAllLaws() {
|
|
145
|
-
return Object.values(definitions_1.IRON_LAWS);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* 获取单个铁律定义
|
|
149
|
-
*/
|
|
150
|
-
getLaw(lawId) {
|
|
151
|
-
return definitions_1.IRON_LAWS[lawId] || null;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.IronLawChecker = IronLawChecker;
|
|
155
|
-
/**
|
|
156
|
-
* 快捷函数:检查铁律
|
|
157
|
-
*/
|
|
158
|
-
async function checkIronLaw(lawId, context) {
|
|
159
|
-
return IronLawChecker.getInstance().check(lawId, context);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* 快捷函数:执行前检查
|
|
163
|
-
*/
|
|
164
|
-
async function checkBeforeExecution(context) {
|
|
165
|
-
return IronLawChecker.getInstance().beforeExecution(context);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* 快捷函数:检查所有铁律
|
|
169
|
-
*/
|
|
170
|
-
async function checkAllIronLaws(context) {
|
|
171
|
-
return IronLawChecker.getInstance().checkAll(context);
|
|
172
|
-
}
|
|
173
|
-
// 导出单例
|
|
174
|
-
exports.ironLawChecker = IronLawChecker.getInstance();
|
|
175
|
-
//# sourceMappingURL=checker.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checker.js","sourceRoot":"","sources":["../../../src/core/iron-laws/checker.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA0LH,oCAKC;AAKD,oDAEC;AAKD,4CAEC;AArMD,+CAAoF;AAEpF;;GAEG;AACH,MAAa,cAAc;IACjB,MAAM,CAAC,QAAQ,CAAiB;IAExC,gBAAuB,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC;YAC7B,cAAc,CAAC,QAAQ,GAAG,IAAI,cAAc,EAAE,CAAC;QACjD,CAAC;QACD,OAAO,cAAc,CAAC,QAAQ,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,OAAuB;QAChD,MAAM,GAAG,GAAG,uBAAS,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;gBACL,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,UAAU,KAAK,EAAE;gBAC1B,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;QACJ,CAAC;QAED,eAAe;QACf,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAE7D,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;gBACL,SAAS,EAAE,KAAK;gBAChB,GAAG;gBACH,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,cAAc,EAAE,GAAG,CAAC,WAAW;gBAC/B,SAAS,EAAE,IA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H,MAAM,CAAC,KAAa;QAClB,OAAO,uBAAS,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IAClC,CAAC;CACF;AAxKD,wCAwKC;AAED;;GAEG;AACI,KAAK,UAAU,YAAY,CAChC,KAAa,EACb,OAAuB;IAEvB,OAAO,cAAc,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,oBAAoB,CAAC,OAAuB;IAChE,OAAO,cAAc,CAAC,WAAW,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,gBAAgB,CAAC,OAAuB;IAC5D,OAAO,cAAc,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,OAAO;AACM,QAAA,cAAc,GAAG,cAAc,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 铁律定义
|
|
3
|
-
*
|
|
4
|
-
* 所有内置的铁律规则
|
|
5
|
-
*/
|
|
6
|
-
import type { IronLaw, IronLawTrigger } from '../../types/iron-law';
|
|
7
|
-
export { IronLawViolationError } from '../../types/iron-law';
|
|
8
|
-
/**
|
|
9
|
-
* 所有铁律定义
|
|
10
|
-
*/
|
|
11
|
-
export declare const IRON_LAWS: Record<string, IronLaw>;
|
|
12
|
-
/**
|
|
13
|
-
* 根据触发条件查找适用的铁律
|
|
14
|
-
*/
|
|
15
|
-
export declare function findLawsByTrigger(trigger: IronLawTrigger): IronLaw[];
|
|
16
|
-
/**
|
|
17
|
-
* 获取所有铁律
|
|
18
|
-
*/
|
|
19
|
-
export declare function getAllLaws(): IronLaw[];
|
|
20
|
-
/**
|
|
21
|
-
* 获取单个铁律
|
|
22
|
-
*/
|
|
23
|
-
export declare function getLaw(id: string): IronLaw | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* 根据严重性过滤铁律
|
|
26
|
-
*/
|
|
27
|
-
export declare function filterLawsBySeverity(severity: 'error' | 'warning' | 'info'): IronLaw[];
|
|
28
|
-
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../src/core/iron-laws/definitions.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAuD,MAAM,sBAAsB,CAAC;AAGzH,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAoK7C,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,EAAE,CAEpE;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,OAAO,EAAE,CAEtC;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEtD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,EAAE,CAEtF"}
|