Skip to content

Commit 2709b2f

Browse files
Ark0Nclaude
andcommitted
feat: make buffer size limits configurable via environment variables
Allow overriding MAX_TERMINAL_BUFFER_SIZE, TRIM_TERMINAL_TO, MAX_TEXT_OUTPUT_SIZE, TRIM_TEXT_TO, and MAX_MESSAGES via CODEMAN_* env vars, falling back to existing defaults. Enables users with fewer sessions or more RAM to tune buffer sizes without patching source. Closes #48 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b1d3b27 commit 2709b2f

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/config/buffer-limits.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
* Maximum terminal buffer size in characters.
2323
* Contains raw terminal output with ANSI escape sequences.
2424
* Reduced from 5MB to 2MB for better render performance.
25+
* Override: CODEMAN_MAX_TERMINAL_BUFFER (bytes)
2526
*/
26-
export const MAX_TERMINAL_BUFFER_SIZE = 2 * 1024 * 1024; // 2MB
27+
export const MAX_TERMINAL_BUFFER_SIZE = parseInt(process.env.CODEMAN_MAX_TERMINAL_BUFFER || '') || 2 * 1024 * 1024;
2728

2829
/**
2930
* Size to trim terminal buffer to when max is exceeded.
3031
* Keeps the most recent portion to preserve context.
32+
* Override: CODEMAN_TRIM_TERMINAL_TO (bytes)
3133
*/
32-
export const TRIM_TERMINAL_TO = 1.5 * 1024 * 1024; // 1.5MB
34+
export const TRIM_TERMINAL_TO = parseInt(process.env.CODEMAN_TRIM_TERMINAL_TO || '') || 1.5 * 1024 * 1024;
3335

3436
// ============================================================================
3537
// Text Output Buffer Limits
@@ -38,13 +40,15 @@ export const TRIM_TERMINAL_TO = 1.5 * 1024 * 1024; // 1.5MB
3840
/**
3941
* Maximum text output buffer size in characters.
4042
* Contains ANSI-stripped text for search and analysis.
43+
* Override: CODEMAN_MAX_TEXT_OUTPUT (bytes)
4144
*/
42-
export const MAX_TEXT_OUTPUT_SIZE = 1 * 1024 * 1024; // 1MB
45+
export const MAX_TEXT_OUTPUT_SIZE = parseInt(process.env.CODEMAN_MAX_TEXT_OUTPUT || '') || 1 * 1024 * 1024;
4346

4447
/**
4548
* Size to trim text output buffer to when max is exceeded.
49+
* Override: CODEMAN_TRIM_TEXT_TO (bytes)
4650
*/
47-
export const TRIM_TEXT_TO = 768 * 1024; // 768KB
51+
export const TRIM_TEXT_TO = parseInt(process.env.CODEMAN_TRIM_TEXT_TO || '') || 768 * 1024;
4852

4953
// ============================================================================
5054
// Message Buffer Limits
@@ -53,8 +57,9 @@ export const TRIM_TEXT_TO = 768 * 1024; // 768KB
5357
/**
5458
* Maximum number of Claude JSON messages to keep in memory per session.
5559
* Older messages are discarded when limit is exceeded.
60+
* Override: CODEMAN_MAX_MESSAGES (count)
5661
*/
57-
export const MAX_MESSAGES = 1000;
62+
export const MAX_MESSAGES = parseInt(process.env.CODEMAN_MAX_MESSAGES || '') || 1000;
5863

5964
// ============================================================================
6065
// Line Buffer Limits

0 commit comments

Comments
 (0)