@lukstei/dsh-yaml-workflow 0.0.0-stage → 0.2.2-rc.5.4
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/LICENSE +21 -0
- package/README.md +452 -2
- package/cordis.patch.yml +4 -0
- package/dist/client.js +1746 -0
- package/dist/index.js +3495 -0
- package/examples/gate.yml +4 -0
- package/examples/parametrized-wf.yml +20 -0
- package/examples/wf.yml +3 -0
- package/package.json +114 -3
- package/src/boolean.ts +96 -0
- package/src/client/WorkflowCommandCard.tsx +217 -0
- package/src/client/WorkflowErrorCard.tsx +99 -0
- package/src/client/WorkflowMarkdown.tsx +28 -0
- package/src/client/WorkflowMarkdownResult.tsx +86 -0
- package/src/client/WorkflowPrintStep.tsx +46 -0
- package/src/client/WorkflowResumeButton.tsx +159 -0
- package/src/client/WorkflowStepRow.tsx +106 -0
- package/src/client/WorkflowStyles.tsx +10 -0
- package/src/client/actions.ts +113 -0
- package/src/client/context.ts +30 -0
- package/src/client/dsh.d.ts +33 -0
- package/src/client/icons.tsx +91 -0
- package/src/client/index.tsx +186 -0
- package/src/client/store.ts +655 -0
- package/src/client/styles.ts +340 -0
- package/src/effects.ts +696 -0
- package/src/fold.ts +201 -0
- package/src/index.ts +468 -0
- package/src/parser.ts +1146 -0
- package/src/requests.ts +85 -0
- package/src/rules.ts +647 -0
- package/src/runner.ts +1955 -0
- package/src/skill.ts +67 -0
- package/src/transitions.ts +357 -0
- package/src/types.ts +604 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lukas Steinbrecher
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,453 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lukstei/dsh-yaml-workflow
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Runs multi-step prompt workflows defined in YAML files. Users start them with `/wf`; each step is sent to the agent in order, with typed arguments, human review gates, zero-token `print` steps, and subagent steps with captured outputs. Agents can also author and validate workflows through a skill and tools.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Use this package](#use-this-package)
|
|
10
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
11
|
+
- [Further Exploration](#further-exploration)
|
|
12
|
+
- [Model Experience](#model-experience)
|
|
13
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
14
|
+
- [Dev Note](#dev-note)
|
|
15
|
+
|
|
16
|
+
-----
|
|
17
|
+
|
|
18
|
+
<a id="use-this-package"></a>
|
|
19
|
+
## Use this package
|
|
20
|
+
|
|
21
|
+
Mount in the agent's Cordis composition (also shipped as `cordis.patch.yml`):
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
- id: dsh-workflow-runner
|
|
25
|
+
name: '@lukstei/dsh-yaml-workflow'
|
|
26
|
+
config: {}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
No config fields. Required services (`inject`): `commands`, `sessionProjections`, `subagents`, `tools`, `skills`. The web client bundle (`./client`) renders the workflow card, step, print, error, and list nodes in the chat.
|
|
30
|
+
|
|
31
|
+
### Plugin dependencies
|
|
32
|
+
|
|
33
|
+
Server-side and client-side entries.
|
|
34
|
+
|
|
35
|
+
**Server-side** (`inject`: `commands`, `sessionProjections`, `subagents`, `tools`, `skills`):
|
|
36
|
+
|
|
37
|
+
| Plugin / service | Required? | Provided by | Effect without it |
|
|
38
|
+
|---|---|---|---|
|
|
39
|
+
| `commands` | Required | @deepseek-ai/dsh-commands | Plugin stays pending; never applies. No `/wf*` commands. |
|
|
40
|
+
| `sessionProjections` | Required | @deepseek-ai/dsh-session-projection | Plugin stays pending; never applies. |
|
|
41
|
+
| `subagents` | Required | @deepseek-ai/dsh-subagent | Plugin stays pending; never applies. |
|
|
42
|
+
| `tools`, `skills` | Required | @deepseek-ai/dsh-tools, @deepseek-ai/dsh-skill | Plugin stays pending; never applies. |
|
|
43
|
+
| `agentPresets` | Optional | @deepseek-ai/dsh-agent-preset-registry | `ctx.get('agentPresets')` at validation. Absent: any step with `preset` fails validation (`'agentPresets' service is unavailable`). Steps without `preset` are unaffected. |
|
|
44
|
+
| `llm` | Optional | @deepseek-ai/dsh-llm | `ctx.get('llm')` at validation. Absent: steps setting `llmProvider`/`model`/`thinking` fail validation (`'llm' service is unavailable`); other steps unaffected. |
|
|
45
|
+
|
|
46
|
+
**Client-side** (`inject`: `slots`, `conversation`, `uiConversation`, `sessions`):
|
|
47
|
+
|
|
48
|
+
| Plugin / service | Required? | Provided by | Effect without it |
|
|
49
|
+
|---|---|---|---|
|
|
50
|
+
| `slots`, `conversation`, `uiConversation` | Required | @deepseek-ai/dsh-client-ui-slots, @deepseek-ai/dsh-client-ui-conversation (also `-chat` in `dsh.client.inject`) | Plugin stays pending; never applies. No run cards. |
|
|
51
|
+
| `sessions` | Required | @deepseek-ai/dsh-api-session-controller | Plugin stays pending; never applies. |
|
|
52
|
+
|
|
53
|
+
Used by: nothing.
|
|
54
|
+
|
|
55
|
+
### Commands
|
|
56
|
+
|
|
57
|
+
| Command | Purpose |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `/wf <workflow.yaml> [key=value ...] [instructions]` | Run a workflow. |
|
|
60
|
+
| `/wf-resume [instructions]` | Resume a paused or interrupted workflow. |
|
|
61
|
+
| `/wf-abort` | Discard the active or paused workflow. |
|
|
62
|
+
| `/wf-list` | List workflows in project and user directories. |
|
|
63
|
+
| `/wf-validate <workflow.yaml> [key=value ...] [instructions]` | Validate without running. |
|
|
64
|
+
|
|
65
|
+
#### `/wf`
|
|
66
|
+
|
|
67
|
+
- **Path resolution**, first match wins: path relative to the session working directory (or absolute), `.agents/wf/<target>` in the session working directory, `~/.agents/wf/<target>`. `.yaml` and `.yml` are tried when the extension is omitted.
|
|
68
|
+
- **Arguments:** `key=value`, quoted when the value has whitespace (`env=production tag="v1.0.0"`).
|
|
69
|
+
- **Trailing text** after the path and arguments maps to the `instructions` argument. If the workflow declares no `instructions` argument, trailing text is an argument error.
|
|
70
|
+
- **Validation up front:** file existence, YAML syntax, required arguments, choice options, and template coverage are checked before the command is accepted, including while another workflow runs. Invalid requests return an error immediately.
|
|
71
|
+
- **Queueing:** an accepted command returns "Workflow queued" and records a request in the session. Requests run FIFO by command arrival, after the active workflow completes or is discarded and finishes cleanup. A paused workflow holds the queue. With no active workflow, execution waits for the agent to be idle. Chat shows "Workflow queued" with the submitted command until the request starts or fails, including in restored history.
|
|
72
|
+
- **Queued file changes:** a pending request keeps the invocation, not the YAML or resolved defaults. The file is reloaded and validated when the request starts, so edits made while waiting apply. A missing or invalid file produces an error notification and the next request proceeds.
|
|
73
|
+
- **Session title:** the workflow `title` (or `name` when no `title`) sets the session title if unset. `{{args.*}}` is supported.
|
|
74
|
+
- **Copy:** the workflow card copies the original invocation without inserted defaults or derived arguments. Copy is disabled for historical runs whose input was not recorded.
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
/wf deploy
|
|
78
|
+
/wf ./workflows/deploy.yaml environment=staging version="2.4.1"
|
|
79
|
+
/wf ./workflows/build.yaml target=release Run extra lint checks before building
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
#### `/wf-resume`
|
|
83
|
+
|
|
84
|
+
- Rebuilds the workflow document, invocation arguments, and step index from session events.
|
|
85
|
+
- After an interruption, the resumed step gets a `<workflow-resume>` notice telling the agent to inspect existing state and not redo completed work. Resuming from a review gate does not add it.
|
|
86
|
+
- Optional trailing instructions are passed to the resumed step.
|
|
87
|
+
- If a prompt is in progress, resumption waits until the agent is idle.
|
|
88
|
+
- Returns "Workflow resume accepted" and the workflow continues; follow it in the workflow card. Cancelling the submitting request after acceptance does not cancel the workflow. Use Stop to pause or `/wf-abort` to discard.
|
|
89
|
+
- Resume button: enter instructions in the prompt and click Resume. The prompt clears when the host admits the command. A rejected dispatch keeps the draft.
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
/wf-resume
|
|
93
|
+
/wf-resume Re-run tests with verbose flags enabled
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### `/wf-abort`
|
|
97
|
+
|
|
98
|
+
Marks the workflow `aborted` in the session event log, appends a discarded `wf-step` notice to the chat, shows the discarded status on the command card, and removes the Resume and Discard buttons from the composer toolbar.
|
|
99
|
+
|
|
100
|
+
#### `/wf-list`
|
|
101
|
+
|
|
102
|
+
Scans `.agents/wf` and `~/.agents/wf` for `.yaml` and `.yml` files, parses each, and lists name, description, and parameters (names and descriptions) for valid ones. Files with invalid YAML or schema errors are skipped. Output is a Markdown command view, expanded by default, and works in a fresh session before any model turn, including after reload.
|
|
103
|
+
|
|
104
|
+
#### `/wf-validate`
|
|
105
|
+
|
|
106
|
+
Checks syntax, step schema, output wiring, and template bindings. It emits no session events, does not change the title, and does not need an idle runner.
|
|
107
|
+
|
|
108
|
+
- **Static check** (no arguments): YAML syntax, schema, output wiring, unused outputs, subagent restrictions, and that every `{{args.<name>}}` matches a declared argument.
|
|
109
|
+
- **Invocation check** (with arguments): static checks plus explicit values, required arguments, choice options, and interpolation.
|
|
110
|
+
- On success it prints a summary of steps, outputs, and parameters. On failure it prints the exact error, rendered as a code block to keep indentation.
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
/wf-validate deploy
|
|
114
|
+
/wf-validate ./workflows/deploy.yaml environment=staging version="2.4.1"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Agent skill and tools
|
|
118
|
+
|
|
119
|
+
| Name | Purpose |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `yaml-workflow` skill | Registered in the skills catalog. Describes commands, tools, and a workflow file schema. |
|
|
122
|
+
| `wf_validate` | Same checks as `/wf-validate`. Params: `target` (required), `args` (optional string of `key=value` pairs or trailing instructions). Returns `{ success, message }`. |
|
|
123
|
+
| `save_output` | Records a declared `string` or `list` output for the running step. Params: `name`, `value` (both required strings; `list` values must be a JSON array string within `min`/`max`). Returns `{ success, message }`. |
|
|
124
|
+
|
|
125
|
+
`save_output` is only visible while a workflow is `running`. `wf_validate` is visible once a workflow has started in the session or the skill was invoked.
|
|
126
|
+
|
|
127
|
+
### Workflow file
|
|
128
|
+
|
|
129
|
+
Files are YAML (`.yaml` or `.yml`). Unknown top-level keys are rejected.
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
name: "Workflow Name" # Optional
|
|
133
|
+
title: "Workflow Title" # Optional. Session title if unset; supports {{args.*}}
|
|
134
|
+
description: "Workflow goal" # Optional
|
|
135
|
+
args: # Optional
|
|
136
|
+
<arg_name>: <ArgDefinition>
|
|
137
|
+
steps: # Required, non-empty
|
|
138
|
+
- <StepDefinition>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Arguments
|
|
142
|
+
|
|
143
|
+
Arguments validate `/wf` input and feed `{{args.<name>}}`.
|
|
144
|
+
|
|
145
|
+
```yaml
|
|
146
|
+
args:
|
|
147
|
+
version:
|
|
148
|
+
type: string # string | choice | bool
|
|
149
|
+
description: "Semantic version tag"
|
|
150
|
+
default: "1.0.0"
|
|
151
|
+
required: true
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- `string`: free text, optional `default` and `required`.
|
|
155
|
+
- `choice`: `choices` list (non-empty strings), `default` must be one of them. Optional `mapping` or `mappings` (not both).
|
|
156
|
+
- `bool`: `true` or `false`; the default may be a boolean or the string `true`/`false`.
|
|
157
|
+
- An argument named `instructions` receives the unflagged trailing text of `/wf`.
|
|
158
|
+
|
|
159
|
+
Choice `mappings` (flat) replaces the value with an expanded one:
|
|
160
|
+
|
|
161
|
+
```yaml
|
|
162
|
+
args:
|
|
163
|
+
effort:
|
|
164
|
+
type: choice
|
|
165
|
+
choices: [low, high]
|
|
166
|
+
default: high
|
|
167
|
+
mappings:
|
|
168
|
+
low: "acp-codex-acp/gpt-6-luna:xhigh"
|
|
169
|
+
high: "acp-codex-acp/gpt-6.1-sol:medium"
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`{{args.effort}}` resolves to `acp-codex-acp/gpt-6.1-sol:medium` when `effort` is `high`.
|
|
173
|
+
|
|
174
|
+
Choice `mapping` (nested) derives extra arguments and keeps the original choice:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
args:
|
|
178
|
+
environment:
|
|
179
|
+
type: choice
|
|
180
|
+
choices: [staging, production]
|
|
181
|
+
default: staging
|
|
182
|
+
mapping:
|
|
183
|
+
cluster_url:
|
|
184
|
+
staging: "https://staging.internal"
|
|
185
|
+
production: "https://prod.internal"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`{{args.cluster_url}}` becomes available to later prompts, conditions, and titles. Derived keys are checked exhaustively at parse time and cannot be overridden on the command line.
|
|
189
|
+
|
|
190
|
+
#### Steps
|
|
191
|
+
|
|
192
|
+
Step forms:
|
|
193
|
+
|
|
194
|
+
```yaml
|
|
195
|
+
steps:
|
|
196
|
+
- "Run the test suite" # bare string: prompt step
|
|
197
|
+
- name: "Migrate" # prompt step
|
|
198
|
+
prompt: "Run migrations for {{args.environment}}."
|
|
199
|
+
gate: "Check the migration logs." # optional review gate
|
|
200
|
+
- print: "Done: {{outputs.summary}}" # print step, no model call
|
|
201
|
+
- gate: "Check the coverage report" # gate-only: gate text is also the prompt
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
- **Prompt step** (`prompt`, also accepts `kind: prompt`): sends the prompt and waits for the agent to be idle.
|
|
205
|
+
- **Print step** (`print:`, or `kind: print` with `text:`): writes a message to the session without model inference.
|
|
206
|
+
- **Gate-only step** (`gate` without `prompt`): the gate string (or the step name when `gate: true`) is used as the prompt.
|
|
207
|
+
- `name` is optional and defaults to `Step N` (1-based).
|
|
208
|
+
- `if` skips the step when false. Forms: `"{{args.flag}}"`, `"!{{args.flag}}"`, `'{{args.mode}} == "review"'`, `'{{args.mode}} != "smell"'`. A bare value is true only when it equals `true`.
|
|
209
|
+
- `gate` is a boolean or string. After the step completes, the run pauses until `/wf-resume` or the Resume button. `false`, empty, or a template resolving to `"false"` means no pause; `true` pauses with the step name; a template can inject a flag, e.g. `gate: "{{args.wait}}"`.
|
|
210
|
+
- `subagent`, `output`, `outputs`, `foreach`: see the details below.
|
|
211
|
+
|
|
212
|
+
Templates `{{args.<name>}}` and `{{outputs.<name>}}` are interpolated in the workflow `name` and `title`, step `name`, `prompt`, `gate`, `print`/`text`, `if`, `subagent`, and `foreach`. `{{item}}` is available inside `foreach` subagent steps. An unresolved `{{args.*}}` fails validation before any step runs.
|
|
213
|
+
|
|
214
|
+
#### Examples
|
|
215
|
+
|
|
216
|
+
Sequential prompt and print:
|
|
217
|
+
|
|
218
|
+
```yaml
|
|
219
|
+
name: "Code Audit"
|
|
220
|
+
steps:
|
|
221
|
+
- print: "Starting linting and static analysis..."
|
|
222
|
+
- name: "Lint Check"
|
|
223
|
+
prompt: "Run biome check on all source files and fix any formatting violations."
|
|
224
|
+
- name: "Type Check"
|
|
225
|
+
prompt: "Run tsc --noEmit and report any type errors."
|
|
226
|
+
- print: "Audit complete."
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Parametrized deployment:
|
|
230
|
+
|
|
231
|
+
```yaml
|
|
232
|
+
name: "Deploy to {{args.environment}}"
|
|
233
|
+
args:
|
|
234
|
+
environment:
|
|
235
|
+
type: choice
|
|
236
|
+
choices: [staging, production]
|
|
237
|
+
default: staging
|
|
238
|
+
description: "Target deployment tier"
|
|
239
|
+
version:
|
|
240
|
+
type: string
|
|
241
|
+
description: "Version string to publish"
|
|
242
|
+
instructions:
|
|
243
|
+
type: string
|
|
244
|
+
description: "Additional operational notes"
|
|
245
|
+
default: "Follow standard release protocols"
|
|
246
|
+
steps:
|
|
247
|
+
- name: "Notify Release"
|
|
248
|
+
print: "Deploying version {{args.version}} to {{args.environment}}"
|
|
249
|
+
- name: "Execute Deployment"
|
|
250
|
+
prompt: "Deploy version {{args.version}} to {{args.environment}}. Notes: {{args.instructions}}"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Review gate:
|
|
254
|
+
|
|
255
|
+
```yaml
|
|
256
|
+
name: "Production Release with Gate"
|
|
257
|
+
steps:
|
|
258
|
+
- name: "Run Database Migrations"
|
|
259
|
+
prompt: "Run pending database schema migrations."
|
|
260
|
+
gate: "Check database migration logs in PostgreSQL console before proceeding."
|
|
261
|
+
- name: "Deploy Service"
|
|
262
|
+
prompt: "Switch traffic router to the newly deployed container instance."
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Subagent delegation:
|
|
266
|
+
|
|
267
|
+
```yaml
|
|
268
|
+
name: "Parallel Architecture Review"
|
|
269
|
+
steps:
|
|
270
|
+
- name: "Review Security"
|
|
271
|
+
prompt: "Review authentication boundaries in src/auth for potential token leakage."
|
|
272
|
+
subagent: "@security-auditor/deepseek-coder"
|
|
273
|
+
output: security_findings
|
|
274
|
+
- name: "Synthesize Findings"
|
|
275
|
+
prompt: "Summarize findings: {{outputs.security_findings}} and propose actionable fixes."
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
More: [examples/](https://github.com/lukstei/dsh-plugins/tree/master/packages/dsh-yaml-workflow/examples).
|
|
279
|
+
|
|
280
|
+
#### Run states
|
|
281
|
+
|
|
282
|
+
The client card shows the state recorded in the session log:
|
|
283
|
+
|
|
284
|
+
- `running`: a step is executing.
|
|
285
|
+
- `paused`: stopped at a `gate`, or interrupted. Continue with `/wf-resume` or the Resume button.
|
|
286
|
+
- `completed`: all steps finished.
|
|
287
|
+
- `aborted`: discarded with `/wf-abort` or the Discard button, or cancelled by signal.
|
|
288
|
+
|
|
289
|
+
-----
|
|
290
|
+
|
|
291
|
+
<a id="understand-the-implementation"></a>
|
|
292
|
+
## Understand the implementation
|
|
293
|
+
|
|
294
|
+
<details>
|
|
295
|
+
<summary>Implementation internals — click to expand</summary>
|
|
296
|
+
|
|
297
|
+
### Architecture
|
|
298
|
+
|
|
299
|
+
Functional core, imperative shell. Pure modules (`types.ts`, `parser.ts`, `boolean.ts`, `rules.ts`, `transitions.ts`, `fold.ts`, `requests.ts`) take inputs and return state plus declarative effects. `runner.ts` and `effects.ts` interpret effects against the agent, subagents, session, and filesystem.
|
|
300
|
+
|
|
301
|
+
| File | Role |
|
|
302
|
+
|---|---|
|
|
303
|
+
| `src/index.ts` | Plugin entry: projection `workflow`, skill, tools, five commands, `session/event` listener that starts pending workflows on `command/done`. |
|
|
304
|
+
| `src/runner.ts` | Request, validation, execution, resume, abort, list. |
|
|
305
|
+
| `src/effects.ts` | `DshWorkflowEffectContext`: workflow lookup, file reads, scratch dir, event append. |
|
|
306
|
+
| `src/transitions.ts` | Pure step transitions, pause/abort, state folding, projection. |
|
|
307
|
+
| `src/parser.ts` | YAML parsing, preprocessing, argument resolution, prompt formatting, list/summary formatting. |
|
|
308
|
+
| `src/rules.ts` | Static validation rules. |
|
|
309
|
+
| `src/requests.ts` | Selects the next pending workflow request from command history. |
|
|
310
|
+
| `src/client/` | Web client (store, cards, slots). |
|
|
311
|
+
|
|
312
|
+
### Persisted state
|
|
313
|
+
|
|
314
|
+
Workflow progress is stored as `command/run` + `command/done` pairs named `wf-event` (`WORKFLOW_EVENT_NAME`). The immutable workflow document and invocation are written once in an `init` event; later events carry only step index, status, gate, outputs, and errors. Title changes use `session/title`. The session projection `workflow` (state version 1) holds `status` (`idle`, `running`, `paused`, `aborted`, `completed`), `runId`, `stepIndex`, `skillInvoked`. Resume reconstructs everything from events.
|
|
315
|
+
|
|
316
|
+
### Validation rules
|
|
317
|
+
|
|
318
|
+
Run by `/wf`, `/wf-validate`, `wf_validate`, and when a queued request starts:
|
|
319
|
+
|
|
320
|
+
- Output names are globally unique, referenced outputs exist and are not forward references, and every declared output is referenced at least once in the workflow. Unused outputs fail static validation.
|
|
321
|
+
- Workflow `name`/`title` cannot reference outputs.
|
|
322
|
+
- `{{args.*}}` placeholders resolve to declared or derived arguments.
|
|
323
|
+
- Subagent steps must declare at least one output, cannot declare `list` outputs, and cannot reference outputs of earlier subagent steps (they run concurrently).
|
|
324
|
+
- `foreach` must reference a declared `list` output.
|
|
325
|
+
- Choice mappings are exhaustive, reference valid choices, and do not collide.
|
|
326
|
+
- A step cannot declare both `output` and `outputs`; `output` and `foreach` are subagent-only.
|
|
327
|
+
|
|
328
|
+
### Outputs
|
|
329
|
+
|
|
330
|
+
- **`output: <name>`** (subagent steps only): the subagent's last message is captured into `{{outputs.<name>}}`. No schema is enforced. Non-subagent prompt steps keep their context in the conversation and cannot use it.
|
|
331
|
+
- **`outputs:`** typed outputs, `string`, `list`, or `file`:
|
|
332
|
+
- `string`: filled by the `save_output` tool (or the subagent's structured result).
|
|
333
|
+
- `list`: array of strings, validated at write time (valid JSON array, strings only). Optional `min` and `max` (`min <= max`). Not allowed on subagent steps.
|
|
334
|
+
- `file`: `path` plus optional `base` (`scratch` default, or `workspace`). `scratch` resolves to `<cwd>/.agents/scratch/<sessionId>/<path>` (the scratch dir is created with a `.gitignore` of `*`); `workspace` resolves against the session working directory. The step prompt tells the agent the resolved path. The file must exist and be non-empty; other filesystem errors (for example permissions) stop the run with the original diagnostic.
|
|
335
|
+
- Output verification retries the step up to 3 times (`Output Retry n/3`), then fails.
|
|
336
|
+
- A `list` output interpolated outside `foreach` renders as a Markdown bullet list (`- a\n- b`), empty string when empty.
|
|
337
|
+
- A step cannot declare both `output` and `outputs`.
|
|
338
|
+
|
|
339
|
+
### Subagent steps
|
|
340
|
+
|
|
341
|
+
`subagent` is `true`, a shorthand string, or an object.
|
|
342
|
+
|
|
343
|
+
- `true`: default subagent using the parent's provider, model, reasoning effort, and max tokens.
|
|
344
|
+
- Shorthand: `[@preset/][llmProvider/]model[:thinking] | :thinking | inherit[:thinking]`:
|
|
345
|
+
- `deepseek-reasoner`, `deepseek-reasoner:high`, `:high`
|
|
346
|
+
- `inherit`, `inherit:high` (same provider, model, effort, and max tokens as the parent)
|
|
347
|
+
- `acp-codex-acp/gpt-6.1-sol`, `acp-codex-acp/gpt-6.1-sol:medium`
|
|
348
|
+
- `@reviewer/deepseek-reasoner`, `@reviewer/deepseek-reasoner:high`, `@reviewer/acp-codex-acp/gpt-6.1-sol:medium`
|
|
349
|
+
- templated: `"{{args.effort}}"`, `"@reviewer/{{args.model}}:{{args.thinking}}"`
|
|
350
|
+
- Object: `{ provider?, llmProvider?, preset?, model?, thinking? }`. `model: inherit` (or a template resolving to it) equals the `inherit` shorthand. Omitting `model` inherits the parent's provider and model. `inherit` is reserved and cannot name a model.
|
|
351
|
+
- Subagents run autonomously. Their output is not injected into later prompt steps unless referenced with `{{outputs.<name>}}`.
|
|
352
|
+
|
|
353
|
+
#### `foreach`
|
|
354
|
+
|
|
355
|
+
`foreach: "{{outputs.<list_name>}}"` runs one subagent per list item, concurrently in one wave. Rejected on non-subagent steps and non-list targets. Inside the prompt, `{{item}}` is the current item. Foreach subagent steps only support `string` outputs.
|
|
356
|
+
|
|
357
|
+
- With `output: <name>`, all subagent results are lifted into a list of strings.
|
|
358
|
+
- With `outputs: { ... }`, each declared property is lifted into a list of strings.
|
|
359
|
+
- An empty input list skips subagent execution and records `[]`.
|
|
360
|
+
|
|
361
|
+
```yaml
|
|
362
|
+
- name: "Discover Microservices"
|
|
363
|
+
prompt: "Find candidate services to review"
|
|
364
|
+
outputs:
|
|
365
|
+
services:
|
|
366
|
+
type: list
|
|
367
|
+
min: 1
|
|
368
|
+
max: 5
|
|
369
|
+
description: "List of service directories"
|
|
370
|
+
- name: "Inspect Services"
|
|
371
|
+
subagent: true
|
|
372
|
+
foreach: "{{outputs.services}}"
|
|
373
|
+
prompt: "Inspect service {{item}} and provide a status summary"
|
|
374
|
+
output: service_summaries
|
|
375
|
+
- name: "Report"
|
|
376
|
+
print: "{{outputs.service_summaries}}"
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### Trust boundaries
|
|
380
|
+
|
|
381
|
+
Workflow files, arguments, and model output (via `save_output`) are untrusted input: they are schema-validated at the boundary (zod) before reaching the pure core. Workflow lookup reads only the three locations above.
|
|
382
|
+
|
|
383
|
+
</details>
|
|
384
|
+
|
|
385
|
+
-----
|
|
386
|
+
|
|
387
|
+
<a id="further-exploration"></a>
|
|
388
|
+
## Further Exploration
|
|
389
|
+
|
|
390
|
+
- Upstream: [DSH module graph](https://github.com/deepseek-ai/deepseek-harness/blob/master/docs/module-graph.md).
|
|
391
|
+
- Sibling: [@lukstei/dsh-schedule-script](https://github.com/lukstei/dsh-plugins/blob/master/packages/dsh-schedule-script/README.md)
|
|
392
|
+
|
|
393
|
+
<a id="model-experience"></a>
|
|
394
|
+
## Model Experience
|
|
395
|
+
|
|
396
|
+
### Step prompt
|
|
397
|
+
|
|
398
|
+
#### What the model sees
|
|
399
|
+
|
|
400
|
+
Each prompt step is sent as one message: a `[STEP n OF m: <name>]` header, a `<workflow-info>` block (workflow name, step number), optional `<workflow-resume>`, optional `<user-instructions>`, optional `<output-requirements>`, `<step-instructions>` with the interpolated prompt, and `<rules>` (do only this step, conclude when done, do not anticipate later steps). Output requirements name each output and how to produce it: file path to write, or `save_output` with `name` and value (JSON array string for lists). Failed output verification sends a retry prompt, up to 3 times. `print` steps are not sent to the model.
|
|
401
|
+
|
|
402
|
+
#### Token effect
|
|
403
|
+
|
|
404
|
+
One message per prompt step, plus up to 3 retry messages per step when outputs are missing. Print steps and gates cost nothing.
|
|
405
|
+
|
|
406
|
+
#### KV Cache effect
|
|
407
|
+
|
|
408
|
+
Messages are appended; earlier history is not rewritten.
|
|
409
|
+
|
|
410
|
+
### yaml-workflow skill
|
|
411
|
+
|
|
412
|
+
#### What the model sees
|
|
413
|
+
|
|
414
|
+
A catalog entry (`yaml-workflow`: "Author, validate, and execute declarative multi-step YAML prompt workflows in DSH."). The body is returned only when the model loads the skill.
|
|
415
|
+
|
|
416
|
+
#### Token effect
|
|
417
|
+
|
|
418
|
+
Catalog entry always; body on load.
|
|
419
|
+
|
|
420
|
+
#### KV Cache effect
|
|
421
|
+
|
|
422
|
+
Static catalog entry; the body extends the conversation.
|
|
423
|
+
|
|
424
|
+
### wf_validate, save_output
|
|
425
|
+
|
|
426
|
+
#### What the model sees
|
|
427
|
+
|
|
428
|
+
Two tools with `{ success, message }` results. `save_output` appears only while a workflow is `running`; `wf_validate` once a workflow has started or the skill was loaded.
|
|
429
|
+
|
|
430
|
+
#### Token effect
|
|
431
|
+
|
|
432
|
+
One schema per visible tool; one short result per call.
|
|
433
|
+
|
|
434
|
+
#### KV Cache effect
|
|
435
|
+
|
|
436
|
+
The tool list changes when a workflow starts or ends and when the skill is loaded, which invalidates the cached prefix at those points.
|
|
437
|
+
|
|
438
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
439
|
+
## Known Limitations and Deferred Work
|
|
440
|
+
|
|
441
|
+
- Input and output file checks as declared step fields are not implemented. File outputs exist (`outputs` with `type: file`), but there is no prerequisite-file check before a step.
|
|
442
|
+
- Subagent steps cannot use `list` outputs or depend on other subagent steps' outputs.
|
|
443
|
+
|
|
444
|
+
<a id="dev-note"></a>
|
|
445
|
+
### Dev Note
|
|
446
|
+
|
|
447
|
+
<details>
|
|
448
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
449
|
+
|
|
450
|
+
- `pnpm run verify` runs check, build, typecheck, unit tests, and e2e tests (`test:e2e`, fixtures under `src/e2e/fixtures/`).
|
|
451
|
+
- This README must be updated when commands or schema change.
|
|
452
|
+
|
|
453
|
+
</details>
|
package/cordis.patch.yml
ADDED