Files
loki/scripts/test
Mao NakamotoandClaude Opus 4.8 136a97e2d6 refactor(agents): extract + harden inbox parser, add fixture tests
Grounded the comms parser against the real ~/.claude/cross-project/inbox-*.md
files, which surfaced three defects in the shipped version:

- `---` message delimiters leaked into message bodies (feed noise). A rule
  line now closes the current message instead of being appended.
- Plain `Re:` subject lines (not just `**Re**:`) were dropped into the body.
  Both forms are now parsed.
- The dedupe id `from->to@ts` collapsed distinct same-day messages when a
  header carried a date with no time. The id now includes a content hash, so
  distinct bodies stay separate while byte-identical copies still dedupe.

Moved the pure parser out of the HTTP route into src/lib/agent-comms.ts
(SoC + testable), re-exported the AgentMessage type there as SSOT (AgentsCockpit
now imports it), and added scripts/test/agent-comms.ts (16 cases, inline
assertions per house convention) + a test:agent-comms npm script. Verified
against the live inbox files end-to-end.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-07 18:03:24 +02:00
..