@wular/coder 0.3.1 → 0.3.2
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/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{B as e,E as t,F as n,M as r,V as i,c as a,d as o,f as s,l as c,m as l,o as u,s as d,u as f}from"./app-server-Dwd7IcQH.js";import{$t as p,A as m,Bt as h,D as g,Ft as _,Gt as ee,Ht as v,It as y,Jt as b,Kt as x,Lt as te,M as S,Nt as ne,O as C,Ot as w,Qt as T,R as re,Rt as E,S as D,T as O,Ut as ie,Vt as ae,Xt as oe,Yt as k,Zt as A,_ as se,a as ce,b as le,d as ue,en as de,g as j,h as fe,j as pe,jt as me,kt as he,l as M,n as ge,nn as _e,p as ve,qt as N,r as ye,rn as be,s as xe,t as Se,tn as Ce,u as we,v as P,vt as Te,w as Ee,x as De,xt as Oe,y as ke,yt as Ae,zt as je}from"./runtime-DRtQOCSz.js";import{D as Me,E as Ne,S as Pe,a as Fe,h as Ie,p as F,r as Le,t as Re,v as ze,w as I,x as Be}from"./upgrade-
|
|
2
|
+
import{B as e,E as t,F as n,M as r,V as i,c as a,d as o,f as s,l as c,m as l,o as u,s as d,u as f}from"./app-server-Dwd7IcQH.js";import{$t as p,A as m,Bt as h,D as g,Ft as _,Gt as ee,Ht as v,It as y,Jt as b,Kt as x,Lt as te,M as S,Nt as ne,O as C,Ot as w,Qt as T,R as re,Rt as E,S as D,T as O,Ut as ie,Vt as ae,Xt as oe,Yt as k,Zt as A,_ as se,a as ce,b as le,d as ue,en as de,g as j,h as fe,j as pe,jt as me,kt as he,l as M,n as ge,nn as _e,p as ve,qt as N,r as ye,rn as be,s as xe,t as Se,tn as Ce,u as we,v as P,vt as Te,w as Ee,x as De,xt as Oe,y as ke,yt as Ae,zt as je}from"./runtime-DRtQOCSz.js";import{D as Me,E as Ne,S as Pe,a as Fe,h as Ie,p as F,r as Le,t as Re,v as ze,w as I,x as Be}from"./upgrade-BNwIk8zT.js";import L from"node:process";import R from"node:fs";import z from"node:path";import{spawn as Ve,spawnSync as He}from"node:child_process";import Ue from"node:os";import*as B from"zod/mini";const We=[[`--wait`,`run in the foreground and block until the answer is ready`],[`--agent <codex|claude|custom>`,`engine to use; custom runs your configured custom models (default: first in the chain)`],[`--model <alias|slug>`,`mini/luna/terra/sol (codex) · haiku/sonnet/opus/fable (claude) · a custom model (coder model list)`],[`--effort <low|medium|high>`,`reasoning effort`],[`--permissions <mode>`,`read-only · workspace-write · auto (default: auto)`],[`--resume <task-id>`,`continue that task's thread instead of a fresh run`],[`--json`,`machine-readable JSON output`]],V=[`--cwd <dir>`,`workspace directory (default: current)`],H=[`--json`,`JSON output`],Ge=[{sub:`run`,usage:`run "<text>"`,blurb:`run a task (background; --wait blocks)`,alias:`run`},{sub:`list`,usage:`list`,blurb:`list recent tasks (running + just stopped)`,alias:`list`},{sub:`result`,usage:`result [task-id]`,blurb:`status + final answer (--wait blocks)`,alias:`result`},{sub:`stream`,usage:`stream [task-id]`,blurb:`watch a task live (progress log)`,alias:`stream`},{sub:`steer`,usage:`steer <task-id> "<follow-up>"`,blurb:`continue a task's thread`},{sub:`stop`,usage:`stop <task-id>`,blurb:`interrupt a running task`},{sub:`archive`,usage:`archive <task-id>`,blurb:`archive a session (or --all-stopped)`},{sub:`delete`,usage:`delete <task-id>`,blurb:`delete a session (or --all-archived)`},{sub:`approvals`,usage:`approvals <task-id>`,blurb:`list escalated approvals`},{sub:`approve`,usage:`approve <task-id> <id>`,blurb:`answer an escalated permission`}],U={"task run":{list:[`task run "<text>"`,`run a coding task (background; --wait blocks)`],usage:`coder task run "<task text>"`,summary:`Dispatch a coding task to the configured engine. Backgrounds by default and
|
|
3
3
|
prints a task id; --wait runs in the foreground and prints the answer.
|
|
4
4
|
Shortcut: \`coder run "<text>"\`.`,flags:[[`--name <name>`,`label the task (shown in list/result)`],[`--system <text>`,`standing instructions prepended to the task (kept out of prompt previews)`],...We,V],examples:[[`coder run "add a /health endpoint"`,`dispatch in the background, print a task id`],[`coder run --wait "fix the failing test"`,`block until done, print the answer`],[`coder task run --model mini --system "tests live in test/, don't touch anything outside of it" "rename foo to bar"`,`pick an engine via its model alias; --system adds standing instructions`]],seeAlso:`task result · task steer · task stop · task stream`},"task list":{list:[`task list [--running|--stopped|--archived]`,`list recent tasks (running + just stopped)`],usage:`coder task list [--running] [--stopped] [--archived [--limit N]]`,summary:`List recent tasks across all workspaces, most recent first: running tasks plus
|
|
5
5
|
ones stopped within the last 10 minutes. Older stopped tasks auto-archive and
|
package/dist/sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,F as t,v as n,x as r}from"./app-server-Dwd7IcQH.js";import{E as i,I as a,M as o,R as s,xt as c,yt as l,z as u}from"./runtime-DRtQOCSz.js";import{C as d,T as f,_ as p,b as m,c as h,d as g,f as _,g as v,i as y,l as b,m as x,n as S,o as C,s as w,u as T,y as E}from"./upgrade-
|
|
1
|
+
import{C as e,F as t,v as n,x as r}from"./app-server-Dwd7IcQH.js";import{E as i,I as a,M as o,R as s,xt as c,yt as l,z as u}from"./runtime-DRtQOCSz.js";import{C as d,T as f,_ as p,b as m,c as h,d as g,f as _,g as v,i as y,l as b,m as x,n as S,o as C,s as w,u as T,y as E}from"./upgrade-BNwIk8zT.js";import D from"./flow/index.js";import O from"node:process";import k from"node:path";function A(e){return e?k.resolve(e):O.cwd()}function j(t,n){let r=e(t,n);if(!r)throw Error(n?`No task found for "${n}".`:`No tasks found for this workspace.`);return r}const M={async run(e,t={}){let{taskId:n}=await a({prompt:e,cwd:A(t.cwd),agent:t.agent,model:t.model,effort:t.effort,permissions:t.permissions,name:t.name,system:t.system,resume:t.resume});return{taskId:n}},async result(e,t={}){let n=A(t.cwd),r=e??j(n).id;return t.wait?u(n,r,{tail:t.tail}):s(n,r,{tail:t.tail})},list(e={}){return m(A(e.cwd),e).jobs},async steer(e,t,n={}){let r=A(n.cwd);return d(r,j(r,e),t)},async stop(e,t={}){let n=A(t.cwd);return i(n,j(n,e))},archive(e,t={}){let r=A(t.cwd);return n(r,j(r,e)),{taskId:e,archived:!0}},delete(e,t={}){let n=A(t.cwd),i=j(n,e);if(i.status===`running`)throw Error(`Task ${i.id} is still running.`);E(i);let a=r(n,i.id);return{taskId:i.id,deleted:a}},approve(e,n,r={}){let i=A(r.cwd),a=j(i,e),o=r.deny?`decline`:`accept`;return l(t(i,a.id),n,o),{taskId:a.id,approvalId:n,decision:o}},approvals(e,n={}){let r=A(n.cwd);return c(t(r,(e?j(r,e):j(r)).id))},stream(e,t={}){let n=A(t.cwd);return f(n,e??j(n).id,{tail:t.tail})}},N={add:(e,t)=>C(A(t.cwd),e,t),update:(e,t)=>_(A(t.cwd),e,t),remove:(e,t={})=>b(A(t.cwd),e,t),list:(e={})=>h(A(e.cwd)),alias:(e,t,n={})=>w(A(n.cwd),e,t,n),unalias:(e,t={})=>g(A(t.cwd),e,t),disable:(e,t={})=>T(A(t.cwd),e,!0,t),enable:(e,t={})=>T(A(t.cwd),e,!1,t)},P={get:(e,t={})=>v(A(t.cwd),e),set:(e,t,n={})=>p(A(n.cwd),e,t,n)};function F(e=[],t={}){return x(A(t.cwd),{claude:e.includes(`claude`),codex:e.includes(`codex`),agents:e.includes(`agents`)})}function I(e={}){return S(e)}function L(e){return y(e)}var R={task:M,flow:D,model:N,config:P,setupHost:F,upgrade:I,docs:L};export{o as CoderError,P as config,R as default,L as docs,D as flow,N as model,F as setupHost,M as task,I as upgrade};
|
|
@@ -10,7 +10,7 @@ ${e.prompt??``}`}function lt(e,t){let n=0;return()=>{Date.now()-n>=1e4&&(n=Date.
|
|
|
10
10
|
`);t.json||(G.stderr.write(`${H.dim(`[coder]`)} task ${H.cyan(e)} started (${n.status}); waiting for it to finish — Ctrl-C to detach (it keeps running).\n`),G.stderr.write(`${H.dim(s)}\n`));let c=()=>{G.stderr.write(`\n${H.dim(`[coder] detached — task still running: coder task result ${e}`)}\n`),G.exit(130)};G.on(`SIGINT`,c);let l;try{l=await Je(r,e)}catch(n){throw G.off(`SIGINT`,c),n instanceof ve&&n.code===`approval-pending`&&Pe(e,n.approval,t.json),n}G.off(`SIGINT`,c);let u=l.job,d=l.result,f=d?.error?.message??``;if(u.status===`failed`&&ge(u.permissions??`auto`,f)&>(f,t),u.status===`failed`&&ye.test(f)){let e=I(r).chain,n=e[e.indexOf(o.agent)+1];n||(P(se(o.agent,f,u.permissions??`auto`,t.system,i)),G.exit(3)),G.stderr.write(`[coder] ${o.agent} failed to start (${f}); falling back to ${n}.\n`);try{o=await fe({...a,agent:n,model:void 0,effort:void 0,name:void 0,resume:void 0,simulateApproval:void 0})}catch(e){ht(e,t)}continue}if(t.json)P({taskId:e,status:u.status,finalMessage:d?.finalMessage,...f?{error:f}:{},tokens:d?.tokens??null,model:d?.model??u.model??null});else{G.stdout.write(`\n${d?.finalMessage||(f?`${H.red(`error:`)} ${f}`:`(no final message)`)}\n\n`);let t=d?.tokens?` tokens=${Te(d.tokens,d.model??u.model)}`:``;G.stderr.write(`${H.dim(`[coder] task=${e} status=${u.status}${t}`)}\n`)}G.exit(u.status===`completed`?0:1)}let s=o.taskId,c=o.job,l=[` result: coder task result ${s}`,` steer: coder task steer ${s} "<follow-up>"`].join(`
|
|
11
11
|
`);if(t.json){P({taskId:s,status:c.status,startupCheck:o.startupCheck,commands:{result:`coder task result ${s}`,steer:`coder task steer ${s} "<follow-up>"`,stop:`coder task stop ${s}`,watch:`coder task stream ${s}`}});return}G.stdout.write(`${H.dim(`[coder]`)} task ${H.cyan(s)} started in the background (${c.status}).\n`),G.stdout.write(`${H.dim(l)}\n`)}async function vt(e){let{options:t,positionals:n}=b(e,J.object({cwd:w})),i=E(t),a=n[0],o=v(i,a);o||O(`Worker: task ${a} not found.`),T(i,a,{status:`running`,pid:G.pid});try{if(o.simulateApproval){let e=await Se(r(i,a),{onEvent:e=>f(i,a,e)});if(f(i,a,{message:`simulated approval: ${e}`}),e===`decline`){T(i,a,{status:`cancelled`,completedAt:new Date().toISOString(),error:`simulated approval denied`});return}}await pt(o)(i,o,{echo:!1}),await mt(i,a)}catch(e){let t=e instanceof Error?e.message:String(e);T(i,a,{status:`failed`,error:t}),f(i,a,{kind:`error`,message:t}),G.exit(1)}}async function*yt(e,t,n={}){let i=new Set([`completed`,`failed`,`cancelled`]),a=v(e,t);if(!a)throw Error(`No task found for "${t}".`);let o=n.tail??1,c=ie(q.join(r(e,t),`log.jsonl`)),l=!0,u=()=>{let e=c();return l&&(l=!1,o!==`all`&&(e=o===0?[]:e.slice(-o))),e.map(e=>{try{return JSON.parse(e)}catch{return{message:e}}})};for(yield*u();!i.has(a.status);)await new Promise(e=>setTimeout(e,400)),a=s(e,v(e,t)??a),yield*u();yield*u()}async function bt(e){let{options:t,positionals:n}=b(e,J.object({...S,tail:h,trim:J.optional(J.union([J.literal(`none`),J.coerce.number().check(J.int(),J.positive())],{error:`expected a positive integer or "none"`}))}));F(n,1,`task stream`);let i=E(t),a=j(i,n[0]),o=t.tail,c=t.trim,l=c===void 0?300:c===`none`?2**53-1:c;if(!t.json){G.stdout.write(`${H.dim(`[coder] task ${a.id} ${a.status} — streaming (Ctrl-C to stop)`)}\n`);let e=[`${H.dim(`agent`.padEnd(8))} ${Ye(a)}`,...ue(a,H)];G.stdout.write(`${e.join(`
|
|
12
12
|
`)}\n`),a.prompt&&G.stdout.write(`${Oe(a.prompt,H).join(`
|
|
13
|
-
`)}\n`)}for await(let e of yt(i,a.id,{tail:o}))if(t.json){let t=e.message?{...e,message:We(e.message,l,{plain:!0})}:e;G.stdout.write(`${JSON.stringify(t)}\n`)}else{let t=e.message??e.kind;t&&G.stdout.write(`${H.dim(`[coder]`)} ${We(t,l)}\n`)}let u=s(i,v(i,a.id)??a),d=qe(q.join(r(i,a.id),`result.json`));if(t.json)P({taskId:a.id,status:u.status,result:d});else{let e=u.status===`completed`?`(no final message)`:`(task ${u.status})`;G.stdout.write(`\n${_e(d,u.error,e)}\n`);let t=d?.tokens?` tokens=${Te(d.tokens,d.model??u.model)}`:``;G.stderr.write(`${H.dim(`[coder] task=${a.id} status=${u.status}${t}`)}\n`)}G.exit(u.status===`completed`?0:1)}async function xt(t,n,r){if(n.status!==`running`)return null;if(n.engine!==`claude`&&(await je(t,{threadId:n.threadId,text:r})).steered)return{taskId:n.id,steered:`live`};let i=v(t,n.id)??n;return e.includes(i.status)?(u(t,i.id,r),{taskId:i.id,steered:`queued`}):null}async function St(e,t,n,r={}){if(!t.threadId)throw Error(`Task ${t.id} has no thread to steer yet (status: ${t.status}).`);return await xt(e,t,n)||{taskId:(await fe({prompt:n,cwd:t.cwd??e,resume:t.id,agent:t.agent,model:r.model??t.model??void 0,effort:r.effort??t.effort??void 0,permissions:r.permissions??t.permissions??void 0})).taskId,steered:`resumed`}}async function Ct(e){let{options:t,positionals:n}=b(e,J.object({...S,model:w,effort:w,permissions:w,background:C,wait:C})),r=E(t),[i,...a]=n,o=a.join(` `).trim();(!i||!o)&&O(`Missing task id or follow-up text.`,{hint:[`Usage: coder task steer <task-id> "<follow-up>" [--wait]`,`Help: coder task steer --help`]});let s=j(r,i);s.threadId||O(`Task ${s.id} has no thread to steer yet (status: ${s.status}).`,{hint:`Wait for it to start: coder task stream ${s.id}`});let c=await xt(r,s,o);if(c)return wt(r,c.taskId,{queued:c.steered===`queued`,options:t});await _t([o,`--resume`,s.id,`--cwd`,s.cwd??r,...s.agent?[`--agent`,s.agent]:[],...t.model?[`--model`,t.model]:s.model?[`--model`,s.model]:[],...t.effort?[`--effort`,t.effort]:s.effort?[`--effort`,s.effort]:[],...t.permissions?[`--permissions`,t.permissions]:s.permissions?[`--permissions`,s.permissions]:[],...t.wait?[`--wait`]:[]])}async function wt(e,t,{queued:n,options:i}){if(n){if(i.json){P({taskId:t,steered:`queued`});return}G.stdout.write(`${H.dim(`[coder]`)} follow-up queued for task ${H.cyan(t)}; it runs when the current turn finishes.\n`),i.wait&&G.stdout.write(`\n${H.dim(`[coder] --wait is not available for a queued follow-up; check: coder task result ${t}`)}\n`);return}if(!i.wait){if(i.json){P({taskId:t,steered:`live`});return}G.stdout.write(`${H.dim(`[coder]`)} steered follow-up into running task ${H.cyan(t)}.\n`),G.stdout.write(`\n${H.dim(` result: coder task result ${t}`)}\n`);return}let a=v(e,t),o=a?await l(e,a):null,s=qe(q.join(r(e,t),`result.json`));i.json?P({taskId:t,status:o?.status??null,finalMessage:s?.finalMessage??null}):(G.stdout.write(`\n${s?.finalMessage||`(no final message)`}\n\n`),G.stderr.write(`${H.dim(`[coder] task=${t} status=${o?.status??`unknown`}`)}\n`)),G.exitCode=o?.status===`completed`?0:1}function Tt(n,r={}){let i=r.limit===`all`?void 0:r.limit,o=e=>d.includes(e.status),s=[],l=c(n).filter(e=>!o(e)||be(e.completedAt??e.updatedAt??e.createdAt)<=6e5?!0:(y(n,e),s.push(e.id),!1));if(ze(n,s),r.archived?l=t(n):r.running?l=l.filter(t=>e.includes(t.status)):r.stopped&&(l=l.filter(o)),r.dir){let e=a(q.resolve(String(r.dir)));l=l.filter(t=>t.cwd&&a(t.cwd)===e)}if(!r.archived&&!r.running&&!r.stopped){let t=t=>t.status===`failed`?0:e.includes(t.status)?1:t.status===`completed`?3:2;l=[...l].sort((e,n)=>t(e)-t(n))}let u=i===void 0?0:Math.max(0,l.length-i);return i!==void 0&&(l=l.slice(0,i)),{jobs:l,clipped:u}}async function Et(r){let{options:i,positionals:a}=b(r,J.object({cwd:w,dir:w,limit:m,json:C,running:C,stopped:C,archived:C}));F(a,0,`task list`);let o=E(i),s=i.limit===`all`?void 0:i.limit,{jobs:c,clipped:l}=Tt(o,{running:i.running,stopped:i.stopped,archived:i.archived,dir:i.dir??i.cwd,limit:i.limit}),u=c.map(t=>({taskId:t.id,status:t.status,agent:t.agent??null,model:t.model??null,name:t.name??null,cwd:t.cwd??null,prompt:String(t.prompt??``).replace(/\s+/g,` `).trim().slice(0,80),updatedAt:t.updatedAt,archived:t.archived??!1,flowRunId:t.flowRunId??null,idleMs:e.includes(t.status)?be(n(o,t)):null}));if(i.json){P(u);return}if(!u.length){let e=i.archived?`archived tasks`:i.running?`running tasks`:i.stopped?`recently stopped tasks`:`recent tasks`;G.stdout.write(`No ${e}.\n`);let n=[];if(!i.archived){let e=t(o,{migrate:!1}).length;e&&n.push(`${e} archived: coder task list --archived [--limit N]`)}n.length&&G.stdout.write(`\n${D(n,H)}\n`);return}let d=H,f=e=>{let t=e.archived?` ${d.dim(`(archived)`)}`:``,n=e.name?e.name:d.light(e.prompt),r=e.idleMs!==null&&e.idleMs>=12e4?` ${(e.idleMs>6e5?d.red:d.dim)(`· idle ${xe(e.idleMs)}`)}`:``,i=e.agent===`custom`&&e.model?e.model:(e.agent??`-`)+(e.model?`/${e.model}`:``);G.stdout.write(`${d.cyan(e.taskId.padEnd(24))} ${me(e.status,10)} ${d.light(ce(i,
|
|
13
|
+
`)}\n`)}for await(let e of yt(i,a.id,{tail:o}))if(t.json){let t=e.message?{...e,message:We(e.message,l,{plain:!0})}:e;G.stdout.write(`${JSON.stringify(t)}\n`)}else{let t=e.message??e.kind;t&&G.stdout.write(`${H.dim(`[coder]`)} ${We(t,l)}\n`)}let u=s(i,v(i,a.id)??a),d=qe(q.join(r(i,a.id),`result.json`));if(t.json)P({taskId:a.id,status:u.status,result:d});else{let e=u.status===`completed`?`(no final message)`:`(task ${u.status})`;G.stdout.write(`\n${_e(d,u.error,e)}\n`);let t=d?.tokens?` tokens=${Te(d.tokens,d.model??u.model)}`:``;G.stderr.write(`${H.dim(`[coder] task=${a.id} status=${u.status}${t}`)}\n`)}G.exit(u.status===`completed`?0:1)}async function xt(t,n,r){if(n.status!==`running`)return null;if(n.engine!==`claude`&&(await je(t,{threadId:n.threadId,text:r})).steered)return{taskId:n.id,steered:`live`};let i=v(t,n.id)??n;return e.includes(i.status)?(u(t,i.id,r),{taskId:i.id,steered:`queued`}):null}async function St(e,t,n,r={}){if(!t.threadId)throw Error(`Task ${t.id} has no thread to steer yet (status: ${t.status}).`);return await xt(e,t,n)||{taskId:(await fe({prompt:n,cwd:t.cwd??e,resume:t.id,agent:t.agent,model:r.model??t.model??void 0,effort:r.effort??t.effort??void 0,permissions:r.permissions??t.permissions??void 0})).taskId,steered:`resumed`}}async function Ct(e){let{options:t,positionals:n}=b(e,J.object({...S,model:w,effort:w,permissions:w,background:C,wait:C})),r=E(t),[i,...a]=n,o=a.join(` `).trim();(!i||!o)&&O(`Missing task id or follow-up text.`,{hint:[`Usage: coder task steer <task-id> "<follow-up>" [--wait]`,`Help: coder task steer --help`]});let s=j(r,i);s.threadId||O(`Task ${s.id} has no thread to steer yet (status: ${s.status}).`,{hint:`Wait for it to start: coder task stream ${s.id}`});let c=await xt(r,s,o);if(c)return wt(r,c.taskId,{queued:c.steered===`queued`,options:t});await _t([o,`--resume`,s.id,`--cwd`,s.cwd??r,...s.agent?[`--agent`,s.agent]:[],...t.model?[`--model`,t.model]:s.model?[`--model`,s.model]:[],...t.effort?[`--effort`,t.effort]:s.effort?[`--effort`,s.effort]:[],...t.permissions?[`--permissions`,t.permissions]:s.permissions?[`--permissions`,s.permissions]:[],...t.wait?[`--wait`]:[]])}async function wt(e,t,{queued:n,options:i}){if(n){if(i.json){P({taskId:t,steered:`queued`});return}G.stdout.write(`${H.dim(`[coder]`)} follow-up queued for task ${H.cyan(t)}; it runs when the current turn finishes.\n`),i.wait&&G.stdout.write(`\n${H.dim(`[coder] --wait is not available for a queued follow-up; check: coder task result ${t}`)}\n`);return}if(!i.wait){if(i.json){P({taskId:t,steered:`live`});return}G.stdout.write(`${H.dim(`[coder]`)} steered follow-up into running task ${H.cyan(t)}.\n`),G.stdout.write(`\n${H.dim(` result: coder task result ${t}`)}\n`);return}let a=v(e,t),o=a?await l(e,a):null,s=qe(q.join(r(e,t),`result.json`));i.json?P({taskId:t,status:o?.status??null,finalMessage:s?.finalMessage??null}):(G.stdout.write(`\n${s?.finalMessage||`(no final message)`}\n\n`),G.stderr.write(`${H.dim(`[coder] task=${t} status=${o?.status??`unknown`}`)}\n`)),G.exitCode=o?.status===`completed`?0:1}function Tt(n,r={}){let i=r.limit===`all`?void 0:r.limit,o=e=>d.includes(e.status),s=[],l=c(n).filter(e=>!o(e)||be(e.completedAt??e.updatedAt??e.createdAt)<=6e5?!0:(y(n,e),s.push(e.id),!1));if(ze(n,s),r.archived?l=t(n):r.running?l=l.filter(t=>e.includes(t.status)):r.stopped&&(l=l.filter(o)),r.dir){let e=a(q.resolve(String(r.dir)));l=l.filter(t=>t.cwd&&a(t.cwd)===e)}if(!r.archived&&!r.running&&!r.stopped){let t=t=>t.status===`failed`?0:e.includes(t.status)?1:t.status===`completed`?3:2;l=[...l].sort((e,n)=>t(e)-t(n))}let u=i===void 0?0:Math.max(0,l.length-i);return i!==void 0&&(l=l.slice(0,i)),{jobs:l,clipped:u}}async function Et(r){let{options:i,positionals:a}=b(r,J.object({cwd:w,dir:w,limit:m,json:C,running:C,stopped:C,archived:C}));F(a,0,`task list`);let o=E(i),s=i.limit===`all`?void 0:i.limit,{jobs:c,clipped:l}=Tt(o,{running:i.running,stopped:i.stopped,archived:i.archived,dir:i.dir??i.cwd,limit:i.limit}),u=c.map(t=>({taskId:t.id,status:t.status,agent:t.agent??null,model:t.model??null,effort:t.effort??null,name:t.name??null,cwd:t.cwd??null,prompt:String(t.prompt??``).replace(/\s+/g,` `).trim().slice(0,80),updatedAt:t.updatedAt,archived:t.archived??!1,flowRunId:t.flowRunId??null,idleMs:e.includes(t.status)?be(n(o,t)):null}));if(i.json){P(u);return}if(!u.length){let e=i.archived?`archived tasks`:i.running?`running tasks`:i.stopped?`recently stopped tasks`:`recent tasks`;G.stdout.write(`No ${e}.\n`);let n=[];if(!i.archived){let e=t(o,{migrate:!1}).length;e&&n.push(`${e} archived: coder task list --archived [--limit N]`)}n.length&&G.stdout.write(`\n${D(n,H)}\n`);return}let d=H,f=e=>{let t=e.archived?` ${d.dim(`(archived)`)}`:``,n=e.name?e.name:d.light(e.prompt),r=e.idleMs!==null&&e.idleMs>=12e4?` ${(e.idleMs>6e5?d.red:d.dim)(`· idle ${xe(e.idleMs)}`)}`:``,i=(e.agent===`custom`&&e.model?e.model:(e.agent??`-`)+(e.model?`/${e.model}`:``))+(e.effort?`/${e.effort}`:``);G.stdout.write(`${d.cyan(e.taskId.padEnd(24))} ${me(e.status,10)} ${d.light(ce(i,18))} ${d.light(ce(e.cwd?q.basename(e.cwd):`-`,12))} ${n}${r}${t}\n`)};G.stdout.write(d.bold(d.light(`${`task-id`.padEnd(24)} ${`status`.padEnd(10)} ${`agent`.padEnd(18)} ${`cwd`.padEnd(12)} name\n`)));let p=new Map;for(let e of u)e.flowRunId&&(p.get(e.flowRunId)??p.set(e.flowRunId,[]).get(e.flowRunId)).push(e);let h=new Set,g=!1,_=!1;for(let e of u){if(!e.flowRunId){_&&G.stdout.write(`
|
|
14
14
|
`),f(e),g=!0,_=!1;continue}if(h.has(e.flowRunId))continue;h.add(e.flowRunId);let t=Le(e.flowRunId),n=t?`(${d.bold(e.flowRunId)} ${t.status} — flow ${t.name})`:`(${d.bold(e.flowRunId)} flow)`;G.stdout.write(`${g?`
|
|
15
15
|
`:``}${n}\n`);for(let t of p.get(e.flowRunId))f(t);g=!0,_=!0}l&&G.stdout.write(d.dim(`\n... ${l} more not shown (--limit ${s})\n`));let v=[`Result: coder task result <task-id>`];i.archived||v.push(`Older tasks: coder task list --archived [--limit N]`),G.stdout.write(`\n${D(v,d)}\n`)}function Dt(){let e=process.env.CLAUDE_CONFIG_DIR||q.join(Ze.homedir(),`.claude`);return q.join(e,`projects`)}function Ot(e){if(!e)return!1;let t=Dt(),n=!1;try{for(let r of K.readdirSync(t)){let i=q.join(t,r,`${e}.jsonl`);K.existsSync(i)&&(K.rmSync(i,{force:!0}),n=!0)}}catch{}return n}function Y(e){e.threadId&&(e.engine===`codex`?i(e.threadId):e.engine===`claude`&&Ot(e.threadId))}async function kt(e){let{options:n,positionals:r}=b(e,J.object({...S,"all-archived":C}));F(r,1,`task delete`);let i=E(n);if(n[`all-archived`]){let e=t(i).filter(e=>(Y(e),te(i,e.id))).map(e=>e.id);if(n.json){P({deleted:e,count:e.length});return}G.stdout.write(e.length?`Deleted ${e.length} archived task${e.length===1?``:`s`}.\n`:`${H.dim(`No archived tasks to delete.`)}\n`);return}let a=r[0];a||O(`Missing task id.`,{hint:[`Delete one: coder task delete <task-id>`,`Delete all archived: coder task delete --all-archived`]});let o=j(i,a);if(o.status===`running`&&O(`Task ${o.id} is still running.`,{hint:`Stop it first: coder task stop ${o.id}`}),Y(o),te(i,o.id),n.json){P({taskId:o.id,deleted:!0});return}G.stdout.write(`Deleted task ${H.cyan(o.id)}.\n`)}function X(e,t){return t.split(`.`).reduce((e,t)=>e?.[t],e)}function At(e,t){return t?q.join(a(e),`coder.config.json`):L()}function jt(e,t){let n=I(e);return t?X(n,t):n}function Mt(e,t,n,r={}){let i=At(e,r.workspace),a=K.existsSync(i)?JSON.parse(K.readFileSync(i,`utf8`)):{},o=t.split(`.`),s=o.at(-1),c=a;for(let e of o.slice(0,-1))(typeof c[e]!=`object`||c[e]===null)&&(c[e]={}),c=c[e];r.unset?delete c[s]:c[s]=n;let l=Ie(a);if(l.length)throw Error(`Refusing to write invalid config:\n ${l.join(`
|
|
16
16
|
`)}`);return K.mkdirSync(q.dirname(i),{recursive:!0}),K.writeFileSync(i,`${JSON.stringify(a,null,2)}\n`,`utf8`),{file:i,key:t,effective:X(I(e),t)??null,...r.unset?{unset:!0}:{value:n}}}async function Nt(e){let{options:t,positionals:n}=b(e,J.object({...S,workspace:C})),r=E(t),[i=`list`,a,...o]=n,s=At(r,t.workspace);if(i===`list`){let e=I(r);if(t.json){P(e);return}let n=H,i=e=>[e?.model,e?.effort,e?.permissions].filter(Boolean).join(`/`)||`-`;G.stdout.write([`${n.dim(`chain`)} ${e.chain.join(` -> `)}`,`${n.dim(`codex`)} ${i(e.agents.codex)}`,`${n.dim(`claude`)} ${i(e.agents.claude)}`,`${n.dim(`approvals`)} timeout=${e.approvals.escalationTimeoutMs}ms hosts=[${e.approvals.allowedNetworkHosts.join(`, `)}]`,`${n.dim(`file`)} ${L()}`].join(`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coder",
|
|
3
3
|
"displayName": "Coder",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"description": "Delegate coding tasks to supervised Coder subagents running on Codex, Claude, or any OpenAI-compatible model. Your main context stays clean.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "muzam1l"
|