pi-gsd 2.0.8 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pi-gsd-hooks.js +9 -3
- package/dist/pi-gsd-tools.js +1 -1
- package/package.json +1 -1
package/dist/pi-gsd-hooks.js
CHANGED
|
@@ -984,6 +984,12 @@ function pi_gsd_hooks_default(pi) {
|
|
|
984
984
|
const pkgHarness = extFile ? (0, import_node_path4.join)((0, import_node_path4.dirname)(extFile), "..", "harnesses", "pi", "get-shit-done") : "";
|
|
985
985
|
const errors = [];
|
|
986
986
|
const messages = event.messages;
|
|
987
|
+
const rawArgsMap = /* @__PURE__ */ new Map();
|
|
988
|
+
messages.forEach((msg, i) => {
|
|
989
|
+
if (msg.role !== "user") return;
|
|
990
|
+
const text = typeof msg.content === "string" ? msg.content : Array.isArray(msg.content) ? msg.content.filter((b) => b.type === "text").map((b) => b.text ?? "").join("\n") : "";
|
|
991
|
+
rawArgsMap.set(i, extractRawArguments(text));
|
|
992
|
+
});
|
|
987
993
|
for (const msg of messages) {
|
|
988
994
|
if (msg.role !== "user") continue;
|
|
989
995
|
if (typeof msg.content === "string") {
|
|
@@ -1052,19 +1058,19 @@ function pi_gsd_hooks_default(pi) {
|
|
|
1052
1058
|
shellTimeoutMs: projectSettings.shellTimeoutMs ?? globalSettings.shellTimeoutMs ?? 3e4
|
|
1053
1059
|
};
|
|
1054
1060
|
try {
|
|
1055
|
-
for (
|
|
1061
|
+
for (let msgIdx = 0; msgIdx < messages.length; msgIdx++) {
|
|
1062
|
+
const msg = messages[msgIdx];
|
|
1056
1063
|
if (msg.role !== "user") continue;
|
|
1064
|
+
const rawArgs = rawArgsMap.get(msgIdx) ?? "";
|
|
1057
1065
|
if (typeof msg.content === "string") {
|
|
1058
1066
|
if (!msg.content.includes("<gsd-")) continue;
|
|
1059
1067
|
const virtualPath = (0, import_node_path4.join)(ctx.cwd, ".pi", "gsd", "workflows", "_message.md");
|
|
1060
|
-
const rawArgs = extractRawArguments(msg.content);
|
|
1061
1068
|
msg.content = processWxpTrustedContent(msg.content, virtualPath, wxpSecurity, ctx.cwd, pkgRoot2, rawArgs, (m, lv) => ctx.ui.notify(m, lv === "error" ? "error" : "info"));
|
|
1062
1069
|
} else if (Array.isArray(msg.content)) {
|
|
1063
1070
|
for (const block of msg.content) {
|
|
1064
1071
|
if (block.type !== "text" || !block.text) continue;
|
|
1065
1072
|
if (!block.text.includes("<gsd-")) continue;
|
|
1066
1073
|
const virtualPath = (0, import_node_path4.join)(ctx.cwd, ".pi", "gsd", "workflows", "_message.md");
|
|
1067
|
-
const rawArgs = extractRawArguments(block.text);
|
|
1068
1074
|
block.text = processWxpTrustedContent(block.text, virtualPath, wxpSecurity, ctx.cwd, pkgRoot2, rawArgs, (m, lv) => ctx.ui.notify(m, lv === "error" ? "error" : "info"));
|
|
1069
1075
|
}
|
|
1070
1076
|
}
|
package/dist/pi-gsd-tools.js
CHANGED
|
@@ -337,7 +337,7 @@ ${p}
|
|
|
337
337
|
`,h=Bt.default.join(t,s.directory,f);if(os.default.existsSync(h)){y({error:"File already exists",path:G(Bt.default.relative(t,h))},r);return}os.default.writeFileSync(h,Ee(g),"utf-8");let x=G(Bt.default.relative(t,h));y({created:!0,path:x,template:e},r,x)}var os,Bt,Js=N(()=>{"use strict";os=W(require("fs")),Bt=W(require("path"));ge();Ue()});var Je,as,cs,Lr=N(()=>{"use strict";Je=require("@oclif/core");$e();as=class t extends w{static description="Select a workflow template";static args={type:Je.Args.string({required:!0})};static flags={...w.baseFlags};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdTemplateSelect:i}=await Promise.resolve().then(()=>(Js(),Bs));i(r,n.type,s)}},cs=class t extends w{static description="Fill a template with values";static args={type:Je.Args.string({required:!0})};static flags={...w.baseFlags,phase:Je.Flags.string(),plan:Je.Flags.string(),name:Je.Flags.string(),type:Je.Flags.string({char:"t"}),wave:Je.Flags.string(),fields:Je.Flags.string({description:"JSON fields"})};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdTemplateFill:i}=await Promise.resolve().then(()=>(Js(),Bs)),o={};if(e.fields)try{o=JSON.parse(e.fields)}catch{}i(r,n.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},s)}}});var Et,ls,ds,us,ms,ps,Ur=N(()=>{"use strict";Et=require("@oclif/core");$e();ls=class t extends w{static description="Show project progress";static args={format:Et.Args.string({default:"json"})};static flags={...w.baseFlags};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdProgressRender:i}=await Promise.resolve().then(()=>(Se(),xe));i(r,n.format,s)}},ds=class t extends w{static description="Show project statistics";static args={format:Et.Args.string({default:"json"})};static flags={...w.baseFlags};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdStats:i}=await Promise.resolve().then(()=>(Se(),xe));i(r,n.format,s)}},us=class t extends w{static description="Mark a todo as complete";static args={id:Et.Args.string({required:!0})};static flags={...w.baseFlags};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdTodoComplete:i}=await Promise.resolve().then(()=>(Se(),xe));i(r,n.id,s)}},ms=class t extends w{static description="Match todos to phase";static args={phase:Et.Args.string({required:!0})};static flags={...w.baseFlags};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdTodoMatchPhase:i}=await Promise.resolve().then(()=>(Se(),xe));i(r,n.phase,s)}},ps=class t extends w{static description="Extract fields from summary files";static args={phase:Et.Args.string({required:!0})};static flags={...w.baseFlags,fields:w.baseFlags.pick};async run(){let{flags:e,args:n}=await this.parse(t),{cwd:r,raw:s}=this.resolveContext(e),{cmdSummaryExtract:i}=await Promise.resolve().then(()=>(Se(),xe)),o=e.fields?e.fields.split(","):null;i(r,n.phase,o,s)}}});function ft(t){let e=[],n=/^```[^\n]*\n[\s\S]*?^```/gm,r;for(;(r=n.exec(t))!==null;)e.push([r.index,r.index+r[0].length]);return e}function gt(t,e){return e.some(([n,r])=>t>=n&&t<r)}function Ia(t){let e={},n=/([a-zA-Z0-9_:-]+)(?:=(?:"([^"]*)"|'([^']*)'|([^\s/>]*)))?/g,r;for(;(r=n.exec(t))!==null;){let s=r[1],i=r[2]??r[3]??r[4]??"";e[s]=i}return e}function Vr(t,e){if(t[e]!=="<")return null;let n=/^<([a-zA-Z0-9_:-]+)((?:\s+[a-zA-Z0-9_:-]+(?:=(?:"[^"]*"|'[^']*'|[^\s/>]*))?)*)?\s*(\/??>)/,r=t.slice(e),s=n.exec(r);if(!s)return null;let i=s[1],o=(s[2]??"").trim(),a=s[3],c=Ia(o);if(a==="/>")return{node:{tag:i,attrs:c,children:[],selfClosing:!0},end:e+s[0].length};let l=e+s[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=Vr(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 Jt(t){let e=ft(t),n=[],r=/<(gsd-[a-zA-Z0-9_-]+)/g,s;for(;(s=r.exec(t))!==null;){let i=s.index;if(gt(i,e))continue;let o=s[1];if(!Ta.has(o))continue;let a=Vr(t,i);a&&(n.push({node:a.node,start:i,end:a.end}),r.lastIndex=a.end)}return n}function fs(t,e,n,r){return t.slice(0,e)+r+t.slice(n)}var Ta,Ys=N(()=>{"use strict";Ta=new Set(["gsd-execute","gsd-arguments","gsd-paste","gsd-include","gsd-version"])});function zr(){let t=new Map,e=new Map,n=r=>{let s=t.get(r)?.value;if(s!==void 0)return s;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,s,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:s,owner:i})):t.set(r,{name:r,value:s,owner:i})},get(r){return t.get(r)?.value},resolve(r){return n(r)},setArray(r,s,i){e.set(r,s),t.set(r,{name:r,value:JSON.stringify(s),owner:i})},getArray(r){if(e.has(r))return e.get(r);let s=t.get(r)?.value;if(s)try{let i=JSON.parse(s);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[s,i]of t)r[s]=i.value;return r}}}var Gr=N(()=>{"use strict"});function Br(t,e,n){let r=t.children.find(g=>g.tag==="settings"),s=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"?`
|
|
338
338
|
`: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?n.set(S,"false",void 0):(n.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",_=g===u.length-1;if(x){if(p>=m.length){if(!("optional"in h.attrs))throw new ht(`Missing required argument '${x}' (type: ${S})`);n.set(x,"",void 0);continue}if(S==="string"&&_)n.set(x,m.slice(p).join(" "),void 0),p=m.length;else if(S==="number"){let P=m[p++],k=Number(P);if(isNaN(k))throw new ht(`Argument '${x}' expected a number, got '${P}'`);n.set(x,String(k),void 0)}else if(S==="boolean"){let P=m[p++].toLowerCase();if(P!=="true"&&P!=="false")throw new ht(`Argument '${x}' expected true/false, got '${P}'`);n.set(x,P,void 0)}else n.set(x,m[p++]??"",void 0)}}let f=m.slice(p).join(" ");if(f){if(i)throw new ht(`Unexpected extra arguments: '${f}'`);s&&n.set("_extra",f,void 0)}}var ht,Hs=N(()=>{"use strict";ht=class extends Error{constructor(e){super(e),this.name="WxpArgumentsError"}}});function gs(t,e,n){switch(t.position){case"project":return Ye.default.resolve(e,t.path);case"pkg":return Ye.default.resolve(n,t.path);case"absolute":return Ye.default.resolve(t.path)}}function Xs(t,e,n,r){let s=Ye.default.resolve(t),i=`${Ye.default.sep}.planning`;if(s.includes(`${i}${Ye.default.sep}`)||s.endsWith(i))return{ok:!1,reason:".planning/ files are never processed by WXP (hard security invariant)"};for(let o of e.untrustedPaths){let a=gs(o,n,r);if(s.startsWith(a+Ye.default.sep)||s===a)return{ok:!1,reason:`File '${t}' is in an explicitly untrusted path: ${a}`}}for(let o of e.trustedPaths){let a=gs(o,n,r);if(s.startsWith(a+Ye.default.sep)||s===a)return{ok:!0}}return{ok:!1,reason:`File '${t}' is not in a trusted WXP path.`}}function Yr(t,e){let n=Ye.default.basename(t);return e.shellBanlist.includes(n)?{ok:!1,reason:`Command '${n}' is explicitly banned by WXP security config.`}:e.shellAllowlist.includes(n)?{ok:!0}:{ok:!1,reason:`Command '${n}' is not in the WXP shell allowlist. Allowed: ${e.shellAllowlist.join(", ")}`}}var Ye,Jr,Yt=N(()=>{"use strict";Ye=W(require("path")),Jr=["pi-gsd-tools","git","node","cat","ls","echo","find"]});function hs(t,e){if(t.attrs.string!==void 0)return t.attrs.string;if(t.attrs.name!==void 0){let n=e.resolve(t.attrs.name)??"",r=t.attrs.wrap;return r?`${r}${n}${r}`:n}return t.attrs.value!==void 0?t.attrs.value:""}function Xr(t,e,n){let r=t.attrs.command??"",s=Yr(r,n);if(!s.ok)throw new yt(r,"",e.snapshot(),s.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=>hs(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,Hr.execFileSync)(r,a,{encoding:"utf8",timeout:n.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 Hr,yt,ys=N(()=>{"use strict";Hr=require("child_process");Yt();yt=class extends Error{constructor(n,r,s,i){super(i);this.command=n;this.stderr=r;this.variableSnapshot=s;this.name="WxpShellError"}command;stderr;variableSnapshot}});function Zr(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"),s=t.children.find(m=>m.tag==="outs");if(!r||!s)throw new xt("<string-op> requires <args> and <outs>");let i=r.children.filter(m=>m.tag==="arg"),o=s.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=hs(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?hs(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,Zs=N(()=>{"use strict";ys();xt=class extends Error{constructor(e){super(e),this.name="WxpStringOpError"}}});function xs(t,e){return t.attrs.name?e.resolve(t.attrs.name)??"":t.attrs.value!==void 0?t.attrs.value:""}function Kr(t){return t.attrs.type==="number"}function Oa(t,e){let n=t.children.find(a=>a.tag==="left"),r=t.children.find(a=>a.tag==="right");if(!n||!r)return!1;if(Kr(n)||Kr(r)){let a=Number(xs(n,e)),c=Number(xs(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=xs(n,e),o=xs(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 Xt(t,e){return t.tag==="and"?t.children.filter(n=>Ht.has(n.tag)).every(n=>Xt(n,e)):t.tag==="or"?t.children.filter(n=>Ht.has(n.tag)).some(n=>Xt(n,e)):Oa(t,e)}function Qr(t,e){let n=t.children.find(s=>s.tag==="condition");if(!n)return!1;let r=n.children.find(s=>Ht.has(s.tag));return r?Xt(r,e):!1}function ei(t,e){let n=t.children.find(r=>Ht.has(r.tag));return n?Xt(n,e):!0}var Da,Ht,ti=N(()=>{"use strict";Da=new Set(["equals","not-equals","starts-with","contains","less-than","greater-than","less-than-or-equal","greater-than-or-equal"]),Ht=new Set([...Da,"and","or"])});function Na(t,e,n){let r=(t.attrs.msg??"").replace(/\{([^}]+)\}/g,(i,o)=>e.resolve(o)??""),s=t.attrs.level;n.onDisplay(r,s==="warning"||s==="error"?s:"info")}function Wa(t,e){let n=t.attrs.src??"",r=t.attrs.out??"",s=t.attrs.path,i=e.get(n);if(i===void 0)throw new Error(`<json-parse>: source variable '${n}' is not defined`);let o;try{o=JSON.parse(i)}catch{throw new Error(`<json-parse>: '${n}' does not contain valid JSON`)}if(s){let a=s.replace(/^\$\.?/,"").split("."),c=o;for(let l of a){if(c===null||typeof c!="object")throw new Error(`<json-parse>: path '${s}' 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 qa(t,e){let n=t.attrs.path??"",r=t.attrs.out??"",s=Zt.default.readFileSync(Kt.default.resolve(n),"utf8");e.set(r,s,void 0)}function La(t,e,n){let r=t.attrs.path??"",s=t.attrs.src??"",i=Kt.default.resolve(r);if(Zt.default.existsSync(i))throw new Error(`<write-file>: '${r}' already exists (create-only, never overwrites)`);for(let a of n.config.trustedPaths){let c=gs(a,n.projectRoot,n.pkgRoot);if(i.startsWith(c+Kt.default.sep)||i===c)throw new Error(`<write-file>: cannot write to trusted harness path '${r}'`)}let o=e.get(s)??"";Zt.default.mkdirSync(Kt.default.dirname(i),{recursive:!0}),Zt.default.writeFileSync(i,o,"utf8")}function Ua(t,e,n){let r=t.attrs.var??"",s=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(s,l,void 0),ei(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(s,m,void 0);let f=e.resolve(`${s}.${l}`)??e.resolve(l)??"";e.set(s,p,void 0);let g=e.resolve(`${s}.${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(s,l,void 0);for(let d of a)Ks(d,e,n)}}}function Ks(t,e,n){switch(t.tag){case"shell":Xr(t,e,n.config);break;case"string-op":Zr(t,e);break;case"json-parse":Wa(t,e);break;case"read-file":qa(t,e);break;case"write-file":La(t,e,n);break;case"display":Na(t,e,n);break;case"for-each":Ua(t,e,n);break;case"if":{let r=Qr(t,e),s=t.children.find(a=>a.tag==="then"),i=t.children.find(a=>a.tag==="else"),o=r?s:i;if(o)for(let a of o.children)Ks(a,e,n);break}case"gsd-execute":Qs(t,e,n);break;default:break}}function Qs(t,e,n){try{for(let r of t.children)Ks(r,e,n)}catch(r){throw r instanceof yt||r instanceof Error?new Ss(r,e.snapshot(),`Execution failed: ${r.message}`):r}}var Zt,Kt,Ss,er=N(()=>{"use strict";Zt=W(require("fs")),Kt=W(require("path"));ys();Zs();ti();Yt();Ss=class extends Error{constructor(n,r,s){super(s);this.cause=n;this.variableSnapshot=r;this.name="WxpExecutionError"}cause;variableSnapshot}});function ni(t,e){let n=ft(t),r=/<gsd-paste\s+name="([^"]+)"\s*\/>/g,s=[],i;for(;(i=r.exec(t))!==null;)gt(i.index,n)||s.push({index:i.index,full:i[0],name:i[1]});for(let a of s)if(e.get(a.name)===void 0)throw new bs(a.name,e.snapshot());let o=t;for(let a=s.length-1;a>=0;a--){let c=s[a],l=e.get(c.name);o=o.slice(0,c.index)+l+o.slice(c.index+c.full.length)}return o}var bs,tr=N(()=>{"use strict";Ys();bs=class extends Error{constructor(n,r){super(`<gsd-paste name="${n}" /> references undefined variable '${n}'`);this.variableName=n;this.variableSnapshot=r;this.name="WxpPasteError"}variableName;variableSnapshot}});function ri(t,e,n,r,s,i="",o=za){let a=Xs(e,n,r,s);if(!a.ok)throw new St(e,new Error(a.reason),{},[],[]);return Ga(t,e,n,r,s,i,o)}function Ga(t,e,n,r,s,i,o){let a=zr(),c=[],l=t,d={config:n,projectRoot:r,pkgRoot:s,onDisplay:o};for(let u=0;u<Va;u++){let p=Jt(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 Jt(l)){if(x.node.tag!=="gsd-include"||gt(x.start,ft(l)))continue;let S=x.node.attrs.path;if(!S)continue;let _=vs.default.resolve(r,S),P=Xs(_,n,r,s);if(!P.ok)throw new Error(`Include rejected: ${P.reason}`);let k=si.default.readFileSync(_,"utf8"),C=vs.default.basename(_,vs.default.extname(_));for(let $ of x.node.children)if($.tag==="gsd-arguments")for(let q of $.children.filter(O=>O.tag==="arg")){let O=q.attrs.name,U=q.attrs.as;if(O&&U){let Y=a.get(O);Y!==void 0&&a.set(U,Y,C)}}let L="include-arguments"in x.node.attrs?`
|
|
339
339
|
${i}`:"";l=fs(l,x.start,x.end,k+L),c.push("gsd-include"),g=!0;break}if(g)continue;for(let x of Jt(l))if(x.node.tag==="gsd-arguments"&&!gt(x.start,ft(l))){Br(x.node,i,a),l=fs(l,x.start,x.end,""),c.push("gsd-arguments"),g=!0;break}if(g)continue;for(let x of Jt(l))if(x.node.tag==="gsd-execute"&&!gt(x.start,ft(l))){Qs(x.node,a,d),l=fs(l,x.start,x.end,""),c.push("gsd-execute"),g=!0;break}if(g)continue;let h=ni(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 si,vs,Va,za,St,ii=N(()=>{"use strict";si=W(require("fs")),vs=W(require("path"));Ys();Gr();Hs();er();tr();Yt();er();ys();tr();Zs();Hs();Va=50,za=()=>{},St=class extends Error{constructor(n,r,s,i,o){super(["WXP Processing Error",`File: ${n}`,`Error: ${r.message}`,`Variable Namespace: ${JSON.stringify(s,null,2)}`,`Pending Operations: [${i.join(", ")}]`,`Completed Operations: [${o.join(", ")}]`].join(`
|
|
340
|
-
`));this.filePath=n;this.cause=r;this.variableSnapshot=s;this.pendingOperations=i;this.completedOperations=o;this.name="WxpProcessingError"}filePath;cause;variableSnapshot;pendingOperations;completedOperations}});var bt,oi,nr,_s,ai=N(()=>{"use strict";bt=require("@oclif/core"),oi=require("@oclif/core"),nr=W(require("path"));ii();Yt();_s=class t extends oi.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:n}=await this.parse(t),r,s;if(e.input!==void 0)r=e.input,s=nr.default.join(e["project-root"],".pi","gsd","workflows","_inline.md");else if(n.file){let o=await import("fs");s=nr.default.resolve(n.file),r=o.default.readFileSync(s,"utf8")}else{this.error("Provide a file argument or --input string");return}let i={trustedPaths:[{position:"project",path:".pi/gsd"},{position:"pkg",path:".gsd/harnesses/pi/get-shit-done"}],untrustedPaths:[],shellAllowlist:[...Jr],shellBanlist:[],shellTimeoutMs:3e4};try{let o=ri(r,s,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 ci={};he(ci,{AuditUatCommand:()=>Bn,CommitCommand:()=>ns,ConfigEnsureSectionCommand:()=>Rn,ConfigGetCommand:()=>Cn,ConfigNewProjectCommand:()=>jn,ConfigSetCommand:()=>$n,ConfigSetModelProfileCommand:()=>An,FrontmatterGetCommand:()=>ss,FrontmatterMergeCommand:()=>is,FrontmatterSetCommand:()=>rs,InitCommand:()=>bn,MilestoneCompleteCommand:()=>Wn,PhaseAddCommand:()=>Fn,PhaseCompleteCommand:()=>Tn,PhaseInsertCommand:()=>Mn,PhaseNextDecimalCommand:()=>En,PhasePlanIndexCommand:()=>Dn,PhaseRemoveCommand:()=>In,ProgressCommand:()=>ls,RequirementsMarkCompleteCommand:()=>qn,RoadmapAnalyzeCommand:()=>wn,RoadmapGetPhaseCommand:()=>kn,RoadmapUpdatePlanProgressCommand:()=>Pn,ScaffoldCommand:()=>es,StateAdvancePlanCommand:()=>fn,StateGetCommand:()=>un,StateJsonCommand:()=>dn,StateLoadCommand:()=>gn,StatePatchCommand:()=>pn,StateUpdateCommand:()=>mn,StateUpdateProgressCommand:()=>hn,StatsCommand:()=>ds,SummaryExtractCommand:()=>ps,TemplateFillCommand:()=>cs,TemplateSelectCommand:()=>as,TodoCompleteCommand:()=>us,TodoMatchPhaseCommand:()=>ms,ValidateAgentsCommand:()=>zn,ValidateConsistencyCommand:()=>Un,ValidateHealthCommand:()=>Vn,VerifyCommand:()=>Gn,WorkstreamCompleteCommand:()=>Xn,WorkstreamCreateCommand:()=>Jn,WorkstreamGetCommand:()=>Kn,WorkstreamListCommand:()=>Yn,WorkstreamProgressCommand:()=>Qn,WorkstreamSetCommand:()=>Zn,WorkstreamStatusCommand:()=>Hn,WxpProcessCommand:()=>_s});var li=N(()=>{"use strict";br();_r();kr();Ar();jr();Rr();Dr();Or();Nr();Wr();qr();Lr();Ur();ai()});var di=ki(($d,Ba)=>{Ba.exports={name:"pi-gsd",version:"2.0.
|
|
340
|
+
`));this.filePath=n;this.cause=r;this.variableSnapshot=s;this.pendingOperations=i;this.completedOperations=o;this.name="WxpProcessingError"}filePath;cause;variableSnapshot;pendingOperations;completedOperations}});var bt,oi,nr,_s,ai=N(()=>{"use strict";bt=require("@oclif/core"),oi=require("@oclif/core"),nr=W(require("path"));ii();Yt();_s=class t extends oi.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:n}=await this.parse(t),r,s;if(e.input!==void 0)r=e.input,s=nr.default.join(e["project-root"],".pi","gsd","workflows","_inline.md");else if(n.file){let o=await import("fs");s=nr.default.resolve(n.file),r=o.default.readFileSync(s,"utf8")}else{this.error("Provide a file argument or --input string");return}let i={trustedPaths:[{position:"project",path:".pi/gsd"},{position:"pkg",path:".gsd/harnesses/pi/get-shit-done"}],untrustedPaths:[],shellAllowlist:[...Jr],shellBanlist:[],shellTimeoutMs:3e4};try{let o=ri(r,s,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 ci={};he(ci,{AuditUatCommand:()=>Bn,CommitCommand:()=>ns,ConfigEnsureSectionCommand:()=>Rn,ConfigGetCommand:()=>Cn,ConfigNewProjectCommand:()=>jn,ConfigSetCommand:()=>$n,ConfigSetModelProfileCommand:()=>An,FrontmatterGetCommand:()=>ss,FrontmatterMergeCommand:()=>is,FrontmatterSetCommand:()=>rs,InitCommand:()=>bn,MilestoneCompleteCommand:()=>Wn,PhaseAddCommand:()=>Fn,PhaseCompleteCommand:()=>Tn,PhaseInsertCommand:()=>Mn,PhaseNextDecimalCommand:()=>En,PhasePlanIndexCommand:()=>Dn,PhaseRemoveCommand:()=>In,ProgressCommand:()=>ls,RequirementsMarkCompleteCommand:()=>qn,RoadmapAnalyzeCommand:()=>wn,RoadmapGetPhaseCommand:()=>kn,RoadmapUpdatePlanProgressCommand:()=>Pn,ScaffoldCommand:()=>es,StateAdvancePlanCommand:()=>fn,StateGetCommand:()=>un,StateJsonCommand:()=>dn,StateLoadCommand:()=>gn,StatePatchCommand:()=>pn,StateUpdateCommand:()=>mn,StateUpdateProgressCommand:()=>hn,StatsCommand:()=>ds,SummaryExtractCommand:()=>ps,TemplateFillCommand:()=>cs,TemplateSelectCommand:()=>as,TodoCompleteCommand:()=>us,TodoMatchPhaseCommand:()=>ms,ValidateAgentsCommand:()=>zn,ValidateConsistencyCommand:()=>Un,ValidateHealthCommand:()=>Vn,VerifyCommand:()=>Gn,WorkstreamCompleteCommand:()=>Xn,WorkstreamCreateCommand:()=>Jn,WorkstreamGetCommand:()=>Kn,WorkstreamListCommand:()=>Yn,WorkstreamProgressCommand:()=>Qn,WorkstreamSetCommand:()=>Zn,WorkstreamStatusCommand:()=>Hn,WxpProcessCommand:()=>_s});var li=N(()=>{"use strict";br();_r();kr();Ar();jr();Rr();Dr();Or();Nr();Wr();qr();Lr();Ur();ai()});var di=ki(($d,Ba)=>{Ba.exports={name:"pi-gsd",version:"2.0.9",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:["dist","scripts/postinstall.js",".gsd/harnesses","README.md","LICENSE","prompts"],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:["./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.0.0",typescript:"^5.0.0",vitest:"^4.1.2"}}});var ws={};he(ws,{cmdExtractMessages:()=>Za,cmdProfileSample:()=>Ka,cmdScanSessions:()=>Xa});function sr(t){if(t)return t;let e=process.env.HOME??"",n=Ie.join(e,".agent","projects");return ee.existsSync(n)?n:Ie.join(e,".claude","projects")}function rr(){let t=process.env.HOME??"";return Ie.join(t,".pi","agent","sessions")}function ir(t){return t.startsWith("--")&&t.endsWith("--")?"/"+t.slice(2,-2).replace(/-/g,"/"):t}function Ja(t){try{let e=ee.readFileSync(t,"utf-8").split(`
|
|
341
341
|
`).find(r=>r.trim().length>0);if(!e)return!1;let n=JSON.parse(e);return n.type==="session"&&"version"in n}catch{return!1}}function Ya(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 Ha(t){try{let e=ee.readFileSync(t,"utf-8").split(`
|
|
342
342
|
`).filter(Boolean),n=[];for(let r of e)try{let s=JSON.parse(r);s.type==="message"&&s.message&&n.push(s)}catch{}return n}catch{return[]}}async function Xa(t,e,n){let s=(e.harness??null)==="pi",i=rr(),o=ee.existsSync(i),a=[];if(o)try{let m=ee.readdirSync(i,{withFileTypes:!0}).filter(p=>p.isDirectory());for(let p of m){let f=Ie.join(i,p.name),g=ee.readdirSync(f).filter(h=>h.endsWith(".jsonl"));a.push({name:p.name,sessions:g.length,path:f,source:"pi",cwd:ir(p.name)})}}catch{}let c=sr(s&&!t?null:t),l=!s||t?ee.existsSync(c):!1,d=[];if(l&&(!s||t))try{let m=ee.readdirSync(c,{withFileTypes:!0}).filter(p=>p.isDirectory());for(let p of m){let f=Ie.join(c,p.name),g=ee.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=s?[...a,...d]:[...d,...a];if(u.length===0){let m=[];o?m.push(i):m.push(i+" (not found)"),s||m.push(l?c:c+" (not found)"),y({available:!1,reason:`No sessions found. Searched: ${m.join(", ")}`,projects:[],count:0},n);return}y({available:!0,pi_base:o?i:null,claude_base:l?c:null,projects:u,count:u.length},n)}async function Za(t,e,n,r){let s=rr(),i=null,o="claude";if(ee.existsSync(s)){let d=Ie.join(s,t);if(ee.existsSync(d))i=d,o="pi";else try{let u=ee.readdirSync(s,{withFileTypes:!0}).filter(m=>m.isDirectory());for(let m of u){let p=ir(m.name);if(p.endsWith("/"+t)||p===t||m.name===t){i=Ie.join(s,m.name),o="pi";break}}}catch{}}if(!i){let d=sr(r),u=Ie.join(d,t);ee.existsSync(u)&&(i=u,o="claude")}if(!i){y({error:`Project not found: ${t}`,available_projects:[]},n);return}let a=[],c=ee.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=Ie.join(i,d);if(o==="pi"||Ja(u))try{let m=ee.readFileSync(u,"utf-8").split(`
|
|
343
343
|
`).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=ee.readFileSync(u,"utf-8").split(`
|