@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,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 约束注册表
|
|
3
|
-
*
|
|
4
|
-
* 基于 core/constraints/definitions 构建,附加分层和退化元数据。
|
|
5
|
-
* 分层规则:iron_law → safety(高阈值),guideline/tip → quality(低阈值)
|
|
6
|
-
* 所有层级均可退化,区别仅在于退化阈值。
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import type { Constraint, ConstraintLevel, ConstraintTrigger } from '../types/constraint';
|
|
10
|
-
import type { LayeredConstraint, ConstraintLayer, DeprecationStatus, LayerStats, DeprecationSchedule } from './types';
|
|
11
|
-
import { IRON_LAWS, GUIDELINES, TIPS } from '../core/constraints/definitions';
|
|
12
|
-
|
|
13
|
-
function toLayered(constraint: Constraint): LayeredConstraint {
|
|
14
|
-
const layer: ConstraintLayer = constraint.level === 'iron_law' ? 'safety' : 'quality';
|
|
15
|
-
const schedule: DeprecationSchedule = layer === 'safety'
|
|
16
|
-
? { targetLevel: 'guideline' as ConstraintLevel, reason: '退化:拦截率持续低于 5%', rollbackable: true }
|
|
17
|
-
: { targetLevel: (constraint.level === 'guideline' ? 'tip' : 'info') as ConstraintLevel, reason: '退化:拦截率持续低于 30%', rollbackable: true };
|
|
18
|
-
return {
|
|
19
|
-
...constraint,
|
|
20
|
-
layer,
|
|
21
|
-
deprecationStatus: 'active' as DeprecationStatus,
|
|
22
|
-
permanent: false,
|
|
23
|
-
deprecationSchedule: schedule,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export class ConstraintRegistry {
|
|
28
|
-
private constraints: Map<string, LayeredConstraint>;
|
|
29
|
-
|
|
30
|
-
constructor() {
|
|
31
|
-
this.constraints = new Map();
|
|
32
|
-
const all = { ...IRON_LAWS, ...GUIDELINES, ...TIPS };
|
|
33
|
-
for (const [id, constraint] of Object.entries(all)) {
|
|
34
|
-
this.constraints.set(id, toLayered(constraint));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
get(id: string): LayeredConstraint | undefined {
|
|
39
|
-
return this.constraints.get(id);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getAll(): LayeredConstraint[] {
|
|
43
|
-
return Array.from(this.constraints.values());
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getByLayer(layer: ConstraintLayer): LayeredConstraint[] {
|
|
47
|
-
return this.getAll().filter(c => c.layer === layer);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
getByStatus(status: DeprecationStatus): LayeredConstraint[] {
|
|
51
|
-
return this.getAll().filter(c => c.deprecationStatus === status);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
getByTrigger(trigger: ConstraintTrigger): LayeredConstraint[] {
|
|
55
|
-
return this.getAll().filter(c => {
|
|
56
|
-
const triggers = Array.isArray(c.trigger) ? c.trigger : [c.trigger];
|
|
57
|
-
return triggers.includes(trigger);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getDeprecationCandidates(interceptRates: Map<string, number>): LayeredConstraint[] {
|
|
62
|
-
return this.getAll().filter(c => {
|
|
63
|
-
if (c.layer !== 'quality' || !c.deprecationSchedule) return false;
|
|
64
|
-
if (c.deprecationStatus !== 'active') return false;
|
|
65
|
-
const threshold = c.deprecationSchedule.interceptRateThreshold;
|
|
66
|
-
if (threshold === undefined) return false;
|
|
67
|
-
const rate = interceptRates.get(c.id);
|
|
68
|
-
return rate !== undefined && rate < threshold;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
degrade(id: string): boolean {
|
|
73
|
-
const constraint = this.constraints.get(id);
|
|
74
|
-
if (!constraint || !constraint.deprecationSchedule) return false;
|
|
75
|
-
if (constraint.deprecationStatus !== 'active') return false;
|
|
76
|
-
constraint.level = constraint.deprecationSchedule.targetLevel;
|
|
77
|
-
constraint.deprecationStatus = 'deprecated';
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
rollback(id: string, originalLevel: ConstraintLevel): boolean {
|
|
82
|
-
const constraint = this.constraints.get(id);
|
|
83
|
-
if (!constraint) return false;
|
|
84
|
-
if (!constraint.deprecationSchedule?.rollbackable) return false;
|
|
85
|
-
constraint.level = originalLevel;
|
|
86
|
-
constraint.deprecationStatus = 'active';
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
scheduleDeprecation(id: string, schedule: DeprecationSchedule): boolean {
|
|
91
|
-
const constraint = this.constraints.get(id);
|
|
92
|
-
if (!constraint || constraint.layer !== 'quality') return false;
|
|
93
|
-
constraint.deprecationSchedule = schedule;
|
|
94
|
-
constraint.deprecationStatus = 'scheduled';
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getLayerStats(): LayerStats[] {
|
|
99
|
-
const layers: ConstraintLayer[] = ['safety', 'quality'];
|
|
100
|
-
return layers.map(layer => {
|
|
101
|
-
const constraints = this.getByLayer(layer);
|
|
102
|
-
return {
|
|
103
|
-
layer,
|
|
104
|
-
totalConstraints: constraints.length,
|
|
105
|
-
active: constraints.filter(c => c.deprecationStatus === 'active').length,
|
|
106
|
-
scheduled: constraints.filter(c => c.deprecationStatus === 'scheduled').length,
|
|
107
|
-
deprecated: constraints.filter(c => c.deprecationStatus === 'deprecated').length,
|
|
108
|
-
removed: constraints.filter(c => c.deprecationStatus === 'removed').length,
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
toLegacyConstraints(): Constraint[] {
|
|
114
|
-
return this.getAll().map(c => ({
|
|
115
|
-
id: c.id,
|
|
116
|
-
rule: c.rule,
|
|
117
|
-
message: c.message,
|
|
118
|
-
level: c.level,
|
|
119
|
-
trigger: c.trigger,
|
|
120
|
-
enforcement: c.enforcement,
|
|
121
|
-
description: c.description,
|
|
122
|
-
enabled: c.enabled,
|
|
123
|
-
exceptions: c.exceptions,
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
register(constraint: LayeredConstraint): void {
|
|
128
|
-
this.constraints.set(constraint.id, constraint);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
remove(id: string): boolean {
|
|
132
|
-
return this.constraints.delete(id);
|
|
133
|
-
}
|
|
134
|
-
}
|
package/src/constraints/types.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 约束分层类型定义
|
|
3
|
-
*
|
|
4
|
-
* 在原有 Constraint 基础上增加分层和退化元数据
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Constraint, ConstraintLevel } from '../types/constraint';
|
|
8
|
-
|
|
9
|
-
/** 约束分层 */
|
|
10
|
-
export type ConstraintLayer = 'safety' | 'quality';
|
|
11
|
-
|
|
12
|
-
/** 退化状态 */
|
|
13
|
-
export type DeprecationStatus = 'active' | 'scheduled' | 'deprecated' | 'removed';
|
|
14
|
-
|
|
15
|
-
/** 退化计划 */
|
|
16
|
-
export interface DeprecationSchedule {
|
|
17
|
-
/** 目标级别(当前 → 目标) */
|
|
18
|
-
targetLevel: ConstraintLevel;
|
|
19
|
-
/** 触发条件:拦截率低于此值时触发退化 */
|
|
20
|
-
interceptRateThreshold?: number;
|
|
21
|
-
/** 计划退化日期 */
|
|
22
|
-
scheduledDate?: string;
|
|
23
|
-
/** 退化原因 */
|
|
24
|
-
reason: string;
|
|
25
|
-
/** 是否可回滚 */
|
|
26
|
-
rollbackable: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** 带分层元数据的约束 */
|
|
30
|
-
export interface LayeredConstraint extends Constraint {
|
|
31
|
-
/** 所属层 */
|
|
32
|
-
layer: ConstraintLayer;
|
|
33
|
-
/** 退化状态 */
|
|
34
|
-
deprecationStatus: DeprecationStatus;
|
|
35
|
-
/** 退化计划(所有层均有,iron_law 高阈值,guideline/tip 低阈值) */
|
|
36
|
-
deprecationSchedule?: DeprecationSchedule;
|
|
37
|
-
/** 是否永久保留(false = 所有层均可退化,区别仅在于阈值) */
|
|
38
|
-
permanent?: boolean;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** 约束拦截统计 */
|
|
42
|
-
export interface ConstraintStats {
|
|
43
|
-
constraintId: string;
|
|
44
|
-
triggerCount: number;
|
|
45
|
-
passCount: number;
|
|
46
|
-
interceptCount: number;
|
|
47
|
-
interceptRate: number;
|
|
48
|
-
lastTriggered?: string;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** 约束层统计汇总 */
|
|
52
|
-
export interface LayerStats {
|
|
53
|
-
layer: ConstraintLayer;
|
|
54
|
-
totalConstraints: number;
|
|
55
|
-
active: number;
|
|
56
|
-
scheduled: number;
|
|
57
|
-
deprecated: number;
|
|
58
|
-
removed: number;
|
|
59
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 恒通过检查组(工单 21)
|
|
3
|
-
*
|
|
4
|
-
* 行为类约束由 promptInjection 注入驱动 + 事后检查,检查器侧恒通过;
|
|
5
|
-
* Tips 仅作信息提示。这些约束无独立检查逻辑,故集中一处。
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { alwaysPass } from './types';
|
|
9
|
-
|
|
10
|
-
// Mnilax guidelines + first-principles(injectPrompt=true,行为层,事后检查)
|
|
11
|
-
export const surgicalChangesOnly = alwaysPass('surgical_changes_only');
|
|
12
|
-
export const noModelForDeterministic = alwaysPass('no_model_for_deterministic');
|
|
13
|
-
export const noConflictBlending = alwaysPass('no_conflict_blending');
|
|
14
|
-
export const readBeforeWrite = alwaysPass('read_before_write');
|
|
15
|
-
export const followConventions = alwaysPass('follow_conventions');
|
|
16
|
-
export const firstPrinciplesFirst = alwaysPass('first_principles_first');
|
|
17
|
-
export const fixTheProblemNotTheGate = alwaysPass('fix_the_problem_not_the_gate');
|
|
18
|
-
export const diagnosisToFixGate = alwaysPass('diagnosis_to_fix_gate');
|
|
19
|
-
|
|
20
|
-
// Tips — 总是通过(仅提示)
|
|
21
|
-
export const readmeRequired = alwaysPass('readme_required');
|
|
22
|
-
export const docRequiredForPublicApi = alwaysPass('doc_required_for_public_api');
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 指导原则层轻量检查(工单 21):纯上下文证据标志判定,无 I/O
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { contextFlag } from './types';
|
|
6
|
-
|
|
7
|
-
export const noFixWithoutRootCause = contextFlag(
|
|
8
|
-
'no_fix_without_root_cause',
|
|
9
|
-
ctx => ctx.hasRootCauseInvestigation === true
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
export const noCodeWithoutTest = contextFlag(
|
|
13
|
-
'no_code_without_test',
|
|
14
|
-
ctx => ctx.hasFailingTest === true
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
export const simplestSolutionFirst = contextFlag(
|
|
18
|
-
'simplest_solution_first',
|
|
19
|
-
ctx => ctx.hasReuseCheck === true
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
export const noCreationWithoutReuseCheck = contextFlag(
|
|
23
|
-
'no_creation_without_reuse_check',
|
|
24
|
-
ctx => ctx.hasReuseCheck === true
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
export const noSkillWithoutTest = contextFlag(
|
|
28
|
-
'no_skill_without_test',
|
|
29
|
-
ctx => ctx.hasTest === true
|
|
30
|
-
);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* no_any_type:变更 TS 文件不得出现 `: any`(工单 21)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { existsSync, readFileSync } from 'fs';
|
|
6
|
-
import type { ConstraintCheck } from './types';
|
|
7
|
-
|
|
8
|
-
export const noAnyType: ConstraintCheck = {
|
|
9
|
-
id: 'no_any_type',
|
|
10
|
-
async evaluate(env) {
|
|
11
|
-
try {
|
|
12
|
-
const changedFiles = env.context.changedFiles || [];
|
|
13
|
-
const filesToCheck = changedFiles.filter(
|
|
14
|
-
f => f.endsWith('.ts') || f.endsWith('.tsx')
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
if (filesToCheck.length === 0) {
|
|
18
|
-
return true; // 无 TS 文件变更
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
for (const file of filesToCheck) {
|
|
22
|
-
if (!existsSync(file)) continue;
|
|
23
|
-
try {
|
|
24
|
-
const content = readFileSync(file, 'utf-8');
|
|
25
|
-
// 检查 : any(排除注释和字符串)
|
|
26
|
-
for (const line of content.split('\n')) {
|
|
27
|
-
if (line.trim().startsWith('//') || line.trim().startsWith('*')) continue;
|
|
28
|
-
if (line.includes(': any') && !line.includes('// ') && !line.includes('/*')) {
|
|
29
|
-
return false; // 发现 any 类型
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
} catch {
|
|
33
|
-
// 文件读取失败,忽略
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return true;
|
|
38
|
-
} catch {
|
|
39
|
-
return true; // 检查失败,默认通过
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* no_excuse_patterns:完成声明不得包含借口模式(工单 21)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ConstraintCheck } from './types';
|
|
6
|
-
|
|
7
|
-
const EXCUSE_PATTERNS = [
|
|
8
|
-
/稍后修复/,
|
|
9
|
-
/小问题/,
|
|
10
|
-
/不影响功能/,
|
|
11
|
-
/以后再说/,
|
|
12
|
-
/先这样/,
|
|
13
|
-
/临时方案/,
|
|
14
|
-
/暂时这样/,
|
|
15
|
-
];
|
|
16
|
-
|
|
17
|
-
export const noExcusePatterns: ConstraintCheck = {
|
|
18
|
-
id: 'no_excuse_patterns',
|
|
19
|
-
evaluate(env) {
|
|
20
|
-
const text = env.context.completionClaimText || env.context.taskDescription || '';
|
|
21
|
-
if (!text) return true;
|
|
22
|
-
return !EXCUSE_PATTERNS.some(p => p.test(text));
|
|
23
|
-
},
|
|
24
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* no_fuzzy_completion_claim:完成声明不得包含模糊词(工单 21)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ConstraintCheck } from './types';
|
|
6
|
-
|
|
7
|
-
const FUZZY_PATTERNS = [
|
|
8
|
-
/应该没问题/,
|
|
9
|
-
/应该可以/,
|
|
10
|
-
/大概/,
|
|
11
|
-
/可能/,
|
|
12
|
-
/好像/,
|
|
13
|
-
/似乎/,
|
|
14
|
-
/差不多/,
|
|
15
|
-
/基本完成/,
|
|
16
|
-
/大部分/,
|
|
17
|
-
// audit-learned (2026-05-18): unverified completion claims
|
|
18
|
-
/我记得删[过掉]了/,
|
|
19
|
-
/之前说删了/,
|
|
20
|
-
/已删除.*但/,
|
|
21
|
-
/大部分实现/,
|
|
22
|
-
/大部分完成/,
|
|
23
|
-
/已修复.*但/,
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
export const noFuzzyCompletionClaim: ConstraintCheck = {
|
|
27
|
-
id: 'no_fuzzy_completion_claim',
|
|
28
|
-
evaluate(env) {
|
|
29
|
-
const text = env.context.completionClaimText || '';
|
|
30
|
-
if (!text) return true; // 没有文本时默认通过(由其他检查覆盖)
|
|
31
|
-
return !FUZZY_PATTERNS.some(p => p.test(text));
|
|
32
|
-
},
|
|
33
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* no_performative_agreement:表演性同意辅助检查(工单 21)
|
|
3
|
-
*
|
|
4
|
-
* 主要由 promptInjection 驱动,此处做辅助检查。
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ConstraintCheck } from './types';
|
|
8
|
-
|
|
9
|
-
const PERFORMATIVE_START = /^(好的[,,]*\s*我[来去]做|明白了[,,]*|没问题[,,]*|ok[,,]*\s*i.?ll)/i;
|
|
10
|
-
|
|
11
|
-
export const noPerformativeAgreement: ConstraintCheck = {
|
|
12
|
-
id: 'no_performative_agreement',
|
|
13
|
-
evaluate(env) {
|
|
14
|
-
const text = env.context.taskDescription || '';
|
|
15
|
-
if (!text) return true;
|
|
16
|
-
// 以表演性模式开头且总长度很短 → 视为表演性同意
|
|
17
|
-
if (PERFORMATIVE_START.test(text) && text.length < 100) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* no_simplification_without_approval:staged diff 不得含简化关键词(工单 21)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { ConstraintCheck } from './types';
|
|
6
|
-
|
|
7
|
-
const SIMPLIFICATION_PATTERNS = [
|
|
8
|
-
/removed\s*test/i,
|
|
9
|
-
/simplified\s*logic/i,
|
|
10
|
-
/removed\s*validation/i,
|
|
11
|
-
/skip\s*check/i,
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
export const noSimplificationWithoutApproval: ConstraintCheck = {
|
|
15
|
-
id: 'no_simplification_without_approval',
|
|
16
|
-
async evaluate(env) {
|
|
17
|
-
try {
|
|
18
|
-
const diff = await env.stagedDiff();
|
|
19
|
-
for (const pattern of SIMPLIFICATION_PATTERNS) {
|
|
20
|
-
if (pattern.test(diff)) {
|
|
21
|
-
return false; // 发现简化关键词
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
} catch {
|
|
26
|
-
return true; // 检查失败,默认通过
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* test_coverage_required:读取 coverage 报告校验行覆盖率(工单 21)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { existsSync, readFileSync } from 'fs';
|
|
6
|
-
import { join } from 'path';
|
|
7
|
-
import type { ConstraintCheck } from './types';
|
|
8
|
-
|
|
9
|
-
export const testCoverageRequired: ConstraintCheck = {
|
|
10
|
-
id: 'test_coverage_required',
|
|
11
|
-
async evaluate(env) {
|
|
12
|
-
const projectPath = env.projectPath;
|
|
13
|
-
try {
|
|
14
|
-
const coverageJsonPath = join(projectPath, 'coverage', 'coverage-final.json');
|
|
15
|
-
const coverageSummaryPath = join(projectPath, 'coverage', 'coverage-summary.json');
|
|
16
|
-
|
|
17
|
-
if (!existsSync(coverageJsonPath) && !existsSync(coverageSummaryPath)) {
|
|
18
|
-
return true; // 无 coverage 报告,默认通过
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (existsSync(coverageSummaryPath)) {
|
|
22
|
-
const summary = JSON.parse(readFileSync(coverageSummaryPath, 'utf-8'));
|
|
23
|
-
const total = summary.total || {};
|
|
24
|
-
const linesCoverage = total.lines?.pct || 0;
|
|
25
|
-
|
|
26
|
-
// 默认要求 50% 覆盖率(可配置)
|
|
27
|
-
return linesCoverage >= 50;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return true;
|
|
31
|
-
} catch {
|
|
32
|
-
return true; // 检查失败,默认通过
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* yagni_check:过度设计信号 — 只有一个实现的 interface/abstract class(工单 21)
|
|
3
|
-
*
|
|
4
|
-
* 主要由 promptInjection 驱动,这里是辅助检查。
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import * as fs from 'fs';
|
|
8
|
-
import * as path from 'path';
|
|
9
|
-
import type { ConstraintCheck } from './types';
|
|
10
|
-
|
|
11
|
-
export const yagniCheck: ConstraintCheck = {
|
|
12
|
-
id: 'yagni_check',
|
|
13
|
-
async evaluate(env) {
|
|
14
|
-
const projectPath = env.projectPath;
|
|
15
|
-
const changedFiles = env.context.changedFiles;
|
|
16
|
-
|
|
17
|
-
// 无上下文时默认通过(主要由 promptInjection 驱动)
|
|
18
|
-
if (!projectPath || !changedFiles || changedFiles.length === 0) return true;
|
|
19
|
-
|
|
20
|
-
try {
|
|
21
|
-
for (const file of changedFiles) {
|
|
22
|
-
if (!file.endsWith('.ts') && !file.endsWith('.tsx')) continue;
|
|
23
|
-
|
|
24
|
-
const filePath = path.join(projectPath, file);
|
|
25
|
-
if (!fs.existsSync(filePath)) continue;
|
|
26
|
-
|
|
27
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
28
|
-
|
|
29
|
-
// 检查是否有 export interface/abstract class
|
|
30
|
-
const hasInterface = /export\s+(?:default\s+)?interface\s+(\w+)/g;
|
|
31
|
-
const hasAbstract = /export\s+(?:default\s+)?abstract\s+class\s+(\w+)/g;
|
|
32
|
-
|
|
33
|
-
const interfaces = [...content.matchAll(hasInterface)].map(m => m[1]);
|
|
34
|
-
const abstracts = [...content.matchAll(hasAbstract)].map(m => m[1]);
|
|
35
|
-
|
|
36
|
-
const exportedTypes = [...interfaces, ...abstracts];
|
|
37
|
-
|
|
38
|
-
for (const typeName of exportedTypes) {
|
|
39
|
-
// 检查同一个 typeName 的 implements/extends 出现次数
|
|
40
|
-
const implPattern = new RegExp(`(?:implements|extends)\\s+${typeName}\\b`, 'g');
|
|
41
|
-
// 简化版:只在 changedFiles 中搜索
|
|
42
|
-
let implCount = 0;
|
|
43
|
-
for (const f of changedFiles) {
|
|
44
|
-
if (!f.endsWith('.ts') && !f.endsWith('.tsx')) continue;
|
|
45
|
-
const fp = path.join(projectPath, f);
|
|
46
|
-
if (!fs.existsSync(fp)) continue;
|
|
47
|
-
const fc = fs.readFileSync(fp, 'utf-8');
|
|
48
|
-
const matches = fc.match(implPattern);
|
|
49
|
-
if (matches) implCount += matches.length;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 只有一个实现者 → YAGNI 违规
|
|
53
|
-
if (implCount <= 1) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
} catch {
|
|
59
|
-
// 文件读取失败,默认通过
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
return true;
|
|
64
|
-
},
|
|
65
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 约束定义拆分文件(工单 20):原 definitions.ts 按层拆分,
|
|
3
|
-
* definitions.ts 保持原路径做薄聚合(studio rule-scanner 契约)。
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { Constraint } from '../../../types/constraint';
|
|
7
|
-
|
|
8
|
-
// ========================================
|
|
9
|
-
// TIPS(提示)
|
|
10
|
-
//
|
|
11
|
-
// 定义:信息性提示,可忽略
|
|
12
|
-
// ========================================
|
|
13
|
-
|
|
14
|
-
export const TIPS: Record<string, Constraint> = {
|
|
15
|
-
/**
|
|
16
|
-
* 建议写 README
|
|
17
|
-
*/
|
|
18
|
-
readme_required: {
|
|
19
|
-
id: 'readme_required',
|
|
20
|
-
rule: 'NEW MODULES SHOULD HAVE README',
|
|
21
|
-
message: '建议为新模块创建 README',
|
|
22
|
-
level: 'tip',
|
|
23
|
-
trigger: 'module_creation',
|
|
24
|
-
enforcement: 'create-readme',
|
|
25
|
-
description: `创建新模块时建议同时创建 README.md,说明:
|
|
26
|
-
|
|
27
|
-
- 模块用途
|
|
28
|
-
- 使用方法
|
|
29
|
-
- API 文档
|
|
30
|
-
- 示例代码
|
|
31
|
-
|
|
32
|
-
README 帮助其他开发者快速了解模块。`,
|
|
33
|
-
promptInjection: '创建新模块时,同时创建 README.md 说明模块用途、使用方法和 API 文档,帮助其他开发者快速了解模块。',
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 建议写 API 文档
|
|
38
|
-
*/
|
|
39
|
-
doc_required_for_public_api: {
|
|
40
|
-
id: 'doc_required_for_public_api',
|
|
41
|
-
rule: 'PUBLIC API SHOULD HAVE DOCUMENTATION',
|
|
42
|
-
message: '建议为公共 API 添加文档注释',
|
|
43
|
-
level: 'tip',
|
|
44
|
-
trigger: 'export_change',
|
|
45
|
-
enforcement: 'add-docs',
|
|
46
|
-
description: `所有导出的函数、类、接口建议添加 JSDoc 注释:
|
|
47
|
-
|
|
48
|
-
\`\`\`typescript
|
|
49
|
-
/**
|
|
50
|
-
* 计算两个数的和
|
|
51
|
-
* @param a 第一个数
|
|
52
|
-
* @param b 第二个数
|
|
53
|
-
* @returns 两数之和
|
|
54
|
-
*/
|
|
55
|
-
export function add(a: number, b: number): number {
|
|
56
|
-
return a + b;
|
|
57
|
-
}
|
|
58
|
-
\`\`\`
|
|
59
|
-
|
|
60
|
-
文档注释帮助 IDE 提供智能提示。`,
|
|
61
|
-
promptInjection: '公共 API(导出的函数、类、接口)必须有 JSDoc 文档注释,说明参数、返回值和用法示例。',
|
|
62
|
-
},
|
|
63
|
-
};
|
package/src/evolution/CONTEXT.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# evolution/
|
|
2
|
-
|
|
3
|
-
## 职责
|
|
4
|
-
约束自动进化:基于 trace 分析自动生成约束优化提案(autoEvolve)。
|
|
5
|
-
|
|
6
|
-
## 核心导出
|
|
7
|
-
- `auto-evolve.ts` — autoEvolve(): 纯计算 API,基于 trace 分析生成进化提案
|
|
8
|
-
|
|
9
|
-
## 依赖关系
|
|
10
|
-
- 依赖 `src/monitoring/` TraceAnalyzer / ConstraintEvolver
|
|
11
|
-
- 依赖 `src/core/constraints/` 约束定义
|
|
12
|
-
- 被 `src/cli/commands/flow.ts` CLI 消费(auto-apply)
|
|
13
|
-
|
|
14
|
-
## 约定
|
|
15
|
-
- autoEvolve() 是纯计算函数,不调用 LLM
|
|
16
|
-
- 进化提案由 ConstraintEvolver 生成
|
|
17
|
-
- 低风险提案可自动应用(flow --auto-apply)
|
|
18
|
-
|
|
19
|
-
## 注意事项
|
|
20
|
-
- 约束退化基于拦截率(不基于日历时间)
|
|
21
|
-
- Iron Law: 拦截率 < 5%(≥100 次检查) → guideline
|
|
22
|
-
- Guideline: 拦截率 < 30%(≥10 次检查) → tip
|