← Public packages
@kentcdodds/ship-pr
Progressive ship-pr loop for agents: PR status, Bugbot, review sort, human review feedback, 7-day decisions, merge, deploy, wrap-up.
Files
import assert from 'node:assert/strict'
import test from 'node:test'
import { agentLabel, parseAgent } from './agent.ts'
test('legacy Cursor agentId keeps working unchanged', () => {
assert.deepEqual(parseAgent({ agentId: ' bc-abc ' }, 'x', true), { kind: 'cursor', cursorAgentId: 'bc-abc', id: 'bc-abc' })
assert.deepEqual(parseAgent({ agent: { kind: 'cursor', id: 'bc-abc' } }, 'x', true)?.cursorAgentId, 'bc-abc')
assert.deepEqual(parseAgent({ agentId: 'bc-abc', agent: { kind: 'Cursor' } }, 'x', true)?.cursorAgentId, 'bc-abc')
assert.throws(() => parseAgent({ agentId: 'bc-a', agent: { kind: 'cursor', id: 'bc-b' } }, 'x', true), /disagree/)
assert.throws(() => parseAgent({ agent: { kind: 'cursor' } }, 'x', true), /needs the bc-/)
})
test('non-Cursor agents identify themselves without a Cursor id', () => {
const codex = parseAgent({ agent: { kind: 'codex' } }, 'x', true)!
assert.equal(codex.cursorAgentId, null)
assert.equal(agentLabel(codex), 'Codex')
const named = parseAgent({ agent: { kind: 'codex', id: 'task_1', name: 'Codex cloud', url: 'https://chatgpt.com/codex/tasks/task_1' } }, 'x', true)!
assert.equal(agentLabel(named), 'Codex cloud · task_1')
assert.equal(named.url, 'https://chatgpt.com/codex/tasks/task_1')
assert.equal(agentLabel(parseAgent({ agent: { kind: 'other', name: 'Goose' } }, 'x', true)!), 'Goose')
})
test('rejects fabricated or malformed identities', () => {
assert.throws(() => parseAgent({}, 'x', true), /identify the agent.*Never fabricate a Cursor id/)
assert.equal(parseAgent({}, 'x', false), null)
assert.throws(() => parseAgent({ agentId: 'bc-fake', agent: { kind: 'codex' } }, 'x', true), /only for Cursor agents/)
assert.throws(() => parseAgent({ agent: { kind: 'gpt' } }, 'x', true), /agent.kind must be one of/)
assert.throws(() => parseAgent({ agent: { kind: 'other' } }, 'x', true), /needs agent.name/)
assert.throws(() => parseAgent({ agent: { kind: 'codex', url: 'javascript:alert(1)' } }, 'x', true), /https URL/)
assert.throws(() => parseAgent({ agent: { kind: 'codex', model: 'x' } }, 'x', true), /unknown agent key/)
assert.throws(() => parseAgent({ agent: 'codex' }, 'x', true), /must be an object/)
})