@simonesiega/codex-limits 0.1.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.
package/.env.example ADDED
@@ -0,0 +1,21 @@
1
+ # Optional: override the local Codex data directory inspected by codex-limits.
2
+ # Leave unset to use the default platform-specific candidate paths.
3
+ CODEX_LIMITS_HOME=
4
+
5
+ # Optional fallback: codex-limits reads ~/.codex/auth.json automatically when available.
6
+ # The tool calls the live Codex reset-credit endpoint at chatgpt.com only when credentials are found.
7
+
8
+ # MacOS/Linux:
9
+ # jq -r '.tokens.account_id // empty' ~/.codex/auth.json
10
+ # Windows PowerShell:
11
+ # (Get-Content "$env:USERPROFILE\.codex\auth.json" -Raw | ConvertFrom-Json).tokens.account_id
12
+ CODEX_LIMITS_ACCOUNT_ID=
13
+
14
+ # MacOS/Linux:
15
+ # jq -r '.tokens.access_token // empty' ~/.codex/auth.json
16
+ # Windows PowerShell:
17
+ # (Get-Content "$env:USERPROFILE\.codex\auth.json" -Raw | ConvertFrom-Json).tokens.access_token
18
+ CODEX_LIMITS_ACCESS_TOKEN=
19
+
20
+ # Optional: override the live usage endpoint if ChatGPT changes the Codex usage API path.
21
+ CODEX_LIMITS_USAGE_ENDPOINT=
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to codex-limits are documented in this file.
4
+
5
+ ## [0.1.0] - 2026-07-05
6
+
7
+ ### Added
8
+
9
+ - Added the shared core API for Codex usage limits and reset-credit coupons.
10
+ - Added the read-only Ink terminal dashboard with usage limit cards and reset coupon panels.
11
+ - Added non-interactive `status`, `coupons`, and JSON command output.
12
+ - Added an opencode plugin that registers `/codex-limits` without sending a prompt to the LLM.
13
+ - Added `codex-limits init` and npm postinstall setup for optional agent integrations.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Simone Siega
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ <h1 align="center">
2
+ <img src="docs/photos/logo/logo.png" alt="codex-limits logo" width="180" />
3
+ <br />
4
+ Codex Limits
5
+ </h1>
6
+
7
+ <p align="center">
8
+ A polished terminal dashboard for checking Codex usage limits, reset times, and reset-credit coupons.
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://github.com/simonesiega/codex-limits/stargazers"><img src="https://img.shields.io/github/stars/simonesiega/codex-limits?style=social" alt="GitHub stars" /></a>
13
+ <a href="https://github.com/simonesiega/codex-limits/issues"><img src="https://img.shields.io/github/issues/simonesiega/codex-limits" alt="Open issues" /></a>
14
+ <a href="https://github.com/simonesiega/codex-limits/pulls"><img src="https://img.shields.io/github/issues-pr/simonesiega/codex-limits" alt="Open pull requests" /></a>
15
+ <a href="https://github.com/simonesiega/codex-limits/commits/main"><img src="https://img.shields.io/github/last-commit/simonesiega/codex-limits" alt="Last commit" /></a>
16
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/simonesiega/codex-limits" alt="License" /></a>
17
+ </p>
18
+
19
+ <p align="center">
20
+ <img src="https://img.shields.io/npm/v/@simonesiega/codex-limits?label=npm" alt="npm version" />
21
+ <img src="https://img.shields.io/badge/TypeScript-5-blue?logo=typescript" alt="TypeScript" />
22
+ <img src="https://img.shields.io/badge/Bun-runtime-black?logo=bun" alt="Bun" />
23
+ </p>
24
+
25
+ ## Final result 🚀
26
+
27
+ <p align="center">
28
+ <img src="docs/photos/terminal/final_result.png" alt="Final codex-limits terminal dashboard" width="740" />
29
+ </p>
30
+
31
+ The screenshot shows the final **`codex-limits`** terminal dashboard: a clean, read-only TUI that summarizes Codex usage limits and reset-credit coupons in one place. The top section displays the current 5-hour and weekly usage windows with remaining percentages, visual progress bars, and reset times, while the lower section shows available reset coupons, their expiration dates, and the next coupon deadline.
32
+
33
+ ## Overview
34
+
35
+ When you are working with Codex or agent-based coding tools, usage limits can interrupt your flow if you do not know what is left or when the next reset happens.
36
+
37
+ **`codex-limits`** gives you that information in one clean terminal view. It shows your current 5-hour and weekly usage windows, remaining percentages, progress bars, reset times, and reset-credit coupons when available, so you can quickly check your status and continue coding without leaving the terminal.
38
+
39
+ It also includes plain-text commands for quick checks, JSON output for scripts and automation, optional agent integrations through `codex-limits init`, and safe output that never prints tokens, account IDs, auth headers, cookies, or raw local files.
40
+
41
+ ## Agent integrations
42
+
43
+ ### Supported agents
44
+
45
+ | Agent | Status | Agent command | Init Command | Description |
46
+ | --- | --- | --- | --- | --- |
47
+ | OpenCode | Supported | `/codex-limits` | `codex-limits init --opencode` | Opens a fast, read-only Codex limits dashboard directly inside OpenCode without sending the request to the LLM. |
48
+
49
+ Agent integrations are not enabled during package installation. The package import export is reserved for the agent plugin entry that supported agents load after you run the matching `codex-limits init` command.
50
+
51
+ ### Selected agent integration screenshots
52
+
53
+ #### OpenCode
54
+ The OpenCode integration adds a `/codex-limits` command that opens a compact modal inside the agent interface. It gives a quick read-only summary of the current 5-hour limit, weekly limit, and reset-credit coupons, then lets you close the view and return immediately to the conversation.
55
+
56
+ <p align="center">
57
+ <img src="docs/photos/agents/opencode/opencode_result.png" alt="OpenCode codex-limits integration screenshot" width="740" />
58
+ </p>
59
+
60
+ ### Adding new agents
61
+
62
+ New agents can be added by creating a dedicated adapter under `src/agents/<agent-name>` and registering it in `src/agents/index.ts`. Each integration should keep the same goal: show Codex limit information quickly, safely, and without exposing tokens, account IDs, cookies, auth headers, or raw local files.
63
+
64
+ See the [Contributing](./CONTRIBUTING.md) section if you want to add support for another agent.
65
+
66
+ ## How it works
67
+
68
+ **`codex-limits`** is built around a shared core with different output surfaces on top of it.
69
+
70
+ | Area | Path | Purpose |
71
+ | --- | --- | --- |
72
+ | CLI entry | `src/package/cli.ts` | Starts the `codex-limits` command and routes to the dashboard, plain-text commands, JSON output, and `init`. |
73
+ | Core logic | `src/package/core` | Detects Codex data, reads local usage, fetches optional live information, normalizes usage windows, and keeps sensitive values out of the output. |
74
+ | CLI commands | `src/package/commands` | Handles the dashboard, `status`, `coupons`, `--json`, and `init` commands. |
75
+ | Terminal UI | `src/package/tui` | Renders the clean Ink-based dashboard from normalized usage data. |
76
+ | Agent integrations | `src/agents` | Contains optional coding-agent adapters that users install with `codex-limits init`. |
77
+ | Tests | `tests` | Contains the test suite used to validate core behavior, CLI output, safety rules, and integration logic. |
78
+
79
+ This structure keeps the project easy to extend: the core decides what the data means, while the CLI, TUI, and agents only decide how that information is shown.
80
+
81
+ ## Environment
82
+
83
+ **`codex-limits`** works out of the box when it can find the required Codex data automatically. By default, it tries to detect the local Codex data directory and discover the information needed to show usage limits and reset-credit coupons. Most users do not need to configure anything manually.
84
+
85
+ Environment variables are only used as a fallback when automatic discovery is not enough, or when you want to override the default behavior.
86
+
87
+ | Variable | Purpose |
88
+ | --- | --- |
89
+ | `CODEX_LIMITS_HOME` | Manually sets the local Codex data directory when it cannot be detected automatically. |
90
+ | `CODEX_LIMITS_ACCESS_TOKEN` | Manually provides an access token for live reset-credit coupon data. |
91
+ | `CODEX_LIMITS_ACCOUNT_ID` | Manually provides the account ID used for live reset-credit coupon data. |
92
+ | `CODEX_LIMITS_USAGE_ENDPOINT` | Overrides the live usage endpoint, mainly for testing or advanced setups. |
93
+
94
+ ## Installation
95
+
96
+ Install **`codex-limits`** globally from npm:
97
+
98
+ ```bash
99
+ npm install -g @simonesiega/codex-limits
100
+ ```
101
+
102
+ Then run it from any terminal:
103
+
104
+ ```bash
105
+ codex-limits
106
+ ```
107
+
108
+ ## Usage
109
+
110
+ | Command | Description |
111
+ | --- | --- |
112
+ | `codex-limits` | Opens the interactive terminal dashboard. |
113
+ | `codex-limits status` | Prints a plain usage summary. |
114
+ | `codex-limits coupons` | Prints reset-credit coupon information. |
115
+ | `codex-limits --json` | Prints machine-readable usage data for scripts and automation. |
116
+ | `codex-limits init` | Installs optional agent integrations. |
117
+ | `codex-limits init --opencode` | Installs the OpenCode integration directly. |
118
+ | `codex-limits --help` | Prints the help text. |
119
+ | `codex-limits --version` | Prints the installed package version. |
120
+
121
+ ## Local development
122
+
123
+ Clone the repository, install dependencies, and run the CLI locally:
124
+
125
+ ```bash
126
+ bun install
127
+ bun run dev
128
+ ```
129
+
130
+ Useful development commands:
131
+
132
+ | Command | Description |
133
+ | --- | --- |
134
+ | `bun run dev` | Runs the CLI in development mode. |
135
+ | `bun run check` | Runs type checking, tests, and build validation. |
136
+ | `bun test` | Runs the test suite. |
137
+ | `bun run build` | Builds the package. |
138
+
139
+
140
+ ## License
141
+
142
+ This project is licensed under the MIT License. See [`LICENSE`](LICENSE).
143
+
144
+ ## Contributors 🧑‍💻
145
+
146
+ <p align="center">
147
+ <a href="https://github.com/simonesiega/codex-limits/graphs/contributors">
148
+ <img src="https://contrib.rocks/image?repo=simonesiega/codex-limits&max=24&columns=12" alt="Contributors" />
149
+ </a>
150
+ </p>