mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 16:07:35 +01:00
Until today, prompts lived in two parallel files: 35 entries in ~/.config/agent-prompts.json (out-of-repo, snake_case keys, dev/ship/vision taxonomy + dimensionId) and 35 in src/config/prompt-library.ts (in-repo, kebab-case ids, domain taxonomy + scope). 12+ duplicate pairs with subtly different bodies; 6 security prompts in TS only (invisible to DimensionSection in /control); 6 control prompts in JSON only (invisible to /prompts library page and ProjectPromptLibrary modal). Adding a new prompt required two edits in two formats. Real SSOT violation. This commit promotes the in-repo TS file to canonical SSOT for prompt METADATA (id, name, description, category, scope, style, slot, sendNow). For the subset of prompts that also need to be dispatchable by the autopilot daemon, an optional `agentKey` field ties the TS entry back to the snake_case identifier the daemon expects. JSON becomes a build artifact, regenerated from TS via `npm run generate:agent-prompts`. Mechanics: - PromptTemplate type gains optional agentKey, icon, style, slot, dimensionId, sendNow fields. Category enum gains "control" and "content". CATEGORY_META extended. No breaking changes to existing fields. - All 6 JSON-only control prompts (hard_stop, blocker_create, orient, unblock, roadmap_check, onboarding) added to TS with agentKey set to their daemon key + dimensionId: "control". They now appear in BOTH /prompts library page AND DimensionSection AND remain dispatchable by the daemon. hard_stop is the only one flagged sendNow:true (kill switch — preview makes no sense). - /api/prompts/agent route gains a mergePromptSources() helper that reads JSON, transforms TS entries with agentKey, dedups by key (TS wins on conflict). The DimensionSection in /control now sees the unified set without a UI change. Old reference to PROMPTS_FILE() preserved so the daemon still works during the incremental migration. - New scripts/generate-agent-prompts.ts generator transforms PROMPT_TEMPLATES → AgentPrompt[] and writes them back to JSON, preserving any legacy JSON entries not yet migrated. Wired as `npm run generate:agent-prompts`. Backup of pre-regen JSON kept at ~/.config/agent-prompts.json.bak-20260531-ssot. Verification: tsc clean. Generator dry-run output: 35 entries (29 legacy + 6 TS-overridden). The 6 TS-sourced entries are byte- identical to their old JSON bodies (same key, same prompt text). Adding a new prompt is now ONE TS edit. Migrating the remaining 29 JSON-only entries to TS is a follow-up commit; the bridge keeps everything working during the transition. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>