Extract groomer LLM prompts to dedicated files#626
Conversation
Move the groomer's LLM system prompt template from an inline 78-line string in src/lib/groomer/llm.ts to a dedicated file at src/lib/groomer/prompts/system-prompt.ts. The prompt is now exported as a `buildGroomerSystemPrompt()` function that accepts dynamic parameters (lane IDs, labels, etc.) and returns the fully interpolated prompt string. This makes prompt content reviewable as a diff when changed, supports easier versioning and A/B testing, and keeps llm.ts focused on orchestration logic. Add regression tests for all dynamic interpolations in the extracted prompt. Fixes #621 Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
There was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: MiniMax-M2.7@https://litellm.jory.dev/v1 (anthropic) — escalated (fast_low_confidence)
Review Summary
PR PR 626: Extract groomer LLM prompts to dedicated files
Recommendation: APPROVE
This PR fully satisfies the linked issue PR 621 acceptance criteria. The embedded ~188-line system prompt string has been moved to a dedicated file at src/lib/groomer/prompts/system-prompt.ts with a parameterized builder function, referenced from llm.ts, and covered by comprehensive tests.
Change-by-Change Findings
1. src/lib/groomer/prompts/system-prompt.ts (new file, 77 lines)
The new buildGroomerSystemPrompt function accepts 9 runtime-computed parameters (lane IDs, label lists, lane guide text, etc.) and returns the full system prompt template with conditional sections:
- Conditional backlog exclusion:
backlogLaneId ? \, NEVER "${backlogLaneId}": ""— only emitted when a backlog lane is configured - Conditional escalation guidance:
escalationLaneId ? \Choose "${escalationLaneId}" ONLY for...: ""— only emitted when an escalation lane exists
This matches the prior behavior in llm.ts where these sections were conditionally built before interpolation.
2. src/lib/groomer/prompts/system-prompt.test.ts (new file, 96 lines)
17 test cases cover:
- All 9 parameter interpolations (lane IDs, labels, lane guide)
- Backlog exclusion conditional: present when
backlogLaneIdset, absent when empty - Escalation guidance conditional: present when
escalationLaneIdset, absent when empty - Core rule sections (title rewriting, body enrichment, comment rules, JSON schema)
Tests pass (CI confirms: Tests: success).
3. src/lib/groomer/llm.ts (modified: -46/+12 lines)
The buildSystemPrompt function now computes the same values as before but passes them to buildGroomerSystemPrompt instead of concatenating an inline template literal. The call is functionally identical to the prior inline string — no behavioral change to groomer output is expected.
Standards Compliance
| Standard | Status |
|---|---|
| No commit of secrets | ✅ Pass — no secrets in diff |
Error handling (error instanceof Error) |
✅ N/A — this is a pure transformation function |
| API routes return appropriate codes | ✅ N/A — no route changes |
| TypeScript validation | ✅ Pass (Typecheck: success) |
| Lint | ✅ Pass (Lint: success) |
| Tests | ✅ Pass (Tests: success) |
| Build | ✅ Pass (Build: success) |
Linked Issue Fit
Issue PR 621 acceptance criteria:
-
✅ "Move the prompt content to a dedicated file under
src/lib/groomer/prompts/"- Created:
src/lib/groomer/prompts/system-prompt.ts
- Created:
-
✅ "Reference it from
llm.ts"llm.tsimports and callsbuildGroomerSystemPromptfrom the new file
-
✅ "Prompt content should be reviewable as a diff when changed"
- The prompt now lives in its own file; any future change produces a clean diff with line-level visibility
Tool Harness Findings
| Tool | File | Status |
|---|---|---|
read_file |
src/lib/groomer/prompts/system-prompt.ts |
✅ Content matches diff |
read_file |
src/lib/groomer/llm.ts |
✅ Import and call verified |
read_file |
src/lib/groomer/prompts/system-prompt.test.ts |
✅ Content matches diff |
gh_api (repos/mitespace/dispatch/pulls) |
— |
Unknowns / Needs Verification
None identified. All changed files were read and verified against the diff. CI passed all checks. The acceptance criteria from PR 621 are fully satisfied.
What
Updates the groomer system prompt (
src/lib/groomer/prompts/system-prompt.ts) with three new rule sections — escalation lane guidance (default to local model for small/medium work, escalate only for genuinely hard cross-cutting changes), @mention safety in `githubC…Fixes #621
Opened by foreman on review GO (workload wl-misospace-dispatch-621).