@dommaker/harness 0.16.9 → 0.17.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/CHANGELOG.md +39 -0
- package/README.md +33 -32
- package/bin/harness.js +33 -20
- package/dist/cli/commands/check.d.ts +3 -2
- package/dist/cli/commands/check.d.ts.map +1 -1
- package/dist/cli/commands/check.js +69 -36
- package/dist/cli/commands/check.js.map +1 -1
- package/dist/cli/commands/constraints-report.d.ts +42 -0
- package/dist/cli/commands/constraints-report.d.ts.map +1 -0
- package/dist/cli/commands/constraints-report.js +233 -0
- package/dist/cli/commands/constraints-report.js.map +1 -0
- package/dist/cli/commands/constraints-retire.d.ts +71 -0
- package/dist/cli/commands/constraints-retire.d.ts.map +1 -0
- package/dist/cli/commands/constraints-retire.js +384 -0
- package/dist/cli/commands/constraints-retire.js.map +1 -0
- package/dist/cli/commands/constraints.d.ts +1 -1
- package/dist/cli/commands/constraints.d.ts.map +1 -1
- package/dist/cli/commands/constraints.js +4 -4
- package/dist/cli/commands/constraints.js.map +1 -1
- package/dist/cli/commands/index.d.ts +2 -1
- package/dist/cli/commands/index.d.ts.map +1 -1
- package/dist/cli/commands/index.js +10 -4
- package/dist/cli/commands/index.js.map +1 -1
- package/dist/cli/commands/init.d.ts +20 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +81 -59
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/report.js +4 -4
- package/dist/cli/commands/report.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +3 -4
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +5 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +2 -10
- package/dist/cli/commands/sync-docs/capabilities-syncer.js.map +1 -1
- package/dist/cli/commands/validate.d.ts.map +1 -1
- package/dist/cli/commands/validate.js +1 -5
- package/dist/cli/commands/validate.js.map +1 -1
- package/dist/core/constraints/capabilities-parser.d.ts +7 -0
- package/dist/core/constraints/capabilities-parser.d.ts.map +1 -1
- package/dist/core/constraints/capabilities-parser.js +13 -0
- package/dist/core/constraints/capabilities-parser.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +13 -5
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +62 -25
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.d.ts +9 -2
- package/dist/core/constraints/checkers/capability-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/capability-sync.js +55 -22
- package/dist/core/constraints/checkers/capability-sync.js.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.d.ts +3 -0
- package/dist/core/constraints/checkers/context-doc-sync.d.ts.map +1 -1
- package/dist/core/constraints/checkers/context-doc-sync.js +8 -2
- package/dist/core/constraints/checkers/context-doc-sync.js.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.d.ts +1 -0
- package/dist/core/constraints/checkers/docs-freshness.d.ts.map +1 -1
- package/dist/core/constraints/checkers/docs-freshness.js +39 -0
- package/dist/core/constraints/checkers/docs-freshness.js.map +1 -1
- package/dist/core/constraints/checkers/index.d.ts +8 -4
- package/dist/core/constraints/checkers/index.d.ts.map +1 -1
- package/dist/core/constraints/checkers/index.js +29 -46
- package/dist/core/constraints/checkers/index.js.map +1 -1
- package/dist/core/constraints/checkers/iron-flags.d.ts +6 -7
- package/dist/core/constraints/checkers/iron-flags.d.ts.map +1 -1
- package/dist/core/constraints/checkers/iron-flags.js +10 -17
- package/dist/core/constraints/checkers/iron-flags.js.map +1 -1
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts +13 -0
- package/dist/core/constraints/checkers/no-hardcoded-credentials.d.ts.map +1 -0
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +91 -0
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js.map +1 -0
- package/dist/core/constraints/checkers/types.d.ts +15 -4
- package/dist/core/constraints/checkers/types.d.ts.map +1 -1
- package/dist/core/constraints/checkers/types.js +16 -4
- package/dist/core/constraints/checkers/types.js.map +1 -1
- package/dist/core/constraints/context-builder.d.ts +6 -3
- package/dist/core/constraints/context-builder.d.ts.map +1 -1
- package/dist/core/constraints/context-builder.js +29 -20
- package/dist/core/constraints/context-builder.js.map +1 -1
- package/dist/core/constraints/definitions/guidelines.d.ts +6 -2
- package/dist/core/constraints/definitions/guidelines.d.ts.map +1 -1
- package/dist/core/constraints/definitions/guidelines.js +29 -572
- package/dist/core/constraints/definitions/guidelines.js.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.d.ts +6 -2
- package/dist/core/constraints/definitions/iron-laws.d.ts.map +1 -1
- package/dist/core/constraints/definitions/iron-laws.js +48 -231
- package/dist/core/constraints/definitions/iron-laws.js.map +1 -1
- package/dist/core/constraints/definitions/prompts.d.ts +12 -0
- package/dist/core/constraints/definitions/prompts.d.ts.map +1 -0
- package/dist/core/constraints/definitions/prompts.js +405 -0
- package/dist/core/constraints/definitions/prompts.js.map +1 -0
- package/dist/core/constraints/definitions.d.ts +15 -9
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +18 -12
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/index.d.ts +3 -2
- package/dist/core/constraints/index.d.ts.map +1 -1
- package/dist/core/constraints/index.js +8 -2
- package/dist/core/constraints/index.js.map +1 -1
- package/dist/core/constraints/injection-drift.d.ts +48 -0
- package/dist/core/constraints/injection-drift.d.ts.map +1 -0
- package/dist/core/constraints/injection-drift.js +140 -0
- package/dist/core/constraints/injection-drift.js.map +1 -0
- package/dist/core/constraints/injection-renderer.d.ts +23 -0
- package/dist/core/constraints/injection-renderer.d.ts.map +1 -0
- package/dist/core/constraints/injection-renderer.js +44 -0
- package/dist/core/constraints/injection-renderer.js.map +1 -0
- package/dist/core/constraints/interceptor.d.ts.map +1 -1
- package/dist/core/constraints/interceptor.js +3 -2
- package/dist/core/constraints/interceptor.js.map +1 -1
- package/dist/core/constraints/usage-report.d.ts +95 -0
- package/dist/core/constraints/usage-report.d.ts.map +1 -0
- package/dist/core/constraints/usage-report.js +206 -0
- package/dist/core/constraints/usage-report.js.map +1 -0
- package/dist/core/effective-constraints.d.ts +47 -0
- package/dist/core/effective-constraints.d.ts.map +1 -0
- package/dist/core/effective-constraints.js +60 -0
- package/dist/core/effective-constraints.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/project-config-loader.d.ts +17 -2
- package/dist/core/project-config-loader.d.ts.map +1 -1
- package/dist/core/project-config-loader.js +55 -8
- package/dist/core/project-config-loader.js.map +1 -1
- package/dist/dashboard/data.d.ts +1 -9
- package/dist/dashboard/data.d.ts.map +1 -1
- package/dist/dashboard/data.js +7 -15
- package/dist/dashboard/data.js.map +1 -1
- package/dist/dashboard/types.d.ts +13 -1
- package/dist/dashboard/types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -13
- package/dist/index.js.map +1 -1
- package/dist/monitoring/index.d.ts +0 -2
- package/dist/monitoring/index.d.ts.map +1 -1
- package/dist/monitoring/index.js +0 -2
- package/dist/monitoring/index.js.map +1 -1
- package/dist/monitoring/knowledge-evolver.d.ts +1 -1
- package/dist/monitoring/knowledge-evolver.js +1 -1
- package/dist/monitoring/trace-analyzer.d.ts +1 -1
- package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
- package/dist/monitoring/trace-analyzer.js +16 -10
- package/dist/monitoring/trace-analyzer.js.map +1 -1
- package/dist/monitoring/traces.d.ts +2 -1
- package/dist/monitoring/traces.d.ts.map +1 -1
- package/dist/monitoring/traces.js +5 -3
- package/dist/monitoring/traces.js.map +1 -1
- package/dist/presets/standard.d.ts +3 -1
- package/dist/presets/standard.d.ts.map +1 -1
- package/dist/presets/standard.js +18 -8
- package/dist/presets/standard.js.map +1 -1
- package/dist/types/constraint.d.ts +51 -11
- package/dist/types/constraint.d.ts.map +1 -1
- package/dist/types/constraint.js +8 -4
- package/dist/types/constraint.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/monitoring-types.d.ts +2 -63
- package/dist/types/monitoring-types.d.ts.map +1 -1
- package/dist/types/monitoring-types.js +2 -2
- package/dist/types/project-config.d.ts +26 -1
- package/dist/types/project-config.d.ts.map +1 -1
- package/dist/types/trace.d.ts +16 -7
- package/dist/types/trace.d.ts.map +1 -1
- package/dist/types/trace.js +8 -0
- package/dist/types/trace.js.map +1 -1
- package/package.json +1 -1
- package/src/CONTEXT.md +2 -2
- package/src/__tests__/checker-extra.test.ts +228 -333
- package/src/__tests__/checker.test.ts +87 -724
- package/src/__tests__/constraint-doctor.test.ts +5 -5
- package/src/__tests__/doctor-extra.test.ts +164 -0
- package/src/__tests__/effective-constraints.test.ts +147 -0
- package/src/__tests__/extend-exceptions.test.ts +3 -3
- package/src/__tests__/iron-laws.test.ts +115 -91
- package/src/__tests__/no-hardcoded-credentials.test.ts +90 -0
- package/src/__tests__/presets.test.ts +7 -7
- package/src/__tests__/project-config-loader-extra.test.ts +41 -4
- package/src/__tests__/skip-semantics.test.ts +322 -0
- package/src/cli/commands/CONTEXT.md +5 -3
- package/src/cli/commands/__tests__/check-drift.test.ts +127 -0
- package/src/cli/commands/__tests__/check-skip-output.test.ts +128 -0
- package/src/cli/commands/__tests__/check.test.ts +14 -25
- package/src/cli/commands/__tests__/constraints-report.test.ts +327 -0
- package/src/cli/commands/__tests__/constraints-retire.test.ts +283 -0
- package/src/cli/commands/__tests__/init-injection.test.ts +234 -0
- package/src/cli/commands/__tests__/status-extra.test.ts +11 -11
- package/src/cli/commands/__tests__/status.test.ts +1 -1
- package/src/cli/commands/check.ts +72 -38
- package/src/cli/commands/constraints-report.ts +234 -0
- package/src/cli/commands/constraints-retire.ts +443 -0
- package/src/cli/commands/constraints.ts +5 -5
- package/src/cli/commands/index.ts +2 -1
- package/src/cli/commands/init.ts +94 -66
- package/src/cli/commands/report.ts +6 -6
- package/src/cli/commands/status.ts +3 -4
- package/src/cli/commands/sync-docs/capabilities-syncer.ts +5 -7
- package/src/cli/commands/validate.ts +1 -5
- package/src/core/CONTEXT.md +7 -4
- package/src/core/constraints/__tests__/injection-drift.test.ts +164 -0
- package/src/core/constraints/__tests__/interceptor.test.ts +4 -0
- package/src/core/constraints/capabilities-parser.ts +13 -0
- package/src/core/constraints/checker.ts +73 -28
- package/src/core/constraints/checkers/capability-sync.ts +72 -29
- package/src/core/constraints/checkers/context-doc-sync.ts +9 -2
- package/src/core/constraints/checkers/docs-freshness.ts +43 -0
- package/src/core/constraints/checkers/index.ts +38 -71
- package/src/core/constraints/checkers/iron-flags.ts +13 -49
- package/src/core/constraints/checkers/no-hardcoded-credentials.ts +93 -0
- package/src/core/constraints/checkers/types.ts +27 -5
- package/src/core/constraints/context-builder.ts +28 -19
- package/src/core/constraints/definitions/guidelines.ts +29 -597
- package/src/core/constraints/definitions/iron-laws.ts +48 -239
- package/src/core/constraints/definitions/prompts.ts +419 -0
- package/src/core/constraints/definitions.ts +18 -11
- package/src/core/constraints/index.ts +10 -1
- package/src/core/constraints/injection-drift.ts +139 -0
- package/src/core/constraints/injection-renderer.ts +44 -0
- package/src/core/constraints/interceptor.ts +3 -2
- package/src/core/constraints/usage-report.ts +254 -0
- package/src/core/effective-constraints.ts +85 -0
- package/src/core/index.ts +4 -1
- package/src/core/project-config-loader.ts +59 -9
- package/src/dashboard/__tests__/data.test.ts +5 -12
- package/src/dashboard/data.ts +9 -19
- package/src/dashboard/types.ts +18 -1
- package/src/index.ts +0 -12
- package/src/knowledge/CONTEXT.md +2 -2
- package/src/monitoring/CONTEXT.md +3 -4
- package/src/monitoring/index.ts +0 -2
- package/src/monitoring/knowledge-evolver.ts +1 -1
- package/src/monitoring/trace-analyzer.ts +15 -10
- package/src/monitoring/traces.ts +10 -6
- package/src/presets/__tests__/standard.test.ts +11 -9
- package/src/presets/standard.ts +24 -15
- package/src/types/constraint.ts +59 -14
- package/src/types/index.ts +1 -3
- package/src/types/monitoring-types.ts +2 -84
- package/src/types/project-config.ts +30 -1
- package/src/types/trace.ts +18 -7
- package/src/verification/CONTEXT.md +1 -1
- package/dist/cli/commands/flow.d.ts +0 -22
- package/dist/cli/commands/flow.d.ts.map +0 -1
- package/dist/cli/commands/flow.js +0 -275
- package/dist/cli/commands/flow.js.map +0 -1
- package/dist/constraints/lifecycle-runner.d.ts +0 -52
- package/dist/constraints/lifecycle-runner.d.ts.map +0 -1
- package/dist/constraints/lifecycle-runner.js +0 -151
- package/dist/constraints/lifecycle-runner.js.map +0 -1
- package/dist/constraints/registry.d.ts +0 -27
- package/dist/constraints/registry.d.ts.map +0 -1
- package/dist/constraints/registry.js +0 -128
- package/dist/constraints/registry.js.map +0 -1
- package/dist/constraints/types.d.ts +0 -53
- package/dist/constraints/types.d.ts.map +0 -1
- package/dist/constraints/types.js +0 -8
- package/dist/constraints/types.js.map +0 -1
- package/dist/core/constraints/checkers/always-pass.d.ts +0 -17
- package/dist/core/constraints/checkers/always-pass.d.ts.map +0 -1
- package/dist/core/constraints/checkers/always-pass.js +0 -23
- package/dist/core/constraints/checkers/always-pass.js.map +0 -1
- package/dist/core/constraints/checkers/guideline-flags.d.ts +0 -9
- package/dist/core/constraints/checkers/guideline-flags.d.ts.map +0 -1
- package/dist/core/constraints/checkers/guideline-flags.js +0 -13
- package/dist/core/constraints/checkers/guideline-flags.js.map +0 -1
- package/dist/core/constraints/checkers/no-any-type.d.ts +0 -6
- package/dist/core/constraints/checkers/no-any-type.d.ts.map +0 -1
- package/dist/core/constraints/checkers/no-any-type.js +0 -42
- package/dist/core/constraints/checkers/no-any-type.js.map +0 -1
- package/dist/core/constraints/checkers/no-excuse-patterns.d.ts +0 -6
- package/dist/core/constraints/checkers/no-excuse-patterns.d.ts.map +0 -1
- package/dist/core/constraints/checkers/no-excuse-patterns.js +0 -25
- package/dist/core/constraints/checkers/no-excuse-patterns.js.map +0 -1
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.d.ts +0 -6
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.d.ts.map +0 -1
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.js +0 -34
- package/dist/core/constraints/checkers/no-fuzzy-completion-claim.js.map +0 -1
- package/dist/core/constraints/checkers/no-performative-agreement.d.ts +0 -8
- package/dist/core/constraints/checkers/no-performative-agreement.d.ts.map +0 -1
- package/dist/core/constraints/checkers/no-performative-agreement.js +0 -23
- package/dist/core/constraints/checkers/no-performative-agreement.js.map +0 -1
- package/dist/core/constraints/checkers/no-simplification-without-approval.d.ts +0 -6
- package/dist/core/constraints/checkers/no-simplification-without-approval.d.ts.map +0 -1
- package/dist/core/constraints/checkers/no-simplification-without-approval.js +0 -30
- package/dist/core/constraints/checkers/no-simplification-without-approval.js.map +0 -1
- package/dist/core/constraints/checkers/test-coverage.d.ts +0 -6
- package/dist/core/constraints/checkers/test-coverage.d.ts.map +0 -1
- package/dist/core/constraints/checkers/test-coverage.js +0 -33
- package/dist/core/constraints/checkers/test-coverage.js.map +0 -1
- package/dist/core/constraints/checkers/yagni.d.ts +0 -8
- package/dist/core/constraints/checkers/yagni.d.ts.map +0 -1
- package/dist/core/constraints/checkers/yagni.js +0 -96
- package/dist/core/constraints/checkers/yagni.js.map +0 -1
- package/dist/core/constraints/definitions/tips.d.ts +0 -7
- package/dist/core/constraints/definitions/tips.d.ts.map +0 -1
- package/dist/core/constraints/definitions/tips.js +0 -62
- package/dist/core/constraints/definitions/tips.js.map +0 -1
- package/dist/evolution/auto-evolve.d.ts +0 -35
- package/dist/evolution/auto-evolve.d.ts.map +0 -1
- package/dist/evolution/auto-evolve.js +0 -64
- package/dist/evolution/auto-evolve.js.map +0 -1
- package/dist/evolution/index.d.ts +0 -2
- package/dist/evolution/index.d.ts.map +0 -1
- package/dist/evolution/index.js +0 -18
- package/dist/evolution/index.js.map +0 -1
- package/dist/monitoring/constraint-evolver.d.ts +0 -120
- package/dist/monitoring/constraint-evolver.d.ts.map +0 -1
- package/dist/monitoring/constraint-evolver.js +0 -410
- package/dist/monitoring/constraint-evolver.js.map +0 -1
- package/src/__tests__/constraint-evolver.test.ts +0 -405
- package/src/__tests__/doctor-evolver.test.ts +0 -381
- package/src/cli/commands/__tests__/flow.test.ts +0 -343
- package/src/cli/commands/flow.ts +0 -277
- package/src/constraints/__tests__/lifecycle-runner.test.ts +0 -246
- package/src/constraints/__tests__/registry.test.ts +0 -196
- package/src/constraints/lifecycle-runner.ts +0 -184
- package/src/constraints/registry.ts +0 -134
- package/src/constraints/types.ts +0 -59
- package/src/core/constraints/checkers/always-pass.ts +0 -22
- package/src/core/constraints/checkers/guideline-flags.ts +0 -30
- package/src/core/constraints/checkers/no-any-type.ts +0 -42
- package/src/core/constraints/checkers/no-excuse-patterns.ts +0 -24
- package/src/core/constraints/checkers/no-fuzzy-completion-claim.ts +0 -33
- package/src/core/constraints/checkers/no-performative-agreement.ts +0 -22
- package/src/core/constraints/checkers/no-simplification-without-approval.ts +0 -29
- package/src/core/constraints/checkers/test-coverage.ts +0 -35
- package/src/core/constraints/checkers/yagni.ts +0 -65
- package/src/core/constraints/definitions/tips.ts +0 -63
- package/src/evolution/CONTEXT.md +0 -22
- package/src/evolution/__tests__/auto-evolve.test.ts +0 -319
- package/src/evolution/auto-evolve.ts +0 -98
- package/src/evolution/index.ts +0 -1
- package/src/monitoring/constraint-evolver.ts +0 -501
|
@@ -1,193 +1,45 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* check · guideline 定义(ADR-0001:kind 二元模型)
|
|
3
|
+
*
|
|
4
|
+
* 只保留带真实 checker 的指导原则。每条必须:
|
|
5
|
+
* - kind: 'check'
|
|
6
|
+
* - level: 'guideline'
|
|
7
|
+
* - 在 checkers/ 注册表中有对应实现(注册表闭环,缺失即加载期抛错)
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
import type { Constraint } from '../../../types/constraint';
|
|
7
11
|
|
|
8
|
-
// ========================================
|
|
9
|
-
// GUIDELINES(指导原则)
|
|
10
|
-
//
|
|
11
|
-
// 定义:优先建议,有例外,违背发警告但不阻止
|
|
12
|
-
// ========================================
|
|
13
|
-
|
|
14
12
|
export const GUIDELINES: Record<string, Constraint> = {
|
|
15
13
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* 来源:Superpowers prefer_worktree
|
|
19
|
-
*/
|
|
20
|
-
prefer_worktree: {
|
|
21
|
-
id: 'prefer_worktree',
|
|
22
|
-
rule: 'USE WORKTREE FOR HIGH-RISK CHANGES',
|
|
23
|
-
message: '高风险改动应在 worktree 中进行',
|
|
24
|
-
level: 'guideline',
|
|
25
|
-
trigger: ['code_implementation'],
|
|
26
|
-
enforcement: 'check-worktree',
|
|
27
|
-
description: `高风险改动应在隔离的 worktree 中进行。
|
|
28
|
-
|
|
29
|
-
【何时需要 worktree】
|
|
30
|
-
- 新功能开发(新增模块/API)
|
|
31
|
-
- 跨模块改动(>3 文件)
|
|
32
|
-
- 基础设施变更(CI/CD、依赖)
|
|
33
|
-
|
|
34
|
-
【何时不需要】
|
|
35
|
-
- 配置文件修改
|
|
36
|
-
- 单文件 bug fix
|
|
37
|
-
- 外科手术式修复(typo、missing import)
|
|
38
|
-
|
|
39
|
-
【原因】
|
|
40
|
-
- 隔离风险:worktree 中的改动不会影响主工作区
|
|
41
|
-
- 安全回滚:删除 worktree 即可放弃改动
|
|
42
|
-
- 并行开发:多个任务可同时在不同 worktree 中进行`,
|
|
43
|
-
promptInjection: '高风险改动(新功能、跨模块、基础设施)应在 worktree 中进行。配置修改、单文件 fix 可直接编辑。',
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 禁止无调查修复 bug
|
|
48
|
-
* 例外:简单 typo、配置错误
|
|
49
|
-
*/
|
|
50
|
-
no_fix_without_root_cause: {
|
|
51
|
-
id: 'no_fix_without_root_cause',
|
|
52
|
-
rule: 'NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST',
|
|
53
|
-
message: '复杂 bug 必须先调查根本原因',
|
|
54
|
-
level: 'guideline',
|
|
55
|
-
trigger: 'code_implementation',
|
|
56
|
-
enforcement: 'debug-systematic',
|
|
57
|
-
description: `在尝试修复 bug 之前,按复杂度区分调查要求:
|
|
58
|
-
|
|
59
|
-
[复杂 bug - 必须系统性调查]
|
|
60
|
-
- 业务逻辑错误(需追踪数据流)
|
|
61
|
-
- 状态不一致(需分析状态变化链)
|
|
62
|
-
- 性能问题(需定位瓶颈)
|
|
63
|
-
- 多模块联动问题(需分析调用链)
|
|
64
|
-
|
|
65
|
-
[简单 bug - 快速确认即可]
|
|
66
|
-
- typo/拼写错误
|
|
67
|
-
- 配置值错误
|
|
68
|
-
- 缺少必要配置
|
|
69
|
-
|
|
70
|
-
[禁止]
|
|
71
|
-
- 没有任何调查就直接猜测修复
|
|
72
|
-
- 看到 error 就直接 try-catch 掩盖`,
|
|
73
|
-
exceptions: ['simple_typo', 'config_value_error', 'missing_config'],
|
|
74
|
-
promptInjection: '修复问题时必须先定位根因。不绕过问题、不遮掩症状、不用临时方案代替根本修复。在分析文档中记录根因分析过程。',
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 业务逻辑代码必须先写测试
|
|
79
|
-
* 例外:配置文件、类型定义
|
|
14
|
+
* 禁止硬编码凭证
|
|
15
|
+
* 原因:密码/token/密钥泄露是最严重的安全漏洞,一旦提交到版本控制即不可逆
|
|
80
16
|
*/
|
|
81
|
-
|
|
82
|
-
id: '
|
|
83
|
-
|
|
84
|
-
|
|
17
|
+
no_hardcoded_credentials: {
|
|
18
|
+
id: 'no_hardcoded_credentials',
|
|
19
|
+
kind: 'check',
|
|
20
|
+
rule: 'NO HARDCODED PASSWORDS, TOKENS, SECRETS, OR CREDENTIALS IN ANY SOURCE FILE',
|
|
21
|
+
message: '禁止在代码/文档/配置文件中硬编码密码、token、密钥、API key',
|
|
85
22
|
level: 'guideline',
|
|
86
|
-
trigger: 'code_implementation',
|
|
87
|
-
enforcement: '
|
|
88
|
-
description:
|
|
89
|
-
|
|
90
|
-
[必须先写测试]
|
|
91
|
-
- 业务逻辑代码(算法、计算、数据处理)
|
|
92
|
-
- 工具函数(可复用的独立函数)
|
|
93
|
-
- API 接口(输入输出验证)
|
|
94
|
-
- 核心组件(影响系统行为的组件)
|
|
95
|
-
|
|
96
|
-
[不强制测试]
|
|
97
|
-
- 配置文件(config、env)
|
|
98
|
-
- 类型定义文件(.d.ts、interface)
|
|
99
|
-
- 简单 getter/setter
|
|
100
|
-
- 纯展示 UI 组件(无交互逻辑)`,
|
|
101
|
-
exceptions: ['config_file', 'type_definition', 'simple_accessor', 'pure_display_component'],
|
|
102
|
-
promptInjection: '新代码必须同时编写测试。实现功能前先写测试用例(RED),然后实现让测试通过(GREEN)。不得提交无测试覆盖的实现代码。',
|
|
23
|
+
trigger: ['code_implementation', 'doc_update', 'config_change', 'commit'],
|
|
24
|
+
enforcement: 'credential-scan',
|
|
25
|
+
description: `凭证(密码/token/密钥/API key)必须从环境变量或加密配置读取,严禁以明文形式出现在任何源代码文件中。包括但不限于:源码、Markdown 文档、YAML/JSON 配置、脚本文件。模板文件(.example/.sample/.template)允许占位符但不得包含真实值。建议配合 pre-commit hook 做自动扫描。`,
|
|
26
|
+
promptInjection: '禁止在代码中硬编码密码、API 密钥、Token 等凭证。使用环境变量或安全的凭证管理方案存储敏感信息。',
|
|
103
27
|
},
|
|
104
28
|
|
|
105
29
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
30
|
+
* 禁止跳过检查点验证
|
|
31
|
+
* 原因:安全底线,检查点是质量门控
|
|
108
32
|
*/
|
|
109
|
-
|
|
110
|
-
id: '
|
|
111
|
-
|
|
112
|
-
|
|
33
|
+
no_bypass_checkpoint: {
|
|
34
|
+
id: 'no_bypass_checkpoint',
|
|
35
|
+
kind: 'check',
|
|
36
|
+
rule: 'NO BYPASSING CHECKPOINTS',
|
|
37
|
+
message: '禁止跳过检查点验证',
|
|
113
38
|
level: 'guideline',
|
|
114
39
|
trigger: 'code_implementation',
|
|
115
|
-
enforcement: '
|
|
116
|
-
description:
|
|
117
|
-
|
|
118
|
-
[推荐做法]
|
|
119
|
-
- 使用 unknown + 类型守卫
|
|
120
|
-
- 使用具体类型定义
|
|
121
|
-
- 使用泛型约束
|
|
122
|
-
|
|
123
|
-
[允许例外] 但需添加注释说明
|
|
124
|
-
- JSON.parse/JSON.stringify 结果
|
|
125
|
-
- 第三方库无类型定义
|
|
126
|
-
- 迁移遗留代码临时使用`,
|
|
127
|
-
exceptions: ['json_parse_result', 'third_party_no_types', 'legacy_migration'],
|
|
128
|
-
promptInjection: '禁止使用 TypeScript any 类型。使用具体类型、泛型或 unknown 代替。any 绕过类型检查带来运行时风险。',
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* 简单方案优先
|
|
133
|
-
* 例外:扩展性、安全性、性能需求
|
|
134
|
-
*/
|
|
135
|
-
simplest_solution_first: {
|
|
136
|
-
id: 'simplest_solution_first',
|
|
137
|
-
rule: 'CHECK LOCAL/SIMPLE OPTIONS BEFORE REMOTE/COMPLEX',
|
|
138
|
-
message: '先检查本地/简单方案',
|
|
139
|
-
level: 'guideline',
|
|
140
|
-
trigger: ['code_implementation', 'module_extension'],
|
|
141
|
-
enforcement: 'check-local-first',
|
|
142
|
-
description: `在实现功能时,必须按顺序检查:
|
|
143
|
-
1) 是否有本地数据源(内存/文件)?
|
|
144
|
-
2) 是否有更简单的方案(更少依赖/更少代码)?
|
|
145
|
-
3) 如需远程查询/复杂架构,必须说明理由。
|
|
146
|
-
|
|
147
|
-
例外情况(可跳过简单方案):
|
|
148
|
-
- scalability_required: 需要多实例/分布式部署
|
|
149
|
-
- security_required: 需要加密/鉴权等安全措施
|
|
150
|
-
- performance_required: 本地方案性能不足
|
|
151
|
-
- reliability_required: 需要持久化/高可用`,
|
|
152
|
-
exceptions: ['scalability_required', 'security_required', 'performance_required', 'reliability_required'],
|
|
153
|
-
promptInjection: '简单至上:仅用最少代码解决问题。不添加"以防万一"的冗余功能。不为仅用一次的代码强行设计抽象。自检:资深工程师是否会认为此实现过度复杂?若是,立即简化。',
|
|
154
|
-
injectPrompt: true,
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* 复用检查优先
|
|
159
|
-
* 例外:紧急修复、hotfix、安全补丁
|
|
160
|
-
*/
|
|
161
|
-
no_creation_without_reuse_check: {
|
|
162
|
-
id: 'no_creation_without_reuse_check',
|
|
163
|
-
rule: 'NO NEW CAPABILITIES WITHOUT REUSE CHECK FIRST',
|
|
164
|
-
message: '创建新能力前必须检查复用',
|
|
165
|
-
level: 'guideline',
|
|
166
|
-
trigger: [
|
|
167
|
-
'module_creation',
|
|
168
|
-
'module_creation',
|
|
169
|
-
'module_creation',
|
|
170
|
-
'module_creation',
|
|
171
|
-
'module_extension',
|
|
172
|
-
'code_implementation',
|
|
173
|
-
],
|
|
174
|
-
enforcement: 'reuse-first',
|
|
175
|
-
description: `在创建新能力之前,必须先执行复用检查:
|
|
176
|
-
|
|
177
|
-
1. 查询现有能力索引
|
|
178
|
-
2. 检查是否有功能相似的能力
|
|
179
|
-
3. 评估是否可以复用或扩展
|
|
180
|
-
4. 记录复用检查结果
|
|
181
|
-
|
|
182
|
-
复用优先级:
|
|
183
|
-
1. 直接复用现有能力
|
|
184
|
-
2. 扩展现有能力
|
|
185
|
-
3. 组合多个现有能力
|
|
186
|
-
4. 创建新能力
|
|
187
|
-
|
|
188
|
-
例外情况下可跳过,但必须记录跳过原因。`,
|
|
189
|
-
exceptions: ['emergency_fix', 'hotfix', 'security_patch'],
|
|
190
|
-
promptInjection: '创建新模块/文件前,先检查项目中是否已有类似实现可以复用。优先扩展现有模块,避免引入重复代码和功能。',
|
|
40
|
+
enforcement: 'checkpoint-required',
|
|
41
|
+
description: '所有检查点必须通过,不能跳过验证步骤。检查点是质量的最后一道防线。',
|
|
42
|
+
promptInjection: '每个关键步骤后有 checkpoint 验证点,必须通过才能继续。通过标准:测试通过、类型检查无错误、lint 无新增警告。未通过时回退修复,不得跳过。',
|
|
191
43
|
},
|
|
192
44
|
|
|
193
45
|
/**
|
|
@@ -196,6 +48,7 @@ export const GUIDELINES: Record<string, Constraint> = {
|
|
|
196
48
|
*/
|
|
197
49
|
capability_sync: {
|
|
198
50
|
id: 'capability_sync',
|
|
51
|
+
kind: 'check',
|
|
199
52
|
rule: 'CODE CHANGES MUST UPDATE CAPABILITIES.MD',
|
|
200
53
|
message: '核心模块变更必须同步功能清单(支持模块级目录条目登记)',
|
|
201
54
|
level: 'guideline',
|
|
@@ -218,152 +71,13 @@ export const GUIDELINES: Record<string, Constraint> = {
|
|
|
218
71
|
exceptions: ['internal_refactor', 'bug_fix_only', 'performance_optimization'],
|
|
219
72
|
},
|
|
220
73
|
|
|
221
|
-
/**
|
|
222
|
-
* 禁止砍功能
|
|
223
|
-
* 例外:冗余代码清理
|
|
224
|
-
*/
|
|
225
|
-
no_simplification_without_approval: {
|
|
226
|
-
id: 'no_simplification_without_approval',
|
|
227
|
-
rule: 'NO SIMPLIFYING LOGIC WITHOUT USER APPROVAL',
|
|
228
|
-
message: '禁止砍功能,合理重构除外',
|
|
229
|
-
level: 'guideline',
|
|
230
|
-
trigger: 'code_implementation',
|
|
231
|
-
enforcement: 'preserve-complexity',
|
|
232
|
-
description: `在实现或修改代码时,区分简化类型:
|
|
233
|
-
|
|
234
|
-
[禁止] 必须向用户说明并获取批准
|
|
235
|
-
- 为了赶进度砍掉必要功能
|
|
236
|
-
- 为了省事跳过边界条件处理
|
|
237
|
-
- 为了简化逻辑牺牲用户体验
|
|
238
|
-
|
|
239
|
-
[允许] 合理优化,不需要批准
|
|
240
|
-
- 发现冗余代码后的重构优化
|
|
241
|
-
- 用更简洁的实现达到相同效果
|
|
242
|
-
- 删除不再使用的遗留代码`,
|
|
243
|
-
exceptions: ['redundant_code_cleanup', 'same_effect_refactor', 'unused_code_removal'],
|
|
244
|
-
promptInjection: '不得擅自简化或删除测试、lint 规则、类型检查或约束。如需降低检查标准,必须先提案并获明确批准。',
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* 技能需要测试
|
|
249
|
-
* 例外:MVP
|
|
250
|
-
*/
|
|
251
|
-
no_skill_without_test: {
|
|
252
|
-
id: 'no_skill_without_test',
|
|
253
|
-
rule: 'NO SKILL WITHOUT A FAILING TEST FIRST',
|
|
254
|
-
message: '创建技能前必须先定义测试场景',
|
|
255
|
-
level: 'guideline',
|
|
256
|
-
trigger: 'module_creation',
|
|
257
|
-
enforcement: 'skill-test-scenario',
|
|
258
|
-
description: `在创建新的 agent 技能之前,必须先定义测试场景:
|
|
259
|
-
|
|
260
|
-
1. 定义输入/输出期望
|
|
261
|
-
2. 定义边界条件
|
|
262
|
-
3. 定义失败场景
|
|
263
|
-
4. 编写测试用例
|
|
264
|
-
|
|
265
|
-
测试场景帮助:
|
|
266
|
-
- 明确技能的功能边界
|
|
267
|
-
- 验证技能的正确性
|
|
268
|
-
- 防止回归`,
|
|
269
|
-
promptInjection: '新创建的 Skill 模块必须有对应的测试文件。测试应覆盖正常路径、边界情况和错误处理。',
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* 测试覆盖率要求
|
|
274
|
-
* 例外:遗留代码
|
|
275
|
-
*/
|
|
276
|
-
test_coverage_required: {
|
|
277
|
-
id: 'test_coverage_required',
|
|
278
|
-
rule: 'TEST COVERAGE MUST MEET REQUIREMENTS',
|
|
279
|
-
message: '测试覆盖率必须达到要求',
|
|
280
|
-
level: 'guideline',
|
|
281
|
-
trigger: 'code_implementation',
|
|
282
|
-
enforcement: 'check-coverage',
|
|
283
|
-
description: `在提交代码前,测试覆盖率必须达到项目要求(默认 80%)。
|
|
284
|
-
|
|
285
|
-
检查命令:
|
|
286
|
-
- npm run test:coverage
|
|
287
|
-
- 查看覆盖率报告
|
|
288
|
-
|
|
289
|
-
提升覆盖率:
|
|
290
|
-
- 为未覆盖的分支添加测试
|
|
291
|
-
- 为边界条件添加测试`,
|
|
292
|
-
},
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* 设计决策需先讨论
|
|
296
|
-
* 例外:明确指令、紧急修复、已有设计文档
|
|
297
|
-
*/
|
|
298
|
-
design_decision_requires_discussion: {
|
|
299
|
-
id: 'design_decision_requires_discussion',
|
|
300
|
-
rule: 'DESIGN DECISIONS MUST BE DISCUSSED BEFORE IMPLEMENTATION',
|
|
301
|
-
message: '设计决策类任务需先讨论方案再实现',
|
|
302
|
-
level: 'guideline',
|
|
303
|
-
trigger: ['design_request', 'architecture_change', 'code_implementation'],
|
|
304
|
-
enforcement: 'require-discussion',
|
|
305
|
-
description: `当用户问"怎么实现"、"设计方案"时,应先:
|
|
306
|
-
|
|
307
|
-
1. 提供方案选项(至少 2 个)
|
|
308
|
-
- 方案 A: ...(优点/缺点)
|
|
309
|
-
- 方案 B: ...(优点/缺点)
|
|
310
|
-
|
|
311
|
-
2. 说明推荐方案和理由
|
|
312
|
-
|
|
313
|
-
3. 让用户选择或确认
|
|
314
|
-
|
|
315
|
-
4. 用户确认后再实现
|
|
316
|
-
|
|
317
|
-
[判断标准]
|
|
318
|
-
- 用户问"怎么实现"、"如何设计" → 设计决策
|
|
319
|
-
- 用户说"帮我做 xxx" → 执行任务
|
|
320
|
-
|
|
321
|
-
[例外]
|
|
322
|
-
- 用户明确说"直接做"、"不用问"
|
|
323
|
-
- 紧急修复
|
|
324
|
-
- 已有明确设计文档`,
|
|
325
|
-
exceptions: ['explicit_instruction', 'emergency_fix', 'existing_design'],
|
|
326
|
-
promptInjection: '涉及架构变更、新增依赖、API 设计等重大决策时,必须先提出讨论获得确认,再开始实现。不要凭单方面判断做架构决策。',
|
|
327
|
-
},
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* 覆盖率不能下降
|
|
331
|
-
* 例外:删除测试、重构核心逻辑
|
|
332
|
-
*/
|
|
333
|
-
no_coverage_decrease: {
|
|
334
|
-
id: 'no_coverage_decrease',
|
|
335
|
-
rule: 'COVERAGE MUST NOT DECREASE ON NEW COMMITS',
|
|
336
|
-
message: '新提交不能降低测试覆盖率',
|
|
337
|
-
level: 'guideline',
|
|
338
|
-
trigger: 'commit',
|
|
339
|
-
enforcement: 'coverage-gate',
|
|
340
|
-
description: `每次提交代码时,测试覆盖率不能低于上一次提交:
|
|
341
|
-
|
|
342
|
-
[检查方式]
|
|
343
|
-
- Git pre-commit hook 运行覆盖率检查
|
|
344
|
-
- GitHub Actions 在 PR 时验证
|
|
345
|
-
- 对比上一次覆盖率报告
|
|
346
|
-
|
|
347
|
-
[阈值要求]
|
|
348
|
-
- Statements ≥ 85%
|
|
349
|
-
- Branches ≥ 75%
|
|
350
|
-
- Functions ≥ 80%
|
|
351
|
-
- Lines ≥ 85%
|
|
352
|
-
|
|
353
|
-
[例外]
|
|
354
|
-
- 删除废弃功能
|
|
355
|
-
- 重构核心逻辑(需评审)
|
|
356
|
-
- 紧急修复(需后续补测)`,
|
|
357
|
-
exceptions: ['deprecated_removal', 'core_refactor_with_review', 'emergency_fix_pending_test'],
|
|
358
|
-
promptInjection: '代码覆盖率不得下降。新增代码必须有对应的测试覆盖。运行 npm test -- --coverage 验证覆盖率。',
|
|
359
|
-
},
|
|
360
|
-
|
|
361
74
|
/**
|
|
362
75
|
* 关键目录需要 CONTEXT.md
|
|
363
76
|
* 例外:临时目录、测试目录、生成代码目录
|
|
364
77
|
*/
|
|
365
78
|
context_doc_sync: {
|
|
366
79
|
id: 'context_doc_sync',
|
|
80
|
+
kind: 'check',
|
|
367
81
|
rule: 'KEY DIRECTORIES SHOULD HAVE CONTEXT.MD',
|
|
368
82
|
message: '关键目录缺少 CONTEXT.md,运行 harness sync-docs 创建模板后填写实际内容',
|
|
369
83
|
level: 'guideline',
|
|
@@ -385,286 +99,4 @@ export const GUIDELINES: Record<string, Constraint> = {
|
|
|
385
99
|
- 生成代码目录(dist、build、generated)`,
|
|
386
100
|
exceptions: ['temp_dir', 'test_dir', 'generated_code'],
|
|
387
101
|
},
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* 文档应与代码同步
|
|
391
|
-
* 例外:WIP 分支、实验性修改
|
|
392
|
-
*/
|
|
393
|
-
/**
|
|
394
|
-
* 禁止借口模式
|
|
395
|
-
* 例外:已有明确修复计划
|
|
396
|
-
* 来源:Superpowers 借口防御表
|
|
397
|
-
*/
|
|
398
|
-
no_excuse_patterns: {
|
|
399
|
-
id: 'no_excuse_patterns',
|
|
400
|
-
rule: 'NO EXCUSE PATTERNS WITHOUT CONCRETE ACTION PLAN',
|
|
401
|
-
message: '禁止借口模式,必须给出具体行动计划',
|
|
402
|
-
level: 'guideline',
|
|
403
|
-
trigger: ['code_implementation'],
|
|
404
|
-
enforcement: 'excuse-check',
|
|
405
|
-
description: `遇到困难时,禁止使用借口搪塞,必须给出具体的解决计划。
|
|
406
|
-
|
|
407
|
-
【禁止借口】
|
|
408
|
-
- "稍后修复" → 没有具体时间
|
|
409
|
-
- "小问题" → 没有影响评估
|
|
410
|
-
- "不影响功能" → 没有证据
|
|
411
|
-
- "以后再说" → 没有计划
|
|
412
|
-
- "先这样" → 没有后续步骤
|
|
413
|
-
- "临时方案" → 没有正式方案时间表
|
|
414
|
-
|
|
415
|
-
【必须】
|
|
416
|
-
- 说明问题的具体影响
|
|
417
|
-
- 给出修复的时间点或版本
|
|
418
|
-
- 如果是临时方案,说明正式方案的计划
|
|
419
|
-
|
|
420
|
-
【例外】
|
|
421
|
-
- 已有明确的修复计划(issue 编号 + 排期)`,
|
|
422
|
-
promptInjection: '遇到困难时,禁止使用借口搪塞(稍后修复、小问题、不影响功能、以后再说、先这样、临时方案)。必须给出:① 问题的具体影响;② 修复的时间点或版本;③ 如果是临时方案,说明正式方案的计划。',
|
|
423
|
-
exceptions: ['has_concrete_plan'],
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* YAGNI 检查:禁止过度设计
|
|
428
|
-
* 例外:已有明确扩展需求、多平台支持、安全强相关抽象
|
|
429
|
-
* 来源:Superpowers yagni_check
|
|
430
|
-
*/
|
|
431
|
-
yagni_check: {
|
|
432
|
-
id: 'yagni_check',
|
|
433
|
-
rule: 'NO SPECULATIVE GENERALIZATION WITHOUT CONCRETE USE CASE',
|
|
434
|
-
message: '禁止过度设计,遵循 YAGNI 原则',
|
|
435
|
-
level: 'guideline',
|
|
436
|
-
trigger: ['code_implementation', 'design_request'],
|
|
437
|
-
enforcement: 'yagni-check',
|
|
438
|
-
description: `遵循 YAGNI 原则(You Aren't Gonna Need It),不要为"未来可能需要"的需求添加代码。
|
|
439
|
-
|
|
440
|
-
【过度设计信号】
|
|
441
|
-
- 只有一个实现者的抽象(interface/abstract class 只有一个 class 实现)
|
|
442
|
-
- "以后可能会用到"的参数或配置项
|
|
443
|
-
- 为"未来扩展"预留的插件系统
|
|
444
|
-
- 超过当前需求的泛型化
|
|
445
|
-
|
|
446
|
-
【允许】
|
|
447
|
-
- 明确在 Spec/Roadmap 中规划的扩展
|
|
448
|
-
- 多个平台/环境需要不同实现
|
|
449
|
-
- 安全强相关的抽象(如加密算法可替换)
|
|
450
|
-
|
|
451
|
-
【判断标准】
|
|
452
|
-
如果一个抽象只有一个实现者 → 删除这个抽象`,
|
|
453
|
-
promptInjection: '遵循 YAGNI 原则(You Aren\'t Gonna Need It)。不要为"未来可能需要"的需求添加抽象层、接口、配置项或插件系统。如果一个 interface/abstract class 只有一个实现者,删除这个抽象。只实现当前明确需要的功能。',
|
|
454
|
-
exceptions: ['planned_extension', 'multi_platform', 'security_abstraction'],
|
|
455
|
-
},
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* 禁止无验证完成声明
|
|
459
|
-
* 原因:口头声明"done"与实际情况不符,需要可复现的证据
|
|
460
|
-
*/
|
|
461
|
-
no_claim_without_evidence: {
|
|
462
|
-
id: 'no_claim_without_evidence',
|
|
463
|
-
rule: 'NO "DONE" CLAIM WITHOUT VERIFIABLE EVIDENCE',
|
|
464
|
-
message: '禁止无验证的完成声明,必须提供可复现的验证证据',
|
|
465
|
-
level: 'guideline',
|
|
466
|
-
trigger: ['code_implementation', 'file_deletion', 'module_modification'],
|
|
467
|
-
enforcement: 'evidence-check',
|
|
468
|
-
description: `声称任何任务"完成"前,必须提供验证证据:
|
|
469
|
-
【代码完成】提供 test 输出(如 "142 passed, 0 failed")
|
|
470
|
-
【文件删除】提供 ls 确认(如 "ls pkg/ → No such file")
|
|
471
|
-
【Spec 完成】提供逐 AC 对照表(每项 pass/fail)
|
|
472
|
-
【文档更新】提供 grep 确认(如 "grep '遗留' CLAUDE.md → no match")`,
|
|
473
|
-
promptInjection: '声称任务"完成"前,必须提供可复现的验证证据:test 输出数字、ls 文件确认、grep 文档确认、spec AC 逐项对照。禁止"我记得""之前说""大部分"等无验证声明。',
|
|
474
|
-
},
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* 禁止无上下文删除
|
|
478
|
-
* 原因:删除代码前应评估是否有可吸收的功能,避免丢弃有用设计
|
|
479
|
-
*/
|
|
480
|
-
no_delete_without_context: {
|
|
481
|
-
id: 'no_delete_without_context',
|
|
482
|
-
rule: 'NO DELETION WITHOUT DESIGN DOCUMENT REVIEW',
|
|
483
|
-
message: '禁止删除代码前未审查设计文档和吸收价值',
|
|
484
|
-
level: 'guideline',
|
|
485
|
-
trigger: ['file_deletion', 'module_deletion'],
|
|
486
|
-
enforcement: 'context-check',
|
|
487
|
-
description: `删除任何代码(包/模块/文件)前,必须:
|
|
488
|
-
1. 查设计文档(CLAUDE.md / roadmap / specs)
|
|
489
|
-
2. 分析是否有可吸收的功能
|
|
490
|
-
3. 查替代函数是否丢失了关键设计模式(零引用≠无价值)
|
|
491
|
-
4. 分类:未接线(应接线)/ 被替代但有可吸收设计 / 真正无用
|
|
492
|
-
5. 记录分析结论(有/无吸收价值,原因)`,
|
|
493
|
-
promptInjection: '删除任何代码前,先查设计意图(JSDoc/commit/spec),分析被替代的函数是否有丢失的关键模式。零引用≠无价值。分类:未接线→接线,被替代→吸收模式,真正无用→才删。',
|
|
494
|
-
},
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* 外科手术式修改 — Mnilax Rule 3
|
|
498
|
-
* 原因:只改必要部分,不顺手改相邻代码
|
|
499
|
-
*/
|
|
500
|
-
surgical_changes_only: {
|
|
501
|
-
id: 'surgical_changes_only',
|
|
502
|
-
rule: 'ONLY CHANGE WHAT IS ABSOLUTELY NECESSARY',
|
|
503
|
-
message: '只改必要部分,不顺手改相邻代码和格式',
|
|
504
|
-
level: 'guideline',
|
|
505
|
-
trigger: ['code_implementation', 'file_modification'],
|
|
506
|
-
enforcement: 'surgical-check',
|
|
507
|
-
description: `仅改动绝对必要的部分。不"顺手优化"相邻代码、注释或排版格式。未出问题的代码不重构。严格贴合项目既有风格。`,
|
|
508
|
-
promptInjection: '外科手术式修改:仅改动绝对必要的部分。不顺手"优化"相邻代码、注释或格式。未出问题的代码不重构。',
|
|
509
|
-
injectPrompt: true,
|
|
510
|
-
},
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* 模型只做判断 — Mnilax Rule 5
|
|
514
|
-
* 原因:路由/重试/状态码用代码比 LLM 可靠
|
|
515
|
-
*/
|
|
516
|
-
no_model_for_deterministic: {
|
|
517
|
-
id: 'no_model_for_deterministic',
|
|
518
|
-
rule: 'USE MODEL ONLY FOR JUDGMENT CALLS, NOT DETERMINISTIC LOGIC',
|
|
519
|
-
message: '路由/重试/状态码处理→代码,不要调 LLM 决策',
|
|
520
|
-
level: 'guideline',
|
|
521
|
-
trigger: ['code_implementation'],
|
|
522
|
-
enforcement: 'deterministic-check',
|
|
523
|
-
description: `仅将模型用于需要判断与裁量的场景:分类、内容起草、摘要、信息提取。切勿将模型用于:路由分发、重试机制、状态码处理、确定性数据转换。若常规代码能给出答案,就由代码处理。`,
|
|
524
|
-
promptInjection: '模型只做判断不做决策:路由、重试、状态码处理→用代码,不调 LLM。若常规代码能给出答案,就由代码处理。',
|
|
525
|
-
injectPrompt: true,
|
|
526
|
-
},
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* 暴露冲突 — Mnilax Rule 7
|
|
530
|
-
* 原因:两种模式冲突时不要折中
|
|
531
|
-
*/
|
|
532
|
-
no_conflict_blending: {
|
|
533
|
-
id: 'no_conflict_blending',
|
|
534
|
-
rule: 'SURFACE CONFLICTS, DO NOT BLEND THEM',
|
|
535
|
-
message: '两种模式冲突→选其一+说明理由,不折中',
|
|
536
|
-
level: 'guideline',
|
|
537
|
-
trigger: ['code_implementation', 'module_extension'],
|
|
538
|
-
enforcement: 'conflict-check',
|
|
539
|
-
description: `若代码库中既有的两种模式相互矛盾,明确选择其一(优先更新或更经测试的版本),阐明选择理由,将另一种标记为待清理项。试图同时迎合两套规则的中庸代码往往是最糟的。`,
|
|
540
|
-
promptInjection: '暴露冲突不折中:若两种模式冲突→选其一(优先更经测试的版本)+说明理由+标记另一种为待清理。',
|
|
541
|
-
injectPrompt: true,
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* 先读后写 — Mnilax Rule 8
|
|
546
|
-
* 原因:加代码前必须理解上下文
|
|
547
|
-
*/
|
|
548
|
-
read_before_write: {
|
|
549
|
-
id: 'read_before_write',
|
|
550
|
-
rule: 'READ IMPORTS AND CALLERS BEFORE ADDING CODE',
|
|
551
|
-
message: '加代码前先读文件的导入、调用方、工具函数',
|
|
552
|
-
level: 'guideline',
|
|
553
|
-
trigger: ['code_implementation', 'file_modification'],
|
|
554
|
-
enforcement: 'read-check',
|
|
555
|
-
description: `在文件中添加代码前,必须通读该文件的导出接口、直接调用方以及任何显而易见的公共工具函数。"看似互不干涉"是最危险的判断。若不理解现有代码为何采用当前结构,在动手添加前必须先提问确认。`,
|
|
556
|
-
promptInjection: '先读后写:加代码前读 imports/callers/工具函数。"看似互不干涉"是最危险的判断。不理解现有结构时先提问。',
|
|
557
|
-
injectPrompt: true,
|
|
558
|
-
},
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* 约定胜于新奇 — Mnilax Rule 11
|
|
562
|
-
* 原因:规范一致性 > 技术偏好
|
|
563
|
-
*/
|
|
564
|
-
follow_conventions: {
|
|
565
|
-
id: 'follow_conventions',
|
|
566
|
-
rule: 'MATCH CODEBASE CONVENTIONS, EVEN IF YOU DISAGREE',
|
|
567
|
-
message: '规范一致性 > 技术偏好,有异议显式提出不暗中背离',
|
|
568
|
-
level: 'guideline',
|
|
569
|
-
trigger: ['code_implementation', 'module_extension'],
|
|
570
|
-
enforcement: 'convention-check',
|
|
571
|
-
description: `在代码库内部:规范一致性 > 个人技术偏好。若项目用 snake_case 而你偏好 camelCase:用 snake_case。若项目用 class 组件而你偏好 hooks:用 class。若确信某规范存在实质危害,请显式提出。切勿暗中背离规范另起范式。`,
|
|
572
|
-
promptInjection: '约定胜于新奇:规范一致性 > 技术偏好。项目用 snake_case 就用 snake_case。有异议显式提出,不暗中另起范式。',
|
|
573
|
-
injectPrompt: true,
|
|
574
|
-
},
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* 第一性优先 — Mnilax extension
|
|
578
|
-
* 原因:从当前状态推导结论会自我证明。正确顺序:第一性→事实校验→结论。
|
|
579
|
-
*/
|
|
580
|
-
first_principles_first: {
|
|
581
|
-
id: 'first_principles_first',
|
|
582
|
-
rule: 'ANALYZE FROM FIRST PRINCIPLES, NOT FROM CURRENT STATE',
|
|
583
|
-
message: '分析顺序: 第一性→事实校验→结论。禁止"代码就是这样"作为理由',
|
|
584
|
-
level: 'guideline',
|
|
585
|
-
trigger: ['code_implementation', 'module_modification', 'file_modification'],
|
|
586
|
-
enforcement: 'principle-check',
|
|
587
|
-
description: `架构分析与设计决策必须从第一性原理出发,而非从当前实现状态推导。禁止的模式: "当前代码这样写的所以应该保持这样"——这是自我证明的错误逻辑。`,
|
|
588
|
-
promptInjection: '第一性优先: 分析设计问题从本质出发,不从当前代码推导。正确设计是什么→当前实现匹配吗→差距决定行动。禁止"代码就是这样"作为理由。',
|
|
589
|
-
injectPrompt: true,
|
|
590
|
-
},
|
|
591
|
-
|
|
592
|
-
/**
|
|
593
|
-
/**
|
|
594
|
-
* 原因:质量门阻断是信号,不是障碍。调整门禁而非修复违规是自我欺骗。
|
|
595
|
-
*/
|
|
596
|
-
fix_the_problem_not_the_gate: {
|
|
597
|
-
id: 'fix_the_problem_not_the_gate',
|
|
598
|
-
rule: 'FIX THE PROBLEM THAT TRIGGERED THE GATE, NOT THE GATE ITSELF',
|
|
599
|
-
message: '修复触发门禁的问题,不降低门禁本身',
|
|
600
|
-
level: 'guideline',
|
|
601
|
-
trigger: ['code_implementation', 'module_modification', 'file_modification'],
|
|
602
|
-
enforcement: 'principle-check',
|
|
603
|
-
description: `质量门禁(测试失败、lint 报错、覆盖率不足、约束违规)阻断时,修复导致阻断的代码,而非调整门禁门槛。降低阈值、删除测试、关闭 lint 规则是对质量信号的压制,不是质量改进。`,
|
|
604
|
-
promptInjection: '质量门禁阻断时修复代码,不修复门禁。不降阈值、不删测试、不关 lint、不改断言让 CI 通过。',
|
|
605
|
-
injectPrompt: true,
|
|
606
|
-
},
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* 下游修复前先诊断上游
|
|
610
|
-
* 原因:兼容/兜底是掩盖,不是修复。连续 fallback 同一位置 2+ 次是上游 bug 信号。
|
|
611
|
-
*/
|
|
612
|
-
no_fallback_without_root_cause: {
|
|
613
|
-
id: 'no_fallback_without_root_cause',
|
|
614
|
-
rule: 'BEFORE ADDING FALLBACK, TRACE UPSTREAM FIRST',
|
|
615
|
-
message: '禁止用兼容/兜底掩盖上游数据异常。先追根因——谁产生的?为什么是空?',
|
|
616
|
-
level: 'guideline',
|
|
617
|
-
trigger: ['code_implementation', 'module_modification', 'file_modification'],
|
|
618
|
-
enforcement: 'principle-check',
|
|
619
|
-
description: `遇到空值/异常/不完整数据时,禁止直接用 fallback/default/兜底值掩盖。必须先追踪数据来源——哪个上游产生的?为什么异常?修复上游 OR 添加防御性兜底——选择后者时必须在代码注释中说明根因。重复 fallback 同一问题 2+ 次是 sign of upstream bug。`,
|
|
620
|
-
promptInjection: '改动前先问: 数据从哪来?为什么是空的?fix upstream first, fallback second。连续 2+ 次相同错误 → 停止修下游,追踪源头。',
|
|
621
|
-
injectPrompt: true,
|
|
622
|
-
},
|
|
623
|
-
|
|
624
|
-
/**
|
|
625
|
-
* 诊断→修复闸门:必须先呈现确认的根因+方案才能编辑,禁止 Read→Edit 直跳
|
|
626
|
-
* 原因:读代码定位问题后直接改,不查设计意图、不验证假设,是"凭猜测修 bug"
|
|
627
|
-
*/
|
|
628
|
-
diagnosis_to_fix_gate: {
|
|
629
|
-
id: 'diagnosis_to_fix_gate',
|
|
630
|
-
rule: 'PRESENT ROOT CAUSE + FIX PLAN BEFORE EDITING CODE',
|
|
631
|
-
message: '诊断出根因后,必须先呈现方案+设计原型对照,禁止从 Read 直接跳到 Edit',
|
|
632
|
-
level: 'guideline',
|
|
633
|
-
trigger: ['code_implementation', 'module_modification', 'file_modification'],
|
|
634
|
-
enforcement: 'principle-check',
|
|
635
|
-
description: `用 Read/Grep 定位问题后,禁止立即 Edit 修改。必须先:① 确认根因(不止是"哪里出错",而是"为什么设计成这样");② 检查设计原型/文档(CLAUDE.md、类型定义、commit message),确认原设计意图;③ 提出方案草案。满足以上三条后才能 Edit。违反此约束会导致"改了但不对"——因为根本没理解代码为什么那么写。`,
|
|
636
|
-
promptInjection: '诊断→修复闸门: 读代码定位根因后,必须先查设计原型(为什么这么写?CLAUDE.md/类型定义/commit message),呈现确认的根因+方案草案,然后才能 Edit。禁止 Read→Edit 直跳,禁止对现有设计做未经原型对照的语义变更。',
|
|
637
|
-
injectPrompt: true,
|
|
638
|
-
},
|
|
639
|
-
|
|
640
|
-
/**
|
|
641
|
-
* 分析闸门:从数据到结论之间,必须先验证关键假设的含义和量纲
|
|
642
|
-
* 原因:看到可疑数字直接跳结论而跳过验证是诊断错误的第一来源(累积 vs 单次、正常 vs 异常、相关 vs 因果)
|
|
643
|
-
*/
|
|
644
|
-
analysis_verification_gate: {
|
|
645
|
-
id: 'analysis_verification_gate',
|
|
646
|
-
rule: 'VERIFY KEY ASSUMPTIONS BEFORE DRAWING CONCLUSIONS FROM DATA',
|
|
647
|
-
message: '从数据到结论之间,必须先验证关键假设的含义和量纲',
|
|
648
|
-
level: 'guideline',
|
|
649
|
-
trigger: ['code_implementation', 'design_request', 'module_modification', 'file_modification', 'diagnosis'],
|
|
650
|
-
enforcement: 'principle-check',
|
|
651
|
-
description: `从代码/日志/指标中发现异常数据时,禁止直接从"数字异常"跳到"根因结论"。必须先验证:① 数字的含义(累积/单次?量纲是什么?);② 正常范围(这个数值在健康状态下是多少?);③ 对比验证(同类场景下是什么值?有无反例?)。验证完关键假设后,再进行因果推断和方案设计。违反此约束导致"翻烧饼"——因为结论建立在未经验证的假设上。`,
|
|
652
|
-
promptInjection: '分析闸门: 从数据到结论必须验证关键假设。一个异常数字≠根因——先确认含义(累积/单次?量纲?正常范围?同类对比?),再推断因果。禁止"数字A太大→一定是B导致的→应该改C"这种跳级推理。',
|
|
653
|
-
injectPrompt: true,
|
|
654
|
-
},
|
|
655
|
-
|
|
656
|
-
/**
|
|
657
|
-
* 禁止硬编码凭证
|
|
658
|
-
* 原因:密码/token/密钥泄露是最严重的安全漏洞,一旦提交到版本控制即不可逆
|
|
659
|
-
*/
|
|
660
|
-
no_hardcoded_credentials: {
|
|
661
|
-
id: 'no_hardcoded_credentials',
|
|
662
|
-
rule: 'NO HARDCODED PASSWORDS, TOKENS, SECRETS, OR CREDENTIALS IN ANY SOURCE FILE',
|
|
663
|
-
message: '禁止在代码/文档/配置文件中硬编码密码、token、密钥、API key',
|
|
664
|
-
level: 'guideline',
|
|
665
|
-
trigger: ['code_implementation', 'doc_update', 'config_change', 'commit'],
|
|
666
|
-
enforcement: 'credential-scan',
|
|
667
|
-
description: `凭证(密码/token/密钥/API key)必须从环境变量或加密配置读取,严禁以明文形式出现在任何源代码文件中。包括但不限于:源码、Markdown 文档、YAML/JSON 配置、脚本文件。模板文件(.example/.sample/.template)允许占位符但不得包含真实值。建议配合 pre-commit hook 做自动扫描。`,
|
|
668
|
-
promptInjection: '禁止在代码中硬编码密码、API 密钥、Token 等凭证。使用环境变量或安全的凭证管理方案存储敏感信息。',
|
|
669
|
-
},
|
|
670
102
|
};
|