chore(voyage): release v5.0.1 — drop standalone HTML render; print literal /playground document-critique invocation
The v5.0.0 stop-gap had /trekbrief, /trekplan, and /trekreview each render
a read-only {artifact}.html (via scripts/render-artifact.mjs) AND print a
vague "run the /playground plugin" instruction. In practice the read-only
HTML was redundant with what /playground produces and the instruction
wasn't copy-paste-ready — the operator had to guess the right invocation.
v5.0.1 deletes scripts/render-artifact.mjs + its test + npm run render,
and makes each producing command end with a single boxed, literal,
copy-paste-ready line:
/playground build a document-critique playground for {artifact_path}
One paste from the operator launches the official playground skill's
document-critique template, which builds an interactive HTML — artifact
on the left, per-line Approve/Reject/Comment cards on the right, Copy
Prompt button at the bottom. Mark suggestions, click Copy Prompt, paste
back, Claude revises the .md. Doc-consistency test pins the literal
invocation so the prose cannot soften back into vagueness.
npm test green: 503 tests, 501 pass, 0 fail, 2 skipped.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
916d30f63e
commit
2e0892cdaf
15 changed files with 206 additions and 563 deletions
|
|
@ -1,122 +0,0 @@
|
|||
// tests/scripts/render-artifact.test.mjs
|
||||
// Covers scripts/render-artifact.mjs — the v5.0.0 self-contained HTML
|
||||
// renderer that /trekbrief, /trekplan, /trekreview call at the end of their
|
||||
// run to produce a browser-readable view of the just-written artifact.
|
||||
|
||||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { mkdtempSync, writeFileSync, readFileSync, rmSync, existsSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { buildHtml, renderMarkdown, render, parseArgs } from '../../scripts/render-artifact.mjs';
|
||||
|
||||
const SAMPLE = `---
|
||||
type: trekplan
|
||||
plan_version: "1.7"
|
||||
task: "Render-artifact smoke test"
|
||||
slug: render-smoke
|
||||
---
|
||||
|
||||
# Render-artifact smoke test
|
||||
|
||||
A paragraph with **bold**, \`inline code\`, and a [link](https://example.com).
|
||||
|
||||
## Steps
|
||||
|
||||
- top item
|
||||
- nested item
|
||||
- second top item
|
||||
|
||||
1. ordered one
|
||||
2. ordered two
|
||||
|
||||
\`\`\`js
|
||||
const x = 1;
|
||||
\`\`\`
|
||||
|
||||
> a blockquote line
|
||||
|
||||
| Col A | Col B |
|
||||
|-------|-------|
|
||||
| 1 | 2 |
|
||||
`;
|
||||
|
||||
test('buildHtml produces a complete self-contained HTML document', () => {
|
||||
const html = buildHtml('plan.md', SAMPLE);
|
||||
assert.ok(html.startsWith('<!DOCTYPE html>'), 'must start with doctype');
|
||||
assert.ok(html.includes('</html>'), 'must close html');
|
||||
assert.ok(html.includes('<style>'), 'must inline a stylesheet');
|
||||
// Zero external network references.
|
||||
assert.ok(!/<link[^>]+href=/i.test(html), 'no external <link> stylesheets');
|
||||
assert.ok(!/<script[^>]+src=/i.test(html), 'no external <script src>');
|
||||
assert.ok(!/https?:\/\/(?!example\.com)/.test(html.replace(/<style>[\s\S]*?<\/style>/, '')), 'no unexpected http(s) URLs outside example link');
|
||||
});
|
||||
|
||||
test('buildHtml folds frontmatter into a <details> block', () => {
|
||||
const html = buildHtml('plan.md', SAMPLE);
|
||||
assert.ok(html.includes('<details class="frontmatter">'), 'frontmatter wrapped in <details>');
|
||||
assert.ok(html.includes('plan_version'), 'frontmatter content preserved');
|
||||
// Frontmatter must NOT leak into the rendered body as a literal "---" rule.
|
||||
const bodyOnly = html.split('</details>')[1] || '';
|
||||
assert.ok(!bodyOnly.startsWith('\n<hr>'), 'frontmatter fence should not become an <hr>');
|
||||
});
|
||||
|
||||
test('buildHtml derives the <title> from frontmatter task', () => {
|
||||
const html = buildHtml('plan.md', SAMPLE);
|
||||
assert.match(html, /<title>Render-artifact smoke test<\/title>/);
|
||||
});
|
||||
|
||||
test('renderMarkdown renders headings, code fences, lists, tables, blockquotes', () => {
|
||||
const out = renderMarkdown(SAMPLE.split('---\n').slice(2).join('---\n'));
|
||||
assert.match(out, /<h1>Render-artifact smoke test<\/h1>/);
|
||||
assert.match(out, /<h2>Steps<\/h2>/);
|
||||
assert.match(out, /<pre><code class="language-js">/);
|
||||
assert.ok(out.includes('const x = 1;'), 'code fence body preserved');
|
||||
assert.match(out, /<ul><li>top item<ul><li>nested item<\/li><\/ul><\/li>/);
|
||||
assert.match(out, /<ol><li>ordered one<\/li><li>ordered two<\/li><\/ol>/);
|
||||
assert.match(out, /<blockquote>a blockquote line<\/blockquote>/);
|
||||
assert.match(out, /<table>[\s\S]*<th>Col A<\/th>[\s\S]*<td>1<\/td>[\s\S]*<\/table>/);
|
||||
assert.match(out, /<strong>bold<\/strong>/);
|
||||
assert.match(out, /<code>inline code<\/code>/);
|
||||
assert.match(out, /<a href="https:\/\/example\.com">link<\/a>/);
|
||||
});
|
||||
|
||||
test('renderMarkdown escapes HTML in body and code', () => {
|
||||
const out = renderMarkdown('A <tag> & "quote".\n\n```\n<script>alert(1)</script>\n```\n');
|
||||
assert.ok(!out.includes('<tag>'), 'raw tag escaped');
|
||||
assert.ok(out.includes('<tag>'), 'tag rendered as entity');
|
||||
assert.ok(out.includes('<script>alert(1)</script>'), 'code-fence content escaped');
|
||||
});
|
||||
|
||||
test('render() is deterministic — two runs byte-identical', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'render-artifact-'));
|
||||
try {
|
||||
const md = join(dir, 'plan.md');
|
||||
writeFileSync(md, SAMPLE);
|
||||
const out1 = render(md, join(dir, 'a.html'));
|
||||
const out2 = render(md, join(dir, 'b.html'));
|
||||
assert.ok(existsSync(out1) && existsSync(out2));
|
||||
assert.equal(readFileSync(out1, 'utf-8'), readFileSync(out2, 'utf-8'));
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('render() defaults output to <input-basename>.html', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'render-artifact-'));
|
||||
try {
|
||||
const md = join(dir, 'review.md');
|
||||
writeFileSync(md, '# Review\n\nok\n');
|
||||
const out = render(md);
|
||||
assert.equal(out, join(dir, 'review.html'));
|
||||
assert.ok(existsSync(out));
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('parseArgs handles --out and positional input', () => {
|
||||
assert.deepEqual(parseArgs(['x.md']), { input: 'x.md', out: null, help: false });
|
||||
assert.deepEqual(parseArgs(['x.md', '--out', 'y.html']), { input: 'x.md', out: 'y.html', help: false });
|
||||
assert.equal(parseArgs(['--help']).help, true);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue