#!/usr/bin/env node // PROTOTYPE — three visual directions for one real workflow artifact, // switchable with ?variant=signal|blueprint|ember and a floating bottom bar. import { spawnSync } from 'node:child_process'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const here = path.dirname(fileURLToPath(import.meta.url)); const repoRoot = path.resolve(here, '../..'); const skillRoot = path.join(repoRoot, 'archify'); const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-visual-prototype-')); const input = path.join(tmp, 'workflow.json'); const rendered = path.join(tmp, 'workflow.html'); const output = path.join(here, 'prototype.html'); try { const source = JSON.parse(fs.readFileSync( path.join(skillRoot, 'examples/agent-tool-call.workflow.json'), 'utf8', )); // Keep the three experimental treatments isolated from the production // preset now carried by the bundled workflow example. source.meta = { ...source.meta, animation: 'trace', visual_preset: 'classic' }; delete source.meta.output; fs.writeFileSync(input, `${JSON.stringify(source, null, 2)}\n`); const result = spawnSync(process.execPath, [ path.join(skillRoot, 'renderers/workflow/render-workflow.mjs'), input, rendered, ], { encoding: 'utf8' }); if (result.status !== 0) { throw new Error(result.stderr || result.stdout || 'workflow render failed'); } let html = fs.readFileSync(rendered, 'utf8'); html = html.replace('', `${prototypeStyle()}\n`); html = html.replace('', `${prototypeSwitcher()}\n${prototypeScript()}\n`); fs.writeFileSync(output, html); console.log(output); } finally { fs.rmSync(tmp, { recursive: true, force: true }); } function prototypeStyle() { return ` `; } function prototypeSwitcher() { return `
`; } function prototypeScript() { return ` `; }