skillhub/plugins/dsh/test/integration/operation-failure-fixture.mjs
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

46 lines
3 KiB
JavaScript

import { randomUUID } from 'node:crypto';
import assert from 'node:assert/strict';
import { access, mkdir, realpath, writeFile } from 'node:fs/promises';
import { join, resolve, sep } from 'node:path';
import { fileURLToPath } from 'node:url';
import { setTimeout as delay } from 'node:timers/promises';
import { tmpdir } from 'node:os';
export const inject = ['sessionController', 'workspaceRegistry', 'tools', 'sessions', 'skillhub', 'clientModules'];
export function apply(ctx, config) {
const root=resolve(config.root);
assert(root.startsWith(resolve(tmpdir())+sep));
assert(fileURLToPath(import.meta.url).startsWith(resolve(tmpdir())+sep), 'Load observer from outside the package');
assert.equal(process.env.DSH_HOME,join(root,'home'));
const abort=new AbortController();
const timer=setTimeout(()=>run(ctx,root,abort.signal).catch(error=>writeFile(join(root,'operation-failure-ready.json'),JSON.stringify({error:error.message}))),1000);
return ()=>{clearTimeout(timer);abort.abort();};
}
async function run(ctx,root,signal) {
assert.equal(await realpath(ctx.clientModules.clientPath('@astron-team/skillhub-dsh')),await realpath(join(root,'home/profiles/skillhub-m0/node_modules/@astron-team/skillhub-dsh/lib/client.js')));
const project=join(root,'conversation-install-'+randomUUID());
await mkdir(project);
const workspace=await ctx.workspaceRegistry.create(project);
const created=await ctx.sessionController.create({workspaceId:workspace.id,agentPreset:'standard'});
const resolved=await ctx.sessionController.resolveAgent(created.sessionId);
if ('error' in resolved) throw resolved.error;
const toolCallId='history-'+randomUUID();
const toolArguments={namespace:process.env.DSH_FIXTURE_NAMESPACE ?? 'demo',slug:'document-helper',scope:'project'};
const toolResult=await ctx.tools.execute({callId:toolCallId,name:'astron_skillhub_install',arguments:toolArguments,agent:resolved.agent,signal});
assert.equal(toolResult.isError,false);
assert.equal(toolResult.value.status,'accepted');
const deadline=Date.now()+15000;
let operation;
while(Date.now()<deadline){
operation=await ctx.skillhub.getInstallationOperation(created.sessionId,toolResult.value.operationId);
if(['completed','failed','unknown','recovery-required'].includes(operation?.phase))break;
await delay(100,undefined,{signal});
}
assert.equal(operation?.phase, 'failed');
assert.equal(operation.files, 'failed');
assert.equal(operation.recovery, 'not-needed');
await assert.rejects(access(join(project, '.dsh/skills/document-helper')), { code: 'ENOENT' });
const retry = await ctx.tools.execute({callId:toolCallId,name:'astron_skillhub_install',arguments:toolArguments,agent:resolved.agent,signal});
assert.equal(retry.value.operationId, toolResult.value.operationId);
await writeFile(join(root,'operation-failure-ready.json'),JSON.stringify({passed:true,operationId:operation.operationId,
acceptedBeforeFailure:true,failedWithoutRecovery:true,noInstalledDirectory:true,sameCallPreservesReceipt:true,modelInvoked:false}));
}