@simonesiega/codex-limits 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,22 +16,24 @@ This page describes the runtime, operating-system, Codex data, network, terminal
16
16
 
17
17
  Bun is used for dependency management, tests, development commands, and production builds. It is not required to run the published CLI. Runtime dependencies are bundled into `dist`, so the published package does not declare separate production dependencies.
18
18
 
19
- The root package module resolves to the agent-specific `dist/opencode.js` bundle for the OpenCode plugin loader. Its public module contract consists of a default plugin export and the named `tui` export; the internal core modules are not public package exports. Pi loads the separate `dist/pi.js` extension declared in the package's `pi.extensions` manifest. The GitHub Copilot CLI installer copies the separate `dist/copilot.mjs` bundle to a recognized user extension entry point.
19
+ The root package module resolves to the agent-specific `dist/opencode.js` bundle for OpenCode plugin-loader compatibility. The explicit `@simonesiega/codex-limits/opencode` subpath and OpenCode's loader-reserved `@simonesiega/codex-limits/tui` subpath resolve to the same module; all three expose a default plugin and the named `tui` export. The host-only `@simonesiega/codex-limits/pi` subpath resolves to the separate `dist/pi.js` extension also declared in the package's `pi.extensions` manifest. The host-only `@simonesiega/codex-limits/copilot` subpath resolves to the executable `dist/copilot.mjs` extension, which the GitHub Copilot CLI installer also copies to its recognized user extension entry point.
20
+
21
+ These agent-host exports are not a general-purpose JavaScript API and do not install an integration by themselves. The supported general interfaces are the CLI and its documented [JSON output](json-output.md). There is intentionally no `@simonesiega/codex-limits/core` export; internal core modules may change without a public API compatibility guarantee.
20
22
 
21
23
  ## Tested environments
22
24
 
23
- The following environments are covered by the repository's automated checks or current local validation. Other compatible environments may also work, but they are not tested for every release.
25
+ The following environments are covered by the repository's automated checks or latest recorded local validation. Other compatible environments may also work, but they are not tested for every release.
24
26
 
25
- | Area | Tested environments |
26
- | ---------------------- | ------------------------------------------------------------------------------------------------------------------ |
27
- | Automated packaged CLI | GitHub Actions on `ubuntu-latest` with Node.js 20, 22, and 24, plus `windows-latest` with Node.js 20 |
28
- | Current local checks | Windows build `10.0.26200.8875` with Node.js 22.20.0 and Bun 1.3.14 (verified 2026-07-23) |
29
- | Terminal rendering | Automated Ink rendering and layout tests; no named terminal application is included in the per-release test matrix |
30
- | OpenCode agent adapter | Mocked current keymap and legacy command API shapes; no exact OpenCode host release is tested end-to-end |
31
- | pi agent adapter | Mocked command/UI APIs with real TUI components; package discovery validated in pi 0.81.1 print mode |
32
- | Copilot CLI adapter | Mocked SDK command/timeline APIs and packed installation; typed against `@github/copilot-sdk` 1.0.8 |
27
+ | Area | Tested environments |
28
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
29
+ | Automated packaged CLI | GitHub Actions on `ubuntu-latest` with Node.js 20 and 22, `windows-latest` with Node.js 20, and `macos-latest` with Node.js 22 |
30
+ | Latest recorded local validation | Windows build `10.0.26200.8875` with Node.js 22.20.0 and Bun 1.3.14 (verified 2026-08-09) |
31
+ | Terminal rendering | Automated Ink rendering and layout tests; no named terminal application is included in the per-release test matrix |
32
+ | OpenCode agent adapter | Mocked API coverage plus packed install, plugin loading, `/codex-limits` dispatch, and removal in real OpenCode 1.18.14 and latest hosts |
33
+ | pi agent adapter | Mocked UI coverage plus packed install, command discovery, dispatch, removal, and post-removal discovery in real pi 0.81.1 and latest hosts |
34
+ | Copilot CLI adapter | Mocked SDK coverage plus packed install, extension loading, `/codex-limits` dispatch, and removal in the latest real Copilot CLI host |
33
35
 
34
- The supported runtime and operating-system ranges are broader than this test matrix. In particular, macOS compatibility follows the cross-platform implementation but is not currently covered by the repository's automated workflow.
36
+ The supported runtime and operating-system ranges are broader than this test matrix. Automated checks sample each supported operating system but do not test every supported Node.js version on every platform. The real-agent matrix runs for normal repository checks and on a weekly schedule so moving `latest` host releases are exercised even when the project has no new commits.
35
37
 
36
38
  ## Operating systems
37
39
 
@@ -48,8 +50,6 @@ Codex home candidates are checked in this order, skipping missing or unreadable
48
50
  7. `%APPDATA%/Codex`, when `APPDATA` is available
49
51
  8. `%LOCALAPPDATA%/Codex`, when `LOCALAPPDATA` is available
50
52
 
51
- The `Parall` spelling in candidate 6 matches the constant in `src/package/core/codex/paths.ts` and is covered by the path-generation test. This verifies that the documentation matches the current implementation; it does not claim that every macOS Codex installation uses that directory.
52
-
53
53
  `CODEX_LIMITS_HOME` has the highest priority. `CODEX_HOME` is Codex's native override and is used next. Override values must identify readable directories; files and unreadable paths are ignored.
54
54
 
55
55
  The default home directory is resolved from `HOME`, then `USERPROFILE`, then the operating system's home-directory API.
@@ -66,7 +66,7 @@ For normal use, Codex must have been installed, run, and authenticated at least
66
66
 
67
67
  Both credential environment variables are required together. Supplying only one produces an incomplete-authentication warning and does not initiate an authenticated request.
68
68
 
69
- Local Codex data is inspected read-only. File traversal, file counts, file sizes, JSONL line sizes, search depth, and response sizes are bounded. Nested symbolic links are skipped. Filesystem warnings do not include relative or absolute Codex paths, and fallback reset-duration strings must use compact duration units before they are normalized. Raw local files, tokens, account IDs, authorization headers, and private paths are excluded from public output.
69
+ Local Codex data is inspected read-only. See the [Security policy](../../SECURITY.md#local-data-and-network-behavior) for the canonical traversal, redaction, and file-handling safeguards.
70
70
 
71
71
  Local state layouts can vary between Codex versions. The parser recognizes common primary/five-hour and secondary/weekly window names and can return partial data when only some fields are understood. For live responses, declared window durations such as `limit_window_seconds` take precedence over legacy primary/secondary slot names, because the usage service can now return weekly usage in `primary_window` without a 5-hour window.
72
72
 
@@ -82,53 +82,46 @@ Live data uses these defaults:
82
82
 
83
83
  These endpoints are implementation details rather than a public API contract and may change when Codex changes its service behavior. A response containing only a recognized weekly window is treated as valid live usage; local discovery is used only when the live response contains no recognized usage window.
84
84
 
85
- Requests are authenticated from Codex credentials, reject redirects, time out after 10 seconds by default, and limit JSON responses to 1 MB. Independent usage and coupon lookups start concurrently. The transport uses the runtime's `fetch` implementation and can fall back to native Node HTTP/HTTPS transport for supported failures. Coupon timestamps must be bounded RFC 3339 values. Coupon redemption accepts only an exact coupon ID with the recognized `codex_rate_limits` type. `--soonest` refuses partial or count-inconsistent coupon data and any available coupon whose expiration cannot be verified. Its bounded JSON `POST` uses a fresh idempotency key for each confirmed redemption and reuses that key for any transport fallback.
85
+ Requests require complete Codex credentials and use a 10-second timeout by default. The runtime's `fetch` implementation and native Node HTTP/HTTPS transport are both supported. See the [Security policy](../../SECURITY.md#local-data-and-network-behavior) for canonical request, response, endpoint, timestamp, and redemption safeguards.
86
86
 
87
- `CODEX_LIMITS_USAGE_ENDPOINT` can override only the live usage endpoint. Overrides must use HTTPS. Plain HTTP is accepted only for loopback testing on `localhost`, `127.0.0.1`, or `::1`. URLs containing embedded usernames or passwords and all other protocols are rejected.
87
+ `CODEX_LIMITS_USAGE_ENDPOINT` can override only the live usage endpoint. Supported overrides use HTTPS, with plain HTTP limited to loopback testing on `localhost`, `127.0.0.1`, or `::1`.
88
88
 
89
89
  An internet connection is therefore recommended for current usage and required for coupon data. The CLI remains usable offline when compatible local usage snapshots exist.
90
90
 
91
91
  ## Terminal and automation compatibility
92
92
 
93
- | Surface | Requirement |
94
- | ------------------------------ | ---------------------------------------------------------- |
95
- | Interactive dashboard | A terminal capable of running the Ink UI |
96
- | `status` and `coupons` | Any environment that can capture standard output |
97
- | JSON output | Any environment that can capture and parse standard output |
98
- | Reset coupon redemption | Both standard input and standard output must be TTYs |
99
- | Interactive agent installation | Both standard input and standard output must be TTYs |
100
- | Explicit agent installation | Works non-interactively with an agent name or `--all` |
93
+ | Surface | Requirement |
94
+ | --------------------------- | ---------------------------------------------------------- |
95
+ | Interactive dashboard | A terminal capable of running the Ink UI |
96
+ | `status` and `coupons` | Any environment that can capture standard output |
97
+ | JSON output | Any environment that can capture and parse standard output |
98
+ | Reset coupon redemption | Both standard input and standard output must be TTYs |
99
+ | Interactive agent lifecycle | Both standard input and standard output must be TTYs |
100
+ | Explicit agent lifecycle | Install and uninstall work with agent names or `--all` |
101
101
 
102
- Use [`codex-limits --json`](json-output.md) or `codex-limits coupons --json` in scripts. Errors use a non-zero exit code and are written to standard error; successful machine-readable output is written to standard output. `codex-limits reset` is intentionally interactive and has no JSON or unattended confirmation mode.
102
+ Use [`codex-limits --json`](json-output.md), `codex-limits coupons --json`, or `codex-limits doctor --json` in scripts. Errors use a non-zero exit code and are written to standard error; successful machine-readable output is written to standard output. `codex-limits reset` is intentionally interactive and has no JSON or unattended confirmation mode.
103
103
 
104
104
  ## OpenCode compatibility
105
105
 
106
- Install the OpenCode integration with `codex-limits agents install opencode` (or the compatible `codex-limits init --opencode` form). The integration writes to both `~/.config/opencode/opencode.json` and `~/.config/opencode/tui.json`. It supports OpenCode hosts that expose either:
107
-
108
- - the current keymap layer registration API; or
109
- - the legacy command registration API.
106
+ The integration supports OpenCode hosts that expose either the current keymap layer registration API or the legacy command registration API. Compatibility is detected from the runtime API shape rather than an exact version list. Automated adapter tests cover both shapes, while the real-host compatibility matrix installs the packed package, dispatches `/codex-limits`, and verifies safe removal in OpenCode 1.18.14 and the latest npm release.
110
107
 
111
- Compatibility is determined from the API shape available at runtime rather than from a list of exact OpenCode versions. Automated adapter tests use host mocks for both supported API shapes; the repository does not currently claim end-to-end validation against named OpenCode releases.
112
-
113
- The command is `/codex-limits`. It loads the shared core locally and does not send an LLM prompt. See [Agent integrations](agent-integrations.md) for installation and troubleshooting.
108
+ See the [OpenCode integration guide](agents/opencode.md) for canonical installation, configuration, removal, and troubleshooting instructions.
114
109
 
115
110
  ## pi compatibility
116
111
 
117
- Install the pi integration with `codex-limits agents install pi` (or the compatible `codex-limits init --pi` form). The installer registers the current package root in `~/.pi/agent/settings.json`, or in the directory selected by `PI_CODING_AGENT_DIR`. The npm package also supports pi's native `pi install npm:@simonesiega/codex-limits` flow through its extension manifest.
112
+ The extension is developed against `@earendil-works/pi-coding-agent` and `@earendil-works/pi-tui` 0.81.x, which require Node.js 22.19 or newer. Those optional peers are supplied by the pi host and do not change the standalone CLI's Node.js 20 requirement.
118
113
 
119
- The extension uses pi's command registration and custom overlay APIs. It is developed against `@earendil-works/pi-coding-agent` and `@earendil-works/pi-tui` 0.81.x, which require Node.js 22.19 or newer. These packages are optional peers and are supplied by the pi host rather than bundled into the extension. This does not change the standalone CLI's Node.js 20 requirement. Local validation confirmed that pi 0.81.1 discovers the installed package and handles `/codex-limits` without invoking the model in print mode; the interactive overlay is covered with host mocks and real TUI components rather than a terminal-level end-to-end test.
114
+ Automated real-host checks install the packed package into pi 0.81.1 and the latest npm release, verify that the host discovers `/codex-limits` as an extension command, dispatch it through pi's RPC command path without creating a model-conversation message, uninstall it, and verify that a fresh pi host no longer discovers the command. Mocked tests continue to cover the interactive overlay with real TUI components; the overlay itself is not terminal-tested against every pi release.
120
115
 
121
- The `/codex-limits` command loads the shared core locally, opens a themed read-only overlay, and never sends a prompt or limit data to the LLM. Outside pi's interactive TUI it skips loading and sends no message to the model. See the dedicated [pi integration guide](agents/pi.md) for installation, removal, and troubleshooting.
116
+ See the [pi integration guide](agents/pi.md) for canonical installation, configuration, removal, and troubleshooting instructions.
122
117
 
123
118
  ## GitHub Copilot CLI compatibility
124
119
 
125
- Install the GitHub Copilot CLI integration with `codex-limits agents install copilot` (or the compatible `codex-limits init --copilot` form). The installer copies the bundled ESM extension to `~/.copilot/extensions/codex-limits/extension.mjs`, or beneath the directory selected by `COPILOT_HOME`.
126
-
127
- The integration uses Copilot CLI's experimental extension mechanism. Copilot starts the extension in a separate Node.js process, supplies `@github/copilot-sdk/extension` through its module resolver, and communicates over JSON-RPC on standard input and output. The bundle calls `joinSession()`, registers `/codex-limits` through session commands, and uses `session.log()` for the compact timeline output. It does not call `session.send()` or add the request or result to the model conversation.
120
+ The integration depends on Copilot CLI's experimental extension mechanism, which may change. npm installations of the current Copilot CLI require Node.js 22 or newer; other official installation methods package the host separately. The host must provide `@github/copilot-sdk/extension` to the extension process.
128
121
 
129
- The adapter is type-checked against `@github/copilot-sdk` 1.0.8. Automated tests use host mocks for registration, timeline output, static safe failures, and installer behavior. Package validation confirms that `dist/copilot.mjs` retains only the CLI-provided SDK as an external host import and is copied to the expected user extension path. No exact Copilot CLI release is currently tested end-to-end, and the experimental API may change. The current npm installation of Copilot CLI requires Node.js 22 or newer; other official installation methods package the host separately.
122
+ The adapter is type-checked against `@github/copilot-sdk` 1.0.8. Automated tests cover registration, timeline output, and safe failures. The real-host compatibility matrix additionally installs the packed extension into the latest Copilot CLI npm release, dispatches `/codex-limits`, requires its local timeline summary to appear without model authentication, and verifies safe removal through packed diagnostics.
130
123
 
131
- See the dedicated [GitHub Copilot CLI integration guide](agents/copilot.md) for installation, removal, host details, and troubleshooting.
124
+ See the [GitHub Copilot CLI integration guide](agents/copilot.md) for canonical installation, configuration, removal, and troubleshooting instructions.
132
125
 
133
126
  ## Support policy
134
127
 
@@ -137,7 +130,8 @@ The latest npm release is supported. The current `main` branch is supported for
137
130
  ## Related documentation
138
131
 
139
132
  - [JSON output](json-output.md) — Machine-readable output, fields, warnings, and scripting behavior.
140
- - [Agent integrations](agent-integrations.md) — Installation, architecture, compatibility, and troubleshooting for agent adapters.
133
+ - [Agent integrations](agent-integrations.md) — Supported-agent index, shared lifecycle modes, and adapter architecture.
141
134
  - [Security policy](../../SECURITY.md) — Data-access safeguards, network behavior, and vulnerability reporting.
135
+ - [Troubleshooting](troubleshooting.md) — Diagnosis for Codex data, network, terminal, reset, and agent problems.
142
136
  - [Documentation hub](../README.md) — Task-oriented index for CLI, automation, agent, development, and security guides.
143
- - [Project README](../../README.md) — Product overview, installation, commands, configuration, and troubleshooting.
137
+ - [Project README](../../README.md) — Product overview, installation, commands, and configuration.
@@ -48,52 +48,73 @@ interface UsageWindowJson {
48
48
  }
49
49
  ```
50
50
 
51
- This example represents one snapshot captured at `2026-07-13T16:00:07.000Z` on a system configured for UTC:
51
+ This example represents a sanitized snapshot:
52
+
53
+ <!-- validated-example: codex-limits-output.example.json -->
52
54
 
53
55
  ```json
54
56
  {
55
57
  "windows": {
56
58
  "fiveHour": {
57
59
  "label": "5-hour usage limit",
58
- "remainingPercent": 93,
59
- "usedPercent": 7,
60
- "resetsAt": "2026-07-13T19:55:07.000Z",
60
+ "remainingPercent": 80,
61
+ "usedPercent": 20,
62
+ "resetsAt": "2026-07-14T01:30:15.000Z",
61
63
  "resetsIn": "3h 55m"
62
64
  },
63
65
  "weekly": {
64
66
  "label": "Weekly usage limit",
65
- "remainingPercent": 11,
66
- "usedPercent": 89,
67
- "resetsAt": "2026-07-15T17:40:07.000Z",
68
- "resetsIn": "2d 1h 40m"
67
+ "remainingPercent": 31,
68
+ "usedPercent": 69,
69
+ "resetsAt": "2026-07-18T11:15:15.000Z",
70
+ "resetsIn": "4d 13h 40m"
69
71
  }
70
72
  },
71
73
  "coupons": {
72
- "available": 2,
73
- "earnedThisPeriod": 4,
74
- "nextExpirationDate": "Monday 20 July 2026",
75
- "nextExpirationIn": "7d 4h 38m",
74
+ "available": 4,
75
+ "earnedThisPeriod": 0,
76
+ "nextExpirationDate": "Saturday 18 July 2026",
77
+ "nextExpirationIn": "4d 2h 42m",
76
78
  "items": [
77
79
  {
78
80
  "index": 1,
79
81
  "status": "available",
80
- "grantedAt": "2026-06-20T20:38:07Z",
81
- "expiresAt": "2026-07-20T20:38:07Z",
82
- "expirationDate": "Monday 20 July 2026",
83
- "expiresIn": "7d 4h 38m"
82
+ "grantedAt": "2026-06-18T00:17:20.252556Z",
83
+ "expiresAt": "2026-07-18T00:17:20.252556Z",
84
+ "expirationDate": "Saturday 18 July 2026",
85
+ "expiresIn": "4d 2h 42m"
84
86
  },
85
87
  {
86
88
  "index": 2,
87
89
  "status": "available",
88
- "grantedAt": "2026-06-27T20:38:07Z",
89
- "expiresAt": "2026-07-27T20:38:07Z",
90
+ "grantedAt": "2026-06-26T23:48:13.132409Z",
91
+ "expiresAt": "2026-07-26T23:48:13.132409Z",
90
92
  "expirationDate": "Monday 27 July 2026",
91
- "expiresIn": "14d 4h 38m"
93
+ "expiresIn": "13d 2h 12m"
94
+ },
95
+ {
96
+ "index": 3,
97
+ "status": "available",
98
+ "grantedAt": "2026-07-01T19:59:47.228684Z",
99
+ "expiresAt": "2026-07-31T19:59:47.228684Z",
100
+ "expirationDate": "Friday 31 July 2026",
101
+ "expiresIn": "17d 22h 24m"
102
+ },
103
+ {
104
+ "index": 4,
105
+ "status": "available",
106
+ "grantedAt": "2026-07-13T17:48:41.527506Z",
107
+ "expiresAt": "2026-08-12T17:48:41.527506Z",
108
+ "expirationDate": "Wednesday 12 August 2026",
109
+ "expiresIn": "29d 20h 13m"
92
110
  }
93
111
  ],
94
112
  "warnings": []
95
113
  },
96
- "warnings": []
114
+ "warnings": [
115
+ "Skipped a sensitive-looking local file.",
116
+ "Skipped a local cache file because it is too large to inspect safely."
117
+ ]
97
118
  }
98
119
  ```
99
120
 
@@ -121,11 +142,13 @@ interface CouponItemJson {
121
142
  }
122
143
  ```
123
144
 
124
- Using the same reference time and timezone as the complete example:
145
+ Sanitized example ([see the sanitized coupon example](../examples/codex-limits-coupons-output.example.json)):
146
+
147
+ <!-- validated-example: codex-limits-coupons-output.example.json -->
125
148
 
126
149
  ```json
127
150
  {
128
- "available": 1,
151
+ "available": 2,
129
152
  "earnedThisPeriod": 4,
130
153
  "nextExpirationDate": "Monday 20 July 2026",
131
154
  "nextExpirationIn": "7d 4h 38m",
@@ -137,6 +160,14 @@ Using the same reference time and timezone as the complete example:
137
160
  "expiresAt": "2026-07-20T20:38:07Z",
138
161
  "expirationDate": "Monday 20 July 2026",
139
162
  "expiresIn": "7d 4h 38m"
163
+ },
164
+ {
165
+ "index": 2,
166
+ "status": "available",
167
+ "grantedAt": "2026-06-27T20:38:07Z",
168
+ "expiresAt": "2026-07-27T20:38:07Z",
169
+ "expirationDate": "Monday 27 July 2026",
170
+ "expiresIn": "14d 4h 38m"
140
171
  }
141
172
  ],
142
173
  "warnings": []
@@ -162,11 +193,13 @@ interface DoctorJson {
162
193
  }
163
194
  ```
164
195
 
165
- Example:
196
+ Sanitized example ([see the JSON example](../examples/codex-limits-doctor-output.example.json)):
197
+
198
+ <!-- validated-example: codex-limits-doctor-output.example.json -->
166
199
 
167
200
  ```json
168
201
  {
169
- "packageVersion": "1.0.0",
202
+ "packageVersion": "1.2.0",
170
203
  "nodeVersion": "22.0.0",
171
204
  "operatingSystem": "Windows",
172
205
  "codexHomeDetected": true,
@@ -201,14 +234,14 @@ For comparisons and stored data, prefer canonical fields such as `resetsAt` and
201
234
 
202
235
  ### Coupon summary
203
236
 
204
- | Field | Meaning |
205
- | -------------------- | ------------------------------------------------------------------------------------ |
206
- | `available` | Available reset-credit count as a non-negative integer, or `null` when not returned. |
207
- | `earnedThisPeriod` | Total earned reset credits as a non-negative integer, or `null`. |
208
- | `nextExpirationDate` | Local calendar date for the next available coupon, or otherwise the soonest coupon. |
209
- | `nextExpirationIn` | Compact non-negative duration until that expiration. |
210
- | `items` | Valid coupon entries sorted by expiration time. |
211
- | `warnings` | Safe coupon-specific availability or payload warnings. |
237
+ | Field | Meaning |
238
+ | -------------------- | ---------------------------------------------------------------------------------------------- |
239
+ | `available` | Available reset-credit count as a non-negative safe integer, or `null` when invalid or absent. |
240
+ | `earnedThisPeriod` | Total earned reset credits as a non-negative safe integer, or `null`. |
241
+ | `nextExpirationDate` | Local calendar date for the next available coupon, or otherwise the soonest coupon. |
242
+ | `nextExpirationIn` | Compact non-negative duration until that expiration. |
243
+ | `items` | Valid coupon entries sorted by expiration time. |
244
+ | `warnings` | Safe coupon-specific availability or payload warnings. |
212
245
 
213
246
  Coupon `index` values are one-based and assigned after sorting. `grantedAt` and `expiresAt` preserve bounded RFC 3339 timestamp strings from the service. `expirationDate` is rendered in the machine's local timezone as `Weekday D Month YYYY`; `expiresIn` is calculated at command execution time. Coupon entries with malformed or extra timestamp text are omitted and produce a warning.
214
247
 
@@ -287,9 +320,11 @@ Consumers should tolerate `null` values and warning entries. Parse fields as JSO
287
320
 
288
321
  ## Related documentation
289
322
 
290
- - [Example JSON output](../examples/codex-limits-output.example.json) Complete example response produced by `codex-limits --json`.
291
- - [JSON Schema](../schema/codex-limits.schema.json) — Machine-readable schema for validating the complete JSON response.
323
+ - [Complete limits example](../examples/codex-limits-output.example.json) and [schema](../schema/codex-limits.schema.json) Resources for `codex-limits --json`.
324
+ - [Coupon example](../examples/codex-limits-coupons-output.example.json) and [schema](../schema/codex-limits-coupons.schema.json) — Resources for `codex-limits coupons --json`.
325
+ - [Doctor example](../examples/codex-limits-doctor-output.example.json) and [schema](../schema/codex-limits-doctor.schema.json) — Resources for `codex-limits doctor --json`.
292
326
  - [Compatibility](compatibility.md) — Runtime, operating system, local-data, terminal, and network requirements.
293
327
  - [Agent integrations](agent-integrations.md) — Installation, architecture, behavior, and development of supported agent integrations.
328
+ - [Troubleshooting](troubleshooting.md) — Diagnosis for JSON output, automation, and data availability problems.
294
329
  - [Documentation hub](../README.md) — Task-oriented index for CLI, automation, agent, development, and security guides.
295
- - [Project README](../../README.md) — Product overview, installation, commands, configuration, and troubleshooting.
330
+ - [Project README](../../README.md) — Product overview, installation, commands, and configuration.
@@ -0,0 +1,160 @@
1
+ # Troubleshooting
2
+
3
+ [← Documentation hub](../README.md) · [Project README](../../README.md)
4
+
5
+ Use this guide when Codex data, live usage, reset-credit coupons, JSON output, the terminal dashboard, reset redemption, or an agent integration is unavailable.
6
+
7
+ ## Contents
8
+
9
+ - [Start with diagnostics](#start-with-diagnostics)
10
+ - [No Codex data found](#no-codex-data-found)
11
+ - [Usage information is unavailable](#usage-information-is-unavailable)
12
+ - [Reset-credit coupons are unavailable](#reset-credit-coupons-are-unavailable)
13
+ - [Authentication overrides are incomplete](#authentication-overrides-are-incomplete)
14
+ - [Permission errors](#permission-errors)
15
+ - [The dashboard does not render correctly](#the-dashboard-does-not-render-correctly)
16
+ - [JSON output or automation fails](#json-output-or-automation-fails)
17
+ - [Reset redemption does not proceed](#reset-redemption-does-not-proceed)
18
+ - [An agent command does not appear](#an-agent-command-does-not-appear)
19
+ - [Agent installation reports invalid or conflicting configuration](#agent-installation-reports-invalid-or-conflicting-configuration)
20
+ - [Agent uninstallation refuses a target](#agent-uninstallation-refuses-a-target)
21
+ - [The problem persists](#the-problem-persists)
22
+ - [Related documentation](#related-documentation)
23
+
24
+ ## Start with diagnostics
25
+
26
+ Run the read-only diagnostic command first:
27
+
28
+ ```bash
29
+ codex-limits doctor
30
+ ```
31
+
32
+ For machine-readable diagnostics:
33
+
34
+ ```bash
35
+ codex-limits doctor --json
36
+ ```
37
+
38
+ Then run `codex-limits status` to see safe usage warnings and `codex-limits coupons` to check coupon availability independently. Diagnostic and warning output intentionally omits credentials, private paths, endpoint URLs, and raw Codex files.
39
+
40
+ ## No Codex data found
41
+
42
+ 1. Run Codex and authenticate at least once.
43
+ 2. Run `codex-limits doctor` and check **Codex home detected**, **Authentication found**, and **Local usage found**.
44
+ 3. If Codex stores data outside its standard location, set `CODEX_LIMITS_HOME` or `CODEX_HOME` to the correct directory.
45
+ 4. Confirm that the selected location is a readable directory rather than a file.
46
+ 5. Review [Codex data compatibility](compatibility.md#codex-data-compatibility) for recognized data and credential sources.
47
+
48
+ ## Usage information is unavailable
49
+
50
+ Current usage normally comes from the live Codex endpoint, with compatible local state used as a fallback.
51
+
52
+ - Confirm that Codex authentication is current.
53
+ - Check **Live endpoint** with `codex-limits doctor`.
54
+ - Confirm that the machine can reach the ChatGPT Codex service.
55
+ - Run Codex again to create a recent local usage snapshot when working offline.
56
+ - Check [network compatibility](compatibility.md#network-compatibility) if a proxy, firewall, endpoint override, or offline environment is involved.
57
+
58
+ A missing 5-hour window is not necessarily an error. Codex may provide only a weekly usage window.
59
+
60
+ ## Reset-credit coupons are unavailable
61
+
62
+ Coupon information requires complete credentials and network access; it has no local-data fallback.
63
+
64
+ - Confirm that `authenticationFound` is `true` in `doctor --json`, or that **Authentication found** is **Yes** in text output.
65
+ - If using environment credentials, provide both `CODEX_LIMITS_ACCESS_TOKEN` and `CODEX_LIMITS_ACCOUNT_ID`.
66
+ - Use the live usage endpoint status as a general connectivity signal, but inspect coupon warnings separately because `doctor` does not call the coupon endpoint.
67
+ - Inspect safe warnings from `codex-limits coupons`.
68
+
69
+ Do not print credential values while troubleshooting.
70
+
71
+ ## Authentication overrides are incomplete
72
+
73
+ `CODEX_LIMITS_ACCESS_TOKEN` and `CODEX_LIMITS_ACCOUNT_ID` must be supplied together. Providing only one disables authenticated live requests and produces a safe warning. Either provide both values or remove the partial override so the CLI can use a readable Codex `auth.json` file.
74
+
75
+ ## Permission errors
76
+
77
+ Confirm that your user can read the selected Codex directory and recognized files. Prefer correcting ownership or permissions, or selecting the correct directory with `CODEX_LIMITS_HOME`, instead of running the CLI with elevated privileges.
78
+
79
+ The CLI intentionally skips unsafe, unreadable, oversized, or symbolic-link entries. See the [Security policy](../../SECURITY.md#local-data-and-network-behavior) for canonical file-handling behavior.
80
+
81
+ ## The dashboard does not render correctly
82
+
83
+ - Confirm that the command is running in an interactive terminal.
84
+ - Resize very narrow or short terminals; the dashboard switches to compact layouts automatically.
85
+ - Use `codex-limits status`, `codex-limits coupons`, or JSON output when Ink rendering is unavailable.
86
+ - Check [terminal compatibility](compatibility.md#terminal-and-automation-compatibility).
87
+
88
+ ## JSON output or automation fails
89
+
90
+ Use one of the documented JSON forms:
91
+
92
+ ```bash
93
+ codex-limits --json
94
+ codex-limits coupons --json
95
+ codex-limits doctor --json
96
+ ```
97
+
98
+ `status --json` is not supported. Successful JSON is written to standard output; command failures are written to standard error and return a non-zero exit code. Warnings and unavailable nullable fields can still appear in a successful document.
99
+
100
+ Validate consumers against the schemas and examples linked from [JSON output](json-output.md). Parse JSON fields rather than terminal text or pretty-print whitespace.
101
+
102
+ ## Reset redemption does not proceed
103
+
104
+ `codex-limits reset` requires both standard input and standard output to be interactive TTYs. It has no unattended or JSON confirmation mode.
105
+
106
+ - Run `codex-limits coupons` first and confirm that an available coupon is listed.
107
+ - Use a displayed coupon index, or `codex-limits reset --soonest` when expiration data is complete.
108
+ - Confirm only after reviewing the recap.
109
+ - If coupon details are incomplete, availability is inconsistent, or the final response is ambiguous, the command fails closed and does not claim success.
110
+
111
+ See [Reset redemption](../../SECURITY.md#reset-redemption) for the canonical safety behavior.
112
+
113
+ ## An agent command does not appear
114
+
115
+ Use the troubleshooting section for the installed agent:
116
+
117
+ - [OpenCode command troubleshooting](agents/opencode.md#the-command-does-not-appear)
118
+ - [pi command troubleshooting](agents/pi.md#the-command-does-not-appear)
119
+ - [GitHub Copilot CLI command troubleshooting](agents/copilot.md#the-command-does-not-appear)
120
+
121
+ In general, rerun the named installer, confirm that it reports **installed** or **already installed**, and restart the agent so it reloads configuration. Agent-specific configuration paths, reload behavior, host requirements, and removal steps remain canonical in each dedicated guide.
122
+
123
+ ## Agent installation reports invalid or conflicting configuration
124
+
125
+ Installers intentionally refuse malformed, oversized, symbolic-link, or conflicting targets rather than overwriting them. Review the relevant dedicated guide before changing agent configuration:
126
+
127
+ - [OpenCode setup troubleshooting](agents/opencode.md#setup-reports-invalid-json)
128
+ - [pi setup troubleshooting](agents/pi.md#setup-reports-invalid-json)
129
+ - [GitHub Copilot CLI extension conflicts](agents/copilot.md#the-extension-path-is-already-in-use)
130
+
131
+ Do not remove unrelated plugins, packages, extensions, or configuration fields.
132
+
133
+ ## Agent uninstallation refuses a target
134
+
135
+ Uninstallers intentionally fail closed on malformed, oversized, symbolic-link, unreadable, or unrecognized targets. They do not rewrite or delete the target merely because it occupies an expected path.
136
+
137
+ 1. Run `codex-limits doctor` to review the bounded installed status.
138
+ 2. Read the removal section for [OpenCode](agents/opencode.md#re-running-or-removing-the-integration), [pi](agents/pi.md#re-running-or-removing-the-integration), or [GitHub Copilot CLI](agents/copilot.md#re-running-or-removing-the-integration).
139
+ 3. Correct malformed host configuration before retrying.
140
+ 4. For an unrecognized Copilot entry point, inspect the dedicated extension directory and remove it manually only if you can independently verify its ownership.
141
+
142
+ With multiple named targets or `--all`, review every per-agent result: one failure does not prevent other adapters from attempting safe removal.
143
+
144
+ ## The problem persists
145
+
146
+ 1. Run `codex-limits doctor` and the affected read-only command again.
147
+ 2. Record the command, expected behavior, safe status labels, and warning text.
148
+ 3. Include the operating system and Node.js version, but redact private paths and environment values.
149
+ 4. Check existing [GitHub issues](https://github.com/simonesiega/codex-limits/issues) before opening a focused report.
150
+
151
+ For a suspected credential, data-exposure, unsafe-write, or reset-redemption vulnerability, follow the private process in the [Security policy](../../SECURITY.md#reporting-a-vulnerability) instead of opening a public issue.
152
+
153
+ ## Related documentation
154
+
155
+ - [Compatibility](compatibility.md) — Canonical runtime, operating-system, Codex-data, network, terminal, and agent-host requirements.
156
+ - [JSON output](json-output.md) — Machine-readable contracts, schemas, examples, and scripting behavior.
157
+ - [Agent integrations](agent-integrations.md) — Supported-agent index and shared lifecycle modes.
158
+ - [Security policy](../../SECURITY.md) — Canonical safety behavior and private vulnerability reporting.
159
+ - [Documentation hub](../README.md) — Task-oriented documentation index.
160
+ - [Project README](../../README.md) — Product overview, installation, and command reference.
@@ -0,0 +1,107 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/simonesiega/codex-limits/main/docs/schema/codex-limits-coupons.schema.json",
4
+ "title": "Codex Limits Coupons JSON Output",
5
+ "description": "Schema for the output of `codex-limits coupons --json`.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "available",
10
+ "earnedThisPeriod",
11
+ "nextExpirationDate",
12
+ "nextExpirationIn",
13
+ "items",
14
+ "warnings"
15
+ ],
16
+ "properties": {
17
+ "available": {
18
+ "$ref": "#/$defs/nullableNonNegativeInteger"
19
+ },
20
+ "earnedThisPeriod": {
21
+ "$ref": "#/$defs/nullableNonNegativeInteger"
22
+ },
23
+ "nextExpirationDate": {
24
+ "$ref": "#/$defs/nullableString"
25
+ },
26
+ "nextExpirationIn": {
27
+ "$ref": "#/$defs/nullableString"
28
+ },
29
+ "items": {
30
+ "type": "array",
31
+ "items": {
32
+ "$ref": "#/$defs/couponItem"
33
+ }
34
+ },
35
+ "warnings": {
36
+ "$ref": "#/$defs/warnings"
37
+ }
38
+ },
39
+ "$defs": {
40
+ "couponItem": {
41
+ "type": "object",
42
+ "additionalProperties": false,
43
+ "required": ["index", "status", "grantedAt", "expiresAt", "expirationDate", "expiresIn"],
44
+ "properties": {
45
+ "index": {
46
+ "type": "integer",
47
+ "minimum": 1
48
+ },
49
+ "status": {
50
+ "anyOf": [
51
+ {
52
+ "type": "string",
53
+ "pattern": "^[a-zA-Z][a-zA-Z0-9_-]{0,63}$"
54
+ },
55
+ {
56
+ "type": "null"
57
+ }
58
+ ]
59
+ },
60
+ "grantedAt": {
61
+ "$ref": "#/$defs/nullableDateTime"
62
+ },
63
+ "expiresAt": {
64
+ "$ref": "#/$defs/nullableDateTime"
65
+ },
66
+ "expirationDate": {
67
+ "$ref": "#/$defs/nullableString"
68
+ },
69
+ "expiresIn": {
70
+ "$ref": "#/$defs/nullableString"
71
+ }
72
+ }
73
+ },
74
+ "nullableDateTime": {
75
+ "anyOf": [
76
+ {
77
+ "type": "string",
78
+ "format": "date-time"
79
+ },
80
+ {
81
+ "type": "null"
82
+ }
83
+ ]
84
+ },
85
+ "nullableNonNegativeInteger": {
86
+ "anyOf": [
87
+ {
88
+ "type": "integer",
89
+ "minimum": 0,
90
+ "maximum": 9007199254740991
91
+ },
92
+ {
93
+ "type": "null"
94
+ }
95
+ ]
96
+ },
97
+ "nullableString": {
98
+ "type": ["string", "null"]
99
+ },
100
+ "warnings": {
101
+ "type": "array",
102
+ "items": {
103
+ "type": "string"
104
+ }
105
+ }
106
+ }
107
+ }