2026-07-28 23:17:46 +08:00
|
|
|
/**
|
|
|
|
|
* The summary blank bit means "conversation not started" (no turn has run),
|
|
|
|
|
* not "log empty": standalone plugin events — command lifecycle records,
|
2026-07-29 11:33:44 +08:00
|
|
|
* plan/mode, permission knob events, session titles — never flip it, so running /plan or /goal on a
|
2026-07-28 23:17:46 +08:00
|
|
|
* fresh session keeps it list-hidden and reusable, while the first accepted
|
|
|
|
|
* prompt's turn/start clears it. The host/session-added frame shares the
|
|
|
|
|
* same predicate function (covered by the workspace spec's frame assertion).
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, expect, it } from 'vitest'
|
build(vendor): rescope the vendored Cordis packages into @deepseek-ai
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.
2026-08-10 22:04:06 +08:00
|
|
|
import { Context } from '@deepseek-ai/cordis'
|
2026-07-28 23:17:46 +08:00
|
|
|
import AgentRegistry from '@deepseek-ai/dsh-agent'
|
|
|
|
|
import type { Agent } from '@deepseek-ai/dsh-agent'
|
|
|
|
|
import SessionStore from '@deepseek-ai/dsh-session'
|
|
|
|
|
import type { Session } from '@deepseek-ai/dsh-session'
|
|
|
|
|
import { CommandId } from '@deepseek-ai/dsh-commands/brand'
|
2026-08-23 00:07:39 +08:00
|
|
|
// Side-effect type imports: the configuration-event SessionEventMap merges.
|
2026-08-13 00:36:22 +08:00
|
|
|
import type {} from '@deepseek-ai/dsh-permission-presets'
|
2026-07-29 11:33:44 +08:00
|
|
|
import type {} from '@deepseek-ai/dsh-sandbox-policy'
|
2026-08-22 21:10:44 +08:00
|
|
|
import { createSessionTestRemote, type TestSessionRemote } from './test-remote.ts'
|
2026-07-28 23:17:46 +08:00
|
|
|
|
2026-08-22 21:10:44 +08:00
|
|
|
async function harness(): Promise<{ ctx: Context; remote: TestSessionRemote; attach: (session: Session) => void }> {
|
2026-07-28 23:17:46 +08:00
|
|
|
const ctx = new Context()
|
|
|
|
|
await ctx.plugin(SessionStore)
|
|
|
|
|
await ctx.plugin(AgentRegistry)
|
|
|
|
|
return {
|
|
|
|
|
ctx,
|
2026-08-22 21:10:44 +08:00
|
|
|
remote: createSessionTestRemote(ctx, { defaultModelSelection: () => ({ provider: 'p', model: 'm' }), cwd: '/tmp' }),
|
2026-07-28 23:17:46 +08:00
|
|
|
attach: (session) => {
|
|
|
|
|
ctx.agents.register({ id: session.id, session, status: 'idle', ctx } as Agent)
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Append the standalone (non-conversation) event family a fresh session can accumulate. */
|
|
|
|
|
function appendStandalone(session: Session): void {
|
|
|
|
|
session.append('command/run', {
|
|
|
|
|
commandId: CommandId('blank-cmd-1'), name: 'plan', args: '', source: { kind: 'user' },
|
|
|
|
|
})
|
|
|
|
|
session.append('plan/mode', { active: true })
|
|
|
|
|
session.append('command/done', { commandId: CommandId('blank-cmd-1'), kind: 'success', text: 'Plan mode on.' })
|
|
|
|
|
session.append('session/title', {
|
|
|
|
|
title: 'standalone title', messageSeqs: [], source: { kind: 'fallback' },
|
|
|
|
|
})
|
2026-08-23 00:07:39 +08:00
|
|
|
// Permission configuration events from a /permission switch on a fresh session.
|
2026-07-29 11:33:44 +08:00
|
|
|
session.append('permission/preset', { preset: 'danger-full-access' })
|
|
|
|
|
session.append('sandbox/mode', { mode: 'danger-full-access' })
|
2026-07-28 23:17:46 +08:00
|
|
|
}
|
|
|
|
|
|
2026-08-22 21:10:44 +08:00
|
|
|
async function listBlank(remote: TestSessionRemote, id: string): Promise<boolean | undefined> {
|
|
|
|
|
const result = await remote.list({})
|
|
|
|
|
if (!result.ok) throw new Error('list failed')
|
|
|
|
|
return result.value.items.find(item => item.sessionId === id)?.blank
|
2026-07-28 23:17:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('summary blank = conversation not started', () => {
|
|
|
|
|
it('standalone events (command lifecycle, plan/mode, title) keep the session blank', async () => {
|
2026-08-22 21:10:44 +08:00
|
|
|
const { ctx, remote, attach } = await harness()
|
2026-07-28 23:17:46 +08:00
|
|
|
const session = ctx.sessions.create()
|
|
|
|
|
attach(session)
|
2026-08-22 21:10:44 +08:00
|
|
|
expect(await listBlank(remote, session.id)).toBe(true)
|
2026-07-28 23:17:46 +08:00
|
|
|
appendStandalone(session)
|
2026-08-22 21:10:44 +08:00
|
|
|
expect(await listBlank(remote, session.id)).toBe(true)
|
2026-07-28 23:17:46 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('the first turn clears blank', async () => {
|
2026-08-22 21:10:44 +08:00
|
|
|
const { ctx, remote, attach } = await harness()
|
2026-07-28 23:17:46 +08:00
|
|
|
const session = ctx.sessions.create()
|
|
|
|
|
attach(session)
|
|
|
|
|
appendStandalone(session)
|
2026-07-30 13:49:57 +08:00
|
|
|
session.append('turn/start', { turn: 0 })
|
2026-08-22 21:10:44 +08:00
|
|
|
expect(await listBlank(remote, session.id)).toBe(false)
|
2026-07-28 23:17:46 +08:00
|
|
|
})
|
|
|
|
|
})
|