mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-27 23:58:51 +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>
44 lines
2.6 KiB
TypeScript
44 lines
2.6 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { randomUUID } from 'node:crypto';
|
|
import type { SessionLogSnapshot } from '@deepseek-ai/dsh-session-query';
|
|
import { historicalSearchCandidate } from '../src/host/conversation-history.js';
|
|
|
|
const ref = randomUUID();
|
|
const scope = { sessionId: 'owner', cwd: '/project', sourceRevision: randomUUID() };
|
|
const source = 'https://registry.example';
|
|
function history() {
|
|
return {
|
|
session: { id: 'owner', cwd: '/project' }, inheritedEventCount: 0,
|
|
events: [
|
|
{ type: 'tool/call', data: { callId: 'call', name: 'astron_skillhub_search', turn: 1, step: 1 } },
|
|
{ type: 'tool/result', data: { turn: 1, step: 1,
|
|
message: { toolCallId: 'call', source: { kind: 'tool', callId: 'call' }, isError: false },
|
|
meta: { schemaVersion: 1, kind: 'skillhub-search', query: 'writer', sourceRevision: randomUUID(),
|
|
sourceLabel: source, createdAt: new Date().toISOString(), total: 1, returned: 1, limit: 20,
|
|
items: [{ namespace: 'team', slug: 'writer', latestVersion: '1.0.0', summary: '', selectionRef: ref }] } } },
|
|
],
|
|
};
|
|
}
|
|
function read(value = history(), reference = ref) {
|
|
return historicalSearchCandidate(value as unknown as SessionLogSnapshot, scope, source, 'call', reference);
|
|
}
|
|
test('history binds persisted candidate and exact version while allowing a new process revision', () => {
|
|
expect(read()).toEqual({ namespace: 'team', slug: 'writer', version: '1.0.0' });
|
|
expect(read(history(), randomUUID())).toBeUndefined();
|
|
});
|
|
test('history rejects foreign, failed, inherited, ambiguous, reordered and unsupported results', () => {
|
|
const changes: ((value: ReturnType<typeof history>) => void)[] = [
|
|
h => { h.session.id = 'other'; }, h => { h.session.cwd = '/other'; },
|
|
h => { h.inheritedEventCount = 2; }, h => { h.events[0]!.data.name = 'other'; },
|
|
h => { h.events[1]!.data.message!.isError = true; },
|
|
h => { h.events[1]!.data.message!.source.callId = 'other'; },
|
|
h => { h.events[1]!.data.message!.toolCallId = 'other'; },
|
|
h => { h.events[1]!.data.turn = 2; }, h => { h.events[1]!.data.step = 2; },
|
|
h => { h.events[1]!.data.meta!.schemaVersion = 2; },
|
|
h => { h.events[1]!.data.meta!.sourceLabel = 'https://other.example'; },
|
|
h => { h.events.push(h.events[0]!); }, h => { h.events.push(h.events[1]!); },
|
|
h => { h.events.reverse(); },
|
|
h => { const meta = h.events[1]!.data.meta!; meta.items.push(meta.items[0]!); meta.returned = meta.total = 2; },
|
|
];
|
|
for (const change of changes) { const value = history(); change(value); expect(read(value)).toBeUndefined(); }
|
|
});
|