agentsmesh 0.18.0 → 0.18.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.
- package/CHANGELOG.md +24 -0
- package/dist/canonical.js +103 -129
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +130 -130
- package/dist/engine.js +103 -129
- package/dist/engine.js.map +1 -1
- package/dist/index.js +103 -129
- package/dist/index.js.map +1 -1
- package/dist/targets.js +103 -129
- package/dist/targets.js.map +1 -1
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {resolve,join,sep,dirname,extname,basename,relative,win32,posix,normalize}from'path';import {rm as rm$1,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,chmod,access,realpath,readlink,symlink,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {realpathSync,rmSync,statSync,existsSync,mkdtempSync,readdirSync,symlinkSync,mkdirSync,constants,readFileSync}from'fs';import {z as z$1}from'zod';import {parse,stringify}from'yaml';import {homedir,tmpdir,hostname}from'os';import {execFile}from'child_process';import {fileURLToPath,pathToFileURL,URL}from'url';import {promisify}from'util';import*as
|
|
3
|
-
`);},warn(t){
|
|
4
|
-
`);},error(t){
|
|
5
|
-
`);},success(t){
|
|
6
|
-
`);},debug(t){
|
|
7
|
-
`);},table(t){if(
|
|
8
|
-
`);for(let n=0;n<t.length;n++){let a="| "+t[n].map((c,l)=>s$(c,r[l])).join(" | ")+" |";
|
|
9
|
-
`);}
|
|
10
|
-
`);}};});var
|
|
11
|
-
`)}function hg(t){return g$.has(extname(t).toLowerCase())?493:void 0}var fg,u$,d$,g$,yg=d(()=>{fg="\uFEFF",u$=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),d$=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(xR,"shouldNormalizeLineEndings");s(DR,"normalizeLineEndings");g$=new Set([".sh",".bash",".zsh"]);s(hg,"executableModeFor");});async function v(t,e){let r;try{r=await realpath(t);}catch(n){let i=n;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="ELOOP")return [];throw new He(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:n,errnoCode:i.code})}let o=e??new Set;if(o.has(r))return [];o.add(r);try{let n=await readdir(t,{withFileTypes:!0}),i=[];for(let a of n){let c=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(c).then(m=>m.isDirectory(),()=>!1)?i.push(...await v(c,o)):i.push(c);}return i}catch(n){let i=n;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="EACCES")return [];throw new He(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:n,errnoCode:i.code})}}async function _g(t,e){let r=resolve(t);try{if(!(await lstat(e)).isSymbolicLink()||resolve(dirname(e),await readlink(e))===r)return;await unlink(e);}catch(o){if(o.code!=="ENOENT")throw o}await symlink(r,e,"dir");}var FR=d(()=>{dn();s(v,"readDirRecursive");s(_g,"ensureCacheSymlink");});async function y(t){try{let e=await readFile(t,"utf-8");return e.startsWith(fg)?e.slice(fg.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new He(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function _(t,e,r){let o=dirname(t);await mkdir(o,{recursive:true});try{let c=await lstat(t);if(c.isDirectory())throw new He(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});c.isSymbolicLink()&&await unlink(t).catch(l=>{if(l.code!=="ENOENT")throw l});}catch(c){if(c instanceof He||c.code!=="ENOENT")throw c}let n=`${t}.tmp`,i=xR(t)?DR(e):e,a=r?.mode??hg(t);try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(l){if(l.code!=="ENOENT")throw l}let c={encoding:"utf-8",flag:"w"};a!==void 0&&(c.mode=a),await writeFile(n,i,c),await rename(n,t),a!==void 0&&await chmod(t,a);}catch(c){await rm$1(n,{force:true}).catch(()=>{});let l=c;throw new He(t,`Failed to write ${t}: ${l.message}. Check permissions and disk space.`,{cause:c,errnoCode:l.code})}}async function j(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function L(t){await mkdir(t,{recursive:true});}var T=d(()=>{dn();yg();FR();yg();s(y,"readFileSafe");s(_,"writeFileAtomic");s(j,"exists");s(L,"mkdirp");});function Tr(t){return Ig.includes(t)}var Ig,$R=d(()=>{Ig=["aider","amazon-q","amp","antigravity","augment-code","claude-code","cline","codex-cli","continue","copilot","crush","cursor","deepagents-cli","factory-droid","gemini-cli","goose","jules","junie","kilo-code","kiro","opencode","pi-agent","qwen-code","replit-agent","roo-code","rovodev","trae","warp","windsurf","zed"];s(Tr,"isBuiltinTargetId");});var kt,Rg,uo=d(()=>{$R();kt=Ig,Rg="codex-cli";});var jR,ze,va,hl,x$,D$,fl,N$,F$,gi,gn=d(()=>{uo();jR=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],ze=z$1.enum(kt),va=z$1.enum(jR),hl=z$1.object({skills:z$1.array(z$1.string()).optional(),commands:z$1.array(z$1.string()).optional(),rules:z$1.array(z$1.string()).optional(),agents:z$1.array(z$1.string()).optional()}).strict(),x$=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:ze.optional(),features:z$1.array(va),path:z$1.string().optional(),pick:hl.optional()}),D$=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),fl=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),N$=z$1.object({commands_to_skills:z$1.object({"codex-cli":fl.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":fl.optional(),cline:fl.optional(),"codex-cli":fl.optional(),windsurf:fl.optional()}).passthrough().optional()}).strict().optional(),F$=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional(),strict:z$1.boolean().optional()}).strict(),gi=z$1.object({version:z$1.literal(1),targets:z$1.array(ze).default([...kt]),features:z$1.array(va).default([...jR]),extends:z$1.array(x$).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:D$.default({strategy:"merge",lock_features:[]}),conversions:N$,plugins:z$1.array(F$).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function M$(t){let e=resolve(t);for(;;){let r=join(e,Cg);if(await j(r))return r;let o=dirname(e);if(o===e)return null;e=o;}}async function $$(t){let e=await y(t);if(e===null)throw new wr(t);let r=parse(e),o=gi.safeParse(r);if(!o.success){let n=o.error.issues.map(i=>i.message);throw new Na(t,n,{cause:o.error})}return o.data}function Sg(t,e){let r={...t};for(let[o,n]of Object.entries(e)){if(n==null)continue;let i=r[o];typeof n=="object"&&!Array.isArray(n)&&n!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[o]=Sg(i,n):r[o]=n;}return r}function j$(t,e){let r={...t};return Array.isArray(e.targets)&&e.targets.length>0&&(r.targets=e.targets),Array.isArray(e.features)&&e.features.length>0&&(r.features=e.features),typeof e.overrides=="object"&&e.overrides!==null&&!Array.isArray(e.overrides)&&(r.overrides=Sg(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Sg(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function tp(t){let e=join(t,Cg),r=await $$(e),o=join(t,G$),n=await y(o);if(n!==null){let i=parse(n);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=j$(r,i),c=gi.safeParse(a);if(c.success)r=c.data;else {let l=c.error.issues.map(m=>m.message).join("; ");I.warn(`Ignoring invalid agentsmesh.local.yaml at ${o}: ${l}. Using project config instead.`);}}}return {config:r,configDir:t}}async function ep(t){let e=await M$(t);if(e===null)throw new wr(join(t,Cg));return tp(dirname(e))}var Cg,G$,rp=d(()=>{T();ft();dn();gn();Cg="agentsmesh.yaml",G$="agentsmesh.local.yaml";s(M$,"findConfigPath");s($$,"loadConfig");s(Sg,"deepMergeObjects");s(j$,"mergeLocalConfig");s(tp,"loadConfigFromExactDir");s(ep,"loadConfigFromDir");});function yl(t,e="project"){if(e==="project")return {scope:e,rootBase:t,configDir:t,canonicalDir:join(t,".agentsmesh")};let r=homedir(),o=join(r,".agentsmesh");return {scope:e,rootBase:r,configDir:o,canonicalDir:o}}async function Tt(t,e="project"){if(e==="project"){let{config:o,configDir:n}=await ep(t);return {config:o,context:{scope:e,rootBase:n,configDir:n,canonicalDir:join(n,".agentsmesh")}}}let r=yl(t,e);try{let{config:o}=await tp(r.configDir);return {config:o,context:r}}catch(o){throw o instanceof wr?new wr(o.path,{cause:o,message:`agentsmesh.yaml not found at ${o.path} (global scope). Run 'agentsmesh init --global' to create it under ~/.agentsmesh, or drop the --global flag to operate on the current project.`}):o}}var Oe=d(()=>{rp();dn();s(yl,"resolveScopeContext");s(Tt,"loadScopedConfig");});function HR(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function op(t,e,r,o,n){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,c=t.ref??"HEAD",l=n(i,a,c),m=join(o,l),p=join(m,BR),u=`${m}.tmp`,g=join(u,BR);if(!r.refresh&&await WR(p))return Ag(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await Y$(J$(t),g),t.ref&&await X$(g,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),Ag(p)}catch(f){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await WR(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${f instanceof Error?f.message:String(f)}`),Ag(p);throw f}}async function Ag(t){return {resolvedPath:t,version:await Z$(t)}}async function WR(t){return j(t)}function J$(t){if("cloneUrl"in t){let e=process.env.AGENTSMESH_GITLAB_TOKEN;if(e){let r=new URL(t.cloneUrl);if(r.protocol==="https:")return r.username="oauth2",r.password=e,r.toString()}return t.cloneUrl}return t.url}async function Y$(t,e){HR(t,"clone-url"),await kg(["clone",t,e]);}async function X$(t,e){HR(e,"ref"),await kg(["checkout",e],t);}async function Z$(t){return kg(["rev-parse","HEAD"],t)}async function kg(t,e){let{stdout:r}=await V$("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var V$,BR,wg=d(()=>{T();V$=promisify(execFile),BR="repo";s(HR,"ensureNotFlag");s(op,"fetchGitRemoteExtend");s(Ag,"readCachedRepo");s(WR,"hasCachedRepo");s(J$,"resolveCloneUrl");s(Y$,"cloneRepo");s(X$,"checkoutRef");s(Z$,"getHeadSha");s(kg,"runGit");});async function rj(t,e){let r=typeof t.headers?.get=="function"?t.headers.get("content-length"):null;if(r!==null){let m=Number(r);if(Number.isFinite(m)&&m>e)throw new Error(`remote response declared ${m} bytes; exceeds cap of ${e}`)}let o=t.body;if(!o){let m=await t.arrayBuffer();if(m.byteLength>e)throw new Error(`remote response is ${m.byteLength} bytes; exceeds cap of ${e}`);return new Uint8Array(m)}let n=o.getReader(),i=[],a=0;for(;;){let{done:m,value:p}=await n.read();if(m)break;if(p){if(a+=p.byteLength,a>e)throw await n.cancel().catch(()=>{}),new Error(`remote response exceeded cap of ${e} bytes during streaming`);i.push(p);}}let c=new Uint8Array(a),l=0;for(let m of i)c.set(m,l),l+=m.byteLength;return c}async function YR(t,e,r){let o=`https://api.github.com/repos/${t}/${e}/releases/latest`,n={Accept:"application/vnd.github+json"};r&&(n.Authorization=`Bearer ${r}`);let i=await globalThis.fetch(o,{headers:n});if(!i.ok)throw new Error(`Failed to resolve latest release for ${t}/${e}: ${i.status} ${i.statusText}`);let a=await i.json();if(!a.tag_name||typeof a.tag_name!="string")throw new Error(`No tag_name in releases/latest response for ${t}/${e}`);return a.tag_name}async function XR(t,e,r,o,n,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,c=r.refresh===true,l=t.tag;if(l==="latest")try{l=await YR(t.org,t.repo,a);}catch(S){if(!i)throw S;return nj(t,e,r,o,n,a)}let m=n("github",`${t.org}/${t.repo}`,l),p=join(o,m);if(!c&&await j(p)){let S=await Tg(p);if(S)return {resolvedPath:join(p,S),version:l}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${l}`,g={};a&&(g.Authorization=`Bearer ${a}`);let f;try{let S=await globalThis.fetch(u,{headers:g,redirect:"follow"});if(!S.ok)throw new Error(`HTTP ${S.status}: ${S.statusText}`);f=await rj(S,ej);}catch(S){if(r.allowOfflineFallback!==false&&await j(p)){let D=await Tg(p);if(D)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${S instanceof Error?S.message:String(S)}`),{resolvedPath:join(p,D),version:l}}throw S}await rm$1(p,{recursive:true,force:true}),await mkdir(p,{recursive:true});let h=join(p,"archive.tar.gz");await writeFile(h,f);try{await JR.extract({file:h,cwd:p,strict:!0,filter:s((S,A)=>!(oj(S)||A&&"type"in A&&(A.type==="Link"||A.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let O=await Tg(p);if(!O)throw new Error(`Extend "${e}": archive has no top-level directory. Expected a single top-level directory inside the archive.`);return {resolvedPath:join(p,O),version:l}}async function Tg(t){let r=(await readdir(t,{withFileTypes:true})).filter(o=>o.isDirectory()&&!o.name.startsWith("."));return r.length===1?r[0].name:null}function VR(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function oj(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function nj(t,e,r,o,n,i){let a=i?[VR(t.org,t.repo,i)]:[VR(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],c;for(let l of a){let m={url:l};try{return await op(m,e,r,o,n)}catch(p){c=p;}}throw c instanceof Error?c:new Error("Failed to clone GitHub default branch")}var ej,ZR=d(()=>{T();wg();ej=500*1024*1024;s(rj,"readBoundedResponse");s(YR,"resolveLatestTag");s(XR,"fetchGithubRemoteExtend");s(Tg,"findExtractTopDir");s(VR,"buildGithubCloneUrl");s(oj,"isZipSlipPath");s(nj,"fetchGithubDefaultBranch");});function QR(t,e,r){if(!t.startsWith(e))return null;let o=t.slice(e.length).trim();if(!o)return null;let n=o.lastIndexOf("@");if(n<0)return [o,r];let i=o.slice(0,n).trim(),a=o.slice(n+1).trim();return !i||!a?null:[i,a]}function qR(t){let e=QR(t,"github:","latest");if(!e)return null;let[r,o]=e,n=r.indexOf("/");if(n<0)return null;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();return !i||!a||!o?null:{org:i,repo:a,tag:o}}function tS(t){let e=QR(t,"gitlab:");if(!e)return null;let[r,o]=e,n=r.lastIndexOf("/");if(n<0)return null;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();return !i||!a?null:{namespace:i,project:a,ref:o,cloneUrl:`https://gitlab.com/${i}/${a}.git`}}function eS(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),o=(r<0?e:e.slice(0,r)).trim(),n=r<0?void 0:e.slice(r+1).trim();if(!o||r>=0&&!n)return null;let i;try{i=new URL(o);}catch{return null}return ["https:","http:","ssh:","file:"].includes(i.protocol)?{url:o,ref:n}:null}function fi(t){let e=qR(t);if(e)return {kind:"github",...e};let r=tS(t);if(r)return {kind:"gitlab",...r};let o=eS(t);return o?{kind:"git",...o}:null}function bg(t){return fi(t)!==null}var Il=d(()=>{s(QR,"splitSourceRef");s(qR,"parseGithubSource");s(tS,"parseGitlabSource");s(eS,"parseGitSource");s(fi,"parseRemoteSource");s(bg,"isSupportedRemoteSource");});function cj(t){let e=fi(t);return e?e.kind==="github"?Ga("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?Ga("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):Ga("git",e.url,e.ref??"HEAD"):null}async function nS(t,e){let r=cj(t);if(!r)return;let o=e??Le(),n=join(o,r);await rm$1(n,{recursive:true,force:true});}async function sS(t,e){let r=t??Le(),o=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,n;try{n=await readdir(r);}catch{return}let i=Date.now();await Promise.all(n.map(async a=>{let c=join(r,a);try{let{mtimeMs:l}=await stat(c);i-l>o&&await rm$1(c,{recursive:!0,force:!0});}catch{}}));}var Pg=d(()=>{Rl();Il();s(cj,"cacheKeyFromSource");s(nS,"cleanInstallCache");s(sS,"sweepStaleCache");});function Ga(t,e,r){let o=s(i=>i.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),n;if(t==="github"){let[i,a]=e.split("/",2);i&&a?n=`${o(i)}--${o(a)}--${o(r)}`:n=`${o(t)}__${o(e)}__${o(r)}`;}else n=`${o(t)}__${o(e)}__${o(r)}`;if(n.length>cS){let i=createHash("sha256").update(n).digest("hex").slice(0,16);n=`${n.slice(0,cS-18)}--${i}`;}return n}function Le(){let t=process.env.AGENTSMESH_CACHE;if(t){let e=t.trim();if(!e)return join(homedir(),".agentsmesh","cache");if(!/^([A-Za-z]:[\\/]|\/)/.test(e))throw new Error(`AGENTSMESH_CACHE must be an absolute path (got: "${e}").`);if(e==="/"||/^[A-Za-z]:[\\/]?$/.test(e))throw new Error(`AGENTSMESH_CACHE must not be the filesystem root (got: "${e}").`);return e}return join(homedir(),".agentsmesh","cache")}async function Ma(t,e,r={}){let o=fi(t);if(!o)throw t.startsWith("github:")?new Error(`Invalid github: source: "${t}" for extend "${e}"`):t.startsWith("gitlab:")?new Error(`Invalid gitlab: source: "${t}" for extend "${e}"`):t.startsWith("git+")?new Error(`Invalid git+ source: "${t}" for extend "${e}"`):new Error(`Invalid remote source: "${t}" for extend "${e}". Use github:org/repo@tag, gitlab:group/project@ref, or git+https://host/org/repo.git#ref.`);let n=r.cacheDir??Le();return sS(n).catch(()=>{}),o.kind==="github"?XR(o,e,r,n,Ga,!t.includes("@")):op(o,e,r,n,Ga)}var cS,Rl=d(()=>{wg();ZR();Il();Pg();cS=80;s(Ga,"buildCacheKey");s(Le,"getCacheDir");s(Ma,"fetchRemoteExtend");});function dj(t){return t.startsWith("http://")||t.startsWith("https://")}async function $a(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(n=>bg(n.source))){let n=Le();await rm$1(n,{recursive:true,force:true}),await mkdir(n,{recursive:true});}let o=[];for(let n of t.extends){if(dj(n.source))throw new Error(`Remote extends (http/https) not supported: "${n.source}" for extend "${n.name}". Use github:org/repo@tag, gitlab:group/project@ref, git+https://host/org/repo.git#ref, or a local path (e.g. ./shared/).`);if(bg(n.source)){let a=await Ma(n.source,n.name,{cacheDir:Le(),refresh:r.refreshCache===true});o.push({name:n.name,resolvedPath:a.resolvedPath,features:[...n.features],target:n.target,version:a.version,path:n.path,pick:n.pick});continue}let i=resolve(e,n.source);if(!await j(i))throw new Error(`Extend "${n.name}": path does not exist: ${i}. Check extends.source in agentsmesh.yaml.`);o.push({name:n.name,resolvedPath:i,features:[...n.features],target:n.target,path:n.path,pick:n.pick});}return o}var np=d(()=>{T();Rl();Il();s(dj,"isOtherRemoteSource");s($a,"resolveExtendPaths");});function k(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let o=t.slice(3,r).trim(),n=t.slice(r+3).trim();return {frontmatter:o===""?{}:parse(o)??{},body:n}}function P(t,e){return Object.keys(t).length===0?e:`---
|
|
2
|
+
import {resolve,join,sep,dirname,extname,basename,relative,win32,posix,normalize}from'path';import {rm as rm$1,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,chmod,access,realpath,readlink,symlink,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {realpathSync,rmSync,statSync,existsSync,mkdtempSync,readdirSync,symlinkSync,mkdirSync,constants,readFileSync}from'fs';import {z as z$1}from'zod';import {parse,stringify}from'yaml';import {homedir,tmpdir,hostname}from'os';import {execFile}from'child_process';import {fileURLToPath,pathToFileURL,URL}from'url';import {promisify}from'util';import*as KR from'tar';import {createHash}from'crypto';import {parse as parse$1}from'smol-toml';import {Buffer as Buffer$1}from'buffer';import {createRequire}from'module';import {createTwoFilesPatch}from'diff';import g1 from'chokidar';import*as FG from'readline';import {Server}from'@modelcontextprotocol/sdk/server/index.js';import {StdioServerTransport}from'@modelcontextprotocol/sdk/server/stdio.js';import {ListToolsRequestSchema,CallToolRequestSchema,ListResourcesRequestSchema,ReadResourceRequestSchema}from'@modelcontextprotocol/sdk/types.js';import {toJSONSchema}from'zod/v4/core';var dR=Object.defineProperty;var s=(t,e)=>dR(t,"name",{value:e,configurable:true});var u=(t,e)=>()=>(t&&(e=t(t=0)),e);var ug=(t,e)=>{for(var r in e)dR(t,r,{get:e[r],enumerable:true});};function hR(){mi=true;}function yR(){fR=true;}function wa(t){fR?process.stderr.write(t):process.stdout.write(t);}function n$(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function pl(t,e){return n$()?e:`${t}${e}${Ta.reset}`}function s$(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Ta,mi,fR,_,ft=u(()=>{Ta={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},mi=false,fR=false;s(hR,"muteLogger");s(yR,"redirectLoggerToStderr");s(wa,"out");s(n$,"noColor");s(pl,"c");s(s$,"pad");_={info(t){mi||wa(pl(Ta.cyan,t)+`
|
|
3
|
+
`);},warn(t){mi||process.stderr.write(pl(Ta.yellow,"\u26A0 ")+t+`
|
|
4
|
+
`);},error(t){mi||process.stderr.write(pl(Ta.red,"\u2717 ")+t+`
|
|
5
|
+
`);},success(t){mi||wa(pl(Ta.green,"\u2713 ")+t+`
|
|
6
|
+
`);},debug(t){mi||process.env.AGENTSMESH_DEBUG==="1"&&wa(pl(Ta.cyan,"[debug] ")+t+`
|
|
7
|
+
`);},table(t){if(mi||t.length===0)return;let e=t[0].length,r=[];for(let n=0;n<e;n++){let i=0;for(let a=0;a<t.length;a++){let c=[...t[a][n]].length;c>i&&(i=c);}r[n]=i;}let o="+"+r.map(n=>"-".repeat(n+2)).join("+")+"+";wa(o+`
|
|
8
|
+
`);for(let n=0;n<t.length;n++){let a="| "+t[n].map((c,l)=>s$(c,r[l])).join(" | ")+" |";wa(a+`
|
|
9
|
+
`);}wa(o+`
|
|
10
|
+
`);}};});var ln,kr,Pa,lo,xa,He,mn=u(()=>{ln=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,o){super(r,o),this.name="AgentsMeshError",this.code=e;}},kr=class extends ln{static{s(this,"ConfigNotFoundError");}path;constructor(e,r){super("AM_CONFIG_NOT_FOUND",r?.message??`agentsmesh.yaml not found at ${e}. Run 'agentsmesh init' to create one.`,r),this.name="ConfigNotFoundError",this.path=e;}},Pa=class extends ln{static{s(this,"ConfigValidationError");}issues;constructor(e,r,o){super("AM_CONFIG_INVALID",`Invalid config at ${e}: ${r.join("; ")}. Fix the YAML and try again.`,o),this.name="ConfigValidationError",this.issues=r;}},lo=class extends ln{static{s(this,"TargetNotFoundError");}target;constructor(e,r){let o=r?.supported?` Supported: ${r.supported.join(", ")}.`:"";super("AM_TARGET_NOT_FOUND",`Unknown target "${e}".${o}`,r),this.name="TargetNotFoundError",this.target=e;}},xa=class extends ln{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,o){super("AM_LOCK_ACQUISITION_FAILED",`Could not acquire generate lock at ${e}: currently held by ${r}. Wait for the other process to finish, or remove ${e} manually if you are sure no agentsmesh process is running.`,o),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},He=class extends ln{static{s(this,"FileSystemError");}path;errnoCode;constructor(e,r,o){super("AM_FILESYSTEM",r,o),this.name="FileSystemError",this.path=e,this.errnoCode=o?.errnoCode;}};});function AR(t){let e=extname(t).toLowerCase();if(e.length>0)return u$.has(e);let r=basename(t).toLowerCase();return d$.has(r)}function kR(t){return t.replace(/\r\n?/g,`
|
|
11
|
+
`)}function gg(t){return g$.has(extname(t).toLowerCase())?493:void 0}var dg,u$,d$,g$,fg=u(()=>{dg="\uFEFF",u$=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),d$=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(AR,"shouldNormalizeLineEndings");s(kR,"normalizeLineEndings");g$=new Set([".sh",".bash",".zsh"]);s(gg,"executableModeFor");});async function N(t,e){let r;try{r=await realpath(t);}catch(n){let i=n;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="ELOOP")return [];throw new He(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:n,errnoCode:i.code})}let o=e??new Set;if(o.has(r))return [];o.add(r);try{let n=await readdir(t,{withFileTypes:!0}),i=[];for(let a of n){let c=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(c).then(m=>m.isDirectory(),()=>!1)?i.push(...await N(c,o)):i.push(c);}return i}catch(n){let i=n;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="EACCES")return [];throw new He(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:n,errnoCode:i.code})}}async function hg(t,e){let r=resolve(t);try{if(!(await lstat(e)).isSymbolicLink()||resolve(dirname(e),await readlink(e))===r)return;await unlink(e);}catch(o){if(o.code!=="ENOENT")throw o}await symlink(r,e,"dir");}var TR=u(()=>{mn();s(N,"readDirRecursive");s(hg,"ensureCacheSymlink");});async function y(t){try{let e=await readFile(t,"utf-8");return e.startsWith(dg)?e.slice(dg.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new He(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function I(t,e,r){let o=dirname(t);await mkdir(o,{recursive:true});try{let c=await lstat(t);if(c.isDirectory())throw new He(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});c.isSymbolicLink()&&await unlink(t).catch(l=>{if(l.code!=="ENOENT")throw l});}catch(c){if(c instanceof He||c.code!=="ENOENT")throw c}let n=`${t}.tmp`,i=AR(t)?kR(e):e,a=r?.mode??gg(t);try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(l){if(l.code!=="ENOENT")throw l}let c={encoding:"utf-8",flag:"w"};a!==void 0&&(c.mode=a),await writeFile(n,i,c),await rename(n,t),a!==void 0&&await chmod(t,a);}catch(c){await rm$1(n,{force:true}).catch(()=>{});let l=c;throw new He(t,`Failed to write ${t}: ${l.message}. Check permissions and disk space.`,{cause:c,errnoCode:l.code})}}async function j(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function L(t){await mkdir(t,{recursive:true});}var T=u(()=>{mn();fg();TR();fg();s(y,"readFileSafe");s(I,"writeFileAtomic");s(j,"exists");s(L,"mkdirp");});function wr(t){return yg.includes(t)}var yg,DR=u(()=>{yg=["aider","amazon-q","amp","antigravity","augment-code","claude-code","cline","codex-cli","continue","copilot","crush","cursor","deepagents-cli","factory-droid","gemini-cli","goose","jules","junie","kilo-code","kiro","opencode","pi-agent","qwen-code","replit-agent","roo-code","rovodev","trae","warp","windsurf","zed"];s(wr,"isBuiltinTargetId");});var kt,_g,mo=u(()=>{DR();kt=yg,_g="codex-cli";});var NR,ze,Da,gl,x$,D$,dl,N$,F$,pi,pn=u(()=>{mo();NR=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],ze=z$1.enum(kt),Da=z$1.enum(NR),gl=z$1.object({skills:z$1.array(z$1.string()).optional(),commands:z$1.array(z$1.string()).optional(),rules:z$1.array(z$1.string()).optional(),agents:z$1.array(z$1.string()).optional()}).strict(),x$=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:ze.optional(),features:z$1.array(Da),path:z$1.string().optional(),pick:gl.optional()}),D$=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),dl=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),N$=z$1.object({commands_to_skills:z$1.object({"codex-cli":dl.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":dl.optional(),cline:dl.optional(),"codex-cli":dl.optional(),windsurf:dl.optional()}).passthrough().optional()}).strict().optional(),F$=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional(),strict:z$1.boolean().optional()}).strict(),pi=z$1.object({version:z$1.literal(1),targets:z$1.array(ze).default([...kt]),features:z$1.array(Da).default([...NR]),extends:z$1.array(x$).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:D$.default({strategy:"merge",lock_features:[]}),conversions:N$,plugins:z$1.array(F$).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function M$(t){let e=resolve(t);for(;;){let r=join(e,Rg);if(await j(r))return r;let o=dirname(e);if(o===e)return null;e=o;}}async function $$(t){let e=await y(t);if(e===null)throw new kr(t);let r=parse(e),o=pi.safeParse(r);if(!o.success){let n=o.error.issues.map(i=>i.message);throw new Pa(t,n,{cause:o.error})}return o.data}function Ig(t,e){let r={...t};for(let[o,n]of Object.entries(e)){if(n==null)continue;let i=r[o];typeof n=="object"&&!Array.isArray(n)&&n!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[o]=Ig(i,n):r[o]=n;}return r}function j$(t,e){let r={...t};return Array.isArray(e.targets)&&e.targets.length>0&&(r.targets=e.targets),Array.isArray(e.features)&&e.features.length>0&&(r.features=e.features),typeof e.overrides=="object"&&e.overrides!==null&&!Array.isArray(e.overrides)&&(r.overrides=Ig(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Ig(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function tp(t){let e=join(t,Rg),r=await $$(e),o=join(t,G$),n=await y(o);if(n!==null){let i=parse(n);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=j$(r,i),c=pi.safeParse(a);if(c.success)r=c.data;else {let l=c.error.issues.map(m=>m.message).join("; ");_.warn(`Ignoring invalid agentsmesh.local.yaml at ${o}: ${l}. Using project config instead.`);}}}return {config:r,configDir:t}}async function ep(t){let e=await M$(t);if(e===null)throw new kr(join(t,Rg));return tp(dirname(e))}var Rg,G$,rp=u(()=>{T();ft();mn();pn();Rg="agentsmesh.yaml",G$="agentsmesh.local.yaml";s(M$,"findConfigPath");s($$,"loadConfig");s(Ig,"deepMergeObjects");s(j$,"mergeLocalConfig");s(tp,"loadConfigFromExactDir");s(ep,"loadConfigFromDir");});function fl(t,e="project"){if(e==="project")return {scope:e,rootBase:t,configDir:t,canonicalDir:join(t,".agentsmesh")};let r=homedir(),o=join(r,".agentsmesh");return {scope:e,rootBase:r,configDir:o,canonicalDir:o}}async function Tt(t,e="project"){if(e==="project"){let{config:o,configDir:n}=await ep(t);return {config:o,context:{scope:e,rootBase:n,configDir:n,canonicalDir:join(n,".agentsmesh")}}}let r=fl(t,e);try{let{config:o}=await tp(r.configDir);return {config:o,context:r}}catch(o){throw o instanceof kr?new kr(o.path,{cause:o,message:`agentsmesh.yaml not found at ${o.path} (global scope). Run 'agentsmesh init --global' to create it under ~/.agentsmesh, or drop the --global flag to operate on the current project.`}):o}}var Oe=u(()=>{rp();mn();s(fl,"resolveScopeContext");s(Tt,"loadScopedConfig");});function $R(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function op(t,e,r,o,n){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,c=t.ref??"HEAD",l=n(i,a,c),m=join(o,l),p=join(m,GR),d=`${m}.tmp`,g=join(d,GR);if(!r.refresh&&await MR(p))return Og(p);try{return await rm$1(d,{recursive:!0,force:!0}),await mkdir(d,{recursive:!0}),await Y$(J$(t),g),t.ref&&await X$(g,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(d,m),Og(p)}catch(f){if(await rm$1(d,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await MR(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${f instanceof Error?f.message:String(f)}`),Og(p);throw f}}async function Og(t){return {resolvedPath:t,version:await Z$(t)}}async function MR(t){return j(t)}function J$(t){if("cloneUrl"in t){let e=process.env.AGENTSMESH_GITLAB_TOKEN;if(e){let r=new URL(t.cloneUrl);if(r.protocol==="https:")return r.username="oauth2",r.password=e,r.toString()}return t.cloneUrl}return t.url}async function Y$(t,e){$R(t,"clone-url"),await Lg(["clone",t,e]);}async function X$(t,e){$R(e,"ref"),await Lg(["checkout",e],t);}async function Z$(t){return Lg(["rev-parse","HEAD"],t)}async function Lg(t,e){let{stdout:r}=await V$("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var V$,GR,Ag=u(()=>{T();V$=promisify(execFile),GR="repo";s($R,"ensureNotFlag");s(op,"fetchGitRemoteExtend");s(Og,"readCachedRepo");s(MR,"hasCachedRepo");s(J$,"resolveCloneUrl");s(Y$,"cloneRepo");s(X$,"checkoutRef");s(Z$,"getHeadSha");s(Lg,"runGit");});async function rj(t,e){let r=typeof t.headers?.get=="function"?t.headers.get("content-length"):null;if(r!==null){let m=Number(r);if(Number.isFinite(m)&&m>e)throw new Error(`remote response declared ${m} bytes; exceeds cap of ${e}`)}let o=t.body;if(!o){let m=await t.arrayBuffer();if(m.byteLength>e)throw new Error(`remote response is ${m.byteLength} bytes; exceeds cap of ${e}`);return new Uint8Array(m)}let n=o.getReader(),i=[],a=0;for(;;){let{done:m,value:p}=await n.read();if(m)break;if(p){if(a+=p.byteLength,a>e)throw await n.cancel().catch(()=>{}),new Error(`remote response exceeded cap of ${e} bytes during streaming`);i.push(p);}}let c=new Uint8Array(a),l=0;for(let m of i)c.set(m,l),l+=m.byteLength;return c}async function BR(t,e,r){let o=`https://api.github.com/repos/${t}/${e}/releases/latest`,n={Accept:"application/vnd.github+json"};r&&(n.Authorization=`Bearer ${r}`);let i=await globalThis.fetch(o,{headers:n});if(!i.ok)throw new Error(`Failed to resolve latest release for ${t}/${e}: ${i.status} ${i.statusText}`);let a=await i.json();if(!a.tag_name||typeof a.tag_name!="string")throw new Error(`No tag_name in releases/latest response for ${t}/${e}`);return a.tag_name}async function WR(t,e,r,o,n,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,c=r.refresh===true,l=t.tag;if(l==="latest")try{l=await BR(t.org,t.repo,a);}catch(E){if(!i)throw E;return nj(t,e,r,o,n,a)}let m=n("github",`${t.org}/${t.repo}`,l),p=join(o,m);if(!c&&await j(p)){let E=await kg(p);if(E)return {resolvedPath:join(p,E),version:l}}let d=`https://github.com/${t.org}/${t.repo}/tarball/${l}`,g={};a&&(g.Authorization=`Bearer ${a}`);let f;try{let E=await globalThis.fetch(d,{headers:g,redirect:"follow"});if(!E.ok)throw new Error(`HTTP ${E.status}: ${E.statusText}`);f=await rj(E,ej);}catch(E){if(r.allowOfflineFallback!==false&&await j(p)){let F=await kg(p);if(F)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${E instanceof Error?E.message:String(E)}`),{resolvedPath:join(p,F),version:l}}throw E}await rm$1(p,{recursive:true,force:true}),await mkdir(p,{recursive:true});let h=join(p,"archive.tar.gz");await writeFile(h,f);try{await KR.extract({file:h,cwd:p,strict:!0,filter:s((E,A)=>!(oj(E)||A&&"type"in A&&(A.type==="Link"||A.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let O=await kg(p);if(!O)throw new Error(`Extend "${e}": archive has no top-level directory. Expected a single top-level directory inside the archive.`);return {resolvedPath:join(p,O),version:l}}async function kg(t){let r=(await readdir(t,{withFileTypes:true})).filter(o=>o.isDirectory()&&!o.name.startsWith("."));return r.length===1?r[0].name:null}function UR(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function oj(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function nj(t,e,r,o,n,i){let a=i?[UR(t.org,t.repo,i)]:[UR(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],c;for(let l of a){let m={url:l};try{return await op(m,e,r,o,n)}catch(p){c=p;}}throw c instanceof Error?c:new Error("Failed to clone GitHub default branch")}var ej,HR=u(()=>{T();Ag();ej=500*1024*1024;s(rj,"readBoundedResponse");s(BR,"resolveLatestTag");s(WR,"fetchGithubRemoteExtend");s(kg,"findExtractTopDir");s(UR,"buildGithubCloneUrl");s(oj,"isZipSlipPath");s(nj,"fetchGithubDefaultBranch");});function zR(t,e,r){if(!t.startsWith(e))return null;let o=t.slice(e.length).trim();if(!o)return null;let n=o.lastIndexOf("@");if(n<0)return [o,r];let i=o.slice(0,n).trim(),a=o.slice(n+1).trim();return !i||!a?null:[i,a]}function VR(t){let e=zR(t,"github:","latest");if(!e)return null;let[r,o]=e,n=r.indexOf("/");if(n<0)return null;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();return !i||!a||!o?null:{org:i,repo:a,tag:o}}function JR(t){let e=zR(t,"gitlab:");if(!e)return null;let[r,o]=e,n=r.lastIndexOf("/");if(n<0)return null;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();return !i||!a?null:{namespace:i,project:a,ref:o,cloneUrl:`https://gitlab.com/${i}/${a}.git`}}function YR(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),o=(r<0?e:e.slice(0,r)).trim(),n=r<0?void 0:e.slice(r+1).trim();if(!o||r>=0&&!n)return null;let i;try{i=new URL(o);}catch{return null}return ["https:","http:","ssh:","file:"].includes(i.protocol)?{url:o,ref:n}:null}function ui(t){let e=VR(t);if(e)return {kind:"github",...e};let r=JR(t);if(r)return {kind:"gitlab",...r};let o=YR(t);return o?{kind:"git",...o}:null}function wg(t){return ui(t)!==null}var yl=u(()=>{s(zR,"splitSourceRef");s(VR,"parseGithubSource");s(JR,"parseGitlabSource");s(YR,"parseGitSource");s(ui,"parseRemoteSource");s(wg,"isSupportedRemoteSource");});function cj(t){let e=ui(t);return e?e.kind==="github"?Na("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?Na("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):Na("git",e.url,e.ref??"HEAD"):null}async function QR(t,e){let r=cj(t);if(!r)return;let o=e??Le(),n=join(o,r);await rm$1(n,{recursive:true,force:true});}async function qR(t,e){let r=t??Le(),o=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,n;try{n=await readdir(r);}catch{return}let i=Date.now();await Promise.all(n.map(async a=>{let c=join(r,a);try{let{mtimeMs:l}=await stat(c);i-l>o&&await rm$1(c,{recursive:!0,force:!0});}catch{}}));}var Tg=u(()=>{_l();yl();s(cj,"cacheKeyFromSource");s(QR,"cleanInstallCache");s(qR,"sweepStaleCache");});function Na(t,e,r){let o=s(i=>i.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),n;if(t==="github"){let[i,a]=e.split("/",2);i&&a?n=`${o(i)}--${o(a)}--${o(r)}`:n=`${o(t)}__${o(e)}__${o(r)}`;}else n=`${o(t)}__${o(e)}__${o(r)}`;if(n.length>rS){let i=createHash("sha256").update(n).digest("hex").slice(0,16);n=`${n.slice(0,rS-18)}--${i}`;}return n}function Le(){let t=process.env.AGENTSMESH_CACHE;if(t){let e=t.trim();if(!e)return join(homedir(),".agentsmesh","cache");if(!/^([A-Za-z]:[\\/]|\/)/.test(e))throw new Error(`AGENTSMESH_CACHE must be an absolute path (got: "${e}").`);if(e==="/"||/^[A-Za-z]:[\\/]?$/.test(e))throw new Error(`AGENTSMESH_CACHE must not be the filesystem root (got: "${e}").`);return e}return join(homedir(),".agentsmesh","cache")}async function Fa(t,e,r={}){let o=ui(t);if(!o)throw t.startsWith("github:")?new Error(`Invalid github: source: "${t}" for extend "${e}"`):t.startsWith("gitlab:")?new Error(`Invalid gitlab: source: "${t}" for extend "${e}"`):t.startsWith("git+")?new Error(`Invalid git+ source: "${t}" for extend "${e}"`):new Error(`Invalid remote source: "${t}" for extend "${e}". Use github:org/repo@tag, gitlab:group/project@ref, or git+https://host/org/repo.git#ref.`);let n=r.cacheDir??Le();return qR(n).catch(()=>{}),o.kind==="github"?WR(o,e,r,n,Na,!t.includes("@")):op(o,e,r,n,Na)}var rS,_l=u(()=>{Ag();HR();yl();Tg();rS=80;s(Na,"buildCacheKey");s(Le,"getCacheDir");s(Fa,"fetchRemoteExtend");});function dj(t){return t.startsWith("http://")||t.startsWith("https://")}async function va(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(n=>wg(n.source))){let n=Le();await rm$1(n,{recursive:true,force:true}),await mkdir(n,{recursive:true});}let o=[];for(let n of t.extends){if(dj(n.source))throw new Error(`Remote extends (http/https) not supported: "${n.source}" for extend "${n.name}". Use github:org/repo@tag, gitlab:group/project@ref, git+https://host/org/repo.git#ref, or a local path (e.g. ./shared/).`);if(wg(n.source)){let a=await Fa(n.source,n.name,{cacheDir:Le(),refresh:r.refreshCache===true});o.push({name:n.name,resolvedPath:a.resolvedPath,features:[...n.features],target:n.target,version:a.version,path:n.path,pick:n.pick});continue}let i=resolve(e,n.source);if(!await j(i))throw new Error(`Extend "${n.name}": path does not exist: ${i}. Check extends.source in agentsmesh.yaml.`);o.push({name:n.name,resolvedPath:i,features:[...n.features],target:n.target,path:n.path,pick:n.pick});}return o}var np=u(()=>{T();_l();yl();s(dj,"isOtherRemoteSource");s(va,"resolveExtendPaths");});function w(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let o=t.slice(3,r).trim(),n=t.slice(r+3).trim();return {frontmatter:o===""?{}:parse(o)??{},body:n}}function P(t,e){return Object.keys(t).length===0?e:`---
|
|
12
12
|
${stringify(t,{lineWidth:0}).trimEnd()}
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
${e}`}var M=
|
|
16
|
-
`;)r++;continue}e+=n,r++;}return e}async function
|
|
15
|
+
${e}`}var M=u(()=>{s(w,"parseFrontmatter");s(P,"serializeFrontmatter");});function _j(t){let e=t.replace(/\.[^.]*$/,"").toUpperCase();return hj.has(e)}function oS(t){let e=[],r=t.split(/[\\/]/);for(let o of r)if(!(o===""||o==="."||o==="..")){if(yj.test(o)){e.push({segment:o,reason:"illegal-character"});continue}if(/[. ]$/.test(o)){e.push({segment:o,reason:"trailing-dot-or-space"});continue}_j(o)&&e.push({segment:o,reason:"reserved-name"});}return e}var hj,yj,nS=u(()=>{hj=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]),yj=new RegExp('[<>:"|?*\\u0000-\\u001F]');s(_j,"segmentReservedName");s(oS,"findWindowsPathIssues");});function un(t,e){let r=oS(e);if(r.length===0)return;let o=r.map(n=>`${n.segment} (${n.reason})`).join(", ");throw new sp(t,e,`canonical ${t} name "${e}" is not portable to Windows: ${o}. Rename the file.`)}function ip(t,e,r){let o=new Map;for(let n of e){let i=n.lastIndexOf("/"),a=n.lastIndexOf("\\"),c=Math.max(i,a),l=c===-1?n:n.slice(c+1),m=l.endsWith(r)?l.slice(0,-r.length):l,p=o.get(m);if(p!==void 0&&p!==n)throw new sp(t,m,`canonical ${t} files collide on slug "${m}": ${p} vs ${n}. Rename one.`);o.set(m,n);}}var sp,Il=u(()=>{nS();sp=class extends Error{static{s(this,"CanonicalNameError");}feature;name;constructor(e,r,o){super(o),this.feature=e,this.name=r;}};s(un,"assertCanonicalName");s(ip,"assertNoBasenameCollisions");});function iS(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function di(t){let r=(await N(t)).filter(n=>{if(!n.endsWith(".md"))return false;let i=basename(n,".md");return i==="_root"||!i.startsWith("_")}),o=[];for(let n of r){let i=await y(n);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(n,".md");un("rule",l);let m=l==="_root",p=a.root===true,d=a.trigger,g=typeof d=="string"&&Ij.includes(d)?d:void 0,f=a.codex_emit,h=f==="execution"?"execution":f==="advisory"?"advisory":void 0,R=a.codex_instruction==="override"?"override":void 0;o.push({source:n,root:m||p,targets:iS(a.targets),description:typeof a.description=="string"?a.description:"",globs:iS(a.globs),body:c,...g!==void 0&&{trigger:g},...h!==void 0&&{codexEmit:h},...R!==void 0&&{codexInstructionVariant:R}});}return o}var Ij,ap=u(()=>{T();M();Il();Ij=["always_on","model_decision","glob","manual"];s(iS,"toStrArray");s(di,"parseRules");});function cS(t){return t===true||t==="true"||t===1||t==="1"}function lS(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function gi(t){let r=(await N(t)).filter(n=>n.endsWith(".md")&&!basename(n).startsWith("_"));ip("command",r,".md");let o=[];for(let n of r){let i=await y(n);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(n,".md");un("command",l);let m=lS(a.allowedTools),p=lS(a["allowed-tools"]),d=m.length>0?m:p;o.push({source:n,name:l,description:typeof a.description=="string"?a.description:"",allowedTools:d,outputStyle:cS(a.outputStyle)||cS(a["output-style"]),body:c});}return o}var cp=u(()=>{T();M();Il();s(cS,"toBool");s(lS,"toToolsArray");s(gi,"parseCommands");});function fi(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function pS(t){return t===true||t==="true"||t===1||t==="1"}function uS(t){if(typeof t=="number"&&Number.isInteger(t)&&t>=0)return t;if(typeof t=="string"){let e=parseInt(t,10);return Number.isInteger(e)&&e>=0?e:0}return 0}function Rj(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function hi(t){let r=(await N(t)).filter(n=>n.endsWith(".md")&&!basename(n).startsWith("_"));ip("agent",r,".md");let o=[];for(let n of r){let i=await y(n);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(n,".md");un("agent",l);let m=fi(a.tools),p=fi(a.tools),d=m.length>0?m:p,g=fi(a.disallowedTools),f=fi(a["disallowed-tools"]),h=g.length>0?g:f,O=fi(a.mcpServers),R=fi(a["mcp-servers"]),E=O.length>0?O:R,A=fi(a.skills),F=uS(a.maxTurns),v=uS(a["max-turns"]),G=F>0?F:v>0?v:0;o.push({source:n,name:l,description:typeof a.description=="string"?a.description:"",tools:d,disallowedTools:h,model:typeof a.model=="string"?a.model:"",permissionMode:typeof a.permissionMode=="string"?a.permissionMode:typeof a["permission-mode"]=="string"?a["permission-mode"]:"",maxTurns:G,mcpServers:E,hooks:Rj(a.hooks),skills:A,memory:typeof a.memory=="string"?a.memory:"",outputStyle:pS(a.outputStyle)||pS(a["output-style"]),body:c});}return o}var lp=u(()=>{T();M();Il();s(fi,"toStrArray");s(pS,"toBool");s(uS,"toInt");s(Rj,"toHooks");s(hi,"parseAgents");});async function Ej(t){return await y(t)??""}function Lj(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function dS(t){let e=await N(t),r=[];for(let o of e){let i=o.slice(t.length+1).replace(/\\/g,"/");if(i===mp||i.endsWith(`/${mp}`))continue;let a=i.split("/")[0];if(Oj.some(l=>a===l)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let c=await Ej(o);r.push({relativePath:i,absolutePath:o,content:c});}return r.sort((o,n)=>o.relativePath.localeCompare(n.relativePath))}async function gS(t){let e=join(t,mp),r=await y(e);if(!r)return null;let{frontmatter:o,body:n}=w(r),i=await dS(t),c=(typeof o.name=="string"?Lj(o.name):"")||basename(t);return un("skill",c),{source:e,name:c,description:typeof o.description=="string"?o.description:"",body:n,supportingFiles:i}}async function Ga(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let o of e){if(!o.isDirectory()||o.name.startsWith("_"))continue;un("skill",o.name);let n=join(t,o.name),i=join(n,mp),a=await y(i);if(!a)continue;let{frontmatter:c,body:l}=w(a),m=await dS(n);r.push({source:i,name:o.name,description:typeof c.description=="string"?c.description:"",body:l,supportingFiles:m});}return r.sort((o,n)=>o.name.localeCompare(n.name))}var mp,Oj,pp=u(()=>{T();M();Il();s(Ej,"readContent");mp="SKILL.md",Oj=[".git","node_modules"];s(Lj,"sanitizeSkillName");s(dS,"listSupportingFiles");s(gS,"parseSkillDirectory");s(Ga,"parseSkills");});function fS(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function Aj(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",o=fS(e.env),n=typeof e.description=="string"?e.description:void 0,i=typeof e.url=="string"?e.url:"";if(i)return {...n!==void 0&&{description:n},type:r,url:i,headers:fS(e.headers),env:o};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let c=Array.isArray(e.args)?e.args.filter(l=>typeof l=="string"):[];return {...n!==void 0&&{description:n},type:r,command:a,args:c,env:o}}function kj(t){let e="",r=0,o=t.length;for(;r<o;){let n=t[r];if(n==='"'){for(e+=n,r++;r<o;){let i=t[r];if(e+=i,i==="\\")r++,r<o&&(e+=t[r]);else if(i==='"')break;r++;}r++;continue}if(n==="/"&&t[r+1]==="*"){for(r+=2;r<o;){if(t[r]==="*"&&t[r+1]==="/"){r+=2;break}r++;}continue}if(n==="/"&&t[r+1]==="/"){for(r+=2;r<o&&t[r]!==`
|
|
16
|
+
`;)r++;continue}e+=n,r++;}return e}async function Tr(t){let e=await y(t);if(!e)return null;let r;try{r=JSON.parse(kj(e));}catch{return null}if(!r||typeof r!="object")return null;let o=r.mcpServers;if(o===void 0||typeof o!="object"||o===null)return null;let n={};for(let[i,a]of Object.entries(o)){let c=Aj(a);c&&(n[i]=c);}return {mcpServers:n}}var Rl=u(()=>{T();s(fS,"parseStringMap");s(Aj,"parseServer");s(kj,"stripJsonComments");s(Tr,"parseMcp");});function Pg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function up(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let o=r,n=Pg(o.allow),i=Pg(o.deny),a=Pg(o.ask);return {allow:n,deny:i,ask:a}}var xg=u(()=>{T();s(Pg,"ensureStringArray");s(up,"parsePermissions");});function hS(t){return typeof t=="string"?t.trim():""}function Kt(t){return hS(t.command)}function le(t){return hS(t.prompt)}function Dg(t){let e=Kt(t),r=le(t);return t.type==="prompt"?r||e:e||r}function dn(t){return Kt(t).length>0}function po(t){return Dg(t).length>0}var br=u(()=>{s(hS,"trimString");s(Kt,"getHookCommand");s(le,"getHookPrompt");s(Dg,"getHookText");s(dn,"hasHookCommand");s(po,"hasHookText");});function Pj(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let o=Dg(e);if(!o)return null;let n=typeof e.type=="string"&&bj.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=le(e)||void 0;return {matcher:r,command:o,...i!==void 0&&{timeout:i},...n&&{type:n},...a&&{prompt:a}}}async function dp(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let o={},n=r;for(let[i,a]of Object.entries(n)){if(!Array.isArray(a))continue;let c=[];for(let l of a){let m=Pj(l);m&&c.push(m);}c.length>0&&(o[i]=c);}return o}var bj,Ng=u(()=>{T();br();bj=["command","prompt"];s(Pj,"toHookEntry");s(dp,"parseHooks");});async function gp(t){let e=await y(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),o=[];for(let n of r){let i=n.trim();i===""||i.startsWith("#")||o.push(i);}return o}var Fg=u(()=>{T();s(gp,"parseIgnore");});async function Ae(t){let e=join(t,".agentsmesh"),r=await j(e)?e:t,[o,n,i,a,c,l,m,p]=await Promise.all([di(join(r,"rules")),gi(join(r,"commands")),hi(join(r,"agents")),Ga(join(r,"skills")),Tr(join(r,"mcp.json")),up(join(r,"permissions.yaml")),dp(join(r,"hooks.yaml")),gp(join(r,"ignore"))]);return {rules:o,commands:n,agents:i,skills:a,mcp:c,permissions:l,hooks:m,ignore:p}}var yi=u(()=>{ap();cp();lp();pp();Rl();xg();Ng();Fg();T();s(Ae,"loadCanonicalFiles");});function yS(t){return basename(t.source,".md")}function Ma(t,e){let r=new Map(t.rules.map(p=>[yS(p),p]));for(let p of e.rules)r.set(yS(p),p);let o=new Map(t.commands.map(p=>[p.name,p]));for(let p of e.commands)o.set(p.name,p);let n=new Map(t.agents.map(p=>[p.name,p]));for(let p of e.agents)n.set(p.name,p);let i=new Map(t.skills.map(p=>[p.name,p]));for(let p of e.skills)i.set(p.name,p);let a=Dj(t.mcp,e.mcp),c=Nj(t.permissions,e.permissions),l=Fj(t.hooks,e.hooks),m=vj(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(o.values()),agents:Array.from(n.values()),skills:Array.from(i.values()),mcp:a,permissions:c,hooks:l,ignore:m}}function Dj(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},o=e?.mcpServers??{};return {mcpServers:{...r,...o}}}function Nj(t,e){if(!t&&!e)return null;let r=vg(t?.allow??[],e?.allow??[]),o=vg(t?.deny??[],e?.deny??[]),n=vg(t?.ask??[],e?.ask??[]);return {allow:r,deny:o,ask:n}}function vg(t,e){let r=new Set(t),o=[...t];for(let n of e)r.has(n)||(r.add(n),o.push(n));return o}function Fj(t,e){if(!t&&!e)return null;let r={},o=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let n of o){let i=e?.[n],a=t?.[n];r[n]=i!==void 0&&i.length>0?i:a??[];}return r}function vj(t,e){let r=new Set(t),o=[...t];for(let n of e)r.has(n)||(r.add(n),o.push(n));return o}var Gg=u(()=>{s(yS,"ruleSlug");s(Ma,"mergeCanonicalFiles");s(Dj,"mergeMcp");s(Nj,"mergePermissions");s(vg,"mergeUniqueStrings");s(Fj,"mergeHooks");s(vj,"mergeIgnore");});async function fp(t){let e=null,r=0;for(let o of _S){let n=0;for(let i of o.paths)await j(join(t,i))&&n++;n>r&&(r=n,e=o.target);}return r>0?e:null}var _S,IS,Mg=u(()=>{T();_S=[{target:"claude-code",paths:["CLAUDE.md",".claude/rules",".claude/commands",".claude/agents",".claude/skills",".claude/settings.json",".claudeignore"]},{target:"cursor",paths:[".cursorrules",".cursor/rules",".cursor",".cursor/mcp.json"]},{target:"copilot",paths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]},{target:"gemini-cli",paths:["GEMINI.md",".gemini",".gemini/settings.json"]},{target:"codex-cli",paths:[".codex",".codex/config.toml","AGENTS.md","codex.md"]},{target:"windsurf",paths:[".windsurfrules",".windsurf",".windsurf/workflows"]},{target:"cline",paths:[".clinerules",".cline"]},{target:"continue",paths:[".continue",".continuerc.json"]},{target:"junie",paths:[".junie",".junie/guidelines.md"]},{target:"kiro",paths:[".kiro",".kiro/steering",".kiro/settings/mcp.json"]},{target:"kilo-code",paths:[".kilo",".kilo/rules",".kilo/commands",".kilo/agents",".kilo/skills",".kilocodeignore",".kilocode",".kilocodemodes","kilo.jsonc","kilo.json"]}];s(fp,"detectNativeFormat");IS=_S.map(t=>t.paths[0]).filter(t=>t!==void 0);});function et(t){return t.includes("\\")||Pr.test(t)?win32:posix}function Pt(t){return t.replace(/\\/g,"/")}function V(t,e){let r=et(t),o=r.normalize(r===win32?e.replace(/\//g,"\\"):Pt(e));return o.endsWith(r.sep)&&o.length>1?o.slice(0,-1):o}function SS(t,e){return et(t).isAbsolute(e)||Pr.test(e)}function $a(t){let e=t,r="";for(;$j.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function CS(t,e){let r=et(e),o=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return o&&o!==t?V(e,r.join(e,o)):null}var Pr,$j,ee=u(()=>{Pr=/^[A-Za-z]:[\\/]/,$j=/[.!?:;]+$/;s(et,"pathApi");s(Pt,"normalizeSeparators");s(V,"normalizeForProject");s(SS,"isAbsoluteForProject");s($a,"stripTrailingPunctuation");s(CS,"rootFallbackPath");});function jj(t){return Object.prototype.hasOwnProperty.call(ES,t)}function Uj(t){return Object.prototype.hasOwnProperty.call(OS,t)}function LS(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function ja(t,e,r,o="project"){let n=t.conversions?.commands_to_skills?.[e],i=LS(n,o);return i!==void 0?i:jj(e)?ES[e]:r??false}function Ve(t,e,r,o="project"){let n=t.conversions?.agents_to_skills?.[e],i=LS(n,o);return i!==void 0?i:Uj(e)?OS[e]:r??false}var ES,OS,Ua=u(()=>{ES={amp:true,"codex-cli":true,goose:true,kiro:true,warp:true},OS={amp:true,"gemini-cli":false,cline:true,"codex-cli":false,windsurf:true,goose:true,antigravity:true,continue:true,warp:true};s(jj,"usesCommandSkillProjection");s(Uj,"usesAgentSkillProjection");s(LS,"resolveConversionValue");s(ja,"shouldConvertCommandsToSkills");s(Ve,"shouldConvertAgentsToSkills");});function Dr(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function xr(t){return typeof t=="string"?{level:t}:t}function AS(t){return {rules:xr(t.rules),additionalRules:xr(t.additionalRules),commands:xr(t.commands),agents:xr(t.agents),skills:xr(t.skills),mcp:xr(t.mcp),hooks:xr(t.hooks),ignore:xr(t.ignore),permissions:xr(t.permissions)}}var _i=u(()=>{s(Dr,"cap");s(xr,"normalizeCapabilityValue");s(AS,"normalizeTargetCapabilities");});function kS(t){for(let e of zt)if(e.sharedArtifacts){for(let[r,o]of Object.entries(e.sharedArtifacts))if(o==="owner"&&t.startsWith(r))return e.id}return null}function Kj(t){let e=[];for(let o of t)if(o.sharedArtifacts)for(let[n,i]of Object.entries(o.sharedArtifacts))i==="owner"&&e.push({targetId:o.id,prefix:n});let r=[];for(let o=0;o<e.length;o++)for(let n=o+1;n<e.length;n++){let i=e[o],a=e[n];i===void 0||a===void 0||(i.prefix===a.prefix||i.prefix.startsWith(a.prefix)||a.prefix.startsWith(i.prefix))&&r.push({a:i,b:a});}return r}function wS(t){let e=Kj(t);if(e.length===0)return;let r=e.map(({a:o,b:n})=>` - "${o.targetId}" owns "${o.prefix}" and "${n.targetId}" owns "${n.prefix}"`);throw new Error(`Shared-artifact ownership conflict: two targets claim the same or overlapping prefix.
|
|
17
17
|
`+r.join(`
|
|
18
18
|
`)+`
|
|
19
|
-
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var
|
|
19
|
+
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var $g=u(()=>{xt();s(kS,"ownerTargetIdForSharedPath");s(Kj,"findSharedArtifactOwnershipConflicts");s(wS,"assertSharedArtifactOwnersUnique");});function Bj(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function W(t){return `${Ka}${t}`}function bt(t){let e={name:W(t.name),description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],P(e,t.body.trim()||"")}function hp(t,e){if(t["x-agentsmesh-kind"]!=="command")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",o=e.startsWith(Ka)?e.slice(Ka.length):e.startsWith(Sl)?e.slice(Sl.length):"",n=(r||o).trim();return n?{name:n,description:typeof t.description=="string"?t.description:"",allowedTools:Bj(t["x-agentsmesh-allowed-tools"])}:null}function yp(t,e){return P({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var Ka,Sl,St=u(()=>{M();Ka="am-command-",Sl="ab-command-";s(Bj,"toStringArray");s(W,"commandSkillDirName");s(bt,"serializeCommandSkill");s(hp,"parseCommandSkillFrontmatter");s(yp,"serializeImportedCommand");});function _p(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function Wj(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t))Array.isArray(o)&&(e[r]=o.filter(n=>n!==null&&typeof n=="object"&&typeof n.matcher=="string"&&typeof n.command=="string"));return e}function $(t){return `${Ba}${t}`}function Lt(t){let e={name:$(t.name),description:t.description||void 0,"x-agentsmesh-kind":"agent","x-agentsmesh-name":t.name,"x-agentsmesh-tools":t.tools.length>0?t.tools:void 0,"x-agentsmesh-disallowed-tools":t.disallowedTools.length>0?t.disallowedTools:void 0,"x-agentsmesh-model":t.model||void 0,"x-agentsmesh-permission-mode":t.permissionMode||void 0,"x-agentsmesh-max-turns":t.maxTurns>0?t.maxTurns:void 0,"x-agentsmesh-mcp-servers":t.mcpServers.length>0?t.mcpServers:void 0,"x-agentsmesh-hooks":Object.keys(t.hooks).length>0?t.hooks:void 0,"x-agentsmesh-skills":t.skills.length>0?t.skills:void 0,"x-agentsmesh-memory":t.memory||void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),P(e,t.body.trim()||"")}function Wa(t,e){if(t["x-agentsmesh-kind"]!=="agent")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",o=e.startsWith(Ba)?e.slice(Ba.length):e.startsWith(Cl)?e.slice(Cl.length):"",n=(r||o).trim();return n?{name:n,description:typeof t.description=="string"?t.description:"",tools:_p(t["x-agentsmesh-tools"]),disallowedTools:_p(t["x-agentsmesh-disallowed-tools"]),model:typeof t["x-agentsmesh-model"]=="string"?t["x-agentsmesh-model"]:"",permissionMode:typeof t["x-agentsmesh-permission-mode"]=="string"?t["x-agentsmesh-permission-mode"]:"",maxTurns:typeof t["x-agentsmesh-max-turns"]=="number"?t["x-agentsmesh-max-turns"]:Number(t["x-agentsmesh-max-turns"]??0),mcpServers:_p(t["x-agentsmesh-mcp-servers"]),hooks:Wj(t["x-agentsmesh-hooks"]),skills:_p(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function fs(t,e){let r={name:t.name,description:t.description,tools:t.tools,disallowedTools:t.disallowedTools.length>0?t.disallowedTools:void 0,model:t.model||void 0,permissionMode:t.permissionMode||void 0,maxTurns:t.maxTurns>0?t.maxTurns:void 0,mcpServers:t.mcpServers.length>0?t.mcpServers:void 0,hooks:Object.keys(t.hooks).length>0?t.hooks:void 0,skills:t.skills.length>0?t.skills:void 0,memory:t.memory||void 0};return Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];}),P(r,e.trim()||"")}var Ba,Cl,at=u(()=>{M();Ba="am-agent-",Cl="ab-agent-";s(_p,"toStringArray");s(Wj,"toHooks");s($,"projectedAgentSkillDirName");s(Lt,"serializeProjectedAgentSkill");s(Wa,"parseProjectedAgentSkillFrontmatter");s(fs,"serializeImportedAgent");});function El(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function jg(t,e){return new RegExp(`${El(t)}[\\s\\S]*?${El(e)}`,"g")}function DS(t,e,r,o){let n=jg(e,r);if(n.test(t))return t.replace(n,o).trim();let i=t.trim();return i?`${i}
|
|
20
20
|
|
|
21
|
-
${o}`:o}function
|
|
21
|
+
${o}`:o}function Ug(t,e,r){return t.replace(jg(e,r),"").trim()}function Vj(t){let e=t.replace(/\\/g,"/"),r=e.lastIndexOf(".agentsmesh/");return r>=0?e.slice(r+12):e.startsWith("rules/")?e:join("rules",basename(e)).replace(/\\/g,"/")}function Jj(t){return {source:Vj(t.source),description:t.description,globs:t.globs,targets:t.targets}}function Yj(t){return `${PS}${JSON.stringify(Jj(t))}${xS}`}function Xj(t){let e=[Yj(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),bS),e.filter(r=>r.length>0).join(`
|
|
22
22
|
`)}function Zj(t){return t.length===0?"":[Ip,...t.map(Xj),Rp].join(`
|
|
23
|
-
`)}function
|
|
23
|
+
`)}function st(t,e){let r=Zj(e),o=Ug(t,Ip,Rp);return r?o?`${o}
|
|
24
24
|
|
|
25
|
-
${r}`:r:o}function
|
|
25
|
+
${r}`:r:o}function TS(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function Qj(t){try{let e=JSON.parse(t);if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e;return typeof r.source!="string"||!r.source.startsWith("rules/")?null:{source:r.source,description:typeof r.description=="string"?r.description:"",globs:TS(r.globs),targets:TS(r.targets)}}catch{return null}}function qj(t,e){let r=t.trim();if(!e.trim())return r;let o=`## ${e.trim()}`;return r.startsWith(o)?r.slice(o.length).trim():r}function NS(t){let e=[],r=jg(Ip,Rp);return {rootContent:t.replace(r,n=>{let i=n.replace(Ip,"").replace(Rp,"").trim(),a=new RegExp(`${El(PS)}([\\s\\S]*?)${El(xS)}([\\s\\S]*?)${El(bS)}`,"g");for(let c of i.matchAll(a)){let l=c[1],m=c[2];if(l===void 0||m===void 0)continue;let p=Qj(l);p&&e.push({...p,body:qj(m,p.description)});}return ""}).trim(),rules:e}}var Ol,Ll,Ip,Rp,bS,PS,xS,Mt=u(()=>{Ol="<!-- agentsmesh:root-generation-contract:start -->",Ll="<!-- agentsmesh:root-generation-contract:end -->",Ip="<!-- agentsmesh:embedded-rules:start -->",Rp="<!-- agentsmesh:embedded-rules:end -->",bS="<!-- agentsmesh:embedded-rule:end -->",PS="<!-- agentsmesh:embedded-rule:start ",xS=" -->";s(El,"escapeRegExp");s(jg,"managedBlockPattern");s(DS,"replaceManagedBlock");s(Ug,"stripManagedBlock");s(Vj,"ruleSource");s(Jj,"markerForRule");s(Yj,"embeddedRuleStart");s(Xj,"renderRule");s(Zj,"renderEmbeddedRulesBlock");s(st,"appendEmbeddedRulesBlock");s(TS,"toStringArray");s(Qj,"parseMarker");s(qj,"stripGeneratedHeading");s(NS,"extractEmbeddedRules");});function Kg(t){return t.replace(/\s+/g," ").trim()}function vS(t){let e=t.trim();if(e.includes(Ol)&&e.includes(Ll))return DS(e,Ol,Ll,Ha);let r=Kg(e);if(r.includes(Kg(Ha)))return e;for(let o of FS)if(r.includes(Kg(o)))return e.replace(o,Ha);return e?`${e}
|
|
26
26
|
|
|
27
|
-
${
|
|
27
|
+
${Ha}`:Ha}function GS(t){let e=Ug(t,Ol,Ll);e=e.replace(`
|
|
28
28
|
|
|
29
|
-
${
|
|
29
|
+
${Ha}`,"");for(let r of FS)e=e.replace(`
|
|
30
30
|
|
|
31
|
-
${r}`,"");return e.trim()}var
|
|
31
|
+
${r}`,"");return e.trim()}var Bg,tU,eU,rU,oU,nU,sU,iU,aU,cU,lU,mU,pU,uU,dU,gU,fU,Ha,FS,Wg=u(()=>{Mt();Bg="AgentsMesh is a config sync library for AI coding tools. The only canonical source of truth is `.agentsmesh/`; files emitted into target formats such as `AGENTS.md`, `.claude/`, `.cursor/`, `.junie/`, and similar directories are generated artifacts. When making changes, edit canonical config first, then regenerate and verify the target outputs. Preserve the library's bidirectional contract: import native tool config into canonical form, generate back to target-specific layouts, and keep projected or embedded features round-trippable rather than treating them as plain text exports.",tU="AgentsMesh is a config sync library for AI coding tools. The only canonical source of truth is the `.agentsmesh` directory at the project root; files emitted into target formats such as `AGENTS.md`, `.claude/`, `.cursor/`, `.junie/`, and similar directories are generated artifacts. When making changes, edit canonical config first, then regenerate and verify the target outputs. Preserve the library's bidirectional contract: import native tool config into canonical form, generate back to target-specific layouts, and keep projected or embedded features round-trippable rather than treating them as plain text exports.",eU="AgentsMesh syncs AI coding tool configuration from a single canonical `.agentsmesh` directory. All target-specific files (`.claude/`, `.cursor/`, `AGENTS.md`, etc.) are generated artifacts \u2014 edit canonical config first, then regenerate. The import/generate contract is bidirectional and lossless: embedded or projected features round-trip without data loss.",rU="Create agents, skills, commands, rules, hooks, and MCP in `.agentsmesh`, then run `agentsmesh generate` to sync each tool's native files. Edit `.agentsmesh`, not generated outputs.",oU="Use Claude-style Markdown in `.agentsmesh`: `agents/*.md`, `commands/*.md`, and `skills/*/SKILL.md`; keep rules in `rules/*.md`, hooks in `hooks.yaml`, MCP in `mcp.json`, permissions in `permissions.yaml`, and ignore patterns in `ignore`, then run `agentsmesh generate`.",nU="Create canonical files in `.agentsmesh`: `rules/_root.md` and `rules/*.md` are Markdown rules; `commands/*.md`, `agents/*.md`, and `skills/*/SKILL.md` plus supporting files use Claude-style frontmatter Markdown; `mcp.json` is MCP JSON; `hooks.yaml` and `permissions.yaml` are YAML; `ignore` is gitignore-style text. Then run `agentsmesh generate`.",sU="`.agentsmesh` is the only folder you edit or add these files in: `rules/_root.md` and `rules/*.md` are Markdown rules; `commands/*.md`, `agents/*.md`, and `skills/*/SKILL.md` plus supporting files use Claude-style frontmatter Markdown; `mcp.json` is MCP JSON; `hooks.yaml` and `permissions.yaml` are YAML; `ignore` is gitignore-style text. Do not edit generated tool files; run `agentsmesh generate`.",iU="`agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, and `merge` as needed; never edit generated tool files.",aU=Bg,cU=`## Project-Specific Rules
|
|
32
32
|
|
|
33
|
-
${
|
|
33
|
+
${Bg}`,lU=`## AgentsMesh Generation Contract
|
|
34
34
|
|
|
35
|
-
${
|
|
35
|
+
${Bg}`,mU=`## AgentsMesh Generation Contract
|
|
36
36
|
|
|
37
37
|
${tU}`,pU=`## AgentsMesh Generation Contract
|
|
38
38
|
|
|
@@ -44,142 +44,142 @@ ${oU}`,gU=`## AgentsMesh Generation Contract
|
|
|
44
44
|
|
|
45
45
|
${nU}`,fU=`## AgentsMesh Generation Contract
|
|
46
46
|
|
|
47
|
-
${sU}`,
|
|
47
|
+
${sU}`,Ha=`${Ol}
|
|
48
48
|
## AgentsMesh Generation Contract
|
|
49
49
|
|
|
50
50
|
${iU}
|
|
51
|
-
${
|
|
52
|
-
`)}]}var rC=d(()=>{Q();Mt();st();St();Xa();s(ZS,"generateRules");s(QS,"generateSkills");s(qS,"generateCommands");s(tC,"generateAgents");s(eC,"generateIgnore");});async function $t(t,e,r){let o=join(t,e),i={...await LU(o),...r};await L(dirname(o)),await _(o,JSON.stringify({mcpServers:i},null,2));}async function LU(t){let e=await y(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let o=r.mcpServers;if(!o||typeof o!="object"||Array.isArray(o))return {};let n={};for(let[i,a]of Object.entries(o))!a||typeof a!="object"||Array.isArray(a)||(n[i]=a);return n}var Fr=d(()=>{T();s($t,"writeMcpWithMerge");s(LU,"readExistingServers");});function Rn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function qe(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function _s(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function _o(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var tr=d(()=>{s(Rn,"toGlobsArray");s(qe,"toToolsArray");s(_s,"toStringArray");s(_o,"toStringRecord");});function wU(t,e){return e.some(r=>t.endsWith(r))}async function yt(t){let r=(await v(t.srcDir)).filter(n=>wU(n,t.extensions)),o=[];for(let n of r){let i=await y(n);if(!i)continue;let a=relative(t.srcDir,n).replace(/\\/g,"/"),c=await t.mapEntry({srcPath:n,relativePath:a,content:i,normalizeTo:s((l,m=i)=>t.normalize(m,n,l),"normalizeTo")});c&&(await L(dirname(c.destPath)),await _(c.destPath,c.content),o.push({fromTool:t.fromTool,fromPath:n,toPath:c.toPath,feature:c.feature}));}return o}var ke=d(()=>{T();s(wU,"matchesExtension");s(yt,"importFileDirectory");});function oC(t){return typeof t=="string"?t:void 0}function TU(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function Xg(t,e){return e?e(t):t}function bU(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=k(e.normalizeTo(r)),i=Xg(o,t.frontmatterRemap),a=TU({root:false,description:oC(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await K(r,a,n)}}}function PU(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=k(e.normalizeTo(r)),i=Xg(o,t.frontmatterRemap),a=await ht(r,{hasDescription:true,description:oC(i.description),hasAllowedTools:true,allowedTools:_s(i["allowed-tools"])},n);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function xU(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=k(e.normalizeTo(r)),i=Xg(o,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Bt(r,i,n)}}}function nC(t){if(t.map)return t.map;switch(t.preset){case "rule":return bU(t);case "command":return PU(t);case "agent":return xU(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var sC=d(()=>{M();lt();tr();s(oC,"pickString");s(TU,"pruneUndefined");s(Xg,"applyRemap");s(bU,"ruleMapper");s(PU,"commandMapper");s(xU,"agentMapper");s(nC,"resolveMapper");});function Zg(t,e){return t?t[e]??[]:[]}var iC,aC=d(()=>{iC=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(Zg,"resolveScopedSources");});async function FU(t,e,r,o,n){if(!t.canonicalRootFilename)throw new Error(`singleFile spec for ${t.feature} must set canonicalRootFilename`);let i=join(r,t.canonicalDir);for(let a of e){let c=join(r,a),l=await y(c);if(l===null)continue;await L(i);let m=join(i,t.canonicalRootFilename),p=s(R=>n(l,c,R),"normalizeTo");if(t.map){let R=await t.map({absolutePath:c,relativePath:a,content:l,destDir:i,normalizeTo:p});if(!R)continue;return await _(R.destPath,R.content),[{fromTool:o,fromPath:c,toPath:R.toPath,feature:t.feature}]}let{frontmatter:u,body:g}=k(p(m)),f=t.frontmatterRemap?t.frontmatterRemap(u):u,h=t.markAsRoot?{...f,root:true}:f,O=await K(m,h,g);return await _(m,O),[{fromTool:o,fromPath:c,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function vU(t,e,r,o,n){let i=nC(t),a=join(r,t.canonicalDir),c=[];for(let l of e){let m=join(r,l),p=await yt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:o,normalize:n,mapEntry:s(async({srcPath:u,relativePath:g,content:f,normalizeTo:h})=>{let O=await i({absolutePath:u,relativePath:g,content:f,destDir:a,normalizeTo:s(R=>h(R),"normalizeTo")});return O?{destPath:O.destPath,toPath:O.toPath,feature:t.feature,content:O.content}:null},"mapEntry")});c.push(...p);}return c}function lC(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function GU(t,e,r,o){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let n=lC(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=join(r,n);return await L(dirname(l)),await _(l,c.trimEnd()),[{fromTool:o,fromPath:a,toPath:n,feature:t.feature}]}return []}function MU(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object")return {};let r=e.mcpServers;if(!r||typeof r!="object"||Array.isArray(r))return {};let o={};for(let[n,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){o[n]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:_s(a.args),env:_o(a.env),description:c};continue}typeof a.url=="string"&&(o[n]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:_o(a.headers),env:_o(a.env),description:c});}return o}async function $U(t,e,r,o){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let n=lC(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=MU(c);return Object.keys(l).length===0?[]:(await $t(r,n,l),[{fromTool:o,fromPath:a,toPath:n,feature:t.feature}])}return []}function cC(t,e,r,o,n){switch(t.mode){case "singleFile":return FU(t,e,r,o,n);case "directory":return vU(t,e,r,o,n);case "flatFile":return GU(t,e,r,o);case "mcpJson":return $U(t,e,r,o)}}async function jU(t,e,r,o,n){let i=Zg(t.source,e),a=Zg(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let c=await cC(t,i,r,o,n);if(c.length>0)return c}return a.length>0?cC(t,a,r,o,n):[]}function UU(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function z(t,e,r,o){let n=t.importer;if(!n)return [];let i=o?.normalize??await U(t.id,e,r),a=[];for(let c of iC)for(let l of UU(n,c))a.push(...await jU(l,r,e,t.id,i));return a}var Ct=d(()=>{mt();T();Fr();M();tr();lt();ke();sC();aC();s(FU,"runSingleFile");s(vU,"runDirectory");s(lC,"resolveCanonicalFilePath");s(GU,"runFlatFile");s(MU,"parseMcpJson");s($U,"runMcpJson");s(cC,"dispatchSpec");s(jU,"runSpec");s(UU,"specsForFeature");s(z,"runDescriptorImport");});async function mC(t,e={}){let r=e.scope??"project",o=[],n=await U(yo,t,r);return o.push(...await z(Cp,t,r,{normalize:n})),await Z(t,r==="global"?Qe:oe,yo,o,n),o}var pC=d(()=>{mt();Q();Ct();Xa();Qg();s(mC,"importFromAider");});function KU(t,e){return dC(e).some(o=>BU(t,o))}function uC(t,e){return t.filter(r=>KU(r,e))}function dC(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,o,n]=e;if(!o)return [t];let i=o.split(",").map(c=>c.trim()),a=[];for(let c of i)for(let l of dC(r+c+n))a.push(l);return a}function BU(t,e){return WU(e).test(t)}function WU(t){let e=[],r=0;for(;r<t.length;){if(t.startsWith("**",r)){let i=t.slice(r+2);if(i.length===0&&e.length===0)e.push(".*");else if(e.push(i.startsWith("/")?"(?:[^/]+/)*":"(?:/[^/]+)*?"),i.startsWith("/")){r+=3;continue}r+=2;continue}if(t[r]==="*"){e.push("[^/]*"),r+=1;continue}if(t[r]==="?"){e.push("[^/]"),r+=1;continue}if(t[r]==="{"){e.push("(?:"),r+=1;continue}if(t[r]==="}"){e.push(")"),r+=1;continue}if(t[r]===","){e.push("|"),r+=1;continue}".^$+?()[]{}|\\".includes(t[r])?e.push("\\"+t[r]):e.push(t[r]),r+=1;}let o="^"+e.join("")+"$";return new RegExp(o)}var gC=d(()=>{s(KU,"globMatch");s(uC,"globFilter");s(dC,"expandBraces");s(BU,"matchOne");s(WU,"globToRegex");});function H(t,e,r,o={}){let n=[],{rules:i}=t;if(i.length===0)return [];if(i.some(c=>c.root)||n.push({level:"error",file:relative(e,i[0].source),message:"Rules exist but no root rule (_root.md or root: true). Add a root rule."}),o.checkGlobMatches===false)return n;for(let c of i){if(c.globs.length===0)continue;let l=false;for(let m of c.globs)if(uC(r,m).length>0){l=true;break}l||n.push({level:"warning",file:relative(e,c.source),message:`globs "${c.globs.join(", ")}" match 0 files in project`});}return n}var _t=d(()=>{gC();s(H,"validateRules");});function hC(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:yo}))}var yC=d(()=>{_t();Xa();s(hC,"lintRules");});function b(t,e,r){return {level:"warning",file:t,target:e,message:r}}function HU(t){return t.length===0?"":t.length===1?t[0]:t.length===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[t.length-1]}`}function Rs(t,e,r,o){let n=o?.unsupportedBy??e,i=HU(r);return b(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${n}; only ${i} are projected.`)}var Et=d(()=>{s(b,"createWarning");s(HU,"formatOxfordComma");s(Rs,"createUnsupportedHookWarning");});function _C(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function IC(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function RC(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var SC=d(()=>{Et();s(_C,"lintHooks");s(IC,"lintPermissions");s(RC,"lintMcp");});function C(t,e){return et(t).relative(t,e).replace(/\\/g,"/")}async function E(t,e){return v(et(t).join(t,e)).catch(()=>[])}function EC(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function ZU(t,e,r,o){let n=posix.dirname(e),i=posix.dirname(r);for(;n!==o&&n!==".";)EC(t,n,i),n=posix.dirname(n),i=posix.dirname(i);}function x(t,e,r,o){t.set(e,`${r}/${basename(e,o)}.md`);}function F(t,e,r){if(!e.startsWith(`${r}/`))return;let o=e.slice(r.length+1);if(!o)return;if(!o.includes("/")){if(!o.endsWith(".md")||basename(o)==="SKILL.md")return;let u=basename(o,".md");t.set(e,`${CC}/${u}/SKILL.md`);return}let[n,...i]=o.split("/"),a=i.join("/");if(!n||!a)return;let c=n.startsWith(Ha)?Ha:n.startsWith(El)?El:null;if(c&&a==="SKILL.md"){t.set(e,`${YU}/${n.slice(c.length)}.md`);return}let l=n.startsWith(za)?za:n.startsWith(Ol)?Ol:null;if(l&&a==="SKILL.md"){t.set(e,`${XU}/${n.slice(l.length)}.md`);return}let m=`${CC}/${n}`;a==="SKILL.md"&&EC(t,`${r}/${n}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&ZU(t,e,p,`${r}/${n}`);}function QU(t){return t.split("/").filter(Boolean)[0]??""}async function qU(){if(qg!==void 0)return qg;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(xt(),OC)),e=new Set;for(let r of t)for(let o of [r.project.rootInstructionPath,r.project.skillDir,...r.project.managedOutputs?.dirs??[],...r.project.managedOutputs?.files??[],...r.detectionPaths,r.globalSupport?.layout.rootInstructionPath,r.globalSupport?.layout.skillDir,...r.globalSupport?.layout.managedOutputs?.dirs??[],...r.globalSupport?.layout.managedOutputs?.files??[],...r.globalSupport?.detectionPaths??[]])if(o!==void 0){let n=QU(o);n.startsWith(".")&&e.add(n);}return qg=e,e}function ef(t){return t.split("/").some(e=>e.startsWith("."))}async function t0(t){let e=[],r=await qU(),o=et(t);async function n(i){let a=o.join(t,i),c=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let l of c){let m=i?`${i}/${l.name}`:l.name;if(l.isDirectory()){if(r.has(l.name)||ef(m))continue;await n(m);continue}if(l.isSymbolicLink()&&await stat(o.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(l.name)||ef(m))continue;await n(m);continue}(l.name==="AGENTS.md"||l.name==="AGENTS.override.md")&&e.push(o.join(t,m));}}return s(n,"walk"),await n(""),e}async function Ep(t,e){let r=await t0(e);for(let o of r){let n=C(e,o),i=n.endsWith("/AGENTS.md")&&n!=="AGENTS.md"&&!n.endsWith("/AGENTS.override.md"),a=n.endsWith("/AGENTS.override.md")&&n!=="AGENTS.override.md";if(!i&&!a)continue;let c=posix.dirname(n);if(ef(c))continue;let l=c.replace(/\//g,"-");t.set(n,`${JU}/${l}.md`);}}var JU,YU,XU,CC,qg,It=d(()=>{re();T();St();st();JU=".agentsmesh/rules",YU=".agentsmesh/commands",XU=".agentsmesh/agents",CC=".agentsmesh/skills";s(C,"rel");s(E,"listFiles");s(EC,"addDirectoryMapping");s(ZU,"addAncestorMappings");s(x,"addSimpleFileMapping");s(F,"addSkillLikeMapping");s(QU,"firstPathSegment");s(qU,"targetRootSegments");s(ef,"hasHiddenSegment");s(t0,"listScopedAgentsFiles");s(Ep,"addScopedAgentsMappings");});var w,rt,Ot,gt=d(()=>{w=".agentsmesh/rules",rt=".agentsmesh/commands",Ot=".agentsmesh/agents";});async function rf(t,e,r="project"){if(r==="global"){t.set(In,`${w}/_root.md`);for(let o of await E(e,Qe))F(t,C(e,o),Qe);t.set(Ci,".agentsmesh/ignore");return}t.set(Ze,`${w}/_root.md`);for(let o of await E(e,oe))F(t,C(e,o),oe);t.set(_n,".agentsmesh/ignore");}var LC=d(()=>{It();Xa();gt();s(rf,"buildAiderImportPaths");});var Ei,vr,Oi,Ss,bl,AC,kC,Pl=d(()=>{Ei="amazon-q",vr=".amazonq/rules",Oi=".amazonq/mcp.json",Ss=".aws/amazonq/rules",bl=".aws/amazonq/mcp.json",AC=".agentsmesh/rules",kC=".agentsmesh/mcp.json";});async function of(t,e,r="project"){let o=r==="global"?Ss:vr;for(let n of await E(e,o)){let i=C(e,n);x(t,i,w,".md");}}var wC=d(()=>{It();Pl();gt();s(of,"buildAmazonQImportPaths");});var er,ne,Io,nf,Sn,rr,Cn,TC,Li=d(()=>{er="AGENTS.md",ne=".agents/skills",Io=".amp/settings.json",nf=".config/amp",Sn=`${nf}/AGENTS.md`,rr=`${nf}/skills`,Cn=`${nf}/settings.json`,TC=".agentsmesh/rules";});async function sf(t,e,r="project"){if(r==="global"){t.set(Sn,`${w}/_root.md`);for(let o of await E(e,rr))F(t,C(e,o),rr);t.set(Cn,".agentsmesh/mcp.json");return}t.set(er,`${w}/_root.md`);for(let o of await E(e,ne))F(t,C(e,o),ne);t.set(Io,".agentsmesh/mcp.json");}var bC=d(()=>{It();Li();gt();s(sf,"buildAmpImportPaths");});var Ai,Op,Ro,Gr,xl,Mr,En,Dl,So,On,Nl,Za,af,ki,Lp,PC,wi=d(()=>{Ai="antigravity",Op=".agents",Ro=`${Op}/rules`,Gr=`${Ro}/general.md`,xl=`${Ro}/_root.md`,Mr=`${Op}/skills`,En=`${Op}/workflows`,Dl=`${Op}/antigravity/mcp_config.json`,So=".gemini/antigravity/GEMINI.md",On=".gemini/antigravity/skills",Nl=".gemini/antigravity/workflows",Za=".gemini/antigravity/mcp_config.json",af=".agentsmesh/rules/_root.md",ki=".agentsmesh/rules",Lp=".agentsmesh/commands",PC=".agentsmesh/mcp.json";});async function cf(t,e,r="project"){if(r==="global"){t.set(So,`${w}/_root.md`);for(let o of await E(e,On))F(t,C(e,o),On);t.set(Za,".agentsmesh/mcp.json");return}t.set(Gr,`${w}/_root.md`),t.set(xl,`${w}/_root.md`);for(let o of await E(e,Ro)){let n=C(e,o);n===Gr||n===xl||x(t,n,w,".md");}for(let o of await E(e,En))x(t,C(e,o),rt,".md");for(let o of await E(e,Mr))F(t,C(e,o),Mr);}var xC=d(()=>{It();wi();gt();s(cf,"buildAntigravityImportPaths");});var se,Ap,we,or,Te,Co,Eo,kp,Ln,An,Oo,kn,lf,mf,pf,uf,Ti=d(()=>{se="augment-code",Ap=".augment",we=`${Ap}/rules`,or=`${Ap}/commands`,Te=`${Ap}/skills`,Co=`${Ap}/settings.json`,Eo=".augmentignore",kp=".augment",Ln=`${kp}/rules`,An=`${kp}/commands`,Oo=`${kp}/skills`,kn=`${kp}/settings.json`,lf=".agentsmesh/rules",mf=".agentsmesh/mcp.json",pf=".agentsmesh/hooks.yaml",uf=".agentsmesh/ignore";});async function df(t,e,r="project"){if(r==="global"){for(let o of await E(e,Ln))x(t,C(e,o),w,".md");for(let o of await E(e,An))x(t,C(e,o),rt,".md");for(let o of await E(e,Oo))F(t,C(e,o),Oo);t.set(kn,".agentsmesh/mcp.json");return}for(let o of await E(e,we))x(t,C(e,o),w,".md");for(let o of await E(e,or))x(t,C(e,o),rt,".md");for(let o of await E(e,Te))F(t,C(e,o),Te);t.set(Co,".agentsmesh/mcp.json"),t.set(Eo,".agentsmesh/ignore");}var DC=d(()=>{It();Ti();gt();s(df,"buildAugmentCodeImportPaths");});var NC,Cs,FC,Fl,vl,Gl,Ml,$l,wn,gf,jl,Qa,Ul,Kl,wp,Tp,ff,Bl,hf,bi,vC,Tn=d(()=>{NC="claude-code",Cs=".claude/CLAUDE.md",FC="CLAUDE.md",Fl=".claude/rules",vl=".claude/commands",Gl=".claude/agents",Ml=".claude/skills",$l=".claude/settings.json",wn=".claude/hooks.json",gf=".claude/output-styles",jl=".claudeignore",Qa=".mcp.json",Ul=".claude.json",Kl=".agentsmesh/rules",wp=".agentsmesh/commands",Tp=".agentsmesh/agents",ff=".agentsmesh/skills",Bl=".agentsmesh/mcp.json",hf=".agentsmesh/permissions.yaml",bi=".agentsmesh/hooks.yaml",vC=".agentsmesh/ignore";});async function yf(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${w}/_root.md`),t.set(wn,bi),r==="project"&&t.set("CLAUDE.md",`${w}/_root.md`),r==="global")for(let o of await E(e,".agents/skills"))F(t,C(e,o),".agents/skills");for(let o of await E(e,".claude/rules"))x(t,C(e,o),w,".md");for(let o of await E(e,".claude/commands"))x(t,C(e,o),rt,".md");for(let o of await E(e,".claude/agents"))x(t,C(e,o),Ot,".md");for(let o of await E(e,".claude/skills"))F(t,C(e,o),".claude/skills");}var GC=d(()=>{It();Tn();gt();s(yf,"buildClaudeCodeImportPaths");});var Es,bn,Pi,Pn,MC,Jt,Lo,Os,xi,Di,Ni,Fi,_f,Ls,bp,If,Rf,Sf,$C,nr=d(()=>{Es="cline",bn=".clinerules",Pi=".clineignore",Pn=".cline/cline_mcp_settings.json",MC=".cline/mcp_settings.json",Jt=".cline/skills",Lo=".clinerules/workflows",Os="AGENTS.md",xi=".clinerules/hooks",Di="Documents/Cline/Rules",Ni="Documents/Cline/Workflows",Fi="Documents/Cline/Hooks",_f=".agentsmesh/hooks.yaml",Ls=".agentsmesh/rules",bp=".agentsmesh/commands",If=".agentsmesh/ignore",Rf=".agentsmesh/mcp.json",Sf=".agentsmesh/agents",$C=".agentsmesh/skills";});async function Cf(t,e,r="project"){if(r==="global"){for(let o of await E(e,Di))x(t,C(e,o),w,".md");for(let o of await E(e,Ni))x(t,C(e,o),rt,".md");for(let o of await E(e,Jt))F(t,C(e,o),Jt);t.set(Pn,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${w}/_root.md`);for(let o of await E(e,".clinerules")){let n=C(e,o);!n.endsWith(".md")||n.includes("/workflows/")||basename(n)==="_root.md"||x(t,n,w,".md");}for(let o of await E(e,".clinerules/workflows"))x(t,C(e,o),rt,".md");for(let o of await E(e,".cline/skills"))F(t,C(e,o),".cline/skills");}var jC=d(()=>{It();nr();gt();s(Cf,"buildClineImportPaths");});async function Ef(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${w}/_root.md`),t.set(".codex/AGENTS.override.md",`${w}/_root.md`)):(t.set("AGENTS.md",`${w}/_root.md`),t.set("codex.md",`${w}/_root.md`),await Ep(t,e)),r==="project")for(let o of await E(e,".codex/instructions"))x(t,C(e,o),w,".md");for(let o of await E(e,".codex/rules")){let n=C(e,o);n.endsWith(".rules")?x(t,n,w,".rules"):n.endsWith(".md")&&x(t,n,w,".md");}for(let o of await E(e,".codex/agents"))x(t,C(e,o),Ot,".toml");for(let o of await E(e,".agents/skills"))F(t,C(e,o),".agents/skills");}var UC=d(()=>{It();gt();s(Ef,"buildCodexCliImportPaths");});var qa,$r,Ao,Of,Pp,xn,Lf,be,tc,Wl,xp,Dp,Af,ko=d(()=>{qa="continue",$r=".continue/rules",Ao=".continue/prompts",Of=".continue/mcpServers",Pp=`${Of}/agentsmesh.json`,xn=`${$r}/general.md`,Lf=`${$r}/_root.md`,be=".continue/skills",tc=".continue/AGENTS.md",Wl=".continue/config.yaml",xp=".agentsmesh/rules",Dp=".agentsmesh/commands",Af=".agentsmesh/mcp.json";});async function kf(t,e,r="project"){t.set(xn,`${w}/_root.md`),t.set(Lf,`${w}/_root.md`);for(let o of await E(e,".continue/rules")){let n=C(e,o);n===xn||n===Lf||x(t,n,w,".md");}for(let o of await E(e,".continue/prompts"))t.set(C(e,o),`${rt}/${basename(o,".md")}.md`);for(let o of await E(e,".continue/skills"))F(t,C(e,o),".continue/skills");if(r==="global")for(let o of await E(e,".agents/skills"))F(t,C(e,o),".agents/skills");}var KC=d(()=>{It();ko();gt();s(kf,"buildContinueImportPaths");});function o0(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${w}/${basename(e,".instructions.md")}.md`);return}x(t,e,w,".md");}async function wf(t,e){t.set(".github/copilot-instructions.md",`${w}/_root.md`);for(let r of await E(e,".github/copilot"))t.set(C(e,r),`${w}/${basename(r,".instructions.md")}.md`);for(let r of await E(e,".github/instructions"))o0(t,C(e,r));for(let r of await E(e,".github/prompts"))t.set(C(e,r),`${rt}/${basename(r,".prompt.md")}.md`);for(let r of await E(e,".github/agents"))t.set(C(e,r),`${Ot}/${basename(r,".agent.md")}.md`);for(let r of await E(e,".github/skills"))F(t,C(e,r),".github/skills");}var BC=d(()=>{It();gt();s(o0,"addCopilotInstructionMapping");s(wf,"buildCopilotImportPaths");});var sr,ir,Yt,Pe,Dn,WC,Fp,xe,vi,vp,Gp,Mp,ec=d(()=>{sr="crush",ir="CRUSH.md",Yt=".crush/skills",Pe="crush.json",Dn=".crushignore",WC=".config/crush",Fp=`${WC}/crush.json`,xe=".config/crush/skills",vi=`${WC}/CRUSH.md`,vp=".agentsmesh/rules",Gp=".agentsmesh/ignore",Mp=".agentsmesh/mcp.json";});async function Tf(t,e,r="project"){if(r==="global"){for(let o of await E(e,xe))F(t,C(e,o),xe);return}t.set(ir,`${vp}/_root.md`),t.set(Pe,Mp),t.set(Dn,Gp);for(let o of await E(e,Yt))F(t,C(e,o),Yt);}var HC=d(()=>{It();ec();s(Tf,"buildCrushImportPaths");});var zC,As,VC,ar,Nn,cr,rc,wo,To,bo,$p,jr,bf,n0,oc,Ur,Hl,ks,ws,Po,Ts,bs,JC,nc,Pf,zl,xf,jt=d(()=>{zC="cursor",As="AGENTS.md",VC=".cursorrules",ar=".cursor/rules",Nn=`${ar}/general.mdc`,cr=".cursor/commands",rc=".cursor/agents",wo=".cursor/skills",To=".cursor/mcp.json",bo=".cursor/hooks.json",$p=".cursor/settings.json",jr=".cursorignore",bf=".cursorindexingignore",n0=".agentsmesh-exports/cursor",oc=`${n0}/user-rules.md`,Ur=".cursor/AGENTS.md",Hl=To,ks=wo,ws=rc,Po=".agentsmesh/rules",Ts=".agentsmesh/commands",bs=".agentsmesh/agents",JC=".agentsmesh/skills",nc=".agentsmesh/mcp.json",Pf=".agentsmesh/permissions.yaml",zl=".agentsmesh/hooks.yaml",xf=".agentsmesh/ignore";});async function Df(t,e,r="project"){if(r==="global"){t.set(To,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${w}/_root.md`);for(let o of await E(e,".cursor/rules"))x(t,C(e,o),w,".mdc");for(let o of await E(e,".cursor/commands"))x(t,C(e,o),rt,".md");for(let o of await E(e,".cursor/agents"))x(t,C(e,o),Ot,".md");for(let o of await E(e,".cursor/skills"))F(t,C(e,o),".cursor/skills");return}t.set("AGENTS.md",`${w}/_root.md`);for(let o of await E(e,".cursor/rules"))x(t,C(e,o),w,".mdc");for(let o of await E(e,".cursor/commands"))x(t,C(e,o),rt,".md");for(let o of await E(e,".cursor/agents"))x(t,C(e,o),Ot,".md");for(let o of await E(e,".cursor/skills"))F(t,C(e,o),".cursor/skills");}var YC=d(()=>{It();jt();gt();s(Df,"buildCursorImportPaths");});var xo,lr,ie,Fn,vn,Kr,Gi,XC,sc=d(()=>{xo="deepagents-cli",lr=".deepagents/AGENTS.md",ie=".deepagents/skills",Fn=".mcp.json",vn=".deepagents/AGENTS.md",Kr=".deepagents/skills",Gi=".deepagents/.mcp.json",XC=".agentsmesh/rules";});async function Nf(t,e,r="project"){if(r==="global"){t.set(vn,`${w}/_root.md`);for(let o of await E(e,Kr))F(t,C(e,o),Kr);t.set(Gi,".agentsmesh/mcp.json");return}t.set(lr,`${w}/_root.md`);for(let o of await E(e,ie))F(t,C(e,o),ie);t.set(Fn,".agentsmesh/mcp.json");}var ZC=d(()=>{It();sc();gt();s(Nf,"buildDeepagentsCliImportPaths");});var mr,pr,_e,Do,No,Gn,Fo,Mi,Ps,QC,$i=d(()=>{mr="factory-droid",pr="AGENTS.md",_e=".factory/skills",Do=".factory/droids",No=".factory/mcp.json",Gn=".factory/AGENTS.md",Fo=".factory/skills",Mi=".factory/droids",Ps=".factory/mcp.json",QC=".agentsmesh/rules";});async function Ff(t,e,r="project"){if(r==="global"){t.set(Gn,`${w}/_root.md`);for(let o of await E(e,Mi))x(t,C(e,o),Ot,".md");for(let o of await E(e,Fo))F(t,C(e,o),Fo);t.set(Ps,".agentsmesh/mcp.json");return}t.set(pr,`${w}/_root.md`);for(let o of await E(e,Do))x(t,C(e,o),Ot,".md");for(let o of await E(e,_e))F(t,C(e,o),_e);t.set(No,".agentsmesh/mcp.json");}var qC=d(()=>{It();$i();gt();s(Ff,"buildFactoryDroidImportPaths");});async function vf(t,e){for(let r of await E(e,".gemini/rules"))x(t,C(e,r),w,".md");for(let r of await E(e,".gemini/commands")){let o=C(e,r);if(!o.endsWith(".toml")&&!o.endsWith(".md"))continue;let n=o.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",l=(n.startsWith(i)?n.slice(i.length):n).split("/").filter(Boolean).join(":");t.set(o,`${rt}/${l}.md`);}for(let r of await E(e,".gemini/agents"))x(t,C(e,r),Ot,".md");for(let r of await E(e,".gemini/skills"))F(t,C(e,r),".gemini/skills");}var tE=d(()=>{It();gt();s(vf,"buildGeminiCliImportPaths");});var vo,ur,ue,Mn,eE,$n,ji,dr,rE,oE,ic=d(()=>{vo="goose",ur=".goosehints",ue=".agents/skills",Mn=".gooseignore",eE=".config/goose",$n=`${eE}/.goosehints`,ji=`${eE}/.gooseignore`,dr=".agents/skills",rE=".agentsmesh/rules",oE=".agentsmesh/ignore";});async function Gf(t,e,r="project"){if(r==="global"){t.set($n,`${w}/_root.md`);for(let o of await E(e,dr))F(t,C(e,o),dr);t.set(ji,".agentsmesh/ignore");return}t.set(ur,`${w}/_root.md`);for(let o of await E(e,ue))F(t,C(e,o),ue);t.set(Mn,".agentsmesh/ignore");}var nE=d(()=>{It();ic();gt();s(Gf,"buildGooseImportPaths");});var jn,Br,sE,ac=d(()=>{jn="jules",Br="AGENTS.md",sE=".agentsmesh/rules";});async function Mf(t,e,r="project"){r!=="global"&&t.set(Br,`${w}/_root.md`);}var iE=d(()=>{ac();gt();s(Mf,"buildJulesImportPaths");});var Ui,xs,jp,aE,Go,cE,s0,Vl,Ki,Jl,cc,lc,Yl,Xl,Zl,Ql,ql,i0,Up,Bi,lE,$f,Kp,mE,pE,uE,dE,mc=d(()=>{Ui="junie",xs=".junie",jp=`${xs}/guidelines.md`,aE=`${xs}/ci-guidelines.md`,Go=`${xs}/AGENTS.md`,cE="AGENTS.md",s0=`${xs}/mcp`,Vl=`${s0}/mcp.json`,Ki=`${xs}/skills`,Jl=`${xs}/rules`,cc=`${xs}/commands`,lc=`${xs}/agents`,Yl=".aiignore",Xl=".junie",Zl=`${Xl}/skills`,Ql=`${Xl}/agents`,ql=`${Xl}/commands`,i0=`${Xl}/mcp`,Up=`${i0}/mcp.json`,Bi=`${Xl}/AGENTS.md`,lE=".agents/skills",$f=".agentsmesh/rules/_root.md",Kp=".agentsmesh/rules",mE=".agentsmesh/commands",pE=".agentsmesh/agents",uE=".agentsmesh/mcp.json",dE=".agentsmesh/ignore";});async function jf(t,e){t.set(jp,`${w}/_root.md`),t.set(Go,`${w}/_root.md`),t.set("AGENTS.md",`${w}/_root.md`);for(let r of await E(e,".junie/rules"))x(t,C(e,r),w,".md");for(let r of await E(e,".junie/commands"))x(t,C(e,r),rt,".md");for(let r of await E(e,".junie/agents"))x(t,C(e,r),Ot,".md");for(let r of await E(e,".junie/skills"))F(t,C(e,r),".junie/skills");}var gE=d(()=>{It();mc();gt();s(jf,"buildJunieImportPaths");});var de,tm,Mo,Un,Kn,Bn,Wr,Ds,pc,Bp,Wi,uc,Hi,em,Wp,dc,Ns,zi,Vi,Ji,Fs,gc,Hp,fE,vs,fc,Yi,hE,yE,Xi=d(()=>{de="kilo-code",tm=".kilo",Mo="AGENTS.md",Un=`${tm}/rules`,Kn=`${tm}/commands`,Bn=`${tm}/agents`,Wr=`${tm}/skills`,Ds=`${tm}/mcp.json`,pc=".kilocodeignore",Bp=".kilocode",Wi=`${Bp}/rules`,uc=`${Bp}/workflows`,Hi=`${Bp}/skills`,em=`${Bp}/mcp.json`,Wp=".kilocodemodes",dc=".kilo",Ns=`${dc}/AGENTS.md`,zi=`${dc}/rules`,Vi=`${dc}/commands`,Ji=`${dc}/agents`,Fs=`${dc}/skills`,gc=`${dc}/mcp.json`,Hp=".kilocodeignore",fE=".agents/skills",vs=".agentsmesh/rules",fc=".agentsmesh/commands",Yi=".agentsmesh/agents",hE=".agentsmesh/mcp.json",yE=".agentsmesh/ignore";});async function Uf(t,e,r="project"){if(r==="global"){t.set(Ns,`${w}/_root.md`);for(let o of await E(e,zi))x(t,C(e,o),w,".md");for(let o of await E(e,Vi))x(t,C(e,o),rt,".md");for(let o of await E(e,Ji))x(t,C(e,o),Ot,".md");for(let o of await E(e,Fs))F(t,C(e,o),Fs);t.set(gc,".agentsmesh/mcp.json");return}t.set(Mo,`${w}/_root.md`);for(let o of await E(e,Un))x(t,C(e,o),w,".md");for(let o of await E(e,Kn))x(t,C(e,o),rt,".md");for(let o of await E(e,Bn))x(t,C(e,o),Ot,".md");for(let o of await E(e,Wr))F(t,C(e,o),Wr);t.set(Ds,".agentsmesh/mcp.json");for(let o of await E(e,Wi)){let n=C(e,o);if(basename(n)==="00-root.md"){t.set(n,`${w}/_root.md`);continue}x(t,n,w,".md");}for(let o of await E(e,uc))x(t,C(e,o),rt,".md");for(let o of await E(e,Hi))F(t,C(e,o),Hi);t.set(em,".agentsmesh/mcp.json");}var _E=d(()=>{It();Xi();gt();s(Uf,"buildKiloCodeImportPaths");});var De,Hr,rm,zr,ge,Vr,Gs,IE,hc,yc,Zi,Jr,Ms,Qi,om,nm,RE,Kf,Bf,SE,CE,Wf,EE,_c=d(()=>{De="kiro",Hr="AGENTS.md",rm=".kiro",zr=`${rm}/steering`,ge=`${rm}/skills`,Vr=`${rm}/agents`,Gs=`${rm}/hooks`,IE=`${rm}/settings`,hc=`${IE}/mcp.json`,yc=".kiroignore",Zi=".kiro/steering",Jr=".kiro/steering/AGENTS.md",Ms=".kiro/skills",Qi=".kiro/agents",om=".kiro/settings/mcp.json",nm=".kiro/settings/kiroignore",RE=".agents/skills",Kf=".agentsmesh/rules/_root.md",Bf=".agentsmesh/rules",SE=".agentsmesh/agents",CE=".agentsmesh/mcp.json",Wf=".agentsmesh/hooks.yaml",EE=".agentsmesh/ignore";});async function Hf(t,e,r="project"){if(r==="global"){t.set(Jr,`${w}/_root.md`);for(let o of await E(e,Zi)){let n=C(e,o);n!==Jr&&x(t,n,w,".md");}for(let o of await E(e,Ms))F(t,C(e,o),Ms);for(let o of await E(e,Qi))x(t,C(e,o),Ot,".md");return}t.set(Hr,`${w}/_root.md`);for(let o of await E(e,zr))x(t,C(e,o),w,".md");for(let o of await E(e,ge))F(t,C(e,o),ge);for(let o of await E(e,Vr))x(t,C(e,o),Ot,".md");}var OE=d(()=>{It();_c();gt();s(Hf,"buildKiroImportPaths");});var Yr,zp,$o,Wn,Hn,zn,Xr,jo,Ic,$s,qi,ta,ea,js,Us,LE,sm,Vp,Jp,zf,ra=d(()=>{Yr="opencode",zp=".opencode",$o="AGENTS.md",Wn=`${zp}/rules`,Hn=`${zp}/commands`,zn=`${zp}/agents`,Xr=`${zp}/skills`,jo="opencode.json",Ic=".config/opencode",$s=`${Ic}/AGENTS.md`,qi=`${Ic}/rules`,ta=`${Ic}/commands`,ea=`${Ic}/agents`,js=`${Ic}/skills`,Us=`${Ic}/opencode.json`,LE=".agents/skills",sm=".agentsmesh/rules",Vp=".agentsmesh/commands",Jp=".agentsmesh/agents",zf=".agentsmesh/mcp.json";});async function Vf(t,e,r="project"){if(r==="global"){t.set($s,`${w}/_root.md`);for(let o of await E(e,qi))x(t,C(e,o),w,".md");for(let o of await E(e,ta))x(t,C(e,o),rt,".md");for(let o of await E(e,ea))x(t,C(e,o),Ot,".md");for(let o of await E(e,js))F(t,C(e,o),js);t.set(Us,".agentsmesh/mcp.json");return}t.set($o,`${w}/_root.md`);for(let o of await E(e,Wn))x(t,C(e,o),w,".md");for(let o of await E(e,Hn))x(t,C(e,o),rt,".md");for(let o of await E(e,zn))x(t,C(e,o),Ot,".md");for(let o of await E(e,Xr))F(t,C(e,o),Xr);t.set(jo,".agentsmesh/mcp.json");}var AE=d(()=>{It();ra();gt();s(Vf,"buildOpencodeImportPaths");});var Uo,gr,Xt,kE,Vn,fr,wE,Rc=d(()=>{Uo="pi-agent",gr="AGENTS.md",Xt=".pi/skills",kE=".pi/agent",Vn=`${kE}/AGENTS.md`,fr=`${kE}/skills`,wE=".agentsmesh/rules";});async function Jf(t,e,r="project"){if(r==="global"){t.set(Vn,`${w}/_root.md`);for(let o of await E(e,fr))F(t,C(e,o),fr);return}t.set(gr,`${w}/_root.md`);for(let o of await E(e,Xt))F(t,C(e,o),Xt);}var Yf=d(()=>{It();Rc();gt();s(Jf,"buildPiAgentImportPaths");});var Ko,hr,Jn,Bo,Wo,Ne,Ks,Bs,Yn,oa,Ws,Ho,Hs,Xf,TE,bE,Sc=d(()=>{Ko="qwen-code",hr="QWEN.md",Jn=".qwen/rules",Bo=".qwen/commands",Wo=".qwen/agents",Ne=".qwen/skills",Ks=".qwen/settings.json",Bs=".qwenignore",Yn=".qwen/QWEN.md",oa=".qwen/settings.json",Ws=".qwen/commands",Ho=".qwen/skills",Hs=".qwen/agents",Xf=".agentsmesh/rules",TE=".agentsmesh/commands",bE=".agentsmesh/agents";});async function Zf(t,e,r="project"){if(r==="global"){t.set(Yn,`${w}/_root.md`),t.set(oa,".agentsmesh/mcp.json");for(let o of await E(e,Ws))x(t,C(e,o),rt,".md");for(let o of await E(e,Hs))x(t,C(e,o),Ot,".md");for(let o of await E(e,Ho))F(t,C(e,o),Ho);return}t.set(hr,`${w}/_root.md`),t.set(Ks,".agentsmesh/mcp.json"),t.set(Bs,".agentsmesh/ignore");for(let o of await E(e,Jn))x(t,C(e,o),w,".md");for(let o of await E(e,Bo))x(t,C(e,o),rt,".md");for(let o of await E(e,Wo))x(t,C(e,o),Ot,".md");for(let o of await E(e,Ne))F(t,C(e,o),Ne);}var PE=d(()=>{It();gt();Sc();s(Zf,"buildQwenCodeImportPaths");});var zo,Zr,Ie,xE,Cc=d(()=>{zo="replit-agent",Zr="replit.md",Ie=".agents/skills",xE=".agentsmesh/rules";});async function Qf(t,e,r="project"){if(r!=="global"){t.set(Zr,`${w}/_root.md`);for(let o of await E(e,Ie))F(t,C(e,o),Ie);}}var qf=d(()=>{It();Cc();gt();s(Qf,"buildReplitAgentImportPaths");});var zs,na,Qr,im,Xn,Zn,Vo,am,cm,Ec,lm,Yp,Vs,Js,Qn,sa,mm,Ys,DE,ia,Xp,NE,FE,aa=d(()=>{zs="roo-code",na=".roo",Qr=`${na}/rules/00-root.md`,im=".roorules",Xn=`${na}/rules`,Zn=`${na}/commands`,Vo=`${na}/skills`,am=`${na}/mcp.json`,cm=".rooignore",Ec=".roomodes",lm="settings/custom_modes.yaml",Yp=".roo",Vs=`${Yp}/rules`,Js=`${Yp}/commands`,Qn=`${Yp}/skills`,sa="mcp_settings.json",mm=".rooignore",Ys=`${Yp}/AGENTS.md`,DE=".agents/skills",ia=".agentsmesh/rules",Xp=".agentsmesh/commands",NE=".agentsmesh/mcp.json",FE=".agentsmesh/ignore";});async function th(t,e,r="project"){if(r==="global"){t.set(Ys,`${w}/_root.md`);for(let o of await E(e,Vs))x(t,C(e,o),w,".md");for(let o of await E(e,Js))x(t,C(e,o),rt,".md");for(let o of await E(e,Qn))F(t,C(e,o),Qn);t.set(sa,".agentsmesh/mcp.json");return}t.set(Qr,`${w}/_root.md`),t.set(im,`${w}/_root.md`);for(let o of await E(e,Xn)){let n=C(e,o);n!==Qr&&x(t,n,w,".md");}for(let o of await E(e,".roo")){let n=C(e,o);/^\.roo\/rules-[^/]+\/.+\.md$/.test(n)&&x(t,n,w,".md");}for(let o of await E(e,Zn))x(t,C(e,o),rt,".md");for(let o of await E(e,Vo))F(t,C(e,o),Vo);}var vE=d(()=>{It();aa();gt();s(th,"buildRooCodeImportPaths");});var Jo,yr,GE,Zt,qn,ME,ts,Fe,Oc,$E,Lc=d(()=>{Jo="rovodev",yr="AGENTS.md",GE=".rovodev",Zt=`${GE}/skills`,qn=`${GE}/mcp.json`,ME=".rovodev",ts=".rovodev/AGENTS.md",Fe=".rovodev/skills",Oc=".rovodev/mcp.json",$E=".agentsmesh/rules";});async function eh(t,e,r="project"){if(r==="global"){t.set(ts,`${w}/_root.md`);for(let o of await E(e,Fe))F(t,C(e,o),Fe);t.set(Oc,".agentsmesh/mcp.json");return}t.set(yr,`${w}/_root.md`);for(let o of await E(e,Zt))F(t,C(e,o),Zt);t.set(qn,".agentsmesh/mcp.json");}var jE=d(()=>{It();Lc();gt();s(eh,"buildRovodevImportPaths");});var _r,Zp,ve,Ge,Ir,ca,Ac,es,Rr,qr,pm,UE,um,KE,BE,kc=d(()=>{_r="trae",Zp=".trae",ve=`${Zp}/rules`,Ge=`${ve}/project_rules.md`,Ir=`${Zp}/skills`,ca=`${Zp}/mcp.json`,Ac=`${Zp}/.ignore`,es=".trae/user_rules",Rr=".trae/user_rules/rules.md",qr=".trae/skills",pm=".trae/mcp.json",UE=".agents/skills",um=".agentsmesh/rules",KE=".agentsmesh/mcp.json",BE=".agentsmesh/ignore";});async function rh(t,e,r="project"){if(r==="global"){t.set(Rr,`${w}/_root.md`);for(let o of await E(e,es)){let n=C(e,o);n!==Rr&&x(t,n,w,".md");}for(let o of await E(e,qr))F(t,C(e,o),qr);return}t.set(Ge,`${w}/_root.md`);for(let o of await E(e,ve)){let n=C(e,o);n!==Ge&&x(t,n,w,".md");}for(let o of await E(e,Ir))F(t,C(e,o),Ir);}var WE=d(()=>{It();kc();gt();s(rh,"buildTraeImportPaths");});var Yo,to,oh,ae,Xs,Re,HE,wc=d(()=>{Yo="warp",to="AGENTS.md",oh="WARP.md",ae=".warp/skills",Xs=".mcp.json",Re=".warp/skills",HE=".agentsmesh/rules";});async function nh(t,e,r="project"){if(r==="global"){for(let o of await E(e,Re))F(t,C(e,o),Re);return}t.set(to,`${w}/_root.md`);for(let o of await E(e,ae))F(t,C(e,o),ae);t.set(Xs,".agentsmesh/mcp.json");}var zE=d(()=>{It();wc();gt();s(nh,"buildWarpImportPaths");});async function sh(t,e){t.set("AGENTS.md",`${w}/_root.md`),t.set(".windsurfrules",`${w}/_root.md`),await Ep(t,e);for(let r of await E(e,".windsurf/rules"))x(t,C(e,r),w,".md");for(let r of await E(e,".windsurf/workflows"))x(t,C(e,r),rt,".md");for(let r of await E(e,".windsurf/skills"))F(t,C(e,r),".windsurf/skills");}var VE=d(()=>{It();gt();s(sh,"buildWindsurfImportPaths");});var eo,Xo,c0,Zo,JE,la=d(()=>{eo=".rules",Xo=".zed/settings.json",c0=".config/zed",Zo=`${c0}/settings.json`,JE=".agentsmesh/rules";});async function ih(t,e,r="project"){if(r==="global"){t.set(Zo,".agentsmesh/mcp.json");return}t.set(eo,`${w}/_root.md`),t.set(Xo,".agentsmesh/mcp.json");}var YE=d(()=>{la();gt();s(ih,"buildZedImportPaths");});var XE=d(()=>{LC();wC();bC();xC();DC();GC();jC();UC();KC();BC();HC();YC();ZC();qC();tE();nE();iE();gE();_E();OE();AE();Yf();PE();qf();vE();jE();WE();zE();VE();YE();});var Rt=d(()=>{XE();});var l0,m0,p0,ZE,Cp,Qg=d(()=>{St();st();rC();pC();yC();SC();Rt();Xa();l0={name:yo,primaryRootInstructionPath:Ze,generateRules:ZS,generateCommands:qS,generateAgents:tC,generateSkills:QS,generateIgnore:eC,importFrom:mC},m0={rootInstructionPath:Ze,skillDir:oe,managedOutputs:{dirs:[oe],files:[Ze,_n]},paths:{rulePath(t){return Ze},commandPath(t){return `${oe}/${W(t)}/SKILL.md`},agentPath(t){return `${oe}/${$(t)}/SKILL.md`}}},p0={rootInstructionPath:In,skillDir:Qe,managedOutputs:{dirs:[Qe],files:[In,Ci]},rewriteGeneratedPath(t){return t===Ze?In:t===_n?Ci:t.startsWith(`${oe}/`)?t.replace(`${oe}/`,`${Qe}/`):t},paths:{rulePath(t){return In},commandPath(t){return `${Qe}/${W(t)}/SKILL.md`},agentPath(t){return `${Qe}/${$(t)}/SKILL.md`}}},ZE={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Cp={id:yo,metadata:{displayName:"Aider",category:"cli",officialUrl:"https://aider.chat",shortDescription:"Open-source terminal AI pair programmer"},generators:l0,capabilities:ZE,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:hC,lint:{hooks:_C,permissions:IC,mcp:RC},supportsConversion:{commands:true,agents:true},project:m0,globalSupport:{capabilities:ZE,detectionPaths:[In,Ci,Qe],layout:p0},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ze],global:[In]},canonicalDir:YS,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[_n],global:[Ci]},canonicalDir:".agentsmesh",canonicalFilename:XS}},buildImportPaths:rf,detectionPaths:[Ze,_n]};});function QE(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(Ei))continue;let o=r.root?"_root":basename(r.source,".md");e.push({path:`${vr}/${o}.md`,content:r.body.trim()});}return e}function qE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Oi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var tO=d(()=>{Pl();s(QE,"generateRules");s(qE,"generateMcp");});async function eO(t,e){let r=e?.scope??"project";return z(Qp,t,r)}var rO=d(()=>{Ct();ah();s(eO,"importFromAmazonQ");});function oO(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Ei}))}var nO=d(()=>{_t();Pl();s(oO,"lintRules");});var d0,g0,f0,h0,Qp,ah=d(()=>{tO();rO();nO();Rt();Pl();d0={name:Ei,generateRules:QE,generateMcp:qE,importFrom:eO},g0={managedOutputs:{dirs:[vr],files:[Oi]},paths:{rulePath(t,e){return `${vr}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},f0={managedOutputs:{dirs:[Ss],files:[bl]},rewriteGeneratedPath(t){return t.startsWith(`${vr}/`)?t.replace(`${vr}/`,`${Ss}/`):t===Oi?bl:t},paths:{rulePath(t,e){return `${Ss}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},h0={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Qp={id:Ei,metadata:{displayName:"Amazon Q Developer",category:"ide",officialUrl:"https://aws.amazon.com/q/developer",shortDescription:"AWS AI coding assistant"},generators:d0,capabilities:{rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Amazon Q Developer config found (.amazonq/rules/ or .amazonq/mcp.json).",lintRules:oO,project:g0,globalSupport:{capabilities:h0,detectionPaths:[Ss,bl],layout:f0},importer:{rules:{feature:"rules",mode:"directory",source:{project:[vr],global:[Ss]},canonicalDir:AC,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Oi],global:[bl]},canonicalDir:".agentsmesh",canonicalFilename:kC}},buildImportPaths:of,detectionPaths:[vr,Oi]};});function sO(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("amp")),o=e?.body.trim()??"",n=it(o,r);return n?[{path:er,content:n}]:[]}function iO(t){return tt(t,ne)}function aO(t){return t.commands.map(e=>({path:`${ne}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function cO(t){return t.agents.map(e=>({path:`${ne}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}var lO=d(()=>{Q();Mt();st();St();Li();s(sO,"generateRules");s(iO,"generateSkills");s(aO,"generateCommands");s(cO,"generateAgents");});function ct(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var Qt=d(()=>{s(ct,"mirrorSkillsToAgents");});async function pO(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let i=n,a=i["amp.mcpServers"]??i.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await $t(t,mO,c),r.push({fromTool:"amp",fromPath:e,toPath:mO,feature:"mcp"}));}var mO,uO=d(()=>{T();Fr();Li();mO=".agentsmesh/mcp.json";s(pO,"importAmpMcp");});async function dO(t,e={}){let r=e.scope??"project",o=[],n=await U("amp",t,r);return o.push(...await z(qp,t,r,{normalize:n})),await Z(t,r==="global"?rr:ne,"amp",o,n),await pO(t,r==="global"?Cn:Io,o),o}var gO=d(()=>{mt();Q();Ct();uO();Li();ch();s(dO,"importFromAmp");});function fO(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:"amp"}))}var hO=d(()=>{_t();Li();s(fO,"lintRules");});function yO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function _O(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function IO(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var RO=d(()=>{Et();s(yO,"lintHooks");s(_O,"lintPermissions");s(IO,"lintIgnore");});function S0(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n["amp.mcpServers"]!==void 0&&(r["amp.mcpServers"]=n["amp.mcpServers"]),JSON.stringify(r,null,2)}var _0,I0,R0,SO,qp,ch=d(()=>{St();st();lO();Qt();gO();hO();RO();Rt();Li();_0={name:"amp",primaryRootInstructionPath:er,generateRules:sO,generateCommands:aO,generateAgents:cO,generateSkills:iO,importFrom:dO},I0={rootInstructionPath:er,skillDir:ne,managedOutputs:{dirs:[ne],files:[er,Io]},paths:{rulePath(t){return er},commandPath(t){return `${ne}/${W(t)}/SKILL.md`},agentPath(t){return `${ne}/${$(t)}/SKILL.md`}}},R0={rootInstructionPath:Sn,skillDir:rr,managedOutputs:{dirs:[rr],files:[Sn,Cn]},rewriteGeneratedPath(t){return t===er?Sn:t===Io?Cn:t.startsWith(`${ne}/`)?t.replace(`${ne}/`,`${rr}/`):t},mirrorGlobalPath(t,e){return ct(t,rr,e)},paths:{rulePath(t){return Sn},commandPath(t){return `${rr}/${W(t)}/SKILL.md`},agentPath(t){return `${rr}/${$(t)}/SKILL.md`}}},SO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(S0,"mergeAmpSettings");qp={id:"amp",metadata:{displayName:"Amp",category:"cli",officialUrl:"https://ampcode.com",shortDescription:"Sourcegraph's coding agent"},generators:_0,capabilities:SO,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:fO,lint:{hooks:yO,permissions:_O,ignore:IO},supportsConversion:{commands:true,agents:true},project:I0,globalSupport:{capabilities:SO,detectionPaths:[Sn,Cn],layout:R0},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[er],global:[Sn]},canonicalDir:TC,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Io,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,o){return o===Io||o===Cn?S0(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:sf,detectionPaths:[er,Io]};});function CO(t){let e=t.rules.find(o=>o.root);if(!e)return [];let r=[{path:Gr,content:e.body.trim()||""}];for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("antigravity"))continue;let n=basename(o.source,".md");r.push({path:`${Ro}/${n}.md`,content:o.body.trim()||""});}return r}function EO(t){return t.commands.map(e=>{let r=e.description.trim(),o=e.body.trim(),n=r&&o&&!o.startsWith(r)?`${r}
|
|
51
|
+
${Ll}`;s(Kg,"normalizeWhitespace");FS=[fU,gU,dU,uU,pU,mU,lU,cU,aU];s(vS,"appendAgentsmeshRootInstructionParagraph");s(GS,"stripAgentsmeshRootInstructionParagraph");});function me(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function za(t){let e=await y(t);return e?w(e).frontmatter:{}}function Vt(t,e){return typeof t[e]=="string"?t[e]:void 0}function Hg(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function hU(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function yU(t,e){let r=basename(t,".md")==="_root",o={...e};return delete o.root,{root:r,...o}}async function K(t,e,r){let o=await za(t),n=basename(t,".md")==="_root"?GS(r):r.trim(),i=yU(t,hU({...o,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=me(i.globs));for(let[c,l]of Object.entries(i))c==="root"||c==="description"||c==="globs"||l===void 0||(a[c]=l);return P(a,n||"")}var zg=u(()=>{T();M();Wg();s(me,"toStringArray");s(za,"readExistingFrontmatter");s(Vt,"readString");s(Hg,"readHooks");s(hU,"pruneUndefined");s(yU,"serializeCanonicalRuleFrontmatter");s(K,"serializeImportedRuleWithFallback");});async function ht(t,e,r){let o=await za(t),n=(()=>{let c=me(o.allowedTools);return c.length>0?c:me(o["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof o.description=="string"?o.description:"",a=e.hasAllowedTools?e.allowedTools??[]:n;return P({description:i,"allowed-tools":a},r.trim()||"")}async function uo(t,e,r){let o=await za(t),n=basename(dirname(t)),i=Vt(e,"name")??Vt(o,"name")??n,a=Vt(e,"description")??Vt(o,"description")??"";return P({name:i,description:a},r.trim()||"")}async function Bt(t,e,r){let o=await za(t),n=Object.prototype.hasOwnProperty.call(e,"tools")?me(e.tools):(()=>{let O=me(o.tools);return O.length>0?O:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?me(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?me(e["disallowed-tools"]):me(o.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?me(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?me(e["mcp-servers"]):me(o.mcpServers),c=Object.prototype.hasOwnProperty.call(e,"skills")?me(e.skills):me(o.skills),l=e.maxTurns??e["max-turns"]??o.maxTurns,m=typeof l=="number"?l:Number(l??0),p=Hg(e)??Hg(o),d={name:Vt(e,"name")??Vt(o,"name")??basename(t,".md"),description:Vt(e,"description")??Vt(o,"description")??"",tools:n};i.length>0&&(d.disallowedTools=i);let g=Vt(e,"model")??Vt(o,"model");g&&(d.model=g);let f=Vt(e,"permissionMode")??Vt(e,"permission-mode")??Vt(o,"permissionMode")??Vt(o,"permission-mode");f&&(d.permissionMode=f),Number.isInteger(m)&&m>0&&(d.maxTurns=m),a.length>0&&(d.mcpServers=a),p&&Object.keys(p).length>0&&(d.hooks=p),c.length>0&&(d.skills=c);let h=Vt(e,"memory")??Vt(o,"memory");return h&&(d.memory=h),P(d,r.trim()||"")}var jS=u(()=>{M();zg();s(ht,"serializeImportedCommandWithFallback");s(uo,"serializeImportedSkillWithFallback");s(Bt,"serializeImportedAgentWithFallback");});var lt=u(()=>{zg();jS();});function Sp(t){let e=t.split("/").filter(Boolean);return e.length===0||e.some(o=>o.startsWith("."))?false:!e.join("/").startsWith("tests/e2e/fixtures/")}async function go(t){await rm$1(t,{recursive:true,force:true});}var Al=u(()=>{s(Sp,"shouldImportScopedAgentsRule");s(go,"removePathIfExists");});function tt(t,e){let r=[];for(let o of t.skills){let n={name:o.name,description:o.description||void 0};n.description===void 0&&delete n.description,r.push({path:`${e}/${o.name}/SKILL.md`,content:P(n,o.body.trim()||"")});for(let i of o.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");r.push({path:`${e}/${o.name}/${a}`,content:i.content});}}return r}async function Z(t,e,r,o,n){let i=await readdir(join(t,e),{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(i!==null)for(let a of i){if(!a.isDirectory())continue;let c=join(t,e,a.name),l=join(c,"SKILL.md"),m=await y(l);if(m===null)continue;let p=join(t,kl,a.name),d=join(p,"SKILL.md"),{frontmatter:g,body:f}=w(n(m,l,d)),h=hp(g,a.name);if(h){await go(join(t,kl,a.name));let A=join(t,US);await L(A);let F=join(A,`${h.name}.md`);await I(F,yp(h,n(f,l,F))),o.push({fromTool:r,fromPath:l,toPath:`${US}/${h.name}.md`,feature:"commands"});continue}let O=Wa(g,a.name);if(O){await go(join(t,kl,a.name));let A=join(t,KS);await L(A);let F=join(A,`${O.name}.md`);await I(F,fs(O,n(f,l,F))),o.push({fromTool:r,fromPath:l,toPath:`${KS}/${O.name}.md`,feature:"agents"});continue}let R=await uo(d,{...g,name:a.name},f);await L(p),await I(d,R),o.push({fromTool:r,fromPath:l,toPath:`${kl}/${a.name}/SKILL.md`,feature:"skills"});let E=await N(c);for(let A of E){if(A===l)continue;let F=relative(c,A).replace(/\\/g,"/"),v=await y(A);if(v===null)continue;let G=join(p,F);await L(dirname(G)),await I(G,n(v,A,G)),o.push({fromTool:r,fromPath:A,toPath:`${kl}/${a.name}/${F}`,feature:"skills"});}}}var kl,US,KS,Q=u(()=>{T();M();lt();at();St();Al();kl=".agentsmesh/skills",US=".agentsmesh/commands",KS=".agentsmesh/agents";s(tt,"generateEmbeddedSkills");s(Z,"importEmbeddedSkills");});var fo,Ye,re,fn,hn,Xe,Ii,BS,WS,Va=u(()=>{fo="aider",Ye="CONVENTIONS.md",re=".aider/skills",fn=".aiderignore",hn="CONVENTIONS.md",Xe=".aider/skills",Ii=".aiderignore",BS=".agentsmesh/rules",WS=".agentsmesh/ignore";});function HS(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(fo)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:Ye,content:n}]:[]}function zS(t){return tt(t,re)}function VS(t){return t.commands.map(e=>({path:`${re}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function JS(t){return t.agents.map(e=>({path:`${re}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function YS(t){return t.ignore.length===0?[]:[{path:fn,content:t.ignore.join(`
|
|
52
|
+
`)}]}var XS=u(()=>{Q();Mt();at();St();Va();s(HS,"generateRules");s(zS,"generateSkills");s(VS,"generateCommands");s(JS,"generateAgents");s(YS,"generateIgnore");});async function $t(t,e,r){let o=join(t,e),i={...await LU(o),...r};await L(dirname(o)),await I(o,JSON.stringify({mcpServers:i},null,2));}async function LU(t){let e=await y(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let o=r.mcpServers;if(!o||typeof o!="object"||Array.isArray(o))return {};let n={};for(let[i,a]of Object.entries(o))!a||typeof a!="object"||Array.isArray(a)||(n[i]=a);return n}var Nr=u(()=>{T();s($t,"writeMcpWithMerge");s(LU,"readExistingServers");});function yn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function Ze(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function hs(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function ho(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var Qe=u(()=>{s(yn,"toGlobsArray");s(Ze,"toToolsArray");s(hs,"toStringArray");s(ho,"toStringRecord");});function wU(t,e){return e.some(r=>t.endsWith(r))}async function yt(t){let r=(await N(t.srcDir)).filter(n=>wU(n,t.extensions)),o=[];for(let n of r){let i=await y(n);if(!i)continue;let a=relative(t.srcDir,n).replace(/\\/g,"/"),c=await t.mapEntry({srcPath:n,relativePath:a,content:i,normalizeTo:s((l,m=i)=>t.normalize(m,n,l),"normalizeTo")});c&&(await L(dirname(c.destPath)),await I(c.destPath,c.content),o.push({fromTool:t.fromTool,fromPath:n,toPath:c.toPath,feature:c.feature}));}return o}var ke=u(()=>{T();s(wU,"matchesExtension");s(yt,"importFileDirectory");});function ZS(t){return typeof t=="string"?t:void 0}function TU(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function Jg(t,e){return e?e(t):t}function bU(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=w(e.normalizeTo(r)),i=Jg(o,t.frontmatterRemap),a=TU({root:false,description:ZS(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await K(r,a,n)}}}function PU(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=w(e.normalizeTo(r)),i=Jg(o,t.frontmatterRemap),a=await ht(r,{hasDescription:true,description:ZS(i.description),hasAllowedTools:true,allowedTools:hs(i["allowed-tools"])},n);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function xU(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=w(e.normalizeTo(r)),i=Jg(o,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Bt(r,i,n)}}}function QS(t){if(t.map)return t.map;switch(t.preset){case "rule":return bU(t);case "command":return PU(t);case "agent":return xU(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var qS=u(()=>{M();lt();Qe();s(ZS,"pickString");s(TU,"pruneUndefined");s(Jg,"applyRemap");s(bU,"ruleMapper");s(PU,"commandMapper");s(xU,"agentMapper");s(QS,"resolveMapper");});function Yg(t,e){return t?t[e]??[]:[]}var tC,eC=u(()=>{tC=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(Yg,"resolveScopedSources");});async function FU(t,e,r,o,n){if(!t.canonicalRootFilename)throw new Error(`singleFile spec for ${t.feature} must set canonicalRootFilename`);let i=join(r,t.canonicalDir);for(let a of e){let c=join(r,a),l=await y(c);if(l===null)continue;await L(i);let m=join(i,t.canonicalRootFilename),p=s(R=>n(l,c,R),"normalizeTo");if(t.map){let R=await t.map({absolutePath:c,relativePath:a,content:l,destDir:i,normalizeTo:p});if(!R)continue;return await I(R.destPath,R.content),[{fromTool:o,fromPath:c,toPath:R.toPath,feature:t.feature}]}let{frontmatter:d,body:g}=w(p(m)),f=t.frontmatterRemap?t.frontmatterRemap(d):d,h=t.markAsRoot?{...f,root:true}:f,O=await K(m,h,g);return await I(m,O),[{fromTool:o,fromPath:c,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function vU(t,e,r,o,n){let i=QS(t),a=join(r,t.canonicalDir),c=[];for(let l of e){let m=join(r,l),p=await yt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:o,normalize:n,mapEntry:s(async({srcPath:d,relativePath:g,content:f,normalizeTo:h})=>{let O=await i({absolutePath:d,relativePath:g,content:f,destDir:a,normalizeTo:s(R=>h(R),"normalizeTo")});return O?{destPath:O.destPath,toPath:O.toPath,feature:t.feature,content:O.content}:null},"mapEntry")});c.push(...p);}return c}function oC(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function GU(t,e,r,o){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let n=oC(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=join(r,n);return await L(dirname(l)),await I(l,c.trimEnd()),[{fromTool:o,fromPath:a,toPath:n,feature:t.feature}]}return []}function MU(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object")return {};let r=e.mcpServers;if(!r||typeof r!="object"||Array.isArray(r))return {};let o={};for(let[n,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){o[n]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:hs(a.args),env:ho(a.env),description:c};continue}typeof a.url=="string"&&(o[n]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:ho(a.headers),env:ho(a.env),description:c});}return o}async function $U(t,e,r,o){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let n=oC(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=MU(c);return Object.keys(l).length===0?[]:(await $t(r,n,l),[{fromTool:o,fromPath:a,toPath:n,feature:t.feature}])}return []}function rC(t,e,r,o,n){switch(t.mode){case "singleFile":return FU(t,e,r,o,n);case "directory":return vU(t,e,r,o,n);case "flatFile":return GU(t,e,r,o);case "mcpJson":return $U(t,e,r,o)}}async function jU(t,e,r,o,n){let i=Yg(t.source,e),a=Yg(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let c=await rC(t,i,r,o,n);if(c.length>0)return c}return a.length>0?rC(t,a,r,o,n):[]}function UU(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function z(t,e,r,o){let n=t.importer;if(!n)return [];let i=o?.normalize??await U(t.id,e,r),a=[];for(let c of tC)for(let l of UU(n,c))a.push(...await jU(l,r,e,t.id,i));return a}var Ct=u(()=>{mt();T();Nr();M();Qe();lt();ke();qS();eC();s(FU,"runSingleFile");s(vU,"runDirectory");s(oC,"resolveCanonicalFilePath");s(GU,"runFlatFile");s(MU,"parseMcpJson");s($U,"runMcpJson");s(rC,"dispatchSpec");s(jU,"runSpec");s(UU,"specsForFeature");s(z,"runDescriptorImport");});async function nC(t,e={}){let r=e.scope??"project",o=[],n=await U(fo,t,r);return o.push(...await z(Cp,t,r,{normalize:n})),await Z(t,r==="global"?Xe:re,fo,o,n),o}var sC=u(()=>{mt();Q();Ct();Va();Xg();s(nC,"importFromAider");});function KU(t,e){return aC(e).some(o=>BU(t,o))}function iC(t,e){return t.filter(r=>KU(r,e))}function aC(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,o,n]=e;if(!o)return [t];let i=o.split(",").map(c=>c.trim()),a=[];for(let c of i)for(let l of aC(r+c+n))a.push(l);return a}function BU(t,e){return WU(e).test(t)}function WU(t){let e=[],r=0;for(;r<t.length;){if(t.startsWith("**",r)){let i=t.slice(r+2);if(i.length===0&&e.length===0)e.push(".*");else if(e.push(i.startsWith("/")?"(?:[^/]+/)*":"(?:/[^/]+)*?"),i.startsWith("/")){r+=3;continue}r+=2;continue}if(t[r]==="*"){e.push("[^/]*"),r+=1;continue}if(t[r]==="?"){e.push("[^/]"),r+=1;continue}if(t[r]==="{"){e.push("(?:"),r+=1;continue}if(t[r]==="}"){e.push(")"),r+=1;continue}if(t[r]===","){e.push("|"),r+=1;continue}".^$+?()[]{}|\\".includes(t[r])?e.push("\\"+t[r]):e.push(t[r]),r+=1;}let o="^"+e.join("")+"$";return new RegExp(o)}var cC=u(()=>{s(KU,"globMatch");s(iC,"globFilter");s(aC,"expandBraces");s(BU,"matchOne");s(WU,"globToRegex");});function H(t,e,r,o={}){let n=[],{rules:i}=t;if(i.length===0)return [];if(i.some(c=>c.root)||n.push({level:"error",file:relative(e,i[0].source),message:"Rules exist but no root rule (_root.md or root: true). Add a root rule."}),o.checkGlobMatches===false)return n;for(let c of i){if(c.globs.length===0)continue;let l=false;for(let m of c.globs)if(iC(r,m).length>0){l=true;break}l||n.push({level:"warning",file:relative(e,c.source),message:`globs "${c.globs.join(", ")}" match 0 files in project`});}return n}var _t=u(()=>{cC();s(H,"validateRules");});function mC(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:fo}))}var pC=u(()=>{_t();Va();s(mC,"lintRules");});function b(t,e,r){return {level:"warning",file:t,target:e,message:r}}function HU(t){return t.length===0?"":t.length===1?t[0]:t.length===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[t.length-1]}`}function _s(t,e,r,o){let n=o?.unsupportedBy??e,i=HU(r);return b(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${n}; only ${i} are projected.`)}var Et=u(()=>{s(b,"createWarning");s(HU,"formatOxfordComma");s(_s,"createUnsupportedHookWarning");});function uC(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function dC(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function gC(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var fC=u(()=>{Et();s(uC,"lintHooks");s(dC,"lintPermissions");s(gC,"lintMcp");});function S(t,e){return et(t).relative(t,e).replace(/\\/g,"/")}async function C(t,e){return N(et(t).join(t,e)).catch(()=>[])}function yC(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function ZU(t,e,r,o){let n=posix.dirname(e),i=posix.dirname(r);for(;n!==o&&n!==".";)yC(t,n,i),n=posix.dirname(n),i=posix.dirname(i);}function x(t,e,r,o){t.set(e,`${r}/${basename(e,o)}.md`);}function D(t,e,r){if(!e.startsWith(`${r}/`))return;let o=e.slice(r.length+1);if(!o)return;if(!o.includes("/")){if(!o.endsWith(".md")||basename(o)==="SKILL.md")return;let d=basename(o,".md");t.set(e,`${hC}/${d}/SKILL.md`);return}let[n,...i]=o.split("/"),a=i.join("/");if(!n||!a)return;let c=n.startsWith(Ka)?Ka:n.startsWith(Sl)?Sl:null;if(c&&a==="SKILL.md"){t.set(e,`${YU}/${n.slice(c.length)}.md`);return}let l=n.startsWith(Ba)?Ba:n.startsWith(Cl)?Cl:null;if(l&&a==="SKILL.md"){t.set(e,`${XU}/${n.slice(l.length)}.md`);return}let m=`${hC}/${n}`;a==="SKILL.md"&&yC(t,`${r}/${n}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&ZU(t,e,p,`${r}/${n}`);}function QU(t){return t.split("/").filter(Boolean)[0]??""}async function qU(){if(Zg!==void 0)return Zg;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(xt(),_C)),e=new Set;for(let r of t)for(let o of [r.project.rootInstructionPath,r.project.skillDir,...r.project.managedOutputs?.dirs??[],...r.project.managedOutputs?.files??[],...r.detectionPaths,r.globalSupport?.layout.rootInstructionPath,r.globalSupport?.layout.skillDir,...r.globalSupport?.layout.managedOutputs?.dirs??[],...r.globalSupport?.layout.managedOutputs?.files??[],...r.globalSupport?.detectionPaths??[]])if(o!==void 0){let n=QU(o);n.startsWith(".")&&e.add(n);}return Zg=e,e}function qg(t){return t.split("/").some(e=>e.startsWith("."))}async function t0(t){let e=[],r=await qU(),o=et(t);async function n(i){let a=o.join(t,i),c=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let l of c){let m=i?`${i}/${l.name}`:l.name;if(l.isDirectory()){if(r.has(l.name)||qg(m))continue;await n(m);continue}if(l.isSymbolicLink()&&await stat(o.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(l.name)||qg(m))continue;await n(m);continue}(l.name==="AGENTS.md"||l.name==="AGENTS.override.md")&&e.push(o.join(t,m));}}return s(n,"walk"),await n(""),e}async function Ep(t,e){let r=await t0(e);for(let o of r){let n=S(e,o),i=n.endsWith("/AGENTS.md")&&n!=="AGENTS.md"&&!n.endsWith("/AGENTS.override.md"),a=n.endsWith("/AGENTS.override.md")&&n!=="AGENTS.override.md";if(!i&&!a)continue;let c=posix.dirname(n);if(qg(c))continue;let l=c.replace(/\//g,"-");t.set(n,`${JU}/${l}.md`);}}var JU,YU,XU,hC,Zg,It=u(()=>{ee();T();St();at();JU=".agentsmesh/rules",YU=".agentsmesh/commands",XU=".agentsmesh/agents",hC=".agentsmesh/skills";s(S,"rel");s(C,"listFiles");s(yC,"addDirectoryMapping");s(ZU,"addAncestorMappings");s(x,"addSimpleFileMapping");s(D,"addSkillLikeMapping");s(QU,"firstPathSegment");s(qU,"targetRootSegments");s(qg,"hasHiddenSegment");s(t0,"listScopedAgentsFiles");s(Ep,"addScopedAgentsMappings");});var k,rt,Ot,gt=u(()=>{k=".agentsmesh/rules",rt=".agentsmesh/commands",Ot=".agentsmesh/agents";});async function tf(t,e,r="project"){if(r==="global"){t.set(hn,`${k}/_root.md`);for(let o of await C(e,Xe))D(t,S(e,o),Xe);t.set(Ii,".agentsmesh/ignore");return}t.set(Ye,`${k}/_root.md`);for(let o of await C(e,re))D(t,S(e,o),re);t.set(fn,".agentsmesh/ignore");}var IC=u(()=>{It();Va();gt();s(tf,"buildAiderImportPaths");});var Ri,Fr,Si,Is,Tl,RC,SC,bl=u(()=>{Ri="amazon-q",Fr=".amazonq/rules",Si=".amazonq/mcp.json",Is=".aws/amazonq/rules",Tl=".aws/amazonq/mcp.json",RC=".agentsmesh/rules",SC=".agentsmesh/mcp.json";});async function ef(t,e,r="project"){let o=r==="global"?Is:Fr;for(let n of await C(e,o)){let i=S(e,n);x(t,i,k,".md");}}var CC=u(()=>{It();bl();gt();s(ef,"buildAmazonQImportPaths");});var qe,oe,yo,rf,_n,tr,In,EC,Ci=u(()=>{qe="AGENTS.md",oe=".agents/skills",yo=".amp/settings.json",rf=".config/amp",_n=`${rf}/AGENTS.md`,tr=`${rf}/skills`,In=`${rf}/settings.json`,EC=".agentsmesh/rules";});async function of(t,e,r="project"){if(r==="global"){t.set(_n,`${k}/_root.md`);for(let o of await C(e,tr))D(t,S(e,o),tr);t.set(In,".agentsmesh/mcp.json");return}t.set(qe,`${k}/_root.md`);for(let o of await C(e,oe))D(t,S(e,o),oe);t.set(yo,".agentsmesh/mcp.json");}var OC=u(()=>{It();Ci();gt();s(of,"buildAmpImportPaths");});var Ei,Op,_o,vr,Pl,Gr,Rn,xl,Io,Sn,Dl,Ja,nf,Oi,Lp,LC,Li=u(()=>{Ei="antigravity",Op=".agents",_o=`${Op}/rules`,vr=`${_o}/general.md`,Pl=`${_o}/_root.md`,Gr=`${Op}/skills`,Rn=`${Op}/workflows`,xl=`${Op}/antigravity/mcp_config.json`,Io=".gemini/antigravity/GEMINI.md",Sn=".gemini/antigravity/skills",Dl=".gemini/antigravity/workflows",Ja=".gemini/antigravity/mcp_config.json",nf=".agentsmesh/rules/_root.md",Oi=".agentsmesh/rules",Lp=".agentsmesh/commands",LC=".agentsmesh/mcp.json";});async function sf(t,e,r="project"){if(r==="global"){t.set(Io,`${k}/_root.md`);for(let o of await C(e,Sn))D(t,S(e,o),Sn);t.set(Ja,".agentsmesh/mcp.json");return}t.set(vr,`${k}/_root.md`),t.set(Pl,`${k}/_root.md`);for(let o of await C(e,_o)){let n=S(e,o);n===vr||n===Pl||x(t,n,k,".md");}for(let o of await C(e,Rn))x(t,S(e,o),rt,".md");for(let o of await C(e,Gr))D(t,S(e,o),Gr);}var AC=u(()=>{It();Li();gt();s(sf,"buildAntigravityImportPaths");});var ne,Ap,we,er,Te,Ro,So,kp,Cn,En,Co,On,af,cf,lf,mf,Ai=u(()=>{ne="augment-code",Ap=".augment",we=`${Ap}/rules`,er=`${Ap}/commands`,Te=`${Ap}/skills`,Ro=`${Ap}/settings.json`,So=".augmentignore",kp=".augment",Cn=`${kp}/rules`,En=`${kp}/commands`,Co=`${kp}/skills`,On=`${kp}/settings.json`,af=".agentsmesh/rules",cf=".agentsmesh/mcp.json",lf=".agentsmesh/hooks.yaml",mf=".agentsmesh/ignore";});async function pf(t,e,r="project"){if(r==="global"){for(let o of await C(e,Cn))x(t,S(e,o),k,".md");for(let o of await C(e,En))x(t,S(e,o),rt,".md");for(let o of await C(e,Co))D(t,S(e,o),Co);t.set(On,".agentsmesh/mcp.json");return}for(let o of await C(e,we))x(t,S(e,o),k,".md");for(let o of await C(e,er))x(t,S(e,o),rt,".md");for(let o of await C(e,Te))D(t,S(e,o),Te);t.set(Ro,".agentsmesh/mcp.json"),t.set(So,".agentsmesh/ignore");}var kC=u(()=>{It();Ai();gt();s(pf,"buildAugmentCodeImportPaths");});var wC,Rs,TC,Nl,Fl,vl,Gl,Ml,Ln,uf,$l,Ya,jl,Ul,wp,Tp,df,Kl,gf,ki,bC,An=u(()=>{wC="claude-code",Rs=".claude/CLAUDE.md",TC="CLAUDE.md",Nl=".claude/rules",Fl=".claude/commands",vl=".claude/agents",Gl=".claude/skills",Ml=".claude/settings.json",Ln=".claude/hooks.json",uf=".claude/output-styles",$l=".claudeignore",Ya=".mcp.json",jl=".claude.json",Ul=".agentsmesh/rules",wp=".agentsmesh/commands",Tp=".agentsmesh/agents",df=".agentsmesh/skills",Kl=".agentsmesh/mcp.json",gf=".agentsmesh/permissions.yaml",ki=".agentsmesh/hooks.yaml",bC=".agentsmesh/ignore";});async function ff(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${k}/_root.md`),t.set(Ln,ki),r==="project"&&t.set("CLAUDE.md",`${k}/_root.md`),r==="global")for(let o of await C(e,".agents/skills"))D(t,S(e,o),".agents/skills");for(let o of await C(e,".claude/rules"))x(t,S(e,o),k,".md");for(let o of await C(e,".claude/commands"))x(t,S(e,o),rt,".md");for(let o of await C(e,".claude/agents"))x(t,S(e,o),Ot,".md");for(let o of await C(e,".claude/skills"))D(t,S(e,o),".claude/skills");}var PC=u(()=>{It();An();gt();s(ff,"buildClaudeCodeImportPaths");});var Ss,kn,wi,wn,xC,Jt,Eo,Cs,Ti,bi,Pi,xi,hf,Es,bp,yf,_f,DC,NC,rr=u(()=>{Ss="cline",kn=".clinerules",wi=".clineignore",wn=".cline/cline_mcp_settings.json",xC=".cline/mcp_settings.json",Jt=".cline/skills",Eo=".clinerules/workflows",Cs="AGENTS.md",Ti=".clinerules/hooks",bi="Documents/Cline/Rules",Pi="Documents/Cline/Workflows",xi="Documents/Cline/Hooks",hf=".agentsmesh/hooks.yaml",Es=".agentsmesh/rules",bp=".agentsmesh/commands",yf=".agentsmesh/ignore",_f=".agentsmesh/mcp.json",DC=".agentsmesh/agents",NC=".agentsmesh/skills";});async function If(t,e,r="project"){if(r==="global"){for(let o of await C(e,bi))x(t,S(e,o),k,".md");for(let o of await C(e,Pi))x(t,S(e,o),rt,".md");for(let o of await C(e,Jt))D(t,S(e,o),Jt);t.set(wn,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${k}/_root.md`);for(let o of await C(e,".clinerules")){let n=S(e,o);!n.endsWith(".md")||n.includes("/workflows/")||basename(n)==="_root.md"||x(t,n,k,".md");}for(let o of await C(e,".clinerules/workflows"))x(t,S(e,o),rt,".md");for(let o of await C(e,".cline/skills"))D(t,S(e,o),".cline/skills");}var FC=u(()=>{It();rr();gt();s(If,"buildClineImportPaths");});async function Rf(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${k}/_root.md`),t.set(".codex/AGENTS.override.md",`${k}/_root.md`)):(t.set("AGENTS.md",`${k}/_root.md`),t.set("codex.md",`${k}/_root.md`),await Ep(t,e)),r==="project")for(let o of await C(e,".codex/instructions"))x(t,S(e,o),k,".md");for(let o of await C(e,".codex/rules")){let n=S(e,o);n.endsWith(".rules")?x(t,n,k,".rules"):n.endsWith(".md")&&x(t,n,k,".md");}for(let o of await C(e,".codex/agents"))x(t,S(e,o),Ot,".toml");for(let o of await C(e,".agents/skills"))D(t,S(e,o),".agents/skills");}var vC=u(()=>{It();gt();s(Rf,"buildCodexCliImportPaths");});var Xa,Mr,Oo,Sf,Pp,Tn,Cf,be,Za,Bl,xp,Dp,Ef,Lo=u(()=>{Xa="continue",Mr=".continue/rules",Oo=".continue/prompts",Sf=".continue/mcpServers",Pp=`${Sf}/agentsmesh.json`,Tn=`${Mr}/general.md`,Cf=`${Mr}/_root.md`,be=".continue/skills",Za=".continue/AGENTS.md",Bl=".continue/config.yaml",xp=".agentsmesh/rules",Dp=".agentsmesh/commands",Ef=".agentsmesh/mcp.json";});async function Of(t,e,r="project"){t.set(Tn,`${k}/_root.md`),t.set(Cf,`${k}/_root.md`);for(let o of await C(e,".continue/rules")){let n=S(e,o);n===Tn||n===Cf||x(t,n,k,".md");}for(let o of await C(e,".continue/prompts"))t.set(S(e,o),`${rt}/${basename(o,".md")}.md`);for(let o of await C(e,".continue/skills"))D(t,S(e,o),".continue/skills");if(r==="global")for(let o of await C(e,".agents/skills"))D(t,S(e,o),".agents/skills");}var GC=u(()=>{It();Lo();gt();s(Of,"buildContinueImportPaths");});function o0(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${k}/${basename(e,".instructions.md")}.md`);return}x(t,e,k,".md");}async function Lf(t,e){t.set(".github/copilot-instructions.md",`${k}/_root.md`);for(let r of await C(e,".github/copilot"))t.set(S(e,r),`${k}/${basename(r,".instructions.md")}.md`);for(let r of await C(e,".github/instructions"))o0(t,S(e,r));for(let r of await C(e,".github/prompts"))t.set(S(e,r),`${rt}/${basename(r,".prompt.md")}.md`);for(let r of await C(e,".github/agents"))t.set(S(e,r),`${Ot}/${basename(r,".agent.md")}.md`);for(let r of await C(e,".github/skills"))D(t,S(e,r),".github/skills");}var MC=u(()=>{It();gt();s(o0,"addCopilotInstructionMapping");s(Lf,"buildCopilotImportPaths");});var or,nr,Yt,Pe,bn,$C,Fp,xe,Di,vp,Gp,Mp,Qa=u(()=>{or="crush",nr="CRUSH.md",Yt=".crush/skills",Pe="crush.json",bn=".crushignore",$C=".config/crush",Fp=`${$C}/crush.json`,xe=".config/crush/skills",Di=`${$C}/CRUSH.md`,vp=".agentsmesh/rules",Gp=".agentsmesh/ignore",Mp=".agentsmesh/mcp.json";});async function Af(t,e,r="project"){if(r==="global"){for(let o of await C(e,xe))D(t,S(e,o),xe);return}t.set(nr,`${vp}/_root.md`),t.set(Pe,Mp),t.set(bn,Gp);for(let o of await C(e,Yt))D(t,S(e,o),Yt);}var jC=u(()=>{It();Qa();s(Af,"buildCrushImportPaths");});var UC,Os,KC,sr,Pn,ir,qa,Ao,ko,wo,$p,$r,kf,n0,tc,jr,Wl,Ls,As,To,ks,ws,BC,ec,wf,Hl,Tf,jt=u(()=>{UC="cursor",Os="AGENTS.md",KC=".cursorrules",sr=".cursor/rules",Pn=`${sr}/general.mdc`,ir=".cursor/commands",qa=".cursor/agents",Ao=".cursor/skills",ko=".cursor/mcp.json",wo=".cursor/hooks.json",$p=".cursor/settings.json",$r=".cursorignore",kf=".cursorindexingignore",n0=".agentsmesh-exports/cursor",tc=`${n0}/user-rules.md`,jr=".cursor/AGENTS.md",Wl=ko,Ls=Ao,As=qa,To=".agentsmesh/rules",ks=".agentsmesh/commands",ws=".agentsmesh/agents",BC=".agentsmesh/skills",ec=".agentsmesh/mcp.json",wf=".agentsmesh/permissions.yaml",Hl=".agentsmesh/hooks.yaml",Tf=".agentsmesh/ignore";});async function bf(t,e,r="project"){if(r==="global"){t.set(ko,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${k}/_root.md`);for(let o of await C(e,".cursor/rules"))x(t,S(e,o),k,".mdc");for(let o of await C(e,".cursor/commands"))x(t,S(e,o),rt,".md");for(let o of await C(e,".cursor/agents"))x(t,S(e,o),Ot,".md");for(let o of await C(e,".cursor/skills"))D(t,S(e,o),".cursor/skills");return}t.set("AGENTS.md",`${k}/_root.md`);for(let o of await C(e,".cursor/rules"))x(t,S(e,o),k,".mdc");for(let o of await C(e,".cursor/commands"))x(t,S(e,o),rt,".md");for(let o of await C(e,".cursor/agents"))x(t,S(e,o),Ot,".md");for(let o of await C(e,".cursor/skills"))D(t,S(e,o),".cursor/skills");}var WC=u(()=>{It();jt();gt();s(bf,"buildCursorImportPaths");});var bo,ar,se,xn,Dn,Ur,Ni,HC,rc=u(()=>{bo="deepagents-cli",ar=".deepagents/AGENTS.md",se=".deepagents/skills",xn=".mcp.json",Dn=".deepagents/AGENTS.md",Ur=".deepagents/skills",Ni=".deepagents/.mcp.json",HC=".agentsmesh/rules";});async function Pf(t,e,r="project"){if(r==="global"){t.set(Dn,`${k}/_root.md`);for(let o of await C(e,Ur))D(t,S(e,o),Ur);t.set(Ni,".agentsmesh/mcp.json");return}t.set(ar,`${k}/_root.md`);for(let o of await C(e,se))D(t,S(e,o),se);t.set(xn,".agentsmesh/mcp.json");}var zC=u(()=>{It();rc();gt();s(Pf,"buildDeepagentsCliImportPaths");});var cr,lr,_e,Po,xo,Nn,Do,Fi,Ts,VC,vi=u(()=>{cr="factory-droid",lr="AGENTS.md",_e=".factory/skills",Po=".factory/droids",xo=".factory/mcp.json",Nn=".factory/AGENTS.md",Do=".factory/skills",Fi=".factory/droids",Ts=".factory/mcp.json",VC=".agentsmesh/rules";});async function xf(t,e,r="project"){if(r==="global"){t.set(Nn,`${k}/_root.md`);for(let o of await C(e,Fi))x(t,S(e,o),Ot,".md");for(let o of await C(e,Do))D(t,S(e,o),Do);t.set(Ts,".agentsmesh/mcp.json");return}t.set(lr,`${k}/_root.md`);for(let o of await C(e,Po))x(t,S(e,o),Ot,".md");for(let o of await C(e,_e))D(t,S(e,o),_e);t.set(xo,".agentsmesh/mcp.json");}var JC=u(()=>{It();vi();gt();s(xf,"buildFactoryDroidImportPaths");});async function Df(t,e){for(let r of await C(e,".gemini/rules"))x(t,S(e,r),k,".md");for(let r of await C(e,".gemini/commands")){let o=S(e,r);if(!o.endsWith(".toml")&&!o.endsWith(".md"))continue;let n=o.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",l=(n.startsWith(i)?n.slice(i.length):n).split("/").filter(Boolean).join(":");t.set(o,`${rt}/${l}.md`);}for(let r of await C(e,".gemini/agents"))x(t,S(e,r),Ot,".md");for(let r of await C(e,".gemini/skills"))D(t,S(e,r),".gemini/skills");}var YC=u(()=>{It();gt();s(Df,"buildGeminiCliImportPaths");});var No,mr,pe,Fn,XC,vn,Gi,pr,ZC,QC,oc=u(()=>{No="goose",mr=".goosehints",pe=".agents/skills",Fn=".gooseignore",XC=".config/goose",vn=`${XC}/.goosehints`,Gi=`${XC}/.gooseignore`,pr=".agents/skills",ZC=".agentsmesh/rules",QC=".agentsmesh/ignore";});async function Nf(t,e,r="project"){if(r==="global"){t.set(vn,`${k}/_root.md`);for(let o of await C(e,pr))D(t,S(e,o),pr);t.set(Gi,".agentsmesh/ignore");return}t.set(mr,`${k}/_root.md`);for(let o of await C(e,pe))D(t,S(e,o),pe);t.set(Fn,".agentsmesh/ignore");}var qC=u(()=>{It();oc();gt();s(Nf,"buildGooseImportPaths");});var Gn,Kr,tE,nc=u(()=>{Gn="jules",Kr="AGENTS.md",tE=".agentsmesh/rules";});async function Ff(t,e,r="project"){r!=="global"&&t.set(Kr,`${k}/_root.md`);}var eE=u(()=>{nc();gt();s(Ff,"buildJulesImportPaths");});var Mi,bs,jp,rE,Fo,oE,s0,zl,$i,Vl,sc,ic,Jl,Yl,Xl,Zl,Ql,i0,Up,ji,nE,vf,Kp,sE,iE,aE,cE,ac=u(()=>{Mi="junie",bs=".junie",jp=`${bs}/guidelines.md`,rE=`${bs}/ci-guidelines.md`,Fo=`${bs}/AGENTS.md`,oE="AGENTS.md",s0=`${bs}/mcp`,zl=`${s0}/mcp.json`,$i=`${bs}/skills`,Vl=`${bs}/rules`,sc=`${bs}/commands`,ic=`${bs}/agents`,Jl=".aiignore",Yl=".junie",Xl=`${Yl}/skills`,Zl=`${Yl}/agents`,Ql=`${Yl}/commands`,i0=`${Yl}/mcp`,Up=`${i0}/mcp.json`,ji=`${Yl}/AGENTS.md`,nE=".agents/skills",vf=".agentsmesh/rules/_root.md",Kp=".agentsmesh/rules",sE=".agentsmesh/commands",iE=".agentsmesh/agents",aE=".agentsmesh/mcp.json",cE=".agentsmesh/ignore";});async function Gf(t,e){t.set(jp,`${k}/_root.md`),t.set(Fo,`${k}/_root.md`),t.set("AGENTS.md",`${k}/_root.md`);for(let r of await C(e,".junie/rules"))x(t,S(e,r),k,".md");for(let r of await C(e,".junie/commands"))x(t,S(e,r),rt,".md");for(let r of await C(e,".junie/agents"))x(t,S(e,r),Ot,".md");for(let r of await C(e,".junie/skills"))D(t,S(e,r),".junie/skills");}var lE=u(()=>{It();ac();gt();s(Gf,"buildJunieImportPaths");});var ue,ql,vo,Mn,$n,jn,Br,Ps,cc,Bp,Ui,lc,Ki,tm,Wp,mc,xs,Bi,Wi,Hi,Ds,pc,Hp,mE,Ns,uc,zi,pE,uE,Vi=u(()=>{ue="kilo-code",ql=".kilo",vo="AGENTS.md",Mn=`${ql}/rules`,$n=`${ql}/commands`,jn=`${ql}/agents`,Br=`${ql}/skills`,Ps=`${ql}/mcp.json`,cc=".kilocodeignore",Bp=".kilocode",Ui=`${Bp}/rules`,lc=`${Bp}/workflows`,Ki=`${Bp}/skills`,tm=`${Bp}/mcp.json`,Wp=".kilocodemodes",mc=".kilo",xs=`${mc}/AGENTS.md`,Bi=`${mc}/rules`,Wi=`${mc}/commands`,Hi=`${mc}/agents`,Ds=`${mc}/skills`,pc=`${mc}/mcp.json`,Hp=".kilocodeignore",mE=".agents/skills",Ns=".agentsmesh/rules",uc=".agentsmesh/commands",zi=".agentsmesh/agents",pE=".agentsmesh/mcp.json",uE=".agentsmesh/ignore";});async function Mf(t,e,r="project"){if(r==="global"){t.set(xs,`${k}/_root.md`);for(let o of await C(e,Bi))x(t,S(e,o),k,".md");for(let o of await C(e,Wi))x(t,S(e,o),rt,".md");for(let o of await C(e,Hi))x(t,S(e,o),Ot,".md");for(let o of await C(e,Ds))D(t,S(e,o),Ds);t.set(pc,".agentsmesh/mcp.json");return}t.set(vo,`${k}/_root.md`);for(let o of await C(e,Mn))x(t,S(e,o),k,".md");for(let o of await C(e,$n))x(t,S(e,o),rt,".md");for(let o of await C(e,jn))x(t,S(e,o),Ot,".md");for(let o of await C(e,Br))D(t,S(e,o),Br);t.set(Ps,".agentsmesh/mcp.json");for(let o of await C(e,Ui)){let n=S(e,o);if(basename(n)==="00-root.md"){t.set(n,`${k}/_root.md`);continue}x(t,n,k,".md");}for(let o of await C(e,lc))x(t,S(e,o),rt,".md");for(let o of await C(e,Ki))D(t,S(e,o),Ki);t.set(tm,".agentsmesh/mcp.json");}var dE=u(()=>{It();Vi();gt();s(Mf,"buildKiloCodeImportPaths");});var De,Wr,em,Hr,de,zr,Fs,gE,dc,gc,Ji,Vr,vs,Yi,rm,om,fE,$f,jf,hE,yE,Uf,_E,fc=u(()=>{De="kiro",Wr="AGENTS.md",em=".kiro",Hr=`${em}/steering`,de=`${em}/skills`,zr=`${em}/agents`,Fs=`${em}/hooks`,gE=`${em}/settings`,dc=`${gE}/mcp.json`,gc=".kiroignore",Ji=".kiro/steering",Vr=".kiro/steering/AGENTS.md",vs=".kiro/skills",Yi=".kiro/agents",rm=".kiro/settings/mcp.json",om=".kiro/settings/kiroignore",fE=".agents/skills",$f=".agentsmesh/rules/_root.md",jf=".agentsmesh/rules",hE=".agentsmesh/agents",yE=".agentsmesh/mcp.json",Uf=".agentsmesh/hooks.yaml",_E=".agentsmesh/ignore";});async function Kf(t,e,r="project"){if(r==="global"){t.set(Vr,`${k}/_root.md`);for(let o of await C(e,Ji)){let n=S(e,o);n!==Vr&&x(t,n,k,".md");}for(let o of await C(e,vs))D(t,S(e,o),vs);for(let o of await C(e,Yi))x(t,S(e,o),Ot,".md");return}t.set(Wr,`${k}/_root.md`);for(let o of await C(e,Hr))x(t,S(e,o),k,".md");for(let o of await C(e,de))D(t,S(e,o),de);for(let o of await C(e,zr))x(t,S(e,o),Ot,".md");}var IE=u(()=>{It();fc();gt();s(Kf,"buildKiroImportPaths");});var Jr,zp,Go,Un,Kn,Bn,Yr,Mo,hc,Gs,Xi,Zi,Qi,Ms,$s,RE,nm,Vp,Jp,Bf,qi=u(()=>{Jr="opencode",zp=".opencode",Go="AGENTS.md",Un=`${zp}/rules`,Kn=`${zp}/commands`,Bn=`${zp}/agents`,Yr=`${zp}/skills`,Mo="opencode.json",hc=".config/opencode",Gs=`${hc}/AGENTS.md`,Xi=`${hc}/rules`,Zi=`${hc}/commands`,Qi=`${hc}/agents`,Ms=`${hc}/skills`,$s=`${hc}/opencode.json`,RE=".agents/skills",nm=".agentsmesh/rules",Vp=".agentsmesh/commands",Jp=".agentsmesh/agents",Bf=".agentsmesh/mcp.json";});async function Wf(t,e,r="project"){if(r==="global"){t.set(Gs,`${k}/_root.md`);for(let o of await C(e,Xi))x(t,S(e,o),k,".md");for(let o of await C(e,Zi))x(t,S(e,o),rt,".md");for(let o of await C(e,Qi))x(t,S(e,o),Ot,".md");for(let o of await C(e,Ms))D(t,S(e,o),Ms);t.set($s,".agentsmesh/mcp.json");return}t.set(Go,`${k}/_root.md`);for(let o of await C(e,Un))x(t,S(e,o),k,".md");for(let o of await C(e,Kn))x(t,S(e,o),rt,".md");for(let o of await C(e,Bn))x(t,S(e,o),Ot,".md");for(let o of await C(e,Yr))D(t,S(e,o),Yr);t.set(Mo,".agentsmesh/mcp.json");}var SE=u(()=>{It();qi();gt();s(Wf,"buildOpencodeImportPaths");});var $o,ur,Xt,CE,Wn,dr,EE,yc=u(()=>{$o="pi-agent",ur="AGENTS.md",Xt=".pi/skills",CE=".pi/agent",Wn=`${CE}/AGENTS.md`,dr=`${CE}/skills`,EE=".agentsmesh/rules";});async function Hf(t,e,r="project"){if(r==="global"){t.set(Wn,`${k}/_root.md`);for(let o of await C(e,dr))D(t,S(e,o),dr);return}t.set(ur,`${k}/_root.md`);for(let o of await C(e,Xt))D(t,S(e,o),Xt);}var zf=u(()=>{It();yc();gt();s(Hf,"buildPiAgentImportPaths");});var jo,gr,Hn,Uo,Ko,Ne,js,Us,zn,ta,Ks,Bo,Bs,Vf,OE,LE,_c=u(()=>{jo="qwen-code",gr="QWEN.md",Hn=".qwen/rules",Uo=".qwen/commands",Ko=".qwen/agents",Ne=".qwen/skills",js=".qwen/settings.json",Us=".qwenignore",zn=".qwen/QWEN.md",ta=".qwen/settings.json",Ks=".qwen/commands",Bo=".qwen/skills",Bs=".qwen/agents",Vf=".agentsmesh/rules",OE=".agentsmesh/commands",LE=".agentsmesh/agents";});async function Jf(t,e,r="project"){if(r==="global"){t.set(zn,`${k}/_root.md`),t.set(ta,".agentsmesh/mcp.json");for(let o of await C(e,Ks))x(t,S(e,o),rt,".md");for(let o of await C(e,Bs))x(t,S(e,o),Ot,".md");for(let o of await C(e,Bo))D(t,S(e,o),Bo);return}t.set(gr,`${k}/_root.md`),t.set(js,".agentsmesh/mcp.json"),t.set(Us,".agentsmesh/ignore");for(let o of await C(e,Hn))x(t,S(e,o),k,".md");for(let o of await C(e,Uo))x(t,S(e,o),rt,".md");for(let o of await C(e,Ko))x(t,S(e,o),Ot,".md");for(let o of await C(e,Ne))D(t,S(e,o),Ne);}var AE=u(()=>{It();gt();_c();s(Jf,"buildQwenCodeImportPaths");});var Wo,Xr,Ie,kE,Ic=u(()=>{Wo="replit-agent",Xr="replit.md",Ie=".agents/skills",kE=".agentsmesh/rules";});async function Yf(t,e,r="project"){if(r!=="global"){t.set(Xr,`${k}/_root.md`);for(let o of await C(e,Ie))D(t,S(e,o),Ie);}}var Xf=u(()=>{It();Ic();gt();s(Yf,"buildReplitAgentImportPaths");});var Ws,ea,Zr,sm,Vn,Jn,Ho,im,am,Rc,cm,Yp,Hs,zs,Yn,ra,lm,Vs,wE,oa,Xp,TE,bE,na=u(()=>{Ws="roo-code",ea=".roo",Zr=`${ea}/rules/00-root.md`,sm=".roorules",Vn=`${ea}/rules`,Jn=`${ea}/commands`,Ho=`${ea}/skills`,im=`${ea}/mcp.json`,am=".rooignore",Rc=".roomodes",cm="settings/custom_modes.yaml",Yp=".roo",Hs=`${Yp}/rules`,zs=`${Yp}/commands`,Yn=`${Yp}/skills`,ra="mcp_settings.json",lm=".rooignore",Vs=`${Yp}/AGENTS.md`,wE=".agents/skills",oa=".agentsmesh/rules",Xp=".agentsmesh/commands",TE=".agentsmesh/mcp.json",bE=".agentsmesh/ignore";});async function Zf(t,e,r="project"){if(r==="global"){t.set(Vs,`${k}/_root.md`);for(let o of await C(e,Hs))x(t,S(e,o),k,".md");for(let o of await C(e,zs))x(t,S(e,o),rt,".md");for(let o of await C(e,Yn))D(t,S(e,o),Yn);t.set(ra,".agentsmesh/mcp.json");return}t.set(Zr,`${k}/_root.md`),t.set(sm,`${k}/_root.md`);for(let o of await C(e,Vn)){let n=S(e,o);n!==Zr&&x(t,n,k,".md");}for(let o of await C(e,".roo")){let n=S(e,o);/^\.roo\/rules-[^/]+\/.+\.md$/.test(n)&&x(t,n,k,".md");}for(let o of await C(e,Jn))x(t,S(e,o),rt,".md");for(let o of await C(e,Ho))D(t,S(e,o),Ho);}var PE=u(()=>{It();na();gt();s(Zf,"buildRooCodeImportPaths");});var zo,fr,xE,Zt,Xn,DE,Zn,Fe,Sc,NE,Cc=u(()=>{zo="rovodev",fr="AGENTS.md",xE=".rovodev",Zt=`${xE}/skills`,Xn=`${xE}/mcp.json`,DE=".rovodev",Zn=".rovodev/AGENTS.md",Fe=".rovodev/skills",Sc=".rovodev/mcp.json",NE=".agentsmesh/rules";});async function Qf(t,e,r="project"){if(r==="global"){t.set(Zn,`${k}/_root.md`);for(let o of await C(e,Fe))D(t,S(e,o),Fe);t.set(Sc,".agentsmesh/mcp.json");return}t.set(fr,`${k}/_root.md`);for(let o of await C(e,Zt))D(t,S(e,o),Zt);t.set(Xn,".agentsmesh/mcp.json");}var FE=u(()=>{It();Cc();gt();s(Qf,"buildRovodevImportPaths");});var hr,Zp,ve,Ge,yr,sa,Ec,Qn,_r,Qr,mm,vE,pm,GE,ME,Oc=u(()=>{hr="trae",Zp=".trae",ve=`${Zp}/rules`,Ge=`${ve}/project_rules.md`,yr=`${Zp}/skills`,sa=`${Zp}/mcp.json`,Ec=`${Zp}/.ignore`,Qn=".trae/user_rules",_r=".trae/user_rules/rules.md",Qr=".trae/skills",mm=".trae/mcp.json",vE=".agents/skills",pm=".agentsmesh/rules",GE=".agentsmesh/mcp.json",ME=".agentsmesh/ignore";});async function qf(t,e,r="project"){if(r==="global"){t.set(_r,`${k}/_root.md`);for(let o of await C(e,Qn)){let n=S(e,o);n!==_r&&x(t,n,k,".md");}for(let o of await C(e,Qr))D(t,S(e,o),Qr);return}t.set(Ge,`${k}/_root.md`);for(let o of await C(e,ve)){let n=S(e,o);n!==Ge&&x(t,n,k,".md");}for(let o of await C(e,yr))D(t,S(e,o),yr);}var $E=u(()=>{It();Oc();gt();s(qf,"buildTraeImportPaths");});var Vo,qr,th,ie,Js,Re,jE,Lc=u(()=>{Vo="warp",qr="AGENTS.md",th="WARP.md",ie=".warp/skills",Js=".mcp.json",Re=".warp/skills",jE=".agentsmesh/rules";});async function eh(t,e,r="project"){if(r==="global"){for(let o of await C(e,Re))D(t,S(e,o),Re);return}t.set(qr,`${k}/_root.md`);for(let o of await C(e,ie))D(t,S(e,o),ie);t.set(Js,".agentsmesh/mcp.json");}var UE=u(()=>{It();Lc();gt();s(eh,"buildWarpImportPaths");});async function rh(t,e){t.set("AGENTS.md",`${k}/_root.md`),t.set(".windsurfrules",`${k}/_root.md`),await Ep(t,e);for(let r of await C(e,".windsurf/rules"))x(t,S(e,r),k,".md");for(let r of await C(e,".windsurf/workflows"))x(t,S(e,r),rt,".md");for(let r of await C(e,".windsurf/skills"))D(t,S(e,r),".windsurf/skills");}var KE=u(()=>{It();gt();s(rh,"buildWindsurfImportPaths");});var to,Jo,c0,Yo,BE,ia=u(()=>{to=".rules",Jo=".zed/settings.json",c0=".config/zed",Yo=`${c0}/settings.json`,BE=".agentsmesh/rules";});async function oh(t,e,r="project"){if(r==="global"){t.set(Yo,".agentsmesh/mcp.json");return}t.set(to,`${k}/_root.md`),t.set(Jo,".agentsmesh/mcp.json");}var WE=u(()=>{ia();gt();s(oh,"buildZedImportPaths");});var HE=u(()=>{IC();CC();OC();AC();kC();PC();FC();vC();GC();MC();jC();WC();zC();JC();YC();qC();eE();lE();dE();IE();SE();zf();AE();Xf();PE();FE();$E();UE();KE();WE();});var Rt=u(()=>{HE();});var l0,m0,p0,zE,Cp,Xg=u(()=>{St();at();XS();sC();pC();fC();Rt();Va();l0={name:fo,primaryRootInstructionPath:Ye,generateRules:HS,generateCommands:VS,generateAgents:JS,generateSkills:zS,generateIgnore:YS,importFrom:nC},m0={rootInstructionPath:Ye,skillDir:re,managedOutputs:{dirs:[re],files:[Ye,fn]},paths:{rulePath(t){return Ye},commandPath(t){return `${re}/${W(t)}/SKILL.md`},agentPath(t){return `${re}/${$(t)}/SKILL.md`}}},p0={rootInstructionPath:hn,skillDir:Xe,managedOutputs:{dirs:[Xe],files:[hn,Ii]},rewriteGeneratedPath(t){return t===Ye?hn:t===fn?Ii:t.startsWith(`${re}/`)?t.replace(`${re}/`,`${Xe}/`):t},paths:{rulePath(t){return hn},commandPath(t){return `${Xe}/${W(t)}/SKILL.md`},agentPath(t){return `${Xe}/${$(t)}/SKILL.md`}}},zE={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Cp={id:fo,metadata:{displayName:"Aider",category:"cli",officialUrl:"https://aider.chat",shortDescription:"Open-source terminal AI pair programmer"},generators:l0,capabilities:zE,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:mC,lint:{hooks:uC,permissions:dC,mcp:gC},supportsConversion:{commands:true,agents:true},project:m0,globalSupport:{capabilities:zE,detectionPaths:[hn,Ii,Xe],layout:p0},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ye],global:[hn]},canonicalDir:BS,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[fn],global:[Ii]},canonicalDir:".agentsmesh",canonicalFilename:WS}},buildImportPaths:tf,detectionPaths:[Ye,fn]};});function VE(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(Ri))continue;let o=r.root?"_root":basename(r.source,".md");e.push({path:`${Fr}/${o}.md`,content:r.body.trim()});}return e}function JE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Si,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var YE=u(()=>{bl();s(VE,"generateRules");s(JE,"generateMcp");});async function XE(t,e){let r=e?.scope??"project";return z(Qp,t,r)}var ZE=u(()=>{Ct();nh();s(XE,"importFromAmazonQ");});function QE(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Ri}))}var qE=u(()=>{_t();bl();s(QE,"lintRules");});var d0,g0,f0,h0,Qp,nh=u(()=>{YE();ZE();qE();Rt();bl();d0={name:Ri,generateRules:VE,generateMcp:JE,importFrom:XE},g0={managedOutputs:{dirs:[Fr],files:[Si]},paths:{rulePath(t,e){return `${Fr}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},f0={managedOutputs:{dirs:[Is],files:[Tl]},rewriteGeneratedPath(t){return t.startsWith(`${Fr}/`)?t.replace(`${Fr}/`,`${Is}/`):t===Si?Tl:t},paths:{rulePath(t,e){return `${Is}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},h0={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Qp={id:Ri,metadata:{displayName:"Amazon Q Developer",category:"ide",officialUrl:"https://aws.amazon.com/q/developer",shortDescription:"AWS AI coding assistant"},generators:d0,capabilities:{rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Amazon Q Developer config found (.amazonq/rules/ or .amazonq/mcp.json).",lintRules:QE,project:g0,globalSupport:{capabilities:h0,detectionPaths:[Is,Tl],layout:f0},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Fr],global:[Is]},canonicalDir:RC,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Si],global:[Tl]},canonicalDir:".agentsmesh",canonicalFilename:SC}},buildImportPaths:ef,detectionPaths:[Fr,Si]};});function tO(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("amp")),o=e?.body.trim()??"",n=st(o,r);return n?[{path:qe,content:n}]:[]}function eO(t){return tt(t,oe)}function rO(t){return t.commands.map(e=>({path:`${oe}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function oO(t){return t.agents.map(e=>({path:`${oe}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}var nO=u(()=>{Q();Mt();at();St();Ci();s(tO,"generateRules");s(eO,"generateSkills");s(rO,"generateCommands");s(oO,"generateAgents");});function ct(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var Qt=u(()=>{s(ct,"mirrorSkillsToAgents");});async function iO(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let i=n,a=i["amp.mcpServers"]??i.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await $t(t,sO,c),r.push({fromTool:"amp",fromPath:e,toPath:sO,feature:"mcp"}));}var sO,aO=u(()=>{T();Nr();Ci();sO=".agentsmesh/mcp.json";s(iO,"importAmpMcp");});async function cO(t,e={}){let r=e.scope??"project",o=[],n=await U("amp",t,r);return o.push(...await z(qp,t,r,{normalize:n})),await Z(t,r==="global"?tr:oe,"amp",o,n),await iO(t,r==="global"?In:yo,o),o}var lO=u(()=>{mt();Q();Ct();aO();Ci();sh();s(cO,"importFromAmp");});function mO(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:"amp"}))}var pO=u(()=>{_t();Ci();s(mO,"lintRules");});function uO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function dO(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function gO(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var fO=u(()=>{Et();s(uO,"lintHooks");s(dO,"lintPermissions");s(gO,"lintIgnore");});function S0(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n["amp.mcpServers"]!==void 0&&(r["amp.mcpServers"]=n["amp.mcpServers"]),JSON.stringify(r,null,2)}var _0,I0,R0,hO,qp,sh=u(()=>{St();at();nO();Qt();lO();pO();fO();Rt();Ci();_0={name:"amp",primaryRootInstructionPath:qe,generateRules:tO,generateCommands:rO,generateAgents:oO,generateSkills:eO,importFrom:cO},I0={rootInstructionPath:qe,skillDir:oe,managedOutputs:{dirs:[oe],files:[qe,yo]},paths:{rulePath(t){return qe},commandPath(t){return `${oe}/${W(t)}/SKILL.md`},agentPath(t){return `${oe}/${$(t)}/SKILL.md`}}},R0={rootInstructionPath:_n,skillDir:tr,managedOutputs:{dirs:[tr],files:[_n,In]},rewriteGeneratedPath(t){return t===qe?_n:t===yo?In:t.startsWith(`${oe}/`)?t.replace(`${oe}/`,`${tr}/`):t},mirrorGlobalPath(t,e){return ct(t,tr,e)},paths:{rulePath(t){return _n},commandPath(t){return `${tr}/${W(t)}/SKILL.md`},agentPath(t){return `${tr}/${$(t)}/SKILL.md`}}},hO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(S0,"mergeAmpSettings");qp={id:"amp",metadata:{displayName:"Amp",category:"cli",officialUrl:"https://ampcode.com",shortDescription:"Sourcegraph's coding agent"},generators:_0,capabilities:hO,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:mO,lint:{hooks:uO,permissions:dO,ignore:gO},supportsConversion:{commands:true,agents:true},project:I0,globalSupport:{capabilities:hO,detectionPaths:[_n,In],layout:R0},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[qe],global:[_n]},canonicalDir:EC,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:yo,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,o){return o===yo||o===In?S0(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:of,detectionPaths:[qe,yo]};});function yO(t){let e=t.rules.find(o=>o.root);if(!e)return [];let r=[{path:vr,content:e.body.trim()||""}];for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("antigravity"))continue;let n=basename(o.source,".md");r.push({path:`${_o}/${n}.md`,content:o.body.trim()||""});}return r}function _O(t){return t.commands.map(e=>{let r=e.description.trim(),o=e.body.trim(),n=r&&o&&!o.startsWith(r)?`${r}
|
|
53
53
|
|
|
54
|
-
${o}`:o||r;return {path:`${
|
|
55
|
-
`)}]}var
|
|
56
|
-
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"));if(n.length===0)return;let i=join(t,
|
|
57
|
-
`)),r.push({fromTool:
|
|
54
|
+
${o}`:o||r;return {path:`${Rn}/${e.name}.md`,content:n}})}function IO(t){return tt(t,Gr)}function RO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:xl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function SO(t){return t.agents.map(e=>({path:`${Gr}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function CO(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>o.root?false:o.targets.length===0||o.targets.includes("antigravity"));return st(e?.body.trim()??"",r)}var EO=u(()=>{Q();Mt();at();Li();s(yO,"generateRules");s(_O,"generateCommands");s(IO,"generateSkills");s(RO,"generateMcp");s(SO,"generateAgents");s(CO,"renderAntigravityGlobalInstructions");});function E0(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function Xo(t){let e=NS(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await L(join(t.projectRoot,t.rulesDir));for(let o of e.rules){let n=E0(o.source);if(n===null||n==="rules/_root.md")continue;let i=join(t.projectRoot,".agentsmesh",n),a=t.normalize(o.body,t.sourcePath,i),{frontmatter:c,body:l}=w(a),m=await K(i,{...c,root:false,description:o.description||void 0,globs:o.globs.length>0?o.globs:void 0,targets:o.targets.length>0?o.targets:void 0},l);await I(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${n}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var Ac=u(()=>{T();M();Mt();lt();s(E0,"canonicalRulePath");s(Xo,"splitEmbeddedRulesToCanonical");});async function O0(t,e,r,o){let n=o==="global"?Io:vr,i=o==="project"?[n,Pl]:[n];for(let a of i){let c=join(t,a),l=await y(c);if(l===null)continue;let m=join(t,nf),p=await Xo({content:l,projectRoot:t,rulesDir:Oi,sourcePath:c,fromTool:Ei,normalize:r});e.push(...p.results);let{body:d}=w(r(p.rootContent,c,m)),g=await K(m,{root:true},d);await L(join(t,Oi)),await I(m,g),e.push({fromTool:Ei,fromPath:c,toPath:nf,feature:"rules"});return}}async function LO(t,e={}){let r=e.scope??"project",o=[],n=await U(Ei,t,r);return await O0(t,o,n,r),o.push(...await z(tu,t,r,{normalize:n})),await Z(t,r==="global"?Sn:Gr,Ei,o,n),o}var AO=u(()=>{mt();T();M();Q();Ct();lt();Ac();Li();ah();s(O0,"importRootRule");s(LO,"importFromAntigravity");});var TO,bO,PO=u(()=>{M();lt();Li();TO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Oi}/${t}`,content:await K(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"nonRootRuleMapper"),bO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Lp}/${t}`,content:await ht(o,{hasDescription:typeof n.description=="string",description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function xO(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Ei}))}var DO=u(()=>{_t();Li();s(xO,"lintRules");});var L0,A0,k0,w0,tu,ah=u(()=>{_i();at();EO();Li();AO();PO();DO();Rt();L0={name:"antigravity",primaryRootInstructionPath:vr,generateRules:yO,generateCommands:_O,generateAgents:SO,generateSkills:IO,generateMcp:RO,importFrom:LO},A0={rootInstructionPath:vr,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===xl?null:t},paths:{rulePath(t,e){return `${_o}/${t}.md`},commandPath(t,e){return `${Rn}/${t}.md`},agentPath(t){return `${Gr}/${$(t)}/SKILL.md`}}},k0={rootInstructionPath:Io,renderPrimaryRootInstruction:CO,skillDir:Sn,managedOutputs:{dirs:[Sn,Dl],files:[Io,Ja]},rewriteGeneratedPath(t){return t===vr?Io:t.startsWith(`${_o}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",Sn):t.startsWith(`${Rn}/`)?t.replace(Rn,Dl):t===xl?Ja:t},paths:{rulePath(t,e){return Io},commandPath(t,e){return `${Dl}/${t}.md`},agentPath(t){return `${Gr}/${$(t)}/SKILL.md`}}},w0={rules:"native",additionalRules:"embedded",commands:Dr("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},tu={id:"antigravity",metadata:{displayName:"Antigravity",category:"ide",officialUrl:"https://antigravity.google",shortDescription:"Google's agentic IDE"},generators:L0,capabilities:{rules:"native",additionalRules:"native",commands:Dr("partial","workflows"),agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Antigravity config found (.agents/rules/, .agents/skills/, or .agents/workflows/).",supportsConversion:{agents:true},lintRules:xO,project:A0,globalSupport:{capabilities:w0,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:k0},importer:{rules:{feature:"rules",mode:"directory",source:{project:[_o]},canonicalDir:Oi,extensions:[".md"],map:TO},commands:{feature:"commands",mode:"directory",source:{project:[Rn],global:[Dl]},canonicalDir:Lp,extensions:[".md"],map:bO},mcp:{feature:"mcp",mode:"flatFile",source:{global:[Ja]},canonicalDir:".agentsmesh",canonicalFilename:LC}},buildImportPaths:sf,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function b0(t){let e={};return t.description&&(e.description=t.description),t.globs.length>0||t.trigger==="manual"||t.trigger==="model_decision"?(e.agent_requested=true,t.globs.length>0&&(e.globs=t.globs)):e.always_apply=true,e}function P0(t){let e={};return t.description&&(e.description=t.description),e}function NO(t){let e=[];for(let r of t.rules)if(!(r.targets.length>0&&!r.targets.includes(ne)))if(r.root){let o={always_apply:true};r.description&&(o.description=r.description),e.push({path:`${we}/_root.md`,content:P(o,r.body.trim())});}else {let o=basename(r.source,".md");e.push({path:`${we}/${o}.md`,content:P(b0(r),r.body.trim())});}return e}function FO(t){return t.commands.map(e=>({path:`${er}/${e.name}.md`,content:P(P0(e),e.body.trim())}))}function vO(t){return tt(t,Te)}function GO(t){return t.ignore.length===0?[]:[{path:So,content:t.ignore.join(`
|
|
55
|
+
`)}]}var MO=u(()=>{Q();M();Ai();s(b0,"ruleFrontmatter");s(P0,"commandFrontmatter");s(NO,"generateRules");s(FO,"generateCommands");s(vO,"generateSkills");s(GO,"generateIgnore");});function D0(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:".*",l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=typeof m.command=="string"?m.command:void 0;if(!p)continue;let d={matcher:c,type:"command",command:p};typeof m.timeout=="number"&&(d.timeout=m.timeout),n.push(d);}}n.length>0&&(e[r]=n);}return e}async function jO(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n.mcpServers&&typeof n.mcpServers=="object"){let a=n.mcpServers;await $t(t,cf,a),r.push({fromTool:ne,fromPath:join(t,e),toPath:cf,feature:"mcp"});}let i=n.hooks;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=D0(i);if(Object.keys(a).length>0){let c=join(t,lf);await L(dirname(c)),await I(c,stringify(a)),r.push({fromTool:ne,fromPath:join(t,e),toPath:lf,feature:"hooks"});}}}async function UO(t,e,r){let o=await y(join(t,e));if(o===null)return;let n=o.split(`
|
|
56
|
+
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"));if(n.length===0)return;let i=join(t,mf);await L(dirname(i)),await I(i,n.join(`
|
|
57
|
+
`)),r.push({fromTool:ne,fromPath:join(t,e),toPath:mf,feature:"ignore"});}var KO=u(()=>{T();Nr();Ai();s(D0,"augmentHooksToCanonical");s(jO,"importAugmentSettings");s(UO,"importAugmentIgnore");});function N0(t,e){let r={root:e,description:typeof t.description=="string"?t.description:void 0,globs:Array.isArray(t.globs)?t.globs:[]};return t.agent_requested===true&&(r.trigger="model_decision"),r}async function F0(t,e,r,o){let n=o==="global"?Cn:we,i=join(t,af);e.push(...await yt({srcDir:join(t,n),destDir:i,extensions:[".md"],fromTool:ne,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:c})=>{let l=a==="_root.md"||basename(a)==="_root.md",m=join(i,a),{frontmatter:p,body:d}=w(c(m));return {destPath:m,toPath:`${af}/${a}`,feature:"rules",content:await K(m,N0(p,l),d)}},"mapEntry")}));}async function v0(t,e,r,o){let n=o==="global"?En:er,i=join(t,".agentsmesh/commands");e.push(...await yt({srcDir:join(t,n),destDir:i,extensions:[".md"],fromTool:ne,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:c})=>{let l=basename(a,".md"),m=join(i,`${l}.md`),{frontmatter:p,body:d}=w(c(m)),g=typeof p.description=="string"?p.description:"";return {destPath:m,toPath:`.agentsmesh/commands/${l}.md`,feature:"commands",content:await ht(m,{description:g,hasDescription:true,hasAllowedTools:false},d)}},"mapEntry")}));}async function WO(t,e={}){let r=e.scope??"project",o=[],n=await U(ne,t,r);return await F0(t,o,n,r),await v0(t,o,n,r),await Z(t,r==="global"?Co:Te,ne,o,n),await jO(t,r==="global"?On:Ro,o),r==="project"&&await UO(t,So,o),o}var HO=u(()=>{mt();ke();Q();lt();M();KO();Ai();s(N0,"canonicalRuleMeta");s(F0,"importRules");s(v0,"importCommands");s(WO,"importFromAugmentCode");});function zO(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:ne}))}var VO=u(()=>{_t();Ai();s(zO,"lintRules");});function YO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=new Set(JO);return Object.keys(t.hooks).filter(r=>!e.has(r)).map(r=>_s(r,"augment-code",JO,{unsupportedBy:"AugmentCode hooks"}))}var JO,XO=u(()=>{Et();JO=["PreToolUse","PostToolUse","SessionStart","SessionEnd","Stop"];s(YO,"lintHooks");});function M0(t){let e={};for(let[r,o]of Object.entries(t)){if(!o||o.length===0)continue;let n=o.map(i=>({matcher:i.matcher,hooks:[{type:"command",command:i.command,...i.timeout!==void 0?{timeout:i.timeout}:{}}]}));e[r]=n;}return e}function $0(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n.mcpServers!==void 0&&(r.mcpServers=n.mcpServers),n.hooks!==void 0&&(r.hooks=n.hooks),JSON.stringify(r,null,2)}function j0(t){let e={};return t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&(e.mcpServers=t.mcp.mcpServers),t.hooks&&Object.keys(t.hooks).length>0&&(e.hooks=M0(t.hooks)),Object.keys(e).length===0?null:JSON.stringify(e,null,2)}var G0,U0,K0,B0,W0,ZO,QO=u(()=>{MO();HO();VO();XO();Rt();Ai();G0={name:ne,generateRules:NO,generateCommands:FO,generateSkills:vO,generateIgnore:GO,importFrom:WO};s(M0,"serializeHooksForSettings");s($0,"mergeAugmentSettings");s(j0,"buildSettingsContent");U0={skillDir:Te,managedOutputs:{dirs:[we,er,Te],files:[Ro,So]},paths:{rulePath(t){return `${we}/${t}.md`},commandPath(t){return `${er}/${t}.md`},agentPath(t){return null}}},K0={skillDir:Co,managedOutputs:{dirs:[Cn,En,Co],files:[On]},rewriteGeneratedPath(t){return t.startsWith(`${we}/`)?t.replace(`${we}/`,`${Cn}/`):t.startsWith(`${er}/`)?t.replace(`${er}/`,`${En}/`):t.startsWith(`${Te}/`)?t.replace(`${Te}/`,`${Co}/`):t===Ro?On:t===So?null:t},paths:{rulePath(t){return `${Cn}/${t}.md`},commandPath(t){return `${En}/${t}.md`},agentPath(t){return null}}},B0={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},W0={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ZO={id:ne,metadata:{displayName:"Augment Code",category:"ide",officialUrl:"https://www.augmentcode.com",shortDescription:"Codebase-aware AI for IDEs"},generators:G0,capabilities:B0,emptyImportMessage:"No AugmentCode config found (.augment/rules, .augment/commands, .augment/skills, .augment/settings.json, or .augmentignore).",lintRules:zO,lint:{hooks:YO},project:U0,globalSupport:{capabilities:W0,detectionPaths:[Cn,En,Co,On],layout:K0},emitScopedSettings(t){let e=j0(t);return e===null?[]:[{path:Ro,content:e}]},mergeGeneratedOutputContent(t,e,r,o){return o===Ro||o===On?$0(t,r):null},buildImportPaths:pf,detectionPaths:[we,er,Te,Ro,So]};});function qO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,o]of Object.entries(t.hooks)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!po(i))continue;let a=Kt(i),c=le(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),n.push({matcher:i.matcher,hooks:[m]});}n.length>0&&(e[r]=n);}return e}var tL=u(()=>{br();s(qO,"buildClaudeHooksObjectFromCanonical");});function eL(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Rs,content:r.body.trim()?r.body:""});let o=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes("claude-code")));for(let n of o){let i=basename(n.source,".md"),a={};n.description&&(a.description=n.description),n.globs.length>0&&(a.globs=n.globs);let c=P(a,n.body.trim()||"");e.push({path:`${Nl}/${i}.md`,content:c});}return e}function rL(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let o=P(r,e.body.trim()||"");return {path:`${Fl}/${e.name}.md`,content:o}})}function oL(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(a=>{r[a]===void 0&&delete r[a];});let o=e.body.trim()||"",n=/^##\s*Role\b/m.test(o)?o:`## Role
|
|
58
58
|
|
|
59
|
-
${o}`,i=P(r,n);return {path:`${
|
|
59
|
+
${o}`,i=P(r,n);return {path:`${vl}/${e.name}.md`,content:i}})}function nL(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Ya,content:e}]}function sL(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=r.body.trim()||"",i=!n||/^##\s*Purpose\b/m.test(n)?n:`## Purpose
|
|
60
60
|
|
|
61
|
-
${n}`,a=P(o,i);e.push({path:`${
|
|
62
|
-
`);return [{path
|
|
61
|
+
${n}`,a=P(o,i);e.push({path:`${Gl}/${r.name}/SKILL.md`,content:a});for(let c of r.supportingFiles){let l=c.relativePath.replace(/\\/g,"/");e.push({path:`${Gl}/${r.name}/${l}`,content:c.content});}}return e}function iL(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];if(e.length===0&&r.length===0&&o.length===0)return [];let n=JSON.stringify({permissions:{allow:e,deny:r,ask:o}},null,2);return [{path:Ml,content:n}]}function aL(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=qO(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:Ln,content:JSON.stringify(r,null,2)}];let o=JSON.stringify({hooks:r},null,2);return [{path:Ml,content:o}]}function cL(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
62
|
+
`);return [{path:$l,content:e}]}var lL=u(()=>{M();An();tL();s(eL,"generateRules");s(rL,"generateCommands");s(oL,"generateAgents");s(nL,"generateMcp");s(sL,"generateSkills");s(iL,"generatePermissions");s(aL,"generateHooks");s(cL,"generateIgnore");});function V0(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function mL(t){let e=t.rules.find(n=>n.root),r=(e?.body??"").trim();return r?`# Global Instructions
|
|
63
63
|
|
|
64
64
|
## ${e?V0(e):"Guidance"}
|
|
65
65
|
|
|
66
66
|
${r}
|
|
67
|
-
`:""}var
|
|
67
|
+
`:""}var pL=u(()=>{s(V0,"ruleSectionTitle");s(mL,"renderClaudeGlobalPrimaryInstructions");});function dL(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function gL(t,e,r,o){if(r!=="global")return [];let n=o.has("agents"),i=o.has("commands");if(!n&&!i)return [];let a=[];if(n)for(let c of t.agents){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=P(l,c.body.trim()),p=`${uf}/${c.name}.md`,d=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:d??void 0,status:dL(d,m)});}if(i)for(let c of t.commands){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=P(l,c.body.trim()),p=`${uf}/${c.name}.md`,d=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:d??void 0,status:dL(d,m)});}return a}var fL=u(()=>{T();M();An();s(dL,"computeStatus");s(gL,"generateClaudeGlobalExtras");});var hL,yL,_L,IL=u(()=>{M();lt();Qe();An();hL=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Ul}/${t}`,content:await K(o,{...n,root:false},i)}},"claudeRuleMapper"),yL=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o)),a=Ze(n.allowedTools),c=a.length>0?a:Ze(n["allowed-tools"]);return {destPath:o,toPath:`${wp}/${t}`,content:await ht(o,{description:typeof n.description=="string"?n.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}},"claudeCommandMapper"),_L=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Tp}/${t}`,content:await Bt(o,n,i)}},"claudeAgentMapper");});function RL(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:wC}))}var SL=u(()=>{_t();An();s(RL,"lintRules");});var J0,CL,Y0,X0,eu,lh=u(()=>{lL();An();Qt();pL();fL();mh();IL();SL();Rt();J0={name:"claude-code",primaryRootInstructionPath:Rs,generateRules:eL,generateCommands:rL,generateAgents:oL,generateSkills:sL,generateMcp:nL,generatePermissions:iL,generateHooks:aL,generateIgnore:cL,importFrom:ru},CL={rootInstructionPath:Rs,skillDir:".claude/skills",managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",".claudeignore",".mcp.json"]},paths:{rulePath(t,e){return `.claude/rules/${t}.md`},commandPath(t,e){return `.claude/commands/${t}.md`},agentPath(t,e){return `.claude/agents/${t}.md`}}},Y0={rootInstructionPath:Rs,skillDir:".claude/skills",renderPrimaryRootInstruction:mL,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",jl,Ln,".claudeignore"]},rewriteGeneratedPath(t){return t===Ya?jl:t},mirrorGlobalPath(t,e){return ct(t,".claude/skills",e)},paths:CL.paths},X0={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},eu={id:"claude-code",metadata:{displayName:"Claude Code",category:"cli",officialUrl:"https://www.anthropic.com/claude-code",shortDescription:"Anthropic's terminal coding agent"},generators:J0,capabilities:{rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},emptyImportMessage:"No Claude Code config found (CLAUDE.md or .claude/rules/*.md).",lintRules:RL,project:CL,globalSupport:{capabilities:X0,detectionPaths:[".claude/CLAUDE.md",".claude/rules",".claude/commands",".claude/agents",".claude/skills",".claude/settings.json",".claude/hooks.json",".claude/output-styles",".claudeignore",".claude.json",".agents/skills"],layout:Y0,scopeExtras:gL},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Rs,TC],global:[Rs]},canonicalDir:Ul,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Nl],global:[Nl]},canonicalDir:Ul,extensions:[".md"],map:hL}],commands:{feature:"commands",mode:"directory",source:{project:[Fl],global:[Fl]},canonicalDir:wp,extensions:[".md"],map:yL},agents:{feature:"agents",mode:"directory",source:{project:[vl],global:[vl]},canonicalDir:Tp,extensions:[".md"],map:_L},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ya],global:[jl]},canonicalDir:".agentsmesh",canonicalFilename:Kl},ignore:{feature:"ignore",mode:"flatFile",source:{project:[$l],global:[$l]},canonicalDir:".agentsmesh",canonicalFilename:bC}},buildImportPaths:ff,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function Q0(t){let e=basename(t,".md");return e==="_root"?"root":e}function EL(t){let e=[],r=t.rules.find(o=>o.root);if(r){let o=r.body.trim()?r.body:"";e.push({path:Cs,content:o});}for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("cline"))continue;let n=Q0(o.source),i={description:o.description||void 0,paths:o.globs.length>0?o.globs:void 0};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=Object.keys(i).length>0?P(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${kn}/${n}.md`,content:a});}return e}function OL(t){return t.commands.map(e=>{let r=e.description.trim(),o=e.body.trim(),n=r&&o?`${r}
|
|
68
68
|
|
|
69
|
-
${o}`:r||o;return {path:`${
|
|
70
|
-
`);return [{path:
|
|
71
|
-
`)}function
|
|
69
|
+
${o}`:r||o;return {path:`${Eo}/${e.name}.md`,content:n}})}function LL(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
70
|
+
`);return [{path:wi,content:e}]}function AL(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:wn,content:e}]}function kL(t){return t.agents.map(e=>({path:`${Jt}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function q0(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function ph(t){return t.replace(/[\r\n]+/g," ")}function tK(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${ph(t)}`,`# agentsmesh-matcher: ${ph(r)}`,`# agentsmesh-command: ${ph(e)}`,"set -eu",e,""].join(`
|
|
71
|
+
`)}function wL(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.hooks)){if(!Array.isArray(o))continue;let n=0;for(let i of o)dn(i)&&(e.push({path:`${Ti}/${q0(r)}-${n}.sh`,content:tK(r,i.command,i.matcher)}),n++);}return e}function TL(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${Jt}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Jt}/${r.name}/${a}`,content:i.content});}}return e}var bL=u(()=>{br();M();at();rr();s(Q0,"ruleSlug");s(EL,"generateRules");s(OL,"generateCommands");s(LL,"generateIgnore");s(AL,"generateMcp");s(kL,"generateAgents");s(q0,"safeEventName");s(ph,"safeShellLine");s(tK,"buildHookScript");s(wL,"generateHooks");s(TL,"generateSkills");});async function xL(t,e,r){if(t==="workflows"||t.startsWith("workflows/"))return null;let o=t.replace(/\\/g,"/");if(o==="_root.md")return null;let n=join(e,o),{frontmatter:i,body:a}=w(r(n)),c=yn(i.paths??i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:n,toPath:`${Es}/${o}`,feature:"rules",content:await K(n,l,a)}}async function DL(t,e,r){let o=join(e,t),{frontmatter:n,body:i}=w(r(o)),a=Object.prototype.hasOwnProperty.call(n,"description"),c=a&&typeof n.description=="string"?n.description:"",l=a,m=i;if(!l){let p=i.indexOf(`
|
|
72
72
|
|
|
73
|
-
`);if(p>0){let
|
|
74
|
-
`)&&(c=
|
|
75
|
-
`)),e.push({fromTool:"cline",fromPath:n,toPath:
|
|
73
|
+
`);if(p>0){let d=i.slice(0,p).trim();d&&!d.includes(`
|
|
74
|
+
`)&&(c=d,l=true,m=i.slice(p+2));}}return {destPath:o,toPath:`${bp}/${t}`,feature:"commands",content:await ht(o,{description:c,hasDescription:l,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},m)}}var uh=u(()=>{M();lt();Qe();rr();s(xL,"mapClineRuleFile");s(DL,"mapClineWorkflowFile");});async function NL(t,e,r){let o=join(t,Es),n=join(t,kn),i=join(t,kn),a=false;try{a=(await stat(i)).isFile();}catch{}if(a){let p=await y(i);if(p!==null){await L(o);let d=join(o,"_root.md"),{frontmatter:g,body:f}=w(r(p,i,d)),O=g.root===true?g:{...g,root:true},R=await K(d,O,f);await I(d,R),e.push({fromTool:"cline",fromPath:i,toPath:`${Es}/_root.md`,feature:"rules"});}return a}let c=null,l=join(n,"_root.md"),m=await y(l);if(m===null){let p=join(t,Cs),d=await y(p);if(d!==null){c=p,await L(o);let g=join(o,"_root.md"),{frontmatter:f,body:h}=w(r(d,p,g)),R=f.root===true?f:{...f,root:true},E=await K(g,R,h);await I(g,E),e.push({fromTool:"cline",fromPath:p,toPath:`${Es}/_root.md`,feature:"rules"});}else {let h=(await N(n)).filter(O=>O.endsWith(".md")&&!O.includes("/workflows/")).sort()[0];if(h){let O=await y(h);if(O!==null){c=h,await L(o);let R=join(o,"_root.md"),{frontmatter:E,body:A}=w(r(O,h,R)),v=E.root===true?E:{...E,root:true},G=await K(R,v,A);await I(R,G),e.push({fromTool:"cline",fromPath:h,toPath:`${Es}/_root.md`,feature:"rules"});}}}}else {c=l,await L(o);let p=join(o,"_root.md"),{frontmatter:d,body:g}=w(r(m,l,p)),h=d.root===true?d:{...d,root:true},O=await K(p,h,g);await I(p,O),e.push({fromTool:"cline",fromPath:l,toPath:`${Es}/_root.md`,feature:"rules"});}return e.push(...await yt({srcDir:n,destDir:o,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:d,normalizeTo:g})=>p===c?null:xL(d,o,g),"mapEntry")})),a}var FL=u(()=>{T();M();lt();ke();uh();rr();s(NL,"importClineRules");});function rK(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let o=typeof e.type=="string"?e.type:typeof e.transportType=="string"?e.transportType:"stdio",n=Array.isArray(e.args)?e.args.filter(l=>typeof l=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(l=>typeof l[1]=="string")):{},c=typeof e.description=="string"?e.description:void 0;return {...c!==void 0&&{description:c},type:o,command:r,args:n,env:a}}async function vL(t,e){let r=[wn,xC].map(l=>join(t,l)),o=null,n=null;for(let l of r){let m=await y(l);if(m!==null){o=l,n=m;break}}if(n===null)return;let i=o??r[0],a;try{a=JSON.parse(n);}catch{}let c=a?.mcpServers;if(c!==void 0&&typeof c=="object"&&c!==null&&Object.keys(c).length>0){let l={};for(let[m,p]of Object.entries(c)){let d=rK(p);d&&(l[m]=d);}Object.keys(l).length>0&&(await L(join(t,".agentsmesh")),await I(join(t,_f),JSON.stringify({mcpServers:l},null,2)),e.push({fromTool:Ss,fromPath:i,toPath:_f,feature:"mcp"}));}}var GL=u(()=>{T();rr();s(rK,"mapClineServerToCanonical");s(vL,"importClineMcp");});function ML(t){return oK.some(e=>e.test(t))}var oK,$L=u(()=>{oK=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(ML,"isReservedArtifactName");});async function sK(t){let e=await N(t).catch(()=>[]),r=[];for(let o of e){let n=relative(t,o).replace(/\\/g,"/"),i=basename(n);if(ML(i))continue;let a=await y(o);a!==null&&r.push({absolutePath:o,relativePath:n,content:a});}return r}async function um(t,e,r){let o=await sK(e),n=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of o){let a=join(n,i.relativePath);await L(dirname(a));let c=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:l,body:m}=w(c),p=await uo(a,{...l,name:t},m);await I(a,p);}else await I(a,c);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function UL(t,e,r,o){let n=join(o.projectRoot,o.destCanonicalSkillsDir,t);await L(n);let i=join(n,"SKILL.md"),a=o.normalize(r,e,i),{frontmatter:c,body:l}=w(a),m=await uo(i,{...c,name:t},l);await I(i,m),o.results.push({fromTool:o.targetName,fromPath:e,toPath:`${o.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function dm(t){let e=new Map;try{let o=(await N(t)).filter(n=>basename(n)==="SKILL.md");for(let n of o){let i=dirname(n),a=basename(i);e.set(a,i);}}catch{}return e}async function wc(t,e,r=[]){for(let o of t){let n=join(e.projectRoot,o),i=await dm(n);if(i.size===0)continue;let a=false;for(let[c,l]of i){let m=join(l,"SKILL.md"),p=await y(m);if(p===null)continue;a=true;let{frontmatter:d,body:g}=w(p),f={skillName:c,skillDir:l,skillMdPath:m,rawContent:p,frontmatter:d,rawBody:g,options:e},h=false;for(let O of r)if(await O.recognize(f)){h=true;break}h||await um(c,l,e);}if(a)return}}function Tc(t){return {async recognize(e){let r=Wa(e.frontmatter,e.skillName);if(!r)return false;let{options:o}=e;await go(join(o.projectRoot,o.destCanonicalSkillsDir,e.skillName));let n=join(o.projectRoot,t.canonicalAgentsDir);await L(n);let i=join(n,`${r.name}.md`),a=o.normalize(e.rawBody,e.skillMdPath,i);return await I(i,fs(r,a)),o.results.push({fromTool:o.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalAgentsDir}/${r.name}.md`,feature:"agents"}),true}}}function KL(t){return {async recognize(e){let r=hp(e.frontmatter,e.skillName);if(!r)return false;let{options:o}=e;await go(join(o.projectRoot,o.destCanonicalSkillsDir,e.skillName));let n=join(o.projectRoot,t.canonicalCommandsDir);await L(n);let i=join(n,`${r.name}.md`),a=o.normalize(e.rawBody,e.skillMdPath,i);return await I(i,yp(r,a)),o.results.push({fromTool:o.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalCommandsDir}/${r.name}.md`,feature:"commands"}),true}}}var bc=u(()=>{T();M();lt();$L();at();St();Al();s(sK,"readNativeSkill");s(um,"importDirectorySkill");s(UL,"importFlatSkill");s(dm,"findDirectorySkills");s(wc,"importSkillsDirectory");s(Tc,"projectedAgentRecognizer");s(KL,"commandSkillRecognizer");});async function BL(t,e,r,o=Jt){await wc([o],{projectRoot:t,destCanonicalSkillsDir:NC,targetName:"cline",normalize:r,results:e},[Tc({canonicalAgentsDir:DC})]);}var WL=u(()=>{bc();rr();s(BL,"importClineSkills");});function fh(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function HL(t,e){let o=(await N(t).catch(()=>[])).filter(n=>basename(n).endsWith(".sh")&&dirname(n)===t);for(let n of o){let i=await y(n);if(!i)continue;let a=fh(i,"event"),c=fh(i,"command");if(!a||!c)continue;let l=fh(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:l,command:c});}}async function VL(t,e){let r={};if(await HL(join(t,Ti),r),await HL(join(t,xi),r),Object.keys(r).length===0)return;let o=join(t,hf);await L(dirname(o)),await I(o,stringify(r)),e.push({fromTool:Ss,fromPath:join(t,xi),toPath:hf,feature:"hooks"});}var JL=u(()=>{T();rr();s(fh,"extractMeta");s(HL,"loadHooksFromDir");s(VL,"importClineHooks");});async function nu(t){let e=[],r=await U(Ss,t),o=await NL(t,e,r),n=join(t,wi),i=await y(n);if(i!==null&&i.trim()){let c=i.split(/\r?\n/),l=[];for(let m of c){let p=m.trim();p&&!p.startsWith("#")&&l.push(p);}if(l.length>0){await L(join(t,".agentsmesh"));let m=join(t,yf);await I(m,l.join(`
|
|
75
|
+
`)),e.push({fromTool:"cline",fromPath:n,toPath:yf,feature:"ignore"});}}await vL(t,e);let a=join(t,bp);return o||e.push(...await yt({srcDir:join(t,Eo),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:c,normalizeTo:l})=>DL(c,a,l),"mapEntry")})),await BL(t,e,r),await VL(t,e),e}var hh=u(()=>{mt();T();ke();uh();FL();rr();GL();WL();JL();s(nu,"importFromCline");});function YL(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:Ss}))}var XL=u(()=>{_t();rr();s(YL,"lintRules");});function ZL(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>b(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function QL(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","cline","cline hooks are emitted as .clinerules/hooks/*.sh wrapper scripts with a `#!/usr/bin/env bash` header; they require a POSIX shell (git-bash or WSL) to execute on Windows.")]:[]:[]}var qL=u(()=>{Et();s(ZL,"lintCommands");s(QL,"lintHooks");});var cK,lK,mK,pK,tA,eA=u(()=>{bL();_i();rr();hh();XL();qL();Rt();Ua();at();cK={name:"cline",primaryRootInstructionPath:Cs,generateRules:EL,generateCommands:OL,generateAgents:kL,generateSkills:TL,generateMcp:AL,generateHooks:wL,generateIgnore:LL,importFrom:nu},lK={rootInstructionPath:Cs,skillDir:".cline/skills",managedOutputs:{dirs:[".cline/skills",".clinerules",".clinerules/hooks",".clinerules/workflows"],files:["AGENTS.md",".cline/cline_mcp_settings.json",".clineignore",".clinerules/typescript.md"]},paths:{rulePath(t,e){return `${kn}/${t}.md`},commandPath(t,e){return `${Eo}/${t}.md`},agentPath(t,e){return Ve(e,"cline")?`.cline/skills/${$(t)}/SKILL.md`:null}}},mK={skillDir:Jt,managedOutputs:{dirs:[bi,Pi,xi,Jt,".agents/skills"],files:[wn,wi]},rewriteGeneratedPath(t){return t===Cs?null:t.startsWith(`${Ti}/`)?`${xi}/${t.slice(Ti.length+1)}`:t.startsWith(`${Eo}/`)?`${Pi}/${t.slice(Eo.length+1)}`:t.startsWith(`${kn}/`)?`${bi}/${t.slice(kn.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${Jt}/`)?`.agents/skills/${t.slice(Jt.length+1)}`:null},paths:{rulePath(t,e){return `${bi}/${t}.md`},commandPath(t,e){return `${Pi}/${t}.md`},agentPath(t,e){return Ve(e,"cline")?`.cline/skills/${$(t)}/SKILL.md`:null}}},pK={rules:"native",additionalRules:"native",commands:Dr("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},tA={id:"cline",metadata:{displayName:"Cline",category:"ide",officialUrl:"https://cline.bot",shortDescription:"Autonomous coding agent for VS Code"},generators:cK,capabilities:{rules:"native",additionalRules:"native",commands:Dr("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},emptyImportMessage:"No Cline config found (.clinerules, .clineignore, .cline/cline_mcp_settings.json, or .cline/skills).",supportsConversion:{agents:true},lintRules:YL,lint:{commands:ZL,hooks:QL},project:lK,globalSupport:{capabilities:pK,detectionPaths:[bi,Pi,xi,Jt,wn,wi],layout:mK},buildImportPaths:If,detectionPaths:[".clinerules",".cline"]};});var ge,rA,ts,ca,oA,Zo,nA,su,la,Qo,ma,es,sA,fm,iA,yh,aA,_h,cA,lA,Ih,Rh,Sh,ae=u(()=>{ge="codex-cli",rA="codex.md",ts="AGENTS.md",ca=".codex/AGENTS.md",oA=".codex/AGENTS.override.md",Zo=".agents/skills",nA=".codex/skills",su=".codex/config.toml",la=".codex/instructions",Qo=".codex/rules",ma=".codex/agents",es=".agentsmesh/rules",sA=".agentsmesh/commands",fm=".agentsmesh/agents",iA=".agentsmesh/skills",yh=".agentsmesh/mcp.json",aA="am-codex-rule:v1",_h="# am-json: ",cA="# am-body-b64-begin",lA="# am-body-b64-end",Ih="# am64:",Rh="<!-- agentsmesh:codex-rule-index:start -->",Sh="<!-- agentsmesh:codex-rule-index:end -->";});function Ch(t){return basename(t,".md")}function hm(t){return `${la}/${Ch(t.source)}.md`}function mA(t){let e={root:t.root,description:t.description||void 0,globs:t.globs.length>0?t.globs:void 0,targets:t.targets.length>0?t.targets:void 0,codex_emit:t.codexEmit||void 0,codex_instruction:t.codexInstructionVariant&&t.codexInstructionVariant!=="default"?t.codexInstructionVariant:void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),P(e,t.body.trim()||"")}function dK(t){let e=[];return t.root?e.push("Applies to the whole project."):t.globs.length>0?e.push(`Applies to ${t.globs.map(r=>`\`${r}\``).join(", ")}.`):e.push("General guidance with no file glob restriction."),t.codexInstructionVariant==="override"&&e.push("Override guidance when this rule conflicts with broader instructions."),t.codexEmit==="execution"&&e.push(`Enforced in \`${Qo}/${Ch(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function pA(t,e){let r=t.trim(),o=e.filter(a=>!a.root);if(o.length===0)return r;let n=o.map(a=>`- [${a.description||Ch(a.source)}](${hm(a)}): ${dK(a)}`),i=[Rh,"## Additional Rule Files",...n,Sh].join(`
|
|
76
76
|
`);return r?`${r}
|
|
77
77
|
|
|
78
|
-
${i}`:i}function
|
|
79
|
-
`).trim()}var
|
|
78
|
+
${i}`:i}function uA(t){let e=Rh.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=Sh.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
|
|
79
|
+
`).trim()}var iu=u(()=>{M();ae();s(Ch,"ruleSlug");s(hm,"codexInstructionMirrorPath");s(mA,"serializeCodexInstructionMirror");s(dK,"summarizeRule");s(pA,"appendCodexRuleIndex");s(uA,"stripCodexRuleIndex");});function fK(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function hK(t){return t.split(`
|
|
80
80
|
`).map(e=>e.length>0?`# ${e}`:"#").join(`
|
|
81
81
|
`)}function yK(t){let e=t.trim();return e?fK(e)?`${e}
|
|
82
82
|
`:`${["# agentsmesh: canonical execution rule body is not Codex DSL","# The original body is preserved below as comments.","# Replace with Codex rules DSL (for example prefix_rule(...)) to enforce behavior.","#",...hK(e).split(`
|
|
83
83
|
`),"#","# Example template:","# prefix_rule(",'# pattern = ["git", "status"],','# decision = "allow",','# justification = "Allow safe status checks",',"# )"].join(`
|
|
84
84
|
`)}
|
|
85
|
-
`:""}function
|
|
85
|
+
`:""}function Eh(t){let e=t.rules.find(o=>o.root),r=[];e&&r.push({path:ts,content:pA(e.body,t.rules)});for(let o of t.rules){if(o.root)continue;let n=basename(o.source,".md");o.targets.length>0&&!o.targets.includes("codex-cli")||(o.codexEmit==="execution"&&r.push({path:`${Qo}/${n}.rules`,content:yK(o.body)}),r.push({path:hm(o),content:mA(o)}));}return r}function Oh(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>o.root||o.codexEmit==="execution"?false:o.targets.length===0||o.targets.includes("codex-cli"));return st(e?.body.trim()??"",r)}var dA=u(()=>{Mt();ae();iu();s(fK,"looksLikeCodexRulesDsl");s(hK,"toCodexRulesComments");s(yK,"toSafeCodexRulesContent");s(Eh,"generateRules");s(Oh,"renderCodexGlobalInstructions");});function Lh(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${Zo}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Zo}/${r.name}/${a}`,content:i.content});}}return e}function _K(t){return {path:`${Zo}/${W(t.name)}/SKILL.md`,content:bt(t)}}function Ah(t){return t.commands.map(_K)}var gA=u(()=>{M();ae();St();s(Lh,"generateSkills");s(_K,"commandToSkillOutput");s(Ah,"generateCommands");});function kh(t){return t.agents.map(e=>({path:`${ma}/${e.name}.toml`,content:IK(e)}))}function IK(t){let e=[];e.push(`name = ${JSON.stringify(t.name)}`),t.description&&e.push(`description = ${JSON.stringify(t.description)}`),t.model&&e.push(`model = ${JSON.stringify(t.model)}`),t.permissionMode==="read-only"||t.permissionMode==="deny"?e.push('sandbox_mode = "read-only"'):t.permissionMode==="allow"&&e.push('sandbox_mode = "workspace-write"');let r=t.body.trim()||"";if(r.includes("'''")){let o=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`developer_instructions = """
|
|
86
86
|
${o}
|
|
87
87
|
"""`);}else e.push(`developer_instructions = '''
|
|
88
88
|
${r}
|
|
89
89
|
'''`);return e.join(`
|
|
90
90
|
`)+`
|
|
91
|
-
`}var
|
|
91
|
+
`}var fA=u(()=>{ae();s(kh,"generateAgents");s(IK,"serializeAgentToCodexToml");});function au(t){return "command"in t}function hA(t){return "url"in t}var cu=u(()=>{s(au,"isStdioMcpServer");s(hA,"isUrlMcpServer");});function wh(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([o,n])=>au(n)?[[o,n]]:[]));if(Object.keys(e).length===0)return [];let r=RK(e);return [{path:su,content:r}]}function RK(t){let e=[];for(let[r,o]of Object.entries(t)){let n=yA(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${n}]`),i.push(`command = ${JSON.stringify(o.command)}`);let a="["+o.args.map(l=>JSON.stringify(l)).join(", ")+"]";i.push(`args = ${a}`);let c=Object.entries(o.env);if(c.length>0){let l=c.map(([m,p])=>`${yA(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${l} }`);}e.push(i.join(`
|
|
92
92
|
`));}return e.join(`
|
|
93
93
|
|
|
94
94
|
`)+`
|
|
95
|
-
`}function
|
|
96
|
-
`).find(l=>l.startsWith(
|
|
97
|
-
`)){let m=l.trimEnd();if(m===mA){c=true;continue}if(m===pA){c=false;continue}c&&m.startsWith(Eh)&&a.push(m.slice(Eh.length));}if(a.length===0)return null;try{let l=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:n,globs:i},body:l}}catch{return null}}var bA=d(()=>{ce();s(TA,"tryParseEmbeddedCanonicalFromCodexRules");});async function xA(t,e,r){let o=[],n=join(t,tn);try{let i=await v(n),a=i.filter(l=>l.endsWith(".md"));for(let l of a){let m=await y(l);if(!m)continue;let p=relative(n,l).replace(/\\/g,"/"),u=join(e,p),{frontmatter:g,body:f}=k(r(m,l,u));await L(e);let h=g.root===!0?g:{...g,root:!1},O=await K(u,h,f);await _(u,O),o.push({fromTool:qt,fromPath:l,toPath:`${ns}/${p}`,feature:"rules"});}let c=i.filter(l=>l.endsWith(".rules"));for(let l of c){let m=await y(l);if(!m)continue;let p=relative(n,l).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await L(e);let g=TA(m);if(g){let f=await K(u,{description:g.meta.description,globs:g.meta.globs,root:!1},r(g.body,l,u));await _(u,f);}else {let f=await K(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),l,u));await _(u,f);}o.push({fromTool:qt,fromPath:l,toPath:`${ns}/${p}`,feature:"rules"});}}catch{}return o}var DA=d(()=>{T();M();lt();ce();bA();s(xA,"importCodexNonRootRuleFiles");});async function FA(t,e,r,o,n){let i=join(t,iA),a=join(t,os),c=join(t,aA),l=join(t,pa),m=n==="global"?await y(c):null,p=n==="global"?await y(l):null,u=n==="project"?await y(a):null,g=n==="project"?await y(i):null,f=m!==null?c:p!==null?l:u!==null?a:i,h=join(t,ns),O=m??p??u??g;if(O!==null){await L(h);let R=join(h,"_root.md"),S=f===a||f===l||f===c?gA(O):O,A=await Qo({content:S,projectRoot:t,rulesDir:ns,sourcePath:f,fromTool:"codex-cli",normalize:r});e.push(...A.results);let D=r(f===a||f===l||f===c?o(A.rootContent,f,R):A.rootContent,f,R),{frontmatter:N,body:G}=k(D),J=N.root===true?N:{...N,root:true},X=await K(R,J,G);await _(R,X),e.push({fromTool:"codex-cli",fromPath:f,toPath:`${ns}/_root.md`,feature:"rules"});}await bK(t,h,e,r),e.push(...await xA(t,h,r)),n!=="global"&&e.push(...await yt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:R,normalizeTo:S})=>{let A=relative(t,dirname(R)).replace(/\\/g,"/"),D=basename(R),N=D==="AGENTS.override.md";if(!A||A==="."||!N&&D!=="AGENTS.md")return null;let G=A.replace(/\//g,"-");if(!Sp(A))return await Ye(join(h,`${G}.md`)),null;let J=join(h,`${G}.md`),{frontmatter:X,body:q}=k(S(J));return {destPath:J,toPath:`${ns}/${G}.md`,feature:"rules",content:await K(J,{...X,root:false,globs:[`${A}/**`],...N?{codex_instruction:"override"}:{}},q)}},"mapEntry")}));}async function bK(t,e,r,o){try{let i=(await v(join(t,ua))).filter(c=>c.endsWith(".md")),a=join(t,ua);for(let c of i){let l=relative(a,c).replace(/\\/g,"/");if(l==="_root.md")continue;let m=await y(c);if(!m)continue;let p=join(e,l),{frontmatter:u,body:g}=k(o(m,c,p));await L(e);let f=u.root===!0?u:{...u,root:!1},h=await K(p,f,g);await _(p,h),r.push({fromTool:qt,fromPath:c,toPath:`${ns}/${l}`,feature:"rules"});}}catch{}}var vA=d(()=>{T();M();lt();Tc();ke();Ya();ce();DA();cu();s(FA,"importCodexRules");s(bK,"importInstructionMirrors");});async function pu(t,e){let r=e?.scope??"project",o=[],n=await U(qt,t,r),i=await U("windsurf",t,r);return await FA(t,o,n,i,r),await LA(t,o,n),await kA(t,o,n),await EA(t,o),o}var Fh=d(()=>{mt();ce();OA();AA();wA();vA();s(pu,"importFromCodex");});function GA(t,e,r){let{rules:o}=t;return o.length===0?[]:o.some(i=>i.root)?[]:[{level:"warning",file:relative(e,o[0].source),target:qt,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var MA=d(()=>{ce();s(GA,"lintRules");});function $A(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers))if(typeof o.description=="string"&&o.description&&e.push(b(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" has a description, but codex-cli does not project MCP descriptions into .codex/config.toml.`)),"url"in o||"type"in o){let n="type"in o?o.type:"url";e.push(b(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${n} transport; codex-cli only generates stdio MCP servers.`));}return e}var jA=d(()=>{Et();s($A,"lintMcp");});function UA(t){return fm(t)}var KA=d(()=>{cu();s(UA,"codexAdvisoryInstructionPath");});var xK,DK,NK,FK,WA,HA=d(()=>{CA();ce();Fh();MA();jA();Rt();Wa();KA();St();xK={name:"codex-cli",primaryRootInstructionPath:os,generateRules:kh,generateCommands:bh,generateAgents:Ph,generateSkills:Th,generateMcp:xh,importFrom:pu},DK={rootInstructionPath:os,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${tn}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return UA(e)},commandPath(t,e){return Ba(e,"codex-cli")?`${oo}/${W(t)}/SKILL.md`:null},agentPath(t,e){return `${da}/${t}.toml`}}},NK={rootInstructionPath:pa,renderPrimaryRootInstruction:wh,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${tn}/${e}.rules`]},skillDir:oo,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[pa,".codex/config.toml"]},rewriteGeneratedPath(t){return t===os?pa:t.startsWith(`${ua}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${tn}/${t}.rules`:pa},commandPath(t,e){return Ba(e,"codex-cli")?`${oo}/${W(t)}/SKILL.md`:null},agentPath(t,e){return `${da}/${t}.toml`}}},FK={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},WA={id:"codex-cli",metadata:{displayName:"Codex CLI",category:"cli",officialUrl:"https://github.com/openai/codex",shortDescription:"OpenAI's terminal coding agent"},generators:xK,capabilities:{rules:"native",additionalRules:"native",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Codex config found (codex.md or AGENTS.md).",supportsConversion:{commands:true},lintRules:GA,lint:{mcp:$A},project:DK,globalSupport:{capabilities:FK,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:NK},buildImportPaths:Ef,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function GK(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function zA(t){return `${Ao}/${t}.md`}function VA(t){let e={description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],P(e,t.body.trim()||"")}function JA(t,e){let r=basename(e,".md");return {name:((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||r).trim(),description:typeof t.description=="string"?t.description:"",allowedTools:GK(t["x-agentsmesh-allowed-tools"])}}function YA(t,e){let r={description:t.description||void 0,"allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return r.description===void 0&&delete r.description,r["allowed-tools"]===void 0&&delete r["allowed-tools"],P(r,e.trim()||"")}var uu=d(()=>{M();ko();s(GK,"toStringArray");s(zA,"continueCommandRulePath");s(VA,"serializeCommandRule");s(JA,"parseCommandRuleFrontmatter");s(YA,"serializeImportedCommand");});function XA(t){let e=[],r=t.rules.find(o=>o.root);if(r){let o={};r.description&&(o.description=r.description),e.push({path:xn,content:P(o,r.body.trim()||"")});}for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("continue"))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs),e.push({path:`${$r}/${n}.md`,content:P(i,o.body.trim()||"")});}return e}function ZA(t){return t.commands.map(e=>({path:`${Ao}/${e.name}.md`,content:VA(e)}))}function QA(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Pp,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function qA(t){return t.agents.map(e=>({path:`${be}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function tk(t){return tt(t,be)}var ek=d(()=>{Q();st();M();uu();ko();s(XA,"generateRules");s(ZA,"generateCommands");s(QA,"generateMcp");s(qA,"generateAgents");s(tk,"generateSkills");});function UK(t,e){let o=(e===".json"?JSON.parse(t):parse(t)??{}).mcpServers;if(!o||typeof o!="object"||Array.isArray(o))return {};let n={};for(let[i,a]of Object.entries(o)){if(!a||typeof a!="object"||Array.isArray(a))continue;let c=a;typeof c.command=="string"&&(n[i]={type:typeof c.type=="string"?c.type:"stdio",command:c.command,args:_s(c.args),env:_o(c.env),description:typeof c.description=="string"?c.description:void 0});}return n}async function KK(t,e){let r=(await v(join(t,Of))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),o={},n=[];for(let i of r){let a=await y(i);a&&(Object.assign(o,UK(a,extname(i))),n.push(i));}if(Object.keys(o).length!==0){await $t(t,Af,o);for(let i of n)e.push({fromTool:qa,fromPath:i,toPath:Af,feature:"mcp"});}}async function du(t){let e=[],r=await U(qa,t);return e.push(...await z(gu,t,"project",{normalize:r})),await Z(t,be,qa,e,r),await KK(t,e),e}var vh=d(()=>{mt();T();Q();Ct();Fr();tr();ko();Gh();s(UK,"readMcpServers");s(KK,"importMcp");s(du,"importFromContinue");});function BK(t){return t==="general.md"||t==="_root.md"}var ok,nk,sk=d(()=>{M();lt();uu();ko();s(BK,"isContinueRootRulePath");ok=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=BK(t),n=o?"_root.md":t,i=join(r,n),{frontmatter:a,body:c}=k(e(i)),l={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:o};return l.description===void 0&&delete l.description,l.globs===void 0&&delete l.globs,{destPath:i,toPath:`${xp}/${n}`,content:await K(i,l,c)}},"continueRuleMapper"),nk=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:o})=>{let n=join(o,e),{frontmatter:i,body:a}=k(r(n)),c=JA(i,t),l=c.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${l}.md`:`${l}.md`,u=join(o,p),g=await ht(u,{description:c.description,hasDescription:!!c.description,allowedTools:c.allowedTools,hasAllowedTools:c.allowedTools.length>0},k(YA(c,a)).body);return {destPath:u,toPath:`${Dp}/${p}`,content:g}},"continueCommandMapper");});function ik(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:qa}))}var ak=d(()=>{_t();ko();s(ik,"lintRules");});function ck(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>b(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var lk=d(()=>{Et();s(ck,"lintCommands");});function VK(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var mk,pk=d(()=>{T();ko();s(VK,"computeStatus");mk=s(async(t,e,r,o)=>{if(r!=="global")return [];let n=o.has("rules"),i=o.has("commands"),a=o.has("mcp");if(!(n&&t.rules.length>0||i&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let l={name:"agentsmesh",version:1,schema:"v1"};if(n&&t.rules.length>0&&(l.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(l.prompts=t.commands.map(u=>{let g={name:u.name};return u.description&&(g.description=u.description),g.prompt=u.body.trim(),g})),a&&t.mcp!==null){let u=Object.entries(t.mcp.mcpServers);u.length>0&&(l.mcpServers=u.map(([g,f])=>({name:g,...f})));}let m=stringify(l),p=await y(join(e,Wl));return [{target:"continue",path:Wl,content:m,currentContent:p??void 0,status:VK(p,m)}]},"generateContinueGlobalConfig");});function YK(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var uk,dk=d(()=>{T();ko();pk();s(YK,"computeStatus");uk=s(async(t,e,r,o)=>{let n=await mk(t,e,r,o);if(r!=="global"||!o.has("rules"))return n;let i=t.rules.find(l=>l.root);if(!i)return n;let a=i.body.trim(),c=await y(join(e,tc));return [...n,{target:"continue",path:tc,content:a,currentContent:c??void 0,status:YK(c,a)}]},"generateContinueScopeExtras");});var XK,ZK,QK,qK,gu,Gh=d(()=>{st();ek();ko();vh();sk();ak();lk();uu();Rt();dk();XK={name:"continue",primaryRootInstructionPath:xn,generateRules:XA,generateCommands:ZA,generateAgents:qA,generateSkills:tk,generateMcp:QA,importFrom:du},ZK={rootInstructionPath:xn,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${$r}/${t}.md`},commandPath(t,e){return zA(t)},agentPath(t){return `${be}/${$(t)}/SKILL.md`}}},QK={rootInstructionPath:xn,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[tc]}],skillDir:be,managedOutputs:{dirs:[$r,Ao,be,".agents/skills"],files:[Pp,tc,Wl]},mirrorGlobalPath(t,e){return t.startsWith(`${be}/`)?`.agents/skills/${t.slice(be.length+1)}`:null},paths:{rulePath(t,e){return `${$r}/${t}.md`},commandPath(t,e){return `${Ao}/${t}.md`},agentPath(t){return `${be}/${$(t)}/SKILL.md`}}},qK={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},gu={id:"continue",metadata:{displayName:"Continue",category:"ide",officialUrl:"https://continue.dev",shortDescription:"Open-source AI code assistant"},generators:XK,capabilities:{rules:"native",additionalRules:"native",commands:"embedded",agents:"none",skills:"embedded",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Continue config found (.continue/rules/*.md, .continue/skills, or .continue/mcpServers/*).",supportsConversion:{agents:true},lintRules:ik,lint:{commands:ck},project:ZK,globalSupport:{capabilities:qK,detectionPaths:[$r,Ao,".continue/mcpServers",be],layout:QK,scopeExtras:uk},importer:{rules:{feature:"rules",mode:"directory",source:{project:[$r],global:[$r]},canonicalDir:xp,extensions:[".md"],map:ok},commands:{feature:"commands",mode:"directory",source:{project:[Ao],global:[Ao]},canonicalDir:Dp,extensions:[".md"],map:nk}},buildImportPaths:kf,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var ss,ga,gk,fa,Qs,rn,on,ha,ya,fu,hu,fk,$h,hk,qs,Dc,is,Nc,_a,jh,Uh,Sr=d(()=>{ss="copilot",ga=".github/copilot-instructions.md",gk=".github/copilot",fa=".github/instructions",Qs=".github/prompts",rn=".github/hooks",on=".github/skills",ha=".github/agents",ya=".agentsmesh/rules",fu=".agentsmesh/commands",hu=".agentsmesh/agents",fk=".agentsmesh/skills",$h=".agentsmesh/hooks.yaml",hk=".github/copilot-hooks",qs=".copilot/copilot-instructions.md",Dc=".copilot/agents",is=".copilot/skills",Nc=".copilot/prompts",_a=".copilot/AGENTS.md",jh=".claude/skills",Uh=".agents/skills";});function yk(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function yu(t){return `${Qs}/${t}.prompt.md`}function _k(t){let e={agent:"agent",description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],P(e,t.body.trim()||"")}function Ik(t,e){let o=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),n=yk(t["x-agentsmesh-allowed-tools"]),i=n.length>0?n:yk(t.tools);return {name:o,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var _u=d(()=>{M();Sr();s(yk,"toStringArray");s(yu,"commandPromptPath");s(_k,"serializeCommandPrompt");s(Ik,"parseCommandPromptFrontmatter");});function Iu(t){return hn(t)}var Kh=d(()=>{Pr();s(Iu,"hasHookCommand");});function rB(t){let e=basename(t,".md");return e==="_root"?"root":e}function oB(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function Rk(t){let e=[],r=t.rules.find(o=>o.root);r?.body.trim()&&e.push(r.body.trim());for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("copilot"))continue;let n=o.body.trim();if(!n)continue;let i=o.description?`## ${o.description}`:null;i?e.push(`${i}
|
|
95
|
+
`}function yA(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var _A=u(()=>{cu();ae();s(wh,"generateMcp");s(RK,"serializeMcpToToml");s(yA,"needsTomlQuoting");});var IA=u(()=>{dA();gA();fA();_A();});var RA=u(()=>{IA();});function EK(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let o=Array.isArray(e.args)?e.args.filter(a=>typeof a=="string"):[],n=e.env,i=n!==null&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string")):{};return {type:"stdio",command:r,args:o,env:i}}async function SA(t,e){let r=join(t,su),o=await y(r);if(o===null)return;let n;try{n=parse$1(o);}catch{return}let i=n.mcp_servers;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0)return;let a={};for(let[c,l]of Object.entries(i)){let m=EK(l);m&&(a[c]=m);}Object.keys(a).length!==0&&(await $t(t,yh,a),e.push({fromTool:ge,fromPath:r,toPath:yh,feature:"mcp"}));}var CA=u(()=>{T();Nr();ae();s(EK,"mapTomlServerToCanonical");s(SA,"importMcp");});async function EA(t,e,r){await wc([Zo,nA],{projectRoot:t,destCanonicalSkillsDir:iA,targetName:ge,normalize:r,results:e},[KL({canonicalCommandsDir:sA}),Tc({canonicalAgentsDir:fm})]);}var OA=u(()=>{bc();ae();s(EA,"importSkills");});async function LA(t,e,r){let o=join(t,ma),n=join(t,fm);try{let a=(await N(o)).filter(c=>c.endsWith(".toml"));for(let c of a){let l=await y(c);if(!l)continue;let m=parse$1(l);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(c,".toml"),d=typeof m.description=="string"?m.description:"",g=typeof m.developer_instructions=="string"?m.developer_instructions.trim():"",f=typeof m.model=="string"?m.model:"",h=typeof m.sandbox_mode=="string"?m.sandbox_mode:"",O=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",R=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(G=>typeof G=="string"):[];await L(n);let E=join(n,`${p}.md`),A=r(g,c,E),v=fs({name:p,description:d,tools:[],disallowedTools:[],model:f,permissionMode:O,maxTurns:0,mcpServers:R,hooks:{},skills:[],memory:""},A);await I(E,v),e.push({fromTool:ge,fromPath:c,toPath:`${fm}/${p}.md`,feature:"agents"});}}catch{}}var AA=u(()=>{T();at();ae();s(LA,"importCodexAgentsFromToml");});function kA(t){if(!t.includes(aA))return null;let e=t.split(`
|
|
96
|
+
`).find(l=>l.startsWith(_h));if(!e)return null;let r;try{r=JSON.parse(e.slice(_h.length));}catch{return null}if(!r||typeof r!="object")return null;let o=r,n=typeof o.description=="string"?o.description:"",i=Array.isArray(o.globs)?o.globs.filter(l=>typeof l=="string"):[],a=[],c=false;for(let l of t.split(`
|
|
97
|
+
`)){let m=l.trimEnd();if(m===cA){c=true;continue}if(m===lA){c=false;continue}c&&m.startsWith(Ih)&&a.push(m.slice(Ih.length));}if(a.length===0)return null;try{let l=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:n,globs:i},body:l}}catch{return null}}var wA=u(()=>{ae();s(kA,"tryParseEmbeddedCanonicalFromCodexRules");});async function bA(t,e,r){let o=[],n=join(t,Qo);try{let i=await N(n),a=i.filter(l=>l.endsWith(".md"));for(let l of a){let m=await y(l);if(!m)continue;let p=relative(n,l).replace(/\\/g,"/"),d=join(e,p),{frontmatter:g,body:f}=w(r(m,l,d));await L(e);let h=g.root===!0?g:{...g,root:!1},O=await K(d,h,f);await I(d,O),o.push({fromTool:ge,fromPath:l,toPath:`${es}/${p}`,feature:"rules"});}let c=i.filter(l=>l.endsWith(".rules"));for(let l of c){let m=await y(l);if(!m)continue;let p=relative(n,l).replace(/\\/g,"/").replace(/\.rules$/i,".md"),d=join(e,p);await L(e);let g=kA(m);if(g){let f=await K(d,{description:g.meta.description,globs:g.meta.globs,root:!1},r(g.body,l,d));await I(d,f);}else {let f=await K(d,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),l,d));await I(d,f);}o.push({fromTool:ge,fromPath:l,toPath:`${es}/${p}`,feature:"rules"});}}catch{}return o}var PA=u(()=>{T();M();lt();ae();wA();s(bA,"importCodexNonRootRuleFiles");});async function DA(t,e,r,o,n){let i=join(t,rA),a=join(t,ts),c=join(t,oA),l=join(t,ca),m=n==="global"?await y(c):null,p=n==="global"?await y(l):null,d=n==="project"?await y(a):null,g=n==="project"?await y(i):null,f=m!==null?c:p!==null?l:d!==null?a:i,h=join(t,es),O=m??p??d??g;if(O!==null){await L(h);let R=join(h,"_root.md"),E=f===a||f===l||f===c?uA(O):O,A=await Xo({content:E,projectRoot:t,rulesDir:es,sourcePath:f,fromTool:"codex-cli",normalize:r});e.push(...A.results);let F=r(f===a||f===l||f===c?o(A.rootContent,f,R):A.rootContent,f,R),{frontmatter:v,body:G}=w(F),J=v.root===true?v:{...v,root:true},Y=await K(R,J,G);await I(R,Y),e.push({fromTool:"codex-cli",fromPath:f,toPath:`${es}/_root.md`,feature:"rules"});}await TK(t,h,e,r),e.push(...await bA(t,h,r)),n!=="global"&&e.push(...await yt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:R,normalizeTo:E})=>{let A=relative(t,dirname(R)).replace(/\\/g,"/"),F=basename(R),v=F==="AGENTS.override.md";if(!A||A==="."||!v&&F!=="AGENTS.md")return null;let G=A.replace(/\//g,"-");if(!Sp(A))return await go(join(h,`${G}.md`)),null;let J=join(h,`${G}.md`),{frontmatter:Y,body:q}=w(E(J));return {destPath:J,toPath:`${es}/${G}.md`,feature:"rules",content:await K(J,{...Y,root:false,globs:[`${A}/**`],...v?{codex_instruction:"override"}:{}},q)}},"mapEntry")}));}async function TK(t,e,r,o){try{let i=(await N(join(t,la))).filter(c=>c.endsWith(".md")),a=join(t,la);for(let c of i){let l=relative(a,c).replace(/\\/g,"/");if(l==="_root.md")continue;let m=await y(c);if(!m)continue;let p=join(e,l),{frontmatter:d,body:g}=w(o(m,c,p));await L(e);let f=d.root===!0?d:{...d,root:!1},h=await K(p,f,g);await I(p,h),r.push({fromTool:ge,fromPath:c,toPath:`${es}/${l}`,feature:"rules"});}}catch{}}var NA=u(()=>{T();M();lt();Ac();ke();Al();ae();PA();iu();s(DA,"importCodexRules");s(TK,"importInstructionMirrors");});async function lu(t,e){let r=e?.scope??"project",o=[],n=await U(ge,t,r),i=await U("windsurf",t,r);return await DA(t,o,n,i,r),await EA(t,o,n),await LA(t,o,n),await SA(t,o),o}var Ph=u(()=>{mt();ae();CA();OA();AA();NA();s(lu,"importFromCodex");});function FA(t,e,r){let{rules:o}=t;return o.length===0?[]:o.some(i=>i.root)?[]:[{level:"warning",file:relative(e,o[0].source),target:ge,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var vA=u(()=>{ae();s(FA,"lintRules");});function GA(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers))if(typeof o.description=="string"&&o.description&&e.push(b(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" has a description, but codex-cli does not project MCP descriptions into .codex/config.toml.`)),"url"in o||"type"in o){let n="type"in o?o.type:"url";e.push(b(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${n} transport; codex-cli only generates stdio MCP servers.`));}return e}var MA=u(()=>{Et();s(GA,"lintMcp");});function $A(t){return hm(t)}var jA=u(()=>{iu();s($A,"codexAdvisoryInstructionPath");});var PK,xK,DK,NK,KA,BA=u(()=>{RA();ae();Ph();vA();MA();Rt();Ua();jA();St();PK={name:"codex-cli",primaryRootInstructionPath:ts,generateRules:Eh,generateCommands:Ah,generateAgents:kh,generateSkills:Lh,generateMcp:wh,importFrom:lu},xK={rootInstructionPath:ts,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Qo}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return $A(e)},commandPath(t,e){return ja(e,"codex-cli")?`${Zo}/${W(t)}/SKILL.md`:null},agentPath(t,e){return `${ma}/${t}.toml`}}},DK={rootInstructionPath:ca,renderPrimaryRootInstruction:Oh,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Qo}/${e}.rules`]},skillDir:Zo,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[ca,".codex/config.toml"]},rewriteGeneratedPath(t){return t===ts?ca:t.startsWith(`${la}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${Qo}/${t}.rules`:ca},commandPath(t,e){return ja(e,"codex-cli")?`${Zo}/${W(t)}/SKILL.md`:null},agentPath(t,e){return `${ma}/${t}.toml`}}},NK={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},KA={id:"codex-cli",metadata:{displayName:"Codex CLI",category:"cli",officialUrl:"https://github.com/openai/codex",shortDescription:"OpenAI's terminal coding agent"},generators:PK,capabilities:{rules:"native",additionalRules:"native",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Codex config found (codex.md or AGENTS.md).",supportsConversion:{commands:true},lintRules:FA,lint:{mcp:GA},project:xK,globalSupport:{capabilities:NK,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:DK},buildImportPaths:Rf,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function vK(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function WA(t){return `${Oo}/${t}.md`}function HA(t){let e={description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],P(e,t.body.trim()||"")}function zA(t,e){let r=basename(e,".md");return {name:((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||r).trim(),description:typeof t.description=="string"?t.description:"",allowedTools:vK(t["x-agentsmesh-allowed-tools"])}}function VA(t,e){let r={description:t.description||void 0,"allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return r.description===void 0&&delete r.description,r["allowed-tools"]===void 0&&delete r["allowed-tools"],P(r,e.trim()||"")}var mu=u(()=>{M();Lo();s(vK,"toStringArray");s(WA,"continueCommandRulePath");s(HA,"serializeCommandRule");s(zA,"parseCommandRuleFrontmatter");s(VA,"serializeImportedCommand");});function JA(t){let e=[],r=t.rules.find(o=>o.root);if(r){let o={};r.description&&(o.description=r.description),e.push({path:Tn,content:P(o,r.body.trim()||"")});}for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("continue"))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs),e.push({path:`${Mr}/${n}.md`,content:P(i,o.body.trim()||"")});}return e}function YA(t){return t.commands.map(e=>({path:`${Oo}/${e.name}.md`,content:HA(e)}))}function XA(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Pp,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function ZA(t){return t.agents.map(e=>({path:`${be}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function QA(t){return tt(t,be)}var qA=u(()=>{Q();at();M();mu();Lo();s(JA,"generateRules");s(YA,"generateCommands");s(XA,"generateMcp");s(ZA,"generateAgents");s(QA,"generateSkills");});function jK(t,e){let o=(e===".json"?JSON.parse(t):parse(t)??{}).mcpServers;if(!o||typeof o!="object"||Array.isArray(o))return {};let n={};for(let[i,a]of Object.entries(o)){if(!a||typeof a!="object"||Array.isArray(a))continue;let c=a;typeof c.command=="string"&&(n[i]={type:typeof c.type=="string"?c.type:"stdio",command:c.command,args:hs(c.args),env:ho(c.env),description:typeof c.description=="string"?c.description:void 0});}return n}async function UK(t,e){let r=(await N(join(t,Sf))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),o={},n=[];for(let i of r){let a=await y(i);a&&(Object.assign(o,jK(a,extname(i))),n.push(i));}if(Object.keys(o).length!==0){await $t(t,Ef,o);for(let i of n)e.push({fromTool:Xa,fromPath:i,toPath:Ef,feature:"mcp"});}}async function pu(t){let e=[],r=await U(Xa,t);return e.push(...await z(uu,t,"project",{normalize:r})),await Z(t,be,Xa,e,r),await UK(t,e),e}var xh=u(()=>{mt();T();Q();Ct();Nr();Qe();Lo();Dh();s(jK,"readMcpServers");s(UK,"importMcp");s(pu,"importFromContinue");});function KK(t){return t==="general.md"||t==="_root.md"}var ek,rk,ok=u(()=>{M();lt();mu();Lo();s(KK,"isContinueRootRulePath");ek=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=KK(t),n=o?"_root.md":t,i=join(r,n),{frontmatter:a,body:c}=w(e(i)),l={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:o};return l.description===void 0&&delete l.description,l.globs===void 0&&delete l.globs,{destPath:i,toPath:`${xp}/${n}`,content:await K(i,l,c)}},"continueRuleMapper"),rk=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:o})=>{let n=join(o,e),{frontmatter:i,body:a}=w(r(n)),c=zA(i,t),l=c.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${l}.md`:`${l}.md`,d=join(o,p),g=await ht(d,{description:c.description,hasDescription:!!c.description,allowedTools:c.allowedTools,hasAllowedTools:c.allowedTools.length>0},w(VA(c,a)).body);return {destPath:d,toPath:`${Dp}/${p}`,content:g}},"continueCommandMapper");});function nk(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Xa}))}var sk=u(()=>{_t();Lo();s(nk,"lintRules");});function ik(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>b(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var ak=u(()=>{Et();s(ik,"lintCommands");});function zK(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var ck,lk=u(()=>{T();Lo();s(zK,"computeStatus");ck=s(async(t,e,r,o)=>{if(r!=="global")return [];let n=o.has("rules"),i=o.has("commands"),a=o.has("mcp");if(!(n&&t.rules.length>0||i&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let l={name:"agentsmesh",version:1,schema:"v1"};if(n&&t.rules.length>0&&(l.rules=t.rules.map(d=>({name:d.description||basename(d.source,".md"),rule:d.body.trim()}))),i&&t.commands.length>0&&(l.prompts=t.commands.map(d=>{let g={name:d.name};return d.description&&(g.description=d.description),g.prompt=d.body.trim(),g})),a&&t.mcp!==null){let d=Object.entries(t.mcp.mcpServers);d.length>0&&(l.mcpServers=d.map(([g,f])=>({name:g,...f})));}let m=stringify(l),p=await y(join(e,Bl));return [{target:"continue",path:Bl,content:m,currentContent:p??void 0,status:zK(p,m)}]},"generateContinueGlobalConfig");});function JK(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var mk,pk=u(()=>{T();Lo();lk();s(JK,"computeStatus");mk=s(async(t,e,r,o)=>{let n=await ck(t,e,r,o);if(r!=="global"||!o.has("rules"))return n;let i=t.rules.find(l=>l.root);if(!i)return n;let a=i.body.trim(),c=await y(join(e,Za));return [...n,{target:"continue",path:Za,content:a,currentContent:c??void 0,status:JK(c,a)}]},"generateContinueScopeExtras");});var YK,XK,ZK,QK,uu,Dh=u(()=>{at();qA();Lo();xh();ok();sk();ak();mu();Rt();pk();YK={name:"continue",primaryRootInstructionPath:Tn,generateRules:JA,generateCommands:YA,generateAgents:ZA,generateSkills:QA,generateMcp:XA,importFrom:pu},XK={rootInstructionPath:Tn,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Mr}/${t}.md`},commandPath(t,e){return WA(t)},agentPath(t){return `${be}/${$(t)}/SKILL.md`}}},ZK={rootInstructionPath:Tn,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Za]}],skillDir:be,managedOutputs:{dirs:[Mr,Oo,be,".agents/skills"],files:[Pp,Za,Bl]},mirrorGlobalPath(t,e){return t.startsWith(`${be}/`)?`.agents/skills/${t.slice(be.length+1)}`:null},paths:{rulePath(t,e){return `${Mr}/${t}.md`},commandPath(t,e){return `${Oo}/${t}.md`},agentPath(t){return `${be}/${$(t)}/SKILL.md`}}},QK={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},uu={id:"continue",metadata:{displayName:"Continue",category:"ide",officialUrl:"https://continue.dev",shortDescription:"Open-source AI code assistant"},generators:YK,capabilities:{rules:"native",additionalRules:"native",commands:"embedded",agents:"none",skills:"embedded",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Continue config found (.continue/rules/*.md, .continue/skills, or .continue/mcpServers/*).",supportsConversion:{agents:true},lintRules:nk,lint:{commands:ik},project:XK,globalSupport:{capabilities:QK,detectionPaths:[Mr,Oo,".continue/mcpServers",be],layout:ZK,scopeExtras:mk},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Mr],global:[Mr]},canonicalDir:xp,extensions:[".md"],map:ek},commands:{feature:"commands",mode:"directory",source:{project:[Oo],global:[Oo]},canonicalDir:Dp,extensions:[".md"],map:rk}},buildImportPaths:Of,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var rs,pa,uk,ua,Ys,qo,tn,da,ga,du,gu,dk,Fh,gk,Xs,Pc,os,xc,fa,vh,Gh,Rr=u(()=>{rs="copilot",pa=".github/copilot-instructions.md",uk=".github/copilot",ua=".github/instructions",Ys=".github/prompts",qo=".github/hooks",tn=".github/skills",da=".github/agents",ga=".agentsmesh/rules",du=".agentsmesh/commands",gu=".agentsmesh/agents",dk=".agentsmesh/skills",Fh=".agentsmesh/hooks.yaml",gk=".github/copilot-hooks",Xs=".copilot/copilot-instructions.md",Pc=".copilot/agents",os=".copilot/skills",xc=".copilot/prompts",fa=".copilot/AGENTS.md",vh=".claude/skills",Gh=".agents/skills";});function fk(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function fu(t){return `${Ys}/${t}.prompt.md`}function hk(t){let e={agent:"agent",description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],P(e,t.body.trim()||"")}function yk(t,e){let o=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),n=fk(t["x-agentsmesh-allowed-tools"]),i=n.length>0?n:fk(t.tools);return {name:o,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var hu=u(()=>{M();Rr();s(fk,"toStringArray");s(fu,"commandPromptPath");s(hk,"serializeCommandPrompt");s(yk,"parseCommandPromptFrontmatter");});function yu(t){return dn(t)}var Mh=u(()=>{br();s(yu,"hasHookCommand");});function eB(t){let e=basename(t,".md");return e==="_root"?"root":e}function rB(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function _k(t){let e=[],r=t.rules.find(o=>o.root);r?.body.trim()&&e.push(r.body.trim());for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("copilot"))continue;let n=o.body.trim();if(!n)continue;let i=o.description?`## ${o.description}`:null;i?e.push(`${i}
|
|
98
98
|
|
|
99
99
|
${n}`):e.push(n);}return e.join(`
|
|
100
100
|
|
|
101
|
-
`)}function
|
|
102
|
-
`)}async function
|
|
101
|
+
`)}function Ik(t){let e=t.rules.find(o=>o.root),r=[];e&&r.push({path:pa,content:e.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("copilot")||o.globs.length===0)continue;let n=eB(o.source),i={description:o.description||void 0,applyTo:o.globs.length===1?o.globs[0]:o.globs};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=P(i,o.body.trim()||"");r.push({path:`${ua}/${n}.instructions.md`,content:a});}return r}function Rk(t){return t.commands.map(e=>({path:fu(e.name),content:hk(e)}))}function Sk(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${tn}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${tn}/${r.name}/${a}`,content:i.content});}}return e}function Ck(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0,"mcp-servers":e.mcpServers.length>0?e.mcpServers:void 0,skills:e.skills.length>0?e.skills:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=P(r,e.body.trim()||"");return {path:`${da}/${e.name}.agent.md`,content:o}})}function Ek(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,o])=>{let n=rB(r);if(!n||!Array.isArray(o))return [];let i=o.filter(a=>typeof a=="object"&&a!==null&&yu(a)).map((a,c)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${c}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[n,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${qo}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var Ok=u(()=>{M();Rr();hu();Mh();s(eB,"ruleSlug");s(rB,"mapHookEvent");s(_k,"renderCopilotGlobalInstructions");s(Ik,"generateRules");s(Rk,"generateCommands");s(Sk,"generateSkills");s(Ck,"generateAgents");s(Ek,"generateHooks");});function nB(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function sB(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function kk(t){let e=t.match(/^# agentsmesh-command:\s*(.+)$/m);return e?.[1]?e[1].trim():t.replace(/^#!.*\n/,"").replace(/^#.*\n/gm,"").replace(/^HOOK_DIR=.*\n/gm,"").replace(/^set -e[u]?\n?/m,"").trim()}async function wk(t,e){let r=join(t,qo),n=(await N(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of n){let d=await y(p);if(!d)continue;let g;try{g=JSON.parse(d);}catch{continue}if(!(!g||typeof g.hooks!="object"||g.hooks===null))for(let[f,h]of Object.entries(g.hooks)){let O=nB(f);if(!(!O||!Array.isArray(h)))for(let R of h){if(!R||typeof R!="object")continue;let E=R,A=typeof E.bash=="string"?E.bash:"";if(!A)continue;let F=join(r,A.replace(/^\.\//,"")),v=await y(F);if(!v)continue;let G=kk(v);G&&(i[O]||(i[O]=[]),i[O].push({matcher:sB(E.comment),command:G,type:"command"}));}}}let a=join(t,gk),l=(await N(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of l){let d=await y(p);if(!d)continue;let g=basename(p,".sh"),f=g.lastIndexOf("-"),h=f>0?g.slice(0,f):g;i[h]||(i[h]=[]),i[h].push({matcher:"*",command:kk(d),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Fh);await L(dirname(m)),await I(m,stringify(i)),e.push({fromTool:rs,fromPath:join(t,qo),toPath:Fh,feature:"hooks"});}var Tk=u(()=>{T();Rr();s(nB,"mapCopilotHookEvent");s(sB,"extractMatcher");s(kk,"extractWrapperCommand");s(wk,"importHooks");});async function bk(t,e,r,o=tn){let n=join(t,o),i=await dm(n),a={projectRoot:t,destCanonicalSkillsDir:dk,targetName:rs,normalize:r,results:e};for(let[c,l]of i)await um(c,l,a);}var Pk=u(()=>{bc();Rr();s(bk,"importSkills");});async function _u(t,e={}){let r=e.scope??"project",o=[],n=await U(rs,t,r);return o.push(...await z(Iu,t,r,{normalize:n})),await bk(t,o,n,r==="global"?os:tn),r==="project"&&await wk(t,o),o}var $h=u(()=>{mt();Ct();Rr();Tk();Pk();jh();s(_u,"importFromCopilot");});function xk(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var Dk,Nk,Fk,vk,Gk=u(()=>{M();lt();Qe();hu();Rr();s(xk,"pruneUndefined");Dk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=t.replace(/\.instructions\.md$/i,".md"),n=join(r,o),{frontmatter:i,body:a}=w(e(n)),c=yn(i.globs),l=xk({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:n,toPath:`${ga}/${o}`,content:await K(n,l,a)}},"copilotLegacyRuleMapper"),Nk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=t.endsWith(".instructions.md")?t.replace(/\.instructions\.md$/i,".md"):t,n=join(r,o),{frontmatter:i,body:a}=w(e(n)),c=yn(i.applyTo!==void 0?i.applyTo:i.globs),l=xk({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:n,toPath:`${ga}/${o}`,content:await K(n,l,a)}},"copilotNewRuleMapper"),Fk=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:o})=>{let n=e.replace(/\.prompt\.md$/i,".md"),i=join(o,n),{frontmatter:a,body:c}=w(r(i)),l=yk(a,t),m=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",p=`${l.name}.md`,d=m?`${m}/${p}`:p,g=join(o,d);return {destPath:g,toPath:`${du}/${d}`,content:await ht(g,{description:l.description,hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:l.allowedTools,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"tools")||Object.prototype.hasOwnProperty.call(a,"x-agentsmesh-allowed-tools")},c)}},"copilotCommandMapper"),vk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(!t.endsWith(".agent.md"))return null;let o=t.replace(/\.agent\.md$/i,".md"),n=basename(o,".md"),i=join(r,o),{frontmatter:a,body:c}=w(e(i));return {destPath:i,toPath:`${gu}/${o}`,content:await Bt(i,{...a,name:typeof a.name=="string"?a.name:n},c)}},"copilotAgentMapper");});function Mk(t,e,r,o){let i=H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(c=>({...c,target:rs})),a=t.rules.filter(c=>!c.root&&c.globs.length===0);return [...i,...a.map(c=>({level:"warning",file:c.source,target:rs,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var $k=u(()=>{_t();Rr();s(Mk,"lintRules");});function jk(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>b(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function Uk(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification","UserPromptSubmit"],r=new Set(e),o=Object.keys(t.hooks).filter(i=>!r.has(i)).map(i=>_s(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&o.push(b(".agentsmesh/hooks.yaml","copilot","copilot hooks are emitted as .github/hooks/scripts/*.sh wrapper scripts with a `#!/usr/bin/env bash` header; they require a POSIX shell (git-bash or WSL) to execute on Windows.")),o}var Kk=u(()=>{Et();s(jk,"lintCommands");s(Uk,"lintHooks");});function mB(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function pB(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function uB(t,e){let r=t.match(Wk);if(!r?.groups)return t;let o=r.groups.prefix??"",n=r.groups.suffix??"";return `${o}"$HOOK_DIR/${e}"${n}`}async function dB(t,e){let o=e.match(Wk)?.groups?.path;if(!o)return null;let n=join(t,o),i=await y(n);if(i===null)return null;let a=pB(t,n);return a?{assetPath:`${qo}/scripts/${a}`,content:i,rewrittenCommand:uB(e,a)}:null}function gB(t,e){return `${qo}/scripts/${mB(t)}-${e}.sh`}function Bk(t){return t.replace(/[\r\n]+/g," ")}function fB(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${Bk(e)}`,`# agentsmesh-command: ${Bk(t)}`,"set -eu",t,""].join(`
|
|
102
|
+
`)}async function Hk(t,e,r){if(!e.hooks)return r;let o=[],n=new Map;for(let[i,a]of Object.entries(e.hooks)){if(!Array.isArray(a))continue;let c=0;for(let l of a){if(!yu(l))continue;let m=gB(i,c),p=l.command,d=await dB(t,l.command);d&&(p=d.rewrittenCommand,n.has(d.assetPath)||n.set(d.assetPath,{path:d.assetPath,content:d.content}));let g=fB(p,l.matcher).replace(`set -eu
|
|
103
103
|
`,`set -eu
|
|
104
104
|
HOOK_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
105
|
-
`);o.push({path:m,content:g}),c++;}}return [...r,...o,...n.values()]}var zk
|
|
106
|
-
`);return [{path:
|
|
107
|
-
`)}var
|
|
105
|
+
`);o.push({path:m,content:g}),c++;}}return [...r,...o,...n.values()]}var Wk,zk=u(()=>{T();Rr();Mh();Wk=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(mB,"safePhaseName");s(pB,"toRepoRelative");s(uB,"rewriteWrapperCommand");s(dB,"buildAssetOutput");s(gB,"wrapperPath");s(Bk,"safeShellLine");s(fB,"buildWrapper");s(Hk,"addHookScriptAssets");});function yB(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Vk,Jk=u(()=>{T();Rr();s(yB,"computeStatus");Vk=s(async(t,e,r,o)=>{if(r!=="global"||!o.has("rules"))return [];let n=t.rules.find(c=>c.root);if(!n)return [];let i=n.body.trim(),a=await y(join(e,fa));return [{target:"copilot",path:fa,content:i,currentContent:a??void 0,status:yB(a,i)}]},"generateCopilotGlobalExtras");});var IB,RB,SB,CB,Iu,jh=u(()=>{Ok();Rr();$h();Gk();$k();Rt();hu();Kk();zk();Jk();IB={name:"copilot",primaryRootInstructionPath:pa,generateRules:Ik,generateCommands:Rk,generateAgents:Ck,generateSkills:Sk,generateHooks:Ek,importFrom:_u},RB={rootInstructionPath:pa,outputFamilies:[{id:"instructions",kind:"additional",pathPrefix:".github/instructions/"}],extraRuleOutputPaths(t){if(t.root||t.globs.length===0)return [];let e=basename(t.source,".md");return [`${ua}/${e}.instructions.md`]},skillDir:".github/skills",managedOutputs:{dirs:[".github/agents",".github/instructions",".github/prompts",".github/skills",".github/hooks/scripts"],files:[".github/copilot-instructions.md",".github/hooks/agentsmesh.json"]},paths:{rulePath(t,e){return `${ua}/${t}.instructions.md`},commandPath(t,e){return fu(t)},agentPath(t,e){return `${da}/${t}.agent.md`}}},SB={rootInstructionPath:Xs,renderPrimaryRootInstruction:_k,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[fa]}],skillDir:os,managedOutputs:{dirs:[Pc,os,xc,Gh,vh],files:[Xs,fa]},rewriteGeneratedPath(t){return t===pa?Xs:t.startsWith(`${ua}/`)?Xs:t.startsWith(`${Ys}/`)?t.replace(`${Ys}/`,`${xc}/`):t.startsWith(`${da}/`)?t.replace(`${da}/`,`${Pc}/`):t.startsWith(`${tn}/`)?t.replace(`${tn}/`,`${os}/`):t.startsWith(`${qo}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${os}/`)&&!e.includes("codex-cli")){let r=t.slice(os.length+1);return [`.agents/skills/${r}`,`${vh}/${r}`]}return null},paths:{rulePath(t,e){return Xs},commandPath(t,e){return `${xc}/${t}.prompt.md`},agentPath(t,e){return `${Pc}/${t}.agent.md`}}},CB={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Iu={id:"copilot",metadata:{displayName:"GitHub Copilot",category:"ide",officialUrl:"https://github.com/features/copilot",shortDescription:"GitHub's AI pair programmer"},generators:IB,capabilities:{rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"partial",ignore:"none",permissions:"none"},emptyImportMessage:"No Copilot config found (.github/copilot-instructions.md, .github/copilot or .github/instructions, .github/prompts, .github/skills, .github/agents, or .github/hooks).",lintRules:Mk,lint:{commands:jk,hooks:Uk},postProcessHookOutputs:s(async(t,e,r)=>Hk(t,e,[...r]),"postProcessHookOutputs"),project:RB,globalSupport:{capabilities:CB,detectionPaths:[Xs,fa,Pc,os,xc,Gh],layout:SB,scopeExtras:Vk},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[pa],global:[Xs]},canonicalDir:ga,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[uk]},canonicalDir:ga,extensions:[".instructions.md"],map:Dk},{feature:"rules",mode:"directory",source:{project:[ua]},canonicalDir:ga,extensions:[".instructions.md",".md"],map:Nk}],commands:{feature:"commands",mode:"directory",source:{project:[Ys],global:[xc]},canonicalDir:du,extensions:[".prompt.md"],map:Fk},agents:{feature:"agents",mode:"directory",source:{project:[da],global:[Pc]},canonicalDir:gu,extensions:[".agent.md"],map:vk}},buildImportPaths:Lf,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function Ru(t){return {$schema:"https://charm.land/crush.json",...t}}var Yk=u(()=>{s(Ru,"buildCrushConfigJson");});function Xk(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(or)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:nr,content:n}]:[]}function Zk(t){return tt(t,Yt)}function Qk(t){return t.commands.map(e=>({path:`${Yt}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function qk(t){return t.agents.map(e=>({path:`${Yt}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function tw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Ru({mcp:t.mcp.mcpServers});return [{path:Pe,content:JSON.stringify(e,null,2)}]}function ew(t){if(!t.hooks)return [];let e=EB(t);if(Object.keys(e).length===0)return [];let r=Ru({hooks:e});return [{path:Pe,content:JSON.stringify(r,null,2)}]}function rw(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];if(e.length===0&&r.length===0&&o.length===0)return [];let n={};e.length>0&&(n.allowed_tools=e),r.length>0&&(n.denied_tools=r);let i=Ru({permissions:n});return [{path:Pe,content:JSON.stringify(i,null,2)}]}function ow(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
106
|
+
`);return [{path:bn,content:e}]}function EB(t){if(!t.hooks)return {};let e={};for(let[r,o]of Object.entries(t.hooks)){if(!Array.isArray(o))continue;let n=[];for(let i of o){let a=typeof i.command=="string"?i.command.trim():"";if(!a)continue;let c={matcher:i.matcher,command:a};i.timeout!==void 0&&(c.timeout=i.timeout),n.push(c);}n.length>0&&(e[r]=n);}return e}var nw=u(()=>{Q();Mt();at();St();Qa();Yk();s(Xk,"generateRules");s(Zk,"generateSkills");s(Qk,"generateCommands");s(qk,"generateAgents");s(tw,"generateMcp");s(ew,"generateHooks");s(rw,"generatePermissions");s(ow,"generateIgnore");s(EB,"buildCrushHooksFromCanonical");});async function iw(t,e={}){let r=e.scope??"project",o=[],n=await U(or,t,r);return o.push(...await z(Su,t,r,{normalize:n})),await Z(t,r==="global"?xe:Yt,or,o,n),await OB(t,o),o}async function OB(t,e){let r=join(t,Pe),o=await y(r);if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||Array.isArray(n))return;let i=n,a=LB(i.mcp);if(Object.keys(a).length>0){let l=Mp,m=join(t,l);await L(dirname(m)),await I(m,JSON.stringify({mcpServers:a},null,2)),e.push({fromTool:or,fromPath:r,toPath:l,feature:"mcp"});}let c=AB(i.hooks);if(c!==null&&Object.keys(c).length>0){let l=".agentsmesh/hooks.yaml",m=join(t,l);await L(dirname(m));let p=kB(c);await I(m,p),e.push({fromTool:or,fromPath:r,toPath:l,feature:"hooks"});}}function LB(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t)){if(!o||typeof o!="object"||Array.isArray(o))continue;let n=o,i=typeof n.description=="string"?n.description:void 0;if(typeof n.command=="string"){e[r]={type:typeof n.type=="string"?n.type:"stdio",command:n.command,args:hs(n.args),env:ho(n.env),...i!==void 0?{description:i}:{}};continue}typeof n.url=="string"&&(e[r]={type:typeof n.type=="string"?n.type:"http",url:n.url,headers:ho(n.headers),env:ho(n.env),...i!==void 0?{description:i}:{}});}return e}function AB(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.command=="string"?a.command.trim():"";if(!c)continue;let m={matcher:typeof a.matcher=="string"?a.matcher:"",command:c};typeof a.timeout=="number"&&(m.timeout=a.timeout),n.push(m);}n.length>0&&(e[r]=n);}return Object.keys(e).length>0?e:null}function kB(t){let e=[];for(let[r,o]of Object.entries(t)){e.push(`${r}:`);for(let n of o)e.push(` - matcher: ${JSON.stringify(n.matcher)}`),e.push(` command: ${JSON.stringify(n.command)}`),n.timeout!==void 0&&e.push(` timeout: ${n.timeout}`);}return e.join(`
|
|
107
|
+
`)}var aw=u(()=>{mt();Q();Ct();T();Qe();Kh();Qa();s(iw,"importFromCrush");s(OB,"importCrushConfigJson");s(LB,"parseCrushMcpServers");s(AB,"parseCrushHooks");s(kB,"serializeHooksYaml");});function cw(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:or}))}var lw=u(()=>{_t();Qa();s(cw,"lintRules");});function mw(t){return t.commands.length===0?[]:[b(".agentsmesh/commands","crush","Crush has no native slash-command format; commands are projected as skills via supportsConversion.")]}var pw=u(()=>{Et();s(mw,"lintCommands");});function Bh(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function dw(t,e){let r=Bh(t),o=TB.parse(JSON.parse(e)),n={...r};o.permissions!==void 0&&(n.permissions=o.permissions),o.hooks!==void 0&&(n.hooks=o.hooks);let i=n.permissions;return i&&typeof i=="object"&&!Array.isArray(i)&&!("ask"in i)&&(i.ask=[]),JSON.stringify(n,null,2)}function gw(t,e){let r=Bh(t),o=bB.parse(JSON.parse(e)),n={...r};return o.mcpServers!==void 0&&(n.mcpServers=o.mcpServers),o.hooks!==void 0&&(n.hooks=o.hooks),o.experimental!==void 0&&(n.experimental=o.experimental),o.context!==void 0&&(n.context=o.context),JSON.stringify(n,null,2)}function fw(t,e){let r=Bh(t),o=wB.parse(JSON.parse(e)),n={...r};return o.$schema!==void 0&&(n.$schema=o.$schema),o.mcp!==void 0&&(n.mcp=o.mcp),o.hooks!==void 0&&(n.hooks=o.hooks),o.permissions!==void 0&&(n.permissions=o.permissions),o.options!==void 0&&(n.options=o.options),JSON.stringify(n,null,2)}var uw,wB,TB,bB,Cu=u(()=>{uw=[".claude/settings.json",".gemini/settings.json"],wB=z$1.object({$schema:z$1.string().optional(),mcp:z$1.record(z$1.string(),z$1.unknown()).optional(),hooks:z$1.record(z$1.string(),z$1.unknown()).optional(),permissions:z$1.record(z$1.string(),z$1.unknown()).optional(),options:z$1.record(z$1.string(),z$1.unknown()).optional()}).passthrough(),TB=z$1.object({permissions:z$1.object({allow:z$1.array(z$1.string()).optional(),deny:z$1.array(z$1.string()).optional()}).passthrough().optional(),hooks:z$1.record(z$1.string(),z$1.unknown()).optional()}).passthrough(),bB=z$1.object({mcpServers:z$1.record(z$1.string(),z$1.unknown()).optional(),hooks:z$1.record(z$1.string(),z$1.unknown()).optional(),experimental:z$1.record(z$1.string(),z$1.unknown()).optional(),context:z$1.record(z$1.string(),z$1.unknown()).optional()}).passthrough();s(Bh,"parseJsonObject");s(dw,"mergeSettingsJson");s(gw,"mergeGeminiSettingsJson");s(fw,"mergeCrushConfigJson");});var PB,xB,DB,NB,FB,Su,Kh=u(()=>{St();at();nw();Qt();aw();lw();pw();Rt();Cu();Qa();PB={name:or,primaryRootInstructionPath:nr,generateRules:Xk,generateCommands:Qk,generateAgents:qk,generateSkills:Zk,generateMcp:tw,generateHooks:ew,generatePermissions:rw,generateIgnore:ow,importFrom:iw},xB={rootInstructionPath:nr,skillDir:Yt,managedOutputs:{dirs:[Yt],files:[nr,Pe,bn]},paths:{rulePath(t){return nr},commandPath(t){return `${Yt}/${W(t)}/SKILL.md`},agentPath(t){return `${Yt}/${$(t)}/SKILL.md`}}},DB={rootInstructionPath:Di,skillDir:xe,managedOutputs:{dirs:[xe],files:[Di,Fp]},rewriteGeneratedPath(t){return t===nr?Di:t===Pe?Fp:t===bn?null:t.startsWith(`${Yt}/`)?t.replace(`${Yt}/`,`${xe}/`):t},mirrorGlobalPath(t,e){return ct(t,xe,e)},paths:{rulePath(t){return Di},commandPath(t){return `${xe}/${W(t)}/SKILL.md`},agentPath(t){return `${xe}/${$(t)}/SKILL.md`}}},NB={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},FB={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"none",permissions:"none"},Su={id:or,metadata:{displayName:"Crush",category:"cli",officialUrl:"https://github.com/charmbracelet/crush",shortDescription:"Charm's TUI coding agent"},generators:PB,capabilities:NB,emptyImportMessage:"No Crush config found (CRUSH.md, .crush/skills/, crush.json, or .crushignore).",lintRules:cw,lint:{commands:mw},supportsConversion:{commands:true,agents:true},project:xB,globalSupport:{capabilities:FB,detectionPaths:[Di,Fp,xe],layout:DB},mergeGeneratedOutputContent(t,e,r,o){let n=e?.content??t;return n!==null&&o===Pe?fw(n,r):null},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[nr],global:[Di]},canonicalDir:vp,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[bn]},canonicalDir:".agentsmesh",canonicalFilename:Gp}},buildImportPaths:Af,detectionPaths:[nr,Pe,Yt,bn],sharedArtifacts:{".crush/skills/":"owner"}};});function Wh(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:Os,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let c=P(a,i);e.push({path:Pn,content:c});}let o=t.rules.filter(i=>!i.root&&(i.targets.length===0||i.targets.includes("cursor")));for(let i of o){let a=basename(i.source,".md"),l={alwaysApply:i.trigger==="always_on"};i.description&&(l.description=i.description),i.globs.length>0&&(l.globs=i.globs);let m=P(l,i.body.trim()||"");e.push({path:`${sr}/${a}.mdc`,content:m});}let n=hw(t);return n.trim()&&e.push({path:jr,content:n}),e}function hw(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes("cursor"))),o=[];return e?.body.trim()?o.push(st(e.body,r)):r.length>0&&o.push(st("",r)),o.filter(Boolean).join(`
|
|
108
108
|
|
|
109
|
-
`)}var
|
|
110
|
-
`);return [{path
|
|
109
|
+
`)}var yw=u(()=>{M();Mt();jt();s(Wh,"generateRules");s(hw,"renderCursorGlobalUserRules");});function Hh(t){return t.commands.map(e=>({path:`${ir}/${e.name}.md`,content:e.body.trim()||""}))}var _w=u(()=>{jt();s(Hh,"generateCommands");});function zh(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ko,content:e}]}var Iw=u(()=>{jt();s(zh,"generateMcp");});function Vh(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${Ao}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Ao}/${r.name}/${a}`,content:i.content});}}return e}var Rw=u(()=>{M();jt();s(Vh,"generateSkills");});function Jh(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=P(r,e.body.trim()||"");return {path:`${qa}/${e.name}.md`,content:o}})}var Sw=u(()=>{M();jt();s(Jh,"generateAgents");});function Yh(t){return []}var Cw=u(()=>{s(Yh,"generatePermissions");});function GB(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!po(i))continue;let a=Kt(i),c=le(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),n.push({matcher:i.matcher,hooks:[m]});}n.length>0&&(e[r]=n);}return e}function Xh(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=GB(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:wo,content:r}]}var Ew=u(()=>{br();jt();s(GB,"toCursorHooks");s(Xh,"generateHooks");});function Zh(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
110
|
+
`);return [{path:$r,content:e}]}var Ow=u(()=>{jt();s(Zh,"generateIgnore");});var Lw=u(()=>{yw();_w();Iw();Rw();Sw();Cw();Ew();Ow();});var Aw=u(()=>{Lw();});async function Ou(t,e,r,o){let n=t.replace(/\.mdc$/i,".md"),i=join(e,n),c=w(r(i)).frontmatter.alwaysApply===true,l=c?join(e,"_root.md"):i,{frontmatter:m,body:p}=w(r(l));c&&o();let d={...m,root:c};if(delete d.alwaysApply,!c){let g=MB(m);g!==null&&(d.trigger=g);}return {destPath:l,toPath:`${To}/${c?"_root.md":n}`,feature:"rules",content:await K(l,d,p)}}function MB(t){return t.alwaysApply!==false?null:(Array.isArray(t.globs)?t.globs:[]).length>0?"glob":(typeof t.description=="string"?t.description:"").trim().length>0?"model_decision":"manual"}async function kw(t,e,r){let o=join(e,t),{frontmatter:n,body:i}=w(r(o)),a=Ze(n.allowedTools),c=a.length>0?a:Ze(n["allowed-tools"]);return {destPath:o,toPath:`${ks}/${t}`,feature:"commands",content:await ht(o,{description:typeof n.description=="string"?n.description:"",hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}}async function ww(t,e,r){let o=join(e,t),{frontmatter:n,body:i}=w(r(o));return {destPath:o,toPath:`${ws}/${t}`,feature:"agents",content:await Bt(o,n,i)}}var Qh=u(()=>{M();lt();Qe();jt();s(Ou,"mapCursorRuleFile");s(MB,"deriveCursorTrigger");s(kw,"mapCursorCommandFile");s(ww,"mapCursorAgentFile");});async function Dc(t){let e=join(t.projectRoot,To);await L(e);let r=join(e,"_root.md"),o=await Xo({content:t.content,projectRoot:t.projectRoot,rulesDir:To,sourcePath:t.sourcePath,fromTool:"cursor",normalize:t.normalize});t.results.push(...o.results);let n=t.normalize(o.rootContent,t.sourcePath,r);if(!n.trim()&&o.results.length>0)return true;let{frontmatter:i,body:a}=w(n),c=i.root===true?i:{...i,root:true},l=await K(r,c,a);return await I(r,l),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${To}/_root.md`,feature:"rules"}),true}var qh=u(()=>{T();M();Ac();lt();jt();s(Dc,"importCursorRootFile");});async function bw(t,e,r){let o=join(t,To),n=false,i=join(t,sr);if(e.push(...await yt({srcDir:i,destDir:o,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:c,normalizeTo:l})=>{if(n){let m=await y(a);if(m!==null){let{frontmatter:p}=w(m);if(p.alwaysApply===true)return null}}return Ou(c,o,l,()=>{n=true;})},"mapEntry")})),!n){let a=join(t,Os),c=await y(a);c!==null&&(n=await Dc({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r}));}if(!n){let a=join(t,KC),c=await y(a);c!==null&&await Dc({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r});}}var Pw=u(()=>{T();M();ke();Qh();qh();jt();s(bw,"importCursorRules");});function xw(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!po({...m,type:p}))continue;let d=p==="prompt"?le(m)||Kt(m):Kt(m)||le(m),g={matcher:c,type:p,command:d};typeof m.timeout=="number"&&(g.timeout=m.timeout),n.push(g);}}n.length>0&&(e[r]=n);}return e}async function ku(t,e){let r=false,o=join(t,wo),n=await y(o);if(n)try{let p=JSON.parse(n);if(p.hooks&&typeof p.hooks=="object"){let d=xw(p.hooks);if(Object.keys(d).length>0){let g=stringify(d),f=join(t,Hl);await L(dirname(f)),await I(f,g),e.push({fromTool:"cursor",fromPath:o,toPath:Hl,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,$p),a=await y(i);if(!a)return;let c;try{c=JSON.parse(a);}catch{return}let l=c.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let p=l,d=Array.isArray(p.allow)?p.allow.filter(f=>typeof f=="string"):[],g=Array.isArray(p.deny)?p.deny.filter(f=>typeof f=="string"):[];if(d.length>0||g.length>0){let f=stringify({allow:d,deny:g}),h=join(t,wf);await L(dirname(h)),await I(h,f),e.push({fromTool:"cursor",fromPath:i,toPath:wf,feature:"permissions"});}}let m=r?void 0:c.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=xw(m);if(Object.keys(p).length>0){let d=stringify(p),g=join(t,Hl);await L(dirname(g)),await I(g,d),e.push({fromTool:"cursor",fromPath:i,toPath:Hl,feature:"hooks"});}}}async function wu(t,e){let r=[{path:join(t,$r),label:$r},{path:join(t,kf),label:kf}],o=[],n=[];for(let a of r){let c=await y(a.path);if(c!==null){n.push(a.label);for(let l of c.split(/\r?\n/)){let m=l.trim();m&&!o.includes(m)&&o.push(m);}}}if(o.length===0)return;let i=join(t,Tf);await L(dirname(i)),await I(i,o.join(`
|
|
111
111
|
`)+`
|
|
112
|
-
`),e.push({fromTool:"cursor",fromPath:join(t,n[0]),toPath:xf,feature:"ignore"});}var sy=d(()=>{Pr();T();jt();s(Nw,"cursorHooksToCanonical");s(Tu,"importSettings");s(bu,"importIgnore");});async function Pu(t,e,r,o=wo){let n=join(t,o),i=await Zs(n),a={projectRoot:t,sourceSkillsDir:o,destCanonicalSkillsDir:JC,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await qo(p,u,a);let c=await v(n).catch(()=>[]),l=c.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>c.filter(u=>u.startsWith(p))));for(let p of l){if(m.has(p))continue;let u=await y(p);if(!u)continue;let g=basename(p,".md");await zL(g,p,u,a);}}var iy=d(()=>{T();Pc();jt();s(Pu,"importSkills");});async function Fw(t){if(await j(join(t,ar)))return true;let e=[join(t,Ur),join(t,oc),join(t,Hl),join(t,bo),join(t,jr),join(t,ks),join(t,ws),join(t,cr)];for(let i of e){let a=await y(i);if(a!==null&&a.trim()!=="")return true}return !!((await v(join(t,ks))).some(i=>i.endsWith(".md"))||(await v(join(t,ws))).some(i=>i.endsWith(".md"))||(await v(join(t,cr))).some(i=>i.endsWith(".md")))}async function vw(t,e,r){let o=join(t,Po),n=false,i=join(t,ar),a=await yt({srcDir:i,destDir:o,extensions:[".mdc"],fromTool:vc,normalize:r,mapEntry:s(async({srcPath:c,relativePath:l,normalizeTo:m})=>{if(n){let p=await y(c);if(p!==null){let{frontmatter:u}=k(p);if(u.alwaysApply===true)return null}}return Au(l,o,m,()=>{n=true;})},"mapEntry")});return e.push(...a),n}async function Gw(t,e,r){let o=join(t,oc),n=await y(o);return n===null||n.trim()===""?false:Fc({projectRoot:t,results:e,sourcePath:o,content:n.trim(),normalize:r})}async function Mw(t,e,r){let o=join(t,Ur),n=await y(o);return n===null||n.trim()===""?false:Fc({projectRoot:t,results:e,sourcePath:o,content:n.trim(),normalize:r})}async function $w(t,e){let r=join(t,Hl),o=await y(r);if(o===null||o.trim()==="")return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||!("mcpServers"in n))return;let i=join(t,nc);await L(dirname(i)),await _(i,o),e.push({fromTool:vc,fromPath:r,toPath:nc,feature:"mcp"});}async function jw(t,e,r){let o=join(t,ws),n=join(t,bs);e.push(...await yt({srcDir:o,destDir:n,extensions:[".md"],fromTool:vc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>bw(i,n,a),"mapEntry")}));}async function Uw(t,e,r){let o=join(t,cr),n=join(t,Ts);e.push(...await yt({srcDir:o,destDir:n,extensions:[".md"],fromTool:vc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>Tw(i,n,a),"mapEntry")}));}var vc,Kw=d(()=>{T();M();ke();jt();oy();ry();vc="cursor";s(Fw,"hasGlobalCursorArtifacts");s(vw,"importGlobalCursorRulesFromDir");s(Gw,"importGlobalUserRules");s(Mw,"importGlobalDotCursorAgents");s($w,"importGlobalMcp");s(jw,"importGlobalAgents");s(Uw,"importGlobalCommands");});async function Bw(t){if(!await Fw(t))return [];let e=[],r=await U(vc,t,"global"),o=await vw(t,e,r);return o||(o=await Gw(t,e,r)),o||await Mw(t,e,r),await $w(t,e),await Pu(t,e,r,ks),await jw(t,e,r),await Uw(t,e,r),await Tu(t,e),await bu(t,e),e}var Ww=d(()=>{mt();jt();iy();sy();Kw();s(Bw,"importFromCursorGlobalExports");});async function WB(t,e){let r=join(t,To),o=await y(r);if(!o)return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||!("mcpServers"in n))return;let i=n.mcpServers;await $t(t,nc,i),e.push({fromTool:"cursor",fromPath:r,toPath:nc,feature:"mcp"});}async function xu(t,e={}){if(e.scope==="global")return Bw(t);let r=[],o=await U("cursor",t);return await xw(t,r,o),r.push(...await z(Du,t,"project",{normalize:o})),await Pu(t,r,o),await WB(t,r),await Tu(t,r),await bu(t,r),r}var ay=d(()=>{mt();T();Ct();Fr();Dw();sy();iy();Ww();jt();cy();s(WB,"importMcp");s(xu,"importFromCursor");});var zw,Vw,Jw=d(()=>{M();lt();tr();jt();zw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=k(e(o)),a=qe(n.allowedTools),c=a.length>0?a:qe(n["allowed-tools"]);return {destPath:o,toPath:`${Ts}/${t}`,content:await ht(o,{description:typeof n.description=="string"?n.description:"",hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}},"cursorCommandMapper"),Vw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=k(e(o));return {destPath:o,toPath:`${bs}/${t}`,content:await Bt(o,n,i)}},"cursorAgentMapper");});function Yw(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:zC}))}var Xw=d(()=>{_t();jt();s(Yw,"lintRules");});function Zw(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>b(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function Qw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers)){let n=o.env&&Object.keys(o.env).length>0,i="url"in o,a="headers"in o;(n||i||a)&&e.push(b(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function qw(t){if(!t.permissions)return [];let e=t.permissions.ask?.length??0;return t.permissions.allow.length>0||t.permissions.deny.length>0||e>0?[b(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var tT=d(()=>{Et();s(Zw,"lintCommands");s(Qw,"lintMcp");s(qw,"lintPermissions");});var HB,zB,VB,JB,Du,cy=d(()=>{ww();jt();Qt();ay();Jw();Xw();Rt();tT();HB={name:"cursor",primaryRootInstructionPath:Nn,generateRules:Jh,generateCommands:Yh,generateAgents:Qh,generateSkills:Zh,generateMcp:Xh,generatePermissions:qh,generateHooks:ty,generateIgnore:ey,importFrom:xu},zB={rootInstructionPath:Nn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[As,Ur]}],skillDir:".cursor/skills",managedOutputs:{dirs:[".cursor/agents",".cursor/commands",".cursor/rules",".cursor/skills"],files:[".cursor/hooks.json",".cursor/mcp.json",".cursorignore","AGENTS.md"]},paths:{rulePath(t,e){return `.cursor/rules/${t}.mdc`},commandPath(t,e){return `.cursor/commands/${t}.md`},agentPath(t,e){return `.cursor/agents/${t}.md`}}},VB={rootInstructionPath:Nn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[As,Ur]}],skillDir:ks,managedOutputs:{dirs:[ar,cr,ws,ks],files:[Nn,Ur,Hl,bo,jr,oc]},rewriteGeneratedPath(t){return t===As?null:t===Ur||t===Nn||t.startsWith(`${ar}/`)||t.startsWith(`${cr}/`)||t.startsWith(`${rc}/`)||t.startsWith(`${wo}/`)||t===To||t===bo||t===jr?t:t===$p?null:t},mirrorGlobalPath(t,e){return ct(t,wo,e)},paths:{rulePath(t,e){return `${ar}/${t}.mdc`},commandPath(t,e){return `${cr}/${t}.md`},agentPath(t,e){return `${ws}/${t}.md`}}},JB={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Du={id:"cursor",metadata:{displayName:"Cursor",category:"ide",officialUrl:"https://cursor.com",shortDescription:"AI-first code editor"},generators:HB,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},emptyImportMessage:"No Cursor config found (AGENTS.md or .cursor/rules/*.mdc; with --global: ~/.cursor/{rules/*.mdc,AGENTS.md,mcp.json,hooks.json,cursorignore,skills/,agents/,commands/} and legacy ~/.agentsmesh-exports/cursor/user-rules.md).",lintRules:Yw,lint:{commands:Zw,mcp:Qw,permissions:qw},project:zB,globalSupport:{capabilities:JB,detectionPaths:[Nn,Ur,To,bo,jr,wo,ws,cr,oc],layout:VB},importer:{commands:{feature:"commands",mode:"directory",source:{project:[cr]},canonicalDir:Ts,extensions:[".md"],map:zw},agents:{feature:"agents",mode:"directory",source:{project:[rc]},canonicalDir:bs,extensions:[".md"],map:Vw}},buildImportPaths:Df,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});function eT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(xo)),o=e?.body.trim()??"",n=it(o,r);return n?[{path:lr,content:n}]:[]}function rT(t){return tt(t,ie)}function oT(t){return t.commands.map(e=>({path:`${ie}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function nT(t){return t.agents.map(e=>({path:`${ie}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function sT(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Fn,content:e}]}var iT=d(()=>{Q();Mt();st();St();sc();s(eT,"generateRules");s(rT,"generateSkills");s(oT,"generateCommands");s(nT,"generateAgents");s(sT,"generateMcp");});async function aT(t,e={}){let r=e.scope??"project",o=[],n=await U(xo,t,r);return o.push(...await z(Nu,t,r,{normalize:n})),await Z(t,r==="global"?Kr:ie,xo,o,n),o}var cT=d(()=>{mt();Q();Ct();sc();ly();s(aT,"importFromDeepagentsCli");});function lT(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:xo}))}var mT=d(()=>{_t();sc();s(lT,"lintRules");});function pT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","deepagents-cli","Deep Agents CLI hooks are global-only (~/.deepagents/hooks.json); project-level canonical hooks are not projected.")]:[]:[]}function uT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","deepagents-cli","Deep Agents CLI permissions are managed via shell allow-lists (--shell-allow-list); canonical permissions are not projected.")]}function dT(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","deepagents-cli","Deep Agents CLI has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var gT=d(()=>{Et();s(pT,"lintHooks");s(uT,"lintPermissions");s(dT,"lintIgnore");});var YB,XB,ZB,QB,qB,Nu,ly=d(()=>{St();st();iT();cT();mT();gT();Rt();sc();YB={name:xo,primaryRootInstructionPath:lr,generateRules:eT,generateCommands:oT,generateAgents:nT,generateSkills:rT,generateMcp:sT,importFrom:aT},XB={rootInstructionPath:lr,skillDir:ie,managedOutputs:{dirs:[ie],files:[lr,Fn]},paths:{rulePath(t){return lr},commandPath(t){return `${ie}/${W(t)}/SKILL.md`},agentPath(t){return `${ie}/${$(t)}/SKILL.md`}}},ZB={rootInstructionPath:vn,skillDir:Kr,managedOutputs:{dirs:[Kr],files:[vn,Gi]},rewriteGeneratedPath(t){return t===lr?vn:t===Fn?Gi:t.startsWith(`${ie}/`)?t.replace(`${ie}/`,`${Kr}/`):t},paths:{rulePath(t){return vn},commandPath(t){return `${Kr}/${W(t)}/SKILL.md`},agentPath(t){return `${Kr}/${$(t)}/SKILL.md`}}},QB={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},qB={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Nu={id:xo,metadata:{displayName:"Deep Agents CLI",category:"cli",officialUrl:"https://github.com/langchain-ai/deepagents",shortDescription:"LangChain Deep Agents framework CLI"},generators:YB,capabilities:QB,emptyImportMessage:"No Deep Agents CLI config found (.deepagents/AGENTS.md, .deepagents/skills, or .mcp.json).",lintRules:lT,lint:{hooks:pT,permissions:uT,ignore:dT},supportsConversion:{commands:true,agents:true},project:XB,globalSupport:{capabilities:qB,detectionPaths:[vn,Gi],layout:ZB},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[lr],global:[vn]},canonicalDir:XC,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Fn],global:[Gi]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Nf,detectionPaths:[lr,Fn]};});function fT(t){let e={name:t.name};return t.description&&(e.description=t.description.slice(0,500)),t.model?e.model=t.model:e.model="inherit",t.tools.length>0&&(e.tools=t.tools),P(e,t.body.trim()||"")}var hT=d(()=>{M();s(fT,"serializeDroid");});function yT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(mr)),o=e?.body.trim()??"",n=it(o,r);return n?[{path:pr,content:n}]:[]}function _T(t){return tt(t,_e)}function IT(t){return t.commands.map(e=>({path:`${_e}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function RT(t){return t.agents.map(e=>({path:`${Do}/${e.name}.md`,content:fT(e)}))}function ST(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:No,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var CT=d(()=>{Q();Mt();St();hT();$i();s(yT,"generateRules");s(_T,"generateSkills");s(IT,"generateCommands");s(RT,"generateAgents");s(ST,"generateMcp");});async function OT(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let a=n.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await $t(t,ET,c),r.push({fromTool:mr,fromPath:e,toPath:ET,feature:"mcp"}));}var ET,LT=d(()=>{T();Fr();$i();ET=".agentsmesh/mcp.json";s(OT,"importFactoryDroidMcp");});async function AT(t,e={}){let r=e.scope??"project",o=[],n=await U(mr,t,r);return o.push(...await z(Fu,t,r,{normalize:n})),await Z(t,r==="global"?Fo:_e,mr,o,n),await OT(t,r==="global"?Ps:No,o),o}var kT=d(()=>{mt();Q();Ct();LT();$i();my();s(AT,"importFromFactoryDroid");});function wT(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:mr}))}var TT=d(()=>{_t();$i();s(wT,"lintRules");});function bT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","factory-droid","Factory Droid hooks are configured via settings.json events (PreToolUse/PostToolUse), not standalone files; canonical hooks are not projected.")]:[]:[]}function PT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","factory-droid","Factory Droid permissions are managed via CLI flags (--skip-permissions-unsafe); canonical permissions are not projected.")]}function xT(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","factory-droid","Factory Droid has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var DT=d(()=>{Et();s(bT,"lintHooks");s(PT,"lintPermissions");s(xT,"lintIgnore");});var eW,rW,oW,NT,Fu,my=d(()=>{CT();$i();kT();TT();DT();Rt();St();eW={name:mr,primaryRootInstructionPath:pr,generateRules:yT,generateCommands:IT,generateAgents:RT,generateSkills:_T,generateMcp:ST,importFrom:AT},rW={rootInstructionPath:pr,skillDir:_e,managedOutputs:{dirs:[_e,Do],files:[pr,No]},paths:{rulePath(t){return pr},commandPath(t){return `${_e}/${W(t)}/SKILL.md`},agentPath(t){return `${Do}/${t}.md`}}},oW={rootInstructionPath:Gn,skillDir:Fo,managedOutputs:{dirs:[Fo,Mi],files:[Gn,Ps]},rewriteGeneratedPath(t){return t===pr?Gn:t===No?Ps:t.startsWith(`${_e}/`)?t.replace(`${_e}/`,`${Fo}/`):t.startsWith(`${Do}/`)?t.replace(`${Do}/`,`${Mi}/`):t},paths:{rulePath(t){return Gn},commandPath(t){return `${Fo}/${W(t)}/SKILL.md`},agentPath(t){return `${Mi}/${t}.md`}}},NT={rules:"native",additionalRules:"embedded",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Fu={id:mr,metadata:{displayName:"Factory Droid",category:"agent-platform",officialUrl:"https://www.factory.ai",shortDescription:"Factory.ai's coding droid"},generators:eW,capabilities:NT,emptyImportMessage:"No Factory Droid config found (AGENTS.md, .factory/skills, or .factory/mcp.json).",lintRules:wT,lint:{hooks:bT,permissions:PT,ignore:xT},supportsConversion:{commands:true},project:rW,globalSupport:{capabilities:NT,detectionPaths:[Gn,Ps,Mi],layout:oW},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[pr],global:[Gn]},canonicalDir:QC,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Ff,detectionPaths:[pr,No,Do]};});var ti,Cr,nn,FT,vT,Me,vu,Ia,Gu,_m,ei,GT,MT,ri,Mu,Im,Rm,py,uy,Gc,dy,Mc,$c,$u,jc,Ra,Sm,Wt=d(()=>{ti="gemini-cli",Cr="GEMINI.md",nn="AGENTS.md",FT=".gemini/rules",vT=".gemini/GEMINI.md",Me=".gemini/commands",vu=".gemini/policies",Ia=".gemini/settings.json",Gu=".geminiignore",_m=".gemini/skills",ei=".gemini/agents",GT=".gemini/system.md",MT=`${vu}/permissions.toml`,ri=".agentsmesh/rules",Mu=".agentsmesh/commands",Im=".agentsmesh/agents",Rm=".agentsmesh/skills",py=".agentsmesh/mcp.json",uy=".agentsmesh/hooks.yaml",Gc=".agentsmesh/ignore",dy=".agentsmesh/permissions.yaml",Mc=".gemini/GEMINI.md",$c=".gemini/AGENTS.md",$u=".gemini/settings.json",jc=".gemini/commands",Ra=".gemini/skills",Sm=".gemini/agents";});function gy(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>!(i.root||i.targets.length>0&&!i.targets.includes("gemini-cli")));if(!e&&r.length===0)return [];let o=it(e?.body.trim()??"",r),n=[{path:Cr,content:o}];return e&&n.push({path:nn,content:e.body.trim()}),n}var $T=d(()=>{Mt();Wt();s(gy,"generateRules");});function jT(t,e){let r=t.split(":").filter(Boolean),o=r.length>0?r.pop():t;return [e,...r,`${o}.toml`].join("/")}var UT=d(()=>{s(jT,"canonicalCommandNameToGeminiTomlPath");});function nW(t){let e=t.replace(/\r\n/g,`
|
|
112
|
+
`),e.push({fromTool:"cursor",fromPath:join(t,n[0]),toPath:Tf,feature:"ignore"});}var ey=u(()=>{br();T();jt();s(xw,"cursorHooksToCanonical");s(ku,"importSettings");s(wu,"importIgnore");});async function Tu(t,e,r,o=Ao){let n=join(t,o),i=await dm(n),a={projectRoot:t,destCanonicalSkillsDir:BC,targetName:"cursor",normalize:r,results:e};for(let[p,d]of i)await um(p,d,a);let c=await N(n).catch(()=>[]),l=c.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>c.filter(d=>d.startsWith(p))));for(let p of l){if(m.has(p))continue;let d=await y(p);if(!d)continue;let g=basename(p,".md");await UL(g,p,d,a);}}var ry=u(()=>{T();bc();jt();s(Tu,"importSkills");});async function Dw(t){if(await j(join(t,sr)))return true;let e=[join(t,jr),join(t,tc),join(t,Wl),join(t,wo),join(t,$r),join(t,Ls),join(t,As),join(t,ir)];for(let i of e){let a=await y(i);if(a!==null&&a.trim()!=="")return true}return !!((await N(join(t,Ls))).some(i=>i.endsWith(".md"))||(await N(join(t,As))).some(i=>i.endsWith(".md"))||(await N(join(t,ir))).some(i=>i.endsWith(".md")))}async function Nw(t,e,r){let o=join(t,To),n=false,i=join(t,sr),a=await yt({srcDir:i,destDir:o,extensions:[".mdc"],fromTool:Nc,normalize:r,mapEntry:s(async({srcPath:c,relativePath:l,normalizeTo:m})=>{if(n){let p=await y(c);if(p!==null){let{frontmatter:d}=w(p);if(d.alwaysApply===true)return null}}return Ou(l,o,m,()=>{n=true;})},"mapEntry")});return e.push(...a),n}async function Fw(t,e,r){let o=join(t,tc),n=await y(o);return n===null||n.trim()===""?false:Dc({projectRoot:t,results:e,sourcePath:o,content:n.trim(),normalize:r})}async function vw(t,e,r){let o=join(t,jr),n=await y(o);return n===null||n.trim()===""?false:Dc({projectRoot:t,results:e,sourcePath:o,content:n.trim(),normalize:r})}async function Gw(t,e){let r=join(t,Wl),o=await y(r);if(o===null||o.trim()==="")return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||!("mcpServers"in n))return;let i=join(t,ec);await L(dirname(i)),await I(i,o),e.push({fromTool:Nc,fromPath:r,toPath:ec,feature:"mcp"});}async function Mw(t,e,r){let o=join(t,As),n=join(t,ws);e.push(...await yt({srcDir:o,destDir:n,extensions:[".md"],fromTool:Nc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>ww(i,n,a),"mapEntry")}));}async function $w(t,e,r){let o=join(t,ir),n=join(t,ks);e.push(...await yt({srcDir:o,destDir:n,extensions:[".md"],fromTool:Nc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>kw(i,n,a),"mapEntry")}));}var Nc,jw=u(()=>{T();M();ke();jt();qh();Qh();Nc="cursor";s(Dw,"hasGlobalCursorArtifacts");s(Nw,"importGlobalCursorRulesFromDir");s(Fw,"importGlobalUserRules");s(vw,"importGlobalDotCursorAgents");s(Gw,"importGlobalMcp");s(Mw,"importGlobalAgents");s($w,"importGlobalCommands");});async function Uw(t){if(!await Dw(t))return [];let e=[],r=await U(Nc,t,"global"),o=await Nw(t,e,r);return o||(o=await Fw(t,e,r)),o||await vw(t,e,r),await Gw(t,e),await Tu(t,e,r,Ls),await Mw(t,e,r),await $w(t,e,r),await ku(t,e),await wu(t,e),e}var Kw=u(()=>{mt();jt();ry();ey();jw();s(Uw,"importFromCursorGlobalExports");});async function BB(t,e){let r=join(t,ko),o=await y(r);if(!o)return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||!("mcpServers"in n))return;let i=n.mcpServers;await $t(t,ec,i),e.push({fromTool:"cursor",fromPath:r,toPath:ec,feature:"mcp"});}async function bu(t,e={}){if(e.scope==="global")return Uw(t);let r=[],o=await U("cursor",t);return await bw(t,r,o),r.push(...await z(Pu,t,"project",{normalize:o})),await Tu(t,r,o),await BB(t,r),await ku(t,r),await wu(t,r),r}var oy=u(()=>{mt();T();Ct();Nr();Pw();ey();ry();Kw();jt();ny();s(BB,"importMcp");s(bu,"importFromCursor");});var Ww,Hw,zw=u(()=>{M();lt();Qe();jt();Ww=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o)),a=Ze(n.allowedTools),c=a.length>0?a:Ze(n["allowed-tools"]);return {destPath:o,toPath:`${ks}/${t}`,content:await ht(o,{description:typeof n.description=="string"?n.description:"",hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}},"cursorCommandMapper"),Hw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${ws}/${t}`,content:await Bt(o,n,i)}},"cursorAgentMapper");});function Vw(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:UC}))}var Jw=u(()=>{_t();jt();s(Vw,"lintRules");});function Yw(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>b(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function Xw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers)){let n=o.env&&Object.keys(o.env).length>0,i="url"in o,a="headers"in o;(n||i||a)&&e.push(b(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function Zw(t){if(!t.permissions)return [];let e=t.permissions.ask?.length??0;return t.permissions.allow.length>0||t.permissions.deny.length>0||e>0?[b(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var Qw=u(()=>{Et();s(Yw,"lintCommands");s(Xw,"lintMcp");s(Zw,"lintPermissions");});var WB,HB,zB,VB,Pu,ny=u(()=>{Aw();jt();Qt();oy();zw();Jw();Rt();Qw();WB={name:"cursor",primaryRootInstructionPath:Pn,generateRules:Wh,generateCommands:Hh,generateAgents:Jh,generateSkills:Vh,generateMcp:zh,generatePermissions:Yh,generateHooks:Xh,generateIgnore:Zh,importFrom:bu},HB={rootInstructionPath:Pn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Os,jr]}],skillDir:".cursor/skills",managedOutputs:{dirs:[".cursor/agents",".cursor/commands",".cursor/rules",".cursor/skills"],files:[".cursor/hooks.json",".cursor/mcp.json",".cursorignore","AGENTS.md"]},paths:{rulePath(t,e){return `.cursor/rules/${t}.mdc`},commandPath(t,e){return `.cursor/commands/${t}.md`},agentPath(t,e){return `.cursor/agents/${t}.md`}}},zB={rootInstructionPath:Pn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Os,jr]}],skillDir:Ls,managedOutputs:{dirs:[sr,ir,As,Ls],files:[Pn,jr,Wl,wo,$r,tc]},rewriteGeneratedPath(t){return t===Os?null:t===jr||t===Pn||t.startsWith(`${sr}/`)||t.startsWith(`${ir}/`)||t.startsWith(`${qa}/`)||t.startsWith(`${Ao}/`)||t===ko||t===wo||t===$r?t:t===$p?null:t},mirrorGlobalPath(t,e){return ct(t,Ao,e)},paths:{rulePath(t,e){return `${sr}/${t}.mdc`},commandPath(t,e){return `${ir}/${t}.md`},agentPath(t,e){return `${As}/${t}.md`}}},VB={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Pu={id:"cursor",metadata:{displayName:"Cursor",category:"ide",officialUrl:"https://cursor.com",shortDescription:"AI-first code editor"},generators:WB,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},emptyImportMessage:"No Cursor config found (AGENTS.md or .cursor/rules/*.mdc; with --global: ~/.cursor/{rules/*.mdc,AGENTS.md,mcp.json,hooks.json,cursorignore,skills/,agents/,commands/} and legacy ~/.agentsmesh-exports/cursor/user-rules.md).",lintRules:Vw,lint:{commands:Yw,mcp:Xw,permissions:Zw},project:HB,globalSupport:{capabilities:VB,detectionPaths:[Pn,jr,ko,wo,$r,Ao,As,ir,tc],layout:zB},importer:{commands:{feature:"commands",mode:"directory",source:{project:[ir]},canonicalDir:ks,extensions:[".md"],map:Ww},agents:{feature:"agents",mode:"directory",source:{project:[qa]},canonicalDir:ws,extensions:[".md"],map:Hw}},buildImportPaths:bf,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});function qw(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(bo)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:ar,content:n}]:[]}function tT(t){return tt(t,se)}function eT(t){return t.commands.map(e=>({path:`${se}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function rT(t){return t.agents.map(e=>({path:`${se}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function oT(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:xn,content:e}]}var nT=u(()=>{Q();Mt();at();St();rc();s(qw,"generateRules");s(tT,"generateSkills");s(eT,"generateCommands");s(rT,"generateAgents");s(oT,"generateMcp");});async function sT(t,e={}){let r=e.scope??"project",o=[],n=await U(bo,t,r);return o.push(...await z(xu,t,r,{normalize:n})),await Z(t,r==="global"?Ur:se,bo,o,n),o}var iT=u(()=>{mt();Q();Ct();rc();sy();s(sT,"importFromDeepagentsCli");});function aT(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:bo}))}var cT=u(()=>{_t();rc();s(aT,"lintRules");});function lT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","deepagents-cli","Deep Agents CLI hooks are global-only (~/.deepagents/hooks.json); project-level canonical hooks are not projected.")]:[]:[]}function mT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","deepagents-cli","Deep Agents CLI permissions are managed via shell allow-lists (--shell-allow-list); canonical permissions are not projected.")]}function pT(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","deepagents-cli","Deep Agents CLI has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var uT=u(()=>{Et();s(lT,"lintHooks");s(mT,"lintPermissions");s(pT,"lintIgnore");});var JB,YB,XB,ZB,QB,xu,sy=u(()=>{St();at();nT();iT();cT();uT();Rt();rc();JB={name:bo,primaryRootInstructionPath:ar,generateRules:qw,generateCommands:eT,generateAgents:rT,generateSkills:tT,generateMcp:oT,importFrom:sT},YB={rootInstructionPath:ar,skillDir:se,managedOutputs:{dirs:[se],files:[ar,xn]},paths:{rulePath(t){return ar},commandPath(t){return `${se}/${W(t)}/SKILL.md`},agentPath(t){return `${se}/${$(t)}/SKILL.md`}}},XB={rootInstructionPath:Dn,skillDir:Ur,managedOutputs:{dirs:[Ur],files:[Dn,Ni]},rewriteGeneratedPath(t){return t===ar?Dn:t===xn?Ni:t.startsWith(`${se}/`)?t.replace(`${se}/`,`${Ur}/`):t},paths:{rulePath(t){return Dn},commandPath(t){return `${Ur}/${W(t)}/SKILL.md`},agentPath(t){return `${Ur}/${$(t)}/SKILL.md`}}},ZB={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},QB={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},xu={id:bo,metadata:{displayName:"Deep Agents CLI",category:"cli",officialUrl:"https://github.com/langchain-ai/deepagents",shortDescription:"LangChain Deep Agents framework CLI"},generators:JB,capabilities:ZB,emptyImportMessage:"No Deep Agents CLI config found (.deepagents/AGENTS.md, .deepagents/skills, or .mcp.json).",lintRules:aT,lint:{hooks:lT,permissions:mT,ignore:pT},supportsConversion:{commands:true,agents:true},project:YB,globalSupport:{capabilities:QB,detectionPaths:[Dn,Ni],layout:XB},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[ar],global:[Dn]},canonicalDir:HC,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[xn],global:[Ni]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Pf,detectionPaths:[ar,xn]};});function dT(t){let e={name:t.name};return t.description&&(e.description=t.description.slice(0,500)),t.model?e.model=t.model:e.model="inherit",t.tools.length>0&&(e.tools=t.tools),P(e,t.body.trim()||"")}var gT=u(()=>{M();s(dT,"serializeDroid");});function fT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(cr)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:lr,content:n}]:[]}function hT(t){return tt(t,_e)}function yT(t){return t.commands.map(e=>({path:`${_e}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function _T(t){return t.agents.map(e=>({path:`${Po}/${e.name}.md`,content:dT(e)}))}function IT(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:xo,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var RT=u(()=>{Q();Mt();St();gT();vi();s(fT,"generateRules");s(hT,"generateSkills");s(yT,"generateCommands");s(_T,"generateAgents");s(IT,"generateMcp");});async function CT(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let a=n.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await $t(t,ST,c),r.push({fromTool:cr,fromPath:e,toPath:ST,feature:"mcp"}));}var ST,ET=u(()=>{T();Nr();vi();ST=".agentsmesh/mcp.json";s(CT,"importFactoryDroidMcp");});async function OT(t,e={}){let r=e.scope??"project",o=[],n=await U(cr,t,r);return o.push(...await z(Du,t,r,{normalize:n})),await Z(t,r==="global"?Do:_e,cr,o,n),await CT(t,r==="global"?Ts:xo,o),o}var LT=u(()=>{mt();Q();Ct();ET();vi();iy();s(OT,"importFromFactoryDroid");});function AT(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:cr}))}var kT=u(()=>{_t();vi();s(AT,"lintRules");});function wT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","factory-droid","Factory Droid hooks are configured via settings.json events (PreToolUse/PostToolUse), not standalone files; canonical hooks are not projected.")]:[]:[]}function TT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","factory-droid","Factory Droid permissions are managed via CLI flags (--skip-permissions-unsafe); canonical permissions are not projected.")]}function bT(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","factory-droid","Factory Droid has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var PT=u(()=>{Et();s(wT,"lintHooks");s(TT,"lintPermissions");s(bT,"lintIgnore");});var tW,eW,rW,xT,Du,iy=u(()=>{RT();vi();LT();kT();PT();Rt();St();tW={name:cr,primaryRootInstructionPath:lr,generateRules:fT,generateCommands:yT,generateAgents:_T,generateSkills:hT,generateMcp:IT,importFrom:OT},eW={rootInstructionPath:lr,skillDir:_e,managedOutputs:{dirs:[_e,Po],files:[lr,xo]},paths:{rulePath(t){return lr},commandPath(t){return `${_e}/${W(t)}/SKILL.md`},agentPath(t){return `${Po}/${t}.md`}}},rW={rootInstructionPath:Nn,skillDir:Do,managedOutputs:{dirs:[Do,Fi],files:[Nn,Ts]},rewriteGeneratedPath(t){return t===lr?Nn:t===xo?Ts:t.startsWith(`${_e}/`)?t.replace(`${_e}/`,`${Do}/`):t.startsWith(`${Po}/`)?t.replace(`${Po}/`,`${Fi}/`):t},paths:{rulePath(t){return Nn},commandPath(t){return `${Do}/${W(t)}/SKILL.md`},agentPath(t){return `${Fi}/${t}.md`}}},xT={rules:"native",additionalRules:"embedded",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Du={id:cr,metadata:{displayName:"Factory Droid",category:"agent-platform",officialUrl:"https://www.factory.ai",shortDescription:"Factory.ai's coding droid"},generators:tW,capabilities:xT,emptyImportMessage:"No Factory Droid config found (AGENTS.md, .factory/skills, or .factory/mcp.json).",lintRules:AT,lint:{hooks:wT,permissions:TT,ignore:bT},supportsConversion:{commands:true},project:eW,globalSupport:{capabilities:xT,detectionPaths:[Nn,Ts,Fi],layout:rW},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[lr],global:[Nn]},canonicalDir:VC,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:xf,detectionPaths:[lr,xo,Po]};});var Zs,Sr,en,DT,NT,Me,Nu,ha,Fu,Im,Qs,FT,vT,qs,vu,Rm,Sm,ay,cy,Fc,ly,vc,Gc,Gu,Mc,ya,Cm,Wt=u(()=>{Zs="gemini-cli",Sr="GEMINI.md",en="AGENTS.md",DT=".gemini/rules",NT=".gemini/GEMINI.md",Me=".gemini/commands",Nu=".gemini/policies",ha=".gemini/settings.json",Fu=".geminiignore",Im=".gemini/skills",Qs=".gemini/agents",FT=".gemini/system.md",vT=`${Nu}/permissions.toml`,qs=".agentsmesh/rules",vu=".agentsmesh/commands",Rm=".agentsmesh/agents",Sm=".agentsmesh/skills",ay=".agentsmesh/mcp.json",cy=".agentsmesh/hooks.yaml",Fc=".agentsmesh/ignore",ly=".agentsmesh/permissions.yaml",vc=".gemini/GEMINI.md",Gc=".gemini/AGENTS.md",Gu=".gemini/settings.json",Mc=".gemini/commands",ya=".gemini/skills",Cm=".gemini/agents";});function my(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>!(i.root||i.targets.length>0&&!i.targets.includes("gemini-cli")));if(!e&&r.length===0)return [];let o=st(e?.body.trim()??"",r),n=[{path:Sr,content:o}];return e&&n.push({path:en,content:e.body.trim()}),n}var GT=u(()=>{Mt();Wt();s(my,"generateRules");});function MT(t,e){let r=t.split(":").filter(Boolean),o=r.length>0?r.pop():t;return [e,...r,`${o}.toml`].join("/")}var $T=u(()=>{s(MT,"canonicalCommandNameToGeminiTomlPath");});function oW(t){let e=t.replace(/\r\n/g,`
|
|
113
113
|
`);return e.includes('"""')?JSON.stringify(e):`"""
|
|
114
114
|
${e}
|
|
115
|
-
"""`}function
|
|
115
|
+
"""`}function nW(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${oW(t.body.trim()||"")}`].join(`
|
|
116
116
|
`)+`
|
|
117
|
-
`}function
|
|
118
|
-
`)}]}var
|
|
119
|
-
`)}function
|
|
120
|
-
`)}]}var
|
|
117
|
+
`}function py(t){return t.commands.map(e=>({path:MT(e.name,Me),content:nW(e)}))}var jT=u(()=>{Wt();$T();s(oW,"serializeTomlMultilineLiteral");s(nW,"serializeGeminiCommand");s(py,"generateCommands");});function uy(t){return t.agents.map(e=>{let r={name:e.name,kind:"local",description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,permissionMode:e.permissionMode||void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=P(r,e.body.trim()||"");return {path:`${Qs}/${e.name}.md`,content:o}})}var UT=u(()=>{M();Wt();s(uy,"generateAgents");});function dy(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${Im}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Im}/${r.name}/${a}`,content:i.content});}}return e}var KT=u(()=>{M();Wt();s(dy,"generateSkills");});function sW(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function gy(t){let e={},r=false;if(t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&(e.mcpServers=t.mcp.mcpServers,r=true),t.agents.length>0&&(e.experimental={enableAgents:true},r=true),t.hooks){let o=Object.entries(t.hooks).flatMap(([n,i])=>{let a=sW(n);if(!a||!Array.isArray(i))return [];let c=i.filter(l=>typeof l=="object"&&l!==null&&dn(l)).map((l,m)=>({matcher:l.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:Kt(l),timeout:l.timeout}]}));return c.length>0?[[a,c]]:[]});o.length>0&&(e.hooks=Object.fromEntries(o),r=true);}return r&&(e.context={fileName:[Sr,en]}),Object.keys(e).length===0?[]:[{path:ha,content:JSON.stringify(e,null,2)}]}var fy=u(()=>{br();Wt();s(sW,"mapHookEvent");s(gy,"generateGeminiSettingsFiles");});function hy(t){return !t.ignore||t.ignore.length===0?[]:[{path:Fu,content:t.ignore.join(`
|
|
118
|
+
`)}]}var BT=u(()=>{Wt();s(hy,"generateIgnore");});var WT=u(()=>{GT();jT();UT();KT();fy();BT();});var HT=u(()=>{WT();});function _a(t){return JSON.stringify(t)}function iW(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function aW(t){let e=t.match(/^Bash\((.*)\)$/);if(e&&typeof e[1]=="string")return {kind:"bash",prefix:e[1]};let r=t.match(/^Read\((.*)\)$/);return r&&typeof r[1]=="string"?{kind:"read",path:r[1]}:t==="Read"||t==="Grep"||t==="LS"||t==="WebFetch"?{kind:"tool",tool:t}:{kind:"unknown",raw:t}}function Mu(t,e,r){return ["[[rule]]",`decision = ${_a(t)}`,`priority = ${e}`,...r,""].join(`
|
|
119
|
+
`)}function zT(t,e,r){let o=aW(t),n={Read:"read_file",Grep:"grep_search",LS:"list_directory",WebFetch:"web_fetch",Bash:"run_shell_command"};if(o.kind==="tool"){let i=n[o.tool]??o.tool;return Mu(e,r,[`toolName = ${_a(i)}`])}if(o.kind==="bash"){let i=o.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return Mu(e,r,[`toolName = ${_a(n.Bash)}`,`commandPrefix = ${_a(i)}`])}return o.kind==="read"?Mu(e,r,[`toolName = ${_a(n.Read)}`,`argsPattern = ${_a(iW(o.path))}`]):Mu(e,r,[`toolName = ${_a(o.raw)}`])}function VT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions;if(e.length+r.length===0)return [];let n=[];return e.forEach((i,a)=>{let c=zT(i,"allow",100+a);c&&n.push(c);}),r.forEach((i,a)=>{let c=zT(i,"deny",200+a);c&&n.push(c);}),n.length===0?[]:[{path:vT,content:n.join(`
|
|
120
|
+
`)}]}var JT=u(()=>{Wt();s(_a,"escapeTomlBasicString");s(iW,"escapeRegexLiteral");s(aW,"parsePermissionExpr");s(Mu,"ruleForDecision");s(zT,"permissionExprToGeminiRule");s(VT,"generateGeminiPermissionsPolicies");});function yy(t){switch(t){case "BeforeTool":case "preToolUse":return "PreToolUse";case "AfterTool":case "postToolUse":return "PostToolUse";case "Notification":case "notification":return "Notification";default:return null}}function $u(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return w(t);if(r===0){let o=t.indexOf("+++",3);if(o!==-1)try{let n=t.slice(3,o).trim(),i=t.slice(o+3).trim();return {frontmatter:n===""?{}:parse$1(n)??{},body:i}}catch{return {frontmatter:{},body:t.trim()}}}return {frontmatter:{},body:t.trim()}}var _y=u(()=>{M();s(yy,"mapGeminiHookEvent");s($u,"parseFlexibleFrontmatter");});async function Iy(t,e){let r=join(t,ha),o=await y(r);if(o===null)return;let n;try{n=JSON.parse(o);}catch{}if(!n)return;let i=n.mcpServers;if(i!==void 0&&typeof i=="object"&&i!==null&&Object.keys(i).length>0){let l=join(t,ay);await L(join(t,".agentsmesh")),await I(l,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:ay,feature:"mcp"});}let a=n.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(l=>typeof l=="string")){let l=join(t,Fc);await L(join(t,".agentsmesh")),await I(l,a.join(`
|
|
121
121
|
`)+`
|
|
122
|
-
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:
|
|
122
|
+
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Fc,feature:"ignore"});}let c=n.hooks;if(c!==void 0&&typeof c=="object"&&c!==null){let l=Object.entries(c).flatMap(([m,p])=>{let d=yy(m);if(!d||!Array.isArray(p))return [];let g=p.filter(f=>f!==null&&typeof f=="object"&&typeof f.matcher=="string"&&Array.isArray(f.hooks)).flatMap(f=>f.hooks.filter(h=>h!==null&&typeof h=="object"&&dn(h)).map(h=>({matcher:f.matcher,command:Kt(h),type:"command",timeout:typeof h.timeout=="number"?h.timeout:void 0})));if(g.length===0){let f=p.filter(h=>h!==null&&typeof h=="object"&&typeof h.matcher=="string"&&dn(h)).map(h=>({matcher:h.matcher,command:Kt(h),type:"command"}));return f.length>0?[[d,f]]:[]}return g.length>0?[[d,g]]:[]});if(l.length>0){let m=Object.fromEntries(l),p=join(t,cy);await L(join(t,".agentsmesh")),await I(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:cy,feature:"hooks"});}}}var YT=u(()=>{br();T();Wt();_y();s(Iy,"importGeminiSettings");});async function XT(t,e){let r=join(t,Fu),o=await y(r);if(o!==null&&o.trim()){let n=o.split(/\r?\n/).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#"));if(n.length>0){await L(join(t,".agentsmesh"));let i=join(t,Fc);await I(i,n.join(`
|
|
123
123
|
`)+`
|
|
124
|
-
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:
|
|
125
|
-
`),e.push({fromTool:
|
|
126
|
-
`)}]}var
|
|
127
|
-
`)}]}function
|
|
128
|
-
`)}]}function
|
|
124
|
+
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Fc,feature:"ignore"});}}}var Sy=u(()=>{T();Wt();_y();YT();s(XT,"importGeminiIgnore");});function uW(t){return t.replace(/\\(.)/g,"$1")}function dW(t){switch(t){case "read_file":return "Read";case "grep_search":return "Grep";case "list_directory":return "LS";case "web_fetch":return "WebFetch";case "run_shell_command":return "Bash";default:return null}}function gW(t){return `Bash(${t}:*)`}function fW(t){return `Read(${uW(t)})`}async function ZT(t){let e=[],r=join(t,Nu),o;try{o=await N(r);}catch{return e}let n=o.filter(d=>d.endsWith(".toml"));if(n.length===0)return e;let i=[],a=[],c=new Set,l=new Set;for(let d of n){let g=await y(d);if(!g)continue;let f;try{f=parse$1(g);}catch{continue}let h=f&&typeof f=="object"&&"rule"in f?f.rule:void 0;if(Array.isArray(h))for(let O of h){if(!O||typeof O!="object")continue;let R=O,E=typeof R.toolName=="string"?R.toolName:null,A=typeof R.decision=="string"?R.decision:null;if(!E||!A)continue;let F=dW(E);if(!F)continue;let v=null;F==="Bash"?typeof R.commandPrefix=="string"&&R.commandPrefix.trim()&&(v=gW(R.commandPrefix.trim())):F==="Read"?typeof R.argsPattern=="string"&&R.argsPattern.trim()?v=fW(R.argsPattern.trim()):v="Read":v=F,v&&(A==="allow"?c.has(v)||(c.add(v),i.push(v)):A==="deny"&&(l.has(v)||(l.add(v),a.push(v))));}}if(i.length===0&&a.length===0)return e;await L(join(t,".agentsmesh"));let m=join(t,ly),p=stringify({allow:i,deny:a});return await I(m,p.trimEnd()+`
|
|
125
|
+
`),e.push({fromTool:Zs,fromPath:join(t,Nu),toPath:ly,feature:"permissions"}),e}var QT=u(()=>{T();Wt();s(uW,"unescapeRegexLiteral");s(dW,"toolNameToPermissionBase");s(gW,"commandPrefixToBashExpr");s(fW,"argsPatternToReadExpr");s(ZT,"importGeminiPolicies");});function Cy(t,e){let r=new Set([e,e.replace(/\\/g,"/"),e.replace(/\//g,"\\")]);try{r.add(realpathSync(e)),r.add(realpathSync.native(e));}catch{}return Array.from(r).reduce((n,i)=>{let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n.replace(new RegExp(`${a}[/\\\\]\\.agentsmesh[/\\\\]`,"g"),".agentsmesh/").replaceAll(`${i}/.agentsmesh`,".agentsmesh").replaceAll(`${i}\\.agentsmesh`,".agentsmesh")},t).replace(/(?:[A-Za-z]:)?[^\s"'`()<>]+[/\\]\.agentsmesh[/\\]/g,".agentsmesh/")}var tb=u(()=>{s(Cy,"stripProjectRootCanonicalPrefix");});async function rb(t,e,r){let o=join(t,Im),i=(await N(o)).filter(c=>basename(c)==="SKILL.md");for(let c of i){let l=await y(c);if(!l)continue;let m=basename(c.slice(0,-9)),p=w(l),d=Wa(p.frontmatter,m);if(d){let A=join(t,Rm);await L(A);let F=join(A,`${d.name}.md`);await I(F,fs(d,r(p.body,c,F))),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${Rm}/${d.name}.md`,feature:"agents"});continue}let g=join(t,Sm,m,"SKILL.md"),f=r(l,c,g),h=join(t,Sm,m);await L(h);let{frontmatter:O,body:R}=w(f);await I(g,await uo(g,{...O,name:m},R)),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${Sm}/${m}/SKILL.md`,feature:"skills"});let E=await N(dirname(c));for(let A of E){if(A===c)continue;let F=await y(A);if(F===null)continue;let v=relative(dirname(c),A).replace(/\\/g,"/"),G=join(h,v);await L(dirname(G)),await I(G,r(F,A,G)),e.push({fromTool:"gemini-cli",fromPath:A,toPath:`${Sm}/${m}/${v}`,feature:"skills"});}}let a=join(t,Qs);try{let l=(await N(a)).filter(m=>m.endsWith(".md"));for(let m of l){let p=await y(m);if(!p)continue;let{frontmatter:d,body:g}=w(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),O=join(t,Rm);await L(O);let R=join(O,h),E=r(g,m,R);await I(R,await Bt(R,{...d,name:typeof d.name=="string"?d.name:basename(h,".md"),maxTurns:d.maxTurns??d["max-turns"]??d.max_turns,permissionMode:d.permissionMode??d["permission-mode"]??d.permission_mode,disallowedTools:d.disallowedTools??d["disallowed-tools"]??d.disallowed_tools},E)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${Rm}/${h}`,feature:"agents"});}}catch{}}var ob=u(()=>{T();M();lt();at();Wt();s(rb,"importGeminiSkillsAndAgents");});async function hW(t,e,r){let o=await U("codex-cli",t),n=join(t,qs),i=join(t,en),a=join(t,NT),c=[i,a,join(t,Sr),join(t,FT)],l=null,m=c[c.length-1];for(let v of c){let G=await y(v);if(G!==null){l=G,m=v;break}}if(l===null)return;await L(n);let p=join(n,"_root.md"),d=m===i||m===a?o(l,m,p):l,g=await Xo({content:d,projectRoot:t,rulesDir:qs,sourcePath:m,fromTool:Zs,normalize:r});e.push(...g.results);let f=r(g.rootContent,m,p),h=Cy(f.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:O,body:R}=w(h),A=O.root===true?O:{...O,root:true},F=Cy(await K(p,A,R),t);await I(p,F),e.push({fromTool:Zs,fromPath:m,toPath:`${qs}/_root.md`,feature:"rules"});}async function Uu(t){let e=[],r=await U(Zs,t);return await hW(t,e,r),e.push(...await z(Ku,t,"project",{normalize:r})),await rb(t,e,r),await Iy(t,e),await XT(t,e),e.push(...await ZT(t)),e}var Ly=u(()=>{mt();T();M();lt();Ac();Ct();Wt();Ay();Sy();QT();tb();ob();s(hW,"importRootRule");s(Uu,"importFromGemini");});async function sb(t,e,r){let o=t.replace(/\\/g,"/"),n=join(e,o),{frontmatter:i,body:a}=$u(r(n)),c=yn(i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:n,toPath:`${qs}/${o}`,feature:"rules",content:await K(n,l,a)}}async function ib(t,e,r){let o=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),n=join(e,o),i=r(n),{frontmatter:a,body:c}=t.endsWith(".toml")?_W(i):$u(i),l=Ze(a.allowedTools),m=Ze(a["allowed-tools"]),p=l.length>0?l:m;return {destPath:n,toPath:`${vu}/${o}`,feature:"commands",content:await ht(n,{description:typeof a.description=="string"?a.description:"",hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:p,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"allowedTools")||Object.prototype.hasOwnProperty.call(a,"allowed-tools")},c)}}function _W(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var ab=u(()=>{lt();Qe();Sy();Wt();s(sb,"mapGeminiRuleFile");s(ib,"mapGeminiCommandFile");s(_W,"parseTomlCommand");});var cb,lb,mb=u(()=>{ab();cb=s(({relativePath:t,destDir:e,normalizeTo:r})=>sb(t,e,r),"geminiRuleMapper"),lb=s(({relativePath:t,destDir:e,normalizeTo:r})=>ib(t,e,r),"geminiCommandMapper");});function pb(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:Zs}))}var ub=u(()=>{_t();Wt();s(pb,"lintRules");});function db(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>b(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function gb(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification"],r=new Set(e);return Object.keys(t.hooks).filter(o=>!r.has(o)).map(o=>_s(o,"gemini-cli",e))}var fb=u(()=>{Et();s(db,"lintCommands");s(gb,"lintHooks");});function hb(t,e){return e==="project"&&ti("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:gy(t)}var yb=u(()=>{xt();fy();s(hb,"emitScopedGeminiSettings");});var IW,RW,SW,CW,Ku,Ay=u(()=>{HT();_i();JT();Wt();Ly();mb();ub();Rt();Ua();at();fb();yb();Qt();Cu();IW={name:"gemini-cli",primaryRootInstructionPath:Sr,generateRules:my,generateCommands:py,generateAgents:uy,generateSkills:dy,generateIgnore:hy,generatePermissions:VT,importFrom:Uu},RW={rootInstructionPath:Sr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[en]}],extraRuleOutputPaths(){return [en]},skillDir:".gemini/skills",managedOutputs:{dirs:[".gemini/agents",".gemini/commands",".gemini/skills",".agents/skills"],files:["AGENTS.md","GEMINI.md",".gemini/settings.json",".gemini/policies/permissions.toml",".geminiignore"]},mirrorGlobalPath(t,e){return ct(t,".gemini/skills",e)},paths:{rulePath(t,e){return Sr},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),o=r.pop()??t;return `${Me}/${r.join("/")}/${o}.toml`}return `${Me}/${t}.toml`},agentPath(t,e){return Ve(e,"gemini-cli")?`.gemini/skills/${$(t)}/SKILL.md`:`${Qs}/${t}.md`}}},SW={rootInstructionPath:vc,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Gc]}],extraRuleOutputPaths(){return [Gc]},skillDir:ya,managedOutputs:{dirs:[Mc,ya,Cm],files:[vc,Gc,Gu]},rewriteGeneratedPath(t){return t===Sr?vc:t===en?Gc:t===ha?Gu:t.startsWith(`${Me}/`)?t.replace(`${Me}/`,`${Mc}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${ya}/`):t.startsWith(`${Qs}/`)?t.replace(`${Qs}/`,`${Cm}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return ct(t,ya,e)},paths:{rulePath(t,e){return vc},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),o=r.pop()??t;return `${Mc}/${r.join("/")}/${o}.toml`}return `${Mc}/${t}.toml`},agentPath(t,e){return Ve(e,"gemini-cli")?`${ya}/${$(t)}/SKILL.md`:`${Cm}/${t}.md`}}},CW={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},Ku={id:"gemini-cli",metadata:{displayName:"Gemini CLI",category:"cli",officialUrl:"https://github.com/google-gemini/gemini-cli",shortDescription:"Google's terminal Gemini agent"},generators:IW,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Dr("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:pb,lint:{commands:db,hooks:gb},emitScopedSettings:hb,mergeGeneratedOutputContent(t,e,r,o){let n=e?.content??t;return n!==null&&o===ha?gw(n,r):null},project:RW,globalSupport:{capabilities:CW,detectionPaths:[vc,Gc,Gu,Mc,ya,Cm],layout:SW},importer:{rules:{feature:"rules",mode:"directory",source:{project:[DT]},canonicalDir:qs,extensions:[".md"],map:cb},commands:{feature:"commands",mode:"directory",source:{project:[Me]},canonicalDir:vu,extensions:[".md",".toml"],map:lb}},buildImportPaths:Df,detectionPaths:["GEMINI.md",".gemini"]};});function _b(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(No)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:mr,content:n}]:[]}function Ib(t){return tt(t,pe)}function Rb(t){return t.commands.map(e=>({path:`${pe}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function Sb(t){return t.agents.map(e=>({path:`${pe}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function Cb(t){return t.ignore.length===0?[]:[{path:Fn,content:t.ignore.join(`
|
|
126
|
+
`)}]}var Eb=u(()=>{Q();Mt();at();St();oc();s(_b,"generateRules");s(Ib,"generateSkills");s(Rb,"generateCommands");s(Sb,"generateAgents");s(Cb,"generateIgnore");});async function Ob(t,e={}){let r=e.scope??"project",o=[],n=await U(No,t,r);return o.push(...await z(Bu,t,r,{normalize:n})),await Z(t,r==="global"?pr:pe,No,o,n),o}var Lb=u(()=>{mt();Q();Ct();oc();ky();s(Ob,"importFromGoose");});function Ab(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:No}))}var kb=u(()=>{_t();oc();s(Ab,"lintRules");});function wb(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Tb(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function bb(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var Pb=u(()=>{Et();s(wb,"lintHooks");s(Tb,"lintPermissions");s(bb,"lintMcp");});var EW,OW,LW,xb,Bu,ky=u(()=>{St();at();Eb();Qt();Lb();kb();Pb();Rt();oc();EW={name:No,primaryRootInstructionPath:mr,generateRules:_b,generateCommands:Rb,generateAgents:Sb,generateSkills:Ib,generateIgnore:Cb,importFrom:Ob},OW={rootInstructionPath:mr,skillDir:pe,managedOutputs:{dirs:[pe],files:[mr,Fn]},paths:{rulePath(t){return mr},commandPath(t){return `${pe}/${W(t)}/SKILL.md`},agentPath(t){return `${pe}/${$(t)}/SKILL.md`}}},LW={rootInstructionPath:vn,skillDir:pr,managedOutputs:{dirs:[pr],files:[vn,Gi]},rewriteGeneratedPath(t){return t===mr?vn:t===Fn?Gi:(t.startsWith(`${pe}/`),t)},mirrorGlobalPath(t,e){return ct(t,pr,e)},paths:{rulePath(t){return vn},commandPath(t){return `${pr}/${W(t)}/SKILL.md`},agentPath(t){return `${pr}/${$(t)}/SKILL.md`}}},xb={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Bu={id:No,metadata:{displayName:"Goose",category:"cli",officialUrl:"https://block.github.io/goose",shortDescription:"Block's open-source AI agent"},generators:EW,capabilities:xb,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:Ab,lint:{hooks:wb,permissions:Tb,mcp:bb},supportsConversion:{commands:true,agents:true},project:OW,globalSupport:{capabilities:xb,detectionPaths:[vn,Gi,pr],layout:LW},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[mr],global:[vn]},canonicalDir:ZC,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Fn],global:[Gi]},canonicalDir:".agentsmesh",canonicalFilename:QC}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Nf,detectionPaths:[mr,Fn]};});function Db(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Gn)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:Kr,content:n}]:[]}var Nb=u(()=>{Mt();nc();s(Db,"generateRules");});async function Fb(t,e={}){let r=e.scope??"project",o=await U(Gn,t,r);return z(Wu,t,r,{normalize:o})}var vb=u(()=>{mt();Ct();nc();wy();s(Fb,"importFromJules");});function Gb(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Gn}))}var Mb=u(()=>{_t();nc();s(Gb,"lintRules");});function $b(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","jules","Jules has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function jb(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","jules","Jules has no permissions system; canonical permissions are not projected.")]}function Ub(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","jules","Jules is a cloud-based agent with no dedicated ignore file; canonical ignore patterns are not projected.")]}function Kb(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","jules","Jules is a cloud-based agent with no MCP support; canonical MCP servers are not projected.")]}function Bb(t){return t.commands.length===0?[]:[b(".agentsmesh/commands","jules","Jules has no command system; canonical commands are not projected.")]}var Wb=u(()=>{Et();s($b,"lintHooks");s(jb,"lintPermissions");s(Ub,"lintIgnore");s(Kb,"lintMcp");s(Bb,"lintCommands");});var AW,kW,wW,Wu,wy=u(()=>{Nb();vb();Mb();Wb();Rt();nc();AW={name:Gn,primaryRootInstructionPath:Kr,generateRules:Db,importFrom:Fb},kW={rootInstructionPath:Kr,managedOutputs:{dirs:[],files:[Kr]},paths:{rulePath(t){return Kr},commandPath(){return null},agentPath(){return null}}},wW={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Wu={id:Gn,metadata:{displayName:"Jules",category:"agent-platform",officialUrl:"https://jules.google",shortDescription:"Google's autonomous coding agent"},generators:AW,capabilities:wW,emptyImportMessage:"No Jules config found (AGENTS.md).",lintRules:Gb,lint:{hooks:$b,permissions:jb,ignore:Ub,mcp:Kb,commands:Bb},project:kW,importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Kr]},canonicalDir:tE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Ff,detectionPaths:[Kr]};});function Hb(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Fo,content:r.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("junie"))continue;let n=basename(o.source,".md");e.push({path:`${Vl}/${n}.md`,content:o.body.trim()||""});}return e}function bW(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),au(t)?(e.command=t.command,e.args=t.args):(e.url=t.url,Object.keys(t.headers).length>0&&(e.headers=t.headers)),Object.keys(t.env).length>0&&(e.env=t.env),e}function zb(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).map(([r,o])=>[r,bW(o)]));return [{path:zl,content:JSON.stringify({mcpServers:e},null,2)}]}function Vb(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${sc}/${e.name}.md`,content:P(r,e.body.trim()||"")}})}function Jb(t){return t.agents.map(e=>{let r={name:e.name,description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,skills:e.skills.length>0?e.skills:void 0};return Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];}),{path:`${ic}/${e.name}.md`,content:P(r,e.body.trim()||"")}})}function Yb(t){return t.ignore.length===0?[]:[{path:Jl,content:t.ignore.join(`
|
|
127
|
+
`)}]}function Xb(t){return tt(t,$i)}function Zb(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>o.root?false:o.targets.length===0||o.targets.includes("junie"));return st(e?.body.trim()??"",r)}var Qb=u(()=>{cu();Q();Mt();M();ac();s(Hb,"generateRules");s(bW,"toJunieMcpServer");s(zb,"generateMcp");s(Vb,"generateCommands");s(Jb,"generateAgents");s(Yb,"generateIgnore");s(Xb,"generateSkills");s(Zb,"renderJunieGlobalInstructions");});async function PW(t,e,r){let o=[Fo,jp,rE,oE],n=join(t,vf);for(let i of o){let a=join(t,i),c=await y(a);if(c===null)continue;let l=await Xo({content:c,projectRoot:t,rulesDir:Kp,sourcePath:a,fromTool:Mi,normalize:r});e.push(...l.results);let{frontmatter:m,body:p}=w(r(l.rootContent,a,n)),d=await K(n,{root:true,description:typeof m.description=="string"?m.description:void 0,globs:Array.isArray(m.globs)?m.globs:void 0},p);await I(n,d),e.push({fromTool:Mi,fromPath:a,toPath:vf,feature:"rules"});return}}async function Hu(t){let e=[],r=await U(Mi,t);return await PW(t,e,r),e.push(...await z(zu,t,"project",{normalize:r})),await Z(t,$i,Mi,e,r),e}var Ty=u(()=>{mt();T();M();Q();Ac();lt();Ct();ac();by();s(PW,"importRootRule");s(Hu,"importFromJunie");});function tP(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Mi}))}var eP=u(()=>{_t();ac();s(tP,"lintRules");});function rP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers))hA(o)&&e.push(b(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${o.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var oP=u(()=>{cu();Et();s(rP,"lintMcp");});var xW,DW,NW,FW,zu,by=u(()=>{Qb();ac();Qt();Ty();eP();oP();Rt();xW={name:"junie",primaryRootInstructionPath:Fo,generateRules:Hb,generateCommands:Vb,generateAgents:Jb,generateSkills:Xb,generateMcp:zb,generateIgnore:Yb,importFrom:Hu},DW={rootInstructionPath:Fo,skillDir:".junie/skills",managedOutputs:{dirs:[".junie/agents",".junie/commands",".junie/rules",".junie/skills"],files:[".aiignore",".junie/AGENTS.md",".junie/mcp/mcp.json"]},paths:{rulePath(t,e){return `${Vl}/${t}.md`},commandPath(t,e){return `${sc}/${t}.md`},agentPath(t,e){return `${ic}/${t}.md`}}},NW={rootInstructionPath:ji,renderPrimaryRootInstruction:Zb,skillDir:Xl,managedOutputs:{dirs:[Xl,Zl,Ql,nE],files:[ji,Up]},rewriteGeneratedPath(t){return t===Fo?ji:t.startsWith(`${Vl}/`)?ji:t.startsWith(`${$i}/`)?t.replace(`${$i}/`,`${Xl}/`):t.startsWith(`${sc}/`)?t.replace(`${sc}/`,`${Ql}/`):t.startsWith(`${ic}/`)?t.replace(`${ic}/`,`${Zl}/`):t===zl?Up:t===Jl?null:t},mirrorGlobalPath(t,e){return ct(t,".junie/skills",e)},paths:{rulePath(t,e){return ji},commandPath(t,e){return `${Ql}/${t}.md`},agentPath(t,e){return `${Zl}/${t}.md`}}},FW={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},zu={id:"junie",metadata:{displayName:"Junie",category:"ide",officialUrl:"https://www.jetbrains.com/junie",shortDescription:"JetBrains AI coding agent"},generators:xW,capabilities:{rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},emptyImportMessage:"No Junie config found (.junie/guidelines.md, .junie/AGENTS.md, .junie/skills, .junie/mcp/mcp.json, or .aiignore).",lintRules:tP,lint:{mcp:rP},project:DW,globalSupport:{capabilities:FW,detectionPaths:[ji,Xl,Zl,Ql,Up],layout:NW},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Kp,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:sE,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:iE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[zl]},canonicalDir:".agentsmesh",canonicalFilename:aE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Jl]},canonicalDir:".agentsmesh",canonicalFilename:cE}},buildImportPaths:Gf,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function sP(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:vo,content:r.body.trim()?r.body:""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(ue))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs);let a=Object.keys(i).length>0?P(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${Mn}/${n}.md`,content:a});}return e}function iP(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${$n}/${e.name}.md`,content:P(r,e.body.trim()||"")}})}function aP(t){return t.agents.map(e=>{let r=basename(e.source,".md"),o={mode:"subagent"};return e.description&&(o.description=e.description),e.model&&(o.model=e.model),e.tools.length>0&&(o.tools=e.tools),e.disallowedTools.length>0&&(o.disallowedTools=e.disallowedTools),{path:`${jn}/${r}.md`,content:P(o,e.body.trim()||"")}})}function cP(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ps,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function lP(t){return t.ignore.length===0?[]:[{path:cc,content:t.ignore.join(`
|
|
128
|
+
`)}]}function mP(t){return tt(t,Br)}var pP=u(()=>{Q();M();Vi();s(sP,"generateRules");s(iP,"generateCommands");s(aP,"generateAgents");s(cP,"generateMcp");s(lP,"generateIgnore");s(mP,"generateSkills");});var Vu,Ju,uP,xy=u(()=>{M();lt();Vi();Vu=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Ns}/${t}`,content:await K(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"kiloNonRootRuleMapper"),Ju=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${uc}/${t}`,content:await ht(o,{hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),uP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${zi}/${t}`,content:await Bt(o,n,i)}},"kiloAgentMapper");});async function dP(t){try{return await stat(t),!0}catch{return false}}async function MW(t,e,r){let o=join(t,Ui);if(!await dP(o))return;let n=join(t,Ns),i=join(o,Ny),c=e.some(l=>l.toPath===Dy)?null:await y(i);if(c!==null){let l=join(t,Dy),m=r(c,i,l),{body:p}=w(m),d=await K(l,{root:true},p);await I(l,d),e.push({feature:"rules",fromTool:ue,fromPath:`${Ui}/${Ny}`,toPath:Dy});}e.push(...await yt({srcDir:o,destDir:n,extensions:[".md"],fromTool:ue,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:d})=>{let g=await Vu({absolutePath:l,relativePath:m,content:p,destDir:n,normalizeTo:d});return m===Ny||!g?null:{...g,feature:"rules"}},"mapEntry")}));}async function $W(t,e,r){let o=join(t,lc);if(!await dP(o))return;let n=join(t,uc);e.push(...await yt({srcDir:o,destDir:n,extensions:[".md"],fromTool:ue,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:c,normalizeTo:l})=>{let m=await Ju({absolutePath:i,relativePath:a,content:c,destDir:n,normalizeTo:l});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function jW(t,e,r){let o=join(t,Wp),n=await y(o);if(n===null)return;let i;try{i=parse(n);}catch{return}if(!(!i||!Array.isArray(i.customModes)))for(let a of i.customModes){if(!a||typeof a!="object")continue;let c=a;if(typeof c.slug!="string"||c.slug.length===0)continue;let l=c.slug,m=join(t,zi,`${l}.md`),p=typeof c.description=="string"?c.description:"",d=typeof c.roleDefinition=="string"?c.roleDefinition.trim():"",g=typeof c.whenToUse=="string"?c.whenToUse.trim():"",f=g?`${d}
|
|
129
129
|
|
|
130
130
|
## When to use
|
|
131
131
|
|
|
132
|
-
${g}`:
|
|
133
|
-
`)}]}var NP=d(()=>{Q();St();M();Uy();_c();s(ZW,"steeringFrontmatter");s(kP,"generateRules");s(wP,"generateCommands");s(TP,"generateSkills");s(bP,"generateMcp");s(PP,"generateHooks");s(xP,"generateAgents");s(DP,"generateIgnore");});function qW(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:Rn(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function tH(t,e,r,o){let n=o==="global"?[Jr,Hr]:[Hr,Jr];for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,Kf),{frontmatter:m,body:p}=k(r(c,a,l));await _(l,await K(l,{...m,root:true},p)),e.push({fromTool:De,fromPath:a,toPath:Kf,feature:"rules"});return}}async function eH(t,e,r){let o=join(t,Bf);e.push(...await yt({srcDir:join(t,zr),destDir:o,extensions:[".md"],fromTool:De,normalize:r,mapEntry:s(async({relativePath:n,normalizeTo:i})=>{if(basename(n)==="AGENTS.md")return null;let a=join(o,n),{frontmatter:c,body:l}=k(i(a));return {destPath:a,toPath:`${Bf}/${n}`,feature:"rules",content:await K(a,qW(c),l)}},"mapEntry")}));}async function rH(t,e){let r={};for(let n of await v(join(t,Gs))){if(!n.endsWith(".kiro.hook"))continue;let i=LP(await y(n)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let o=join(t,Wf);await L(join(t,".agentsmesh")),await _(o,AP(r)),e.push({fromTool:De,fromPath:join(t,Gs),toPath:Wf,feature:"hooks"});}async function qu(t,e={}){let r=e.scope??"project",o=[],n=await U(De,t,r);return await tH(t,o,n,r),await eH(t,o,n),o.push(...await z(td,t,r,{normalize:n})),await Z(t,ge,De,o,n),r==="project"&&await rH(t,o),o}var Ky=d(()=>{mt();Q();ke();Ct();lt();tr();T();M();Uy();_c();By();s(qW,"canonicalRuleMeta");s(tH,"importRoot");s(eH,"importNonRootRules");s(rH,"importHooks");s(qu,"importFromKiro");});function FP(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:De}))}var vP=d(()=>{_t();_c();s(FP,"lintRules");});function GP(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","UserPromptSubmit","SubagentStop"],r=new Set(e);return Object.keys(t.hooks).filter(o=>!r.has(o)).map(o=>Rs(o,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var MP=d(()=>{Et();s(GP,"lintHooks");});var oH,nH,sH,iH,td,By=d(()=>{St();NP();Qt();Ky();vP();MP();Rt();_c();oH={name:De,primaryRootInstructionPath:Hr,generateRules:kP,generateCommands:wP,generateAgents:xP,generateSkills:TP,generateMcp:bP,generateHooks:PP,generateIgnore:DP,importFrom:qu},nH={rootInstructionPath:Hr,skillDir:ge,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${zr}/${t}.md`},commandPath(t){return `${ge}/${W(t)}/SKILL.md`},agentPath(t,e){return `${Vr}/${t}.md`}}},sH={rootInstructionPath:Jr,skillDir:Ms,managedOutputs:{dirs:[Zi,Ms,Qi,RE],files:[Jr,om,nm]},rewriteGeneratedPath(t){return t===Hr?Jr:t.startsWith(`${zr}/`)?t.replace(`${zr}/`,`${Zi}/`):t.startsWith(`${ge}/`)?t.replace(`${ge}/`,`${Ms}/`):t.startsWith(`${Vr}/`)?t.replace(`${Vr}/`,`${Qi}/`):t===hc?om:t===yc?nm:t.startsWith(`${Gs}/`)?null:t},mirrorGlobalPath(t,e){return ct(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${Zi}/${t}.md`},commandPath(t){return `${ge}/${W(t)}/SKILL.md`},agentPath(t,e){return `${Qi}/${t}.md`}}},iH={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},td={id:De,metadata:{displayName:"Kiro",category:"ide",officialUrl:"https://kiro.dev",shortDescription:"AWS spec-driven AI IDE"},generators:oH,capabilities:{rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},emptyImportMessage:"No Kiro config found (AGENTS.md, .kiro/steering, .kiro/skills, .kiro/agents, .kiro/hooks, .kiro/settings/mcp.json, or .kiroignore).",supportsConversion:{commands:true},lintRules:FP,lint:{hooks:GP},project:nH,globalSupport:{capabilities:iH,detectionPaths:[Zi,Jr,Ms,Qi,om,nm],layout:sH},importer:{agents:{feature:"agents",mode:"directory",source:{project:[Vr],global:[Vr]},canonicalDir:SE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[hc],global:[om]},canonicalDir:".agentsmesh",canonicalFilename:CE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[yc],global:[nm]},canonicalDir:".agentsmesh",canonicalFilename:EE}},buildImportPaths:Hf,detectionPaths:[zr,ge,Vr,Gs,hc,yc]};});function jP(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:$o,content:r.body.trim()?r.body:""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(Yr))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs);let a=Object.keys(i).length>0?P(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${Wn}/${n}.md`,content:a});}return e}function UP(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Hn}/${e.name}.md`,content:P(r,e.body.trim()||"")}})}function KP(t){return t.agents.map(e=>{let r=basename(e.source,".md"),o={mode:"subagent"};return e.description&&(o.description=e.description),e.model&&(o.model=e.model),e.tools.length>0&&(o.tools=e.tools),e.disallowedTools.length>0&&(o.disallowedTools=e.disallowedTools),{path:`${zn}/${r}.md`,content:P(o,e.body.trim()||"")}})}function aH(t){if("url"in t){let r={type:"remote",url:t.url};return Object.keys(t.headers).length>0&&(r.headers=t.headers),t.description&&(r.description=t.description),r}let e={type:"local",command:[t.command,...t.args]};return Object.keys(t.env).length>0&&(e.environment=t.env),t.description&&(e.description=t.description),e}function BP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e={};for(let[r,o]of Object.entries(t.mcp.mcpServers))e[r]=aH(o);return [{path:jo,content:JSON.stringify({mcp:e},null,2)}]}function WP(t){return tt(t,Xr)}var HP=d(()=>{Q();M();ra();s(jP,"generateRules");s(UP,"generateCommands");s(KP,"generateAgents");s(aH,"toOpenCodeMcpServer");s(BP,"generateMcp");s(WP,"generateSkills");});function Wy(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t))typeof o=="string"&&(e[r]=o);return e}function lH(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object"||Array.isArray(e))return {};let r=e.mcp;if(!r||typeof r!="object"||Array.isArray(r))return {};let o={};for(let[n,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i;if(typeof a.url=="string"){o[n]={type:"url",url:a.url,headers:Wy(a.headers),env:Wy(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let c=a.command,l=c[0];if(l===void 0)continue;let m=c.slice(1);o[n]={type:"stdio",command:l,args:m,env:Wy(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return o}async function mH(t,e,r){let n=join(t,e==="global"?Us:jo),i=await y(n);if(i===null)return;let a=lH(i);Object.keys(a).length!==0&&(await $t(t,zf,a),r.push({feature:"mcp",fromTool:Yr,fromPath:n,toPath:zf}));}async function zP(t,e={}){let r=e.scope??"project",o=[],n=await U(Yr,t,r);return o.push(...await z(ed,t,r,{normalize:n})),await Z(t,Xr,Yr,o,n),await mH(t,r,o),o}var VP=d(()=>{mt();Q();Ct();Fr();T();ra();Hy();s(Wy,"toStringRecord");s(lH,"parseOpenCodeMcp");s(mH,"importMcp");s(zP,"importFromOpenCode");});var JP,YP,XP,ZP=d(()=>{M();lt();ra();JP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=k(e(o));return {destPath:o,toPath:`${sm}/${t}`,content:await K(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"opencodeNonRootRuleMapper"),YP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=k(e(o));return {destPath:o,toPath:`${Vp}/${t}`,content:await ht(o,{hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),XP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=k(e(o));return {destPath:o,toPath:`${Jp}/${t}`,content:await Bt(o,n,i)}},"opencodeAgentMapper");});function QP(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Yr}))}var qP=d(()=>{_t();ra();s(QP,"lintRules");});function tx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function ex(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function rx(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var ox=d(()=>{Et();s(tx,"lintHooks");s(ex,"lintPermissions");s(rx,"lintIgnore");});var pH,uH,dH,nx,ed,Hy=d(()=>{HP();ra();Qt();VP();ZP();qP();ox();Rt();pH={name:Yr,primaryRootInstructionPath:$o,generateRules:jP,generateCommands:UP,generateAgents:KP,generateSkills:WP,generateMcp:BP,importFrom:zP},uH={rootInstructionPath:$o,skillDir:Xr,managedOutputs:{dirs:[Wn,Hn,zn,Xr],files:[$o,jo]},paths:{rulePath(t){return `${Wn}/${t}.md`},commandPath(t){return `${Hn}/${t}.md`},agentPath(t){return `${zn}/${t}.md`}}},dH={rootInstructionPath:$s,skillDir:js,managedOutputs:{dirs:[qi,ta,ea,js,LE],files:[$s,Us]},rewriteGeneratedPath(t){return t===$o?$s:t===jo?Us:t},mirrorGlobalPath(t,e){return ct(t,js,e)},paths:{rulePath(t){return `${qi}/${t}.md`},commandPath(t){return `${ta}/${t}.md`},agentPath(t){return `${ea}/${t}.md`}}},nx={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ed={id:Yr,metadata:{displayName:"OpenCode",category:"cli",officialUrl:"https://opencode.ai",shortDescription:"Open-source terminal AI agent"},generators:pH,capabilities:nx,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:QP,lint:{hooks:tx,permissions:ex,ignore:rx},project:uH,globalSupport:{capabilities:nx,detectionPaths:[$s,qi,ta,ea,js,Us],layout:dH},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[$o],global:[$s]},canonicalDir:sm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Wn],global:[qi]},canonicalDir:sm,extensions:[".md"],map:JP}],commands:{feature:"commands",mode:"directory",source:{project:[Hn],global:[ta]},canonicalDir:Vp,extensions:[".md"],map:YP},agents:{feature:"agents",mode:"directory",source:{project:[zn],global:[ea]},canonicalDir:Jp,extensions:[".md"],map:XP}},buildImportPaths:Vf,detectionPaths:[Wn,Hn,zn,Xr,jo,"opencode.jsonc"]};});function sx(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Uo)),o=e?.body.trim()??"",n=it(o,r);return n?[{path:gr,content:n}]:[]}function ix(t){return tt(t,Xt)}function ax(t){return t.commands.map(e=>({path:`${Xt}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function cx(t){return t.agents.map(e=>({path:`${Xt}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}var lx=d(()=>{Q();Mt();st();St();Rc();s(sx,"generateRules");s(ix,"generateSkills");s(ax,"generateCommands");s(cx,"generateAgents");});async function mx(t,e={}){let r=e.scope??"project",o=[],n=await U(Uo,t,r);return o.push(...await z(rd,t,r,{normalize:n})),await Z(t,r==="global"?fr:Xt,Uo,o,n),o}var px=d(()=>{mt();Q();Ct();Rc();Vy();s(mx,"importFromPiAgent");});function ux(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Uo}))}var dx=d(()=>{_t();Rc();s(ux,"lintRules");});function gx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","pi-agent","Pi Coding Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function fx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","pi-agent","Pi Coding Agent has no dedicated permissions config; canonical permissions are not projected.")]}function hx(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","pi-agent","Pi Coding Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function yx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","pi-agent","Pi Coding Agent manages MCP servers via extensions, not a dedicated config file; canonical MCP servers are not projected.")]}var _x=d(()=>{Et();s(gx,"lintHooks");s(fx,"lintPermissions");s(hx,"lintIgnore");s(yx,"lintMcp");});var gH,fH,hH,Ix,rd,Vy=d(()=>{St();st();lx();Qt();px();dx();_x();Yf();Rc();gH={name:Uo,primaryRootInstructionPath:gr,generateRules:sx,generateCommands:ax,generateAgents:cx,generateSkills:ix,importFrom:mx},fH={rootInstructionPath:gr,skillDir:Xt,managedOutputs:{dirs:[Xt],files:[gr]},paths:{rulePath(t){return gr},commandPath(t){return `${Xt}/${W(t)}/SKILL.md`},agentPath(t){return `${Xt}/${$(t)}/SKILL.md`}}},hH={rootInstructionPath:Vn,skillDir:fr,managedOutputs:{dirs:[fr],files:[Vn]},rewriteGeneratedPath(t){return t===gr?Vn:t.startsWith(`${Xt}/`)?t.replace(`${Xt}/`,`${fr}/`):t},mirrorGlobalPath(t,e){return ct(t,fr,e)},paths:{rulePath(t){return Vn},commandPath(t){return `${fr}/${W(t)}/SKILL.md`},agentPath(t){return `${fr}/${$(t)}/SKILL.md`}}},Ix={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},rd={id:Uo,metadata:{displayName:"Pi Agent",category:"cli",officialUrl:"https://github.com/pi-labs/pi-agent",shortDescription:"Pi coding agent"},generators:gH,capabilities:Ix,emptyImportMessage:"No Pi Coding Agent config found (AGENTS.md or .pi/skills).",lintRules:ux,lint:{hooks:gx,permissions:fx,ignore:hx,mcp:yx},supportsConversion:{commands:true,agents:true},project:fH,globalSupport:{capabilities:Ix,detectionPaths:[Vn],layout:hH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gr],global:[Vn]},canonicalDir:wE,canonicalRootFilename:"_root.md",markAsRoot:true}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Jf,detectionPaths:[gr,Xt]};});function Rx(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:hr,content:r.body.trim()?r.body:""});let o=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes(Ko)));for(let n of o){let i=basename(n.source,".md"),a={};n.description&&(a.description=n.description),n.globs.length>0&&(a.globs=n.globs);let c=P(a,n.body.trim()||"");e.push({path:`${Jn}/${i}.md`,content:c});}return e}function Sx(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let o=P(r,e.body.trim()||"");return {path:`${Bo}/${e.name}.md`,content:o}})}function Cx(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=P(r,e.body.trim()||"");return {path:`${Wo}/${e.name}.md`,content:o}})}function Ex(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${Ne}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Ne}/${r.name}/${a}`,content:i.content});}}return e}function Ox(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Ks,content:e}]}function Lx(t){return !t.ignore||t.ignore.length===0?[]:[{path:Bs,content:t.ignore.join(`
|
|
134
|
-
`)}]}var
|
|
135
|
-
`)}]}function
|
|
136
|
-
`)}]}var
|
|
137
|
-
`)}]}var VD=
|
|
138
|
-
`)),o.push({fromTool:"windsurf",fromPath:p,toPath:i_,feature:"ignore"});}}return await rN(t,o,n),await nN(t,o,n),await aN(t,o),await cN(t,o),o}var y_=d(()=>{mt();T();M();lt();ke();Ya();fe();oN();sN();lN();s(gd,"importFromWindsurf");});function mN(t,e,r){let o=[],{rules:n}=t;n.length>0&&(n.some(c=>c.root)||o.push({level:"warning",file:relative(e,n[0].source),target:sn,message:"Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."}));let i=[];return t.permissions&&(t.permissions.allow.length>0||t.permissions.deny.length>0)&&i.push("permissions"),i.length>0&&o.push({level:"warning",file:".agentsmesh",target:sn,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),o}var pN=d(()=>{fe();s(mN,"lintRules");});function uN(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>b(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function dN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var gN=d(()=>{Et();s(uN,"lintCommands");s(dN,"lintMcp");});function fz(t){if(t.length===0)return null;let e=t.map(r=>r.split("/")[0]??"").filter(r=>/^[A-Za-z0-9._-]+$/.test(r));return e.length!==t.length?null:e.every(r=>r===e[0])?e[0]:null}var hz,yz,_z,Iz,fN,hN=d(()=>{tN();Si();fe();Qt();y_();pN();gN();Rt();Wa();st();s(fz,"directoryScopedRuleDir");hz={name:"windsurf",primaryRootInstructionPath:an,generateRules:l_,generateCommands:p_,generateAgents:u_,generateSkills:f_,generateMcp:d_,generateHooks:g_,generateIgnore:m_,importFrom:gd},yz={rootInstructionPath:an,extraRuleOutputPaths(t){if(t.root)return [an];let e=fz(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:so,managedOutputs:{dirs:[".windsurf/rules",".windsurf/skills",".windsurf/workflows"],files:["AGENTS.md",".codeiumignore",".windsurf/hooks.json",".windsurf/mcp_config.example.json"]},paths:{rulePath(t,e){return `${si}/${t}.md`},commandPath(t,e){return `${ii}/${t}.md`},agentPath(t,e){return Ve(e,"windsurf")?`.windsurf/skills/${$(t)}/SKILL.md`:null}}},_z={rootInstructionPath:Vc,skillDir:Jc,managedOutputs:{dirs:[Jc,Cm,HD],files:[Vc,md,pd,ud]},rewriteGeneratedPath(t){return t===an?Vc:t.startsWith(`${si}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${so}/`)?t.replace(`${so}/`,`${Jc}/`):t.startsWith(`${ii}/`)?t.replace(`${ii}/`,`${Cm}/`):t===Wc?md:t===Hc?pd:t===Bc?ud:t},mirrorGlobalPath(t,e){return ct(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return Vc},commandPath(t,e){return `${Cm}/${t}.md`},agentPath(t,e){return Ve(e,"windsurf")?`${Jc}/${$(t)}/SKILL.md`:null}}},Iz={rules:"native",additionalRules:"partial",commands:Nr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},fN={id:"windsurf",metadata:{displayName:"Windsurf",category:"ide",officialUrl:"https://windsurf.com",shortDescription:"Codeium's agentic IDE"},generators:hz,capabilities:{rules:"native",additionalRules:"native",commands:Nr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},emptyImportMessage:"No Windsurf config found (.windsurfrules, .windsurf/rules, .windsurfignore, or .codeiumignore).",supportsConversion:{agents:true},lintRules:mN,lint:{commands:uN,mcp:dN},project:yz,globalSupport:{capabilities:Iz,detectionPaths:[Vc,Jc,Cm,md,pd,ud],layout:_z},buildImportPaths:sh,detectionPaths:[".windsurfrules",".windsurf"]};});function yN(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("zed")),o=e?.body.trim()??"",n=it(o,r);return n?[{path:eo,content:n}]:[]}var _N=d(()=>{Mt();la();s(yN,"generateRules");});async function RN(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let a=n.context_servers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,c[l]=p;}Object.keys(c).length!==0&&(await $t(t,IN,c),r.push({fromTool:"zed",fromPath:e,toPath:IN,feature:"mcp"}));}var IN,SN=d(()=>{T();Fr();la();IN=".agentsmesh/mcp.json";s(RN,"importZedMcp");});async function CN(t,e={}){let r=e.scope??"project",o=[],n=await U("zed",t,r);return o.push(...await z(fd,t,r,{normalize:n})),await RN(t,r==="global"?Zo:Xo,o),o}var EN=d(()=>{mt();Ct();SN();la();__();s(CN,"importFromZed");});function ON(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:"zed"}))}var LN=d(()=>{_t();la();s(ON,"lintRules");});function AN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function kN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function wN(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","zed","Zed has no dedicated ignore file and relies on file_scan_exclusions in settings.json; canonical ignore patterns are not projected.")]}var TN=d(()=>{Et();s(AN,"lintHooks");s(kN,"lintPermissions");s(wN,"lintIgnore");});function Az(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n.context_servers!==void 0&&(r.context_servers=n.context_servers),JSON.stringify(r,null,2)}var Sz,Cz,Ez,Oz,Lz,fd,__=d(()=>{_N();EN();LN();TN();Rt();la();Sz={name:"zed",primaryRootInstructionPath:eo,generateRules:yN,importFrom:CN},Cz={rootInstructionPath:eo,managedOutputs:{dirs:[],files:[eo,Xo]},paths:{rulePath(t){return eo},commandPath(){return null},agentPath(){return null}}},Ez={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[Zo]},rewriteGeneratedPath(t){return t===Xo?Zo:t},paths:{rulePath(){return Zo},commandPath(){return null},agentPath(){return null}}},Oz={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Lz={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(Az,"mergeZedSettings");fd={id:"zed",metadata:{displayName:"Zed",category:"ide",officialUrl:"https://zed.dev",shortDescription:"Collaborative AI editor"},generators:Sz,capabilities:Oz,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:ON,lint:{hooks:AN,permissions:kN,ignore:wN},project:Cz,globalSupport:{capabilities:Lz,detectionPaths:[Zo],layout:Ez},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[eo],global:[]},canonicalDir:JE,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let r={};for(let[o,n]of Object.entries(t.mcp.mcpServers))r[o]=n;return [{path:Xo,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,o){return o===Xo||o===Zo?Az(t,r):null},buildImportPaths:ih,detectionPaths:[eo,Xo]};});var OC={};gg(OC,{BUILTIN_TARGETS:()=>zt,TARGET_IDS:()=>kt,getBuiltinTargetDefinition:()=>Er,getEffectiveTargetSupportLevel:()=>hd,getTargetCapabilities:()=>oi,getTargetDetectionPaths:()=>R_,getTargetLayout:()=>vt,getTargetManagedOutputs:()=>S_,getTargetPrimaryRootInstructionPath:()=>wz,getTargetSkillDir:()=>Om,isBuiltinTargetId:()=>Tr,resolveTargetFeatureGenerator:()=>Yc,rewriteGeneratedOutputPath:()=>C_});function kz(){return I_||(NS(zt),I_=new Map(zt.map(t=>[t.id,t]))),I_}function Er(t){return kz().get(t)}function oi(t,e="project"){let r=Er(t)??ut(t);if(!r)return;let o=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return xS(o)}function R_(t,e="project"){let r=Er(t)??ut(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function vt(t,e="project"){let r=Er(t)??ut(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function wz(t,e="project"){return vt(t,e)?.rootInstructionPath}function Om(t,e="project"){return vt(t,e)?.skillDir}function S_(t,e="project"){return vt(t,e)?.managedOutputs}function C_(t,e,r="project"){let o=vt(t,r);return o?o.rewriteGeneratedPath?o.rewriteGeneratedPath(e):e:null}function bN(t,e,r,o){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!Ba(r,t.id,true,o):e==="agents"&&t.supportsConversion?.agents?!Ve(r,t.id,true,o):false}function Tz(t,e,r,o){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?Ba(r,t.id,true,o):e==="agents"&&t.supportsConversion?.agents?Ve(r,t.id,true,o):false}function hd(t,e,r,o="project"){let n=oi(t,o)?.[e]?.level??"none",i=Er(t)??ut(t);return n==="none"&&Tz(i,e,r,o)?"embedded":n!=="embedded"?n:bN(i,e,r,o)?"none":n}function Yc(t,e,r,o="project"){let n=Er(t)??ut(t);if(!n?.generators||bN(n,e,r,o))return;let i=bz[e];return i===null?void 0:i(n.generators)}var zt,I_,bz,xt=d(()=>{Wa();Si();je();Ug();uo();Qg();ah();ch();mh();oL();uh();sA();HA();Gh();Wh();zh();cy();ly();my();by();Py();xy();Ny();jy();By();Hy();Vy();Jy();Yy();Qy();qy();t_();e_();hN();__();zt=[Cp,Qp,qp,tu,rL,eu,nA,WA,gu,Su,Eu,Du,Nu,Fu,Wu,Hu,zu,Ju,Qu,td,ed,rd,od,nd,id,ad,cd,ld,fN,fd];s(kz,"builtinTargetsMap");s(Er,"getBuiltinTargetDefinition");s(oi,"getTargetCapabilities");s(R_,"getTargetDetectionPaths");s(vt,"getTargetLayout");s(wz,"getTargetPrimaryRootInstructionPath");s(Om,"getTargetSkillDir");s(S_,"getTargetManagedOutputs");s(C_,"rewriteGeneratedOutputPath");s(bN,"isFeatureSuppressedByConversion");s(Tz,"isConversionUpgrading");s(hd,"getEffectiveTargetSupportLevel");bz={rules:s(t=>t.generateRules,"rules"),additionalRules:null,commands:s(t=>t.generateCommands,"commands"),agents:s(t=>t.generateAgents,"agents"),skills:s(t=>t.generateSkills,"skills"),mcp:s(t=>t.generateMcp,"mcp"),permissions:s(t=>t.generatePermissions,"permissions"),hooks:s(t=>t.generateHooks,"hooks"),ignore:s(t=>t.generateIgnore,"ignore")};s(Yc,"resolveTargetFeatureGenerator");});function Gz(t){return typeof t=="string"?t:t.level}function PN(t){return vz.includes(t)}function xN(t,e,r,o){for(let n of Fz){let i=Gz(e[n.feature]);if(i==="none")continue;let a=typeof t.generators[n.generator]=="function",c=PN(n.feature)&&typeof t.emitScopedSettings=="function";a||c||r.addIssue({code:"custom",path:[...o,n.feature],message:`Capability "${n.feature}" is "${i}" but generators.${n.generator}`+(PN(n.feature)?" or emitScopedSettings":"")+" is missing."});}}function yd(t){return $z.parse(t)}var ms,DN,Pz,xz,NN,Dz,Nz,Fz,vz,Mz,$z,E_=d(()=>{ms=z$1.union([z$1.enum(["native","embedded","partial","none"]),z$1.object({level:z$1.enum(["native","embedded","partial","none"]),flavor:z$1.string().optional()})]),DN=z$1.object({rules:ms,additionalRules:ms,commands:ms,agents:ms,skills:ms,mcp:ms,hooks:ms,ignore:ms,permissions:ms}),Pz=z$1.object({name:z$1.string(),generateRules:z$1.function(),importFrom:z$1.function(),generateCommands:z$1.function().optional(),generateAgents:z$1.function().optional(),generateSkills:z$1.function().optional(),generateMcp:z$1.function().optional(),generatePermissions:z$1.function().optional(),generateHooks:z$1.function().optional(),generateIgnore:z$1.function().optional(),lint:z$1.function().optional()}).passthrough(),xz=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),NN=z$1.object({paths:xz}).passthrough(),Dz=z$1.object({capabilities:DN,detectionPaths:z$1.array(z$1.string()),layout:NN,scopeExtras:z$1.function().optional()}).passthrough(),Nz=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],Fz=[{feature:"commands",generator:"generateCommands"},{feature:"agents",generator:"generateAgents"},{feature:"skills",generator:"generateSkills"},{feature:"mcp",generator:"generateMcp"},{feature:"hooks",generator:"generateHooks"},{feature:"ignore",generator:"generateIgnore"},{feature:"permissions",generator:"generatePermissions"}],vz=["mcp","hooks","ignore","permissions"];s(Gz,"capabilityLevel");s(PN,"canUseScopedSettings");s(xN,"validateCapabilityImplementations");Mz=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:Pz,capabilities:DN,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:NN,globalSupport:Dz.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),$z=Mz.superRefine((t,e)=>{for(let r of Nz)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});xN(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&xN(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(yd,"validateDescriptor");});function jz(){return O_||(O_=new Map(zt.map(t=>[t.id,t]))),O_}function _d(t){let e=yd(t);L_.set(e.id,e);}function ut(t){return L_.get(t)??jz().get(t)}function Id(){return [...L_.values()]}var L_,O_,je=d(()=>{xt();E_();L_=new Map;s(jz,"builtinDescriptors");s(_d,"registerTargetDescriptor");s(ut,"getDescriptor");s(Id,"getAllDescriptors");});async function FN(t,e,r="project"){let o=new Map,n=ut(t);return n&&await n.buildImportPaths(o,e,r),o}var vN=d(()=>{je();s(FN,"buildImportReferenceMap");});function Bz(t){let e=[t.project,t.globalSupport?.layout].filter(n=>n!==void 0),r=[...t.detectionPaths,...e.flatMap(n=>n.managedOutputs?.dirs??[]),...e.flatMap(n=>n.managedOutputs?.files??[])],o=new Set;for(let n of r){let i=n.split("/")[0];i&&i.startsWith(".")&&i.length>1&&o.add(`${i}/`);}return o}function Wz(){let t=new Set([".agentsmesh/"]);for(let e of zt)for(let r of Bz(e))t.add(r);return Array.from(t)}function Hz(){let t=new Set([...Wz(),...A_.rootRelativePrefixes]),e=new Set([...Kz,...A_.meshRootSegments]);return {protectedSchemes:[...Uz,...A_.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function Rd(){return k_||(k_=Hz()),k_}var Uz,Kz,A_,k_,GN=d(()=>{xt();Uz=[/\b[A-Za-z][A-Za-z0-9+.-]+:[^\s<>()\]]+/g,/\b[\w.-]+@[\w.-]+:[^\s<>()\]]+/g,/\b[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}\b/g,/\/\/[A-Za-z0-9][\w.-]*\.[A-Za-z]{2,}[^\s<>()\]]*/g],Kz=new Set(["skills","rules","commands","agents","packs"]),A_={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(Bz,"topLevelDotfilePrefixes");s(Wz,"buildDefaultRootRelativePrefixes");s(Hz,"rebuild");s(Rd,"getLinkFormatRegistry");});function io(t){let e=Pt(t);return Rd().rootRelativePrefixes.some(r=>e.startsWith(r))}function Vz(t){let e=Pt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||xr.test(e)||/^[a-zA-Z]:/.test(e)||io(e))return false;let r=e.split("/").filter(o=>o.length>0)[0];return r!==void 0&&Rd().meshRootSegments.has(r)}function Lm(t,e,r){let o=et(e),n=V(e,e),i=V(e,r),a=Pt(t);if(xr.test(t)){let c=V(e,t);return o===win32||c.startsWith(`${n}${o.sep}`)?[c]:[c]}if(o.isAbsolute(t)){let c=V(e,t);return c.startsWith(n)||existsSync(t)?[c]:[V(e,o.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let c=V(e,o.join(o.dirname(i),a)),l=wS(a,n);return l&&l!==c?[c,l]:[c]}if(io(a))return [V(e,o.join(n,a))];if(a.includes("/")){let c=V(e,o.join(n,".agentsmesh")),l=Vz(a)?V(e,o.join(c,a)):null,m=V(e,o.join(n,a)),p=V(e,o.join(o.dirname(i),a));return l!==null?[l,m,p]:[m,p]}return Jz.has(a)?[]:a.includes(".")?[V(e,o.join(o.dirname(i),a))]:[]}function Am(t,e){let r=[e];if(!kS(t,e)||!existsSync(e))return r;try{let o=[realpathSync(e),realpathSync.native(e)];for(let n of o)n!==e&&!r.includes(n)&&r.push(n);}catch{}return r}function UN(t,e,r){let o=e>0?t.at(e-1):"",n=r<t.length?t.at(r):"";return o==="*"||n==="*"}function Sd(t){let e=[];for(let r of Rd().protectedSchemes){let o=r.flags.includes("g")?r:new RegExp(r.source,`${r.flags}g`);for(let n of t.matchAll(o))e.push([n.index??0,(n.index??0)+n[0].length]);}for(let r of t.matchAll(Yz))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(Xz))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(Zz))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var Jz,Yz,Xz,Zz,jN,Xc,ai=d(()=>{re();GN();s(io,"isRootRelativePathToken");s(Vz,"isMeshRootRelativePathToken");Jz=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),Yz=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,Xz=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,Zz=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,jN=/(?:\.\.[\\/]|\.\/|\.\\|\/[A-Za-z0-9._-]|[A-Za-z]:[\\/][A-Za-z0-9._-]|\.agentsmesh[\\/]|\.claude[\\/]|\.cursor[\\/]|\.github[\\/]|\.continue[\\/]|\.junie[\\/]|\.kiro[\\/]|\.gemini[\\/]|\.clinerules[\\/]|\.cline[\\/]|\.codex[\\/]|\.agents[\\/]|\.windsurf[\\/]|\.roo[\\/]|(?:[A-Za-z0-9._-]+[\\/])+|[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+)[A-Za-z0-9._@%+~:\\/-]*/g,Xc=/(?::(\d+)){1,2}$/;s(Lm,"resolveProjectPath");s(Am,"expandResolvedPaths");s(UN,"isGlobAdjacent");s(Sd,"protectedRanges");});function Qz(t){return t===void 0||t.role==="inline-code"||t.role==="bracketed"||t.role==="quoted"||t.role==="at-prefix"||t.role==="bracket-label"||t.role==="bare-prose"}function KN(t){return Qz(t.tokenContext)}function w_(t,e){let r=et(t),o=V(t,t),n=V(t,e);if(n===o)return true;let i=o.endsWith(r.sep)?o:`${o}${r.sep}`;return n.startsWith(i)}function BN(t){let e=et(t);return V(t,e.join(t,".agentsmesh"))}function ao(t,e){let r=et(t),o=BN(t),n=V(t,e);if(n===o)return true;let i=o.endsWith(r.sep)?o:`${o}${r.sep}`;return n.startsWith(i)}function WN(t,e,r){let o=et(t),n=BN(t),i=V(t,e);if(!ao(t,i))return null;let a=o.relative(n,i).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function T_(t,e,r){let n=et(t).relative(V(t,t),V(t,e)).replace(/\\/g,"/");if(n.startsWith(".."))return null;let i=n.length>0?n:".";return r&&!i.endsWith("/")?`${i}/`:i}function Zc(t,e,r){let o=T_(t,e,r);return o===null?null:{kind:"projectRoot",rest:o,text:o}}function b_(t,e,r,o,n){let i=et(t),a=V(t,t),c=V(t,e),l=V(t,r);if(!w_(t,l))return Zc(t,l,o)?.text??null;let m=V(t,i.dirname(c));if(!w_(t,m)&&m!==a)return Zc(t,l,o)?.text??null;let p=i.relative(m,l).replace(/\\/g,"/");if(i.isAbsolute(p)||xr.test(p))return T_(t,l,o);let u=V(t,i.join(m,p));return w_(t,u)?(p===""||p==="."?p=".":n.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),o&&!p.endsWith("/")?`${p}/`:p):T_(t,l,o)}var P_=d(()=>{re();s(Qz,"isReadingContext");s(KN,"isReadingContextOptions");s(w_,"isUnderProjectRoot");s(BN,"agentsMeshRoot");s(ao,"isUnderAgentsMesh");s(WN,"toAgentsMeshRootRelative");s(T_,"toProjectRootRelative");s(Zc,"toProjectRootReference");s(b_,"formatLinkPathForDestinationLegacy");});function HN(t,e,r,o,n={}){let i=n.scope??"project",a=V(t,r);if(KN(n)&&ao(t,e)&&ao(t,a)){let m=et(t),p=V(t,t),u=m.relative(p,a).replace(/\\/g,"/");if(!u.startsWith("..")&&u.length>0)return o&&!u.endsWith("/")?`${u}/`:u}if(n.forceRelative)return b_(t,e,r,o,n);if(i==="global"&&!ao(t,e))return Zc(t,a,o)?.text??null;let c=(()=>{if(ao(t,a))return a;let m=n.logicalMeshSourceAbsolute;return m&&ao(t,V(t,m))?V(t,m):null})();if(!c)return Zc(t,a,o)?.text??null;if(o||(n.pathIsDirectory?.(a)??false)){let m=WN(t,c,o);return m!==null?m:Zc(t,c,o)?.text??null}return b_(t,e,r,o,n)}var zN=d(()=>{ai();re();P_();P_();s(HN,"formatLinkPathForDestination");});function VN(t,e,r,o){let n=et(e),i=Pt(t);if(!io(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let c=V(e,r),l=n.dirname(c);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=V(e,n.join(l,p));if(u!==c&&o(u))return u}return null}var JN=d(()=>{re();ai();s(VN,"resolveByDestinationSuffixStrip");});function YN(t){let e=null,r=false,o=null,n=null,i=null;for(let l of Lm(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of Am(t.projectRoot,l)){let g=V(t.projectRoot,u),f=V(t.projectRoot,t.translatePath(g)),h=t.pathExists(g),O=t.pathExists(f);if(O&&f!==g){e=f,o=g,r=true;break}(h||O)&&m===null&&(m=f,p=g),e===null&&(e=f);}if(!r&&m!==null&&n===null&&(n=m,i=p),r)break}if(!r){let l=VN(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);l!==null&&(e=l,r=true);}!r&&n!==null&&(e=n,i!==null&&(o=i),r=true);let a=Pt(t.destinationFile),c=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&Pt(t.rawToken).startsWith(".agentsmesh/")&&c&&(r=true),{translatedPath:e,resolvedBeforeTranslate:o,matchedPath:r}}var XN=d(()=>{re();ai();JN();s(YN,"resolveLinkTarget");});function ZN(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function QN(t,e,r){if(e<=0||t[e-1]!=="(")return false;let o=e+r.length,n=t[o];return n!==")"&&n!=="#"&&n!=="?"&&n!==" "&&n!==" "?false:t[e-2]==="]"}function qN(t){let e=Pt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||xr.test(e)||io(e)?false:e.includes("/")}var tF=d(()=>{re();ai();s(ZN,"isTildeHomeRelativePathToken");s(QN,"isMarkdownLinkDestinationToken");s(qN,"isRelativePathToken");});function qz(t,e,r){let o=e+r.length;if(t[o]!=="]"||t[o+1]!=="(")return false;let n=o+2,i="";for(;n<t.length;){let a=t[n];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
|
|
132
|
+
${g}`:d,h={};p&&(h.description=p),typeof c.name=="string"&&c.name.length>0&&(h.name=c.name);let O=await Bt(m,h,f),R=r(O,o,m);await I(m,R),e.push({feature:"agents",fromTool:ue,fromPath:o,toPath:`${zi}/${l}.md`});}}async function Yu(t,e={}){let r=e.scope??"project",o=[],n=await U(ue,t,r);return o.push(...await z(Xu,t,r,{normalize:n})),await Z(t,Br,ue,o,n),r==="project"&&(await MW(t,o,n),await $W(t,o,n),await jW(t,o,n),await Z(t,Ki,ue,o,n)),o}var Dy,Ny,Fy=u(()=>{mt();Q();ke();Ct();T();lt();M();xy();Vi();vy();Dy=`${Ns}/_root.md`,Ny="00-root.md";s(dP,"pathExists");s(MW,"importLegacyRules");s($W,"importLegacyWorkflows");s(jW,"importLegacyModes");s(Yu,"importFromKiloCode");});function gP(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:ue}))}var fP=u(()=>{_t();Vi();s(gP,"lintRules");});function hP(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function yP(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","kilo-code","kilo-code permissions live in kilo.jsonc, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}var _P=u(()=>{Et();s(hP,"lintHooks");s(yP,"lintPermissions");});var UW,KW,BW,IP,Xu,vy=u(()=>{pP();Vi();Qt();Fy();xy();fP();_P();Rt();UW={name:ue,primaryRootInstructionPath:vo,generateRules:sP,generateCommands:iP,generateAgents:aP,generateSkills:mP,generateMcp:cP,generateIgnore:lP,importFrom:Yu},KW={rootInstructionPath:vo,skillDir:Br,managedOutputs:{dirs:[Mn,$n,jn,Br],files:[vo,Ps,cc]},paths:{rulePath(t,e){return `${Mn}/${t}.md`},commandPath(t,e){return `${$n}/${t}.md`},agentPath(t,e){return `${jn}/${t}.md`}}},BW={rootInstructionPath:xs,skillDir:Ds,managedOutputs:{dirs:[Bi,Wi,Hi,Ds,mE],files:[xs,pc,Hp]},rewriteGeneratedPath(t){return t===vo?xs:t},mirrorGlobalPath(t,e){return ct(t,Ds,e)},paths:{rulePath(t,e){return `${Bi}/${t}.md`},commandPath(t,e){return `${Wi}/${t}.md`},agentPath(t,e){return `${Hi}/${t}.md`}}},IP={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Xu={id:ue,metadata:{displayName:"Kilo Code",category:"ide",officialUrl:"https://kilocode.ai",shortDescription:"Open-source AI coding agent for VS Code"},generators:UW,capabilities:IP,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:gP,lint:{hooks:hP,permissions:yP},project:KW,globalSupport:{capabilities:IP,detectionPaths:[xs,Bi,Wi,Hi,Ds,pc,Hp],layout:BW},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[vo],global:[xs]},canonicalDir:Ns,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Mn],global:[Bi]},canonicalDir:Ns,extensions:[".md"],map:Vu}],commands:{feature:"commands",mode:"directory",source:{project:[$n],global:[Wi]},canonicalDir:uc,extensions:[".md"],map:Ju},agents:{feature:"agents",mode:"directory",source:{project:[jn],global:[Hi]},canonicalDir:zi,extensions:[".md"],map:uP},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ps,tm],global:[pc]},canonicalDir:".agentsmesh",canonicalFilename:pE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[cc],global:[Hp]},canonicalDir:".agentsmesh",canonicalFilename:uE}},buildImportPaths:Mf,detectionPaths:[Mn,$n,jn,Br,Ps,Ui,lc,Ki,tm,Wp,cc,"kilo.jsonc","kilo.json"]};});function RP(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function zW(t){return t.type==="prompt"?t.prompt:t.command}function VW(t,e){let r=SP[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function CP(t){let e=[];for(let[r,o]of Object.entries(t)){let n=r;if(!(n in SP)||!Array.isArray(o))continue;let i=1;for(let a of o){let c=zW(a);if(!c)continue;let l={name:`${RP(r)} ${i}`,version:"1",when:VW(n,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:c}:{type:"shellCommand",command:c}};e.push({name:`${RP(r)}-${i}.kiro.hook`,content:JSON.stringify(l,null,2)}),i+=1;}}return e}function JW(t){let e=HW.get(t.when.type);if(!e)return null;let r=t.when.tools?.[0]??t.when.patterns?.[0]??"*";return t.then.type==="askAgent"&&typeof t.then.prompt=="string"?{event:e,entry:{matcher:r,command:t.then.prompt,prompt:t.then.prompt,type:"prompt"}}:t.then.type==="shellCommand"&&typeof t.then.command=="string"?{event:e,entry:{matcher:r,command:t.then.command,type:"command"}}:null}function EP(t){let e;try{e=JSON.parse(t);}catch{return null}if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e;return !r.when||!r.then||typeof r.when.type!="string"?null:JW(r)}function OP(t){return stringify(t).trimEnd()}var SP,HW,Gy=u(()=>{SP={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},HW=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(RP,"toKebab");s(zW,"hookText");s(VW,"toWhen");s(CP,"generateKiroHooks");s(JW,"toCanonicalEntry");s(EP,"parseKiroHookFile");s(OP,"serializeCanonicalHooks");});function XW(t){let e={};return t.globs.length>0?(e.inclusion="fileMatch",e.fileMatchPattern=t.globs.length===1?t.globs[0]:t.globs):t.trigger==="manual"?e.inclusion="manual":t.trigger==="model_decision"?e.inclusion="auto":e.inclusion="always",t.description&&(e.description=t.description),e}function LP(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Wr,content:r.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(De))continue;let n=basename(o.source,".md");e.push({path:`${Hr}/${n}.md`,content:P(XW(o),o.body.trim()||"")});}return e}function AP(t){return t.commands.map(e=>({path:`${de}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function kP(t){return tt(t,de)}function wP(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:dc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function TP(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:CP(t.hooks).map(e=>({path:`${Fs}/${e.name}`,content:e.content}))}function bP(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=P(r,e.body.trim()||"");return {path:`${zr}/${e.name}.md`,content:o}})}function PP(t){return t.ignore.length===0?[]:[{path:gc,content:t.ignore.join(`
|
|
133
|
+
`)}]}var xP=u(()=>{Q();St();M();Gy();fc();s(XW,"steeringFrontmatter");s(LP,"generateRules");s(AP,"generateCommands");s(kP,"generateSkills");s(wP,"generateMcp");s(TP,"generateHooks");s(bP,"generateAgents");s(PP,"generateIgnore");});function QW(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:yn(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function qW(t,e,r,o){let n=o==="global"?[Vr,Wr]:[Wr,Vr];for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,$f),{frontmatter:m,body:p}=w(r(c,a,l));await I(l,await K(l,{...m,root:true},p)),e.push({fromTool:De,fromPath:a,toPath:$f,feature:"rules"});return}}async function tH(t,e,r){let o=join(t,jf);e.push(...await yt({srcDir:join(t,Hr),destDir:o,extensions:[".md"],fromTool:De,normalize:r,mapEntry:s(async({relativePath:n,normalizeTo:i})=>{if(basename(n)==="AGENTS.md")return null;let a=join(o,n),{frontmatter:c,body:l}=w(i(a));return {destPath:a,toPath:`${jf}/${n}`,feature:"rules",content:await K(a,QW(c),l)}},"mapEntry")}));}async function eH(t,e){let r={};for(let n of await N(join(t,Fs))){if(!n.endsWith(".kiro.hook"))continue;let i=EP(await y(n)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let o=join(t,Uf);await L(join(t,".agentsmesh")),await I(o,OP(r)),e.push({fromTool:De,fromPath:join(t,Fs),toPath:Uf,feature:"hooks"});}async function Zu(t,e={}){let r=e.scope??"project",o=[],n=await U(De,t,r);return await qW(t,o,n,r),await tH(t,o,n),o.push(...await z(Qu,t,r,{normalize:n})),await Z(t,de,De,o,n),r==="project"&&await eH(t,o),o}var My=u(()=>{mt();Q();ke();Ct();lt();Qe();T();M();Gy();fc();$y();s(QW,"canonicalRuleMeta");s(qW,"importRoot");s(tH,"importNonRootRules");s(eH,"importHooks");s(Zu,"importFromKiro");});function DP(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:De}))}var NP=u(()=>{_t();fc();s(DP,"lintRules");});function FP(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","UserPromptSubmit","SubagentStop"],r=new Set(e);return Object.keys(t.hooks).filter(o=>!r.has(o)).map(o=>_s(o,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var vP=u(()=>{Et();s(FP,"lintHooks");});var rH,oH,nH,sH,Qu,$y=u(()=>{St();xP();Qt();My();NP();vP();Rt();fc();rH={name:De,primaryRootInstructionPath:Wr,generateRules:LP,generateCommands:AP,generateAgents:bP,generateSkills:kP,generateMcp:wP,generateHooks:TP,generateIgnore:PP,importFrom:Zu},oH={rootInstructionPath:Wr,skillDir:de,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${Hr}/${t}.md`},commandPath(t){return `${de}/${W(t)}/SKILL.md`},agentPath(t,e){return `${zr}/${t}.md`}}},nH={rootInstructionPath:Vr,skillDir:vs,managedOutputs:{dirs:[Ji,vs,Yi,fE],files:[Vr,rm,om]},rewriteGeneratedPath(t){return t===Wr?Vr:t.startsWith(`${Hr}/`)?t.replace(`${Hr}/`,`${Ji}/`):t.startsWith(`${de}/`)?t.replace(`${de}/`,`${vs}/`):t.startsWith(`${zr}/`)?t.replace(`${zr}/`,`${Yi}/`):t===dc?rm:t===gc?om:t.startsWith(`${Fs}/`)?null:t},mirrorGlobalPath(t,e){return ct(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${Ji}/${t}.md`},commandPath(t){return `${de}/${W(t)}/SKILL.md`},agentPath(t,e){return `${Yi}/${t}.md`}}},sH={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Qu={id:De,metadata:{displayName:"Kiro",category:"ide",officialUrl:"https://kiro.dev",shortDescription:"AWS spec-driven AI IDE"},generators:rH,capabilities:{rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},emptyImportMessage:"No Kiro config found (AGENTS.md, .kiro/steering, .kiro/skills, .kiro/agents, .kiro/hooks, .kiro/settings/mcp.json, or .kiroignore).",supportsConversion:{commands:true},lintRules:DP,lint:{hooks:FP},project:oH,globalSupport:{capabilities:sH,detectionPaths:[Ji,Vr,vs,Yi,rm,om],layout:nH},importer:{agents:{feature:"agents",mode:"directory",source:{project:[zr],global:[zr]},canonicalDir:hE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[dc],global:[rm]},canonicalDir:".agentsmesh",canonicalFilename:yE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[gc],global:[om]},canonicalDir:".agentsmesh",canonicalFilename:_E}},buildImportPaths:Kf,detectionPaths:[Hr,de,zr,Fs,dc,gc]};});function MP(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Go,content:r.body.trim()?r.body:""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(Jr))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs);let a=Object.keys(i).length>0?P(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${Un}/${n}.md`,content:a});}return e}function $P(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Kn}/${e.name}.md`,content:P(r,e.body.trim()||"")}})}function jP(t){return t.agents.map(e=>{let r=basename(e.source,".md"),o={mode:"subagent"};return e.description&&(o.description=e.description),e.model&&(o.model=e.model),e.tools.length>0&&(o.tools=e.tools),e.disallowedTools.length>0&&(o.disallowedTools=e.disallowedTools),{path:`${Bn}/${r}.md`,content:P(o,e.body.trim()||"")}})}function iH(t){if("url"in t){let r={type:"remote",url:t.url};return Object.keys(t.headers).length>0&&(r.headers=t.headers),t.description&&(r.description=t.description),r}let e={type:"local",command:[t.command,...t.args]};return Object.keys(t.env).length>0&&(e.environment=t.env),t.description&&(e.description=t.description),e}function UP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e={};for(let[r,o]of Object.entries(t.mcp.mcpServers))e[r]=iH(o);return [{path:Mo,content:JSON.stringify({mcp:e},null,2)}]}function KP(t){return tt(t,Yr)}var BP=u(()=>{Q();M();qi();s(MP,"generateRules");s($P,"generateCommands");s(jP,"generateAgents");s(iH,"toOpenCodeMcpServer");s(UP,"generateMcp");s(KP,"generateSkills");});function jy(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t))typeof o=="string"&&(e[r]=o);return e}function cH(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object"||Array.isArray(e))return {};let r=e.mcp;if(!r||typeof r!="object"||Array.isArray(r))return {};let o={};for(let[n,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i;if(typeof a.url=="string"){o[n]={type:"url",url:a.url,headers:jy(a.headers),env:jy(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let c=a.command,l=c[0];if(l===void 0)continue;let m=c.slice(1);o[n]={type:"stdio",command:l,args:m,env:jy(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return o}async function lH(t,e,r){let n=join(t,e==="global"?$s:Mo),i=await y(n);if(i===null)return;let a=cH(i);Object.keys(a).length!==0&&(await $t(t,Bf,a),r.push({feature:"mcp",fromTool:Jr,fromPath:n,toPath:Bf}));}async function WP(t,e={}){let r=e.scope??"project",o=[],n=await U(Jr,t,r);return o.push(...await z(qu,t,r,{normalize:n})),await Z(t,Yr,Jr,o,n),await lH(t,r,o),o}var HP=u(()=>{mt();Q();Ct();Nr();T();qi();Uy();s(jy,"toStringRecord");s(cH,"parseOpenCodeMcp");s(lH,"importMcp");s(WP,"importFromOpenCode");});var zP,VP,JP,YP=u(()=>{M();lt();qi();zP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${nm}/${t}`,content:await K(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"opencodeNonRootRuleMapper"),VP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Vp}/${t}`,content:await ht(o,{hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),JP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Jp}/${t}`,content:await Bt(o,n,i)}},"opencodeAgentMapper");});function XP(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Jr}))}var ZP=u(()=>{_t();qi();s(XP,"lintRules");});function QP(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function qP(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function tx(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var ex=u(()=>{Et();s(QP,"lintHooks");s(qP,"lintPermissions");s(tx,"lintIgnore");});var mH,pH,uH,rx,qu,Uy=u(()=>{BP();qi();Qt();HP();YP();ZP();ex();Rt();mH={name:Jr,primaryRootInstructionPath:Go,generateRules:MP,generateCommands:$P,generateAgents:jP,generateSkills:KP,generateMcp:UP,importFrom:WP},pH={rootInstructionPath:Go,skillDir:Yr,managedOutputs:{dirs:[Un,Kn,Bn,Yr],files:[Go,Mo]},paths:{rulePath(t){return `${Un}/${t}.md`},commandPath(t){return `${Kn}/${t}.md`},agentPath(t){return `${Bn}/${t}.md`}}},uH={rootInstructionPath:Gs,skillDir:Ms,managedOutputs:{dirs:[Xi,Zi,Qi,Ms,RE],files:[Gs,$s]},rewriteGeneratedPath(t){return t===Go?Gs:t===Mo?$s:t},mirrorGlobalPath(t,e){return ct(t,Ms,e)},paths:{rulePath(t){return `${Xi}/${t}.md`},commandPath(t){return `${Zi}/${t}.md`},agentPath(t){return `${Qi}/${t}.md`}}},rx={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},qu={id:Jr,metadata:{displayName:"OpenCode",category:"cli",officialUrl:"https://opencode.ai",shortDescription:"Open-source terminal AI agent"},generators:mH,capabilities:rx,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:XP,lint:{hooks:QP,permissions:qP,ignore:tx},project:pH,globalSupport:{capabilities:rx,detectionPaths:[Gs,Xi,Zi,Qi,Ms,$s],layout:uH},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Go],global:[Gs]},canonicalDir:nm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Un],global:[Xi]},canonicalDir:nm,extensions:[".md"],map:zP}],commands:{feature:"commands",mode:"directory",source:{project:[Kn],global:[Zi]},canonicalDir:Vp,extensions:[".md"],map:VP},agents:{feature:"agents",mode:"directory",source:{project:[Bn],global:[Qi]},canonicalDir:Jp,extensions:[".md"],map:JP}},buildImportPaths:Wf,detectionPaths:[Un,Kn,Bn,Yr,Mo,"opencode.jsonc"]};});function ox(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes($o)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:ur,content:n}]:[]}function nx(t){return tt(t,Xt)}function sx(t){return t.commands.map(e=>({path:`${Xt}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function ix(t){return t.agents.map(e=>({path:`${Xt}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}var ax=u(()=>{Q();Mt();at();St();yc();s(ox,"generateRules");s(nx,"generateSkills");s(sx,"generateCommands");s(ix,"generateAgents");});async function cx(t,e={}){let r=e.scope??"project",o=[],n=await U($o,t,r);return o.push(...await z(td,t,r,{normalize:n})),await Z(t,r==="global"?dr:Xt,$o,o,n),o}var lx=u(()=>{mt();Q();Ct();yc();By();s(cx,"importFromPiAgent");});function mx(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:$o}))}var px=u(()=>{_t();yc();s(mx,"lintRules");});function ux(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","pi-agent","Pi Coding Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function dx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","pi-agent","Pi Coding Agent has no dedicated permissions config; canonical permissions are not projected.")]}function gx(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","pi-agent","Pi Coding Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function fx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","pi-agent","Pi Coding Agent manages MCP servers via extensions, not a dedicated config file; canonical MCP servers are not projected.")]}var hx=u(()=>{Et();s(ux,"lintHooks");s(dx,"lintPermissions");s(gx,"lintIgnore");s(fx,"lintMcp");});var dH,gH,fH,yx,td,By=u(()=>{St();at();ax();Qt();lx();px();hx();zf();yc();dH={name:$o,primaryRootInstructionPath:ur,generateRules:ox,generateCommands:sx,generateAgents:ix,generateSkills:nx,importFrom:cx},gH={rootInstructionPath:ur,skillDir:Xt,managedOutputs:{dirs:[Xt],files:[ur]},paths:{rulePath(t){return ur},commandPath(t){return `${Xt}/${W(t)}/SKILL.md`},agentPath(t){return `${Xt}/${$(t)}/SKILL.md`}}},fH={rootInstructionPath:Wn,skillDir:dr,managedOutputs:{dirs:[dr],files:[Wn]},rewriteGeneratedPath(t){return t===ur?Wn:t.startsWith(`${Xt}/`)?t.replace(`${Xt}/`,`${dr}/`):t},mirrorGlobalPath(t,e){return ct(t,dr,e)},paths:{rulePath(t){return Wn},commandPath(t){return `${dr}/${W(t)}/SKILL.md`},agentPath(t){return `${dr}/${$(t)}/SKILL.md`}}},yx={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},td={id:$o,metadata:{displayName:"Pi Agent",category:"cli",officialUrl:"https://github.com/pi-labs/pi-agent",shortDescription:"Pi coding agent"},generators:dH,capabilities:yx,emptyImportMessage:"No Pi Coding Agent config found (AGENTS.md or .pi/skills).",lintRules:mx,lint:{hooks:ux,permissions:dx,ignore:gx,mcp:fx},supportsConversion:{commands:true,agents:true},project:gH,globalSupport:{capabilities:yx,detectionPaths:[Wn],layout:fH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[ur],global:[Wn]},canonicalDir:EE,canonicalRootFilename:"_root.md",markAsRoot:true}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Hf,detectionPaths:[ur,Xt]};});function _x(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:gr,content:r.body.trim()?r.body:""});let o=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes(jo)));for(let n of o){let i=basename(n.source,".md"),a={};n.description&&(a.description=n.description),n.globs.length>0&&(a.globs=n.globs);let c=P(a,n.body.trim()||"");e.push({path:`${Hn}/${i}.md`,content:c});}return e}function Ix(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let o=P(r,e.body.trim()||"");return {path:`${Uo}/${e.name}.md`,content:o}})}function Rx(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=P(r,e.body.trim()||"");return {path:`${Ko}/${e.name}.md`,content:o}})}function Sx(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=P(o,r.body.trim()||"");e.push({path:`${Ne}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Ne}/${r.name}/${a}`,content:i.content});}}return e}function Cx(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:js,content:e}]}function Ex(t){return !t.ignore||t.ignore.length===0?[]:[{path:Us,content:t.ignore.join(`
|
|
134
|
+
`)}]}var Ox=u(()=>{M();_c();s(_x,"generateRules");s(Ix,"generateCommands");s(Rx,"generateAgents");s(Sx,"generateSkills");s(Cx,"generateMcp");s(Ex,"generateIgnore");});async function Lx(t,e={}){let r=e.scope??"project",o=[],n=await U(jo,t,r);return o.push(...await z(ed,t,r,{normalize:n})),await Z(t,r==="global"?Bo:Ne,jo,o,n),o}var Ax=u(()=>{mt();Ct();Q();_c();Wy();s(Lx,"importFromQwenCode");});function kx(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:jo}))}var wx=u(()=>{_t();_c();s(kx,"lintRules");});var yH,_H,IH,RH,SH,ed,Wy=u(()=>{Ox();Ax();wx();Rt();_c();yH={name:jo,primaryRootInstructionPath:gr,generateRules:_x,generateCommands:Ix,generateAgents:Rx,generateSkills:Sx,generateMcp:Cx,generateIgnore:Ex,importFrom:Lx},_H={rootInstructionPath:gr,skillDir:Ne,managedOutputs:{dirs:[Hn,Uo,Ko,Ne],files:[gr,js,Us]},paths:{rulePath(t,e){return e.root?gr:`${Hn}/${t}.md`},commandPath(t){return `${Uo}/${t}.md`},agentPath(t){return `${Ko}/${t}.md`}}},IH={rootInstructionPath:zn,skillDir:Bo,managedOutputs:{dirs:[Ks,Bs,Bo],files:[zn,ta]},rewriteGeneratedPath(t){return t===gr?zn:t===js?ta:t===Us?null:t.startsWith(`${Uo}/`)?t.replace(`${Uo}/`,`${Ks}/`):t.startsWith(`${Ko}/`)?t.replace(`${Ko}/`,`${Bs}/`):t.startsWith(`${Ne}/`)?t.replace(`${Ne}/`,`${Bo}/`):t.startsWith(`${Hn}/`)?null:t},paths:{rulePath(t,e){return zn},commandPath(t){return `${Ks}/${t}.md`},agentPath(t){return `${Bs}/${t}.md`}}},RH={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},SH={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ed={id:jo,metadata:{displayName:"Qwen Code",category:"cli",officialUrl:"https://github.com/QwenLM/qwen-code",shortDescription:"Alibaba's Qwen coding CLI"},generators:yH,capabilities:RH,emptyImportMessage:"No Qwen Code config found (QWEN.md or .qwen/rules, .qwen/commands, .qwen/settings.json).",lintRules:kx,project:_H,globalSupport:{capabilities:SH,detectionPaths:[zn,ta,Ks,Bs,Bo],layout:IH},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[gr],global:[zn]},canonicalDir:Vf,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Hn],global:[]},canonicalDir:Vf,extensions:[".md"],preset:"rule"}],commands:{feature:"commands",mode:"directory",source:{project:[Uo],global:[Ks]},canonicalDir:OE,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[Ko],global:[Bs]},canonicalDir:LE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[js],global:[ta]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/mcp.json"},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Us],global:[]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/ignore"}},buildImportPaths:Jf,detectionPaths:[gr,".qwen/settings.json",".qwen/commands",".qwen/rules"]};});function Tx(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Wo)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:Xr,content:n}]:[]}function bx(t){return tt(t,Ie)}function Px(t){return t.commands.map(e=>({path:`${Ie}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function xx(t){return t.agents.map(e=>({path:`${Ie}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}var Dx=u(()=>{Q();Mt();at();St();Ic();s(Tx,"generateRules");s(bx,"generateSkills");s(Px,"generateCommands");s(xx,"generateAgents");});async function Nx(t,e={}){let r=e.scope??"project",o=[],n=await U(Wo,t,r);return o.push(...await z(rd,t,r,{normalize:n})),await Z(t,Ie,Wo,o,n),o}var Fx=u(()=>{mt();Q();Ct();Ic();Hy();s(Nx,"importFromReplitAgent");});function vx(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Wo}))}var Gx=u(()=>{_t();Ic();s(vx,"lintRules");});function Mx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","replit-agent","Replit Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function $x(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","replit-agent","Replit Agent permissions are managed in the cloud UI; canonical permissions are not projected.")]}function jx(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","replit-agent","Replit Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function Ux(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","replit-agent","Replit Agent MCP servers are configured via the Integrations UI, not file-based; canonical MCP config is not projected.")]}var Kx=u(()=>{Et();s(Mx,"lintHooks");s($x,"lintPermissions");s(jx,"lintIgnore");s(Ux,"lintMcp");});var CH,EH,OH,rd,Hy=u(()=>{St();at();Dx();Fx();Gx();Kx();Xf();Ic();CH={name:Wo,primaryRootInstructionPath:Xr,generateRules:Tx,generateCommands:Px,generateAgents:xx,generateSkills:bx,importFrom:Nx},EH={rootInstructionPath:Xr,skillDir:Ie,managedOutputs:{dirs:[Ie],files:[Xr]},paths:{rulePath(t){return Xr},commandPath(t){return `${Ie}/${W(t)}/SKILL.md`},agentPath(t){return `${Ie}/${$(t)}/SKILL.md`}}},OH={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},rd={id:Wo,metadata:{displayName:"Replit Agent",category:"agent-platform",officialUrl:"https://replit.com",shortDescription:"Replit's autonomous coding agent"},generators:CH,capabilities:OH,emptyImportMessage:"No Replit Agent config found (replit.md or .agents/skills).",lintRules:vx,lint:{hooks:Mx,permissions:$x,ignore:jx,mcp:Ux},supportsConversion:{commands:true,agents:true},project:EH,sharedArtifacts:{".agents/skills/":"consumer"},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Xr]},canonicalDir:kE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Yf,detectionPaths:[Xr]};});function Wx(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Zr,content:r.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(Ws))continue;let n=basename(o.source,".md");e.push({path:`${Vn}/${n}.md`,content:o.body.trim()||""});}return e}function Hx(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Jn}/${e.name}.md`,content:P(r,e.body.trim()||"")}})}function zx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:im,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Vx(t){return t.ignore.length===0?[]:[{path:am,content:t.ignore.join(`
|
|
135
|
+
`)}]}function Jx(t){return tt(t,Ho)}function Yx(t){if(t.agents.length===0)return [];let e=t.agents.map(r=>{let n={slug:basename(r.source,".md"),name:r.name};return r.description&&(n.description=r.description),r.body.trim()&&(n.roleDefinition=r.body.trim()),n});return [{path:Rc,content:stringify({customModes:e})}]}var Xx=u(()=>{Q();M();na();s(Wx,"generateRules");s(Hx,"generateCommands");s(zx,"generateMcp");s(Vx,"generateIgnore");s(Jx,"generateSkills");s(Yx,"generateAgents");});var od,Qx,zy=u(()=>{M();lt();na();od=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${oa}/${t}`,content:await K(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"rooNonRootRuleMapper"),Qx=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=w(e(o));return {destPath:o,toPath:`${Xp}/${t}`,content:await ht(o,{hasDescription:true,description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function kH(t,e,r){let o=join(t,ea),n;try{n=await readdir(o,{withFileTypes:!0});}catch{return}let i=n.filter(c=>c.isDirectory()&&c.name.startsWith("rules-")).map(c=>c.name),a=join(t,oa);for(let c of i)e.push(...await yt({srcDir:join(o,c),destDir:a,extensions:[".md"],fromTool:Ws,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:d})=>{let g=await od({absolutePath:l,relativePath:m,content:p,destDir:a,normalizeTo:d});return g?{...g,feature:"rules"}:null},"mapEntry")}));}async function qx(t,e={}){let r=e.scope??"project",o=[],n=await U(Ws,t,r);return o.push(...await z(nd,t,r,{normalize:n})),await kH(t,o,n),await Z(t,Ho,Ws,o,n),o}var tD=u(()=>{mt();Q();ke();Ct();zy();na();Jy();s(kH,"importPerModeRules");s(qx,"importFromRooCode");});function eD(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Ws}))}var rD=u(()=>{_t();na();s(eD,"lintRules");});function DH(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var PH,xH,NH,FH,vH,nd,Jy=u(()=>{T();Xx();na();Qt();tD();zy();rD();Rt();PH={name:"roo-code",primaryRootInstructionPath:Zr,generateRules:Wx,generateCommands:Hx,generateSkills:Jx,generateMcp:zx,generateIgnore:Vx,generateAgents:Yx,importFrom:qx},xH={rootInstructionPath:Zr,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Rc]},paths:{rulePath(t,e){return `${Vn}/${t}.md`},commandPath(t,e){return `${Jn}/${t}.md`},agentPath(t,e){return null}}};s(DH,"computeStatus");NH=s(async(t,e,r,o)=>{if(r!=="global")return [];if(!o.has("agents")||t.agents.length===0)return [];let n=t.agents.map(c=>{let m={slug:basename(c.source,".md"),name:c.name};return c.description&&(m.description=c.description),c.body.trim()&&(m.roleDefinition=c.body.trim()),m}),i=stringify({customModes:n}),a=await y(join(e,cm));return [{target:"roo-code",path:cm,content:i,currentContent:a??void 0,status:DH(a,i)}]},"generateRooGlobalExtras"),FH={rootInstructionPath:Vs,skillDir:Yn,managedOutputs:{dirs:[Hs,zs,Yn,wE],files:[Vs,ra,lm,cm]},rewriteGeneratedPath(t){return t===Zr?Vs:t===Rc?null:t.startsWith(`${Vn}/`)?t.replace(`${Vn}/`,`${Hs}/`):t.startsWith(`${Jn}/`)?t.replace(`${Jn}/`,`${zs}/`):t.startsWith(`${Ho}/`)?t.replace(`${Ho}/`,`${Yn}/`):t===im?ra:t===am?lm:t},mirrorGlobalPath(t,e){return ct(t,Yn,e)},paths:{rulePath(t,e){return `${Hs}/${t}.md`},commandPath(t,e){return `${zs}/${t}.md`},agentPath(t,e){return null}}},vH={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},nd={id:"roo-code",metadata:{displayName:"Roo Code",category:"ide",officialUrl:"https://roocode.com",shortDescription:"Open-source AI VS Code extension"},generators:PH,capabilities:{rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},emptyImportMessage:"No Roo Code config found (.roo/rules, .roo/commands, .roo/skills, .roo/mcp.json, .rooignore, or .roorules).",lintRules:eD,project:xH,globalSupport:{capabilities:vH,detectionPaths:[Hs,zs,Yn,ra,lm,Vs,cm],layout:FH,scopeExtras:NH},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Zr,sm],global:[Vs,Zr,sm]},canonicalDir:oa,canonicalRootFilename:"_root.md",markAsRoot:true,frontmatterRemap:s(({description:t,globs:e})=>({description:typeof t=="string"?t:void 0,globs:Array.isArray(e)?e:void 0}),"frontmatterRemap")},{feature:"rules",mode:"directory",source:{project:[Vn],global:[Hs]},canonicalDir:oa,extensions:[".md"],map:od}],commands:{feature:"commands",mode:"directory",source:{project:[Jn],global:[zs]},canonicalDir:Xp,extensions:[".md"],map:Qx},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[im],global:[ra]},canonicalDir:".agentsmesh",canonicalFilename:TE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[am],global:[lm]},canonicalDir:".agentsmesh",canonicalFilename:bE}},buildImportPaths:Zf,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Rc]};});function oD(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(zo)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:fr,content:n}]:[]}function nD(t){return tt(t,Zt)}function sD(t){return t.commands.map(e=>({path:`${Zt}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function iD(t){return t.agents.map(e=>({path:`${Zt}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function aD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Xn,content:e}]}var cD=u(()=>{Q();Mt();at();St();Cc();s(oD,"generateRules");s(nD,"generateSkills");s(sD,"generateCommands");s(iD,"generateAgents");s(aD,"generateMcp");});async function lD(t,e={}){let r=e.scope??"project",o=[],n=await U(zo,t,r);return o.push(...await z(sd,t,r,{normalize:n})),await Z(t,r==="global"?Fe:Zt,zo,o,n),o}var mD=u(()=>{mt();Q();Ct();Cc();Yy();s(lD,"importFromRovodev");});function pD(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:zo}))}var uD=u(()=>{_t();Cc();s(pD,"lintRules");});function dD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","rovodev","Rovo Dev has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function gD(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","rovodev","Rovo Dev permissions are managed in config.yaml; canonical permissions are not projected.")]}function fD(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","rovodev","Rovo Dev has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var hD=u(()=>{Et();s(dD,"lintHooks");s(gD,"lintPermissions");s(fD,"lintIgnore");});var GH,MH,$H,jH,UH,sd,Yy=u(()=>{St();at();cD();Qt();mD();uD();hD();Rt();Cc();GH={name:zo,primaryRootInstructionPath:fr,generateRules:oD,generateCommands:sD,generateAgents:iD,generateSkills:nD,generateMcp:aD,importFrom:lD},MH={rootInstructionPath:fr,skillDir:Zt,managedOutputs:{dirs:[Zt],files:[fr,Xn]},paths:{rulePath(t){return fr},commandPath(t){return `${Zt}/${W(t)}/SKILL.md`},agentPath(t){return `${Zt}/${$(t)}/SKILL.md`}}},$H={rootInstructionPath:Zn,skillDir:Fe,managedOutputs:{dirs:[Fe],files:[Zn,Sc]},rewriteGeneratedPath(t){return t===fr?Zn:t.startsWith(`${Zt}/`)?t.replace(`${Zt}/`,`${Fe}/`):t===Xn?Sc:t},mirrorGlobalPath(t,e){return ct(t,Fe,e)},paths:{rulePath(t){return Zn},commandPath(t){return `${Fe}/${W(t)}/SKILL.md`},agentPath(t){return `${Fe}/${$(t)}/SKILL.md`}}},jH={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},UH={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},sd={id:zo,metadata:{displayName:"Rovo Dev",category:"cli",officialUrl:"https://www.atlassian.com/solutions/devops/rovo-dev",shortDescription:"Atlassian's coding agent"},generators:GH,capabilities:jH,emptyImportMessage:"No Rovo Dev config found (AGENTS.md, .rovodev/skills, or .rovodev/mcp.json).",lintRules:pD,lint:{hooks:dD,permissions:gD,ignore:fD},supportsConversion:{commands:true,agents:true},project:MH,globalSupport:{capabilities:UH,detectionPaths:[DE,Zn,Fe],layout:$H},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[fr],global:[Zn]},canonicalDir:NE,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Xn],global:[Sc]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Qf,detectionPaths:[fr,Zt,Xn]};});function yD(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Ge,content:r.body.trim()});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(hr))continue;let n=basename(o.source,".md");e.push({path:`${ve}/${n}.md`,content:o.body.trim()});}return e}function _D(t){return tt(t,yr)}function ID(t){return t.mcp===null||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:sa,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function RD(t){return t.ignore.length===0?[]:[{path:Ec,content:t.ignore.join(`
|
|
136
|
+
`)}]}var SD=u(()=>{Q();Oc();s(yD,"generateRules");s(_D,"generateSkills");s(ID,"generateMcp");s(RD,"generateIgnore");});async function WH(t,e,r,o){let n=o==="global"?[_r,Ge]:[Ge,_r];for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,CD),{frontmatter:m,body:p}=w(r(c,a,l));await L(join(t,pm)),await I(l,await K(l,{...m,root:true},p)),e.push({fromTool:hr,fromPath:a,toPath:CD,feature:"rules"});return}}async function HH(t,e,r,o){let n=join(t,o==="global"?Qn:ve),i=join(t,pm);e.push(...await yt({srcDir:n,destDir:i,extensions:[".md"],fromTool:hr,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:c})=>{let l=basename(a);if(l==="project_rules.md"||l==="rules.md")return null;let m=join(i,a),{frontmatter:p,body:d}=w(c(m));return {destPath:m,toPath:`${pm}/${a}`,feature:"rules",content:await K(m,{...p,root:false},d)}},"mapEntry")}));}async function ED(t,e={}){let r=e.scope??"project",o=[],n=await U(hr,t,r);return await WH(t,o,n,r),await HH(t,o,n,r),o.push(...await z(id,t,r,{normalize:n})),await Z(t,r==="global"?Qr:yr,hr,o,n),o}var CD,OD=u(()=>{mt();Q();ke();Ct();lt();T();M();Oc();Xy();CD=`${pm}/_root.md`;s(WH,"importRoot");s(HH,"importNonRootRules");s(ED,"importFromTrae");});function LD(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:hr}))}var AD=u(()=>{_t();Oc();s(LD,"lintRules");});var zH,VH,JH,YH,id,Xy=u(()=>{SD();Qt();OD();AD();Rt();Oc();zH={name:hr,primaryRootInstructionPath:Ge,generateRules:yD,generateSkills:_D,generateMcp:ID,generateIgnore:RD,importFrom:ED},VH={rootInstructionPath:Ge,skillDir:yr,managedOutputs:{dirs:[ve,yr],files:[sa,Ec]},paths:{rulePath(t,e){return `${ve}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},JH={rootInstructionPath:_r,skillDir:Qr,managedOutputs:{dirs:[Qn,Qr,vE],files:[_r,mm]},rewriteGeneratedPath(t){return t===Ge?_r:t.startsWith(`${ve}/`)?t.replace(`${ve}/`,`${Qn}/`):t.startsWith(`${yr}/`)?t.replace(`${yr}/`,`${Qr}/`):t===sa?mm:t===Ec?null:t},mirrorGlobalPath(t,e){return ct(t,Qr,e)},paths:{rulePath(t,e){return t==="_root"?_r:`${Qn}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},YH={rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},id={id:hr,metadata:{displayName:"Trae",category:"ide",officialUrl:"https://www.trae.ai",shortDescription:"ByteDance's adaptive AI IDE"},generators:zH,capabilities:{rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},emptyImportMessage:"No Trae config found (.trae/rules/project_rules.md, .trae/rules/*.md, .trae/skills/, .trae/mcp.json, or .trae/.ignore).",lintRules:LD,project:VH,globalSupport:{capabilities:YH,detectionPaths:[_r,Qn,Qr,mm],layout:JH},importer:{mcp:{feature:"mcp",mode:"mcpJson",source:{project:[sa],global:[mm]},canonicalDir:".agentsmesh",canonicalFilename:GE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ec]},canonicalDir:".agentsmesh",canonicalFilename:ME}},buildImportPaths:qf,detectionPaths:[ve,sa,Ge]};});function kD(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Vo)),o=e?.body.trim()??"",n=st(o,r);return n?[{path:qr,content:n}]:[]}function wD(t){return tt(t,ie)}function TD(t){return t.commands.map(e=>({path:`${ie}/${W(e.name)}/SKILL.md`,content:bt(e)}))}function bD(t){return t.agents.map(e=>({path:`${ie}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}function PD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Js,content:e}]}var xD=u(()=>{Q();Mt();at();St();Lc();s(kD,"generateRules");s(wD,"generateSkills");s(TD,"generateCommands");s(bD,"generateAgents");s(PD,"generateMcp");});async function DD(t,e={}){let r=e.scope??"project",o=[],n=await U(Vo,t,r);return o.push(...await z(ad,t,r,{normalize:n})),await Z(t,r==="global"?Re:ie,Vo,o,n),o}var ND=u(()=>{mt();Q();Ct();Lc();Zy();s(DD,"importFromWarp");});function FD(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Vo}))}var vD=u(()=>{_t();Lc();s(FD,"lintRules");});function GD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function MD(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function $D(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var jD=u(()=>{Et();s(GD,"lintHooks");s(MD,"lintPermissions");s($D,"lintIgnore");});var XH,ZH,QH,qH,tz,ad,Zy=u(()=>{St();at();xD();Qt();ND();vD();jD();Rt();Lc();XH={name:Vo,primaryRootInstructionPath:qr,generateRules:kD,generateCommands:TD,generateAgents:bD,generateSkills:wD,generateMcp:PD,importFrom:DD},ZH={rootInstructionPath:qr,skillDir:ie,managedOutputs:{dirs:[ie],files:[qr,Js]},paths:{rulePath(t){return qr},commandPath(t){return `${ie}/${W(t)}/SKILL.md`},agentPath(t){return `${ie}/${$(t)}/SKILL.md`}}},QH={rootInstructionPath:void 0,skillDir:Re,managedOutputs:{dirs:[Re],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${ie}/`)?t.replace(`${ie}/`,`${Re}/`):t},mirrorGlobalPath(t,e){return ct(t,Re,e)},paths:{rulePath(){return Re},commandPath(t){return `${Re}/${W(t)}/SKILL.md`},agentPath(t){return `${Re}/${$(t)}/SKILL.md`}}},qH={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},tz={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},ad={id:Vo,metadata:{displayName:"Warp",category:"cli",officialUrl:"https://www.warp.dev",shortDescription:"AI-powered terminal"},generators:XH,capabilities:qH,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:FD,lint:{hooks:GD,permissions:MD,ignore:$D},supportsConversion:{commands:true,agents:true},project:ZH,globalSupport:{capabilities:tz,detectionPaths:[Re],layout:QH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[th,qr]},canonicalDir:jE,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Js]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:eh,detectionPaths:[qr,th,Js]};});var rn,Qy,ri,UD,Uc,on,Kc,Bc,KD,oi,oo,Wc,qy,BD,WD,t_,e_,r_,Hc,zc,Em,cd,ld,md,HD,fe=u(()=>{rn="windsurf",Qy=".windsurfrules",ri=".windsurf/rules",UD=".windsurfignore",Uc=".codeiumignore",on="AGENTS.md",Kc=".windsurf/hooks.json",Bc=".windsurf/mcp_config.example.json",KD=".windsurf/mcp_config.json",oi=".windsurf/workflows",oo=".windsurf/skills",Wc=".agentsmesh/rules",qy=".agentsmesh/commands",BD=".agentsmesh/agents",WD=".agentsmesh/skills",t_=".agentsmesh/ignore",e_=".agentsmesh/hooks.yaml",r_=".agentsmesh/mcp.json",Hc=".codeium/windsurf/memories/global_rules.md",zc=".codeium/windsurf/skills",Em=".codeium/windsurf/global_workflows",cd=".codeium/windsurf/hooks.json",ld=".codeium/windsurf/mcp_config.json",md=".codeium/.codeiumignore",HD=".agents/skills";});function rz(t){let e=basename(t,".md");return e==="_root"?"root":e}function oz(t){if(t.length===0)return null;let e=t.map(r=>r.split("/")[0]??"").filter(r=>/^[A-Za-z0-9._-]+$/.test(r));return e.length!==t.length?null:e.every(r=>r===e[0])?e[0]:null}function o_(t){let e=[],r=t.rules.find(o=>o.root);if(!r)return [];e.push({path:on,content:r.body.trim()});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("windsurf"))continue;let n=rz(o.source),i=o.trigger||(o.globs.length>0?"glob":void 0),a={description:o.description||void 0,trigger:i,glob:o.globs.length===1?o.globs[0]:void 0,globs:o.globs.length>1?o.globs:void 0};Object.keys(a).forEach(m=>{a[m]===void 0&&delete a[m];});let c=Object.keys(a).length>0?P(a,o.body.trim()||""):o.body.trim()||"";e.push({path:`${ri}/${n}.md`,content:c});let l=oz(o.globs);l&&(l!==n&&e.push({path:`${ri}/${l}.md`,content:c}),e.push({path:`${l}/AGENTS.md`,content:o.body.trim()||""}));}return e}var zD=u(()=>{M();fe();s(rz,"ruleSlug");s(oz,"directoryScopedRuleDir");s(o_,"generateRules");});function n_(t){return !t.ignore||t.ignore.length===0?[]:[{path:Uc,content:t.ignore.join(`
|
|
137
|
+
`)}]}var VD=u(()=>{fe();s(n_,"generateIgnore");});function s_(t){return t.commands.map(e=>{let r={description:e.description.trim()||void 0,allowedTools:e.allowedTools.length>0?e.allowedTools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=Object.keys(r).length>0?P(r,e.body.trim()||""):e.body.trim();return {path:`${oi}/${e.name}.md`,content:o}})}var JD=u(()=>{M();fe();s(s_,"generateCommands");});function i_(t){return t.agents.map(e=>({path:`${oo}/${$(e.name)}/SKILL.md`,content:Lt(e)}))}var YD=u(()=>{at();fe();s(i_,"generateAgents");});function a_(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Bc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var XD=u(()=>{fe();s(a_,"generateMcp");});function nz(t){let e={PreToolUse:"pre_tool_use",PostToolUse:"post_tool_use",Notification:"notification",UserPromptSubmit:"user_prompt_submit",SubagentStart:"subagent_start",SubagentStop:"subagent_stop"};return e[t]?e[t]:t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function sz(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!po(i))continue;let a=Kt(i),c=le(i),l=i.type==="prompt"?c||a:a||c;l&&n.push({command:l,show_output:true});}n.length>0&&(e[nz(r)]=n);}return e}function c_(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=sz(t.hooks);return Object.keys(e).length===0?[]:[{path:Kc,content:JSON.stringify({hooks:e},null,2)}]}var ZD=u(()=>{br();fe();s(nz,"windsurfEventName");s(sz,"toWindsurfHooks");s(c_,"generateHooks");});function l_(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=Object.keys(o).length>0?P(o,r.body.trim()||""):r.body.trim()||"";e.push({path:`${oo}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles)e.push({path:`${oo}/${r.name}/${i.relativePath}`,content:i.content});}return e}var QD=u(()=>{M();fe();s(l_,"generateSkills");});var qD=u(()=>{zD();VD();JD();YD();XD();ZD();QD();});var tN=u(()=>{qD();});function eN(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function rN(t,e,r){let o=join(t,oi),i=(await N(o)).filter(c=>c.endsWith(".md")),a=join(t,qy);for(let c of i){let l=await y(c);if(!l)continue;let m=relative(o,c).replace(/\\/g,"/");await L(a);let p=join(a,m),d=r(l,c,p),{frontmatter:g,body:f}=w(d),h=await ht(p,{description:typeof g.description=="string"?g.description:"",hasDescription:Object.prototype.hasOwnProperty.call(g,"description"),allowedTools:(()=>{let O=eN(g.allowedTools);return O.length>0?O:eN(g["allowed-tools"])})(),hasAllowedTools:Object.prototype.hasOwnProperty.call(g,"allowedTools")||Object.prototype.hasOwnProperty.call(g,"allowed-tools")},f);await I(p,h),e.push({fromTool:rn,fromPath:c,toPath:`${qy}/${m}`,feature:"commands"});}}var oN=u(()=>{T();M();lt();fe();s(eN,"toStringArray");s(rN,"importWorkflows");});async function nN(t,e,r,o=oo){await wc([o],{projectRoot:t,destCanonicalSkillsDir:WD,targetName:"windsurf",normalize:r,results:e},[Tc({canonicalAgentsDir:BD})]);}var sN=u(()=>{bc();fe();s(nN,"importSkills");});async function aN(t,e){let r=join(t,Kc),o=await y(r);if(o)try{let n=JSON.parse(o);if(!n.hooks||typeof n.hooks!="object"||Array.isArray(n.hooks))return;let i=lz(n.hooks);if(Object.keys(i).length===0)return;let a=join(t,e_);await L(dirname(a)),await I(a,stringify(i)),e.push({fromTool:rn,fromPath:r,toPath:e_,feature:"hooks"});}catch{}}function cz(t){return {pre_tool_use:"PreToolUse",post_tool_use:"PostToolUse",notification:"Notification",user_prompt_submit:"UserPromptSubmit",subagent_start:"SubagentStart",subagent_stop:"SubagentStop"}[t]??t}function lz(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=cz(r),i=[];for(let a of o){if(!a||typeof a!="object")continue;let c=a;if(typeof c.command=="string"&&c.command.trim()){i.push({matcher:".*",type:"command",command:c.command});continue}let l=typeof c.matcher=="string"&&c.matcher.trim()?c.matcher:".*",m=Array.isArray(c.hooks)?c.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let d=p,g=typeof d.command=="string"?d.command:typeof d.prompt=="string"?d.prompt:"";if(!g.trim())continue;let f={matcher:l,type:d.type==="prompt"?"prompt":"command",command:g};typeof d.timeout=="number"&&(f.timeout=d.timeout),i.push(f);}}i.length>0&&(e[n]=i);}return e}async function cN(t,e){let r=[Bc,KD];for(let o of r){let n=join(t,o),i=await y(n);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let c=join(t,r_);await L(dirname(c)),await I(c,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:rn,fromPath:n,toPath:r_,feature:"mcp"});return}catch{}}}var lN=u(()=>{T();fe();s(aN,"importWindsurfHooks");s(cz,"canonicalHookEventName");s(lz,"windsurfHooksToCanonical");s(cN,"importWindsurfMcp");});async function ud(t,e){let r=e?.scope??"project",o=[],n=await U(rn,t),i=await U("codex-cli",t),a=join(t,Wc),c=join(t,Qy),l=await y(c);if(l!==null){await L(a);let g=join(a,"_root.md"),f=n(l,c,g).trim(),h=await K(g,{root:true},f);await I(g,h),o.push({fromTool:"windsurf",fromPath:c,toPath:`${Wc}/_root.md`,feature:"rules"});}if(l===null){let g=join(t,on),f=await y(g);if(f!==null){await L(a);let h=join(a,"_root.md"),O=n(i(f,g,h),g,h).trim(),R=await K(h,{root:true},O);await I(h,R),o.push({fromTool:"windsurf",fromPath:g,toPath:`${Wc}/_root.md`,feature:"rules"});}}r!=="global"&&o.push(...await yt({srcDir:t,destDir:a,extensions:["AGENTS.md"],fromTool:"windsurf",normalize:n,mapEntry:s(async({srcPath:g,normalizeTo:f})=>{let h=relative(t,dirname(g)).replace(/\\/g,"/");if(!h||h==="."||basename(g)!=="AGENTS.md")return null;let O=h.replace(/\//g,"-");if(!Sp(h))return await go(join(a,`${O}.md`)),null;let R=join(a,`${O}.md`);return {destPath:R,toPath:`${Wc}/${O}.md`,feature:"rules",content:await K(R,{root:false,globs:[`${h}/**`]},f(R))}},"mapEntry")}));let m=join(t,ri);o.push(...await yt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:n,mapEntry:s(async({relativePath:g,normalizeTo:f})=>{if(g==="_root.md"&&l!==null)return null;let h=join(a,g),{frontmatter:O,body:R}=w(f(h)),E={...O};return typeof E.glob=="string"&&E.glob.trim()&&(E.globs=[E.glob],delete E.glob),{destPath:h,toPath:`${Wc}/${g}`,feature:"rules",content:await K(h,{...E,root:false},R)}},"mapEntry")}));let p=join(t,UD),d=await y(p);if((d===null||!d.trim())&&(p=join(t,Uc),d=await y(p)),d!==null&&d.trim()){let g=d.split(/\r?\n/),f=[];for(let h of g){let O=h.trim();O&&!O.startsWith("#")&&f.push(O);}if(f.length>0){await L(join(t,".agentsmesh"));let h=join(t,t_);await I(h,f.join(`
|
|
138
|
+
`)),o.push({fromTool:"windsurf",fromPath:p,toPath:t_,feature:"ignore"});}}return await rN(t,o,n),await nN(t,o,n),await aN(t,o),await cN(t,o),o}var p_=u(()=>{mt();T();M();lt();ke();Al();fe();oN();sN();lN();s(ud,"importFromWindsurf");});function mN(t,e,r){let o=[],{rules:n}=t;n.length>0&&(n.some(c=>c.root)||o.push({level:"warning",file:relative(e,n[0].source),target:rn,message:"Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."}));let i=[];return t.permissions&&(t.permissions.allow.length>0||t.permissions.deny.length>0)&&i.push("permissions"),i.length>0&&o.push({level:"warning",file:".agentsmesh",target:rn,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),o}var pN=u(()=>{fe();s(mN,"lintRules");});function uN(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>b(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function dN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[b(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var gN=u(()=>{Et();s(uN,"lintCommands");s(dN,"lintMcp");});function gz(t){if(t.length===0)return null;let e=t.map(r=>r.split("/")[0]??"").filter(r=>/^[A-Za-z0-9._-]+$/.test(r));return e.length!==t.length?null:e.every(r=>r===e[0])?e[0]:null}var fz,hz,yz,_z,fN,hN=u(()=>{tN();_i();fe();Qt();p_();pN();gN();Rt();Ua();at();s(gz,"directoryScopedRuleDir");fz={name:"windsurf",primaryRootInstructionPath:on,generateRules:o_,generateCommands:s_,generateAgents:i_,generateSkills:l_,generateMcp:a_,generateHooks:c_,generateIgnore:n_,importFrom:ud},hz={rootInstructionPath:on,extraRuleOutputPaths(t){if(t.root)return [on];let e=gz(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:oo,managedOutputs:{dirs:[".windsurf/rules",".windsurf/skills",".windsurf/workflows"],files:["AGENTS.md",".codeiumignore",".windsurf/hooks.json",".windsurf/mcp_config.example.json"]},paths:{rulePath(t,e){return `${ri}/${t}.md`},commandPath(t,e){return `${oi}/${t}.md`},agentPath(t,e){return Ve(e,"windsurf")?`.windsurf/skills/${$(t)}/SKILL.md`:null}}},yz={rootInstructionPath:Hc,skillDir:zc,managedOutputs:{dirs:[zc,Em,HD],files:[Hc,cd,ld,md]},rewriteGeneratedPath(t){return t===on?Hc:t.startsWith(`${ri}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${oo}/`)?t.replace(`${oo}/`,`${zc}/`):t.startsWith(`${oi}/`)?t.replace(`${oi}/`,`${Em}/`):t===Kc?cd:t===Bc?ld:t===Uc?md:t},mirrorGlobalPath(t,e){return ct(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return Hc},commandPath(t,e){return `${Em}/${t}.md`},agentPath(t,e){return Ve(e,"windsurf")?`${zc}/${$(t)}/SKILL.md`:null}}},_z={rules:"native",additionalRules:"partial",commands:Dr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},fN={id:"windsurf",metadata:{displayName:"Windsurf",category:"ide",officialUrl:"https://windsurf.com",shortDescription:"Codeium's agentic IDE"},generators:fz,capabilities:{rules:"native",additionalRules:"native",commands:Dr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},emptyImportMessage:"No Windsurf config found (.windsurfrules, .windsurf/rules, .windsurfignore, or .codeiumignore).",supportsConversion:{agents:true},lintRules:mN,lint:{commands:uN,mcp:dN},project:hz,globalSupport:{capabilities:_z,detectionPaths:[Hc,zc,Em,cd,ld,md],layout:yz},buildImportPaths:rh,detectionPaths:[".windsurfrules",".windsurf"]};});function yN(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("zed")),o=e?.body.trim()??"",n=st(o,r);return n?[{path:to,content:n}]:[]}var _N=u(()=>{Mt();ia();s(yN,"generateRules");});async function RN(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let a=n.context_servers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,c[l]=p;}Object.keys(c).length!==0&&(await $t(t,IN,c),r.push({fromTool:"zed",fromPath:e,toPath:IN,feature:"mcp"}));}var IN,SN=u(()=>{T();Nr();ia();IN=".agentsmesh/mcp.json";s(RN,"importZedMcp");});async function CN(t,e={}){let r=e.scope??"project",o=[],n=await U("zed",t,r);return o.push(...await z(dd,t,r,{normalize:n})),await RN(t,r==="global"?Yo:Jo,o),o}var EN=u(()=>{mt();Ct();SN();ia();u_();s(CN,"importFromZed");});function ON(t,e,r,o){return H(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:"zed"}))}var LN=u(()=>{_t();ia();s(ON,"lintRules");});function AN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[b(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function kN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[b(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function wN(t){return t.ignore.length===0?[]:[b(".agentsmesh/ignore","zed","Zed has no dedicated ignore file and relies on file_scan_exclusions in settings.json; canonical ignore patterns are not projected.")]}var TN=u(()=>{Et();s(AN,"lintHooks");s(kN,"lintPermissions");s(wN,"lintIgnore");});function Lz(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n.context_servers!==void 0&&(r.context_servers=n.context_servers),JSON.stringify(r,null,2)}var Rz,Sz,Cz,Ez,Oz,dd,u_=u(()=>{_N();EN();LN();TN();Rt();ia();Rz={name:"zed",primaryRootInstructionPath:to,generateRules:yN,importFrom:CN},Sz={rootInstructionPath:to,managedOutputs:{dirs:[],files:[to,Jo]},paths:{rulePath(t){return to},commandPath(){return null},agentPath(){return null}}},Cz={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[Yo]},rewriteGeneratedPath(t){return t===Jo?Yo:t},paths:{rulePath(){return Yo},commandPath(){return null},agentPath(){return null}}},Ez={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Oz={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(Lz,"mergeZedSettings");dd={id:"zed",metadata:{displayName:"Zed",category:"ide",officialUrl:"https://zed.dev",shortDescription:"Collaborative AI editor"},generators:Rz,capabilities:Ez,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:ON,lint:{hooks:AN,permissions:kN,ignore:wN},project:Sz,globalSupport:{capabilities:Oz,detectionPaths:[Yo],layout:Cz},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[to],global:[]},canonicalDir:BE,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let r={};for(let[o,n]of Object.entries(t.mcp.mcpServers))r[o]=n;return [{path:Jo,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,o){return o===Jo||o===Yo?Lz(t,r):null},buildImportPaths:oh,detectionPaths:[to,Jo]};});var _C={};ug(_C,{BUILTIN_TARGETS:()=>zt,TARGET_IDS:()=>kt,getBuiltinTargetDefinition:()=>Cr,getEffectiveTargetSupportLevel:()=>gd,getTargetCapabilities:()=>ti,getTargetDetectionPaths:()=>g_,getTargetLayout:()=>vt,getTargetManagedOutputs:()=>f_,getTargetPrimaryRootInstructionPath:()=>kz,getTargetSkillDir:()=>Om,isBuiltinTargetId:()=>wr,resolveTargetFeatureGenerator:()=>Vc,rewriteGeneratedOutputPath:()=>h_});function Az(){return d_||(wS(zt),d_=new Map(zt.map(t=>[t.id,t]))),d_}function Cr(t){return Az().get(t)}function ti(t,e="project"){let r=Cr(t)??ut(t);if(!r)return;let o=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return AS(o)}function g_(t,e="project"){let r=Cr(t)??ut(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function vt(t,e="project"){let r=Cr(t)??ut(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function kz(t,e="project"){return vt(t,e)?.rootInstructionPath}function Om(t,e="project"){return vt(t,e)?.skillDir}function f_(t,e="project"){return vt(t,e)?.managedOutputs}function h_(t,e,r="project"){let o=vt(t,r);return o?o.rewriteGeneratedPath?o.rewriteGeneratedPath(e):e:null}function bN(t,e,r,o){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!ja(r,t.id,true,o):e==="agents"&&t.supportsConversion?.agents?!Ve(r,t.id,true,o):false}function wz(t,e,r,o){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?ja(r,t.id,true,o):e==="agents"&&t.supportsConversion?.agents?Ve(r,t.id,true,o):false}function gd(t,e,r,o="project"){let n=ti(t,o)?.[e]?.level??"none",i=Cr(t)??ut(t);return n==="none"&&wz(i,e,r,o)?"embedded":n!=="embedded"?n:bN(i,e,r,o)?"none":n}function Vc(t,e,r,o="project"){let n=Cr(t)??ut(t);if(!n?.generators||bN(n,e,r,o))return;let i=Tz[e];return i===null?void 0:i(n.generators)}var zt,d_,Tz,xt=u(()=>{Ua();_i();je();$g();mo();Xg();nh();sh();ah();QO();lh();eA();BA();Dh();jh();Kh();ny();sy();iy();Ay();ky();wy();by();vy();$y();Uy();By();Wy();Hy();Jy();Yy();Xy();Zy();hN();u_();zt=[Cp,Qp,qp,tu,ZO,eu,tA,KA,uu,Iu,Su,Pu,xu,Du,Ku,Bu,Wu,zu,Xu,Qu,qu,td,ed,rd,nd,sd,id,ad,fN,dd];s(Az,"builtinTargetsMap");s(Cr,"getBuiltinTargetDefinition");s(ti,"getTargetCapabilities");s(g_,"getTargetDetectionPaths");s(vt,"getTargetLayout");s(kz,"getTargetPrimaryRootInstructionPath");s(Om,"getTargetSkillDir");s(f_,"getTargetManagedOutputs");s(h_,"rewriteGeneratedOutputPath");s(bN,"isFeatureSuppressedByConversion");s(wz,"isConversionUpgrading");s(gd,"getEffectiveTargetSupportLevel");Tz={rules:s(t=>t.generateRules,"rules"),additionalRules:null,commands:s(t=>t.generateCommands,"commands"),agents:s(t=>t.generateAgents,"agents"),skills:s(t=>t.generateSkills,"skills"),mcp:s(t=>t.generateMcp,"mcp"),permissions:s(t=>t.generatePermissions,"permissions"),hooks:s(t=>t.generateHooks,"hooks"),ignore:s(t=>t.generateIgnore,"ignore")};s(Vc,"resolveTargetFeatureGenerator");});function vz(t){return typeof t=="string"?t:t.level}function PN(t){return Fz.includes(t)}function xN(t,e,r,o){for(let n of Nz){let i=vz(e[n.feature]);if(i==="none")continue;let a=typeof t.generators[n.generator]=="function",c=PN(n.feature)&&typeof t.emitScopedSettings=="function";a||c||r.addIssue({code:"custom",path:[...o,n.feature],message:`Capability "${n.feature}" is "${i}" but generators.${n.generator}`+(PN(n.feature)?" or emitScopedSettings":"")+" is missing."});}}function fd(t){return Mz.parse(t)}var as,DN,bz,Pz,NN,xz,Dz,Nz,Fz,Gz,Mz,y_=u(()=>{as=z$1.union([z$1.enum(["native","embedded","partial","none"]),z$1.object({level:z$1.enum(["native","embedded","partial","none"]),flavor:z$1.string().optional()})]),DN=z$1.object({rules:as,additionalRules:as,commands:as,agents:as,skills:as,mcp:as,hooks:as,ignore:as,permissions:as}),bz=z$1.object({name:z$1.string(),generateRules:z$1.function(),importFrom:z$1.function(),generateCommands:z$1.function().optional(),generateAgents:z$1.function().optional(),generateSkills:z$1.function().optional(),generateMcp:z$1.function().optional(),generatePermissions:z$1.function().optional(),generateHooks:z$1.function().optional(),generateIgnore:z$1.function().optional(),lint:z$1.function().optional()}).passthrough(),Pz=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),NN=z$1.object({paths:Pz}).passthrough(),xz=z$1.object({capabilities:DN,detectionPaths:z$1.array(z$1.string()),layout:NN,scopeExtras:z$1.function().optional()}).passthrough(),Dz=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],Nz=[{feature:"commands",generator:"generateCommands"},{feature:"agents",generator:"generateAgents"},{feature:"skills",generator:"generateSkills"},{feature:"mcp",generator:"generateMcp"},{feature:"hooks",generator:"generateHooks"},{feature:"ignore",generator:"generateIgnore"},{feature:"permissions",generator:"generatePermissions"}],Fz=["mcp","hooks","ignore","permissions"];s(vz,"capabilityLevel");s(PN,"canUseScopedSettings");s(xN,"validateCapabilityImplementations");Gz=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:bz,capabilities:DN,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:NN,globalSupport:xz.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),Mz=Gz.superRefine((t,e)=>{for(let r of Dz)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});xN(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&xN(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(fd,"validateDescriptor");});function $z(){return __||(__=new Map(zt.map(t=>[t.id,t]))),__}function hd(t){let e=fd(t);I_.set(e.id,e);}function ut(t){return I_.get(t)??$z().get(t)}function yd(){return [...I_.values()]}var I_,__,je=u(()=>{xt();y_();I_=new Map;s($z,"builtinDescriptors");s(hd,"registerTargetDescriptor");s(ut,"getDescriptor");s(yd,"getAllDescriptors");});async function FN(t,e,r="project"){let o=new Map,n=ut(t);return n&&await n.buildImportPaths(o,e,r),o}var vN=u(()=>{je();s(FN,"buildImportReferenceMap");});function Kz(t){let e=[t.project,t.globalSupport?.layout].filter(n=>n!==void 0),r=[...t.detectionPaths,...e.flatMap(n=>n.managedOutputs?.dirs??[]),...e.flatMap(n=>n.managedOutputs?.files??[])],o=new Set;for(let n of r){let i=n.split("/")[0];i&&i.startsWith(".")&&i.length>1&&o.add(`${i}/`);}return o}function Bz(){let t=new Set([".agentsmesh/"]);for(let e of zt)for(let r of Kz(e))t.add(r);return Array.from(t)}function Wz(){let t=new Set([...Bz(),...R_.rootRelativePrefixes]),e=new Set([...Uz,...R_.meshRootSegments]);return {protectedSchemes:[...jz,...R_.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function _d(){return S_||(S_=Wz()),S_}var jz,Uz,R_,S_,GN=u(()=>{xt();jz=[/\b[A-Za-z][A-Za-z0-9+.-]+:[^\s<>()\]]+/g,/\b[\w.-]+@[\w.-]+:[^\s<>()\]]+/g,/\b[\w.+-]+@[\w.-]+\.[A-Za-z]{2,}\b/g,/\/\/[A-Za-z0-9][\w.-]*\.[A-Za-z]{2,}[^\s<>()\]]*/g],Uz=new Set(["skills","rules","commands","agents","packs"]),R_={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(Kz,"topLevelDotfilePrefixes");s(Bz,"buildDefaultRootRelativePrefixes");s(Wz,"rebuild");s(_d,"getLinkFormatRegistry");});function no(t){let e=Pt(t);return _d().rootRelativePrefixes.some(r=>e.startsWith(r))}function zz(t){let e=Pt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Pr.test(e)||/^[a-zA-Z]:/.test(e)||no(e))return false;let r=e.split("/").filter(o=>o.length>0)[0];return r!==void 0&&_d().meshRootSegments.has(r)}function Lm(t,e,r){let o=et(e),n=V(e,e),i=V(e,r),a=Pt(t);if(Pr.test(t)){let c=V(e,t);return o===win32||c.startsWith(`${n}${o.sep}`)?[c]:[c]}if(o.isAbsolute(t)){let c=V(e,t);return c.startsWith(n)||existsSync(t)?[c]:[V(e,o.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let c=V(e,o.join(o.dirname(i),a)),l=CS(a,n);return l&&l!==c?[c,l]:[c]}if(no(a))return [V(e,o.join(n,a))];if(a.includes("/")){let c=V(e,o.join(n,".agentsmesh")),l=zz(a)?V(e,o.join(c,a)):null,m=V(e,o.join(n,a)),p=V(e,o.join(o.dirname(i),a));return l!==null?[l,m,p]:[m,p]}return Vz.has(a)?[]:a.includes(".")?[V(e,o.join(o.dirname(i),a))]:[]}function Am(t,e){let r=[e];if(!SS(t,e)||!existsSync(e))return r;try{let o=[realpathSync(e),realpathSync.native(e)];for(let n of o)n!==e&&!r.includes(n)&&r.push(n);}catch{}return r}function UN(t,e,r){let o=e>0?t.at(e-1):"",n=r<t.length?t.at(r):"";return o==="*"||n==="*"}function Id(t){let e=[];for(let r of _d().protectedSchemes){let o=r.flags.includes("g")?r:new RegExp(r.source,`${r.flags}g`);for(let n of t.matchAll(o))e.push([n.index??0,(n.index??0)+n[0].length]);}for(let r of t.matchAll(Jz))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(Yz))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(Xz))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var Vz,Jz,Yz,Xz,jN,Jc,ni=u(()=>{ee();GN();s(no,"isRootRelativePathToken");s(zz,"isMeshRootRelativePathToken");Vz=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),Jz=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,Yz=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,Xz=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,jN=/(?:\.\.[\\/]|\.\/|\.\\|\/[A-Za-z0-9._-]|[A-Za-z]:[\\/][A-Za-z0-9._-]|\.agentsmesh[\\/]|\.claude[\\/]|\.cursor[\\/]|\.github[\\/]|\.continue[\\/]|\.junie[\\/]|\.kiro[\\/]|\.gemini[\\/]|\.clinerules[\\/]|\.cline[\\/]|\.codex[\\/]|\.agents[\\/]|\.windsurf[\\/]|\.roo[\\/]|(?:[A-Za-z0-9._-]+[\\/])+|[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+)[A-Za-z0-9._@%+~:\\/-]*/g,Jc=/(?::(\d+)){1,2}$/;s(Lm,"resolveProjectPath");s(Am,"expandResolvedPaths");s(UN,"isGlobAdjacent");s(Id,"protectedRanges");});function Zz(t){return t===void 0||t.role==="inline-code"||t.role==="bracketed"||t.role==="quoted"||t.role==="at-prefix"||t.role==="bracket-label"||t.role==="bare-prose"}function KN(t){return Zz(t.tokenContext)}function C_(t,e){let r=et(t),o=V(t,t),n=V(t,e);if(n===o)return true;let i=o.endsWith(r.sep)?o:`${o}${r.sep}`;return n.startsWith(i)}function BN(t){let e=et(t);return V(t,e.join(t,".agentsmesh"))}function so(t,e){let r=et(t),o=BN(t),n=V(t,e);if(n===o)return true;let i=o.endsWith(r.sep)?o:`${o}${r.sep}`;return n.startsWith(i)}function WN(t,e,r){let o=et(t),n=BN(t),i=V(t,e);if(!so(t,i))return null;let a=o.relative(n,i).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function E_(t,e,r){let n=et(t).relative(V(t,t),V(t,e)).replace(/\\/g,"/");if(n.startsWith(".."))return null;let i=n.length>0?n:".";return r&&!i.endsWith("/")?`${i}/`:i}function Yc(t,e,r){let o=E_(t,e,r);return o===null?null:{kind:"projectRoot",rest:o,text:o}}function O_(t,e,r,o,n){let i=et(t),a=V(t,t),c=V(t,e),l=V(t,r);if(!C_(t,l))return Yc(t,l,o)?.text??null;let m=V(t,i.dirname(c));if(!C_(t,m)&&m!==a)return Yc(t,l,o)?.text??null;let p=i.relative(m,l).replace(/\\/g,"/");if(i.isAbsolute(p)||Pr.test(p))return E_(t,l,o);let d=V(t,i.join(m,p));return C_(t,d)?(p===""||p==="."?p=".":n.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),o&&!p.endsWith("/")?`${p}/`:p):E_(t,l,o)}var L_=u(()=>{ee();s(Zz,"isReadingContext");s(KN,"isReadingContextOptions");s(C_,"isUnderProjectRoot");s(BN,"agentsMeshRoot");s(so,"isUnderAgentsMesh");s(WN,"toAgentsMeshRootRelative");s(E_,"toProjectRootRelative");s(Yc,"toProjectRootReference");s(O_,"formatLinkPathForDestinationLegacy");});function HN(t,e,r,o,n={}){let i=n.scope??"project",a=V(t,r);if(KN(n)&&so(t,e)&&so(t,a)){let m=et(t),p=V(t,t),d=m.relative(p,a).replace(/\\/g,"/");if(!d.startsWith("..")&&d.length>0)return o&&!d.endsWith("/")?`${d}/`:d}if(n.forceRelative)return O_(t,e,r,o,n);if(i==="global"&&!so(t,e))return Yc(t,a,o)?.text??null;let c=(()=>{if(so(t,a))return a;let m=n.logicalMeshSourceAbsolute;return m&&so(t,V(t,m))?V(t,m):null})();if(!c)return Yc(t,a,o)?.text??null;if(o||(n.pathIsDirectory?.(a)??false)){let m=WN(t,c,o);return m!==null?m:Yc(t,c,o)?.text??null}return O_(t,e,r,o,n)}var zN=u(()=>{ni();ee();L_();L_();s(HN,"formatLinkPathForDestination");});function VN(t,e,r,o){let n=et(e),i=Pt(t);if(!no(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let c=V(e,r),l=n.dirname(c);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),d=V(e,n.join(l,p));if(d!==c&&o(d))return d}return null}var JN=u(()=>{ee();ni();s(VN,"resolveByDestinationSuffixStrip");});function YN(t){let e=null,r=false,o=null,n=null,i=null;for(let l of Lm(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let d of Am(t.projectRoot,l)){let g=V(t.projectRoot,d),f=V(t.projectRoot,t.translatePath(g)),h=t.pathExists(g),O=t.pathExists(f);if(O&&f!==g){e=f,o=g,r=true;break}(h||O)&&m===null&&(m=f,p=g),e===null&&(e=f);}if(!r&&m!==null&&n===null&&(n=m,i=p),r)break}if(!r){let l=VN(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);l!==null&&(e=l,r=true);}!r&&n!==null&&(e=n,i!==null&&(o=i),r=true);let a=Pt(t.destinationFile),c=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&Pt(t.rawToken).startsWith(".agentsmesh/")&&c&&(r=true),{translatedPath:e,resolvedBeforeTranslate:o,matchedPath:r}}var XN=u(()=>{ee();ni();JN();s(YN,"resolveLinkTarget");});function ZN(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function QN(t,e,r){if(e<=0||t[e-1]!=="(")return false;let o=e+r.length,n=t[o];return n!==")"&&n!=="#"&&n!=="?"&&n!==" "&&n!==" "?false:t[e-2]==="]"}function qN(t){let e=Pt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Pr.test(e)||no(e)?false:e.includes("/")}var tF=u(()=>{ee();ni();s(ZN,"isTildeHomeRelativePathToken");s(QN,"isMarkdownLinkDestinationToken");s(qN,"isRelativePathToken");});function Qz(t,e,r){let o=e+r.length;if(t[o]!=="]"||t[o+1]!=="(")return false;let n=o+2,i="";for(;n<t.length;){let a=t[n];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
|
|
139
139
|
`)break;i+=a,n++;}return i===r}function eF(t,e,r){let o=t.lastIndexOf(`
|
|
140
140
|
`,e-1)+1,n=t.slice(o,e);if(!/^\s*\[[^\]\n]+\]:\s*<?\s*$/.test(n))return false;let i=r<t.length?t[r]:"";return i===""||i===`
|
|
141
|
-
`||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function rF(t,e,r){let o=e>0?t[e-1]:"",n=r<t.length?t[r]:"";return o==="`"&&n==="`"?{role:"inline-code"}:eF(t,e,r)?{role:"markdown-link-dest"}:o==="<"&&n===">"?{role:"bracketed"}:o==="'"&&n==="'"||o==='"'&&n==='"'?{role:"quoted"}:o==="@"?{role:"at-prefix"}:o==="("&&t[e-2]==="]"?{role:"markdown-link-dest"}:o==="["&&n==="]"?{role:"bracket-label"}:{role:"bare-prose"}}function oF(t,e,r,o,n){if(e<0||r>t.length)return false;let{candidate:i}=Ka(o),a=i.replace(Xc,""),c=Pt(a),l=e+a.length,m=t[e-1],p=t[r];return eF(t,e,l)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!n&&!io(c)&&qz(t,e,o)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":n?io(c)?true:c.includes("/")||c.includes("\\")?c.startsWith("./")||c.startsWith("../")?true:(c.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var nF=d(()=>{re();ai();s(qz,"markdownBracketLabelDuplicatesDestination");s(eF,"isMarkdownReferenceDefinitionDestination");s(rF,"getTokenContext");s(oF,"shouldRewritePathToken");});function Cd(t){let e=new Set,r=Sd(t.content);return {content:t.content.replace(jN,(n,i,a)=>{if(r.some(([Ut,wt])=>i>=Ut&&i<wt)||!oF(a,i,i+n.length,n,t.rewriteBarePathTokens===true)||ZN(a,i,n)||UN(a,i,i+n.length))return n;let{candidate:c,suffix:l}=Ka(n);if(!c)return n;let m=Xc.exec(c),p=m?c.slice(0,m.index):c,u=m?m[0]:"";if(!p)return n;let g=rF(a,i,i+p.length);if(g.role!=="markdown-link-dest"&&xr.test(p))return n;let{translatedPath:f,resolvedBeforeTranslate:h,matchedPath:O}=YN({candidate:p,rawToken:c,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),R=h;if(!O||!f)return f&&e.add(f),n;let S=Pt(p),A=p.endsWith("/")||t.pathIsDirectory?.(f)===true;if(A&&!S.includes("/")&&!S.includes("\\"))return n;if(R===null){let Ut=Pt(c);if(Ut.startsWith("agentsmesh/")&&(Ut=`.${Ut}`),Ut.startsWith(".agentsmesh/")||Ut.includes("/.agentsmesh/")){let wt=et(t.projectRoot),pn=V(t.projectRoot,t.projectRoot),kr=Ut.replace(/^\.\//,"");R=V(t.projectRoot,wt.join(pn,kr));}}let D=et(t.projectRoot);if(t.scope==="global"){let Ut=Pt(c),wt=Ut.startsWith(".agentsmesh/")||Ut.includes("/.agentsmesh/"),pn=io(Ut)||qN(Ut),kr=R!==null&&ao(t.projectRoot,R),hs=ao(t.projectRoot,f);if(R===f&&!hs&&!kr&&!wt){let _R=Pt(D.relative(t.projectRoot,V(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",o$=(R!==null?Pt(D.relative(t.projectRoot,R)):"").split("/").filter(Boolean)[0]??"";if(_R.length>0&&_R===o$)return n}if(!pn&&!wt&&!kr&&!hs)return n}let N=V(t.projectRoot,t.destinationFile),G=V(t.projectRoot,f),J=Pt(D.relative(t.projectRoot,N)),X=Pt(D.relative(t.projectRoot,G)),q=J.split("/").filter(Boolean)[0]??"",Ft=X.split("/").filter(Boolean)[0]??"",Ht=!Pt(p).startsWith(".agentsmesh/")&&!A&&q.length>0&&q===Ft&&q.startsWith(".")&&q!==".agentsmesh"||g.role==="markdown-link-dest"||QN(a,i,p),lo=HN(t.projectRoot,t.destinationFile,f,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||Ht,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:A?null:R,forceRelative:Ht,tokenContext:g,originalToken:p});return lo?`${lo}${u}${l}`:n}),missing:[...e]}}var x_=d(()=>{re();ai();zN();XN();tF();nF();s(Cd,"rewriteFileLinks");});function iF(t,e){let r=[t.normalize(e)];if(!existsSync(e))return r;try{let o=[realpathSync(e),realpathSync.native(e)];for(let n of o){let i=t.normalize(n);r.includes(i)||r.push(i);}}catch{}return r}async function U(t,e,r="project"){let o=et(e),n=new Map,i=Array.from(new Set([t,...kt]));for(let l of i){let m=await FN(l,e,r);for(let[p,u]of m.entries())n.set(p,u);}let a=new Map;for(let[l,m]of n.entries()){let p=o.normalize(o.join(e,m));for(let u of iF(o,o.join(e,l)))a.set(u,p);}let c=new Set;for(let l of new Set(n.values())){let m=o.normalize(o.join(e,l));c.add(m);for(let p of iF(o,m))c.add(o.normalize(p));}return (l,m,p)=>Cd({content:l,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:s(u=>a.get(u)??u,"translatePath"),pathExists:s(u=>{let g=o.normalize(u);return a.has(u)||a.has(g)||existsSync(u)||c.has(g)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:s(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var mt=d(()=>{re();vN();x_();uo();s(iF,"pathVariants");s(U,"createImportReferenceNormalizer");});function cF(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!go({...m,type:p}))continue;let u=p==="prompt"?me(m)||Kt(m):Kt(m)||me(m),g={matcher:c,type:p,command:u};typeof m.timeout=="number"&&(g.timeout=m.timeout),n.push(g);}}n.length>0&&(e[r]=n);}return e}async function lF(t,e){let r=join(t,wn),o=await y(r);if(o===null)return false;let n;try{n=JSON.parse(o);}catch{return false}if(!n||typeof n!="object"||Array.isArray(n))return false;let i=cF(n);if(Object.keys(i).length===0)return false;let a=stringify(i),c=join(t,bi);return await L(dirname(c)),await _(c,a),e.push({fromTool:"claude-code",fromPath:r,toPath:bi,feature:"hooks"}),true}async function mF(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(wn)),o=join(t,$l),n=await y(o);if(!n)return;let i;try{i=JSON.parse(n);}catch{return}if(!e.some(m=>m.feature==="mcp")&&i.mcpServers&&typeof i.mcpServers=="object"){let m=i.mcpServers;await $t(t,Bl,m),e.push({fromTool:"claude-code",fromPath:o,toPath:Bl,feature:"mcp"});}let c=i.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let m=c,p=Array.isArray(m.allow)?m.allow.filter(f=>typeof f=="string"):[],u=Array.isArray(m.deny)?m.deny.filter(f=>typeof f=="string"):[],g=Array.isArray(m.ask)?m.ask.filter(f=>typeof f=="string"):[];if(p.length>0||u.length>0||g.length>0){let f=stringify({allow:p,deny:u,ask:g}),h=join(t,hf);await L(dirname(h)),await _(h,f),e.push({fromTool:"claude-code",fromPath:o,toPath:hf,feature:"permissions"});}}let l=i.hooks;if(!r&&l&&typeof l=="object"&&!Array.isArray(l)){let m=cF(l);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,bi);await L(dirname(u)),await _(u,p),e.push({fromTool:"claude-code",fromPath:o,toPath:bi,feature:"hooks"});}}}var pF=d(()=>{Pr();T();Fr();Tn();s(cF,"claudeHooksToCanonical");s(lF,"importClaudeHooksJson");s(mF,"importSettings");});async function dF(t,e,r){let o=join(t,Ml),n=join(t,ff),a=(await v(o)).filter(c=>c.endsWith("SKILL.md"));for(let c of a){let l=dirname(c),m=basename(l),p=join(n,m),u=await v(l);for(let g of u){let f=await y(g);if(f===null)continue;let h=relative(l,g),O=join(p,h);await L(dirname(O));let R=r(f,g,O),S=h==="SKILL.md"?k(R):null;await _(O,h==="SKILL.md"?await ho(O,S?.frontmatter??{},S?.body??""):R);let A=`${ff}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:g,toPath:A,feature:"skills"});}}}var gF=d(()=>{T();M();lt();Tn();s(dF,"importClaudeSkills");});async function ru(t,e={}){let r=e.scope??"project",o=[],n=await U("claude-code",t,r);return o.push(...await z(eu,t,r,{normalize:n})),await dF(t,o,n),await lF(t,o),await mF(t,o),o}var dh=d(()=>{mt();Ct();pF();gF();uh();s(ru,"importFromClaudeCode");});async function wm(t,e){let r=oV[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}var oV,F_=d(()=>{dh();ay();Bh();Ty();Fh();y_();Ih();vh();Dy();Ky();$y();oV={"claude-code":ru,cursor:xu,copilot:Ru,"gemini-cli":Bu,"codex-cli":pu,windsurf:gd,cline:iu,continue:du,junie:Vu,kiro:qu,"kilo-code":Zu};s(wm,"importNativeToCanonical");});async function Ea(t){if(!await j(t))return false;if(await j(join(t,G_)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await j(join(t,r.name,G_)))return !0}catch{return false}return false}async function Tm(t){if(!await j(t))return [];if(await j(join(t,G_))){let e=await RS(t);return e?[e]:[]}return ja(t)}var G_,Od=d(()=>{T();pp();G_="SKILL.md";s(Ea,"isSkillPackLayout");s(Tm,"loadSkillsAtExtendPath");});function aV(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function cV(t){return t.rules.length===0&&t.commands.length===0&&t.agents.length===0&&t.skills.length===0&&t.mcp===null&&t.permissions===null&&t.hooks===null&&t.ignore.length===0}async function Ld(t){if(!await j(t))throw new Error(`Path does not exist: ${t}`);let e=await stat(t);if(e.isDirectory())return {sliceRoot:t};if(!e.isFile()||!t.toLowerCase().endsWith(".md"))throw new Error(`Install path must be a directory or a .md file inside rules/, commands/, or agents/: ${t}`);let r=dirname(t),o=basename(r),i=basename(t).replace(/\.md$/i,"");if(o==="rules")return {sliceRoot:r,implicitPick:{rules:[i]}};if(o==="commands")return {sliceRoot:r,implicitPick:{commands:[i]}};if(o==="agents")return {sliceRoot:r,implicitPick:{agents:[i]}};throw new Error(`Single-file install only supports .md files under rules/, commands/, or agents/. Got: ${t}`)}async function lV(t){if(basename(t)==="rules")return hi(t);let r=join(t,"rules");return await j(r)?hi(r):[]}async function mV(t){if(basename(t)==="commands")return yi(t);let r=join(t,"commands");return await j(r)?yi(r):[]}async function pV(t){if(basename(t)==="agents")return Ii(t);let r=join(t,"agents");return await j(r)?Ii(r):[]}async function uV(t){if(await Ea(t))return Tm(t);let e=join(t,"skills");return await Ea(e)?Tm(e):[]}async function Ad(t){let e=join(t,".agentsmesh");if(await j(e))return Ae(t);let r=aV();if(r.rules=await lV(t),r.commands=await mV(t),r.agents=await pV(t),r.skills=await uV(t),cV(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}var M_=d(()=>{T();lp();Ri();cp();ap();Od();s(aV,"emptyCanonical");s(cV,"isCanonicalSliceEmpty");s(Ld,"normalizeSlicePath");s(lV,"parseRulesAt");s(mV,"parseCommandsAt");s(pV,"parseAgentsAt");s(uV,"loadSkillsForPartialSlice");s(Ad,"loadCanonicalSliceAtPath");});function dV(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function fF(t){let e=t.resolvedPath;if(!t.path){let n=join(e,".agentsmesh");if(!await j(n)){if(await Ea(e)){let a=await Tm(e);return {...dV(),skills:a}}let i=t.target??await fp(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
142
|
-
Expected one of: .agentsmesh/, ${
|
|
141
|
+
`||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function rF(t,e,r){let o=e>0?t[e-1]:"",n=r<t.length?t[r]:"";return o==="`"&&n==="`"?{role:"inline-code"}:eF(t,e,r)?{role:"markdown-link-dest"}:o==="<"&&n===">"?{role:"bracketed"}:o==="'"&&n==="'"||o==='"'&&n==='"'?{role:"quoted"}:o==="@"?{role:"at-prefix"}:o==="("&&t[e-2]==="]"?{role:"markdown-link-dest"}:o==="["&&n==="]"?{role:"bracket-label"}:{role:"bare-prose"}}function oF(t,e,r,o,n){if(e<0||r>t.length)return false;let{candidate:i}=$a(o),a=i.replace(Jc,""),c=Pt(a),l=e+a.length,m=t[e-1],p=t[r];return eF(t,e,l)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!n&&!no(c)&&Qz(t,e,o)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":n?no(c)?true:c.includes("/")||c.includes("\\")?c.startsWith("./")||c.startsWith("../")?true:(c.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var nF=u(()=>{ee();ni();s(Qz,"markdownBracketLabelDuplicatesDestination");s(eF,"isMarkdownReferenceDefinitionDestination");s(rF,"getTokenContext");s(oF,"shouldRewritePathToken");});function Rd(t){let e=new Set,r=Id(t.content);return {content:t.content.replace(jN,(n,i,a)=>{if(r.some(([Ut,wt])=>i>=Ut&&i<wt)||!oF(a,i,i+n.length,n,t.rewriteBarePathTokens===true)||ZN(a,i,n)||UN(a,i,i+n.length))return n;let{candidate:c,suffix:l}=$a(n);if(!c)return n;let m=Jc.exec(c),p=m?c.slice(0,m.index):c,d=m?m[0]:"";if(!p)return n;let g=rF(a,i,i+p.length);if(g.role!=="markdown-link-dest"&&Pr.test(p))return n;let{translatedPath:f,resolvedBeforeTranslate:h,matchedPath:O}=YN({candidate:p,rawToken:c,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),R=h;if(!O||!f)return f&&e.add(f),n;let E=Pt(p),A=p.endsWith("/")||t.pathIsDirectory?.(f)===true;if(A&&!E.includes("/")&&!E.includes("\\"))return n;if(R===null){let Ut=Pt(c);if(Ut.startsWith("agentsmesh/")&&(Ut=`.${Ut}`),Ut.startsWith(".agentsmesh/")||Ut.includes("/.agentsmesh/")){let wt=et(t.projectRoot),cn=V(t.projectRoot,t.projectRoot),Ar=Ut.replace(/^\.\//,"");R=V(t.projectRoot,wt.join(cn,Ar));}}let F=et(t.projectRoot);if(t.scope==="global"){let Ut=Pt(c),wt=Ut.startsWith(".agentsmesh/")||Ut.includes("/.agentsmesh/"),cn=no(Ut)||qN(Ut),Ar=R!==null&&so(t.projectRoot,R),ds=so(t.projectRoot,f);if(R===f&&!ds&&!Ar&&!wt){let uR=Pt(F.relative(t.projectRoot,V(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",o$=(R!==null?Pt(F.relative(t.projectRoot,R)):"").split("/").filter(Boolean)[0]??"";if(uR.length>0&&uR===o$)return n}if(!cn&&!wt&&!Ar&&!ds)return n}let v=V(t.projectRoot,t.destinationFile),G=V(t.projectRoot,f),J=Pt(F.relative(t.projectRoot,v)),Y=Pt(F.relative(t.projectRoot,G)),q=J.split("/").filter(Boolean)[0]??"",Ft=Y.split("/").filter(Boolean)[0]??"",Ht=!Pt(p).startsWith(".agentsmesh/")&&!A&&q.length>0&&q===Ft&&q.startsWith(".")&&q!==".agentsmesh"||g.role==="markdown-link-dest"||QN(a,i,p),ao=HN(t.projectRoot,t.destinationFile,f,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||Ht,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:A?null:R,forceRelative:Ht,tokenContext:g,originalToken:p});return ao?`${ao}${d}${l}`:n}),missing:[...e]}}var A_=u(()=>{ee();ni();zN();XN();tF();nF();s(Rd,"rewriteFileLinks");});function iF(t,e){let r=[t.normalize(e)];if(!existsSync(e))return r;try{let o=[realpathSync(e),realpathSync.native(e)];for(let n of o){let i=t.normalize(n);r.includes(i)||r.push(i);}}catch{}return r}async function U(t,e,r="project"){let o=et(e),n=new Map,i=Array.from(new Set([t,...kt]));for(let l of i){let m=await FN(l,e,r);for(let[p,d]of m.entries())n.set(p,d);}let a=new Map;for(let[l,m]of n.entries()){let p=o.normalize(o.join(e,m));for(let d of iF(o,o.join(e,l)))a.set(d,p);}let c=new Set;for(let l of new Set(n.values())){let m=o.normalize(o.join(e,l));c.add(m);for(let p of iF(o,m))c.add(o.normalize(p));}return (l,m,p)=>Rd({content:l,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:s(d=>a.get(d)??d,"translatePath"),pathExists:s(d=>{let g=o.normalize(d);return a.has(d)||a.has(g)||existsSync(d)||c.has(g)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:s(d=>{try{return statSync(d).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var mt=u(()=>{ee();vN();A_();mo();s(iF,"pathVariants");s(U,"createImportReferenceNormalizer");});function cF(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!po({...m,type:p}))continue;let d=p==="prompt"?le(m)||Kt(m):Kt(m)||le(m),g={matcher:c,type:p,command:d};typeof m.timeout=="number"&&(g.timeout=m.timeout),n.push(g);}}n.length>0&&(e[r]=n);}return e}async function lF(t,e){let r=join(t,Ln),o=await y(r);if(o===null)return false;let n;try{n=JSON.parse(o);}catch{return false}if(!n||typeof n!="object"||Array.isArray(n))return false;let i=cF(n);if(Object.keys(i).length===0)return false;let a=stringify(i),c=join(t,ki);return await L(dirname(c)),await I(c,a),e.push({fromTool:"claude-code",fromPath:r,toPath:ki,feature:"hooks"}),true}async function mF(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(Ln)),o=join(t,Ml),n=await y(o);if(!n)return;let i;try{i=JSON.parse(n);}catch{return}if(!e.some(m=>m.feature==="mcp")&&i.mcpServers&&typeof i.mcpServers=="object"){let m=i.mcpServers;await $t(t,Kl,m),e.push({fromTool:"claude-code",fromPath:o,toPath:Kl,feature:"mcp"});}let c=i.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let m=c,p=Array.isArray(m.allow)?m.allow.filter(f=>typeof f=="string"):[],d=Array.isArray(m.deny)?m.deny.filter(f=>typeof f=="string"):[],g=Array.isArray(m.ask)?m.ask.filter(f=>typeof f=="string"):[];if(p.length>0||d.length>0||g.length>0){let f=stringify({allow:p,deny:d,ask:g}),h=join(t,gf);await L(dirname(h)),await I(h,f),e.push({fromTool:"claude-code",fromPath:o,toPath:gf,feature:"permissions"});}}let l=i.hooks;if(!r&&l&&typeof l=="object"&&!Array.isArray(l)){let m=cF(l);if(Object.keys(m).length>0){let p=stringify(m),d=join(t,ki);await L(dirname(d)),await I(d,p),e.push({fromTool:"claude-code",fromPath:o,toPath:ki,feature:"hooks"});}}}var pF=u(()=>{br();T();Nr();An();s(cF,"claudeHooksToCanonical");s(lF,"importClaudeHooksJson");s(mF,"importSettings");});async function dF(t,e,r){let o=join(t,Gl),n=join(t,df),a=(await N(o)).filter(c=>c.endsWith("SKILL.md"));for(let c of a){let l=dirname(c),m=basename(l),p=join(n,m),d=await N(l);for(let g of d){let f=await y(g);if(f===null)continue;let h=relative(l,g),O=join(p,h);await L(dirname(O));let R=r(f,g,O),E=h==="SKILL.md"?w(R):null;await I(O,h==="SKILL.md"?await uo(O,E?.frontmatter??{},E?.body??""):R);let A=`${df}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:g,toPath:A,feature:"skills"});}}}var gF=u(()=>{T();M();lt();An();s(dF,"importClaudeSkills");});async function ru(t,e={}){let r=e.scope??"project",o=[],n=await U("claude-code",t,r);return o.push(...await z(eu,t,r,{normalize:n})),await dF(t,o,n),await lF(t,o),await mF(t,o),o}var mh=u(()=>{mt();Ct();pF();gF();lh();s(ru,"importFromClaudeCode");});async function wm(t,e){let r=rV[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}var rV,T_=u(()=>{mh();oy();$h();Ly();Ph();p_();hh();xh();Ty();My();Fy();rV={"claude-code":ru,cursor:bu,copilot:_u,"gemini-cli":Uu,"codex-cli":lu,windsurf:ud,cline:nu,continue:pu,junie:Hu,kiro:Zu,"kilo-code":Yu};s(wm,"importNativeToCanonical");});async function Ra(t){if(!await j(t))return false;if(await j(join(t,P_)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await j(join(t,r.name,P_)))return !0}catch{return false}return false}async function Tm(t){if(!await j(t))return [];if(await j(join(t,P_))){let e=await gS(t);return e?[e]:[]}return Ga(t)}var P_,Cd=u(()=>{T();pp();P_="SKILL.md";s(Ra,"isSkillPackLayout");s(Tm,"loadSkillsAtExtendPath");});function iV(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function aV(t){return t.rules.length===0&&t.commands.length===0&&t.agents.length===0&&t.skills.length===0&&t.mcp===null&&t.permissions===null&&t.hooks===null&&t.ignore.length===0}async function Ed(t){if(!await j(t))throw new Error(`Path does not exist: ${t}`);let e=await stat(t);if(e.isDirectory())return {sliceRoot:t};if(!e.isFile()||!t.toLowerCase().endsWith(".md"))throw new Error(`Install path must be a directory or a .md file inside rules/, commands/, or agents/: ${t}`);let r=dirname(t),o=basename(r),i=basename(t).replace(/\.md$/i,"");if(o==="rules")return {sliceRoot:r,implicitPick:{rules:[i]}};if(o==="commands")return {sliceRoot:r,implicitPick:{commands:[i]}};if(o==="agents")return {sliceRoot:r,implicitPick:{agents:[i]}};throw new Error(`Single-file install only supports .md files under rules/, commands/, or agents/. Got: ${t}`)}async function cV(t){if(basename(t)==="rules")return di(t);let r=join(t,"rules");return await j(r)?di(r):[]}async function lV(t){if(basename(t)==="commands")return gi(t);let r=join(t,"commands");return await j(r)?gi(r):[]}async function mV(t){if(basename(t)==="agents")return hi(t);let r=join(t,"agents");return await j(r)?hi(r):[]}async function pV(t){if(await Ra(t))return Tm(t);let e=join(t,"skills");return await Ra(e)?Tm(e):[]}async function Od(t){let e=join(t,".agentsmesh");if(await j(e))return Ae(t);let r=iV();if(r.rules=await cV(t),r.commands=await lV(t),r.agents=await mV(t),r.skills=await pV(t),aV(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}var x_=u(()=>{T();lp();yi();cp();ap();Cd();s(iV,"emptyCanonical");s(aV,"isCanonicalSliceEmpty");s(Ed,"normalizeSlicePath");s(cV,"parseRulesAt");s(lV,"parseCommandsAt");s(mV,"parseAgentsAt");s(pV,"loadSkillsForPartialSlice");s(Od,"loadCanonicalSliceAtPath");});function uV(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function fF(t){let e=t.resolvedPath;if(!t.path){let n=join(e,".agentsmesh");if(!await j(n)){if(await Ra(e)){let a=await Tm(e);return {...uV(),skills:a}}let i=t.target??await fp(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
142
|
+
Expected one of: .agentsmesh/, ${IS.join(", ")}.`);_.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await wm(e,i);}return Ae(e)}let r=join(e,t.path);if(!await j(r))throw new Error(`Extend "${t.name}": path does not exist: ${r}`);if(t.target){let n=join(e,".agentsmesh");return await j(n)||(_.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await wm(e,t.target)),Ae(e)}let{sliceRoot:o}=await Ed(r);try{return await Od(o)}catch(n){let i=n instanceof Error?n.message:String(n),a=new Error(`Extend "${t.name}": ${i}`);throw n instanceof Error&&(a.cause=n),a}}var hF=u(()=>{Mg();T();ft();yi();T_();Cd();x_();s(uV,"emptyCanonical");s(fF,"loadCanonicalForExtend");});function Ld(t,e,r,o){if(!r)return t;let n={...t};if(r.skills?.length&&e.includes("skills")){let i=new Set(r.skills),a=n.skills;n={...n,skills:a.filter(c=>i.has(c.name))};for(let c of r.skills)a.some(l=>l.name===c)||_.warn(`[agentsmesh] pick name "${c}" not found in skills from extend "${o}".`);}if(r.commands?.length&&e.includes("commands")){let i=new Set(r.commands),a=n.commands;n={...n,commands:a.filter(c=>i.has(c.name))};for(let c of r.commands)a.some(l=>l.name===c)||_.warn(`[agentsmesh] pick name "${c}" not found in commands from extend "${o}".`);}if(r.agents?.length&&e.includes("agents")){let i=new Set(r.agents),a=n.agents;n={...n,agents:a.filter(c=>i.has(c.name))};for(let c of r.agents)a.some(l=>l.name===c)||_.warn(`[agentsmesh] pick name "${c}" not found in agents from extend "${o}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=n.rules,c=s(l=>basename(l).replace(/\.md$/i,""),"stem");n={...n,rules:a.filter(l=>i.has(c(l.source)))};for(let l of r.rules)a.some(m=>c(m.source)===l)||_.warn(`[agentsmesh] pick name "${l}" not found in rules from extend "${o}".`);}return n}var N_=u(()=>{ft();s(Ld,"applyExtendPick");});var fV,Xc,Ad=u(()=>{fV=["rules","commands","agents","skills"],Xc=z$1.enum(fV);});var hV,yF,_F=u(()=>{pn();Ad();hV=z$1.enum(["github","gitlab","git","local"]),yF=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:hV,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(Da).min(1),pick:gl.optional(),target:ze.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:Xc.optional(),content_hash:z$1.string()});});function IF(t){let e=ui(t);return e?e.kind==="github"?`github:${e.org}/${e.repo}`:e.kind==="gitlab"?`gitlab:${e.namespace}/${e.project}`:`git+${e.url}`:t.trim()}function _V(t,e){return e?t.length===e.length&&[...t].sort().every((r,o)=>r===[...e].sort()[o]):true}async function kd(t){let e=join(t,"pack.yaml"),r=await y(e);if(r===null)return null;try{let o=parse(r);return yF.parse(o)}catch{return null}}async function SF(t,e,r){if(!await j(t))return null;let o=IF(e),n;try{n=await readdir(t,{withFileTypes:!0});}catch{return null}for(let i of n){if(!i.isDirectory())continue;let a=join(t,i.name),c=await kd(a);if(c&&IF(c.source)===o&&c.target===r.target&&c.as===r.as&&_V(c.features,r.features))return {meta:c,packDir:a,name:c.name}}return null}async function wd(t){if(!await j(t))return [];let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let o of e){if(!o.isDirectory())continue;let n=join(t,o.name),i=await kd(n);i&&r.push({meta:i,packDir:n,name:i.name});}return r}var Td=u(()=>{T();_F();yl();s(IF,"sourceIdentity");s(_V,"sameFeatures");s(kd,"readPackMetadata");s(SF,"findExistingPack");s(wd,"listPacks");});function CF(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function IV(t){let[e,r,o,n,i,a,c,l]=await Promise.all([di(join(t,"rules")),gi(join(t,"commands")),hi(join(t,"agents")),Ga(join(t,"skills")),Tr(join(t,"mcp.json")),up(join(t,"permissions.yaml")),dp(join(t,"hooks.yaml")),gp(join(t,"ignore"))]);return {...CF(),rules:e,commands:r,agents:o,skills:n,mcp:i,permissions:a,hooks:c,ignore:l}}async function EF(t){let e=join(t,"packs"),r=await wd(e),o=CF();for(let{meta:n,packDir:i}of r){let a=await IV(i),c=v_(a,n.features),l=Ld(c,n.features,n.pick,n.name);o=Ma(o,l);}return o}var OF=u(()=>{ap();cp();lp();pp();Rl();xg();Ng();Fg();Gg();sn();N_();Td();s(CF,"emptyCanonical");s(IV,"loadPackCanonical");s(EF,"loadPacksCanonical");});function v_(t,e){if(e.length===0)return LF();let r=new Set(e.flatMap(o=>SV[o]??[]));return {rules:r.has("rules")?t.rules:[],commands:r.has("commands")?t.commands:[],agents:r.has("agents")?t.agents:[],skills:r.has("skills")?t.skills:[],mcp:r.has("mcp")?t.mcp:null,permissions:r.has("permissions")?t.permissions:null,hooks:r.has("hooks")?t.hooks:null,ignore:r.has("ignore")?t.ignore:[]}}function LF(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function he(t,e,r={},o=join(e,".agentsmesh")){let n=await va(t,e,{refreshCache:r.refreshRemoteCache===true}),i=LF();for(let l of n){let m=await fF(l),p=v_(m,l.features),d=Ld(p,l.features,l.pick,l.name);i=Ma(i,d);}let a=await EF(o);i=Ma(i,a);let c=await Ae(o);return i=Ma(i,c),{canonical:i,resolvedExtends:n}}var SV,sn=u(()=>{np();yi();Gg();hF();N_();OF();SV={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(v_,"filterCanonicalByFeatures");s(LF,"emptyCanonical");s(he,"loadCanonicalWithExtends");});function mJ(t,e){let r=join(e,"node_modules",t),o=join(r,"package.json");if(!existsSync(o))throw new Error(`Cannot find package '${t}' in ${join(e,"node_modules")}`);let n=JSON.parse(readFileSync(o,"utf-8")),i=(typeof n.exports=="string"?n.exports:null)??(typeof n.main=="string"?n.main:null)??"index.js",a=resolve(r,i);if(!existsSync(a))throw new Error(`Package '${t}' entry '${i}' does not exist at ${a}`);return a}function pJ(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}async function uJ(t,e){let{source:r}=t,o;if(pJ(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);o=pathToFileURL(a).href;}else {let i=mJ(r,e);o=pathToFileURL(i).href;}return await import(o)}function dJ(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function Md(t,e){let r;try{r=await uJ(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let o=dJ(r),n=[];for(let i of o)try{let a=fd(i);hd(a),n.push(a);}catch(a){throw new Error(`Plugin '${t.source}' exported an invalid descriptor: ${a instanceof Error?a.message:String(a)}`,{cause:a})}return {entry:t,descriptors:n}}async function ev(t,e){let r=[],o=process.env.AGENTSMESH_STRICT_PLUGINS==="1"||process.env.AGENTSMESH_STRICT_PLUGINS==="true",i=(await Promise.all(t.map(async a=>{try{let c=await Md(a,e);return r.push(c),null}catch(c){let l=`Plugin '${a.source}' failed to load: ${c instanceof Error?c.message:String(c)}`;return a.strict===true||o?new Error(l):(_.warn(l),null)}}))).filter(a=>a!==null);if(i.length>0){let a=i.map(c=>` - ${c.message}`).join(`
|
|
143
143
|
`);throw new Error(`agentsmesh: ${i.length} plugin(s) failed strict load:
|
|
144
|
-
${a}`)}return r}var
|
|
145
|
-
`)}var yv=
|
|
144
|
+
${a}`)}return r}var H_=u(()=>{y_();je();ft();s(mJ,"resolveNpmSpecifier");s(pJ,"isLocalSource");s(uJ,"importPluginModule");s(dJ,"extractDescriptors");s(Md,"loadPlugin");s(ev,"loadAllPlugins");});async function ce(t,e){t.plugins.length!==0&&await ev(t.plugins,e);}var ms=u(()=>{H_();s(ce,"bootstrapPlugins");});function J_(t,e,r="project"){let o=[],n=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,c;switch(i){case "rules":c=e.rules.length,a="rules";break;case "commands":c=e.commands.length,a=c>0?`commands (${c})`:"commands";break;case "agents":c=e.agents.length,a=c>0?`agents (${c})`:"agents";break;case "skills":c=e.skills.length,a=c>0?`skills (${c})`:"skills";break;case "mcp":c=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=c>0?`mcp (${c} servers)`:"mcp";break;case "hooks":c=vJ(e.hooks),a=c>0?`hooks (${c})`:"hooks";break;case "ignore":c=e.ignore.length>0?1:0,a="ignore";break;case "permissions":c=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let l={};for(let m of n)l[m]=gd(m,i,t,r);if(o.push({feature:a,count:c,support:l}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let d of n)p[d]=gd(d,"additionalRules",t,r);o.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return o}function vJ(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var pv=u(()=>{xt();s(J_,"buildCompatibilityMatrix");s(vJ,"countHooks");});function uv(t){return GJ[t]??t}var GJ,dv=u(()=>{GJ={"claude-code":"Claude"};s(uv,"matrixColumnLabel");});function gv(t){return Object.fromEntries(MJ.map(e=>[e,Object.fromEntries(kt.map(r=>{let n=ti(r,t)?.[e];return [r,n??{level:"none"}]}))]))}function $J(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function jJ(t,e){return $J()?e:`${t}${e}${Nm.reset}`}function hv(t){let e=Y_[t];return jJ(UJ[t],e)}var MJ,fv,Y_,Nm,UJ,X_=u(()=>{mo();xt();MJ=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(gv,"buildSupportMatrix");fv=gv("project"),gv("global"),Y_={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},Nm={green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",dim:"\x1B[2m",cyan:"\x1B[36m",magenta:"\x1B[35m",bold:"\x1B[1m",reset:"\x1B[0m"};s($J,"noColor");s(jJ,"colorize");UJ={native:Nm.green,embedded:Nm.blue,partial:Nm.yellow,none:Nm.dim};s(hv,"coloredSymbol");});function Z_(t,e){let r=process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!=="",o={cyan:"\x1B[36m",magenta:"\x1B[35m",bold:"\x1B[1m",dim:"\x1B[2m",green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",reset:"\x1B[0m"},n=s((Y,q)=>r?q:`${Y}${q}${o.reset}`,"c"),i=s(Y=>Y.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((Y,q)=>{let Ft=i(Y),Gt=Math.max(0,q-Ft);return Y+" ".repeat(Gt)},"padWithColor"),c=Math.max(12,...e.map(Y=>Y.length)),l=e.map(Y=>uv(Y)),m=Math.max(8,c),p=Math.max(12,...t.map(Y=>Y.feature.length)),d=s(Y=>n(o.dim,"\u250C"+Y.map(q=>"\u2500".repeat(q)).join("\u252C")+"\u2510"),"border"),g=s(Y=>n(o.dim,"\u251C"+Y.map(q=>"\u2500".repeat(q)).join("\u253C")+"\u2524"),"sep"),f=s(Y=>n(o.dim,"\u2514"+Y.map(q=>"\u2500".repeat(q)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],O=d(h),R=[a(n(o.bold+o.cyan,"Feature"),p),...l.map(Y=>a(n(o.bold+o.magenta,Y),m))],E=n(o.dim,"\u2502")+R.join(n(o.dim,"\u2502"))+n(o.dim,"\u2502"),A=g(h),F=t.map(Y=>{let q=[a(n(o.cyan,Y.feature),p)];for(let Ft of e){let Gt=Y.support[Ft]??"none",io=r?Y_[Gt]:hv(Gt);q.push(a(` ${io} `,m));}return n(o.dim,"\u2502")+q.join(n(o.dim,"\u2502"))+n(o.dim,"\u2502")}),v=f(h),G=[O,E,A,...F,v];G.push("");let J=[n(o.green,"\u2713")+" = native",n(o.blue,"\u25C6")+" = embedded",n(o.yellow,"\u25D0")+" = partial",n(o.dim,"\u2013")+" = not supported"];return G.push(n(o.bold,"Legend: ")+J.join(" ")),G.join(`
|
|
145
|
+
`)}var yv=u(()=>{dv();X_();s(Z_,"formatMatrix");});function q_(t){let e=[];if(t.rules.length>0&&e.push(`rules: ${t.rules.map(r=>basename(r.source)).join(", ")}`),t.commands.length>0&&e.push(`commands: ${t.commands.map(r=>basename(r.source)).join(", ")}`),t.agents.length>0&&e.push(`agents: ${t.agents.map(r=>basename(r.source)).join(", ")}`),t.skills.length>0&&e.push(`skills: ${t.skills.map(r=>r.name).join(", ")}`),t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&e.push(`mcp: ${Object.keys(t.mcp.mcpServers).join(", ")}`),t.hooks){let r=Object.values(t.hooks).reduce((o,n)=>o+(Array.isArray(n)?n.length:0),0);r>0&&e.push(`hooks: ${r} entries in hooks.yaml`);}return t.ignore.length>0&&e.push("ignore: .agentsmesh/ignore"),t.permissions&&t.permissions.allow.length+t.permissions.deny.length>0&&e.push("permissions: .agentsmesh/permissions.yaml"),e.length===0?"":`
|
|
146
146
|
Per-file details:
|
|
147
147
|
`+e.join(`
|
|
148
148
|
`)+`
|
|
149
|
-
`}var _v=
|
|
149
|
+
`}var _v=u(()=>{s(q_,"formatVerboseDetails");});var tI=u(()=>{pv();yv();_v();});var eI={};ug(eI,{runMatrix:()=>Fm});async function Fm(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(g=>g.trim()).filter(Boolean):void 0,{config:a,context:c}=await Tt(r,o);await ce(a,r);let{canonical:l}=await he(a,c.configDir,{},c.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=J_(a,l,o),d=q_(l);return {exitCode:0,data:{targets:m,features:p.map(g=>({name:g.feature,support:g.support}))},verboseDetails:d||void 0}}var vm=u(()=>{Oe();sn();tI();ms();s(Fm,"runMatrix");});var rI={};ug(rI,{renderMatrix:()=>Gm});function Gm(t,e){if(t.data.features.length===0){_.info("No features enabled. Enable features in agentsmesh.yaml.");return}let r=t.data.features.map(n=>({feature:n.name,count:0,support:n.support})),o=Z_(r,t.data.targets);process.stdout.write(o),process.stdout.write(`
|
|
150
150
|
`),e?.verbose&&t.verboseDetails&&(process.stdout.write(t.verboseDetails),process.stdout.write(`
|
|
151
|
-
`));}var Mm=
|
|
152
|
-
`)}s(
|
|
151
|
+
`));}var Mm=u(()=>{ft();tI();s(Gm,"renderMatrix");});function gR(t){let e=Object.keys(t);return {async route(r,o,n){let i=t[r];if(i){await i(o,n);return}throw new Error(`Unknown command "${r}". Available: ${e.join(", ")}`)},commands:s(()=>[...e],"commands")}}s(gR,"createRouter");ft();var _R=[{name:"--help",description:"Show this help output and exit"},{name:"--version",description:"Print CLI version and exit"},{name:"--verbose",description:"Show full error details on failure"},{name:"--json",description:"Output machine-readable JSON (single envelope to stdout)"}],IR=[{name:"init",usage:"agentsmesh init [flags]",description:"Create agentsmesh.yaml, agentsmesh.local.yaml, and canonical .agentsmesh scaffold",flags:[{name:"--global",description:"Initialize canonical home config under ~/.agentsmesh/ (global targets include claude-code, antigravity, codex-cli, cursor, gemini-cli, kilo-code)"},{name:"--yes",description:"Auto-import detected tool configs, then add example scaffold only under empty canonical paths"}]},{name:"generate",usage:"agentsmesh generate [flags]",description:"Generate target files from canonical sources",flags:[{name:"--global",description:"Generate user-level config from ~/.agentsmesh/ (e.g. claude-code, antigravity, codex-cli, gemini-cli, kilo-code; Cursor writes ~/.cursor/rules, ~/.cursor/AGENTS.md, hooks, ignore, MCP, skills, agents, commands; legacy ~/.agentsmesh-exports/cursor/user-rules.md is import-only)"},{name:"--targets <csv>",description:"Limit generation to target IDs (comma-separated)"},{name:"--check",description:"Check drift only; exit non-zero when out of sync"},{name:"--dry-run",description:"Preview file changes without writing outputs"},{name:"--force",description:"Bypass lock-strategy blocked feature violations"},{name:"--refresh-cache",description:"Refresh remote extends cache before loading"},{name:"--no-cache",description:"Alias for --refresh-cache"}]},{name:"import",usage:"agentsmesh import --from <target> [flags]",description:"Import existing tool config into canonical .agentsmesh files",flags:[{name:"--from <target>",description:"Source tool ID to import from (required)"},{name:"--global",description:"Import from user-level paths into ~/.agentsmesh/ (claude-code, antigravity, codex-cli, gemini-cli, kilo-code; cursor reads ~/.cursor/{rules,AGENTS.md,mcp.json,hooks.json,cursorignore,skills,agents,commands} and legacy ~/.agentsmesh-exports/cursor/user-rules.md)"}]},{name:"convert",usage:"agentsmesh convert --from <target> --to <target> [flags]",description:"Convert configuration directly from one tool to another",flags:[{name:"--from <target>",description:"Source tool ID to convert from (required)"},{name:"--to <target>",description:"Destination tool ID to convert to (required)"},{name:"--global",description:"Convert user-level config (use home directory paths)"},{name:"--dry-run",description:"Preview conversion without writing files"}]},{name:"install",usage:"agentsmesh install <source> [flags]",description:"Install canonical resources from local/remote sources",flags:[{name:"<source>",description:"GitHub/GitLab/tree/blob URL, git+ URL, SSH, or local path"},{name:"--sync",description:"Reinstall missing packs recorded in .agentsmesh/installs.yaml"},{name:"--path <dir>",description:"Subdirectory inside source repo when not embedded in URL"},{name:"--target <id>",description:"Native format used for import-at-root discovery (same as extends.target)"},{name:"--as <kind>",description:"Manual collection mode: rules, commands, agents, or skills"},{name:"--name <id>",description:"Override generated install entry/pack name"},{name:"--extends",description:"Write install as extends entry instead of materialized pack"},{name:"--dry-run",description:"Preview only (no YAML write, no pack write, no generate)"},{name:"--global",description:"Install into ~/.agentsmesh/ and regenerate user-level config"},{name:"--force",description:"Non-interactive mode; include invalid resources and skip selection prompts (implied by --json)"}]},{name:"diff",usage:"agentsmesh diff [flags]",description:"Show patch-style output for what generate would change",flags:[{name:"--global",description:"Diff against outputs generated from ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit diff to target IDs (comma-separated)"}]},{name:"lint",usage:"agentsmesh lint [flags]",description:"Validate canonical files against target constraints",flags:[{name:"--global",description:"Lint canonical home config under ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit linting to target IDs (comma-separated)"}]},{name:"watch",usage:"agentsmesh watch [flags]",description:"Watch canonical files and regenerate on change",flags:[{name:"--global",description:"Watch ~/.agentsmesh/ and regenerate user-level config"},{name:"--targets <csv>",description:"Limit watched generate/matrix output to target IDs"}]},{name:"check",usage:"agentsmesh check",description:"Verify canonical files still match .agentsmesh/.lock",flags:[{name:"--global",description:"Check ~/.agentsmesh/.lock"}]},{name:"merge",usage:"agentsmesh merge",description:"Resolve .agentsmesh/.lock merge conflicts from current canonical state",flags:[{name:"--global",description:"Resolve ~/.agentsmesh/.lock conflicts"}]},{name:"matrix",usage:"agentsmesh matrix [flags]",description:"Print compatibility matrix for enabled features and targets",flags:[{name:"--global",description:"Show matrix for canonical home config under ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit matrix columns to target IDs"},{name:"--verbose",description:"Include expanded feature details in matrix output"}]},{name:"target",usage:"agentsmesh target scaffold <id> [--name <displayName>] [--force]",description:"Generate a new target skeleton (files, tests, fixture) under src/targets/<id>/.",flags:[{name:"--name <displayName>",description:"Human-readable name (defaults to id)"},{name:"--force",description:"Overwrite existing files"}]},{name:"plugin",usage:"agentsmesh plugin <add|list|remove|info> [args] [flags]",description:"Manage plugin-provided targets (npm packages exporting a TargetDescriptor).",flags:[{name:"--version <v>",description:"Pin plugin version (add)"},{name:"--id <id>",description:"Override derived plugin id (add)"}]},{name:"mcp",usage:"agentsmesh mcp",description:"Start the agentsmesh MCP server (stdio)",flags:[]}];function RR(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
|
|
152
|
+
`)}s(RR,"formatFlags");function SR(){let t=IR.map(e=>`- ${e.name.padEnd(8)} ${e.description}
|
|
153
153
|
Usage: ${e.usage}
|
|
154
|
-
${
|
|
154
|
+
${RR(e.flags)}`).join(`
|
|
155
155
|
|
|
156
|
-
`);
|
|
156
|
+
`);_.info(`agentsmesh <command> [flags]
|
|
157
157
|
|
|
158
158
|
Global flags:
|
|
159
|
-
${
|
|
159
|
+
${RR(_R)}
|
|
160
160
|
|
|
161
161
|
Commands:
|
|
162
162
|
${t}
|
|
163
163
|
|
|
164
|
-
Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(
|
|
165
|
-
`);}s(
|
|
166
|
-
`);}s(
|
|
167
|
-
`):
|
|
164
|
+
Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(SR,"printHelp");var Qm;function l$(){try{let t=createRequire(import.meta.url),e=dirname(fileURLToPath(import.meta.url)),r=e.endsWith("dist")?join(e,"..","package.json"):join(e,"..","..","package.json");return t(r).version}catch{return}}s(l$,"readPackageVersion");function m$(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(m$,"getVersionFallback");function ul(){return Qm||(Qm=l$()??m$(),Qm)}s(ul,"getVersion");function ER(){process.stdout.write(`agentsmesh v${ul()}
|
|
165
|
+
`);}s(ER,"printVersion");ft();function ba(t,e){let r={success:e.success,command:t};e.success?r.data=e.data:(r.error=e.error,e.data!==void 0&&(r.data=e.data)),process.stdout.write(JSON.stringify(r)+`
|
|
166
|
+
`);}s(ba,"emitJson");var co=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function OR(t,e){let r=t instanceof co?2:1;if(e?.json)return ba(e.command??"unknown",{success:false,error:t.message}),process.exit(r);e?.verbose&&t.stack?process.stderr.write(t.stack+`
|
|
167
|
+
`):_.error(t.message),process.exit(r);}s(OR,"handleError");ft();function Ee(t,e,r,o){if(r.json===true){let n=e.exitCode===0;ba(t,n?{success:true,data:e.data}:{success:false,error:`Command '${t}' failed`,data:e.data}),process.exit(e.exitCode);return}o(),e.exitCode!==0&&process.exit(e.exitCode);}s(Ee,"handleResult");Oe();sn();T();function xm(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(xm,"hashContent");async function bd(t){try{let e=await readFile(t,"utf8");return xm(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(bd,"hashFile");Td();var M_=".lock",kV=[t=>t.startsWith("rules/")&&t.endsWith(".md"),t=>t.startsWith("commands/")&&t.endsWith(".md"),t=>t.startsWith("agents/")&&t.endsWith(".md"),t=>t.match(/^skills\/[^/]+\/.+$/)!==null,t=>t==="mcp.json",t=>t==="permissions.yaml",t=>t==="hooks.yaml",t=>t==="ignore"];function wV(t){return t.startsWith("packs/")?false:kV.some(e=>e(t))}s(wV,"isCanonical");var TV={rules:s(t=>t.startsWith("rules/"),"rules"),commands:s(t=>t.startsWith("commands/"),"commands"),agents:s(t=>t.startsWith("agents/"),"agents"),skills:s(t=>/^skills\/[^/]+\/.+$/.test(t),"skills"),mcp:s(t=>t==="mcp.json","mcp"),permissions:s(t=>t==="permissions.yaml","permissions"),hooks:s(t=>t==="hooks.yaml","hooks"),ignore:s(t=>t==="ignore","ignore")};async function Pd(t){let e=join(t,M_),r=await y(e);if(r===null)return null;try{let o=parse(r);return !o||typeof o!="object"?null:{generatedAt:String(o.generated_at??""),generatedBy:String(o.generated_by??""),libVersion:String(o.lib_version??""),checksums:o.checksums&&typeof o.checksums=="object"?o.checksums:{},extends:o.extends&&typeof o.extends=="object"?o.extends:{},packs:o.packs&&typeof o.packs=="object"?o.packs:{}}}catch{return null}}s(Pd,"readLock");async function xd(t,e){let r=join(t,M_),o={generated_at:e.generatedAt,generated_by:e.generatedBy,lib_version:e.libVersion,checksums:e.checksums,extends:e.extends,packs:e.packs},n=`# Auto-generated. DO NOT EDIT MANUALLY.
|
|
168
168
|
# Tracks the state of all config files for team conflict resolution.
|
|
169
169
|
|
|
170
|
-
`+stringify(o);await
|
|
171
|
-
`),a=xm(i),c=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${c}`;}return e}s(
|
|
170
|
+
`+stringify(o);await I(r,n);}s(xd,"writeLock");async function ls(t){if(!await j(t))return {};let e=await N(t),r={};for(let o of e){let n=relative(t,o).replace(/\\/g,"/");if(n===M_||!wV(n))continue;let i=await bd(o);i!==null&&(r[n]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(ls,"buildChecksums");function Dd(t,e,r){if(r.length===0)return [];let o=r.map(a=>TV[a]).filter(a=>a!==void 0);if(o.length===0)return [];let n=new Set([...Object.keys(t),...Object.keys(e)]),i=[];for(let a of n)o.some(c=>c(a))&&t[a]!==e[a]&&i.push(a);return i}s(Dd,"detectLockedFeatureViolations");async function Nd(t){let e=await wd(t),r={};for(let{meta:o}of e)r[o.name]=o.content_hash;return r}s(Nd,"buildPackChecksums");async function Zc(t){let e={};for(let r of t){if(r.version!==void 0){e[r.name]=r.version;continue}let o=join(r.resolvedPath,".agentsmesh"),n=await ls(o),i=Object.keys(n).sort().map(l=>`${l}:${n[l]}`).join(`
|
|
171
|
+
`),a=xm(i),c=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${c}`;}return e}s(Zc,"buildExtendChecksums");xt();je();function Qc(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Qc,"getAdditionalRootDecorationPaths");function AF(t,e){for(let r of t?.outputFamilies??[])if(r.pathPrefix!==void 0&&e.startsWith(r.pathPrefix)||r.explicitPaths?.includes(e))return r.id;return "default"}s(AF,"resolveRewriteFamilyId");ee();A_();function bV(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(bV,"addDirectoryMapping");function kF(t,e,r){let o=posix.dirname(e),n=posix.dirname(r);for(;o!==".agentsmesh/skills"&&o!==".";)bV(t,o,n),o=posix.dirname(o),n=posix.dirname(n);}s(kF,"addSkillDirectoryMappings");xt();function wF(t,e,r="project"){let o=vt(t,r);if(!o)return null;if(e.root)return o.rootInstructionPath??null;if(e.targets.length>0&&!e.targets.includes(t))return null;let n=posix.basename(e.source.replace(/\\/g,"/"),".md");return o.paths.rulePath(n,e)}s(wF,"ruleTargetPath");function TF(t,e,r,o="project"){let n=vt(t,o);return n?n.paths.commandPath(e,r):null}s(TF,"commandTargetPath");function bF(t,e,r,o="project"){let n=vt(t,o);return n?n.paths.agentPath(e,r):null}s(bF,"agentTargetPath");ae();Wt();fe();xt();function DV(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(DV,"addDirectoryMapping");function $_(t,e,r,o="project"){let n=new Map;for(let a of e.rules){let c=wF(t,a,o);c&&n.set(`.agentsmesh/rules/${basename(a.source)}`,c);}for(let a of e.commands){let c=TF(t,a.name,r,o);c&&n.set(`.agentsmesh/commands/${a.name}.md`,c);}for(let a of e.agents){let c=bF(t,a.name,r,o);c&&n.set(`.agentsmesh/agents/${a.name}.md`,c);}let i=Om(t,o);if(!i)return n;for(let a of e.skills){DV(n,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),n.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let c of a.supportingFiles){let l=c.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${l}`,p=`${i}/${a.name}/${l}`;n.set(m,p),kF(n,m,p);}}return n}s($_,"buildReferenceMap");ee();ee();xt();function xF(t,e,r,o){let n=o.normalize(e),i=o.normalize(r);t.set(n,i),t.set(`${n}/`,`${i}/`);}s(xF,"addPackAbsoluteDirMapping");function NV(t){let e=new Set;for(let{relativePath:r}of t){let o=r.replace(/\\/g,"/"),n=posix.dirname(o);for(;n!=="."&&n.length>0;){e.add(n);let i=posix.dirname(n);if(i===n)break;n=i;}}return [...e]}s(NV,"skillSupportingDirPrefixes");function DF(t,e,r,o,n){let i=Om(e,n);if(!i)return;let a=et(o),c=a.join(o,".agentsmesh","packs");for(let l of r.skills){let m=a.dirname(l.source);if(!m.startsWith(c))continue;let p=a.normalize(a.join(o,i,l.name));xF(t,m,p,a),t.set(a.normalize(l.source),a.normalize(a.join(p,"SKILL.md")));for(let d of l.supportingFiles){let g=a.normalize(a.join(p,d.relativePath));t.set(a.normalize(d.absolutePath),g);}for(let d of NV(l.supportingFiles))xF(t,a.join(m,d),a.join(p,d),a);}}s(DF,"addPackSkillArtifactMappings");ee();function FV(t){return `.agentsmesh/rules/${basename(t.source)}`}s(FV,"canonicalRulePath");function vV(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(vV,"copilotInstructionsPath");function FF(t,e,r,o,n){if(t!=="copilot"||!o?.startsWith(".github/instructions/"))return;let i=et(r);for(let a of n.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,FV(a))),i.normalize(i.join(r,vV(a))));}s(FF,"applyCopilotInstructionArtifactRefs");xt();function j_(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(j_,"pushUnique");function vF(t,e,r,o){let n=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);j_(n,i);let a=vt(t,o);if(e.root)for(let c of Qc(a))j_(n,c);for(let c of a?.extraRuleOutputPaths?.(e,{refs:r,scope:o})??[])j_(n,c);return n}s(vF,"extraRuleOutputPaths");xt();function GF(t,e,r,o,n,i){let a=vt(t,e);if(!a?.mirrorGlobalPath)return;let c=a.mirrorGlobalPath(r,i??[]),l=c===null?[]:Array.isArray(c)?c:[c];for(let m of l)m!==r&&n.set(m,o);}s(GF,"addSkillMirrorSourceEntry");function MV(t){return `.agentsmesh/commands/${t.name}.md`}s(MV,"canonicalCommandPath");function $V(t){return `.agentsmesh/agents/${t.name}.md`}s($V,"canonicalAgentPath");function jV(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(jV,"canonicalSkillPath");function MF(t,e,r,o,n,i){let a=i?.scope??"project",c=et(o),l=new Map([...$_(t,e,r,a)].map(([m,p])=>[c.normalize(c.join(o,m)),c.normalize(c.join(o,p))]));return FF(t,l,o,n,e),DF(l,t,e,o,a),l}s(MF,"buildArtifactPathMap");function $F(t,e,r,o="project",n){let i=$_(t,e,r,o),a=new Map;for(let c of e.rules)for(let l of vF(t,c,i,o))a.set(l,c.source);for(let c of e.commands){let l=i.get(MV(c));l&&a.set(l,c.source);}for(let c of e.agents){let l=i.get($V(c));l&&a.set(l,c.source);}for(let c of e.skills){let l=i.get(jV(c));l&&(a.set(l,c.source),GF(t,o,l,c.source,a,n));for(let m of c.supportingFiles){let p=`.agentsmesh/skills/${c.name}/${m.relativePath.replace(/\\/g,"/")}`,d=i.get(p);d&&(a.set(d,m.absolutePath),GF(t,o,d,m.absolutePath,a,n));}}return a}s($F,"buildOutputSourceMap");xt();je();$g();function BV(t,e){if(!e)return null;for(let r of e){let o=ut(r);if(o?.sharedArtifacts){for(let[n,i]of Object.entries(o.sharedArtifacts))if(i==="owner"&&t.startsWith(n))return r}}return null}s(BV,"findSharedArtifactOwner");function jF(t,e,r){if(e==="global"){let o=BV(t.path,r);if(o)return o;let n=kS(t.path);if(n)return n}return t.target}s(jF,"artifactMapTargetForResult");function WV(t,e){return `${t}\0${(e??[]).join(",")}`}s(WV,"sourceMapCacheKey");function U_(t,e){let r=et(t),o=new Set;for(let n of e){let i=r.join(t,n.path);o.add(i);let a=r.dirname(i);for(;a.startsWith(t)&&!o.has(a)&&(o.add(a),a!==t);)a=r.dirname(a);}return o}s(U_,"collectPlannedPaths");function HV(t,e,r){let o=vt(t.target,e),n=AF(o,t.path);if(n!=="default")return `${t.target}:${n}`;let i=jF(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(HV,"artifactCacheKey");function UF(t,e,r,o,n="project",i,a){let c=U_(o,t),l=new Map,m=new Map;return t.map(p=>{if(a?.has(p.path))return p;let d=WV(p.target,i),f=(m.get(d)??(()=>{let A=$F(p.target,e,r,n,i);return m.set(d,A),A})()).get(p.path);if(!f)return p;let h=jF(p,n,i),O=HV(p,n,i),R=l.get(O)??(()=>{let A=MF(h,e,r,o,p.path,{scope:n});return l.set(O,A),A})(),E=Rd({content:p.content,projectRoot:o,sourceFile:f,destinationFile:et(o).join(o,p.path),translatePath:s(A=>R.get(A)??A,"translatePath"),pathExists:s(A=>c.has(A)||existsSync(A),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:n,pathIsDirectory:s(A=>{try{return statSync(A).isDirectory()}catch{return false}},"pathIsDirectory")});return E.content===p.content?p:{...p,content:E.content}})}s(UF,"rewriteGeneratedReferences");ee();ni();var VV=/!?\[[^\]]*\]\(([^)]+)\)/g,JV=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function YV(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(YV,"isMarkdownLikeOutput");function XV(t,e){return e.some(([r,o])=>t>=r&&t<o)}s(XV,"isOffsetInRanges");function ZV(t){let e=t.trim(),r=/^(.*?)\s+(["'])([\s\S]*?)\2\s*$/.exec(e);return r?.[1]!==void 0&&(e=r[1].trim()),e.startsWith("<")&&e.endsWith(">")&&(e=e.slice(1,-1).trim()),e}s(ZV,"parseMarkdownLinkDestination");function QV(t){let e=t.trim();return !e||e.startsWith("#")||/^https?:\/\//i.test(e)||/^mailto:/i.test(e)||/^data:/i.test(e)||/^javascript:/i.test(e)||/^ftp:/i.test(e)?true:/^[a-zA-Z]:[\\/]/.test(e)?false:!!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)}s(QV,"shouldSkipLocalValidation");function qV(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(qV,"pathExistsForGenerate");function tJ(t,e,r){let n=ZV(t).split("#")[0]??"",{candidate:i}=$a(n),a=i,c=Jc.exec(a);c&&(a=a.slice(0,c.index));let l;try{l=decodeURIComponent(a);}catch{l=a;}if(QV(l))return [];let m=Lm(l,e,r);if(m.length===0){let d=et(e),g=V(e,r);m=[V(e,d.join(d.dirname(g),l)),V(e,d.join(e,l))];}let p=[];for(let d of m)for(let g of Am(e,d)){let f=V(e,g);p.includes(f)||p.push(f);}return p}s(tJ,"resolveMarkdownLinkTargets");function eJ(t,e){let r=U_(e,t),o=[];for(let n of t){if(!YV(n.path))continue;let i=V(e,et(e).join(e,n.path)),a=Id(n.content),c=s((l,m)=>{if(XV(m,a))return;let p=tJ(l,e,i);p.length!==0&&(p.some(d=>qV(d,r))||o.push({generatePath:n.path,target:n.target,rawLink:l.trim(),checkedPaths:p}));},"visitDestination");for(let l of n.content.matchAll(VV)){let m=l[1];m!==void 0&&c(m,l.index??0);}for(let l of n.content.matchAll(JV)){let m=(l[1]??l[2]??"").trim();m&&c(m,l.index??0);}}return o}s(eJ,"findBrokenMarkdownLinks");function KF(t,e){let r=eJ(t,e);if(r.length===0)return;let o=r.map(n=>` ${n.generatePath} (${n.target}): "${n.rawLink}" \u2192 not found (tried: ${n.checkedPaths.join(", ")})`);throw new Error(`Generated markdown contains broken local links:
|
|
172
172
|
${o.join(`
|
|
173
173
|
`)}
|
|
174
|
-
Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(KF,"validateGeneratedMarkdownLinks");uo();var WF="AGENTS.md";function BF(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(BF,"statusRank");function oJ(t,e){return BF(e.status)<=BF(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(oJ,"mergeDuplicateMetadata");function Md(t){return t.trim()}s(Md,"trimmedContent");function nJ(t,e){if(!t.path.endsWith(WF)||t.path!==e.path)return null;let r=Md(t.content),o=Md(e.content);if(!r||!o)return null;let n=r.includes(o),i=o.includes(r);return n===i?null:n?t:e}s(nJ,"richerAgentsResult");function sJ(t,e){if(!t.path.endsWith(WF)||t.path!==e.path)return null;let r=t.target===Rg?t:e.target===Rg?e:null,o=r===t?e:t;if(!r)return null;let n=Md(r.content).length,i=Md(o.content).length;return n===i?null:n>i?r:o}s(sJ,"richerCodexAgentsResult");function $d(t){let e=[];for(let r of t){let o=e.findIndex(i=>i.path===r.path);if(o===-1){e.push(r);continue}let n=e[o];if(n.content!==r.content){let i=nJ(n,r);if(i){e[o]=i;continue}let a=sJ(n,r);if(a){e[o]=a;continue}throw new Error(`Conflicting generated outputs for ${r.path}: ${n.target} and ${r.target} produce different content.`)}e[o]=oJ(n,r);}return e}s($d,"resolveOutputCollisions");function HF(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(HF,"refreshResultStatus");T();xt();je();function VF(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(VF,"computeStatus");function iJ(t,e,r){let o=C_(t,e,r);if(o!==null)return o;let n=ut(t);if(!n)return null;let i=r==="global"?n.globalSupport?.layout:n.project;return i?(o=i.rewriteGeneratedPath?i.rewriteGeneratedPath(e):e,o):null}s(iJ,"resolveGeneratedOutputPath");async function Dm(t,e,r,o,n,i){let a=iJ(e,r.path,n);if(a===null)return null;let c=await y(join(o,a)),l=t.findIndex(u=>u.path===a&&u.target===e),m=l>=0?t[l]:void 0,p=i?.mergeContent?.(c,m,r.content,a)??r.content;return l>=0&&t.splice(l,1),t.push({target:e,path:a,content:p,currentContent:c??void 0,status:VF(c,p)}),a}s(Dm,"emitGeneratedOutput");function J_(t,e,r){return {capability:oi(t,r)?.[e]??{level:"none"},scope:r}}s(J_,"featureContext");async function Oa(t,e,r,o,n,i,a,c){if(n)for(let l of e){let m=c(l);if(!m)continue;let p=J_(l,a,i);for(let u of m(r,p)){let g=await Dm(t,l,u,o,i);if(g===null)continue;let f=vt(l,i);if(f?.mirrorGlobalPath){let h=f.mirrorGlobalPath(g,e),O=h===null?[]:Array.isArray(h)?h:[h];for(let R of O){let S=await y(join(o,R));t.push({target:l,path:R,content:u.content,currentContent:S??void 0,status:VF(S,u.content)});}}}}}s(Oa,"generateFeature");zg();xt();function aJ(t){return t?.rootInstructionPath?[t.rootInstructionPath,...tl(t)]:[]}s(aJ,"rootDecorationPaths");function JF(t,e,r="project"){return t.map(o=>{let n=vt(o.target,r);if(!n)return o;let i=aJ(n);if(i.length===0||!i.includes(o.path))return o;let c=o.path===n.rootInstructionPath&&n.renderPrimaryRootInstruction?n.renderPrimaryRootInstruction(e):o.content,l=KS(c);return l===o.content?o:{...o,content:l}})}s(JF,"decoratePrimaryRootInstructions");xt();je();Ou();function Y_(t,e,r,o,n){let a=(Er(t)??ut(t))?.mergeGeneratedOutputContent?.(e,r,o,n);if(a!=null)return a;let c=r?.content??e;return c!==null&&gw.includes(n)?fw(c,o):o}s(Y_,"mergeOutputContent");async function YF(t,e,r,o,n){for(let i of e){let a=Yc(i,"permissions",void 0,n)??ut(i)?.generators.generatePermissions;if(a)for(let c of a(r))await Dm(t,i,c,o,n,{mergeContent:s((l,m,p,u)=>Y_(i,l,m,p,u),"mergeContent")});}}s(YF,"generatePermissionsFeature");async function XF(t,e,r,o,n,i){for(let a of e){let c=Yc(a,"hooks",i,n)??ut(a)?.generators.generateHooks;if(!c)continue;let l=J_(a,"hooks",n),m=[...c(r,l)],u=(Er(a)??ut(a))?.postProcessHookOutputs;u&&(m=[...await u(o,r,m)]);for(let g of m)await Dm(t,a,g,o,n,{mergeContent:s((f,h,O,R)=>Y_(a,f,h,O,R),"mergeContent")});}}s(XF,"generateHooksFeature");async function ZF(t,e,r,o,n){for(let i of e){let c=(Er(i)??ut(i))?.emitScopedSettings;if(!c)continue;let l=c(r,n);if(l.length!==0)for(let m of l)await Dm(t,i,m,o,n,{mergeContent:s((p,u,g,f)=>Y_(i,p,u,g,f),"mergeContent")});}}s(ZF,"generateScopedSettingsFeature");async function Lr(t){let{config:e,canonical:r,projectRoot:o,scope:n="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],c=i?a.filter(J=>i.includes(J)):a;function l(J,X){return Yc(J,X,e,n)}s(l,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),u=e.features.includes("agents"),g=e.features.includes("skills"),f=e.features.includes("mcp"),h=e.features.includes("permissions"),O=e.features.includes("hooks"),R=e.features.includes("ignore"),S=[];await Oa(S,c,r,o,m,n,"rules",J=>l(J,"rules")),await Oa(S,c,r,o,p,n,"commands",J=>l(J,"commands")),await Oa(S,c,r,o,u,n,"agents",J=>l(J,"agents")),await Oa(S,c,r,o,g,n,"skills",J=>l(J,"skills")),await Oa(S,c,r,o,f,n,"mcp",J=>l(J,"mcp")),h&&await YF(S,c,r,o,n),O&&await XF(S,c,r,o,n,e),await Oa(S,c,r,o,R,n,"ignore",J=>l(J,"ignore"));let A=new Set(e.features);for(let J of c){let q=(Er(J)??ut(J))?.globalSupport?.scopeExtras;if(q){let Ft=await q(r,o,n,A);S.push(...Ft);}}(f||R||O||u||h)&&await ZF(S,c,r,o,n);let D=JF(S,r,n),N=cJ(D,n),G=UF(D,r,e,o,n,c,N);return KF(G,o),$d(G.map(HF))}s(Lr,"generate");function cJ(t,e){let r=new Map;function o(a){let c=r.get(a);if(c)return c;let l=vt(a,e),m=new Set;if(l?.rootInstructionPath){m.add(l.rootInstructionPath);for(let p of tl(l))m.add(p);}return r.set(a,m),m}s(o,"rootPathsFor");let n=new Map;for(let a of t){if(!o(a.target).has(a.path))continue;let c=n.get(a.path)??new Set;c.add(a.target),n.set(a.path,c);}let i=new Set;for(let[a,c]of n)c.size>1&&i.add(a);return i}s(cJ,"computeSharedRootInstructionPaths");ds();ft();T();dn();var SJ=6e4,CJ=30,EJ=200,OJ=2e3;async function sv(t,e={}){let r=e.retries??CJ,o=e.retryDelayMs??EJ,n=e.staleMs??SJ;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await LJ(t);if(a)return a;let c=await AJ(t);if(c!=="young"&&kJ(c,n)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let l=c==="young"?null:c;throw new Fa(t,TJ(l))}i++,await PJ(o);}}s(sv,"acquireProcessLock");async function LJ(t){try{await mkdir(t,{recursive:!1});}catch(i){if(i.code==="EEXIST")return null;throw i}let e=join(t,"holder.json"),r={pid:process.pid,started:Date.now(),hostname:iv()};await writeFile(e,JSON.stringify(r),"utf-8");let o=false,n=s(()=>{if(!o){o=true;try{rmSync(t,{recursive:!0,force:!0});}catch{}}},"signalHandler");return process.once("SIGINT",n),process.once("SIGTERM",n),process.once("exit",n),async()=>{o||(o=true,process.off("SIGINT",n),process.off("SIGTERM",n),process.off("exit",n),await rm$1(t,{recursive:true,force:true}).catch(()=>{}));}}s(LJ,"tryAcquire");async function AJ(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return bJ(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<OJ)return "young"}catch{}return null}}s(AJ,"inspectLock");function kJ(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==iv()?false:!wJ(t.pid)}s(kJ,"isStale");function wJ(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(wJ,"isProcessAlive");function TJ(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(TJ,"describeHolder");function bJ(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(bJ,"isLockMetadata");function iv(){return hostname()}s(iv,"getHostname");function PJ(t){return new Promise(e=>setTimeout(e,t))}s(PJ,"sleep");T();xt();async function av(t,e=t){let r=await readdir(t,{withFileTypes:true}),o=[];for(let n of r){let i=join(t,n.name);if(n.isDirectory()){o.push(...await av(i,e));continue}o.push(relative(e,i).replace(/\\/g,"/"));}return o}s(av,"listFiles");async function FJ(t,e,r){if(r.has(e))return;let o=join(t,e);await j(o)&&await rm$1(o,{recursive:true,force:true});}s(FJ,"removeIfStale");async function cv(t){let e=new Set(t.expectedPaths),r=new Set,o=t.scope??"project";for(let n of t.targets){let i=S_(n,o);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let c=join(t.projectRoot,a);if(await j(c))for(let l of await av(c))r.add(`${a}/${l}`.replace(/\/+/g,"/"));}}}for(let n of r)await FJ(t.projectRoot,n,e);}s(cv,"cleanupStaleGeneratedOutputs");function el(t,e,r){let o=resolve(t),n=resolve(t,e);if(n===o||n.startsWith(`${o}${sep}`))return n;throw new Error(`Unsafe generated output path for ${r}: ${e}`)}s(el,"ensurePathInsideRoot");Rl();T();ft();async function q_(t,e){let r=await us(t.canonicalDir),o=e.length>0?await qc(e):{},n=await vd(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await Nd(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:gl(),checksums:r,extends:o,packs:n});try{await _g(Le(),join(t.configDir,".agentsmeshcache"));}catch(a){I.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(q_,"writeLockFile");async function Iv(t){let{mode:e,scope:r,dryRun:o,context:n,resolvedExtends:i,flags:a,root:c,options:l}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Ud([])}};if(o||await q_(n,i),l.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(vm(),aI)),{renderMatrix:p}=await Promise.resolve().then(()=>(Mm(),cI)),u=await m(a,c);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Ud([])}}}s(Iv,"handleEmptyResults");function Rv(t,e){let r=t.filter(a=>a.status!=="skipped"),o=r.filter(a=>a.status!=="unchanged"),n=r.map(a=>({path:a.path,target:a.target,status:a.status}));return {exitCode:o.length===0?0:1,data:{scope:e,mode:"check",files:n,summary:Ud(r)}}}s(Rv,"buildCheckResult");async function Sv(t){let{results:e,dryRun:r,scope:o,mode:n,context:i,activeTargets:a,resolvedExtends:c,flags:l,root:m,options:p}=t,u=r?null:await sv(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let O=el(i.rootBase,h.path,h.target);await _(O,h.content);}await cv({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:o}),await q_(i,c);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(vm(),aI)),{renderMatrix:O}=await Promise.resolve().then(()=>(Mm(),cI)),R=await h(l,m);O(R,{verbose:l.verbose===true});}let g=e.filter(h=>h.status!=="skipped"),f=g.map(h=>({path:h.path,target:h.target,status:h.status}));return {exitCode:0,data:{scope:o,mode:n,files:f,summary:Ud(g)}}}s(Sv,"handleGenerateOrDryRun");function Ud(t){return {created:t.filter(e=>e.status==="created").length,updated:t.filter(e=>e.status==="updated").length,unchanged:t.filter(e=>e.status==="unchanged").length}}s(Ud,"buildSummary");async function rl(t,e,r={}){if(t.features!==void 0)throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");let o=e??process.cwd(),n=t.check===true,i=t["dry-run"]===true,a=t.force===true,c=t.global===true?"global":"project",l=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(N=>N.trim()).filter(Boolean):void 0,u=n?"check":i?"dry-run":"generate",{config:g,context:f}=await Tt(o,c);await le(g,o);let h=g.collaboration?.lock_features??[];if(g.collaboration?.strategy==="lock"&&!a&&h.length>0){let N=await Dd(f.canonicalDir);if(N!==null){let G=await us(f.canonicalDir),J=Fd(N.checksums,G,h);if(J.length>0){I.error("Locked feature violation (strategy: lock). Modified files:");for(let X of J)I.error(` ${X}`);throw I.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:O,resolvedExtends:R}=await he(g,f.configDir,{refreshRemoteCache:l},f.canonicalDir),S=[...g.targets,...g.pluginTargets??[]];if(p){let N=p.filter(G=>!S.includes(G));if(N.length>0)throw new Error(`Unknown target(s) in --targets: ${N.join(", ")}. Available: ${S.join(", ")}`)}let A=p?S.filter(N=>p.includes(N)):S,D=await Lr({config:g,canonical:O,projectRoot:f.rootBase,scope:c,targetFilter:p});return D.length===0?Iv({mode:u,scope:c,dryRun:i,context:f,resolvedExtends:R,flags:t,root:o,options:r}):n?Rv(D,c):Sv({results:D,dryRun:i,scope:c,mode:u,context:f,activeTargets:A,resolvedExtends:R,flags:t,root:o,options:r})}s(rl,"runGenerate");ft();function lI(t,e){return t==="global"?`~/${e}`:e}s(lI,"formatDisplayPath");function ol(t){let{data:e}=t,{scope:r,mode:o,files:n}=e;if(n.length===0){I.info("No files to generate (no root rule or rules feature disabled)."),o==="check"&&I.success("Generated files are in sync.");return}if(o==="check"){let l=n.filter(m=>m.status!=="unchanged");if(l.length===0){I.success("Generated files are in sync.");return}for(let m of l)I.error(`[check] ${m.status} ${lI(r,m.path)} (${m.target})`);I.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(o==="dry-run"){for(let l of n)I.info(`[dry-run] ${l.status} ${lI(r,l.path)} (${l.target})`);return}for(let l of n)(l.status==="created"||l.status==="updated")&&I.success(`${l.status} ${lI(r,l.path)}`);let{created:i,updated:a,unchanged:c}=e.summary;i>0||a>0?I.info(`Generated: ${i} created, ${a} updated, ${c} unchanged`):I.info(`Nothing changed. (${c} unchanged)`);}s(ol,"renderGenerate");T();xt();uo();var WJ=["codex-cli"];function Cv(){return kt.filter(t=>!WJ.includes(t))}s(Cv,"starterInitTargetIds");var HJ=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],zJ=Cv();function Kd(t,e=zJ){let r=(t.length>0?t:e).map(n=>` - ${n}`).join(`
|
|
175
|
-
`),o=
|
|
174
|
+
Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(KF,"validateGeneratedMarkdownLinks");mo();var WF="AGENTS.md";function BF(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(BF,"statusRank");function rJ(t,e){return BF(e.status)<=BF(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(rJ,"mergeDuplicateMetadata");function vd(t){return t.trim()}s(vd,"trimmedContent");function oJ(t,e){if(!t.path.endsWith(WF)||t.path!==e.path)return null;let r=vd(t.content),o=vd(e.content);if(!r||!o)return null;let n=r.includes(o),i=o.includes(r);return n===i?null:n?t:e}s(oJ,"richerAgentsResult");function nJ(t,e){if(!t.path.endsWith(WF)||t.path!==e.path)return null;let r=t.target===_g?t:e.target===_g?e:null,o=r===t?e:t;if(!r)return null;let n=vd(r.content).length,i=vd(o.content).length;return n===i?null:n>i?r:o}s(nJ,"richerCodexAgentsResult");function Gd(t){let e=[];for(let r of t){let o=e.findIndex(i=>i.path===r.path);if(o===-1){e.push(r);continue}let n=e[o];if(n.content!==r.content){let i=oJ(n,r);if(i){e[o]=i;continue}let a=nJ(n,r);if(a){e[o]=a;continue}throw new Error(`Conflicting generated outputs for ${r.path}: ${n.target} and ${r.target} produce different content.`)}e[o]=rJ(n,r);}return e}s(Gd,"resolveOutputCollisions");function HF(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(HF,"refreshResultStatus");T();xt();je();function VF(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(VF,"computeStatus");function sJ(t,e,r){let o=h_(t,e,r);if(o!==null)return o;let n=ut(t);if(!n)return null;let i=r==="global"?n.globalSupport?.layout:n.project;return i?(o=i.rewriteGeneratedPath?i.rewriteGeneratedPath(e):e,o):null}s(sJ,"resolveGeneratedOutputPath");async function Dm(t,e,r,o,n,i){let a=sJ(e,r.path,n);if(a===null)return null;let c=await y(join(o,a)),l=t.findIndex(d=>d.path===a&&d.target===e),m=l>=0?t[l]:void 0,p=i?.mergeContent?.(c,m,r.content,a)??r.content;return l>=0&&t.splice(l,1),t.push({target:e,path:a,content:p,currentContent:c??void 0,status:VF(c,p)}),a}s(Dm,"emitGeneratedOutput");function K_(t,e,r){return {capability:ti(t,r)?.[e]??{level:"none"},scope:r}}s(K_,"featureContext");async function Sa(t,e,r,o,n,i,a,c){if(n)for(let l of e){let m=c(l);if(!m)continue;let p=K_(l,a,i);for(let d of m(r,p)){let g=await Dm(t,l,d,o,i);if(g===null)continue;let f=vt(l,i);if(f?.mirrorGlobalPath){let h=f.mirrorGlobalPath(g,e),O=h===null?[]:Array.isArray(h)?h:[h];for(let R of O){let E=await y(join(o,R));t.push({target:l,path:R,content:d.content,currentContent:E??void 0,status:VF(E,d.content)});}}}}}s(Sa,"generateFeature");Wg();xt();function iJ(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Qc(t)]:[]}s(iJ,"rootDecorationPaths");function JF(t,e,r="project"){return t.map(o=>{let n=vt(o.target,r);if(!n)return o;let i=iJ(n);if(i.length===0||!i.includes(o.path))return o;let c=o.path===n.rootInstructionPath&&n.renderPrimaryRootInstruction?n.renderPrimaryRootInstruction(e):o.content,l=vS(c);return l===o.content?o:{...o,content:l}})}s(JF,"decoratePrimaryRootInstructions");xt();je();Cu();function B_(t,e,r,o,n){let a=(Cr(t)??ut(t))?.mergeGeneratedOutputContent?.(e,r,o,n);if(a!=null)return a;let c=r?.content??e;return c!==null&&uw.includes(n)?dw(c,o):o}s(B_,"mergeOutputContent");async function YF(t,e,r,o,n){for(let i of e){let a=Vc(i,"permissions",void 0,n)??ut(i)?.generators.generatePermissions;if(a)for(let c of a(r))await Dm(t,i,c,o,n,{mergeContent:s((l,m,p,d)=>B_(i,l,m,p,d),"mergeContent")});}}s(YF,"generatePermissionsFeature");async function XF(t,e,r,o,n,i){for(let a of e){let c=Vc(a,"hooks",i,n)??ut(a)?.generators.generateHooks;if(!c)continue;let l=K_(a,"hooks",n),m=[...c(r,l)],d=(Cr(a)??ut(a))?.postProcessHookOutputs;d&&(m=[...await d(o,r,m)]);for(let g of m)await Dm(t,a,g,o,n,{mergeContent:s((f,h,O,R)=>B_(a,f,h,O,R),"mergeContent")});}}s(XF,"generateHooksFeature");async function ZF(t,e,r,o,n){for(let i of e){let c=(Cr(i)??ut(i))?.emitScopedSettings;if(!c)continue;let l=c(r,n);if(l.length!==0)for(let m of l)await Dm(t,i,m,o,n,{mergeContent:s((p,d,g,f)=>B_(i,p,d,g,f),"mergeContent")});}}s(ZF,"generateScopedSettingsFeature");async function Or(t){let{config:e,canonical:r,projectRoot:o,scope:n="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],c=i?a.filter(J=>i.includes(J)):a;function l(J,Y){return Vc(J,Y,e,n)}s(l,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),d=e.features.includes("agents"),g=e.features.includes("skills"),f=e.features.includes("mcp"),h=e.features.includes("permissions"),O=e.features.includes("hooks"),R=e.features.includes("ignore"),E=[];await Sa(E,c,r,o,m,n,"rules",J=>l(J,"rules")),await Sa(E,c,r,o,p,n,"commands",J=>l(J,"commands")),await Sa(E,c,r,o,d,n,"agents",J=>l(J,"agents")),await Sa(E,c,r,o,g,n,"skills",J=>l(J,"skills")),await Sa(E,c,r,o,f,n,"mcp",J=>l(J,"mcp")),h&&await YF(E,c,r,o,n),O&&await XF(E,c,r,o,n,e),await Sa(E,c,r,o,R,n,"ignore",J=>l(J,"ignore"));let A=new Set(e.features);for(let J of c){let q=(Cr(J)??ut(J))?.globalSupport?.scopeExtras;if(q){let Ft=await q(r,o,n,A);E.push(...Ft);}}(f||R||O||d||h)&&await ZF(E,c,r,o,n);let F=JF(E,r,n),v=aJ(F,n),G=UF(F,r,e,o,n,c,v);return KF(G,o),Gd(G.map(HF))}s(Or,"generate");function aJ(t,e){let r=new Map;function o(a){let c=r.get(a);if(c)return c;let l=vt(a,e),m=new Set;if(l?.rootInstructionPath){m.add(l.rootInstructionPath);for(let p of Qc(l))m.add(p);}return r.set(a,m),m}s(o,"rootPathsFor");let n=new Map;for(let a of t){if(!o(a.target).has(a.path))continue;let c=n.get(a.path)??new Set;c.add(a.target),n.set(a.path,c);}let i=new Set;for(let[a,c]of n)c.size>1&&i.add(a);return i}s(aJ,"computeSharedRootInstructionPaths");ms();ft();T();mn();var RJ=6e4,SJ=30,CJ=200,EJ=2e3;async function sv(t,e={}){let r=e.retries??SJ,o=e.retryDelayMs??CJ,n=e.staleMs??RJ;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await OJ(t);if(a)return a;let c=await LJ(t);if(c!=="young"&&AJ(c,n)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let l=c==="young"?null:c;throw new xa(t,wJ(l))}i++,await bJ(o);}}s(sv,"acquireProcessLock");async function OJ(t){try{await mkdir(t,{recursive:!1});}catch(i){if(i.code==="EEXIST")return null;throw i}let e=join(t,"holder.json"),r={pid:process.pid,started:Date.now(),hostname:iv()};await writeFile(e,JSON.stringify(r),"utf-8");let o=false,n=s(()=>{if(!o){o=true;try{rmSync(t,{recursive:!0,force:!0});}catch{}}},"signalHandler");return process.once("SIGINT",n),process.once("SIGTERM",n),process.once("exit",n),async()=>{o||(o=true,process.off("SIGINT",n),process.off("SIGTERM",n),process.off("exit",n),await rm$1(t,{recursive:true,force:true}).catch(()=>{}));}}s(OJ,"tryAcquire");async function LJ(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return TJ(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<EJ)return "young"}catch{}return null}}s(LJ,"inspectLock");function AJ(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==iv()?false:!kJ(t.pid)}s(AJ,"isStale");function kJ(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(kJ,"isProcessAlive");function wJ(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(wJ,"describeHolder");function TJ(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(TJ,"isLockMetadata");function iv(){return hostname()}s(iv,"getHostname");function bJ(t){return new Promise(e=>setTimeout(e,t))}s(bJ,"sleep");T();xt();async function av(t,e=t){let r=await readdir(t,{withFileTypes:true}),o=[];for(let n of r){let i=join(t,n.name);if(n.isDirectory()){o.push(...await av(i,e));continue}o.push(relative(e,i).replace(/\\/g,"/"));}return o}s(av,"listFiles");async function NJ(t,e,r){if(r.has(e))return;let o=join(t,e);await j(o)&&await rm$1(o,{recursive:true,force:true});}s(NJ,"removeIfStale");async function cv(t){let e=new Set(t.expectedPaths),r=new Set,o=t.scope??"project";for(let n of t.targets){let i=f_(n,o);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let c=join(t.projectRoot,a);if(await j(c))for(let l of await av(c))r.add(`${a}/${l}`.replace(/\/+/g,"/"));}}}for(let n of r)await NJ(t.projectRoot,n,e);}s(cv,"cleanupStaleGeneratedOutputs");function qc(t,e,r){let o=resolve(t),n=resolve(t,e);if(n===o||n.startsWith(`${o}${sep}`))return n;throw new Error(`Unsafe generated output path for ${r}: ${e}`)}s(qc,"ensurePathInsideRoot");_l();T();ft();async function V_(t,e){let r=await ls(t.canonicalDir),o=e.length>0?await Zc(e):{},n=await Nd(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await xd(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:ul(),checksums:r,extends:o,packs:n});try{await hg(Le(),join(t.configDir,".agentsmeshcache"));}catch(a){_.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(V_,"writeLockFile");async function Iv(t){let{mode:e,scope:r,dryRun:o,context:n,resolvedExtends:i,flags:a,root:c,options:l}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:$d([])}};if(o||await V_(n,i),l.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(vm(),eI)),{renderMatrix:p}=await Promise.resolve().then(()=>(Mm(),rI)),d=await m(a,c);p(d,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:$d([])}}}s(Iv,"handleEmptyResults");function Rv(t,e){let r=t.filter(a=>a.status!=="skipped"),o=r.filter(a=>a.status!=="unchanged"),n=r.map(a=>({path:a.path,target:a.target,status:a.status}));return {exitCode:o.length===0?0:1,data:{scope:e,mode:"check",files:n,summary:$d(r)}}}s(Rv,"buildCheckResult");async function Sv(t){let{results:e,dryRun:r,scope:o,mode:n,context:i,activeTargets:a,resolvedExtends:c,flags:l,root:m,options:p}=t,d=r?null:await sv(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let O=qc(i.rootBase,h.path,h.target);await I(O,h.content);}await cv({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:o}),await V_(i,c);}}finally{d&&await d();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(vm(),eI)),{renderMatrix:O}=await Promise.resolve().then(()=>(Mm(),rI)),R=await h(l,m);O(R,{verbose:l.verbose===true});}let g=e.filter(h=>h.status!=="skipped"),f=g.map(h=>({path:h.path,target:h.target,status:h.status}));return {exitCode:0,data:{scope:o,mode:n,files:f,summary:$d(g)}}}s(Sv,"handleGenerateOrDryRun");function $d(t){return {created:t.filter(e=>e.status==="created").length,updated:t.filter(e=>e.status==="updated").length,unchanged:t.filter(e=>e.status==="unchanged").length}}s($d,"buildSummary");async function tl(t,e,r={}){if(t.features!==void 0)throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");let o=e??process.cwd(),n=t.check===true,i=t["dry-run"]===true,a=t.force===true,c=t.global===true?"global":"project",l=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(v=>v.trim()).filter(Boolean):void 0,d=n?"check":i?"dry-run":"generate",{config:g,context:f}=await Tt(o,c);await ce(g,o);let h=g.collaboration?.lock_features??[];if(g.collaboration?.strategy==="lock"&&!a&&h.length>0){let v=await Pd(f.canonicalDir);if(v!==null){let G=await ls(f.canonicalDir),J=Dd(v.checksums,G,h);if(J.length>0){_.error("Locked feature violation (strategy: lock). Modified files:");for(let Y of J)_.error(` ${Y}`);throw _.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:O,resolvedExtends:R}=await he(g,f.configDir,{refreshRemoteCache:l},f.canonicalDir),E=[...g.targets,...g.pluginTargets??[]];if(p){let v=p.filter(G=>!E.includes(G));if(v.length>0)throw new Error(`Unknown target(s) in --targets: ${v.join(", ")}. Available: ${E.join(", ")}`)}let A=p?E.filter(v=>p.includes(v)):E,F=await Or({config:g,canonical:O,projectRoot:f.rootBase,scope:c,targetFilter:p});return F.length===0?Iv({mode:d,scope:c,dryRun:i,context:f,resolvedExtends:R,flags:t,root:o,options:r}):n?Rv(F,c):Sv({results:F,dryRun:i,scope:c,mode:d,context:f,activeTargets:A,resolvedExtends:R,flags:t,root:o,options:r})}s(tl,"runGenerate");ft();function oI(t,e){return t==="global"?`~/${e}`:e}s(oI,"formatDisplayPath");function el(t){let{data:e}=t,{scope:r,mode:o,files:n}=e;if(n.length===0){_.info("No files to generate (no root rule or rules feature disabled)."),o==="check"&&_.success("Generated files are in sync.");return}if(o==="check"){let l=n.filter(m=>m.status!=="unchanged");if(l.length===0){_.success("Generated files are in sync.");return}for(let m of l)_.error(`[check] ${m.status} ${oI(r,m.path)} (${m.target})`);_.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(o==="dry-run"){for(let l of n)_.info(`[dry-run] ${l.status} ${oI(r,l.path)} (${l.target})`);return}for(let l of n)(l.status==="created"||l.status==="updated")&&_.success(`${l.status} ${oI(r,l.path)}`);let{created:i,updated:a,unchanged:c}=e.summary;i>0||a>0?_.info(`Generated: ${i} created, ${a} updated, ${c} unchanged`):_.info(`Nothing changed. (${c} unchanged)`);}s(el,"renderGenerate");T();xt();mo();var BJ=["codex-cli"];function Cv(){return kt.filter(t=>!BJ.includes(t))}s(Cv,"starterInitTargetIds");var WJ=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],HJ=Cv();function jd(t,e=HJ){let r=(t.length>0?t:e).map(n=>` - ${n}`).join(`
|
|
175
|
+
`),o=WJ.map(n=>` - ${n}`).join(`
|
|
176
176
|
`);return `# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
177
177
|
version: 1
|
|
178
178
|
targets:
|
|
179
179
|
${r}
|
|
180
180
|
features:
|
|
181
181
|
${o}
|
|
182
|
-
`}s(
|
|
182
|
+
`}s(jd,"buildConfig");var Ud=`---
|
|
183
183
|
root: true
|
|
184
184
|
description: "Project rules"
|
|
185
185
|
---
|
|
@@ -188,7 +188,7 @@ description: "Project rules"
|
|
|
188
188
|
|
|
189
189
|
Add your project-wide instructions here.
|
|
190
190
|
This file is always included in AI tool context and synced to all configured tools.
|
|
191
|
-
`,
|
|
191
|
+
`,nI=`---
|
|
192
192
|
description: "Example contextual rule \u2014 rename and customize"
|
|
193
193
|
# targets: [claude-code, cursor] # limit to specific tools (optional)
|
|
194
194
|
# globs: ["src/**/*.ts"] # activate only for matching files (optional)
|
|
@@ -197,14 +197,14 @@ description: "Example contextual rule \u2014 rename and customize"
|
|
|
197
197
|
# Example Rule
|
|
198
198
|
|
|
199
199
|
Replace this with your coding standards, conventions, or domain-specific guidelines.
|
|
200
|
-
`,
|
|
200
|
+
`,sI=`---
|
|
201
201
|
description: "Example command \u2014 rename and customize"
|
|
202
202
|
# allowed-tools: [Read, Grep, Glob, Bash]
|
|
203
203
|
---
|
|
204
204
|
|
|
205
205
|
Describe the task for this command here.
|
|
206
206
|
Commands are invoked on-demand (e.g. /example) with a focused tool set.
|
|
207
|
-
`,
|
|
207
|
+
`,iI=`---
|
|
208
208
|
name: example-agent
|
|
209
209
|
description: "Example subagent \u2014 rename and customize"
|
|
210
210
|
# tools: [Read, Grep, Glob]
|
|
@@ -215,7 +215,7 @@ description: "Example subagent \u2014 rename and customize"
|
|
|
215
215
|
|
|
216
216
|
Describe this agent's role and instructions here.
|
|
217
217
|
Agents are specialized subagents with restricted tools and a specific purpose.
|
|
218
|
-
`,
|
|
218
|
+
`,aI=`---
|
|
219
219
|
name: example-skill
|
|
220
220
|
description: "Example skill \u2014 rename and customize"
|
|
221
221
|
---
|
|
@@ -224,7 +224,7 @@ description: "Example skill \u2014 rename and customize"
|
|
|
224
224
|
|
|
225
225
|
Describe the skill procedure here.
|
|
226
226
|
Skills are reusable multi-step procedures that commands and agents can reference.
|
|
227
|
-
`,
|
|
227
|
+
`,cI=`{
|
|
228
228
|
"mcpServers": {
|
|
229
229
|
// agentsmesh self-serve MCP server \u2014 exposes your canonical config to AI agents.
|
|
230
230
|
// Lets agents introspect rules/commands/agents/skills and trigger generate.
|
|
@@ -251,7 +251,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
251
251
|
// }
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
`,
|
|
254
|
+
`,lI=`# Lifecycle hooks \u2014 run shell commands before/after AI tool use
|
|
255
255
|
# Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
|
|
256
256
|
# Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
|
|
257
257
|
#
|
|
@@ -264,7 +264,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
264
264
|
# - matcher: Edit|Write
|
|
265
265
|
# type: command
|
|
266
266
|
# command: npm test --passWithNoTests
|
|
267
|
-
`,
|
|
267
|
+
`,mI=`# Tool permission allow/deny lists
|
|
268
268
|
#
|
|
269
269
|
# allow:
|
|
270
270
|
# - Bash(npm run:*)
|
|
@@ -280,7 +280,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
280
280
|
allow: []
|
|
281
281
|
deny: []
|
|
282
282
|
ask: []
|
|
283
|
-
`,
|
|
283
|
+
`,pI=`# Patterns ignored by all configured AI tools (gitignore syntax)
|
|
284
284
|
#
|
|
285
285
|
# node_modules/
|
|
286
286
|
# dist/
|
|
@@ -306,27 +306,27 @@ ask: []
|
|
|
306
306
|
# overrides:
|
|
307
307
|
# claude-code:
|
|
308
308
|
# model: opus
|
|
309
|
-
`;T();xt();function Ov(t){let e=[];for(let r of zt)for(let o of
|
|
310
|
-
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),n=
|
|
309
|
+
`;T();xt();function Ov(t){let e=[];for(let r of zt)for(let o of g_(r.id,t))e.push({target:r.id,path:o});return e}s(Ov,"collectDetectionPaths");function Lv(t){let e=new Map;for(let{target:r,path:o}of Ov(t)){let n=e.get(r)??[];n.push(o),e.set(r,n);}return [...e.entries()].map(([r,o])=>({id:r,paths:o}))}s(Lv,"toolIndicators");Lv("project");async function Av(t,e="project"){let r=[];for(let{id:o,paths:n}of Lv(e))for(let i of n){let a=join(t,i);if(await j(a)){r.push(o);break}}return [...new Set(r)]}s(Av,"detectExistingConfigs");T();ft();function qt(t,e){return join(t,e)}s(qt,"ab");async function uI(t){return await j(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(uI,"countMdFiles");async function VJ(t){let e=qt(t,"skills");if(!await j(e))return false;let r=await readdir(e,{withFileTypes:true});for(let o of r)if(o.isDirectory()&&!o.name.startsWith("_")&&await j(join(e,o.name,"SKILL.md")))return true;return false}s(VJ,"hasAnyImportedSkill");async function dI(t){let e=qt(t,"rules");await L(e),await I(join(e,"_root.md"),Ud),_.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),nI),_.success("Created .agentsmesh/rules/_example.md");let r=qt(t,"commands");await L(r),await I(join(r,"_example.md"),sI),_.success("Created .agentsmesh/commands/_example.md");let o=qt(t,"agents");await L(o),await I(join(o,"_example.md"),iI),_.success("Created .agentsmesh/agents/_example.md");let n=qt(t,join("skills","_example"));await L(n),await I(join(n,"SKILL.md"),aI),_.success("Created .agentsmesh/skills/_example/SKILL.md"),await I(qt(t,"mcp.json"),cI),_.success("Created .agentsmesh/mcp.json"),await I(qt(t,"hooks.yaml"),lI),_.success("Created .agentsmesh/hooks.yaml"),await I(qt(t,"permissions.yaml"),mI),_.success("Created .agentsmesh/permissions.yaml"),await I(qt(t,"ignore"),pI),_.success("Created .agentsmesh/ignore");}s(dI,"writeScaffoldFull");async function wv(t){let e=qt(t,"rules"),r=await uI(e),o=join(e,"_root.md"),n=await j(o);await L(e),r===0?(await I(o,Ud),_.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),nI),_.success("Created .agentsmesh/rules/_example.md")):n||(await I(o,Ud),_.success("Created .agentsmesh/rules/_root.md"));let i=qt(t,"commands");await uI(i)===0&&(await L(i),await I(join(i,"_example.md"),sI),_.success("Created .agentsmesh/commands/_example.md"));let a=qt(t,"agents");if(await uI(a)===0&&(await L(a),await I(join(a,"_example.md"),iI),_.success("Created .agentsmesh/agents/_example.md")),!await VJ(t)){let d=qt(t,join("skills","_example"));await L(d),await I(join(d,"SKILL.md"),aI),_.success("Created .agentsmesh/skills/_example/SKILL.md");}let c=qt(t,"mcp.json");await j(c)||(await I(c,cI),_.success("Created .agentsmesh/mcp.json"));let l=qt(t,"hooks.yaml");await j(l)||(await I(l,lI),_.success("Created .agentsmesh/hooks.yaml"));let m=qt(t,"permissions.yaml");await j(m)||(await I(m,mI),_.success("Created .agentsmesh/permissions.yaml"));let p=qt(t,"ignore");await j(p)||(await I(p,pI),_.success("Created .agentsmesh/ignore"));}s(wv,"writeScaffoldGapFill");Oe();var gI="agentsmesh.yaml",Tv="agentsmesh.local.yaml",YJ=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],XJ=Object.fromEntries(zt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),bv=zt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function ZJ(t,e){if(e.has(t))return true;let r=t.replace(/\/$/,"");for(;r.includes("/")&&(r=r.slice(0,r.lastIndexOf("/")),r!=="");)if(e.has(r)||e.has(`${r}/`)||e.has(`${r}/**`))return true;return false}s(ZJ,"isCoveredByExisting");async function QJ(t){let e=join(t,".gitignore"),r=await y(e)??"",o=new Set(r.split(`
|
|
310
|
+
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),n=YJ.filter(a=>!ZJ(a,o));if(n.length===0)return false;let i=r.endsWith(`
|
|
311
311
|
`)||r===""?"":`
|
|
312
|
-
`;return await
|
|
312
|
+
`;return await I(e,r+i+n.join(`
|
|
313
313
|
`)+`
|
|
314
|
-
`),true}s(
|
|
314
|
+
`),true}s(QJ,"appendToGitignore");async function Pv(t,e={}){let r=e.global===true?"global":"project",o=fl(t,r),n=join(o.configDir,gI);if(await j(n))throw new Error(`Already initialized. ${gI} exists. Remove it first to re-init.`);let i=await Av(o.rootBase,r),a=r==="global"?i.filter(f=>bv.includes(f)):i,c=r==="global"?bv:void 0,l=[],m,p=0;if(a.length>0)if(e.yes){for(let f of a){let h=XJ[f];if(!h)continue;let O=await h(o.rootBase,r);for(let R of O)l.push({from:relative(o.rootBase,R.fromPath).replaceAll("\\","/"),to:R.toPath.replaceAll("\\","/")});}p=a.length,await wv(o.canonicalDir),m="gap-fill",await I(n,jd(a,c));}else await dI(o.canonicalDir),m="full",await I(n,jd([],c));else await dI(o.canonicalDir),m="full",await I(n,jd([],c));let d=join(o.configDir,Tv);await I(d,Ev);let g=false;return r==="project"&&(g=await QJ(t)),{exitCode:0,data:{scope:r,configFile:gI,localConfigFile:Tv,detectedConfigs:a,imported:l,importedToolCount:p,scaffoldType:m,gitignoreUpdated:g}}}s(Pv,"runInit");ft();function xv(t){let{data:e}=t;if(e.detectedConfigs.length>0&&_.info(`Found existing configurations: ${e.detectedConfigs.join(", ")}`),e.detectedConfigs.length>0&&e.imported.length===0&&_.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),e.imported.length>0){_.info("Auto-importing existing configurations (--yes)...");for(let o of e.imported)_.success(` ${o.from} \u2192 ${o.to}`);_.info(`Imported ${e.imported.length} file(s) from ${e.importedToolCount} tool(s).`);}let r=e.imported.length>0&&e.detectedConfigs.length>0?` (targets: ${e.detectedConfigs.join(", ")})`:"";_.success(`Created ${e.configFile}${r}`),_.success(`Created ${e.localConfigFile}`),e.gitignoreUpdated&&_.success("Updated .gitignore");}s(xv,"renderInit");Oe();xt();var qJ=Object.fromEntries(zt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Kd(t){let e=qJ[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}s(Kd,"getTargetCatalogEntry");je();ms();Rl();var s1={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function i1(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=s1,true)}s(i1,"injectAgentsmeshEntry");async function hI(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await Tr(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!i1(r))return !1;let o=JSON.stringify(r,null,2)+`
|
|
315
315
|
`;await mkdir(dirname(e),{recursive:!0});let n=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(n,o,"utf8"),await rename(n,e),!0}catch(r){return process.stderr.write(`[agentsmesh] warning: could not seed agentsmesh MCP server entry into mcp.json: ${r instanceof Error?r.message:String(r)}
|
|
316
|
-
`),false}}s(CI,"seedAgentsmeshMcpEntry");function Dv(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(Dv,"mapResults");async function Nv(t,e){let r=e??process.cwd(),o=t.from;if(typeof o!="string"||!o)throw new Error("--from is required. Example: agentsmesh import --from claude-code");let n=o.toLowerCase().trim(),i=t.global===true?"global":"project";if(Tr(n)){let p=yl(r,i),g=await Wd(n).importFrom(p.rootBase,{scope:i});return g.length>0&&await CI(p.rootBase),{exitCode:0,data:{scope:i,target:n,files:Dv(g,p.rootBase)}}}let a,c;try{({config:a,context:c}=await Tt(r,i));}catch{throw new Error(`Unknown --from "${o}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${kt.join(", ")}.`)}await le(a,r);let l=ut(n);if(!l)throw new Error(`Unknown --from "${o}". Supported: ${[...kt,...a.pluginTargets??[]].join(", ")}.`);let m=await l.generators.importFrom(c.rootBase,{scope:i});return m.length>0&&await CI(c.rootBase),{exitCode:0,data:{scope:i,target:n,files:Dv(m,c.rootBase)}}}s(Nv,"runImport");Oe();ln();function Hd(t){let e=[],r={new:0,updated:0,unchanged:0,deleted:0};for(let o of t){if(o.status==="unchanged"){r.unchanged++;continue}if(o.status==="created"){r.new++;let n=createTwoFilesPatch(`${o.path} (current)`,`${o.path} (generated)`,"",o.content,void 0,void 0,{context:3});e.push({path:o.path,patch:n});continue}if(o.status==="updated"&&o.currentContent!==void 0){r.updated++;let n=createTwoFilesPatch(`${o.path} (current)`,`${o.path} (generated)`,o.currentContent,o.content,void 0,void 0,{context:3});e.push({path:o.path,patch:n});continue}}return {diffs:e,summary:r}}s(Hd,"computeDiff");function zd(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(zd,"formatDiffSummary");ds();async function vv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(f=>f.trim()).filter(Boolean):void 0,{config:a,context:c}=await Tt(r,o);await le(a,r);let{canonical:l}=await he(a,c.configDir,{},c.canonicalDir),m=await Lr({config:a,canonical:l,projectRoot:c.rootBase,scope:o,targetFilter:i});if(m.length===0)return {exitCode:0,data:{files:[],patches:[],summary:{created:0,updated:0,unchanged:0,deleted:0}}};let{diffs:p,summary:u}=Hd(m);return {exitCode:0,data:{files:m.filter(f=>f.status!=="unchanged"&&f.status!=="skipped").map(f=>({path:f.path,target:f.target,status:f.status})),patches:p.map(f=>({path:f.path,patch:f.patch})),summary:{created:u.new,updated:u.updated,unchanged:u.unchanged,deleted:u.deleted}}}}s(vv,"runDiff");Oe();ln();T();je();Si();Et();var l1=[{canonicalKey:"permissions",capabilityKey:"permissions",featureFlag:"permissions",file:".agentsmesh/permissions.yaml",label:"permissions",hasContent:s(t=>{let e=t.permissions;if(!e)return false;let r=e.ask?.length??0;return e.allow.length+e.deny.length+r>0},"hasContent")},{canonicalKey:"hooks",capabilityKey:"hooks",featureFlag:"hooks",file:".agentsmesh/hooks.yaml",label:"hooks",hasContent:s(t=>{let e=t.hooks;return e?Object.values(e).some(r=>Array.isArray(r)&&r.length>0):false},"hasContent")},{canonicalKey:"mcp",capabilityKey:"mcp",featureFlag:"mcp",file:".agentsmesh/mcp.json",label:"MCP servers",hasContent:s(t=>{let e=t.mcp;return e?Object.keys(e.mcpServers).length>0:false},"hasContent")},{canonicalKey:"commands",capabilityKey:"commands",featureFlag:"commands",file:".agentsmesh/commands",label:"commands",hasContent:s(t=>t.commands.length>0,"hasContent")},{canonicalKey:"agents",capabilityKey:"agents",featureFlag:"agents",file:".agentsmesh/agents",label:"agents",hasContent:s(t=>t.agents.length>0,"hasContent")},{canonicalKey:"skills",capabilityKey:"skills",featureFlag:"skills",file:".agentsmesh/skills",label:"skills",hasContent:s(t=>t.skills.length>0,"hasContent")},{canonicalKey:"ignore",capabilityKey:"ignore",featureFlag:"ignore",file:".agentsmesh/ignore",label:"ignore patterns",hasContent:s(t=>t.ignore.length>0,"hasContent")}];function Gv(t){let e=new Set(t.enabledFeatures),r=[];for(let o of l1)!e.has(o.featureFlag)||!o.hasContent(t.canonical)||Dr(t.capabilities[o.capabilityKey]).level!=="none"||r.push(b(o.file,t.target,`${t.target} does not support ${o.label}; canonical entries are silently dropped during generation. Disable the feature for this target or remove the canonical content.`));return r}s(Gv,"lintSilentFeatureDrops");Et();var m1=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function p1(t){let r=t.match(m1)?.groups?.path;return typeof r=="string"?r:null}s(p1,"extractScriptToken");function Mv(t){if(t.hasScriptProjection)return [];let e=t.canonical.hooks;if(!e)return [];let r=[];for(let o of Object.values(e))if(Array.isArray(o))for(let n of o){if(typeof n?.command!="string")continue;let i=p1(n.command);i&&r.push(b(".agentsmesh/hooks.yaml",t.target,`${t.target} hook command references script "${i}"; agentsmesh does not copy hook scripts into ${t.target} output, so the script must already exist relative to the hook execution directory or the generated config will fail.`));}return r}s(Mv,"lintHookScriptReferences");Et();function $v(t){if(t.preservesManualActivation)return [];let e=[];for(let r of t.canonical.rules)r.root||r.trigger==="manual"&&(r.targets.length>0&&!r.targets.includes(t.target)||e.push(b(r.source,t.target,`Rule has trigger: 'manual' (Cursor-style "@-mention only" activation), but ${t.target} loads every rule unconditionally. The rule will become always-on for ${t.target} \u2014 restrict it with \`targets: [cursor]\`, convert it to a skill with manual invocation, or remove it.`)));return e}s($v,"lintRuleScopeInversion");var u1=["node_modules",".git","dist","coverage",".agentsmesh"];async function d1(t){return (await v(t)).filter(o=>{let n=relative(t,o);return !u1.some(i=>n.includes(`/${i}/`)||n.startsWith(`${i}/`))}).map(o=>relative(t,o))}s(d1,"getProjectFiles");async function Vd(t,e,r,o,n={}){let i=n.scope??"project",a=[...t.targets,...t.pluginTargets??[]],c=o?a.filter(R=>o.includes(R)):a,l=t.features.includes("rules"),m=t.features.includes("commands"),p=t.features.includes("mcp"),u=t.features.includes("permissions"),g=t.features.includes("hooks"),f=[],h=i==="global"?[]:await d1(r);for(let R of c){let S=ut(R),A=Tr(R)?Wd(R):S;A?.capabilities&&f.push(...Gv({target:R,capabilities:A.capabilities,canonical:e,enabledFeatures:t.features})),g&&f.push(...Mv({target:R,canonical:e,hasScriptProjection:S?.postProcessHookOutputs!==void 0})),l&&f.push(...$v({target:R,canonical:e,preservesManualActivation:S?.preservesManualActivation===true})),l&&A?.lintRules&&f.push(...A.lintRules(e,r,h,{scope:i})),S?.generators.lint&&f.push(...S.generators.lint(e));let D={scope:i};m&&A?.lint?.commands&&f.push(...A.lint.commands(e,D)),p&&A?.lint?.mcp&&f.push(...A.lint.mcp(e,D)),u&&A?.lint?.permissions&&f.push(...A.lint.permissions(e,D)),g&&A?.lint?.hooks&&f.push(...A.lint.hooks(e,D));}let O=f.some(R=>R.level==="error");return {diagnostics:f,hasErrors:O}}s(Vd,"runLint");ds();async function Uv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(u=>u.trim()).filter(Boolean):void 0,{config:a,context:c}=await Tt(r,o);await le(a,r);let{canonical:l}=await he(a,c.configDir,{},c.canonicalDir),{diagnostics:m,hasErrors:p}=await Vd(a,l,c.configDir,i,{scope:o});return {exitCode:p?1:0,data:{diagnostics:m.map(u=>({level:u.level,file:u.file,target:u.target,message:u.message})),summary:{errors:m.filter(u=>u.level==="error").length,warnings:m.filter(u=>u.level==="warning").length}}}}s(Uv,"runLintCmd");ft();function Kv(t){let{data:e}=t;if(e.diagnostics.length===0){I.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),o=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)I.error(`${a.file} (${a.target}): ${a.message}`);for(let a of o)I.warn(`${a.file} (${a.target}): ${a.message}`);let n=e.summary.errors,i=e.summary.warnings;I.info(`${n} error${n!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(Kv,"renderLint");ft();function Bv(t){let{data:e}=t;if(!e.hasLock){I.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){I.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);I.error("Conflict detected:");for(let o of e.extendsModified)I.error(` extend "${o}" was modified`);for(let o of e.modified){let n=r.has(o)?" [LOCKED]":"";I.error(` ${o} was modified${n}`);}for(let o of e.added){let n=r.has(o)?" [LOCKED]":"";I.error(` ${o} was added${n}`);}for(let o of e.removed){let n=r.has(o)?" [LOCKED]":"";I.error(` ${o} was removed${n}`);}I.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(Bv,"renderCheck");ft();function Wv(t){let{data:e}=t;if(e.files.length===0){I.info(`Nothing to import from ${e.target}.`);return}for(let o of e.files)I.success(`${o.from} \u2192 ${o.to}`);let r=e.scope==="global"?" --global":"";I.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(Wv,"renderImport");ft();function Hv(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){I.info("No files to generate (no root rule or rules feature disabled).");return}for(let o of t.data.patches)process.stdout.write(o.patch);I.info(zd({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(Hv,"renderDiff");ft();function zv(t){if(!t.data.hadConflict){I.info("No conflicts to resolve.");return}I.success("Lock file conflict resolved.");}s(zv,"renderMerge");vm();Mm();Oe();ln();vm();Mm();ft();var h1=300;function y1(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(y1,"normalizeWatchPath");function _1(t,e,r){let o=y1(relative(t,e));return o===""?true:o===".lock"||o===".lock.tmp"||o===".generate.lock"||o.endsWith("/.lock")||o.endsWith("/.lock.tmp")||o.endsWith("/.generate.lock")||o.includes("/.generate.lock/")||o.startsWith(".generate.lock/")}s(_1,"shouldIgnoreWatchPath");function I1(t,e,r,o,n,i,a,c,l){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:o,skillsCount:n,mcpServerCount:i,permissionsCount:a,hooksCount:c,ignoreCount:l})}s(I1,"featureFingerprint");async function Jv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{context:n}=await Tt(r,o),i=[n.canonicalDir,join(n.configDir,"agentsmesh.yaml"),join(n.configDir,"agentsmesh.local.yaml")],a=null,c=null,l=false,m=null,u=s(async()=>{if(l)return;a=null;let{config:O,context:R}=await Tt(r,o),{canonical:S}=await he(O,R.configDir,{},R.canonicalDir),A=S.mcp?Object.keys(S.mcp.mcpServers).length:0,D=S.permissions?S.permissions.allow.length+S.permissions.deny.length:0,N=S.hooks?Object.values(S.hooks).reduce((Ft,Gt)=>Ft+(Array.isArray(Gt)?Gt.length:0),0):0,G=S.ignore.length,J=I1(O.features,S.rules.length,S.commands.length,S.agents.length,S.skills.length,A,D,N,G),X=c!==null&&c!==J;if(c=J,l)return;let q=await rl(t,r,{printMatrix:false});if(ol(q),!l)if(X){let Ft=await Fm(t,r);Gm(Ft,{verbose:t.verbose===true});}else I.info("Regenerated.");},"run"),g=s(()=>{let O=u().catch(R=>{if(!l){let S=R instanceof Error?R.message:String(R);I.error(S);}}).finally(()=>{m===O&&(m=null);});m=O;},"scheduleRun"),f=s(()=>{l||(a&&clearTimeout(a),a=setTimeout(g,h1));},"schedule"),h=f1.watch(i,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(O,R)=>{_1(n.canonicalDir,R)||f();}),await new Promise((O,R)=>{h.once("ready",O),h.once("error",R);}),I.info(o==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=u(),await m,m=null,{stop:s(async()=>{l=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}s(Jv,"runWatch");Oe();np();async function Jd(t){let{config:e,configDir:r,canonicalDir:o}=t,n=await Dd(o);if(n===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await us(o),a=await $a(e,r),c=a.length>0?await qc(a):{},l=new Set(Object.keys(n.checksums)),m=new Set(Object.keys(i)),p=[],u=[],g=[];for(let S of l){let A=i[S];A===void 0?g.push(S):A!==n.checksums[S]&&p.push(S);}for(let S of m)l.has(S)||u.push(S);let f=new Set([...Object.keys(n.extends),...Object.keys(c)]),h=[];for(let S of f)c[S]!==n.extends[S]&&h.push(S);let O=Fd(n.checksums,i,e.collaboration?.lock_features??[]);return {inSync:p.length===0&&u.length===0&&g.length===0&&h.length===0,hasLock:true,modified:p,added:u,removed:g,extendsModified:h,lockedViolations:O}}s(Jd,"checkLockSync");ds();async function Yv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{config:n,context:i}=await Tt(r,o);await le(n,r);let a=await Jd({config:n,configDir:i.configDir,canonicalDir:i.canonicalDir});return a.hasLock?{exitCode:a.inSync?0:1,data:{hasLock:true,inSync:a.inSync,modified:[...a.modified],added:[...a.added],removed:[...a.removed],extendsModified:[...a.extendsModified],lockedViolations:[...a.lockedViolations]}}:{exitCode:1,data:{hasLock:false,inSync:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]}}}s(Yv,"runCheck");Oe();T();np();var S1=".lock",C1="<<<<<<<";async function EI(t){let e=join(t,S1),r=await y(e);return r===null?false:r.includes(C1)}s(EI,"hasLockConflict");async function Zv(t,e,r){if(!await EI(t))throw new Error("No conflict to resolve.");let n=await us(t),i=dirname(t),a=r?await $a(r,i):[],c=a.length>0?await qc(a):{},l=await vd(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await Nd(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:n,extends:c,packs:l});}s(Zv,"resolveLockConflict");async function Qv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{config:n,context:i}=await Tt(r,o),a=i.canonicalDir;return await EI(a)?(await Zv(a,gl(),n),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(Qv,"runMerge");Oe();T();Rl();var L1=promisify(execFile);function Yd(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(Yd,"ensureNotFlag");async function OI(t){let{stdout:e}=await L1("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(OI,"runGit");async function qv(){try{return await OI(["--version"]),!0}catch{return false}}s(qv,"isGitAvailable");async function A1(t,e){Yd(t,"remote-url"),Yd(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],o;for(let n of r)try{let a=(await OI(["ls-remote",t,n])).split(`
|
|
317
|
-
`).map(l=>l.trim()).find(l=>l.length>0);if(!a)continue;let c=a.split(/\s+/)[0];if(c&&/^[0-9a-f]{40}$/i.test(c))return c}catch(i){o=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${o instanceof Error?o.message:String(o)}`)}s(
|
|
318
|
-
`).find(a=>a.trim().length>0);if(!n)throw new Error(`Could not resolve HEAD for ${e}`);let i=n.split(/\s+/)[0];if(!i||!/^[0-9a-f]{40}$/i.test(i))throw new Error(`Invalid ls-remote HEAD line for ${e}`);return i.toLowerCase()}return A1(e,r)}s(tG,"resolveRemoteRefForInstall");async function eG(t){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};let e=t.gitRemoteUrl;if(!e)throw new Error("Internal error: missing git remote URL");let r=await tG(t.rawRef||"HEAD",e);if(t.kind==="github"){let c=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Ma(c,"install",{cacheDir:Le(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}if(t.kind==="gitlab"){let c=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Ma(c,"install",{cacheDir:Le(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}let o=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${o}`;return {resolvedPath:(await Ma(i,"install",{cacheDir:Le(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(eG,"fetchInstallSource");async function rG(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await eG(t);return {resolvedPath:r.resolvedPath,sourceForYaml:r.sourceForYaml,version:r.version}}catch(r){let o=r instanceof Error?r.message:String(r),n=new Error(`Failed to fetch from ${e}: ${o}. Check your network connection and try again.`);throw r instanceof Error&&(n.cause=r),n}}s(rG,"resolveInstallResolvedPath");function LI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("tree");if(o<2||o+1>=r.length)return null;let n=r[0],i=r[1],a=r[o+1],c=r.slice(o+2).join("/");return !n||!i||!a?null:{org:n,repo:i,ref:a,path:c||""}}catch{return null}}s(LI,"parseGithubTreeUrl");function AI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("blob");if(o<2||o+1>=r.length)return null;let n=r[0],i=r[1],a=r[o+1],c=r.slice(o+2).join("/");return !n||!i||!a||!c?null:{org:n,repo:i,ref:a,path:c}}catch{return null}}s(AI,"parseGithubBlobUrl");function kI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("-");if(o<0||r[o+1]!=="tree")return null;let n=o+1;if(n+1>=r.length)return null;let i=r[n+1],a=r.slice(n+2).join("/"),c=r.slice(0,o);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i?null:{namespace:m,project:l,ref:i,path:a||""}}catch{return null}}s(kI,"parseGitlabTreeUrl");function wI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("-");if(o<0||r[o+1]!=="blob")return null;let n=o+1;if(n+1>=r.length)return null;let i=r[n+1],a=r.slice(n+2).join("/"),c=r.slice(0,o);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i||!a?null:{namespace:m,project:l,ref:i,path:a}}catch{return null}}s(wI,"parseGitlabBlobUrl");var k1=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function TI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.length>2||k1.has(r[1]))return null;let o=r[0],n=r[1];return {org:o,repo:n}}catch{return null}}s(TI,"parseGithubRepoUrl");function bI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.includes("-"))return null;let o=r[r.length-1],n=r.slice(0,-1).join("/");return !n||!o?null:{namespace:n,project:o}}catch{return null}}s(bI,"parseGitlabRepoUrl");function PI(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(PI,"parseGitSshGithub");function xI(t){let e=t.match(/^git@gitlab\.com:(.+?)(?:\.git)?$/i);if(!e)return null;let o=e[1].replace(/\.git$/i,"").split("/").filter(Boolean);if(o.length<2)return null;let n=o[o.length-1];return {namespace:o.slice(0,-1).join("/"),project:n}}s(xI,"parseGitSshGitlab");T();var b1=/^[A-Za-z]:[\\/]/,P1=/^[A-Za-z]:\//;function oG(...t){return t.some(e=>e.includes("\\")||b1.test(e))?win32:posix}s(oG,"pathApiFor");function jm(t){return t.replace(/\\/g,"/")}s(jm,"toPosixPath");function $m(t){return jm(t).replace(/^\/+|\/+$/g,"")}s($m,"normalizeInstallPathField");function Xd(t){let e=jm(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||P1.test(e)?e:`./${e}`}s(Xd,"normalizeLocalSourceForYaml");function ci(t){return {...t,source:t.source_kind==="local"?Xd(t.source):t.source,...t.path!==void 0?{path:$m(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>$m(e))}:{}}}s(ci,"normalizePersistedInstallPaths");function nG(t,e,r){let o=oG(t,e),n=o.normalize(t),i=o.normalize(e),a=$m(r),c=`${o.sep}.agentsmesh${o.sep}`,l=n.indexOf(c);if(l>=0){let p=n.slice(0,l),u=n.slice(l+c.length),g=$m(u),f=jm(o.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||g.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Xd(f)}}let m=jm(o.relative(i,n))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:n,localSourceForYaml:Xd(m)}}s(nG,"localParsedFromAbsPath");async function DI(t,e,r){let o=t.trim(),n=r?.trim().replace(/\\/g,"/")??"";if(o.startsWith("git+")){let l=o.lastIndexOf("#"),m=l<0?o:o.slice(0,l),p=l<0?"HEAD":o.slice(l+1),u=m.slice(4);return {kind:"git",rawRef:p,gitPlusBase:u,gitRemoteUrl:u,pathInRepo:n}}if(o.startsWith("https://")||o.startsWith("http://")){let l=LI(o)??AI(o);if(l)return {kind:"github",rawRef:l.ref,org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:n||l.path};let m=TI(o);if(m)return {kind:"github",rawRef:"HEAD",org:m.org,repo:m.repo,gitRemoteUrl:`https://github.com/${m.org}/${m.repo}.git`,pathInRepo:n};let p=kI(o)??wI(o);if(p)return {kind:"gitlab",rawRef:p.ref,org:p.namespace,repo:p.project,gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:n||p.path};let u=bI(o);if(u)return {kind:"gitlab",rawRef:"HEAD",org:u.namespace,repo:u.project,gitRemoteUrl:`https://gitlab.com/${u.namespace}/${u.project}.git`,pathInRepo:n}}if(o.startsWith("git@github.com:")){let l=PI(o);if(!l)throw new Error(`Invalid GitHub SSH URL: ${o}`);return {kind:"github",rawRef:"HEAD",org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:n}}if(o.startsWith("git@gitlab.com:")){let l=xI(o);if(!l)throw new Error(`Invalid GitLab SSH URL: ${o}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${l.namespace}/${l.project}.git`,pathInRepo:n}}if(o.startsWith("git@")){let l=o.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!l)throw new Error(`Invalid SSH git URL: ${o}`);let m=l[1],p=l[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${p}.git`,pathInRepo:n}}let i=o.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let l=i[1],m=i[2];return {kind:"github",rawRef:i[3],org:l,repo:m,gitRemoteUrl:`https://github.com/${l}/${m}.git`,pathInRepo:n}}let a=o.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let l=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:l,repo:m,gitRemoteUrl:`https://gitlab.com/${l}/${m}.git`,pathInRepo:n}}let c=resolve(e,o);if(!await j(c))throw new Error(`Path does not exist: ${c}`);return nG(c,e,n)}s(DI,"parseInstallSource");T();ft();gn();T();wd();var sG=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:z$1.enum(["github","gitlab","git","local"]),features:z$1.array(va).min(1),pick:hl.optional(),target:ze.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:Qc.optional()}),v1=z$1.object({version:z$1.literal(1),installs:z$1.array(sG).default([])});function G1(t,e){return t.length===e.length&&[...t].sort().every((r,o)=>r===[...e].sort()[o])}s(G1,"sameFeatures");function M1(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&G1(t.features,e.features)}s(M1,"sameInstallIdentity");function iG(t){return join(t,"installs.yaml")}s(iG,"manifestPath");async function NI(t){let e=await y(iG(t));if(e===null)return [];try{return v1.parse(parse(e)).installs.map(r=>ci(r))}catch{return []}}s(NI,"readInstallManifest");async function aG(t,e){let r=ci(e),n=(await NI(t)).filter(i=>i.name!==r.name&&!M1(i,r));n.push(r),await _(iG(t),stringify({version:1,installs:n.sort((i,a)=>i.name.localeCompare(a.name))}));}s(aG,"upsertInstallManifestEntry");function cG(t){return ci(sG.parse({name:t.name,source:t.source,version:t.version,source_kind:t.sourceKind,features:t.features,pick:t.pick,target:t.target,path:t.path,paths:t.paths,as:t.as}))}s(cG,"buildInstallManifestEntry");async function j1(t){let e=await NI(t.canonicalDir);if(e.length===0){I.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let o of e){let n=join(t.canonicalDir,"packs",o.name);await j(n)||r.push(o);}if(r.length===0){I.info("All recorded packs are already installed.");return}for(let o of r)await t.reinstall(o);I.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(j1,"syncInstalledPacks");async function lG(t){return t.sync?(await j1({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(lG,"maybeRunInstallSync");wd();function mG(t){return {sync:t.sync===true,dryRun:t["dry-run"]===true,force:t.force===true,useExtends:t.extends===true,explicitPath:typeof t.path=="string"?t.path:void 0,explicitTarget:typeof t.target=="string"?t.target.trim():void 0,explicitAs:typeof t.as=="string"?Qc.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(mG,"readInstallFlags");M_();function La(t){let e=[];return t.skills.length&&e.push("skills"),t.rules.length&&e.push("rules"),t.commands.length&&e.push("commands"),t.agents.length&&e.push("agents"),t.mcp!==null&&e.push("mcp"),t.permissions!==null&&e.push("permissions"),t.hooks!==null&&e.push("hooks"),t.ignore.length&&e.push("ignore"),e}s(La,"featuresFromCanonical");async function Zd(t){let{sliceRoot:e,implicitPick:r}=await Ld(t),o=await Ad(e);return {canonical:o,features:La(o),implicitPick:r}}s(Zd,"discoverFromContentRoot");function pG(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(pG,"validateSkill");function uG(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(uG,"validateRule");function dG(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(dG,"validateCommand");function gG(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(gG,"validateAgent");function Ce(t){return basename(t.source).replace(/\.md$/i,"")}s(Ce,"ruleSlug");function K1(t){if(!t)return;let e=[];return t.skills!==void 0&&e.push("skills"),t.rules!==void 0&&e.push("rules"),t.commands!==void 0&&e.push("commands"),t.agents!==void 0&&e.push("agents"),e.length>0?e:void 0}s(K1,"featuresFromImplicitPick");function sl(t,e){let{implicitPick:r}=e,o=e.scopedFeatures??K1(r);if(!r&&!o)return t;let n=new Set(o??[]),i={...t,mcp:!o||n.has("mcp")?t.mcp:null,permissions:!o||n.has("permissions")?t.permissions:null,hooks:!o||n.has("hooks")?t.hooks:null,ignore:!o||n.has("ignore")?t.ignore:[]};if(r?.skills!==void 0){let a=new Set(r.skills);i={...i,skills:r.skills.length===0?[]:i.skills.filter(c=>a.has(c.name))};}else o&&!n.has("skills")&&(i={...i,skills:[]});if(r?.rules!==void 0){let a=new Set(r.rules);i={...i,rules:r.rules.length===0?[]:i.rules.filter(c=>a.has(Ce(c)))};}else o&&!n.has("rules")&&(i={...i,rules:[]});if(r?.commands!==void 0){let a=new Set(r.commands);i={...i,commands:r.commands.length===0?[]:i.commands.filter(c=>a.has(c.name))};}else o&&!n.has("commands")&&(i={...i,commands:[]});if(r?.agents!==void 0){let a=new Set(r.agents);i={...i,agents:r.agents.length===0?[]:i.agents.filter(c=>a.has(c.name))};}else o&&!n.has("agents")&&(i={...i,agents:[]});return i}s(sl,"narrowDiscoveredForInstallScope");T();Od();T();M();var H1=new Set(["README.md","README.rst","README.txt","README","LICENSE","LICENSE.md","LICENSE.txt","LICENSE-MIT","LICENSE-APACHE","CONTRIBUTING.md","CHANGELOG.md","CODE_OF_CONDUCT.md","package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]),z1=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function Qd(t){let e=await y(t);if(!e)return "";let{frontmatter:r}=k(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Qd,"readSkillFrontmatterName");async function fG(t,e){await cp$1(t,e,{recursive:true,filter:s(r=>{let o=relative(t,r).replace(/\\/g,"/");if(o==="")return true;let n=o.split("/")[0];return !(z1.has(n)||!o.includes("/")&&H1.has(o))},"filter")});}s(fG,"cpFilteredSkill");async function Z1(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await L(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:s(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}s(Z1,"createStageRoot");async function Q1(t,e){if((await stat(t)).isFile()){if(!t.toLowerCase().endsWith(".md"))throw new Error(`Manual install only supports .md files for this collection: ${t}`);await L(e),await cp$1(t,join(e,basename(t)));return}let o=(await v(t)).filter(i=>i.toLowerCase().endsWith(".md"));if(o.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let n=new Map;await L(e);for(let i of o){let a=basename(i),c=n.get(a);if(c)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${c} and ${i}).`);n.set(a,i),await cp$1(i,join(e,a));}}s(Q1,"stageMarkdownCollection");async function hG(t,e,r){if(r.length===0)return false;let o=new Set(r),n=new Map;for(let i of await v(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),c=basename(a);if(!o.has(c))continue;let l=n.get(c);if(l&&l!==a)throw new Error(`Manual skill replay found duplicate skill "${c}" under ${t} (${l} and ${a}).`);n.set(c,a);}if(n.size!==r.length)return false;await L(e);for(let i of r)await cp$1(n.get(i),join(e,i),{recursive:true});return true}s(hG,"stagePreferredSkills");async function q1(t,e,r={}){if((await stat(t)).isFile()){if(basename(t)!=="SKILL.md")throw new Error(`Manual skill install expects SKILL.md or a skill directory: ${t}`);let n=basename(dirname(t)),i=join(e,n);await L(i),await cp$1(dirname(t),i,{recursive:true});return}if(await Ea(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await hG(t,e,r.preferredSkillNames??[]))return;let c=await Qd(join(t,"SKILL.md"))||basename(t),l=join(e,c);await L(e),await fG(t,l);return}if(await hG(t,e,r.preferredSkillNames??[]))return;await L(e);let n=await v(t),i=new Set;for(let a of n.filter(c=>c.endsWith("/SKILL.md")||c.endsWith("\\SKILL.md")))i.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of i)await cp$1(join(t,a),join(e,a),{recursive:true});return}throw new Error(`Manual skill install expects a skill directory or skills collection at ${t}.`)}s(q1,"stageSkills");async function yG(t,e,r={}){let o=await Z1();try{let n=join(o.discoveryRoot,".agentsmesh",e);return e==="skills"?await q1(t,n,r):await Q1(t,n),o}catch(n){throw await o.cleanup(),n}}s(yG,"stageManualInstallScope");async function _G(t,e,r,o){let n=await yG(t,e,{preferredSkillNames:e==="skills"?o?.skills:void 0}),{canonical:i}=await Zd(n.discoveryRoot),a=sl(i,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:n.cleanup},narrowed:a,discoveredFeatures:La(a)}}s(_G,"resolveManualDiscoveredForInstall");gn();jg();T();var tY=[{prefix:".gemini/commands",target:"gemini-cli"},{prefix:".github/instructions",target:"copilot"},{prefix:".github/copilot-instructions.md",target:"copilot"},{prefix:".github/copilot",target:"copilot"},{prefix:".github/prompts",target:"copilot"},{prefix:".github/skills",target:"copilot"},{prefix:".github/agents",target:"copilot"},{prefix:".github/hooks",target:"copilot"},{prefix:".claude/commands",target:"claude-code"},{prefix:".claude/rules",target:"claude-code"},{prefix:".claude/skills",target:"claude-code"},{prefix:".claude/agents",target:"claude-code"},{prefix:".cursor/commands",target:"cursor"},{prefix:".cursor/rules",target:"cursor"},{prefix:".cursor/agents",target:"cursor"},{prefix:".cursor/skills",target:"cursor"},{prefix:".continue/prompts",target:"continue"},{prefix:".continue/rules",target:"continue"},{prefix:".continue/skills",target:"continue"},{prefix:".junie/commands",target:"junie"},{prefix:".junie/rules",target:"junie"},{prefix:".junie/agents",target:"junie"},{prefix:".junie/skills",target:"junie"},{prefix:".kiro/steering",target:"kiro"},{prefix:".kiro/skills",target:"kiro"},{prefix:".kilo/commands",target:"kilo-code"},{prefix:".kilo/rules",target:"kilo-code"},{prefix:".kilo/skills",target:"kilo-code"},{prefix:".kilo/agents",target:"kilo-code"},{prefix:".kilocode/workflows",target:"kilo-code"},{prefix:".kilocode/rules",target:"kilo-code"},{prefix:".kilocode/skills",target:"kilo-code"},{prefix:".kilocodemodes",target:"kilo-code"},{prefix:".kilocodeignore",target:"kilo-code"},{prefix:".cline/skills",target:"cline"},{prefix:".clinerules/workflows",target:"cline"},{prefix:".windsurf/rules",target:"windsurf"},{prefix:".codex",target:"codex-cli"}];function eY(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(eY,"norm");function tg(t){let e=eY(t),r=[...tY].sort((o,n)=>n.prefix.length-o.prefix.length);for(let{prefix:o,target:n}of r)if(e===o||e.startsWith(`${o}/`))return n}s(tg,"targetHintFromNativePath");function vI(t,e){return tg(t)===e}s(vI,"pathSupportsNativePick");function IG(t,e){if(!t||!e)return;let r=tg(e);if(r&&r!==t)throw new Error(`--target "${t}" does not match the install path (native path suggests "${r}"). Omit --target to auto-detect, or point at a subtree for that target.`)}s(IG,"validateTargetMatchesPath");function RG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(RG,"extendPickHasArrays");T();T();Wt();async function CG(t,e){let r=join(t,...Me.split("/")),o=join(t,...e.split("/")),n=await v(o),i=[];for(let a of n){if(!/\.(toml|md)$/i.test(a))continue;let c=relative(r,a).replace(/\\/g,"/");if(c.startsWith("..")||c==="")continue;let m=c.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(CG,"inferGeminiCommandNamesFromFiles");Wt();nr();T();async function Aa(t){let e=await v(t),r=new Set;for(let o of e){if(basename(o)==="SKILL.md"){r.add(basename(dirname(o)));continue}!relative(t,o).replace(/\\/g,"/").includes("/")&&o.toLowerCase().endsWith(".md")&&r.add(basename(o,".md"));}return [...r].filter(Boolean).sort()}s(Aa,"skillNamesFromNativeSkillDir");T();Sr();async function EG(t,e){let r=join(t,...e.split("/"));if(e.startsWith(Qs)){let o=await v(r),n=[...new Set(o.filter(i=>i.toLowerCase().endsWith(".prompt.md")).map(i=>basename(i,".prompt.md")))].sort();return n.length?{commands:n}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let o=await v(r),n=[...new Set(o.filter(i=>i.includes(".instructions.md")).map(i=>basename(i).replace(/\.instructions\.md$/i,"")))].sort();return n.length?{rules:n}:{}}if(e.startsWith(".github/instructions")){let o=await v(r),n=new Set;for(let a of o){let c=basename(a);c.toLowerCase().endsWith(".instructions.md")?n.add(c.replace(/\.instructions\.md$/i,"")):c.toLowerCase().endsWith(".md")&&n.add(basename(a,".md"));}let i=[...n].sort();return i.length?{rules:i}:{}}if(e.startsWith(".github/skills")){let o=await Aa(r);return o.length?{skills:o}:{}}if(e.startsWith(".github/agents")){let o=await v(r),n=[...new Set(o.filter(i=>i.toLowerCase().endsWith(".agent.md")).map(i=>basename(i,".agent.md")))].sort();return n.length?{agents:n}:{}}return {}}s(EG,"inferCopilotPickFromPath");async function Ke(t,e){let r=await v(t),o=e.toLowerCase();return [...new Set(r.filter(n=>n.toLowerCase().endsWith(o)).map(n=>basename(n,e)))].sort()}s(Ke,"mdNames");async function LG(t,e,r){let o=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),n=join(t,...o.split("/"));if(r==="gemini-cli"){if(o===Me||o.startsWith(`${Me}/`)){let i=await CG(t,o);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(o.startsWith(".claude/commands")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".claude/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".claude/agents")){let i=await Ke(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".claude/skills/")){let a=o.replace(/^\.claude\/skills\/?/,"").split("/").filter(Boolean)[0];return a?{skills:[a]}:{}}return {}}if(r==="cursor"){if(o.startsWith(".cursor/rules")){let i=await Ke(n,".mdc");return i.length?{rules:i}:{}}if(o.startsWith(".cursor/commands")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".cursor/agents")){let i=await Ke(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".cursor/skills")){let i=await Aa(n);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return EG(t,o);if(r==="windsurf"&&o.startsWith(".windsurf/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(o.startsWith(Jt)){let i=await Aa(n);return i.length?{skills:i}:{}}if(o.startsWith(Lo)){let i=await Ke(n,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(o.startsWith(".continue/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".continue/prompts")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".continue/skills")){let i=await Aa(n);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(o.startsWith(".junie/commands")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".junie/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".junie/agents")){let i=await Ke(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".junie/skills")){let i=await Aa(n);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&o.startsWith(".codex")){let i=await v(n),a=[...new Set(i.filter(c=>c.toLowerCase().endsWith(".md")).map(c=>basename(c,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(LG,"inferImplicitPickFromNativePath");function AG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(AG,"isImplicitPickEmpty");F_();function Bm(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(Bm,"normalizePath");function pY(t,e){let r=Bm(t),o=Bm(e);return r===o||r.startsWith(`${o}/`)||o.startsWith(`${r}/`)}s(pY,"overlapsPath");function eg(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(eg,"addUnique");async function uY(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),o=s(async()=>{await rm$1(e,{recursive:true,force:true});},"cleanup");try{return await cp$1(t,r,{recursive:!0}),{stageRoot:r,cleanup:o}}catch(n){throw await o(),n}}s(uY,"makeStageRoot");function dY(t,e){let r;for(let n of t){if(n.feature==="rules"&&n.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:eg(r?.rules,basename(n.toPath,".md"))};continue}if(n.feature==="commands"&&n.toPath.startsWith(".agentsmesh/commands/")){let i=Bm(relative(join(e,".agentsmesh","commands"),join(e,n.toPath)));r={...r,commands:eg(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(n.feature==="agents"&&n.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:eg(r?.agents,basename(n.toPath,".md"))};continue}if(n.feature==="skills"&&n.toPath.startsWith(".agentsmesh/skills/")){let a=Bm(relative(join(e,".agentsmesh","skills"),join(e,n.toPath))).split("/")[0];a&&(r={...r,skills:eg(r?.skills,a)});}}return r&&(r.rules?.length??0)+(r.commands?.length??0)+(r.agents?.length??0)+(r.skills?.length??0)>0?r:void 0}s(dY,"buildPickFromResults");function gY(t,e,r,o){let n=join(e,...Bm(t).split("/")),i=r.filter(a=>pY(n,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${o}".`);return {features:[...new Set(i.map(a=>a.feature))],pick:dY(i,e)}}s(gY,"scopeImportedResults");async function MI(t,e){let{stageRoot:r,cleanup:o}=await uY(t);try{let n=await wm(r,e);return {stageRoot:r,results:n,cleanup:o}}catch(n){throw await o(),n}}s(MI,"stageImportedNativeRepo");async function $I(t,e,r){let o=await MI(t,r);try{return {stageRoot:o.stageRoot,cleanup:o.cleanup,...gY(e,o.stageRoot,o.results,r)}}catch(n){throw await o.cleanup(),n}}s($I,"stageNativeInstallScope");async function bG(t,e,r,o){let n=o.explicitTarget?.trim();n&&ze.parse(n);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");IG(n,i);let a=join(t,".agentsmesh"),c=await j(a),l=i?tg(i):void 0,m=!c&&!n?await fp(t)??void 0:void 0;if(!n&&l&&m&&l!==m)throw new Error(`Install path suggests native layout "${l}" but auto-detect imported "${m}". Use --target ${l} for this path, or install from the repo root without a conflicting subtree path.`);let p=n??l??m,u=!!i&&!!p&&!i.startsWith(".agentsmesh");if(!c&&p){if(u){let A=await $I(t,i,p);return {discoveryRoot:A.stageRoot,implicitPick:A.pick,scopedFeatures:A.features,yamlTarget:p,importHappened:true,cleanup:A.cleanup}}let S=await MI(t,p);return {discoveryRoot:i?join(S.stageRoot,i):S.stageRoot,yamlTarget:p,importHappened:true,cleanup:S.cleanup}}let g;c?i?p&&vI(i,p)?g=t:g=e:g=t:g=e;let f,h,O;if(u&&p){let S=await $I(t,i,p);g=S.stageRoot,f=S.pick,h=S.features,O=S.cleanup;}else if(g===t&&i&&p&&vI(i,p)&&(f=await LG(t,i,p),AG(f)))throw new Error(`No installable native resources found under "${i}" for target "${p}".`);let R;return n?R=n:p&&(f&&RG(f)||(h?.length??0)>0)&&(R=p),{discoveryRoot:g,implicitPick:f,scopedFeatures:h,yamlTarget:R,importHappened:O!==void 0,cleanup:O}}s(bG,"prepareInstallDiscovery");async function PG(t,e,r,o){let n=await bG(t,e,r,{explicitTarget:o}),{canonical:i,implicitPick:a}=await Zd(n.discoveryRoot),c=a??n.implicitPick,l=sl(i,{implicitPick:c,scopedFeatures:n.scopedFeatures}),m=La(l);return {prep:n,discovered:i,implicitPick:c,narrowed:l,discoveredFeatures:m}}s(PG,"resolveDiscoveredForInstall");async function xG(t){return t.explicitAs?{implicitPick:void 0,...await _G(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:PG(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}s(xG,"resolveInstallDiscovery");function al(t){return t==="."||t===""?void 0:t}s(al,"trimDot");function hY(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(hY,"markdownPick");async function NG(t){if(!t.as)return {pathInRepo:al(t.pathInRepo)};let e=t.pathInRepo.replace(/^\/+|\/+$/g,""),r=await stat(t.contentRoot);if(t.as!=="skills"&&r.isFile()&&t.contentRoot.toLowerCase().endsWith(".md"))return {pathInRepo:al(dirname(e)),pick:hY(t.as,e||t.contentRoot)};if(t.as==="skills"){if(r.isFile()&&basename(t.contentRoot)==="SKILL.md"){let o=e?dirname(e):dirname(t.contentRoot);return {pathInRepo:al(dirname(o)),pick:{skills:[basename(o)]}}}if(r.isDirectory()){let o=e||basename(t.contentRoot),n=join(t.contentRoot.replace(/\/+$/g,""),"SKILL.md");try{if((await stat(n)).isFile()){let a=await Qd(n);return {pathInRepo:al(dirname(o)),pick:{skills:[a||basename(o)]}}}}catch{return {pathInRepo:al(e)}}}}return {pathInRepo:al(e)}}s(NG,"resolveManualInstallPersistence");ln();ft();async function mn(t){return process.stdin.isTTY?new Promise(e=>{let r=FG.createInterface({input:process.stdin,output:process.stdout});r.question(`${t} (y/n) `,o=>{r.close();let n=o.trim().toLowerCase();e(n==="y"||n==="yes");});}):false}s(mn,"confirm");function yY(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(yY,"hasArrayResources");function vG(t){return yY(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(vG,"hasInstallableResources");async function GG(t,e,r,o){let n=t.skills.map(c=>pG(c)),i=n.filter(c=>c.ok).map(c=>c.skill),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await mn(`Include invalid skill "${c.skill.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.skill);else e&&(i=n.map(c=>c.skill));return r&&(i=n.filter(c=>c.ok).map(c=>c.skill)),i}s(GG,"resolveSkillPool");async function MG(t,e,r,o){let n=t.rules.map(c=>uG(c)),i=n.filter(c=>c.ok).map(c=>c.rule),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await mn(`Include invalid rule "${Ce(c.rule)}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.rule);else e&&(i=n.map(c=>c.rule));return r&&(i=n.filter(c=>c.ok).map(c=>c.rule)),i}s(MG,"resolveRulePool");async function $G(t,e,r,o){let n=t.commands.map(c=>dG(c)),i=n.filter(c=>c.ok).map(c=>c.command),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await mn(`Include invalid command "${c.command.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.command);else e&&(i=n.map(c=>c.command));return r&&(i=n.filter(c=>c.ok).map(c=>c.command)),i}s($G,"resolveCommandPool");async function jG(t,e,r,o){let n=t.agents.map(c=>gG(c)),i=n.filter(c=>c.ok).map(c=>c.agent),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await mn(`Include invalid agent "${c.agent.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.agent);else e&&(i=n.map(c=>c.agent));return r&&(i=n.filter(c=>c.ok).map(c=>c.agent)),i}s(jG,"resolveAgentPool");async function UG(t,e){let r=e.skills.map(a=>a.name),o=e.rules.map(a=>Ce(a)),n=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(c=>c.name===a.name)&&(await mn(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(l=>l!==a.name)));for(let a of e.rules){let c=Ce(a);t.rules.some(l=>Ce(l)===c)&&(await mn(`Rule "${c}" already exists in merged config. Add extend anyway?`)||(o=o.filter(m=>m!==c)));}for(let a of e.commands)t.commands.some(c=>c.name===a.name)&&(await mn(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(n=n.filter(l=>l!==a.name)));for(let a of e.agents)t.agents.some(c=>c.name===a.name)&&(await mn(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(l=>l!==a.name)));return {skillNames:r,ruleSlugs:o,commandNames:n,agentNames:i}}s(UG,"resolveInstallConflicts");function KG(t,e){if(!t)return;let r={},o=t.skills?.filter(c=>e.skillNames.includes(c)),n=t.rules?.filter(c=>e.ruleSlugs.includes(c)),i=t.commands?.filter(c=>e.commandNames.includes(c)),a=t.agents?.filter(c=>e.agentNames.includes(c));return o&&o.length>0&&(r.skills=o),n&&n.length>0&&(r.rules=n),i&&i.length>0&&(r.commands=i),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}s(KG,"pickForSelectedResources");function _Y(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(_Y,"pathEndsWithName");function rg(t,e,r){return r!==1||e.length!==1?false:_Y(t,e[0])}s(rg,"inferSingleNamePick");function BG(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:o,selected:n}=t,i={},a=n.skillNames.length>0&&(!!r?.skills?.length||n.skillNames.length<o.skills||rg(e,n.skillNames,o.skills)),c=n.ruleSlugs.length>0&&(!!r?.rules?.length||n.ruleSlugs.length<o.rules||rg(e,n.ruleSlugs,o.rules)),l=n.commandNames.length>0&&(!!r?.commands?.length||n.commandNames.length<o.commands||rg(e,n.commandNames,o.commands)),m=n.agentNames.length>0&&(!!r?.agents?.length||n.agentNames.length<o.agents||rg(e,n.agentNames,o.agents));return a&&(i.skills=[...n.skillNames]),c&&(i.rules=[...n.ruleSlugs]),l&&(i.commands=[...n.commandNames]),m&&(i.agents=[...n.agentNames]),Object.keys(i).length?i:void 0}s(BG,"buildInstallPick");function WG(t,e){let r=new Set(t);return e.skillNames.length===0&&r.delete("skills"),e.ruleSlugs.length===0&&r.delete("rules"),e.commandNames.length===0&&r.delete("commands"),e.agentNames.length===0&&r.delete("agents"),[...r]}s(WG,"deriveInstallFeatures");function IY(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(IY,"isEmptyInstallSelection");function HG(t){let{selected:e,discoveredFeatures:r,preConflict:o}=t,n=s(c=>r.includes(c),"had"),i=n("skills")&&e.skillNames.length===0&&o.skills>0&&"skills"||n("rules")&&e.ruleSlugs.length===0&&o.rules>0&&"rules"||n("commands")&&e.commandNames.length===0&&o.commands>0&&"commands"||n("agents")&&e.agentNames.length===0&&o.agents>0&&"agents";if(i)throw new Error(`No ${i} selected to install.`);let a=r.some(c=>["mcp","permissions","hooks","ignore"].includes(c));if(IY(e)&&!a)throw new Error("No resources selected to install.")}s(HG,"ensureInstallSelection");gn();function zG(t,e){if(t.find(o=>o.name===e.name&&o.source!==e.source))throw new Error(`Extends entry "${e.name}" already exists with a different source. Use --name to provide a different name.`)}s(zG,"assertExtendNameAvailable");function RY(t,e,r){if(r===void 0){if(!t)return;let n={...t};for(let i of ["skills","commands","rules","agents"])e.includes(i)&&delete n[i];return Object.keys(n).length?n:void 0}let o={...t};for(let n of ["skills","commands","rules","agents"]){if(!(n in r))continue;let i=r[n];if(i===void 0||i.length===0){delete o[n];continue}o[n]=[...new Set([...t?.[n]??[],...i])];}return Object.keys(o).length?o:void 0}s(RY,"mergePick");function VG(t,e){let r=t.findIndex(a=>a.source===e.source);if(r<0)return [...t,{name:e.name,source:e.source,version:e.version,features:e.features,path:e.path,pick:e.pick,target:e.target}];let o=t[r],n=[...new Set([...o.features,...e.features])],i=RY(o.pick,e.features,e.pick);return t.map((a,c)=>c===r?{name:e.name,source:e.source,version:e.version??o.version,features:n,path:e.path!==void 0?e.path:o.path,pick:i,target:e.target??o.target}:a)}s(VG,"mergeExtendList");T();async function JG(t,e,r){let o=await y(t);if(o===null)throw new Error(`Missing config: ${t}`);let n=parse(o),i=VG(e.extends,r);n.extends=i;let a=stringify(n,{indent:2,lineWidth:0});await _(t,a.endsWith(`
|
|
316
|
+
`),false}}s(hI,"seedAgentsmeshMcpEntry");function Dv(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(Dv,"mapResults");async function Nv(t,e){let r=e??process.cwd(),o=t.from;if(typeof o!="string"||!o)throw new Error("--from is required. Example: agentsmesh import --from claude-code");let n=o.toLowerCase().trim(),i=t.global===true?"global":"project";if(wr(n)){let p=fl(r,i),g=await Kd(n).importFrom(p.rootBase,{scope:i});return g.length>0&&await hI(p.rootBase),{exitCode:0,data:{scope:i,target:n,files:Dv(g,p.rootBase)}}}let a,c;try{({config:a,context:c}=await Tt(r,i));}catch{throw new Error(`Unknown --from "${o}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${kt.join(", ")}.`)}await ce(a,r);let l=ut(n);if(!l)throw new Error(`Unknown --from "${o}". Supported: ${[...kt,...a.pluginTargets??[]].join(", ")}.`);let m=await l.generators.importFrom(c.rootBase,{scope:i});return m.length>0&&await hI(c.rootBase),{exitCode:0,data:{scope:i,target:n,files:Dv(m,c.rootBase)}}}s(Nv,"runImport");Oe();sn();function Bd(t){let e=[],r={new:0,updated:0,unchanged:0,deleted:0};for(let o of t){if(o.status==="unchanged"){r.unchanged++;continue}if(o.status==="created"){r.new++;let n=createTwoFilesPatch(`${o.path} (current)`,`${o.path} (generated)`,"",o.content,void 0,void 0,{context:3});e.push({path:o.path,patch:n});continue}if(o.status==="updated"&&o.currentContent!==void 0){r.updated++;let n=createTwoFilesPatch(`${o.path} (current)`,`${o.path} (generated)`,o.currentContent,o.content,void 0,void 0,{context:3});e.push({path:o.path,patch:n});continue}}return {diffs:e,summary:r}}s(Bd,"computeDiff");function Wd(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(Wd,"formatDiffSummary");ms();async function vv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(f=>f.trim()).filter(Boolean):void 0,{config:a,context:c}=await Tt(r,o);await ce(a,r);let{canonical:l}=await he(a,c.configDir,{},c.canonicalDir),m=await Or({config:a,canonical:l,projectRoot:c.rootBase,scope:o,targetFilter:i});if(m.length===0)return {exitCode:0,data:{files:[],patches:[],summary:{created:0,updated:0,unchanged:0,deleted:0}}};let{diffs:p,summary:d}=Bd(m);return {exitCode:0,data:{files:m.filter(f=>f.status!=="unchanged"&&f.status!=="skipped").map(f=>({path:f.path,target:f.target,status:f.status})),patches:p.map(f=>({path:f.path,patch:f.patch})),summary:{created:d.new,updated:d.updated,unchanged:d.unchanged,deleted:d.deleted}}}}s(vv,"runDiff");Oe();sn();T();je();_i();Et();var c1=[{canonicalKey:"permissions",capabilityKey:"permissions",featureFlag:"permissions",file:".agentsmesh/permissions.yaml",label:"permissions",hasContent:s(t=>{let e=t.permissions;if(!e)return false;let r=e.ask?.length??0;return e.allow.length+e.deny.length+r>0},"hasContent")},{canonicalKey:"hooks",capabilityKey:"hooks",featureFlag:"hooks",file:".agentsmesh/hooks.yaml",label:"hooks",hasContent:s(t=>{let e=t.hooks;return e?Object.values(e).some(r=>Array.isArray(r)&&r.length>0):false},"hasContent")},{canonicalKey:"mcp",capabilityKey:"mcp",featureFlag:"mcp",file:".agentsmesh/mcp.json",label:"MCP servers",hasContent:s(t=>{let e=t.mcp;return e?Object.keys(e.mcpServers).length>0:false},"hasContent")},{canonicalKey:"commands",capabilityKey:"commands",featureFlag:"commands",file:".agentsmesh/commands",label:"commands",hasContent:s(t=>t.commands.length>0,"hasContent")},{canonicalKey:"agents",capabilityKey:"agents",featureFlag:"agents",file:".agentsmesh/agents",label:"agents",hasContent:s(t=>t.agents.length>0,"hasContent")},{canonicalKey:"skills",capabilityKey:"skills",featureFlag:"skills",file:".agentsmesh/skills",label:"skills",hasContent:s(t=>t.skills.length>0,"hasContent")},{canonicalKey:"ignore",capabilityKey:"ignore",featureFlag:"ignore",file:".agentsmesh/ignore",label:"ignore patterns",hasContent:s(t=>t.ignore.length>0,"hasContent")}];function Gv(t){let e=new Set(t.enabledFeatures),r=[];for(let o of c1)!e.has(o.featureFlag)||!o.hasContent(t.canonical)||xr(t.capabilities[o.capabilityKey]).level!=="none"||r.push(b(o.file,t.target,`${t.target} does not support ${o.label}; canonical entries are silently dropped during generation. Disable the feature for this target or remove the canonical content.`));return r}s(Gv,"lintSilentFeatureDrops");Et();var l1=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function m1(t){let r=t.match(l1)?.groups?.path;return typeof r=="string"?r:null}s(m1,"extractScriptToken");function Mv(t){if(t.hasScriptProjection)return [];let e=t.canonical.hooks;if(!e)return [];let r=[];for(let o of Object.values(e))if(Array.isArray(o))for(let n of o){if(typeof n?.command!="string")continue;let i=m1(n.command);i&&r.push(b(".agentsmesh/hooks.yaml",t.target,`${t.target} hook command references script "${i}"; agentsmesh does not copy hook scripts into ${t.target} output, so the script must already exist relative to the hook execution directory or the generated config will fail.`));}return r}s(Mv,"lintHookScriptReferences");Et();function $v(t){if(t.preservesManualActivation)return [];let e=[];for(let r of t.canonical.rules)r.root||r.trigger==="manual"&&(r.targets.length>0&&!r.targets.includes(t.target)||e.push(b(r.source,t.target,`Rule has trigger: 'manual' (Cursor-style "@-mention only" activation), but ${t.target} loads every rule unconditionally. The rule will become always-on for ${t.target} \u2014 restrict it with \`targets: [cursor]\`, convert it to a skill with manual invocation, or remove it.`)));return e}s($v,"lintRuleScopeInversion");var p1=["node_modules",".git","dist","coverage",".agentsmesh"];async function u1(t){return (await N(t)).filter(o=>{let n=relative(t,o);return !p1.some(i=>n.includes(`/${i}/`)||n.startsWith(`${i}/`))}).map(o=>relative(t,o))}s(u1,"getProjectFiles");async function Hd(t,e,r,o,n={}){let i=n.scope??"project",a=[...t.targets,...t.pluginTargets??[]],c=o?a.filter(R=>o.includes(R)):a,l=t.features.includes("rules"),m=t.features.includes("commands"),p=t.features.includes("mcp"),d=t.features.includes("permissions"),g=t.features.includes("hooks"),f=[],h=i==="global"?[]:await u1(r);for(let R of c){let E=ut(R),A=wr(R)?Kd(R):E;A?.capabilities&&f.push(...Gv({target:R,capabilities:A.capabilities,canonical:e,enabledFeatures:t.features})),g&&f.push(...Mv({target:R,canonical:e,hasScriptProjection:E?.postProcessHookOutputs!==void 0})),l&&f.push(...$v({target:R,canonical:e,preservesManualActivation:E?.preservesManualActivation===true})),l&&A?.lintRules&&f.push(...A.lintRules(e,r,h,{scope:i})),E?.generators.lint&&f.push(...E.generators.lint(e));let F={scope:i};m&&A?.lint?.commands&&f.push(...A.lint.commands(e,F)),p&&A?.lint?.mcp&&f.push(...A.lint.mcp(e,F)),d&&A?.lint?.permissions&&f.push(...A.lint.permissions(e,F)),g&&A?.lint?.hooks&&f.push(...A.lint.hooks(e,F));}let O=f.some(R=>R.level==="error");return {diagnostics:f,hasErrors:O}}s(Hd,"runLint");ms();async function Uv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(d=>d.trim()).filter(Boolean):void 0,{config:a,context:c}=await Tt(r,o);await ce(a,r);let{canonical:l}=await he(a,c.configDir,{},c.canonicalDir),{diagnostics:m,hasErrors:p}=await Hd(a,l,c.configDir,i,{scope:o});return {exitCode:p?1:0,data:{diagnostics:m.map(d=>({level:d.level,file:d.file,target:d.target,message:d.message})),summary:{errors:m.filter(d=>d.level==="error").length,warnings:m.filter(d=>d.level==="warning").length}}}}s(Uv,"runLintCmd");ft();function Kv(t){let{data:e}=t;if(e.diagnostics.length===0){_.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),o=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)_.error(`${a.file} (${a.target}): ${a.message}`);for(let a of o)_.warn(`${a.file} (${a.target}): ${a.message}`);let n=e.summary.errors,i=e.summary.warnings;_.info(`${n} error${n!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(Kv,"renderLint");ft();function Bv(t){let{data:e}=t;if(!e.hasLock){_.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){_.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);_.error("Conflict detected:");for(let o of e.extendsModified)_.error(` extend "${o}" was modified`);for(let o of e.modified){let n=r.has(o)?" [LOCKED]":"";_.error(` ${o} was modified${n}`);}for(let o of e.added){let n=r.has(o)?" [LOCKED]":"";_.error(` ${o} was added${n}`);}for(let o of e.removed){let n=r.has(o)?" [LOCKED]":"";_.error(` ${o} was removed${n}`);}_.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(Bv,"renderCheck");ft();function Wv(t){let{data:e}=t;if(e.files.length===0){_.info(`Nothing to import from ${e.target}.`);return}for(let o of e.files)_.success(`${o.from} \u2192 ${o.to}`);let r=e.scope==="global"?" --global":"";_.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(Wv,"renderImport");ft();function Hv(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){_.info("No files to generate (no root rule or rules feature disabled).");return}for(let o of t.data.patches)process.stdout.write(o.patch);_.info(Wd({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(Hv,"renderDiff");ft();function zv(t){if(!t.data.hadConflict){_.info("No conflicts to resolve.");return}_.success("Lock file conflict resolved.");}s(zv,"renderMerge");vm();Mm();Oe();sn();vm();Mm();ft();var f1=300;function h1(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(h1,"normalizeWatchPath");function y1(t,e){let r=h1(relative(t,e));return r===""?true:r===".lock"||r===".lock.tmp"||r===".generate.lock"||r.endsWith("/.lock")||r.endsWith("/.lock.tmp")||r.endsWith("/.generate.lock")||r.includes("/.generate.lock/")||r.startsWith(".generate.lock/")}s(y1,"shouldIgnoreWatchPath");function _1(t,e,r,o,n,i,a,c,l){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:o,skillsCount:n,mcpServerCount:i,permissionsCount:a,hooksCount:c,ignoreCount:l})}s(_1,"featureFingerprint");async function Jv(t,e,r={}){let o=e??process.cwd(),n=t.global===true?"global":"project",{context:i}=await Tt(o,n),a=[i.canonicalDir,join(i.configDir,"agentsmesh.yaml"),join(i.configDir,"agentsmesh.local.yaml")],c=null,l=null,m=false,p=null,d=s(async()=>{if(m)return;c=null;let{config:O,context:R}=await Tt(o,n),{canonical:E}=await he(O,R.configDir,{},R.canonicalDir),A=E.mcp?Object.keys(E.mcp.mcpServers).length:0,F=E.permissions?E.permissions.allow.length+E.permissions.deny.length:0,v=E.hooks?Object.values(E.hooks).reduce((Ft,Gt)=>Ft+(Array.isArray(Gt)?Gt.length:0),0):0,G=E.ignore.length,J=_1(O.features,E.rules.length,E.commands.length,E.agents.length,E.skills.length,A,F,v,G),Y=l!==null&&l!==J;if(l=J,m)return;let q=await tl(t,o,{printMatrix:false});if(el(q),!m){if(Y){let Ft=await Fm(t,o);Gm(Ft,{verbose:t.verbose===true});}else _.info("Regenerated.");r.onCycle?.({featuresChanged:Y});}},"run"),g=s(()=>{let O=d().catch(R=>{if(!m){let E=R instanceof Error?R.message:String(R);_.error(E);}}).finally(()=>{p===O&&(p=null);});p=O;},"scheduleRun"),f=s(()=>{m||(c&&clearTimeout(c),c=setTimeout(g,f1));},"schedule"),h=g1.watch(a,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(O,R)=>{y1(i.canonicalDir,R)||f();}),await new Promise((O,R)=>{h.once("ready",O),h.once("error",R);}),_.info(n==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),p=d(),await p,p=null,{stop:s(async()=>{m=true,c&&(clearTimeout(c),c=null),await h.close(),p&&await p;},"stop")}}s(Jv,"runWatch");Oe();np();async function zd(t){let{config:e,configDir:r,canonicalDir:o}=t,n=await Pd(o);if(n===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await ls(o),a=await va(e,r),c=a.length>0?await Zc(a):{},l=new Set(Object.keys(n.checksums)),m=new Set(Object.keys(i)),p=[],d=[],g=[];for(let E of l){let A=i[E];A===void 0?g.push(E):A!==n.checksums[E]&&p.push(E);}for(let E of m)l.has(E)||d.push(E);let f=new Set([...Object.keys(n.extends),...Object.keys(c)]),h=[];for(let E of f)c[E]!==n.extends[E]&&h.push(E);let O=Dd(n.checksums,i,e.collaboration?.lock_features??[]);return {inSync:p.length===0&&d.length===0&&g.length===0&&h.length===0,hasLock:true,modified:p,added:d,removed:g,extendsModified:h,lockedViolations:O}}s(zd,"checkLockSync");ms();async function Yv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{config:n,context:i}=await Tt(r,o);await ce(n,r);let a=await zd({config:n,configDir:i.configDir,canonicalDir:i.canonicalDir});return a.hasLock?{exitCode:a.inSync?0:1,data:{hasLock:true,inSync:a.inSync,modified:[...a.modified],added:[...a.added],removed:[...a.removed],extendsModified:[...a.extendsModified],lockedViolations:[...a.lockedViolations]}}:{exitCode:1,data:{hasLock:false,inSync:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]}}}s(Yv,"runCheck");Oe();T();np();var R1=".lock",S1="<<<<<<<";async function yI(t){let e=join(t,R1),r=await y(e);return r===null?false:r.includes(S1)}s(yI,"hasLockConflict");async function Zv(t,e,r){if(!await yI(t))throw new Error("No conflict to resolve.");let n=await ls(t),i=dirname(t),a=r?await va(r,i):[],c=a.length>0?await Zc(a):{},l=await Nd(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await xd(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:n,extends:c,packs:l});}s(Zv,"resolveLockConflict");async function Qv(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{config:n,context:i}=await Tt(r,o),a=i.canonicalDir;return await yI(a)?(await Zv(a,ul(),n),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(Qv,"runMerge");Oe();T();_l();var O1=promisify(execFile);function Vd(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(Vd,"ensureNotFlag");async function _I(t){let{stdout:e}=await O1("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(_I,"runGit");async function qv(){try{return await _I(["--version"]),!0}catch{return false}}s(qv,"isGitAvailable");async function L1(t,e){Vd(t,"remote-url"),Vd(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],o;for(let n of r)try{let a=(await _I(["ls-remote",t,n])).split(`
|
|
317
|
+
`).map(l=>l.trim()).find(l=>l.length>0);if(!a)continue;let c=a.split(/\s+/)[0];if(c&&/^[0-9a-f]{40}$/i.test(c))return c}catch(i){o=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${o instanceof Error?o.message:String(o)}`)}s(L1,"gitLsRemoteResolve");async function tG(t,e){Vd(e,"remote-url");let r=t===""?"HEAD":t;if(Vd(r,"ref"),/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let n=(await _I(["ls-remote",e,"HEAD"])).split(`
|
|
318
|
+
`).find(a=>a.trim().length>0);if(!n)throw new Error(`Could not resolve HEAD for ${e}`);let i=n.split(/\s+/)[0];if(!i||!/^[0-9a-f]{40}$/i.test(i))throw new Error(`Invalid ls-remote HEAD line for ${e}`);return i.toLowerCase()}return L1(e,r)}s(tG,"resolveRemoteRefForInstall");async function eG(t){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};let e=t.gitRemoteUrl;if(!e)throw new Error("Internal error: missing git remote URL");let r=await tG(t.rawRef||"HEAD",e);if(t.kind==="github"){let c=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Fa(c,"install",{cacheDir:Le(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}if(t.kind==="gitlab"){let c=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Fa(c,"install",{cacheDir:Le(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}let o=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${o}`;return {resolvedPath:(await Fa(i,"install",{cacheDir:Le(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(eG,"fetchInstallSource");async function rG(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await eG(t);return {resolvedPath:r.resolvedPath,sourceForYaml:r.sourceForYaml,version:r.version}}catch(r){let o=r instanceof Error?r.message:String(r),n=new Error(`Failed to fetch from ${e}: ${o}. Check your network connection and try again.`);throw r instanceof Error&&(n.cause=r),n}}s(rG,"resolveInstallResolvedPath");function II(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("tree");if(o<2||o+1>=r.length)return null;let n=r[0],i=r[1],a=r[o+1],c=r.slice(o+2).join("/");return !n||!i||!a?null:{org:n,repo:i,ref:a,path:c||""}}catch{return null}}s(II,"parseGithubTreeUrl");function RI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("blob");if(o<2||o+1>=r.length)return null;let n=r[0],i=r[1],a=r[o+1],c=r.slice(o+2).join("/");return !n||!i||!a||!c?null:{org:n,repo:i,ref:a,path:c}}catch{return null}}s(RI,"parseGithubBlobUrl");function SI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("-");if(o<0||r[o+1]!=="tree")return null;let n=o+1;if(n+1>=r.length)return null;let i=r[n+1],a=r.slice(n+2).join("/"),c=r.slice(0,o);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i?null:{namespace:m,project:l,ref:i,path:a||""}}catch{return null}}s(SI,"parseGitlabTreeUrl");function CI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("-");if(o<0||r[o+1]!=="blob")return null;let n=o+1;if(n+1>=r.length)return null;let i=r[n+1],a=r.slice(n+2).join("/"),c=r.slice(0,o);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i||!a?null:{namespace:m,project:l,ref:i,path:a}}catch{return null}}s(CI,"parseGitlabBlobUrl");var A1=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function EI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.length>2||A1.has(r[1]))return null;let o=r[0],n=r[1];return {org:o,repo:n}}catch{return null}}s(EI,"parseGithubRepoUrl");function OI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.includes("-"))return null;let o=r[r.length-1],n=r.slice(0,-1).join("/");return !n||!o?null:{namespace:n,project:o}}catch{return null}}s(OI,"parseGitlabRepoUrl");function LI(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(LI,"parseGitSshGithub");function AI(t){let e=t.match(/^git@gitlab\.com:(.+?)(?:\.git)?$/i);if(!e)return null;let o=e[1].replace(/\.git$/i,"").split("/").filter(Boolean);if(o.length<2)return null;let n=o[o.length-1];return {namespace:o.slice(0,-1).join("/"),project:n}}s(AI,"parseGitSshGitlab");T();var T1=/^[A-Za-z]:[\\/]/,b1=/^[A-Za-z]:\//;function oG(...t){return t.some(e=>e.includes("\\")||T1.test(e))?win32:posix}s(oG,"pathApiFor");function jm(t){return t.replace(/\\/g,"/")}s(jm,"toPosixPath");function $m(t){return jm(t).replace(/^\/+|\/+$/g,"")}s($m,"normalizeInstallPathField");function Jd(t){let e=jm(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||b1.test(e)?e:`./${e}`}s(Jd,"normalizeLocalSourceForYaml");function si(t){return {...t,source:t.source_kind==="local"?Jd(t.source):t.source,...t.path!==void 0?{path:$m(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>$m(e))}:{}}}s(si,"normalizePersistedInstallPaths");function nG(t,e,r){let o=oG(t,e),n=o.normalize(t),i=o.normalize(e),a=$m(r),c=`${o.sep}.agentsmesh${o.sep}`,l=n.indexOf(c);if(l>=0){let p=n.slice(0,l),d=n.slice(l+c.length),g=$m(d),f=jm(o.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||g.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Jd(f)}}let m=jm(o.relative(i,n))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:n,localSourceForYaml:Jd(m)}}s(nG,"localParsedFromAbsPath");async function kI(t,e,r){let o=t.trim(),n=r?.trim().replace(/\\/g,"/")??"";if(o.startsWith("git+")){let l=o.lastIndexOf("#"),m=l<0?o:o.slice(0,l),p=l<0?"HEAD":o.slice(l+1),d=m.slice(4);return {kind:"git",rawRef:p,gitPlusBase:d,gitRemoteUrl:d,pathInRepo:n}}if(o.startsWith("https://")||o.startsWith("http://")){let l=II(o)??RI(o);if(l)return {kind:"github",rawRef:l.ref,org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:n||l.path};let m=EI(o);if(m)return {kind:"github",rawRef:"HEAD",org:m.org,repo:m.repo,gitRemoteUrl:`https://github.com/${m.org}/${m.repo}.git`,pathInRepo:n};let p=SI(o)??CI(o);if(p)return {kind:"gitlab",rawRef:p.ref,org:p.namespace,repo:p.project,gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:n||p.path};let d=OI(o);if(d)return {kind:"gitlab",rawRef:"HEAD",org:d.namespace,repo:d.project,gitRemoteUrl:`https://gitlab.com/${d.namespace}/${d.project}.git`,pathInRepo:n}}if(o.startsWith("git@github.com:")){let l=LI(o);if(!l)throw new Error(`Invalid GitHub SSH URL: ${o}`);return {kind:"github",rawRef:"HEAD",org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:n}}if(o.startsWith("git@gitlab.com:")){let l=AI(o);if(!l)throw new Error(`Invalid GitLab SSH URL: ${o}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${l.namespace}/${l.project}.git`,pathInRepo:n}}if(o.startsWith("git@")){let l=o.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!l)throw new Error(`Invalid SSH git URL: ${o}`);let m=l[1],p=l[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${p}.git`,pathInRepo:n}}let i=o.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let l=i[1],m=i[2];return {kind:"github",rawRef:i[3],org:l,repo:m,gitRemoteUrl:`https://github.com/${l}/${m}.git`,pathInRepo:n}}let a=o.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let l=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:l,repo:m,gitRemoteUrl:`https://gitlab.com/${l}/${m}.git`,pathInRepo:n}}let c=resolve(e,o);if(!await j(c))throw new Error(`Path does not exist: ${c}`);return nG(c,e,n)}s(kI,"parseInstallSource");T();ft();pn();T();Ad();var sG=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:z$1.enum(["github","gitlab","git","local"]),features:z$1.array(Da).min(1),pick:gl.optional(),target:ze.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:Xc.optional()}),F1=z$1.object({version:z$1.literal(1),installs:z$1.array(sG).default([])});function v1(t,e){return t.length===e.length&&[...t].sort().every((r,o)=>r===[...e].sort()[o])}s(v1,"sameFeatures");function G1(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&v1(t.features,e.features)}s(G1,"sameInstallIdentity");function iG(t){return join(t,"installs.yaml")}s(iG,"manifestPath");async function wI(t){let e=await y(iG(t));if(e===null)return [];try{return F1.parse(parse(e)).installs.map(r=>si(r))}catch{return []}}s(wI,"readInstallManifest");async function aG(t,e){let r=si(e),n=(await wI(t)).filter(i=>i.name!==r.name&&!G1(i,r));n.push(r),await I(iG(t),stringify({version:1,installs:n.sort((i,a)=>i.name.localeCompare(a.name))}));}s(aG,"upsertInstallManifestEntry");function cG(t){return si(sG.parse({name:t.name,source:t.source,version:t.version,source_kind:t.sourceKind,features:t.features,pick:t.pick,target:t.target,path:t.path,paths:t.paths,as:t.as}))}s(cG,"buildInstallManifestEntry");async function $1(t){let e=await wI(t.canonicalDir);if(e.length===0){_.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let o of e){let n=join(t.canonicalDir,"packs",o.name);await j(n)||r.push(o);}if(r.length===0){_.info("All recorded packs are already installed.");return}for(let o of r)await t.reinstall(o);_.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s($1,"syncInstalledPacks");async function lG(t){return t.sync?(await $1({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(lG,"maybeRunInstallSync");Ad();function mG(t){return {sync:t.sync===true,dryRun:t["dry-run"]===true,force:t.force===true,useExtends:t.extends===true,explicitPath:typeof t.path=="string"?t.path:void 0,explicitTarget:typeof t.target=="string"?t.target.trim():void 0,explicitAs:typeof t.as=="string"?Xc.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(mG,"readInstallFlags");x_();function Ca(t){let e=[];return t.skills.length&&e.push("skills"),t.rules.length&&e.push("rules"),t.commands.length&&e.push("commands"),t.agents.length&&e.push("agents"),t.mcp!==null&&e.push("mcp"),t.permissions!==null&&e.push("permissions"),t.hooks!==null&&e.push("hooks"),t.ignore.length&&e.push("ignore"),e}s(Ca,"featuresFromCanonical");async function Yd(t){let{sliceRoot:e,implicitPick:r}=await Ed(t),o=await Od(e);return {canonical:o,features:Ca(o),implicitPick:r}}s(Yd,"discoverFromContentRoot");function pG(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(pG,"validateSkill");function uG(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(uG,"validateRule");function dG(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(dG,"validateCommand");function gG(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(gG,"validateAgent");function Ce(t){return basename(t.source).replace(/\.md$/i,"")}s(Ce,"ruleSlug");function U1(t){if(!t)return;let e=[];return t.skills!==void 0&&e.push("skills"),t.rules!==void 0&&e.push("rules"),t.commands!==void 0&&e.push("commands"),t.agents!==void 0&&e.push("agents"),e.length>0?e:void 0}s(U1,"featuresFromImplicitPick");function ol(t,e){let{implicitPick:r}=e,o=e.scopedFeatures??U1(r);if(!r&&!o)return t;let n=new Set(o??[]),i={...t,mcp:!o||n.has("mcp")?t.mcp:null,permissions:!o||n.has("permissions")?t.permissions:null,hooks:!o||n.has("hooks")?t.hooks:null,ignore:!o||n.has("ignore")?t.ignore:[]};if(r?.skills!==void 0){let a=new Set(r.skills);i={...i,skills:r.skills.length===0?[]:i.skills.filter(c=>a.has(c.name))};}else o&&!n.has("skills")&&(i={...i,skills:[]});if(r?.rules!==void 0){let a=new Set(r.rules);i={...i,rules:r.rules.length===0?[]:i.rules.filter(c=>a.has(Ce(c)))};}else o&&!n.has("rules")&&(i={...i,rules:[]});if(r?.commands!==void 0){let a=new Set(r.commands);i={...i,commands:r.commands.length===0?[]:i.commands.filter(c=>a.has(c.name))};}else o&&!n.has("commands")&&(i={...i,commands:[]});if(r?.agents!==void 0){let a=new Set(r.agents);i={...i,agents:r.agents.length===0?[]:i.agents.filter(c=>a.has(c.name))};}else o&&!n.has("agents")&&(i={...i,agents:[]});return i}s(ol,"narrowDiscoveredForInstallScope");T();Cd();T();M();var W1=new Set(["README.md","README.rst","README.txt","README","LICENSE","LICENSE.md","LICENSE.txt","LICENSE-MIT","LICENSE-APACHE","CONTRIBUTING.md","CHANGELOG.md","CODE_OF_CONDUCT.md","package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]),H1=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function Xd(t){let e=await y(t);if(!e)return "";let{frontmatter:r}=w(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Xd,"readSkillFrontmatterName");async function fG(t,e){await cp$1(t,e,{recursive:true,filter:s(r=>{let o=relative(t,r).replace(/\\/g,"/");if(o==="")return true;let n=o.split("/")[0];return !(H1.has(n)||!o.includes("/")&&W1.has(o))},"filter")});}s(fG,"cpFilteredSkill");async function X1(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await L(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:s(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}s(X1,"createStageRoot");async function Z1(t,e){if((await stat(t)).isFile()){if(!t.toLowerCase().endsWith(".md"))throw new Error(`Manual install only supports .md files for this collection: ${t}`);await L(e),await cp$1(t,join(e,basename(t)));return}let o=(await N(t)).filter(i=>i.toLowerCase().endsWith(".md"));if(o.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let n=new Map;await L(e);for(let i of o){let a=basename(i),c=n.get(a);if(c)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${c} and ${i}).`);n.set(a,i),await cp$1(i,join(e,a));}}s(Z1,"stageMarkdownCollection");async function hG(t,e,r){if(r.length===0)return false;let o=new Set(r),n=new Map;for(let i of await N(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),c=basename(a);if(!o.has(c))continue;let l=n.get(c);if(l&&l!==a)throw new Error(`Manual skill replay found duplicate skill "${c}" under ${t} (${l} and ${a}).`);n.set(c,a);}if(n.size!==r.length)return false;await L(e);for(let i of r)await cp$1(n.get(i),join(e,i),{recursive:true});return true}s(hG,"stagePreferredSkills");async function Q1(t,e,r={}){if((await stat(t)).isFile()){if(basename(t)!=="SKILL.md")throw new Error(`Manual skill install expects SKILL.md or a skill directory: ${t}`);let n=basename(dirname(t)),i=join(e,n);await L(i),await cp$1(dirname(t),i,{recursive:true});return}if(await Ra(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await hG(t,e,r.preferredSkillNames??[]))return;let c=await Xd(join(t,"SKILL.md"))||basename(t),l=join(e,c);await L(e),await fG(t,l);return}if(await hG(t,e,r.preferredSkillNames??[]))return;await L(e);let n=await N(t),i=new Set;for(let a of n.filter(c=>c.endsWith("/SKILL.md")||c.endsWith("\\SKILL.md")))i.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of i)await cp$1(join(t,a),join(e,a),{recursive:true});return}throw new Error(`Manual skill install expects a skill directory or skills collection at ${t}.`)}s(Q1,"stageSkills");async function yG(t,e,r={}){let o=await X1();try{let n=join(o.discoveryRoot,".agentsmesh",e);return e==="skills"?await Q1(t,n,r):await Z1(t,n),o}catch(n){throw await o.cleanup(),n}}s(yG,"stageManualInstallScope");async function _G(t,e,r,o){let n=await yG(t,e,{preferredSkillNames:e==="skills"?o?.skills:void 0}),{canonical:i}=await Yd(n.discoveryRoot),a=ol(i,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:n.cleanup},narrowed:a,discoveredFeatures:Ca(a)}}s(_G,"resolveManualDiscoveredForInstall");pn();Mg();T();var q1=[{prefix:".gemini/commands",target:"gemini-cli"},{prefix:".github/instructions",target:"copilot"},{prefix:".github/copilot-instructions.md",target:"copilot"},{prefix:".github/copilot",target:"copilot"},{prefix:".github/prompts",target:"copilot"},{prefix:".github/skills",target:"copilot"},{prefix:".github/agents",target:"copilot"},{prefix:".github/hooks",target:"copilot"},{prefix:".claude/commands",target:"claude-code"},{prefix:".claude/rules",target:"claude-code"},{prefix:".claude/skills",target:"claude-code"},{prefix:".claude/agents",target:"claude-code"},{prefix:".cursor/commands",target:"cursor"},{prefix:".cursor/rules",target:"cursor"},{prefix:".cursor/agents",target:"cursor"},{prefix:".cursor/skills",target:"cursor"},{prefix:".continue/prompts",target:"continue"},{prefix:".continue/rules",target:"continue"},{prefix:".continue/skills",target:"continue"},{prefix:".junie/commands",target:"junie"},{prefix:".junie/rules",target:"junie"},{prefix:".junie/agents",target:"junie"},{prefix:".junie/skills",target:"junie"},{prefix:".kiro/steering",target:"kiro"},{prefix:".kiro/skills",target:"kiro"},{prefix:".kilo/commands",target:"kilo-code"},{prefix:".kilo/rules",target:"kilo-code"},{prefix:".kilo/skills",target:"kilo-code"},{prefix:".kilo/agents",target:"kilo-code"},{prefix:".kilocode/workflows",target:"kilo-code"},{prefix:".kilocode/rules",target:"kilo-code"},{prefix:".kilocode/skills",target:"kilo-code"},{prefix:".kilocodemodes",target:"kilo-code"},{prefix:".kilocodeignore",target:"kilo-code"},{prefix:".cline/skills",target:"cline"},{prefix:".clinerules/workflows",target:"cline"},{prefix:".windsurf/rules",target:"windsurf"},{prefix:".codex",target:"codex-cli"}];function tY(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(tY,"norm");function Qd(t){let e=tY(t),r=[...q1].sort((o,n)=>n.prefix.length-o.prefix.length);for(let{prefix:o,target:n}of r)if(e===o||e.startsWith(`${o}/`))return n}s(Qd,"targetHintFromNativePath");function bI(t,e){return Qd(t)===e}s(bI,"pathSupportsNativePick");function IG(t,e){if(!t||!e)return;let r=Qd(e);if(r&&r!==t)throw new Error(`--target "${t}" does not match the install path (native path suggests "${r}"). Omit --target to auto-detect, or point at a subtree for that target.`)}s(IG,"validateTargetMatchesPath");function RG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(RG,"extendPickHasArrays");T();T();Wt();async function CG(t,e){let r=join(t,...Me.split("/")),o=join(t,...e.split("/")),n=await N(o),i=[];for(let a of n){if(!/\.(toml|md)$/i.test(a))continue;let c=relative(r,a).replace(/\\/g,"/");if(c.startsWith("..")||c==="")continue;let m=c.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(CG,"inferGeminiCommandNamesFromFiles");Wt();rr();T();async function Ea(t){let e=await N(t),r=new Set;for(let o of e){if(basename(o)==="SKILL.md"){r.add(basename(dirname(o)));continue}!relative(t,o).replace(/\\/g,"/").includes("/")&&o.toLowerCase().endsWith(".md")&&r.add(basename(o,".md"));}return [...r].filter(Boolean).sort()}s(Ea,"skillNamesFromNativeSkillDir");T();Rr();async function EG(t,e){let r=join(t,...e.split("/"));if(e.startsWith(Ys)){let o=await N(r),n=[...new Set(o.filter(i=>i.toLowerCase().endsWith(".prompt.md")).map(i=>basename(i,".prompt.md")))].sort();return n.length?{commands:n}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let o=await N(r),n=[...new Set(o.filter(i=>i.includes(".instructions.md")).map(i=>basename(i).replace(/\.instructions\.md$/i,"")))].sort();return n.length?{rules:n}:{}}if(e.startsWith(".github/instructions")){let o=await N(r),n=new Set;for(let a of o){let c=basename(a);c.toLowerCase().endsWith(".instructions.md")?n.add(c.replace(/\.instructions\.md$/i,"")):c.toLowerCase().endsWith(".md")&&n.add(basename(a,".md"));}let i=[...n].sort();return i.length?{rules:i}:{}}if(e.startsWith(".github/skills")){let o=await Ea(r);return o.length?{skills:o}:{}}if(e.startsWith(".github/agents")){let o=await N(r),n=[...new Set(o.filter(i=>i.toLowerCase().endsWith(".agent.md")).map(i=>basename(i,".agent.md")))].sort();return n.length?{agents:n}:{}}return {}}s(EG,"inferCopilotPickFromPath");async function Ke(t,e){let r=await N(t),o=e.toLowerCase();return [...new Set(r.filter(n=>n.toLowerCase().endsWith(o)).map(n=>basename(n,e)))].sort()}s(Ke,"mdNames");async function LG(t,e,r){let o=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),n=join(t,...o.split("/"));if(r==="gemini-cli"){if(o===Me||o.startsWith(`${Me}/`)){let i=await CG(t,o);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(o.startsWith(".claude/commands")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".claude/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".claude/agents")){let i=await Ke(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".claude/skills/")){let a=o.replace(/^\.claude\/skills\/?/,"").split("/").filter(Boolean)[0];return a?{skills:[a]}:{}}return {}}if(r==="cursor"){if(o.startsWith(".cursor/rules")){let i=await Ke(n,".mdc");return i.length?{rules:i}:{}}if(o.startsWith(".cursor/commands")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".cursor/agents")){let i=await Ke(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".cursor/skills")){let i=await Ea(n);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return EG(t,o);if(r==="windsurf"&&o.startsWith(".windsurf/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(o.startsWith(Jt)){let i=await Ea(n);return i.length?{skills:i}:{}}if(o.startsWith(Eo)){let i=await Ke(n,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(o.startsWith(".continue/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".continue/prompts")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".continue/skills")){let i=await Ea(n);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(o.startsWith(".junie/commands")){let i=await Ke(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".junie/rules")){let i=await Ke(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".junie/agents")){let i=await Ke(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".junie/skills")){let i=await Ea(n);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&o.startsWith(".codex")){let i=await N(n),a=[...new Set(i.filter(c=>c.toLowerCase().endsWith(".md")).map(c=>basename(c,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(LG,"inferImplicitPickFromNativePath");function AG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(AG,"isImplicitPickEmpty");T_();function Bm(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(Bm,"normalizePath");function mY(t,e){let r=Bm(t),o=Bm(e);return r===o||r.startsWith(`${o}/`)||o.startsWith(`${r}/`)}s(mY,"overlapsPath");function qd(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(qd,"addUnique");async function pY(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),o=s(async()=>{await rm$1(e,{recursive:true,force:true});},"cleanup");try{return await cp$1(t,r,{recursive:!0}),{stageRoot:r,cleanup:o}}catch(n){throw await o(),n}}s(pY,"makeStageRoot");function uY(t,e){let r;for(let n of t){if(n.feature==="rules"&&n.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:qd(r?.rules,basename(n.toPath,".md"))};continue}if(n.feature==="commands"&&n.toPath.startsWith(".agentsmesh/commands/")){let i=Bm(relative(join(e,".agentsmesh","commands"),join(e,n.toPath)));r={...r,commands:qd(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(n.feature==="agents"&&n.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:qd(r?.agents,basename(n.toPath,".md"))};continue}if(n.feature==="skills"&&n.toPath.startsWith(".agentsmesh/skills/")){let a=Bm(relative(join(e,".agentsmesh","skills"),join(e,n.toPath))).split("/")[0];a&&(r={...r,skills:qd(r?.skills,a)});}}return r&&(r.rules?.length??0)+(r.commands?.length??0)+(r.agents?.length??0)+(r.skills?.length??0)>0?r:void 0}s(uY,"buildPickFromResults");function dY(t,e,r,o){let n=join(e,...Bm(t).split("/")),i=r.filter(a=>mY(n,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${o}".`);return {features:[...new Set(i.map(a=>a.feature))],pick:uY(i,e)}}s(dY,"scopeImportedResults");async function xI(t,e){let{stageRoot:r,cleanup:o}=await pY(t);try{let n=await wm(r,e);return {stageRoot:r,results:n,cleanup:o}}catch(n){throw await o(),n}}s(xI,"stageImportedNativeRepo");async function DI(t,e,r){let o=await xI(t,r);try{return {stageRoot:o.stageRoot,cleanup:o.cleanup,...dY(e,o.stageRoot,o.results,r)}}catch(n){throw await o.cleanup(),n}}s(DI,"stageNativeInstallScope");async function bG(t,e,r,o){let n=o.explicitTarget?.trim();n&&ze.parse(n);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");IG(n,i);let a=join(t,".agentsmesh"),c=await j(a),l=i?Qd(i):void 0,m=!c&&!n?await fp(t)??void 0:void 0;if(!n&&l&&m&&l!==m)throw new Error(`Install path suggests native layout "${l}" but auto-detect imported "${m}". Use --target ${l} for this path, or install from the repo root without a conflicting subtree path.`);let p=n??l??m,d=!!i&&!!p&&!i.startsWith(".agentsmesh");if(!c&&p){if(d){let A=await DI(t,i,p);return {discoveryRoot:A.stageRoot,implicitPick:A.pick,scopedFeatures:A.features,yamlTarget:p,importHappened:true,cleanup:A.cleanup}}let E=await xI(t,p);return {discoveryRoot:i?join(E.stageRoot,i):E.stageRoot,yamlTarget:p,importHappened:true,cleanup:E.cleanup}}let g;c?i?p&&bI(i,p)?g=t:g=e:g=t:g=e;let f,h,O;if(d&&p){let E=await DI(t,i,p);g=E.stageRoot,f=E.pick,h=E.features,O=E.cleanup;}else if(g===t&&i&&p&&bI(i,p)&&(f=await LG(t,i,p),AG(f)))throw new Error(`No installable native resources found under "${i}" for target "${p}".`);let R;return n?R=n:p&&(f&&RG(f)||(h?.length??0)>0)&&(R=p),{discoveryRoot:g,implicitPick:f,scopedFeatures:h,yamlTarget:R,importHappened:O!==void 0,cleanup:O}}s(bG,"prepareInstallDiscovery");async function PG(t,e,r,o){let n=await bG(t,e,r,{explicitTarget:o}),{canonical:i,implicitPick:a}=await Yd(n.discoveryRoot),c=a??n.implicitPick,l=ol(i,{implicitPick:c,scopedFeatures:n.scopedFeatures}),m=Ca(l);return {prep:n,discovered:i,implicitPick:c,narrowed:l,discoveredFeatures:m}}s(PG,"resolveDiscoveredForInstall");async function xG(t){return t.explicitAs?{implicitPick:void 0,...await _G(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:PG(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}s(xG,"resolveInstallDiscovery");function sl(t){return t==="."||t===""?void 0:t}s(sl,"trimDot");function fY(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(fY,"markdownPick");async function NG(t){if(!t.as)return {pathInRepo:sl(t.pathInRepo)};let e=t.pathInRepo.replace(/^\/+|\/+$/g,""),r=await stat(t.contentRoot);if(t.as!=="skills"&&r.isFile()&&t.contentRoot.toLowerCase().endsWith(".md"))return {pathInRepo:sl(dirname(e)),pick:fY(t.as,e||t.contentRoot)};if(t.as==="skills"){if(r.isFile()&&basename(t.contentRoot)==="SKILL.md"){let o=e?dirname(e):dirname(t.contentRoot);return {pathInRepo:sl(dirname(o)),pick:{skills:[basename(o)]}}}if(r.isDirectory()){let o=e||basename(t.contentRoot),n=join(t.contentRoot.replace(/\/+$/g,""),"SKILL.md");try{if((await stat(n)).isFile()){let a=await Xd(n);return {pathInRepo:sl(dirname(o)),pick:{skills:[a||basename(o)]}}}}catch{return {pathInRepo:sl(e)}}}}return {pathInRepo:sl(e)}}s(NG,"resolveManualInstallPersistence");sn();ft();async function an(t){return process.stdin.isTTY?new Promise(e=>{let r=FG.createInterface({input:process.stdin,output:process.stdout});r.question(`${t} (y/n) `,o=>{r.close();let n=o.trim().toLowerCase();e(n==="y"||n==="yes");});}):false}s(an,"confirm");function hY(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(hY,"hasArrayResources");function vG(t){return hY(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(vG,"hasInstallableResources");async function GG(t,e,r,o){let n=t.skills.map(c=>pG(c)),i=n.filter(c=>c.ok).map(c=>c.skill),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await an(`Include invalid skill "${c.skill.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.skill);else e&&(i=n.map(c=>c.skill));return r&&(i=n.filter(c=>c.ok).map(c=>c.skill)),i}s(GG,"resolveSkillPool");async function MG(t,e,r,o){let n=t.rules.map(c=>uG(c)),i=n.filter(c=>c.ok).map(c=>c.rule),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await an(`Include invalid rule "${Ce(c.rule)}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.rule);else e&&(i=n.map(c=>c.rule));return r&&(i=n.filter(c=>c.ok).map(c=>c.rule)),i}s(MG,"resolveRulePool");async function $G(t,e,r,o){let n=t.commands.map(c=>dG(c)),i=n.filter(c=>c.ok).map(c=>c.command),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await an(`Include invalid command "${c.command.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.command);else e&&(i=n.map(c=>c.command));return r&&(i=n.filter(c=>c.ok).map(c=>c.command)),i}s($G,"resolveCommandPool");async function jG(t,e,r,o){let n=t.agents.map(c=>gG(c)),i=n.filter(c=>c.ok).map(c=>c.agent),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await an(`Include invalid agent "${c.agent.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.agent);else e&&(i=n.map(c=>c.agent));return r&&(i=n.filter(c=>c.ok).map(c=>c.agent)),i}s(jG,"resolveAgentPool");async function UG(t,e){let r=e.skills.map(a=>a.name),o=e.rules.map(a=>Ce(a)),n=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(c=>c.name===a.name)&&(await an(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(l=>l!==a.name)));for(let a of e.rules){let c=Ce(a);t.rules.some(l=>Ce(l)===c)&&(await an(`Rule "${c}" already exists in merged config. Add extend anyway?`)||(o=o.filter(m=>m!==c)));}for(let a of e.commands)t.commands.some(c=>c.name===a.name)&&(await an(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(n=n.filter(l=>l!==a.name)));for(let a of e.agents)t.agents.some(c=>c.name===a.name)&&(await an(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(l=>l!==a.name)));return {skillNames:r,ruleSlugs:o,commandNames:n,agentNames:i}}s(UG,"resolveInstallConflicts");function KG(t,e){if(!t)return;let r={},o=t.skills?.filter(c=>e.skillNames.includes(c)),n=t.rules?.filter(c=>e.ruleSlugs.includes(c)),i=t.commands?.filter(c=>e.commandNames.includes(c)),a=t.agents?.filter(c=>e.agentNames.includes(c));return o&&o.length>0&&(r.skills=o),n&&n.length>0&&(r.rules=n),i&&i.length>0&&(r.commands=i),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}s(KG,"pickForSelectedResources");function yY(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(yY,"pathEndsWithName");function tg(t,e,r){return r!==1||e.length!==1?false:yY(t,e[0])}s(tg,"inferSingleNamePick");function BG(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:o,selected:n}=t,i={},a=n.skillNames.length>0&&(!!r?.skills?.length||n.skillNames.length<o.skills||tg(e,n.skillNames,o.skills)),c=n.ruleSlugs.length>0&&(!!r?.rules?.length||n.ruleSlugs.length<o.rules||tg(e,n.ruleSlugs,o.rules)),l=n.commandNames.length>0&&(!!r?.commands?.length||n.commandNames.length<o.commands||tg(e,n.commandNames,o.commands)),m=n.agentNames.length>0&&(!!r?.agents?.length||n.agentNames.length<o.agents||tg(e,n.agentNames,o.agents));return a&&(i.skills=[...n.skillNames]),c&&(i.rules=[...n.ruleSlugs]),l&&(i.commands=[...n.commandNames]),m&&(i.agents=[...n.agentNames]),Object.keys(i).length?i:void 0}s(BG,"buildInstallPick");function WG(t,e){let r=new Set(t);return e.skillNames.length===0&&r.delete("skills"),e.ruleSlugs.length===0&&r.delete("rules"),e.commandNames.length===0&&r.delete("commands"),e.agentNames.length===0&&r.delete("agents"),[...r]}s(WG,"deriveInstallFeatures");function _Y(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(_Y,"isEmptyInstallSelection");function HG(t){let{selected:e,discoveredFeatures:r,preConflict:o}=t,n=s(c=>r.includes(c),"had"),i=n("skills")&&e.skillNames.length===0&&o.skills>0&&"skills"||n("rules")&&e.ruleSlugs.length===0&&o.rules>0&&"rules"||n("commands")&&e.commandNames.length===0&&o.commands>0&&"commands"||n("agents")&&e.agentNames.length===0&&o.agents>0&&"agents";if(i)throw new Error(`No ${i} selected to install.`);let a=r.some(c=>["mcp","permissions","hooks","ignore"].includes(c));if(_Y(e)&&!a)throw new Error("No resources selected to install.")}s(HG,"ensureInstallSelection");pn();function zG(t,e){if(t.find(o=>o.name===e.name&&o.source!==e.source))throw new Error(`Extends entry "${e.name}" already exists with a different source. Use --name to provide a different name.`)}s(zG,"assertExtendNameAvailable");function IY(t,e,r){if(r===void 0){if(!t)return;let n={...t};for(let i of ["skills","commands","rules","agents"])e.includes(i)&&delete n[i];return Object.keys(n).length?n:void 0}let o={...t};for(let n of ["skills","commands","rules","agents"]){if(!(n in r))continue;let i=r[n];if(i===void 0||i.length===0){delete o[n];continue}o[n]=[...new Set([...t?.[n]??[],...i])];}return Object.keys(o).length?o:void 0}s(IY,"mergePick");function VG(t,e){let r=t.findIndex(a=>a.source===e.source);if(r<0)return [...t,{name:e.name,source:e.source,version:e.version,features:e.features,path:e.path,pick:e.pick,target:e.target}];let o=t[r],n=[...new Set([...o.features,...e.features])],i=IY(o.pick,e.features,e.pick);return t.map((a,c)=>c===r?{name:e.name,source:e.source,version:e.version??o.version,features:n,path:e.path!==void 0?e.path:o.path,pick:i,target:e.target??o.target}:a)}s(VG,"mergeExtendList");T();async function JG(t,e,r){let o=await y(t);if(o===null)throw new Error(`Missing config: ${t}`);let n=parse(o),i=VG(e.extends,r);n.extends=i;let a=stringify(n,{indent:2,lineWidth:0});await I(t,a.endsWith(`
|
|
319
319
|
`)?a:`${a}
|
|
320
|
-
`);}s(JG,"writeAgentsmeshWithNewExtend");ft();async function YG(t){let{configDir:e,config:r,entryArgs:o,dryRun:n}=t,i=
|
|
321
|
-
${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await JG(a,r,i),
|
|
322
|
-
`);return `sha256:${xm(o)}`}s(
|
|
323
|
-
`),t.permissions!==null&&await
|
|
320
|
+
`);}s(JG,"writeAgentsmeshWithNewExtend");ft();async function YG(t){let{configDir:e,config:r,entryArgs:o,dryRun:n}=t,i=EY(o);if(zG(r.extends,i),n){_.info(`[dry-run] Would add extend:
|
|
321
|
+
${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await JG(a,r,i),_.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(YG,"writeInstallAsExtend");function EY(t){return {name:t.name,source:t.source,version:t.version,features:t.features,path:t.path,pick:t.pick,target:t.yamlTarget!==void 0?ze.parse(t.yamlTarget):void 0}}s(EY,"toNewExtendEntry");T();T();var LY="pack.yaml";async function eg(t){let e=await N(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===LY)continue;let c=await bd(i);c!==null&&r.push(`${a}:${c}`);}let o=r.join(`
|
|
322
|
+
`);return `sha256:${xm(o)}`}s(eg,"hashPackContent");async function TY(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await L(r);for(let o of t.rules){let n=join(r,basename(o.source));await copyFile(o.source,n);}}s(TY,"writeRules");async function bY(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await L(r);for(let o of t.commands){let n=join(r,basename(o.source));await copyFile(o.source,n);}}s(bY,"writeCommands");async function PY(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await L(r);for(let o of t.agents){let n=join(r,basename(o.source));await copyFile(o.source,n);}}s(PY,"writeAgents");async function xY(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await L(r);for(let o of t.skills){let n=join(r,o.name);await L(n),await copyFile(o.source,join(n,"SKILL.md"));for(let i of o.supportingFiles){let a=join(n,i.relativePath);await L(dirname(a)),await copyFile(i.absolutePath,a);}}}s(xY,"writeSkills");async function DY(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
|
|
323
|
+
`),t.permissions!==null&&await I(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await I(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await I(join(e,"ignore"),`${t.ignore.join(`
|
|
324
324
|
`)}
|
|
325
|
-
`);}s(
|
|
326
|
-
`),t.permissions!==null&&await
|
|
325
|
+
`);}s(DY,"writeSettings");function NY(t){if(t.includes("/")||t.includes("\\")||t===".."||t==="."||t.includes("\0"))throw new Error(`Invalid pack name "${t}". Pack names must be a single directory segment without path separators.`)}s(NY,"validatePackName");async function ZG(t,e,r,o){NY(e);let n=join(t,`${e}.tmp`),i=join(t,e);await j(n)&&await rm$1(n,{recursive:true,force:true}),await L(n),await TY(r,n),await bY(r,n),await PY(r,n),await xY(r,n),await DY(r,n);let a=await eg(n),c=si({...o,content_hash:a});return await I(join(n,"pack.yaml"),stringify(c)),await j(i)&&await rm$1(i,{recursive:true,force:true}),await mkdir(t,{recursive:true}),await rename(n,i),c}s(ZG,"materializePack");Td();T();function MI(t,e){return [...new Set([...t,...e])]}s(MI,"union");function vY(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let o=MI(t.paths??(t.path?[t.path]:[]),[e]);return o.length===1?{path:o[0],paths:void 0}:{path:void 0,paths:o}}s(vY,"mergePathScope");function GY(t,e,r){let o={...t};for(let i of e)r&&r[i]!==void 0?o[i]=MI(o[i]??[],r[i]):delete o[i];return (o.skills?.length??0)>0||(o.rules?.length??0)>0||(o.commands?.length??0)>0||(o.agents?.length??0)>0?o:void 0}s(GY,"mergePick");async function MY(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await L(r);for(let o of t.rules)await copyFile(o.source,join(r,basename(o.source)));}s(MY,"mergeRules");async function $Y(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await L(r);for(let o of t.commands)await copyFile(o.source,join(r,basename(o.source)));}s($Y,"mergeCommands");async function jY(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await L(r);for(let o of t.agents)await copyFile(o.source,join(r,basename(o.source)));}s(jY,"mergeAgents");async function UY(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await L(r);for(let o of t.skills){let n=join(r,o.name);await L(n),await copyFile(o.source,join(n,"SKILL.md"));for(let i of o.supportingFiles){let a=join(n,i.relativePath);await L(dirname(a)),await copyFile(i.absolutePath,a);}}}s(UY,"mergeSkills");async function KY(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
|
|
326
|
+
`),t.permissions!==null&&await I(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await I(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await I(join(e,"ignore"),`${t.ignore.join(`
|
|
327
327
|
`)}
|
|
328
|
-
`);}s(
|
|
329
|
-
`,n=parse(o)??{};if(n.plugins||(n.plugins=[]),n.plugins.some(a=>a.id===e.id))return;let i={id:e.id,source:e.source};e.version!==void 0&&(i.version=e.version),n.plugins.push(i),await
|
|
328
|
+
`);}s(KY,"mergeSettings");async function QG(t,e,r,o,n,i){await MY(r,t),await $Y(r,t),await jY(r,t),await UY(r,t),await KY(r,t);let a=MI(e.features,o),c=GY(e.pick,o,n),l=vY(e,i?.path),m=await eg(t),p=new Date().toISOString(),d=si({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:a,pick:c,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...l,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:p,content_hash:m});return await I(join(t,"pack.yaml"),stringify(d)),d}s(QG,"mergeIntoPack");Tg();pn();ft();T();function WY(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(WY,"pathScope");function HY(t,e){let r=new Set(e.skillNames),o=new Set(e.ruleSlugs),n=new Set(e.commandNames),i=new Set(e.agentNames);return {...t,skills:t.skills.filter(a=>r.has(a.name)),rules:t.rules.filter(a=>o.has(Ce(a))),commands:t.commands.filter(a=>n.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(HY,"applySelection");async function qG(t){let{canonicalDir:e,packName:r,narrowed:o,selected:n,sourceForYaml:i,version:a,sourceKind:c,entryFeatures:l,pick:m,yamlTarget:p,pathInRepo:d,manualAs:g,renameExistingPack:f}=t,h=join(e,"packs"),O=HY(o,n),R=new Date().toISOString(),E=p!==void 0?ze.parse(p):void 0,A=await SF(h,i,{target:E,as:g,features:l}),F=r,v=l,G=m,J=d,Y;if(A){let q=A.packDir,Ft=A.meta;if(f&&A.name!==r){let io=join(h,r);if(await j(io))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(A.packDir,io),q=io,Ft={...A.meta,name:r};}let Gt=await QG(q,Ft,O,l,m,{source:i,...a!==void 0?{version:a}:{},...E!==void 0?{target:E}:{},...d?{path:d}:{},...g!==void 0?{as:g}:{}});F=Gt.name,v=Gt.features,G=Gt.pick,J=Gt.path,Y=Gt.paths,_.success(`Updated pack "${Gt.name}" in .agentsmesh/packs/.`);}else {if(await kd(join(h,r)))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await ZG(h,r,O,{name:r,source:i,...a!==void 0&&{version:a},source_kind:c,installed_at:R,updated_at:R,features:l,...m!==void 0&&{pick:m},...E!==void 0&&{target:E},...WY(d),...g!==void 0&&{as:g}}),_.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await aG(e,cG({name:F,source:i,version:a,sourceKind:c,features:v,pick:G,target:E,path:J,paths:Y,as:g})),c!=="local"&&await QR(i);}s(qG,"installAsPack");function VY(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(VY,"sanitize");function JY(t){try{let r=new URL(t.replace(/^git\+/,"https://").replace(/^ssh:\/\/git@/,"https://")).pathname.split("/").filter(Boolean);if(r.length===0)return "repo";let o=r[r.length-1].replace(/\.git$/i,"");return r.length>=2?`${r[r.length-2].replace(/\.git$/i,"")}-${o}`:o}catch{return "repo"}}s(JY,"gitUrlLastSegments");function tM(t,e,r){let o;if(t.kind==="local"){let c=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);o=c[c.length-1]??"local";}else t.kind==="github"&&t.org&&t.repo?o=`${t.org}-${t.repo}`:t.kind==="gitlab"&&t.org&&t.repo?o=`${t.org.replace(/\//g,"-")}-${t.repo}`:t.gitRemoteUrl?o=JY(t.gitRemoteUrl):o="extend";e.featureHint?o=`${o}-${e.featureHint}`:o=`${o}-pack`;let n=VY(o)||"extend";if(!r.has(n))return n;let i=2;for(;r.has(`${n}-${i}`);)i++;return `${n}-${i}`}s(tM,"suggestExtendName");function eM(t){let{config:e,parsed:r,entryFeatures:o,nameOverride:n}=t,i=new Set(e.extends.map(a=>a.name));return n||tM(r,{featureHint:o.length===1?o[0]:void 0},i)}s(eM,"selectInstallEntryName");function rM(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let o=ol(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:o,discoveredFeatures:Ca(o)}}s(rM,"applyReplayInstallScope");function oM(t,e){let r=[];for(let o of t.skillNames)r.push({kind:"skill",name:o,path:e});for(let o of t.ruleSlugs)r.push({kind:"rule",name:o,path:e});for(let o of t.commandNames)r.push({kind:"command",name:o,path:e});for(let o of t.agentNames)r.push({kind:"agent",name:o,path:e});return r}s(oM,"buildInstalledList");function nM(t,e,r,o,n){let i=[];for(let a of t)n.skillNames.includes(a.name)||i.push({kind:"skill",name:a.name,reason:"conflict"});for(let a of e){let c=Ce(a);n.ruleSlugs.includes(c)||i.push({kind:"rule",name:c,reason:"conflict"});}for(let a of r)n.commandNames.includes(a.name)||i.push({kind:"command",name:a.name,reason:"conflict"});for(let a of o)n.agentNames.includes(a.name)||i.push({kind:"agent",name:a.name,reason:"conflict"});return i}s(nM,"buildSkippedList");async function sM(t){let{scope:e,force:r,dryRun:o,tty:n,useExtends:i,nameOverride:a,explicitAs:c,config:l,context:m,parsed:p,sourceForYaml:d,version:g,pathInRepo:f,persisted:h,replay:O,prep:R,implicitPick:E,narrowed:A,discoveredFeatures:F}=t,{narrowed:v,discoveredFeatures:G}=rM(A,F,O);if(!vG(v))throw new Error(E||R.scopedFeatures?"No resources match the install path or implicit selection (check pick names exist at that path).":"No supported resources found to install (skills, rules, commands, agents).");let J=await GG(v,r,o,n),Y=await MG(v,r,o,n),q=await $G(v,r,o,n),Ft=await jG(v,r,o,n),Gt={skills:J.length,rules:Y.length,commands:q.length,agents:Ft.length},{canonical:io}=await he(l,m.configDir,{},m.canonicalDir),Ht=!r&&!o&&n?await UG(io,{skills:J,rules:Y,commands:q,agents:Ft}):{skillNames:J.map(gs=>gs.name),ruleSlugs:Y.map(gs=>Ce(gs)),commandNames:q.map(gs=>gs.name),agentNames:Ft.map(gs=>gs.name)};HG({selected:Ht,discoveredFeatures:G,preConflict:Gt});let ao=O?.features??WG(G,Ht);if(ao.length===0)throw new Error("No features left to install after selection.");let Ut=KG(O?.pick,Ht)??h.pick??BG({pathInRepo:h.pathInRepo??f,implicitPick:E,preConflictCounts:Gt,selected:Ht}),wt=eM({config:l,parsed:p,entryFeatures:ao,nameOverride:a}),cn=oM(Ht,wt),Ar=nM(J,Y,q,Ft,Ht);if(i){if(await YG({configDir:m.configDir,config:l,entryArgs:{name:wt,source:d,version:g,features:ao,path:h.pathInRepo,pick:Ut,yamlTarget:R.yamlTarget},dryRun:o}),o)return {installed:cn,skipped:Ar}}else {if(o)return _.info(`[dry-run] Would install pack "${wt}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:cn,skipped:Ar};await qG({canonicalDir:m.canonicalDir,packName:wt,narrowed:v,selected:Ht,sourceForYaml:d,version:g,sourceKind:p.kind,entryFeatures:ao,pick:Ut,yamlTarget:R.yamlTarget,pathInRepo:h.pathInRepo,manualAs:c,renameExistingPack:a===""});}let ds=await tl(e==="global"?{global:true}:{},m.rootBase);return el(ds),ds.exitCode!==0&&_.warn(`Generate failed after install. Fix the issue and run agentsmesh generate${e==="global"?" --global":""}.`),{installed:cn,skipped:Ar}}s(sM,"executeRunInstallPoolsAndWrite");async function jI(t,e,r,o){let{sync:n,dryRun:i,force:a,useExtends:c,explicitPath:l,explicitTarget:m,explicitAs:p,nameOverride:d}=mG(t),g=t.global===true?"global":"project",f=e[0]?.trim();if(n){let{context:Ht}=await Tt(r,g),ao=[],Ut=[];if(await lG({sync:n,canonicalDir:Ht.canonicalDir,reinstall:s(async wt=>{let cn=wt.paths&&wt.paths.length>0?wt.paths:[wt.path];for(let Ar of cn){let ds=await jI({...a?{force:true}:{},...i?{"dry-run":true}:{},...g==="global"?{global:true}:{},name:wt.name,...wt.target?{target:wt.target}:{},...Ar?{path:Ar}:{},...wt.as?{as:wt.as}:{}},[wt.source],r,{features:wt.features,pick:wt.pick});ao.push(...ds.data.installed),Ut.push(...ds.data.skipped);}},"reinstall")}))return {exitCode:0,data:{source:"",mode:"sync",installed:ao,skipped:Ut,dryRun:i}}}if(!f)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let h=process.stdin.isTTY;if(!h&&!a&&!i)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:O,context:R}=await Tt(r,g),E=await kI(f,R.configDir,l);if(E.kind!=="local"&&!await qv())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:A,sourceForYaml:F,version:v}=await rG(E,f),G=E.pathInRepo.replace(/^\/+|\/+$/g,"");if(G){let Ht=normalize(G).replace(/\\/g,"/");if(Ht===".."||Ht.startsWith("../"))throw new Error(`Install --path "${E.pathInRepo}" escapes the source root. Path must stay within the source.`)}let J=G?join(A,G):A;if(!await j(J))throw new Error(`Install path does not exist: ${J}`);let Y=await NG({as:p,contentRoot:J,pathInRepo:G}),{prep:q,implicitPick:Ft,narrowed:Gt,discoveredFeatures:io}=await xG({resolvedPath:A,contentRoot:J,pathInRepo:G,explicitTarget:m,explicitAs:p,replayPick:o?.pick});try{let Ht=await sM({scope:g,force:a,dryRun:i,tty:h,useExtends:c,nameOverride:d,explicitAs:p,config:O,context:R,parsed:E,sourceForYaml:F,version:v,pathInRepo:G,persisted:Y,replay:o,prep:q,implicitPick:Ft,narrowed:Gt,discoveredFeatures:io});return {exitCode:0,data:{source:f,mode:"install",installed:Ht.installed,skipped:Ht.skipped,dryRun:i}}}finally{q.cleanup&&await q.cleanup();}}s(jI,"runInstall");async function iM(t,e,r){return jI(t,e,r)}s(iM,"runInstall");ft();function aM(t){let{data:e}=t;if(!(e.mode==="sync"&&e.installed.length===0&&e.skipped.length===0)){if(e.installed.length>0&&!e.dryRun){let o=[...new Set(e.installed.map(n=>n.kind))].map(n=>{let i=e.installed.filter(a=>a.kind===n).length;return `${i} ${n}${i>1?"s":""}`}).join(", ");_.success(`Installed ${o}.`);}if(e.skipped.length>0)for(let r of e.skipped)_.warn(`Skipped ${r.kind} "${r.name}": ${r.reason}`);}}s(aM,"renderInstall");H_();T();var BI="agentsmesh.yaml";async function WI(t){let e=join(t,BI),r=await y(e);return r===null?{}:parse(r)??{}}s(WI,"readScopedConfigRaw");async function lM(t,e){let r=join(t,BI),o=await y(r)??`version: 1
|
|
329
|
+
`,n=parse(o)??{};if(n.plugins||(n.plugins=[]),n.plugins.some(a=>a.id===e.id))return;let i={id:e.id,source:e.source};e.version!==void 0&&(i.version=e.version),n.plugins.push(i),await I(r,stringify(n));}s(lM,"writePluginEntry");async function mM(t,e){let r=join(t,BI),o=await y(r);if(o===null)return false;let n=parse(o)??{},i=(n.plugins??[]).length;n.plugins=(n.plugins??[]).filter(c=>c.id!==e),n.pluginTargets&&(n.pluginTargets=n.pluginTargets.filter(c=>c!==e));let a=n.plugins.length<i;return a&&await I(r,stringify(n)),a}s(mM,"removePluginEntry");async function pM(t,e,r){let o=e[0];if(o===void 0||o==="")return {exitCode:0,data:{subcommand:"list",plugins:[]},showHelp:true};switch(o){case "add":return ZY(t,e.slice(1),r);case "list":return QY(r);case "remove":return qY(e.slice(1),r);case "info":return tX(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${o}`}}}s(pM,"runPlugin");async function ZY(t,e,r){let o=e[0];if(!o)throw new co("Usage: agentsmesh plugin add <source> [--version <v>] [--id <id>]");let n=typeof t.version=="string"?t.version:"latest",a=(typeof t.id=="string"?t.id:void 0)??eX(o);return await lM(r,{id:a,source:o,version:n==="latest"?void 0:n}),{exitCode:0,data:{subcommand:"add",id:a,package:o,version:n}}}s(ZY,"runPluginAdd");async function QY(t){let r=(await WI(t)).plugins??[],o=[];for(let n of r){let i="\u2717",a="";try{let c=await Md(n,t);i=c.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",a=c.descriptors.map(l=>l.id).join(", ");}catch{}o.push({id:n.id,package:n.source,version:n.version,status:i,targets:a});}return {exitCode:0,data:{subcommand:"list",plugins:o}}}s(QY,"runPluginList");async function qY(t,e){let r=t[0];if(!r)throw new co("Usage: agentsmesh plugin remove <id>");let o=await mM(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:o}}}s(qY,"runPluginRemove");async function tX(t,e){let r=t[0];if(!r)throw new co("Usage: agentsmesh plugin info <id>");let n=((await WI(e)).plugins??[]).find(c=>c.id===r);if(!n)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await Md(n,e);}catch{return {exitCode:1,data:{subcommand:"info",id:r,package:n.source,version:n.version,descriptors:[]}}}let a=i.descriptors.map(c=>({id:c.id,description:c.emptyImportMessage}));return {exitCode:0,data:{subcommand:"info",id:r,package:n.source,version:n.version,descriptors:a}}}s(tX,"runPluginInfo");function eX(t){let e=t;if(e.startsWith("@")){let o=e.indexOf("/");o!==-1&&(e=e.slice(o+1));}e.startsWith("agentsmesh-target-")&&(e=e.slice(18)),e.startsWith("file:")&&(e=e.slice(5));let r=e.replace(/\\/g,"/").split("/");return e=r[r.length-1]??e,e=e.replace(/\.(js|ts)$/,""),e=e.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),e||"plugin"}s(eX,"derivePluginId");ft();function uM(t){if(t.error&&_.error(t.error),t.showHelp){iX();return}let{data:e}=t;switch(e.subcommand){case "add":rX(e.id,e.package,e.version);break;case "list":oX(e.plugins);break;case "remove":nX(e.id,e.found);break;case "info":sX(e,t.exitCode);break}}s(uM,"renderPlugin");function rX(t,e,r){_.success(`Plugin '${t}' added to agentsmesh.yaml`),_.warn("Plugins load as trusted Node.js modules and run with full process privileges. Only install plugins from sources you trust.");let o=r!=="latest"?`@${r}`:"@latest";_.info(`Next: npm install ${e}${o}`),_.info(`Then add '${t}' to pluginTargets in agentsmesh.yaml to enable it.`);}s(rX,"renderAdd");function oX(t){if(t.length===0){_.info("No plugins configured. Use: agentsmesh plugin add <source>");return}_.info("Configured plugins:");for(let e of t){let r=e.version!==void 0?`@${e.version}`:"",o=e.status??"",n=e.targets??"";_.info(` ${e.id} | ${e.package}${r} | ${o} | ${n}`);}}s(oX,"renderList");function nX(t,e){e?_.success(`Plugin '${t}' removed from agentsmesh.yaml`):_.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s(nX,"renderRemove");function sX(t,e){if(e!==0&&t.package===""){_.error(`Plugin '${t.id}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`);return}if(e!==0){_.error(`Failed to load plugin '${t.id}'`);return}_.info(`Plugin: ${t.id}`),_.info(`Source: ${t.package}${t.version!==void 0?`@${t.version}`:""}`),_.info(`Descriptors: ${t.descriptors.length}`);for(let r of t.descriptors)_.info(` - ${r.id}: ${r.description}`);}s(sX,"renderInfo");function iX(){_.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),_.info(""),_.info("Subcommands:"),_.info(" add <source> Register a plugin package in agentsmesh.yaml"),_.info(" list Show all configured plugins and load status"),_.info(" remove <id> Remove a plugin from agentsmesh.yaml"),_.info(" info <id> Show descriptor details for a configured plugin"),_.info(""),_.info("Flags (add):"),_.info(" --version <v> Pin plugin version"),_.info(" --id <id> Override derived plugin id"),_.info(""),_.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),_.info(" Only install plugins from sources you trust.");}s(iX,"printPluginHelp");T();mo();function ii(t){return t.toUpperCase().replace(/-/g,"_")}s(ii,"toPrefix");function ps(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(ps,"toPascal");function HI(t){let e=ii(t.id),r=ps(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
|
|
330
330
|
import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
|
|
331
331
|
import { generateRules } from './generator.js';
|
|
332
332
|
import { importFrom${r} } from './importer.js';
|
|
@@ -429,7 +429,7 @@ export const descriptor = {
|
|
|
429
429
|
buildImportPaths: build${r}ImportPaths,
|
|
430
430
|
detectionPaths: [${e}_DIR],
|
|
431
431
|
} satisfies TargetDescriptor;
|
|
432
|
-
`}s(
|
|
432
|
+
`}s(HI,"TEMPLATE_INDEX");function zI(t){return `import { describe, it, expect } from 'vitest';
|
|
433
433
|
import type { CanonicalFiles } from '../../../../src/core/types.js';
|
|
434
434
|
import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
|
|
435
435
|
|
|
@@ -458,7 +458,7 @@ describe('generateRules (${t.id})', () => {
|
|
|
458
458
|
expect(result).toHaveLength(0);
|
|
459
459
|
});
|
|
460
460
|
});
|
|
461
|
-
`}s(
|
|
461
|
+
`}s(zI,"TEMPLATE_GENERATOR_TEST");function VI(t){let e=ps(t.id);return `import { describe, it, expect } from 'vitest';
|
|
462
462
|
import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
|
|
463
463
|
|
|
464
464
|
describe('importFrom${e} (${t.id})', () => {
|
|
@@ -472,10 +472,10 @@ describe('importFrom${e} (${t.id})', () => {
|
|
|
472
472
|
expect(result).toHaveLength(0);
|
|
473
473
|
});
|
|
474
474
|
});
|
|
475
|
-
`}s(
|
|
475
|
+
`}s(VI,"TEMPLATE_IMPORTER_TEST");function JI(t){return `# ${t.displayName} Workspace
|
|
476
476
|
|
|
477
477
|
Follow the ${t.displayName} configuration files and keep changes small.
|
|
478
|
-
`}s(
|
|
478
|
+
`}s(JI,"TEMPLATE_FIXTURE_ROOT_MD");function dM(t){let e=ii(t.id);return `export const ${e}_TARGET = '${t.id}';
|
|
479
479
|
|
|
480
480
|
// Project-level paths
|
|
481
481
|
export const ${e}_DIR = '.${t.id}';
|
|
@@ -488,21 +488,21 @@ export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
|
|
|
488
488
|
// Canonical paths
|
|
489
489
|
export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
|
|
490
490
|
export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
|
|
491
|
-
`}s(dM,"TEMPLATE_CONSTANTS");function gM(t){let e=
|
|
491
|
+
`}s(dM,"TEMPLATE_CONSTANTS");function gM(t){let e=ii(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
|
|
492
492
|
import { ${e}_TARGET, ${e}_DIR } from './constants.js';
|
|
493
493
|
|
|
494
|
-
export interface ${
|
|
494
|
+
export interface ${ps(t.id)}Output {
|
|
495
495
|
path: string;
|
|
496
496
|
content: string;
|
|
497
497
|
}
|
|
498
498
|
|
|
499
|
-
export function generateRules(_canonical: CanonicalFiles): ${
|
|
499
|
+
export function generateRules(_canonical: CanonicalFiles): ${ps(t.id)}Output[] {
|
|
500
500
|
// TODO(agentsmesh-scaffold): implement generateRules for ${t.displayName}
|
|
501
501
|
void ${e}_TARGET;
|
|
502
502
|
void ${e}_DIR;
|
|
503
503
|
return [];
|
|
504
504
|
}
|
|
505
|
-
`}s(gM,"TEMPLATE_GENERATOR");function fM(t){let e=
|
|
505
|
+
`}s(gM,"TEMPLATE_GENERATOR");function fM(t){let e=ps(t.id),r=ii(t.id);return `import type { ImportResult } from '../../core/types.js';
|
|
506
506
|
import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
|
|
507
507
|
import { ${r}_TARGET } from './constants.js';
|
|
508
508
|
|
|
@@ -514,7 +514,7 @@ export async function importFrom${e}(
|
|
|
514
514
|
void ${r}_TARGET;
|
|
515
515
|
return [];
|
|
516
516
|
}
|
|
517
|
-
`}s(fM,"TEMPLATE_IMPORTER");function hM(t){let e=
|
|
517
|
+
`}s(fM,"TEMPLATE_IMPORTER");function hM(t){let e=ii(t.id);return `/** Lint rules for the ${t.id} target. */
|
|
518
518
|
import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
|
|
519
519
|
import { validateRules } from '../../core/lint/validate-rules.js';
|
|
520
520
|
import { ${e}_TARGET } from './constants.js';
|
|
@@ -542,7 +542,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
|
|
|
542
542
|
// TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
|
|
543
543
|
return [];
|
|
544
544
|
}
|
|
545
|
-
`}s(yM,"TEMPLATE_LINT_HOOKS");function _M(t){let e=
|
|
545
|
+
`}s(yM,"TEMPLATE_LINT_HOOKS");function _M(t){let e=ps(t.id),r=ii(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
|
|
546
546
|
import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
|
|
547
547
|
|
|
548
548
|
export async function build${e}ImportPaths(
|
|
@@ -554,14 +554,14 @@ export async function build${e}ImportPaths(
|
|
|
554
554
|
// Reference: src/core/reference/import-maps/kiro.ts for a full example
|
|
555
555
|
void ${r}_DIR;
|
|
556
556
|
}
|
|
557
|
-
`}s(_M,"TEMPLATE_IMPORT_MAP");var
|
|
557
|
+
`}s(_M,"TEMPLATE_IMPORT_MAP");var cX=/^[a-z][a-z0-9-]*$/;async function IM(t){let{id:e,projectRoot:r,force:o=false}=t,n=t.displayName??e,i={id:e,displayName:n};if(!cX.test(e))throw new Error(`Invalid target id "${e}". Must match /^[a-z][a-z0-9-]*$/ (lowercase letters, digits, hyphens; start with a letter).`);if(kt.includes(e))throw new Error(`Target "${e}" already exists as a built-in target. Choose a different id.`);let a=[{rel:`src/targets/${e}/constants.ts`,content:dM(i)},{rel:`src/targets/${e}/index.ts`,content:HI(i)},{rel:`src/targets/${e}/generator.ts`,content:gM(i)},{rel:`src/targets/${e}/importer.ts`,content:fM(i)},{rel:`src/targets/${e}/linter.ts`,content:hM(i)},{rel:`src/targets/${e}/lint.ts`,content:yM(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:_M(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:zI(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:VI(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:JI(i)}],c=[],l=[];for(let p of a){let d=join(r,p.rel);if(!o&&await j(d)){l.push(d);continue}await I(d,p.content),c.push(d);}let m=["1. Run: pnpm catalog:generate (auto-discovers the new target \u2014 updates IDs, descriptors, and import-map barrel)",`2. Fill in TODO(agentsmesh-scaffold) markers in src/targets/${e}/`,`3. Run: pnpm typecheck && pnpm test -- tests/unit/targets/${e}`,"4. Run: pnpm schemas:generate && pnpm matrix:generate"];return {written:c,skipped:l,postSteps:m}}s(IM,"writeTargetScaffold");async function SM(t,e,r){let o=e[0];return o===void 0||o===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:o==="scaffold"?lX(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${o}`}}s(SM,"runTarget");async function lX(t,e,r){let o=e[0];if(!o)throw new co("Usage: agentsmesh target scaffold <id> [--name <displayName>] [--force]");let n=typeof t.name=="string"?t.name:void 0,i=t.force===true,a;try{a=await IM({id:o,displayName:n,projectRoot:r,force:i});}catch(c){return {exitCode:1,data:{id:o,written:[],skipped:[],postSteps:[]},error:c instanceof Error?c.message:String(c)}}return {exitCode:0,data:{id:o,written:a.written.map(c=>RM(c,r)),skipped:a.skipped.map(c=>RM(c,r)),postSteps:a.postSteps}}}s(lX,"runScaffold");function RM(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(RM,"relativize");ft();function CM(t){if(t.error&&_.error(t.error),t.showHelp){mX();return}let{data:e}=t;for(let r of e.written)_.success(`created ${r}`);for(let r of e.skipped)_.warn(`skipped ${r} (already exists \u2014 use --force to overwrite)`);if(e.written.length>0){_.info(""),_.info("Next steps:");for(let r of e.postSteps)_.info(` ${r}`);}}s(CM,"renderTarget");function mX(){_.info("Usage: agentsmesh target <subcommand> [args] [flags]"),_.info(""),_.info("Subcommands:"),_.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),_.info(""),_.info("Flags (scaffold):"),_.info(" --name <displayName> Human-readable name (defaults to id)"),_.info(" --force Overwrite existing files");}s(mX,"printTargetHelp");je();yi();T();Oe();ms();pn();function _X(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(_X,"shouldSymlink");function IX(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let o of r){if(!_X(o.name,o.isDirectory()))continue;let n=join(t,o.name),i=join(e,o.name);symlinkSync(n,i,o.isDirectory()?"dir":"file");}return mkdirSync(join(e,".agentsmesh"),{recursive:true}),e}s(IX,"createTempProjectRoot");async function og(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=o==="global"?homedir():r,i=t.from,a=t.to;if(typeof i!="string"||!i)throw new Error("--from is required. Example: agentsmesh convert --from cursor --to claude-code");if(typeof a!="string"||!a)throw new Error("--to is required. Example: agentsmesh convert --from cursor --to claude-code");let c=i.toLowerCase().trim(),l=a.toLowerCase().trim();if(c===l)throw new Error("--from and --to must be different targets.");let m=wr(c),p=wr(l);if(!m||!p)try{let{config:R}=await Tt(r,"project");await ce(R,r);}catch{let R=[];throw m||R.push(`--from "${i}"`),p||R.push(`--to "${a}"`),new Error(`Unknown ${R.join(" and ")}. Supported: ${kt.join(", ")}.`)}let d=ut(c);if(!d)throw new Error(`Unknown --from "${i}". Supported: ${kt.join(", ")}.`);if(!ut(l))throw new Error(`Unknown --to "${a}". Supported: ${kt.join(", ")}.`);let f=t["dry-run"]===true,h=f?"dry-run":"convert",O=IX(n);try{await d.generators.importFrom(O,{scope:o});let R=await Ae(O),E=pi.parse({version:1,targets:p?[l]:[],pluginTargets:p?[]:[l]}),A=await Or({config:E,canonical:R,projectRoot:n,scope:o,targetFilter:[l]});if(!f){for(let G of A)if(G.status==="created"||G.status==="updated"){let J=qc(n,G.path,G.target);await I(J,G.content);}}let F=A.filter(G=>G.status!=="skipped"),v=F.map(G=>({path:G.path,target:G.target,status:G.status}));return {exitCode:0,data:{from:c,to:l,mode:h,files:v,summary:{created:F.filter(G=>G.status==="created").length,updated:F.filter(G=>G.status==="updated").length,unchanged:F.filter(G=>G.status==="unchanged").length}}}}finally{rmSync(O,{recursive:true,force:true});}}s(og,"runConvert");ft();function EM(t){let{data:e}=t;if(e.files.length===0){_.info(`No files found to convert from ${e.from}.`);return}if(e.mode==="dry-run"){for(let i of e.files)_.info(`[dry-run] ${i.status} ${i.path} (${i.target})`);return}for(let i of e.files)(i.status==="created"||i.status==="updated")&&_.success(`${i.status} ${i.path}`);let{created:r,updated:o,unchanged:n}=e.summary;r>0||o>0?_.info(`Converted from ${e.from} \u2192 ${e.to}: ${r} created, ${o} updated, ${n} unchanged`):_.info(`Nothing changed. (${n} unchanged)`);}s(EM,"renderConvert");var RX=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,B=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,o){if(RX.test(r))throw new Error(`McpError refuses absolute fs path in message: ${r}`);super(r),this.code=e,this.details=o;}toEnvelope(){return this.details===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,details:this.details}}};function OM(t){return t.replace(/(['"`])\/[^'"`\s]+\1/gu,"$1<redacted>$1").replace(/(\s|^)\/[A-Za-z][^\s'"`]*/gu,"$1<redacted>").replace(/(\s|^)[A-Z]:[\\/][^\s'"`]*/gu,"$1<redacted>")}s(OM,"redactAbsolutePaths");async function YI(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new B("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","file body exceeds 1 MiB cap",{limit:1048576,actual:Buffer.byteLength(t.content,"utf8")});await mkdir(dirname(r),{recursive:true});let o=`${r}.tmp.${process.pid}.${Date.now()}`;return await writeFile(o,t.content,"utf8"),await rename(o,r),r}s(YI,"safeWrite");var wX=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function ci(t){let e=wX.exec(t);return e?{frontmatter:parse(e[1]??"")??{},body:e[2]??""}:{frontmatter:{},body:t}}s(ci,"parseMd");function il(t,e){return Object.keys(t).length===0?e:`---
|
|
558
558
|
${stringify(t).trimEnd()}
|
|
559
559
|
---
|
|
560
560
|
|
|
561
|
-
${e}`}s(cl,"serializeMd");var NX=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,FX={rules:"_root"};function ig(t){if(!NX.test(t)||t.includes(".."))throw new B("INVALID_NAME",`invalid name: ${t}`)}s(ig,"checkName");function ag(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(ag,"pathFor");function ll(t){let{feature:e,frontmatterSchema:r,toSummary:o}=t,n=s(c=>resolve(c,".agentsmesh",e),"featureDir");async function i(c){try{return (await readdir(n(c),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(c){try{return await stat(c),!0}catch{return false}}return s(a,"exists"),{async list(c){let l=await i(c.projectRoot),m=[];for(let p of l){let u=p.replace(/\.md$/,""),g=await readFile(join(n(c.projectRoot),p),"utf8"),{frontmatter:f}=pi(g);m.push(o(u,f));}return m},async get(c,{name:l}){ig(l);let m=ag(c.projectRoot,e,l);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:g}=pi(p);return {name:l,frontmatter:u,body:g}}catch(p){let u=p.code;throw u==="ENOENT"?new B("NOT_FOUND",`${e} "${l}" not found`):new B("IO_ERROR",`failed to read ${e}`,{errno:u})}},async create(c,{name:l,frontmatter:m,body:p,dry_run:u}){ig(l);let g=r.safeParse(m);if(!g.success)throw new B("VALIDATION_FAILED","invalid frontmatter",g.error.issues);let f=ag(c.projectRoot,e,l);if(await a(f))throw new B("ALREADY_EXISTS",`${e} "${l}" exists`);if((await i(c.projectRoot)).length>=1e3)throw new B("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let O=cl(m,p);return u===true?{path:f,written:false}:(await eR({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:O}),{path:f,written:true})},async update(c,{name:l,frontmatter:m,body:p,merge:u,dry_run:g}){ig(l);let f=ag(c.projectRoot,e,l),h;try{let D=await readFile(f,"utf8");h=pi(D);}catch(D){let N=D.code;throw N==="ENOENT"?new B("NOT_FOUND",`${e} "${l}" not found`):new B("IO_ERROR",`failed to read ${e}`,{errno:N})}let O=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,R=r.safeParse(O);if(!R.success)throw new B("VALIDATION_FAILED","invalid frontmatter",R.error.issues);let S=p!==void 0?p:h.body,A=cl(O,S);return g===true?{path:f,written:false}:(await eR({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:A}),{path:f,written:true})},async delete(c,{name:l,force:m,dry_run:p}){if(ig(l),FX[e]===l&&m!==true)throw new B("PROTECTED_FILE",`${e} "${l}" requires force: true`);let u=ag(c.projectRoot,e,l);if(!await a(u))throw new B("NOT_FOUND",`${e} "${l}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(ll,"createCanonicalHandlers");var vX=z$1.object({description:z$1.string().optional(),root:z$1.boolean().optional(),globs:z$1.array(z$1.string()).nullable().optional(),targets:z$1.array(z$1.string()).nullable().optional()}).passthrough(),kM=ll({feature:"rules",frontmatterSchema:vX,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var GX=z$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),wM=ll({feature:"commands",frontmatterSchema:GX,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var MX=z$1.object({name:z$1.string().optional(),description:z$1.string().optional(),tools:z$1.array(z$1.string()).optional(),model:z$1.string().optional()}).passthrough(),TM=ll({feature:"agents",frontmatterSchema:MX,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var $X=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")')}),jX=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")'),frontmatter:z$1.record(z$1.string(),z$1.unknown()).describe("YAML frontmatter fields (e.g. { description, globs, targets })"),body:z$1.string().describe("Markdown body content"),dry_run:z$1.boolean().optional().describe("Preview changes without writing to disk")}),UX=z$1.object({}).strict();function oR(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:UX,handler:s(o=>e.list(o),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:$X,handler:s((o,n)=>e.get(o,n),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:jX,handler:s((o,n)=>e.create(o,n),"handler")},{name:`update_${t}`,description:`Update a ${t}. Default: replace frontmatter entirely. Set merge=true to shallow-merge. Omitting body preserves the existing body.`,inputSchema:z$1.object({name:z$1.string().describe("Name of the item to update"),frontmatter:z$1.record(z$1.string(),z$1.unknown()).optional().describe("New frontmatter fields (replaces by default; set merge=true to shallow-merge)"),body:z$1.string().optional().describe("New markdown body (omit to preserve existing)"),merge:z$1.boolean().optional().describe("If true, shallow-merge frontmatter instead of replacing"),dry_run:z$1.boolean().optional().describe("Preview changes without writing to disk")}),handler:s((o,n)=>e.update(o,n),"handler")},{name:`delete_${t}`,description:`Delete a ${t}. For rules: deleting _root requires force=true.`,inputSchema:z$1.object({name:z$1.string().describe("Name of the item to delete"),force:z$1.boolean().optional().describe("Required to delete protected files like _root"),dry_run:z$1.boolean().optional().describe("Preview without deleting")}),handler:s((o,n)=>e.delete(o,n),"handler")}]}s(oR,"canonicalTools");var bM=[...oR("rule",kM),...oR("command",wM),...oR("agent",TM)];async function xM(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new B("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(o){throw o.code==="ENOENT"?new B("NOT_FOUND",`skill file not found: ${t.filePath}`):new B("IO_ERROR","failed to read skill file")}}s(xM,"safeRead");var JX=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,YX=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,vM=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function Jm(t){if(!JX.test(t))throw new B("INVALID_NAME",`invalid skill name: ${t}`)}s(Jm,"checkName");function iR(t){if(!YX.test(t)||t.includes("..")||t.includes("//"))throw new B("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(iR,"checkSupportPath");async function mg(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","file body exceeds 1 MiB cap");await mkdir(dirname(t),{recursive:true});let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(mg,"atomicWrite");var GM=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),Ym=s((t,e)=>resolve(GM(t),e),"skillDir"),Ta={async list(t){let e;try{e=(await readdir(GM(t.projectRoot),{withFileTypes:!0})).filter(o=>o.isDirectory()).map(o=>o.name);}catch{return []}let r=[];for(let o of e)try{let n=await readFile(resolve(Ym(t.projectRoot,o),"SKILL.md"),"utf8"),i=pi(n).frontmatter;r.push({name:o,description:i.description??null});}catch{}return r},async get(t,{name:e}){Jm(e);let r=Ym(t.projectRoot,e);try{let o=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:n,body:i}=pi(o),c=(await readdir(r)).filter(l=>l!=="SKILL.md").sort();return {name:e,frontmatter:n,body:i,supportingFiles:c}}catch(o){throw o.code==="ENOENT"?new B("NOT_FOUND",`skill "${e}" not found`):new B("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Jm(e),iR(r),{content:await xM({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Jm(e.name);let r=vM.safeParse(e.frontmatter);if(!r.success)throw new B("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let o=Ym(t.projectRoot,e.name),n=false;try{await stat(o),n=!0;}catch{}if(n)throw new B("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(iR),a.length+1>1e3)throw new B("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:o,written:false,supportingFilesWritten:[]};let c=resolve(o,"SKILL.md");await mg(c,cl(e.frontmatter,e.body));for(let[l,m]of Object.entries(i))await mg(resolve(o,l),m);return {path:o,written:true,supportingFilesWritten:a}},async update(t,e){Jm(e.name);let r=Ym(t.projectRoot,e.name),o;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");o=pi(p);}catch(p){throw p.code==="ENOENT"?new B("NOT_FOUND",`skill "${e.name}" not found`):new B("IO_ERROR","failed to read skill")}let n=e.frontmatter===void 0?o.frontmatter:e.merge===true?{...o.frontmatter,...e.frontmatter}:e.frontmatter,i=vM.safeParse(n);if(!i.success)throw new B("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:o.body,c=e.supportingFiles??{};Object.keys(c).forEach(iR);let l=[],m=[];if(e.dry_run===true)return Object.entries(c).forEach(([p,u])=>(u===null?m:l).push(p)),{path:r,written:false,supportingFilesAffected:{written:l,deleted:m}};await mg(resolve(r,"SKILL.md"),cl(n,a));for(let[p,u]of Object.entries(c)){let g=resolve(r,p);if(u===null)try{await rm$1(g),m.push(p);}catch{}else await mg(g,u),l.push(p);}return {path:r,written:true,supportingFilesAffected:{written:l,deleted:m}}},async delete(t,{name:e,dry_run:r}){Jm(e);let o=Ym(t.projectRoot,e);try{await stat(o);}catch{throw new B("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:o,deleted:false}:(await rm$1(o,{recursive:true}),{path:o,deleted:true})}};var XX=z$1.object({}).strict(),ZX=z$1.object({name:z$1.string().describe("Item name")}),MM=[{name:"list_skills",description:"List skills",inputSchema:XX,handler:s(t=>Ta.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:ZX,handler:s((t,e)=>Ta.get(t,e),"handler"),resourceUri:"agentsmesh://canonical/skills/{name}"},{name:"get_skill_file",description:"Read a skill supporting file by name and relative path",inputSchema:z$1.object({name:z$1.string().describe("Skill name"),path:z$1.string().describe('Relative path within the skill directory (e.g. "helper.md")')}),handler:s((t,e)=>Ta.getFile(t,e),"handler"),resourceUri:"agentsmesh://canonical/skills/{name}/files/{path}"},{name:"create_skill",description:"Create a skill directory with SKILL.md and optional supporting files",inputSchema:z$1.object({name:z$1.string().describe("Skill name (becomes directory name)"),frontmatter:z$1.record(z$1.string(),z$1.unknown()).describe("YAML frontmatter for SKILL.md"),body:z$1.string().describe("Markdown body for SKILL.md"),supportingFiles:z$1.record(z$1.string(),z$1.string()).optional().describe("Map of relative-path \u2192 content for supporting files"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ta.create(t,e),"handler")},{name:"update_skill",description:"Update a skill. supportingFiles: string value writes/replaces, null deletes, unlisted files are untouched.",inputSchema:z$1.object({name:z$1.string().describe("Skill name"),frontmatter:z$1.record(z$1.string(),z$1.unknown()).optional().describe("New frontmatter (replaces by default; merge=true to shallow-merge)"),body:z$1.string().optional().describe("New body (omit to preserve existing)"),merge:z$1.boolean().optional().describe("Shallow-merge frontmatter instead of replacing"),supportingFiles:z$1.record(z$1.string(),z$1.union([z$1.string(),z$1.null()])).optional().describe("Map of path \u2192 content (string=write, null=delete, absent=keep)"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ta.update(t,e),"handler")},{name:"delete_skill",description:"Delete a skill",inputSchema:z$1.object({name:z$1.string(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>Ta.delete(t,e),"handler")}];async function $M(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new B("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","config exceeds 1 MiB cap");let e=resolve(t.projectRoot,"agentsmesh.yaml"),r=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(r,t.content,"utf8"),await rename(r,e),e}s($M,"safeConfigWrite");gn();Cl();async function Xm(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new B("IO_ERROR","failed to read yaml")}}s(Xm,"readYaml");async function pl(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","file exceeds 1 MiB cap");let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(pl,"atomicWrite");var We={async getConfig(t){let e=await Xm(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new B("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await br(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await Xm(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Xm(resolve(t.projectRoot,".agentsmesh/hooks.yaml"))??null},async getIgnore(t){try{return {patterns:(await readFile(resolve(t.projectRoot,".agentsmesh/ignore"),"utf8")).split(/\r?\n/).filter(r=>r!==""&&!r.startsWith("#"))}}catch{return {patterns:null}}},async updateConfig(t,e){let r=await Xm(resolve(t.projectRoot,"agentsmesh.yaml"))??{},o={...r},n=s((l,m)=>{m!==void 0&&(o[l]=e.merge===true&&Array.isArray(r[l])?Array.from(new Set([...r[l],...m])):m);},"apply");n("targets",e.targets),n("features",e.features),e.conversions!==void 0&&(o.conversions=e.merge===true&&r.conversions!==void 0?{...r.conversions,...e.conversions}:e.conversions);let i=gi.safeParse(o);if(!i.success)throw new B("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(o);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await $M({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await br(r).catch(()=>null)??{mcpServers:{}};if(o.mcpServers[e.name]!==void 0)throw new B("ALREADY_EXISTS",`server "${e.name}" exists`);return o.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await pl(r,JSON.stringify(o,null,2)+`
|
|
562
|
-
`),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await
|
|
563
|
-
`),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await
|
|
564
|
-
`),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),o=await Xm(r)??{allow:[],deny:[],ask:[]},n={...o},i=s((a,c)=>{c!==void 0&&(n[a]=e.mode==="append"?Array.from(new Set([...o[a]??[],...c])):c);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await
|
|
561
|
+
${e}`}s(il,"serializeMd");var DX=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,NX={rules:"_root"};function ng(t){if(!DX.test(t)||t.includes(".."))throw new B("INVALID_NAME",`invalid name: ${t}`)}s(ng,"checkName");function sg(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(sg,"pathFor");function al(t){let{feature:e,frontmatterSchema:r,toSummary:o}=t,n=s(c=>resolve(c,".agentsmesh",e),"featureDir");async function i(c){try{return (await readdir(n(c),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(c){try{return await stat(c),!0}catch{return false}}return s(a,"exists"),{async list(c){let l=await i(c.projectRoot),m=[];for(let p of l){let d=p.replace(/\.md$/,""),g=await readFile(join(n(c.projectRoot),p),"utf8"),{frontmatter:f}=ci(g);m.push(o(d,f));}return m},async get(c,{name:l}){ng(l);let m=sg(c.projectRoot,e,l);try{let p=await readFile(m,"utf8"),{frontmatter:d,body:g}=ci(p);return {name:l,frontmatter:d,body:g}}catch(p){let d=p.code;throw d==="ENOENT"?new B("NOT_FOUND",`${e} "${l}" not found`):new B("IO_ERROR",`failed to read ${e}`,{errno:d})}},async create(c,{name:l,frontmatter:m,body:p,dry_run:d}){ng(l);let g=r.safeParse(m);if(!g.success)throw new B("VALIDATION_FAILED","invalid frontmatter",g.error.issues);let f=sg(c.projectRoot,e,l);if(await a(f))throw new B("ALREADY_EXISTS",`${e} "${l}" exists`);if((await i(c.projectRoot)).length>=1e3)throw new B("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let O=il(m,p);return d===true?{path:f,written:false}:(await YI({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:O}),{path:f,written:true})},async update(c,{name:l,frontmatter:m,body:p,merge:d,dry_run:g}){ng(l);let f=sg(c.projectRoot,e,l),h;try{let F=await readFile(f,"utf8");h=ci(F);}catch(F){let v=F.code;throw v==="ENOENT"?new B("NOT_FOUND",`${e} "${l}" not found`):new B("IO_ERROR",`failed to read ${e}`,{errno:v})}let O=m===void 0?h.frontmatter:d===true?{...h.frontmatter,...m}:m,R=r.safeParse(O);if(!R.success)throw new B("VALIDATION_FAILED","invalid frontmatter",R.error.issues);let E=p!==void 0?p:h.body,A=il(O,E);return g===true?{path:f,written:false}:(await YI({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:A}),{path:f,written:true})},async delete(c,{name:l,force:m,dry_run:p}){if(ng(l),NX[e]===l&&m!==true)throw new B("PROTECTED_FILE",`${e} "${l}" requires force: true`);let d=sg(c.projectRoot,e,l);if(!await a(d))throw new B("NOT_FOUND",`${e} "${l}" not found`);return p===true?{path:d,deleted:false}:(await rm$1(d),{path:d,deleted:true})}}}s(al,"createCanonicalHandlers");var FX=z$1.object({description:z$1.string().optional(),root:z$1.boolean().optional(),globs:z$1.array(z$1.string()).nullable().optional(),targets:z$1.array(z$1.string()).nullable().optional()}).passthrough(),kM=al({feature:"rules",frontmatterSchema:FX,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var vX=z$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),wM=al({feature:"commands",frontmatterSchema:vX,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var GX=z$1.object({name:z$1.string().optional(),description:z$1.string().optional(),tools:z$1.array(z$1.string()).optional(),model:z$1.string().optional()}).passthrough(),TM=al({feature:"agents",frontmatterSchema:GX,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var MX=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")')}),$X=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")'),frontmatter:z$1.record(z$1.string(),z$1.unknown()).describe("YAML frontmatter fields (e.g. { description, globs, targets })"),body:z$1.string().describe("Markdown body content"),dry_run:z$1.boolean().optional().describe("Preview changes without writing to disk")}),jX=z$1.object({}).strict();function ZI(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:jX,handler:s(o=>e.list(o),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:MX,handler:s((o,n)=>e.get(o,n),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:$X,handler:s((o,n)=>e.create(o,n),"handler")},{name:`update_${t}`,description:`Update a ${t}. Default: replace frontmatter entirely. Set merge=true to shallow-merge. Omitting body preserves the existing body.`,inputSchema:z$1.object({name:z$1.string().describe("Name of the item to update"),frontmatter:z$1.record(z$1.string(),z$1.unknown()).optional().describe("New frontmatter fields (replaces by default; set merge=true to shallow-merge)"),body:z$1.string().optional().describe("New markdown body (omit to preserve existing)"),merge:z$1.boolean().optional().describe("If true, shallow-merge frontmatter instead of replacing"),dry_run:z$1.boolean().optional().describe("Preview changes without writing to disk")}),handler:s((o,n)=>e.update(o,n),"handler")},{name:`delete_${t}`,description:`Delete a ${t}. For rules: deleting _root requires force=true.`,inputSchema:z$1.object({name:z$1.string().describe("Name of the item to delete"),force:z$1.boolean().optional().describe("Required to delete protected files like _root"),dry_run:z$1.boolean().optional().describe("Preview without deleting")}),handler:s((o,n)=>e.delete(o,n),"handler")}]}s(ZI,"canonicalTools");var bM=[...ZI("rule",kM),...ZI("command",wM),...ZI("agent",TM)];async function xM(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new B("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(o){throw o.code==="ENOENT"?new B("NOT_FOUND",`skill file not found: ${t.filePath}`):new B("IO_ERROR","failed to read skill file")}}s(xM,"safeRead");var VX=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,JX=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,vM=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function Jm(t){if(!VX.test(t))throw new B("INVALID_NAME",`invalid skill name: ${t}`)}s(Jm,"checkName");function tR(t){if(!JX.test(t)||t.includes("..")||t.includes("//"))throw new B("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(tR,"checkSupportPath");async function cg(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","file body exceeds 1 MiB cap");await mkdir(dirname(t),{recursive:true});let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(cg,"atomicWrite");var GM=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),Ym=s((t,e)=>resolve(GM(t),e),"skillDir"),Aa={async list(t){let e;try{e=(await readdir(GM(t.projectRoot),{withFileTypes:!0})).filter(o=>o.isDirectory()).map(o=>o.name);}catch{return []}let r=[];for(let o of e)try{let n=await readFile(resolve(Ym(t.projectRoot,o),"SKILL.md"),"utf8"),i=ci(n).frontmatter;r.push({name:o,description:i.description??null});}catch{}return r},async get(t,{name:e}){Jm(e);let r=Ym(t.projectRoot,e);try{let o=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:n,body:i}=ci(o),c=(await readdir(r)).filter(l=>l!=="SKILL.md").sort();return {name:e,frontmatter:n,body:i,supportingFiles:c}}catch(o){throw o.code==="ENOENT"?new B("NOT_FOUND",`skill "${e}" not found`):new B("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Jm(e),tR(r),{content:await xM({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Jm(e.name);let r=vM.safeParse(e.frontmatter);if(!r.success)throw new B("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let o=Ym(t.projectRoot,e.name),n=false;try{await stat(o),n=!0;}catch{}if(n)throw new B("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(tR),a.length+1>1e3)throw new B("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:o,written:false,supportingFilesWritten:[]};let c=resolve(o,"SKILL.md");await cg(c,il(e.frontmatter,e.body));for(let[l,m]of Object.entries(i))await cg(resolve(o,l),m);return {path:o,written:true,supportingFilesWritten:a}},async update(t,e){Jm(e.name);let r=Ym(t.projectRoot,e.name),o;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");o=ci(p);}catch(p){throw p.code==="ENOENT"?new B("NOT_FOUND",`skill "${e.name}" not found`):new B("IO_ERROR","failed to read skill")}let n=e.frontmatter===void 0?o.frontmatter:e.merge===true?{...o.frontmatter,...e.frontmatter}:e.frontmatter,i=vM.safeParse(n);if(!i.success)throw new B("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:o.body,c=e.supportingFiles??{};Object.keys(c).forEach(tR);let l=[],m=[];if(e.dry_run===true)return Object.entries(c).forEach(([p,d])=>(d===null?m:l).push(p)),{path:r,written:false,supportingFilesAffected:{written:l,deleted:m}};await cg(resolve(r,"SKILL.md"),il(n,a));for(let[p,d]of Object.entries(c)){let g=resolve(r,p);if(d===null)try{await rm$1(g),m.push(p);}catch{}else await cg(g,d),l.push(p);}return {path:r,written:true,supportingFilesAffected:{written:l,deleted:m}}},async delete(t,{name:e,dry_run:r}){Jm(e);let o=Ym(t.projectRoot,e);try{await stat(o);}catch{throw new B("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:o,deleted:false}:(await rm$1(o,{recursive:true}),{path:o,deleted:true})}};var YX=z$1.object({}).strict(),XX=z$1.object({name:z$1.string().describe("Item name")}),MM=[{name:"list_skills",description:"List skills",inputSchema:YX,handler:s(t=>Aa.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:XX,handler:s((t,e)=>Aa.get(t,e),"handler"),resourceUri:"agentsmesh://canonical/skills/{name}"},{name:"get_skill_file",description:"Read a skill supporting file by name and relative path",inputSchema:z$1.object({name:z$1.string().describe("Skill name"),path:z$1.string().describe('Relative path within the skill directory (e.g. "helper.md")')}),handler:s((t,e)=>Aa.getFile(t,e),"handler"),resourceUri:"agentsmesh://canonical/skills/{name}/files/{path}"},{name:"create_skill",description:"Create a skill directory with SKILL.md and optional supporting files",inputSchema:z$1.object({name:z$1.string().describe("Skill name (becomes directory name)"),frontmatter:z$1.record(z$1.string(),z$1.unknown()).describe("YAML frontmatter for SKILL.md"),body:z$1.string().describe("Markdown body for SKILL.md"),supportingFiles:z$1.record(z$1.string(),z$1.string()).optional().describe("Map of relative-path \u2192 content for supporting files"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Aa.create(t,e),"handler")},{name:"update_skill",description:"Update a skill. supportingFiles: string value writes/replaces, null deletes, unlisted files are untouched.",inputSchema:z$1.object({name:z$1.string().describe("Skill name"),frontmatter:z$1.record(z$1.string(),z$1.unknown()).optional().describe("New frontmatter (replaces by default; merge=true to shallow-merge)"),body:z$1.string().optional().describe("New body (omit to preserve existing)"),merge:z$1.boolean().optional().describe("Shallow-merge frontmatter instead of replacing"),supportingFiles:z$1.record(z$1.string(),z$1.union([z$1.string(),z$1.null()])).optional().describe("Map of path \u2192 content (string=write, null=delete, absent=keep)"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Aa.update(t,e),"handler")},{name:"delete_skill",description:"Delete a skill",inputSchema:z$1.object({name:z$1.string(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>Aa.delete(t,e),"handler")}];async function $M(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new B("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","config exceeds 1 MiB cap");let e=resolve(t.projectRoot,"agentsmesh.yaml"),r=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(r,t.content,"utf8"),await rename(r,e),e}s($M,"safeConfigWrite");pn();Rl();async function Xm(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new B("IO_ERROR","failed to read yaml")}}s(Xm,"readYaml");async function ll(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new B("LIMIT_EXCEEDED","file exceeds 1 MiB cap");let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(ll,"atomicWrite");var We={async getConfig(t){let e=await Xm(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new B("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await Tr(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await Xm(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Xm(resolve(t.projectRoot,".agentsmesh/hooks.yaml"))??null},async getIgnore(t){try{return {patterns:(await readFile(resolve(t.projectRoot,".agentsmesh/ignore"),"utf8")).split(/\r?\n/).filter(r=>r!==""&&!r.startsWith("#"))}}catch{return {patterns:null}}},async updateConfig(t,e){let r=await Xm(resolve(t.projectRoot,"agentsmesh.yaml"))??{},o={...r},n=s((l,m)=>{m!==void 0&&(o[l]=e.merge===true&&Array.isArray(r[l])?Array.from(new Set([...r[l],...m])):m);},"apply");n("targets",e.targets),n("features",e.features),e.conversions!==void 0&&(o.conversions=e.merge===true&&r.conversions!==void 0?{...r.conversions,...e.conversions}:e.conversions);let i=pi.safeParse(o);if(!i.success)throw new B("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(o);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await $M({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await Tr(r).catch(()=>null)??{mcpServers:{}};if(o.mcpServers[e.name]!==void 0)throw new B("ALREADY_EXISTS",`server "${e.name}" exists`);return o.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await ll(r,JSON.stringify(o,null,2)+`
|
|
562
|
+
`),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await Tr(r).catch(()=>null);if(o===null||o.mcpServers[e.name]===void 0)throw new B("NOT_FOUND",`server "${e.name}" not found`);return o.mcpServers[e.name]=e.merge===true?{...o.mcpServers[e.name],...e.server}:e.server,e.dry_run===true?{path:r,written:false}:(await ll(r,JSON.stringify(o,null,2)+`
|
|
563
|
+
`),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await Tr(r).catch(()=>null);if(o===null||o.mcpServers[e.name]===void 0)throw new B("NOT_FOUND",`server "${e.name}" not found`);return delete o.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await ll(r,JSON.stringify(o,null,2)+`
|
|
564
|
+
`),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),o=await Xm(r)??{allow:[],deny:[],ask:[]},n={...o},i=s((a,c)=>{c!==void 0&&(n[a]=e.mode==="append"?Array.from(new Set([...o[a]??[],...c])):c);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await ll(r,stringify(n)),{path:r,written:true})},async updateHooks(t,e){let r=resolve(t.projectRoot,".agentsmesh/hooks.yaml");return e.dry_run===true?{path:r,written:false}:(await ll(r,stringify(e.hooks)),{path:r,written:true})},async updateIgnore(t,e){let r=resolve(t.projectRoot,".agentsmesh/ignore"),o;if(e.mode==="append"){let n=(await readFile(r,"utf8").catch(()=>"")).split(/\r?\n/).filter(Boolean);o=Array.from(new Set([...n,...e.patterns]));}else o=e.patterns;return e.dry_run===true?{path:r,written:false}:(await ll(r,o.join(`
|
|
565
565
|
`)+`
|
|
566
|
-
`),{path:r,written:true})}};var d2=/[;&|`$<>!\\\r\n]/u,g2=/^[A-Za-z_][A-Za-z0-9_]*$/u,f2=/^[A-Za-z][A-Za-z0-9_-]*$/u,h2=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,KM=/[\r\n]/u;function y2(t){return z$1.string().min(1).max(512).refine(e=>!d2.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(y2,"noShellMeta");var lR=z$1.object({type:z$1.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z$1.string().max(1024).optional(),command:y2("command").optional(),args:z$1.array(z$1.string().max(2048)).max(100).optional(),env:z$1.record(z$1.string().regex(g2,"env key must be a valid identifier"),z$1.string().max(8192)).optional(),url:z$1.string().url().max(2048).refine(t=>/^https?:\/\//u.test(t),{message:"url must use http(s) protocol"}).optional(),headers:z$1.record(z$1.string().regex(f2,"header name must be a valid identifier"),z$1.string().max(8192)).optional(),cwd:z$1.string().max(2048).optional(),disabled:z$1.boolean().optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict(),_2=z$1.object({type:z$1.enum(["command","prompt"]).optional(),command:z$1.string().min(1).max(8192).optional(),prompt:z$1.string().min(1).max(8192).optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict().refine(t=>(t.command??"").length>0||(t.prompt??"").length>0,{message:"hook entry must define command or prompt"}),BM=z$1.string().max(256).refine(t=>!KM.test(t),{message:"hook matcher must not contain newlines"}),I2=z$1.object({matcher:BM,type:z$1.enum(["command","prompt"]).optional(),command:z$1.string().min(1).max(8192).optional(),prompt:z$1.string().min(1).max(8192).optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict().refine(t=>(t.command??"").length>0||(t.prompt??"").length>0,{message:"hook entry must define command or prompt"}),R2=z$1.object({matcher:BM,hooks:z$1.array(_2).min(1).max(50)}).strict(),S2=z$1.union([I2,R2]),WM=z$1.record(z$1.string().min(1).max(64),z$1.array(S2).max(100)),C2=z$1.string().min(1).max(256).refine(t=>!KM.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>h2.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),ug=z$1.array(C2).max(500);var Zm=z$1.object({}).strict(),E2=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Zm,handler:s(t=>We.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Zm,handler:s(t=>We.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Zm,handler:s(t=>We.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Zm,handler:s(t=>We.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Zm,handler:s(t=>We.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],O2=[{name:"update_config",description:"Update agentsmesh.yaml. Default: replace listed fields. Set merge=true to union arrays and shallow-merge objects. Only writes agentsmesh.yaml, never agentsmesh.local.yaml.",inputSchema:z$1.object({targets:z$1.array(z$1.string()).optional().describe('Target tool IDs (e.g. ["claude-code", "cursor"])'),features:z$1.array(z$1.string()).optional().describe('Feature names (e.g. ["rules", "commands", "mcp"])'),conversions:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Conversion overrides"),merge:z$1.boolean().optional().describe("If true, union arrays and shallow-merge objects instead of replacing"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updateConfig(t,e),"handler")},{name:"add_mcp_server",description:"Add an MCP server entry to .agentsmesh/mcp.json. Fails if name already exists.",inputSchema:z$1.object({name:z$1.string().describe('Server name (e.g. "github", "filesystem")'),server:lR.describe('Server config (e.g. { type: "stdio", command: "npx", args: [...], env: {...} })'),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.addMcpServer(t,e),"handler")},{name:"update_mcp_server",description:"Update an MCP server entry (replace or merge)",inputSchema:z$1.object({name:z$1.string(),server:lR,merge:z$1.boolean().optional(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>We.updateMcpServer(t,e),"handler")},{name:"remove_mcp_server",description:"Remove an MCP server entry",inputSchema:z$1.object({name:z$1.string(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>We.removeMcpServer(t,e),"handler")},{name:"update_permissions",description:"Update permissions.yaml. mode=replace (default) overwrites listed fields; mode=append unions and dedups.",inputSchema:z$1.object({allow:ug.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:ug.optional().describe("Denied tool patterns"),ask:ug.optional().describe("Tools requiring confirmation"),mode:z$1.enum(["replace","append"]).optional().describe("replace=overwrite, append=union+dedup (default: replace)"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updatePermissions(t,e),"handler")},{name:"update_hooks",description:"Replace hooks.yaml content entirely. Read current hooks with get_hooks, modify, then write back.",inputSchema:z$1.object({hooks:WM.describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updateHooks(t,e),"handler")},{name:"update_ignore",description:"Update .agentsmesh/ignore patterns. mode=replace (default) overwrites; mode=append adds new patterns.",inputSchema:z$1.object({patterns:z$1.array(z$1.string()).describe('Gitignore-syntax patterns (e.g. ["node_modules/", "dist/", ".env*"])'),mode:z$1.enum(["replace","append"]).optional().describe("replace=overwrite, append=add (default: replace)"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updateIgnore(t,e),"handler")}],HM=[...E2,...O2];rI();uo();function L2(){return Object.fromEntries(kt.map(t=>[t,Object.fromEntries(Object.entries(fv).map(([e,r])=>[e,r[t]]))]))}s(L2,"buildTargetIndex");var zM=L2(),mR={async list(){return zM},async get(t){let e=zM[t.targetId];if(e===void 0)throw new B("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};dn();dn();rp();Oe();ln();ds();je();uo();async function pR(t,e){let r=ut(t);if(!r)throw new po(t,{supported:[...kt,...Id().map(o=>o.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(pR,"importFrom");async function ul(t,e={}){let r=e.scope??"project",{config:o,context:n}=await Tt(t,r);await le(o,t);let{canonical:i}=await he(o,n.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},n.canonicalDir);return {config:o,canonical:i,projectRoot:n.rootBase,scope:r,configDir:n.configDir,canonicalDir:n.canonicalDir}}s(ul,"loadProjectContext");async function uR(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return Vd(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(uR,"lint");async function dR(t){let e=await Lr(t);return {...Hd(e),results:e}}s(dR,"diff");async function gR(t){return Jd(t)}s(gR,"check");dn();ln();Ri();rp();xt();je();Ct();T();function ui(t){if(t instanceof B)throw t;if(t instanceof po)throw new B("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new B("VALIDATION_FAILED",e):/lock/i.test(e)?new B("LOCK_HELD","generate lock is held"):new B("IO_ERROR","engine failure",{reason:e})}s(ui,"wrapEngineError");async function VM(t,e){if(e.dry_run===true)throw new B("VALIDATION_FAILED","dry_run is not supported for import \u2014 the engine writes files directly. Use diff to preview changes instead.");try{let r=await pR(e.from,{root:t.projectRoot,scope:"project"});return {imported:r.length,files:r.map(o=>({fromPath:o.fromPath,toPath:o.toPath,feature:o.feature})),warnings:[],errors:[]}}catch(r){if(r instanceof po)throw new B("VALIDATION_FAILED",`unknown target "${e.from}"`);let o=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(o))throw new B("VALIDATION_FAILED",o);ui(r);}}s(VM,"importFromTarget");async function JM(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},o=await sg(r,t.projectRoot);return {filesAffected:o.data.summary.created+o.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let o=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(o))throw new B("VALIDATION_FAILED",o);ui(r);}}s(JM,"convert");async function T2(t,e){try{let r=await ul(t.projectRoot),o=e.targets&&e.targets.length>0?e.targets:void 0,i=(await Lr({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:o})).filter(m=>m.status!=="skipped"),a=i.filter(m=>m.status==="created"||m.status==="updated");if(!e.dry_run)for(let m of a){let p=el(r.projectRoot,m.path,m.target);await _(p,m.content);}let c={};for(let m of a){let p=c[m.target]??{filesWritten:0};c[m.target]={filesWritten:p.filesWritten+1};}let l={filesWritten:a.length,byTarget:c,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(l.files=i.map(m=>m.path)),l}catch(r){ui(r);}}s(T2,"generate");async function b2(t,e){try{let r=await ul(t.projectRoot),o=await uR({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope});return {issues:(e.severity?o.diagnostics.filter(i=>i.level===e.severity):o.diagnostics).map(i=>({level:i.level,file:i.file,target:i.target,message:i.message}))}}catch(r){ui(r);}}s(b2,"lint");async function P2(t){try{let e=await ul(t.projectRoot),r=await gR({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){ui(e);}}s(P2,"check");async function x2(t,e){try{let r=await ul(t.projectRoot),o=e.targets&&e.targets.length>0?e.targets:void 0,n=await dR({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:o});return {willCreate:n.summary.new,willModify:n.summary.updated,willDelete:n.summary.deleted}}catch(r){ui(r);}}s(x2,"diff");var ba={generate:T2,lint:b2,check:P2,diff:x2,import:VM,convert:JM};var YM=z$1.object({}).strict(),XM=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:YM,handler:s(()=>mR.list(),"handler"),resourceUri:"agentsmesh://capabilities"},{name:"get_target_capabilities",description:"Get feature support levels for a specific target (e.g. which features are native, mapped, or unsupported)",inputSchema:z$1.object({targetId:z$1.string().describe('Target tool ID (e.g. "claude-code", "cursor")')}),handler:s((t,e)=>mR.get(e),"handler"),resourceUri:"agentsmesh://capabilities/{targetId}"},{name:"generate",description:"Generate target-native config files from canonical .agentsmesh/ content. Propagates rules, commands, agents, skills, MCP, hooks, ignore, and permissions to all configured targets.",inputSchema:z$1.object({targets:z$1.array(z$1.string()).optional().describe("Filter to specific targets (default: all from agentsmesh.yaml)"),features:z$1.array(z$1.string()).optional().describe("Filter to specific features"),verbose:z$1.boolean().optional().describe("Include full file list in response"),dry_run:z$1.boolean().optional().describe("Preview without writing files")}),handler:s((t,e)=>ba.generate(t,e),"handler")},{name:"lint",description:"Lint canonical .agentsmesh/ files for schema errors, missing frontmatter, and other issues",inputSchema:z$1.object({severity:z$1.enum(["error","warning","info"]).optional().describe("Filter results by minimum severity")}),handler:s((t,e)=>ba.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:YM,handler:s(t=>ba.check(t),"handler")},{name:"diff",description:"Preview what generate would create, modify, or delete without writing",inputSchema:z$1.object({targets:z$1.array(z$1.string()).optional().describe("Filter to specific targets"),features:z$1.array(z$1.string()).optional().describe("Filter to specific features")}),handler:s((t,e)=>ba.diff(t,e),"handler")},{name:"import",description:"Import another tool's native config into canonical .agentsmesh/. Note: dry_run is not supported (the engine writes directly).",inputSchema:z$1.object({from:z$1.string().describe('Source target ID to import from (e.g. "cursor", "claude-code")'),features:z$1.array(z$1.string()).optional().describe("Restrict import to specific features"),dry_run:z$1.boolean().optional().describe("NOT SUPPORTED \u2014 will throw VALIDATION_FAILED. Use diff instead.")}),handler:s((t,e)=>ba.import(t,e),"handler")},{name:"convert",description:"Convert config directly from one tool to another (e.g. Cursor \u2192 Claude Code) without creating canonical .agentsmesh/ files",inputSchema:z$1.object({from:z$1.string().describe('Source target ID (e.g. "cursor")'),to:z$1.string().describe('Destination target ID (e.g. "claude-code")'),dry_run:z$1.boolean().optional().describe("Preview conversion without writing files")}),handler:s((t,e)=>ba.convert(t,e),"handler")}];function ZM(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(ZM,"zodToMcpSchema");var dg=[...bM,...MM,...HM,...XM],fR=dg.filter(t=>t.resourceUri!==void 0).map(t=>({uri:t.resourceUri,name:t.name,description:t.description,read:s((e,r)=>t.handler(e,r),"read")}));Ri();async function v2(t){let e=resolve(t);for(;;){try{return await stat(resolve(e,"agentsmesh.yaml")),e}catch{}let r=dirname(e);if(r===e)throw new B("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(v2,"findProjectRoot");async function hR(t){let e=await v2(t.cwd);return {projectRoot:e,loadCanonical:s(()=>Ae(e),"loadCanonical")}}s(hR,"resolveContext");async function z2(){let t=dirname(fileURLToPath(import.meta.url));for(let e of [resolve(t,"../../package.json"),resolve(t,"../package.json"),resolve(t,"../../../package.json")])try{let r=JSON.parse(await readFile(e,"utf8"));if(r.name==="agentsmesh")return r.version}catch{}return "0.0.0"}s(z2,"pkgVersion");function V2(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(V2,"matchTemplate");function J2(t,e){let r=[...t.matchAll(/\{([^}]+)\}/g)].map(i=>i[1]),n=new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").exec(e);return n?Object.fromEntries(r.map((i,a)=>[i,n[a+1]])):{}}s(J2,"extractTemplateParams");async function qM(){let t=new Server({name:"agentsmesh-mcp",version:await z2()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:dg.map(e=>({name:e.name,description:e.description,inputSchema:ZM(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=dg.find(o=>o.name===e.params.name);if(!r)return {isError:true,content:[{type:"text",text:JSON.stringify({code:"NOT_FOUND",message:`unknown tool: ${e.params.name}`})}]};try{let o=r.inputSchema.safeParse(e.params.arguments??{});if(!o.success)throw new B("VALIDATION_FAILED","invalid input",o.error.issues);let n=await hR({cwd:process.cwd()}),i=await r.handler(n,o.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(o){let n=o instanceof B?o.toEnvelope():{code:"IO_ERROR",message:OM(o instanceof Error?o.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(n)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:fR.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=fR.find(a=>a.uri===e.params.uri||V2(a.uri,e.params.uri));if(!r)throw new B("NOT_FOUND",`resource not found: ${e.params.uri}`);let o=await hR({cwd:process.cwd()}),n=J2(r.uri,e.params.uri),i=await r.read(o,n);return {contents:[{uri:e.params.uri,mimeType:"application/json",text:JSON.stringify(i)}]}}),await t.connect(new StdioServerTransport);}s(qM,"startServer");ft();async function t$(t,e){ER(),await qM();}s(t$,"runMcp");var e$={generate:s(async(t,e)=>{let r=await rl(t,void 0,{printMatrix:t.json!==true});Ee("generate",r,t,()=>ol(r));},"generate"),init:s(async(t,e)=>{let r=await Pv(process.cwd(),{yes:t.yes===true,global:t.global===true});Ee("init",r,t,()=>xv(r));},"init"),import:s(async(t,e)=>{let r=await Nv(t);Ee("import",r,t,()=>Wv(r));},"import"),diff:s(async(t,e)=>{let r=await vv(t);Ee("diff",r,t,()=>Hv(r));},"diff"),lint:s(async(t,e)=>{let r=await Uv(t);Ee("lint",r,t,()=>Kv(r));},"lint"),check:s(async(t,e)=>{let r=await Yv(t);Ee("check",r,t,()=>Bv(r));},"check"),merge:s(async(t,e)=>{let r=await Qv(t);Ee("merge",r,t,()=>zv(r));},"merge"),matrix:s(async(t,e)=>{let r=await Fm(t);Ee("matrix",r,t,()=>Gm(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){Da("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await Jv(t),o=s(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",o),process.on("SIGTERM",o);},"watch"),install:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await iM(t,e,process.cwd());Ee("install",r,t,()=>aM(r));},"install"),plugin:s(async(t,e)=>{let r=await pM(t,e,process.cwd());Ee("plugin",r,t,()=>uM(r));},"plugin"),target:s(async(t,e)=>{let r=await SM(t,e,process.cwd());Ee("target",r,t,()=>CM(r));},"target"),convert:s(async(t,e)=>{let r=await sg(t);Ee("convert",r,t,()=>EM(r));},"convert"),mcp:s(async(t,e)=>{await t$();},"mcp")};function Z2(t){let e={},r=[],o="help";for(let n=0;n<t.length;n++){let i=t[n];if(o==="help"&&i==="--version")return {command:"version",flags:{},args:[]};if(o==="help"&&i==="--help")return {command:"help",flags:{},args:[]};if(i.startsWith("--")){let a=i.slice(2),c=t[n+1];c===void 0||c.startsWith("--")?e[a]=true:(e[a]=c,n++);continue}o==="help"?o=i:r.push(i);}return {command:o,flags:e,args:r}}s(Z2,"parseArgs");var Q2=RR(e$);async function q2(t){let{command:e,flags:r,args:o}=t;if(e==="help"){kR();return}if(e==="version"){TR();return}r.json===true&&CR(),await Q2.route(e,r,o);}s(q2,"main");function tZ(){let t=process.argv[1];if(!t)return false;let e=fileURLToPath(import.meta.url);try{let r=resolve(process.cwd(),t);return r===e||realpathSync(r)===realpathSync(e)}catch{return t.endsWith("cli.js")||t.includes("agentsmesh")}}s(tZ,"isMainModule");if(tZ()){let t=Z2(process.argv.slice(2));q2(t).catch(e=>bR(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
|
|
567
|
-
export{
|
|
566
|
+
`),{path:r,written:true})}};var u2=/[;&|`$<>!\\\r\n]/u,d2=/^[A-Za-z_][A-Za-z0-9_]*$/u,g2=/^[A-Za-z][A-Za-z0-9_-]*$/u,f2=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,KM=/[\r\n]/u;function h2(t){return z$1.string().min(1).max(512).refine(e=>!u2.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(h2,"noShellMeta");var oR=z$1.object({type:z$1.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z$1.string().max(1024).optional(),command:h2("command").optional(),args:z$1.array(z$1.string().max(2048)).max(100).optional(),env:z$1.record(z$1.string().regex(d2,"env key must be a valid identifier"),z$1.string().max(8192)).optional(),url:z$1.string().url().max(2048).refine(t=>/^https?:\/\//u.test(t),{message:"url must use http(s) protocol"}).optional(),headers:z$1.record(z$1.string().regex(g2,"header name must be a valid identifier"),z$1.string().max(8192)).optional(),cwd:z$1.string().max(2048).optional(),disabled:z$1.boolean().optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict(),y2=z$1.object({type:z$1.enum(["command","prompt"]).optional(),command:z$1.string().min(1).max(8192).optional(),prompt:z$1.string().min(1).max(8192).optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict().refine(t=>(t.command??"").length>0||(t.prompt??"").length>0,{message:"hook entry must define command or prompt"}),BM=z$1.string().max(256).refine(t=>!KM.test(t),{message:"hook matcher must not contain newlines"}),_2=z$1.object({matcher:BM,type:z$1.enum(["command","prompt"]).optional(),command:z$1.string().min(1).max(8192).optional(),prompt:z$1.string().min(1).max(8192).optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict().refine(t=>(t.command??"").length>0||(t.prompt??"").length>0,{message:"hook entry must define command or prompt"}),I2=z$1.object({matcher:BM,hooks:z$1.array(y2).min(1).max(50)}).strict(),R2=z$1.union([_2,I2]),WM=z$1.record(z$1.string().min(1).max(64),z$1.array(R2).max(100)),S2=z$1.string().min(1).max(256).refine(t=>!KM.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>f2.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),mg=z$1.array(S2).max(500);var Zm=z$1.object({}).strict(),C2=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Zm,handler:s(t=>We.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Zm,handler:s(t=>We.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Zm,handler:s(t=>We.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Zm,handler:s(t=>We.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Zm,handler:s(t=>We.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],E2=[{name:"update_config",description:"Update agentsmesh.yaml. Default: replace listed fields. Set merge=true to union arrays and shallow-merge objects. Only writes agentsmesh.yaml, never agentsmesh.local.yaml.",inputSchema:z$1.object({targets:z$1.array(z$1.string()).optional().describe('Target tool IDs (e.g. ["claude-code", "cursor"])'),features:z$1.array(z$1.string()).optional().describe('Feature names (e.g. ["rules", "commands", "mcp"])'),conversions:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Conversion overrides"),merge:z$1.boolean().optional().describe("If true, union arrays and shallow-merge objects instead of replacing"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updateConfig(t,e),"handler")},{name:"add_mcp_server",description:"Add an MCP server entry to .agentsmesh/mcp.json. Fails if name already exists.",inputSchema:z$1.object({name:z$1.string().describe('Server name (e.g. "github", "filesystem")'),server:oR.describe('Server config (e.g. { type: "stdio", command: "npx", args: [...], env: {...} })'),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.addMcpServer(t,e),"handler")},{name:"update_mcp_server",description:"Update an MCP server entry (replace or merge)",inputSchema:z$1.object({name:z$1.string(),server:oR,merge:z$1.boolean().optional(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>We.updateMcpServer(t,e),"handler")},{name:"remove_mcp_server",description:"Remove an MCP server entry",inputSchema:z$1.object({name:z$1.string(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>We.removeMcpServer(t,e),"handler")},{name:"update_permissions",description:"Update permissions.yaml. mode=replace (default) overwrites listed fields; mode=append unions and dedups.",inputSchema:z$1.object({allow:mg.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:mg.optional().describe("Denied tool patterns"),ask:mg.optional().describe("Tools requiring confirmation"),mode:z$1.enum(["replace","append"]).optional().describe("replace=overwrite, append=union+dedup (default: replace)"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updatePermissions(t,e),"handler")},{name:"update_hooks",description:"Replace hooks.yaml content entirely. Read current hooks with get_hooks, modify, then write back.",inputSchema:z$1.object({hooks:WM.describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updateHooks(t,e),"handler")},{name:"update_ignore",description:"Update .agentsmesh/ignore patterns. mode=replace (default) overwrites; mode=append adds new patterns.",inputSchema:z$1.object({patterns:z$1.array(z$1.string()).describe('Gitignore-syntax patterns (e.g. ["node_modules/", "dist/", ".env*"])'),mode:z$1.enum(["replace","append"]).optional().describe("replace=overwrite, append=add (default: replace)"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>We.updateIgnore(t,e),"handler")}],HM=[...C2,...E2];X_();mo();function O2(){return Object.fromEntries(kt.map(t=>[t,Object.fromEntries(Object.entries(fv).map(([e,r])=>[e,r[t]]))]))}s(O2,"buildTargetIndex");var zM=O2(),nR={async list(){return zM},async get(t){let e=zM[t.targetId];if(e===void 0)throw new B("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};mn();mn();rp();Oe();sn();ms();je();mo();async function sR(t,e){let r=ut(t);if(!r)throw new lo(t,{supported:[...kt,...yd().map(o=>o.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(sR,"importFrom");async function ml(t,e={}){let r=e.scope??"project",{config:o,context:n}=await Tt(t,r);await ce(o,t);let{canonical:i}=await he(o,n.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},n.canonicalDir);return {config:o,canonical:i,projectRoot:n.rootBase,scope:r,configDir:n.configDir,canonicalDir:n.canonicalDir}}s(ml,"loadProjectContext");async function iR(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return Hd(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(iR,"lint");async function aR(t){let e=await Or(t);return {...Bd(e),results:e}}s(aR,"diff");async function cR(t){return zd(t)}s(cR,"check");mn();sn();yi();rp();xt();je();Ct();T();function li(t){if(t instanceof B)throw t;if(t instanceof lo)throw new B("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new B("VALIDATION_FAILED",e):/lock/i.test(e)?new B("LOCK_HELD","generate lock is held"):new B("IO_ERROR","engine failure",{reason:e})}s(li,"wrapEngineError");async function VM(t,e){if(e.dry_run===true)throw new B("VALIDATION_FAILED","dry_run is not supported for import \u2014 the engine writes files directly. Use diff to preview changes instead.");try{let r=await sR(e.from,{root:t.projectRoot,scope:"project"});return {imported:r.length,files:r.map(o=>({fromPath:o.fromPath,toPath:o.toPath,feature:o.feature})),warnings:[],errors:[]}}catch(r){if(r instanceof lo)throw new B("VALIDATION_FAILED",`unknown target "${e.from}"`);let o=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(o))throw new B("VALIDATION_FAILED",o);li(r);}}s(VM,"importFromTarget");async function JM(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},o=await og(r,t.projectRoot);return {filesAffected:o.data.summary.created+o.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let o=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(o))throw new B("VALIDATION_FAILED",o);li(r);}}s(JM,"convert");async function w2(t,e){try{let r=await ml(t.projectRoot),o=e.targets&&e.targets.length>0?e.targets:void 0,i=(await Or({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:o})).filter(m=>m.status!=="skipped"),a=i.filter(m=>m.status==="created"||m.status==="updated");if(!e.dry_run)for(let m of a){let p=qc(r.projectRoot,m.path,m.target);await I(p,m.content);}let c={};for(let m of a){let p=c[m.target]??{filesWritten:0};c[m.target]={filesWritten:p.filesWritten+1};}let l={filesWritten:a.length,byTarget:c,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(l.files=i.map(m=>m.path)),l}catch(r){li(r);}}s(w2,"generate");async function T2(t,e){try{let r=await ml(t.projectRoot),o=await iR({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope});return {issues:(e.severity?o.diagnostics.filter(i=>i.level===e.severity):o.diagnostics).map(i=>({level:i.level,file:i.file,target:i.target,message:i.message}))}}catch(r){li(r);}}s(T2,"lint");async function b2(t){try{let e=await ml(t.projectRoot),r=await cR({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){li(e);}}s(b2,"check");async function P2(t,e){try{let r=await ml(t.projectRoot),o=e.targets&&e.targets.length>0?e.targets:void 0,n=await aR({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:o});return {willCreate:n.summary.new,willModify:n.summary.updated,willDelete:n.summary.deleted}}catch(r){li(r);}}s(P2,"diff");var ka={generate:w2,lint:T2,check:b2,diff:P2,import:VM,convert:JM};var YM=z$1.object({}).strict(),XM=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:YM,handler:s(()=>nR.list(),"handler"),resourceUri:"agentsmesh://capabilities"},{name:"get_target_capabilities",description:"Get feature support levels for a specific target (e.g. which features are native, mapped, or unsupported)",inputSchema:z$1.object({targetId:z$1.string().describe('Target tool ID (e.g. "claude-code", "cursor")')}),handler:s((t,e)=>nR.get(e),"handler"),resourceUri:"agentsmesh://capabilities/{targetId}"},{name:"generate",description:"Generate target-native config files from canonical .agentsmesh/ content. Propagates rules, commands, agents, skills, MCP, hooks, ignore, and permissions to all configured targets.",inputSchema:z$1.object({targets:z$1.array(z$1.string()).optional().describe("Filter to specific targets (default: all from agentsmesh.yaml)"),features:z$1.array(z$1.string()).optional().describe("Filter to specific features"),verbose:z$1.boolean().optional().describe("Include full file list in response"),dry_run:z$1.boolean().optional().describe("Preview without writing files")}),handler:s((t,e)=>ka.generate(t,e),"handler")},{name:"lint",description:"Lint canonical .agentsmesh/ files for schema errors, missing frontmatter, and other issues",inputSchema:z$1.object({severity:z$1.enum(["error","warning","info"]).optional().describe("Filter results by minimum severity")}),handler:s((t,e)=>ka.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:YM,handler:s(t=>ka.check(t),"handler")},{name:"diff",description:"Preview what generate would create, modify, or delete without writing",inputSchema:z$1.object({targets:z$1.array(z$1.string()).optional().describe("Filter to specific targets"),features:z$1.array(z$1.string()).optional().describe("Filter to specific features")}),handler:s((t,e)=>ka.diff(t,e),"handler")},{name:"import",description:"Import another tool's native config into canonical .agentsmesh/. Note: dry_run is not supported (the engine writes directly).",inputSchema:z$1.object({from:z$1.string().describe('Source target ID to import from (e.g. "cursor", "claude-code")'),features:z$1.array(z$1.string()).optional().describe("Restrict import to specific features"),dry_run:z$1.boolean().optional().describe("NOT SUPPORTED \u2014 will throw VALIDATION_FAILED. Use diff instead.")}),handler:s((t,e)=>ka.import(t,e),"handler")},{name:"convert",description:"Convert config directly from one tool to another (e.g. Cursor \u2192 Claude Code) without creating canonical .agentsmesh/ files",inputSchema:z$1.object({from:z$1.string().describe('Source target ID (e.g. "cursor")'),to:z$1.string().describe('Destination target ID (e.g. "claude-code")'),dry_run:z$1.boolean().optional().describe("Preview conversion without writing files")}),handler:s((t,e)=>ka.convert(t,e),"handler")}];function ZM(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(ZM,"zodToMcpSchema");var pg=[...bM,...MM,...HM,...XM],lR=pg.filter(t=>t.resourceUri!==void 0).map(t=>({uri:t.resourceUri,name:t.name,description:t.description,read:s((e,r)=>t.handler(e,r),"read")}));yi();async function F2(t){let e=resolve(t);for(;;){try{return await stat(resolve(e,"agentsmesh.yaml")),e}catch{}let r=dirname(e);if(r===e)throw new B("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(F2,"findProjectRoot");async function mR(t){let e=await F2(t.cwd);return {projectRoot:e,loadCanonical:s(()=>Ae(e),"loadCanonical")}}s(mR,"resolveContext");async function H2(){let t=dirname(fileURLToPath(import.meta.url));for(let e of [resolve(t,"../../package.json"),resolve(t,"../package.json"),resolve(t,"../../../package.json")])try{let r=JSON.parse(await readFile(e,"utf8"));if(r.name==="agentsmesh")return r.version}catch{}return "0.0.0"}s(H2,"pkgVersion");function z2(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(z2,"matchTemplate");function V2(t,e){let r=[...t.matchAll(/\{([^}]+)\}/g)].map(i=>i[1]),n=new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").exec(e);return n?Object.fromEntries(r.map((i,a)=>[i,n[a+1]])):{}}s(V2,"extractTemplateParams");async function qM(){let t=new Server({name:"agentsmesh-mcp",version:await H2()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:pg.map(e=>({name:e.name,description:e.description,inputSchema:ZM(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=pg.find(o=>o.name===e.params.name);if(!r)return {isError:true,content:[{type:"text",text:JSON.stringify({code:"NOT_FOUND",message:`unknown tool: ${e.params.name}`})}]};try{let o=r.inputSchema.safeParse(e.params.arguments??{});if(!o.success)throw new B("VALIDATION_FAILED","invalid input",o.error.issues);let n=await mR({cwd:process.cwd()}),i=await r.handler(n,o.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(o){let n=o instanceof B?o.toEnvelope():{code:"IO_ERROR",message:OM(o instanceof Error?o.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(n)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:lR.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=lR.find(a=>a.uri===e.params.uri||z2(a.uri,e.params.uri));if(!r)throw new B("NOT_FOUND",`resource not found: ${e.params.uri}`);let o=await mR({cwd:process.cwd()}),n=V2(r.uri,e.params.uri),i=await r.read(o,n);return {contents:[{uri:e.params.uri,mimeType:"application/json",text:JSON.stringify(i)}]}}),await t.connect(new StdioServerTransport);}s(qM,"startServer");ft();async function t$(t,e){yR(),await qM();}s(t$,"runMcp");var e$={generate:s(async(t,e)=>{let r=await tl(t,void 0,{printMatrix:t.json!==true});Ee("generate",r,t,()=>el(r));},"generate"),init:s(async(t,e)=>{let r=await Pv(process.cwd(),{yes:t.yes===true,global:t.global===true});Ee("init",r,t,()=>xv(r));},"init"),import:s(async(t,e)=>{let r=await Nv(t);Ee("import",r,t,()=>Wv(r));},"import"),diff:s(async(t,e)=>{let r=await vv(t);Ee("diff",r,t,()=>Hv(r));},"diff"),lint:s(async(t,e)=>{let r=await Uv(t);Ee("lint",r,t,()=>Kv(r));},"lint"),check:s(async(t,e)=>{let r=await Yv(t);Ee("check",r,t,()=>Bv(r));},"check"),merge:s(async(t,e)=>{let r=await Qv(t);Ee("merge",r,t,()=>zv(r));},"merge"),matrix:s(async(t,e)=>{let r=await Fm(t);Ee("matrix",r,t,()=>Gm(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){ba("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await Jv(t),o=s(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",o),process.on("SIGTERM",o);},"watch"),install:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await iM(t,e,process.cwd());Ee("install",r,t,()=>aM(r));},"install"),plugin:s(async(t,e)=>{let r=await pM(t,e,process.cwd());Ee("plugin",r,t,()=>uM(r));},"plugin"),target:s(async(t,e)=>{let r=await SM(t,e,process.cwd());Ee("target",r,t,()=>CM(r));},"target"),convert:s(async(t,e)=>{let r=await og(t);Ee("convert",r,t,()=>EM(r));},"convert"),mcp:s(async(t,e)=>{await t$();},"mcp")};function X2(t){let e={},r=[],o="help";for(let n=0;n<t.length;n++){let i=t[n];if(o==="help"&&i==="--version")return {command:"version",flags:{},args:[]};if(o==="help"&&i==="--help")return {command:"help",flags:{},args:[]};if(i.startsWith("--")){let a=i.slice(2),c=t[n+1];c===void 0||c.startsWith("--")?e[a]=true:(e[a]=c,n++);continue}o==="help"?o=i:r.push(i);}return {command:o,flags:e,args:r}}s(X2,"parseArgs");var Z2=gR(e$);async function Q2(t){let{command:e,flags:r,args:o}=t;if(e==="help"){SR();return}if(e==="version"){ER();return}r.json===true&&hR(),await Z2.route(e,r,o);}s(Q2,"main");function q2(){let t=process.argv[1];if(!t)return false;let e=fileURLToPath(import.meta.url);try{let r=resolve(process.cwd(),t);return r===e||realpathSync(r)===realpathSync(e)}catch{return t.endsWith("cli.js")||t.includes("agentsmesh")}}s(q2,"isMainModule");if(q2()){let t=X2(process.argv.slice(2));Q2(t).catch(e=>OR(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
|
|
567
|
+
export{X2 as parseArgs};
|