@dommaker/harness 1.1.1 → 1.2.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/CHANGELOG.md +10 -0
- package/README.md +2 -4
- package/bin/harness.js +12 -37
- package/dist/cli/commands/check.d.ts +2 -2
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +7 -32
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/definitions.d.ts +2 -0
- package/dist/cli/commands/definitions.d.ts.map +1 -1
- package/dist/cli/commands/definitions.js.map +1 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +6 -37
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/knowledge.d.ts.map +1 -1
- package/dist/cli/commands/knowledge.js +1 -12
- package/dist/cli/commands/knowledge.js.map +1 -1
- package/dist/cli/commands/report.d.ts.map +1 -1
- package/dist/cli/commands/report.js +0 -2
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/status.js +2 -2
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/context/index.d.ts +9 -6
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +18 -20
- package/dist/context/index.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +3 -2
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +25 -47
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +29 -32
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +34 -126
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +2 -1
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +3 -0
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/types.d.ts +25 -0
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +24 -0
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +0 -2
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/prompts.d.ts.map +1 -1
- package/dist/core/constraints/definitions/prompts.js +0 -5
- package/dist/core/constraints/definitions/prompts.js.map +1 -1
- package/dist/core/constraints/index.d.ts +1 -2
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +1 -7
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +1 -2
- package/dist/core/constraints/usage-report.d.ts.map +1 -1
- package/dist/core/constraints/usage-report.js +2 -5
- package/dist/core/constraints/usage-report.js.map +1 -1
- package/dist/core/effective-constraints.d.ts +24 -4
- package/dist/core/effective-constraints.d.ts.map +1 -1
- package/dist/core/effective-constraints.js +28 -7
- package/dist/core/effective-constraints.js.map +1 -1
- package/dist/core/effective-set.d.ts +30 -0
- package/dist/core/effective-set.d.ts.map +1 -0
- package/dist/core/effective-set.js +35 -0
- package/dist/core/effective-set.js.map +1 -0
- package/dist/core/index.d.ts +13 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +44 -21
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +3 -6
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +47 -61
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/failure/constraint-handler.d.ts +1 -1
- package/dist/failure/constraint-handler.js +1 -1
- package/dist/gates/checker-gate.d.ts +1 -4
- package/dist/gates/checker-gate.d.ts.map +1 -1
- package/dist/gates/checker-gate.js +3 -11
- package/dist/gates/checker-gate.js.map +1 -1
- package/dist/gates/definitions.d.ts +9 -38
- package/dist/gates/definitions.d.ts.map +1 -1
- package/dist/gates/definitions.js +24 -13
- package/dist/gates/definitions.js.map +1 -1
- package/dist/gates/effective-gates.d.ts.map +1 -1
- package/dist/gates/effective-gates.js +14 -18
- package/dist/gates/effective-gates.js.map +1 -1
- package/dist/gates/index.d.ts +1 -1
- package/dist/gates/index.d.ts.map +1 -1
- package/dist/gates/index.js.map +1 -1
- package/dist/hooks/bootstrap.d.ts.map +1 -1
- package/dist/hooks/bootstrap.js +0 -3
- package/dist/hooks/bootstrap.js.map +1 -1
- package/dist/index.d.ts +43 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +180 -143
- package/dist/index.js.map +1 -1
- package/dist/knowledge/query.d.ts +15 -0
- package/dist/knowledge/query.d.ts.map +1 -1
- package/dist/knowledge/query.js +23 -0
- package/dist/knowledge/query.js.map +1 -1
- package/dist/monitoring/analyzer-base.d.ts +0 -4
- package/dist/monitoring/analyzer-base.d.ts.map +1 -1
- package/dist/monitoring/analyzer-base.js +0 -21
- package/dist/monitoring/analyzer-base.js.map +1 -1
- package/dist/monitoring/index.d.ts +6 -12
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +13 -29
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +2 -68
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +0 -4
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +0 -14
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/presets/index.d.ts +2 -2
- package/dist/presets/index.d.ts.map +1 -1
- package/dist/presets/index.js +3 -4
- package/dist/presets/index.js.map +1 -1
- package/dist/presets/standard.d.ts +10 -22
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +15 -75
- package/dist/presets/standard.js.map +1 -1
- package/dist/types/constraint.d.ts +1 -29
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +1 -1
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -4
- package/dist/types/index.js.map +1 -1
- package/dist/types/project-config.d.ts +4 -8
- package/dist/types/project-config.d.ts.map +1 -1
- package/dist/types/trace.d.ts +5 -18
- package/dist/types/trace.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/CONTEXT.md +4 -5
- package/src/__tests__/checker-extra.test.ts +33 -139
- package/src/__tests__/checker.test.ts +0 -376
- package/src/__tests__/project-config-loader-extra.test.ts +42 -29
- package/src/__tests__/public-exports.test.ts +138 -0
- package/src/__tests__/trace-analyzer-extra.test.ts +6 -86
- package/src/__tests__/trace-analyzer.test.ts +4 -5
- package/src/__tests__/trace-collector.test.ts +0 -11
- package/src/__tests__/traces.test.ts +3 -22
- package/src/cli/commands/CONTEXT.md +2 -2
- package/src/cli/commands/__tests__/check-skip-output.test.ts +10 -7
- package/src/cli/commands/__tests__/check.test.ts +29 -69
- package/src/cli/commands/__tests__/constraints-report.test.ts +1 -1
- package/src/cli/commands/__tests__/knowledge.test.ts +90 -1
- package/src/cli/commands/__tests__/registry.test.ts +8 -6
- package/src/cli/commands/__tests__/status-extra.test.ts +6 -6
- package/src/cli/commands/__tests__/status.test.ts +6 -6
- package/src/cli/commands/check.ts +8 -34
- package/src/cli/commands/definitions.ts +2 -0
- package/src/cli/commands/init.ts +6 -37
- package/src/cli/commands/knowledge.ts +1 -16
- package/src/cli/commands/report.ts +0 -2
- package/src/cli/commands/status.ts +2 -2
- package/src/context/index.ts +29 -6
- package/src/core/CONTEXT.md +4 -3
- package/src/core/__tests__/effective-set.test.ts +80 -0
- package/src/core/constraints/capabilities-parser.ts +43 -49
- package/src/core/constraints/checker.ts +51 -145
- package/src/core/constraints/checkers/index.ts +2 -1
- package/src/core/constraints/checkers/types.ts +42 -0
- package/src/core/constraints/definitions/guidelines.ts +0 -2
- package/src/core/constraints/definitions/prompts.ts +0 -5
- package/src/core/constraints/index.ts +2 -17
- package/src/core/constraints/usage-report.ts +5 -8
- package/src/core/effective-constraints.ts +35 -7
- package/src/core/effective-set.ts +56 -0
- package/src/core/index.ts +80 -6
- package/src/core/project-config-loader.ts +53 -68
- package/src/failure/CONTEXT.md +1 -1
- package/src/failure/constraint-handler.ts +1 -1
- package/src/gates/CONTEXT.md +3 -3
- package/src/gates/checker-gate.ts +4 -12
- package/src/gates/definitions.ts +27 -50
- package/src/gates/effective-gates.ts +14 -21
- package/src/gates/index.ts +1 -1
- package/src/hooks/bootstrap.ts +0 -3
- package/src/index.ts +384 -148
- package/src/knowledge/CONTEXT.md +2 -2
- package/src/knowledge/__tests__/query.test.ts +64 -0
- package/src/knowledge/query.ts +28 -0
- package/src/monitoring/CONTEXT.md +7 -13
- package/src/monitoring/__tests__/traces.test.ts +0 -10
- package/src/monitoring/analyzer-base.ts +0 -22
- package/src/monitoring/index.ts +6 -12
- package/src/monitoring/trace-analyzer.ts +2 -73
- package/src/monitoring/traces.ts +0 -20
- package/src/presets/__tests__/standard.test.ts +48 -69
- package/src/presets/index.ts +3 -5
- package/src/presets/standard.ts +14 -79
- package/src/spec/CONTEXT.md +5 -13
- package/src/types/constraint.ts +1 -51
- package/src/types/index.ts +0 -12
- package/src/types/project-config.ts +4 -10
- package/src/types/trace.ts +5 -30
- package/dist/core/constraints/interceptor.d.ts +0 -39
- package/dist/core/constraints/interceptor.d.ts.map +0 -1
- package/dist/core/constraints/interceptor.js +0 -166
- package/dist/core/constraints/interceptor.js.map +0 -1
- package/dist/dashboard/data.d.ts +0 -31
- package/dist/dashboard/data.d.ts.map +0 -1
- package/dist/dashboard/data.js +0 -81
- package/dist/dashboard/data.js.map +0 -1
- package/dist/dashboard/index.d.ts +0 -4
- package/dist/dashboard/index.d.ts.map +0 -1
- package/dist/dashboard/index.js +0 -20
- package/dist/dashboard/index.js.map +0 -1
- package/dist/dashboard/stats.d.ts +0 -20
- package/dist/dashboard/stats.d.ts.map +0 -1
- package/dist/dashboard/stats.js +0 -115
- package/dist/dashboard/stats.js.map +0 -1
- package/dist/dashboard/types.d.ts +0 -110
- package/dist/dashboard/types.d.ts.map +0 -1
- package/dist/dashboard/types.js +0 -8
- package/dist/dashboard/types.js.map +0 -1
- package/dist/monitoring/constraint-doctor.d.ts +0 -76
- package/dist/monitoring/constraint-doctor.d.ts.map +0 -1
- package/dist/monitoring/constraint-doctor.js +0 -189
- package/dist/monitoring/constraint-doctor.js.map +0 -1
- package/dist/monitoring/diagnosis-rules.d.ts +0 -18
- package/dist/monitoring/diagnosis-rules.d.ts.map +0 -1
- package/dist/monitoring/diagnosis-rules.js +0 -119
- package/dist/monitoring/diagnosis-rules.js.map +0 -1
- package/dist/monitoring/knowledge-doctor.d.ts +0 -78
- package/dist/monitoring/knowledge-doctor.d.ts.map +0 -1
- package/dist/monitoring/knowledge-doctor.js +0 -266
- package/dist/monitoring/knowledge-doctor.js.map +0 -1
- package/dist/monitoring/knowledge-evolver.d.ts +0 -72
- package/dist/monitoring/knowledge-evolver.d.ts.map +0 -1
- package/dist/monitoring/knowledge-evolver.js +0 -205
- package/dist/monitoring/knowledge-evolver.js.map +0 -1
- package/dist/monitoring/performance-analyzer.d.ts +0 -92
- package/dist/monitoring/performance-analyzer.d.ts.map +0 -1
- package/dist/monitoring/performance-analyzer.js +0 -343
- package/dist/monitoring/performance-analyzer.js.map +0 -1
- package/dist/monitoring/performance-collector.d.ts +0 -103
- package/dist/monitoring/performance-collector.d.ts.map +0 -1
- package/dist/monitoring/performance-collector.js +0 -298
- package/dist/monitoring/performance-collector.js.map +0 -1
- package/dist/safety/index.d.ts +0 -6
- package/dist/safety/index.d.ts.map +0 -1
- package/dist/safety/index.js +0 -22
- package/dist/safety/index.js.map +0 -1
- package/dist/safety/input-guardrail.d.ts +0 -36
- package/dist/safety/input-guardrail.d.ts.map +0 -1
- package/dist/safety/input-guardrail.js +0 -118
- package/dist/safety/input-guardrail.js.map +0 -1
- package/dist/safety/output-guardrail.d.ts +0 -39
- package/dist/safety/output-guardrail.d.ts.map +0 -1
- package/dist/safety/output-guardrail.js +0 -147
- package/dist/safety/output-guardrail.js.map +0 -1
- package/dist/safety/sandbox.d.ts +0 -45
- package/dist/safety/sandbox.d.ts.map +0 -1
- package/dist/safety/sandbox.js +0 -134
- package/dist/safety/sandbox.js.map +0 -1
- package/dist/safety/tool-guardrail.d.ts +0 -51
- package/dist/safety/tool-guardrail.d.ts.map +0 -1
- package/dist/safety/tool-guardrail.js +0 -147
- package/dist/safety/tool-guardrail.js.map +0 -1
- package/dist/safety/types.d.ts +0 -104
- package/dist/safety/types.d.ts.map +0 -1
- package/dist/safety/types.js +0 -6
- package/dist/safety/types.js.map +0 -1
- package/dist/spec/annotation-checker.d.ts +0 -47
- package/dist/spec/annotation-checker.d.ts.map +0 -1
- package/dist/spec/annotation-checker.js +0 -279
- package/dist/spec/annotation-checker.js.map +0 -1
- package/dist/types/enforcement.d.ts +0 -42
- package/dist/types/enforcement.d.ts.map +0 -1
- package/dist/types/enforcement.js +0 -6
- package/dist/types/enforcement.js.map +0 -1
- package/dist/types/monitoring-types.d.ts +0 -53
- package/dist/types/monitoring-types.d.ts.map +0 -1
- package/dist/types/monitoring-types.js +0 -10
- package/dist/types/monitoring-types.js.map +0 -1
- package/dist/types/performance.d.ts +0 -204
- package/dist/types/performance.d.ts.map +0 -1
- package/dist/types/performance.js +0 -12
- package/dist/types/performance.js.map +0 -1
- package/dist/verification/index.d.ts +0 -4
- package/dist/verification/index.d.ts.map +0 -1
- package/dist/verification/index.js +0 -20
- package/dist/verification/index.js.map +0 -1
- package/dist/verification/loop.d.ts +0 -30
- package/dist/verification/loop.d.ts.map +0 -1
- package/dist/verification/loop.js +0 -114
- package/dist/verification/loop.js.map +0 -1
- package/dist/verification/rules-based.d.ts +0 -40
- package/dist/verification/rules-based.d.ts.map +0 -1
- package/dist/verification/rules-based.js +0 -130
- package/dist/verification/rules-based.js.map +0 -1
- package/dist/verification/types.d.ts +0 -69
- package/dist/verification/types.d.ts.map +0 -1
- package/dist/verification/types.js +0 -6
- package/dist/verification/types.js.map +0 -1
- package/src/__tests__/annotation-checker.test.ts +0 -183
- package/src/__tests__/constraint-doctor.test.ts +0 -271
- package/src/__tests__/doctor-extra.test.ts +0 -155
- package/src/__tests__/extend-exceptions.test.ts +0 -149
- package/src/__tests__/interceptor.test.ts +0 -89
- package/src/__tests__/performance-analyzer.test.ts +0 -499
- package/src/__tests__/performance-collector.test.ts +0 -276
- package/src/__tests__/presets.test.ts +0 -65
- package/src/core/constraints/__tests__/interceptor.test.ts +0 -267
- package/src/core/constraints/interceptor.ts +0 -217
- package/src/dashboard/CONTEXT.md +0 -21
- package/src/dashboard/__tests__/data.test.ts +0 -111
- package/src/dashboard/__tests__/stats.test.ts +0 -159
- package/src/dashboard/data.ts +0 -103
- package/src/dashboard/index.ts +0 -3
- package/src/dashboard/stats.ts +0 -127
- package/src/dashboard/types.ts +0 -130
- package/src/monitoring/__tests__/knowledge-doctor.test.ts +0 -278
- package/src/monitoring/__tests__/knowledge-evolver.test.ts +0 -368
- package/src/monitoring/__tests__/performance-analyzer.test.ts +0 -137
- package/src/monitoring/__tests__/performance-collector.test.ts +0 -331
- package/src/monitoring/constraint-doctor.ts +0 -228
- package/src/monitoring/diagnosis-rules.ts +0 -132
- package/src/monitoring/knowledge-doctor.ts +0 -322
- package/src/monitoring/knowledge-evolver.ts +0 -289
- package/src/monitoring/performance-analyzer.ts +0 -400
- package/src/monitoring/performance-collector.ts +0 -326
- package/src/safety/CONTEXT.md +0 -23
- package/src/safety/__tests__/input-guardrail.test.ts +0 -105
- package/src/safety/__tests__/output-guardrail.test.ts +0 -108
- package/src/safety/__tests__/sandbox.test.ts +0 -158
- package/src/safety/__tests__/tool-guardrail.test.ts +0 -127
- package/src/safety/index.ts +0 -5
- package/src/safety/input-guardrail.ts +0 -133
- package/src/safety/output-guardrail.ts +0 -170
- package/src/safety/sandbox.ts +0 -148
- package/src/safety/tool-guardrail.ts +0 -176
- package/src/safety/types.ts +0 -124
- package/src/spec/__tests__/annotation-checker.test.ts +0 -294
- package/src/spec/annotation-checker.ts +0 -320
- package/src/types/enforcement.ts +0 -48
- package/src/types/monitoring-types.ts +0 -68
- package/src/types/performance.ts +0 -295
- package/src/verification/CONTEXT.md +0 -23
- package/src/verification/__tests__/loop.test.ts +0 -303
- package/src/verification/__tests__/rules-based.test.ts +0 -240
- package/src/verification/index.ts +0 -3
- package/src/verification/loop.ts +0 -137
- package/src/verification/rules-based.ts +0 -152
- package/src/verification/types.ts +0 -81
package/src/core/index.ts
CHANGED
|
@@ -1,13 +1,78 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 核心模块导出(ADR-0003:显式清单,禁 export *)
|
|
3
|
+
*
|
|
4
|
+
* checkConstraints 与包根统一为 options 对象签名(CheckConstraintsOptions),
|
|
5
|
+
* 不再暴露位置参数版。
|
|
3
6
|
*/
|
|
4
7
|
|
|
5
8
|
// 约束系统(三层:Iron Laws / Guidelines / Tips)
|
|
9
|
+
export {
|
|
10
|
+
IRON_LAWS,
|
|
11
|
+
GUIDELINES,
|
|
12
|
+
PROMPTS,
|
|
13
|
+
getAllConstraints,
|
|
14
|
+
findConstraintsByTrigger,
|
|
15
|
+
getConstraint,
|
|
16
|
+
ConstraintChecker,
|
|
17
|
+
checkConstraint,
|
|
18
|
+
checkConstraints,
|
|
19
|
+
checkBeforeExecution,
|
|
20
|
+
constraintChecker,
|
|
21
|
+
CONSTRAINTS_START_MARKER,
|
|
22
|
+
CONSTRAINTS_END_MARKER,
|
|
23
|
+
renderConstraintsSection,
|
|
24
|
+
CheckCache,
|
|
25
|
+
renderConstraintsByTrigger,
|
|
26
|
+
ConstraintViolationError,
|
|
27
|
+
} from './constraints';
|
|
28
|
+
export type {
|
|
29
|
+
CheckConstraintsOptions,
|
|
30
|
+
CheckCacheConfig,
|
|
31
|
+
CheckSamplingConfig,
|
|
32
|
+
RenderConstraintsByTriggerOptions,
|
|
33
|
+
ConstraintId,
|
|
34
|
+
ConstraintKind,
|
|
35
|
+
ConstraintLevel,
|
|
36
|
+
ConstraintTrigger,
|
|
37
|
+
Constraint,
|
|
38
|
+
ConstraintResult,
|
|
39
|
+
ConstraintContext,
|
|
40
|
+
ConstraintCheckResult,
|
|
41
|
+
IronLawContext,
|
|
42
|
+
} from './constraints';
|
|
6
43
|
|
|
7
|
-
|
|
44
|
+
// 验证器(检查点 / PassesGate / CSO)
|
|
45
|
+
export {
|
|
46
|
+
CheckpointValidator,
|
|
47
|
+
PassesGate,
|
|
48
|
+
createPassesGate,
|
|
49
|
+
CSOValidator,
|
|
50
|
+
} from './validators';
|
|
51
|
+
export type {
|
|
52
|
+
CSOValidationResult,
|
|
53
|
+
CSOIssue,
|
|
54
|
+
Checkpoint,
|
|
55
|
+
CheckpointCheck,
|
|
56
|
+
CheckpointResult,
|
|
57
|
+
CheckResult,
|
|
58
|
+
CheckpointContext,
|
|
59
|
+
CheckType,
|
|
60
|
+
CheckConfig,
|
|
61
|
+
PassesGateConfig,
|
|
62
|
+
PassesGateResult,
|
|
63
|
+
TaskTestResult,
|
|
64
|
+
DynamicTask,
|
|
65
|
+
} from './validators';
|
|
8
66
|
|
|
9
|
-
|
|
10
|
-
export
|
|
67
|
+
// 会话启动 / 净室状态
|
|
68
|
+
export {
|
|
69
|
+
SessionStartup,
|
|
70
|
+
createSessionStartup,
|
|
71
|
+
DEFAULT_CODE_CHECKPOINTS,
|
|
72
|
+
MINIMAL_CHECKPOINTS,
|
|
73
|
+
CleanStateManager,
|
|
74
|
+
createCleanStateManager,
|
|
75
|
+
} from './session';
|
|
11
76
|
|
|
12
77
|
// Spec 验证器
|
|
13
78
|
export { SpecValidator } from './spec/validator';
|
|
@@ -20,7 +85,16 @@ export type {
|
|
|
20
85
|
} from '../types/spec';
|
|
21
86
|
|
|
22
87
|
// 项目配置加载器
|
|
23
|
-
export
|
|
88
|
+
export {
|
|
89
|
+
ProjectConfigLoader,
|
|
90
|
+
loadRawProjectConfig,
|
|
91
|
+
getCapabilitiesMode,
|
|
92
|
+
} from './project-config-loader';
|
|
93
|
+
export type { CapabilitiesMode } from './project-config-loader';
|
|
24
94
|
|
|
25
95
|
// 生效约束集(ADR-0001:唯一生效集来源)
|
|
26
|
-
export
|
|
96
|
+
export {
|
|
97
|
+
getEffectiveConstraints,
|
|
98
|
+
lintEffectiveConfig,
|
|
99
|
+
} from './effective-constraints';
|
|
100
|
+
export type { EffectiveConfigLint } from './effective-constraints';
|
|
@@ -16,7 +16,8 @@ import type {
|
|
|
16
16
|
CapabilitiesConfig,
|
|
17
17
|
} from '../types/project-config';
|
|
18
18
|
import { IRON_LAWS, GUIDELINES, PROMPTS } from './constraints/definitions';
|
|
19
|
-
import {
|
|
19
|
+
import { PRESETS_BY_NAME, STANDARD_PRESET } from '../presets';
|
|
20
|
+
import { filterEnabledEntries } from './effective-set';
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* 默认配置
|
|
@@ -156,47 +157,72 @@ export class ProjectConfigLoader {
|
|
|
156
157
|
* 合并内置约束和自定义约束(ADR-0001 生效集完整链路)
|
|
157
158
|
*
|
|
158
159
|
* 合并顺序:内置 → preset 裁剪 → config.yml `constraints.<id>.enabled:false`
|
|
159
|
-
* 删除(对内置与 custom 同效)→ custom-constraints
|
|
160
|
+
* 删除(对内置与 custom 同效)→ custom-constraints 追加
|
|
160
161
|
* (禁用/已退役的 custom 不追加)→ scenes 过滤
|
|
161
162
|
* (带 appliesTo 的 prompt 仅当 scenes 交集非空时保留)。
|
|
162
163
|
*
|
|
163
164
|
* config.yml 中未知约束 id(如已移除约束的禁用残留)静默忽略,
|
|
164
165
|
* 记录在结果 unknownIds 中供诊断。
|
|
165
166
|
*
|
|
166
|
-
* @param options.preset 覆盖 config.yml 的 preset(CLI --preset
|
|
167
|
+
* @param options.preset 覆盖 config.yml 的 preset(CLI --preset 用);
|
|
168
|
+
* 未知预设名回落 standard + stderr 警告
|
|
167
169
|
*/
|
|
168
170
|
mergeConstraints(options?: { preset?: string }): MergedConstraintsConfig {
|
|
169
|
-
// 0. preset
|
|
170
|
-
const
|
|
171
|
+
// 0. preset 裁剪(strict 是 standard 的别名;未知名回落 standard)
|
|
172
|
+
const presetName = options?.preset ?? this.config.preset ?? 'standard';
|
|
173
|
+
let preset = PRESETS_BY_NAME[presetName];
|
|
174
|
+
if (!preset) {
|
|
175
|
+
console.error(`[harness] 未知预设 "${presetName}",已回落 standard`);
|
|
176
|
+
preset = STANDARD_PRESET;
|
|
177
|
+
}
|
|
178
|
+
const pick = (
|
|
179
|
+
source: Record<string, Constraint>,
|
|
180
|
+
ids: string[] | null
|
|
181
|
+
): Record<string, Constraint> => {
|
|
182
|
+
if (ids === null) return { ...source };
|
|
183
|
+
const filtered: Record<string, Constraint> = {};
|
|
184
|
+
for (const id of ids) {
|
|
185
|
+
if (source[id]) filtered[id] = source[id];
|
|
186
|
+
}
|
|
187
|
+
return filtered;
|
|
188
|
+
};
|
|
189
|
+
const presetDisabled = (
|
|
190
|
+
source: Record<string, Constraint>,
|
|
191
|
+
ids: string[] | null
|
|
192
|
+
): string[] => (ids === null ? [] : Object.keys(source).filter(id => !ids.includes(id)));
|
|
193
|
+
|
|
171
194
|
const unknownIds: string[] = [];
|
|
172
195
|
const result: MergedConstraintsConfig = {
|
|
173
|
-
ironLaws:
|
|
174
|
-
guidelines:
|
|
175
|
-
prompts:
|
|
176
|
-
disabled: [
|
|
196
|
+
ironLaws: pick(IRON_LAWS, preset.ironLaws),
|
|
197
|
+
guidelines: pick(GUIDELINES, preset.guidelines),
|
|
198
|
+
prompts: pick(PROMPTS, preset.prompts),
|
|
199
|
+
disabled: [
|
|
200
|
+
...presetDisabled(IRON_LAWS, preset.ironLaws),
|
|
201
|
+
...presetDisabled(GUIDELINES, preset.guidelines),
|
|
202
|
+
...presetDisabled(PROMPTS, preset.prompts),
|
|
203
|
+
],
|
|
177
204
|
custom: [],
|
|
178
205
|
unknownIds,
|
|
179
206
|
};
|
|
180
207
|
|
|
181
|
-
// 1.
|
|
208
|
+
// 1. 处理启用/禁用配置(未知 id 静默忽略,记录供诊断)
|
|
182
209
|
if (this.config.constraints) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
210
|
+
const knownIds = new Set([
|
|
211
|
+
...Object.keys(IRON_LAWS),
|
|
212
|
+
...Object.keys(GUIDELINES),
|
|
213
|
+
...Object.keys(PROMPTS),
|
|
214
|
+
...Object.keys(this.customConstraints),
|
|
215
|
+
]);
|
|
216
|
+
const filtered = filterEnabledEntries(knownIds, this.config.constraints, {
|
|
217
|
+
onUnknownId: 'collect',
|
|
218
|
+
});
|
|
219
|
+
unknownIds.push(...filtered.unknownIds);
|
|
220
|
+
for (const constraintId of filtered.disabledIds) {
|
|
221
|
+
result.disabled.push(constraintId);
|
|
222
|
+
// 从对应层级中移除
|
|
223
|
+
delete result.ironLaws[constraintId];
|
|
224
|
+
delete result.guidelines[constraintId];
|
|
225
|
+
delete result.prompts![constraintId];
|
|
200
226
|
}
|
|
201
227
|
}
|
|
202
228
|
|
|
@@ -207,38 +233,8 @@ export class ProjectConfigLoader {
|
|
|
207
233
|
if (result.disabled.includes(id) || customDef.retired) {
|
|
208
234
|
continue;
|
|
209
235
|
}
|
|
210
|
-
const extendExceptions = customDef.extend_exceptions;
|
|
211
|
-
const isExtendOnly =
|
|
212
|
-
!!extendExceptions && extendExceptions.length > 0 &&
|
|
213
|
-
!customDef.rule &&
|
|
214
|
-
!customDef.exceptions;
|
|
215
|
-
|
|
216
|
-
if (isExtendOnly) {
|
|
217
|
-
const builtIn = this.findBuiltInConstraint(id, result);
|
|
218
|
-
if (builtIn) {
|
|
219
|
-
const constraint = { ...builtIn };
|
|
220
|
-
constraint.exceptions = [
|
|
221
|
-
...(builtIn.exceptions || []),
|
|
222
|
-
...extendExceptions!,
|
|
223
|
-
];
|
|
224
|
-
if (result.ironLaws[id]) result.ironLaws[id] = constraint;
|
|
225
|
-
if (result.guidelines[id]) result.guidelines[id] = constraint;
|
|
226
|
-
if (result.prompts![id]) result.prompts![id] = constraint;
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
236
|
const constraint = this.toConstraint(customDef, id);
|
|
232
237
|
|
|
233
|
-
if (extendExceptions && extendExceptions.length > 0) {
|
|
234
|
-
const builtIn = this.findBuiltInConstraint(id, result);
|
|
235
|
-
constraint.exceptions = [
|
|
236
|
-
...(builtIn?.exceptions || []),
|
|
237
|
-
...(customDef.exceptions || []),
|
|
238
|
-
...extendExceptions,
|
|
239
|
-
];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
238
|
result.custom.push(id);
|
|
243
239
|
|
|
244
240
|
const level = customDef.level || 'guideline';
|
|
@@ -272,16 +268,6 @@ export class ProjectConfigLoader {
|
|
|
272
268
|
return result;
|
|
273
269
|
}
|
|
274
270
|
|
|
275
|
-
/**
|
|
276
|
-
* 在合并结果中查找内置约束
|
|
277
|
-
*/
|
|
278
|
-
private findBuiltInConstraint(
|
|
279
|
-
id: string,
|
|
280
|
-
merged: MergedConstraintsConfig
|
|
281
|
-
): Constraint | undefined {
|
|
282
|
-
return merged.ironLaws[id] || merged.guidelines[id] || merged.prompts?.[id];
|
|
283
|
-
}
|
|
284
|
-
|
|
285
271
|
/**
|
|
286
272
|
* 将自定义约束定义转换为 Constraint
|
|
287
273
|
*
|
|
@@ -298,7 +284,6 @@ export class ProjectConfigLoader {
|
|
|
298
284
|
rule: def.rule || '',
|
|
299
285
|
message: def.message || '',
|
|
300
286
|
trigger: (def.trigger || 'manual') as ConstraintTrigger | ConstraintTrigger[],
|
|
301
|
-
exceptions: def.exceptions,
|
|
302
287
|
description: def.description,
|
|
303
288
|
promptInjection: def.promptInjection,
|
|
304
289
|
enabled: def.enabled !== false,
|
package/src/failure/CONTEXT.md
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
## 依赖关系
|
|
13
13
|
- 依赖 `src/types/constraint` ConstraintViolationError
|
|
14
14
|
- 依赖 `src/core/constraints/` 约束检查结果
|
|
15
|
-
- 被 `src/
|
|
15
|
+
- 被 `src/cli/commands/report.ts` 消费(executeWithCollect),并经包根导出
|
|
16
16
|
|
|
17
17
|
## 约定
|
|
18
18
|
- 分类规则可扩展(自定义 ErrorClassifierConfig)
|
package/src/gates/CONTEXT.md
CHANGED
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
## 核心导出
|
|
7
7
|
- 统一协议:`Gate{id, order, evaluate(ctx)}` → `GateDecision{status: deny|abstain|ask, result: GateResult}`(`types.ts`;`decisionFromResult` 报告→决策映射,浅冻结)
|
|
8
8
|
- 注册表:`gateRegistry`(`registry.ts`)——定义即注册 + 构建期双向闭环(定义无实现/实现无定义/重复 id → 加载期抛错);`getGate`(未注册抛错)/`listRegisteredGates`/`registeredGateCount`
|
|
9
|
-
- 定义表:`GATE_DEFINITIONS`(`definitions.ts`)——id/description/默认 order/CLI 元数据;bin/harness.js 注册表驱动生成 6 门禁命令(纯数据模块,禁 import 实现,保 --help 懒加载;CLI 实现引用为 module+export,per-command 懒加载,H5)
|
|
9
|
+
- 定义表:`GATE_DEFINITIONS`(`definitions.ts`)——id/description/默认 order/CLI 元数据;CLI 元数据形状即 `CommandDefinition`(ADR-0007:门禁与非门禁共用同一命令定义形状,bin 单引擎单循环;门禁特有语义 = `subcommandStrict:false` 未知子命令落回默认 action + `bareRunsAction:true` 裸跑执行 action);bin/harness.js 注册表驱动生成 6 门禁命令(纯数据模块,禁 import 实现,保 --help 懒加载;CLI 实现引用为 module+export,per-command 懒加载,H5)
|
|
10
10
|
- 执行器:`runGates`(`runner.ts`)——按 order 升序;deny 单调(下游 abstain 不得改回 allow)+ ask 枚举预留 fail-closed = deny;决策浅冻结
|
|
11
|
-
- 生效集:`getEffectiveGates(projectRoot)`(`effective-gates.ts`)——对齐 getEffectiveConstraints 裁剪模式:config.yml `gates.order` 重排 + `gates.<id>.enabled:false`
|
|
12
|
-
- checker-as-guard 接线点:`createCheckerGate(check)`(`checker-gate.ts`)——ConstraintCheck → Gate(studio #129 随动);false→deny,true/'skip'→abstain
|
|
11
|
+
- 生效集:`getEffectiveGates(projectRoot)`(`effective-gates.ts`)——对齐 getEffectiveConstraints 裁剪模式:config.yml `gates.order` 重排 + `gates.<id>.enabled:false` 移除;enabled 段未注册校验与裁剪走 core/effective-set 共享筛选器(throw 模式),order 重排与重复 id 检测留本侧
|
|
12
|
+
- checker-as-guard 接线点:`createCheckerGate(check)`(`checker-gate.ts`)——ConstraintCheck → Gate(studio #129 随动);false→deny,true/'skip'→abstain;env 经 `buildCheckEnv(..., 'none')` 构造(显式不接证据,语义见 core/constraints/checkers/types.ts 工厂 doc)
|
|
13
13
|
- 门禁类:`ReviewGate` / `SecurityGate` / `PerformanceGate` / `ContractGate` / `SpecAcceptanceGate` / `CommandGate`(各自执行细节私有,保留 `check()`/`scan()` 报告方法)
|
|
14
14
|
- `types.ts` — GateResult(报告结构,保留)/ GateContext / GateDecision 等公共类型
|
|
15
15
|
- 便捷工厂函数:createReviewGate / createSecurityGate / createPerformanceGate / createContractGate / createSpecAcceptanceGate / createCommandGate
|
|
@@ -4,13 +4,11 @@
|
|
|
4
4
|
* 把已注册的 ConstraintCheck 适配为统一 Gate,供守卫链(如 studio
|
|
5
5
|
* runCompletionGuards)复用 runGates 的 deny 单调 / ask fail-closed 语义。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* (stagedDiff 空、srcScan 空)——证据 flag 未接线的 checker 按契约返回
|
|
9
|
-
* 'skip'(不阻断,映射为 abstain);纯上下文判断的 checker 照常判定。
|
|
10
|
-
* studio 侧若需 git 证据,在 #129 接线时扩展 CheckEnv 构造。
|
|
7
|
+
* env 经 buildCheckEnv(..., 'none') 构造(显式不接证据),语义见工厂 doc。
|
|
11
8
|
*/
|
|
12
9
|
|
|
13
|
-
import type {
|
|
10
|
+
import type { ConstraintCheck } from '../core/constraints/checkers';
|
|
11
|
+
import { buildCheckEnv } from '../core/constraints/checkers';
|
|
14
12
|
import type { Gate, GateContext, GateDecision } from './types';
|
|
15
13
|
import { decisionFromResult } from './decision';
|
|
16
14
|
|
|
@@ -29,13 +27,7 @@ export function createCheckerGate(check: ConstraintCheck, order = 0): Gate {
|
|
|
29
27
|
async evaluate(ctx: GateContext): Promise<GateDecision> {
|
|
30
28
|
const startTime = Date.now();
|
|
31
29
|
const projectPath = ctx.projectPath || process.cwd();
|
|
32
|
-
const env:
|
|
33
|
-
context: { operation: 'manual', projectPath },
|
|
34
|
-
projectPath,
|
|
35
|
-
stagedDiff: async () => '',
|
|
36
|
-
stagedDiffNames: async () => '',
|
|
37
|
-
srcScan: () => [],
|
|
38
|
-
};
|
|
30
|
+
const env = buildCheckEnv({ operation: 'manual', projectPath }, 'none');
|
|
39
31
|
const outcome = await check.evaluate(env);
|
|
40
32
|
return decisionFromResult({
|
|
41
33
|
gate: check.id,
|
package/src/gates/definitions.ts
CHANGED
|
@@ -3,49 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* - 每个门禁在此声明 id / description / 默认 order / CLI 元数据;
|
|
5
5
|
* registry.ts 按此表做「定义↔实现」双向闭环校验(复制 checker 闭环模式)。
|
|
6
|
-
* - CLI
|
|
7
|
-
*
|
|
8
|
-
* module+export(CommandImplRef),
|
|
6
|
+
* - CLI 元数据即 CommandDefinition(架构评审候选8,ADR-0007:形状对齐通用
|
|
7
|
+
* 命令定义,bin/harness.js 单引擎单循环生成全部命令):命令名/别名/选项/
|
|
8
|
+
* 子命令路由与历史手工块完全兼容;实现引用为 module+export(CommandImplRef),
|
|
9
|
+
* bin 按需 per-command 懒加载(H5/O2)。门禁特有语义由两个标志表达:
|
|
10
|
+
* subcommandStrict:false(未知位置参数落回默认 action)+
|
|
11
|
+
* bareRunsAction:true(无位置参数时跑默认 action 而非显示帮助)。
|
|
9
12
|
* - 本模块禁止 import 任何门禁/命令实现(仅 type import,运行时零依赖)——
|
|
10
13
|
* bin 启动期只加载本纯数据模块(保持 --help/--version 懒加载,
|
|
11
14
|
* 闭环校验在 registry 加载期执行)。
|
|
12
15
|
*/
|
|
13
16
|
|
|
14
|
-
import type {
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 门禁 CLI 选项元数据(直接映射 commander `.option()`)
|
|
18
|
-
*/
|
|
19
|
-
export interface GateCliOption {
|
|
20
|
-
/** commander option flags,如 '-p, --project-path <path>' */
|
|
21
|
-
flags: string;
|
|
22
|
-
/** 选项描述 */
|
|
23
|
-
description: string;
|
|
24
|
-
/** commander 缺省值;negated option(如 --no-strict)不设,由 commander 默认 true */
|
|
25
|
-
defaultValue?: string | boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 门禁 CLI 命令元数据(bin/harness.js 注册表驱动生成)
|
|
30
|
-
*/
|
|
31
|
-
export interface GateCliDefinition {
|
|
32
|
-
/** 命令名(历史命令名兼容保留) */
|
|
33
|
-
command: string;
|
|
34
|
-
/** 命令别名 */
|
|
35
|
-
alias?: string;
|
|
36
|
-
/** 位置参数声明,如 '[subcommand]' / '[cmd]' */
|
|
37
|
-
argument?: string;
|
|
38
|
-
/** 命令描述 */
|
|
39
|
-
description: string;
|
|
40
|
-
/** 命令选项 */
|
|
41
|
-
options: GateCliOption[];
|
|
42
|
-
/** 子命令名 → 命令实现引用(module+export);命中后按 [options] 透传 */
|
|
43
|
-
subcommands?: Record<string, CommandImplRef>;
|
|
44
|
-
/** 默认 action 命令实现引用(module+export) */
|
|
45
|
-
action: CommandImplRef;
|
|
46
|
-
/** 默认 action 实参构造:arg = 位置参数(无位置参数时为 undefined),options = commander 选项对象 */
|
|
47
|
-
mapActionArgs: (arg: string | undefined, options: Record<string, unknown>) => unknown[];
|
|
48
|
-
}
|
|
17
|
+
import type { CommandDefinition } from '../cli/commands/definitions';
|
|
49
18
|
|
|
50
19
|
/**
|
|
51
20
|
* 门禁定义
|
|
@@ -57,8 +26,8 @@ export interface GateDefinition {
|
|
|
57
26
|
description: string;
|
|
58
27
|
/** 默认顺序(config.yml `gates.order` 可覆盖),小者先执行 */
|
|
59
28
|
order: number;
|
|
60
|
-
/** CLI
|
|
61
|
-
cli:
|
|
29
|
+
/** CLI 元数据(形状 = CommandDefinition,bin/harness.js 通用引擎驱动生成) */
|
|
30
|
+
cli: CommandDefinition;
|
|
62
31
|
}
|
|
63
32
|
|
|
64
33
|
/**
|
|
@@ -81,9 +50,11 @@ export const GATE_DEFINITIONS: GateDefinition[] = [
|
|
|
81
50
|
{ flags: '--check-all', description: '检查所有任务', defaultValue: false },
|
|
82
51
|
{ flags: '--run-e2e', description: '运行 E2E 测试', defaultValue: false },
|
|
83
52
|
],
|
|
84
|
-
subcommands: { list: { module: 'acceptance', export: 'listAcceptanceCriteria' } },
|
|
53
|
+
subcommands: { list: { impl: { module: 'acceptance', export: 'listAcceptanceCriteria' } } },
|
|
54
|
+
subcommandStrict: false,
|
|
55
|
+
bareRunsAction: true,
|
|
85
56
|
action: { module: 'acceptance', export: 'acceptance' },
|
|
86
|
-
mapActionArgs: (
|
|
57
|
+
mapActionArgs: (_positionals, options) => [options],
|
|
87
58
|
},
|
|
88
59
|
},
|
|
89
60
|
{
|
|
@@ -102,7 +73,7 @@ export const GATE_DEFINITIONS: GateDefinition[] = [
|
|
|
102
73
|
{ flags: '--strict', description: '严格模式(warn 也阻止)' },
|
|
103
74
|
],
|
|
104
75
|
action: { module: 'command', export: 'executeCommand' },
|
|
105
|
-
mapActionArgs: (
|
|
76
|
+
mapActionArgs: (positionals, options) => [positionals[0], options],
|
|
106
77
|
},
|
|
107
78
|
},
|
|
108
79
|
{
|
|
@@ -119,9 +90,11 @@ export const GATE_DEFINITIONS: GateDefinition[] = [
|
|
|
119
90
|
{ flags: '--no-strict', description: '关闭严格模式' },
|
|
120
91
|
{ flags: '--allow-breaking', description: '允许破坏性变更', defaultValue: false },
|
|
121
92
|
],
|
|
122
|
-
subcommands: { validate: { module: 'contract', export: 'validateSchema' } },
|
|
93
|
+
subcommands: { validate: { impl: { module: 'contract', export: 'validateSchema' } } },
|
|
94
|
+
subcommandStrict: false,
|
|
95
|
+
bareRunsAction: true,
|
|
123
96
|
action: { module: 'contract', export: 'contract' },
|
|
124
|
-
mapActionArgs: (
|
|
97
|
+
mapActionArgs: (_positionals, options) => [options],
|
|
125
98
|
},
|
|
126
99
|
},
|
|
127
100
|
{
|
|
@@ -142,7 +115,7 @@ export const GATE_DEFINITIONS: GateDefinition[] = [
|
|
|
142
115
|
{ flags: '--benchmark-timeout <n>', description: '基准测试超时(秒)', defaultValue: '60' },
|
|
143
116
|
],
|
|
144
117
|
action: { module: 'performance', export: 'performance' },
|
|
145
|
-
mapActionArgs: (
|
|
118
|
+
mapActionArgs: (_positionals, options) => [
|
|
146
119
|
{
|
|
147
120
|
projectPath: options.projectPath,
|
|
148
121
|
coverage: options.coverage,
|
|
@@ -170,9 +143,11 @@ export const GATE_DEFINITIONS: GateDefinition[] = [
|
|
|
170
143
|
{ flags: '--no-block-on-changes', description: '不阻止变更请求' },
|
|
171
144
|
{ flags: '--allowed-reviewers <list>', description: '允许的审查者(逗号分隔)' },
|
|
172
145
|
],
|
|
173
|
-
subcommands: { status: { module: 'review', export: 'reviewStatus' } },
|
|
146
|
+
subcommands: { status: { impl: { module: 'review', export: 'reviewStatus' } } },
|
|
147
|
+
subcommandStrict: false,
|
|
148
|
+
bareRunsAction: true,
|
|
174
149
|
action: { module: 'review', export: 'review' },
|
|
175
|
-
mapActionArgs: (
|
|
150
|
+
mapActionArgs: (_positionals, options) => [
|
|
176
151
|
{
|
|
177
152
|
projectPath: options.projectPath,
|
|
178
153
|
minReviewers: parseInt(String(options.minReviewers), 10),
|
|
@@ -199,9 +174,11 @@ export const GATE_DEFINITIONS: GateDefinition[] = [
|
|
|
199
174
|
{ flags: '--ignore-dev-deps', description: '忽略开发依赖', defaultValue: false },
|
|
200
175
|
{ flags: '--scan-command <cmd>', description: '自定义扫描命令' },
|
|
201
176
|
],
|
|
202
|
-
subcommands: { audit: { module: 'security', export: 'auditDetails' } },
|
|
177
|
+
subcommands: { audit: { impl: { module: 'security', export: 'auditDetails' } } },
|
|
178
|
+
subcommandStrict: false,
|
|
179
|
+
bareRunsAction: true,
|
|
203
180
|
action: { module: 'security', export: 'security' },
|
|
204
|
-
mapActionArgs: (
|
|
181
|
+
mapActionArgs: (_positionals, options) => [options],
|
|
205
182
|
},
|
|
206
183
|
},
|
|
207
184
|
];
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import type { Gate } from './types';
|
|
13
13
|
import { listRegisteredGates } from './registry';
|
|
14
14
|
import { loadRawProjectConfig } from '../core/project-config-loader';
|
|
15
|
+
import { filterEnabledEntries } from '../core/effective-set';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* config.yml `gates` 段
|
|
@@ -40,7 +41,8 @@ export function getEffectiveGates(projectRoot: string = process.cwd()): Gate[] {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
// ========================================
|
|
43
|
-
//
|
|
44
|
+
// 闭环校验(order 重排与重复 id 检测留门禁侧;
|
|
45
|
+
// enabled 段的未注册校验走共享筛选器 throw 模式)
|
|
44
46
|
// ========================================
|
|
45
47
|
const orderIds = Array.isArray(config.order) ? (config.order as string[]) : undefined;
|
|
46
48
|
if (orderIds) {
|
|
@@ -60,31 +62,22 @@ export function getEffectiveGates(projectRoot: string = process.cwd()): Gate[] {
|
|
|
60
62
|
seen.add(id);
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
for (const key of Object.keys(config)) {
|
|
64
|
-
if (key === 'order') continue;
|
|
65
|
-
if (!known.has(key)) {
|
|
66
|
-
throw new Error(
|
|
67
|
-
`[harness] config.yml gates.${key} 引用了未注册的门禁。` +
|
|
68
|
-
`可用门禁: ${[...known].join(', ')}。`
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
65
|
|
|
73
66
|
// ========================================
|
|
74
67
|
// enabled 裁剪(与 getEffectiveConstraints 的 enabled:false 删除同效)
|
|
75
68
|
// ========================================
|
|
76
|
-
const
|
|
77
|
-
for (const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
entry &&
|
|
81
|
-
typeof entry === 'object' &&
|
|
82
|
-
!Array.isArray(entry) &&
|
|
83
|
-
entry.enabled === false
|
|
84
|
-
) {
|
|
85
|
-
disabled.add(gate.id);
|
|
86
|
-
}
|
|
69
|
+
const enabledEntries: Record<string, { enabled?: boolean } | undefined> = {};
|
|
70
|
+
for (const [key, value] of Object.entries(config)) {
|
|
71
|
+
if (key === 'order') continue;
|
|
72
|
+
enabledEntries[key] = value as { enabled?: boolean } | undefined;
|
|
87
73
|
}
|
|
74
|
+
const { disabledIds } = filterEnabledEntries(known, enabledEntries, {
|
|
75
|
+
onUnknownId: 'throw',
|
|
76
|
+
unknownIdError: id =>
|
|
77
|
+
`[harness] config.yml gates.${id} 引用了未注册的门禁。` +
|
|
78
|
+
`可用门禁: ${[...known].join(', ')}。`,
|
|
79
|
+
});
|
|
80
|
+
const disabled = new Set(disabledIds);
|
|
88
81
|
const effective = gates.filter(g => !disabled.has(g.id));
|
|
89
82
|
|
|
90
83
|
// ========================================
|
package/src/gates/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { decisionFromResult } from './decision';
|
|
|
35
35
|
/**
|
|
36
36
|
* 门禁定义表(定义即注册的单一定义源;bin/harness.js 注册表驱动生成 CLI)
|
|
37
37
|
*/
|
|
38
|
-
export { GATE_DEFINITIONS, type GateDefinition
|
|
38
|
+
export { GATE_DEFINITIONS, type GateDefinition } from './definitions';
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* 门禁注册表(定义↔实现双向闭环,加载期抛错)+ getGate 引用闭环
|
package/src/hooks/bootstrap.ts
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { ConstraintChecker } from '../core/constraints/checker';
|
|
16
|
-
import { getTraceCollector } from '../monitoring/traces';
|
|
17
16
|
import { SessionManager } from '../context/session-manager';
|
|
18
17
|
import { ProjectConfigLoader } from '../core/project-config-loader';
|
|
19
18
|
import { HookRegistry } from './registry';
|
|
@@ -74,7 +73,6 @@ export async function bootstrapHarness(
|
|
|
74
73
|
|
|
75
74
|
// 2. 初始化核心组件
|
|
76
75
|
const checker = ConstraintChecker.getInstance();
|
|
77
|
-
checker.setTraceRecorder(getTraceCollector());
|
|
78
76
|
|
|
79
77
|
const sessions = new SessionManager(resolvedPath);
|
|
80
78
|
const hooks = new HookRegistry();
|
|
@@ -111,7 +109,6 @@ export function bootstrapHarnessSync(
|
|
|
111
109
|
const mergedConstraints = loader.mergeConstraints();
|
|
112
110
|
|
|
113
111
|
const checker = ConstraintChecker.getInstance();
|
|
114
|
-
checker.setTraceRecorder(getTraceCollector());
|
|
115
112
|
|
|
116
113
|
const sessions = new SessionManager(resolvedPath);
|
|
117
114
|
const hooks = new HookRegistry();
|