mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-16 09:21:18 +00:00
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
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>
40 lines
2.4 KiB
TypeScript
40 lines
2.4 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { Context } from '@deepseek-ai/cordis';
|
|
import { FileSystemSkillProvider } from '@deepseek-ai/dsh-skill-filesystem';
|
|
import { realpath, mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { observeDshInstallation } from '../src/host/skill-discovery.js';
|
|
|
|
test('scoped discovery requires the exact directory, body and parsed invocation metadata', async () => {
|
|
const directory = await realpath(await mkdtemp(join(tmpdir(), 'skillhub-discovery-')));
|
|
const ctx = new Context();
|
|
const signal = new AbortController().signal;
|
|
const provider = new FileSystemSkillProvider(ctx, { signal, invalidate: () => {} }, {
|
|
providerName: 'fixture', includeDefaultRoots: false, customSkillDirs: [directory], watch: false,
|
|
});
|
|
try {
|
|
await writeFile(join(directory, 'SKILL.md'), '---\nname: actual-name\ndescription: Write documents\n---\nRead references/note.md.');
|
|
const listed = await provider.list({ signal });
|
|
const candidates = Array.isArray(listed) ? listed : listed.candidates;
|
|
const loaded = await provider.get(candidates[0]!, { signal });
|
|
if (!loaded) throw new Error('Missing fixture');
|
|
const lookup = async (name: string) => { expect(name).toBe('actual-name'); return loaded; };
|
|
expect(await observeDshInstallation(ctx, [directory], signal, lookup)).toBe(true);
|
|
expect(await observeDshInstallation(ctx, [], signal, lookup)).toBe(false);
|
|
expect(await observeDshInstallation(ctx, [directory], signal, async () => undefined)).toBe(false);
|
|
expect(await observeDshInstallation(ctx, [directory], signal,
|
|
async () => ({ ...loaded, resourceBase: { kind: 'directory', path: join(directory, 'other') } }))).toBe(false);
|
|
expect(await observeDshInstallation(ctx, [directory], signal,
|
|
async () => ({ ...loaded, content: 'Stale cached body' }))).toBe(false);
|
|
expect(await observeDshInstallation(ctx, [directory], signal,
|
|
async () => ({ ...loaded, description: 'Other description' }))).toBe(false);
|
|
expect(await observeDshInstallation(ctx, [directory], signal,
|
|
async () => ({ ...loaded, metadata: { changed: true } }))).toBe(false);
|
|
await expect(observeDshInstallation(ctx, [directory], AbortSignal.abort(), lookup)).rejects.toThrow();
|
|
expect(ctx.get('skills')).toBeUndefined();
|
|
} finally {
|
|
await provider.dispose();
|
|
await rm(directory, { recursive: true, force: true });
|
|
}
|
|
});
|