@michelj/context-guard 0.4.3 → 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 (161) hide show
  1. package/Coordinator.md +88 -0
  2. package/Executor.md +53 -0
  3. package/README.md +89 -224
  4. package/README.zh-CN.md +89 -224
  5. package/SKILL.md +26 -684
  6. package/THIRD_PARTY_NOTICES.md +47 -0
  7. package/Tester.md +53 -0
  8. package/agents/openai.yaml +2 -2
  9. package/bin/build-runtime.mjs +96 -0
  10. package/bin/context-guard-skill.js +399 -78
  11. package/bin/postinstall.js +2 -2
  12. package/hooks.json +89 -13
  13. package/licenses/JSONParse-MIT.txt +24 -0
  14. package/licenses/Marked-MIT.txt +44 -0
  15. package/licenses/Portless-Apache-2.0.txt +201 -0
  16. package/package.json +35 -6
  17. package/prototype/LICENSES/Marked-MIT.txt +44 -0
  18. package/prototype/LICENSES/Ready-redistribution.txt +14 -0
  19. package/prototype/attachments.mjs +75 -0
  20. package/prototype/coordinator-markdown.mjs +283 -0
  21. package/prototype/coordinator-working-blot.mjs +124 -0
  22. package/prototype/vendor/marked.mjs +2189 -0
  23. package/prototype/workbench-app.js +5197 -0
  24. package/prototype/workbench-data.js +33 -0
  25. package/prototype/workbench-sync.mjs +898 -0
  26. package/prototype/workbench.css +1050 -0
  27. package/prototype/workbench.html +211 -0
  28. package/prototype/working-blot-atlas.png +0 -0
  29. package/references/agent-handoff.md +40 -0
  30. package/references/claude-runtime.md +120 -0
  31. package/references/cloud-sync-interface.md +66 -0
  32. package/references/design-current.md +14 -0
  33. package/references/map-mount.md +41 -0
  34. package/references/map-read.md +50 -0
  35. package/references/memory-definition.md +120 -0
  36. package/references/memory-filesystem-v2/Bug.en.md +162 -0
  37. package/references/memory-filesystem-v2/Bug.md +162 -0
  38. package/references/memory-filesystem-v2/Bug_Coordinater.md +8 -0
  39. package/references/memory-filesystem-v2/Bug_Executor.md +8 -0
  40. package/references/memory-filesystem-v2/Bug_Tester.md +7 -0
  41. package/references/memory-filesystem-v2/Idea.en.md +36 -0
  42. package/references/memory-filesystem-v2/Idea.md +36 -0
  43. package/references/memory-filesystem-v2/Node_Module_Index.en.md +88 -0
  44. package/references/memory-filesystem-v2/Node_Module_Index.md +88 -0
  45. package/references/memory-filesystem-v2/README.md +60 -0
  46. package/references/memory-filesystem-v2/Todo.en.md +137 -0
  47. package/references/memory-filesystem-v2/Todo.md +137 -0
  48. package/references/memory-filesystem-v2/Todo_Coordinater.md +7 -0
  49. package/references/memory-filesystem-v2/Todo_Executor.md +7 -0
  50. package/references/memory-filesystem-v2/Todo_Tester.md +7 -0
  51. package/references/named-workbench.md +124 -0
  52. package/references/plan-review.md +12 -0
  53. package/references/server-memory.md +276 -0
  54. package/references/test-check.md +7 -0
  55. package/references/user-reply.md +38 -0
  56. package/references/workbench-interface.md +531 -0
  57. package/roles.md +13 -0
  58. package/scripts/context_guard.py +1366 -7602
  59. package/scripts/context_guard_hook.py +1960 -711
  60. package/scripts/map_owns.py +699 -0
  61. package/scripts/shared/LICENSES/JSONParse-MIT.txt +24 -0
  62. package/scripts/shared/filesystem-v2.mjs +430 -0
  63. package/scripts/shared/io.mjs +117 -0
  64. package/scripts/shared/map-model.mjs +506 -0
  65. package/scripts/shared/memory-schema.mjs +13 -0
  66. package/scripts/shared/protocol-blobs.mjs +112 -0
  67. package/scripts/shared/protocol-map.mjs +146 -0
  68. package/scripts/shared/protocol-snapshots.mjs +84 -0
  69. package/scripts/shared/protocol-store.mjs +624 -0
  70. package/scripts/shared/protocol-workflow.mjs +226 -0
  71. package/scripts/shared/protocol.mjs +125 -0
  72. package/scripts/shared/vendor/jsonparse.cjs +413 -0
  73. package/scripts/workbench/access.mjs +496 -0
  74. package/scripts/workbench/attachments.mjs +92 -0
  75. package/scripts/workbench/browser-login.mjs +78 -0
  76. package/scripts/workbench/claude-runtime.mjs +372 -0
  77. package/scripts/workbench/cli.mjs +980 -0
  78. package/scripts/workbench/device-heartbeat.mjs +72 -0
  79. package/scripts/workbench/hook-status.mjs +38 -0
  80. package/scripts/workbench/inbox.mjs +155 -0
  81. package/scripts/workbench/journal.mjs +56 -0
  82. package/scripts/workbench/memory-merge.mjs +65 -0
  83. package/scripts/workbench/memory.mjs +252 -0
  84. package/scripts/workbench/named-proxy.mjs +108 -0
  85. package/scripts/workbench/named.mjs +152 -0
  86. package/scripts/workbench/portless-routes.mjs +51 -0
  87. package/scripts/workbench/project.mjs +327 -0
  88. package/scripts/workbench/projections.mjs +68 -0
  89. package/scripts/workbench/protocol-client.mjs +165 -0
  90. package/scripts/workbench/protocol-delivery.mjs +133 -0
  91. package/scripts/workbench/protocol-device.mjs +316 -0
  92. package/scripts/workbench/protocol-events.mjs +53 -0
  93. package/scripts/workbench/protocol-repository.mjs +58 -0
  94. package/scripts/workbench/reconcile.mjs +244 -0
  95. package/scripts/workbench/registry.mjs +111 -0
  96. package/scripts/workbench/runtime.mjs +54 -0
  97. package/scripts/workbench/server.mjs +1171 -0
  98. package/scripts/workbench/store.mjs +243 -0
  99. package/scripts/workbench/sync-coordinator.mjs +518 -0
  100. package/scripts/workbench/sync.mjs +86 -0
  101. package/references/context-template.md +0 -341
  102. package/references/feature-chain-methodology.md +0 -228
  103. package/references/register-template.md +0 -85
  104. package/references/task-case-template.md +0 -63
  105. package/tests/BC-20260618-063.sh +0 -116
  106. package/tests/BC-20260618-065.sh +0 -66
  107. package/tests/BC-20260626-080.sh +0 -48
  108. package/tests/BC-20260626-081.sh +0 -40
  109. package/tests/BC-20260626-082.sh +0 -32
  110. package/tests/BC-20260626-083.sh +0 -66
  111. package/tests/BC-20260627-084.sh +0 -74
  112. package/tests/BC-20260630-086.sh +0 -50
  113. package/tests/BC-20260630-087.sh +0 -103
  114. package/tests/BC-20260630-088.sh +0 -32
  115. package/tests/BC-20260630-089.sh +0 -63
  116. package/tests/BC-20260701-090.sh +0 -84
  117. package/tests/BC-20260702-096.sh +0 -48
  118. package/tests/BC-20260706-098.sh +0 -66
  119. package/tests/BC-20260707-099.sh +0 -47
  120. package/tests/BC-20260707-100.sh +0 -46
  121. package/tests/BC-20260707-101.sh +0 -47
  122. package/tests/BC-20260707-102.sh +0 -68
  123. package/tests/BC-20260707-103.sh +0 -59
  124. package/tests/BC-20260707-104.sh +0 -103
  125. package/tests/BC-20260707-105.sh +0 -109
  126. package/tests/BC-20260707-106.sh +0 -80
  127. package/tests/BC-20260707-107.sh +0 -74
  128. package/tests/BC-20260707-108.sh +0 -48
  129. package/tests/BC-20260707-109.sh +0 -56
  130. package/tests/BC-20260707-110.sh +0 -71
  131. package/tests/BC-20260707-111.sh +0 -70
  132. package/tests/BC-20260707-112.sh +0 -45
  133. package/tests/BC-20260707-113.sh +0 -73
  134. package/tests/BC-20260707-115.sh +0 -77
  135. package/tests/BC-20260707-116.sh +0 -77
  136. package/tests/BC-20260707-118.sh +0 -115
  137. package/tests/BC-20260707-119.sh +0 -47
  138. package/tests/BC-20260707-120.sh +0 -60
  139. package/tests/BC-20260707-121.sh +0 -66
  140. package/tests/BC-20260707-122.sh +0 -48
  141. package/tests/BC-20260707-123.sh +0 -43
  142. package/tests/BC-20260707-124.sh +0 -56
  143. package/tests/BC-20260707-125.sh +0 -64
  144. package/tests/BC-20260707-126.sh +0 -80
  145. package/tests/BC-20260707-127.sh +0 -88
  146. package/tests/BC-20260707-129.sh +0 -59
  147. package/tests/BC-20260707-130.sh +0 -69
  148. package/tests/BC-20260707-131.sh +0 -140
  149. package/tests/BC-20260707-132.sh +0 -150
  150. package/tests/BC-20260707-133.sh +0 -70
  151. package/tests/BC-20260708-136.sh +0 -210
  152. package/tests/BC-20260708-137.sh +0 -106
  153. package/tests/BC-20260708-138.sh +0 -168
  154. package/tests/BC-20260708-139.sh +0 -79
  155. package/tests/BC-20260709-002.sh +0 -63
  156. package/tests/BC-20260709-003.sh +0 -239
  157. package/tests/BC-20260709-006.sh +0 -76
  158. package/tests/BC-20260709-008.sh +0 -168
  159. package/tests/BC-20260710-001.sh +0 -61
  160. package/tests/BC-20260710-002.sh +0 -111
  161. package/tests/npm-install-smoke.sh +0 -53
@@ -0,0 +1,120 @@
1
+ # 记忆定义与撰写规范
2
+
3
+ 版本:v0.2
4
+
5
+ 读者:Coordinator。创建、修改、合并或清理项目与节点记忆前阅读本文。
6
+
7
+ 本文规定项目记忆和节点记忆写什么、怎样组织,以及 Coordinator 何时维护。文档随 Main Map 版本保存,使用现有 `edit_map` 和单文件读取接口;不新增权限体系。自动更新记忆仍未实现。
8
+
9
+ ## 记忆的定义
10
+
11
+ 记忆是供 Agent 接手项目时阅读的最新项目说明,不是完整对话、操作日志或任务记录的集合。项目记忆作为静态上下文,在用户第一次对话前由 Agent 阅读;节点记忆提供对应模块的细节,在处理该模块时按需读取。
12
+
13
+ 了解项目不是读完所有对话或文档,而是能够回答以下六方面的问题。
14
+
15
+ - **目标**:项目为什么存在,要解决什么问题,做到什么程度才算成功,以及明确不解决哪些问题。
16
+ - **用户**:谁会使用项目,在什么情况下使用,想完成什么事情,对使用方式有什么要求。
17
+ - **能力**:项目目前能做什么,每项功能接收什么、产生什么结果,在什么条件下可用,有哪些限制。
18
+ - **协作**:项目由哪些模块组成,各自负责什么,谁调用谁,信息如何传递,哪些事情必须配合完成。
19
+ - **进展**:对照目标,哪些已经完成并验证,哪些尚未完成,当前卡在哪里。只保留最新状态,不记录操作过程。
20
+ - **约束**:后续开发必须遵守哪些规则,哪些决定已经确认,为什么这样决定。尚未确定的讨论不能作为规则。
21
+
22
+ ## 文档位置与标题
23
+
24
+ 项目级和节点级都使用 Markdown。下面的位置指服务器上的逻辑记忆目录,不是要求在源码仓库中新增这些文件;服务器保存权威版本,本地只作为缓存或待同步草稿。项目根节点的 `memoryDocument` 投影为项目 `memory.md`,其他节点的同名字段投影到各节点目录的 `memory.md`。没有文档的节点不生成空文件。
25
+
26
+ 旧 `memories[]` 卡片不再是日常记忆编辑入口。工作台只提供按需打开的只读历史迁移预览,保留原文、附件引用和提案依据等元数据;用户可复制历史,人工整理到对应记忆文档并明确保存。预览不自动归类、追加正文、删除历史或生成完成事项记忆;保存仍使用现有版本校验事务,冲突时保留草稿。
27
+
28
+ | 文档 | 逻辑位置 | 一级标题 |
29
+ | --- | --- | --- |
30
+ | 项目记忆 | 项目根目录 `memory.md` | `# 项目名称 · 项目记忆` |
31
+ | 节点记忆 | 对应节点目录 `memory.md` | `# 节点名称 · 节点记忆` |
32
+
33
+ 项目记忆固定使用六个二级标题,名称和顺序不得更换:
34
+
35
+ ```markdown
36
+ # 项目名称 · 项目记忆
37
+
38
+ ## 目标
39
+
40
+ ## 用户
41
+
42
+ ## 能力
43
+
44
+ ## 协作
45
+
46
+ ## 进展
47
+
48
+ ## 约束
49
+ ```
50
+
51
+ 节点记忆沿用相同的六个标题及顺序,只保留适用的部分,不用其他名称代替它们。适用但尚未明确的内容可以注明“尚未确认”,不能为了填满章节而编造。
52
+
53
+ 正文使用自然段或列表。目标、能力和规则适合逐点列出;职责和协作关系适合连贯说明。不要把每条记忆写成“编号/内容/依据/更新”的表单,不强制附加 P、R、E 或 001 等编号。
54
+
55
+ 来源、修改时间和历史版本由系统记录,不要求 Coordinator 在正文反复填写。需要向人展示日期时使用 `YYYYMMDD`。这不表示可以省略事实核实或修改追踪。
56
+
57
+ ## 项目与节点分别写什么
58
+
59
+ | 部分 | 项目记忆 | 节点记忆 |
60
+ | --- | --- | --- |
61
+ | 目标 | 整个项目解决的问题、成功标准和不做的事情 | 本模块承担的目标、职责边界和不负责的事情 |
62
+ | 用户 | 项目的使用者、主要场景和使用要求 | 使用本模块的人或调用它的其他模块,以及他们要完成的事情 |
63
+ | 能力 | 主要能力概览和影响全局的限制 | 具体功能、输入输出、使用条件和局部限制 |
64
+ | 协作 | 主要模块的分工与整体协作关系 | 与其他模块的依赖、调用和信息传递关系 |
65
+ | 进展 | 整体完成情况、尚未完成的主要能力和关键阻塞 | 本模块已验证的结果、未完成部分和局部阻塞 |
66
+ | 约束 | 全项目必须遵守的要求和已确认的取舍 | 本模块修改时必须保留的行为、兼容要求和局部规则 |
67
+
68
+ 项目记忆应让 Agent 先理解全貌,不展开所有模块细节。节点记忆应让 Agent 理解处理该模块所需的背景,不复制项目级规则,也不承诺代替阅读代码和接口文档。
69
+
70
+ ### 如何处理每个节点
71
+
72
+ - 记忆跟随节点所代表的职责,不跟随某次任务或某个执行 Session。同一模块的多次开发更新同一份节点记忆。
73
+ - 只影响某个节点的内容写在该节点;改变全局目标、整体协作或全局规则时,才更新项目记忆。
74
+ - 有子节点时,父节点说明整体职责和子节点分工,具体行为留在对应子节点。只有会影响父级判断的变化才向上概括,不把子节点正文逐份复制上去。
75
+ - 涉及多个模块时,各节点写自己的责任,项目级或共同父节点说明整体关系;引用实际存在的节点或文档,不为记忆另造一套模块分类。
76
+ - 节点移动或改名后,Coordinator 检查记忆中的名称、关系与链接是否仍然正确。删除节点时,检查是否有仍有效的项目知识需要保留,不把全部旧记录搬到父节点。
77
+ - 没有足够信息的节点不强行生成完整文档。已有任务记录、代码路径或一句节点名称,不足以证明模块能力已经实现。
78
+
79
+ ## Coordinator 的维护职责
80
+
81
+ 项目记忆和节点记忆统一由 Coordinator 整理与更新。人类可以直接编辑;Executor 和 Tester 提供实际结果及修改建议,不直接覆盖项目或节点的权威记忆。各 Agent 的工作记录不等于项目记忆。
82
+
83
+ ### 谁决定内容
84
+
85
+ | 内容 | 决定与核实方式 |
86
+ | --- | --- |
87
+ | 目标、目标用户、用户需求、业务约束 | 由人类决定。Coordinator 只能根据明确确认更新,不能从随口建议或自己的推测中认定要求已变化 |
88
+ | 已实现能力和技术限制 | Executor 回报实现,Tester 提供独立验证;Coordinator 对照相同实现版本更新,不能将方案直接写成现有能力 |
89
+ | 模块职责与协作 | Coordinator 对照已批准方案和实际改动更新;超出方案的职责调整先向人类确认 |
90
+ | 开发、测试进展与阻塞 | Executor 回报开发情况,Tester 回报测试情况,Coordinator 根据实际结果更新,不需要人类替 Agent 判断每项技术事实 |
91
+ | 用户验收状态 | 由人类决定,Coordinator 记录结论;测试通过不能代替用户验收 |
92
+
93
+ 一段内容同时包含“人的要求”和“当前实现”时,要分开写。实现不符合要求,应在进展中说明差距,不能修改目标或约束来迁就实现。
94
+
95
+ ### 何时考虑更新
96
+
97
+ | 流程时点 | Coordinator 要检查的内容 |
98
+ | --- | --- |
99
+ | 人类明确确认需求、规则或纠正记忆后 | 目标、用户、约束是否变化,是否需要修正现有说法 |
100
+ | 方案审核通过后 | 是否需要记录已批准的决定或当前计划;尚未实施的方案不能写成已经存在的能力或协作关系 |
101
+ | Executor 回报实现或阻塞后 | 开发进展、实际改动和待验证内容是否变化,哪些内容还需 Tester 核实 |
102
+ | Tester 回报结果后 | 已验证的能力、技术限制和测试进展是否变化;验证结果是否对应 Executor 回报的实现版本 |
103
+ | 人类验收后 | 更新验收结论;通过时整理最终说明,拒绝时保留未完成状态和待解决的问题 |
104
+ | 节点结构变化或人类直接编辑记忆后 | 相关文档是否重复、过时或矛盾;不能用旧摘要覆盖人的新决定 |
105
+
106
+ 以上是检查时点,不是强制写入时点。没有新信息、没有错误、没有过时内容,就不修改。
107
+
108
+ ## 撰写与编辑要求
109
+
110
+ 1. **写能指导后续工作的内容。** 保留理解项目、作出决定或避免重复踩坑所需的信息,不因一段话能归入六类之一就全部保存。
111
+ 2. **写清楚,不凑字段。** 一句话能说明就写一句;需要交代条件、边界和原因时可以写一小段。有关联的内容连贯表达,不为缩短字数拆成看不懂的碎片。
112
+ 3. **先核实,再写成事实。** 区分用户要求、计划、实际实现、测试结果和验收结论。历史记录、Agent 自述或过时页面不能单独证明当前状态。
113
+ 4. **优先修改原文。** 同一事实有了变化,更新对应段落;重复内容合并,已经无效的说法从当前正文移除,历史由版本记录保留。
114
+ 5. **不要静默解决矛盾。** 来源冲突时先核实。涉及目标和业务规则的分歧交人类决定;技术事实回到代码和验证结果确认。核实前不能择一写成定论。
115
+ 6. **进展只讲当前结论。** 说明完成到哪、还有什么没完成、卡在哪里;不写每次命令、重启、重试或聊天过程。不用“刚刚”“昨天”等离开对话就不明确的说法。
116
+ 7. **不要把任务局部要求扩大成全局规则。** 只适用于某次任务的条件留在任务记录;确实影响后续模块工作的要求才进入节点记忆,影响整个项目的才进入项目记忆。
117
+ 8. **不保存无关和敏感内容。** 不把寒暄、原始日志、临时调试输出、个人琐事、密码或令牌写进记忆。详细测试证据和操作过程留在各自记录中。
118
+ 9. **遵守已有写入机制。** 编辑前读取权威版本,保存时使用现有版本校验和权限。遇到冲突保留草稿并重新核对,不覆盖其他修改;保存失败不能报告已更新。
119
+
120
+ 提交修改前,Coordinator 应确认:标题没有变、范围放对了、事实有根据、旧说法已处理、没有重复或流水账。版本、记录与发布仍遵循现有协议,本规范不新增接口。
@@ -0,0 +1,162 @@
1
+ # Bug.md format
2
+
3
+ ## Status
4
+
5
+ - `Open`: recorded, not started.
6
+ - `InProgress`: the Executor and Tester workflow is not complete.
7
+ - `Pending`: tests are complete and human acceptance is pending.
8
+ - `Resolved`: human acceptance passed.
9
+ - `Unfixable`: cannot be fixed; the workflow ends and the record stays. This is not deferral.
10
+
11
+ **No deferred bugs.** Do not use `Deferred`. If the bug does not need a fix, **delete the Bug file** (it disappears from the index). Do not keep a `WontFix` parking status.
12
+
13
+ Store images and other binaries separately; this Markdown file only holds a reference link.
14
+
15
+ The migration generator projects leftover `deferred` values as `Unfixable` and omits leftover `wontfix` files. Neither becomes `Open`.
16
+
17
+ Attribution attempts use only `Confirmed` and `Refuted`. A supported attribution starts as `Confirmed`. A later attempt changes it to `Refuted` and adds `RefutedBy` and the reason.
18
+
19
+ ## Template
20
+
21
+ ```md
22
+ # <Bug ID> <Title>
23
+
24
+ Reporter: <Human|Agent>
25
+ Status: <Open|InProgress|Pending|Resolved|Unfixable>
26
+ CurrentAttempt: <A1...An>
27
+
28
+ ## 1. Phenomenon
29
+
30
+ <Original observable phenomenon>
31
+
32
+ ## 2. Later correction events
33
+
34
+ - <Attempt / Human|Agent>: <Feedback or new evidence>
35
+
36
+ ## 3. Reproduction
37
+
38
+ ### A1
39
+ <Reproduction steps for this attempt>
40
+
41
+ ## 4. Cause and code changes
42
+
43
+ ### Current valid conclusion
44
+ <Causes and fixes that still hold>
45
+
46
+ ### A1
47
+ Status: <Confirmed|Refuted>
48
+ RefutedBy: <Attempt, only when Refuted>
49
+ Reason: <Reason, only when Refuted>
50
+
51
+ Cause: <Attribution made by that attempt>
52
+
53
+ #### code index
54
+ - `<code path>`
55
+ <Change summary>
56
+
57
+ ## 5. Tests
58
+
59
+ - [A1](tests/<Bug ID>-A1.md): <one-line result>
60
+
61
+ ## 6. Repair Session index
62
+
63
+ - [A1](traces/<Bug ID>-A1.md)
64
+ ```
65
+
66
+ The Tests section does not record human acceptance. The Session section contains links only.
67
+
68
+ ## Four-attempt example
69
+
70
+ ```md
71
+ # B002 Repeated clicks create duplicate feedback
72
+
73
+ Reporter: Human
74
+ Status: Pending
75
+ CurrentAttempt: A4
76
+
77
+ ## 1. Phenomenon
78
+
79
+ Clicking submit again before the first request finishes creates two identical feedback records.
80
+
81
+ ## 2. Later correction events
82
+
83
+ - A1 / Human: rapid double-click still duplicates; acceptance failed because disabling the button misses the queued second event.
84
+ - A2 / Human: retry after a weak-network timeout still duplicates; the synchronous lock covers one window only.
85
+ - A3 / Agent B: two windows can submit the same draft; the request-key lookup does not prevent concurrent creation.
86
+ - A4 / Tester B: concurrency, retry, and conflict regressions pass; awaiting human acceptance.
87
+
88
+ ## 3. Reproduction
89
+
90
+ ### A1
91
+ Enter feedback and double-click Submit.
92
+
93
+ ### A2
94
+ Delay the first request until timeout, then retry in the UI.
95
+
96
+ ### A3
97
+ Let the server create the record, drop the response, and retry with the same request key.
98
+
99
+ ### A4
100
+ Submit the same draft from two windows; retry with the same key and same content, then the same key and different content.
101
+
102
+ ## 4. Cause and code changes
103
+
104
+ ### Current valid conclusion
105
+ A synchronous UI lock prevents single-window re-entry. An atomic server uniqueness constraint guarantees one record across windows and retries, while different content with the same key returns a conflict.
106
+
107
+ ### A1
108
+ Status: Refuted
109
+ RefutedBy: A2
110
+ Reason: the second queued click occurs before the disabled state is committed.
111
+
112
+ Cause: the submit button permits repeated clicks.
113
+
114
+ #### code index
115
+ - `src/ui/FeedbackForm.tsx`
116
+ Disable the button when submission starts.
117
+
118
+ ### A2
119
+ Status: Confirmed
120
+
121
+ Cause: there is a re-entry window before UI state updates.
122
+
123
+ #### code index
124
+ - `src/ui/submitFeedback.ts`
125
+ Add a synchronous lock at the submission boundary.
126
+
127
+ ### A3
128
+ Status: Refuted
129
+ RefutedBy: A4
130
+ Reason: request-key lookup and insertion are not atomic.
131
+
132
+ Cause: retry does not reuse an existing record; reusing the request key is sufficient.
133
+
134
+ #### code index
135
+ - `src/server/createFeedback.ts`
136
+ Look up the request key before creation.
137
+
138
+ ### A4
139
+ Status: Confirmed
140
+
141
+ Cause: concurrent requests can both pass the non-atomic lookup.
142
+
143
+ #### code index
144
+ - `src/storage/migrations/004_feedback_unique_key.sql`
145
+ Add a unique constraint over user and request key.
146
+ - `src/server/createFeedback.ts`
147
+ Create atomically; return the existing record on an equivalent conflict and reject different content.
148
+
149
+ ## 5. Tests
150
+
151
+ - [A1](tests/B002-A1.md): repeated clicks still reproduce the bug.
152
+ - [A2](tests/B002-A2.md): one window passes; network retry fails.
153
+ - [A3](tests/B002-A3.md): sequential retry passes; concurrency fails.
154
+ - [A4](tests/B002-A4.md): concurrency, timeout retry, and conflict regressions pass.
155
+
156
+ ## 6. Repair Session index
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,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
+ ```