README.md
# Workflow Automation (AgentRove native agent)
`agentrove.workflow-automation` 0.1.2 · MIT · Node.js >= 20 · no npm dependencies · no network
Published by AgentRove (provisional, configurable name). Package identifiers keep the agentrove prefix for compatibility.
Runs small, repeatable automation **recipes** on the files in one folder (the workspace): read CSV,
JSON, Markdown or text files, filter, sort, de-duplicate, summarise and join the rows, turn them into
text with templates, then write, append, move or copy files. Recipes are JSON lists of built-in
steps. There is **no shell, script, network, download, delete or code step**, and nothing in a
recipe or in your files is ever executed.
Every run is a two-stage process: `plan_recipe` (a dry run that writes nothing and shows exactly
which files would change, with a diff) and `run_recipe` (applies that plan only with
`"confirm": true`, ideally pinned to the reviewed `plan_hash`).
## Tools
| Tool | Side effects | What it does |
| --- | --- | --- |
| `validate_recipe` | none | Checks a recipe without reading any file: step types and properties, step references, paths, templates, globs, conditions, limits. Returns `valid`, every error with its location (`steps[3] (paid).where[0].op`), warnings, and what each step reads and writes. |
| `plan_recipe` | none (reads files in the workspace) | Dry run: reads the inputs, runs every step in memory and returns the planned operations (create folder, create / overwrite / append file, move, copy; plus skips, unchanged files and conflicts), a text `diff` with line diffs for overwrites, previews of each step's output, warnings, a Markdown `report` and a `plan_hash`. |
| `run_recipe` | **writes local files** (confirmation required) | Applies the plan. Refuses to start while the plan has conflicts or when `expected_plan_hash` no longer matches; re-checks each operation just before it runs; stops at the first failure and lists what was already done. |
## Recipe format
```json
{
"name": "Monthly sales by region",
"timezone": "America/Toronto",
"vars": { "month": "2026-11" },
"steps": [
{ "id": "orders", "type": "read_csv", "path": "data/orders-{{vars.month}}.csv" },
{ "id": "unique", "type": "dedupe", "by": ["order_id"] },
{ "id": "paid", "type": "filter", "where": [{ "field": "status", "op": "eq", "value": "paid" }] },
{ "id": "by_region", "type": "summarize", "group_by": ["region"],
"metrics": [{ "op": "count", "as": "orders" }, { "op": "sum", "field": "amount", "as": "revenue" }] },
{ "id": "ranked", "type": "sort", "by": "-revenue" },
{ "id": "report", "type": "template", "escape": "markdown",
"template": "# Sales {{vars.month}}\n{{#rows}}\n- {{region}}: {{orders}} orders, {{revenue | fixed:2}}\n{{/rows}}\n" },
{ "id": "save", "type": "write_file", "from": "report", "path": "reports/sales-{{vars.month}}.md", "if_exists": "overwrite" }
]
}
```
- Steps run in order. A step reads the output of an earlier step through `from` (default: the step
just before it). Step ids are lowercase letters, digits and `_`.
- `vars` are defaults; the tool input `vars` overrides them. `run.date`, `run.time` and
`run.timestamp` give the run time (`run.date` in the recipe's `timezone`, default UTC).
- All reading happens before anything is written: a step never sees files written, moved or copied
by an earlier step of the same recipe (that is refused with a clear error; use `from` instead).
- Limits (`limits` in the recipe may lower or raise them up to the hard limit): 10 MB per file read
or written, 50 MB read in total, 100,000 rows per step, 5,000 listed files (hard 10,000), 500 file
operations (hard 1,000), 20 MB written (hard 50 MB), 2 million characters per template output (hard
5 million), 30 s run time (hard 120 s). At most 50 steps; recipe JSON at most 512 KB.
### Step types
| Group | Type | Properties |
| --- | --- | --- |
| Source | `read_csv` | `path` or `glob` (each matching file, with a `_file` column), `delimiter` (`auto`, `,`, `;`, `tab`, `\|`), `header` (default true). Quoted fields, line breaks in quotes, BOM handled; values are text. |
| Source | `read_json` | `path` or `glob`, `pointer` (JSON pointer such as `/items`). |
| Source | `read_markdown` | `path` or `glob`. One row per file: `path`, `name`, `stem`, `folder`, `title` (front matter, first heading or file name), `front_matter`, `tags`, `headings`, `tasks` (`text`, `done`, `line`, `section`), `open_tasks`, `word_count`, `text`, `modified`. |
| Source | `read_text` | `path`. |
| Source | `list_files` | `folder` (default the workspace), `pattern` (default `*`; `**/` for subfolders; `{a,b}` alternatives; case-insensitive), `include_folders`. Rows: `path`, `name`, `stem`, `ext` (lowercase), `folder`, `kind`, `size`, `modified`. |
| Source | `read_input` | `format`: `text`, `csv`, `json` or `markdown`; reads the tool call's `input_text` (for example another agent's output). |
| Source | `literal` | `value`: fixed JSON in the recipe (a list of objects is a table). |
| Transform | `filter` | `where`: conditions `{field, op, value, type?, ignore_case?}` with `eq ne gt gte lt lte contains not_contains starts_with ends_with in not_in empty not_empty like not_like` (`like`: `*` and `?` wildcards); `match`: `all` (default) or `any`. Numbers and dates compare as numbers and dates; values may use `{{vars.x}}`. Dotted fields reach into objects (`task.done`). |
| Transform | `map` | `rename`, `set` (field: template, per row), `cast` (`number`, `integer`, `string`, `boolean`, `date`), `pick`, `omit`, applied in that order. |
| Transform | `sort` | `by`: `"field"`, `"-field"` (descending) or `[{field, order, type}]`. Stable; empty values last. |
| Transform | `dedupe` | `by` (default: whole row), `keep` (`first`/`last`), `ignore_case`. |
| Transform | `limit` | `count`, `offset`. |
| Transform | `summarize` | `group_by`, `metrics`: `count`, `count_distinct`, `sum`, `avg`, `min`, `max`, `first`, `last`, `values` (`as` names the column). Non-numeric values are left out of sums and averages and counted in a warning. |
| Transform | `join` | `with` (another step), `on` or `left_on` + `right_on`, `how` (`left`/`inner`), `fields`, `prefix`, `ignore_case`. First match wins. |
| Transform | `concat` | `from`: two or more step ids. |
| Transform | `unnest` | `field` (a list), `as`, `keep_empty`: one row per item. |
| Format | `template` | `template`, `escape` (`html` default, `markdown`, `none`). Context: `rows` and `count` (rows input), `text`, `data`, plus `vars`, `run`, `steps.<id>`. |
| Format | `to_csv` | `columns`, `delimiter`, `header`, `protect_formulas` (default true: cells starting with `= + - @` get a `'` prefix, plain numbers excepted). |
| Format | `to_json` / `to_markdown_table` | `pretty` / `columns`, `headers`. Markdown cells are escaped. |
| File | `write_file` | `path` (template), `from` (a text step) or `content` (template), `for_each` (one file per row), `if_exists`: `error` (default), `skip`, `overwrite`, `append`, `suffix` (`name-2.md`), `create_folders` (default true), `escape`. |
| File | `move_files` / `copy_files` | Rows with a `path` field (e.g. from `list_files`; `path_field` to change), `to` (template per row), `if_exists`: `error` (default), `skip`, `suffix`, `create_folders`. Never replaces an existing file. Output rows list what was planned, so a later template can log the moves. |
### Templates
Mustache-like: `{{name}}` (escaped), `{{{name}}}` or `{{& name}}` (not escaped), dotted names,
`{{#list}}...{{/list}}` (repeat per item; once for a non-empty value), `{{^list}}...{{/list}}`
(when empty), `{{! comment}}`, `{{.}}`, and inside sections `{{@index}}`, `{{@number}}`,
`{{@first}}`, `{{@last}}`. Section tags alone on a line leave no blank line. Filters:
`lower upper trim title slug default:"x" fixed:2 round thousands pad:3 truncate:80 date:"YYYY-MM-DD" json length join:", "`
(`date` tokens `YYYY MM DD HH mm ss`, shown in the recipe time zone; dates written without a zone are
shown as written). Partials, delimiter changes and lambdas are not supported. Unknown names render
empty, with a warning.
In **paths**, every `{{value}}` (also `{{{value}}}`) becomes one safe file or folder name: `/`, `\`,
`:` and other characters Windows refuses become `-`, and leading or trailing dots and spaces are
removed, so data such as `../../x` cannot change the folder. Write folder separators in the template
itself (`clients/{{name}}/README.md`).
## Workspace rules
The workspace is the folder you choose; paths in recipes are relative to it.
- **`AGENTROVE_WORKFLOW_ROOT` set:** that folder is used (for example a Downloads or Documents
subfolder; in an MCP client, set it in the server's `env`).
- **Not set:** the folder the CLI or MCP server was started in is used **only if it looks like a
project you chose**: it contains `.git`, `.hg`, `.svn`, `.claude`, `.mcp.json`, `.vscode`, `CLAUDE.md`,
`AGENTS.md`, `package.json`, `pyproject.toml`, `setup.py`, `requirements.txt`, `go.mod`,
`Cargo.toml`, `pom.xml`, `build.gradle(.kts)`, `composer.json`, `Gemfile`, `deno.json`,
`CMakeLists.txt`, `Makefile`, or an empty `.agentrove-workspace` file you create to opt a folder in.
Otherwise the call fails with `workspace_not_chosen` and says how to choose one.
- **Always refused**, even when set explicitly: a drive or file-system root, your home folder itself
(its subfolders are fine), the folder that holds the users' home folders, and system folders
(Windows, Program Files, ProgramData; `/etc`, `/usr`, `/bin`, `/System`, `/Library` and similar).
(Security review finding C6, 0.1.1.)
- Refused: absolute paths, drive letters, UNC paths, `..`, `:` (alternate data streams), control
characters, `< > " | ? *`, reserved Windows names (`CON`, `NUL`, `COM1`, ...), names ending in a dot
or space, Windows 8.3 short names such as `ENV~1` (they can stand for hidden names), and **hidden
names starting with `.`** (so `.git`, `.env` or `.ssh` are never read, listed or written).
- **Protected names are never written or moved into place** (security review finding C5, 0.1.1): files
that AI assistants, MCP clients, package managers or build tools read as instructions, configuration
or code, in any folder and any letter case. For example `CLAUDE.md`, `AGENTS.md`, `GEMINI.md`,
`SKILL.md`, `copilot-instructions.md`, `*.instructions.md`, `*.prompt.md`, `llms.txt`, `mcp.json`,
`settings.json`, `claude_desktop_config.json`, `package.json` and lock files, `tsconfig.json`,
`pyproject.toml`, `requirements.txt`, `conftest.py`, `Makefile`, `Dockerfile`, `*.config.js|ts|json`,
`*.code-workspace`, and anything under `node_modules/` or a tool folder such as `.claude/`, `.cursor/`,
`.github/` or `.vscode/` (see `PROTECTED_FILES` in `src/fsguard.js`). A `write_file` to such a name is
a conflict (the run is refused); a move or copy to one is skipped and the file stays where it is.
The list is not exhaustive; reviewing the plan stays the main check.
- Reads follow links only if they end inside the workspace. Listings skip links and never follow
linked folders. Writes, moves and copies never go through a link (symbolic link or junction) and
never replace one.
- Existing files are replaced only by `write_file` with `if_exists: "overwrite"` (via a temporary file
and rename, after checking the file still matches the plan). Moves and copies never replace a file.
Appending to a file with several hard links is refused. Nothing is ever deleted.
## Usage (Node CLI)
```sh
node bin/cli.js --help
node bin/cli.js validate_recipe --input check.json # {"recipe": {...}}
node bin/cli.js plan_recipe --input plan.json # {"recipe": {...}, "vars": {"month": "2026-12"}}
# Review the diff, then apply exactly that plan:
node bin/cli.js run_recipe --input run.json # {"recipe": {...}, "confirm": true, "expected_plan_hash": "<plan_hash>"}
```
Run the CLI in a project folder (see Workspace rules), or set `AGENTROVE_WORKFLOW_ROOT`. On Windows
PowerShell, prefer `--input file.json` over `--json` quoting.
## Use as an MCP server
```sh
claude mcp add workflow-automation -- node /absolute/path/to/workflow-automation/bin/mcp.js
```
The server's start folder is the workspace if it looks like a project (see Workspace rules); otherwise
set `AGENTROVE_WORKFLOW_ROOT` in the server's environment.
`claude-code/SKILL.md` is a Claude Code skill that drives the CLI.
## Typed IO (composition)
- Input `input_text` (`text`): read by `read_input` steps, so another agent's output (for example
captions or a report) can be saved or reshaped by a recipe.
- Output `report` (`markdown_document`): the plan or run report.
## Testing status
- Node.js (Vitest): `tests/workflow-automation.test.ts` covers validation, templates, CSV, every step
type, dry runs that leave the workspace byte-for-byte unchanged, confirmation, plan-hash pinning,
if_exists modes, path traversal, link escapes (junctions on Windows; file symlinks where the OS
allows them), size, row, operation, output and time limits, the CLI and MCP stdio.
- Tested on Windows 11 (NTFS) with Node.js 24. macOS and Linux have not been tested by AgentRove.
- Runs inside AI clients (Claude Code, Codex and others) are recorded separately for each version on this
agent's page on the AgentRove site; this file is written before those runs, so it states none.
## Limitations
- Built-in steps only: no conditions between steps, loops other than `for_each`, arithmetic
expressions, regular expressions, spreadsheets (`.xlsx`), PDFs or images. Values read from CSV are
text until a step compares, sums or casts them.
- Recipes run when you run them; there is no scheduler (use your operating system's scheduler to run
the CLI if you want that, and review the plan output it prints).
- Time-of-check/time-of-use: operations are re-checked just before they run, but another program
changing the same files at the same moment is not fully guarded against (for example a file created
at the destination between the check and a move).
- Line diffs are shown for text overwrites up to a size limit; larger changes are summarised.