Initial import: open-design source for helix-mind.ai distribution
Some checks failed
ci / Validate workspace (push) Successful in 12m32s
landing-page-ci / Validate landing page (push) Successful in 9m41s
landing-page-deploy / Deploy landing page (push) Failing after 5m23s
github-metrics / Generate repository metrics SVG (push) Failing after 2m6s
refresh-contributors-wall / Refresh contributors wall cache bust (push) Failing after 12s

This repository contains the open-design daemon CLI source code, built
and packaged at https://helix-mind.ai/cli/open-design/latest.tgz for use
by the HelixMind /design slash command.

Licenses: Apache-2.0 (root) + MIT (skills/*)
This commit is contained in:
marco
2026-05-06 20:50:24 +02:00
commit 5dd70b5016
1336 changed files with 287186 additions and 0 deletions

View File

@@ -0,0 +1,120 @@
import { describe, expect, it } from 'vitest';
import {
artifactManifestNameFor,
createHtmlArtifactManifest,
inferLegacyManifest,
parseArtifactManifest,
} from '../../src/artifacts/manifest';
describe('parseArtifactManifest', () => {
it('returns null for malformed json', () => {
expect(parseArtifactManifest('{"version":1')).toBeNull();
});
it('returns null when required fields are missing', () => {
expect(parseArtifactManifest(JSON.stringify({ version: 1, kind: 'html' }))).toBeNull();
});
it('returns null for wrong version', () => {
const raw = JSON.stringify({
version: 2,
kind: 'html',
title: 'x',
entry: 'index.html',
renderer: 'html',
exports: ['html'],
});
expect(parseArtifactManifest(raw)).toBeNull();
});
it('defaults status to complete when missing', () => {
const raw = JSON.stringify({
version: 1,
kind: 'html',
title: 'x',
entry: 'index.html',
renderer: 'html',
exports: ['html'],
});
const out = parseArtifactManifest(raw);
expect(out?.status).toBe('complete');
});
it('preserves valid status when provided', () => {
const raw = JSON.stringify({
version: 1,
kind: 'html',
title: 'x',
entry: 'index.html',
renderer: 'html',
status: 'streaming',
exports: ['html'],
});
const out = parseArtifactManifest(raw);
expect(out?.status).toBe('streaming');
});
});
describe('inferLegacyManifest', () => {
it('infers markdown manifests for .md files', () => {
const out = inferLegacyManifest({ entry: 'README.md' });
expect(out?.kind).toBe('markdown-document');
expect(out?.renderer).toBe('markdown');
expect(out?.status).toBe('complete');
});
it('infers svg manifests for .svg files', () => {
const out = inferLegacyManifest({ entry: 'logo.svg' });
expect(out?.kind).toBe('svg');
expect(out?.renderer).toBe('svg');
expect(out?.status).toBe('complete');
});
it('returns null for non-artifact file types', () => {
expect(inferLegacyManifest({ entry: 'photo.png' })).toBeNull();
expect(inferLegacyManifest({ entry: 'archive.bin' })).toBeNull();
});
it('infers React component artifacts from JSX and TSX entries', () => {
expect(inferLegacyManifest({ entry: 'Card.jsx' })).toMatchObject({
kind: 'react-component',
renderer: 'react-component',
exports: ['jsx', 'html', 'zip'],
});
expect(inferLegacyManifest({ entry: 'Card.tsx' })).toMatchObject({
kind: 'react-component',
renderer: 'react-component',
exports: ['jsx', 'html', 'zip'],
});
});
});
describe('artifactManifestNameFor', () => {
it('handles names without extension', () => {
expect(artifactManifestNameFor('README')).toBe('README.artifact.json');
});
it('handles names with multiple dots', () => {
expect(artifactManifestNameFor('page.v2.final.html')).toBe('page.v2.final.html.artifact.json');
});
it('avoids collisions between different extensions', () => {
expect(artifactManifestNameFor('foo.html')).not.toBe(artifactManifestNameFor('foo.md'));
});
});
describe('createHtmlArtifactManifest', () => {
it('creates expected default html manifest shape', () => {
const out = createHtmlArtifactManifest({ entry: 'index.html', title: 'Landing' });
expect(out.version).toBe(1);
expect(out.kind).toBe('html');
expect(out.renderer).toBe('html');
expect(out.status).toBe('complete');
expect(out.exports).toEqual(['html', 'pdf', 'zip']);
expect(out.entry).toBe('index.html');
expect(out.title).toBe('Landing');
expect(typeof out.createdAt).toBe('string');
expect(typeof out.updatedAt).toBe('string');
});
});

View File

@@ -0,0 +1,71 @@
import { describe, expect, it } from 'vitest';
import { renderMarkdownToSafeHtml } from '../../src/artifacts/markdown';
describe('renderMarkdownToSafeHtml', () => {
it('renders common markdown blocks', () => {
const md = [
'# Title',
'',
'Paragraph with **bold** and *italic* and `code`.',
'',
'- one',
'- two',
'',
'1. first',
'2. second',
'',
'> note line',
'',
'```',
'const x = 1 < 2;',
'```',
].join('\n');
const out = renderMarkdownToSafeHtml(md);
expect(out).toContain('<h1>Title</h1>');
expect(out).toContain('<p>Paragraph with <strong>bold</strong> and <em>italic</em> and <code>code</code>.</p>');
expect(out).toContain('<ul><li>one</li><li>two</li></ul>');
expect(out).toContain('<ol><li>first</li><li>second</li></ol>');
expect(out).toContain('<blockquote>note line</blockquote>');
expect(out).toContain('<pre><code>const x = 1 &lt; 2;</code></pre>');
});
it('escapes raw html', () => {
const out = renderMarkdownToSafeHtml('<script>alert(1)</script>');
expect(out).toContain('&lt;script&gt;alert(1)&lt;/script&gt;');
expect(out).not.toContain('<script>');
});
it('renders safe links with target attributes', () => {
const out = renderMarkdownToSafeHtml('[Open](https://example.com)');
expect(out).toContain('<a href="https://example.com" rel="noreferrer noopener" target="_blank">Open</a>');
});
it('keeps underscores inside href intact', () => {
const out = renderMarkdownToSafeHtml('[x](https://example.com/a_b_c)');
expect(out).toContain('<a href="https://example.com/a_b_c" rel="noreferrer noopener" target="_blank">x</a>');
expect(out).not.toContain('<em>b</em>');
});
it('escapes raw html inside link text', () => {
const out = renderMarkdownToSafeHtml('[<img src=x onerror=alert(1)>](https://example.com)');
expect(out).toContain('&lt;img src=x onerror=alert(1)&gt;');
expect(out).not.toContain('<img ');
});
it('keeps markdown emphasis markers literal inside inline code', () => {
const out = renderMarkdownToSafeHtml('Use `**literal**` and `_literal_` as code.');
expect(out).toContain('<code>**literal**</code>');
expect(out).toContain('<code>_literal_</code>');
expect(out).not.toContain('<code><strong>literal</strong></code>');
expect(out).not.toContain('<code><em>literal</em></code>');
});
it('does not render unsafe link protocols', () => {
const out = renderMarkdownToSafeHtml('[Bad](javascript:alert(1))');
expect(out).toContain('<p>Bad)</p>');
expect(out).not.toContain('javascript:');
expect(out).not.toContain('<a ');
});
});

View File

@@ -0,0 +1,168 @@
import { describe, expect, it } from 'vitest';
import {
DeckHtmlRenderer,
HtmlRenderer,
MarkdownRenderer,
ReactComponentRenderer,
RendererRegistry,
SvgRenderer,
artifactRendererRegistry,
} from '../../src/artifacts/renderer-registry';
import { renderMarkdownToSafeHtml } from '../../src/artifacts/markdown';
import type { ProjectFile } from '../../src/types';
function baseFile(overrides: Partial<ProjectFile> & Pick<ProjectFile, 'name'>): ProjectFile {
return {
path: 'artifact.html',
type: 'file',
size: 1,
mtime: Date.now(),
kind: 'html',
mime: 'text/html; charset=utf-8',
...overrides,
};
}
describe('RendererRegistry', () => {
const registry = new RendererRegistry([
ReactComponentRenderer,
DeckHtmlRenderer,
HtmlRenderer,
MarkdownRenderer,
SvgRenderer,
]);
it('resolves markdown renderer from explicit manifest', () => {
const file = baseFile({
name: 'notes.md',
kind: 'text',
mime: 'text/markdown; charset=utf-8',
artifactManifest: {
version: 1,
kind: 'markdown-document',
title: 'Notes',
entry: 'notes.md',
renderer: 'markdown',
exports: ['md', 'html'],
},
});
const match = registry.resolve({ file, isDeckHint: false });
expect(match?.renderer.id).toBe('markdown');
expect(match?.manifest.renderer).toBe('markdown');
});
it('falls back to inferred markdown manifest for .md files', () => {
const file = baseFile({
name: 'README.md',
kind: 'text',
mime: 'text/markdown; charset=utf-8',
artifactManifest: undefined,
});
const match = registry.resolve({ file, isDeckHint: false });
expect(match?.renderer.id).toBe('markdown');
expect(match?.manifest.kind).toBe('markdown-document');
});
it('resolves svg renderer from explicit manifest', () => {
const file = baseFile({
name: 'diagram.svg',
kind: 'sketch',
mime: 'image/svg+xml',
artifactManifest: {
version: 1,
kind: 'svg',
title: 'Diagram',
entry: 'diagram.svg',
renderer: 'svg',
exports: ['svg'],
},
});
const match = registry.resolve({ file, isDeckHint: false });
expect(match?.renderer.id).toBe('svg');
expect(match?.manifest.renderer).toBe('svg');
});
it('falls back to inferred svg manifest for .svg files', () => {
const file = baseFile({
name: 'logo.svg',
kind: 'sketch',
mime: 'image/svg+xml',
artifactManifest: undefined,
});
const match = registry.resolve({ file, isDeckHint: false });
expect(match?.renderer.id).toBe('svg');
expect(match?.manifest.kind).toBe('svg');
});
it('keeps unknown files on old fallback path', () => {
const file = baseFile({
name: 'archive.bin',
kind: 'binary',
mime: 'application/octet-stream',
artifactManifest: undefined,
});
expect(registry.resolve({ file, isDeckHint: false })).toBeNull();
});
it('exposes conservative streaming contract values', () => {
expect(HtmlRenderer.supportsStreaming).toBe(false);
expect(DeckHtmlRenderer.supportsStreaming).toBe(false);
expect(MarkdownRenderer.supportsStreaming).toBe(true);
expect(MarkdownRenderer.renderPartial).toBe(renderMarkdownToSafeHtml);
expect(SvgRenderer.supportsStreaming).toBe(false);
expect(SvgRenderer.renderPartial).toBeUndefined();
});
it('keeps markdown partial renderer output safe', () => {
const out = MarkdownRenderer.renderPartial?.('[<script>alert(1)</script>](https://example.com/a_b_c)') ?? '';
expect(out).toContain('&lt;script&gt;alert(1)&lt;/script&gt;');
expect(out).toContain('href="https://example.com/a_b_c"');
expect(out).not.toContain('<script>');
});
it('routes JSX and TSX files to the React component renderer', () => {
expect(
artifactRendererRegistry.resolve({
file: baseFile({
name: 'Hero.jsx',
kind: 'code',
mime: 'text/javascript; charset=utf-8',
}),
isDeckHint: false,
})?.renderer.id,
).toBe('react-component');
expect(
artifactRendererRegistry.resolve({
file: baseFile({
name: 'Hero.tsx',
kind: 'code',
mime: 'text/typescript; charset=utf-8',
}),
isDeckHint: false,
})?.renderer.id,
).toBe('react-component');
});
it('prefers an explicit React manifest over the coarse code kind', () => {
expect(
artifactRendererRegistry.resolve({
file: baseFile({
name: 'entry.txt',
kind: 'text',
artifactManifest: {
version: 1,
kind: 'react-component',
title: 'Entry',
entry: 'entry.txt',
renderer: 'react-component',
exports: ['jsx', 'html', 'zip'],
},
}),
isDeckHint: false,
})?.renderer.id,
).toBe('react-component');
});
});