@iamdevlinph/codex-kit 1.0.13 → 1.0.14
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 +25 -24
- package/bin/codex-kit.js +44 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -143,47 +143,41 @@ hooks. Modified managed files are preserved unless `--force` is supplied.
|
|
|
143
143
|
|
|
144
144
|
## Apply to a project
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
### First-time setup
|
|
147
|
+
|
|
148
|
+
For a new blank project, scaffold its initial stack first. Then initialize
|
|
149
|
+
codex-kit once from the project root:
|
|
147
150
|
|
|
148
151
|
```sh
|
|
149
152
|
cd /path/to/project
|
|
150
153
|
pnpm dlx @iamdevlinph/codex-kit@latest project init
|
|
151
154
|
```
|
|
152
155
|
|
|
153
|
-
|
|
156
|
+
`project init` performs the initial template sync, so do not run `project sync`
|
|
157
|
+
immediately afterward. It creates or updates:
|
|
154
158
|
|
|
155
|
-
- `AGENTS.md`,
|
|
159
|
+
- `AGENTS.md`, only when missing; an existing file is preserved
|
|
156
160
|
- `TEMPLATE_AGENTS.md`, a local reference copy used for future comparisons
|
|
157
161
|
- `.codex-kit-state.json`, reconciliation bookkeeping
|
|
158
162
|
|
|
159
|
-
|
|
160
|
-
the
|
|
161
|
-
|
|
162
|
-
|
|
163
|
+
If `AGENTS.md` is missing or still contains only the untouched codex-kit
|
|
164
|
+
scaffold, the CLI prints a clearly marked initialization prompt. Copy everything
|
|
165
|
+
between `BEGIN CODEX INITIALIZATION PROMPT` and
|
|
166
|
+
`END CODEX INITIALIZATION PROMPT` into a Codex task opened at the project root.
|
|
167
|
+
The prompt asks Codex to verify that the project has enough substantive code,
|
|
168
|
+
dependencies, configuration, and scripts to derive reliable guidance. If not,
|
|
169
|
+
Codex stops without inventing rules or marking the template applied. Finish
|
|
170
|
+
scaffolding the project, rerun `project init`, and send the new CLI prompt.
|
|
163
171
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
```txt
|
|
168
|
-
Explore this repository before changing code. Identify its languages,
|
|
169
|
-
frameworks, package manager, scripts, directory structure, styling and component
|
|
170
|
-
systems, form and validation libraries, data-access patterns, testing tools, and
|
|
171
|
-
generated files.
|
|
172
|
-
|
|
173
|
-
Update only the project-specific section of AGENTS.md with concise guidelines
|
|
174
|
-
derived from the repository's actual dependencies, configuration, scripts, and
|
|
175
|
-
established code patterns. Include exact verification commands. Preserve the
|
|
176
|
-
managed shared-template block, avoid speculative preferences, and do not add
|
|
177
|
-
rules for tools the repository does not use.
|
|
178
|
-
```
|
|
172
|
+
When `AGENTS.md` already contains guidance, `project init` preserves it and
|
|
173
|
+
prints the reconciliation prompt described below instead.
|
|
179
174
|
|
|
180
175
|
## Synchronize template updates
|
|
181
176
|
|
|
182
|
-
|
|
177
|
+
After a newer codex-kit template is released, refresh an initialized project:
|
|
183
178
|
|
|
184
179
|
```sh
|
|
185
180
|
pnpm dlx @iamdevlinph/codex-kit@latest project sync
|
|
186
|
-
codex-kit project status
|
|
187
181
|
```
|
|
188
182
|
|
|
189
183
|
`project sync` never edits `AGENTS.md` or project skills. It routes Codex to the
|
|
@@ -195,10 +189,17 @@ database, deployment, and destructive-operation rules remain in `AGENTS.md`;
|
|
|
195
189
|
do not copy the complete template or introduce managed markers. After semantic
|
|
196
190
|
reconciliation and validation, record the applied template hash:
|
|
197
191
|
|
|
192
|
+
The CLI prints a clearly marked reconciliation prompt. Copy everything between
|
|
193
|
+
`BEGIN CODEX RECONCILIATION PROMPT` and `END CODEX RECONCILIATION PROMPT` into a
|
|
194
|
+
Codex task opened at the project root. That prompt tells Codex to validate and
|
|
195
|
+
then run:
|
|
196
|
+
|
|
198
197
|
```sh
|
|
199
198
|
codex-kit project mark-applied
|
|
200
199
|
```
|
|
201
200
|
|
|
201
|
+
You normally do not run that command manually.
|
|
202
|
+
|
|
202
203
|
`mark-applied` updates only `.codex-kit-state.json`; it does not validate or
|
|
203
204
|
modify `AGENTS.md`.
|
|
204
205
|
|
package/bin/codex-kit.js
CHANGED
|
@@ -1,35 +1,61 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{realpathSync as $e}from"node:fs";import{resolve as
|
|
3
|
-
`)}function B(o,e,t,n,r){let i=
|
|
4
|
-
`)){if(/^\s*\[/.test(n)){t=!0;continue}if(t)continue;let r=/^(\s*)(model|model_reasoning_effort|plan_mode_reasoning_effort)\s*=\s*(.*?)\s*$/.exec(n),i=r?.[2],s=r?.[3];i&&s!==void 0&&!e.has(i)&&e.set(i,{value:s,line:n})}return e}var
|
|
5
|
-
`),n=new Set,r=t.findIndex(s=>/^\s*\[/.test(s));r<0&&(r=t.length);for(let s=0;s<r;s++){let a=/^(\s*)(model|model_reasoning_effort|plan_mode_reasoning_effort)\s*=\s*(.*?)\s*$/.exec(t[s]??""),c=a?.[2];!a||!c||n.has(c)||(t[s]=`${a[1]}${c} = ${
|
|
2
|
+
import{realpathSync as $e}from"node:fs";import{resolve as lo}from"node:path";import{fileURLToPath as co}from"node:url";import{copyFileSync as Ve,existsSync as m,mkdirSync as Xe,readdirSync as N,rmSync as A,statSync as ge}from"node:fs";import{join as f}from"node:path";import{createHash as Oe}from"node:crypto";import{copyFileSync as Ce,existsSync as H,mkdirSync as _e,readFileSync as Q,renameSync as Ne,writeFileSync as Ie}from"node:fs";import{dirname as Le}from"node:path";var k=o=>typeof o=="object"&&o!==null,E=o=>Oe("sha256").update(o).digest("hex"),y=o=>Q(o),g=o=>Q(o,"utf8");function S(o){if(!H(o))return null;let e=()=>new Date().toISOString().replace(/[-:TZ.]/g,""),t=`${o}.codex-kit.bak-${e()}`,n=1;for(;H(t);)t=`${o}.codex-kit.bak-${e()}-${n++}`;return Ce(o,t),console.log(`backup: ${t}`),t}function u(o,e){_e(Le(o),{recursive:!0});let t=`${o}.codex-kit.tmp-${process.pid}`;Ie(t,e),Ne(t,o)}function K(o){if(!H(o))return{};try{let e=JSON.parse(g(o));if(k(e))return e}catch{}throw new Error(`${o} must contain a JSON object; fix or move it before installing.`)}import{readFileSync as je}from"node:fs";import{dirname as Ge,join as w,resolve as Re}from"node:path";import{fileURLToPath as Pe}from"node:url";var M=Re(Ge(Pe(import.meta.url)),".."),L=w(M,"assets"),D=w(L,"agents"),ee=w(L,"skills"),h="codex-kit-reconcile-agents",oe=w(ee,h,"SKILL.md"),te=w(ee,h,"agents","openai.yaml"),F=w(L,"SUBAGENT_ROUTING.md"),ne=w(M,"bin","routing-hook.js"),U=w(L,"TEMPLATE_AGENTS.md"),p=JSON.parse(je(w(M,"package.json"),"utf8")),J=p.publishConfig?.registry??"https://registry.npmjs.org";import{existsSync as ie,rmSync as Me}from"node:fs";import{join as De}from"node:path";import{copyFileSync as He,existsSync as j,rmSync as Ke}from"node:fs";import{join as re}from"node:path";var C=".codex-kit-state.json";function O(o){let e=re(o,C);if(!j(e))return{version:p.version,files:{}};try{let t=JSON.parse(g(e));return k(t)&&k(t.files)?t:{version:p.version,files:{}}}catch{throw new Error(`${e} is not valid JSON; move it aside before reinstalling.`)}}function G(o,e){u(re(o,C),`${JSON.stringify(e,null,2)}
|
|
3
|
+
`)}function B(o,e,t,n,r){let i=y(o),s=E(i),a=n.files[t];if(!j(e))return u(e,i),console.log(`installed: ${e}`),{target:e,hash:s,ownership:"created",backup:null};let c=E(y(e));if(c===s)return console.log(`unchanged: ${e}`),a??{target:e,hash:s,ownership:"preexisting",backup:null};let d=a&&a.target===e&&a.ownership!=="preexisting"&&a.hash===c;if(!d&&!r)return console.warn(`preserved modified or pre-existing file: ${e} (use --force to replace)`),a??null;let l=S(e);return u(e,i),console.log(`updated: ${e}`),{target:e,hash:s,ownership:d?a.ownership:"replaced",backup:d?a.backup:l}}function se(o){let{target:e}=o;!j(e)||E(y(e))!==o.hash?console.warn(`preserved modified or missing file: ${e}`):o.ownership==="created"?(Ke(e),console.log(`removed: ${e}`)):o.ownership==="replaced"&&o.backup&&j(o.backup)?(He(o.backup,e),console.log(`restored: ${e}`)):console.log(`preserved pre-existing file: ${e}`)}function R(o){let e=new Map,t=!1;for(let n of o.split(`
|
|
4
|
+
`)){if(/^\s*\[/.test(n)){t=!0;continue}if(t)continue;let r=/^(\s*)(model|model_reasoning_effort|plan_mode_reasoning_effort)\s*=\s*(.*?)\s*$/.exec(n),i=r?.[2],s=r?.[3];i&&s!==void 0&&!e.has(i)&&e.set(i,{value:s,line:n})}return e}var _=o=>JSON.stringify(o);function Fe(o,e){let t=o.split(`
|
|
5
|
+
`),n=new Set,r=t.findIndex(s=>/^\s*\[/.test(s));r<0&&(r=t.length);for(let s=0;s<r;s++){let a=/^(\s*)(model|model_reasoning_effort|plan_mode_reasoning_effort)\s*=\s*(.*?)\s*$/.exec(t[s]??""),c=a?.[2];!a||!c||n.has(c)||(t[s]=`${a[1]}${c} = ${_(e[c])}`,n.add(c))}let i=Object.keys(e).filter(s=>!n.has(s)).map(s=>`${s} = ${_(e[s])}`);return i.length&&t.splice(0,0,...i,""),t.join(`
|
|
6
6
|
`)}function Ue(o,e){let t=o.split(`
|
|
7
|
-
`),n=t.findIndex(i=>/^\s*\[/.test(i));n<0&&(n=t.length);let r=new Set;for(let i=0;i<n;i++){let s=/^(\s*)(model|model_reasoning_effort|plan_mode_reasoning_effort)\s*=\s*(.*?)\s*$/.exec(t[i]??""),a=s?.[2];if(!s||!a||r.has(a)||s[3]!==
|
|
8
|
-
`)}function
|
|
9
|
-
`,
|
|
10
|
-
`),console.log(`removed managed routing hooks from: ${o.target}`)}var
|
|
7
|
+
`),n=t.findIndex(i=>/^\s*\[/.test(i));n<0&&(n=t.length);let r=new Set;for(let i=0;i<n;i++){let s=/^(\s*)(model|model_reasoning_effort|plan_mode_reasoning_effort)\s*=\s*(.*?)\s*$/.exec(t[i]??""),a=s?.[2];if(!s||!a||r.has(a)||s[3]!==_(e.desired[a]))continue;let c=e.previous[a];c?.present?t[i]=`${s[1]}${a} = ${c.value}`:(t.splice(i,1),i--,n--),r.add(a)}return Object.values(e.previous).some(i=>i&&!i.present)&&t[0]===""&&t.shift(),t.join(`
|
|
8
|
+
`)}function z(o){let e=o.codexHome,t=De(e,"config.toml"),n={model:o.orchestrator,model_reasoning_effort:o.reasoningEffort,plan_mode_reasoning_effort:o.planReasoningEffort},r=O(e),i=ie(t)?g(t):"",s=R(i);if(r.config?.target===t&&Object.entries(r.config.desired).some(([l,v])=>s.get(l)?.value!==_(v))&&!o.force){console.warn(`preserved modified config: ${t} (use --force to replace)`);return}let a=Fe(i,n);a!==i?(S(t),u(t,a),console.log(`configured orchestrator: ${t}`)):console.log(`unchanged: ${t}`);let c=r.config?.previous??{};for(let d of Object.keys(n)){if(d in c)continue;let l=s.get(d);c[d]=l?{present:!0,value:l.value}:{present:!1}}r.version=p.version,r.config={target:t,desired:n,previous:c},G(e,r),console.log(`Orchestrator: ${n.model}`),console.log(`Reasoning effort: ${n.model_reasoning_effort}`),console.log(`Plan mode reasoning effort: ${n.plan_mode_reasoning_effort}`)}function ae(o){if(!ie(o.target)){console.warn(`preserved missing config: ${o.target}`);return}let e=g(o.target),t=R(e);if(Object.entries(o.desired).some(([i,s])=>t.get(i)?.value!==_(s))){console.warn(`preserved modified config: ${o.target}`);return}let r=Ue(e,o);r!==e&&(S(o.target),r.trim()?u(o.target,r):Me(o.target),console.log(`restored config: ${o.target}`))}import{existsSync as V,rmSync as Je}from"node:fs";import{join as le}from"node:path";var Be=o=>`'${o.replaceAll("'",`'"'"'`)}'`,ze=o=>({command:`/usr/bin/env node ${Be(o)}`,commandWindows:`node ${JSON.stringify(o)}`});function ce(o,e){let t=o.hooks;if(k(t))for(let[n,r]of Object.entries(t)){if(!Array.isArray(r))continue;let i=r.flatMap(s=>{if(!k(s)||!Array.isArray(s.hooks))return[s];let a=s.hooks.filter(c=>!k(c)||c.command!==e.command&&c.commandWindows!==e.commandWindows);return a.length?[{...s,hooks:a}]:[]});i.length?t[n]=i:delete t[n]}}function de(o,e){let t=le(o,"hooks.json"),n=ze(le(o,"codex-kit","routing-hook.js")),r=e?.created??!V(t),i=K(t);e&&ce(i,e);let s=k(i.hooks)?i.hooks:{};i.hooks=s;let a={type:"command",...n,timeout:5};s.UserPromptSubmit=[...Array.isArray(s.UserPromptSubmit)?s.UserPromptSubmit:[],{hooks:[{...a,statusMessage:"Loading subagent routing"}]}],s.SubagentStart=[...Array.isArray(s.SubagentStart)?s.SubagentStart:[],{hooks:[{...a,statusMessage:"Briefing delegated worker"}]}];let c=`${JSON.stringify(i,null,2)}
|
|
9
|
+
`,d=V(t)?g(t):"";return c!==d&&(S(t),u(t,c),console.log(`updated: ${t}`)),{target:t,...n,created:r}}function fe(o){if(!V(o.target)){console.warn(`preserved missing hooks file: ${o.target}`);return}let e=K(o.target);ce(e,o),k(e.hooks)&&!Object.keys(e.hooks).length&&delete e.hooks,S(o.target),o.created&&!Object.keys(e).length?Je(o.target):u(o.target,`${JSON.stringify(e,null,2)}
|
|
10
|
+
`),console.log(`removed managed routing hooks from: ${o.target}`)}var X="<!-- BEGIN codex-kit:subagent-routing -->",pe="<!-- END codex-kit:subagent-routing -->",We=(o,e,t)=>`${e}
|
|
11
11
|
${o.trimEnd()}
|
|
12
|
-
${t}`;function qe(o,e,t,n){let r=o.indexOf(t),i=o.indexOf(n);if(r>=0!=i>=0||r>=0&&i<r)throw new Error(`Malformed managed block: expected both ${t} and ${n}.`);let s=
|
|
12
|
+
${t}`;function qe(o,e,t,n){let r=o.indexOf(t),i=o.indexOf(n);if(r>=0!=i>=0||r>=0&&i<r)throw new Error(`Malformed managed block: expected both ${t} and ${n}.`);let s=We(e,t,n);return r>=0?`${o.slice(0,r)}${s}${o.slice(i+n.length)}`:`${o.trimEnd()}${o.trim()?`
|
|
13
13
|
|
|
14
14
|
`:""}${s}
|
|
15
|
-
`}function
|
|
15
|
+
`}function Ze(o,e,t){let n=o.indexOf(e),r=o.indexOf(t);if(n<0&&r<0)return o;if(n<0||r<n)throw new Error("Malformed managed block in AGENTS.md.");let i=o.slice(0,n).trimEnd(),s=o.slice(r+t.length).trimStart();return`${i}${i&&s?`
|
|
16
16
|
|
|
17
17
|
`:""}${s}${i||s?`
|
|
18
|
-
`:""}`}function me(o){let e=o.codexHome;
|
|
19
|
-
|
|
18
|
+
`:""}`}function me(o){let e=o.codexHome;Xe(e,{recursive:!0});let t=O(e),n={version:p.version,files:{},globalAgents:null,hooks:null,config:t.config??null};for(let d of N(D).filter(l=>l.endsWith(".toml")).sort()){let l=`agents/${d}`,v=B(f(D,d),f(e,"agents",d),l,t,o.force);v&&(n.files[l]=v)}let r=[[F,f(e,"SUBAGENT_ROUTING.md"),"routing"],[oe,f(e,"skills",h,"SKILL.md"),`skills/${h}/SKILL.md`],[te,f(e,"skills",h,"agents","openai.yaml"),`skills/${h}/agents/openai.yaml`],[ne,f(e,"codex-kit","routing-hook.js"),"routing-hook"]];for(let[d,l,v]of r){let I=B(d,l,v,t,o.force);I&&(n.files[v]=I)}for(let[d,l]of Object.entries(t.files))d in n.files||(!m(l.target)||E(y(l.target))!==l.hash?(console.warn(`preserved stale modified or missing file: ${l.target}`),n.files[d]=l):l.ownership==="created"?(A(l.target),console.log(`removed stale: ${l.target}`)):l.ownership==="replaced"&&l.backup&&m(l.backup)&&(Ve(l.backup,l.target),console.log(`restored stale: ${l.target}`)));let i=f(e,"AGENTS.md"),s=m(i)?g(i):"",a=qe(s,g(F),X,pe);a!==s&&(S(i),u(i,a),console.log(`updated: ${i}`)),n.globalAgents={target:i},n.hooks=de(e,t.hooks),G(e,n);let c=f(e,"agents","commit-pusher.toml");m(c)&&console.warn(`warning: existing unmanaged commit-pusher remains at ${c}`),console.log(`Codex kit ${p.version} installed under ${e}`)}function ue(o){let e=o.codexHome,t=f(e,"config.toml"),n=f(e,"AGENTS.md"),r=O(e),i=m(t)?R(g(t)):new Map,s=b=>{let x=i.get(b)?.value;if(!x)return"not set";try{return String(JSON.parse(x))}catch{return x}};console.log(`Codex home: ${e}`),console.log(`Config: ${t}${m(t)?"":" (missing)"}`),console.log(`Orchestrator: ${s("model")}`),console.log(`Reasoning effort: ${s("model_reasoning_effort")}`),console.log(`Plan mode reasoning effort: ${s("plan_mode_reasoning_effort")}`),console.log(`Kit state: ${m(f(e,C))?r.version:"not installed"}`),console.log(`Global routing: ${m(n)&&g(n).includes(X)?"installed":"not installed"}`),console.log(`Routing file: ${m(f(e,"SUBAGENT_ROUTING.md"))?f(e,"SUBAGENT_ROUTING.md"):"missing"}`);let a=r.hooks;console.log(`Routing hook: ${a&&m(a.target)&&g(a.target).includes(a.command)?"installed":"not installed"}`);let c=[[f(e,"skills",h,"SKILL.md"),r.files[`skills/${h}/SKILL.md`]],[f(e,"skills",h,"agents","openai.yaml"),r.files[`skills/${h}/agents/openai.yaml`]]],d=c.every(([b,x])=>m(b)&&x&&E(y(b))===x.hash)?"installed":c.some(([b])=>m(b))?"modified or incomplete":"missing";console.log(`Reconciliation skill: ${d}`),console.log("Custom agents:");let l=f(e,"agents"),v=m(l)?N(l).filter(b=>b.endsWith(".toml")).sort():[];if(!v.length){console.log(" (none)");return}let I=new Set(Object.values(r.files).map(b=>b.target));for(let b of v){let x=f(l,b),Te=g(x),P=Ae=>new RegExp(`^${Ae}\\s*=\\s*"([^"]*)"`,"m").exec(Te)?.[1]??"not set";console.log(` ${P("name")} \u2014 ${P("model")}, ${P("model_reasoning_effort")} (${I.has(x)?"managed":"unmanaged"})`)}}function he(o){let e=o.codexHome,t=f(e,C);if(!m(t)){console.log(`No installer state at ${t}; nothing removed.`);return}let n=O(e);for(let d of Object.values(n.files))se(d);let r=n.globalAgents?.target??f(e,"AGENTS.md");if(m(r)){let d=g(r),l=Ze(d,X,pe);l!==d&&(S(r),l?u(r,l):A(r),console.log(`removed managed routing from: ${r}`))}n.config&&ae(n.config),n.hooks&&fe(n.hooks);let i=f(e,"skills",h),s=f(i,"agents");m(s)&&ge(s).isDirectory()&&!N(s).length&&A(s,{recursive:!0}),m(i)&&ge(i).isDirectory()&&!N(i).length&&A(i,{recursive:!0});let a=f(e,"codex-kit","allowances");m(a)&&A(a,{recursive:!0,force:!0});let c=f(e,"codex-kit");m(c)&&!N(c).length&&A(c,{recursive:!0}),A(t),console.log(`Codex kit uninstalled from ${e}`)}import{existsSync as $,statSync as Ye}from"node:fs";import{join as T}from"node:path";var Ee=".codex-kit-state.json",Qe="<!-- BEGIN codex-kit:shared-template -->",eo="<!-- END codex-kit:shared-template -->",ke=`# Project-Specific Instructions
|
|
19
|
+
|
|
20
|
+
<!-- Add repository-specific commands, architecture, and exceptions here. -->
|
|
21
|
+
`;function W(o){let e=T(o,Ee);if(!$(e))return{version:1,template:{}};try{let t=JSON.parse(g(e));return k(t)&&k(t.template)?t:{version:1,template:{}}}catch{throw new Error(`${e} is not valid JSON; move it aside before syncing.`)}}var Se=(o,e)=>u(T(o,Ee),`${JSON.stringify(e,null,2)}
|
|
22
|
+
`),q=o=>{if(!$(o)||!Ye(o).isDirectory())throw new Error(`Not a directory: ${o}`)};function oo(){return`Project guidance needs initialization. Copy everything between the markers into Codex.
|
|
23
|
+
|
|
24
|
+
===== BEGIN CODEX INITIALIZATION PROMPT =====
|
|
25
|
+
Explore this repository before changing code. First determine whether it has a
|
|
26
|
+
substantially scaffolded implementation with enough dependency, configuration,
|
|
27
|
+
script, and source evidence to derive reliable project guidance.
|
|
28
|
+
|
|
29
|
+
If evidence is insufficient, do not add speculative rules or mark the template
|
|
30
|
+
applied. Report what still needs to be scaffolded, then stop.
|
|
31
|
+
|
|
32
|
+
If evidence is sufficient, identify the stack, package manager, scripts,
|
|
33
|
+
structure, established patterns, testing tools, and generated files. Add concise
|
|
34
|
+
project-specific guidance to AGENTS.md based only on repository evidence,
|
|
35
|
+
including exact verification commands. Then use the global
|
|
36
|
+
$${h} skill to merge applicable reusable guidance from
|
|
37
|
+
TEMPLATE_AGENTS.md while preserving AGENTS.md organization and local rules.
|
|
38
|
+
Validate the final instruction changes, mark the template applied only after
|
|
39
|
+
validation succeeds, and confirm codex-kit project status is up to date.
|
|
40
|
+
===== END CODEX INITIALIZATION PROMPT =====`}function to(){return`Template reference updated. Copy everything between the markers into Codex.
|
|
41
|
+
|
|
42
|
+
===== BEGIN CODEX RECONCILIATION PROMPT =====
|
|
43
|
+
Use the global $${h} skill to reconcile the existing AGENTS.md
|
|
44
|
+
with the refreshed TEMPLATE_AGENTS.md.
|
|
20
45
|
|
|
21
46
|
Inspect TEMPLATE_AGENTS.md, AGENTS.md, .codex-kit-state.json, existing
|
|
22
47
|
.agents/skills, and codex-kit project status. Preserve local adaptations and
|
|
23
48
|
AGENTS.md organization; merge only applicable reusable guidance. Keep critical
|
|
24
49
|
always-on safety and authorization rules in AGENTS.md, extract only concrete
|
|
25
50
|
conditional procedures into validated skills, and do not copy the complete
|
|
26
|
-
template or introduce managed markers.
|
|
27
|
-
and validation, then report any template-worthy generalized promotion.`}function Ee(o){let{cwd:e}=o;X(e);let t=A(e,"AGENTS.md"),n=A(e,"TEMPLATE_AGENTS.md"),r=Buffer.from(g(D)),i=S(r),s=q(e);if(w(n)){let a=S(b(n));if(a!==i&&(!s.template.availableHash||a!==s.template.availableHash)&&!o.force){console.warn(`preserved locally modified template: ${n} (use --force to replace)`),console.log(`The installed kit has template ${p.version}; review the local change before syncing.`);return}a===i?console.log(`unchanged: ${n}`):(E(n),u(n,r),console.log(`refreshed template reference: ${n}`))}else u(n,r),console.log(`created template reference: ${n}`);if(s.version=1,s.template={...s.template,availableHash:i,availableVersion:p.version},Se(e,s),!w(t))u(t,`# Project-Specific Instructions
|
|
51
|
+
template or introduce managed markers.
|
|
28
52
|
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
Validate the final instruction changes. Mark applied only after reconciliation
|
|
54
|
+
and validation succeed, confirm codex-kit project status is up to date, then
|
|
55
|
+
report any template-worthy generalized promotion.
|
|
56
|
+
===== END CODEX RECONCILIATION PROMPT =====`}function be(o){let{cwd:e}=o;q(e);let t=T(e,"AGENTS.md"),n=T(e,"TEMPLATE_AGENTS.md"),r=Buffer.from(g(U)),i=E(r),s=W(e);if($(n)){let d=E(y(n));if(d!==i&&(!s.template.availableHash||d!==s.template.availableHash)&&!o.force){console.warn(`preserved locally modified template: ${n} (use --force to replace)`),console.log(`The installed kit has template ${p.version}; review the local change before syncing.`);return}d===i?console.log(`unchanged: ${n}`):(S(n),u(n,r),console.log(`refreshed template reference: ${n}`))}else u(n,r),console.log(`created template reference: ${n}`);if(s.version=1,s.template={...s.template,availableHash:i,availableVersion:p.version},Se(e,s),!$(t))u(t,ke),console.log(`created project instructions file: ${t}`);else{let d=g(t);(d.includes(Qe)||d.includes(eo))&&(console.warn(`preserved legacy managed template in: ${t}`),console.warn("Ask Codex to migrate it to semantic template reconciliation before applying updates."))}let c=g(t).trim()===ke.trim();console.log(c?oo():to())}function ye(o){let{cwd:e}=o;q(e);let t=T(e,"TEMPLATE_AGENTS.md"),n=W(e),r=n.template.availableHash??null,i=$(t)?E(y(t)):null;if(console.log(`Project: ${e}`),!i){console.log("Status: not initialized (run codex-kit project sync)");return}if(!$(T(e,"AGENTS.md"))){console.log("Status: AGENTS.md missing (reconcile the template first)");return}if(console.log(`Available: ${n.template.availableVersion??"unknown"} (${r??"untracked"})`),console.log(`Applied: ${n.template.appliedHash??"never"}`),E(y(U))!==r){console.log("Status: kit template update available; run project sync");return}if(i!==r){console.log("Status: local template changed; review it before syncing");return}if(n.template.appliedHash!==i){console.log("Status: reconciliation required");return}console.log("Status: up to date")}function ve(o){let{cwd:e}=o;q(e);let t=T(e,"TEMPLATE_AGENTS.md"),n=T(e,"AGENTS.md");if(!$(t))throw new Error(`Missing ${t}; run project sync first.`);if(!$(n))throw new Error(`Missing ${n}; reconcile the template into AGENTS.md first.`);let r=W(e);r.version=1,r.template={...r.template,appliedHash:E(y(t)),appliedAt:new Date().toISOString()},Se(e,r),console.log(`recorded template reconciliation: ${t}`)}import{spawnSync as no}from"node:child_process";function ro(o,e){let t=i=>{let s=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/.exec(i);if(!s)throw new Error(`Invalid package version: ${i}`);return{numbers:[Number(s[1]),Number(s[2]),Number(s[3])],prerelease:s[4]??null}},n=t(o),r=t(e);for(let[i,s]of[[n.numbers[0],r.numbers[0]],[n.numbers[1],r.numbers[1]],[n.numbers[2],r.numbers[2]]])if(i!==s)return Math.sign(i-s);return n.prerelease===r.prerelease?0:n.prerelease?r.prerelease?Math.sign(n.prerelease.localeCompare(r.prerelease,"en",{numeric:!0})):-1:1}function xe(){let o=process.env.CODEX_KIT_LATEST_VERSION;if(!o){let t=no(process.platform==="win32"?"pnpm.cmd":"pnpm",["view",p.name,"version","--json",`--registry=${J}`],{encoding:"utf8",timeout:15e3});if(t.error)throw new Error(`Unable to run pnpm: ${t.error.message}`);if(t.status!==0)throw new Error(`Unable to check ${J}: ${t.stderr.trim()||"pnpm view failed"}`);try{let n=JSON.parse(t.stdout);o=Array.isArray(n)&&typeof n.at(-1)=="string"?n.at(-1):typeof n=="string"?n:void 0}catch{o=t.stdout.trim()}}if(!o)throw new Error("Registry returned no package version.");console.log(`Installed: ${p.version}`),console.log(`Latest: ${o}`);let e=ro(p.version,o);if(e===0){console.log("codex-kit is up to date.");return}if(e>0){console.log("This local build is newer than the published package.");return}console.log(`Update available. Run:
|
|
31
57
|
pnpm add --global ${p.name}@latest
|
|
32
|
-
codex-kit global install`)}import{homedir as
|
|
58
|
+
codex-kit global install`)}import{homedir as so}from"node:os";import{join as io,resolve as Z}from"node:path";function we(o){let e={cwd:process.cwd(),codexHome:Z(process.env.CODEX_HOME||io(so(),".codex")),orchestrator:"gpt-5.6-sol",reasoningEffort:"low",planReasoningEffort:"high",force:!1,positionals:[]};for(let t=0;t<o.length;t++){let n=o[t];if(n!==void 0)if(n==="--force")e.force=!0;else if(n==="--cwd"||n==="--codex-home"){let r=o[++t];if(!r)throw new Error(`${n} requires a path.`);n==="--cwd"?e.cwd=Z(r):e.codexHome=Z(r)}else if(n==="--orchestrator"||n==="--model"){let r=o[++t];if(!r)throw new Error(`${n} requires a model.`);e.orchestrator=r}else if(n==="--reasoning-effort"||n==="--plan-reasoning-effort"){let r=o[++t];if(!r)throw new Error(`${n} requires a value.`);n==="--reasoning-effort"?e.reasoningEffort=r:e.planReasoningEffort=r}else e.positionals.push(n)}return e}function ao(){console.log(`codex-kit ${p.version}
|
|
33
59
|
|
|
34
60
|
Usage:
|
|
35
61
|
codex-kit <command> [options]
|
|
@@ -74,4 +100,4 @@ Examples:
|
|
|
74
100
|
codex-kit global install --force
|
|
75
101
|
codex-kit global configure --reasoning-effort low --plan-reasoning-effort high
|
|
76
102
|
codex-kit project sync --cwd /path/to/project --force
|
|
77
|
-
codex-kit project status --cwd /path/to/project`)}function
|
|
103
|
+
codex-kit project status --cwd /path/to/project`)}function Y(o=process.argv.slice(2)){let e=we(o);if(e.positionals.includes("--version")){console.log(p.version);return}if(!e.positionals.length||e.positionals.includes("--help")){ao();return}let[t,n]=e.positionals;if(t==="global"&&n==="install")me(e);else if(t==="global"&&n==="configure")z(e);else if(t==="global"&&n==="list")ue(e);else if(t==="global"&&n==="uninstall")he(e);else if(t==="project"&&(n==="init"||n==="sync"))be(e);else if(t==="project"&&n==="status")ye(e);else if(t==="project"&&n==="mark-applied")ve(e);else if(t==="version"&&n==="check")xe();else throw new Error(`Unknown command: ${e.positionals.join(" ")}`)}if(process.argv[1]&&$e(lo(process.argv[1]))===$e(co(import.meta.url)))try{Y()}catch(o){console.error(`error: ${o instanceof Error?o.message:String(o)}`),process.exitCode=1}export{Y as main};
|