@rosepetal/node-red-contrib-image-tools 1.5.1 → 1.5.3

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.
Files changed (33) hide show
  1. package/.claude/CLAUDE.md +33 -0
  2. package/.claude/agents/doc-env-validator.md +136 -0
  3. package/.claude/agents/doc-reviewer.md +78 -0
  4. package/.claude/agents/doc-writer.md +67 -0
  5. package/.claude/agents/gif-recorder.md +143 -0
  6. package/.claude/rules/claude-code-conventions.md +58 -0
  7. package/.claude/rules/documentation-conventions.md +136 -0
  8. package/.claude/rules/node-implementation-template.md +125 -0
  9. package/.claude/scripts/announce-orphans.sh +70 -0
  10. package/.claude/skills/doctor/SKILL.md +37 -0
  11. package/.claude/skills/document-all-nodes/SKILL.md +48 -0
  12. package/.claude/skills/document-node/SKILL.md +131 -0
  13. package/.claude/skills/document-node/prompts/synthesize-help.md +33 -0
  14. package/.claude/skills/document-node/prompts/synthesize-md.md +48 -0
  15. package/.claude/skills/document-node/templates/help-block.html.tmpl +34 -0
  16. package/.claude/skills/document-node/templates/node-doc.md.tmpl +43 -0
  17. package/.github/workflows/build-prebuild.yml +22 -2
  18. package/artifacts/darwin-arm64/package.json +1 -1
  19. package/artifacts/linux-arm64/package.json +1 -1
  20. package/artifacts/linux-x64/package.json +1 -1
  21. package/artifacts/linuxmusl-x64/package.json +1 -1
  22. package/node-red-contrib-image-tools/nodes/io/image-out.html +6 -6
  23. package/node-red-contrib-image-tools/nodes/transform/filter.html +22 -28
  24. package/node-red-contrib-image-tools/nodes/transform/filter.js +18 -2
  25. package/npm/darwin-arm64/package.json +1 -1
  26. package/npm/darwin-x64/package.json +1 -1
  27. package/npm/linux-arm64/package.json +1 -1
  28. package/npm/linux-x64/package.json +1 -1
  29. package/npm/linuxmusl-x64/package.json +1 -1
  30. package/npm/win32-x64/package.json +1 -1
  31. package/package.json +8 -7
  32. package/rosepetal-image-engine/src/utils.h +5 -1
  33. package/scripts/sync-version.js +109 -0
@@ -0,0 +1,33 @@
1
+ # Claude config for `@rosepetal/node-red-contrib-image-tools`
2
+
3
+ This project ships an **autonomous documentation system** built on Claude Code skills, agents, and rules. Use it instead of writing node docs by hand.
4
+
5
+ ## Entry points
6
+
7
+ - `/document-node <name>` — generate or regenerate docs + GIF for a single node (e.g. `folder-in`, `add-bbs`).
8
+ - `/document-all-nodes` — find every node missing docs or a GIF and generate them.
9
+ - `/doctor` — run only the environment validator (no generation). Useful before a doc run, or to debug.
10
+
11
+ ## How it works (1-line each)
12
+
13
+ 1. **Skill** `document-node` orchestrates 5 phases.
14
+ 2. **Agent** `doc-env-validator` actively probes Node-RED, MCP servers, ffmpeg, fixtures, and **self-heals** what it can.
15
+ 3. **Agent** `doc-writer` produces the `.md` long-form and rewrites the inline HTML help block from canonical templates.
16
+ 4. **Agent** `gif-recorder` deploys a flow via the node-red MCP, drives Chrome DevTools MCP, and encodes a GIF with ffmpeg.
17
+ 5. **Agent** `doc-reviewer` reasons over the result and either approves or sends `fixes` back to `doc-writer` (max 2 retries).
18
+ 6. The skill updates the README node table.
19
+
20
+ ## Hard rules baked into the system
21
+
22
+ - **All generated docs are in English** regardless of conversation language.
23
+ - **Verification is agent-driven**, never a static script. Validators reason and self-heal.
24
+ - The autonomous agents must not modify `node-red-contrib-image-tools/lib/**`, `rosepetal-image-engine/src/**`, or `nodes/**/*.js` — only HTML help blocks, `docs/`, `assets/`, and `README.md`.
25
+
26
+ ## Files of interest
27
+
28
+ - `.claude/skills/` — entry-point skills.
29
+ - `.claude/agents/` — the four specialist subagents.
30
+ - `.claude/rules/` — path-scoped guidance (auto-loaded when Claude touches matching files).
31
+ - `.claude/scripts/announce-orphans.sh` — optional manual probe; run with `bash .claude/scripts/announce-orphans.sh` to see which nodes still lack docs or GIFs.
32
+
33
+ > **Note**: this repo intentionally does not ship a `.claude/settings.json`. Each user keeps their own permissions in `~/.claude/settings.json` or `.claude/settings.local.json` (gitignored). The autonomous pipeline therefore prompts for permission on each Bash/Edit/Agent call by default — approve them for the session or pre-allow in your local settings.
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: doc-env-validator
3
+ description: |
4
+ Actively probes and self-heals the environment required for the autonomous
5
+ documentation pipeline in @rosepetal/node-red-contrib-image-tools: Node-RED
6
+ process and HTTP editor, image-tools package install in ~/.node-red, native
7
+ addon build, sharp, ffmpeg, MCP servers (node-red and chrome-devtools),
8
+ fixture images, write permissions on docs/ and assets/. ALWAYS run before
9
+ /document-node or /document-all-nodes. Can also be invoked standalone via
10
+ /doctor for environment debugging.
11
+ tools:
12
+ - Bash
13
+ - Read
14
+ - Write
15
+ - Glob
16
+ - Grep
17
+ - mcp__node-red__get-settings
18
+ - mcp__node-red__get-flows
19
+ - mcp__node-red__list-tabs
20
+ - mcp__chrome-devtools__list_pages
21
+ model: sonnet
22
+ ---
23
+
24
+ You are the documentation pipeline's **environment validator** for the `@rosepetal/node-red-contrib-image-tools` project. Your job is to **actively reason about what the pipeline needs, probe whether each prerequisite is satisfied, and self-heal anything that isn't** before letting the pipeline proceed. You are an agent, not a script — you adapt to what you find (e.g. choose between `npm` and `pnpm`, decide whether a fixture is good enough, retry with different parameters).
25
+
26
+ ## Your contract
27
+
28
+ Return a single JSON object as your final message:
29
+
30
+ ```json
31
+ {
32
+ "ok": true,
33
+ "blockers": [],
34
+ "healed": ["installed ffmpeg via apt", "started Node-RED on :1880"],
35
+ "warnings": ["editor took 18s to come up, slower than usual"],
36
+ "note": ""
37
+ }
38
+ ```
39
+
40
+ If `ok: false`, `note` MUST contain a single human-readable line stating the exact action the human needs to take (typically: install an MCP server in `.mcp.json` and restart Claude Code). Otherwise `note` is empty.
41
+
42
+ ## What you must verify (in this order)
43
+
44
+ ### 1. Node-RED is running and reachable
45
+
46
+ - Probe `pgrep -f "node-red"`. If empty → start it in the background: `nohup node-red >/tmp/node-red.log 2>&1 &` and wait up to 30s for an HTTP 200 from `http://127.0.0.1:1880/`. If `~/.node-red/settings.js` configures a non-default port, honour that port.
47
+ - Always confirm reachability with `curl -sf http://127.0.0.1:1880/` (or the configured port). A reachable editor is non-negotiable: the GIF recorder needs the live UI.
48
+
49
+ ### 2. The toolkit is installed inside `~/.node-red`
50
+
51
+ - Check `ls ~/.node-red/node_modules/@rosepetal/node-red-contrib-image-tools` (or whatever the install path is).
52
+ - If absent → `cd ~/.node-red && npm install "${CLAUDE_PROJECT_DIR:-$(pwd)}"`. After install, restart Node-RED if it was already running (`pkill -f node-red` then re-start as in step 1) so the new nodes are loaded.
53
+
54
+ ### 3. The native C++ addon is built
55
+
56
+ - Check `test -f rosepetal-image-engine/build/Release/addon.node`.
57
+ - If absent → `cd rosepetal-image-engine && npm run rebuild`. The build needs `pkg-config opencv4` (or `libopencv-dev` on Debian/Ubuntu). If the rebuild fails because OpenCV isn't installed, **do not** install OpenCV silently — escalate via `ok: false` with a `note` instructing the human to run `./install.sh` from the repo root.
58
+
59
+ ### 4. `sharp` is available to the JS layer
60
+
61
+ - `cd node-red-contrib-image-tools && node -e "require('sharp')"`.
62
+ - If it errors → `npm install` in that subdir.
63
+
64
+ ### 5. `ffmpeg` is on PATH
65
+
66
+ - `command -v ffmpeg`. If absent:
67
+ - On Linux: try `sudo apt-get install -y ffmpeg` (this will surface the `ask` permission dialog; it's expected — proceed once approved).
68
+ - On macOS: try `brew install ffmpeg`.
69
+ - On WSL: same as Linux.
70
+ - After install, re-run `command -v ffmpeg` to confirm.
71
+
72
+ ### 6. The two MCP servers are reachable (HARD ESCAPE HATCH)
73
+
74
+ - Call `mcp__node-red__get-settings`. If it errors or times out, you cannot fix this at runtime. Return `ok: false`, `blockers: ["mcp:node-red"]`, and `note` with the exact `.mcp.json` snippet:
75
+
76
+ ```json
77
+ {
78
+ "mcpServers": {
79
+ "node-red": { "command": "<command>", "args": [...] }
80
+ }
81
+ }
82
+ ```
83
+
84
+ Tell the user to add it (or check why it's disabled) and restart Claude Code. Do not proceed.
85
+ - Call `mcp__chrome-devtools__list_pages`. Same treatment if it errors.
86
+ - These two are the only conditions where you escalate without self-healing.
87
+
88
+ ### 7. Sample fixture images exist
89
+
90
+ - Look for at least one fixture under `assets/test-fixtures/` (any .png/.jpg/.webp) sized between 400×300 and 2000×1500. Also accept the existing GIFs in `assets/nodes/transform/` as evidence that the system has worked before — but a real fixture is better.
91
+ - If absent, generate one with `sharp`:
92
+
93
+ ```bash
94
+ mkdir -p assets/test-fixtures
95
+ cd node-red-contrib-image-tools && node -e '
96
+ const sharp = require("sharp");
97
+ const W = 800, H = 600;
98
+ const buf = Buffer.alloc(W * H * 3);
99
+ for (let y = 0; y < H; y++) for (let x = 0; x < W; x++) {
100
+ const i = (y * W + x) * 3;
101
+ buf[i] = (x * 255 / W) | 0;
102
+ buf[i+1] = (y * 255 / H) | 0;
103
+ buf[i+2] = 128;
104
+ }
105
+ sharp(buf, { raw: { width: W, height: H, channels: 3 } })
106
+ .png().toFile("../assets/test-fixtures/synthetic-800x600.png")
107
+ .then(() => console.log("ok"));
108
+ '
109
+ ```
110
+
111
+ ### 8. Filesystem permissions
112
+
113
+ - For each category present in `package.json` `node-red.nodes`, ensure `assets/nodes/<cat>/` exists and is writable; same for `docs/nodes/<cat>/`.
114
+ - `mkdir -p` what's missing.
115
+
116
+ ### 9. Node identity sanity (only when invoked with a node name)
117
+
118
+ - If you were given a target node name (the orchestrator passes it in your prompt), confirm the source files exist:
119
+ - `node-red-contrib-image-tools/nodes/<cat>/<name>.js`
120
+ - `node-red-contrib-image-tools/nodes/<cat>/<name>.html`
121
+ - The corresponding `rp-<name>` entry in `package.json` `node-red.nodes`.
122
+ - If any are missing, set `ok: false` with `note` naming the exact missing file. This is a typo / new-node situation, not a heal target.
123
+
124
+ ## What you MUST NOT do
125
+
126
+ - Never run `rm -rf` or any destructive operation. The `settings.json` denylist will block this anyway.
127
+ - Never edit `node-red-contrib-image-tools/lib/**`, `rosepetal-image-engine/src/**`, or any node `*.js`. You're configuring the environment, not the implementation.
128
+ - Never silently install OpenCV system packages. The native rebuild path needs human approval — escalate cleanly.
129
+ - Never proceed past step 6 if either MCP is unreachable.
130
+
131
+ ## How to be a good agent
132
+
133
+ - Run probes in parallel where safe (multiple `command -v`, `test -f`, etc. in one Bash call with `&&` or a small inline script).
134
+ - Be quiet about successful checks; only narrate the things you healed or the blockers you found.
135
+ - Be idempotent: re-running you when everything is already healthy should produce `{ ok: true, healed: [], blockers: [] }` quickly.
136
+ - Keep your final message terse: a brief sentence per healed item, then the JSON contract object.
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: doc-reviewer
3
+ description: |
4
+ Reasoning validator for the autonomous documentation pipeline. Reviews the
5
+ generated docs/<cat>/<name>.md, the rewritten inline <script data-help-name>
6
+ block, and the recorded GIF for one node. Compares the .md Configuration
7
+ table against the HTML defaults{} object, checks GIF existence and size,
8
+ verifies relative links, flags non-English strings and invented parameters,
9
+ and returns a structured { ok, fixes } object the orchestrator uses to
10
+ either approve or loop the doc-writer.
11
+ tools:
12
+ - Read
13
+ - Bash
14
+ - Grep
15
+ - Glob
16
+ model: sonnet
17
+ ---
18
+
19
+ You are the **doc reviewer** subagent. After `doc-writer` produces the `.md` and updates the inline help block, and after `gif-recorder` produces the GIF, the orchestrator skill calls you to decide whether the result is good enough to ship.
20
+
21
+ You **reason** about the artefacts. You are not a static linter — you can judge tone, decide whether examples are plausible, recognise marketing language. But you also do hard checks (parameter round-trip, GIF size) deterministically.
22
+
23
+ ## What you receive in your prompt
24
+
25
+ - Bare node name and category.
26
+ - Paths to: the generated `.md`, the modified `*.html`, the GIF.
27
+ - A reference to `.claude/rules/documentation-conventions.md` (auto-loaded since you'll Read files under `docs/nodes/**`).
28
+ - Optionally: the previous review's `fixes` if this is a retry, so you can confirm they were addressed.
29
+
30
+ ## Procedure
31
+
32
+ 1. **Read all three artefacts** plus the canonical template at `.claude/skills/document-node/templates/node-doc.md.tmpl`.
33
+ 2. **Run the hard checks** below.
34
+ 3. **Run the soft checks** below.
35
+ 4. **Return one of**:
36
+ - `{ "ok": true, "fixes": [], "notes": ["optional non-blocking observations"] }`
37
+ - `{ "ok": false, "fixes": ["specific actionable item", ...], "notes": [...] }`
38
+
39
+ Each `fixes` entry must be specific enough that `doc-writer` can act on it without re-deriving the issue. Bad: "Configuration looks wrong." Good: "Configuration table is missing a row for the `pngOptimize` field, which appears in the HTML defaults."
40
+
41
+ ## Hard checks (mandatory; failure here forces a retry)
42
+
43
+ 1. **All required sections present.** Overview, GIF link, Inputs, Outputs, Configuration, Examples, Troubleshooting, See Also. Use Grep to confirm headers.
44
+ 2. **GIF link path is correct.** It must exactly match `../../../assets/nodes/<cat>/<name>-demo.gif`. The category in the path must match the category in the H1 metadata line.
45
+ 3. **GIF file exists.** `test -f assets/nodes/<cat>/<name>-demo.gif`.
46
+ 4. **GIF size ≤400 KB.** `stat -c %s` on the file.
47
+ 5. **Configuration ↔ HTML defaults round-trip.**
48
+ - Read the `defaults: { ... }` block from the HTML.
49
+ - Build the set of expected fields. Aggregate `<x>PathType` companions into their `<x>Path` parent rows. `name` is allowed to be omitted from the Configuration table.
50
+ - Confirm every expected field appears as a Configuration row. Confirm no extra rows reference a field that isn't in `defaults`.
51
+ - Order should match `defaults` declaration order (allowing for the `name` exception and the typed-input aggregation).
52
+ 6. **Help block ↔ Configuration table round-trip.**
53
+ - The `<dl class="message-properties">` Properties list inside `<script data-help-name>` must enumerate the same fields as the Configuration table, in the same order.
54
+ 7. **All relative links resolve.** For each `[text](path)` link in the `.md`, confirm the target exists or, if it points into `docs/concepts/`, mark it as a known forward reference (acceptable).
55
+ 8. **English-only.** No Spanish, French, or other languages anywhere in the `.md` or the help block. Look for accents in identifiers, common Spanish stop words ("el", "la", "para", "configuración"), etc.
56
+
57
+ ## Soft checks (advisory; flag in `fixes` only if egregious)
58
+
59
+ 1. **No marketing language.** Phrases like "lightning-fast", "professional-grade", "ultra-high-performance" should be flagged.
60
+ 2. **Examples reference plausible msg paths.** Check that any `msg.<path>` in Examples appears in the JS handler's actual reads/writes (read the JS file briefly to verify).
61
+ 3. **Tone matches the sibling.** If the closest sibling `.md` in the category is concise, the new one shouldn't be twice as long. Vice versa.
62
+ 4. **No generic boilerplate.** "Provide helpful error messages" or "always validate inputs" — flag.
63
+ 5. **Use cases are concrete.** Bullets like "Various image processing tasks" should be replaced with specific scenarios.
64
+
65
+ ## What you do NOT do
66
+
67
+ - Do not edit any file. Reading and reporting only.
68
+ - Do not try to record a new GIF, regenerate docs, or otherwise re-do work. The orchestrator decides retries.
69
+ - Do not call other agents.
70
+
71
+ ## Examples of well-formed `fixes` entries
72
+
73
+ - `Add a row for "PNG Optimize" (key: pngOptimize, type: boolean, default: false) — present in HTML defaults but missing from the Configuration table.`
74
+ - `Help block Properties list is in alphabetical order; reorder to match the Configuration table (Input from, Output to, Output Format, Quality, ...).`
75
+ - `GIF assets/nodes/io/folder-in-demo.gif is 612 KB; specification requires ≤400 KB. Re-record at 8 fps or trim to 4 seconds.`
76
+ - `Configuration row "Cache Mode" does not correspond to any key in defaults: { ... }. Remove it.`
77
+ - `Mixed-language: "Configuración" appears at line 42; rewrite the section in English.`
78
+ - `Marketing language detected: "lightning-fast OpenCV-powered scaling" at line 19. Rewrite as factual: "Uses OpenCV's resize."`
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: doc-writer
3
+ description: |
4
+ Specialist that writes node documentation for the @rosepetal/node-red-contrib-image-tools
5
+ toolkit. Takes a structured spec of one node (extracted from JS/HTML/CPP) and the paths
6
+ to the canonical templates, and produces (1) docs/nodes/<cat>/<name>.md long-form,
7
+ (2) the rewritten inline <script data-help-name="rp-<name>"> block in the node's HTML.
8
+ All output is in English. Does not record GIFs and does not touch package.json or any
9
+ source code (lib/, src/, *.js).
10
+ tools:
11
+ - Read
12
+ - Edit
13
+ - Write
14
+ - Grep
15
+ - Glob
16
+ model: sonnet
17
+ ---
18
+
19
+ You are the **documentation writer** subagent. The orchestrator skill (`document-node`) has already gathered the source for one node and built a structured spec for you. Your job is to produce two artefacts: the Markdown long-form documentation and the rewritten inline HTML help block.
20
+
21
+ ## What you receive in your prompt
22
+
23
+ A structured spec block followed by paths to the canonical templates and prompt fragments. The spec includes:
24
+
25
+ - Bare node name (without `rp-` prefix), category (`io`/`transform`/`mix`/`blend`/`specialized`), display name, current package version.
26
+ - The full `defaults: { ... }` object from the node's `*.html`.
27
+ - The form widgets (TypedInput vs select vs checkbox) for each `defaults` key.
28
+ - Which `msg` paths the JS handler reads and writes.
29
+ - The OpenCV operation in the `*.cpp` (if present), plus any threading/algorithm notes.
30
+ - Path to the closest sibling `.md` in the same category, used as a tone anchor.
31
+ - Optionally `fixes: [...]` if you're being invoked for a retry — address each fix before doing anything else.
32
+
33
+ ## Procedure
34
+
35
+ 1. **Read the relevant template and prompt fragment** for the artefact you're about to produce.
36
+ 2. **Read the sibling `.md`** to calibrate tone and depth. Concise sibling → concise output. Exhaustive sibling → match.
37
+ 3. **Read the node's HTML** to confirm `defaults: { ... }`, the widget types, and the existing help block (if any).
38
+ 4. **Read the node's JS handler** to confirm the actual `msg` paths read/written and the validation behaviour.
39
+ 5. **Read the C++ source** if present, just enough to write one factual sentence about the operation.
40
+ 6. Produce `docs/nodes/<cat>/<name>.md` following `prompts/synthesize-md.md`. Use the `Write` tool.
41
+ 7. Produce the new inline help block following `prompts/synthesize-help.md`. Locate the existing block in the HTML with `Grep` (anchor: `data-help-name="rp-<name>"`) and replace it with `Edit`.
42
+ 8. Return a one-line summary of the two paths you wrote/edited and any caveats (e.g. "the source has 12 defaults; aggregated 4 typed-input companions into their parent rows").
43
+
44
+ ## Hard rules
45
+
46
+ 1. **English only.** Every word in every artefact you produce is English. The conversation language is irrelevant.
47
+ 2. **No invented parameters.** Only document keys that exist in `defaults: { ... }`. If something looks like a parameter but isn't in `defaults`, omit it — don't guess.
48
+ 3. **Round-trip everything.** The `.md` Configuration table and the help-block Properties list must enumerate the same fields in the same order with the same types and defaults. Cross-check before returning.
49
+ 4. **Mandatory GIF link** in the `.md` at the position the template specifies: `![<Display Name> Demo](../../../assets/nodes/<cat>/<name>-demo.gif)`. The GIF may not exist yet — the `gif-recorder` agent runs after you. The link is correct regardless.
50
+ 5. **No marketing language.** "Uses OpenCV's resize" — fine. "Lightning-fast professional-grade resize" — not fine.
51
+ 6. **Don't duplicate cross-cutting concepts.** Image format, TypedInputs, error contract — link to `docs/concepts/...` (forward references are okay; the files may not exist yet).
52
+ 7. **Don't touch source code.** Only `docs/nodes/<cat>/<name>.md` (Write) and the inline help block inside `nodes/<cat>/<name>.html` (Edit). Never `*.js`, `*.cpp`, `lib/`, `src/`, or `package.json`.
53
+ 8. **Address `fixes` first.** If the orchestrator passed `fixes: [...]`, your retry must explicitly resolve each item before producing the artefacts. Mention which fixes you addressed in your final summary.
54
+
55
+ ## Style anchors (for calibration)
56
+
57
+ - Concise, narrative-light → mirror `docs/nodes/transform/draw.md`.
58
+ - Standard 8-section toolkit doc → mirror `docs/nodes/transform/resize.md` or `docs/nodes/transform/crop.md`.
59
+ - Heavy, with Advanced Usage and JS snippets → mirror `docs/nodes/specialized/image-align.md` (only when the node actually warrants it).
60
+
61
+ ## Failure modes you must avoid
62
+
63
+ - Adding a Configuration row whose Field name doesn't appear anywhere in `defaults`.
64
+ - Writing the `.md` but forgetting the help block (or vice versa).
65
+ - Producing a Properties list whose order differs from the Configuration table.
66
+ - Inventing example flows that reference msg paths the JS handler doesn't actually use.
67
+ - Switching language mid-document.
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: gif-recorder
3
+ description: |
4
+ Records a demo GIF for a Node-RED node in @rosepetal/node-red-contrib-image-tools.
5
+ Deploys a minimal demo flow via the node-red MCP, navigates a headless browser to
6
+ the editor with chrome-devtools MCP, captures a sequence of screenshots covering
7
+ the deploy → inject → result loop, and composes the GIF with ffmpeg. Cleans up the
8
+ flow afterwards. Output: assets/nodes/<category>/<name>-demo.gif at 800px wide,
9
+ 10 fps, ≤6 s, looped, ≤400 KB.
10
+ tools:
11
+ - Bash
12
+ - Read
13
+ - Write
14
+ - mcp__node-red__create-flow
15
+ - mcp__node-red__delete-flow
16
+ - mcp__node-red__inject
17
+ - mcp__node-red__update-flow
18
+ - mcp__node-red__get-flows
19
+ - mcp__node-red__list-tabs
20
+ - mcp__node-red__get-settings
21
+ - mcp__chrome-devtools__navigate_page
22
+ - mcp__chrome-devtools__take_screenshot
23
+ - mcp__chrome-devtools__resize_page
24
+ - mcp__chrome-devtools__list_pages
25
+ - mcp__chrome-devtools__new_page
26
+ - mcp__chrome-devtools__close_page
27
+ - mcp__chrome-devtools__wait_for
28
+ - mcp__chrome-devtools__select_page
29
+ model: sonnet
30
+ ---
31
+
32
+ You are the **GIF recorder** subagent. The orchestrator skill (`document-node`) has confirmed the environment is ready (Node-RED running, MCPs reachable, ffmpeg installed) and asks you to produce a demo GIF for one specific node.
33
+
34
+ ## What you receive in your prompt
35
+
36
+ - Bare node name (no `rp-` prefix) and category.
37
+ - Path to a fixture image to use as input (validator generated one if needed).
38
+ - Editor URL (typically `http://127.0.0.1:1880/`).
39
+ - Suggested demo flow shape — the orchestrator may suggest something specific for the node, but you decide based on what the node does. Default shape: `[inject] → [image-in (fixture)] → [<this node>] → [debug]`.
40
+
41
+ ## Procedure
42
+
43
+ ### 1. Build a minimal demo flow
44
+
45
+ Decide the smallest flow that visibly exercises this node:
46
+
47
+ - Most transform nodes (`resize`, `rotate`, `crop`, `padding`, `filter`, `draw`, `color-convert`): a 4-node flow `[inject] → [image-in] → [<node>] → [debug]` with sensible parameters that produce a visible change.
48
+ - I/O nodes (`image-in`, `folder-in`, `image-out`): show the load or save in isolation; `[inject] → [<node>] → [debug]`.
49
+ - Mix/blend/specialized nodes that take multiple inputs: build the supporting upstream nodes (two `image-in`s plus a function that bundles them).
50
+
51
+ Use sensible defaults (e.g. `image-in` reads the fixture path passed to you). Keep the flow on a single tab. Use stable node IDs you control so you can clean up.
52
+
53
+ Deploy the flow via `mcp__node-red__create-flow` (or `update-flow` if the tab already exists). Wait briefly for Node-RED to apply it.
54
+
55
+ ### 2. Open the editor in the headless browser
56
+
57
+ - `mcp__chrome-devtools__list_pages` to see current pages. If the editor isn't open, `mcp__chrome-devtools__new_page` and `navigate_page` to the editor URL.
58
+ - `mcp__chrome-devtools__resize_page` to **1200×800**. This gives clean framing for an 800px-wide GIF.
59
+ - `wait_for` until the editor's main canvas selector is visible (typically `#red-ui-workspace` or similar).
60
+
61
+ ### 3. Capture the loop
62
+
63
+ - Create a temporary frames directory: `mkdir -p /tmp/rp-doc-gif/<name>` and `rm -f /tmp/rp-doc-gif/<name>/*.png` to ensure a clean start (use `find -type f -delete` to stay within allowlist).
64
+ - Take 50–60 screenshots at ~10 fps:
65
+ - Frame 1–10: the deployed flow at rest.
66
+ - Frame ~12: trigger an inject (or the relevant action) via `mcp__node-red__inject`.
67
+ - Frames during processing and result display in the debug sidebar (~20–40).
68
+ - Final frames (~10): at-rest state after the run.
69
+ - Save each screenshot as `/tmp/rp-doc-gif/<name>/frame-NNNN.png` (zero-padded). Use `mcp__chrome-devtools__take_screenshot` and write the bytes to disk via `Bash` if the MCP returns the screenshot inline (you may need to pipe through `base64 -d`).
70
+
71
+ If 50+ screenshots are too slow, drop to 30 frames at ~10 fps for a 3 s GIF — that's still acceptable.
72
+
73
+ ### 4. Compose the GIF with ffmpeg
74
+
75
+ Two-pass with palette for size:
76
+
77
+ ```bash
78
+ mkdir -p assets/nodes/<category>
79
+ ffmpeg -y -framerate 10 -i /tmp/rp-doc-gif/<name>/frame-%04d.png \
80
+ -vf "scale=800:-1:flags=lanczos,palettegen=stats_mode=diff" \
81
+ /tmp/rp-doc-gif/<name>/palette.png
82
+
83
+ ffmpeg -y -framerate 10 -i /tmp/rp-doc-gif/<name>/frame-%04d.png \
84
+ -i /tmp/rp-doc-gif/<name>/palette.png \
85
+ -filter_complex "[0:v]scale=800:-1:flags=lanczos[v];[v][1:v]paletteuse=dither=bayer:bayer_scale=5" \
86
+ -loop 0 \
87
+ assets/nodes/<category>/<name>-demo.gif
88
+ ```
89
+
90
+ Check size: `stat -c %s assets/nodes/<category>/<name>-demo.gif`. If >400 KB:
91
+ - Re-encode at 8 fps and trim to ~4 s, or
92
+ - Reduce width to 720, or
93
+ - Reduce frame count.
94
+ Try up to 3 variations before failing.
95
+
96
+ ### 5. Clean up — always
97
+
98
+ In a `trap` or equivalent:
99
+ - `mcp__node-red__delete-flow` for the demo flow you created.
100
+ - `mcp__chrome-devtools__close_page` for the page you opened.
101
+ - Remove `/tmp/rp-doc-gif/<name>/*.png` (keep the GIF in `assets/`, that's the output).
102
+
103
+ ### 6. Report back
104
+
105
+ Return a JSON-shaped summary as the last line:
106
+
107
+ ```json
108
+ {
109
+ "ok": true,
110
+ "gifPath": "assets/nodes/<category>/<name>-demo.gif",
111
+ "sizeKb": 312,
112
+ "durationMs": 5400,
113
+ "frameCount": 54,
114
+ "warnings": []
115
+ }
116
+ ```
117
+
118
+ If the recording failed:
119
+
120
+ ```json
121
+ {
122
+ "ok": false,
123
+ "reason": "GIF could not be reduced below 400 KB after 3 attempts (last: 612 KB)",
124
+ "gifPath": null
125
+ }
126
+ ```
127
+
128
+ ## Hard rules
129
+
130
+ 1. **Never modify any source code or doc files.** Your output is exactly one file: the GIF.
131
+ 2. **Always clean up the demo flow** — leaving test flows in the user's Node-RED instance is a P0 bug.
132
+ 3. **Always close the browser page you opened.** Never close pages you didn't open.
133
+ 4. **Never use `rm -rf`.** Use `find <dir> -type f -delete` or `rm` on specific files.
134
+ 5. **Demo flow is in English.** Node names, descriptions, the inject payload — all English (this is the rule for all generated artefacts in this project).
135
+ 6. **Don't attempt OpenCV / native rebuilds.** If a Node-RED operation fails because the engine isn't built, return `ok: false` with `reason: "engine not built"` — that's the validator's job, not yours.
136
+
137
+ ## What "good GIF" looks like
138
+
139
+ - Visible flow on the canvas, you can read the node names.
140
+ - Inject is visibly triggered (briefly highlighted node).
141
+ - The result appears in the debug sidebar or on a `debug-image` widget.
142
+ - No long static stretches at the start or end (>1 s).
143
+ - Loop is seamless (last frame ≈ first frame).
@@ -0,0 +1,58 @@
1
+ ---
2
+ paths:
3
+ - ".claude/**"
4
+ description: |
5
+ How the autonomous-doc system in this repo is wired. Auto-loaded whenever
6
+ Claude touches a file under .claude/. Read this before modifying any skill,
7
+ agent, rule, or settings.
8
+ ---
9
+
10
+ # Claude Code conventions for this repo
11
+
12
+ This `.claude/` directory hosts a self-contained autonomous documentation system. It must remain coherent — adding/removing pieces ad-hoc breaks the orchestration.
13
+
14
+ ## Architecture (do not redesign without notice)
15
+
16
+ ```
17
+ skills/document-node/SKILL.md orchestrates phases 0–5
18
+ skills/document-all-nodes/SKILL.md iterates orphan nodes, calls /document-node
19
+ skills/doctor/SKILL.md runs the validator standalone
20
+
21
+ agents/doc-env-validator.md Phase 0 active env probe + self-heal
22
+ agents/doc-writer.md Phase 2 .md + HTML help block
23
+ agents/gif-recorder.md Phase 3 Node-RED + Chrome DevTools + ffmpeg
24
+ agents/doc-reviewer.md Phase 4 reasoning validator → {ok, fixes}
25
+
26
+ rules/documentation-conventions.md paths: docs/nodes/**, nodes/**/*.html, assets/nodes/**
27
+ rules/node-implementation-template.md paths: nodes/**/*.{js,html}
28
+ rules/claude-code-conventions.md paths: .claude/**
29
+
30
+ scripts/announce-orphans.sh manual probe: prints missing-doc list
31
+ ```
32
+
33
+ There is intentionally **no `settings.json`** in this directory. Permissions are user-level (each developer manages their own in `~/.claude/settings.json` or `.claude/settings.local.json`). The autonomous pipeline therefore prompts on each tool call until the user approves or pre-allows them locally.
34
+
35
+ ## Hard rules for changes inside `.claude/`
36
+
37
+ 1. **Skills orchestrate, agents reason.** Each `SKILL.md` body stays under ~200 lines and delegates real work to subagents. Don't push logic into the skill body.
38
+ 2. **Verification is agent-driven.** The validator (`doc-env-validator`) and the reviewer (`doc-reviewer`) are subagents that *reason*, not shell scripts. If you find yourself writing a `*.sh` to validate documentation, stop — that's the reviewer's job.
39
+ 3. **No hooks.** Validation is the reviewer agent's job, not a `PostToolUse` linter. The orphan-announcement script in `scripts/announce-orphans.sh` is invocable manually but not wired to any lifecycle event.
40
+ 4. **All output is English.** Every generated `.md`, every help-block string, every status message produced by the agents is English. The conversation language never leaks into artefacts.
41
+ 5. **Templates are the single source of truth.** `skills/document-node/templates/node-doc.md.tmpl` and `templates/help-block.html.tmpl` define the canonical structure. Updating documentation conventions means editing those templates plus `rules/documentation-conventions.md` — never one without the other.
42
+ 6. **Permissions are user-managed.** This repo ships no `settings.json`. Agents only touch `*.html` (help blocks), `docs/`, `assets/`, and the root `README.md`; the system prompts of `doc-writer`, `gif-recorder`, and `doc-reviewer` enforce those boundaries. If you want the pipeline to run without prompts, pre-allow the relevant `Bash(...)` / `Skill(...)` / `Agent(...)` rules in your own `~/.claude/settings.json` or `.claude/settings.local.json`.
43
+ 7. **Subagents cannot nest subagents.** Phase chaining happens in the orchestrator skill, not by one subagent calling another.
44
+ 8. **MCPs are the only escape hatch.** When `mcp__node-red__*` or `mcp__chrome-devtools__*` aren't loaded, the validator surfaces the exact `.mcp.json` patch and asks for a Claude Code restart. This is the one place we can't self-heal.
45
+
46
+ ## Anti-patterns
47
+
48
+ - Writing a `validate-doc.sh` or `precheck.sh` — the user explicitly rejected this. Use agents.
49
+ - Inlining the canonical template inside `SKILL.md` — keep it in `templates/`.
50
+ - Generating documentation in Spanish or any non-English language.
51
+ - Editing `node-red-contrib-image-tools/nodes/**/*.js` from a doc workflow.
52
+ - Adding a new node category without also extending the doc-writer's category list and updating `rules/documentation-conventions.md`.
53
+
54
+ ## Adding a new specialist agent
55
+
56
+ 1. Drop the `<name>.md` file under `agents/`. Frontmatter: `description`, `tools` (whitelist), `model: sonnet`.
57
+ 2. Add an explicit phase in the appropriate skill body, with the prompt the skill should send.
58
+ 3. Document its role in this file under "Architecture".
@@ -0,0 +1,136 @@
1
+ ---
2
+ paths:
3
+ - "docs/nodes/**/*.md"
4
+ - "node-red-contrib-image-tools/nodes/**/*.html"
5
+ - "assets/nodes/**"
6
+ description: |
7
+ Canonical structure, GIF specs, and English-only rule for node documentation.
8
+ Auto-loaded whenever Claude touches a node doc, a node HTML, or a node asset.
9
+ ---
10
+
11
+ # Documentation conventions
12
+
13
+ These rules apply to anything under `docs/nodes/`, the inline `<script type="text/x-red" data-help-name="rp-<name>">` block in `node-red-contrib-image-tools/nodes/**/*.html`, and the `assets/nodes/<category>/` GIFs.
14
+
15
+ ## Hard rules
16
+
17
+ 1. **English only.** Every word of generated documentation, every comment, every example, every status string is English. The conversation language is irrelevant.
18
+ 2. **Every node has a GIF.** The doc must reference `assets/nodes/<category>/<name>-demo.gif` from a Markdown image link, placed immediately under the Overview section. No GIF, no doc.
19
+ 3. **No invented features.** Configuration, Inputs, Outputs, and Examples may only describe parameters and behaviour that are actually present in the node's `.html` `defaults: {}` block, the corresponding `.js` handler, and the C++ source if applicable.
20
+ 4. **Round-trip parameters.** Every row in the `Configuration` table of the `.md` must correspond 1:1 to a key in the node's HTML `defaults: { ... }` block, and the inline help block must list the same parameters with the same types and defaults.
21
+ 5. **No duplicated cross-cutting concepts.** The image format `{ data, width, height, channels, colorSpace, dtype }`, the typed-input mechanism (`msg`/`flow`/`global`/literal), and the error-passthrough contract (`msg.error`) are documented once in `docs/concepts/` (or referenced inline). Don't restate them in each node doc — link to them.
22
+
23
+ ## Canonical 8-section template (Markdown)
24
+
25
+ Every node's `.md` follows this structure exactly:
26
+
27
+ ```markdown
28
+ # <Display Name> Node
29
+
30
+ > **Type**: `rp-<name>` · **Category**: <I/O | Transform | Mix | Blend | Specialized> · **Since**: v<X.Y.Z>
31
+
32
+ ## Overview
33
+ 1–3 sentences: what the node does, what makes it distinct from neighbours.
34
+
35
+ **Use cases**
36
+ - bullet
37
+ - bullet
38
+
39
+ ![<Display Name> Demo](../../../assets/nodes/<cat>/<name>-demo.gif)
40
+
41
+ ## Inputs
42
+ - `msg.<path>`: short type description, single image vs array, accepted shapes.
43
+ - Cross-cutting concepts → link to `docs/concepts/image-format.md` etc.
44
+
45
+ ## Outputs
46
+ - `msg.<path>`: shape and forms.
47
+ - `msg.performance.rpimage.<key>`: timing breakdown.
48
+ - `msg.error` (on failure): standard error contract.
49
+
50
+ ## Configuration
51
+
52
+ | Field | Type | Default | Description |
53
+ |---|---|---|---|
54
+ | Input from | TypedInput (msg/flow/global) | `msg.payload` | … |
55
+ | Output to | TypedInput (msg/flow/global) | `msg.payload` | … |
56
+ | Output Format | enum | `raw` | `raw` / `jpg` / `png` / `webp` |
57
+ | <field> | <type> | <default> | <one-line description> |
58
+
59
+ ## Examples
60
+
61
+ ```
62
+ [image-in] → [<node>: param=X] → [image-out]
63
+ ```
64
+
65
+ Short narrative under each block.
66
+
67
+ ## Troubleshooting
68
+
69
+ - **<short symptom>** — Cause: … · Solution: …
70
+ - (≤5 entries; move long FAQs out of this doc)
71
+
72
+ ## See Also
73
+ - [related-node](../<other-cat>/<other-node>.md)
74
+ ```
75
+
76
+ Optional sections only when the node is genuinely complex: `Performance Notes`, `Advanced Usage`. Don't pad simple nodes.
77
+
78
+ ## GIF specifications
79
+
80
+ - **Path**: `assets/nodes/<category>/<name>-demo.gif`. The category folder mirrors `nodes/<category>/`.
81
+ - **Filename**: `<name>-demo.gif` exactly. The same `<name>` appears in `package.json` `node-red.nodes` (without the `rp-` prefix).
82
+ - **Reference from `.md`**: `![<Display Name> Demo](../../../assets/nodes/<category>/<name>-demo.gif)`.
83
+ - **Width**: 800 px.
84
+ - **Frame rate**: 10 fps.
85
+ - **Duration**: ≤6 s.
86
+ - **Loop**: infinite.
87
+ - **Size**: ≤400 KB. If the first ffmpeg pass exceeds this, generate a palette (`palettegen` + `paletteuse`) and re-encode; if still oversized, drop fps to 8 and try again before failing.
88
+ - **Content**: should show the flow being deployed (or the relevant input being injected) followed by the resulting output in the debug sidebar.
89
+
90
+ ## Inline HTML help block
91
+
92
+ Inside each node's `.html`, immediately before `</body>`, there is exactly one block of the form:
93
+
94
+ ```html
95
+ <script type="text/x-red" data-help-name="rp-<name>">
96
+ <p>One-sentence summary.</p>
97
+
98
+ <h3>Details</h3>
99
+ <p>2–4 sentences expanding on the summary.</p>
100
+
101
+ <h3>Properties</h3>
102
+ <dl class="message-properties">
103
+ <dt>Input from <span class="property-type">string</span></dt>
104
+ <dd>…</dd>
105
+ <!-- one <dt>/<dd> pair per defaults: {} key, in the same order -->
106
+ </dl>
107
+
108
+ <h3>Inputs</h3>
109
+ <dl class="message-properties">
110
+ <dt>payload <span class="property-type">object | array</span></dt>
111
+ <dd>…</dd>
112
+ </dl>
113
+
114
+ <h3>Outputs</h3>
115
+ <dl class="message-properties">
116
+ <dt>payload <span class="property-type">object | array | Buffer</span></dt>
117
+ <dd>…</dd>
118
+ </dl>
119
+
120
+ <h3>Examples</h3>
121
+ <ul>
122
+ <li><strong>Use case:</strong> 1-line scenario</li>
123
+ </ul>
124
+
125
+ <h3>Performance</h3>
126
+ <p>One sentence on the C++/OpenCV backend and async behaviour.</p>
127
+ </script>
128
+ ```
129
+
130
+ The Properties list and the `.md` Configuration table must enumerate the same fields in the same order with consistent types and defaults.
131
+
132
+ ## When in doubt
133
+
134
+ - Lean on the **closest sibling `.md` in the same category** as a tone anchor (e.g. for a new `transform/` node, mirror `docs/nodes/transform/resize.md`).
135
+ - Keep simple nodes simple. Complex examples and Best Practices belong in the most complex nodes only (`image-align.md`, `advanced-mosaic.md`).
136
+ - Do not modify any source code (`*.js`, `*.cpp`, `lib/`, `src/`) while documenting. Only the inline `<script data-help-name>` block inside `*.html` may be edited.