mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Greenfield #2 "建插件" modules for the forthcoming `dsh-sdk create <source>` command, in a new foundation-independent package so it touches none of the dsh-scripts / dsh-helper / create-sdk hotspots the foundation refactor edits. - `resolvePluginSource(spec)` parses `owner/repo[/subdir]#ref` (github) or `pkg@version` (npm) into a `PluginSource` discriminated union, failing loud on an ambiguous or malformed spec. - `PluginFetcher<S>` seam + `fetchPlugin` tag dispatch returning a common `FetchedPlugin` (temp dir + immutable provenance). - `GigetFetcher` (github) over @bluwy/giget-core: resolve `#ref` to a commit SHA first, download that SHA; provenance pins the SHA. Chosen over unjs/giget for its single runtime dep and absent install/action surface. - `PacoteFetcher` (npm) over pacote: resolve the manifest, then extract the tarball verified against its registry integrity. Registry-only is enforced by the source resolver; extract runs no lifecycle scripts. - Branded `CommitSha`/`Integrity`; network + temp-dir boundaries are injected so the logic is unit-tested at 100% per-file coverage without network. Wiring (package.json pin, cordis.yml via ProjectEditSession with a confirmed diff, install --ignore-scripts) and the launcher command registration land later with the foundation.
20 lines
725 B
TypeScript
20 lines
725 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { assertNever } from '../src/never.ts'
|
|
|
|
describe('assertNever', () => {
|
|
it('throws with the rendered value and a context label', () => {
|
|
expect(() => assertNever('surprise' as never, 'demo')).toThrow(
|
|
/unreachable variant in demo: "surprise"/,
|
|
)
|
|
})
|
|
|
|
it('omits the context clause when none is given', () => {
|
|
expect(() => assertNever(7 as never)).toThrow(/unreachable variant: 7$/)
|
|
})
|
|
|
|
it('falls back to String() when the value is not JSON-serializable', () => {
|
|
// JSON.stringify(undefined) is undefined, exercising the String() fallback.
|
|
expect(() => assertNever(undefined as never)).toThrow(/unreachable variant: undefined$/)
|
|
})
|
|
})
|