@michelj/context-guard 0.4.4 → 0.6.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.
Files changed (101) hide show
  1. package/Coordinator.md +88 -0
  2. package/Executor.md +53 -0
  3. package/README.md +72 -102
  4. package/README.zh-CN.md +72 -102
  5. package/SKILL.md +26 -33
  6. package/THIRD_PARTY_NOTICES.md +47 -0
  7. package/Tester.md +53 -0
  8. package/bin/build-runtime.mjs +96 -0
  9. package/bin/context-guard-skill.js +287 -69
  10. package/bin/postinstall.js +1 -1
  11. package/hooks.json +80 -4
  12. package/licenses/JSONParse-MIT.txt +24 -0
  13. package/licenses/Marked-MIT.txt +44 -0
  14. package/licenses/Portless-Apache-2.0.txt +201 -0
  15. package/package.json +31 -5
  16. package/prototype/LICENSES/Marked-MIT.txt +44 -0
  17. package/prototype/LICENSES/Ready-redistribution.txt +14 -0
  18. package/prototype/attachments.mjs +75 -0
  19. package/prototype/coordinator-markdown.mjs +283 -0
  20. package/prototype/coordinator-working-blot.mjs +124 -0
  21. package/prototype/vendor/marked.mjs +2189 -0
  22. package/prototype/workbench-app.js +5197 -0
  23. package/prototype/workbench-data.js +33 -0
  24. package/prototype/workbench-sync.mjs +898 -0
  25. package/prototype/workbench.css +1050 -0
  26. package/prototype/workbench.html +139 -4861
  27. package/prototype/working-blot-atlas.png +0 -0
  28. package/references/agent-handoff.md +40 -0
  29. package/references/claude-runtime.md +120 -0
  30. package/references/cloud-sync-interface.md +66 -0
  31. package/references/design-current.md +14 -0
  32. package/references/map-mount.md +41 -0
  33. package/references/map-read.md +50 -0
  34. package/references/memory-definition.md +120 -0
  35. package/references/memory-filesystem-v2/Bug.en.md +162 -0
  36. package/references/memory-filesystem-v2/Bug.md +162 -0
  37. package/references/memory-filesystem-v2/Bug_Coordinater.md +8 -0
  38. package/references/memory-filesystem-v2/Bug_Executor.md +8 -0
  39. package/references/memory-filesystem-v2/Bug_Tester.md +7 -0
  40. package/references/memory-filesystem-v2/Idea.en.md +36 -0
  41. package/references/memory-filesystem-v2/Idea.md +36 -0
  42. package/references/memory-filesystem-v2/Node_Module_Index.en.md +88 -0
  43. package/references/memory-filesystem-v2/Node_Module_Index.md +88 -0
  44. package/references/memory-filesystem-v2/README.md +60 -0
  45. package/references/memory-filesystem-v2/Todo.en.md +137 -0
  46. package/references/memory-filesystem-v2/Todo.md +137 -0
  47. package/references/memory-filesystem-v2/Todo_Coordinater.md +7 -0
  48. package/references/memory-filesystem-v2/Todo_Executor.md +7 -0
  49. package/references/memory-filesystem-v2/Todo_Tester.md +7 -0
  50. package/references/named-workbench.md +124 -0
  51. package/references/plan-review.md +12 -0
  52. package/references/server-memory.md +276 -0
  53. package/references/test-check.md +7 -0
  54. package/references/user-reply.md +38 -0
  55. package/references/workbench-interface.md +531 -0
  56. package/roles.md +13 -0
  57. package/scripts/context_guard.py +1163 -321
  58. package/scripts/context_guard_hook.py +1864 -63
  59. package/scripts/map_owns.py +68 -138
  60. package/scripts/shared/LICENSES/JSONParse-MIT.txt +24 -0
  61. package/scripts/shared/filesystem-v2.mjs +430 -0
  62. package/scripts/shared/io.mjs +117 -0
  63. package/scripts/shared/map-model.mjs +506 -0
  64. package/scripts/shared/memory-schema.mjs +13 -0
  65. package/scripts/shared/protocol-blobs.mjs +112 -0
  66. package/scripts/shared/protocol-map.mjs +146 -0
  67. package/scripts/shared/protocol-snapshots.mjs +84 -0
  68. package/scripts/shared/protocol-store.mjs +624 -0
  69. package/scripts/shared/protocol-workflow.mjs +226 -0
  70. package/scripts/shared/protocol.mjs +125 -0
  71. package/scripts/shared/vendor/jsonparse.cjs +413 -0
  72. package/scripts/workbench/access.mjs +496 -0
  73. package/scripts/workbench/attachments.mjs +92 -0
  74. package/scripts/workbench/browser-login.mjs +78 -0
  75. package/scripts/workbench/claude-runtime.mjs +372 -0
  76. package/scripts/workbench/cli.mjs +980 -0
  77. package/scripts/workbench/device-heartbeat.mjs +72 -0
  78. package/scripts/workbench/hook-status.mjs +38 -0
  79. package/scripts/workbench/inbox.mjs +155 -0
  80. package/scripts/workbench/journal.mjs +56 -0
  81. package/scripts/workbench/memory-merge.mjs +65 -0
  82. package/scripts/workbench/memory.mjs +252 -0
  83. package/scripts/workbench/named-proxy.mjs +108 -0
  84. package/scripts/workbench/named.mjs +152 -0
  85. package/scripts/workbench/portless-routes.mjs +51 -0
  86. package/scripts/workbench/project.mjs +327 -0
  87. package/scripts/workbench/projections.mjs +68 -0
  88. package/scripts/workbench/protocol-client.mjs +165 -0
  89. package/scripts/workbench/protocol-delivery.mjs +133 -0
  90. package/scripts/workbench/protocol-device.mjs +316 -0
  91. package/scripts/workbench/protocol-events.mjs +53 -0
  92. package/scripts/workbench/protocol-repository.mjs +58 -0
  93. package/scripts/workbench/reconcile.mjs +244 -0
  94. package/scripts/workbench/registry.mjs +111 -0
  95. package/scripts/workbench/runtime.mjs +54 -0
  96. package/scripts/workbench/server.mjs +1171 -0
  97. package/scripts/workbench/store.mjs +243 -0
  98. package/scripts/workbench/sync-coordinator.mjs +518 -0
  99. package/scripts/workbench/sync.mjs +86 -0
  100. package/references/bug-record-template.md +0 -37
  101. package/references/context-template.md +0 -19
@@ -0,0 +1,162 @@
1
+ # Bug.md 格式
2
+
3
+ ## 状态
4
+
5
+ - `Open`:已记录,尚未开始处理。
6
+ - `InProgress`:Executor 与 Tester 的处理流程尚未结束。
7
+ - `Pending`:测试已完成,等待人类验收。
8
+ - `Resolved`:人类验收通过。
9
+ - `Unfixable`:修不好,流程结束,保留这条记录。不是延期,也不是「以后再做」。
10
+
11
+ **没有延期。** 禁止 `Deferred`。不需要修 → **删除该 Bug 文件**(索引中消失),不要写成 `WontFix` 留着挂起。
12
+
13
+ 图片等二进制文件单独存储,只在本文挂引用链接。
14
+
15
+ 迁移生成器把历史 `deferred` 投影为 `Unfixable`,历史 `wontfix` 不生成文件。二者都不会变成 `Open`。
16
+
17
+ 归因轮次只使用 `Confirmed` 和 `Refuted`。新归因在本轮证据支持时写 `Confirmed`;后续轮次推翻后改为 `Refuted`,并补充 `RefutedBy` 和原因。
18
+
19
+ ## 格式
20
+
21
+ ```md
22
+ # <Bug ID> <标题>
23
+
24
+ Reporter: <Human|Agent>
25
+ Status: <Open|InProgress|Pending|Resolved|Unfixable>
26
+ CurrentAttempt: <A1...An>
27
+
28
+ ## 1. 现象
29
+
30
+ <最初报告的现象,只描述可观察结果>
31
+
32
+ ## 2. 后续纠正事件
33
+
34
+ - <A轮次 / Human|Agent>:<反馈或新证据>
35
+
36
+ ## 3. 复现
37
+
38
+ ### A1
39
+ <该轮复现方法>
40
+
41
+ ## 4. 原因与代码改动
42
+
43
+ ### 当前有效结论
44
+ <仍成立的原因与修复结论>
45
+
46
+ ### A1
47
+ Status: <Confirmed|Refuted>
48
+ RefutedBy: <A轮次,仅 Refuted 时出现>
49
+ Reason: <推翻原因,仅 Refuted 时出现>
50
+
51
+ 原因:<该轮 Agent 当时的归因>
52
+
53
+ #### code index
54
+ - `<代码路径>`
55
+ <改动简介>
56
+
57
+ ## 5. 测试
58
+
59
+ - [A1](tests/<Bug ID>-A1.md):<一句结果>
60
+
61
+ ## 6. 修复 Session 索引
62
+
63
+ - [A1](traces/<Bug ID>-A1.md)
64
+ ```
65
+
66
+ 测试区不记录人类验收。Session 区只放链接,不复制 Trace 内容。
67
+
68
+ ## 四轮复杂示例
69
+
70
+ ```md
71
+ # B002 连续点击产生重复反馈
72
+
73
+ Reporter: Human
74
+ Status: Pending
75
+ CurrentAttempt: A4
76
+
77
+ ## 1. 现象
78
+
79
+ 一次提交尚未结束时再次点击,会生成两条内容相同的反馈。
80
+
81
+ ## 2. 后续纠正事件
82
+
83
+ - A1 / Human:快速双击仍重复,验收不通过;禁用按钮不能覆盖事件队列中的第二次提交。
84
+ - A2 / Human:弱网超时后重试仍重复,验收不通过;同步锁只覆盖单个窗口。
85
+ - A3 / Agent B:第二轮修复后,同一草稿在多个窗口同时提交仍重复,旧的请求键方案不能防并发创建。
86
+ - A4 / Tester B:并发、重试和冲突回归通过,等待人类验收。
87
+
88
+ ## 3. 复现
89
+
90
+ ### A1
91
+ 填写反馈,连续双击提交按钮。
92
+
93
+ ### A2
94
+ 将首个请求延迟到超时,在界面重试。
95
+
96
+ ### A3
97
+ 服务端创建成功后丢弃响应,再用相同请求键重试。
98
+
99
+ ### A4
100
+ 两个窗口同时提交同一草稿;再以同键同内容和同键不同内容分别重试。
101
+
102
+ ## 4. 原因与代码改动
103
+
104
+ ### 当前有效结论
105
+ 单窗口同步锁阻止界面重入;服务端原子唯一约束保证跨窗口及网络重试只创建一条记录,同键不同内容明确冲突。
106
+
107
+ ### A1
108
+ Status: Refuted
109
+ RefutedBy: A2
110
+ Reason: 事件队列中的第二次点击发生在按钮禁用生效前。
111
+
112
+ 原因:怀疑提交按钮允许重复点击。
113
+
114
+ #### code index
115
+ - `src/ui/FeedbackForm.tsx`
116
+ 提交开始时禁用按钮。
117
+
118
+ ### A2
119
+ Status: Confirmed
120
+
121
+ 原因:界面状态更新前存在重入窗口。
122
+
123
+ #### code index
124
+ - `src/ui/submitFeedback.ts`
125
+ 在提交入口增加同步锁,结束时释放。
126
+
127
+ ### A3
128
+ Status: Refuted
129
+ RefutedBy: A4
130
+ Reason: 请求键查重与插入不是原子操作,并发请求可同时通过检查。
131
+
132
+ 原因:超时重试未复用已创建反馈;复用请求键即可防止重复。
133
+
134
+ #### code index
135
+ - `src/server/createFeedback.ts`
136
+ 创建前查询请求键并返回已有记录。
137
+
138
+ ### A4
139
+ Status: Confirmed
140
+
141
+ 原因:查重与插入不原子,并发请求会同时通过检查。
142
+
143
+ #### code index
144
+ - `src/storage/migrations/004_feedback_unique_key.sql`
145
+ 为用户与请求键建立组合唯一约束。
146
+ - `src/server/createFeedback.ts`
147
+ 原子创建;唯一键冲突时返回已有记录,同键不同内容返回冲突。
148
+
149
+ ## 5. 测试
150
+
151
+ - [A1](tests/B002-A1.md):连续点击仍可复现。
152
+ - [A2](tests/B002-A2.md):单窗口通过,弱网重试失败。
153
+ - [A3](tests/B002-A3.md):顺序重试通过,并发提交失败。
154
+ - [A4](tests/B002-A4.md):并发、超时重试和冲突回归通过。
155
+
156
+ ## 6. 修复 Session 索引
157
+
158
+ - [A1](traces/B002-A1.md)
159
+ - [A2](traces/B002-A2.md)
160
+ - [A3](traces/B002-A3.md)
161
+ - [A4](traces/B002-A4.md)
162
+ ```
@@ -0,0 +1,8 @@
1
+ # Bug Coordinator
2
+
3
+ Bug 模式下负责:
4
+
5
+ - 创建 Bug,并在 `1. 现象` 记录人类或 Agent 报告的原始现象。
6
+ - 明确 Reporter,启动 A1,并把执行任务交给 Executor。
7
+ - 后续 Agent 或人类指出旧结论有误时,将事件追加到 `2. 后续纠正事件`。
8
+ - 人类未验收时启动下一轮;Executor 与 Tester 完成后将整体状态推进到 `Pending` 等待人类验收。
@@ -0,0 +1,8 @@
1
+ # Bug Executor
2
+
3
+ Bug 模式下负责当前轮次:
4
+
5
+ - 复现 Bug,并把最短可重复步骤写入 `3. 复现` 的对应 A 轮次。
6
+ - 在 `4. 原因与代码改动` 记录本轮归因、改动摘要和 `code index`。
7
+ - 若本轮证据推翻旧归因,为旧轮次补充 `RefutedBy` 与推翻原因。
8
+ - 保留同一现象下的所有根因,不因根因不同拆成另一个 Bug。
@@ -0,0 +1,7 @@
1
+ # Bug Tester
2
+
3
+ Bug 模式下负责当前轮次:
4
+
5
+ - 编写该轮测试记录,覆盖复现路径、修复验证和必要回归。
6
+ - 将结果保存到测试文档;Bug.md 的 `5. 测试` 只登记对应 A 轮次的链接和一句结果。
7
+ - 测试不通过时保留证据并交回下一轮,不代替人类验收。
@@ -0,0 +1,36 @@
1
+ # Idea.md format
2
+
3
+ Only the Coordinator reads and writes Idea documents. Whether an Idea becomes a Todo is decided by the user and Coordinator in conversation and is not recorded in Idea.md.
4
+
5
+ ## Template
6
+
7
+ ```md
8
+ # <Idea ID> <Title>
9
+
10
+ Status: <Proposed|Accepted>
11
+
12
+ ## 1. Idea
13
+
14
+ <Idea text>
15
+
16
+ ## 2. Discussion and conclusion
17
+
18
+ - <Time or round>: <Discussion conclusion>
19
+ ```
20
+
21
+ ## Example
22
+
23
+ ```md
24
+ # I002 Include the current node with feedback
25
+
26
+ Status: Proposed
27
+
28
+ ## 1. Idea
29
+
30
+ When feedback is created from a node, include its ID and title automatically so the user does not need to describe the location manually.
31
+
32
+ ## 2. Discussion and conclusion
33
+
34
+ - C1: retain the stable node ID; use the title for display only so renaming does not break the relationship.
35
+ - C2: implementation has not been decided, so this remains an Idea.
36
+ ```
@@ -0,0 +1,36 @@
1
+ # Idea.md 格式
2
+
3
+ Idea 只由 Coordinator 读写。是否转成 Todo 由用户与 Coordinator 在对话中决定,不记录在 Idea.md。
4
+
5
+ ## 格式
6
+
7
+ ```md
8
+ # <Idea ID> <标题>
9
+
10
+ Status: <Proposed|Accepted>
11
+
12
+ ## 1. 想法
13
+
14
+ <想法正文>
15
+
16
+ ## 2. 讨论与结论
17
+
18
+ - <时间或轮次>:<讨论结论>
19
+ ```
20
+
21
+ ## 示例
22
+
23
+ ```md
24
+ # I002 反馈时附带当前节点信息
25
+
26
+ Status: Proposed
27
+
28
+ ## 1. 想法
29
+
30
+ 用户从节点内创建反馈时,自动附带当前节点 ID 和标题,减少手工描述问题位置。
31
+
32
+ ## 2. 讨论与结论
33
+
34
+ - C1:保留原始节点 ID;标题只用于显示,避免重命名后失去关联。
35
+ - C2:尚未决定是否实施,继续作为 Idea 保留。
36
+ ```
@@ -0,0 +1,88 @@
1
+ # Node / Module index format
2
+
3
+ ## Template
4
+
5
+ ```md
6
+ # <Title>
7
+
8
+ <Responsibility summary>
9
+
10
+ ## Related modules and nodes
11
+
12
+ ### Related
13
+
14
+ #### [<Related title>](<path>/index.md)
15
+ <Related responsibility summary>
16
+
17
+ ### Sub
18
+
19
+ #### [<Child title>](<path>/index.md)
20
+ <Child responsibility summary>
21
+
22
+ ## Bug
23
+
24
+ ### [<Bug ID> <Title>](bugs/<id>.md)
25
+ <Copied bug phenomenon>
26
+
27
+ Status: <Open|InProgress|Pending|Resolved|Unfixable>
28
+
29
+ ## Todo
30
+
31
+ ### [<Todo ID> <Title>](todos/<id>.md)
32
+ <Copied requirement>
33
+
34
+ Status: <Open|InProgress|Done>
35
+
36
+ ## Idea
37
+
38
+ ### [<Idea ID> <Title>](ideas/<id>.md)
39
+ <Copied idea text>
40
+
41
+ Status: <Proposed|Accepted>
42
+
43
+ ## Memory
44
+
45
+ [Read memory](memory.md)
46
+ ```
47
+
48
+ Use `NULL` when a section is empty. Related contains related nodes; Sub contains direct children. Bug, Todo, and Idea entries are generated by code. The Memory section appears only when that node has a memory document; the root node links to project-level `memory.md`.
49
+
50
+ ## Complete example
51
+
52
+ ```md
53
+ # Bug button
54
+
55
+ Submits defect feedback for the current node.
56
+
57
+ ## Related modules and nodes
58
+
59
+ ### Related
60
+
61
+ #### [Sidebar](../../Sidebar-module/index.md)
62
+ Provides module navigation and switching.
63
+
64
+ ### Sub
65
+
66
+ NULL
67
+
68
+ ## Bug
69
+
70
+ ### [B002 Repeated clicks create duplicate feedback](bugs/B002.md)
71
+ Repeated submission clicks create duplicate records.
72
+
73
+ Status: Pending
74
+
75
+ ## Todo
76
+
77
+ ### [T002 Show feedback submission state](todos/T002.md)
78
+ Show progress and prevent repeated submission while a request is active.
79
+
80
+ Status: InProgress
81
+
82
+ ## Idea
83
+
84
+ ### [I002 Include the current node with feedback](ideas/I002.md)
85
+ Reduce the location details the user must enter manually.
86
+
87
+ Status: Proposed
88
+ ```
@@ -0,0 +1,88 @@
1
+ # Node / Module index 格式
2
+
3
+ ## 格式
4
+
5
+ ```md
6
+ # <标题>
7
+
8
+ <职责简介>
9
+
10
+ ## 关联模块与节点
11
+
12
+ ### Related
13
+
14
+ #### [<关联标题>](<path>/index.md)
15
+ <关联职责简介>
16
+
17
+ ### Sub
18
+
19
+ #### [<下级标题>](<path>/index.md)
20
+ <下级职责简介>
21
+
22
+ ## Bug
23
+
24
+ ### [<Bug ID> <标题>](bugs/<id>.md)
25
+ <Bug 现象原文>
26
+
27
+ Status: <Open|InProgress|Pending|Resolved|Unfixable>
28
+
29
+ ## Todo
30
+
31
+ ### [<Todo ID> <标题>](todos/<id>.md)
32
+ <Todo 需求原文>
33
+
34
+ Status: <Open|InProgress|Done>
35
+
36
+ ## Idea
37
+
38
+ ### [<Idea ID> <标题>](ideas/<id>.md)
39
+ <Idea 正文原文>
40
+
41
+ Status: <Proposed|Accepted>
42
+
43
+ ## 记忆
44
+
45
+ [阅读记忆](memory.md)
46
+ ```
47
+
48
+ 没有内容时写 `NULL`。Related 只放相关节点,Sub 只放直接下级。Bug/Todo/Idea 区块全部由代码生成。`## 记忆` 仅在该节点有记忆文档时生成;项目根节点的链接指向项目根目录 `memory.md`。
49
+
50
+ ## 完整示例
51
+
52
+ ```md
53
+ # Bug按钮
54
+
55
+ 提交当前节点的缺陷反馈。
56
+
57
+ ## 关联模块与节点
58
+
59
+ ### Related
60
+
61
+ #### [侧边栏](../../侧边栏-module/index.md)
62
+ 提供模块导航与切换。
63
+
64
+ ### Sub
65
+
66
+ NULL
67
+
68
+ ## Bug
69
+
70
+ ### [B002 连续点击产生重复反馈](bugs/B002.md)
71
+ 连续点击提交时生成重复记录。
72
+
73
+ Status: Pending
74
+
75
+ ## Todo
76
+
77
+ ### [T002 补充反馈提交中的状态](todos/T002.md)
78
+ 提交期间显示进度并阻止重复提交。
79
+
80
+ Status: InProgress
81
+
82
+ ## Idea
83
+
84
+ ### [I002 反馈时附带当前节点信息](ideas/I002.md)
85
+ 减少用户手工描述问题位置。
86
+
87
+ Status: Proposed
88
+ ```
@@ -0,0 +1,60 @@
1
+ # Memory Filesystem v2.1
2
+
3
+ 读者:产品角色 Agent(格式与阅读面);仓库开发 Agent(生成器与迁移缺口)。
4
+
5
+ **版本:`fs-v2.1`(当前设计版本;底层事务格式仍为 v2)**
6
+ 从何而来:已评审的 Cloud Main / Session 记忆文件结构。
7
+
8
+ 确认:现行存储法只认这一版。下一版必须另开版本号。入口见 [当前设计版本](../design-current.md)。
9
+ 未升格设计草案不是本版本,不得当存储法。
10
+
11
+ 这是 Cloud Main 与 Session 记忆的已评审目标文件结构。启用 filesystem v2 的服务器提供按版本读取单份 Markdown 的显式 API,Agent 可通过 `context-guard memory file` 读取获授权的文档;这不是本地私有 `content/` 磁盘路径。未启用该投影的项目不能使用此入口,旧记录仍只作兼容传输。Agent 打开模块时默认读哪套目录(FIND.md / snapshot 与本投影如何切换)尚未拍板,不得在本文里选边。
12
+
13
+ ## 目录
14
+
15
+ ```text
16
+ filesystem-v2/
17
+ |-- FORMAT
18
+ |-- runtime-state.json # 事务兼容状态,不是 Agent 阅读入口
19
+ `-- content/
20
+ |-- storage.json
21
+ |-- main/
22
+ | |-- map.json # 代码导航表
23
+ | |-- memory.md # 项目记忆;有内容时生成
24
+ | |-- nodes/
25
+ | | `-- <name>-module|node/
26
+ | | |-- index.md
27
+ | | |-- memory.md # 节点记忆;有内容时生成
28
+ | | |-- bugs/<id>.md
29
+ | | |-- todos/<id>.md
30
+ | | `-- ideas/<id>.md
31
+ | |-- manifest.json
32
+ | `-- migration-report.json
33
+ `-- sessions/<session-hash>/ # 与 Main 同构,彼此隔离
34
+ ```
35
+
36
+ 节点的 Bug、Todo、Idea 索引直接生成在该节点的 `index.md` 中,不再创建 `bugs-index.json`、`tasks-index.json` 或 Idea JSON 索引。
37
+ 项目和节点的记忆正文存于 Main Map 对应节点的 `memoryDocument`,随版本写入并投影为上述 `memory.md`。只有人和 Coordinator 能修改;Executor、Tester 可按已有单文件读取权限查看。项目记忆是 Coordinator 首轮静态上下文,进入节点时只加载最近的相关节点记忆,历史条目仍按需读。文档格式见 [记忆定义](../memory-definition.md)。
38
+
39
+ ## 文档
40
+
41
+ - [Node / Module index](Node_Module_Index.md) · [English](Node_Module_Index.en.md)
42
+ - [Bug](Bug.md) · [English](Bug.en.md)
43
+ - [Todo](Todo.md) · [English](Todo.en.md)
44
+ - [Idea](Idea.md) · [English](Idea.en.md)
45
+ - Bug 模式:[Coordinator](Bug_Coordinater.md) · [Executor](Bug_Executor.md) · [Tester](Bug_Tester.md)
46
+ - Todo 模式:[Coordinator](Todo_Coordinater.md) · [Executor](Todo_Executor.md) · [Tester](Todo_Tester.md)
47
+
48
+ ## 代码生成职责
49
+
50
+ 目标实现由代码生成目录名、文档 ID、整体状态、`CurrentAttempt`、A1/A2 轮次编号、Related/Sub、节点 `index.md` 中的 Bug/Todo/Idea 条目、测试链接、Session 链接、`map.json`、`manifest.json` 和迁移报告。
51
+
52
+ Todo/Bug 的显式 `attempts` 依附工作项保存在版本化 Map 事务快照中;数组顺序生成 A1…An、`CurrentAttempt`、反证关系、测试和 Session 链接。每轮包含 `status`(`Confirmed|Refuted`);`Refuted` 必须指向更晚轮次并写明原因。可选字段为 `event`/`eventSource`、Bug 的 `reproduction`/`cause`/`resolution`、Todo 的 `acceptance`/`solution`,以及 `codeIndex`、`test`、`sessionIds`。生成的 Markdown 是投影,不是手工持久化入口;重建时从事务快照恢复。
53
+
54
+ 旧 Todo 若没有方案证据,迁移投影仍保留未判定的 A1 并在报告标记 `TODO_ATTEMPT_UNCLASSIFIED`;不能擅自判为 `Confirmed`。该旧项需要后续审核补齐显式 Attempt,完成前不得把它称为完全符合模板。
55
+
56
+ 生成器完整复制对应 Bug 现象、Todo 需求或 Idea 正文的首段,不由 Agent 重写,也不按字符数截断。详细内容仍以链接文档为准。
57
+
58
+ ## 兼容边界
59
+
60
+ `legacy-records/` 和 `runtime-state.json` 仅用于迁移、事务兼容与回滚。普通 Agent 上下文、接口分析和项目导航不得读取它们。需要核对历史迁移时必须显式说明兼容目的。
@@ -0,0 +1,137 @@
1
+ # Todo.md format
2
+
3
+ ## Status
4
+
5
+ - `Open`: recorded, not started.
6
+ - `InProgress`: the Executor and Tester workflow is not complete.
7
+ - `Done`: the current requirement has passed acceptance.
8
+
9
+ Solution attempts use `Confirmed` and `Refuted`. When later requirements or evidence invalidate an earlier solution, update that attempt with `RefutedBy` and the reason.
10
+
11
+ Migration compatibility: Todo A1 generated by the current runtime may omit `Status`. That legacy projection does not yet conform to this format and does not introduce a third attribution status. Do not synthesize the field or treat its absence as `Confirmed` before the generator is fixed.
12
+
13
+ ## Template
14
+
15
+ ```md
16
+ # <Todo ID> <Title>
17
+
18
+ Reporter: <Human|Agent>
19
+ Status: <Open|InProgress|Done>
20
+ CurrentAttempt: <A1...An>
21
+
22
+ ## 1. Requirement
23
+
24
+ <Confirmed user goal>
25
+
26
+ ## 2. Later adjustment events
27
+
28
+ - <Attempt / Human|Agent>: <New constraint or scope change>
29
+
30
+ ## 3. Acceptance criteria
31
+
32
+ ### A1
33
+ <Executable acceptance criteria for this attempt>
34
+
35
+ ## 4. Solution and code changes
36
+
37
+ ### Current valid solution
38
+ <Solution conclusions that still hold>
39
+
40
+ ### A1
41
+ Status: <Confirmed|Refuted>
42
+ RefutedBy: <Attempt, only when Refuted>
43
+ Reason: <Reason, only when Refuted>
44
+
45
+ Solution: <Solution proposed in this attempt>
46
+
47
+ #### code index
48
+ - `<code path>`
49
+ <Change summary>
50
+
51
+ ## 5. Tests
52
+
53
+ - [A1](tests/<Todo ID>-A1.md): <one-line result>
54
+
55
+ ## 6. Implementation Session index
56
+
57
+ - [A1](traces/<Todo ID>-A1.md)
58
+ ```
59
+
60
+ ## Three-attempt example
61
+
62
+ ```md
63
+ # T002 Show feedback submission state
64
+
65
+ Reporter: Human
66
+ Status: InProgress
67
+ CurrentAttempt: A3
68
+
69
+ ## 1. Requirement
70
+
71
+ Show an explicit state during feedback submission and prevent duplicate execution.
72
+
73
+ ## 2. Later adjustment events
74
+
75
+ - A1 / Human: disabling the button removes cancellation; cancellation must remain available.
76
+ - A2 / Human: multiple windows still duplicate submissions; scope expands to cross-window consistency.
77
+ - A3 / Executor B: use a server request key and define conflicts for different content using the same key.
78
+
79
+ ## 3. Acceptance criteria
80
+
81
+ ### A1
82
+ Show progress, prevent a second request, and allow cancellation.
83
+
84
+ ### A2
85
+ Two windows submitting the same draft create one record.
86
+
87
+ ### A3
88
+ Same key and content return one record; different content returns a conflict; a new request is allowed after cancellation.
89
+
90
+ ## 4. Solution and code changes
91
+
92
+ ### Current valid solution
93
+ A client state machine provides progress and cancellation. A server request key and uniqueness constraint provide cross-window idempotency.
94
+
95
+ ### A1
96
+ Status: Refuted
97
+ RefutedBy: A2
98
+ Reason: disabling one button cannot provide cancellation or cross-window consistency.
99
+
100
+ Solution: disable the button and show loading during submission.
101
+
102
+ #### code index
103
+ - `src/ui/FeedbackForm.tsx`
104
+ Add the submitting state.
105
+
106
+ ### A2
107
+ Status: Confirmed
108
+
109
+ Solution: use a cancellable state machine for one-window submission.
110
+
111
+ #### code index
112
+ - `src/ui/feedbackSubmission.ts`
113
+ Manage idle, submitting, and cancelling states.
114
+
115
+ ### A3
116
+ Status: Confirmed
117
+
118
+ Solution: enforce atomic idempotency by user and request key on the server.
119
+
120
+ #### code index
121
+ - `src/server/createFeedback.ts`
122
+ Validate the request key and handle uniqueness conflicts.
123
+ - `src/storage/migrations/004_feedback_unique_key.sql`
124
+ Add the composite uniqueness constraint.
125
+
126
+ ## 5. Tests
127
+
128
+ - [A1](tests/T002-A1.md): progress passes; cancellation fails.
129
+ - [A2](tests/T002-A2.md): one window passes; multiple windows fail.
130
+ - [A3](tests/T002-A3.md): state, cancellation, cross-window, and conflict regressions pass.
131
+
132
+ ## 6. Implementation Session index
133
+
134
+ - [A1](traces/T002-A1.md)
135
+ - [A2](traces/T002-A2.md)
136
+ - [A3](traces/T002-A3.md)
137
+ ```