@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,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
+ ```
@@ -0,0 +1,137 @@
1
+ # Todo.md 格式
2
+
3
+ ## 状态
4
+
5
+ - `Open`:已记录,尚未开始。
6
+ - `InProgress`:Executor 与 Tester 的流程尚未结束。
7
+ - `Done`:当前需求已经验收完成。
8
+
9
+ 方案轮次使用 `Confirmed` 和 `Refuted`。后续需求或证据推翻旧方案时,更新旧轮次并写明 `RefutedBy` 与原因。
10
+
11
+ 迁移兼容说明:当前生成器的 Todo A1 可能缺少 `Status`。这是尚未符合本格式的旧投影,不是第三种归因状态;修复生成器前不得自行补写或把缺失状态当成 `Confirmed`。
12
+
13
+ ## 格式
14
+
15
+ ```md
16
+ # <Todo ID> <标题>
17
+
18
+ Reporter: <Human|Agent>
19
+ Status: <Open|InProgress|Done>
20
+ CurrentAttempt: <A1...An>
21
+
22
+ ## 1. 需求
23
+
24
+ <用户确认的目标>
25
+
26
+ ## 2. 后续调整事件
27
+
28
+ - <A轮次 / Human|Agent>:<新增约束或范围变化>
29
+
30
+ ## 3. 验收标准
31
+
32
+ ### A1
33
+ <该轮可执行验收标准>
34
+
35
+ ## 4. 方案与代码改动
36
+
37
+ ### 当前有效方案
38
+ <仍成立的方案结论>
39
+
40
+ ### A1
41
+ Status: <Confirmed|Refuted>
42
+ RefutedBy: <A轮次,仅 Refuted 时出现>
43
+ Reason: <推翻原因,仅 Refuted 时出现>
44
+
45
+ 方案:<该轮方案>
46
+
47
+ #### code index
48
+ - `<代码路径>`
49
+ <改动简介>
50
+
51
+ ## 5. 测试
52
+
53
+ - [A1](tests/<Todo ID>-A1.md):<一句结果>
54
+
55
+ ## 6. 实现 Session 索引
56
+
57
+ - [A1](traces/<Todo ID>-A1.md)
58
+ ```
59
+
60
+ ## 三轮示例
61
+
62
+ ```md
63
+ # T002 补充反馈提交中的状态
64
+
65
+ Reporter: Human
66
+ Status: InProgress
67
+ CurrentAttempt: A3
68
+
69
+ ## 1. 需求
70
+
71
+ 反馈提交期间显示明确状态,并阻止同一提交重复执行。
72
+
73
+ ## 2. 后续调整事件
74
+
75
+ - A1 / Human:按钮禁用后无法取消,要求保留取消操作。
76
+ - A2 / Human:多个窗口仍会重复提交,范围扩展到跨窗口一致性。
77
+ - A3 / Executor B:采用服务端请求键,补充同键不同内容的冲突规则。
78
+
79
+ ## 3. 验收标准
80
+
81
+ ### A1
82
+ 提交中显示进度;重复点击不产生第二个请求;用户可以取消。
83
+
84
+ ### A2
85
+ 两个窗口提交同一草稿时只创建一条记录。
86
+
87
+ ### A3
88
+ 同键同内容返回同一记录;同键不同内容返回冲突;取消后允许新请求。
89
+
90
+ ## 4. 方案与代码改动
91
+
92
+ ### 当前有效方案
93
+ 客户端状态机负责进度与取消,服务端请求键和唯一约束负责跨窗口幂等。
94
+
95
+ ### A1
96
+ Status: Refuted
97
+ RefutedBy: A2
98
+ Reason: 仅禁用按钮不能满足取消和跨窗口一致性。
99
+
100
+ 方案:提交时禁用按钮并显示加载状态。
101
+
102
+ #### code index
103
+ - `src/ui/FeedbackForm.tsx`
104
+ 增加提交中状态。
105
+
106
+ ### A2
107
+ Status: Confirmed
108
+
109
+ 方案:使用可取消状态机管理单窗口提交。
110
+
111
+ #### code index
112
+ - `src/ui/feedbackSubmission.ts`
113
+ 管理 idle、submitting、cancelling 状态。
114
+
115
+ ### A3
116
+ Status: Confirmed
117
+
118
+ 方案:服务端以用户和请求键保证原子幂等。
119
+
120
+ #### code index
121
+ - `src/server/createFeedback.ts`
122
+ 校验请求键并处理唯一键冲突。
123
+ - `src/storage/migrations/004_feedback_unique_key.sql`
124
+ 增加组合唯一约束。
125
+
126
+ ## 5. 测试
127
+
128
+ - [A1](tests/T002-A1.md):进度通过,取消失败。
129
+ - [A2](tests/T002-A2.md):单窗口通过,跨窗口失败。
130
+ - [A3](tests/T002-A3.md):状态、取消、跨窗口与冲突回归通过。
131
+
132
+ ## 6. 实现 Session 索引
133
+
134
+ - [A1](traces/T002-A1.md)
135
+ - [A2](traces/T002-A2.md)
136
+ - [A3](traces/T002-A3.md)
137
+ ```
@@ -0,0 +1,7 @@
1
+ # Todo Coordinator
2
+
3
+ Todo 模式下负责:
4
+
5
+ - 在 `1. 需求` 记录用户确认的目标。
6
+ - 将后续范围或目标变化追加到 `2. 后续调整事件`,并启动新的 A 轮次。
7
+ - 协调 Executor 与 Tester 完成当前轮次,并维护整体流程状态。
@@ -0,0 +1,7 @@
1
+ # Todo Executor
2
+
3
+ Todo 模式下负责当前轮次:
4
+
5
+ - 根据需求和验收标准执行任务,包括代码修改、实现、修复。
6
+ - 在 `4. 方案与代码改动` 记录方案、改动摘要和 `code index`。
7
+ - 后续方案推翻旧方案时,为旧轮次补充 `RefutedBy` 与原因。
@@ -0,0 +1,7 @@
1
+ # Todo Tester
2
+
3
+ Todo 模式下负责当前轮次:
4
+
5
+ - 在 `3. 验收标准` 完善可执行的验收条件。
6
+ - 编写并执行该轮测试记录。
7
+ - Todo.md 的 `5. 测试` 只登记对应 A 轮次的测试链接和一句结果。
@@ -0,0 +1,124 @@
1
+ # Project-named local workbench
2
+
3
+ `context-guard workbench --root /path/to/project` now prints an HTTP URL such as
4
+ `http://my-project.localhost:1355/prototype/workbench.html`. SessionStart uses the
5
+ same entry. No global Portless install, DNS edit, certificate, administrator
6
+ permission, or additional npm runtime dependency is needed.
7
+
8
+ The name is derived from the Map's project name and normalized to lowercase DNS
9
+ letters, digits and hyphens (`Context_Guard` becomes `context-guard`). Non-ASCII
10
+ only names use a stable `project-<id>` fallback. Set a readable explicit name with:
11
+
12
+ ```sh
13
+ context-guard workbench --root /path/to/project --name my-project
14
+ ```
15
+
16
+ Different projects cannot take over the same registered name, even when a backend
17
+ is stopped. Choose another name; this command never kills the other project.
18
+ Runtime routes are private local state, not project memory or files to commit.
19
+
20
+ ## Multiple sessions and worktrees
21
+
22
+ Linked Git worktrees share one project service. Bindings are keyed by the real
23
+ Session ID, never by branch: two Sessions on one branch remain independent. Once
24
+ a project workbench has been established, a new unbound Session automatically
25
+ reuses the unique matching registered workbench. Human confirmation is required
26
+ only for the project's first workbench, an ambiguous/mismatched candidate, or an
27
+ explicit move of an already-bound Session to another worktree.
28
+ The legacy service-target command remains available:
29
+
30
+ ```sh
31
+ context-guard workbench bind --root /path/to/second-worktree --project-root /path/to/map-worktree
32
+ ```
33
+
34
+ The two paths must have the same local Git common directory. Unrelated clones,
35
+ same-name folders and different repositories are not silently joined. Binding
36
+ chains are rejected. Stop any service in the second worktree first, after saving
37
+ its drafts. The target Map must already exist; this command does not create one.
38
+ If the second worktree has its own Map, binding fails unless `--keep-local` is
39
+ explicitly provided. That flag preserves its files unchanged; it does not merge
40
+ or delete data, and does not authorize a Session binding.
41
+
42
+ The target selects only the service. Python lifecycle records stay in the source
43
+ worktree; the service keeps Maps isolated by Session/worktree identity. Existing
44
+ records are not migrated to the target. First-use or ambiguous hooks ask for
45
+ confirmation and do not guess a service or open a browser. A unique established
46
+ project binding is reused automatically. All Sessions remains the read-only published
47
+ main baseline, never the target worktree's unmerged Map. See `server-memory.md`
48
+ for the private-memory deployment and publication boundary.
49
+
50
+ The named entry and project identity are shared in the Git common directory. A
51
+ user-private global registry at `~/.context-guard/named-workbench/projects.json`
52
+ also records every established local project, its known worktree roots and its
53
+ canonical URL. It lives outside the replaceable Skill directory, so reinstalling
54
+ or upgrading the Skill does not erase bindings or create a second workbench.
55
+ Restarting the backend from another linked worktree retains the project's URL.
56
+ Inspect every known project without starting or stopping a service with
57
+ `context-guard workbench --list --root /path/to/current/project`. The command
58
+ does not equate historical registration with liveness: it probes the backend
59
+ and named route, includes route-only legacy instances, deduplicates the same
60
+ physical instance across linked worktrees, and returns separate
61
+ `registeredCount`, `runningCount`, `readyCount`, `stoppedCount`, and
62
+ `attentionCount` values. Project entries expose readable names, canonical URLs
63
+ and states (`ready`, `direct-only`, `legacy`, `duplicate`, `route-stale`,
64
+ `route-mismatch`, `stopped`, or `unknown`) without user-facing Session, Git or
65
+ backend instance identifiers. `unknown` means a recorded owner process is still
66
+ alive but did not answer the bounded health probe; it must not be treated as
67
+ stopped or replaced automatically.
68
+
69
+ When opening is requested, it is claimed atomically by the backend: live workbench pages
70
+ suppress another open, and parallel first starts share a five-second opening
71
+ window. A failed browser launch can therefore delay a retry for five seconds.
72
+ An explicit CLI command still prints the URL for manual opening. Headless/CI and
73
+ resume/compact hooks do not open a browser. SessionStart validates the binding and
74
+ injects the URL without automatically opening another page.
75
+
76
+ ## Process lifecycle and compatibility
77
+
78
+ One loopback-only HTTP proxy is shared across projects, independent of each
79
+ backend. Closing one project does not close the proxy or other projects. The
80
+ proxy does no directory polling, certificate work, LAN exposure or tunnelling.
81
+ SSE is streamed; WebSockets are intentionally unsupported.
82
+
83
+ Default proxy port is 1355. If another application (including full Portless) owns
84
+ it, the proxy chooses a free port among the next 20 and returns that actual URL;
85
+ it never takes over the existing listener. The chosen URL still has a port. A
86
+ proxy/backend crash is recovered on the next `workbench`/SessionStart invocation;
87
+ there is no always-polling supervisor. Run the command again after an unexpected
88
+ exit. A still-live but unhealthy owner fails visibly instead of being killed.
89
+
90
+ Each forwarded request checks the backend's instance identity before sending
91
+ capabilities. Host, Origin and the forwarding capability are checked; agent
92
+ grants and cross-project token isolation remain in force. These are local
93
+ single-user safeguards, not protection against another process running with
94
+ full access to the same user's files.
95
+
96
+ A recognized older backend or named proxy is upgraded in place on the next bound
97
+ lifecycle or `workbench` command. The proxy preserves its route store and must
98
+ acknowledge an authenticated stop before replacement. The old backend must first
99
+ acknowledge its synchronization fence and release the project lock; otherwise the
100
+ command returns `UPGRADE_PENDING` and does not start a replacement. Unknown legacy
101
+ runtimes and duplicate owners still require explicit diagnosis/migration. Browser
102
+ recovery storage remains on the stable project origin, so a normal compatible
103
+ upgrade does not change its storage boundary.
104
+
105
+ - `CONTEXT_GUARD_NAMED_WORKBENCH=0` or `--direct`: old direct loopback URL.
106
+ - `CONTEXT_GUARD_NAMED_STATE_DIR`: isolated private proxy state directory (default
107
+ `~/.context-guard/named-workbench`). Never share this directory across OS users.
108
+ - `CONTEXT_GUARD_NAMED_PORT`: preferred proxy port, default 1355.
109
+
110
+ ## Attribution and tests
111
+
112
+ The reduced route store derives from Portless 0.15.6 under Apache-2.0. See
113
+ `THIRD_PARTY_NOTICES.md` and `licenses/Portless-Apache-2.0.txt`; both are included
114
+ in the npm package and installed Skill. The proxy/adapter are separate Context
115
+ Guard implementations, not a vendored full Portless CLI.
116
+
117
+ `tests/named-workbench.test.mjs` is part of `npm test`: authorization, Origin/Host,
118
+ read/write, five sessions/SSE streams, opening claims, name collision, backend
119
+ identity/port reuse, proxy restart, multi-project isolation, corrupt route state,
120
+ concurrent process startup, isolated test registries, persistent global registry,
121
+ recognized backend/proxy runtime upgrade, legacy route repair, explicit Git
122
+ worktree binding and the real Python SessionStart handler. This does not prove
123
+ delivery by every desktop host, OS or browser.
124
+ Outstanding coverage is tracked in `CI_todo.md`.
@@ -0,0 +1,12 @@
1
+ # 计划审核
2
+
3
+ Executor 把 Plan 交给 Coordinator 时适用。Executor 提交前按同一四项自检。
4
+
5
+ 只检查以下四项,全部成立才可通过:
6
+
7
+ 1. 范围与已确认需求一致
8
+ 2. 节点与 Ask user 的挂载一致
9
+ 3. 含有可检查的验收条件
10
+ 4. 未越出授权节点
11
+
12
+ 任一项不成立则退回,并指出不成立的项。你通过 Plan 后对方才可开发。你通过 Plan 不等于用户已验收。不得伪造审核回执。