@iceinvein/agent-skills 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +4 -3
  2. package/dist/cli/index.js +775 -236
  3. package/package.json +2 -1
  4. package/skills/index.json +2 -2
  5. package/skills/magpie/README.md +14 -0
  6. package/skills/magpie/SKILL.md +42 -23
  7. package/skills/magpie/bin/magpie.ts +91 -3
  8. package/skills/magpie/evals/README.md +1 -1
  9. package/skills/magpie/evals/post-folds-selection-events/fixture.sh +35 -0
  10. package/skills/magpie/evals/post-folds-selection-events/graders/selection-read-from-magpie-view.md +6 -0
  11. package/skills/magpie/evals/post-folds-selection-events/prompt.md +2 -2
  12. package/skills/magpie/evals/rules.json +2 -2
  13. package/skills/magpie/package.json +1 -1
  14. package/skills/magpie/references/critic.md +2 -2
  15. package/skills/magpie/references/peer-review.md +7 -7
  16. package/skills/magpie/references/proof.md +2 -2
  17. package/skills/magpie/scripts/__tests__/helper.test.ts +300 -0
  18. package/skills/magpie/scripts/__tests__/labels.test.ts +46 -1
  19. package/skills/magpie/scripts/__tests__/mark-cmd.test.ts +129 -0
  20. package/skills/magpie/scripts/__tests__/peer-run.test.ts +231 -0
  21. package/skills/magpie/scripts/__tests__/post-cmd.test.ts +298 -1
  22. package/skills/magpie/scripts/__tests__/preflight.test.ts +22 -1
  23. package/skills/magpie/scripts/__tests__/render-cmd.test.ts +15 -1
  24. package/skills/magpie/scripts/__tests__/render-findings.test.ts +13 -0
  25. package/skills/magpie/scripts/__tests__/server.test.ts +96 -1
  26. package/skills/magpie/scripts/__tests__/setup-cmd.test.ts +14 -0
  27. package/skills/magpie/scripts/__tests__/skill-lint.test.ts +68 -4
  28. package/skills/magpie/scripts/__tests__/view-cmd.test.ts +219 -0
  29. package/skills/magpie/scripts/helper.js +44 -4
  30. package/skills/magpie/scripts/labels.ts +11 -0
  31. package/skills/magpie/scripts/mark-cmd.ts +56 -0
  32. package/skills/magpie/scripts/peer-run.ts +146 -0
  33. package/skills/magpie/scripts/post-cmd.ts +75 -5
  34. package/skills/magpie/scripts/preflight.ts +20 -20
  35. package/skills/magpie/scripts/render-cmd.ts +3 -1
  36. package/skills/magpie/scripts/render-findings.ts +3 -1
  37. package/skills/magpie/scripts/server.ts +31 -2
  38. package/skills/magpie/scripts/setup-cmd.ts +7 -1
  39. package/skills/magpie/scripts/view-cmd.ts +143 -0
  40. package/skills/magpie/skill.json +1 -1
  41. package/skills/sluice/SKILL.md +21 -6
  42. package/skills/sluice/references/deep-channel.md +35 -25
  43. package/skills/sluice/references/finish.md +2 -2
  44. package/skills/sluice/references/intent.md +1 -1
  45. package/skills/sluice/references/status.md +10 -4
  46. package/skills/sluice/references/test-first.md +12 -0
  47. package/skills/sluice/scripts/board-index.sh +59 -37
  48. package/skills/sluice/scripts/board.sh +72 -40
  49. package/skills/sluice/scripts/host.sh +60 -0
  50. package/skills/sluice/scripts/run-stats.sh +41 -3
  51. package/skills/sluice/scripts/session-start.sh +75 -17
  52. package/skills/sluice/scripts/status.sh +9 -5
  53. package/skills/sluice/scripts/stop-guard.sh +101 -37
  54. package/skills/sluice/scripts/transcript.sh +221 -0
  55. package/skills/sluice/skill.json +1 -1
@@ -240,3 +240,303 @@ test('each page post path sends its via to the server', async () => {
240
240
  'JSON.stringify({ findingIds: ids, via })',
241
241
  )
242
242
  })
243
+
244
+ // A page small enough to run helper.js against: two findings, each with a card
245
+ // and a checkbox, plus the action bar's count, status line and post button.
246
+ type FakeResponse = { ok: boolean; status: number; body: unknown }
247
+
248
+ class FakeElement {
249
+ tagName: string
250
+ attrs: Map<string, string>
251
+ dataset: Record<string, string> = {}
252
+ checked = false
253
+ disabled = false
254
+ hidden = false
255
+ className = ''
256
+ private text = ''
257
+ onText: (() => void) | null = null
258
+
259
+ constructor(tag: string, attrs: Record<string, string>) {
260
+ this.tagName = tag.toUpperCase()
261
+ this.attrs = new Map(Object.entries(attrs))
262
+ for (const [name, value] of Object.entries(attrs)) {
263
+ if (!name.startsWith('data-')) continue
264
+ const key = name.slice(5).replace(/-([a-z])/g, (_, c: string) => c.toUpperCase())
265
+ this.dataset[key] = value
266
+ }
267
+ }
268
+
269
+ get type(): string | undefined {
270
+ return this.attrs.get('type')
271
+ }
272
+
273
+ get textContent(): string {
274
+ return this.text
275
+ }
276
+
277
+ set textContent(value: string) {
278
+ this.text = value
279
+ this.onText?.()
280
+ }
281
+
282
+ getAttribute(name: string): string | null {
283
+ return this.attrs.get(name) ?? null
284
+ }
285
+
286
+ setAttribute(name: string, value: string): void {
287
+ this.attrs.set(name, value)
288
+ }
289
+
290
+ hasAttribute(name: string): boolean {
291
+ return this.attrs.has(name)
292
+ }
293
+
294
+ removeAttribute(name: string): void {
295
+ this.attrs.delete(name)
296
+ }
297
+
298
+ querySelector(): null {
299
+ return null
300
+ }
301
+
302
+ closest(selector: string): FakeElement | null {
303
+ return this.matches(selector) ? this : null
304
+ }
305
+
306
+ // Only compound tag and attribute selectors, which is all the paths under test use.
307
+ matches(selector: string): boolean {
308
+ const m = selector.match(/^(\w+)?((?:\[[^\]]+\])*)(?::not\((\w+)\))?$/)
309
+ if (!m) return false
310
+ const [, tag, attrPart, notTag] = m
311
+ if (tag && tag.toUpperCase() !== this.tagName) return false
312
+ if (notTag && notTag.toUpperCase() === this.tagName) return false
313
+ for (const [, name, value] of (attrPart ?? '').matchAll(/\[([\w-]+)(?:="([^"]*)")?\]/g)) {
314
+ if (name === undefined || !this.attrs.has(name)) return false
315
+ if (value !== undefined && this.attrs.get(name) !== value) return false
316
+ }
317
+ return true
318
+ }
319
+ }
320
+
321
+ type Page = {
322
+ checkbox: (id: string) => FakeElement
323
+ card: (id: string) => FakeElement
324
+ status: FakeElement
325
+ postSelected: FakeElement
326
+ requests: string[]
327
+ answers: Record<string, FakeResponse>
328
+ focus: () => void
329
+ click: (el: FakeElement) => void
330
+ selectionApplied: (n: number) => Promise<void>
331
+ statusShown: (match: RegExp) => Promise<void>
332
+ }
333
+
334
+ async function openPage(opts: {
335
+ protocol?: string
336
+ persisted?: string[]
337
+ answers: Record<string, FakeResponse>
338
+ }): Promise<Page> {
339
+ const src = await readFile(HELPER, 'utf8')
340
+ const elements: FakeElement[] = []
341
+ for (const id of ['bugs-1', 'perf-2']) {
342
+ elements.push(new FakeElement('div', { 'data-finding-id': id }))
343
+ elements.push(new FakeElement('input', { type: 'checkbox', 'data-finding-id': id }))
344
+ }
345
+ const count = new FakeElement('span', { 'data-role': 'selected-count' })
346
+ const status = new FakeElement('p', { 'data-role': 'post-status' })
347
+ const postSelected = new FakeElement('button', { 'data-action': 'post-selected' })
348
+ elements.push(count, status, postSelected)
349
+
350
+ const requests: string[] = []
351
+ const answers = opts.answers
352
+ let selectionAnswers = 0
353
+ let selectionApplied = 0
354
+ const appliedWaiters: Array<{ n: number; resolve: () => void }> = []
355
+ count.onText = () => {
356
+ selectionApplied = selectionAnswers
357
+ for (const w of appliedWaiters.splice(0)) {
358
+ if (selectionApplied >= w.n) w.resolve()
359
+ else appliedWaiters.push(w)
360
+ }
361
+ }
362
+ const statusWaiters: Array<{ match: RegExp; resolve: () => void }> = []
363
+ status.onText = () => {
364
+ for (const w of statusWaiters.splice(0)) {
365
+ if (w.match.test(status.textContent)) w.resolve()
366
+ else statusWaiters.push(w)
367
+ }
368
+ }
369
+
370
+ const docListeners = new Map<string, Array<(e: unknown) => void>>()
371
+ const winListeners = new Map<string, Array<(e: unknown) => void>>()
372
+ const listen =
373
+ (map: Map<string, Array<(e: unknown) => void>>) => (type: string, fn: (e: unknown) => void) => {
374
+ map.set(type, [...(map.get(type) ?? []), fn])
375
+ }
376
+ const document = {
377
+ readyState: 'complete',
378
+ body: { dataset: { runId: 'pr-1337-test' } },
379
+ documentElement: { dataset: {} as Record<string, string> },
380
+ querySelectorAll: (sel: string) => elements.filter((el) => el.matches(sel)),
381
+ querySelector: (sel: string) => elements.find((el) => el.matches(sel)) ?? null,
382
+ addEventListener: listen(docListeners),
383
+ }
384
+ const window = { addEventListener: listen(winListeners) }
385
+ const store = new Map<string, string>()
386
+ if (opts.persisted) store.set('magpie:selection:pr-1337-test', JSON.stringify(opts.persisted))
387
+ const localStorage = {
388
+ getItem: (k: string) => store.get(k) ?? null,
389
+ setItem: (k: string, v: string) => store.set(k, v),
390
+ }
391
+ const fetch = async (url: string) => {
392
+ requests.push(url)
393
+ const answer = answers[url]
394
+ if (!answer) throw new Error(`no answer for ${url}`)
395
+ if (url === '/selection') selectionAnswers++
396
+ return { ok: answer.ok, status: answer.status, json: async () => answer.body }
397
+ }
398
+ const noTimer = () => 0
399
+ new Function(
400
+ 'document',
401
+ 'window',
402
+ 'location',
403
+ 'localStorage',
404
+ 'fetch',
405
+ 'HTMLElement',
406
+ 'HTMLInputElement',
407
+ 'HTMLButtonElement',
408
+ 'HTMLTextAreaElement',
409
+ 'setInterval',
410
+ 'setTimeout',
411
+ 'clearTimeout',
412
+ src,
413
+ )(
414
+ document,
415
+ window,
416
+ { protocol: opts.protocol ?? 'http:' },
417
+ localStorage,
418
+ fetch,
419
+ FakeElement,
420
+ FakeElement,
421
+ FakeElement,
422
+ class {},
423
+ noTimer,
424
+ noTimer,
425
+ noTimer,
426
+ )
427
+
428
+ const find = (tag: string, id: string) => {
429
+ const el = elements.find((e) => e.tagName === tag && e.getAttribute('data-finding-id') === id)
430
+ if (!el) throw new Error(`no ${tag} for ${id}`)
431
+ return el
432
+ }
433
+ return {
434
+ checkbox: (id) => find('INPUT', id),
435
+ card: (id) => find('DIV', id),
436
+ status,
437
+ postSelected,
438
+ requests,
439
+ answers,
440
+ focus: () => {
441
+ for (const fn of winListeners.get('focus') ?? []) fn({})
442
+ },
443
+ click: (el) => {
444
+ for (const fn of docListeners.get('click') ?? []) fn({ target: el })
445
+ },
446
+ selectionApplied: (n) =>
447
+ new Promise((resolve) => {
448
+ if (selectionApplied >= n) resolve()
449
+ else appliedWaiters.push({ n, resolve })
450
+ }),
451
+ statusShown: (match) =>
452
+ new Promise((resolve) => {
453
+ if (match.test(status.textContent)) resolve()
454
+ else statusWaiters.push({ match, resolve })
455
+ }),
456
+ }
457
+ }
458
+
459
+ const live = { ok: true, status: 200, body: null }
460
+
461
+ function selection(selected: string[], posted: string[] = []): FakeResponse {
462
+ return { ok: true, status: 200, body: { selected, posted } }
463
+ }
464
+
465
+ test('a live page ticks the ids /selection answers and posts no event for them', async () => {
466
+ const page = await openPage({
467
+ answers: { '/heartbeat': live, '/selection': selection(['bugs-1']) },
468
+ })
469
+ await page.selectionApplied(1)
470
+ expect(page.checkbox('bugs-1').checked).toBe(true)
471
+ expect(page.checkbox('perf-2').checked).toBe(false)
472
+ expect(page.requests).not.toContain('/events')
473
+ })
474
+
475
+ test('a focus after the selection changes to empty unticks the finding', async () => {
476
+ const page = await openPage({
477
+ answers: { '/heartbeat': live, '/selection': selection(['bugs-1']) },
478
+ })
479
+ await page.selectionApplied(1)
480
+ page.answers['/selection'] = selection([])
481
+ page.focus()
482
+ await page.selectionApplied(2)
483
+ expect(page.checkbox('bugs-1').checked).toBe(false)
484
+ expect(page.requests).not.toContain('/events')
485
+ })
486
+
487
+ test('a focus answer listing a finding as posted leaves it checked and disabled', async () => {
488
+ const page = await openPage({
489
+ answers: { '/heartbeat': live, '/selection': selection([]) },
490
+ })
491
+ await page.selectionApplied(1)
492
+ page.answers['/selection'] = selection([], ['bugs-1'])
493
+ page.focus()
494
+ await page.selectionApplied(2)
495
+ expect(page.checkbox('bugs-1').checked).toBe(true)
496
+ expect(page.checkbox('bugs-1').disabled).toBe(true)
497
+ })
498
+
499
+ test('a live page takes its ticks from /selection, not from localStorage', async () => {
500
+ const page = await openPage({
501
+ persisted: ['perf-2'],
502
+ answers: { '/heartbeat': live, '/selection': selection([]) },
503
+ })
504
+ await page.selectionApplied(1)
505
+ expect(page.checkbox('perf-2').checked).toBe(false)
506
+ })
507
+
508
+ test('a report opened from file still ticks from localStorage', async () => {
509
+ const page = await openPage({ protocol: 'file:', persisted: ['perf-2'], answers: {} })
510
+ expect(page.checkbox('perf-2').checked).toBe(true)
511
+ expect(page.requests).toEqual([])
512
+ })
513
+
514
+ test('a failed /selection fetch shows the status line', async () => {
515
+ const page = await openPage({
516
+ answers: {
517
+ '/heartbeat': live,
518
+ '/selection': { ok: false, status: 500, body: { error: 'bad events line' } },
519
+ },
520
+ })
521
+ await page.statusShown(/bad events line/)
522
+ expect(page.status.hidden).toBe(false)
523
+ })
524
+
525
+ test('an already-posted result from Post Selected marks the finding posted', async () => {
526
+ const page = await openPage({
527
+ answers: {
528
+ '/heartbeat': live,
529
+ '/selection': selection(['bugs-1']),
530
+ '/api/post-review': {
531
+ ok: true,
532
+ status: 200,
533
+ body: { reviewId: null, comments: [{ id: 'bugs-1', status: 'already-posted' }] },
534
+ },
535
+ },
536
+ })
537
+ await page.selectionApplied(1)
538
+ page.click(page.postSelected)
539
+ await page.statusShown(/already posted/)
540
+ expect(page.card('bugs-1').getAttribute('data-posted')).toBe('true')
541
+ expect(page.checkbox('bugs-1').disabled).toBe(true)
542
+ })
@@ -2,7 +2,7 @@ import { afterEach, beforeEach, expect, test } from 'bun:test'
2
2
  import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
3
3
  import { tmpdir } from 'node:os'
4
4
  import { join } from 'node:path'
5
- import { foldLabels, readDismissed } from '../labels.ts'
5
+ import { foldLabels, foldSelection, readDismissed } from '../labels.ts'
6
6
 
7
7
  test('a posted id is labelled posted with the via from its post log entry', () => {
8
8
  const labels = foldLabels({
@@ -150,3 +150,48 @@ test('readDismissed returns an empty map when state/events does not exist', asyn
150
150
  const dismissed = await readDismissed(runDir)
151
151
  expect(dismissed.size).toBe(0)
152
152
  })
153
+
154
+ test('an id selected and then deselected is not selected', () => {
155
+ const selected = foldSelection([
156
+ { type: 'select', findingId: 'a', timestamp: 1 },
157
+ { type: 'deselect', findingId: 'a', timestamp: 2 },
158
+ ])
159
+ expect([...selected]).toEqual([])
160
+ })
161
+
162
+ test('an id selected again after a deselect is selected', () => {
163
+ const selected = foldSelection([
164
+ { type: 'select', findingId: 'a', timestamp: 1 },
165
+ { type: 'deselect', findingId: 'a', timestamp: 2 },
166
+ { type: 'select', findingId: 'a', timestamp: 3 },
167
+ ])
168
+ expect([...selected]).toEqual(['a'])
169
+ })
170
+
171
+ test('a dismiss after a select unselects the id', () => {
172
+ const selected = foldSelection([
173
+ { type: 'select', findingId: 'a', timestamp: 1 },
174
+ { type: 'dismiss', findingId: 'a', reason: 'wrong', timestamp: 2 },
175
+ ])
176
+ expect([...selected]).toEqual([])
177
+ })
178
+
179
+ test('undismiss leaves the selection alone and a later select still selects', () => {
180
+ const selected = foldSelection([
181
+ { type: 'dismiss', findingId: 'a', reason: 'style', timestamp: 1 },
182
+ { type: 'undismiss', findingId: 'a', timestamp: 2 },
183
+ { type: 'select', findingId: 'a', timestamp: 3 },
184
+ { type: 'select', findingId: 'b', timestamp: 4 },
185
+ { type: 'undismiss', findingId: 'b', timestamp: 5 },
186
+ ])
187
+ expect([...selected].sort()).toEqual(['a', 'b'])
188
+ })
189
+
190
+ test('events without a string findingId are skipped', () => {
191
+ const selected = foldSelection([
192
+ { type: 'select', findingId: 'a', timestamp: 1 },
193
+ { type: 'deselect', findingId: 7, timestamp: 2 },
194
+ { type: 'select', timestamp: 3 },
195
+ ])
196
+ expect([...selected]).toEqual(['a'])
197
+ })
@@ -0,0 +1,129 @@
1
+ import { afterEach, beforeEach, expect, test } from 'bun:test'
2
+ import { existsSync } from 'node:fs'
3
+ import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'
4
+ import { tmpdir } from 'node:os'
5
+ import { join } from 'node:path'
6
+ import { readDismissed } from '../labels.ts'
7
+
8
+ const FIXTURE = new URL('../../fixtures/example-pr', import.meta.url).pathname
9
+ const CLI = new URL('../../bin/magpie.ts', import.meta.url).pathname
10
+
11
+ let runDir: string
12
+ let eventsPath: string
13
+
14
+ beforeEach(async () => {
15
+ runDir = await mkdtemp(join(tmpdir(), 'magpie-mark-'))
16
+ await cp(FIXTURE, runDir, { recursive: true })
17
+ eventsPath = join(runDir, 'state', 'events')
18
+ })
19
+
20
+ afterEach(async () => {
21
+ await rm(runDir, { recursive: true, force: true })
22
+ })
23
+
24
+ async function mark(args: string[]): Promise<{ exit: number; stderr: string }> {
25
+ const proc = Bun.spawn(['bun', CLI, 'mark', runDir, ...args], { stdout: 'pipe', stderr: 'pipe' })
26
+ const exit = await proc.exited
27
+ const stderr = await new Response(proc.stderr).text()
28
+ return { exit, stderr }
29
+ }
30
+
31
+ async function eventLines(): Promise<Array<Record<string, unknown>>> {
32
+ const text = await readFile(eventsPath, 'utf8')
33
+ return text
34
+ .split('\n')
35
+ .filter((line) => line !== '')
36
+ .map((line) => JSON.parse(line) as Record<string, unknown>)
37
+ }
38
+
39
+ const EXISTING = '{"type":"select","findingId":"perf-1","timestamp":1}\n'
40
+
41
+ async function seedEvents(): Promise<void> {
42
+ await mkdir(join(runDir, 'state'), { recursive: true })
43
+ await writeFile(eventsPath, EXISTING)
44
+ }
45
+
46
+ test('mark select appends one select line for the finding', async () => {
47
+ const result = await mark(['bugs-1', 'select'])
48
+ expect(result.stderr).toBe('')
49
+ expect(result.exit).toBe(0)
50
+ const lines = await eventLines()
51
+ expect(lines).toHaveLength(1)
52
+ expect(lines[0]?.type).toBe('select')
53
+ expect(lines[0]?.findingId).toBe('bugs-1')
54
+ expect(typeof lines[0]?.timestamp).toBe('number')
55
+ })
56
+
57
+ test('mark appends after the events already in state/events', async () => {
58
+ await seedEvents()
59
+ expect((await mark(['bugs-1', 'deselect'])).exit).toBe(0)
60
+ const lines = await eventLines()
61
+ expect(lines.map((l) => [l.type, l.findingId])).toEqual([
62
+ ['select', 'perf-1'],
63
+ ['deselect', 'bugs-1'],
64
+ ])
65
+ })
66
+
67
+ test('mark dismiss writes the reason on the line', async () => {
68
+ expect((await mark(['bugs-1', 'dismiss', 'style'])).exit).toBe(0)
69
+ const lines = await eventLines()
70
+ expect(lines).toHaveLength(1)
71
+ expect(lines[0]?.type).toBe('dismiss')
72
+ expect(lines[0]?.findingId).toBe('bugs-1')
73
+ expect(lines[0]?.reason).toBe('style')
74
+ })
75
+
76
+ test('a dismissal written by mark is read back by readDismissed with its reason', async () => {
77
+ expect((await mark(['bugs-1', 'dismiss', 'style'])).exit).toBe(0)
78
+ expect(await readDismissed(runDir)).toEqual(new Map([['bugs-1', 'style']]))
79
+ })
80
+
81
+ test('mark undismiss appends an undismiss line', async () => {
82
+ expect((await mark(['bugs-1', 'undismiss'])).exit).toBe(0)
83
+ const lines = await eventLines()
84
+ expect(lines.map((l) => [l.type, l.findingId])).toEqual([['undismiss', 'bugs-1']])
85
+ })
86
+
87
+ test('mark of an id not in findings.final.json exits 2 and leaves state/events unchanged', async () => {
88
+ await seedEvents()
89
+ const result = await mark(['nope-1', 'select'])
90
+ expect(result.exit).toBe(2)
91
+ expect(result.stderr).toContain('nope-1')
92
+ expect(await readFile(eventsPath, 'utf8')).toBe(EXISTING)
93
+ })
94
+
95
+ test('mark with an unknown verb exits 2 and leaves state/events unchanged', async () => {
96
+ await seedEvents()
97
+ const result = await mark(['bugs-1', 'toggle'])
98
+ expect(result.exit).toBe(2)
99
+ expect(result.stderr).toContain('toggle')
100
+ expect(await readFile(eventsPath, 'utf8')).toBe(EXISTING)
101
+ })
102
+
103
+ test('mark dismiss with an unknown reason exits 2 and leaves state/events unchanged', async () => {
104
+ await seedEvents()
105
+ const result = await mark(['bugs-1', 'dismiss', 'meh'])
106
+ expect(result.exit).toBe(2)
107
+ expect(result.stderr).toContain('meh')
108
+ expect(await readFile(eventsPath, 'utf8')).toBe(EXISTING)
109
+ })
110
+
111
+ test('mark dismiss without a reason exits 2 and leaves state/events unchanged', async () => {
112
+ await seedEvents()
113
+ const result = await mark(['bugs-1', 'dismiss'])
114
+ expect(result.exit).toBe(2)
115
+ expect(await readFile(eventsPath, 'utf8')).toBe(EXISTING)
116
+ })
117
+
118
+ test('mark with a reason after a verb other than dismiss exits 2 and leaves state/events unchanged', async () => {
119
+ await seedEvents()
120
+ const result = await mark(['bugs-1', 'select', 'wrong'])
121
+ expect(result.exit).toBe(2)
122
+ expect(result.stderr).toContain('wrong')
123
+ expect(await readFile(eventsPath, 'utf8')).toBe(EXISTING)
124
+ })
125
+
126
+ test('a rejected mark on a run with no state/events creates no file', async () => {
127
+ expect((await mark(['nope-1', 'select'])).exit).toBe(2)
128
+ expect(existsSync(eventsPath)).toBe(false)
129
+ })