feat(DIS-105): codeblock-aware message splitting for Discord 2000-char limit #47

Merged
dev merged 3 commits from phase-1/split-for-discord into main 2026-04-10 08:15:38 +00:00
Owner

Summary

  • Add splitForDiscord() in src/discord/split.ts with codeblock-aware line-based splitting
  • Fenced code blocks are properly closed (```) at chunk boundaries and reopened with the original language tag in the next chunk
  • No chunk ever exceeds 2000 characters (Discord hard limit); configurable soft limit defaults to 1900
  • src/router.ts now imports and uses splitForDiscord instead of the removed internal splitMessage()
  • 7 new unit tests cover all specified cases (short message, exact limit, plain split, fence continuity, hard limit, empty input, lang tag preservation)

Test plan

  • npm test passes all 51 tests (7 new + 44 existing)
  • Verify fence close/reopen in chunk (d) test produces correct ```typescript prefix
  • Verify no chunk in stress test (e) exceeds 2000 chars
## Summary - Add `splitForDiscord()` in `src/discord/split.ts` with codeblock-aware line-based splitting - Fenced code blocks are properly closed (```` ``` ````) at chunk boundaries and reopened with the original language tag in the next chunk - No chunk ever exceeds 2000 characters (Discord hard limit); configurable soft limit defaults to 1900 - `src/router.ts` now imports and uses `splitForDiscord` instead of the removed internal `splitMessage()` - 7 new unit tests cover all specified cases (short message, exact limit, plain split, fence continuity, hard limit, empty input, lang tag preservation) ## Test plan - [ ] `npm test` passes all 51 tests (7 new + 44 existing) - [ ] Verify fence close/reopen in chunk (d) test produces correct ` ```typescript ` prefix - [ ] Verify no chunk in stress test (e) exceeds 2000 chars
dev added 1 commit 2026-04-09 15:49:14 +00:00
feat(DIS-105): codeblock-aware message splitting for Discord 2000-char limit
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
00132c6d22
Add splitForDiscord() in src/discord/split.ts.
Fences are properly closed and reopened across chunk boundaries.
Router uses splitForDiscord instead of internal splitMessage().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev added 2 commits 2026-04-10 08:14:07 +00:00
Resolve conflict in src/router.ts: keep both splitForDiscord (DIS-105)
and sanitizeForDiscord (DIS-102). Apply splitForDiscord to the already
sanitized response text.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fix(DIS-105): prevent fence closure from pushing chunks beyond 2000-char hard limit
Some checks failed
CI / build-and-test (ubuntu-latest) (pull_request) Has been cancelled
CI / build-and-test (windows-latest) (pull_request) Has been cancelled
CI / lint (pull_request) Has been cancelled
62ea507974
The flush() helper now enforces the Discord hard limit by hard-splitting
any chunk that exceeds 2000 chars (e.g. when "\n```" was appended after
the soft-limit check). Also reserves 4 chars of overhead in the
soft-limit check when inside a fenced code block.

Adds a regression test that verifies no chunk exceeds 2000 chars even
when the fence closure is appended at the limit boundary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev merged commit e390365810 into main 2026-04-10 08:15:38 +00:00
dev deleted branch phase-1/split-for-discord 2026-04-10 08:15:50 +00:00
Sign in to join this conversation.
No description provided.