Skip to content

Commit d57cbc2

Browse files
authored
docs: add input-form decision rule, document @- heredoc as hook-safe path (#334)
The @- stdin/heredoc route already works and is the cleanest way to make a single multi-line edit without writing a file — and because the command line starts with ./supertool (no cat/echo), it survives enforced/autonomous runs that block bare shell builtins. The docs covered the mechanic but never the decision: when to pick colon-CLI vs @- vs @file. Add a 'Which form?' table to input-forms.md naming the cat-to-file trap, and expand the bare @- line in edits.md with a working heredoc example and cross-link. Refs #328
1 parent 7aed79b commit d57cbc2

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

docs/input-forms.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
Three ways to pass arguments to supertool ops.
44

5+
## Which form? {#which-form}
6+
7+
Pick by the shape of your content, not by habit:
8+
9+
| Use | When | Why |
10+
| --- | --- | --- |
11+
| **Colon-CLI** | Short, single-line content with no `:` / quotes / newlines | Zero ceremony — it's just the op string |
12+
| **`@-` heredoc** | Multi-line / quoted / colon-bearing content, **one** op, nothing to keep | No file written; the command line starts with `./supertool`, so it survives enforced or autonomous runs that block bare shell builtins (`cat`, `echo`, …) |
13+
| **`@file`** | Same messy content, but you want to **re-run, batch, or diff** it | The payload is a durable artifact. Write it with an editor or your harness's file-write tool — **not** `cat > file`, which puts a blocked builtin at the start of the line under enforcement |
14+
15+
The trap to avoid: writing a payload with `cat > .max/x.json <<'EOF'` and then reading it back. That line *starts* with `cat`, so an enforced/autonomous run flags it — and it forces hand-escaped `\n` JSON. If you need a single edit, pipe the heredoc straight into `@-`; if you need the file, write it with a tool, not `cat`.
16+
517
## Colon-CLI (default)
618

719
Most ops take arguments via `:``read:PATH:OFFSET:LIMIT`, `grep:PATTERN:PATH:LIMIT`. When content itself contains colons (code, SQL, timestamps), switch to `:::` triple-colon separators: `edit:::OLD:::NEW:::PATH`.

docs/operations/edits.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,17 @@ When `old` or `new` spans multiple lines or contains characters that clash with
7272
{ "old": "return false;", "new": "return true;", "path": "src/app/Foo.py" }
7373
```
7474

75-
Use `@-` to pipe from stdin instead of a file.
75+
Use `@-` to pipe from stdin instead of a file — a heredoc keeps the whole edit in one command with nothing written to disk, and a TOML body takes raw multi-line code with no escaping:
76+
77+
```bash
78+
./supertool 'edit:@-' <<'EOF'
79+
path = "src/app/Foo.py"
80+
old = '''return false;'''
81+
new = '''return true;'''
82+
EOF
83+
```
84+
85+
Because the line starts with `./supertool` (not `cat`/`echo`), this is the form to reach for under enforced or autonomous runs that block bare shell builtins. See [Which form?](../input-forms.md#which-form) for choosing between colon-CLI, `@-`, and `@file`.
7686

7787
### `batch:@file` — mixed ops in one round-trip
7888

0 commit comments

Comments
 (0)