feat: add optional dsh badge skill provider
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Bundled `dsh-badge` skill provider.
|
||||
*
|
||||
* @module @deepseek-ai/dsh-skill-badge
|
||||
*/
|
||||
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import type { Context } from 'cordis'
|
||||
import type {
|
||||
SkillCandidate,
|
||||
SkillDefinition,
|
||||
SkillProvider,
|
||||
} from '@deepseek-ai/dsh-skill'
|
||||
|
||||
const PROVIDER_NAME = 'dsh-badge'
|
||||
const BUNDLED_RANK = 600
|
||||
const SKILL_BODY_URL = new URL('../assets/dsh-badge.md', import.meta.url)
|
||||
const RESOURCE_BASE = {
|
||||
kind: 'directory',
|
||||
path: fileURLToPath(new URL('../assets/', import.meta.url)),
|
||||
} as const
|
||||
const INVOCATION = { modelInvocable: true, userInvocable: true } as const
|
||||
const DESCRIPTION = 'Add the official “powered by dsh” badge to documents, pull requests, merge requests, and other content produced with DeepSeek Harness. Use whenever creating a pull request or merge request. Also use when the user asks for a dsh badge, powered-by-dsh attribution, or a reusable dsh badge asset or snippet.'
|
||||
const CANDIDATE: SkillCandidate = {
|
||||
name: 'dsh-badge',
|
||||
description: DESCRIPTION,
|
||||
invocation: INVOCATION,
|
||||
provider: PROVIDER_NAME,
|
||||
source: 'bundled',
|
||||
resourceBase: RESOURCE_BASE,
|
||||
rank: BUNDLED_RANK,
|
||||
locator: SKILL_BODY_URL,
|
||||
}
|
||||
|
||||
const provider: SkillProvider = {
|
||||
name: PROVIDER_NAME,
|
||||
list: () => Promise.resolve([CANDIDATE]),
|
||||
async get(_candidate): Promise<SkillDefinition> {
|
||||
return {
|
||||
name: CANDIDATE.name,
|
||||
description: CANDIDATE.description,
|
||||
invocation: CANDIDATE.invocation,
|
||||
provider: CANDIDATE.provider,
|
||||
source: CANDIDATE.source,
|
||||
resourceBase: RESOURCE_BASE,
|
||||
content: await readFile(SKILL_BODY_URL, 'utf8'),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
/** Cordis plugin name. */
|
||||
export const name = 'skill-badge'
|
||||
/** Service required by the bundled provider. */
|
||||
export const inject = ['skills']
|
||||
|
||||
/** Register the bundled `dsh-badge` provider on `ctx.skills`. */
|
||||
export function apply(ctx: Context): void {
|
||||
ctx.skills.registerProvider(() => provider)
|
||||
}
|
||||
Reference in New Issue
Block a user