Repository navigation
Commit d6483ea
feat(workflows): export a workflow as a runnable .claude/workflows/*.js (P4)
The other half of P4. `iris agents export` makes an agent forkable; this makes a
workflow runnable somewhere else. IRIS stays the system of record and Claude Code
becomes a runtime for it.
Steps become phases: each IRIS step emits `phase(name)` + `agent(prompt)` in `order`,
threading the previous step's result into the next. A stepless agentic workflow
becomes a single labelled `agent()` call from agent_prompt or description.
It is a TRANSLITERATION and the generated file says so in its own header rather than
letting someone find out in production. Named there, per workflow:
- allowed_tools — an IRIS step runs against an allowlist; a Claude Code agent()
gets whatever its harness gives it. The script cannot enforce the narrower set,
so it lists the tools the original was scoped to and says honouring them is on
the reader.
- require_human_approval — no counterpart. /workflows is ephemeral and session
scoped, which is precisely the gap §03 says to sell into.
- max_iterations — no equivalent ceiling.
- script_content — emitted as a COMMENT, never wrapped in agent(). Pretending a
shell payload is a prompt would produce a file that runs and does the wrong
thing, which is worse than one that obviously does nothing.
Verified by running it against real workflows: #196 (agentic, 3 steps) produces the
three phases with their prompts intact and flags 3 unenforceable tools; #195 (code
mode) comments its script and says so.
Both outputs parse. Note the check that matters: `node --check` on the whole file
FAILS, because Workflow scripts carry a top-level `return` and run inside an async
wrapper supplied by the harness — so the file is verified the way the runtime reads
it, meta as a module and body inside `(async () => { … })`. Checking it as a plain
ES module would have reported working output as broken.
Prompts are arbitrary text going into a template literal, so jsTemplate escapes
backslashes, backticks and ${ — a single stray backtick in a prompt would otherwise
close the literal and emit a file that looks right and does not parse. 13 tests,
including one that plants backticks and asserts the body still compiles.
Endpoint taken from `workflows pull` after the first guess 404'd — the same dead-path
class routes:check exists to catch.
Co-Authored-By: Claude Opus 5 <[email protected]>1 parent fd7c43b commit d6483ea
4 files changed
Lines changed: 273 additions & 4 deletions
File tree
- packages/opencode
- src/cli/cmd
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| |||
10173 | 10173 | | |
10174 | 10174 | | |
10175 | 10175 | | |
10176 | | - | |
| 10176 | + | |
10177 | 10177 | | |
10178 | 10178 | | |
10179 | 10179 | | |
| |||
10239 | 10239 | | |
10240 | 10240 | | |
10241 | 10241 | | |
| 10242 | + | |
| 10243 | + | |
| 10244 | + | |
| 10245 | + | |
| 10246 | + | |
| 10247 | + | |
| 10248 | + | |
| 10249 | + | |
10242 | 10250 | | |
10243 | 10251 | | |
10244 | 10252 | | |
| |||
10776 | 10784 | | |
10777 | 10785 | | |
10778 | 10786 | | |
10779 | | - | |
| 10787 | + | |
10780 | 10788 | | |
10781 | 10789 | | |
10782 | 10790 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments