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.
86 lines
3.6 KiB
TypeScript
86 lines
3.6 KiB
TypeScript
/**
|
|
* ui-plan browser half on a real SlotsService: the plugin occupies the
|
|
* conversation-declared `conversation.input.plan` single seat with the active
|
|
* plan status chip; the injected face executes /plan off and folds admission
|
|
* outcomes into null (admitted) or a user-visible failure line; teardown
|
|
* empties the seat (HMR safety).
|
|
*/
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { SlotsService } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import { LocaleService } from '@deepseek-ai/dsh-client-locale/client'
|
|
import { PlanChip } from '../src/client/PlanModeControl.tsx'
|
|
import type { PlanChipInjected } from '../src/client/index.ts'
|
|
import { apply, inject } from '../src/client/index.ts'
|
|
import { apply as nodeApply } from '../src/index.ts'
|
|
|
|
const SID = 's-plan' as SessionId
|
|
|
|
async function bench() {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotsService).await()
|
|
const slots = ctx.get('slots') as SlotsService
|
|
slots.register({
|
|
name: 'root',
|
|
children: { 'conversation.input.plan': { kind: 'single', scope: 'session' } },
|
|
} as never, () => null)
|
|
const execute = vi.fn((_payload: { sessionId: SessionId; line: string }) =>
|
|
Promise.resolve({ result: { ok: true as const, value: { matched: true as const, commandId: 'c1' } } }))
|
|
ctx.provide('connection', { api: { commands: { execute } } })
|
|
ctx.provide('locale', new LocaleService(ctx))
|
|
return { ctx, slots, execute }
|
|
}
|
|
|
|
describe('ui-plan browser apply', () => {
|
|
it('declares every service it binds', () => {
|
|
expect(inject).toEqual(['slots', 'connection', 'locale'])
|
|
})
|
|
|
|
it('node-half apply is an intentional no-op', () => {
|
|
expect(() => { nodeApply() }).not.toThrow()
|
|
})
|
|
|
|
it('waits until conversation declares the plan seat', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotsService).await()
|
|
ctx.provide('connection', {})
|
|
ctx.provide('locale', new LocaleService(ctx))
|
|
const fiber = ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
expect(ctx.slots.entries('conversation.input.plan')).toHaveLength(0)
|
|
ctx.slots.register({
|
|
name: 'root', children: { 'conversation.input.plan': { kind: 'single', scope: 'session' } },
|
|
} as never, () => null)
|
|
await Promise.resolve()
|
|
expect(ctx.slots.entries('conversation.input.plan')).toHaveLength(1)
|
|
})
|
|
|
|
it('registers the chip, executes /plan off, and unregisters on teardown', async () => {
|
|
const b = await bench()
|
|
const fiber = b.ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
const entry = b.slots.entries('conversation.input.plan')[0]!
|
|
expect(entry.component).toBe(PlanChip)
|
|
const injected = (entry.inject as unknown as (id: SessionId) => PlanChipInjected)(SID)
|
|
|
|
await expect(injected.exitPlanMode()).resolves.toBeNull()
|
|
expect(b.execute).toHaveBeenLastCalledWith({ sessionId: SID, line: '/plan off' })
|
|
|
|
// Business failure folds to the composer-visible line.
|
|
b.execute.mockResolvedValueOnce({
|
|
result: { ok: false as const, error: { code: 'session-not-found', message: 'gone', details: {} } },
|
|
} as never)
|
|
await expect(injected.exitPlanMode()).resolves.toBe('gone (session-not-found)')
|
|
|
|
// Unmatched admission (plan-mode not composed host-side) is also a failure line.
|
|
b.execute.mockResolvedValueOnce({
|
|
result: { ok: true as const, value: { matched: false as const } },
|
|
} as never)
|
|
await expect(injected.exitPlanMode()).resolves.toBe('unknown command: /plan off')
|
|
|
|
await fiber.dispose()
|
|
expect(b.slots.entries('conversation.input.plan')).toHaveLength(0)
|
|
})
|
|
})
|