Self-learning is excluded from the community edition (ADR-0004); the project owner reworks it separately. Cost tracking stays. - agent: delete behaviour evolution (evolve-schema, iterative GEPA, compose-evolution, evolution gates, orchestrator and deploy), improvement and correction detection, AgentLearning, the eval-dataset builder, optimization-capture and the agent_insights tool. Secret detection moves from eval-dataset to secret-patterns. The LLM wiring keeps only the Haiku adapter and judge call used by skill audit and hygiene, so @ax-llm/ax is now declared by agent instead of server. - server: delete /api/evolution/*, the evolution and optimizer services, GEPA expansion of the first chat message, the prompt_optimization and monthly_assessment jobs, the idle-session reviewer and its session-reviewer persona, prompt injection of past corrections and thumbs-down recorded as correction signals. Existing job rows of the removed types are ignored, not deleted. - core: delete OptimizationLogStore; stop re-exporting the improvement signal and evolution run stores. - web: delete the Evolution screen and the two job types in the automation editor. - delete packages/optimizer. Also logs UF-027 (self-learning loops read data nothing collects) and UF-028 (the Settings prompt-shape choice is ignored by chat).
101 lines
3.6 KiB
TypeScript
101 lines
3.6 KiB
TypeScript
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
import {
|
|
loadSystemPrompt,
|
|
loadSystemPromptWithOverrides,
|
|
loadSkills,
|
|
} from '../src/prompt-loader.js';
|
|
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
import * as os from 'node:os';
|
|
|
|
describe('Prompt Loader', () => {
|
|
let tmpDir: string;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'waggle-prompt-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
});
|
|
|
|
describe('loadSystemPrompt', () => {
|
|
it('returns null when no system-prompt.md exists', () => {
|
|
const result = loadSystemPrompt(tmpDir);
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it('loads system-prompt.md from waggle dir', () => {
|
|
fs.writeFileSync(path.join(tmpDir, 'system-prompt.md'), 'You are a helpful bot.');
|
|
const result = loadSystemPrompt(tmpDir);
|
|
expect(result).toBe('You are a helpful bot.');
|
|
});
|
|
|
|
it('trims whitespace', () => {
|
|
fs.writeFileSync(path.join(tmpDir, 'system-prompt.md'), ' Hello \n\n');
|
|
const result = loadSystemPrompt(tmpDir);
|
|
expect(result).toBe('Hello');
|
|
});
|
|
});
|
|
|
|
describe('loadSkills', () => {
|
|
it('returns empty array when no skills dir', () => {
|
|
const result = loadSkills(tmpDir);
|
|
expect(result).toEqual([]);
|
|
});
|
|
|
|
it('loads .md files from skills directory', () => {
|
|
const skillsDir = path.join(tmpDir, 'skills');
|
|
fs.mkdirSync(skillsDir);
|
|
fs.writeFileSync(path.join(skillsDir, 'coding.md'), '# Coding\nYou are a coder.');
|
|
fs.writeFileSync(path.join(skillsDir, 'research.md'), '# Research\nYou research things.');
|
|
|
|
const result = loadSkills(tmpDir);
|
|
expect(result).toHaveLength(2);
|
|
expect(result.map(s => s.name)).toContain('coding');
|
|
expect(result.map(s => s.name)).toContain('research');
|
|
});
|
|
|
|
it('ignores non-md files', () => {
|
|
const skillsDir = path.join(tmpDir, 'skills');
|
|
fs.mkdirSync(skillsDir);
|
|
fs.writeFileSync(path.join(skillsDir, 'coding.md'), '# Coding');
|
|
fs.writeFileSync(path.join(skillsDir, 'notes.txt'), 'not a skill');
|
|
|
|
const result = loadSkills(tmpDir);
|
|
expect(result).toHaveLength(1);
|
|
});
|
|
});
|
|
|
|
describe('loadSystemPromptWithOverrides', () => {
|
|
it('returns baseline when no overrides exist', () => {
|
|
const composed = loadSystemPromptWithOverrides(tmpDir);
|
|
expect(composed.userPromptMd).toBeNull();
|
|
expect(composed.behavioralSpec).toBeDefined();
|
|
// Baseline should contain at least one known section string
|
|
const flattened = Object.values(composed.behavioralSpec).join('\n');
|
|
expect(flattened.length).toBeGreaterThan(0);
|
|
expect(composed.customPersonas).toEqual([]);
|
|
});
|
|
|
|
it('surfaces a custom system-prompt.md alongside baseline spec', () => {
|
|
fs.writeFileSync(path.join(tmpDir, 'system-prompt.md'), 'hello from user');
|
|
const composed = loadSystemPromptWithOverrides(tmpDir);
|
|
expect(composed.userPromptMd).toBe('hello from user');
|
|
});
|
|
|
|
it('ignores override files left on disk by earlier versions', () => {
|
|
const overrideDir = path.join(tmpDir, 'behavioral-overrides');
|
|
fs.mkdirSync(overrideDir, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(overrideDir, 'coreLoop.json'),
|
|
JSON.stringify({ section: 'coreLoop', text: 'STALE OVERRIDE TEXT', deployedAt: new Date().toISOString() }),
|
|
);
|
|
|
|
const composed = loadSystemPromptWithOverrides(tmpDir);
|
|
const flattened = Object.values(composed.behavioralSpec).join('\n');
|
|
expect(flattened).not.toContain('STALE OVERRIDE TEXT');
|
|
});
|
|
});
|
|
});
|