89 lines
3.9 KiB
TypeScript
89 lines
3.9 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { buildAgentSystemPrompt } from './ai-agent'
|
|
|
|
// --- buildAgentSystemPrompt ---
|
|
|
|
describe('buildAgentSystemPrompt', () => {
|
|
it('stays a neutral guide until the user triggers identity wake-up', () => {
|
|
const prompt = buildAgentSystemPrompt()
|
|
|
|
expect(prompt).toContain('already inside Fifth Domain')
|
|
expect(prompt).toContain('A greeting deserves a greeting, not a system manifesto')
|
|
expect(prompt).toContain('Do not infer the human identity')
|
|
expect(prompt).toContain('do not claim to be a registered persona')
|
|
expect(prompt).toContain('Wait for the user to speak')
|
|
expect(prompt).toContain('already inside Fifth Domain')
|
|
expect(prompt).toContain('background operating knowledge')
|
|
expect(prompt).toContain('future Guanghu Lighthouse domain-selection lobby')
|
|
expect(prompt).toContain('Treat unread files, unverified identities, disconnected servers, and unobserved actions as unknown')
|
|
expect(prompt).not.toContain('QUICKSTART-FOR-GENERAL-AI.md')
|
|
})
|
|
|
|
it('keeps the earlier structured Markdown answer style without exposing internal routing', () => {
|
|
const prompt = buildAgentSystemPrompt()
|
|
|
|
expect(prompt).toContain('clear Markdown headings')
|
|
expect(prompt).toContain('Do not expose raw Markdown syntax as plain text')
|
|
expect(prompt).toContain('Keep routing, identity checks, skill loading, and repository lookup in the background')
|
|
})
|
|
|
|
it('returns preamble when no vault context', () => {
|
|
const prompt = buildAgentSystemPrompt()
|
|
expect(prompt).toContain('current AI instance assisting inside HoloLake Era')
|
|
expect(prompt).toContain('active vault')
|
|
expect(prompt).toContain("vault's AGENTS.md")
|
|
expect(prompt).toContain('Vault Safe mode is active')
|
|
expect(prompt).toContain('not available in Vault Safe')
|
|
expect(prompt).not.toContain('full shell access')
|
|
expect(prompt).not.toContain('Vault context')
|
|
})
|
|
|
|
it('appends vault context when provided', () => {
|
|
const prompt = buildAgentSystemPrompt('Recent notes: foo, bar')
|
|
expect(prompt).toContain('current AI instance assisting inside HoloLake Era')
|
|
expect(prompt).toContain('Vault context:')
|
|
expect(prompt).toContain('Recent notes: foo, bar')
|
|
})
|
|
|
|
it('points safe-mode agents to bundled HoloLake Era docs without shell commands', () => {
|
|
const prompt = buildAgentSystemPrompt({ agentDocsPath: '/app/agent-docs' })
|
|
|
|
expect(prompt).toContain('/app/agent-docs/index.md')
|
|
expect(prompt).toContain('/app/agent-docs/pages/templates/portent.md')
|
|
expect(prompt).toContain("Portent as HoloLake Era's default best-practice model")
|
|
expect(prompt).not.toContain('ripgrep')
|
|
expect(prompt).toContain('Prefer bundled docs over guesses')
|
|
})
|
|
|
|
it('keeps ripgrep guidance for bundled docs in shell-capable power user mode', () => {
|
|
const prompt = buildAgentSystemPrompt({
|
|
agent: 'codex',
|
|
agentDocsPath: '/app/agent-docs',
|
|
permissionMode: 'power_user',
|
|
})
|
|
|
|
expect(prompt).toContain('ripgrep')
|
|
expect(prompt).toContain('Power User mode is active')
|
|
})
|
|
|
|
it('allows shell commands in power user mode where supported', () => {
|
|
const prompt = buildAgentSystemPrompt({ agent: 'codex', permissionMode: 'power_user' })
|
|
expect(prompt).toContain('Power User mode is active')
|
|
expect(prompt).toContain('Local shell commands are available')
|
|
expect(prompt).not.toContain('not available in Vault Safe')
|
|
})
|
|
|
|
it('does not promise shell execution for Pi power user mode', () => {
|
|
const prompt = buildAgentSystemPrompt({ agent: 'pi', permissionMode: 'power_user' })
|
|
expect(prompt).toContain('Pi currently uses the same conservative HoloLake Era MCP configuration')
|
|
expect(prompt).not.toContain('Local shell commands are available')
|
|
})
|
|
|
|
it('instructs AI to use wikilink syntax', () => {
|
|
const prompt = buildAgentSystemPrompt()
|
|
expect(prompt).toContain('[[')
|
|
expect(prompt).toMatch(/wikilink/i)
|
|
})
|
|
})
|