ralphflow-dsh 2.3.1 → 2.4.0

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 (86) hide show
  1. package/README.md +47 -21
  2. package/graphs/codewiki/format.md +362 -0
  3. package/graphs/codewiki/graph.yaml +39 -0
  4. package/graphs/codewiki/nodes/assemble.md +24 -0
  5. package/graphs/codewiki/nodes/core-pages.md +17 -0
  6. package/graphs/codewiki/nodes/module-pages.md +18 -0
  7. package/graphs/codewiki/nodes/operations-pages.md +18 -0
  8. package/graphs/codewiki/nodes/survey.md +22 -0
  9. package/lib/asset-path.d.ts +59 -0
  10. package/lib/asset-path.js +181 -0
  11. package/lib/assets.d.ts +42 -0
  12. package/lib/assets.js +86 -0
  13. package/lib/client/phase.d.ts +29 -0
  14. package/lib/client/phase.js +86 -0
  15. package/lib/client/selection.d.ts +28 -0
  16. package/lib/client/selection.js +9 -0
  17. package/lib/client/status-source.d.ts +3 -1
  18. package/lib/client/status-source.js +3 -2
  19. package/lib/client/status.js +49 -13
  20. package/lib/client/viewer.d.ts +18 -0
  21. package/lib/client/viewer.js +540 -0
  22. package/lib/client.js +1159 -64
  23. package/lib/engine.d.ts +111 -47
  24. package/lib/engine.js +473 -320
  25. package/lib/facade.d.ts +175 -0
  26. package/lib/facade.js +553 -0
  27. package/lib/graph/agent-registry.d.ts +4 -0
  28. package/lib/graph/agent-registry.js +20 -0
  29. package/lib/graph/asset.d.ts +47 -0
  30. package/lib/graph/asset.js +276 -0
  31. package/lib/graph/assets.d.ts +47 -0
  32. package/lib/graph/assets.js +224 -0
  33. package/lib/graph/branches.d.ts +9 -0
  34. package/lib/graph/branches.js +13 -0
  35. package/lib/graph/check.d.ts +23 -0
  36. package/lib/graph/check.js +46 -0
  37. package/lib/graph/engine.d.ts +55 -0
  38. package/lib/graph/engine.js +2002 -0
  39. package/lib/graph/report.d.ts +9 -0
  40. package/lib/graph/report.js +117 -0
  41. package/lib/graph/state.d.ts +244 -0
  42. package/lib/graph/state.js +358 -0
  43. package/lib/graph/workspace.d.ts +68 -0
  44. package/lib/graph/workspace.js +262 -0
  45. package/lib/index.js +150 -47
  46. package/lib/owner.d.ts +34 -0
  47. package/lib/owner.js +49 -0
  48. package/lib/paths.d.ts +12 -0
  49. package/lib/paths.js +44 -0
  50. package/lib/pause.d.ts +12 -0
  51. package/lib/pause.js +19 -0
  52. package/lib/skills.d.ts +17 -30
  53. package/lib/skills.js +85 -21
  54. package/lib/status-contract.d.ts +114 -1
  55. package/lib/status-contract.js +106 -4
  56. package/lib/status-service.d.ts +5 -1
  57. package/lib/status-service.js +8 -1
  58. package/lib/tools.d.ts +14 -6
  59. package/lib/tools.js +88 -60
  60. package/lib/unfinished.d.ts +11 -0
  61. package/lib/unfinished.js +18 -0
  62. package/lib/verifier-preset.d.ts +40 -0
  63. package/lib/verifier-preset.js +126 -0
  64. package/lib/verify.d.ts +63 -9
  65. package/lib/verify.js +282 -72
  66. package/package.json +50 -38
  67. package/skills/ralphflow-create/SKILL.md +32 -0
  68. package/skills/ralphflow-create/graph-authoring.md +85 -0
  69. package/skills/ralphflow-create/matt/LICENSE +21 -0
  70. package/skills/ralphflow-create/matt/SHA256SUMS +6 -0
  71. package/skills/ralphflow-create/matt/SKILL-MECHANICS.md +22 -0
  72. package/skills/ralphflow-create/matt/SOURCE.md +12 -0
  73. package/skills/ralphflow-create/matt/grilling.md +30 -0
  74. package/skills/ralphflow-create/matt/to-spec.md +75 -0
  75. package/skills/ralphflow-create/matt/to-tickets.md +105 -0
  76. package/skills/ralphflow-create/matt/writing-for-agents.md +81 -0
  77. package/skills/ralphflow-create/ralphflow-authoring.md +31 -0
  78. package/skills/ralphflow-create/testing-workflow.md +60 -0
  79. package/{references → skills/ralphflow-create}/workflow-authoring.md +25 -5
  80. package/workflows/create-graph/steps/graph.md +17 -0
  81. package/workflows/create-graph/workflow.yaml +77 -0
  82. package/workflows/loop/workflow.yaml +23 -0
  83. package/lib/create.d.ts +0 -2
  84. package/lib/create.js +0 -17
  85. package/workflows/loop.yaml +0 -45
  86. /package/workflows/{spec.yaml → spec/workflow.yaml} +0 -0
@@ -0,0 +1,81 @@
1
+ ---
2
+ name: writing-for-agents
3
+ description: Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
4
+ ---
5
+
6
+ Reference for writing any document an agent consumes: a skill, an `AGENTS.md` / `CLAUDE.md`, a doc reached by a pointer. The packaging differs; the writing does not: the same levers make each one predictable, since the agent takes the same _process_ every run rather than producing the same output.
7
+
8
+ When the document you're writing is a skill, read [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md) for frontmatter, invocation choice, and router skills.
9
+
10
+ ## Context pointers
11
+
12
+ A **context pointer** is a reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. A skill's description is one; a line in `AGENTS.md` naming a doc is the same object. The pointer's _wording_, not its target, decides when the agent reaches the material, and how reliably. A must-have target behind a weakly worded pointer is a variance bug: sharpen the wording first, and inline the material only if sharpening fails.
13
+
14
+ A pointer does two jobs: state what the material is, and list the **branches** that should trigger reaching it (a branch is a distinct case the document handles, so different runs take different paths through it). Every word of an always-loaded pointer costs on every turn, so it earns even harder pruning than the body:
15
+
16
+ - **Front-load the leading word**: the pointer is where it does its triggering work.
17
+ - **One trigger per branch.** Synonyms that rename a single branch are one branch written twice; collapse them and keep only genuinely distinct branches.
18
+ - **Cut identity the body already carries.**
19
+
20
+ ## The two loads
21
+
22
+ Every document and pointer you add spends one of two budgets:
23
+
24
+ - **Context load** is the cost of always-loaded material on the agent's window: an `AGENTS.md` line, a skill description, anything sitting in context every turn, spending tokens and attention whether or not it fires.
25
+ - **Cognitive load** is the cost on the human: which documents exist and when to reach for each. The human is the index. Not a cost to minimise: it is the price of human agency; spend it where human judgement matters, remove it where it does not.
26
+
27
+ Material reached only through a pointer escapes context load at the price of the pointer's own line; material with no pointer at all rides entirely on cognitive load.
28
+
29
+ ## Information hierarchy
30
+
31
+ A document is built from two content types: **steps** (the ordered actions the agent performs) and **reference** (definitions, rules, facts consulted on demand). The two mix freely: all steps (a recipe), all reference (a review's rules, this skill), or both. The core decision is where each piece sits on the **information hierarchy**, a ladder ranked by how immediately the agent needs the material:
32
+
33
+ 1. **In-file step** is the primary tier: what the agent does, in order.
34
+ 2. **In-file reference** is consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung), which is a fine arrangement, not a smell.
35
+ 3. **Disclosed reference** is pushed out into a separate file, reached by a context pointer, loaded only when the pointer fires. Spans a sibling file in the same folder through fully external reference that lives anywhere and any document can point at.
36
+
37
+ Push too little down and the top bloats; push too much and you hide material the agent actually needs. That tension is the whole decision.
38
+
39
+ **Progressive disclosure** is the move down the ladder (out of the main file and behind a pointer) so the top stays legible. Not primarily a token optimisation: it is how the hierarchy is protected. Branching is the cleanest disclosure test: inline what every branch needs, and push behind a pointer what only some branches reach. When a document has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip: a variance lever, not just a legibility one.
40
+
41
+ **Co-location** is the within-file companion: where the ladder decides _how far down_ a piece sits, co-location decides _what sits beside it_ once there. Keep a concept's definition, rules, and caveats under one heading rather than scattered, so reading one part brings its neighbours with it. The test: the document should read like documentation written for the agent. Grouped material reads that way; scattered material does not. (Distinct from duplication: that repeats one meaning in two places; scattering fragments one meaning across many.)
42
+
43
+ **Sprawl** is the failure mode here: a document simply too long, even when every line is live and unique. Attention thins across the excess, and every extra line is one more to keep relevant. The cure is the ladder: disclose reference behind pointers, and split by branch or sequence so each path carries only what it needs.
44
+
45
+ ## Steps and completion criteria
46
+
47
+ Every step ends on a **completion criterion**, the condition that tells the agent the work is done. Two properties make it a lever:
48
+
49
+ - **Clarity**: can the agent tell done from not-done? A vague bound ("understanding reached") invites **premature completion**: ending the step before it is genuinely done, attention slipping to _being done_. The visible steps still ahead (the **post-completion steps**) supply the pull; the criterion's clarity is the resistance. Defend in order: **sharpen the bound first** (local and cheap); only if it is irreducibly fuzzy _and_ you observe the rush, hide the later steps by splitting the sequence. Hiding only works across a real context boundary (a hand-off or a subagent dispatch; an inline call leaves the later steps in context and clears nothing).
50
+ - **Demand**: how much it requires. "Every modified model accounted for" forces thorough work where "produce a change list" does not. Demand drives **legwork** (the digging the agent does within the work, latent in the wording rather than written as its own step), and it is not step-bound: "every rule applied" binds a body of flat reference just as "every step done" binds a sequence, which is how an all-reference document still carries an exhaustiveness bar.
51
+
52
+ The strongest criteria are both checkable and exhaustive.
53
+
54
+ ## When to split
55
+
56
+ Splitting one document into two spends one of the two loads, so split only when the cut earns it:
57
+
58
+ - **By sequence**: split a run of steps where the post-completion steps tempt the agent to rush the one in front of it. Keeping them out of view drives more legwork on the current task. Beware the reverse: merging sequences exposes each step's later steps to what follows, inviting premature completion.
59
+ - **By invocation**, skill-specific: see [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md).
60
+
61
+ ## Leading words
62
+
63
+ A **leading word** is a compact concept already living in the model's pretraining that the agent thinks with while running the document (_lesson_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition and anchors a whole region of behaviour in the fewest tokens, by recruiting priors the model already holds. Coining your own works if you define it clearly, but a made-up word recruits no priors: you pay in definition tokens what a pretrained word gives free; reach for an existing word first.
64
+
65
+ It anchors twice. In the body, _execution_: the agent reaches for the same behaviour every time the word appears, and inside flat reference it focuses attention on a class of thing to look for. In a pointer, _invocation_: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the material and reaches it more reliably.
66
+
67
+ Hunt for opportunities to refactor with leading words. A triad spelled out at three sites, a pointer spending a sentence to gesture at one idea. Each is a passage begging to collapse into a single token:
68
+
69
+ - "fast, deterministic, low-overhead" → _tight_ (a _tight_ loop).
70
+ - "a loop you believe in" → _red_, turning a fuzzy gate into a binary observable state (the loop goes _red_ on the bug, or it doesn't).
71
+
72
+ You win twice: fewer tokens, and a sharper hook for the agent to hang its thinking on. Assume every document is carrying restatements that leading words retire. Go find them.
73
+
74
+ **Negation** is the failure mode beside this lever: steering by prohibition drags the forbidden behaviour into context and makes it _more_ available, not less. _Don't think of an elephant_, and the elephant is all there is; the negation is a weak modifier the strongly-activated concept overruns, so the ban half-reads as an instruction to do the thing. Prompt the **positive**: state the target behaviour ("write one-line comments") so the banned one is never spoken. A prohibition earns its place only as a hard guardrail you cannot phrase positively; even then, pair it with the positive target so attention lands on what to do.
75
+
76
+ ## Pruning
77
+
78
+ - Keep each meaning in a **single source of truth**: one authoritative place, so changing the behaviour is a one-place edit. **Duplication** (the same meaning in more than one place) costs maintenance and tokens, and inflates a meaning's prominence on the ladder past its real rank. (The accidental inverse of a leading word, which repeats a token on purpose, never the meaning.)
79
+ - The **environment** is a source of truth too (`package.json` scripts, config files, the directory layout, `--help` output), and a document that restates it is a **cache**: a copy of a lookup, earning its load only when the lookup is expensive. Cache what the agent cannot find by looking: the unwritten convention, the reason behind a choice, the gotcha no config confesses. Leave the one-file, one-command lookups to the environment, where they cannot go stale.
80
+ - Check every line for **relevance**: does it still bear on what the document does? A line loses relevance by never bearing on the task (mere exposition, or a branch that should be disclosed) or by going stale as the behaviour or world it describes changes. Shorter documents are easier to keep relevant. Without a pruning discipline the default fate is **sediment**: stale layers that settle because adding feels safe and removing feels risky, until you must core down through them to find what is still live.
81
+ - Hunt **no-ops** sentence by sentence: an instruction the model already obeys by default pays load to say nothing. The test (does it change behaviour versus the default?) is model-relative, not reader-relative: two people disagreeing about a no-op disagree about the default, and settle it by running the document, not by debate. When a sentence fails, delete the whole sentence rather than trim words from it. The test also grades leading words: a word too weak to beat the default (_be thorough_ when the agent is already thorough-ish) is a no-op, and the fix is a stronger word (_relentless_), not a different technique.
@@ -0,0 +1,31 @@
1
+ # RalphFlow 作者适配
2
+
3
+ 本文件只补 RalphFlow 的落盘约定;grill、spec、tickets 的方法用同目录 `matt/` 的原文,不在这里复述。
4
+
5
+ ## 本地文件模式
6
+
7
+ Matt 的 `to-spec` / `to-tickets` 默认发布到 issue tracker。RalphFlow 使用本地文件,不运行 `/setup-matt-pocock-skills`,不创建 GitHub/Linear issue。
8
+
9
+ 一次设计使用 `.dsh/ralph-flow/designs/<slug>/`:
10
+
11
+ - `grill.md`:grill 的决定与未决项
12
+ - `spec.md`:spec 正文
13
+ - `tickets/<NN>-<slug>.md`:一个 ticket 一个文件
14
+ - `tickets.json`:ticket 图,字段 `id`、`title`、`depends_on`、`acceptance`、`files`
15
+ - `design-delivery.json`:交付摘要
16
+
17
+ `<slug>` 用小写 kebab-case,与最终资产目录 `.dsh/ralph-flow/graphs/<slug>/` 同名。
18
+
19
+ ## 生成的 Graph
20
+
21
+ - 一个 ticket 一个 `steps` 条目;`id` 用 ticket id
22
+ - 一个 ticket 一个 `nodes/<id>.md`:`## 做什么` 写完整动作与完成条件,`## 验收` 写 ticket 的 acceptance
23
+ - `graph.yaml` 是入口地图:每个 `do` 一句话(目标 + 交付)加 `nodes/<id>.md` 指针,`check` 一句话指向该文件的「验收」一节
24
+ - 节点文件用项目内路径引用 spec 与 ticket
25
+ - `depends_on` 来自 `tickets.json`
26
+ - 资产生成后用 `ralphflow_doctor` 校验;不自动启动
27
+ - 生成资产把可复用的契约、模板放进自己的资产目录,DO/CHECK 用相对路径指向它们(参考根 = 入口文件所在目录);用户项目的事实用项目内路径
28
+
29
+ ## 写作规范
30
+
31
+ 写 spec、tickets、Graph 的 DO/CHECK 前,读 `matt/writing-for-agents.md`;每条适用规则都要落到交付物里。
@@ -0,0 +1,60 @@
1
+ # 测试工作流设计
2
+
3
+ 当请求要构建测试任务,或要构建可复用的测试与缺陷工作流时阅读。交付物是一张工作图,其报告在发现缺陷或列出未验证范围时即属完整;你负责设计,用户负责启动。
4
+
5
+ ## 梳理测试范围
6
+
7
+ 设计前,先找到项目真正的检查入口:阅读 `package.json` 脚本、测试目录、CI 配置和现有测试数据。为每个验收区域记录:
8
+
9
+ - 全新的执行者能在 Git 工作树中运行的确切命令;
10
+ - 该命令读取的仅运行期数据或环境,例如未跟踪的 fixture、被忽略的测试数据目录;
11
+ - 该命令产生的证据:失败的测试名称、断言消息、用例结果、退出码。
12
+
13
+ 覆盖区域来自任务的验收标准,而不是只看现有测试文件。没有任何命令检查的需求,要留在方案中,标为未覆盖并说明原因。
14
+
15
+ 完成条件:每个区域都指明一条真实命令,或被记录为未覆盖并写明原因。
16
+
17
+ ## 测试分支
18
+
19
+ Graph 始终在 Git worktree 中运行。为每条独立命令分配自己的 `background` 步骤;就绪步骤全部放行,由 DSH 的 agent 并发限制排队。
20
+
21
+ DO 在自己的工作树中用原生 Bash 运行命令,然后写入证据产物,记录确切命令、工作目录、退出码、输出摘要或节选,以及每个失败测试或用例及其断言消息。命令失败也是要记录的结果:当证据说明了实际发生的情况时,该分支即完成。
22
+
23
+ 分支的 CHECK(独立验收)核验证据是否忠实:确切命令、真实退出码、每个被指名的失败及其证据、每个被指名的跳过及其原因。证据忠实的失败测试套件也能通过;这正是测试工作流的意义所在。
24
+
25
+ 完成条件:每个分支都运行真实命令,并交付一个证据产物,其 CHECK 能接受失败或部分跳过的测试套件。
26
+
27
+ ## 缺陷报告
28
+
29
+ 一个综合节点依赖所有测试分支,并通过 `原生 read` 读取它们已验收的证据。它的报告合并三个部分:
30
+
31
+ - **缺陷**:每条发现单独一条记录,包含复现命令、退出状态、失败的测试或用例,以及它来自哪个证据产物。
32
+ - **覆盖情况**:一张表格,把每个计划中的验收区域归类为已验证或未验证,并附上证据或原因。
33
+ - **未验证范围**:每个缺失的数据文件、环境值、依赖或未覆盖区域,它导致哪项验收未验证,以及为什么没有验证。
34
+
35
+ 测试全绿只是一种可能的结果,不是交付。交付是一份完整、有证据支撑的报告:当证据支持时,一份发现缺陷的报告同样完成任务。
36
+
37
+ 完成条件:每个缺陷和每个计划中的验收区域都出现,并带有证据或明确的未验证原因。
38
+
39
+ ## 缺失的资料
40
+
41
+ 需要仅运行期数据或环境的命令,在 DO 里写清它读取的路径或条件,并让步骤先核对它们是否存在:
42
+
43
+ - 文件或目录:在任务文本或 DO 中给出工作区相对路径;缺失时把该步骤判为 blocked,并在证据中写明缺失路径和未验证范围。
44
+ - 宿主环境值:在 DO 中写明变量名和用途;缺失时同样 blocked,不编造值。
45
+
46
+ 把缺失描述写成该资料提供的验收项,因为它会出现在状态和未验证范围中。没有已验收证据的计划验收区域,在报告中保持未验证。被跳过的关键验收永远不算通过。
47
+
48
+ 完成条件:每个仅运行期输入都在 DO 中声明,由需要它的步骤核对,并描述为它所提供的验收。
49
+
50
+ ## CHECK 的选择
51
+
52
+ - 测试分支:使用自定义 CHECK,判据覆盖可观察的证据——命令、退出码、被指名的失败和被指名的跳过。
53
+ - 报告:使用自定义 CHECK,判据覆盖证据引用、区域覆盖、未验证范围,以及“没有支撑证据就不得判定通过”的规则。按证据和覆盖情况评判报告,因此只要报告忠实记录,发现缺陷或指出被跳过的范围也算通过。
54
+ - 没有专门验收需求的节点可以关闭 CHECK。
55
+
56
+ 完成条件:`ralphflow_doctor 的有效 CHECK` 显示每个节点选定的模式和判据,且报告判据能接受失败或部分跳过的测试套件。
57
+
58
+ ## 交付
59
+
60
+ 方案指明命令和已声明的资料;结果只有来自已验收的证据才能进入报告。交付的资产要固定其 CHECK 模式;设计期间不启动任何测试实例。用户在审查后明确启动工作流。
@@ -1,6 +1,24 @@
1
1
  # 工作流 YAML 参考
2
2
 
3
- 创建指南指向的按需参考。字段行为以加载器及 doctor 的结果为准;这里只描述本插件支持的方言。
3
+ 创建指南指向的按需参考。字段行为以加载器及 doctor 的结果为准;这里只描述本插件支持的 Flow 方言。
4
+
5
+ - 写步骤的 DO/CHECK 之前,先读随包唯一权威副本 [`matt/writing-for-agents.md`](matt/writing-for-agents.md)(同目录);它讲的是“给 agent 读的执行指令怎么写”,不是另一份 YAML 字段表。
6
+ - Graph 资产(`kind: graph`、`nodes`、`dependsOn`、逐节点产物)的字段与例子见 [`graph-authoring.md`](graph-authoring.md);本文件不重复 Graph schema。
7
+
8
+ ## 资产目录
9
+
10
+ 资产是一个目录:`workflows/<name>/workflow.yaml` 加它引用的资源。**参考根是入口文件所在目录**:DO/CHECK 引用的**资产资源**(契约、模板、校验清单)用相对路径按它解析,执行者与验证者的提示词里都会带上同一个目录。可复用的契约、模板放进资产目录并用相对路径指向,不要复制进每一步的提示词。这个根只解析资产资源;过程记录与交付物按用途分流(见本文「过程记录与交付物的落点」)。单文件形态 `workflows/<name>.yaml` 仍可加载,参考根是 `workflows/`(兼容形态,共享资源放那里)。
11
+
12
+ ## 入口是地图,做法在资源里
13
+
14
+ 资产入口(`workflow.yaml`)先给人看:每一步只留「做什么、交付什么」一句话,让人一眼看懂整条流程。具体做法与验收判据放进资产目录的文件,入口用相对路径指向。
15
+
16
+ - 入口的 `do` 写这一步的目标与交付;动作序列、领域契约、字段表、校验清单放进 `steps/<id>.md`(或共用的一份 `format.md`)。
17
+ - CHECK 同理:入口写「按 `<文件>` 的验收一节逐条核对并给出证据」,判据正文放文件。
18
+ - 判断该不该外置:把入口单独给人看,他能不能说清每一步在做什么;把入口单独给执行者,它能不能顺指针拿到全部做法。两条都成立就够。
19
+ - 只有一步就能说清的工作(例如内置 `loop`)不拆:入口本身就是全部。
20
+
21
+ 完成条件:入口的每一行都在描述「做什么」;同一份做法只在一个文件里出现。
4
22
 
5
23
  ## 本版本支持的 YAML 方言(引擎硬校验)
6
24
 
@@ -43,7 +61,7 @@ steps: # 必填,非空;从第一个元素开始执行
43
61
  # - check: 实现的行为符合预期,真实可用
44
62
  # model: deepseek/deepseek-chat # 可选:该票专用模型(不填继承全局 adversarial_check.model)
45
63
  input: proposal.md # 必填:输入说明(**进 DO 与 CHECK 提示词**;写清输入在哪里及如何使用)
46
- output: | # 必填:交付物说明(只说**产出什么**;落在哪里见「产出目录」一节)
64
+ output: | # 必填:交付物说明(只说**产出什么**;落在哪里见「落点」一节)
47
65
  实现的代码/文件
48
66
  on_pass: next-id # 必填:下个步骤 id,或 "done"(末步);不再有「缺省 = 顺序下一步」
49
67
  on_fail: step-id # 必填:失败重试目标(步骤 id,**不允许 "done"**);不再有「缺省 = 自身」
@@ -62,7 +80,7 @@ steps: # 必填,非空;从第一个元素开始执行
62
80
  desc: 需求分析 # 必填:与子工作流各步的 desc 组合显示(`需求分析 · 子步骤 desc`)
63
81
  input: proposal.md # 必填:调用点没有 DO/CHECK 阶段 —— 这一项只作为**委托声明**被保留与校验
64
82
  output: analysis.md # 必填:同上
65
- workflow: analyze # 必填:子工作流**名**(`workflows/<名字>.yaml`、全局目录或内置同名);不能是路径
83
+ workflow: analyze # 必填:子工作流**名**(`workflows/<名字>/workflow.yaml`、全局目录或内置同名);不能是路径
66
84
  on_pass: build # 必填:整段子工作流跑完后去哪(步骤 id 或 "done")
67
85
  on_fail: analyze # 必填:只做**引用校验**(子步骤失败不会回到它 —— 子步骤耗尽预算是暂停等人)
68
86
  max_fail_count: 3 # 必填:同上,只做校验
@@ -75,6 +93,8 @@ steps: # 必填,非空;从第一个元素开始执行
75
93
  # 它们都属于子工作流**内部**的具体步骤。
76
94
  ```
77
95
 
96
+ **`do` 只写这一步的工作**:做什么、交付什么、怎么自查。不要写引擎内部协议——交卷/报进度、`unfinished`、CHECK 如何委派、状态字段、心跳/恢复、产出目录落点;这些由引擎在 DO/CHECK 提示词里自动追加。工作流里重复它们会与引擎的单一事实源打架,也会让把工作流当模板的人困惑。
97
+
78
98
  **验证模型优先级链**(与 opencode/claude 一致):`check_voting` 条目 `model` > 步骤 `check_model` > 全局 `adversarial_check.model` > 发起会话当前模型(都不写时不传模型覆盖,由宿主继承发起会话的 provider/model)。
79
99
 
80
100
  **硬规则**(违反 → 启动即被拒绝并说人话):
@@ -100,9 +120,9 @@ steps: # 必填,非空;从第一个元素开始执行
100
120
 
101
121
  **输出契约**:output 列明最终产出与必须交接的过程文档;do 负责生成与更新,check 负责核对存在、内容及实际证据。output 本身不会创建文件或机械检查文件存在。过程文档列入 output 后仍遵循下方落点规则。
102
122
 
103
- **产出目录**:每个实例有隔离的产出目录 `<workspace>/.dsh/ralph-flow/artifacts/<实例ID 摘要>/`(目录名 = 任务摘要 slug + 实例 id 尾段),实例启动时自动建好。它是**过程文档**(清单、方案、报告、摘要、草稿等)的唯一默认落点:`do`/`output` 里写**裸文件名**即可(例如 `summary.md`),不用写路径、也不需要任何模板记号;写了**明确路径**的按写的路径来。工作目录只放本步的**产物**(代码、资源、可执行文件);同一份过程文档只写一处、不要在工作目录里再留副本。DO 与 CHECK 提示词都会自动带上这条落点边界(CHECK 还会点明「工作目录里的副本是落点错误、不算满足」)。
123
+ **过程记录与交付物的落点**:每个实例有隔离的产出目录 `<项目根>/.dsh/ralph-flow/artifacts/<实例ID 摘要>/`(目录名 = 任务摘要 slug + 实例 id 尾段;项目根 = 从会话目录向上最近的含 `.git` 的祖先目录,没有就用会话目录本身),实例启动时自动建好。**过程记录**(清单、方案、报告、摘要、草稿等)写进这个目录:在 `do`/`output` 里写**文件名**即可(例如 `summary.md`),不用写路径、也不需要任何模板记号;**交付物**(代码、文档产品、可执行文件)落工作目录,`output` 里写了**明确路径**的按那个路径。DO 与 CHECK 提示词都会自动带上这条规则(CHECK 还会点明:工作目录里的副本不算满足)。这条规则与「资产目录」并行:资产目录只解析资产资源的相对引用。
104
124
 
105
- **实例生命周期**:工作流完成或取消时,实例目录与 `state.json` 会被**销毁**,最终报告归档到 `<workspace>/.dsh/ralph-flow/reports/<实例ID>.md`(报告与产出是永久的,插件永不自动删除;只有**空的**产出目录会被删掉)。要回看已结束的运行,用 `/ralphflow-list` 的「历史运行」节或直接读报告文件。
125
+ **实例生命周期**:工作流完成或取消时,实例目录与 `state.json` 会被**销毁**,最终报告归档到 `<项目根>/.dsh/ralph-flow/reports/<实例ID>.md`(报告与产出是永久的,插件永不自动删除;只有**空的**产出目录会被删掉)。要回看已结束的运行,用 `/ralphflow-list` 的「历史运行」节或直接读报告文件。
106
126
 
107
127
  **子工作流(加载期静态展开,与 opencode 对齐但落地方式不同)**:调用点被**就地展开**成子工作流的步骤 —— 每个子步骤 id 是 `调用点id/子步骤id`(多层继续叠加,如 `analyze/research/step1`),子工作流的出口(`on_pass: done` )接到调用点的 `on_pass`(调用点必须显式填写)。运行期因此没有任何「父子状态栈」:`current_step` 仍是单字符串、失败预算仍按步记账,**零新增实例状态字段**。要点:
108
128
 
@@ -0,0 +1,17 @@
1
+ ## 做什么
2
+
3
+ 按 `ralphflow-create` skill 资源目录中的 `graph-authoring.md`、`ralphflow-authoring.md` 和 `matt/writing-for-agents.md` 生成资产。
4
+
5
+ 按 tickets.json 生成 `.dsh/ralph-flow/graphs/<slug>/`:一个 ticket 一个步骤,`id` 用 ticket id,`depends_on` 来自 ticket 依赖。`graph.yaml` 是入口地图:每步只写一句「做什么、交付什么」加指针(`do` ≤ 120 字符),`check` 只写一句验收指针(≤ 80 字符);每个 ticket 的完整动作与验收写进同目录 `nodes/<ticket-id>.md`,分「## 做什么」「## 验收」两节,入口用相对路径 `nodes/<ticket-id>.md` 指向。节点文件用项目内路径引用 spec 与 ticket。可复用的契约与模板放进同一个资产目录,用相对路径指向;入口不复述做法,也不复制 Matt 参考正文。
6
+
7
+ 用 `ralphflow_doctor({ "path": ".dsh/ralph-flow/graphs/<slug>/graph.yaml" })` 校验;修到全部通过。把资产路径、ticket 图和下一步写进交付消息;不启动生成的 Graph。
8
+
9
+ 完成条件:资产通过 doctor,目录名与启动名一致,ticket、步骤与 `nodes/<id>.md` 一一对应,交付消息给出路径和用户下一步。
10
+
11
+ ## 验收
12
+
13
+ 1. 每个 ticket 恰好对应一个 Graph 步骤;id、depends_on 与 tickets.json 一致,依赖无环。
14
+ 2. `graph.yaml` 是入口地图:每个 `do` 是一句「目标 + 交付」并指向 `nodes/<ticket-id>.md`(≤ 120 字符),每个 `check` 是一句验收指针(≤ 80 字符);入口每行只描述「做什么」。
15
+ 3. 每个 ticket 的完整动作与验收都写在同目录 `nodes/<ticket-id>.md` 的两节里:`## 做什么` 覆盖 spec 与 ticket 的动作、完成条件,`## 验收` 覆盖 ticket acceptance;执行者顺指针能拿到全部做法。
16
+ 4. 生成的 DO/CHECK 符合 `ralphflow-create` skill 资源目录中的 `matt/writing-for-agents.md`;可复用的契约与模板放在同一个资产目录并由相对路径指向,没有复制进节点提示词;入口是 `.dsh/ralph-flow/graphs/<slug>/graph.yaml`,每条相对路径都指向同目录里存在的文件(含 `nodes/<id>.md`)。
17
+ 5. `ralphflow_doctor` 对保存的资产全部通过;交付声明没有启动生成的 Graph。
@@ -0,0 +1,77 @@
1
+ description: 设计 Graph DAG:grill 决定 → spec → tickets → 按 ticket 依赖生成 Graph 资产
2
+
3
+ # spec 和 tickets 是 DAG 的输入契约:独立 CHECK 后再由用户明确放行。
4
+ manual_step: [spec, tickets]
5
+
6
+ steps:
7
+ - id: grill
8
+ desc: 把设计目标 grill 成可执行决定
9
+ input: 用户的想法与约束
10
+ output: .dsh/ralph-flow/designs/<slug>/grill.md
11
+ do: |
12
+ 加载 `ralphflow-create` skill,按其 Graph 分支工作;如果你已经在 create-graph 中,只执行本步骤,不重新启动实例。
13
+
14
+ 读 `ralphflow-create` skill 资源目录中的 `matt/grilling.md`,按 design tree 逐轮提问:先问 frontier(不依赖未答问题的一批决定),每问给推荐答案;用户答完再问下一轮。事实由你查,决定交给用户。
15
+
16
+ 把已决定事项、未决项、非目标和约束写进 grill.md。
17
+
18
+ 完成条件:每个会改变 spec 或 ticket 边界的决定都有答案或明确待定;grill.md 可独立阅读。
19
+ check: |
20
+ 1. grill.md 记录每个已决定事项的答案、理由和影响;没有只有问题、没有结论的条目。
21
+ 2. 每个未决项都标为待定并说明它阻塞哪个决定;没有隐含假设。
22
+ 3. 非目标与约束已写明,且与用户回答一致。
23
+ on_pass: spec
24
+ on_fail: grill
25
+ max_fail_count: 2
26
+
27
+ - id: spec
28
+ desc: 把 grill 决定写成可执行 spec
29
+ input: grill.md
30
+ output: .dsh/ralph-flow/designs/<slug>/spec.md
31
+ do: |
32
+ 按 `ralphflow-create` skill 资源目录中的 `matt/to-spec.md` 和 `ralphflow-authoring.md` 的本地文件模式写 spec;不运行 `/setup-matt-pocock-skills`,不创建 issue。
33
+
34
+ 以 grill.md 为唯一需求来源写 spec.md,按 to-spec 的模板组织:问题、方案、用户故事、实现决定、测试决定、范围外、补充说明。每条验收写成可观察结果。
35
+
36
+ 完成条件:spec 覆盖 grill 的每个决定,没有待定项;每条验收都能映射到未来的 ticket。
37
+ check: |
38
+ 1. grill 的每个决定都在 spec 中有对应条目;未决项已解决或写成明确的非目标。
39
+ 2. spec 的目标、非目标、约束、实现决定、测试决定和验收都可执行、可验证,没有“待定”或空章节。
40
+ 3. 每条验收都能在未来 ticket 中被单独验证,没有把实现细节写成不可验收的愿望。
41
+ 4. spec 中面向 agent 的文本符合 `ralphflow-create` skill 资源目录中的 `matt/writing-for-agents.md`:完成条件清晰、指针带触发条件、正面表述、单一事实来源。
42
+ on_pass: tickets
43
+ on_fail: spec
44
+ max_fail_count: 2
45
+
46
+ - id: tickets
47
+ desc: 把 spec 拆成带依赖的垂直切片
48
+ input: spec.md
49
+ output: .dsh/ralph-flow/designs/<slug>/tickets/
50
+ do: |
51
+ 按 `ralphflow-create` skill 资源目录中的 `matt/to-tickets.md` 和 `ralphflow-authoring.md` 的本地文件模式拆分 ticket。
52
+
53
+ 先向用户展示 ticket 列表与阻塞边(标题、Blocked by、交付的端到端行为),问粒度与依赖是否正确;用户确认后再落盘。
54
+
55
+ 每个 ticket 写到 `.dsh/ralph-flow/designs/<slug>/tickets/<NN>-<slug>.md`,同时写 `tickets.json`。ticket 的 `do` 要能独立执行,acceptance 要可观察;依赖只保留真正阻塞的关系。
56
+
57
+ 完成条件:tickets.json 与 ticket 文件一一对应,依赖无环,每个 spec 验收都有 ticket 覆盖。
58
+ check: |
59
+ 1. 每个 spec 验收项至少被一个 ticket 覆盖;没有重复覆盖或计划外 ticket。
60
+ 2. 每个 ticket 是垂直切片,依赖完成后可独立实现;写明 What to build、Blocked by、acceptance 和涉及面。
61
+ 3. tickets.json 与 ticket 文件一一对应,依赖都存在且无环;没有悬空依赖。
62
+ 4. ticket 的 `do` 与 acceptance 符合 `ralphflow-create` skill 资源目录中的 `matt/writing-for-agents.md`:完成条件可核查、动作具体、正面表述。
63
+ on_pass: graph
64
+ on_fail: tickets
65
+ max_fail_count: 2
66
+
67
+ - id: graph
68
+ desc: 按 ticket 依赖生成 Graph 资产并校验
69
+ input: tickets.json 与 tickets/
70
+ output: .dsh/ralph-flow/graphs/<slug>/graph.yaml 与 nodes/<id>.md
71
+ do: |
72
+ 按 ticket 依赖生成 Graph 资产并校验:读 steps/graph.md 的「做什么」一节,按它执行。
73
+ check: |
74
+ 读 steps/graph.md 的「验收」一节,逐条核对并给出证据。
75
+ on_pass: done
76
+ on_fail: graph
77
+ max_fail_count: 1
@@ -0,0 +1,23 @@
1
+ description: 单步对抗验证循环:需求与边界、实际可用性、回归影响三个视角全部通过才结束
2
+
3
+ steps:
4
+ - id: loop
5
+ desc: 迭代执行任务直到通过对抗验证
6
+ reset: true
7
+ do: |
8
+ 按用户要求完成任务,控制修改范围,避免引入无关改动。
9
+
10
+ 每次交卷前,把本次交卷的摘要追加到 summary.md(一次交卷一节,保持精简):
11
+ - 本次交卷实际完成的事项(逐条对照任务要求)
12
+ - 变更文件
13
+ - 验证结果(命令与结果,或文件位置)
14
+ input: 用户任务描述
15
+ output: 实现的代码/文件
16
+ check_voting:
17
+ # 三个互补视角:需求与边界、实际可用性、回归影响。
18
+ - check: 用户任务的每一条要求都已落实,没有遗漏,相关边界与异常情况已覆盖
19
+ - check: 实现的行为和实际产出符合预期、真实可用,有可复核的验证依据
20
+ - check: 修改不影响原有功能和既有约定,不引入需求以外的副作用
21
+ on_pass: done
22
+ on_fail: loop
23
+ max_fail_count: 100
package/lib/create.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const AUTHORING_REFERENCE_PATH: string;
2
- export declare const CREATE_GUIDE: string;
package/lib/create.js DELETED
@@ -1,17 +0,0 @@
1
- /** Workflow creation recipe; detailed dialect is disclosed through a shipped reference. */
2
- import { fileURLToPath } from "node:url";
3
- export const AUTHORING_REFERENCE_PATH = fileURLToPath(new URL("../references/workflow-authoring.md", import.meta.url));
4
- export const CREATE_GUIDE = `与用户设计自定义 Ralph Flow 工作流,按以下顺序完成:
5
-
6
- 1. 明确流程目标、交付物与可验证的完成条件,找出需要用户审查的位置;已有信息足够就直接设计,仅问会影响流程的缺项。
7
- 2. 展示紧凑步骤图:步骤 → 交付物 → 验收方式 → on_pass / on_fail 目标。方向明确后写 YAML;跨步任务应有可从文件恢复的需求、决定和证据。
8
- 3. 默认写入 \`<workspace>/.dsh/ralph-flow/workflows/<name>.yaml\`。用户要求全局复用时写入 \`~/.dsh/ralph-flow/workflows/<name>.yaml\`。用小写 kebab-case 命名;同名文件会遮蔽内置或全局工作流,先确认这是用户意图。
9
- 4. 写定义前读取下方 YAML 参考的基本字段与硬规则。用投票时查 check_voting;需要模型覆盖时查模型配置与优先级;跨步清上下文时查 reset;复用子流程时查子工作流调用点与继承。参考文件:
10
- \`${AUTHORING_REFERENCE_PATH}\`
11
- 5. do 写执行顺序与交付标准;check 写独立验证者可以取证的通过/失败条件。项目专用流程点名文件与命令,通用流程按项目实际入口选方法。投票各管一个互补视角;通常 2–3 票足够。角色纪律与判定输出由插件提供。
12
- 6. 调用 \`ralphflow_doctor\`,修复目标工作流的每个 ❌ 与告警再重跑,直到目标定义全部 ✅ 且无告警。它同时检查其它定义与实例:范围外问题如实告知用户,勿为完成创建而修改其它运行。
13
- 7. 给出文件位置、最终步骤图、审查门和运行方式 \`/ralphflow-start <名字> <任务>\`。后续会话可使用快捷技能 \`/ralphflow-<工作流名> <任务>\`;本次创建不自动启动执行。
14
-
15
- 过程文档(清单、方案、报告、摘要、草稿)的默认落点是实例产出目录。写裸文件名即可;明确路径按指定路径。工作目录只放本步的**产物**;同一份过程文档只写一处。DO 与 CHECK 会给出实际目录,工作目录中的重复副本是落点错误。
16
-
17
- 需要人工决定的步骤列入顶层 manual_step;on_fail 通常指自身,只有前序成果确实失效才指向前序步骤。失败预算适合任务成本,不靠无限循环掩盖缺少验收依据。正文使用用户的语言。`;
@@ -1,45 +0,0 @@
1
- description: 单步对抗验证循环:需求与边界、实际可用性、回归影响三个视角全部通过才结束
2
-
3
- # 验证者模型可选("provider/model" 或 {providerID, modelID});不填沿用发起会话当前模型。
4
- # 验证超时不在 ralphflow 里设置:委派生命周期跟随宿主 dsh 的原生能力
5
- # (宿主自带的请求级空闲看门狗负责卡死保护)。
6
- # ← 与 opencode 版 loop.yaml 的差异(刻意,不上移):它在下面这个块里写 `timeout_ms`
7
- # (验证超时上限);本引擎已把 `timeout_ms` 从公开契约中删除 —— 写了只会得到加载期
8
- # 告警并忽略,所以这里不抄,超时仍归宿主原生看门狗。
9
- # adversarial_check:
10
- # model: deepseek/deepseek-chat
11
-
12
- steps:
13
- - id: loop
14
- desc: 迭代执行任务直到通过对抗验证
15
- # `reset: true` 与 opencode 一致 —— 它在这一步的注释原文是「单步轻量循环:失败重试频繁」。
16
- # 两种进入方式的行为(与 opencode 同构):
17
- # · **重试** → 返工走的是空闲窗口,**每轮都重置**(本步最多 100 轮)。这才是 loop 标 reset 的目的。
18
- # · **首步初次进入** → 结构上无法重置:首步 DO 是 `ralphflow_start` 工具的返回值,替换会落在
19
- # 工具调用内部(孤儿 tool/result,静默损坏会话)。opencode 的 start 路径同样不检查 reset。
20
- # 标了会在启动回执里如实说明,绝不假装做过。
21
- reset: true
22
- do: |
23
- 按用户要求完成任务,控制修改范围,避免引入无关改动。
24
- 交卷前自行核验完成情况;没有验证依据的事项如实标为未验证,不把计划当作完成。
25
-
26
- 每轮交卷前,把本轮摘要**追加**到 summary.md(一轮一节,保持精简):
27
- - 完成事项(逐条对照任务要求)
28
- - 变更文件
29
- - 验证结果
30
- - 未完成部分与下一步打算
31
-
32
- summary.md 是**过程文档**:按提示词「产出目录」一节落在本实例产出目录里,不要写进工作目录。
33
- input: 用户任务描述
34
- # 交付物只说**产出什么**:这里只列产物;过程文档(summary.md 累积器)的落点由提示词
35
- # 「产出目录」一节决定,不列进这里 —— 否则与紧邻的「产出目录」打架,诱导模型两边都写。
36
- output: 实现的代码/文件
37
- check_voting:
38
- # 三个互补视角:需求与边界、实际可用性、回归影响;减少重复取证。
39
- # 检查依据只写判定目标,不假定项目有测试套件或 git 基线。
40
- - check: 用户任务的每一条要求都已落实,没有遗漏,相关边界与异常情况已覆盖
41
- - check: 实现的行为和实际产出符合预期、真实可用,有可复核的验证依据
42
- - check: 修改不影响原有功能和既有约定,不引入需求以外的副作用
43
- on_pass: done
44
- on_fail: loop
45
- max_fail_count: 100
File without changes