pi-gsd 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1368,7 +1368,7 @@ Run: pi-gsd-tools harness update [y|n|pick|diff]`,
1368
1368
  );
1369
1369
  if (!data)
1370
1370
  return "\u274C No GSD project found. Run /gsd-new-project to initialise.";
1371
- const icon = data.status === "ok" ? "\u2705" : data.status === "broken" ? "\u274C" : "\u26A0\uFE0F";
1371
+ const icon = data.status === "healthy" ? "\u2705" : data.status === "broken" ? "\u274C" : "\u26A0\uFE0F";
1372
1372
  const lines = [
1373
1373
  `\u2501\u2501 GSD Health \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`,
1374
1374
  `${icon} Status: ${data.status.toUpperCase()}`
@@ -1377,7 +1377,7 @@ Run: pi-gsd-tools harness update [y|n|pick|diff]`,
1377
1377
  lines.push(``, `Errors (${data.errors.length}):`);
1378
1378
  for (const e of data.errors) {
1379
1379
  lines.push(` \u2717 [${e.code}] ${e.message}`);
1380
- if (e.repair) lines.push(` fix: ${e.repair}`);
1380
+ if (e.fix) lines.push(` fix: ${e.fix}`);
1381
1381
  }
1382
1382
  }
1383
1383
  if (data.warnings?.length) {
@@ -1386,8 +1386,14 @@ Run: pi-gsd-tools harness update [y|n|pick|diff]`,
1386
1386
  lines.push(` \u26A0 [${w.code}] ${w.message}`);
1387
1387
  }
1388
1388
  }
1389
- if (data.status !== "ok" && !repair) {
1390
- lines.push(``, ` \u2192 /gsd-health --repair Auto-fix all issues`);
1389
+ if (data.repairs_performed?.length) {
1390
+ lines.push(``, `Repairs performed (${data.repairs_performed.length}):`);
1391
+ for (const r of data.repairs_performed) {
1392
+ lines.push(` ${r.success ? "\u2713" : "\u2717"} ${r.action}${r.path ? ` \u2192 ${r.path}` : ""}${r.error ? `: ${r.error}` : ""}`);
1393
+ }
1394
+ }
1395
+ if (data.status !== "healthy" && !repair && (data.repairable_count ?? 0) > 0) {
1396
+ lines.push(``, ` \u2192 /gsd-health --repair Auto-fix ${data.repairable_count} issue(s)`);
1391
1397
  }
1392
1398
  lines.push(``, `\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`);
1393
1399
  return lines.join("\n");
@@ -350,7 +350,7 @@ ${p}
350
350
  `,h=Jt.default.join(t,n.directory,f);if(ls.default.existsSync(h)){y({error:"File already exists",path:J(Jt.default.relative(t,h))},r);return}ls.default.writeFileSync(h,Ie(g),"utf-8");let x=J(Jt.default.relative(t,h));y({created:!0,path:x,template:e},r,x)}var ls,Jt,Ks=L(()=>{"use strict";ls=U(require("fs")),Jt=U(require("path"));ye();Ve()});var Xe,ds,us,Yr=L(()=>{"use strict";Xe=require("@oclif/core");je();ds=class t extends w{static description="Select a workflow template";static args={type:Xe.Args.string({required:!0})};static flags={...w.baseFlags};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdTemplateSelect:i}=await Promise.resolve().then(()=>(Ks(),Zs));i(r,s.type,n)}},us=class t extends w{static description="Fill a template with values";static args={type:Xe.Args.string({required:!0})};static flags={...w.baseFlags,phase:Xe.Flags.string(),plan:Xe.Flags.string(),name:Xe.Flags.string(),type:Xe.Flags.string({char:"t"}),wave:Xe.Flags.string(),fields:Xe.Flags.string({description:"JSON fields"})};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdTemplateFill:i}=await Promise.resolve().then(()=>(Ks(),Zs)),o={};if(e.fields)try{o=JSON.parse(e.fields)}catch{}i(r,s.type,{phase:e.phase??void 0,plan:e.plan??void 0,name:e.name??void 0,type:e.type??void 0,wave:e.wave??void 0,...o},n)}}});var Ft,ms,ps,fs,gs,hs,Hr=L(()=>{"use strict";Ft=require("@oclif/core");je();ms=class t extends w{static description="Show project progress";static args={format:Ft.Args.string({default:"json"})};static flags={...w.baseFlags};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdProgressRender:i}=await Promise.resolve().then(()=>(_e(),ve));i(r,s.format,n)}},ps=class t extends w{static description="Show project statistics";static args={format:Ft.Args.string({default:"json"})};static flags={...w.baseFlags};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdStats:i}=await Promise.resolve().then(()=>(_e(),ve));i(r,s.format,n)}},fs=class t extends w{static description="Mark a todo as complete";static args={id:Ft.Args.string({required:!0})};static flags={...w.baseFlags};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdTodoComplete:i}=await Promise.resolve().then(()=>(_e(),ve));i(r,s.id,n)}},gs=class t extends w{static description="Match todos to phase";static args={phase:Ft.Args.string({required:!0})};static flags={...w.baseFlags};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdTodoMatchPhase:i}=await Promise.resolve().then(()=>(_e(),ve));i(r,s.phase,n)}},hs=class t extends w{static description="Extract fields from summary files";static args={phase:Ft.Args.string({required:!0})};static flags={...w.baseFlags,fields:w.baseFlags.pick};async run(){let{flags:e,args:s}=await this.parse(t),{cwd:r,raw:n}=this.resolveContext(e),{cmdSummaryExtract:i}=await Promise.resolve().then(()=>(_e(),ve)),o=e.fields?e.fields.split(","):null;i(r,s.phase,o,n)}}});function ft(t){let e=[],s=/^```[^\n]*\n[\s\S]*?^```/gm,r;for(;(r=s.exec(t))!==null;)e.push([r.index,r.index+r[0].length]);return e}function gt(t,e){return e.some(([s,r])=>t>=s&&t<r)}function za(t){let e={},s=/([a-zA-Z0-9_:-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s/>]*)))?/g,r;for(;(r=s.exec(t))!==null;){let n=r[1],i=r[2]??r[3]??r[4]??"";e[n]=i}return e}function Xr(t,e){if(t[e]!=="<")return null;let s=/^<([a-zA-Z0-9_:-]+)((?:\s+[a-zA-Z0-9_:-]+(?:=(?:"[^"]*"|'[^']*'|[^\s/>]*))?)*)?\s*(\/??>)/,r=t.slice(e),n=s.exec(r);if(!n)return null;let i=n[1],o=(n[2]??"").trim(),a=n[3],c=za(o);if(a==="/>")return{node:{tag:i,attrs:c,children:[],selfClosing:!0},end:e+n[0].length};let l=e+n[0].length,d=[],u=`</${i}>`;for(;l<t.length;){let m=t.indexOf("<",l);if(m===-1)break;if(t.startsWith(u,m))return{node:{tag:i,attrs:c,children:d,selfClosing:!1},end:m+u.length};if(t.startsWith("<!--",m)){let f=t.indexOf("-->",m+4);l=f!==-1?f+3:t.length;continue}let p=Xr(t,m);p?(d.push(p.node),l=p.end):l=m+1}return{node:{tag:i,attrs:c,children:d,selfClosing:!1},end:l}}function Yt(t){let e=ft(t),s=[],r=/<(gsd-[a-zA-Z0-9_-]+)/g,n;for(;(n=r.exec(t))!==null;){let i=n.index;if(gt(i,e))continue;let o=n[1];if(!Ba.has(o))continue;let a=Xr(t,i);a&&(s.push({node:a.node,start:i,end:a.end}),r.lastIndex=a.end)}return s}function ys(t,e,s,r){return t.slice(0,e)+r+t.slice(s)}var Ba,Qs=L(()=>{"use strict";Ba=new Set(["gsd-execute","gsd-arguments","gsd-paste","gsd-include","gsd-version"])});function Zr(){let t=new Map,e=new Map,s=r=>{let n=t.get(r)?.value;if(n!==void 0)return n;let i=r.indexOf(".");if(i===-1)return;let o=r.slice(0,i),a=r.slice(i+1),c=t.get(o)?.value;if(c!==void 0)try{let l=JSON.parse(c);for(let d of a.split(".")){if(l===null||typeof l!="object")return;l=l[d]}return l==null?void 0:String(l)}catch{return}};return{set(r,n,i){let o=t.get(r);o?.owner&&i&&o.owner!==i?(t.delete(r),t.set(`${o.owner}:${r}`,{name:`${o.owner}:${r}`,value:o.value,owner:o.owner}),t.set(`${i}:${r}`,{name:`${i}:${r}`,value:n,owner:i})):t.set(r,{name:r,value:n,owner:i})},get(r){return t.get(r)?.value},resolve(r){return s(r)},setArray(r,n,i){e.set(r,n),t.set(r,{name:r,value:JSON.stringify(n),owner:i})},getArray(r){if(e.has(r))return e.get(r);let n=t.get(r)?.value;if(n)try{let i=JSON.parse(n);if(Array.isArray(i))return i.map(o=>typeof o=="string"?o:JSON.stringify(o))}catch{}},has(r){return t.has(r)||e.has(r)},entries(){return t.entries()},snapshot(){let r={};for(let[n,i]of t)r[n]=i.value;return r}}}var Kr=L(()=>{"use strict"});function Qr(t,e,s){let r=t.children.find(g=>g.tag==="settings"),n=r?.children.some(g=>g.tag==="keep-extra-args")??!1,i=r?.children.some(g=>g.tag==="strict-args")??!1,a=r?.children.find(g=>g.tag==="delimiters")?.children.find(g=>g.tag==="delimiter"),c;if(a){let g=a.attrs.value??"",h=g==="\\n"?`
351
351
  `:g;c=e.split(h).map(x=>x.trim()).filter(Boolean)}else c=e.trim().split(/\s+/).filter(Boolean);let l=t.children.filter(g=>g.tag==="arg"),d=new Set;for(let g of l.filter(h=>h.attrs.type==="flag")){let h=g.attrs.flag??`--${g.attrs.name}`,x=c.indexOf(h),S=g.attrs.name;S&&(x===-1?s.set(S,"false",void 0):(s.set(S,"true",void 0),d.add(x)))}let u=l.filter(g=>g.attrs.type!=="flag"),m=c.filter((g,h)=>!d.has(h)),p=0;for(let g=0;g<u.length;g++){let h=u[g],x=h.attrs.name,S=h.attrs.type??"string",v=g===u.length-1;if(x){if(p>=m.length){if(!("optional"in h.attrs))throw new ht(`Missing required argument '${x}' (type: ${S})`);s.set(x,"",void 0);continue}if(S==="string"&&v)s.set(x,m.slice(p).join(" "),void 0),p=m.length;else if(S==="number"){let C=m[p++],P=Number(C);if(isNaN(P))throw new ht(`Argument '${x}' expected a number, got '${C}'`);s.set(x,String(P),void 0)}else if(S==="boolean"){let C=m[p++].toLowerCase();if(C!=="true"&&C!=="false")throw new ht(`Argument '${x}' expected true/false, got '${C}'`);s.set(x,C,void 0)}else s.set(x,m[p++]??"",void 0)}}let f=m.slice(p).join(" ");if(f){if(i)throw new ht(`Unexpected extra arguments: '${f}'`);n&&s.set("_extra",f,void 0)}}var ht,er=L(()=>{"use strict";ht=class extends Error{constructor(e){super(e),this.name="WxpArgumentsError"}}});function xs(t,e,s){switch(t.position){case"project":return Ze.default.resolve(e,t.path);case"pkg":return Ze.default.resolve(s,t.path);case"absolute":return Ze.default.resolve(t.path)}}function tr(t,e,s,r){let n=Ze.default.resolve(t),i=`${Ze.default.sep}.planning`;if(n.includes(`${i}${Ze.default.sep}`)||n.endsWith(i))return{ok:!1,reason:".planning/ files are never processed by WXP (hard security invariant)"};for(let o of e.untrustedPaths){let a=xs(o,s,r);if(n.startsWith(a+Ze.default.sep)||n===a)return{ok:!1,reason:`File '${t}' is in an explicitly untrusted path: ${a}`}}for(let o of e.trustedPaths){let a=xs(o,s,r);if(n.startsWith(a+Ze.default.sep)||n===a)return{ok:!0}}return{ok:!1,reason:`File '${t}' is not in a trusted WXP path.`}}function ti(t,e){let s=Ze.default.basename(t);return e.shellBanlist.includes(s)?{ok:!1,reason:`Command '${s}' is explicitly banned by WXP security config.`}:e.shellAllowlist.includes(s)?{ok:!0}:{ok:!1,reason:`Command '${s}' is not in the WXP shell allowlist. Allowed: ${e.shellAllowlist.join(", ")}`}}var Ze,ei,Ht=L(()=>{"use strict";Ze=U(require("path")),ei=["pi-gsd-tools","git","node","cat","ls","echo","find"]});function Ss(t,e){if(t.attrs.string!==void 0)return t.attrs.string;if(t.attrs.name!==void 0){let s=e.resolve(t.attrs.name)??"",r=t.attrs.wrap;return r?`${r}${s}${r}`:s}return t.attrs.value!==void 0?t.attrs.value:""}function si(t,e,s){let r=t.attrs.command??"",n=ti(r,s);if(!n.ok)throw new yt(r,"",e.snapshot(),n.reason);let i=t.children.find(u=>u.tag==="args"),o=t.children.find(u=>u.tag==="outs"),a=i?i.children.filter(u=>u.tag==="arg").map(u=>Ss(u,e)):[],c=o?o.children.some(u=>u.tag==="suppress-errors"):!1,l=o?o.children.filter(u=>u.tag==="out"&&u.attrs.name).map(u=>u.attrs.name):[],d="";try{d=(0,ni.execFileSync)(r,a,{encoding:"utf8",timeout:s.shellTimeoutMs,windowsHide:!0}).trim()}catch(u){if(c){for(let f of l)e.set(f,"",void 0);return}let m=u,p=(m.stderr??m.message??String(u)).trim();throw new yt(r,p,e.snapshot(),`Shell '${r} ${a.join(" ")}' failed: ${p}`)}l.length>0&&e.set(l[0],d,void 0)}var ni,yt,bs=L(()=>{"use strict";ni=require("child_process");Ht();yt=class extends Error{constructor(s,r,n,i){super(i);this.command=s;this.stderr=r;this.variableSnapshot=n;this.name="WxpShellError"}command;stderr;variableSnapshot}});function ri(t,e){if(t.attrs.op!=="split")throw new xt('<string-op> only op="split" is supported in v1');let r=t.children.find(m=>m.tag==="args"),n=t.children.find(m=>m.tag==="outs");if(!r||!n)throw new xt("<string-op> requires <args> and <outs>");let i=r.children.filter(m=>m.tag==="arg"),o=n.children.filter(m=>m.tag==="out"),a=i[0],c=i[1];if(!a)throw new xt('<string-op op="split"> requires at least 2 <arg> children');let l=Ss(a,e);if(a.attrs.name&&e.get(a.attrs.name)===void 0)throw new xt(`string-op split: source variable '${a.attrs.name}' is not defined`);let d=c?Ss(c,e):"",u=l.split(d);o.forEach((m,p)=>{let f=m.attrs.name;f&&e.set(f,u[p+1]??u[p]??"",void 0)})}var xt,nr=L(()=>{"use strict";bs();xt=class extends Error{constructor(e){super(e),this.name="WxpStringOpError"}}});function vs(t,e){return t.attrs.name?e.resolve(t.attrs.name)??"":t.attrs.value!==void 0?t.attrs.value:""}function ii(t){return t.attrs.type==="number"}function Ja(t,e){let s=t.children.find(a=>a.tag==="left"),r=t.children.find(a=>a.tag==="right");if(!s||!r)return!1;if(ii(s)||ii(r)){let a=Number(vs(s,e)),c=Number(vs(r,e));switch(t.tag){case"equals":return a===c;case"not-equals":return a!==c;case"less-than":return a<c;case"greater-than":return a>c;case"less-than-or-equal":return a<=c;case"greater-than-or-equal":return a>=c;default:return!1}}let i=vs(s,e),o=vs(r,e);switch(t.tag){case"equals":return i===o;case"not-equals":return i!==o;case"starts-with":return i.startsWith(o);case"contains":return i.includes(o);case"less-than":return Number(i)<Number(o);case"greater-than":return Number(i)>Number(o);case"less-than-or-equal":return Number(i)<=Number(o);case"greater-than-or-equal":return Number(i)>=Number(o);default:return!1}}function Zt(t,e){return t.tag==="and"?t.children.filter(s=>Xt.has(s.tag)).every(s=>Zt(s,e)):t.tag==="or"?t.children.filter(s=>Xt.has(s.tag)).some(s=>Zt(s,e)):Ja(t,e)}function oi(t,e){let s=t.children.find(n=>n.tag==="condition");if(!s)return!1;let r=s.children.find(n=>Xt.has(n.tag));return r?Zt(r,e):!1}function ai(t,e){let s=t.children.find(r=>Xt.has(r.tag));return s?Zt(s,e):!0}var Ga,Xt,ci=L(()=>{"use strict";Ga=new Set(["equals","not-equals","starts-with","contains","less-than","greater-than","less-than-or-equal","greater-than-or-equal"]),Xt=new Set([...Ga,"and","or"])});function Ya(t,e,s){let r=(t.attrs.msg??"").replace(/\{([^}]+)\}/g,(i,o)=>e.resolve(o)??""),n=t.attrs.level;s.onDisplay(r,n==="warning"||n==="error"?n:"info")}function Ha(t,e){let s=t.attrs.src??"",r=t.attrs.out??"",n=t.attrs.path,i=e.get(s);if(i===void 0)throw new Error(`<json-parse>: source variable '${s}' is not defined`);let o;try{o=JSON.parse(i)}catch{throw new Error(`<json-parse>: '${s}' does not contain valid JSON`)}if(n){let a=n.replace(/^\$\.?/,"").split("."),c=o;for(let l of a){if(c===null||typeof c!="object")throw new Error(`<json-parse>: path '${n}' not found`);c=c[l]}o=c}Array.isArray(o)?e.setArray(r,o.map(a=>typeof a=="string"?a:JSON.stringify(a))):o!==null&&typeof o=="object"?e.set(r,JSON.stringify(o),void 0):e.set(r,o==null?"":String(o),void 0)}function Xa(t,e){let s=t.attrs.path??"",r=t.attrs.out??"",n=Kt.default.readFileSync(Qt.default.resolve(s),"utf8");e.set(r,n,void 0)}function Za(t,e,s){let r=t.attrs.path??"",n=t.attrs.src??"",i=Qt.default.resolve(r);if(Kt.default.existsSync(i))throw new Error(`<write-file>: '${r}' already exists (create-only, never overwrites)`);for(let a of s.config.trustedPaths){let c=xs(a,s.projectRoot,s.pkgRoot);if(i.startsWith(c+Qt.default.sep)||i===c)throw new Error(`<write-file>: cannot write to trusted harness path '${r}'`)}let o=e.get(n)??"";Kt.default.mkdirSync(Qt.default.dirname(i),{recursive:!0}),Kt.default.writeFileSync(i,o,"utf8")}function Ka(t,e,s){let r=t.attrs.var??"",n=t.attrs.item??"",i=t.children.find(l=>l.tag==="where"),o=t.children.find(l=>l.tag==="sort-by"),a=t.children.filter(l=>l.tag!=="where"&&l.tag!=="sort-by"),c=e.getArray(r);if(c){if(i&&(c=c.filter(l=>(e.set(n,l,void 0),ai(i,e)))),o){let l=o.attrs.key??"",d=o.attrs.type??"string",u=o.attrs.order??"asc";c=[...c].sort((m,p)=>{e.set(n,m,void 0);let f=e.resolve(`${n}.${l}`)??e.resolve(l)??"";e.set(n,p,void 0);let g=e.resolve(`${n}.${l}`)??e.resolve(l)??"",h=d==="number"?Number(f)-Number(g):f.localeCompare(g);return u==="desc"?-h:h})}for(let l of c){e.set(n,l,void 0);for(let d of a)sr(d,e,s)}}}function sr(t,e,s){switch(t.tag){case"shell":si(t,e,s.config);break;case"string-op":ri(t,e);break;case"json-parse":Ha(t,e);break;case"read-file":Xa(t,e);break;case"write-file":Za(t,e,s);break;case"display":Ya(t,e,s);break;case"for-each":Ka(t,e,s);break;case"if":{let r=oi(t,e),n=t.children.find(a=>a.tag==="then"),i=t.children.find(a=>a.tag==="else"),o=r?n:i;if(o)for(let a of o.children)sr(a,e,s);break}case"gsd-execute":rr(t,e,s);break;default:break}}function rr(t,e,s){try{for(let r of t.children)sr(r,e,s)}catch(r){throw r instanceof yt||r instanceof Error?new _s(r,e.snapshot(),`Execution failed: ${r.message}`):r}}var Kt,Qt,_s,ir=L(()=>{"use strict";Kt=U(require("fs")),Qt=U(require("path"));bs();nr();ci();Ht();_s=class extends Error{constructor(s,r,n){super(n);this.cause=s;this.variableSnapshot=r;this.name="WxpExecutionError"}cause;variableSnapshot}});function li(t,e){let s=ft(t),r=/<gsd-paste\s+name="([^"]+)"\s*\/>/g,n=[],i;for(;(i=r.exec(t))!==null;)gt(i.index,s)||n.push({index:i.index,full:i[0],name:i[1]});for(let a of n)if(e.get(a.name)===void 0)throw new ws(a.name,e.snapshot());let o=t;for(let a=n.length-1;a>=0;a--){let c=n[a],l=e.get(c.name);o=o.slice(0,c.index)+l+o.slice(c.index+c.full.length)}return o}var ws,or=L(()=>{"use strict";Qs();ws=class extends Error{constructor(s,r){super(`<gsd-paste name="${s}" /> references undefined variable '${s}'`);this.variableName=s;this.variableSnapshot=r;this.name="WxpPasteError"}variableName;variableSnapshot}});function di(t,e,s,r,n,i="",o=ec){let a=tr(e,s,r,n);if(!a.ok)throw new St(e,new Error(a.reason),{},[],[]);return tc(t,e,s,r,n,i,o)}function tc(t,e,s,r,n,i,o){let a=Zr(),c=[],l=t,d={config:s,projectRoot:r,pkgRoot:n,onDisplay:o};for(let u=0;u<Qa;u++){let p=Yt(l).filter(g=>g.node.tag!=="gsd-version");if(p.length===0)break;let f=p.map(g=>g.node.tag);try{let g=!1;for(let x of Yt(l)){if(x.node.tag!=="gsd-include"||gt(x.start,ft(l)))continue;let S=x.node.attrs.path;if(!S)continue;let v=ks.default.resolve(r,S);if(!ar.default.existsSync(v))throw new Error(`Include not found: ${S}`);let C=tr(v,s,r,n);if(!C.ok)throw new Error(`Include rejected: ${C.reason}`);let P=ar.default.readFileSync(v,"utf8"),$=ks.default.basename(v,ks.default.extname(v));for(let k of x.node.children)if(k.tag==="gsd-arguments")for(let j of k.children.filter(R=>R.tag==="arg")){let R=j.attrs.name,E=j.attrs.as;if(R&&E){let V=a.get(R);V!==void 0&&a.set(E,V,$)}}let T="include-arguments"in x.node.attrs?`
352
352
  ${i}`:"";l=ys(l,x.start,x.end,P+T),c.push("gsd-include"),g=!0;break}if(g)continue;for(let x of Yt(l))if(x.node.tag==="gsd-arguments"&&!gt(x.start,ft(l))){Qr(x.node,i,a),l=ys(l,x.start,x.end,""),c.push("gsd-arguments"),g=!0;break}if(g)continue;for(let x of Yt(l))if(x.node.tag==="gsd-execute"&&!gt(x.start,ft(l))){rr(x.node,a,d),l=ys(l,x.start,x.end,""),c.push("gsd-execute"),g=!0;break}if(g)continue;let h=li(l,a);if(h!==l){l=h,c.push("gsd-paste");continue}break}catch(g){if(g instanceof St)throw g;let h=g instanceof Error?g:new Error(String(g));throw new St(e,h,a.snapshot(),f,c)}}return l}var ar,ks,Qa,ec,St,ui=L(()=>{"use strict";ar=U(require("fs")),ks=U(require("path"));Qs();Kr();er();ir();or();Ht();ir();bs();or();nr();er();Qa=50,ec=()=>{},St=class extends Error{constructor(s,r,n,i,o){super(["WXP Processing Error",`File: ${s}`,`Error: ${r.message}`,`Variable Namespace: ${JSON.stringify(n,null,2)}`,`Pending Operations: [${i.join(", ")}]`,`Completed Operations: [${o.join(", ")}]`].join(`
353
- `));this.filePath=s;this.cause=r;this.variableSnapshot=n;this.pendingOperations=i;this.completedOperations=o;this.name="WxpProcessingError"}filePath;cause;variableSnapshot;pendingOperations;completedOperations}});var bt,mi,cr,Ps,pi=L(()=>{"use strict";bt=require("@oclif/core"),mi=require("@oclif/core"),cr=U(require("path"));ui();Ht();Ps=class t extends mi.Command{static description="Process WXP tags in a workflow file";static args={file:bt.Args.string({description:"File to process",required:!1})};static flags={input:bt.Flags.string({description:"Input content string (alternative to file)"}),arguments:bt.Flags.string({description:"Raw $ARGUMENTS string",default:""}),"project-root":bt.Flags.string({description:"Project root directory",default:process.cwd()}),"pkg-root":bt.Flags.string({description:"Package root directory",default:process.cwd()})};async run(){let{flags:e,args:s}=await this.parse(t),r,n;if(e.input!==void 0)r=e.input,n=cr.default.join(e["project-root"],".pi","gsd","workflows","_inline.md");else if(s.file){let o=await import("fs");n=cr.default.resolve(s.file),r=o.default.readFileSync(n,"utf8")}else{this.error("Provide a file argument or --input string");return}let i={trustedPaths:[{position:"project",path:".pi/gsd"},{position:"pkg",path:"gsd"}],untrustedPaths:[],shellAllowlist:[...ei],shellBanlist:[],shellTimeoutMs:3e4};try{let o=di(r,n,i,e["project-root"],e["pkg-root"],e.arguments);process.stdout.write(o)}catch(o){throw o instanceof St&&this.error(o.message,{exit:1}),o}}}});var fi={};xe(fi,{AuditUatCommand:()=>Hn,CommitCommand:()=>is,ConfigEnsureSectionCommand:()=>Fn,ConfigGetCommand:()=>An,ConfigNewProjectCommand:()=>En,ConfigSetCommand:()=>jn,ConfigSetModelProfileCommand:()=>Rn,FrontmatterGetCommand:()=>os,FrontmatterMergeCommand:()=>cs,FrontmatterSetCommand:()=>as,InitCommand:()=>_n,MilestoneCompleteCommand:()=>Un,PhaseAddBatchCommand:()=>Tn,PhaseAddCommand:()=>In,PhaseCompleteCommand:()=>Nn,PhaseInsertCommand:()=>Dn,PhaseNextDecimalCommand:()=>Mn,PhasePlanIndexCommand:()=>Wn,PhaseRemoveCommand:()=>On,ProgressCommand:()=>ms,RequirementsMarkCompleteCommand:()=>Vn,RoadmapAnalyzeCommand:()=>Pn,RoadmapGetPhaseCommand:()=>$n,RoadmapUpdatePlanProgressCommand:()=>Cn,ScaffoldCommand:()=>ss,StateAdvancePlanCommand:()=>gn,StateGetCommand:()=>mn,StateJsonCommand:()=>un,StateLoadCommand:()=>hn,StatePatchCommand:()=>fn,StateReconcileCommand:()=>xn,StateUpdateCommand:()=>pn,StateUpdateProgressCommand:()=>yn,StatsCommand:()=>ps,SummaryExtractCommand:()=>hs,TemplateFillCommand:()=>us,TemplateSelectCommand:()=>ds,TodoCompleteCommand:()=>fs,TodoMatchPhaseCommand:()=>gs,ValidateAgentsCommand:()=>Jn,ValidateConsistencyCommand:()=>Bn,ValidateHealthCommand:()=>Gn,VerifyCommand:()=>Yn,WorkstreamCompleteCommand:()=>Qn,WorkstreamCreateCommand:()=>Xn,WorkstreamGetCommand:()=>ts,WorkstreamListCommand:()=>Zn,WorkstreamProgressCommand:()=>ns,WorkstreamSetCommand:()=>es,WorkstreamStatusCommand:()=>Kn,WxpProcessCommand:()=>Ps});var gi=L(()=>{"use strict";Pr();Cr();jr();Mr();Dr();Or();Vr();zr();Br();Gr();Jr();Yr();Hr();pi()});var hi=Fi((Nd,nc)=>{nc.exports={name:"pi-gsd",version:"2.1.3",description:"Get Shit Done - Unofficial port of the renowned AI-native project-planning spec-driven toolkit",main:"dist/pi-gsd-tools.js",bin:{"pi-gsd-tools":"./dist/pi-gsd-tools.js","pi-gsd":"./dist/pi-gsd-tools.js"},scripts:{build:"tsup",dev:"tsup src/cli.ts --format cjs --out-dir dist --watch",typecheck:"tsc --noEmit",check:"tsc --noEmit && npm run build",postinstall:"node scripts/postinstall.js",prepublishOnly:"npm run build",test:"vitest run","test:unit":"vitest run src/wxp/__tests__ --ignore src/wxp/__tests__/integration.test.ts","test:integration":"vitest run src/wxp/__tests__/integration.test.ts",lint:"eslint src/ --ext .ts"},files:["gsd","dist","scripts/postinstall.js","README.md","LICENSE"],engines:{node:">=18.0.0"},keywords:["ai","agent","planning","cli","workflow","get-shit-done","gsd","productivity","project-management","milestones","phases","spec","pi-package"],author:"Alessio Corsi",license:"MIT",repository:{type:"git",url:"https://github.com/fulgidus/pi-gsd.git"},bugs:{url:"https://github.com/fulgidus/pi-gsd/issues"},homepage:"https://github.com/fulgidus/pi-gsd#readme",publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},pi:{extensions:["./dist/pi-gsd-hooks.js"],prompts:["./gsd/prompts"]},dependencies:{"@oclif/core":"^4.10.5","@toon-format/toon":"^2.1.0","jsonpath-plus":"^10.4.0",zod:"^3.25.76"},devDependencies:{"@mariozechner/pi-coding-agent":"^0.65.0","@types/node":"^22.0.0","@typescript-eslint/eslint-plugin":"^8.58.0","@typescript-eslint/parser":"^8.58.0",eslint:"^10.2.0",tsup:"^8.5.1",typescript:"^5.0.0",vitest:"^4.1.2"}}});var $s={};xe($s,{cmdExtractMessages:()=>ac,cmdProfileSample:()=>cc,cmdScanSessions:()=>oc});function lr(t){if(t)return t;let e=process.env.HOME??"",s=De.join(e,".agent","projects");return re.existsSync(s)?s:De.join(e,".claude","projects")}function dr(){let t=process.env.HOME??"";return De.join(t,".pi","agent","sessions")}function ur(t){return t.startsWith("--")&&t.endsWith("--")?"/"+t.slice(2,-2).replace(/-/g,"/"):t}function sc(t){try{let e=re.readFileSync(t,"utf-8").split(`
353
+ `));this.filePath=s;this.cause=r;this.variableSnapshot=n;this.pendingOperations=i;this.completedOperations=o;this.name="WxpProcessingError"}filePath;cause;variableSnapshot;pendingOperations;completedOperations}});var bt,mi,cr,Ps,pi=L(()=>{"use strict";bt=require("@oclif/core"),mi=require("@oclif/core"),cr=U(require("path"));ui();Ht();Ps=class t extends mi.Command{static description="Process WXP tags in a workflow file";static args={file:bt.Args.string({description:"File to process",required:!1})};static flags={input:bt.Flags.string({description:"Input content string (alternative to file)"}),arguments:bt.Flags.string({description:"Raw $ARGUMENTS string",default:""}),"project-root":bt.Flags.string({description:"Project root directory",default:process.cwd()}),"pkg-root":bt.Flags.string({description:"Package root directory",default:process.cwd()})};async run(){let{flags:e,args:s}=await this.parse(t),r,n;if(e.input!==void 0)r=e.input,n=cr.default.join(e["project-root"],".pi","gsd","workflows","_inline.md");else if(s.file){let o=await import("fs");n=cr.default.resolve(s.file),r=o.default.readFileSync(n,"utf8")}else{this.error("Provide a file argument or --input string");return}let i={trustedPaths:[{position:"project",path:".pi/gsd"},{position:"pkg",path:"gsd"}],untrustedPaths:[],shellAllowlist:[...ei],shellBanlist:[],shellTimeoutMs:3e4};try{let o=di(r,n,i,e["project-root"],e["pkg-root"],e.arguments);process.stdout.write(o)}catch(o){throw o instanceof St&&this.error(o.message,{exit:1}),o}}}});var fi={};xe(fi,{AuditUatCommand:()=>Hn,CommitCommand:()=>is,ConfigEnsureSectionCommand:()=>Fn,ConfigGetCommand:()=>An,ConfigNewProjectCommand:()=>En,ConfigSetCommand:()=>jn,ConfigSetModelProfileCommand:()=>Rn,FrontmatterGetCommand:()=>os,FrontmatterMergeCommand:()=>cs,FrontmatterSetCommand:()=>as,InitCommand:()=>_n,MilestoneCompleteCommand:()=>Un,PhaseAddBatchCommand:()=>Tn,PhaseAddCommand:()=>In,PhaseCompleteCommand:()=>Nn,PhaseInsertCommand:()=>Dn,PhaseNextDecimalCommand:()=>Mn,PhasePlanIndexCommand:()=>Wn,PhaseRemoveCommand:()=>On,ProgressCommand:()=>ms,RequirementsMarkCompleteCommand:()=>Vn,RoadmapAnalyzeCommand:()=>Pn,RoadmapGetPhaseCommand:()=>$n,RoadmapUpdatePlanProgressCommand:()=>Cn,ScaffoldCommand:()=>ss,StateAdvancePlanCommand:()=>gn,StateGetCommand:()=>mn,StateJsonCommand:()=>un,StateLoadCommand:()=>hn,StatePatchCommand:()=>fn,StateReconcileCommand:()=>xn,StateUpdateCommand:()=>pn,StateUpdateProgressCommand:()=>yn,StatsCommand:()=>ps,SummaryExtractCommand:()=>hs,TemplateFillCommand:()=>us,TemplateSelectCommand:()=>ds,TodoCompleteCommand:()=>fs,TodoMatchPhaseCommand:()=>gs,ValidateAgentsCommand:()=>Jn,ValidateConsistencyCommand:()=>Bn,ValidateHealthCommand:()=>Gn,VerifyCommand:()=>Yn,WorkstreamCompleteCommand:()=>Qn,WorkstreamCreateCommand:()=>Xn,WorkstreamGetCommand:()=>ts,WorkstreamListCommand:()=>Zn,WorkstreamProgressCommand:()=>ns,WorkstreamSetCommand:()=>es,WorkstreamStatusCommand:()=>Kn,WxpProcessCommand:()=>Ps});var gi=L(()=>{"use strict";Pr();Cr();jr();Mr();Dr();Or();Vr();zr();Br();Gr();Jr();Yr();Hr();pi()});var hi=Fi((Nd,nc)=>{nc.exports={name:"pi-gsd",version:"2.1.4",description:"Get Shit Done - Unofficial port of the renowned AI-native project-planning spec-driven toolkit",main:"dist/pi-gsd-tools.js",bin:{"pi-gsd-tools":"./dist/pi-gsd-tools.js","pi-gsd":"./dist/pi-gsd-tools.js"},scripts:{build:"tsup",dev:"tsup src/cli.ts --format cjs --out-dir dist --watch",typecheck:"tsc --noEmit",check:"tsc --noEmit && npm run build",postinstall:"node scripts/postinstall.js",prepublishOnly:"npm run build",test:"vitest run","test:unit":"vitest run src/wxp/__tests__ --ignore src/wxp/__tests__/integration.test.ts","test:integration":"vitest run src/wxp/__tests__/integration.test.ts",lint:"eslint src/ --ext .ts"},files:["gsd","dist","scripts/postinstall.js","README.md","LICENSE"],engines:{node:">=18.0.0"},keywords:["ai","agent","planning","cli","workflow","get-shit-done","gsd","productivity","project-management","milestones","phases","spec","pi-package"],author:"Alessio Corsi",license:"MIT",repository:{type:"git",url:"https://github.com/fulgidus/pi-gsd.git"},bugs:{url:"https://github.com/fulgidus/pi-gsd/issues"},homepage:"https://github.com/fulgidus/pi-gsd#readme",publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},pi:{extensions:["./dist/pi-gsd-hooks.js"],prompts:["./gsd/prompts"]},dependencies:{"@oclif/core":"^4.10.5","@toon-format/toon":"^2.1.0","jsonpath-plus":"^10.4.0",zod:"^3.25.76"},devDependencies:{"@mariozechner/pi-coding-agent":"^0.65.0","@types/node":"^22.0.0","@typescript-eslint/eslint-plugin":"^8.58.0","@typescript-eslint/parser":"^8.58.0",eslint:"^10.2.0",tsup:"^8.5.1",typescript:"^5.0.0",vitest:"^4.1.2"}}});var $s={};xe($s,{cmdExtractMessages:()=>ac,cmdProfileSample:()=>cc,cmdScanSessions:()=>oc});function lr(t){if(t)return t;let e=process.env.HOME??"",s=De.join(e,".agent","projects");return re.existsSync(s)?s:De.join(e,".claude","projects")}function dr(){let t=process.env.HOME??"";return De.join(t,".pi","agent","sessions")}function ur(t){return t.startsWith("--")&&t.endsWith("--")?"/"+t.slice(2,-2).replace(/-/g,"/"):t}function sc(t){try{let e=re.readFileSync(t,"utf-8").split(`
354
354
  `).find(r=>r.trim().length>0);if(!e)return!1;let s=JSON.parse(e);return s.type==="session"&&"version"in s}catch{return!1}}function rc(t){return typeof t=="string"?t:Array.isArray(t)?t.filter(e=>e!==null&&typeof e=="object"&&e.type==="text").map(e=>String(e.text??"")).join(" "):""}function ic(t){try{let e=re.readFileSync(t,"utf-8").split(`
355
355
  `).filter(Boolean),s=[];for(let r of e)try{let n=JSON.parse(r);n.type==="message"&&n.message&&s.push(n)}catch{}return s}catch{return[]}}async function oc(t,e,s){let n=(e.harness??null)==="pi",i=dr(),o=re.existsSync(i),a=[];if(o)try{let m=re.readdirSync(i,{withFileTypes:!0}).filter(p=>p.isDirectory());for(let p of m){let f=De.join(i,p.name),g=re.readdirSync(f).filter(h=>h.endsWith(".jsonl"));a.push({name:p.name,sessions:g.length,path:f,source:"pi",cwd:ur(p.name)})}}catch{}let c=lr(n&&!t?null:t),l=!n||t?re.existsSync(c):!1,d=[];if(l&&(!n||t))try{let m=re.readdirSync(c,{withFileTypes:!0}).filter(p=>p.isDirectory());for(let p of m){let f=De.join(c,p.name),g=re.readdirSync(f).filter(h=>h.endsWith(".jsonl")||h.endsWith(".json"));d.push({name:p.name,sessions:g.length,path:f,source:"claude"})}}catch{}let u=n?[...a,...d]:[...d,...a];if(u.length===0){let m=[];o?m.push(i):m.push(i+" (not found)"),n||m.push(l?c:c+" (not found)"),y({available:!1,reason:`No sessions found. Searched: ${m.join(", ")}`,projects:[],count:0},s);return}y({available:!0,pi_base:o?i:null,claude_base:l?c:null,projects:u,count:u.length},s)}async function ac(t,e,s,r){let n=dr(),i=null,o="claude";if(re.existsSync(n)){let d=De.join(n,t);if(re.existsSync(d))i=d,o="pi";else try{let u=re.readdirSync(n,{withFileTypes:!0}).filter(m=>m.isDirectory());for(let m of u){let p=ur(m.name);if(p.endsWith("/"+t)||p===t||m.name===t){i=De.join(n,m.name),o="pi";break}}}catch{}}if(!i){let d=lr(r),u=De.join(d,t);re.existsSync(u)&&(i=u,o="claude")}if(!i){y({error:`Project not found: ${t}`,available_projects:[]},s);return}let a=[],c=re.readdirSync(i).filter(d=>d.endsWith(".jsonl")),l=e.limit??null;for(let d of c){if(e.sessionId&&!d.includes(e.sessionId))continue;let u=De.join(i,d);if(o==="pi"||sc(u))try{let m=re.readFileSync(u,"utf-8").split(`
356
356
  `).filter(Boolean);for(let p of m)try{let f=JSON.parse(p);if(f.type==="message"&&f.message&&(a.push(f.message),l&&a.length>=l))break}catch{}}catch{}else try{let m=re.readFileSync(u,"utf-8").split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-gsd",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "Get Shit Done - Unofficial port of the renowned AI-native project-planning spec-driven toolkit",
5
5
  "main": "dist/pi-gsd-tools.js",
6
6
  "bin": {