← Public packages
@kentcdodds/sentry-triage
Sentry triage wakes Cole (Grok Bot) per issue: one active wake per repo (lease + queue), loop-safe Discord. Cole may spawn Cursor for isolated repo work.
src/agent-prompt.test.ts
65 lines · 2.3 KB · TypeScriptimport assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import { buildTriageAgentPrompt } from './agent-prompt.ts'
import { emptyIssueState } from './issue-state.ts'
import { triageProjectForSlug } from './shared.ts'
const project = triageProjectForSlug('kody')
describe('buildTriageAgentPrompt', () => {
it('seeds get-issue-state and tells the agent not to repeat it first', () => {
assert.ok(project)
const prompt = buildTriageAgentPrompt({
issue: {
id: '12345',
shortId: 'KODY-1',
title: 'TypeError: Cannot read properties of undefined',
culprit: 'packages.invoke',
level: 'error',
permalink: 'https://kent-c-dodds-tech-llc.sentry.io/issues/12345/',
},
project,
discordMessageId: 'msg-1',
context: {
eventSummary: { level: 'error', topFrames: ['src/foo.ts in bar:10'] },
siblings: [],
},
issueState: {
...emptyIssueState(),
capRemaining: 7,
spawnedThisHour: 3,
issuesSeenThisHour: 5,
record: { status: 'spawned', agentId: 'bc-1' },
},
})
assert.match(prompt, /Do not start by repeating those calls/)
assert.match(prompt, /capRemaining: 7/)
assert.match(prompt, /issuesSeenThisHour: 5/)
assert.match(prompt, /stored record status: spawned/)
assert.match(prompt, /src\/foo.ts in bar:10/)
assert.match(prompt, /kody:@kentcdodds\/sentry-triage\/record-outcome/)
assert.match(prompt, /needs-Kent-decision/)
assert.match(prompt, /title: 'short decision title'/)
assert.match(prompt, /Choosable option A/)
assert.match(prompt, /Every option needs an impact tag/)
assert.match(prompt, /You are Cole \(Grok Bot\)/)
assert.match(prompt, /Do not auto-fan-out extra triage agents/)
})
it('uses override package names in execute samples', () => {
assert.ok(project)
const prompt = buildTriageAgentPrompt({
issue: { id: '9', title: 'x', permalink: 'https://example.test/9' },
project,
discordMessageId: 'msg-2',
selfPackageName: '@you/sentry-triage',
sentryPackageName: '@you/sentry',
sentryOrgSlug: 'your-org',
discordChannelId: '111',
})
assert.match(prompt, /kody:@you\/sentry-triage\/record-outcome/)
assert.match(prompt, /kody:@you\/sentry\/request/)
assert.match(prompt, /organizations\/your-org\/issues\/9/)
assert.doesNotMatch(prompt, /kody:@kentcdodds\/sentry-triage\/record-outcome/)
})
})