mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 12:39:42 +02:00
docs: update token tracking documentation
- Document different token tracking approaches for one-shot vs interactive modes - Update PTY spawn mode examples to show --output-format stream-json flag - Explain that interactive mode parses tokens from status line with 60/40 split estimate Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -111,12 +111,12 @@ const msg = JSON.parse(cleanLine) as ClaudeMessage;
|
||||
|
||||
### PTY Spawn Modes
|
||||
|
||||
**One-shot mode** (prompt execution):
|
||||
**One-shot mode** (prompt execution with JSON output for token tracking):
|
||||
```typescript
|
||||
pty.spawn('claude', ['-p', '--dangerously-skip-permissions', prompt], { ... })
|
||||
pty.spawn('claude', ['-p', '--dangerously-skip-permissions', '--output-format', 'stream-json', prompt], { ... })
|
||||
```
|
||||
|
||||
**Interactive mode** (persistent terminal):
|
||||
**Interactive mode** (persistent terminal, tokens parsed from status line):
|
||||
```typescript
|
||||
pty.spawn('claude', ['--dangerously-skip-permissions'], { ... })
|
||||
```
|
||||
@@ -168,7 +168,11 @@ Default config (`RespawnConfig` in `src/types.ts`):
|
||||
|
||||
### Token Tracking & Auto-Clear
|
||||
|
||||
Session tracks input/output tokens from Claude's JSON messages:
|
||||
Session tracks input/output tokens differently depending on mode:
|
||||
|
||||
**One-shot mode (`runPrompt`)**: Uses `--output-format stream-json` to get JSON output with detailed token usage from `msg.message.usage.input_tokens` and `output_tokens`.
|
||||
|
||||
**Interactive mode (`startInteractive`)**: Parses tokens from Claude's status line display (e.g., "123.4k tokens"). Since only total is shown, estimates 60/40 input/output split.
|
||||
|
||||
```typescript
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user