@coreframe/dev 0.1.43 → 0.1.45
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/dist/environment.js +1 -1
- package/dist/managed-dev-codex.js +5 -2
- package/package.json +4 -4
package/dist/environment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:process";import{access as t,appendFile as n,chmod as r,mkdir as i,readFile as a,rename as o,rm as s,stat as c,unlink as l,writeFile as u}from"node:fs/promises";import{readFileSync as d}from"node:fs";const f={access:t,appendFile:n,chmod:r,mkdir:i,readFile:a,readFileSync:d,rename:o,rm:s,stat:c,unlink:l,writeFile:u},p={cwd:e.cwd.bind(e),env:e.env,execPath:e.execPath,kill:e.kill.bind(e),once:e.once.bind(e),pid:e.pid,platform:e.platform};export{f as fs,p as process};
|
|
1
|
+
import e from"node:process";import{access as t,appendFile as n,chmod as r,mkdir as i,readFile as a,rename as o,rm as s,stat as c,unlink as l,writeFile as u}from"node:fs/promises";import{readFileSync as d}from"node:fs";import"node:os";const f={access:t,appendFile:n,chmod:r,mkdir:i,readFile:a,readFileSync:d,rename:o,rm:s,stat:c,unlink:l,writeFile:u},p={cwd:e.cwd.bind(e),env:e.env,execPath:e.execPath,kill:e.kill.bind(e),once:e.once.bind(e),pid:e.pid,platform:e.platform};export{f as fs,p as process};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import{managedDevCodexArgs as e,managedDevCodexAuthor as t,managedDevCodexHighArgs as n}from"./codex-model.js";import{reserveManagedProcess as r}from"./managed-dev-process.js";import{access as i}from"node:fs/promises";import{randomUUID as
|
|
2
|
-
`).trim(),
|
|
1
|
+
import{managedDevCodexArgs as e,managedDevCodexAuthor as t,managedDevCodexHighArgs as n}from"./codex-model.js";import{reserveManagedProcess as r}from"./managed-dev-process.js";import{access as i,mkdtemp as a,writeFile as o}from"node:fs/promises";import{pathToFileURL as s}from"node:url";import{randomUUID as c}from"node:crypto";import{constants as l}from"node:fs";import u from"node:path";import{stripVTControlCharacters as d}from"node:util";import f,{SubprocessError as p}from"nano-spawn";import{spawn as m}from"node:child_process";import{tmpdir as h}from"node:os";import{createInterface as g}from"node:readline";async function _(e,t,n){let r=[`--disable`,`plugins`,`--disable`,`apps`],i;try{let a=await f(`codex`,[`mcp`,`list`,`--json`,...r],{cwd:e,env:t,signal:n});i=JSON.parse(a.stdout)}catch{throw Error(`Could not inspect Codex integration settings. Retry after checking the installed Codex CLI.`)}if(!Array.isArray(i)||i.some(e=>typeof e?.name!=`string`))throw Error(`Codex returned an unsupported MCP configuration listing.`);let a=i.map(e=>{let t=e.transport?.type;if(t!==`stdio`&&t!==`streamable_http`)throw Error(`Codex returned an unsupported MCP transport.`);let n=t===`stdio`?`command="false"`:`url="http://127.0.0.1:1"`;return`${JSON.stringify(e.name)}={enabled=false,${n}}`});return r.push(`--config`,`mcp_servers={${a.join(`,`)}}`),r}async function v(n,i,a,o,s,l,u=`workspace-write`){if(w(l),process.platform===`win32`)throw Error(`Managed Codex requires process-tree isolation unavailable on Windows; ownership is retained until shutdown.`);let d=await _(n,i,l);w(l);let f=await r(n),p=m(`codex`,[`exec`,...e(o),`--ephemeral`,`--ignore-user-config`,...d,`--json`,`--sandbox`,u,`--cd`,n,a],{cwd:n,env:{...i,GIT_AUTHOR_EMAIL:i.GIT_AUTHOR_EMAIL??`codex@managed-dev.local`,GIT_AUTHOR_NAME:i.GIT_AUTHOR_NAME??`Codex`,GIT_COMMITTER_EMAIL:i.GIT_COMMITTER_EMAIL??`codex@managed-dev.local`,GIT_COMMITTER_NAME:i.GIT_COMMITTER_NAME??`Codex`},detached:!0,stdio:[`ignore`,`pipe`,`pipe`]}),h=[],v=[],S,D=new Promise((e,t)=>{p.once(`error`,t),p.once(`close`,(n,r)=>{n===0?e():(S=`Codex exited with ${r??n}.`,t(Error(S)))})});D.catch(()=>void 0),await f?.spawned(p.pid);let O,k,A=e=>{if(p.pid)try{process.kill(-p.pid,e)}catch(e){e.code!==`ESRCH`&&(k=Error(`Unresolved Codex process ownership: could not terminate process group; stop the owned processes before replacing this owner.`))}},j,M,N=new Promise((e,t)=>{M=t}),P=new Map,F=c(),I=e=>{let t=y(e,F,P);t&&(t.status===`running`?P.set(t.id,t):P.delete(t.id),s({phase:`activity`,activity:t}))},L=``,R=[],z=[],B=()=>{A(`SIGTERM`),O??=setTimeout(()=>A(`SIGKILL`),500),j??=setTimeout(()=>{k=Error(`Unresolved Codex process ownership: exit or streams did not settle after forced termination; ownership is retained.`),M(k)},3e3)};l?.addEventListener(`abort`,B),l?.aborted&&B(),p.stdout.on(`data`,e=>h.push(e)),p.stderr.on(`data`,e=>v.push(e));try{let e=(await Promise.race([N,Promise.allSettled([D,x(g({input:p.stdout}),e=>{I(e);let n=b(e,t(o)),r=JSON.parse(e),i=r?.type===`error`?r.message:r?.type===`turn.failed`?r.error?.message:void 0;typeof i==`string`&&i.trim()&&R.push(i),n&&(n.kind===`agent`&&(L=n.text),s({message:n,phase:`message`}))}),x(g({input:p.stderr}),e=>z.push(e))])])).find(e=>e.status===`rejected`);if(e?.status===`rejected`)throw e.reason;w(l)}catch(e){let t=S?await E(S,Buffer.concat(h),Buffer.concat(v)):void 0;s({phase:`error`}),w(l);let n=[...R,...z].join(`
|
|
2
|
+
`).trim(),r=!L&&P.size===0?`Codex stopped before producing a result. Retry the agent step. ${T(e)}`:T(e);throw Error([r,n,t].filter(Boolean).join(`
|
|
3
|
+
`))}finally{for(let e of P.values())e.status===`running`&&s({phase:`activity`,activity:{...e,status:l?.aborted?`cancelled`:`interrupted`,finishedAt:Date.now()}});if(clearTimeout(j),O&&(clearTimeout(O),A(`SIGKILL`),p.pid&&!k)){let e=Date.now()+2e3;for(;C(-p.pid)&&Date.now()<e;)await new Promise(e=>setTimeout(e,20));C(-p.pid)&&(k=Error(`Unresolved Codex process ownership: process group remains after forced termination; ownership is retained.`))}if(k)throw k;l?.removeEventListener(`abort`,B),await f?.release()}return L}function y(e,t,n){let r;try{r=JSON.parse(e)}catch{return}if(!r||typeof r!=`object`)return;let i=r;if(typeof i.type!=`string`||![`item.started`,`item.updated`,`item.completed`].includes(i.type)||!i.item||typeof i.item!=`object`)return;let a=i.item;if(typeof a.id!=`string`)return;let o=a.type===`command_execution`?a.command:a.type===`mcp_tool_call`&&typeof a.server==`string`&&typeof a.tool==`string`?`${a.server}.${a.tool}`:void 0;if(typeof o!=`string`||typeof a.status!=`string`)return;let s=`${t}:${a.id}`,c=n.get(s),l=i.type===`item.completed`,u=typeof a.exit_code==`number`?a.exit_code:void 0,f=l?a.status===`failed`||u!==void 0&&u!==0?`failed`:a.status===`completed`?`succeeded`:`interrupted`:`running`,p=o.match(/^(?:\S*\/)?(?:bash|zsh|sh)\s+-(?:lc|c|cl)\s+(['"])([\s\S]*)\1$/)?.[2]??o;return{id:s,label:a.type===`mcp_tool_call`?`Calling tool`:/^(?:pnpm|npm|yarn|bun) (?:install|ci|add)(?: |$)/.test(p)?`Installing dependencies`:/^(?:pnpm|npm|yarn|bun) (?:run )?test(?: |$)/.test(p)?`Running tests`:/^(?:pnpm|npm|yarn|bun) (?:run )?typecheck(?: |$)/.test(p)?`Checking types`:`Running command`,command:o.slice(0,2e3),source:`codex`,status:f,startedAt:c?.startedAt??Date.now(),finishedAt:l?Date.now():void 0,exitCode:u,output:typeof a.aggregated_output==`string`?d(a.aggregated_output).slice(-8e3):c?.output}}function b(e,t){let n;try{n=JSON.parse(e)}catch{throw Error(`Codex emitted invalid JSONL output.`)}if(!n||typeof n!=`object`)return;let r=n.item;if(n.type!==`item.completed`||!r||typeof r!=`object`)return;let{text:i,type:a}=r;if(!(typeof i!=`string`||!i.trim())){if(a===`reasoning`)return{kind:`thought`,text:i};if(a===`agent_message`)return{author:t,kind:`agent`,text:i}}}async function x(e,t){let n;for await(let r of e)if(!n)try{t(r)}catch(e){n={error:e}}if(n)throw n.error}async function S(e,t){let n=t.PATH??t.Path??t.path??``,r=process.platform===`win32`?(t.PATHEXT??`.COM;.EXE;.BAT;.CMD`).split(`;`):[``];for(let t of n.split(u.delimiter))for(let n of r)try{return await i(u.join(t||`.`,`${e}${n}`),l.X_OK),!0}catch{}return!1}function C(e){try{return process.kill(e,0),!0}catch(e){return!(e instanceof Error&&`code`in e&&e.code===`ESRCH`)}}function w(e){if(e?.aborted)throw Error(`The update integration was cancelled.`)}function T(e){return e instanceof Error?e.message:String(e)}async function E(e,t,n){try{let r=await a(u.join(h(),`coreframe-codex-`)),i=u.join(r,`stdio.log`);await o(i,Buffer.concat([Buffer.from(`${e}\n\n--- stdout ---\n`),Buffer.from(t),Buffer.from(`
|
|
4
|
+
--- stderr ---
|
|
5
|
+
`),Buffer.from(n)]),{mode:384});let c=`Full Codex stdio: ${s(i).href}`;return console.error(`${e} ${c}`),c}catch(t){let n=`Could not save Codex stdio: ${T(t)}`;return console.error(`${e} ${n}`),n}}async function D(e,t,r){let i=await _(e,t);return f(`codex`,[`exec`,...n,`--ephemeral`,`--ignore-user-config`,...i,`--sandbox`,`read-only`,`--cd`,e,`Return only a concise Conventional Commits message for the supplied working-tree changes. Use a body only when it adds material context.`],{cwd:e,env:t,stdin:{string:r}}).catch(async e=>{if(e instanceof p&&e.exitCode!==void 0&&e.exitCode!==0){let t=await E(`Codex exited with ${e.exitCode}.`,e.stdout,e.stderr);e.message+=`\n${t}`}throw e})}export{S as executableExists,v as executeCodex,D as requestCommitMessage};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coreframe/dev",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"description": "Development workflow utilities for Coreframe apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"import-meta-resolve": "^4.2.0",
|
|
38
38
|
"nano-spawn": "^2.1.0",
|
|
39
39
|
"oxc-parser": "^0.157.0",
|
|
40
|
-
"@coreframe/config": "^0.1.19",
|
|
41
|
-
"@coreframe/db": "^0.1.29",
|
|
42
40
|
"@coreframe/dev-contracts": "^0.1.15",
|
|
43
|
-
"@coreframe/dev-supervisor": "^0.1.
|
|
41
|
+
"@coreframe/dev-supervisor": "^0.1.26",
|
|
42
|
+
"@coreframe/db": "^0.1.30",
|
|
43
|
+
"@coreframe/config": "^0.1.19"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^26.1.0",
|