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).
71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import * as fs from 'node:fs';
|
|
import * as path from 'node:path';
|
|
|
|
import { buildActiveBehavioralSpec } from './behavioral-spec.js';
|
|
|
|
/** The resolved behavioral-spec shape returned by `buildActiveBehavioralSpec`. */
|
|
export type BehavioralSpec = ReturnType<typeof buildActiveBehavioralSpec>;
|
|
import { loadCustomPersonas } from './custom-personas.js';
|
|
import type { AgentPersona } from './personas.js';
|
|
|
|
export interface LoadedSkill {
|
|
name: string;
|
|
content: string;
|
|
}
|
|
|
|
/**
|
|
* Raw disk read of `{waggleDir}/system-prompt.md`. Returns null if missing
|
|
* or empty. Runtime code should prefer `loadSystemPromptWithOverrides`, which
|
|
* also returns the behavioral spec and custom personas.
|
|
*/
|
|
export function loadSystemPrompt(waggleDir: string): string | null {
|
|
const filePath = path.join(waggleDir, 'system-prompt.md');
|
|
if (!fs.existsSync(filePath)) return null;
|
|
const content = fs.readFileSync(filePath, 'utf-8').trim();
|
|
return content || null;
|
|
}
|
|
|
|
/** Bundle of every prompt input the agent runtime needs. */
|
|
export interface ComposedSystemPrompt {
|
|
/** User's literal system-prompt.md content, or null if absent. */
|
|
userPromptMd: string | null;
|
|
/** The active behavioral spec. */
|
|
behavioralSpec: BehavioralSpec;
|
|
/** Custom personas discovered in `waggleDir/personas/*.json`. */
|
|
customPersonas: AgentPersona[];
|
|
}
|
|
|
|
/**
|
|
* Composes the runtime prompt inputs: reads `system-prompt.md`, builds the
|
|
* behavioral spec and surfaces any custom personas the user has added.
|
|
*
|
|
* Callers typically pass the bundle to their orchestrator:
|
|
*
|
|
* const composed = loadSystemPromptWithOverrides(waggleDir);
|
|
* const orchestrator = new Orchestrator({
|
|
* systemPromptAddendum: composed.userPromptMd,
|
|
* behavioralSpec: composed.behavioralSpec,
|
|
* extraPersonas: composed.customPersonas,
|
|
* });
|
|
*
|
|
* Does not throw on missing files — any piece absent resolves to an empty
|
|
* value so a fresh install just gets the compile-time baseline.
|
|
*/
|
|
export function loadSystemPromptWithOverrides(waggleDir: string): ComposedSystemPrompt {
|
|
const userPromptMd = loadSystemPrompt(waggleDir);
|
|
const behavioralSpec = buildActiveBehavioralSpec();
|
|
const customPersonas = loadCustomPersonas(waggleDir);
|
|
return { userPromptMd, behavioralSpec, customPersonas };
|
|
}
|
|
|
|
export function loadSkills(waggleDir: string): LoadedSkill[] {
|
|
const skillsDir = path.join(waggleDir, 'skills');
|
|
if (!fs.existsSync(skillsDir)) return [];
|
|
|
|
const files = fs.readdirSync(skillsDir).filter(f => f.endsWith('.md'));
|
|
return files.map(f => ({
|
|
name: f.replace(/\.md$/, ''),
|
|
content: fs.readFileSync(path.join(skillsDir, f), 'utf-8').trim(),
|
|
}));
|
|
}
|