You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Introduce agent-native execution contract and resilience features
- Added structured output for machine-readable execution results in JSON and JSONL formats.
- Implemented stable exit codes for various failure scenarios including parse, SSH config, runtime, and timeout failures.
- Introduced resilience controls with timeout and retry directives for block execution.
- Enabled named exports to propagate environment variables between blocks.
- Added safety controls including no-input mode and dry-run functionality.
- Created comprehensive BDD scenarios to validate new features and ensure backward compatibility.
- Developed detailed design documentation outlining the architecture and implementation plan.
@@ -18,6 +20,10 @@ ShellFlow is a minimal shell script orchestrator for mixed local and remote exec
18
20
- Run each block fail-fast, in order.
19
21
- Reuse the shared prelude before the first marker for every block.
20
22
- Pass the previous block output forward as `SHELLFLOW_LAST_OUTPUT`.
23
+
- Export named scalar values from a block into later block environments.
24
+
- Emit either a final JSON report or streaming JSON Lines events for agents.
25
+
- Support bounded `@TIMEOUT` and `@RETRY` directives without embedding workflow logic.
26
+
- Provide non-interactive, dry-run, and audit-log modes for automated execution.
21
27
- Resolve remote targets from `~/.ssh/config` or a custom SSH config path.
22
28
23
29
## Quick Start
@@ -80,6 +86,12 @@ Shellflow recognizes two markers:
80
86
-`# @LOCAL`
81
87
-`# @REMOTE <ssh-host>`
82
88
89
+
Shellflow also recognizes bounded block directives at the top of a block body:
90
+
91
+
-`# @TIMEOUT <seconds>`
92
+
-`# @RETRY <count>`
93
+
-`# @EXPORT NAME=stdout|stderr|output|exit_code`
94
+
83
95
`<ssh-host>` must match a `Host` entry in your SSH config. Shellflow then connects using that SSH host definition, which means the actual machine can be resolved through the configured `HostName`, `User`, `Port`, and `IdentityFile` values.
84
96
85
97
Example:
@@ -89,13 +101,15 @@ Example:
89
101
set -euo pipefail
90
102
91
103
# @LOCAL
104
+
# @EXPORT VERSION=stdout
92
105
echo"runs locally"
93
106
94
107
# @REMOTE sui
95
108
uname -a
96
109
97
110
# @LOCAL
98
111
echo"remote output: $SHELLFLOW_LAST_OUTPUT"
112
+
echo"version = $VERSION"
99
113
```
100
114
101
115
## SSH Configuration
@@ -141,6 +155,18 @@ echo "build-123"
141
155
echo"last output = $SHELLFLOW_LAST_OUTPUT"
142
156
```
143
157
158
+
Named exports are additive to `SHELLFLOW_LAST_OUTPUT`:
159
+
160
+
```bash
161
+
# @LOCAL
162
+
# @EXPORT VERSION=stdout
163
+
echo"2026.03.15"
164
+
165
+
# @REMOTE sui
166
+
echo"deploying $VERSION"
167
+
echo"last output = $SHELLFLOW_LAST_OUTPUT"
168
+
```
169
+
144
170
Lines before the first marker are treated as a shared prelude and prepended to every executable block:
145
171
146
172
```bash
@@ -154,11 +180,41 @@ echo "prelude is active"
154
180
echo"prelude is also active here"
155
181
```
156
182
183
+
## Agent-Native Usage
184
+
185
+
Shellflow is designed to be the execution substrate for an outer agent, not an embedded planner.
186
+
187
+
- Use `--json` when you want one final machine-readable run report.
188
+
- Use `--jsonl` when you want ordered event records while the script runs.
189
+
- Use `--no-input` for CI or agent runs where interactive prompts must fail deterministically.
190
+
- Use `--dry-run` to preview planned execution without running commands.
191
+
- Use `--audit-log <path>` to mirror the structured event stream into a redacted JSONL file.
192
+
193
+
Recommended agent flow:
194
+
195
+
1. Generate or select a plain shell script with `@LOCAL` and `@REMOTE` markers.
196
+
2. Add bounded directives only where needed: `@TIMEOUT`, `@RETRY`, and `@EXPORT`.
197
+
3. Run with `--json` or `--jsonl`.
198
+
4. Let the outer agent decide whether to retry, branch, or stop based on Shellflow's structured result.
199
+
200
+
Shellflow intentionally does not provide:
201
+
202
+
- Conditional directives such as `@IF stdout_contains=...`
203
+
- A workflow DSL or embedded ReAct loop
204
+
- Heuristic destructive-command detection
205
+
206
+
Those decisions belong in the outer agent or automation layer.
207
+
157
208
## CLI
158
209
159
210
```text
160
211
shellflow run <script>
161
212
shellflow run <script> --verbose
213
+
shellflow run <script> --json
214
+
shellflow run <script> --jsonl
215
+
shellflow run <script> --no-input
216
+
shellflow run <script> --dry-run
217
+
shellflow run <script> --audit-log ./audit.jsonl --jsonl
162
218
shellflow run <script> --ssh-config ./ssh_config
163
219
shellflow --version
164
220
```
@@ -168,6 +224,10 @@ Examples:
168
224
```bash
169
225
shellflow run playbooks/hello.sh
170
226
shellflow run playbooks/hello.sh -v
227
+
shellflow run playbooks/hello.sh --json
228
+
shellflow run playbooks/hello.sh --jsonl --no-input
229
+
shellflow run playbooks/hello.sh --dry-run --jsonl
230
+
shellflow run playbooks/hello.sh --audit-log ./audit.jsonl --jsonl
171
231
shellflow run playbooks/hello.sh --ssh-config ~/.ssh/config.work
0 commit comments