@iamdevlinph/codex-kit 1.1.0 → 1.1.1
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/README.md +100 -226
- package/assets/TEMPLATE_AGENTS.md +4 -0
- package/bin/codex-kit.js +40 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,288 +1,162 @@
|
|
|
1
1
|
# `@iamdevlinph/codex-kit`
|
|
2
2
|
|
|
3
|
-
Portable Codex
|
|
3
|
+
Portable Codex subagents, automatic task routing, and reusable project guidance.
|
|
4
4
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
- a
|
|
8
|
-
-
|
|
9
|
-
-
|
|
5
|
+
- Routes work automatically while keeping small tasks with the root agent.
|
|
6
|
+
- Includes four subagents for exploration, implementation, review, and quick edits.
|
|
7
|
+
- Provides a stack-neutral `AGENTS.md` starting point.
|
|
8
|
+
- Reconciles template updates semantically instead of replacing project guidance.
|
|
9
|
+
- Preserves user-owned configuration and modified managed files.
|
|
10
|
+
- Runs as a dependency-free Node.js CLI.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
root orchestrator to `gpt-5.6-sol` with low normal reasoning and high Plan-mode
|
|
13
|
-
reasoning. Use the separate configuration command to override these defaults.
|
|
12
|
+
## Quick start
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
1. Install the CLI and global Codex assets:
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
```sh
|
|
17
|
+
pnpm add --global @iamdevlinph/codex-kit@latest
|
|
18
|
+
codex-kit global install
|
|
19
|
+
```
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
pnpm add --global @iamdevlinph/codex-kit@latest
|
|
21
|
-
codex-kit global install
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Start a new Codex task or restart the client after installation. Codex may ask
|
|
25
|
-
you to review and trust the new command hooks once; approve them after confirming
|
|
26
|
-
that they run the installed `${CODEX_HOME:-~/.codex}/codex-kit/routing-hook.js`.
|
|
27
|
-
|
|
28
|
-
`npm install --global @iamdevlinph/codex-kit@latest` works as an alternative.
|
|
29
|
-
For one-off use without a global installation, prefix a command with
|
|
30
|
-
`pnpm dlx @iamdevlinph/codex-kit@latest`.
|
|
31
|
-
|
|
32
|
-
`global install` copies reusable agents and the
|
|
33
|
-
`skills/codex-kit-reconcile-agents` skill to `${CODEX_HOME:-~/.codex}`, maintains
|
|
34
|
-
the package routing section in global `AGENTS.md`, and adds package-owned
|
|
35
|
-
handlers to `hooks.json` without replacing existing hooks. `global list` shows
|
|
36
|
-
the reconciliation skill's ownership status. Install and uninstall preserve
|
|
37
|
-
modified or user-owned skill files using the same backup/restore semantics as
|
|
38
|
-
other package files.
|
|
39
|
-
|
|
40
|
-
The Sol root plans, routes, coordinates, and validates. On every prompt, the
|
|
41
|
-
routing hook supplies the current `SUBAGENT_ROUTING.md`; the root classifies the
|
|
42
|
-
task and delegates substantive work to the exact matching role. The role's agent
|
|
43
|
-
TOML—not the routing policy—selects its model and reasoning effort. To avoid
|
|
44
|
-
subagent startup overhead, the root may directly handle planning, conversation,
|
|
45
|
-
read-only checks, documentation, bookkeeping, and clear changes spanning up to
|
|
46
|
-
roughly three files. Automatic delegation is reserved for broad discovery,
|
|
47
|
-
large multi-file implementation or debugging, high-risk review, and the
|
|
48
|
-
structural review required for every completed feature.
|
|
49
|
-
|
|
50
|
-
Every feature follows a mandatory semantic decomposition pass: implement and
|
|
51
|
-
stabilize it, map each responsibility to its final file, extract independently
|
|
52
|
-
understandable concerns, validate the decomposed implementation, and hand it to
|
|
53
|
-
`code-reviewer`. Pages, routes, controllers, commands, and entrypoints contain
|
|
54
|
-
composition and orchestration only. Web page files may contain framework exports,
|
|
55
|
-
metadata, loading, guards, page-level state, minimal layout wrappers, and imported
|
|
56
|
-
child composition, but not child components, substantial UI sections, or domain
|
|
57
|
-
logic. Independently changeable UI concerns get descriptive feature-local files;
|
|
58
|
-
hooks, schemas, data access, transformations, and domain logic move out of
|
|
59
|
-
presentation when independently testable or when they obscure the primary
|
|
60
|
-
responsibility. Avoid generic dumping grounds, keep components feature-local by
|
|
61
|
-
default, and promote only proven shared/global primitives. Tiny inseparable
|
|
62
|
-
helpers or markup may remain inline. Unrelated small fixes need no broad
|
|
63
|
-
refactoring. Every completed feature receives automatic structural review; a
|
|
64
|
-
concrete framework or tooling constraint must be named for any exception.
|
|
65
|
-
|
|
66
|
-
User-facing work also begins with a UI/style preflight. Inspect the closest
|
|
67
|
-
same-purpose shipped features—especially tables, filters, search, forms, dialogs,
|
|
68
|
-
and page layouts—and reuse their components, tokens, layout, responsive
|
|
69
|
-
behavior, interactions, states, and accessibility conventions. When repeated
|
|
70
|
-
precedent exists without written guidance, record always-on conventions in
|
|
71
|
-
`AGENTS.md` and feature-specific decisions or exceptions in `PLANS.md`. Ask the
|
|
72
|
-
user whether to keep, update, or override before deliberate divergence,
|
|
73
|
-
changing an established guideline, resolving conflicting precedents, or
|
|
74
|
-
proceeding without a trustworthy analogue. Use browser or screenshot comparison
|
|
75
|
-
when available; otherwise report it unavailable. The structural reviewer blocks
|
|
76
|
-
unexplained divergence or needless duplication only when repository evidence
|
|
77
|
-
supports the finding.
|
|
78
|
-
|
|
79
|
-
## Available subagents
|
|
80
|
-
|
|
81
|
-
| Subagent | Routing | Model and effort | Used for |
|
|
82
|
-
| --- | --- | --- | --- |
|
|
83
|
-
| `code-explorer` | Automatic | `gpt-5.6-terra`, medium | Read-only broad repository discovery, contract tracing, and multi-file searches |
|
|
84
|
-
| `implementer` | Automatic | `gpt-5.6-luna`, high | Large behavior changes, non-obvious debugging, migrations, and substantial tests |
|
|
85
|
-
| `code-reviewer` | Automatic | `gpt-5.6-sol`, high | Structural review of every completed feature, plus read-only review of security-sensitive, architectural, public-API, concurrency, migration, or difficult-to-validate changes |
|
|
86
|
-
| `quick-implementer` | Manual only | `gpt-5.6-luna`, medium | Small, mechanical, well-specified changes limited to one or two files |
|
|
21
|
+
2. Initialize a project from its root:
|
|
87
22
|
|
|
88
|
-
|
|
89
|
-
|
|
23
|
+
```sh
|
|
24
|
+
codex-kit project init
|
|
25
|
+
```
|
|
90
26
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
file or module ownership and separate validation scope. Work that shares types,
|
|
94
|
-
schemas, configuration, generated artifacts, migrations, lockfiles, or dependency
|
|
95
|
-
ordering stays with one implementer or runs sequentially; multiple files alone
|
|
96
|
-
do not justify duplicate agents.
|
|
97
|
-
|
|
98
|
-
`quick-implementer` remains installed for explicit manual delegation but is not
|
|
99
|
-
selected by the default automatic route. The root reuses delegated test evidence
|
|
100
|
-
and normally performs only lightweight integration checks.
|
|
101
|
-
|
|
102
|
-
`global install` sets these defaults while preserving unrelated settings;
|
|
103
|
-
`global configure` can override them:
|
|
104
|
-
|
|
105
|
-
```toml
|
|
106
|
-
model = "gpt-5.6-sol"
|
|
107
|
-
model_reasoning_effort = "low"
|
|
108
|
-
plan_mode_reasoning_effort = "high"
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
This balances ordinary orchestration and direct small changes while retaining
|
|
112
|
-
high reasoning in Plan Mode. Override either effort independently when needed:
|
|
113
|
-
|
|
114
|
-
```sh
|
|
115
|
-
codex-kit global configure \
|
|
116
|
-
--reasoning-effort low \
|
|
117
|
-
--plan-reasoning-effort high
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Delegation is time-bounded. The root waits once for up to 60 seconds, requests
|
|
121
|
-
one progress update, and then enforces a three-minute read/review/manual-quick
|
|
122
|
-
deadline or five-minute implementation deadline. Validation commands that make
|
|
123
|
-
no progress for two minutes are stopped unless the repository documents a
|
|
124
|
-
longer normal runtime. Root and worker never run the same validation
|
|
125
|
-
concurrently.
|
|
126
|
-
|
|
127
|
-
Before changing these keys, codex-kit creates a timestamped `config.toml`
|
|
128
|
-
backup and records their previous values. `global uninstall` restores those
|
|
129
|
-
values without replacing unrelated configuration changed afterward.
|
|
130
|
-
|
|
131
|
-
Use a different Codex home when needed:
|
|
132
|
-
|
|
133
|
-
```sh
|
|
134
|
-
pnpm dlx @iamdevlinph/codex-kit@latest global install \
|
|
135
|
-
--codex-home /path/to/.codex
|
|
136
|
-
pnpm dlx @iamdevlinph/codex-kit@latest global configure \
|
|
137
|
-
--codex-home /path/to/.codex
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
Inspect the installed setup:
|
|
141
|
-
|
|
142
|
-
```sh
|
|
143
|
-
pnpm dlx @iamdevlinph/codex-kit@latest global list
|
|
144
|
-
```
|
|
27
|
+
Restart Codex after global installation. Codex may ask you to trust the installed
|
|
28
|
+
hook at `${CODEX_HOME:-~/.codex}/codex-kit/routing-hook.js`.
|
|
145
29
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
installed custom agents without dumping unrelated configuration.
|
|
30
|
+
`npm install --global @iamdevlinph/codex-kit@latest` is also supported. For
|
|
31
|
+
one-off use, prefix commands with `pnpm dlx @iamdevlinph/codex-kit@latest`.
|
|
149
32
|
|
|
150
|
-
|
|
33
|
+
## Included subagents
|
|
151
34
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
35
|
+
| Subagent | Routing | Model and effort | Purpose |
|
|
36
|
+
| --- | --- | --- | --- |
|
|
37
|
+
| `code-explorer` | Automatic | `gpt-5.6-terra`, medium | Broad read-only discovery and contract tracing |
|
|
38
|
+
| `implementer` | Automatic | `gpt-5.6-luna`, high | Large changes, debugging, migrations, and substantial tests |
|
|
39
|
+
| `code-reviewer` | Automatic | `gpt-5.6-sol`, high | Feature structure and high-risk review |
|
|
40
|
+
| `quick-implementer` | Manual | `gpt-5.6-luna`, medium | Small mechanical changes in one or two files |
|
|
155
41
|
|
|
156
|
-
|
|
157
|
-
|
|
42
|
+
The root orchestrator plans, routes, integrates, and validates. It handles clear
|
|
43
|
+
small changes directly and delegates broader discovery, implementation, or review
|
|
44
|
+
according to the installed `SUBAGENT_ROUTING.md` policy.
|
|
158
45
|
|
|
159
46
|
## Commands
|
|
160
47
|
|
|
161
48
|
| Action | Command |
|
|
162
49
|
| --- | --- |
|
|
163
|
-
| Show
|
|
164
|
-
| Print
|
|
165
|
-
| Install
|
|
166
|
-
| Configure
|
|
167
|
-
| Inspect global
|
|
50
|
+
| Show help | `codex-kit -h` or `codex-kit --help` |
|
|
51
|
+
| Print version | `codex-kit -v` or `codex-kit --version` |
|
|
52
|
+
| Install or update global assets | `codex-kit global install` |
|
|
53
|
+
| Configure model defaults | `codex-kit global configure` |
|
|
54
|
+
| Inspect global setup | `codex-kit global list` |
|
|
168
55
|
| Remove package-managed global files | `codex-kit global uninstall` |
|
|
169
56
|
| Initialize project guidance | `codex-kit project init` |
|
|
170
|
-
| Refresh the project template
|
|
171
|
-
| Check
|
|
57
|
+
| Refresh the project template | `codex-kit project sync` |
|
|
58
|
+
| Check reconciliation status | `codex-kit project status` |
|
|
172
59
|
| Record completed reconciliation | `codex-kit project mark-applied` |
|
|
173
60
|
| Check for a package update | `codex-kit version check` |
|
|
174
61
|
|
|
175
|
-
|
|
62
|
+
Use `codex-kit --help` for exhaustive command details.
|
|
176
63
|
|
|
177
|
-
|
|
64
|
+
## Device setup
|
|
178
65
|
|
|
179
|
-
|
|
180
|
-
codex-kit
|
|
66
|
+
`global install` copies the agents, routing assets, hooks, and
|
|
67
|
+
`codex-kit-reconcile-agents` skill into `${CODEX_HOME:-~/.codex}`. It adds only
|
|
68
|
+
codex-kit's hook handlers and preserves unrelated settings and hooks.
|
|
181
69
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
70
|
+
The default root configuration is:
|
|
71
|
+
|
|
72
|
+
```toml
|
|
73
|
+
model = "gpt-5.6-sol"
|
|
74
|
+
model_reasoning_effort = "low"
|
|
75
|
+
plan_mode_reasoning_effort = "high"
|
|
185
76
|
```
|
|
186
77
|
|
|
187
|
-
|
|
188
|
-
immediately afterward. It creates or updates:
|
|
78
|
+
Override it explicitly when needed:
|
|
189
79
|
|
|
190
|
-
|
|
191
|
-
-
|
|
192
|
-
|
|
80
|
+
```sh
|
|
81
|
+
codex-kit global configure \
|
|
82
|
+
--orchestrator gpt-5.6-sol \
|
|
83
|
+
--reasoning-effort low \
|
|
84
|
+
--plan-reasoning-effort high
|
|
85
|
+
```
|
|
193
86
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
The prompt asks Codex to verify that the project has enough substantive code,
|
|
199
|
-
dependencies, configuration, and scripts to derive reliable guidance. If not,
|
|
200
|
-
Codex stops without inventing rules or marking the template applied. Finish
|
|
201
|
-
scaffolding the project, rerun `project init`, and send the new CLI prompt.
|
|
87
|
+
`--model` is an alias for `--orchestrator`. Before changing managed values,
|
|
88
|
+
codex-kit creates a timestamped `config.toml` backup and records the previous
|
|
89
|
+
values. `global uninstall` restores them without replacing unrelated later edits.
|
|
90
|
+
Modified managed files are preserved.
|
|
202
91
|
|
|
203
|
-
|
|
204
|
-
|
|
92
|
+
Use `codex-kit global list` to inspect model settings, routing and hook status,
|
|
93
|
+
the reconciliation skill, and installed agents. Use `codex-kit global uninstall`
|
|
94
|
+
to remove package-managed global files.
|
|
205
95
|
|
|
206
|
-
##
|
|
96
|
+
## Project workflow
|
|
207
97
|
|
|
208
|
-
|
|
98
|
+
Run `codex-kit project init` after the project has enough code, dependencies,
|
|
99
|
+
configuration, and scripts for Codex to derive reliable guidance. It creates:
|
|
209
100
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
101
|
+
- `AGENTS.md` only when missing; existing guidance is preserved;
|
|
102
|
+
- `TEMPLATE_AGENTS.md` as the local template reference;
|
|
103
|
+
- `.codex-kit-state.json` for reconciliation bookkeeping.
|
|
213
104
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
adaptations and organization, and may create or update a concrete conditional
|
|
218
|
-
workflow under `.agents/skills`. Critical safety, authorization, secrets,
|
|
219
|
-
database, deployment, and destructive-operation rules remain in `AGENTS.md`;
|
|
220
|
-
do not copy the complete template or introduce managed markers. After semantic
|
|
221
|
-
reconciliation and validation, record the applied template hash:
|
|
105
|
+
Initialization includes the first template sync. When the CLI prints an
|
|
106
|
+
initialization or reconciliation prompt, copy the complete marked block into a
|
|
107
|
+
Codex task opened at the project root.
|
|
222
108
|
|
|
223
|
-
|
|
224
|
-
`BEGIN CODEX RECONCILIATION PROMPT` and `END CODEX RECONCILIATION PROMPT` into a
|
|
225
|
-
Codex task opened at the project root. That prompt tells Codex to validate and
|
|
226
|
-
then run:
|
|
109
|
+
After installing a newer package version, refresh the reference template:
|
|
227
110
|
|
|
228
111
|
```sh
|
|
229
|
-
codex-kit project
|
|
112
|
+
codex-kit project sync
|
|
230
113
|
```
|
|
231
114
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
115
|
+
`project sync` never edits `AGENTS.md` or project skills. The reconciliation skill
|
|
116
|
+
compares the refreshed template with the project's guidance and merges only
|
|
117
|
+
applicable rules while preserving local organization and adaptations. If
|
|
118
|
+
`TEMPLATE_AGENTS.md` was modified locally, sync preserves it for review instead
|
|
119
|
+
of overwriting it.
|
|
236
120
|
|
|
237
|
-
|
|
238
|
-
asks for review instead of overwriting it. Use `--force` only after intentionally
|
|
239
|
-
discarding the local candidate changes.
|
|
240
|
-
|
|
241
|
-
### Synchronize multiple projects
|
|
242
|
-
|
|
243
|
-
Install the CLI once and keep a local path list:
|
|
121
|
+
After reconciliation and validation, Codex runs:
|
|
244
122
|
|
|
245
123
|
```sh
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
while IFS= read -r repo; do
|
|
249
|
-
[ -n "$repo" ] && codex-kit project sync --cwd "$repo"
|
|
250
|
-
done < ~/.config/codex-kit/projects.txt
|
|
124
|
+
codex-kit project mark-applied
|
|
251
125
|
```
|
|
252
126
|
|
|
253
|
-
|
|
127
|
+
`mark-applied` only updates `.codex-kit-state.json`; it does not validate or
|
|
128
|
+
modify `AGENTS.md`. Use `codex-kit project status` to check whether the current
|
|
129
|
+
template still needs reconciliation.
|
|
254
130
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
codex-
|
|
258
|
-
|
|
131
|
+
## Options
|
|
132
|
+
|
|
133
|
+
- `--codex-home PATH` selects a Codex home for global commands instead of
|
|
134
|
+
`CODEX_HOME` or `~/.codex`.
|
|
135
|
+
- `--cwd PATH` selects a project directory for project commands instead of the
|
|
136
|
+
current directory.
|
|
137
|
+
- `--force` lets `global install`, `global configure`, `project init`, or
|
|
138
|
+
`project sync` replace modified files they manage. Use it only when you intend
|
|
139
|
+
to discard those local changes.
|
|
259
140
|
|
|
260
|
-
|
|
141
|
+
Examples:
|
|
261
142
|
|
|
262
143
|
```sh
|
|
263
|
-
codex-kit
|
|
144
|
+
codex-kit global install --codex-home /path/to/.codex
|
|
145
|
+
codex-kit project sync --cwd /path/to/project
|
|
264
146
|
```
|
|
265
147
|
|
|
266
|
-
The command queries the public npm registry only when requested. Normal project
|
|
267
|
-
commands do not add network latency or depend on registry availability.
|
|
268
|
-
|
|
269
148
|
## Requirements
|
|
270
149
|
|
|
271
150
|
- Node.js 20 or newer
|
|
272
151
|
- Codex with custom subagent and lifecycle-hook support
|
|
273
152
|
|
|
274
|
-
The published package
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
## License
|
|
278
|
-
|
|
279
|
-
This repository and the published `@iamdevlinph/codex-kit` package are licensed
|
|
280
|
-
under the [ISC License](LICENSE).
|
|
153
|
+
The published package contains no credentials or runtime dependencies. Version
|
|
154
|
+
checks contact the public npm registry only when `codex-kit version check` runs.
|
|
281
155
|
|
|
282
|
-
## Security
|
|
156
|
+
## Security and license
|
|
283
157
|
|
|
284
158
|
See [SECURITY.md](SECURITY.md) for supported versions and private vulnerability
|
|
285
|
-
reporting
|
|
159
|
+
reporting. This repository and package use the [ISC License](LICENSE).
|
|
286
160
|
|
|
287
161
|
## References
|
|
288
162
|
|
|
@@ -129,6 +129,10 @@ conditional procedures into validated project skills.
|
|
|
129
129
|
- For behavior changes and bug fixes, add or update the smallest focused
|
|
130
130
|
automated tests that meaningfully prevent regression when the repository has
|
|
131
131
|
an established test setup.
|
|
132
|
+
- Treat existing tests as regression contracts. Preserve their assertions unless
|
|
133
|
+
the requested behavior intentionally changes. When behavior changes, update
|
|
134
|
+
only the affected tests and add coverage for the new contract; never weaken or
|
|
135
|
+
delete tests merely to make the suite pass.
|
|
132
136
|
- Do not introduce a test framework or create low-value tests solely to satisfy
|
|
133
137
|
this rule. If automated coverage is impractical, explain why and perform the
|
|
134
138
|
strongest targeted verification available.
|
package/bin/codex-kit.js
CHANGED
|
@@ -747,18 +747,17 @@ function markApplied(options) {
|
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
// src/version.ts
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
numbers: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
757
|
-
prerelease: match[4] ?? null
|
|
758
|
-
};
|
|
750
|
+
function parseVersion(value) {
|
|
751
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(value);
|
|
752
|
+
if (!match) throw new Error(`Invalid package version: ${value}`);
|
|
753
|
+
return {
|
|
754
|
+
numbers: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
755
|
+
prerelease: match[4] ?? null
|
|
759
756
|
};
|
|
760
|
-
|
|
761
|
-
|
|
757
|
+
}
|
|
758
|
+
function compareVersions(left, right) {
|
|
759
|
+
const a = parseVersion(left);
|
|
760
|
+
const b = parseVersion(right);
|
|
762
761
|
for (const [leftNumber, rightNumber] of [
|
|
763
762
|
[a.numbers[0], b.numbers[0]],
|
|
764
763
|
[a.numbers[1], b.numbers[1]],
|
|
@@ -772,27 +771,35 @@ function compareVersions(left, right) {
|
|
|
772
771
|
a.prerelease.localeCompare(b.prerelease, "en", { numeric: true })
|
|
773
772
|
);
|
|
774
773
|
}
|
|
775
|
-
function
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
774
|
+
async function fetchLatestVersion() {
|
|
775
|
+
const url = `${REGISTRY}/${encodeURIComponent(PACKAGE.name)}/latest`;
|
|
776
|
+
let response;
|
|
777
|
+
try {
|
|
778
|
+
response = await fetch(url, { signal: AbortSignal.timeout(15e3) });
|
|
779
|
+
} catch (error) {
|
|
780
|
+
throw new Error(
|
|
781
|
+
`Unable to check ${REGISTRY}: ${error instanceof Error ? error.message : String(error)}`
|
|
782
782
|
);
|
|
783
|
-
if (result.error)
|
|
784
|
-
throw new Error(`Unable to run pnpm: ${result.error.message}`);
|
|
785
|
-
if (result.status !== 0)
|
|
786
|
-
throw new Error(
|
|
787
|
-
`Unable to check ${REGISTRY}: ${result.stderr.trim() || "pnpm view failed"}`
|
|
788
|
-
);
|
|
789
|
-
try {
|
|
790
|
-
const value = JSON.parse(result.stdout);
|
|
791
|
-
latest = Array.isArray(value) && typeof value.at(-1) === "string" ? value.at(-1) : typeof value === "string" ? value : void 0;
|
|
792
|
-
} catch {
|
|
793
|
-
latest = result.stdout.trim();
|
|
794
|
-
}
|
|
795
783
|
}
|
|
784
|
+
if (!response.ok)
|
|
785
|
+
throw new Error(
|
|
786
|
+
`Unable to check ${REGISTRY}: ${response.status} ${response.statusText}`
|
|
787
|
+
);
|
|
788
|
+
let value;
|
|
789
|
+
try {
|
|
790
|
+
value = await response.json();
|
|
791
|
+
} catch {
|
|
792
|
+
throw new Error("Registry returned no package version.");
|
|
793
|
+
}
|
|
794
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || typeof value.version !== "string")
|
|
795
|
+
throw new Error("Registry returned no package version.");
|
|
796
|
+
const latest = value.version;
|
|
797
|
+
parseVersion(latest);
|
|
798
|
+
return latest;
|
|
799
|
+
}
|
|
800
|
+
async function checkVersion() {
|
|
801
|
+
let latest = process.env.CODEX_KIT_LATEST_VERSION;
|
|
802
|
+
if (!latest) latest = await fetchLatestVersion();
|
|
796
803
|
if (!latest) throw new Error("Registry returned no package version.");
|
|
797
804
|
console.log(`Installed: ${PACKAGE.version}`);
|
|
798
805
|
console.log(`Latest: ${latest}`);
|
|
@@ -897,7 +904,7 @@ Examples:
|
|
|
897
904
|
codex-kit project sync --cwd /path/to/project --force
|
|
898
905
|
codex-kit project status --cwd /path/to/project`);
|
|
899
906
|
}
|
|
900
|
-
function main(argv = process.argv.slice(2)) {
|
|
907
|
+
async function main(argv = process.argv.slice(2)) {
|
|
901
908
|
const options = parse(argv);
|
|
902
909
|
if (options.positionals.includes("--version") || options.positionals.includes("-v")) {
|
|
903
910
|
console.log(PACKAGE.version);
|
|
@@ -919,14 +926,14 @@ function main(argv = process.argv.slice(2)) {
|
|
|
919
926
|
else if (scope === "project" && action === "status") projectStatus(options);
|
|
920
927
|
else if (scope === "project" && action === "mark-applied")
|
|
921
928
|
markApplied(options);
|
|
922
|
-
else if (scope === "version" && action === "check") checkVersion();
|
|
929
|
+
else if (scope === "version" && action === "check") await checkVersion();
|
|
923
930
|
else throw new Error(`Unknown command: ${options.positionals.join(" ")}`);
|
|
924
931
|
}
|
|
925
932
|
|
|
926
933
|
// src/codex-kit.ts
|
|
927
934
|
if (process.argv[1] && realpathSync(resolve3(process.argv[1])) === realpathSync(fileURLToPath2(import.meta.url))) {
|
|
928
935
|
try {
|
|
929
|
-
main();
|
|
936
|
+
await main();
|
|
930
937
|
} catch (error) {
|
|
931
938
|
console.error(
|
|
932
939
|
`error: ${error instanceof Error ? error.message : String(error)}`
|