mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-07 07:59:42 +02:00
refactor: extract magic numbers to named constants
Low severity code quality improvements: - session.ts: Add timing constants (SCREEN_STARTUP_DELAY_MS, etc.) - screen-manager.ts: Add EXEC_TIMEOUT_MS, CR_MAX_ATTEMPTS, etc. - subagent-watcher.ts: Add display length constants - server.ts: Add STATS_COLLECTION_INTERVAL_MS, SESSION_LIMIT_WAIT_MS, etc. - spawn-orchestrator.ts: Add budget ratio constants - respawn-controller.ts: Use pre-compiled ANSI_ESCAPE_PATTERN - state-store.ts: Use ES6 import for unlinkSync instead of dynamic require - app.js: Add notification timing constants Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,9 @@ const PLAN_MODE_OPTION_PATTERN = /\d+\.\s+(Yes|No|Type|Cancel|Skip|Proceed|Appro
|
||||
/** Pre-filter: selection indicator arrow for plan mode detection */
|
||||
const PLAN_MODE_SELECTOR_PATTERN = /[❯>]\s*\d+\./;
|
||||
|
||||
/** Pattern to strip ANSI escape codes from terminal output */
|
||||
const ANSI_ESCAPE_PATTERN = /\x1b\[[0-9;]*[A-Za-z]/g;
|
||||
|
||||
// Note: The old '↵ send' indicator is no longer reliable in Claude Code 2024+
|
||||
// Detection now uses completion message patterns ("for Xm Xs") instead.
|
||||
|
||||
@@ -1277,7 +1280,8 @@ export class RespawnController extends EventEmitter {
|
||||
// This prevents false triggers when Claude pauses briefly mid-work.
|
||||
if (this._state === 'confirming_idle' || this._state === 'ai_checking') {
|
||||
// Strip ANSI escape codes to check if there's real content
|
||||
const stripped = data.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '').trim();
|
||||
ANSI_ESCAPE_PATTERN.lastIndex = 0;
|
||||
const stripped = data.replace(ANSI_ESCAPE_PATTERN, '').trim();
|
||||
if (stripped.length > 2) {
|
||||
if (this._state === 'ai_checking') {
|
||||
this.log(`Substantial output during AI check ("${stripped.substring(0, 40)}..."), cancelling`);
|
||||
@@ -1924,7 +1928,8 @@ export class RespawnController extends EventEmitter {
|
||||
const tail = buffer.slice(-2000);
|
||||
|
||||
// Strip ANSI codes for pattern matching
|
||||
const stripped = tail.replace(/\x1b\[[0-9;]*[A-Za-z]/g, '');
|
||||
ANSI_ESCAPE_PATTERN.lastIndex = 0;
|
||||
const stripped = tail.replace(ANSI_ESCAPE_PATTERN, '');
|
||||
|
||||
// Must find numbered option pattern
|
||||
if (!PLAN_MODE_OPTION_PATTERN.test(stripped)) return false;
|
||||
|
||||
Reference in New Issue
Block a user