@swifty.js/swifty 0.0.13 → 0.0.15
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/{agent-NX7ND57K.js → agent-KIMFD4RH.js} +1 -1
- package/dist/anthropic-K3YA64W4.js +4 -0
- package/dist/checker-RSBYV6EP.js +4 -0
- package/dist/chunk-32AZCTP4.js +4 -0
- package/dist/chunk-5CPQ6RWA.js +4 -0
- package/dist/chunk-6AOZQ3ON.js +354 -0
- package/dist/{chunk-GQ2COSTQ.js → chunk-6ZXBZB2Y.js} +1 -1
- package/dist/chunk-A3NIT2ZF.js +4 -0
- package/dist/{chunk-RNUCVDX2.js → chunk-CYMOBNZF.js} +26 -24
- package/dist/chunk-E55KH72M.js +4 -0
- package/dist/{chunk-MSJOPX6X.js → chunk-F24VPQ2I.js} +1 -1
- package/dist/{chunk-M5AOLYFS.js → chunk-J5LWUHF6.js} +14 -14
- package/dist/chunk-MNZYPUTY.js +4 -0
- package/dist/glob.wasm +0 -0
- package/dist/main.js +204 -203
- package/dist/{openai-L6LWA2MU.js → openai-HEG2P5DF.js} +1 -1
- package/dist/{server-TYLDPSLT.js → server-EXSHPT5H.js} +20 -20
- package/dist/tool-filter-334HOWZK.js +4 -0
- package/package.json +3 -3
- package/dist/anthropic-EAEDMTTA.js +0 -4
- package/dist/builtin/fullstack-interview/SKILL.md +0 -105
- package/dist/builtin/teach-me/SKILL.md +0 -399
- package/dist/builtin/teach-me/references/pedagogy.md +0 -244
- package/dist/checker-NNTNXNYP.js +0 -4
- package/dist/chunk-QNFMJDDO.js +0 -354
- package/dist/chunk-R7VREEYH.js +0 -4
- package/dist/chunk-UBV5T4TV.js +0 -4
- package/dist/glob_addon.node +0 -0
- package/dist/tool-filter-ERUPKZYV.js +0 -4
package/dist/chunk-R7VREEYH.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
|
-
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{a as w}from"./chunk-7MHXMDYC.js";import{D as u,I as D,S as d,e as k}from"./chunk-M5AOLYFS.js";import{readFileSync as $,writeFileSync as j,mkdirSync as A,statSync as S}from"fs";import{homedir as _,tmpdir as M}from"os";import{join as h,resolve as l,dirname as W}from"path";var E=D({module:"permissions"}),T=[{re:/rm\s+(-rf?|--recursive)\s+[/~]/,reason:"recursive force delete root"},{re:/rm\s+-rf?\s+\*/,reason:"recursive force delete wildcard"},{re:/mkfs\./,reason:"format disk"},{re:/dd\s+if=/,reason:"direct write to disk device"},{re:/>\s*\/dev\/sd/,reason:"overwrite disk device"},{re:/chmod\s+-R?\s*777\s+\//,reason:"recursive chmod root"},{re:/:\(\)\{\s*:\|\s*:\s*&\s*\}\s*;/,reason:"fork bomb"},{re:/curl\s+.*\|\s*(ba)?sh/,reason:"pipe remote script"},{re:/wget\s+.*\|\s*(ba)?sh/,reason:"pipe remote script"},{re:/git\s+push\s+.*--force/,reason:"force push"},{re:/git\s+reset\s+--hard/,reason:"hard reset"},{re:/git\s+clean\s+-f/,reason:"force clean untracked files"},{re:/git\s+checkout\s+\./,reason:"discard all changes"},{re:/git\s+branch\s+-D/,reason:"force delete branch"}],z=["ls","pwd","echo","cat","head","tail","wc","date","whoami","uname","hostname","which","type","file","git status","git log","git diff","git branch","git show","git rev-parse","git remote","bun test","bun run","npm test","npm run","go test","go build","go vet","python -c","node -e"],L={Bash:"command",ReadFile:"file_path",WriteFile:"file_path",EditFile:"file_path",Glob:"pattern",Grep:"pattern"},C=[".swifty/config.yaml",".swifty/permissions.local.yaml",".swifty/skills/"];function y(i,e){let t=L[i];if(!t)return"";let s=e[t];return typeof s=="string"?s:""}var R=class{allowedRoots;denyWritePaths;projectDir;constructor(e){this.projectDir=l(e),this.allowedRoots=[this.projectDir,M()],this.denyWritePaths=C.map(t=>h(this.projectDir,t))}addRoot(e){this.allowedRoots.push(l(e))}addDenyWrite(e){this.denyWritePaths.push(l(e))}checkDenyWrite(e){let t=l(e);for(let s of this.denyWritePaths)if(t.startsWith(s))return{effect:"deny",reason:`Path ${e} is in deny-write list`};return null}check(e){let t=l(e);for(let s of this.allowedRoots)if(t.startsWith(s))return null;return{effect:"deny",reason:`Path ${e} is outside allowed directories`}}};function O(i,e){let t="^"+i.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$";try{return new RegExp(t).test(e)}catch(s){return E.error({err:s},"permissions operation failed"),!1}}var Y=/^(\w+)\((.+)\)$/;function x(i){let e;try{e=$(i,"utf-8")}catch(r){return r.code!=="ENOENT"&&E.error({err:r},"permissions operation failed"),[]}let t=u.object({rule:u.string().optional(),effect:u.string().optional()}),s;try{let r=w.load(e);s=k(u.array(t),r)}catch(r){return E.error({err:r},"permissions operation failed"),[]}let n=[];for(let r of s){if(r.effect!=="allow"&&r.effect!=="deny"&&r.effect!=="ask")continue;let o=Y.exec((r.rule??"").trim());o&&n.push({tool:o[1],pattern:o[2],effect:r.effect})}return n}function b(i,e,t){let s=null;for(let n of i)if(!(n.tool!==e&&n.tool!=="*")&&O(n.pattern,t)){if(n.effect==="deny")return"deny";n.effect==="ask"?s="ask":s??="allow"}return s}var v=class{userPath;projectPath;localPath;cache=new Map;constructor(e){this.userPath=h(_(),".swifty","permissions.yaml"),this.projectPath=h(e,".swifty","permissions.yaml"),this.localPath=h(e,".swifty","permissions.local.yaml")}rulesFor(e){let t;try{t=S(e,{bigint:!0})}catch{return this.cache.delete(e),[]}let s=this.cache.get(e);if(s?.mtimeNs===t.mtimeNs&&s.size===t.size)return s.rules;let n=x(e);return this.cache.set(e,{mtimeNs:t.mtimeNs,size:t.size,rules:n}),n}snapshot(){return[this.userPath,this.projectPath,this.localPath].flatMap(e=>this.rulesFor(e))}evaluate(e,t){return b(this.snapshot(),e,t)}appendLocalRule(e){A(W(this.localPath),{recursive:!0});let t=x(this.localPath);if(t.some(r=>r.tool===e.tool&&r.pattern===e.pattern&&r.effect===e.effect))return;t.push(e);let n=t.map(r=>({rule:`${r.tool}(${r.pattern})`,effect:r.effect}));j(this.localPath,w.dump(n),"utf-8")}};function N(i){for(let e of T)if(e.re.test(i))return e.reason;return""}function G(i){let e=i.trim();return e.includes(">")||e.includes("|")||e.includes(";")||e.includes("&&")||e.includes("$(")||e.includes("`")?!1:z.some(t=>e===t||e.startsWith(t+" ")||e.startsWith(t+" "))}function I(i,e){switch(i){case"bypassPermissions":return"allow";case"plan":return e==="read"?"allow":"ask";case"acceptEdits":return e==="command"?"ask":"allow";default:return e==="read"?"allow":"ask"}}var F=class{mode;planFilePath="";sandboxEnabled=!1;sandboxAutoAllow=!1;sandbox;ruleEngine;constructor(e,t="default"){this.mode=t,this.sandbox=new R(e),this.ruleEngine=new v(e)}check(e,t,s){let n=y(e,s),r=null,o=()=>r??=this.ruleEngine.snapshot();if(this.mode==="plan"&&(e==="WriteFile"||e==="EditFile")&&d(s,"file_path","").includes(".swifty/plans/"))return{effect:"allow",reason:"Plan file write allowed in plan mode"};if(t==="command"&&G(n))return{effect:"allow",reason:"Safe read-only command"};let a=t==="command"?N(n):"";if(a)return{effect:"deny",reason:`Dangerous command blocked: ${a}`};if(this.sandboxEnabled&&this.sandboxAutoAllow&&t==="command"){let f=d(s,"command").split(/\s*(?:&&|\|\||[;|])\s*/).map(g=>g.trim()).filter(Boolean),c=!1;for(let g of f){let P=b(o(),e,g);if(P==="deny")return{effect:"deny",reason:"Permission rule: deny"};P==="ask"&&(c=!0)}return c?{effect:"ask",reason:"Permission rule: ask (sandbox does not override)"}:{effect:"allow",reason:"Sandbox auto-allow: OS sandbox active"}}let p=d(s,"file_path",d(s,"path",""));if((t==="read"||t==="write")&&p){if(t==="write"){let c=this.sandbox.checkDenyWrite(p);if(c)return c}let f=this.sandbox.check(p);if(f&&this.mode!=="bypassPermissions"){let c=this.ruleEngine.evaluate(e,n);return c?{effect:c,reason:`Permission rule: ${c}`}:{effect:"ask",reason:f.reason}}}let m=b(o(),e,n);return m?{effect:m,reason:`Permission rule: ${m}`}:{effect:I(this.mode,t),reason:`Mode: ${this.mode}`}}allowExtraRoot(e){this.sandbox.addRoot(e)}allowAlways(e,t){let s=y(e,t),n=e==="ReadFile"||e==="WriteFile"||e==="EditFile",r;if(n&&s){let o=l(s),a=!1;try{a=S(o).isDirectory()}catch{}r=h(a?o:W(o),"*")}else r=s.trim().split(/\s+/).slice(0,2).join(" ")+"*";this.ruleEngine.appendLocalRule({tool:e,pattern:r,effect:"allow"})}describeToolAction(e,t){let s=y(e,t);if(s)return s;let n=[];for(let[r,o]of Object.entries(t)){let a=String(o);a.length>80&&(a=a.slice(0,80)+"..."),n.push(`${r}: ${a}`)}return n.join(", ")}};export{y as a,R as b,b as c,v as d,F as e};
|
package/dist/chunk-UBV5T4TV.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
|
-
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
var l=class{tools=new Map;discovered=new Set;register(e){this.tools.set(e.name,e)}get(e){return this.tools.get(e)}listTools(){return[...this.tools.values()]}getAllSchemas(e="anthropic"){let o=[];for(let t of this.tools.values()){if(t.deferred&&!this.discovered.has(t.name))continue;let s=t.schema();e==="anthropic"?o.push({name:s.name,description:s.description,input_schema:{type:"object",properties:s.input_schema.properties,required:s.input_schema.required??[]}}):o.push({strict:!1,type:"function",name:s.name,description:s.description,parameters:s.input_schema})}return o}getDeferredToolNames(){let e=[];for(let o of this.tools.values())o.deferred&&!this.discovered.has(o.name)&&e.push(o.name);return e}getDeferredTools(){return[...this.tools.values()].filter(e=>e.deferred&&!this.discovered.has(e.name))}searchDeferred(e,o=5){let t=e.toLowerCase(),s=[];for(let r of this.tools.values())if(!(!r.deferred||this.discovered.has(r.name))&&(r.name.toLowerCase().includes(t)||r.description.toLowerCase().includes(t))&&(s.push(r),s.length>=o))break;return s}findDeferredByNames(e){let o=new Map;for(let[t,s]of this.tools)o.set(t.toLowerCase(),s);return e.map(t=>o.get(t.toLowerCase())).filter(t=>t?.deferred??!1)}markDiscovered(e){this.discovered.add(e)}isDiscovered(e){return this.discovered.has(e)}};var f=new Set(["TaskOutput","ExitPlanMode","EnterPlanMode","Agent","AskUserQuestion","TaskStop","Workflow"]),S=new Set(["TeamCreate","TeamDelete"]),u=new Set(["TaskOutput","ExitPlanMode","EnterPlanMode","Agent","AskUserQuestion","TaskStop","Workflow"]),h=new Set(["ReadFile","WebSearch","TodoWrite","Grep","WebFetch","Glob","Bash","EditFile","WriteFile","NotebookEdit","Skill","LoadSkill","SyntheticOutput","ToolSearch","EnterWorktree","ExitWorktree"]);function T(n){return n.startsWith("mcp__")}function O(n,e,o,t,s=!1){let r=new Set(o??[]),a=new Set(e??[]),d=a.size>0&&!(a.size===1&&a.has("*")),c=new l;for(let p of n.listTools()){let i=p.name;if(T(i)){c.register(p);continue}f.has(i)||s&&u.has(i)||t&&!h.has(i)||r.has(i)||d&&!a.has(i)||c.register(p)}return c}var m="agent:builtin:fork";function w(n){let e=new l;for(let o of n.listTools())if(o.name==="Agent"&&"querySource"in o){let t=Object.create(Object.getPrototypeOf(o),Object.getOwnPropertyDescriptors(o));t.querySource=m,e.register(t)}else e.register(o);return e}export{l as a,f as b,S as c,u as d,h as e,O as f,m as g,w as h};
|
package/dist/glob_addon.node
DELETED
|
Binary file
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
|
-
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g}from"./chunk-UBV5T4TV.js";import"./chunk-X3UA5OZL.js";export{a as ALL_AGENT_DISALLOWED_TOOLS,d as ASYNC_AGENT_ALLOWED_TOOLS,c as CUSTOM_AGENT_DISALLOWED_TOOLS,f as FORK_QUERY_SOURCE,b as TEAMMATE_DISALLOWED_TOOLS,g as cloneRegistryForFork,e as filterToolsForAgent};
|