skillhub/plugins/dsh/test/skill-format.test.ts
XiaoSeS 3560679793
Some checks failed
Deploy Docs / build (push) Has been cancelled
Security / Dependency Review (push) Has been cancelled
Security / CodeQL (java-kotlin) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Deploy Docs / Deploy (push) Has been cancelled
feat(dsh): add native SkillHub plugin for DeepSeek Harness (#956)
Add the native SkillHub plugin for DeepSeek Harness with a scoped skill center, conversation search/install tools, exact-version installation and protected lifecycle management. Prepare the independently versioned 0.1.0 npm candidate with an empty default Registry and documented compatibility limits.

Keep formal specifications and executable regression tests; remove archived development screenshots and runtime reports from the final tree. Review fixes cover independent scopes, installed references, pre-staging recovery and idempotent discovery.

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
2026-10-16 19:22:26 +08:00

32 lines
1.8 KiB
TypeScript

import { expect, test } from 'bun:test';
import { Context } from '@deepseek-ai/cordis';
import { realpath, mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { validateDshSkill } from '../src/host/skill-format.js';
test('official DSH provider validates a staged skill and its resources without registering it', async () => {
const directory = await realpath(await mkdtemp(join(tmpdir(), 'skillhub-format-')));
try {
await writeFile(join(directory, 'SKILL.md'), '---\nname: writer\ndescription: Write documents\nuser-invocable: true\n---\nRead references/note.md.');
await mkdir(join(directory, 'references'));
await writeFile(join(directory, 'references/note.md'), 'Resource');
const ctx = new Context();
await validateDshSkill(ctx, directory, new AbortController().signal);
expect(ctx.get('skills')).toBeUndefined();
await expect(validateDshSkill(ctx, directory, AbortSignal.abort())).rejects.toThrow();
} finally { await rm(directory, { recursive: true, force: true }); }
});
test.each([
'# No frontmatter',
'---\nname: writer\n---\nMissing description',
'---\nname: writer\ndescription: Write\nuser-invocable: invalid\n---\nBody',
'---\nname: writer\ndescription: Write\nmodelInvocable: true\n---\nLegacy invocation',
])('official parser rejects incompatible staged SKILL.md: %s', async content => {
const directory = await realpath(await mkdtemp(join(tmpdir(), 'skillhub-format-invalid-')));
try {
await writeFile(join(directory, 'SKILL.md'), content);
await expect(validateDshSkill(new Context(), directory, new AbortController().signal)).rejects.toThrow('not a valid DSH skill');
} finally { await rm(directory, { recursive: true, force: true }); }
});