test(server): unit-test skill-loader template + dispatch prompt builder (#273 follow-up) #287
No reviewers
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!287
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "test/s11-skill-loader"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR #273 s11 extraction follow-up. Covers
skill-loader.ts.Coverage (18 tests across 8 describe blocks)
interpolate— string/numeric sub, repeats, unknown-placeholder fallback to literal{{key}}, non-word keys skipped, no-placeholder passthroughSTATELESS_SKILLS— pinned to{review, design-review}; tripwire against silent additionsskillForEvent— stateless skill always returns base; no-session → base; active session →-delta; delta missing → fallback to basebuildPromptForDispatch— interpolates + no appendix heading when null; appends under heading when set; whitespace-only appendix treated as emptyshouldApplyCaveman—caveman: trueunconditional;caveman_labelslabel-gated; missingtoken_economyshort-circuits to falsemaybeApplyCavemanAppendix— passthrough when not applied; appended forcaveman: true; appended on label matchapplyArtifactStyleAppendix— always appends; empty task safeBehaviour surprises
interpolate's regex is/\{\{(\w+)\}\}/g— placeholders with hyphens or dots ({{repo.owner}}) are silently ignored. Test pins the current contract.shouldApplyCavemanshort-circuits tofalsewhentoken_economyisundefined— deliberate legacy-fixture escape hatch; noted in-line.skillForEvent's delta-fallback path is a baretry/catch; any file-read error silently falls back to the full template. Tested viabreakdown(no delta variant). If someone addsbreakdown-delta.md, this test will need a new skill name.skillForAgentis not inskill-loader.tsdespite what the task brief said — it lives inhttp/webhook-routing.tsand already has dedicated coverage atwebhook-routing.test.ts:160. Not duplicated.Isolation seam
CLAUDE_HOOKS_STATE_DIR+mkdtempinbeforeEach(same pattern assessions.test.ts), plus clearing the module-levelskillCachebefore each test. Nomock.module.Checks
bunx tsc --noEmit -p apps/server/tsconfig.json— EXIT=0bun test apps/server/src/domain/analytics/skill-loader.test.ts— 18/18 pass (~55 ms)