intentdna 1.5.14 → 1.5.16
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/.claude-plugin/marketplace.json +20 -7
- package/.claude-plugin/plugin.json +16 -2
- package/dist/hooks/cli.d.ts +30 -0
- package/dist/hooks/cli.js +168 -59
- package/dist/hooks/enforce.d.ts +13 -12
- package/dist/hooks/enforce.js +61 -46
- package/dist/hooks/protocol.d.ts +11 -0
- package/dist/hooks/schema.d.ts +22 -0
- package/dist/hooks/schema.js +86 -0
- package/dist/hooks/state-manager.d.ts +48 -0
- package/dist/hooks/state-manager.js +135 -0
- package/dist/hooks/state.d.ts +8 -0
- package/dist/hooks/state.js +8 -0
- package/dist/mcp/tools-enforce.js +6 -2
- package/dist/templates/flutter-rewrite.dna.yaml +18 -17
- package/package.json +4 -2
- package/spec/hooks-infra-harness-hardening.md +72 -26
- package/LICENSE +0 -69
- /package/{.claude-plugin/hooks → hooks}/hooks.json +0 -0
package/dist/hooks/state.js
CHANGED
|
@@ -30,6 +30,7 @@ export function resolveStateDir(projectDir, sessionId) {
|
|
|
30
30
|
// ── Workflow State ─────────────────────────────────────────
|
|
31
31
|
/**
|
|
32
32
|
* Read current workflow state. Returns null if not found or stale.
|
|
33
|
+
* @deprecated Prefer `new DNAStateManager(projectDir, sessionId).readWorkflowState()`.
|
|
33
34
|
*/
|
|
34
35
|
export async function readWorkflowState(projectDir, sessionId, stalenessMs = DEFAULT_STALENESS_MS) {
|
|
35
36
|
const stateDir = resolveStateDir(projectDir, sessionId);
|
|
@@ -51,6 +52,7 @@ export async function readWorkflowState(projectDir, sessionId, stalenessMs = DEF
|
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* Write workflow state atomically.
|
|
55
|
+
* @deprecated Prefer `DNAStateManager.writeWorkflowState()`.
|
|
54
56
|
*/
|
|
55
57
|
export async function writeWorkflowState(projectDir, state, sessionId) {
|
|
56
58
|
const stateDir = resolveStateDir(projectDir, sessionId);
|
|
@@ -60,6 +62,7 @@ export async function writeWorkflowState(projectDir, state, sessionId) {
|
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* Clear workflow state (workflow complete).
|
|
65
|
+
* @deprecated Prefer `DNAStateManager.clearWorkflowState()`.
|
|
63
66
|
*/
|
|
64
67
|
export async function clearWorkflowState(projectDir, sessionId) {
|
|
65
68
|
const stateDir = resolveStateDir(projectDir, sessionId);
|
|
@@ -76,6 +79,7 @@ export async function clearWorkflowState(projectDir, sessionId) {
|
|
|
76
79
|
* Append an entry to the audit log with dedup protection.
|
|
77
80
|
* Dedup key: event + tool_name + timestamp (second-level).
|
|
78
81
|
* Log file: `.dna/audit/violations-YYYY-MM-DD.log` (JSON Lines format)
|
|
82
|
+
* @deprecated Prefer `DNAStateManager.appendAudit()`.
|
|
79
83
|
*/
|
|
80
84
|
export async function appendAudit(projectDir, entry) {
|
|
81
85
|
const auditDir = join(projectDir, ".dna", "audit");
|
|
@@ -153,6 +157,7 @@ function defaultSurgeonState() {
|
|
|
153
157
|
}
|
|
154
158
|
/**
|
|
155
159
|
* Read surgeon attempt state. Returns default state if not found.
|
|
160
|
+
* @deprecated Prefer `DNAStateManager.readSurgeonAttempts()`.
|
|
156
161
|
*/
|
|
157
162
|
export async function readSurgeonAttempts(projectDir, sessionId) {
|
|
158
163
|
const stateDir = resolveStateDir(projectDir, sessionId);
|
|
@@ -167,6 +172,7 @@ export async function readSurgeonAttempts(projectDir, sessionId) {
|
|
|
167
172
|
}
|
|
168
173
|
/**
|
|
169
174
|
* Write surgeon attempt state atomically.
|
|
175
|
+
* @deprecated Prefer `DNAStateManager.writeSurgeonAttempts()`.
|
|
170
176
|
*/
|
|
171
177
|
export async function writeSurgeonAttempts(projectDir, state, sessionId) {
|
|
172
178
|
const stateDir = resolveStateDir(projectDir, sessionId);
|
|
@@ -176,6 +182,7 @@ export async function writeSurgeonAttempts(projectDir, state, sessionId) {
|
|
|
176
182
|
const SESSION_READS_FILE = "workflow/session-reads.json";
|
|
177
183
|
/**
|
|
178
184
|
* Read session reads state. Returns empty reads if not found.
|
|
185
|
+
* @deprecated Prefer `DNAStateManager.readSessionReads()`.
|
|
179
186
|
*/
|
|
180
187
|
export async function readSessionReads(projectDir, sessionId) {
|
|
181
188
|
const stateDir = resolveStateDir(projectDir, sessionId);
|
|
@@ -198,6 +205,7 @@ export async function writeSessionReads(projectDir, state, sessionId) {
|
|
|
198
205
|
}
|
|
199
206
|
/**
|
|
200
207
|
* Append a file path to session reads (dedup).
|
|
208
|
+
* @deprecated Prefer `DNAStateManager.appendSessionRead()`.
|
|
201
209
|
*/
|
|
202
210
|
export async function appendSessionRead(projectDir, filePath, sessionId) {
|
|
203
211
|
const state = await readSessionReads(projectDir, sessionId);
|
|
@@ -66,6 +66,10 @@ const VALID_EVENTS = new Set([
|
|
|
66
66
|
"SubagentStop", "PreCompact", "Notification", "SessionStart",
|
|
67
67
|
]);
|
|
68
68
|
function dispatchEnforce(event, ir, input, roles) {
|
|
69
|
+
const result = dispatchEnforceInner(event, ir, input, roles);
|
|
70
|
+
return result?.output ?? { continue: true, suppressOutput: true };
|
|
71
|
+
}
|
|
72
|
+
function dispatchEnforceInner(event, ir, input, roles) {
|
|
69
73
|
switch (event) {
|
|
70
74
|
case "PreToolUse":
|
|
71
75
|
return enforcePreToolUse(ir, {
|
|
@@ -100,10 +104,10 @@ function dispatchEnforce(event, ir, input, roles) {
|
|
|
100
104
|
case "SessionStart":
|
|
101
105
|
return enforceSessionStart(ir, {
|
|
102
106
|
cwd: typeof input.cwd === "string" ? input.cwd : undefined,
|
|
103
|
-
|
|
107
|
+
sessionId: typeof input.session_id === "string" ? input.session_id : undefined,
|
|
104
108
|
});
|
|
105
109
|
default:
|
|
106
|
-
return
|
|
110
|
+
return null;
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
// ── Tool Registration ───────────────────────────────────────
|
|
@@ -131,9 +131,9 @@ context_files:
|
|
|
131
131
|
- "docs/behavior/{{ARGUMENTS}}.md"
|
|
132
132
|
analysis_reviewer:
|
|
133
133
|
- "docs/behavior/{{ARGUMENTS}}.md"
|
|
134
|
-
- ".
|
|
134
|
+
- ".dna/specs/diagnosis-{{ARGUMENTS}}.md"
|
|
135
135
|
surgeon:
|
|
136
|
-
- ".
|
|
136
|
+
- ".dna/specs/diagnosis-{{ARGUMENTS}}.md"
|
|
137
137
|
test_runner:
|
|
138
138
|
- "docs/behavior/{{ARGUMENTS}}.md"
|
|
139
139
|
|
|
@@ -201,7 +201,7 @@ roles:
|
|
|
201
201
|
read: ["**/*"]
|
|
202
202
|
write: ["lib/**", "v2/**", "test/**"]
|
|
203
203
|
instructions:
|
|
204
|
-
- "REQUIRED FIRST: Read context files — CLAUDE.md, docs/refactoring-workflow-v2.md, v2/docs/PROVIDER_DESIGN.md, and the diagnosis spec (.
|
|
204
|
+
- "REQUIRED FIRST: Read context files — CLAUDE.md, docs/refactoring-workflow-v2.md, v2/docs/PROVIDER_DESIGN.md, and the diagnosis spec (.dna/specs/diagnosis-$ARGUMENTS.md). Then read v1 corresponding file before any Edit. Hook will block Edit if context files are not read."
|
|
205
205
|
- Fix only the identified breakpoint or missing implementation
|
|
206
206
|
- Read v1 to understand intent, rewrite in v2 framework style
|
|
207
207
|
- Do not copy v1 code verbatim — adapt to v2 architecture
|
|
@@ -235,17 +235,17 @@ roles:
|
|
|
235
235
|
|
|
236
236
|
# ── v2 角色: diagnosis + fix workflow ──
|
|
237
237
|
analyzer:
|
|
238
|
-
description: "Reads code and classifies failing tests.
|
|
238
|
+
description: "Reads code and classifies failing tests. Writes diagnosis spec only."
|
|
239
239
|
tool_permissions:
|
|
240
|
-
allow: [Read, Grep, Glob]
|
|
241
|
-
deny: [Bash, Edit,
|
|
240
|
+
allow: [Read, Grep, Glob, Write]
|
|
241
|
+
deny: [Bash, Edit, NotebookEdit]
|
|
242
242
|
scope:
|
|
243
243
|
read: ["**/*"]
|
|
244
|
-
write: []
|
|
244
|
+
write: [".dna/specs/**"]
|
|
245
245
|
instructions:
|
|
246
246
|
- "REQUIRED FIRST: Read all context files listed in SKILL.md"
|
|
247
|
-
- "For each failing test: read test code + v1 impl + v2 impl"
|
|
248
|
-
- "Classify each
|
|
247
|
+
- "For each failing, skipped, and hung test: read test code + v1 impl + v2 impl"
|
|
248
|
+
- "Classify each as BUG / UNIMPLEMENTED / INFRA / REMOVED / TEST_BUG (skipped tests are usually UNIMPLEMENTED)"
|
|
249
249
|
- "Output diagnosis spec with v1 code snippets + v2 current state"
|
|
250
250
|
- "DO NOT run tests. DO NOT edit code. Analysis only."
|
|
251
251
|
|
|
@@ -518,19 +518,19 @@ workflows:
|
|
|
518
518
|
For module $ARGUMENTS, analyze failing tests in baseline:
|
|
519
519
|
1. Read behavior doc: docs/behavior/$ARGUMENTS.md
|
|
520
520
|
2. Read test results from last behavior-lock run
|
|
521
|
-
3. For each failing test:
|
|
521
|
+
3. For each failing, skipped, and hung test:
|
|
522
522
|
a. Read test code (what behavior does it expect?)
|
|
523
523
|
b. Read v1 implementation (how did v1 do this?)
|
|
524
524
|
c. Read v2 current state (what's missing/wrong?)
|
|
525
|
-
d. Classify: BUG / INFRA / REMOVED / TEST_BUG
|
|
526
|
-
4. Write .
|
|
525
|
+
d. Classify: BUG / UNIMPLEMENTED / INFRA / REMOVED / TEST_BUG
|
|
526
|
+
4. Write .dna/specs/diagnosis-$ARGUMENTS.md with:
|
|
527
527
|
- For each failure: v1 code snippet + v2 current state + classification
|
|
528
528
|
- NO fix prescriptions (surgeon decides how to implement)
|
|
529
529
|
- NO running tests (analysis only)
|
|
530
530
|
handoff:
|
|
531
531
|
produces:
|
|
532
532
|
- type: file
|
|
533
|
-
path: ".
|
|
533
|
+
path: ".dna/specs/diagnosis-$ARGUMENTS.md"
|
|
534
534
|
description: "Diagnosis spec for module"
|
|
535
535
|
|
|
536
536
|
- id: review
|
|
@@ -539,7 +539,7 @@ workflows:
|
|
|
539
539
|
max_attempts: 2
|
|
540
540
|
description: "Review analyzer output quality"
|
|
541
541
|
prompt: |
|
|
542
|
-
Read context files + .
|
|
542
|
+
Read context files + .dna/specs/diagnosis-$ARGUMENTS.md
|
|
543
543
|
|
|
544
544
|
Verify:
|
|
545
545
|
1. All failing tests from baseline covered?
|
|
@@ -552,7 +552,7 @@ workflows:
|
|
|
552
552
|
handoff:
|
|
553
553
|
consumes:
|
|
554
554
|
- type: file
|
|
555
|
-
path: ".
|
|
555
|
+
path: ".dna/specs/diagnosis-$ARGUMENTS.md"
|
|
556
556
|
description: "Diagnosis spec from analyzer"
|
|
557
557
|
produces:
|
|
558
558
|
- type: summary
|
|
@@ -576,11 +576,12 @@ workflows:
|
|
|
576
576
|
|
|
577
577
|
Read context + diagnosis spec first.
|
|
578
578
|
|
|
579
|
-
Process issues in priority order: INFRA → BUG → TEST_BUG
|
|
579
|
+
Process issues in priority order: INFRA → BUG → UNIMPLEMENTED → TEST_BUG
|
|
580
580
|
(REMOVED skipped — needs user confirmation)
|
|
581
581
|
|
|
582
582
|
For each issue:
|
|
583
583
|
- BUG: read v1 file, edit v2 (use Riverpod per refactoring-workflow-v2.md)
|
|
584
|
+
- UNIMPLEMENTED: read v1 impl, implement in v2 style, remove skip marker from test
|
|
584
585
|
- INFRA: edit test_helpers only, do NOT touch v2/lib
|
|
585
586
|
- TEST_BUG: re-read v1, edit test to match v1 behavior
|
|
586
587
|
|
|
@@ -592,7 +593,7 @@ workflows:
|
|
|
592
593
|
handoff:
|
|
593
594
|
consumes:
|
|
594
595
|
- type: file
|
|
595
|
-
path: ".
|
|
596
|
+
path: ".dna/specs/diagnosis-$ARGUMENTS.md"
|
|
596
597
|
description: "Diagnosis spec"
|
|
597
598
|
produces:
|
|
598
599
|
- type: git_commit
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intentdna",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.16",
|
|
4
4
|
"description": "Intent DNA — Declarative policy layer for AI agent behavior",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "Apache-2.0",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "https://github.com/lushan1314/intentdna.git"
|
|
23
|
+
"url": "git+https://github.com/lushan1314/intentdna-repo.git"
|
|
24
24
|
},
|
|
25
25
|
"keywords": [
|
|
26
26
|
"ai",
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
"dist",
|
|
37
37
|
"spec",
|
|
38
38
|
".claude-plugin",
|
|
39
|
+
"hooks",
|
|
39
40
|
"README.md",
|
|
40
41
|
"LICENSE"
|
|
41
42
|
],
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@types/node": "^25.3.3",
|
|
45
|
+
"fast-check": "^4.7.0",
|
|
44
46
|
"typescript": "^5.9.3",
|
|
45
47
|
"vitest": "^4.0.18"
|
|
46
48
|
}
|
|
@@ -93,6 +93,8 @@ npm test
|
|
|
93
93
|
**测试**: +20
|
|
94
94
|
**破坏性**: 无(纯增量)
|
|
95
95
|
|
|
96
|
+
**实施状态(2026-04-20 更新)**: 与 Phase 1B 合并完成,产出 +108 测试(schema+contract ≈18 属 1A,其余属 1B 断言重写)。评审 GO with reservations。未提交,3 个 blocker 待修(见本 spec 末尾"Phase 1A+1B 合并 Followup"章节)。
|
|
97
|
+
|
|
96
98
|
### 1A.1 新建 src/hooks/schema.ts
|
|
97
99
|
|
|
98
100
|
```typescript
|
|
@@ -163,6 +165,8 @@ npm test # 全绿,+20 新测试
|
|
|
163
165
|
**破坏性**: 是(限定在此 phase)
|
|
164
166
|
**依赖**: Phase 1A
|
|
165
167
|
|
|
168
|
+
**实施状态(2026-04-20 更新)**: 与 Phase 1A 一起完成(autopilot 超范围)。类型/签名/断言重写都到位,未提交。
|
|
169
|
+
|
|
166
170
|
### 1B.1 protocol.ts 新增类型
|
|
167
171
|
|
|
168
172
|
```typescript
|
|
@@ -261,13 +265,15 @@ npm test # 全绿,+15 新测试
|
|
|
261
265
|
|
|
262
266
|
---
|
|
263
267
|
|
|
264
|
-
## Phase 2A: DNAStateManager
|
|
268
|
+
## Phase 2A: DNAStateManager ✓ (2026-04-21)
|
|
265
269
|
|
|
266
270
|
**目标**: 统一所有 state 操作,支持 session reads + surgeon attempts + experience chain
|
|
267
|
-
**测试**: +
|
|
271
|
+
**测试**: +21 (state-manager.test.ts)
|
|
268
272
|
**破坏性**: 无(旧函数 @deprecated 保留)
|
|
269
273
|
**可与 Phase 1A 并行**
|
|
270
274
|
|
|
275
|
+
**实施**: `src/hooks/state-manager.ts` — 类 facade 封装 workflow / audit / surgeon / session reads,新增 experience chain (json + markdown dual-write) 和 init/cleanup/isStale 生命周期。state.ts 全部被 manager 替代的函数加 `@deprecated`。1076 tests pass (1055 existing + 21 new)。
|
|
276
|
+
|
|
271
277
|
### 2A.1 新建 src/hooks/state-manager.ts
|
|
272
278
|
|
|
273
279
|
```typescript
|
|
@@ -343,13 +349,15 @@ npm test # 全绿,+20 新测试
|
|
|
343
349
|
|
|
344
350
|
---
|
|
345
351
|
|
|
346
|
-
## Phase 2B: Context Gate + Reflection Gate + Workflow Boundary
|
|
352
|
+
## Phase 2B: Context Gate + Reflection Gate + Workflow Boundary ✓ (2026-04-21)
|
|
347
353
|
|
|
348
354
|
**目标**: 3 个核心 Harness 加固机制
|
|
349
|
-
**测试**: +
|
|
355
|
+
**测试**: +18 (hooks-harness.test.ts)
|
|
350
356
|
**破坏性**: 无
|
|
351
357
|
**依赖**: Phase 1B (EnforceResult) + Phase 2A (StateManager)
|
|
352
358
|
|
|
359
|
+
**实施**: `src/hooks/cli.ts:handlePreToolGates()` — PreToolUse 前置门,按优先级评估 workflow_boundary 和 context_gate。Context gate 已从 v1.5.12 的 PostToolUse warn 模式迁移到 PreToolUse block 模式(spec 已确认去掉 warn 过渡期)。Reflection gate 保持 v1.5.10 PostToolUse 实现。Session-read 追踪由 PostToolUse Read 路径写入 `.dna/state/sessions/<id>/workflow/session-reads.json`。1094 tests pass (1076 + 18 new)。
|
|
360
|
+
|
|
353
361
|
### 2B.1 Context Gate — src/hooks/cli.ts
|
|
354
362
|
|
|
355
363
|
在 PreToolUse 处理中新增:
|
|
@@ -508,13 +516,20 @@ npm test # 全绿,+15 新测试
|
|
|
508
516
|
|
|
509
517
|
---
|
|
510
518
|
|
|
511
|
-
## Phase 3: Stop Hook 智能编排 +
|
|
519
|
+
## Phase 3: Stop Hook 智能编排 + Property Tests ✓ (2026-04-21)
|
|
512
520
|
|
|
513
|
-
**目标**: Stop hook 从"继续工作"升级为"输出下一步 Agent 调用"
|
|
514
|
-
**测试**: +
|
|
521
|
+
**目标**: Stop hook 从"继续工作"升级为"输出下一步 Agent 调用";property-based 不变量验证
|
|
522
|
+
**测试**: +22 (9 stop-guidance + 13 property)
|
|
515
523
|
**破坏性**: 无
|
|
516
524
|
**依赖**: Phase 2B
|
|
517
525
|
|
|
526
|
+
**实施**:
|
|
527
|
+
- `src/hooks/cli.ts:buildWorkflowGuidance()` — Stop hook 读 workflow state + reflection-config sidecar + surgeon attempts,按 (完成 / surgeon 停滞 / 正常) 三种情况输出 STOP 指令或 `Agent(subagent_type=..., prompt=...)` 调用模板。
|
|
528
|
+
- `test/property/enforce-invariants.test.ts` — fast-check 属性测试 13 条,覆盖 checkContextReadiness 幂等性、checkReflectionLimit 三种分支边界、checkWorkflowBoundary completed=true/false 对偶、extractBashWritePaths / validateHookInput 不抛错 + 归一化一致性。
|
|
529
|
+
- **跳过**: subprocess integration tests(`spawn dist/hooks/cli.js` 全链路)— 需要预先 `npm run build`,留待后续补充。不影响 gate 逻辑验证,因为 buildWorkflowGuidance / handlePreToolGates 都是可直接导入的纯/半纯函数,已有完整单测。
|
|
530
|
+
|
|
531
|
+
1116 tests pass.
|
|
532
|
+
|
|
518
533
|
### 3.1 Stop Hook 智能编排 — src/hooks/cli.ts
|
|
519
534
|
|
|
520
535
|
在 enforceStop 中,读 workflow state 后输出明确的下一步指令:
|
|
@@ -669,27 +684,58 @@ dna sync # 新 agent/skill 生成
|
|
|
669
684
|
- [ ] trace metadata 不进入 HookOutput(CC 协议边界)
|
|
670
685
|
- [ ] mcp/tools-enforce.ts 同步更新
|
|
671
686
|
|
|
672
|
-
### Phase 2A
|
|
673
|
-
- [
|
|
674
|
-
- [
|
|
675
|
-
- [
|
|
676
|
-
- [
|
|
677
|
-
- [
|
|
678
|
-
- [
|
|
679
|
-
|
|
680
|
-
### Phase 2B
|
|
681
|
-
- [
|
|
682
|
-
- [
|
|
683
|
-
- [
|
|
684
|
-
- [
|
|
685
|
-
- [
|
|
686
|
-
|
|
687
|
-
### Phase 3
|
|
688
|
-
- [
|
|
689
|
-
- [ ] Integration tests: spawn dna-hook 全链路
|
|
690
|
-
- [
|
|
687
|
+
### Phase 2A ✓
|
|
688
|
+
- [x] DNAStateManager class 实现
|
|
689
|
+
- [x] Session reads 追踪
|
|
690
|
+
- [x] Surgeon attempts 追踪
|
|
691
|
+
- [x] Experience chain 读写(json + markdown dual-write)
|
|
692
|
+
- [x] init/cleanup/isStale 生命周期
|
|
693
|
+
- [x] state.ts 旧函数 @deprecated 保留
|
|
694
|
+
|
|
695
|
+
### Phase 2B ✓
|
|
696
|
+
- [x] Context gate: block Edit/Bash/Write if context files not read (PreToolUse, block mode)
|
|
697
|
+
- [x] Reflection gate: detect no-progress, warn/handoff/skip (PostToolUse, v1.5.10+)
|
|
698
|
+
- [x] Workflow boundary: block Skill() after workflow completed (wfState.active=false)
|
|
699
|
+
- [x] PostToolUse Read → appendSessionRead
|
|
700
|
+
- [x] parseGreenCount 支持 3 种格式 + null 安全 (v1.5.10+ TEST_PASSED_RE)
|
|
701
|
+
|
|
702
|
+
### Phase 3 ✓ (partial — integration tests deferred)
|
|
703
|
+
- [x] Stop hook 读 workflow state 输出 Agent() 调用指令 (buildWorkflowGuidance)
|
|
704
|
+
- [ ] Integration tests: spawn dna-hook 全链路 (deferred — 需 build 先行)
|
|
705
|
+
- [x] Property tests: 13 个不变量 (fast-check)
|
|
691
706
|
|
|
692
707
|
### Phase 4
|
|
693
708
|
- [ ] dna verify --health 通过
|
|
694
709
|
- [ ] lwk_flutter diagnosis → fix 流程验证
|
|
695
710
|
- [ ] 发版
|
|
711
|
+
|
|
712
|
+
---
|
|
713
|
+
|
|
714
|
+
## Phase 1A+1B 合并 Followup(2026-04-20 评审产出 → 2026-04-21 已修)
|
|
715
|
+
|
|
716
|
+
autopilot 超范围将 1A+1B 一并完成,3 个 blocker 均已修复:
|
|
717
|
+
|
|
718
|
+
### Blocker 1: schema.ts 接入 cli.ts ✓
|
|
719
|
+
|
|
720
|
+
**实施**: `src/hooks/cli.ts:24,125-137` — 在 `readStdin` 后、任何业务逻辑前调用 `validateHookInput(event, rawStdin)`;无效输入 fail-open(stderr 警告 + silent exit),有效输入使用 `validation.normalized` 作为后续 `rawInput`(session_id 已归一化为 sessionId)。
|
|
721
|
+
|
|
722
|
+
### Blocker 2: matched_rule 语义修正 ✓
|
|
723
|
+
|
|
724
|
+
**实施**: `src/hooks/protocol.ts:100` — MatchedRule 枚举新增 `"validator"`;`src/hooks/enforce.ts:155-160` — audit-only 路径使用 `"validator"`,bash scope 违规仍用 `"scope"`(真实路径匹配)。
|
|
725
|
+
|
|
726
|
+
### Blocker 3: commit 信息如实 ✓
|
|
727
|
+
|
|
728
|
+
**实施**: commit message 明确标注 "Phase 1A+1B 合并(autopilot 超范围)+ 3 blocker 修复"。
|
|
729
|
+
|
|
730
|
+
### Phase 1A/1B 验收全 PASS
|
|
731
|
+
|
|
732
|
+
- [x] schema.ts validateHookInput() 实现 + 接入 cli.ts
|
|
733
|
+
- [x] 8 个真实 CC fixture 文件 + contract tests 全链路通过
|
|
734
|
+
- [x] SessionStartInput snake_case bug 已修
|
|
735
|
+
- [x] EnforceResult + TraceMetadata 类型定义
|
|
736
|
+
- [x] matched_rule 包含 context_gate / reflection_gate / workflow_boundary / validator
|
|
737
|
+
- [x] 8 个 enforce 函数返回 EnforceResult
|
|
738
|
+
- [x] cli.ts 不再猜 decision(读 `result.output`)
|
|
739
|
+
- [x] trace metadata 不进入 HookOutput(CC 协议边界)
|
|
740
|
+
- [x] mcp/tools-enforce.ts 同步更新
|
|
741
|
+
- [x] 全量测试 1055 passed
|
package/LICENSE
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
-
|
|
11
|
-
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
-
|
|
13
|
-
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
-
|
|
15
|
-
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
-
|
|
17
|
-
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
-
|
|
19
|
-
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
-
|
|
21
|
-
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
-
|
|
23
|
-
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
-
|
|
25
|
-
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
-
|
|
27
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
-
|
|
29
|
-
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
-
|
|
31
|
-
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
-
|
|
33
|
-
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
-
|
|
35
|
-
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
-
|
|
37
|
-
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
-
|
|
39
|
-
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
-
|
|
41
|
-
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
-
|
|
43
|
-
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
-
|
|
45
|
-
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
-
|
|
47
|
-
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
-
|
|
49
|
-
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
-
|
|
51
|
-
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
-
|
|
53
|
-
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
-
|
|
55
|
-
END OF TERMS AND CONDITIONS
|
|
56
|
-
|
|
57
|
-
Copyright 2026 Samuel
|
|
58
|
-
|
|
59
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
60
|
-
you may not use this file except in compliance with the License.
|
|
61
|
-
You may obtain a copy of the License at
|
|
62
|
-
|
|
63
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
64
|
-
|
|
65
|
-
Unless required by applicable law or agreed to in writing, software
|
|
66
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
67
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
68
|
-
See the License for the specific language governing permissions and
|
|
69
|
-
limitations under the License.
|
|
File without changes
|