36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { installPromptSection } from '../src/host/prompt.js'
|
|
import { setupService, seatById } from './helpers.js'
|
|
|
|
test('只对十席会话注入角色提示', async () => {
|
|
const { service, store, fake } = await setupService()
|
|
installPromptSection(fake.ctx, { store })
|
|
const section = fake.getPromptSection()
|
|
assert.ok(section)
|
|
assert.equal(section.name, 'sansheng')
|
|
|
|
const opened = await service.open({ path: '/pp', name: '提示项目' })
|
|
await service.enable(opened.project.id)
|
|
const p = await service.project(opened.project.id)
|
|
const seat = seatById(p, 'gongbu')
|
|
|
|
const text = section.text({ agent: { id: seat.sessionId } })
|
|
assert.match(text, /工部/)
|
|
assert.match(text, /代码实现与工程产出/)
|
|
|
|
assert.equal(section.text({ agent: { id: 'other-session' } }), '')
|
|
assert.equal(section.text({}), '')
|
|
})
|
|
|
|
test('补充说明出现在提示里', async () => {
|
|
const { service, store, fake } = await setupService()
|
|
installPromptSection(fake.ctx, { store })
|
|
const opened = await service.open({ path: '/pp2', name: 'p' })
|
|
await service.enable(opened.project.id)
|
|
await service.configure(opened.project.id, 'libu', { instructions: '先问清目标' })
|
|
const p = await service.project(opened.project.id)
|
|
const text = fake.getPromptSection().text({ agent: { id: seatById(p, 'libu').sessionId } })
|
|
assert.match(text, /先问清目标/)
|
|
})
|