@chenmk/superflow 0.5.6 → 0.5.8

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 (56) hide show
  1. package/README.md +12 -0
  2. package/README.zh-CN.md +10 -0
  3. package/assets/scripts/superflow-managed-command-guard.py +52 -17
  4. package/assets/scripts/superflow-managed-work-check.mjs +286 -126
  5. package/assets/skills/superflow-pipeline/references/managed-work.md +5 -0
  6. package/assets/skills-en/superflow-pipeline/references/managed-work.md +7 -0
  7. package/dist/app/cli.js +12 -0
  8. package/dist/app/cli.js.map +1 -1
  9. package/dist/app/commands/cleanup.js +17 -0
  10. package/dist/app/commands/cleanup.js.map +1 -0
  11. package/dist/app/commands/pipeline.js +16 -5
  12. package/dist/app/commands/pipeline.js.map +1 -1
  13. package/dist/app/commands/status.js +7 -1
  14. package/dist/app/commands/status.js.map +1 -1
  15. package/dist/domains/config/cli-help.js +8 -0
  16. package/dist/domains/config/cli-help.js.map +1 -1
  17. package/dist/domains/managed-work/acceptance-contract.js +139 -0
  18. package/dist/domains/managed-work/acceptance-contract.js.map +1 -0
  19. package/dist/domains/managed-work/cleanup.js +247 -0
  20. package/dist/domains/managed-work/cleanup.js.map +1 -0
  21. package/dist/domains/managed-work/context-manifest.js +26 -0
  22. package/dist/domains/managed-work/context-manifest.js.map +1 -1
  23. package/dist/domains/managed-work/contract.js +40 -4
  24. package/dist/domains/managed-work/contract.js.map +1 -1
  25. package/dist/domains/managed-work/control.js +82 -5
  26. package/dist/domains/managed-work/control.js.map +1 -1
  27. package/dist/domains/managed-work/execution-contract.js +33 -4
  28. package/dist/domains/managed-work/execution-contract.js.map +1 -1
  29. package/dist/domains/managed-work/executor-policy.js +1 -0
  30. package/dist/domains/managed-work/executor-policy.js.map +1 -1
  31. package/dist/domains/managed-work/host-review.js +4 -0
  32. package/dist/domains/managed-work/host-review.js.map +1 -1
  33. package/dist/domains/managed-work/journal.js +3 -2
  34. package/dist/domains/managed-work/journal.js.map +1 -1
  35. package/dist/domains/managed-work/prompts.js +52 -0
  36. package/dist/domains/managed-work/prompts.js.map +1 -1
  37. package/dist/domains/managed-work/review-facts.js +85 -1
  38. package/dist/domains/managed-work/review-facts.js.map +1 -1
  39. package/dist/domains/managed-work/runner.js +17 -7
  40. package/dist/domains/managed-work/runner.js.map +1 -1
  41. package/dist/domains/managed-work/schemas.js +26 -1
  42. package/dist/domains/managed-work/schemas.js.map +1 -1
  43. package/dist/domains/managed-work/state.js +1 -0
  44. package/dist/domains/managed-work/state.js.map +1 -1
  45. package/dist/domains/managed-work/storage.js +68 -0
  46. package/dist/domains/managed-work/storage.js.map +1 -1
  47. package/dist/domains/managed-work/time-format.js +69 -0
  48. package/dist/domains/managed-work/time-format.js.map +1 -0
  49. package/dist/domains/managed-work/types.js.map +1 -1
  50. package/dist/mcp/server.js +42 -1
  51. package/dist/mcp/server.js.map +1 -1
  52. package/dist/platform/agent-process.js +21 -0
  53. package/dist/platform/agent-process.js.map +1 -1
  54. package/dist/platform/codex-config.js +91 -0
  55. package/dist/platform/codex-config.js.map +1 -0
  56. package/package.json +1 -1
package/README.md CHANGED
@@ -195,6 +195,17 @@ superflow pipeline "<prompt path, change directory, or task>" --managed \
195
195
  --project "<project root>" --supervisor current --executor peer
196
196
  ```
197
197
 
198
+ For a prompt path or SDD change, also pass a Host-authored frozen acceptance
199
+ contract. Its JSON declares business invariants, existing repository-relative
200
+ source coverage, deliverables, verification, and exclusions; start fails closed
201
+ without it.
202
+
203
+ ```bash
204
+ superflow pipeline "<prompt path or change directory>" --managed \
205
+ --project "<project root>" --acceptance-contract ./acceptance-contract.json \
206
+ --supervisor current --executor peer
207
+ ```
208
+
198
209
  The selected language is frozen into the task contract and reused by Agent
199
210
  prompts, reviews, journals, reports, notifications, and resumed rounds.
200
211
  The first executor invocation runs continuously without a Superflow tool-turn
@@ -315,6 +326,7 @@ best-effort and does not block initialization.
315
326
  | `superflow scan --language en` | Regenerate project context templates in English |
316
327
  | `superflow pipeline` | Check pipeline skill deployment |
317
328
  | `superflow pipeline "<task>" --managed --project <path>` | Run short-session execution with direct review by the current host agent |
329
+ | `--acceptance-contract <file>` | Required frozen acceptance JSON for prompt/SDD starts |
318
330
  | `superflow docs [change]` | Run the docs gate and check the phase skill |
319
331
  | `superflow design` | Check design-phase skill deployment |
320
332
  | `superflow implement [change]` | Create a current Coding Ready receipt before implementation |
package/README.zh-CN.md CHANGED
@@ -158,6 +158,15 @@ superflow pipeline "<prompt 路径、change 目录或任务>" --managed \
158
158
  --project "<项目根目录>" --supervisor current --executor peer
159
159
  ```
160
160
 
161
+ Prompt 路径或 SDD change 启动还必须传入由 Host 编写的冻结验收合同:JSON 内声明业务不变量、
162
+ 启动时已存在的仓库内源码覆盖路径、交付物、验证和排除范围;缺失即失败关闭。
163
+
164
+ ```bash
165
+ superflow pipeline "<prompt 路径或 change 目录>" --managed \
166
+ --project "<项目根目录>" --acceptance-contract ./acceptance-contract.json \
167
+ --supervisor current --executor peer
168
+ ```
169
+
161
170
  语言会冻结进任务合同;执行 Prompt、评审、账本、报告、通知和恢复轮次保持一致。
162
171
  执行 Agent 每轮使用全新短会话;当前 Host Agent 直接评审,不再由后台启动第二个同名
163
172
  CLI。首轮自动使用冻结任务 Prompt,后续每轮生成压缩交接包,因此旧会话或新会话均能从
@@ -258,6 +267,7 @@ MCP 是主 Agent 与本地托管状态机的通信通道,不会把 Superflow
258
267
  | `superflow implement [change]` | 生成当前 Coding Ready 凭证后进入实现阶段 |
259
268
  | `superflow pipeline` | 校验 SuperBridge Flow pipeline 阶段技能部署 |
260
269
  | `superflow pipeline "<任务>" --managed --project <目录>` | 执行 Agent 短会话开发,当前 Host Agent 直接评审 |
270
+ | `--acceptance-contract <文件>` | Prompt/SDD 启动必填的冻结验收合同 JSON |
261
271
  | `superflow check <change> --level files\|docs\|coding-ready` | 分级检查文件、文档交付或可直接编码就绪度 |
262
272
  | `superflow config <change> --review-mode <mode>` | 设置代码审查强度(off/standard/thorough) |
263
273
  | `superflow config <change> --auto-transition <bool>` | 控制阶段自动流转(true/false) |
@@ -171,6 +171,28 @@ def guard_supervisor(tool_name: str, command: str) -> None:
171
171
  )
172
172
 
173
173
 
174
+ PATCH_TARGET_PATTERN = re.compile(
175
+ r"\*{3}\s*(Update|Add|Delete)\s+File:\s*([^\r\n]+)"
176
+ )
177
+
178
+
179
+ def patch_target_paths(command: str) -> list[tuple[str, str]]:
180
+ """Extracts (action, path) targets from patch markup inside a command.
181
+
182
+ Codex 0.154 routes ``tools.apply_patch(patch)`` through the hook as an
183
+ ``apply_patch`` tool call whose input only carries the patch text, so the
184
+ declared file_path is empty. The patch markup itself names every target
185
+ path, which lets the guard validate real targets instead of failing closed.
186
+ """
187
+ targets: list[tuple[str, str]] = []
188
+ for match in PATCH_TARGET_PATTERN.finditer(command or ""):
189
+ action = match.group(1).lower()
190
+ value = match.group(2).strip().strip("\"'")
191
+ if value:
192
+ targets.append((action, value))
193
+ return targets
194
+
195
+
174
196
  def guard_executor(
175
197
  tool_name: str,
176
198
  file_path: str,
@@ -181,22 +203,35 @@ def guard_executor(
181
203
  ) -> None:
182
204
  write_tools = {"Edit", "Write", "MultiEdit", "NotebookEdit", "apply_patch"}
183
205
  if tool_name in write_tools:
184
- if not file_path:
185
- block(
186
- "写入工具缺少目标路径,按失败关闭。",
187
- "The write tool has no target path; failing closed.",
188
- )
189
- target = canonical(file_path, root)
190
- if ".superflow/tasks" in target.as_posix():
191
- block(
192
- "执行角色禁止修改托管状态、事件、Prompt 和过程报告。",
193
- "The executor cannot edit managed state, events, prompts, or run reports.",
194
- )
195
- if target in immutable:
196
- block(
197
- f"冻结输入只读,禁止修改:{target}",
198
- f"Frozen input is read-only: {target}",
199
- )
206
+ if file_path:
207
+ targets: list[tuple[Path, str]] = [(canonical(file_path, root), "update")]
208
+ else:
209
+ patch_targets = patch_target_paths(command)
210
+ if not patch_targets:
211
+ block(
212
+ "写入工具缺少目标路径,按失败关闭。",
213
+ "The write tool has no target path; failing closed.",
214
+ )
215
+ targets = [
216
+ (canonical(value, root), action)
217
+ for action, value in patch_targets
218
+ ]
219
+ for target, action in targets:
220
+ if ".superflow/tasks" in target.as_posix():
221
+ block(
222
+ "执行角色禁止修改托管状态、事件、Prompt 和过程报告。",
223
+ "The executor cannot edit managed state, events, prompts, or run reports.",
224
+ )
225
+ if target in immutable:
226
+ block(
227
+ f"冻结输入只读,禁止修改:{target}",
228
+ f"Frozen input is read-only: {target}",
229
+ )
230
+ if action == "delete" and target in retained:
231
+ block(
232
+ "命令试图删除受保护的交付文档。",
233
+ "The command would delete a retained delivery document.",
234
+ )
200
235
 
201
236
  if command and ".superflow/tasks/" in command.replace("\\", "/"):
202
237
  block(
@@ -286,7 +321,7 @@ def main() -> None:
286
321
 
287
322
  tool_name = str(payload.get("tool_name") or payload.get("tool") or "")
288
323
  file_path = tool_field(payload, "file_path", "path", "file")
289
- command = tool_field(payload, "command", "cmd").replace("\n", " ")
324
+ command = tool_field(payload, "command", "cmd")
290
325
  root = Path(
291
326
  os.environ.get("SUPERFLOW_MANAGED_PROJECT_ROOT", os.getcwd())
292
327
  ).resolve(strict=False)