Files
claude-auto-retry/test/tmux.test.js
T
CheapestInference 1aad1e0313 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>
2026-03-18 11:43:36 +01:00

28 lines
1.1 KiB
JavaScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { buildCaptureArgs, buildSendKeysArgs, buildDisplayArgs, parseTmuxVersion } from '../src/tmux.js';
describe('buildCaptureArgs', () => {
it('builds correct args', () => {
assert.deepEqual(buildCaptureArgs('%3', 200),
['capture-pane', '-t', '%3', '-p', '-S', '-200']);
});
});
describe('buildSendKeysArgs', () => {
it('builds correct args with Enter', () => {
assert.deepEqual(buildSendKeysArgs('%3', 'hello world'),
['send-keys', '-t', '%3', 'hello world', 'Enter']);
});
});
describe('buildDisplayArgs', () => {
it('builds correct args', () => {
assert.deepEqual(buildDisplayArgs('%3', '#{pane_current_command}'),
['display-message', '-t', '%3', '-p', '#{pane_current_command}']);
});
});
describe('parseTmuxVersion', () => {
it('parses "tmux 3.4"', () => { assert.equal(parseTmuxVersion('tmux 3.4'), 3.4); });
it('parses "tmux 2.1"', () => { assert.equal(parseTmuxVersion('tmux 2.1'), 2.1); });
it('returns 0 for unparseable', () => { assert.equal(parseTmuxVersion('not tmux'), 0); });
});