mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
Machine-produced by `pnpm run rescope-vendor --apply` plus the regeneration it prints: `pnpm install` for the lockfile, `pnpm run gen-third-party-notices`, `verify-translation-pairing --write` for the touched bilingual pairs, `gen-doc-graphs`, and one typert snapshot whose ids embed character offsets. `pnpm run rescope-vendor --check` verifies the result. Renames nine vendored packages (cordis, cosmokit, schemastery and the six @cordisjs plugins) and every reference that resolves them: manifest names and dependency keys, module specifiers including declare-module merges, cordis.yml plugin names, tsconfig paths, every Markdown fence, and `docs/` prose. Directory names, upstream versions, and dependency ranges are unchanged, so vendor/README.md still reads as an upstream snapshot; its manifest table gains an upstream-name column so THIRD_PARTY_NOTICES keeps MIT attribution pointed at each fork's origin. The tutorial tier follows the rename end to end: its yaml fences named plugins the Loader can no longer resolve, its `ts ignore-check` fences disagreed with the compiled fences beside them, and its prose quoted both. The contracts that told readers to keep upstream names — the root convention and the vendoring cookbook's tree comment and manifest invariant — now say to rescope instead. Two rules read `@deepseek-ai/` as "another workspace plugin": the client bundle purity gate now names the vendored libraries a browser bundle inlines, and the files where a bare `cordis` is an agent-preset id keep that product data.
96 lines
3.7 KiB
TypeScript
96 lines
3.7 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import SessionStore, { Session, SessionId, type SessionEvent } from '@deepseek-ai/dsh-session'
|
|
import * as PlanModeInvariant from '@deepseek-ai/dsh-plan-mode/invariant'
|
|
import InvariantService from '@deepseek-ai/dsh-invariants'
|
|
|
|
async function setup(): Promise<Context> {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SessionStore)
|
|
await ctx.plugin(InvariantService, { enabled: true })
|
|
await ctx.plugin(PlanModeInvariant)
|
|
return ctx
|
|
}
|
|
|
|
function event(active: unknown): SessionEvent {
|
|
return { type: 'plan/mode', seq: 0, time: 0, data: { active } } as SessionEvent
|
|
}
|
|
|
|
function emitTurnStart(ctx: Context, session: Session): void {
|
|
ctx.emit('session/event', session, {
|
|
type: 'turn/start', seq: 0, time: 0,
|
|
data: { turn: 1 },
|
|
})
|
|
}
|
|
|
|
describe('plan-mode stream invariants', () => {
|
|
it('accepts either boolean state', async () => {
|
|
const ctx = await setup()
|
|
const session = Session.create(SessionId('plan-state'))
|
|
emitTurnStart(ctx, session)
|
|
expect(() => { ctx.emit('session/event', session, event(true)) }).not.toThrow()
|
|
expect(() => { ctx.emit('session/event', session, event(false)) }).not.toThrow()
|
|
ctx.emit('session/event', session, {
|
|
type: 'turn/end', seq: 3, time: 3, data: { turn: 1, reason: { kind: 'completed' } },
|
|
})
|
|
})
|
|
|
|
it.each([42, 'plan', undefined])('rejects invalid durable plan state %j', async (active) => {
|
|
const ctx = await setup()
|
|
const session = Session.create(SessionId(`invalid-${String(active)}`))
|
|
emitTurnStart(ctx, session)
|
|
expect(() => { ctx.emit('session/event', session, event(active)) })
|
|
.toThrow(/expected a boolean/)
|
|
})
|
|
|
|
it('accepts standalone plan state between turns (the idle immediate commit)', async () => {
|
|
const ctx = await setup()
|
|
expect(() => ctx.sessions.create().append('plan/mode', { active: true }))
|
|
.not.toThrow()
|
|
})
|
|
|
|
it('ignores unrelated dispatches and session events', async () => {
|
|
const ctx = await setup()
|
|
const session = Session.create(SessionId('unrelated'))
|
|
expect(() => {
|
|
ctx.emit('tools/change')
|
|
ctx.emit('session/event', session, {
|
|
type: 'turn/start', seq: 0, time: 0, data: { turn: 1 },
|
|
})
|
|
}).not.toThrow()
|
|
})
|
|
|
|
it('rejects invalid existing state on late registration', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SessionStore)
|
|
const session = ctx.sessions.create()
|
|
session.append('turn/start', { turn: 1 })
|
|
session.append('plan/mode', { active: 'plan' as unknown as boolean })
|
|
session.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
|
|
await ctx.plugin(InvariantService, { enabled: true })
|
|
|
|
await expect(ctx.plugin(PlanModeInvariant).then(() => undefined)).rejects.toThrow(/expected a boolean/)
|
|
})
|
|
|
|
it('replays enclosed existing plan state through its closing boundary', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SessionStore)
|
|
const session = ctx.sessions.create()
|
|
session.append('turn/start', { turn: 1 })
|
|
session.append('plan/mode', { active: true })
|
|
session.append('turn/end', { turn: 1, reason: { kind: 'completed' } })
|
|
await ctx.plugin(InvariantService, { enabled: true })
|
|
|
|
await expect(ctx.plugin(PlanModeInvariant).then(() => undefined)).resolves.toBeUndefined()
|
|
})
|
|
|
|
it('accepts standalone existing plan state on late registration', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SessionStore)
|
|
ctx.sessions.create().append('plan/mode', { active: true })
|
|
await ctx.plugin(InvariantService, { enabled: true })
|
|
|
|
await expect(ctx.plugin(PlanModeInvariant).then(() => undefined)).resolves.toBeUndefined()
|
|
})
|
|
})
|