codex-1up 0.2.2 → 0.2.4
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 +14 -4
- package/dist/main.js +34 -28
- package/package.json +1 -1
- package/templates/codex-config.toml +5 -5
package/README.md
CHANGED
|
@@ -16,7 +16,12 @@
|
|
|
16
16
|
## Quick start
|
|
17
17
|
|
|
18
18
|
```bash
|
|
19
|
-
#
|
|
19
|
+
# Quick install (no global install needed)
|
|
20
|
+
npx -y codex-1up install
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Or install globally (recommended for repeated use)
|
|
20
25
|
npm install -g codex-1up
|
|
21
26
|
codex-1up install
|
|
22
27
|
```
|
|
@@ -36,6 +41,7 @@ codex-1up install
|
|
|
36
41
|
| **ripgrep (rg)** | Fast text search across code. |
|
|
37
42
|
| **fzf** | Fuzzy‑finder to select among many matches. |
|
|
38
43
|
| **jq** / **yq** | Reliable JSON/YAML processing on the command line. |
|
|
44
|
+
| **difftastic** | Fast syntax‑aware diff tool for git. |
|
|
39
45
|
| **\~/.codex/config.toml** | Single template with multiple profiles. Active profile is chosen during install (default: `balanced`). See [Codex config reference](https://github.com/openai/codex/blob/main/docs/config.md). |
|
|
40
46
|
| **AGENTS.md** | Minimal per‑repo rubric; installer can also create global `~/.codex/AGENTS.md`. |
|
|
41
47
|
| **\~/.codex/notify.sh** | Notification hook script with customizable sounds for Codex events (default: `noti_1.wav`). |
|
|
@@ -47,7 +53,7 @@ codex-1up install
|
|
|
47
53
|
| --- | --- |
|
|
48
54
|
| balanced (default) | Approvals on-request; workspace-write sandbox with network access inside workspace. |
|
|
49
55
|
| safe | Approvals on-failure; workspace-write sandbox; conservative. |
|
|
50
|
-
| minimal |
|
|
56
|
+
| minimal | Medium reasoning effort; web search off. |
|
|
51
57
|
| yolo | Never ask for approvals; danger-full-access (only trusted environments). |
|
|
52
58
|
|
|
53
59
|
Switch profiles anytime: `codex --profile <name>` for a session, or `codex-1up config set-profile <name>` to persist.
|
|
@@ -82,17 +88,21 @@ See memory behavior with AGENTS.md in the official docs: [Memory with AGENTS.md]
|
|
|
82
88
|
|
|
83
89
|
### Common flags
|
|
84
90
|
|
|
85
|
-
- `--shell auto|zsh|bash|fish`
|
|
91
|
+
- `--shell auto|zsh|bash|fish` : shell to configure aliases for
|
|
86
92
|
- `--vscode EXT_ID` : install a VS Code extension (e.g. `openai.codex`)
|
|
87
93
|
- `--agents-md [PATH]` : write a starter `AGENTS.md` to PATH (default: `$PWD/AGENTS.md`)
|
|
88
94
|
- `--no-vscode` : skip VS Code extension checks
|
|
89
95
|
- `--install-node nvm|brew|skip` : how to install Node.js if missing (default: `nvm`)
|
|
96
|
+
- `--codex-cli yes|no` : install/upgrade Codex CLI (default: `yes` on macOS/Linux)
|
|
97
|
+
- `--tools yes|no` : install/upgrade tools: rg, fd, fzf, jq, yq, difftastic, ast-grep (default: `yes` on macOS/Linux)
|
|
98
|
+
- `--profile balanced|safe|minimal|yolo|skip` : profile to write (default: `balanced`)
|
|
99
|
+
- `--profile-mode add|overwrite` : profile merge strategy (default: `add`)
|
|
90
100
|
|
|
91
101
|
### Advanced / CI flags
|
|
92
102
|
|
|
93
103
|
- `--dry-run` : print what would happen, change nothing
|
|
94
104
|
- `--skip-confirmation` : suppress interactive prompts
|
|
95
|
-
- `--yes` : non-interactive, accept safe defaults (CI). Most users don
|
|
105
|
+
- `--yes` : non-interactive, accept safe defaults (CI). Most users don't need this.
|
|
96
106
|
|
|
97
107
|
## Develop locally (from source)
|
|
98
108
|
|
package/dist/main.js
CHANGED
|
@@ -1,47 +1,53 @@
|
|
|
1
|
-
import{runMain as
|
|
2
|
-
`:`${
|
|
3
|
-
`;process.stdout.write(r),t&&t.write(r)};return{log:i=>
|
|
4
|
-
`;async function
|
|
5
|
-
`,!0}setKey(t,
|
|
1
|
+
import{runMain as hn}from"citty";import{defineCommand as pn}from"citty";import{readFileSync as fn}from"fs";import{fileURLToPath as dn}from"url";import{dirname as cn,join as un}from"path";import{defineCommand as St}from"citty";import{fileURLToPath as Rt}from"url";import{dirname as Et,resolve as D}from"path";import{promises as X}from"fs";import*as J from"os";import{accessSync as Pt}from"fs";import*as ye from"toml";import*as l from"@clack/prompts";import{which as G,$ as K}from"zx";import Ct from"fs-extra";import*as me from"path";import*as qe from"os";import{createWriteStream as it}from"fs";function Re(e){let t=null;try{t=it(e,{flags:"a"})}catch{}let n=(i,o)=>{let r=i?`${i} ${o}
|
|
2
|
+
`:`${o}
|
|
3
|
+
`;process.stdout.write(r),t&&t.write(r)};return{log:i=>n("",i),info:i=>n("",i),ok:i=>n("\u2714",i),warn:i=>n("\u26A0",i),err:i=>n("\u2716",i)}}import{$ as L}from"zx";import{which as rt,$ as st}from"zx";import{spawn as at}from"child_process";async function c(e){try{return await rt(e),!0}catch{return!1}}async function Ee(){return await c("brew")?"brew":await c("apt-get")?"apt":await c("dnf")?"dnf":await c("pacman")?"pacman":await c("zypper")?"zypper":"none"}async function ee(e){if(await c("pnpm"))try{if((await st`pnpm bin -g`.quiet()).stdout.trim())return"pnpm";e?.warn('Detected pnpm but global bin dir is not configured; skipping global Node installs to avoid duplicates. Run "pnpm setup" then re-run.')}catch{e?.warn('Detected pnpm but global bin dir is not configured; skipping global Node installs to avoid duplicates. Run "pnpm setup" then re-run.')}return await c("pnpm")?"none":"npm"}async function g(e,t,n={dryRun:!1}){if(n.dryRun){let o=[e,...t].map(r=>r.includes(" ")?`"${r}"`:r).join(" ");n.logger?.log(`[dry-run] ${o}`);return}let i=at(e,t,{stdio:"inherit",cwd:n.cwd||process.cwd(),shell:!1});await new Promise((o,r)=>{i.on("error",r),i.on("exit",s=>{if(s===0)return o();r(new Error(`Command failed (${s}): ${e} ${t.join(" ")}`))})})}function T(e){let t=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);return`${e}.backup.${t}`}import Pe from"fs-extra";import*as U from"path";import*as z from"os";async function Ie(e){let t=await c("node"),n=await c("npm");if(t&&n){let o=(await L`node -v`).stdout.trim();e.logger.ok(`Node.js present (${o})`);return}switch(e.options.installNode){case"nvm":await lt(e);break;case"brew":await pt(e);break;case"skip":e.logger.warn("Skipping Node installation; please install Node 18+ manually");return}if(await c("node")){let o=(await L`node -v`).stdout.trim();e.logger.ok(`Node.js installed (${o})`)}else throw e.logger.err("Node installation failed"),new Error("Node.js installation failed")}async function lt(e){if(e.logger.info("Installing Node.js via nvm"),e.options.dryRun){e.logger.log("[dry-run] install nvm + Node LTS");return}let t=U.join(e.homeDir,".nvm"),n=U.join(t,"nvm.sh");await Pe.pathExists(t)||(e.logger.info("Installing nvm..."),await L`bash -c "curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash"`);let i=`export NVM_DIR="${t}" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" && nvm install --lts`;await L`bash -c ${i}`}async function pt(e){if(e.logger.info("Installing Node.js via Homebrew"),!await c("brew"))if(z.platform()==="darwin"){if(e.logger.info("Homebrew not found; installing Homebrew"),e.options.dryRun){e.logger.log("[dry-run] install Homebrew");return}await L`/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`;let t=z.platform()==="darwin"&&z.arch()==="arm64"?"/opt/homebrew/bin/brew":"/usr/local/bin/brew";if(await Pe.pathExists(t)){let n=U.dirname(t);process.env.PATH=`${n}:${process.env.PATH||""}`;try{let o=(await L`${t} shellenv`).stdout.trim().match(/export PATH="([^"]+)"/);o&&(process.env.PATH=`${o[1]}:${process.env.PATH||""}`)}catch{}}}else throw new Error("Homebrew is only available on macOS");await g("brew",["install","node"],{dryRun:e.options.dryRun,logger:e.logger})}import{$ as fe}from"zx";var ft=["@openai/codex"],dt="@openai/codex";async function Ne(e){if(e.options.installCodexCli==="no"){e.logger.info("Skipping Codex CLI install (user choice)");return}e.logger.info("Checking global packages (@openai/codex)");let t=[];for(let n of ft)try{if(n===dt&&await c("codex")){e.logger.ok("codex found on PATH; skipping global install/upgrade");continue}let o=(await fe`npm view ${n} version`.quiet()).stdout.trim();if(!o){e.logger.warn(`Could not fetch latest version for ${n}; skipping upgrade check`);continue}let r=await fe`npm ls -g ${n} --depth=0 --json`.quiet().nothrow(),s="";try{s=JSON.parse(r.stdout||"{}").dependencies?.[n]?.version||""}catch{s=""}s?s!==o?(e.logger.info(`${n} ${s} -> ${o}`),t.push(`${n}@${o}`)):e.logger.ok(`${n} up-to-date (${s})`):(e.logger.info(`${n} not installed; will install @${o}`),t.push(`${n}@${o}`))}catch(i){e.logger.warn(`Error checking ${n}: ${i}`);let o=await fe`npm ls -g ${n} --depth=0 --json`.quiet().nothrow(),r="";try{r=JSON.parse(o.stdout||"{}").dependencies?.[n]?.version||""}catch{r=""}r||t.push(n)}if(t.length>0){let n=await ee(e.logger);n==="none"?e.logger.warn('Skipping global Node installs because pnpm is detected but not configured. Run "pnpm setup" and re-run the installer.'):n==="pnpm"?(e.logger.info("Installing/updating global packages via pnpm"),await g("pnpm",["add","-g",...t],{dryRun:e.options.dryRun,logger:e.logger})):(e.logger.info("Installing/updating global packages via npm"),await g("npm",["install","-g",...t],{dryRun:e.options.dryRun,logger:e.logger}))}else e.logger.ok("Global packages are up-to-date");await c("codex")?e.logger.ok("Codex CLI installed"):e.logger.err("Codex CLI not found after install")}import{$ as ct}from"zx";import*as ce from"path";import de from"fs-extra";var ut={brew:["fd","ripgrep","fzf","jq","yq","difftastic","ast-grep"],apt:["ripgrep","fzf","jq","yq","git-delta"],dnf:["ripgrep","fd-find","fzf","jq","yq","git-delta"],pacman:["ripgrep","fd","fzf","jq","yq","git-delta"],zypper:["ripgrep","fd","fzf","jq","yq","git-delta"],none:[]};async function Te(e){if(e.options.installTools==="no"){e.logger.info("Skipping developer tool installs (user choice)");return}let t=await Ee();if(e.logger.info(`Detected package manager: ${t}`),t==="none"){e.logger.warn("Could not detect a supported package manager; please install tools manually");return}let n=ut[t]||[];if(n.length>0)switch(t){case"brew":await g("brew",["update"],{dryRun:e.options.dryRun,logger:e.logger}),await g("brew",["install",...n],{dryRun:e.options.dryRun,logger:e.logger});break;case"apt":await g("sudo",["apt-get","update","-y"],{dryRun:e.options.dryRun,logger:e.logger}),await g("sudo",["apt-get","install","-y",...n],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{}),await c("fd")||await g("sudo",["apt-get","install","-y","fd-find"],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{});break;case"dnf":await g("sudo",["dnf","install","-y",...n],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{});break;case"pacman":await g("sudo",["pacman","-Sy","--noconfirm",...n],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{});break;case"zypper":await g("sudo",["zypper","refresh"],{dryRun:e.options.dryRun,logger:e.logger}),await g("sudo",["zypper","install","-y",...n],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{});break}if(!await c("difft")&&!await c("difftastic")&&(await c("cargo")?(e.logger.info("Installing difftastic via cargo"),await g("cargo",["install","difftastic"],{dryRun:e.options.dryRun,logger:e.logger})):e.logger.warn("difftastic not found and Rust/cargo missing; falling back to git-delta")),await gt(e,t),await c("fdfind")&&!await c("fd")){let o=ce.join(e.homeDir,".local","bin");await de.ensureDir(o);let r=(await ct`command -v fdfind`).stdout.trim(),s=ce.join(o,"fd");await de.pathExists(s)||(e.options.dryRun?e.logger.log(`[dry-run] ln -s ${r} ${s}`):await de.symlink(r,s),e.logger.ok("fd alias created at ~/.local/bin/fd"))}let i=["fd","fdfind","rg","fzf","jq","yq","difft","difftastic","delta","ast-grep"];for(let o of i)await c(o)&&e.logger.ok(`${o} \u2713`)}async function gt(e,t){if(await c("sg")||await c("ast-grep"))return;let i=await(async()=>{switch(t){case"brew":return await g("brew",["install","ast-grep"],{dryRun:e.options.dryRun,logger:e.logger}),!0;case"apt":return await g("sudo",["apt-get","install","-y","ast-grep"],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{}),!0;case"dnf":return await g("sudo",["dnf","install","-y","ast-grep"],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{}),!0;case"pacman":return await g("sudo",["pacman","-Sy","--noconfirm","ast-grep"],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{}),!0;case"zypper":return await g("sudo",["zypper","install","-y","ast-grep"],{dryRun:e.options.dryRun,logger:e.logger}).catch(()=>{}),!0;default:return!1}})();if(await c("sg")||await c("ast-grep"))return;let o=await ee(e.logger);o==="pnpm"?(e.logger.info("Installing ast-grep via pnpm -g"),await g("pnpm",["add","-g","@ast-grep/cli"],{dryRun:e.options.dryRun,logger:e.logger})):o==="npm"?(e.logger.info("Installing ast-grep via npm -g"),await g("npm",["install","-g","@ast-grep/cli"],{dryRun:e.options.dryRun,logger:e.logger})):i||e.logger.warn("ast-grep not installed (no supported package manager or global npm). Install manually from https://ast-grep.github.io/")}import V from"fs-extra";import*as ne from"path";var mt={balanced:{root:[["approval_policy",'"on-request"'],["sandbox_mode",'"workspace-write"'],["model",'"gpt-5.1-codex"'],["model_reasoning_effort",'"medium"']],features:[["web_search_request","true"]]},safe:{root:[["approval_policy",'"on-failure"'],["sandbox_mode",'"workspace-write"'],["model",'"gpt-5.1-codex"'],["model_reasoning_effort",'"medium"']],features:[["web_search_request","false"]]},minimal:{root:[["model",'"gpt-5.1-codex"'],["model_reasoning_effort",'"medium"']],features:[["web_search_request","false"]]},yolo:{root:[["approval_policy",'"never"'],["sandbox_mode",'"danger-full-access"'],["model",'"gpt-5.1-codex"'],["model_reasoning_effort",'"medium"'],["model_reasoning_summary",'"detailed"'],["model_verbosity",'"high"'],["tool_output_token_limit","25000"]],features:[["web_search_request","true"]]}},ht=`# ~/.codex/config.toml \u2014 managed by codex-1up (patch mode)
|
|
4
|
+
`;async function xe(e){let t=ne.join(e.homeDir,".codex","config.toml");await V.ensureDir(ne.dirname(t));let n=await V.pathExists(t),i=n?await V.readFile(t,"utf8"):ht,o=new ge(i),r=!1;if(r=wt(o,e.options.profile,e.options.profileMode)||r,r=yt(o,e.options.profile,e.options.setDefaultProfile)||r,r=bt(o,e.options.notificationSound)||r,!r){e.logger.info("Config already up to date; no changes needed.");return}let s=o.content();if(e.options.dryRun){e.logger.log(`[dry-run] write ${t}`),e.logger.log(s);return}if(n){let a=T(t);await V.copy(t,a),e.logger.info(`Backed up current config to ${a}`)}await V.writeFile(t,s,"utf8"),e.logger.ok("Updated ~/.codex/config.toml with requested settings.")}function wt(e,t,n){if(t==="skip")return!1;let i=mt[t],o=!1;if(n==="overwrite")o=e.replaceTable(`profiles.${t}`,i.root)||o,o=e.replaceTable(`profiles.${t}.features`,i.features)||o;else{e.ensureTable(`profiles.${t}`);for(let[r,s]of i.root)o=e.setKey(`profiles.${t}`,r,s,{mode:"if-missing"})||o;e.ensureTable(`profiles.${t}.features`);for(let[r,s]of i.features)o=e.setKey(`profiles.${t}.features`,r,s,{mode:"if-missing"})||o}return o}function yt(e,t,n){return!n||t==="skip"?!1:e.setRootKey("profile",`"${t}"`,{mode:"force"})}function bt(e,t){if(!t||t==="none")return!1;e.ensureTable("tui");let n=e.getValue("tui","notifications");if(n){let i=n.trim().toLowerCase();if(i.startsWith("true")||i.startsWith("["))return!1}return e.setKey("tui","notifications","true",{mode:"force"})}var ge=class{text;constructor(t){this.text=t||""}content(){return $t(this.text)}ensureTable(t){if(this.hasTable(t))return!1;let n=this.text.length===0?"":De(this.text);return this.text=n+`[${t}]
|
|
5
|
+
`,!0}setKey(t,n,i,o){let r=te(this.text,t);if(!r)return this.ensureTable(t),this.setKey(t,n,i,o);let s=this.text.slice(r.start,r.end),d=new RegExp(`^\\s*${ue(n)}\\s*=.*$`,"m").exec(s);if(d){if(o.mode==="if-missing")return!1;let k=this.text,N=r.start+d.index,x=N+d[0].length;return this.text=k.slice(0,N)+`${n} = ${i}`+k.slice(x),this.text!==k}let m=this.text,b=r.end,h=m.slice(0,b),v=m.slice(b),p=h.length>0&&!h.endsWith(`
|
|
6
6
|
`),f=v.length>0&&!v.startsWith(`
|
|
7
|
-
`),
|
|
8
|
-
`:""}${
|
|
7
|
+
`),y=`${p?`
|
|
8
|
+
`:""}${n} = ${i}
|
|
9
9
|
${f?`
|
|
10
|
-
`:""}`;return this.text=y+
|
|
11
|
-
`),
|
|
10
|
+
`:""}`;return this.text=h+y+v,this.text!==m}getValue(t,n){let i=te(this.text,t);if(!i)return;let o=this.text.slice(i.start,i.end),s=new RegExp(`^\\s*${ue(n)}\\s*=\\s*(.+)$`,"m").exec(o);return s?s[1]:void 0}replaceTable(t,n){let i=n.map(([a,d])=>`${a} = ${d}`).join(`
|
|
11
|
+
`),o=`[${t}]
|
|
12
12
|
${i}
|
|
13
13
|
|
|
14
|
-
`,r=this.text,s=
|
|
14
|
+
`,r=this.text,s=te(this.text,t);if(!s){let a=r.length===0?"":De(r);return this.text=a+o,this.text!==r}return this.text=r.slice(0,s.start)+o+r.slice(s.end),this.text!==r}setRootKey(t,n,i){let o=kt(this.text),r=this.text.slice(o.start,o.end),a=new RegExp(`^\\s*${ue(t)}\\s*=.*$`,"m").exec(r);if(a){if(i.mode==="if-missing")return!1;let f=this.text,y=o.start+a.index,k=y+a[0].length;return this.text=f.slice(0,y)+`${t} = ${n}`+f.slice(k),this.text!==f}let d=this.text,m=o.end,b=m>0&&!d.slice(0,m).endsWith(`
|
|
15
|
+
`),h=d.slice(m),v=h.length>0&&!h.startsWith(`
|
|
16
|
+
`),p=`${b?`
|
|
17
|
+
`:""}${t} = ${n}
|
|
18
|
+
${v?`
|
|
19
|
+
`:""}`;return this.text=d.slice(0,m)+p+h,this.text!==d}hasTable(t){return te(this.text,t)!==null}};function te(e,t){let n=/^\s*\[([^\]]+)\]\s*$/gm,i=[],o;for(;o=n.exec(e);)i.push({name:o[1].trim(),index:o.index});for(let r=0;r<i.length;r++)if(i[r].name===t){let s=i[r].index,a=i[r+1]?.index??e.length;return{start:s,end:a}}return null}function kt(e){let n=/^\s*\[([^\]]+)\]\s*$/gm.exec(e);return n?{start:0,end:n.index}:{start:0,end:e.length}}function ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $t(e){return e.endsWith(`
|
|
15
20
|
`)?e:e+`
|
|
16
|
-
`}function
|
|
21
|
+
`}function De(e){let t=e;return t.endsWith(`
|
|
17
22
|
`)||(t+=`
|
|
18
23
|
`),t.endsWith(`
|
|
19
24
|
|
|
20
25
|
`)||(t+=`
|
|
21
|
-
`),t}import
|
|
22
|
-
notifications = true`);let v=[];r="";for(let
|
|
23
|
-
`),"utf8")}import S from"fs-extra";import*as
|
|
26
|
+
`),t}import P from"fs-extra";import*as F from"path";async function Ae(e){let t=F.join(e.homeDir,".codex","notify.sh"),n=F.join(e.rootDir,"templates","notification.sh");await P.ensureDir(F.dirname(t));let i=e.options.notify;if(i==="no"){e.logger.info("Skipping notify hook installation");return}if(!await P.pathExists(n)){e.logger.warn(`Notification template missing at ${n}; skipping notify hook install`);return}if(await P.pathExists(t))if(i==="yes"){let r=T(t);e.options.dryRun?e.logger.log(`[dry-run] cp ${t} ${r}`):await P.copy(t,r),e.options.dryRun?e.logger.log(`[dry-run] cp ${n} ${t}`):(await P.copy(n,t),await P.chmod(t,493)),e.logger.ok("Updated notify hook (backup created)")}else!e.options.assumeYes&&!e.options.skipConfirmation&&e.logger.info("Keeping existing notify hook");else e.options.dryRun?e.logger.log(`[dry-run] cp ${n} ${t}`):(await P.copy(n,t),await P.chmod(t,493)),e.logger.ok("Installed notify hook to ~/.codex/notify.sh");let o=F.join(e.homeDir,".codex","config.toml");await P.pathExists(o)?await vt(o,t,e):e.logger.warn(`Config not found at ${o}; run again after config is created`)}async function vt(e,t,n){if(n.options.dryRun){n.logger.log("[dry-run] update config notify and tui.notifications");return}let o=(await P.readFile(e,"utf8")).split(/\r?\n/),r="",s=null,a=null,d=!1,m=!1;for(let p=0;p<o.length;p++){let f=o[p],y=f.match(/^\s*\[([^\]]+)\]\s*$/);if(y){r=y[1],r==="tui"&&(a=p);continue}let k=/^\s*notify\s*=\s*\[/.test(f),N=/^\s*tui\.notifications\s*=/.test(f),x=/^\s*notifications\s*=/.test(f);k&&(r===""?s===null&&(s=p):/^profiles\.[^.]+\.features$/.test(r)&&(o.splice(p,1),p--,d=!0)),N&&/^profiles\.[^.]+\.features$/.test(r)&&(o.splice(p,1),p--,m=!0),x&&r===""&&(o.splice(p,1),p--,m=!0)}function b(p){let f=0;for(;f<o.length&&/^\s*(#.*)?$/.test(o[f]);)f++;o.splice(f,0,p)}if(s!==null){let p=o[s].match(/^(\s*notify\s*=\s*\[)([^\]]*)\]/);if(p){let f=p[2].trim();if(!f.includes(JSON.stringify(t))){let k=f&&!f.endsWith(",")?", ":"";o[s]=`${p[1]}${f}${k}${JSON.stringify(t)}]`,n.logger.ok("Added notify hook to config")}}}else b(`notify = [${JSON.stringify(t)}]`),n.logger.ok("Enabled notify hook in config");let h=!1;if(a!==null){let p=a+1,f=!1;for(;p<o.length;p++){let y=o[p];if(/^\s*\[/.test(y))break;if(/^\s*notifications\s*=/.test(y)){o[p]="notifications = true",f=!0,h=!0;break}}f||(o.splice(a+1,0,"notifications = true"),h=!0)}h||b(`[tui]
|
|
27
|
+
notifications = true`);let v=[];r="";for(let p=0;p<o.length;p++){let f=o[p],y=f.match(/^\s*\[([^\]]+)\]\s*$/);if(y){r=y[1],v.push(f);continue}/^\s*tui\.notifications\s*=/.test(f)||/^\s*notifications\s*=/.test(f)&&r!=="tui"||v.push(f)}await P.writeFile(e,v.join(`
|
|
28
|
+
`),"utf8")}import S from"fs-extra";import*as w from"path";async function Oe(e){let t=w.join(e.rootDir,"sounds"),n=w.join(e.homeDir,".codex","sounds");await S.ensureDir(n);let i=e.options.notificationSound;if(i==="none"){let h=await _e(e);e.options.dryRun?e.logger.log(`[dry-run] update ${h}`):await je(h,`# Notification sound (disabled)
|
|
24
29
|
export CODEX_DISABLE_SOUND=1
|
|
25
30
|
export CODEX_CUSTOM_SOUND=""
|
|
26
|
-
`,e);let
|
|
31
|
+
`,e);let p=w.join(e.homeDir,".codex","notify.sh");if(await S.pathExists(p)){let f=await S.readFile(p,"utf8"),y=f.replace(/^DEFAULT_CODEX_SOUND=.*$/m,'DEFAULT_CODEX_SOUND=""');e.options.dryRun?e.logger.log(`[dry-run] patch ${p} DEFAULT_CODEX_SOUND -> empty`):y!==f&&await S.writeFile(p,y,"utf8")}e.logger.ok("Notification sound disabled");return}let o;if(i&&!w.isAbsolute(i)?o=w.join(t,i):i?o=i:e.options.mode==="recommended"&&(o=w.join(t,"noti_1.wav")),!o||!await S.pathExists(o)){e.logger.warn("No notification sound selected or file missing; skipping sound setup");return}let r=w.isAbsolute(o),s=o.startsWith(w.join(e.rootDir,"sounds")),a=!r||s?w.join(n,w.basename(o)):o;(!r||s)&&(e.options.dryRun?e.logger.log(`[dry-run] cp ${o} ${a}`):await S.copy(o,a));let d=await _e(e),m=`# Notification sound
|
|
27
32
|
export CODEX_DISABLE_SOUND=0
|
|
28
33
|
export CODEX_CUSTOM_SOUND="${a}"
|
|
29
|
-
`;e.options.dryRun?e.logger.log(`[dry-run] update ${
|
|
34
|
+
`;e.options.dryRun?e.logger.log(`[dry-run] update ${d}`):await je(d,m,e),e.logger.ok("Notification sound configured. Open a new shell or source your rc to apply.");let b=w.join(e.homeDir,".codex","notify.sh");if(await S.pathExists(b)){let h=await S.readFile(b,"utf8"),v=`DEFAULT_CODEX_SOUND="${a}"`,p=h.replace(/^DEFAULT_CODEX_SOUND=.*$/m,v);p!==h&&(e.options.dryRun?e.logger.log(`[dry-run] patch ${b} DEFAULT_CODEX_SOUND -> ${a}`):await S.writeFile(b,p,"utf8"))}}async function _e(e){let t=e.options.shell||process.env.SHELL||"",n="auto";switch(n==="auto"&&(t.includes("zsh")?n="zsh":t.includes("fish")?n="fish":n="bash"),n){case"zsh":return w.join(e.homeDir,".zshrc");case"fish":return w.join(e.homeDir,".config","fish","config.fish");default:return w.join(e.homeDir,".bashrc")}}async function je(e,t,n){let i="codex-1up";await S.ensureDir(w.dirname(e));let o="";if(await S.pathExists(e)){o=await S.readFile(e,"utf8");let s=`>>> ${i} >>>`,a=`<<< ${i} <<<`,d=new RegExp(`${s}[\\s\\S]*?${a}\\n?`,"g");o=o.replace(d,"")}let r=`>>> ${i} >>>
|
|
30
35
|
${t}<<< ${i} <<<
|
|
31
|
-
`;await S.writeFile(e,
|
|
36
|
+
`;await S.writeFile(e,o+r,"utf8")}import R from"fs-extra";import*as j from"path";async function Le(e){let t=j.join(e.homeDir,".codex","AGENTS.md"),n=e.options.globalAgents;if(n==="skip"){e.logger.info("Skipping global AGENTS.md creation");return}let i=j.join(e.rootDir,"templates","agent-templates","AGENTS-default.md");if(!await R.pathExists(i)){e.logger.warn(`Template not found at ${i}`);return}switch(n){case"create-default":if(await R.pathExists(t)){e.logger.info("Global AGENTS.md already exists; leaving unchanged");return}await R.ensureDir(j.dirname(t)),e.options.dryRun?e.logger.log(`[dry-run] cp ${i} ${t}`):await R.copy(i,t),e.logger.ok(`Wrote ${t}`);break;case"overwrite-default":if(await R.ensureDir(j.dirname(t)),await R.pathExists(t)){let r=T(t);e.options.dryRun?e.logger.log(`[dry-run] cp ${t} ${r}`):await R.copy(t,r),e.logger.info(`Backed up existing AGENTS.md to: ${r}`)}e.options.dryRun?e.logger.log(`[dry-run] cp ${i} ${t}`):await R.copy(i,t),e.logger.ok(`Wrote ${t}`);break;case"append-default":if(await R.ensureDir(j.dirname(t)),await R.pathExists(t)){let r=T(t);e.options.dryRun?e.logger.log(`[dry-run] cp ${t} ${r}`):await R.copy(t,r),e.logger.info(`Backed up existing AGENTS.md to: ${r}`)}let o=await R.readFile(i,"utf8");e.options.dryRun?e.logger.log(`[dry-run] append template to ${t}`):await R.appendFile(t,`
|
|
32
37
|
---
|
|
33
38
|
|
|
34
|
-
${
|
|
39
|
+
${o}`,"utf8"),e.logger.ok(`Appended template to ${t}`);break;default:e.options.skipConfirmation&&e.logger.info("Skipping global AGENTS.md creation (non-interactive mode)");break}}async function Fe(e){if(e.options.noVscode)return;let t=e.options.vscodeId;if(!t){e.logger.info("VS Code extension id not provided. Use: --vscode <publisher.extension>");return}if(!await c("code")){e.logger.warn("'code' (VS Code) not in PATH; skipping extension install");return}if(e.options.dryRun){e.logger.log(`[dry-run] code --install-extension ${t}`);return}e.logger.info(`Installing VS Code extension: ${t}`),await g("code",["--install-extension",t,"--force"],{dryRun:!1,logger:e.logger}),e.logger.ok(`VS Code extension '${t}' installed (or already present)`)}import B from"fs-extra";import*as H from"path";async function Ge(e){let t=e.options.agentsMd;if(!t)return;let n=t;(await B.stat(n).catch(()=>null))?.isDirectory()&&(n=H.join(n,"AGENTS.md"));let i=H.join(e.rootDir,"templates","agent-templates","AGENTS-default.md");if(await B.pathExists(n)){e.logger.warn(`${n} already exists`);let o=T(n);e.options.dryRun?e.logger.log(`[dry-run] cp ${n} ${o}`):await B.copy(n,o),e.logger.info(`Backed up existing AGENTS.md to: ${o}`)}e.logger.info(`Writing starter AGENTS.md to: ${n}`),e.options.dryRun?e.logger.log(`[dry-run] write AGENTS.md to ${n}`):(await B.ensureDir(H.dirname(n)),await B.copy(i,n),e.logger.ok("Wrote AGENTS.md"))}var Me="codex-1up";async function he(e,t){let n=qe.homedir(),i=me.join(n,`.${Me}`);await Ct.ensureDir(i);let o=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5),r=me.join(i,`install-${o}.log`),s=Re(r);s.info(`==> ${Me} installer`),s.info(`Log: ${r}`);let a={cwd:process.cwd(),homeDir:n,rootDir:t,logDir:i,logFile:r,options:e,logger:s};try{await Ie(a),await Ne(a),await Te(a);let m=await c("codex")||a.options.installCodexCli==="yes";m||s.warn("Codex CLI not found and codex install was skipped; skipping config/notify setup until codex is installed."),m&&(await xe(a),await Ae(a),await Oe(a),await Le(a)),await Fe(a),await Ge(a),s.ok("All done. Open a new shell or 'source' your rc file to load aliases."),s.info("Next steps:"),s.info(" 1) codex # sign in; then ask it to plan a refactor"),s.info(" 2) ./bin/codex-1up agents --path $PWD # write a starter AGENTS.md to your repo"),s.info(" 3) Review ~/.codex/config.toml (see: https://github.com/openai/codex/blob/main/docs/config.md)")}catch(d){throw s.err(`Installation failed: ${d}`),d}}var We=Et(Rt(import.meta.url));function It(){let e=We;for(let t=0;t<6;t++){try{return Pt(D(e,"templates","codex-config.toml")),e}catch{}e=D(e,"..")}return D(We,"..")}var oe=It(),ze=St({meta:{name:"install",description:"Run the codex-1up installer with validated flags"},args:{yes:{type:"boolean",description:"Non-interactive; accept safe defaults"},"dry-run":{type:"boolean",description:"Print actions without making changes"},"skip-confirmation":{type:"boolean",description:"Skip prompts"},shell:{type:"string",description:"auto|zsh|bash|fish"},vscode:{type:"string",description:"Install VS Code extension id"},"no-vscode":{type:"boolean",description:"Skip VS Code extension checks"},"git-external-diff":{type:"boolean",description:"Set difftastic as git external diff"},"install-node":{type:"string",description:"nvm|brew|skip"},tools:{type:"string",description:"yes|no install/upgrade core CLI tools (rg, fd, fzf, jq, yq, difftastic)"},"codex-cli":{type:"string",description:"yes|no install/upgrade Codex CLI + ast-grep globally"},profile:{type:"string",description:"balanced|safe|minimal|yolo|skip (choose profile to write)"},"profile-mode":{type:"string",description:"add|overwrite (profile table merge strategy)"},sound:{type:"string",description:'Sound file, "none", or "skip" to leave unchanged'},"agents-md":{type:"string",description:"Write starter AGENTS.md to PATH (default PWD/AGENTS.md)",required:!1}},async run({args:e}){let t=D(J.homedir(),".codex","config.toml"),n=await we(t),i=D(J.homedir(),".codex","notify.sh"),o=await we(i),r=D(J.homedir(),".codex","AGENTS.md"),s=await we(r),a=n?await jt(t):void 0,d=process.stdout.isTTY&&!e["dry-run"]&&!e["skip-confirmation"]&&!e.yes,m=Tt(e.profile),b=Dt(e["profile-mode"]),h=xt(e.tools),v=At(e["codex-cli"]),p=process.platform==="darwin"||process.platform==="linux",f=typeof e.sound>"u"?void 0:String(e.sound).trim();if(f==="")throw new Error('Invalid --sound value (expected path, "none", or "skip")');let k=m||(be(a)?a:void 0)||"balanced",N=b||"add",x=!0,ae=h||(p?"yes":"no"),Ce=v||"yes",A,q,_;if(f&&(u=>{let I=u.trim().toLowerCase();if(I==="skip"){A="no",_=void 0;return}A="yes",_=I==="none"?"none":u})(f),d){if(l.intro("codex-1up \xB7 Install"),!v){let u=await l.confirm({message:"Install/update Codex CLI globally?",initialValue:!0});if(l.isCancel(u))return l.cancel("Install aborted");Ce=u?"yes":"no"}if(p&&!h){l.note("We can install/update developer tools (rg, fd, fzf, jq, yq, difftastic, ast-grep) using your package manager (macOS/Linux).");let u=await l.confirm({message:"Install/update these CLI tools?",initialValue:!0});if(l.isCancel(u))return l.cancel("Install aborted");ae=u?"yes":"no"}else!p&&!h&&(ae="no");if(!m){l.note(["Profiles:"," \u2022 Balanced: on-request approvals, workspace-write sandbox, web search on."," \u2022 Safe: on-failure approvals, workspace-write, web search off."," \u2022 Minimal: lean settings, minimal reasoning effort, web search off."," \u2022 YOLO: never approvals, danger-full-access, web search on, verbose."].join(`
|
|
40
|
+
`));let u=await l.select({message:"Choose a Codex profile to install",options:[{label:"Balanced (recommended)",value:"balanced",hint:"on-request approvals \xB7 workspace-write \xB7 web search on"},{label:"Safe",value:"safe",hint:"on-failure approvals \xB7 workspace-write \xB7 web search off"},{label:"Minimal",value:"minimal",hint:"lean defaults \xB7 minimal reasoning effort \xB7 web search off"},{label:"YOLO",value:"yolo",hint:"never approvals \xB7 danger-full-access \xB7 web search on"},{label:"Skip (no profile changes)",value:"skip"}],initialValue:_t(a)});if(l.isCancel(u))return l.cancel("Install aborted");k=u}if(k!=="skip"&&!b){let u=await l.select({message:`How should we write profiles.${k}?`,options:[{label:"Add / merge (preserve custom keys)",value:"add"},{label:"Overwrite codex profile (replace table)",value:"overwrite"}],initialValue:N});if(l.isCancel(u))return l.cancel("Install aborted");N=u}if(k==="skip")x=!1;else{let u=await l.confirm({message:`Wrote profiles.${k} to ~/.codex/config.toml (mode: ${N}). Set this as the default profile?`,initialValue:!0});if(l.isCancel(u))return l.cancel("Install aborted");x=!!u}if(!f){let le=function(E){return[{label:"Skip (leave current setup)",value:"skip"},{label:"None (disable sounds)",value:"none"},...I.map($=>({label:$,value:$})),{label:"Custom path\u2026",value:"custom"}]};var yn=le;let u=D(oe,"sounds"),I=[];try{I=(await X.readdir(u)).filter(E=>/\.(wav|mp3|ogg)$/i.test(E)).sort()}catch{}A="yes";let C=I.includes("noti_1.wav")?"noti_1.wav":I[0]||"none";async function pe(E){let $=await l.text({message:"Enter absolute path to a .wav file",placeholder:E||"/absolute/path/to/sound.wav",validate(O){if(!O)return"Path required";if(!O.startsWith("/"))return"Use an absolute path";if(!/(\.wav|\.mp3|\.ogg)$/i.test(O))return"Supported: .wav, .mp3, .ogg"}});if(l.isCancel($))return null;try{await X.access(String($))}catch{return l.log.warn("File not found. Try again."),await pe(String($))}return String($)}let W=await l.select({message:"Notification sound",options:le(C),initialValue:C});if(l.isCancel(W))return l.cancel("Install aborted");if(W==="skip")A="no",_=void 0;else if(W==="custom"){let E=await pe();if(E===null)return l.cancel("Install aborted");C=E}else C=W;if(W!=="skip"){for(;;){let E=await l.select({message:`Selected: ${C}. What next?`,options:[{label:"Preview \u25B6 (press p then Enter)",value:"preview"},{label:"Use this",value:"use"},{label:"Choose another\u2026",value:"change"}],initialValue:"use"});if(l.isCancel(E))return l.cancel("Install aborted");if(E==="use")break;if(E==="change"){let $=await l.select({message:"Notification sound",options:le(C),initialValue:C});if(l.isCancel($))return l.cancel("Install aborted");if($==="custom"){let O=await pe();if(O===null)return l.cancel("Install aborted");C=O}else if($==="skip"){A="no",_=void 0;break}else C=$;continue}try{let $=C==="none"?"none":C.startsWith("/")?C:D(oe,"sounds",C);await Nt($)}catch($){l.log.warn(String($))}}_===void 0&&(_=C)}}if(s){let u=await l.select({message:"Global ~/.codex/AGENTS.md",options:[{label:"Add to your existing AGENTS.md (Backup will be created)",value:"append-default"},{label:"Overwrite existing (Backup will be created)",value:"overwrite-default"},{label:"Skip \u2014 leave as-is",value:"skip"}],initialValue:"append-default"});if(l.isCancel(u))return l.cancel("Install aborted");q=u}else q="skip"}d||(k==="skip"&&(x=!1),typeof A>"u"&&(A=o?"no":"yes"),typeof q>"u"&&(q="skip"));let Se={profile:k,profileMode:N,setDefaultProfile:x,installCodexCli:Ce,installTools:ae,notify:A??(o?"no":"yes"),globalAgents:q??"skip",notificationSound:_,mode:"manual",installNode:e["install-node"]||"nvm",shell:String(e.shell||"auto"),vscodeId:e.vscode?String(e.vscode):void 0,noVscode:e["no-vscode"]||!1,agentsMd:typeof e["agents-md"]<"u"?String(e["agents-md"]||process.cwd()):void 0,dryRun:e["dry-run"]||!1,assumeYes:e.yes||!1,skipConfirmation:e["skip-confirmation"]||!1};if(d){let u=l.spinner();u.start("Installing prerequisites and writing config");try{await he(Se,oe),u.stop("Base install complete"),l.outro("Install finished")}catch(I){throw u.stop("Installation failed"),l.cancel(`Installation failed: ${I}`),I}await Ue();return}try{await he(Se,oe),await Ue()}catch(u){throw l.cancel(`Installation failed: ${u}`),u}}});async function Ue(){let e=J.homedir(),t=D(e,".codex","config.toml"),n,i=[];try{let d=await X.readFile(t,"utf8"),m=ye.parse(d);n=m.profile;let b=m.profiles||{};i=Object.keys(b)}catch{}let o=["codex","ast-grep","fd","rg","fzf","jq","yq","difft","difftastic"],s=(await Promise.all(o.map(async d=>{try{return await G(d),[d,!0]}catch{return[d,!1]}}))).filter(([,d])=>d).map(([d])=>d),a=[];a.push(""),a.push("codex-1up: Installation summary"),a.push("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),a.push(`Config: ${t}${n?` (active profile: ${n})`:""}`),i.length&&a.push(`Profiles: ${i.join(", ")}`),a.push(`Tools detected: ${s.join(", ")||"none"}`),a.push(""),a.push("Usage:"),a.push(" - Switch profile for a session: codex --profile <name>"),a.push(" - List available profiles: codex-1up config profiles"),a.push(" - Persist active profile: codex-1up config set-profile <name>"),a.push(" - Write AGENTS.md to a repo: codex-1up agents --path . --template default"),a.push(""),process.stdout.write(a.join(`
|
|
35
41
|
`)+`
|
|
36
|
-
`)}async function
|
|
37
|
-
`)}});import{defineCommand as
|
|
38
|
-
`);return i===-1?
|
|
39
|
-
`+e:e.slice(0,i+1)+
|
|
40
|
-
`+e.slice(i+1)}var
|
|
41
|
-
`);return}if(
|
|
42
|
-
`)}await
|
|
43
|
-
`)}}),profiles:
|
|
42
|
+
`)}async function Nt(e){if(e.endsWith("/none")||e==="none")return;let t=[async n=>{await G("afplay"),await K`afplay ${n}`},async n=>{await G("paplay"),await K`paplay ${n}`},async n=>{await G("aplay"),await K`aplay ${n}`},async n=>{await G("mpg123"),await K`mpg123 -q ${n}`},async n=>{await G("ffplay"),await K`ffplay -nodisp -autoexit -loglevel quiet ${n}`}];for(let n of t)try{await n(e);return}catch{}throw new Error("No audio player found (afplay/paplay/aplay/mpg123/ffplay)")}async function we(e){try{return await X.access(e),!0}catch{return!1}}function Tt(e){if(e==null)return;let t=String(e).toLowerCase();if(be(t))return t;if(t==="skip")return"skip";throw new Error("Invalid --profile value (use balanced|safe|minimal|yolo|skip).")}function Dt(e){if(e==null)return;let t=String(e).toLowerCase();if(t==="add"||t==="overwrite")return t;throw new Error("Invalid --profile-mode value (use add|overwrite).")}function xt(e){if(e==null)return;let t=String(e).toLowerCase();if(t==="yes"||t==="no")return t;throw new Error("Invalid --tools value (use yes|no).")}function At(e){if(e==null)return;let t=String(e).toLowerCase();if(t==="yes"||t==="no")return t;throw new Error("Expected yes|no")}function be(e){return e==="balanced"||e==="safe"||e==="minimal"||e==="yolo"}function _t(e){return be(e)?e:"balanced"}async function jt(e){try{let t=await X.readFile(e,"utf8"),i=ye.parse(t).profile;return typeof i=="string"?i:void 0}catch{return}}import{defineCommand as Ot}from"citty";import{promises as Y}from"fs";import{accessSync as Lt}from"fs";import{resolve as Q,dirname as Be}from"path";import{fileURLToPath as Ft}from"url";var Ve=Be(Ft(import.meta.url));function Gt(){let e=Ve;for(let t=0;t<6;t++){try{return Lt(Q(e,"templates","codex-config.toml")),e}catch{}e=Q(e,"..")}return Q(Ve,"..")}var Mt=Gt();async function ke(e){try{return await Y.access(e),!0}catch{return!1}}async function qt(e,t){if(await ke(t)){let i=`${t}.backup.${new Date().toISOString().replace(/[:.]/g,"").replace("T","_").slice(0,15)}`;await Y.copyFile(t,i)}await Y.mkdir(Be(t),{recursive:!0}),await Y.copyFile(e,t)}var He=Ot({meta:{name:"agents",description:"Write an AGENTS.md template"},args:{path:{type:"string",required:!0,description:"Target repo path or file"}},async run({args:e}){let t=String(e.path),n=Q(Mt,"templates/agent-templates","AGENTS-default.md"),o=await ke(t).then(async r=>r&&(await Y.stat(t)).isDirectory()).catch(()=>!1)?Q(t,"AGENTS.md"):t;if(!await ke(n))throw new Error(`Template not found: ${n}`);await qt(n,o),process.stdout.write(`Wrote ${o}
|
|
43
|
+
`)}});import{defineCommand as Wt}from"citty";import{$ as Ut}from"zx";import{fileURLToPath as zt}from"url";import{accessSync as Vt}from"fs";import{dirname as Bt,resolve as ie}from"path";var Ke=Bt(zt(import.meta.url));function Ht(){let e=Ke;for(let t=0;t<6;t++){try{return Vt(ie(e,"templates","codex-config.toml")),e}catch{}e=ie(e,"..")}return ie(Ke,"..")}var Kt=Ht(),Je=Wt({meta:{name:"doctor",description:"Run environment checks"},async run(){await Ut`bash ${ie(Kt,"scripts/doctor.sh")}`}});import{defineCommand as Jt}from"citty";import{$ as Xt}from"zx";import{fileURLToPath as Yt}from"url";import{accessSync as Qt}from"fs";import{dirname as Zt,resolve as re}from"path";var Xe=Zt(Yt(import.meta.url));function en(){let e=Xe;for(let t=0;t<6;t++){try{return Qt(re(e,"templates","codex-config.toml")),e}catch{}e=re(e,"..")}return re(Xe,"..")}var tn=en(),Ye=Jt({meta:{name:"uninstall",description:"Clean up aliases and config created by this tool"},async run(){await Xt`bash ${re(tn,"scripts/uninstall.sh")}`}});import{defineCommand as se}from"citty";import{promises as Z}from"fs";import{resolve as M,dirname as tt}from"path";import{fileURLToPath as nn}from"url";import{accessSync as on}from"fs";import rn from"os";var Qe=tt(nn(import.meta.url));function sn(){let e=Qe;for(let t=0;t<6;t++){try{return on(M(e,"templates","codex-config.toml")),e}catch{}e=M(e,"..")}return M(Qe,"..")}var an=sn();function $e(){let e=M(rn.homedir(),".codex"),t=M(e,"config.toml");return{CODEX_HOME:e,CFG:t}}async function ve(e){return Z.readFile(e,"utf8")}async function Ze(e,t){await Z.mkdir(tt(e),{recursive:!0}),await Z.writeFile(e,t,"utf8")}function et(e){let t=/^\[profiles\.(.+?)\]/gm,n=[],i;for(;i=t.exec(e);)n.push(i[1]);return n}function ln(e,t){let n=`profile = "${t}"`;if(/^profile\s*=\s*".*"/m.test(e))return e.replace(/^profile\s*=\s*".*"/m,n);let i=e.indexOf(`
|
|
44
|
+
`);return i===-1?n+`
|
|
45
|
+
`+e:e.slice(0,i+1)+n+`
|
|
46
|
+
`+e.slice(i+1)}var nt=se({meta:{name:"config",description:"Manage Codex config profiles"},subCommands:{init:se({meta:{name:"init",description:"Install unified config with multiple profiles"},args:{force:{type:"boolean",description:"Backup and overwrite if exists"}},async run({args:e}){let t=M(an,"templates/codex-config.toml"),n=await ve(t),{CFG:i}=$e(),o=await Z.access(i).then(()=>!0).catch(()=>!1);if(o&&!e.force){process.stdout.write(`${i} exists. Use --force to overwrite.
|
|
47
|
+
`);return}if(o){let r=`${i}.backup.${Date.now()}`;await Z.copyFile(i,r),process.stdout.write(`Backed up to ${r}
|
|
48
|
+
`)}await Ze(i,n),process.stdout.write(`Wrote ${i}
|
|
49
|
+
`)}}),profiles:se({meta:{name:"profiles",description:"List profiles in the current config"},async run(){let{CFG:e}=$e(),t=await ve(e),n=et(t);process.stdout.write(n.length?n.join(`
|
|
44
50
|
`)+`
|
|
45
51
|
`:`No profiles found
|
|
46
|
-
`)}}),"set-profile":
|
|
47
|
-
`)}})}});var
|
|
52
|
+
`)}}),"set-profile":se({meta:{name:"set-profile",description:"Set the active profile in config.toml"},args:{name:{type:"positional",required:!0,description:"Profile name"}},async run({args:e}){let{CFG:t}=$e(),n=await ve(t),i=et(n),o=String(e.name);if(!i.includes(o))throw new Error(`Unknown profile: ${o}`);let r=ln(n,o);await Ze(t,r),process.stdout.write(`profile set to ${o}
|
|
53
|
+
`)}})}});var gn=cn(dn(import.meta.url)),mn=JSON.parse(fn(un(gn,"../package.json"),"utf-8")),ot=pn({meta:{name:"codex-1up",version:mn.version,description:"Power up Codex CLI with clean profiles config and helpers"},subCommands:{install:ze,agents:He,doctor:Je,uninstall:Ye,config:nt}});hn(ot);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Adjust to your liking. See Codex CLI docs for full options.
|
|
3
3
|
|
|
4
4
|
# Core (root defaults)
|
|
5
|
-
model = "gpt-5.1-codex
|
|
5
|
+
model = "gpt-5.1-codex"
|
|
6
6
|
approval_policy = "on-request" # untrusted|on-failure|on-request|never
|
|
7
7
|
sandbox_mode = "workspace-write" # read-only|workspace-write|danger-full-access
|
|
8
8
|
profile = "balanced" # active profile: balanced|safe|minimal|yolo
|
|
@@ -40,7 +40,7 @@ enable_experimental_windows_sandbox = false
|
|
|
40
40
|
[profiles.balanced]
|
|
41
41
|
approval_policy = "on-request"
|
|
42
42
|
sandbox_mode = "workspace-write"
|
|
43
|
-
model = "gpt-5.1-codex
|
|
43
|
+
model = "gpt-5.1-codex"
|
|
44
44
|
model_reasoning_effort = "medium"
|
|
45
45
|
[profiles.balanced.features]
|
|
46
46
|
web_search_request = true
|
|
@@ -48,13 +48,13 @@ web_search_request = true
|
|
|
48
48
|
[profiles.safe]
|
|
49
49
|
approval_policy = "on-failure"
|
|
50
50
|
sandbox_mode = "workspace-write"
|
|
51
|
-
model = "gpt-5.1-codex
|
|
51
|
+
model = "gpt-5.1-codex"
|
|
52
52
|
model_reasoning_effort = "medium"
|
|
53
53
|
[profiles.safe.features]
|
|
54
54
|
web_search_request = false
|
|
55
55
|
|
|
56
56
|
[profiles.minimal]
|
|
57
|
-
model = "gpt-5.1-codex
|
|
57
|
+
model = "gpt-5.1-codex"
|
|
58
58
|
model_reasoning_effort = "medium"
|
|
59
59
|
[profiles.minimal.features]
|
|
60
60
|
web_search_request = false
|
|
@@ -62,7 +62,7 @@ web_search_request = false
|
|
|
62
62
|
[profiles.yolo]
|
|
63
63
|
approval_policy = "never"
|
|
64
64
|
sandbox_mode = "danger-full-access"
|
|
65
|
-
model = "gpt-5.1-codex
|
|
65
|
+
model = "gpt-5.1-codex"
|
|
66
66
|
model_reasoning_effort = "medium"
|
|
67
67
|
model_reasoning_summary = "detailed"
|
|
68
68
|
model_verbosity = "high"
|