lib/extract-subagent-ids.ts exports an extractSubagentIds(fileContent: string): string[] that scans newline-delimited JSON for toolUseResult.agentId values on user-type entries, deduplicates them, and returns the result. It has no unit test.
- Create
__tests__/lib/extract-subagent-ids.test.ts — model it on __tests__/lib/format-duration.test.ts.
- Import:
import { extractSubagentIds } from "@/lib/extract-subagent-ids";
- Cover: (a) happy path with two valid
user entries → both ids returned and deduped, (b) malformed JSON line is skipped silently, (c) type !== "user" entries are ignored, (d) non-hex agentId strings are rejected (regex /^[a-f0-9]+$/), (e) missing toolUseResult is ignored, (f) empty input returns [].
- Run
bun run test:run and confirm all cases pass.
Out of scope: changing extract-subagent-ids.ts itself.
lib/extract-subagent-ids.tsexports anextractSubagentIds(fileContent: string): string[]that scans newline-delimited JSON fortoolUseResult.agentIdvalues onuser-type entries, deduplicates them, and returns the result. It has no unit test.__tests__/lib/extract-subagent-ids.test.ts— model it on__tests__/lib/format-duration.test.ts.import { extractSubagentIds } from "@/lib/extract-subagent-ids";userentries → both ids returned and deduped, (b) malformed JSON line is skipped silently, (c)type !== "user"entries are ignored, (d) non-hexagentIdstrings are rejected (regex/^[a-f0-9]+$/), (e) missingtoolUseResultis ignored, (f) empty input returns[].bun run test:runand confirm all cases pass.Out of scope: changing
extract-subagent-ids.tsitself.