@chenmk/superflow 0.4.0 → 0.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.
- package/INSTALL.en.md +58 -12
- package/INSTALL.md +62 -33
- package/README.md +181 -54
- package/README.zh-CN.md +158 -51
- package/assets/brand/managed-review-loop.png +0 -0
- package/assets/manifest.json +10 -5
- package/assets/scripts/superflow-coding-ready.mjs +135 -0
- package/assets/scripts/superflow-dependency-update-hook.sh +81 -8
- package/assets/scripts/superflow-document-audit.mjs +240 -0
- package/assets/scripts/superflow-environment-preflight.mjs +398 -0
- package/assets/scripts/superflow-hook-guard.sh +40 -1
- package/assets/scripts/superflow-managed-command-guard.py +309 -0
- package/assets/scripts/superflow-managed-executor-preflight.mjs +421 -0
- package/assets/scripts/superflow-managed-owner-verification.sh +117 -0
- package/assets/scripts/superflow-managed-work-check.mjs +287 -26
- package/assets/scripts/superflow-managed-work-guard.sh +6 -92
- package/assets/skills/superflow-clarify/SKILL.md +14 -0
- package/assets/skills/superflow-design/SKILL.md +38 -13
- package/assets/skills/superflow-docs/SKILL.md +93 -2
- package/assets/skills/superflow-pipeline/SKILL.md +167 -10
- package/assets/skills/superflow-pipeline/references/batch-prompt-template.md +17 -9
- package/assets/skills/superflow-pipeline/references/document-readiness.md +157 -0
- package/assets/skills/superflow-pipeline/references/document-templates.md +9 -5
- package/assets/skills/superflow-pipeline/references/feature-gated-workflow.md +14 -0
- package/assets/skills/superflow-pipeline/references/implementation-prompt-template.md +20 -11
- package/assets/skills/superflow-pipeline/references/managed-work.md +123 -15
- package/assets/skills/superflow-pipeline/references/orchestration.md +2 -2
- package/assets/skills/superflow-pipeline/references/p0-baseline-template.md +3 -2
- package/assets/skills/superflow-pipeline/references/quality-gate.md +7 -5
- package/assets/skills/superflow-pipeline/references/reviewer-checklist.md +7 -0
- package/assets/skills/superflow-pipeline/scripts/superflow-guard.sh +205 -9
- package/assets/skills/superflow-pipeline/scripts/superflow-handoff.sh +7 -4
- package/assets/skills/superflow-requirement-review/SKILL.md +178 -0
- package/assets/skills/superflow-requirement-review/agents/openai.yaml +4 -0
- package/assets/skills-en/superflow-clarify/SKILL.md +17 -0
- package/assets/skills-en/superflow-design/SKILL.md +31 -12
- package/assets/skills-en/superflow-docs/SKILL.md +99 -0
- package/assets/skills-en/superflow-pipeline/SKILL.md +163 -9
- package/assets/skills-en/superflow-pipeline/references/batch-prompt-template.md +4 -0
- package/assets/skills-en/superflow-pipeline/references/document-readiness.md +125 -0
- package/assets/skills-en/superflow-pipeline/references/document-templates.md +10 -0
- package/assets/skills-en/superflow-pipeline/references/feature-gated-workflow.md +7 -0
- package/assets/skills-en/superflow-pipeline/references/implementation-prompt-template.md +7 -0
- package/assets/skills-en/superflow-pipeline/references/managed-work.md +160 -10
- package/assets/skills-en/superflow-pipeline/references/quality-gate.md +12 -0
- package/assets/skills-en/superflow-pipeline/references/reviewer-checklist.md +7 -0
- package/assets/skills-en/superflow-pipeline/scripts/superflow-guard.sh +205 -9
- package/assets/skills-en/superflow-pipeline/scripts/superflow-handoff.sh +7 -4
- package/assets/skills-en/superflow-requirement-review/SKILL.md +99 -0
- package/assets/skills-en/superflow-requirement-review/agents/openai.yaml +4 -0
- package/dist/app/cli.js +64 -9
- package/dist/app/cli.js.map +1 -1
- package/dist/app/commands/change-guard.js +19 -2
- package/dist/app/commands/change-guard.js.map +1 -1
- package/dist/app/commands/check.js +107 -45
- package/dist/app/commands/check.js.map +1 -1
- package/dist/app/commands/docs.js +7 -3
- package/dist/app/commands/docs.js.map +1 -1
- package/dist/app/commands/doctor.js +174 -198
- package/dist/app/commands/doctor.js.map +1 -1
- package/dist/app/commands/eval.js +64 -0
- package/dist/app/commands/eval.js.map +1 -0
- package/dist/app/commands/implement.js +7 -3
- package/dist/app/commands/implement.js.map +1 -1
- package/dist/app/commands/init.js +12 -24
- package/dist/app/commands/init.js.map +1 -1
- package/dist/app/commands/mcp.js +167 -0
- package/dist/app/commands/mcp.js.map +1 -0
- package/dist/app/commands/pipeline.js +652 -18
- package/dist/app/commands/pipeline.js.map +1 -1
- package/dist/app/commands/requirement-review.js +6 -0
- package/dist/app/commands/requirement-review.js.map +1 -0
- package/dist/app/commands/status.js +66 -3
- package/dist/app/commands/status.js.map +1 -1
- package/dist/app/commands/uninstall.js +3 -3
- package/dist/app/commands/uninstall.js.map +1 -1
- package/dist/app/commands/update.js +83 -9
- package/dist/app/commands/update.js.map +1 -1
- package/dist/domains/agent.js +3 -11
- package/dist/domains/agent.js.map +1 -1
- package/dist/domains/config/cli-help.js +54 -12
- package/dist/domains/config/cli-help.js.map +1 -1
- package/dist/domains/config/i18n.js +6 -8
- package/dist/domains/config/i18n.js.map +1 -1
- package/dist/domains/config/manifest.js +0 -3
- package/dist/domains/config/manifest.js.map +1 -1
- package/dist/domains/deps.js +68 -7
- package/dist/domains/deps.js.map +1 -1
- package/dist/domains/managed-work/completion-policy.js +174 -0
- package/dist/domains/managed-work/completion-policy.js.map +1 -0
- package/dist/domains/managed-work/context-manifest.js +208 -0
- package/dist/domains/managed-work/context-manifest.js.map +1 -0
- package/dist/domains/managed-work/contract.js +135 -4
- package/dist/domains/managed-work/contract.js.map +1 -1
- package/dist/domains/managed-work/control-signals.js +34 -0
- package/dist/domains/managed-work/control-signals.js.map +1 -0
- package/dist/domains/managed-work/control.js +628 -0
- package/dist/domains/managed-work/control.js.map +1 -0
- package/dist/domains/managed-work/evaluation.js +497 -0
- package/dist/domains/managed-work/evaluation.js.map +1 -0
- package/dist/domains/managed-work/evidence-path.js +14 -0
- package/dist/domains/managed-work/evidence-path.js.map +1 -0
- package/dist/domains/managed-work/execution-contract.js +167 -0
- package/dist/domains/managed-work/execution-contract.js.map +1 -0
- package/dist/domains/managed-work/executor-policy.js +65 -0
- package/dist/domains/managed-work/executor-policy.js.map +1 -0
- package/dist/domains/managed-work/failure.js +65 -0
- package/dist/domains/managed-work/failure.js.map +1 -0
- package/dist/domains/managed-work/host-review.js +77 -0
- package/dist/domains/managed-work/host-review.js.map +1 -0
- package/dist/domains/managed-work/human-messages.js +31 -0
- package/dist/domains/managed-work/human-messages.js.map +1 -0
- package/dist/domains/managed-work/input.js +29 -3
- package/dist/domains/managed-work/input.js.map +1 -1
- package/dist/domains/managed-work/journal.js +77 -3
- package/dist/domains/managed-work/journal.js.map +1 -1
- package/dist/domains/managed-work/lock.js +67 -1
- package/dist/domains/managed-work/lock.js.map +1 -1
- package/dist/domains/managed-work/notifications.js +0 -15
- package/dist/domains/managed-work/notifications.js.map +1 -1
- package/dist/domains/managed-work/pair-admission.js +108 -0
- package/dist/domains/managed-work/pair-admission.js.map +1 -0
- package/dist/domains/managed-work/prompts.js +257 -22
- package/dist/domains/managed-work/prompts.js.map +1 -1
- package/dist/domains/managed-work/redaction.js +90 -0
- package/dist/domains/managed-work/redaction.js.map +1 -0
- package/dist/domains/managed-work/review-convergence.js +41 -0
- package/dist/domains/managed-work/review-convergence.js.map +1 -0
- package/dist/domains/managed-work/review-facts.js +181 -0
- package/dist/domains/managed-work/review-facts.js.map +1 -0
- package/dist/domains/managed-work/rule-selection.js +84 -0
- package/dist/domains/managed-work/rule-selection.js.map +1 -0
- package/dist/domains/managed-work/runner.js +1967 -175
- package/dist/domains/managed-work/runner.js.map +1 -1
- package/dist/domains/managed-work/schemas.js +72 -2
- package/dist/domains/managed-work/schemas.js.map +1 -1
- package/dist/domains/managed-work/service.js +82 -13
- package/dist/domains/managed-work/service.js.map +1 -1
- package/dist/domains/managed-work/state.js +195 -5
- package/dist/domains/managed-work/state.js.map +1 -1
- package/dist/domains/managed-work/storage.js +66 -24
- package/dist/domains/managed-work/storage.js.map +1 -1
- package/dist/domains/managed-work/types.js +12 -9
- package/dist/domains/managed-work/types.js.map +1 -1
- package/dist/domains/managed-work/verification-categories.js +39 -0
- package/dist/domains/managed-work/verification-categories.js.map +1 -0
- package/dist/domains/managed-work/verification-policy.js +116 -0
- package/dist/domains/managed-work/verification-policy.js.map +1 -0
- package/dist/domains/managed-work/wait.js +21 -3
- package/dist/domains/managed-work/wait.js.map +1 -1
- package/dist/domains/managed-work/workspace-binding.js +133 -0
- package/dist/domains/managed-work/workspace-binding.js.map +1 -0
- package/dist/domains/sdd-readiness.js +44 -0
- package/dist/domains/sdd-readiness.js.map +1 -0
- package/dist/domains/skill/deploy.js +0 -6
- package/dist/domains/skill/deploy.js.map +1 -1
- package/dist/domains/skill/scripts.js +0 -8
- package/dist/domains/skill/scripts.js.map +1 -1
- package/dist/domains/state.js +1 -2
- package/dist/domains/state.js.map +1 -1
- package/dist/mcp/runtime-identity.js +21 -0
- package/dist/mcp/runtime-identity.js.map +1 -0
- package/dist/mcp/server.js +369 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/platform/agent-process.js +499 -38
- package/dist/platform/agent-process.js.map +1 -1
- package/dist/platform/executable.js +28 -0
- package/dist/platform/executable.js.map +1 -0
- package/dist/platform/paths.js +1 -17
- package/dist/platform/paths.js.map +1 -1
- package/dist/platform/process-tree.js +44 -0
- package/dist/platform/process-tree.js.map +1 -0
- package/dist/platform/process.js +1 -1
- package/dist/platform/process.js.map +1 -1
- package/package.json +17 -7
- package/scripts/check-design-principles.mjs +107 -0
- package/scripts/check-managed-work-design.mjs +507 -0
- package/scripts/clean-dist.js +9 -0
- package/scripts/ensure-bin-modes.js +11 -0
- package/scripts/preinstall.js +57 -0
- package/dist/cli/index.js +0 -193
- package/dist/cli/index.js.map +0 -1
- package/dist/commands/archive.js +0 -6
- package/dist/commands/archive.js.map +0 -1
- package/dist/commands/clarify.js +0 -6
- package/dist/commands/clarify.js.map +0 -1
- package/dist/commands/design.js +0 -28
- package/dist/commands/design.js.map +0 -1
- package/dist/commands/docs.js +0 -6
- package/dist/commands/docs.js.map +0 -1
- package/dist/commands/doctor.js +0 -494
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/implement.js +0 -6
- package/dist/commands/implement.js.map +0 -1
- package/dist/commands/init.js +0 -520
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/pipeline.js +0 -6
- package/dist/commands/pipeline.js.map +0 -1
- package/dist/commands/scan.js +0 -63
- package/dist/commands/scan.js.map +0 -1
- package/dist/commands/status.js +0 -173
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/uninstall.js +0 -214
- package/dist/commands/uninstall.js.map +0 -1
- package/dist/commands/update.js +0 -193
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/verify.js +0 -6
- package/dist/commands/verify.js.map +0 -1
- package/dist/core/assets.js +0 -27
- package/dist/core/assets.js.map +0 -1
- package/dist/core/cli-help.js +0 -98
- package/dist/core/cli-help.js.map +0 -1
- package/dist/core/context.js +0 -123
- package/dist/core/context.js.map +0 -1
- package/dist/core/dependencies.js +0 -146
- package/dist/core/dependencies.js.map +0 -1
- package/dist/core/detect.js +0 -64
- package/dist/core/detect.js.map +0 -1
- package/dist/core/i18n.js +0 -105
- package/dist/core/i18n.js.map +0 -1
- package/dist/core/integrity.js +0 -46
- package/dist/core/integrity.js.map +0 -1
- package/dist/core/manifest.js +0 -21
- package/dist/core/manifest.js.map +0 -1
- package/dist/core/prompts.js +0 -20
- package/dist/core/prompts.js.map +0 -1
- package/dist/core/registry.js +0 -134
- package/dist/core/registry.js.map +0 -1
- package/dist/core/rules.js +0 -17
- package/dist/core/rules.js.map +0 -1
- package/dist/core/scripts.js +0 -48
- package/dist/core/scripts.js.map +0 -1
- package/dist/core/skill-check.js +0 -32
- package/dist/core/skill-check.js.map +0 -1
- package/dist/core/skills.js +0 -62
- package/dist/core/skills.js.map +0 -1
- package/dist/core/state.js +0 -54
- package/dist/core/state.js.map +0 -1
- package/dist/utils/path.js +0 -11
- package/dist/utils/path.js.map +0 -1
- package/dist/utils/shell.js +0 -29
- package/dist/utils/shell.js.map +0 -1
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
|
|
7
|
+
const root = process.cwd();
|
|
8
|
+
|
|
9
|
+
const requirements = new Map([
|
|
10
|
+
[
|
|
11
|
+
"AGENTS.md",
|
|
12
|
+
["docs/managed-work-design-principles.md", "修改托管功能的强制回归清单"],
|
|
13
|
+
],
|
|
14
|
+
[
|
|
15
|
+
"docs/managed-work-design-principles.md",
|
|
16
|
+
[
|
|
17
|
+
"脚本与 Agent 裁决矩阵",
|
|
18
|
+
"superflow.handoff.v2",
|
|
19
|
+
"superflow.executor.v2",
|
|
20
|
+
"superflow.review.v2",
|
|
21
|
+
"修改托管功能的强制回归清单",
|
|
22
|
+
"不得启动完整 Executor 修 JSON",
|
|
23
|
+
"不得无条件重置为源码检索",
|
|
24
|
+
"合同哈希的不可变字段投影必须只有一个事实源",
|
|
25
|
+
"单命令、可重复、失败安全、可移植",
|
|
26
|
+
"强制规则不得只依赖 Prompt 上下文",
|
|
27
|
+
"Hook、preflight 或最终门禁",
|
|
28
|
+
"预期失败和失败注入必须由父级验收命令",
|
|
29
|
+
"禁止为删除或改写 JSON 启动完整 Executor",
|
|
30
|
+
"控制面原子性与注册表容错",
|
|
31
|
+
"启动失败、响应丢失和安全重试",
|
|
32
|
+
"单个陈旧 registry locator",
|
|
33
|
+
"CLI `pipeline --managed` 与 MCP 使用同一原子语义",
|
|
34
|
+
"MCP 进程必须暴露启动时运行时指纹",
|
|
35
|
+
"详细构建和运行日志写入任务证据文件",
|
|
36
|
+
"Host usage",
|
|
37
|
+
"executor.stage_rework",
|
|
38
|
+
"owner 确定事实模板",
|
|
39
|
+
"正常 cleanup 删除 nonce/运行目录后仍须可读",
|
|
40
|
+
"系统休眠不消耗执行预算",
|
|
41
|
+
"正常 cleanup 删除 nonce/运行目录后仍须可读",
|
|
42
|
+
"默认覆盖",
|
|
43
|
+
"三级验证模型",
|
|
44
|
+
"受影响验证",
|
|
45
|
+
"任务级真实验收",
|
|
46
|
+
"框架认证",
|
|
47
|
+
"不得为每个业务任务重复",
|
|
48
|
+
"历史有效证据",
|
|
49
|
+
"正在运行的任务只允许安全接入",
|
|
50
|
+
"progress notification",
|
|
51
|
+
"连续两个无有效里程碑",
|
|
52
|
+
"验证类别歧义",
|
|
53
|
+
"所有网络或模型连接失败共享同一个连续计数",
|
|
54
|
+
"只有一次完整 Agent 返回才重置连续计数",
|
|
55
|
+
"状态码必须按独立 token 边界匹配",
|
|
56
|
+
"空白 `blockers`",
|
|
57
|
+
"不消耗 Agent 调用",
|
|
58
|
+
"一键源码安装必须同时完成",
|
|
59
|
+
"Codex/Claude",
|
|
60
|
+
"Hook 自动升级必须复用同一完整部署闭环",
|
|
61
|
+
"CLAUDE_CODE_AUTO_COMPACT_WINDOW",
|
|
62
|
+
"240 秒兼容传输窗口",
|
|
63
|
+
"统一执行上下文清单",
|
|
64
|
+
"紧凑事实包",
|
|
65
|
+
"三级执行合同",
|
|
66
|
+
"收敛门禁",
|
|
67
|
+
"worktree",
|
|
68
|
+
"superflow doctor",
|
|
69
|
+
"taskkill /T /F",
|
|
70
|
+
"托管层保持轻量",
|
|
71
|
+
"Executor Prompt 只继承,不重新设计",
|
|
72
|
+
"完整 Superflow 任务必须是低自由度交付",
|
|
73
|
+
"Host 的持续目标机制可以包住一次 Superflow Task/Run",
|
|
74
|
+
"入口与资产保护同样遵守以下长期原则",
|
|
75
|
+
"protected-contracts",
|
|
76
|
+
],
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"docs/managed-work-design-principles.en.md",
|
|
80
|
+
[
|
|
81
|
+
"Script-versus-Agent decision matrix",
|
|
82
|
+
"superflow.handoff.v2",
|
|
83
|
+
"superflow.executor.v2",
|
|
84
|
+
"superflow.review.v2",
|
|
85
|
+
"Mandatory change review",
|
|
86
|
+
"never launch a full Executor invocation merely to repair JSON",
|
|
87
|
+
"instead of resetting every fresh session to source discovery",
|
|
88
|
+
"Immutable contract-hash projection has one source of truth",
|
|
89
|
+
"one-command, repeatable",
|
|
90
|
+
"Mandatory rules never rely on prompt context alone",
|
|
91
|
+
"hook, preflight, or final gate",
|
|
92
|
+
"Expected-failure and fault-injection checks use a parent acceptance command",
|
|
93
|
+
"launching a full Executor to delete or rewrite JSON",
|
|
94
|
+
"Control-plane atomicity and registry fault isolation",
|
|
95
|
+
"Start failure, lost-response retry, and stale-registry isolation",
|
|
96
|
+
"CLI `pipeline --managed` has the same atomic contract",
|
|
97
|
+
"MCP process exposes its startup runtime fingerprint",
|
|
98
|
+
"Verbose build/runtime logs go to task evidence files",
|
|
99
|
+
"Host review records real `hostUsage`",
|
|
100
|
+
"executor.stage_rework",
|
|
101
|
+
"deterministic owner template",
|
|
102
|
+
"remain readable after normal cleanup",
|
|
103
|
+
"system sleep consumes no execution budget",
|
|
104
|
+
"remain readable after normal cleanup",
|
|
105
|
+
"overwrites Superflow Skills",
|
|
106
|
+
"Three verification levels",
|
|
107
|
+
"Change-scoped checks",
|
|
108
|
+
"Task-level real acceptance",
|
|
109
|
+
"Framework certification",
|
|
110
|
+
"must not rerun",
|
|
111
|
+
"historical evidence",
|
|
112
|
+
"running task may only be safely attached",
|
|
113
|
+
"MCP progress notification",
|
|
114
|
+
"two consecutive checkpoints without an effective milestone",
|
|
115
|
+
"verification-category ambiguity",
|
|
116
|
+
"All network and model-connectivity failures share one consecutive counter",
|
|
117
|
+
"Only a complete Agent response",
|
|
118
|
+
"status codes require",
|
|
119
|
+
"blank `blockers`",
|
|
120
|
+
"without an Agent call",
|
|
121
|
+
"One-command source installation includes",
|
|
122
|
+
"Codex/Claude",
|
|
123
|
+
"Hook auto-apply share one complete deployment closure",
|
|
124
|
+
"CLAUDE_CODE_AUTO_COMPACT_WINDOW",
|
|
125
|
+
"240-second transport window",
|
|
126
|
+
"execution context manifest",
|
|
127
|
+
"compact fact packet",
|
|
128
|
+
"execution contracts",
|
|
129
|
+
"convergence gate",
|
|
130
|
+
"worktree",
|
|
131
|
+
"superflow doctor",
|
|
132
|
+
"taskkill /T /F",
|
|
133
|
+
"Managed orchestration stays lightweight",
|
|
134
|
+
"Executor prompts inherit rather than redesign",
|
|
135
|
+
"complete Superflow task is a low-freedom delivery contract",
|
|
136
|
+
"Host-native persistent goal may wrap one Superflow Task/Run",
|
|
137
|
+
"Entry and asset protection follow these additional long-term principles",
|
|
138
|
+
"protected-contracts",
|
|
139
|
+
],
|
|
140
|
+
],
|
|
141
|
+
[
|
|
142
|
+
"src/domains/managed-work/context-manifest.ts",
|
|
143
|
+
[
|
|
144
|
+
"manifestHash",
|
|
145
|
+
"validateManagedContextManifest",
|
|
146
|
+
"sha256",
|
|
147
|
+
"referencedLocalFiles",
|
|
148
|
+
"ManagedContextProtection",
|
|
149
|
+
'protection: "retain"',
|
|
150
|
+
],
|
|
151
|
+
],
|
|
152
|
+
[
|
|
153
|
+
"src/domains/managed-work/review-facts.ts",
|
|
154
|
+
["writeManagedReviewFacts", "changedFiles", "exitCode", "sha256"],
|
|
155
|
+
],
|
|
156
|
+
[
|
|
157
|
+
"src/domains/managed-work/evidence-path.ts",
|
|
158
|
+
["canonicalEvidencePath", "trailing description"],
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
"src/domains/managed-work/execution-contract.ts",
|
|
162
|
+
["minimal", "standard", "full", "defaultTasks", "canonicalTasksPath"],
|
|
163
|
+
],
|
|
164
|
+
[
|
|
165
|
+
"src/domains/managed-work/review-convergence.ts",
|
|
166
|
+
["MAX_STAGNANT_TRANSITIONS", "resolvedAny", "shouldContinue"],
|
|
167
|
+
],
|
|
168
|
+
[
|
|
169
|
+
"src/domains/managed-work/workspace-binding.ts",
|
|
170
|
+
["repositoryIdentity", "worktreeIdentity", "taskLocator", "branch"],
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
"src/platform/process-tree.ts",
|
|
174
|
+
["windows_tree", "taskkill.exe", "process_group"],
|
|
175
|
+
],
|
|
176
|
+
[
|
|
177
|
+
"assets/skills/superflow-pipeline/references/managed-work.md",
|
|
178
|
+
[
|
|
179
|
+
"设计宪章门禁",
|
|
180
|
+
"docs/managed-work-design-principles.md",
|
|
181
|
+
"验证固定分三级",
|
|
182
|
+
"不得为每个业务任务重复",
|
|
183
|
+
"共享连续失败计数",
|
|
184
|
+
"结构化数组中的空白项",
|
|
185
|
+
"安全接入",
|
|
186
|
+
"progress notification",
|
|
187
|
+
"连续两个无有效里程碑",
|
|
188
|
+
"验证类别歧义",
|
|
189
|
+
"Coding Ready",
|
|
190
|
+
"protected-contracts",
|
|
191
|
+
],
|
|
192
|
+
],
|
|
193
|
+
[
|
|
194
|
+
"assets/skills-en/superflow-pipeline/references/managed-work.md",
|
|
195
|
+
[
|
|
196
|
+
"Design-constitution gate",
|
|
197
|
+
"docs/managed-work-design-principles.en.md",
|
|
198
|
+
"Verification has three levels",
|
|
199
|
+
"must not rerun",
|
|
200
|
+
"consecutive-failure counter",
|
|
201
|
+
"blank structured-array entries",
|
|
202
|
+
"safe attach",
|
|
203
|
+
"progress notifications",
|
|
204
|
+
"two consecutive checkpoints without an effective milestone",
|
|
205
|
+
"verification-category ambiguity",
|
|
206
|
+
"docs-only work stops",
|
|
207
|
+
"protected-contracts",
|
|
208
|
+
],
|
|
209
|
+
],
|
|
210
|
+
[
|
|
211
|
+
"assets/scripts/superflow-managed-owner-verification.sh",
|
|
212
|
+
["通过可配置路径 source", "禁止复制后分叉维护"],
|
|
213
|
+
],
|
|
214
|
+
[
|
|
215
|
+
"src/domains/managed-work/prompts.ts",
|
|
216
|
+
[
|
|
217
|
+
"docs/managed-work-design-principles.md",
|
|
218
|
+
"docs/managed-work-design-principles.en.md",
|
|
219
|
+
"进程启动指纹",
|
|
220
|
+
"验证分三级",
|
|
221
|
+
"不得为每个业务任务重复",
|
|
222
|
+
"process-start fingerprint",
|
|
223
|
+
"Verification has three levels",
|
|
224
|
+
"must not rerun for every business task",
|
|
225
|
+
"workspace-temporary",
|
|
226
|
+
"Never use pkill",
|
|
227
|
+
],
|
|
228
|
+
],
|
|
229
|
+
[
|
|
230
|
+
"docs/managed-agent-protocol.md",
|
|
231
|
+
[
|
|
232
|
+
"强制规则不能只存在于 Prompt",
|
|
233
|
+
"hook/preflight/final gate",
|
|
234
|
+
"在持久化前完成运行时握手",
|
|
235
|
+
"单个陈旧条目不得让全局任务列表失败",
|
|
236
|
+
"运行时指纹",
|
|
237
|
+
"hostUsageUnavailableReason",
|
|
238
|
+
"不能复用旧裸 PID",
|
|
239
|
+
"休眠不计入",
|
|
240
|
+
"不能复用旧裸 PID",
|
|
241
|
+
"验证固定分三级",
|
|
242
|
+
"不得为每个业务任务重复",
|
|
243
|
+
"共享同一个连续失败计数",
|
|
244
|
+
"确定性清洗空白字符串元数据",
|
|
245
|
+
"安全接入",
|
|
246
|
+
"MCP progress notification",
|
|
247
|
+
"连续两个监督点没有有效里程碑",
|
|
248
|
+
"验证类别歧义",
|
|
249
|
+
"纯文档入口",
|
|
250
|
+
"immutable",
|
|
251
|
+
"delivery-artifacts",
|
|
252
|
+
],
|
|
253
|
+
],
|
|
254
|
+
[
|
|
255
|
+
"docs/managed-agent-protocol.en.md",
|
|
256
|
+
[
|
|
257
|
+
"mandatory rule never exists only in prompt context",
|
|
258
|
+
"Host semantic review",
|
|
259
|
+
"completes its runtime handshake before persistence",
|
|
260
|
+
"one stale entry never fails the global task list",
|
|
261
|
+
"runtime fingerprint",
|
|
262
|
+
"hostUsageUnavailableReason",
|
|
263
|
+
"never reused blindly",
|
|
264
|
+
"exclude system sleep",
|
|
265
|
+
"never reused blindly",
|
|
266
|
+
"Verification has three levels",
|
|
267
|
+
"must not rerun per business task",
|
|
268
|
+
"consecutive-failure counter",
|
|
269
|
+
"removes blank string metadata",
|
|
270
|
+
"safe attach",
|
|
271
|
+
"MCP progress notifications",
|
|
272
|
+
"Two consecutive",
|
|
273
|
+
"Verification-category ambiguity",
|
|
274
|
+
"docs-only entry",
|
|
275
|
+
"immutable",
|
|
276
|
+
"delivery artifacts",
|
|
277
|
+
],
|
|
278
|
+
],
|
|
279
|
+
[
|
|
280
|
+
"assets/scripts/superflow-managed-command-guard.py",
|
|
281
|
+
[
|
|
282
|
+
"SUPERFLOW_MANAGED_CONTEXT_MANIFEST",
|
|
283
|
+
"superflow_signal_owner",
|
|
284
|
+
"superflow_runtime_remove_verified",
|
|
285
|
+
"pkill",
|
|
286
|
+
],
|
|
287
|
+
],
|
|
288
|
+
]);
|
|
289
|
+
|
|
290
|
+
const failures = [];
|
|
291
|
+
|
|
292
|
+
for (const [relativePath, expectedTexts] of requirements) {
|
|
293
|
+
const absolutePath = path.join(root, relativePath);
|
|
294
|
+
if (!fs.existsSync(absolutePath)) {
|
|
295
|
+
failures.push(`${relativePath}: 文件不存在`);
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const content = fs.readFileSync(absolutePath, "utf8");
|
|
299
|
+
for (const expectedText of expectedTexts) {
|
|
300
|
+
if (!content.includes(expectedText)) {
|
|
301
|
+
failures.push(`${relativePath}: 缺少 ${expectedText}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const control = fs.readFileSync(
|
|
307
|
+
path.join(root, "src/domains/managed-work/control.ts"),
|
|
308
|
+
"utf8",
|
|
309
|
+
);
|
|
310
|
+
const startFunction = control.slice(
|
|
311
|
+
control.indexOf("export function startManagedTaskFromHost"),
|
|
312
|
+
control.indexOf("export function listManagedTaskSnapshots"),
|
|
313
|
+
);
|
|
314
|
+
if (
|
|
315
|
+
startFunction.indexOf("startService(runtime, language)") < 0 ||
|
|
316
|
+
startFunction.indexOf("startService(runtime, language)") >
|
|
317
|
+
startFunction.indexOf("createManagedTaskFiles(contract, state, env)")
|
|
318
|
+
) {
|
|
319
|
+
failures.push(
|
|
320
|
+
"src/domains/managed-work/control.ts: 托管启动必须先完成 service handshake 再持久化任务",
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
if (!control.includes("findRetryReusableTask(")) {
|
|
324
|
+
failures.push("src/domains/managed-work/control.ts: 缺少非终态启动幂等复用");
|
|
325
|
+
}
|
|
326
|
+
const listFunction = control.slice(
|
|
327
|
+
control.indexOf("export function listManagedTaskSnapshots"),
|
|
328
|
+
control.indexOf("export function getManagedTaskSnapshot"),
|
|
329
|
+
);
|
|
330
|
+
if (!listFunction.includes("try {") || !listFunction.includes("catch {")) {
|
|
331
|
+
failures.push(
|
|
332
|
+
"src/domains/managed-work/control.ts: task list 未隔离陈旧 registry locator",
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const pipeline = fs.readFileSync(
|
|
337
|
+
path.join(root, "src/app/commands/pipeline.ts"),
|
|
338
|
+
"utf8",
|
|
339
|
+
);
|
|
340
|
+
const cliService = pipeline.indexOf(
|
|
341
|
+
"ensureManagedService(process.argv[1], process.env, language)",
|
|
342
|
+
);
|
|
343
|
+
const cliPersist = pipeline.indexOf("createManagedTaskFiles(contract, state)");
|
|
344
|
+
if (cliService < 0 || cliPersist < 0 || cliService > cliPersist) {
|
|
345
|
+
failures.push("src/app/commands/pipeline.ts: CLI 托管启动必须先握手再持久化");
|
|
346
|
+
}
|
|
347
|
+
if (
|
|
348
|
+
!pipeline.includes("shouldAttachRunningTask") ||
|
|
349
|
+
!pipeline.includes("hasRunningResumeMutations")
|
|
350
|
+
) {
|
|
351
|
+
failures.push(
|
|
352
|
+
"src/app/commands/pipeline.ts: 健康运行任务缺少只读安全接入和改写参数拒绝门禁",
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const mcpServer = fs.readFileSync(path.join(root, "src/mcp/server.ts"), "utf8");
|
|
357
|
+
if (
|
|
358
|
+
!mcpServer.includes("superflow_managed_runtime") ||
|
|
359
|
+
!mcpServer.includes("assertMcpRuntimeCurrent(runtimeIdentity)")
|
|
360
|
+
) {
|
|
361
|
+
failures.push(
|
|
362
|
+
"src/mcp/server.ts: 缺少 MCP 运行时指纹查询或 start 前陈旧运行时门禁",
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
if (!mcpServer.includes("hostUsageUnavailableReason")) {
|
|
366
|
+
failures.push("src/mcp/server.ts: Host usage 不可用时缺少审计原因");
|
|
367
|
+
}
|
|
368
|
+
if (!mcpServer.includes('method: "notifications/progress"')) {
|
|
369
|
+
failures.push(
|
|
370
|
+
"src/mcp/server.ts: 健康进度缺少标准 MCP progress notification",
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
if (
|
|
374
|
+
!mcpServer.includes("DEFAULT_MCP_WAIT_TIMEOUT_SECONDS = 240") ||
|
|
375
|
+
!mcpServer.includes(".default(DEFAULT_MCP_WAIT_TIMEOUT_SECONDS)")
|
|
376
|
+
) {
|
|
377
|
+
failures.push("src/mcp/server.ts: MCP 默认等待未使用 240 秒兼容窗口");
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const runner = fs.readFileSync(
|
|
381
|
+
path.join(root, "src/domains/managed-work/runner.ts"),
|
|
382
|
+
"utf8",
|
|
383
|
+
);
|
|
384
|
+
const executorPolicy = fs.readFileSync(
|
|
385
|
+
path.join(root, "src/domains/managed-work/executor-policy.ts"),
|
|
386
|
+
"utf8",
|
|
387
|
+
);
|
|
388
|
+
if (
|
|
389
|
+
!executorPolicy.includes("# Compact Instructions") ||
|
|
390
|
+
!executorPolicy.includes("frozen prompt path and hash") ||
|
|
391
|
+
!executorPolicy.includes("stableExecutorPolicyHash")
|
|
392
|
+
) {
|
|
393
|
+
failures.push(
|
|
394
|
+
"src/domains/managed-work/executor-policy.ts: 稳定策略前缀或长会话交接指令缺失",
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
const agentProcess = fs.readFileSync(
|
|
398
|
+
path.join(root, "src/platform/agent-process.ts"),
|
|
399
|
+
"utf8",
|
|
400
|
+
);
|
|
401
|
+
if (
|
|
402
|
+
!agentProcess.includes("CLAUDE_CODE_AUTO_COMPACT_WINDOW") ||
|
|
403
|
+
!agentProcess.includes("CLAUDE_AUTOCOMPACT_PCT_OVERRIDE")
|
|
404
|
+
) {
|
|
405
|
+
failures.push(
|
|
406
|
+
"src/platform/agent-process.ts: Claude Executor 缺少提前自动压缩",
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
if (!runner.includes("\\b(?:429|503|529)\\b")) {
|
|
410
|
+
failures.push(
|
|
411
|
+
"src/domains/managed-work/runner.ts: 供应商状态码必须按 token 边界匹配,禁止命中 UUID 或路径",
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
if (
|
|
415
|
+
!runner.includes("executor.stage_rework") ||
|
|
416
|
+
!runner.includes("MANAGED_LOG_PART_BYTES") ||
|
|
417
|
+
!runner.includes("superflow-managed-owner-verification.sh") ||
|
|
418
|
+
!executorPolicy.includes("Use three verification levels") ||
|
|
419
|
+
!executorPolicy.includes("must not be rebuilt for every business task") ||
|
|
420
|
+
!executorPolicy.includes("certified owner-verification helper")
|
|
421
|
+
) {
|
|
422
|
+
failures.push(
|
|
423
|
+
"src/domains/managed-work/runner.ts: 缺少返工事件、日志分片、三级验证或 owner 模板复用约束",
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
if (
|
|
427
|
+
!runner.includes("executor.supervision_checkpoint_idle") ||
|
|
428
|
+
!runner.includes("executor.supervision_attention_required") ||
|
|
429
|
+
!runner.includes("executor.verification_metadata_escalated_to_host") ||
|
|
430
|
+
!runner.includes("executor.verification_metadata_host_promoted")
|
|
431
|
+
) {
|
|
432
|
+
failures.push(
|
|
433
|
+
"src/domains/managed-work/runner.ts: 缺少双空闲监督点 attention 或验证类别歧义的 Host 晋升审计",
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
if (
|
|
437
|
+
!runner.includes("runExecutorFinalPreflight") ||
|
|
438
|
+
!runner.includes("ExecutorFinalPreflightError")
|
|
439
|
+
) {
|
|
440
|
+
failures.push(
|
|
441
|
+
"src/domains/managed-work/runner.ts: ready_for_review 前缺少 Runner 最终 preflight 门禁",
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const installer = fs.readFileSync(path.join(root, "install.sh"), "utf8");
|
|
446
|
+
const windowsInstaller = fs.readFileSync(
|
|
447
|
+
path.join(root, "install.ps1"),
|
|
448
|
+
"utf8",
|
|
449
|
+
);
|
|
450
|
+
const mcpCommand = fs.readFileSync(
|
|
451
|
+
path.join(root, "src/app/commands/mcp.ts"),
|
|
452
|
+
"utf8",
|
|
453
|
+
);
|
|
454
|
+
const updateCommand = fs.readFileSync(
|
|
455
|
+
path.join(root, "src/app/commands/update.ts"),
|
|
456
|
+
"utf8",
|
|
457
|
+
);
|
|
458
|
+
const dependencyUpdateHook = fs.readFileSync(
|
|
459
|
+
path.join(root, "assets/scripts/superflow-dependency-update-hook.sh"),
|
|
460
|
+
"utf8",
|
|
461
|
+
);
|
|
462
|
+
if (
|
|
463
|
+
!installer.includes("--overwrite") ||
|
|
464
|
+
!windowsInstaller.includes("--overwrite")
|
|
465
|
+
) {
|
|
466
|
+
failures.push(
|
|
467
|
+
"安装器必须在 Unix/Windows 重复部署时覆盖 Skills,避免持续生成 backup",
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
if (
|
|
471
|
+
!installer.includes("mcp install $AGENT_FLAG") ||
|
|
472
|
+
!installer.includes("command -v codex") ||
|
|
473
|
+
!windowsInstaller.includes('@("mcp", "install", "--agent", $agentValue)') ||
|
|
474
|
+
!windowsInstaller.includes("Get-Command codex")
|
|
475
|
+
) {
|
|
476
|
+
failures.push(
|
|
477
|
+
"Unix/Windows 一键安装器必须检测实际 Host 并自动注册对应托管 MCP",
|
|
478
|
+
);
|
|
479
|
+
}
|
|
480
|
+
if (
|
|
481
|
+
!updateCommand.includes("refreshWithInstalledCli") ||
|
|
482
|
+
!updateCommand.includes("manageMcpIntegration") ||
|
|
483
|
+
!dependencyUpdateHook.includes("refresh_superflow_installation") ||
|
|
484
|
+
!dependencyUpdateHook.includes('rm -f "$STAMP" "$GLOBAL_STAMP"')
|
|
485
|
+
) {
|
|
486
|
+
failures.push(
|
|
487
|
+
"显式更新与 Hook 自动升级必须由新 CLI 完整刷新 Agent 资产和托管 MCP,并保留失败重试资格",
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
if (
|
|
491
|
+
!mcpCommand.includes("resolveMcpNodePath") ||
|
|
492
|
+
!mcpCommand.includes("/Cellar\\/node")
|
|
493
|
+
) {
|
|
494
|
+
failures.push(
|
|
495
|
+
"src/app/commands/mcp.ts: Homebrew MCP 注册必须使用稳定 Node 入口",
|
|
496
|
+
);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
if (failures.length > 0) {
|
|
500
|
+
console.error("托管设计宪章门禁失败:");
|
|
501
|
+
for (const failure of failures) {
|
|
502
|
+
console.error(`- ${failure}`);
|
|
503
|
+
}
|
|
504
|
+
process.exit(1);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
console.log("托管设计宪章门禁通过");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { chmodSync, existsSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
|
|
5
|
+
if (process.platform !== "win32") {
|
|
6
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
for (const file of ["dist/app/cli.js", "dist/mcp/server.js"]) {
|
|
8
|
+
const target = path.join(root, file);
|
|
9
|
+
if (existsSync(target)) chmodSync(target, 0o755);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolveInstallLanguage } from './postinstall.js';
|
|
3
|
+
|
|
4
|
+
const MIN_NODE_MAJOR = 20;
|
|
5
|
+
|
|
6
|
+
export function nodeMajor(version) {
|
|
7
|
+
const match = String(version).match(/^v?(\d+)/);
|
|
8
|
+
return match ? Number.parseInt(match[1], 10) : 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function isSupportedNode(version) {
|
|
12
|
+
return nodeMajor(version) >= MIN_NODE_MAJOR;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function buildNodeVersionMessage(version, language) {
|
|
16
|
+
const commands = [
|
|
17
|
+
' nvm install 22',
|
|
18
|
+
' nvm use 22',
|
|
19
|
+
' nvm alias default 22',
|
|
20
|
+
].join('\n');
|
|
21
|
+
|
|
22
|
+
if (language === 'zh') {
|
|
23
|
+
return [
|
|
24
|
+
`[Superflow] 需要 Node.js ${MIN_NODE_MAJOR} 或更高版本,当前检测到 ${version}。`,
|
|
25
|
+
'',
|
|
26
|
+
'请先升级到 Node.js 22 LTS;Superflow 不会自动修改你的系统 Node。',
|
|
27
|
+
'若已安装 nvm,请运行:',
|
|
28
|
+
commands,
|
|
29
|
+
'',
|
|
30
|
+
'完成后重新打开终端,再运行:',
|
|
31
|
+
' npm install -g @chenmk/superflow',
|
|
32
|
+
'未安装 nvm 时,请用系统包管理器或 https://nodejs.org 安装 Node.js 22 LTS。',
|
|
33
|
+
].join('\n');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return [
|
|
37
|
+
`[Superflow] Node.js ${MIN_NODE_MAJOR} or later is required; detected ${version}.`,
|
|
38
|
+
'',
|
|
39
|
+
'Install Node.js 22 LTS first. Superflow never changes your system Node automatically.',
|
|
40
|
+
'If nvm is already installed, run:',
|
|
41
|
+
commands,
|
|
42
|
+
'',
|
|
43
|
+
'Open a new terminal, then rerun:',
|
|
44
|
+
' npm install -g @chenmk/superflow',
|
|
45
|
+
'Without nvm, use your system package manager or https://nodejs.org to install Node.js 22 LTS.',
|
|
46
|
+
].join('\n');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function runPreinstall(version = process.versions.node, env = process.env) {
|
|
50
|
+
if (isSupportedNode(version)) return 0;
|
|
51
|
+
const language = resolveInstallLanguage(env);
|
|
52
|
+
console.error(buildNodeVersionMessage(version, language));
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const exitCode = runPreinstall();
|
|
57
|
+
if (exitCode !== 0) process.exitCode = exitCode;
|