feat: claude-auto-retry v0.1.0
Auto-retry Claude Code sessions when hitting Anthropic subscription rate limits. Uses tmux monitoring + send-keys to detect rate limit messages, wait for reset, and send "continue" automatically. Zero dependencies, zero workflow change. - Shell wrapper intercepts `claude` command transparently - Background monitor polls tmux pane for rate limit patterns - Timezone-aware reset time parsing with DST safety - Safe send-keys with foreground process verification - --print mode: buffers output, retries cleanly for pipes - Config validation prevents bad values from causing crashes - 59 tests, 0 dependencies Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { describe, it, afterEach } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { createLogger } from '../src/logger.js';
|
||||
import { readFile, rm } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
|
||||
describe('createLogger', () => {
|
||||
const testDir = join(tmpdir(), `car-logger-test-${Date.now()}`);
|
||||
|
||||
afterEach(async () => { await rm(testDir, { recursive: true, force: true }); });
|
||||
|
||||
it('creates log directory and writes log entry', async () => {
|
||||
const logger = createLogger(testDir);
|
||||
await logger.info('test message');
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const content = await readFile(join(testDir, `${today}.log`), 'utf-8');
|
||||
assert.ok(content.includes('test message'));
|
||||
assert.ok(content.includes('[INFO]'));
|
||||
});
|
||||
it('includes timestamp in log entries', async () => {
|
||||
const logger = createLogger(testDir);
|
||||
await logger.info('timestamped');
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const content = await readFile(join(testDir, `${today}.log`), 'utf-8');
|
||||
assert.match(content, /\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\]/);
|
||||
});
|
||||
it('supports warn and error levels', async () => {
|
||||
const logger = createLogger(testDir);
|
||||
await logger.warn('warning msg');
|
||||
await logger.error('error msg');
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const content = await readFile(join(testDir, `${today}.log`), 'utf-8');
|
||||
assert.ok(content.includes('[WARN]'));
|
||||
assert.ok(content.includes('[ERROR]'));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user