fix(cli): register web prompt context before boot

This commit is contained in:
Tianyi Cui
2026-08-02 00:49:58 +08:00
parent d74048345a
commit 6cd9fefe88
7 changed files with 54 additions and 21 deletions

View File

@@ -0,0 +1,29 @@
import { sep } from 'node:path'
import { Context } from 'cordis'
import { describe, expect, it } from 'vitest'
import SystemPrompt from '@deepseek-ai/dsh-system-prompt'
import { HARNESS_SOURCE_SECTION } from '@deepseek-ai/dsh-app-boot'
import { prepareWebPromptContext } from '../src/web.ts'
describe('prepareWebPromptContext', () => {
it('installs both sections before a later systemPrompt consumer activates', async () => {
const ctx = new Context()
const sourceRoot = `${sep}opt${sep}harness-src`
let observedNames: string[] | undefined
try {
prepareWebPromptContext(ctx, sourceRoot)
const consumer = ctx.inject(['systemPrompt'], async (promptCtx) => {
const assembly = await promptCtx.systemPrompt.assemble()
observedNames = assembly.sections.map(section => section.name)
})
await ctx.plugin(SystemPrompt, { persona: 'You are a coding agent.' })
await consumer
expect(observedNames).toContain(HARNESS_SOURCE_SECTION)
expect(observedNames).toContain('app:web-surface')
} finally {
await ctx.fiber.dispose()
}
})
})