@neurynae/toolcairn-mcp 1.1.0 → 1.1.1

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.
@@ -213,7 +213,7 @@ ${i}`,n),this.line=r,this.column=s,this.codeblock=i}};function Dk(t,e){let n=0;f
213
213
  `),r=0,s=!1;for(let i of n){let o=i.split("#")[0]?.trim()??"";if(!o)continue;let a=o.match(/^group\s+(:[\w,\s:]+?)\s*do\s*$/);if(a&&a[1]){r++,s=/\b(development|test)\b/.test(a[1]);continue}if(o==="end"&&r>0){r--,r===0&&(s=!1);continue}let c=o.match(/^gem\s+(['"])([A-Za-z0-9_\-.]+)\1(?:\s*,\s*(['"])([^'"]+)\3)?/);c?.[2]&&e.push({name:c[2],constraint:c[4],dev:s})}return e}var Qg=async({workspace_dir:t,workspace_rel:e})=>{let n=[],r=[],s=Zg(t,"Gemfile.lock"),i=Zg(t,"Gemfile");if(await P(s))try{let o=await kl(s,"utf-8"),a=e?`${e}/Gemfile.lock`:"Gemfile.lock",c=new Set;if(await P(i))try{let l=await kl(i,"utf-8");for(let u of Xg(l))c.add(u.name)}catch{}for(let l of YA(o))c.size>0&&!c.has(l.name)||r.push({name:l.name,ecosystem:"rubygems",version_constraint:void 0,resolved_version:l.version,section:"dep",manifest_file:a,workspace_path:e});if(r.length>0)return{ecosystem:"rubygems",tools:r,warnings:n}}catch(o){n.push({scope:"parser:ruby",path:s,message:`Failed to parse Gemfile.lock: ${o instanceof Error?o.message:String(o)}`})}if(await P(i))try{let o=await kl(i,"utf-8"),a=e?`${e}/Gemfile`:"Gemfile";for(let c of Xg(o))r.push({name:c.name,ecosystem:"rubygems",version_constraint:c.constraint,section:c.dev?"dev":"dep",manifest_file:a,workspace_path:e});n.push({scope:"parser:ruby",path:a,message:"No Gemfile.lock \u2014 resolved_version unavailable."})}catch(o){n.push({scope:"parser:ruby",path:i,message:`Failed to parse Gemfile: ${o instanceof Error?o.message:String(o)}`})}return{ecosystem:"rubygems",tools:r,warnings:n}};d();import{readFile as ey}from"fs/promises";import{join as ty}from"path";function zA(t){let e;try{e=JSON.parse(t)}catch{return[]}let n=[];for(let r of e.pins??[])r.identity&&n.push({name:r.identity,version:r.state?.version});for(let r of e.object?.pins??[])r.package&&n.push({name:r.package,version:r.state?.version});return n}function HA(t){let e=[],n=/\.package\(\s*(?:name:\s*"[^"]+"\s*,\s*)?url:\s*"([^"]+)"\s*,\s*([^)]+)\)/g,r;for(;(r=n.exec(t))!==null;){let s=r[1],i=r[2]?.trim();if(!s)continue;let o=s.split("/").pop()?.replace(/\.git$/,"");o&&e.push({name:o,constraint:i})}return e}var ny=async({workspace_dir:t,workspace_rel:e})=>{let n=[],r=[],s=ty(t,"Package.resolved");if(await P(s))try{let o=await ey(s,"utf-8"),a=e?`${e}/Package.resolved`:"Package.resolved";for(let c of zA(o))r.push({name:c.name,ecosystem:"swift-pm",resolved_version:c.version,section:"dep",manifest_file:a,workspace_path:e});if(r.length>0)return{ecosystem:"swift-pm",tools:r,warnings:n}}catch(o){n.push({scope:"parser:swift",path:s,message:`Failed to parse Package.resolved: ${o instanceof Error?o.message:String(o)}`})}let i=ty(t,"Package.swift");if(await P(i))try{let o=await ey(i,"utf-8"),a=e?`${e}/Package.swift`:"Package.swift";for(let c of HA(o))r.push({name:c.name,ecosystem:"swift-pm",version_constraint:c.constraint,section:"dep",manifest_file:a,workspace_path:e});n.push({scope:"parser:swift",path:a,message:"No Package.resolved \u2014 resolved_version unavailable."})}catch(o){n.push({scope:"parser:swift",path:i,message:`Failed to parse Package.swift: ${o instanceof Error?o.message:String(o)}`})}return{ecosystem:"swift-pm",tools:r,warnings:n}};var ry={npm:zg,pypi:Hg,cargo:th,go:qg,rubygems:Qg,maven:Kg,gradle:Dg,composer:ih,hex:Jg,pub:Hm,nuget:Mg,"swift-pm":ny};d();d();var iy=H(oe(),1);import{readFile as ZA,readdir as sy}from"fs/promises";import{homedir as XA}from"os";import{join as xl}from"path";d();function ie(t){if(!t)return;let e=t.trim();if(!e||(e.startsWith("git+")&&(e=e.slice(4)),e.startsWith("github:")&&(e=`https://github.com/${e.slice(7)}`),/^[A-Za-z0-9_.\-]+\/[A-Za-z0-9_.\-]+$/.test(e)&&(e=`https://github.com/${e}`),e=e.replace(/^git@github\.com:/,"https://github.com/"),e=e.replace(/^ssh:\/\/git@github\.com\//,"https://github.com/"),e=e.replace(/^http:\/\//,"https://"),!/^https:\/\/github\.com\//.test(e)))return;e=e.replace(/\.git$/,""),e=e.replace(/\/$/,"");let n=e.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)/);if(n)return`https://github.com/${n[1]}/${n[2]}`}var QA=(0,iy.createMcpLogger)({name:"@toolcairn/tools:resolver:cargo"});async function eC(t,e){let n=xl(XA(),".cargo","registry","src");if(!await fe(n))return null;let r;try{r=await sy(n)}catch{return null}let s=[];for(let i of r){let o=xl(n,i);if(!await fe(o))continue;let a;try{a=await sy(o)}catch{continue}for(let c of a){if(!c.startsWith(`${t}-`)||e&&c!==`${t}-${e}`)continue;let l=xl(o,c,"Cargo.toml");await P(l)&&s.push(l)}}return s.length===0?null:(s.sort(),s[s.length-1]??null)}async function oy(t,e,n,r={}){let s=await eC(n,r.resolved_version);if(!s)return{};try{let i=await ZA(s,"utf-8"),a=Ue(i).package;if(!a)return{};let c={};a.name&&a.name!==n&&(c.canonical_package_name=a.name),a.version&&(c.resolved_version=a.version);let l=ie(a.repository??a.homepage);return l&&(c.github_url=l),c}catch(i){return QA.debug({err:i instanceof Error?i.message:String(i),manifestPath:s},"Failed to parse cached Cargo.toml"),{}}}d();var ay=H(oe(),1);import{readFile as tC}from"fs/promises";import{join as nC}from"path";var rC=(0,ay.createMcpLogger)({name:"@toolcairn/tools:resolver:composer"});async function cy(t,e,n){let r=nC(t,"vendor",n,"composer.json");if(!await P(r))return{};try{let s=JSON.parse(await tC(r,"utf-8")),i={};s.name&&s.name!==n&&(i.canonical_package_name=s.name),s.version&&(i.resolved_version=s.version);let o=s.source?.url??s.support?.source??s.homepage,a=ie(o);return a&&(i.github_url=a),i}catch(s){return rC.debug({err:s instanceof Error?s.message:String(s),path:r},"Failed to parse installed composer.json"),{}}}d();function ly(t,e,n){if(!n.startsWith("github.com/"))return{};let s=n.slice(11).split("/");if(s.length<2||!s[0]||!s[1])return{};let i=s[0],o=s[1];o=o.replace(/\.git$/,"");let a=ie(`https://github.com/${i}/${o}`);return a?{github_url:a}:{}}d();import{readdir as dy}from"fs/promises";import{homedir as oC}from"os";import{join as Tl}from"path";d();var uy=H(oe(),1),fy=H(Kr(),1);import{readFile as sC}from"fs/promises";var iC=(0,uy.createMcpLogger)({name:"@toolcairn/tools:resolver:pom"});async function Li(t,e){if(!await P(t))return{};try{let n=await sC(t,"utf-8"),i=new fy.XMLParser({ignoreAttributes:!0,parseTagValue:!0}).parse(n).project;if(!i)return{};let o={},a=i.groupId&&i.artifactId?`${i.groupId}:${i.artifactId}`:void 0;a&&a!==e&&(o.canonical_package_name=a),i.version&&(o.resolved_version=i.version);let c=[i.scm?.url,i.scm?.connection,i.scm?.developerConnection,i.url];for(let l of c){let u=ie(l);if(u){o.github_url=u;break}}return o}catch(n){return iC.debug({err:n instanceof Error?n.message:String(n),path:t},"Failed to parse .pom"),{}}}async function aC(t,e,n){let r=Tl(oC(),".gradle","caches","modules-2","files-2.1",t,e);if(!await fe(r))return null;let s;try{s=await dy(r)}catch{return null}let i=n&&s.includes(n)?n:s.sort().at(-1);if(!i)return null;let o=Tl(r,i),a;try{a=await dy(o)}catch{return null}for(let c of a)return Tl(o,c,`${e}-${i}.pom`);return null}async function hy(t,e,n,r={}){let s=n.indexOf(":");if(s<0)return{};let i=n.slice(0,s),o=n.slice(s+1);if(!i||!o)return{};let a=await aC(i,o,r.resolved_version);return a?Li(a,n):{}}d();var my=H(oe(),1);import{readFile as py}from"fs/promises";import{join as Ol}from"path";var cC=(0,my.createMcpLogger)({name:"@toolcairn/tools:resolver:hex"});function lC(t){let e=t.match(/<<"GitHub">>\s*,\s*<<"([^"]+)">>/i);if(e?.[1]||(e=t.match(/<<"[^"]*github[^"]*">>\s*,\s*<<"(https?:\/\/[^"]+)">>/i),e?.[1]))return e[1]}function uC(t){let e=t.match(/@source_url\s*\(?\s*["']([^"']+)["']/);if(e?.[1])return e[1];let n=t.match(/\bsource_url\s*:\s*["']([^"']+)["']/);if(n?.[1])return n[1]}async function gy(t,e,n){let r=Ol(t,"deps",n),s={},i=Ol(r,"hex_metadata.config");if(await P(i))try{let o=await py(i,"utf-8"),a=lC(o),c=ie(a);c&&(s.github_url=c)}catch(o){cC.debug({err:o instanceof Error?o.message:String(o),metaPath:i},"Failed to read hex_metadata.config")}if(!s.github_url){let o=Ol(r,"mix.exs");if(await P(o))try{let a=await py(o,"utf-8"),c=uC(a),l=ie(c);l&&(s.github_url=l)}catch{}}return s}d();import{readdir as fC}from"fs/promises";import{homedir as dC}from"os";import{join as yy}from"path";async function hC(t,e,n){let r=t.replace(/\./g,"/"),s=yy(dC(),".m2","repository",r,e);if(!await fe(s))return null;let i;try{i=await fC(s)}catch{return null}let o;return n&&i.includes(n)?o=n:(i.sort(),o=i[i.length-1]),o?yy(s,o,`${e}-${o}.pom`):null}async function _y(t,e,n,r={}){let s=n.indexOf(":");if(s<0)return{};let i=n.slice(0,s),o=n.slice(s+1);if(!i||!o)return{};let a=await hC(i,o,r.resolved_version);return a?Li(a,n):{}}d();var by=H(oe(),1);import{readFile as pC}from"fs/promises";import{join as wy}from"path";var mC=(0,by.createMcpLogger)({name:"@toolcairn/tools:resolver:npm"});function gC(t){let e=t.repository;if(e)return typeof e=="string"?e:e.url}async function yC(t,e,n){let r=t,s=e;for(let i=0;i<10;i++){let o=wy(r,"node_modules",n,"package.json");if(await P(o))return o;if(r===s)break;let a=wy(r,"..");if(a===r)break;r=a}return null}async function vy(t,e,n){let r=await yC(t,e,n);if(!r)return{};let s;try{s=JSON.parse(await pC(r,"utf-8"))}catch(c){return mC.debug({err:c instanceof Error?c.message:String(c),manifestPath:r},"Failed to parse installed package.json \u2014 skipping url resolution"),{}}let i={};s.name&&s.name!==n&&(i.canonical_package_name=s.name),s.version&&(i.resolved_version=s.version);let o=gC(s),a=ie(o);return a&&(i.github_url=a),i}d();var Ey=H(oe(),1),ky=H(Kr(),1);import{readFile as _C,readdir as wC}from"fs/promises";import{homedir as bC}from"os";import{join as Sy}from"path";var vC=(0,Ey.createMcpLogger)({name:"@toolcairn/tools:resolver:nuget"});async function SC(t,e){let n=Sy(bC(),".nuget","packages",t.toLowerCase());if(!await fe(n))return null;let r;try{r=await wC(n)}catch{return null}let s=e&&r.includes(e)?e:r.sort().at(-1);if(!s)return null;let i=Sy(n,s,`${t.toLowerCase()}.nuspec`);return await P(i)?i:null}async function xy(t,e,n,r={}){let s=await SC(n,r.resolved_version);if(!s)return{};try{let i=await _C(s,"utf-8"),c=new ky.XMLParser({ignoreAttributes:!1}).parse(i).package?.metadata;if(!c)return{};let l={};c.id&&c.id!==n&&(l.canonical_package_name=c.id),c.version&&(l.resolved_version=c.version);let u=c.repository?.["@_url"]??c.repository?.url,f=ie(u??c.projectUrl);return f&&(l.github_url=f),l}catch(i){return vC.debug({err:i instanceof Error?i.message:String(i),path:s},"Failed to parse .nuspec"),{}}}d();var Ty=H(oe(),1),Oy=H(Br(),1);import{readFile as EC}from"fs/promises";import{homedir as kC,platform as xC}from"os";import{join as Ri}from"path";var TC=(0,Ty.createMcpLogger)({name:"@toolcairn/tools:resolver:pub"});function OC(){if(xC()==="win32"){let t=process.env.LOCALAPPDATA;if(t)return Ri(t,"Pub","Cache","hosted","pub.dev")}return Ri(kC(),".pub-cache","hosted","pub.dev")}async function NC(t,e){let n=OC();if(e){let r=Ri(n,`${t}-${e}`,"pubspec.yaml");return await P(r)?r:null}try{let{readdir:r}=await import("fs/promises"),o=(await r(n)).filter(c=>c.startsWith(`${t}-`)).sort().at(-1);if(!o)return null;let a=Ri(n,o,"pubspec.yaml");return await P(a)?a:null}catch{return null}}async function Ny(t,e,n,r={}){let s=await NC(n,r.resolved_version);if(!s)return{};try{let i=await EC(s,"utf-8"),o=(0,Oy.parse)(i),a={};o.name&&o.name!==n&&(a.canonical_package_name=o.name),o.version&&(a.resolved_version=o.version);let c=ie(o.repository??o.homepage);return c&&(a.github_url=c),a}catch(i){return TC.debug({err:i instanceof Error?i.message:String(i),path:s},"Failed to parse pubspec.yaml"),{}}}d();var Cy=H(oe(),1);import{readFile as AC,readdir as Ay}from"fs/promises";import{join as Gr}from"path";var CC=(0,Cy.createMcpLogger)({name:"@toolcairn/tools:resolver:pypi"});async function IC(t){let e=[],n=[".venv","venv",".virtualenv"];for(let r of n){let s=Gr(t,r);if(!await fe(s))continue;let i=Gr(s,"Lib","site-packages");await fe(i)&&e.push(i);let o=Gr(s,"lib");if(await fe(o))try{for(let a of await Ay(o)){if(!a.startsWith("python"))continue;let c=Gr(o,a,"site-packages");await fe(c)&&e.push(c)}}catch{}}return e}function ji(t){return t.toLowerCase().replace(/[._]+/g,"-")}async function PC(t,e){let n=ji(e),r;try{r=await Ay(t)}catch{return null}for(let s of r){if(!s.endsWith(".dist-info"))continue;let i=s.replace(/-[^-]+\.dist-info$/,"");if(ji(i)===n){let o=Gr(t,s,"METADATA");if(await P(o))return o}}return null}function LC(t){let e=[],n,r,s=t.split(`
214
214
  `);for(let i of s){if(i.trim()==="")break;let o=i.indexOf(":");if(o<0)continue;let a=i.slice(0,o).trim(),c=i.slice(o+1).trim();if(a==="Name"&&!n)n=c;else if(a==="Version"&&!r)r=c;else if(a==="Home-page")e.push(c);else if(a==="Project-URL"){let l=c.indexOf(",");l>=0?e.push(c.slice(l+1).trim()):e.push(c)}}return{name:n,version:r,urls:e}}async function Iy(t,e,n){let r=await IC(t);for(let s of r){let i=await PC(s,n);if(i)try{let o=await AC(i,"utf-8"),{name:a,version:c,urls:l}=LC(o),u={};a&&ji(a)!==ji(n)&&(u.canonical_package_name=a),c&&(u.resolved_version=c);for(let f of l){let h=ie(f);if(h){u.github_url=h;break}}return u}catch(o){CC.debug({err:o instanceof Error?o.message:String(o),path:i},"Failed to parse METADATA")}}return{}}d();var Ly=H(oe(),1);import{readFile as RC,readdir as Py}from"fs/promises";import{homedir as jC}from"os";import{join as $i}from"path";var $C=(0,Ly.createMcpLogger)({name:"@toolcairn/tools:resolver:ruby"});async function MC(t,e,n){let r=[],s=$i(t,"vendor","bundle","ruby");if(await fe(s))try{for(let o of await Py(s)){let a=$i(s,o,"specifications");await fe(a)&&r.push(a)}}catch{}let i=$i(jC(),".gem","specifications");await fe(i)&&r.push(i);for(let o of r){let a;try{a=await Py(o)}catch{continue}let l=a.filter(u=>u.endsWith(".gemspec")&&u.startsWith(`${e}-`)).filter(u=>n?u===`${e}-${n}.gemspec`:!0).sort().at(-1);if(l){let u=$i(o,l);if(await P(u))return u}}return null}function qC(t){let e={},n=r=>{let s=t.match(r);return s?s[1]:void 0};return e.name=n(/(?:s|spec)\.name\s*=\s*(['"])([^'"]+)\1/)?t.match(/(?:s|spec)\.name\s*=\s*['"]([^'"]+)['"]/)?.[1]:void 0,e.version=t.match(/(?:s|spec)\.version\s*=\s*['"]([^'"]+)['"]/)?.[1],e.homepage=t.match(/(?:s|spec)\.homepage\s*=\s*['"]([^'"]+)['"]/)?.[1],e.source_code_uri=t.match(/["']source_code_uri["']\s*=>\s*["']([^'"]+)["']/)?.[1],e}async function Ry(t,e,n,r={}){let s=await MC(t,n,r.resolved_version);if(!s)return{};try{let i=await RC(s,"utf-8"),o=qC(i),a={};o.name&&o.name!==n&&(a.canonical_package_name=o.name),o.version&&(a.resolved_version=o.version);let c=ie(o.source_code_uri??o.homepage);return c&&(a.github_url=c),a}catch(i){return $C.debug({err:i instanceof Error?i.message:String(i),path:s},"Failed to read/parse gemspec"),{}}}d();var jy=H(oe(),1);import{readFile as FC}from"fs/promises";import{join as BC}from"path";var DC=(0,jy.createMcpLogger)({name:"@toolcairn/tools:resolver:swift-pm"});async function $y(t,e,n){let r=BC(t,"Package.resolved");if(!await P(r))return{};try{let s=await FC(r,"utf-8"),i=JSON.parse(s),o={};for(let a of i.pins??[])if(a.identity===n){a.state?.version&&(o.resolved_version=a.state.version);let c=ie(a.location);return c&&(o.github_url=c),o}for(let a of i.object?.pins??[])if(a.package===n){a.state?.version&&(o.resolved_version=a.state.version);let c=ie(a.repositoryURL);return c&&(o.github_url=c),o}return{}}catch(s){return DC.debug({err:s instanceof Error?s.message:String(s),path:r},"Failed to parse Package.resolved during resolve"),{}}}var My={npm:vy,pypi:Iy,cargo:oy,go:(t,e,n)=>ly(t,e,n),rubygems:Ry,maven:_y,gradle:hy,composer:cy,hex:gy,pub:Ny,nuget:xy,"swift-pm":$y};d();import{readdir as qy}from"fs/promises";import{join as Nl,relative as UC,sep as VC}from"path";async function Fy(t,e){let n=new Set,r=new Set;for(let s of e){let i=s.trim();if(!i)continue;let o=i.startsWith("!"),c=(o?i.slice(1):i).replace(/\\/g,"/"),l=await KC(t,c),u=o?n:r;for(let f of l)u.add(f)}return[...r].filter(s=>!n.has(s)).sort()}async function KC(t,e){let n=e.split("/").filter(Boolean),r=[];return await Wr(t,t,n,0,r),r}async function Wr(t,e,n,r,s){if(r>=n.length){await fe(e)&&s.push(e);return}let i=n[r];if(i){if(i==="**"){await Wr(t,e,n,r+1,s);try{let o=await qy(e,{withFileTypes:!0});for(let a of o)!a.isDirectory()||tn.has(a.name)||await Wr(t,Nl(e,a.name),n,r,s)}catch{}return}if(i.includes("*")){let o=GC(i);try{let a=await qy(e,{withFileTypes:!0});for(let c of a)!c.isDirectory()||tn.has(c.name)||o.test(c.name)&&await Wr(t,Nl(e,c.name),n,r+1,s)}catch{}return}await Wr(t,Nl(e,i),n,r+1,s)}}function GC(t){let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${e}$`)}function Mi(t,e){return UC(t,e).split(VC).join("/")}d();import{readFile as Kn}from"fs/promises";import{join as Gn}from"path";var By=H(Br(),1);async function qi(t,e=5){let n=[],r=new Set([t]),s=new Set,i=[{dir:t,depth:0}];for(;i.length>0;){let{dir:o,depth:a}=i.shift();if(s.has(o)||a>e)continue;s.add(o);let c=await WC(o,n);if(c.length===0)continue;let l=await Fy(o,c);for(let u of l)r.has(u)||(r.add(u),i.push({dir:u,depth:a+1}))}return{paths:[...r].sort(),warnings:n}}async function WC(t,e){let n=[],r=Gn(t,"pnpm-workspace.yaml");if(await P(r))try{let l=(0,By.parse)(await Kn(r,"utf-8"));Array.isArray(l.packages)&&n.push(...l.packages)}catch(l){e.push({scope:"workspace:pnpm",path:r,message:`Failed to parse pnpm-workspace.yaml: ${l instanceof Error?l.message:String(l)}`})}let s=Gn(t,"package.json");if(await P(s))try{let l=JSON.parse(await Kn(s,"utf-8"));Array.isArray(l.workspaces)?n.push(...l.workspaces):l.workspaces&&Array.isArray(l.workspaces.packages)&&n.push(...l.workspaces.packages)}catch(l){e.push({scope:"workspace:package-json",path:s,message:`Failed to parse package.json#workspaces: ${l instanceof Error?l.message:String(l)}`})}let i=Gn(t,"Cargo.toml");if(await P(i))try{let l=Ue(await Kn(i,"utf-8"));Array.isArray(l.workspace?.members)&&n.push(...l.workspace.members)}catch(l){e.push({scope:"workspace:cargo",path:i,message:`Failed to parse Cargo workspace: ${l instanceof Error?l.message:String(l)}`})}let o=Gn(t,"go.work");if(await P(o))try{let l=await Kn(o,"utf-8"),u=l.match(/use\s*\(([^)]*)\)/s);if(u?.[1])for(let f of u[1].split(`
215
215
  `)){let h=f.trim().replace(/^['"]|['"]$/g,"");h&&!h.startsWith("//")&&n.push(h)}else for(let f of l.split(`
216
- `)){let h=f.match(/^\s*use\s+(.+)$/);h?.[1]&&n.push(h[1].trim().replace(/^['"]|['"]$/g,""))}}catch(l){e.push({scope:"workspace:go",path:o,message:`Failed to parse go.work: ${l instanceof Error?l.message:String(l)}`})}let a=Gn(t,"lerna.json");if(await P(a))try{let l=JSON.parse(await Kn(a,"utf-8"));Array.isArray(l.packages)&&n.push(...l.packages)}catch(l){e.push({scope:"workspace:lerna",path:a,message:`Failed to parse lerna.json: ${l instanceof Error?l.message:String(l)}`})}let c=Gn(t,"nx.json");if(await P(c))try{let u=JSON.parse(await Kn(c,"utf-8")).workspaceLayout?.projectsDir??"packages";n.push(`${u}/*`)}catch(l){e.push({scope:"workspace:nx",path:c,message:`Failed to parse nx.json: ${l instanceof Error?l.message:String(l)}`})}return n}var Al=(0,Dy.createMcpLogger)({name:"@toolcairn/tools:scan-project"});async function Il(t,e={}){let n=Date.now(),{batchResolve:r,maxDepth:s=5}=e,i=Cl(t),o=[];Al.info({projectRoot:i},"Starting project scan");let{paths:a,warnings:c}=await qi(i,s);o.push(...c);let l=[],u=new Set,f=[],h=[],g=[];for(let x of a){let I=Mi(i,x),j=await Ud(x);for(let U of j){u.add(U);let J=ry[U];g.push(J({workspace_dir:x,workspace_rel:I,project_root:i}).then(D=>{l.push(...D.tools),o.push(...D.warnings),D.tools.length>0&&I!==""&&(h.find(re=>re.path===I&&re.ecosystem===U)||h.push({path:I,manifest:zC(U),ecosystem:U}))}).catch(D=>{f.push(`${U}@${I||"."}`),o.push({scope:`parser:${U}`,path:I||".",message:`Parser crashed: ${D instanceof Error?D.message:String(D)}`})}))}}await Promise.all(g);let p=new Map;for(let x of l){let I=`${x.ecosystem}:${x.name}`,j={workspace_path:x.workspace_path,manifest_file:x.manifest_file,section:x.section,ecosystem:x.ecosystem,version_constraint:x.version_constraint,resolved_version:x.resolved_version},U=p.get(I);U?U.locations.some(D=>D.workspace_path===j.workspace_path&&D.manifest_file===j.manifest_file&&D.section===j.section)||U.locations.push(j):p.set(I,{name:x.name,ecosystem:x.ecosystem,locations:[j]})}await Promise.all([...p.values()].map(async x=>{let I=My[x.ecosystem];if(I)for(let j of x.locations){let U=Cl(i,j.workspace_path),J={resolved_version:j.resolved_version};try{let D=await I(U,i,x.name,J);if(D.canonical_package_name&&(x.canonical_package_name=D.canonical_package_name),D.github_url&&(x.local_github_url=D.github_url),D.canonical_package_name||D.github_url)break}catch(D){Al.debug({ecosystem:x.ecosystem,name:x.name,workspace:j.workspace_path,err:D instanceof Error?D.message:String(D)},"Resolver threw \u2014 skipping this location")}}}));let m=a.map(x=>Mi(i,x)),y=await Kd(i,m),b=[...p.values()].map(({name:x,ecosystem:I,canonical_package_name:j,local_github_url:U})=>({name:x,ecosystem:I,canonical_package_name:j,github_url:U})),v=new Map,k=new Map,N=new Map;if(r&&b.length>0)try{let x=await r(b);for(let I of x.results){let j=`${I.input.ecosystem}:${I.input.name}`;v.set(j,I)}for(let[I,j]of x.methods)k.set(I,j);for(let[I,j]of x.githubUrls)N.set(I,j);o.push(...x.warnings)}catch(x){o.push({scope:"batch-resolve",message:`Failed to resolve tools against graph: ${x instanceof Error?x.message:String(x)}. Falling back to local classification.`})}else r||o.push({scope:"batch-resolve",message:"No batchResolve client provided \u2014 running in offline-only mode; all tools classified as non_oss."});let L=Vd(l,v),$=new Date().toISOString(),F=[],E=0;for(let{name:x,ecosystem:I,locations:j,local_github_url:U}of p.values()){let J=`${I}:${x}`,D=v.get(J),Q=k.get(J)??"none",re=D?.matched===!0;re&&E++;let ne=re?"toolcairn":"non_oss",Xr=D?.tool?.canonical_name,ow=D?.tool?.categories,aw=N.get(J)??U,cw=j.find(fo=>fo.resolved_version)?.resolved_version??j[0]?.version_constraint,qe=D?.tool,uo=qe?.docs?{readme_url:qe.docs.readme_url??void 0,docs_url:qe.docs.docs_url??void 0,api_url:qe.docs.api_url??void 0,changelog_url:qe.docs.changelog_url??void 0}:void 0,lw=uo&&Object.values(uo).some(fo=>fo!==void 0);F.push({name:x,source:ne,github_url:aw,version:cw,chosen_at:$,chosen_reason:"Auto-detected from manifest during toolcairn_init scan",alternatives_considered:[],canonical_name:Xr,categories:ow,match_method:Q,locations:j,description:qe?.description??void 0,license:qe?.license??void 0,homepage_url:qe?.homepage_url??void 0,docs:lw?uo:void 0,package_managers:qe?.package_managers&&qe.package_managers.length>0?qe.package_managers:void 0})}F.sort((x,I)=>{let j=U=>U.source==="toolcairn"?0:1;return j(x)!==j(I)?j(x)-j(I):x.name.localeCompare(I.name)}),h.sort((x,I)=>x.path.localeCompare(I.path));let O=await HC(i),M={ecosystems_scanned:[...u].sort(),parsers_failed:f.sort(),tools_resolved:E,tools_unresolved:F.length-E,duration_ms:Date.now()-n,completed_at:$};return Al.info({projectRoot:i,workspaces:a.length,ecosystems:M.ecosystems_scanned,tools:F.length,resolved:E,languages:y.map(x=>x.name),frameworks:L.map(x=>x.name),duration_ms:M.duration_ms},"Project scan complete"),{name:O,languages:y,frameworks:L,subprojects:h,tools:F,warnings:o,scan_metadata:M}}function zC(t){switch(t){case"npm":return"package.json";case"pypi":return"pyproject.toml";case"cargo":return"Cargo.toml";case"go":return"go.mod";case"rubygems":return"Gemfile";case"maven":return"pom.xml";case"gradle":return"build.gradle";case"composer":return"composer.json";case"hex":return"mix.exs";case"pub":return"pubspec.yaml";case"nuget":return"*.csproj";case"swift-pm":return"Package.swift"}}async function HC(t){let e=Cl(t,"package.json");if(await P(e))try{let n=JSON.parse(await JC(e,"utf-8"));if(n.name)return n.name}catch{}return YC(t)}d();d();var Ky=H(oe(),1);import{readdir as Vy}from"fs/promises";import{resolve as Pl}from"path";var Uy=(0,Ky.createMcpLogger)({name:"@toolcairn/tools:discover-roots"}),ZC=["package.json","Cargo.toml","pyproject.toml","requirements.txt","setup.py","setup.cfg","go.mod","Gemfile","pom.xml","build.gradle","build.gradle.kts","composer.json","mix.exs","pubspec.yaml","Package.swift"],XC=[".csproj",".fsproj",".sln"];async function QC(t,e={}){let{maxDepth:n=5}=e,r=Pl(t),s=await eI(r,n);if(s.length===0)return Uy.info({cwd:r},"No project roots discovered \u2014 falling back to cwd itself"),{roots:[r],usedFallback:!0};s.sort((a,c)=>a.split(/[\\/]/).length-c.split(/[\\/]/).length||a.localeCompare(c));let i=new Set(s);for(let a of s){if(!i.has(a))continue;let c=await qi(a,n).catch(()=>({paths:[a]}));if(!(c.paths.length<=1))for(let l of c.paths)l!==a&&i.has(l)&&i.delete(l)}let o=[...i].sort();return Uy.info({cwd:r,candidates:s.length,roots:o.length},"Discovered project roots"),{roots:o,usedFallback:!1}}async function eI(t,e){let n=[],r=[{dir:t,depth:0}];for(;r.length>0;){let s=r.shift();if(!s)break;let{dir:i,depth:o}=s;if(o>e)continue;await tI(i)&&n.push(i);let a;try{a=await Vy(i,{withFileTypes:!0})}catch{continue}for(let c of a)c.isDirectory()&&(tn.has(c.name)||c.name.startsWith(".")||r.push({dir:Pl(i,c.name),depth:o+1}))}return[...new Set(n)]}async function tI(t){if(!await fe(t))return!1;for(let n of ZC)if(await P(Pl(t,n)))return!0;let e;try{e=await Vy(t)}catch{return!1}for(let n of e)for(let r of XC)if(n.endsWith(r))return!0;return!1}d();d();var UD={query:A.string().min(1).max(500),context:A.object({filters:A.record(A.string(),A.unknown())}).optional(),query_id:A.string().uuid().optional(),user_id:A.string().optional()},VD={query_id:A.string().uuid(),answers:A.array(A.object({dimension:A.string(),value:A.string()}))},KD={query_id:A.string().uuid(),chosen_tool:A.string(),reason:A.string().optional(),outcome:A.enum(["success","failure","replaced","pending"]),feedback:A.string().optional(),replaced_by:A.string().optional()},GD={use_case:A.string().min(1),sub_needs:A.array(A.union([A.string().min(1),A.object({sub_need_type:A.string().min(1).max(50).describe('Stack layer type, e.g. "database", "auth", "web-framework"'),keyword_sentence:A.string().min(1).max(500).describe("Comma-separated keywords matching tool vocabulary, max 20 keywords")})])).min(1).max(8).optional().describe("Structured sub-needs from refine_requirement. Each is {sub_need_type, keyword_sentence} for keyword-matched search, or a plain string (legacy). The structured format dramatically improves accuracy."),constraints:A.object({deployment_model:A.enum(["self-hosted","cloud","embedded","serverless"]).optional(),language:A.string().optional(),license:A.string().optional()}).optional(),limit:A.number().int().positive().max(10).default(5)},WD={tool_name:A.string(),issue_title:A.string(),retry_count:A.number().int().min(0).default(0),docs_consulted:A.boolean().default(!1),issue_url:A.string().url().optional()},JD={tool_a:A.string(),tool_b:A.string(),tool_a_version:A.string().optional().describe('Specific version of tool_a to evaluate (e.g., "14.0.0"). Default: latest.'),tool_b_version:A.string().optional().describe('Specific version of tool_b to evaluate (e.g., "18.2.0"). Default: latest.')},YD={suggestion_type:A.enum(["new_tool","new_edge","update_health","new_use_case"]),data:A.object({tool_name:A.string().optional(),github_url:A.string().url().optional(),description:A.string().optional(),tools:A.array(A.object({tool_name:A.string().min(1),github_url:A.string().url().optional(),description:A.string().optional(),ecosystem:A.string().min(1).optional()})).min(1).max(200).optional().describe('Batch of tools to stage for admin review. Use with suggestion_type="new_tool". Each entry may include `ecosystem` (npm/pypi/cargo/\u2026) so the engine can cross-check the authoritative github_url from the package registry. Overrides single-tool fields when present.'),ecosystem:A.string().min(1).optional(),relationship:A.object({source_tool:A.string(),target_tool:A.string(),edge_type:A.enum(["SOLVES","REQUIRES","INTEGRATES_WITH","REPLACES","CONFLICTS_WITH","POPULAR_WITH","BREAKS_FROM","COMPATIBLE_WITH"]),evidence:A.string().optional()}).optional(),use_case:A.object({name:A.string(),description:A.string(),tools:A.array(A.string()).optional()}).optional()}),query_id:A.string().uuid().optional(),confidence:A.number().min(0).max(1).default(.5)},zD={tool_a:A.string().min(1),tool_b:A.string().min(1),use_case:A.string().optional(),project_config:A.string().max(1e5).optional()},HD={agent:A.enum(["claude","cursor","windsurf","copilot","copilot-cli","opencode","generic"]),project_root:A.string().min(1),server_path:A.string().optional()},ZD={project_root:A.string().min(1),include_locations:A.boolean().optional()},XD={project_root:A.string().min(1),action:A.enum(["add_tool","remove_tool","update_tool","add_evaluation","mark_suggestions_sent"]),tool_name:A.string().min(1).optional(),data:A.record(A.string(),A.unknown()).optional()},QD={prompt:A.string().min(1).max(2e3),project_tools:A.array(A.string()).optional()},eU={query:A.string().min(1).max(500),agent_suggestions:A.array(A.string().min(1)).min(1).max(10)},tU={prompt:A.string().min(1).max(2e3),classification:A.enum(["tool_discovery","stack_building","tool_comparison","tool_configuration"]),project_context:A.object({existing_tools:A.array(A.string()).optional(),language:A.string().optional(),framework:A.string().optional()}).optional()},nU={tool_name:A.enum(["classify_prompt","search_tools","search_tools_respond","get_stack","check_compatibility","compare_tools","refine_requirement","check_issue","verify_suggestion","report_outcome","suggest_graph_update","toolcairn_init","read_project_config","update_project_config","toolcairn_auth"]),severity:A.enum(["broken","wrong_result","low_quality","missing_capability","confusing"]),message:A.string().min(20).max(2e3),query_id:A.string().uuid().optional(),expected:A.string().max(1e3).optional(),actual:A.string().max(1e3).optional()};d();function tt(t){return{content:[{type:"text",text:JSON.stringify({ok:!0,data:t})}]}}function je(t,e){return{content:[{type:"text",text:JSON.stringify({ok:!1,error:t,message:e})}],isError:!0}}d();var Wy=H(oe(),1);var Gy=(0,Wy.createMcpLogger)({name:"@toolcairn/tools:classify-prompt"}),nI=["tool_discovery","stack_building","tool_comparison"];async function rI(t){try{Gy.info({promptLen:t.prompt.length},"classify_prompt called");let e=t.project_tools&&t.project_tools.length>0?`
216
+ `)){let h=f.match(/^\s*use\s+(.+)$/);h?.[1]&&n.push(h[1].trim().replace(/^['"]|['"]$/g,""))}}catch(l){e.push({scope:"workspace:go",path:o,message:`Failed to parse go.work: ${l instanceof Error?l.message:String(l)}`})}let a=Gn(t,"lerna.json");if(await P(a))try{let l=JSON.parse(await Kn(a,"utf-8"));Array.isArray(l.packages)&&n.push(...l.packages)}catch(l){e.push({scope:"workspace:lerna",path:a,message:`Failed to parse lerna.json: ${l instanceof Error?l.message:String(l)}`})}let c=Gn(t,"nx.json");if(await P(c))try{let u=JSON.parse(await Kn(c,"utf-8")).workspaceLayout?.projectsDir??"packages";n.push(`${u}/*`)}catch(l){e.push({scope:"workspace:nx",path:c,message:`Failed to parse nx.json: ${l instanceof Error?l.message:String(l)}`})}return n}var Al=(0,Dy.createMcpLogger)({name:"@toolcairn/tools:scan-project"});async function Il(t,e={}){let n=Date.now(),{batchResolve:r,maxDepth:s=5}=e,i=Cl(t),o=[];Al.info({projectRoot:i},"Starting project scan");let{paths:a,warnings:c}=await qi(i,s);o.push(...c);let l=[],u=new Set,f=[],h=[],g=[];for(let x of a){let I=Mi(i,x),j=await Ud(x);for(let U of j){u.add(U);let J=ry[U];g.push(J({workspace_dir:x,workspace_rel:I,project_root:i}).then(D=>{l.push(...D.tools),o.push(...D.warnings),D.tools.length>0&&I!==""&&(h.find(re=>re.path===I&&re.ecosystem===U)||h.push({path:I,manifest:zC(U),ecosystem:U}))}).catch(D=>{f.push(`${U}@${I||"."}`),o.push({scope:`parser:${U}`,path:I||".",message:`Parser crashed: ${D instanceof Error?D.message:String(D)}`})}))}}await Promise.all(g);let p=new Map;for(let x of l){let I=`${x.ecosystem}:${x.name}`,j={workspace_path:x.workspace_path,manifest_file:x.manifest_file,section:x.section,ecosystem:x.ecosystem,version_constraint:x.version_constraint,resolved_version:x.resolved_version},U=p.get(I);U?U.locations.some(D=>D.workspace_path===j.workspace_path&&D.manifest_file===j.manifest_file&&D.section===j.section)||U.locations.push(j):p.set(I,{name:x.name,ecosystem:x.ecosystem,locations:[j]})}await Promise.all([...p.values()].map(async x=>{let I=My[x.ecosystem];if(I)for(let j of x.locations){let U=Cl(i,j.workspace_path),J={resolved_version:j.resolved_version};try{let D=await I(U,i,x.name,J);if(D.canonical_package_name&&(x.canonical_package_name=D.canonical_package_name),D.github_url&&(x.local_github_url=D.github_url),D.canonical_package_name||D.github_url)break}catch(D){Al.debug({ecosystem:x.ecosystem,name:x.name,workspace:j.workspace_path,err:D instanceof Error?D.message:String(D)},"Resolver threw \u2014 skipping this location")}}}));let m=a.map(x=>Mi(i,x)),y=await Kd(i,m),b=[...p.values()].map(({name:x,ecosystem:I,canonical_package_name:j,local_github_url:U})=>({name:x,ecosystem:I,canonical_package_name:j,github_url:U})),v=new Map,k=new Map,N=new Map;if(r&&b.length>0)try{let x=await r(b);for(let I of x.results){let j=`${I.input.ecosystem}:${I.input.name}`;v.set(j,I)}for(let[I,j]of x.methods)k.set(I,j);for(let[I,j]of x.githubUrls)N.set(I,j);o.push(...x.warnings)}catch(x){o.push({scope:"batch-resolve",message:`Failed to resolve tools against graph: ${x instanceof Error?x.message:String(x)}. Falling back to local classification.`})}else r||o.push({scope:"batch-resolve",message:"No batchResolve client provided \u2014 running in offline-only mode; all tools classified as non_oss."});let L=Vd(l,v),$=new Date().toISOString(),F=[],E=0;for(let{name:x,ecosystem:I,locations:j,local_github_url:U}of p.values()){let J=`${I}:${x}`,D=v.get(J),Q=k.get(J)??"none",re=D?.matched===!0;re&&E++;let ne=re?"toolcairn":"non_oss",Xr=D?.tool?.canonical_name,ow=D?.tool?.categories,aw=N.get(J)??U,cw=j.find(fo=>fo.resolved_version)?.resolved_version??j[0]?.version_constraint,qe=D?.tool,uo=qe?.docs?{readme_url:qe.docs.readme_url??void 0,docs_url:qe.docs.docs_url??void 0,api_url:qe.docs.api_url??void 0,changelog_url:qe.docs.changelog_url??void 0}:void 0,lw=uo&&Object.values(uo).some(fo=>fo!==void 0);F.push({name:x,source:ne,github_url:aw,version:cw,chosen_at:$,chosen_reason:"Auto-detected from manifest during toolcairn_init scan",alternatives_considered:[],canonical_name:Xr,categories:ow,match_method:Q,locations:j,description:qe?.description??void 0,license:qe?.license??void 0,homepage_url:qe?.homepage_url??void 0,docs:lw?uo:void 0,package_managers:qe?.package_managers&&qe.package_managers.length>0?qe.package_managers:void 0})}F.sort((x,I)=>{let j=U=>U.source==="toolcairn"?0:1;return j(x)!==j(I)?j(x)-j(I):x.name.localeCompare(I.name)}),h.sort((x,I)=>x.path.localeCompare(I.path));let O=await HC(i),M={ecosystems_scanned:[...u].sort(),parsers_failed:f.sort(),tools_resolved:E,tools_unresolved:F.length-E,duration_ms:Date.now()-n,completed_at:$};return Al.info({projectRoot:i,workspaces:a.length,ecosystems:M.ecosystems_scanned,tools:F.length,resolved:E,languages:y.map(x=>x.name),frameworks:L.map(x=>x.name),duration_ms:M.duration_ms},"Project scan complete"),{name:O,languages:y,frameworks:L,subprojects:h,tools:F,warnings:o,scan_metadata:M}}function zC(t){switch(t){case"npm":return"package.json";case"pypi":return"pyproject.toml";case"cargo":return"Cargo.toml";case"go":return"go.mod";case"rubygems":return"Gemfile";case"maven":return"pom.xml";case"gradle":return"build.gradle";case"composer":return"composer.json";case"hex":return"mix.exs";case"pub":return"pubspec.yaml";case"nuget":return"*.csproj";case"swift-pm":return"Package.swift"}}async function HC(t){let e=Cl(t,"package.json");if(await P(e))try{let n=JSON.parse(await JC(e,"utf-8"));if(n.name)return n.name}catch{}return YC(t)}d();d();var Ky=H(oe(),1);import{readdir as Vy}from"fs/promises";import{resolve as Pl}from"path";var Uy=(0,Ky.createMcpLogger)({name:"@toolcairn/tools:discover-roots"}),ZC=["package.json","Cargo.toml","pyproject.toml","requirements.txt","setup.py","setup.cfg","go.mod","Gemfile","pom.xml","build.gradle","build.gradle.kts","composer.json","mix.exs","pubspec.yaml","Package.swift"],XC=[".csproj",".fsproj",".sln"];async function QC(t,e={}){let{maxDepth:n=5}=e,r=Pl(t),s=await eI(r,n);if(s.length===0)return Uy.info({cwd:r},"No project roots discovered \u2014 falling back to cwd itself"),{roots:[r],usedFallback:!0};s.sort((a,c)=>a.split(/[\\/]/).length-c.split(/[\\/]/).length||a.localeCompare(c));let i=new Set(s);for(let a of s){if(!i.has(a))continue;let c=await qi(a,n).catch(()=>({paths:[a]}));if(!(c.paths.length<=1))for(let l of c.paths)l!==a&&i.has(l)&&i.delete(l)}let o=[...i].sort();return Uy.info({cwd:r,candidates:s.length,roots:o.length},"Discovered project roots"),{roots:o,usedFallback:!1}}async function eI(t,e){let n=[],r=[{dir:t,depth:0}];for(;r.length>0;){let s=r.shift();if(!s)break;let{dir:i,depth:o}=s;if(o>e)continue;await tI(i)&&n.push(i);let a;try{a=await Vy(i,{withFileTypes:!0})}catch{continue}for(let c of a)c.isDirectory()&&(tn.has(c.name)||c.name.startsWith(".")||r.push({dir:Pl(i,c.name),depth:o+1}))}return[...new Set(n)]}async function tI(t){if(!await fe(t))return!1;for(let n of ZC)if(await P(Pl(t,n)))return!0;let e;try{e=await Vy(t)}catch{return!1}for(let n of e)for(let r of XC)if(n.endsWith(r))return!0;return!1}d();d();var UD={query:A.string().min(1).max(500),context:A.object({filters:A.record(A.string(),A.unknown())}).optional(),query_id:A.string().uuid().optional(),user_id:A.string().optional()},VD={query_id:A.string().uuid(),answers:A.array(A.object({dimension:A.string(),value:A.string()}))},KD={query_id:A.string().uuid(),chosen_tool:A.string(),reason:A.string().optional(),outcome:A.enum(["success","failure","replaced","pending"]),feedback:A.string().optional(),replaced_by:A.string().optional()},GD={use_case:A.string().min(1),sub_needs:A.array(A.union([A.string().min(1),A.object({sub_need_type:A.string().min(1).max(50).describe('Stack layer type, e.g. "database", "auth", "web-framework"'),keyword_sentence:A.string().min(1).max(500).describe("Comma-separated keywords matching tool vocabulary, max 20 keywords")})])).min(1).max(8).optional().describe("Structured sub-needs from refine_requirement. Each is {sub_need_type, keyword_sentence} for keyword-matched search, or a plain string (legacy). The structured format dramatically improves accuracy."),constraints:A.object({deployment_model:A.enum(["self-hosted","cloud","embedded","serverless"]).optional(),language:A.string().optional(),license:A.string().optional()}).optional(),existing_tools:A.array(A.string().min(1)).max(50).optional(),limit:A.number().int().positive().max(10).default(5)},WD={tool_name:A.string(),issue_title:A.string(),retry_count:A.number().int().min(0).default(0),docs_consulted:A.boolean().default(!1),issue_url:A.string().url().optional()},JD={tool_a:A.string(),tool_b:A.string(),tool_a_version:A.string().optional().describe('Specific version of tool_a to evaluate (e.g., "14.0.0"). Default: latest.'),tool_b_version:A.string().optional().describe('Specific version of tool_b to evaluate (e.g., "18.2.0"). Default: latest.')},YD={suggestion_type:A.enum(["new_tool","new_edge","update_health","new_use_case"]),data:A.object({tool_name:A.string().optional(),github_url:A.string().url().optional(),description:A.string().optional(),tools:A.array(A.object({tool_name:A.string().min(1),github_url:A.string().url().optional(),description:A.string().optional(),ecosystem:A.string().min(1).optional()})).min(1).max(200).optional().describe('Batch of tools to stage for admin review. Use with suggestion_type="new_tool". Each entry may include `ecosystem` (npm/pypi/cargo/\u2026) so the engine can cross-check the authoritative github_url from the package registry. Overrides single-tool fields when present.'),ecosystem:A.string().min(1).optional(),relationship:A.object({source_tool:A.string(),target_tool:A.string(),edge_type:A.enum(["SOLVES","REQUIRES","INTEGRATES_WITH","REPLACES","CONFLICTS_WITH","POPULAR_WITH","BREAKS_FROM","COMPATIBLE_WITH"]),evidence:A.string().optional()}).optional(),use_case:A.object({name:A.string(),description:A.string(),tools:A.array(A.string()).optional()}).optional()}),query_id:A.string().uuid().optional(),confidence:A.number().min(0).max(1).default(.5)},zD={tool_a:A.string().min(1),tool_b:A.string().min(1),use_case:A.string().optional(),project_config:A.string().max(1e5).optional()},HD={agent:A.enum(["claude","cursor","windsurf","copilot","copilot-cli","opencode","generic"]),project_root:A.string().min(1),server_path:A.string().optional()},ZD={project_root:A.string().min(1),include_locations:A.boolean().optional()},XD={project_root:A.string().min(1),action:A.enum(["add_tool","remove_tool","update_tool","add_evaluation","mark_suggestions_sent"]),tool_name:A.string().min(1).optional(),data:A.record(A.string(),A.unknown()).optional()},QD={prompt:A.string().min(1).max(2e3),project_tools:A.array(A.string()).optional()},eU={query:A.string().min(1).max(500),agent_suggestions:A.array(A.string().min(1)).min(1).max(10)},tU={prompt:A.string().min(1).max(2e3),classification:A.enum(["tool_discovery","stack_building","tool_comparison","tool_configuration"]),project_context:A.object({existing_tools:A.array(A.string()).optional(),language:A.string().optional(),framework:A.string().optional()}).optional()},nU={tool_name:A.enum(["classify_prompt","search_tools","search_tools_respond","get_stack","check_compatibility","compare_tools","refine_requirement","check_issue","verify_suggestion","report_outcome","suggest_graph_update","toolcairn_init","read_project_config","update_project_config","toolcairn_auth"]),severity:A.enum(["broken","wrong_result","low_quality","missing_capability","confusing"]),message:A.string().min(20).max(2e3),query_id:A.string().uuid().optional(),expected:A.string().max(1e3).optional(),actual:A.string().max(1e3).optional()};d();function tt(t){return{content:[{type:"text",text:JSON.stringify({ok:!0,data:t})}]}}function je(t,e){return{content:[{type:"text",text:JSON.stringify({ok:!1,error:t,message:e})}],isError:!0}}d();var Wy=H(oe(),1);var Gy=(0,Wy.createMcpLogger)({name:"@toolcairn/tools:classify-prompt"}),nI=["tool_discovery","stack_building","tool_comparison"];async function rI(t){try{Gy.info({promptLen:t.prompt.length},"classify_prompt called");let e=t.project_tools&&t.project_tools.length>0?`
217
217
 
218
218
  The project already uses: ${t.project_tools.join(", ")}. Consider whether the prompt relates to tools already confirmed in the project.`:"",n=`Classify the following developer prompt into exactly ONE of these categories:
219
219
 
package/dist/cli/scan.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __nodeCreateRequire } from 'module'; const require = __nodeCreateRequire(import.meta.url);
2
- import{K as g,d as u,j as h,l as m,m as d}from"../chunk-U7RBABZP.js";u();var _=process.env.TOOLPILOT_API_URL??"https://api.neurynae.com";function b(){console.error(`
2
+ import{K as g,d as u,j as h,l as m,m as d}from"../chunk-IUBGWDQC.js";u();var _=process.env.TOOLPILOT_API_URL??"https://api.neurynae.com";function b(){console.error(`
3
3
  \u274C Authentication required for \`scan\`.
4
4
 
5
5
  ToolCairn tracks scan calls per-user for graph learning, so this command
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __nodeCreateRequire } from 'module'; const require = __nodeCreateRequire(import.meta.url);
2
- import{A as np,B as op,C as sp,D as ip,E as ap,F as cp,G as up,H as lp,I as dp,J as pp,L as fp,M as mp,N as hp,O as gp,P as _p,Q as yp,a as P,b as Ld,c as Me,d,e as Ud,f as U,g as Vd,h as Ur,i as or,j as Uo,k as Fd,l as Cn,m as Tt,n as Hd,o as Bd,p as Vo,q as Jd,r as Kd,s as Gd,t as Wd,u as Yd,v as Xd,w as Qd,x as ep,y as tp,z as rp}from"./chunk-U7RBABZP.js";var io=P(te=>{"use strict";d();Object.defineProperty(te,"__esModule",{value:!0});te.regexpCode=te.getEsmExportName=te.getProperty=te.safeStringify=te.stringify=te.strConcat=te.addCodeArg=te.str=te._=te.nil=te._Code=te.Name=te.IDENTIFIER=te._CodeOrName=void 0;var oo=class{};te._CodeOrName=oo;te.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var pr=class extends oo{constructor(e){if(super(),!te.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};te.Name=pr;var et=class extends oo{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof pr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};te._Code=et;te.nil=new et("");function rh(t,...e){let r=[t[0]],n=0;for(;n<e.length;)bu(r,e[n]),r.push(t[++n]);return new et(r)}te._=rh;var vu=new et("+");function nh(t,...e){let r=[so(t[0])],n=0;for(;n<e.length;)r.push(vu),bu(r,e[n]),r.push(vu,so(t[++n]));return D0(r),new et(r)}te.str=nh;function bu(t,e){e instanceof et?t.push(...e._items):e instanceof pr?t.push(e):t.push(U0(e))}te.addCodeArg=bu;function D0(t){let e=1;for(;e<t.length-1;){if(t[e]===vu){let r=q0(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function q0(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof pr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof pr))return`"${t}${e.slice(1)}`}function L0(t,e){return e.emptyStr()?t:t.emptyStr()?e:nh`${t}${e}`}te.strConcat=L0;function U0(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:so(Array.isArray(t)?t.join(","):t)}function V0(t){return new et(so(t))}te.stringify=V0;function so(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}te.safeStringify=so;function F0(t){return typeof t=="string"&&te.IDENTIFIER.test(t)?new et(`.${t}`):rh`[${t}]`}te.getProperty=F0;function H0(t){if(typeof t=="string"&&te.IDENTIFIER.test(t))return new et(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}te.getEsmExportName=H0;function B0(t){return new et(t.toString())}te.regexpCode=B0});var ku=P(Le=>{"use strict";d();Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var qe=io(),wu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},qs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(qs||(Le.UsedValueState=qs={}));Le.varKinds={const:new qe.Name("const"),let:new qe.Name("let"),var:new qe.Name("var")};var Ls=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof qe.Name?e:this.name(e)}name(e){return new qe.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Le.Scope=Ls;var Us=class extends qe.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,qe._)`.${new qe.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var J0=(0,qe._)`\n`,xu=class extends Ls{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?J0:qe.nil}}get(){return this._scope}name(e){return new Us(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,qe._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=qe.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,qs.Started);let l=r(u);if(l){let p=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,qe._)`${s}${p} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,qe._)`${s}${l}${this.opts._n}`;else throw new wu(u);c.set(u,qs.Completed)})}return s}};Le.ValueScope=xu});var B=P(J=>{"use strict";d();Object.defineProperty(J,"__esModule",{value:!0});J.or=J.and=J.not=J.CodeGen=J.operators=J.varKinds=J.ValueScopeName=J.ValueScope=J.Scope=J.Name=J.regexpCode=J.stringify=J.getProperty=J.nil=J.strConcat=J.str=J._=void 0;var X=io(),lt=ku(),Ft=io();Object.defineProperty(J,"_",{enumerable:!0,get:function(){return Ft._}});Object.defineProperty(J,"str",{enumerable:!0,get:function(){return Ft.str}});Object.defineProperty(J,"strConcat",{enumerable:!0,get:function(){return Ft.strConcat}});Object.defineProperty(J,"nil",{enumerable:!0,get:function(){return Ft.nil}});Object.defineProperty(J,"getProperty",{enumerable:!0,get:function(){return Ft.getProperty}});Object.defineProperty(J,"stringify",{enumerable:!0,get:function(){return Ft.stringify}});Object.defineProperty(J,"regexpCode",{enumerable:!0,get:function(){return Ft.regexpCode}});Object.defineProperty(J,"Name",{enumerable:!0,get:function(){return Ft.Name}});var Bs=ku();Object.defineProperty(J,"Scope",{enumerable:!0,get:function(){return Bs.Scope}});Object.defineProperty(J,"ValueScope",{enumerable:!0,get:function(){return Bs.ValueScope}});Object.defineProperty(J,"ValueScopeName",{enumerable:!0,get:function(){return Bs.ValueScopeName}});Object.defineProperty(J,"varKinds",{enumerable:!0,get:function(){return Bs.varKinds}});J.operators={GT:new X._Code(">"),GTE:new X._Code(">="),LT:new X._Code("<"),LTE:new X._Code("<="),EQ:new X._Code("==="),NEQ:new X._Code("!=="),NOT:new X._Code("!"),OR:new X._Code("||"),AND:new X._Code("&&"),ADD:new X._Code("+")};var It=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},$u=class extends It{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=tn(this.rhs,e,r)),this}get names(){return this.rhs instanceof X._CodeOrName?this.rhs.names:{}}},Vs=class extends It{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof X.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=tn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof X.Name?{}:{...this.lhs.names};return Hs(e,this.rhs)}},Su=class extends Vs{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Tu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},zu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Pu=class extends It{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Iu=class extends It{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=tn(this.code,e,r),this}get names(){return this.code instanceof X._CodeOrName?this.code.names:{}}},ao=class extends It{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(K0(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>hr(e,r.names),{})}},Et=class extends ao{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Eu=class extends ao{},en=class extends Et{};en.kind="else";var fr=class t extends Et{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new en(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(oh(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=tn(this.condition,e,r),this}get names(){let e=super.names;return Hs(e,this.condition),this.else&&hr(e,this.else.names),e}};fr.kind="if";var mr=class extends Et{};mr.kind="for";var Ru=class extends mr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=tn(this.iteration,e,r),this}get names(){return hr(super.names,this.iteration.names)}},Cu=class extends mr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Hs(super.names,this.from);return Hs(e,this.to)}},Fs=class extends mr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=tn(this.iterable,e,r),this}get names(){return hr(super.names,this.iterable.names)}},co=class extends Et{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};co.kind="func";var uo=class extends ao{render(e){return"return "+super.render(e)}};uo.kind="return";var Zu=class extends Et{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&hr(e,this.catch.names),this.finally&&hr(e,this.finally.names),e}},lo=class extends Et{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};lo.kind="catch";var po=class extends Et{render(e){return"finally"+super.render(e)}};po.kind="finally";var Ou=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
+ import{A as np,B as op,C as sp,D as ip,E as ap,F as cp,G as up,H as lp,I as dp,J as pp,L as fp,M as mp,N as hp,O as gp,P as _p,Q as yp,a as P,b as Ld,c as Me,d,e as Ud,f as U,g as Vd,h as Ur,i as or,j as Uo,k as Fd,l as Cn,m as Tt,n as Hd,o as Bd,p as Vo,q as Jd,r as Kd,s as Gd,t as Wd,u as Yd,v as Xd,w as Qd,x as ep,y as tp,z as rp}from"./chunk-IUBGWDQC.js";var io=P(te=>{"use strict";d();Object.defineProperty(te,"__esModule",{value:!0});te.regexpCode=te.getEsmExportName=te.getProperty=te.safeStringify=te.stringify=te.strConcat=te.addCodeArg=te.str=te._=te.nil=te._Code=te.Name=te.IDENTIFIER=te._CodeOrName=void 0;var oo=class{};te._CodeOrName=oo;te.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var pr=class extends oo{constructor(e){if(super(),!te.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};te.Name=pr;var et=class extends oo{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof pr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};te._Code=et;te.nil=new et("");function rh(t,...e){let r=[t[0]],n=0;for(;n<e.length;)bu(r,e[n]),r.push(t[++n]);return new et(r)}te._=rh;var vu=new et("+");function nh(t,...e){let r=[so(t[0])],n=0;for(;n<e.length;)r.push(vu),bu(r,e[n]),r.push(vu,so(t[++n]));return D0(r),new et(r)}te.str=nh;function bu(t,e){e instanceof et?t.push(...e._items):e instanceof pr?t.push(e):t.push(U0(e))}te.addCodeArg=bu;function D0(t){let e=1;for(;e<t.length-1;){if(t[e]===vu){let r=q0(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function q0(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof pr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof pr))return`"${t}${e.slice(1)}`}function L0(t,e){return e.emptyStr()?t:t.emptyStr()?e:nh`${t}${e}`}te.strConcat=L0;function U0(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:so(Array.isArray(t)?t.join(","):t)}function V0(t){return new et(so(t))}te.stringify=V0;function so(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}te.safeStringify=so;function F0(t){return typeof t=="string"&&te.IDENTIFIER.test(t)?new et(`.${t}`):rh`[${t}]`}te.getProperty=F0;function H0(t){if(typeof t=="string"&&te.IDENTIFIER.test(t))return new et(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}te.getEsmExportName=H0;function B0(t){return new et(t.toString())}te.regexpCode=B0});var ku=P(Le=>{"use strict";d();Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var qe=io(),wu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},qs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(qs||(Le.UsedValueState=qs={}));Le.varKinds={const:new qe.Name("const"),let:new qe.Name("let"),var:new qe.Name("var")};var Ls=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof qe.Name?e:this.name(e)}name(e){return new qe.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Le.Scope=Ls;var Us=class extends qe.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,qe._)`.${new qe.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var J0=(0,qe._)`\n`,xu=class extends Ls{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?J0:qe.nil}}get(){return this._scope}name(e){return new Us(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,qe._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=qe.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,qs.Started);let l=r(u);if(l){let p=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,qe._)`${s}${p} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,qe._)`${s}${l}${this.opts._n}`;else throw new wu(u);c.set(u,qs.Completed)})}return s}};Le.ValueScope=xu});var B=P(J=>{"use strict";d();Object.defineProperty(J,"__esModule",{value:!0});J.or=J.and=J.not=J.CodeGen=J.operators=J.varKinds=J.ValueScopeName=J.ValueScope=J.Scope=J.Name=J.regexpCode=J.stringify=J.getProperty=J.nil=J.strConcat=J.str=J._=void 0;var X=io(),lt=ku(),Ft=io();Object.defineProperty(J,"_",{enumerable:!0,get:function(){return Ft._}});Object.defineProperty(J,"str",{enumerable:!0,get:function(){return Ft.str}});Object.defineProperty(J,"strConcat",{enumerable:!0,get:function(){return Ft.strConcat}});Object.defineProperty(J,"nil",{enumerable:!0,get:function(){return Ft.nil}});Object.defineProperty(J,"getProperty",{enumerable:!0,get:function(){return Ft.getProperty}});Object.defineProperty(J,"stringify",{enumerable:!0,get:function(){return Ft.stringify}});Object.defineProperty(J,"regexpCode",{enumerable:!0,get:function(){return Ft.regexpCode}});Object.defineProperty(J,"Name",{enumerable:!0,get:function(){return Ft.Name}});var Bs=ku();Object.defineProperty(J,"Scope",{enumerable:!0,get:function(){return Bs.Scope}});Object.defineProperty(J,"ValueScope",{enumerable:!0,get:function(){return Bs.ValueScope}});Object.defineProperty(J,"ValueScopeName",{enumerable:!0,get:function(){return Bs.ValueScopeName}});Object.defineProperty(J,"varKinds",{enumerable:!0,get:function(){return Bs.varKinds}});J.operators={GT:new X._Code(">"),GTE:new X._Code(">="),LT:new X._Code("<"),LTE:new X._Code("<="),EQ:new X._Code("==="),NEQ:new X._Code("!=="),NOT:new X._Code("!"),OR:new X._Code("||"),AND:new X._Code("&&"),ADD:new X._Code("+")};var It=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},$u=class extends It{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=tn(this.rhs,e,r)),this}get names(){return this.rhs instanceof X._CodeOrName?this.rhs.names:{}}},Vs=class extends It{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof X.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=tn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof X.Name?{}:{...this.lhs.names};return Hs(e,this.rhs)}},Su=class extends Vs{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Tu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},zu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Pu=class extends It{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Iu=class extends It{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=tn(this.code,e,r),this}get names(){return this.code instanceof X._CodeOrName?this.code.names:{}}},ao=class extends It{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(K0(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>hr(e,r.names),{})}},Et=class extends ao{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Eu=class extends ao{},en=class extends Et{};en.kind="else";var fr=class t extends Et{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new en(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(oh(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=tn(this.condition,e,r),this}get names(){let e=super.names;return Hs(e,this.condition),this.else&&hr(e,this.else.names),e}};fr.kind="if";var mr=class extends Et{};mr.kind="for";var Ru=class extends mr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=tn(this.iteration,e,r),this}get names(){return hr(super.names,this.iteration.names)}},Cu=class extends mr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Hs(super.names,this.from);return Hs(e,this.to)}},Fs=class extends mr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=tn(this.iterable,e,r),this}get names(){return hr(super.names,this.iterable.names)}},co=class extends Et{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};co.kind="func";var uo=class extends ao{render(e){return"return "+super.render(e)}};uo.kind="return";var Zu=class extends Et{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&hr(e,this.catch.names),this.finally&&hr(e,this.finally.names),e}},lo=class extends Et{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};lo.kind="catch";var po=class extends Et{render(e){return"finally"+super.render(e)}};po.kind="finally";var Ou=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
3
3
  `:""},this._extScope=e,this._scope=new lt.Scope({parent:e}),this._nodes=[new Eu]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new $u(e,s,n)),s}const(e,r,n){return this._def(lt.varKinds.const,e,r,n)}let(e,r,n){return this._def(lt.varKinds.let,e,r,n)}var(e,r,n){return this._def(lt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Vs(e,r,n))}add(e,r){return this._leafNode(new Su(e,J.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==X.nil&&this._leafNode(new Iu(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,X.addCodeArg)(r,o));return r.push("}"),new X._Code(r)}if(e,r,n){if(this._blockNode(new fr(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new fr(e))}else(){return this._elseNode(new en)}endIf(){return this._endBlockNode(fr,en)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ru(e),r)}forRange(e,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(e);return this._for(new Cu(s,i,r,n),()=>o(i))}forOf(e,r,n,o=lt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof X.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,X._)`${i}.length`,a=>{this.var(s,(0,X._)`${i}[${a}]`),n(s)})}return this._for(new Fs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,X._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Fs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(mr)}label(e){return this._leafNode(new Tu(e))}break(e){return this._leafNode(new zu(e))}return(e){let r=new uo;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(uo)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Zu;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new lo(s),r(s)}return n&&(this._currNode=o.finally=new po,this.code(n)),this._endBlockNode(lo,po)}throw(e){return this._leafNode(new Pu(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=X.nil,n,o){return this._blockNode(new co(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(co)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof fr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};J.CodeGen=Ou;function hr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Hs(t,e){return e instanceof X._CodeOrName?hr(t,e.names):t}function tn(t,e,r){if(t instanceof X.Name)return n(t);if(!o(t))return t;return new X._Code(t._items.reduce((s,i)=>(i instanceof X.Name&&(i=n(i)),i instanceof X._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof X._Code&&s._items.some(i=>i instanceof X.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function K0(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function oh(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,X._)`!${ju(t)}`}J.not=oh;var G0=sh(J.operators.AND);function W0(...t){return t.reduce(G0)}J.and=W0;var Y0=sh(J.operators.OR);function X0(...t){return t.reduce(Y0)}J.or=X0;function sh(t){return(e,r)=>e===X.nil?r:r===X.nil?e:(0,X._)`${ju(e)} ${t} ${ju(r)}`}function ju(t){return t instanceof X.Name?t:(0,X._)`(${t})`}});var Q=P(K=>{"use strict";d();Object.defineProperty(K,"__esModule",{value:!0});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;var ie=B(),Q0=io();function ex(t){let e={};for(let r of t)e[r]=!0;return e}K.toHash=ex;function tx(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(ch(t,e),!uh(e,t.self.RULES.all))}K.alwaysValidSchema=tx;function ch(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||ph(t,`unknown keyword: "${s}"`)}K.checkUnknownRules=ch;function uh(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}K.schemaHasRules=uh;function rx(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}K.schemaHasRulesButRef=rx;function nx({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ie._)`${r}`}return(0,ie._)`${t}${e}${(0,ie.getProperty)(n)}`}K.schemaRefOrVal=nx;function ox(t){return lh(decodeURIComponent(t))}K.unescapeFragment=ox;function sx(t){return encodeURIComponent(Nu(t))}K.escapeFragment=sx;function Nu(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=Nu;function lh(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=lh;function ix(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}K.eachItem=ix;function ih({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ie.Name?(s instanceof ie.Name?t(o,s,i):e(o,s,i),i):s instanceof ie.Name?(e(o,i,s),s):r(s,i);return a===ie.Name&&!(c instanceof ie.Name)?n(o,c):c}}K.mergeEvaluated={props:ih({mergeNames:(t,e,r)=>t.if((0,ie._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ie._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ie._)`${r} || {}`).code((0,ie._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ie._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ie._)`${r} || {}`),Mu(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:dh}),items:ih({mergeNames:(t,e,r)=>t.if((0,ie._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ie._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ie._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ie._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function dh(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ie._)`{}`);return e!==void 0&&Mu(t,r,e),r}K.evaluatedPropsToName=dh;function Mu(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ie._)`${e}${(0,ie.getProperty)(n)}`,!0))}K.setEvaluated=Mu;var ah={};function ax(t,e){return t.scopeValue("func",{ref:e,code:ah[e.code]||(ah[e.code]=new Q0._Code(e.code))})}K.useFunc=ax;var Au;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Au||(K.Type=Au={}));function cx(t,e,r){if(t instanceof ie.Name){let n=e===Au.Num;return r?n?(0,ie._)`"[" + ${t} + "]"`:(0,ie._)`"['" + ${t} + "']"`:n?(0,ie._)`"/" + ${t}`:(0,ie._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ie.getProperty)(t).toString():"/"+Nu(t)}K.getErrorPath=cx;function ph(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}K.checkStrictMode=ph});var Rt=P(Du=>{"use strict";d();Object.defineProperty(Du,"__esModule",{value:!0});var Pe=B(),ux={data:new Pe.Name("data"),valCxt:new Pe.Name("valCxt"),instancePath:new Pe.Name("instancePath"),parentData:new Pe.Name("parentData"),parentDataProperty:new Pe.Name("parentDataProperty"),rootData:new Pe.Name("rootData"),dynamicAnchors:new Pe.Name("dynamicAnchors"),vErrors:new Pe.Name("vErrors"),errors:new Pe.Name("errors"),this:new Pe.Name("this"),self:new Pe.Name("self"),scope:new Pe.Name("scope"),json:new Pe.Name("json"),jsonPos:new Pe.Name("jsonPos"),jsonLen:new Pe.Name("jsonLen"),jsonPart:new Pe.Name("jsonPart")};Du.default=ux});var fo=P(Ie=>{"use strict";d();Object.defineProperty(Ie,"__esModule",{value:!0});Ie.extendErrors=Ie.resetErrorsCount=Ie.reportExtraError=Ie.reportError=Ie.keyword$DataError=Ie.keywordError=void 0;var ee=B(),Js=Q(),je=Rt();Ie.keywordError={message:({keyword:t})=>(0,ee.str)`must pass "${t}" keyword validation`};Ie.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,ee.str)`"${t}" keyword must be ${e} ($data)`:(0,ee.str)`"${t}" keyword is invalid ($data)`};function lx(t,e=Ie.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=hh(t,e,r);n??(i||a)?fh(s,c):mh(o,(0,ee._)`[${c}]`)}Ie.reportError=lx;function dx(t,e=Ie.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=hh(t,e,r);fh(o,a),s||i||mh(n,je.default.vErrors)}Ie.reportExtraError=dx;function px(t,e){t.assign(je.default.errors,e),t.if((0,ee._)`${je.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,ee._)`${je.default.vErrors}.length`,e),()=>t.assign(je.default.vErrors,null)))}Ie.resetErrorsCount=px;function fx({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,je.default.errors,a=>{t.const(i,(0,ee._)`${je.default.vErrors}[${a}]`),t.if((0,ee._)`${i}.instancePath === undefined`,()=>t.assign((0,ee._)`${i}.instancePath`,(0,ee.strConcat)(je.default.instancePath,s.errorPath))),t.assign((0,ee._)`${i}.schemaPath`,(0,ee.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,ee._)`${i}.schema`,r),t.assign((0,ee._)`${i}.data`,n))})}Ie.extendErrors=fx;function fh(t,e){let r=t.const("err",e);t.if((0,ee._)`${je.default.vErrors} === null`,()=>t.assign(je.default.vErrors,(0,ee._)`[${r}]`),(0,ee._)`${je.default.vErrors}.push(${r})`),t.code((0,ee._)`${je.default.errors}++`)}function mh(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,ee._)`new ${t.ValidationError}(${e})`):(r.assign((0,ee._)`${n}.errors`,e),r.return(!1))}var gr={keyword:new ee.Name("keyword"),schemaPath:new ee.Name("schemaPath"),params:new ee.Name("params"),propertyName:new ee.Name("propertyName"),message:new ee.Name("message"),schema:new ee.Name("schema"),parentSchema:new ee.Name("parentSchema")};function hh(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,ee._)`{}`:mx(t,e,r)}function mx(t,e,r={}){let{gen:n,it:o}=t,s=[hx(o,r),gx(t,r)];return _x(t,e,s),n.object(...s)}function hx({errorPath:t},{instancePath:e}){let r=e?(0,ee.str)`${t}${(0,Js.getErrorPath)(e,Js.Type.Str)}`:t;return[je.default.instancePath,(0,ee.strConcat)(je.default.instancePath,r)]}function gx({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,ee.str)`${e}/${t}`;return r&&(o=(0,ee.str)`${o}${(0,Js.getErrorPath)(r,Js.Type.Str)}`),[gr.schemaPath,o]}function _x(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:p}=a;n.push([gr.keyword,o],[gr.params,typeof e=="function"?e(t):e||(0,ee._)`{}`]),c.messages&&n.push([gr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([gr.schema,i],[gr.parentSchema,(0,ee._)`${l}${p}`],[je.default.data,s]),u&&n.push([gr.propertyName,u])}});var _h=P(rn=>{"use strict";d();Object.defineProperty(rn,"__esModule",{value:!0});rn.boolOrEmptySchema=rn.topBoolOrEmptySchema=void 0;var yx=fo(),vx=B(),bx=Rt(),wx={message:"boolean schema is false"};function xx(t){let{gen:e,schema:r,validateName:n}=t;r===!1?gh(t,!1):typeof r=="object"&&r.$async===!0?e.return(bx.default.data):(e.assign((0,vx._)`${n}.errors`,null),e.return(!0))}rn.topBoolOrEmptySchema=xx;function kx(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),gh(t)):r.var(e,!0)}rn.boolOrEmptySchema=kx;function gh(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,yx.reportError)(o,wx,void 0,e)}});var qu=P(nn=>{"use strict";d();Object.defineProperty(nn,"__esModule",{value:!0});nn.getRules=nn.isJSONType=void 0;var $x=["string","number","integer","boolean","null","object","array"],Sx=new Set($x);function Tx(t){return typeof t=="string"&&Sx.has(t)}nn.isJSONType=Tx;function zx(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}nn.getRules=zx});var Lu=P(Ht=>{"use strict";d();Object.defineProperty(Ht,"__esModule",{value:!0});Ht.shouldUseRule=Ht.shouldUseGroup=Ht.schemaHasRulesForType=void 0;function Px({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&yh(t,n)}Ht.schemaHasRulesForType=Px;function yh(t,e){return e.rules.some(r=>vh(t,r))}Ht.shouldUseGroup=yh;function vh(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ht.shouldUseRule=vh});var mo=P(Ee=>{"use strict";d();Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var Ix=qu(),Ex=Lu(),Rx=fo(),H=B(),bh=Q(),on;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(on||(Ee.DataType=on={}));function Cx(t){let e=wh(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=Cx;function wh(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(Ix.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=wh;function Zx(t,e){let{gen:r,data:n,opts:o}=t,s=Ox(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,Ex.schemaHasRulesForType)(t,e[0]));if(i){let a=Vu(e,n,o.strictNumbers,on.Wrong);r.if(a,()=>{s.length?jx(t,e,s):Fu(t)})}return i}Ee.coerceAndCheckDataType=Zx;var xh=new Set(["string","number","integer","boolean","null"]);function Ox(t,e){return e?t.filter(r=>xh.has(r)||e==="array"&&r==="array"):[]}function jx(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,H._)`typeof ${o}`),a=n.let("coerced",(0,H._)`undefined`);s.coerceTypes==="array"&&n.if((0,H._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,H._)`${o}[0]`).assign(i,(0,H._)`typeof ${o}`).if(Vu(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,H._)`${a} !== undefined`);for(let u of r)(xh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Fu(t),n.endIf(),n.if((0,H._)`${a} !== undefined`,()=>{n.assign(o,a),Ax(t,a)});function c(u){switch(u){case"string":n.elseIf((0,H._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,H._)`"" + ${o}`).elseIf((0,H._)`${o} === null`).assign(a,(0,H._)`""`);return;case"number":n.elseIf((0,H._)`${i} == "boolean" || ${o} === null
4
4
  || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,H._)`+${o}`);return;case"integer":n.elseIf((0,H._)`${i} === "boolean" || ${o} === null
5
5
  || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,H._)`+${o}`);return;case"boolean":n.elseIf((0,H._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,H._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,H._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,H._)`${i} === "string" || ${i} === "number"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neurynae/toolcairn-mcp",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "mcpName": "io.github.neurynae/toolcairn-mcp",
5
5
  "private": false,
6
6
  "license": "MIT",