Skip to content

Extract groomer LLM prompts to dedicated files#626

Merged
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-dispatch-621/issue-621
Jul 15, 2026
Merged

Extract groomer LLM prompts to dedicated files#626
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-dispatch-621/issue-621

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

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).

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>
@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner July 15, 2026 17:10

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 backlogLaneId set, absent when empty
  • Escalation guidance conditional: present when escalationLaneId set, 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:

  1. ✅ "Move the prompt content to a dedicated file under src/lib/groomer/prompts/"

    • Created: src/lib/groomer/prompts/system-prompt.ts
  2. ✅ "Reference it from llm.ts"

    • llm.ts imports and calls buildGroomerSystemPrompt from the new file
  3. ✅ "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) ⚠️ 404 — unrelated to this PR (endpoint does not exist in this form); no impact

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.

@joryirving
joryirving merged commit 6e4baca into main Jul 15, 2026
6 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-dispatch-621/issue-621 branch July 15, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract groomer LLM prompts to dedicated files

2 participants