|
|
@@ -5,6 +5,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest'
|
|
|
import type { AgentHandle } from '@deepseek-ai/dsh-agent'
|
|
|
import { CallId } from '@deepseek-ai/dsh-llm'
|
|
|
import { SessionId } from '@deepseek-ai/dsh-session'
|
|
|
+import { renderPrompt } from '@deepseek-ai/dsh-system-prompt'
|
|
|
import { launchWebScaffold, type WebScaffold } from './scaffold.ts'
|
|
|
|
|
|
const CORE_WEB_OVERLAY = fileURLToPath(new URL('../../cli/config/core-web.cordis.yml', import.meta.url))
|
|
|
@@ -14,10 +15,13 @@ describe('core Web profile', () => {
|
|
|
let agentHandle: AgentHandle
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
- scaffold = await launchWebScaffold({
|
|
|
- extraOverlayPath: CORE_WEB_OVERLAY,
|
|
|
- toolsMode: 'native',
|
|
|
- })
|
|
|
+ const systemPrompt = process.env.DSH_SYSTEM_PROMPT
|
|
|
+ Reflect.deleteProperty(process.env, 'DSH_SYSTEM_PROMPT')
|
|
|
+ try {
|
|
|
+ scaffold = await launchWebScaffold({ extraOverlayPath: CORE_WEB_OVERLAY })
|
|
|
+ } finally {
|
|
|
+ if (systemPrompt !== undefined) process.env.DSH_SYSTEM_PROMPT = systemPrompt
|
|
|
+ }
|
|
|
agentHandle = await scaffold.ctx.agents.create({
|
|
|
sessionId: SessionId('core-web-profile-smoke'),
|
|
|
meta: { cwd: scaffold.workspaceCwd },
|
|
|
@@ -59,7 +63,9 @@ describe('core Web profile', () => {
|
|
|
.replaceAll(scaffold.workspaceCwd, '{{cwd}}')
|
|
|
.trimEnd()
|
|
|
|
|
|
+ const prompt = renderPrompt(await scaffold.ctx.systemPrompt.assemble())
|
|
|
expect({
|
|
|
+ prompt,
|
|
|
tools: scaffold.ctx.tools.schemas().map(tool => tool.name),
|
|
|
bash: text(bash),
|
|
|
editor: text(editor),
|
|
|
@@ -69,6 +75,7 @@ describe('core Web profile', () => {
|
|
|
"editor": "Here's the content of {{cwd}}/profile-smoke.txt with line numbers (which has a total of 2 lines):
|
|
|
1 CORE_WEB_EDITOR_OK
|
|
|
2",
|
|
|
+ "prompt": "You are a helpful software engineer assistant.",
|
|
|
"tools": [
|
|
|
"bash",
|
|
|
"str_replace_editor",
|
|
|
@@ -80,5 +87,24 @@ describe('core Web profile', () => {
|
|
|
expect(entries.find(entry => entry.options.id === 'persistent-bash')?.fiber).toBeDefined()
|
|
|
expect(entries.find(entry => entry.options.id === 'pty-local')?.fiber).toBeDefined()
|
|
|
expect(entries.find(entry => entry.options.id === 'str-replace-editor')?.fiber).toBeDefined()
|
|
|
+ expect(entries.find(entry => entry.options.id === 'web-runtime-context')?.fiber).toBeUndefined()
|
|
|
+ expect(entries.find(entry => entry.options.id === 'workspace-context')?.fiber).toBeUndefined()
|
|
|
+ })
|
|
|
+
|
|
|
+ it('uses DSH_SYSTEM_PROMPT as the complete prompt when configured', async () => {
|
|
|
+ const previous = process.env.DSH_SYSTEM_PROMPT
|
|
|
+ process.env.DSH_SYSTEM_PROMPT = 'RL prompt override'
|
|
|
+ let overrideScaffold: WebScaffold | undefined
|
|
|
+ try {
|
|
|
+ overrideScaffold = await launchWebScaffold({ extraOverlayPath: CORE_WEB_OVERLAY })
|
|
|
+ expect(renderPrompt(await overrideScaffold.ctx.systemPrompt.assemble())).toBe('RL prompt override')
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ await overrideScaffold?.close()
|
|
|
+ } finally {
|
|
|
+ if (previous === undefined) Reflect.deleteProperty(process.env, 'DSH_SYSTEM_PROMPT')
|
|
|
+ else process.env.DSH_SYSTEM_PROMPT = previous
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
})
|