@swifty.js/swifty 0.0.5 → 0.0.6
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.
|
@@ -339,7 +339,7 @@ Please revise the plan accordingly and resubmit.`}return null}getMember(e){retur
|
|
|
339
339
|
`))}return e}};function RE(t){return t==="in-process"||t==="tmux"||t==="iterm"}var CE=new Set(["Agent","SendMessage","TaskStop","SyntheticOutput","TeamDelete"]);function ME(t){return CE.has(t)}function XN(t=!1){return t?ME:()=>!0}function QN(t=!1){return t}import{createHash as zE}from"crypto";import{existsSync as Zs,mkdirSync as AE,readFileSync as Js,unlinkSync as IE,writeFileSync as Ys}from"fs";import{join as Xs,resolve as OE}from"path";var Fr=C({module:"file-history"}),Tg=100,xg=60;function $g(t,e){return`${zE("sha256").update(t).digest("hex").slice(0,16)}@v${String(e)}`}var Eg=class{sessionDir;trackedFiles=new Map;snapshots=[];constructor(e,r){this.sessionDir=Xs(e,".swifty","file-history",r),AE(this.sessionDir,{recursive:!0})}trackEdit(e){let r=OE(e),o=(this.trackedFiles.get(r)??0)+1;if(Zs(r))try{let s=Js(r),i=$g(r,o);Ys(Xs(this.sessionDir,i),s)}catch(s){Fr.error({err:s},"file-history operation failed")}this.trackedFiles.set(r,o)}makeSnapshot(e,r){let n=r;n.length>xg&&(n=n.slice(0,xg)+"...");let o={};for(let[s,i]of this.trackedFiles){let a=$g(s,i),c=Xs(this.sessionDir,a);if(!Zs(c)&&Zs(s))try{Ys(c,Js(s))}catch(u){Fr.error({err:u},"file-history operation failed")}o[s]={backupPath:c,version:i,time:new Date().toISOString()}}this.snapshots.push({messageIndex:e,userText:n,backups:o,timestamp:new Date().toISOString()}),this.snapshots.length>Tg&&(this.snapshots=this.snapshots.slice(this.snapshots.length-Tg))}rewind(e){if(e<0||e>=this.snapshots.length)throw new Error(`Invalid snapshot index: ${String(e)}`);let r=this.snapshots[e],n=[];for(let[o,s]of Object.entries(r.backups)){let i=null;try{i=Js(s.backupPath)}catch(l){if(Fr.error({err:l},"file-history operation failed"),Zs(o))try{IE(o)}catch(d){Fr.error({err:d},"file-history operation failed")}continue}let a=null;try{a=Js(o)}catch(l){Fr.error({err:l},"file-history operation failed")}let c=i.toString(),u=a?.toString();if(c!==u)try{Ys(o,i),n.push(o)}catch(l){Fr.error({err:l},"file-history operation failed")}}this.snapshots=this.snapshots.slice(0,e+1);for(let[o,s]of Object.entries(r.backups))this.trackedFiles.set(o,s.version);return n}getSnapshots(){return[...this.snapshots]}hasSnapshots(){return this.snapshots.length>0}save(){let e=Xs(this.sessionDir,"snapshots.json");Ys(e,JSON.stringify(this.snapshots,null,2),"utf-8")}};import{statSync as Rg}from"fs";var Pg=C({module:"file-state-cache"}),Cg=class{cache=new Map;record(e,r){this.cache.set(e,r)}check(e){let r=this.cache.get(e);if(r===void 0)return{ok:!1,error:"Error: file has not been read yet, read it first before editing."};let n;try{n=Rg(e).mtimeMs}catch(o){return Pg.error({err:o},"file state cache operation failed"),{ok:!0}}return n>r?{ok:!1,error:"Error: file has been modified since last read, read it again before editing."}:{ok:!0}}update(e){let r;try{r=Rg(e).mtimeMs}catch(n){Pg.error({err:n},"file state cache operation failed"),this.cache.delete(e);return}this.cache.set(e,r)}};var jE=O.object({label:O.string(),description:O.string().optional()}),NE=O.object({question:O.string(),header:O.string(),options:O.array(jE),multiSelect:O.boolean()}),Mg=class{constructor(e){this.ask=e}ask;name="AskUserQuestion";description=`
|
|
340
340
|
Ask the user 1 to 4 single-choice or multiple-choices questions and wait for their answers. Each question needs 1 to 4 options; an "Other" option for custom input is added automatically.
|
|
341
341
|
Set "multiSelect: true" when choices are not mutually exclusive (single-choice), set "multiSelect: false" otherwise (multiple-choices).
|
|
342
|
-
`;category="read";schema(){let e={type:"object",properties:{questions:{type:"array",description:"question",minItems:1,maxItems:4,items:{type:"object",properties:{question:{type:"string",description:"The question to ask"},header:{type:"string",description:"Short label/category (<=12 chars)"},options:{type:"array",description:"options",minItems:2,maxItems:4,items:{type:"object",properties:{label:{type:"string",description:"label"},description:{type:"string",description:"description"}},required:["label"]}},multiSelect:{type:"boolean",description:"Set to true for multiple-choice, false for single-choice"}},required:["question","header","options","multiSelect"]}}},required:["questions"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let{success:n,data:o,error:s}=await Ml(O.object({questions:O.array(NE)}),r);if(!n)return{output:s.message,isError:!0};let i=o.questions;if(!Array.isArray(i)||i.length<1||i.length>4)return{output:"Error: must have 1-4 questions",isError:!0};for(let u of i)if(!Array.isArray(u.options)||u.options.length<2||u.options.length>4)return{output:`Error: question '${u.question}' must have 2-4 options`,isError:!0};let a=await this.ask(i);return{output:`User has answered your questions: ${Object.entries(a).map(([u,l])=>`"${u}" = "${l}"`).join(", ")}. You can now continue with the user's answers`,isError:!1}}};export{ni as a,Ql as b,eu as c,VE as d,ou as e,mo as f,fo as g,fu as h,go as i,_o as j,wo as k,vo as l,ku as m,Tu as n,Cu as o,Mu as p,TR as q,xR as r,zR as s,
|
|
342
|
+
`;category="read";schema(){let e={type:"object",properties:{questions:{type:"array",description:"question",minItems:1,maxItems:4,items:{type:"object",properties:{question:{type:"string",description:"The question to ask"},header:{type:"string",description:"Short label/category (<=12 chars)"},options:{type:"array",description:"options",minItems:2,maxItems:4,items:{type:"object",properties:{label:{type:"string",description:"label"},description:{type:"string",description:"description"}},required:["label"]}},multiSelect:{type:"boolean",description:"Set to true for multiple-choice, false for single-choice"}},required:["question","header","options","multiSelect"]}}},required:["questions"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let{success:n,data:o,error:s}=await Ml(O.object({questions:O.array(NE)}),r);if(!n)return{output:s.message,isError:!0};let i=o.questions;if(!Array.isArray(i)||i.length<1||i.length>4)return{output:"Error: must have 1-4 questions",isError:!0};for(let u of i)if(!Array.isArray(u.options)||u.options.length<2||u.options.length>4)return{output:`Error: question '${u.question}' must have 2-4 options`,isError:!0};let a=await this.ask(i);return{output:`User has answered your questions: ${Object.entries(a).map(([u,l])=>`"${u}" = "${l}"`).join(", ")}. You can now continue with the user's answers`,isError:!1}}};export{ni as a,Ql as b,eu as c,VE as d,ou as e,mo as f,fo as g,fu as h,go as i,_o as j,wo as k,vo as l,ku as m,Tu as n,Cu as o,Mu as p,TR as q,xR as r,zR as s,yt as t,ys as u,Ff as v,ph as w,mh as x,l1 as y,Is as z,kh as A,Eh as B,W1 as C,Rh as D,Ch as E,Mh as F,zh as G,Ah as H,Ih as I,Oh as J,Fs as K,Hs as L,Ws as M,Vs as N,Fh as O,Hh as P,Us as Q,Wh as R,Vh as S,Jh as T,Xh as U,Uj as V,Qh as W,eg as X,tg as Y,Yj as Z,rg as _,ng as $,og as aa,to as ba,wN as ca,vN as da,Tl as ea,SN as fa,kg as ga,XN as ha,QN as ia,Eg as ja,Cg as ka,Mg as la};
|
|
343
343
|
/*! Bundled license information:
|
|
344
344
|
|
|
345
345
|
content-type/index.js:
|
package/dist/glob_addon.node
CHANGED
|
Binary file
|