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

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 (30) 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/artifacts/darwin-arm64/package.json +1 -1
  18. package/artifacts/linux-arm64/package.json +1 -1
  19. package/artifacts/linux-x64/package.json +1 -1
  20. package/artifacts/linuxmusl-x64/package.json +1 -1
  21. package/node-red-contrib-image-tools/nodes/io/image-out.html +6 -6
  22. package/node-red-contrib-image-tools/nodes/transform/filter.html +22 -28
  23. package/node-red-contrib-image-tools/nodes/transform/filter.js +18 -2
  24. package/npm/darwin-arm64/package.json +1 -1
  25. package/npm/darwin-x64/package.json +1 -1
  26. package/npm/linux-arm64/package.json +1 -1
  27. package/npm/linux-x64/package.json +1 -1
  28. package/npm/linuxmusl-x64/package.json +1 -1
  29. package/npm/win32-x64/package.json +1 -1
  30. package/package.json +6 -6
@@ -0,0 +1,125 @@
1
+ ---
2
+ paths:
3
+ - "node-red-contrib-image-tools/nodes/**/*.js"
4
+ - "node-red-contrib-image-tools/nodes/**/*.html"
5
+ description: |
6
+ Canonical implementation pattern for Node-RED nodes in this toolkit.
7
+ Auto-loaded whenever Claude touches a node JS or HTML file. Documentation
8
+ agents read this to understand what parameters/contracts to surface.
9
+ ---
10
+
11
+ # Node implementation pattern
12
+
13
+ Every node in this toolkit follows the same shape. When documenting a node, extract from these locations; when adding a node, mirror them.
14
+
15
+ ## File layout
16
+
17
+ ```
18
+ node-red-contrib-image-tools/nodes/<category>/<name>.js # Node-RED handler
19
+ node-red-contrib-image-tools/nodes/<category>/<name>.html # editor UI + help block
20
+ rosepetal-image-engine/src/<name>.cpp # OpenCV implementation (if native)
21
+ ```
22
+
23
+ Categories: `io`, `transform`, `mix`, `blend`, `specialized`.
24
+
25
+ ## JS handler structure (canonical: `nodes/transform/resize.js`)
26
+
27
+ ```js
28
+ const { performance } = require('perf_hooks');
29
+ const CppProcessor = require('../../lib/cpp-bridge.js');
30
+
31
+ module.exports = function (RED) {
32
+ const NodeUtils = require('../../lib/node-utils.js')(RED);
33
+
34
+ function <Name>Node(config) {
35
+ RED.nodes.createNode(this, config);
36
+ const node = this;
37
+
38
+ node.on('input', async (msg, send, done) => {
39
+ const inputPath = config.inputPath || 'payload';
40
+ const inputPathType = config.inputPathType || 'msg';
41
+ const outputPath = config.outputPath || 'payload';
42
+ const outputPathType = config.outputPathType || 'msg';
43
+
44
+ // 1. Resolve input via NodeUtils.getInputValue
45
+ // 2. Validate single image or array
46
+ // 3. Resolve dimensions / typed inputs via NodeUtils.resolveDimension / resolveArrayPosition
47
+ // 4. fan-out: const promises = inputList.map(img => CppProcessor.<op>(img, ...))
48
+ // 5. const results = await Promise.all(promises)
49
+ // 6. Aggregate timings (convertMs/taskMs/encodeMs)
50
+ // 7. NodeUtils.setSuccessStatus + recordPerformanceMetrics
51
+ // 8. NodeUtils.setOutputValue
52
+ // 9. Optional inferenceEnabled → InfTx.applyTransform
53
+ // 10. send(msg); done();
54
+ // catch → NodeUtils.handleNodeErrorWithPassthrough (preserves originalPayload)
55
+ });
56
+ }
57
+
58
+ RED.nodes.registerType('rp-<name>', <Name>Node);
59
+ };
60
+ ```
61
+
62
+ ## HTML structure
63
+
64
+ ```html
65
+ <script type="text/javascript">
66
+ RED.nodes.registerType('rp-<name>', {
67
+ category: 'RP Image',
68
+ color: '#DDA0DD',
69
+ defaults: {
70
+ name: { value: "" },
71
+ inputPath: { value: "payload" },
72
+ inputPathType: { value: "msg" },
73
+ outputPath: { value: "payload" },
74
+ outputPathType: { value: "msg" },
75
+ outputFormat: { value: "raw" },
76
+ outputQuality: { value: 90 },
77
+ pngOptimize: { value: false },
78
+ // … node-specific params
79
+ debugEnabled: { value: false },
80
+ debugWidth: { value: 200 },
81
+ debugWidthType: { value: "num" }
82
+ },
83
+ inputs: 1, outputs: 1,
84
+ icon: "font-awesome/fa-...",
85
+ label: function () { return this.name || 'rp-<name>'; },
86
+ oneditprepare: function () { /* TypedInput init, conditional row visibility */ }
87
+ });
88
+ </script>
89
+
90
+ <script type="text/html" data-template-name="rp-<name>">
91
+ <!-- form rows with TypedInput widgets -->
92
+ </script>
93
+
94
+ <script type="text/x-red" data-help-name="rp-<name>">
95
+ <!-- canonical inline help block — see documentation-conventions.md -->
96
+ </script>
97
+ ```
98
+
99
+ ## What to extract for documentation
100
+
101
+ When the doc-writer agent reads a node, it must extract:
102
+
103
+ | From | Field | Used for |
104
+ |---|---|---|
105
+ | `*.html` `defaults: { … }` | every key + initial value | the Configuration table rows + Properties `<dl>` |
106
+ | `*.html` `<script type="text/html" data-template-name>` | `<input id="node-input-X">` widgets | type information for each field (TypedInput vs select vs checkbox) |
107
+ | `*.js` `node.on('input', …)` body | which `config.<key>` are read; which `msg.<path>` are read/written | Inputs/Outputs section |
108
+ | `package.json` `node-red.nodes` | the registered type id | confirm the `rp-<name>` mapping |
109
+ | sibling `.md` in the same category | tone, depth | style anchor |
110
+ | `rosepetal-image-engine/src/<name>.cpp` (if exists) | OpenCV operation, threading model | the optional Performance Notes section |
111
+
112
+ The doc-writer must never add a doc row whose key is not in `defaults: {}`, and must never omit a `defaults` key (even if it seems unimportant; fields like `name` and the typed-input pair `<x>PathType` are also part of the contract — but `name` and the `*PathType` companions can be aggregated under "Input from"/"Output to" rather than listed separately).
113
+
114
+ ## Common helpers in `lib/node-utils.js`
115
+
116
+ These are the names doc-writer is allowed to reference in Examples:
117
+
118
+ - `getInputValue` / `setOutputValue` — TypedInput-aware msg path read/write
119
+ - `validateImageStructure`, `validateSingleImage`, `validateListImage` — input shape validation
120
+ - `resolveDimension`, `resolveArrayPosition` — typed-numeric resolution
121
+ - `setSuccessStatus`, `setSuccessStatusWithDebug` — node status display
122
+ - `handleNodeErrorWithPassthrough`, `handleValidationErrorWithPassthrough` — error path
123
+ - `recordPerformanceMetrics` — sets `msg.performance.rpimage.<key>`
124
+ - `debugImageDisplay` — emits the editor preview via `RED.comms.publish('debug-image', …)`
125
+ - `rawToJpeg`, `encodeWebpAdvanced` — Sharp-based encoders
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env bash
2
+ # SessionStart hook: announce nodes that still lack a docs/.md or assets GIF.
3
+ # Emits Claude Code hook JSON so the missing-doc list shows up at session start.
4
+ #
5
+ # This is the only script in .claude/. All other validation is agent-driven.
6
+ set -euo pipefail
7
+
8
+ cd "${CLAUDE_PROJECT_DIR:-$(pwd)}"
9
+
10
+ # Use Node since we already require it for the toolkit.
11
+ report=$(node -e '
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+
15
+ let pkg;
16
+ try { pkg = require("./package.json"); } catch { process.exit(0); }
17
+
18
+ const types = Object.keys((pkg["node-red"] || {}).nodes || {});
19
+ if (!types.length) process.exit(0);
20
+
21
+ const docsRoot = "docs/nodes";
22
+ if (!fs.existsSync(docsRoot)) process.exit(0);
23
+
24
+ const docs = [];
25
+ (function walk(dir) {
26
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
27
+ const full = path.join(dir, entry.name);
28
+ if (entry.isDirectory()) walk(full);
29
+ else if (entry.name.endsWith(".md")) docs.push(entry.name);
30
+ }
31
+ })(docsRoot);
32
+
33
+ const assetsRoot = "assets/nodes";
34
+ const gifs = [];
35
+ if (fs.existsSync(assetsRoot)) {
36
+ (function walk(dir) {
37
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
38
+ const full = path.join(dir, entry.name);
39
+ if (entry.isDirectory()) walk(full);
40
+ else if (entry.name.endsWith("-demo.gif")) gifs.push(entry.name);
41
+ }
42
+ })(assetsRoot);
43
+ }
44
+
45
+ const missingDocs = [];
46
+ const missingGifs = [];
47
+ for (const t of types) {
48
+ const name = t.replace(/^rp-/, "");
49
+ if (!docs.includes(name + ".md")) missingDocs.push(name);
50
+ if (!gifs.includes(name + "-demo.gif")) missingGifs.push(name);
51
+ }
52
+
53
+ if (!missingDocs.length && !missingGifs.length) process.exit(0);
54
+
55
+ const lines = [];
56
+ if (missingDocs.length) lines.push("Nodes still missing docs/<cat>/<name>.md: " + missingDocs.join(", "));
57
+ if (missingGifs.length) lines.push("Nodes still missing assets/nodes/<cat>/<name>-demo.gif: " + missingGifs.join(", "));
58
+ lines.push("Run /document-all-nodes to generate everything autonomously, or /document-node <name> for one.");
59
+
60
+ process.stdout.write(JSON.stringify({
61
+ hookSpecificOutput: {
62
+ hookEventName: "SessionStart",
63
+ additionalContext: lines.join("\n")
64
+ }
65
+ }));
66
+ ' 2>/dev/null || true)
67
+
68
+ if [ -n "$report" ]; then
69
+ printf '%s\n' "$report"
70
+ fi
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: doctor
3
+ description: |
4
+ Run the documentation environment validator standalone. Probes Node-RED,
5
+ the toolkit install in ~/.node-red, the native addon, sharp, ffmpeg, the
6
+ required MCP servers, fixture images, and filesystem permissions. Self-heals
7
+ whatever can be fixed automatically; reports a structured JSON status.
8
+ Use before a /document-node run if anything in the environment changed,
9
+ or to debug why a doc run failed.
10
+ when_to_use: |
11
+ Trigger phrases: "doctor", "doc env check", "is the doc system ready", "check
12
+ the documentation environment", "run the validator". No arguments.
13
+ argument-hint: ""
14
+ allowed-tools: Agent
15
+ disable-model-invocation: false
16
+ ---
17
+
18
+ # Doctor
19
+
20
+ Standalone wrapper that runs the `doc-env-validator` subagent and surfaces its report.
21
+
22
+ ## What you do
23
+
24
+ 1. Spawn the validator subagent in the foreground with this prompt:
25
+
26
+ > Run the full environment validation playbook described in your system prompt. Self-heal everything you can. Return your standard JSON contract object as the last line of your response.
27
+
28
+ 2. When it returns:
29
+ - If `ok: true` → reply with a one-line green summary like "Environment ready (healed: <count>, warnings: <count>)".
30
+ - If `ok: false` → echo the validator's `note` verbatim as the actionable instruction for the user, plus the `blockers` list. Do not retry; the user must act.
31
+ 3. Do not generate any documentation. This skill is read/heal only.
32
+
33
+ ## Constraints
34
+
35
+ - Single-shot — one validator invocation, no loop.
36
+ - No editing of source code.
37
+ - No documentation generation. If the user wanted that, they'd have called `/document-node`.
@@ -0,0 +1,48 @@
1
+ ---
2
+ name: document-all-nodes
3
+ description: |
4
+ Find every node in @rosepetal/node-red-contrib-image-tools that lacks
5
+ documentation (no docs/<cat>/<name>.md or no assets/nodes/<cat>/<name>-demo.gif)
6
+ and run /document-node on each, sequentially. Reports a final table of
7
+ successes and failures. Pass --include-existing to re-document every
8
+ registered node, regardless of current state.
9
+ when_to_use: |
10
+ Trigger phrases: "document all nodes", "document missing nodes", "fill in
11
+ the missing docs", "regenerate all node docs". No required arguments.
12
+ argument-hint: "[--include-existing]"
13
+ allowed-tools: Read Bash Skill
14
+ disable-model-invocation: false
15
+ ---
16
+
17
+ # /document-all-nodes
18
+
19
+ Batch wrapper that runs `/document-node` for every orphan node in this repo.
20
+
21
+ ## Procedure
22
+
23
+ 1. **Discover orphans.** Read `package.json` and list `rp-*` keys under `node-red.nodes`. For each, derive the bare name and category (from the JS path). A node is an "orphan" when **either** `docs/nodes/<cat>/<name>.md` is missing **or** `assets/nodes/<cat>/<name>-demo.gif` is missing. Use `Bash` to run `find` / `test -f` rather than reading directories manually.
24
+
25
+ With `--include-existing`, treat every registered node as orphan.
26
+
27
+ 2. **Print a plan.** Show the user the list you'll process, in order. Sort by category, then alphabetically.
28
+
29
+ 3. **Process sequentially.** For each orphan, invoke `/document-node <name>` via the `Skill` tool and wait for the result before moving on. Why sequentially: the GIF recorder needs exclusive access to the headless browser page; running concurrent doc runs would race on Node-RED state.
30
+
31
+ 4. **Per-node bookkeeping.** Track success/failure for each. On failure, capture the failure reason but **continue** with the next node — don't abort the whole batch.
32
+
33
+ 5. **Final summary.** Print a Markdown table:
34
+
35
+ | Node | Category | .md | GIF | Status |
36
+ |---|---|---|---|---|
37
+ | folder-in | io | ✅ written | ✅ 312 KB | OK |
38
+ | add-bbs | blend | ✅ written | ❌ failed (size) | Reviewer flagged |
39
+ | … | … | … | … | … |
40
+
41
+ Then a one-line totals row: "X/Y nodes documented end-to-end. Z need manual review."
42
+
43
+ ## Hard rules
44
+
45
+ 1. **No parallelism.** Sequential only.
46
+ 2. **Don't skip Phase 0** for each `/document-node` run — the validator is idempotent and cheap; let it confirm the environment didn't drift mid-batch.
47
+ 3. **Don't keep going if Phase 0 fails for any node** — that's an environment problem affecting the whole batch. Stop and surface the validator's note immediately.
48
+ 4. **English only** in the final report and any per-node messages.
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: document-node
3
+ description: |
4
+ Autonomously generate complete documentation for a Node-RED node in
5
+ @rosepetal/node-red-contrib-image-tools. Produces (1) the long-form Markdown
6
+ at docs/nodes/<category>/<name>.md, (2) the inline <script data-help-name>
7
+ block inside the node's HTML, and (3) the demo GIF at
8
+ assets/nodes/<category>/<name>-demo.gif. Coordinates four specialist agents
9
+ through a 5-phase pipeline with active environment validation, self-healing,
10
+ and a reasoning post-review with up to 2 retries. All output is in English.
11
+ when_to_use: |
12
+ Trigger phrases: "document <name>", "document the <name> node", "regenerate
13
+ docs for <name>", "fix the docs of <name>", "documentar el nodo <name>",
14
+ "redocument <name>". Argument is the bare node name (without the rp- prefix).
15
+ argument-hint: "<node-name> [--force]"
16
+ allowed-tools: Read Edit Write Bash Agent Skill
17
+ disable-model-invocation: false
18
+ ---
19
+
20
+ # /document-node
21
+
22
+ Orchestrator for the autonomous documentation pipeline. You receive a single argument: the bare node name (e.g. `folder-in`, `add-bbs`, `image-out`). Optional flag `--force` skips the "already documented" early exit.
23
+
24
+ You drive the pipeline phase-by-phase, delegating to specialist subagents. Each subagent has its own restricted tools and system prompt; you only pass them what they need.
25
+
26
+ ## Phase 0 — Environment validation
27
+
28
+ Spawn `doc-env-validator` (foreground) with this prompt:
29
+
30
+ > Run the full environment validation playbook. The target node for this run is `<NAME>` in the `<CATEGORY>` category (the orchestrator will determine the category in Phase 1, you can ignore that here and verify generic prerequisites). Self-heal everything you can. Return your standard JSON contract object as the last line of your response.
31
+
32
+ If the validator returns `ok: false`, **stop**. Echo its `note` verbatim to the user as the actionable instruction; do not proceed to later phases. Do not try to work around an unreachable MCP — that's the one hard escape hatch.
33
+
34
+ ## Phase 1 — Source extraction (you do this in your own context)
35
+
36
+ Read the source for the target node:
37
+
38
+ 1. Look up the node in the repo's `package.json` `node-red.nodes` map. The key is `rp-<NAME>`; the value is the relative JS path (e.g. `node-red-contrib-image-tools/nodes/io/folder-in.js`). Derive the **category** from the path (`io`, `transform`, `mix`, `blend`, `specialized`).
39
+ 2. Read:
40
+ - `node-red-contrib-image-tools/nodes/<cat>/<name>.js`
41
+ - `node-red-contrib-image-tools/nodes/<cat>/<name>.html`
42
+ - `rosepetal-image-engine/src/<name>.cpp` if it exists (some nodes are pure JS)
43
+ - The closest sibling `.md` in `docs/nodes/<cat>/` to use as a tone anchor (any existing `.md` in the same category; pick the one nearest in complexity).
44
+ 3. Build a **structured spec** that you'll hand to `doc-writer`. The spec is plain English / structured Markdown, not JSON. It MUST contain:
45
+ - `name`, `category`, `display_name` (Title-cased), `since_version` (current `package.json` `version`)
46
+ - The full `defaults: { ... }` object verbatim
47
+ - For each defaults key, the widget type derived from the form template (TypedInput / select / checkbox / number / text / hidden)
48
+ - The msg paths the JS handler reads (typed-input resolved) and writes
49
+ - One-sentence summary of the C++ operation if present
50
+ - Path to the sibling `.md` you chose as the tone anchor
51
+
52
+ If `--force` was not passed and the `.md` already exists at `docs/nodes/<cat>/<name>.md`, skip generation and only run Phase 3 (GIF) + Phase 4 (review). Otherwise continue to Phase 2.
53
+
54
+ ## Phase 2 — Generate `.md` and HTML help block
55
+
56
+ Spawn `doc-writer` (foreground). Pass it the structured spec, plus the literal paths to the templates and prompts:
57
+
58
+ > You are producing documentation for `<NAME>` in `<CATEGORY>`. Use the spec below.
59
+ >
60
+ > Templates: `${CLAUDE_SKILL_DIR}/templates/node-doc.md.tmpl` and `${CLAUDE_SKILL_DIR}/templates/help-block.html.tmpl`.
61
+ >
62
+ > First, follow `${CLAUDE_SKILL_DIR}/prompts/synthesize-md.md` to produce `docs/nodes/<CATEGORY>/<NAME>.md`.
63
+ >
64
+ > Then, follow `${CLAUDE_SKILL_DIR}/prompts/synthesize-help.md` to rewrite the inline `<script data-help-name="rp-<NAME>">` block inside `node-red-contrib-image-tools/nodes/<CATEGORY>/<NAME>.html`.
65
+ >
66
+ > Spec:
67
+ >
68
+ > ```
69
+ > [structured spec here]
70
+ > ```
71
+ >
72
+ > Return the two paths you wrote/edited and any caveats.
73
+
74
+ If you're invoking `doc-writer` for a retry, append a `Fixes from previous review:` block listing the items the reviewer flagged.
75
+
76
+ ## Phase 3 — Record the demo GIF
77
+
78
+ Spawn `gif-recorder` (foreground) with:
79
+
80
+ > Record a demo GIF for the `<NAME>` node in the `<CATEGORY>` category. Editor URL: `<EDITOR_URL>` (default `http://127.0.0.1:1880/`). Fixture image: `<FIXTURE_PATH>` (the validator generated one if needed; otherwise look in `assets/test-fixtures/`). Output: `assets/nodes/<CATEGORY>/<NAME>-demo.gif`. Specs: 800px wide, 10 fps, ≤6 s, looped, ≤400 KB.
81
+ >
82
+ > Build the smallest demo flow that visibly exercises this node, capture the deploy → inject → result loop, and clean up. Return your JSON summary.
83
+
84
+ If the recorder returns `ok: false`, do NOT abandon the run. Move to Phase 4 with whatever the recorder produced (it may have left a partial GIF) and let the reviewer flag the GIF problem; the retry loop handles it.
85
+
86
+ ## Phase 4 — Review
87
+
88
+ Spawn `doc-reviewer` (foreground) with:
89
+
90
+ > Review the documentation for the `<NAME>` node in `<CATEGORY>`.
91
+ >
92
+ > Artefacts:
93
+ > - Markdown: `docs/nodes/<CATEGORY>/<NAME>.md`
94
+ > - HTML (help block): `node-red-contrib-image-tools/nodes/<CATEGORY>/<NAME>.html`
95
+ > - GIF: `assets/nodes/<CATEGORY>/<NAME>-demo.gif`
96
+ >
97
+ > Run the hard and soft checks from your system prompt. Return the `{ ok, fixes, notes }` JSON object.
98
+
99
+ **Decision tree:**
100
+ - `ok: true` → proceed to Phase 5.
101
+ - `ok: false` and retry count < 2 → loop back to Phase 2 with the reviewer's `fixes` (and Phase 3 again only if the GIF is among the issues).
102
+ - `ok: false` and retry count = 2 → stop. Report the remaining `fixes` to the user, leave the artefacts in place, exit with a clear message.
103
+
104
+ ## Phase 5 — README and summary
105
+
106
+ 1. Update the README node table at `README.md` (root). Add or update the row for this node in the right category section. Use a short factual purpose blurb derived from the new `.md`'s Overview.
107
+ 2. Print a final summary:
108
+ - Files written: `.md` path, `.html` (help block updated), `.gif` path.
109
+ - GIF size in KB.
110
+ - Total elapsed time (rough).
111
+ - `git status --porcelain` of the changed paths so the user can review.
112
+
113
+ ## Hard rules
114
+
115
+ 1. **Phase 0 must pass before any other phase runs.** No exceptions.
116
+ 2. **All artefacts are in English.** Every agent in this pipeline knows this; you don't need to remind them, but if you ever see Spanish slipping in, that's a `fixes` item for the reviewer.
117
+ 3. **Subagents do not chain.** You invoke them sequentially from this skill body. Doc-writer never calls gif-recorder, etc.
118
+ 4. **Max 2 retries** of Phase 2. After that, escalate to the user.
119
+ 5. **Never modify source code.** Only `docs/`, `assets/`, the inline `<script data-help-name>` block in HTML, and `README.md`.
120
+ 6. **Always clean up.** If a phase fails, the gif-recorder's cleanup of the demo flow is your safety net; verify it ran by calling `mcp__node-red__list-tabs` after Phase 3 and confirming the demo tab is gone.
121
+
122
+ ## Argument parsing
123
+
124
+ - `<node-name>`: required. Validate by checking `rp-<name>` exists in `package.json` `node-red.nodes`.
125
+ - `--force`: optional. Re-generate even if `.md` already exists. Without `--force`, an existing `.md` skips Phase 2.
126
+
127
+ ## Failure messages
128
+
129
+ - Phase 0 failed → "Documentation pipeline blocked: <validator note>. Fix and re-run /document-node."
130
+ - Phase 4 exhausted retries → "Documentation generated but reviewer flagged unresolved issues after 2 retries: <fixes list>. Artefacts left in place; please inspect docs/nodes/<cat>/<name>.md."
131
+ - GIF could not be made small enough → that's a Phase 4 fix; reviewer will retry Phase 3 specifically.
@@ -0,0 +1,33 @@
1
+ # Synthesize the inline `<script data-help-name="rp-...">` block
2
+
3
+ You are inside `doc-writer`. After producing the `.md`, your second job is to **rewrite the inline help block** inside `node-red-contrib-image-tools/nodes/<category>/<name>.html` so the editor's "info" pane stays in sync.
4
+
5
+ ## What to do
6
+
7
+ 1. Read `node-red-contrib-image-tools/nodes/<category>/<name>.html`.
8
+ 2. Locate the existing `<script type="text/x-red" data-help-name="rp-<name>">…</script>` block. There is exactly one. If it doesn't exist, the block is appended just before the closing of the file.
9
+ 3. Generate a new block by filling `templates/help-block.html.tmpl`.
10
+ 4. Replace the existing block with the new one using `Edit`. Don't touch anything else in the file.
11
+
12
+ ## Mapping from the spec
13
+
14
+ | Placeholder | What goes in |
15
+ |---|---|
16
+ | `{{name}}` | `spec.name`. |
17
+ | `{{summary_one_sentence}}` | The same one-sentence summary as the `.md`'s Overview's first sentence. |
18
+ | `{{details_paragraph}}` | 2–4 sentences. Slightly more technical than the summary. Mention the C++/OpenCV backend if applicable. |
19
+ | `{{properties_dl_entries}}` | One `<dt>/<dd>` pair per Configuration row in the same order as the `.md` table. Format: `<dt>Label <span class="property-type">type</span></dt><dd>description.</dd>`. |
20
+ | `{{input_type}}` | One of: `object`, `array`, `object \| array`, `Buffer`, `object \| Buffer`. Match what the JS handler accepts. |
21
+ | `{{input_description}}` | One sentence. Mention single image vs array. Cross-reference: `Standard image structure: { data, width, height, channels, colorSpace, dtype }.` |
22
+ | `{{output_type}}` | Same enum, what the node emits. Encoded formats are `Buffer`. |
23
+ | `{{output_description}}` | One sentence. Mention how the format is determined ("depends on Output Format setting"). |
24
+ | `{{examples_li_entries}}` | 2–4 `<li><strong>Use case:</strong> 1-line scenario</li>` items. Mirror the `.md`'s Examples but as compact list items. |
25
+ | `{{performance_paragraph}}` | One sentence on the C++ backend, async behaviour, and array-parallelism. |
26
+
27
+ ## Hard rules
28
+
29
+ 1. **English only.**
30
+ 2. **Properties match `.md` Configuration table exactly** — same fields, same order, same types, same defaults.
31
+ 3. **No marketing language.** "Uses OpenCV's optimized resize" is fine; "lightning-fast professional-grade" is not.
32
+ 4. **Don't touch the rest of the HTML.** No edits to the registration script, no edits to the form template. Only the `data-help-name` block.
33
+ 5. If the file has no closing `</body>` (it's a Node-RED partial, which is normal), simply locate the `data-help-name` block by regex and use `Edit` with the precise old/new strings.
@@ -0,0 +1,48 @@
1
+ # Synthesize the long-form `.md` for a node
2
+
3
+ You are inside `doc-writer`. The orchestrator handed you a structured spec of one node and the path to `templates/node-doc.md.tmpl`. Produce the `.md` file at `docs/nodes/<category>/<name>.md`.
4
+
5
+ ## Inputs you have
6
+
7
+ - `spec.name` — bare node name without `rp-` (e.g. `folder-in`).
8
+ - `spec.category` — one of `io`, `transform`, `mix`, `blend`, `specialized`.
9
+ - `spec.display_name` — Title-cased name for the H1 (e.g. "Folder-In").
10
+ - `spec.since_version` — the current `package.json` `version` field.
11
+ - `spec.defaults` — the `defaults: { ... }` object from the node's `*.html`, including TypedInput companion keys.
12
+ - `spec.template_form_widgets` — for each `defaults` key, the widget type derived from `<script type="text/html" data-template-name>` (TypedInput/select/checkbox/text/etc.).
13
+ - `spec.js_io` — what `msg` paths the JS handler reads (typed-input resolved) and writes.
14
+ - `spec.cpp_op` — the OpenCV operation in `rosepetal-image-engine/src/<name>.cpp` if applicable, with a one-sentence summary of its threading model and complexity.
15
+ - `spec.sibling_md_path` — path to the closest sibling `.md` in the same category, to mirror tone and depth.
16
+ - `spec.fixes` — optional. If the orchestrator is invoking you for a retry, this is the reviewer's list of corrections from the previous pass; address each before doing anything else.
17
+
18
+ ## What to produce
19
+
20
+ A complete `.md` file that follows `node-doc.md.tmpl` exactly. Replace every `{{placeholder}}`. Specifically:
21
+
22
+ | Placeholder | What goes in |
23
+ |---|---|
24
+ | `{{display_name}}` | Title-cased name. |
25
+ | `{{name}}` | `spec.name`. |
26
+ | `{{category_label}}` | One of: `I/O`, `Transform`, `Mix`, `Blend`, `Specialized`. |
27
+ | `{{since_version}}` | `spec.since_version`. |
28
+ | `{{overview_paragraph}}` | 1–3 sentences. State the operation and what makes this node distinct from neighbours. No marketing words. No "high-performance" / "lightning-fast" / similar. |
29
+ | `{{use_cases_bullets}}` | 3–5 bullets, real-world, concrete. Mirror the tone of the sibling `.md`. Not invented features. |
30
+ | `{{category}}` | `spec.category` (lowercased). |
31
+ | `{{inputs_section}}` | Bulleted list. For each msg path the node reads, one bullet: `- \`msg.<path>\` *(TypedInput)*: <one-line description, mention single-or-array behaviour if applicable>`. |
32
+ | `{{outputs_section}}` | Bulleted list of msg paths the node writes. |
33
+ | `{{performance_key}}` | The output of `NodeUtils.getPerformanceKey(node)` — typically the `name` lowercased with non-alphanumerics replaced by `_`. If unsure, use `spec.name`. |
34
+ | `{{configuration_rows}}` | One Markdown table row per `spec.defaults` key, in declaration order. Aggregate `<x>PathType` companions into the row of `<x>Path`. Columns: Field (human-readable label, e.g. "Input from" not `inputPath`); Type (TypedInput, enum, number, boolean, string, color, hex); Default (the literal default value, or "—" for empty strings); Description (short, factual, no fluff). |
35
+ | `{{examples_section}}` | 2–4 mini ASCII flows. Each followed by a one-line caption. Use realistic msg paths from `spec.js_io`. Don't invent. Format: a fenced code block with `[node-a] → [<this-node>] → [node-b]`. |
36
+ | `{{troubleshooting_section}}` | At most 5 entries. Format: `- **<symptom>** — Cause: … Solution: …`. Cover the genuine failure modes you can deduce from `defaults` validation in the JS handler (missing input, invalid dimensions, format mismatches). |
37
+ | `{{see_also_links}}` | 2–4 links to neighbouring nodes' `.md` from the same category, by relative path. |
38
+
39
+ ## Hard rules
40
+
41
+ 1. **English only.** Even if the conversation is in Spanish, the file is in English.
42
+ 2. **No invented parameters.** Every Configuration row maps to an actual key in `spec.defaults`.
43
+ 3. **No omitted parameters.** Every key in `spec.defaults` ends up in the Configuration table (companions can be aggregated; `name` is the only free pass).
44
+ 4. **GIF link is mandatory** at the position the template specifies. Path: `../../../assets/nodes/<category>/<name>-demo.gif`.
45
+ 5. **No cross-cutting concept duplication.** Don't restate the image format, typed-input mechanics, or error contract — link to `docs/concepts/` (even if those files don't exist yet; the link is a forward reference).
46
+ 6. **Mirror tone of `spec.sibling_md_path`.** If the sibling is concise (e.g. `draw.md`), be concise. If the sibling is exhaustive (e.g. `image-align.md`), match that depth.
47
+
48
+ After writing the file, return the path. Do not produce HTML in this prompt — that's `synthesize-help.md`.
@@ -0,0 +1,34 @@
1
+ <script type="text/x-red" data-help-name="rp-{{name}}">
2
+ <p>{{summary_one_sentence}}</p>
3
+
4
+ <h3>Details</h3>
5
+ <p>{{details_paragraph}}</p>
6
+
7
+ <h3>Properties</h3>
8
+ <dl class="message-properties">
9
+ {{properties_dl_entries}}
10
+ </dl>
11
+
12
+ <h3>Inputs</h3>
13
+ <dl class="message-properties">
14
+ <dt>payload <span class="property-type">{{input_type}}</span></dt>
15
+ <dd>{{input_description}}</dd>
16
+ </dl>
17
+
18
+ <h3>Outputs</h3>
19
+ <dl class="message-properties">
20
+ <dt>payload <span class="property-type">{{output_type}}</span></dt>
21
+ <dd>{{output_description}}</dd>
22
+ </dl>
23
+
24
+ <h3>Examples</h3>
25
+ <ul>
26
+ {{examples_li_entries}}
27
+ </ul>
28
+
29
+ <h3>Performance</h3>
30
+ <p>{{performance_paragraph}}</p>
31
+
32
+ <h3>Error Handling</h3>
33
+ <p>On invalid input or processing failure, <code>msg.error</code> is populated with <code>{ message, hint, details, operation, nodeId, nodeType, timestamp }</code> and the original payload is passed through unchanged so the flow continues.</p>
34
+ </script>
@@ -0,0 +1,43 @@
1
+ # {{display_name}} Node
2
+
3
+ > **Type**: `rp-{{name}}` · **Category**: {{category_label}} · **Since**: v{{since_version}}
4
+
5
+ ## Overview
6
+
7
+ {{overview_paragraph}}
8
+
9
+ **Use cases**
10
+ {{use_cases_bullets}}
11
+
12
+ ![{{display_name}} Demo](../../../assets/nodes/{{category}}/{{name}}-demo.gif)
13
+
14
+ ## Inputs
15
+
16
+ {{inputs_section}}
17
+
18
+ > Image-format details, the typed-input mechanism (`msg`/`flow`/`global`/literal), and the array-vs-single behaviour are documented in `docs/concepts/`. Don't restate them here.
19
+
20
+ ## Outputs
21
+
22
+ {{outputs_section}}
23
+
24
+ - `msg.performance.rpimage.{{performance_key}}`: `{ conversion, task, total }` in milliseconds.
25
+ - On failure: `msg.error = { message, hint, details, operation, nodeId, nodeName, nodeType, timestamp, validationError? }` and the original payload is passed through (`outputType: 'preserve'`).
26
+
27
+ ## Configuration
28
+
29
+ | Field | Type | Default | Description |
30
+ |---|---|---|---|
31
+ {{configuration_rows}}
32
+
33
+ ## Examples
34
+
35
+ {{examples_section}}
36
+
37
+ ## Troubleshooting
38
+
39
+ {{troubleshooting_section}}
40
+
41
+ ## See Also
42
+
43
+ {{see_also_links}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-darwin-arm64",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Prebuilt native binary for macOS ARM64 (Apple Silicon)",
5
5
  "os": ["darwin"],
6
6
  "cpu": ["arm64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-linux-arm64",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Prebuilt native binary for Linux ARM64 (glibc)",
5
5
  "os": ["linux"],
6
6
  "cpu": ["arm64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-linux-x64",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Prebuilt native binary for Linux x64 (glibc)",
5
5
  "os": ["linux"],
6
6
  "cpu": ["x64"],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rosepetal/node-red-contrib-image-tools-linuxmusl-x64",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "Prebuilt native binary for Linux x64 (musl/Alpine)",
5
5
  "os": ["linux"],
6
6
  "cpu": ["x64"],