Morgan's system prompt is now generated at build time and embedded directly in the code, making it available in Cloudflare Worker environments where file system access isn't available. Changes: - Add scripts/generate-morgan-prompt.js to generate TypeScript constant from markdown - Generate src/lib/agents/morgan-system-prompt.ts with full Fortura Agent Bundle - Update agent definitions to import and use the embedded constant - Update package.json build scripts to generate prompt before building - Remove runtime file system access (readFileSync) that failed on Cloudflare This ensures Morgan agent has full system prompt capabilities on all deployments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
2.4 KiB
TypeScript
67 lines
2.4 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { GET } from '@/app/api/agents/route'
|
|
import { NextRequest } from 'next/server'
|
|
|
|
describe('/api/agents', () => {
|
|
it('returns list of standard agents', async () => {
|
|
const request = new NextRequest('http://localhost:3000/api/agents')
|
|
const response = await GET(request)
|
|
const data = await response.json()
|
|
|
|
expect(response.status).toBe(200)
|
|
expect(data.agents).toBeDefined()
|
|
expect(Array.isArray(data.agents)).toBe(true)
|
|
expect(data.agents.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
it('includes agent-1 (Repoguide)', async () => {
|
|
const request = new NextRequest('http://localhost:3000/api/agents')
|
|
const response = await GET(request)
|
|
const data = await response.json()
|
|
|
|
const agent1 = data.agents.find((a: any) => a.id === 'agent-1')
|
|
expect(agent1).toBeDefined()
|
|
expect(agent1?.name).toBe('Repoguide')
|
|
expect(agent1?.description).toBe('Documenting the development process.')
|
|
})
|
|
|
|
it('includes agent-2 (Morgan)', async () => {
|
|
const request = new NextRequest('http://localhost:3000/api/agents')
|
|
const response = await GET(request)
|
|
const data = await response.json()
|
|
|
|
const agent2 = data.agents.find((a: any) => a.id === 'agent-2')
|
|
expect(agent2).toBeDefined()
|
|
expect(agent2?.name).toBe('Morgan')
|
|
expect(agent2?.description).toBe('System Prompt Designer')
|
|
})
|
|
|
|
it('agent response does not include webhookUrl', async () => {
|
|
const request = new NextRequest('http://localhost:3000/api/agents')
|
|
const response = await GET(request)
|
|
const data = await response.json()
|
|
|
|
data.agents.forEach((agent: any) => {
|
|
expect(agent).toHaveProperty('id')
|
|
expect(agent).toHaveProperty('name')
|
|
expect(agent).toHaveProperty('description')
|
|
expect(agent).not.toHaveProperty('webhookUrl')
|
|
})
|
|
})
|
|
|
|
it('agent response includes id, name, and description', async () => {
|
|
const request = new NextRequest('http://localhost:3000/api/agents')
|
|
const response = await GET(request)
|
|
const data = await response.json()
|
|
|
|
expect(data.agents.length).toBeGreaterThan(0)
|
|
const firstAgent = data.agents[0]
|
|
expect(firstAgent.id).toBeDefined()
|
|
expect(typeof firstAgent.id).toBe('string')
|
|
expect(firstAgent.name).toBeDefined()
|
|
expect(typeof firstAgent.name).toBe('string')
|
|
expect(firstAgent.description).toBeDefined()
|
|
expect(typeof firstAgent.description).toBe('string')
|
|
})
|
|
})
|