Skip to content

Commit d33faa0

Browse files
committed
docs: streamline README tool section and add quick navigation
1 parent 2dd7217 commit d33faa0

1 file changed

Lines changed: 51 additions & 215 deletions

File tree

README.md

Lines changed: 51 additions & 215 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ Start here if you are implementing or auditing changes:
6565
|-- docs/
6666
`-- dist/ (generated)
6767
```
68+
69+
### Jump to section
70+
71+
- [Installation](#installation)
72+
- [Models](#models)
73+
- [Multi-Account Setup](#multi-account-setup)
74+
- [Account Management Tools](#account-management-tools)
75+
- [Rotation Behavior](#rotation-behavior)
76+
- [Troubleshooting](#troubleshooting)
77+
- [Configuration](#configuration)
78+
- [Documentation](#documentation)
6879
---
6980

7081
<details open>
@@ -315,250 +326,75 @@ opencode auth login # Run again to add more accounts
315326

316327
## Account Management Tools
317328

318-
The plugin provides built-in tools for managing your OpenAI accounts. These are available directly in OpenCode — just ask the agent or type the tool name.
329+
The plugin provides built-in `codex-*` tools directly in OpenCode.
319330

320-
> **Note:** Tools were renamed from `openai-accounts-*` to `codex-*` in v4.12.0 for brevity.
321-
>
322-
> **Default v1 surface:** `codex-list`, `codex-switch`, `codex-status`, `codex-health`.
323-
> Advanced admin tools (`codex-metrics`, `codex-refresh`, `codex-remove`, `codex-export`, `codex-import`) are hidden by default and can be enabled with `CODEX_MULTI_AUTH_EXPOSE_ADMIN_TOOLS=1`.
331+
- Default tools: `codex-list`, `codex-switch`, `codex-status`, `codex-health`
332+
- Advanced tools (hidden by default): `codex-metrics`, `codex-refresh`, `codex-remove`, `codex-export`, `codex-import`
333+
- Enable advanced tools with:
324334

325-
### Hashline Editing (Plain OpenCode)
335+
```bash
336+
CODEX_MULTI_AUTH_EXPOSE_ADMIN_TOOLS=1 opencode
337+
```
326338

327-
This plugin now provides a true hashline editing engine on plain OpenCode by overriding `edit` and adding `hashline_read`.
339+
> Note: tools were renamed from `openai-accounts-*` to `codex-*` in v4.12.0.
328340
329-
Use this standard flow:
341+
### Quick command map
330342

331-
1. Read hashline refs:
343+
| Tool | Availability | Purpose | Example |
344+
|---|---|---|---|
345+
| `codex-list` | Default | List configured accounts | `codex-list` |
346+
| `codex-switch` | Default | Switch active account by index | `codex-switch index=2` |
347+
| `codex-status` | Default | Show health, usage, reset timing | `codex-status` |
348+
| `codex-health` | Default | Validate account tokens (read-only) | `codex-health` |
349+
| `codex-metrics` | Advanced | Show runtime metrics for current plugin process | `codex-metrics` |
350+
| `codex-refresh` | Advanced | Refresh tokens and persist updates | `codex-refresh` |
351+
| `codex-remove` | Advanced | Remove account by index | `codex-remove index=3` |
352+
| `codex-export` | Advanced | Export accounts to JSON | `codex-export path="~/backup/accounts.json"` |
353+
| `codex-import` | Advanced | Import/merge accounts from JSON | `codex-import path="~/backup/accounts.json"` |
354+
| `hashline_read` | Default | Read hashline refs for deterministic edits | `hashline_read path="src/file.ts"` |
355+
| `edit` | Default | Hashline-capable edit engine (or legacy `oldString/newString`) | `edit path="src/file.ts" lineRef="L42#..." operation="replace" content="..."` |
332356

333-
```
334-
hashline_read path="src/file.ts"
335-
```
357+
### Recommended day-to-day flow
336358

337-
2. Edit with hash-verified refs:
359+
1. Run `codex-list` to see available accounts.
360+
2. If needed, switch active account with `codex-switch index=<n>`.
361+
3. Use `codex-status` when requests slow down or fail.
362+
4. Use `codex-health` to validate tokens.
363+
5. Use `codex-refresh` (advanced) after long idle periods.
338364

339-
```
340-
edit path="src/file.ts" lineRef="L42#deadbeef" operation="replace" content="new code"
341-
```
365+
### Hashline editing (plain OpenCode)
342366

343-
3. Optional range edit:
367+
Use this standard flow:
344368

345-
```
369+
```text
370+
hashline_read path="src/file.ts"
371+
edit path="src/file.ts" lineRef="L42#deadbeef" operation="replace" content="new code"
346372
edit path="src/file.ts" lineRef="L42#deadbeef" endLineRef="L44#feedcafe" operation="replace" content="replacement block"
347-
```
348-
349-
4. Legacy fallback (still supported):
350-
351-
```
373+
# legacy fallback remains supported:
352374
edit path="src/file.ts" oldString="from" newString="to"
353375
```
354376

355377
No extra plugin is required. This works with plain OpenCode + `codex-multi-auth`.
356378

357-
---
358-
359-
### codex-list
360-
361-
List all configured accounts with their status.
379+
<details>
380+
<summary><b>Example outputs (condensed)</b></summary>
362381

363-
```
382+
```text
364383
codex-list
365-
```
366-
367-
**Output:**
368-
```
369384
OpenAI Accounts (3 total):
370-
371385
[1] user@gmail.com (active)
372386
[2] work@company.com
373387
[3] backup@email.com
374388
375-
Use codex-switch to change active account.
376-
```
377-
378-
---
379-
380-
### codex-switch
381-
382-
Switch to a different account by index (1-based).
383-
384-
```
385-
codex-switch index=2
386-
```
387-
388-
**Output:**
389-
```
390-
Switched to account [2] work@company.com
391-
```
392-
393-
---
394-
395-
### codex-status
396-
397-
Show detailed status including rate limits and health scores.
398-
399-
```
400389
codex-status
401-
```
390+
[1] user@gmail.com (active) Health: 100/100 Rate Limit: 45/50 Resets: 2m 30s
391+
[2] work@company.com Health: 85/100 Rate Limit: 12/50 Resets: 8m 15s
402392
403-
**Output:**
404-
```
405-
OpenAI Account Status:
406-
407-
[1] user@gmail.com (active)
408-
Health: 100/100
409-
Rate Limit: 45/50 requests remaining
410-
Resets: 2m 30s
411-
Last Used: 5 minutes ago
412-
413-
[2] work@company.com
414-
Health: 85/100
415-
Rate Limit: 12/50 requests remaining
416-
Resets: 8m 15s
417-
Last Used: 1 hour ago
418-
```
419-
420-
---
421-
422-
### Advanced Admin Tools (Optional)
423-
424-
The following tools are available only when:
425-
426-
```bash
427-
CODEX_MULTI_AUTH_EXPOSE_ADMIN_TOOLS=1 opencode
428-
```
429-
430-
---
431-
432-
### codex-metrics
433-
434-
Show live runtime metrics (request counts, latency, errors, rotations) for the current plugin process.
435-
436-
```
437-
codex-metrics
438-
```
439-
440-
**Output:**
441-
```
442-
Codex Plugin Metrics:
443-
444-
Uptime: 12m
445-
Total upstream requests: 84
446-
Successful responses: 77
447-
Failed responses: 7
448-
Average successful latency: 842ms
449-
```
450-
451-
---
452-
453-
### codex-health
454-
455-
Check if all account tokens are still valid (read-only check).
456-
457-
```
458-
codex-health
459-
```
460-
461-
**Output:**
462-
```
463-
Checking 3 account(s):
464-
465-
✓ [1] user@gmail.com: Healthy
466-
✓ [2] work@company.com: Healthy
467-
✗ [3] old@expired.com: Token expired
468-
469-
Summary: 2 healthy, 1 unhealthy
470-
```
471-
472-
---
473-
474-
### codex-refresh
475-
476-
Refresh all OAuth tokens and save them to disk. Use this after long idle periods.
477-
478-
```
479393
codex-refresh
480-
```
481-
482-
**Output:**
483-
```
484-
Refreshing 3 account(s):
485-
486-
✓ [1] user@gmail.com: Refreshed
487-
✓ [2] work@company.com: Refreshed
488-
✗ [3] old@expired.com: Failed - Token expired
489-
490394
Summary: 2 refreshed, 1 failed
491395
```
492396

493-
**Difference from health check:** `codex-health` only validates tokens. `codex-refresh` actually refreshes them and saves new tokens to disk.
494-
495-
---
496-
497-
### codex-remove
498-
499-
Remove an account by index. Useful for cleaning up expired accounts.
500-
501-
```
502-
codex-remove index=3
503-
```
504-
505-
**Output:**
506-
```
507-
Removed: [3] old@expired.com
508-
509-
Remaining accounts: 2
510-
```
511-
512-
---
513-
514-
### codex-export
515-
516-
Export all accounts to a portable JSON file. Useful for backup or migration.
517-
518-
```
519-
codex-export path="~/backup/accounts.json"
520-
```
521-
522-
**Output:**
523-
```
524-
Exported 3 account(s) to ~/backup/accounts.json
525-
```
526-
527-
---
528-
529-
### codex-import
530-
531-
Import accounts from a JSON file (exported via `codex-export`). Merges with existing accounts.
532-
533-
```
534-
codex-import path="~/backup/accounts.json"
535-
```
536-
537-
**Output:**
538-
```
539-
Imported 2 new account(s) (1 duplicate skipped)
540-
541-
Total accounts: 4
542-
```
543-
544-
---
545-
546-
### Quick Reference
547-
548-
| Tool | What It Does | Example |
549-
|------|--------------|---------|
550-
| `codex-list` | List all accounts | "list my accounts" |
551-
| `codex-switch` | Switch active account | "switch to account 2" |
552-
| `codex-status` | Show rate limits & health | "show account status" |
553-
| `codex-health` | Validate tokens (read-only) | "check account health" |
554-
| `codex-metrics` | Show runtime metrics (advanced, env-gated) | "show plugin metrics" |
555-
| `codex-refresh` | Refresh & save tokens (advanced, env-gated) | "refresh my tokens" |
556-
| `codex-remove` | Remove an account (advanced, env-gated) | "remove account 3" |
557-
| `codex-export` | Export accounts to file (advanced, env-gated) | "export my accounts" |
558-
| `codex-import` | Import accounts from file (advanced, env-gated) | "import accounts from backup" |
559-
| `hashline_read` | Read hashline refs for deterministic edits | "show hashline refs for src/file.ts" |
560-
| `edit` | Hashline-capable edit engine (or legacy oldString/newString) | "replace lineRef L42#... with new content" |
561-
397+
</details>
562398
---
563399

564400
## Rotation Behavior

0 commit comments

Comments
 (0)