patchwarden 1.5.0 → 1.5.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 (217) hide show
  1. package/README.en.md +43 -2
  2. package/README.md +43 -2
  3. package/dist/assessments/agentAssessor.d.ts +1 -1
  4. package/dist/assessments/agentAssessor.js +3 -3
  5. package/dist/assessments/assessmentStore.d.ts +1 -1
  6. package/dist/assessments/assessmentStore.js +2 -2
  7. package/dist/assessments/confirmCli.js +5 -4
  8. package/dist/config.d.ts +7 -0
  9. package/dist/config.js +34 -0
  10. package/dist/control/middleware/auth.d.ts +10 -0
  11. package/dist/control/middleware/auth.js +8 -0
  12. package/dist/control/middleware/static.d.ts +3 -0
  13. package/dist/control/middleware/static.js +65 -0
  14. package/dist/control/routes/audit.d.ts +15 -0
  15. package/dist/control/routes/audit.js +277 -0
  16. package/dist/control/routes/evidence.d.ts +4 -0
  17. package/dist/control/routes/evidence.js +96 -0
  18. package/dist/control/routes/lineage.d.ts +3 -0
  19. package/dist/control/routes/lineage.js +71 -0
  20. package/dist/control/routes/policy.d.ts +3 -0
  21. package/dist/control/routes/policy.js +81 -0
  22. package/dist/control/routes/process.d.ts +5 -0
  23. package/dist/control/routes/process.js +200 -0
  24. package/dist/control/routes/sessions.d.ts +22 -0
  25. package/dist/control/routes/sessions.js +224 -0
  26. package/dist/control/routes/status.d.ts +6 -0
  27. package/dist/control/routes/status.js +250 -0
  28. package/dist/control/routes/taskActions.d.ts +21 -0
  29. package/dist/control/routes/taskActions.js +233 -0
  30. package/dist/control/routes/tasks.d.ts +20 -0
  31. package/dist/control/routes/tasks.js +310 -0
  32. package/dist/control/routes/workspace.d.ts +15 -0
  33. package/dist/control/routes/workspace.js +193 -0
  34. package/dist/control/runtime.d.ts +91 -0
  35. package/dist/control/runtime.js +392 -0
  36. package/dist/control/server.d.ts +13 -0
  37. package/dist/control/server.js +479 -0
  38. package/dist/control/shared.d.ts +35 -0
  39. package/dist/control/shared.js +288 -0
  40. package/dist/controlCenter.d.ts +6 -0
  41. package/dist/controlCenter.js +7 -2197
  42. package/dist/direct/directGuards.js +30 -8
  43. package/dist/doctor.d.ts +18 -1
  44. package/dist/doctor.js +579 -348
  45. package/dist/goal/goalReport.d.ts +54 -0
  46. package/dist/goal/goalReport.js +204 -0
  47. package/dist/goal/goalStatus.d.ts +6 -0
  48. package/dist/goal/specKitImport.d.ts +63 -0
  49. package/dist/goal/specKitImport.js +220 -0
  50. package/dist/goal/subgoalSync.js +2 -1
  51. package/dist/httpServer.js +15 -12
  52. package/dist/index.js +7 -4
  53. package/dist/logging.d.ts +7 -1
  54. package/dist/logging.js +8 -0
  55. package/dist/runner/changeCapture.d.ts +3 -3
  56. package/dist/runner/changeCapture.js +63 -39
  57. package/dist/runner/cli.js +7 -6
  58. package/dist/runner/postTaskCleanup.js +26 -2
  59. package/dist/runner/runTask.js +245 -221
  60. package/dist/runner/simpleProcess.js +4 -4
  61. package/dist/runner/watch.js +17 -14
  62. package/dist/security/contentRedaction.d.ts +6 -0
  63. package/dist/security/contentRedaction.js +22 -0
  64. package/dist/smoke-test.js +257 -251
  65. package/dist/test/unit/apply-patch.test.d.ts +1 -0
  66. package/dist/test/unit/apply-patch.test.js +225 -0
  67. package/dist/test/unit/create-task.test.d.ts +1 -0
  68. package/dist/test/unit/create-task.test.js +197 -0
  69. package/dist/test/unit/direct-guards.test.js +124 -9
  70. package/dist/test/unit/evidence-pack.test.js +95 -1
  71. package/dist/test/unit/get-task-status.test.d.ts +1 -0
  72. package/dist/test/unit/get-task-status.test.js +174 -0
  73. package/dist/test/unit/get-task-summary.test.d.ts +1 -0
  74. package/dist/test/unit/get-task-summary.test.js +146 -0
  75. package/dist/test/unit/goal-report.test.d.ts +1 -0
  76. package/dist/test/unit/goal-report.test.js +159 -0
  77. package/dist/test/unit/goal-subgoal-task.test.js +6 -6
  78. package/dist/test/unit/goal-tools-registry.test.js +6 -4
  79. package/dist/test/unit/path-guard.test.js +24 -0
  80. package/dist/test/unit/spec-kit-import.test.d.ts +1 -0
  81. package/dist/test/unit/spec-kit-import.test.js +341 -0
  82. package/dist/test/unit/wait-for-task.test.d.ts +1 -0
  83. package/dist/test/unit/wait-for-task.test.js +144 -0
  84. package/dist/tools/auditTask.d.ts +8 -63
  85. package/dist/tools/auditTask.js +12 -8
  86. package/dist/tools/createDirectSession.d.ts +1 -1
  87. package/dist/tools/createDirectSession.js +2 -2
  88. package/dist/tools/createTask.d.ts +2 -2
  89. package/dist/tools/createTask.js +4 -4
  90. package/dist/tools/dispatch/coreDispatch.d.ts +9 -0
  91. package/dist/tools/dispatch/coreDispatch.js +282 -0
  92. package/dist/tools/dispatch/diagnosticDispatch.d.ts +14 -0
  93. package/dist/tools/dispatch/diagnosticDispatch.js +78 -0
  94. package/dist/tools/dispatch/directDispatch.d.ts +8 -0
  95. package/dist/tools/dispatch/directDispatch.js +115 -0
  96. package/dist/tools/dispatch/goalDispatch.d.ts +8 -0
  97. package/dist/tools/dispatch/goalDispatch.js +91 -0
  98. package/dist/tools/dispatch/releaseDispatch.d.ts +8 -0
  99. package/dist/tools/dispatch/releaseDispatch.js +45 -0
  100. package/dist/tools/dispatch/types.d.ts +23 -0
  101. package/dist/tools/dispatch/types.js +15 -0
  102. package/dist/tools/evidencePack.d.ts +6 -0
  103. package/dist/tools/evidencePack.js +213 -6
  104. package/dist/tools/finalizeDirectSession.d.ts +1 -1
  105. package/dist/tools/finalizeDirectSession.js +3 -3
  106. package/dist/tools/goalSubgoalTask.d.ts +1 -1
  107. package/dist/tools/goalSubgoalTask.js +2 -2
  108. package/dist/tools/healthCheck.js +3 -3
  109. package/dist/tools/registry.d.ts +3 -3
  110. package/dist/tools/registry.js +60 -503
  111. package/dist/tools/retryTask.d.ts +2 -2
  112. package/dist/tools/retryTask.js +2 -2
  113. package/dist/tools/runTaskLoop.js +4 -4
  114. package/dist/tools/safeViews.d.ts +2 -2
  115. package/dist/tools/safeViews.js +2 -2
  116. package/dist/tools/toolRegistry.js +22 -0
  117. package/dist/version.d.ts +1 -1
  118. package/dist/version.js +1 -1
  119. package/docs/CODE_WIKI.md +983 -0
  120. package/docs/agentseal-integration.md +150 -0
  121. package/docs/architecture.md +63 -0
  122. package/docs/assets/patchwarden-oss-demo.gif +0 -0
  123. package/docs/dashboard-overview.md +86 -0
  124. package/docs/demo.md +8 -0
  125. package/docs/direct-session-workflow.md +98 -0
  126. package/docs/evidence-pack-schema.md +215 -0
  127. package/docs/execution-plan-2026-07-09.md +315 -0
  128. package/docs/lineage-evidence-pack-workflow.md +127 -0
  129. package/docs/mcp-inspector-testing.md +200 -0
  130. package/docs/open-source-application.md +162 -0
  131. package/docs/opencode-worker.md +151 -0
  132. package/docs/openhands-worker.md +181 -0
  133. package/docs/release-evidence.md +72 -0
  134. package/docs/roadmap-execution-and-acceptance.md +365 -0
  135. package/docs/spec-kit-integration.md +131 -0
  136. package/docs/task-safe-review-workflow.md +98 -0
  137. package/docs/threat-model.md +79 -0
  138. package/docs/user-feedback.md +40 -0
  139. package/docs/why-patchwarden.md +110 -0
  140. package/package.json +2 -2
  141. package/scripts/checks/control-center-smoke.js +356 -0
  142. package/scripts/checks/lifecycle-smoke.js +29 -23
  143. package/scripts/checks/mcp-smoke.js +3 -1
  144. package/scripts/generate-demo-gif.py +320 -0
  145. package/src/assessments/agentAssessor.ts +3 -3
  146. package/src/assessments/assessmentStore.ts +2 -2
  147. package/src/assessments/confirmCli.ts +5 -4
  148. package/src/config.ts +37 -0
  149. package/src/control/middleware/auth.ts +17 -0
  150. package/src/control/middleware/static.ts +71 -0
  151. package/src/control/routes/audit.ts +321 -0
  152. package/src/control/routes/evidence.ts +107 -0
  153. package/src/control/routes/lineage.ts +92 -0
  154. package/src/control/routes/policy.ts +81 -0
  155. package/src/control/routes/process.ts +204 -0
  156. package/src/control/routes/sessions.ts +251 -0
  157. package/src/control/routes/status.ts +325 -0
  158. package/src/control/routes/taskActions.ts +248 -0
  159. package/src/control/routes/tasks.ts +323 -0
  160. package/src/control/routes/workspace.ts +203 -0
  161. package/src/control/runtime.ts +472 -0
  162. package/src/control/server.ts +471 -0
  163. package/src/control/shared.ts +294 -0
  164. package/src/controlCenter.ts +7 -2347
  165. package/src/direct/directGuards.ts +28 -7
  166. package/src/doctor.ts +741 -481
  167. package/src/goal/goalReport.ts +271 -0
  168. package/src/goal/goalStatus.ts +6 -0
  169. package/src/goal/specKitImport.ts +355 -0
  170. package/src/goal/subgoalSync.ts +4 -2
  171. package/src/httpServer.ts +17 -14
  172. package/src/index.ts +7 -4
  173. package/src/logging.ts +10 -1
  174. package/src/runner/changeCapture.ts +70 -42
  175. package/src/runner/cli.ts +7 -6
  176. package/src/runner/postTaskCleanup.ts +26 -2
  177. package/src/runner/runTask.ts +325 -223
  178. package/src/runner/simpleProcess.ts +4 -4
  179. package/src/runner/watch.ts +17 -14
  180. package/src/security/contentRedaction.ts +29 -0
  181. package/src/smoke-test.ts +252 -250
  182. package/src/test/unit/apply-patch.test.ts +293 -0
  183. package/src/test/unit/create-task.test.ts +255 -0
  184. package/src/test/unit/direct-guards.test.ts +178 -8
  185. package/src/test/unit/evidence-pack.test.ts +110 -1
  186. package/src/test/unit/get-task-status.test.ts +203 -0
  187. package/src/test/unit/get-task-summary.test.ts +173 -0
  188. package/src/test/unit/goal-report.test.ts +189 -0
  189. package/src/test/unit/goal-subgoal-task.test.ts +6 -6
  190. package/src/test/unit/goal-tools-registry.test.ts +7 -5
  191. package/src/test/unit/path-guard.test.ts +30 -0
  192. package/src/test/unit/spec-kit-import.test.ts +429 -0
  193. package/src/test/unit/wait-for-task.test.ts +176 -0
  194. package/src/tools/auditTask.ts +99 -59
  195. package/src/tools/createDirectSession.ts +3 -3
  196. package/src/tools/createTask.ts +7 -7
  197. package/src/tools/dispatch/coreDispatch.ts +374 -0
  198. package/src/tools/dispatch/diagnosticDispatch.ts +101 -0
  199. package/src/tools/dispatch/directDispatch.ts +167 -0
  200. package/src/tools/dispatch/goalDispatch.ts +127 -0
  201. package/src/tools/dispatch/releaseDispatch.ts +65 -0
  202. package/src/tools/dispatch/types.ts +24 -0
  203. package/src/tools/evidencePack.ts +291 -6
  204. package/src/tools/finalizeDirectSession.ts +4 -4
  205. package/src/tools/goalSubgoalTask.ts +2 -2
  206. package/src/tools/healthCheck.ts +3 -3
  207. package/src/tools/registry.ts +68 -628
  208. package/src/tools/retryTask.ts +2 -2
  209. package/src/tools/runTaskLoop.ts +4 -4
  210. package/src/tools/safeViews.ts +2 -2
  211. package/src/tools/toolRegistry.ts +22 -0
  212. package/src/version.ts +1 -1
  213. package/ui/pages/audit.html +192 -3
  214. package/ui/pages/dashboard.html +959 -44
  215. package/ui/pages/direct-sessions.html +505 -53
  216. package/ui/pages/task-detail.html +456 -438
  217. package/ui/pages/tasks.html +598 -61
@@ -0,0 +1,162 @@
1
+ # PatchWarden Open Source Application Brief
2
+
3
+ This brief is written for programs that evaluate open source maintainer work,
4
+ including Codex-style OSS support programs. It is evidence-oriented and avoids
5
+ claiming adoption that has not happened yet.
6
+
7
+ ## Project
8
+
9
+ - Repository: https://github.com/jiezeng2004-design/PatchWarden
10
+ - Package: `patchwarden`
11
+ - License: MIT
12
+ - Primary language: TypeScript
13
+ - Runtime: Node.js 18+
14
+ - Primary maintainer: `jiezeng2004-design`
15
+
16
+ PatchWarden is a local-first MCP safety and verification layer for AI coding
17
+ agents. It lets ChatGPT, Codex, OpenCode, or another MCP client plan and review
18
+ work while a preconfigured local agent performs bounded execution inside a
19
+ configured workspace.
20
+
21
+ ## Why This Matters For OSS Maintainers
22
+
23
+ AI coding workflows are becoming useful for maintainers, but many local bridges
24
+ solve convenience by exposing an unrestricted shell or broad filesystem access.
25
+ That is a poor default for open source work, where a maintainer may have
26
+ credentials, release artifacts, private issue context, unpublished patches, and
27
+ multiple repositories on the same machine.
28
+
29
+ PatchWarden narrows that workflow into an auditable task channel:
30
+
31
+ - workspace confinement through `workspaceRoot` and repo-scoped task paths
32
+ - pre-registered local agents instead of model-supplied shell commands
33
+ - exact allowlisted verification commands
34
+ - sensitive-path blocking for `.env`, tokens, SSH keys, cookies, and credential
35
+ material
36
+ - scope-violation detection for unexpected out-of-repository changes
37
+ - structured task artifacts, diffs, verification records, and evidence packs
38
+ - release checks that distinguish local verification from GitHub/npm truth
39
+
40
+ The goal is not to replace human maintainers. The goal is to make AI-assisted
41
+ maintenance reviewable enough for routine OSS work: small fixes, test
42
+ generation, documentation updates, release preflight checks, and post-task
43
+ audit.
44
+
45
+ ## Maintainer Role
46
+
47
+ I am the primary maintainer of PatchWarden. My work includes architecture,
48
+ security boundaries, MCP tool design, TypeScript implementation, CI, release
49
+ checklists, documentation, issue/PR templates, and package metadata.
50
+
51
+ The repository is early-stage, but it is not a throwaway demo. The project has a
52
+ documented safety model, bilingual README files, CI across Linux and Windows, a
53
+ private security reporting path, release notes, package verification scripts,
54
+ and a growing control center for safe summaries, audit views, lineage, and
55
+ evidence packs.
56
+
57
+ ## Current Public Evidence
58
+
59
+ Snapshot checked on 2026-07-12:
60
+
61
+ - GitHub repository: `jiezeng2004-design/PatchWarden`
62
+ - Stars: 2
63
+ - Forks: 0
64
+ - Open issues: 9 (`#25`, `#26`, `#28`–`#34`)
65
+ - Open pull requests: 2 (`#24`, `#37`, both draft)
66
+ - GitHub latest release: `v1.5.0`
67
+ - npm latest dist-tag: `patchwarden@1.5.0`
68
+ - Local source version in `package.json`: `1.5.1`
69
+
70
+ The source version is ahead of the latest public Release/npm package. Treat
71
+ `1.5.1` as pending release work until GitHub Release and npm are verified.
72
+
73
+ ## Existing Project Evidence
74
+
75
+ Repository-facing evidence already present:
76
+
77
+ - `README.md` and `README.en.md` explain the MCP bridge model, safety boundary,
78
+ setup, ChatGPT/Codex/OpenCode usage, and local data handling.
79
+ - `CHANGELOG.md` records ongoing releases from the 1.0 line through 1.5.x.
80
+ - `SECURITY.md` directs vulnerability reports to GitHub private security
81
+ advisories.
82
+ - `CONTRIBUTING.md` documents local verification and safety expectations.
83
+ - `.github/workflows/ci.yml` runs Node 20 checks on Ubuntu and Windows, full
84
+ regression tests, MCP smoke tests, HTTP MCP smoke tests, redacted doctor,
85
+ clean package verification, npm package-surface verification, and Gitleaks.
86
+ - `.github/ISSUE_TEMPLATE/` and `.github/PULL_REQUEST_TEMPLATE.md` guide bug,
87
+ feature, and safety review reports.
88
+ - `docs/release-checklist.md` separates local validation, PR review, GitHub
89
+ Release, npm publish, and remote publication verification.
90
+ - `docs/chatgpt-usage.md` documents safer ChatGPT connector usage patterns.
91
+ - `docs/demo.md` provides a privacy-safe demo flow.
92
+ - `docs/assets/patchwarden-chatgpt-demo.svg` provides a repository-safe visual
93
+ demo asset.
94
+ - `docs/assets/patchwarden-oss-demo.gif` provides a privacy-safe animated demo
95
+ of the maintainer workflow. It is scripted demo material, not adoption
96
+ evidence.
97
+
98
+ ## Related Project
99
+
100
+ RelayForge can be mentioned as a related local-first AI coding gateway project,
101
+ but PatchWarden should be the primary application repository because its safety
102
+ boundary and MCP maintainer workflow are more directly aligned with Codex-style
103
+ OSS automation.
104
+
105
+ ## Honest Gaps
106
+
107
+ PatchWarden should not claim broad adoption yet. The strongest current argument
108
+ is ecosystem importance, not stars or download volume.
109
+
110
+ Known gaps before submission:
111
+
112
+ - collect 3 to 5 real user reports through GitHub issues or discussions
113
+ - record a live screencast if stronger evidence is needed; a privacy-safe
114
+ scripted GIF now exists for the public maintainer workflow
115
+ - finish the `1.5.1` release only after PR/CI, GitHub Release, npm, and
116
+ `dist-tags.latest` are all verified
117
+ - add small contributor-friendly roadmap issues such as macOS docs, Codex CLI
118
+ examples, and a minimal demo repository
119
+
120
+ Do not fabricate feedback, usage numbers, or third-party endorsements.
121
+
122
+ ## Application Statement
123
+
124
+ PatchWarden addresses a growing safety gap in AI coding workflows: connecting
125
+ ChatGPT, Codex, OpenCode, and other MCP clients to local coding agents without
126
+ giving the upstream model unrestricted shell access. It provides workspace
127
+ confinement, command allowlists, sensitive-path blocking, scope-violation
128
+ detection, CI-backed regression tests, release verification, and auditable task
129
+ evidence. As the primary maintainer, I maintain the architecture, TypeScript
130
+ implementation, documentation, security policy, tests, release workflow, and
131
+ review process. The project is early, with low public adoption metrics, but it
132
+ directly supports safer OSS maintainer automation for Codex-style agents.
133
+
134
+ ## API Credits Use
135
+
136
+ API credits would be used for maintainer automation only:
137
+
138
+ - Codex-assisted pull request review
139
+ - security regression analysis
140
+ - release evidence review
141
+ - documentation consistency checks
142
+ - compatibility testing across ChatGPT, Codex, OpenCode, and MCP profiles
143
+ - issue triage and small test generation
144
+
145
+ Credits would not be used to publish releases automatically, bypass human
146
+ confirmation, inspect private credentials, or weaken PatchWarden's safety
147
+ boundary.
148
+
149
+ ## Submission Checklist
150
+
151
+ - [ ] Confirm GitHub stars, forks, issues, PRs, and latest release again on the
152
+ day of submission.
153
+ - [ ] Confirm `npm.cmd view patchwarden version dist-tags --json`.
154
+ - [ ] Confirm README version text matches the intended release story.
155
+ - [ ] Link `docs/threat-model.md`.
156
+ - [ ] Link `docs/release-evidence.md`.
157
+ - [ ] Link `docs/user-feedback.md` only after real feedback exists.
158
+ - [x] Prepare a privacy-safe scripted GIF without secrets or private workspace
159
+ names.
160
+ - [ ] Optionally record a live screencast for stronger external evidence.
161
+ - [ ] Do not click any final application submit button until the maintainer has
162
+ reviewed the form.
@@ -0,0 +1,151 @@
1
+ # OpenCode worker 集成模式
2
+
3
+ > 本文基于 v1.5.1 源码编写;安装时请使用已验证发布的 <published-version>。
4
+ > 说明:本文描述的是 PatchWarden 将 OpenCode 作为 worker agent 的集成模式建议。
5
+ > OpenCode 是独立的本地编程 Agent 项目,本文不声称任何官方集成关系。
6
+
7
+ ## OpenCode 是什么
8
+
9
+ OpenCode 是面向本地开发的编程 Agent,主要能力包括:
10
+
11
+ - 在本地仓库中读写文件、执行命令、运行测试。
12
+ - 接收自然语言任务描述并产出代码改动。
13
+ - 支持多种模型后端。
14
+
15
+ OpenCode 本身是通用 Agent,默认不具备 PatchWarden 的安全边界。
16
+ 本文描述如何让 PatchWarden 作为外部监督层,OpenCode 作为受约束的 worker。
17
+
18
+ ## External Supervisor Pattern
19
+
20
+ PatchWarden 与 OpenCode 的集成采用 **external supervisor pattern**:
21
+
22
+ ```
23
+ MCP 客户端 → PatchWarden(supervisor)→ OpenCode(worker)→ workspace
24
+ ↑ 安全边界在此
25
+ ```
26
+
27
+ - **PatchWarden 作为 supervisor**:接收 MCP 客户端的任务请求,
28
+ 负责工作区隔离、命令允许列表、范围违规检测、证据收集。
29
+ - **OpenCode 作为 worker**:在 PatchWarden 允许的范围内执行具体编码任务。
30
+ - **安全边界在 PatchWarden 侧**:OpenCode 的所有文件改动与命令执行
31
+ 必须经过 PatchWarden 的策略校验。
32
+
33
+ 关键点:OpenCode 不直接暴露给 MCP 客户端,而是由 PatchWarden 调度。
34
+ 这避免了 OpenCode 在无监督下执行越权操作。
35
+
36
+ ## 配置示例
37
+
38
+ ### 1. 在 PatchWarden 中注册 OpenCode agent
39
+
40
+ 在 `.patchwarden/config.json` 中注册 OpenCode:
41
+
42
+ ```json
43
+ {
44
+ "workspaceRoot": "D:\\repos\\my-project",
45
+ "agents": [
46
+ {
47
+ "name": "opencode",
48
+ "type": "local-worker",
49
+ "command": "opencode",
50
+ "args": ["--no-interactive"],
51
+ "workspace": "D:\\repos\\my-project"
52
+ }
53
+ ],
54
+ "evidencePackVersion": 2,
55
+ "safeResult": { "maxBytes": 4096 }
56
+ }
57
+ ```
58
+
59
+ ### 2. 配置 project-policy.json 约束 OpenCode 的操作范围
60
+
61
+ ```json
62
+ {
63
+ "allowedPaths": ["src/**", "test/**", "docs/**"],
64
+ "allowedCommands": [
65
+ "npm.cmd test",
66
+ "npm.cmd run build",
67
+ "git status",
68
+ "git diff",
69
+ "opencode --no-interactive"
70
+ ],
71
+ "blockedFiles": [".env", ".env.*", "id_rsa", "*.key", "*.pem", "cookies.db"],
72
+ "scopeRules": {
73
+ "enforceDeclaredFiles": true,
74
+ "blockOutOfWorkspace": true
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### 3. OpenCode 在 workspace 内执行
80
+
81
+ OpenCode 进程由 PatchWarden 启动并监督:
82
+
83
+ ```powershell
84
+ # PatchWarden 通过 MCP 工具 run_safe_task 调度 OpenCode
85
+ # MCP 客户端传入任务描述与声明的文件范围
86
+ # PatchWarden 在执行前校验范围,执行中监督,执行后收集证据
87
+ ```
88
+
89
+ ## 工作流示例
90
+
91
+ ### 任务:让 OpenCode 实现一个新模块
92
+
93
+ 1. **MCP 客户端发起任务**:
94
+
95
+ ```json
96
+ {
97
+ "agent": "opencode",
98
+ "task": "add input validation to src/handlers/user.ts",
99
+ "declaredFiles": ["src/handlers/user.ts", "test/handlers/user.test.ts"]
100
+ }
101
+ ```
102
+
103
+ 2. **PatchWarden 校验范围**:
104
+
105
+ - `src/handlers/user.ts` 与 `test/handlers/user.test.ts` 在 `allowedPaths` 内。
106
+ - `opencode` 命令在 `allowedCommands` 内。
107
+ - 无 `blockedFiles` 命中。
108
+
109
+ 3. **PatchWarden 启动 OpenCode worker**:
110
+
111
+ - OpenCode 在 `workspaceRoot` 下执行。
112
+ - OpenCode 的文件改动受 PatchWarden 监督。
113
+ - 若 OpenCode 尝试修改未声明文件,PatchWarden 触发范围违规检测并阻断。
114
+
115
+ 4. **任务完成后导出证据**:
116
+
117
+ ```powershell
118
+ # 产物位于 .patchwarden/evidence-packs/<lineage_id>/
119
+ # 包含 evidence.json / EVIDENCE.md / risk.json / verify.json 等 8 个文件
120
+ ```
121
+
122
+ ## 安全边界
123
+
124
+ PatchWarden 对 OpenCode worker 的约束包括:
125
+
126
+ | 维度 | 约束 |
127
+ | --- | --- |
128
+ | 文件读写 | 必须在 `allowedPaths` 内,命中 `blockedFiles` 即阻断 |
129
+ | 命令执行 | 必须在 `allowedCommands` 中(精确匹配) |
130
+ | 工作区 | OpenCode 进程的 cwd 限定在 `workspaceRoot` 下 |
131
+ | 越界改动 | `enforceDeclaredFiles` 为 true 时,未声明文件改动被阻断 |
132
+ | 敏感资源 | `.env`、SSH key、cookie、token 等一律不可访问 |
133
+ | 进程监督 | OpenCode 进程由 PatchWarden launcher 拥有,可被监督与终止 |
134
+
135
+ ## 注意事项
136
+
137
+ - OpenCode 必须以非交互模式运行(如 `--no-interactive`),避免阻塞 PatchWarden。
138
+ - OpenCode 的模型后端配置(API key 等)属于 OpenCode 自身配置,
139
+ PatchWarden 不读取也不持久化这些凭据。
140
+ - 若 OpenCode 任务需要执行 `allowedCommands` 之外的命令,
141
+ 应先更新 `project-policy.json` 再执行,不应临时放宽约束。
142
+ - OpenCode worker 的 stdout / stderr 由 PatchWarden 收集为有界摘要,
143
+ 完整日志不直接暴露给 MCP 客户端。
144
+ - 本集成模式不修改 OpenCode 的任何行为,仅在调度与监督层面配合。
145
+
146
+ ## 相关文档
147
+
148
+ - `docs/threat-model.md`:PatchWarden 安全契约与进程监督边界。
149
+ - `docs/evidence-pack-schema.md`:Evidence Pack v2 文件结构。
150
+ - `docs/why-patchwarden.md`:external supervisor pattern 的定位。
151
+ - `docs/openhands-worker.md`:类似的 worker 集成模式(OpenHands)。
@@ -0,0 +1,181 @@
1
+ # OpenHands worker 集成模式
2
+
3
+ > 本文基于 v1.5.1 源码编写;安装时请使用已验证发布的 <published-version>。
4
+ > 说明:本文描述的是 PatchWarden 将 OpenHands 作为 worker agent 的集成模式建议。
5
+ > OpenHands 是独立的 AI 软件开发 Agent 项目,本文不声称任何官方集成关系。
6
+
7
+ ## OpenHands 是什么
8
+
9
+ OpenHands 是面向软件开发的 AI Agent,主要能力包括:
10
+
11
+ - 在本地或容器化环境中编写、修改、调试代码。
12
+ - 执行测试、运行构建、操作文件系统。
13
+ - 接收自然语言任务并自主规划实现步骤。
14
+ - 支持多种模型后端与运行时环境。
15
+
16
+ OpenHands 默认以较自主的方式运行,本身不具备 PatchWarden 的安全边界。
17
+ 本文描述如何让 PatchWarden 作为外部监督层,OpenHands 作为受约束的 worker。
18
+
19
+ ## External Supervisor Pattern
20
+
21
+ PatchWarden 与 OpenHands 的集成采用 **external supervisor pattern**:
22
+
23
+ ```
24
+ MCP 客户端 → PatchWarden(supervisor)→ OpenHands(worker)→ workspace
25
+ ↑ 安全边界在此
26
+ ```
27
+
28
+ - **PatchWarden 作为 supervisor**:接收 MCP 客户端的任务请求,
29
+ 负责工作区隔离、命令允许列表、范围违规检测、证据收集。
30
+ - **OpenHands 作为 worker**:在 PatchWarden 允许的范围内执行软件开发任务。
31
+ - **安全边界在 PatchWarden 侧**:OpenHands 的所有文件改动与命令执行
32
+ 必须经过 PatchWarden 的策略校验。
33
+
34
+ 关键点:OpenHands 不直接暴露给 MCP 客户端,而是由 PatchWarden 调度。
35
+ 这避免了 OpenHands 在无监督下执行越权操作或访问敏感资源。
36
+
37
+ ## 配置示例
38
+
39
+ ### 1. 在 PatchWarden 中注册 OpenHands agent
40
+
41
+ 在 `.patchwarden/config.json` 中注册 OpenHands:
42
+
43
+ ```json
44
+ {
45
+ "workspaceRoot": "D:\\repos\\my-project",
46
+ "agents": [
47
+ {
48
+ "name": "openhands",
49
+ "type": "local-worker",
50
+ "command": "openhands",
51
+ "args": ["--headless", "--task"],
52
+ "workspace": "D:\\repos\\my-project"
53
+ }
54
+ ],
55
+ "evidencePackVersion": 2,
56
+ "safeResult": { "maxBytes": 4096 }
57
+ }
58
+ ```
59
+
60
+ ### 2. 配置 project-policy.json 约束 OpenHands 的操作范围
61
+
62
+ ```json
63
+ {
64
+ "allowedPaths": ["src/**", "test/**", "docs/**"],
65
+ "allowedCommands": [
66
+ "npm.cmd test",
67
+ "npm.cmd run build",
68
+ "git status",
69
+ "git diff",
70
+ "openhands --headless"
71
+ ],
72
+ "blockedFiles": [".env", ".env.*", "id_rsa", "*.key", "*.pem", "cookies.db"],
73
+ "scopeRules": {
74
+ "enforceDeclaredFiles": true,
75
+ "blockOutOfWorkspace": true
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### 3. OpenHands 在 workspace 内执行
81
+
82
+ OpenHands 进程由 PatchWarden 启动并监督:
83
+
84
+ ```powershell
85
+ # PatchWarden 通过 MCP 工具 run_safe_task 调度 OpenHands
86
+ # MCP 客户端传入任务描述与声明的文件范围
87
+ # PatchWarden 在执行前校验范围,执行中监督,执行后收集证据
88
+ ```
89
+
90
+ ## 工作流示例
91
+
92
+ ### 任务:让 OpenHands 修复一个 bug
93
+
94
+ 1. **MCP 客户端发起任务**:
95
+
96
+ ```json
97
+ {
98
+ "agent": "openhands",
99
+ "task": "fix null pointer in src/services/auth.ts when token is missing",
100
+ "declaredFiles": ["src/services/auth.ts", "test/services/auth.test.ts"]
101
+ }
102
+ ```
103
+
104
+ 2. **PatchWarden 校验范围**:
105
+
106
+ - `src/services/auth.ts` 与 `test/services/auth.test.ts` 在 `allowedPaths` 内。
107
+ - `openhands` 命令在 `allowedCommands` 内。
108
+ - 无 `blockedFiles` 命中。
109
+
110
+ 3. **PatchWarden 启动 OpenHands worker**:
111
+
112
+ - OpenHands 在 `workspaceRoot` 下以 headless 模式执行。
113
+ - OpenHands 的文件改动受 PatchWarden 监督。
114
+ - 若 OpenHands 尝试修改未声明文件,PatchWarden 触发范围违规检测并阻断。
115
+ - 若 OpenHands 尝试读取 `.env` 或凭据文件,PatchWarden 立即阻断。
116
+
117
+ 4. **任务完成后导出证据**:
118
+
119
+ ```powershell
120
+ # 产物位于 .patchwarden/evidence-packs/<lineage_id>/
121
+ # 包含 evidence.json / EVIDENCE.md / risk.json / verify.json 等 8 个文件
122
+ ```
123
+
124
+ ## 安全边界
125
+
126
+ PatchWarden 对 OpenHands worker 的约束包括:
127
+
128
+ | 维度 | 约束 |
129
+ | --- | --- |
130
+ | 文件读写 | 必须在 `allowedPaths` 内,命中 `blockedFiles` 即阻断 |
131
+ | 命令执行 | 必须在 `allowedCommands` 中(精确匹配) |
132
+ | 工作区 | OpenHands 进程的 cwd 限定在 `workspaceRoot` 下 |
133
+ | 越界改动 | `enforceDeclaredFiles` 为 true 时,未声明文件改动被阻断 |
134
+ | 敏感资源 | `.env`、SSH key、cookie、token 等一律不可访问 |
135
+ | 进程监督 | OpenHands 进程由 PatchWarden launcher 拥有,可被监督与终止 |
136
+ | 网络访问 | 取决于 OpenHands 运行时配置,PatchWarden 不放宽命令允许列表 |
137
+
138
+ ## 容器化运行注意事项
139
+
140
+ 若 OpenHands 运行在容器中,需额外注意:
141
+
142
+ - PatchWarden 监督的是宿主机上的 OpenHands 进程,
143
+ 容器内的文件系统改动应通过挂载卷映射回 `workspaceRoot`。
144
+ - `project-policy.json` 的 `allowedPaths` 应对应宿主机路径,
145
+ 而非容器内路径。
146
+ - 容器内的命令执行若需被 PatchWarden 监督,
147
+ 应通过 OpenHands 的 headless 接口走 PatchWarden 调度,
148
+ 而非绕过 PatchWarden 直接在容器内执行。
149
+
150
+ ## 注意事项
151
+
152
+ - OpenHands 必须以 headless / 非交互模式运行,避免阻塞 PatchWarden。
153
+ - OpenHands 的模型后端配置(API key 等)属于 OpenHands 自身配置,
154
+ PatchWarden 不读取也不持久化这些凭据。
155
+ - 若 OpenHands 任务需要执行 `allowedCommands` 之外的命令,
156
+ 应先更新 `project-policy.json` 再执行,不应临时放宽约束。
157
+ - OpenHands worker 的 stdout / stderr 由 PatchWarden 收集为有界摘要,
158
+ 完整日志不直接暴露给 MCP 客户端。
159
+ - 本集成模式不修改 OpenHands 的任何行为,仅在调度与监督层面配合。
160
+
161
+ ## 与 OpenCode worker 的差异
162
+
163
+ OpenHands 与 OpenCode 的集成模式在结构上一致(均采用 external supervisor pattern),
164
+ 主要差异在于:
165
+
166
+ | 维度 | OpenCode | OpenHands |
167
+ | --- | --- | --- |
168
+ | 定位 | 本地编程 Agent | AI 软件开发 Agent |
169
+ | 运行模式 | 通常直接在宿主机 | 支持 headless 与容器化 |
170
+ | 自主性 | 中等,偏交互式 | 较高,偏自主规划 |
171
+ | 适用任务 | 中小规模代码改动 | 较复杂的软件开发任务 |
172
+
173
+ 选择哪个 worker 取决于任务复杂度与运行时偏好,
174
+ PatchWarden 的安全边界对两者一视同仁。
175
+
176
+ ## 相关文档
177
+
178
+ - `docs/threat-model.md`:PatchWarden 安全契约与进程监督边界。
179
+ - `docs/evidence-pack-schema.md`:Evidence Pack v2 文件结构。
180
+ - `docs/why-patchwarden.md`:external supervisor pattern 的定位。
181
+ - `docs/opencode-worker.md`:类似的 worker 集成模式(OpenCode)。
@@ -0,0 +1,72 @@
1
+ # PatchWarden Release Evidence
2
+
3
+ This file separates local source state from public release truth. Update it
4
+ before submitting external applications or publishing a release.
5
+
6
+ ## Current Snapshot
7
+
8
+ Checked on 2026-07-12 from the PatchWarden workspace.
9
+
10
+ | Surface | Current evidence |
11
+ | --- | --- |
12
+ | Local branch | `codex/evidence-pack-v2` |
13
+ | Local `package.json` | `patchwarden@1.5.1` |
14
+ | GitHub latest release | `v1.5.0` |
15
+ | GitHub release URL | https://github.com/jiezeng2004-design/PatchWarden/releases/tag/v1.5.0 |
16
+ | GitHub release published at | 2026-07-07T11:36:48Z |
17
+ | npm latest | `patchwarden@1.5.0` |
18
+ | npm `dist-tags.latest` | `1.5.0` |
19
+ | GitHub stars | 2 |
20
+ | GitHub forks | 0 |
21
+ | Open issues | 9 (`#25`, `#26`, `#28`–`#34`) |
22
+ | Open pull requests | 2 (`#24`, `#37`, both draft) |
23
+
24
+ Conclusion: `1.5.0` is the latest verified public release. The local `1.5.1`
25
+ source state is ahead of the public release and should be treated as pending
26
+ until PR, CI, GitHub Release, npm, and `dist-tags.latest` are all verified.
27
+
28
+ ## Commands Used
29
+
30
+ Windows PowerShell:
31
+
32
+ ```powershell
33
+ gh repo view jiezeng2004-design/PatchWarden --json nameWithOwner,stargazerCount,forkCount,issues,pullRequests,defaultBranchRef,pushedAt,url,description,licenseInfo,repositoryTopics,latestRelease,hasDiscussionsEnabled,hasIssuesEnabled,securityPolicyUrl
34
+ gh release view v1.5.1 --repo jiezeng2004-design/PatchWarden --json tagName,name,publishedAt,isDraft,isPrerelease,url
35
+ gh release view --repo jiezeng2004-design/PatchWarden --json tagName,name,publishedAt,isDraft,isPrerelease,url
36
+ npm.cmd view patchwarden version dist-tags --json --cache .\.npm-cache
37
+ ```
38
+
39
+ The npm query succeeded on 2026-07-12 with the repository-local `.npm-cache`:
40
+ `version=1.5.0`, `dist-tags.latest=1.5.0`.
41
+
42
+ ## Local Verification Snapshot
43
+
44
+ - `npm.cmd run build`: passed.
45
+ - `npm.cmd run test:unit`: 716 tests, 714 passed, 2 skipped, 0 failed.
46
+ - `npm.cmd run doctor:ci`: 83 OK, 0 warnings, 0 failures.
47
+ - `npm.cmd run verify:package`: passed; 584 package files, no private local launchers.
48
+ - `npm.cmd test`: passed in 284.5 seconds in an approved Windows child-process
49
+ environment. This includes 139 security smoke checks, 716 unit tests (714
50
+ passed, 2 skipped), 22 lifecycle checks, doctor, tunnel/watcher supervisors,
51
+ Windows control, MCP manifest, brand, and 32 Control Center checks.
52
+ - `npm.cmd run test:mcp`: passed.
53
+ - `npm.cmd run test:http-mcp`: 13 passed, 0 failed, including owner-token checks.
54
+ - `npm.cmd run pack:clean` was not run here because it removes and recreates
55
+ release artifacts; run it only in an explicitly approved release-preparation
56
+ workspace.
57
+
58
+ ## Release Verification Checklist
59
+
60
+ - [ ] Confirm the target version in `package.json`.
61
+ - [ ] Confirm `src/version.ts`, package metadata, README version text, and
62
+ changelog agree.
63
+ - [ ] Run the complete local gate chain from `AGENTS.md`.
64
+ - [ ] Open a PR and wait for the GitHub CI gate.
65
+ - [ ] Merge only after review.
66
+ - [ ] Create the tag from the verified merge commit.
67
+ - [ ] Create the GitHub Release with reviewed artifacts and checksums.
68
+ - [ ] Publish `patchwarden` to npm using process-scoped authentication.
69
+ - [ ] Verify the remote tag, GitHub Release, npm package version, and
70
+ `dist-tags.latest`.
71
+
72
+ Do not publish new versions under the frozen pre-rename package name.