eser 4.1.55 → 4.1.56
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/chunks/{ajan-HYDPJF3Z.js → ajan-RZNLBRWL.js} +1 -1
- package/chunks/approve-CSNHLN74.js +2 -0
- package/chunks/{block-4ISSYCGQ.js → block-RYXM4VQQ.js} +1 -1
- package/chunks/{cancel-ZRTVX5AT.js → cancel-KVUNVJJ2.js} +1 -1
- package/chunks/chunk-E4WXXNF6.js +2 -0
- package/chunks/{chunk-MLC6JFJF.js → chunk-IHHITZU2.js} +1 -1
- package/chunks/chunk-P4SPHY3G.js +6 -0
- package/chunks/{chunk-IXO5V52Y.js → chunk-YTLTR452.js} +1 -1
- package/chunks/{delegate-EBL5HMGD.js → delegate-JVA57PQG.js} +1 -1
- package/chunks/{done-QSQ7AMLP.js → done-MQGWNNZO.js} +1 -1
- package/chunks/{followup-EMQ3ZNNS.js → followup-H2CVZVOP.js} +1 -1
- package/chunks/{init-OQ4CKFY7.js → init-4Q4HAHND.js} +1 -1
- package/chunks/invoke-hook-NMA2CDWK.js +14 -0
- package/chunks/manager-QK6D3SA2.js +7 -0
- package/chunks/{mod-FSAQBB7E.js → mod-EQ33JILZ.js} +1 -1
- package/chunks/mod-KPAF2K4Q.js +23 -0
- package/chunks/next-S6SRRGZ4.js +8 -0
- package/chunks/{reopen-KFHUPFTT.js → reopen-SJU63UEG.js} +1 -1
- package/chunks/{reset-F25OLGX7.js → reset-ELKH7QV3.js} +1 -1
- package/chunks/{review-ITFNV2TI.js → review-GYD3HGFK.js} +1 -1
- package/chunks/{run-7HOUSACQ.js → run-H3PSKRPV.js} +1 -1
- package/chunks/spec-QQW7427P.js +2 -0
- package/chunks/status-MZRTOMES.js +2 -0
- package/chunks/{sync-7FA2HPX7.js → sync-JYEN3MZS.js} +1 -1
- package/chunks/{system-I6RBRBRL.js → system-TEBXYSPT.js} +1 -1
- package/chunks/{watch-XTRRIRTM.js → watch-SAPVNSL6.js} +5 -5
- package/chunks/{wontfix-SLHYAWS7.js → wontfix-LL6NHECR.js} +1 -1
- package/eser.js +1 -1
- package/package.json +2 -1
- package/chunks/approve-7QQFUQ2C.js +0 -2
- package/chunks/chunk-BAVRVBBX.js +0 -2
- package/chunks/chunk-KI6473LF.js +0 -6
- package/chunks/invoke-hook-U3LDMMLY.js +0 -14
- package/chunks/manager-R2Q4FOHO.js +0 -7
- package/chunks/mod-ZCIGCCW4.js +0 -23
- package/chunks/next-ZR6B35KN.js +0 -8
- package/chunks/spec-XFXHNULK.js +0 -2
- package/chunks/status-KEARGELM.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{f as l,h as m,k as d}from"./chunk-SHN5MT56.js";import{b as r,f as i}from"./chunk-YVN2NZL4.js";import"./chunk-PWLF3WXM.js";import{b as n}from"./chunk-RNFCAHVL.js";import"./chunk-MG65QJY6.js";import{a,b as o}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var c=async w=>{let s=l({renderer:d.ansi(),sink:m.stdout()});try{let t=await(await import("./mod-
|
|
2
|
+
import{f as l,h as m,k as d}from"./chunk-SHN5MT56.js";import{b as r,f as i}from"./chunk-YVN2NZL4.js";import"./chunk-PWLF3WXM.js";import{b as n}from"./chunk-RNFCAHVL.js";import"./chunk-MG65QJY6.js";import{a,b as o}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var c=async w=>{let s=l({renderer:d.ansi(),sink:m.stdout()});try{let t=await(await import("./mod-KPAF2K4Q.js")).loadEserAjan();try{let p=t.symbols.EserAjanVersion();s.writeln(r(p))}finally{t.close()}}catch(e){return s.writeln(i("Error: "),r(`Failed to load ajan library: ${e instanceof Error?e.message:String(e)}`)),s.writeln(),s.writeln(r("To fix this, try one of:")),s.writeln(r(" Install via npm: npm install @eser/ajan")),s.writeln(r(" Or via Homebrew: brew install eser/tap/eser")),await s.close(),o({exitCode:1})}return await s.close(),a(void 0)},h=new n("ajan").description("Ajan native bridge commands").command(new n("version").description("Show ajan library version").run(c));export{h as ajanCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as x}from"./chunk-LEG3PWOU.js";import"./chunk-ODBJ5KMQ.js";import{a as k,d as L}from"./chunk-DI7OHJ53.js";import{h}from"./chunk-L32KHQVT.js";import{C as b,i as I,l as $,s as S}from"./chunk-E4WXXNF6.js";import{B as _,c as R,e as y,g as O,h as u,j as f,l as A,p as D}from"./chunk-LOZLXP5G.js";import{c}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{f as v,h as E,k as C}from"./chunk-SHN5MT56.js";import{c as o,d as p,f as n,g as m,k as w}from"./chunk-YVN2NZL4.js";import{a as g,b as i}from"./chunk-FFWPJP7A.js";import{i as P}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var K=async N=>{let e=v({renderer:C.ansi(),sink:E.stdout()}),{root:r}=await _(),l=O(N);if(!l.ok)return e.writeln(n(l.error)),await e.close(),i({exitCode:1});let s;try{s=await y(r,l.spec)}catch(a){let t=a instanceof Error?a.message:String(a);return e.writeln(n(t)),await e.close(),i({exitCode:1})}let T=await A(r);if(s.spec!==null){let a=`${r}/${R.specDir(s.spec)}`;try{await P.fs.stat(a)}catch{return e.writeln(n(`Active spec '${s.spec}' directory not found.`)),e.writeln(p("Run `noskills reset` to return to idle.")),await e.close(),i({exitCode:1})}}let d=b(s);if(d.length>0&&(s.phase==="SPEC_PROPOSAL"||s.phase==="DISCOVERY_REFINEMENT")){e.writeln(n(`Cannot approve \u2014 ${d.length} pending delegation(s):`)),e.writeln("");for(let a of d)e.writeln(` ${a.questionId}: delegated to `,o(a.delegatedTo),p(` (pending since ${a.delegatedAt.slice(0,10)})`));return e.writeln(""),e.writeln(p("All delegations must be answered before approval.")),await e.close(),i({exitCode:1})}if(s.phase==="SPEC_PROPOSAL"){if(s.classification===null&&s.spec!==null){let V=(await D(r)).filter(F=>T?.concerns.includes(F.id)??!1);try{await x(r,s,V)}catch{}}let a=await h(r),t=$(s);t=S(t,"SPEC_PROPOSAL","SPEC_APPROVED",a),await u(r,t),t.spec!==null&&await f(r,t.spec,t),t.spec!==null&&(await k(r,t.spec,"approved"),await L(r,t.spec,"approved")),e.writeln(m("\u2714")," Spec approved. Phase: ",w("SPEC_APPROVED")),e.writeln("When ready, run ",o(`${c('next --answer="start"')}`)," to begin execution.")}else if(s.phase==="DISCOVERY_REFINEMENT"){let a=await h(r),t=I(s);t=S(t,"DISCOVERY_REFINEMENT","SPEC_PROPOSAL",a),await u(r,t),t.spec!==null&&await f(r,t.spec,t),e.writeln(m("\u2714")," Discovery answers approved. Phase: ",w("SPEC_PROPOSAL")),e.writeln("Review the spec and run ",o(c("approve"))," again to approve.")}else s.phase==="DISCOVERY"&&s.discovery.completed?(e.writeln(p("Discovery complete. Spec draft already generated.")),e.writeln("Review the spec and run ",o(c("approve"))," again when in SPEC_PROPOSAL phase.")):e.writeln(n(`Cannot approve in phase: ${s.phase}`));return await e.close(),g(void 0)};export{K as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as $}from"./chunk-L32KHQVT.js";import{n as A,s as R}from"./chunk-
|
|
2
|
+
import{h as $}from"./chunk-L32KHQVT.js";import{n as A,s as R}from"./chunk-E4WXXNF6.js";import{B as x,c as y,e as k,g as C,h as S,j as v}from"./chunk-LOZLXP5G.js";import{c as E}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{f as w,h,k as g}from"./chunk-SHN5MT56.js";import{c as d,d as c,f as o,h as f}from"./chunk-YVN2NZL4.js";import{a as m,b as n}from"./chunk-FFWPJP7A.js";import{i as u}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var q=async p=>{let e=w({renderer:g.ansi(),sink:h.stdout()}),{root:i}=await x(),a=C(p);if(!a.ok)return e.writeln(o(a.error)),await e.close(),n({exitCode:1});let l=(p??[]).filter(s=>!s.startsWith("--spec=")).join(" ")||"No reason given",t;try{t=await k(i,a.spec)}catch(s){let D=s instanceof Error?s.message:String(s);return e.writeln(o(D)),await e.close(),n({exitCode:1})}if(t.spec!==null){let s=`${i}/${y.specDir(t.spec)}`;try{await u.fs.stat(s)}catch{return e.writeln(o(`Active spec '${t.spec}' directory not found.`)),e.writeln(c("Run `noskills reset` to return to idle.")),await e.close(),n({exitCode:1})}}if(t.phase!=="EXECUTING")return e.writeln(o(`Cannot block in phase: ${t.phase}`)),await e.close(),n({exitCode:1});let b=await $(i),r=A(t,l);return r=R(r,"EXECUTING","BLOCKED",b,l),await S(i,r),r.spec!==null&&await v(i,r.spec,r),e.writeln(f("\u26A0")," Spec blocked: ",c(l)),e.writeln("Resolve with: ",d(`${E('next --answer="resolution"')}`)),await e.close(),m(void 0)};export{q as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as P}from"./chunk-YWSOQJ7G.js";import{a as T,d as x}from"./chunk-DI7OHJ53.js";import{h as I}from"./chunk-L32KHQVT.js";import{D as k,p as v,s as D}from"./chunk-
|
|
2
|
+
import{a as P}from"./chunk-YWSOQJ7G.js";import{a as T,d as x}from"./chunk-DI7OHJ53.js";import{h as I}from"./chunk-L32KHQVT.js";import{D as k,p as v,s as D}from"./chunk-E4WXXNF6.js";import{B as C,c as h,e as S,g,h as E,j as y}from"./chunk-LOZLXP5G.js";import"./chunk-2XNFZXHY.js";import{f as u,h as f,k as w}from"./chunk-SHN5MT56.js";import{d as m,f as i,g as d}from"./chunk-YVN2NZL4.js";import{a as p,b as n}from"./chunk-FFWPJP7A.js";import{i as l}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var Z=async L=>{let t=u({renderer:w.ansi(),sink:f.stdout()}),{root:r}=await C(),o=g(L);if(!o.ok)return t.writeln(i(o.error)),await t.close(),n({exitCode:1});let e;try{e=await S(r,o.spec)}catch(a){let A=a instanceof Error?a.message:String(a);return t.writeln(i(A)),await t.close(),n({exitCode:1})}if(e.phase==="IDLE"||e.phase==="UNINITIALIZED"||e.phase==="COMPLETED")return t.writeln(i(`Cannot cancel in phase: ${e.phase}`)),await t.close(),n({exitCode:1});if(e.spec!==null){let a=`${r}/${h.specDir(e.spec)}`;try{await l.fs.stat(a)}catch{return t.writeln(i(`Active spec '${e.spec}' directory not found.`)),t.writeln(m("Run `noskills reset` to return to idle.")),await t.close(),n({exitCode:1})}}let c=await I(r),s=v(e,"cancelled");s=D(s,e.phase,"COMPLETED",c,"cancelled"),s.spec!==null&&await y(r,s.spec,s);let U=k(s);return await E(r,U),s.spec!==null&&(await T(r,s.spec,"cancelled"),await x(r,s.spec,"cancelled")),await P(r,{ts:new Date().toISOString(),type:"phase-change",spec:e.spec??"unknown",user:c.name,from:e.phase,to:"COMPLETED",reason:"cancelled"}),t.writeln(d("\u2714")," Spec cancelled."),await t.close(),p(void 0)};export{Z as main};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import{c}from"./chunk-LOZLXP5G.js";var l={UNINITIALIZED:["IDLE"],IDLE:["DISCOVERY","COMPLETED"],DISCOVERY:["DISCOVERY_REFINEMENT","COMPLETED"],DISCOVERY_REFINEMENT:["DISCOVERY_REFINEMENT","SPEC_PROPOSAL","COMPLETED"],SPEC_PROPOSAL:["SPEC_PROPOSAL","SPEC_APPROVED","COMPLETED"],SPEC_APPROVED:["EXECUTING","COMPLETED"],EXECUTING:["COMPLETED","BLOCKED"],BLOCKED:["EXECUTING","COMPLETED"],COMPLETED:["IDLE","DISCOVERY"]},h=(e,t)=>l[e].includes(t),a=(e,t)=>{if(!h(e,t))throw new Error(`Invalid phase transition: ${e} \u2192 ${t}. Allowed: ${l[e].join(", ")}`)},E=(e,t)=>(a(e.phase,t),{...e,phase:t}),g=(e,t,n,s)=>(a(e.phase,"DISCOVERY"),{...e,phase:"DISCOVERY",spec:t,specDescription:s??null,branch:n,discovery:{answers:[],completed:!1,currentQuestion:0,audience:"human",approved:!1,planPath:null},specState:{path:null,status:"none"},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},decisions:[]}),w=(e,t)=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot set discovery mode in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,mode:t}}},F=(e,t)=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot complete premises in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,premises:t,premisesCompleted:!0}}},C=(e,t)=>{if(e.phase!=="DISCOVERY_REFINEMENT")throw new Error(`Cannot select approach in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,selectedApproach:t,alternativesPresented:!0}}},v=e=>{if(e.phase!=="DISCOVERY_REFINEMENT")throw new Error(`Cannot skip alternatives in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,alternativesPresented:!0}}},y=(e,t,n,s)=>{if(e.phase!=="DISCOVERY"&&e.phase!=="DISCOVERY_REFINEMENT")throw new Error(`Cannot add discovery answer in phase: ${e.phase}`);if(n.trim().length<20)throw new Error("Answer too short. Discovery answers must be meaningful (minimum 20 characters).");let i=e.discovery.answers.filter(r=>r.questionId!==t),o={questionId:t,answer:n,user:s?.name??"Unknown User",email:s?.email??"",timestamp:new Date().toISOString(),type:"original"};return{...e,discovery:{...e.discovery,answers:[...i,o]}}};var f=e=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot complete discovery in phase: ${e.phase}`);let t=u(e);if(t.length>0)throw new Error(`Cannot complete discovery: ${t.length} pending follow-up(s). Answer or skip them first.`);return{...e,phase:"DISCOVERY_REFINEMENT",discovery:{...e.discovery,completed:!0},specState:{path:c.specFile(e.spec),status:"draft"}}},D=e=>(a(e.phase,"SPEC_PROPOSAL"),{...e,phase:"SPEC_PROPOSAL"}),x=e=>{if(e.phase!=="DISCOVERY_REFINEMENT")throw new Error(`Cannot approve discovery answers in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,approved:!0}}},I=e=>{if(e.phase!=="DISCOVERY")throw new Error(`Cannot advance discovery question in phase: ${e.phase}`);return{...e,discovery:{...e.discovery,currentQuestion:e.discovery.currentQuestion+1}}},O=e=>(a(e.phase,"SPEC_APPROVED"),{...e,phase:"SPEC_APPROVED",specState:{...e.specState,status:"approved"}}),P=e=>(a(e.phase,"EXECUTING"),{...e,phase:"EXECUTING",discovery:{...e.discovery,completed:!0,approved:!1},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]}});var R=(e,t)=>(a(e.phase,"BLOCKED"),{...e,phase:"BLOCKED",execution:{...e.execution,lastProgress:`BLOCKED: ${t}`}}),U=(e,t)=>({...e,decisions:[...e.decisions,t]}),T=(e,t,n)=>(a(e.phase,"COMPLETED"),{...e,phase:"COMPLETED",completionReason:t,completedAt:new Date().toISOString(),completionNote:n??null}),A=e=>{if(e.phase!=="COMPLETED")throw new Error(`Cannot reopen in phase: ${e.phase}`);return{...e,phase:"DISCOVERY",reopenedFrom:e.completionReason,completionReason:null,completedAt:null,completionNote:null,discovery:{...e.discovery,completed:!1,currentQuestion:0},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},classification:null}},N=(e,t)=>{if(e.phase!=="EXECUTING"&&e.phase!=="BLOCKED")throw new Error(`Cannot revisit in phase: ${e.phase}. Only EXECUTING or BLOCKED can revisit.`);let n={from:e.phase,reason:t,completedTasks:[...e.execution.completedTasks],timestamp:new Date().toISOString()};return{...e,phase:"DISCOVERY",discovery:{...e.discovery,completed:!1,currentQuestion:0,approved:!1},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},classification:null,revisitHistory:[...e.revisitHistory??[],n]}},L=(e,t,n,s,i)=>{let o={from:t,to:n,user:s?.name??"Unknown User",email:s?.email??"",timestamp:new Date().toISOString(),reason:i},r=e.transitionHistory??[];return{...e,transitionHistory:[...r,o]}},V=(e,t,n)=>{let s=e.customACs??[],o={id:`custom-ac-${s.length+1}`,text:t,user:n?.name??"Unknown User",email:n?.email??"",timestamp:new Date().toISOString(),addedInPhase:e.phase};return{...e,customACs:[...s,o]}},M=(e,t,n)=>{let s=e.specNotes??[],o={id:`note-${s.length+1}`,text:t,user:n?.name??"Unknown User",email:n?.email??"",timestamp:new Date().toISOString(),phase:e.phase};return{...e,specNotes:[...s,o]}},b=(e,t)=>({...e,discovery:{...e.discovery,userContext:t,userContextProcessed:!1}});var m=3,Y=(e,t,n,s)=>{let i=e.discovery.followUps??[],o=i.filter(d=>d.parentQuestionId===t).length;if(o>=m)return e;let p={id:`${t}${String.fromCharCode(97+o)}`,parentQuestionId:t,question:n,answer:null,status:"pending",createdBy:s,createdAt:new Date().toISOString()};return{...e,discovery:{...e.discovery,followUps:[...i,p]}}},_=(e,t,n)=>{let i=(e.discovery.followUps??[]).map(o=>o.id===t&&o.status==="pending"?{...o,answer:n,status:"answered",answeredAt:new Date().toISOString()}:o);return{...e,discovery:{...e.discovery,followUps:i}}},$=(e,t)=>{let s=(e.discovery.followUps??[]).map(i=>i.id===t&&i.status==="pending"?{...i,status:"skipped"}:i);return{...e,discovery:{...e.discovery,followUps:s}}},u=e=>(e.discovery.followUps??[]).filter(t=>t.status==="pending"),k=(e,t)=>(e.discovery.followUps??[]).filter(n=>n.parentQuestionId===t),X=(e,t,n,s)=>{let i=e.discovery.delegations??[],o={questionId:t,delegatedTo:n,delegatedBy:s,status:"pending",delegatedAt:new Date().toISOString()};return{...e,discovery:{...e.discovery,delegations:[...i,o]}}},G=(e,t,n,s)=>{let o=(e.discovery.delegations??[]).map(r=>r.questionId===t&&r.status==="pending"?{...r,status:"answered",answer:n,answeredBy:s,answeredAt:new Date().toISOString()}:r);return{...e,discovery:{...e.discovery,delegations:o}}},Q=e=>(e.discovery.delegations??[]).filter(t=>t.status==="pending"),B=e=>{if(!new Set(["IDLE","EXECUTING","BLOCKED","COMPLETED"]).has(e.phase))throw new Error(`Cannot reset from ${e.phase}. Use \`cancel\` or \`wontfix\` instead.`);return{...e,phase:"IDLE",spec:null,branch:null,discovery:{answers:[],completed:!1,currentQuestion:0,audience:"human",approved:!1,planPath:null},specState:{path:null,status:"none"},execution:{iteration:0,lastProgress:null,modifiedFiles:[],lastVerification:null,awaitingStatusReport:!1,debt:null,completedTasks:[],debtCounter:0,naItems:[]},decisions:[],classification:null,completionReason:null,completedAt:null,completionNote:null,reopenedFrom:null}};export{E as a,g as b,w as c,F as d,C as e,v as f,y as g,f as h,D as i,x as j,I as k,O as l,P as m,R as n,U as o,T as p,A as q,N as r,L as s,V as t,M as u,b as v,Y as w,_ as x,$ as y,k as z,X as A,G as B,Q as C,B as D};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
var r={name:"@eser/cli",version:"4.1.
|
|
2
|
+
var r={name:"@eser/cli",version:"4.1.56",type:"module",exports:"./main.ts",bin:{eser:"./bin.ts"},dependencies:{"@eser/ai":"workspace:*","@eser/codebase":"workspace:*","@eser/kit":"workspace:*","@eser/noskills":"workspace:*","@eser/laroux-server":"workspace:*","@eser/workflows":"workspace:*","@eser/functions":"workspace:*","@eser/logging":"workspace:*","@eser/shell":"workspace:*","@eser/standards":"workspace:*","@std/cli":"npm:@jsr/std__cli@^1.0.25","@std/fmt":"npm:@jsr/std__fmt@^1.0.8"},devDependencies:{"@std/assert":"npm:@jsr/std__assert@^1.0.16",esbuild:"^0.27.3"},optionalDependencies:{"@eserstack/ajan-darwin-arm64":"^4.1.47","@eserstack/ajan-darwin-x64":"^4.1.47","@eserstack/ajan-linux-arm64":"^4.1.47","@eserstack/ajan-linux-x64":"^4.1.47","@eserstack/ajan-win32-x64":"^4.1.47","@eserstack/ajan-wasm":"^4.1.47"}};export{r as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as _,c as J}from"./chunk-4KDDHQVL.js";import{a as Y,d as M,e as B,g as j,h as X,i as K,j as z}from"./chunk-PPB6ACBB.js";import{d as Z,e as ee}from"./chunk-KFVUFHJB.js";import{a as te}from"./chunk-NY4W44PI.js";import{c as ne}from"./chunk-UEMWZOIU.js";import{i as Q}from"./chunk-6DBKPC2O.js";var O=e=>ne(e),o=(e,t)=>O(t===null?e:`spec ${t} ${e}`),ae="NEVER run git write commands (commit, add, push, checkout, stash, reset, merge, rebase, cherry-pick). Git is read-only for agents. The user controls git. You may read: git log, git diff, git status, git show, git blame.",G={hasAskUserTool:!0,optionPresentation:"tool",hasSubAgentDelegation:!0,subAgentMethod:"task"},le=(e,t,n,s,r,l=G)=>{let m=e.execution.iteration>=t,u=l.hasAskUserTool?"Use AskUserQuestion for all decision points.":"Present options as a numbered list at every decision point.",p=[];n||p.push(ae),p.push("Report progress honestly. Not done = 'not done'. Partial = 'partial: [works]/[doesn't]'. Untested = 'untested'. 4 of 6 = '4 of 6 done, 2 remaining'.",`Never skip steps or infer decisions. ${u} Recommend first, then ask. One noskills call per interaction \u2014 never batch-submit or backfill.`,"Display `roadmap` before other content. Display `gate` prominently.","NEVER suggest bypassing, skipping, or 'breaking out of' noskills. Discovery helps the user \u2014 it is not an obstacle. If scope changes: revise spec, reset and create new, or split.","NEVER ask permission to run the next noskills command. After spec new \u2192 run next immediately. After answering questions \u2192 run next. After approve \u2192 run next. After task completion \u2192 run next. The workflow is sequential \u2014 each step has one next step. Just run it.","Listen first: after spec creation, ask 'Tell me about this \u2014 share as much context as you have.' Wait for their response before mode selection. Rich context (>200 chars) \u2192 pre-fill discovery answers as STATED/INFERRED. Brief response \u2192 proceed normally.",'Discovery questions are adaptive. After each answer, generate 1-3 follow-up questions if the answer reveals ambiguity, risk, dependencies, or missing detail. Submit follow-ups via `noskills spec <name> followup <questionId> "question"`. Max 3 per question. Do NOT rush through discovery.',"Confidence scoring: every technical finding needs a confidence score (1-10). 9-10: verified (read code, ran test). 7-8: strong evidence. 5-6: reasonable inference. 3-4: guess. 1-2: speculation. State basis ('read X', 'inferred from Y'). If confidence < 5, prefix with '\u26A0 Unverified:'.");let b=r?.outOfScope??[],x=e.spec;switch(e.phase){case"IDLE":{let d=l.optionPresentation==="tool"?"Pass interactiveOptions DIRECTLY to AskUserQuestion options array (header max 12 chars). Use commandMap to resolve selections. For availableConcerns: AskUserQuestion with multiSelect:true, max 4 per question \u2014 split across questions if needed. Present ALL concerns.":"Present interactiveOptions as numbered list. Use commandMap to resolve selections. Present ALL availableConcerns as numbered list for multiselect.";return{rules:["If the user described a feature/bug/task, create a spec immediately: `noskills spec new \"description\"` \u2014 name is auto-generated. Do NOT present menus or ask 'What would you like to do?' unless the conversation has no prior context.",...p,d,"Encourage full context: 'Tell me what you want to build \u2014 one-liner, detailed requirements, meeting notes, anything.' Slug is auto-generated. Pass full text to `noskills spec new \"...\"`.","After spec new, ask: full discovery, quick discovery, or skip to spec draft. Never skip without asking.","Every task gets a spec. No exceptions. A one-liner fix, a config change, a 'simple' refactor \u2014 all get specs. The spec can be short but it must exist. 'Too simple for a spec' is the anti-pattern."],tone:"Welcoming. Present choices, then wait."}}case"DISCOVERY":{let d=l.hasAskUserTool?"Ask each question via AskUserQuestion. One question per call.":"Ask one question at a time as text.";return{modeOverride:"plan mode. DO NOT create, edit, or write any files. DO NOT run state-modifying commands. MAY read files and run read-only commands (cat, ls, grep, git log, git diff).",rules:[...p,`${d} Never answer questions yourself. Never submit answers without user confirmation. Pre-fill suggested answers from detailed descriptions \u2014 user must confirm each. With a fully formed plan, skip questions but MUST run premise challenge and alternatives.`,"DO NOT create, edit, or write any files.","DO NOT run shell commands that modify state.","You MAY read files and run read-only commands (cat, ls, grep, git log, git diff).","Pre-discovery: (1) pre-discovery codebase scan \u2014 read README, CLAUDE.md, design docs, last 20 commits, TODOs, existing specs, directory structure. Present a brief audit summary. (2) If `preDiscoveryResearch.required`, web-search every `extractedTerms` entry \u2014 report versions, API changes, deprecations. (3) Ask discovery mode: A) Explore scope B) Technical depth C) Validate my plan D) Ship fast. Adapt emphasis accordingly.","Before starting discovery questions, challenge the user's initial spec description against codebase findings. Flag: hidden complexity, conflicts with existing code, scope mismatch, overlapping modules. Ask clarifying follow-ups.","When asking questions, offer concrete options from codebase knowledge alongside the open-ended question (e.g., 'I see three scenarios: A)... B)... C)... D) Something else'). Push back on vague answers. Follow up on short answer with 'Can you be more specific?'",(()=>{let i=z(s);return`${i.length>0?`After answers, ${i.join(" Also: ")}`:"After answers, synthesize CURRENT STATE \u2192 THIS SPEC \u2192 6-MONTH IDEAL vision."} Then: (1) expansion opportunities as numbered proposals with effort (S/M/L/XL), risk, completeness delta \u2014 options: Add/Defer/Skip. (2) Architectural decisions that BLOCK implementation \u2014 present with options, RECOMMENDATION, completeness scores. Unresolved = risk flag. (3) Error/rescue map: codepath | failure mode | handling. Flag CRITICAL GAPS as decisions.`})(),"Present DISCOVERY SUMMARY for confirmation: intent, scope, dream state, expansions, architectural decisions, error map. Ask for confirmation before generating spec. Submit all answers together in one `noskills next --answer` JSON call."],tone:"Curious interviewer with a stake in the answers. Comes PREPARED \u2014 read the codebase first. Challenge assumptions, think about architecture and failure modes."}}case"DISCOVERY_REFINEMENT":return{modeOverride:"You are in plan mode. Do not create, edit, or write any files. Present the discovery answers to the user for review and confirmation.",rules:[...p,"DO NOT create, edit, or write any files.","Present ALL discovery answers to the user clearly, one by one.",l.hasAskUserTool?"Use AskUserQuestion to ask: 'Are these answers correct, or would you like to revise any?'":"Ask the user: 'Are these answers correct, or would you like to revise any?' Present approval and revision as numbered options.","If the user approves, run the approve command.","If the user wants to revise, collect their corrections and submit them.","You MUST NOT approve on behalf of the user. The user must explicitly confirm.","If noskills output contains a splitProposal, present it to the user with the exact options shown. Do NOT split or merge specs on your own. Do NOT recommend one option over the other unless the user asks for your opinion. The user decides."],tone:"Careful reviewer. The user must confirm every answer."};case"SPEC_PROPOSAL":{let d=e.discovery.delegations??[],i=[];if(d.length>0){let c=d.filter(f=>f.status==="pending"),y=d.filter(f=>f.status==="answered"),k=d.map(f=>`- ${f.questionId}: delegated to ${f.delegatedTo} \u2014 ${f.status==="answered"?"ANSWERED \u2713":"PENDING"}`);i.push(`DELEGATION STATUS:
|
|
3
|
+
${k.join(`
|
|
4
|
+
`)}${c.length>0?`
|
|
5
|
+
Approve BLOCKED \u2014 ${c.length} pending delegation(s).`:`
|
|
6
|
+
All ${y.length} delegation(s) answered. Approve is allowed.`}`)}return{modeOverride:"plan mode. DO NOT create, edit, or write any files. DO NOT run state-modifying commands. MAY read files and run read-only commands.",rules:[...p,...i,"DO NOT create, edit, or write any files.","Read the spec and present a summary to the user.","Flag any tasks that are too vague to execute.","Flag any missing acceptance criteria.","No placeholders in specs. If a task has 'TBD', 'TODO', 'to be determined', 'details to follow', or 'implement appropriate X' \u2014 fill in the detail or remove the task and add it as an open question.","Ask the user if they want to refine before approving.",l.hasAskUserTool?"When presenting classification options, use AskUserQuestion with multiSelect:true. Do NOT infer classification yourself.":"When presenting classification options, present them as a numbered list with multiselect (user picks multiple numbers). Do NOT infer classification yourself.","When generating or refining tasks, include a 'Files:' hint listing likely files to create/modify. Format: 'Files: `path/to/file.ts`, `path/to/other.ts`'. Hints, not constraints \u2014 helps sub-agents load right context.","If you identify issues in the spec (vague tasks, irrelevant sections, missing acceptance criteria), submit a refinement via: `"+o(`next --answer='{"refinement":"task-1: Add upload endpoint, task-2: Add validation middleware, task-3: Write integration tests"}'`,x)+"`. The spec will be updated and you can review again."],tone:"Thoughtful reviewer preparing to hand off to an implementer."}}case"SPEC_APPROVED":return{rules:[...p,"The spec is approved but execution has not started.","Do not start coding until the user triggers execution.","If the user wants changes, they must reset and re-spec.",l.hasAskUserTool?"Before starting execution, show the spec summary to the user and ask for final confirmation via AskUserQuestion.":"Before starting execution, show the spec summary to the user and ask for final confirmation. Present 'Start execution' and 'Not yet' as numbered options."],tone:"Patient. Wait for the go signal."};case"EXECUTING":{let d=o(`next --answer='{"completed":[...],"remaining":[...],"blocked":[...]}'`,x),i,c,y="Verifier scope: (1) AC verification with evidence. (2) Plan alignment \u2014 does implementation match task description? Flag deviations. (3) Code quality \u2014 follows existing patterns? Flag style breaks, missing error handling. Categorize findings: CRITICAL (blocks completion), IMPORTANT (should fix), SUGGESTION (nice to have).";l.subAgentMethod==="task"?(i=`Spawn noskills-executor via Agent tool. Pass: task title, description, ACs, rules, scope constraints, concern reminders, file paths. Report via \`${d}\`.`,c=`After executor completes, spawn noskills-verifier with changed files + ACs + test commands. Never trust executor self-report alone. ${y}`):l.subAgentMethod==="spawn"?(i=`Use spawn_agent for noskills-executor. Pass: task, ACs, rules, scope, file paths. Use wait_agent to collect. Report via \`${d}\`.`,c=`After executor completes, spawn noskills-verifier with changed files + ACs + test commands. ${y}`):l.subAgentMethod==="fleet"?(i=`Use /fleet for parallel executors. Pass each: task, ACs, rules, scope, file paths. Report via \`${d}\`.`,c=`After fleet completes, run verification pass. ${y}`):l.subAgentMethod==="delegation"?(i=`Use Kiro agent delegation for noskills-executor. Pass: task, ACs, rules, scope, file paths. Report via \`${d}\`.`,c=`After executor completes, delegate to noskills-verifier with changed files + ACs + test commands. ${y}`):(i=`Execute tasks sequentially yourself. Verify (type-check + tests) after each. Report via \`${d}\`.`,c="");let k=l.subAgentMethod!=="none",f=k?`You are the orchestrator. NEVER edit files directly \u2014 delegate ALL edits to noskills-executor. ${i} On sub-agent failure, fall back to direct execution and note it in status.`:i,v=[...p,f,...c?[c]:[],"Do not explore beyond current task. Do not refactor outside scope. Do not add features, tests, or docs not in the spec. timebox context reads \u2014 the deliverable is working code.",...k?["Show a dispatch table: | Step | Agent | Files | Tasks | Est. |. Separate executor for implementation vs tests. Batch tightly-coupled files; parallelize independent modules."]:[],"Edit discipline: (1) Re-read file before editing. (2) Re-read after to confirm. (3) Files >500 LOC: read in chunks. (4) Run type-check + lint after edits \u2014 never mark AC passed if type-check fails. (5) If search returns few results, re-run narrower \u2014 assume truncation.",`On recurring patterns or corrections, ask: 'Permanent rule or just this task?' If permanent: \`${O('rule add "<description>"')}\`. Never write to \`.eser/rules/\` directly.`,"Before structural refactors on files >300 LOC, remove dead code first. Do NOT suggest pausing or stopping mid-spec \u2014 execute to completion. The user decides when to stop.","RATIONALIZATION ALERT: Never use 'should work now', 'looks correct', 'I'm confident', 'seems right', 'probably passes'. Run the command, read the output, report what happened. Evidence, not belief.","TDD: (1) Write test. (2) Run it \u2014 MUST fail. If it passes before implementation, the test is wrong. (3) Implement. (4) Run test \u2014 must pass. Skipping step 2 means the test is unverified.","Parallel vs serial sub-agents: PARALLEL when tasks touch different files with no shared state. SERIAL when tasks modify same files or depend on each other. When unsure, default to serial.",...k?["VERIFICATION REQUIRED: After EVERY task completion, you MUST spawn noskills-verifier before reporting done. If you skip verification and self-report, the status report will flag it. No exceptions \u2014 'it looks correct' is not verification."]:["VERIFICATION REQUIRED: After EVERY task completion, run type-check + tests before reporting done. Evidence of passing tests must be included in the status report."]];e.execution.lastVerification?.passed===!1&&v.push("Tests are failing. Fix ONLY the failing tests. Do not refactor passing code.");let S={rules:v,tone:"Direct. Orchestrate immediately \u2014 spawn sub-agents.",outOfScope:b.length>0?b:void 0};return m?{...S,urgency:`${e.execution.iteration}+ iterations \u2014 context degrading. Finish current task, recommend fresh session.`}:S}case"BLOCKED":return{rules:[...p,"Present the decision to the user exactly as described.","Do not suggest a preferred option unless the user asks for your opinion.","After the user decides, relay the answer immediately. Do not elaborate."],tone:"Brief. The user is making a decision, not having a discussion."};case"COMPLETED":return{rules:[...p,"Report the completion summary. Do not start new work.","If the user wants to continue, they start a new spec."],tone:"Concise. Celebrate briefly, then stop."};default:return{rules:[...p,`Run \`${o("next",x)}\` to get your instructions.`,"Do not take action without noskills guidance."],tone:"Neutral. Waiting for direction."}}},ce=5*60*1e3,de=e=>{let n=e.hasSubAgentDelegation?"enforced":"behavioral";return n==="enforced"?{level:n,capabilities:["PreToolUse file edit gate","Git write guard","Stop iteration tracking","PostToolUse file logging","Sub-agent delegation"]}:{level:n,capabilities:["Behavioral rules only"],gaps:["File edits not blocked in non-execution phases","Git write commands not blocked","No iteration tracking","No file change logging","No sub-agent delegation available"]}},ue=(e,t,n=G)=>{let s=e.spec,r;switch(e.phase){case"IDLE":r=`No active spec. Start one with: \`${O('spec new --name=<slug> "description"')}\``;break;case"DISCOVERY":r=`Discovery in progress for "${e.spec}". ${e.discovery.answers.length} questions answered so far.`;break;case"DISCOVERY_REFINEMENT":r=`Discovery answers ready for review. ${e.discovery.answers.length} answers collected. Waiting for user confirmation.`;break;case"SPEC_PROPOSAL":r=`Spec draft ready for review at ${e.specState.path}. Waiting for approval.`;break;case"SPEC_APPROVED":r=`Spec "${e.spec}" is approved. Waiting to start execution.`;break;case"EXECUTING":r=e.execution.lastProgress!==null?`Executing "${e.spec}", iteration ${e.execution.iteration}. Last progress: ${e.execution.lastProgress}. Continue with the current task.`:`Executing "${e.spec}", iteration ${e.execution.iteration}. Start the first task.`;break;case"BLOCKED":r=`Execution blocked: ${e.execution.lastProgress}. Ask the user to resolve.`;break;case"COMPLETED":r=`Spec "${e.spec}" completed in ${e.execution.iteration} iterations.`;break;default:r=`Run \`${o("next",s)}\` to get started.`}let l=de(n);return{protocol:`Run \`${o('next --answer="..."',s)}\` to submit results and advance`,spec:e.spec,branch:e.branch,iteration:e.execution.iteration,lastProgress:e.execution.lastProgress,activeConcerns:t.map(m=>m.id),resumeHint:r,enforcement:l}},pe=e=>{let t=e.spec;if(e.lastCalledAt===null)return{what:"noskills orchestrates your work: IDLE \u2192 DISCOVERY \u2192 DISCOVERY_REFINEMENT \u2192 SPEC_PROPOSAL \u2192 SPEC_APPROVED \u2192 EXECUTING \u2192 DONE \u2192 IDLE",how:`Run \`${o("next",t)}\` for instructions. Submit results with \`${o('next --answer="..."',t)}\`. Never make architectural decisions without asking.`,currentPhase:e.phase};let n=new Date(e.lastCalledAt).getTime();if(Date.now()-n>ce)return{what:"noskills orchestrates your work: IDLE \u2192 DISCOVERY \u2192 DISCOVERY_REFINEMENT \u2192 SPEC_PROPOSAL \u2192 SPEC_APPROVED \u2192 EXECUTING \u2192 DONE \u2192 IDLE",how:`Run \`${o("next",t)}\` for instructions. Submit results with \`${o('next --answer="..."',t)}\`. Never make architectural decisions without asking.`,currentPhase:e.phase}},se=[{key:"IDLE",label:"IDLE"},{key:"DISCOVERY",label:"DISCOVERY"},{key:"DISCOVERY_REFINEMENT",label:"REFINEMENT"},{key:"SPEC_PROPOSAL",label:"PROPOSAL"},{key:"SPEC_APPROVED",label:"APPROVED"},{key:"EXECUTING",label:"EXECUTING"},{key:"COMPLETED",label:"COMPLETED"},{key:"IDLE_END",label:"IDLE"}],me=e=>e==="BLOCKED"?se.map(t=>t.key==="EXECUTING"?"[ EXECUTING (BLOCKED) ]":t.label).join(" \u2192 "):se.map(t=>t.key==="IDLE"&&e==="IDLE"?"[ IDLE ]":t.key===e?`[ ${t.label} ]`:t.label).join(" \u2192 "),he=(e,t)=>{switch(e.phase){case"DISCOVERY_REFINEMENT":return{message:`${e.discovery.answers.length}/6 answers collected.`,action:"Type APPROVE to generate spec, or REVISE to correct answers.",phase:"DISCOVERY_REFINEMENT"};case"SPEC_APPROVED":return{message:`Spec approved. ${t?.tasks?.length??0} tasks ready.`,action:"Type START to begin execution.",phase:"SPEC_APPROVED"};default:return}},Be=async(e,t,n,s,r,l,m,u,p,b,x)=>{let d=u??G,i=ue(e,t,d),c=s?.maxIterationsBeforeRestart??15,y=s?.allowGit??!1,k=le(e,c,y,t,r,d);if(e.phase==="EXECUTING"){let I=b??0,P=B(t).tier2.length,h=I+P;h>0&&(k={...k,tier2Summary:`${h} file-specific rules delivered via PreToolUse hook when editing matching files.`})}let f=pe(e),v;switch(e.phase){case"IDLE":v=re(t,Y,n.length,m);break;case"DISCOVERY":v=await Ee(e,t,n,p,x);break;case"DISCOVERY_REFINEMENT":v=Re(e,t);break;case"SPEC_PROPOSAL":v=De(e);break;case"SPEC_APPROVED":v=Ie(e);break;case"EXECUTING":v=Ce(e,t,n,c,r,l);break;case"BLOCKED":v=Oe(e);break;case"COMPLETED":v=await Se(e,x);break;default:v=re(t,Y,n.length,m)}let S=me(e.phase),L=he(e,r),E={...v,meta:i,behavioral:k,roadmap:S};L!==void 0&&(E={...E,gate:L}),f!==void 0&&(E={...E,protocolGuide:f});let g=ge(e,t,m);if(g.length>0){let I=g.map(({label:$,description:A})=>({label:$,description:A})),P={};for(let $ of g)P[$.label]=$.command;let h=d.optionPresentation==="tool"?"AskUserQuestion":"prose-numbered-list",R=d.optionPresentation==="tool"?"Use AskUserQuestion tool to present these options. Do NOT use prose.":"Present options as a numbered list. Ask user to pick a number.";E={...E,interactiveOptions:I,commandMap:P,toolHint:h,toolHintInstruction:R}}return E},ge=(e,t,n)=>{let s=e.spec;switch(e.phase){case"IDLE":{let r=[],m=(n?.existingSpecs??[]).filter(u=>u.phase!=="COMPLETED");t.length===0&&r.push({label:"Add concerns (Recommended)",description:"Shape how discovery and specs work by adding project concerns",command:O("concern add <id> [<id2> ...]")}),r.push({label:"Start a new spec",description:"Tell me what you want to build \u2014 a one-liner, detailed requirements, meeting notes, anything",command:O('spec new "description"')});for(let u of m.slice(0,2))r.push({label:`Continue: ${u.name} (${u.phase})`,description:u.detail??`Iteration ${u.iteration}`,command:o("next",u.name)});return t.length>0&&r.push({label:"Edit concerns",description:`Currently: ${t.map(u=>u.id).join(", ")}`,command:O("concern list")}),r.slice(0,4)}case"DISCOVERY_REFINEMENT":return e.discovery.approved?[{label:"Keep as one spec",description:"All work in a single spec",command:o('next --answer="keep"',s)},{label:"Split into separate specs",description:"Create one spec per independent area",command:o('next --answer="split"',s)}]:[{label:"Approve all answers",description:"Answers look correct \u2014 generate the spec",command:o('next --answer="approve"',s)},{label:"Revise answers",description:"Correct one or more discovery answers",command:o(`next --answer='{"revise":{...}}'`,s)}];case"SPEC_PROPOSAL":return[{label:"Approve spec",description:"Review looks good \u2014 approve and move to execution",command:o("approve",s)},{label:"Refine spec",description:"Submit refinements to improve tasks or sections",command:o(`next --answer='{"refinement":"..."}'`,s)},{label:"Save for later",description:"Keep the draft as-is. Others can review, add ACs, notes, or tasks. Come back anytime to approve.",command:o('next --answer="save"',s)},{label:"Start over",description:"Reset the spec and start fresh",command:o("reset",s)}];case"SPEC_APPROVED":return[{label:"Start execution",description:"Begin implementing the tasks",command:o('next --answer="start"',s)},{label:"Save for later",description:"Spec is approved but don't start execution yet. Others can still add ACs or notes.",command:o('next --answer="save"',s)}];case"EXECUTING":return[];case"BLOCKED":return[{label:"Resolve block",description:"Provide a resolution to unblock execution",command:o('next --answer="resolution"',s)},{label:"Reset spec",description:"Abandon this spec and start over",command:o("reset",s)}];case"COMPLETED":return[{label:"New spec",description:"Start a new feature spec",command:O('spec new --name=<slug> "description"')},{label:"Reopen spec",description:"Reopen this spec for revision",command:o("reopen",s)},{label:"Check status",description:"Review completed spec summary",command:O("status")}];default:return[]}},fe="noskills is a state-machine orchestrator that acts as a scrum master for both you and your agent \u2014 keeping work focused, decisions in your hands, and tokens efficient.",re=(e,t,n,s)=>({phase:"IDLE",instruction:'No active spec. If the user described what they want, run `noskills spec new "description"` immediately \u2014 name is auto-generated. Present ALL available concerns (split across multiple calls if needed).',welcome:fe,existingSpecs:s?.existingSpecs??[],availableConcerns:t.map(r=>({id:r.id,description:r.description})),activeConcerns:e.map(r=>r.id),activeRulesCount:s?.rulesCount??n,behavioralNote:"These options are fallbacks. If the user already described what they want, act on it directly without presenting these options.",hint:e.length===0?"No concerns active. Consider adding concerns first \u2014 they shape discovery questions and specs.":void 0}),ye=/\b(Node\.?js|Deno|Bun|Go|Rust|Python|Ruby|Java|Kotlin|Swift|PHP|React|Vue|Angular|Svelte|Next\.?js|Nuxt|Remix|Astro|SolidJS|Qwik|TypeScript|Webpack|Vite|esbuild|Rollup|Terraform|Docker|Kubernetes|PostgreSQL|MySQL|Redis|MongoDB|SQLite|Prisma|Drizzle|gRPC|GraphQL|tRPC)\s+v?(\d+(?:\.\d+)?(?:\.\d+)?\+?)\b/gi,ve=e=>{if(e===null||e.length===0)return[];let t=[],n,s=new RegExp(ye.source,"gi");for(;(n=s.exec(e))!==null;)t.push(`${n[1]} ${n[2]}`);return t},oe=e=>{let t=ve(e);if(t.length!==0)return{required:!0,instruction:"Before asking discovery questions, research the current state of all platforms, runtimes, libraries, and APIs mentioned in the spec description. Use web search and Context7 MCP if available. Report findings as a pre-discovery brief to the user. Do NOT assume your training data is current \u2014 versions change, APIs get added, features get deprecated.",extractedTerms:t}},we=50*1024,ie=async e=>{if(e!==null)try{let t=await Q.fs.readTextFile(e);return t.length>we?void 0:{provided:!0,content:t,instruction:"A plan document was provided. Read it carefully, extract relevant information for each discovery question, and present pre-filled answers for user review. Do NOT skip any question \u2014 present your extraction and let the user confirm, correct, or expand. IMPORTANT: When extracting answers from the plan, mark each extraction as [STATED] (directly written in the plan) or [INFERRED] (your interpretation). Present extractions individually for confirmation."}}catch{return}},be=e=>{let t=[],n=e.toLowerCase(),s=["websocket","graphql","grpc","redis","postgres","mongodb","kafka","rabbitmq","docker","kubernetes","lambda","s3"];for(let r of s)n.includes(r)&&t.push(`Answer mentions ${r} \u2014 consider: error handling, versioning, fallback strategy`);return(n.includes("should work")||n.includes("standard approach")||n.includes("probably")||n.includes("i think")||n.includes("not sure"))&&t.push("Answer is vague \u2014 ask for specifics"),(n.includes("and also")||n.includes("we might")||n.includes("could also")||n.includes("maybe we should"))&&t.push("Scope expansion signal \u2014 clarify if in scope or deferred"),(n.includes("tricky")||n.includes("complicated")||n.includes("risky")||n.includes("not sure about"))&&t.push("Risk signal \u2014 dig deeper into what makes it risky"),(n.includes("depends on")||n.includes("after")||n.includes("blocked by")||n.includes("waiting for"))&&t.push("Dependency detected \u2014 clarify what happens if dependency isn't ready"),(n.includes("real-time")||n.includes("scalab")||n.includes("performance")||n.includes("latency")||n.includes("concurrent"))&&t.push("Performance/scale mention \u2014 ask about limits, degradation, monitoring"),t},ke=e=>{switch(e){case"full":return["Ask each discovery question as written. Push for specific, concrete answers.","If the answer is vague, ask follow-up questions before accepting."];case"validate":return["The user has a plan. Your job is to challenge it, not explore it.","For each question, identify assumptions and ask: 'What would prove this wrong?'","If the description already answers a question, present your understanding and ask to confirm.","When pre-filling answers from a rich description, plan, or prior discussion, DISTINGUISH between what the user EXPLICITLY STATED and what you INFERRED. Format each pre-filled item as: '[STATED] GPU skinning in all 3 renderers \u2014 you said this during technical discussion' or '[INFERRED] tangent space is 10-star scope \u2014 I assumed this based on complexity'. The user confirms stated items and corrects inferred items.","Present pre-filled answers ONE ITEM AT A TIME for confirmation, not as a completed block. The user's job is to correct your inferences, not rubber-stamp your summary. If you pre-fill 5 items and 2 are wrong, the user must be able to catch them individually."];case"technical-depth":return["Focus on architecture, data flow, performance, and integration points.","Before each question, scan the codebase for related implementations.","Ask: 'How does this interact with [existing system]?' for each integration point."];case"ship-fast":return["Focus on minimum viable scope.","For each question, also ask: 'What can we defer to a follow-up?'","Push for the smallest version that delivers value."];case"explore":return["Think bigger. What's the 10x version?","For each question, ask about adjacent opportunities.","Suggest possibilities the user might not have considered."]}},xe=(e,t)=>{let n=new Map;for(let s of e){let r="user"in s?s.user:"Unknown User";t!==void 0&&r===t.name||n.set(r,(n.get(r)??0)+1)}return[...n.entries()].map(([s,r])=>({name:s,contributions:`${r} answer${r>1?"s":""}`}))},Ee=async(e,t,n,s,r)=>{let l=e.spec,m=_(t),u=e.discovery.answers.length,p=J(e.discovery.answers),b=e.discovery.audience==="agent",x=xe(e.discovery.answers,s),d=(e.specNotes??[]).filter(a=>!a.text.startsWith("[TASK] ")).map(a=>({text:a.text,user:a.user})),i={...s!==void 0?{currentUser:s}:{},...x.length>0?{previousContributors:x}:{},...d.length>0?{notes:d}:{}},c=e.discovery.userContext!==void 0&&e.discovery.userContext.length>0,y=e.specDescription!==null&&e.specDescription.length>0,k=e.discovery.planPath!==null,f=e.discovery.mode;if(f===void 0&&!c&&u===0&&!k&&y){let a={phase:"DISCOVERY",instruction:"The user just created this spec. Before starting discovery, ask them to share whatever context they have \u2014 requirements, notes, tasks, or just a brief description. Say: 'Tell me about this \u2014 share as much context as you have.' Listen first, then proceed.",questions:[],answeredCount:0,context:{rules:n,concernReminders:M(t)},transition:{onComplete:o('next --answer="<user context or just start>"',l)},...i};return s!==void 0?{...a,currentUser:s}:a}if(f===void 0&&y&&u===0&&!k){let w={phase:"DISCOVERY",instruction:"Before starting discovery, select the discovery mode that best fits this spec.",questions:[],answeredCount:0,context:{rules:n,concernReminders:M(t)},transition:{onComplete:o('next --answer="<mode>"',l)},modeSelection:{required:!0,instruction:"Select the discovery mode.",options:[{id:"full",label:"Full discovery",description:"Standard 6 questions with all concern extras. Default for new features."},{id:"validate",label:"Validate my plan",description:"I already know what I want \u2014 challenge my assumptions, find gaps."},{id:"technical-depth",label:"Technical depth",description:"Focus on architecture, data flow, performance, integration points."},{id:"ship-fast",label:"Ship fast",description:"Minimum viable scope. What can we defer? What's the MVP?"},{id:"explore",label:"Explore scope",description:"Think bigger. 10x version? Adjacent opportunities? What are we missing?"}]}};if(r!==void 0)try{let C=await Z(r,e.specDescription??"");C.length>0&&(w={...w,previousLearnings:ee(C)})}catch{}return s!==void 0?{...w,currentUser:s}:w}let v=e.discovery.premisesCompleted===!0;if(f!==void 0&&!v&&!p){let a={phase:"DISCOVERY",instruction:"Before asking discovery questions, challenge the premises of this spec.",questions:[],answeredCount:0,context:{rules:n,concernReminders:M(t)},transition:{onComplete:o(`next --answer='{"premises":[...]}'`,l)},premiseChallenge:{required:!0,instruction:"Read the spec description"+(e.discovery.planPath!==null?" and the plan document":"")+'. Identify 2-4 premises the spec assumes. Present each premise and ask the user to agree or disagree. Submit as JSON: {"premises":[{"text":"...","agreed":true/false,"revision":"..."}]}',prompts:["Is this the right problem to solve? Could a different framing yield a simpler solution?","What happens if we do nothing? Is this a real pain point or a hypothetical one?","What existing code already partially solves this? Can we build on it instead?"]}};return s!==void 0?{...a,currentUser:s}:a}let S=f!==void 0?ke(f):[],L=[...n,...S],E=e.specDescription??"",g=E.length>500,I=e.discovery.premises??[],P=I.filter(a=>a.agreed).map(a=>a.text),h=I.filter(a=>!a.agreed&&a.revision!==void 0).map(a=>({original:a.text,revision:a.revision}));if(p){let a=e.revisitHistory??[],w=a.length>0?a[a.length-1]:null,C={phase:"DISCOVERY",instruction:w!==null?"This spec was revisited from EXECUTING. All previous answers are preserved. Review and approve, or revise answers before regenerating the spec.":`All discovery questions answered. Run: \`${o("approve",l)}\``,questions:[],answeredCount:u,context:{rules:n,concernReminders:[]},transition:{onComplete:o("approve",l)},...i};if(w!=null){let q=w;return{...C,revisited:!0,revisitReason:q.reason,previousProgress:{completedTasks:[...q.completedTasks],totalTasks:q.completedTasks.length}}}return C}if(b){let a=e.discovery.currentQuestion,w=m[a];if(w===void 0)return{phase:"DISCOVERY",instruction:`All discovery questions answered. Run: \`${o("approve",l)}\``,questions:[],answeredCount:u,context:{rules:n,concernReminders:[]},transition:{onComplete:o("approve",l)},...i};let C={id:w.id,text:w.text,concerns:[...w.concerns],extras:w.extras.map(T=>T.text)},q={phase:"DISCOVERY",instruction:`Ask this question to the user using AskUserQuestion. Submit the answer with: \`${o('next --agent --answer="<answer>"',l)}\``,questions:[C],answeredCount:u,currentQuestion:a,totalQuestions:m.length,context:{rules:L,concernReminders:M(t)},transition:{onComplete:`${o('next --agent --answer="<answer>"',l)}`},...i},D=q;if((P.length>0||h.length>0)&&(D={...D,...P.length>0?{agreedPremises:P}:{},...h.length>0?{revisedPremises:h}:{}}),a===0){let T=oe(e.specDescription??null);T!==void 0&&(D={...D,preDiscoveryResearch:T});let V=await ie(e.discovery.planPath??null);V!==void 0&&(D={...D,planContext:V}),g&&V===void 0&&(D={...D,richDescription:{provided:!0,length:E.length,content:E,instruction:"The user provided a detailed description. For each question, extract relevant info and present as a pre-filled suggestion. IMPORTANT: When extracting answers from the description, mark each extraction as [STATED] (directly written by the user) or [INFERRED] (your interpretation). Present extractions individually for confirmation."}})}let W=(e.discovery.followUps??[]).filter(T=>T.status==="pending");W.length>0&&(D={...D,pendingFollowUps:W});let H=e.discovery.answers.length>0?e.discovery.answers[e.discovery.answers.length-1]:void 0;if(H!==void 0){let T=be(H.answer);T.length>0&&(D={...D,followUpHints:T})}return D!==q?D:q}let R=new Set(e.discovery.answers.map(a=>a.questionId)),$=m.filter(a=>!R.has(a.id)).map(a=>({id:a.id,text:a.text,concerns:[...a.concerns],extras:a.extras.map(w=>w.text)})),A=e.revisitHistory??[],N=A.length>0?A[A.length-1]:null,F=N!==null,U={phase:"DISCOVERY",instruction:F?"This spec was revisited from EXECUTING. Previous discovery answers are preserved \u2014 review and revise as needed, or approve to regenerate tasks.":"Conduct a thorough discovery conversation. FIRST: perform a pre-discovery codebase scan (README, CLAUDE.md, recent git log, TODOs, directory structure) and present a brief audit summary. THEN: challenge the user's spec description against your findings. THEN: ask the discovery questions one at a time, offering concrete options based on codebase knowledge. AFTER questions: present a dream state table (current \u2192 this spec \u2192 future), scored expansion proposals, architectural decisions, and an error/rescue map. FINALLY: present a complete discovery synthesis for user confirmation before submitting answers as a JSON object.",questions:$,answeredCount:u,context:{rules:L,concernReminders:M(t)},transition:{onComplete:`${o(`next --answer='{"status_quo":"...","ambition":"...",...}'`,l)}`},...i,...P.length>0?{agreedPremises:P}:{},...h.length>0?{revisedPremises:h}:{}};if(F&&N!==void 0)return{...U,revisited:!0,revisitReason:N.reason,previousProgress:{completedTasks:[...N.completedTasks],totalTasks:N.completedTasks.length}};if(u===0){let a=U,w=oe(e.specDescription??null);w!==void 0&&(a={...a,preDiscoveryResearch:w});let C=await ie(e.discovery.planPath??null);if(C!==void 0&&(a={...a,planContext:C}),g&&C===void 0&&(a={...a,richDescription:{provided:!0,length:E.length,content:E,instruction:"The user provided a detailed description. For each question, extract relevant info and present as a pre-filled suggestion."}}),a!==U)return a}return U},Re=(e,t)=>{let n=e.spec,s=_(t),r=e.discovery.answers.map(d=>{let i=s.find(c=>c.id===d.questionId);return{questionId:d.questionId,question:i?.text??d.questionId,answer:d.answer}}),l=te(e.discovery.answers);if(e.discovery.approved&&l.detected)return{phase:"DISCOVERY_REFINEMENT",instruction:"Discovery answers are approved. noskills detected multiple independent work areas in this spec. Present the split proposal to the user and let them decide whether to keep as one spec or split into separate specs.",answers:r,transition:{onApprove:o('next --answer="keep"',n),onRevise:o(`next --answer='{"revise":{"status_quo":"corrected answer"}}'`,n)},splitProposal:l};let m=e.discovery.alternativesPresented===!0;if(e.discovery.approved&&!m)return{phase:"DISCOVERY_REFINEMENT",subPhase:"alternatives",instruction:"Based on discovery answers, propose 2-3 distinct implementation approaches. Present each with name, summary, effort (S/M/L/XL), risk (Low/Med/High), pros, and cons. Ask the user to choose one, or skip.",answers:r,transition:{onApprove:o(`next --answer='{"approach":"A","name":"...","summary":"...","effort":"M","risk":"Low"}'`,n),onRevise:o('next --answer="skip"',n)},alternatives:{required:!0,instruction:"Generate 2-3 approaches from discovery answers and codebase. Present via AskUserQuestion.",format:{fields:["id","name","summary","effort","risk","pros","cons"]}}};let u=e.discovery.batchSubmitted===!0?" IMPORTANT: These answers were BATCH-SUBMITTED (not confirmed one-by-one). You MUST present EVERY answer individually and get explicit user confirmation for each. Do NOT auto-approve.":"",p=X(t),b=K(t),x;if(p.length>0){let d=p.map(c=>({id:c.id,label:c.label,prompt:c.prompt,evidenceRequired:c.evidenceRequired,isRegistry:b.includes(c.id),concernId:c.concernId})),i=d.some(c=>c.isRegistry);x={dimensions:d,instruction:"Before approving, review the plan against each dimension below. For dimensions marked evidenceRequired, cite specific files or code. Present findings to the user for each dimension via AskUserQuestion \u2014 one dimension at a time.",...i?{registryInstruction:"Registry dimensions (isRegistry=true) require a structured table with every row filled. These tables will be included in the generated spec."}:{}}}return{phase:"DISCOVERY_REFINEMENT",instruction:l.detected?`Present ALL discovery answers to the user for review. ALSO present the split proposal \u2014 noskills detected multiple independent areas.${u}`:`Present ALL discovery answers to the user for review. The user must confirm or correct each answer before the spec can be generated. Use AskUserQuestion to ask for confirmation.${u}`,answers:r,transition:{onApprove:o('next --answer="approve"',n),onRevise:o(`next --answer='{"revise":{"status_quo":"corrected answer"}}'`,n)},splitProposal:l.detected?l:void 0,reviewChecklist:x}},De=e=>{let t=e.spec;return e.classification===null?{phase:"SPEC_PROPOSAL",instruction:"Before generating the spec, classify what this spec involves. Ask the user to select all that apply.",specPath:e.specState.path??"",transition:{onApprove:`${o(`next --answer='{"involvesWebUI":false,"involvesCLI":false,"involvesPublicAPI":false,"involvesMigration":false,"involvesDataHandling":false}'`,t)}`},classificationRequired:!0,classificationPrompt:{options:[{id:"involvesWebUI",label:"Web/Mobile UI \u2014 layouts, responsive design, visual components"},{id:"involvesCLI",label:"CLI/Terminal UI \u2014 spinners, progress bars, interactive prompts"},{id:"involvesPublicAPI",label:"Public API changes"},{id:"involvesMigration",label:"Data migration or schema changes"},{id:"involvesDataHandling",label:"Data handling or privacy"}],instruction:"Select all that apply. Submit as JSON: `"+o(`next --answer='{"involvesWebUI":true,"involvesCLI":false,"involvesPublicAPI":false,...}'`,t)+"`. If none apply, answer with: `"+o('next --answer="none"',t)+"`"}}:{phase:"SPEC_PROPOSAL",instruction:"Spec draft is ready. Self-review before presenting to user.",specPath:e.specState.path??"",transition:{onApprove:o("approve",t)},selfReview:{required:!0,checks:["Placeholder scan: no TBD, TODO, vague requirements","Consistency: tasks match discovery, ACs match tasks","Scope: single spec, not multiple independent subsystems","Ambiguity: every AC has one interpretation"],instruction:"Review draft against these checks. Fix issues inline before presenting to user. Do not ask user to fix \u2014 fix it yourself."}}},Ie=e=>{let t=e.spec;return{phase:"SPEC_APPROVED",instruction:"Spec is approved and ready. When the user is ready to start, begin execution.",specPath:e.specState.path??"",transition:{onStart:`${o('next --answer="start"',t)}`}}},Pe=(e,t)=>{if(t===null)return!1;let n=e.toLowerCase();return n.includes("mobile")||n.includes("layout")||n.includes("interaction design")?t.involvesWebUI:n.includes("ui state")||n.includes("skeleton ui")?t.involvesWebUI||t.involvesCLI:n.includes("readme")||n.includes("documentation updated")||n.includes("reflected in")&&n.includes("docs")?!0:n.includes("api doc")||n.includes("public api")?t.involvesPublicAPI:n.includes("migration")||n.includes("backward compat")||n.includes("deprecat")?t.involvesMigration:n.includes("audit trail")||n.includes("access control")||n.includes("data handling")||n.includes("data retention")?t.involvesDataHandling:!0},Ae=(e,t,n,s,r,l,m,u)=>{let p=[],b=new Set(u??[]),x=0,d=()=>`ac-${++x}`;if(s!==null)for(let i of s.items)b.has(i.id)||p.push({id:i.id,text:`[DEBT from iteration ${i.since}] ${i.text}`});if(t&&p.push({id:d(),text:`[FAILED] Tests \u2014 fix this first: ${n.slice(0,200)}`}),l!=null)for(let i of l.verification){let c=d();b.has(c)||p.push({id:c,text:i})}for(let i of e)if(i.acceptanceCriteria!==void 0&&i.acceptanceCriteria.length>0)for(let c of i.acceptanceCriteria){if(!Pe(c,r))continue;let y=d();b.has(y)||p.push({id:y,text:`(${i.id}) ${c}`})}if(m!==void 0)for(let i of m){let c=d();b.has(c)||p.push({id:c,text:`(folder: ${i.folder}) ${i.rule}`})}if(l!=null){let i=l.tasks?.find(c=>c.files!==void 0&&c.files.length>0);i?.files!==void 0&&i.files.length>0&&p.push({id:"scope-check",text:`Scope check: only files listed in task (${i.files.join(", ")}) should be modified. Report any out-of-scope changes with justification.`})}return p.push({id:"mandatory-tests",text:"Tests written and passing for all new and changed behavior"}),p.push({id:"mandatory-docs",text:"Documentation updated for all public-facing changes"}),p},Ce=(e,t,n,s,r,l)=>{let m=e.spec,u=j(t),p=e.execution.iteration>=s,b=e.execution.lastVerification?.passed===!1,x=e.execution.lastVerification?.output??"",d=r?.tasks??[],i=e.execution.completedTasks??[],c=new Set(i),y=d.find(h=>!c.has(h.id))??null,k=y!==null?{id:y.id,title:y.title,totalTasks:d.length,completedTasks:i.length,...y.files!==void 0&&y.files.length>0?{files:y.files}:{}}:void 0;if(e.execution.awaitingStatusReport){let h=Ae(t,b,x,e.execution.debt,e.classification,r,l,e.execution.naItems),R=[];try{let N=JSON.parse(e.execution.lastProgress??"");Array.isArray(N.completed)&&(R=N.completed.filter(F=>typeof F=="string"&&F.startsWith("task-")))}catch{}let A={phase:"EXECUTING",instruction:R.length>=2?`${R.length} tasks reported complete. Report status against ALL relevant acceptance criteria.`:"Before this task is accepted, report your completion status against these acceptance criteria.",context:{rules:n,concernReminders:B(t).tier1},transition:{onComplete:`${o(`next --answer='{"completed":[...],"remaining":[...],"blocked":[...]}'`,m)}`,onBlocked:`${o('block "reason"',m)}`,iteration:e.execution.iteration},statusReportRequired:!0,statusReport:{criteria:h,reportFormat:{completed:"list item IDs you finished (e.g., ['debt-1', 'ac-3']) with evidence",remaining:"list item IDs not yet done",blocked:"list item IDs that need a decision from the user",na:"(optional) list item IDs that are not applicable to this task \u2014 they will be removed from future criteria",newIssues:"(optional) list NEW issues discovered during implementation \u2014 free text, will be assigned debt IDs automatically"}}};return R.length>=2&&(A={...A,batchTasks:R}),b&&(A={...A,verificationFailed:!0,verificationOutput:x.slice(0,2e3)}),A}let f=(e.execution.lastProgress??"").includes("Task not accepted"),v=e.execution.debt?.items??[],S=e.execution.debt?.unaddressedIterations??0,L=k!==void 0?`Execute task ${k.id}: ${k.title} (${k.completedTasks}/${k.totalTasks} completed)`:"All tasks completed. Run `"+o("done",m)+"` to finish.",E;if(b)E="Verification FAILED. Fix the failing tests before continuing.";else if(f&&v.length>0){let h=S>=3?` These items have been outstanding for ${S} iterations.`:"";E=`Task not accepted \u2014 ${v.length} remaining item(s) must be addressed before this task can be completed.${h} Address them, then submit a new status report.`}else E=L;let g={phase:"EXECUTING",instruction:E,task:k,context:{rules:n,concernReminders:B(t).tier1},transition:{onComplete:`${o('next --answer="..."',m)}`,onBlocked:`${o('block "reason"',m)}`,iteration:e.execution.iteration}};if(f&&v.length>0&&(g={...g,taskRejected:!0,rejectionReason:`${v.length} remaining item(s) must be addressed.`,rejectionRemaining:v.map(h=>h.text)}),e.execution.debt!==null&&e.execution.debt.items.length>0){let h=e.execution.debt.unaddressedIterations??0,R=h>=3?`URGENT: These items have been unaddressed for ${h} iterations. Address them IMMEDIATELY before any new work.`:"These were not completed in a previous iteration. Address them BEFORE starting new work.";g={...g,previousIterationDebt:{fromIteration:e.execution.debt.fromIteration,items:e.execution.debt.items,note:R}}}if(b){let h=x.slice(0,2e3);g={...g,verificationFailed:!0,verificationOutput:h}}if(u.length>0){let h=u.map(R=>`${R.between.join(" vs ")}: ${R.issue}`).join("; ");g={...g,concernTensions:u,instruction:`TENSION GATE: ${u.length} concern tension(s) detected: ${h}. You MUST present these to the user and get explicit resolution for each before proceeding. Use AskUserQuestion to ask which side to prioritize.`}}p&&(g={...g,restartRecommended:!0,restartInstruction:`Context may be getting large after ${e.execution.iteration} iterations. Consider starting a new conversation and running \`${o("next",m)}\` to resume - your progress is saved.`});let I=[...e.decisions].reverse().find(h=>!h.promoted);return I!==void 0&&e.execution.lastProgress?.startsWith("Resolved:")&&(g={...g,promotePrompt:{decisionId:I.id,question:I.question,choice:I.choice,prompt:`You just resolved a decision: "${I.choice}". Ask the user: "Should this be a permanent rule for future specs too?" If yes, run: \`${O(`rule add "${I.choice}"`)}\``}}),e.execution.iteration===0&&!b&&!f&&(g={...g,preExecutionReview:{instruction:"Re-read spec before starting. Flag: missing info that will block mid-execution, wrong task order, unclear ACs. Better to catch now than mid-execution."}}),t.some(h=>h.id==="beautiful-product")&&(g={...g,designChecklist:{required:!0,instruction:"Before completing any UI task, rate your implementation 0-10 on these dimensions and include the ratings in your AC report:",dimensions:[{id:"hierarchy",label:"Information hierarchy \u2014 what does the user see first, second, third?"},{id:"states",label:"Interaction states \u2014 loading, empty, error, success all specified?"},{id:"edge-cases",label:"Edge cases \u2014 long text, zero results, slow connection handled?"},{id:"intentionality",label:"Overall intentionality \u2014 does this feel designed or generated?"}]}}),g},Oe=e=>{let t=e.spec;return{phase:"BLOCKED",instruction:"A decision is needed. Ask the user.",reason:e.execution.lastProgress??"Unknown",transition:{onResolved:`${o('next --answer="..."',t)}`}}},Se=async(e,t)=>{let s={phase:"COMPLETED",summary:{spec:e.spec,iterations:e.execution.iteration,decisionsCount:e.decisions.length,completionReason:e.completionReason,completionNote:e.completionNote},learningPrompt:{instruction:`LEARNING PENDING \u2014 Record learnings before moving on. For each insight, decide: one-time learning or permanent rule? One-time ("assumed X, was Y") \u2192 \`learn "text"\`. Permanent ("always/never do X") \u2192 \`learn "text" --rule\`. Run: \`noskills spec ${e.spec??"<name>"} learn "text"\` or \`learn "text" --rule\`.`,examples:[`noskills spec ${e.spec??"upload"} learn "Assumed S3 SDK v2, was v3"`,`noskills spec ${e.spec??"upload"} learn "Always use Result types" --rule`,"noskills learn promote 1"]},learningsPending:!0};if(t!==void 0)try{let{checkStaleness:r}=await import("./diagrams-IC2ADMKS.js"),l=await r(t,e.execution.modifiedFiles);if(l.length>0)return{...s,staleDiagrams:l.map(m=>({file:m.file,line:m.line,reason:m.reason})),staleDiagramsBlocking:!0}}catch{}return s};export{Be as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as S,b as G,c as R}from"./chunk-L5OC7F24.js";import{e as ee}from"./chunk-J2Z7NG2X.js";import{f as p,h as u,k as d}from"./chunk-SHN5MT56.js";import{b as r,d as i,f as w,g as y,h as Z,k as l}from"./chunk-YVN2NZL4.js";import{d as v}from"./chunk-VKB3B2FE.js";import{a as k}from"./chunk-
|
|
2
|
+
import{a as S,b as G,c as R}from"./chunk-L5OC7F24.js";import{e as ee}from"./chunk-J2Z7NG2X.js";import{f as p,h as u,k as d}from"./chunk-SHN5MT56.js";import{b as r,d as i,f as w,g as y,h as Z,k as l}from"./chunk-YVN2NZL4.js";import{d as v}from"./chunk-VKB3B2FE.js";import{a as k}from"./chunk-IHHITZU2.js";import{a as f,b as g}from"./chunk-FFWPJP7A.js";import{g as T,i as m}from"./chunk-6DBKPC2O.js";import{g as ie,m as O,n as K,o as I,p as le}from"./chunk-6G6UVWJN.js";var de="# eser CLI completions",B="eser",te=async e=>{try{return await m.fs.readTextFile(e)}catch{return""}},me=async e=>{try{return await m.fs.stat(e),!0}catch{return!1}},se=async e=>{let t=R(e,B);if(t.completionType==="file")return await me(t.completionsFile);let s=await te(t.rcFile),n=G(e,B);return s.includes(n)},ne=async e=>{let t=R(e,B),s=p({renderer:d.ansi(),sink:u.stdout()});try{if(t.completionType==="file"){let n=t.completionsFile,o=m.path.dirname(n);try{await m.fs.mkdir(o,{recursive:!0})}catch{}await m.fs.writeTextFile(n,`# eser CLI completions
|
|
3
3
|
# This file is auto-generated. Run 'eser system completions --shell fish' to regenerate.
|
|
4
4
|
complete -c eser -f
|
|
5
5
|
complete -c eser -n "__fish_use_subcommand" -a "codebase" -d "Codebase management tools"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-YWSOQJ7G.js";import{h as C}from"./chunk-L32KHQVT.js";import{A as
|
|
2
|
+
import{a as k}from"./chunk-YWSOQJ7G.js";import{h as C}from"./chunk-L32KHQVT.js";import{A as v}from"./chunk-E4WXXNF6.js";import{B as S,e as g,g as y,j as E}from"./chunk-LOZLXP5G.js";import"./chunk-2XNFZXHY.js";import{f,h as w,k as h}from"./chunk-SHN5MT56.js";import{f as n,g as u}from"./chunk-YVN2NZL4.js";import{a as d,b as a}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var $=async p=>{let e=f({renderer:h.ansi(),sink:w.stdout()}),{root:i}=await S(),s=y(p);if(!s.ok)return e.writeln(n(s.error)),await e.close(),a({exitCode:1});let m=(p??[]).filter(r=>!r.startsWith("--")),o=m[0],l=m.slice(1).join(" ");if(!o||!l)return e.writeln(n("Usage: noskills spec <name> delegate <questionId> <userName>")),await e.close(),a({exitCode:1});let t;try{t=await g(i,s.spec)}catch(r){let R=r instanceof Error?r.message:String(r);return e.writeln(n(R)),await e.close(),a({exitCode:1})}if(t.phase!=="DISCOVERY"&&t.phase!=="DISCOVERY_REFINEMENT")return e.writeln(n(`Cannot delegate in phase: ${t.phase}. Only during discovery.`)),await e.close(),a({exitCode:1});let c=await C(i),I=v(t,o,l,c.name);return await E(i,s.spec,I),await k(i,{ts:new Date().toISOString(),type:"delegation-created",spec:s.spec,user:c.name,question:o,from:c.name,to:l}),e.writeln(u("\u2714"),` Delegated "${o}" to ${l}`),await e.close(),d(void 0)};export{$ as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as I}from"./chunk-YWSOQJ7G.js";import{a as P,d as O}from"./chunk-DI7OHJ53.js";import{h as D}from"./chunk-L32KHQVT.js";import{D as U,p as T,s as k}from"./chunk-
|
|
2
|
+
import{a as I}from"./chunk-YWSOQJ7G.js";import{a as P,d as O}from"./chunk-DI7OHJ53.js";import{h as D}from"./chunk-L32KHQVT.js";import{D as U,p as T,s as k}from"./chunk-E4WXXNF6.js";import{B as v,c as C,e as x,g as y,h as $,j as b}from"./chunk-LOZLXP5G.js";import{c as m}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{f as g,h as S,k as E}from"./chunk-SHN5MT56.js";import{c,d as a,f as o,g as f,h}from"./chunk-YVN2NZL4.js";import{a as u,b as n}from"./chunk-FFWPJP7A.js";import{i as w}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var B=async R=>{let e=g({renderer:E.ansi(),sink:S.stdout()}),{root:i}=await v(),p=y(R);if(!p.ok)return e.writeln(o(p.error)),await e.close(),n({exitCode:1});let t;try{t=await x(i,p.spec)}catch(s){let l=s instanceof Error?s.message:String(s);return e.writeln(o(l)),await e.close(),n({exitCode:1})}if(t.phase!=="EXECUTING")return e.writeln(o(`Cannot complete in phase: ${t.phase}`)),e.writeln(a("Only EXECUTING phase can transition to COMPLETED.")),await e.close(),n({exitCode:1});if(t.execution.awaitingStatusReport)return e.writeln(o("Cannot complete: status report is pending.")),e.writeln(a(`Submit a status report first: ${m(`next --answer='{"completed":[...],"remaining":[...]}'`)}`)),await e.close(),n({exitCode:1});if(t.execution.debt!==null&&t.execution.debt.items.length>0){e.writeln(h(`Warning: ${t.execution.debt.items.length} unresolved debt item(s).`));for(let s of t.execution.debt.items)e.writeln(a(` - ${s.id}: ${s.text}`));e.writeln("")}if(t.spec!==null){let s=`${i}/${C.specDir(t.spec)}`;try{await w.fs.stat(s)}catch{return e.writeln(o(`Active spec '${t.spec}' directory not found.`)),e.writeln(a("Run `noskills reset` to return to idle.")),await e.close(),n({exitCode:1})}}let d=await D(i),r=T(t,"done");r=k(r,"EXECUTING","COMPLETED",d),r.spec!==null&&await b(i,r.spec,r);let G=U(r);if(await $(i,G),r.spec!==null&&(await P(i,r.spec,"completed"),await O(i,r.spec,"completed")),await I(i,{ts:new Date().toISOString(),type:"phase-change",spec:t.spec??"unknown",user:d.name,from:"EXECUTING",to:"COMPLETED"}),e.writeln(f("\u2714")," Spec completed!"),e.writeln(""),e.writeln(" Spec: ",c(t.spec??"unknown")),e.writeln(` Iterations: ${t.execution.iteration}`),e.writeln(` Decisions: ${t.decisions.length}`),t.decisions.length>0){let s=t.decisions.filter(l=>l.promoted);s.length>0&&e.writeln(a(` Promoted to rules: ${s.length}`))}return e.writeln(""),e.writeln("Start a new spec with: ",c(`${m('spec new "..."')}`)),await e.close(),u(void 0)};export{B as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as v}from"./chunk-L32KHQVT.js";import{w as y,x as I,y as
|
|
2
|
+
import{h as v}from"./chunk-L32KHQVT.js";import{w as y,x as I,y as E,z as R}from"./chunk-E4WXXNF6.js";import{B as q,e as C,g as U,j as c}from"./chunk-LOZLXP5G.js";import"./chunk-2XNFZXHY.js";import{f as k,h as x,k as F}from"./chunk-SHN5MT56.js";import{d,f as o,g as p}from"./chunk-YVN2NZL4.js";import{a as l,b as i}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var W=async w=>{let e=k({renderer:F.ansi(),sink:x.stdout()}),{root:a}=await q(),n=U(w);if(!n.ok)return e.writeln(o(n.error)),await e.close(),i({exitCode:1});let f=(w??[]).filter(s=>!s.startsWith("--")),t=f[0],m=f.slice(1).join(" "),u=null,h=!1;for(let s of w??[])s.startsWith("--answer=")&&(u=s.slice(9)),s==="--skip"&&(h=!0);if(!t)return e.writeln(o('Usage: noskills spec <name> followup <questionId> "question text"')),e.writeln(d(' Or: noskills spec <name> followup <followUpId> --answer="text"')),e.writeln(d(" Or: noskills spec <name> followup <followUpId> --skip")),await e.close(),i({exitCode:1});let r;try{r=await C(a,n.spec)}catch(s){let A=s instanceof Error?s.message:String(s);return e.writeln(o(A)),await e.close(),i({exitCode:1})}if(u!==null){let s=I(r,t,u);return await c(a,n.spec,s),e.writeln(p("\u2714"),` Answered follow-up: ${t}`),await e.close(),l(void 0)}if(h){let s=E(r,t);return await c(a,n.spec,s),e.writeln(p("\u2714"),` Skipped follow-up: ${t}`),await e.close(),l(void 0)}if(m.length===0)return e.writeln(o("Follow-up question text is required.")),await e.close(),i({exitCode:1});if(r.phase!=="DISCOVERY"&&r.phase!=="DISCOVERY_REFINEMENT")return e.writeln(o(`Cannot add follow-ups in phase: ${r.phase}`)),await e.close(),i({exitCode:1});let O=await v(a),g=y(r,t,m,O.name);await c(a,n.spec,g);let S=R(g,t),$=S[S.length-1];return e.writeln(p("\u2714"),` Follow-up added: ${$?.id??t}`),await e.close(),l(void 0)};export{W as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ae,b as re}from"./chunk-NTY267SI.js";import{d as oe}from"./chunk-L5OC7F24.js";import{a as ee}from"./chunk-
|
|
2
|
+
import{a as ae,b as re}from"./chunk-NTY267SI.js";import{d as oe}from"./chunk-L5OC7F24.js";import{a as ee}from"./chunk-P4SPHY3G.js";import"./chunk-4KDDHQVL.js";import{b as k}from"./chunk-PPB6ACBB.js";import{b as te,e as se,f as ne}from"./chunk-4JICYXYK.js";import"./chunk-KFVUFHJB.js";import"./chunk-NY4W44PI.js";import{d as ie}from"./chunk-2ZYCRMUT.js";import{A as Q,a as H,b as _,d as q,h as B,l as S,m as K,o as U,q as V}from"./chunk-LOZLXP5G.js";import{a as X,c as Y,d as Z}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import"./chunk-7ZYDAZBD.js";import{a as I,b as R,i as P,j as W,k as J,l as z,m as G,n as g,o as w,p as m}from"./chunk-5GGWX7CO.js";import"./chunk-GE3LJ6QM.js";import{a as N}from"./chunk-QXSFQQGJ.js";import"./chunk-BNQAZLIQ.js";import"./chunk-SHN5MT56.js";import"./chunk-YVN2NZL4.js";import"./chunk-J7YTWK67.js";import"./chunk-VKB3B2FE.js";import"./chunk-PBZV2KA3.js";import"./chunk-NMEPQK3T.js";import"./chunk-RNFCAHVL.js";import"./chunk-MG65QJY6.js";import{a as F}from"./chunk-FFWPJP7A.js";import{i as p}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var ce=N;var ye=async t=>{try{return await p.fs.stat(t),!0}catch{return!1}},Ce=[{id:"claude-code",paths:["CLAUDE.md",".claude"]},{id:"cursor",paths:[".cursorrules",".cursor"]},{id:"kiro",paths:[".kiro"]},{id:"copilot",paths:[".github/copilot-instructions.md"]},{id:"windsurf",paths:[".windsurfrules"]},{id:"codex",paths:[".codex",".codex/config.toml"]},{id:"copilot-cli",paths:[".copilot",".github/hooks"]}],le=async t=>{let e=[];for(let i of Ce)for(let n of i.paths)if(await ye(`${t}/${n}`)){e.push(i.id);break}return e};var r=async t=>{try{return await p.fs.stat(t),!0}catch{return!1}},de=async(t,e)=>{try{let i=await p.fs.readTextFile(t);return JSON.parse(i)[e]??null}catch{return null}},xe=async t=>{let e=[];return(await r(`${t}/package.json`)||await r(`${t}/deno.json`))&&e.push("typescript"),await r(`${t}/go.mod`)&&e.push("go"),await r(`${t}/Cargo.toml`)&&e.push("rust"),(await r(`${t}/pyproject.toml`)||await r(`${t}/setup.py`))&&e.push("python"),e},Te=async t=>{let e=[],i=await de(`${t}/package.json`,"dependencies");return i!==null&&("react"in i&&e.push("react"),"vue"in i&&e.push("vue"),"svelte"in i&&e.push("svelte"),"next"in i&&e.push("nextjs"),"express"in i&&e.push("express"),"hono"in i&&e.push("hono")),e},be=async t=>{let e=[];return await r(`${t}/.github/workflows`)&&e.push("github-actions"),await r(`${t}/.gitlab-ci.yml`)&&e.push("gitlab-ci"),await r(`${t}/Jenkinsfile`)&&e.push("jenkins"),await r(`${t}/.circleci`)&&e.push("circleci"),e},$e=async t=>{if(await r(`${t}/deno.json`))return"deno";let e=await de(`${t}/package.json`,"devDependencies");if(e!==null){if("vitest"in e)return"vitest";if("jest"in e)return"jest";if("playwright"in e)return"playwright"}return null},ue=async t=>{let[e,i,n,d]=await Promise.all([xe(t),Te(t),be(t),$e(t)]);return{languages:e,frameworks:i,ci:n,testRunner:d}};var qe=async t=>{let e=p.process.cwd(),i=ae(t),n=R({target:i==="agent"?"non-interactive":"interactive"}),d=re(t),h=pe(d,"--concerns"),f=pe(d,"--tools"),u=d.includes("--non-interactive")||i==="agent",x=await Q(e);W(n,"noskills init");let D=m(n,"Checking directories...");D.start(),await V(e),D.succeed("Config: .eser/");let j=m(n,"Scanning project...");j.start();let T=await ue(e);j.succeed("Project scanned");for(let s of T.languages)w.step(n,` ${s}`);for(let s of T.frameworks)w.step(n,` ${s}`);g(n);let A=m(n,"Detecting coding tools...");A.start();let L=await le(e),y=oe(),O=y!==null&&!L.includes(y)?[y]:[],C=[...new Set([...O,...L])];A.succeed(`${C.length} coding tool(s) detected`);let l;if(f!==null){let s=["claude-code","cursor","kiro","copilot","windsurf","opencode","codex","copilot-cli"],o=f.filter(a=>s.includes(a));l=[...new Set([...O,...o])]}else if(x){let s=await S(e);l=s!==null?[...s.tools]:[...C]}else u?l=[...C]:(g(n),l=await Se(n,C,y));g(n);let E=m(n,"Detecting AI providers...");E.start();let b=(await ce()).filter(s=>s.available).map(s=>s.name);E.succeed(`${b.length} provider(s) detected`),g(n);let $=await k(),c;if(h!==null){let s=$.map(o=>o.id);c=h.filter(o=>s.includes(o)).sort((o,a)=>s.indexOf(o)-s.indexOf(a))}else if(x){let s=await S(e);c=s!==null?[...s.concerns]:[]}else if(u)c=[];else{let s=$.map(a=>({value:a.id,label:a.name,hint:a.description.slice(0,60)})),o=await P(n,{message:"What kind of project is this? (space to toggle, enter to confirm)",options:s});c=I(o)?[]:[...o]}c.length>0&&w.success(n,` Concerns: ${c.join(", ")}`),g(n);let fe=$.filter(s=>c.includes(s.id));for(let s of fe)await U(e,s);let M=await Z();X(M);let v={..._(c,l,b,T),command:M};if(await K(e,v),!x){let s=H();await B(e,s)}if(l.length>0){let s=m(n,"Syncing tool files...");s.start();let o=await ne(e,l,v);s.succeed(`Synced ${o.length} tool(s)`);for(let a of o)w.step(n,` ${a}`)}if(J(n,`Done. ${l.length} tool(s), ${b.length} provider(s), ${c.length} concern(s).`),i==="agent"){let s=await q(e),a=(await k()).filter(we=>c.includes(we.id)),ge=await te(e),me=se(v?.tools??[]),he=await ee(s,a,ge,v,void 0,void 0,void 0,me);await ie(he,"json")}else z(n),G(n,`Start a spec with: ${Y('spec new "..."')}`);return F(void 0)},Pe=[{value:"claude-code",label:"Claude Code"},{value:"cursor",label:"Cursor"},{value:"kiro",label:"Kiro"},{value:"copilot",label:"GitHub Copilot"},{value:"windsurf",label:"Windsurf"},{value:"opencode",label:"OpenCode"},{value:"codex",label:"Codex CLI"},{value:"copilot-cli",label:"Copilot CLI"}],Se=async(t,e,i)=>{let n=e.length===0?"No coding tools detected. Which tools do you use? (space to toggle)":"Any additional tools? (space to toggle, enter to skip)",d=new Set(e),h=await P(t,{message:n,options:Pe.map(u=>({...u,hint:u.value===i?"you're running inside it":d.has(u.value)?"detected":void 0,disabled:u.value===i})),initialValues:[...e],required:!1});if(I(h))return[...e];let f=[...h];return i!==null&&!f.includes(i)&&f.unshift(i),f},pe=(t,e)=>{if(t===void 0)return null;for(let i of t)if(i.startsWith(`${e}=`))return i.slice(e.length+1).split(",").map(n=>n.trim()).filter(Boolean);return null};export{qe as main};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as B}from"./chunk-5YBG2HOI.js";import{a as A}from"./chunk-P4SPHY3G.js";import"./chunk-4KDDHQVL.js";import{f as F}from"./chunk-PPB6ACBB.js";import{a as G,b as W,d as M,e as U}from"./chunk-4JICYXYK.js";import"./chunk-KFVUFHJB.js";import"./chunk-NY4W44PI.js";import{A as $,c as w,d as D,e as _,l as O,p as N,t as P,u as L}from"./chunk-LOZLXP5G.js";import{c as m}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{a as l}from"./chunk-FFWPJP7A.js";import{i as r}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var X=new Set(["log","diff","status","show","blame","rev-parse","ls-files","ls-tree","cat-file","describe","shortlog","name-rev","for-each-ref","rev-list","help","version"]),H=new Map([["branch",new Set(["","--list","-l","-a","--all","-r","--remotes","-v","--verbose","--contains","--no-contains","--merged","--no-merged"])],["tag",new Set(["","-l","--list","-v","--verify","-n"])],["stash",new Set(["list","show"])],["remote",new Set(["","-v","--verbose","show","get-url"])],["config",new Set(["--get","--get-all","--get-regexp","--list","-l","--global","--local","--system"])],["reflog",new Set(["","show"])]]),z=new Set(["-C","-c","--git-dir","--work-tree","--namespace","--super-prefix","--config-env"]),q=new Set(["--no-replace-objects","--bare","--no-optional-locks","--literal-pathspecs","--glob-pathspecs","--noglob-pathspecs","--icase-pathspecs","--no-pager","--paginate"]),Q=t=>{let s=0;for(;s<t.length;){let e=t[s];if(z.has(e)){s+=2;continue}if(q.has(e)){s+=1;continue}if(e.startsWith("--git-dir=")||e.startsWith("--work-tree=")||e.startsWith("--namespace=")||e.startsWith("--super-prefix=")||e.startsWith("--config-env=")){s+=1;continue}if(e.startsWith("-C")&&e.length>2){s+=1;continue}if(e.startsWith("-c")&&e.length>2&&e.includes("=")){s+=1;continue}return e}return null},E=t=>{let s=t.trim();if(!s.startsWith("git"))return!0;let e=s.slice(3).trim();if(e.length===0)return!0;let n=e.split(/\s+/),c=Q(n)??"";if(X.has(c))return!0;let i=H.get(c);if(i!==void 0){let o=n.indexOf(c),g=o>=0&&o+1<n.length?n[o+1]:"";if(i.has(g))return!0}return!1};var J=t=>{let s=[/(?:bash|sh|\/bin\/bash|\/bin\/sh)\s+-c\s+["'](.+?)["']/g,/(?:bash|sh|\/bin\/bash|\/bin\/sh)\s+-c\s+(\S+)/g,/eval\s+["'](.+?)["']/g];for(let c of s){let i;for(;(i=c.exec(t))!==null;){let o=i[1]??"";if(o.includes("git")&&!E(o))return!0}}let e=t.split(/\s*\|\s*/);for(let c of e){let i=c.trim();if(i.startsWith("git")&&!E(i))return!0}let n=t.matchAll(/(?:^|[\s($`(])git\b/g);for(let c of n){let o=c[0].indexOf("git"),g=(c.index??0)+o,f=(t.slice(g).split(/[;&|$)`'"]/)[0]??"").trim();if(f.startsWith("git")&&!E(f))return!0}return!1},K=t=>t.replace(/--\w+='[^']*'/g,"").replace(/--\w+="[^"]*"/g,"").replace(/--\w+=\S*/g,"");var x=async()=>{let t=r.process.stdin.getReader(),s=[];try{for(;;){let{done:i,value:o}=await t.read();if(i||o===void 0)break;s.push(o)}}finally{t.releaseLock()}let e=0,n=new Uint8Array(s.reduce((i,o)=>i+o.length,0));for(let i of s)n.set(i,e),e+=i.length;let c=new TextDecoder().decode(n);try{return JSON.parse(c)}catch{return{}}},b=async t=>{let s=new TextEncoder,e=r.process.stdout.getWriter();await e.write(s.encode(JSON.stringify(t))),e.releaseLock()},pe=async t=>{switch(t?.[0]){case"pre-tool-use":return await te();case"stop":return await se();case"post-file-write":return await ne();case"post-bash":return await ie();case"session-start":return await re();default:return l(void 0)}},v=async t=>{await b({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:`noskills: ${t}`}})},ee=async t=>{await b({hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"allow",additionalContext:t}})},V=(t,s)=>{if(s)return null;let e=K(t);if(!e.includes("git"))return null;let n=e.split(/\s*(?:&&|;)\s*/);for(let c of n){let i=c.trim();if(i.startsWith("git")&&!E(i))return"Git write operations are not allowed. Only read commands (log, diff, status, show, blame, branch, tag) are permitted. The user controls git, the agent controls files."}return J(e)?"Git write operations detected in subshell or pipe. Only read commands are permitted. The user controls git, the agent controls files.":null},te=async()=>{let t=await x(),s=t.tool_name??"unknown",e=t.tool_input??{},n=t.cwd??r.env.get("NOSKILLS_PROJECT_ROOT")??r.process.cwd(),c=await O(n),i=r.env.get("NOSKILLS_SESSION")??null;if(i!==null){let a=await P(n,i);if(a!==null&&a.mode==="free"){if(s==="Bash"){let u=(e.command??"").trim(),d=c?.allowGit??!1;if(!d&&u.includes("git")){let h=V(u,d);if(h!==null)return await v(h),l(void 0)}}return l(void 0)}}let o={};if(i!==null){let a=await P(n,i);if(a!==null&&a.mode==="spec"&&a.phase!==null)o={phase:a.phase};else if(a!==null&&a.spec!==null)try{o=await _(n,a.spec)}catch{return l(void 0)}else return l(void 0)}else{let a=await L(n);if(a.length>0){let u={DISCOVERY:10,DISCOVERY_REFINEMENT:10,SPEC_PROPOSAL:10,SPEC_APPROVED:8,BLOCKED:8,EXECUTING:2,IDLE:0,COMPLETED:0},d="IDLE",h=0;for(let C of a){let R=C.phase??"IDLE",I=u[R]??0;I>h&&(h=I,d=R)}o={phase:d};let k=new TextEncoder,T=r.process.stderr.getWriter();await T.write(k.encode(`noskills: WARNING \u2014 ${a.length} session(s) active but NOSKILLS_SESSION not set. Using most restrictive phase (${d}). Set NOSKILLS_SESSION for correct per-instance enforcement.
|
|
3
|
+
`)),T.releaseLock()}else try{o=await D(n)}catch{return l(void 0)}}if(s==="Bash"){let a=(e.command??"").trim(),u=c?.allowGit??!1,d=V(a,u);return d!==null?(await v(d),l(void 0)):l(void 0)}let g=["Write","Edit","MultiEdit"];if(!g.includes(s))return l(void 0);let p=e.file_path??e.path??"";if(p.includes(".eser/")||p.includes(".claude/"))return l(void 0);let f=o.phase??"UNKNOWN";if(f==="UNKNOWN")return await v("Phase unknown \u2014 file edit blocked. Run `noskills status` to check state."),l(void 0);if(f==="EXECUTING"||f==="IDLE"||f==="COMPLETED"){if(f==="EXECUTING"&&g.includes(s)){let a=`${n}/${w.stateDir}/executor-warned.flag`;try{await r.fs.readTextFile(a)}catch{try{await r.fs.mkdir(`${n}/${w.stateDir}`,{recursive:!0}),await r.fs.writeTextFile(a,new Date().toISOString());let u=new TextEncoder,d=r.process.stderr.getWriter();await d.write(u.encode(`noskills: REMINDER \u2014 You should be spawning a noskills-executor sub-agent for implementation work. If you're the main orchestrator agent, delegate to a sub-agent instead of editing directly. If you ARE a sub-agent, ignore this message and continue.
|
|
4
|
+
`)),d.releaseLock()}catch{}}}if(f==="EXECUTING"&&p.length>0)try{let a=[],u=await G(n),d=M(u,"EXECUTING",p);a.push(...d);let h=await B(n,[p]);for(let S of h)a.push(`(${S.folder}/) ${S.rule}`);let T=o.classification??null,C=await N(n),R=await O(n),I=C.filter(S=>R!==null&&R.concerns.includes(S.id)),Y=F(I,p,T);if(a.push(...Y),a.length>0){let S=`[noskills] Rules for this file:
|
|
5
|
+
`+a.map(j=>`- ${j}`).join(`
|
|
6
|
+
`);return await ee(S),l(void 0)}}catch{}return l(void 0)}let y={DISCOVERY:`You are in DISCOVERY \u2014 this is a thinking phase, not an implementation phase. Read and discuss only. To write code, complete discovery and get the spec approved first. Run \`${m("next")}\` to continue.`,DISCOVERY_REFINEMENT:`You are in DISCOVERY_REFINEMENT \u2014 this is a thinking phase, not an implementation phase. Read and discuss only. To write code, complete discovery and get the spec approved first. Run \`${m('next --answer="approve"')}\` or revise answers.`,SPEC_PROPOSAL:`You are in SPEC_PROPOSAL \u2014 this is a thinking phase, not an implementation phase. Read and discuss only. To write code, approve the spec first. Run \`${m("approve")}\``,SPEC_APPROVED:`You are in SPEC_APPROVED \u2014 start execution first: \`${m('next --answer="start"')}\``,BLOCKED:`Execution blocked. Resolve with \`${m('next --answer="resolution"')}\``};return await v(y[f]??`Run \`${m("next")}\` first.`),l(void 0)},se=async()=>{let t=await x();if(t.stop_hook_active===!0)return l(void 0);let s=t.cwd??r.env.get("NOSKILLS_PROJECT_ROOT")??r.process.cwd(),e;try{let u=await r.fs.readTextFile(`${s}/${w.stateFile}`);e=JSON.parse(u)}catch{return l(void 0)}if(e.phase!=="EXECUTING")return l(void 0);let n=e.execution??{},c=`${s}/${w.stateDir}/files-changed.jsonl`,i=[];try{let d=(await r.fs.readTextFile(c)).trim().split(`
|
|
7
|
+
`).filter(Boolean);i=[...new Set(d.map(h=>{try{return JSON.parse(h).file}catch{return null}}).filter(h=>h!==null))]}catch{}let o=[],g="no changes";try{let{execSync:u}=await import("node:child_process");o=u("git diff --name-only",{cwd:s,encoding:"utf-8",timeout:5e3}).trim().split(`
|
|
8
|
+
`).filter(Boolean);let k=u("git diff --stat",{cwd:s,encoding:"utf-8",timeout:5e3}).trim().split(`
|
|
9
|
+
`);g=k[k.length-1]??"no changes"}catch{}let p=[...new Set([...i,...o])],f=(n.iteration??0)+1,y=`${s}/${w.stateDir}/iterations`;try{await r.fs.mkdir(y,{recursive:!0}),await r.fs.writeTextFile(`${y}/iteration-${f}.json`,JSON.stringify({iteration:f,files:p,gitStat:g.trim(),timestamp:new Date().toISOString()},null,2)+`
|
|
10
|
+
`)}catch{}let a=15;try{let u=await O(s);u!==null&&(a=u.maxIterationsBeforeRestart)}catch{}e.execution={...n,iteration:f,modifiedFiles:p,lastProgress:g.trim()||n.lastProgress||null},e.lastCalledAt=new Date().toISOString();try{await r.fs.writeTextFile(`${s}/${w.stateFile}`,JSON.stringify(e,null,2)+`
|
|
11
|
+
`)}catch{}try{await r.fs.writeTextFile(c,"")}catch{}try{await r.fs.remove(`${s}/${w.stateDir}/executor-warned.flag`)}catch{}if(f>=a){let u=new TextEncoder,d=r.process.stderr.getWriter();await d.write(u.encode(`noskills: iteration ${f} reached threshold (${a}). Consider starting a fresh conversation.
|
|
12
|
+
`)),d.releaseLock()}return l(void 0)},ne=async()=>{let t=await x(),s=t.tool_input??{},e=s.file_path??s.path??"";if(!e||e.includes(".eser/")||e.includes(".claude/"))return l(void 0);let n=t.cwd??r.env.get("NOSKILLS_PROJECT_ROOT")??r.process.cwd(),c=`${n}/${w.stateDir}/files-changed.jsonl`,i=JSON.stringify({file:e,tool:t.tool_name,ts:new Date().toISOString()});try{await r.fs.mkdir(`${n}/${w.stateDir}`,{recursive:!0});let o="";try{o=await r.fs.readTextFile(c)}catch{}await r.fs.writeTextFile(c,o+i+`
|
|
13
|
+
`)}catch{}return l(void 0)},ie=async()=>{let t=await x(),e=(t.tool_input??{}).command??"";if(!e.includes("noskills"))return l(void 0);let n=t.cwd??r.env.get("NOSKILLS_PROJECT_ROOT")??r.process.cwd(),c=`${n}/${w.stateDir}/noskills-calls.jsonl`,i=JSON.stringify({command:e,ts:new Date().toISOString()});try{await r.fs.mkdir(`${n}/${w.stateDir}`,{recursive:!0});let o="";try{o=await r.fs.readTextFile(c)}catch{}await r.fs.writeTextFile(c,o+i+`
|
|
14
|
+
`)}catch{}return l(void 0)},re=async()=>{let t=r.env.get("NOSKILLS_PROJECT_ROOT")??r.process.cwd();if(!await $(t))return l(void 0);let s=await D(t),e=await O(t),c=(await N(t)).filter(p=>e!==null&&e.concerns.includes(p.id)),i=await W(t),o=U(e?.tools??[]),g=await A(s,c,i,e,void 0,void 0,void 0,o);return await b(g),l(void 0)};export{pe as main};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import"./chunk-NE2J6ISX.js";import"./chunk-KFVUFHJB.js";import{a as Oe}from"./chunk-ODBJ5KMQ.js";import{b as ae,c as oe}from"./chunk-YWSOQJ7G.js";import"./chunk-DI7OHJ53.js";import{h as ie}from"./chunk-L32KHQVT.js";import"./chunk-E4WXXNF6.js";import{A as De,B as Le,c as Te,d as xe,e as te,i as ve,k as Pe,l as Ie,s as se,v as Me,x as Re,z as ne}from"./chunk-LOZLXP5G.js";import{b as re}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{c as J,d as Se,e as we,r as C,s as a,t as B,u as K,v as Z,w as ee,x as z,y as Ee}from"./chunk-5GGWX7CO.js";import"./chunk-SHN5MT56.js";import"./chunk-YVN2NZL4.js";import{d as he,e as H,f as be}from"./chunk-VKB3B2FE.js";import{a as Q,b as ye}from"./chunk-FFWPJP7A.js";import{i as $}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var Ye=["IDLE","DISCOVERY","REVIEW","DRAFT","APPROVED","EXECUTING","DONE","IDLE"],Ge=e=>{let n={DISCOVERY_REFINEMENT:"REVIEW",SPEC_PROPOSAL:"DRAFT",SPEC_APPROVED:"APPROVED",COMPLETED:"DONE",BLOCKED:"EXECUTING"}[e]??e;return Ye.map(r=>r===n?`[ ${r} ]`:r).join(" \u2192 ")},Ae=async(e,s)=>{let n;try{n=await ve(e,s)}catch{n=await xe(e)}let r=await Oe(e,s),l=new Set(n.execution.completedTasks??[]),t=(r?.tasks??[]).map(u=>({id:u.id,description:u.title,done:l.has(u.id),...u.files!==void 0&&u.files.length>0?{files:u.files}:{}})),b=[...new Set(n.discovery.answers.map(u=>"user"in u?u.user:null).filter(u=>u!==null&&u!=="Unknown User"))],E=(n.specNotes??[]).filter(u=>u.text.startsWith("[QUESTION] ")).map(u=>({id:u.id,text:u.text.replace("[QUESTION] ",""),user:u.user,ts:u.timestamp})),v=n.transitionHistory??[],g=v.length>0?v[0].timestamp:new Date().toISOString(),P=n.lastCalledAt??g,w=n.execution.confidenceFindings??[],h=w.length>0?Math.round(w.reduce((u,i)=>u+i.confidence,0)/w.length*10)/10:null,I=w.filter(u=>u.confidence<5).length;return{name:s,slug:s,phase:n.phase,description:n.specDescription??"",tasks:t,contributors:b,delegations:n.discovery.delegations??[],pendingQuestions:E,pendingSignoffs:[],roadmap:Ge(n.phase),createdAt:g,updatedAt:P,avgConfidence:h,lowConfidenceItems:I}},W=async e=>{let s=await Pe(e),n=new Set(s.map(i=>i.name));try{let i=`${e}/${Te.specsDir}`;for await(let m of(await import("./mod-4XKQZL6W.js")).runtime.fs.readDir(i))m.isDirectory&&!n.has(m.name)&&n.add(m.name)}catch{}let r=[];for(let i of n)try{r.push(await Ae(e,i))}catch{}r.sort((i,m)=>{let T=i.phase!=="COMPLETED"&&i.phase!=="IDLE",M=m.phase!=="COMPLETED"&&m.phase!=="IDLE";return T&&!M?-1:!T&&M?1:m.updatedAt.localeCompare(i.updatedAt)});let l=r.find(i=>i.phase!=="COMPLETED"&&i.phase!=="IDLE")??null,t=await ae(e,{limit:50}),b=t.filter(i=>i.type==="mention"),E=new Set(t.filter(i=>i.type==="mention-reply").map(i=>i.mentionId)),v=b.filter(i=>!E.has(i.id)).map(i=>({id:i.id??"",spec:i.spec,from:i.from??i.user,to:i.to??"",question:i.question??"",status:"pending",ts:i.ts})),P=t.filter(i=>i.type==="signoff").filter(i=>i.status==="pending").map(i=>({spec:i.spec,role:i.role??"",status:"pending",ts:i.ts})),w=await ie(e),h=w!==void 0?{name:w.name,email:w.email}:null,u=(await Ie(e))?.roles??null;return{specs:r,activeSpec:l,pendingMentions:v,pendingSignoffs:P,recentEvents:t,currentUser:h,roles:u}};var ke=()=>({tabs:[],selectedTabIndex:-1,focus:"list",running:!0,specsVisible:!0,monitorVisible:!0});var Ze=e=>e===null?"\u2014":{DISCOVERY:"DISC",DISCOVERY_REFINEMENT:"REVW",SPEC_PROPOSAL:"DRFT",SPEC_APPROVED:"APPR",EXECUTING:"EXEC",BLOCKED:"BLKD",COMPLETED:"DONE",IDLE:"IDLE"}[e]??e.slice(0,4),et=e=>{switch(e){case"EXECUTING":return"green";case"DISCOVERY":case"DISCOVERY_REFINEMENT":return"cyan";case"BLOCKED":return"red";case"SPEC_PROPOSAL":case"SPEC_APPROVED":return"yellow";case"COMPLETED":return"dim";default:return"dim"}},tt=(e,s)=>{switch(s){case"green":return a.green(e);case"yellow":return a.yellow(e);case"red":return a.red(e);case"cyan":return a.cyan(e);case"dim":return a.dim(e);default:return e}},A=(e,s)=>{let n=new Set(s.filter(l=>l.spec!==null).map(l=>l.spec)),r=e.map(l=>({label:l.name,badge:Ze(l.phase),badgeColor:et(l.phase),active:n.has(l.name),dimmed:l.phase==="COMPLETED"}));return r.length===0&&r.push({label:"No specs yet",dimmed:!0,selectable:!1}),r},ce=(e,s,n,r)=>{let l=A(e,s),t=B.drawBox({x:r.x,y:r.y,width:r.width,height:r.height,title:"Specs",borderStyle:"rounded"}),b=r.width-2,E=r.height-2,v=Math.max(0,Math.min(n,l.length-1)),g=z.ensureVisible(z.createScrollState(l.length,E),v),P=z.visibleRange(g),w=[];for(let u=0;u<E;u++){let i=P.start+u,m=r.y+1+u;if(i>=P.end||i>=l.length){w.push(a.moveTo(m,r.x+1)+" ".repeat(b));continue}let T=l[i];if(T===void 0){w.push(a.moveTo(m,r.x+1)+" ".repeat(b));continue}let M=T.selectable!==!1,f=i===n&&M,R=T.active?a.green("\u25CF"):f?"\u25B8":" ",L=T.badge!==void 0?" "+tt(`[${T.badge}]`,T.badgeColor??"dim"):"",N=T.dimmed?a.dim(T.label):T.label,Y=` ${R} ${N}${L}`,U=a.truncate(Y,b),c=Math.max(0,b-a.visibleLength(U));f?w.push(a.moveTo(m,r.x+1)+a.inverse(U+" ".repeat(c))):w.push(a.moveTo(m,r.x+1)+U+" ".repeat(c))}let h={id:r.id,x:r.x,y:r.y+1,width:r.width-1,height:E},I=z.renderScrollbar(h,g);return t+w.join("")+I};var nt=["IDLE","DISCOVERY","REVIEW","DRAFT","APPROVED","EXECUTING","DONE","IDLE"],rt=e=>{if(e===null||e==="IDLE")return"IDLE";let n={DISCOVERY_REFINEMENT:"REVIEW",SPEC_PROPOSAL:"DRAFT",SPEC_APPROVED:"APPROVED",COMPLETED:"DONE"}[e]??e;return nt.map(r=>r===n?a.bold(`\u2726${r}\u2726`):a.dim(r)).join("\u2192")},it=(e,s,n)=>{if(s===0)return a.dim("no tasks");let r=Math.round(e/s*n),l=n-r;return a.green("\u2588".repeat(r))+a.dim("\u2591".repeat(l))+` ${e}/${s}`},le=(e,s,n)=>{let r=[];return e===null?(r.push(a.bold("Mode: ")+a.cyan("IDLE")),r.push(a.dim("No active spec"))):e.mode==="free"?(r.push(a.bold("Mode: ")+a.cyan("IDLE")),r.push(a.dim("No active spec")),r.push(""),r.push(a.dim(`Session: ${e.sessionId}`))):(r.push(a.bold("Spec: ")+(e.spec??"unknown")),r.push(a.bold("Phase: ")+(e.phase??"unknown")),r.push(""),r.push(rt(e.phase)),r.push(""),n!==void 0&&r.push(a.bold("Progress: ")+it(n.completed,n.total,15)),r.push(""),r.push(a.dim(`Session: ${e.sessionId}`))),B.fillBox({x:s.x,y:s.y,width:s.width,height:s.height,title:"Monitor",borderStyle:"rounded"},r)};var ot=e=>({DISCOVERY:"DISC",DISCOVERY_REFINEMENT:"REVW",SPEC_PROPOSAL:"DRFT",SPEC_APPROVED:"APPR",EXECUTING:"EXEC",BLOCKED:"BLKD",COMPLETED:"DONE",IDLE:"IDLE"})[e]??e.slice(0,4),ct=e=>{switch(e){case"EXECUTING":return"green";case"DISCOVERY":case"DISCOVERY_REFINEMENT":return"cyan";case"BLOCKED":return"red";case"SPEC_PROPOSAL":case"SPEC_APPROVED":return"yellow";case"COMPLETED":return"dim";default:return"dim"}},lt=e=>e.map(s=>({id:s.id,label:s.spec!==null?s.spec:"IDLE",badge:s.phase!==null?ot(s.phase):void 0,badgeColor:s.phase!==null?ct(s.phase):void 0,closable:!0})),Be=(e,s,n,r,l=1)=>{let t=[];if(t.push(a.moveTo(r,l)),e.length===0){let v=a.dim(" No tabs \u2014 press n to create one ");return t.push(v+" ".repeat(Math.max(0,n-a.visibleLength(v)))),t.join("")}let b=lt(e),E=Ee.renderTabBar({tabs:b,activeIndex:s,maxWidth:n,style:"inverse"});return t.push(E),t.join("")};var de=(e,s,n,r)=>{let l="Terminal",t=n??[],b=r??0,E=s.y-1,v=s.width,g=Be(t,b,v,E,s.x),P=e!==null&&e.widget!==null,w=B.drawBox({x:s.x,y:s.y,width:s.width,height:s.height,title:l,borderStyle:"rounded",skipInterior:P});if(t.length===0){let u=a.dim("No tabs \u2014 press n to create one"),i=" ".repeat(Math.max(0,s.width-2)),m="",T=Math.floor((s.height-2)/2);for(let M=1;M<s.height-1;M++)if(m+=a.moveTo(s.y+M,s.x+1),M===T){let f=a.visibleLength(u),R=Math.max(0,Math.floor((s.width-2-f)/2));m+=" ".repeat(R)+u+" ".repeat(Math.max(0,s.width-2-R-f))}else m+=i;return g+w+m}if(e===null||e.widget===null&&e.buffer.length===0){let u=" ".repeat(Math.max(0,s.width-2)),i="";for(let m=1;m<s.height-1;m++)i+=a.moveTo(s.y+m,s.x+1),i+=u;return g+w+i}if(e.widget!==null)return g+w+e.widget.render(s);let h=s.height-2,I=e.buffer.slice(-h);return g+B.fillBox({x:s.x,y:s.y,width:s.width,height:s.height,title:l,borderStyle:"rounded"},I)};var ue=(e,s)=>({...e,tabs:[...e.tabs,s],selectedTabIndex:e.tabs.length}),X=(e,s)=>{let n=e.tabs.findIndex(t=>t.id===s);if(n===-1)return e;let r=e.tabs[n];r.process!==null&&r.process.kill();let l=e.tabs.filter(t=>t.id!==s);return{...e,tabs:l,selectedTabIndex:Math.min(e.selectedTabIndex,l.length-1)}},Ve=(e,s)=>s<0||s>=e.tabs.length?e:{...e,selectedTabIndex:s},pe=(e,s)=>{let n=s.split(`
|
|
3
|
+
`);for(let r of n)e.buffer.push(r);e.buffer.length>1e3&&e.buffer.splice(0,e.buffer.length-1e3)},k=e=>e.selectedTabIndex<0||e.selectedTabIndex>=e.tabs.length?null:e.tabs[e.selectedTabIndex]??null;var me=(e,s,n)=>{if(e.focus==="terminal")return n&&s==="c"?{type:"quit"}:s==="escape"?{type:"toggleFocus"}:{type:"passthrough",data:s};if(n&&s==="c")return{type:"quit"};if(n&&s==="d")return{type:"quit"};if(n&&s==="t")return{type:"newTab"};if(s==="tab"||s==="escape")return{type:"toggleFocus"};if(n&&s==="e")return{type:"toggleSpecs"};if(n&&s==="w")return{type:"toggleMonitor"};if(e.focus==="list")switch(s){case"up":return{type:"navigate",direction:"up"};case"down":return{type:"navigate",direction:"down"};case"return":return{type:"select"};case"n":return{type:"newTab"};case"x":return{type:"closeTab"};case"q":return{type:"quit"};default:return{type:"none"}}return{type:"passthrough",data:s}},Ne=e=>({...e,focus:e.focus==="list"?"terminal":"list"}),fe=(e,s,n)=>{let r=K.nextSelectableIndex(n,e.selectedTabIndex,s);return{...e,selectedTabIndex:r}},ge=(e,s,n)=>e>=n.x&&e<n.x+n.width&&s>=n.y&&s<n.y+n.height,Ue=(e,s,n,r)=>{let l=e.x+1,t=e.y+1;if(ge(l,t,s.left)){if(e.type==="wheel")return{type:"scrollSpecs",direction:e.direction==="up"?"up":"down"};if(e.type==="mousedown"&&e.button===0){let b=e.y+1-s.left.y-1;if(b>=0&&b<n.length&&n[b].selectable!==!1)return{type:"clickSpec",index:b}}return{type:"none"}}return ge(l,t,s.rightBottom)?e.type==="wheel"?{type:"scrollTerminal",direction:e.direction==="up"?"up":"down"}:r!=="terminal"?{type:"clickTerminal"}:{type:"forwardMouse",event:e}:ge(l,t,s.rightTop)?{type:"clickMonitor"}:{type:"none"}};var Zt=async e=>{let s=e?.includes("--dry-run")??!1,{root:n}=await Le();if(!await De(n))return console.error("noskills is not initialized. Run:",re(),"init"),ye({exitCode:1});let l=(await W(n)).specs.map(c=>({name:c.name,phase:c.phase,hasActiveSession:!1})),t=ke(),{cols:b,rows:E}=C.getTerminalSize(),v=(c,d)=>{let o=E-1,p=F=>({id:F,x:0,y:0,width:0,height:0});if(!c&&!d)return{left:p("left"),rightTop:p("rightTop"),rightBottom:{id:"rightBottom",x:1,y:2,width:b,height:o-1},statusBar:{id:"statusBar",x:1,y:E,width:b,height:1}};let S=c?Math.min(Math.floor(b*.25),b):0,D=Math.floor(o*(d?.35:0)),O=[];d&&O.push({id:"rightTop",size:{type:"fixed",value:D}}),O.push({id:"rightBottom",size:{type:"flex",grow:1}});let V=[];c&&V.push({id:"left",size:{type:"fixed",value:S}}),V.push({direction:"column",size:{type:"flex",grow:1},children:O});let Fe={direction:"column",children:[{direction:"row",size:{type:"flex",grow:1},children:V},{id:"statusBar",size:{type:"fixed",value:1}}]},_e=ee.computeLayout(Fe,b,E),j=F=>{let _=ee.findPanel(_e,F);return _===void 0?p(F):{id:F,x:_.x+1,y:_.y+1,width:_.width,height:_.height}},$e=j("left"),ze=j("rightTop"),G=j("rightBottom"),qe=j("statusBar"),je=G.y+1,Ke=G.height-1;return{left:c?$e:p("left"),rightTop:d?ze:p("rightTop"),rightBottom:{...G,y:je,height:Ke},statusBar:qe}},g=v(t.specsVisible,t.monitorVisible),P=()=>({cols:g.rightBottom.width-2,rows:g.rightBottom.height-2}),w=new TextEncoder,h=c=>{$.process.writeToStdout(w.encode(c))};if(s){h(C.clearScreenSeq());let c=` noskills manager | ${l.length} spec(s) | ${re()} | Ctrl+C to quit`;h(a.moveTo(g.statusBar.y,g.statusBar.x)),h(a.inverse(a.truncate(c,g.statusBar.width))),h(ce(l,t.tabs,t.selectedTabIndex,g.left));let d=k(t);return h(le(d,g.rightTop)),h(de(d,g.rightBottom,t.tabs,t.selectedTabIndex)),h(a.moveTo(E,1)),h(`
|
|
4
|
+
`),Q(void 0)}let I=new be,u=null,i=async()=>{for(let c of["claude","claude-code"])try{if(await he`which ${c}`.noThrow().code()===0)return c}catch{}return"claude"},m=A(l,t.tabs);t.selectedTabIndex=K.nextSelectableIndex(m,-1,"down");let T=async()=>{let c=ne();await se(n,{id:c,spec:null,mode:"free",phase:null,pid:0,startedAt:new Date().toISOString(),lastActiveAt:new Date().toISOString(),tool:"claude-code"});let d=P(),y=new Z(d.rows,d.cols),o={id:`tab-${c}`,spec:null,mode:"free",sessionId:c,process:null,buffer:[],widget:y,active:!0,phase:null};try{let p=await i(),S=await H({command:p,cwd:n,env:{...$.env.toObject(),NOSKILLS_SESSION:c,NOSKILLS_PROJECT_ROOT:n},cols:d.cols,rows:d.rows});o.process=S,I.add(o.id,S),S.onData(x=>{y.write(x),pe(o,x),u?.()}),S.exitCode.then(()=>{Object.assign(t,X(t,o.id)),m=A(l,t.tabs),L(),t.running&&R()}).catch(()=>{})}catch(p){let S=p instanceof Error?p.message:String(p);y.write(`[noskills manager] Failed to spawn claude: ${S}\r
|
|
5
|
+
`),y.write(`Is Claude Code installed? Set command in manifest.yml\r
|
|
6
|
+
`)}Object.assign(t,ue(t,o)),t.focus="terminal",m=A(l,t.tabs)},M=async c=>{let d=t.tabs.find(D=>D.spec===c);if(d!==void 0){let D=t.tabs.indexOf(d);Object.assign(t,Ve(t,D)),t.focus="terminal";return}let y=null;try{y=(await te(n,c)).phase}catch{}let o=ne();await se(n,{id:o,spec:c,mode:"spec",phase:y,pid:0,startedAt:new Date().toISOString(),lastActiveAt:new Date().toISOString(),tool:"claude-code"});let p=P(),S=new Z(p.rows,p.cols),x={id:`tab-${o}`,spec:c,mode:"spec",sessionId:o,process:null,buffer:[],widget:S,active:!0,phase:y};try{let D=await i(),O=await H({command:D,cwd:n,env:{...$.env.toObject(),NOSKILLS_SESSION:o,NOSKILLS_PROJECT_ROOT:n},cols:p.cols,rows:p.rows});x.process=O,I.add(x.id,O),O.onData(V=>{S.write(V),pe(x,V),u?.()}),O.exitCode.then(()=>{Object.assign(t,X(t,x.id)),m=A(l,t.tabs),L(),t.running&&R()}).catch(()=>{})}catch(D){let O=D instanceof Error?D.message:String(D);S.write(`[noskills manager] Failed to spawn claude for spec "${c}": ${O}\r
|
|
7
|
+
`)}Object.assign(t,ue(t,x)),t.focus="terminal",m=A(l,t.tabs)};await T(),h(C.enterAlternateScreen()),h(C.hideCursorSeq()),h(C.clearScreenSeq()),h(J.enableMouse());let f=new Set(["specs","monitor","terminal","status"]),R=()=>{let c=k(t),d=[];if(d.push(C.hideCursorSeq()),f.size>=4&&d.push("\x1B[2J\x1B[H"),f.has("status")||f.size===0){let o=t.focus==="list"?"LIST":"TERM",p=`ctrl+e: ${t.specsVisible?"hide":"show"} specs | ctrl+w: ${t.monitorVisible?"hide":"show"} monitor`,S=t.focus==="terminal"?"esc: panels | ctrl+c: quit":`esc/tab: switch | ctrl+d: quit | ctrl+t: new tab | ${p}`,x=` noskills | ${t.tabs.length} tab(s) | [${o}] ${S}`;d.push(a.moveTo(g.statusBar.y,g.statusBar.x)),d.push(a.inverse(a.truncate(x,g.statusBar.width)+" ".repeat(Math.max(0,g.statusBar.width-a.visibleLength(x)))))}t.specsVisible&&f.has("specs")&&d.push(ce(l,t.tabs,t.selectedTabIndex,g.left)),t.monitorVisible&&f.has("monitor")&&d.push(le(c,g.rightTop)),f.has("terminal")&&d.push(de(c,g.rightBottom,t.tabs,t.selectedTabIndex));let y=k(t);if(y?.widget!==null&&y?.widget!==void 0){let o=g.rightBottom.y+1+y.widget.terminal.cursorRow,p=g.rightBottom.x+1+y.widget.terminal.cursorCol;d.push(a.moveTo(o,p))}d.push(C.showCursorSeq()),f.clear(),h(d.join(""))},L=()=>{f.add("specs"),f.add("monitor"),f.add("terminal"),f.add("status")},N=!1;u=()=>{f.add("terminal"),!N&&(N=!0,setTimeout(()=>{N=!1,t.running&&R()},16))};let Y=oe(n,async()=>{try{let c=await W(n);l.length=0;for(let d of c.specs)l.push({name:d.name,phase:d.phase,hasActiveSession:!1});m=A(l,t.tabs),f.add("specs"),f.add("monitor"),t.running&&R()}catch{}});L(),R();let U=async c=>{let d=Ue(c,g,m,t.focus);switch(d.type){case"clickSpec":{t.focus="list",t.selectedTabIndex=d.index;let y=l.find(o=>o.name===m[d.index]?.label)?.name;if(y!==void 0){await M(y),L();return}f.add("specs"),f.add("monitor"),f.add("status");break}case"clickTerminal":{t.focus="terminal",f.add("status");break}case"clickMonitor":{t.focus="list",f.add("status");break}case"scrollSpecs":{Object.assign(t,fe(t,d.direction,m)),f.add("specs"),f.add("monitor");break}case"scrollTerminal":{let y=k(t);if(y?.process!==null&&y!==null){let o=d.direction==="up"?"\x1B[A":"\x1B[B";y.process?.write(o.repeat(3))}break}case"forwardMouse":{t.focus="terminal",f.add("status");let y=k(t);if(y?.process!==null&&y!==null){let o=c.x+1-g.rightBottom.x,p=c.y+1-g.rightBottom.y,S=c.button;c.type==="mousemove"&&(S|=32),c.type==="wheel"&&(S=64|(c.direction==="down"?1:0)),c.shift&&(S|=4),c.ctrl&&(S|=16);let x=c.type==="mouseup"?"m":"M";y.process?.write(`\x1B[<${S};${o};${p}${x}`)}break}case"none":break}};try{await Se(async()=>{for await(let c of we($.process.stdin)){if(!t.running)break;if(c.kind==="mouse"){await U(c.event),f.size>0&&R();continue}let d=c.event;if(t.focus==="terminal"){let o=me(t,d.name,d.ctrl);if(o.type==="passthrough"||o.type==="none"){let p=k(t);p?.process!==null&&p!==null&&p.process?.write(new TextDecoder().decode(d.raw));continue}}let y=me(t,d.name,d.ctrl);switch(y.type){case"quit":t.running=!1;break;case"toggleFocus":Object.assign(t,Ne(t)),f.add("status");break;case"navigate":Object.assign(t,fe(t,y.direction,m)),f.add("specs"),f.add("monitor"),f.add("terminal");break;case"newTab":await T(),L();break;case"toggleSpecs":{t.specsVisible=!t.specsVisible,!t.specsVisible&&!t.monitorVisible&&(t.focus="terminal"),g=v(t.specsVisible,t.monitorVisible);let o=P();for(let p of t.tabs)p.process!==null&&p.process.resize(o.cols,o.rows),p.widget!==null&&p.widget.resize(o.rows,o.cols);L();break}case"toggleMonitor":{t.monitorVisible=!t.monitorVisible,!t.specsVisible&&!t.monitorVisible&&(t.focus="terminal"),g=v(t.specsVisible,t.monitorVisible);let o=P();for(let p of t.tabs)p.process!==null&&p.process.resize(o.cols,o.rows),p.widget!==null&&p.widget.resize(o.rows,o.cols);L();break}case"select":{let o=m[t.selectedTabIndex];if(o===void 0)break;let p=o.label;{let S=l.find(x=>x.name===p)?.name;S!==void 0&&await M(S)}L();break}case"closeTab":{let o=k(t);o!==null&&(o.process!==null&&I.remove(o.id),await Me(n,o.sessionId),Object.assign(t,X(t,o.id)),m=A(l,t.tabs),t.focus="list"),L();break}case"passthrough":{let o=k(t);o?.process!==null&&o!==null&&o.process?.write(new TextDecoder().decode(d.raw));break}case"none":break}if(!t.running)break;f.size>0&&R()}})}finally{Y(),await I.killAll(),I.forceKillAll(),await Re(n),h(J.disableMouse()),h(C.showCursorSeq()),h(C.exitAlternateScreen())}return Q(void 0)};export{Zt as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g}from"./chunk-YTLTR452.js";import"./chunk-L5OC7F24.js";import"./chunk-J2Z7NG2X.js";import"./chunk-SHN5MT56.js";import"./chunk-YVN2NZL4.js";import"./chunk-VKB3B2FE.js";import"./chunk-IHHITZU2.js";import"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";export{d as completionsHandler,f as doctorHandler,g as infoHandler,a as installHandler,b as uninstallHandler,c as updateHandler,e as versionHandler};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import"./chunk-5WJ6AUNY.js";var B={EserAjanVersion:{parameters:[],result:"pointer"},EserAjanInit:{parameters:[],result:"i32"},EserAjanShutdown:{parameters:[],result:"void"},EserAjanFree:{parameters:["pointer"],result:"void"},EserAjanConfigLoad:{parameters:["pointer"],result:"pointer"},EserAjanDIResolve:{parameters:["pointer"],result:"pointer"}},D=e=>{let r=new TextEncoder().encode(e),t=new ArrayBuffer(r.length+1),o=new Uint8Array(t);return o.set(r),o},v=e=>e===null?{value:"",ptr:e}:{value:new Deno.UnsafePointerView(e).getCString(),ptr:e},T=e=>{let n=r=>{r!==null&&e.EserAjanFree(r)};return{EserAjanVersion:()=>{let{value:r,ptr:t}=v(e.EserAjanVersion());return n(t),r},EserAjanInit:()=>e.EserAjanInit(),EserAjanShutdown:()=>{e.EserAjanShutdown()},EserAjanFree:r=>{e.EserAjanFree(r)},EserAjanConfigLoad:r=>{let t=D(r),o=e.EserAjanConfigLoad(Deno.UnsafePointer.of(t)),{value:a,ptr:s}=v(o);return n(s),a},EserAjanDIResolve:r=>{let t=D(r),o=e.EserAjanDIResolve(Deno.UnsafePointer.of(t)),{value:a,ptr:s}=v(o);return n(s),a}}},L={name:"deno",available:()=>typeof Deno<"u"&&typeof Deno.dlopen=="function",open:e=>{let n=Deno.dlopen(e,B);return Promise.resolve({symbols:T(n.symbols),close:()=>{n.close()}})}};var S={name:"bun",available:()=>typeof globalThis.Bun<"u",open:async e=>{let n=await import("bun:ffi"),{dlopen:r,CString:t,ptr:o}=n,a=r(e,{EserAjanVersion:{args:[],returns:"ptr"},EserAjanInit:{args:[],returns:"i32"},EserAjanShutdown:{args:[],returns:"void"},EserAjanFree:{args:["ptr"],returns:"void"},EserAjanConfigLoad:{args:["ptr"],returns:"ptr"},EserAjanDIResolve:{args:["ptr"],returns:"ptr"}}),{symbols:s}=a,i=d=>{let g=new TextEncoder().encode(d+"\0");return o(g)},c=d=>{if(d===null||d===0)return"";let f=new t(d);return s.EserAjanFree(d),f.toString()};return{symbols:{EserAjanVersion:()=>c(s.EserAjanVersion()),EserAjanInit:()=>s.EserAjanInit(),EserAjanShutdown:()=>{s.EserAjanShutdown()},EserAjanFree:d=>{s.EserAjanFree(d)},EserAjanConfigLoad:d=>c(s.EserAjanConfigLoad(i(d))),EserAjanDIResolve:d=>c(s.EserAjanDIResolve(i(d)))},close:()=>{a.close()}}}};var _={name:"node",available:()=>{let e=globalThis;return typeof e.process<"u"&&typeof e.process.versions?.node=="string"&&typeof e.Deno>"u"&&typeof e.Bun>"u"},open:async e=>{let n=await import("koffi");if(n.default!==void 0&&(n=n.default),typeof n.load!="function")throw new Error("koffi module loaded but koffi.load is not a function. Check your koffi version (requires ^2.15.0).");let r=n.load(e),t=r.func("char* EserAjanVersion()"),o=r.func("int EserAjanInit()"),a=r.func("void EserAjanShutdown()"),s=r.func("char* EserAjanConfigLoad(const char* path)"),i=r.func("char* EserAjanDIResolve(const char* name)");return{symbols:{EserAjanVersion:()=>t()??"",EserAjanInit:()=>o(),EserAjanShutdown:()=>{a()},EserAjanFree:c=>{},EserAjanConfigLoad:c=>s(c)??"",EserAjanDIResolve:c=>i(c)??""},close:()=>{r.unload()}}}};var J=await import("node:fs"),j=()=>{let e=globalThis;if(typeof e.Deno<"u"){let n=e.Deno.build.os;return n==="darwin"?".dylib":n==="windows"?".dll":".so"}if(typeof e.process<"u"&&typeof e.process.platform=="string"){let n=e.process.platform;return n==="darwin"?".dylib":n==="win32"?".dll":".so"}return".so"},W=()=>{let e=globalThis,n="linux",r="x64";if(typeof e.Deno<"u"){let t=e.Deno.build.os;n=t==="windows"?"win32":t,r=e.Deno.build.arch==="aarch64"?"arm64":"x64"}else typeof e.process<"u"&&(n=e.process.platform,r=e.process.arch==="arm64"?"arm64":"x64");return`${n}-${r}`},l=e=>{try{return J.statSync(e),!0}catch{return!1}},O=e=>{if(e!==void 0)return e;let n=globalThis;return typeof n.__dirname=="string"?n.__dirname:typeof n.process<"u"&&typeof n.process.cwd=="function"?n.process.cwd():"."},w=e=>{let r=`libeser_ajan${j()}`,t=[],o=U("ESER_AJAN_LIB_PATH");if(o!==void 0){if(l(o))return o;t.push(`$ESER_AJAN_LIB_PATH = ${o}`)}let a=O(e),s=`${a}/${r}`;if(t.push(s),l(s))return s;let i=W(),c={x64:"x86_64",arm64:"aarch64"},d={win32:"windows"},f=i.split("-"),g=f[0]??"linux",I=f[1]??"x64",$=c[I]??I,R=d[g]??g,y=`${$}-${R}`,k=`${a}/..`,b=`${k}/dist/${y}/${r}`;if(t.push(b),l(b))return b;let A=`${a}/dist/${y}/${r}`;if(t.push(A),l(A))return A;let E=globalThis,m=typeof E.process<"u"&&typeof E.process.cwd=="function"?E.process.cwd():".";if(m!==a){let u=`${m}/pkg/@eser/ajan/dist/${y}/${r}`;if(t.push(u),l(u))return u}let P=[a,k,m];for(let u of P){let h=`${u}/node_modules/@eserstack/ajan-${i}/${r}`;if(t.push(h),l(h))return h}let N=[`/usr/local/lib/${r}`,`/usr/lib/${r}`];for(let u of N)if(t.push(u),l(u))return u;throw new Error(`Could not find eser-ajan shared library (${r}).
|
|
3
|
+
Checked the following locations:
|
|
4
|
+
`+t.map(u=>` - ${u}`).join(`
|
|
5
|
+
`)+`
|
|
6
|
+
|
|
7
|
+
To fix this:
|
|
8
|
+
1. Install: npm install @eser/ajan
|
|
9
|
+
2. Or set ESER_AJAN_LIB_PATH to the full path of ${r}`)},U=e=>{let n=globalThis;if(typeof n.process<"u"&&typeof n.process.env=="object")return n.process.env[e]??void 0};var K=e=>{try{let n=globalThis;if(typeof n.process<"u"&&n.process.env!=null)return n.process.env[e]}catch{}},p=e=>{let n=K(e);return n!==void 0&&n.toLowerCase()==="disabled"},F=e=>{console.debug(`[eser-ajan/ffi] ${e}`)},x=import.meta.dirname,G=j,Q=e=>w(e??x),q=[L,S,_],Y=()=>{let e=globalThis;return typeof e.Deno<"u"&&typeof e.Deno.dlopen=="function"?"deno":typeof e.Bun<"u"?"bun":typeof e.process<"u"&&typeof e.process.versions?.node=="string"&&typeof e.Deno>"u"&&typeof e.Bun>"u"?"node":"unknown"},z=()=>{for(let n of q)if(n.available())return n;let e=Y();throw new Error(`No FFI backend available for runtime "${e}".
|
|
10
|
+
Supported runtimes:
|
|
11
|
+
- Deno 2.7+ (Deno.dlopen)
|
|
12
|
+
- Bun 1.3+ (bun:ffi)
|
|
13
|
+
- Node 25+ (node:ffi, experimental)
|
|
14
|
+
|
|
15
|
+
Current runtime: ${e}`)},X=async(e,n)=>{let r=typeof e=="string"?e:void 0,t=typeof e=="object"?e:n;if(p("ESER_AJAN"))throw F("ALL disabled \u2014 ESER_AJAN=disabled"),new Error(`Ajan is disabled via ESER_AJAN=disabled environment variable.
|
|
16
|
+
Unset ESER_AJAN to re-enable.`);let o=!p("ESER_AJAN_NATIVE")&&t?.native!==!1,a=!p("ESER_AJAN_WASM")&&t?.wasm!==!1;if(o||F("Native FFI disabled \u2014 skipping to WASM fallback"),a||F("WASM fallback disabled"),o)try{let i=r??w(x);return await z().open(i)}catch{}if(a)try{return await(await import("./mod-HZDU4RQ6.js")).loadEserAjanWasm()}catch(i){throw new Error(`No native FFI backend available and WASM fallback failed.
|
|
17
|
+
WASM error: ${i instanceof Error?i.message:String(i)}
|
|
18
|
+
|
|
19
|
+
To fix this, install the @eser/ajan package or build the native library.
|
|
20
|
+
See: https://github.com/eser/stack/tree/main/pkg/@eser/ajan`)}let s=[];throw o||s.push(p("ESER_AJAN_NATIVE")?"ESER_AJAN_NATIVE=disabled":"native=false in LoadOptions"),a||s.push(p("ESER_AJAN_WASM")?"ESER_AJAN_WASM=disabled":"wasm=false in LoadOptions"),new Error(`All FFI backends are disabled.
|
|
21
|
+
Reasons: ${s.join(", ")}
|
|
22
|
+
|
|
23
|
+
To fix this, unset the relevant environment variables or adjust LoadOptions.`)};export{Y as detectRuntime,G as getLibraryExtension,X as loadEserAjan,Q as resolveLibraryPath,z as selectBackend};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as ie}from"./chunk-5YBG2HOI.js";import{a as ye}from"./chunk-NTY267SI.js";import"./chunk-L5OC7F24.js";import{a as z}from"./chunk-P4SPHY3G.js";import{a as he,b as ge,c as Se}from"./chunk-4KDDHQVL.js";import"./chunk-PPB6ACBB.js";import{a as K,c as Y,e as X}from"./chunk-4JICYXYK.js";import"./chunk-KFVUFHJB.js";import{a as G}from"./chunk-NY4W44PI.js";import{a as ve,b as we,d as P}from"./chunk-2ZYCRMUT.js";import{a as Ee}from"./chunk-LEG3PWOU.js";import{a as H}from"./chunk-ODBJ5KMQ.js";import{a as Oe,b as Re,c as Fe,d as Te}from"./chunk-DI7OHJ53.js";import{h as W}from"./chunk-L32KHQVT.js";import{a as xe,b as Ce,c as Z,d as Ie,e as De,f as ee,g as F,h as te,i as J,j as se,k as Pe,m as ke,o as ne,p as be,v as Ae}from"./chunk-E4WXXNF6.js";import{A as me,B as fe,a as ae,c as R,e as oe,f as ce,j as le,k as de,l as pe,p as ue,r as _,w as B}from"./chunk-LOZLXP5G.js";import{c as V}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{a as q,b as E}from"./chunk-FFWPJP7A.js";import{i as D}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var ot=async l=>{let{root:e}=await fe(),r=ve(l),u=we(l);if(!await me(e))return await P({error:`noskills not initialized. Run: ${V("init")}`},r),E({exitCode:1});let n=null;for(let f of u)f.startsWith("--answer=")&&(n=f.slice(9));let s=ce(u),t;try{t=await oe(e,s)}catch(f){let h=f instanceof Error?f.message:String(f);return await P({error:h},r),E({exitCode:1})}if(s===null&&t.phase!=="IDLE"&&t.phase!=="COMPLETED")return await P({error:"Error: --spec=<name> is required. Use `noskills spec list` to see available specs."},r),E({exitCode:1});let a=await pe(e);if(a?.command!==void 0){let{setCommandPrefix:f}=await import("./cmd-QE4P4DS4.js");f(a.command)}if(a===null)return await P({error:"No config found"},r),E({exitCode:1});if(t.spec!==null&&t.phase!=="IDLE"&&t.phase!=="COMPLETED"){let f=`${e}/${R.specDir(t.spec)}`;try{await D.fs.stat(f)}catch{return await P({error:!0,message:`Active spec '${t.spec}' directory not found. Files may have been deleted manually.`,suggestion:`Run \`${V("reset")}\` to return to idle, or \`${V("cancel")}\` to mark as cancelled.`},r),E({exitCode:1})}}let i=ye(u,a);t.phase==="DISCOVERY"&&t.discovery.audience!==i&&(t={...t,discovery:{...t.discovery,audience:i}});let d=(await ue(e)).filter(f=>a.concerns.includes(f.id));if(n!==null){let f=await W(e),h=await Me(e,t,a,d,n,f);await _(e,h);let g={...h,lastCalledAt:new Date().toISOString()};await _(e,g);let N=D.env.get("NOSKILLS_SESSION")??null;N!==null&&await B(e,N,g.phase);let M=await K(e),{tier1:j,tier2Count:w}=Y(M,g.phase),k=g.spec!==null?await H(e,g.spec):null,A=await $e(e,g),I=await ie(e,A),C=X(a?.tools??[]),S=await W(e),b=await z(g,d,j,a,k,I,void 0,C,S,w,e),Q=n.trim().toLowerCase()==="save",Le=g.phase===t.phase;if(Q&&Le&&(g.phase==="SPEC_PROPOSAL"||g.phase==="SPEC_APPROVED")){let Ue=g.phase==="SPEC_PROPOSAL"?"Spec draft saved. The spec stays in DRAFT and can be reviewed by anyone. Other users can add ACs (`ac add`), notes (`note add`), or tasks (`task add`) while in draft. When ready, any user can approve with `noskills spec <name> approve`.":'Spec is approved and parked. Others can still add ACs or notes. When ready, run `noskills next --answer="start"` to begin execution.',Ne={...b,instruction:Ue,saved:!0};return await P(Ne,r),q(void 0)}return await P(b,r),q(void 0)}let c={...t,lastCalledAt:new Date().toISOString()};await _(e,c);let m=D.env.get("NOSKILLS_SESSION")??null;m!==null&&await B(e,m,c.phase);let p=await K(e),{tier1:v,tier2Count:x}=Y(p,c.phase),y=c.spec!==null?await H(e,c.spec):null,T=await $e(e,c),$=await ie(e,T),L;c.phase==="IDLE"&&(L={existingSpecs:(await de(e)).map(h=>({name:h.name,phase:h.state.phase,iteration:h.state.execution.iteration,detail:h.state.phase==="EXECUTING"?`${h.state.execution.completedTasks.length} tasks done, iteration ${h.state.execution.iteration}`:h.state.phase==="SPEC_PROPOSAL"?"awaiting approval":h.state.phase==="COMPLETED"?"completed":void 0})),rulesCount:v.length});let U=X(a?.tools??[]),re=await W(e),O=await z(c,d,v,a,y,$,L,U,re,x,e);return await P(O,r),q(void 0)},Me=async(l,e,r,u,n,s)=>{switch(e.phase){case"DISCOVERY":{let t=e.discovery.userContext!==void 0&&e.discovery.userContext.length>0,a=e.specDescription!==null&&e.specDescription.length>0,i=e.discovery.mode;if(!t&&i===void 0&&a)return Ae(e,n);if(i===void 0&&a)return["full","validate","technical-depth","ship-fast","explore"].includes(n)?Z(e,n):Z(e,"full");let o=e.discovery.premisesCompleted===!0;if(i!==void 0&&!o){try{let p=JSON.parse(n);if(p!==null&&typeof p=="object"&&"premises"in p){let x=p.premises.map(y=>({text:y.text??"",agreed:y.agreed??!0,revision:y.revision,user:s?.name??"Unknown User",timestamp:new Date().toISOString()}));if(x.length===0)throw new Error("Premise challenge requires at least one premise. Empty array rejected.");return Ie(e,x)}}catch{throw new Error("Premise challenge requires valid JSON with premises array. Re-prompt the user.")}throw new Error("Premise challenge requires a premises array. Cannot skip with empty input.")}let d=e.discovery.audience==="agent",c=null;try{let p=JSON.parse(n);typeof p=="object"&&p!==null&&!Array.isArray(p)&&(d?he.map(y=>y.id).every(y=>y in p)&&(c=p):c=p)}catch{}let m=e;if(c!==null){for(let[p,v]of Object.entries(c))typeof v=="string"&&v.length>0&&(m=F(m,p,v,s));m={...m,discovery:{...m.discovery,batchSubmitted:!0}}}else{let p=ge(u),v=m.discovery.currentQuestion,x=p[v];if(x===void 0)return e;m=F(m,x.id,n,s),m=Pe(m)}return Se(m.discovery.answers)&&(m=te(m)),m}case"DISCOVERY_REFINEMENT":{let t=n.trim().toLowerCase();if(t==="approve"){let i=G(e.discovery.answers);return i.detected&&i.proposals.length>=2?se(e):e.discovery.mode!==void 0?se(e):J(e)}if(t==="split")return await je(l,e);if(t==="keep"){let i=ne(e,{id:`decision-split-keep-${Date.now()}`,question:"Split spec into separate areas?",choice:"Chose to keep as single spec despite multiple areas detected",promoted:!1,timestamp:new Date().toISOString()});return J(i)}let a=e.discovery.alternativesPresented===!0;if(e.discovery.approved&&!a){let i;if(t==="skip"||t==="none")i=ee(e);else{let o=!1;try{let d=JSON.parse(n);if(d!==null&&typeof d=="object"&&"approach"in d){let c={id:String(d.approach),name:String(d.name??d.approach),summary:String(d.summary??""),effort:String(d.effort??""),risk:String(d.risk??""),user:s?.name??"Unknown User",timestamp:new Date().toISOString()};i=De(e,c),o=!0}}catch{}o||(i=ee(e))}return J(i)}try{let i=JSON.parse(n);if(typeof i.revise=="object"&&i.revise!==null){let o=e;for(let[d,c]of Object.entries(i.revise))typeof c=="string"&&c.length>0&&(o=F(o,d,c,s));return o}}catch{}return e}case"SPEC_PROPOSAL":{if(n.trim().toLowerCase()==="save")return e;if(e.classification===null){let t,a=n.trim().toLowerCase();if(a==="none"||a==="skip")t={involvesWebUI:!1,involvesCLI:!1,involvesPublicAPI:!1,involvesMigration:!1,involvesDataHandling:!1};else try{let o=JSON.parse(n);t={involvesWebUI:o.involvesWebUI===!0||o.involvesUI===!0,involvesCLI:o.involvesCLI===!0||o.involvesUI===!0,involvesPublicAPI:o.involvesPublicAPI===!0,involvesMigration:o.involvesMigration===!0,involvesDataHandling:o.involvesDataHandling===!0}}catch{t={involvesWebUI:!1,involvesCLI:!1,involvesPublicAPI:!1,involvesMigration:!1,involvesDataHandling:!1}}let i={...e,classification:t};try{await Ee(l,i,u)}catch{}return i}try{let t=JSON.parse(n);if(typeof t.refinement=="string"&&t.refinement.length>0){let a=t.refinement;if(e.spec!==null){let i=`${l}/${R.specFile(e.spec)}`,o=await D.fs.readTextFile(i);if(a.includes("task-")){let c=qe(a).map(v=>`- [ ] ${v}`).join(`
|
|
3
|
+
`),m=/## Tasks\n\n([\s\S]*?)(?=\n## |\n*$)/,p=o.replace(m,`## Tasks
|
|
4
|
+
|
|
5
|
+
${c}
|
|
6
|
+
`);await D.fs.writeTextFile(i,p)}}return e}}catch{}return e}case"SPEC_APPROVED":{if(n.trim().toLowerCase()==="save")return e;let t=ke(e);return t.spec!==null&&(await Oe(l,t.spec,"executing"),await Te(l,t.spec,"executing")),t}case"EXECUTING":{if(!e.execution.awaitingStatusReport){let t={...e,execution:{...e.execution,lastProgress:n}};if(r.verifyCommand!==null&&r.verifyCommand!==void 0&&r.verifyCommand.length>0){let a=await Ve(l,r.verifyCommand);if(t={...t,execution:{...t.execution,lastVerification:a}},!a.passed)return t}return t={...t,execution:{...t.execution,awaitingStatusReport:!0}},t}return await _e(l,e,n,u)}case"BLOCKED":{let t=e.execution.lastProgress??"Unknown",a={id:`d${e.decisions.length+1}`,question:t.replace(/^BLOCKED:\s*/,""),choice:n,promoted:!1,timestamp:new Date().toISOString()},i=ne(e,a);return i=xe(i,"EXECUTING"),i={...i,execution:{...i.execution,lastProgress:`Resolved: ${n}`}},i}default:return e}},je=async(l,e)=>{let r=G(e.discovery.answers);if(!r.detected||r.proposals.length===0)return e;let u=[];for(let s of r.proposals){let t=`${l}/${R.specDir(s.name)}`;await D.fs.mkdir(t,{recursive:!0});let a=e.discovery.answers.filter(d=>s.relevantAnswers.includes(d.questionId)),o=Ce(ae(),s.name,`spec/${s.name}`);for(let d of a)o=F(o,d.questionId,d.answer);o=te(o),await le(l,s.name,o),u.push(s.name)}return be(e,"cancelled",`Split into: ${u.join(", ")}`)},qe=l=>l.split(/(?=task-\d+:)/).map(e=>e.replace(/[,;\n\s]+$/,"").trim()).filter(e=>/^task-\d+:/.test(e)),_e=async(l,e,r,u)=>{let n;try{n=JSON.parse(r)}catch{return{...e,execution:{...e.execution,lastProgress:r,awaitingStatusReport:!1}}}let s=e;if(e.execution.debt!==null&&e.execution.debt.items.length>0&&typeof e.execution.debt.items[0]=="string"){let k=e.execution.debt.items.map((C,S)=>({id:`legacy-${S+1}`,text:C,since:e.execution.debt.fromIteration}));s={...e,execution:{...e.execution,debt:{...e.execution.debt,items:k}}};let A=new TextEncoder,I=D.process.stderr.getWriter();await I.write(A.encode(`noskills: migrated legacy string[] debt to DebtItem[] format
|
|
7
|
+
`)),I.releaseLock()}let t=new Set(["mandatory-tests","mandatory-docs"]),i=(n.na??[]).filter(w=>t.has(w));if(i.length>0)return{...s,execution:{...s.execution,lastProgress:`REJECTED: Tests and documentation ACs require explicit justification to mark as N/A. Explain why tests or docs are not needed for this spec. Rejected IDs: ${i.join(", ")}`,awaitingStatusReport:!0}};let o=n.completed??[],d=new Set(o),c=n.na??[],m=new Set(c),p=n.newIssues??[],v=n.remaining??[],x=n.blocked??[],y=s.execution.debt?.unaddressedIterations??0,T=s.execution.debt!==null?s.execution.debt.items.filter(w=>!d.has(w.id)&&!m.has(w.id)):[],$=s.execution.debtCounter??0,L=p.map((w,k)=>({id:`debt-${$+k+1}`,text:w,since:s.execution.iteration})),U=[...T,...L],O=v.length===0&&x.length===0&&p.length===0||U.length===0?null:{items:U,fromIteration:s.execution.debt?.fromIteration??s.execution.iteration,unaddressedIterations:T.length>0?y+1:1},f=[...new Set([...s.execution.naItems??[],...c])],h=[];o.length>0&&h.push(`Completed: ${o.join(", ")}`),c.length>0&&h.push(`N/A: ${c.join(", ")}`);let g=h.length>0?h.join("; "):"Status report submitted",N=s.execution.lastVerification===null||s.execution.lastVerification.passed===!0,M=O===null&&N,j=$+p.length;if(M&&s.spec!==null){let w=await H(l,s.spec);if(w!==null){let k=s.execution.completedTasks??[],A=new Set(k),I=[];try{let S=JSON.parse(s.execution.lastProgress??"");Array.isArray(S.completed)&&(I=S.completed.filter(b=>!A.has(b)&&w.tasks.some(Q=>Q.id===b)))}catch{}if(I.length===0){let S=w.tasks.find(b=>!A.has(b.id));S!==void 0&&(I=[S.id])}let C=[];for(let S of I)await Re(l,s.spec,S),await Fe(l,s.spec,S,"done"),C.push(S);if(C.length>0){let S=C.length===1?`Task ${C[0]} accepted`:`Tasks ${C.join(", ")} accepted`;return{...s,execution:{...s.execution,lastProgress:`${S}: ${g}`,awaitingStatusReport:!1,debt:O,completedTasks:[...k,...C],debtCounter:j,naItems:f}}}}}return{...s,execution:{...s.execution,lastProgress:M?g:`Task not accepted \u2014 remaining items must be addressed first. ${g}`,awaitingStatusReport:!1,debt:O,debtCounter:j,naItems:f}}},Ve=async(l,e)=>{try{let{execSync:r}=await import("node:child_process"),u=r(e,{cwd:l,encoding:"utf-8",timeout:6e4,stdio:["pipe","pipe","pipe"]});return{passed:!0,output:String(u).slice(0,4e3),timestamp:new Date().toISOString()}}catch(r){let u=r,n=((u.stdout??"")+(u.stderr??"")).slice(0,4e3);return u.status!==void 0?{passed:!1,output:n||"Verification failed with no output",timestamp:new Date().toISOString()}:{passed:!1,output:`Verification command failed to execute: ${r instanceof Error?r.message:String(r)}`,timestamp:new Date().toISOString()}}},$e=async(l,e)=>{let r=[...e.execution.modifiedFiles??[]],u=await Je(l);return[...new Set([...r,...u])]},Je=async l=>{let e=`${l}/${R.stateDir}/files-changed.jsonl`;try{let u=(await D.fs.readTextFile(e)).trim().split(`
|
|
8
|
+
`).filter(Boolean),n=[];for(let s of u)try{let t=JSON.parse(s);n.includes(t.file)||n.push(t.file)}catch{}return n}catch{return[]}};export{Me as handleAnswer,ot as main,qe as parseRefinementTasks};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as E}from"./chunk-L32KHQVT.js";import{q as y,s as C}from"./chunk-
|
|
2
|
+
import{h as E}from"./chunk-L32KHQVT.js";import{q as y,s as C}from"./chunk-E4WXXNF6.js";import{B as g,e as w,g as f,h,j as S}from"./chunk-LOZLXP5G.js";import"./chunk-2XNFZXHY.js";import{f as m,h as d,k as u}from"./chunk-SHN5MT56.js";import{d as c,f as n,g as l}from"./chunk-YVN2NZL4.js";import{a as p,b as a}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var M=async v=>{let e=m({renderer:u.ansi(),sink:d.stdout()}),{root:r}=await g(),i=f(v);if(!i.ok)return e.writeln(n(i.error)),await e.close(),a({exitCode:1});let t;try{t=await w(r,i.spec)}catch(o){let x=o instanceof Error?o.message:String(o);return e.writeln(n(x)),await e.close(),a({exitCode:1})}if(t.phase!=="COMPLETED")return e.writeln(n(`Cannot reopen in phase: ${t.phase}`)),e.writeln(c("Only COMPLETED specs can be reopened.")),await e.close(),a({exitCode:1});let k=await E(r),s=y(t);return s=C(s,"COMPLETED","DISCOVERY",k,"reopened"),await h(r,s),s.spec!==null&&await S(r,s.spec,s),e.writeln(l("\u2714")," Spec reopened. Discovery answers preserved \u2014 run `noskills next` to revise."),await e.close(),p(void 0)};export{M as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{D as v}from"./chunk-
|
|
2
|
+
import{D as v}from"./chunk-E4WXXNF6.js";import{B as I,c as h,e as g,g as y,h as S,j as k}from"./chunk-LOZLXP5G.js";import"./chunk-2XNFZXHY.js";import{f as u,h as w,k as f}from"./chunk-SHN5MT56.js";import{d as a,f as n,g as d}from"./chunk-YVN2NZL4.js";import{a as c,b as l}from"./chunk-FFWPJP7A.js";import{i as m}from"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var F=async A=>{let e=u({renderer:f.ansi(),sink:w.stdout()}),{root:i}=await I(),o=y(A);if(!o.ok)return e.writeln(n(o.error)),await e.close(),l({exitCode:1});let s;try{s=await g(i,o.spec)}catch(r){let R=r instanceof Error?r.message:String(r);return e.writeln(n(R)),await e.close(),l({exitCode:1})}if(s.phase==="IDLE"||s.phase==="UNINITIALIZED")return e.writeln(a("Already idle. Nothing to reset.")),await e.close(),c(void 0);if(s.spec!==null){let r=`${i}/${h.specDir(s.spec)}`;try{await m.fs.stat(r)}catch{e.writeln(n(`Active spec '${s.spec}' directory not found.`)),e.writeln(a("Resetting to idle anyway."))}}let t=s.spec,p=v(s);return await S(i,p),t!==null&&await k(i,t,p),e.writeln(d("\u2714")," Reset to idle."),t!==null&&e.writeln(a(`Spec "${t}" state cleared. Files in .eser/specs/${t}/ preserved.`)),await e.close(),c(void 0)};export{F as main};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as T}from"./chunk-4KDDHQVL.js";import"./chunk-PPB6ACBB.js";import{a as M}from"./chunk-YWSOQJ7G.js";import{h as P}from"./chunk-L32KHQVT.js";import{B as D}from"./chunk-
|
|
2
|
+
import{b as T}from"./chunk-4KDDHQVL.js";import"./chunk-PPB6ACBB.js";import{a as M}from"./chunk-YWSOQJ7G.js";import{h as P}from"./chunk-L32KHQVT.js";import{B as D}from"./chunk-E4WXXNF6.js";import{B as C,e as x,g as E,j as b,l as k,p as A}from"./chunk-LOZLXP5G.js";import"./chunk-2XNFZXHY.js";import{f as I,h as S,k as $}from"./chunk-SHN5MT56.js";import{c as q,d as c,f as d,g as p,h as v}from"./chunk-YVN2NZL4.js";import{a as w,b as g}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var J=async f=>{let t=I({renderer:$.ansi(),sink:S.stdout()}),{root:r}=await C(),i=E(f);if(!i.ok)return t.writeln(d(i.error)),await t.close(),g({exitCode:1});let u;try{u=await x(r,i.spec)}catch(e){let s=e instanceof Error?e.message:String(e);return t.writeln(d(s)),await t.close(),g({exitCode:1})}let o=await P(r),h=u.discovery.delegations??[],n=h.filter(e=>e.delegatedTo===o.name&&e.status==="pending"),l=h.filter(e=>e.delegatedTo===o.name&&e.status==="answered");if(n.length===0&&l.length===0)return t.writeln(c("No delegations for you on this spec.")),await t.close(),w(void 0);let N=await A(r),R=await k(r),W=N.filter(e=>R?.concerns.includes(e.id)??!1),F=T(W),y=new Map(F.map(e=>[e.id,e.text]));if(t.writeln(q(`Spec: ${i.spec}`)),t.writeln(""),n.length>0){t.writeln(v(`You have ${n.length} pending delegation(s):`)),t.writeln("");for(let e=0;e<n.length;e++){let s=n[e],Q=y.get(s.questionId)??s.questionId;t.writeln(` ${e+1}. `,d("[PENDING]"),` ${Q}`),t.writeln(c(` Delegated by: ${s.delegatedBy} (${s.delegatedAt.slice(0,10)})`))}}if(l.length>0){t.writeln(""),t.writeln(p(`${l.length} answered delegation(s):`));for(let e of l){let s=y.get(e.questionId)??e.questionId;t.writeln(" ",p("\u2714"),` ${s}`),t.writeln(c(` Answer: ${e.answer?.slice(0,80)??""}`))}}let m=null,a=null;for(let e of f??[])e.startsWith("--answer=")&&(m=e.slice(9)),e.startsWith("--question=")&&(a=parseInt(e.slice(11),10)-1);if(m!==null&&a!==null&&a>=0&&a<n.length){let e=n[a],s=D(u,e.questionId,m,o.name);await b(r,i.spec,s),await M(r,{ts:new Date().toISOString(),type:"delegation-answered",spec:i.spec,user:o.name,question:e.questionId}),t.writeln(""),t.writeln(p("\u2714"),` Answered: ${e.questionId}`)}return await t.close(),w(void 0)};export{J as main};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as B}from"./chunk-
|
|
2
|
+
import{a as B}from"./chunk-P4SPHY3G.js";import"./chunk-4KDDHQVL.js";import"./chunk-PPB6ACBB.js";import{b as W,e as X}from"./chunk-4JICYXYK.js";import"./chunk-KFVUFHJB.js";import"./chunk-NY4W44PI.js";import{a as j,m as _}from"./chunk-E4WXXNF6.js";import{A as L,B as M,d as g,e as F,f as N,h as $,l as U,p as G}from"./chunk-LOZLXP5G.js";import{b as E,c as V}from"./chunk-UEMWZOIU.js";import"./chunk-2XNFZXHY.js";import{a as T,b as D,g as A}from"./chunk-5GGWX7CO.js";import{f as I,h as R,k as O}from"./chunk-SHN5MT56.js";import{c as y,d as o,f as l,g as v,h,k as P}from"./chunk-YVN2NZL4.js";import{a as S,b as w}from"./chunk-FFWPJP7A.js";import"./chunk-6DBKPC2O.js";import"./chunk-ALFFE37K.js";import"./chunk-6G6UVWJN.js";import"./chunk-5WJ6AUNY.js";var pe=async t=>{let e=I({renderer:O.ansi(),sink:R.stdout()}),{root:i}=await M(),n=t?.includes("--unattended")??!1,r=z(t,"--max-turns")??10,p=z(t,"--max-iterations")??50;if(!await L(i))return e.writeln(l(`noskills not initialized. Run: ${V("init")}`)),await e.close(),w({exitCode:1});let x=N(t),c=await F(i,x);if(c.phase!=="EXECUTING"&&c.phase!=="SPEC_APPROVED")return e.writeln(l(`Cannot run from phase: ${c.phase}`)),e.writeln(o("Must be in SPEC_APPROVED or EXECUTING to start.")),await e.close(),w({exitCode:1});if(c.phase==="SPEC_APPROVED"){e.writeln(o("Starting execution from approved spec..."));let s=_(c);await $(i,s)}let u=await U(i);if(u===null)return e.writeln(l("Config not found.")),await e.close(),w({exitCode:1});e.writeln(y(`${E()} run`)),e.writeln(o(`Mode: ${n?"unattended":"interactive"}, max-turns: ${r}, max-iterations: ${p}`)),e.writeln("");let m=0,d=0;for(;m<p;){m++;let s=await g(i);if(s.phase==="COMPLETED"){e.writeln(""),e.writeln(v("\u2714")," Spec completed!"),e.writeln(` Iterations: ${s.execution.iteration}`),e.writeln(` Decisions: ${s.decisions.length}`);break}if(s.phase==="BLOCKED"){let a=s.execution.lastProgress??"Unknown";if(e.writeln(""),e.writeln(h("\u26A0")," Execution blocked: ",o(a)),n){await Z(i,a,m),e.writeln(o("Logged to .eser/.state/blocked.log. Resolve and re-run.")),d=1;break}let C=D(),f=await A(C,{message:"Enter resolution (or leave empty to stop):"});if(T(f)||f===""){e.writeln(o("Stopped by user."));break}let k=j(s,"EXECUTING");await $(i,{...k,execution:{...k.execution,lastProgress:`Resolved: ${f}`}});continue}if(s.phase!=="EXECUTING"){e.writeln(l(`Unexpected phase: ${s.phase}. Stopping.`)),d=1;break}let H=(await G(i)).filter(a=>u.concerns.includes(a.id)),q=await W(i),K=X(u.tools),J=await B(s,H,q,u,void 0,void 0,void 0,K),Q=Y(J);e.writeln(P(`\u2500\u2500 Iteration ${m}`),o(` (execution: ${s.execution.iteration}, debt: ${s.execution.debt?.items.length??0})`)),s.execution.lastProgress!==null&&e.writeln(o(` Last: ${s.execution.lastProgress}`)),s.execution.lastVerification?.passed===!1&&e.writeln(l(" Verification failed \u2014 agent will fix")),s.execution.debt!==null&&e.writeln(h(` Debt: ${s.execution.debt.items.length} items`)),e.writeln(o(" Spawning agent..."));try{await(await import("./mod-D5IDWU35.js")).exec`claude -p ${Q} --max-turns ${String(r)} --output-format json`.noThrow().text()}catch{e.writeln(l(" Failed to spawn claude CLI. Is it installed?")),d=1;break}e.writeln(o(" Agent exited. Stop hook captured state."));let b=await g(i);if(u.autoCommit===!0&&u.allowGit!==!1)try{let a=await import("./mod-D5IDWU35.js");if((await a.exec`git diff --name-only`.noThrow().text()).trim().length>0){await a.exec`git add -A`.noThrow().text();let f=`noskills: iteration ${b.execution.iteration} \u2014 ${b.execution.lastProgress??"progress"}`;await a.exec`git commit -m ${f}`.noThrow().text(),e.writeln(o(" Auto-committed."))}}catch{e.writeln(o(" Auto-commit failed (non-fatal)."))}}return m>=p&&(e.writeln(""),e.writeln(h("\u26A0"),` Max iterations (${p}) reached. Stopping.`),d=2),await e.close(),d!==0?w({exitCode:d}):S(void 0)},Y=t=>{let e=[];if(e.push(t.meta.resumeHint),e.push(""),t.meta.spec!==null&&(e.push(`Working on spec: ${t.meta.spec}`),e.push("")),"instruction"in t&&(e.push(t.instruction),e.push("")),"previousIterationDebt"in t){let n=t.previousIterationDebt;if(n!==void 0){e.push(`DEBT from iteration ${n.fromIteration} (address first):`);for(let r of n.items)e.push(`- ${r}`);e.push("")}}if("statusReportRequired"in t){let n=t.statusReport;if(n!==void 0){e.push("Report against these acceptance criteria:");for(let r of n.criteria)e.push(`- ${r}`);e.push("")}}if("verificationFailed"in t&&t.verificationFailed===!0&&(e.push("Test output:"),e.push(("verificationOutput"in t?t.verificationOutput:"")??""),e.push("")),t.behavioral.rules.length>0){e.push("Rules:");for(let n of t.behavioral.rules)e.push(`- ${n}`);e.push("")}if("context"in t){let n=t.context;if(n.concernReminders.length>0){e.push("Reminders:");for(let r of n.concernReminders)e.push(`- ${r}`);e.push("")}}let i=E();return e.push(`When done, report progress: ${i} next --answer="your progress"`),e.push(`If blocked, run: ${i} block "reason"`),e.push(`When all tasks are complete: ${i} done`),e.join(`
|
|
3
3
|
`)},z=(t,e)=>{if(t===void 0)return null;let i=`${e}=`;for(let n of t)if(n.startsWith(i)){let r=parseInt(n.slice(i.length),10);if(!isNaN(r)&&r>0)return r}return null},Z=async(t,e,i)=>{let n=`${t}/.eser/.state/blocked.log`,r=`[${new Date().toISOString()}] iteration=${i} reason=${e}
|
|
4
4
|
`;try{let{appendFileSync:p,mkdirSync:x}=await import("node:fs"),{dirname:c}=await import("node:path");x(c(n),{recursive:!0}),p(n,r)}catch{}};export{pe as main};
|