feat: add optional dsh badge skill provider
This commit is contained in:
60
packages/skill/skill-badge/src/index.ts
Normal file
60
packages/skill/skill-badge/src/index.ts
Normal file
@@ -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)
|
||||
}
|
||||
30
packages/skill/skill-badge/src/invariant.ts
Normal file
30
packages/skill/skill-badge/src/invariant.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Package-owned invariant companion for `@deepseek-ai/dsh-skill-badge`.
|
||||
* @module @deepseek-ai/dsh-skill-badge/invariant
|
||||
*/
|
||||
|
||||
/* jscpd:ignore-start */
|
||||
import type { Context } from 'cordis'
|
||||
import type { InvariantInstaller } from '@deepseek-ai/dsh-invariants'
|
||||
|
||||
const PACKAGE_NAME = '@deepseek-ai/dsh-skill-badge'
|
||||
|
||||
/** Cordis companion plugin name. */
|
||||
export const name = 'skill-badge-invariant'
|
||||
/** Service required before the companion can reserve package ownership. */
|
||||
export const inject = ['invariants']
|
||||
|
||||
/**
|
||||
* No runtime invariant: the package owns one immutable provider registration,
|
||||
* while the skill registry owns registration uniqueness and lifecycle checks.
|
||||
*/
|
||||
const install: InvariantInstaller = () => {}
|
||||
|
||||
/**
|
||||
* Register this package's invariant companion.
|
||||
* @param ctx - Cordis context carrying the invariant service.
|
||||
* @returns the installed registration's disposer after setup succeeds.
|
||||
*/
|
||||
export const apply = (ctx: Context): Promise<() => void> =>
|
||||
Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install))
|
||||
/* jscpd:ignore-end */
|
||||
Reference in New Issue
Block a user