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
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:
53
packages/contracts/tests/critique.test.ts
Normal file
53
packages/contracts/tests/critique.test.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
panelEventToSse,
|
||||
CRITIQUE_SSE_EVENT_NAMES,
|
||||
type PanelEvent,
|
||||
} from '../src/critique';
|
||||
|
||||
describe('CritiqueSseEvent', () => {
|
||||
it('panelEventToSse maps PanelEvent.type "run_started" to event "critique.run_started"', () => {
|
||||
const e: PanelEvent = {
|
||||
type: 'run_started', runId: 'r1', protocolVersion: 1,
|
||||
cast: ['designer','critic','brand','a11y','copy'],
|
||||
maxRounds: 3, threshold: 8, scale: 10,
|
||||
};
|
||||
const sse = panelEventToSse(e);
|
||||
expect(sse.event).toBe('critique.run_started');
|
||||
expect(sse.data).toMatchObject({
|
||||
runId: 'r1', protocolVersion: 1, maxRounds: 3, threshold: 8, scale: 10,
|
||||
});
|
||||
// No 'type' field on the SSE payload.
|
||||
expect((sse.data as Record<string, unknown>).type).toBeUndefined();
|
||||
});
|
||||
|
||||
it('panelEventToSse round-trips every PanelEvent type', () => {
|
||||
const samples: PanelEvent[] = [
|
||||
{ type: 'run_started', runId: 'r', protocolVersion: 1, cast: ['critic'], maxRounds: 3, threshold: 8, scale: 10 },
|
||||
{ type: 'panelist_open', runId: 'r', round: 1, role: 'designer' },
|
||||
{ type: 'panelist_dim', runId: 'r', round: 1, role: 'critic', dimName: 'contrast', dimScore: 4, dimNote: '' },
|
||||
{ type: 'panelist_must_fix', runId: 'r', round: 1, role: 'a11y', text: '' },
|
||||
{ type: 'panelist_close', runId: 'r', round: 1, role: 'critic', score: 6 },
|
||||
{ type: 'round_end', runId: 'r', round: 1, composite: 6, mustFix: 7, decision: 'continue', reason: '' },
|
||||
{ type: 'ship', runId: 'r', round: 3, composite: 8.6, status: 'shipped', artifactRef: { projectId: 'p', artifactId: 'a' }, summary: '' },
|
||||
{ type: 'degraded', runId: 'r', reason: 'malformed_block', adapter: 'pi-rpc' },
|
||||
{ type: 'interrupted', runId: 'r', bestRound: 2, composite: 7.86 },
|
||||
{ type: 'failed', runId: 'r', cause: 'cli_exit_nonzero' },
|
||||
{ type: 'parser_warning', runId: 'r', kind: 'weak_debate', position: 0 },
|
||||
];
|
||||
for (const e of samples) {
|
||||
const sse = panelEventToSse(e);
|
||||
expect(sse.event).toBe(`critique.${e.type}`);
|
||||
}
|
||||
});
|
||||
|
||||
it('CRITIQUE_SSE_EVENT_NAMES contains all 11 critique.* names', () => {
|
||||
expect(CRITIQUE_SSE_EVENT_NAMES).toContain('critique.run_started');
|
||||
expect(CRITIQUE_SSE_EVENT_NAMES).toContain('critique.parser_warning');
|
||||
expect(CRITIQUE_SSE_EVENT_NAMES.length).toBe(11);
|
||||
// Each name has the 'critique.' prefix.
|
||||
for (const name of CRITIQUE_SSE_EVENT_NAMES) {
|
||||
expect(name.startsWith('critique.')).toBe(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
50
packages/contracts/tests/package-runtime.test.ts
Normal file
50
packages/contracts/tests/package-runtime.test.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { access } from 'node:fs/promises';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const packageRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
|
||||
function readPackageJson(): {
|
||||
exports?: Record<string, { default?: string; types?: string }>;
|
||||
files?: string[];
|
||||
main?: string;
|
||||
types?: string;
|
||||
} {
|
||||
return JSON.parse(readFileSync(join(packageRoot, 'package.json'), 'utf8'));
|
||||
}
|
||||
|
||||
describe('@open-design/contracts package runtime shape', () => {
|
||||
it('exports built JavaScript instead of TypeScript source files', () => {
|
||||
const pkg = readPackageJson();
|
||||
|
||||
expect(pkg.main).toBe('./dist/index.mjs');
|
||||
expect(pkg.types).toBe('./dist/index.d.ts');
|
||||
expect(pkg.files).toEqual(['dist']);
|
||||
expect(pkg.exports?.['.']?.default).toBe('./dist/index.mjs');
|
||||
expect(pkg.exports?.['.']?.types).toBe('./dist/index.d.ts');
|
||||
expect(pkg.exports?.['./critique']?.default).toBe('./dist/critique.mjs');
|
||||
expect(pkg.exports?.['./critique']?.types).toBe('./dist/critique.d.ts');
|
||||
});
|
||||
|
||||
it('points every runtime export at generated files', async () => {
|
||||
await expect(access(join(packageRoot, 'dist/index.mjs'))).resolves.toBeUndefined();
|
||||
await expect(access(join(packageRoot, 'dist/index.d.ts'))).resolves.toBeUndefined();
|
||||
await expect(access(join(packageRoot, 'dist/critique.mjs'))).resolves.toBeUndefined();
|
||||
await expect(access(join(packageRoot, 'dist/critique.d.ts'))).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it('makes runtime exports importable through package exports', async () => {
|
||||
const contracts = await import('@open-design/contracts');
|
||||
const critique = await import('@open-design/contracts/critique');
|
||||
|
||||
expect(contracts.composeSystemPrompt).toEqual(expect.any(Function));
|
||||
expect(contracts.exampleHealthResponse).toEqual({ ok: true, service: 'daemon' });
|
||||
expect(critique.defaultCritiqueConfig()).toMatchObject({
|
||||
enabled: false,
|
||||
protocolVersion: critique.CRITIQUE_PROTOCOL_VERSION,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user