agentsmesh 0.19.1 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,201 +1,203 @@
1
1
  #!/usr/bin/env node
2
- import {resolve,join,sep,dirname,extname,basename,relative,win32,posix,normalize,isAbsolute}from'path';import {rm,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,chmod,access,realpath,mkdtemp,cp as cp$1,readlink,symlink,copyFile}from'fs/promises';import {realpathSync,rmSync,statSync,existsSync,mkdtempSync,readdirSync,symlinkSync,mkdirSync,constants,readFileSync}from'fs';import {z}from'zod';import {parse,stringify}from'yaml';import {homedir,tmpdir,hostname}from'os';import {execFile}from'child_process';import {fileURLToPath,URL,pathToFileURL}from'url';import {promisify}from'util';import*as VS 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 IZ from'chokidar';import*as QG 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 _S=Object.defineProperty;var s=(t,e)=>_S(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var og=(t,e)=>{for(var r in e)_S(t,r,{get:e[r],enumerable:true});};function SS(){Si=true;}function CS(){IS=true;}function Ka(t){IS?process.stderr.write(t):process.stdout.write(t);}function h0(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function Fc(t,e){return h0()?e:`${t}${e}${Wa.reset}`}function y0(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Wa,Si,IS,y,ot=d(()=>{Wa={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},Si=false,IS=false;s(SS,"muteLogger");s(CS,"redirectLoggerToStderr");s(Ka,"out");s(h0,"noColor");s(Fc,"c");s(y0,"pad");y={info(t){Si||Ka(Fc(Wa.cyan,t)+`
3
- `);},warn(t){Si||process.stderr.write(Fc(Wa.yellow,"\u26A0 ")+t+`
4
- `);},error(t){Si||process.stderr.write(Fc(Wa.red,"\u2717 ")+t+`
5
- `);},success(t){Si||Ka(Fc(Wa.green,"\u2713 ")+t+`
6
- `);},debug(t){Si||process.env.AGENTSMESH_DEBUG==="1"&&Ka(Fc(Wa.cyan,"[debug] ")+t+`
7
- `);},table(t){if(Si||t.length===0)return;let e=t[0].length,r=[];for(let o=0;o<e;o++){let i=0;for(let a=0;a<t.length;a++){let l=[...t[a][o]].length;l>i&&(i=l);}r[o]=i;}let n="+"+r.map(o=>"-".repeat(o+2)).join("+")+"+";Ka(n+`
8
- `);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>y0(l,r[c])).join(" | ")+" |";Ka(a+`
9
- `);}Ka(n+`
10
- `);}};});var yo,Nr,za,_n,Va,be,_o=d(()=>{yo=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},Nr=class extends yo{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;}},za=class extends yo{static{s(this,"ConfigValidationError");}issues;constructor(e,r,n){super("AM_CONFIG_INVALID",`Invalid config at ${e}: ${r.join("; ")}. Fix the YAML and try again.`,n),this.name="ConfigValidationError",this.issues=r;}},_n=class extends yo{static{s(this,"TargetNotFoundError");}target;constructor(e,r){let n=r?.supported?` Supported: ${r.supported.join(", ")}.`:"";super("AM_TARGET_NOT_FOUND",`Unknown target "${e}".${n}`,r),this.name="TargetNotFoundError",this.target=e;}},Va=class extends yo{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,n){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.`,n),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},be=class extends yo{static{s(this,"FileSystemError");}path;errnoCode;constructor(e,r,n){super("AM_FILESYSTEM",r,n),this.name="FileSystemError",this.path=e,this.errnoCode=n?.errnoCode;}};});function Ap(t){let e=extname(t).toLowerCase();if(e.length>0)return E0.has(e);let r=basename(t).toLowerCase();return L0.has(r)}function wp(t){return t.replace(/\r\n?/g,`
11
- `)}function lg(t){return O0.has(extname(t).toLowerCase())?493:void 0}var Ja,E0,L0,O0,bp=d(()=>{Ja="\uFEFF",E0=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),L0=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(Ap,"shouldNormalizeLineEndings");s(wp,"normalizeLineEndings");O0=new Set([".sh",".bash",".zsh"]);s(lg,"executableModeFor");});function TS(t){if(t.length>N0)return true;let e=new Map;for(let r of t){let n=(e.get(r)??0)+1;if(n>=F0)return true;e.set(r,n);}return false}async function v(t,e,r){let n=r??[basename(t)],o;try{o=await realpath(t);}catch(a){let l=a;if(l.code==="ENOENT"||l.code==="ENOTDIR"||l.code==="ELOOP")return [];throw new be(t,`Failed to read directory ${t}: ${l.message}. Check permissions.`,{cause:a,errnoCode:l.code})}let i=e??new Set;if(i.has(o))return [];i.add(o);try{let a=await readdir(t,{withFileTypes:!0}),l=[];for(let c of a){let m=join(t,c.name);if(c.isDirectory()||c.isSymbolicLink()&&await stat(m).then(u=>u.isDirectory(),()=>!1)){let u=[...n,c.name];if(TS(u))continue;l.push(...await v(m,i,u));}else l.push(m);}return l}catch(a){let l=a;if(l.code==="ENOENT"||l.code==="ENOTDIR"||l.code==="EACCES")return [];throw new be(t,`Failed to read directory ${t}: ${l.message}. Check permissions.`,{cause:a,errnoCode:l.code})}}async function Ya(t,e){let r=e??[basename(t)];try{let n=await readdir(t,{withFileTypes:!0}),o=[];for(let i of n){if(i.isSymbolicLink())continue;let a=join(t,i.name);if(i.isDirectory()){let l=[...r,i.name];if(TS(l))continue;o.push(...await Ya(a,l));}else i.isFile()&&o.push(a);}return o}catch(n){let o=n;if(o.code==="ENOENT"||o.code==="ENOTDIR"||o.code==="EACCES")return [];throw new be(t,`Failed to read directory ${t}: ${o.message}. Check permissions.`,{cause:n,errnoCode:o.code})}}async function cg(t,e){let r=resolve(t);try{if(!(await lstat(e)).isSymbolicLink()||resolve(dirname(e),await readlink(e))===r)return;await unlink(e);}catch(n){if(n.code!=="ENOENT")throw n}await symlink(r,e,"dir");}var N0,F0,xS=d(()=>{_o();N0=32,F0=3;s(TS,"shouldSkipRecursiveBranch");s(v,"readDirRecursive");s(Ya,"readDirRecursiveNoSymlinks");s(cg,"ensureCacheSymlink");});async function _(t){try{let e=await readFile(t,"utf-8");return e.startsWith(Ja)?e.slice(Ja.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new be(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 n=dirname(t);await mkdir(n,{recursive:true});try{let l=await lstat(t);if(l.isDirectory())throw new be(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});l.isSymbolicLink()&&await unlink(t).catch(c=>{if(c.code!=="ENOENT")throw c});}catch(l){if(l instanceof be||l.code!=="ENOENT")throw l}let o=`${t}.tmp`,i=Ap(t)?wp(e):e,a=r?.mode??lg(t);try{try{(await lstat(o)).isSymbolicLink()&&await unlink(o);}catch(c){if(c.code!=="ENOENT")throw c}let l={encoding:"utf-8",flag:"w"};a!==void 0&&(l.mode=a),await writeFile(o,i,l),await rename(o,t),a!==void 0&&await chmod(t,a);}catch(l){await rm(o,{force:true}).catch(()=>{});let c=l;throw new be(t,`Failed to write ${t}: ${c.message}. Check permissions and disk space.`,{cause:l,errnoCode:c.code})}}async function $(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function O(t){await mkdir(t,{recursive:true});}var w=d(()=>{_o();bp();xS();bp();s(_,"readFileSafe");s(I,"writeFileAtomic");s($,"exists");s(O,"mkdirp");});function Pe(t){return mg.includes(t)}var mg,vS=d(()=>{mg=["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(Pe,"isBuiltinTargetId");});var Ft,pg,Rn=d(()=>{vS();Ft=mg,pg="codex-cli";});var MS,Qe,Xa,W0,Mc,H0,z0,vc,V0,J0,ki,Ro=d(()=>{Rn();MS=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],Qe=z.enum(Ft),Xa=z.enum(MS),W0=z.enum(["rules","commands","agents","skills"]),Mc=z.object({skills:z.array(z.string()).optional(),commands:z.array(z.string()).optional(),rules:z.array(z.string()).optional(),agents:z.array(z.string()).optional()}).strict(),H0=z.object({name:z.string(),source:z.string(),version:z.string().optional(),target:Qe.optional(),as:W0.optional(),features:z.array(Xa),path:z.string().optional(),pick:Mc.optional()}),z0=z.object({strategy:z.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z.array(z.string()).default([])}),vc=z.union([z.boolean(),z.object({project:z.boolean().optional(),global:z.boolean().optional()}).strict()]),V0=z.object({commands_to_skills:z.object({"codex-cli":vc.optional()}).passthrough().optional(),agents_to_skills:z.object({"gemini-cli":vc.optional(),cline:vc.optional(),"codex-cli":vc.optional(),windsurf:vc.optional()}).passthrough().optional()}).strict().optional(),J0=z.object({id:z.string().regex(/^[a-z][a-z0-9-]*$/),source:z.string(),version:z.string().optional(),strict:z.boolean().optional()}).strict(),ki=z.object({version:z.literal(1),targets:z.array(Qe).default([...Ft]),features:z.array(Xa).default([...MS]),extends:z.array(H0).default([]),overrides:z.record(z.string(),z.record(z.string(),z.unknown())).default({}),collaboration:z0.default({strategy:"merge",lock_features:[]}),conversions:V0,plugins:z.array(J0).default([]),pluginTargets:z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function Z0(t){let e=resolve(t);for(;;){let r=join(e,dg);if(await $(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}async function Q0(t){let e=await _(t);if(e===null)throw new Nr(t);let r=parse(e),n=ki.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new za(t,o,{cause:n.error})}return n.data}function ug(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null||q0.has(n))continue;let i=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[n]=ug(i,o):r[n]=o;}return r}function tB(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=ug(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=ug(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,dg),r=await Q0(e),n=join(t,X0),o=await _(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=tB(r,i),l=ki.safeParse(a);if(l.success)r=l.data;else {let c=l.error.issues.map(m=>m.message).join("; ");y.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${c}. Using project config instead.`);}}}return {config:r,configDir:t}}async function xp(t){let e=await Z0(t);if(e===null)throw new Nr(join(t,dg));return Tp(dirname(e))}var dg,X0,q0,Dp=d(()=>{w();ot();_o();Ro();dg="agentsmesh.yaml",X0="agentsmesh.local.yaml";s(Z0,"findConfigPath");s(Q0,"loadConfig");q0=new Set(["__proto__","constructor","prototype"]);s(ug,"deepMergeObjects");s(tB,"mergeLocalConfig");s(Tp,"loadConfigFromExactDir");s(xp,"loadConfigFromDir");});function Ei(t,e="project"){if(e==="project")return {scope:e,rootBase:t,configDir:t,canonicalDir:join(t,".agentsmesh")};let r=homedir(),n=join(r,".agentsmesh");return {scope:e,rootBase:r,configDir:n,canonicalDir:n}}async function yt(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await xp(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Ei(t,e);try{let{config:n}=await Tp(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof Nr?new Nr(n.path,{cause:n,message:`agentsmesh.yaml not found at ${n.path} (global scope). Run 'agentsmesh init --global' to create it under ~/.agentsmesh, or drop the --global flag to operate on the current project.`}):n}}var Yt=d(()=>{Dp();_o();s(Ei,"resolveScopeContext");s(yt,"loadScopedConfig");});function BS(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function Np(t,e,r,n,o){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,l=t.ref??"HEAD",c=o(i,a,l),m=join(n,c),p=join(m,jS),u=`${m}.tmp`,f=join(u,jS);if(!r.refresh&&await US(p))return yg(p);try{return await rm(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await cB(lB(t),f),t.ref&&await mB(f,t.ref),await rm(m,{recursive:!0,force:!0}),await rename(u,m),yg(p)}catch(g){if(await rm(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await US(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),yg(p);throw g}}async function yg(t){return {resolvedPath:t,version:await pB(t)}}async function US(t){return $(t)}function lB(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 cB(t,e){BS(t,"clone-url"),await _g(["clone",t,e]);}async function mB(t,e){BS(e,"ref"),await _g(["checkout",e],t);}async function pB(t){return _g(["rev-parse","HEAD"],t)}async function _g(t,e){let{stdout:r}=await aB("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var aB,jS,Rg=d(()=>{w();aB=promisify(execFile),jS="repo";s(BS,"ensureNotFlag");s(Np,"fetchGitRemoteExtend");s(yg,"readCachedRepo");s(US,"hasCachedRepo");s(lB,"resolveCloneUrl");s(cB,"cloneRepo");s(mB,"checkoutRef");s(pB,"getHeadSha");s(_g,"runGit");});function gB(){let t=process.env.AGENTSMESH_MAX_TARBALL_MB;if(t===void 0||t==="")return Gc*1024*1024;let e=Number(t);return !Number.isFinite(e)||!Number.isInteger(e)?(console.warn(`[agentsmesh] AGENTSMESH_MAX_TARBALL_MB="${t}" is not an integer; using default ${Gc} MiB.`),Gc*1024*1024):e<WS||e>HS?(console.warn(`[agentsmesh] AGENTSMESH_MAX_TARBALL_MB=${e} is outside [${WS}, ${HS}]; using default ${Gc} MiB.`),Gc*1024*1024):e*1024*1024}async function yB(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 n=t.body;if(!n){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 o=n.getReader(),i=[],a=0;for(;;){let{done:m,value:p}=await o.read();if(m)break;if(p){if(a+=p.byteLength,a>e)throw await o.cancel().catch(()=>{}),new Error(`remote response exceeded cap of ${e} bytes during streaming`);i.push(p);}}let l=new Uint8Array(a),c=0;for(let m of i)l.set(m,c),c+=m.byteLength;return l}async function JS(t,e,r){let n=`https://api.github.com/repos/${t}/${e}/releases/latest`,o={Accept:"application/vnd.github+json"};r&&(o.Authorization=`Bearer ${r}`);let i=await globalThis.fetch(n,{headers:o});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 YS(t,e,r,n,o,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,l=r.refresh===true,c=t.tag;if(c==="latest")try{c=await JS(t.org,t.repo,a);}catch(S){if(!i)throw S;return RB(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,c),p=join(n,m);if(!l&&await $(p)){let S=await Ig(p);if(S)return {resolvedPath:join(p,S),version:c}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,f={};a&&(f.Authorization=`Bearer ${a}`);let g;try{let S=await globalThis.fetch(u,{headers:f,redirect:"follow"});if(!S.ok)throw new Error(`HTTP ${S.status}: ${S.statusText}`);g=await yB(S,hB);}catch(S){if(r.allowOfflineFallback!==false&&await $(p)){let P=await Ig(p);if(P)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${S instanceof Error?S.message:String(S)}`),{resolvedPath:join(p,P),version:c}}throw S}await rm(p,{recursive:true,force:true}),await mkdir(p,{recursive:true});let h=join(p,"archive.tar.gz");await writeFile(h,g);try{await VS.extract({file:h,cwd:p,strict:!0,filter:s((S,k)=>!(_B(S)||k&&"type"in k&&(k.type==="Link"||k.type==="SymbolicLink")),"filter")});}finally{await rm(h,{force:true}).catch(()=>{});}let R=await Ig(p);if(!R)throw new Error(`Extend "${e}": archive has no top-level directory. Expected a single top-level directory inside the archive.`);return {resolvedPath:join(p,R),version:c}}async function Ig(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}function zS(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function _B(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function RB(t,e,r,n,o,i){let a=i?[zS(t.org,t.repo,i)]:[zS(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],l;for(let c of a){let m={url:c};try{return await Np(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}var Gc,WS,HS,hB,XS=d(()=>{w();Rg();Gc=500,WS=1,HS=4096;s(gB,"resolveMaxTarballBytes");hB=gB();s(yB,"readBoundedResponse");s(JS,"resolveLatestTag");s(YS,"fetchGithubRemoteExtend");s(Ig,"findExtractTopDir");s(zS,"buildGithubCloneUrl");s(_B,"isZipSlipPath");s(RB,"fetchGithubDefaultBranch");});function ZS(t,e,r){if(!t.startsWith(e))return null;let n=t.slice(e.length).trim();if(!n)return null;let o=n.lastIndexOf("@");if(o<0)return [n,r];let i=n.slice(0,o).trim(),a=n.slice(o+1).trim();return !i||!a?null:[i,a]}function QS(t){let e=ZS(t,"github:","latest");if(!e)return null;let[r,n]=e,o=r.indexOf("/");if(o<0)return null;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !i||!a||!n?null:{org:i,repo:a,tag:n}}function qS(t){let e=ZS(t,"gitlab:");if(!e)return null;let[r,n]=e,o=r.lastIndexOf("/");if(o<0)return null;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !i||!a?null:{namespace:i,project:a,ref:n,cloneUrl:`https://gitlab.com/${i}/${a}.git`}}function tC(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),n=(r<0?e:e.slice(0,r)).trim(),o=r<0?void 0:e.slice(r+1).trim();if(!n||r>=0&&!o)return null;let i;try{i=new URL(n);}catch{return null}return (process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="1"||process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="true"?["https:","http:","ssh:","file:"]:["https:","ssh:","file:"]).includes(i.protocol)?{url:n,ref:o}:null}function Li(t){let e=QS(t);if(e)return {kind:"github",...e};let r=qS(t);if(r)return {kind:"gitlab",...r};let n=tC(t);return n?{kind:"git",...n}:null}function Sg(t){return Li(t)!==null}var jc=d(()=>{s(ZS,"splitSourceRef");s(QS,"parseGithubSource");s(qS,"parseGitlabSource");s(tC,"parseGitSource");s(Li,"parseRemoteSource");s(Sg,"isSupportedRemoteSource");});function kB(t){let e=Li(t);return e?e.kind==="github"?Za("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?Za("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):Za("git",e.url,e.ref??"HEAD"):null}async function nC(t,e){let r=kB(t);if(!r)return;let n=e??Te(),o=join(n,r);await rm(o,{recursive:true,force:true});}async function oC(t,e){let r=t??Te(),n=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,o;try{o=await readdir(r);}catch{return}let i=Date.now();await Promise.all(o.map(async a=>{let l=join(r,a);try{let{mtimeMs:c}=await stat(l);i-c>n&&await rm(l,{recursive:!0,force:!0});}catch{}}));}var Cg=d(()=>{Uc();jc();s(kB,"cacheKeyFromSource");s(nC,"cleanInstallCache");s(oC,"sweepStaleCache");});function Za(t,e,r){let n=s(i=>i.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),o;if(t==="github"){let[i,a]=e.split("/",2);i&&a?o=`${n(i)}--${n(a)}--${n(r)}`:o=`${n(t)}__${n(e)}__${n(r)}`;}else o=`${n(t)}__${n(e)}__${n(r)}`;if(o.length>aC){let i=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,aC-18)}--${i}`;}return o}function Te(){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 Qa(t,e,r={}){let n=Li(t);if(!n)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 o=r.cacheDir??Te();return oC(o).catch(()=>{}),n.kind==="github"?YS(n,e,r,o,Za,!t.includes("@")):Np(n,e,r,o,Za)}var aC,Uc=d(()=>{Rg();XS();jc();Cg();aC=80;s(Za,"buildCacheKey");s(Te,"getCacheDir");s(Qa,"fetchRemoteExtend");});function wB(t){return t.startsWith("http://")||t.startsWith("https://")}async function qa(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Sg(o.source))){let o=Te();await rm(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(wB(o.source))throw new Error(`Remote extends (http/https) not supported: "${o.source}" for extend "${o.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(Sg(o.source)){let a=await Qa(o.source,o.name,{cacheDir:Te(),refresh:r.refreshCache===true});n.push({name:o.name,resolvedPath:a.resolvedPath,features:[...o.features],target:o.target,as:o.as,version:a.version,path:o.path,pick:o.pick});continue}let i=resolve(e,o.source);if(!await $(i))throw new Error(`Extend "${o.name}": path does not exist: ${i}. Check extends.source in agentsmesh.yaml.`);n.push({name:o.name,resolvedPath:i,features:[...o.features],target:o.target,as:o.as,path:o.path,pick:o.pick});}return n}var Fp=d(()=>{w();Uc();jc();s(wB,"isOtherRemoteSource");s(qa,"resolveExtendPaths");});function b(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let n=t.slice(3,r).trim(),o=t.slice(r+3).trim();return {frontmatter:n===""?{}:parse(n)??{},body:o}}function TB(t){if(t.indexOf("---")!==0)return t.trim();let e=t.indexOf("---",3);return e===-1?t.trim():t.slice(e+3).trim()}function Fr(t,e){try{return {ok:!0,value:b(t)}}catch(r){let n=r instanceof Error?r.message:String(r);return {ok:false,error:new Error(`Failed to parse frontmatter in ${e}: ${n}`,{cause:r}),bodyFallback:TB(t)}}}function Io(t,e,r){let n=Fr(t,e);if(n.ok)return n.value;if(r)return r(n.error,e),null;throw n.error}function T(t,e){return Object.keys(t).length===0?e:`---
2
+ import {resolve,join,sep,dirname,extname,basename,relative,win32,posix,normalize,isAbsolute}from'path';import {rm as rm$1,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,chmod,access,realpath,mkdtemp,cp as cp$1,readlink,symlink,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,URL,pathToFileURL}from'url';import {promisify}from'util';import*as tC 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 vZ from'chokidar';import*as oj 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 LS=Object.defineProperty;var s=(t,e)=>LS(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var _g=(t,e)=>{for(var r in e)LS(t,r,{get:e[r],enumerable:true});};function AS(){ki=true;}function bS(){wS=true;}function Wa(t){wS?process.stderr.write(t):process.stdout.write(t);}function P0(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function Gc(t,e){return P0()?e:`${t}${e}${Ha.reset}`}function T0(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Ha,ki,wS,y,st=d(()=>{Ha={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},ki=false,wS=false;s(AS,"muteLogger");s(bS,"redirectLoggerToStderr");s(Wa,"out");s(P0,"noColor");s(Gc,"c");s(T0,"pad");y={info(t){ki||Wa(Gc(Ha.cyan,t)+`
3
+ `);},warn(t){ki||process.stderr.write(Gc(Ha.yellow,"\u26A0 ")+t+`
4
+ `);},error(t){ki||process.stderr.write(Gc(Ha.red,"\u2717 ")+t+`
5
+ `);},success(t){ki||Wa(Gc(Ha.green,"\u2713 ")+t+`
6
+ `);},debug(t){ki||process.env.AGENTSMESH_DEBUG==="1"&&Wa(Gc(Ha.cyan,"[debug] ")+t+`
7
+ `);},table(t){if(ki||t.length===0)return;let e=t[0].length,r=[];for(let o=0;o<e;o++){let i=0;for(let a=0;a<t.length;a++){let l=[...t[a][o]].length;l>i&&(i=l);}r[o]=i;}let n="+"+r.map(o=>"-".repeat(o+2)).join("+")+"+";Wa(n+`
8
+ `);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>T0(l,r[c])).join(" | ")+" |";Wa(a+`
9
+ `);}Wa(n+`
10
+ `);}};});var Ro,$r,Va,In,Ja,Ne,Io=d(()=>{Ro=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},$r=class extends Ro{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;}},Va=class extends Ro{static{s(this,"ConfigValidationError");}issues;constructor(e,r,n){super("AM_CONFIG_INVALID",`Invalid config at ${e}: ${r.join("; ")}. Fix the YAML and try again.`,n),this.name="ConfigValidationError",this.issues=r;}},In=class extends Ro{static{s(this,"TargetNotFoundError");}target;constructor(e,r){let n=r?.supported?` Supported: ${r.supported.join(", ")}.`:"";super("AM_TARGET_NOT_FOUND",`Unknown target "${e}".${n}`,r),this.name="TargetNotFoundError",this.target=e;}},Ja=class extends Ro{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,n){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.`,n),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},Ne=class extends Ro{static{s(this,"FileSystemError");}path;errnoCode;constructor(e,r,n){super("AM_FILESYSTEM",r,n),this.name="FileSystemError",this.path=e,this.errnoCode=n?.errnoCode;}};});function jp(t){let e=extname(t).toLowerCase();if(e.length>0)return $0.has(e);let r=basename(t).toLowerCase();return G0.has(r)}function Up(t){return t.replace(/\r\n?/g,`
11
+ `)}function Cg(t){return j0.has(extname(t).toLowerCase())?493:void 0}var Ya,$0,G0,j0,Bp=d(()=>{Ya="\uFEFF",$0=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),G0=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(jp,"shouldNormalizeLineEndings");s(Up,"normalizeLineEndings");j0=new Set([".sh",".bash",".zsh"]);s(Cg,"executableModeFor");});function $S(t){if(t.length>J0)return true;let e=new Map;for(let r of t){let n=(e.get(r)??0)+1;if(n>=Y0)return true;e.set(r,n);}return false}async function $(t,e,r){let n=r??[basename(t)],o;try{o=await realpath(t);}catch(a){let l=a;if(l.code==="ENOENT"||l.code==="ENOTDIR"||l.code==="ELOOP")return [];throw new Ne(t,`Failed to read directory ${t}: ${l.message}. Check permissions.`,{cause:a,errnoCode:l.code})}let i=e??new Set;if(i.has(o))return [];i.add(o);try{let a=await readdir(t,{withFileTypes:!0}),l=[];for(let c of a){let m=join(t,c.name);if(c.isDirectory()||c.isSymbolicLink()&&await stat(m).then(u=>u.isDirectory(),()=>!1)){let u=[...n,c.name];if($S(u))continue;l.push(...await $(m,i,u));}else l.push(m);}return l}catch(a){let l=a;if(l.code==="ENOENT"||l.code==="ENOTDIR"||l.code==="EACCES")return [];throw new Ne(t,`Failed to read directory ${t}: ${l.message}. Check permissions.`,{cause:a,errnoCode:l.code})}}async function Xa(t,e){let r=e??[basename(t)];try{let n=await readdir(t,{withFileTypes:!0}),o=[];for(let i of n){if(i.isSymbolicLink())continue;let a=join(t,i.name);if(i.isDirectory()){let l=[...r,i.name];if($S(l))continue;o.push(...await Xa(a,l));}else i.isFile()&&o.push(a);}return o}catch(n){let o=n;if(o.code==="ENOENT"||o.code==="ENOTDIR"||o.code==="EACCES")return [];throw new Ne(t,`Failed to read directory ${t}: ${o.message}. Check permissions.`,{cause:n,errnoCode:o.code})}}async function kg(t,e){let r=resolve(t);try{if(!(await lstat(e)).isSymbolicLink()||resolve(dirname(e),await readlink(e))===r)return;await unlink(e);}catch(n){if(n.code!=="ENOENT")throw n}await symlink(r,e,"dir");}var J0,Y0,GS=d(()=>{Io();J0=32,Y0=3;s($S,"shouldSkipRecursiveBranch");s($,"readDirRecursive");s(Xa,"readDirRecursiveNoSymlinks");s(kg,"ensureCacheSymlink");});async function _(t){try{let e=await readFile(t,"utf-8");return e.startsWith(Ya)?e.slice(Ya.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new Ne(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function S(t,e,r){let n=dirname(t);await mkdir(n,{recursive:true});try{let l=await lstat(t);if(l.isDirectory())throw new Ne(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});l.isSymbolicLink()&&await unlink(t).catch(c=>{if(c.code!=="ENOENT")throw c});}catch(l){if(l instanceof Ne||l.code!=="ENOENT")throw l}let o=`${t}.tmp`,i=jp(t)?Up(e):e,a=r?.mode??Cg(t);try{try{(await lstat(o)).isSymbolicLink()&&await unlink(o);}catch(c){if(c.code!=="ENOENT")throw c}let l={encoding:"utf-8",flag:"w"};a!==void 0&&(l.mode=a),await writeFile(o,i,l),await rename(o,t),a!==void 0&&await chmod(t,a);}catch(l){await rm$1(o,{force:true}).catch(()=>{});let c=l;throw new Ne(t,`Failed to write ${t}: ${c.message}. Check permissions and disk space.`,{cause:l,errnoCode:c.code})}}async function j(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function O(t){await mkdir(t,{recursive:true});}var A=d(()=>{Io();Bp();GS();Bp();s(_,"readFileSafe");s(S,"writeFileAtomic");s(j,"exists");s(O,"mkdirp");});function Fe(t){return Eg.includes(t)}var Eg,KS=d(()=>{Eg=["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(Fe,"isBuiltinTargetId");});var vt,Lg,Sn=d(()=>{KS();vt=Eg,Lg="codex-cli";});var WS,nr,Za,oB,Uc,sB,iB,jc,aB,lB,Li,So=d(()=>{Sn();WS=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],nr=z$1.enum(vt),Za=z$1.enum(WS),oB=z$1.enum(["rules","commands","agents","skills"]),Uc=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(),sB=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:nr.optional(),as:oB.optional(),features:z$1.array(Za),path:z$1.string().optional(),pick:Uc.optional()}),iB=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),jc=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),aB=z$1.object({commands_to_skills:z$1.object({"codex-cli":jc.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":jc.optional(),cline:jc.optional(),"codex-cli":jc.optional(),windsurf:jc.optional()}).passthrough().optional()}).strict().optional(),lB=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(),Li=z$1.object({version:z$1.literal(1),targets:z$1.array(nr).default([...vt]),features:z$1.array(Za).default([...WS]),extends:z$1.array(sB).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:iB.default({strategy:"merge",lock_features:[]}),conversions:aB,plugins:z$1.array(lB).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function pB(t){let e=resolve(t);for(;;){let r=join(e,wg);if(await j(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}async function uB(t){let e=await _(t);if(e===null)throw new $r(t);let r=parse(e),n=Li.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new Va(t,o,{cause:n.error})}return n.data}function Og(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null||dB.has(n))continue;let i=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[n]=Og(i,o):r[n]=o;}return r}function fB(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=Og(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Og(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function Wp(t){let e=join(t,wg),r=await uB(e),n=join(t,mB),o=await _(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=fB(r,i),l=Li.safeParse(a);if(l.success)r=l.data;else {let c=l.error.issues.map(m=>m.message).join("; ");y.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${c}. Using project config instead.`);}}}return {config:r,configDir:t}}async function Hp(t){let e=await pB(t);if(e===null)throw new $r(join(t,wg));return Wp(dirname(e))}var wg,mB,dB,zp=d(()=>{A();st();Io();So();wg="agentsmesh.yaml",mB="agentsmesh.local.yaml";s(pB,"findConfigPath");s(uB,"loadConfig");dB=new Set(["__proto__","constructor","prototype"]);s(Og,"deepMergeObjects");s(fB,"mergeLocalConfig");s(Wp,"loadConfigFromExactDir");s(Hp,"loadConfigFromDir");});function Oi(t,e="project"){if(e==="project")return {scope:e,rootBase:t,configDir:t,canonicalDir:join(t,".agentsmesh")};let r=homedir(),n=join(r,".agentsmesh");return {scope:e,rootBase:r,configDir:n,canonicalDir:n}}async function yt(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await Hp(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Oi(t,e);try{let{config:n}=await Wp(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof $r?new $r(n.path,{cause:n,message:`agentsmesh.yaml not found at ${n.path} (global scope). Run 'agentsmesh init --global' to create it under ~/.agentsmesh, or drop the --global flag to operate on the current project.`}):n}}var Zt=d(()=>{zp();Io();s(Oi,"resolveScopeContext");s(yt,"loadScopedConfig");});function YS(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function Vp(t,e,r,n,o){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,l=t.ref??"HEAD",c=o(i,a,l),m=join(n,c),p=join(m,VS),u=`${m}.tmp`,f=join(u,VS);if(!r.refresh&&await JS(p))return Tg(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await kB(CB(t),f),t.ref&&await EB(f,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),Tg(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await JS(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),Tg(p);throw g}}async function Tg(t){return {resolvedPath:t,version:await LB(t)}}async function JS(t){return j(t)}function CB(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 kB(t,e){YS(t,"clone-url"),await xg(["clone",t,e]);}async function EB(t,e){YS(e,"ref"),await xg(["checkout",e],t);}async function LB(t){return xg(["rev-parse","HEAD"],t)}async function xg(t,e){let{stdout:r}=await SB("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var SB,VS,Dg=d(()=>{A();SB=promisify(execFile),VS="repo";s(YS,"ensureNotFlag");s(Vp,"fetchGitRemoteExtend");s(Tg,"readCachedRepo");s(JS,"hasCachedRepo");s(CB,"resolveCloneUrl");s(kB,"cloneRepo");s(EB,"checkoutRef");s(LB,"getHeadSha");s(xg,"runGit");});function bB(){let t=process.env.AGENTSMESH_MAX_TARBALL_MB;if(t===void 0||t==="")return Kc*1024*1024;let e=Number(t);return !Number.isFinite(e)||!Number.isInteger(e)?(console.warn(`[agentsmesh] AGENTSMESH_MAX_TARBALL_MB="${t}" is not an integer; using default ${Kc} MiB.`),Kc*1024*1024):e<ZS||e>QS?(console.warn(`[agentsmesh] AGENTSMESH_MAX_TARBALL_MB=${e} is outside [${ZS}, ${QS}]; using default ${Kc} MiB.`),Kc*1024*1024):e*1024*1024}async function TB(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 n=t.body;if(!n){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 o=n.getReader(),i=[],a=0;for(;;){let{done:m,value:p}=await o.read();if(m)break;if(p){if(a+=p.byteLength,a>e)throw await o.cancel().catch(()=>{}),new Error(`remote response exceeded cap of ${e} bytes during streaming`);i.push(p);}}let l=new Uint8Array(a),c=0;for(let m of i)l.set(m,c),c+=m.byteLength;return l}async function eC(t,e,r){let n=`https://api.github.com/repos/${t}/${e}/releases/latest`,o={Accept:"application/vnd.github+json"};r&&(o.Authorization=`Bearer ${r}`);let i=await globalThis.fetch(n,{headers:o});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 rC(t,e,r,n,o,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,l=r.refresh===true,c=t.tag;if(c==="latest")try{c=await eC(t.org,t.repo,a);}catch(C){if(!i)throw C;return DB(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,c),p=join(n,m);if(!l&&await j(p)){let C=await Ng(p);if(C)return {resolvedPath:join(p,C),version:c}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,f={};a&&(f.Authorization=`Bearer ${a}`);let g;try{let C=await globalThis.fetch(u,{headers:f,redirect:"follow"});if(!C.ok)throw new Error(`HTTP ${C.status}: ${C.statusText}`);g=await TB(C,PB);}catch(C){if(r.allowOfflineFallback!==false&&await j(p)){let P=await Ng(p);if(P)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${C instanceof Error?C.message:String(C)}`),{resolvedPath:join(p,P),version:c}}throw C}await rm$1(p,{recursive:true,force:true}),await mkdir(p,{recursive:true});let h=join(p,"archive.tar.gz");await writeFile(h,g);try{await tC.extract({file:h,cwd:p,strict:!0,filter:s((C,R)=>!(xB(C)||R&&"type"in R&&(R.type==="Link"||R.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let I=await Ng(p);if(!I)throw new Error(`Extend "${e}": archive has no top-level directory. Expected a single top-level directory inside the archive.`);return {resolvedPath:join(p,I),version:c}}async function Ng(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}function qS(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function xB(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function DB(t,e,r,n,o,i){let a=i?[qS(t.org,t.repo,i)]:[qS(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],l;for(let c of a){let m={url:c};try{return await Vp(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}var Kc,ZS,QS,PB,nC=d(()=>{A();Dg();Kc=500,ZS=1,QS=4096;s(bB,"resolveMaxTarballBytes");PB=bB();s(TB,"readBoundedResponse");s(eC,"resolveLatestTag");s(rC,"fetchGithubRemoteExtend");s(Ng,"findExtractTopDir");s(qS,"buildGithubCloneUrl");s(xB,"isZipSlipPath");s(DB,"fetchGithubDefaultBranch");});function oC(t,e,r){if(!t.startsWith(e))return null;let n=t.slice(e.length).trim();if(!n)return null;let o=n.lastIndexOf("@");if(o<0)return [n,r];let i=n.slice(0,o).trim(),a=n.slice(o+1).trim();return !i||!a?null:[i,a]}function sC(t){let e=oC(t,"github:","latest");if(!e)return null;let[r,n]=e,o=r.indexOf("/");if(o<0)return null;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !i||!a||!n?null:{org:i,repo:a,tag:n}}function iC(t){let e=oC(t,"gitlab:");if(!e)return null;let[r,n]=e,o=r.lastIndexOf("/");if(o<0)return null;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !i||!a?null:{namespace:i,project:a,ref:n,cloneUrl:`https://gitlab.com/${i}/${a}.git`}}function aC(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),n=(r<0?e:e.slice(0,r)).trim(),o=r<0?void 0:e.slice(r+1).trim();if(!n||r>=0&&!o)return null;let i;try{i=new URL(n);}catch{return null}return (process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="1"||process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="true"?["https:","http:","ssh:","file:"]:["https:","ssh:","file:"]).includes(i.protocol)?{url:n,ref:o}:null}function wi(t){let e=sC(t);if(e)return {kind:"github",...e};let r=iC(t);if(r)return {kind:"gitlab",...r};let n=aC(t);return n?{kind:"git",...n}:null}function Fg(t){return wi(t)!==null}var Wc=d(()=>{s(oC,"splitSourceRef");s(sC,"parseGithubSource");s(iC,"parseGitlabSource");s(aC,"parseGitSource");s(wi,"parseRemoteSource");s(Fg,"isSupportedRemoteSource");});function MB(t){let e=wi(t);return e?e.kind==="github"?Qa("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?Qa("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):Qa("git",e.url,e.ref??"HEAD"):null}async function mC(t,e){let r=MB(t);if(!r)return;let n=e??ve(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}async function pC(t,e){let r=t??ve(),n=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,o;try{o=await readdir(r);}catch{return}let i=Date.now();await Promise.all(o.map(async a=>{let l=join(r,a);try{let{mtimeMs:c}=await stat(l);i-c>n&&await rm$1(l,{recursive:!0,force:!0});}catch{}}));}var vg=d(()=>{Hc();Wc();s(MB,"cacheKeyFromSource");s(mC,"cleanInstallCache");s(pC,"sweepStaleCache");});function Qa(t,e,r){let n=s(i=>i.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),o;if(t==="github"){let[i,a]=e.split("/",2);i&&a?o=`${n(i)}--${n(a)}--${n(r)}`:o=`${n(t)}__${n(e)}__${n(r)}`;}else o=`${n(t)}__${n(e)}__${n(r)}`;if(o.length>fC){let i=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,fC-18)}--${i}`;}return o}function ve(){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 qa(t,e,r={}){let n=wi(t);if(!n)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 o=r.cacheDir??ve();return pC(o).catch(()=>{}),n.kind==="github"?rC(n,e,r,o,Qa,!t.includes("@")):Vp(n,e,r,o,Qa)}var fC,Hc=d(()=>{Dg();nC();Wc();vg();fC=80;s(Qa,"buildCacheKey");s(ve,"getCacheDir");s(qa,"fetchRemoteExtend");});function BB(t){return t.startsWith("http://")||t.startsWith("https://")}async function tl(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Fg(o.source))){let o=ve();await rm$1(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(BB(o.source))throw new Error(`Remote extends (http/https) not supported: "${o.source}" for extend "${o.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(Fg(o.source)){let a=await qa(o.source,o.name,{cacheDir:ve(),refresh:r.refreshCache===true});n.push({name:o.name,resolvedPath:a.resolvedPath,features:[...o.features],target:o.target,as:o.as,version:a.version,path:o.path,pick:o.pick});continue}let i=resolve(e,o.source);if(!await j(i))throw new Error(`Extend "${o.name}": path does not exist: ${i}. Check extends.source in agentsmesh.yaml.`);n.push({name:o.name,resolvedPath:i,features:[...o.features],target:o.target,as:o.as,path:o.path,pick:o.pick});}return n}var Jp=d(()=>{A();Hc();Wc();s(BB,"isOtherRemoteSource");s(tl,"resolveExtendPaths");});function b(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let n=t.slice(3,r).trim(),o=t.slice(r+3).trim();return {frontmatter:n===""?{}:parse(n)??{},body:o}}function HB(t){if(t.indexOf("---")!==0)return t.trim();let e=t.indexOf("---",3);return e===-1?t.trim():t.slice(e+3).trim()}function Gr(t,e){try{return {ok:!0,value:b(t)}}catch(r){let n=r instanceof Error?r.message:String(r);return {ok:false,error:new Error(`Failed to parse frontmatter in ${e}: ${n}`,{cause:r}),bodyFallback:HB(t)}}}function Co(t,e,r){let n=Gr(t,e);if(n.ok)return n.value;if(r)return r(n.error,e),null;throw n.error}function T(t,e){return Object.keys(t).length===0?e:`---
12
12
  ${stringify(t,{lineWidth:0}).trimEnd()}
13
13
  ---
14
14
 
15
- ${e}`}var j=d(()=>{s(b,"parseFrontmatter");s(TB,"extractBody");s(Fr,"tryParseFrontmatter");s(Io,"parseOrSkipFrontmatter");s(T,"serializeFrontmatter");});function NB(t){let e=t.replace(/\.[^.]*$/,"").toUpperCase();return xB.has(e)}function lC(t){let e=[],r=t.split(/[\\/]/);for(let n of r)if(!(n===""||n==="."||n==="..")){if(DB.test(n)){e.push({segment:n,reason:"illegal-character"});continue}if(/[. ]$/.test(n)){e.push({segment:n,reason:"trailing-dot-or-space"});continue}NB(n)&&e.push({segment:n,reason:"reserved-name"});}return e}var xB,DB,cC=d(()=>{xB=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]),DB=new RegExp('[<>:"|?*\\u0000-\\u001F]');s(NB,"segmentReservedName");s(lC,"findWindowsPathIssues");});function So(t,e){let r=lC(e);if(r.length===0)return;let n=r.map(o=>`${o.segment} (${o.reason})`).join(", ");throw new vp(t,e,`canonical ${t} name "${e}" is not portable to Windows: ${n}. Rename the file.`)}function Mp(t,e,r){let n=new Map;for(let o of e){let i=o.lastIndexOf("/"),a=o.lastIndexOf("\\"),l=Math.max(i,a),c=l===-1?o:o.slice(l+1),m=c.endsWith(r)?c.slice(0,-r.length):c,p=n.get(m);if(p!==void 0&&p!==o)throw new vp(t,m,`canonical ${t} files collide on slug "${m}": ${p} vs ${o}. Rename one.`);n.set(m,o);}}var vp,Bc=d(()=>{cC();vp=class extends Error{static{s(this,"CanonicalNameError");}feature;name;constructor(e,r,n){super(n),this.feature=e,this.name=r;}};s(So,"assertCanonicalName");s(Mp,"assertNoBasenameCollisions");});function tl(t,e,r,n,o={}){if(r.length===0)return;let i=new Set(n),a=o.handledByOtherReader,l=new Set,c=0;for(let p of r){if(i.has(p)||basename(p).startsWith("."))continue;let u=extname(p).toLowerCase();MB.has(u)&&(a?.has(u)||(l.add(u),c++));}if(c===0)return;let m=[...l].sort().join(", ");y.warn(`Skipped ${c} ${t} file(s) in ${e} (format${l.size===1?"":"s"}: ${m}). agentsmesh ${t} are parsed from .md files only.`);}var MB,$p=d(()=>{ot();MB=new Set([".toml",".yaml",".yml",".json"]);s(tl,"warnIfUnrecognizedResourceFormats");});function pC(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function Cs(t,e={}){let r=await v(t),n=r.filter(i=>{if(!i.endsWith(".md"))return false;let a=basename(i,".md");return a==="_root"||!a.startsWith("_")});tl("rules",t,r,n,{handledByOtherReader:e.handledByOtherReader});let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=Io(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");So("rule",p);let u=p==="_root",f=c.root===true,g=c.trigger,h=typeof g=="string"&&$B.includes(g)?g:void 0,R=c.codex_emit,C=R==="execution"?"execution":R==="advisory"?"advisory":void 0,k=c.codex_instruction==="override"?"override":void 0;o.push({source:i,root:u||f,targets:pC(c.targets),description:typeof c.description=="string"?c.description:"",globs:pC(c.globs),body:m,...h!==void 0&&{trigger:h},...C!==void 0&&{codexEmit:C},...k!==void 0&&{codexInstructionVariant:k}});}return o}var $B,Kc=d(()=>{w();j();Bc();$p();$B=["always_on","model_decision","glob","manual"];s(pC,"toStrArray");s(Cs,"parseRules");});function dC(t){return t===true||t==="true"||t===1||t==="1"}function fC(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 ks(t,e={}){let r=await v(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));tl("commands",t,r,n,{handledByOtherReader:e.handledByOtherReader}),Mp("command",n,".md");let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=Io(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");So("command",p);let u=fC(c.allowedTools),f=fC(c["allowed-tools"]),g=u.length>0?u:f;o.push({source:i,name:p,description:typeof c.description=="string"?c.description:"",allowedTools:g,outputStyle:dC(c.outputStyle)||dC(c["output-style"]),body:m});}return o}var Wc=d(()=>{w();j();Bc();$p();s(dC,"toBool");s(fC,"toToolsArray");s(ks,"parseCommands");});function Oi(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 hC(t){return t===true||t==="true"||t===1||t==="1"}function yC(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 GB(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function Es(t,e={}){let r=await v(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));tl("agents",t,r,n,{handledByOtherReader:e.handledByOtherReader}),Mp("agent",n,".md");let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=Io(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");So("agent",p);let u=Oi(c.tools),f=Oi(c.tools),g=u.length>0?u:f,h=Oi(c.disallowedTools),R=Oi(c["disallowed-tools"]),C=h.length>0?h:R,S=Oi(c.mcpServers),k=Oi(c["mcp-servers"]),P=S.length>0?S:k,N=Oi(c.skills),F=yC(c.maxTurns),W=yC(c["max-turns"]),z=F>0?F:W>0?W:0;o.push({source:i,name:p,description:typeof c.description=="string"?c.description:"",tools:g,disallowedTools:C,model:typeof c.model=="string"?c.model:"",permissionMode:typeof c.permissionMode=="string"?c.permissionMode:typeof c["permission-mode"]=="string"?c["permission-mode"]:"",maxTurns:z,mcpServers:P,hooks:GB(c.hooks),skills:N,memory:typeof c.memory=="string"?c.memory:"",outputStyle:hC(c.outputStyle)||hC(c["output-style"]),body:m});}return o}var Hc=d(()=>{w();j();Bc();$p();s(Oi,"toStrArray");s(hC,"toBool");s(yC,"toInt");s(GB,"toHooks");s(Es,"parseAgents");});function kg(t){let e=t.toLowerCase(),r=e.lastIndexOf("."),n=r>0?e.slice(0,r):e;return jB.get(n)}function In(t){return kg(t)!==void 0}function Gp(t){return kg(t)==="preserved"}function jp(t){return kg(t)==="noise"}function _C(t){return UB.has(t)}function RC(t){return BB.has(t)}var jB,UB,BB,Co=d(()=>{jB=new Map([["contributing","noise"],["changelog","noise"],["changes","noise"],["history","noise"],["code_of_conduct","noise"],["security","noise"],["support","noise"],["maintainers","noise"],["governance","noise"],["authors","noise"],["contributors","noise"],["codeowners","noise"],["citation","noise"],["acknowledgments","noise"],["acknowledgements","noise"],["license","preserved"],["license-mit","preserved"],["license-apache","preserved"],["license-bsd","preserved"],["license-gpl","preserved"],["notice","preserved"],["copying","preserved"],["copyright","preserved"],["readme","preserved"]]),UB=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]),BB=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]);s(kg,"boilerplateKind");s(In,"isBoilerplate");s(Gp,"isPreservedBoilerplate");s(jp,"isNoiseBoilerplate");s(_C,"isRepoNonContentDir");s(RC,"isRepoNonContentFile");});async function HB(t){return await _(t)??""}function VB(t){let e=t.lastIndexOf(".");return e<0?true:zB.has(t.slice(e).toLowerCase())}function YB(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function IC(t){let e=await v(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===Up||i.endsWith(`/${Up}`))continue;let a=i.split("/")[0];if(JB.some(m=>a===m)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let l=i.includes("/")?i.slice(i.lastIndexOf("/")+1):i;if(VB(l)&&jp(l))continue;let c=await HB(n);r.push({relativePath:i,absolutePath:n,content:c});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}async function Bp(t,e={}){let r=join(t,Up),n=await _(r);if(!n)return null;let o=Io(n,r,e.onParseError);if(!o)return null;let{frontmatter:i,body:a}=o,l=await IC(t),m=(typeof i.name=="string"?YB(i.name):"")||basename(t);return So("skill",m),{source:r,name:m,description:typeof i.description=="string"?i.description:"",body:a,supportingFiles:l}}async function Ls(t,e={}){let r;try{r=await readdir(t,{withFileTypes:!0});}catch{return []}let n=[];for(let o of r){if(!o.isDirectory()||o.name.startsWith("_"))continue;So("skill",o.name);let i=join(t,o.name),a=join(i,Up),l=await _(a);if(!l)continue;let c=Io(l,a,e.onParseError);if(!c)continue;let{frontmatter:m,body:p}=c,u=await IC(i);n.push({source:a,name:o.name,description:typeof m.description=="string"?m.description:"",body:p,supportingFiles:u});}return n.sort((o,i)=>o.name.localeCompare(i.name))}var Up,zB,JB,el=d(()=>{w();j();Co();Bc();s(HB,"readContent");Up="SKILL.md",zB=new Set([".md",".mdx",".rst",".txt"]);s(VB,"isMarkdownLikeDoc");JB=[".git","node_modules"];s(YB,"sanitizeSkillName");s(IC,"listSupportingFiles");s(Bp,"parseSkillDirectory");s(Ls,"parseSkills");});function SC(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function XB(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=SC(e.env),o=typeof e.description=="string"?e.description:void 0,i=typeof e.url=="string"?e.url:"";if(i)return {...o!==void 0&&{description:o},type:r,url:i,headers:SC(e.headers),env:n};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let l=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[];return {...o!==void 0&&{description:o},type:r,command:a,args:l,env:n}}function ZB(t){let e="",r=0,n=t.length;for(;r<n;){let o=t[r];if(o==='"'){for(e+=o,r++;r<n;){let i=t[r];if(e+=i,i==="\\")r++,r<n&&(e+=t[r]);else if(i==='"')break;r++;}r++;continue}if(o==="/"&&t[r+1]==="*"){for(r+=2;r<n;){if(t[r]==="*"&&t[r+1]==="/"){r+=2;break}r++;}continue}if(o==="/"&&t[r+1]==="/"){for(r+=2;r<n&&t[r]!==`
16
- `;)r++;continue}e+=o,r++;}return e}async function vr(t){let e=await _(t);if(!e)return null;let r;try{r=JSON.parse(ZB(e));}catch{return null}if(!r||typeof r!="object")return null;let n=r.mcpServers;if(n===void 0||typeof n!="object"||n===null)return null;let o={};for(let[i,a]of Object.entries(n)){let l=XB(a);l&&(o[i]=l);}return {mcpServers:o}}var zc=d(()=>{w();s(SC,"parseStringMap");s(XB,"parseServer");s(ZB,"stripJsonComments");s(vr,"parseMcp");});function Lg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function Kp(t){let e=await _(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 n=r,o=Lg(n.allow),i=Lg(n.deny),a=Lg(n.ask);return {allow:o,deny:i,ask:a}}var Og=d(()=>{w();s(Lg,"ensureStringArray");s(Kp,"parsePermissions");});function CC(t){return typeof t=="string"?t.trim():""}function zt(t){return CC(t.command)}function he(t){return CC(t.prompt)}function Ag(t){let e=zt(t),r=he(t);return t.type==="prompt"?r||e:e||r}function ko(t){return zt(t).length>0}function Sn(t){return Ag(t).length>0}var Mr=d(()=>{s(CC,"trimString");s(zt,"getHookCommand");s(he,"getHookPrompt");s(Ag,"getHookText");s(ko,"hasHookCommand");s(Sn,"hasHookText");});function eK(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=Ag(e);if(!n)return null;let o=typeof e.type=="string"&&tK.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=he(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}async function Wp(t){let e=await _(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 n={},o=r;for(let[i,a]of Object.entries(o)){if(!Array.isArray(a))continue;let l=[];for(let c of a){let m=eK(c);m&&l.push(m);}l.length>0&&(n[i]=l);}return n}var tK,wg=d(()=>{w();Mr();tK=["command","prompt"];s(eK,"toHookEntry");s(Wp,"parseHooks");});async function Hp(t){let e=await _(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),n=[];for(let o of r){let i=o.trim();i===""||i.startsWith("#")||n.push(i);}return n}var bg=d(()=>{w();s(Hp,"parseIgnore");});async function Ee(t,e={}){let r=join(t,".agentsmesh"),n=await $(r)?r:t,[o,i,a,l,c,m,p,u]=await Promise.all([Cs(join(n,"rules"),e),ks(join(n,"commands"),e),Es(join(n,"agents"),e),Ls(join(n,"skills"),e),vr(join(n,"mcp.json")),Kp(join(n,"permissions.yaml")),Wp(join(n,"hooks.yaml")),Hp(join(n,"ignore"))]);return {rules:o,commands:i,agents:a,skills:l,mcp:c,permissions:m,hooks:p,ignore:u}}var Ai=d(()=>{Kc();Wc();Hc();el();zc();Og();wg();bg();w();s(Ee,"loadCanonicalFiles");});function kC(t){return basename(t.source,".md")}function rl(t,e){let r=new Map(t.rules.map(p=>[kC(p),p]));for(let p of e.rules)r.set(kC(p),p);let n=new Map(t.commands.map(p=>[p.name,p]));for(let p of e.commands)n.set(p.name,p);let o=new Map(t.agents.map(p=>[p.name,p]));for(let p of e.agents)o.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=nK(t.mcp,e.mcp),l=oK(t.permissions,e.permissions),c=sK(t.hooks,e.hooks),m=iK(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(n.values()),agents:Array.from(o.values()),skills:Array.from(i.values()),mcp:a,permissions:l,hooks:c,ignore:m}}function nK(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}function oK(t,e){if(!t&&!e)return null;let r=Pg(t?.allow??[],e?.allow??[]),n=Pg(t?.deny??[],e?.deny??[]),o=Pg(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}function Pg(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}function sK(t,e){if(!t&&!e)return null;let r={},n=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let o of n){let i=e?.[o],a=t?.[o];r[o]=i!==void 0&&i.length>0?i:a??[];}return r}function iK(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}var Tg=d(()=>{s(kC,"ruleSlug");s(rl,"mergeCanonicalFiles");s(nK,"mergeMcp");s(oK,"mergePermissions");s(Pg,"mergeUniqueStrings");s(sK,"mergeHooks");s(iK,"mergeIgnore");});function dK(t){return typeof t=="string"?t:t.level}function EC(t){return uK.includes(t)}function LC(t,e,r,n){for(let o of pK){let i=dK(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",l=EC(o.feature)&&typeof t.emitScopedSettings=="function";a||l||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${i}" but generators.${o.generator}`+(EC(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function zp(t){return yK.parse(t)}var Lo,OC,aK,lK,AC,cK,mK,pK,uK,fK,gK,hK,yK,xg=d(()=>{Lo=z.union([z.enum(["native","embedded","partial","none"]),z.object({level:z.enum(["native","embedded","partial","none"]),flavor:z.string().optional()})]),OC=z.object({rules:Lo,additionalRules:Lo,commands:Lo,agents:Lo,skills:Lo,mcp:Lo,hooks:Lo,ignore:Lo,permissions:Lo}),aK=z.object({name:z.string(),generateRules:z.function(),importFrom:z.function(),generateCommands:z.function().optional(),generateAgents:z.function().optional(),generateSkills:z.function().optional(),generateMcp:z.function().optional(),generatePermissions:z.function().optional(),generateHooks:z.function().optional(),generateIgnore:z.function().optional(),lint:z.function().optional()}).passthrough(),lK=z.object({rulePath:z.function(),commandPath:z.function(),agentPath:z.function()}),AC=z.object({paths:lK}).passthrough(),cK=z.object({capabilities:OC,detectionPaths:z.array(z.string()),layout:AC,scopeExtras:z.function().optional()}).passthrough(),mK=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],pK=[{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"}],uK=["mcp","hooks","ignore","permissions"];s(dK,"capabilityLevel");s(EC,"canUseScopedSettings");s(LC,"validateCapabilityImplementations");fK=z.object({commandsToSkills:z.boolean().optional(),agentsToSkills:z.boolean().optional()}).strict(),gK=z.object({displayName:z.string().min(1),category:z.enum(["cli","ide","agent-platform"]),officialUrl:z.string().min(1),shortDescription:z.string().min(1)}).passthrough(),hK=z.object({id:z.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),metadata:gK,generators:aK,capabilities:OC,emptyImportMessage:z.string(),lintRules:z.union([z.function(),z.null()]),project:AC,globalSupport:cK.optional(),buildImportPaths:z.function(),detectionPaths:z.array(z.string()),excludeFromStarterInit:z.boolean().optional(),conversionDefaults:fK.optional(),emitScopedSettings:z.function().optional(),mergeGeneratedOutputContent:z.function().optional(),postProcessHookOutputs:z.function().optional(),preservesManualActivation:z.boolean().optional()}).passthrough(),yK=hK.superRefine((t,e)=>{for(let r of mK)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});LC(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&LC(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(zp,"validateDescriptor");});function wC(){if(Dg)return Dg;let t=bt.filter(r=>r!==void 0&&typeof r.id=="string"),e=new Map(t.map(r=>[r.id,r]));return t.length===bt.length&&(Dg=e),e}function Jp(t){let e=zp(t);Vp.set(e.id,e);}function et(t){return Vp.get(t)??wC().get(t)}function Yp(){return [...Vp.values()]}function bC(){return [...new Set([...wC().keys(),...Vp.keys()])]}var Vp,Dg,se=d(()=>{Pt();xg();Vp=new Map;s(wC,"builtinDescriptors");s(Jp,"registerTargetDescriptor");s(et,"getDescriptor");s(Yp,"getAllDescriptors");s(bC,"getAllRegisteredDescriptorIds");});function PC(t,e){return et(t)?.conversionDefaults?.[e]}function TC(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function nl(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=TC(o,n);if(i!==void 0)return i;let a=PC(e,"commandsToSkills");return a!==void 0?a:r??false}function qe(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],i=TC(o,n);if(i!==void 0)return i;let a=PC(e,"agentsToSkills");return a!==void 0?a:r??false}var ol=d(()=>{se();s(PC,"builtinDefault");s(TC,"resolveConversionValue");s(nl,"shouldConvertCommandsToSkills");s(qe,"shouldConvertAgentsToSkills");});function Gr(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function $r(t){return typeof t=="string"?{level:t}:t}function xC(t){return {rules:$r(t.rules),additionalRules:$r(t.additionalRules),commands:$r(t.commands),agents:$r(t.agents),skills:$r(t.skills),mcp:$r(t.mcp),hooks:$r(t.hooks),ignore:$r(t.ignore),permissions:$r(t.permissions)}}var wi=d(()=>{s(Gr,"cap");s($r,"normalizeCapabilityValue");s(xC,"normalizeTargetCapabilities");});function DC(t){for(let e of bt)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function _K(t){let e=[];for(let n of t)if(n.sharedArtifacts)for(let[o,i]of Object.entries(n.sharedArtifacts))i==="owner"&&e.push({targetId:n.id,prefix:o});let r=[];for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++){let i=e[n],a=e[o];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 NC(t){let e=_K(t);if(e.length===0)return;let r=e.map(({a:n,b:o})=>` - "${n.targetId}" owns "${n.prefix}" and "${o.targetId}" owns "${o.prefix}"`);throw new Error(`Shared-artifact ownership conflict: two targets claim the same or overlapping prefix.
15
+ ${e}`}var K=d(()=>{s(b,"parseFrontmatter");s(HB,"extractBody");s(Gr,"tryParseFrontmatter");s(Co,"parseOrSkipFrontmatter");s(T,"serializeFrontmatter");});function JB(t){let e=t.replace(/\.[^.]*$/,"").toUpperCase();return zB.has(e)}function gC(t){let e=[],r=t.split(/[\\/]/);for(let n of r)if(!(n===""||n==="."||n==="..")){if(VB.test(n)){e.push({segment:n,reason:"illegal-character"});continue}if(/[. ]$/.test(n)){e.push({segment:n,reason:"trailing-dot-or-space"});continue}JB(n)&&e.push({segment:n,reason:"reserved-name"});}return e}var zB,VB,hC=d(()=>{zB=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]),VB=new RegExp('[<>:"|?*\\u0000-\\u001F]');s(JB,"segmentReservedName");s(gC,"findWindowsPathIssues");});function ko(t,e){let r=gC(e);if(r.length===0)return;let n=r.map(o=>`${o.segment} (${o.reason})`).join(", ");throw new Yp(t,e,`canonical ${t} name "${e}" is not portable to Windows: ${n}. Rename the file.`)}function Xp(t,e,r){let n=new Map;for(let o of e){let i=o.lastIndexOf("/"),a=o.lastIndexOf("\\"),l=Math.max(i,a),c=l===-1?o:o.slice(l+1),m=c.endsWith(r)?c.slice(0,-r.length):c,p=n.get(m);if(p!==void 0&&p!==o)throw new Yp(t,m,`canonical ${t} files collide on slug "${m}": ${p} vs ${o}. Rename one.`);n.set(m,o);}}var Yp,zc=d(()=>{hC();Yp=class extends Error{static{s(this,"CanonicalNameError");}feature;name;constructor(e,r,n){super(n),this.feature=e,this.name=r;}};s(ko,"assertCanonicalName");s(Xp,"assertNoBasenameCollisions");});function el(t,e,r,n,o={}){if(r.length===0)return;let i=new Set(n),a=o.handledByOtherReader,l=new Set,c=0;for(let p of r){if(i.has(p)||basename(p).startsWith("."))continue;let u=extname(p).toLowerCase();ZB.has(u)&&(a?.has(u)||(l.add(u),c++));}if(c===0)return;let m=[...l].sort().join(", ");y.warn(`Skipped ${c} ${t} file(s) in ${e} (format${l.size===1?"":"s"}: ${m}). agentsmesh ${t} are parsed from .md files only.`);}var ZB,Zp=d(()=>{st();ZB=new Set([".toml",".yaml",".yml",".json"]);s(el,"warnIfUnrecognizedResourceFormats");});function _C(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function ks(t,e={}){let r=await $(t),n=r.filter(i=>{if(!i.endsWith(".md"))return false;let a=basename(i,".md");return a==="_root"||!a.startsWith("_")});el("rules",t,r,n,{handledByOtherReader:e.handledByOtherReader});let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=Co(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");ko("rule",p);let u=p==="_root",f=c.root===true,g=c.trigger,h=typeof g=="string"&&QB.includes(g)?g:void 0,I=c.codex_emit,k=I==="execution"?"execution":I==="advisory"?"advisory":void 0,R=c.codex_instruction==="override"?"override":void 0;o.push({source:i,root:u||f,targets:_C(c.targets),description:typeof c.description=="string"?c.description:"",globs:_C(c.globs),body:m,...h!==void 0&&{trigger:h},...k!==void 0&&{codexEmit:k},...R!==void 0&&{codexInstructionVariant:R}});}return o}var QB,Vc=d(()=>{A();K();zc();Zp();QB=["always_on","model_decision","glob","manual"];s(_C,"toStrArray");s(ks,"parseRules");});function IC(t){return t===true||t==="true"||t===1||t==="1"}function SC(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 Es(t,e={}){let r=await $(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));el("commands",t,r,n,{handledByOtherReader:e.handledByOtherReader}),Xp("command",n,".md");let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=Co(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");ko("command",p);let u=SC(c.allowedTools),f=SC(c["allowed-tools"]),g=u.length>0?u:f;o.push({source:i,name:p,description:typeof c.description=="string"?c.description:"",allowedTools:g,outputStyle:IC(c.outputStyle)||IC(c["output-style"]),body:m});}return o}var Jc=d(()=>{A();K();zc();Zp();s(IC,"toBool");s(SC,"toToolsArray");s(Es,"parseCommands");});function Ai(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 kC(t){return t===true||t==="true"||t===1||t==="1"}function EC(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 qB(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function Ls(t,e={}){let r=await $(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));el("agents",t,r,n,{handledByOtherReader:e.handledByOtherReader}),Xp("agent",n,".md");let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=Co(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");ko("agent",p);let u=Ai(c.tools),f=Ai(c.tools),g=u.length>0?u:f,h=Ai(c.disallowedTools),I=Ai(c["disallowed-tools"]),k=h.length>0?h:I,C=Ai(c.mcpServers),R=Ai(c["mcp-servers"]),P=C.length>0?C:R,N=Ai(c.skills),F=EC(c.maxTurns),B=EC(c["max-turns"]),U=F>0?F:B>0?B:0;o.push({source:i,name:p,description:typeof c.description=="string"?c.description:"",tools:g,disallowedTools:k,model:typeof c.model=="string"?c.model:"",permissionMode:typeof c.permissionMode=="string"?c.permissionMode:typeof c["permission-mode"]=="string"?c["permission-mode"]:"",maxTurns:U,mcpServers:P,hooks:qB(c.hooks),skills:N,memory:typeof c.memory=="string"?c.memory:"",outputStyle:kC(c.outputStyle)||kC(c["output-style"]),body:m});}return o}var Yc=d(()=>{A();K();zc();Zp();s(Ai,"toStrArray");s(kC,"toBool");s(EC,"toInt");s(qB,"toHooks");s(Ls,"parseAgents");});function Mg(t){let e=t.toLowerCase(),r=e.lastIndexOf("."),n=r>0?e.slice(0,r):e;return tK.get(n)}function Cn(t){return Mg(t)!==void 0}function Qp(t){return Mg(t)==="preserved"}function qp(t){return Mg(t)==="noise"}function LC(t){return eK.has(t)}function OC(t){return rK.has(t)}var tK,eK,rK,Eo=d(()=>{tK=new Map([["contributing","noise"],["changelog","noise"],["changes","noise"],["history","noise"],["code_of_conduct","noise"],["security","noise"],["support","noise"],["maintainers","noise"],["governance","noise"],["authors","noise"],["contributors","noise"],["codeowners","noise"],["citation","noise"],["acknowledgments","noise"],["acknowledgements","noise"],["license","preserved"],["license-mit","preserved"],["license-apache","preserved"],["license-bsd","preserved"],["license-gpl","preserved"],["notice","preserved"],["copying","preserved"],["copyright","preserved"],["readme","preserved"]]),eK=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]),rK=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]);s(Mg,"boilerplateKind");s(Cn,"isBoilerplate");s(Qp,"isPreservedBoilerplate");s(qp,"isNoiseBoilerplate");s(LC,"isRepoNonContentDir");s(OC,"isRepoNonContentFile");});async function sK(t){return await _(t)??""}function aK(t){let e=t.lastIndexOf(".");return e<0?true:iK.has(t.slice(e).toLowerCase())}function cK(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function wC(t){let e=await $(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===tu||i.endsWith(`/${tu}`))continue;let a=i.split("/")[0];if(lK.some(m=>a===m)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let l=i.includes("/")?i.slice(i.lastIndexOf("/")+1):i;if(aK(l)&&qp(l))continue;let c=await sK(n);r.push({relativePath:i,absolutePath:n,content:c});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}async function eu(t,e={}){let r=join(t,tu),n=await _(r);if(!n)return null;let o=Co(n,r,e.onParseError);if(!o)return null;let{frontmatter:i,body:a}=o,l=await wC(t),m=(typeof i.name=="string"?cK(i.name):"")||basename(t);return ko("skill",m),{source:r,name:m,description:typeof i.description=="string"?i.description:"",body:a,supportingFiles:l}}async function Os(t,e={}){let r;try{r=await readdir(t,{withFileTypes:!0});}catch{return []}let n=[];for(let o of r){if(!o.isDirectory()||o.name.startsWith("_"))continue;ko("skill",o.name);let i=join(t,o.name),a=join(i,tu),l=await _(a);if(!l)continue;let c=Co(l,a,e.onParseError);if(!c)continue;let{frontmatter:m,body:p}=c,u=await wC(i);n.push({source:a,name:o.name,description:typeof m.description=="string"?m.description:"",body:p,supportingFiles:u});}return n.sort((o,i)=>o.name.localeCompare(i.name))}var tu,iK,lK,rl=d(()=>{A();K();Eo();zc();s(sK,"readContent");tu="SKILL.md",iK=new Set([".md",".mdx",".rst",".txt"]);s(aK,"isMarkdownLikeDoc");lK=[".git","node_modules"];s(cK,"sanitizeSkillName");s(wC,"listSupportingFiles");s(eu,"parseSkillDirectory");s(Os,"parseSkills");});function AC(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function mK(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=AC(e.env),o=typeof e.description=="string"?e.description:void 0,i=typeof e.url=="string"?e.url:"";if(i)return {...o!==void 0&&{description:o},type:r,url:i,headers:AC(e.headers),env:n};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let l=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[];return {...o!==void 0&&{description:o},type:r,command:a,args:l,env:n}}function pK(t){let e="",r=0,n=t.length;for(;r<n;){let o=t[r];if(o==='"'){for(e+=o,r++;r<n;){let i=t[r];if(e+=i,i==="\\")r++,r<n&&(e+=t[r]);else if(i==='"')break;r++;}r++;continue}if(o==="/"&&t[r+1]==="*"){for(r+=2;r<n;){if(t[r]==="*"&&t[r+1]==="/"){r+=2;break}r++;}continue}if(o==="/"&&t[r+1]==="/"){for(r+=2;r<n&&t[r]!==`
16
+ `;)r++;continue}e+=o,r++;}return e}async function jr(t){let e=await _(t);if(!e)return null;let r;try{r=JSON.parse(pK(e));}catch{return null}if(!r||typeof r!="object")return null;let n=r.mcpServers;if(n===void 0||typeof n!="object"||n===null)return null;let o={};for(let[i,a]of Object.entries(n)){let l=mK(a);l&&(o[i]=l);}return {mcpServers:o}}var Xc=d(()=>{A();s(AC,"parseStringMap");s(mK,"parseServer");s(pK,"stripJsonComments");s(jr,"parseMcp");});function Gg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function ru(t){let e=await _(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 n=r,o=Gg(n.allow),i=Gg(n.deny),a=Gg(n.ask);return {allow:o,deny:i,ask:a}}var jg=d(()=>{A();s(Gg,"ensureStringArray");s(ru,"parsePermissions");});function bC(t){return typeof t=="string"?t.trim():""}function Vt(t){return bC(t.command)}function ye(t){return bC(t.prompt)}function Ug(t){let e=Vt(t),r=ye(t);return t.type==="prompt"?r||e:e||r}function Lo(t){return Vt(t).length>0}function kn(t){return Ug(t).length>0}var Ur=d(()=>{s(bC,"trimString");s(Vt,"getHookCommand");s(ye,"getHookPrompt");s(Ug,"getHookText");s(Lo,"hasHookCommand");s(kn,"hasHookText");});function gK(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=Ug(e);if(!n)return null;let o=typeof e.type=="string"&&fK.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=ye(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}async function nu(t){let e=await _(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 n={},o=r;for(let[i,a]of Object.entries(o)){if(!Array.isArray(a))continue;let l=[];for(let c of a){let m=gK(c);m&&l.push(m);}l.length>0&&(n[i]=l);}return n}var fK,Bg=d(()=>{A();Ur();fK=["command","prompt"];s(gK,"toHookEntry");s(nu,"parseHooks");});async function ou(t){let e=await _(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),n=[];for(let o of r){let i=o.trim();i===""||i.startsWith("#")||n.push(i);}return n}var Kg=d(()=>{A();s(ou,"parseIgnore");});async function Oe(t,e={}){let r=join(t,".agentsmesh"),n=await j(r)?r:t,[o,i,a,l,c,m,p,u]=await Promise.all([ks(join(n,"rules"),e),Es(join(n,"commands"),e),Ls(join(n,"agents"),e),Os(join(n,"skills"),e),jr(join(n,"mcp.json")),ru(join(n,"permissions.yaml")),nu(join(n,"hooks.yaml")),ou(join(n,"ignore"))]);return {rules:o,commands:i,agents:a,skills:l,mcp:c,permissions:m,hooks:p,ignore:u}}var bi=d(()=>{Vc();Jc();Yc();rl();Xc();jg();Bg();Kg();A();s(Oe,"loadCanonicalFiles");});function PC(t){return basename(t.source,".md")}function nl(t,e){let r=new Map(t.rules.map(p=>[PC(p),p]));for(let p of e.rules)r.set(PC(p),p);let n=new Map(t.commands.map(p=>[p.name,p]));for(let p of e.commands)n.set(p.name,p);let o=new Map(t.agents.map(p=>[p.name,p]));for(let p of e.agents)o.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=yK(t.mcp,e.mcp),l=_K(t.permissions,e.permissions),c=RK(t.hooks,e.hooks),m=IK(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(n.values()),agents:Array.from(o.values()),skills:Array.from(i.values()),mcp:a,permissions:l,hooks:c,ignore:m}}function yK(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}function _K(t,e){if(!t&&!e)return null;let r=Wg(t?.allow??[],e?.allow??[]),n=Wg(t?.deny??[],e?.deny??[]),o=Wg(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}function Wg(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}function RK(t,e){if(!t&&!e)return null;let r={},n=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let o of n){let i=e?.[o],a=t?.[o];r[o]=i!==void 0&&i.length>0?i:a??[];}return r}function IK(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}var Hg=d(()=>{s(PC,"ruleSlug");s(nl,"mergeCanonicalFiles");s(yK,"mergeMcp");s(_K,"mergePermissions");s(Wg,"mergeUniqueStrings");s(RK,"mergeHooks");s(IK,"mergeIgnore");});function wK(t){return typeof t=="string"?t:t.level}function TC(t){return OK.includes(t)}function xC(t,e,r,n){for(let o of LK){let i=wK(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",l=TC(o.feature)&&typeof t.emitScopedSettings=="function";a||l||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${i}" but generators.${o.generator}`+(TC(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function su(t){return TK.parse(t)}var wo,DC,SK,CK,NC,kK,EK,LK,OK,AK,bK,PK,TK,zg=d(()=>{wo=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()})]),DC=z$1.object({rules:wo,additionalRules:wo,commands:wo,agents:wo,skills:wo,mcp:wo,hooks:wo,ignore:wo,permissions:wo}),SK=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(),CK=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),NC=z$1.object({paths:CK}).passthrough(),kK=z$1.object({capabilities:DC,detectionPaths:z$1.array(z$1.string()),layout:NC,scopeExtras:z$1.function().optional()}).passthrough(),EK=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],LK=[{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"}],OK=["mcp","hooks","ignore","permissions"];s(wK,"capabilityLevel");s(TC,"canUseScopedSettings");s(xC,"validateCapabilityImplementations");AK=z$1.object({commandsToSkills:z$1.boolean().optional(),agentsToSkills:z$1.boolean().optional()}).strict(),bK=z$1.object({displayName:z$1.string().min(1),category:z$1.enum(["cli","ide","agent-platform"]),officialUrl:z$1.string().min(1),shortDescription:z$1.string().min(1)}).passthrough(),PK=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),metadata:bK,generators:SK,capabilities:DC,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:NC,globalSupport:kK.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string()),excludeFromStarterInit:z$1.boolean().optional(),conversionDefaults:AK.optional(),emitScopedSettings:z$1.function().optional(),mergeGeneratedOutputContent:z$1.function().optional(),postProcessHookOutputs:z$1.function().optional(),preservesManualActivation:z$1.boolean().optional()}).passthrough(),TK=PK.superRefine((t,e)=>{for(let r of EK)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});xC(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&xC(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(su,"validateDescriptor");});function FC(){if(Vg)return Vg;let t=bt.filter(r=>r!==void 0&&typeof r.id=="string"),e=new Map(t.map(r=>[r.id,r]));return t.length===bt.length&&(Vg=e),e}function au(t){let e=su(t);iu.set(e.id,e);}function ot(t){return iu.get(t)??FC().get(t)}function lu(){return [...iu.values()]}function vC(){return [...new Set([...FC().keys(),...iu.keys()])]}var iu,Vg,ae=d(()=>{Pt();zg();iu=new Map;s(FC,"builtinDescriptors");s(au,"registerTargetDescriptor");s(ot,"getDescriptor");s(lu,"getAllDescriptors");s(vC,"getAllRegisteredDescriptorIds");});function MC(t,e){return ot(t)?.conversionDefaults?.[e]}function $C(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function ol(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=$C(o,n);if(i!==void 0)return i;let a=MC(e,"commandsToSkills");return a!==void 0?a:r??false}function or(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],i=$C(o,n);if(i!==void 0)return i;let a=MC(e,"agentsToSkills");return a!==void 0?a:r??false}var sl=d(()=>{ae();s(MC,"builtinDefault");s($C,"resolveConversionValue");s(ol,"shouldConvertCommandsToSkills");s(or,"shouldConvertAgentsToSkills");});function Kr(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Br(t){return typeof t=="string"?{level:t}:t}function GC(t){return {rules:Br(t.rules),additionalRules:Br(t.additionalRules),commands:Br(t.commands),agents:Br(t.agents),skills:Br(t.skills),mcp:Br(t.mcp),hooks:Br(t.hooks),ignore:Br(t.ignore),permissions:Br(t.permissions)}}var Pi=d(()=>{s(Kr,"cap");s(Br,"normalizeCapabilityValue");s(GC,"normalizeTargetCapabilities");});function jC(t){for(let e of bt)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function xK(t){let e=[];for(let n of t)if(n.sharedArtifacts)for(let[o,i]of Object.entries(n.sharedArtifacts))i==="owner"&&e.push({targetId:n.id,prefix:o});let r=[];for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++){let i=e[n],a=e[o];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 UC(t){let e=xK(t);if(e.length===0)return;let r=e.map(({a:n,b:o})=>` - "${n.targetId}" owns "${n.prefix}" and "${o.targetId}" owns "${o.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 Ng=d(()=>{Pt();s(DC,"ownerTargetIdForSharedPath");s(_K,"findSharedArtifactOwnershipConflicts");s(NC,"assertSharedArtifactOwnersUnique");});function RK(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 H(t){return `${sl}${t}`}function Nt(t){let e={name:H(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"],T(e,t.body.trim()||"")}function Xp(t,e){if(t["x-agentsmesh-kind"]!=="command")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(sl)?e.slice(sl.length):e.startsWith(Vc)?e.slice(Vc.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:RK(t["x-agentsmesh-allowed-tools"])}:null}function Zp(t,e){return T({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var sl,Vc,kt=d(()=>{j();sl="am-command-",Vc="ab-command-";s(RK,"toStringArray");s(H,"commandSkillDirName");s(Nt,"serializeCommandSkill");s(Xp,"parseCommandSkillFrontmatter");s(Zp,"serializeImportedCommand");});function Qp(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 IK(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t))Array.isArray(n)&&(e[r]=n.filter(o=>o!==null&&typeof o=="object"&&typeof o.matcher=="string"&&typeof o.command=="string"));return e}function U(t){return `${il}${t}`}function Tt(t){let e={name:U(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];}),T(e,t.body.trim()||"")}function al(t,e){if(t["x-agentsmesh-kind"]!=="agent")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(il)?e.slice(il.length):e.startsWith(Jc)?e.slice(Jc.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:Qp(t["x-agentsmesh-tools"]),disallowedTools:Qp(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:Qp(t["x-agentsmesh-mcp-servers"]),hooks:IK(t["x-agentsmesh-hooks"]),skills:Qp(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function Os(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(n=>{r[n]===void 0&&delete r[n];}),T(r,e.trim()||"")}var il,Jc,mt=d(()=>{j();il="am-agent-",Jc="ab-agent-";s(Qp,"toStringArray");s(IK,"toHooks");s(U,"projectedAgentSkillDirName");s(Tt,"serializeProjectedAgentSkill");s(al,"parseProjectedAgentSkillFrontmatter");s(Os,"serializeImportedAgent");});function Yc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fg(t,e){return new RegExp(`${Yc(t)}[\\s\\S]*?${Yc(e)}`,"g")}function GC(t,e,r,n){let o=Fg(e,r);if(o.test(t))return t.replace(o,n).trim();let i=t.trim();return i?`${i}
19
+ Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var Jg=d(()=>{Pt();s(jC,"ownerTargetIdForSharedPath");s(xK,"findSharedArtifactOwnershipConflicts");s(UC,"assertSharedArtifactOwnersUnique");});function DK(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 V(t){return `${il}${t}`}function Ft(t){let e={name:V(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"],T(e,t.body.trim()||"")}function cu(t,e){if(t["x-agentsmesh-kind"]!=="command")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(il)?e.slice(il.length):e.startsWith(Zc)?e.slice(Zc.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:DK(t["x-agentsmesh-allowed-tools"])}:null}function mu(t,e){return T({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var il,Zc,Lt=d(()=>{K();il="am-command-",Zc="ab-command-";s(DK,"toStringArray");s(V,"commandSkillDirName");s(Ft,"serializeCommandSkill");s(cu,"parseCommandSkillFrontmatter");s(mu,"serializeImportedCommand");});function pu(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 NK(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t))Array.isArray(n)&&(e[r]=n.filter(o=>o!==null&&typeof o=="object"&&typeof o.matcher=="string"&&typeof o.command=="string"));return e}function W(t){return `${al}${t}`}function Tt(t){let e={name:W(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];}),T(e,t.body.trim()||"")}function ll(t,e){if(t["x-agentsmesh-kind"]!=="agent")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(al)?e.slice(al.length):e.startsWith(Qc)?e.slice(Qc.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:pu(t["x-agentsmesh-tools"]),disallowedTools:pu(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:pu(t["x-agentsmesh-mcp-servers"]),hooks:NK(t["x-agentsmesh-hooks"]),skills:pu(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function ws(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(n=>{r[n]===void 0&&delete r[n];}),T(r,e.trim()||"")}var al,Qc,ut=d(()=>{K();al="am-agent-",Qc="ab-agent-";s(pu,"toStringArray");s(NK,"toHooks");s(W,"projectedAgentSkillDirName");s(Tt,"serializeProjectedAgentSkill");s(ll,"parseProjectedAgentSkillFrontmatter");s(ws,"serializeImportedAgent");});function qc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yg(t,e){return new RegExp(`${qc(t)}[\\s\\S]*?${qc(e)}`,"g")}function zC(t,e,r,n){let o=Yg(e,r);if(o.test(t))return t.replace(o,n).trim();let i=t.trim();return i?`${i}
20
20
 
21
- ${n}`:n}function vg(t,e,r){return t.replace(Fg(e,r),"").trim()}function kK(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 EK(t){return {source:kK(t.source),description:t.description,globs:t.globs,targets:t.targets}}function LK(t){return `${MC}${JSON.stringify(EK(t))}${$C}`}function OK(t){let e=[LK(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),vC),e.filter(r=>r.length>0).join(`
22
- `)}function AK(t){return t.length===0?"":[qp,...t.map(OK),tu].join(`
23
- `)}function lt(t,e){let r=AK(e),n=vg(t,qp,tu);return r?n?`${n}
21
+ ${n}`:n}function Xg(t,e,r){return t.replace(Yg(e,r),"").trim()}function MK(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 $K(t){return {source:MK(t.source),description:t.description,globs:t.globs,targets:t.targets}}function GK(t){return `${WC}${JSON.stringify($K(t))}${HC}`}function jK(t){let e=[GK(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),KC),e.filter(r=>r.length>0).join(`
22
+ `)}function UK(t){return t.length===0?"":[uu,...t.map(jK),du].join(`
23
+ `)}function mt(t,e){let r=UK(e),n=Xg(t,uu,du);return r?n?`${n}
24
24
 
25
- ${r}`:r:n}function FC(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function wK(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:FC(r.globs),targets:FC(r.targets)}}catch{return null}}function bK(t,e){let r=t.trim();if(!e.trim())return r;let n=`## ${e.trim()}`;return r.startsWith(n)?r.slice(n.length).trim():r}function jC(t){let e=[],r=Fg(qp,tu);return {rootContent:t.replace(r,o=>{let i=o.replace(qp,"").replace(tu,"").trim(),a=new RegExp(`${Yc(MC)}([\\s\\S]*?)${Yc($C)}([\\s\\S]*?)${Yc(vC)}`,"g");for(let l of i.matchAll(a)){let c=l[1],m=l[2];if(c===void 0||m===void 0)continue;let p=wK(c);p&&e.push({...p,body:bK(m,p.description)});}return ""}).trim(),rules:e}}var Xc,Zc,qp,tu,vC,MC,$C,Ut=d(()=>{Xc="<!-- agentsmesh:root-generation-contract:start -->",Zc="<!-- agentsmesh:root-generation-contract:end -->",qp="<!-- agentsmesh:embedded-rules:start -->",tu="<!-- agentsmesh:embedded-rules:end -->",vC="<!-- agentsmesh:embedded-rule:end -->",MC="<!-- agentsmesh:embedded-rule:start ",$C=" -->";s(Yc,"escapeRegExp");s(Fg,"managedBlockPattern");s(GC,"replaceManagedBlock");s(vg,"stripManagedBlock");s(kK,"ruleSource");s(EK,"markerForRule");s(LK,"embeddedRuleStart");s(OK,"renderRule");s(AK,"renderEmbeddedRulesBlock");s(lt,"appendEmbeddedRulesBlock");s(FC,"toStringArray");s(wK,"parseMarker");s(bK,"stripGeneratedHeading");s(jC,"extractEmbeddedRules");});function Mg(t){return t.replace(/\s+/g," ").trim()}function BC(t){let e=t.trim();if(e.includes(Xc)&&e.includes(Zc))return GC(e,Xc,Zc,ll);let r=Mg(e);if(r.includes(Mg(ll)))return e;for(let n of UC)if(r.includes(Mg(n)))return e.replace(n,ll);return e?`${e}
25
+ ${r}`:r:n}function BC(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function BK(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:BC(r.globs),targets:BC(r.targets)}}catch{return null}}function KK(t,e){let r=t.trim();if(!e.trim())return r;let n=`## ${e.trim()}`;return r.startsWith(n)?r.slice(n.length).trim():r}function VC(t){let e=[],r=Yg(uu,du);return {rootContent:t.replace(r,o=>{let i=o.replace(uu,"").replace(du,"").trim(),a=new RegExp(`${qc(WC)}([\\s\\S]*?)${qc(HC)}([\\s\\S]*?)${qc(KC)}`,"g");for(let l of i.matchAll(a)){let c=l[1],m=l[2];if(c===void 0||m===void 0)continue;let p=BK(c);p&&e.push({...p,body:KK(m,p.description)});}return ""}).trim(),rules:e}}var tm,em,uu,du,KC,WC,HC,Kt=d(()=>{tm="<!-- agentsmesh:root-generation-contract:start -->",em="<!-- agentsmesh:root-generation-contract:end -->",uu="<!-- agentsmesh:embedded-rules:start -->",du="<!-- agentsmesh:embedded-rules:end -->",KC="<!-- agentsmesh:embedded-rule:end -->",WC="<!-- agentsmesh:embedded-rule:start ",HC=" -->";s(qc,"escapeRegExp");s(Yg,"managedBlockPattern");s(zC,"replaceManagedBlock");s(Xg,"stripManagedBlock");s(MK,"ruleSource");s($K,"markerForRule");s(GK,"embeddedRuleStart");s(jK,"renderRule");s(UK,"renderEmbeddedRulesBlock");s(mt,"appendEmbeddedRulesBlock");s(BC,"toStringArray");s(BK,"parseMarker");s(KK,"stripGeneratedHeading");s(VC,"extractEmbeddedRules");});function Zg(t){return t.replace(/\s+/g," ").trim()}function YC(t){let e=t.trim();if(e.includes(tm)&&e.includes(em))return zC(e,tm,em,cl);let r=Zg(e);if(r.includes(Zg(cl)))return e;for(let n of JC)if(r.includes(Zg(n)))return e.replace(n,cl);return e?`${e}
26
26
 
27
- ${ll}`:ll}function KC(t){let e=vg(t,Xc,Zc);e=e.replace(`
27
+ ${cl}`:cl}function XC(t){let e=Xg(t,tm,em);e=e.replace(`
28
28
 
29
- ${ll}`,"");for(let r of UC)e=e.replace(`
29
+ ${cl}`,"");for(let r of JC)e=e.replace(`
30
30
 
31
- ${r}`,"");return e.trim()}var $g,PK,TK,xK,DK,NK,FK,vK,MK,$K,GK,jK,UK,BK,KK,WK,HK,ll,UC,Gg=d(()=>{Ut();$g="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.",PK="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.",TK="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.",xK="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.",DK="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`.",NK="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`.",FK="`.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`.",vK="`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.",MK=$g,$K=`## Project-Specific Rules
31
+ ${r}`,"");return e.trim()}var Qg,WK,HK,zK,VK,JK,YK,XK,ZK,QK,qK,tW,eW,rW,nW,oW,sW,iW,aW,cl,JC,qg=d(()=>{Kt();Qg="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.",WK="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.",HK="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.",zK="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.",VK="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`.",JK="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`.",YK="`.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`.",XK="`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.",ZK="`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`, `merge`, and `refresh` as needed; never edit generated tool files.",QK=Qg,qK=`## Project-Specific Rules
32
32
 
33
- ${$g}`,GK=`## AgentsMesh Generation Contract
33
+ ${Qg}`,tW=`## AgentsMesh Generation Contract
34
34
 
35
- ${$g}`,jK=`## AgentsMesh Generation Contract
35
+ ${Qg}`,eW=`## AgentsMesh Generation Contract
36
36
 
37
- ${PK}`,UK=`## AgentsMesh Generation Contract
37
+ ${WK}`,rW=`## AgentsMesh Generation Contract
38
38
 
39
- ${TK}`,BK=`## AgentsMesh Generation Contract
39
+ ${HK}`,nW=`## AgentsMesh Generation Contract
40
40
 
41
- ${xK}`,KK=`## AgentsMesh Generation Contract
41
+ ${zK}`,oW=`## AgentsMesh Generation Contract
42
42
 
43
- ${DK}`,WK=`## AgentsMesh Generation Contract
43
+ ${VK}`,sW=`## AgentsMesh Generation Contract
44
44
 
45
- ${NK}`,HK=`## AgentsMesh Generation Contract
45
+ ${JK}`,iW=`## AgentsMesh Generation Contract
46
46
 
47
- ${FK}`,ll=`${Xc}
47
+ ${YK}`,aW=`## AgentsMesh Generation Contract
48
+
49
+ ${XK}`,cl=`${tm}
48
50
  ## AgentsMesh Generation Contract
49
51
 
50
- ${vK}
51
- ${Zc}`;s(Mg,"normalizeWhitespace");UC=[HK,WK,KK,BK,UK,jK,GK,$K,MK];s(BC,"appendAgentsmeshRootInstructionParagraph");s(KC,"stripAgentsmeshRootInstructionParagraph");});function ye(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 cl(t){let e=await _(t);return e?b(e).frontmatter:{}}function Xt(t,e){return typeof t[e]=="string"?t[e]:void 0}function jg(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function zK(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function VK(t,e){let r=basename(t,".md")==="_root",n={...e};return delete n.root,{root:r,...n}}async function K(t,e,r){let n=await cl(t),o=basename(t,".md")==="_root"?KC(r):r.trim(),i=VK(t,zK({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=ye(i.globs));for(let[l,c]of Object.entries(i))l==="root"||l==="description"||l==="globs"||c===void 0||(a[l]=c);return T(a,o||"")}var Ug=d(()=>{w();j();Gg();s(ye,"toStringArray");s(cl,"readExistingFrontmatter");s(Xt,"readString");s(jg,"readHooks");s(zK,"pruneUndefined");s(VK,"serializeCanonicalRuleFrontmatter");s(K,"serializeImportedRuleWithFallback");});async function _t(t,e,r){let n=await cl(t),o=(()=>{let l=ye(n.allowedTools);return l.length>0?l:ye(n["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return T({description:i,"allowed-tools":a},r.trim()||"")}async function Cn(t,e,r){let n=await cl(t),o=basename(dirname(t)),i=Xt(e,"name")??Xt(n,"name")??o,a=Xt(e,"description")??Xt(n,"description")??"";return T({name:i,description:a},r.trim()||"")}async function Vt(t,e,r){let n=await cl(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?ye(e.tools):(()=>{let R=ye(n.tools);return R.length>0?R:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?ye(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?ye(e["disallowed-tools"]):ye(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?ye(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?ye(e["mcp-servers"]):ye(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?ye(e.skills):ye(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=jg(e)??jg(n),u={name:Xt(e,"name")??Xt(n,"name")??basename(t,".md"),description:Xt(e,"description")??Xt(n,"description")??"",tools:o};i.length>0&&(u.disallowedTools=i);let f=Xt(e,"model")??Xt(n,"model");f&&(u.model=f);let g=Xt(e,"permissionMode")??Xt(e,"permission-mode")??Xt(n,"permissionMode")??Xt(n,"permission-mode");g&&(u.permissionMode=g),Number.isInteger(m)&&m>0&&(u.maxTurns=m),a.length>0&&(u.mcpServers=a),p&&Object.keys(p).length>0&&(u.hooks=p),l.length>0&&(u.skills=l);let h=Xt(e,"memory")??Xt(n,"memory");return h&&(u.memory=h),T(u,r.trim()||"")}var zC=d(()=>{j();Ug();s(_t,"serializeImportedCommandWithFallback");s(Cn,"serializeImportedSkillWithFallback");s(Vt,"serializeImportedAgentWithFallback");});var ut=d(()=>{Ug();zC();});function eu(t){let e=t.split("/").filter(Boolean);return e.length===0||e.some(n=>n.startsWith("."))?false:!e.join("/").startsWith("tests/e2e/fixtures/")}async function kn(t){await rm(t,{recursive:true,force:true});}var Qc=d(()=>{s(eu,"shouldImportScopedAgentsRule");s(kn,"removePathIfExists");});function rt(t,e){let r=[];for(let n of t.skills){let o={name:n.name,description:n.description||void 0};o.description===void 0&&delete o.description,r.push({path:`${e}/${n.name}/SKILL.md`,content:T(o,n.body.trim()||"")});for(let i of n.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");r.push({path:`${e}/${n.name}/${a}`,content:i.content});}}return r}async function q(t,e,r,n,o){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 l=join(t,e,a.name),c=join(l,"SKILL.md"),m=await _(c);if(m===null)continue;let p=join(t,qc,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=b(o(m,c,u)),h=Xp(f,a.name);if(h){await kn(join(t,qc,a.name));let k=join(t,VC);await O(k);let P=join(k,`${h.name}.md`);await I(P,Zp(h,o(g,c,P))),n.push({fromTool:r,fromPath:c,toPath:`${VC}/${h.name}.md`,feature:"commands"});continue}let R=al(f,a.name);if(R){await kn(join(t,qc,a.name));let k=join(t,JC);await O(k);let P=join(k,`${R.name}.md`);await I(P,Os(R,o(g,c,P))),n.push({fromTool:r,fromPath:c,toPath:`${JC}/${R.name}.md`,feature:"agents"});continue}let C=await Cn(u,{...f,name:a.name},g);await O(p),await I(u,C),n.push({fromTool:r,fromPath:c,toPath:`${qc}/${a.name}/SKILL.md`,feature:"skills"});let S=await v(l);for(let k of S){if(k===c)continue;let P=relative(l,k).replace(/\\/g,"/"),N=await _(k);if(N===null)continue;let F=join(p,P);await O(dirname(F)),await I(F,o(N,k,F)),n.push({fromTool:r,fromPath:k,toPath:`${qc}/${a.name}/${P}`,feature:"skills"});}}}var qc,VC,JC,tt=d(()=>{w();j();ut();mt();kt();Qc();qc=".agentsmesh/skills",VC=".agentsmesh/commands",JC=".agentsmesh/agents";s(rt,"generateEmbeddedSkills");s(q,"importEmbeddedSkills");});var En,er,ie,Oo,Ao,rr,bi,YC,XC,ml=d(()=>{En="aider",er="CONVENTIONS.md",ie=".aider/skills",Oo=".aiderignore",Ao="CONVENTIONS.md",rr=".aider/skills",bi=".aiderignore",YC=".agentsmesh/rules",XC=".agentsmesh/ignore";});function ZC(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(En)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:er,content:o}]:[]}function QC(t){return rt(t,ie)}function qC(t){return t.commands.map(e=>({path:`${ie}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function tk(t){return t.agents.map(e=>({path:`${ie}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function ek(t){return t.ignore.length===0?[]:[{path:Oo,content:t.ignore.join(`
52
- `)}]}var rk=d(()=>{tt();Ut();mt();kt();ml();s(ZC,"generateRules");s(QC,"generateSkills");s(qC,"generateCommands");s(tk,"generateAgents");s(ek,"generateIgnore");});function nt(t){return t.includes("\\")||jr.test(t)?win32:posix}function vt(t){return t.replace(/\\/g,"/")}function Y(t,e){let r=nt(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):vt(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function ok(t,e){return nt(t).isAbsolute(e)||jr.test(e)}function pl(t){let e=t,r="";for(;tW.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function sk(t,e){let r=nt(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?Y(e,r.join(e,n)):null}var jr,tW,ae=d(()=>{jr=/^[A-Za-z]:[\\/]/,tW=/[.!?:;]+$/;s(nt,"pathApi");s(vt,"normalizeSeparators");s(Y,"normalizeForProject");s(ok,"isAbsoluteForProject");s(pl,"stripTrailingPunctuation");s(sk,"rootFallbackPath");});async function ik(t,e,r="project"){let n=new Map,o=et(t);return o&&await o.buildImportPaths(n,e,r),n}var ak=d(()=>{se();s(ik,"buildImportReferenceMap");});function nW(t){let e=[t.project,t.globalSupport?.layout].filter(o=>o!==void 0),r=[...t.detectionPaths,...e.flatMap(o=>o.managedOutputs?.dirs??[]),...e.flatMap(o=>o.managedOutputs?.files??[])],n=new Set;for(let o of r){let i=o.split("/")[0];i&&i.startsWith(".")&&i.length>1&&n.add(`${i}/`);}return n}function oW(){let t=new Set([".agentsmesh/"]);for(let e of bt)for(let r of nW(e))t.add(r);return Array.from(t)}function sW(){let t=new Set([...oW(),...Bg.rootRelativePrefixes]),e=new Set([...rW,...Bg.meshRootSegments]);return {protectedSchemes:[...eW,...Bg.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function ru(){return Kg||(Kg=sW()),Kg}var eW,rW,Bg,Kg,lk=d(()=>{Pt();eW=[/\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],rW=new Set(["skills","rules","commands","agents","packs"]),Bg={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(nW,"topLevelDotfilePrefixes");s(oW,"buildDefaultRootRelativePrefixes");s(sW,"rebuild");s(ru,"getLinkFormatRegistry");});function Ur(t){let e=vt(t);return ru().rootRelativePrefixes.some(r=>e.startsWith(r))}function aW(t){let e=vt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||jr.test(e)||/^[a-zA-Z]:/.test(e)||Ur(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&ru().meshRootSegments.has(r)}function tm(t,e,r){let n=nt(e),o=Y(e,e),i=Y(e,r),a=vt(t);if(jr.test(t)){let l=Y(e,t);return n===win32||l.startsWith(`${o}${n.sep}`)?[l]:[l]}if(n.isAbsolute(t)){let l=Y(e,t);return l.startsWith(o)||existsSync(t)?[l]:[Y(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let l=Y(e,n.join(n.dirname(i),a)),c=sk(a,o);return c&&c!==l?[l,c]:[l]}if(Ur(a))return [Y(e,n.join(o,a))];if(a.includes("/")){let l=Y(e,n.join(o,".agentsmesh")),c=aW(a)?Y(e,n.join(l,a)):null,m=Y(e,n.join(o,a)),p=Y(e,n.join(n.dirname(i),a));return c!==null?[c,m,p]:[m,p]}return lW.has(a)?[]:a.includes(".")?[Y(e,n.join(n.dirname(i),a))]:[]}function em(t,e){let r=[e];if(!ok(t,e)||!existsSync(e))return r;try{let n=[realpathSync(e),realpathSync.native(e)];for(let o of n)o!==e&&!r.includes(o)&&r.push(o);}catch{}return r}function uk(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function nu(t){let e=[];for(let r of ru().protectedSchemes){let n=r.flags.includes("g")?r:new RegExp(r.source,`${r.flags}g`);for(let o of t.matchAll(n))e.push([o.index??0,(o.index??0)+o[0].length]);}for(let r of t.matchAll(cW))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(mW))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(pW))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var lW,cW,mW,pW,pk,ul,As=d(()=>{ae();lk();s(Ur,"isRootRelativePathToken");s(aW,"isMeshRootRelativePathToken");lW=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),cW=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,mW=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,pW=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,pk=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,ul=/(?::(\d+)){1,2}$/;s(tm,"resolveProjectPath");s(em,"expandResolvedPaths");s(uk,"isGlobAdjacent");s(nu,"protectedRanges");});function uW(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 dk(t){return uW(t.tokenContext)}function Wg(t,e){let r=nt(t),n=Y(t,t),o=Y(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function fk(t){let e=nt(t);return Y(t,e.join(t,".agentsmesh"))}function Br(t,e){let r=nt(t),n=fk(t),o=Y(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function gk(t,e,r){let n=nt(t),o=fk(t),i=Y(t,e);if(!Br(t,i))return null;let a=n.relative(o,i).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function Hg(t,e,r){let o=nt(t).relative(Y(t,t),Y(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let i=o.length>0?o:".";return r&&!i.endsWith("/")?`${i}/`:i}function dl(t,e,r){let n=Hg(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function zg(t,e,r,n,o){let i=nt(t),a=Y(t,t),l=Y(t,e),c=Y(t,r);if(!Wg(t,c))return dl(t,c,n)?.text??null;let m=Y(t,i.dirname(l));if(!Wg(t,m)&&m!==a)return dl(t,c,n)?.text??null;let p=i.relative(m,c).replace(/\\/g,"/");if(i.isAbsolute(p)||jr.test(p))return Hg(t,c,n);let u=Y(t,i.join(m,p));return Wg(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):Hg(t,c,n)}var Vg=d(()=>{ae();s(uW,"isReadingContext");s(dk,"isReadingContextOptions");s(Wg,"isUnderProjectRoot");s(fk,"agentsMeshRoot");s(Br,"isUnderAgentsMesh");s(gk,"toAgentsMeshRootRelative");s(Hg,"toProjectRootRelative");s(dl,"toProjectRootReference");s(zg,"formatLinkPathForDestinationLegacy");});function hk(t,e,r,n,o={}){let i=o.scope??"project",a=Y(t,r);if(dk(o)&&Br(t,e)&&Br(t,a)){let m=nt(t),p=Y(t,t),u=m.relative(p,a).replace(/\\/g,"/");if(!u.startsWith("..")&&u.length>0)return n&&!u.endsWith("/")?`${u}/`:u}if(o.forceRelative)return zg(t,e,r,n,o);if(i==="global"&&!Br(t,e))return dl(t,a,n)?.text??null;let l=(()=>{if(Br(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&Br(t,Y(t,m))?Y(t,m):null})();if(!l)return dl(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=gk(t,l,n);return m!==null?m:dl(t,l,n)?.text??null}return zg(t,e,r,n,o)}var yk=d(()=>{As();ae();Vg();Vg();s(hk,"formatLinkPathForDestination");});function _k(t,e,r,n){let o=nt(e),i=vt(t);if(!Ur(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let l=Y(e,r),c=o.dirname(l);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=Y(e,o.join(c,p));if(u!==l&&n(u))return u}return null}var Rk=d(()=>{ae();As();s(_k,"resolveByDestinationSuffixStrip");});function Ik(t){let e=null,r=false,n=null,o=null,i=null;for(let c of tm(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of em(t.projectRoot,c)){let f=Y(t.projectRoot,u),g=Y(t.projectRoot,t.translatePath(f)),h=t.pathExists(f),R=t.pathExists(g);if(R&&g!==f){e=g,n=f,r=true;break}(h||R)&&m===null&&(m=g,p=f),e===null&&(e=g);}if(!r&&m!==null&&o===null&&(o=m,i=p),r)break}if(!r){let c=_k(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);c!==null&&(e=c,r=true);}!r&&o!==null&&(e=o,i!==null&&(n=i),r=true);let a=vt(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&vt(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var Sk=d(()=>{ae();As();Rk();s(Ik,"resolveLinkTarget");});function Ck(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function kk(t,e,r){if(e<=0||t[e-1]!=="(")return false;let n=e+r.length,o=t[n];return o!==")"&&o!=="#"&&o!=="?"&&o!==" "&&o!==" "?false:t[e-2]==="]"}function Ek(t){let e=vt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||jr.test(e)||Ur(e)?false:e.includes("/")}var Lk=d(()=>{ae();As();s(Ck,"isTildeHomeRelativePathToken");s(kk,"isMarkdownLinkDestinationToken");s(Ek,"isRelativePathToken");});function dW(t,e,r){let n=e+r.length;if(t[n]!=="]"||t[n+1]!=="(")return false;let o=n+2,i="";for(;o<t.length;){let a=t[o];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
53
- `)break;i+=a,o++;}return i===r}function Ok(t,e,r){let n=t.lastIndexOf(`
52
+ ${ZK}
53
+ ${em}`;s(Zg,"normalizeWhitespace");JC=[aW,iW,sW,oW,nW,rW,eW,tW,qK,QK];s(YC,"appendAgentsmeshRootInstructionParagraph");s(XC,"stripAgentsmeshRootInstructionParagraph");});function _e(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 ml(t){let e=await _(t);return e?b(e).frontmatter:{}}function Qt(t,e){return typeof t[e]=="string"?t[e]:void 0}function th(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function lW(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function cW(t,e){let r=basename(t,".md")==="_root",n={...e};return delete n.root,{root:r,...n}}async function z(t,e,r){let n=await ml(t),o=basename(t,".md")==="_root"?XC(r):r.trim(),i=cW(t,lW({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=_e(i.globs));for(let[l,c]of Object.entries(i))l==="root"||l==="description"||l==="globs"||c===void 0||(a[l]=c);return T(a,o||"")}var eh=d(()=>{A();K();qg();s(_e,"toStringArray");s(ml,"readExistingFrontmatter");s(Qt,"readString");s(th,"readHooks");s(lW,"pruneUndefined");s(cW,"serializeCanonicalRuleFrontmatter");s(z,"serializeImportedRuleWithFallback");});async function It(t,e,r){let n=await ml(t),o=(()=>{let l=_e(n.allowedTools);return l.length>0?l:_e(n["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return T({description:i,"allowed-tools":a},r.trim()||"")}async function En(t,e,r){let n=await ml(t),o=basename(dirname(t)),i=Qt(e,"name")??Qt(n,"name")??o,a=Qt(e,"description")??Qt(n,"description")??"";return T({name:i,description:a},r.trim()||"")}async function Jt(t,e,r){let n=await ml(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?_e(e.tools):(()=>{let I=_e(n.tools);return I.length>0?I:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?_e(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?_e(e["disallowed-tools"]):_e(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?_e(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?_e(e["mcp-servers"]):_e(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?_e(e.skills):_e(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=th(e)??th(n),u={name:Qt(e,"name")??Qt(n,"name")??basename(t,".md"),description:Qt(e,"description")??Qt(n,"description")??"",tools:o};i.length>0&&(u.disallowedTools=i);let f=Qt(e,"model")??Qt(n,"model");f&&(u.model=f);let g=Qt(e,"permissionMode")??Qt(e,"permission-mode")??Qt(n,"permissionMode")??Qt(n,"permission-mode");g&&(u.permissionMode=g),Number.isInteger(m)&&m>0&&(u.maxTurns=m),a.length>0&&(u.mcpServers=a),p&&Object.keys(p).length>0&&(u.hooks=p),l.length>0&&(u.skills=l);let h=Qt(e,"memory")??Qt(n,"memory");return h&&(u.memory=h),T(u,r.trim()||"")}var qC=d(()=>{K();eh();s(It,"serializeImportedCommandWithFallback");s(En,"serializeImportedSkillWithFallback");s(Jt,"serializeImportedAgentWithFallback");});var ft=d(()=>{eh();qC();});function fu(t){let e=t.split("/").filter(Boolean);return e.length===0||e.some(n=>n.startsWith("."))?false:!e.join("/").startsWith("tests/e2e/fixtures/")}async function Ln(t){await rm$1(t,{recursive:true,force:true});}var rm=d(()=>{s(fu,"shouldImportScopedAgentsRule");s(Ln,"removePathIfExists");});function it(t,e){let r=[];for(let n of t.skills){let o={name:n.name,description:n.description||void 0};o.description===void 0&&delete o.description,r.push({path:`${e}/${n.name}/SKILL.md`,content:T(o,n.body.trim()||"")});for(let i of n.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");r.push({path:`${e}/${n.name}/${a}`,content:i.content});}}return r}async function et(t,e,r,n,o){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 l=join(t,e,a.name),c=join(l,"SKILL.md"),m=await _(c);if(m===null)continue;let p=join(t,nm,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=b(o(m,c,u)),h=cu(f,a.name);if(h){await Ln(join(t,nm,a.name));let R=join(t,tk);await O(R);let P=join(R,`${h.name}.md`);await S(P,mu(h,o(g,c,P))),n.push({fromTool:r,fromPath:c,toPath:`${tk}/${h.name}.md`,feature:"commands"});continue}let I=ll(f,a.name);if(I){await Ln(join(t,nm,a.name));let R=join(t,ek);await O(R);let P=join(R,`${I.name}.md`);await S(P,ws(I,o(g,c,P))),n.push({fromTool:r,fromPath:c,toPath:`${ek}/${I.name}.md`,feature:"agents"});continue}let k=await En(u,{...f,name:a.name},g);await O(p),await S(u,k),n.push({fromTool:r,fromPath:c,toPath:`${nm}/${a.name}/SKILL.md`,feature:"skills"});let C=await $(l);for(let R of C){if(R===c)continue;let P=relative(l,R).replace(/\\/g,"/"),N=await _(R);if(N===null)continue;let F=join(p,P);await O(dirname(F)),await S(F,o(N,R,F)),n.push({fromTool:r,fromPath:R,toPath:`${nm}/${a.name}/${P}`,feature:"skills"});}}}var nm,tk,ek,rt=d(()=>{A();K();ft();ut();Lt();rm();nm=".agentsmesh/skills",tk=".agentsmesh/commands",ek=".agentsmesh/agents";s(it,"generateEmbeddedSkills");s(et,"importEmbeddedSkills");});var On,ir,le,Ao,bo,ar,Ti,rk,nk,pl=d(()=>{On="aider",ir="CONVENTIONS.md",le=".aider/skills",Ao=".aiderignore",bo="CONVENTIONS.md",ar=".aider/skills",Ti=".aiderignore",rk=".agentsmesh/rules",nk=".agentsmesh/ignore";});function ok(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(On)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:ir,content:o}]:[]}function sk(t){return it(t,le)}function ik(t){return t.commands.map(e=>({path:`${le}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function ak(t){return t.agents.map(e=>({path:`${le}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function lk(t){return t.ignore.length===0?[]:[{path:Ao,content:t.ignore.join(`
54
+ `)}]}var ck=d(()=>{rt();Kt();ut();Lt();pl();s(ok,"generateRules");s(sk,"generateSkills");s(ik,"generateCommands");s(ak,"generateAgents");s(lk,"generateIgnore");});function at(t){return t.includes("\\")||Wr.test(t)?win32:posix}function Mt(t){return t.replace(/\\/g,"/")}function X(t,e){let r=at(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):Mt(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function pk(t,e){return at(t).isAbsolute(e)||Wr.test(e)}function ul(t){let e=t,r="";for(;hW.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function uk(t,e){let r=at(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?X(e,r.join(e,n)):null}var Wr,hW,ce=d(()=>{Wr=/^[A-Za-z]:[\\/]/,hW=/[.!?:;]+$/;s(at,"pathApi");s(Mt,"normalizeSeparators");s(X,"normalizeForProject");s(pk,"isAbsoluteForProject");s(ul,"stripTrailingPunctuation");s(uk,"rootFallbackPath");});async function dk(t,e,r="project"){let n=new Map,o=ot(t);return o&&await o.buildImportPaths(n,e,r),n}var fk=d(()=>{ae();s(dk,"buildImportReferenceMap");});function RW(t){let e=[t.project,t.globalSupport?.layout].filter(o=>o!==void 0),r=[...t.detectionPaths,...e.flatMap(o=>o.managedOutputs?.dirs??[]),...e.flatMap(o=>o.managedOutputs?.files??[])],n=new Set;for(let o of r){let i=o.split("/")[0];i&&i.startsWith(".")&&i.length>1&&n.add(`${i}/`);}return n}function IW(){let t=new Set([".agentsmesh/"]);for(let e of bt)for(let r of RW(e))t.add(r);return Array.from(t)}function SW(){let t=new Set([...IW(),...rh.rootRelativePrefixes]),e=new Set([..._W,...rh.meshRootSegments]);return {protectedSchemes:[...yW,...rh.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function gu(){return nh||(nh=SW()),nh}var yW,_W,rh,nh,gk=d(()=>{Pt();yW=[/\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],_W=new Set(["skills","rules","commands","agents","packs"]),rh={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(RW,"topLevelDotfilePrefixes");s(IW,"buildDefaultRootRelativePrefixes");s(SW,"rebuild");s(gu,"getLinkFormatRegistry");});function Hr(t){let e=Mt(t);return gu().rootRelativePrefixes.some(r=>e.startsWith(r))}function kW(t){let e=Mt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Wr.test(e)||/^[a-zA-Z]:/.test(e)||Hr(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&gu().meshRootSegments.has(r)}function om(t,e,r){let n=at(e),o=X(e,e),i=X(e,r),a=Mt(t);if(Wr.test(t)){let l=X(e,t);return n===win32||l.startsWith(`${o}${n.sep}`)?[l]:[l]}if(n.isAbsolute(t)){let l=X(e,t);return l.startsWith(o)||existsSync(t)?[l]:[X(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let l=X(e,n.join(n.dirname(i),a)),c=uk(a,o);return c&&c!==l?[l,c]:[l]}if(Hr(a))return [X(e,n.join(o,a))];if(a.includes("/")){let l=X(e,n.join(o,".agentsmesh")),c=kW(a)?X(e,n.join(l,a)):null,m=X(e,n.join(o,a)),p=X(e,n.join(n.dirname(i),a));return c!==null?[c,m,p]:[m,p]}return EW.has(a)?[]:a.includes(".")?[X(e,n.join(n.dirname(i),a))]:[]}function sm(t,e){let r=[e];if(!pk(t,e)||!existsSync(e))return r;try{let n=[realpathSync(e),realpathSync.native(e)];for(let o of n)o!==e&&!r.includes(o)&&r.push(o);}catch{}return r}function Rk(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function hu(t){let e=[];for(let r of gu().protectedSchemes){let n=r.flags.includes("g")?r:new RegExp(r.source,`${r.flags}g`);for(let o of t.matchAll(n))e.push([o.index??0,(o.index??0)+o[0].length]);}for(let r of t.matchAll(LW))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(OW))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(wW))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var EW,LW,OW,wW,_k,dl,As=d(()=>{ce();gk();s(Hr,"isRootRelativePathToken");s(kW,"isMeshRootRelativePathToken");EW=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),LW=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,OW=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,wW=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,_k=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,dl=/(?::(\d+)){1,2}$/;s(om,"resolveProjectPath");s(sm,"expandResolvedPaths");s(Rk,"isGlobAdjacent");s(hu,"protectedRanges");});function AW(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 Ik(t){return AW(t.tokenContext)}function oh(t,e){let r=at(t),n=X(t,t),o=X(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function Sk(t){let e=at(t);return X(t,e.join(t,".agentsmesh"))}function zr(t,e){let r=at(t),n=Sk(t),o=X(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function Ck(t,e,r){let n=at(t),o=Sk(t),i=X(t,e);if(!zr(t,i))return null;let a=n.relative(o,i).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function sh(t,e,r){let o=at(t).relative(X(t,t),X(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let i=o.length>0?o:".";return r&&!i.endsWith("/")?`${i}/`:i}function fl(t,e,r){let n=sh(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function ih(t,e,r,n,o){let i=at(t),a=X(t,t),l=X(t,e),c=X(t,r);if(!oh(t,c))return fl(t,c,n)?.text??null;let m=X(t,i.dirname(l));if(!oh(t,m)&&m!==a)return fl(t,c,n)?.text??null;let p=i.relative(m,c).replace(/\\/g,"/");if(i.isAbsolute(p)||Wr.test(p))return sh(t,c,n);let u=X(t,i.join(m,p));return oh(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):sh(t,c,n)}var ah=d(()=>{ce();s(AW,"isReadingContext");s(Ik,"isReadingContextOptions");s(oh,"isUnderProjectRoot");s(Sk,"agentsMeshRoot");s(zr,"isUnderAgentsMesh");s(Ck,"toAgentsMeshRootRelative");s(sh,"toProjectRootRelative");s(fl,"toProjectRootReference");s(ih,"formatLinkPathForDestinationLegacy");});function kk(t,e,r,n,o={}){let i=o.scope??"project",a=X(t,r);if(Ik(o)&&zr(t,e)&&zr(t,a)){let m=at(t),p=X(t,t),u=m.relative(p,a).replace(/\\/g,"/");if(!u.startsWith("..")&&u.length>0)return n&&!u.endsWith("/")?`${u}/`:u}if(o.forceRelative)return ih(t,e,r,n,o);if(i==="global"&&!zr(t,e))return fl(t,a,n)?.text??null;let l=(()=>{if(zr(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&zr(t,X(t,m))?X(t,m):null})();if(!l)return fl(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=Ck(t,l,n);return m!==null?m:fl(t,l,n)?.text??null}return ih(t,e,r,n,o)}var Ek=d(()=>{As();ce();ah();ah();s(kk,"formatLinkPathForDestination");});function Lk(t,e,r,n){let o=at(e),i=Mt(t);if(!Hr(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let l=X(e,r),c=o.dirname(l);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=X(e,o.join(c,p));if(u!==l&&n(u))return u}return null}var Ok=d(()=>{ce();As();s(Lk,"resolveByDestinationSuffixStrip");});function wk(t){let e=null,r=false,n=null,o=null,i=null;for(let c of om(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of sm(t.projectRoot,c)){let f=X(t.projectRoot,u),g=X(t.projectRoot,t.translatePath(f)),h=t.pathExists(f),I=t.pathExists(g);if(I&&g!==f){e=g,n=f,r=true;break}(h||I)&&m===null&&(m=g,p=f),e===null&&(e=g);}if(!r&&m!==null&&o===null&&(o=m,i=p),r)break}if(!r){let c=Lk(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);c!==null&&(e=c,r=true);}!r&&o!==null&&(e=o,i!==null&&(n=i),r=true);let a=Mt(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&Mt(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var Ak=d(()=>{ce();As();Ok();s(wk,"resolveLinkTarget");});function bk(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function Pk(t,e,r){if(e<=0||t[e-1]!=="(")return false;let n=e+r.length,o=t[n];return o!==")"&&o!=="#"&&o!=="?"&&o!==" "&&o!==" "?false:t[e-2]==="]"}function Tk(t){let e=Mt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Wr.test(e)||Hr(e)?false:e.includes("/")}var xk=d(()=>{ce();As();s(bk,"isTildeHomeRelativePathToken");s(Pk,"isMarkdownLinkDestinationToken");s(Tk,"isRelativePathToken");});function bW(t,e,r){let n=e+r.length;if(t[n]!=="]"||t[n+1]!=="(")return false;let o=n+2,i="";for(;o<t.length;){let a=t[o];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
55
+ `)break;i+=a,o++;}return i===r}function Dk(t,e,r){let n=t.lastIndexOf(`
54
56
  `,e-1)+1,o=t.slice(n,e);if(!/^\s*\[[^\]\n]+\]:\s*<?\s*$/.test(o))return false;let i=r<t.length?t[r]:"";return i===""||i===`
55
- `||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function Ak(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:Ok(t,e,r)?{role:"markdown-link-dest"}:n==="<"&&o===">"?{role:"bracketed"}:n==="'"&&o==="'"||n==='"'&&o==='"'?{role:"quoted"}:n==="@"?{role:"at-prefix"}:n==="("&&t[e-2]==="]"?{role:"markdown-link-dest"}:n==="["&&o==="]"?{role:"bracket-label"}:{role:"bare-prose"}}function wk(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=pl(n),a=i.replace(ul,""),l=vt(a),c=e+a.length,m=t[e-1],p=t[r];return Ok(t,e,c)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!Ur(l)&&dW(t,e,n)):m==="@"?true:m==="("&&t[e-2]==="]"?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?Ur(l)?true:l.includes("/")||l.includes("\\")?l.startsWith("./")||l.startsWith("../")?true:(l.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var bk=d(()=>{ae();As();s(dW,"markdownBracketLabelDuplicatesDestination");s(Ok,"isMarkdownReferenceDefinitionDestination");s(Ak,"getTokenContext");s(wk,"shouldRewritePathToken");});function ou(t){let e=new Set,r=nu(t.content);return {content:t.content.replace(pk,(o,i,a)=>{if(r.some(([Dt,Ze])=>i>=Dt&&i<Ze)||!wk(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||Ck(a,i,o)||uk(a,i,i+o.length))return o;let{candidate:l,suffix:c}=pl(o);if(!l)return o;let m=ul.exec(l),p=m?l.slice(0,m.index):l,u=m?m[0]:"";if(!p)return o;let f=Ak(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&jr.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:R}=Ik({candidate:p,rawToken:l,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),C=h;if(!R||!g)return g&&e.add(g),o;let S=vt(p),k=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(k&&!S.includes("/")&&!S.includes("\\"))return o;if(C===null){let Dt=vt(l);if(Dt.startsWith("agentsmesh/")&&(Dt=`.${Dt}`),Dt.startsWith(".agentsmesh/")||Dt.includes("/.agentsmesh/")){let Ze=nt(t.projectRoot),ja=Y(t.projectRoot,t.projectRoot),Ua=Dt.replace(/^\.\//,"");C=Y(t.projectRoot,Ze.join(ja,Ua));}}let P=nt(t.projectRoot);if(t.scope==="global"){let Dt=vt(l),Ze=Dt.startsWith(".agentsmesh/")||Dt.includes("/.agentsmesh/"),ja=Ur(Dt)||Ek(Dt),Ua=C!==null&&Br(t.projectRoot,C),Dc=Br(t.projectRoot,g);if(C===g&&!Dc&&!Ua&&!Ze){let Ba=vt(P.relative(t.projectRoot,Y(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",g0=(C!==null?vt(P.relative(t.projectRoot,C)):"").split("/").filter(Boolean)[0]??"";if(Ba.length>0&&Ba===g0)return o}if(!ja&&!Ze&&!Ua&&!Dc)return o}let N=Y(t.projectRoot,t.destinationFile),F=Y(t.projectRoot,g),W=vt(P.relative(t.projectRoot,N)),z=vt(P.relative(t.projectRoot,F)),Q=W.split("/").filter(Boolean)[0]??"",at=z.split("/").filter(Boolean)[0]??"",oe=!vt(p).startsWith(".agentsmesh/")&&!k&&Q.length>0&&Q===at&&Q.startsWith(".")&&Q!==".agentsmesh"||f.role==="markdown-link-dest"||kk(a,i,p),Dr=hk(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||oe,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:k?null:C,forceRelative:oe,tokenContext:f,originalToken:p});return Dr?`${Dr}${u}${c}`:o}),missing:[...e]}}var Jg=d(()=>{ae();As();yk();Sk();Lk();bk();s(ou,"rewriteFileLinks");});function Tk(t,e){let r=[t.normalize(e)];if(!existsSync(e))return r;try{let n=[realpathSync(e),realpathSync.native(e)];for(let o of n){let i=t.normalize(o);r.includes(i)||r.push(i);}}catch{}return r}async function B(t,e,r="project"){let n=nt(e),o=new Map,i=Array.from(new Set([t,...Ft]));for(let c of i){let m=await ik(c,e,r);for(let[p,u]of m.entries())o.set(p,u);}let a=new Map;for(let[c,m]of o.entries()){let p=n.normalize(n.join(e,m));for(let u of Tk(n,n.join(e,c)))a.set(u,p);}let l=new Set;for(let c of new Set(o.values())){let m=n.normalize(n.join(e,c));l.add(m);for(let p of Tk(n,m))l.add(n.normalize(p));}return (c,m,p)=>ou({content:c,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:s(u=>a.get(u)??u,"translatePath"),pathExists:s(u=>{let f=n.normalize(u);return a.has(u)||a.has(f)||existsSync(u)||l.has(f)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:s(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var dt=d(()=>{ae();ak();Jg();Rn();s(Tk,"pathVariants");s(B,"createImportReferenceNormalizer");});async function Bt(t,e,r){let n=join(t,e),i={...await yW(n),...r};await O(dirname(n)),await I(n,JSON.stringify({mcpServers:i},null,2));}async function yW(t){let e=await _(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let n=r.mcpServers;if(!n||typeof n!="object"||Array.isArray(n))return {};let o={};for(let[i,a]of Object.entries(n))!a||typeof a!="object"||Array.isArray(a)||(o[i]=a);return o}var Kr=d(()=>{w();s(Bt,"writeMcpWithMerge");s(yW,"readExistingServers");});function wo(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function nr(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 ws(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function Ln(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var or=d(()=>{s(wo,"toGlobsArray");s(nr,"toToolsArray");s(ws,"toStringArray");s(Ln,"toStringRecord");});function IW(t,e){return e.some(r=>t.endsWith(r))}async function Rt(t){let r=(await v(t.srcDir)).filter(o=>IW(o,t.extensions)),n=[];for(let o of r){let i=await _(o);if(!i)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),l=await t.mapEntry({srcPath:o,relativePath:a,content:i,normalizeTo:s((c,m=i)=>t.normalize(m,o,c),"normalizeTo")});l&&(await O(dirname(l.destPath)),await I(l.destPath,l.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:l.toPath,feature:l.feature}));}return n}var xe=d(()=>{w();s(IW,"matchesExtension");s(Rt,"importFileDirectory");});function Dk(t){return typeof t=="string"?t:void 0}function SW(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 CW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=b(e.normalizeTo(r)),i=Xg(n,t.frontmatterRemap),a=SW({root:false,description:Dk(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,o)}}}function kW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=b(e.normalizeTo(r)),i=Xg(n,t.frontmatterRemap),a=await _t(r,{hasDescription:true,description:Dk(i.description),hasAllowedTools:true,allowedTools:ws(i["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function EW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=b(e.normalizeTo(r)),i=Xg(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Vt(r,i,o)}}}function Nk(t){if(t.map)return t.map;switch(t.preset){case "rule":return CW(t);case "command":return kW(t);case "agent":return EW(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Fk=d(()=>{j();ut();or();s(Dk,"pickString");s(SW,"pruneUndefined");s(Xg,"applyRemap");s(CW,"ruleMapper");s(kW,"commandMapper");s(EW,"agentMapper");s(Nk,"resolveMapper");});function Zg(t,e){return t?t[e]??[]:[]}var vk,Mk=d(()=>{vk=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(Zg,"resolveScopedSources");});async function wW(t,e,r,n,o){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 l=join(r,a),c=await _(l);if(c===null)continue;await O(i);let m=join(i,t.canonicalRootFilename),p=s(S=>o(c,l,S),"normalizeTo");if(t.map){let S;try{S=await t.map({absolutePath:l,relativePath:a,content:c,destDir:i,normalizeTo:p});}catch(k){let P=k instanceof Error?k.message:String(k);process.stderr.write(`\u26A0 skipping ${l}: ${P}
56
- `);continue}if(!S)continue;return await I(S.destPath,S.content),[{fromTool:n,fromPath:l,toPath:S.toPath,feature:t.feature}]}let u=Fr(p(m),l);if(!u.ok){process.stderr.write(`\u26A0 skipping ${l}: ${u.error.message}
57
- `);continue}let{frontmatter:f,body:g}=u.value,h=t.frontmatterRemap?t.frontmatterRemap(f):f,R=t.markAsRoot?{...h,root:true}:h,C=await K(m,R,g);return await I(m,C),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function bW(t,e,r,n,o){let i=Nk(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),p=await Rt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:s(async({srcPath:u,relativePath:f,content:g,normalizeTo:h})=>{if(Gp(basename(u)))return null;let R;try{R=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(C=>h(C),"normalizeTo")});}catch(C){let S=C instanceof Error?C.message:String(C);return process.stderr.write(`\u26A0 skipping ${u}: ${S}
58
- `),null}return R?{destPath:R.destPath,toPath:R.toPath,feature:t.feature,content:R.content}:null},"mapEntry")});l.push(...p);}return l}function Gk(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function PW(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=Gk(t);for(let i of e){let a=join(r,i),l=await _(a);if(l===null)continue;let c=join(r,o);return await O(dirname(c)),await I(c,l.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function TW(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 n={};for(let[o,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,l=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){n[o]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:ws(a.args),env:Ln(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:Ln(a.headers),env:Ln(a.env),description:l});}return n}async function xW(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=Gk(t);for(let i of e){let a=join(r,i),l=await _(a);if(l===null)continue;let c=TW(l);return Object.keys(c).length===0?[]:(await Bt(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function $k(t,e,r,n,o){switch(t.mode){case "singleFile":return wW(t,e,r,n,o);case "directory":return bW(t,e,r,n,o);case "flatFile":return PW(t,e,r,n);case "mcpJson":return xW(t,e,r,n)}}async function DW(t,e,r,n,o){let i=Zg(t.source,e),a=Zg(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let l=await $k(t,i,r,n,o);if(l.length>0)return l}return a.length>0?$k(t,a,r,n,o):[]}function NW(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function J(t,e,r,n){let o=t.importer;if(!o)return [];let i=n?.normalize??await B(t.id,e,r),a=[];for(let l of vk)for(let c of NW(o,l))a.push(...await DW(c,r,e,t.id,i));return a}var Et=d(()=>{dt();w();Kr();j();or();ut();xe();Fk();Co();Mk();s(wW,"runSingleFile");s(bW,"runDirectory");s(Gk,"resolveCanonicalFilePath");s(PW,"runFlatFile");s(TW,"parseMcpJson");s(xW,"runMcpJson");s($k,"dispatchSpec");s(DW,"runSpec");s(NW,"specsForFeature");s(J,"runDescriptorImport");});async function jk(t,e={}){let r=e.scope??"project",n=[],o=await B(En,t,r);return n.push(...await J(su,t,r,{normalize:o})),await q(t,r==="global"?rr:ie,En,n,o),n}var Uk=d(()=>{dt();tt();Et();ml();Qg();s(jk,"importFromAider");});function FW(t,e){return Kk(e).some(n=>vW(t,n))}function Bk(t,e){return t.filter(r=>FW(r,e))}function Kk(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let i=n.split(",").map(l=>l.trim()),a=[];for(let l of i)for(let c of Kk(r+l+o))a.push(c);return a}function vW(t,e){return MW(e).test(t)}function MW(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 n="^"+e.join("")+"$";return new RegExp(n)}var Wk=d(()=>{s(FW,"globMatch");s(Bk,"globFilter");s(Kk,"expandBraces");s(vW,"matchOne");s(MW,"globToRegex");});function V(t,e,r,n={}){let o=[],{rules:i}=t;if(i.length===0)return [];if(i.some(l=>l.root)||o.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."}),n.checkGlobMatches===false)return o;for(let l of i){if(l.globs.length===0)continue;let c=false;for(let m of l.globs)if(Bk(r,m).length>0){c=true;break}c||o.push({level:"warning",file:relative(e,l.source),message:`globs "${l.globs.join(", ")}" match 0 files in project`});}return o}var It=d(()=>{Wk();s(V,"validateRules");});function zk(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:En}))}var Vk=d(()=>{It();ml();s(zk,"lintRules");});function x(t,e,r){return {level:"warning",file:t,target:e,message:r}}function $W(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 Ps(t,e,r,n){let o=n?.unsupportedBy??e,i=$W(r);return x(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var Lt=d(()=>{s(x,"createWarning");s($W,"formatOxfordComma");s(Ps,"createUnsupportedHookWarning");});function Jk(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Yk(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function Xk(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var Zk=d(()=>{Lt();s(Jk,"lintHooks");s(Yk,"lintPermissions");s(Xk,"lintMcp");});function E(t,e){return nt(t).relative(t,e).replace(/\\/g,"/")}async function L(t,e){return v(nt(t).join(t,e)).catch(()=>[])}function qk(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function WW(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)qk(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function D(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function M(t,e,r){if(!e.startsWith(`${r}/`))return;let n=e.slice(r.length+1);if(!n)return;if(!n.includes("/")){if(!n.endsWith(".md")||basename(n)==="SKILL.md")return;let u=basename(n,".md");t.set(e,`${Qk}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let l=o.startsWith(sl)?sl:o.startsWith(Vc)?Vc:null;if(l&&a==="SKILL.md"){t.set(e,`${BW}/${o.slice(l.length)}.md`);return}let c=o.startsWith(il)?il:o.startsWith(Jc)?Jc:null;if(c&&a==="SKILL.md"){t.set(e,`${KW}/${o.slice(c.length)}.md`);return}let m=`${Qk}/${o}`;a==="SKILL.md"&&qk(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&WW(t,e,p,`${r}/${o}`);}function HW(t){return t.split("/").filter(Boolean)[0]??""}async function zW(){if(qg!==void 0)return qg;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(Pt(),tE)),e=new Set;for(let r of t)for(let n 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(n!==void 0){let o=HW(n);o.startsWith(".")&&e.add(o);}return qg=e,e}function eh(t){return t.split("/").some(e=>e.startsWith("."))}async function VW(t){let e=[],r=await zW(),n=nt(t);async function o(i){let a=n.join(t,i),l=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let c of l){let m=i?`${i}/${c.name}`:c.name;if(c.isDirectory()){if(r.has(c.name)||eh(m))continue;await o(m);continue}if(c.isSymbolicLink()&&await stat(n.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(c.name)||eh(m))continue;await o(m);continue}(c.name==="AGENTS.md"||c.name==="AGENTS.override.md")&&e.push(n.join(t,m));}}return s(o,"walk"),await o(""),e}async function iu(t,e){let r=await VW(e);for(let n of r){let o=E(e,n),i=o.endsWith("/AGENTS.md")&&o!=="AGENTS.md"&&!o.endsWith("/AGENTS.override.md"),a=o.endsWith("/AGENTS.override.md")&&o!=="AGENTS.override.md";if(!i&&!a)continue;let l=posix.dirname(o);if(eh(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${UW}/${c}.md`);}}var UW,BW,KW,Qk,qg,St=d(()=>{ae();w();kt();mt();UW=".agentsmesh/rules",BW=".agentsmesh/commands",KW=".agentsmesh/agents",Qk=".agentsmesh/skills";s(E,"rel");s(L,"listFiles");s(qk,"addDirectoryMapping");s(WW,"addAncestorMappings");s(D,"addSimpleFileMapping");s(M,"addSkillLikeMapping");s(HW,"firstPathSegment");s(zW,"targetRootSegments");s(eh,"hasHiddenSegment");s(VW,"listScopedAgentsFiles");s(iu,"addScopedAgentsMappings");});var A,st,Ot,ht=d(()=>{A=".agentsmesh/rules",st=".agentsmesh/commands",Ot=".agentsmesh/agents";});async function rh(t,e,r="project"){if(r==="global"){t.set(Ao,`${A}/_root.md`);for(let n of await L(e,rr))M(t,E(e,n),rr);t.set(bi,".agentsmesh/ignore");return}t.set(er,`${A}/_root.md`);for(let n of await L(e,ie))M(t,E(e,n),ie);t.set(Oo,".agentsmesh/ignore");}var eE=d(()=>{St();ml();ht();s(rh,"buildAiderImportPaths");});var Pi,Wr,Ti,Ts,nm,rE,nE,om=d(()=>{Pi="amazon-q",Wr=".amazonq/rules",Ti=".amazonq/mcp.json",Ts=".aws/amazonq/rules",nm=".aws/amazonq/mcp.json",rE=".agentsmesh/rules",nE=".agentsmesh/mcp.json";});async function nh(t,e,r="project"){let n=r==="global"?Ts:Wr;for(let o of await L(e,n)){let i=E(e,o);D(t,i,A,".md");}}var oE=d(()=>{St();om();ht();s(nh,"buildAmazonQImportPaths");});var sr,le,On,oh,bo,ir,Po,sE,xi=d(()=>{sr="AGENTS.md",le=".agents/skills",On=".amp/settings.json",oh=".config/amp",bo=`${oh}/AGENTS.md`,ir=`${oh}/skills`,Po=`${oh}/settings.json`,sE=".agentsmesh/rules";});async function sh(t,e,r="project"){if(r==="global"){t.set(bo,`${A}/_root.md`);for(let n of await L(e,ir))M(t,E(e,n),ir);t.set(Po,".agentsmesh/mcp.json");return}t.set(sr,`${A}/_root.md`);for(let n of await L(e,le))M(t,E(e,n),le);t.set(On,".agentsmesh/mcp.json");}var iE=d(()=>{St();xi();ht();s(sh,"buildAmpImportPaths");});var Di,au,Hr,ar,sm,zr,An,im,wn,bn,am,fl,ih,Ni,lu,aE,Fi=d(()=>{Di="antigravity",au=".agents",Hr=`${au}/rules`,ar=`${Hr}/general.md`,sm=`${Hr}/_root.md`,zr=`${au}/skills`,An=`${au}/workflows`,im=`${au}/antigravity/mcp_config.json`,wn=".gemini/antigravity/GEMINI.md",bn=".gemini/antigravity/skills",am=".gemini/antigravity/workflows",fl=".gemini/antigravity/mcp_config.json",ih=".agentsmesh/rules/_root.md",Ni=".agentsmesh/rules",lu=".agentsmesh/commands",aE=".agentsmesh/mcp.json";});async function ah(t,e,r="project"){if(r==="global"){t.set(wn,`${A}/_root.md`);for(let n of await L(e,bn))M(t,E(e,n),bn);t.set(fl,".agentsmesh/mcp.json");return}t.set(ar,`${A}/_root.md`),t.set(sm,`${A}/_root.md`);for(let n of await L(e,Hr)){let o=E(e,n);o===ar||o===sm||D(t,o,A,".md");}for(let n of await L(e,An))D(t,E(e,n),st,".md");for(let n of await L(e,zr))M(t,E(e,n),zr);}var lE=d(()=>{St();Fi();ht();s(ah,"buildAntigravityImportPaths");});var ce,cu,De,lr,Ne,Pn,Tn,mu,To,xo,xn,Do,lh,ch,mh,ph,vi=d(()=>{ce="augment-code",cu=".augment",De=`${cu}/rules`,lr=`${cu}/commands`,Ne=`${cu}/skills`,Pn=`${cu}/settings.json`,Tn=".augmentignore",mu=".augment",To=`${mu}/rules`,xo=`${mu}/commands`,xn=`${mu}/skills`,Do=`${mu}/settings.json`,lh=".agentsmesh/rules",ch=".agentsmesh/mcp.json",mh=".agentsmesh/hooks.yaml",ph=".agentsmesh/ignore";});async function uh(t,e,r="project"){if(r==="global"){for(let n of await L(e,To))D(t,E(e,n),A,".md");for(let n of await L(e,xo))D(t,E(e,n),st,".md");for(let n of await L(e,xn))M(t,E(e,n),xn);t.set(Do,".agentsmesh/mcp.json");return}for(let n of await L(e,De))D(t,E(e,n),A,".md");for(let n of await L(e,lr))D(t,E(e,n),st,".md");for(let n of await L(e,Ne))M(t,E(e,n),Ne);t.set(Pn,".agentsmesh/mcp.json"),t.set(Tn,".agentsmesh/ignore");}var cE=d(()=>{St();vi();ht();s(uh,"buildAugmentCodeImportPaths");});var mE,xs,pE,lm,cm,mm,pm,um,No,dh,dm,gl,fm,gm,pu,uu,fh,hm,gh,Mi,uE,Fo=d(()=>{mE="claude-code",xs=".claude/CLAUDE.md",pE="CLAUDE.md",lm=".claude/rules",cm=".claude/commands",mm=".claude/agents",pm=".claude/skills",um=".claude/settings.json",No=".claude/hooks.json",dh=".claude/output-styles",dm=".claudeignore",gl=".mcp.json",fm=".claude.json",gm=".agentsmesh/rules",pu=".agentsmesh/commands",uu=".agentsmesh/agents",fh=".agentsmesh/skills",hm=".agentsmesh/mcp.json",gh=".agentsmesh/permissions.yaml",Mi=".agentsmesh/hooks.yaml",uE=".agentsmesh/ignore";});async function hh(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${A}/_root.md`),t.set(No,Mi),r==="project"&&t.set("CLAUDE.md",`${A}/_root.md`),r==="global")for(let n of await L(e,".agents/skills"))M(t,E(e,n),".agents/skills");for(let n of await L(e,".claude/rules"))D(t,E(e,n),A,".md");for(let n of await L(e,".claude/commands"))D(t,E(e,n),st,".md");for(let n of await L(e,".claude/agents"))D(t,E(e,n),Ot,".md");for(let n of await L(e,".claude/skills"))M(t,E(e,n),".claude/skills");}var dE=d(()=>{St();Fo();ht();s(hh,"buildClaudeCodeImportPaths");});var Ds,vo,$i,Mo,fE,Zt,Dn,Ns,Gi,ji,Ui,Bi,yh,Fs,du,_h,Rh,gE,hE,cr=d(()=>{Ds="cline",vo=".clinerules",$i=".clineignore",Mo=".cline/cline_mcp_settings.json",fE=".cline/mcp_settings.json",Zt=".cline/skills",Dn=".clinerules/workflows",Ns="AGENTS.md",Gi=".clinerules/hooks",ji="Documents/Cline/Rules",Ui="Documents/Cline/Workflows",Bi="Documents/Cline/Hooks",yh=".agentsmesh/hooks.yaml",Fs=".agentsmesh/rules",du=".agentsmesh/commands",_h=".agentsmesh/ignore",Rh=".agentsmesh/mcp.json",gE=".agentsmesh/agents",hE=".agentsmesh/skills";});async function Ih(t,e,r="project"){if(r==="global"){for(let n of await L(e,ji))D(t,E(e,n),A,".md");for(let n of await L(e,Ui))D(t,E(e,n),st,".md");for(let n of await L(e,Zt))M(t,E(e,n),Zt);t.set(Mo,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${A}/_root.md`);for(let n of await L(e,".clinerules")){let o=E(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||D(t,o,A,".md");}for(let n of await L(e,".clinerules/workflows"))D(t,E(e,n),st,".md");for(let n of await L(e,".cline/skills"))M(t,E(e,n),".cline/skills");}var yE=d(()=>{St();cr();ht();s(Ih,"buildClineImportPaths");});async function Sh(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${A}/_root.md`),t.set(".codex/AGENTS.override.md",`${A}/_root.md`)):(t.set("AGENTS.md",`${A}/_root.md`),t.set("codex.md",`${A}/_root.md`),await iu(t,e)),r==="project")for(let n of await L(e,".codex/instructions"))D(t,E(e,n),A,".md");for(let n of await L(e,".codex/rules")){let o=E(e,n);o.endsWith(".rules")?D(t,o,A,".rules"):o.endsWith(".md")&&D(t,o,A,".md");}for(let n of await L(e,".codex/agents"))D(t,E(e,n),Ot,".toml");for(let n of await L(e,".agents/skills"))M(t,E(e,n),".agents/skills");}var _E=d(()=>{St();ht();s(Sh,"buildCodexCliImportPaths");});var hl,Vr,Nn,Ch,fu,$o,kh,Fe,yl,ym,gu,hu,Eh,Fn=d(()=>{hl="continue",Vr=".continue/rules",Nn=".continue/prompts",Ch=".continue/mcpServers",fu=`${Ch}/agentsmesh.json`,$o=`${Vr}/general.md`,kh=`${Vr}/_root.md`,Fe=".continue/skills",yl=".continue/AGENTS.md",ym=".continue/config.yaml",gu=".agentsmesh/rules",hu=".agentsmesh/commands",Eh=".agentsmesh/mcp.json";});async function Lh(t,e,r="project"){t.set($o,`${A}/_root.md`),t.set(kh,`${A}/_root.md`);for(let n of await L(e,".continue/rules")){let o=E(e,n);o===$o||o===kh||D(t,o,A,".md");}for(let n of await L(e,".continue/prompts"))t.set(E(e,n),`${st}/${basename(n,".md")}.md`);for(let n of await L(e,".continue/skills"))M(t,E(e,n),".continue/skills");if(r==="global")for(let n of await L(e,".agents/skills"))M(t,E(e,n),".agents/skills");}var RE=d(()=>{St();Fn();ht();s(Lh,"buildContinueImportPaths");});function XW(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${A}/${basename(e,".instructions.md")}.md`);return}D(t,e,A,".md");}async function Oh(t,e){t.set(".github/copilot-instructions.md",`${A}/_root.md`);for(let r of await L(e,".github/copilot"))t.set(E(e,r),`${A}/${basename(r,".instructions.md")}.md`);for(let r of await L(e,".github/instructions"))XW(t,E(e,r));for(let r of await L(e,".github/prompts"))t.set(E(e,r),`${st}/${basename(r,".prompt.md")}.md`);for(let r of await L(e,".github/agents"))t.set(E(e,r),`${Ot}/${basename(r,".agent.md")}.md`);for(let r of await L(e,".github/skills"))M(t,E(e,r),".github/skills");}var IE=d(()=>{St();ht();s(XW,"addCopilotInstructionMapping");s(Oh,"buildCopilotImportPaths");});var mr,pr,Qt,ve,Go,SE,_u,Me,Ki,Ru,Iu,Su,_l=d(()=>{mr="crush",pr="CRUSH.md",Qt=".crush/skills",ve="crush.json",Go=".crushignore",SE=".config/crush",_u=`${SE}/crush.json`,Me=".config/crush/skills",Ki=`${SE}/CRUSH.md`,Ru=".agentsmesh/rules",Iu=".agentsmesh/ignore",Su=".agentsmesh/mcp.json";});async function Ah(t,e,r="project"){if(r==="global"){for(let n of await L(e,Me))M(t,E(e,n),Me);return}t.set(pr,`${Ru}/_root.md`),t.set(ve,Su),t.set(Go,Iu);for(let n of await L(e,Qt))M(t,E(e,n),Qt);}var CE=d(()=>{St();_l();s(Ah,"buildCrushImportPaths");});var kE,vs,EE,ur,jo,dr,fr,me,$e,vn,Cu,Jr,wh,ZW,Rl,Yr,Mn,Ms,$s,LE,Il,bh,_m,Ph,Kt=d(()=>{kE="cursor",vs="AGENTS.md",EE=".cursorrules",ur=".cursor/rules",jo=`${ur}/general.mdc`,dr=".cursor/commands",fr=".cursor/agents",me=".cursor/skills",$e=".cursor/mcp.json",vn=".cursor/hooks.json",Cu=".cursor/settings.json",Jr=".cursorignore",wh=".cursorindexingignore",ZW=".agentsmesh-exports/cursor",Rl=`${ZW}/user-rules.md`,Yr=".cursor/AGENTS.md",Mn=".agentsmesh/rules",Ms=".agentsmesh/commands",$s=".agentsmesh/agents",LE=".agentsmesh/skills",Il=".agentsmesh/mcp.json",bh=".agentsmesh/permissions.yaml",_m=".agentsmesh/hooks.yaml",Ph=".agentsmesh/ignore";});async function Th(t,e,r="project"){if(r==="global"){t.set($e,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${A}/_root.md`);for(let n of await L(e,".cursor/rules"))D(t,E(e,n),A,".mdc");for(let n of await L(e,".cursor/commands"))D(t,E(e,n),st,".md");for(let n of await L(e,".cursor/agents"))D(t,E(e,n),Ot,".md");for(let n of await L(e,".cursor/skills"))M(t,E(e,n),".cursor/skills");return}t.set("AGENTS.md",`${A}/_root.md`);for(let n of await L(e,".cursor/rules"))D(t,E(e,n),A,".mdc");for(let n of await L(e,".cursor/commands"))D(t,E(e,n),st,".md");for(let n of await L(e,".cursor/agents"))D(t,E(e,n),Ot,".md");for(let n of await L(e,".cursor/skills"))M(t,E(e,n),".cursor/skills");}var OE=d(()=>{St();Kt();ht();s(Th,"buildCursorImportPaths");});var $n,gr,pe,Uo,Bo,Xr,Wi,AE,Sl=d(()=>{$n="deepagents-cli",gr=".deepagents/AGENTS.md",pe=".deepagents/skills",Uo=".mcp.json",Bo=".deepagents/AGENTS.md",Xr=".deepagents/skills",Wi=".deepagents/.mcp.json",AE=".agentsmesh/rules";});async function xh(t,e,r="project"){if(r==="global"){t.set(Bo,`${A}/_root.md`);for(let n of await L(e,Xr))M(t,E(e,n),Xr);t.set(Wi,".agentsmesh/mcp.json");return}t.set(gr,`${A}/_root.md`);for(let n of await L(e,pe))M(t,E(e,n),pe);t.set(Uo,".agentsmesh/mcp.json");}var wE=d(()=>{St();Sl();ht();s(xh,"buildDeepagentsCliImportPaths");});var hr,yr,Le,Gn,jn,Ko,Un,Hi,Gs,bE,zi=d(()=>{hr="factory-droid",yr="AGENTS.md",Le=".factory/skills",Gn=".factory/droids",jn=".factory/mcp.json",Ko=".factory/AGENTS.md",Un=".factory/skills",Hi=".factory/droids",Gs=".factory/mcp.json",bE=".agentsmesh/rules";});async function Dh(t,e,r="project"){if(r==="global"){t.set(Ko,`${A}/_root.md`);for(let n of await L(e,Hi))D(t,E(e,n),Ot,".md");for(let n of await L(e,Un))M(t,E(e,n),Un);t.set(Gs,".agentsmesh/mcp.json");return}t.set(yr,`${A}/_root.md`);for(let n of await L(e,Gn))D(t,E(e,n),Ot,".md");for(let n of await L(e,Le))M(t,E(e,n),Le);t.set(jn,".agentsmesh/mcp.json");}var PE=d(()=>{St();zi();ht();s(Dh,"buildFactoryDroidImportPaths");});async function Nh(t,e){for(let r of await L(e,".gemini/rules"))D(t,E(e,r),A,".md");for(let r of await L(e,".gemini/commands")){let n=E(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",c=(o.startsWith(i)?o.slice(i.length):o).split("/").filter(Boolean).join(":");t.set(n,`${st}/${c}.md`);}for(let r of await L(e,".gemini/agents"))D(t,E(e,r),Ot,".md");for(let r of await L(e,".gemini/skills"))M(t,E(e,r),".gemini/skills");}var TE=d(()=>{St();ht();s(Nh,"buildGeminiCliImportPaths");});var Bn,_r,Oe,Wo,xE,Ho,Vi,Rr,DE,NE,Cl=d(()=>{Bn="goose",_r=".goosehints",Oe=".agents/skills",Wo=".gooseignore",xE=".config/goose",Ho=`${xE}/.goosehints`,Vi=`${xE}/.gooseignore`,Rr=".agents/skills",DE=".agentsmesh/rules",NE=".agentsmesh/ignore";});async function Fh(t,e,r="project"){if(r==="global"){t.set(Ho,`${A}/_root.md`);for(let n of await L(e,Rr))M(t,E(e,n),Rr);t.set(Vi,".agentsmesh/ignore");return}t.set(_r,`${A}/_root.md`);for(let n of await L(e,Oe))M(t,E(e,n),Oe);t.set(Wo,".agentsmesh/ignore");}var FE=d(()=>{St();Cl();ht();s(Fh,"buildGooseImportPaths");});var zo,Zr,vE,kl=d(()=>{zo="jules",Zr="AGENTS.md",vE=".agentsmesh/rules";});async function vh(t,e,r="project"){r!=="global"&&t.set(Zr,`${A}/_root.md`);}var ME=d(()=>{kl();ht();s(vh,"buildJulesImportPaths");});var Ji,js,ku,$E,Kn,GE,QW,Rm,Yi,Im,El,Ll,Sm,Cm,km,Em,Lm,qW,Eu,Xi,jE,Mh,Lu,UE,BE,KE,WE,Ol=d(()=>{Ji="junie",js=".junie",ku=`${js}/guidelines.md`,$E=`${js}/ci-guidelines.md`,Kn=`${js}/AGENTS.md`,GE="AGENTS.md",QW=`${js}/mcp`,Rm=`${QW}/mcp.json`,Yi=`${js}/skills`,Im=`${js}/rules`,El=`${js}/commands`,Ll=`${js}/agents`,Sm=".aiignore",Cm=".junie",km=`${Cm}/skills`,Em=`${Cm}/agents`,Lm=`${Cm}/commands`,qW=`${Cm}/mcp`,Eu=`${qW}/mcp.json`,Xi=`${Cm}/AGENTS.md`,jE=".agents/skills",Mh=".agentsmesh/rules/_root.md",Lu=".agentsmesh/rules",UE=".agentsmesh/commands",BE=".agentsmesh/agents",KE=".agentsmesh/mcp.json",WE=".agentsmesh/ignore";});async function $h(t,e){t.set(ku,`${A}/_root.md`),t.set(Kn,`${A}/_root.md`),t.set("AGENTS.md",`${A}/_root.md`);for(let r of await L(e,".junie/rules"))D(t,E(e,r),A,".md");for(let r of await L(e,".junie/commands"))D(t,E(e,r),st,".md");for(let r of await L(e,".junie/agents"))D(t,E(e,r),Ot,".md");for(let r of await L(e,".junie/skills"))M(t,E(e,r),".junie/skills");}var HE=d(()=>{St();Ol();ht();s($h,"buildJunieImportPaths");});var _e,Om,Wn,Vo,Jo,Yo,Qr,Us,Al,Ou,Zi,wl,Qi,Am,Au,bl,Bs,qi,ta,ea,Ks,Pl,wu,zE,Ws,Tl,ra,VE,JE,na=d(()=>{_e="kilo-code",Om=".kilo",Wn="AGENTS.md",Vo=`${Om}/rules`,Jo=`${Om}/commands`,Yo=`${Om}/agents`,Qr=`${Om}/skills`,Us=`${Om}/mcp.json`,Al=".kilocodeignore",Ou=".kilocode",Zi=`${Ou}/rules`,wl=`${Ou}/workflows`,Qi=`${Ou}/skills`,Am=`${Ou}/mcp.json`,Au=".kilocodemodes",bl=".kilo",Bs=`${bl}/AGENTS.md`,qi=`${bl}/rules`,ta=`${bl}/commands`,ea=`${bl}/agents`,Ks=`${bl}/skills`,Pl=`${bl}/mcp.json`,wu=".kilocodeignore",zE=".agents/skills",Ws=".agentsmesh/rules",Tl=".agentsmesh/commands",ra=".agentsmesh/agents",VE=".agentsmesh/mcp.json",JE=".agentsmesh/ignore";});async function Gh(t,e,r="project"){if(r==="global"){t.set(Bs,`${A}/_root.md`);for(let n of await L(e,qi))D(t,E(e,n),A,".md");for(let n of await L(e,ta))D(t,E(e,n),st,".md");for(let n of await L(e,ea))D(t,E(e,n),Ot,".md");for(let n of await L(e,Ks))M(t,E(e,n),Ks);t.set(Pl,".agentsmesh/mcp.json");return}t.set(Wn,`${A}/_root.md`);for(let n of await L(e,Vo))D(t,E(e,n),A,".md");for(let n of await L(e,Jo))D(t,E(e,n),st,".md");for(let n of await L(e,Yo))D(t,E(e,n),Ot,".md");for(let n of await L(e,Qr))M(t,E(e,n),Qr);t.set(Us,".agentsmesh/mcp.json");for(let n of await L(e,Zi)){let o=E(e,n);if(basename(o)==="00-root.md"){t.set(o,`${A}/_root.md`);continue}D(t,o,A,".md");}for(let n of await L(e,wl))D(t,E(e,n),st,".md");for(let n of await L(e,Qi))M(t,E(e,n),Qi);t.set(Am,".agentsmesh/mcp.json");}var YE=d(()=>{St();na();ht();s(Gh,"buildKiloCodeImportPaths");});var Ge,qr,wm,tn,Re,en,Hs,eH,xl,Dl,oa,rn,zs,sa,bm,Pm,XE,jh,Uh,ZE,QE,Bh,qE,Nl=d(()=>{Ge="kiro",qr="AGENTS.md",wm=".kiro",tn=`${wm}/steering`,Re=`${wm}/skills`,en=`${wm}/agents`,Hs=`${wm}/hooks`,eH=`${wm}/settings`,xl=`${eH}/mcp.json`,Dl=".kiroignore",oa=".kiro/steering",rn=".kiro/steering/AGENTS.md",zs=".kiro/skills",sa=".kiro/agents",bm=".kiro/settings/mcp.json",Pm=".kiro/settings/kiroignore",XE=".agents/skills",jh=".agentsmesh/rules/_root.md",Uh=".agentsmesh/rules",ZE=".agentsmesh/agents",QE=".agentsmesh/mcp.json",Bh=".agentsmesh/hooks.yaml",qE=".agentsmesh/ignore";});async function Kh(t,e,r="project"){if(r==="global"){t.set(rn,`${A}/_root.md`);for(let n of await L(e,oa)){let o=E(e,n);o!==rn&&D(t,o,A,".md");}for(let n of await L(e,zs))M(t,E(e,n),zs);for(let n of await L(e,sa))D(t,E(e,n),Ot,".md");return}t.set(qr,`${A}/_root.md`);for(let n of await L(e,tn))D(t,E(e,n),A,".md");for(let n of await L(e,Re))M(t,E(e,n),Re);for(let n of await L(e,en))D(t,E(e,n),Ot,".md");}var tL=d(()=>{St();Nl();ht();s(Kh,"buildKiroImportPaths");});var nn,bu,Hn,Xo,Zo,Qo,on,zn,Fl,Vs,ia,aa,la,Js,Ys,eL,Tm,Pu,Tu,Wh,ca=d(()=>{nn="opencode",bu=".opencode",Hn="AGENTS.md",Xo=`${bu}/rules`,Zo=`${bu}/commands`,Qo=`${bu}/agents`,on=`${bu}/skills`,zn="opencode.json",Fl=".config/opencode",Vs=`${Fl}/AGENTS.md`,ia=`${Fl}/rules`,aa=`${Fl}/commands`,la=`${Fl}/agents`,Js=`${Fl}/skills`,Ys=`${Fl}/opencode.json`,eL=".agents/skills",Tm=".agentsmesh/rules",Pu=".agentsmesh/commands",Tu=".agentsmesh/agents",Wh=".agentsmesh/mcp.json";});async function Hh(t,e,r="project"){if(r==="global"){t.set(Vs,`${A}/_root.md`);for(let n of await L(e,ia))D(t,E(e,n),A,".md");for(let n of await L(e,aa))D(t,E(e,n),st,".md");for(let n of await L(e,la))D(t,E(e,n),Ot,".md");for(let n of await L(e,Js))M(t,E(e,n),Js);t.set(Ys,".agentsmesh/mcp.json");return}t.set(Hn,`${A}/_root.md`);for(let n of await L(e,Xo))D(t,E(e,n),A,".md");for(let n of await L(e,Zo))D(t,E(e,n),st,".md");for(let n of await L(e,Qo))D(t,E(e,n),Ot,".md");for(let n of await L(e,on))M(t,E(e,n),on);t.set(zn,".agentsmesh/mcp.json");}var rL=d(()=>{St();ca();ht();s(Hh,"buildOpencodeImportPaths");});var Vn,Ir,qt,nL,qo,Sr,oL,vl=d(()=>{Vn="pi-agent",Ir="AGENTS.md",qt=".pi/skills",nL=".pi/agent",qo=`${nL}/AGENTS.md`,Sr=`${nL}/skills`,oL=".agentsmesh/rules";});async function zh(t,e,r="project"){if(r==="global"){t.set(qo,`${A}/_root.md`);for(let n of await L(e,Sr))M(t,E(e,n),Sr);return}t.set(Ir,`${A}/_root.md`);for(let n of await L(e,qt))M(t,E(e,n),qt);}var Vh=d(()=>{St();vl();ht();s(zh,"buildPiAgentImportPaths");});var Jn,Cr,ts,Yn,Xn,je,Xs,Zs,es,ma,Qs,Zn,qs,Jh,sL,iL,Ml=d(()=>{Jn="qwen-code",Cr="QWEN.md",ts=".qwen/rules",Yn=".qwen/commands",Xn=".qwen/agents",je=".qwen/skills",Xs=".qwen/settings.json",Zs=".qwenignore",es=".qwen/QWEN.md",ma=".qwen/settings.json",Qs=".qwen/commands",Zn=".qwen/skills",qs=".qwen/agents",Jh=".agentsmesh/rules",sL=".agentsmesh/commands",iL=".agentsmesh/agents";});async function Yh(t,e,r="project"){if(r==="global"){t.set(es,`${A}/_root.md`),t.set(ma,".agentsmesh/mcp.json");for(let n of await L(e,Qs))D(t,E(e,n),st,".md");for(let n of await L(e,qs))D(t,E(e,n),Ot,".md");for(let n of await L(e,Zn))M(t,E(e,n),Zn);return}t.set(Cr,`${A}/_root.md`),t.set(Xs,".agentsmesh/mcp.json"),t.set(Zs,".agentsmesh/ignore");for(let n of await L(e,ts))D(t,E(e,n),A,".md");for(let n of await L(e,Yn))D(t,E(e,n),st,".md");for(let n of await L(e,Xn))D(t,E(e,n),Ot,".md");for(let n of await L(e,je))M(t,E(e,n),je);}var aL=d(()=>{St();ht();Ml();s(Yh,"buildQwenCodeImportPaths");});var Qn,sn,Ae,lL,$l=d(()=>{Qn="replit-agent",sn="replit.md",Ae=".agents/skills",lL=".agentsmesh/rules";});async function Xh(t,e,r="project"){if(r!=="global"){t.set(sn,`${A}/_root.md`);for(let n of await L(e,Ae))M(t,E(e,n),Ae);}}var Zh=d(()=>{St();$l();ht();s(Xh,"buildReplitAgentImportPaths");});var ti,pa,an,xm,rs,ns,qn,Dm,Nm,Gl,Fm,xu,ei,ri,os,ua,vm,ni,cL,da,Du,mL,pL,fa=d(()=>{ti="roo-code",pa=".roo",an=`${pa}/rules/00-root.md`,xm=".roorules",rs=`${pa}/rules`,ns=`${pa}/commands`,qn=`${pa}/skills`,Dm=`${pa}/mcp.json`,Nm=".rooignore",Gl=".roomodes",Fm="settings/custom_modes.yaml",xu=".roo",ei=`${xu}/rules`,ri=`${xu}/commands`,os=`${xu}/skills`,ua="mcp_settings.json",vm=".rooignore",ni=`${xu}/AGENTS.md`,cL=".agents/skills",da=".agentsmesh/rules",Du=".agentsmesh/commands",mL=".agentsmesh/mcp.json",pL=".agentsmesh/ignore";});async function Qh(t,e,r="project"){if(r==="global"){t.set(ni,`${A}/_root.md`);for(let n of await L(e,ei))D(t,E(e,n),A,".md");for(let n of await L(e,ri))D(t,E(e,n),st,".md");for(let n of await L(e,os))M(t,E(e,n),os);t.set(ua,".agentsmesh/mcp.json");return}t.set(an,`${A}/_root.md`),t.set(xm,`${A}/_root.md`);for(let n of await L(e,rs)){let o=E(e,n);o!==an&&D(t,o,A,".md");}for(let n of await L(e,".roo")){let o=E(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&D(t,o,A,".md");}for(let n of await L(e,ns))D(t,E(e,n),st,".md");for(let n of await L(e,qn))M(t,E(e,n),qn);}var uL=d(()=>{St();fa();ht();s(Qh,"buildRooCodeImportPaths");});var to,kr,dL,te,ss,fL,is,Ue,jl,gL,Ul=d(()=>{to="rovodev",kr="AGENTS.md",dL=".rovodev",te=`${dL}/skills`,ss=`${dL}/mcp.json`,fL=".rovodev",is=".rovodev/AGENTS.md",Ue=".rovodev/skills",jl=".rovodev/mcp.json",gL=".agentsmesh/rules";});async function qh(t,e,r="project"){if(r==="global"){t.set(is,`${A}/_root.md`);for(let n of await L(e,Ue))M(t,E(e,n),Ue);t.set(jl,".agentsmesh/mcp.json");return}t.set(kr,`${A}/_root.md`);for(let n of await L(e,te))M(t,E(e,n),te);t.set(ss,".agentsmesh/mcp.json");}var hL=d(()=>{St();Ul();ht();s(qh,"buildRovodevImportPaths");});var Er,Nu,Be,Ke,Lr,ga,Bl,as,Or,ln,Mm,yL,$m,_L,RL,Kl=d(()=>{Er="trae",Nu=".trae",Be=`${Nu}/rules`,Ke=`${Be}/project_rules.md`,Lr=`${Nu}/skills`,ga=`${Nu}/mcp.json`,Bl=`${Nu}/.ignore`,as=".trae/user_rules",Or=".trae/user_rules/rules.md",ln=".trae/skills",Mm=".trae/mcp.json",yL=".agents/skills",$m=".agentsmesh/rules",_L=".agentsmesh/mcp.json",RL=".agentsmesh/ignore";});async function ty(t,e,r="project"){if(r==="global"){t.set(Or,`${A}/_root.md`);for(let n of await L(e,as)){let o=E(e,n);o!==Or&&D(t,o,A,".md");}for(let n of await L(e,ln))M(t,E(e,n),ln);return}t.set(Ke,`${A}/_root.md`);for(let n of await L(e,Be)){let o=E(e,n);o!==Ke&&D(t,o,A,".md");}for(let n of await L(e,Lr))M(t,E(e,n),Lr);}var IL=d(()=>{St();Kl();ht();s(ty,"buildTraeImportPaths");});var eo,cn,ey,ue,oi,We,SL,Wl=d(()=>{eo="warp",cn="AGENTS.md",ey="WARP.md",ue=".warp/skills",oi=".mcp.json",We=".warp/skills",SL=".agentsmesh/rules";});async function ry(t,e,r="project"){if(r==="global"){for(let n of await L(e,We))M(t,E(e,n),We);return}t.set(cn,`${A}/_root.md`);for(let n of await L(e,ue))M(t,E(e,n),ue);t.set(oi,".agentsmesh/mcp.json");}var CL=d(()=>{St();Wl();ht();s(ry,"buildWarpImportPaths");});async function ny(t,e){t.set("AGENTS.md",`${A}/_root.md`),t.set(".windsurfrules",`${A}/_root.md`),await iu(t,e);for(let r of await L(e,".windsurf/rules"))D(t,E(e,r),A,".md");for(let r of await L(e,".windsurf/workflows"))D(t,E(e,r),st,".md");for(let r of await L(e,".windsurf/skills"))M(t,E(e,r),".windsurf/skills");}var kL=d(()=>{St();ht();s(ny,"buildWindsurfImportPaths");});var mn,ro,rH,no,EL,ha=d(()=>{mn=".rules",ro=".zed/settings.json",rH=".config/zed",no=`${rH}/settings.json`,EL=".agentsmesh/rules";});async function oy(t,e,r="project"){if(r==="global"){t.set(no,".agentsmesh/mcp.json");return}t.set(mn,`${A}/_root.md`),t.set(ro,".agentsmesh/mcp.json");}var LL=d(()=>{ha();ht();s(oy,"buildZedImportPaths");});var OL=d(()=>{eE();oE();iE();lE();cE();dE();yE();_E();RE();IE();CE();OE();wE();PE();TE();FE();ME();HE();YE();tL();rL();Vh();aL();Zh();uL();hL();IL();CL();kL();LL();});var Ct=d(()=>{OL();});var nH,oH,sH,AL,su,Qg=d(()=>{kt();mt();rk();Uk();Vk();Zk();Ct();ml();nH={name:En,primaryRootInstructionPath:er,generateRules:ZC,generateCommands:qC,generateAgents:tk,generateSkills:QC,generateIgnore:ek,importFrom:jk},oH={rootInstructionPath:er,skillDir:ie,managedOutputs:{dirs:[ie],files:[er,Oo]},paths:{rulePath(t){return er},commandPath(t){return `${ie}/${H(t)}/SKILL.md`},agentPath(t){return `${ie}/${U(t)}/SKILL.md`}}},sH={rootInstructionPath:Ao,skillDir:rr,managedOutputs:{dirs:[rr],files:[Ao,bi]},rewriteGeneratedPath(t){return t===er?Ao:t===Oo?bi:t.startsWith(`${ie}/`)?t.replace(`${ie}/`,`${rr}/`):t},paths:{rulePath(t){return Ao},commandPath(t){return `${rr}/${H(t)}/SKILL.md`},agentPath(t){return `${rr}/${U(t)}/SKILL.md`}}},AL={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},su={id:En,metadata:{displayName:"Aider",category:"cli",officialUrl:"https://aider.chat",shortDescription:"Open-source terminal AI pair programmer"},generators:nH,capabilities:AL,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:zk,lint:{hooks:Jk,permissions:Yk,mcp:Xk},supportsConversion:{commands:true,agents:true},project:oH,globalSupport:{capabilities:AL,detectionPaths:[Ao,bi,rr],layout:sH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[er],global:[Ao]},canonicalDir:YC,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Oo],global:[bi]},canonicalDir:".agentsmesh",canonicalFilename:XC}},buildImportPaths:rh,detectionPaths:[er,Oo]};});function wL(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(Pi))continue;let n=r.root?"_root":basename(r.source,".md");e.push({path:`${Wr}/${n}.md`,content:r.body.trim()});}return e}function bL(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ti,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var PL=d(()=>{om();s(wL,"generateRules");s(bL,"generateMcp");});async function TL(t,e){let r=e?.scope??"project";return J(Fu,t,r)}var xL=d(()=>{Et();sy();s(TL,"importFromAmazonQ");});function DL(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Pi}))}var NL=d(()=>{It();om();s(DL,"lintRules");});var aH,lH,cH,mH,Fu,sy=d(()=>{PL();xL();NL();Ct();om();aH={name:Pi,generateRules:wL,generateMcp:bL,importFrom:TL},lH={managedOutputs:{dirs:[Wr],files:[Ti]},paths:{rulePath(t,e){return `${Wr}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},cH={managedOutputs:{dirs:[Ts],files:[nm]},rewriteGeneratedPath(t){return t.startsWith(`${Wr}/`)?t.replace(`${Wr}/`,`${Ts}/`):t===Ti?nm:t},paths:{rulePath(t,e){return `${Ts}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},mH={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Fu={id:Pi,metadata:{displayName:"Amazon Q Developer",category:"ide",officialUrl:"https://aws.amazon.com/q/developer",shortDescription:"AWS AI coding assistant"},generators:aH,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:DL,project:lH,globalSupport:{capabilities:mH,detectionPaths:[Ts,nm],layout:cH},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Wr],global:[Ts]},canonicalDir:rE,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ti],global:[nm]},canonicalDir:".agentsmesh",canonicalFilename:nE}},buildImportPaths:nh,detectionPaths:[Wr,Ti]};});function FL(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")),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:sr,content:o}]:[]}function vL(t){return rt(t,le)}function ML(t){return t.commands.map(e=>({path:`${le}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function $L(t){return t.agents.map(e=>({path:`${le}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}var GL=d(()=>{tt();Ut();mt();kt();xi();s(FL,"generateRules");s(vL,"generateSkills");s(ML,"generateCommands");s($L,"generateAgents");});function pt(t,e,r){let n=r.some(o=>pH.includes(o));return t.startsWith(`${e}/`)&&!n?`.agents/skills/${t.slice(e.length+1)}`:null}var pH,ee=d(()=>{pH=["amp","antigravity","codex-cli","goose","replit-agent"];s(pt,"mirrorSkillsToAgents");});async function UL(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let i=o,a=i["amp.mcpServers"]??i.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(l[c]=m);Object.keys(l).length!==0&&(await Bt(t,jL,l),r.push({fromTool:"amp",fromPath:e,toPath:jL,feature:"mcp"}));}var jL,BL=d(()=>{w();Kr();xi();jL=".agentsmesh/mcp.json";s(UL,"importAmpMcp");});async function KL(t,e={}){let r=e.scope??"project",n=[],o=await B("amp",t,r);return n.push(...await J(vu,t,r,{normalize:o})),await q(t,r==="global"?ir:le,"amp",n,o),await UL(t,r==="global"?Po:On,n),n}var WL=d(()=>{dt();tt();Et();BL();xi();iy();s(KL,"importFromAmp");});function HL(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var zL=d(()=>{It();xi();s(HL,"lintRules");});function VL(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function JL(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function YL(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var XL=d(()=>{Lt();s(VL,"lintHooks");s(JL,"lintPermissions");s(YL,"lintIgnore");});function hH(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 n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o["amp.mcpServers"]!==void 0&&(r["amp.mcpServers"]=o["amp.mcpServers"]),JSON.stringify(r,null,2)}var dH,fH,gH,ZL,vu,iy=d(()=>{kt();mt();GL();ee();WL();zL();XL();Ct();xi();dH={name:"amp",primaryRootInstructionPath:sr,generateRules:FL,generateCommands:ML,generateAgents:$L,generateSkills:vL,importFrom:KL},fH={rootInstructionPath:sr,skillDir:le,managedOutputs:{dirs:[le],files:[sr,On]},paths:{rulePath(t){return sr},commandPath(t){return `${le}/${H(t)}/SKILL.md`},agentPath(t){return `${le}/${U(t)}/SKILL.md`}}},gH={rootInstructionPath:bo,skillDir:ir,managedOutputs:{dirs:[ir],files:[bo,Po]},rewriteGeneratedPath(t){return t===sr?bo:t===On?Po:t.startsWith(`${le}/`)?t.replace(`${le}/`,`${ir}/`):t},mirrorGlobalPath(t,e){return pt(t,ir,e)},paths:{rulePath(t){return bo},commandPath(t){return `${ir}/${H(t)}/SKILL.md`},agentPath(t){return `${ir}/${U(t)}/SKILL.md`}}},ZL={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(hH,"mergeAmpSettings");vu={id:"amp",metadata:{displayName:"Amp",category:"cli",officialUrl:"https://ampcode.com",shortDescription:"Sourcegraph's coding agent"},generators:dH,capabilities:ZL,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:HL,lint:{hooks:VL,permissions:JL,ignore:YL},supportsConversion:{commands:true,agents:true},project:fH,globalSupport:{capabilities:ZL,detectionPaths:[bo,Po],layout:gH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[sr],global:[bo]},canonicalDir:sE,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:On,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===On||n===Po?hH(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:sh,detectionPaths:[sr,On],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function QL(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:ar,content:e.body.trim()||""}];for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("antigravity"))continue;let o=basename(n.source,".md");r.push({path:`${Hr}/${o}.md`,content:n.body.trim()||""});}return r}function qL(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
57
+ `||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function Nk(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:Dk(t,e,r)?{role:"markdown-link-dest"}:n==="<"&&o===">"?{role:"bracketed"}:n==="'"&&o==="'"||n==='"'&&o==='"'?{role:"quoted"}:n==="@"?{role:"at-prefix"}:n==="("&&t[e-2]==="]"?{role:"markdown-link-dest"}:n==="["&&o==="]"?{role:"bracket-label"}:{role:"bare-prose"}}function Fk(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=ul(n),a=i.replace(dl,""),l=Mt(a),c=e+a.length,m=t[e-1],p=t[r];return Dk(t,e,c)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!Hr(l)&&bW(t,e,n)):m==="@"?true:m==="("&&t[e-2]==="]"?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?Hr(l)?true:l.includes("/")||l.includes("\\")?l.startsWith("./")||l.startsWith("../")?true:(l.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var vk=d(()=>{ce();As();s(bW,"markdownBracketLabelDuplicatesDestination");s(Dk,"isMarkdownReferenceDefinitionDestination");s(Nk,"getTokenContext");s(Fk,"shouldRewritePathToken");});function yu(t){let e=new Set,r=hu(t.content);return {content:t.content.replace(_k,(o,i,a)=>{if(r.some(([Xt,Ut])=>i>=Xt&&i<Ut)||!Fk(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||bk(a,i,o)||Rk(a,i,i+o.length))return o;let{candidate:l,suffix:c}=ul(o);if(!l)return o;let m=dl.exec(l),p=m?l.slice(0,m.index):l,u=m?m[0]:"";if(!p)return o;let f=Nk(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&Wr.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:I}=wk({candidate:p,rawToken:l,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),k=h;if(!I||!g)return g&&e.add(g),o;let C=Mt(p),R=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(R&&!C.includes("/")&&!C.includes("\\"))return o;if(k===null){let Xt=Mt(l);if(Xt.startsWith("agentsmesh/")&&(Xt=`.${Xt}`),Xt.startsWith(".agentsmesh/")||Xt.includes("/.agentsmesh/")){let Ut=at(t.projectRoot),De=X(t.projectRoot,t.projectRoot),Ci=Xt.replace(/^\.\//,"");k=X(t.projectRoot,Ut.join(De,Ci));}}let P=at(t.projectRoot);if(t.scope==="global"){let Xt=Mt(l),Ut=Xt.startsWith(".agentsmesh/")||Xt.includes("/.agentsmesh/"),De=Hr(Xt)||Tk(Xt),Ci=k!==null&&zr(t.projectRoot,k),Fp=zr(t.projectRoot,g);if(k===g&&!Fp&&!Ci&&!Ut){let Ka=Mt(P.relative(t.projectRoot,X(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",_o=(k!==null?Mt(P.relative(t.projectRoot,k)):"").split("/").filter(Boolean)[0]??"";if(Ka.length>0&&Ka===_o)return o}if(!De&&!Ut&&!Ci&&!Fp)return o}let N=X(t.projectRoot,t.destinationFile),F=X(t.projectRoot,g),B=Mt(P.relative(t.projectRoot,N)),U=Mt(P.relative(t.projectRoot,F)),q=B.split("/").filter(Boolean)[0]??"",nt=U.split("/").filter(Boolean)[0]??"",Nt=!Mt(p).startsWith(".agentsmesh/")&&!R&&q.length>0&&q===nt&&q.startsWith(".")&&q!==".agentsmesh"||f.role==="markdown-link-dest"||Pk(a,i,p),Le=kk(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||Nt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:R?null:k,forceRelative:Nt,tokenContext:f,originalToken:p});return Le?`${Le}${u}${c}`:o}),missing:[...e]}}var lh=d(()=>{ce();As();Ek();Ak();xk();vk();s(yu,"rewriteFileLinks");});function $k(t,e){let r=[t.normalize(e)];if(!existsSync(e))return r;try{let n=[realpathSync(e),realpathSync.native(e)];for(let o of n){let i=t.normalize(o);r.includes(i)||r.push(i);}}catch{}return r}async function H(t,e,r="project"){let n=at(e),o=new Map,i=Array.from(new Set([t,...vt]));for(let c of i){let m=await dk(c,e,r);for(let[p,u]of m.entries())o.set(p,u);}let a=new Map;for(let[c,m]of o.entries()){let p=n.normalize(n.join(e,m));for(let u of $k(n,n.join(e,c)))a.set(u,p);}let l=new Set;for(let c of new Set(o.values())){let m=n.normalize(n.join(e,c));l.add(m);for(let p of $k(n,m))l.add(n.normalize(p));}return (c,m,p)=>yu({content:c,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:s(u=>a.get(u)??u,"translatePath"),pathExists:s(u=>{let f=n.normalize(u);return a.has(u)||a.has(f)||existsSync(u)||l.has(f)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:s(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var gt=d(()=>{ce();fk();lh();Sn();s($k,"pathVariants");s(H,"createImportReferenceNormalizer");});async function Wt(t,e,r){let n=join(t,e),i={...await DW(n),...r};await O(dirname(n)),await S(n,JSON.stringify({mcpServers:i},null,2));}async function DW(t){let e=await _(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let n=r.mcpServers;if(!n||typeof n!="object"||Array.isArray(n))return {};let o={};for(let[i,a]of Object.entries(n))!a||typeof a!="object"||Array.isArray(a)||(o[i]=a);return o}var Vr=d(()=>{A();s(Wt,"writeMcpWithMerge");s(DW,"readExistingServers");});function Po(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function lr(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 bs(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function wn(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var cr=d(()=>{s(Po,"toGlobsArray");s(lr,"toToolsArray");s(bs,"toStringArray");s(wn,"toStringRecord");});function vW(t,e){return e.some(r=>t.endsWith(r))}async function St(t){let r=(await $(t.srcDir)).filter(o=>vW(o,t.extensions)),n=[];for(let o of r){let i=await _(o);if(!i)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),l=await t.mapEntry({srcPath:o,relativePath:a,content:i,normalizeTo:s((c,m=i)=>t.normalize(m,o,c),"normalizeTo")});l&&(await O(dirname(l.destPath)),await S(l.destPath,l.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:l.toPath,feature:l.feature}));}return n}var Me=d(()=>{A();s(vW,"matchesExtension");s(St,"importFileDirectory");});function jk(t){return typeof t=="string"?t:void 0}function MW(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function mh(t,e){return e?e(t):t}function $W(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=b(e.normalizeTo(r)),i=mh(n,t.frontmatterRemap),a=MW({root:false,description:jk(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await z(r,a,o)}}}function GW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=b(e.normalizeTo(r)),i=mh(n,t.frontmatterRemap),a=await It(r,{hasDescription:true,description:jk(i.description),hasAllowedTools:true,allowedTools:bs(i["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function jW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=b(e.normalizeTo(r)),i=mh(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Jt(r,i,o)}}}function Uk(t){if(t.map)return t.map;switch(t.preset){case "rule":return $W(t);case "command":return GW(t);case "agent":return jW(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Bk=d(()=>{K();ft();cr();s(jk,"pickString");s(MW,"pruneUndefined");s(mh,"applyRemap");s($W,"ruleMapper");s(GW,"commandMapper");s(jW,"agentMapper");s(Uk,"resolveMapper");});function ph(t,e){return t?t[e]??[]:[]}var Kk,Wk=d(()=>{Kk=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(ph,"resolveScopedSources");});async function WW(t,e,r,n,o){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 l=join(r,a),c=await _(l);if(c===null)continue;await O(i);let m=join(i,t.canonicalRootFilename),p=s(C=>o(c,l,C),"normalizeTo");if(t.map){let C;try{C=await t.map({absolutePath:l,relativePath:a,content:c,destDir:i,normalizeTo:p});}catch(R){let P=R instanceof Error?R.message:String(R);process.stderr.write(`\u26A0 skipping ${l}: ${P}
58
+ `);continue}if(!C)continue;return await S(C.destPath,C.content),[{fromTool:n,fromPath:l,toPath:C.toPath,feature:t.feature}]}let u=Gr(p(m),l);if(!u.ok){process.stderr.write(`\u26A0 skipping ${l}: ${u.error.message}
59
+ `);continue}let{frontmatter:f,body:g}=u.value,h=t.frontmatterRemap?t.frontmatterRemap(f):f,I=t.markAsRoot?{...h,root:true}:h,k=await z(m,I,g);return await S(m,k),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function HW(t,e,r,n,o){let i=Uk(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),p=await St({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:s(async({srcPath:u,relativePath:f,content:g,normalizeTo:h})=>{if(Qp(basename(u)))return null;let I;try{I=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(k=>h(k),"normalizeTo")});}catch(k){let C=k instanceof Error?k.message:String(k);return process.stderr.write(`\u26A0 skipping ${u}: ${C}
60
+ `),null}return I?{destPath:I.destPath,toPath:I.toPath,feature:t.feature,content:I.content}:null},"mapEntry")});l.push(...p);}return l}function zk(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function zW(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=zk(t);for(let i of e){let a=join(r,i),l=await _(a);if(l===null)continue;let c=join(r,o);return await O(dirname(c)),await S(c,l.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function VW(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 n={};for(let[o,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,l=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){n[o]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:bs(a.args),env:wn(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:wn(a.headers),env:wn(a.env),description:l});}return n}async function JW(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=zk(t);for(let i of e){let a=join(r,i),l=await _(a);if(l===null)continue;let c=VW(l);return Object.keys(c).length===0?[]:(await Wt(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function Hk(t,e,r,n,o){switch(t.mode){case "singleFile":return WW(t,e,r,n,o);case "directory":return HW(t,e,r,n,o);case "flatFile":return zW(t,e,r,n);case "mcpJson":return JW(t,e,r,n)}}async function YW(t,e,r,n,o){let i=ph(t.source,e),a=ph(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let l=await Hk(t,i,r,n,o);if(l.length>0)return l}return a.length>0?Hk(t,a,r,n,o):[]}function XW(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function Y(t,e,r,n){let o=t.importer;if(!o)return [];let i=n?.normalize??await H(t.id,e,r),a=[];for(let l of Kk)for(let c of XW(o,l))a.push(...await YW(c,r,e,t.id,i));return a}var Ot=d(()=>{gt();A();Vr();K();cr();ft();Me();Bk();Eo();Wk();s(WW,"runSingleFile");s(HW,"runDirectory");s(zk,"resolveCanonicalFilePath");s(zW,"runFlatFile");s(VW,"parseMcpJson");s(JW,"runMcpJson");s(Hk,"dispatchSpec");s(YW,"runSpec");s(XW,"specsForFeature");s(Y,"runDescriptorImport");});async function Vk(t,e={}){let r=e.scope??"project",n=[],o=await H(On,t,r);return n.push(...await Y(_u,t,r,{normalize:o})),await et(t,r==="global"?ar:le,On,n,o),n}var Jk=d(()=>{gt();rt();Ot();pl();uh();s(Vk,"importFromAider");});function ZW(t,e){return Xk(e).some(n=>QW(t,n))}function Yk(t,e){return t.filter(r=>ZW(r,e))}function Xk(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let i=n.split(",").map(l=>l.trim()),a=[];for(let l of i)for(let c of Xk(r+l+o))a.push(c);return a}function QW(t,e){return qW(e).test(t)}function qW(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 n="^"+e.join("")+"$";return new RegExp(n)}var Zk=d(()=>{s(ZW,"globMatch");s(Yk,"globFilter");s(Xk,"expandBraces");s(QW,"matchOne");s(qW,"globToRegex");});function J(t,e,r,n={}){let o=[],{rules:i}=t;if(i.length===0)return [];if(i.some(l=>l.root)||o.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."}),n.checkGlobMatches===false)return o;for(let l of i){if(l.globs.length===0)continue;let c=false;for(let m of l.globs)if(Yk(r,m).length>0){c=true;break}c||o.push({level:"warning",file:relative(e,l.source),message:`globs "${l.globs.join(", ")}" match 0 files in project`});}return o}var Ct=d(()=>{Zk();s(J,"validateRules");});function qk(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:On}))}var tE=d(()=>{Ct();pl();s(qk,"lintRules");});function x(t,e,r){return {level:"warning",file:t,target:e,message:r}}function tH(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 Ts(t,e,r,n){let o=n?.unsupportedBy??e,i=tH(r);return x(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var wt=d(()=>{s(x,"createWarning");s(tH,"formatOxfordComma");s(Ts,"createUnsupportedHookWarning");});function eE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function rE(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function nE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var oE=d(()=>{wt();s(eE,"lintHooks");s(rE,"lintPermissions");s(nE,"lintMcp");});function E(t,e){return at(t).relative(t,e).replace(/\\/g,"/")}async function L(t,e){return $(at(t).join(t,e)).catch(()=>[])}function iE(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function iH(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)iE(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function D(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function G(t,e,r){if(!e.startsWith(`${r}/`))return;let n=e.slice(r.length+1);if(!n)return;if(!n.includes("/")){if(!n.endsWith(".md")||basename(n)==="SKILL.md")return;let u=basename(n,".md");t.set(e,`${sE}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let l=o.startsWith(il)?il:o.startsWith(Zc)?Zc:null;if(l&&a==="SKILL.md"){t.set(e,`${oH}/${o.slice(l.length)}.md`);return}let c=o.startsWith(al)?al:o.startsWith(Qc)?Qc:null;if(c&&a==="SKILL.md"){t.set(e,`${sH}/${o.slice(c.length)}.md`);return}let m=`${sE}/${o}`;a==="SKILL.md"&&iE(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&iH(t,e,p,`${r}/${o}`);}function aH(t){return t.split("/").filter(Boolean)[0]??""}async function lH(){if(dh!==void 0)return dh;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(Pt(),aE)),e=new Set;for(let r of t)for(let n 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(n!==void 0){let o=aH(n);o.startsWith(".")&&e.add(o);}return dh=e,e}function gh(t){return t.split("/").some(e=>e.startsWith("."))}async function cH(t){let e=[],r=await lH(),n=at(t);async function o(i){let a=n.join(t,i),l=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let c of l){let m=i?`${i}/${c.name}`:c.name;if(c.isDirectory()){if(r.has(c.name)||gh(m))continue;await o(m);continue}if(c.isSymbolicLink()&&await stat(n.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(c.name)||gh(m))continue;await o(m);continue}(c.name==="AGENTS.md"||c.name==="AGENTS.override.md")&&e.push(n.join(t,m));}}return s(o,"walk"),await o(""),e}async function Ru(t,e){let r=await cH(e);for(let n of r){let o=E(e,n),i=o.endsWith("/AGENTS.md")&&o!=="AGENTS.md"&&!o.endsWith("/AGENTS.override.md"),a=o.endsWith("/AGENTS.override.md")&&o!=="AGENTS.override.md";if(!i&&!a)continue;let l=posix.dirname(o);if(gh(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${nH}/${c}.md`);}}var nH,oH,sH,sE,dh,kt=d(()=>{ce();A();Lt();ut();nH=".agentsmesh/rules",oH=".agentsmesh/commands",sH=".agentsmesh/agents",sE=".agentsmesh/skills";s(E,"rel");s(L,"listFiles");s(iE,"addDirectoryMapping");s(iH,"addAncestorMappings");s(D,"addSimpleFileMapping");s(G,"addSkillLikeMapping");s(aH,"firstPathSegment");s(lH,"targetRootSegments");s(gh,"hasHiddenSegment");s(cH,"listScopedAgentsFiles");s(Ru,"addScopedAgentsMappings");});var w,lt,At,Rt=d(()=>{w=".agentsmesh/rules",lt=".agentsmesh/commands",At=".agentsmesh/agents";});async function hh(t,e,r="project"){if(r==="global"){t.set(bo,`${w}/_root.md`);for(let n of await L(e,ar))G(t,E(e,n),ar);t.set(Ti,".agentsmesh/ignore");return}t.set(ir,`${w}/_root.md`);for(let n of await L(e,le))G(t,E(e,n),le);t.set(Ao,".agentsmesh/ignore");}var lE=d(()=>{kt();pl();Rt();s(hh,"buildAiderImportPaths");});var xi,Jr,Di,xs,am,cE,mE,lm=d(()=>{xi="amazon-q",Jr=".amazonq/rules",Di=".amazonq/mcp.json",xs=".aws/amazonq/rules",am=".aws/amazonq/mcp.json",cE=".agentsmesh/rules",mE=".agentsmesh/mcp.json";});async function yh(t,e,r="project"){let n=r==="global"?xs:Jr;for(let o of await L(e,n)){let i=E(e,o);D(t,i,w,".md");}}var pE=d(()=>{kt();lm();Rt();s(yh,"buildAmazonQImportPaths");});var mr,me,An,_h,To,pr,xo,uE,Ni=d(()=>{mr="AGENTS.md",me=".agents/skills",An=".amp/settings.json",_h=".config/amp",To=`${_h}/AGENTS.md`,pr=`${_h}/skills`,xo=`${_h}/settings.json`,uE=".agentsmesh/rules";});async function Rh(t,e,r="project"){if(r==="global"){t.set(To,`${w}/_root.md`);for(let n of await L(e,pr))G(t,E(e,n),pr);t.set(xo,".agentsmesh/mcp.json");return}t.set(mr,`${w}/_root.md`);for(let n of await L(e,me))G(t,E(e,n),me);t.set(An,".agentsmesh/mcp.json");}var dE=d(()=>{kt();Ni();Rt();s(Rh,"buildAmpImportPaths");});var Fi,Iu,Yr,ur,cm,Xr,bn,mm,Pn,Tn,pm,gl,Ih,vi,Su,fE,Mi=d(()=>{Fi="antigravity",Iu=".agents",Yr=`${Iu}/rules`,ur=`${Yr}/general.md`,cm=`${Yr}/_root.md`,Xr=`${Iu}/skills`,bn=`${Iu}/workflows`,mm=`${Iu}/antigravity/mcp_config.json`,Pn=".gemini/antigravity/GEMINI.md",Tn=".gemini/antigravity/skills",pm=".gemini/antigravity/workflows",gl=".gemini/antigravity/mcp_config.json",Ih=".agentsmesh/rules/_root.md",vi=".agentsmesh/rules",Su=".agentsmesh/commands",fE=".agentsmesh/mcp.json";});async function Sh(t,e,r="project"){if(r==="global"){t.set(Pn,`${w}/_root.md`);for(let n of await L(e,Tn))G(t,E(e,n),Tn);t.set(gl,".agentsmesh/mcp.json");return}t.set(ur,`${w}/_root.md`),t.set(cm,`${w}/_root.md`);for(let n of await L(e,Yr)){let o=E(e,n);o===ur||o===cm||D(t,o,w,".md");}for(let n of await L(e,bn))D(t,E(e,n),lt,".md");for(let n of await L(e,Xr))G(t,E(e,n),Xr);}var gE=d(()=>{kt();Mi();Rt();s(Sh,"buildAntigravityImportPaths");});var pe,Cu,$e,dr,Ge,xn,Dn,ku,Do,No,Nn,Fo,Ch,kh,Eh,Lh,$i=d(()=>{pe="augment-code",Cu=".augment",$e=`${Cu}/rules`,dr=`${Cu}/commands`,Ge=`${Cu}/skills`,xn=`${Cu}/settings.json`,Dn=".augmentignore",ku=".augment",Do=`${ku}/rules`,No=`${ku}/commands`,Nn=`${ku}/skills`,Fo=`${ku}/settings.json`,Ch=".agentsmesh/rules",kh=".agentsmesh/mcp.json",Eh=".agentsmesh/hooks.yaml",Lh=".agentsmesh/ignore";});async function Oh(t,e,r="project"){if(r==="global"){for(let n of await L(e,Do))D(t,E(e,n),w,".md");for(let n of await L(e,No))D(t,E(e,n),lt,".md");for(let n of await L(e,Nn))G(t,E(e,n),Nn);t.set(Fo,".agentsmesh/mcp.json");return}for(let n of await L(e,$e))D(t,E(e,n),w,".md");for(let n of await L(e,dr))D(t,E(e,n),lt,".md");for(let n of await L(e,Ge))G(t,E(e,n),Ge);t.set(xn,".agentsmesh/mcp.json"),t.set(Dn,".agentsmesh/ignore");}var hE=d(()=>{kt();$i();Rt();s(Oh,"buildAugmentCodeImportPaths");});var yE,Ds,_E,um,dm,fm,gm,hm,vo,wh,ym,hl,_m,Rm,Eu,Lu,Ah,Im,bh,Gi,RE,Mo=d(()=>{yE="claude-code",Ds=".claude/CLAUDE.md",_E="CLAUDE.md",um=".claude/rules",dm=".claude/commands",fm=".claude/agents",gm=".claude/skills",hm=".claude/settings.json",vo=".claude/hooks.json",wh=".claude/output-styles",ym=".claudeignore",hl=".mcp.json",_m=".claude.json",Rm=".agentsmesh/rules",Eu=".agentsmesh/commands",Lu=".agentsmesh/agents",Ah=".agentsmesh/skills",Im=".agentsmesh/mcp.json",bh=".agentsmesh/permissions.yaml",Gi=".agentsmesh/hooks.yaml",RE=".agentsmesh/ignore";});async function Ph(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${w}/_root.md`),t.set(vo,Gi),r==="project"&&t.set("CLAUDE.md",`${w}/_root.md`),r==="global")for(let n of await L(e,".agents/skills"))G(t,E(e,n),".agents/skills");for(let n of await L(e,".claude/rules"))D(t,E(e,n),w,".md");for(let n of await L(e,".claude/commands"))D(t,E(e,n),lt,".md");for(let n of await L(e,".claude/agents"))D(t,E(e,n),At,".md");for(let n of await L(e,".claude/skills"))G(t,E(e,n),".claude/skills");}var IE=d(()=>{kt();Mo();Rt();s(Ph,"buildClaudeCodeImportPaths");});var Ns,$o,ji,Go,SE,qt,Fn,Fs,Ui,Bi,Ki,Wi,Th,vs,Ou,xh,Dh,CE,kE,fr=d(()=>{Ns="cline",$o=".clinerules",ji=".clineignore",Go=".cline/cline_mcp_settings.json",SE=".cline/mcp_settings.json",qt=".cline/skills",Fn=".clinerules/workflows",Fs="AGENTS.md",Ui=".clinerules/hooks",Bi="Documents/Cline/Rules",Ki="Documents/Cline/Workflows",Wi="Documents/Cline/Hooks",Th=".agentsmesh/hooks.yaml",vs=".agentsmesh/rules",Ou=".agentsmesh/commands",xh=".agentsmesh/ignore",Dh=".agentsmesh/mcp.json",CE=".agentsmesh/agents",kE=".agentsmesh/skills";});async function Nh(t,e,r="project"){if(r==="global"){for(let n of await L(e,Bi))D(t,E(e,n),w,".md");for(let n of await L(e,Ki))D(t,E(e,n),lt,".md");for(let n of await L(e,qt))G(t,E(e,n),qt);t.set(Go,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${w}/_root.md`);for(let n of await L(e,".clinerules")){let o=E(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||D(t,o,w,".md");}for(let n of await L(e,".clinerules/workflows"))D(t,E(e,n),lt,".md");for(let n of await L(e,".cline/skills"))G(t,E(e,n),".cline/skills");}var EE=d(()=>{kt();fr();Rt();s(Nh,"buildClineImportPaths");});async function Fh(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 Ru(t,e)),r==="project")for(let n of await L(e,".codex/instructions"))D(t,E(e,n),w,".md");for(let n of await L(e,".codex/rules")){let o=E(e,n);o.endsWith(".rules")?D(t,o,w,".rules"):o.endsWith(".md")&&D(t,o,w,".md");}for(let n of await L(e,".codex/agents"))D(t,E(e,n),At,".toml");for(let n of await L(e,".agents/skills"))G(t,E(e,n),".agents/skills");}var LE=d(()=>{kt();Rt();s(Fh,"buildCodexCliImportPaths");});var yl,Zr,vn,vh,wu,jo,Mh,je,_l,Sm,Au,bu,$h,Mn=d(()=>{yl="continue",Zr=".continue/rules",vn=".continue/prompts",vh=".continue/mcpServers",wu=`${vh}/agentsmesh.json`,jo=`${Zr}/general.md`,Mh=`${Zr}/_root.md`,je=".continue/skills",_l=".continue/AGENTS.md",Sm=".continue/config.yaml",Au=".agentsmesh/rules",bu=".agentsmesh/commands",$h=".agentsmesh/mcp.json";});async function Gh(t,e,r="project"){t.set(jo,`${w}/_root.md`),t.set(Mh,`${w}/_root.md`);for(let n of await L(e,".continue/rules")){let o=E(e,n);o===jo||o===Mh||D(t,o,w,".md");}for(let n of await L(e,".continue/prompts"))t.set(E(e,n),`${lt}/${basename(n,".md")}.md`);for(let n of await L(e,".continue/skills"))G(t,E(e,n),".continue/skills");if(r==="global")for(let n of await L(e,".agents/skills"))G(t,E(e,n),".agents/skills");}var OE=d(()=>{kt();Mn();Rt();s(Gh,"buildContinueImportPaths");});function uH(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${w}/${basename(e,".instructions.md")}.md`);return}D(t,e,w,".md");}async function jh(t,e){t.set(".github/copilot-instructions.md",`${w}/_root.md`);for(let r of await L(e,".github/copilot"))t.set(E(e,r),`${w}/${basename(r,".instructions.md")}.md`);for(let r of await L(e,".github/instructions"))uH(t,E(e,r));for(let r of await L(e,".github/prompts"))t.set(E(e,r),`${lt}/${basename(r,".prompt.md")}.md`);for(let r of await L(e,".github/agents"))t.set(E(e,r),`${At}/${basename(r,".agent.md")}.md`);for(let r of await L(e,".github/skills"))G(t,E(e,r),".github/skills");}var wE=d(()=>{kt();Rt();s(uH,"addCopilotInstructionMapping");s(jh,"buildCopilotImportPaths");});var gr,hr,te,Ue,Uo,AE,Tu,Be,Hi,xu,Du,Nu,Rl=d(()=>{gr="crush",hr="CRUSH.md",te=".crush/skills",Ue="crush.json",Uo=".crushignore",AE=".config/crush",Tu=`${AE}/crush.json`,Be=".config/crush/skills",Hi=`${AE}/CRUSH.md`,xu=".agentsmesh/rules",Du=".agentsmesh/ignore",Nu=".agentsmesh/mcp.json";});async function Uh(t,e,r="project"){if(r==="global"){for(let n of await L(e,Be))G(t,E(e,n),Be);return}t.set(hr,`${xu}/_root.md`),t.set(Ue,Nu),t.set(Uo,Du);for(let n of await L(e,te))G(t,E(e,n),te);}var bE=d(()=>{kt();Rl();s(Uh,"buildCrushImportPaths");});var PE,Ms,TE,yr,Bo,_r,Rr,ue,Ke,$n,Fu,Qr,Bh,dH,Il,qr,Gn,$s,Gs,xE,Sl,Kh,Cm,Wh,Ht=d(()=>{PE="cursor",Ms="AGENTS.md",TE=".cursorrules",yr=".cursor/rules",Bo=`${yr}/general.mdc`,_r=".cursor/commands",Rr=".cursor/agents",ue=".cursor/skills",Ke=".cursor/mcp.json",$n=".cursor/hooks.json",Fu=".cursor/settings.json",Qr=".cursorignore",Bh=".cursorindexingignore",dH=".agentsmesh-exports/cursor",Il=`${dH}/user-rules.md`,qr=".cursor/AGENTS.md",Gn=".agentsmesh/rules",$s=".agentsmesh/commands",Gs=".agentsmesh/agents",xE=".agentsmesh/skills",Sl=".agentsmesh/mcp.json",Kh=".agentsmesh/permissions.yaml",Cm=".agentsmesh/hooks.yaml",Wh=".agentsmesh/ignore";});async function Hh(t,e,r="project"){if(r==="global"){t.set(Ke,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${w}/_root.md`);for(let n of await L(e,".cursor/rules"))D(t,E(e,n),w,".mdc");for(let n of await L(e,".cursor/commands"))D(t,E(e,n),lt,".md");for(let n of await L(e,".cursor/agents"))D(t,E(e,n),At,".md");for(let n of await L(e,".cursor/skills"))G(t,E(e,n),".cursor/skills");return}t.set("AGENTS.md",`${w}/_root.md`);for(let n of await L(e,".cursor/rules"))D(t,E(e,n),w,".mdc");for(let n of await L(e,".cursor/commands"))D(t,E(e,n),lt,".md");for(let n of await L(e,".cursor/agents"))D(t,E(e,n),At,".md");for(let n of await L(e,".cursor/skills"))G(t,E(e,n),".cursor/skills");}var DE=d(()=>{kt();Ht();Rt();s(Hh,"buildCursorImportPaths");});var jn,Ir,de,Ko,Wo,tn,zi,NE,Cl=d(()=>{jn="deepagents-cli",Ir=".deepagents/AGENTS.md",de=".deepagents/skills",Ko=".mcp.json",Wo=".deepagents/AGENTS.md",tn=".deepagents/skills",zi=".deepagents/.mcp.json",NE=".agentsmesh/rules";});async function zh(t,e,r="project"){if(r==="global"){t.set(Wo,`${w}/_root.md`);for(let n of await L(e,tn))G(t,E(e,n),tn);t.set(zi,".agentsmesh/mcp.json");return}t.set(Ir,`${w}/_root.md`);for(let n of await L(e,de))G(t,E(e,n),de);t.set(Ko,".agentsmesh/mcp.json");}var FE=d(()=>{kt();Cl();Rt();s(zh,"buildDeepagentsCliImportPaths");});var Sr,Cr,we,Un,Bn,Ho,Kn,Vi,js,vE,Ji=d(()=>{Sr="factory-droid",Cr="AGENTS.md",we=".factory/skills",Un=".factory/droids",Bn=".factory/mcp.json",Ho=".factory/AGENTS.md",Kn=".factory/skills",Vi=".factory/droids",js=".factory/mcp.json",vE=".agentsmesh/rules";});async function Vh(t,e,r="project"){if(r==="global"){t.set(Ho,`${w}/_root.md`);for(let n of await L(e,Vi))D(t,E(e,n),At,".md");for(let n of await L(e,Kn))G(t,E(e,n),Kn);t.set(js,".agentsmesh/mcp.json");return}t.set(Cr,`${w}/_root.md`);for(let n of await L(e,Un))D(t,E(e,n),At,".md");for(let n of await L(e,we))G(t,E(e,n),we);t.set(Bn,".agentsmesh/mcp.json");}var ME=d(()=>{kt();Ji();Rt();s(Vh,"buildFactoryDroidImportPaths");});async function Jh(t,e){for(let r of await L(e,".gemini/rules"))D(t,E(e,r),w,".md");for(let r of await L(e,".gemini/commands")){let n=E(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",c=(o.startsWith(i)?o.slice(i.length):o).split("/").filter(Boolean).join(":");t.set(n,`${lt}/${c}.md`);}for(let r of await L(e,".gemini/agents"))D(t,E(e,r),At,".md");for(let r of await L(e,".gemini/skills"))G(t,E(e,r),".gemini/skills");}var $E=d(()=>{kt();Rt();s(Jh,"buildGeminiCliImportPaths");});var Wn,kr,Ae,zo,GE,Vo,Yi,Er,jE,UE,kl=d(()=>{Wn="goose",kr=".goosehints",Ae=".agents/skills",zo=".gooseignore",GE=".config/goose",Vo=`${GE}/.goosehints`,Yi=`${GE}/.gooseignore`,Er=".agents/skills",jE=".agentsmesh/rules",UE=".agentsmesh/ignore";});async function Yh(t,e,r="project"){if(r==="global"){t.set(Vo,`${w}/_root.md`);for(let n of await L(e,Er))G(t,E(e,n),Er);t.set(Yi,".agentsmesh/ignore");return}t.set(kr,`${w}/_root.md`);for(let n of await L(e,Ae))G(t,E(e,n),Ae);t.set(zo,".agentsmesh/ignore");}var BE=d(()=>{kt();kl();Rt();s(Yh,"buildGooseImportPaths");});var Jo,en,KE,El=d(()=>{Jo="jules",en="AGENTS.md",KE=".agentsmesh/rules";});async function Xh(t,e,r="project"){r!=="global"&&t.set(en,`${w}/_root.md`);}var WE=d(()=>{El();Rt();s(Xh,"buildJulesImportPaths");});var Xi,Us,vu,HE,Hn,zE,fH,km,Zi,Em,Ll,Ol,Lm,Om,wm,Am,bm,gH,Mu,Qi,VE,Zh,$u,JE,YE,XE,ZE,wl=d(()=>{Xi="junie",Us=".junie",vu=`${Us}/guidelines.md`,HE=`${Us}/ci-guidelines.md`,Hn=`${Us}/AGENTS.md`,zE="AGENTS.md",fH=`${Us}/mcp`,km=`${fH}/mcp.json`,Zi=`${Us}/skills`,Em=`${Us}/rules`,Ll=`${Us}/commands`,Ol=`${Us}/agents`,Lm=".aiignore",Om=".junie",wm=`${Om}/skills`,Am=`${Om}/agents`,bm=`${Om}/commands`,gH=`${Om}/mcp`,Mu=`${gH}/mcp.json`,Qi=`${Om}/AGENTS.md`,VE=".agents/skills",Zh=".agentsmesh/rules/_root.md",$u=".agentsmesh/rules",JE=".agentsmesh/commands",YE=".agentsmesh/agents",XE=".agentsmesh/mcp.json",ZE=".agentsmesh/ignore";});async function Qh(t,e){t.set(vu,`${w}/_root.md`),t.set(Hn,`${w}/_root.md`),t.set("AGENTS.md",`${w}/_root.md`);for(let r of await L(e,".junie/rules"))D(t,E(e,r),w,".md");for(let r of await L(e,".junie/commands"))D(t,E(e,r),lt,".md");for(let r of await L(e,".junie/agents"))D(t,E(e,r),At,".md");for(let r of await L(e,".junie/skills"))G(t,E(e,r),".junie/skills");}var QE=d(()=>{kt();wl();Rt();s(Qh,"buildJunieImportPaths");});var Re,Pm,zn,Yo,Xo,Zo,rn,Bs,Al,Gu,qi,bl,ta,Tm,ju,Pl,Ks,ea,ra,na,Ws,Tl,Uu,qE,Hs,xl,oa,tL,eL,sa=d(()=>{Re="kilo-code",Pm=".kilo",zn="AGENTS.md",Yo=`${Pm}/rules`,Xo=`${Pm}/commands`,Zo=`${Pm}/agents`,rn=`${Pm}/skills`,Bs=`${Pm}/mcp.json`,Al=".kilocodeignore",Gu=".kilocode",qi=`${Gu}/rules`,bl=`${Gu}/workflows`,ta=`${Gu}/skills`,Tm=`${Gu}/mcp.json`,ju=".kilocodemodes",Pl=".kilo",Ks=`${Pl}/AGENTS.md`,ea=`${Pl}/rules`,ra=`${Pl}/commands`,na=`${Pl}/agents`,Ws=`${Pl}/skills`,Tl=`${Pl}/mcp.json`,Uu=".kilocodeignore",qE=".agents/skills",Hs=".agentsmesh/rules",xl=".agentsmesh/commands",oa=".agentsmesh/agents",tL=".agentsmesh/mcp.json",eL=".agentsmesh/ignore";});async function qh(t,e,r="project"){if(r==="global"){t.set(Ks,`${w}/_root.md`);for(let n of await L(e,ea))D(t,E(e,n),w,".md");for(let n of await L(e,ra))D(t,E(e,n),lt,".md");for(let n of await L(e,na))D(t,E(e,n),At,".md");for(let n of await L(e,Ws))G(t,E(e,n),Ws);t.set(Tl,".agentsmesh/mcp.json");return}t.set(zn,`${w}/_root.md`);for(let n of await L(e,Yo))D(t,E(e,n),w,".md");for(let n of await L(e,Xo))D(t,E(e,n),lt,".md");for(let n of await L(e,Zo))D(t,E(e,n),At,".md");for(let n of await L(e,rn))G(t,E(e,n),rn);t.set(Bs,".agentsmesh/mcp.json");for(let n of await L(e,qi)){let o=E(e,n);if(basename(o)==="00-root.md"){t.set(o,`${w}/_root.md`);continue}D(t,o,w,".md");}for(let n of await L(e,bl))D(t,E(e,n),lt,".md");for(let n of await L(e,ta))G(t,E(e,n),ta);t.set(Tm,".agentsmesh/mcp.json");}var rL=d(()=>{kt();sa();Rt();s(qh,"buildKiloCodeImportPaths");});var We,nn,xm,on,Ie,sn,zs,yH,Dl,Nl,ia,an,Vs,aa,Dm,Nm,nL,ty,ey,oL,sL,ry,iL,Fl=d(()=>{We="kiro",nn="AGENTS.md",xm=".kiro",on=`${xm}/steering`,Ie=`${xm}/skills`,sn=`${xm}/agents`,zs=`${xm}/hooks`,yH=`${xm}/settings`,Dl=`${yH}/mcp.json`,Nl=".kiroignore",ia=".kiro/steering",an=".kiro/steering/AGENTS.md",Vs=".kiro/skills",aa=".kiro/agents",Dm=".kiro/settings/mcp.json",Nm=".kiro/settings/kiroignore",nL=".agents/skills",ty=".agentsmesh/rules/_root.md",ey=".agentsmesh/rules",oL=".agentsmesh/agents",sL=".agentsmesh/mcp.json",ry=".agentsmesh/hooks.yaml",iL=".agentsmesh/ignore";});async function ny(t,e,r="project"){if(r==="global"){t.set(an,`${w}/_root.md`);for(let n of await L(e,ia)){let o=E(e,n);o!==an&&D(t,o,w,".md");}for(let n of await L(e,Vs))G(t,E(e,n),Vs);for(let n of await L(e,aa))D(t,E(e,n),At,".md");return}t.set(nn,`${w}/_root.md`);for(let n of await L(e,on))D(t,E(e,n),w,".md");for(let n of await L(e,Ie))G(t,E(e,n),Ie);for(let n of await L(e,sn))D(t,E(e,n),At,".md");}var aL=d(()=>{kt();Fl();Rt();s(ny,"buildKiroImportPaths");});var ln,Bu,Vn,Qo,qo,ts,cn,Jn,vl,Js,la,ca,ma,Ys,Xs,lL,Fm,Ku,Wu,oy,pa=d(()=>{ln="opencode",Bu=".opencode",Vn="AGENTS.md",Qo=`${Bu}/rules`,qo=`${Bu}/commands`,ts=`${Bu}/agents`,cn=`${Bu}/skills`,Jn="opencode.json",vl=".config/opencode",Js=`${vl}/AGENTS.md`,la=`${vl}/rules`,ca=`${vl}/commands`,ma=`${vl}/agents`,Ys=`${vl}/skills`,Xs=`${vl}/opencode.json`,lL=".agents/skills",Fm=".agentsmesh/rules",Ku=".agentsmesh/commands",Wu=".agentsmesh/agents",oy=".agentsmesh/mcp.json";});async function sy(t,e,r="project"){if(r==="global"){t.set(Js,`${w}/_root.md`);for(let n of await L(e,la))D(t,E(e,n),w,".md");for(let n of await L(e,ca))D(t,E(e,n),lt,".md");for(let n of await L(e,ma))D(t,E(e,n),At,".md");for(let n of await L(e,Ys))G(t,E(e,n),Ys);t.set(Xs,".agentsmesh/mcp.json");return}t.set(Vn,`${w}/_root.md`);for(let n of await L(e,Qo))D(t,E(e,n),w,".md");for(let n of await L(e,qo))D(t,E(e,n),lt,".md");for(let n of await L(e,ts))D(t,E(e,n),At,".md");for(let n of await L(e,cn))G(t,E(e,n),cn);t.set(Jn,".agentsmesh/mcp.json");}var cL=d(()=>{kt();pa();Rt();s(sy,"buildOpencodeImportPaths");});var Yn,Lr,ee,mL,es,Or,pL,Ml=d(()=>{Yn="pi-agent",Lr="AGENTS.md",ee=".pi/skills",mL=".pi/agent",es=`${mL}/AGENTS.md`,Or=`${mL}/skills`,pL=".agentsmesh/rules";});async function iy(t,e,r="project"){if(r==="global"){t.set(es,`${w}/_root.md`);for(let n of await L(e,Or))G(t,E(e,n),Or);return}t.set(Lr,`${w}/_root.md`);for(let n of await L(e,ee))G(t,E(e,n),ee);}var ay=d(()=>{kt();Ml();Rt();s(iy,"buildPiAgentImportPaths");});var Xn,wr,rs,Zn,Qn,He,Zs,Qs,ns,ua,qs,qn,ti,ly,uL,dL,$l=d(()=>{Xn="qwen-code",wr="QWEN.md",rs=".qwen/rules",Zn=".qwen/commands",Qn=".qwen/agents",He=".qwen/skills",Zs=".qwen/settings.json",Qs=".qwenignore",ns=".qwen/QWEN.md",ua=".qwen/settings.json",qs=".qwen/commands",qn=".qwen/skills",ti=".qwen/agents",ly=".agentsmesh/rules",uL=".agentsmesh/commands",dL=".agentsmesh/agents";});async function cy(t,e,r="project"){if(r==="global"){t.set(ns,`${w}/_root.md`),t.set(ua,".agentsmesh/mcp.json");for(let n of await L(e,qs))D(t,E(e,n),lt,".md");for(let n of await L(e,ti))D(t,E(e,n),At,".md");for(let n of await L(e,qn))G(t,E(e,n),qn);return}t.set(wr,`${w}/_root.md`),t.set(Zs,".agentsmesh/mcp.json"),t.set(Qs,".agentsmesh/ignore");for(let n of await L(e,rs))D(t,E(e,n),w,".md");for(let n of await L(e,Zn))D(t,E(e,n),lt,".md");for(let n of await L(e,Qn))D(t,E(e,n),At,".md");for(let n of await L(e,He))G(t,E(e,n),He);}var fL=d(()=>{kt();Rt();$l();s(cy,"buildQwenCodeImportPaths");});var to,mn,be,gL,Gl=d(()=>{to="replit-agent",mn="replit.md",be=".agents/skills",gL=".agentsmesh/rules";});async function my(t,e,r="project"){if(r!=="global"){t.set(mn,`${w}/_root.md`);for(let n of await L(e,be))G(t,E(e,n),be);}}var py=d(()=>{kt();Gl();Rt();s(my,"buildReplitAgentImportPaths");});var ei,da,pn,vm,os,ss,eo,Mm,$m,jl,Gm,Hu,ri,ni,is,fa,jm,oi,hL,ga,zu,yL,_L,ha=d(()=>{ei="roo-code",da=".roo",pn=`${da}/rules/00-root.md`,vm=".roorules",os=`${da}/rules`,ss=`${da}/commands`,eo=`${da}/skills`,Mm=`${da}/mcp.json`,$m=".rooignore",jl=".roomodes",Gm="settings/custom_modes.yaml",Hu=".roo",ri=`${Hu}/rules`,ni=`${Hu}/commands`,is=`${Hu}/skills`,fa="mcp_settings.json",jm=".rooignore",oi=`${Hu}/AGENTS.md`,hL=".agents/skills",ga=".agentsmesh/rules",zu=".agentsmesh/commands",yL=".agentsmesh/mcp.json",_L=".agentsmesh/ignore";});async function uy(t,e,r="project"){if(r==="global"){t.set(oi,`${w}/_root.md`);for(let n of await L(e,ri))D(t,E(e,n),w,".md");for(let n of await L(e,ni))D(t,E(e,n),lt,".md");for(let n of await L(e,is))G(t,E(e,n),is);t.set(fa,".agentsmesh/mcp.json");return}t.set(pn,`${w}/_root.md`),t.set(vm,`${w}/_root.md`);for(let n of await L(e,os)){let o=E(e,n);o!==pn&&D(t,o,w,".md");}for(let n of await L(e,".roo")){let o=E(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&D(t,o,w,".md");}for(let n of await L(e,ss))D(t,E(e,n),lt,".md");for(let n of await L(e,eo))G(t,E(e,n),eo);}var RL=d(()=>{kt();ha();Rt();s(uy,"buildRooCodeImportPaths");});var ro,Ar,IL,re,as,SL,ls,ze,Ul,CL,Bl=d(()=>{ro="rovodev",Ar="AGENTS.md",IL=".rovodev",re=`${IL}/skills`,as=`${IL}/mcp.json`,SL=".rovodev",ls=".rovodev/AGENTS.md",ze=".rovodev/skills",Ul=".rovodev/mcp.json",CL=".agentsmesh/rules";});async function dy(t,e,r="project"){if(r==="global"){t.set(ls,`${w}/_root.md`);for(let n of await L(e,ze))G(t,E(e,n),ze);t.set(Ul,".agentsmesh/mcp.json");return}t.set(Ar,`${w}/_root.md`);for(let n of await L(e,re))G(t,E(e,n),re);t.set(as,".agentsmesh/mcp.json");}var kL=d(()=>{kt();Bl();Rt();s(dy,"buildRovodevImportPaths");});var br,Vu,Ve,Je,Pr,ya,Kl,cs,Tr,un,Um,EL,Bm,LL,OL,Wl=d(()=>{br="trae",Vu=".trae",Ve=`${Vu}/rules`,Je=`${Ve}/project_rules.md`,Pr=`${Vu}/skills`,ya=`${Vu}/mcp.json`,Kl=`${Vu}/.ignore`,cs=".trae/user_rules",Tr=".trae/user_rules/rules.md",un=".trae/skills",Um=".trae/mcp.json",EL=".agents/skills",Bm=".agentsmesh/rules",LL=".agentsmesh/mcp.json",OL=".agentsmesh/ignore";});async function fy(t,e,r="project"){if(r==="global"){t.set(Tr,`${w}/_root.md`);for(let n of await L(e,cs)){let o=E(e,n);o!==Tr&&D(t,o,w,".md");}for(let n of await L(e,un))G(t,E(e,n),un);return}t.set(Je,`${w}/_root.md`);for(let n of await L(e,Ve)){let o=E(e,n);o!==Je&&D(t,o,w,".md");}for(let n of await L(e,Pr))G(t,E(e,n),Pr);}var wL=d(()=>{kt();Wl();Rt();s(fy,"buildTraeImportPaths");});var no,dn,gy,fe,si,Ye,AL,Hl=d(()=>{no="warp",dn="AGENTS.md",gy="WARP.md",fe=".warp/skills",si=".mcp.json",Ye=".warp/skills",AL=".agentsmesh/rules";});async function hy(t,e,r="project"){if(r==="global"){for(let n of await L(e,Ye))G(t,E(e,n),Ye);return}t.set(dn,`${w}/_root.md`);for(let n of await L(e,fe))G(t,E(e,n),fe);t.set(si,".agentsmesh/mcp.json");}var bL=d(()=>{kt();Hl();Rt();s(hy,"buildWarpImportPaths");});async function yy(t,e){t.set("AGENTS.md",`${w}/_root.md`),t.set(".windsurfrules",`${w}/_root.md`),await Ru(t,e);for(let r of await L(e,".windsurf/rules"))D(t,E(e,r),w,".md");for(let r of await L(e,".windsurf/workflows"))D(t,E(e,r),lt,".md");for(let r of await L(e,".windsurf/skills"))G(t,E(e,r),".windsurf/skills");}var PL=d(()=>{kt();Rt();s(yy,"buildWindsurfImportPaths");});var fn,oo,_H,so,TL,_a=d(()=>{fn=".rules",oo=".zed/settings.json",_H=".config/zed",so=`${_H}/settings.json`,TL=".agentsmesh/rules";});async function _y(t,e,r="project"){if(r==="global"){t.set(so,".agentsmesh/mcp.json");return}t.set(fn,`${w}/_root.md`),t.set(oo,".agentsmesh/mcp.json");}var xL=d(()=>{_a();Rt();s(_y,"buildZedImportPaths");});var DL=d(()=>{lE();pE();dE();gE();hE();IE();EE();LE();OE();wE();bE();DE();FE();ME();$E();BE();WE();QE();rL();aL();cL();ay();fL();py();RL();kL();wL();bL();PL();xL();});var Et=d(()=>{DL();});var RH,IH,SH,NL,_u,uh=d(()=>{Lt();ut();ck();Jk();tE();oE();Et();pl();RH={name:On,primaryRootInstructionPath:ir,generateRules:ok,generateCommands:ik,generateAgents:ak,generateSkills:sk,generateIgnore:lk,importFrom:Vk},IH={rootInstructionPath:ir,skillDir:le,managedOutputs:{dirs:[le],files:[ir,Ao]},paths:{rulePath(t){return ir},commandPath(t){return `${le}/${V(t)}/SKILL.md`},agentPath(t){return `${le}/${W(t)}/SKILL.md`}}},SH={rootInstructionPath:bo,skillDir:ar,managedOutputs:{dirs:[ar],files:[bo,Ti]},rewriteGeneratedPath(t){return t===ir?bo:t===Ao?Ti:t.startsWith(`${le}/`)?t.replace(`${le}/`,`${ar}/`):t},paths:{rulePath(t){return bo},commandPath(t){return `${ar}/${V(t)}/SKILL.md`},agentPath(t){return `${ar}/${W(t)}/SKILL.md`}}},NL={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},_u={id:On,metadata:{displayName:"Aider",category:"cli",officialUrl:"https://aider.chat",shortDescription:"Open-source terminal AI pair programmer"},generators:RH,capabilities:NL,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:qk,lint:{hooks:eE,permissions:rE,mcp:nE},supportsConversion:{commands:true,agents:true},project:IH,globalSupport:{capabilities:NL,detectionPaths:[bo,Ti,ar],layout:SH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[ir],global:[bo]},canonicalDir:rk,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ao],global:[Ti]},canonicalDir:".agentsmesh",canonicalFilename:nk}},buildImportPaths:hh,detectionPaths:[ir,Ao]};});function FL(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(xi))continue;let n=r.root?"_root":basename(r.source,".md");e.push({path:`${Jr}/${n}.md`,content:r.body.trim()});}return e}function vL(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Di,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var ML=d(()=>{lm();s(FL,"generateRules");s(vL,"generateMcp");});async function $L(t,e){let r=e?.scope??"project";return Y(Ju,t,r)}var GL=d(()=>{Ot();Ry();s($L,"importFromAmazonQ");});function jL(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:xi}))}var UL=d(()=>{Ct();lm();s(jL,"lintRules");});var kH,EH,LH,OH,Ju,Ry=d(()=>{ML();GL();UL();Et();lm();kH={name:xi,generateRules:FL,generateMcp:vL,importFrom:$L},EH={managedOutputs:{dirs:[Jr],files:[Di]},paths:{rulePath(t,e){return `${Jr}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},LH={managedOutputs:{dirs:[xs],files:[am]},rewriteGeneratedPath(t){return t.startsWith(`${Jr}/`)?t.replace(`${Jr}/`,`${xs}/`):t===Di?am:t},paths:{rulePath(t,e){return `${xs}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},OH={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Ju={id:xi,metadata:{displayName:"Amazon Q Developer",category:"ide",officialUrl:"https://aws.amazon.com/q/developer",shortDescription:"AWS AI coding assistant"},generators:kH,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:jL,project:EH,globalSupport:{capabilities:OH,detectionPaths:[xs,am],layout:LH},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Jr],global:[xs]},canonicalDir:cE,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Di],global:[am]},canonicalDir:".agentsmesh",canonicalFilename:mE}},buildImportPaths:yh,detectionPaths:[Jr,Di]};});function BL(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")),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:mr,content:o}]:[]}function KL(t){return it(t,me)}function WL(t){return t.commands.map(e=>({path:`${me}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function HL(t){return t.agents.map(e=>({path:`${me}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}var zL=d(()=>{rt();Kt();ut();Lt();Ni();s(BL,"generateRules");s(KL,"generateSkills");s(WL,"generateCommands");s(HL,"generateAgents");});function dt(t,e,r){let n=r.some(o=>wH.includes(o));return t.startsWith(`${e}/`)&&!n?`.agents/skills/${t.slice(e.length+1)}`:null}var wH,ne=d(()=>{wH=["amp","antigravity","codex-cli","goose","replit-agent"];s(dt,"mirrorSkillsToAgents");});async function JL(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let i=o,a=i["amp.mcpServers"]??i.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(l[c]=m);Object.keys(l).length!==0&&(await Wt(t,VL,l),r.push({fromTool:"amp",fromPath:e,toPath:VL,feature:"mcp"}));}var VL,YL=d(()=>{A();Vr();Ni();VL=".agentsmesh/mcp.json";s(JL,"importAmpMcp");});async function XL(t,e={}){let r=e.scope??"project",n=[],o=await H("amp",t,r);return n.push(...await Y(Yu,t,r,{normalize:o})),await et(t,r==="global"?pr:me,"amp",n,o),await JL(t,r==="global"?xo:An,n),n}var ZL=d(()=>{gt();rt();Ot();YL();Ni();Iy();s(XL,"importFromAmp");});function QL(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var qL=d(()=>{Ct();Ni();s(QL,"lintRules");});function tO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function eO(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function rO(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var nO=d(()=>{wt();s(tO,"lintHooks");s(eO,"lintPermissions");s(rO,"lintIgnore");});function xH(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 n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o["amp.mcpServers"]!==void 0&&(r["amp.mcpServers"]=o["amp.mcpServers"]),JSON.stringify(r,null,2)}var bH,PH,TH,oO,Yu,Iy=d(()=>{Lt();ut();zL();ne();ZL();qL();nO();Et();Ni();bH={name:"amp",primaryRootInstructionPath:mr,generateRules:BL,generateCommands:WL,generateAgents:HL,generateSkills:KL,importFrom:XL},PH={rootInstructionPath:mr,skillDir:me,managedOutputs:{dirs:[me],files:[mr,An]},paths:{rulePath(t){return mr},commandPath(t){return `${me}/${V(t)}/SKILL.md`},agentPath(t){return `${me}/${W(t)}/SKILL.md`}}},TH={rootInstructionPath:To,skillDir:pr,managedOutputs:{dirs:[pr],files:[To,xo]},rewriteGeneratedPath(t){return t===mr?To:t===An?xo:t.startsWith(`${me}/`)?t.replace(`${me}/`,`${pr}/`):t},mirrorGlobalPath(t,e){return dt(t,pr,e)},paths:{rulePath(t){return To},commandPath(t){return `${pr}/${V(t)}/SKILL.md`},agentPath(t){return `${pr}/${W(t)}/SKILL.md`}}},oO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(xH,"mergeAmpSettings");Yu={id:"amp",metadata:{displayName:"Amp",category:"cli",officialUrl:"https://ampcode.com",shortDescription:"Sourcegraph's coding agent"},generators:bH,capabilities:oO,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:QL,lint:{hooks:tO,permissions:eO,ignore:rO},supportsConversion:{commands:true,agents:true},project:PH,globalSupport:{capabilities:oO,detectionPaths:[To,xo],layout:TH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[mr],global:[To]},canonicalDir:uE,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:An,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===An||n===xo?xH(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Rh,detectionPaths:[mr,An],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function sO(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:ur,content:e.body.trim()||""}];for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("antigravity"))continue;let o=basename(n.source,".md");r.push({path:`${Yr}/${o}.md`,content:n.body.trim()||""});}return r}function iO(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
59
61
 
60
- ${n}`:n||r;return {path:`${An}/${e.name}.md`,content:o}})}function tO(t){return rt(t,zr)}function eO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:im,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function rO(t){return t.agents.map(e=>({path:`${zr}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function nO(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("antigravity"));return lt(e?.body.trim()??"",r)}var oO=d(()=>{tt();Ut();mt();Fi();s(QL,"generateRules");s(qL,"generateCommands");s(tO,"generateSkills");s(eO,"generateMcp");s(rO,"generateAgents");s(nO,"renderAntigravityGlobalInstructions");});function _H(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function oo(t){let e=jC(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await O(join(t.projectRoot,t.rulesDir));for(let n of e.rules){let o=_H(n.source);if(o===null||o==="rules/_root.md")continue;let i=join(t.projectRoot,".agentsmesh",o),a=t.normalize(n.body,t.sourcePath,i),{frontmatter:l,body:c}=b(a),m=await K(i,{...l,root:false,description:n.description||void 0,globs:n.globs.length>0?n.globs:void 0,targets:n.targets.length>0?n.targets:void 0},c);await I(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var Hl=d(()=>{w();j();Ut();ut();s(_H,"canonicalRulePath");s(oo,"splitEmbeddedRulesToCanonical");});async function RH(t,e,r,n){let o=n==="global"?wn:ar,i=n==="project"?[o,sm]:[o];for(let a of i){let l=join(t,a),c=await _(l);if(c===null)continue;let m=join(t,ih),p=await oo({content:c,projectRoot:t,rulesDir:Ni,sourcePath:l,fromTool:Di,normalize:r});e.push(...p.results);let{body:u}=b(r(p.rootContent,l,m)),f=await K(m,{root:true},u);await O(join(t,Ni)),await I(m,f),e.push({fromTool:Di,fromPath:l,toPath:ih,feature:"rules"});return}}async function iO(t,e={}){let r=e.scope??"project",n=[],o=await B(Di,t,r);return await RH(t,n,o,r),n.push(...await J(Mu,t,r,{normalize:o})),await q(t,r==="global"?bn:zr,Di,n,o),n}var aO=d(()=>{dt();w();j();tt();Et();ut();Hl();Fi();ly();s(RH,"importRootRule");s(iO,"importFromAntigravity");});var mO,pO,uO=d(()=>{j();ut();Fi();mO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Ni}/${t}`,content:await K(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"nonRootRuleMapper"),pO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${lu}/${t}`,content:await _t(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function dO(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Di}))}var fO=d(()=>{It();Fi();s(dO,"lintRules");});var IH,SH,CH,kH,Mu,ly=d(()=>{wi();mt();oO();Fi();aO();uO();fO();Ct();IH={name:"antigravity",primaryRootInstructionPath:ar,generateRules:QL,generateCommands:qL,generateAgents:rO,generateSkills:tO,generateMcp:eO,importFrom:iO},SH={rootInstructionPath:ar,skillDir:".agents/skills",managedOutputs:{dirs:[Hr,An,zr],files:[ar]},rewriteGeneratedPath(t){return t===im?null:t},paths:{rulePath(t,e){return `${Hr}/${t}.md`},commandPath(t,e){return `${An}/${t}.md`},agentPath(t){return `${zr}/${U(t)}/SKILL.md`}}},CH={rootInstructionPath:wn,renderPrimaryRootInstruction:nO,skillDir:bn,managedOutputs:{dirs:[bn,am],files:[wn,fl]},rewriteGeneratedPath(t){return t===ar?wn:t.startsWith(`${Hr}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",bn):t.startsWith(`${An}/`)?t.replace(An,am):t===im?fl:t},paths:{rulePath(t,e){return wn},commandPath(t,e){return `${am}/${t}.md`},agentPath(t){return `${bn}/${U(t)}/SKILL.md`}}},kH={rules:"native",additionalRules:"embedded",commands:Gr("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Mu={id:"antigravity",metadata:{displayName:"Antigravity",category:"ide",officialUrl:"https://antigravity.google",shortDescription:"Google's agentic IDE"},generators:IH,capabilities:{rules:"native",additionalRules:"native",commands:Gr("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:dO,project:SH,globalSupport:{capabilities:kH,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:CH},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Hr]},canonicalDir:Ni,extensions:[".md"],map:mO},commands:{feature:"commands",mode:"directory",source:{project:[An],global:[am]},canonicalDir:lu,extensions:[".md"],map:pO},mcp:{feature:"mcp",mode:"flatFile",source:{global:[fl]},canonicalDir:".agentsmesh",canonicalFilename:aE}},buildImportPaths:ah,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"],conversionDefaults:{agentsToSkills:true}};});function LH(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 OH(t){let e={};return t.description&&(e.description=t.description),e}function gO(t){let e=[];for(let r of t.rules)if(!(r.targets.length>0&&!r.targets.includes(ce)))if(r.root){let n={always_apply:true};r.description&&(n.description=r.description),e.push({path:`${De}/_root.md`,content:T(n,r.body.trim())});}else {let n=basename(r.source,".md");e.push({path:`${De}/${n}.md`,content:T(LH(r),r.body.trim())});}return e}function hO(t){return t.commands.map(e=>({path:`${lr}/${e.name}.md`,content:T(OH(e),e.body.trim())}))}function yO(t){return rt(t,Ne)}function _O(t){return t.ignore.length===0?[]:[{path:Tn,content:t.ignore.join(`
61
- `)}]}var RO=d(()=>{tt();j();vi();s(LH,"ruleFrontmatter");s(OH,"commandFrontmatter");s(gO,"generateRules");s(hO,"generateCommands");s(yO,"generateSkills");s(_O,"generateIgnore");});function wH(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:".*",c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=typeof m.command=="string"?m.command:void 0;if(!p)continue;let u={matcher:l,type:"command",command:p};typeof m.timeout=="number"&&(u.timeout=m.timeout),o.push(u);}}o.length>0&&(e[r]=o);}return e}async function SO(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o.mcpServers&&typeof o.mcpServers=="object"){let a=o.mcpServers;await Bt(t,ch,a),r.push({fromTool:ce,fromPath:join(t,e),toPath:ch,feature:"mcp"});}let i=o.hooks;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=wH(i);if(Object.keys(a).length>0){let l=join(t,mh);await O(dirname(l)),await I(l,stringify(a)),r.push({fromTool:ce,fromPath:join(t,e),toPath:mh,feature:"hooks"});}}}async function CO(t,e,r){let n=await _(join(t,e));if(n===null)return;let o=n.split(`
62
- `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"));if(o.length===0)return;let i=join(t,ph);await O(dirname(i)),await I(i,o.join(`
63
- `)),r.push({fromTool:ce,fromPath:join(t,e),toPath:ph,feature:"ignore"});}var kO=d(()=>{w();Kr();vi();s(wH,"augmentHooksToCanonical");s(SO,"importAugmentSettings");s(CO,"importAugmentIgnore");});function bH(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 PH(t,e,r,n){let o=n==="global"?To:De,i=join(t,lh);e.push(...await Rt({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:ce,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=a==="_root.md"||basename(a)==="_root.md",m=join(i,a),{frontmatter:p,body:u}=b(l(m));return {destPath:m,toPath:`${lh}/${a}`,feature:"rules",content:await K(m,bH(p,c),u)}},"mapEntry")}));}async function TH(t,e,r,n){let o=n==="global"?xo:lr,i=join(t,".agentsmesh/commands");e.push(...await Rt({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:ce,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=basename(a,".md"),m=join(i,`${c}.md`),{frontmatter:p,body:u}=b(l(m)),f=typeof p.description=="string"?p.description:"";return {destPath:m,toPath:`.agentsmesh/commands/${c}.md`,feature:"commands",content:await _t(m,{description:f,hasDescription:true,hasAllowedTools:false},u)}},"mapEntry")}));}async function LO(t,e={}){let r=e.scope??"project",n=[],o=await B(ce,t,r);return await PH(t,n,o,r),await TH(t,n,o,r),await q(t,r==="global"?xn:Ne,ce,n,o),await SO(t,r==="global"?Do:Pn,n),r==="project"&&await CO(t,Tn,n),n}var OO=d(()=>{dt();xe();tt();ut();j();kO();vi();s(bH,"canonicalRuleMeta");s(PH,"importRules");s(TH,"importCommands");s(LO,"importFromAugmentCode");});function AO(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ce}))}var wO=d(()=>{It();vi();s(AO,"lintRules");});function PO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=new Set(bO);return Object.keys(t.hooks).filter(r=>!e.has(r)).map(r=>Ps(r,"augment-code",bO,{unsupportedBy:"AugmentCode hooks"}))}var bO,TO=d(()=>{Lt();bO=["PreToolUse","PostToolUse","SessionStart","SessionEnd","Stop"];s(PO,"lintHooks");});function DH(t){let e={};for(let[r,n]of Object.entries(t)){if(!n||n.length===0)continue;let o=n.map(i=>({matcher:i.matcher,hooks:[{type:"command",command:i.command,...i.timeout!==void 0?{timeout:i.timeout}:{}}]}));e[r]=o;}return e}function NH(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 n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o.mcpServers!==void 0&&(r.mcpServers=o.mcpServers),o.hooks!==void 0&&(r.hooks=o.hooks),JSON.stringify(r,null,2)}function FH(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=DH(t.hooks)),Object.keys(e).length===0?null:JSON.stringify(e,null,2)}var xH,vH,MH,$H,GH,xO,DO=d(()=>{RO();OO();wO();TO();Ct();vi();xH={name:ce,generateRules:gO,generateCommands:hO,generateSkills:yO,generateIgnore:_O,importFrom:LO};s(DH,"serializeHooksForSettings");s(NH,"mergeAugmentSettings");s(FH,"buildSettingsContent");vH={skillDir:Ne,managedOutputs:{dirs:[De,lr,Ne],files:[Pn,Tn]},paths:{rulePath(t){return `${De}/${t}.md`},commandPath(t){return `${lr}/${t}.md`},agentPath(t){return null}}},MH={skillDir:xn,managedOutputs:{dirs:[To,xo,xn],files:[Do]},rewriteGeneratedPath(t){return t.startsWith(`${De}/`)?t.replace(`${De}/`,`${To}/`):t.startsWith(`${lr}/`)?t.replace(`${lr}/`,`${xo}/`):t.startsWith(`${Ne}/`)?t.replace(`${Ne}/`,`${xn}/`):t===Pn?Do:t===Tn?null:t},paths:{rulePath(t){return `${To}/${t}.md`},commandPath(t){return `${xo}/${t}.md`},agentPath(t){return null}}},$H={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},GH={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},xO={id:ce,metadata:{displayName:"Augment Code",category:"ide",officialUrl:"https://www.augmentcode.com",shortDescription:"Codebase-aware AI for IDEs"},generators:xH,capabilities:$H,emptyImportMessage:"No AugmentCode config found (.augment/rules, .augment/commands, .augment/skills, .augment/settings.json, or .augmentignore).",lintRules:AO,lint:{hooks:PO},project:vH,globalSupport:{capabilities:GH,detectionPaths:[To,xo,xn,Do],layout:MH},emitScopedSettings(t){let e=FH(t);return e===null?[]:[{path:Pn,content:e}]},mergeGeneratedOutputContent(t,e,r,n){return n===Pn||n===Do?NH(t,r):null},buildImportPaths:uh,detectionPaths:[De,lr,Ne,Pn,Tn]};});function NO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Sn(i))continue;let a=zt(i),l=he(i),c=i.type==="prompt"?l||a:a||l,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:c};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var FO=d(()=>{Mr();s(NO,"buildClaudeHooksObjectFromCanonical");});function vO(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:xs,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("claude-code")));for(let o of n){let i=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=T(a,o.body.trim()||"");e.push({path:`${lm}/${i}.md`,content:l});}return e}function MO(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 n=T(r,e.body.trim()||"");return {path:`${cm}/${e.name}.md`,content:n}})}function $O(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 n=e.body.trim()||"",o=/^##\s*Role\b/m.test(n)?n:`## Role
62
+ ${n}`:n||r;return {path:`${bn}/${e.name}.md`,content:o}})}function aO(t){return it(t,Xr)}function lO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:mm,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function cO(t){return t.agents.map(e=>({path:`${Xr}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function mO(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("antigravity"));return mt(e?.body.trim()??"",r)}var pO=d(()=>{rt();Kt();ut();Mi();s(sO,"generateRules");s(iO,"generateCommands");s(aO,"generateSkills");s(lO,"generateMcp");s(cO,"generateAgents");s(mO,"renderAntigravityGlobalInstructions");});function NH(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function io(t){let e=VC(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await O(join(t.projectRoot,t.rulesDir));for(let n of e.rules){let o=NH(n.source);if(o===null||o==="rules/_root.md")continue;let i=join(t.projectRoot,".agentsmesh",o),a=t.normalize(n.body,t.sourcePath,i),{frontmatter:l,body:c}=b(a),m=await z(i,{...l,root:false,description:n.description||void 0,globs:n.globs.length>0?n.globs:void 0,targets:n.targets.length>0?n.targets:void 0},c);await S(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var zl=d(()=>{A();K();Kt();ft();s(NH,"canonicalRulePath");s(io,"splitEmbeddedRulesToCanonical");});async function FH(t,e,r,n){let o=n==="global"?Pn:ur,i=n==="project"?[o,cm]:[o];for(let a of i){let l=join(t,a),c=await _(l);if(c===null)continue;let m=join(t,Ih),p=await io({content:c,projectRoot:t,rulesDir:vi,sourcePath:l,fromTool:Fi,normalize:r});e.push(...p.results);let{body:u}=b(r(p.rootContent,l,m)),f=await z(m,{root:true},u);await O(join(t,vi)),await S(m,f),e.push({fromTool:Fi,fromPath:l,toPath:Ih,feature:"rules"});return}}async function dO(t,e={}){let r=e.scope??"project",n=[],o=await H(Fi,t,r);return await FH(t,n,o,r),n.push(...await Y(Xu,t,r,{normalize:o})),await et(t,r==="global"?Tn:Xr,Fi,n,o),n}var fO=d(()=>{gt();A();K();rt();Ot();ft();zl();Mi();Cy();s(FH,"importRootRule");s(dO,"importFromAntigravity");});var yO,_O,RO=d(()=>{K();ft();Mi();yO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${vi}/${t}`,content:await z(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"nonRootRuleMapper"),_O=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Su}/${t}`,content:await It(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function IO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Fi}))}var SO=d(()=>{Ct();Mi();s(IO,"lintRules");});var vH,MH,$H,GH,Xu,Cy=d(()=>{Pi();ut();pO();Mi();fO();RO();SO();Et();vH={name:"antigravity",primaryRootInstructionPath:ur,generateRules:sO,generateCommands:iO,generateAgents:cO,generateSkills:aO,generateMcp:lO,importFrom:dO},MH={rootInstructionPath:ur,skillDir:".agents/skills",managedOutputs:{dirs:[Yr,bn,Xr],files:[ur]},rewriteGeneratedPath(t){return t===mm?null:t},paths:{rulePath(t,e){return `${Yr}/${t}.md`},commandPath(t,e){return `${bn}/${t}.md`},agentPath(t){return `${Xr}/${W(t)}/SKILL.md`}}},$H={rootInstructionPath:Pn,renderPrimaryRootInstruction:mO,skillDir:Tn,managedOutputs:{dirs:[Tn,pm],files:[Pn,gl]},rewriteGeneratedPath(t){return t===ur?Pn:t.startsWith(`${Yr}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",Tn):t.startsWith(`${bn}/`)?t.replace(bn,pm):t===mm?gl:t},paths:{rulePath(t,e){return Pn},commandPath(t,e){return `${pm}/${t}.md`},agentPath(t){return `${Tn}/${W(t)}/SKILL.md`}}},GH={rules:"native",additionalRules:"embedded",commands:Kr("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Xu={id:"antigravity",metadata:{displayName:"Antigravity",category:"ide",officialUrl:"https://antigravity.google",shortDescription:"Google's agentic IDE"},generators:vH,capabilities:{rules:"native",additionalRules:"native",commands:Kr("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:IO,project:MH,globalSupport:{capabilities:GH,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:$H},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Yr]},canonicalDir:vi,extensions:[".md"],map:yO},commands:{feature:"commands",mode:"directory",source:{project:[bn],global:[pm]},canonicalDir:Su,extensions:[".md"],map:_O},mcp:{feature:"mcp",mode:"flatFile",source:{global:[gl]},canonicalDir:".agentsmesh",canonicalFilename:fE}},buildImportPaths:Sh,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"],conversionDefaults:{agentsToSkills:true}};});function UH(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 BH(t){let e={};return t.description&&(e.description=t.description),e}function CO(t){let e=[];for(let r of t.rules)if(!(r.targets.length>0&&!r.targets.includes(pe)))if(r.root){let n={always_apply:true};r.description&&(n.description=r.description),e.push({path:`${$e}/_root.md`,content:T(n,r.body.trim())});}else {let n=basename(r.source,".md");e.push({path:`${$e}/${n}.md`,content:T(UH(r),r.body.trim())});}return e}function kO(t){return t.commands.map(e=>({path:`${dr}/${e.name}.md`,content:T(BH(e),e.body.trim())}))}function EO(t){return it(t,Ge)}function LO(t){return t.ignore.length===0?[]:[{path:Dn,content:t.ignore.join(`
63
+ `)}]}var OO=d(()=>{rt();K();$i();s(UH,"ruleFrontmatter");s(BH,"commandFrontmatter");s(CO,"generateRules");s(kO,"generateCommands");s(EO,"generateSkills");s(LO,"generateIgnore");});function WH(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:".*",c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=typeof m.command=="string"?m.command:void 0;if(!p)continue;let u={matcher:l,type:"command",command:p};typeof m.timeout=="number"&&(u.timeout=m.timeout),o.push(u);}}o.length>0&&(e[r]=o);}return e}async function AO(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o.mcpServers&&typeof o.mcpServers=="object"){let a=o.mcpServers;await Wt(t,kh,a),r.push({fromTool:pe,fromPath:join(t,e),toPath:kh,feature:"mcp"});}let i=o.hooks;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=WH(i);if(Object.keys(a).length>0){let l=join(t,Eh);await O(dirname(l)),await S(l,stringify(a)),r.push({fromTool:pe,fromPath:join(t,e),toPath:Eh,feature:"hooks"});}}}async function bO(t,e,r){let n=await _(join(t,e));if(n===null)return;let o=n.split(`
64
+ `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"));if(o.length===0)return;let i=join(t,Lh);await O(dirname(i)),await S(i,o.join(`
65
+ `)),r.push({fromTool:pe,fromPath:join(t,e),toPath:Lh,feature:"ignore"});}var PO=d(()=>{A();Vr();$i();s(WH,"augmentHooksToCanonical");s(AO,"importAugmentSettings");s(bO,"importAugmentIgnore");});function HH(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 zH(t,e,r,n){let o=n==="global"?Do:$e,i=join(t,Ch);e.push(...await St({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:pe,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=a==="_root.md"||basename(a)==="_root.md",m=join(i,a),{frontmatter:p,body:u}=b(l(m));return {destPath:m,toPath:`${Ch}/${a}`,feature:"rules",content:await z(m,HH(p,c),u)}},"mapEntry")}));}async function VH(t,e,r,n){let o=n==="global"?No:dr,i=join(t,".agentsmesh/commands");e.push(...await St({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:pe,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=basename(a,".md"),m=join(i,`${c}.md`),{frontmatter:p,body:u}=b(l(m)),f=typeof p.description=="string"?p.description:"";return {destPath:m,toPath:`.agentsmesh/commands/${c}.md`,feature:"commands",content:await It(m,{description:f,hasDescription:true,hasAllowedTools:false},u)}},"mapEntry")}));}async function xO(t,e={}){let r=e.scope??"project",n=[],o=await H(pe,t,r);return await zH(t,n,o,r),await VH(t,n,o,r),await et(t,r==="global"?Nn:Ge,pe,n,o),await AO(t,r==="global"?Fo:xn,n),r==="project"&&await bO(t,Dn,n),n}var DO=d(()=>{gt();Me();rt();ft();K();PO();$i();s(HH,"canonicalRuleMeta");s(zH,"importRules");s(VH,"importCommands");s(xO,"importFromAugmentCode");});function NO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:pe}))}var FO=d(()=>{Ct();$i();s(NO,"lintRules");});function MO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=new Set(vO);return Object.keys(t.hooks).filter(r=>!e.has(r)).map(r=>Ts(r,"augment-code",vO,{unsupportedBy:"AugmentCode hooks"}))}var vO,$O=d(()=>{wt();vO=["PreToolUse","PostToolUse","SessionStart","SessionEnd","Stop"];s(MO,"lintHooks");});function YH(t){let e={};for(let[r,n]of Object.entries(t)){if(!n||n.length===0)continue;let o=n.map(i=>({matcher:i.matcher,hooks:[{type:"command",command:i.command,...i.timeout!==void 0?{timeout:i.timeout}:{}}]}));e[r]=o;}return e}function XH(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 n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o.mcpServers!==void 0&&(r.mcpServers=o.mcpServers),o.hooks!==void 0&&(r.hooks=o.hooks),JSON.stringify(r,null,2)}function ZH(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=YH(t.hooks)),Object.keys(e).length===0?null:JSON.stringify(e,null,2)}var JH,QH,qH,tz,ez,GO,jO=d(()=>{OO();DO();FO();$O();Et();$i();JH={name:pe,generateRules:CO,generateCommands:kO,generateSkills:EO,generateIgnore:LO,importFrom:xO};s(YH,"serializeHooksForSettings");s(XH,"mergeAugmentSettings");s(ZH,"buildSettingsContent");QH={skillDir:Ge,managedOutputs:{dirs:[$e,dr,Ge],files:[xn,Dn]},paths:{rulePath(t){return `${$e}/${t}.md`},commandPath(t){return `${dr}/${t}.md`},agentPath(t){return null}}},qH={skillDir:Nn,managedOutputs:{dirs:[Do,No,Nn],files:[Fo]},rewriteGeneratedPath(t){return t.startsWith(`${$e}/`)?t.replace(`${$e}/`,`${Do}/`):t.startsWith(`${dr}/`)?t.replace(`${dr}/`,`${No}/`):t.startsWith(`${Ge}/`)?t.replace(`${Ge}/`,`${Nn}/`):t===xn?Fo:t===Dn?null:t},paths:{rulePath(t){return `${Do}/${t}.md`},commandPath(t){return `${No}/${t}.md`},agentPath(t){return null}}},tz={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},ez={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},GO={id:pe,metadata:{displayName:"Augment Code",category:"ide",officialUrl:"https://www.augmentcode.com",shortDescription:"Codebase-aware AI for IDEs"},generators:JH,capabilities:tz,emptyImportMessage:"No AugmentCode config found (.augment/rules, .augment/commands, .augment/skills, .augment/settings.json, or .augmentignore).",lintRules:NO,lint:{hooks:MO},project:QH,globalSupport:{capabilities:ez,detectionPaths:[Do,No,Nn,Fo],layout:qH},emitScopedSettings(t){let e=ZH(t);return e===null?[]:[{path:xn,content:e}]},mergeGeneratedOutputContent(t,e,r,n){return n===xn||n===Fo?XH(t,r):null},buildImportPaths:Oh,detectionPaths:[$e,dr,Ge,xn,Dn]};});function UO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!kn(i))continue;let a=Vt(i),l=ye(i),c=i.type==="prompt"?l||a:a||l,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:c};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var BO=d(()=>{Ur();s(UO,"buildClaudeHooksObjectFromCanonical");});function KO(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Ds,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("claude-code")));for(let o of n){let i=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=T(a,o.body.trim()||"");e.push({path:`${um}/${i}.md`,content:l});}return e}function WO(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 n=T(r,e.body.trim()||"");return {path:`${dm}/${e.name}.md`,content:n}})}function HO(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 n=e.body.trim()||"",o=/^##\s*Role\b/m.test(n)?n:`## Role
64
66
 
65
- ${n}`,i=T(r,o);return {path:`${mm}/${e.name}.md`,content:i}})}function GO(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:gl,content:e}]}function jO(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=r.body.trim()||"",i=!o||/^##\s*Purpose\b/m.test(o)?o:`## Purpose
67
+ ${n}`,i=T(r,o);return {path:`${fm}/${e.name}.md`,content:i}})}function zO(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:hl,content:e}]}function VO(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=r.body.trim()||"",i=!o||/^##\s*Purpose\b/m.test(o)?o:`## Purpose
66
68
 
67
- ${o}`,a=T(n,i);e.push({path:`${pm}/${r.name}/SKILL.md`,content:a});for(let l of r.supportingFiles){let c=l.relativePath.replace(/\\/g,"/");e.push({path:`${pm}/${r.name}/${c}`,content:l.content});}}return e}function UO(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];if(e.length===0&&r.length===0&&n.length===0)return [];let o=JSON.stringify({permissions:{allow:e,deny:r,ask:n}},null,2);return [{path:um,content:o}]}function BO(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=NO(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:No,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:um,content:n}]}function KO(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
68
- `);return [{path:dm,content:e}]}var WO=d(()=>{j();Fo();FO();s(vO,"generateRules");s(MO,"generateCommands");s($O,"generateAgents");s(GO,"generateMcp");s(jO,"generateSkills");s(UO,"generatePermissions");s(BO,"generateHooks");s(KO,"generateIgnore");});function BH(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function HO(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
69
+ ${o}`,a=T(n,i);e.push({path:`${gm}/${r.name}/SKILL.md`,content:a});for(let l of r.supportingFiles){let c=l.relativePath.replace(/\\/g,"/");e.push({path:`${gm}/${r.name}/${c}`,content:l.content});}}return e}function JO(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];if(e.length===0&&r.length===0&&n.length===0)return [];let o=JSON.stringify({permissions:{allow:e,deny:r,ask:n}},null,2);return [{path:hm,content:o}]}function YO(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=UO(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:vo,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:hm,content:n}]}function XO(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
70
+ `);return [{path:ym,content:e}]}var ZO=d(()=>{K();Mo();BO();s(KO,"generateRules");s(WO,"generateCommands");s(HO,"generateAgents");s(zO,"generateMcp");s(VO,"generateSkills");s(JO,"generatePermissions");s(YO,"generateHooks");s(XO,"generateIgnore");});function oz(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function QO(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
69
71
 
70
- ## ${e?BH(e):"Guidance"}
72
+ ## ${e?oz(e):"Guidance"}
71
73
 
72
74
  ${r}
73
- `:""}var zO=d(()=>{s(BH,"ruleSectionTitle");s(HO,"renderClaudeGlobalPrimaryInstructions");});function JO(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function YO(t,e,r,n){if(r!=="global")return [];let o=n.has("agents"),i=n.has("commands");if(!o&&!i)return [];let a=[];if(o)for(let l of t.agents){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=T(c,l.body.trim()),p=`${dh}/${l.name}.md`,u=await _(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:JO(u,m)});}if(i)for(let l of t.commands){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=T(c,l.body.trim()),p=`${dh}/${l.name}.md`,u=await _(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:JO(u,m)});}return a}var XO=d(()=>{w();j();Fo();s(JO,"computeStatus");s(YO,"generateClaudeGlobalExtras");});function ZO(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!Sn({...m,type:p}))continue;let u=p==="prompt"?he(m)||zt(m):zt(m)||he(m),f={matcher:l,type:p,command:u};typeof m.timeout=="number"&&(f.timeout=m.timeout),o.push(f);}}o.length>0&&(e[r]=o);}return e}async function QO(t,e){let r=join(t,No),n=await _(r);if(n===null)return false;let o;try{o=JSON.parse(n);}catch{return false}if(!o||typeof o!="object"||Array.isArray(o))return false;let i=ZO(o);if(Object.keys(i).length===0)return false;let a=stringify(i),l=join(t,Mi);return await O(dirname(l)),await I(l,a),e.push({fromTool:"claude-code",fromPath:r,toPath:Mi,feature:"hooks"}),true}async function qO(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(No)),n=join(t,um),o=await _(n);if(!o)return;let i;try{i=JSON.parse(o);}catch{return}if(!e.some(m=>m.feature==="mcp")&&i.mcpServers&&typeof i.mcpServers=="object"){let m=i.mcpServers;await Bt(t,hm,m),e.push({fromTool:"claude-code",fromPath:n,toPath:hm,feature:"mcp"});}let l=i.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let m=l,p=Array.isArray(m.allow)?m.allow.filter(g=>typeof g=="string"):[],u=Array.isArray(m.deny)?m.deny.filter(g=>typeof g=="string"):[],f=Array.isArray(m.ask)?m.ask.filter(g=>typeof g=="string"):[];if(p.length>0||u.length>0||f.length>0){let g=stringify({allow:p,deny:u,ask:f}),h=join(t,gh);await O(dirname(h)),await I(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:gh,feature:"permissions"});}}let c=i.hooks;if(!r&&c&&typeof c=="object"&&!Array.isArray(c)){let m=ZO(c);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,Mi);await O(dirname(u)),await I(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:Mi,feature:"hooks"});}}}var tA=d(()=>{Mr();w();Kr();Fo();s(ZO,"claudeHooksToCanonical");s(QO,"importClaudeHooksJson");s(qO,"importSettings");});async function rA(t,e,r){let n=join(t,pm),o=join(t,fh),a=(await v(n)).filter(l=>l.endsWith("SKILL.md"));for(let l of a){let c=dirname(l),m=basename(c),p=join(o,m),u=await _(l);if(u===null)continue;let f=r(u,l,join(p,"SKILL.md")),g=Fr(f,l);if(!g.ok){process.stderr.write(`\u26A0 skipping ${l}: ${g.error.message}
74
- `);continue}let h=await v(c);for(let R of h){let C=await _(R);if(C===null)continue;let S=relative(c,R),k=join(p,S);await O(dirname(k));let P=r(C,R,k);await I(k,S==="SKILL.md"?await Cn(k,g.value.frontmatter,g.value.body):P);let N=`${fh}/${m}/${S}`;e.push({fromTool:"claude-code",fromPath:R,toPath:N,feature:"skills"});}}}var nA=d(()=>{w();j();ut();Fo();s(rA,"importClaudeSkills");});async function oA(t,e={}){let r=e.scope??"project",n=[],o=await B("claude-code",t,r);return n.push(...await J($u,t,r,{normalize:o})),await rA(t,n,o),await QO(t,n),await qO(t,n),n}var sA=d(()=>{dt();Et();tA();nA();py();s(oA,"importFromClaudeCode");});var iA,aA,lA,cA=d(()=>{j();ut();or();Fo();iA=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${gm}/${t}`,content:await K(n,{...o,root:false},i)}},"claudeRuleMapper"),aA=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n)),a=nr(o.allowedTools),l=a.length>0?a:nr(o["allowed-tools"]);return {destPath:n,toPath:`${pu}/${t}`,content:await _t(n,{description:typeof o.description=="string"?o.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"claudeCommandMapper"),lA=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${uu}/${t}`,content:await Vt(n,o,i)}},"claudeAgentMapper");});function mA(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:mE}))}var pA=d(()=>{It();Fo();s(mA,"lintRules");});var HH,uA,zH,VH,$u,py=d(()=>{WO();Fo();ee();zO();XO();sA();cA();pA();Ct();HH={name:"claude-code",primaryRootInstructionPath:xs,generateRules:vO,generateCommands:MO,generateAgents:$O,generateSkills:jO,generateMcp:GO,generatePermissions:UO,generateHooks:BO,generateIgnore:KO,importFrom:oA},uA={rootInstructionPath:xs,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`}}},zH={rootInstructionPath:xs,skillDir:".claude/skills",renderPrimaryRootInstruction:HO,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",fm,No,".claudeignore"]},rewriteGeneratedPath(t){return t===gl?fm:t},mirrorGlobalPath(t,e){return pt(t,".claude/skills",e)},paths:uA.paths},VH={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},$u={id:"claude-code",metadata:{displayName:"Claude Code",category:"cli",officialUrl:"https://www.anthropic.com/claude-code",shortDescription:"Anthropic's terminal coding agent"},generators:HH,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:mA,project:uA,globalSupport:{capabilities:VH,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:zH,scopeExtras:YO},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[xs,pE],global:[xs]},canonicalDir:gm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[lm],global:[lm]},canonicalDir:gm,extensions:[".md"],map:iA}],commands:{feature:"commands",mode:"directory",source:{project:[cm],global:[cm]},canonicalDir:pu,extensions:[".md"],map:aA},agents:{feature:"agents",mode:"directory",source:{project:[mm],global:[mm]},canonicalDir:uu,extensions:[".md"],map:lA},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[gl],global:[fm]},canonicalDir:".agentsmesh",canonicalFilename:hm},ignore:{feature:"ignore",mode:"flatFile",source:{project:[dm],global:[dm]},canonicalDir:".agentsmesh",canonicalFilename:uE}},buildImportPaths:hh,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function YH(t){let e=basename(t,".md");return e==="_root"?"root":e}function dA(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:Ns,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=YH(n.source),i={description:n.description||void 0,paths:n.globs.length>0?n.globs:void 0};Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l];});let a=Object.keys(i).length>0?T(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${vo}/${o}.md`,content:a});}return e}function fA(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
75
+ `:""}var qO=d(()=>{s(oz,"ruleSectionTitle");s(QO,"renderClaudeGlobalPrimaryInstructions");});function ew(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function rw(t,e,r,n){if(r!=="global")return [];let o=n.has("agents"),i=n.has("commands");if(!o&&!i)return [];let a=[];if(o)for(let l of t.agents){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=T(c,l.body.trim()),p=`${wh}/${l.name}.md`,u=await _(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:ew(u,m)});}if(i)for(let l of t.commands){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=T(c,l.body.trim()),p=`${wh}/${l.name}.md`,u=await _(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:ew(u,m)});}return a}var nw=d(()=>{A();K();Mo();s(ew,"computeStatus");s(rw,"generateClaudeGlobalExtras");});function ow(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!kn({...m,type:p}))continue;let u=p==="prompt"?ye(m)||Vt(m):Vt(m)||ye(m),f={matcher:l,type:p,command:u};typeof m.timeout=="number"&&(f.timeout=m.timeout),o.push(f);}}o.length>0&&(e[r]=o);}return e}async function sw(t,e){let r=join(t,vo),n=await _(r);if(n===null)return false;let o;try{o=JSON.parse(n);}catch{return false}if(!o||typeof o!="object"||Array.isArray(o))return false;let i=ow(o);if(Object.keys(i).length===0)return false;let a=stringify(i),l=join(t,Gi);return await O(dirname(l)),await S(l,a),e.push({fromTool:"claude-code",fromPath:r,toPath:Gi,feature:"hooks"}),true}async function iw(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(vo)),n=join(t,hm),o=await _(n);if(!o)return;let i;try{i=JSON.parse(o);}catch{return}if(!e.some(m=>m.feature==="mcp")&&i.mcpServers&&typeof i.mcpServers=="object"){let m=i.mcpServers;await Wt(t,Im,m),e.push({fromTool:"claude-code",fromPath:n,toPath:Im,feature:"mcp"});}let l=i.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let m=l,p=Array.isArray(m.allow)?m.allow.filter(g=>typeof g=="string"):[],u=Array.isArray(m.deny)?m.deny.filter(g=>typeof g=="string"):[],f=Array.isArray(m.ask)?m.ask.filter(g=>typeof g=="string"):[];if(p.length>0||u.length>0||f.length>0){let g=stringify({allow:p,deny:u,ask:f}),h=join(t,bh);await O(dirname(h)),await S(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:bh,feature:"permissions"});}}let c=i.hooks;if(!r&&c&&typeof c=="object"&&!Array.isArray(c)){let m=ow(c);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,Gi);await O(dirname(u)),await S(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:Gi,feature:"hooks"});}}}var aw=d(()=>{Ur();A();Vr();Mo();s(ow,"claudeHooksToCanonical");s(sw,"importClaudeHooksJson");s(iw,"importSettings");});async function cw(t,e,r){let n=join(t,gm),o=join(t,Ah),a=(await $(n)).filter(l=>l.endsWith("SKILL.md"));for(let l of a){let c=dirname(l),m=basename(c),p=join(o,m),u=await _(l);if(u===null)continue;let f=r(u,l,join(p,"SKILL.md")),g=Gr(f,l);if(!g.ok){process.stderr.write(`\u26A0 skipping ${l}: ${g.error.message}
76
+ `);continue}let h=await $(c);for(let I of h){let k=await _(I);if(k===null)continue;let C=relative(c,I),R=join(p,C);await O(dirname(R));let P=r(k,I,R);await S(R,C==="SKILL.md"?await En(R,g.value.frontmatter,g.value.body):P);let N=`${Ah}/${m}/${C}`;e.push({fromTool:"claude-code",fromPath:I,toPath:N,feature:"skills"});}}}var mw=d(()=>{A();K();ft();Mo();s(cw,"importClaudeSkills");});async function pw(t,e={}){let r=e.scope??"project",n=[],o=await H("claude-code",t,r);return n.push(...await Y(Zu,t,r,{normalize:o})),await cw(t,n,o),await sw(t,n),await iw(t,n),n}var uw=d(()=>{gt();Ot();aw();mw();Ly();s(pw,"importFromClaudeCode");});var dw,fw,gw,hw=d(()=>{K();ft();cr();Mo();dw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Rm}/${t}`,content:await z(n,{...o,root:false},i)}},"claudeRuleMapper"),fw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n)),a=lr(o.allowedTools),l=a.length>0?a:lr(o["allowed-tools"]);return {destPath:n,toPath:`${Eu}/${t}`,content:await It(n,{description:typeof o.description=="string"?o.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"claudeCommandMapper"),gw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Lu}/${t}`,content:await Jt(n,o,i)}},"claudeAgentMapper");});function yw(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:yE}))}var _w=d(()=>{Ct();Mo();s(yw,"lintRules");});var az,Rw,lz,cz,Zu,Ly=d(()=>{ZO();Mo();ne();qO();nw();uw();hw();_w();Et();az={name:"claude-code",primaryRootInstructionPath:Ds,generateRules:KO,generateCommands:WO,generateAgents:HO,generateSkills:VO,generateMcp:zO,generatePermissions:JO,generateHooks:YO,generateIgnore:XO,importFrom:pw},Rw={rootInstructionPath:Ds,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`}}},lz={rootInstructionPath:Ds,skillDir:".claude/skills",renderPrimaryRootInstruction:QO,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",_m,vo,".claudeignore"]},rewriteGeneratedPath(t){return t===hl?_m:t},mirrorGlobalPath(t,e){return dt(t,".claude/skills",e)},paths:Rw.paths},cz={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},Zu={id:"claude-code",metadata:{displayName:"Claude Code",category:"cli",officialUrl:"https://www.anthropic.com/claude-code",shortDescription:"Anthropic's terminal coding agent"},generators:az,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:yw,project:Rw,globalSupport:{capabilities:cz,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:lz,scopeExtras:rw},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Ds,_E],global:[Ds]},canonicalDir:Rm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[um],global:[um]},canonicalDir:Rm,extensions:[".md"],map:dw}],commands:{feature:"commands",mode:"directory",source:{project:[dm],global:[dm]},canonicalDir:Eu,extensions:[".md"],map:fw},agents:{feature:"agents",mode:"directory",source:{project:[fm],global:[fm]},canonicalDir:Lu,extensions:[".md"],map:gw},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[hl],global:[_m]},canonicalDir:".agentsmesh",canonicalFilename:Im},ignore:{feature:"ignore",mode:"flatFile",source:{project:[ym],global:[ym]},canonicalDir:".agentsmesh",canonicalFilename:RE}},buildImportPaths:Ph,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function pz(t){let e=basename(t,".md");return e==="_root"?"root":e}function Iw(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:Fs,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=pz(n.source),i={description:n.description||void 0,paths:n.globs.length>0?n.globs:void 0};Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l];});let a=Object.keys(i).length>0?T(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${$o}/${o}.md`,content:a});}return e}function Sw(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
75
77
 
76
- ${n}`:r||n;return {path:`${Dn}/${e.name}.md`,content:o}})}function gA(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
77
- `);return [{path:$i,content:e}]}function hA(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Mo,content:e}]}function yA(t){return t.agents.map(e=>({path:`${Zt}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function XH(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function dy(t){return t.replace(/[\r\n]+/g," ")}function ZH(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${dy(t)}`,`# agentsmesh-matcher: ${dy(r)}`,`# agentsmesh-command: ${dy(e)}`,"set -eu",e,""].join(`
78
- `)}function _A(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=0;for(let i of n)ko(i)&&(e.push({path:`${Gi}/${XH(r)}-${o}.sh`,content:ZH(r,i.command,i.matcher)}),o++);}return e}function RA(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${Zt}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Zt}/${r.name}/${a}`,content:i.content});}}return e}var IA=d(()=>{Mr();j();mt();cr();s(YH,"ruleSlug");s(dA,"generateRules");s(fA,"generateCommands");s(gA,"generateIgnore");s(hA,"generateMcp");s(yA,"generateAgents");s(XH,"safeEventName");s(dy,"safeShellLine");s(ZH,"buildHookScript");s(_A,"generateHooks");s(RA,"generateSkills");});async function CA(t,e,r){if(t==="workflows"||t.startsWith("workflows/"))return null;let n=t.replace(/\\/g,"/");if(n==="_root.md")return null;let o=join(e,n),{frontmatter:i,body:a}=b(r(o)),l=wo(i.paths??i.globs),c={root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${Fs}/${n}`,feature:"rules",content:await K(o,c,a)}}async function kA(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=b(r(n)),a=Object.prototype.hasOwnProperty.call(o,"description"),l=a&&typeof o.description=="string"?o.description:"",c=a,m=i;if(!c){let p=i.indexOf(`
78
+ ${n}`:r||n;return {path:`${Fn}/${e.name}.md`,content:o}})}function Cw(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
79
+ `);return [{path:ji,content:e}]}function kw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Go,content:e}]}function Ew(t){return t.agents.map(e=>({path:`${qt}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function uz(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function wy(t){return t.replace(/[\r\n]+/g," ")}function dz(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${wy(t)}`,`# agentsmesh-matcher: ${wy(r)}`,`# agentsmesh-command: ${wy(e)}`,"set -eu",e,""].join(`
80
+ `)}function Lw(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=0;for(let i of n)Lo(i)&&(e.push({path:`${Ui}/${uz(r)}-${o}.sh`,content:dz(r,i.command,i.matcher)}),o++);}return e}function Ow(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${qt}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${qt}/${r.name}/${a}`,content:i.content});}}return e}var ww=d(()=>{Ur();K();ut();fr();s(pz,"ruleSlug");s(Iw,"generateRules");s(Sw,"generateCommands");s(Cw,"generateIgnore");s(kw,"generateMcp");s(Ew,"generateAgents");s(uz,"safeEventName");s(wy,"safeShellLine");s(dz,"buildHookScript");s(Lw,"generateHooks");s(Ow,"generateSkills");});async function bw(t,e,r){if(t==="workflows"||t.startsWith("workflows/"))return null;let n=t.replace(/\\/g,"/");if(n==="_root.md")return null;let o=join(e,n),{frontmatter:i,body:a}=b(r(o)),l=Po(i.paths??i.globs),c={root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${vs}/${n}`,feature:"rules",content:await z(o,c,a)}}async function Pw(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=b(r(n)),a=Object.prototype.hasOwnProperty.call(o,"description"),l=a&&typeof o.description=="string"?o.description:"",c=a,m=i;if(!c){let p=i.indexOf(`
79
81
 
80
82
  `);if(p>0){let u=i.slice(0,p).trim();u&&!u.includes(`
81
- `)&&(l=u,c=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${du}/${t}`,feature:"commands",content:await _t(n,{description:l,hasDescription:c,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var fy=d(()=>{j();ut();or();cr();s(CA,"mapClineRuleFile");s(kA,"mapClineWorkflowFile");});async function EA(t,e,r){let n=join(t,Fs),o=join(t,vo),i=join(t,vo),a=false;try{a=(await stat(i)).isFile();}catch{}if(a){let p=await _(i);if(p!==null){await O(n);let u=join(n,"_root.md"),{frontmatter:f,body:g}=b(r(p,i,u)),R=f.root===true?f:{...f,root:true},C=await K(u,R,g);await I(u,C),e.push({fromTool:"cline",fromPath:i,toPath:`${Fs}/_root.md`,feature:"rules"});}return a}let l=null,c=join(o,"_root.md"),m=await _(c);if(m===null){let p=join(t,Ns),u=await _(p);if(u!==null){l=p,await O(n);let f=join(n,"_root.md"),{frontmatter:g,body:h}=b(r(u,p,f)),C=g.root===true?g:{...g,root:true},S=await K(f,C,h);await I(f,S),e.push({fromTool:"cline",fromPath:p,toPath:`${Fs}/_root.md`,feature:"rules"});}else {let h=(await v(o)).filter(R=>R.endsWith(".md")&&!R.includes("/workflows/")).sort()[0];if(h){let R=await _(h);if(R!==null){l=h,await O(n);let C=join(n,"_root.md"),{frontmatter:S,body:k}=b(r(R,h,C)),N=S.root===true?S:{...S,root:true},F=await K(C,N,k);await I(C,F),e.push({fromTool:"cline",fromPath:h,toPath:`${Fs}/_root.md`,feature:"rules"});}}}}else {l=c,await O(n);let p=join(n,"_root.md"),{frontmatter:u,body:f}=b(r(m,c,p)),h=u.root===true?u:{...u,root:true},R=await K(p,h,f);await I(p,R),e.push({fromTool:"cline",fromPath:c,toPath:`${Fs}/_root.md`,feature:"rules"});}return e.push(...await Rt({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:f})=>p===l?null:CA(u,n,f),"mapEntry")})),a}var LA=d(()=>{w();j();ut();xe();fy();cr();s(EA,"importClineRules");});function qH(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let n=typeof e.type=="string"?e.type:typeof e.transportType=="string"?e.transportType:"stdio",o=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(c=>typeof c[1]=="string")):{},l=typeof e.description=="string"?e.description:void 0;return {...l!==void 0&&{description:l},type:n,command:r,args:o,env:a}}async function OA(t,e){let r=[Mo,fE].map(c=>join(t,c)),n=null,o=null;for(let c of r){let m=await _(c);if(m!==null){n=c,o=m;break}}if(o===null)return;let i=n??r[0],a;try{a=JSON.parse(o);}catch{}let l=a?.mcpServers;if(l!==void 0&&typeof l=="object"&&l!==null&&Object.keys(l).length>0){let c={};for(let[m,p]of Object.entries(l)){let u=qH(p);u&&(c[m]=u);}Object.keys(c).length>0&&(await O(join(t,".agentsmesh")),await I(join(t,Rh),JSON.stringify({mcpServers:c},null,2)),e.push({fromTool:Ds,fromPath:i,toPath:Rh,feature:"mcp"}));}}var AA=d(()=>{w();cr();s(qH,"mapClineServerToCanonical");s(OA,"importClineMcp");});function wA(t){return tz.some(e=>e.test(t))}var tz,bA=d(()=>{tz=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(wA,"isReservedArtifactName");});async function rz(t){let e=await v(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(wA(i))continue;let a=await _(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Um(t,e,r){let n=await rz(e),o=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of n){let a=join(o,i.relativePath);await O(dirname(a));let l=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:c,body:m}=b(l),p=await Cn(a,{...c,name:t},m);await I(a,p);}else await I(a,l);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function TA(t,e,r,n){let o=join(n.projectRoot,n.destCanonicalSkillsDir,t);await O(o);let i=join(o,"SKILL.md"),a=n.normalize(r,e,i),{frontmatter:l,body:c}=b(a),m=await Cn(i,{...l,name:t},c);await I(i,m),n.results.push({fromTool:n.targetName,fromPath:e,toPath:`${n.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function Bm(t){let e=new Map;try{let n=(await v(t)).filter(o=>basename(o)==="SKILL.md");for(let o of n){let i=dirname(o),a=basename(i);e.set(a,i);}}catch{}return e}async function Vl(t,e,r=[]){for(let n of t){let o=join(e.projectRoot,n),i=await Bm(o);if(i.size===0)continue;let a=false;for(let[l,c]of i){let m=join(c,"SKILL.md"),p=await _(m);if(p===null)continue;a=true;let{frontmatter:u,body:f}=b(p),g={skillName:l,skillDir:c,skillMdPath:m,rawContent:p,frontmatter:u,rawBody:f,options:e},h=false;for(let R of r)if(await R.recognize(g)){h=true;break}h||await Um(l,c,e);}if(a)return}}function Jl(t){return {async recognize(e){let r=al(e.frontmatter,e.skillName);if(!r)return false;let{options:n}=e;await kn(join(n.projectRoot,n.destCanonicalSkillsDir,e.skillName));let o=join(n.projectRoot,t.canonicalAgentsDir);await O(o);let i=join(o,`${r.name}.md`),a=n.normalize(e.rawBody,e.skillMdPath,i);return await I(i,Os(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalAgentsDir}/${r.name}.md`,feature:"agents"}),true}}}function xA(t){return {async recognize(e){let r=Xp(e.frontmatter,e.skillName);if(!r)return false;let{options:n}=e;await kn(join(n.projectRoot,n.destCanonicalSkillsDir,e.skillName));let o=join(n.projectRoot,t.canonicalCommandsDir);await O(o);let i=join(o,`${r.name}.md`),a=n.normalize(e.rawBody,e.skillMdPath,i);return await I(i,Zp(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalCommandsDir}/${r.name}.md`,feature:"commands"}),true}}}var Yl=d(()=>{w();j();ut();bA();mt();kt();Qc();s(rz,"readNativeSkill");s(Um,"importDirectorySkill");s(TA,"importFlatSkill");s(Bm,"findDirectorySkills");s(Vl,"importSkillsDirectory");s(Jl,"projectedAgentRecognizer");s(xA,"commandSkillRecognizer");});async function DA(t,e,r,n=Zt){await Vl([n],{projectRoot:t,destCanonicalSkillsDir:hE,targetName:"cline",normalize:r,results:e},[Jl({canonicalAgentsDir:gE})]);}var NA=d(()=>{Yl();cr();s(DA,"importClineSkills");});function yy(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function FA(t,e){let n=(await v(t).catch(()=>[])).filter(o=>basename(o).endsWith(".sh")&&dirname(o)===t);for(let o of n){let i=await _(o);if(!i)continue;let a=yy(i,"event"),l=yy(i,"command");if(!a||!l)continue;let c=yy(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:c,command:l});}}async function MA(t,e){let r={};if(await FA(join(t,Gi),r),await FA(join(t,Bi),r),Object.keys(r).length===0)return;let n=join(t,yh);await O(dirname(n)),await I(n,stringify(r)),e.push({fromTool:Ds,fromPath:join(t,Bi),toPath:yh,feature:"hooks"});}var $A=d(()=>{w();cr();s(yy,"extractMeta");s(FA,"loadHooksFromDir");s(MA,"importClineHooks");});async function GA(t){let e=[],r=await B(Ds,t),n=await EA(t,e,r),o=join(t,$i),i=await _(o);if(i!==null&&i.trim()){let l=i.split(/\r?\n/),c=[];for(let m of l){let p=m.trim();p&&!p.startsWith("#")&&c.push(p);}if(c.length>0){await O(join(t,".agentsmesh"));let m=join(t,_h);await I(m,c.join(`
82
- `)),e.push({fromTool:"cline",fromPath:o,toPath:_h,feature:"ignore"});}}await OA(t,e);let a=join(t,du);return n||e.push(...await Rt({srcDir:join(t,Dn),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:l,normalizeTo:c})=>kA(l,a,c),"mapEntry")})),await DA(t,e,r),await MA(t,e),e}var jA=d(()=>{dt();w();xe();fy();LA();cr();AA();NA();$A();s(GA,"importFromCline");});function UA(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:Ds}))}var BA=d(()=>{It();cr();s(UA,"lintRules");});function KA(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>x(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function WA(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".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 HA=d(()=>{Lt();s(KA,"lintCommands");s(WA,"lintHooks");});var sz,iz,az,lz,zA,VA=d(()=>{IA();wi();cr();jA();BA();HA();Ct();ol();mt();sz={name:"cline",primaryRootInstructionPath:Ns,generateRules:dA,generateCommands:fA,generateAgents:yA,generateSkills:RA,generateMcp:hA,generateHooks:_A,generateIgnore:gA,importFrom:GA},iz={rootInstructionPath:Ns,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 `${vo}/${t}.md`},commandPath(t,e){return `${Dn}/${t}.md`},agentPath(t,e){return qe(e,"cline")?`.cline/skills/${U(t)}/SKILL.md`:null}}},az={skillDir:Zt,managedOutputs:{dirs:[ji,Ui,Bi,Zt,".agents/skills"],files:[Mo,$i]},rewriteGeneratedPath(t){return t===Ns?null:t.startsWith(`${Gi}/`)?`${Bi}/${t.slice(Gi.length+1)}`:t.startsWith(`${Dn}/`)?`${Ui}/${t.slice(Dn.length+1)}`:t.startsWith(`${vo}/`)?`${ji}/${t.slice(vo.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${Zt}/`)?`.agents/skills/${t.slice(Zt.length+1)}`:null},paths:{rulePath(t,e){return `${ji}/${t}.md`},commandPath(t,e){return `${Ui}/${t}.md`},agentPath(t,e){return qe(e,"cline")?`.cline/skills/${U(t)}/SKILL.md`:null}}},lz={rules:"native",additionalRules:"native",commands:Gr("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},zA={id:"cline",metadata:{displayName:"Cline",category:"ide",officialUrl:"https://cline.bot",shortDescription:"Autonomous coding agent for VS Code"},generators:sz,capabilities:{rules:"native",additionalRules:"native",commands:Gr("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:UA,lint:{commands:KA,hooks:WA},project:iz,globalSupport:{capabilities:lz,detectionPaths:[ji,Ui,Bi,Zt,Mo,$i],layout:az},buildImportPaths:Ih,detectionPaths:[".clinerules",".cline"],conversionDefaults:{agentsToSkills:true}};});var Ie,JA,cs,_a,YA,so,XA,ju,Ra,io,Ia,ms,ZA,Wm,QA,_y,qA,Ry,tw,ew,Iy,Sy,Cy,de=d(()=>{Ie="codex-cli",JA="codex.md",cs="AGENTS.md",_a=".codex/AGENTS.md",YA=".codex/AGENTS.override.md",so=".agents/skills",XA=".codex/skills",ju=".codex/config.toml",Ra=".codex/instructions",io=".codex/rules",Ia=".codex/agents",ms=".agentsmesh/rules",ZA=".agentsmesh/commands",Wm=".agentsmesh/agents",QA=".agentsmesh/skills",_y=".agentsmesh/mcp.json",qA="am-codex-rule:v1",Ry="# am-json: ",tw="# am-body-b64-begin",ew="# am-body-b64-end",Iy="# am64:",Sy="<!-- agentsmesh:codex-rule-index:start -->",Cy="<!-- agentsmesh:codex-rule-index:end -->";});function ky(t){return basename(t,".md")}function Hm(t){return `${Ra}/${ky(t.source)}.md`}function rw(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];}),T(e,t.body.trim()||"")}function mz(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 \`${io}/${ky(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function nw(t,e){let r=t.trim(),n=e.filter(a=>!a.root);if(n.length===0)return r;let o=n.map(a=>`- [${a.description||ky(a.source)}](${Hm(a)}): ${mz(a)}`),i=[Sy,"## Additional Rule Files",...o,Cy].join(`
83
+ `)&&(l=u,c=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${Ou}/${t}`,feature:"commands",content:await It(n,{description:l,hasDescription:c,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var Ay=d(()=>{K();ft();cr();fr();s(bw,"mapClineRuleFile");s(Pw,"mapClineWorkflowFile");});async function Tw(t,e,r){let n=join(t,vs),o=join(t,$o),i=join(t,$o),a=false;try{a=(await stat(i)).isFile();}catch{}if(a){let p=await _(i);if(p!==null){await O(n);let u=join(n,"_root.md"),{frontmatter:f,body:g}=b(r(p,i,u)),I=f.root===true?f:{...f,root:true},k=await z(u,I,g);await S(u,k),e.push({fromTool:"cline",fromPath:i,toPath:`${vs}/_root.md`,feature:"rules"});}return a}let l=null,c=join(o,"_root.md"),m=await _(c);if(m===null){let p=join(t,Fs),u=await _(p);if(u!==null){l=p,await O(n);let f=join(n,"_root.md"),{frontmatter:g,body:h}=b(r(u,p,f)),k=g.root===true?g:{...g,root:true},C=await z(f,k,h);await S(f,C),e.push({fromTool:"cline",fromPath:p,toPath:`${vs}/_root.md`,feature:"rules"});}else {let h=(await $(o)).filter(I=>I.endsWith(".md")&&!I.includes("/workflows/")).sort()[0];if(h){let I=await _(h);if(I!==null){l=h,await O(n);let k=join(n,"_root.md"),{frontmatter:C,body:R}=b(r(I,h,k)),N=C.root===true?C:{...C,root:true},F=await z(k,N,R);await S(k,F),e.push({fromTool:"cline",fromPath:h,toPath:`${vs}/_root.md`,feature:"rules"});}}}}else {l=c,await O(n);let p=join(n,"_root.md"),{frontmatter:u,body:f}=b(r(m,c,p)),h=u.root===true?u:{...u,root:true},I=await z(p,h,f);await S(p,I),e.push({fromTool:"cline",fromPath:c,toPath:`${vs}/_root.md`,feature:"rules"});}return e.push(...await St({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:f})=>p===l?null:bw(u,n,f),"mapEntry")})),a}var xw=d(()=>{A();K();ft();Me();Ay();fr();s(Tw,"importClineRules");});function gz(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let n=typeof e.type=="string"?e.type:typeof e.transportType=="string"?e.transportType:"stdio",o=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(c=>typeof c[1]=="string")):{},l=typeof e.description=="string"?e.description:void 0;return {...l!==void 0&&{description:l},type:n,command:r,args:o,env:a}}async function Dw(t,e){let r=[Go,SE].map(c=>join(t,c)),n=null,o=null;for(let c of r){let m=await _(c);if(m!==null){n=c,o=m;break}}if(o===null)return;let i=n??r[0],a;try{a=JSON.parse(o);}catch{}let l=a?.mcpServers;if(l!==void 0&&typeof l=="object"&&l!==null&&Object.keys(l).length>0){let c={};for(let[m,p]of Object.entries(l)){let u=gz(p);u&&(c[m]=u);}Object.keys(c).length>0&&(await O(join(t,".agentsmesh")),await S(join(t,Dh),JSON.stringify({mcpServers:c},null,2)),e.push({fromTool:Ns,fromPath:i,toPath:Dh,feature:"mcp"}));}}var Nw=d(()=>{A();fr();s(gz,"mapClineServerToCanonical");s(Dw,"importClineMcp");});function Fw(t){return hz.some(e=>e.test(t))}var hz,vw=d(()=>{hz=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(Fw,"isReservedArtifactName");});async function _z(t){let e=await $(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(Fw(i))continue;let a=await _(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Hm(t,e,r){let n=await _z(e),o=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of n){let a=join(o,i.relativePath);await O(dirname(a));let l=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:c,body:m}=b(l),p=await En(a,{...c,name:t},m);await S(a,p);}else await S(a,l);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function $w(t,e,r,n){let o=join(n.projectRoot,n.destCanonicalSkillsDir,t);await O(o);let i=join(o,"SKILL.md"),a=n.normalize(r,e,i),{frontmatter:l,body:c}=b(a),m=await En(i,{...l,name:t},c);await S(i,m),n.results.push({fromTool:n.targetName,fromPath:e,toPath:`${n.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function zm(t){let e=new Map;try{let n=(await $(t)).filter(o=>basename(o)==="SKILL.md");for(let o of n){let i=dirname(o),a=basename(i);e.set(a,i);}}catch{}return e}async function Jl(t,e,r=[]){for(let n of t){let o=join(e.projectRoot,n),i=await zm(o);if(i.size===0)continue;let a=false;for(let[l,c]of i){let m=join(c,"SKILL.md"),p=await _(m);if(p===null)continue;a=true;let{frontmatter:u,body:f}=b(p),g={skillName:l,skillDir:c,skillMdPath:m,rawContent:p,frontmatter:u,rawBody:f,options:e},h=false;for(let I of r)if(await I.recognize(g)){h=true;break}h||await Hm(l,c,e);}if(a)return}}function Yl(t){return {async recognize(e){let r=ll(e.frontmatter,e.skillName);if(!r)return false;let{options:n}=e;await Ln(join(n.projectRoot,n.destCanonicalSkillsDir,e.skillName));let o=join(n.projectRoot,t.canonicalAgentsDir);await O(o);let i=join(o,`${r.name}.md`),a=n.normalize(e.rawBody,e.skillMdPath,i);return await S(i,ws(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalAgentsDir}/${r.name}.md`,feature:"agents"}),true}}}function Gw(t){return {async recognize(e){let r=cu(e.frontmatter,e.skillName);if(!r)return false;let{options:n}=e;await Ln(join(n.projectRoot,n.destCanonicalSkillsDir,e.skillName));let o=join(n.projectRoot,t.canonicalCommandsDir);await O(o);let i=join(o,`${r.name}.md`),a=n.normalize(e.rawBody,e.skillMdPath,i);return await S(i,mu(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalCommandsDir}/${r.name}.md`,feature:"commands"}),true}}}var Xl=d(()=>{A();K();ft();vw();ut();Lt();rm();s(_z,"readNativeSkill");s(Hm,"importDirectorySkill");s($w,"importFlatSkill");s(zm,"findDirectorySkills");s(Jl,"importSkillsDirectory");s(Yl,"projectedAgentRecognizer");s(Gw,"commandSkillRecognizer");});async function jw(t,e,r,n=qt){await Jl([n],{projectRoot:t,destCanonicalSkillsDir:kE,targetName:"cline",normalize:r,results:e},[Yl({canonicalAgentsDir:CE})]);}var Uw=d(()=>{Xl();fr();s(jw,"importClineSkills");});function Ty(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function Bw(t,e){let n=(await $(t).catch(()=>[])).filter(o=>basename(o).endsWith(".sh")&&dirname(o)===t);for(let o of n){let i=await _(o);if(!i)continue;let a=Ty(i,"event"),l=Ty(i,"command");if(!a||!l)continue;let c=Ty(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:c,command:l});}}async function Ww(t,e){let r={};if(await Bw(join(t,Ui),r),await Bw(join(t,Wi),r),Object.keys(r).length===0)return;let n=join(t,Th);await O(dirname(n)),await S(n,stringify(r)),e.push({fromTool:Ns,fromPath:join(t,Wi),toPath:Th,feature:"hooks"});}var Hw=d(()=>{A();fr();s(Ty,"extractMeta");s(Bw,"loadHooksFromDir");s(Ww,"importClineHooks");});async function zw(t){let e=[],r=await H(Ns,t),n=await Tw(t,e,r),o=join(t,ji),i=await _(o);if(i!==null&&i.trim()){let l=i.split(/\r?\n/),c=[];for(let m of l){let p=m.trim();p&&!p.startsWith("#")&&c.push(p);}if(c.length>0){await O(join(t,".agentsmesh"));let m=join(t,xh);await S(m,c.join(`
84
+ `)),e.push({fromTool:"cline",fromPath:o,toPath:xh,feature:"ignore"});}}await Dw(t,e);let a=join(t,Ou);return n||e.push(...await St({srcDir:join(t,Fn),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:l,normalizeTo:c})=>Pw(l,a,c),"mapEntry")})),await jw(t,e,r),await Ww(t,e),e}var Vw=d(()=>{gt();A();Me();Ay();xw();fr();Nw();Uw();Hw();s(zw,"importFromCline");});function Jw(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:Ns}))}var Yw=d(()=>{Ct();fr();s(Jw,"lintRules");});function Xw(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>x(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function Zw(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".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 Qw=d(()=>{wt();s(Xw,"lintCommands");s(Zw,"lintHooks");});var Sz,Cz,kz,Ez,qw,tA=d(()=>{ww();Pi();fr();Vw();Yw();Qw();Et();sl();ut();Sz={name:"cline",primaryRootInstructionPath:Fs,generateRules:Iw,generateCommands:Sw,generateAgents:Ew,generateSkills:Ow,generateMcp:kw,generateHooks:Lw,generateIgnore:Cw,importFrom:zw},Cz={rootInstructionPath:Fs,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 `${$o}/${t}.md`},commandPath(t,e){return `${Fn}/${t}.md`},agentPath(t,e){return or(e,"cline")?`.cline/skills/${W(t)}/SKILL.md`:null}}},kz={skillDir:qt,managedOutputs:{dirs:[Bi,Ki,Wi,qt,".agents/skills"],files:[Go,ji]},rewriteGeneratedPath(t){return t===Fs?null:t.startsWith(`${Ui}/`)?`${Wi}/${t.slice(Ui.length+1)}`:t.startsWith(`${Fn}/`)?`${Ki}/${t.slice(Fn.length+1)}`:t.startsWith(`${$o}/`)?`${Bi}/${t.slice($o.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${qt}/`)?`.agents/skills/${t.slice(qt.length+1)}`:null},paths:{rulePath(t,e){return `${Bi}/${t}.md`},commandPath(t,e){return `${Ki}/${t}.md`},agentPath(t,e){return or(e,"cline")?`.cline/skills/${W(t)}/SKILL.md`:null}}},Ez={rules:"native",additionalRules:"native",commands:Kr("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},qw={id:"cline",metadata:{displayName:"Cline",category:"ide",officialUrl:"https://cline.bot",shortDescription:"Autonomous coding agent for VS Code"},generators:Sz,capabilities:{rules:"native",additionalRules:"native",commands:Kr("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:Jw,lint:{commands:Xw,hooks:Zw},project:Cz,globalSupport:{capabilities:Ez,detectionPaths:[Bi,Ki,Wi,qt,Go,ji],layout:kz},buildImportPaths:Nh,detectionPaths:[".clinerules",".cline"],conversionDefaults:{agentsToSkills:true}};});var Se,eA,ps,Ia,rA,ao,nA,qu,Sa,lo,Ca,us,oA,Jm,sA,xy,iA,Dy,aA,lA,Ny,Fy,vy,ge=d(()=>{Se="codex-cli",eA="codex.md",ps="AGENTS.md",Ia=".codex/AGENTS.md",rA=".codex/AGENTS.override.md",ao=".agents/skills",nA=".codex/skills",qu=".codex/config.toml",Sa=".codex/instructions",lo=".codex/rules",Ca=".codex/agents",us=".agentsmesh/rules",oA=".agentsmesh/commands",Jm=".agentsmesh/agents",sA=".agentsmesh/skills",xy=".agentsmesh/mcp.json",iA="am-codex-rule:v1",Dy="# am-json: ",aA="# am-body-b64-begin",lA="# am-body-b64-end",Ny="# am64:",Fy="<!-- agentsmesh:codex-rule-index:start -->",vy="<!-- agentsmesh:codex-rule-index:end -->";});function My(t){return basename(t,".md")}function Ym(t){return `${Sa}/${My(t.source)}.md`}function cA(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];}),T(e,t.body.trim()||"")}function Oz(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 \`${lo}/${My(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function mA(t,e){let r=t.trim(),n=e.filter(a=>!a.root);if(n.length===0)return r;let o=n.map(a=>`- [${a.description||My(a.source)}](${Ym(a)}): ${Oz(a)}`),i=[Fy,"## Additional Rule Files",...o,vy].join(`
83
85
  `);return r?`${r}
84
86
 
85
- ${i}`:i}function ow(t){let e=Sy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=Cy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
86
- `).trim()}var Uu=d(()=>{j();de();s(ky,"ruleSlug");s(Hm,"codexInstructionMirrorPath");s(rw,"serializeCodexInstructionMirror");s(mz,"summarizeRule");s(nw,"appendCodexRuleIndex");s(ow,"stripCodexRuleIndex");});function uz(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function dz(t){return t.split(`
87
+ ${i}`:i}function pA(t){let e=Fy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=vy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
88
+ `).trim()}var td=d(()=>{K();ge();s(My,"ruleSlug");s(Ym,"codexInstructionMirrorPath");s(cA,"serializeCodexInstructionMirror");s(Oz,"summarizeRule");s(mA,"appendCodexRuleIndex");s(pA,"stripCodexRuleIndex");});function Az(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function bz(t){return t.split(`
87
89
  `).map(e=>e.length>0?`# ${e}`:"#").join(`
88
- `)}function fz(t){let e=t.trim();return e?uz(e)?`${e}
89
- `:`${["# 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.","#",...dz(e).split(`
90
+ `)}function Pz(t){let e=t.trim();return e?Az(e)?`${e}
91
+ `:`${["# 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.","#",...bz(e).split(`
90
92
  `),"#","# Example template:","# prefix_rule(",'# pattern = ["git", "status"],','# decision = "allow",','# justification = "Allow safe status checks",',"# )"].join(`
91
93
  `)}
92
- `:""}function Ey(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:cs,content:nw(e.body,t.rules)});for(let n of t.rules){if(n.root)continue;let o=basename(n.source,".md");n.targets.length>0&&!n.targets.includes("codex-cli")||(n.codexEmit==="execution"&&r.push({path:`${io}/${o}.rules`,content:fz(n.body)}),r.push({path:Hm(n),content:rw(n)}));}return r}function Ly(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root||n.codexEmit==="execution"?false:n.targets.length===0||n.targets.includes("codex-cli"));return lt(e?.body.trim()??"",r)}var sw=d(()=>{Ut();de();Uu();s(uz,"looksLikeCodexRulesDsl");s(dz,"toCodexRulesComments");s(fz,"toSafeCodexRulesContent");s(Ey,"generateRules");s(Ly,"renderCodexGlobalInstructions");});function Oy(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${so}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${so}/${r.name}/${a}`,content:i.content});}}return e}function gz(t){return {path:`${so}/${H(t.name)}/SKILL.md`,content:Nt(t)}}function Ay(t){return t.commands.map(gz)}var iw=d(()=>{j();de();kt();s(Oy,"generateSkills");s(gz,"commandToSkillOutput");s(Ay,"generateCommands");});function wy(t){return t.agents.map(e=>({path:`${Ia}/${e.name}.toml`,content:hz(e)}))}function hz(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 n=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`developer_instructions = """
94
+ `:""}function $y(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:ps,content:mA(e.body,t.rules)});for(let n of t.rules){if(n.root)continue;let o=basename(n.source,".md");n.targets.length>0&&!n.targets.includes("codex-cli")||(n.codexEmit==="execution"&&r.push({path:`${lo}/${o}.rules`,content:Pz(n.body)}),r.push({path:Ym(n),content:cA(n)}));}return r}function Gy(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root||n.codexEmit==="execution"?false:n.targets.length===0||n.targets.includes("codex-cli"));return mt(e?.body.trim()??"",r)}var uA=d(()=>{Kt();ge();td();s(Az,"looksLikeCodexRulesDsl");s(bz,"toCodexRulesComments");s(Pz,"toSafeCodexRulesContent");s($y,"generateRules");s(Gy,"renderCodexGlobalInstructions");});function jy(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${ao}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${ao}/${r.name}/${a}`,content:i.content});}}return e}function Tz(t){return {path:`${ao}/${V(t.name)}/SKILL.md`,content:Ft(t)}}function Uy(t){return t.commands.map(Tz)}var dA=d(()=>{K();ge();Lt();s(jy,"generateSkills");s(Tz,"commandToSkillOutput");s(Uy,"generateCommands");});function By(t){return t.agents.map(e=>({path:`${Ca}/${e.name}.toml`,content:xz(e)}))}function xz(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 n=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`developer_instructions = """
93
95
  ${n}
94
96
  """`);}else e.push(`developer_instructions = '''
95
97
  ${r}
96
98
  '''`);return e.join(`
97
99
  `)+`
98
- `}var aw=d(()=>{de();s(wy,"generateAgents");s(hz,"serializeAgentToCodexToml");});function Bu(t){return "command"in t}function lw(t){return "url"in t}var Ku=d(()=>{s(Bu,"isStdioMcpServer");s(lw,"isUrlMcpServer");});function by(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>Bu(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=yz(e);return [{path:ju,content:r}]}function yz(t){let e=[];for(let[r,n]of Object.entries(t)){let o=cw(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${o}]`),i.push(`command = ${JSON.stringify(n.command)}`);let a="["+n.args.map(c=>JSON.stringify(c)).join(", ")+"]";i.push(`args = ${a}`);let l=Object.entries(n.env);if(l.length>0){let c=l.map(([m,p])=>`${cw(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${c} }`);}e.push(i.join(`
100
+ `}var fA=d(()=>{ge();s(By,"generateAgents");s(xz,"serializeAgentToCodexToml");});function ed(t){return "command"in t}function gA(t){return "url"in t}var rd=d(()=>{s(ed,"isStdioMcpServer");s(gA,"isUrlMcpServer");});function Ky(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>ed(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=Dz(e);return [{path:qu,content:r}]}function Dz(t){let e=[];for(let[r,n]of Object.entries(t)){let o=hA(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${o}]`),i.push(`command = ${JSON.stringify(n.command)}`);let a="["+n.args.map(c=>JSON.stringify(c)).join(", ")+"]";i.push(`args = ${a}`);let l=Object.entries(n.env);if(l.length>0){let c=l.map(([m,p])=>`${hA(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${c} }`);}e.push(i.join(`
99
101
  `));}return e.join(`
100
102
 
101
103
  `)+`
102
- `}function cw(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var mw=d(()=>{Ku();de();s(by,"generateMcp");s(yz,"serializeMcpToToml");s(cw,"needsTomlQuoting");});var pw=d(()=>{sw();iw();aw();mw();});var uw=d(()=>{pw();});function Iz(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 n=Array.isArray(e.args)?e.args.filter(a=>typeof a=="string"):[],o=e.env,i=o!==null&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).filter(a=>typeof a[1]=="string")):{};return {type:"stdio",command:r,args:n,env:i}}async function dw(t,e){let r=join(t,ju),n=await _(r);if(n===null)return;let o;try{o=parse$1(n);}catch{return}let i=o.mcp_servers;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0)return;let a={};for(let[l,c]of Object.entries(i)){let m=Iz(c);m&&(a[l]=m);}Object.keys(a).length!==0&&(await Bt(t,_y,a),e.push({fromTool:Ie,fromPath:r,toPath:_y,feature:"mcp"}));}var fw=d(()=>{w();Kr();de();s(Iz,"mapTomlServerToCanonical");s(dw,"importMcp");});async function gw(t,e,r){await Vl([so,XA],{projectRoot:t,destCanonicalSkillsDir:QA,targetName:Ie,normalize:r,results:e},[xA({canonicalCommandsDir:ZA}),Jl({canonicalAgentsDir:Wm})]);}var hw=d(()=>{Yl();de();s(gw,"importSkills");});async function yw(t,e,r){let n=join(t,Ia),o=join(t,Wm);try{let a=(await v(n)).filter(l=>l.endsWith(".toml"));for(let l of a){let c=await _(l);if(!c)continue;let m=parse$1(c);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(l,".toml"),u=typeof m.description=="string"?m.description:"",f=typeof m.developer_instructions=="string"?m.developer_instructions.trim():"",g=typeof m.model=="string"?m.model:"",h=typeof m.sandbox_mode=="string"?m.sandbox_mode:"",R=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",C=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(F=>typeof F=="string"):[];await O(o);let S=join(o,`${p}.md`),k=r(f,l,S),N=Os({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:R,maxTurns:0,mcpServers:C,hooks:{},skills:[],memory:""},k);await I(S,N),e.push({fromTool:Ie,fromPath:l,toPath:`${Wm}/${p}.md`,feature:"agents"});}}catch{}}var _w=d(()=>{w();mt();de();s(yw,"importCodexAgentsFromToml");});function Rw(t){if(!t.includes(qA))return null;let e=t.split(`
103
- `).find(c=>c.startsWith(Ry));if(!e)return null;let r;try{r=JSON.parse(e.slice(Ry.length));}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=typeof n.description=="string"?n.description:"",i=Array.isArray(n.globs)?n.globs.filter(c=>typeof c=="string"):[],a=[],l=false;for(let c of t.split(`
104
- `)){let m=c.trimEnd();if(m===tw){l=true;continue}if(m===ew){l=false;continue}l&&m.startsWith(Iy)&&a.push(m.slice(Iy.length));}if(a.length===0)return null;try{let c=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:i},body:c}}catch{return null}}var Iw=d(()=>{de();s(Rw,"tryParseEmbeddedCanonicalFromCodexRules");});async function Cw(t,e,r){let n=[],o=join(t,io);try{let i=await v(o),a=i.filter(c=>c.endsWith(".md"));for(let c of a){let m=await _(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/"),u=join(e,p),{frontmatter:f,body:g}=b(r(m,c,u));await O(e);let h=f.root===!0?f:{...f,root:!1},R=await K(u,h,g);await I(u,R),n.push({fromTool:Ie,fromPath:c,toPath:`${ms}/${p}`,feature:"rules"});}let l=i.filter(c=>c.endsWith(".rules"));for(let c of l){let m=await _(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await O(e);let f=Rw(m);if(f){let g=await K(u,{description:f.meta.description,globs:f.meta.globs,root:!1},r(f.body,c,u));await I(u,g);}else {let g=await K(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),c,u));await I(u,g);}n.push({fromTool:Ie,fromPath:c,toPath:`${ms}/${p}`,feature:"rules"});}}catch{}return n}var kw=d(()=>{w();j();ut();de();Iw();s(Cw,"importCodexNonRootRuleFiles");});async function Lw(t,e,r,n,o){let i=join(t,JA),a=join(t,cs),l=join(t,YA),c=join(t,_a),m=o==="global"?await _(l):null,p=o==="global"?await _(c):null,u=o==="project"?await _(a):null,f=o==="project"?await _(i):null,g=m!==null?l:p!==null?c:u!==null?a:i,h=join(t,ms),R=m??p??u??f;if(R!==null){await O(h);let C=join(h,"_root.md"),S=g===a||g===c||g===l?ow(R):R,k=await oo({content:S,projectRoot:t,rulesDir:ms,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...k.results);let P=r(g===a||g===c||g===l?n(k.rootContent,g,C):k.rootContent,g,C),{frontmatter:N,body:F}=b(P),W=N.root===true?N:{...N,root:true},z=await K(C,W,F);await I(C,z),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${ms}/_root.md`,feature:"rules"});}await Oz(t,h,e,r),e.push(...await Cw(t,h,r)),o!=="global"&&e.push(...await Rt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:C,normalizeTo:S})=>{let k=relative(t,dirname(C)).replace(/\\/g,"/"),P=basename(C),N=P==="AGENTS.override.md";if(!k||k==="."||!N&&P!=="AGENTS.md")return null;let F=k.replace(/\//g,"-");if(!eu(k))return await kn(join(h,`${F}.md`)),null;let W=join(h,`${F}.md`),{frontmatter:z,body:Q}=b(S(W));return {destPath:W,toPath:`${ms}/${F}.md`,feature:"rules",content:await K(W,{...z,root:false,globs:[`${k}/**`],...N?{codex_instruction:"override"}:{}},Q)}},"mapEntry")}));}async function Oz(t,e,r,n){try{let i=(await v(join(t,Ra))).filter(l=>l.endsWith(".md")),a=join(t,Ra);for(let l of i){let c=relative(a,l).replace(/\\/g,"/");if(c==="_root.md")continue;let m=await _(l);if(!m)continue;let p=join(e,c),{frontmatter:u,body:f}=b(n(m,l,p));await O(e);let g=u.root===!0?u:{...u,root:!1},h=await K(p,g,f);await I(p,h),r.push({fromTool:Ie,fromPath:l,toPath:`${ms}/${c}`,feature:"rules"});}}catch{}}var Ow=d(()=>{w();j();ut();Hl();xe();Qc();de();kw();Uu();s(Lw,"importCodexRules");s(Oz,"importInstructionMirrors");});async function Aw(t,e){let r=e?.scope??"project",n=[],o=await B(Ie,t,r),i=await B("windsurf",t,r);return await Lw(t,n,o,i,r),await gw(t,n,o),await yw(t,n,o),await dw(t,n),n}var ww=d(()=>{dt();de();fw();hw();_w();Ow();s(Aw,"importFromCodex");});function bw(t,e,r){let{rules:n}=t;return n.length===0?[]:n.some(i=>i.root)?[]:[{level:"warning",file:relative(e,n[0].source),target:Ie,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var Pw=d(()=>{de();s(bw,"lintRules");});function Tw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))if(typeof n.description=="string"&&n.description&&e.push(x(".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 n||"type"in n){let o="type"in n?n.type:"url";e.push(x(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var xw=d(()=>{Lt();s(Tw,"lintMcp");});function Dw(t){return Hm(t)}var Nw=d(()=>{Uu();s(Dw,"codexAdvisoryInstructionPath");});var wz,bz,Pz,Tz,vw,Mw=d(()=>{uw();de();ww();Pw();xw();Ct();ol();Nw();kt();wz={name:"codex-cli",primaryRootInstructionPath:cs,generateRules:Ey,generateCommands:Ay,generateAgents:wy,generateSkills:Oy,generateMcp:by,importFrom:Aw},bz={rootInstructionPath:cs,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${io}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return Dw(e)},commandPath(t,e){return nl(e,"codex-cli")?`${so}/${H(t)}/SKILL.md`:null},agentPath(t,e){return `${Ia}/${t}.toml`}}},Pz={rootInstructionPath:_a,renderPrimaryRootInstruction:Ly,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${io}/${e}.rules`]},skillDir:so,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[_a,".codex/config.toml"]},rewriteGeneratedPath(t){return t===cs?_a:t.startsWith(`${Ra}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${io}/${t}.rules`:_a},commandPath(t,e){return nl(e,"codex-cli")?`${so}/${H(t)}/SKILL.md`:null},agentPath(t,e){return `${Ia}/${t}.toml`}}},Tz={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},vw={id:"codex-cli",metadata:{displayName:"Codex CLI",category:"cli",officialUrl:"https://github.com/openai/codex",shortDescription:"OpenAI's terminal coding agent"},generators:wz,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:bw,lint:{mcp:Tw},project:bz,globalSupport:{capabilities:Tz,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:Pz},buildImportPaths:Sh,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"],excludeFromStarterInit:true,conversionDefaults:{commandsToSkills:true,agentsToSkills:false}};});function Dz(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 `${Nn}/${t}.md`}function Gw(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"],T(e,t.body.trim()||"")}function jw(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:Dz(t["x-agentsmesh-allowed-tools"])}}function Uw(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"],T(r,e.trim()||"")}var Wu=d(()=>{j();Fn();s(Dz,"toStringArray");s($w,"continueCommandRulePath");s(Gw,"serializeCommandRule");s(jw,"parseCommandRuleFrontmatter");s(Uw,"serializeImportedCommand");});function Bw(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:$o,content:T(n,r.body.trim()||"")});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("continue"))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs),e.push({path:`${Vr}/${o}.md`,content:T(i,n.body.trim()||"")});}return e}function Kw(t){return t.commands.map(e=>({path:`${Nn}/${e.name}.md`,content:Gw(e)}))}function Ww(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:fu,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Hw(t){return t.agents.map(e=>({path:`${Fe}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function zw(t){return rt(t,Fe)}var Vw=d(()=>{tt();mt();j();Wu();Fn();s(Bw,"generateRules");s(Kw,"generateCommands");s(Ww,"generateMcp");s(Hw,"generateAgents");s(zw,"generateSkills");});function Mz(t,e){let n=(e===".json"?JSON.parse(t):parse(t)??{}).mcpServers;if(!n||typeof n!="object"||Array.isArray(n))return {};let o={};for(let[i,a]of Object.entries(n)){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a;typeof l.command=="string"&&(o[i]={type:typeof l.type=="string"?l.type:"stdio",command:l.command,args:ws(l.args),env:Ln(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function $z(t,e){let r=(await v(join(t,Ch))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await _(i);a&&(Object.assign(n,Mz(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Bt(t,Eh,n);for(let i of o)e.push({fromTool:hl,fromPath:i,toPath:Eh,feature:"mcp"});}}async function Yw(t){let e=[],r=await B(hl,t);return e.push(...await J(Hu,t,"project",{normalize:r})),await q(t,Fe,hl,e,r),await $z(t,e),e}var Xw=d(()=>{dt();w();tt();Et();Kr();or();Fn();xy();s(Mz,"readMcpServers");s($z,"importMcp");s(Yw,"importFromContinue");});function Gz(t){return t==="general.md"||t==="_root.md"}var Zw,Qw,qw=d(()=>{j();ut();Wu();Fn();s(Gz,"isContinueRootRulePath");Zw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=Gz(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:l}=b(e(i)),c={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return c.description===void 0&&delete c.description,c.globs===void 0&&delete c.globs,{destPath:i,toPath:`${gu}/${o}`,content:await K(i,c,l)}},"continueRuleMapper"),Qw=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=b(r(o)),l=jw(i,t),c=l.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${c}.md`:`${c}.md`,u=join(n,p),f=await _t(u,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},b(Uw(l,a)).body);return {destPath:u,toPath:`${hu}/${p}`,content:f}},"continueCommandMapper");});function tb(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:hl}))}var eb=d(()=>{It();Fn();s(tb,"lintRules");});function rb(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>x(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var nb=d(()=>{Lt();s(rb,"lintCommands");});function Kz(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var ob,sb=d(()=>{w();Fn();s(Kz,"computeStatus");ob=s(async(t,e,r,n)=>{if(r!=="global")return [];let o=n.has("rules"),i=n.has("commands"),a=n.has("mcp");if(!(o&&t.rules.length>0||i&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let c={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(c.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(c.prompts=t.commands.map(u=>{let f={name:u.name};return u.description&&(f.description=u.description),f.prompt=u.body.trim(),f})),a&&t.mcp!==null){let u=Object.entries(t.mcp.mcpServers);u.length>0&&(c.mcpServers=u.map(([f,g])=>({name:f,...g})));}let m=stringify(c),p=await _(join(e,ym));return [{target:"continue",path:ym,content:m,currentContent:p??void 0,status:Kz(p,m)}]},"generateContinueGlobalConfig");});function Hz(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var ib,ab=d(()=>{w();Fn();sb();s(Hz,"computeStatus");ib=s(async(t,e,r,n)=>{let o=await ob(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let i=t.rules.find(c=>c.root);if(!i)return o;let a=i.body.trim(),l=await _(join(e,yl));return [...o,{target:"continue",path:yl,content:a,currentContent:l??void 0,status:Hz(l,a)}]},"generateContinueScopeExtras");});var zz,Vz,Jz,Yz,Hu,xy=d(()=>{mt();Vw();Fn();Xw();qw();eb();nb();Wu();Ct();ab();zz={name:"continue",primaryRootInstructionPath:$o,generateRules:Bw,generateCommands:Kw,generateAgents:Hw,generateSkills:zw,generateMcp:Ww,importFrom:Yw},Vz={rootInstructionPath:$o,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Vr}/${t}.md`},commandPath(t,e){return $w(t)},agentPath(t){return `${Fe}/${U(t)}/SKILL.md`}}},Jz={rootInstructionPath:$o,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[yl]}],skillDir:Fe,managedOutputs:{dirs:[Vr,Nn,Fe,".agents/skills"],files:[fu,yl,ym]},mirrorGlobalPath(t,e){return t.startsWith(`${Fe}/`)?`.agents/skills/${t.slice(Fe.length+1)}`:null},paths:{rulePath(t,e){return `${Vr}/${t}.md`},commandPath(t,e){return `${Nn}/${t}.md`},agentPath(t){return `${Fe}/${U(t)}/SKILL.md`}}},Yz={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Hu={id:"continue",metadata:{displayName:"Continue",category:"ide",officialUrl:"https://continue.dev",shortDescription:"Open-source AI code assistant"},generators:zz,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:tb,lint:{commands:rb},project:Vz,globalSupport:{capabilities:Yz,detectionPaths:[Vr,Nn,".continue/mcpServers",Fe],layout:Jz,scopeExtras:ib},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Vr],global:[Vr]},canonicalDir:gu,extensions:[".md"],map:Zw},commands:{feature:"commands",mode:"directory",source:{project:[Nn],global:[Nn]},canonicalDir:hu,extensions:[".md"],map:Qw}},buildImportPaths:Lh,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"],conversionDefaults:{agentsToSkills:true}};});var ps,Sa,lb,Ca,si,ao,lo,ka,Ea,zu,Vu,cb,Ny,mb,ii,Xl,us,Zl,La,Fy,vy,wr=d(()=>{ps="copilot",Sa=".github/copilot-instructions.md",lb=".github/copilot",Ca=".github/instructions",si=".github/prompts",ao=".github/hooks",lo=".github/skills",ka=".github/agents",Ea=".agentsmesh/rules",zu=".agentsmesh/commands",Vu=".agentsmesh/agents",cb=".agentsmesh/skills",Ny=".agentsmesh/hooks.yaml",mb=".github/copilot-hooks",ii=".copilot/copilot-instructions.md",Xl=".copilot/agents",us=".copilot/skills",Zl=".copilot/prompts",La=".copilot/AGENTS.md",Fy=".claude/skills",vy=".agents/skills";});function pb(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 Ju(t){return `${si}/${t}.prompt.md`}function ub(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"],T(e,t.body.trim()||"")}function db(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=pb(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:pb(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var Yu=d(()=>{j();wr();s(pb,"toStringArray");s(Ju,"commandPromptPath");s(ub,"serializeCommandPrompt");s(db,"parseCommandPromptFrontmatter");});function Xu(t){return ko(t)}var My=d(()=>{Mr();s(Xu,"hasHookCommand");});function Qz(t){let e=basename(t,".md");return e==="_root"?"root":e}function qz(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function fb(t){let e=[],r=t.rules.find(n=>n.root);r?.body.trim()&&e.push(r.body.trim());for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("copilot"))continue;let o=n.body.trim();if(!o)continue;let i=n.description?`## ${n.description}`:null;i?e.push(`${i}
104
+ `}function hA(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var yA=d(()=>{rd();ge();s(Ky,"generateMcp");s(Dz,"serializeMcpToToml");s(hA,"needsTomlQuoting");});var _A=d(()=>{uA();dA();fA();yA();});var RA=d(()=>{_A();});function vz(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 n=Array.isArray(e.args)?e.args.filter(a=>typeof a=="string"):[],o=e.env,i=o!==null&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).filter(a=>typeof a[1]=="string")):{};return {type:"stdio",command:r,args:n,env:i}}async function IA(t,e){let r=join(t,qu),n=await _(r);if(n===null)return;let o;try{o=parse$1(n);}catch{return}let i=o.mcp_servers;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0)return;let a={};for(let[l,c]of Object.entries(i)){let m=vz(c);m&&(a[l]=m);}Object.keys(a).length!==0&&(await Wt(t,xy,a),e.push({fromTool:Se,fromPath:r,toPath:xy,feature:"mcp"}));}var SA=d(()=>{A();Vr();ge();s(vz,"mapTomlServerToCanonical");s(IA,"importMcp");});async function CA(t,e,r){await Jl([ao,nA],{projectRoot:t,destCanonicalSkillsDir:sA,targetName:Se,normalize:r,results:e},[Gw({canonicalCommandsDir:oA}),Yl({canonicalAgentsDir:Jm})]);}var kA=d(()=>{Xl();ge();s(CA,"importSkills");});async function EA(t,e,r){let n=join(t,Ca),o=join(t,Jm);try{let a=(await $(n)).filter(l=>l.endsWith(".toml"));for(let l of a){let c=await _(l);if(!c)continue;let m=parse$1(c);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(l,".toml"),u=typeof m.description=="string"?m.description:"",f=typeof m.developer_instructions=="string"?m.developer_instructions.trim():"",g=typeof m.model=="string"?m.model:"",h=typeof m.sandbox_mode=="string"?m.sandbox_mode:"",I=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",k=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(F=>typeof F=="string"):[];await O(o);let C=join(o,`${p}.md`),R=r(f,l,C),N=ws({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:I,maxTurns:0,mcpServers:k,hooks:{},skills:[],memory:""},R);await S(C,N),e.push({fromTool:Se,fromPath:l,toPath:`${Jm}/${p}.md`,feature:"agents"});}}catch{}}var LA=d(()=>{A();ut();ge();s(EA,"importCodexAgentsFromToml");});function OA(t){if(!t.includes(iA))return null;let e=t.split(`
105
+ `).find(c=>c.startsWith(Dy));if(!e)return null;let r;try{r=JSON.parse(e.slice(Dy.length));}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=typeof n.description=="string"?n.description:"",i=Array.isArray(n.globs)?n.globs.filter(c=>typeof c=="string"):[],a=[],l=false;for(let c of t.split(`
106
+ `)){let m=c.trimEnd();if(m===aA){l=true;continue}if(m===lA){l=false;continue}l&&m.startsWith(Ny)&&a.push(m.slice(Ny.length));}if(a.length===0)return null;try{let c=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:i},body:c}}catch{return null}}var wA=d(()=>{ge();s(OA,"tryParseEmbeddedCanonicalFromCodexRules");});async function bA(t,e,r){let n=[],o=join(t,lo);try{let i=await $(o),a=i.filter(c=>c.endsWith(".md"));for(let c of a){let m=await _(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/"),u=join(e,p),{frontmatter:f,body:g}=b(r(m,c,u));await O(e);let h=f.root===!0?f:{...f,root:!1},I=await z(u,h,g);await S(u,I),n.push({fromTool:Se,fromPath:c,toPath:`${us}/${p}`,feature:"rules"});}let l=i.filter(c=>c.endsWith(".rules"));for(let c of l){let m=await _(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await O(e);let f=OA(m);if(f){let g=await z(u,{description:f.meta.description,globs:f.meta.globs,root:!1},r(f.body,c,u));await S(u,g);}else {let g=await z(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),c,u));await S(u,g);}n.push({fromTool:Se,fromPath:c,toPath:`${us}/${p}`,feature:"rules"});}}catch{}return n}var PA=d(()=>{A();K();ft();ge();wA();s(bA,"importCodexNonRootRuleFiles");});async function xA(t,e,r,n,o){let i=join(t,eA),a=join(t,ps),l=join(t,rA),c=join(t,Ia),m=o==="global"?await _(l):null,p=o==="global"?await _(c):null,u=o==="project"?await _(a):null,f=o==="project"?await _(i):null,g=m!==null?l:p!==null?c:u!==null?a:i,h=join(t,us),I=m??p??u??f;if(I!==null){await O(h);let k=join(h,"_root.md"),C=g===a||g===c||g===l?pA(I):I,R=await io({content:C,projectRoot:t,rulesDir:us,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...R.results);let P=r(g===a||g===c||g===l?n(R.rootContent,g,k):R.rootContent,g,k),{frontmatter:N,body:F}=b(P),B=N.root===true?N:{...N,root:true},U=await z(k,B,F);await S(k,U),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${us}/_root.md`,feature:"rules"});}await Bz(t,h,e,r),e.push(...await bA(t,h,r)),o!=="global"&&e.push(...await St({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:k,normalizeTo:C})=>{let R=relative(t,dirname(k)).replace(/\\/g,"/"),P=basename(k),N=P==="AGENTS.override.md";if(!R||R==="."||!N&&P!=="AGENTS.md")return null;let F=R.replace(/\//g,"-");if(!fu(R))return await Ln(join(h,`${F}.md`)),null;let B=join(h,`${F}.md`),{frontmatter:U,body:q}=b(C(B));return {destPath:B,toPath:`${us}/${F}.md`,feature:"rules",content:await z(B,{...U,root:false,globs:[`${R}/**`],...N?{codex_instruction:"override"}:{}},q)}},"mapEntry")}));}async function Bz(t,e,r,n){try{let i=(await $(join(t,Sa))).filter(l=>l.endsWith(".md")),a=join(t,Sa);for(let l of i){let c=relative(a,l).replace(/\\/g,"/");if(c==="_root.md")continue;let m=await _(l);if(!m)continue;let p=join(e,c),{frontmatter:u,body:f}=b(n(m,l,p));await O(e);let g=u.root===!0?u:{...u,root:!1},h=await z(p,g,f);await S(p,h),r.push({fromTool:Se,fromPath:l,toPath:`${us}/${c}`,feature:"rules"});}}catch{}}var DA=d(()=>{A();K();ft();zl();Me();rm();ge();PA();td();s(xA,"importCodexRules");s(Bz,"importInstructionMirrors");});async function NA(t,e){let r=e?.scope??"project",n=[],o=await H(Se,t,r),i=await H("windsurf",t,r);return await xA(t,n,o,i,r),await CA(t,n,o),await EA(t,n,o),await IA(t,n),n}var FA=d(()=>{gt();ge();SA();kA();LA();DA();s(NA,"importFromCodex");});function vA(t,e,r){let{rules:n}=t;return n.length===0?[]:n.some(i=>i.root)?[]:[{level:"warning",file:relative(e,n[0].source),target:Se,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var MA=d(()=>{ge();s(vA,"lintRules");});function $A(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))if(typeof n.description=="string"&&n.description&&e.push(x(".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 n||"type"in n){let o="type"in n?n.type:"url";e.push(x(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var GA=d(()=>{wt();s($A,"lintMcp");});function jA(t){return Ym(t)}var UA=d(()=>{td();s(jA,"codexAdvisoryInstructionPath");});var Wz,Hz,zz,Vz,KA,WA=d(()=>{RA();ge();FA();MA();GA();Et();sl();UA();Lt();Wz={name:"codex-cli",primaryRootInstructionPath:ps,generateRules:$y,generateCommands:Uy,generateAgents:By,generateSkills:jy,generateMcp:Ky,importFrom:NA},Hz={rootInstructionPath:ps,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${lo}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return jA(e)},commandPath(t,e){return ol(e,"codex-cli")?`${ao}/${V(t)}/SKILL.md`:null},agentPath(t,e){return `${Ca}/${t}.toml`}}},zz={rootInstructionPath:Ia,renderPrimaryRootInstruction:Gy,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${lo}/${e}.rules`]},skillDir:ao,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Ia,".codex/config.toml"]},rewriteGeneratedPath(t){return t===ps?Ia:t.startsWith(`${Sa}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${lo}/${t}.rules`:Ia},commandPath(t,e){return ol(e,"codex-cli")?`${ao}/${V(t)}/SKILL.md`:null},agentPath(t,e){return `${Ca}/${t}.toml`}}},Vz={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:Wz,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:vA,lint:{mcp:$A},project:Hz,globalSupport:{capabilities:Vz,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:zz},buildImportPaths:Fh,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"],excludeFromStarterInit:true,conversionDefaults:{commandsToSkills:true,agentsToSkills:false}};});function Yz(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 HA(t){return `${vn}/${t}.md`}function zA(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"],T(e,t.body.trim()||"")}function VA(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:Yz(t["x-agentsmesh-allowed-tools"])}}function JA(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"],T(r,e.trim()||"")}var nd=d(()=>{K();Mn();s(Yz,"toStringArray");s(HA,"continueCommandRulePath");s(zA,"serializeCommandRule");s(VA,"parseCommandRuleFrontmatter");s(JA,"serializeImportedCommand");});function YA(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:jo,content:T(n,r.body.trim()||"")});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("continue"))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs),e.push({path:`${Zr}/${o}.md`,content:T(i,n.body.trim()||"")});}return e}function XA(t){return t.commands.map(e=>({path:`${vn}/${e.name}.md`,content:zA(e)}))}function ZA(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:wu,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function QA(t){return t.agents.map(e=>({path:`${je}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function qA(t){return it(t,je)}var tb=d(()=>{rt();ut();K();nd();Mn();s(YA,"generateRules");s(XA,"generateCommands");s(ZA,"generateMcp");s(QA,"generateAgents");s(qA,"generateSkills");});function qz(t,e){let n=(e===".json"?JSON.parse(t):parse(t)??{}).mcpServers;if(!n||typeof n!="object"||Array.isArray(n))return {};let o={};for(let[i,a]of Object.entries(n)){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a;typeof l.command=="string"&&(o[i]={type:typeof l.type=="string"?l.type:"stdio",command:l.command,args:bs(l.args),env:wn(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function tV(t,e){let r=(await $(join(t,vh))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await _(i);a&&(Object.assign(n,qz(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Wt(t,$h,n);for(let i of o)e.push({fromTool:yl,fromPath:i,toPath:$h,feature:"mcp"});}}async function rb(t){let e=[],r=await H(yl,t);return e.push(...await Y(od,t,"project",{normalize:r})),await et(t,je,yl,e,r),await tV(t,e),e}var nb=d(()=>{gt();A();rt();Ot();Vr();cr();Mn();zy();s(qz,"readMcpServers");s(tV,"importMcp");s(rb,"importFromContinue");});function eV(t){return t==="general.md"||t==="_root.md"}var ob,sb,ib=d(()=>{K();ft();nd();Mn();s(eV,"isContinueRootRulePath");ob=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=eV(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:l}=b(e(i)),c={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return c.description===void 0&&delete c.description,c.globs===void 0&&delete c.globs,{destPath:i,toPath:`${Au}/${o}`,content:await z(i,c,l)}},"continueRuleMapper"),sb=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=b(r(o)),l=VA(i,t),c=l.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${c}.md`:`${c}.md`,u=join(n,p),f=await It(u,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},b(JA(l,a)).body);return {destPath:u,toPath:`${bu}/${p}`,content:f}},"continueCommandMapper");});function ab(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:yl}))}var lb=d(()=>{Ct();Mn();s(ab,"lintRules");});function cb(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>x(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var mb=d(()=>{wt();s(cb,"lintCommands");});function sV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var pb,ub=d(()=>{A();Mn();s(sV,"computeStatus");pb=s(async(t,e,r,n)=>{if(r!=="global")return [];let o=n.has("rules"),i=n.has("commands"),a=n.has("mcp");if(!(o&&t.rules.length>0||i&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let c={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(c.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(c.prompts=t.commands.map(u=>{let f={name:u.name};return u.description&&(f.description=u.description),f.prompt=u.body.trim(),f})),a&&t.mcp!==null){let u=Object.entries(t.mcp.mcpServers);u.length>0&&(c.mcpServers=u.map(([f,g])=>({name:f,...g})));}let m=stringify(c),p=await _(join(e,Sm));return [{target:"continue",path:Sm,content:m,currentContent:p??void 0,status:sV(p,m)}]},"generateContinueGlobalConfig");});function aV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var db,fb=d(()=>{A();Mn();ub();s(aV,"computeStatus");db=s(async(t,e,r,n)=>{let o=await pb(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let i=t.rules.find(c=>c.root);if(!i)return o;let a=i.body.trim(),l=await _(join(e,_l));return [...o,{target:"continue",path:_l,content:a,currentContent:l??void 0,status:aV(l,a)}]},"generateContinueScopeExtras");});var lV,cV,mV,pV,od,zy=d(()=>{ut();tb();Mn();nb();ib();lb();mb();nd();Et();fb();lV={name:"continue",primaryRootInstructionPath:jo,generateRules:YA,generateCommands:XA,generateAgents:QA,generateSkills:qA,generateMcp:ZA,importFrom:rb},cV={rootInstructionPath:jo,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Zr}/${t}.md`},commandPath(t,e){return HA(t)},agentPath(t){return `${je}/${W(t)}/SKILL.md`}}},mV={rootInstructionPath:jo,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[_l]}],skillDir:je,managedOutputs:{dirs:[Zr,vn,je,".agents/skills"],files:[wu,_l,Sm]},mirrorGlobalPath(t,e){return t.startsWith(`${je}/`)?`.agents/skills/${t.slice(je.length+1)}`:null},paths:{rulePath(t,e){return `${Zr}/${t}.md`},commandPath(t,e){return `${vn}/${t}.md`},agentPath(t){return `${je}/${W(t)}/SKILL.md`}}},pV={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},od={id:"continue",metadata:{displayName:"Continue",category:"ide",officialUrl:"https://continue.dev",shortDescription:"Open-source AI code assistant"},generators:lV,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:ab,lint:{commands:cb},project:cV,globalSupport:{capabilities:pV,detectionPaths:[Zr,vn,".continue/mcpServers",je],layout:mV,scopeExtras:db},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Zr],global:[Zr]},canonicalDir:Au,extensions:[".md"],map:ob},commands:{feature:"commands",mode:"directory",source:{project:[vn],global:[vn]},canonicalDir:bu,extensions:[".md"],map:sb}},buildImportPaths:Gh,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"],conversionDefaults:{agentsToSkills:true}};});var ds,ka,gb,Ea,ii,co,mo,La,Oa,sd,id,hb,Jy,yb,ai,Zl,fs,Ql,wa,Yy,Xy,Dr=d(()=>{ds="copilot",ka=".github/copilot-instructions.md",gb=".github/copilot",Ea=".github/instructions",ii=".github/prompts",co=".github/hooks",mo=".github/skills",La=".github/agents",Oa=".agentsmesh/rules",sd=".agentsmesh/commands",id=".agentsmesh/agents",hb=".agentsmesh/skills",Jy=".agentsmesh/hooks.yaml",yb=".github/copilot-hooks",ai=".copilot/copilot-instructions.md",Zl=".copilot/agents",fs=".copilot/skills",Ql=".copilot/prompts",wa=".copilot/AGENTS.md",Yy=".claude/skills",Xy=".agents/skills";});function _b(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 ad(t){return `${ii}/${t}.prompt.md`}function Rb(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"],T(e,t.body.trim()||"")}function Ib(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=_b(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:_b(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var ld=d(()=>{K();Dr();s(_b,"toStringArray");s(ad,"commandPromptPath");s(Rb,"serializeCommandPrompt");s(Ib,"parseCommandPromptFrontmatter");});function cd(t){return Lo(t)}var Zy=d(()=>{Ur();s(cd,"hasHookCommand");});function fV(t){let e=basename(t,".md");return e==="_root"?"root":e}function gV(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function Sb(t){let e=[],r=t.rules.find(n=>n.root);r?.body.trim()&&e.push(r.body.trim());for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("copilot"))continue;let o=n.body.trim();if(!o)continue;let i=n.description?`## ${n.description}`:null;i?e.push(`${i}
105
107
 
106
108
  ${o}`):e.push(o);}return e.join(`
107
109
 
108
- `)}function gb(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:Sa,content:e.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("copilot")||n.globs.length===0)continue;let o=Qz(n.source),i={description:n.description||void 0,applyTo:n.globs.length===1?n.globs[0]:n.globs};Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l];});let a=T(i,n.body.trim()||"");r.push({path:`${Ca}/${o}.instructions.md`,content:a});}return r}function hb(t){return t.commands.map(e=>({path:Ju(e.name),content:ub(e)}))}function yb(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${lo}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${lo}/${r.name}/${a}`,content:i.content});}}return e}function _b(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${ka}/${e.name}.agent.md`,content:n}})}function Rb(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=qz(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&Xu(a)).map((a,l)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${l}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[o,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${ao}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var Ib=d(()=>{j();wr();Yu();My();s(Qz,"ruleSlug");s(qz,"mapHookEvent");s(fb,"renderCopilotGlobalInstructions");s(gb,"generateRules");s(hb,"generateCommands");s(yb,"generateSkills");s(_b,"generateAgents");s(Rb,"generateHooks");});function eV(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function rV(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function kb(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 Eb(t,e){let r=join(t,ao),o=(await v(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of o){let u=await _(p);if(!u)continue;let f;try{f=JSON.parse(u);}catch{continue}if(!(!f||typeof f.hooks!="object"||f.hooks===null))for(let[g,h]of Object.entries(f.hooks)){let R=eV(g);if(!(!R||!Array.isArray(h)))for(let C of h){if(!C||typeof C!="object")continue;let S=C,k=typeof S.bash=="string"?S.bash:"";if(!k)continue;let P=join(r,k.replace(/^\.\//,"")),N=await _(P);if(!N)continue;let F=kb(N);F&&(i[R]||(i[R]=[]),i[R].push({matcher:rV(S.comment),command:F,type:"command"}));}}}let a=join(t,mb),c=(await v(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of c){let u=await _(p);if(!u)continue;let f=basename(p,".sh"),g=f.lastIndexOf("-"),h=g>0?f.slice(0,g):f;i[h]||(i[h]=[]),i[h].push({matcher:"*",command:kb(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Ny);await O(dirname(m)),await I(m,stringify(i)),e.push({fromTool:ps,fromPath:join(t,ao),toPath:Ny,feature:"hooks"});}var Lb=d(()=>{w();wr();s(eV,"mapCopilotHookEvent");s(rV,"extractMatcher");s(kb,"extractWrapperCommand");s(Eb,"importHooks");});async function Ob(t,e,r,n=lo){let o=join(t,n),i=await Bm(o),a={projectRoot:t,destCanonicalSkillsDir:cb,targetName:ps,normalize:r,results:e};for(let[l,c]of i)await Um(l,c,a);}var Ab=d(()=>{Yl();wr();s(Ob,"importSkills");});async function wb(t,e={}){let r=e.scope??"project",n=[],o=await B(ps,t,r);return n.push(...await J(Zu,t,r,{normalize:o})),await Ob(t,n,o,r==="global"?us:lo),r==="project"&&await Eb(t,n),n}var bb=d(()=>{dt();Et();wr();Lb();Ab();$y();s(wb,"importFromCopilot");});function Pb(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var Tb,xb,Db,Nb,Fb=d(()=>{j();ut();or();Yu();wr();s(Pb,"pruneUndefined");Tb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=b(e(o)),l=wo(i.globs),c=Pb({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Ea}/${n}`,content:await K(o,c,a)}},"copilotLegacyRuleMapper"),xb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.endsWith(".instructions.md")?t.replace(/\.instructions\.md$/i,".md"):t,o=join(r,n),{frontmatter:i,body:a}=b(e(o)),l=wo(i.applyTo!==void 0?i.applyTo:i.globs),c=Pb({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Ea}/${n}`,content:await K(o,c,a)}},"copilotNewRuleMapper"),Db=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=e.replace(/\.prompt\.md$/i,".md"),i=join(n,o),{frontmatter:a,body:l}=b(r(i)),c=db(a,t),m=o.includes("/")?o.slice(0,o.lastIndexOf("/")):"",p=`${c.name}.md`,u=m?`${m}/${p}`:p,f=join(n,u);return {destPath:f,toPath:`${zu}/${u}`,content:await _t(f,{description:c.description,hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:c.allowedTools,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"tools")||Object.prototype.hasOwnProperty.call(a,"x-agentsmesh-allowed-tools")},l)}},"copilotCommandMapper"),Nb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(!t.endsWith(".agent.md"))return null;let n=t.replace(/\.agent\.md$/i,".md"),o=basename(n,".md"),i=join(r,n),{frontmatter:a,body:l}=b(e(i));return {destPath:i,toPath:`${Vu}/${n}`,content:await Vt(i,{...a,name:typeof a.name=="string"?a.name:o},l)}},"copilotAgentMapper");});function vb(t,e,r,n){let i=V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(l=>({...l,target:ps})),a=t.rules.filter(l=>!l.root&&l.globs.length===0);return [...i,...a.map(l=>({level:"warning",file:l.source,target:ps,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var Mb=d(()=>{It();wr();s(vb,"lintRules");});function $b(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>x(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function Gb(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification","UserPromptSubmit"],r=new Set(e),n=Object.keys(t.hooks).filter(i=>!r.has(i)).map(i=>Ps(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(x(".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.")),n}var jb=d(()=>{Lt();s($b,"lintCommands");s(Gb,"lintHooks");});function aV(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function lV(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function cV(t,e){let r=t.match(Bb);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function mV(t,e){let n=e.match(Bb)?.groups?.path;if(!n)return null;let o=join(t,n),i=await _(o);if(i===null)return null;let a=lV(t,o);return a?{assetPath:`${ao}/scripts/${a}`,content:i,rewrittenCommand:cV(e,a)}:null}function pV(t,e){return `${ao}/scripts/${aV(t)}-${e}.sh`}function Ub(t){return t.replace(/[\r\n]+/g," ")}function uV(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${Ub(e)}`,`# agentsmesh-command: ${Ub(t)}`,"set -eu",t,""].join(`
109
- `)}async function Kb(t,e,r){if(!e.hooks)return r;let n=[],o=new Map;for(let[i,a]of Object.entries(e.hooks)){if(!Array.isArray(a))continue;let l=0;for(let c of a){if(!Xu(c))continue;let m=pV(i,l),p=c.command,u=await mV(t,c.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=uV(p,c.matcher).replace(`set -eu
110
+ `)}function Cb(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:ka,content:e.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("copilot")||n.globs.length===0)continue;let o=fV(n.source),i={description:n.description||void 0,applyTo:n.globs.length===1?n.globs[0]:n.globs};Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l];});let a=T(i,n.body.trim()||"");r.push({path:`${Ea}/${o}.instructions.md`,content:a});}return r}function kb(t){return t.commands.map(e=>({path:ad(e.name),content:Rb(e)}))}function Eb(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${mo}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${mo}/${r.name}/${a}`,content:i.content});}}return e}function Lb(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${La}/${e.name}.agent.md`,content:n}})}function Ob(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=gV(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&cd(a)).map((a,l)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${l}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[o,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${co}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var wb=d(()=>{K();Dr();ld();Zy();s(fV,"ruleSlug");s(gV,"mapHookEvent");s(Sb,"renderCopilotGlobalInstructions");s(Cb,"generateRules");s(kb,"generateCommands");s(Eb,"generateSkills");s(Lb,"generateAgents");s(Ob,"generateHooks");});function yV(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function _V(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function Pb(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 Tb(t,e){let r=join(t,co),o=(await $(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of o){let u=await _(p);if(!u)continue;let f;try{f=JSON.parse(u);}catch{continue}if(!(!f||typeof f.hooks!="object"||f.hooks===null))for(let[g,h]of Object.entries(f.hooks)){let I=yV(g);if(!(!I||!Array.isArray(h)))for(let k of h){if(!k||typeof k!="object")continue;let C=k,R=typeof C.bash=="string"?C.bash:"";if(!R)continue;let P=join(r,R.replace(/^\.\//,"")),N=await _(P);if(!N)continue;let F=Pb(N);F&&(i[I]||(i[I]=[]),i[I].push({matcher:_V(C.comment),command:F,type:"command"}));}}}let a=join(t,yb),c=(await $(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of c){let u=await _(p);if(!u)continue;let f=basename(p,".sh"),g=f.lastIndexOf("-"),h=g>0?f.slice(0,g):f;i[h]||(i[h]=[]),i[h].push({matcher:"*",command:Pb(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Jy);await O(dirname(m)),await S(m,stringify(i)),e.push({fromTool:ds,fromPath:join(t,co),toPath:Jy,feature:"hooks"});}var xb=d(()=>{A();Dr();s(yV,"mapCopilotHookEvent");s(_V,"extractMatcher");s(Pb,"extractWrapperCommand");s(Tb,"importHooks");});async function Db(t,e,r,n=mo){let o=join(t,n),i=await zm(o),a={projectRoot:t,destCanonicalSkillsDir:hb,targetName:ds,normalize:r,results:e};for(let[l,c]of i)await Hm(l,c,a);}var Nb=d(()=>{Xl();Dr();s(Db,"importSkills");});async function Fb(t,e={}){let r=e.scope??"project",n=[],o=await H(ds,t,r);return n.push(...await Y(md,t,r,{normalize:o})),await Db(t,n,o,r==="global"?fs:mo),r==="project"&&await Tb(t,n),n}var vb=d(()=>{gt();Ot();Dr();xb();Nb();Qy();s(Fb,"importFromCopilot");});function Mb(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var $b,Gb,jb,Ub,Bb=d(()=>{K();ft();cr();ld();Dr();s(Mb,"pruneUndefined");$b=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=b(e(o)),l=Po(i.globs),c=Mb({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Oa}/${n}`,content:await z(o,c,a)}},"copilotLegacyRuleMapper"),Gb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.endsWith(".instructions.md")?t.replace(/\.instructions\.md$/i,".md"):t,o=join(r,n),{frontmatter:i,body:a}=b(e(o)),l=Po(i.applyTo!==void 0?i.applyTo:i.globs),c=Mb({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Oa}/${n}`,content:await z(o,c,a)}},"copilotNewRuleMapper"),jb=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=e.replace(/\.prompt\.md$/i,".md"),i=join(n,o),{frontmatter:a,body:l}=b(r(i)),c=Ib(a,t),m=o.includes("/")?o.slice(0,o.lastIndexOf("/")):"",p=`${c.name}.md`,u=m?`${m}/${p}`:p,f=join(n,u);return {destPath:f,toPath:`${sd}/${u}`,content:await It(f,{description:c.description,hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:c.allowedTools,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"tools")||Object.prototype.hasOwnProperty.call(a,"x-agentsmesh-allowed-tools")},l)}},"copilotCommandMapper"),Ub=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(!t.endsWith(".agent.md"))return null;let n=t.replace(/\.agent\.md$/i,".md"),o=basename(n,".md"),i=join(r,n),{frontmatter:a,body:l}=b(e(i));return {destPath:i,toPath:`${id}/${n}`,content:await Jt(i,{...a,name:typeof a.name=="string"?a.name:o},l)}},"copilotAgentMapper");});function Kb(t,e,r,n){let i=J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(l=>({...l,target:ds})),a=t.rules.filter(l=>!l.root&&l.globs.length===0);return [...i,...a.map(l=>({level:"warning",file:l.source,target:ds,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var Wb=d(()=>{Ct();Dr();s(Kb,"lintRules");});function Hb(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>x(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function zb(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification","UserPromptSubmit"],r=new Set(e),n=Object.keys(t.hooks).filter(i=>!r.has(i)).map(i=>Ts(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(x(".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.")),n}var Vb=d(()=>{wt();s(Hb,"lintCommands");s(zb,"lintHooks");});function kV(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function EV(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function LV(t,e){let r=t.match(Yb);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function OV(t,e){let n=e.match(Yb)?.groups?.path;if(!n)return null;let o=join(t,n),i=await _(o);if(i===null)return null;let a=EV(t,o);return a?{assetPath:`${co}/scripts/${a}`,content:i,rewrittenCommand:LV(e,a)}:null}function wV(t,e){return `${co}/scripts/${kV(t)}-${e}.sh`}function Jb(t){return t.replace(/[\r\n]+/g," ")}function AV(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${Jb(e)}`,`# agentsmesh-command: ${Jb(t)}`,"set -eu",t,""].join(`
111
+ `)}async function Xb(t,e,r){if(!e.hooks)return r;let n=[],o=new Map;for(let[i,a]of Object.entries(e.hooks)){if(!Array.isArray(a))continue;let l=0;for(let c of a){if(!cd(c))continue;let m=wV(i,l),p=c.command,u=await OV(t,c.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=AV(p,c.matcher).replace(`set -eu
110
112
  `,`set -eu
111
113
  HOOK_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
112
- `);n.push({path:m,content:f}),l++;}}return [...r,...n,...o.values()]}var Bb,Wb=d(()=>{w();wr();My();Bb=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(aV,"safePhaseName");s(lV,"toRepoRelative");s(cV,"rewriteWrapperCommand");s(mV,"buildAssetOutput");s(pV,"wrapperPath");s(Ub,"safeShellLine");s(uV,"buildWrapper");s(Kb,"addHookScriptAssets");});function fV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Hb,zb=d(()=>{w();wr();s(fV,"computeStatus");Hb=s(async(t,e,r,n)=>{if(r!=="global"||!n.has("rules"))return [];let o=t.rules.find(l=>l.root);if(!o)return [];let i=o.body.trim(),a=await _(join(e,La));return [{target:"copilot",path:La,content:i,currentContent:a??void 0,status:fV(a,i)}]},"generateCopilotGlobalExtras");});var hV,yV,_V,RV,Zu,$y=d(()=>{Ib();wr();bb();Fb();Mb();Ct();Yu();jb();Wb();zb();hV={name:"copilot",primaryRootInstructionPath:Sa,generateRules:gb,generateCommands:hb,generateAgents:_b,generateSkills:yb,generateHooks:Rb,importFrom:wb},yV={rootInstructionPath:Sa,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 [`${Ca}/${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 `${Ca}/${t}.instructions.md`},commandPath(t,e){return Ju(t)},agentPath(t,e){return `${ka}/${t}.agent.md`}}},_V={rootInstructionPath:ii,renderPrimaryRootInstruction:fb,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[La]}],skillDir:us,managedOutputs:{dirs:[Xl,us,Zl,vy,Fy],files:[ii,La]},rewriteGeneratedPath(t){return t===Sa?ii:t.startsWith(`${Ca}/`)?ii:t.startsWith(`${si}/`)?t.replace(`${si}/`,`${Zl}/`):t.startsWith(`${ka}/`)?t.replace(`${ka}/`,`${Xl}/`):t.startsWith(`${lo}/`)?t.replace(`${lo}/`,`${us}/`):t.startsWith(`${ao}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${us}/`)&&!e.includes("codex-cli")){let r=t.slice(us.length+1);return [`.agents/skills/${r}`,`${Fy}/${r}`]}return null},paths:{rulePath(t,e){return ii},commandPath(t,e){return `${Zl}/${t}.prompt.md`},agentPath(t,e){return `${Xl}/${t}.agent.md`}}},RV={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Zu={id:"copilot",metadata:{displayName:"GitHub Copilot",category:"ide",officialUrl:"https://github.com/features/copilot",shortDescription:"GitHub's AI pair programmer"},generators:hV,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:vb,lint:{commands:$b,hooks:Gb},postProcessHookOutputs:s(async(t,e,r)=>Kb(t,e,[...r]),"postProcessHookOutputs"),project:yV,globalSupport:{capabilities:RV,detectionPaths:[ii,La,Xl,us,Zl,vy],layout:_V,scopeExtras:Hb},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Sa],global:[ii]},canonicalDir:Ea,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[lb]},canonicalDir:Ea,extensions:[".instructions.md"],map:Tb},{feature:"rules",mode:"directory",source:{project:[Ca]},canonicalDir:Ea,extensions:[".instructions.md",".md"],map:xb}],commands:{feature:"commands",mode:"directory",source:{project:[si],global:[Zl]},canonicalDir:zu,extensions:[".prompt.md"],map:Db},agents:{feature:"agents",mode:"directory",source:{project:[ka],global:[Xl]},canonicalDir:Vu,extensions:[".agent.md"],map:Nb}},buildImportPaths:Oh,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function Qu(t){return {$schema:"https://charm.land/crush.json",...t}}var Vb=d(()=>{s(Qu,"buildCrushConfigJson");});function Jb(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)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:pr,content:o}]:[]}function Yb(t){return rt(t,Qt)}function Xb(t){return t.commands.map(e=>({path:`${Qt}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function Zb(t){return t.agents.map(e=>({path:`${Qt}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function Qb(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Qu({mcp:t.mcp.mcpServers});return [{path:ve,content:JSON.stringify(e,null,2)}]}function qb(t){if(!t.hooks)return [];let e=IV(t);if(Object.keys(e).length===0)return [];let r=Qu({hooks:e});return [{path:ve,content:JSON.stringify(r,null,2)}]}function tP(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];if(e.length===0&&r.length===0&&n.length===0)return [];let o={};e.length>0&&(o.allowed_tools=e),r.length>0&&(o.denied_tools=r);let i=Qu({permissions:o});return [{path:ve,content:JSON.stringify(i,null,2)}]}function eP(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
113
- `);return [{path:Go,content:e}]}function IV(t){if(!t.hooks)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let i of n){let a=typeof i.command=="string"?i.command.trim():"";if(!a)continue;let l={matcher:i.matcher,command:a};i.timeout!==void 0&&(l.timeout=i.timeout),o.push(l);}o.length>0&&(e[r]=o);}return e}var rP=d(()=>{tt();Ut();mt();kt();_l();Vb();s(Jb,"generateRules");s(Yb,"generateSkills");s(Xb,"generateCommands");s(Zb,"generateAgents");s(Qb,"generateMcp");s(qb,"generateHooks");s(tP,"generatePermissions");s(eP,"generateIgnore");s(IV,"buildCrushHooksFromCanonical");});async function oP(t,e={}){let r=e.scope??"project",n=[],o=await B(mr,t,r);return n.push(...await J(qu,t,r,{normalize:o})),await q(t,r==="global"?Me:Qt,mr,n,o),await SV(t,n),n}async function SV(t,e){let r=join(t,ve),n=await _(r);if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||Array.isArray(o))return;let i=o,a=CV(i.mcp);if(Object.keys(a).length>0){let c=Su,m=join(t,c);await O(dirname(m)),await I(m,JSON.stringify({mcpServers:a},null,2)),e.push({fromTool:mr,fromPath:r,toPath:c,feature:"mcp"});}let l=kV(i.hooks);if(l!==null&&Object.keys(l).length>0){let c=".agentsmesh/hooks.yaml",m=join(t,c);await O(dirname(m));let p=EV(l);await I(m,p),e.push({fromTool:mr,fromPath:r,toPath:c,feature:"hooks"});}}function CV(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;let o=n,i=typeof o.description=="string"?o.description:void 0;if(typeof o.command=="string"){e[r]={type:typeof o.type=="string"?o.type:"stdio",command:o.command,args:ws(o.args),env:Ln(o.env),...i!==void 0?{description:i}:{}};continue}typeof o.url=="string"&&(e[r]={type:typeof o.type=="string"?o.type:"http",url:o.url,headers:Ln(o.headers),env:Ln(o.env),...i!==void 0?{description:i}:{}});}return e}function kV(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,l=typeof a.command=="string"?a.command.trim():"";if(!l)continue;let m={matcher:typeof a.matcher=="string"?a.matcher:"",command:l};typeof a.timeout=="number"&&(m.timeout=a.timeout),o.push(m);}o.length>0&&(e[r]=o);}return Object.keys(e).length>0?e:null}function EV(t){let e=[];for(let[r,n]of Object.entries(t)){e.push(`${r}:`);for(let o of n)e.push(` - matcher: ${JSON.stringify(o.matcher)}`),e.push(` command: ${JSON.stringify(o.command)}`),o.timeout!==void 0&&e.push(` timeout: ${o.timeout}`);}return e.join(`
114
- `)}var sP=d(()=>{dt();tt();Et();w();or();jy();_l();s(oP,"importFromCrush");s(SV,"importCrushConfigJson");s(CV,"parseCrushMcpServers");s(kV,"parseCrushHooks");s(EV,"serializeHooksYaml");});function iP(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:mr}))}var aP=d(()=>{It();_l();s(iP,"lintRules");});function lP(t){return t.commands.length===0?[]:[x(".agentsmesh/commands","crush","Crush has no native slash-command format; commands are projected as skills via supportsConversion.")]}var cP=d(()=>{Lt();s(lP,"lintCommands");});function Uy(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function pP(t,e){let r=Uy(t),n=OV.parse(JSON.parse(e)),o={...r};n.permissions!==void 0&&(o.permissions=n.permissions),n.hooks!==void 0&&(o.hooks=n.hooks);let i=o.permissions;return i&&typeof i=="object"&&!Array.isArray(i)&&!("ask"in i)&&(i.ask=[]),JSON.stringify(o,null,2)}function uP(t,e){let r=Uy(t),n=AV.parse(JSON.parse(e)),o={...r};return n.mcpServers!==void 0&&(o.mcpServers=n.mcpServers),n.hooks!==void 0&&(o.hooks=n.hooks),n.experimental!==void 0&&(o.experimental=n.experimental),n.context!==void 0&&(o.context=n.context),JSON.stringify(o,null,2)}function dP(t,e){let r=Uy(t),n=LV.parse(JSON.parse(e)),o={...r};return n.$schema!==void 0&&(o.$schema=n.$schema),n.mcp!==void 0&&(o.mcp=n.mcp),n.hooks!==void 0&&(o.hooks=n.hooks),n.permissions!==void 0&&(o.permissions=n.permissions),n.options!==void 0&&(o.options=n.options),JSON.stringify(o,null,2)}var mP,LV,OV,AV,td=d(()=>{mP=[".claude/settings.json",".gemini/settings.json"],LV=z.object({$schema:z.string().optional(),mcp:z.record(z.string(),z.unknown()).optional(),hooks:z.record(z.string(),z.unknown()).optional(),permissions:z.record(z.string(),z.unknown()).optional(),options:z.record(z.string(),z.unknown()).optional()}).passthrough(),OV=z.object({permissions:z.object({allow:z.array(z.string()).optional(),deny:z.array(z.string()).optional()}).passthrough().optional(),hooks:z.record(z.string(),z.unknown()).optional()}).passthrough(),AV=z.object({mcpServers:z.record(z.string(),z.unknown()).optional(),hooks:z.record(z.string(),z.unknown()).optional(),experimental:z.record(z.string(),z.unknown()).optional(),context:z.record(z.string(),z.unknown()).optional()}).passthrough();s(Uy,"parseJsonObject");s(pP,"mergeSettingsJson");s(uP,"mergeGeminiSettingsJson");s(dP,"mergeCrushConfigJson");});var wV,bV,PV,TV,xV,qu,jy=d(()=>{kt();mt();rP();ee();sP();aP();cP();Ct();td();_l();wV={name:mr,primaryRootInstructionPath:pr,generateRules:Jb,generateCommands:Xb,generateAgents:Zb,generateSkills:Yb,generateMcp:Qb,generateHooks:qb,generatePermissions:tP,generateIgnore:eP,importFrom:oP},bV={rootInstructionPath:pr,skillDir:Qt,managedOutputs:{dirs:[Qt],files:[pr,ve,Go]},paths:{rulePath(t){return pr},commandPath(t){return `${Qt}/${H(t)}/SKILL.md`},agentPath(t){return `${Qt}/${U(t)}/SKILL.md`}}},PV={rootInstructionPath:Ki,skillDir:Me,managedOutputs:{dirs:[Me],files:[Ki,_u]},rewriteGeneratedPath(t){return t===pr?Ki:t===ve?_u:t===Go?null:t.startsWith(`${Qt}/`)?t.replace(`${Qt}/`,`${Me}/`):t},mirrorGlobalPath(t,e){return pt(t,Me,e)},paths:{rulePath(t){return Ki},commandPath(t){return `${Me}/${H(t)}/SKILL.md`},agentPath(t){return `${Me}/${U(t)}/SKILL.md`}}},TV={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},xV={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"none",permissions:"none"},qu={id:mr,metadata:{displayName:"Crush",category:"cli",officialUrl:"https://github.com/charmbracelet/crush",shortDescription:"Charm's TUI coding agent"},generators:wV,capabilities:TV,emptyImportMessage:"No Crush config found (CRUSH.md, .crush/skills/, crush.json, or .crushignore).",lintRules:iP,lint:{commands:lP},supportsConversion:{commands:true,agents:true},project:bV,globalSupport:{capabilities:xV,detectionPaths:[Ki,_u,Me],layout:PV},mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===ve?dP(o,r):null},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[pr],global:[Ki]},canonicalDir:Ru,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Go]},canonicalDir:".agentsmesh",canonicalFilename:Iu}},buildImportPaths:Ah,detectionPaths:[pr,ve,Qt,Go],sharedArtifacts:{".crush/skills/":"owner"}};});function By(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:vs,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let l=T(a,i);e.push({path:jo,content:l});}let n=t.rules.filter(i=>!i.root&&(i.targets.length===0||i.targets.includes("cursor")));for(let i of n){let a=basename(i.source,".md"),c={alwaysApply:i.trigger==="always_on"};i.description&&(c.description=i.description),i.globs.length>0&&(c.globs=i.globs);let m=T(c,i.body.trim()||"");e.push({path:`${ur}/${a}.mdc`,content:m});}let o=fP(t);return o.trim()&&e.push({path:Yr,content:o}),e}function fP(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("cursor"))),n=[];return e?.body.trim()?n.push(lt(e.body,r)):r.length>0&&n.push(lt("",r)),n.filter(Boolean).join(`
114
+ `);n.push({path:m,content:f}),l++;}}return [...r,...n,...o.values()]}var Yb,Zb=d(()=>{A();Dr();Zy();Yb=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(kV,"safePhaseName");s(EV,"toRepoRelative");s(LV,"rewriteWrapperCommand");s(OV,"buildAssetOutput");s(wV,"wrapperPath");s(Jb,"safeShellLine");s(AV,"buildWrapper");s(Xb,"addHookScriptAssets");});function PV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Qb,qb=d(()=>{A();Dr();s(PV,"computeStatus");Qb=s(async(t,e,r,n)=>{if(r!=="global"||!n.has("rules"))return [];let o=t.rules.find(l=>l.root);if(!o)return [];let i=o.body.trim(),a=await _(join(e,wa));return [{target:"copilot",path:wa,content:i,currentContent:a??void 0,status:PV(a,i)}]},"generateCopilotGlobalExtras");});var xV,DV,NV,FV,md,Qy=d(()=>{wb();Dr();vb();Bb();Wb();Et();ld();Vb();Zb();qb();xV={name:"copilot",primaryRootInstructionPath:ka,generateRules:Cb,generateCommands:kb,generateAgents:Lb,generateSkills:Eb,generateHooks:Ob,importFrom:Fb},DV={rootInstructionPath:ka,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 [`${Ea}/${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 `${Ea}/${t}.instructions.md`},commandPath(t,e){return ad(t)},agentPath(t,e){return `${La}/${t}.agent.md`}}},NV={rootInstructionPath:ai,renderPrimaryRootInstruction:Sb,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[wa]}],skillDir:fs,managedOutputs:{dirs:[Zl,fs,Ql,Xy,Yy],files:[ai,wa]},rewriteGeneratedPath(t){return t===ka?ai:t.startsWith(`${Ea}/`)?ai:t.startsWith(`${ii}/`)?t.replace(`${ii}/`,`${Ql}/`):t.startsWith(`${La}/`)?t.replace(`${La}/`,`${Zl}/`):t.startsWith(`${mo}/`)?t.replace(`${mo}/`,`${fs}/`):t.startsWith(`${co}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${fs}/`)&&!e.includes("codex-cli")){let r=t.slice(fs.length+1);return [`.agents/skills/${r}`,`${Yy}/${r}`]}return null},paths:{rulePath(t,e){return ai},commandPath(t,e){return `${Ql}/${t}.prompt.md`},agentPath(t,e){return `${Zl}/${t}.agent.md`}}},FV={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},md={id:"copilot",metadata:{displayName:"GitHub Copilot",category:"ide",officialUrl:"https://github.com/features/copilot",shortDescription:"GitHub's AI pair programmer"},generators:xV,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:Kb,lint:{commands:Hb,hooks:zb},postProcessHookOutputs:s(async(t,e,r)=>Xb(t,e,[...r]),"postProcessHookOutputs"),project:DV,globalSupport:{capabilities:FV,detectionPaths:[ai,wa,Zl,fs,Ql,Xy],layout:NV,scopeExtras:Qb},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[ka],global:[ai]},canonicalDir:Oa,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[gb]},canonicalDir:Oa,extensions:[".instructions.md"],map:$b},{feature:"rules",mode:"directory",source:{project:[Ea]},canonicalDir:Oa,extensions:[".instructions.md",".md"],map:Gb}],commands:{feature:"commands",mode:"directory",source:{project:[ii],global:[Ql]},canonicalDir:sd,extensions:[".prompt.md"],map:jb},agents:{feature:"agents",mode:"directory",source:{project:[La],global:[Zl]},canonicalDir:id,extensions:[".agent.md"],map:Ub}},buildImportPaths:jh,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function pd(t){return {$schema:"https://charm.land/crush.json",...t}}var tP=d(()=>{s(pd,"buildCrushConfigJson");});function eP(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(gr)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:hr,content:o}]:[]}function rP(t){return it(t,te)}function nP(t){return t.commands.map(e=>({path:`${te}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function oP(t){return t.agents.map(e=>({path:`${te}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function sP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=pd({mcp:t.mcp.mcpServers});return [{path:Ue,content:JSON.stringify(e,null,2)}]}function iP(t){if(!t.hooks)return [];let e=vV(t);if(Object.keys(e).length===0)return [];let r=pd({hooks:e});return [{path:Ue,content:JSON.stringify(r,null,2)}]}function aP(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];if(e.length===0&&r.length===0&&n.length===0)return [];let o={};e.length>0&&(o.allowed_tools=e),r.length>0&&(o.denied_tools=r);let i=pd({permissions:o});return [{path:Ue,content:JSON.stringify(i,null,2)}]}function lP(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
115
+ `);return [{path:Uo,content:e}]}function vV(t){if(!t.hooks)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let i of n){let a=typeof i.command=="string"?i.command.trim():"";if(!a)continue;let l={matcher:i.matcher,command:a};i.timeout!==void 0&&(l.timeout=i.timeout),o.push(l);}o.length>0&&(e[r]=o);}return e}var cP=d(()=>{rt();Kt();ut();Lt();Rl();tP();s(eP,"generateRules");s(rP,"generateSkills");s(nP,"generateCommands");s(oP,"generateAgents");s(sP,"generateMcp");s(iP,"generateHooks");s(aP,"generatePermissions");s(lP,"generateIgnore");s(vV,"buildCrushHooksFromCanonical");});async function pP(t,e={}){let r=e.scope??"project",n=[],o=await H(gr,t,r);return n.push(...await Y(ud,t,r,{normalize:o})),await et(t,r==="global"?Be:te,gr,n,o),await MV(t,n),n}async function MV(t,e){let r=join(t,Ue),n=await _(r);if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||Array.isArray(o))return;let i=o,a=$V(i.mcp);if(Object.keys(a).length>0){let c=Nu,m=join(t,c);await O(dirname(m)),await S(m,JSON.stringify({mcpServers:a},null,2)),e.push({fromTool:gr,fromPath:r,toPath:c,feature:"mcp"});}let l=GV(i.hooks);if(l!==null&&Object.keys(l).length>0){let c=".agentsmesh/hooks.yaml",m=join(t,c);await O(dirname(m));let p=jV(l);await S(m,p),e.push({fromTool:gr,fromPath:r,toPath:c,feature:"hooks"});}}function $V(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t)){if(!n||typeof n!="object"||Array.isArray(n))continue;let o=n,i=typeof o.description=="string"?o.description:void 0;if(typeof o.command=="string"){e[r]={type:typeof o.type=="string"?o.type:"stdio",command:o.command,args:bs(o.args),env:wn(o.env),...i!==void 0?{description:i}:{}};continue}typeof o.url=="string"&&(e[r]={type:typeof o.type=="string"?o.type:"http",url:o.url,headers:wn(o.headers),env:wn(o.env),...i!==void 0?{description:i}:{}});}return e}function GV(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,l=typeof a.command=="string"?a.command.trim():"";if(!l)continue;let m={matcher:typeof a.matcher=="string"?a.matcher:"",command:l};typeof a.timeout=="number"&&(m.timeout=a.timeout),o.push(m);}o.length>0&&(e[r]=o);}return Object.keys(e).length>0?e:null}function jV(t){let e=[];for(let[r,n]of Object.entries(t)){e.push(`${r}:`);for(let o of n)e.push(` - matcher: ${JSON.stringify(o.matcher)}`),e.push(` command: ${JSON.stringify(o.command)}`),o.timeout!==void 0&&e.push(` timeout: ${o.timeout}`);}return e.join(`
116
+ `)}var uP=d(()=>{gt();rt();Ot();A();cr();t_();Rl();s(pP,"importFromCrush");s(MV,"importCrushConfigJson");s($V,"parseCrushMcpServers");s(GV,"parseCrushHooks");s(jV,"serializeHooksYaml");});function dP(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:gr}))}var fP=d(()=>{Ct();Rl();s(dP,"lintRules");});function gP(t){return t.commands.length===0?[]:[x(".agentsmesh/commands","crush","Crush has no native slash-command format; commands are projected as skills via supportsConversion.")]}var hP=d(()=>{wt();s(gP,"lintCommands");});function e_(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function _P(t,e){let r=e_(t),n=BV.parse(JSON.parse(e)),o={...r};n.permissions!==void 0&&(o.permissions=n.permissions),n.hooks!==void 0&&(o.hooks=n.hooks);let i=o.permissions;return i&&typeof i=="object"&&!Array.isArray(i)&&!("ask"in i)&&(i.ask=[]),JSON.stringify(o,null,2)}function RP(t,e){let r=e_(t),n=KV.parse(JSON.parse(e)),o={...r};return n.mcpServers!==void 0&&(o.mcpServers=n.mcpServers),n.hooks!==void 0&&(o.hooks=n.hooks),n.experimental!==void 0&&(o.experimental=n.experimental),n.context!==void 0&&(o.context=n.context),JSON.stringify(o,null,2)}function IP(t,e){let r=e_(t),n=UV.parse(JSON.parse(e)),o={...r};return n.$schema!==void 0&&(o.$schema=n.$schema),n.mcp!==void 0&&(o.mcp=n.mcp),n.hooks!==void 0&&(o.hooks=n.hooks),n.permissions!==void 0&&(o.permissions=n.permissions),n.options!==void 0&&(o.options=n.options),JSON.stringify(o,null,2)}var yP,UV,BV,KV,dd=d(()=>{yP=[".claude/settings.json",".gemini/settings.json"],UV=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(),BV=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(),KV=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(e_,"parseJsonObject");s(_P,"mergeSettingsJson");s(RP,"mergeGeminiSettingsJson");s(IP,"mergeCrushConfigJson");});var WV,HV,zV,VV,JV,ud,t_=d(()=>{Lt();ut();cP();ne();uP();fP();hP();Et();dd();Rl();WV={name:gr,primaryRootInstructionPath:hr,generateRules:eP,generateCommands:nP,generateAgents:oP,generateSkills:rP,generateMcp:sP,generateHooks:iP,generatePermissions:aP,generateIgnore:lP,importFrom:pP},HV={rootInstructionPath:hr,skillDir:te,managedOutputs:{dirs:[te],files:[hr,Ue,Uo]},paths:{rulePath(t){return hr},commandPath(t){return `${te}/${V(t)}/SKILL.md`},agentPath(t){return `${te}/${W(t)}/SKILL.md`}}},zV={rootInstructionPath:Hi,skillDir:Be,managedOutputs:{dirs:[Be],files:[Hi,Tu]},rewriteGeneratedPath(t){return t===hr?Hi:t===Ue?Tu:t===Uo?null:t.startsWith(`${te}/`)?t.replace(`${te}/`,`${Be}/`):t},mirrorGlobalPath(t,e){return dt(t,Be,e)},paths:{rulePath(t){return Hi},commandPath(t){return `${Be}/${V(t)}/SKILL.md`},agentPath(t){return `${Be}/${W(t)}/SKILL.md`}}},VV={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},JV={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"none",permissions:"none"},ud={id:gr,metadata:{displayName:"Crush",category:"cli",officialUrl:"https://github.com/charmbracelet/crush",shortDescription:"Charm's TUI coding agent"},generators:WV,capabilities:VV,emptyImportMessage:"No Crush config found (CRUSH.md, .crush/skills/, crush.json, or .crushignore).",lintRules:dP,lint:{commands:gP},supportsConversion:{commands:true,agents:true},project:HV,globalSupport:{capabilities:JV,detectionPaths:[Hi,Tu,Be],layout:zV},mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Ue?IP(o,r):null},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[hr],global:[Hi]},canonicalDir:xu,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Uo]},canonicalDir:".agentsmesh",canonicalFilename:Du}},buildImportPaths:Uh,detectionPaths:[hr,Ue,te,Uo],sharedArtifacts:{".crush/skills/":"owner"}};});function r_(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:Ms,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let l=T(a,i);e.push({path:Bo,content:l});}let n=t.rules.filter(i=>!i.root&&(i.targets.length===0||i.targets.includes("cursor")));for(let i of n){let a=basename(i.source,".md"),c={alwaysApply:i.trigger==="always_on"};i.description&&(c.description=i.description),i.globs.length>0&&(c.globs=i.globs);let m=T(c,i.body.trim()||"");e.push({path:`${yr}/${a}.mdc`,content:m});}let o=SP(t);return o.trim()&&e.push({path:qr,content:o}),e}function SP(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("cursor"))),n=[];return e?.body.trim()?n.push(mt(e.body,r)):r.length>0&&n.push(mt("",r)),n.filter(Boolean).join(`
115
117
 
116
- `)}var gP=d(()=>{j();Ut();Kt();s(By,"generateRules");s(fP,"renderCursorGlobalUserRules");});function Ky(t){return t.commands.map(e=>({path:`${dr}/${e.name}.md`,content:e.body.trim()||""}))}var hP=d(()=>{Kt();s(Ky,"generateCommands");});function Wy(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:$e,content:e}]}var yP=d(()=>{Kt();s(Wy,"generateMcp");});function Hy(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${me}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${me}/${r.name}/${a}`,content:i.content});}}return e}var _P=d(()=>{j();Kt();s(Hy,"generateSkills");});function zy(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${fr}/${e.name}.md`,content:n}})}var RP=d(()=>{j();Kt();s(zy,"generateAgents");});function Vy(t){return []}var IP=d(()=>{s(Vy,"generatePermissions");});function NV(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Sn(i))continue;let a=zt(i),l=he(i),c=i.type==="prompt"?l||a:a||l,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:c};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}function Jy(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=NV(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:vn,content:r}]}var SP=d(()=>{Mr();Kt();s(NV,"toCursorHooks");s(Jy,"generateHooks");});function Yy(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
117
- `);return [{path:Jr,content:e}]}var CP=d(()=>{Kt();s(Yy,"generateIgnore");});var kP=d(()=>{gP();hP();yP();_P();RP();IP();SP();CP();});var EP=d(()=>{kP();});async function rd(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),l=b(r(i)).frontmatter.alwaysApply===true,c=l?join(e,"_root.md"):i,{frontmatter:m,body:p}=b(r(c));l&&n();let u={...m,root:l};if(delete u.alwaysApply,!l){let f=FV(m);f!==null&&(u.trigger=f);}return {destPath:c,toPath:`${Mn}/${l?"_root.md":o}`,feature:"rules",content:await K(c,u,p)}}function FV(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 LP(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=b(r(n)),a=nr(o.allowedTools),l=a.length>0?a:nr(o["allowed-tools"]);return {destPath:n,toPath:`${Ms}/${t}`,feature:"commands",content:await _t(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}}async function OP(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=b(r(n));return {destPath:n,toPath:`${$s}/${t}`,feature:"agents",content:await Vt(n,o,i)}}var Xy=d(()=>{j();ut();or();Kt();s(rd,"mapCursorRuleFile");s(FV,"deriveCursorTrigger");s(LP,"mapCursorCommandFile");s(OP,"mapCursorAgentFile");});async function Ql(t){let e=join(t.projectRoot,Mn);await O(e);let r=join(e,"_root.md"),n=await oo({content:t.content,projectRoot:t.projectRoot,rulesDir:Mn,sourcePath:t.sourcePath,fromTool:"cursor",normalize:t.normalize});t.results.push(...n.results);let o=t.normalize(n.rootContent,t.sourcePath,r);if(!o.trim()&&n.results.length>0)return true;let{frontmatter:i,body:a}=b(o),l=i.root===true?i:{...i,root:true},c=await K(r,l,a);return await I(r,c),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${Mn}/_root.md`,feature:"rules"}),true}var Zy=d(()=>{w();j();Hl();ut();Kt();s(Ql,"importCursorRootFile");});async function wP(t,e,r){let n=join(t,Mn),o=false,i=join(t,ur);if(e.push(...await Rt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:l,normalizeTo:c})=>{if(o){let m=await _(a);if(m!==null){let{frontmatter:p}=b(m);if(p.alwaysApply===true)return null}}return rd(l,n,c,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,vs),l=await _(a);l!==null&&(o=await Ql({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r}));}if(!o){let a=join(t,EE),l=await _(a);l!==null&&await Ql({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r});}}var bP=d(()=>{w();j();xe();Xy();Zy();Kt();s(wP,"importCursorRules");});function PP(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!Sn({...m,type:p}))continue;let u=p==="prompt"?he(m)||zt(m):zt(m)||he(m),f={matcher:l,type:p,command:u};typeof m.timeout=="number"&&(f.timeout=m.timeout),o.push(f);}}o.length>0&&(e[r]=o);}return e}async function sd(t,e){let r=false,n=join(t,vn),o=await _(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=PP(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,_m);await O(dirname(g)),await I(g,f),e.push({fromTool:"cursor",fromPath:n,toPath:_m,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,Cu),a=await _(i);if(!a)return;let l;try{l=JSON.parse(a);}catch{return}let c=l.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let p=c,u=Array.isArray(p.allow)?p.allow.filter(g=>typeof g=="string"):[],f=Array.isArray(p.deny)?p.deny.filter(g=>typeof g=="string"):[];if(u.length>0||f.length>0){let g=stringify({allow:u,deny:f}),h=join(t,bh);await O(dirname(h)),await I(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:bh,feature:"permissions"});}}let m=r?void 0:l.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=PP(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,_m);await O(dirname(f)),await I(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:_m,feature:"hooks"});}}}async function id(t,e){let r=[{path:join(t,Jr),label:Jr},{path:join(t,wh),label:wh}],n=[],o=[];for(let a of r){let l=await _(a.path);if(l!==null){o.push(a.label);for(let c of l.split(/\r?\n/)){let m=c.trim();m&&!n.includes(m)&&n.push(m);}}}if(n.length===0)return;let i=join(t,Ph);await O(dirname(i)),await I(i,n.join(`
118
+ `)}var CP=d(()=>{K();Kt();Ht();s(r_,"generateRules");s(SP,"renderCursorGlobalUserRules");});function n_(t){return t.commands.map(e=>({path:`${_r}/${e.name}.md`,content:e.body.trim()||""}))}var kP=d(()=>{Ht();s(n_,"generateCommands");});function o_(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Ke,content:e}]}var EP=d(()=>{Ht();s(o_,"generateMcp");});function s_(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${ue}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${ue}/${r.name}/${a}`,content:i.content});}}return e}var LP=d(()=>{K();Ht();s(s_,"generateSkills");});function i_(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${Rr}/${e.name}.md`,content:n}})}var OP=d(()=>{K();Ht();s(i_,"generateAgents");});function a_(t){return []}var wP=d(()=>{s(a_,"generatePermissions");});function XV(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!kn(i))continue;let a=Vt(i),l=ye(i),c=i.type==="prompt"?l||a:a||l,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:c};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}function l_(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=XV(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:$n,content:r}]}var AP=d(()=>{Ur();Ht();s(XV,"toCursorHooks");s(l_,"generateHooks");});function c_(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
119
+ `);return [{path:Qr,content:e}]}var bP=d(()=>{Ht();s(c_,"generateIgnore");});var PP=d(()=>{CP();kP();EP();LP();OP();wP();AP();bP();});var TP=d(()=>{PP();});async function gd(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),l=b(r(i)).frontmatter.alwaysApply===true,c=l?join(e,"_root.md"):i,{frontmatter:m,body:p}=b(r(c));l&&n();let u={...m,root:l};if(delete u.alwaysApply,!l){let f=ZV(m);f!==null&&(u.trigger=f);}return {destPath:c,toPath:`${Gn}/${l?"_root.md":o}`,feature:"rules",content:await z(c,u,p)}}function ZV(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 xP(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=b(r(n)),a=lr(o.allowedTools),l=a.length>0?a:lr(o["allowed-tools"]);return {destPath:n,toPath:`${$s}/${t}`,feature:"commands",content:await It(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}}async function DP(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=b(r(n));return {destPath:n,toPath:`${Gs}/${t}`,feature:"agents",content:await Jt(n,o,i)}}var m_=d(()=>{K();ft();cr();Ht();s(gd,"mapCursorRuleFile");s(ZV,"deriveCursorTrigger");s(xP,"mapCursorCommandFile");s(DP,"mapCursorAgentFile");});async function ql(t){let e=join(t.projectRoot,Gn);await O(e);let r=join(e,"_root.md"),n=await io({content:t.content,projectRoot:t.projectRoot,rulesDir:Gn,sourcePath:t.sourcePath,fromTool:"cursor",normalize:t.normalize});t.results.push(...n.results);let o=t.normalize(n.rootContent,t.sourcePath,r);if(!o.trim()&&n.results.length>0)return true;let{frontmatter:i,body:a}=b(o),l=i.root===true?i:{...i,root:true},c=await z(r,l,a);return await S(r,c),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${Gn}/_root.md`,feature:"rules"}),true}var p_=d(()=>{A();K();zl();ft();Ht();s(ql,"importCursorRootFile");});async function FP(t,e,r){let n=join(t,Gn),o=false,i=join(t,yr);if(e.push(...await St({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:l,normalizeTo:c})=>{if(o){let m=await _(a);if(m!==null){let{frontmatter:p}=b(m);if(p.alwaysApply===true)return null}}return gd(l,n,c,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,Ms),l=await _(a);l!==null&&(o=await ql({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r}));}if(!o){let a=join(t,TE),l=await _(a);l!==null&&await ql({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r});}}var vP=d(()=>{A();K();Me();m_();p_();Ht();s(FP,"importCursorRules");});function MP(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!kn({...m,type:p}))continue;let u=p==="prompt"?ye(m)||Vt(m):Vt(m)||ye(m),f={matcher:l,type:p,command:u};typeof m.timeout=="number"&&(f.timeout=m.timeout),o.push(f);}}o.length>0&&(e[r]=o);}return e}async function _d(t,e){let r=false,n=join(t,$n),o=await _(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=MP(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,Cm);await O(dirname(g)),await S(g,f),e.push({fromTool:"cursor",fromPath:n,toPath:Cm,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,Fu),a=await _(i);if(!a)return;let l;try{l=JSON.parse(a);}catch{return}let c=l.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let p=c,u=Array.isArray(p.allow)?p.allow.filter(g=>typeof g=="string"):[],f=Array.isArray(p.deny)?p.deny.filter(g=>typeof g=="string"):[];if(u.length>0||f.length>0){let g=stringify({allow:u,deny:f}),h=join(t,Kh);await O(dirname(h)),await S(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:Kh,feature:"permissions"});}}let m=r?void 0:l.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=MP(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,Cm);await O(dirname(f)),await S(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:Cm,feature:"hooks"});}}}async function Rd(t,e){let r=[{path:join(t,Qr),label:Qr},{path:join(t,Bh),label:Bh}],n=[],o=[];for(let a of r){let l=await _(a.path);if(l!==null){o.push(a.label);for(let c of l.split(/\r?\n/)){let m=c.trim();m&&!n.includes(m)&&n.push(m);}}}if(n.length===0)return;let i=join(t,Wh);await O(dirname(i)),await S(i,n.join(`
118
120
  `)+`
119
- `),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:Ph,feature:"ignore"});}var qy=d(()=>{Mr();w();Kt();s(PP,"cursorHooksToCanonical");s(sd,"importSettings");s(id,"importIgnore");});async function ad(t,e,r,n=me){let o=join(t,n),i=await Bm(o),a={projectRoot:t,destCanonicalSkillsDir:LE,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Um(p,u,a);let l=await v(o).catch(()=>[]),c=l.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>l.filter(u=>u.startsWith(p))));for(let p of c){if(m.has(p))continue;let u=await _(p);if(!u)continue;let f=basename(p,".md");await TA(f,p,u,a);}}var t_=d(()=>{w();Yl();Kt();s(ad,"importSkills");});async function TP(t){if(await $(join(t,ur)))return true;let e=[join(t,Yr),join(t,Rl),join(t,$e),join(t,vn),join(t,Jr),join(t,me),join(t,fr),join(t,dr)];for(let i of e){let a=await _(i);if(a!==null&&a.trim()!=="")return true}return !!((await v(join(t,me))).some(i=>i.endsWith(".md"))||(await v(join(t,fr))).some(i=>i.endsWith(".md"))||(await v(join(t,dr))).some(i=>i.endsWith(".md")))}async function xP(t,e,r){let n=join(t,Mn),o=false,i=join(t,ur),a=await Rt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:ql,normalize:r,mapEntry:s(async({srcPath:l,relativePath:c,normalizeTo:m})=>{if(o){let p=await _(l);if(p!==null){let{frontmatter:u}=b(p);if(u.alwaysApply===true)return null}}return rd(c,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function DP(t,e,r){let n=join(t,Rl),o=await _(n);return o===null||o.trim()===""?false:Ql({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function NP(t,e,r){let n=join(t,Yr),o=await _(n);return o===null||o.trim()===""?false:Ql({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function FP(t,e){let r=join(t,$e),n=await _(r);if(n===null||n.trim()==="")return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let i=join(t,Il);await O(dirname(i)),await I(i,n),e.push({fromTool:ql,fromPath:r,toPath:Il,feature:"mcp"});}async function vP(t,e,r){let n=join(t,fr),o=join(t,$s);e.push(...await Rt({srcDir:n,destDir:o,extensions:[".md"],fromTool:ql,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>OP(i,o,a),"mapEntry")}));}async function MP(t,e,r){let n=join(t,dr),o=join(t,Ms);e.push(...await Rt({srcDir:n,destDir:o,extensions:[".md"],fromTool:ql,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>LP(i,o,a),"mapEntry")}));}var ql,$P=d(()=>{w();j();xe();Kt();Zy();Xy();ql="cursor";s(TP,"hasGlobalCursorArtifacts");s(xP,"importGlobalCursorRulesFromDir");s(DP,"importGlobalUserRules");s(NP,"importGlobalDotCursorAgents");s(FP,"importGlobalMcp");s(vP,"importGlobalAgents");s(MP,"importGlobalCommands");});async function GP(t){if(!await TP(t))return [];let e=[],r=await B(ql,t,"global"),n=await xP(t,e,r);return n||(n=await DP(t,e,r)),n||await NP(t,e,r),await FP(t,e),await ad(t,e,r,me),await vP(t,e,r),await MP(t,e,r),await sd(t,e),await id(t,e),e}var jP=d(()=>{dt();Kt();t_();qy();$P();s(GP,"importFromCursorGlobalExports");});async function jV(t,e){let r=join(t,$e),n=await _(r);if(!n)return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let i=o.mcpServers;await Bt(t,Il,i),e.push({fromTool:"cursor",fromPath:r,toPath:Il,feature:"mcp"});}async function UP(t,e={}){if(e.scope==="global")return GP(t);let r=[],n=await B("cursor",t);return await wP(t,r,n),r.push(...await J(ld,t,"project",{normalize:n})),await ad(t,r,n),await jV(t,r),await sd(t,r),await id(t,r),r}var BP=d(()=>{dt();w();Et();Kr();bP();qy();t_();jP();Kt();e_();s(jV,"importMcp");s(UP,"importFromCursor");});var WP,HP,zP=d(()=>{j();ut();or();Kt();WP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n)),a=nr(o.allowedTools),l=a.length>0?a:nr(o["allowed-tools"]);return {destPath:n,toPath:`${Ms}/${t}`,content:await _t(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"cursorCommandMapper"),HP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${$s}/${t}`,content:await Vt(n,o,i)}},"cursorAgentMapper");});function VP(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:kE}))}var JP=d(()=>{It();Kt();s(VP,"lintRules");});function YP(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>x(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function XP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers)){let o=n.env&&Object.keys(n.env).length>0,i="url"in n,a="headers"in n;(o||i||a)&&e.push(x(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function ZP(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?[x(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var QP=d(()=>{Lt();s(YP,"lintCommands");s(XP,"lintMcp");s(ZP,"lintPermissions");});var UV,BV,KV,WV,ld,e_=d(()=>{EP();Kt();ee();BP();zP();JP();Ct();QP();UV={name:"cursor",primaryRootInstructionPath:jo,generateRules:By,generateCommands:Ky,generateAgents:zy,generateSkills:Hy,generateMcp:Wy,generatePermissions:Vy,generateHooks:Jy,generateIgnore:Yy,importFrom:UP},BV={rootInstructionPath:jo,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[vs,Yr]}],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`}}},KV={rootInstructionPath:jo,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[vs,Yr]}],skillDir:me,managedOutputs:{dirs:[ur,dr,fr,me],files:[jo,Yr,$e,vn,Jr,Rl]},rewriteGeneratedPath(t){return t===vs?null:t===Yr||t===jo||t.startsWith(`${ur}/`)||t.startsWith(`${dr}/`)||t.startsWith(`${fr}/`)||t.startsWith(`${me}/`)||t===$e||t===vn||t===Jr?t:t===Cu?null:t},mirrorGlobalPath(t,e){return pt(t,me,e)},paths:{rulePath(t,e){return `${ur}/${t}.mdc`},commandPath(t,e){return `${dr}/${t}.md`},agentPath(t,e){return `${fr}/${t}.md`}}},WV={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},ld={id:"cursor",metadata:{displayName:"Cursor",category:"ide",officialUrl:"https://cursor.com",shortDescription:"AI-first code editor"},generators:UV,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:VP,lint:{commands:YP,mcp:XP,permissions:ZP},project:BV,globalSupport:{capabilities:WV,detectionPaths:[jo,Yr,$e,vn,Jr,me,fr,dr,Rl],layout:KV},importer:{commands:{feature:"commands",mode:"directory",source:{project:[dr]},canonicalDir:Ms,extensions:[".md"],map:WP},agents:{feature:"agents",mode:"directory",source:{project:[fr]},canonicalDir:$s,extensions:[".md"],map:HP}},buildImportPaths:Th,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});function qP(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes($n)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:gr,content:o}]:[]}function tT(t){return rt(t,pe)}function eT(t){return t.commands.map(e=>({path:`${pe}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function rT(t){return t.agents.map(e=>({path:`${pe}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function nT(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Uo,content:e}]}var oT=d(()=>{tt();Ut();mt();kt();Sl();s(qP,"generateRules");s(tT,"generateSkills");s(eT,"generateCommands");s(rT,"generateAgents");s(nT,"generateMcp");});async function sT(t,e={}){let r=e.scope??"project",n=[],o=await B($n,t,r);return n.push(...await J(cd,t,r,{normalize:o})),await q(t,r==="global"?Xr:pe,$n,n,o),n}var iT=d(()=>{dt();tt();Et();Sl();r_();s(sT,"importFromDeepagentsCli");});function aT(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:$n}))}var lT=d(()=>{It();Sl();s(aT,"lintRules");});function cT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".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,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".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?[]:[x(".agentsmesh/ignore","deepagents-cli","Deep Agents CLI has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var uT=d(()=>{Lt();s(cT,"lintHooks");s(mT,"lintPermissions");s(pT,"lintIgnore");});var HV,zV,VV,JV,YV,cd,r_=d(()=>{kt();mt();oT();iT();lT();uT();Ct();Sl();HV={name:$n,primaryRootInstructionPath:gr,generateRules:qP,generateCommands:eT,generateAgents:rT,generateSkills:tT,generateMcp:nT,importFrom:sT},zV={rootInstructionPath:gr,skillDir:pe,managedOutputs:{dirs:[pe],files:[gr,Uo]},paths:{rulePath(t){return gr},commandPath(t){return `${pe}/${H(t)}/SKILL.md`},agentPath(t){return `${pe}/${U(t)}/SKILL.md`}}},VV={rootInstructionPath:Bo,skillDir:Xr,managedOutputs:{dirs:[Xr],files:[Bo,Wi]},rewriteGeneratedPath(t){return t===gr?Bo:t===Uo?Wi:t.startsWith(`${pe}/`)?t.replace(`${pe}/`,`${Xr}/`):t},paths:{rulePath(t){return Bo},commandPath(t){return `${Xr}/${H(t)}/SKILL.md`},agentPath(t){return `${Xr}/${U(t)}/SKILL.md`}}},JV={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},YV={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},cd={id:$n,metadata:{displayName:"Deep Agents CLI",category:"cli",officialUrl:"https://github.com/langchain-ai/deepagents",shortDescription:"LangChain Deep Agents framework CLI"},generators:HV,capabilities:JV,emptyImportMessage:"No Deep Agents CLI config found (.deepagents/AGENTS.md, .deepagents/skills, or .mcp.json).",lintRules:aT,lint:{hooks:cT,permissions:mT,ignore:pT},supportsConversion:{commands:true,agents:true},project:zV,globalSupport:{capabilities:YV,detectionPaths:[Bo,Wi],layout:VV},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gr],global:[Bo]},canonicalDir:AE,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Uo],global:[Wi]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:xh,detectionPaths:[gr,Uo]};});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),T(e,t.body.trim()||"")}var fT=d(()=>{j();s(dT,"serializeDroid");});function gT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(hr)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:yr,content:o}]:[]}function hT(t){return rt(t,Le)}function yT(t){return t.commands.map(e=>({path:`${Le}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function _T(t){return t.agents.map(e=>({path:`${Gn}/${e.name}.md`,content:dT(e)}))}function RT(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:jn,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var IT=d(()=>{tt();Ut();kt();fT();zi();s(gT,"generateRules");s(hT,"generateSkills");s(yT,"generateCommands");s(_T,"generateAgents");s(RT,"generateMcp");});async function CT(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let a=o.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(l[c]=m);Object.keys(l).length!==0&&(await Bt(t,ST,l),r.push({fromTool:hr,fromPath:e,toPath:ST,feature:"mcp"}));}var ST,kT=d(()=>{w();Kr();zi();ST=".agentsmesh/mcp.json";s(CT,"importFactoryDroidMcp");});async function ET(t,e={}){let r=e.scope??"project",n=[],o=await B(hr,t,r);return n.push(...await J(md,t,r,{normalize:o})),await q(t,r==="global"?Un:Le,hr,n,o),await CT(t,r==="global"?Gs:jn,n),n}var LT=d(()=>{dt();tt();Et();kT();zi();n_();s(ET,"importFromFactoryDroid");});function OT(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:hr}))}var AT=d(()=>{It();zi();s(OT,"lintRules");});function wT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".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 bT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","factory-droid","Factory Droid permissions are managed via CLI flags (--skip-permissions-unsafe); canonical permissions are not projected.")]}function PT(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","factory-droid","Factory Droid has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var TT=d(()=>{Lt();s(wT,"lintHooks");s(bT,"lintPermissions");s(PT,"lintIgnore");});var ZV,QV,qV,xT,md,n_=d(()=>{IT();zi();LT();AT();TT();Ct();kt();ZV={name:hr,primaryRootInstructionPath:yr,generateRules:gT,generateCommands:yT,generateAgents:_T,generateSkills:hT,generateMcp:RT,importFrom:ET},QV={rootInstructionPath:yr,skillDir:Le,managedOutputs:{dirs:[Le,Gn],files:[yr,jn]},paths:{rulePath(t){return yr},commandPath(t){return `${Le}/${H(t)}/SKILL.md`},agentPath(t){return `${Gn}/${t}.md`}}},qV={rootInstructionPath:Ko,skillDir:Un,managedOutputs:{dirs:[Un,Hi],files:[Ko,Gs]},rewriteGeneratedPath(t){return t===yr?Ko:t===jn?Gs:t.startsWith(`${Le}/`)?t.replace(`${Le}/`,`${Un}/`):t.startsWith(`${Gn}/`)?t.replace(`${Gn}/`,`${Hi}/`):t},paths:{rulePath(t){return Ko},commandPath(t){return `${Un}/${H(t)}/SKILL.md`},agentPath(t){return `${Hi}/${t}.md`}}},xT={rules:"native",additionalRules:"embedded",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},md={id:hr,metadata:{displayName:"Factory Droid",category:"agent-platform",officialUrl:"https://www.factory.ai",shortDescription:"Factory.ai's coding droid"},generators:ZV,capabilities:xT,emptyImportMessage:"No Factory Droid config found (AGENTS.md, .factory/skills, or .factory/mcp.json).",lintRules:OT,lint:{hooks:wT,permissions:bT,ignore:PT},supportsConversion:{commands:true},project:QV,globalSupport:{capabilities:xT,detectionPaths:[Ko,Gs,Hi],layout:qV},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[yr],global:[Ko]},canonicalDir:bE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Dh,detectionPaths:[yr,jn,Gn]};});var ai,br,co,DT,NT,He,pd,Oa,ud,Jm,li,FT,vT,ci,dd,Ym,Xm,o_,s_,tc,i_,ec,rc,fd,nc,Aa,Zm,Jt=d(()=>{ai="gemini-cli",br="GEMINI.md",co="AGENTS.md",DT=".gemini/rules",NT=".gemini/GEMINI.md",He=".gemini/commands",pd=".gemini/policies",Oa=".gemini/settings.json",ud=".geminiignore",Jm=".gemini/skills",li=".gemini/agents",FT=".gemini/system.md",vT=`${pd}/permissions.toml`,ci=".agentsmesh/rules",dd=".agentsmesh/commands",Ym=".agentsmesh/agents",Xm=".agentsmesh/skills",o_=".agentsmesh/mcp.json",s_=".agentsmesh/hooks.yaml",tc=".agentsmesh/ignore",i_=".agentsmesh/permissions.yaml",ec=".gemini/GEMINI.md",rc=".gemini/AGENTS.md",fd=".gemini/settings.json",nc=".gemini/commands",Aa=".gemini/skills",Zm=".gemini/agents";});function a_(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 n=lt(e?.body.trim()??"",r),o=[{path:br,content:n}];return e&&o.push({path:co,content:e.body.trim()}),o}var MT=d(()=>{Ut();Jt();s(a_,"generateRules");});function $T(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var GT=d(()=>{s($T,"canonicalCommandNameToGeminiTomlPath");});function t1(t){let e=t.replace(/\r\n/g,`
121
+ `),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:Wh,feature:"ignore"});}var d_=d(()=>{Ur();A();Ht();s(MP,"cursorHooksToCanonical");s(_d,"importSettings");s(Rd,"importIgnore");});async function Id(t,e,r,n=ue){let o=join(t,n),i=await zm(o),a={projectRoot:t,destCanonicalSkillsDir:xE,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Hm(p,u,a);let l=await $(o).catch(()=>[]),c=l.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>l.filter(u=>u.startsWith(p))));for(let p of c){if(m.has(p))continue;let u=await _(p);if(!u)continue;let f=basename(p,".md");await $w(f,p,u,a);}}var f_=d(()=>{A();Xl();Ht();s(Id,"importSkills");});async function $P(t){if(await j(join(t,yr)))return true;let e=[join(t,qr),join(t,Il),join(t,Ke),join(t,$n),join(t,Qr),join(t,ue),join(t,Rr),join(t,_r)];for(let i of e){let a=await _(i);if(a!==null&&a.trim()!=="")return true}return !!((await $(join(t,ue))).some(i=>i.endsWith(".md"))||(await $(join(t,Rr))).some(i=>i.endsWith(".md"))||(await $(join(t,_r))).some(i=>i.endsWith(".md")))}async function GP(t,e,r){let n=join(t,Gn),o=false,i=join(t,yr),a=await St({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:tc,normalize:r,mapEntry:s(async({srcPath:l,relativePath:c,normalizeTo:m})=>{if(o){let p=await _(l);if(p!==null){let{frontmatter:u}=b(p);if(u.alwaysApply===true)return null}}return gd(c,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function jP(t,e,r){let n=join(t,Il),o=await _(n);return o===null||o.trim()===""?false:ql({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function UP(t,e,r){let n=join(t,qr),o=await _(n);return o===null||o.trim()===""?false:ql({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function BP(t,e){let r=join(t,Ke),n=await _(r);if(n===null||n.trim()==="")return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let i=join(t,Sl);await O(dirname(i)),await S(i,n),e.push({fromTool:tc,fromPath:r,toPath:Sl,feature:"mcp"});}async function KP(t,e,r){let n=join(t,Rr),o=join(t,Gs);e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:tc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>DP(i,o,a),"mapEntry")}));}async function WP(t,e,r){let n=join(t,_r),o=join(t,$s);e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:tc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>xP(i,o,a),"mapEntry")}));}var tc,HP=d(()=>{A();K();Me();Ht();p_();m_();tc="cursor";s($P,"hasGlobalCursorArtifacts");s(GP,"importGlobalCursorRulesFromDir");s(jP,"importGlobalUserRules");s(UP,"importGlobalDotCursorAgents");s(BP,"importGlobalMcp");s(KP,"importGlobalAgents");s(WP,"importGlobalCommands");});async function zP(t){if(!await $P(t))return [];let e=[],r=await H(tc,t,"global"),n=await GP(t,e,r);return n||(n=await jP(t,e,r)),n||await UP(t,e,r),await BP(t,e),await Id(t,e,r,ue),await KP(t,e,r),await WP(t,e,r),await _d(t,e),await Rd(t,e),e}var VP=d(()=>{gt();Ht();f_();d_();HP();s(zP,"importFromCursorGlobalExports");});async function r1(t,e){let r=join(t,Ke),n=await _(r);if(!n)return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let i=o.mcpServers;await Wt(t,Sl,i),e.push({fromTool:"cursor",fromPath:r,toPath:Sl,feature:"mcp"});}async function JP(t,e={}){if(e.scope==="global")return zP(t);let r=[],n=await H("cursor",t);return await FP(t,r,n),r.push(...await Y(Sd,t,"project",{normalize:n})),await Id(t,r,n),await r1(t,r),await _d(t,r),await Rd(t,r),r}var YP=d(()=>{gt();A();Ot();Vr();vP();d_();f_();VP();Ht();g_();s(r1,"importMcp");s(JP,"importFromCursor");});var ZP,QP,qP=d(()=>{K();ft();cr();Ht();ZP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n)),a=lr(o.allowedTools),l=a.length>0?a:lr(o["allowed-tools"]);return {destPath:n,toPath:`${$s}/${t}`,content:await It(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"cursorCommandMapper"),QP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Gs}/${t}`,content:await Jt(n,o,i)}},"cursorAgentMapper");});function tT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:PE}))}var eT=d(()=>{Ct();Ht();s(tT,"lintRules");});function rT(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>x(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function nT(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers)){let o=n.env&&Object.keys(n.env).length>0,i="url"in n,a="headers"in n;(o||i||a)&&e.push(x(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function oT(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?[x(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var sT=d(()=>{wt();s(rT,"lintCommands");s(nT,"lintMcp");s(oT,"lintPermissions");});var n1,o1,s1,i1,Sd,g_=d(()=>{TP();Ht();ne();YP();qP();eT();Et();sT();n1={name:"cursor",primaryRootInstructionPath:Bo,generateRules:r_,generateCommands:n_,generateAgents:i_,generateSkills:s_,generateMcp:o_,generatePermissions:a_,generateHooks:l_,generateIgnore:c_,importFrom:JP},o1={rootInstructionPath:Bo,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Ms,qr]}],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`}}},s1={rootInstructionPath:Bo,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Ms,qr]}],skillDir:ue,managedOutputs:{dirs:[yr,_r,Rr,ue],files:[Bo,qr,Ke,$n,Qr,Il]},rewriteGeneratedPath(t){return t===Ms?null:t===qr||t===Bo||t.startsWith(`${yr}/`)||t.startsWith(`${_r}/`)||t.startsWith(`${Rr}/`)||t.startsWith(`${ue}/`)||t===Ke||t===$n||t===Qr?t:t===Fu?null:t},mirrorGlobalPath(t,e){return dt(t,ue,e)},paths:{rulePath(t,e){return `${yr}/${t}.mdc`},commandPath(t,e){return `${_r}/${t}.md`},agentPath(t,e){return `${Rr}/${t}.md`}}},i1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Sd={id:"cursor",metadata:{displayName:"Cursor",category:"ide",officialUrl:"https://cursor.com",shortDescription:"AI-first code editor"},generators:n1,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:tT,lint:{commands:rT,mcp:nT,permissions:oT},project:o1,globalSupport:{capabilities:i1,detectionPaths:[Bo,qr,Ke,$n,Qr,ue,Rr,_r,Il],layout:s1},importer:{commands:{feature:"commands",mode:"directory",source:{project:[_r]},canonicalDir:$s,extensions:[".md"],map:ZP},agents:{feature:"agents",mode:"directory",source:{project:[Rr]},canonicalDir:Gs,extensions:[".md"],map:QP}},buildImportPaths:Hh,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});function iT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(jn)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:Ir,content:o}]:[]}function aT(t){return it(t,de)}function lT(t){return t.commands.map(e=>({path:`${de}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function cT(t){return t.agents.map(e=>({path:`${de}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function mT(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 pT=d(()=>{rt();Kt();ut();Lt();Cl();s(iT,"generateRules");s(aT,"generateSkills");s(lT,"generateCommands");s(cT,"generateAgents");s(mT,"generateMcp");});async function uT(t,e={}){let r=e.scope??"project",n=[],o=await H(jn,t,r);return n.push(...await Y(Cd,t,r,{normalize:o})),await et(t,r==="global"?tn:de,jn,n,o),n}var dT=d(()=>{gt();rt();Ot();Cl();h_();s(uT,"importFromDeepagentsCli");});function fT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:jn}))}var gT=d(()=>{Ct();Cl();s(fT,"lintRules");});function hT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","deepagents-cli","Deep Agents CLI hooks are global-only (~/.deepagents/hooks.json); project-level canonical hooks are not projected.")]:[]:[]}function yT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","deepagents-cli","Deep Agents CLI permissions are managed via shell allow-lists (--shell-allow-list); canonical permissions are not projected.")]}function _T(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","deepagents-cli","Deep Agents CLI has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var RT=d(()=>{wt();s(hT,"lintHooks");s(yT,"lintPermissions");s(_T,"lintIgnore");});var a1,l1,c1,m1,p1,Cd,h_=d(()=>{Lt();ut();pT();dT();gT();RT();Et();Cl();a1={name:jn,primaryRootInstructionPath:Ir,generateRules:iT,generateCommands:lT,generateAgents:cT,generateSkills:aT,generateMcp:mT,importFrom:uT},l1={rootInstructionPath:Ir,skillDir:de,managedOutputs:{dirs:[de],files:[Ir,Ko]},paths:{rulePath(t){return Ir},commandPath(t){return `${de}/${V(t)}/SKILL.md`},agentPath(t){return `${de}/${W(t)}/SKILL.md`}}},c1={rootInstructionPath:Wo,skillDir:tn,managedOutputs:{dirs:[tn],files:[Wo,zi]},rewriteGeneratedPath(t){return t===Ir?Wo:t===Ko?zi:t.startsWith(`${de}/`)?t.replace(`${de}/`,`${tn}/`):t},paths:{rulePath(t){return Wo},commandPath(t){return `${tn}/${V(t)}/SKILL.md`},agentPath(t){return `${tn}/${W(t)}/SKILL.md`}}},m1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},p1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Cd={id:jn,metadata:{displayName:"Deep Agents CLI",category:"cli",officialUrl:"https://github.com/langchain-ai/deepagents",shortDescription:"LangChain Deep Agents framework CLI"},generators:a1,capabilities:m1,emptyImportMessage:"No Deep Agents CLI config found (.deepagents/AGENTS.md, .deepagents/skills, or .mcp.json).",lintRules:fT,lint:{hooks:hT,permissions:yT,ignore:_T},supportsConversion:{commands:true,agents:true},project:l1,globalSupport:{capabilities:p1,detectionPaths:[Wo,zi],layout:c1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ir],global:[Wo]},canonicalDir:NE,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ko],global:[zi]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:zh,detectionPaths:[Ir,Ko]};});function IT(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),T(e,t.body.trim()||"")}var ST=d(()=>{K();s(IT,"serializeDroid");});function CT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Sr)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:Cr,content:o}]:[]}function kT(t){return it(t,we)}function ET(t){return t.commands.map(e=>({path:`${we}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function LT(t){return t.agents.map(e=>({path:`${Un}/${e.name}.md`,content:IT(e)}))}function OT(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Bn,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var wT=d(()=>{rt();Kt();Lt();ST();Ji();s(CT,"generateRules");s(kT,"generateSkills");s(ET,"generateCommands");s(LT,"generateAgents");s(OT,"generateMcp");});async function bT(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let a=o.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(l[c]=m);Object.keys(l).length!==0&&(await Wt(t,AT,l),r.push({fromTool:Sr,fromPath:e,toPath:AT,feature:"mcp"}));}var AT,PT=d(()=>{A();Vr();Ji();AT=".agentsmesh/mcp.json";s(bT,"importFactoryDroidMcp");});async function TT(t,e={}){let r=e.scope??"project",n=[],o=await H(Sr,t,r);return n.push(...await Y(kd,t,r,{normalize:o})),await et(t,r==="global"?Kn:we,Sr,n,o),await bT(t,r==="global"?js:Bn,n),n}var xT=d(()=>{gt();rt();Ot();PT();Ji();y_();s(TT,"importFromFactoryDroid");});function DT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Sr}))}var NT=d(()=>{Ct();Ji();s(DT,"lintRules");});function FT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".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 vT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","factory-droid","Factory Droid permissions are managed via CLI flags (--skip-permissions-unsafe); canonical permissions are not projected.")]}function MT(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","factory-droid","Factory Droid has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var $T=d(()=>{wt();s(FT,"lintHooks");s(vT,"lintPermissions");s(MT,"lintIgnore");});var d1,f1,g1,GT,kd,y_=d(()=>{wT();Ji();xT();NT();$T();Et();Lt();d1={name:Sr,primaryRootInstructionPath:Cr,generateRules:CT,generateCommands:ET,generateAgents:LT,generateSkills:kT,generateMcp:OT,importFrom:TT},f1={rootInstructionPath:Cr,skillDir:we,managedOutputs:{dirs:[we,Un],files:[Cr,Bn]},paths:{rulePath(t){return Cr},commandPath(t){return `${we}/${V(t)}/SKILL.md`},agentPath(t){return `${Un}/${t}.md`}}},g1={rootInstructionPath:Ho,skillDir:Kn,managedOutputs:{dirs:[Kn,Vi],files:[Ho,js]},rewriteGeneratedPath(t){return t===Cr?Ho:t===Bn?js:t.startsWith(`${we}/`)?t.replace(`${we}/`,`${Kn}/`):t.startsWith(`${Un}/`)?t.replace(`${Un}/`,`${Vi}/`):t},paths:{rulePath(t){return Ho},commandPath(t){return `${Kn}/${V(t)}/SKILL.md`},agentPath(t){return `${Vi}/${t}.md`}}},GT={rules:"native",additionalRules:"embedded",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},kd={id:Sr,metadata:{displayName:"Factory Droid",category:"agent-platform",officialUrl:"https://www.factory.ai",shortDescription:"Factory.ai's coding droid"},generators:d1,capabilities:GT,emptyImportMessage:"No Factory Droid config found (AGENTS.md, .factory/skills, or .factory/mcp.json).",lintRules:DT,lint:{hooks:FT,permissions:vT,ignore:MT},supportsConversion:{commands:true},project:f1,globalSupport:{capabilities:GT,detectionPaths:[Ho,js,Vi],layout:g1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Cr],global:[Ho]},canonicalDir:vE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Vh,detectionPaths:[Cr,Bn,Un]};});var li,Nr,po,jT,UT,Xe,Ed,Aa,Ld,Qm,ci,BT,KT,mi,Od,qm,tp,__,R_,ec,I_,rc,nc,wd,oc,ba,ep,Yt=d(()=>{li="gemini-cli",Nr="GEMINI.md",po="AGENTS.md",jT=".gemini/rules",UT=".gemini/GEMINI.md",Xe=".gemini/commands",Ed=".gemini/policies",Aa=".gemini/settings.json",Ld=".geminiignore",Qm=".gemini/skills",ci=".gemini/agents",BT=".gemini/system.md",KT=`${Ed}/permissions.toml`,mi=".agentsmesh/rules",Od=".agentsmesh/commands",qm=".agentsmesh/agents",tp=".agentsmesh/skills",__=".agentsmesh/mcp.json",R_=".agentsmesh/hooks.yaml",ec=".agentsmesh/ignore",I_=".agentsmesh/permissions.yaml",rc=".gemini/GEMINI.md",nc=".gemini/AGENTS.md",wd=".gemini/settings.json",oc=".gemini/commands",ba=".gemini/skills",ep=".gemini/agents";});function S_(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 n=mt(e?.body.trim()??"",r),o=[{path:Nr,content:n}];return e&&o.push({path:po,content:e.body.trim()}),o}var WT=d(()=>{Kt();Yt();s(S_,"generateRules");});function HT(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var zT=d(()=>{s(HT,"canonicalCommandNameToGeminiTomlPath");});function h1(t){let e=t.replace(/\r\n/g,`
120
122
  `);return e.includes('"""')?JSON.stringify(e):`"""
121
123
  ${e}
122
- """`}function e1(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${t1(t.body.trim()||"")}`].join(`
124
+ """`}function y1(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${h1(t.body.trim()||"")}`].join(`
123
125
  `)+`
124
- `}function l_(t){return t.commands.map(e=>({path:$T(e.name,He),content:e1(e)}))}var jT=d(()=>{Jt();GT();s(t1,"serializeTomlMultilineLiteral");s(e1,"serializeGeminiCommand");s(l_,"generateCommands");});function c_(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${li}/${e.name}.md`,content:n}})}var UT=d(()=>{j();Jt();s(c_,"generateAgents");});function m_(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${Jm}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Jm}/${r.name}/${a}`,content:i.content});}}return e}var BT=d(()=>{j();Jt();s(m_,"generateSkills");});function r1(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function p_(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 n=Object.entries(t.hooks).flatMap(([o,i])=>{let a=r1(o);if(!a||!Array.isArray(i))return [];let l=i.filter(c=>typeof c=="object"&&c!==null&&ko(c)).map((c,m)=>({matcher:c.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:zt(c),timeout:c.timeout}]}));return l.length>0?[[a,l]]:[]});n.length>0&&(e.hooks=Object.fromEntries(n),r=true);}return r&&(e.context={fileName:[br,co]}),Object.keys(e).length===0?[]:[{path:Oa,content:JSON.stringify(e,null,2)}]}var u_=d(()=>{Mr();Jt();s(r1,"mapHookEvent");s(p_,"generateGeminiSettingsFiles");});function d_(t){return !t.ignore||t.ignore.length===0?[]:[{path:ud,content:t.ignore.join(`
125
- `)}]}var KT=d(()=>{Jt();s(d_,"generateIgnore");});var WT=d(()=>{MT();jT();UT();BT();u_();KT();});var HT=d(()=>{WT();});function wa(t){return JSON.stringify(t)}function n1(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function o1(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 gd(t,e,r){return ["[[rule]]",`decision = ${wa(t)}`,`priority = ${e}`,...r,""].join(`
126
- `)}function zT(t,e,r){let n=o1(t),o={Read:"read_file",Grep:"grep_search",LS:"list_directory",WebFetch:"web_fetch",Bash:"run_shell_command"};if(n.kind==="tool"){let i=o[n.tool]??n.tool;return gd(e,r,[`toolName = ${wa(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return gd(e,r,[`toolName = ${wa(o.Bash)}`,`commandPrefix = ${wa(i)}`])}return n.kind==="read"?gd(e,r,[`toolName = ${wa(o.Read)}`,`argsPattern = ${wa(n1(n.path))}`]):gd(e,r,[`toolName = ${wa(n.raw)}`])}function VT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions;if(e.length+r.length===0)return [];let o=[];return e.forEach((i,a)=>{let l=zT(i,"allow",100+a);l&&o.push(l);}),r.forEach((i,a)=>{let l=zT(i,"deny",200+a);l&&o.push(l);}),o.length===0?[]:[{path:vT,content:o.join(`
127
- `)}]}var JT=d(()=>{Jt();s(wa,"escapeTomlBasicString");s(n1,"escapeRegexLiteral");s(o1,"parsePermissionExpr");s(gd,"ruleForDecision");s(zT,"permissionExprToGeminiRule");s(VT,"generateGeminiPermissionsPolicies");});function f_(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 hd(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return b(t);if(r===0){let n=t.indexOf("+++",3);if(n!==-1)try{let o=t.slice(3,n).trim(),i=t.slice(n+3).trim();return {frontmatter:o===""?{}:parse$1(o)??{},body:i}}catch{return {frontmatter:{},body:t.trim()}}}return {frontmatter:{},body:t.trim()}}var g_=d(()=>{j();s(f_,"mapGeminiHookEvent");s(hd,"parseFlexibleFrontmatter");});async function h_(t,e){let r=join(t,Oa),n=await _(r);if(n===null)return;let o;try{o=JSON.parse(n);}catch{}if(!o)return;let i=o.mcpServers;if(i!==void 0&&typeof i=="object"&&i!==null&&Object.keys(i).length>0){let c=join(t,o_);await O(join(t,".agentsmesh")),await I(c,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:o_,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(c=>typeof c=="string")){let c=join(t,tc);await O(join(t,".agentsmesh")),await I(c,a.join(`
126
+ `}function C_(t){return t.commands.map(e=>({path:HT(e.name,Xe),content:y1(e)}))}var VT=d(()=>{Yt();zT();s(h1,"serializeTomlMultilineLiteral");s(y1,"serializeGeminiCommand");s(C_,"generateCommands");});function k_(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${ci}/${e.name}.md`,content:n}})}var JT=d(()=>{K();Yt();s(k_,"generateAgents");});function E_(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${Qm}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Qm}/${r.name}/${a}`,content:i.content});}}return e}var YT=d(()=>{K();Yt();s(E_,"generateSkills");});function _1(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function L_(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 n=Object.entries(t.hooks).flatMap(([o,i])=>{let a=_1(o);if(!a||!Array.isArray(i))return [];let l=i.filter(c=>typeof c=="object"&&c!==null&&Lo(c)).map((c,m)=>({matcher:c.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:Vt(c),timeout:c.timeout}]}));return l.length>0?[[a,l]]:[]});n.length>0&&(e.hooks=Object.fromEntries(n),r=true);}return r&&(e.context={fileName:[Nr,po]}),Object.keys(e).length===0?[]:[{path:Aa,content:JSON.stringify(e,null,2)}]}var O_=d(()=>{Ur();Yt();s(_1,"mapHookEvent");s(L_,"generateGeminiSettingsFiles");});function w_(t){return !t.ignore||t.ignore.length===0?[]:[{path:Ld,content:t.ignore.join(`
127
+ `)}]}var XT=d(()=>{Yt();s(w_,"generateIgnore");});var ZT=d(()=>{WT();VT();JT();YT();O_();XT();});var QT=d(()=>{ZT();});function Pa(t){return JSON.stringify(t)}function R1(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function I1(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 Ad(t,e,r){return ["[[rule]]",`decision = ${Pa(t)}`,`priority = ${e}`,...r,""].join(`
128
+ `)}function qT(t,e,r){let n=I1(t),o={Read:"read_file",Grep:"grep_search",LS:"list_directory",WebFetch:"web_fetch",Bash:"run_shell_command"};if(n.kind==="tool"){let i=o[n.tool]??n.tool;return Ad(e,r,[`toolName = ${Pa(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return Ad(e,r,[`toolName = ${Pa(o.Bash)}`,`commandPrefix = ${Pa(i)}`])}return n.kind==="read"?Ad(e,r,[`toolName = ${Pa(o.Read)}`,`argsPattern = ${Pa(R1(n.path))}`]):Ad(e,r,[`toolName = ${Pa(n.raw)}`])}function tx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions;if(e.length+r.length===0)return [];let o=[];return e.forEach((i,a)=>{let l=qT(i,"allow",100+a);l&&o.push(l);}),r.forEach((i,a)=>{let l=qT(i,"deny",200+a);l&&o.push(l);}),o.length===0?[]:[{path:KT,content:o.join(`
129
+ `)}]}var ex=d(()=>{Yt();s(Pa,"escapeTomlBasicString");s(R1,"escapeRegexLiteral");s(I1,"parsePermissionExpr");s(Ad,"ruleForDecision");s(qT,"permissionExprToGeminiRule");s(tx,"generateGeminiPermissionsPolicies");});function A_(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 bd(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return b(t);if(r===0){let n=t.indexOf("+++",3);if(n!==-1)try{let o=t.slice(3,n).trim(),i=t.slice(n+3).trim();return {frontmatter:o===""?{}:parse$1(o)??{},body:i}}catch{return {frontmatter:{},body:t.trim()}}}return {frontmatter:{},body:t.trim()}}var b_=d(()=>{K();s(A_,"mapGeminiHookEvent");s(bd,"parseFlexibleFrontmatter");});async function P_(t,e){let r=join(t,Aa),n=await _(r);if(n===null)return;let o;try{o=JSON.parse(n);}catch{}if(!o)return;let i=o.mcpServers;if(i!==void 0&&typeof i=="object"&&i!==null&&Object.keys(i).length>0){let c=join(t,__);await O(join(t,".agentsmesh")),await S(c,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:__,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(c=>typeof c=="string")){let c=join(t,ec);await O(join(t,".agentsmesh")),await S(c,a.join(`
128
130
  `)+`
129
- `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:tc,feature:"ignore"});}let l=o.hooks;if(l!==void 0&&typeof l=="object"&&l!==null){let c=Object.entries(l).flatMap(([m,p])=>{let u=f_(m);if(!u||!Array.isArray(p))return [];let f=p.filter(g=>g!==null&&typeof g=="object"&&typeof g.matcher=="string"&&Array.isArray(g.hooks)).flatMap(g=>g.hooks.filter(h=>h!==null&&typeof h=="object"&&ko(h)).map(h=>({matcher:g.matcher,command:zt(h),type:"command",timeout:typeof h.timeout=="number"?h.timeout:void 0})));if(f.length===0){let g=p.filter(h=>h!==null&&typeof h=="object"&&typeof h.matcher=="string"&&ko(h)).map(h=>({matcher:h.matcher,command:zt(h),type:"command"}));return g.length>0?[[u,g]]:[]}return f.length>0?[[u,f]]:[]});if(c.length>0){let m=Object.fromEntries(c),p=join(t,s_);await O(join(t,".agentsmesh")),await I(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:s_,feature:"hooks"});}}}var YT=d(()=>{Mr();w();Jt();g_();s(h_,"importGeminiSettings");});async function XT(t,e){let r=join(t,ud),n=await _(r);if(n!==null&&n.trim()){let o=n.split(/\r?\n/).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#"));if(o.length>0){await O(join(t,".agentsmesh"));let i=join(t,tc);await I(i,o.join(`
131
+ `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:ec,feature:"ignore"});}let l=o.hooks;if(l!==void 0&&typeof l=="object"&&l!==null){let c=Object.entries(l).flatMap(([m,p])=>{let u=A_(m);if(!u||!Array.isArray(p))return [];let f=p.filter(g=>g!==null&&typeof g=="object"&&typeof g.matcher=="string"&&Array.isArray(g.hooks)).flatMap(g=>g.hooks.filter(h=>h!==null&&typeof h=="object"&&Lo(h)).map(h=>({matcher:g.matcher,command:Vt(h),type:"command",timeout:typeof h.timeout=="number"?h.timeout:void 0})));if(f.length===0){let g=p.filter(h=>h!==null&&typeof h=="object"&&typeof h.matcher=="string"&&Lo(h)).map(h=>({matcher:h.matcher,command:Vt(h),type:"command"}));return g.length>0?[[u,g]]:[]}return f.length>0?[[u,f]]:[]});if(c.length>0){let m=Object.fromEntries(c),p=join(t,R_);await O(join(t,".agentsmesh")),await S(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:R_,feature:"hooks"});}}}var rx=d(()=>{Ur();A();Yt();b_();s(P_,"importGeminiSettings");});async function nx(t,e){let r=join(t,Ld),n=await _(r);if(n!==null&&n.trim()){let o=n.split(/\r?\n/).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#"));if(o.length>0){await O(join(t,".agentsmesh"));let i=join(t,ec);await S(i,o.join(`
130
132
  `)+`
131
- `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:tc,feature:"ignore"});}}}var __=d(()=>{w();Jt();g_();YT();s(XT,"importGeminiIgnore");});function c1(t){return t.replace(/\\(.)/g,"$1")}function m1(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 p1(t){return `Bash(${t}:*)`}function u1(t){return `Read(${c1(t)})`}async function ZT(t){let e=[],r=join(t,pd),n;try{n=await v(r);}catch{return e}let o=n.filter(u=>u.endsWith(".toml"));if(o.length===0)return e;let i=[],a=[],l=new Set,c=new Set;for(let u of o){let f=await _(u);if(!f)continue;let g;try{g=parse$1(f);}catch{continue}let h=g&&typeof g=="object"&&"rule"in g?g.rule:void 0;if(Array.isArray(h))for(let R of h){if(!R||typeof R!="object")continue;let C=R,S=typeof C.toolName=="string"?C.toolName:null,k=typeof C.decision=="string"?C.decision:null;if(!S||!k)continue;let P=m1(S);if(!P)continue;let N=null;P==="Bash"?typeof C.commandPrefix=="string"&&C.commandPrefix.trim()&&(N=p1(C.commandPrefix.trim())):P==="Read"?typeof C.argsPattern=="string"&&C.argsPattern.trim()?N=u1(C.argsPattern.trim()):N="Read":N=P,N&&(k==="allow"?l.has(N)||(l.add(N),i.push(N)):k==="deny"&&(c.has(N)||(c.add(N),a.push(N))));}}if(i.length===0&&a.length===0)return e;await O(join(t,".agentsmesh"));let m=join(t,i_),p=stringify({allow:i,deny:a});return await I(m,p.trimEnd()+`
132
- `),e.push({fromTool:ai,fromPath:join(t,pd),toPath:i_,feature:"permissions"}),e}var QT=d(()=>{w();Jt();s(c1,"unescapeRegexLiteral");s(m1,"toolNameToPermissionBase");s(p1,"commandPrefixToBashExpr");s(u1,"argsPatternToReadExpr");s(ZT,"importGeminiPolicies");});function R_(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((o,i)=>{let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return o.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 tx=d(()=>{s(R_,"stripProjectRootCanonicalPrefix");});async function rx(t,e,r){let n=join(t,Jm),i=(await v(n)).filter(l=>basename(l)==="SKILL.md");for(let l of i){let c=await _(l);if(!c)continue;let m=basename(l.slice(0,-9)),p=b(c),u=al(p.frontmatter,m);if(u){let k=join(t,Ym);await O(k);let P=join(k,`${u.name}.md`);await I(P,Os(u,r(p.body,l,P))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Ym}/${u.name}.md`,feature:"agents"});continue}let f=join(t,Xm,m,"SKILL.md"),g=r(c,l,f),h=join(t,Xm,m);await O(h);let{frontmatter:R,body:C}=b(g);await I(f,await Cn(f,{...R,name:m},C)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Xm}/${m}/SKILL.md`,feature:"skills"});let S=await v(dirname(l));for(let k of S){if(k===l)continue;let P=await _(k);if(P===null)continue;let N=relative(dirname(l),k).replace(/\\/g,"/"),F=join(h,N);await O(dirname(F)),await I(F,r(P,k,F)),e.push({fromTool:"gemini-cli",fromPath:k,toPath:`${Xm}/${m}/${N}`,feature:"skills"});}}let a=join(t,li);try{let c=(await v(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await _(m);if(!p)continue;let{frontmatter:u,body:f}=b(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),R=join(t,Ym);await O(R);let C=join(R,h),S=r(f,m,C);await I(C,await Vt(C,{...u,name:typeof u.name=="string"?u.name:basename(h,".md"),maxTurns:u.maxTurns??u["max-turns"]??u.max_turns,permissionMode:u.permissionMode??u["permission-mode"]??u.permission_mode,disallowedTools:u.disallowedTools??u["disallowed-tools"]??u.disallowed_tools},S)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${Ym}/${h}`,feature:"agents"});}}catch{}}var nx=d(()=>{w();j();ut();mt();Jt();s(rx,"importGeminiSkillsAndAgents");});async function d1(t,e,r){let n=await B("codex-cli",t),o=join(t,ci),i=join(t,co),a=join(t,NT),l=[i,a,join(t,br),join(t,FT)],c=null,m=l[l.length-1];for(let N of l){let F=await _(N);if(F!==null){c=F,m=N;break}}if(c===null)return;await O(o);let p=join(o,"_root.md"),u=m===i||m===a?n(c,m,p):c,f=await oo({content:u,projectRoot:t,rulesDir:ci,sourcePath:m,fromTool:ai,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=R_(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:R,body:C}=b(h),k=R.root===true?R:{...R,root:true},P=R_(await K(p,k,C),t);await I(p,P),e.push({fromTool:ai,fromPath:m,toPath:`${ci}/_root.md`,feature:"rules"});}async function ox(t){let e=[],r=await B(ai,t);return await d1(t,e,r),e.push(...await J(_d,t,"project",{normalize:r})),await rx(t,e,r),await h_(t,e),await XT(t,e),e.push(...await ZT(t)),e}var sx=d(()=>{dt();w();j();ut();Hl();Et();Jt();C_();__();QT();tx();nx();s(d1,"importRootRule");s(ox,"importFromGemini");});async function ax(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=hd(r(o)),l=wo(i.globs),c={root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${ci}/${n}`,feature:"rules",content:await K(o,c,a)}}async function lx(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),i=r(o),{frontmatter:a,body:l}=t.endsWith(".toml")?g1(i):hd(i),c=nr(a.allowedTools),m=nr(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${dd}/${n}`,feature:"commands",content:await _t(o,{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")},l)}}function g1(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var cx=d(()=>{ut();or();__();Jt();s(ax,"mapGeminiRuleFile");s(lx,"mapGeminiCommandFile");s(g1,"parseTomlCommand");});var mx,px,ux=d(()=>{cx();mx=s(({relativePath:t,destDir:e,normalizeTo:r})=>ax(t,e,r),"geminiRuleMapper"),px=s(({relativePath:t,destDir:e,normalizeTo:r})=>lx(t,e,r),"geminiCommandMapper");});function dx(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:ai}))}var fx=d(()=>{It();Jt();s(dx,"lintRules");});function gx(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>x(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function hx(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(n=>!r.has(n)).map(n=>Ps(n,"gemini-cli",e))}var yx=d(()=>{Lt();s(gx,"lintCommands");s(hx,"lintHooks");});function _x(t,e){return e==="project"&&mi("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:p_(t)}var Rx=d(()=>{Pt();u_();s(_x,"emitScopedGeminiSettings");});var h1,y1,_1,R1,_d,C_=d(()=>{HT();wi();JT();Jt();sx();ux();fx();Ct();ol();mt();yx();Rx();ee();td();h1={name:"gemini-cli",primaryRootInstructionPath:br,generateRules:a_,generateCommands:l_,generateAgents:c_,generateSkills:m_,generateIgnore:d_,generatePermissions:VT,importFrom:ox},y1={rootInstructionPath:br,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[co]}],extraRuleOutputPaths(){return [co]},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 pt(t,".gemini/skills",e)},paths:{rulePath(t,e){return br},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${He}/${r.join("/")}/${n}.toml`}return `${He}/${t}.toml`},agentPath(t,e){return qe(e,"gemini-cli")?`.gemini/skills/${U(t)}/SKILL.md`:`${li}/${t}.md`}}},_1={rootInstructionPath:ec,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[rc]}],extraRuleOutputPaths(){return [rc]},skillDir:Aa,managedOutputs:{dirs:[nc,Aa,Zm],files:[ec,rc,fd]},rewriteGeneratedPath(t){return t===br?ec:t===co?rc:t===Oa?fd:t.startsWith(`${He}/`)?t.replace(`${He}/`,`${nc}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Aa}/`):t.startsWith(`${li}/`)?t.replace(`${li}/`,`${Zm}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return pt(t,Aa,e)},paths:{rulePath(t,e){return ec},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${nc}/${r.join("/")}/${n}.toml`}return `${nc}/${t}.toml`},agentPath(t,e){return qe(e,"gemini-cli")?`${Aa}/${U(t)}/SKILL.md`:`${Zm}/${t}.md`}}},R1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},_d={id:"gemini-cli",metadata:{displayName:"Gemini CLI",category:"cli",officialUrl:"https://github.com/google-gemini/gemini-cli",shortDescription:"Google's terminal Gemini agent"},generators:h1,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Gr("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:dx,lint:{commands:gx,hooks:hx},emitScopedSettings:_x,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Oa?uP(o,r):null},project:y1,globalSupport:{capabilities:R1,detectionPaths:[ec,rc,fd,nc,Aa,Zm],layout:_1},importer:{rules:{feature:"rules",mode:"directory",source:{project:[DT]},canonicalDir:ci,extensions:[".md"],map:mx},commands:{feature:"commands",mode:"directory",source:{project:[He]},canonicalDir:dd,extensions:[".md",".toml"],map:px}},buildImportPaths:Nh,detectionPaths:["GEMINI.md",".gemini"],conversionDefaults:{agentsToSkills:false}};});function Ix(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Bn)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:_r,content:o}]:[]}function Sx(t){return rt(t,Oe)}function Cx(t){return t.commands.map(e=>({path:`${Oe}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function kx(t){return t.agents.map(e=>({path:`${Oe}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function Ex(t){return t.ignore.length===0?[]:[{path:Wo,content:t.ignore.join(`
133
- `)}]}var Lx=d(()=>{tt();Ut();mt();kt();Cl();s(Ix,"generateRules");s(Sx,"generateSkills");s(Cx,"generateCommands");s(kx,"generateAgents");s(Ex,"generateIgnore");});async function Ox(t,e={}){let r=e.scope??"project",n=[],o=await B(Bn,t,r);return n.push(...await J(Rd,t,r,{normalize:o})),await q(t,r==="global"?Rr:Oe,Bn,n,o),n}var Ax=d(()=>{dt();tt();Et();Cl();k_();s(Ox,"importFromGoose");});function wx(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Bn}))}var bx=d(()=>{It();Cl();s(wx,"lintRules");});function Px(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Tx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function xx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var Dx=d(()=>{Lt();s(Px,"lintHooks");s(Tx,"lintPermissions");s(xx,"lintMcp");});var I1,S1,C1,Nx,Rd,k_=d(()=>{kt();mt();Lx();ee();Ax();bx();Dx();Ct();Cl();I1={name:Bn,primaryRootInstructionPath:_r,generateRules:Ix,generateCommands:Cx,generateAgents:kx,generateSkills:Sx,generateIgnore:Ex,importFrom:Ox},S1={rootInstructionPath:_r,skillDir:Oe,managedOutputs:{dirs:[Oe],files:[_r,Wo]},paths:{rulePath(t){return _r},commandPath(t){return `${Oe}/${H(t)}/SKILL.md`},agentPath(t){return `${Oe}/${U(t)}/SKILL.md`}}},C1={rootInstructionPath:Ho,skillDir:Rr,managedOutputs:{dirs:[Rr],files:[Ho,Vi]},rewriteGeneratedPath(t){return t===_r?Ho:t===Wo?Vi:t},mirrorGlobalPath(t,e){return pt(t,Rr,e)},paths:{rulePath(t){return Ho},commandPath(t){return `${Rr}/${H(t)}/SKILL.md`},agentPath(t){return `${Rr}/${U(t)}/SKILL.md`}}},Nx={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Rd={id:Bn,metadata:{displayName:"Goose",category:"cli",officialUrl:"https://block.github.io/goose",shortDescription:"Block's open-source AI agent"},generators:I1,capabilities:Nx,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:wx,lint:{hooks:Px,permissions:Tx,mcp:xx},supportsConversion:{commands:true,agents:true},project:S1,globalSupport:{capabilities:Nx,detectionPaths:[Ho,Vi,Rr],layout:C1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[_r],global:[Ho]},canonicalDir:DE,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Wo],global:[Vi]},canonicalDir:".agentsmesh",canonicalFilename:NE}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Fh,detectionPaths:[_r,Wo],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function Fx(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)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:Zr,content:o}]:[]}var vx=d(()=>{Ut();kl();s(Fx,"generateRules");});async function Mx(t,e={}){let r=e.scope??"project",n=await B(zo,t,r);return J(Id,t,r,{normalize:n})}var $x=d(()=>{dt();Et();kl();E_();s(Mx,"importFromJules");});function Gx(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:zo}))}var jx=d(()=>{It();kl();s(Gx,"lintRules");});function Ux(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","jules","Jules has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Bx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","jules","Jules has no permissions system; canonical permissions are not projected.")]}function Kx(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","jules","Jules is a cloud-based agent with no dedicated ignore file; canonical ignore patterns are not projected.")]}function Wx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","jules","Jules is a cloud-based agent with no MCP support; canonical MCP servers are not projected.")]}function Hx(t){return t.commands.length===0?[]:[x(".agentsmesh/commands","jules","Jules has no command system; canonical commands are not projected.")]}var zx=d(()=>{Lt();s(Ux,"lintHooks");s(Bx,"lintPermissions");s(Kx,"lintIgnore");s(Wx,"lintMcp");s(Hx,"lintCommands");});var k1,E1,L1,Id,E_=d(()=>{vx();$x();jx();zx();Ct();kl();k1={name:zo,primaryRootInstructionPath:Zr,generateRules:Fx,importFrom:Mx},E1={rootInstructionPath:Zr,managedOutputs:{dirs:[],files:[Zr]},paths:{rulePath(t){return Zr},commandPath(){return null},agentPath(){return null}}},L1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Id={id:zo,metadata:{displayName:"Jules",category:"agent-platform",officialUrl:"https://jules.google",shortDescription:"Google's autonomous coding agent"},generators:k1,capabilities:L1,emptyImportMessage:"No Jules config found (AGENTS.md).",lintRules:Gx,lint:{hooks:Ux,permissions:Bx,ignore:Kx,mcp:Wx,commands:Hx},project:E1,importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Zr]},canonicalDir:vE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:vh,detectionPaths:[Zr]};});function Vx(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Kn,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("junie"))continue;let o=basename(n.source,".md");e.push({path:`${Im}/${o}.md`,content:n.body.trim()||""});}return e}function A1(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),Bu(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 Jx(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).map(([r,n])=>[r,A1(n)]));return [{path:Rm,content:JSON.stringify({mcpServers:e},null,2)}]}function Yx(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${El}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function Xx(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(n=>{r[n]===void 0&&delete r[n];}),{path:`${Ll}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function Zx(t){return t.ignore.length===0?[]:[{path:Sm,content:t.ignore.join(`
134
- `)}]}function Qx(t){return rt(t,Yi)}function qx(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("junie"));return lt(e?.body.trim()??"",r)}var tD=d(()=>{Ku();tt();Ut();j();Ol();s(Vx,"generateRules");s(A1,"toJunieMcpServer");s(Jx,"generateMcp");s(Yx,"generateCommands");s(Xx,"generateAgents");s(Zx,"generateIgnore");s(Qx,"generateSkills");s(qx,"renderJunieGlobalInstructions");});async function w1(t,e,r){let n=[Kn,ku,$E,GE],o=join(t,Mh);for(let i of n){let a=join(t,i),l=await _(a);if(l===null)continue;let c=await oo({content:l,projectRoot:t,rulesDir:Lu,sourcePath:a,fromTool:Ji,normalize:r});e.push(...c.results);let{frontmatter:m,body:p}=b(r(c.rootContent,a,o)),u=await K(o,{root:true,description:typeof m.description=="string"?m.description:void 0,globs:Array.isArray(m.globs)?m.globs:void 0},p);await I(o,u),e.push({fromTool:Ji,fromPath:a,toPath:Mh,feature:"rules"});return}}async function rD(t){let e=[],r=await B(Ji,t);return await w1(t,e,r),e.push(...await J(Sd,t,"project",{normalize:r})),await q(t,Yi,Ji,e,r),e}var nD=d(()=>{dt();w();j();tt();Hl();ut();Et();Ol();L_();s(w1,"importRootRule");s(rD,"importFromJunie");});function oD(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Ji}))}var sD=d(()=>{It();Ol();s(oD,"lintRules");});function iD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))lw(n)&&e.push(x(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${n.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var aD=d(()=>{Ku();Lt();s(iD,"lintMcp");});var b1,P1,T1,x1,Sd,L_=d(()=>{tD();Ol();ee();nD();sD();aD();Ct();b1={name:"junie",primaryRootInstructionPath:Kn,generateRules:Vx,generateCommands:Yx,generateAgents:Xx,generateSkills:Qx,generateMcp:Jx,generateIgnore:Zx,importFrom:rD},P1={rootInstructionPath:Kn,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 `${Im}/${t}.md`},commandPath(t,e){return `${El}/${t}.md`},agentPath(t,e){return `${Ll}/${t}.md`}}},T1={rootInstructionPath:Xi,renderPrimaryRootInstruction:qx,skillDir:km,managedOutputs:{dirs:[km,Em,Lm,jE],files:[Xi,Eu]},rewriteGeneratedPath(t){return t===Kn?Xi:t.startsWith(`${Im}/`)?Xi:t.startsWith(`${Yi}/`)?t.replace(`${Yi}/`,`${km}/`):t.startsWith(`${El}/`)?t.replace(`${El}/`,`${Lm}/`):t.startsWith(`${Ll}/`)?t.replace(`${Ll}/`,`${Em}/`):t===Rm?Eu:t===Sm?null:t},mirrorGlobalPath(t,e){return pt(t,".junie/skills",e)},paths:{rulePath(t,e){return Xi},commandPath(t,e){return `${Lm}/${t}.md`},agentPath(t,e){return `${Em}/${t}.md`}}},x1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Sd={id:"junie",metadata:{displayName:"Junie",category:"ide",officialUrl:"https://www.jetbrains.com/junie",shortDescription:"JetBrains AI coding agent"},generators:b1,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:oD,lint:{mcp:iD},project:P1,globalSupport:{capabilities:x1,detectionPaths:[Xi,km,Em,Lm,Eu],layout:T1},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Lu,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:UE,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:BE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Rm]},canonicalDir:".agentsmesh",canonicalFilename:KE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Sm]},canonicalDir:".agentsmesh",canonicalFilename:WE}},buildImportPaths:$h,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function cD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Wn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(_e))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs);let a=Object.keys(i).length>0?T(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Vo}/${o}.md`,content:a});}return e}function mD(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Jo}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function pD(t){return t.agents.map(e=>{let r=basename(e.source,".md"),n={mode:"subagent"};return e.description&&(n.description=e.description),e.model&&(n.model=e.model),e.tools.length>0&&(n.tools=e.tools),e.disallowedTools.length>0&&(n.disallowedTools=e.disallowedTools),{path:`${Yo}/${r}.md`,content:T(n,e.body.trim()||"")}})}function uD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Us,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function dD(t){return t.ignore.length===0?[]:[{path:Al,content:t.ignore.join(`
135
- `)}]}function fD(t){return rt(t,Qr)}var gD=d(()=>{tt();j();na();s(cD,"generateRules");s(mD,"generateCommands");s(pD,"generateAgents");s(uD,"generateMcp");s(dD,"generateIgnore");s(fD,"generateSkills");});var Cd,kd,hD,A_=d(()=>{j();ut();na();Cd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Ws}/${t}`,content:await K(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"kiloNonRootRuleMapper"),kd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Tl}/${t}`,content:await _t(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),hD=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${ra}/${t}`,content:await Vt(n,o,i)}},"kiloAgentMapper");});async function yD(t){try{return await stat(t),!0}catch{return false}}async function F1(t,e,r){let n=join(t,Zi);if(!await yD(n))return;let o=join(t,Ws),i=join(n,b_),l=e.some(c=>c.toPath===w_)?null:await _(i);if(l!==null){let c=join(t,w_),m=r(l,i,c),{body:p}=b(m),u=await K(c,{root:true},p);await I(c,u),e.push({feature:"rules",fromTool:_e,fromPath:`${Zi}/${b_}`,toPath:w_});}e.push(...await Rt({srcDir:n,destDir:o,extensions:[".md"],fromTool:_e,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await Cd({absolutePath:c,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===b_||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function v1(t,e,r){let n=join(t,wl);if(!await yD(n))return;let o=join(t,Tl);e.push(...await Rt({srcDir:n,destDir:o,extensions:[".md"],fromTool:_e,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:l,normalizeTo:c})=>{let m=await kd({absolutePath:i,relativePath:a,content:l,destDir:o,normalizeTo:c});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function M1(t,e,r){let n=join(t,Au),o=await _(n);if(o===null)return;let i;try{i=parse(o);}catch{return}if(!(!i||!Array.isArray(i.customModes)))for(let a of i.customModes){if(!a||typeof a!="object")continue;let l=a;if(typeof l.slug!="string"||l.slug.length===0)continue;let c=l.slug,m=join(t,ra,`${c}.md`),p=typeof l.description=="string"?l.description:"",u=typeof l.roleDefinition=="string"?l.roleDefinition.trim():"",f=typeof l.whenToUse=="string"?l.whenToUse.trim():"",g=f?`${u}
133
+ `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:ec,feature:"ignore"});}}}var x_=d(()=>{A();Yt();b_();rx();s(nx,"importGeminiIgnore");});function L1(t){return t.replace(/\\(.)/g,"$1")}function O1(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 w1(t){return `Bash(${t}:*)`}function A1(t){return `Read(${L1(t)})`}async function ox(t){let e=[],r=join(t,Ed),n;try{n=await $(r);}catch{return e}let o=n.filter(u=>u.endsWith(".toml"));if(o.length===0)return e;let i=[],a=[],l=new Set,c=new Set;for(let u of o){let f=await _(u);if(!f)continue;let g;try{g=parse$1(f);}catch{continue}let h=g&&typeof g=="object"&&"rule"in g?g.rule:void 0;if(Array.isArray(h))for(let I of h){if(!I||typeof I!="object")continue;let k=I,C=typeof k.toolName=="string"?k.toolName:null,R=typeof k.decision=="string"?k.decision:null;if(!C||!R)continue;let P=O1(C);if(!P)continue;let N=null;P==="Bash"?typeof k.commandPrefix=="string"&&k.commandPrefix.trim()&&(N=w1(k.commandPrefix.trim())):P==="Read"?typeof k.argsPattern=="string"&&k.argsPattern.trim()?N=A1(k.argsPattern.trim()):N="Read":N=P,N&&(R==="allow"?l.has(N)||(l.add(N),i.push(N)):R==="deny"&&(c.has(N)||(c.add(N),a.push(N))));}}if(i.length===0&&a.length===0)return e;await O(join(t,".agentsmesh"));let m=join(t,I_),p=stringify({allow:i,deny:a});return await S(m,p.trimEnd()+`
134
+ `),e.push({fromTool:li,fromPath:join(t,Ed),toPath:I_,feature:"permissions"}),e}var sx=d(()=>{A();Yt();s(L1,"unescapeRegexLiteral");s(O1,"toolNameToPermissionBase");s(w1,"commandPrefixToBashExpr");s(A1,"argsPatternToReadExpr");s(ox,"importGeminiPolicies");});function D_(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((o,i)=>{let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return o.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 ax=d(()=>{s(D_,"stripProjectRootCanonicalPrefix");});async function cx(t,e,r){let n=join(t,Qm),i=(await $(n)).filter(l=>basename(l)==="SKILL.md");for(let l of i){let c=await _(l);if(!c)continue;let m=basename(l.slice(0,-9)),p=b(c),u=ll(p.frontmatter,m);if(u){let R=join(t,qm);await O(R);let P=join(R,`${u.name}.md`);await S(P,ws(u,r(p.body,l,P))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${qm}/${u.name}.md`,feature:"agents"});continue}let f=join(t,tp,m,"SKILL.md"),g=r(c,l,f),h=join(t,tp,m);await O(h);let{frontmatter:I,body:k}=b(g);await S(f,await En(f,{...I,name:m},k)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${tp}/${m}/SKILL.md`,feature:"skills"});let C=await $(dirname(l));for(let R of C){if(R===l)continue;let P=await _(R);if(P===null)continue;let N=relative(dirname(l),R).replace(/\\/g,"/"),F=join(h,N);await O(dirname(F)),await S(F,r(P,R,F)),e.push({fromTool:"gemini-cli",fromPath:R,toPath:`${tp}/${m}/${N}`,feature:"skills"});}}let a=join(t,ci);try{let c=(await $(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await _(m);if(!p)continue;let{frontmatter:u,body:f}=b(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),I=join(t,qm);await O(I);let k=join(I,h),C=r(f,m,k);await S(k,await Jt(k,{...u,name:typeof u.name=="string"?u.name:basename(h,".md"),maxTurns:u.maxTurns??u["max-turns"]??u.max_turns,permissionMode:u.permissionMode??u["permission-mode"]??u.permission_mode,disallowedTools:u.disallowedTools??u["disallowed-tools"]??u.disallowed_tools},C)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${qm}/${h}`,feature:"agents"});}}catch{}}var mx=d(()=>{A();K();ft();ut();Yt();s(cx,"importGeminiSkillsAndAgents");});async function b1(t,e,r){let n=await H("codex-cli",t),o=join(t,mi),i=join(t,po),a=join(t,UT),l=[i,a,join(t,Nr),join(t,BT)],c=null,m=l[l.length-1];for(let N of l){let F=await _(N);if(F!==null){c=F,m=N;break}}if(c===null)return;await O(o);let p=join(o,"_root.md"),u=m===i||m===a?n(c,m,p):c,f=await io({content:u,projectRoot:t,rulesDir:mi,sourcePath:m,fromTool:li,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=D_(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:I,body:k}=b(h),R=I.root===true?I:{...I,root:true},P=D_(await z(p,R,k),t);await S(p,P),e.push({fromTool:li,fromPath:m,toPath:`${mi}/_root.md`,feature:"rules"});}async function px(t){let e=[],r=await H(li,t);return await b1(t,e,r),e.push(...await Y(Td,t,"project",{normalize:r})),await cx(t,e,r),await P_(t,e),await nx(t,e),e.push(...await ox(t)),e}var ux=d(()=>{gt();A();K();ft();zl();Ot();Yt();v_();x_();sx();ax();mx();s(b1,"importRootRule");s(px,"importFromGemini");});async function fx(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=bd(r(o)),l=Po(i.globs),c={root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${mi}/${n}`,feature:"rules",content:await z(o,c,a)}}async function gx(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),i=r(o),{frontmatter:a,body:l}=t.endsWith(".toml")?T1(i):bd(i),c=lr(a.allowedTools),m=lr(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${Od}/${n}`,feature:"commands",content:await It(o,{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")},l)}}function T1(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var hx=d(()=>{ft();cr();x_();Yt();s(fx,"mapGeminiRuleFile");s(gx,"mapGeminiCommandFile");s(T1,"parseTomlCommand");});var yx,_x,Rx=d(()=>{hx();yx=s(({relativePath:t,destDir:e,normalizeTo:r})=>fx(t,e,r),"geminiRuleMapper"),_x=s(({relativePath:t,destDir:e,normalizeTo:r})=>gx(t,e,r),"geminiCommandMapper");});function Ix(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:li}))}var Sx=d(()=>{Ct();Yt();s(Ix,"lintRules");});function Cx(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>x(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function kx(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(n=>!r.has(n)).map(n=>Ts(n,"gemini-cli",e))}var Ex=d(()=>{wt();s(Cx,"lintCommands");s(kx,"lintHooks");});function Lx(t,e){return e==="project"&&pi("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:L_(t)}var Ox=d(()=>{Pt();O_();s(Lx,"emitScopedGeminiSettings");});var x1,D1,N1,F1,Td,v_=d(()=>{QT();Pi();ex();Yt();ux();Rx();Sx();Et();sl();ut();Ex();Ox();ne();dd();x1={name:"gemini-cli",primaryRootInstructionPath:Nr,generateRules:S_,generateCommands:C_,generateAgents:k_,generateSkills:E_,generateIgnore:w_,generatePermissions:tx,importFrom:px},D1={rootInstructionPath:Nr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[po]}],extraRuleOutputPaths(){return [po]},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 dt(t,".gemini/skills",e)},paths:{rulePath(t,e){return Nr},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${Xe}/${r.join("/")}/${n}.toml`}return `${Xe}/${t}.toml`},agentPath(t,e){return or(e,"gemini-cli")?`.gemini/skills/${W(t)}/SKILL.md`:`${ci}/${t}.md`}}},N1={rootInstructionPath:rc,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[nc]}],extraRuleOutputPaths(){return [nc]},skillDir:ba,managedOutputs:{dirs:[oc,ba,ep],files:[rc,nc,wd]},rewriteGeneratedPath(t){return t===Nr?rc:t===po?nc:t===Aa?wd:t.startsWith(`${Xe}/`)?t.replace(`${Xe}/`,`${oc}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${ba}/`):t.startsWith(`${ci}/`)?t.replace(`${ci}/`,`${ep}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return dt(t,ba,e)},paths:{rulePath(t,e){return rc},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${oc}/${r.join("/")}/${n}.toml`}return `${oc}/${t}.toml`},agentPath(t,e){return or(e,"gemini-cli")?`${ba}/${W(t)}/SKILL.md`:`${ep}/${t}.md`}}},F1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},Td={id:"gemini-cli",metadata:{displayName:"Gemini CLI",category:"cli",officialUrl:"https://github.com/google-gemini/gemini-cli",shortDescription:"Google's terminal Gemini agent"},generators:x1,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Kr("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:Ix,lint:{commands:Cx,hooks:kx},emitScopedSettings:Lx,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Aa?RP(o,r):null},project:D1,globalSupport:{capabilities:F1,detectionPaths:[rc,nc,wd,oc,ba,ep],layout:N1},importer:{rules:{feature:"rules",mode:"directory",source:{project:[jT]},canonicalDir:mi,extensions:[".md"],map:yx},commands:{feature:"commands",mode:"directory",source:{project:[Xe]},canonicalDir:Od,extensions:[".md",".toml"],map:_x}},buildImportPaths:Jh,detectionPaths:["GEMINI.md",".gemini"],conversionDefaults:{agentsToSkills:false}};});function wx(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Wn)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:kr,content:o}]:[]}function Ax(t){return it(t,Ae)}function bx(t){return t.commands.map(e=>({path:`${Ae}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function Px(t){return t.agents.map(e=>({path:`${Ae}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function Tx(t){return t.ignore.length===0?[]:[{path:zo,content:t.ignore.join(`
135
+ `)}]}var xx=d(()=>{rt();Kt();ut();Lt();kl();s(wx,"generateRules");s(Ax,"generateSkills");s(bx,"generateCommands");s(Px,"generateAgents");s(Tx,"generateIgnore");});async function Dx(t,e={}){let r=e.scope??"project",n=[],o=await H(Wn,t,r);return n.push(...await Y(xd,t,r,{normalize:o})),await et(t,r==="global"?Er:Ae,Wn,n,o),n}var Nx=d(()=>{gt();rt();Ot();kl();M_();s(Dx,"importFromGoose");});function Fx(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Wn}))}var vx=d(()=>{Ct();kl();s(Fx,"lintRules");});function Mx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function $x(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function Gx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var jx=d(()=>{wt();s(Mx,"lintHooks");s($x,"lintPermissions");s(Gx,"lintMcp");});var v1,M1,$1,Ux,xd,M_=d(()=>{Lt();ut();xx();ne();Nx();vx();jx();Et();kl();v1={name:Wn,primaryRootInstructionPath:kr,generateRules:wx,generateCommands:bx,generateAgents:Px,generateSkills:Ax,generateIgnore:Tx,importFrom:Dx},M1={rootInstructionPath:kr,skillDir:Ae,managedOutputs:{dirs:[Ae],files:[kr,zo]},paths:{rulePath(t){return kr},commandPath(t){return `${Ae}/${V(t)}/SKILL.md`},agentPath(t){return `${Ae}/${W(t)}/SKILL.md`}}},$1={rootInstructionPath:Vo,skillDir:Er,managedOutputs:{dirs:[Er],files:[Vo,Yi]},rewriteGeneratedPath(t){return t===kr?Vo:t===zo?Yi:t},mirrorGlobalPath(t,e){return dt(t,Er,e)},paths:{rulePath(t){return Vo},commandPath(t){return `${Er}/${V(t)}/SKILL.md`},agentPath(t){return `${Er}/${W(t)}/SKILL.md`}}},Ux={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},xd={id:Wn,metadata:{displayName:"Goose",category:"cli",officialUrl:"https://block.github.io/goose",shortDescription:"Block's open-source AI agent"},generators:v1,capabilities:Ux,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:Fx,lint:{hooks:Mx,permissions:$x,mcp:Gx},supportsConversion:{commands:true,agents:true},project:M1,globalSupport:{capabilities:Ux,detectionPaths:[Vo,Yi,Er],layout:$1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[kr],global:[Vo]},canonicalDir:jE,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[zo],global:[Yi]},canonicalDir:".agentsmesh",canonicalFilename:UE}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Yh,detectionPaths:[kr,zo],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function Bx(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Jo)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:en,content:o}]:[]}var Kx=d(()=>{Kt();El();s(Bx,"generateRules");});async function Wx(t,e={}){let r=e.scope??"project",n=await H(Jo,t,r);return Y(Dd,t,r,{normalize:n})}var Hx=d(()=>{gt();Ot();El();$_();s(Wx,"importFromJules");});function zx(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Jo}))}var Vx=d(()=>{Ct();El();s(zx,"lintRules");});function Jx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","jules","Jules has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Yx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","jules","Jules has no permissions system; canonical permissions are not projected.")]}function Xx(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","jules","Jules is a cloud-based agent with no dedicated ignore file; canonical ignore patterns are not projected.")]}function Zx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","jules","Jules is a cloud-based agent with no MCP support; canonical MCP servers are not projected.")]}function Qx(t){return t.commands.length===0?[]:[x(".agentsmesh/commands","jules","Jules has no command system; canonical commands are not projected.")]}var qx=d(()=>{wt();s(Jx,"lintHooks");s(Yx,"lintPermissions");s(Xx,"lintIgnore");s(Zx,"lintMcp");s(Qx,"lintCommands");});var G1,j1,U1,Dd,$_=d(()=>{Kx();Hx();Vx();qx();Et();El();G1={name:Jo,primaryRootInstructionPath:en,generateRules:Bx,importFrom:Wx},j1={rootInstructionPath:en,managedOutputs:{dirs:[],files:[en]},paths:{rulePath(t){return en},commandPath(){return null},agentPath(){return null}}},U1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Dd={id:Jo,metadata:{displayName:"Jules",category:"agent-platform",officialUrl:"https://jules.google",shortDescription:"Google's autonomous coding agent"},generators:G1,capabilities:U1,emptyImportMessage:"No Jules config found (AGENTS.md).",lintRules:zx,lint:{hooks:Jx,permissions:Yx,ignore:Xx,mcp:Zx,commands:Qx},project:j1,importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[en]},canonicalDir:KE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Xh,detectionPaths:[en]};});function tD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Hn,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("junie"))continue;let o=basename(n.source,".md");e.push({path:`${Em}/${o}.md`,content:n.body.trim()||""});}return e}function K1(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),ed(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 eD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).map(([r,n])=>[r,K1(n)]));return [{path:km,content:JSON.stringify({mcpServers:e},null,2)}]}function rD(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${Ll}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function nD(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(n=>{r[n]===void 0&&delete r[n];}),{path:`${Ol}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function oD(t){return t.ignore.length===0?[]:[{path:Lm,content:t.ignore.join(`
136
+ `)}]}function sD(t){return it(t,Zi)}function iD(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("junie"));return mt(e?.body.trim()??"",r)}var aD=d(()=>{rd();rt();Kt();K();wl();s(tD,"generateRules");s(K1,"toJunieMcpServer");s(eD,"generateMcp");s(rD,"generateCommands");s(nD,"generateAgents");s(oD,"generateIgnore");s(sD,"generateSkills");s(iD,"renderJunieGlobalInstructions");});async function W1(t,e,r){let n=[Hn,vu,HE,zE],o=join(t,Zh);for(let i of n){let a=join(t,i),l=await _(a);if(l===null)continue;let c=await io({content:l,projectRoot:t,rulesDir:$u,sourcePath:a,fromTool:Xi,normalize:r});e.push(...c.results);let{frontmatter:m,body:p}=b(r(c.rootContent,a,o)),u=await z(o,{root:true,description:typeof m.description=="string"?m.description:void 0,globs:Array.isArray(m.globs)?m.globs:void 0},p);await S(o,u),e.push({fromTool:Xi,fromPath:a,toPath:Zh,feature:"rules"});return}}async function cD(t){let e=[],r=await H(Xi,t);return await W1(t,e,r),e.push(...await Y(Nd,t,"project",{normalize:r})),await et(t,Zi,Xi,e,r),e}var mD=d(()=>{gt();A();K();rt();zl();ft();Ot();wl();G_();s(W1,"importRootRule");s(cD,"importFromJunie");});function pD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Xi}))}var uD=d(()=>{Ct();wl();s(pD,"lintRules");});function dD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))gA(n)&&e.push(x(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${n.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var fD=d(()=>{rd();wt();s(dD,"lintMcp");});var H1,z1,V1,J1,Nd,G_=d(()=>{aD();wl();ne();mD();uD();fD();Et();H1={name:"junie",primaryRootInstructionPath:Hn,generateRules:tD,generateCommands:rD,generateAgents:nD,generateSkills:sD,generateMcp:eD,generateIgnore:oD,importFrom:cD},z1={rootInstructionPath:Hn,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 `${Em}/${t}.md`},commandPath(t,e){return `${Ll}/${t}.md`},agentPath(t,e){return `${Ol}/${t}.md`}}},V1={rootInstructionPath:Qi,renderPrimaryRootInstruction:iD,skillDir:wm,managedOutputs:{dirs:[wm,Am,bm,VE],files:[Qi,Mu]},rewriteGeneratedPath(t){return t===Hn?Qi:t.startsWith(`${Em}/`)?Qi:t.startsWith(`${Zi}/`)?t.replace(`${Zi}/`,`${wm}/`):t.startsWith(`${Ll}/`)?t.replace(`${Ll}/`,`${bm}/`):t.startsWith(`${Ol}/`)?t.replace(`${Ol}/`,`${Am}/`):t===km?Mu:t===Lm?null:t},mirrorGlobalPath(t,e){return dt(t,".junie/skills",e)},paths:{rulePath(t,e){return Qi},commandPath(t,e){return `${bm}/${t}.md`},agentPath(t,e){return `${Am}/${t}.md`}}},J1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Nd={id:"junie",metadata:{displayName:"Junie",category:"ide",officialUrl:"https://www.jetbrains.com/junie",shortDescription:"JetBrains AI coding agent"},generators:H1,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:pD,lint:{mcp:dD},project:z1,globalSupport:{capabilities:J1,detectionPaths:[Qi,wm,Am,bm,Mu],layout:V1},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:$u,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:JE,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:YE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[km]},canonicalDir:".agentsmesh",canonicalFilename:XE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Lm]},canonicalDir:".agentsmesh",canonicalFilename:ZE}},buildImportPaths:Qh,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function hD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:zn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Re))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs);let a=Object.keys(i).length>0?T(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Yo}/${o}.md`,content:a});}return e}function yD(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Xo}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function _D(t){return t.agents.map(e=>{let r=basename(e.source,".md"),n={mode:"subagent"};return e.description&&(n.description=e.description),e.model&&(n.model=e.model),e.tools.length>0&&(n.tools=e.tools),e.disallowedTools.length>0&&(n.disallowedTools=e.disallowedTools),{path:`${Zo}/${r}.md`,content:T(n,e.body.trim()||"")}})}function RD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Bs,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function ID(t){return t.ignore.length===0?[]:[{path:Al,content:t.ignore.join(`
137
+ `)}]}function SD(t){return it(t,rn)}var CD=d(()=>{rt();K();sa();s(hD,"generateRules");s(yD,"generateCommands");s(_D,"generateAgents");s(RD,"generateMcp");s(ID,"generateIgnore");s(SD,"generateSkills");});var Fd,vd,kD,U_=d(()=>{K();ft();sa();Fd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Hs}/${t}`,content:await z(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"kiloNonRootRuleMapper"),vd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${xl}/${t}`,content:await It(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),kD=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${oa}/${t}`,content:await Jt(n,o,i)}},"kiloAgentMapper");});async function ED(t){try{return await stat(t),!0}catch{return false}}async function Z1(t,e,r){let n=join(t,qi);if(!await ED(n))return;let o=join(t,Hs),i=join(n,K_),l=e.some(c=>c.toPath===B_)?null:await _(i);if(l!==null){let c=join(t,B_),m=r(l,i,c),{body:p}=b(m),u=await z(c,{root:true},p);await S(c,u),e.push({feature:"rules",fromTool:Re,fromPath:`${qi}/${K_}`,toPath:B_});}e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:Re,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await Fd({absolutePath:c,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===K_||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function Q1(t,e,r){let n=join(t,bl);if(!await ED(n))return;let o=join(t,xl);e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:Re,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:l,normalizeTo:c})=>{let m=await vd({absolutePath:i,relativePath:a,content:l,destDir:o,normalizeTo:c});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function q1(t,e,r){let n=join(t,ju),o=await _(n);if(o===null)return;let i;try{i=parse(o);}catch{return}if(!(!i||!Array.isArray(i.customModes)))for(let a of i.customModes){if(!a||typeof a!="object")continue;let l=a;if(typeof l.slug!="string"||l.slug.length===0)continue;let c=l.slug,m=join(t,oa,`${c}.md`),p=typeof l.description=="string"?l.description:"",u=typeof l.roleDefinition=="string"?l.roleDefinition.trim():"",f=typeof l.whenToUse=="string"?l.whenToUse.trim():"",g=f?`${u}
136
138
 
137
139
  ## When to use
138
140
 
139
- ${f}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let R=await Vt(m,h,g),C=r(R,n,m);await I(m,C),e.push({feature:"agents",fromTool:_e,fromPath:n,toPath:`${ra}/${c}.md`});}}async function _D(t,e={}){let r=e.scope??"project",n=[],o=await B(_e,t,r);return n.push(...await J(Ed,t,r,{normalize:o})),await q(t,Qr,_e,n,o),r==="project"&&(await F1(t,n,o),await v1(t,n,o),await M1(t,n,o),await q(t,Qi,_e,n,o)),n}var w_,b_,RD=d(()=>{dt();tt();xe();Et();w();ut();j();A_();na();P_();w_=`${Ws}/_root.md`,b_="00-root.md";s(yD,"pathExists");s(F1,"importLegacyRules");s(v1,"importLegacyWorkflows");s(M1,"importLegacyModes");s(_D,"importFromKiloCode");});function ID(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:_e}))}var SD=d(()=>{It();na();s(ID,"lintRules");});function CD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function kD(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".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 ED=d(()=>{Lt();s(CD,"lintHooks");s(kD,"lintPermissions");});var $1,G1,j1,LD,Ed,P_=d(()=>{gD();na();ee();RD();A_();SD();ED();Ct();$1={name:_e,primaryRootInstructionPath:Wn,generateRules:cD,generateCommands:mD,generateAgents:pD,generateSkills:fD,generateMcp:uD,generateIgnore:dD,importFrom:_D},G1={rootInstructionPath:Wn,skillDir:Qr,managedOutputs:{dirs:[Vo,Jo,Yo,Qr],files:[Wn,Us,Al]},paths:{rulePath(t,e){return `${Vo}/${t}.md`},commandPath(t,e){return `${Jo}/${t}.md`},agentPath(t,e){return `${Yo}/${t}.md`}}},j1={rootInstructionPath:Bs,skillDir:Ks,managedOutputs:{dirs:[qi,ta,ea,Ks,zE],files:[Bs,Pl,wu]},rewriteGeneratedPath(t){return t===Wn?Bs:t},mirrorGlobalPath(t,e){return pt(t,Ks,e)},paths:{rulePath(t,e){return `${qi}/${t}.md`},commandPath(t,e){return `${ta}/${t}.md`},agentPath(t,e){return `${ea}/${t}.md`}}},LD={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Ed={id:_e,metadata:{displayName:"Kilo Code",category:"ide",officialUrl:"https://kilocode.ai",shortDescription:"Open-source AI coding agent for VS Code"},generators:$1,capabilities:LD,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:ID,lint:{hooks:CD,permissions:kD},project:G1,globalSupport:{capabilities:LD,detectionPaths:[Bs,qi,ta,ea,Ks,Pl,wu],layout:j1},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Wn],global:[Bs]},canonicalDir:Ws,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Vo],global:[qi]},canonicalDir:Ws,extensions:[".md"],map:Cd}],commands:{feature:"commands",mode:"directory",source:{project:[Jo],global:[ta]},canonicalDir:Tl,extensions:[".md"],map:kd},agents:{feature:"agents",mode:"directory",source:{project:[Yo],global:[ea]},canonicalDir:ra,extensions:[".md"],map:hD},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Us,Am],global:[Pl]},canonicalDir:".agentsmesh",canonicalFilename:VE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Al],global:[wu]},canonicalDir:".agentsmesh",canonicalFilename:JE}},buildImportPaths:Gh,detectionPaths:[Vo,Jo,Yo,Qr,Us,Zi,wl,Qi,Am,Au,Al,"kilo.jsonc","kilo.json"]};});function OD(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function K1(t){return t.type==="prompt"?t.prompt:t.command}function W1(t,e){let r=AD[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function wD(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in AD)||!Array.isArray(n))continue;let i=1;for(let a of n){let l=K1(a);if(!l)continue;let c={name:`${OD(r)} ${i}`,version:"1",when:W1(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:l}:{type:"shellCommand",command:l}};e.push({name:`${OD(r)}-${i}.kiro.hook`,content:JSON.stringify(c,null,2)}),i+=1;}}return e}function H1(t){let e=B1.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 bD(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:H1(r)}function PD(t){return stringify(t).trimEnd()}var AD,B1,T_=d(()=>{AD={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},B1=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(OD,"toKebab");s(K1,"hookText");s(W1,"toWhen");s(wD,"generateKiroHooks");s(H1,"toCanonicalEntry");s(bD,"parseKiroHookFile");s(PD,"serializeCanonicalHooks");});function V1(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 TD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:qr,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Ge))continue;let o=basename(n.source,".md");e.push({path:`${tn}/${o}.md`,content:T(V1(n),n.body.trim()||"")});}return e}function xD(t){return t.commands.map(e=>({path:`${Re}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function DD(t){return rt(t,Re)}function ND(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:xl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function FD(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:wD(t.hooks).map(e=>({path:`${Hs}/${e.name}`,content:e.content}))}function vD(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${en}/${e.name}.md`,content:n}})}function MD(t){return t.ignore.length===0?[]:[{path:Dl,content:t.ignore.join(`
140
- `)}]}var $D=d(()=>{tt();kt();j();T_();Nl();s(V1,"steeringFrontmatter");s(TD,"generateRules");s(xD,"generateCommands");s(DD,"generateSkills");s(ND,"generateMcp");s(FD,"generateHooks");s(vD,"generateAgents");s(MD,"generateIgnore");});function Y1(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:wo(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function X1(t,e,r,n){let o=n==="global"?[rn,qr]:[qr,rn];for(let i of o){let a=join(t,i),l=await _(a);if(l===null)continue;let c=join(t,jh),{frontmatter:m,body:p}=b(r(l,a,c));await I(c,await K(c,{...m,root:true},p)),e.push({fromTool:Ge,fromPath:a,toPath:jh,feature:"rules"});return}}async function Z1(t,e,r){let n=join(t,Uh);e.push(...await Rt({srcDir:join(t,tn),destDir:n,extensions:[".md"],fromTool:Ge,normalize:r,mapEntry:s(async({relativePath:o,normalizeTo:i})=>{if(basename(o)==="AGENTS.md")return null;let a=join(n,o),{frontmatter:l,body:c}=b(i(a));return {destPath:a,toPath:`${Uh}/${o}`,feature:"rules",content:await K(a,Y1(l),c)}},"mapEntry")}));}async function Q1(t,e){let r={};for(let o of await v(join(t,Hs))){if(!o.endsWith(".kiro.hook"))continue;let i=bD(await _(o)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let n=join(t,Bh);await O(join(t,".agentsmesh")),await I(n,PD(r)),e.push({fromTool:Ge,fromPath:join(t,Hs),toPath:Bh,feature:"hooks"});}async function GD(t,e={}){let r=e.scope??"project",n=[],o=await B(Ge,t,r);return await X1(t,n,o,r),await Z1(t,n,o),n.push(...await J(Ld,t,r,{normalize:o})),await q(t,Re,Ge,n,o),r==="project"&&await Q1(t,n),n}var jD=d(()=>{dt();tt();xe();Et();ut();or();w();j();T_();Nl();x_();s(Y1,"canonicalRuleMeta");s(X1,"importRoot");s(Z1,"importNonRootRules");s(Q1,"importHooks");s(GD,"importFromKiro");});function UD(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Ge}))}var BD=d(()=>{It();Nl();s(UD,"lintRules");});function KD(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(n=>!r.has(n)).map(n=>Ps(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var WD=d(()=>{Lt();s(KD,"lintHooks");});var q1,tJ,eJ,rJ,Ld,x_=d(()=>{kt();$D();ee();jD();BD();WD();Ct();Nl();q1={name:Ge,primaryRootInstructionPath:qr,generateRules:TD,generateCommands:xD,generateAgents:vD,generateSkills:DD,generateMcp:ND,generateHooks:FD,generateIgnore:MD,importFrom:GD},tJ={rootInstructionPath:qr,skillDir:Re,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${tn}/${t}.md`},commandPath(t){return `${Re}/${H(t)}/SKILL.md`},agentPath(t,e){return `${en}/${t}.md`}}},eJ={rootInstructionPath:rn,skillDir:zs,managedOutputs:{dirs:[oa,zs,sa,XE],files:[rn,bm,Pm]},rewriteGeneratedPath(t){return t===qr?rn:t.startsWith(`${tn}/`)?t.replace(`${tn}/`,`${oa}/`):t.startsWith(`${Re}/`)?t.replace(`${Re}/`,`${zs}/`):t.startsWith(`${en}/`)?t.replace(`${en}/`,`${sa}/`):t===xl?bm:t===Dl?Pm:t.startsWith(`${Hs}/`)?null:t},mirrorGlobalPath(t,e){return pt(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${oa}/${t}.md`},commandPath(t){return `${Re}/${H(t)}/SKILL.md`},agentPath(t,e){return `${sa}/${t}.md`}}},rJ={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Ld={id:Ge,metadata:{displayName:"Kiro",category:"ide",officialUrl:"https://kiro.dev",shortDescription:"AWS spec-driven AI IDE"},generators:q1,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:UD,lint:{hooks:KD},project:tJ,globalSupport:{capabilities:rJ,detectionPaths:[oa,rn,zs,sa,bm,Pm],layout:eJ},importer:{agents:{feature:"agents",mode:"directory",source:{project:[en],global:[en]},canonicalDir:ZE,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[xl],global:[bm]},canonicalDir:".agentsmesh",canonicalFilename:QE},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Dl],global:[Pm]},canonicalDir:".agentsmesh",canonicalFilename:qE}},buildImportPaths:Kh,detectionPaths:[tn,Re,en,Hs,xl,Dl],conversionDefaults:{commandsToSkills:true}};});function zD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Hn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(nn))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs);let a=Object.keys(i).length>0?T(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Xo}/${o}.md`,content:a});}return e}function VD(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Zo}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function JD(t){return t.agents.map(e=>{let r=basename(e.source,".md"),n={mode:"subagent"};return e.description&&(n.description=e.description),e.model&&(n.model=e.model),e.tools.length>0&&(n.tools=e.tools),e.disallowedTools.length>0&&(n.disallowedTools=e.disallowedTools),{path:`${Qo}/${r}.md`,content:T(n,e.body.trim()||"")}})}function nJ(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 YD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e={};for(let[r,n]of Object.entries(t.mcp.mcpServers))e[r]=nJ(n);return [{path:zn,content:JSON.stringify({mcp:e},null,2)}]}function XD(t){return rt(t,on)}var ZD=d(()=>{tt();j();ca();s(zD,"generateRules");s(VD,"generateCommands");s(JD,"generateAgents");s(nJ,"toOpenCodeMcpServer");s(YD,"generateMcp");s(XD,"generateSkills");});function D_(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t))typeof n=="string"&&(e[r]=n);return e}function sJ(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 n={};for(let[o,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i;if(typeof a.url=="string"){n[o]={type:"url",url:a.url,headers:D_(a.headers),env:D_(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let l=a.command,c=l[0];if(c===void 0)continue;let m=l.slice(1);n[o]={type:"stdio",command:c,args:m,env:D_(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function iJ(t,e,r){let o=join(t,e==="global"?Ys:zn),i=await _(o);if(i===null)return;let a=sJ(i);Object.keys(a).length!==0&&(await Bt(t,Wh,a),r.push({feature:"mcp",fromTool:nn,fromPath:o,toPath:Wh}));}async function QD(t,e={}){let r=e.scope??"project",n=[],o=await B(nn,t,r);return n.push(...await J(Od,t,r,{normalize:o})),await q(t,on,nn,n,o),await iJ(t,r,n),n}var qD=d(()=>{dt();tt();Et();Kr();w();ca();N_();s(D_,"toStringRecord");s(sJ,"parseOpenCodeMcp");s(iJ,"importMcp");s(QD,"importFromOpenCode");});var tN,eN,rN,nN=d(()=>{j();ut();ca();tN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Tm}/${t}`,content:await K(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"opencodeNonRootRuleMapper"),eN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Pu}/${t}`,content:await _t(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),rN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Tu}/${t}`,content:await Vt(n,o,i)}},"opencodeAgentMapper");});function oN(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:nn}))}var sN=d(()=>{It();ca();s(oN,"lintRules");});function iN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function aN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function lN(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var cN=d(()=>{Lt();s(iN,"lintHooks");s(aN,"lintPermissions");s(lN,"lintIgnore");});var aJ,lJ,cJ,mN,Od,N_=d(()=>{ZD();ca();ee();qD();nN();sN();cN();Ct();aJ={name:nn,primaryRootInstructionPath:Hn,generateRules:zD,generateCommands:VD,generateAgents:JD,generateSkills:XD,generateMcp:YD,importFrom:QD},lJ={rootInstructionPath:Hn,skillDir:on,managedOutputs:{dirs:[Xo,Zo,Qo,on],files:[Hn,zn]},paths:{rulePath(t){return `${Xo}/${t}.md`},commandPath(t){return `${Zo}/${t}.md`},agentPath(t){return `${Qo}/${t}.md`}}},cJ={rootInstructionPath:Vs,skillDir:Js,managedOutputs:{dirs:[ia,aa,la,Js,eL],files:[Vs,Ys]},rewriteGeneratedPath(t){return t===Hn?Vs:t===zn?Ys:t},mirrorGlobalPath(t,e){return pt(t,Js,e)},paths:{rulePath(t){return `${ia}/${t}.md`},commandPath(t){return `${aa}/${t}.md`},agentPath(t){return `${la}/${t}.md`}}},mN={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Od={id:nn,metadata:{displayName:"OpenCode",category:"cli",officialUrl:"https://opencode.ai",shortDescription:"Open-source terminal AI agent"},generators:aJ,capabilities:mN,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:oN,lint:{hooks:iN,permissions:aN,ignore:lN},project:lJ,globalSupport:{capabilities:mN,detectionPaths:[Vs,ia,aa,la,Js,Ys],layout:cJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Hn],global:[Vs]},canonicalDir:Tm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Xo],global:[ia]},canonicalDir:Tm,extensions:[".md"],map:tN}],commands:{feature:"commands",mode:"directory",source:{project:[Zo],global:[aa]},canonicalDir:Pu,extensions:[".md"],map:eN},agents:{feature:"agents",mode:"directory",source:{project:[Qo],global:[la]},canonicalDir:Tu,extensions:[".md"],map:rN}},buildImportPaths:Hh,detectionPaths:[Xo,Zo,Qo,on,zn,"opencode.jsonc"]};});function pN(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Vn)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:Ir,content:o}]:[]}function uN(t){return rt(t,qt)}function dN(t){return t.commands.map(e=>({path:`${qt}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function fN(t){return t.agents.map(e=>({path:`${qt}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}var gN=d(()=>{tt();Ut();mt();kt();vl();s(pN,"generateRules");s(uN,"generateSkills");s(dN,"generateCommands");s(fN,"generateAgents");});async function hN(t,e={}){let r=e.scope??"project",n=[],o=await B(Vn,t,r);return n.push(...await J(Ad,t,r,{normalize:o})),await q(t,r==="global"?Sr:qt,Vn,n,o),n}var yN=d(()=>{dt();tt();Et();vl();v_();s(hN,"importFromPiAgent");});function _N(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Vn}))}var RN=d(()=>{It();vl();s(_N,"lintRules");});function IN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","pi-agent","Pi Coding Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function SN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","pi-agent","Pi Coding Agent has no dedicated permissions config; canonical permissions are not projected.")]}function CN(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","pi-agent","Pi Coding Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function kN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".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 EN=d(()=>{Lt();s(IN,"lintHooks");s(SN,"lintPermissions");s(CN,"lintIgnore");s(kN,"lintMcp");});var mJ,pJ,uJ,LN,Ad,v_=d(()=>{kt();mt();gN();ee();yN();RN();EN();Vh();vl();mJ={name:Vn,primaryRootInstructionPath:Ir,generateRules:pN,generateCommands:dN,generateAgents:fN,generateSkills:uN,importFrom:hN},pJ={rootInstructionPath:Ir,skillDir:qt,managedOutputs:{dirs:[qt],files:[Ir]},paths:{rulePath(t){return Ir},commandPath(t){return `${qt}/${H(t)}/SKILL.md`},agentPath(t){return `${qt}/${U(t)}/SKILL.md`}}},uJ={rootInstructionPath:qo,skillDir:Sr,managedOutputs:{dirs:[Sr],files:[qo]},rewriteGeneratedPath(t){return t===Ir?qo:t.startsWith(`${qt}/`)?t.replace(`${qt}/`,`${Sr}/`):t},mirrorGlobalPath(t,e){return pt(t,Sr,e)},paths:{rulePath(t){return qo},commandPath(t){return `${Sr}/${H(t)}/SKILL.md`},agentPath(t){return `${Sr}/${U(t)}/SKILL.md`}}},LN={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Ad={id:Vn,metadata:{displayName:"Pi Agent",category:"cli",officialUrl:"https://github.com/pi-labs/pi-agent",shortDescription:"Pi coding agent"},generators:mJ,capabilities:LN,emptyImportMessage:"No Pi Coding Agent config found (AGENTS.md or .pi/skills).",lintRules:_N,lint:{hooks:IN,permissions:SN,ignore:CN,mcp:kN},supportsConversion:{commands:true,agents:true},project:pJ,globalSupport:{capabilities:LN,detectionPaths:[qo],layout:uJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ir],global:[qo]},canonicalDir:oL,canonicalRootFilename:"_root.md",markAsRoot:true}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:zh,detectionPaths:[Ir,qt]};});function ON(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Cr,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes(Jn)));for(let o of n){let i=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=T(a,o.body.trim()||"");e.push({path:`${ts}/${i}.md`,content:l});}return e}function AN(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 n=T(r,e.body.trim()||"");return {path:`${Yn}/${e.name}.md`,content:n}})}function wN(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${Xn}/${e.name}.md`,content:n}})}function bN(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${je}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${je}/${r.name}/${a}`,content:i.content});}}return e}function PN(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Xs,content:e}]}function TN(t){return !t.ignore||t.ignore.length===0?[]:[{path:Zs,content:t.ignore.join(`
141
- `)}]}var xN=d(()=>{j();Ml();s(ON,"generateRules");s(AN,"generateCommands");s(wN,"generateAgents");s(bN,"generateSkills");s(PN,"generateMcp");s(TN,"generateIgnore");});async function DN(t,e={}){let r=e.scope??"project",n=[],o=await B(Jn,t,r);return n.push(...await J(wd,t,r,{normalize:o})),await q(t,r==="global"?Zn:je,Jn,n,o),n}var NN=d(()=>{dt();Et();tt();Ml();M_();s(DN,"importFromQwenCode");});function FN(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Jn}))}var vN=d(()=>{It();Ml();s(FN,"lintRules");});var fJ,gJ,hJ,yJ,_J,wd,M_=d(()=>{xN();NN();vN();Ct();Ml();fJ={name:Jn,primaryRootInstructionPath:Cr,generateRules:ON,generateCommands:AN,generateAgents:wN,generateSkills:bN,generateMcp:PN,generateIgnore:TN,importFrom:DN},gJ={rootInstructionPath:Cr,skillDir:je,managedOutputs:{dirs:[ts,Yn,Xn,je],files:[Cr,Xs,Zs]},paths:{rulePath(t,e){return e.root?Cr:`${ts}/${t}.md`},commandPath(t){return `${Yn}/${t}.md`},agentPath(t){return `${Xn}/${t}.md`}}},hJ={rootInstructionPath:es,skillDir:Zn,managedOutputs:{dirs:[Qs,qs,Zn],files:[es,ma]},rewriteGeneratedPath(t){return t===Cr?es:t===Xs?ma:t===Zs?null:t.startsWith(`${Yn}/`)?t.replace(`${Yn}/`,`${Qs}/`):t.startsWith(`${Xn}/`)?t.replace(`${Xn}/`,`${qs}/`):t.startsWith(`${je}/`)?t.replace(`${je}/`,`${Zn}/`):t.startsWith(`${ts}/`)?null:t},paths:{rulePath(t,e){return es},commandPath(t){return `${Qs}/${t}.md`},agentPath(t){return `${qs}/${t}.md`}}},yJ={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},_J={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},wd={id:Jn,metadata:{displayName:"Qwen Code",category:"cli",officialUrl:"https://github.com/QwenLM/qwen-code",shortDescription:"Alibaba's Qwen coding CLI"},generators:fJ,capabilities:yJ,emptyImportMessage:"No Qwen Code config found (QWEN.md or .qwen/rules, .qwen/commands, .qwen/settings.json).",lintRules:FN,project:gJ,globalSupport:{capabilities:_J,detectionPaths:[es,ma,Qs,qs,Zn],layout:hJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Cr],global:[es]},canonicalDir:Jh,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[ts],global:[]},canonicalDir:Jh,extensions:[".md"],preset:"rule"}],commands:{feature:"commands",mode:"directory",source:{project:[Yn],global:[Qs]},canonicalDir:sL,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[Xn],global:[qs]},canonicalDir:iL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Xs],global:[ma]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/mcp.json"},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Zs],global:[]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/ignore"}},buildImportPaths:Yh,detectionPaths:[Cr,".qwen/settings.json",".qwen/commands",".qwen/rules"]};});function MN(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Qn)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:sn,content:o}]:[]}function $N(t){return rt(t,Ae)}function GN(t){return t.commands.map(e=>({path:`${Ae}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function jN(t){return t.agents.map(e=>({path:`${Ae}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}var UN=d(()=>{tt();Ut();mt();kt();$l();s(MN,"generateRules");s($N,"generateSkills");s(GN,"generateCommands");s(jN,"generateAgents");});async function BN(t,e={}){let r=e.scope??"project",n=[],o=await B(Qn,t,r);return n.push(...await J(bd,t,r,{normalize:o})),await q(t,Ae,Qn,n,o),n}var KN=d(()=>{dt();tt();Et();$l();$_();s(BN,"importFromReplitAgent");});function WN(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Qn}))}var HN=d(()=>{It();$l();s(WN,"lintRules");});function zN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","replit-agent","Replit Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function VN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","replit-agent","Replit Agent permissions are managed in the cloud UI; canonical permissions are not projected.")]}function JN(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","replit-agent","Replit Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function YN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".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 XN=d(()=>{Lt();s(zN,"lintHooks");s(VN,"lintPermissions");s(JN,"lintIgnore");s(YN,"lintMcp");});var RJ,IJ,SJ,bd,$_=d(()=>{kt();mt();UN();KN();HN();XN();Zh();$l();RJ={name:Qn,primaryRootInstructionPath:sn,generateRules:MN,generateCommands:GN,generateAgents:jN,generateSkills:$N,importFrom:BN},IJ={rootInstructionPath:sn,skillDir:Ae,managedOutputs:{dirs:[Ae],files:[sn]},paths:{rulePath(t){return sn},commandPath(t){return `${Ae}/${H(t)}/SKILL.md`},agentPath(t){return `${Ae}/${U(t)}/SKILL.md`}}},SJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},bd={id:Qn,metadata:{displayName:"Replit Agent",category:"agent-platform",officialUrl:"https://replit.com",shortDescription:"Replit's autonomous coding agent"},generators:RJ,capabilities:SJ,emptyImportMessage:"No Replit Agent config found (replit.md or .agents/skills).",lintRules:WN,lint:{hooks:zN,permissions:VN,ignore:JN,mcp:YN},supportsConversion:{commands:true,agents:true},project:IJ,sharedArtifacts:{".agents/skills/":"consumer"},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[sn]},canonicalDir:lL,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:Xh,detectionPaths:[sn]};});function QN(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:an,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(ti))continue;let o=basename(n.source,".md");e.push({path:`${rs}/${o}.md`,content:n.body.trim()||""});}return e}function qN(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${ns}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function tF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Dm,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function eF(t){return t.ignore.length===0?[]:[{path:Nm,content:t.ignore.join(`
142
- `)}]}function rF(t){return rt(t,qn)}function nF(t){if(t.agents.length===0)return [];let e=t.agents.map(r=>{let o={slug:basename(r.source,".md"),name:r.name};return r.description&&(o.description=r.description),r.body.trim()&&(o.roleDefinition=r.body.trim()),o});return [{path:Gl,content:stringify({customModes:e})}]}var oF=d(()=>{tt();j();fa();s(QN,"generateRules");s(qN,"generateCommands");s(tF,"generateMcp");s(eF,"generateIgnore");s(rF,"generateSkills");s(nF,"generateAgents");});var Pd,iF,G_=d(()=>{j();ut();fa();Pd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${da}/${t}`,content:await K(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"rooNonRootRuleMapper"),iF=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Du}/${t}`,content:await _t(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function EJ(t,e,r){let n=join(t,pa),o;try{o=await readdir(n,{withFileTypes:!0});}catch{return}let i=o.filter(l=>l.isDirectory()&&l.name.startsWith("rules-")).map(l=>l.name),a=join(t,da);for(let l of i)e.push(...await Rt({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:ti,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await Pd({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function aF(t,e={}){let r=e.scope??"project",n=[],o=await B(ti,t,r);return n.push(...await J(Td,t,r,{normalize:o})),await EJ(t,n,o),await q(t,qn,ti,n,o),n}var lF=d(()=>{dt();tt();xe();Et();G_();fa();U_();s(EJ,"importPerModeRules");s(aF,"importFromRooCode");});function cF(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ti}))}var mF=d(()=>{It();fa();s(cF,"lintRules");});function PJ(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var wJ,bJ,TJ,xJ,DJ,Td,U_=d(()=>{w();oF();fa();ee();lF();G_();mF();Ct();wJ={name:"roo-code",primaryRootInstructionPath:an,generateRules:QN,generateCommands:qN,generateSkills:rF,generateMcp:tF,generateIgnore:eF,generateAgents:nF,importFrom:aF},bJ={rootInstructionPath:an,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Gl]},paths:{rulePath(t,e){return `${rs}/${t}.md`},commandPath(t,e){return `${ns}/${t}.md`},agentPath(t,e){return null}}};s(PJ,"computeStatus");TJ=s(async(t,e,r,n)=>{if(r!=="global")return [];if(!n.has("agents")||t.agents.length===0)return [];let o=t.agents.map(l=>{let m={slug:basename(l.source,".md"),name:l.name};return l.description&&(m.description=l.description),l.body.trim()&&(m.roleDefinition=l.body.trim()),m}),i=stringify({customModes:o}),a=await _(join(e,Fm));return [{target:"roo-code",path:Fm,content:i,currentContent:a??void 0,status:PJ(a,i)}]},"generateRooGlobalExtras"),xJ={rootInstructionPath:ni,skillDir:os,managedOutputs:{dirs:[ei,ri,os,cL],files:[ni,ua,vm,Fm]},rewriteGeneratedPath(t){return t===an?ni:t===Gl?null:t.startsWith(`${rs}/`)?t.replace(`${rs}/`,`${ei}/`):t.startsWith(`${ns}/`)?t.replace(`${ns}/`,`${ri}/`):t.startsWith(`${qn}/`)?t.replace(`${qn}/`,`${os}/`):t===Dm?ua:t===Nm?vm:t},mirrorGlobalPath(t,e){return pt(t,os,e)},paths:{rulePath(t,e){return `${ei}/${t}.md`},commandPath(t,e){return `${ri}/${t}.md`},agentPath(t,e){return null}}},DJ={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Td={id:"roo-code",metadata:{displayName:"Roo Code",category:"ide",officialUrl:"https://roocode.com",shortDescription:"Open-source AI VS Code extension"},generators:wJ,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:cF,project:bJ,globalSupport:{capabilities:DJ,detectionPaths:[ei,ri,os,ua,vm,ni,Fm],layout:xJ,scopeExtras:TJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[an,xm],global:[ni,an,xm]},canonicalDir:da,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:[rs],global:[ei]},canonicalDir:da,extensions:[".md"],map:Pd}],commands:{feature:"commands",mode:"directory",source:{project:[ns],global:[ri]},canonicalDir:Du,extensions:[".md"],map:iF},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Dm],global:[ua]},canonicalDir:".agentsmesh",canonicalFilename:mL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Nm],global:[vm]},canonicalDir:".agentsmesh",canonicalFilename:pL}},buildImportPaths:Qh,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Gl]};});function pF(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(to)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:kr,content:o}]:[]}function uF(t){return rt(t,te)}function dF(t){return t.commands.map(e=>({path:`${te}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function fF(t){return t.agents.map(e=>({path:`${te}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function gF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ss,content:e}]}var hF=d(()=>{tt();Ut();mt();kt();Ul();s(pF,"generateRules");s(uF,"generateSkills");s(dF,"generateCommands");s(fF,"generateAgents");s(gF,"generateMcp");});async function yF(t,e={}){let r=e.scope??"project",n=[],o=await B(to,t,r);return n.push(...await J(xd,t,r,{normalize:o})),await q(t,r==="global"?Ue:te,to,n,o),n}var _F=d(()=>{dt();tt();Et();Ul();B_();s(yF,"importFromRovodev");});function RF(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:to}))}var IF=d(()=>{It();Ul();s(RF,"lintRules");});function SF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","rovodev","Rovo Dev has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function CF(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","rovodev","Rovo Dev permissions are managed in config.yaml; canonical permissions are not projected.")]}function kF(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","rovodev","Rovo Dev has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var EF=d(()=>{Lt();s(SF,"lintHooks");s(CF,"lintPermissions");s(kF,"lintIgnore");});var NJ,FJ,vJ,MJ,$J,xd,B_=d(()=>{kt();mt();hF();ee();_F();IF();EF();Ct();Ul();NJ={name:to,primaryRootInstructionPath:kr,generateRules:pF,generateCommands:dF,generateAgents:fF,generateSkills:uF,generateMcp:gF,importFrom:yF},FJ={rootInstructionPath:kr,skillDir:te,managedOutputs:{dirs:[te],files:[kr,ss]},paths:{rulePath(t){return kr},commandPath(t){return `${te}/${H(t)}/SKILL.md`},agentPath(t){return `${te}/${U(t)}/SKILL.md`}}},vJ={rootInstructionPath:is,skillDir:Ue,managedOutputs:{dirs:[Ue],files:[is,jl]},rewriteGeneratedPath(t){return t===kr?is:t.startsWith(`${te}/`)?t.replace(`${te}/`,`${Ue}/`):t===ss?jl:t},mirrorGlobalPath(t,e){return pt(t,Ue,e)},paths:{rulePath(t){return is},commandPath(t){return `${Ue}/${H(t)}/SKILL.md`},agentPath(t){return `${Ue}/${U(t)}/SKILL.md`}}},MJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},$J={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},xd={id:to,metadata:{displayName:"Rovo Dev",category:"cli",officialUrl:"https://www.atlassian.com/solutions/devops/rovo-dev",shortDescription:"Atlassian's coding agent"},generators:NJ,capabilities:MJ,emptyImportMessage:"No Rovo Dev config found (AGENTS.md, .rovodev/skills, or .rovodev/mcp.json).",lintRules:RF,lint:{hooks:SF,permissions:CF,ignore:kF},supportsConversion:{commands:true,agents:true},project:FJ,globalSupport:{capabilities:$J,detectionPaths:[fL,is,Ue],layout:vJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[kr],global:[is]},canonicalDir:gL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ss],global:[jl]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:qh,detectionPaths:[kr,te,ss]};});function LF(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Ke,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Er))continue;let o=basename(n.source,".md");e.push({path:`${Be}/${o}.md`,content:n.body.trim()});}return e}function OF(t){return rt(t,Lr)}function AF(t){return t.mcp===null||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ga,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function wF(t){return t.ignore.length===0?[]:[{path:Bl,content:t.ignore.join(`
143
- `)}]}var bF=d(()=>{tt();Kl();s(LF,"generateRules");s(OF,"generateSkills");s(AF,"generateMcp");s(wF,"generateIgnore");});async function UJ(t,e,r,n){let o=n==="global"?[Or,Ke]:[Ke,Or];for(let i of o){let a=join(t,i),l=await _(a);if(l===null)continue;let c=join(t,PF),{frontmatter:m,body:p}=b(r(l,a,c));await O(join(t,$m)),await I(c,await K(c,{...m,root:true},p)),e.push({fromTool:Er,fromPath:a,toPath:PF,feature:"rules"});return}}async function BJ(t,e,r,n){let o=join(t,n==="global"?as:Be),i=join(t,$m);e.push(...await Rt({srcDir:o,destDir:i,extensions:[".md"],fromTool:Er,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=basename(a);if(c==="project_rules.md"||c==="rules.md")return null;let m=join(i,a),{frontmatter:p,body:u}=b(l(m));return {destPath:m,toPath:`${$m}/${a}`,feature:"rules",content:await K(m,{...p,root:false},u)}},"mapEntry")}));}async function TF(t,e={}){let r=e.scope??"project",n=[],o=await B(Er,t,r);return await UJ(t,n,o,r),await BJ(t,n,o,r),n.push(...await J(Dd,t,r,{normalize:o})),await q(t,r==="global"?ln:Lr,Er,n,o),n}var PF,xF=d(()=>{dt();tt();xe();Et();ut();w();j();Kl();K_();PF=`${$m}/_root.md`;s(UJ,"importRoot");s(BJ,"importNonRootRules");s(TF,"importFromTrae");});function DF(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Er}))}var NF=d(()=>{It();Kl();s(DF,"lintRules");});var KJ,WJ,HJ,zJ,Dd,K_=d(()=>{bF();ee();xF();NF();Ct();Kl();KJ={name:Er,primaryRootInstructionPath:Ke,generateRules:LF,generateSkills:OF,generateMcp:AF,generateIgnore:wF,importFrom:TF},WJ={rootInstructionPath:Ke,skillDir:Lr,managedOutputs:{dirs:[Be,Lr],files:[ga,Bl]},paths:{rulePath(t,e){return `${Be}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},HJ={rootInstructionPath:Or,skillDir:ln,managedOutputs:{dirs:[as,ln,yL],files:[Or,Mm]},rewriteGeneratedPath(t){return t===Ke?Or:t.startsWith(`${Be}/`)?t.replace(`${Be}/`,`${as}/`):t.startsWith(`${Lr}/`)?t.replace(`${Lr}/`,`${ln}/`):t===ga?Mm:t===Bl?null:t},mirrorGlobalPath(t,e){return pt(t,ln,e)},paths:{rulePath(t,e){return t==="_root"?Or:`${as}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},zJ={rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Dd={id:Er,metadata:{displayName:"Trae",category:"ide",officialUrl:"https://www.trae.ai",shortDescription:"ByteDance's adaptive AI IDE"},generators:KJ,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:DF,project:WJ,globalSupport:{capabilities:zJ,detectionPaths:[Or,as,ln,Mm],layout:HJ},importer:{mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ga],global:[Mm]},canonicalDir:".agentsmesh",canonicalFilename:_L},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Bl]},canonicalDir:".agentsmesh",canonicalFilename:RL}},buildImportPaths:ty,detectionPaths:[Be,ga,Ke]};});function FF(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(eo)),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:cn,content:o}]:[]}function vF(t){return rt(t,ue)}function MF(t){return t.commands.map(e=>({path:`${ue}/${H(e.name)}/SKILL.md`,content:Nt(e)}))}function $F(t){return t.agents.map(e=>({path:`${ue}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}function GF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:oi,content:e}]}var jF=d(()=>{tt();Ut();mt();kt();Wl();s(FF,"generateRules");s(vF,"generateSkills");s(MF,"generateCommands");s($F,"generateAgents");s(GF,"generateMcp");});async function UF(t,e={}){let r=e.scope??"project",n=[],o=await B(eo,t,r);return n.push(...await J(Nd,t,r,{normalize:o})),await q(t,r==="global"?We:ue,eo,n,o),n}var BF=d(()=>{dt();tt();Et();Wl();W_();s(UF,"importFromWarp");});function KF(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:eo}))}var WF=d(()=>{It();Wl();s(KF,"lintRules");});function HF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function zF(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function VF(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var JF=d(()=>{Lt();s(HF,"lintHooks");s(zF,"lintPermissions");s(VF,"lintIgnore");});var VJ,JJ,YJ,XJ,ZJ,Nd,W_=d(()=>{kt();mt();jF();ee();BF();WF();JF();Ct();Wl();VJ={name:eo,primaryRootInstructionPath:cn,generateRules:FF,generateCommands:MF,generateAgents:$F,generateSkills:vF,generateMcp:GF,importFrom:UF},JJ={rootInstructionPath:cn,skillDir:ue,managedOutputs:{dirs:[ue],files:[cn,oi]},paths:{rulePath(t){return cn},commandPath(t){return `${ue}/${H(t)}/SKILL.md`},agentPath(t){return `${ue}/${U(t)}/SKILL.md`}}},YJ={rootInstructionPath:void 0,skillDir:We,managedOutputs:{dirs:[We],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${ue}/`)?t.replace(`${ue}/`,`${We}/`):t},mirrorGlobalPath(t,e){return pt(t,We,e)},paths:{rulePath(){return null},commandPath(t){return `${We}/${H(t)}/SKILL.md`},agentPath(t){return `${We}/${U(t)}/SKILL.md`}}},XJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ZJ={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Nd={id:eo,metadata:{displayName:"Warp",category:"cli",officialUrl:"https://www.warp.dev",shortDescription:"AI-powered terminal"},generators:VJ,capabilities:XJ,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:KF,lint:{hooks:HF,permissions:zF,ignore:VF},supportsConversion:{commands:true,agents:true},project:JJ,globalSupport:{capabilities:ZJ,detectionPaths:[We],layout:YJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[ey,cn]},canonicalDir:SL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[oi]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:ry,detectionPaths:[cn,ey,oi],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});var mo,H_,ui,YF,ic,po,ac,lc,XF,di,dn,cc,z_,ZF,QF,V_,J_,Y_,mc,pc,Qm,Fd,vd,Md,qF,Se=d(()=>{mo="windsurf",H_=".windsurfrules",ui=".windsurf/rules",YF=".windsurfignore",ic=".codeiumignore",po="AGENTS.md",ac=".windsurf/hooks.json",lc=".windsurf/mcp_config.example.json",XF=".windsurf/mcp_config.json",di=".windsurf/workflows",dn=".windsurf/skills",cc=".agentsmesh/rules",z_=".agentsmesh/commands",ZF=".agentsmesh/agents",QF=".agentsmesh/skills",V_=".agentsmesh/ignore",J_=".agentsmesh/hooks.yaml",Y_=".agentsmesh/mcp.json",mc=".codeium/windsurf/memories/global_rules.md",pc=".codeium/windsurf/skills",Qm=".codeium/windsurf/global_workflows",Fd=".codeium/windsurf/hooks.json",vd=".codeium/windsurf/mcp_config.json",Md=".codeium/.codeiumignore",qF=".agents/skills";});function qJ(t){let e=basename(t,".md");return e==="_root"?"root":e}function tY(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 X_(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:po,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=qJ(n.source),i=n.trigger||(n.globs.length>0?"glob":void 0),a={description:n.description||void 0,trigger:i,glob:n.globs.length===1?n.globs[0]:void 0,globs:n.globs.length>1?n.globs:void 0};Object.keys(a).forEach(m=>{a[m]===void 0&&delete a[m];});let l=Object.keys(a).length>0?T(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${ui}/${o}.md`,content:l});let c=tY(n.globs);c&&(c!==o&&e.push({path:`${ui}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var tv=d(()=>{j();Se();s(qJ,"ruleSlug");s(tY,"directoryScopedRuleDir");s(X_,"generateRules");});function Z_(t){return !t.ignore||t.ignore.length===0?[]:[{path:ic,content:t.ignore.join(`
144
- `)}]}var ev=d(()=>{Se();s(Z_,"generateIgnore");});function Q_(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(o=>{r[o]===void 0&&delete r[o];});let n=Object.keys(r).length>0?T(r,e.body.trim()||""):e.body.trim();return {path:`${di}/${e.name}.md`,content:n}})}var rv=d(()=>{j();Se();s(Q_,"generateCommands");});function q_(t){return t.agents.map(e=>({path:`${dn}/${U(e.name)}/SKILL.md`,content:Tt(e)}))}var nv=d(()=>{mt();Se();s(q_,"generateAgents");});function tR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:lc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var ov=d(()=>{Se();s(tR,"generateMcp");});function eY(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 rY(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Sn(i))continue;let a=zt(i),l=he(i),c=i.type==="prompt"?l||a:a||l;c&&o.push({command:c,show_output:true});}o.length>0&&(e[eY(r)]=o);}return e}function eR(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=rY(t.hooks);return Object.keys(e).length===0?[]:[{path:ac,content:JSON.stringify({hooks:e},null,2)}]}var sv=d(()=>{Mr();Se();s(eY,"windsurfEventName");s(rY,"toWindsurfHooks");s(eR,"generateHooks");});function rR(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=Object.keys(n).length>0?T(n,r.body.trim()||""):r.body.trim()||"";e.push({path:`${dn}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles)e.push({path:`${dn}/${r.name}/${i.relativePath}`,content:i.content});}return e}var iv=d(()=>{j();Se();s(rR,"generateSkills");});var av=d(()=>{tv();ev();rv();nv();ov();sv();iv();});var lv=d(()=>{av();});function cv(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 mv(t,e,r){let n=join(t,di),i=(await v(n)).filter(l=>l.endsWith(".md")),a=join(t,z_);for(let l of i){let c=await _(l);if(!c)continue;let m=relative(n,l).replace(/\\/g,"/");await O(a);let p=join(a,m),u=r(c,l,p),{frontmatter:f,body:g}=b(u),h=await _t(p,{description:typeof f.description=="string"?f.description:"",hasDescription:Object.prototype.hasOwnProperty.call(f,"description"),allowedTools:(()=>{let R=cv(f.allowedTools);return R.length>0?R:cv(f["allowed-tools"])})(),hasAllowedTools:Object.prototype.hasOwnProperty.call(f,"allowedTools")||Object.prototype.hasOwnProperty.call(f,"allowed-tools")},g);await I(p,h),e.push({fromTool:mo,fromPath:l,toPath:`${z_}/${m}`,feature:"commands"});}}var pv=d(()=>{w();j();ut();Se();s(cv,"toStringArray");s(mv,"importWorkflows");});async function uv(t,e,r,n=dn){await Vl([n],{projectRoot:t,destCanonicalSkillsDir:QF,targetName:"windsurf",normalize:r,results:e},[Jl({canonicalAgentsDir:ZF})]);}var dv=d(()=>{Yl();Se();s(uv,"importSkills");});async function gv(t,e){let r=join(t,ac),n=await _(r);if(n)try{let o=JSON.parse(n);if(!o.hooks||typeof o.hooks!="object"||Array.isArray(o.hooks))return;let i=iY(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,J_);await O(dirname(a)),await I(a,stringify(i)),e.push({fromTool:mo,fromPath:r,toPath:J_,feature:"hooks"});}catch{}}function sY(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 iY(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=sY(r),i=[];for(let a of n){if(!a||typeof a!="object")continue;let l=a;if(typeof l.command=="string"&&l.command.trim()){i.push({matcher:".*",type:"command",command:l.command});continue}let c=typeof l.matcher=="string"&&l.matcher.trim()?l.matcher:".*",m=Array.isArray(l.hooks)?l.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let u=p,f=typeof u.command=="string"?u.command:typeof u.prompt=="string"?u.prompt:"";if(!f.trim())continue;let g={matcher:c,type:u.type==="prompt"?"prompt":"command",command:f};typeof u.timeout=="number"&&(g.timeout=u.timeout),i.push(g);}}i.length>0&&(e[o]=i);}return e}async function hv(t,e){let r=[lc,XF];for(let n of r){let o=join(t,n),i=await _(o);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let l=join(t,Y_);await O(dirname(l)),await I(l,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:mo,fromPath:o,toPath:Y_,feature:"mcp"});return}catch{}}}var yv=d(()=>{w();Se();s(gv,"importWindsurfHooks");s(sY,"canonicalHookEventName");s(iY,"windsurfHooksToCanonical");s(hv,"importWindsurfMcp");});async function _v(t,e){let r=e?.scope??"project",n=[],o=await B(mo,t),i=await B("codex-cli",t),a=join(t,cc),l=join(t,H_),c=await _(l);if(c!==null){await O(a);let f=join(a,"_root.md"),g=o(c,l,f).trim(),h=await K(f,{root:true},g);await I(f,h),n.push({fromTool:"windsurf",fromPath:l,toPath:`${cc}/_root.md`,feature:"rules"});}if(c===null){let f=join(t,po),g=await _(f);if(g!==null){await O(a);let h=join(a,"_root.md"),R=o(i(g,f,h),f,h).trim(),C=await K(h,{root:true},R);await I(h,C),n.push({fromTool:"windsurf",fromPath:f,toPath:`${cc}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await Rt({srcDir:t,destDir:a,extensions:["AGENTS.md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({srcPath:f,normalizeTo:g})=>{let h=relative(t,dirname(f)).replace(/\\/g,"/");if(!h||h==="."||basename(f)!=="AGENTS.md")return null;let R=h.replace(/\//g,"-");if(!eu(h))return await kn(join(a,`${R}.md`)),null;let C=join(a,`${R}.md`);return {destPath:C,toPath:`${cc}/${R}.md`,feature:"rules",content:await K(C,{root:false,globs:[`${h}/**`]},g(C))}},"mapEntry")}));let m=join(t,ui);n.push(...await Rt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({relativePath:f,normalizeTo:g})=>{if(f==="_root.md"&&c!==null)return null;let h=join(a,f),{frontmatter:R,body:C}=b(g(h)),S={...R};return typeof S.glob=="string"&&S.glob.trim()&&(S.globs=[S.glob],delete S.glob),{destPath:h,toPath:`${cc}/${f}`,feature:"rules",content:await K(h,{...S,root:false},C)}},"mapEntry")}));let p=join(t,YF),u=await _(p);if((u===null||!u.trim())&&(p=join(t,ic),u=await _(p)),u!==null&&u.trim()){let f=u.split(/\r?\n/),g=[];for(let h of f){let R=h.trim();R&&!R.startsWith("#")&&g.push(R);}if(g.length>0){await O(join(t,".agentsmesh"));let h=join(t,V_);await I(h,g.join(`
145
- `)),n.push({fromTool:"windsurf",fromPath:p,toPath:V_,feature:"ignore"});}}return await mv(t,n,o),await uv(t,n,o),await gv(t,n),await hv(t,n),n}var Rv=d(()=>{dt();w();j();ut();xe();Qc();Se();pv();dv();yv();s(_v,"importFromWindsurf");});function Iv(t,e,r){let n=[],{rules:o}=t;o.length>0&&(o.some(l=>l.root)||n.push({level:"warning",file:relative(e,o[0].source),target:mo,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&&n.push({level:"warning",file:".agentsmesh",target:mo,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),n}var Sv=d(()=>{Se();s(Iv,"lintRules");});function Cv(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>x(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function kv(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var Ev=d(()=>{Lt();s(Cv,"lintCommands");s(kv,"lintMcp");});function pY(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 uY,dY,fY,gY,Lv,Ov=d(()=>{lv();wi();Se();ee();Rv();Sv();Ev();Ct();ol();mt();s(pY,"directoryScopedRuleDir");uY={name:"windsurf",primaryRootInstructionPath:po,generateRules:X_,generateCommands:Q_,generateAgents:q_,generateSkills:rR,generateMcp:tR,generateHooks:eR,generateIgnore:Z_,importFrom:_v},dY={rootInstructionPath:po,extraRuleOutputPaths(t){if(t.root)return [po];let e=pY(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:dn,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 `${ui}/${t}.md`},commandPath(t,e){return `${di}/${t}.md`},agentPath(t,e){return qe(e,"windsurf")?`.windsurf/skills/${U(t)}/SKILL.md`:null}}},fY={rootInstructionPath:mc,skillDir:pc,managedOutputs:{dirs:[pc,Qm,qF],files:[mc,Fd,vd,Md]},rewriteGeneratedPath(t){return t===po?mc:t.startsWith(`${ui}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${dn}/`)?t.replace(`${dn}/`,`${pc}/`):t.startsWith(`${di}/`)?t.replace(`${di}/`,`${Qm}/`):t===ac?Fd:t===lc?vd:t===ic?Md:t},mirrorGlobalPath(t,e){return pt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return mc},commandPath(t,e){return `${Qm}/${t}.md`},agentPath(t,e){return qe(e,"windsurf")?`${pc}/${U(t)}/SKILL.md`:null}}},gY={rules:"native",additionalRules:"partial",commands:Gr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},Lv={id:"windsurf",metadata:{displayName:"Windsurf",category:"ide",officialUrl:"https://windsurf.com",shortDescription:"Codeium's agentic IDE"},generators:uY,capabilities:{rules:"native",additionalRules:"native",commands:Gr("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:Iv,lint:{commands:Cv,mcp:kv},project:dY,globalSupport:{capabilities:gY,detectionPaths:[mc,pc,Qm,Fd,vd,Md],layout:fY},buildImportPaths:ny,detectionPaths:[".windsurfrules",".windsurf"],conversionDefaults:{agentsToSkills:true}};});function Av(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")),n=e?.body.trim()??"",o=lt(n,r);return o?[{path:mn,content:o}]:[]}var wv=d(()=>{Ut();ha();s(Av,"generateRules");});async function Pv(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let a=o.context_servers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,l[c]=p;}Object.keys(l).length!==0&&(await Bt(t,bv,l),r.push({fromTool:"zed",fromPath:e,toPath:bv,feature:"mcp"}));}var bv,Tv=d(()=>{w();Kr();ha();bv=".agentsmesh/mcp.json";s(Pv,"importZedMcp");});async function xv(t,e={}){let r=e.scope??"project",n=[],o=await B("zed",t,r);return n.push(...await J(Gd,t,r,{normalize:o})),await Pv(t,r==="global"?no:ro,n),n}var Dv=d(()=>{dt();Et();Tv();ha();oR();s(xv,"importFromZed");});function Nv(t,e,r,n){return V(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var Fv=d(()=>{It();ha();s(Nv,"lintRules");});function vv(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Mv(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function $v(t){return t.ignore.length===0?[]:[x(".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 Gv=d(()=>{Lt();s(vv,"lintHooks");s(Mv,"lintPermissions");s($v,"lintIgnore");});function CY(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 n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o.context_servers!==void 0&&(r.context_servers=o.context_servers),JSON.stringify(r,null,2)}var yY,_Y,RY,IY,SY,Gd,oR=d(()=>{wv();Dv();Fv();Gv();Ct();ha();yY={name:"zed",primaryRootInstructionPath:mn,generateRules:Av,importFrom:xv},_Y={rootInstructionPath:mn,managedOutputs:{dirs:[],files:[mn,ro]},paths:{rulePath(t){return mn},commandPath(){return null},agentPath(){return null}}},RY={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[no]},rewriteGeneratedPath(t){return t===ro?no:t},paths:{rulePath(){return no},commandPath(){return null},agentPath(){return null}}},IY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},SY={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(CY,"mergeZedSettings");Gd={id:"zed",metadata:{displayName:"Zed",category:"ide",officialUrl:"https://zed.dev",shortDescription:"Collaborative AI editor"},generators:yY,capabilities:IY,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:Nv,lint:{hooks:vv,permissions:Mv,ignore:$v},project:_Y,globalSupport:{capabilities:SY,detectionPaths:[no],layout:RY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[mn],global:[]},canonicalDir:EL,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let r={};for(let[n,o]of Object.entries(t.mcp.mcpServers))r[n]=o;return [{path:ro,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===ro||n===no?CY(t,r):null},buildImportPaths:oy,detectionPaths:[mn,ro]};});var tE={};og(tE,{BUILTIN_TARGETS:()=>bt,TARGET_IDS:()=>Ft,getBuiltinTargetDefinition:()=>Pr,getEffectiveTargetSupportLevel:()=>jd,getTargetCapabilities:()=>mi,getTargetDetectionPaths:()=>iR,getTargetLayout:()=>Gt,getTargetManagedOutputs:()=>aR,getTargetPrimaryRootInstructionPath:()=>EY,getTargetSkillDir:()=>qm,isBuiltinTargetId:()=>Pe,resolveTargetFeatureGenerator:()=>uc,rewriteGeneratedOutputPath:()=>lR});function kY(){return sR||(NC(bt),sR=new Map(bt.map(t=>[t.id,t]))),sR}function Pr(t){return kY().get(t)}function mi(t,e="project"){let r=Pr(t)??et(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return xC(n)}function iR(t,e="project"){let r=Pr(t)??et(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function Gt(t,e="project"){let r=Pr(t)??et(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function EY(t,e="project"){return Gt(t,e)?.rootInstructionPath}function qm(t,e="project"){return Gt(t,e)?.skillDir}function aR(t,e="project"){return Gt(t,e)?.managedOutputs}function lR(t,e,r="project"){let n=Gt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function jv(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!nl(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!qe(r,t.id,true,n):false}function LY(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?nl(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?qe(r,t.id,true,n):false}function jd(t,e,r,n="project"){let o=mi(t,n)?.[e]?.level??"none",i=Pr(t)??et(t);return o==="none"&&LY(i,e,r,n)?"embedded":o!=="embedded"?o:jv(i,e,r,n)?"none":o}function uc(t,e,r,n="project"){let o=Pr(t)??et(t);if(!o?.generators||jv(o,e,r,n))return;let i=OY[e];return i===null?void 0:i(o.generators)}var bt,sR,OY,Pt=d(()=>{ol();wi();se();Ng();Rn();Qg();sy();iy();ly();DO();py();VA();Mw();xy();$y();jy();e_();r_();n_();C_();k_();E_();L_();P_();x_();N_();v_();M_();$_();U_();B_();K_();W_();Ov();oR();bt=[su,Fu,vu,Mu,xO,$u,zA,vw,Hu,Zu,qu,ld,cd,md,_d,Rd,Id,Sd,Ed,Ld,Od,Ad,wd,bd,Td,xd,Dd,Nd,Lv,Gd];s(kY,"builtinTargetsMap");s(Pr,"getBuiltinTargetDefinition");s(mi,"getTargetCapabilities");s(iR,"getTargetDetectionPaths");s(Gt,"getTargetLayout");s(EY,"getTargetPrimaryRootInstructionPath");s(qm,"getTargetSkillDir");s(aR,"getTargetManagedOutputs");s(lR,"rewriteGeneratedOutputPath");s(jv,"isFeatureSuppressedByConversion");s(LY,"isConversionUpgrading");s(jd,"getEffectiveTargetSupportLevel");OY={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(uc,"resolveTargetFeatureGenerator");});function bY(t,e){return t.uniqueHits!==e.uniqueHits?e.uniqueHits-t.uniqueHits:t.sharedScore!==e.sharedScore?e.sharedScore-t.sharedScore:t.id.localeCompare(e.id)}async function Ud(t){let e=[];for(let n of bt){let o=0,i=0;for(let a of n.detectionPaths){if(!await $(join(t,a)))continue;let l=wY.get(a)??1;l===1?o+=1:i+=1/l;}(o>0||i>0)&&e.push({id:n.id,uniqueHits:o,sharedScore:i});}if(e.length===0)return null;e.sort(bY);let r=e[0];return r.uniqueHits===0?null:r.id}var wY,Uv,cR=d(()=>{w();Pt();wY=(()=>{let t=new Map;for(let e of bt)for(let r of e.detectionPaths)t.set(r,(t.get(r)??0)+1);return t})();s(bY,"compare");s(Ud,"detectNativeFormat");Uv=bt.map(t=>t.detectionPaths[0]).filter(t=>t!==void 0);});async function tp(t,e){let r=et(e);if(!r)throw new Error(`No importer registered for native target: ${e}`);return r.generators.importFrom(t)}var mR=d(()=>{se();s(tp,"importNativeToCanonical");});async function Pa(t){if(!await $(t))return false;if(await $(join(t,uR)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await $(join(t,r.name,uR)))return !0}catch{return false}return false}async function ep(t,e={}){if(!await $(t))return [];if(await $(join(t,uR))){let r=await Bp(t,e);return r?[r]:[]}return Ls(t,e)}var uR,Bd=d(()=>{w();el();uR="SKILL.md";s(Pa,"isSkillPackLayout");s(ep,"loadSkillsAtExtendPath");});async function Kd(t,e={}){return (await Es(t,e)).filter(n=>!In(basename(n.source)))}async function Wd(t,e={}){return (await ks(t,e)).filter(n=>!In(basename(n.source)))}async function Hd(t,e={}){return (await Cs(t,e)).filter(n=>!In(basename(n.source)))}async function Bv(t,e={}){return Ls(t,e)}var zd=d(()=>{Hc();Wc();Kc();el();Co();s(Kd,"importAgents");s(Wd,"importCommands");s(Hd,"importRules");s(Bv,"importSkills");});function fR(t,e){let r=t?.[e];if(!r)return [];let n=Array.isArray(r)?r:[r],o=[];for(let i of n)i.mode!=="directory"||!i.map||!i.extensions||o.push({extensions:i.extensions,map:i.map});return o}function gR(t){return t.toLowerCase().endsWith(".md")}function Wv(t,e){for(let r of fR(et(t)?.importer,e))if(r.extensions.some(n=>!gR(n)))return true;return false}function MY(t,e){let r=new Set;for(let n of fR(et(t)?.importer,e))for(let o of n.extensions)gR(o)||r.add(o.toLowerCase());return r}function $Y(t){return bC().filter(e=>Wv(e,t))}async function UY(t,e,r){return GY[t](e,r)}async function BY(t,e,r){return jY[t](e,r)}async function KY(t,e,r,n={}){let o=fR(et(e)?.importer,r),i=await v(t),a=new Set;for(let p of o)for(let u of p.extensions)gR(u)||a.add(u.toLowerCase());let l=i.filter(p=>[...a].some(u=>p.toLowerCase().endsWith(u))&&!In(basename(p)));if(l.length===0)return {entities:[],cleanup:s(async()=>{},"cleanup")};let c=await mkdtemp(join(tmpdir(),`am-tool-${r}-${e}-`)),m=s(async()=>{await rm(c,{recursive:true,force:true});},"cleanup");try{for(let u of l){let f=await _(u);if(f===null)continue;let g=relative(t,u).replaceAll("\\","/"),h=null;for(let R of o){if(!R.extensions.some(k=>u.toLowerCase().endsWith(k.toLowerCase())))continue;let S=await R.map({absolutePath:u,relativePath:g,content:f,destDir:c,normalizeTo:s(()=>f,"normalizeTo")});if(S){h=S;break}}h&&(await O(dirname(h.destPath)),await I(h.destPath,h.content));}return {entities:await UY(r,c,n),cleanup:m}}catch(p){throw await m(),p}}async function hR(t,e,r={}){let n=r.restrictToTarget,o=n?Wv(n,e)?[n]:[]:$Y(e),i=new Set;for(let f of o)for(let g of MY(f,e))i.add(g);let a=await BY(e,t,{...r.parseOpts,handledByOtherReader:i.size>0?i:void 0}),l=[],c=s(f=>basename(f.source).replace(/\.[^.]+$/,""),"slugOf"),m=new Map;for(let f of a)m.set(c(f),f);for(let f of o){let g=await KY(t,f,e,r.parseOpts??{});l.push(g.cleanup);for(let h of g.entities){let R=c(h);m.has(R)||m.set(R,h);}}return {entities:[...m.values()].sort((f,g)=>c(f).localeCompare(c(g))),cleanup:s(async()=>{await Promise.allSettled(l.map(f=>f()));},"cleanup")}}async function Vd(t,e={}){let r=await hR(t,"commands",e);return {commands:[...r.entities],cleanup:r.cleanup}}async function Jd(t,e={}){let r=await hR(t,"rules",e);return {rules:[...r.entities],cleanup:r.cleanup}}async function Yd(t,e={}){let r=await hR(t,"agents",e);return {agents:[...r.entities],cleanup:r.cleanup}}var GY,jY,Xd=d(()=>{Hc();Wc();Kc();w();se();Co();zd();s(fR,"directorySpecsFor");s(gR,"isMarkdownExtension");s(Wv,"hasNonMdEntityMapper");s(MY,"nonMdEntityExtensions");s($Y,"targetsWithNonMdEntityMapper");GY={rules:Cs,commands:ks,agents:Es},jY={rules:Hd,commands:Wd,agents:Kd};s(UY,"parseEntityDir");s(BY,"importEntities");s(KY,"readToolNativeEntities");s(hR,"readEntityDirWithMappers");s(Vd,"readCommandsDirWithMappers");s(Jd,"readRulesDirWithMappers");s(Yd,"readAgentsDirWithMappers");});function zY(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function VY(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 Zd(t){if(!await $(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),n=basename(r),i=basename(t).replace(/\.md$/i,"");if(n==="rules")return {sliceRoot:r,implicitPick:{rules:[i]}};if(n==="commands")return {sliceRoot:r,implicitPick:{commands:[i]}};if(n==="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 RR(t,e){if(basename(t)===e)return t;let r=join(t,e);return await $(r)?r:null}async function JY(t,e,r){let n=s(async()=>{},"noop"),o=await RR(t,"rules");if(!o)return {rules:[],cleanup:n};if(!r)return {rules:await Hd(o,e),cleanup:n};let i=await Jd(o,{parseOpts:e});return {rules:[...i.rules],cleanup:i.cleanup}}async function YY(t,e,r){let n=s(async()=>{},"noop"),o=await RR(t,"commands");if(!o)return {commands:[],cleanup:n};if(!r)return {commands:await Wd(o,e),cleanup:n};let i=await Vd(o,{parseOpts:e});return {commands:[...i.commands],cleanup:i.cleanup}}async function XY(t,e,r){let n=s(async()=>{},"noop"),o=await RR(t,"agents");if(!o)return {agents:[],cleanup:n};if(!r)return {agents:await Kd(o,e),cleanup:n};let i=await Yd(o,{parseOpts:e});return {agents:[...i.agents],cleanup:i.cleanup}}async function ZY(t,e){if(await Pa(t))return ep(t,e);let r=join(t,"skills");return await Pa(r)?ep(r,e):[]}async function Qd(t,e={}){let r=s(async()=>{},"noop"),n=join(t,".agentsmesh");if(await $(n))return {canonical:await Ee(t,e),cleanup:r};let o=e.enableTargetEntityMappers??false,i=zY(),a=await JY(t,e,o);i.rules=a.rules;let l=await YY(t,e,o);i.commands=l.commands;let c=await XY(t,e,o);i.agents=c.agents,i.skills=await ZY(t,e);let m=s(async()=>{await Promise.allSettled([a.cleanup(),l.cleanup(),c.cleanup()]);},"mergedCleanup");if(VY(i))throw await m(),new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md). Hint: pass --as commands|agents|rules|skills to force a kind for flat markdown directories.`);return {canonical:i,cleanup:m}}var IR=d(()=>{w();zd();Xd();Ai();Bd();s(zY,"emptyCanonical");s(VY,"isCanonicalSliceEmpty");s(Zd,"normalizeSlicePath");s(RR,"resolveEntityDir");s(JY,"parseRulesAt");s(YY,"parseCommandsAt");s(XY,"parseAgentsAt");s(ZY,"loadSkillsForPartialSlice");s(Qd,"loadCanonicalSliceAtPath");});async function qd(t){let e=await _(t);if(!e)return "";let r=Fr(e,t);if(!r.ok)return "";let{frontmatter:n}=r.value;return typeof n.name!="string"?"":n.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function Hv(t,e){await cp$1(t,e,{recursive:true,filter:s(r=>{let n=relative(t,r).replace(/\\/g,"/");if(n==="")return true;let o=n.split("/")[0];return !(_C(o)||!n.includes("/")&&(jp(n)||RC(n)))},"filter")});}var SR=d(()=>{w();j();Co();s(qd,"readSkillFrontmatterName");s(Hv,"cpFilteredSkill");});function CR(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function tX(t){let e={...t},r=t.alwaysApply===true;if(e.root=r,delete e.alwaysApply,!r){let n=CR(t.globs),o=typeof t.description=="string"?t.description.trim():"";n.length>0?e.trigger="glob":o.length>0?e.trigger="model_decision":e.trigger="manual";}return e}function eX(t){let e={...t};return e.trigger==="always"&&(e.trigger="always_on"),typeof e.glob=="string"&&(e.globs=CR(e.globs).length>0?CR(e.globs):[e.glob],delete e.glob),e}function kR(t){let e=Fr(t,"<mdc>");if(!e.ok)return e.bodyFallback;let{frontmatter:r,body:n}=e.value;if(Object.keys(r).length===0&&!t.startsWith("---"))return t;let o;return "alwaysApply"in r?o=tX(r):"trigger"in r||"glob"in r?o=eX(r):o=r,T(o,n.trim())}var zv=d(()=>{j();s(CR,"toStrArray");s(tX,"normalizeCursorKeys");s(eX,"normalizeWindsurfKeys");s(kR,"normalizeMdcToCanonical");});function ER(t){return t.toLowerCase().replace(/[^a-z0-9.-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function LR(t){return t.toLowerCase().endsWith(".mdc")?basename(t).replace(/\.mdc$/i,".md"):basename(t)}function Jv(t,e,r){let o=relative(t,e).replace(/\\/g,"/").split("/");if(o.pop(),o.length===0)return r;let i=ER(o[o.length-1]);return i?`${i}-${r}`:r}var Yv=d(()=>{s(ER,"sanitizeNameSegment");s(LR,"computeDestName");s(Jv,"namespacedName");});async function iX(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await O(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:s(async()=>{await rm(t,{recursive:true,force:true});},"cleanup")}}function qv(t,e){let r=t.toLowerCase();return !!(r.endsWith(".md")||e&&r.endsWith(".mdc"))}async function aX(t,e,r){if(!qv(t,r))throw new Error(`Manual install only supports .md files for this collection: ${t}`);if(await O(e),t.toLowerCase().endsWith(".mdc")){let n=await _(t);if(!n)return;let o=basename(t).replace(/\.mdc$/i,".md");await writeFile(join(e,o),kR(n));}else await cp$1(t,join(e,basename(t)));}async function lX(t,e,r){if((await stat(t)).isFile())return aX(t,e,r);let o=(await v(t)).filter(l=>qv(l,r)&&!In(basename(l)));if(o.length===0)throw new Error(`No installable files found under ${t} for manual install. Try a different --path to point at the directory holding *.md (or *.mdc) files, or omit --as so agentsmesh can auto-detect the layout.`);let i=new Map;for(let l of o){let c=LR(l);i.set(c,(i.get(c)??0)+1);}let a=new Map;await O(e);for(let l of o){let c=LR(l),p=(i.get(c)??0)>1?Jv(t,l,c):c;if(a.has(p)&&a.get(p)!==l){let f=relative(t,l).replace(/\\/g,"/").split("/").map(ER).filter(Boolean),g=c.includes(".")?"."+c.split(".").pop():"";p=f.join("-").replace(/\.(md|mdc)$/i,"")+g||p;}if(a.has(p))throw new Error(`Manual install could not resolve duplicate name "${p}" under ${t} (${a.get(p)} and ${l}).`);if(a.set(p,l),l.toLowerCase().endsWith(".mdc")){let f=await _(l);if(!f)continue;await writeFile(join(e,p),kR(f));}else await cp$1(l,join(e,p));}}async function Xv(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await v(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),l=basename(a);if(!n.has(l))continue;let c=o.get(l);if(c&&c!==a)throw new Error(`Manual skill replay found duplicate skill "${l}" under ${t} (${c} and ${a}).`);o.set(l,a);}if(o.size!==r.length)return false;await O(e);for(let i of r)await cp$1(o.get(i),join(e,i),{recursive:true});return true}async function cX(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 o=basename(dirname(t)),i=join(e,o);await O(i),await cp$1(dirname(t),i,{recursive:true});return}if(await Pa(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await Xv(t,e,r.preferredSkillNames??[]))return;let l=await qd(join(t,"SKILL.md"))||basename(t),c=join(e,l);await O(e),await Hv(t,c);return}if(await Xv(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await v(t),i=new Set;for(let a of o.filter(l=>l.endsWith("/SKILL.md")||l.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}.`)}async function ef(t,e,r={}){let n=await iX();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await cX(t,o,r):await lX(t,o,e==="rules"),n}catch(o){throw await n.cleanup(),o}}var AR=d(()=>{w();Bd();SR();Co();zv();Yv();s(iX,"createStageRoot");s(qv,"isAcceptedFile");s(aX,"stageSingleFile");s(lX,"stageMarkdownCollection");s(Xv,"stagePreferredSkills");s(cX,"stageSkills");s(ef,"stageManualInstallScope");});function mX(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function tM(t){let e=t.resolvedPath;if(t.as!==void 0){let o=t.path?join(e,t.path):e;if(!await $(o))throw new Error(`Extend "${t.name}": path does not exist: ${o}`);let i=await ef(o,t.as);try{return Ee(join(i.discoveryRoot,".agentsmesh"))}finally{await i.cleanup();}}if(!t.path){let o=join(e,".agentsmesh");if(!await $(o)){if(await Pa(e)){let a=await ep(e);return {...mX(),skills:a}}let i=t.target??await Ud(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
146
- Expected one of: .agentsmesh/, ${Uv.join(", ")}.`);y.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await tp(e,i);}return Ee(e)}let r=join(e,t.path);if(!await $(r))throw new Error(`Extend "${t.name}": path does not exist: ${r}`);if(t.target){let o=join(e,".agentsmesh");return await $(o)||(y.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await tp(e,t.target)),Ee(e)}let{sliceRoot:n}=await Zd(r);try{let{canonical:o}=await Qd(n);return o}catch(o){let i=o instanceof Error?o.message:String(o),a=new Error(`Extend "${t.name}": ${i}`);throw o instanceof Error&&(a.cause=o),a}}var eM=d(()=>{cR();w();ot();Ai();mR();Bd();IR();AR();s(mX,"emptyCanonical");s(tM,"loadCanonicalForExtend");});function rf(t,e,r,n){if(!r)return t;let o={...t};if(r.skills?.length&&e.includes("skills")){let i=new Set(r.skills),a=o.skills;o={...o,skills:a.filter(l=>i.has(l.name))};for(let l of r.skills)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in skills from extend "${n}".`);}if(r.commands?.length&&e.includes("commands")){let i=new Set(r.commands),a=o.commands;o={...o,commands:a.filter(l=>i.has(l.name))};for(let l of r.commands)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in commands from extend "${n}".`);}if(r.agents?.length&&e.includes("agents")){let i=new Set(r.agents),a=o.agents;o={...o,agents:a.filter(l=>i.has(l.name))};for(let l of r.agents)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in agents from extend "${n}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=o.rules,l=s(c=>basename(c).replace(/\.md$/i,""),"stem");o={...o,rules:a.filter(c=>i.has(l(c.source)))};for(let c of r.rules)a.some(m=>l(m.source)===c)||y.warn(`[agentsmesh] pick name "${c}" not found in rules from extend "${n}".`);}return o}var wR=d(()=>{ot();s(rf,"applyExtendPick");});var dX,dc,nf=d(()=>{dX=["rules","commands","agents","skills"],dc=z.enum(dX);});var fX,rM,nM=d(()=>{Ro();nf();fX=z.enum(["github","gitlab","git","local"]),rM=z.object({name:z.string().min(1),source:z.string().min(1),version:z.string().optional(),source_kind:fX,installed_at:z.string(),updated_at:z.string(),features:z.array(Xa).min(1),pick:Mc.optional(),target:Qe.optional(),path:z.string().optional(),paths:z.array(z.string().min(1)).min(1).optional(),as:dc.optional(),content_hash:z.string(),license:z.string().nullable().optional()});});function oM(t){let e=Li(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 hX(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}async function fi(t){let e=join(t,"pack.yaml"),r=await _(e);if(r===null)return null;try{let n=parse(r);return rM.parse(n)}catch{return null}}async function iM(t,e,r){if(!await $(t))return null;let n=oM(e),o;try{o=await readdir(t,{withFileTypes:!0});}catch{return null}for(let i of o){if(!i.isDirectory())continue;let a=join(t,i.name),l=await fi(a);if(l&&oM(l.source)===n&&l.target===r.target&&l.as===r.as&&hX(l.features,r.features))return {meta:l,packDir:a,name:l.name}}return null}async function of(t){if(!await $(t))return [];let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory())continue;let o=join(t,n.name),i=await fi(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}var fc=d(()=>{w();nM();jc();s(oM,"sourceIdentity");s(hX,"sameFeatures");s(fi,"readPackMetadata");s(iM,"findExistingPack");s(of,"listPacks");});function aM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function yX(t){let[e,r,n,o,i,a,l,c]=await Promise.all([Cs(join(t,"rules")),ks(join(t,"commands")),Es(join(t,"agents")),Ls(join(t,"skills")),vr(join(t,"mcp.json")),Kp(join(t,"permissions.yaml")),Wp(join(t,"hooks.yaml")),Hp(join(t,"ignore"))]);return {...aM(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:l,ignore:c}}async function lM(t){let e=join(t,"packs"),r=await of(e),n=aM();for(let{meta:o,packDir:i}of r){let a=await yX(i),l=PR(a,o.features),c=rf(l,o.features,o.pick,o.name);n=rl(n,c);}return n}var cM=d(()=>{Kc();Wc();Hc();el();zc();Og();wg();bg();Tg();fo();wR();fc();s(aM,"emptyCanonical");s(yX,"loadPackCanonical");s(lM,"loadPacksCanonical");});function PR(t,e){if(e.length===0)return mM();let r=new Set(e.flatMap(n=>RX[n]??[]));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 mM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function ke(t,e,r={},n=join(e,".agentsmesh")){let o=await qa(t,e,{refreshCache:r.refreshRemoteCache===true}),i=mM();for(let c of o){let m=await tM(c),p=PR(m,c.features),u=rf(p,c.features,c.pick,c.name);i=rl(i,u);}let a=await lM(n);i=rl(i,a);let l=await Ee(n);return i=rl(i,l),{canonical:i,resolvedExtends:o}}var RX,fo=d(()=>{Fp();Ai();Tg();eM();wR();cM();RX={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(PR,"filterCanonicalByFeatures");s(mM,"emptyCanonical");s(ke,"loadCanonicalWithExtends");});function h2(t,e){let r=join(e,"node_modules",t),n=join(r,"package.json");if(!existsSync(n))throw new Error(`Cannot find package '${t}' in ${join(e,"node_modules")}`);let o=JSON.parse(readFileSync(n,"utf-8")),i=(typeof o.exports=="string"?o.exports:null)??(typeof o.main=="string"?o.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 y2(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}function KM(t){try{return realpathSync(t)}catch{return t}}function WM(t,e){let r=KM(resolve(e)),n=KM(t);if(!(n===r||n.startsWith(`${r}${sep}`)))throw new Error(`Plugin source resolves outside project root (escapes ${r}): ${n}`)}async function _2(t,e){let{source:r}=t,n;if(y2(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);WM(a,e),n=pathToFileURL(a).href;}else {let i=h2(r,e);WM(i,e),n=pathToFileURL(i).href;}return await import(n)}function R2(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function _f(t,e){let r;try{r=await _2(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=R2(r),o=[];for(let i of n)try{let a=zp(i);Jp(a),o.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:o}}async function HM(t,e){let r=[],n=process.env.AGENTSMESH_STRICT_PLUGINS==="1"||process.env.AGENTSMESH_STRICT_PLUGINS==="true",i=(await Promise.all(t.map(async a=>{try{let l=await _f(a,e);return r.push(l),null}catch(l){let c=`Plugin '${a.source}' failed to load: ${l instanceof Error?l.message:String(l)}`;return a.strict===true||n?new Error(c):(y.warn(c),null)}}))).filter(a=>a!==null);if(i.length>0){let a=i.map(l=>` - ${l.message}`).join(`
141
+ ${f}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let I=await Jt(m,h,g),k=r(I,n,m);await S(m,k),e.push({feature:"agents",fromTool:Re,fromPath:n,toPath:`${oa}/${c}.md`});}}async function LD(t,e={}){let r=e.scope??"project",n=[],o=await H(Re,t,r);return n.push(...await Y(Md,t,r,{normalize:o})),await et(t,rn,Re,n,o),r==="project"&&(await Z1(t,n,o),await Q1(t,n,o),await q1(t,n,o),await et(t,ta,Re,n,o)),n}var B_,K_,OD=d(()=>{gt();rt();Me();Ot();A();ft();K();U_();sa();W_();B_=`${Hs}/_root.md`,K_="00-root.md";s(ED,"pathExists");s(Z1,"importLegacyRules");s(Q1,"importLegacyWorkflows");s(q1,"importLegacyModes");s(LD,"importFromKiloCode");});function wD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Re}))}var AD=d(()=>{Ct();sa();s(wD,"lintRules");});function bD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function PD(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".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 TD=d(()=>{wt();s(bD,"lintHooks");s(PD,"lintPermissions");});var tJ,eJ,rJ,xD,Md,W_=d(()=>{CD();sa();ne();OD();U_();AD();TD();Et();tJ={name:Re,primaryRootInstructionPath:zn,generateRules:hD,generateCommands:yD,generateAgents:_D,generateSkills:SD,generateMcp:RD,generateIgnore:ID,importFrom:LD},eJ={rootInstructionPath:zn,skillDir:rn,managedOutputs:{dirs:[Yo,Xo,Zo,rn],files:[zn,Bs,Al]},paths:{rulePath(t,e){return `${Yo}/${t}.md`},commandPath(t,e){return `${Xo}/${t}.md`},agentPath(t,e){return `${Zo}/${t}.md`}}},rJ={rootInstructionPath:Ks,skillDir:Ws,managedOutputs:{dirs:[ea,ra,na,Ws,qE],files:[Ks,Tl,Uu]},rewriteGeneratedPath(t){return t===zn?Ks:t},mirrorGlobalPath(t,e){return dt(t,Ws,e)},paths:{rulePath(t,e){return `${ea}/${t}.md`},commandPath(t,e){return `${ra}/${t}.md`},agentPath(t,e){return `${na}/${t}.md`}}},xD={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Md={id:Re,metadata:{displayName:"Kilo Code",category:"ide",officialUrl:"https://kilocode.ai",shortDescription:"Open-source AI coding agent for VS Code"},generators:tJ,capabilities:xD,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:wD,lint:{hooks:bD,permissions:PD},project:eJ,globalSupport:{capabilities:xD,detectionPaths:[Ks,ea,ra,na,Ws,Tl,Uu],layout:rJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[zn],global:[Ks]},canonicalDir:Hs,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Yo],global:[ea]},canonicalDir:Hs,extensions:[".md"],map:Fd}],commands:{feature:"commands",mode:"directory",source:{project:[Xo],global:[ra]},canonicalDir:xl,extensions:[".md"],map:vd},agents:{feature:"agents",mode:"directory",source:{project:[Zo],global:[na]},canonicalDir:oa,extensions:[".md"],map:kD},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Bs,Tm],global:[Tl]},canonicalDir:".agentsmesh",canonicalFilename:tL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Al],global:[Uu]},canonicalDir:".agentsmesh",canonicalFilename:eL}},buildImportPaths:qh,detectionPaths:[Yo,Xo,Zo,rn,Bs,qi,bl,ta,Tm,ju,Al,"kilo.jsonc","kilo.json"]};});function DD(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function sJ(t){return t.type==="prompt"?t.prompt:t.command}function iJ(t,e){let r=ND[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function FD(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in ND)||!Array.isArray(n))continue;let i=1;for(let a of n){let l=sJ(a);if(!l)continue;let c={name:`${DD(r)} ${i}`,version:"1",when:iJ(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:l}:{type:"shellCommand",command:l}};e.push({name:`${DD(r)}-${i}.kiro.hook`,content:JSON.stringify(c,null,2)}),i+=1;}}return e}function aJ(t){let e=oJ.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 vD(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:aJ(r)}function MD(t){return stringify(t).trimEnd()}var ND,oJ,H_=d(()=>{ND={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},oJ=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(DD,"toKebab");s(sJ,"hookText");s(iJ,"toWhen");s(FD,"generateKiroHooks");s(aJ,"toCanonicalEntry");s(vD,"parseKiroHookFile");s(MD,"serializeCanonicalHooks");});function cJ(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 $D(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:nn,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(We))continue;let o=basename(n.source,".md");e.push({path:`${on}/${o}.md`,content:T(cJ(n),n.body.trim()||"")});}return e}function GD(t){return t.commands.map(e=>({path:`${Ie}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function jD(t){return it(t,Ie)}function UD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Dl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function BD(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:FD(t.hooks).map(e=>({path:`${zs}/${e.name}`,content:e.content}))}function KD(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${sn}/${e.name}.md`,content:n}})}function WD(t){return t.ignore.length===0?[]:[{path:Nl,content:t.ignore.join(`
142
+ `)}]}var HD=d(()=>{rt();Lt();K();H_();Fl();s(cJ,"steeringFrontmatter");s($D,"generateRules");s(GD,"generateCommands");s(jD,"generateSkills");s(UD,"generateMcp");s(BD,"generateHooks");s(KD,"generateAgents");s(WD,"generateIgnore");});function pJ(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:Po(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function uJ(t,e,r,n){let o=n==="global"?[an,nn]:[nn,an];for(let i of o){let a=join(t,i),l=await _(a);if(l===null)continue;let c=join(t,ty),{frontmatter:m,body:p}=b(r(l,a,c));await S(c,await z(c,{...m,root:true},p)),e.push({fromTool:We,fromPath:a,toPath:ty,feature:"rules"});return}}async function dJ(t,e,r){let n=join(t,ey);e.push(...await St({srcDir:join(t,on),destDir:n,extensions:[".md"],fromTool:We,normalize:r,mapEntry:s(async({relativePath:o,normalizeTo:i})=>{if(basename(o)==="AGENTS.md")return null;let a=join(n,o),{frontmatter:l,body:c}=b(i(a));return {destPath:a,toPath:`${ey}/${o}`,feature:"rules",content:await z(a,pJ(l),c)}},"mapEntry")}));}async function fJ(t,e){let r={};for(let o of await $(join(t,zs))){if(!o.endsWith(".kiro.hook"))continue;let i=vD(await _(o)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let n=join(t,ry);await O(join(t,".agentsmesh")),await S(n,MD(r)),e.push({fromTool:We,fromPath:join(t,zs),toPath:ry,feature:"hooks"});}async function zD(t,e={}){let r=e.scope??"project",n=[],o=await H(We,t,r);return await uJ(t,n,o,r),await dJ(t,n,o),n.push(...await Y($d,t,r,{normalize:o})),await et(t,Ie,We,n,o),r==="project"&&await fJ(t,n),n}var VD=d(()=>{gt();rt();Me();Ot();ft();cr();A();K();H_();Fl();z_();s(pJ,"canonicalRuleMeta");s(uJ,"importRoot");s(dJ,"importNonRootRules");s(fJ,"importHooks");s(zD,"importFromKiro");});function JD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:We}))}var YD=d(()=>{Ct();Fl();s(JD,"lintRules");});function XD(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(n=>!r.has(n)).map(n=>Ts(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var ZD=d(()=>{wt();s(XD,"lintHooks");});var gJ,hJ,yJ,_J,$d,z_=d(()=>{Lt();HD();ne();VD();YD();ZD();Et();Fl();gJ={name:We,primaryRootInstructionPath:nn,generateRules:$D,generateCommands:GD,generateAgents:KD,generateSkills:jD,generateMcp:UD,generateHooks:BD,generateIgnore:WD,importFrom:zD},hJ={rootInstructionPath:nn,skillDir:Ie,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${on}/${t}.md`},commandPath(t){return `${Ie}/${V(t)}/SKILL.md`},agentPath(t,e){return `${sn}/${t}.md`}}},yJ={rootInstructionPath:an,skillDir:Vs,managedOutputs:{dirs:[ia,Vs,aa,nL],files:[an,Dm,Nm]},rewriteGeneratedPath(t){return t===nn?an:t.startsWith(`${on}/`)?t.replace(`${on}/`,`${ia}/`):t.startsWith(`${Ie}/`)?t.replace(`${Ie}/`,`${Vs}/`):t.startsWith(`${sn}/`)?t.replace(`${sn}/`,`${aa}/`):t===Dl?Dm:t===Nl?Nm:t.startsWith(`${zs}/`)?null:t},mirrorGlobalPath(t,e){return dt(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${ia}/${t}.md`},commandPath(t){return `${Ie}/${V(t)}/SKILL.md`},agentPath(t,e){return `${aa}/${t}.md`}}},_J={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},$d={id:We,metadata:{displayName:"Kiro",category:"ide",officialUrl:"https://kiro.dev",shortDescription:"AWS spec-driven AI IDE"},generators:gJ,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:JD,lint:{hooks:XD},project:hJ,globalSupport:{capabilities:_J,detectionPaths:[ia,an,Vs,aa,Dm,Nm],layout:yJ},importer:{agents:{feature:"agents",mode:"directory",source:{project:[sn],global:[sn]},canonicalDir:oL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Dl],global:[Dm]},canonicalDir:".agentsmesh",canonicalFilename:sL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Nl],global:[Nm]},canonicalDir:".agentsmesh",canonicalFilename:iL}},buildImportPaths:ny,detectionPaths:[on,Ie,sn,zs,Dl,Nl],conversionDefaults:{commandsToSkills:true}};});function qD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Vn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(ln))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs);let a=Object.keys(i).length>0?T(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Qo}/${o}.md`,content:a});}return e}function tN(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${qo}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function eN(t){return t.agents.map(e=>{let r=basename(e.source,".md"),n={mode:"subagent"};return e.description&&(n.description=e.description),e.model&&(n.model=e.model),e.tools.length>0&&(n.tools=e.tools),e.disallowedTools.length>0&&(n.disallowedTools=e.disallowedTools),{path:`${ts}/${r}.md`,content:T(n,e.body.trim()||"")}})}function RJ(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 rN(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e={};for(let[r,n]of Object.entries(t.mcp.mcpServers))e[r]=RJ(n);return [{path:Jn,content:JSON.stringify({mcp:e},null,2)}]}function nN(t){return it(t,cn)}var oN=d(()=>{rt();K();pa();s(qD,"generateRules");s(tN,"generateCommands");s(eN,"generateAgents");s(RJ,"toOpenCodeMcpServer");s(rN,"generateMcp");s(nN,"generateSkills");});function V_(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t))typeof n=="string"&&(e[r]=n);return e}function SJ(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 n={};for(let[o,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i;if(typeof a.url=="string"){n[o]={type:"url",url:a.url,headers:V_(a.headers),env:V_(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let l=a.command,c=l[0];if(c===void 0)continue;let m=l.slice(1);n[o]={type:"stdio",command:c,args:m,env:V_(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function CJ(t,e,r){let o=join(t,e==="global"?Xs:Jn),i=await _(o);if(i===null)return;let a=SJ(i);Object.keys(a).length!==0&&(await Wt(t,oy,a),r.push({feature:"mcp",fromTool:ln,fromPath:o,toPath:oy}));}async function sN(t,e={}){let r=e.scope??"project",n=[],o=await H(ln,t,r);return n.push(...await Y(Gd,t,r,{normalize:o})),await et(t,cn,ln,n,o),await CJ(t,r,n),n}var iN=d(()=>{gt();rt();Ot();Vr();A();pa();J_();s(V_,"toStringRecord");s(SJ,"parseOpenCodeMcp");s(CJ,"importMcp");s(sN,"importFromOpenCode");});var aN,lN,cN,mN=d(()=>{K();ft();pa();aN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Fm}/${t}`,content:await z(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"opencodeNonRootRuleMapper"),lN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Ku}/${t}`,content:await It(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),cN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${Wu}/${t}`,content:await Jt(n,o,i)}},"opencodeAgentMapper");});function pN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ln}))}var uN=d(()=>{Ct();pa();s(pN,"lintRules");});function dN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function fN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function gN(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var hN=d(()=>{wt();s(dN,"lintHooks");s(fN,"lintPermissions");s(gN,"lintIgnore");});var kJ,EJ,LJ,yN,Gd,J_=d(()=>{oN();pa();ne();iN();mN();uN();hN();Et();kJ={name:ln,primaryRootInstructionPath:Vn,generateRules:qD,generateCommands:tN,generateAgents:eN,generateSkills:nN,generateMcp:rN,importFrom:sN},EJ={rootInstructionPath:Vn,skillDir:cn,managedOutputs:{dirs:[Qo,qo,ts,cn],files:[Vn,Jn]},paths:{rulePath(t){return `${Qo}/${t}.md`},commandPath(t){return `${qo}/${t}.md`},agentPath(t){return `${ts}/${t}.md`}}},LJ={rootInstructionPath:Js,skillDir:Ys,managedOutputs:{dirs:[la,ca,ma,Ys,lL],files:[Js,Xs]},rewriteGeneratedPath(t){return t===Vn?Js:t===Jn?Xs:t},mirrorGlobalPath(t,e){return dt(t,Ys,e)},paths:{rulePath(t){return `${la}/${t}.md`},commandPath(t){return `${ca}/${t}.md`},agentPath(t){return `${ma}/${t}.md`}}},yN={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Gd={id:ln,metadata:{displayName:"OpenCode",category:"cli",officialUrl:"https://opencode.ai",shortDescription:"Open-source terminal AI agent"},generators:kJ,capabilities:yN,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:pN,lint:{hooks:dN,permissions:fN,ignore:gN},project:EJ,globalSupport:{capabilities:yN,detectionPaths:[Js,la,ca,ma,Ys,Xs],layout:LJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Vn],global:[Js]},canonicalDir:Fm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Qo],global:[la]},canonicalDir:Fm,extensions:[".md"],map:aN}],commands:{feature:"commands",mode:"directory",source:{project:[qo],global:[ca]},canonicalDir:Ku,extensions:[".md"],map:lN},agents:{feature:"agents",mode:"directory",source:{project:[ts],global:[ma]},canonicalDir:Wu,extensions:[".md"],map:cN}},buildImportPaths:sy,detectionPaths:[Qo,qo,ts,cn,Jn,"opencode.jsonc"]};});function _N(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Yn)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:Lr,content:o}]:[]}function RN(t){return it(t,ee)}function IN(t){return t.commands.map(e=>({path:`${ee}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function SN(t){return t.agents.map(e=>({path:`${ee}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}var CN=d(()=>{rt();Kt();ut();Lt();Ml();s(_N,"generateRules");s(RN,"generateSkills");s(IN,"generateCommands");s(SN,"generateAgents");});async function kN(t,e={}){let r=e.scope??"project",n=[],o=await H(Yn,t,r);return n.push(...await Y(jd,t,r,{normalize:o})),await et(t,r==="global"?Or:ee,Yn,n,o),n}var EN=d(()=>{gt();rt();Ot();Ml();X_();s(kN,"importFromPiAgent");});function LN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Yn}))}var ON=d(()=>{Ct();Ml();s(LN,"lintRules");});function wN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","pi-agent","Pi Coding Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function AN(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","pi-agent","Pi Coding Agent has no dedicated permissions config; canonical permissions are not projected.")]}function bN(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","pi-agent","Pi Coding Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function PN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".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 TN=d(()=>{wt();s(wN,"lintHooks");s(AN,"lintPermissions");s(bN,"lintIgnore");s(PN,"lintMcp");});var OJ,wJ,AJ,xN,jd,X_=d(()=>{Lt();ut();CN();ne();EN();ON();TN();ay();Ml();OJ={name:Yn,primaryRootInstructionPath:Lr,generateRules:_N,generateCommands:IN,generateAgents:SN,generateSkills:RN,importFrom:kN},wJ={rootInstructionPath:Lr,skillDir:ee,managedOutputs:{dirs:[ee],files:[Lr]},paths:{rulePath(t){return Lr},commandPath(t){return `${ee}/${V(t)}/SKILL.md`},agentPath(t){return `${ee}/${W(t)}/SKILL.md`}}},AJ={rootInstructionPath:es,skillDir:Or,managedOutputs:{dirs:[Or],files:[es]},rewriteGeneratedPath(t){return t===Lr?es:t.startsWith(`${ee}/`)?t.replace(`${ee}/`,`${Or}/`):t},mirrorGlobalPath(t,e){return dt(t,Or,e)},paths:{rulePath(t){return es},commandPath(t){return `${Or}/${V(t)}/SKILL.md`},agentPath(t){return `${Or}/${W(t)}/SKILL.md`}}},xN={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},jd={id:Yn,metadata:{displayName:"Pi Agent",category:"cli",officialUrl:"https://github.com/pi-labs/pi-agent",shortDescription:"Pi coding agent"},generators:OJ,capabilities:xN,emptyImportMessage:"No Pi Coding Agent config found (AGENTS.md or .pi/skills).",lintRules:LN,lint:{hooks:wN,permissions:AN,ignore:bN,mcp:PN},supportsConversion:{commands:true,agents:true},project:wJ,globalSupport:{capabilities:xN,detectionPaths:[es],layout:AJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Lr],global:[es]},canonicalDir:pL,canonicalRootFilename:"_root.md",markAsRoot:true}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:iy,detectionPaths:[Lr,ee]};});function DN(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:wr,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes(Xn)));for(let o of n){let i=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=T(a,o.body.trim()||"");e.push({path:`${rs}/${i}.md`,content:l});}return e}function NN(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 n=T(r,e.body.trim()||"");return {path:`${Zn}/${e.name}.md`,content:n}})}function FN(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(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${Qn}/${e.name}.md`,content:n}})}function vN(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${He}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${He}/${r.name}/${a}`,content:i.content});}}return e}function MN(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Zs,content:e}]}function $N(t){return !t.ignore||t.ignore.length===0?[]:[{path:Qs,content:t.ignore.join(`
143
+ `)}]}var GN=d(()=>{K();$l();s(DN,"generateRules");s(NN,"generateCommands");s(FN,"generateAgents");s(vN,"generateSkills");s(MN,"generateMcp");s($N,"generateIgnore");});async function jN(t,e={}){let r=e.scope??"project",n=[],o=await H(Xn,t,r);return n.push(...await Y(Ud,t,r,{normalize:o})),await et(t,r==="global"?qn:He,Xn,n,o),n}var UN=d(()=>{gt();Ot();rt();$l();Z_();s(jN,"importFromQwenCode");});function BN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Xn}))}var KN=d(()=>{Ct();$l();s(BN,"lintRules");});var PJ,TJ,xJ,DJ,NJ,Ud,Z_=d(()=>{GN();UN();KN();Et();$l();PJ={name:Xn,primaryRootInstructionPath:wr,generateRules:DN,generateCommands:NN,generateAgents:FN,generateSkills:vN,generateMcp:MN,generateIgnore:$N,importFrom:jN},TJ={rootInstructionPath:wr,skillDir:He,managedOutputs:{dirs:[rs,Zn,Qn,He],files:[wr,Zs,Qs]},paths:{rulePath(t,e){return e.root?wr:`${rs}/${t}.md`},commandPath(t){return `${Zn}/${t}.md`},agentPath(t){return `${Qn}/${t}.md`}}},xJ={rootInstructionPath:ns,skillDir:qn,managedOutputs:{dirs:[qs,ti,qn],files:[ns,ua]},rewriteGeneratedPath(t){return t===wr?ns:t===Zs?ua:t===Qs?null:t.startsWith(`${Zn}/`)?t.replace(`${Zn}/`,`${qs}/`):t.startsWith(`${Qn}/`)?t.replace(`${Qn}/`,`${ti}/`):t.startsWith(`${He}/`)?t.replace(`${He}/`,`${qn}/`):t.startsWith(`${rs}/`)?null:t},paths:{rulePath(t,e){return ns},commandPath(t){return `${qs}/${t}.md`},agentPath(t){return `${ti}/${t}.md`}}},DJ={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},NJ={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Ud={id:Xn,metadata:{displayName:"Qwen Code",category:"cli",officialUrl:"https://github.com/QwenLM/qwen-code",shortDescription:"Alibaba's Qwen coding CLI"},generators:PJ,capabilities:DJ,emptyImportMessage:"No Qwen Code config found (QWEN.md or .qwen/rules, .qwen/commands, .qwen/settings.json).",lintRules:BN,project:TJ,globalSupport:{capabilities:NJ,detectionPaths:[ns,ua,qs,ti,qn],layout:xJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[wr],global:[ns]},canonicalDir:ly,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[rs],global:[]},canonicalDir:ly,extensions:[".md"],preset:"rule"}],commands:{feature:"commands",mode:"directory",source:{project:[Zn],global:[qs]},canonicalDir:uL,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[Qn],global:[ti]},canonicalDir:dL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Zs],global:[ua]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/mcp.json"},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Qs],global:[]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/ignore"}},buildImportPaths:cy,detectionPaths:[wr,".qwen/settings.json",".qwen/commands",".qwen/rules"]};});function WN(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(to)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:mn,content:o}]:[]}function HN(t){return it(t,be)}function zN(t){return t.commands.map(e=>({path:`${be}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function VN(t){return t.agents.map(e=>({path:`${be}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}var JN=d(()=>{rt();Kt();ut();Lt();Gl();s(WN,"generateRules");s(HN,"generateSkills");s(zN,"generateCommands");s(VN,"generateAgents");});async function YN(t,e={}){let r=e.scope??"project",n=[],o=await H(to,t,r);return n.push(...await Y(Bd,t,r,{normalize:o})),await et(t,be,to,n,o),n}var XN=d(()=>{gt();rt();Ot();Gl();Q_();s(YN,"importFromReplitAgent");});function ZN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:to}))}var QN=d(()=>{Ct();Gl();s(ZN,"lintRules");});function qN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","replit-agent","Replit Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function tF(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","replit-agent","Replit Agent permissions are managed in the cloud UI; canonical permissions are not projected.")]}function eF(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","replit-agent","Replit Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function rF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".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 nF=d(()=>{wt();s(qN,"lintHooks");s(tF,"lintPermissions");s(eF,"lintIgnore");s(rF,"lintMcp");});var FJ,vJ,MJ,Bd,Q_=d(()=>{Lt();ut();JN();XN();QN();nF();py();Gl();FJ={name:to,primaryRootInstructionPath:mn,generateRules:WN,generateCommands:zN,generateAgents:VN,generateSkills:HN,importFrom:YN},vJ={rootInstructionPath:mn,skillDir:be,managedOutputs:{dirs:[be],files:[mn]},paths:{rulePath(t){return mn},commandPath(t){return `${be}/${V(t)}/SKILL.md`},agentPath(t){return `${be}/${W(t)}/SKILL.md`}}},MJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Bd={id:to,metadata:{displayName:"Replit Agent",category:"agent-platform",officialUrl:"https://replit.com",shortDescription:"Replit's autonomous coding agent"},generators:FJ,capabilities:MJ,emptyImportMessage:"No Replit Agent config found (replit.md or .agents/skills).",lintRules:ZN,lint:{hooks:qN,permissions:tF,ignore:eF,mcp:rF},supportsConversion:{commands:true,agents:true},project:vJ,sharedArtifacts:{".agents/skills/":"consumer"},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[mn]},canonicalDir:gL,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:my,detectionPaths:[mn]};});function sF(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:pn,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(ei))continue;let o=basename(n.source,".md");e.push({path:`${os}/${o}.md`,content:n.body.trim()||""});}return e}function iF(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${ss}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function aF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Mm,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function lF(t){return t.ignore.length===0?[]:[{path:$m,content:t.ignore.join(`
144
+ `)}]}function cF(t){return it(t,eo)}function mF(t){if(t.agents.length===0)return [];let e=t.agents.map(r=>{let o={slug:basename(r.source,".md"),name:r.name};return r.description&&(o.description=r.description),r.body.trim()&&(o.roleDefinition=r.body.trim()),o});return [{path:jl,content:stringify({customModes:e})}]}var pF=d(()=>{rt();K();ha();s(sF,"generateRules");s(iF,"generateCommands");s(aF,"generateMcp");s(lF,"generateIgnore");s(cF,"generateSkills");s(mF,"generateAgents");});var Kd,dF,q_=d(()=>{K();ft();ha();Kd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${ga}/${t}`,content:await z(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"rooNonRootRuleMapper"),dF=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=b(e(n));return {destPath:n,toPath:`${zu}/${t}`,content:await It(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function jJ(t,e,r){let n=join(t,da),o;try{o=await readdir(n,{withFileTypes:!0});}catch{return}let i=o.filter(l=>l.isDirectory()&&l.name.startsWith("rules-")).map(l=>l.name),a=join(t,ga);for(let l of i)e.push(...await St({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:ei,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await Kd({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function fF(t,e={}){let r=e.scope??"project",n=[],o=await H(ei,t,r);return n.push(...await Y(Wd,t,r,{normalize:o})),await jJ(t,n,o),await et(t,eo,ei,n,o),n}var gF=d(()=>{gt();rt();Me();Ot();q_();ha();eR();s(jJ,"importPerModeRules");s(fF,"importFromRooCode");});function hF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ei}))}var yF=d(()=>{Ct();ha();s(hF,"lintRules");});function zJ(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var WJ,HJ,VJ,JJ,YJ,Wd,eR=d(()=>{A();pF();ha();ne();gF();q_();yF();Et();WJ={name:"roo-code",primaryRootInstructionPath:pn,generateRules:sF,generateCommands:iF,generateSkills:cF,generateMcp:aF,generateIgnore:lF,generateAgents:mF,importFrom:fF},HJ={rootInstructionPath:pn,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",jl]},paths:{rulePath(t,e){return `${os}/${t}.md`},commandPath(t,e){return `${ss}/${t}.md`},agentPath(t,e){return null}}};s(zJ,"computeStatus");VJ=s(async(t,e,r,n)=>{if(r!=="global")return [];if(!n.has("agents")||t.agents.length===0)return [];let o=t.agents.map(l=>{let m={slug:basename(l.source,".md"),name:l.name};return l.description&&(m.description=l.description),l.body.trim()&&(m.roleDefinition=l.body.trim()),m}),i=stringify({customModes:o}),a=await _(join(e,Gm));return [{target:"roo-code",path:Gm,content:i,currentContent:a??void 0,status:zJ(a,i)}]},"generateRooGlobalExtras"),JJ={rootInstructionPath:oi,skillDir:is,managedOutputs:{dirs:[ri,ni,is,hL],files:[oi,fa,jm,Gm]},rewriteGeneratedPath(t){return t===pn?oi:t===jl?null:t.startsWith(`${os}/`)?t.replace(`${os}/`,`${ri}/`):t.startsWith(`${ss}/`)?t.replace(`${ss}/`,`${ni}/`):t.startsWith(`${eo}/`)?t.replace(`${eo}/`,`${is}/`):t===Mm?fa:t===$m?jm:t},mirrorGlobalPath(t,e){return dt(t,is,e)},paths:{rulePath(t,e){return `${ri}/${t}.md`},commandPath(t,e){return `${ni}/${t}.md`},agentPath(t,e){return null}}},YJ={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Wd={id:"roo-code",metadata:{displayName:"Roo Code",category:"ide",officialUrl:"https://roocode.com",shortDescription:"Open-source AI VS Code extension"},generators:WJ,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:hF,project:HJ,globalSupport:{capabilities:YJ,detectionPaths:[ri,ni,is,fa,jm,oi,Gm],layout:JJ,scopeExtras:VJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[pn,vm],global:[oi,pn,vm]},canonicalDir:ga,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:[os],global:[ri]},canonicalDir:ga,extensions:[".md"],map:Kd}],commands:{feature:"commands",mode:"directory",source:{project:[ss],global:[ni]},canonicalDir:zu,extensions:[".md"],map:dF},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Mm],global:[fa]},canonicalDir:".agentsmesh",canonicalFilename:yL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[$m],global:[jm]},canonicalDir:".agentsmesh",canonicalFilename:_L}},buildImportPaths:uy,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",jl]};});function _F(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(ro)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:Ar,content:o}]:[]}function RF(t){return it(t,re)}function IF(t){return t.commands.map(e=>({path:`${re}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function SF(t){return t.agents.map(e=>({path:`${re}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function CF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:as,content:e}]}var kF=d(()=>{rt();Kt();ut();Lt();Bl();s(_F,"generateRules");s(RF,"generateSkills");s(IF,"generateCommands");s(SF,"generateAgents");s(CF,"generateMcp");});async function EF(t,e={}){let r=e.scope??"project",n=[],o=await H(ro,t,r);return n.push(...await Y(Hd,t,r,{normalize:o})),await et(t,r==="global"?ze:re,ro,n,o),n}var LF=d(()=>{gt();rt();Ot();Bl();rR();s(EF,"importFromRovodev");});function OF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ro}))}var wF=d(()=>{Ct();Bl();s(OF,"lintRules");});function AF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","rovodev","Rovo Dev has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function bF(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","rovodev","Rovo Dev permissions are managed in config.yaml; canonical permissions are not projected.")]}function PF(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","rovodev","Rovo Dev has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var TF=d(()=>{wt();s(AF,"lintHooks");s(bF,"lintPermissions");s(PF,"lintIgnore");});var XJ,ZJ,QJ,qJ,tY,Hd,rR=d(()=>{Lt();ut();kF();ne();LF();wF();TF();Et();Bl();XJ={name:ro,primaryRootInstructionPath:Ar,generateRules:_F,generateCommands:IF,generateAgents:SF,generateSkills:RF,generateMcp:CF,importFrom:EF},ZJ={rootInstructionPath:Ar,skillDir:re,managedOutputs:{dirs:[re],files:[Ar,as]},paths:{rulePath(t){return Ar},commandPath(t){return `${re}/${V(t)}/SKILL.md`},agentPath(t){return `${re}/${W(t)}/SKILL.md`}}},QJ={rootInstructionPath:ls,skillDir:ze,managedOutputs:{dirs:[ze],files:[ls,Ul]},rewriteGeneratedPath(t){return t===Ar?ls:t.startsWith(`${re}/`)?t.replace(`${re}/`,`${ze}/`):t===as?Ul:t},mirrorGlobalPath(t,e){return dt(t,ze,e)},paths:{rulePath(t){return ls},commandPath(t){return `${ze}/${V(t)}/SKILL.md`},agentPath(t){return `${ze}/${W(t)}/SKILL.md`}}},qJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},tY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Hd={id:ro,metadata:{displayName:"Rovo Dev",category:"cli",officialUrl:"https://www.atlassian.com/solutions/devops/rovo-dev",shortDescription:"Atlassian's coding agent"},generators:XJ,capabilities:qJ,emptyImportMessage:"No Rovo Dev config found (AGENTS.md, .rovodev/skills, or .rovodev/mcp.json).",lintRules:OF,lint:{hooks:AF,permissions:bF,ignore:PF},supportsConversion:{commands:true,agents:true},project:ZJ,globalSupport:{capabilities:tY,detectionPaths:[SL,ls,ze],layout:QJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ar],global:[ls]},canonicalDir:CL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[as],global:[Ul]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:dy,detectionPaths:[Ar,re,as]};});function xF(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Je,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(br))continue;let o=basename(n.source,".md");e.push({path:`${Ve}/${o}.md`,content:n.body.trim()});}return e}function DF(t){return it(t,Pr)}function NF(t){return t.mcp===null||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ya,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function FF(t){return t.ignore.length===0?[]:[{path:Kl,content:t.ignore.join(`
145
+ `)}]}var vF=d(()=>{rt();Wl();s(xF,"generateRules");s(DF,"generateSkills");s(NF,"generateMcp");s(FF,"generateIgnore");});async function nY(t,e,r,n){let o=n==="global"?[Tr,Je]:[Je,Tr];for(let i of o){let a=join(t,i),l=await _(a);if(l===null)continue;let c=join(t,MF),{frontmatter:m,body:p}=b(r(l,a,c));await O(join(t,Bm)),await S(c,await z(c,{...m,root:true},p)),e.push({fromTool:br,fromPath:a,toPath:MF,feature:"rules"});return}}async function oY(t,e,r,n){let o=join(t,n==="global"?cs:Ve),i=join(t,Bm);e.push(...await St({srcDir:o,destDir:i,extensions:[".md"],fromTool:br,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=basename(a);if(c==="project_rules.md"||c==="rules.md")return null;let m=join(i,a),{frontmatter:p,body:u}=b(l(m));return {destPath:m,toPath:`${Bm}/${a}`,feature:"rules",content:await z(m,{...p,root:false},u)}},"mapEntry")}));}async function $F(t,e={}){let r=e.scope??"project",n=[],o=await H(br,t,r);return await nY(t,n,o,r),await oY(t,n,o,r),n.push(...await Y(zd,t,r,{normalize:o})),await et(t,r==="global"?un:Pr,br,n,o),n}var MF,GF=d(()=>{gt();rt();Me();Ot();ft();A();K();Wl();nR();MF=`${Bm}/_root.md`;s(nY,"importRoot");s(oY,"importNonRootRules");s($F,"importFromTrae");});function jF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:br}))}var UF=d(()=>{Ct();Wl();s(jF,"lintRules");});var sY,iY,aY,lY,zd,nR=d(()=>{vF();ne();GF();UF();Et();Wl();sY={name:br,primaryRootInstructionPath:Je,generateRules:xF,generateSkills:DF,generateMcp:NF,generateIgnore:FF,importFrom:$F},iY={rootInstructionPath:Je,skillDir:Pr,managedOutputs:{dirs:[Ve,Pr],files:[ya,Kl]},paths:{rulePath(t,e){return `${Ve}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},aY={rootInstructionPath:Tr,skillDir:un,managedOutputs:{dirs:[cs,un,EL],files:[Tr,Um]},rewriteGeneratedPath(t){return t===Je?Tr:t.startsWith(`${Ve}/`)?t.replace(`${Ve}/`,`${cs}/`):t.startsWith(`${Pr}/`)?t.replace(`${Pr}/`,`${un}/`):t===ya?Um:t===Kl?null:t},mirrorGlobalPath(t,e){return dt(t,un,e)},paths:{rulePath(t,e){return t==="_root"?Tr:`${cs}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},lY={rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},zd={id:br,metadata:{displayName:"Trae",category:"ide",officialUrl:"https://www.trae.ai",shortDescription:"ByteDance's adaptive AI IDE"},generators:sY,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:jF,project:iY,globalSupport:{capabilities:lY,detectionPaths:[Tr,cs,un,Um],layout:aY},importer:{mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ya],global:[Um]},canonicalDir:".agentsmesh",canonicalFilename:LL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Kl]},canonicalDir:".agentsmesh",canonicalFilename:OL}},buildImportPaths:fy,detectionPaths:[Ve,ya,Je]};});function BF(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)),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:dn,content:o}]:[]}function KF(t){return it(t,fe)}function WF(t){return t.commands.map(e=>({path:`${fe}/${V(e.name)}/SKILL.md`,content:Ft(e)}))}function HF(t){return t.agents.map(e=>({path:`${fe}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}function zF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:si,content:e}]}var VF=d(()=>{rt();Kt();ut();Lt();Hl();s(BF,"generateRules");s(KF,"generateSkills");s(WF,"generateCommands");s(HF,"generateAgents");s(zF,"generateMcp");});async function JF(t,e={}){let r=e.scope??"project",n=[],o=await H(no,t,r);return n.push(...await Y(Vd,t,r,{normalize:o})),await et(t,r==="global"?Ye:fe,no,n,o),n}var YF=d(()=>{gt();rt();Ot();Hl();oR();s(JF,"importFromWarp");});function XF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:no}))}var ZF=d(()=>{Ct();Hl();s(XF,"lintRules");});function QF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function qF(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function tv(t){return t.ignore.length===0?[]:[x(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var ev=d(()=>{wt();s(QF,"lintHooks");s(qF,"lintPermissions");s(tv,"lintIgnore");});var cY,mY,pY,uY,dY,Vd,oR=d(()=>{Lt();ut();VF();ne();YF();ZF();ev();Et();Hl();cY={name:no,primaryRootInstructionPath:dn,generateRules:BF,generateCommands:WF,generateAgents:HF,generateSkills:KF,generateMcp:zF,importFrom:JF},mY={rootInstructionPath:dn,skillDir:fe,managedOutputs:{dirs:[fe],files:[dn,si]},paths:{rulePath(t){return dn},commandPath(t){return `${fe}/${V(t)}/SKILL.md`},agentPath(t){return `${fe}/${W(t)}/SKILL.md`}}},pY={rootInstructionPath:void 0,skillDir:Ye,managedOutputs:{dirs:[Ye],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${fe}/`)?t.replace(`${fe}/`,`${Ye}/`):t},mirrorGlobalPath(t,e){return dt(t,Ye,e)},paths:{rulePath(){return null},commandPath(t){return `${Ye}/${V(t)}/SKILL.md`},agentPath(t){return `${Ye}/${W(t)}/SKILL.md`}}},uY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},dY={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Vd={id:no,metadata:{displayName:"Warp",category:"cli",officialUrl:"https://www.warp.dev",shortDescription:"AI-powered terminal"},generators:cY,capabilities:uY,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:XF,lint:{hooks:QF,permissions:qF,ignore:tv},supportsConversion:{commands:true,agents:true},project:mY,globalSupport:{capabilities:dY,detectionPaths:[Ye],layout:pY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gy,dn]},canonicalDir:AL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[si]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:hy,detectionPaths:[dn,gy,si],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});var uo,sR,di,rv,ac,fo,lc,cc,nv,fi,yn,mc,iR,ov,sv,aR,lR,cR,pc,uc,rp,Jd,Yd,Xd,iv,Ce=d(()=>{uo="windsurf",sR=".windsurfrules",di=".windsurf/rules",rv=".windsurfignore",ac=".codeiumignore",fo="AGENTS.md",lc=".windsurf/hooks.json",cc=".windsurf/mcp_config.example.json",nv=".windsurf/mcp_config.json",fi=".windsurf/workflows",yn=".windsurf/skills",mc=".agentsmesh/rules",iR=".agentsmesh/commands",ov=".agentsmesh/agents",sv=".agentsmesh/skills",aR=".agentsmesh/ignore",lR=".agentsmesh/hooks.yaml",cR=".agentsmesh/mcp.json",pc=".codeium/windsurf/memories/global_rules.md",uc=".codeium/windsurf/skills",rp=".codeium/windsurf/global_workflows",Jd=".codeium/windsurf/hooks.json",Yd=".codeium/windsurf/mcp_config.json",Xd=".codeium/.codeiumignore",iv=".agents/skills";});function gY(t){let e=basename(t,".md");return e==="_root"?"root":e}function hY(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 mR(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:fo,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=gY(n.source),i=n.trigger||(n.globs.length>0?"glob":void 0),a={description:n.description||void 0,trigger:i,glob:n.globs.length===1?n.globs[0]:void 0,globs:n.globs.length>1?n.globs:void 0};Object.keys(a).forEach(m=>{a[m]===void 0&&delete a[m];});let l=Object.keys(a).length>0?T(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${di}/${o}.md`,content:l});let c=hY(n.globs);c&&(c!==o&&e.push({path:`${di}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var av=d(()=>{K();Ce();s(gY,"ruleSlug");s(hY,"directoryScopedRuleDir");s(mR,"generateRules");});function pR(t){return !t.ignore||t.ignore.length===0?[]:[{path:ac,content:t.ignore.join(`
146
+ `)}]}var lv=d(()=>{Ce();s(pR,"generateIgnore");});function uR(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(o=>{r[o]===void 0&&delete r[o];});let n=Object.keys(r).length>0?T(r,e.body.trim()||""):e.body.trim();return {path:`${fi}/${e.name}.md`,content:n}})}var cv=d(()=>{K();Ce();s(uR,"generateCommands");});function dR(t){return t.agents.map(e=>({path:`${yn}/${W(e.name)}/SKILL.md`,content:Tt(e)}))}var mv=d(()=>{ut();Ce();s(dR,"generateAgents");});function fR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:cc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var pv=d(()=>{Ce();s(fR,"generateMcp");});function yY(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 _Y(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!kn(i))continue;let a=Vt(i),l=ye(i),c=i.type==="prompt"?l||a:a||l;c&&o.push({command:c,show_output:true});}o.length>0&&(e[yY(r)]=o);}return e}function gR(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=_Y(t.hooks);return Object.keys(e).length===0?[]:[{path:lc,content:JSON.stringify({hooks:e},null,2)}]}var uv=d(()=>{Ur();Ce();s(yY,"windsurfEventName");s(_Y,"toWindsurfHooks");s(gR,"generateHooks");});function hR(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=Object.keys(n).length>0?T(n,r.body.trim()||""):r.body.trim()||"";e.push({path:`${yn}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles)e.push({path:`${yn}/${r.name}/${i.relativePath}`,content:i.content});}return e}var dv=d(()=>{K();Ce();s(hR,"generateSkills");});var fv=d(()=>{av();lv();cv();mv();pv();uv();dv();});var gv=d(()=>{fv();});function hv(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 yv(t,e,r){let n=join(t,fi),i=(await $(n)).filter(l=>l.endsWith(".md")),a=join(t,iR);for(let l of i){let c=await _(l);if(!c)continue;let m=relative(n,l).replace(/\\/g,"/");await O(a);let p=join(a,m),u=r(c,l,p),{frontmatter:f,body:g}=b(u),h=await It(p,{description:typeof f.description=="string"?f.description:"",hasDescription:Object.prototype.hasOwnProperty.call(f,"description"),allowedTools:(()=>{let I=hv(f.allowedTools);return I.length>0?I:hv(f["allowed-tools"])})(),hasAllowedTools:Object.prototype.hasOwnProperty.call(f,"allowedTools")||Object.prototype.hasOwnProperty.call(f,"allowed-tools")},g);await S(p,h),e.push({fromTool:uo,fromPath:l,toPath:`${iR}/${m}`,feature:"commands"});}}var _v=d(()=>{A();K();ft();Ce();s(hv,"toStringArray");s(yv,"importWorkflows");});async function Rv(t,e,r,n=yn){await Jl([n],{projectRoot:t,destCanonicalSkillsDir:sv,targetName:"windsurf",normalize:r,results:e},[Yl({canonicalAgentsDir:ov})]);}var Iv=d(()=>{Xl();Ce();s(Rv,"importSkills");});async function Cv(t,e){let r=join(t,lc),n=await _(r);if(n)try{let o=JSON.parse(n);if(!o.hooks||typeof o.hooks!="object"||Array.isArray(o.hooks))return;let i=CY(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,lR);await O(dirname(a)),await S(a,stringify(i)),e.push({fromTool:uo,fromPath:r,toPath:lR,feature:"hooks"});}catch{}}function SY(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 CY(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=SY(r),i=[];for(let a of n){if(!a||typeof a!="object")continue;let l=a;if(typeof l.command=="string"&&l.command.trim()){i.push({matcher:".*",type:"command",command:l.command});continue}let c=typeof l.matcher=="string"&&l.matcher.trim()?l.matcher:".*",m=Array.isArray(l.hooks)?l.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let u=p,f=typeof u.command=="string"?u.command:typeof u.prompt=="string"?u.prompt:"";if(!f.trim())continue;let g={matcher:c,type:u.type==="prompt"?"prompt":"command",command:f};typeof u.timeout=="number"&&(g.timeout=u.timeout),i.push(g);}}i.length>0&&(e[o]=i);}return e}async function kv(t,e){let r=[cc,nv];for(let n of r){let o=join(t,n),i=await _(o);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let l=join(t,cR);await O(dirname(l)),await S(l,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:uo,fromPath:o,toPath:cR,feature:"mcp"});return}catch{}}}var Ev=d(()=>{A();Ce();s(Cv,"importWindsurfHooks");s(SY,"canonicalHookEventName");s(CY,"windsurfHooksToCanonical");s(kv,"importWindsurfMcp");});async function Lv(t,e){let r=e?.scope??"project",n=[],o=await H(uo,t),i=await H("codex-cli",t),a=join(t,mc),l=join(t,sR),c=await _(l);if(c!==null){await O(a);let f=join(a,"_root.md"),g=o(c,l,f).trim(),h=await z(f,{root:true},g);await S(f,h),n.push({fromTool:"windsurf",fromPath:l,toPath:`${mc}/_root.md`,feature:"rules"});}if(c===null){let f=join(t,fo),g=await _(f);if(g!==null){await O(a);let h=join(a,"_root.md"),I=o(i(g,f,h),f,h).trim(),k=await z(h,{root:true},I);await S(h,k),n.push({fromTool:"windsurf",fromPath:f,toPath:`${mc}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await St({srcDir:t,destDir:a,extensions:["AGENTS.md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({srcPath:f,normalizeTo:g})=>{let h=relative(t,dirname(f)).replace(/\\/g,"/");if(!h||h==="."||basename(f)!=="AGENTS.md")return null;let I=h.replace(/\//g,"-");if(!fu(h))return await Ln(join(a,`${I}.md`)),null;let k=join(a,`${I}.md`);return {destPath:k,toPath:`${mc}/${I}.md`,feature:"rules",content:await z(k,{root:false,globs:[`${h}/**`]},g(k))}},"mapEntry")}));let m=join(t,di);n.push(...await St({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({relativePath:f,normalizeTo:g})=>{if(f==="_root.md"&&c!==null)return null;let h=join(a,f),{frontmatter:I,body:k}=b(g(h)),C={...I};return typeof C.glob=="string"&&C.glob.trim()&&(C.globs=[C.glob],delete C.glob),{destPath:h,toPath:`${mc}/${f}`,feature:"rules",content:await z(h,{...C,root:false},k)}},"mapEntry")}));let p=join(t,rv),u=await _(p);if((u===null||!u.trim())&&(p=join(t,ac),u=await _(p)),u!==null&&u.trim()){let f=u.split(/\r?\n/),g=[];for(let h of f){let I=h.trim();I&&!I.startsWith("#")&&g.push(I);}if(g.length>0){await O(join(t,".agentsmesh"));let h=join(t,aR);await S(h,g.join(`
147
+ `)),n.push({fromTool:"windsurf",fromPath:p,toPath:aR,feature:"ignore"});}}return await yv(t,n,o),await Rv(t,n,o),await Cv(t,n),await kv(t,n),n}var Ov=d(()=>{gt();A();K();ft();Me();rm();Ce();_v();Iv();Ev();s(Lv,"importFromWindsurf");});function wv(t,e,r){let n=[],{rules:o}=t;o.length>0&&(o.some(l=>l.root)||n.push({level:"warning",file:relative(e,o[0].source),target:uo,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&&n.push({level:"warning",file:".agentsmesh",target:uo,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),n}var Av=d(()=>{Ce();s(wv,"lintRules");});function bv(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>x(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function Pv(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[x(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var Tv=d(()=>{wt();s(bv,"lintCommands");s(Pv,"lintMcp");});function wY(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 AY,bY,PY,TY,xv,Dv=d(()=>{gv();Pi();Ce();ne();Ov();Av();Tv();Et();sl();ut();s(wY,"directoryScopedRuleDir");AY={name:"windsurf",primaryRootInstructionPath:fo,generateRules:mR,generateCommands:uR,generateAgents:dR,generateSkills:hR,generateMcp:fR,generateHooks:gR,generateIgnore:pR,importFrom:Lv},bY={rootInstructionPath:fo,extraRuleOutputPaths(t){if(t.root)return [fo];let e=wY(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:yn,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 `${di}/${t}.md`},commandPath(t,e){return `${fi}/${t}.md`},agentPath(t,e){return or(e,"windsurf")?`.windsurf/skills/${W(t)}/SKILL.md`:null}}},PY={rootInstructionPath:pc,skillDir:uc,managedOutputs:{dirs:[uc,rp,iv],files:[pc,Jd,Yd,Xd]},rewriteGeneratedPath(t){return t===fo?pc:t.startsWith(`${di}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${yn}/`)?t.replace(`${yn}/`,`${uc}/`):t.startsWith(`${fi}/`)?t.replace(`${fi}/`,`${rp}/`):t===lc?Jd:t===cc?Yd:t===ac?Xd:t},mirrorGlobalPath(t,e){return dt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return pc},commandPath(t,e){return `${rp}/${t}.md`},agentPath(t,e){return or(e,"windsurf")?`${uc}/${W(t)}/SKILL.md`:null}}},TY={rules:"native",additionalRules:"partial",commands:Kr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},xv={id:"windsurf",metadata:{displayName:"Windsurf",category:"ide",officialUrl:"https://windsurf.com",shortDescription:"Codeium's agentic IDE"},generators:AY,capabilities:{rules:"native",additionalRules:"native",commands:Kr("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:wv,lint:{commands:bv,mcp:Pv},project:bY,globalSupport:{capabilities:TY,detectionPaths:[pc,uc,rp,Jd,Yd,Xd],layout:PY},buildImportPaths:yy,detectionPaths:[".windsurfrules",".windsurf"],conversionDefaults:{agentsToSkills:true}};});function Nv(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")),n=e?.body.trim()??"",o=mt(n,r);return o?[{path:fn,content:o}]:[]}var Fv=d(()=>{Kt();_a();s(Nv,"generateRules");});async function Mv(t,e,r){let n=await _(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let a=o.context_servers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,l[c]=p;}Object.keys(l).length!==0&&(await Wt(t,vv,l),r.push({fromTool:"zed",fromPath:e,toPath:vv,feature:"mcp"}));}var vv,$v=d(()=>{A();Vr();_a();vv=".agentsmesh/mcp.json";s(Mv,"importZedMcp");});async function Gv(t,e={}){let r=e.scope??"project",n=[],o=await H("zed",t,r);return n.push(...await Y(Qd,t,r,{normalize:o})),await Mv(t,r==="global"?so:oo,n),n}var jv=d(()=>{gt();Ot();$v();_a();_R();s(Gv,"importFromZed");});function Uv(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var Bv=d(()=>{Ct();_a();s(Uv,"lintRules");});function Kv(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[x(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Wv(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];return e.length===0&&r.length===0&&n.length===0?[]:[x(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function Hv(t){return t.ignore.length===0?[]:[x(".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 zv=d(()=>{wt();s(Kv,"lintHooks");s(Wv,"lintPermissions");s(Hv,"lintIgnore");});function $Y(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 n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o.context_servers!==void 0&&(r.context_servers=o.context_servers),JSON.stringify(r,null,2)}var DY,NY,FY,vY,MY,Qd,_R=d(()=>{Fv();jv();Bv();zv();Et();_a();DY={name:"zed",primaryRootInstructionPath:fn,generateRules:Nv,importFrom:Gv},NY={rootInstructionPath:fn,managedOutputs:{dirs:[],files:[fn,oo]},paths:{rulePath(t){return fn},commandPath(){return null},agentPath(){return null}}},FY={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[so]},rewriteGeneratedPath(t){return t===oo?so:t},paths:{rulePath(){return so},commandPath(){return null},agentPath(){return null}}},vY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},MY={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s($Y,"mergeZedSettings");Qd={id:"zed",metadata:{displayName:"Zed",category:"ide",officialUrl:"https://zed.dev",shortDescription:"Collaborative AI editor"},generators:DY,capabilities:vY,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:Uv,lint:{hooks:Kv,permissions:Wv,ignore:Hv},project:NY,globalSupport:{capabilities:MY,detectionPaths:[so],layout:FY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[fn],global:[]},canonicalDir:TL,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let r={};for(let[n,o]of Object.entries(t.mcp.mcpServers))r[n]=o;return [{path:oo,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===oo||n===so?$Y(t,r):null},buildImportPaths:_y,detectionPaths:[fn,oo]};});var aE={};_g(aE,{BUILTIN_TARGETS:()=>bt,TARGET_IDS:()=>vt,getBuiltinTargetDefinition:()=>Fr,getEffectiveTargetSupportLevel:()=>qd,getTargetCapabilities:()=>pi,getTargetDetectionPaths:()=>IR,getTargetLayout:()=>Bt,getTargetManagedOutputs:()=>SR,getTargetPrimaryRootInstructionPath:()=>jY,getTargetSkillDir:()=>np,isBuiltinTargetId:()=>Fe,resolveTargetFeatureGenerator:()=>dc,rewriteGeneratedOutputPath:()=>CR});function GY(){return RR||(UC(bt),RR=new Map(bt.map(t=>[t.id,t]))),RR}function Fr(t){return GY().get(t)}function pi(t,e="project"){let r=Fr(t)??ot(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return GC(n)}function IR(t,e="project"){let r=Fr(t)??ot(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function Bt(t,e="project"){let r=Fr(t)??ot(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function jY(t,e="project"){return Bt(t,e)?.rootInstructionPath}function np(t,e="project"){return Bt(t,e)?.skillDir}function SR(t,e="project"){return Bt(t,e)?.managedOutputs}function CR(t,e,r="project"){let n=Bt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function Vv(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!ol(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!or(r,t.id,true,n):false}function UY(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?ol(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?or(r,t.id,true,n):false}function qd(t,e,r,n="project"){let o=pi(t,n)?.[e]?.level??"none",i=Fr(t)??ot(t);return o==="none"&&UY(i,e,r,n)?"embedded":o!=="embedded"?o:Vv(i,e,r,n)?"none":o}function dc(t,e,r,n="project"){let o=Fr(t)??ot(t);if(!o?.generators||Vv(o,e,r,n))return;let i=BY[e];return i===null?void 0:i(o.generators)}var bt,RR,BY,Pt=d(()=>{sl();Pi();ae();Jg();Sn();uh();Ry();Iy();Cy();jO();Ly();tA();WA();zy();Qy();t_();g_();h_();y_();v_();M_();$_();G_();W_();z_();J_();X_();Z_();Q_();eR();rR();nR();oR();Dv();_R();bt=[_u,Ju,Yu,Xu,GO,Zu,qw,KA,od,md,ud,Sd,Cd,kd,Td,xd,Dd,Nd,Md,$d,Gd,jd,Ud,Bd,Wd,Hd,zd,Vd,xv,Qd];s(GY,"builtinTargetsMap");s(Fr,"getBuiltinTargetDefinition");s(pi,"getTargetCapabilities");s(IR,"getTargetDetectionPaths");s(Bt,"getTargetLayout");s(jY,"getTargetPrimaryRootInstructionPath");s(np,"getTargetSkillDir");s(SR,"getTargetManagedOutputs");s(CR,"rewriteGeneratedOutputPath");s(Vv,"isFeatureSuppressedByConversion");s(UY,"isConversionUpgrading");s(qd,"getEffectiveTargetSupportLevel");BY={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(dc,"resolveTargetFeatureGenerator");});function HY(t,e){return t.uniqueHits!==e.uniqueHits?e.uniqueHits-t.uniqueHits:t.sharedScore!==e.sharedScore?e.sharedScore-t.sharedScore:t.id.localeCompare(e.id)}async function tf(t){let e=[];for(let n of bt){let o=0,i=0;for(let a of n.detectionPaths){if(!await j(join(t,a)))continue;let l=WY.get(a)??1;l===1?o+=1:i+=1/l;}(o>0||i>0)&&e.push({id:n.id,uniqueHits:o,sharedScore:i});}if(e.length===0)return null;e.sort(HY);let r=e[0];return r.uniqueHits===0?null:r.id}var WY,Jv,kR=d(()=>{A();Pt();WY=(()=>{let t=new Map;for(let e of bt)for(let r of e.detectionPaths)t.set(r,(t.get(r)??0)+1);return t})();s(HY,"compare");s(tf,"detectNativeFormat");Jv=bt.map(t=>t.detectionPaths[0]).filter(t=>t!==void 0);});async function op(t,e){let r=ot(e);if(!r)throw new Error(`No importer registered for native target: ${e}`);return r.generators.importFrom(t)}var ER=d(()=>{ae();s(op,"importNativeToCanonical");});async function xa(t){if(!await j(t))return false;if(await j(join(t,OR)))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,OR)))return !0}catch{return false}return false}async function sp(t,e={}){if(!await j(t))return [];if(await j(join(t,OR))){let r=await eu(t,e);return r?[r]:[]}return Os(t,e)}var OR,ef=d(()=>{A();rl();OR="SKILL.md";s(xa,"isSkillPackLayout");s(sp,"loadSkillsAtExtendPath");});async function rf(t,e={}){return (await Ls(t,e)).filter(n=>!Cn(basename(n.source)))}async function nf(t,e={}){return (await Es(t,e)).filter(n=>!Cn(basename(n.source)))}async function of(t,e={}){return (await ks(t,e)).filter(n=>!Cn(basename(n.source)))}async function Yv(t,e={}){return Os(t,e)}var sf=d(()=>{Yc();Jc();Vc();rl();Eo();s(rf,"importAgents");s(nf,"importCommands");s(of,"importRules");s(Yv,"importSkills");});function AR(t,e){let r=t?.[e];if(!r)return [];let n=Array.isArray(r)?r:[r],o=[];for(let i of n)i.mode!=="directory"||!i.map||!i.extensions||o.push({extensions:i.extensions,map:i.map});return o}function bR(t){return t.toLowerCase().endsWith(".md")}function Zv(t,e){for(let r of AR(ot(t)?.importer,e))if(r.extensions.some(n=>!bR(n)))return true;return false}function qY(t,e){let r=new Set;for(let n of AR(ot(t)?.importer,e))for(let o of n.extensions)bR(o)||r.add(o.toLowerCase());return r}function t2(t){return vC().filter(e=>Zv(e,t))}async function n2(t,e,r){return e2[t](e,r)}async function o2(t,e,r){return r2[t](e,r)}async function s2(t,e,r,n={}){let o=AR(ot(e)?.importer,r),i=await $(t),a=new Set;for(let p of o)for(let u of p.extensions)bR(u)||a.add(u.toLowerCase());let l=i.filter(p=>[...a].some(u=>p.toLowerCase().endsWith(u))&&!Cn(basename(p)));if(l.length===0)return {entities:[],cleanup:s(async()=>{},"cleanup")};let c=await mkdtemp(join(tmpdir(),`am-tool-${r}-${e}-`)),m=s(async()=>{await rm$1(c,{recursive:true,force:true});},"cleanup");try{for(let u of l){let f=await _(u);if(f===null)continue;let g=relative(t,u).replaceAll("\\","/"),h=null;for(let I of o){if(!I.extensions.some(R=>u.toLowerCase().endsWith(R.toLowerCase())))continue;let C=await I.map({absolutePath:u,relativePath:g,content:f,destDir:c,normalizeTo:s(()=>f,"normalizeTo")});if(C){h=C;break}}h&&(await O(dirname(h.destPath)),await S(h.destPath,h.content));}return {entities:await n2(r,c,n),cleanup:m}}catch(p){throw await m(),p}}async function PR(t,e,r={}){let n=r.restrictToTarget,o=n?Zv(n,e)?[n]:[]:t2(e),i=new Set;for(let f of o)for(let g of qY(f,e))i.add(g);let a=await o2(e,t,{...r.parseOpts,handledByOtherReader:i.size>0?i:void 0}),l=[],c=s(f=>basename(f.source).replace(/\.[^.]+$/,""),"slugOf"),m=new Map;for(let f of a)m.set(c(f),f);for(let f of o){let g=await s2(t,f,e,r.parseOpts??{});l.push(g.cleanup);for(let h of g.entities){let I=c(h);m.has(I)||m.set(I,h);}}return {entities:[...m.values()].sort((f,g)=>c(f).localeCompare(c(g))),cleanup:s(async()=>{await Promise.allSettled(l.map(f=>f()));},"cleanup")}}async function af(t,e={}){let r=await PR(t,"commands",e);return {commands:[...r.entities],cleanup:r.cleanup}}async function lf(t,e={}){let r=await PR(t,"rules",e);return {rules:[...r.entities],cleanup:r.cleanup}}async function cf(t,e={}){let r=await PR(t,"agents",e);return {agents:[...r.entities],cleanup:r.cleanup}}var e2,r2,mf=d(()=>{Yc();Jc();Vc();A();ae();Eo();sf();s(AR,"directorySpecsFor");s(bR,"isMarkdownExtension");s(Zv,"hasNonMdEntityMapper");s(qY,"nonMdEntityExtensions");s(t2,"targetsWithNonMdEntityMapper");e2={rules:ks,commands:Es,agents:Ls},r2={rules:of,commands:nf,agents:rf};s(n2,"parseEntityDir");s(o2,"importEntities");s(s2,"readToolNativeEntities");s(PR,"readEntityDirWithMappers");s(af,"readCommandsDirWithMappers");s(lf,"readRulesDirWithMappers");s(cf,"readAgentsDirWithMappers");});function l2(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function c2(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 pf(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),n=basename(r),i=basename(t).replace(/\.md$/i,"");if(n==="rules")return {sliceRoot:r,implicitPick:{rules:[i]}};if(n==="commands")return {sliceRoot:r,implicitPick:{commands:[i]}};if(n==="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 DR(t,e){if(basename(t)===e)return t;let r=join(t,e);return await j(r)?r:null}async function m2(t,e,r){let n=s(async()=>{},"noop"),o=await DR(t,"rules");if(!o)return {rules:[],cleanup:n};if(!r)return {rules:await of(o,e),cleanup:n};let i=await lf(o,{parseOpts:e});return {rules:[...i.rules],cleanup:i.cleanup}}async function p2(t,e,r){let n=s(async()=>{},"noop"),o=await DR(t,"commands");if(!o)return {commands:[],cleanup:n};if(!r)return {commands:await nf(o,e),cleanup:n};let i=await af(o,{parseOpts:e});return {commands:[...i.commands],cleanup:i.cleanup}}async function u2(t,e,r){let n=s(async()=>{},"noop"),o=await DR(t,"agents");if(!o)return {agents:[],cleanup:n};if(!r)return {agents:await rf(o,e),cleanup:n};let i=await cf(o,{parseOpts:e});return {agents:[...i.agents],cleanup:i.cleanup}}async function d2(t,e){if(await xa(t))return sp(t,e);let r=join(t,"skills");return await xa(r)?sp(r,e):[]}async function uf(t,e={}){let r=s(async()=>{},"noop"),n=join(t,".agentsmesh");if(await j(n))return {canonical:await Oe(t,e),cleanup:r};let o=e.enableTargetEntityMappers??false,i=l2(),a=await m2(t,e,o);i.rules=a.rules;let l=await p2(t,e,o);i.commands=l.commands;let c=await u2(t,e,o);i.agents=c.agents,i.skills=await d2(t,e);let m=s(async()=>{await Promise.allSettled([a.cleanup(),l.cleanup(),c.cleanup()]);},"mergedCleanup");if(c2(i))throw await m(),new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md). Hint: pass --as commands|agents|rules|skills to force a kind for flat markdown directories.`);return {canonical:i,cleanup:m}}var NR=d(()=>{A();sf();mf();bi();ef();s(l2,"emptyCanonical");s(c2,"isCanonicalSliceEmpty");s(pf,"normalizeSlicePath");s(DR,"resolveEntityDir");s(m2,"parseRulesAt");s(p2,"parseCommandsAt");s(u2,"parseAgentsAt");s(d2,"loadSkillsForPartialSlice");s(uf,"loadCanonicalSliceAtPath");});async function df(t){let e=await _(t);if(!e)return "";let r=Gr(e,t);if(!r.ok)return "";let{frontmatter:n}=r.value;return typeof n.name!="string"?"":n.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function Qv(t,e){await cp$1(t,e,{recursive:true,filter:s(r=>{let n=relative(t,r).replace(/\\/g,"/");if(n==="")return true;let o=n.split("/")[0];return !(LC(o)||!n.includes("/")&&(qp(n)||OC(n)))},"filter")});}var FR=d(()=>{A();K();Eo();s(df,"readSkillFrontmatterName");s(Qv,"cpFilteredSkill");});function vR(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function h2(t){let e={...t},r=t.alwaysApply===true;if(e.root=r,delete e.alwaysApply,!r){let n=vR(t.globs),o=typeof t.description=="string"?t.description.trim():"";n.length>0?e.trigger="glob":o.length>0?e.trigger="model_decision":e.trigger="manual";}return e}function y2(t){let e={...t};return e.trigger==="always"&&(e.trigger="always_on"),typeof e.glob=="string"&&(e.globs=vR(e.globs).length>0?vR(e.globs):[e.glob],delete e.glob),e}function MR(t){let e=Gr(t,"<mdc>");if(!e.ok)return e.bodyFallback;let{frontmatter:r,body:n}=e.value;if(Object.keys(r).length===0&&!t.startsWith("---"))return t;let o;return "alwaysApply"in r?o=h2(r):"trigger"in r||"glob"in r?o=y2(r):o=r,T(o,n.trim())}var qv=d(()=>{K();s(vR,"toStrArray");s(h2,"normalizeCursorKeys");s(y2,"normalizeWindsurfKeys");s(MR,"normalizeMdcToCanonical");});function $R(t){return t.toLowerCase().replace(/[^a-z0-9.-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function GR(t){return t.toLowerCase().endsWith(".mdc")?basename(t).replace(/\.mdc$/i,".md"):basename(t)}function eM(t,e,r){let o=relative(t,e).replace(/\\/g,"/").split("/");if(o.pop(),o.length===0)return r;let i=$R(o[o.length-1]);return i?`${i}-${r}`:r}var rM=d(()=>{s($R,"sanitizeNameSegment");s(GR,"computeDestName");s(eM,"namespacedName");});async function C2(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await O(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:s(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}function iM(t,e){let r=t.toLowerCase();return !!(r.endsWith(".md")||e&&r.endsWith(".mdc"))}async function k2(t,e,r){if(!iM(t,r))throw new Error(`Manual install only supports .md files for this collection: ${t}`);if(await O(e),t.toLowerCase().endsWith(".mdc")){let n=await _(t);if(!n)return;let o=basename(t).replace(/\.mdc$/i,".md");await writeFile(join(e,o),MR(n));}else await cp$1(t,join(e,basename(t)));}async function E2(t,e,r){if((await stat(t)).isFile())return k2(t,e,r);let o=(await $(t)).filter(l=>iM(l,r)&&!Cn(basename(l)));if(o.length===0)throw new Error(`No installable files found under ${t} for manual install. Try a different --path to point at the directory holding *.md (or *.mdc) files, or omit --as so agentsmesh can auto-detect the layout.`);let i=new Map;for(let l of o){let c=GR(l);i.set(c,(i.get(c)??0)+1);}let a=new Map;await O(e);for(let l of o){let c=GR(l),p=(i.get(c)??0)>1?eM(t,l,c):c;if(a.has(p)&&a.get(p)!==l){let f=relative(t,l).replace(/\\/g,"/").split("/").map($R).filter(Boolean),g=c.includes(".")?"."+c.split(".").pop():"";p=f.join("-").replace(/\.(md|mdc)$/i,"")+g||p;}if(a.has(p))throw new Error(`Manual install could not resolve duplicate name "${p}" under ${t} (${a.get(p)} and ${l}).`);if(a.set(p,l),l.toLowerCase().endsWith(".mdc")){let f=await _(l);if(!f)continue;await writeFile(join(e,p),MR(f));}else await cp$1(l,join(e,p));}}async function nM(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await $(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),l=basename(a);if(!n.has(l))continue;let c=o.get(l);if(c&&c!==a)throw new Error(`Manual skill replay found duplicate skill "${l}" under ${t} (${c} and ${a}).`);o.set(l,a);}if(o.size!==r.length)return false;await O(e);for(let i of r)await cp$1(o.get(i),join(e,i),{recursive:true});return true}async function L2(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 o=basename(dirname(t)),i=join(e,o);await O(i),await cp$1(dirname(t),i,{recursive:true});return}if(await xa(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await nM(t,e,r.preferredSkillNames??[]))return;let l=await df(join(t,"SKILL.md"))||basename(t),c=join(e,l);await O(e),await Qv(t,c);return}if(await nM(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await $(t),i=new Set;for(let a of o.filter(l=>l.endsWith("/SKILL.md")||l.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}.`)}async function gf(t,e,r={}){let n=await C2();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await L2(t,o,r):await E2(t,o,e==="rules"),n}catch(o){throw await n.cleanup(),o}}var UR=d(()=>{A();ef();FR();Eo();qv();rM();s(C2,"createStageRoot");s(iM,"isAcceptedFile");s(k2,"stageSingleFile");s(E2,"stageMarkdownCollection");s(nM,"stagePreferredSkills");s(L2,"stageSkills");s(gf,"stageManualInstallScope");});function O2(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function aM(t){let e=t.resolvedPath;if(t.as!==void 0){let o=t.path?join(e,t.path):e;if(!await j(o))throw new Error(`Extend "${t.name}": path does not exist: ${o}`);let i=await gf(o,t.as);try{return Oe(join(i.discoveryRoot,".agentsmesh"))}finally{await i.cleanup();}}if(!t.path){let o=join(e,".agentsmesh");if(!await j(o)){if(await xa(e)){let a=await sp(e);return {...O2(),skills:a}}let i=t.target??await tf(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
148
+ Expected one of: .agentsmesh/, ${Jv.join(", ")}.`);y.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await op(e,i);}return Oe(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 o=join(e,".agentsmesh");return await j(o)||(y.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await op(e,t.target)),Oe(e)}let{sliceRoot:n}=await pf(r);try{let{canonical:o}=await uf(n);return o}catch(o){let i=o instanceof Error?o.message:String(o),a=new Error(`Extend "${t.name}": ${i}`);throw o instanceof Error&&(a.cause=o),a}}var lM=d(()=>{kR();A();st();bi();ER();ef();NR();UR();s(O2,"emptyCanonical");s(aM,"loadCanonicalForExtend");});function hf(t,e,r,n){if(!r)return t;let o={...t};if(r.skills?.length&&e.includes("skills")){let i=new Set(r.skills),a=o.skills;o={...o,skills:a.filter(l=>i.has(l.name))};for(let l of r.skills)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in skills from extend "${n}".`);}if(r.commands?.length&&e.includes("commands")){let i=new Set(r.commands),a=o.commands;o={...o,commands:a.filter(l=>i.has(l.name))};for(let l of r.commands)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in commands from extend "${n}".`);}if(r.agents?.length&&e.includes("agents")){let i=new Set(r.agents),a=o.agents;o={...o,agents:a.filter(l=>i.has(l.name))};for(let l of r.agents)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in agents from extend "${n}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=o.rules,l=s(c=>basename(c).replace(/\.md$/i,""),"stem");o={...o,rules:a.filter(c=>i.has(l(c.source)))};for(let c of r.rules)a.some(m=>l(m.source)===c)||y.warn(`[agentsmesh] pick name "${c}" not found in rules from extend "${n}".`);}return o}var BR=d(()=>{st();s(hf,"applyExtendPick");});var b2,fc,yf=d(()=>{b2=["rules","commands","agents","skills"],fc=z$1.enum(b2);});var P2,cM,mM=d(()=>{So();yf();P2=z$1.enum(["github","gitlab","git","local"]),cM=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:P2,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(Za).min(1),pick:Uc.optional(),target:nr.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:fc.optional(),content_hash:z$1.string(),license:z$1.string().nullable().optional()});});function pM(t){let e=wi(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 x2(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}async function gi(t){let e=join(t,"pack.yaml"),r=await _(e);if(r===null)return null;try{let n=parse(r);return cM.parse(n)}catch{return null}}async function dM(t,e,r){if(!await j(t))return null;let n=pM(e),o;try{o=await readdir(t,{withFileTypes:!0});}catch{return null}for(let i of o){if(!i.isDirectory())continue;let a=join(t,i.name),l=await gi(a);if(l&&pM(l.source)===n&&l.target===r.target&&l.as===r.as&&x2(l.features,r.features))return {meta:l,packDir:a,name:l.name}}return null}async function _f(t){if(!await j(t))return [];let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory())continue;let o=join(t,n.name),i=await gi(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}var gc=d(()=>{A();mM();Wc();s(pM,"sourceIdentity");s(x2,"sameFeatures");s(gi,"readPackMetadata");s(dM,"findExistingPack");s(_f,"listPacks");});function fM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function D2(t){let[e,r,n,o,i,a,l,c]=await Promise.all([ks(join(t,"rules")),Es(join(t,"commands")),Ls(join(t,"agents")),Os(join(t,"skills")),jr(join(t,"mcp.json")),ru(join(t,"permissions.yaml")),nu(join(t,"hooks.yaml")),ou(join(t,"ignore"))]);return {...fM(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:l,ignore:c}}async function gM(t){let e=join(t,"packs"),r=await _f(e),n=fM();for(let{meta:o,packDir:i}of r){let a=await D2(i),l=WR(a,o.features),c=hf(l,o.features,o.pick,o.name);n=nl(n,c);}return n}var hM=d(()=>{Vc();Jc();Yc();rl();Xc();jg();Bg();Kg();Hg();ho();BR();gc();s(fM,"emptyCanonical");s(D2,"loadPackCanonical");s(gM,"loadPacksCanonical");});function WR(t,e){if(e.length===0)return yM();let r=new Set(e.flatMap(n=>F2[n]??[]));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 yM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function Ee(t,e,r={},n=join(e,".agentsmesh")){let o=await tl(t,e,{refreshCache:r.refreshRemoteCache===true}),i=yM();for(let c of o){let m=await aM(c),p=WR(m,c.features),u=hf(p,c.features,c.pick,c.name);i=nl(i,u);}let a=await gM(n);i=nl(i,a);let l=await Oe(n);return i=nl(i,l),{canonical:i,resolvedExtends:o}}var F2,ho=d(()=>{Jp();bi();Hg();lM();BR();hM();F2={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(WR,"filterCanonicalByFeatures");s(yM,"emptyCanonical");s(Ee,"loadCanonicalWithExtends");});function xX(t,e){let r=join(e,"node_modules",t),n=join(r,"package.json");if(!existsSync(n))throw new Error(`Cannot find package '${t}' in ${join(e,"node_modules")}`);let o=JSON.parse(readFileSync(n,"utf-8")),i=(typeof o.exports=="string"?o.exports:null)??(typeof o.main=="string"?o.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 DX(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}function XM(t){try{return realpathSync(t)}catch{return t}}function ZM(t,e){let r=XM(resolve(e)),n=XM(t);if(!(n===r||n.startsWith(`${r}${sep}`)))throw new Error(`Plugin source resolves outside project root (escapes ${r}): ${n}`)}async function NX(t,e){let{source:r}=t,n;if(DX(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);ZM(a,e),n=pathToFileURL(a).href;}else {let i=xX(r,e);ZM(i,e),n=pathToFileURL(i).href;}return await import(n)}function FX(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function Tf(t,e){let r;try{r=await NX(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=FX(r),o=[];for(let i of n)try{let a=su(i);au(a),o.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:o}}async function QM(t,e){let r=[],n=process.env.AGENTSMESH_STRICT_PLUGINS==="1"||process.env.AGENTSMESH_STRICT_PLUGINS==="true",i=(await Promise.all(t.map(async a=>{try{let l=await Tf(a,e);return r.push(l),null}catch(l){let c=`Plugin '${a.source}' failed to load: ${l instanceof Error?l.message:String(l)}`;return a.strict===true||n?new Error(c):(y.warn(c),null)}}))).filter(a=>a!==null);if(i.length>0){let a=i.map(l=>` - ${l.message}`).join(`
147
149
  `);throw new Error(`agentsmesh: ${i.length} plugin(s) failed strict load:
148
- ${a}`)}return r}var BR=d(()=>{xg();se();ot();s(h2,"resolveNpmSpecifier");s(y2,"isLocalSource");s(KM,"canonicalize");s(WM,"assertSourceInsideProjectRoot");s(_2,"importPluginModule");s(R2,"extractDescriptors");s(_f,"loadPlugin");s(HM,"loadAllPlugins");});async function Wt(t,e){t.plugins.length!==0&&await HM(t.plugins,e);}var fn=d(()=>{BR();s(Wt,"bootstrapPlugins");});function HR(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,l;switch(i){case "rules":l=e.rules.length,a="rules";break;case "commands":l=e.commands.length,a=l>0?`commands (${l})`:"commands";break;case "agents":l=e.agents.length,a=l>0?`agents (${l})`:"agents";break;case "skills":l=e.skills.length,a=l>0?`skills (${l})`:"skills";break;case "mcp":l=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=l>0?`mcp (${l} servers)`:"mcp";break;case "hooks":l=B2(e.hooks),a=l>0?`hooks (${l})`:"hooks";break;case "ignore":l=e.ignore.length>0?1:0,a="ignore";break;case "permissions":l=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let c={};for(let m of o)c[m]=jd(m,i,t,r);if(n.push({feature:a,count:l,support:c}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of o)p[u]=jd(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}function B2(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var t$=d(()=>{Pt();s(HR,"buildCompatibilityMatrix");s(B2,"countHooks");});function e$(t){return K2[t]??t}var K2,r$=d(()=>{K2={"claude-code":"Claude"};s(e$,"matrixColumnLabel");});function n$(t){return Object.fromEntries(W2.map(e=>[e,Object.fromEntries(Ft.map(r=>{let o=mi(r,t)?.[e];return [r,o??{level:"none"}]}))]))}function H2(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function z2(t,e){return H2()?e:`${t}${e}${sp.reset}`}function s$(t){let e=zR[t];return z2(V2[t],e)}var W2,o$,zR,sp,V2,VR=d(()=>{Rn();Pt();W2=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(n$,"buildSupportMatrix");o$=n$("project"),n$("global"),zR={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},sp={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(H2,"noColor");s(z2,"colorize");V2={native:sp.green,embedded:sp.blue,partial:sp.yellow,none:sp.dim};s(s$,"coloredSymbol");});function JR(t,e){let r=process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!=="",n={cyan:"\x1B[36m",magenta:"\x1B[35m",bold:"\x1B[1m",dim:"\x1B[2m",green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",reset:"\x1B[0m"},o=s((z,Q)=>r?Q:`${z}${Q}${n.reset}`,"c"),i=s(z=>z.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((z,Q)=>{let at=i(z),At=Math.max(0,Q-at);return z+" ".repeat(At)},"padWithColor"),l=Math.max(12,...e.map(z=>z.length)),c=e.map(z=>e$(z)),m=Math.max(8,l),p=Math.max(12,...t.map(z=>z.feature.length)),u=s(z=>o(n.dim,"\u250C"+z.map(Q=>"\u2500".repeat(Q)).join("\u252C")+"\u2510"),"border"),f=s(z=>o(n.dim,"\u251C"+z.map(Q=>"\u2500".repeat(Q)).join("\u253C")+"\u2524"),"sep"),g=s(z=>o(n.dim,"\u2514"+z.map(Q=>"\u2500".repeat(Q)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],R=u(h),C=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(z=>a(o(n.bold+n.magenta,z),m))],S=o(n.dim,"\u2502")+C.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),k=f(h),P=t.map(z=>{let Q=[a(o(n.cyan,z.feature),p)];for(let at of e){let At=z.support[at]??"none",wt=r?zR[At]:s$(At);Q.push(a(` ${wt} `,m));}return o(n.dim,"\u2502")+Q.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),N=g(h),F=[R,S,k,...P,N];F.push("");let W=[o(n.green,"\u2713")+" = native",o(n.blue,"\u25C6")+" = embedded",o(n.yellow,"\u25D0")+" = partial",o(n.dim,"\u2013")+" = not supported"];return F.push(o(n.bold,"Legend: ")+W.join(" ")),F.join(`
149
- `)}var i$=d(()=>{r$();VR();s(JR,"formatMatrix");});function XR(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((n,o)=>n+(Array.isArray(o)?o.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?"":`
150
+ ${a}`)}return r}var rI=d(()=>{zg();ae();st();s(xX,"resolveNpmSpecifier");s(DX,"isLocalSource");s(XM,"canonicalize");s(ZM,"assertSourceInsideProjectRoot");s(NX,"importPluginModule");s(FX,"extractDescriptors");s(Tf,"loadPlugin");s(QM,"loadAllPlugins");});async function Gt(t,e){t.plugins.length!==0&&await QM(t.plugins,e);}var Mr=d(()=>{rI();s(Gt,"bootstrapPlugins");});function sI(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,l;switch(i){case "rules":l=e.rules.length,a="rules";break;case "commands":l=e.commands.length,a=l>0?`commands (${l})`:"commands";break;case "agents":l=e.agents.length,a=l>0?`agents (${l})`:"agents";break;case "skills":l=e.skills.length,a=l>0?`skills (${l})`:"skills";break;case "mcp":l=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=l>0?`mcp (${l} servers)`:"mcp";break;case "hooks":l=oZ(e.hooks),a=l>0?`hooks (${l})`:"hooks";break;case "ignore":l=e.ignore.length>0?1:0,a="ignore";break;case "permissions":l=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let c={};for(let m of o)c[m]=qd(m,i,t,r);if(n.push({feature:a,count:l,support:c}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of o)p[u]=qd(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}function oZ(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var a$=d(()=>{Pt();s(sI,"buildCompatibilityMatrix");s(oZ,"countHooks");});function l$(t){return sZ[t]??t}var sZ,c$=d(()=>{sZ={"claude-code":"Claude"};s(l$,"matrixColumnLabel");});function m$(t){return Object.fromEntries(iZ.map(e=>[e,Object.fromEntries(vt.map(r=>{let o=pi(r,t)?.[e];return [r,o??{level:"none"}]}))]))}function aZ(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function lZ(t,e){return aZ()?e:`${t}${e}${cp.reset}`}function u$(t){let e=iI[t];return lZ(cZ[t],e)}var iZ,p$,iI,cp,cZ,aI=d(()=>{Sn();Pt();iZ=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(m$,"buildSupportMatrix");p$=m$("project"),m$("global"),iI={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},cp={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(aZ,"noColor");s(lZ,"colorize");cZ={native:cp.green,embedded:cp.blue,partial:cp.yellow,none:cp.dim};s(u$,"coloredSymbol");});function lI(t,e){let r=process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!=="",n={cyan:"\x1B[36m",magenta:"\x1B[35m",bold:"\x1B[1m",dim:"\x1B[2m",green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",reset:"\x1B[0m"},o=s((U,q)=>r?q:`${U}${q}${n.reset}`,"c"),i=s(U=>U.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((U,q)=>{let nt=i(U),M=Math.max(0,q-nt);return U+" ".repeat(M)},"padWithColor"),l=Math.max(12,...e.map(U=>U.length)),c=e.map(U=>l$(U)),m=Math.max(8,l),p=Math.max(12,...t.map(U=>U.feature.length)),u=s(U=>o(n.dim,"\u250C"+U.map(q=>"\u2500".repeat(q)).join("\u252C")+"\u2510"),"border"),f=s(U=>o(n.dim,"\u251C"+U.map(q=>"\u2500".repeat(q)).join("\u253C")+"\u2524"),"sep"),g=s(U=>o(n.dim,"\u2514"+U.map(q=>"\u2500".repeat(q)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],I=u(h),k=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(U=>a(o(n.bold+n.magenta,U),m))],C=o(n.dim,"\u2502")+k.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),R=f(h),P=t.map(U=>{let q=[a(o(n.cyan,U.feature),p)];for(let nt of e){let M=U.support[nt]??"none",tt=r?iI[M]:u$(M);q.push(a(` ${tt} `,m));}return o(n.dim,"\u2502")+q.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),N=g(h),F=[I,C,R,...P,N];F.push("");let B=[o(n.green,"\u2713")+" = native",o(n.blue,"\u25C6")+" = embedded",o(n.yellow,"\u25D0")+" = partial",o(n.dim,"\u2013")+" = not supported"];return F.push(o(n.bold,"Legend: ")+B.join(" ")),F.join(`
151
+ `)}var d$=d(()=>{c$();aI();s(lI,"formatMatrix");});function mI(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((n,o)=>n+(Array.isArray(o)?o.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?"":`
150
152
  Per-file details:
151
153
  `+e.join(`
152
154
  `)+`
153
- `}var a$=d(()=>{s(XR,"formatVerboseDetails");});var ZR=d(()=>{t$();i$();a$();});var QR={};og(QR,{runMatrix:()=>ip});async function ip(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(f=>f.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Wt(a,r);let{canonical:c}=await ke(a,l.configDir,{},l.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=HR(a,c,n),u=XR(c);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var ap=d(()=>{Yt();fo();ZR();fn();s(ip,"runMatrix");});var qR={};og(qR,{renderMatrix:()=>lp});function lp(t,e){if(t.data.features.length===0){y.info("No features enabled. Enable features in agentsmesh.yaml.");return}let r=t.data.features.map(o=>({feature:o.name,count:0,support:o.support})),n=JR(r,t.data.targets);process.stdout.write(n),process.stdout.write(`
155
+ `}var f$=d(()=>{s(mI,"formatVerboseDetails");});var pI=d(()=>{a$();d$();f$();});var uI={};_g(uI,{runMatrix:()=>mp});async function mp(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(f=>f.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Gt(a,r);let{canonical:c}=await Ee(a,l.configDir,{},l.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=sI(a,c,n),u=mI(c);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var pp=d(()=>{Zt();ho();pI();Mr();s(mp,"runMatrix");});var dI={};_g(dI,{renderMatrix:()=>up});function up(t,e){if(t.data.features.length===0){y.info("No features enabled. Enable features in agentsmesh.yaml.");return}let r=t.data.features.map(o=>({feature:o.name,count:0,support:o.support})),n=lI(r,t.data.targets);process.stdout.write(n),process.stdout.write(`
154
156
  `),e?.verbose&&t.verboseDetails&&(process.stdout.write(t.verboseDetails),process.stdout.write(`
155
- `));}var cp=d(()=>{ot();ZR();s(lp,"renderMatrix");});function RS(t){let e=Object.keys(t);return {async route(r,n,o){let i=t[r];if(i){await i(n,o);return}throw new Error(`Unknown command "${r}". Available: ${e.join(", ")}`)},commands:s(()=>[...e],"commands")}}s(RS,"createRouter");ot();var sg=[{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)"}],ig=[{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 rules/commands/agents/skills from a local path or remote repo. Auto-classifies anthropic-skill-pack / canonical-agentsmesh / tool-native sources. When auto-detection is ambiguous or refuses a non-standard layout, override with: --path <dir> to narrow scope, --as <kind> to force a flat collection (rules|commands|agents|skills), --target <id> to lock the native importer, or --all to install every sub-pack of a marketplace.",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:"--all",description:"Install every sub-pack from a marketplace source"},{name:"--force",description:"Non-interactive mode; include invalid resources and skip selection prompts (implied by --json)"}]},{name:"installs",usage:"agentsmesh installs <subcommand> [flags]",description:"Read-only inventory of installed packs (subcommands: list)",flags:[{name:"list",description:"List installed packs (NAME, SOURCE, FEATURES, INSTALLED)"},{name:"--global",description:"Read from ~/.agentsmesh/installs.yaml"}]},{name:"uninstall",usage:"agentsmesh uninstall <name>[,<name>...] [flags]",description:"Remove an installed pack; cleans installs.yaml, extends, and generated outputs",flags:[{name:"<name>",description:"Install entry name from installs.yaml (comma-separated for batch)"},{name:"--all",description:"Remove every installed pack in this scope"},{name:"--keep-pack",description:"Keep .agentsmesh/packs/<name>/ on disk; only drop yaml/extends entries"},{name:"--keep-generated",description:"Skip the post-uninstall generate pass; warn about stale target files"},{name:"--global",description:"Uninstall from ~/.agentsmesh/"},{name:"--dry-run",description:"Preview removal plan; no writes"},{name:"--force",description:"Non-interactive mode; accept all prompts (delete-anyway on modifications). 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 Ep(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
156
- `)}s(Ep,"formatFlags");function ag(){let t=ig.map(e=>`- ${e.name.padEnd(8)} ${e.description}
157
+ `));}var dp=d(()=>{st();pI();s(up,"renderMatrix");});function OS(t){let e=Object.keys(t);return {async route(r,n,o){let i=t[r];if(i){await i(n,o);return}throw new Error(`Unknown command "${r}". Available: ${e.join(", ")}`)},commands:s(()=>[...e],"commands")}}s(OS,"createRouter");st();var Rg=[{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)"}],Ig=[{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 rules/commands/agents/skills from a local path or remote repo. Auto-classifies anthropic-skill-pack / canonical-agentsmesh / tool-native sources. When auto-detection is ambiguous or refuses a non-standard layout, override with: --path <dir> to narrow scope, --as <kind> to force a flat collection (rules|commands|agents|skills), --target <id> to lock the native importer, or --all to install every sub-pack of a marketplace.",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:"--all",description:"Install every sub-pack from a marketplace source"},{name:"--force",description:"Non-interactive mode; include invalid resources and skip selection prompts (implied by --json)"}]},{name:"installs",usage:"agentsmesh installs <subcommand> [flags]",description:"Read-only inventory of installed packs (subcommands: list)",flags:[{name:"list",description:"List installed packs (NAME, SOURCE, FEATURES, INSTALLED)"},{name:"--global",description:"Read from ~/.agentsmesh/installs.yaml"}]},{name:"uninstall",usage:"agentsmesh uninstall <name>[,<name>...] [flags]",description:"Remove an installed pack; cleans installs.yaml, extends, and generated outputs",flags:[{name:"<name>",description:"Install entry name from installs.yaml (comma-separated for batch)"},{name:"--all",description:"Remove every installed pack in this scope"},{name:"--keep-pack",description:"Keep .agentsmesh/packs/<name>/ on disk; only drop yaml/extends entries"},{name:"--keep-generated",description:"Skip the post-uninstall generate pass; warn about stale target files"},{name:"--global",description:"Uninstall from ~/.agentsmesh/"},{name:"--dry-run",description:"Preview removal plan; no writes"},{name:"--force",description:"Non-interactive mode; accept all prompts (delete-anyway on modifications). Implied by --json."}]},{name:"refresh",usage:"agentsmesh refresh [<name>...] [flags]",description:"Re-fetch and re-apply installed packs from their recorded sources",flags:[{name:"<name>",description:"Pack name(s) to refresh (defaults to all installed packs)"},{name:"--dry-run",description:"Preview what would be refreshed without writing"},{name:"--force",description:"Skip drift-consent prompts; refresh even modified packs"},{name:"--global",description:"Refresh packs installed in ~/.agentsmesh/"}]},{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 Mp(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
158
+ `)}s(Mp,"formatFlags");function Sg(){let t=Ig.map(e=>`- ${e.name.padEnd(8)} ${e.description}
157
159
  Usage: ${e.usage}
158
- ${Ep(e.flags)}`).join(`
160
+ ${Mp(e.flags)}`).join(`
159
161
 
160
162
  `);y.info(`agentsmesh <command> [flags]
161
163
 
162
164
  Global flags:
163
- ${Ep(sg)}
165
+ ${Mp(Rg)}
164
166
 
165
167
  Commands:
166
168
  ${t}
167
169
 
168
- Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(ag,"printHelp");function Lp(t){let e=ig.find(r=>r.name===t);if(!e){ag();return}y.info(`${e.usage}
170
+ Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(Sg,"printHelp");function $p(t){let e=Ig.find(r=>r.name===t);if(!e){Sg();return}y.info(`${e.usage}
169
171
 
170
172
  ${e.description}
171
173
 
172
174
  Command flags:
173
- ${Ep(e.flags)}
175
+ ${Mp(e.flags)}
174
176
 
175
177
  Global flags:
176
- ${Ep(sg)}`);}s(Lp,"printCommandHelp");var Op;function S0(){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(S0,"readPackageVersion");function C0(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(C0,"getVersionFallback");function Ci(){return Op||(Op=S0()??C0(),Op)}s(Ci,"getVersion");function ES(){process.stdout.write(`agentsmesh v${Ci()}
177
- `);}s(ES,"printVersion");ot();function Ha(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)+`
178
- `);}s(Ha,"emitJson");var yn=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function LS(t,e){let r=t instanceof yn?2:1;if(e?.json)return Ha(e.command??"unknown",{success:false,error:t.message}),process.exit(r);e?.verbose&&t.stack?process.stderr.write(t.stack+`
179
- `):y.error(t.message),process.exit(r);}s(LS,"handleError");ot();function ge(t,e,r,n){if(r.json===true){let o=e.exitCode===0;Ha(t,o?{success:true,data:e.data}:{success:false,error:`Command '${t}' failed`,data:e.data}),process.exit(e.exitCode);return}n(),e.exitCode!==0&&process.exit(e.exitCode);}s(ge,"handleResult");Yt();fo();w();bp();function af(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(af,"hashContent");async function lf(t){try{let e=await readFile(t);return createHash("sha256").update(e).digest("hex")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(lf,"hashFile");async function cf(t){try{if(!Ap(t)){let r=await readFile(t);return createHash("sha256").update(r).digest("hex")}let e=await readFile(t,"utf-8");return e.startsWith(Ja)&&(e=e.slice(Ja.length)),e=wp(e),createHash("sha256").update(e,"utf8").digest("hex")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(cf,"hashFileForManifest");fc();var DR=".lock",kX=[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 EX(t){return t.startsWith("packs/")?false:kX.some(e=>e(t))}s(EX,"isCanonical");var LX={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 mf(t){let e=join(t,DR),r=await _(e);if(r===null)return null;try{let n=parse(r);return !n||typeof n!="object"?null:{generatedAt:String(n.generated_at??""),generatedBy:String(n.generated_by??""),libVersion:String(n.lib_version??""),checksums:n.checksums&&typeof n.checksums=="object"?n.checksums:{},extends:n.extends&&typeof n.extends=="object"?n.extends:{},packs:n.packs&&typeof n.packs=="object"?n.packs:{}}}catch{return null}}s(mf,"readLock");async function pf(t,e){let r=join(t,DR),n={generated_at:e.generatedAt,generated_by:e.generatedBy,lib_version:e.libVersion,checksums:e.checksums,extends:e.extends,packs:e.packs},o=`# Auto-generated. DO NOT EDIT MANUALLY.
178
+ ${Mp(Rg)}`);}s($p,"printCommandHelp");var Gp;function F0(){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(F0,"readPackageVersion");function v0(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(v0,"getVersionFallback");function Ei(){return Gp||(Gp=F0()??v0(),Gp)}s(Ei,"getVersion");function TS(){process.stdout.write(`agentsmesh v${Ei()}
179
+ `);}s(TS,"printVersion");st();function za(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)+`
180
+ `);}s(za,"emitJson");var Rn=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function xS(t,e){let r=t instanceof Rn?2:1;if(e?.json)return za(e.command??"unknown",{success:false,error:t.message}),process.exit(r);e?.verbose&&t.stack?process.stderr.write(t.stack+`
181
+ `):y.error(t.message),process.exit(r);}s(xS,"handleError");st();function ie(t,e,r,n){if(r.json===true){let o=e.exitCode===0;za(t,o?{success:true,data:e.data}:{success:false,error:`Command '${t}' failed`,data:e.data}),process.exit(e.exitCode);return}n(),e.exitCode!==0&&process.exit(e.exitCode);}s(ie,"handleResult");Zt();ho();A();Bp();function If(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(If,"hashContent");async function Sf(t){try{let e=await readFile(t);return createHash("sha256").update(e).digest("hex")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(Sf,"hashFile");async function Cf(t){try{if(!jp(t)){let r=await readFile(t);return createHash("sha256").update(r).digest("hex")}let e=await readFile(t,"utf-8");return e.startsWith(Ya)&&(e=e.slice(Ya.length)),e=Up(e),createHash("sha256").update(e,"utf8").digest("hex")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(Cf,"hashFileForManifest");gc();var VR=".lock",G2=[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 j2(t){return t.startsWith("packs/")?false:G2.some(e=>e(t))}s(j2,"isCanonical");var U2={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 kf(t){let e=join(t,VR),r=await _(e);if(r===null)return null;try{let n=parse(r);return !n||typeof n!="object"?null:{generatedAt:String(n.generated_at??""),generatedBy:String(n.generated_by??""),libVersion:String(n.lib_version??""),checksums:n.checksums&&typeof n.checksums=="object"?n.checksums:{},extends:n.extends&&typeof n.extends=="object"?n.extends:{},packs:n.packs&&typeof n.packs=="object"?n.packs:{}}}catch{return null}}s(kf,"readLock");async function Ef(t,e){let r=join(t,VR),n={generated_at:e.generatedAt,generated_by:e.generatedBy,lib_version:e.libVersion,checksums:e.checksums,extends:e.extends,packs:e.packs},o=`# Auto-generated. DO NOT EDIT MANUALLY.
180
182
  # Tracks the state of all config files for team conflict resolution.
181
183
 
182
- `+stringify(n);await I(r,o);}s(pf,"writeLock");async function ys(t){if(!await $(t))return {};let e=await v(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===DR||!EX(o))continue;let i=await lf(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(ys,"buildChecksums");function uf(t,e,r){if(r.length===0)return [];let n=r.map(a=>LX[a]).filter(a=>a!==void 0);if(n.length===0)return [];let o=new Set([...Object.keys(t),...Object.keys(e)]),i=[];for(let a of o)n.some(l=>l(a))&&t[a]!==e[a]&&i.push(a);return i}s(uf,"detectLockedFeatureViolations");async function df(t){let e=await of(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(df,"buildPackChecksums");async function gc(t){let e={};for(let r of t){if(r.version!==void 0){e[r.name]=r.version;continue}let n=join(r.resolvedPath,".agentsmesh"),o=await ys(n),i=Object.keys(o).sort().map(c=>`${c}:${o[c]}`).join(`
183
- `),a=af(i),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}s(gc,"buildExtendChecksums");Pt();se();function hc(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(hc,"getAdditionalRootDecorationPaths");function pM(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(pM,"resolveRewriteFamilyId");ae();Jg();function OX(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(OX,"addDirectoryMapping");function uM(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)OX(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}s(uM,"addSkillDirectoryMappings");Pt();function dM(t,e,r="project"){let n=Gt(t,r);if(!n)return null;if(e.root)return n.rootInstructionPath??null;if(e.targets.length>0&&!e.targets.includes(t))return null;let o=posix.basename(e.source.replace(/\\/g,"/"),".md");return n.paths.rulePath(o,e)}s(dM,"ruleTargetPath");function fM(t,e,r,n="project"){let o=Gt(t,n);return o?o.paths.commandPath(e,r):null}s(fM,"commandTargetPath");function gM(t,e,r,n="project"){let o=Gt(t,n);return o?o.paths.agentPath(e,r):null}s(gM,"agentTargetPath");de();Jt();Se();Pt();function bX(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(bX,"addDirectoryMapping");function NR(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=dM(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=fM(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=gM(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let i=qm(t,n);if(!i)return o;for(let a of e.skills){bX(o,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let l of a.supportingFiles){let c=l.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${c}`,p=`${i}/${a.name}/${c}`;o.set(m,p),uM(o,m,p);}}return o}s(NR,"buildReferenceMap");ae();ae();Pt();function yM(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(yM,"addPackAbsoluteDirMapping");function PX(t){let e=new Set;for(let{relativePath:r}of t){let n=r.replace(/\\/g,"/"),o=posix.dirname(n);for(;o!=="."&&o.length>0;){e.add(o);let i=posix.dirname(o);if(i===o)break;o=i;}}return [...e]}s(PX,"skillSupportingDirPrefixes");function _M(t,e,r,n,o){let i=qm(e,o);if(!i)return;let a=nt(n),l=a.join(n,".agentsmesh","packs");for(let c of r.skills){let m=a.dirname(c.source);if(!m.startsWith(l))continue;let p=a.normalize(a.join(n,i,c.name));yM(t,m,p,a),t.set(a.normalize(c.source),a.normalize(a.join(p,"SKILL.md")));for(let u of c.supportingFiles){let f=a.normalize(a.join(p,u.relativePath));t.set(a.normalize(u.absolutePath),f);}for(let u of PX(c.supportingFiles))yM(t,a.join(m,u),a.join(p,u),a);}}s(_M,"addPackSkillArtifactMappings");ae();function TX(t){return `.agentsmesh/rules/${basename(t.source)}`}s(TX,"canonicalRulePath");function xX(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(xX,"copilotInstructionsPath");function IM(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let i=nt(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,TX(a))),i.normalize(i.join(r,xX(a))));}s(IM,"applyCopilotInstructionArtifactRefs");Pt();function FR(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(FR,"pushUnique");function SM(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);FR(o,i);let a=Gt(t,n);if(e.root)for(let l of hc(a))FR(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])FR(o,l);return o}s(SM,"extraRuleOutputPaths");Pt();function CM(t,e,r,n,o,i){let a=Gt(t,e);if(!a?.mirrorGlobalPath)return;let l=a.mirrorGlobalPath(r,i??[]),c=l===null?[]:Array.isArray(l)?l:[l];for(let m of c)m!==r&&o.set(m,n);}s(CM,"addSkillMirrorSourceEntry");function NX(t){return `.agentsmesh/commands/${t.name}.md`}s(NX,"canonicalCommandPath");function FX(t){return `.agentsmesh/agents/${t.name}.md`}s(FX,"canonicalAgentPath");function vX(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(vX,"canonicalSkillPath");function kM(t,e,r,n,o,i){let a=i?.scope??"project",l=nt(n),c=new Map([...NR(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return IM(t,c,n,o,e),_M(c,t,e,n,a),c}s(kM,"buildArtifactPathMap");function EM(t,e,r,n="project",o){let i=NR(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of SM(t,l,i,n))a.set(c,l.source);for(let l of e.commands){let c=i.get(NX(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=i.get(FX(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=i.get(vX(l));c&&(a.set(c,l.source),CM(t,n,c,l.source,a,o));for(let m of l.supportingFiles){let p=`.agentsmesh/skills/${l.name}/${m.relativePath.replace(/\\/g,"/")}`,u=i.get(p);u&&(a.set(u,m.absolutePath),CM(t,n,u,m.absolutePath,a,o));}}return a}s(EM,"buildOutputSourceMap");Pt();se();Ng();function GX(t,e){if(!e)return null;for(let r of e){let n=et(r);if(n?.sharedArtifacts){for(let[o,i]of Object.entries(n.sharedArtifacts))if(i==="owner"&&t.startsWith(o))return r}}return null}s(GX,"findSharedArtifactOwner");function LM(t,e,r){if(e==="global"){let n=GX(t.path,r);if(n)return n;let o=DC(t.path);if(o)return o}return t.target}s(LM,"artifactMapTargetForResult");function jX(t,e){return `${t}\0${(e??[]).join(",")}`}s(jX,"sourceMapCacheKey");function vR(t,e){let r=nt(t),n=new Set;for(let o of e){let i=r.join(t,o.path);n.add(i);let a=r.dirname(i);for(;a.startsWith(t)&&!n.has(a)&&(n.add(a),a!==t);)a=r.dirname(a);}return n}s(vR,"collectPlannedPaths");function UX(t,e,r){let n=Gt(t.target,e),o=pM(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=LM(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(UX,"artifactCacheKey");function OM(t,e,r,n,o="project",i,a){let l=vR(n,t),c=new Map,m=new Map;return t.map(p=>{if(a?.has(p.path))return p;let u=jX(p.target,i),g=(m.get(u)??(()=>{let k=EM(p.target,e,r,o,i);return m.set(u,k),k})()).get(p.path);if(!g)return p;let h=LM(p,o,i),R=UX(p,o,i),C=c.get(R)??(()=>{let k=kM(h,e,r,n,p.path,{scope:o});return c.set(R,k),k})(),S=ou({content:p.content,projectRoot:n,sourceFile:g,destinationFile:nt(n).join(n,p.path),translatePath:s(k=>C.get(k)??k,"translatePath"),pathExists:s(k=>l.has(k)||existsSync(k),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:s(k=>{try{return statSync(k).isDirectory()}catch{return false}},"pathIsDirectory")});return S.content===p.content?p:{...p,content:S.content}})}s(OM,"rewriteGeneratedReferences");ae();As();ot();var KX=/!?\[[^\]]*\]\(([^)]+)\)/g,WX=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function HX(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(HX,"isMarkdownLikeOutput");function zX(t,e){return e.some(([r,n])=>t>=r&&t<n)}s(zX,"isOffsetInRanges");function VX(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(VX,"parseMarkdownLinkDestination");function JX(t,e){let r=t.trim();if(!r||r.startsWith("#")||/^https?:\/\//i.test(r)||/^mailto:/i.test(r)||/^data:/i.test(r)||/^javascript:/i.test(r)||/^ftp:/i.test(r))return true;if(/^[a-zA-Z]:[\\/]/.test(r))return false;if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(r))return true;if(r.startsWith("/")){let n=Y(e,e),o=Y(e,r);if(!o.startsWith(`${n}/`)&&o!==n)return true}return false}s(JX,"shouldSkipLocalValidation");function YX(t){return /(?:^|\/)[^/]+\/skills\/[^/]+\//.test(t)}s(YX,"isSkillGeneratedOutput");var XX={rules:"rules",steering:"rules",commands:"commands",agents:"agents",skills:"skills",droids:"agents",instructions:"rules",prompts:"commands"},ZX={".clinerules":"rules"},QX=[".agent.md",".instructions.md",".prompt.md"];function AM(t){for(let e of QX)if(t.endsWith(e))return t.slice(0,-e.length);return t.endsWith(".mdc")?t.slice(0,-4):t.endsWith(".md")?t.slice(0,-3):t}s(AM,"stripMarkdownExt");function qX(t){let e=/^[^/]+\/([^/]+)\/([^/]+)/.exec(t);if(e){let n=XX[e[1]??""];if(n){let o=e[2]??"";return n!=="skills"&&(o=AM(o)),`${n}/${o}`}}let r=/^([^/]+)\/([^/]+)/.exec(t);if(r){let n=ZX[r[1]??""];if(n)return `${n}/${AM(r[2]??"")}`}return null}s(qX,"canonicalKeyFromOutputPath");function t2(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(t2,"pathExistsForGenerate");function e2(t,e,r){let o=VX(t).split("#")[0]??"",{candidate:i}=pl(o),a=i,l=ul.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(JX(c,e))return [];let m=tm(c,e,r);if(m.length===0){let u=nt(e),f=Y(e,r);m=[Y(e,u.join(u.dirname(f),c)),Y(e,u.join(e,c))];}let p=[];for(let u of m)for(let f of em(e,u)){let g=Y(e,f);p.includes(g)||p.push(g);}return p}s(e2,"resolveMarkdownLinkTargets");function r2(t,e){let r=vR(e,t),n=[];for(let o of t){if(!HX(o.path))continue;let i=Y(e,nt(e).join(e,o.path)),a=nu(o.content),l=s((c,m)=>{if(zX(m,a))return;let p=e2(c,e,i);p.length!==0&&(p.some(u=>t2(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:p}));},"visitDestination");for(let c of o.content.matchAll(KX)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(WX)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}s(r2,"findBrokenMarkdownLinks");function wM(t,e,r={}){let n=r2(t,e);if(n.length===0)return;let o=r.packOriginatedKeys,i=[],a=[];for(let c of n){let m=qX(c.generatePath),p=o!==void 0&&m!==null&&o.has(m);YX(c.generatePath)||p?a.push(c):i.push(c);}if(a.length>0){let c=a.map(m=>` ${m.generatePath} (${m.target}): "${m.rawLink}" \u2192 not found`);y.warn(`Third-party content contains ${a.length} broken local link${a.length===1?"":"s"} (warning only; outputs from installed packs and skill subtrees are treated as advisory):
184
+ `+stringify(n);await S(r,o);}s(Ef,"writeLock");async function Rs(t){if(!await j(t))return {};let e=await $(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===VR||!j2(o))continue;let i=await Sf(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(Rs,"buildChecksums");function Lf(t,e,r){if(r.length===0)return [];let n=r.map(a=>U2[a]).filter(a=>a!==void 0);if(n.length===0)return [];let o=new Set([...Object.keys(t),...Object.keys(e)]),i=[];for(let a of o)n.some(l=>l(a))&&t[a]!==e[a]&&i.push(a);return i}s(Lf,"detectLockedFeatureViolations");async function Of(t){let e=await _f(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(Of,"buildPackChecksums");async function hc(t){let e={};for(let r of t){if(r.version!==void 0){e[r.name]=r.version;continue}let n=join(r.resolvedPath,".agentsmesh"),o=await Rs(n),i=Object.keys(o).sort().map(c=>`${c}:${o[c]}`).join(`
185
+ `),a=If(i),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}s(hc,"buildExtendChecksums");Pt();ae();function yc(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(yc,"getAdditionalRootDecorationPaths");function _M(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(_M,"resolveRewriteFamilyId");ce();lh();function B2(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(B2,"addDirectoryMapping");function RM(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)B2(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}s(RM,"addSkillDirectoryMappings");Pt();function IM(t,e,r="project"){let n=Bt(t,r);if(!n)return null;if(e.root)return n.rootInstructionPath??null;if(e.targets.length>0&&!e.targets.includes(t))return null;let o=posix.basename(e.source.replace(/\\/g,"/"),".md");return n.paths.rulePath(o,e)}s(IM,"ruleTargetPath");function SM(t,e,r,n="project"){let o=Bt(t,n);return o?o.paths.commandPath(e,r):null}s(SM,"commandTargetPath");function CM(t,e,r,n="project"){let o=Bt(t,n);return o?o.paths.agentPath(e,r):null}s(CM,"agentTargetPath");ge();Yt();Ce();Pt();function H2(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(H2,"addDirectoryMapping");function JR(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=IM(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=SM(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=CM(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let i=np(t,n);if(!i)return o;for(let a of e.skills){H2(o,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let l of a.supportingFiles){let c=l.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${c}`,p=`${i}/${a.name}/${c}`;o.set(m,p),RM(o,m,p);}}return o}s(JR,"buildReferenceMap");ce();ce();Pt();function EM(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(EM,"addPackAbsoluteDirMapping");function z2(t){let e=new Set;for(let{relativePath:r}of t){let n=r.replace(/\\/g,"/"),o=posix.dirname(n);for(;o!=="."&&o.length>0;){e.add(o);let i=posix.dirname(o);if(i===o)break;o=i;}}return [...e]}s(z2,"skillSupportingDirPrefixes");function LM(t,e,r,n,o){let i=np(e,o);if(!i)return;let a=at(n),l=a.join(n,".agentsmesh","packs");for(let c of r.skills){let m=a.dirname(c.source);if(!m.startsWith(l))continue;let p=a.normalize(a.join(n,i,c.name));EM(t,m,p,a),t.set(a.normalize(c.source),a.normalize(a.join(p,"SKILL.md")));for(let u of c.supportingFiles){let f=a.normalize(a.join(p,u.relativePath));t.set(a.normalize(u.absolutePath),f);}for(let u of z2(c.supportingFiles))EM(t,a.join(m,u),a.join(p,u),a);}}s(LM,"addPackSkillArtifactMappings");ce();function V2(t){return `.agentsmesh/rules/${basename(t.source)}`}s(V2,"canonicalRulePath");function J2(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(J2,"copilotInstructionsPath");function wM(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let i=at(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,V2(a))),i.normalize(i.join(r,J2(a))));}s(wM,"applyCopilotInstructionArtifactRefs");Pt();function YR(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(YR,"pushUnique");function AM(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);YR(o,i);let a=Bt(t,n);if(e.root)for(let l of yc(a))YR(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])YR(o,l);return o}s(AM,"extraRuleOutputPaths");Pt();function bM(t,e,r,n,o,i){let a=Bt(t,e);if(!a?.mirrorGlobalPath)return;let l=a.mirrorGlobalPath(r,i??[]),c=l===null?[]:Array.isArray(l)?l:[l];for(let m of c)m!==r&&o.set(m,n);}s(bM,"addSkillMirrorSourceEntry");function X2(t){return `.agentsmesh/commands/${t.name}.md`}s(X2,"canonicalCommandPath");function Z2(t){return `.agentsmesh/agents/${t.name}.md`}s(Z2,"canonicalAgentPath");function Q2(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(Q2,"canonicalSkillPath");function PM(t,e,r,n,o,i){let a=i?.scope??"project",l=at(n),c=new Map([...JR(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return wM(t,c,n,o,e),LM(c,t,e,n,a),c}s(PM,"buildArtifactPathMap");function TM(t,e,r,n="project",o){let i=JR(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of AM(t,l,i,n))a.set(c,l.source);for(let l of e.commands){let c=i.get(X2(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=i.get(Z2(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=i.get(Q2(l));c&&(a.set(c,l.source),bM(t,n,c,l.source,a,o));for(let m of l.supportingFiles){let p=`.agentsmesh/skills/${l.name}/${m.relativePath.replace(/\\/g,"/")}`,u=i.get(p);u&&(a.set(u,m.absolutePath),bM(t,n,u,m.absolutePath,a,o));}}return a}s(TM,"buildOutputSourceMap");Pt();ae();Jg();function eX(t,e){if(!e)return null;for(let r of e){let n=ot(r);if(n?.sharedArtifacts){for(let[o,i]of Object.entries(n.sharedArtifacts))if(i==="owner"&&t.startsWith(o))return r}}return null}s(eX,"findSharedArtifactOwner");function xM(t,e,r){if(e==="global"){let n=eX(t.path,r);if(n)return n;let o=jC(t.path);if(o)return o}return t.target}s(xM,"artifactMapTargetForResult");function rX(t,e){return `${t}\0${(e??[]).join(",")}`}s(rX,"sourceMapCacheKey");function XR(t,e){let r=at(t),n=new Set;for(let o of e){let i=r.join(t,o.path);n.add(i);let a=r.dirname(i);for(;a.startsWith(t)&&!n.has(a)&&(n.add(a),a!==t);)a=r.dirname(a);}return n}s(XR,"collectPlannedPaths");function nX(t,e,r){let n=Bt(t.target,e),o=_M(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=xM(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(nX,"artifactCacheKey");function DM(t,e,r,n,o="project",i,a){let l=XR(n,t),c=new Map,m=new Map;return t.map(p=>{if(a?.has(p.path))return p;let u=rX(p.target,i),g=(m.get(u)??(()=>{let R=TM(p.target,e,r,o,i);return m.set(u,R),R})()).get(p.path);if(!g)return p;let h=xM(p,o,i),I=nX(p,o,i),k=c.get(I)??(()=>{let R=PM(h,e,r,n,p.path,{scope:o});return c.set(I,R),R})(),C=yu({content:p.content,projectRoot:n,sourceFile:g,destinationFile:at(n).join(n,p.path),translatePath:s(R=>k.get(R)??R,"translatePath"),pathExists:s(R=>l.has(R)||existsSync(R),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:s(R=>{try{return statSync(R).isDirectory()}catch{return false}},"pathIsDirectory")});return C.content===p.content?p:{...p,content:C.content}})}s(DM,"rewriteGeneratedReferences");ce();As();st();var sX=/!?\[[^\]]*\]\(([^)]+)\)/g,iX=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function aX(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(aX,"isMarkdownLikeOutput");function lX(t,e){return e.some(([r,n])=>t>=r&&t<n)}s(lX,"isOffsetInRanges");function cX(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(cX,"parseMarkdownLinkDestination");function mX(t,e){let r=t.trim();if(!r||r.startsWith("#")||/^https?:\/\//i.test(r)||/^mailto:/i.test(r)||/^data:/i.test(r)||/^javascript:/i.test(r)||/^ftp:/i.test(r))return true;if(/^[a-zA-Z]:[\\/]/.test(r))return false;if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(r))return true;if(r.startsWith("/")){let n=X(e,e),o=X(e,r);if(!o.startsWith(`${n}/`)&&o!==n)return true}return false}s(mX,"shouldSkipLocalValidation");function pX(t){return /(?:^|\/)[^/]+\/skills\/[^/]+\//.test(t)}s(pX,"isSkillGeneratedOutput");var uX={rules:"rules",steering:"rules",commands:"commands",agents:"agents",skills:"skills",droids:"agents",instructions:"rules",prompts:"commands"},dX={".clinerules":"rules"},fX=[".agent.md",".instructions.md",".prompt.md"];function NM(t){for(let e of fX)if(t.endsWith(e))return t.slice(0,-e.length);return t.endsWith(".mdc")?t.slice(0,-4):t.endsWith(".md")?t.slice(0,-3):t}s(NM,"stripMarkdownExt");function gX(t){let e=/^[^/]+\/([^/]+)\/([^/]+)/.exec(t);if(e){let n=uX[e[1]??""];if(n){let o=e[2]??"";return n!=="skills"&&(o=NM(o)),`${n}/${o}`}}let r=/^([^/]+)\/([^/]+)/.exec(t);if(r){let n=dX[r[1]??""];if(n)return `${n}/${NM(r[2]??"")}`}return null}s(gX,"canonicalKeyFromOutputPath");function hX(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(hX,"pathExistsForGenerate");function yX(t,e,r){let o=cX(t).split("#")[0]??"",{candidate:i}=ul(o),a=i,l=dl.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(mX(c,e))return [];let m=om(c,e,r);if(m.length===0){let u=at(e),f=X(e,r);m=[X(e,u.join(u.dirname(f),c)),X(e,u.join(e,c))];}let p=[];for(let u of m)for(let f of sm(e,u)){let g=X(e,f);p.includes(g)||p.push(g);}return p}s(yX,"resolveMarkdownLinkTargets");function _X(t,e){let r=XR(e,t),n=[];for(let o of t){if(!aX(o.path))continue;let i=X(e,at(e).join(e,o.path)),a=hu(o.content),l=s((c,m)=>{if(lX(m,a))return;let p=yX(c,e,i);p.length!==0&&(p.some(u=>hX(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:p}));},"visitDestination");for(let c of o.content.matchAll(sX)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(iX)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}s(_X,"findBrokenMarkdownLinks");function FM(t,e,r={}){let n=_X(t,e);if(n.length===0)return;let o=r.packOriginatedKeys,i=[],a=[];for(let c of n){let m=gX(c.generatePath),p=o!==void 0&&m!==null&&o.has(m);pX(c.generatePath)||p?a.push(c):i.push(c);}if(a.length>0){let c=a.map(m=>` ${m.generatePath} (${m.target}): "${m.rawLink}" \u2192 not found`);y.warn(`Third-party content contains ${a.length} broken local link${a.length===1?"":"s"} (warning only; outputs from installed packs and skill subtrees are treated as advisory):
184
186
  ${c.join(`
185
187
  `)}`);}if(i.length===0)return;let l=i.map(c=>` ${c.generatePath} (${c.target}): "${c.rawLink}" \u2192 not found (tried: ${c.checkedPaths.join(", ")})`);throw new Error(`Generated markdown contains broken local links:
186
188
  ${l.join(`
187
189
  `)}
188
- Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(wM,"validateGeneratedMarkdownLinks");var n2=[`${sep}.agentsmesh${sep}packs${sep}`,"/.agentsmesh/packs/"];function gf(t){return n2.some(e=>t.includes(e))}s(gf,"isUnderPacks");function bM(t){let e=new Set;for(let r of t.rules)if(gf(r.source)){let n=r.root?"_root":o2(r.source);n&&e.add(`rules/${n}`);}for(let r of t.agents)gf(r.source)&&e.add(`agents/${r.name}`);for(let r of t.commands)gf(r.source)&&e.add(`commands/${r.name}`);for(let r of t.skills)gf(r.source)&&e.add(`skills/${r.name}`);return e}s(bM,"buildPackOriginatedKeys");function o2(t){let r=t.replace(/\\/g,"/").split("/").pop()??"";return r.endsWith(".md")?r.slice(0,-3):r}s(o2,"ruleNameFromSource");Rn();var DM="AGENTS.md";function PM(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(PM,"statusRank");function s2(t,e){return PM(e.status)<=PM(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(s2,"mergeDuplicateMetadata");function hf(t){return t.trim()}s(hf,"trimmedContent");var i2=[/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->\n*/g];function TM(t){let e=t;for(let r of i2)e=e.replace(r,"");return e.trim().replace(/\n{2,}/g,`
190
+ Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(FM,"validateGeneratedMarkdownLinks");var RX=[`${sep}.agentsmesh${sep}packs${sep}`,"/.agentsmesh/packs/"];function Af(t){return RX.some(e=>t.includes(e))}s(Af,"isUnderPacks");function vM(t){let e=new Set;for(let r of t.rules)if(Af(r.source)){let n=r.root?"_root":IX(r.source);n&&e.add(`rules/${n}`);}for(let r of t.agents)Af(r.source)&&e.add(`agents/${r.name}`);for(let r of t.commands)Af(r.source)&&e.add(`commands/${r.name}`);for(let r of t.skills)Af(r.source)&&e.add(`skills/${r.name}`);return e}s(vM,"buildPackOriginatedKeys");function IX(t){let r=t.replace(/\\/g,"/").split("/").pop()??"";return r.endsWith(".md")?r.slice(0,-3):r}s(IX,"ruleNameFromSource");Sn();var jM="AGENTS.md";function MM(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(MM,"statusRank");function SX(t,e){return MM(e.status)<=MM(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(SX,"mergeDuplicateMetadata");function bf(t){return t.trim()}s(bf,"trimmedContent");var CX=[/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->\n*/g];function $M(t){let e=t;for(let r of CX)e=e.replace(r,"");return e.trim().replace(/\n{2,}/g,`
189
191
 
190
- `)}s(TM,"normalizeAgentsContent");function xM(t){return /<!-- agentsmesh:embedded-rules:start -->/.test(t)}s(xM,"hasOptionalAgentsBlock");function a2(t,e){if(!t.path.endsWith(DM)||t.path!==e.path)return null;let r=hf(t.content),n=hf(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);if(o!==i)return o?t:e;if(TM(t.content)===TM(e.content)){let a=xM(t.content),l=xM(e.content);if(a!==l)return a?t:e}return null}s(a2,"richerAgentsResult");function l2(t,e){if(!t.path.endsWith(DM)||t.path!==e.path)return null;let r=t.target===pg?t:e.target===pg?e:null,n=r===t?e:t;if(!r)return null;let o=hf(r.content).length,i=hf(n.content).length;return o===i?null:o>i?r:n}s(l2,"richerCodexAgentsResult");function yf(t){let e=[];for(let r of t){let n=e.findIndex(i=>i.path===r.path);if(n===-1){e.push(r);continue}let o=e[n];if(o.content!==r.content){let i=a2(o,r);if(i){e[n]=i;continue}let a=l2(o,r);if(a){e[n]=a;continue}throw new Error(`Conflicting generated outputs for ${r.path}: ${o.target} and ${r.target} produce different content.`)}e[n]=s2(o,r);}return e}s(yf,"resolveOutputCollisions");function NM(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(NM,"refreshResultStatus");w();Pt();se();function vM(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(vM,"computeStatus");function c2(t,e,r){let n=lR(t,e,r);if(n!==null)return n;let o=et(t);if(!o)return null;let i=r==="global"?o.globalSupport?.layout:o.project;return i?(n=i.rewriteGeneratedPath?i.rewriteGeneratedPath(e):e,n):null}s(c2,"resolveGeneratedOutputPath");async function op(t,e,r,n,o,i){let a=c2(e,r.path,o);if(a===null)return null;let l=await _(join(n,a)),c=t.findIndex(u=>u.path===a&&u.target===e),m=c>=0?t[c]:void 0,p=i?.mergeContent?.(l,m,r.content,a)??r.content;return c>=0&&t.splice(c,1),t.push({target:e,path:a,content:p,currentContent:l??void 0,status:vM(l,p)}),a}s(op,"emitGeneratedOutput");function $R(t,e,r){return {capability:mi(t,r)?.[e]??{level:"none"},scope:r}}s($R,"featureContext");async function xa(t,e,r,n,o,i,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=$R(c,a,i);for(let u of m(r,p)){let f=await op(t,c,u,n,i);if(f===null)continue;let g=Gt(c,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),R=h===null?[]:Array.isArray(h)?h:[h];for(let C of R){let S=await _(join(n,C));t.push({target:c,path:C,content:u.content,currentContent:S??void 0,status:vM(S,u.content)});}}}}}s(xa,"generateFeature");Gg();Pt();function m2(t){return t?.rootInstructionPath?[t.rootInstructionPath,...hc(t)]:[]}s(m2,"rootDecorationPaths");function MM(t,e,r="project"){return t.map(n=>{let o=Gt(n.target,r);if(!o)return n;let i=m2(o);if(i.length===0||!i.includes(n.path))return n;let l=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,c=BC(l);return c===n.content?n:{...n,content:c}})}s(MM,"decoratePrimaryRootInstructions");Pt();se();td();function GR(t,e,r,n,o){let a=(Pr(t)??et(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&mP.includes(o)?pP(l,n):n}s(GR,"mergeOutputContent");async function $M(t,e,r,n,o){for(let i of e){let a=uc(i,"permissions",void 0,o)??et(i)?.generators.generatePermissions;if(a)for(let l of a(r))await op(t,i,l,n,o,{mergeContent:s((c,m,p,u)=>GR(i,c,m,p,u),"mergeContent")});}}s($M,"generatePermissionsFeature");async function GM(t,e,r,n,o,i){for(let a of e){let l=uc(a,"hooks",i,o)??et(a)?.generators.generateHooks;if(!l)continue;let c=$R(a,"hooks",o),m=[...l(r,c)],u=(Pr(a)??et(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let f of m)await op(t,a,f,n,o,{mergeContent:s((g,h,R,C)=>GR(a,g,h,R,C),"mergeContent")});}}s(GM,"generateHooksFeature");async function jM(t,e,r,n,o){for(let i of e){let l=(Pr(i)??et(i))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await op(t,i,m,n,o,{mergeContent:s((p,u,f,g)=>GR(i,p,u,f,g),"mergeContent")});}}s(jM,"generateScopedSettingsFeature");async function Tr(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],l=i?a.filter(W=>i.includes(W)):a;function c(W,z){return uc(W,z,e,o)}s(c,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),u=e.features.includes("agents"),f=e.features.includes("skills"),g=e.features.includes("mcp"),h=e.features.includes("permissions"),R=e.features.includes("hooks"),C=e.features.includes("ignore"),S=[];await xa(S,l,r,n,m,o,"rules",W=>c(W,"rules")),await xa(S,l,r,n,p,o,"commands",W=>c(W,"commands")),await xa(S,l,r,n,u,o,"agents",W=>c(W,"agents")),await xa(S,l,r,n,f,o,"skills",W=>c(W,"skills")),await xa(S,l,r,n,g,o,"mcp",W=>c(W,"mcp")),h&&await $M(S,l,r,n,o),R&&await GM(S,l,r,n,o,e),await xa(S,l,r,n,C,o,"ignore",W=>c(W,"ignore"));let k=new Set(e.features);for(let W of l){let Q=(Pr(W)??et(W))?.globalSupport?.scopeExtras;if(Q){let at=await Q(r,n,o,k);S.push(...at);}}(g||C||R||u||h)&&await jM(S,l,r,n,o);let P=MM(S,r,o),N=p2(P,o),F=OM(P,r,e,n,o,l,N);return wM(F,n,{packOriginatedKeys:bM(r)}),yf(F.map(NM))}s(Tr,"generate");function p2(t,e){let r=new Map;function n(a){let l=r.get(a);if(l)return l;let c=Gt(a,e),m=new Set;if(c?.rootInstructionPath){m.add(c.rootInstructionPath);for(let p of hc(c))m.add(p);}return r.set(a,m),m}s(n,"rootPathsFor");let o=new Map;for(let a of t){if(!n(a.target).has(a.path))continue;let l=o.get(a.path)??new Set;l.add(a.target),o.set(a.path,l);}let i=new Set;for(let[a,l]of o)l.size>1&&i.add(a);return i}s(p2,"computeSharedRootInstructionPaths");fn();ot();w();_o();var O2=6e4,A2=30,w2=200,b2=2e3;async function Rf(t,e={}){let r=e.retries??A2,n=e.retryDelayMs??w2,o=e.staleMs??O2;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await P2(t);if(a)return a;let l=await T2(t);if(l!=="young"&&x2(l,o)){await rm(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let c=l==="young"?null:l;throw new Va(t,N2(c))}i++,await v2(n);}}s(Rf,"acquireProcessLock");async function P2(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:YM()};await writeFile(e,JSON.stringify(r),"utf-8");let n=false,o=s(()=>{if(!n){n=true;try{rmSync(t,{recursive:!0,force:!0});}catch{}}},"signalHandler");return process.once("SIGINT",o),process.once("SIGTERM",o),process.once("exit",o),async()=>{n||(n=true,process.off("SIGINT",o),process.off("SIGTERM",o),process.off("exit",o),await rm(t,{recursive:true,force:true}).catch(()=>{}));}}s(P2,"tryAcquire");async function T2(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return F2(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<b2)return "young"}catch{}return null}}s(T2,"inspectLock");function x2(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==YM()?false:!D2(t.pid)}s(x2,"isStale");function D2(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(D2,"isProcessAlive");function N2(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(N2,"describeHolder");function F2(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(F2,"isLockMetadata");function YM(){return hostname()}s(YM,"getHostname");function v2(t){return new Promise(e=>setTimeout(e,t))}s(v2,"sleep");w();Pt();async function XM(t,e=t){let r=await readdir(t,{withFileTypes:true}),n=[];for(let o of r){let i=join(t,o.name);if(o.isDirectory()){n.push(...await XM(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(XM,"listFiles");async function j2(t,e,r){if(r.has(e))return;let n=join(t,e);await $(n)&&await rm(n,{recursive:true,force:true});}s(j2,"removeIfStale");async function ZM(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let i=aR(o,n);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let l=join(t.projectRoot,a);if(await $(l))for(let c of await XM(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await j2(t.projectRoot,o,e);}s(ZM,"cleanupStaleGeneratedOutputs");function yc(t,e,r){let n=resolve(t),o=resolve(t,e);if(o===n||o.startsWith(`${n}${sep}`))return o;throw new Error(`Unsafe generated output path for ${r}: ${e}`)}s(yc,"ensurePathInsideRoot");Uc();w();ot();async function WR(t,e){let r=await ys(t.canonicalDir),n=e.length>0?await gc(e):{},o=await df(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await pf(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:Ci(),checksums:r,extends:n,packs:o});try{await cg(Te(),join(t.configDir,".agentsmeshcache"));}catch(a){y.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(WR,"writeLockFile");async function l$(t){let{mode:e,scope:r,dryRun:n,context:o,resolvedExtends:i,flags:a,root:l,options:c}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:If([])}};if(n||await WR(o,i),c.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(ap(),QR)),{renderMatrix:p}=await Promise.resolve().then(()=>(cp(),qR)),u=await m(a,l);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:If([])}}}s(l$,"handleEmptyResults");function c$(t,e){let r=t.filter(a=>a.status!=="skipped"),n=r.filter(a=>a.status!=="unchanged"),o=r.map(a=>({path:a.path,target:a.target,status:a.status}));return {exitCode:n.length===0?0:1,data:{scope:e,mode:"check",files:o,summary:If(r)}}}s(c$,"buildCheckResult");async function m$(t){let{results:e,dryRun:r,scope:n,mode:o,context:i,activeTargets:a,resolvedExtends:l,flags:c,root:m,options:p}=t,u=r?null:await Rf(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let R=yc(i.rootBase,h.path,h.target);await I(R,h.content);}await ZM({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:n}),await WR(i,l);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(ap(),QR)),{renderMatrix:R}=await Promise.resolve().then(()=>(cp(),qR)),C=await h(c,m);R(C,{verbose:c.verbose===true});}let f=e.filter(h=>h.status!=="skipped"),g=f.map(h=>({path:h.path,target:h.target,status:h.status}));return {exitCode:0,data:{scope:n,mode:o,files:g,summary:If(f)}}}s(m$,"handleGenerateOrDryRun");function If(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(If,"buildSummary");async function _c(t,e,r={}){if(t.features!==void 0)throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");let n=e??process.cwd(),o=t.check===true,i=t["dry-run"]===true,a=t.force===true,l=t.global===true?"global":"project",c=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=o?"check":i?"dry-run":"generate",{config:f,context:g}=await yt(n,l);await Wt(f,n);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let N=await mf(g.canonicalDir);if(N!==null){let F=await ys(g.canonicalDir),W=uf(N.checksums,F,h);if(W.length>0){y.error("Locked feature violation (strategy: lock). Modified files:");for(let z of W)y.error(` ${z}`);throw y.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:R,resolvedExtends:C}=await ke(f,g.configDir,{refreshRemoteCache:c},g.canonicalDir),S=[...f.targets,...f.pluginTargets??[]];if(p){let N=p.filter(F=>!S.includes(F));if(N.length>0)throw new Error(`Unknown target(s) in --targets: ${N.join(", ")}. Available: ${S.join(", ")}`)}let k=p?S.filter(N=>p.includes(N)):S,P=await Tr({config:f,canonical:R,projectRoot:g.rootBase,scope:l,targetFilter:p});return P.length===0?l$({mode:u,scope:l,dryRun:i,context:g,resolvedExtends:C,flags:t,root:n,options:r}):o?c$(P,l):m$({results:P,dryRun:i,scope:l,mode:u,context:g,activeTargets:k,resolvedExtends:C,flags:t,root:n,options:r})}s(_c,"runGenerate");ot();function tI(t,e){return t==="global"?`~/${e}`:e}s(tI,"formatDisplayPath");function Rc(t){let{data:e}=t,{scope:r,mode:n,files:o}=e;if(o.length===0){y.info("No files to generate (no root rule or rules feature disabled)."),n==="check"&&y.success("Generated files are in sync.");return}if(n==="check"){let c=o.filter(m=>m.status!=="unchanged");if(c.length===0){y.success("Generated files are in sync.");return}for(let m of c)y.error(`[check] ${m.status} ${tI(r,m.path)} (${m.target})`);y.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(n==="dry-run"){for(let c of o)y.info(`[dry-run] ${c.status} ${tI(r,c.path)} (${c.target})`);return}for(let c of o)(c.status==="created"||c.status==="updated")&&y.success(`${c.status} ${tI(r,c.path)}`);let{created:i,updated:a,unchanged:l}=e.summary;i>0||a>0?y.info(`Generated: ${i} created, ${a} updated, ${l} unchanged`):y.info(`Nothing changed. (${l} unchanged)`);}s(Rc,"renderGenerate");w();Pt();Pt();Rn();function p$(){return bt.filter(t=>!t.excludeFromStarterInit).map(t=>t.id).filter(Pe)}s(p$,"starterInitTargetIds");var u$=/^# yaml-language-server: \$schema=[^\n]*\n?/;function Y2(){let t=Ci();return `https://unpkg.com/agentsmesh${t&&t!=="unknown"?`@${t}`:""}/schemas`}s(Y2,"schemaBaseUrl");function d$(t){return `${Y2()}/${t}.json`}s(d$,"schemaUrl");function Ic(t){return `# yaml-language-server: $schema=${d$(t)}
191
- `}s(Ic,"yamlSchemaDirective");function Da(t,e){let r=Ic(e);return u$.test(t)?t.replace(u$,r):`${r}${t}`}s(Da,"prependYamlSchemaDirective");function f$(t,e){let{$schema:r,...n}=t;return {$schema:d$(e),...n}}s(f$,"stampJsonSchemaField");var X2=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],Z2=p$();function Sf(t,e=Z2){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
192
- `),n=X2.map(o=>` - ${o}`).join(`
193
- `);return `${Ic("agentsmesh")}version: 1
192
+ `)}s($M,"normalizeAgentsContent");function GM(t){return /<!-- agentsmesh:embedded-rules:start -->/.test(t)}s(GM,"hasOptionalAgentsBlock");function kX(t,e){if(!t.path.endsWith(jM)||t.path!==e.path)return null;let r=bf(t.content),n=bf(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);if(o!==i)return o?t:e;if($M(t.content)===$M(e.content)){let a=GM(t.content),l=GM(e.content);if(a!==l)return a?t:e}return null}s(kX,"richerAgentsResult");function EX(t,e){if(!t.path.endsWith(jM)||t.path!==e.path)return null;let r=t.target===Lg?t:e.target===Lg?e:null,n=r===t?e:t;if(!r)return null;let o=bf(r.content).length,i=bf(n.content).length;return o===i?null:o>i?r:n}s(EX,"richerCodexAgentsResult");function Pf(t){let e=[];for(let r of t){let n=e.findIndex(i=>i.path===r.path);if(n===-1){e.push(r);continue}let o=e[n];if(o.content!==r.content){let i=kX(o,r);if(i){e[n]=i;continue}let a=EX(o,r);if(a){e[n]=a;continue}throw new Error(`Conflicting generated outputs for ${r.path}: ${o.target} and ${r.target} produce different content.`)}e[n]=SX(o,r);}return e}s(Pf,"resolveOutputCollisions");function UM(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(UM,"refreshResultStatus");A();Pt();ae();function KM(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(KM,"computeStatus");function LX(t,e,r){let n=CR(t,e,r);if(n!==null)return n;let o=ot(t);if(!o)return null;let i=r==="global"?o.globalSupport?.layout:o.project;return i?(n=i.rewriteGeneratedPath?i.rewriteGeneratedPath(e):e,n):null}s(LX,"resolveGeneratedOutputPath");async function lp(t,e,r,n,o,i){let a=LX(e,r.path,o);if(a===null)return null;let l=await _(join(n,a)),c=t.findIndex(u=>u.path===a&&u.target===e),m=c>=0?t[c]:void 0,p=i?.mergeContent?.(l,m,r.content,a)??r.content;return c>=0&&t.splice(c,1),t.push({target:e,path:a,content:p,currentContent:l??void 0,status:KM(l,p)}),a}s(lp,"emitGeneratedOutput");function QR(t,e,r){return {capability:pi(t,r)?.[e]??{level:"none"},scope:r}}s(QR,"featureContext");async function Na(t,e,r,n,o,i,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=QR(c,a,i);for(let u of m(r,p)){let f=await lp(t,c,u,n,i);if(f===null)continue;let g=Bt(c,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),I=h===null?[]:Array.isArray(h)?h:[h];for(let k of I){let C=await _(join(n,k));t.push({target:c,path:k,content:u.content,currentContent:C??void 0,status:KM(C,u.content)});}}}}}s(Na,"generateFeature");qg();Pt();function OX(t){return t?.rootInstructionPath?[t.rootInstructionPath,...yc(t)]:[]}s(OX,"rootDecorationPaths");function WM(t,e,r="project"){return t.map(n=>{let o=Bt(n.target,r);if(!o)return n;let i=OX(o);if(i.length===0||!i.includes(n.path))return n;let l=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,c=YC(l);return c===n.content?n:{...n,content:c}})}s(WM,"decoratePrimaryRootInstructions");Pt();ae();dd();function qR(t,e,r,n,o){let a=(Fr(t)??ot(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&yP.includes(o)?_P(l,n):n}s(qR,"mergeOutputContent");async function HM(t,e,r,n,o){for(let i of e){let a=dc(i,"permissions",void 0,o)??ot(i)?.generators.generatePermissions;if(a)for(let l of a(r))await lp(t,i,l,n,o,{mergeContent:s((c,m,p,u)=>qR(i,c,m,p,u),"mergeContent")});}}s(HM,"generatePermissionsFeature");async function zM(t,e,r,n,o,i){for(let a of e){let l=dc(a,"hooks",i,o)??ot(a)?.generators.generateHooks;if(!l)continue;let c=QR(a,"hooks",o),m=[...l(r,c)],u=(Fr(a)??ot(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let f of m)await lp(t,a,f,n,o,{mergeContent:s((g,h,I,k)=>qR(a,g,h,I,k),"mergeContent")});}}s(zM,"generateHooksFeature");async function VM(t,e,r,n,o){for(let i of e){let l=(Fr(i)??ot(i))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await lp(t,i,m,n,o,{mergeContent:s((p,u,f,g)=>qR(i,p,u,f,g),"mergeContent")});}}s(VM,"generateScopedSettingsFeature");async function vr(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],l=i?a.filter(B=>i.includes(B)):a;function c(B,U){return dc(B,U,e,o)}s(c,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),u=e.features.includes("agents"),f=e.features.includes("skills"),g=e.features.includes("mcp"),h=e.features.includes("permissions"),I=e.features.includes("hooks"),k=e.features.includes("ignore"),C=[];await Na(C,l,r,n,m,o,"rules",B=>c(B,"rules")),await Na(C,l,r,n,p,o,"commands",B=>c(B,"commands")),await Na(C,l,r,n,u,o,"agents",B=>c(B,"agents")),await Na(C,l,r,n,f,o,"skills",B=>c(B,"skills")),await Na(C,l,r,n,g,o,"mcp",B=>c(B,"mcp")),h&&await HM(C,l,r,n,o),I&&await zM(C,l,r,n,o,e),await Na(C,l,r,n,k,o,"ignore",B=>c(B,"ignore"));let R=new Set(e.features);for(let B of l){let q=(Fr(B)??ot(B))?.globalSupport?.scopeExtras;if(q){let nt=await q(r,n,o,R);C.push(...nt);}}(g||k||I||u||h)&&await VM(C,l,r,n,o);let P=WM(C,r,o),N=wX(P,o),F=DM(P,r,e,n,o,l,N);return FM(F,n,{packOriginatedKeys:vM(r)}),Pf(F.map(UM))}s(vr,"generate");function wX(t,e){let r=new Map;function n(a){let l=r.get(a);if(l)return l;let c=Bt(a,e),m=new Set;if(c?.rootInstructionPath){m.add(c.rootInstructionPath);for(let p of yc(c))m.add(p);}return r.set(a,m),m}s(n,"rootPathsFor");let o=new Map;for(let a of t){if(!n(a.target).has(a.path))continue;let l=o.get(a.path)??new Set;l.add(a.target),o.set(a.path,l);}let i=new Set;for(let[a,l]of o)l.size>1&&i.add(a);return i}s(wX,"computeSharedRootInstructionPaths");Mr();st();A();Io();var BX=6e4,KX=30,WX=200,HX=2e3;async function xf(t,e={}){let r=e.retries??KX,n=e.retryDelayMs??WX,o=e.staleMs??BX;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await zX(t);if(a)return a;let l=await VX(t);if(l!=="young"&&JX(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let c=l==="young"?null:l;throw new Ja(t,XX(c))}i++,await QX(n);}}s(xf,"acquireProcessLock");async function zX(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:r$()};await writeFile(e,JSON.stringify(r),"utf-8");let n=false,o=s(()=>{if(!n){n=true;try{rmSync(t,{recursive:!0,force:!0});}catch{}}},"signalHandler");return process.once("SIGINT",o),process.once("SIGTERM",o),process.once("exit",o),async()=>{n||(n=true,process.off("SIGINT",o),process.off("SIGTERM",o),process.off("exit",o),await rm$1(t,{recursive:true,force:true}).catch(()=>{}));}}s(zX,"tryAcquire");async function VX(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return ZX(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<HX)return "young"}catch{}return null}}s(VX,"inspectLock");function JX(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==r$()?false:!YX(t.pid)}s(JX,"isStale");function YX(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(YX,"isProcessAlive");function XX(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(XX,"describeHolder");function ZX(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(ZX,"isLockMetadata");function r$(){return hostname()}s(r$,"getHostname");function QX(t){return new Promise(e=>setTimeout(e,t))}s(QX,"sleep");A();Pt();async function n$(t,e=t){let r=await readdir(t,{withFileTypes:true}),n=[];for(let o of r){let i=join(t,o.name);if(o.isDirectory()){n.push(...await n$(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(n$,"listFiles");async function rZ(t,e,r){if(r.has(e))return;let n=join(t,e);await j(n)&&await rm$1(n,{recursive:true,force:true});}s(rZ,"removeIfStale");async function o$(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let i=SR(o,n);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let l=join(t.projectRoot,a);if(await j(l))for(let c of await n$(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await rZ(t.projectRoot,o,e);}s(o$,"cleanupStaleGeneratedOutputs");function _c(t,e,r){let n=resolve(t),o=resolve(t,e);if(o===n||o.startsWith(`${n}${sep}`))return o;throw new Error(`Unsafe generated output path for ${r}: ${e}`)}s(_c,"ensurePathInsideRoot");Hc();A();st();async function oI(t,e){let r=await Rs(t.canonicalDir),n=e.length>0?await hc(e):{},o=await Of(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await Ef(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:Ei(),checksums:r,extends:n,packs:o});try{await kg(ve(),join(t.configDir,".agentsmeshcache"));}catch(a){y.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(oI,"writeLockFile");async function g$(t){let{mode:e,scope:r,dryRun:n,context:o,resolvedExtends:i,flags:a,root:l,options:c}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Df([])}};if(n||await oI(o,i),c.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(pp(),uI)),{renderMatrix:p}=await Promise.resolve().then(()=>(dp(),dI)),u=await m(a,l);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Df([])}}}s(g$,"handleEmptyResults");function h$(t,e){let r=t.filter(a=>a.status!=="skipped"),n=r.filter(a=>a.status!=="unchanged"),o=r.map(a=>({path:a.path,target:a.target,status:a.status}));return {exitCode:n.length===0?0:1,data:{scope:e,mode:"check",files:o,summary:Df(r)}}}s(h$,"buildCheckResult");async function y$(t){let{results:e,dryRun:r,scope:n,mode:o,context:i,activeTargets:a,resolvedExtends:l,flags:c,root:m,options:p}=t,u=r?null:await xf(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let I=_c(i.rootBase,h.path,h.target);await S(I,h.content);}await o$({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:n}),await oI(i,l);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(pp(),uI)),{renderMatrix:I}=await Promise.resolve().then(()=>(dp(),dI)),k=await h(c,m);I(k,{verbose:c.verbose===true});}let f=e.filter(h=>h.status!=="skipped"),g=f.map(h=>({path:h.path,target:h.target,status:h.status}));return {exitCode:0,data:{scope:n,mode:o,files:g,summary:Df(f)}}}s(y$,"handleGenerateOrDryRun");function Df(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(Df,"buildSummary");async function Rc(t,e,r={}){if(t.features!==void 0)throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");let n=e??process.cwd(),o=t.check===true,i=t["dry-run"]===true,a=t.force===true,l=t.global===true?"global":"project",c=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=o?"check":i?"dry-run":"generate",{config:f,context:g}=await yt(n,l);await Gt(f,n);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let N=await kf(g.canonicalDir);if(N!==null){let F=await Rs(g.canonicalDir),B=Lf(N.checksums,F,h);if(B.length>0){y.error("Locked feature violation (strategy: lock). Modified files:");for(let U of B)y.error(` ${U}`);throw y.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:I,resolvedExtends:k}=await Ee(f,g.configDir,{refreshRemoteCache:c},g.canonicalDir),C=[...f.targets,...f.pluginTargets??[]];if(p){let N=p.filter(F=>!C.includes(F));if(N.length>0)throw new Error(`Unknown target(s) in --targets: ${N.join(", ")}. Available: ${C.join(", ")}`)}let R=p?C.filter(N=>p.includes(N)):C,P=await vr({config:f,canonical:I,projectRoot:g.rootBase,scope:l,targetFilter:p});return P.length===0?g$({mode:u,scope:l,dryRun:i,context:g,resolvedExtends:k,flags:t,root:n,options:r}):o?h$(P,l):y$({results:P,dryRun:i,scope:l,mode:u,context:g,activeTargets:R,resolvedExtends:k,flags:t,root:n,options:r})}s(Rc,"runGenerate");st();function fI(t,e){return t==="global"?`~/${e}`:e}s(fI,"formatDisplayPath");function Ic(t){let{data:e}=t,{scope:r,mode:n,files:o}=e;if(o.length===0){y.info("No files to generate (no root rule or rules feature disabled)."),n==="check"&&y.success("Generated files are in sync.");return}if(n==="check"){let c=o.filter(m=>m.status!=="unchanged");if(c.length===0){y.success("Generated files are in sync.");return}for(let m of c)y.error(`[check] ${m.status} ${fI(r,m.path)} (${m.target})`);y.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(n==="dry-run"){for(let c of o)y.info(`[dry-run] ${c.status} ${fI(r,c.path)} (${c.target})`);return}for(let c of o)(c.status==="created"||c.status==="updated")&&y.success(`${c.status} ${fI(r,c.path)}`);let{created:i,updated:a,unchanged:l}=e.summary;i>0||a>0?y.info(`Generated: ${i} created, ${a} updated, ${l} unchanged`):y.info(`Nothing changed. (${l} unchanged)`);}s(Ic,"renderGenerate");A();Pt();Pt();Sn();function _$(){return bt.filter(t=>!t.excludeFromStarterInit).map(t=>t.id).filter(Fe)}s(_$,"starterInitTargetIds");var R$=/^# yaml-language-server: \$schema=[^\n]*\n?/;function pZ(){let t=Ei();return `https://unpkg.com/agentsmesh${t&&t!=="unknown"?`@${t}`:""}/schemas`}s(pZ,"schemaBaseUrl");function I$(t){return `${pZ()}/${t}.json`}s(I$,"schemaUrl");function Sc(t){return `# yaml-language-server: $schema=${I$(t)}
193
+ `}s(Sc,"yamlSchemaDirective");function Fa(t,e){let r=Sc(e);return R$.test(t)?t.replace(R$,r):`${r}${t}`}s(Fa,"prependYamlSchemaDirective");function S$(t,e){let{$schema:r,...n}=t;return {$schema:I$(e),...n}}s(S$,"stampJsonSchemaField");var uZ=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],dZ=_$();function Nf(t,e=dZ){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
194
+ `),n=uZ.map(o=>` - ${o}`).join(`
195
+ `);return `${Sc("agentsmesh")}version: 1
194
196
  targets:
195
197
  ${r}
196
198
  features:
197
199
  ${n}
198
- `}s(Sf,"buildConfig");var Cf=`---
200
+ `}s(Nf,"buildConfig");var Ff=`---
199
201
  root: true
200
202
  description: "Project rules"
201
203
  ---
@@ -204,7 +206,7 @@ description: "Project rules"
204
206
 
205
207
  Add your project-wide instructions here.
206
208
  This file is always included in AI tool context and synced to all configured tools.
207
- `,eI=`---
209
+ `,gI=`---
208
210
  description: "Example contextual rule \u2014 rename and customize"
209
211
  # targets: [claude-code, cursor] # limit to specific tools (optional)
210
212
  # globs: ["src/**/*.ts"] # activate only for matching files (optional)
@@ -213,14 +215,14 @@ description: "Example contextual rule \u2014 rename and customize"
213
215
  # Example Rule
214
216
 
215
217
  Replace this with your coding standards, conventions, or domain-specific guidelines.
216
- `,rI=`---
218
+ `,hI=`---
217
219
  description: "Example command \u2014 rename and customize"
218
220
  # allowed-tools: [Read, Grep, Glob, Bash]
219
221
  ---
220
222
 
221
223
  Describe the task for this command here.
222
224
  Commands are invoked on-demand (e.g. /example) with a focused tool set.
223
- `,nI=`---
225
+ `,yI=`---
224
226
  name: example-agent
225
227
  description: "Example subagent \u2014 rename and customize"
226
228
  # tools: [Read, Grep, Glob]
@@ -231,7 +233,7 @@ description: "Example subagent \u2014 rename and customize"
231
233
 
232
234
  Describe this agent's role and instructions here.
233
235
  Agents are specialized subagents with restricted tools and a specific purpose.
234
- `,oI=`---
236
+ `,_I=`---
235
237
  name: example-skill
236
238
  description: "Example skill \u2014 rename and customize"
237
239
  ---
@@ -240,7 +242,7 @@ description: "Example skill \u2014 rename and customize"
240
242
 
241
243
  Describe the skill procedure here.
242
244
  Skills are reusable multi-step procedures that commands and agents can reference.
243
- `,sI=`{
245
+ `,RI=`{
244
246
  "mcpServers": {
245
247
  // agentsmesh self-serve MCP server \u2014 exposes your canonical config to AI agents.
246
248
  // Lets agents introspect rules/commands/agents/skills and trigger generate.
@@ -267,7 +269,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
267
269
  // }
268
270
  }
269
271
  }
270
- `,iI=`${Ic("hooks")}# Lifecycle hooks \u2014 run shell commands before/after AI tool use
272
+ `,II=`${Sc("hooks")}# Lifecycle hooks \u2014 run shell commands before/after AI tool use
271
273
  # Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
272
274
  # Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
273
275
  #
@@ -280,7 +282,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
280
282
  # - matcher: Edit|Write
281
283
  # type: command
282
284
  # command: npm test --passWithNoTests
283
- `,aI=`${Ic("permissions")}# Tool permission allow/deny lists
285
+ `,SI=`${Sc("permissions")}# Tool permission allow/deny lists
284
286
  #
285
287
  # allow:
286
288
  # - Bash(npm run:*)
@@ -296,14 +298,14 @@ Skills are reusable multi-step procedures that commands and agents can reference
296
298
  allow: []
297
299
  deny: []
298
300
  ask: []
299
- `,lI=`# Patterns ignored by all configured AI tools (gitignore syntax)
301
+ `,CI=`# Patterns ignored by all configured AI tools (gitignore syntax)
300
302
  #
301
303
  # node_modules/
302
304
  # dist/
303
305
  # .env*
304
306
  # *.log
305
307
  # coverage/
306
- `,g$=`${Ic("agentsmesh")}# Personal overrides \u2014 NOT committed to git
308
+ `,C$=`${Sc("agentsmesh")}# Personal overrides \u2014 NOT committed to git
307
309
  # Uncomment and customize for your local setup:
308
310
 
309
311
  # targets:
@@ -321,44 +323,45 @@ ask: []
321
323
  # overrides:
322
324
  # claude-code:
323
325
  # model: opus
324
- `;w();Pt();function h$(t){let e=[];for(let r of bt)for(let n of iR(r.id,t))e.push({target:r.id,path:n});return e}s(h$,"collectDetectionPaths");function y$(t){let e=new Map;for(let{target:r,path:n}of h$(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}s(y$,"toolIndicators");y$("project");async function _$(t,e="project"){let r=[];for(let{id:n,paths:o}of y$(e))for(let i of o){let a=join(t,i);if(await $(a)){r.push(n);break}}return [...new Set(r)]}s(_$,"detectExistingConfigs");w();ot();function re(t,e){return join(t,e)}s(re,"ab");async function cI(t){return await $(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(cI,"countMdFiles");async function q2(t){let e=re(t,"skills");if(!await $(e))return false;let r=await readdir(e,{withFileTypes:true});for(let n of r)if(n.isDirectory()&&!n.name.startsWith("_")&&await $(join(e,n.name,"SKILL.md")))return true;return false}s(q2,"hasAnyImportedSkill");async function mI(t){let e=re(t,"rules");await O(e),await I(join(e,"_root.md"),Cf),y.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),eI),y.success("Created .agentsmesh/rules/_example.md");let r=re(t,"commands");await O(r),await I(join(r,"_example.md"),rI),y.success("Created .agentsmesh/commands/_example.md");let n=re(t,"agents");await O(n),await I(join(n,"_example.md"),nI),y.success("Created .agentsmesh/agents/_example.md");let o=re(t,join("skills","_example"));await O(o),await I(join(o,"SKILL.md"),oI),y.success("Created .agentsmesh/skills/_example/SKILL.md"),await I(re(t,"mcp.json"),sI),y.success("Created .agentsmesh/mcp.json"),await I(re(t,"hooks.yaml"),iI),y.success("Created .agentsmesh/hooks.yaml"),await I(re(t,"permissions.yaml"),aI),y.success("Created .agentsmesh/permissions.yaml"),await I(re(t,"ignore"),lI),y.success("Created .agentsmesh/ignore");}s(mI,"writeScaffoldFull");async function I$(t){let e=re(t,"rules"),r=await cI(e),n=join(e,"_root.md"),o=await $(n);await O(e),r===0?(await I(n,Cf),y.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),eI),y.success("Created .agentsmesh/rules/_example.md")):o||(await I(n,Cf),y.success("Created .agentsmesh/rules/_root.md"));let i=re(t,"commands");await cI(i)===0&&(await O(i),await I(join(i,"_example.md"),rI),y.success("Created .agentsmesh/commands/_example.md"));let a=re(t,"agents");if(await cI(a)===0&&(await O(a),await I(join(a,"_example.md"),nI),y.success("Created .agentsmesh/agents/_example.md")),!await q2(t)){let u=re(t,join("skills","_example"));await O(u),await I(join(u,"SKILL.md"),oI),y.success("Created .agentsmesh/skills/_example/SKILL.md");}let l=re(t,"mcp.json");await $(l)||(await I(l,sI),y.success("Created .agentsmesh/mcp.json"));let c=re(t,"hooks.yaml");await $(c)||(await I(c,iI),y.success("Created .agentsmesh/hooks.yaml"));let m=re(t,"permissions.yaml");await $(m)||(await I(m,aI),y.success("Created .agentsmesh/permissions.yaml"));let p=re(t,"ignore");await $(p)||(await I(p,lI),y.success("Created .agentsmesh/ignore"));}s(I$,"writeScaffoldGapFill");Yt();var pI="agentsmesh.yaml",S$="agentsmesh.local.yaml",eZ=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],rZ=Object.fromEntries(bt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),C$=bt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function nZ(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(nZ,"isCoveredByExisting");async function oZ(t){let e=join(t,".gitignore"),r=await _(e)??"",n=new Set(r.split(`
325
- `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=eZ.filter(a=>!nZ(a,n));if(o.length===0)return false;let i=r.endsWith(`
326
+ `;A();Pt();function k$(t){let e=[];for(let r of bt)for(let n of IR(r.id,t))e.push({target:r.id,path:n});return e}s(k$,"collectDetectionPaths");function E$(t){let e=new Map;for(let{target:r,path:n}of k$(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}s(E$,"toolIndicators");E$("project");async function L$(t,e="project"){let r=[];for(let{id:n,paths:o}of E$(e))for(let i of o){let a=join(t,i);if(await j(a)){r.push(n);break}}return [...new Set(r)]}s(L$,"detectExistingConfigs");A();st();function oe(t,e){return join(t,e)}s(oe,"ab");async function kI(t){return await j(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(kI,"countMdFiles");async function gZ(t){let e=oe(t,"skills");if(!await j(e))return false;let r=await readdir(e,{withFileTypes:true});for(let n of r)if(n.isDirectory()&&!n.name.startsWith("_")&&await j(join(e,n.name,"SKILL.md")))return true;return false}s(gZ,"hasAnyImportedSkill");async function EI(t){let e=oe(t,"rules");await O(e),await S(join(e,"_root.md"),Ff),y.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),gI),y.success("Created .agentsmesh/rules/_example.md");let r=oe(t,"commands");await O(r),await S(join(r,"_example.md"),hI),y.success("Created .agentsmesh/commands/_example.md");let n=oe(t,"agents");await O(n),await S(join(n,"_example.md"),yI),y.success("Created .agentsmesh/agents/_example.md");let o=oe(t,join("skills","_example"));await O(o),await S(join(o,"SKILL.md"),_I),y.success("Created .agentsmesh/skills/_example/SKILL.md"),await S(oe(t,"mcp.json"),RI),y.success("Created .agentsmesh/mcp.json"),await S(oe(t,"hooks.yaml"),II),y.success("Created .agentsmesh/hooks.yaml"),await S(oe(t,"permissions.yaml"),SI),y.success("Created .agentsmesh/permissions.yaml"),await S(oe(t,"ignore"),CI),y.success("Created .agentsmesh/ignore");}s(EI,"writeScaffoldFull");async function w$(t){let e=oe(t,"rules"),r=await kI(e),n=join(e,"_root.md"),o=await j(n);await O(e),r===0?(await S(n,Ff),y.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),gI),y.success("Created .agentsmesh/rules/_example.md")):o||(await S(n,Ff),y.success("Created .agentsmesh/rules/_root.md"));let i=oe(t,"commands");await kI(i)===0&&(await O(i),await S(join(i,"_example.md"),hI),y.success("Created .agentsmesh/commands/_example.md"));let a=oe(t,"agents");if(await kI(a)===0&&(await O(a),await S(join(a,"_example.md"),yI),y.success("Created .agentsmesh/agents/_example.md")),!await gZ(t)){let u=oe(t,join("skills","_example"));await O(u),await S(join(u,"SKILL.md"),_I),y.success("Created .agentsmesh/skills/_example/SKILL.md");}let l=oe(t,"mcp.json");await j(l)||(await S(l,RI),y.success("Created .agentsmesh/mcp.json"));let c=oe(t,"hooks.yaml");await j(c)||(await S(c,II),y.success("Created .agentsmesh/hooks.yaml"));let m=oe(t,"permissions.yaml");await j(m)||(await S(m,SI),y.success("Created .agentsmesh/permissions.yaml"));let p=oe(t,"ignore");await j(p)||(await S(p,CI),y.success("Created .agentsmesh/ignore"));}s(w$,"writeScaffoldGapFill");Zt();var LI="agentsmesh.yaml",A$="agentsmesh.local.yaml",yZ=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],_Z=Object.fromEntries(bt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),b$=bt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function RZ(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(RZ,"isCoveredByExisting");async function IZ(t){let e=join(t,".gitignore"),r=await _(e)??"",n=new Set(r.split(`
327
+ `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=yZ.filter(a=>!RZ(a,n));if(o.length===0)return false;let i=r.endsWith(`
326
328
  `)||r===""?"":`
327
- `;return await I(e,r+i+o.join(`
329
+ `;return await S(e,r+i+o.join(`
328
330
  `)+`
329
- `),true}s(oZ,"appendToGitignore");async function k$(t,e={}){let r=e.global===true?"global":"project",n=Ei(t,r),o=join(n.configDir,pI);if(await $(o))throw new Error(`Already initialized. ${pI} exists. Remove it first to re-init.`);let i=await _$(n.rootBase,r),a=r==="global"?i.filter(g=>C$.includes(g)):i,l=r==="global"?C$:void 0,c=[],m,p=0;if(a.length>0)if(e.yes){for(let g of a){let h=rZ[g];if(!h)continue;let R=await h(n.rootBase,r);for(let C of R)c.push({from:relative(n.rootBase,C.fromPath).replaceAll("\\","/"),to:C.toPath.replaceAll("\\","/")});}p=a.length,await I$(n.canonicalDir),m="gap-fill",await I(o,Sf(a,l));}else await mI(n.canonicalDir),m="full",await I(o,Sf([],l));else await mI(n.canonicalDir),m="full",await I(o,Sf([],l));let u=join(n.configDir,S$);await I(u,g$);let f=false;return r==="project"&&(f=await oZ(t)),{exitCode:0,data:{scope:r,configFile:pI,localConfigFile:S$,detectedConfigs:a,imported:c,importedToolCount:p,scaffoldType:m,gitignoreUpdated:f}}}s(k$,"runInit");ot();function E$(t){let{data:e}=t;if(e.detectedConfigs.length>0&&y.info(`Found existing configurations: ${e.detectedConfigs.join(", ")}`),e.detectedConfigs.length>0&&e.imported.length===0&&y.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),e.imported.length>0){y.info("Auto-importing existing configurations (--yes)...");for(let n of e.imported)y.success(` ${n.from} \u2192 ${n.to}`);y.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(", ")})`:"";y.success(`Created ${e.configFile}${r}`),y.success(`Created ${e.localConfigFile}`),e.gitignoreUpdated&&y.success("Updated .gitignore");}s(E$,"renderInit");Yt();Pt();var sZ=Object.fromEntries(bt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function kf(t){return sZ[t]}s(kf,"getTargetCatalogEntry");se();fn();zc();var pZ={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function uZ(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=pZ,true)}s(uZ,"injectAgentsmeshEntry");async function dI(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await vr(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!uZ(r))return !1;let n=JSON.stringify(r,null,2)+`
331
+ `),true}s(IZ,"appendToGitignore");async function P$(t,e={}){let r=e.global===true?"global":"project",n=Oi(t,r),o=join(n.configDir,LI);if(await j(o))throw new Error(`Already initialized. ${LI} exists. Remove it first to re-init.`);let i=await L$(n.rootBase,r),a=r==="global"?i.filter(g=>b$.includes(g)):i,l=r==="global"?b$:void 0,c=[],m,p=0;if(a.length>0)if(e.yes){for(let g of a){let h=_Z[g];if(!h)continue;let I=await h(n.rootBase,r);for(let k of I)c.push({from:relative(n.rootBase,k.fromPath).replaceAll("\\","/"),to:k.toPath.replaceAll("\\","/")});}p=a.length,await w$(n.canonicalDir),m="gap-fill",await S(o,Nf(a,l));}else await EI(n.canonicalDir),m="full",await S(o,Nf([],l));else await EI(n.canonicalDir),m="full",await S(o,Nf([],l));let u=join(n.configDir,A$);await S(u,C$);let f=false;return r==="project"&&(f=await IZ(t)),{exitCode:0,data:{scope:r,configFile:LI,localConfigFile:A$,detectedConfigs:a,imported:c,importedToolCount:p,scaffoldType:m,gitignoreUpdated:f}}}s(P$,"runInit");st();function T$(t){let{data:e}=t;if(e.detectedConfigs.length>0&&y.info(`Found existing configurations: ${e.detectedConfigs.join(", ")}`),e.detectedConfigs.length>0&&e.imported.length===0&&y.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),e.imported.length>0){y.info("Auto-importing existing configurations (--yes)...");for(let n of e.imported)y.success(` ${n.from} \u2192 ${n.to}`);y.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(", ")})`:"";y.success(`Created ${e.configFile}${r}`),y.success(`Created ${e.localConfigFile}`),e.gitignoreUpdated&&y.success("Updated .gitignore");}s(T$,"renderInit");Zt();Pt();var SZ=Object.fromEntries(bt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function vf(t){return SZ[t]}s(vf,"getTargetCatalogEntry");ae();Mr();Xc();var wZ={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function AZ(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=wZ,true)}s(AZ,"injectAgentsmeshEntry");async function wI(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await jr(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!AZ(r))return !1;let n=JSON.stringify(r,null,2)+`
330
332
  `;await mkdir(dirname(e),{recursive:!0});let o=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(o,n,"utf8"),await rename(o,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)}
331
- `),false}}s(dI,"seedAgentsmeshMcpEntry");function L$(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(L$,"mapResults");async function O$(t,e){let r=e??process.cwd(),n=t.from;if(typeof n!="string"||!n)throw new Error("--from is required. Example: agentsmesh import --from claude-code");let o=n.toLowerCase().trim(),i=t.global===true?"global":"project";if(Pe(o)){let p=Ei(r,i),f=await kf(o).importFrom(p.rootBase,{scope:i});return f.length>0&&await dI(p.rootBase),{exitCode:0,data:{scope:i,target:o,files:L$(f,p.rootBase)}}}let a,l;try{({config:a,context:l}=await yt(r,i));}catch{throw new Error(`Unknown --from "${n}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${Ft.join(", ")}.`)}await Wt(a,r);let c=et(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...Ft,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:i});return m.length>0&&await dI(l.rootBase),{exitCode:0,data:{scope:i,target:o,files:L$(m,l.rootBase)}}}s(O$,"runImport");Yt();fo();function Ef(t){let e=[],r={new:0,updated:0,unchanged:0,deleted:0};for(let n of t){if(n.status==="unchanged"){r.unchanged++;continue}if(n.status==="created"){r.new++;let o=createTwoFilesPatch(`${n.path} (current)`,`${n.path} (generated)`,"",n.content,void 0,void 0,{context:3});e.push({path:n.path,patch:o});continue}if(n.status==="updated"&&n.currentContent!==void 0){r.updated++;let o=createTwoFilesPatch(`${n.path} (current)`,`${n.path} (generated)`,n.currentContent,n.content,void 0,void 0,{context:3});e.push({path:n.path,patch:o});continue}}return {diffs:e,summary:r}}s(Ef,"computeDiff");function Lf(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(Lf,"formatDiffSummary");fn();async function w$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(g=>g.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Wt(a,r);let{canonical:c}=await ke(a,l.configDir,{},l.canonicalDir),m=await Tr({config:a,canonical:c,projectRoot:l.rootBase,scope:n,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}=Ef(m);return {exitCode:0,data:{files:m.filter(g=>g.status!=="unchanged"&&g.status!=="skipped").map(g=>({path:g.path,target:g.target,status:g.status})),patches:p.map(g=>({path:g.path,patch:g.patch})),summary:{created:u.new,updated:u.updated,unchanged:u.unchanged,deleted:u.deleted}}}}s(w$,"runDiff");Yt();fo();w();se();wi();Lt();var fZ=[{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 b$(t){let e=new Set(t.enabledFeatures),r=[];for(let n of fZ)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||$r(t.capabilities[n.capabilityKey]).level!=="none"||r.push(x(n.file,t.target,`${t.target} does not support ${n.label}; canonical entries are silently dropped during generation. Disable the feature for this target or remove the canonical content.`));return r}s(b$,"lintSilentFeatureDrops");Lt();var gZ=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function hZ(t){let r=t.match(gZ)?.groups?.path;return typeof r=="string"?r:null}s(hZ,"extractScriptToken");function P$(t){if(t.hasScriptProjection)return [];let e=t.canonical.hooks;if(!e)return [];let r=[];for(let n of Object.values(e))if(Array.isArray(n))for(let o of n){if(typeof o?.command!="string")continue;let i=hZ(o.command);i&&r.push(x(".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(P$,"lintHookScriptReferences");Lt();function T$(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(x(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(T$,"lintRuleScopeInversion");var yZ=["node_modules",".git","dist","coverage",".agentsmesh"];async function _Z(t){return (await v(t)).filter(n=>{let o=relative(t,n);return !yZ.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(_Z,"getProjectFiles");async function Of(t,e,r,n,o={}){let i=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],l=n?a.filter(C=>n.includes(C)):a,c=t.features.includes("rules"),m=t.features.includes("commands"),p=t.features.includes("mcp"),u=t.features.includes("permissions"),f=t.features.includes("hooks"),g=[],h=i==="global"?[]:await _Z(r);for(let C of l){let S=et(C),k=Pe(C)?kf(C):S;k?.capabilities&&g.push(...b$({target:C,capabilities:k.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...P$({target:C,canonical:e,hasScriptProjection:S?.postProcessHookOutputs!==void 0})),c&&g.push(...T$({target:C,canonical:e,preservesManualActivation:S?.preservesManualActivation===true})),c&&k?.lintRules&&g.push(...k.lintRules(e,r,h,{scope:i})),S?.generators.lint&&g.push(...S.generators.lint(e));let P={scope:i};m&&k?.lint?.commands&&g.push(...k.lint.commands(e,P)),p&&k?.lint?.mcp&&g.push(...k.lint.mcp(e,P)),u&&k?.lint?.permissions&&g.push(...k.lint.permissions(e,P)),f&&k?.lint?.hooks&&g.push(...k.lint.hooks(e,P));}let R=g.some(C=>C.level==="error");return {diagnostics:g,hasErrors:R}}s(Of,"runLint");fn();async function D$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(u=>u.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Wt(a,r);let{canonical:c}=await ke(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await Of(a,c,l.configDir,i,{scope:n});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(D$,"runLintCmd");ot();function N$(t){let{data:e}=t;if(e.diagnostics.length===0){y.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),n=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)y.error(`${a.file} (${a.target}): ${a.message}`);for(let a of n)y.warn(`${a.file} (${a.target}): ${a.message}`);let o=e.summary.errors,i=e.summary.warnings;y.info(`${o} error${o!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(N$,"renderLint");ot();function F$(t){let{data:e}=t;if(!e.hasLock){y.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){y.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);y.error("Conflict detected:");for(let n of e.extendsModified)y.error(` extend "${n}" was modified`);for(let n of e.modified){let o=r.has(n)?" [LOCKED]":"";y.error(` ${n} was modified${o}`);}for(let n of e.added){let o=r.has(n)?" [LOCKED]":"";y.error(` ${n} was added${o}`);}for(let n of e.removed){let o=r.has(n)?" [LOCKED]":"";y.error(` ${n} was removed${o}`);}y.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(F$,"renderCheck");ot();function v$(t){let{data:e}=t;if(e.files.length===0){y.info(`Nothing to import from ${e.target}.`);return}for(let n of e.files)y.success(`${n.from} \u2192 ${n.to}`);let r=e.scope==="global"?" --global":"";y.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(v$,"renderImport");ot();function M$(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){y.info("No files to generate (no root rule or rules feature disabled).");return}for(let n of t.data.patches)process.stdout.write(n.patch);y.info(Lf({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(M$,"renderDiff");ot();function $$(t){if(!t.data.hadConflict){y.info("No conflicts to resolve.");return}y.success("Lock file conflict resolved.");}s($$,"renderMerge");ap();cp();Yt();fo();ap();cp();ot();var SZ=300;function CZ(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(CZ,"normalizeWatchPath");function kZ(t,e){let r=CZ(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(kZ,"shouldIgnoreWatchPath");function EZ(t,e,r,n,o,i,a,l,c){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:i,permissionsCount:a,hooksCount:l,ignoreCount:c})}s(EZ,"featureFingerprint");async function j$(t,e,r={}){let n=e??process.cwd(),o=t.global===true?"global":"project",{context:i}=await yt(n,o),a=[i.canonicalDir,join(i.configDir,"agentsmesh.yaml"),join(i.configDir,"agentsmesh.local.yaml")],l=null,c=null,m=false,p=null,u=s(async()=>{if(m)return;l=null;let{config:C,context:S}=await yt(n,o),{canonical:k}=await ke(C,S.configDir,{},S.canonicalDir),P=k.mcp?Object.keys(k.mcp.mcpServers).length:0,N=k.permissions?k.permissions.allow.length+k.permissions.deny.length:0,F=k.hooks?Object.values(k.hooks).reduce((At,wt)=>At+(Array.isArray(wt)?wt.length:0),0):0,W=k.ignore.length,z=EZ(C.features,k.rules.length,k.commands.length,k.agents.length,k.skills.length,P,N,F,W),Q=c!==null&&c!==z;if(c=z,m)return;let at=await _c(t,n,{printMatrix:false});if(Rc(at),!m){if(Q){let At=await ip(t,n);lp(At,{verbose:t.verbose===true});}else y.info("Regenerated.");r.onCycle?.({featuresChanged:Q});}},"run"),f=s(()=>{let C=u().catch(S=>{if(!m){let k=S instanceof Error?S.message:String(S);y.error(k);}}).finally(()=>{p===C&&(p=null);});p=C;},"scheduleRun"),g=s(()=>{m||(l&&clearTimeout(l),l=setTimeout(f,SZ));},"schedule"),h=r.usePolling??process.platform==="win32",R=IZ.watch(a,{ignoreInitial:true,usePolling:h,...h&&r.pollIntervalMs!==void 0?{interval:r.pollIntervalMs}:{}});return R.on("all",(C,S)=>{kZ(i.canonicalDir,S)||g();}),await new Promise((C,S)=>{R.once("ready",C),R.once("error",S);}),y.info(o==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),p=u(),await p,p=null,{stop:s(async()=>{m=true,l&&(clearTimeout(l),l=null),await R.close(),p&&await p;},"stop")}}s(j$,"runWatch");Yt();Fp();async function Af(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await mf(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await ys(n),a=await qa(e,r),l=a.length>0?await gc(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let S of c){let k=i[S];k===void 0?f.push(S):k!==o.checksums[S]&&p.push(S);}for(let S of m)c.has(S)||u.push(S);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let S of g)l[S]!==o.extends[S]&&h.push(S);let R=uf(o.checksums,i,e.collaboration?.lock_features??[]);return {inSync:p.length===0&&u.length===0&&f.length===0&&h.length===0,hasLock:true,modified:p,added:u,removed:f,extendsModified:h,lockedViolations:R}}s(Af,"checkLockSync");fn();async function U$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n);await Wt(o,r);let a=await Af({config:o,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(U$,"runCheck");Yt();w();Fp();var OZ=".lock",AZ="<<<<<<<";async function fI(t){let e=join(t,OZ),r=await _(e);return r===null?false:r.includes(AZ)}s(fI,"hasLockConflict");async function K$(t,e,r){if(!await fI(t))throw new Error("No conflict to resolve.");let o=await ys(t),i=dirname(t),a=r?await qa(r,i):[],l=a.length>0?await gc(a):{},c=await df(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await pf(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}s(K$,"resolveLockConflict");async function W$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n),a=i.canonicalDir;return await fI(a)?(await K$(a,Ci(),o),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(W$,"runMerge");Yt();nf();function H$(t){let e=typeof t.path=="string"?t.path.trim():void 0,r=typeof t.target=="string"?t.target.trim():void 0,n=typeof t.as=="string"?t.as.trim():void 0;return {sync:t.sync===true,dryRun:t["dry-run"]===true,force:t.force===true,useExtends:t.extends===true,all:t.all===true,explicitPath:e||void 0,explicitTarget:r||void 0,explicitAs:n?dc.parse(n):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(H$,"readInstallFlags");var PZ=".install.lock";async function wf(t,e={}){return await mkdir(t,{recursive:true}),Rf(join(t,PZ),e)}s(wf,"acquireInstallLock");Yt();w();Uc();var DZ=promisify(execFile);function bf(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(bf,"ensureNotFlag");async function gI(t){let{stdout:e}=await DZ("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(gI,"runGit");async function z$(){try{return await gI(["--version"]),!0}catch{return false}}s(z$,"isGitAvailable");async function NZ(t,e){bf(t,"remote-url"),bf(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await gI(["ls-remote",t,o])).split(`
332
- `).map(c=>c.trim()).find(c=>c.length>0);if(!a)continue;let l=a.split(/\s+/)[0];if(l&&/^[0-9a-f]{40}$/i.test(l))return l}catch(i){n=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}s(NZ,"gitLsRemoteResolve");async function V$(t,e){bf(e,"remote-url");let r=t===""?"HEAD":t;if(bf(r,"ref"),/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await gI(["ls-remote",e,"HEAD"])).split(`
333
- `).find(a=>a.trim().length>0);if(!o)throw new Error(`Could not resolve HEAD for ${e}`);let i=o.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 NZ(e,r)}s(V$,"resolveRemoteRefForInstall");async function J$(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 V$(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Qa(l,"install",{cacheDir:Te(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}if(t.kind==="gitlab"){let l=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Qa(l,"install",{cacheDir:Te(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await Qa(i,"install",{cacheDir:Te(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(J$,"fetchInstallSource");async function Y$(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await J$(t);return {resolvedPath:r.resolvedPath,sourceForYaml:r.sourceForYaml,version:r.version}}catch(r){let n=r instanceof Error?r.message:String(r),o=new Error(`Failed to fetch from ${e}: ${n}. Check your network connection and try again.`);throw r instanceof Error&&(o.cause=r),o}}s(Y$,"resolveInstallResolvedPath");function hI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("tree");if(n<2||n+1>=r.length)return null;let o=r[0],i=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!i||!a?null:{org:o,repo:i,ref:a,path:l||""}}catch{return null}}s(hI,"parseGithubTreeUrl");function yI(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("blob");if(n<2||n+1>=r.length)return null;let o=r[0],i=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!i||!a||!l?null:{org:o,repo:i,ref:a,path:l}}catch{return null}}s(yI,"parseGithubBlobUrl");function _I(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("-");if(n<0||r[n+1]!=="tree")return null;let o=n+1;if(o+1>=r.length)return null;let i=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!i?null:{namespace:m,project:c,ref:i,path:a||""}}catch{return null}}s(_I,"parseGitlabTreeUrl");function RI(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("-");if(n<0||r[n+1]!=="blob")return null;let o=n+1;if(o+1>=r.length)return null;let i=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!i||!a?null:{namespace:m,project:c,ref:i,path:a}}catch{return null}}s(RI,"parseGitlabBlobUrl");var FZ=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function II(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||FZ.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(II,"parseGithubRepoUrl");function SI(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 n=r[r.length-1],o=r.slice(0,-1).join("/");return !o||!n?null:{namespace:o,project:n}}catch{return null}}s(SI,"parseGitlabRepoUrl");function CI(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(CI,"parseGitSshGithub");function kI(t){let e=t.match(/^git@gitlab\.com:(.+?)(?:\.git)?$/i);if(!e)return null;let n=e[1].replace(/\.git$/i,"").split("/").filter(Boolean);if(n.length<2)return null;let o=n[n.length-1];return {namespace:n.slice(0,-1).join("/"),project:o}}s(kI,"parseGitSshGitlab");w();var $Z=/^[A-Za-z]:[\\/]/,GZ=/^[A-Za-z]:\//;function X$(...t){return t.some(e=>e.includes("\\")||$Z.test(e))?win32:posix}s(X$,"pathApiFor");function pp(t){return t.replace(/\\/g,"/")}s(pp,"toPosixPath");function mp(t){return pp(t).replace(/^\/+|\/+$/g,"")}s(mp,"normalizeInstallPathField");function Pf(t){let e=pp(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||GZ.test(e)?e:`./${e}`}s(Pf,"normalizeLocalSourceForYaml");function gi(t){return {...t,source:t.source_kind==="local"?Pf(t.source):t.source,...t.path!==void 0?{path:mp(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>mp(e))}:{}}}s(gi,"normalizePersistedInstallPaths");function Z$(t,e,r){let n=X$(t,e),o=n.normalize(t),i=n.normalize(e),a=mp(r),l=`${n.sep}.agentsmesh${n.sep}`,c=o.indexOf(l);if(c>=0){let p=o.slice(0,c),u=o.slice(c+l.length),f=mp(u),g=pp(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Pf(g)}}let m=pp(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:Pf(m)}}s(Z$,"localParsedFromAbsPath");async function EI(t,e,r){let n=t.trim(),o=r?.trim().replace(/\\/g,"/")??"";if(n.startsWith("git+")){let p=n.lastIndexOf("#"),u=p<0?n:n.slice(0,p),f=p<0?"HEAD":n.slice(p+1),g=u.slice(4);return {kind:"git",rawRef:f,gitPlusBase:g,gitRemoteUrl:g,pathInRepo:o}}if(n.startsWith("https://")||n.startsWith("http://")){let p=hI(n)??yI(n);if(p)return {kind:"github",rawRef:p.ref,org:p.org,repo:p.repo,gitRemoteUrl:`https://github.com/${p.org}/${p.repo}.git`,pathInRepo:o||p.path};let u=II(n);if(u)return {kind:"github",rawRef:"HEAD",org:u.org,repo:u.repo,gitRemoteUrl:`https://github.com/${u.org}/${u.repo}.git`,pathInRepo:o};let f=_I(n)??RI(n);if(f)return {kind:"gitlab",rawRef:f.ref,org:f.namespace,repo:f.project,gitRemoteUrl:`https://gitlab.com/${f.namespace}/${f.project}.git`,pathInRepo:o||f.path};let g=SI(n);if(g)return {kind:"gitlab",rawRef:"HEAD",org:g.namespace,repo:g.project,gitRemoteUrl:`https://gitlab.com/${g.namespace}/${g.project}.git`,pathInRepo:o}}if(n.startsWith("git@github.com:")){let p=CI(n);if(!p)throw new Error(`Invalid GitHub SSH URL: ${n}`);return {kind:"github",rawRef:"HEAD",org:p.org,repo:p.repo,gitRemoteUrl:`https://github.com/${p.org}/${p.repo}.git`,pathInRepo:o}}if(n.startsWith("git@gitlab.com:")){let p=kI(n);if(!p)throw new Error(`Invalid GitLab SSH URL: ${n}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:o}}if(n.startsWith("git@")){let p=n.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!p)throw new Error(`Invalid SSH git URL: ${n}`);let u=p[1],f=p[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${u}/${f}.git`,pathInRepo:o}}let i=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let p=i[1],u=i[2];return {kind:"github",rawRef:i[3],org:p,repo:u,gitRemoteUrl:`https://github.com/${p}/${u}.git`,pathInRepo:o}}let a=n.match(/^github:([^/]+)\/([^/@]+)$/);if(a){let p=a[1],u=a[2];return {kind:"github",rawRef:"HEAD",org:p,repo:u,gitRemoteUrl:`https://github.com/${p}/${u}.git`,pathInRepo:o}}let l=n.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(l){let p=l[1],u=l[2];return {kind:"gitlab",rawRef:l[3],org:p,repo:u,gitRemoteUrl:`https://gitlab.com/${p}/${u}.git`,pathInRepo:o}}let c=n.match(/^gitlab:(.+)\/([^/@]+)$/);if(c){let p=c[1],u=c[2];return {kind:"gitlab",rawRef:"HEAD",org:p,repo:u,gitRemoteUrl:`https://gitlab.com/${p}/${u}.git`,pathInRepo:o}}let m=resolve(e,n);if(!await $(m))throw new Error(`Path does not exist: ${m}`);return Z$(m,e,o)}s(EI,"parseInstallSource");IR();function gn(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(gn,"featuresFromCanonical");async function Tf(t,e={}){let{sliceRoot:r,implicitPick:n}=await Zd(t),{canonical:o,cleanup:i}=await Qd(r,{...e,enableTargetEntityMappers:true});return {canonical:o,features:gn(o),implicitPick:n,cleanup:i}}s(Tf,"discoverFromContentRoot");function Q$(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(Q$,"validateSkill");function q$(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(q$,"validateRule");function tG(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(tG,"validateCommand");function eG(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(eG,"validateAgent");function ne(t){return basename(t.source).replace(/\.md$/i,"")}s(ne,"ruleSlug");function BZ(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(BZ,"featuresFromImplicitPick");function Cc(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??BZ(r);if(!r&&!n)return t;let o=new Set(n??[]),i={...t,mcp:!n||o.has("mcp")?t.mcp:null,permissions:!n||o.has("permissions")?t.permissions:null,hooks:!n||o.has("hooks")?t.hooks:null,ignore:!n||o.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(l=>a.has(l.name))};}else n&&!o.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(l=>a.has(ne(l)))};}else n&&!o.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(l=>a.has(l.name))};}else n&&!o.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(l=>a.has(l.name))};}else n&&!o.has("agents")&&(i={...i,agents:[]});return i}s(Cc,"narrowDiscoveredForInstallScope");AR();async function rG(t,e,r,n,o={}){let i=await ef(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:a,cleanup:l}=await Tf(i.discoveryRoot,o),c=Cc(a,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:s(async()=>{await Promise.allSettled([l(),i.cleanup()]);},"combinedCleanup")},narrowed:c,discoveredFeatures:gn(c)}}s(rG,"resolveManualDiscoveredForInstall");Ro();cR();w();Pt();var KZ=(()=>{let t=new Map;for(let r of bt){let n=r.project.managedOutputs,o=[...n?.dirs??[],...n?.files??[],...r.detectionPaths];for(let i of o){let a=i.replace(/\/$/,""),l=t.get(a)??new Set;l.add(r.id),t.set(a,l);}}let e=[];for(let[r,n]of t){if(n.size!==1)continue;let[o]=[...n];e.push({prefix:r,target:o});}return e.sort((r,n)=>n.prefix.length-r.prefix.length)})();function WZ(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(WZ,"norm");function xf(t){let e=WZ(t);if(e){for(let{prefix:r,target:n}of KZ)if(e===r||e.startsWith(`${r}/`))return n}}s(xf,"targetHintFromNativePath");function LI(t,e){return xf(t)===e}s(LI,"pathSupportsNativePick");function nG(t,e){if(!t||!e)return;let r=xf(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(nG,"validateTargetMatchesPath");function oG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(oG,"extendPickHasArrays");w();w();Jt();async function iG(t,e){let r=join(t,...He.split("/")),n=join(t,...e.split("/")),o=await v(n),i=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let l=relative(r,a).replace(/\\/g,"/");if(l.startsWith("..")||l==="")continue;let m=l.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(iG,"inferGeminiCommandNamesFromFiles");Jt();cr();w();async function Na(t){let e=await v(t),r=new Set;for(let n of e){if(basename(n)==="SKILL.md"){r.add(basename(dirname(n)));continue}!relative(t,n).replace(/\\/g,"/").includes("/")&&n.toLowerCase().endsWith(".md")&&r.add(basename(n,".md"));}return [...r].filter(Boolean).sort()}s(Na,"skillNamesFromNativeSkillDir");w();wr();async function aG(t,e){let r=join(t,...e.split("/"));if(e.startsWith(si)){let n=await v(r),o=[...new Set(n.filter(i=>i.toLowerCase().endsWith(".prompt.md")).map(i=>basename(i,".prompt.md")))].sort();return o.length?{commands:o}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let n=await v(r),o=[...new Set(n.filter(i=>i.includes(".instructions.md")).map(i=>basename(i).replace(/\.instructions\.md$/i,"")))].sort();return o.length?{rules:o}:{}}if(e.startsWith(".github/instructions")){let n=await v(r),o=new Set;for(let a of n){let l=basename(a);l.toLowerCase().endsWith(".instructions.md")?o.add(l.replace(/\.instructions\.md$/i,"")):l.toLowerCase().endsWith(".md")&&o.add(basename(a,".md"));}let i=[...o].sort();return i.length?{rules:i}:{}}if(e.startsWith(".github/skills")){let n=await Na(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await v(r),o=[...new Set(n.filter(i=>i.toLowerCase().endsWith(".agent.md")).map(i=>basename(i,".agent.md")))].sort();return o.length?{agents:o}:{}}return {}}s(aG,"inferCopilotPickFromPath");async function Je(t,e){let r=await v(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}s(Je,"mdNames");async function cG(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===He||n.startsWith(`${He}/`)){let i=await iG(t,n);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let i=await Je(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".claude/rules")){let i=await Je(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".claude/agents")){let i=await Je(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".claude/skills/")){let a=n.replace(/^\.claude\/skills\/?/,"").split("/").filter(Boolean)[0];return a?{skills:[a]}:{}}return {}}if(r==="cursor"){if(n.startsWith(".cursor/rules")){let i=await Je(o,".mdc");return i.length?{rules:i}:{}}if(n.startsWith(".cursor/commands")){let i=await Je(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".cursor/agents")){let i=await Je(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".cursor/skills")){let i=await Na(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return aG(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let i=await Je(o,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(n.startsWith(Zt)){let i=await Na(o);return i.length?{skills:i}:{}}if(n.startsWith(Dn)){let i=await Je(o,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let i=await Je(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".continue/prompts")){let i=await Je(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".continue/skills")){let i=await Na(o);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let i=await Je(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".junie/rules")){let i=await Je(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".junie/agents")){let i=await Je(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".junie/skills")){let i=await Na(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await v(o),a=[...new Set(i.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(cG,"inferImplicitPickFromNativePath");function mG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(mG,"isImplicitPickEmpty");mR();function dp(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(dp,"normalizePath");function tQ(t,e){let r=dp(t),n=dp(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(tQ,"overlapsPath");function Df(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(Df,"addUnique");async function eQ(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),n=s(async()=>{await rm(e,{recursive:true,force:true});},"cleanup");try{return await cp$1(t,r,{recursive:!0}),{stageRoot:r,cleanup:n}}catch(o){throw await n(),o}}s(eQ,"makeStageRoot");function rQ(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:Df(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=dp(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:Df(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:Df(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=dp(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:Df(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(rQ,"buildPickFromResults");function nQ(t,e,r,n){let o=join(e,...dp(t).split("/")),i=r.filter(a=>tQ(o,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}". Try --path "${t}" without --target so agentsmesh can auto-detect the layout, or use --as <rules|commands|agents|skills> to install the directory as a flat collection.`);return {features:[...new Set(i.map(a=>a.feature))],pick:rQ(i,e)}}s(nQ,"scopeImportedResults");async function AI(t,e){let{stageRoot:r,cleanup:n}=await eQ(t);try{let o=await tp(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s(AI,"stageImportedNativeRepo");async function wI(t,e,r){let n=await AI(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...nQ(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(wI,"stageNativeInstallScope");async function fG(t,e,r,n){let o=n.explicitTarget?.trim();o&&Qe.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");nG(o,i);let a=join(t,".agentsmesh"),l=await $(a),c=i?xf(i):void 0,p=!l&&!o&&(!i||c!==void 0)?await Ud(t)??void 0:void 0;if(!o&&c&&p&&c!==p)throw new Error(`Install path suggests native layout "${c}" but auto-detect imported "${p}". Use --target ${c} for this path, or install from the repo root without a conflicting subtree path.`);let u=o??c??p,f=!!i&&!!u&&!i.startsWith(".agentsmesh");if(!l&&u){if(f){let P=await wI(t,i,u);return {discoveryRoot:P.stageRoot,implicitPick:P.pick,scopedFeatures:P.features,yamlTarget:u,importHappened:true,cleanup:P.cleanup}}let k=await AI(t,u);return {discoveryRoot:i?join(k.stageRoot,i):k.stageRoot,yamlTarget:u,importHappened:true,cleanup:k.cleanup}}let g;l?i?u&&LI(i,u)?g=t:g=e:g=t:g=e;let h,R,C;if(f&&u){let k=await wI(t,i,u);g=k.stageRoot,h=k.pick,R=k.features,C=k.cleanup;}else if(g===t&&i&&u&&LI(i,u)&&(h=await cG(t,i,u),mG(h)))throw new Error(`No installable native resources found under "${i}" for target "${u}". Try --path "${i}" without --target so agentsmesh can auto-detect the layout, or use --as <rules|commands|agents|skills> to install the directory as a flat collection.`);let S;return o?S=o:u&&(h&&oG(h)||(R?.length??0)>0)&&(S=u),{discoveryRoot:g,implicitPick:h,scopedFeatures:R,yamlTarget:S,importHappened:C!==void 0,cleanup:C}}s(fG,"prepareInstallDiscovery");async function bI(t,e,r,n,o={}){let i=await fG(t,e,r,{explicitTarget:n}),{canonical:a,implicitPick:l,cleanup:c}=await Tf(i.discoveryRoot,o),m=i.cleanup,u={...i,cleanup:s(async()=>{await Promise.allSettled([c(),...m?[m()]:[]]);},"mergedCleanup")},f=l??i.implicitPick,g=Cc(a,{implicitPick:f,scopedFeatures:i.scopedFeatures}),h=gn(g);return {prep:u,discovered:a,implicitPick:f,narrowed:g,discoveredFeatures:h}}s(bI,"resolveDiscoveredForInstall");var iQ=[".claude-plugin","marketplace.json"];async function aQ(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(aQ,"dirExists");function lQ(t){if(typeof t!="string"||t.length===0||t.startsWith("/"))return null;let e=t.replace(/^\.\/+/,"").replace(/\/+$/,"");return e.split("/").some(r=>r==="..")?null:e}s(lQ,"normalizeSource");async function hG(t,e,r){let n=join(t,...iQ),o;try{o=await readFile(n,"utf-8");}catch{return null}let i;try{i=JSON.parse(o);}catch{return null}if(typeof i!="object"||i===null||!Array.isArray(i.plugins))return null;let a=i.plugins,l=[];for(let c of a){if(typeof c!="object"||c===null)continue;let m=lQ(c.source);if(!m)continue;let p=join(t,m);if(!await aQ(p))continue;let u=await e(p,m);r(u)&&l.push({path:m,layout:u});}return l}s(hG,"detectMarketplaceSubPacks");async function fp(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(fp,"dirExists");async function hi(t){try{return (await readdir(t,{withFileTypes:!0})).map(r=>({name:r.name,isDir:r.isDirectory(),isFile:r.isFile()}))}catch{return []}}s(hi,"listDirEntries");function yG(t){return t.endsWith(".instructions.md")?"copilot-instructions":t.endsWith(".md")?"md":t.endsWith(".mdc")?"mdc":t.endsWith(".toml")?"toml":null}s(yG,"classifyFileShape");var pQ=["rules","commands","agents","skills","mcp.json","hooks.yaml","permissions.yaml","ignore"],uQ=[".cursorrules",".windsurfrules"];async function RG(t){let e=join(t,".agentsmesh");if(!await fp(e))return null;let r=await hi(e),n=new Set(r.map(o=>o.name));for(let o of pQ)if(n.has(o))return {path:".agentsmesh"};return null}s(RG,"detectCanonical");async function IG(t){for(let e of uQ)try{if((await stat(join(t,e))).isFile())return {path:e}}catch{}return null}s(IG,"detectRootRule");async function SG(t){try{if((await stat(join(t,"SKILL.md"))).isFile())return {path:"SKILL.md"}}catch{}return null}s(SG,"detectRootSkill");Co();var fQ={rules:"rules",commands:"commands",agents:"agents",skills:"skills"},gQ=[".claude-plugin",".codex-plugin",".cursor-plugin"],hQ=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;async function CG(t){let e=join(t,"skills"),r=await hi(e);for(let n of r)if(!(!n.isDir||n.name.startsWith("_")||!hQ.test(n.name))&&await fp(join(e,n.name)))try{if((await stat(join(e,n.name,"SKILL.md"))).isFile())return {path:"skills"}}catch{continue}return null}s(CG,"detectSkillPack");async function kG(t){let e=[];for(let[r,n]of Object.entries(fQ)){let o=join(t,r),i=await hi(o),a=new Set;for(let l of i){if(!l.isFile||In(l.name))continue;let c=yG(l.name);c&&a.add(c);}for(let l of a)e.push({path:r,suggestedAs:n,fileShape:l});}return e}s(kG,"detectFlatCollections");async function EG(t){let e=[];for(let r of gQ)await fp(join(t,r))&&e.push({path:r});return e}s(EG,"detectToolNativeManifests");async function xI(t,e){let r=await RG(t);if(r)return {canonical:r,skillPack:null,rootSkill:null,rootRule:null,flatCollections:[],toolNativeManifests:[]};let n=await CG(t),o=n?null:await SG(t),i=await kG(t),a=n||o||i.length>0?null:await IG(t),l=await EG(t);return {canonical:r,skillPack:n?{path:e?`${e}/skills`:"skills"}:null,rootSkill:o?{path:e?`${e}/SKILL.md`:"SKILL.md"}:null,rootRule:a?{path:e?`${e}/${a.path}`:a.path}:null,flatCollections:i.map(c=>({...c,path:e?`${e}/${c.path}`:c.path})),toolNativeManifests:l.map(c=>({path:e?`${e}/${c.path}`:c.path}))}}s(xI,"detectFlatLayout");function TI(t){return t.canonical!==null||t.skillPack!==null||t.rootSkill!==null||t.rootRule!==null||t.flatCollections.length>0}s(TI,"hasContent");async function LG(t,e){let r=await hi(t),n=[];for(let o of r){if(!o.isDir||o.name.startsWith("."))continue;let i=join(t,o.name),a=e?`${e}/${o.name}`:o.name,l=await xI(i,a);TI(l)&&n.push({path:a,layout:l});}return n}s(LG,"collectSubPackCandidates");async function yQ(t,e){if(TI(e))return [];let r=await hG(t,xI,TI);if(r&&r.length>0)return r;let n=await LG(t,"");if(n.length>=2)return n;let o=await hi(t);for(let i of o){if(!i.isDir||i.name.startsWith("."))continue;let a=await LG(join(t,i.name),i.name);if(a.length>=2)return a}return []}s(yQ,"detectSubPacks");async function AG(t){let e=await xI(t,"");if(e.canonical)return {...e,subPacks:[]};let r=await yQ(t,e);return {...e,subPacks:r}}s(AG,"detectLayout");w();j();async function bG(t){let e;try{e=await readdir(t);}catch{return null}let r=e.sort().find(c=>c.toLowerCase().endsWith(".mdc"));if(!r)return null;let n=await _(join(t,r));if(!n)return null;let o=Fr(n,join(t,r));if(!o.ok)return null;let{frontmatter:i}=o.value,a="alwaysApply"in i,l="trigger"in i;return a&&l?null:a?"cursor":l?"windsurf":null}s(bG,"inferMdcTarget");zd();Xd();function kQ(t){let e=t.indexOf("#");return e<0?{path:t,anchor:""}:{path:t.slice(0,e),anchor:t.slice(e)}}s(kQ,"splitAnchor");function EQ(t){return t.split(sep).join("/")}s(EQ,"toForwardSlash");async function LQ(t){try{return await stat(t),!0}catch{return false}}s(LQ,"pathExists");async function DG(t){let{link:e,fromFile:r,contentRoot:n,includedPaths:o}=t,{path:i,anchor:a}=kQ(e.path);if(i===""||isAbsolute(i))return {link:e,classification:"unresolvable",resolvedRelative:null,anchor:a};let l=join(n,r,".."),c=normalize(resolve(l,i)),m=normalize(resolve(n)),p=relative(m,c);if(p.startsWith("..")||isAbsolute(p))return {link:e,classification:"unresolvable",resolvedRelative:null,anchor:a};let u=EQ(p);return await LQ(c)?o.has(u)?{link:e,classification:"in-tree-included",resolvedRelative:u,anchor:a}:{link:e,classification:"resolvable-outside",resolvedRelative:u,anchor:a}:{link:e,classification:"unresolvable",resolvedRelative:u,anchor:a}}s(DG,"resolveLink");var OQ=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,AQ=/(!?)\[[^\]\n]*\]\(([^)\n]+)\)/g,wQ=/^\s*\[([^\]\n]+)\]:\s*(.+?)\s*$/gm;function bQ(t){let e=[];for(let r of t.matchAll(OQ)){let n=r.index??0;e.push([n,n+r[0].length]);}return e}s(bQ,"getFencedCodeRanges");function NG(t,e){for(let[r,n]of e)if(t>=r&&t<n)return true;return false}s(NG,"isInRanges");function FG(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(FG,"normalizeDestination");function Nf(t){let e=bQ(t),r=[];for(let n of t.matchAll(AQ)){let o=n.index??0;if(NG(o,e))continue;let i=n[1]==="!",a=n[2];if(a===void 0)continue;let l=t.indexOf("(",o);if(l<0)continue;let c=l+1;r.push({kind:i?"image":"inline",destination:FG(a),destinationOffset:c,destinationLength:a.length});}for(let n of t.matchAll(wQ)){let o=n.index??0;if(NG(o,e))continue;let i=(n[1]??"").trim(),a=n[2]??"";if(i===""||a.trim()==="")continue;let l=o,c=t.indexOf("]:",l);if(c<0)continue;let m=c+2;for(;m<t.length&&(t[m]===" "||t[m]===" ");)m+=1;r.push({kind:"reference-def",destination:FG(a),label:i,destinationOffset:m,destinationLength:a.trimEnd().length});}return r}s(Nf,"scanMarkdownLinks");function vG(t,e){if(e.length===0)return t;let r=[...e].sort((o,i)=>i.offset-o.offset),n=t;for(let o of r)n=`${n.slice(0,o.offset)}${o.replacement}${n.slice(o.offset+o.length)}`;return n}s(vG,"applyRangeRewrites");function PQ(t){return !(t.length===0||t.startsWith("#")||t.startsWith("/")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))}s(PQ,"isCandidateRelativePath");function TQ(t){let e=t.replaceAll("\\","/");return e==="{baseDir}"?".":e.startsWith("{baseDir}/")?e.slice(10):e}s(TQ,"stripPath");function xQ(t){let e=t.destination;return PQ(e)?{raw:e,path:TQ(e),kind:t.kind,...t.label!==void 0?{label:t.label}:{}}:null}s(xQ,"toScannedLink");function MG(t){let e=[];for(let r of Nf(t)){let n=xQ(r);n!==null&&e.push(n);}return e}s(MG,"scanRelativeLinks");function kc(t,e){let r=t.replaceAll("\\","/"),n=e.replaceAll("\\","/"),o=r.endsWith("/")?r:`${r}/`;return n.startsWith(o)?n.slice(o.length):n}s(kc,"toForwardSlashRelative");function $G(t,e,r,n,o){let i=new Set;for(let a of e){i.add(kc(t,a.source));for(let l of a.supportingFiles)i.add(kc(t,l.absolutePath));}for(let a of r)i.add(kc(t,a.source));for(let a of n)i.add(kc(t,a.source));for(let a of o)i.add(kc(t,a.source));return i}s($G,"buildIncludedPaths");function NQ(t,e,r,n){let o=[];for(let i of t)o.push({kind:"skill",name:i.name,body:i.body,sourcePath:i.source});for(let i of e)o.push({kind:"agent",name:i.name,body:i.body,sourcePath:i.source});for(let i of r)o.push({kind:"command",name:i.name,body:i.body,sourcePath:i.source});for(let i of n)o.push({kind:"rule",name:basename(i.source,".md"),body:i.body,sourcePath:i.source});return o}s(NQ,"listScannables");async function GG(t,e,r,n,o,i){let a=NQ(e,r,n,o),l=[];for(let c of a){let m=MG(c.body);if(m.length===0)continue;let p=kc(t,c.sourcePath),u=[];for(let f of m){let g=await DG({link:f,fromFile:p,contentRoot:t,includedPaths:i});g.classification!=="in-tree-included"&&u.push(g);}u.length>0&&l.push({entityKind:c.kind,entityName:c.name,resolved:u});}return l}s(GG,"detectBrokenLinks");Xd();async function jG(t,e,r={}){let n=new Map,o=new Map,i=[],a=[...e].sort((p,u)=>p.precedence-u.precedence);for(let p of a){let{commands:u,cleanup:f}=await Vd(join(t,p.dir),{restrictToTarget:p.target,parseOpts:r});i.push(f);for(let g of u){if(n.get(g.name)===void 0){n.set(g.name,{command:g,precedence:p.precedence});continue}let R=o.get(g.name)??[];R.push({path:g.source,precedence:p.precedence}),o.set(g.name,R);}}let l=[];for(let[p,u]of o){let f=n.get(p);if(f===void 0)throw new Error(`mergeCommands invariant: loser without winner for "${p}"`);l.push({basename:p,winnerPath:f.command.source,loserPaths:u.map(g=>g.path)});}return l.sort((p,u)=>p.basename.localeCompare(u.basename)),{commands:[...n.values()].map(p=>p.command).sort((p,u)=>p.name.localeCompare(u.name)),dedups:l,cleanup:s(async()=>{await Promise.allSettled(i.map(p=>p()));},"cleanup")}}s(jG,"mergeCommands");async function UG(t,e,r={}){let[n,o,i,a]=await Promise.all([Bv(`${t}/skills`,r),Yd(`${t}/agents`,{parseOpts:r}),Jd(`${t}/rules`,{parseOpts:r}),jG(t,e.mergeFromToolDirs,r)]),l=[...o.agents],c=[...i.rules],m=$G(t,n,l,a.commands,c),p=await GG(t,n,l,a.commands,c,m),u=s(async()=>{await Promise.allSettled([i.cleanup(),o.cleanup(),a.cleanup()]);},"cleanup");return {skills:n,agents:l,commands:a.commands,rules:c,dedups:a.dedups,brokenLinks:p,cleanup:u}}s(UG,"aggregateAnthropicSkillPack");var BG={mergeFromToolDirs:[{dir:"commands",precedence:0},{dir:".claude/commands",target:"claude-code",precedence:1},{dir:".gemini/commands",target:"gemini-cli",precedence:2}]};el();function MQ(t){return {rules:[...t.rules],commands:[...t.commands],agents:[...t.agents],skills:[...t.skills],mcp:null,permissions:null,hooks:null,ignore:[]}}s(MQ,"aggregateToCanonical");function Ff(){return {}}s(Ff,"emptyPrep");async function $Q(t,e){let r=[];for(let n of e)if(n.fileShape==="mdc"&&!n.inferredTarget){let o=await bG(join(t,n.path));r.push(o?{...n,inferredTarget:o}:n);}else r.push(n);return r}s($Q,"enrichMdcTargets");function WG(t){return t.canonical?"canonical-agentsmesh":t.skillPack||t.rootSkill?"anthropic-skill-pack":t.rootRule||t.toolNativeManifests.length>0?"tool-native":"unknown"}s(WG,"deriveSourceType");async function GQ(t,e){let r=await Bp(t,e);return {rules:[],commands:[],agents:[],skills:r?[r]:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(GQ,"rootSkillToCanonical");async function jQ(t,e){let r=join(t,e),n=await readFile(r,"utf-8").catch(()=>""),o=`Imported from ${e}`;return {rules:n?[{source:r,root:true,targets:[],description:o,globs:[],body:n}]:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(jQ,"rootRuleToCanonical");async function HG(t){let e=t.parseOpts??{};if(t.explicitAs)return {implicitPick:void 0,...await rG(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick,e)};if(t.explicitTarget)return bI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e);let r=await AG(t.contentRoot),n=await $Q(t.contentRoot,r.flatCollections),o={...r,flatCollections:n};if(o.skillPack&&!o.canonical){let a=await UG(t.contentRoot,BG,e),l=MQ(a);return {prep:{cleanup:a.cleanup},implicitPick:void 0,narrowed:l,discoveredFeatures:gn(l),layout:o,aggregate:a}}if(o.rootSkill&&!o.canonical&&!o.skillPack){let a=await GQ(t.contentRoot,e);return {prep:Ff(),implicitPick:void 0,narrowed:a,discoveredFeatures:gn(a),layout:o}}if(o.rootRule&&!o.canonical&&!o.skillPack&&!o.rootSkill&&o.flatCollections.length===0){let a=await jQ(t.contentRoot,o.rootRule.path);return {prep:Ff(),implicitPick:void 0,narrowed:a,discoveredFeatures:gn(a),layout:o}}return o.subPacks.length>0?{prep:Ff(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:o.flatCollections.length>0?{prep:Ff(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:{...await bI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e),layout:o}}s(HG,"resolveInstallDiscovery");function VG(t){let e=new Set;t.skillPack&&e.add("skills"),t.rootSkill&&e.add("skills");for(let r of t.flatCollections)e.add(r.suggestedAs);return [...e]}s(VG,"featuresFromLayout");function UQ(t){return t.replace(/[/\\]+/g,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}s(UQ,"subPackSlug");function zG(t,e,r){let n=VG(t.layout),o=n[0];return {name:`${e}-${UQ(t.path)}`,source:r,path:t.path,as:o,features:n}}s(zG,"targetFromSubPack");function JG(t,e,r){return {name:e,source:r,path:t.path,as:t.suggestedAs,target:t.inferredTarget,features:[t.suggestedAs]}}s(JG,"targetFromCollection");function YG(t){let{layout:e,sourceName:r,sourceForYaml:n,explicitPath:o,explicitAs:i,explicitTarget:a}=t;if(o||i||a)return {targets:[],isMarketplace:false};if(e.canonical||e.skillPack)return {targets:[],isMarketplace:false};if(e.subPacks.length>=1)return BQ(t);if(e.flatCollections.length===1){let l=e.flatCollections[0];return {targets:[JG(l,r,n)],isMarketplace:false}}return e.flatCollections.length>1?KQ(t):{targets:[],isMarketplace:false}}s(YG,"selectInstallCandidates");function BQ(t){let{layout:e,sourceName:r,sourceForYaml:n}=t;if(t.all)return {targets:e.subPacks.map(a=>zG(a,r,n)),isMarketplace:true};if(t.force||!t.tty){let a=e.subPacks.map(l=>({path:l.path,features:VG(l.layout)})).map(l=>` - ${l.path} (${l.features.join(", ")})`).join(`
333
+ `),false}}s(wI,"seedAgentsmeshMcpEntry");function x$(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(x$,"mapResults");async function D$(t,e){let r=e??process.cwd(),n=t.from;if(typeof n!="string"||!n)throw new Error("--from is required. Example: agentsmesh import --from claude-code");let o=n.toLowerCase().trim(),i=t.global===true?"global":"project";if(Fe(o)){let p=Oi(r,i),f=await vf(o).importFrom(p.rootBase,{scope:i});return f.length>0&&await wI(p.rootBase),{exitCode:0,data:{scope:i,target:o,files:x$(f,p.rootBase)}}}let a,l;try{({config:a,context:l}=await yt(r,i));}catch{throw new Error(`Unknown --from "${n}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${vt.join(", ")}.`)}await Gt(a,r);let c=ot(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...vt,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:i});return m.length>0&&await wI(l.rootBase),{exitCode:0,data:{scope:i,target:o,files:x$(m,l.rootBase)}}}s(D$,"runImport");Zt();ho();function Mf(t){let e=[],r={new:0,updated:0,unchanged:0,deleted:0};for(let n of t){if(n.status==="unchanged"){r.unchanged++;continue}if(n.status==="created"){r.new++;let o=createTwoFilesPatch(`${n.path} (current)`,`${n.path} (generated)`,"",n.content,void 0,void 0,{context:3});e.push({path:n.path,patch:o});continue}if(n.status==="updated"&&n.currentContent!==void 0){r.updated++;let o=createTwoFilesPatch(`${n.path} (current)`,`${n.path} (generated)`,n.currentContent,n.content,void 0,void 0,{context:3});e.push({path:n.path,patch:o});continue}}return {diffs:e,summary:r}}s(Mf,"computeDiff");function $f(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s($f,"formatDiffSummary");Mr();async function F$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(g=>g.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Gt(a,r);let{canonical:c}=await Ee(a,l.configDir,{},l.canonicalDir),m=await vr({config:a,canonical:c,projectRoot:l.rootBase,scope:n,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}=Mf(m);return {exitCode:0,data:{files:m.filter(g=>g.status!=="unchanged"&&g.status!=="skipped").map(g=>({path:g.path,target:g.target,status:g.status})),patches:p.map(g=>({path:g.path,patch:g.patch})),summary:{created:u.new,updated:u.updated,unchanged:u.unchanged,deleted:u.deleted}}}}s(F$,"runDiff");Zt();ho();A();ae();Pi();wt();var PZ=[{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 v$(t){let e=new Set(t.enabledFeatures),r=[];for(let n of PZ)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Br(t.capabilities[n.capabilityKey]).level!=="none"||r.push(x(n.file,t.target,`${t.target} does not support ${n.label}; canonical entries are silently dropped during generation. Disable the feature for this target or remove the canonical content.`));return r}s(v$,"lintSilentFeatureDrops");wt();var TZ=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function xZ(t){let r=t.match(TZ)?.groups?.path;return typeof r=="string"?r:null}s(xZ,"extractScriptToken");function M$(t){if(t.hasScriptProjection)return [];let e=t.canonical.hooks;if(!e)return [];let r=[];for(let n of Object.values(e))if(Array.isArray(n))for(let o of n){if(typeof o?.command!="string")continue;let i=xZ(o.command);i&&r.push(x(".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(M$,"lintHookScriptReferences");wt();function $$(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(x(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($$,"lintRuleScopeInversion");var DZ=["node_modules",".git","dist","coverage",".agentsmesh"];async function NZ(t){return (await $(t)).filter(n=>{let o=relative(t,n);return !DZ.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(NZ,"getProjectFiles");async function Gf(t,e,r,n,o={}){let i=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],l=n?a.filter(k=>n.includes(k)):a,c=t.features.includes("rules"),m=t.features.includes("commands"),p=t.features.includes("mcp"),u=t.features.includes("permissions"),f=t.features.includes("hooks"),g=[],h=i==="global"?[]:await NZ(r);for(let k of l){let C=ot(k),R=Fe(k)?vf(k):C;R?.capabilities&&g.push(...v$({target:k,capabilities:R.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...M$({target:k,canonical:e,hasScriptProjection:C?.postProcessHookOutputs!==void 0})),c&&g.push(...$$({target:k,canonical:e,preservesManualActivation:C?.preservesManualActivation===true})),c&&R?.lintRules&&g.push(...R.lintRules(e,r,h,{scope:i})),C?.generators.lint&&g.push(...C.generators.lint(e));let P={scope:i};m&&R?.lint?.commands&&g.push(...R.lint.commands(e,P)),p&&R?.lint?.mcp&&g.push(...R.lint.mcp(e,P)),u&&R?.lint?.permissions&&g.push(...R.lint.permissions(e,P)),f&&R?.lint?.hooks&&g.push(...R.lint.hooks(e,P));}let I=g.some(k=>k.level==="error");return {diagnostics:g,hasErrors:I}}s(Gf,"runLint");Mr();async function j$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(u=>u.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Gt(a,r);let{canonical:c}=await Ee(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await Gf(a,c,l.configDir,i,{scope:n});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(j$,"runLintCmd");st();function U$(t){let{data:e}=t;if(e.diagnostics.length===0){y.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),n=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)y.error(`${a.file} (${a.target}): ${a.message}`);for(let a of n)y.warn(`${a.file} (${a.target}): ${a.message}`);let o=e.summary.errors,i=e.summary.warnings;y.info(`${o} error${o!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(U$,"renderLint");st();function B$(t){let{data:e}=t;if(!e.hasLock){y.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){y.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);y.error("Conflict detected:");for(let n of e.extendsModified)y.error(` extend "${n}" was modified`);for(let n of e.modified){let o=r.has(n)?" [LOCKED]":"";y.error(` ${n} was modified${o}`);}for(let n of e.added){let o=r.has(n)?" [LOCKED]":"";y.error(` ${n} was added${o}`);}for(let n of e.removed){let o=r.has(n)?" [LOCKED]":"";y.error(` ${n} was removed${o}`);}y.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(B$,"renderCheck");st();function K$(t){let{data:e}=t;if(e.files.length===0){y.info(`Nothing to import from ${e.target}.`);return}for(let n of e.files)y.success(`${n.from} \u2192 ${n.to}`);let r=e.scope==="global"?" --global":"";y.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(K$,"renderImport");st();function W$(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){y.info("No files to generate (no root rule or rules feature disabled).");return}for(let n of t.data.patches)process.stdout.write(n.patch);y.info($f({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(W$,"renderDiff");st();function H$(t){if(!t.data.hadConflict){y.info("No conflicts to resolve.");return}y.success("Lock file conflict resolved.");}s(H$,"renderMerge");pp();dp();Zt();ho();pp();dp();st();var MZ=300;function $Z(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s($Z,"normalizeWatchPath");function GZ(t,e){let r=$Z(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(GZ,"shouldIgnoreWatchPath");function jZ(t,e,r,n,o,i,a,l,c){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:i,permissionsCount:a,hooksCount:l,ignoreCount:c})}s(jZ,"featureFingerprint");async function V$(t,e,r={}){let n=e??process.cwd(),o=t.global===true?"global":"project",{context:i}=await yt(n,o),a=[i.canonicalDir,join(i.configDir,"agentsmesh.yaml"),join(i.configDir,"agentsmesh.local.yaml")],l=null,c=null,m=false,p=null,u=s(async()=>{if(m)return;l=null;let{config:k,context:C}=await yt(n,o),{canonical:R}=await Ee(k,C.configDir,{},C.canonicalDir),P=R.mcp?Object.keys(R.mcp.mcpServers).length:0,N=R.permissions?R.permissions.allow.length+R.permissions.deny.length:0,F=R.hooks?Object.values(R.hooks).reduce((M,tt)=>M+(Array.isArray(tt)?tt.length:0),0):0,B=R.ignore.length,U=jZ(k.features,R.rules.length,R.commands.length,R.agents.length,R.skills.length,P,N,F,B),q=c!==null&&c!==U;if(c=U,m)return;let nt=await Rc(t,n,{printMatrix:false});if(Ic(nt),!m){if(q){let M=await mp(t,n);up(M,{verbose:t.verbose===true});}else y.info("Regenerated.");r.onCycle?.({featuresChanged:q});}},"run"),f=s(()=>{let k=u().catch(C=>{if(!m){let R=C instanceof Error?C.message:String(C);y.error(R);}}).finally(()=>{p===k&&(p=null);});p=k;},"scheduleRun"),g=s(()=>{m||(l&&clearTimeout(l),l=setTimeout(f,MZ));},"schedule"),h=r.usePolling??process.platform==="win32",I=vZ.watch(a,{ignoreInitial:true,usePolling:h,...h&&r.pollIntervalMs!==void 0?{interval:r.pollIntervalMs}:{}});return I.on("all",(k,C)=>{GZ(i.canonicalDir,C)||g();}),await new Promise((k,C)=>{I.once("ready",k),I.once("error",C);}),y.info(o==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),p=u(),await p,p=null,{stop:s(async()=>{m=true,l&&(clearTimeout(l),l=null),await I.close(),p&&await p;},"stop")}}s(V$,"runWatch");Zt();Jp();async function jf(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await kf(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await Rs(n),a=await tl(e,r),l=a.length>0?await hc(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let C of c){let R=i[C];R===void 0?f.push(C):R!==o.checksums[C]&&p.push(C);}for(let C of m)c.has(C)||u.push(C);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let C of g)l[C]!==o.extends[C]&&h.push(C);let I=Lf(o.checksums,i,e.collaboration?.lock_features??[]);return {inSync:p.length===0&&u.length===0&&f.length===0&&h.length===0,hasLock:true,modified:p,added:u,removed:f,extendsModified:h,lockedViolations:I}}s(jf,"checkLockSync");Mr();async function J$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n);await Gt(o,r);let a=await jf({config:o,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(J$,"runCheck");Zt();A();Jp();var BZ=".lock",KZ="<<<<<<<";async function AI(t){let e=join(t,BZ),r=await _(e);return r===null?false:r.includes(KZ)}s(AI,"hasLockConflict");async function X$(t,e,r){if(!await AI(t))throw new Error("No conflict to resolve.");let o=await Rs(t),i=dirname(t),a=r?await tl(r,i):[],l=a.length>0?await hc(a):{},c=await Of(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await Ef(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}s(X$,"resolveLockConflict");async function Z$(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n),a=i.canonicalDir;return await AI(a)?(await X$(a,Ei(),o),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(Z$,"runMerge");Zt();yf();function Q$(t){let e=typeof t.path=="string"?t.path.trim():void 0,r=typeof t.target=="string"?t.target.trim():void 0,n=typeof t.as=="string"?t.as.trim():void 0;return {sync:t.sync===true,dryRun:t["dry-run"]===true,force:t.force===true,useExtends:t.extends===true,all:t.all===true,forceFreshMaterialize:t.forceFreshMaterialize===true,explicitPath:e||void 0,explicitTarget:r||void 0,explicitAs:n?fc.parse(n):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(Q$,"readInstallFlags");var zZ=".install.lock";async function Cc(t,e={}){return await mkdir(t,{recursive:true}),xf(join(t,zZ),e)}s(Cc,"acquireInstallLock");Zt();A();Hc();var YZ=promisify(execFile);function Uf(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(Uf,"ensureNotFlag");async function bI(t){let{stdout:e}=await YZ("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(bI,"runGit");async function q$(){try{return await bI(["--version"]),!0}catch{return false}}s(q$,"isGitAvailable");async function XZ(t,e){Uf(t,"remote-url"),Uf(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await bI(["ls-remote",t,o])).split(`
334
+ `).map(c=>c.trim()).find(c=>c.length>0);if(!a)continue;let l=a.split(/\s+/)[0];if(l&&/^[0-9a-f]{40}$/i.test(l))return l}catch(i){n=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}s(XZ,"gitLsRemoteResolve");async function Bf(t,e){Uf(e,"remote-url");let r=t===""?"HEAD":t;if(Uf(r,"ref"),/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await bI(["ls-remote",e,"HEAD"])).split(`
335
+ `).find(a=>a.trim().length>0);if(!o)throw new Error(`Could not resolve HEAD for ${e}`);let i=o.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 XZ(e,r)}s(Bf,"resolveRemoteRefForInstall");async function tG(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 Bf(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await qa(l,"install",{cacheDir:ve(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}if(t.kind==="gitlab"){let l=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await qa(l,"install",{cacheDir:ve(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await qa(i,"install",{cacheDir:ve(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(tG,"fetchInstallSource");async function eG(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await tG(t);return {resolvedPath:r.resolvedPath,sourceForYaml:r.sourceForYaml,version:r.version}}catch(r){let n=r instanceof Error?r.message:String(r),o=new Error(`Failed to fetch from ${e}: ${n}. Check your network connection and try again.`);throw r instanceof Error&&(o.cause=r),o}}s(eG,"resolveInstallResolvedPath");function fp(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("tree");if(n<2||n+1>=r.length)return null;let o=r[0],i=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!i||!a?null:{org:o,repo:i,ref:a,path:l||""}}catch{return null}}s(fp,"parseGithubTreeUrl");function gp(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("blob");if(n<2||n+1>=r.length)return null;let o=r[0],i=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!i||!a||!l?null:{org:o,repo:i,ref:a,path:l}}catch{return null}}s(gp,"parseGithubBlobUrl");function hp(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("-");if(n<0||r[n+1]!=="tree")return null;let o=n+1;if(o+1>=r.length)return null;let i=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!i?null:{namespace:m,project:c,ref:i,path:a||""}}catch{return null}}s(hp,"parseGitlabTreeUrl");function yp(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("-");if(n<0||r[n+1]!=="blob")return null;let o=n+1;if(o+1>=r.length)return null;let i=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!i||!a?null:{namespace:m,project:c,ref:i,path:a}}catch{return null}}s(yp,"parseGitlabBlobUrl");var ZZ=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function _p(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||ZZ.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(_p,"parseGithubRepoUrl");function Rp(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 n=r[r.length-1],o=r.slice(0,-1).join("/");return !o||!n?null:{namespace:o,project:n}}catch{return null}}s(Rp,"parseGitlabRepoUrl");function Ip(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(Ip,"parseGitSshGithub");function Sp(t){let e=t.match(/^git@gitlab\.com:(.+?)(?:\.git)?$/i);if(!e)return null;let n=e[1].replace(/\.git$/i,"").split("/").filter(Boolean);if(n.length<2)return null;let o=n[n.length-1];return {namespace:n.slice(0,-1).join("/"),project:o}}s(Sp,"parseGitSshGitlab");A();var tQ=/^[A-Za-z]:[\\/]/,eQ=/^[A-Za-z]:\//;function rG(...t){return t.some(e=>e.includes("\\")||tQ.test(e))?win32:posix}s(rG,"pathApiFor");function kp(t){return t.replace(/\\/g,"/")}s(kp,"toPosixPath");function Cp(t){return kp(t).replace(/^\/+|\/+$/g,"")}s(Cp,"normalizeInstallPathField");function Kf(t){let e=kp(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||eQ.test(e)?e:`./${e}`}s(Kf,"normalizeLocalSourceForYaml");function hi(t){return {...t,source:t.source_kind==="local"?Kf(t.source):t.source,...t.path!==void 0?{path:Cp(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>Cp(e))}:{}}}s(hi,"normalizePersistedInstallPaths");function nG(t,e,r){let n=rG(t,e),o=n.normalize(t),i=n.normalize(e),a=Cp(r),l=`${n.sep}.agentsmesh${n.sep}`,c=o.indexOf(l);if(c>=0){let p=o.slice(0,c),u=o.slice(c+l.length),f=Cp(u),g=kp(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Kf(g)}}let m=kp(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:Kf(m)}}s(nG,"localParsedFromAbsPath");async function PI(t,e,r){let n=t.trim(),o=r?.trim().replace(/\\/g,"/")??"";if(n.startsWith("git+")){let p=n.lastIndexOf("#"),u=p<0?n:n.slice(0,p),f=p<0?"HEAD":n.slice(p+1),g=u.slice(4);return {kind:"git",rawRef:f,gitPlusBase:g,gitRemoteUrl:g,pathInRepo:o}}if(n.startsWith("https://")||n.startsWith("http://")){let p=fp(n)??gp(n);if(p)return {kind:"github",rawRef:p.ref,org:p.org,repo:p.repo,gitRemoteUrl:`https://github.com/${p.org}/${p.repo}.git`,pathInRepo:o||p.path};let u=_p(n);if(u)return {kind:"github",rawRef:"HEAD",org:u.org,repo:u.repo,gitRemoteUrl:`https://github.com/${u.org}/${u.repo}.git`,pathInRepo:o};let f=hp(n)??yp(n);if(f)return {kind:"gitlab",rawRef:f.ref,org:f.namespace,repo:f.project,gitRemoteUrl:`https://gitlab.com/${f.namespace}/${f.project}.git`,pathInRepo:o||f.path};let g=Rp(n);if(g)return {kind:"gitlab",rawRef:"HEAD",org:g.namespace,repo:g.project,gitRemoteUrl:`https://gitlab.com/${g.namespace}/${g.project}.git`,pathInRepo:o}}if(n.startsWith("git@github.com:")){let p=Ip(n);if(!p)throw new Error(`Invalid GitHub SSH URL: ${n}`);return {kind:"github",rawRef:"HEAD",org:p.org,repo:p.repo,gitRemoteUrl:`https://github.com/${p.org}/${p.repo}.git`,pathInRepo:o}}if(n.startsWith("git@gitlab.com:")){let p=Sp(n);if(!p)throw new Error(`Invalid GitLab SSH URL: ${n}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:o}}if(n.startsWith("git@")){let p=n.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!p)throw new Error(`Invalid SSH git URL: ${n}`);let u=p[1],f=p[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${u}/${f}.git`,pathInRepo:o}}let i=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let p=i[1],u=i[2];return {kind:"github",rawRef:i[3],org:p,repo:u,gitRemoteUrl:`https://github.com/${p}/${u}.git`,pathInRepo:o}}let a=n.match(/^github:([^/]+)\/([^/@]+)$/);if(a){let p=a[1],u=a[2];return {kind:"github",rawRef:"HEAD",org:p,repo:u,gitRemoteUrl:`https://github.com/${p}/${u}.git`,pathInRepo:o}}let l=n.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(l){let p=l[1],u=l[2];return {kind:"gitlab",rawRef:l[3],org:p,repo:u,gitRemoteUrl:`https://gitlab.com/${p}/${u}.git`,pathInRepo:o}}let c=n.match(/^gitlab:(.+)\/([^/@]+)$/);if(c){let p=c[1],u=c[2];return {kind:"gitlab",rawRef:"HEAD",org:p,repo:u,gitRemoteUrl:`https://gitlab.com/${p}/${u}.git`,pathInRepo:o}}let m=resolve(e,n);if(!await j(m))throw new Error(`Path does not exist: ${m}`);return nG(m,e,o)}s(PI,"parseInstallSource");function Ep(t){let e=t.trim();if(e.startsWith("local:"))return {kind:"local"};if(e.startsWith("git+")){let a=e.lastIndexOf("#"),l=a<0?e:e.slice(0,a),c=a<0?"HEAD":e.slice(a+1);return {kind:"git",remoteUrl:l.slice(4),ref:c}}let r=e.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(r!==null){let a=r[1],l=r[2],c=r[3];return {kind:"github",remoteUrl:`https://github.com/${a}/${l}.git`,ref:c}}let n=e.match(/^github:([^/]+)\/([^/@]+)$/);if(n!==null){let a=n[1],l=n[2];return {kind:"github",remoteUrl:`https://github.com/${a}/${l}.git`,ref:"HEAD"}}let o=e.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(o!==null){let a=o[1],l=o[2],c=o[3];return {kind:"gitlab",remoteUrl:`https://gitlab.com/${a}/${l}.git`,ref:c}}let i=e.match(/^gitlab:(.+)\/([^/@]+)$/);if(i!==null){let a=i[1],l=i[2];return {kind:"gitlab",remoteUrl:`https://gitlab.com/${a}/${l}.git`,ref:"HEAD"}}if(e.startsWith("https://")||e.startsWith("http://")){let a=fp(e)??gp(e);if(a!==null)return {kind:"github",remoteUrl:`https://github.com/${a.org}/${a.repo}.git`,ref:a.ref};let l=_p(e);if(l!==null)return {kind:"github",remoteUrl:`https://github.com/${l.org}/${l.repo}.git`,ref:"HEAD"};let c=hp(e)??yp(e);if(c!==null)return {kind:"gitlab",remoteUrl:`https://gitlab.com/${c.namespace}/${c.project}.git`,ref:c.ref};let m=Rp(e);return m!==null?{kind:"gitlab",remoteUrl:`https://gitlab.com/${m.namespace}/${m.project}.git`,ref:"HEAD"}:{kind:"git",remoteUrl:e,ref:"HEAD"}}if(e.startsWith("git@github.com:")){let a=Ip(e);return a===null?null:{kind:"github",remoteUrl:`https://github.com/${a.org}/${a.repo}.git`,ref:"HEAD"}}if(e.startsWith("git@gitlab.com:")){let a=Sp(e);return a===null?null:{kind:"gitlab",remoteUrl:`https://gitlab.com/${a.namespace}/${a.project}.git`,ref:"HEAD"}}if(e.startsWith("git@")){let a=e.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(a===null)return null;let l=a[1],c=a[2].replace(/\.git$/i,"");return {kind:"git",remoteUrl:`ssh://git@${l}/${c}.git`,ref:"HEAD"}}return null}s(Ep,"parseSourceUrl");NR();function _n(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(_n,"featuresFromCanonical");async function Wf(t,e={}){let{sliceRoot:r,implicitPick:n}=await pf(t),{canonical:o,cleanup:i}=await uf(r,{...e,enableTargetEntityMappers:true});return {canonical:o,features:_n(o),implicitPick:n,cleanup:i}}s(Wf,"discoverFromContentRoot");function oG(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(oG,"validateSkill");function sG(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(sG,"validateRule");function iG(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(iG,"validateCommand");function aG(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(aG,"validateAgent");function se(t){return basename(t.source).replace(/\.md$/i,"")}s(se,"ruleSlug");function oQ(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(oQ,"featuresFromImplicitPick");function Ec(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??oQ(r);if(!r&&!n)return t;let o=new Set(n??[]),i={...t,mcp:!n||o.has("mcp")?t.mcp:null,permissions:!n||o.has("permissions")?t.permissions:null,hooks:!n||o.has("hooks")?t.hooks:null,ignore:!n||o.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(l=>a.has(l.name))};}else n&&!o.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(l=>a.has(se(l)))};}else n&&!o.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(l=>a.has(l.name))};}else n&&!o.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(l=>a.has(l.name))};}else n&&!o.has("agents")&&(i={...i,agents:[]});return i}s(Ec,"narrowDiscoveredForInstallScope");UR();async function lG(t,e,r,n,o={}){let i=await gf(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:a,cleanup:l}=await Wf(i.discoveryRoot,o),c=Ec(a,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:s(async()=>{await Promise.allSettled([l(),i.cleanup()]);},"combinedCleanup")},narrowed:c,discoveredFeatures:_n(c)}}s(lG,"resolveManualDiscoveredForInstall");So();kR();A();Pt();var sQ=(()=>{let t=new Map;for(let r of bt){let n=r.project.managedOutputs,o=[...n?.dirs??[],...n?.files??[],...r.detectionPaths];for(let i of o){let a=i.replace(/\/$/,""),l=t.get(a)??new Set;l.add(r.id),t.set(a,l);}}let e=[];for(let[r,n]of t){if(n.size!==1)continue;let[o]=[...n];e.push({prefix:r,target:o});}return e.sort((r,n)=>n.prefix.length-r.prefix.length)})();function iQ(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(iQ,"norm");function Hf(t){let e=iQ(t);if(e){for(let{prefix:r,target:n}of sQ)if(e===r||e.startsWith(`${r}/`))return n}}s(Hf,"targetHintFromNativePath");function TI(t,e){return Hf(t)===e}s(TI,"pathSupportsNativePick");function cG(t,e){if(!t||!e)return;let r=Hf(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(cG,"validateTargetMatchesPath");function mG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(mG,"extendPickHasArrays");A();A();Yt();async function uG(t,e){let r=join(t,...Xe.split("/")),n=join(t,...e.split("/")),o=await $(n),i=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let l=relative(r,a).replace(/\\/g,"/");if(l.startsWith("..")||l==="")continue;let m=l.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(uG,"inferGeminiCommandNamesFromFiles");Yt();fr();A();async function va(t){let e=await $(t),r=new Set;for(let n of e){if(basename(n)==="SKILL.md"){r.add(basename(dirname(n)));continue}!relative(t,n).replace(/\\/g,"/").includes("/")&&n.toLowerCase().endsWith(".md")&&r.add(basename(n,".md"));}return [...r].filter(Boolean).sort()}s(va,"skillNamesFromNativeSkillDir");A();Dr();async function dG(t,e){let r=join(t,...e.split("/"));if(e.startsWith(ii)){let n=await $(r),o=[...new Set(n.filter(i=>i.toLowerCase().endsWith(".prompt.md")).map(i=>basename(i,".prompt.md")))].sort();return o.length?{commands:o}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let n=await $(r),o=[...new Set(n.filter(i=>i.includes(".instructions.md")).map(i=>basename(i).replace(/\.instructions\.md$/i,"")))].sort();return o.length?{rules:o}:{}}if(e.startsWith(".github/instructions")){let n=await $(r),o=new Set;for(let a of n){let l=basename(a);l.toLowerCase().endsWith(".instructions.md")?o.add(l.replace(/\.instructions\.md$/i,"")):l.toLowerCase().endsWith(".md")&&o.add(basename(a,".md"));}let i=[...o].sort();return i.length?{rules:i}:{}}if(e.startsWith(".github/skills")){let n=await va(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await $(r),o=[...new Set(n.filter(i=>i.toLowerCase().endsWith(".agent.md")).map(i=>basename(i,".agent.md")))].sort();return o.length?{agents:o}:{}}return {}}s(dG,"inferCopilotPickFromPath");async function qe(t,e){let r=await $(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}s(qe,"mdNames");async function gG(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===Xe||n.startsWith(`${Xe}/`)){let i=await uG(t,n);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let i=await qe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".claude/rules")){let i=await qe(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".claude/agents")){let i=await qe(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".claude/skills/")){let a=n.replace(/^\.claude\/skills\/?/,"").split("/").filter(Boolean)[0];return a?{skills:[a]}:{}}return {}}if(r==="cursor"){if(n.startsWith(".cursor/rules")){let i=await qe(o,".mdc");return i.length?{rules:i}:{}}if(n.startsWith(".cursor/commands")){let i=await qe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".cursor/agents")){let i=await qe(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".cursor/skills")){let i=await va(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return dG(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let i=await qe(o,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(n.startsWith(qt)){let i=await va(o);return i.length?{skills:i}:{}}if(n.startsWith(Fn)){let i=await qe(o,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let i=await qe(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".continue/prompts")){let i=await qe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".continue/skills")){let i=await va(o);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let i=await qe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".junie/rules")){let i=await qe(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".junie/agents")){let i=await qe(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".junie/skills")){let i=await va(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await $(o),a=[...new Set(i.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(gG,"inferImplicitPickFromNativePath");function hG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(hG,"isImplicitPickEmpty");ER();function Op(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(Op,"normalizePath");function hQ(t,e){let r=Op(t),n=Op(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(hQ,"overlapsPath");function zf(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(zf,"addUnique");async function yQ(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),n=s(async()=>{await rm$1(e,{recursive:true,force:true});},"cleanup");try{return await cp$1(t,r,{recursive:!0}),{stageRoot:r,cleanup:n}}catch(o){throw await n(),o}}s(yQ,"makeStageRoot");function _Q(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:zf(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=Op(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:zf(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:zf(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=Op(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:zf(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(_Q,"buildPickFromResults");function RQ(t,e,r,n){let o=join(e,...Op(t).split("/")),i=r.filter(a=>hQ(o,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}". Try --path "${t}" without --target so agentsmesh can auto-detect the layout, or use --as <rules|commands|agents|skills> to install the directory as a flat collection.`);return {features:[...new Set(i.map(a=>a.feature))],pick:_Q(i,e)}}s(RQ,"scopeImportedResults");async function DI(t,e){let{stageRoot:r,cleanup:n}=await yQ(t);try{let o=await op(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s(DI,"stageImportedNativeRepo");async function NI(t,e,r){let n=await DI(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...RQ(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(NI,"stageNativeInstallScope");async function IG(t,e,r,n){let o=n.explicitTarget?.trim();o&&nr.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");cG(o,i);let a=join(t,".agentsmesh"),l=await j(a),c=i?Hf(i):void 0,p=!l&&!o&&(!i||c!==void 0)?await tf(t)??void 0:void 0;if(!o&&c&&p&&c!==p)throw new Error(`Install path suggests native layout "${c}" but auto-detect imported "${p}". Use --target ${c} for this path, or install from the repo root without a conflicting subtree path.`);let u=o??c??p,f=!!i&&!!u&&!i.startsWith(".agentsmesh");if(!l&&u){if(f){let P=await NI(t,i,u);return {discoveryRoot:P.stageRoot,implicitPick:P.pick,scopedFeatures:P.features,yamlTarget:u,importHappened:true,cleanup:P.cleanup}}let R=await DI(t,u);return {discoveryRoot:i?join(R.stageRoot,i):R.stageRoot,yamlTarget:u,importHappened:true,cleanup:R.cleanup}}let g;l?i?u&&TI(i,u)?g=t:g=e:g=t:g=e;let h,I,k;if(f&&u){let R=await NI(t,i,u);g=R.stageRoot,h=R.pick,I=R.features,k=R.cleanup;}else if(g===t&&i&&u&&TI(i,u)&&(h=await gG(t,i,u),hG(h)))throw new Error(`No installable native resources found under "${i}" for target "${u}". Try --path "${i}" without --target so agentsmesh can auto-detect the layout, or use --as <rules|commands|agents|skills> to install the directory as a flat collection.`);let C;return o?C=o:u&&(h&&mG(h)||(I?.length??0)>0)&&(C=u),{discoveryRoot:g,implicitPick:h,scopedFeatures:I,yamlTarget:C,importHappened:k!==void 0,cleanup:k}}s(IG,"prepareInstallDiscovery");async function FI(t,e,r,n,o={}){let i=await IG(t,e,r,{explicitTarget:n}),{canonical:a,implicitPick:l,cleanup:c}=await Wf(i.discoveryRoot,o),m=i.cleanup,u={...i,cleanup:s(async()=>{await Promise.allSettled([c(),...m?[m()]:[]]);},"mergedCleanup")},f=l??i.implicitPick,g=Ec(a,{implicitPick:f,scopedFeatures:i.scopedFeatures}),h=_n(g);return {prep:u,discovered:a,implicitPick:f,narrowed:g,discoveredFeatures:h}}s(FI,"resolveDiscoveredForInstall");var CQ=[".claude-plugin","marketplace.json"];async function kQ(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(kQ,"dirExists");function EQ(t){if(typeof t!="string"||t.length===0||t.startsWith("/"))return null;let e=t.replace(/^\.\/+/,"").replace(/\/+$/,"");return e.split("/").some(r=>r==="..")?null:e}s(EQ,"normalizeSource");async function CG(t,e,r){let n=join(t,...CQ),o;try{o=await readFile(n,"utf-8");}catch{return null}let i;try{i=JSON.parse(o);}catch{return null}if(typeof i!="object"||i===null||!Array.isArray(i.plugins))return null;let a=i.plugins,l=[];for(let c of a){if(typeof c!="object"||c===null)continue;let m=EQ(c.source);if(!m)continue;let p=join(t,m);if(!await kQ(p))continue;let u=await e(p,m);r(u)&&l.push({path:m,layout:u});}return l}s(CG,"detectMarketplaceSubPacks");async function wp(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(wp,"dirExists");async function yi(t){try{return (await readdir(t,{withFileTypes:!0})).map(r=>({name:r.name,isDir:r.isDirectory(),isFile:r.isFile()}))}catch{return []}}s(yi,"listDirEntries");function kG(t){return t.endsWith(".instructions.md")?"copilot-instructions":t.endsWith(".md")?"md":t.endsWith(".mdc")?"mdc":t.endsWith(".toml")?"toml":null}s(kG,"classifyFileShape");var wQ=["rules","commands","agents","skills","mcp.json","hooks.yaml","permissions.yaml","ignore"],AQ=[".cursorrules",".windsurfrules"];async function LG(t){let e=join(t,".agentsmesh");if(!await wp(e))return null;let r=await yi(e),n=new Set(r.map(o=>o.name));for(let o of wQ)if(n.has(o))return {path:".agentsmesh"};return null}s(LG,"detectCanonical");async function OG(t){for(let e of AQ)try{if((await stat(join(t,e))).isFile())return {path:e}}catch{}return null}s(OG,"detectRootRule");async function wG(t){try{if((await stat(join(t,"SKILL.md"))).isFile())return {path:"SKILL.md"}}catch{}return null}s(wG,"detectRootSkill");Eo();var PQ={rules:"rules",commands:"commands",agents:"agents",skills:"skills"},TQ=[".claude-plugin",".codex-plugin",".cursor-plugin"],xQ=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;async function AG(t){let e=join(t,"skills"),r=await yi(e);for(let n of r)if(!(!n.isDir||n.name.startsWith("_")||!xQ.test(n.name))&&await wp(join(e,n.name)))try{if((await stat(join(e,n.name,"SKILL.md"))).isFile())return {path:"skills"}}catch{continue}return null}s(AG,"detectSkillPack");async function bG(t){let e=[];for(let[r,n]of Object.entries(PQ)){let o=join(t,r),i=await yi(o),a=new Set;for(let l of i){if(!l.isFile||Cn(l.name))continue;let c=kG(l.name);c&&a.add(c);}for(let l of a)e.push({path:r,suggestedAs:n,fileShape:l});}return e}s(bG,"detectFlatCollections");async function PG(t){let e=[];for(let r of TQ)await wp(join(t,r))&&e.push({path:r});return e}s(PG,"detectToolNativeManifests");async function $I(t,e){let r=await LG(t);if(r)return {canonical:r,skillPack:null,rootSkill:null,rootRule:null,flatCollections:[],toolNativeManifests:[]};let n=await AG(t),o=n?null:await wG(t),i=await bG(t),a=n||o||i.length>0?null:await OG(t),l=await PG(t);return {canonical:r,skillPack:n?{path:e?`${e}/skills`:"skills"}:null,rootSkill:o?{path:e?`${e}/SKILL.md`:"SKILL.md"}:null,rootRule:a?{path:e?`${e}/${a.path}`:a.path}:null,flatCollections:i.map(c=>({...c,path:e?`${e}/${c.path}`:c.path})),toolNativeManifests:l.map(c=>({path:e?`${e}/${c.path}`:c.path}))}}s($I,"detectFlatLayout");function MI(t){return t.canonical!==null||t.skillPack!==null||t.rootSkill!==null||t.rootRule!==null||t.flatCollections.length>0}s(MI,"hasContent");async function TG(t,e){let r=await yi(t),n=[];for(let o of r){if(!o.isDir||o.name.startsWith("."))continue;let i=join(t,o.name),a=e?`${e}/${o.name}`:o.name,l=await $I(i,a);MI(l)&&n.push({path:a,layout:l});}return n}s(TG,"collectSubPackCandidates");async function DQ(t,e){if(MI(e))return [];let r=await CG(t,$I,MI);if(r&&r.length>0)return r;let n=await TG(t,"");if(n.length>=2)return n;let o=await yi(t);for(let i of o){if(!i.isDir||i.name.startsWith("."))continue;let a=await TG(join(t,i.name),i.name);if(a.length>=2)return a}return []}s(DQ,"detectSubPacks");async function DG(t){let e=await $I(t,"");if(e.canonical)return {...e,subPacks:[]};let r=await DQ(t,e);return {...e,subPacks:r}}s(DG,"detectLayout");A();K();async function FG(t){let e;try{e=await readdir(t);}catch{return null}let r=e.sort().find(c=>c.toLowerCase().endsWith(".mdc"));if(!r)return null;let n=await _(join(t,r));if(!n)return null;let o=Gr(n,join(t,r));if(!o.ok)return null;let{frontmatter:i}=o.value,a="alwaysApply"in i,l="trigger"in i;return a&&l?null:a?"cursor":l?"windsurf":null}s(FG,"inferMdcTarget");sf();mf();function GQ(t){let e=t.indexOf("#");return e<0?{path:t,anchor:""}:{path:t.slice(0,e),anchor:t.slice(e)}}s(GQ,"splitAnchor");function jQ(t){return t.split(sep).join("/")}s(jQ,"toForwardSlash");async function UQ(t){try{return await stat(t),!0}catch{return false}}s(UQ,"pathExists");async function GG(t){let{link:e,fromFile:r,contentRoot:n,includedPaths:o}=t,{path:i,anchor:a}=GQ(e.path);if(i===""||isAbsolute(i))return {link:e,classification:"unresolvable",resolvedRelative:null,anchor:a};let l=join(n,r,".."),c=normalize(resolve(l,i)),m=normalize(resolve(n)),p=relative(m,c);if(p.startsWith("..")||isAbsolute(p))return {link:e,classification:"unresolvable",resolvedRelative:null,anchor:a};let u=jQ(p);return await UQ(c)?o.has(u)?{link:e,classification:"in-tree-included",resolvedRelative:u,anchor:a}:{link:e,classification:"resolvable-outside",resolvedRelative:u,anchor:a}:{link:e,classification:"unresolvable",resolvedRelative:u,anchor:a}}s(GG,"resolveLink");var BQ=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,KQ=/(!?)\[[^\]\n]*\]\(([^)\n]+)\)/g,WQ=/^\s*\[([^\]\n]+)\]:\s*(.+?)\s*$/gm;function HQ(t){let e=[];for(let r of t.matchAll(BQ)){let n=r.index??0;e.push([n,n+r[0].length]);}return e}s(HQ,"getFencedCodeRanges");function jG(t,e){for(let[r,n]of e)if(t>=r&&t<n)return true;return false}s(jG,"isInRanges");function UG(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(UG,"normalizeDestination");function Vf(t){let e=HQ(t),r=[];for(let n of t.matchAll(KQ)){let o=n.index??0;if(jG(o,e))continue;let i=n[1]==="!",a=n[2];if(a===void 0)continue;let l=t.indexOf("(",o);if(l<0)continue;let c=l+1;r.push({kind:i?"image":"inline",destination:UG(a),destinationOffset:c,destinationLength:a.length});}for(let n of t.matchAll(WQ)){let o=n.index??0;if(jG(o,e))continue;let i=(n[1]??"").trim(),a=n[2]??"";if(i===""||a.trim()==="")continue;let l=o,c=t.indexOf("]:",l);if(c<0)continue;let m=c+2;for(;m<t.length&&(t[m]===" "||t[m]===" ");)m+=1;r.push({kind:"reference-def",destination:UG(a),label:i,destinationOffset:m,destinationLength:a.trimEnd().length});}return r}s(Vf,"scanMarkdownLinks");function BG(t,e){if(e.length===0)return t;let r=[...e].sort((o,i)=>i.offset-o.offset),n=t;for(let o of r)n=`${n.slice(0,o.offset)}${o.replacement}${n.slice(o.offset+o.length)}`;return n}s(BG,"applyRangeRewrites");function zQ(t){return !(t.length===0||t.startsWith("#")||t.startsWith("/")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))}s(zQ,"isCandidateRelativePath");function VQ(t){let e=t.replaceAll("\\","/");return e==="{baseDir}"?".":e.startsWith("{baseDir}/")?e.slice(10):e}s(VQ,"stripPath");function JQ(t){let e=t.destination;return zQ(e)?{raw:e,path:VQ(e),kind:t.kind,...t.label!==void 0?{label:t.label}:{}}:null}s(JQ,"toScannedLink");function KG(t){let e=[];for(let r of Vf(t)){let n=JQ(r);n!==null&&e.push(n);}return e}s(KG,"scanRelativeLinks");function Lc(t,e){let r=t.replaceAll("\\","/"),n=e.replaceAll("\\","/"),o=r.endsWith("/")?r:`${r}/`;return n.startsWith(o)?n.slice(o.length):n}s(Lc,"toForwardSlashRelative");function WG(t,e,r,n,o){let i=new Set;for(let a of e){i.add(Lc(t,a.source));for(let l of a.supportingFiles)i.add(Lc(t,l.absolutePath));}for(let a of r)i.add(Lc(t,a.source));for(let a of n)i.add(Lc(t,a.source));for(let a of o)i.add(Lc(t,a.source));return i}s(WG,"buildIncludedPaths");function XQ(t,e,r,n){let o=[];for(let i of t)o.push({kind:"skill",name:i.name,body:i.body,sourcePath:i.source});for(let i of e)o.push({kind:"agent",name:i.name,body:i.body,sourcePath:i.source});for(let i of r)o.push({kind:"command",name:i.name,body:i.body,sourcePath:i.source});for(let i of n)o.push({kind:"rule",name:basename(i.source,".md"),body:i.body,sourcePath:i.source});return o}s(XQ,"listScannables");async function HG(t,e,r,n,o,i){let a=XQ(e,r,n,o),l=[];for(let c of a){let m=KG(c.body);if(m.length===0)continue;let p=Lc(t,c.sourcePath),u=[];for(let f of m){let g=await GG({link:f,fromFile:p,contentRoot:t,includedPaths:i});g.classification!=="in-tree-included"&&u.push(g);}u.length>0&&l.push({entityKind:c.kind,entityName:c.name,resolved:u});}return l}s(HG,"detectBrokenLinks");mf();async function zG(t,e,r={}){let n=new Map,o=new Map,i=[],a=[...e].sort((p,u)=>p.precedence-u.precedence);for(let p of a){let{commands:u,cleanup:f}=await af(join(t,p.dir),{restrictToTarget:p.target,parseOpts:r});i.push(f);for(let g of u){if(n.get(g.name)===void 0){n.set(g.name,{command:g,precedence:p.precedence});continue}let I=o.get(g.name)??[];I.push({path:g.source,precedence:p.precedence}),o.set(g.name,I);}}let l=[];for(let[p,u]of o){let f=n.get(p);if(f===void 0)throw new Error(`mergeCommands invariant: loser without winner for "${p}"`);l.push({basename:p,winnerPath:f.command.source,loserPaths:u.map(g=>g.path)});}return l.sort((p,u)=>p.basename.localeCompare(u.basename)),{commands:[...n.values()].map(p=>p.command).sort((p,u)=>p.name.localeCompare(u.name)),dedups:l,cleanup:s(async()=>{await Promise.allSettled(i.map(p=>p()));},"cleanup")}}s(zG,"mergeCommands");async function VG(t,e,r={}){let[n,o,i,a]=await Promise.all([Yv(`${t}/skills`,r),cf(`${t}/agents`,{parseOpts:r}),lf(`${t}/rules`,{parseOpts:r}),zG(t,e.mergeFromToolDirs,r)]),l=[...o.agents],c=[...i.rules],m=WG(t,n,l,a.commands,c),p=await HG(t,n,l,a.commands,c,m),u=s(async()=>{await Promise.allSettled([i.cleanup(),o.cleanup(),a.cleanup()]);},"cleanup");return {skills:n,agents:l,commands:a.commands,rules:c,dedups:a.dedups,brokenLinks:p,cleanup:u}}s(VG,"aggregateAnthropicSkillPack");var JG={mergeFromToolDirs:[{dir:"commands",precedence:0},{dir:".claude/commands",target:"claude-code",precedence:1},{dir:".gemini/commands",target:"gemini-cli",precedence:2}]};rl();function qQ(t){return {rules:[...t.rules],commands:[...t.commands],agents:[...t.agents],skills:[...t.skills],mcp:null,permissions:null,hooks:null,ignore:[]}}s(qQ,"aggregateToCanonical");function Jf(){return {}}s(Jf,"emptyPrep");async function tq(t,e){let r=[];for(let n of e)if(n.fileShape==="mdc"&&!n.inferredTarget){let o=await FG(join(t,n.path));r.push(o?{...n,inferredTarget:o}:n);}else r.push(n);return r}s(tq,"enrichMdcTargets");function XG(t){return t.canonical?"canonical-agentsmesh":t.skillPack||t.rootSkill?"anthropic-skill-pack":t.rootRule||t.toolNativeManifests.length>0?"tool-native":"unknown"}s(XG,"deriveSourceType");async function eq(t,e){let r=await eu(t,e);return {rules:[],commands:[],agents:[],skills:r?[r]:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(eq,"rootSkillToCanonical");async function rq(t,e){let r=join(t,e),n=await readFile(r,"utf-8").catch(()=>""),o=`Imported from ${e}`;return {rules:n?[{source:r,root:true,targets:[],description:o,globs:[],body:n}]:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(rq,"rootRuleToCanonical");async function ZG(t){let e=t.parseOpts??{};if(t.explicitAs)return {implicitPick:void 0,...await lG(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick,e)};if(t.explicitTarget)return FI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e);let r=await DG(t.contentRoot),n=await tq(t.contentRoot,r.flatCollections),o={...r,flatCollections:n};if(o.skillPack&&!o.canonical){let a=await VG(t.contentRoot,JG,e),l=qQ(a);return {prep:{cleanup:a.cleanup},implicitPick:void 0,narrowed:l,discoveredFeatures:_n(l),layout:o,aggregate:a}}if(o.rootSkill&&!o.canonical&&!o.skillPack){let a=await eq(t.contentRoot,e);return {prep:Jf(),implicitPick:void 0,narrowed:a,discoveredFeatures:_n(a),layout:o}}if(o.rootRule&&!o.canonical&&!o.skillPack&&!o.rootSkill&&o.flatCollections.length===0){let a=await rq(t.contentRoot,o.rootRule.path);return {prep:Jf(),implicitPick:void 0,narrowed:a,discoveredFeatures:_n(a),layout:o}}return o.subPacks.length>0?{prep:Jf(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:o.flatCollections.length>0?{prep:Jf(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:{...await FI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e),layout:o}}s(ZG,"resolveInstallDiscovery");function qG(t){let e=new Set;t.skillPack&&e.add("skills"),t.rootSkill&&e.add("skills");for(let r of t.flatCollections)e.add(r.suggestedAs);return [...e]}s(qG,"featuresFromLayout");function nq(t){return t.replace(/[/\\]+/g,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}s(nq,"subPackSlug");function QG(t,e,r){let n=qG(t.layout),o=n[0];return {name:`${e}-${nq(t.path)}`,source:r,path:t.path,as:o,features:n}}s(QG,"targetFromSubPack");function tj(t,e,r){return {name:e,source:r,path:t.path,as:t.suggestedAs,target:t.inferredTarget,features:[t.suggestedAs]}}s(tj,"targetFromCollection");function ej(t){let{layout:e,sourceName:r,sourceForYaml:n,explicitPath:o,explicitAs:i,explicitTarget:a}=t;if(o||i||a)return {targets:[],isMarketplace:false};if(e.canonical||e.skillPack)return {targets:[],isMarketplace:false};if(e.subPacks.length>=1)return oq(t);if(e.flatCollections.length===1){let l=e.flatCollections[0];return {targets:[tj(l,r,n)],isMarketplace:false}}return e.flatCollections.length>1?sq(t):{targets:[],isMarketplace:false}}s(ej,"selectInstallCandidates");function oq(t){let{layout:e,sourceName:r,sourceForYaml:n}=t;if(t.all)return {targets:e.subPacks.map(a=>QG(a,r,n)),isMarketplace:true};if(t.force||!t.tty){let a=e.subPacks.map(l=>({path:l.path,features:qG(l.layout)})).map(l=>` - ${l.path} (${l.features.join(", ")})`).join(`
334
336
  `);throw new Error(`Marketplace source with ${e.subPacks.length} sub-packs. Pass --all to install all, or use --path <subpath>:
335
- ${a}`)}return {targets:e.subPacks.map(i=>zG(i,r,n)),isMarketplace:true}}s(BQ,"selectMarketplace");function KQ(t){let{layout:e,sourceName:r,sourceForYaml:n}=t;if(t.force||!t.tty){let i=e.flatCollections.map(a=>` - ${a.path} (${a.suggestedAs}, .${a.fileShape})`).join(`
337
+ ${a}`)}return {targets:e.subPacks.map(i=>QG(i,r,n)),isMarketplace:true}}s(oq,"selectMarketplace");function sq(t){let{layout:e,sourceName:r,sourceForYaml:n}=t;if(t.force||!t.tty){let i=e.flatCollections.map(a=>` - ${a.path} (${a.suggestedAs}, .${a.fileShape})`).join(`
336
338
  `);throw new Error(`Ambiguous source with ${e.flatCollections.length} resource collections. Pass --as <kind> to select, or --path <subpath>:
337
- ${i}`)}return {targets:e.flatCollections.map(i=>JG(i,r,n)),isMarketplace:false}}s(KQ,"selectMultipleCollections");fn();SR();function Ec(t){return t==="."||t===""?void 0:t}s(Ec,"trimDot");function HQ(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(HQ,"markdownPick");async function ZG(t){if(!t.as)return {pathInRepo:Ec(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:Ec(dirname(e)),pick:HQ(t.as,e||t.contentRoot)};if(t.as==="skills"){if(r.isFile()&&basename(t.contentRoot)==="SKILL.md"){let n=e?dirname(e):dirname(t.contentRoot);return {pathInRepo:Ec(dirname(n)),pick:{skills:[basename(n)]}}}if(r.isDirectory()){let n=e||basename(t.contentRoot),o=join(t.contentRoot.replace(/\/+$/g,""),"SKILL.md");try{if((await stat(o)).isFile()){let a=await qd(o);return {pathInRepo:Ec(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:Ec(e)}}}}return {pathInRepo:Ec(e)}}s(ZG,"resolveManualInstallPersistence");fo();ot();ot();async function vf(t,e,r){let n=t==="install"?"Pack is installed":"Uninstall is committed",o=e==="global"?" --global":"";try{let i=await _c(e==="global"?{global:!0}:{},r,{printMatrix:!1});Rc(i),i.exitCode!==0&&y.warn(`Generate failed after ${t}. ${n}; run agentsmesh generate${o}.`);}catch(i){let a=i instanceof Error?i.message:String(i);y.warn(`Generate failed after ${t}: ${a}`),y.warn(`${n}; run agentsmesh generate${o} after resolving the issue.`);}}s(vf,"runPostOperationGenerate");async function go(t){return process.stdin.isTTY?new Promise(e=>{let r=QG.createInterface({input:process.stdin,output:process.stdout});r.question(`${t} (y/n) `,n=>{r.close();let o=n.trim().toLowerCase();e(o==="y"||o==="yes");});}):false}s(go,"confirm");function zQ(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(zQ,"hasArrayResources");function qG(t){return zQ(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(qG,"hasInstallableResources");async function tj(t,e,r,n){let o=t.skills.map(l=>Q$(l)),i=o.filter(l=>l.ok).map(l=>l.skill),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await go(`Include invalid skill "${l.skill.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.skill);else e&&(i=o.map(l=>l.skill));return r&&(i=o.filter(l=>l.ok).map(l=>l.skill)),i}s(tj,"resolveSkillPool");async function ej(t,e,r,n){let o=t.rules.map(l=>q$(l)),i=o.filter(l=>l.ok).map(l=>l.rule),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await go(`Include invalid rule "${ne(l.rule)}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.rule);else e&&(i=o.map(l=>l.rule));return r&&(i=o.filter(l=>l.ok).map(l=>l.rule)),i}s(ej,"resolveRulePool");async function rj(t,e,r,n){let o=t.commands.map(l=>tG(l)),i=o.filter(l=>l.ok).map(l=>l.command),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await go(`Include invalid command "${l.command.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.command);else e&&(i=o.map(l=>l.command));return r&&(i=o.filter(l=>l.ok).map(l=>l.command)),i}s(rj,"resolveCommandPool");async function nj(t,e,r,n){let o=t.agents.map(l=>eG(l)),i=o.filter(l=>l.ok).map(l=>l.agent),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await go(`Include invalid agent "${l.agent.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.agent);else e&&(i=o.map(l=>l.agent));return r&&(i=o.filter(l=>l.ok).map(l=>l.agent)),i}s(nj,"resolveAgentPool");async function oj(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>ne(a)),o=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(l=>l.name===a.name)&&(await go(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(c=>c!==a.name)));for(let a of e.rules){let l=ne(a);t.rules.some(c=>ne(c)===l)&&(await go(`Rule "${l}" already exists in merged config. Add extend anyway?`)||(n=n.filter(m=>m!==l)));}for(let a of e.commands)t.commands.some(l=>l.name===a.name)&&(await go(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(o=o.filter(c=>c!==a.name)));for(let a of e.agents)t.agents.some(l=>l.name===a.name)&&(await go(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(c=>c!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:i}}s(oj,"resolveInstallConflicts");function sj(t,e){if(!t)return;let r={},n=t.skills?.filter(l=>e.skillNames.includes(l)),o=t.rules?.filter(l=>e.ruleSlugs.includes(l)),i=t.commands?.filter(l=>e.commandNames.includes(l)),a=t.agents?.filter(l=>e.agentNames.includes(l));return n&&n.length>0&&(r.skills=n),o&&o.length>0&&(r.rules=o),i&&i.length>0&&(r.commands=i),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}s(sj,"pickForSelectedResources");function VQ(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(VQ,"pathEndsWithName");function Mf(t,e,r){return r!==1||e.length!==1?false:VQ(t,e[0])}s(Mf,"inferSingleNamePick");function ij(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:n,selected:o}=t,i={},a=o.skillNames.length>0&&(!!r?.skills?.length||o.skillNames.length<n.skills||Mf(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||Mf(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||Mf(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||Mf(e,o.agentNames,n.agents));return a&&(i.skills=[...o.skillNames]),l&&(i.rules=[...o.ruleSlugs]),c&&(i.commands=[...o.commandNames]),m&&(i.agents=[...o.agentNames]),Object.keys(i).length?i:void 0}s(ij,"buildInstallPick");function aj(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(aj,"deriveInstallFeatures");function JQ(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(JQ,"isEmptyInstallSelection");function lj(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=s(l=>r.includes(l),"had"),i=o("skills")&&e.skillNames.length===0&&n.skills>0&&"skills"||o("rules")&&e.ruleSlugs.length===0&&n.rules>0&&"rules"||o("commands")&&e.commandNames.length===0&&n.commands>0&&"commands"||o("agents")&&e.agentNames.length===0&&n.agents>0&&"agents";if(i)throw new Error(`No ${i} selected to install.`);let a=r.some(l=>["mcp","permissions","hooks","ignore"].includes(l));if(JQ(e)&&!a)throw new Error("No resources selected to install.")}s(lj,"ensureInstallSelection");Ro();function cj(t,e){if(t.find(n=>n.name===e.name&&n.source!==e.source))throw new Error(`Extends entry "${e.name}" already exists with a different source. Use --name to provide a different name.`)}s(cj,"assertExtendNameAvailable");function YQ(t,e,r){if(r===void 0){if(!t)return;let o={...t};for(let i of ["skills","commands","rules","agents"])e.includes(i)&&delete o[i];return Object.keys(o).length?o:void 0}let n={...t};for(let o of ["skills","commands","rules","agents"]){if(!(o in r))continue;let i=r[o];if(i===void 0||i.length===0){delete n[o];continue}n[o]=[...new Set([...t?.[o]??[],...i])];}return Object.keys(n).length?n:void 0}s(YQ,"mergePick");function mj(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,as:e.as}];let n=t[r],o=[...new Set([...n.features,...e.features])],i=YQ(n.pick,e.features,e.pick);return t.map((a,l)=>l===r?{name:e.name,source:e.source,version:e.version??n.version,features:o,path:e.path!==void 0?e.path:n.path,pick:i,target:e.target??n.target,as:e.as??n.as}:a)}s(mj,"mergeExtendList");w();async function pj(t,e,r){let n=await _(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=mj(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await I(t,a.endsWith(`
339
+ ${i}`)}return {targets:e.flatCollections.map(i=>tj(i,r,n)),isMarketplace:false}}s(sq,"selectMultipleCollections");Mr();FR();function Oc(t){return t==="."||t===""?void 0:t}s(Oc,"trimDot");function aq(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(aq,"markdownPick");async function nj(t){if(!t.as)return {pathInRepo:Oc(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:Oc(dirname(e)),pick:aq(t.as,e||t.contentRoot)};if(t.as==="skills"){if(r.isFile()&&basename(t.contentRoot)==="SKILL.md"){let n=e?dirname(e):dirname(t.contentRoot);return {pathInRepo:Oc(dirname(n)),pick:{skills:[basename(n)]}}}if(r.isDirectory()){let n=e||basename(t.contentRoot),o=join(t.contentRoot.replace(/\/+$/g,""),"SKILL.md");try{if((await stat(o)).isFile()){let a=await df(o);return {pathInRepo:Oc(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:Oc(e)}}}}return {pathInRepo:Oc(e)}}s(nj,"resolveManualInstallPersistence");ho();st();st();async function wc(t,e,r){let n=t==="install"?"Pack is installed":t==="refresh"?"Refresh is committed":"Uninstall is committed",o=e==="global"?" --global":"";try{let i=await Rc(e==="global"?{global:!0}:{},r,{printMatrix:!1});Ic(i),i.exitCode!==0&&y.warn(`Generate failed after ${t}. ${n}; run agentsmesh generate${o}.`);}catch(i){let a=i instanceof Error?i.message:String(i);y.warn(`Generate failed after ${t}: ${a}`),y.warn(`${n}; run agentsmesh generate${o} after resolving the issue.`);}}s(wc,"runPostOperationGenerate");async function yo(t){return process.stdin.isTTY?new Promise(e=>{let r=oj.createInterface({input:process.stdin,output:process.stdout});r.question(`${t} (y/n) `,n=>{r.close();let o=n.trim().toLowerCase();e(o==="y"||o==="yes");});}):false}s(yo,"confirm");function lq(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(lq,"hasArrayResources");function sj(t){return lq(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(sj,"hasInstallableResources");async function ij(t,e,r,n){let o=t.skills.map(l=>oG(l)),i=o.filter(l=>l.ok).map(l=>l.skill),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await yo(`Include invalid skill "${l.skill.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.skill);else e&&(i=o.map(l=>l.skill));return r&&(i=o.filter(l=>l.ok).map(l=>l.skill)),i}s(ij,"resolveSkillPool");async function aj(t,e,r,n){let o=t.rules.map(l=>sG(l)),i=o.filter(l=>l.ok).map(l=>l.rule),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await yo(`Include invalid rule "${se(l.rule)}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.rule);else e&&(i=o.map(l=>l.rule));return r&&(i=o.filter(l=>l.ok).map(l=>l.rule)),i}s(aj,"resolveRulePool");async function lj(t,e,r,n){let o=t.commands.map(l=>iG(l)),i=o.filter(l=>l.ok).map(l=>l.command),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await yo(`Include invalid command "${l.command.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.command);else e&&(i=o.map(l=>l.command));return r&&(i=o.filter(l=>l.ok).map(l=>l.command)),i}s(lj,"resolveCommandPool");async function cj(t,e,r,n){let o=t.agents.map(l=>aG(l)),i=o.filter(l=>l.ok).map(l=>l.agent),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await yo(`Include invalid agent "${l.agent.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.agent);else e&&(i=o.map(l=>l.agent));return r&&(i=o.filter(l=>l.ok).map(l=>l.agent)),i}s(cj,"resolveAgentPool");async function mj(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>se(a)),o=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(l=>l.name===a.name)&&(await yo(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(c=>c!==a.name)));for(let a of e.rules){let l=se(a);t.rules.some(c=>se(c)===l)&&(await yo(`Rule "${l}" already exists in merged config. Add extend anyway?`)||(n=n.filter(m=>m!==l)));}for(let a of e.commands)t.commands.some(l=>l.name===a.name)&&(await yo(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(o=o.filter(c=>c!==a.name)));for(let a of e.agents)t.agents.some(l=>l.name===a.name)&&(await yo(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(c=>c!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:i}}s(mj,"resolveInstallConflicts");function pj(t,e){if(!t)return;let r={},n=t.skills?.filter(l=>e.skillNames.includes(l)),o=t.rules?.filter(l=>e.ruleSlugs.includes(l)),i=t.commands?.filter(l=>e.commandNames.includes(l)),a=t.agents?.filter(l=>e.agentNames.includes(l));return n&&n.length>0&&(r.skills=n),o&&o.length>0&&(r.rules=o),i&&i.length>0&&(r.commands=i),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}s(pj,"pickForSelectedResources");function cq(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(cq,"pathEndsWithName");function Yf(t,e,r){return r!==1||e.length!==1?false:cq(t,e[0])}s(Yf,"inferSingleNamePick");function uj(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:n,selected:o}=t,i={},a=o.skillNames.length>0&&(!!r?.skills?.length||o.skillNames.length<n.skills||Yf(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||Yf(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||Yf(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||Yf(e,o.agentNames,n.agents));return a&&(i.skills=[...o.skillNames]),l&&(i.rules=[...o.ruleSlugs]),c&&(i.commands=[...o.commandNames]),m&&(i.agents=[...o.agentNames]),Object.keys(i).length?i:void 0}s(uj,"buildInstallPick");function dj(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(dj,"deriveInstallFeatures");function mq(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(mq,"isEmptyInstallSelection");function fj(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=s(l=>r.includes(l),"had"),i=o("skills")&&e.skillNames.length===0&&n.skills>0&&"skills"||o("rules")&&e.ruleSlugs.length===0&&n.rules>0&&"rules"||o("commands")&&e.commandNames.length===0&&n.commands>0&&"commands"||o("agents")&&e.agentNames.length===0&&n.agents>0&&"agents";if(i)throw new Error(`No ${i} selected to install.`);let a=r.some(l=>["mcp","permissions","hooks","ignore"].includes(l));if(mq(e)&&!a)throw new Error("No resources selected to install.")}s(fj,"ensureInstallSelection");So();function gj(t,e){if(t.find(n=>n.name===e.name&&n.source!==e.source))throw new Error(`Extends entry "${e.name}" already exists with a different source. Use --name to provide a different name.`)}s(gj,"assertExtendNameAvailable");function pq(t,e,r){if(r===void 0){if(!t)return;let o={...t};for(let i of ["skills","commands","rules","agents"])e.includes(i)&&delete o[i];return Object.keys(o).length?o:void 0}let n={...t};for(let o of ["skills","commands","rules","agents"]){if(!(o in r))continue;let i=r[o];if(i===void 0||i.length===0){delete n[o];continue}n[o]=[...new Set([...t?.[o]??[],...i])];}return Object.keys(n).length?n:void 0}s(pq,"mergePick");function hj(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,as:e.as}];let n=t[r],o=[...new Set([...n.features,...e.features])],i=pq(n.pick,e.features,e.pick);return t.map((a,l)=>l===r?{name:e.name,source:e.source,version:e.version??n.version,features:o,path:e.path!==void 0?e.path:n.path,pick:i,target:e.target??n.target,as:e.as??n.as}:a)}s(hj,"mergeExtendList");A();async function yj(t,e,r){let n=await _(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=hj(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await S(t,a.endsWith(`
338
340
  `)?a:`${a}
339
- `);}s(pj,"writeAgentsmeshWithNewExtend");ot();async function uj(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=qQ(n);if(cj(r.extends,i),o){y.info(`[dry-run] Would add extend:
340
- ${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await pj(a,r,i),y.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(uj,"writeInstallAsExtend");function qQ(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?Qe.parse(t.yamlTarget):void 0,as:t.as}}s(qQ,"toNewExtendEntry");w();w();var eq="pack.yaml";async function $f(t){let e=await v(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===eq)continue;let l=await lf(i);l!==null&&r.push(`${a}:${l}`);}let n=r.join(`
341
- `);return `sha256:${af(n)}`}s($f,"hashPackContent");w();var hn=".agentsmesh-install-manifest.json",nq=["pack.yaml",hn];z.object({name:z.string().min(1),source:z.string().min(1),installed_at:z.string().min(1),extends_id:z.string().nullable(),source_type:z.enum(["anthropic-skill-pack","canonical-agentsmesh","tool-native","unknown"]).nullable(),files:z.record(z.string().min(1),z.string().regex(/^sha256:[0-9a-f]{64}$/))});function oq(t,e){return relative(t,e).replaceAll("\\","/")}s(oq,"toForwardSlashRelative");async function Gf(t){let e=await Ya(t),r=[];for(let n of e){let o=oq(t,n);if(nq.includes(o))continue;let i=await cf(n);i!==null&&r.push([o,`sha256:${i}`]);}return r.sort(([n],[o])=>n.localeCompare(o)),Object.fromEntries(r)}s(Gf,"hashPackFiles");w();var sq=/spdx-license-identifier:\s*([A-Za-z0-9.+-]+)/i,iq=[{id:"BSD-3-Clause",pattern:/redistribution and use in source and binary forms[\s\S]+?neither the name of[\s\S]+?contributors/i},{id:"BSD-2-Clause",pattern:/redistribution and use in source and binary forms/i},{id:"AGPL-3.0",pattern:/gnu affero general public license[\s\S]+?version 3/i},{id:"LGPL-3.0",pattern:/gnu lesser general public license[\s\S]+?version 3/i},{id:"LGPL-2.1",pattern:/gnu lesser general public license[\s\S]+?version 2\.1/i},{id:"GPL-3.0",pattern:/gnu general public license[\s\S]+?version 3/i},{id:"GPL-2.0",pattern:/gnu general public license[\s\S]+?version 2/i},{id:"MPL-2.0",pattern:/mozilla public license[\s\S]+?version 2\.0/i},{id:"Apache-2.0",pattern:/apache license[\s\S]+?version 2\.0/i},{id:"MIT",pattern:/permission is hereby granted, free of charge, to any person obtaining a copy/i},{id:"ISC",pattern:/permission to use, copy, modify,? and\/or distribute this software/i},{id:"Unlicense",pattern:/this is free and unencumbered software released into the public domain/i},{id:"CC0-1.0",pattern:/cc0 1\.0 universal/i}];function dj(t){if(t.trim().length===0)return null;let e=sq.exec(t);if(e)return e[1]??null;for(let{id:r,pattern:n}of iq)if(n.test(t))return r;return null}s(dj,"detectSpdxLicense");var lq=["LICENSE","COPYING","NOTICE","COPYRIGHT"],cq=["",".md",".txt",".rst"];async function fj(t){for(let e of lq)for(let r of cq){let n=await _(join(t,`${e}${r}`));if(n===null)continue;let o=dj(n);if(o!==null)return o}return null}s(fj,"detectLicenseInPackDir");async function uq(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await O(r);for(let n of t.rules){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(uq,"writeRules");async function dq(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await O(r);for(let n of t.commands){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(dq,"writeCommands");async function fq(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await O(r);for(let n of t.agents){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(fq,"writeAgents");async function gq(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await O(r);for(let n of t.skills){let o=join(r,n.name);await O(o),await copyFile(n.source,join(o,"SKILL.md"));for(let i of n.supportingFiles){let a=join(o,i.relativePath);await O(dirname(a)),await copyFile(i.absolutePath,a);}}}s(gq,"writeSkills");async function hq(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(hq,"writePreservedRootFiles");async function yq(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
342
- `),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(`
341
+ `);}s(yj,"writeAgentsmeshWithNewExtend");st();async function _j(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=gq(n);if(gj(r.extends,i),o){y.info(`[dry-run] Would add extend:
342
+ ${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await yj(a,r,i),y.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(_j,"writeInstallAsExtend");function gq(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?nr.parse(t.yamlTarget):void 0,as:t.as}}s(gq,"toNewExtendEntry");A();A();var yq="pack.yaml";async function Xf(t){let e=await $(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===yq)continue;let l=await Sf(i);l!==null&&r.push(`${a}:${l}`);}let n=r.join(`
343
+ `);return `sha256:${If(n)}`}s(Xf,"hashPackContent");A();var tr=".agentsmesh-install-manifest.json",Rq=["pack.yaml",tr];z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),installed_at:z$1.string().min(1),extends_id:z$1.string().nullable(),source_type:z$1.enum(["anthropic-skill-pack","canonical-agentsmesh","tool-native","unknown"]).nullable(),files:z$1.record(z$1.string().min(1),z$1.string().regex(/^sha256:[0-9a-f]{64}$/))});function Iq(t,e){return relative(t,e).replaceAll("\\","/")}s(Iq,"toForwardSlashRelative");async function Zf(t){let e=await Xa(t),r=[];for(let n of e){let o=Iq(t,n);if(Rq.includes(o))continue;let i=await Cf(n);i!==null&&r.push([o,`sha256:${i}`]);}return r.sort(([n],[o])=>n.localeCompare(o)),Object.fromEntries(r)}s(Zf,"hashPackFiles");A();var Sq=/spdx-license-identifier:\s*([A-Za-z0-9.+-]+)/i,Cq=[{id:"BSD-3-Clause",pattern:/redistribution and use in source and binary forms[\s\S]+?neither the name of[\s\S]+?contributors/i},{id:"BSD-2-Clause",pattern:/redistribution and use in source and binary forms/i},{id:"AGPL-3.0",pattern:/gnu affero general public license[\s\S]+?version 3/i},{id:"LGPL-3.0",pattern:/gnu lesser general public license[\s\S]+?version 3/i},{id:"LGPL-2.1",pattern:/gnu lesser general public license[\s\S]+?version 2\.1/i},{id:"GPL-3.0",pattern:/gnu general public license[\s\S]+?version 3/i},{id:"GPL-2.0",pattern:/gnu general public license[\s\S]+?version 2/i},{id:"MPL-2.0",pattern:/mozilla public license[\s\S]+?version 2\.0/i},{id:"Apache-2.0",pattern:/apache license[\s\S]+?version 2\.0/i},{id:"MIT",pattern:/permission is hereby granted, free of charge, to any person obtaining a copy/i},{id:"ISC",pattern:/permission to use, copy, modify,? and\/or distribute this software/i},{id:"Unlicense",pattern:/this is free and unencumbered software released into the public domain/i},{id:"CC0-1.0",pattern:/cc0 1\.0 universal/i}];function Rj(t){if(t.trim().length===0)return null;let e=Sq.exec(t);if(e)return e[1]??null;for(let{id:r,pattern:n}of Cq)if(n.test(t))return r;return null}s(Rj,"detectSpdxLicense");var Eq=["LICENSE","COPYING","NOTICE","COPYRIGHT"],Lq=["",".md",".txt",".rst"];async function Ij(t){for(let e of Eq)for(let r of Lq){let n=await _(join(t,`${e}${r}`));if(n===null)continue;let o=Rj(n);if(o!==null)return o}return null}s(Ij,"detectLicenseInPackDir");async function Aq(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await O(r);for(let n of t.rules){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(Aq,"writeRules");async function bq(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await O(r);for(let n of t.commands){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(bq,"writeCommands");async function Pq(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await O(r);for(let n of t.agents){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(Pq,"writeAgents");async function Tq(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await O(r);for(let n of t.skills){let o=join(r,n.name);await O(o),await copyFile(n.source,join(o,"SKILL.md"));for(let i of n.supportingFiles){let a=join(o,i.relativePath);await O(dirname(a)),await copyFile(i.absolutePath,a);}}}s(Tq,"writeSkills");async function xq(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(xq,"writePreservedRootFiles");async function Dq(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
344
+ `),t.permissions!==null&&await S(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await S(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await S(join(e,"ignore"),`${t.ignore.join(`
343
345
  `)}
344
- `);}s(yq,"writeSettings");function _q(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(_q,"validatePackName");async function Rq(t,e,r){let n=await Gf(t),o=f$({name:e.name,source:e.source,installed_at:e.installed_at,extends_id:r.extends_id??null,source_type:r.source_type??null,files:n},"install-manifest");await I(join(t,hn),`${JSON.stringify(o,null,2)}
345
- `);}s(Rq,"writeInstallManifest");async function gj(t,e,r,n,o={},i=[]){_q(e);let a=join(t,`${e}.tmp`),l=join(t,`${e}.old`),c=join(t,e);await $(a)&&await rm(a,{recursive:true,force:true}),await $(l)&&await rm(l,{recursive:true,force:true});let m,p=false;try{await O(a),await uq(r,a),await dq(r,a),await fq(r,a),await gq(r,a),await yq(r,a),await hq(i,a);let u=await $f(a),f=await fj(a);m=gi({...n,content_hash:u,license:f}),await I(join(a,"pack.yaml"),Da(stringify(m),"pack")),await Rq(a,m,o),await mkdir(t,{recursive:!0}),await $(c)&&(await rename(c,l),p=!0);try{await rename(a,c);}catch(g){throw p&&(await rename(l,c).catch(()=>{}),p=!1),g}}catch(u){throw await rm(a,{recursive:true,force:true}).catch(()=>{}),u}return p&&await rm(l,{recursive:true,force:true}).catch(()=>{}),m}s(gj,"materializePack");fc();w();function $I(t,e){return [...new Set([...t,...e])]}s($I,"union");function Sq(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=$I(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(Sq,"mergePathScope");function Cq(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=$I(n[i]??[],r[i]):delete n[i];return (n.skills?.length??0)>0||(n.rules?.length??0)>0||(n.commands?.length??0)>0||(n.agents?.length??0)>0?n:void 0}s(Cq,"mergePick");async function kq(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await O(r);for(let n of t.rules)await copyFile(n.source,join(r,basename(n.source)));}s(kq,"mergeRules");async function Eq(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await O(r);for(let n of t.commands)await copyFile(n.source,join(r,basename(n.source)));}s(Eq,"mergeCommands");async function Lq(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await O(r);for(let n of t.agents)await copyFile(n.source,join(r,basename(n.source)));}s(Lq,"mergeAgents");async function Oq(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await O(r);for(let n of t.skills){let o=join(r,n.name);await O(o),await copyFile(n.source,join(o,"SKILL.md"));for(let i of n.supportingFiles){let a=join(o,i.relativePath);await O(dirname(a)),await copyFile(i.absolutePath,a);}}}s(Oq,"mergeSkills");async function Aq(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(Aq,"mergePreservedRootFiles");async function wq(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
346
- `),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(`
346
+ `);}s(Dq,"writeSettings");function Nq(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(Nq,"validatePackName");async function Fq(t,e,r){let n=await Zf(t),o=S$({name:e.name,source:e.source,installed_at:e.installed_at,extends_id:r.extends_id??null,source_type:r.source_type??null,files:n},"install-manifest");await S(join(t,tr),`${JSON.stringify(o,null,2)}
347
+ `);}s(Fq,"writeInstallManifest");async function Sj(t,e,r,n,o={},i=[]){Nq(e);let a=join(t,`${e}.tmp`),l=join(t,`${e}.old`),c=join(t,e);await j(a)&&await rm$1(a,{recursive:true,force:true}),await j(l)&&await rm$1(l,{recursive:true,force:true});let m,p=false;try{await O(a),await Aq(r,a),await bq(r,a),await Pq(r,a),await Tq(r,a),await Dq(r,a),await xq(i,a);let u=await Xf(a),f=await Ij(a);m=hi({...n,content_hash:u,license:f}),await S(join(a,"pack.yaml"),Fa(stringify(m),"pack")),await Fq(a,m,o),await mkdir(t,{recursive:!0}),await j(c)&&(await rename(c,l),p=!0);try{await rename(a,c);}catch(g){throw p&&(await rename(l,c).catch(()=>{}),p=!1),g}}catch(u){throw await rm$1(a,{recursive:true,force:true}).catch(()=>{}),u}return p&&await rm$1(l,{recursive:true,force:true}).catch(()=>{}),m}s(Sj,"materializePack");gc();A();function WI(t,e){return [...new Set([...t,...e])]}s(WI,"union");function Mq(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=WI(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(Mq,"mergePathScope");function $q(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=WI(n[i]??[],r[i]):delete n[i];return (n.skills?.length??0)>0||(n.rules?.length??0)>0||(n.commands?.length??0)>0||(n.agents?.length??0)>0?n:void 0}s($q,"mergePick");async function Gq(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await O(r);for(let n of t.rules)await copyFile(n.source,join(r,basename(n.source)));}s(Gq,"mergeRules");async function jq(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await O(r);for(let n of t.commands)await copyFile(n.source,join(r,basename(n.source)));}s(jq,"mergeCommands");async function Uq(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await O(r);for(let n of t.agents)await copyFile(n.source,join(r,basename(n.source)));}s(Uq,"mergeAgents");async function Bq(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await O(r);for(let n of t.skills){let o=join(r,n.name);await O(o),await copyFile(n.source,join(o,"SKILL.md"));for(let i of n.supportingFiles){let a=join(o,i.relativePath);await O(dirname(a)),await copyFile(i.absolutePath,a);}}}s(Bq,"mergeSkills");async function Kq(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(Kq,"mergePreservedRootFiles");async function Wq(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
348
+ `),t.permissions!==null&&await S(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await S(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await S(join(e,"ignore"),`${t.ignore.join(`
347
349
  `)}
348
- `);}s(wq,"mergeSettings");async function hj(t,e,r,n,o,i,a=[]){await kq(r,t),await Eq(r,t),await Lq(r,t),await Oq(r,t),await wq(r,t),await Aq(a,t);let l=$I(e.features,n),c=Cq(e.pick,n,o),m=Sq(e,i?.path),p=await $f(t),u=new Date().toISOString(),f=gi({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:l,pick:c,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...m,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:u,content_hash:p});return await I(join(t,"pack.yaml"),Da(stringify(f),"pack")),f}s(hj,"mergeIntoPack");Cg();Co();async function yj(t){let e=[];try{let r=await readdir(t,{withFileTypes:!0});for(let n of r)n.isFile()&&Gp(n.name)&&e.push({relativePath:n.name,absolutePath:join(t,n.name)});}catch{return []}return e.sort((r,n)=>r.relativePath.localeCompare(n.relativePath)),e}s(yj,"collectPreservedRootFiles");Ro();ot();Ro();w();nf();function xq(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(xq,"sanitize");function Dq(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 n=r[r.length-1].replace(/\.git$/i,"");return r.length>=2?`${r[r.length-2].replace(/\.git$/i,"")}-${n}`:n}catch{return "repo"}}s(Dq,"gitUrlLastSegments");function _j(t,e,r){let n;if(t.kind==="local"){let l=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);n=l[l.length-1]??"local";}else t.kind==="github"&&t.org&&t.repo?n=`${t.org}-${t.repo}`:t.kind==="gitlab"&&t.org&&t.repo?n=`${t.org.replace(/\//g,"-")}-${t.repo}`:t.gitRemoteUrl?n=Dq(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=xq(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(_j,"suggestExtendName");function Rj(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||_j(r,{featureHint:n.length===1?n[0]:void 0},i)}s(Rj,"selectInstallEntryName");function Ij(t){let e=t.trim();for(;e.startsWith("git+");){let c=e.lastIndexOf("#");e=(c<0?e.slice(4):e.slice(4,c)).trim();}let r=e.match(/^github:([^/]+)\/([^/@]+?)(?:\.git)?(?:@[^/]+)?$/i);if(r)return `github:${r[1].toLowerCase()}/${r[2].toLowerCase()}`;let n=e.match(/^gitlab:(.+?)\/([^/@]+?)(?:\.git)?(?:@[^/]+)?$/i);if(n)return `gitlab:${n[1].toLowerCase()}/${n[2].toLowerCase()}`;let o=e.match(/^https?:\/\/github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/i);if(o)return `github:${o[1].toLowerCase()}/${o[2].toLowerCase()}`;let i=e.match(/^https?:\/\/gitlab\.com\/(.+?)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/i);if(i)return `gitlab:${i[1].toLowerCase()}/${i[2].toLowerCase()}`;let a=e.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/i);if(a)return `github:${a[1].toLowerCase()}/${a[2].toLowerCase()}`;let l=e.match(/^git@gitlab\.com:(.+?)\/([^/]+?)(?:\.git)?$/i);return l?`gitlab:${l[1].toLowerCase()}/${l[2].toLowerCase()}`:null}s(Ij,"canonicalRemoteIdentity");function Nq(t){return t.kind==="github"&&t.org&&t.repo?`github:${t.org.toLowerCase()}/${t.repo.toLowerCase()}`:t.kind==="gitlab"&&t.org&&t.repo?`gitlab:${t.org.toLowerCase()}/${t.repo.toLowerCase()}`:t.gitRemoteUrl?Ij(t.gitRemoteUrl):null}s(Nq,"parsedSourceIdentity");function Sj(t,e){let r=Nq(e);if(r===null)return null;for(let n of t){let o=Ij(n.source);if(o!==null&&o===r)return n.name}return null}s(Sj,"findExistingInstallName");function GI(t,e){if(t.length!==e.length)return false;let r=[...t].sort(),n=[...e].sort();for(let o=0;o<r.length;o++)if(r[o]!==n[o])return false;return true}s(GI,"sameFeatureSet");function Cj(t){let{manifest:e,parsed:r,entryFeatures:n,yamlTarget:o,explicitAs:i}=t,a=Sj(e,r);if(a===null)return null;let l=e.find(c=>c.name===a);return l.target!==o||l.as!==i||!GI(l.features,n)?null:l.name}s(Cj,"pickReuseEntryName");var Mq=s(t=>!t.includes("/")&&!t.includes("\\")&&!t.includes("\0")&&t!=="."&&t!=="..","isSafeInstallName"),Ej=z.object({name:z.string().min(1).refine(Mq,{message:'install name must not contain path separators, NUL, or "."/".." segments'}),source:z.string().min(1),version:z.string().optional(),source_kind:z.enum(["github","gitlab","git","local"]),features:z.array(Xa).min(1),pick:Mc.optional(),target:Qe.optional(),path:z.string().optional(),paths:z.array(z.string().min(1)).min(1).optional(),as:dc.optional()}),$q=z.object({version:z.literal(1),installs:z.array(Ej).default([])});function Gq(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&GI(t.features,e.features)}s(Gq,"sameInstallIdentity");function jI(t){return join(t,"installs.yaml")}s(jI,"manifestPath");async function ho(t){let e=await _(jI(t));if(e===null)return [];try{return $q.parse(parse(e)).installs.map(r=>gi(r))}catch{return []}}s(ho,"readInstallManifest");async function Lj(t,e){let r=gi(e),o=(await ho(t)).filter(i=>i.name!==r.name&&!Gq(i,r));o.push(r),await I(jI(t),Da(stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}),"installs"));}s(Lj,"upsertInstallManifestEntry");async function Oj(t,e){let r=await ho(t),n=r.filter(o=>o.name!==e);return n.length===r.length?false:(await I(jI(t),Da(stringify({version:1,installs:n.sort((o,i)=>o.name.localeCompare(i.name))}),"installs")),true)}s(Oj,"removeInstallManifestEntry");function Aj(t){return gi(Ej.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(Aj,"buildInstallManifestEntry");w();function Uq(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(Uq,"pathScope");function Bq(t,e){let r=new Set(e.skillNames),n=new Set(e.ruleSlugs),o=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=>n.has(ne(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(Bq,"applySelection");async function wj(t){let{canonicalDir:e,packName:r,narrowed:n,selected:o,sourceForYaml:i,version:a,sourceKind:l,entryFeatures:c,pick:m,yamlTarget:p,pathInRepo:u,manualAs:f,renameExistingPack:g,sourceType:h,contentRoot:R}=t,C=join(e,"packs"),S=Bq(n,o),k=R?await yj(R):[],P=new Date().toISOString(),N=p!==void 0?Qe.parse(p):void 0,F=await iM(C,i,{target:N,as:f,features:c}),W=r,z=c,Q=m,at=u,At;if(F){let wt=F.packDir,oe=F.meta;if(g&&F.name!==r){let Dt=join(C,r);if(await $(Dt))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(F.packDir,Dt),wt=Dt,oe={...F.meta,name:r};}let Dr=await hj(wt,oe,S,c,m,{source:i,...a!==void 0?{version:a}:{},...N!==void 0?{target:N}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}},k);W=Dr.name,z=Dr.features,Q=Dr.pick,at=Dr.path,At=Dr.paths,y.success(`Updated pack "${Dr.name}" in .agentsmesh/packs/.`);}else {if(await fi(join(C,r)))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await gj(C,r,S,{name:r,source:i,...a!==void 0&&{version:a},source_kind:l,installed_at:P,updated_at:P,features:c,...m!==void 0&&{pick:m},...N!==void 0&&{target:N},...Uq(u),...f!==void 0&&{as:f}},h!==void 0?{source_type:h}:{},k),y.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await Lj(e,Aj({name:W,source:i,version:a,sourceKind:l,features:z,pick:Q,target:N,path:at,paths:At,as:f})),l!=="local"&&await nC(i);}s(wj,"installAsPack");function bj(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=Cc(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:gn(n)}}s(bj,"applyReplayInstallScope");function Pj(t,e){let r=[];for(let n of t.skillNames)r.push({kind:"skill",name:n,path:e});for(let n of t.ruleSlugs)r.push({kind:"rule",name:n,path:e});for(let n of t.commandNames)r.push({kind:"command",name:n,path:e});for(let n of t.agentNames)r.push({kind:"agent",name:n,path:e});return r}s(Pj,"buildInstalledList");function Tj(t,e,r,n,o){let i=[];for(let a of t)o.skillNames.includes(a.name)||i.push({kind:"skill",name:a.name,reason:"conflict"});for(let a of e){let l=ne(a);o.ruleSlugs.includes(l)||i.push({kind:"rule",name:l,reason:"conflict"});}for(let a of r)o.commandNames.includes(a.name)||i.push({kind:"command",name:a.name,reason:"conflict"});for(let a of n)o.agentNames.includes(a.name)||i.push({kind:"agent",name:a.name,reason:"conflict"});return i}s(Tj,"buildSkippedList");async function xj(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,nameOverride:a,explicitAs:l}=t,{config:c,context:m,parsed:p,sourceForYaml:u,version:f,pathInRepo:g,contentRoot:h,persisted:R}=t,{replay:C,prep:S,implicitPick:k,narrowed:P,discoveredFeatures:N,sourceType:F}=t,{narrowed:W,discoveredFeatures:z}=bj(P,N,C);if(!qG(W))throw new Error(k||S.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 Q=await tj(W,r,n,o),at=await ej(W,r,n,o),At=await rj(W,r,n,o),wt=await nj(W,r,n,o),oe={skills:Q.length,rules:at.length,commands:At.length,agents:wt.length},{canonical:Dr}=await ke(c,m.configDir,{},m.canonicalDir),Dt=!r&&!n&&o?await oj(Dr,{skills:Q,rules:at,commands:At,agents:wt}):{skillNames:Q.map(Ss=>Ss.name),ruleSlugs:at.map(Ss=>ne(Ss)),commandNames:At.map(Ss=>Ss.name),agentNames:wt.map(Ss=>Ss.name)};lj({selected:Dt,discoveredFeatures:z,preConflict:oe});let Ze=C?.features??aj(z,Dt);if(Ze.length===0)throw new Error("No features left to install after selection.");let ja=sj(C?.pick,Dt)??R.pick??ij({pathInRepo:R.pathInRepo??g,implicitPick:k,preConflictCounts:oe,selected:Dt}),Ua=await ho(m.canonicalDir),Dc=Cj({manifest:Ua,parsed:p,entryFeatures:Ze,yamlTarget:S.yamlTarget,explicitAs:l}),Nc=Rj({config:c,parsed:p,entryFeatures:Ze,nameOverride:a||Dc||""}),kp=Pj(Dt,Nc),Ba=Tj(Q,at,At,wt,Dt);if(i){if(await uj({configDir:m.configDir,config:c,entryArgs:{name:Nc,source:u,version:f,features:Ze,path:R.pathInRepo,pick:ja,yamlTarget:S.yamlTarget,as:l},dryRun:n}),n)return {installed:kp,skipped:Ba}}else {if(n)return y.info(`[dry-run] Would install pack "${Nc}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:kp,skipped:Ba};await wj({canonicalDir:m.canonicalDir,packName:Nc,narrowed:W,selected:Dt,sourceForYaml:u,version:f,sourceKind:p.kind,entryFeatures:Ze,pick:ja,yamlTarget:S.yamlTarget,pathInRepo:R.pathInRepo,manualAs:l,renameExistingPack:a===""&&Dc===null,sourceType:F,contentRoot:h});}return await vf("install",e,m.rootBase),{installed:kp,skipped:Ba}}s(xj,"executeRunInstallPoolsAndWrite");function Uf(t,e){let r=e?.input??process.stdin,n=e?.output??process.stdout;return new Promise(o=>{let i=QG.createInterface({input:r,output:n,terminal:false}),a=false;i.on("close",()=>{a||o("");}),i.question(t,l=>{a=true,i.close(),o(l);});})}s(Uf,"readLine");function Nj(t,e){let r=e.resolved.length,n=r===1?"link":"links",o=[`Entity "${e.entityName}" (${e.entityKind}) has ${r} broken ${n}:`];for(let i of e.resolved)o.push(` - ${i.link.path} (${i.classification})`);o.push(""),t.write(`${o.join(`
350
+ `);}s(Wq,"mergeSettings");async function Cj(t,e,r,n,o,i,a=[]){await Gq(r,t),await jq(r,t),await Uq(r,t),await Bq(r,t),await Wq(r,t),await Kq(a,t);let l=WI(e.features,n),c=$q(e.pick,n,o),m=Mq(e,i?.path),p=await Xf(t),u=new Date().toISOString(),f=hi({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:l,pick:c,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...m,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:u,content_hash:p});return await S(join(t,"pack.yaml"),Fa(stringify(f),"pack")),f}s(Cj,"mergeIntoPack");vg();Eo();async function kj(t){let e=[];try{let r=await readdir(t,{withFileTypes:!0});for(let n of r)n.isFile()&&Qp(n.name)&&e.push({relativePath:n.name,absolutePath:join(t,n.name)});}catch{return []}return e.sort((r,n)=>r.relativePath.localeCompare(n.relativePath)),e}s(kj,"collectPreservedRootFiles");So();st();So();A();yf();function Jq(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Jq,"sanitize");function Yq(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 n=r[r.length-1].replace(/\.git$/i,"");return r.length>=2?`${r[r.length-2].replace(/\.git$/i,"")}-${n}`:n}catch{return "repo"}}s(Yq,"gitUrlLastSegments");function Ej(t,e,r){let n;if(t.kind==="local"){let l=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);n=l[l.length-1]??"local";}else t.kind==="github"&&t.org&&t.repo?n=`${t.org}-${t.repo}`:t.kind==="gitlab"&&t.org&&t.repo?n=`${t.org.replace(/\//g,"-")}-${t.repo}`:t.gitRemoteUrl?n=Yq(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=Jq(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(Ej,"suggestExtendName");function Lj(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||Ej(r,{featureHint:n.length===1?n[0]:void 0},i)}s(Lj,"selectInstallEntryName");function Oj(t){let e=t.trim();for(;e.startsWith("git+");){let c=e.lastIndexOf("#");e=(c<0?e.slice(4):e.slice(4,c)).trim();}let r=e.match(/^github:([^/]+)\/([^/@]+?)(?:\.git)?(?:@[^/]+)?$/i);if(r)return `github:${r[1].toLowerCase()}/${r[2].toLowerCase()}`;let n=e.match(/^gitlab:(.+?)\/([^/@]+?)(?:\.git)?(?:@[^/]+)?$/i);if(n)return `gitlab:${n[1].toLowerCase()}/${n[2].toLowerCase()}`;let o=e.match(/^https?:\/\/github\.com\/([^/]+)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/i);if(o)return `github:${o[1].toLowerCase()}/${o[2].toLowerCase()}`;let i=e.match(/^https?:\/\/gitlab\.com\/(.+?)\/([^/?#]+?)(?:\.git)?(?:[/?#].*)?$/i);if(i)return `gitlab:${i[1].toLowerCase()}/${i[2].toLowerCase()}`;let a=e.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/i);if(a)return `github:${a[1].toLowerCase()}/${a[2].toLowerCase()}`;let l=e.match(/^git@gitlab\.com:(.+?)\/([^/]+?)(?:\.git)?$/i);return l?`gitlab:${l[1].toLowerCase()}/${l[2].toLowerCase()}`:null}s(Oj,"canonicalRemoteIdentity");function Xq(t){return t.kind==="github"&&t.org&&t.repo?`github:${t.org.toLowerCase()}/${t.repo.toLowerCase()}`:t.kind==="gitlab"&&t.org&&t.repo?`gitlab:${t.org.toLowerCase()}/${t.repo.toLowerCase()}`:t.gitRemoteUrl?Oj(t.gitRemoteUrl):null}s(Xq,"parsedSourceIdentity");function wj(t,e){let r=Xq(e);if(r===null)return null;for(let n of t){let o=Oj(n.source);if(o!==null&&o===r)return n.name}return null}s(wj,"findExistingInstallName");function HI(t,e){if(t.length!==e.length)return false;let r=[...t].sort(),n=[...e].sort();for(let o=0;o<r.length;o++)if(r[o]!==n[o])return false;return true}s(HI,"sameFeatureSet");function Aj(t){let{manifest:e,parsed:r,entryFeatures:n,yamlTarget:o,explicitAs:i}=t,a=wj(e,r);if(a===null)return null;let l=e.find(c=>c.name===a);return l.target!==o||l.as!==i||!HI(l.features,n)?null:l.name}s(Aj,"pickReuseEntryName");var qq=s(t=>!t.includes("/")&&!t.includes("\\")&&!t.includes("\0")&&t!=="."&&t!=="..","isSafeInstallName"),Pj=z$1.object({name:z$1.string().min(1).refine(qq,{message:'install name must not contain path separators, NUL, or "."/".." segments'}),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:z$1.enum(["github","gitlab","git","local"]),features:z$1.array(Za).min(1),pick:Uc.optional(),target:nr.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:fc.optional(),refreshed_at:z$1.string().min(1).optional(),original_ref:z$1.string().optional()}),t3=z$1.object({version:z$1.literal(1),installs:z$1.array(Pj).default([])});function e3(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&HI(t.features,e.features)}s(e3,"sameInstallIdentity");function zI(t){return join(t,"installs.yaml")}s(zI,"manifestPath");async function xe(t){let e=await _(zI(t));if(e===null)return [];try{return t3.parse(parse(e)).installs.map(r=>hi(r))}catch{return []}}s(xe,"readInstallManifest");async function qf(t,e){let r=hi(e),o=(await xe(t)).filter(i=>i.name!==r.name&&!e3(i,r));o.push(r),await S(zI(t),Fa(stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}),"installs"));}s(qf,"upsertInstallManifestEntry");async function Tj(t,e){let r=await xe(t),n=r.filter(o=>o.name!==e);return n.length===r.length?false:(await S(zI(t),Fa(stringify({version:1,installs:n.sort((o,i)=>o.name.localeCompare(i.name))}),"installs")),true)}s(Tj,"removeInstallManifestEntry");function xj(t){return hi(Pj.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,refreshed_at:t.refreshed_at,original_ref:t.originalRef}))}s(xj,"buildInstallManifestEntry");A();function n3(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(n3,"pathScope");function o3(t,e){let r=new Set(e.skillNames),n=new Set(e.ruleSlugs),o=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=>n.has(se(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(o3,"applySelection");async function Dj(t){let{canonicalDir:e,packName:r,narrowed:n,selected:o,sourceForYaml:i,version:a,sourceKind:l,entryFeatures:c,pick:m,yamlTarget:p,pathInRepo:u,manualAs:f,renameExistingPack:g,sourceType:h,contentRoot:I,forceFreshMaterialize:k,originalRef:C}=t,R=join(e,"packs"),P=o3(n,o),N=I?await kj(I):[],F=new Date().toISOString(),B=p!==void 0?nr.parse(p):void 0,U=k?null:await dM(R,i,{target:B,as:f,features:c}),q=r,nt=c,M=m,tt=u,Nt;if(U){let Le=U.packDir,Xt=U.meta;if(g&&U.name!==r){let De=join(R,r);if(await j(De))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(U.packDir,De),Le=De,Xt={...U.meta,name:r};}let Ut=await Cj(Le,Xt,P,c,m,{source:i,...a!==void 0?{version:a}:{},...B!==void 0?{target:B}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}},N);q=Ut.name,nt=Ut.features,M=Ut.pick,tt=Ut.path,Nt=Ut.paths,y.success(`Updated pack "${Ut.name}" in .agentsmesh/packs/.`);}else {if(!k&&await gi(join(R,r)))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await Sj(R,r,P,{name:r,source:i,...a!==void 0&&{version:a},source_kind:l,installed_at:F,updated_at:F,features:c,...m!==void 0&&{pick:m},...B!==void 0&&{target:B},...n3(u),...f!==void 0&&{as:f}},h!==void 0?{source_type:h}:{},N),y.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await qf(e,xj({name:q,source:i,version:a,sourceKind:l,features:nt,pick:M,target:B,path:tt,paths:Nt,as:f,originalRef:C})),l!=="local"&&await mC(i);}s(Dj,"installAsPack");function Nj(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=Ec(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:_n(n)}}s(Nj,"applyReplayInstallScope");function Fj(t,e){let r=[];for(let n of t.skillNames)r.push({kind:"skill",name:n,path:e});for(let n of t.ruleSlugs)r.push({kind:"rule",name:n,path:e});for(let n of t.commandNames)r.push({kind:"command",name:n,path:e});for(let n of t.agentNames)r.push({kind:"agent",name:n,path:e});return r}s(Fj,"buildInstalledList");function vj(t,e,r,n,o){let i=[];for(let a of t)o.skillNames.includes(a.name)||i.push({kind:"skill",name:a.name,reason:"conflict"});for(let a of e){let l=se(a);o.ruleSlugs.includes(l)||i.push({kind:"rule",name:l,reason:"conflict"});}for(let a of r)o.commandNames.includes(a.name)||i.push({kind:"command",name:a.name,reason:"conflict"});for(let a of n)o.agentNames.includes(a.name)||i.push({kind:"agent",name:a.name,reason:"conflict"});return i}s(vj,"buildSkippedList");async function Mj(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,forceFreshMaterialize:a,nameOverride:l,explicitAs:c}=t,{config:m,context:p,parsed:u,sourceForYaml:f,version:g,pathInRepo:h,contentRoot:I,persisted:k}=t,{replay:C,prep:R,implicitPick:P,narrowed:N,discoveredFeatures:F,sourceType:B}=t,{narrowed:U,discoveredFeatures:q}=Nj(N,F,C);if(!sj(U))throw new Error(P||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 nt=await ij(U,r,n,o),M=await aj(U,r,n,o),tt=await lj(U,r,n,o),Nt=await cj(U,r,n,o),Le={skills:nt.length,rules:M.length,commands:tt.length,agents:Nt.length},{canonical:Xt}=await Ee(m,p.configDir,{},p.canonicalDir),Ut=!r&&!n&&o?await mj(Xt,{skills:nt,rules:M,commands:tt,agents:Nt}):{skillNames:nt.map(_o=>_o.name),ruleSlugs:M.map(_o=>se(_o)),commandNames:tt.map(_o=>_o.name),agentNames:Nt.map(_o=>_o.name)};fj({selected:Ut,discoveredFeatures:q,preConflict:Le});let De=C?.features??dj(q,Ut);if(De.length===0)throw new Error("No features left to install after selection.");let Ci=pj(C?.pick,Ut)??k.pick??uj({pathInRepo:k.pathInRepo??h,implicitPick:P,preConflictCounts:Le,selected:Ut}),Fp=await xe(p.canonicalDir),yg=Aj({manifest:Fp,parsed:u,entryFeatures:De,yamlTarget:R.yamlTarget,explicitAs:c}),$c=Lj({config:m,parsed:u,entryFeatures:De,nameOverride:l||yg||""}),Ka=Fj(Ut,$c),vp=vj(nt,M,tt,Nt,Ut);if(i){if(await _j({configDir:p.configDir,config:m,entryArgs:{name:$c,source:f,version:g,features:De,path:k.pathInRepo,pick:Ci,yamlTarget:R.yamlTarget,as:c},dryRun:n}),n)return {installed:Ka,skipped:vp}}else {if(n)return y.info(`[dry-run] Would install pack "${$c}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:Ka,skipped:vp};await Dj({canonicalDir:p.canonicalDir,packName:$c,narrowed:U,selected:Ut,sourceForYaml:f,version:g,sourceKind:u.kind,entryFeatures:De,pick:Ci,yamlTarget:R.yamlTarget,pathInRepo:k.pathInRepo,manualAs:c,renameExistingPack:l===""&&yg===null,sourceType:B,contentRoot:I,forceFreshMaterialize:a,originalRef:u.rawRef!==""?u.rawRef:void 0});}return await wc("install",e,p.rootBase),{installed:Ka,skipped:vp}}s(Mj,"executeRunInstallPoolsAndWrite");function Pc(t,e){let r=e?.input??process.stdin,n=e?.output??process.stdout;return new Promise(o=>{let i=oj.createInterface({input:r,output:n,terminal:false}),a=false;i.on("close",()=>{a||o("");}),i.question(t,l=>{a=true,i.close(),o(l);});})}s(Pc,"readLine");function Gj(t,e){let r=e.resolved.length,n=r===1?"link":"links",o=[`Entity "${e.entityName}" (${e.entityKind}) has ${r} broken ${n}:`];for(let i of e.resolved)o.push(` - ${i.link.path} (${i.classification})`);o.push(""),t.write(`${o.join(`
349
351
  `)}
350
- `);}s(Nj,"writeBanner");async function Fj(t,e,r){let n=[];for(let o of t){if(o.resolved.length===0)continue;if(e.bypass){Nj(r,o),n.push({entityKind:o.entityKind,entityName:o.entityName,action:"leave-with-warnings"});continue}Nj(r,o);let i=(await r.ask("Action: [i]nclude resolvable as supporting files / [l]eave with warnings / [a]bort install ")).trim().toLowerCase();if(i==="i"){n.push({entityKind:o.entityKind,entityName:o.entityName,action:"include-resolvable"});continue}if(i==="l"){n.push({entityKind:o.entityKind,entityName:o.entityName,action:"leave-with-warnings"});continue}return {decisions:[],aborted:true}}return {decisions:n,aborted:false}}s(Fj,"runBrokenLinkPrompt");var BI=["skills","agents","commands","rules"],KI={skills:"skill",agents:"agent",commands:"command",rules:"rule"},$j={skills:"skills",agents:"agents",commands:"commands",rules:"rules"};function va(t){return {skills:[],agents:[],commands:[],rules:[],aborted:t}}s(va,"emptySelection");function vj(t){return {skills:[...t.skills],agents:[...t.agents],commands:[...t.commands],rules:[...t.rules],aborted:false}}s(vj,"selectAll");function Mj(t,e,r){let n=[`Found in ${e}:`];for(let o of BI){let i=r[o];if(i.length===0)continue;let a=i.length===1?KI[o]:$j[o];n.push(` - ${i.length} ${a}`);}n.push(""),t.write(`${n.join(`
352
+ `);}s(Gj,"writeBanner");async function jj(t,e,r){let n=[];for(let o of t){if(o.resolved.length===0)continue;if(e.bypass){Gj(r,o),n.push({entityKind:o.entityKind,entityName:o.entityName,action:"leave-with-warnings"});continue}Gj(r,o);let i=(await r.ask("Action: [i]nclude resolvable as supporting files / [l]eave with warnings / [a]bort install ")).trim().toLowerCase();if(i==="i"){n.push({entityKind:o.entityKind,entityName:o.entityName,action:"include-resolvable"});continue}if(i==="l"){n.push({entityKind:o.entityKind,entityName:o.entityName,action:"leave-with-warnings"});continue}return {decisions:[],aborted:true}}return {decisions:n,aborted:false}}s(jj,"runBrokenLinkPrompt");var JI=["skills","agents","commands","rules"],YI={skills:"skill",agents:"agent",commands:"command",rules:"rule"},Kj={skills:"skills",agents:"agents",commands:"commands",rules:"rules"};function $a(t){return {skills:[],agents:[],commands:[],rules:[],aborted:t}}s($a,"emptySelection");function Uj(t){return {skills:[...t.skills],agents:[...t.agents],commands:[...t.commands],rules:[...t.rules],aborted:false}}s(Uj,"selectAll");function Bj(t,e,r){let n=[`Found in ${e}:`];for(let o of JI){let i=r[o];if(i.length===0)continue;let a=i.length===1?YI[o]:Kj[o];n.push(` - ${i.length} ${a}`);}n.push(""),t.write(`${n.join(`
351
353
  `)}
352
- `);}s(Mj,"writeBanner");async function Kq(t,e,r){if(r.length===0)return {selected:[],aborted:false};let n=$j[e],o=(await t.ask(`Install all ${r.length} ${n}? [y/n/c] `)).trim().toLowerCase();if(o==="y")return {selected:[...r],aborted:false};if(o==="n")return {selected:[],aborted:false};if(o!=="c")return {selected:[],aborted:true};let i=KI[e],a=[];for(let l=0;l<r.length;l++){let c=r[l],m=(await t.ask(`Install ${i} "${c}"? [y/N/a/q] `)).trim().toLowerCase();if(m==="y"){a.push(c);continue}if(!(m===""||m==="n")){if(m==="a"){for(let p=l;p<r.length;p++)a.push(r[p]);return {selected:a,aborted:false}}return m==="q"?{selected:a,aborted:false}:{selected:[],aborted:true}}}return {selected:a,aborted:false}}s(Kq,"walkType");function Wq(t){let e=null;for(let r of BI)for(let n of t[r]){if(e!==null)return null;e={kind:r,id:n};}return e}s(Wq,"findSingleEntity");async function Hq(t,e){let r=KI[e.kind],n=(await t.ask(`Install ${r} "${e.id}"? [y/N] `)).trim().toLowerCase();return n==="y"?{...va(false),[e.kind]:[e.id]}:va(!(n===""||n==="n"))}s(Hq,"runSingleEntityPrompt");async function Gj(t,e,r){if(e.bypass)return vj(t);let n=t.skills.length+t.agents.length+t.commands.length+t.rules.length;if(n===0)return va(false);if(n===1){let a=Wq(t);if(a!==null)return Mj(r,e.packName,t),Hq(r,a)}Mj(r,e.packName,t);let o=(await r.ask("Install [a]ll, [n]one, or [s]elect per type? [a/n/s] ")).trim().toLowerCase();if(o==="a")return vj(t);if(o==="n")return va(false);if(o!=="s")return va(true);let i={skills:[],agents:[],commands:[],rules:[]};for(let a of BI){let{selected:l,aborted:c}=await Kq(r,a,t[a]);if(c)return va(true);i[a]=l;}return {...i,aborted:false}}s(Gj,"runBulkPrompt");ot();function Yq(t,e,r){let n=[];for(let o of Nf(t))o.destination===e&&n.push({offset:o.destinationOffset,length:o.destinationLength,replacement:r});return n}s(Yq,"buildLinkRewrites");function Uj(t,e,r){t.warn(`Broken link in ${e.entityKind} "${e.entityName}": ${r.link.path} (${r.classification})`);}s(Uj,"warnLink");function Xq(t){let e=new Map;for(let n of t){let o=basename(n.resolvedRelative),i=e.get(o)??new Set;i.add(n.resolvedRelative),e.set(o,i);}let r=new Map;for(let[n,o]of e){if(o.size===1){let i=[...o][0];r.set(i,`references/${n}`);continue}for(let i of o){let a=i.replaceAll("/","-");r.set(i,`references/${a}`);}}return r}s(Xq,"allocateSupportingFileNames");function jj(t,e,r){return t.find(n=>n.entityKind===e&&n.entityName===r)}s(jj,"findEntity");async function Zq(t,e,r,n){let o=[...e],i=new Set(o.map(l=>l.relativePath)),a=new Set;for(let l of r){if(a.has(l.resolvedRelative))continue;a.add(l.resolvedRelative);let c=n.get(l.resolvedRelative);if(c===void 0||i.has(c))continue;i.add(c);let m=posix.join(t.replaceAll("\\","/"),l.resolvedRelative);o.push({relativePath:c,absolutePath:m,content:await readFile(m,"utf-8")});}return o}s(Zq,"buildSupportingFiles");async function Qq(t,e,r,n){let o=r.resolved.filter(p=>p.classification==="resolvable-outside"),i=Xq(o),a=await Zq(t,e.supportingFiles,o,i),l=[],c=new Set;for(let p of r.resolved)if(p.classification==="resolvable-outside"){if(c.has(p.link.raw))continue;let u=i.get(p.resolvedRelative);if(u===void 0)continue;c.add(p.link.raw);let f=`./${u}${p.anchor}`;l.push(...Yq(e.body,p.link.raw,f));}else Uj(n,r,p);let m=vG(e.body,l);return {...e,body:m,supportingFiles:a}}s(Qq,"applySkillDecision");async function Bj(t){let{contentRoot:e,aggregate:r,decisions:n,logger:o}=t;if(n.length===0)return r;let i=new Set;for(let l of n)l.entityKind==="skill"&&l.action==="include-resolvable"&&i.add(l.entityName);let a=[];for(let l of r.skills){let c=i.has(l.name)?jj(r.brokenLinks,"skill",l.name):void 0;a.push(c?await Qq(e,l,c,o):l);}for(let l of n){if(l.entityKind==="skill"&&l.action==="include-resolvable")continue;let c=jj(r.brokenLinks,l.entityKind,l.entityName);if(c)for(let m of c.resolved)Uj(o,c,m);}return {...r,skills:a}}s(Bj,"applyBrokenLinkDecisions");var Ac=class extends Error{static{s(this,"InstallAbortError");}aborted=true;constructor(e){super(e),this.name="InstallAbortError";}};function t3(){return {ask:s(t=>Uf(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(t3,"defaultAdapter");function e3(t){return {skills:t.skills.map(e=>e.name),agents:t.agents.map(e=>e.name),commands:t.commands.map(e=>e.name),rules:t.rules.map(e=>ne(e))}}s(e3,"bulkCandidatesFrom");function Kj(t,e){let r=new Set(e.skills),n=new Set(e.agents),o=new Set(e.commands),i=new Set(e.rules);return {skills:t.skills.filter(a=>r.has(a.name)),agents:t.agents.filter(a=>n.has(a.name)),commands:t.commands.filter(a=>o.has(a.name)),rules:t.rules.filter(a=>i.has(ne(a))),mcp:null,permissions:null,hooks:null,ignore:[]}}s(Kj,"filterCanonical");function r3(t){let e=[];return t.skills.length>0&&e.push("skills"),t.rules.length>0&&e.push("rules"),t.commands.length>0&&e.push("commands"),t.agents.length>0&&e.push("agents"),e}s(r3,"discoveredFeaturesOf");async function n3(t){let e=t.adapter??t3(),r=await Fj(t.aggregate.brokenLinks,{bypass:t.bypass},e);if(r.aborted)throw new Ac("User aborted at broken-link prompt.");let n=[...r.decisions],o=await Bj({contentRoot:t.contentRoot,aggregate:t.aggregate,decisions:n,logger:y}),i=e3(o);if(i.skills.length+i.agents.length+i.commands.length+i.rules.length===0)return {aggregate:o,narrowed:Kj(o,{skills:[],agents:[],commands:[],rules:[]}),discoveredFeatures:[]};let l=await Gj(i,{packName:t.displayName,bypass:t.bypass},e);if(l.aborted)throw new Ac("User aborted at bulk-select prompt.");let c=Kj(o,l);return {aggregate:o,narrowed:c,discoveredFeatures:r3(c)}}s(n3,"runSkillPackPromptFlow");function o3(t){return basename(t)||"install source"}s(o3,"displayNameForContentRoot");async function Wj(t){if(!t.discovery.aggregate)return {aborted:false};try{let e=await n3({contentRoot:t.contentRoot,aggregate:t.discovery.aggregate,narrowed:t.discovery.narrowed,bypass:t.bypass,displayName:o3(t.contentRoot)});return {aborted:!1,narrowed:e.narrowed,discoveredFeatures:e.discoveredFeatures}}catch(e){if(e instanceof Ac)return y.warn(e.message),{aborted:true};throw e}}s(Wj,"runPromptFlowWithAbort");async function Hj(t){let{discovery:e,installReport:r,persisted:n,parsed:o,sourceForYaml:i,version:a,pathInRepo:l,contentRoot:c,config:m,context:p,dryRun:u,force:f,useExtends:g,explicitAs:h,nameOverride:R,scope:C,sourceArg:S,replay:k}=t,P=process.stdin.isTTY,{prep:N,implicitPick:F}=e,{narrowed:W,discoveredFeatures:z}=e;try{let Q=await Wj({discovery:e,contentRoot:c,bypass:f||u||!P});if(Q.aborted)return {exitCode:130,data:{source:S,mode:"install",installed:[],skipped:[],dryRun:u}};if(W=Q.narrowed??W,z=Q.discoveredFeatures??z,z.length===0&&r.brokenResources.length>0){let At=r.brokenResources.map(wt=>` - ${wt.path}: ${wt.reason}`).join(`
354
+ `);}s(Bj,"writeBanner");async function s3(t,e,r){if(r.length===0)return {selected:[],aborted:false};let n=Kj[e],o=(await t.ask(`Install all ${r.length} ${n}? [y/n/c] `)).trim().toLowerCase();if(o==="y")return {selected:[...r],aborted:false};if(o==="n")return {selected:[],aborted:false};if(o!=="c")return {selected:[],aborted:true};let i=YI[e],a=[];for(let l=0;l<r.length;l++){let c=r[l],m=(await t.ask(`Install ${i} "${c}"? [y/N/a/q] `)).trim().toLowerCase();if(m==="y"){a.push(c);continue}if(!(m===""||m==="n")){if(m==="a"){for(let p=l;p<r.length;p++)a.push(r[p]);return {selected:a,aborted:false}}return m==="q"?{selected:a,aborted:false}:{selected:[],aborted:true}}}return {selected:a,aborted:false}}s(s3,"walkType");function i3(t){let e=null;for(let r of JI)for(let n of t[r]){if(e!==null)return null;e={kind:r,id:n};}return e}s(i3,"findSingleEntity");async function a3(t,e){let r=YI[e.kind],n=(await t.ask(`Install ${r} "${e.id}"? [y/N] `)).trim().toLowerCase();return n==="y"?{...$a(false),[e.kind]:[e.id]}:$a(!(n===""||n==="n"))}s(a3,"runSingleEntityPrompt");async function Wj(t,e,r){if(e.bypass)return Uj(t);let n=t.skills.length+t.agents.length+t.commands.length+t.rules.length;if(n===0)return $a(false);if(n===1){let a=i3(t);if(a!==null)return Bj(r,e.packName,t),a3(r,a)}Bj(r,e.packName,t);let o=(await r.ask("Install [a]ll, [n]one, or [s]elect per type? [a/n/s] ")).trim().toLowerCase();if(o==="a")return Uj(t);if(o==="n")return $a(false);if(o!=="s")return $a(true);let i={skills:[],agents:[],commands:[],rules:[]};for(let a of JI){let{selected:l,aborted:c}=await s3(r,a,t[a]);if(c)return $a(true);i[a]=l;}return {...i,aborted:false}}s(Wj,"runBulkPrompt");st();function p3(t,e,r){let n=[];for(let o of Vf(t))o.destination===e&&n.push({offset:o.destinationOffset,length:o.destinationLength,replacement:r});return n}s(p3,"buildLinkRewrites");function zj(t,e,r){t.warn(`Broken link in ${e.entityKind} "${e.entityName}": ${r.link.path} (${r.classification})`);}s(zj,"warnLink");function u3(t){let e=new Map;for(let n of t){let o=basename(n.resolvedRelative),i=e.get(o)??new Set;i.add(n.resolvedRelative),e.set(o,i);}let r=new Map;for(let[n,o]of e){if(o.size===1){let i=[...o][0];r.set(i,`references/${n}`);continue}for(let i of o){let a=i.replaceAll("/","-");r.set(i,`references/${a}`);}}return r}s(u3,"allocateSupportingFileNames");function Hj(t,e,r){return t.find(n=>n.entityKind===e&&n.entityName===r)}s(Hj,"findEntity");async function d3(t,e,r,n){let o=[...e],i=new Set(o.map(l=>l.relativePath)),a=new Set;for(let l of r){if(a.has(l.resolvedRelative))continue;a.add(l.resolvedRelative);let c=n.get(l.resolvedRelative);if(c===void 0||i.has(c))continue;i.add(c);let m=posix.join(t.replaceAll("\\","/"),l.resolvedRelative);o.push({relativePath:c,absolutePath:m,content:await readFile(m,"utf-8")});}return o}s(d3,"buildSupportingFiles");async function f3(t,e,r,n){let o=r.resolved.filter(p=>p.classification==="resolvable-outside"),i=u3(o),a=await d3(t,e.supportingFiles,o,i),l=[],c=new Set;for(let p of r.resolved)if(p.classification==="resolvable-outside"){if(c.has(p.link.raw))continue;let u=i.get(p.resolvedRelative);if(u===void 0)continue;c.add(p.link.raw);let f=`./${u}${p.anchor}`;l.push(...p3(e.body,p.link.raw,f));}else zj(n,r,p);let m=BG(e.body,l);return {...e,body:m,supportingFiles:a}}s(f3,"applySkillDecision");async function Vj(t){let{contentRoot:e,aggregate:r,decisions:n,logger:o}=t;if(n.length===0)return r;let i=new Set;for(let l of n)l.entityKind==="skill"&&l.action==="include-resolvable"&&i.add(l.entityName);let a=[];for(let l of r.skills){let c=i.has(l.name)?Hj(r.brokenLinks,"skill",l.name):void 0;a.push(c?await f3(e,l,c,o):l);}for(let l of n){if(l.entityKind==="skill"&&l.action==="include-resolvable")continue;let c=Hj(r.brokenLinks,l.entityKind,l.entityName);if(c)for(let m of c.resolved)zj(o,c,m);}return {...r,skills:a}}s(Vj,"applyBrokenLinkDecisions");var Tc=class extends Error{static{s(this,"InstallAbortError");}aborted=true;constructor(e){super(e),this.name="InstallAbortError";}};function h3(){return {ask:s(t=>Pc(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(h3,"defaultAdapter");function y3(t){return {skills:t.skills.map(e=>e.name),agents:t.agents.map(e=>e.name),commands:t.commands.map(e=>e.name),rules:t.rules.map(e=>se(e))}}s(y3,"bulkCandidatesFrom");function Jj(t,e){let r=new Set(e.skills),n=new Set(e.agents),o=new Set(e.commands),i=new Set(e.rules);return {skills:t.skills.filter(a=>r.has(a.name)),agents:t.agents.filter(a=>n.has(a.name)),commands:t.commands.filter(a=>o.has(a.name)),rules:t.rules.filter(a=>i.has(se(a))),mcp:null,permissions:null,hooks:null,ignore:[]}}s(Jj,"filterCanonical");function _3(t){let e=[];return t.skills.length>0&&e.push("skills"),t.rules.length>0&&e.push("rules"),t.commands.length>0&&e.push("commands"),t.agents.length>0&&e.push("agents"),e}s(_3,"discoveredFeaturesOf");async function R3(t){let e=t.adapter??h3(),r=await jj(t.aggregate.brokenLinks,{bypass:t.bypass},e);if(r.aborted)throw new Tc("User aborted at broken-link prompt.");let n=[...r.decisions],o=await Vj({contentRoot:t.contentRoot,aggregate:t.aggregate,decisions:n,logger:y}),i=y3(o);if(i.skills.length+i.agents.length+i.commands.length+i.rules.length===0)return {aggregate:o,narrowed:Jj(o,{skills:[],agents:[],commands:[],rules:[]}),discoveredFeatures:[]};let l=await Wj(i,{packName:t.displayName,bypass:t.bypass},e);if(l.aborted)throw new Tc("User aborted at bulk-select prompt.");let c=Jj(o,l);return {aggregate:o,narrowed:c,discoveredFeatures:_3(c)}}s(R3,"runSkillPackPromptFlow");function I3(t){return basename(t)||"install source"}s(I3,"displayNameForContentRoot");async function Yj(t){if(!t.discovery.aggregate)return {aborted:false};try{let e=await R3({contentRoot:t.contentRoot,aggregate:t.discovery.aggregate,narrowed:t.discovery.narrowed,bypass:t.bypass,displayName:I3(t.contentRoot)});return {aborted:!1,narrowed:e.narrowed,discoveredFeatures:e.discoveredFeatures}}catch(e){if(e instanceof Tc)return y.warn(e.message),{aborted:true};throw e}}s(Yj,"runPromptFlowWithAbort");async function Xj(t){let{discovery:e,installReport:r,persisted:n,parsed:o,sourceForYaml:i,version:a,pathInRepo:l,contentRoot:c,config:m,context:p,dryRun:u,force:f,useExtends:g,forceFreshMaterialize:h,explicitAs:I,nameOverride:k,scope:C,sourceArg:R,replay:P}=t,N=process.stdin.isTTY,{prep:F,implicitPick:B}=e,{narrowed:U,discoveredFeatures:q}=e;try{let nt=await Yj({discovery:e,contentRoot:c,bypass:f||u||!N});if(nt.aborted)return {exitCode:130,data:{source:R,mode:"install",installed:[],skipped:[],dryRun:u}};if(U=nt.narrowed??U,q=nt.discoveredFeatures??q,q.length===0&&r.brokenResources.length>0){let tt=r.brokenResources.map(Nt=>` - ${Nt.path}: ${Nt.reason}`).join(`
353
355
  `);throw new Error(`No installable resources after skipping invalid files (${r.brokenResources.length}):
354
- ${At}
355
- Fix the frontmatter in the source files (most often: unquoted scalars containing colons or square brackets), or narrow --path to a subdirectory that excludes them.`)}let at=await xj({scope:C,force:f,dryRun:u,tty:P,useExtends:g,nameOverride:R,explicitAs:h,config:m,context:p,parsed:o,sourceForYaml:i,version:a,pathInRepo:l,contentRoot:c,persisted:n,replay:k,prep:N,implicitPick:F,narrowed:W,discoveredFeatures:z,sourceType:e.layout?WG(e.layout):void 0});return {exitCode:0,data:{source:S,mode:"install",installed:at.installed,skipped:at.skipped,dryRun:u,...r.brokenResources.length>0?{brokenResources:r.brokenResources}:{}}}}finally{N.cleanup&&await N.cleanup();}}s(Hj,"runSinglePackInstall");async function zj(t,e,r){let n=[],o=[],i=0;for(let a of t)try{let l=await e(a);n.push(...l.installed),o.push(...l.skipped),i+=1;}catch(l){let c=l instanceof Error?l.message:String(l);r.subPackFailures.push({name:a.name,path:a.path??".",error:c});}return {exitCode:i>0?0:1,installed:n,skipped:o}}s(zj,"runInstallMarketplace");async function Vj(t){let{pickerResult:e,installReport:r,sourceArg:n,projectRoot:o,dryRun:i,force:a,useExtends:l,nameOverride:c,replay:m,recurseInstall:p}=t;if(e.isMarketplace&&e.targets.length>0){let u=await zj(e.targets,async f=>(await p({force:!0,"dry-run":i,path:f.path??"",target:f.target??"",name:f.name,extends:l},[n],o,{})).data,r);return {exitCode:u.exitCode,data:{source:n,mode:"install",installed:u.installed,skipped:u.skipped,dryRun:i,...r.brokenResources.length>0?{brokenResources:r.brokenResources}:{}}}}if(!e.isMarketplace&&e.targets.length===1){let u=e.targets[0];return p({force:a,"dry-run":i,path:u.path??"",as:u.as??"",target:u.target??"",name:c,extends:l},[n],o,m??{})}return null}s(Vj,"routePickerResult");Yt();w();ot();async function i3(t){let e=await ho(t.canonicalDir);if(e.length===0){y.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let n of e){let o=join(t.canonicalDir,"packs",n.name);await $(o)||r.push(n);}if(r.length===0){y.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);y.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(i3,"syncInstalledPacks");async function Jj(t){return t.sync?(await i3({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(Jj,"maybeRunInstallSync");async function Yj(t){let{projectRoot:e,sync:r,dryRun:n,force:o,scope:i,recurseInstall:a}=t;if(!r)return;let{context:l}=await yt(e,i),c=[],m=[];if(await Jj({sync:r,canonicalDir:l.canonicalDir,reinstall:s(async u=>{let f=u.paths&&u.paths.length>0?u.paths:[u.path];for(let g of f){let h=await a({...o?{force:true}:{},...n?{"dry-run":true}:{},...i==="global"?{global:true}:{},name:u.name,...u.target?{target:u.target}:{},...g?{path:g}:{},...u.as?{as:u.as}:{}},[u.source],e,{features:u.features,pick:u.pick});c.push(...h.data.installed),m.push(...h.data.skipped);}},"reinstall")}))return {exitCode:0,data:{source:"",mode:"sync",installed:c,skipped:m,dryRun:n}}}s(Yj,"handleSync");function Xj(){return {brokenResources:[],subPackFailures:[]}}s(Xj,"createInstallReport");function c3(t,e){if(!t)return;let r=normalize(t).replace(/\\/g,"/");if(r===".."||r.startsWith("../"))throw new Error(`Install --path "${e}" escapes the source root. Path must stay within the source.`)}s(c3,"assertPathStaysInRepo");async function Zj(t){let e=await Yj(t);if(e)return e;let{projectRoot:r,replay:n,dryRun:o,force:i,useExtends:a,all:l,explicitPath:c,explicitTarget:m,explicitAs:p,nameOverride:u,scope:f,sourceArg:g}=t;if(!g)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let h=process.stdin.isTTY;if(!h&&!i&&!o)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:R,context:C}=await yt(r,f);await Wt(R,r);let S=await EI(g,C.configDir,c);if(S.kind!=="local"&&!await z$())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:k,sourceForYaml:P,version:N}=await Y$(S,g),F=S.pathInRepo.replaceAll("\\","/").replace(/^\/+|\/+$/g,"");c3(F,S.pathInRepo);let W=F?join(k,F):k;if(!await $(W))throw new Error(`Install path does not exist: ${W}`);let z=await ZG({as:p,contentRoot:W,pathInRepo:F}),Q=Xj(),at={onParseError:s((wt,oe)=>{Q.brokenResources.push({path:oe,kind:"frontmatter",reason:wt.message});},"onParseError")},At=await HG({resolvedPath:k,contentRoot:W,pathInRepo:F,explicitTarget:m,explicitAs:p,replayPick:n?.pick,parseOpts:at});if(At.layout&&!p&&!m&&!c){let wt=YG({layout:At.layout,sourceName:u||(S.org&&S.repo?`${S.org}-${S.repo}`:"source"),sourceForYaml:P,explicitPath:c,explicitAs:p,explicitTarget:m,all:l,force:i,tty:h}),oe=await Vj({pickerResult:wt,installReport:Q,sourceArg:g,projectRoot:r,dryRun:o,force:i,useExtends:a,nameOverride:u,replay:n,recurseInstall:t.recurseInstall});if(oe!==null)return oe}return Hj({discovery:At,installReport:Q,persisted:z,parsed:S,sourceForYaml:P,version:N,pathInRepo:F,contentRoot:W,config:R,context:C,dryRun:o,force:i,useExtends:a,explicitAs:p,nameOverride:u,scope:f,sourceArg:g,replay:n})}s(Zj,"runInstallLocked");async function _p(t,e,r,n){let{sync:o,dryRun:i,force:a,useExtends:l,all:c,explicitPath:m,explicitTarget:p,explicitAs:u,nameOverride:f}=H$(t),g=t.global===true?"global":"project",h=e[0]?.trim(),R;if(n===void 0){let{context:C}=await yt(r,g);R=await wf(C.canonicalDir);}try{return await Zj({args:e,projectRoot:r,replay:n,sync:o,dryRun:i,force:a,useExtends:l,all:c,explicitPath:m,explicitTarget:p,explicitAs:u,nameOverride:f,scope:g,sourceArg:h,recurseInstall:_p})}finally{await R?.();}}s(_p,"runInstall");async function Qj(t,e,r){return _p(t,e,r)}s(Qj,"runInstall");ot();function qj(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 n=[...new Set(e.installed.map(o=>o.kind))].map(o=>{let i=e.installed.filter(a=>a.kind===o).length;return `${i} ${o}${i>1?"s":""}`}).join(", ");y.success(`Installed ${n}.`);}if(e.skipped.length>0)for(let r of e.skipped)y.warn(`Skipped ${r.kind} "${r.name}": ${r.reason}`);if(e.brokenResources&&e.brokenResources.length>0){let r=e.brokenResources.length;y.warn(`Skipped ${r} file${r>1?"s":""} with invalid frontmatter; see --json for details.`);}}}s(qj,"renderInstall");Yt();fn();ot();function tU(t){let e=new Set,r=new Set;for(let n of t)e.has(n)?r.add(n):e.add(n);return [...r]}s(tU,"detectDuplicates");function Bf(t,e,r,n){let o=[];r.keepGenerated&&o.push(`--keep-generated: target trees will not be re-rendered; generated files derived from "${t}" may remain stale until the next generate.`);let i=r.keepPack||e===null?null:join(r.packsDir,t);return {name:t,packDir:i,manifestEntry:e,extendsEntry:n.get(t)??null,removeGenerated:!r.keepGenerated,warnings:o}}s(Bf,"buildPlan");function eU(t){if(!t.all&&t.names.length===0)throw new Error("uninstall: must provide at least one name or pass --all.");let e=new Map;for(let a of t.extends)e.has(a.name)||e.set(a.name,a);let r=new Map;for(let a of t.installs)r.set(a.name,a);if(t.all){let a=t.installs.map(m=>m.name),l=tU(a);if(l.length>0)throw new Error(`uninstall --all: installs.yaml has duplicate names: ${l.join(", ")}. Manifest is corrupt; remove the duplicates before retrying.`);let c=t.installs.map(m=>Bf(m.name,m,t,e));for(let m of t.extends)r.has(m.name)||c.push(Bf(m.name,null,t,e));return {removals:c,skipped:[]}}let n=tU(t.names);if(n.length>0)throw new Error(`uninstall: duplicate names requested: ${n.join(", ")}.`);let o=[],i=[];for(let a of t.names){let l=r.get(a);if(l!==void 0){o.push(Bf(a,l,t,e));continue}if(e.has(a)){o.push(Bf(a,null,t,e));continue}i.push(a);}return {removals:o,skipped:i}}s(eU,"planUninstall");w();w();fc();async function rU(t,e){let r=join(t,hn);if(await $(r))return null;let n=await fi(t);if(n===null)throw new Error(`Cannot migrate legacy pack at ${t}: pack.yaml is missing or invalid; cannot recover install provenance.`);let o=await Gf(t),i={name:n.name,source:n.source,installed_at:n.installed_at,extends_id:null,source_type:null,files:o};return e.dryRun!==true&&await I(r,`${JSON.stringify(i,null,2)}
356
- `),e.warn(`Legacy pack "${n.name}" detected; generated baseline install manifest from current contents. Local modifications since install cannot be detected.`),{manifest:i,manifestPath:r}}s(rU,"migrateLegacyManifest");w();var d3=["pack.yaml",hn];function f3(t,e){return relative(t,e).replaceAll("\\","/")}s(f3,"toForwardSlashRelative");async function nU(t,e){let r=await Ya(t),n=new Map;for(let i of r){let a=f3(t,i);d3.includes(a)||n.set(a,i);}let o=[];for(let[i,a]of Object.entries(e)){let l=n.get(i);if(l===void 0){o.push({relativePath:i,status:"deleted"});continue}let c=await cf(l);if(c===null){o.push({relativePath:i,status:"deleted"});continue}`sha256:${c}`!==a&&o.push({relativePath:i,status:"modified"});}for(let i of n.keys())i in e||o.push({relativePath:i,status:"added"});return o.sort((i,a)=>i.relativePath<a.relativePath?-1:i.relativePath>a.relativePath?1:0),o}s(nU,"detectModifiedFiles");function oU(t,e){let r=e.modifications.length,n=r===1?"file":"files",o=[`Pack "${e.packName}" has ${r} locally modified ${n}:`];for(let i of e.modifications)o.push(` - ${i.relativePath} (${i.status})`);o.push(""),t.write(`${o.join(`
356
+ ${tt}
357
+ Fix the frontmatter in the source files (most often: unquoted scalars containing colons or square brackets), or narrow --path to a subdirectory that excludes them.`)}let M=await Mj({scope:C,force:f,dryRun:u,tty:N,useExtends:g,forceFreshMaterialize:h,nameOverride:k,explicitAs:I,config:m,context:p,parsed:o,sourceForYaml:i,version:a,pathInRepo:l,contentRoot:c,persisted:n,replay:P,prep:F,implicitPick:B,narrowed:U,discoveredFeatures:q,sourceType:e.layout?XG(e.layout):void 0});return {exitCode:0,data:{source:R,mode:"install",installed:M.installed,skipped:M.skipped,dryRun:u,...r.brokenResources.length>0?{brokenResources:r.brokenResources}:{}}}}finally{F.cleanup&&await F.cleanup();}}s(Xj,"runSinglePackInstall");async function Zj(t,e,r){let n=[],o=[],i=0;for(let a of t)try{let l=await e(a);n.push(...l.installed),o.push(...l.skipped),i+=1;}catch(l){let c=l instanceof Error?l.message:String(l);r.subPackFailures.push({name:a.name,path:a.path??".",error:c});}return {exitCode:i>0?0:1,installed:n,skipped:o}}s(Zj,"runInstallMarketplace");async function Qj(t){let{pickerResult:e,installReport:r,sourceArg:n,projectRoot:o,dryRun:i,force:a,useExtends:l,nameOverride:c,replay:m,recurseInstall:p}=t;if(e.isMarketplace&&e.targets.length>0){let u=await Zj(e.targets,async f=>(await p({force:!0,"dry-run":i,path:f.path??"",target:f.target??"",name:f.name,extends:l},[n],o,{})).data,r);return {exitCode:u.exitCode,data:{source:n,mode:"install",installed:u.installed,skipped:u.skipped,dryRun:i,...r.brokenResources.length>0?{brokenResources:r.brokenResources}:{}}}}if(!e.isMarketplace&&e.targets.length===1){let u=e.targets[0];return p({force:a,"dry-run":i,path:u.path??"",as:u.as??"",target:u.target??"",name:c,extends:l},[n],o,m??{})}return null}s(Qj,"routePickerResult");Zt();A();st();async function C3(t){let e=await xe(t.canonicalDir);if(e.length===0){y.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let n of e){let o=join(t.canonicalDir,"packs",n.name);await j(o)||r.push(n);}if(r.length===0){y.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);y.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(C3,"syncInstalledPacks");async function qj(t){return t.sync?(await C3({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(qj,"maybeRunInstallSync");async function tU(t){let{projectRoot:e,sync:r,dryRun:n,force:o,scope:i,recurseInstall:a}=t;if(!r)return;let{context:l}=await yt(e,i),c=[],m=[];if(await qj({sync:r,canonicalDir:l.canonicalDir,reinstall:s(async u=>{let f=u.paths&&u.paths.length>0?u.paths:[u.path];for(let g of f){let h=await a({...o?{force:true}:{},...n?{"dry-run":true}:{},...i==="global"?{global:true}:{},name:u.name,...u.target?{target:u.target}:{},...g?{path:g}:{},...u.as?{as:u.as}:{}},[u.source],e,{features:u.features,pick:u.pick});c.push(...h.data.installed),m.push(...h.data.skipped);}},"reinstall")}))return {exitCode:0,data:{source:"",mode:"sync",installed:c,skipped:m,dryRun:n}}}s(tU,"handleSync");function eU(){return {brokenResources:[],subPackFailures:[]}}s(eU,"createInstallReport");function L3(t,e){if(!t)return;let r=normalize(t).replace(/\\/g,"/");if(r===".."||r.startsWith("../"))throw new Error(`Install --path "${e}" escapes the source root. Path must stay within the source.`)}s(L3,"assertPathStaysInRepo");async function rU(t){let e=await tU(t);if(e)return e;let{projectRoot:r,replay:n,dryRun:o,force:i,useExtends:a,all:l,forceFreshMaterialize:c,explicitPath:m,explicitTarget:p,explicitAs:u,nameOverride:f,scope:g,sourceArg:h}=t;if(!h)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let I=process.stdin.isTTY;if(!I&&!i&&!o)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:k,context:C}=await yt(r,g);await Gt(k,r);let R=await PI(h,C.configDir,m);if(R.kind!=="local"&&!await q$())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:P,sourceForYaml:N,version:F}=await eG(R,h),B=R.pathInRepo.replaceAll("\\","/").replace(/^\/+|\/+$/g,"");L3(B,R.pathInRepo);let U=B?join(P,B):P;if(!await j(U))throw new Error(`Install path does not exist: ${U}`);let q=await nj({as:u,contentRoot:U,pathInRepo:B}),nt=eU(),M={onParseError:s((Nt,Le)=>{nt.brokenResources.push({path:Le,kind:"frontmatter",reason:Nt.message});},"onParseError")},tt=await ZG({resolvedPath:P,contentRoot:U,pathInRepo:B,explicitTarget:p,explicitAs:u,replayPick:n?.pick,parseOpts:M});if(tt.layout&&!u&&!p&&!m){let Nt=ej({layout:tt.layout,sourceName:f||(R.org&&R.repo?`${R.org}-${R.repo}`:"source"),sourceForYaml:N,explicitPath:m,explicitAs:u,explicitTarget:p,all:l,force:i,tty:I}),Le=await Qj({pickerResult:Nt,installReport:nt,sourceArg:h,projectRoot:r,dryRun:o,force:i,useExtends:a,nameOverride:f,replay:n,recurseInstall:t.recurseInstall});if(Le!==null)return Le}return Xj({discovery:tt,installReport:nt,persisted:q,parsed:R,sourceForYaml:N,version:F,pathInRepo:B,contentRoot:U,config:k,context:C,dryRun:o,force:i,useExtends:a,forceFreshMaterialize:c,explicitAs:u,nameOverride:f,scope:g,sourceArg:h,replay:n})}s(rU,"runInstallLocked");async function Ga(t,e,r,n){let{sync:o,dryRun:i,force:a,useExtends:l,all:c,forceFreshMaterialize:m,explicitPath:p,explicitTarget:u,explicitAs:f,nameOverride:g}=Q$(t),h=t.global===true?"global":"project",I=e[0]?.trim(),k;if(n===void 0){let{context:C}=await yt(r,h);k=await Cc(C.canonicalDir);}try{return await rU({args:e,projectRoot:r,replay:n,sync:o,dryRun:i,force:a,useExtends:l,all:c,forceFreshMaterialize:m,explicitPath:p,explicitTarget:u,explicitAs:f,nameOverride:g,scope:h,sourceArg:I,recurseInstall:Ga})}finally{await k?.();}}s(Ga,"runInstall");async function nU(t,e,r){return Ga(t,e,r)}s(nU,"runInstall");st();function oU(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 n=[...new Set(e.installed.map(o=>o.kind))].map(o=>{let i=e.installed.filter(a=>a.kind===o).length;return `${i} ${o}${i>1?"s":""}`}).join(", ");y.success(`Installed ${n}.`);}if(e.skipped.length>0)for(let r of e.skipped)y.warn(`Skipped ${r.kind} "${r.name}": ${r.reason}`);if(e.brokenResources&&e.brokenResources.length>0){let r=e.brokenResources.length;y.warn(`Skipped ${r} file${r>1?"s":""} with invalid frontmatter; see --json for details.`);}}}s(oU,"renderInstall");Zt();Mr();st();function sU(t){let e=new Set,r=new Set;for(let n of t)e.has(n)?r.add(n):e.add(n);return [...r]}s(sU,"detectDuplicates");function tg(t,e,r,n){let o=[];r.keepGenerated&&o.push(`--keep-generated: target trees will not be re-rendered; generated files derived from "${t}" may remain stale until the next generate.`);let i=r.keepPack||e===null?null:join(r.packsDir,t);return {name:t,packDir:i,manifestEntry:e,extendsEntry:n.get(t)??null,removeGenerated:!r.keepGenerated,warnings:o}}s(tg,"buildPlan");function iU(t){if(!t.all&&t.names.length===0)throw new Error("uninstall: must provide at least one name or pass --all.");let e=new Map;for(let a of t.extends)e.has(a.name)||e.set(a.name,a);let r=new Map;for(let a of t.installs)r.set(a.name,a);if(t.all){let a=t.installs.map(m=>m.name),l=sU(a);if(l.length>0)throw new Error(`uninstall --all: installs.yaml has duplicate names: ${l.join(", ")}. Manifest is corrupt; remove the duplicates before retrying.`);let c=t.installs.map(m=>tg(m.name,m,t,e));for(let m of t.extends)r.has(m.name)||c.push(tg(m.name,null,t,e));return {removals:c,skipped:[]}}let n=sU(t.names);if(n.length>0)throw new Error(`uninstall: duplicate names requested: ${n.join(", ")}.`);let o=[],i=[];for(let a of t.names){let l=r.get(a);if(l!==void 0){o.push(tg(a,l,t,e));continue}if(e.has(a)){o.push(tg(a,null,t,e));continue}i.push(a);}return {removals:o,skipped:i}}s(iU,"planUninstall");A();A();gc();async function aU(t,e){let r=join(t,tr);if(await j(r))return null;let n=await gi(t);if(n===null)throw new Error(`Cannot migrate legacy pack at ${t}: pack.yaml is missing or invalid; cannot recover install provenance.`);let o=await Zf(t),i={name:n.name,source:n.source,installed_at:n.installed_at,extends_id:null,source_type:null,files:o};return e.dryRun!==true&&await S(r,`${JSON.stringify(i,null,2)}
358
+ `),e.warn(`Legacy pack "${n.name}" detected; generated baseline install manifest from current contents. Local modifications since install cannot be detected.`),{manifest:i,manifestPath:r}}s(aU,"migrateLegacyManifest");A();var b3=["pack.yaml",tr];function P3(t,e){return relative(t,e).replaceAll("\\","/")}s(P3,"toForwardSlashRelative");async function eg(t,e){let r=await Xa(t),n=new Map;for(let i of r){let a=P3(t,i);b3.includes(a)||n.set(a,i);}let o=[];for(let[i,a]of Object.entries(e)){let l=n.get(i);if(l===void 0){o.push({relativePath:i,status:"deleted"});continue}let c=await Cf(l);if(c===null){o.push({relativePath:i,status:"deleted"});continue}`sha256:${c}`!==a&&o.push({relativePath:i,status:"modified"});}for(let i of n.keys())i in e||o.push({relativePath:i,status:"added"});return o.sort((i,a)=>i.relativePath<a.relativePath?-1:i.relativePath>a.relativePath?1:0),o}s(eg,"detectModifiedFiles");function lU(t,e){let r=e.modifications.length,n=r===1?"file":"files",o=[`Pack "${e.packName}" has ${r} locally modified ${n}:`];for(let i of e.modifications)o.push(` - ${i.relativePath} (${i.status})`);o.push(""),t.write(`${o.join(`
357
359
  `)}
358
- `);}s(oU,"writeBanner");async function sU(t,e,r){if(t.modifications.length===0)return {action:"proceed"};if(e.bypass)return oU(r,t),{action:"delete-anyway"};oU(r,t);let n=(await r.ask("Action: [d]elete anyway / [k]eep modified files (uninstall the rest) / [a]bort ")).trim().toLowerCase();return n==="d"?{action:"delete-anyway"}:n==="k"?{action:"keep-modified"}:{action:"abort"}}s(sU,"runModifiedFilesPrompt");async function g3(t){let e=await _(join(t,hn));if(e===null)return null;try{return JSON.parse(e).files??{}}catch{return null}}s(g3,"readManifestFiles");async function h3(t,e,r){if(t.manifestEntry===null)return {plan:t,modifications:[],action:"proceed",legacyMigrated:false,packDirMissing:false};let n=join(e,t.name);if(!await $(n))return r.warn(`Pack "${t.name}" directory missing at ${n}; only manifest entries will be removed.`),{plan:t,modifications:[],action:"proceed",legacyMigrated:false,packDirMissing:true};let o=await rU(n,{warn:r.warn,dryRun:r.dryRun===true}),i=o!==null,a=o!==null&&r.dryRun===true?o.manifest.files:await g3(n);if(a===null)return {plan:t,modifications:[],action:"proceed",legacyMigrated:i,packDirMissing:false};let l=await nU(n,a);if(r.keepPack||l.length===0)return {plan:t,modifications:l,action:"proceed",legacyMigrated:i,packDirMissing:false};let c=await sU({packName:t.name,modifications:l},{bypass:r.bypassPrompts},r.adapter);return c.action==="abort"?"abort":{plan:t,modifications:l,action:c.action,legacyMigrated:i,packDirMissing:false}}s(h3,"decideOne");async function aU(t,e,r){let n=[];for(let o of t){let i=await h3(o,e,r);if(i==="abort")return {decisions:n,aborted:true};n.push(i);}return {decisions:n,aborted:false}}s(aU,"gatherUninstallDecisions");w();w();async function lU(t,e,r){if(!e.extends.some(c=>c.name===r))return false;let n=await _(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=Array.isArray(o.extends)?o.extends:[],a=i.filter(c=>typeof c!="object"||c===null?true:c.name!==r);if(a.length===i.length)return false;o.extends=a;let l=stringify(o,{indent:2,lineWidth:0});return await I(t,l.endsWith(`
360
+ `);}s(lU,"writeBanner");async function cU(t,e,r){if(t.modifications.length===0)return {action:"proceed"};if(e.bypass)return lU(r,t),{action:"delete-anyway"};lU(r,t);let n=(await r.ask("Action: [d]elete anyway / [k]eep modified files (uninstall the rest) / [a]bort ")).trim().toLowerCase();return n==="d"?{action:"delete-anyway"}:n==="k"?{action:"keep-modified"}:{action:"abort"}}s(cU,"runModifiedFilesPrompt");async function T3(t){let e=await _(join(t,tr));if(e===null)return null;try{return JSON.parse(e).files??{}}catch{return null}}s(T3,"readManifestFiles");async function x3(t,e,r){if(t.manifestEntry===null)return {plan:t,modifications:[],action:"proceed",legacyMigrated:false,packDirMissing:false};let n=join(e,t.name);if(!await j(n))return r.warn(`Pack "${t.name}" directory missing at ${n}; only manifest entries will be removed.`),{plan:t,modifications:[],action:"proceed",legacyMigrated:false,packDirMissing:true};let o=await aU(n,{warn:r.warn,dryRun:r.dryRun===true}),i=o!==null,a=o!==null&&r.dryRun===true?o.manifest.files:await T3(n);if(a===null)return {plan:t,modifications:[],action:"proceed",legacyMigrated:i,packDirMissing:false};let l=await eg(n,a);if(r.keepPack||l.length===0)return {plan:t,modifications:l,action:"proceed",legacyMigrated:i,packDirMissing:false};let c=await cU({packName:t.name,modifications:l},{bypass:r.bypassPrompts},r.adapter);return c.action==="abort"?"abort":{plan:t,modifications:l,action:c.action,legacyMigrated:i,packDirMissing:false}}s(x3,"decideOne");async function pU(t,e,r){let n=[];for(let o of t){let i=await x3(o,e,r);if(i==="abort")return {decisions:n,aborted:true};n.push(i);}return {decisions:n,aborted:false}}s(pU,"gatherUninstallDecisions");A();A();async function uU(t,e,r){if(!e.extends.some(c=>c.name===r))return false;let n=await _(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=Array.isArray(o.extends)?o.extends:[],a=i.filter(c=>typeof c!="object"||c===null?true:c.name!==r);if(a.length===i.length)return false;o.extends=a;let l=stringify(o,{indent:2,lineWidth:0});return await S(t,l.endsWith(`
359
361
  `)?l:`${l}
360
- `),true}s(lU,"removeAgentsmeshExtendByName");async function cU(t){let{plan:e,canonicalDir:r,configPath:n,config:o}=t,i=false;e.packDir!==null&&await $(e.packDir)&&(await rm(e.packDir,{recursive:true}),i=true);let a=await Oj(r,e.name),l=false;e.extendsEntry!==null&&(l=await lU(n,o,e.name));let c=e.packDir!==null,m=e.manifestEntry!==null,p=e.extendsEntry!==null,u=c&&!i||m&&!a||p&&!l;return {name:e.name,packDirRemoved:i,manifestEntryRemoved:a,extendsEntryRemoved:l,partial:u}}s(cU,"applyUninstall");function C3(t,e){return relative(t,e).replaceAll("\\","/")}s(C3,"toForwardSlashRel");function WI(t){return t.map(e=>({name:e,reason:"not found in installs.yaml"}))}s(WI,"buildSkipped");function mU(t,e,r){return t.plan.manifestEntry===null?null:C3(e,join(r,t.plan.name))}s(mU,"packPathFor");function pU(t,e,r){return t.map(n=>({name:n.plan.name,pack_path:mU(n,e,r),manifest_entry_removed:false,extends_entry_removed:false,generated_files_removed:0,modified_files_kept:n.modifications.map(o=>({relativePath:o.relativePath,status:o.status})),legacy_migrated:n.legacyMigrated,partial:n.action==="keep-modified"||n.plan.packDir===null}))}s(pU,"previewEntries");function uU(t,e,r,n){let o=t.action==="keep-modified"||!e.packDirRemoved;return {name:e.name,pack_path:mU(t,r,n),manifest_entry_removed:e.manifestEntryRemoved,extends_entry_removed:e.extendsEntryRemoved,generated_files_removed:0,modified_files_kept:o?t.modifications.map(i=>({relativePath:i.relativePath,status:i.status})):[],legacy_migrated:t.legacyMigrated,partial:e.partial}}s(uU,"appliedEntry");function k3(t){let e=[];for(let r of t)for(let n of r.split(",").map(o=>o.trim()).filter(Boolean))e.push(n);return e}s(k3,"parseNames");function E3(){return {ask:s(t=>Uf(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(E3,"defaultAdapter");async function Kf(t,e,r,n={}){let o=t.global===true?"global":"project",i=t.all===true,a=t.force===true,l=t["dry-run"]===true,c=t["keep-pack"]===true,m=t["keep-generated"]===true,p=n.assumeTty===true||process.stdin.isTTY,u=k3(e),f=t.json===true;function g(S){return f||y.error(S),{exitCode:1,data:{scope:o,mode:"uninstall",removed:[],skipped:[],failed:[],dryRun:l}}}if(s(g,"validationFailure"),!i&&u.length===0)return g("Missing install name. Usage: agentsmesh uninstall <name>[,<name>...] [--all]");if(!p&&!a&&!l)return g("Non-interactive terminal: use --force or --dry-run for agentsmesh uninstall.");let{config:h,context:R}=await yt(r,o);await Wt(h,r);let C=await wf(R.canonicalDir);try{let S=await ho(R.canonicalDir),k=join(R.canonicalDir,"packs"),P=eU({names:u,all:i,keepPack:c,keepGenerated:m,installs:S,extends:h.extends,packsDir:k}),{decisions:N,aborted:F}=await aU(P.removals,k,{adapter:n.promptAdapter??E3(),warn:s(at=>y.warn(at),"warn"),bypassPrompts:a||l||!p,keepPack:c,dryRun:l});if(F)return y.warn("Uninstall aborted at modification prompt."),{exitCode:130,data:{scope:o,mode:"uninstall",removed:[],skipped:[],failed:[],dryRun:l}};for(let at of P.removals)for(let At of at.warnings)y.warn(At);if(l){for(let at of N)y.info(`[dry-run] Would uninstall pack "${at.plan.name}".`);return {exitCode:0,data:{scope:o,mode:"uninstall",removed:pU(N,R.rootBase,k),skipped:WI(P.skipped),failed:[],dryRun:!0}}}let W=join(R.configDir,"agentsmesh.yaml"),z=[],Q=[];for(let at of N){let At=at.action==="keep-modified"?{...at.plan,packDir:null}:at.plan;try{let wt=await cU({plan:At,canonicalDir:R.canonicalDir,configPath:W,config:h});z.push(uU(at,wt,R.rootBase,k));}catch(wt){let oe=wt instanceof Error?wt.message:String(wt);Q.push({name:at.plan.name,reason:oe}),f||y.error(`Failed to uninstall "${at.plan.name}": ${oe}`);}}return !m&&z.length>0?await vf("uninstall",o,R.rootBase):m&&z.length>0&&y.warn("--keep-generated: target files derived from the removed pack(s) may be stale until the next generate."),{exitCode:Q.length>0?1:0,data:{scope:o,mode:"uninstall",removed:z,skipped:WI(P.skipped),failed:Q,dryRun:!1}}}finally{await C();}}s(Kf,"runUninstall");async function fU(t,e,r){return Kf(t,e,r)}s(fU,"runUninstall");ot();function gU(t){let{data:e}=t;if(e.dryRun){if(e.removed.length===0){y.info("[dry-run] No installs matched.");return}y.info(`[dry-run] Would uninstall ${e.removed.length} pack(s):`);for(let r of e.removed){let n=r.pack_path===null?"extends-only":r.pack_path;y.info(` - ${r.name} (${n})`);}return}if(e.removed.length>0){let r=e.removed.map(n=>`"${n.name}"`).join(", ");y.success(`Uninstalled ${e.removed.length} pack(s): ${r}.`);}for(let r of e.skipped)y.warn(`Skipped "${r.name}": ${r.reason}`);for(let r of e.failed)y.error(`Failed "${r.name}": ${r.reason}`);}s(gU,"renderUninstall");Yt();w();fc();async function O3(t){let e=await _(join(t,hn));if(e===null)return {installed_at:null,source_type:null};try{let r=JSON.parse(e);return {installed_at:typeof r.installed_at=="string"?r.installed_at:null,source_type:typeof r.source_type=="string"?r.source_type:null}}catch{return {installed_at:null,source_type:null}}}s(O3,"readPackManifestMeta");function A3(t,e){return relative(t,e).replaceAll("\\","/")}s(A3,"toForwardSlashRel");async function Wf(t,e){let r=t.global===true?"global":"project",n=Ei(e,r),o=await ho(n.canonicalDir),i=join(n.canonicalDir,"packs"),a=[];for(let l of o){let c=join(i,l.name),m=await O3(c),p=await fi(c);a.push({name:l.name,source:l.source,source_kind:l.source_kind,source_type:m.source_type,version:l.version??null,features:[...l.features],target:l.target??null,installed_at:m.installed_at,pack_path:A3(n.rootBase,c),license:p?.license??null});}return {exitCode:0,data:{scope:r,subcommand:"list",installs:a}}}s(Wf,"runInstallsList");var w3=["list"];function hU(t){return {scope:t,subcommand:"list",installs:[]}}s(hU,"emptyData");async function yU(t,e,r){let n=t.global===true?"global":"project",o=e[0];return o===void 0||o===""?{exitCode:0,data:hU(n),showHelp:true}:o==="list"?Wf(t,r):{exitCode:2,data:hU(n),showHelp:true,error:`Unknown installs subcommand: "${o}". Available: ${w3.join(", ")}. Did you mean \`agentsmesh install ${o}\`?`}}s(yU,"runInstalls");ot();var Hf=[{key:"name",label:"NAME"},{key:"source",label:"SOURCE"},{key:"features",label:"FEATURES"},{key:"license",label:"LICENSE"},{key:"installed",label:"INSTALLED"}];function b3(t){return {name:t.name,source:t.source,features:t.features.join(", "),license:t.license??"-",installed:t.installed_at?t.installed_at.slice(0,10):"-"}}s(b3,"toRow");function P3(t){let e={name:0,source:0,features:0,license:0,installed:0};for(let n of Hf)e[n.key]=n.label.length;for(let n of t)for(let o of Hf)e[o.key]=Math.max(e[o.key],n[o.key].length);let r=Hf.map(n=>n.label.padEnd(e[n.key])).join(" ");y.info(r);for(let n of t)y.info(Hf.map(o=>n[o.key].padEnd(e[o.key])).join(" "));}s(P3,"renderTable");function _U(t){if(t.error&&y.error(t.error),t.showHelp){Lp("installs");return}let{data:e}=t;if(e.installs.length===0){y.info("No installed packs.");return}P3(e.installs.map(b3));}s(_U,"renderInstalls");BR();w();var JI="agentsmesh.yaml";async function YI(t){let e=join(t,JI),r=await _(e);return r===null?{}:parse(r)??{}}s(YI,"readScopedConfigRaw");async function IU(t,e){let r=join(t,JI),n=await _(r)??`version: 1
361
- `,o=parse(n)??{};if(o.plugins||(o.plugins=[]),o.plugins.some(a=>a.id===e.id))return;let i={id:e.id,source:e.source};e.version!==void 0&&(i.version=e.version),o.plugins.push(i),await I(r,stringify(o));}s(IU,"writePluginEntry");async function SU(t,e){let r=join(t,JI),n=await _(r);if(n===null)return false;let o=parse(n)??{},i=(o.plugins??[]).length;o.plugins=(o.plugins??[]).filter(l=>l.id!==e),o.pluginTargets&&(o.pluginTargets=o.pluginTargets.filter(l=>l!==e));let a=o.plugins.length<i;return a&&await I(r,stringify(o)),a}s(SU,"removePluginEntry");async function CU(t,e,r){let n=e[0];if(n===void 0||n==="")return {exitCode:0,data:{subcommand:"list",plugins:[]},showHelp:true};switch(n){case "add":return T3(t,e.slice(1),r);case "list":return x3(r);case "remove":return D3(e.slice(1),r);case "info":return N3(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${n}`}}}s(CU,"runPlugin");async function T3(t,e,r){let n=e[0];if(!n)throw new yn("Usage: agentsmesh plugin add <source> [--version <v>] [--id <id>]");let o=typeof t.version=="string"?t.version:"latest",a=(typeof t.id=="string"?t.id:void 0)??F3(n);return await IU(r,{id:a,source:n,version:o==="latest"?void 0:o}),{exitCode:0,data:{subcommand:"add",id:a,package:n,version:o}}}s(T3,"runPluginAdd");async function x3(t){let r=(await YI(t)).plugins??[],n=[];for(let o of r){let i="\u2717",a="";try{let l=await _f(o,t);i=l.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",a=l.descriptors.map(c=>c.id).join(", ");}catch{}n.push({id:o.id,package:o.source,version:o.version,status:i,targets:a});}return {exitCode:0,data:{subcommand:"list",plugins:n}}}s(x3,"runPluginList");async function D3(t,e){let r=t[0];if(!r)throw new yn("Usage: agentsmesh plugin remove <id>");let n=await SU(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:n}}}s(D3,"runPluginRemove");async function N3(t,e){let r=t[0];if(!r)throw new yn("Usage: agentsmesh plugin info <id>");let o=((await YI(e)).plugins??[]).find(l=>l.id===r);if(!o)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await _f(o,e);}catch{return {exitCode:1,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:[]}}}let a=i.descriptors.map(l=>({id:l.id,description:l.emptyImportMessage}));return {exitCode:0,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:a}}}s(N3,"runPluginInfo");function F3(t){let e=t;if(e.startsWith("@")){let n=e.indexOf("/");n!==-1&&(e=e.slice(n+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(F3,"derivePluginId");ot();function kU(t){if(t.error&&y.error(t.error),t.showHelp){j3();return}let{data:e}=t;switch(e.subcommand){case "add":v3(e.id,e.package,e.version);break;case "list":M3(e.plugins);break;case "remove":$3(e.id,e.found);break;case "info":G3(e,t.exitCode);break}}s(kU,"renderPlugin");function v3(t,e,r){y.success(`Plugin '${t}' added to agentsmesh.yaml`),y.warn("Plugins load as trusted Node.js modules and run with full process privileges. Only install plugins from sources you trust.");let n=r!=="latest"?`@${r}`:"@latest";y.info(`Next: npm install ${e}${n}`),y.info(`Then add '${t}' to pluginTargets in agentsmesh.yaml to enable it.`);}s(v3,"renderAdd");function M3(t){if(t.length===0){y.info("No plugins configured. Use: agentsmesh plugin add <source>");return}y.info("Configured plugins:");for(let e of t){let r=e.version!==void 0?`@${e.version}`:"",n=e.status??"",o=e.targets??"";y.info(` ${e.id} | ${e.package}${r} | ${n} | ${o}`);}}s(M3,"renderList");function $3(t,e){e?y.success(`Plugin '${t}' removed from agentsmesh.yaml`):y.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s($3,"renderRemove");function G3(t,e){if(e!==0&&t.package===""){y.error(`Plugin '${t.id}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`);return}if(e!==0){y.error(`Failed to load plugin '${t.id}'`);return}y.info(`Plugin: ${t.id}`),y.info(`Source: ${t.package}${t.version!==void 0?`@${t.version}`:""}`),y.info(`Descriptors: ${t.descriptors.length}`);for(let r of t.descriptors)y.info(` - ${r.id}: ${r.description}`);}s(G3,"renderInfo");function j3(){y.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),y.info(""),y.info("Subcommands:"),y.info(" add <source> Register a plugin package in agentsmesh.yaml"),y.info(" list Show all configured plugins and load status"),y.info(" remove <id> Remove a plugin from agentsmesh.yaml"),y.info(" info <id> Show descriptor details for a configured plugin"),y.info(""),y.info("Flags (add):"),y.info(" --version <v> Pin plugin version"),y.info(" --id <id> Override derived plugin id"),y.info(""),y.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),y.info(" Only install plugins from sources you trust.");}s(j3,"printPluginHelp");w();Rn();function yi(t){return t.toUpperCase().replace(/-/g,"_")}s(yi,"toPrefix");function Rs(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(Rs,"toPascal");function XI(t){let e=yi(t.id),r=Rs(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
362
+ `),true}s(uU,"removeAgentsmeshExtendByName");async function dU(t){let{plan:e,canonicalDir:r,configPath:n,config:o}=t,i=false;e.packDir!==null&&await j(e.packDir)&&(await rm$1(e.packDir,{recursive:true}),i=true);let a=await Tj(r,e.name),l=false;e.extendsEntry!==null&&(l=await uU(n,o,e.name));let c=e.packDir!==null,m=e.manifestEntry!==null,p=e.extendsEntry!==null,u=c&&!i||m&&!a||p&&!l;return {name:e.name,packDirRemoved:i,manifestEntryRemoved:a,extendsEntryRemoved:l,partial:u}}s(dU,"applyUninstall");function $3(t,e){return relative(t,e).replaceAll("\\","/")}s($3,"toForwardSlashRel");function XI(t){return t.map(e=>({name:e,reason:"not found in installs.yaml"}))}s(XI,"buildSkipped");function fU(t,e,r){return t.plan.manifestEntry===null?null:$3(e,join(r,t.plan.name))}s(fU,"packPathFor");function gU(t,e,r){return t.map(n=>({name:n.plan.name,pack_path:fU(n,e,r),manifest_entry_removed:false,extends_entry_removed:false,generated_files_removed:0,modified_files_kept:n.modifications.map(o=>({relativePath:o.relativePath,status:o.status})),legacy_migrated:n.legacyMigrated,partial:n.action==="keep-modified"||n.plan.packDir===null}))}s(gU,"previewEntries");function hU(t,e,r,n){let o=t.action==="keep-modified"||!e.packDirRemoved;return {name:e.name,pack_path:fU(t,r,n),manifest_entry_removed:e.manifestEntryRemoved,extends_entry_removed:e.extendsEntryRemoved,generated_files_removed:0,modified_files_kept:o?t.modifications.map(i=>({relativePath:i.relativePath,status:i.status})):[],legacy_migrated:t.legacyMigrated,partial:e.partial}}s(hU,"appliedEntry");function G3(t){let e=[];for(let r of t)for(let n of r.split(",").map(o=>o.trim()).filter(Boolean))e.push(n);return e}s(G3,"parseNames");function j3(){return {ask:s(t=>Pc(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(j3,"defaultAdapter");async function rg(t,e,r,n={}){let o=t.global===true?"global":"project",i=t.all===true,a=t.force===true,l=t["dry-run"]===true,c=t["keep-pack"]===true,m=t["keep-generated"]===true,p=n.assumeTty===true||process.stdin.isTTY,u=G3(e),f=t.json===true;function g(C){return f||y.error(C),{exitCode:1,data:{scope:o,mode:"uninstall",removed:[],skipped:[],failed:[],dryRun:l}}}if(s(g,"validationFailure"),!i&&u.length===0)return g("Missing install name. Usage: agentsmesh uninstall <name>[,<name>...] [--all]");if(!p&&!a&&!l)return g("Non-interactive terminal: use --force or --dry-run for agentsmesh uninstall.");let{config:h,context:I}=await yt(r,o);await Gt(h,r);let k=await Cc(I.canonicalDir);try{let C=await xe(I.canonicalDir),R=join(I.canonicalDir,"packs"),P=iU({names:u,all:i,keepPack:c,keepGenerated:m,installs:C,extends:h.extends,packsDir:R}),{decisions:N,aborted:F}=await pU(P.removals,R,{adapter:n.promptAdapter??j3(),warn:s(nt=>y.warn(nt),"warn"),bypassPrompts:a||l||!p,keepPack:c,dryRun:l});if(F)return y.warn("Uninstall aborted at modification prompt."),{exitCode:130,data:{scope:o,mode:"uninstall",removed:[],skipped:[],failed:[],dryRun:l}};for(let nt of P.removals)for(let M of nt.warnings)y.warn(M);if(l){for(let nt of N)y.info(`[dry-run] Would uninstall pack "${nt.plan.name}".`);return {exitCode:0,data:{scope:o,mode:"uninstall",removed:gU(N,I.rootBase,R),skipped:XI(P.skipped),failed:[],dryRun:!0}}}let B=join(I.configDir,"agentsmesh.yaml"),U=[],q=[];for(let nt of N){let M=nt.action==="keep-modified"?{...nt.plan,packDir:null}:nt.plan;try{let tt=await dU({plan:M,canonicalDir:I.canonicalDir,configPath:B,config:h});U.push(hU(nt,tt,I.rootBase,R));}catch(tt){let Nt=tt instanceof Error?tt.message:String(tt);q.push({name:nt.plan.name,reason:Nt}),f||y.error(`Failed to uninstall "${nt.plan.name}": ${Nt}`);}}return !m&&U.length>0?await wc("uninstall",o,I.rootBase):m&&U.length>0&&y.warn("--keep-generated: target files derived from the removed pack(s) may be stale until the next generate."),{exitCode:q.length>0?1:0,data:{scope:o,mode:"uninstall",removed:U,skipped:XI(P.skipped),failed:q,dryRun:!1}}}finally{await k();}}s(rg,"runUninstall");async function _U(t,e,r){return rg(t,e,r)}s(_U,"runUninstall");st();function RU(t){let{data:e}=t;if(e.dryRun){if(e.removed.length===0){y.info("[dry-run] No installs matched.");return}y.info(`[dry-run] Would uninstall ${e.removed.length} pack(s):`);for(let r of e.removed){let n=r.pack_path===null?"extends-only":r.pack_path;y.info(` - ${r.name} (${n})`);}return}if(e.removed.length>0){let r=e.removed.map(n=>`"${n.name}"`).join(", ");y.success(`Uninstalled ${e.removed.length} pack(s): ${r}.`);}for(let r of e.skipped)y.warn(`Skipped "${r.name}": ${r.reason}`);for(let r of e.failed)y.error(`Failed "${r.name}": ${r.reason}`);}s(RU,"renderUninstall");Zt();Mr();st();function IU(t){let e=t.json===true;return {dryRun:t["dry-run"]===true,force:t.force===true||e,global:t.global===true,json:e,verbose:t.verbose===true}}s(IU,"readRefreshFlags");function SU(t){let e=[];for(let r of t)for(let n of r.split(",").map(o=>o.trim()).filter(Boolean))e.push(n);return e}s(SU,"parseRefreshNames");A();function U3(t){return t.modifications.length>0?"needs-consent":t.oldSha===t.newSha?"unchanged":"clean-update"}s(U3,"classifyRefreshPlan");async function kU(t,e,r){let n=join(e,t.name),o=t.version??null,i=join(n,tr),a=await _(i);if(a===null)return {name:t.name,entry:t,oldSha:o,newSha:o??"",modifications:[],classification:"error",error:{phase:"plan",message:`Pack manifest missing at ${i}`}};let l;try{l=JSON.parse(a).files??{};}catch{return {name:t.name,entry:t,oldSha:o,newSha:o??"",modifications:[],classification:"error",error:{phase:"plan",message:`Pack manifest is corrupt at ${i}`}}}let c=[];await j(n)&&(c=await eg(n,l));let m;try{m=await r.resolveRef(t);}catch(p){let u=p instanceof Error?p.message:String(p);return {name:t.name,entry:t,oldSha:o,newSha:o??"",modifications:c,classification:"error",error:{phase:"plan",message:u}}}return {name:t.name,entry:t,oldSha:o,newSha:m,modifications:c,classification:U3({modifications:c,oldSha:o,newSha:m})}}s(kU,"planSinglePack");function EU(){return async t=>{if(t.source_kind==="local")return t.version??"local";let e=Ep(t.source);if(e===null||e.remoteUrl===void 0)throw new Error(`Cannot parse source for refresh: ${t.source}`);let r=t.original_ref!==void 0&&t.original_ref!==""?t.original_ref:e.ref??"HEAD";return Bf(r,e.remoteUrl)}}s(EU,"createDefaultResolveRef");async function LU(t,e,r){try{await r.runInstallForRefresh(t.entry,t.newSha);}catch(n){return {success:false,phase:"apply",error:n instanceof Error?n.message:String(n)}}try{let n=(r.now??(()=>new Date().toISOString()))(),i=(await xe(e)).find(a=>a.name===t.entry.name);if(i===void 0)return {success:!1,phase:"manifest-update",error:`Entry "${t.entry.name}" not found after install`};await qf(e,{...i,refreshed_at:n});}catch(n){return {success:false,phase:"manifest-update",error:n instanceof Error?n.message:String(n)}}return {success:true}}s(LU,"applySinglePack");async function B3(t,e,r={}){let n=r.readLine??Pc,o,i=new Promise(a=>{o=setTimeout(()=>a("timeout"),e),o.unref?.();});try{let a=await Promise.race([n(t),i]);return a==="timeout"?"timeout":K3(a)}finally{o&&clearTimeout(o);}}s(B3,"promptWithTimeout");function K3(t){let e=t.trim().toLowerCase();return e==="y"||e==="yes"?"y":e==="per-pack"?"per-pack":"n"}s(K3,"normalize");async function ZI(t,e){let n=[`The following ${t.length} pack(s) have local edits that refresh will overwrite:`,...t.map(i=>` - ${i.name}: ${i.modifiedCount} modified file(s)`),"Continue? [y/N/per-pack] (5 min timeout, default N) "].join(`
363
+ `);switch(await B3(n,e.timeoutMs,e)){case "y":return {proceed:true,perPack:false,declined:[]};case "per-pack":return {proceed:true,perPack:true,declined:[]};case "n":case "timeout":return {proceed:false,perPack:false,declined:t.map(i=>i.name)}}}s(ZI,"runConsentPrompt");function W3(t,e){let r=Ep(t.source);if(r===null||r.remoteUrl===void 0)return t.source;if(t.source_kind==="github"&&t.source.startsWith("github:")){let n=t.source.indexOf(":"),o=t.source.lastIndexOf("@");return `${o>n?t.source.slice(0,o):t.source}@${e}`}if(t.source_kind==="gitlab"&&t.source.startsWith("gitlab:")){let n=t.source.indexOf(":"),o=t.source.lastIndexOf("@");return `${o>n?t.source.slice(0,o):t.source}@${e}`}if(t.source.startsWith("git+")){let n=t.source.lastIndexOf("#");return `${n<0?t.source:t.source.slice(0,n)}#${e}`}return t.source}s(W3,"buildSourceForRefresh");function OU(t){return async(e,r)=>{let n={force:true,forceFreshMaterialize:true};t.scope==="global"&&(n.global=true),e.target!==void 0&&(n.target=e.target),e.as!==void 0&&(n.as=e.as),e.path!==void 0&&(n.path=e.path),e.paths!==void 0&&e.paths.length>0&&(n.all=true),n.name=e.name;let o={features:e.features,pick:e.pick},i=W3(e,r),a=await Ga(n,[i],t.projectRoot,o);if(a.exitCode!==0)throw new Error(`Install for refresh "${e.name}" failed with exit code ${a.exitCode}`)}}s(OU,"createRunInstallForRefresh");var wU=300*1e3;async function ng(t,e,r){let{dryRun:n,force:o,global:i,json:a}=IU(t),l=i?"global":"project",c=SU(e),m=s(()=>({scope:l,mode:"refresh",refreshed:[],unchanged:[],skipped:[],failed:[],dryRun:n}),"emptyData"),{config:p,context:u}=await yt(r,l);await Gt(p,r);let f=await Cc(u.canonicalDir);try{let g=await xe(u.canonicalDir);if(c.length>0){let M=new Set(g.map(Nt=>Nt.name)),tt=c.filter(Nt=>!M.has(Nt));if(tt.length>0)return a||y.error(`Unknown pack(s): ${tt.join(", ")}`),{exitCode:2,data:m()}}let h=c.length>0?g.filter(M=>c.includes(M.name)):g;if(h.length===0)return a||y.info("No packs to refresh."),{exitCode:0,data:m()};let I=join(u.canonicalDir,"packs"),k=EU(),C=[];for(let M of h)C.push(await kU(M,I,{resolveRef:k}));let R=C.filter(M=>M.classification==="error"),P=C.filter(M=>M.classification==="unchanged"),N=C.filter(M=>M.classification==="clean-update"),F=C.filter(M=>M.classification==="needs-consent"),B=m();if(B.unchanged=P.map(M=>({name:M.name,ref:M.newSha})),B.failed=R.map(M=>({name:M.name,phase:"plan",error:M.error?.message??"unknown plan error"})),n){for(let M of N)B.refreshed.push({name:M.name,oldRef:M.oldSha,newRef:M.newSha,oldSha:M.oldSha,newSha:M.newSha,changedFiles:{added:[],removed:[],modified:[]}});for(let M of F)B.refreshed.push({name:M.name,oldRef:M.oldSha,newRef:M.newSha,oldSha:M.oldSha,newSha:M.newSha,changedFiles:{added:[],removed:[],modified:[]}});return {exitCode:R.length>0?1:0,data:B}}let U=new Set(N.map(M=>M.name));if(F.length>0)if(o)for(let M of F)U.add(M.name);else {let M=await ZI(F.map(tt=>({name:tt.name,modifiedCount:tt.modifications.length})),{timeoutMs:wU});if(M.proceed&&!M.perPack)for(let tt of F)U.add(tt.name);else if(M.proceed&&M.perPack)for(let tt of F)(await ZI([{name:tt.name,modifiedCount:tt.modifications.length}],{timeoutMs:wU})).proceed?U.add(tt.name):B.skipped.push({name:tt.name,reason:"user-declined"});else for(let tt of M.declined)B.skipped.push({name:tt,reason:"user-declined"});}let q=OU({projectRoot:r,scope:l});for(let M of [...N,...F]){if(!U.has(M.name))continue;let tt=await LU(M,u.canonicalDir,{runInstallForRefresh:q});tt.success?B.refreshed.push({name:M.name,oldRef:M.oldSha,newRef:M.newSha,oldSha:M.oldSha,newSha:M.newSha,changedFiles:{added:[],removed:[],modified:[]}}):B.failed.push({name:M.name,phase:tt.phase??"apply",error:tt.error??"unknown"});}return B.refreshed.length>0&&await wc("refresh",l,u.rootBase),{exitCode:B.failed.length>0?1:0,data:B}}finally{await f();}}s(ng,"runRefresh");async function AU(t,e,r){return ng(t,e,r)}s(AU,"runRefresh");st();function bU(t){let{data:e}=t;if(e.dryRun){if(e.refreshed.length===0&&e.unchanged.length===0){y.info("[dry-run] No packs to refresh.");return}y.info(`[dry-run] Would refresh ${e.refreshed.length} pack(s); ${e.unchanged.length} unchanged.`);for(let r of e.refreshed)y.info(` - ${r.name}: ${r.oldSha??"\u2014"} \u2192 ${r.newSha}`);for(let r of e.unchanged)y.info(` - ${r.name}: unchanged at ${r.ref}`);return}if(e.refreshed.length>0){y.success(`Refreshed ${e.refreshed.length} pack(s):`);for(let r of e.refreshed)y.info(` - ${r.name}: ${r.oldSha??"\u2014"} \u2192 ${r.newSha}`);}for(let r of e.unchanged)y.info(`Pack "${r.name}" unchanged at ${r.ref}.`);for(let r of e.skipped)y.warn(`Skipped "${r.name}": ${r.reason}`);for(let r of e.failed)y.error(`Failed "${r.name}" (${r.phase}): ${r.error}`);}s(bU,"renderRefresh");Zt();A();gc();async function V3(t){let e=await _(join(t,tr));if(e===null)return {installed_at:null,source_type:null};try{let r=JSON.parse(e);return {installed_at:typeof r.installed_at=="string"?r.installed_at:null,source_type:typeof r.source_type=="string"?r.source_type:null}}catch{return {installed_at:null,source_type:null}}}s(V3,"readPackManifestMeta");function J3(t,e){return relative(t,e).replaceAll("\\","/")}s(J3,"toForwardSlashRel");async function og(t,e){let r=t.global===true?"global":"project",n=Oi(e,r),o=await xe(n.canonicalDir),i=join(n.canonicalDir,"packs"),a=[];for(let l of o){let c=join(i,l.name),m=await V3(c),p=await gi(c);a.push({name:l.name,source:l.source,source_kind:l.source_kind,source_type:m.source_type,version:l.version??null,features:[...l.features],target:l.target??null,installed_at:m.installed_at,refreshed_at:l.refreshed_at??null,pack_path:J3(n.rootBase,c),license:p?.license??null});}return {exitCode:0,data:{scope:r,subcommand:"list",installs:a}}}s(og,"runInstallsList");var Y3=["list"];function PU(t){return {scope:t,subcommand:"list",installs:[]}}s(PU,"emptyData");async function TU(t,e,r){let n=t.global===true?"global":"project",o=e[0];return o===void 0||o===""?{exitCode:0,data:PU(n),showHelp:true}:o==="list"?og(t,r):{exitCode:2,data:PU(n),showHelp:true,error:`Unknown installs subcommand: "${o}". Available: ${Y3.join(", ")}. Did you mean \`agentsmesh install ${o}\`?`}}s(TU,"runInstalls");st();var sg=[{key:"name",label:"NAME"},{key:"source",label:"SOURCE"},{key:"features",label:"FEATURES"},{key:"license",label:"LICENSE"},{key:"installed",label:"LAST TOUCHED"}];function X3(t){let e=t.refreshed_at??t.installed_at??null;return {name:t.name,source:t.source,features:t.features.join(", "),license:t.license??"-",installed:e?e.slice(0,10):"-"}}s(X3,"toRow");function Z3(t){let e={name:0,source:0,features:0,license:0,installed:0};for(let n of sg)e[n.key]=n.label.length;for(let n of t)for(let o of sg)e[o.key]=Math.max(e[o.key],n[o.key].length);let r=sg.map(n=>n.label.padEnd(e[n.key])).join(" ");y.info(r);for(let n of t)y.info(sg.map(o=>n[o.key].padEnd(e[o.key])).join(" "));}s(Z3,"renderTable");function xU(t){if(t.error&&y.error(t.error),t.showHelp){$p("installs");return}let{data:e}=t;if(e.installs.length===0){y.info("No installed packs.");return}Z3(e.installs.map(X3));}s(xU,"renderInstalls");rI();A();var eS="agentsmesh.yaml";async function rS(t){let e=join(t,eS),r=await _(e);return r===null?{}:parse(r)??{}}s(rS,"readScopedConfigRaw");async function NU(t,e){let r=join(t,eS),n=await _(r)??`version: 1
364
+ `,o=parse(n)??{};if(o.plugins||(o.plugins=[]),o.plugins.some(a=>a.id===e.id))return;let i={id:e.id,source:e.source};e.version!==void 0&&(i.version=e.version),o.plugins.push(i),await S(r,stringify(o));}s(NU,"writePluginEntry");async function FU(t,e){let r=join(t,eS),n=await _(r);if(n===null)return false;let o=parse(n)??{},i=(o.plugins??[]).length;o.plugins=(o.plugins??[]).filter(l=>l.id!==e),o.pluginTargets&&(o.pluginTargets=o.pluginTargets.filter(l=>l!==e));let a=o.plugins.length<i;return a&&await S(r,stringify(o)),a}s(FU,"removePluginEntry");async function vU(t,e,r){let n=e[0];if(n===void 0||n==="")return {exitCode:0,data:{subcommand:"list",plugins:[]},showHelp:true};switch(n){case "add":return Q3(t,e.slice(1),r);case "list":return q3(r);case "remove":return t8(e.slice(1),r);case "info":return e8(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${n}`}}}s(vU,"runPlugin");async function Q3(t,e,r){let n=e[0];if(!n)throw new Rn("Usage: agentsmesh plugin add <source> [--version <v>] [--id <id>]");let o=typeof t.version=="string"?t.version:"latest",a=(typeof t.id=="string"?t.id:void 0)??r8(n);return await NU(r,{id:a,source:n,version:o==="latest"?void 0:o}),{exitCode:0,data:{subcommand:"add",id:a,package:n,version:o}}}s(Q3,"runPluginAdd");async function q3(t){let r=(await rS(t)).plugins??[],n=[];for(let o of r){let i="\u2717",a="";try{let l=await Tf(o,t);i=l.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",a=l.descriptors.map(c=>c.id).join(", ");}catch{}n.push({id:o.id,package:o.source,version:o.version,status:i,targets:a});}return {exitCode:0,data:{subcommand:"list",plugins:n}}}s(q3,"runPluginList");async function t8(t,e){let r=t[0];if(!r)throw new Rn("Usage: agentsmesh plugin remove <id>");let n=await FU(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:n}}}s(t8,"runPluginRemove");async function e8(t,e){let r=t[0];if(!r)throw new Rn("Usage: agentsmesh plugin info <id>");let o=((await rS(e)).plugins??[]).find(l=>l.id===r);if(!o)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await Tf(o,e);}catch{return {exitCode:1,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:[]}}}let a=i.descriptors.map(l=>({id:l.id,description:l.emptyImportMessage}));return {exitCode:0,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:a}}}s(e8,"runPluginInfo");function r8(t){let e=t;if(e.startsWith("@")){let n=e.indexOf("/");n!==-1&&(e=e.slice(n+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(r8,"derivePluginId");st();function MU(t){if(t.error&&y.error(t.error),t.showHelp){a8();return}let{data:e}=t;switch(e.subcommand){case "add":n8(e.id,e.package,e.version);break;case "list":o8(e.plugins);break;case "remove":s8(e.id,e.found);break;case "info":i8(e,t.exitCode);break}}s(MU,"renderPlugin");function n8(t,e,r){y.success(`Plugin '${t}' added to agentsmesh.yaml`),y.warn("Plugins load as trusted Node.js modules and run with full process privileges. Only install plugins from sources you trust.");let n=r!=="latest"?`@${r}`:"@latest";y.info(`Next: npm install ${e}${n}`),y.info(`Then add '${t}' to pluginTargets in agentsmesh.yaml to enable it.`);}s(n8,"renderAdd");function o8(t){if(t.length===0){y.info("No plugins configured. Use: agentsmesh plugin add <source>");return}y.info("Configured plugins:");for(let e of t){let r=e.version!==void 0?`@${e.version}`:"",n=e.status??"",o=e.targets??"";y.info(` ${e.id} | ${e.package}${r} | ${n} | ${o}`);}}s(o8,"renderList");function s8(t,e){e?y.success(`Plugin '${t}' removed from agentsmesh.yaml`):y.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s(s8,"renderRemove");function i8(t,e){if(e!==0&&t.package===""){y.error(`Plugin '${t.id}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`);return}if(e!==0){y.error(`Failed to load plugin '${t.id}'`);return}y.info(`Plugin: ${t.id}`),y.info(`Source: ${t.package}${t.version!==void 0?`@${t.version}`:""}`),y.info(`Descriptors: ${t.descriptors.length}`);for(let r of t.descriptors)y.info(` - ${r.id}: ${r.description}`);}s(i8,"renderInfo");function a8(){y.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),y.info(""),y.info("Subcommands:"),y.info(" add <source> Register a plugin package in agentsmesh.yaml"),y.info(" list Show all configured plugins and load status"),y.info(" remove <id> Remove a plugin from agentsmesh.yaml"),y.info(" info <id> Show descriptor details for a configured plugin"),y.info(""),y.info("Flags (add):"),y.info(" --version <v> Pin plugin version"),y.info(" --id <id> Override derived plugin id"),y.info(""),y.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),y.info(" Only install plugins from sources you trust.");}s(a8,"printPluginHelp");A();Sn();function _i(t){return t.toUpperCase().replace(/-/g,"_")}s(_i,"toPrefix");function Ss(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(Ss,"toPascal");function nS(t){let e=_i(t.id),r=Ss(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
362
365
  import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
363
366
  import { generateRules } from './generator.js';
364
367
  import { importFrom${r} } from './importer.js';
@@ -461,7 +464,7 @@ export const descriptor = {
461
464
  buildImportPaths: build${r}ImportPaths,
462
465
  detectionPaths: [${e}_DIR],
463
466
  } satisfies TargetDescriptor;
464
- `}s(XI,"TEMPLATE_INDEX");function ZI(t){return `import { describe, it, expect } from 'vitest';
467
+ `}s(nS,"TEMPLATE_INDEX");function oS(t){return `import { describe, it, expect } from 'vitest';
465
468
  import type { CanonicalFiles } from '../../../../src/core/types.js';
466
469
  import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
467
470
 
@@ -490,7 +493,7 @@ describe('generateRules (${t.id})', () => {
490
493
  expect(result).toHaveLength(0);
491
494
  });
492
495
  });
493
- `}s(ZI,"TEMPLATE_GENERATOR_TEST");function QI(t){let e=Rs(t.id);return `import { describe, it, expect } from 'vitest';
496
+ `}s(oS,"TEMPLATE_GENERATOR_TEST");function sS(t){let e=Ss(t.id);return `import { describe, it, expect } from 'vitest';
494
497
  import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
495
498
 
496
499
  describe('importFrom${e} (${t.id})', () => {
@@ -504,10 +507,10 @@ describe('importFrom${e} (${t.id})', () => {
504
507
  expect(result).toHaveLength(0);
505
508
  });
506
509
  });
507
- `}s(QI,"TEMPLATE_IMPORTER_TEST");function qI(t){return `# ${t.displayName} Workspace
510
+ `}s(sS,"TEMPLATE_IMPORTER_TEST");function iS(t){return `# ${t.displayName} Workspace
508
511
 
509
512
  Follow the ${t.displayName} configuration files and keep changes small.
510
- `}s(qI,"TEMPLATE_FIXTURE_ROOT_MD");function EU(t){let e=yi(t.id);return `export const ${e}_TARGET = '${t.id}';
513
+ `}s(iS,"TEMPLATE_FIXTURE_ROOT_MD");function $U(t){let e=_i(t.id);return `export const ${e}_TARGET = '${t.id}';
511
514
 
512
515
  // Project-level paths
513
516
  export const ${e}_DIR = '.${t.id}';
@@ -520,21 +523,21 @@ export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
520
523
  // Canonical paths
521
524
  export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
522
525
  export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
523
- `}s(EU,"TEMPLATE_CONSTANTS");function LU(t){let e=yi(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
526
+ `}s($U,"TEMPLATE_CONSTANTS");function GU(t){let e=_i(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
524
527
  import { ${e}_TARGET, ${e}_DIR } from './constants.js';
525
528
 
526
- export interface ${Rs(t.id)}Output {
529
+ export interface ${Ss(t.id)}Output {
527
530
  path: string;
528
531
  content: string;
529
532
  }
530
533
 
531
- export function generateRules(_canonical: CanonicalFiles): ${Rs(t.id)}Output[] {
534
+ export function generateRules(_canonical: CanonicalFiles): ${Ss(t.id)}Output[] {
532
535
  // TODO(agentsmesh-scaffold): implement generateRules for ${t.displayName}
533
536
  void ${e}_TARGET;
534
537
  void ${e}_DIR;
535
538
  return [];
536
539
  }
537
- `}s(LU,"TEMPLATE_GENERATOR");function OU(t){let e=Rs(t.id),r=yi(t.id);return `import type { ImportResult } from '../../core/types.js';
540
+ `}s(GU,"TEMPLATE_GENERATOR");function jU(t){let e=Ss(t.id),r=_i(t.id);return `import type { ImportResult } from '../../core/types.js';
538
541
  import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
539
542
  import { ${r}_TARGET } from './constants.js';
540
543
 
@@ -546,7 +549,7 @@ export async function importFrom${e}(
546
549
  void ${r}_TARGET;
547
550
  return [];
548
551
  }
549
- `}s(OU,"TEMPLATE_IMPORTER");function AU(t){let e=yi(t.id);return `/** Lint rules for the ${t.id} target. */
552
+ `}s(jU,"TEMPLATE_IMPORTER");function UU(t){let e=_i(t.id);return `/** Lint rules for the ${t.id} target. */
550
553
  import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
551
554
  import { validateRules } from '../../core/lint/validate-rules.js';
552
555
  import { ${e}_TARGET } from './constants.js';
@@ -564,7 +567,7 @@ export function lintRules(
564
567
  target: ${e}_TARGET,
565
568
  }));
566
569
  }
567
- `}s(AU,"TEMPLATE_LINTER");function wU(t){return `/**
570
+ `}s(UU,"TEMPLATE_LINTER");function BU(t){return `/**
568
571
  * ${t.displayName}-specific lint hooks.
569
572
  */
570
573
 
@@ -574,7 +577,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
574
577
  // TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
575
578
  return [];
576
579
  }
577
- `}s(wU,"TEMPLATE_LINT_HOOKS");function bU(t){let e=Rs(t.id),r=yi(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
580
+ `}s(BU,"TEMPLATE_LINT_HOOKS");function KU(t){let e=Ss(t.id),r=_i(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
578
581
  import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
579
582
 
580
583
  export async function build${e}ImportPaths(
@@ -586,14 +589,14 @@ export async function build${e}ImportPaths(
586
589
  // Reference: src/core/reference/import-maps/kiro.ts for a full example
587
590
  void ${r}_DIR;
588
591
  }
589
- `}s(bU,"TEMPLATE_IMPORT_MAP");var B3=/^[a-z][a-z0-9-]*$/;async function PU(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!B3.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(Ft.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:EU(i)},{rel:`src/targets/${e}/index.ts`,content:XI(i)},{rel:`src/targets/${e}/generator.ts`,content:LU(i)},{rel:`src/targets/${e}/importer.ts`,content:OU(i)},{rel:`src/targets/${e}/linter.ts`,content:AU(i)},{rel:`src/targets/${e}/lint.ts`,content:wU(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:bU(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:ZI(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:QI(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:qI(i)}],l=[],c=[];for(let p of a){let u=join(r,p.rel);if(!n&&await $(u)){c.push(u);continue}await I(u,p.content),l.push(u);}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:l,skipped:c,postSteps:m}}s(PU,"writeTargetScaffold");async function xU(t,e,r){let n=e[0];return n===void 0||n===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:n==="scaffold"?K3(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${n}`}}s(xU,"runTarget");async function K3(t,e,r){let n=e[0];if(!n)throw new yn("Usage: agentsmesh target scaffold <id> [--name <displayName>] [--force]");let o=typeof t.name=="string"?t.name:void 0,i=t.force===true,a;try{a=await PU({id:n,displayName:o,projectRoot:r,force:i});}catch(l){return {exitCode:1,data:{id:n,written:[],skipped:[],postSteps:[]},error:l instanceof Error?l.message:String(l)}}return {exitCode:0,data:{id:n,written:a.written.map(l=>TU(l,r)),skipped:a.skipped.map(l=>TU(l,r)),postSteps:a.postSteps}}}s(K3,"runScaffold");function TU(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(TU,"relativize");ot();function DU(t){if(t.error&&y.error(t.error),t.showHelp){W3();return}let{data:e}=t;for(let r of e.written)y.success(`created ${r}`);for(let r of e.skipped)y.warn(`skipped ${r} (already exists \u2014 use --force to overwrite)`);if(e.written.length>0){y.info(""),y.info("Next steps:");for(let r of e.postSteps)y.info(` ${r}`);}}s(DU,"renderTarget");function W3(){y.info("Usage: agentsmesh target <subcommand> [args] [flags]"),y.info(""),y.info("Subcommands:"),y.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),y.info(""),y.info("Flags (scaffold):"),y.info(" --name <displayName> Human-readable name (defaults to id)"),y.info(" --force Overwrite existing files");}s(W3,"printTargetHelp");se();Ai();w();Yt();fn();Ro();function Q3(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(Q3,"shouldSymlink");function q3(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let n of r){if(!Q3(n.name,n.isDirectory()))continue;let o=join(t,n.name),i=join(e,n.name);symlinkSync(o,i,n.isDirectory()?"dir":"file");}return mkdirSync(join(e,".agentsmesh"),{recursive:true}),e}s(q3,"createTempProjectRoot");async function Vf(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=n==="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 l=i.toLowerCase().trim(),c=a.toLowerCase().trim();if(l===c)throw new Error("--from and --to must be different targets.");let m=Pe(l),p=Pe(c);if(!m||!p)try{let{config:C}=await yt(r,"project");await Wt(C,r);}catch{let C=[];throw m||C.push(`--from "${i}"`),p||C.push(`--to "${a}"`),new Error(`Unknown ${C.join(" and ")}. Supported: ${Ft.join(", ")}.`)}let u=et(l);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${Ft.join(", ")}.`);if(!et(c))throw new Error(`Unknown --to "${a}". Supported: ${Ft.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",R=q3(o);try{await u.generators.importFrom(R,{scope:n});let C=await Ee(R),S=ki.parse({version:1,targets:p?[c]:[],pluginTargets:p?[]:[c]}),k=await Tr({config:S,canonical:C,projectRoot:o,scope:n,targetFilter:[c]});if(!g){for(let F of k)if(F.status==="created"||F.status==="updated"){let W=yc(o,F.path,F.target);await I(W,F.content);}}let P=k.filter(F=>F.status!=="skipped"),N=P.map(F=>({path:F.path,target:F.target,status:F.status}));return {exitCode:0,data:{from:l,to:c,mode:h,files:N,summary:{created:P.filter(F=>F.status==="created").length,updated:P.filter(F=>F.status==="updated").length,unchanged:P.filter(F=>F.status==="unchanged").length}}}}finally{rmSync(R,{recursive:true,force:true});}}s(Vf,"runConvert");ot();function NU(t){let{data:e}=t;if(e.files.length===0){y.info(`No files found to convert from ${e.from}.`);return}if(e.mode==="dry-run"){for(let i of e.files)y.info(`[dry-run] ${i.status} ${i.path} (${i.target})`);return}for(let i of e.files)(i.status==="created"||i.status==="updated")&&y.success(`${i.status} ${i.path}`);let{created:r,updated:n,unchanged:o}=e.summary;r>0||n>0?y.info(`Converted from ${e.from} \u2192 ${e.to}: ${r} created, ${n} updated, ${o} unchanged`):y.info(`Nothing changed. (${o} unchanged)`);}s(NU,"renderConvert");var t8=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,G=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,n){if(t8.test(r))throw new Error(`McpError refuses absolute fs path in message: ${r}`);super(r),this.code=e,this.details=n;}toEnvelope(){return this.details===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,details:this.details}}};function Jf(t){return t.replace(/(['"`])\/[^'"`\s]+\1/gu,"$1<redacted>$1").replace(/(['"`])[A-Z]:[\\/][^'"`\s]+\1/gu,"$1<redacted>$1").replace(/\/[A-Za-z][^\s'"`<>()]*/gu,"<redacted>").replace(/[A-Z]:[\\/][^\s'"`<>()]*/gu,"<redacted>")}s(Jf,"redactAbsolutePaths");async function tS(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new G("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file body exceeds 1 MiB cap",{limit:1048576,actual:Buffer.byteLength(t.content,"utf8")});await mkdir(dirname(r),{recursive:true});let n=`${r}.tmp.${process.pid}.${Date.now()}`;return await writeFile(n,t.content,"utf8"),await rename(n,r),r}s(tS,"safeWrite");var l8=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function Ri(t){let e=l8.exec(t);if(!e)return {frontmatter:{},body:t};let[,r,n]=e;return {frontmatter:parse(r)??{},body:n}}s(Ri,"parseMd");function wc(t,e){return Object.keys(t).length===0?e:`---
592
+ `}s(KU,"TEMPLATE_IMPORT_MAP");var c8=/^[a-z][a-z0-9-]*$/;async function WU(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!c8.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(vt.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:$U(i)},{rel:`src/targets/${e}/index.ts`,content:nS(i)},{rel:`src/targets/${e}/generator.ts`,content:GU(i)},{rel:`src/targets/${e}/importer.ts`,content:jU(i)},{rel:`src/targets/${e}/linter.ts`,content:UU(i)},{rel:`src/targets/${e}/lint.ts`,content:BU(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:KU(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:oS(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:sS(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:iS(i)}],l=[],c=[];for(let p of a){let u=join(r,p.rel);if(!n&&await j(u)){c.push(u);continue}await S(u,p.content),l.push(u);}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:l,skipped:c,postSteps:m}}s(WU,"writeTargetScaffold");async function zU(t,e,r){let n=e[0];return n===void 0||n===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:n==="scaffold"?m8(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${n}`}}s(zU,"runTarget");async function m8(t,e,r){let n=e[0];if(!n)throw new Rn("Usage: agentsmesh target scaffold <id> [--name <displayName>] [--force]");let o=typeof t.name=="string"?t.name:void 0,i=t.force===true,a;try{a=await WU({id:n,displayName:o,projectRoot:r,force:i});}catch(l){return {exitCode:1,data:{id:n,written:[],skipped:[],postSteps:[]},error:l instanceof Error?l.message:String(l)}}return {exitCode:0,data:{id:n,written:a.written.map(l=>HU(l,r)),skipped:a.skipped.map(l=>HU(l,r)),postSteps:a.postSteps}}}s(m8,"runScaffold");function HU(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(HU,"relativize");st();function VU(t){if(t.error&&y.error(t.error),t.showHelp){p8();return}let{data:e}=t;for(let r of e.written)y.success(`created ${r}`);for(let r of e.skipped)y.warn(`skipped ${r} (already exists \u2014 use --force to overwrite)`);if(e.written.length>0){y.info(""),y.info("Next steps:");for(let r of e.postSteps)y.info(` ${r}`);}}s(VU,"renderTarget");function p8(){y.info("Usage: agentsmesh target <subcommand> [args] [flags]"),y.info(""),y.info("Subcommands:"),y.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),y.info(""),y.info("Flags (scaffold):"),y.info(" --name <displayName> Human-readable name (defaults to id)"),y.info(" --force Overwrite existing files");}s(p8,"printTargetHelp");ae();bi();A();Zt();Mr();So();function R8(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(R8,"shouldSymlink");function I8(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let n of r){if(!R8(n.name,n.isDirectory()))continue;let o=join(t,n.name),i=join(e,n.name);symlinkSync(o,i,n.isDirectory()?"dir":"file");}return mkdirSync(join(e,".agentsmesh"),{recursive:true}),e}s(I8,"createTempProjectRoot");async function ag(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=n==="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 l=i.toLowerCase().trim(),c=a.toLowerCase().trim();if(l===c)throw new Error("--from and --to must be different targets.");let m=Fe(l),p=Fe(c);if(!m||!p)try{let{config:k}=await yt(r,"project");await Gt(k,r);}catch{let k=[];throw m||k.push(`--from "${i}"`),p||k.push(`--to "${a}"`),new Error(`Unknown ${k.join(" and ")}. Supported: ${vt.join(", ")}.`)}let u=ot(l);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${vt.join(", ")}.`);if(!ot(c))throw new Error(`Unknown --to "${a}". Supported: ${vt.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",I=I8(o);try{await u.generators.importFrom(I,{scope:n});let k=await Oe(I),C=Li.parse({version:1,targets:p?[c]:[],pluginTargets:p?[]:[c]}),R=await vr({config:C,canonical:k,projectRoot:o,scope:n,targetFilter:[c]});if(!g){for(let F of R)if(F.status==="created"||F.status==="updated"){let B=_c(o,F.path,F.target);await S(B,F.content);}}let P=R.filter(F=>F.status!=="skipped"),N=P.map(F=>({path:F.path,target:F.target,status:F.status}));return {exitCode:0,data:{from:l,to:c,mode:h,files:N,summary:{created:P.filter(F=>F.status==="created").length,updated:P.filter(F=>F.status==="updated").length,unchanged:P.filter(F=>F.status==="unchanged").length}}}}finally{rmSync(I,{recursive:true,force:true});}}s(ag,"runConvert");st();function JU(t){let{data:e}=t;if(e.files.length===0){y.info(`No files found to convert from ${e.from}.`);return}if(e.mode==="dry-run"){for(let i of e.files)y.info(`[dry-run] ${i.status} ${i.path} (${i.target})`);return}for(let i of e.files)(i.status==="created"||i.status==="updated")&&y.success(`${i.status} ${i.path}`);let{created:r,updated:n,unchanged:o}=e.summary;r>0||n>0?y.info(`Converted from ${e.from} \u2192 ${e.to}: ${r} created, ${n} updated, ${o} unchanged`):y.info(`Nothing changed. (${o} unchanged)`);}s(JU,"renderConvert");var S8=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,v=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,n){if(S8.test(r))throw new Error(`McpError refuses absolute fs path in message: ${r}`);super(r),this.code=e,this.details=n;}toEnvelope(){return this.details===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,details:this.details}}};function xc(t){return t.replace(/(['"`])\/[^'"`\s]+\1/gu,"$1<redacted>$1").replace(/(['"`])[A-Z]:[\\/][^'"`\s]+\1/gu,"$1<redacted>$1").replace(/\/[A-Za-z][^\s'"`<>()]*/gu,"<redacted>").replace(/[A-Z]:[\\/][^\s'"`<>()]*/gu,"<redacted>")}s(xc,"redactAbsolutePaths");async function aS(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new v("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new v("LIMIT_EXCEEDED","file body exceeds 1 MiB cap",{limit:1048576,actual:Buffer.byteLength(t.content,"utf8")});await mkdir(dirname(r),{recursive:true});let n=`${r}.tmp.${process.pid}.${Date.now()}`;return await writeFile(n,t.content,"utf8"),await rename(n,r),r}s(aS,"safeWrite");var b8=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function Ii(t){let e=b8.exec(t);if(!e)return {frontmatter:{},body:t};let[,r,n]=e;return {frontmatter:parse(r)??{},body:n}}s(Ii,"parseMd");function Dc(t,e){return Object.keys(t).length===0?e:`---
590
593
  ${stringify(t).trimEnd()}
591
594
  ---
592
595
 
593
- ${e}`}s(wc,"serializeMd");var d8=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,f8={rules:"_root"};function Yf(t){if(!d8.test(t)||t.includes(".."))throw new G("INVALID_NAME",`invalid name: ${t}`)}s(Yf,"checkName");function Xf(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(Xf,"pathFor");function bc(t){let{feature:e,frontmatterSchema:r,toSummary:n}=t,o=s(l=>resolve(l,".agentsmesh",e),"featureDir");async function i(l){try{return (await readdir(o(l),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(l){try{return await stat(l),!0}catch{return false}}return s(a,"exists"),{async list(l){let c=await i(l.projectRoot),m=[];for(let p of c){let u=p.replace(/\.md$/,""),f=await readFile(join(o(l.projectRoot),p),"utf8"),{frontmatter:g}=Ri(f);m.push(n(u,g));}return m},async get(l,{name:c}){Yf(c);let m=Xf(l.projectRoot,e,c);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=Ri(p);return {name:c,frontmatter:u,body:f}}catch(p){let u=p.code;throw u==="ENOENT"?new G("NOT_FOUND",`${e} "${c}" not found`):new G("IO_ERROR",`failed to read ${e}`,{errno:u})}},async create(l,{name:c,frontmatter:m,body:p,dry_run:u}){Yf(c);let f=r.safeParse(m);if(!f.success)throw new G("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=Xf(l.projectRoot,e,c);if(await a(g))throw new G("ALREADY_EXISTS",`${e} "${c}" exists`);if((await i(l.projectRoot)).length>=1e3)throw new G("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let R=wc(m,p);return u===true?{path:g,written:false}:(await tS({projectRoot:l.projectRoot,feature:e,relativePath:`${c}.md`,content:R}),{path:g,written:true})},async update(l,{name:c,frontmatter:m,body:p,merge:u,dry_run:f}){Yf(c);let g=Xf(l.projectRoot,e,c),h;try{let P=await readFile(g,"utf8");h=Ri(P);}catch(P){let N=P.code;throw N==="ENOENT"?new G("NOT_FOUND",`${e} "${c}" not found`):new G("IO_ERROR",`failed to read ${e}`,{errno:N})}let R=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,C=r.safeParse(R);if(!C.success)throw new G("VALIDATION_FAILED","invalid frontmatter",C.error.issues);let S=p!==void 0?p:h.body,k=wc(R,S);return f===true?{path:g,written:false}:(await tS({projectRoot:l.projectRoot,feature:e,relativePath:`${c}.md`,content:k}),{path:g,written:true})},async delete(l,{name:c,force:m,dry_run:p}){if(Yf(c),f8[e]===c&&m!==true)throw new G("PROTECTED_FILE",`${e} "${c}" requires force: true`);let u=Xf(l.projectRoot,e,c);if(!await a(u))throw new G("NOT_FOUND",`${e} "${c}" not found`);return p===true?{path:u,deleted:false}:(await rm(u),{path:u,deleted:true})}}}s(bc,"createCanonicalHandlers");var g8=z.object({description:z.string().optional(),root:z.boolean().optional(),globs:z.array(z.string()).nullable().optional(),targets:z.array(z.string()).nullable().optional()}).passthrough(),MU=bc({feature:"rules",frontmatterSchema:g8,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var h8=z.object({description:z.string().optional(),"allowed-tools":z.array(z.string()).optional()}).passthrough(),$U=bc({feature:"commands",frontmatterSchema:h8,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var y8=z.object({name:z.string().optional(),description:z.string().optional(),tools:z.array(z.string()).optional(),model:z.string().optional()}).passthrough(),GU=bc({feature:"agents",frontmatterSchema:y8,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var _8=z.object({name:z.string().describe('Item name (e.g. "auth", "code-review")')}),R8=z.object({name:z.string().describe('Item name (e.g. "auth", "code-review")'),frontmatter:z.record(z.string(),z.unknown()).describe("YAML frontmatter fields (e.g. { description, globs, targets })"),body:z.string().describe("Markdown body content"),dry_run:z.boolean().optional().describe("Preview changes without writing to disk")}),I8=z.object({}).strict();function rS(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:I8,handler:s(n=>e.list(n),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:_8,handler:s((n,o)=>e.get(n,o),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:R8,handler:s((n,o)=>e.create(n,o),"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.object({name:z.string().describe("Name of the item to update"),frontmatter:z.record(z.string(),z.unknown()).optional().describe("New frontmatter fields (replaces by default; set merge=true to shallow-merge)"),body:z.string().optional().describe("New markdown body (omit to preserve existing)"),merge:z.boolean().optional().describe("If true, shallow-merge frontmatter instead of replacing"),dry_run:z.boolean().optional().describe("Preview changes without writing to disk")}),handler:s((n,o)=>e.update(n,o),"handler")},{name:`delete_${t}`,description:`Delete a ${t}. For rules: deleting _root requires force=true.`,inputSchema:z.object({name:z.string().describe("Name of the item to delete"),force:z.boolean().optional().describe("Required to delete protected files like _root"),dry_run:z.boolean().optional().describe("Preview without deleting")}),handler:s((n,o)=>e.delete(n,o),"handler")}]}s(rS,"canonicalTools");var jU=[...rS("rule",MU),...rS("command",$U),...rS("agent",GU)];async function BU(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new G("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(n){throw n.code==="ENOENT"?new G("NOT_FOUND",`skill file not found: ${t.filePath}`):new G("IO_ERROR","failed to read skill file")}}s(BU,"safeRead");var A8=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,w8=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,zU=z.object({name:z.string().optional(),description:z.string().optional()}).passthrough();function Rp(t){if(!A8.test(t))throw new G("INVALID_NAME",`invalid skill name: ${t}`)}s(Rp,"checkName");function sS(t){if(!w8.test(t)||t.includes("..")||t.includes("//"))throw new G("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(sS,"checkSupportPath");async function qf(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new G("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(qf,"atomicWrite");var VU=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),Ip=s((t,e)=>resolve(VU(t),e),"skillDir"),$a={async list(t){let e;try{e=(await readdir(VU(t.projectRoot),{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name);}catch{return []}let r=[];for(let n of e)try{let o=await readFile(resolve(Ip(t.projectRoot,n),"SKILL.md"),"utf8"),i=Ri(o).frontmatter;r.push({name:n,description:i.description??null});}catch{}return r},async get(t,{name:e}){Rp(e);let r=Ip(t.projectRoot,e);try{let n=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:o,body:i}=Ri(n),l=(await readdir(r)).filter(c=>c!=="SKILL.md").sort();return {name:e,frontmatter:o,body:i,supportingFiles:l}}catch(n){throw n.code==="ENOENT"?new G("NOT_FOUND",`skill "${e}" not found`):new G("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Rp(e),sS(r),{content:await BU({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Rp(e.name);let r=zU.safeParse(e.frontmatter);if(!r.success)throw new G("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let n=Ip(t.projectRoot,e.name),o=false;try{await stat(n),o=!0;}catch{}if(o)throw new G("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(sS),a.length+1>1e3)throw new G("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:n,written:false,supportingFilesWritten:[]};let l=resolve(n,"SKILL.md");await qf(l,wc(e.frontmatter,e.body));for(let[c,m]of Object.entries(i))await qf(resolve(n,c),m);return {path:n,written:true,supportingFilesWritten:a}},async update(t,e){Rp(e.name);let r=Ip(t.projectRoot,e.name),n;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");n=Ri(p);}catch(p){throw p.code==="ENOENT"?new G("NOT_FOUND",`skill "${e.name}" not found`):new G("IO_ERROR","failed to read skill")}let o=e.frontmatter===void 0?n.frontmatter:e.merge===true?{...n.frontmatter,...e.frontmatter}:e.frontmatter,i=zU.safeParse(o);if(!i.success)throw new G("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:n.body,l=e.supportingFiles??{};Object.keys(l).forEach(sS);let c=[],m=[];if(e.dry_run===true)return Object.entries(l).forEach(([p,u])=>(u===null?m:c).push(p)),{path:r,written:false,supportingFilesAffected:{written:c,deleted:m}};await qf(resolve(r,"SKILL.md"),wc(o,a));for(let[p,u]of Object.entries(l)){let f=resolve(r,p);if(u===null)try{await rm(f),m.push(p);}catch{}else await qf(f,u),c.push(p);}return {path:r,written:true,supportingFilesAffected:{written:c,deleted:m}}},async delete(t,{name:e,dry_run:r}){Rp(e);let n=Ip(t.projectRoot,e);try{await stat(n);}catch{throw new G("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:n,deleted:false}:(await rm(n,{recursive:true}),{path:n,deleted:true})}};var b8=z.object({}).strict(),P8=z.object({name:z.string().describe("Item name")}),JU=[{name:"list_skills",description:"List skills",inputSchema:b8,handler:s(t=>$a.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:P8,handler:s((t,e)=>$a.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.object({name:z.string().describe("Skill name"),path:z.string().describe('Relative path within the skill directory (e.g. "helper.md")')}),handler:s((t,e)=>$a.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.object({name:z.string().describe("Skill name (becomes directory name)"),frontmatter:z.record(z.string(),z.unknown()).describe("YAML frontmatter for SKILL.md"),body:z.string().describe("Markdown body for SKILL.md"),supportingFiles:z.record(z.string(),z.string()).optional().describe("Map of relative-path \u2192 content for supporting files"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>$a.create(t,e),"handler")},{name:"update_skill",description:"Update a skill. supportingFiles: string value writes/replaces, null deletes, unlisted files are untouched.",inputSchema:z.object({name:z.string().describe("Skill name"),frontmatter:z.record(z.string(),z.unknown()).optional().describe("New frontmatter (replaces by default; merge=true to shallow-merge)"),body:z.string().optional().describe("New body (omit to preserve existing)"),merge:z.boolean().optional().describe("Shallow-merge frontmatter instead of replacing"),supportingFiles:z.record(z.string(),z.union([z.string(),z.null()])).optional().describe("Map of path \u2192 content (string=write, null=delete, absent=keep)"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>$a.update(t,e),"handler")},{name:"delete_skill",description:"Delete a skill",inputSchema:z.object({name:z.string(),dry_run:z.boolean().optional()}),handler:s((t,e)=>$a.delete(t,e),"handler")}];async function YU(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new G("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new G("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(YU,"safeConfigWrite");Ro();zc();async function Sp(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new G("IO_ERROR","failed to read yaml")}}s(Sp,"readYaml");async function Tc(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new G("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(Tc,"atomicWrite");var Xe={async getConfig(t){let e=await Sp(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new G("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await vr(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await Sp(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Sp(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 Sp(resolve(t.projectRoot,"agentsmesh.yaml"))??{},n={...r},o=s((c,m)=>{m!==void 0&&(n[c]=e.merge===true&&Array.isArray(r[c])?Array.from(new Set([...r[c],...m])):m);},"apply");o("targets",e.targets),o("features",e.features),e.conversions!==void 0&&(n.conversions=e.merge===true&&r.conversions!==void 0?{...r.conversions,...e.conversions}:e.conversions);let i=ki.safeParse(n);if(!i.success)throw new G("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(n);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await YU({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await vr(r).catch(()=>null)??{mcpServers:{}};if(n.mcpServers[e.name]!==void 0)throw new G("ALREADY_EXISTS",`server "${e.name}" exists`);return n.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await Tc(r,JSON.stringify(n,null,2)+`
594
- `),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await vr(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new G("NOT_FOUND",`server "${e.name}" not found`);return n.mcpServers[e.name]=e.merge===true?{...n.mcpServers[e.name],...e.server}:e.server,e.dry_run===true?{path:r,written:false}:(await Tc(r,JSON.stringify(n,null,2)+`
595
- `),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await vr(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new G("NOT_FOUND",`server "${e.name}" not found`);return delete n.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await Tc(r,JSON.stringify(n,null,2)+`
596
- `),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),n=await Sp(r)??{allow:[],deny:[],ask:[]},o={...n},i=s((a,l)=>{l!==void 0&&(o[a]=e.mode==="append"?Array.from(new Set([...n[a]??[],...l])):l);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await Tc(r,stringify(o)),{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 Tc(r,stringify(e.hooks)),{path:r,written:true})},async updateIgnore(t,e){let r=resolve(t.projectRoot,".agentsmesh/ignore"),n;if(e.mode==="append"){let o=(await readFile(r,"utf8").catch(()=>"")).split(/\r?\n/).filter(Boolean);n=Array.from(new Set([...o,...e.patterns]));}else n=e.patterns;return e.dry_run===true?{path:r,written:false}:(await Tc(r,n.join(`
596
+ ${e}`}s(Dc,"serializeMd");var N8=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,F8={rules:"_root"};function lg(t){if(!N8.test(t)||t.includes(".."))throw new v("INVALID_NAME",`invalid name: ${t}`)}s(lg,"checkName");function cg(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(cg,"pathFor");function Nc(t){let{feature:e,frontmatterSchema:r,toSummary:n}=t,o=s(l=>resolve(l,".agentsmesh",e),"featureDir");async function i(l){try{return (await readdir(o(l),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(l){try{return await stat(l),!0}catch{return false}}return s(a,"exists"),{async list(l){let c=await i(l.projectRoot),m=[];for(let p of c){let u=p.replace(/\.md$/,""),f=await readFile(join(o(l.projectRoot),p),"utf8"),{frontmatter:g}=Ii(f);m.push(n(u,g));}return m},async get(l,{name:c}){lg(c);let m=cg(l.projectRoot,e,c);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=Ii(p);return {name:c,frontmatter:u,body:f}}catch(p){let u=p.code;throw u==="ENOENT"?new v("NOT_FOUND",`${e} "${c}" not found`):new v("IO_ERROR",`failed to read ${e}`,{errno:u})}},async create(l,{name:c,frontmatter:m,body:p,dry_run:u}){lg(c);let f=r.safeParse(m);if(!f.success)throw new v("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=cg(l.projectRoot,e,c);if(await a(g))throw new v("ALREADY_EXISTS",`${e} "${c}" exists`);if((await i(l.projectRoot)).length>=1e3)throw new v("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let I=Dc(m,p);return u===true?{path:g,written:false}:(await aS({projectRoot:l.projectRoot,feature:e,relativePath:`${c}.md`,content:I}),{path:g,written:true})},async update(l,{name:c,frontmatter:m,body:p,merge:u,dry_run:f}){lg(c);let g=cg(l.projectRoot,e,c),h;try{let P=await readFile(g,"utf8");h=Ii(P);}catch(P){let N=P.code;throw N==="ENOENT"?new v("NOT_FOUND",`${e} "${c}" not found`):new v("IO_ERROR",`failed to read ${e}`,{errno:N})}let I=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,k=r.safeParse(I);if(!k.success)throw new v("VALIDATION_FAILED","invalid frontmatter",k.error.issues);let C=p!==void 0?p:h.body,R=Dc(I,C);return f===true?{path:g,written:false}:(await aS({projectRoot:l.projectRoot,feature:e,relativePath:`${c}.md`,content:R}),{path:g,written:true})},async delete(l,{name:c,force:m,dry_run:p}){if(lg(c),F8[e]===c&&m!==true)throw new v("PROTECTED_FILE",`${e} "${c}" requires force: true`);let u=cg(l.projectRoot,e,c);if(!await a(u))throw new v("NOT_FOUND",`${e} "${c}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(Nc,"createCanonicalHandlers");var v8=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(),ZU=Nc({feature:"rules",frontmatterSchema:v8,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var M8=z$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),QU=Nc({feature:"commands",frontmatterSchema:M8,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var $8=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(),qU=Nc({feature:"agents",frontmatterSchema:$8,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var G8=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")')}),j8=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")}),U8=z$1.object({}).strict();function cS(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:U8,handler:s(n=>e.list(n),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:G8,handler:s((n,o)=>e.get(n,o),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:j8,handler:s((n,o)=>e.create(n,o),"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((n,o)=>e.update(n,o),"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((n,o)=>e.delete(n,o),"handler")}]}s(cS,"canonicalTools");var t0=[...cS("rule",ZU),...cS("command",QU),...cS("agent",qU)];async function r0(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new v("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(n){throw n.code==="ENOENT"?new v("NOT_FOUND",`skill file not found: ${t.filePath}`):new v("IO_ERROR","failed to read skill file")}}s(r0,"safeRead");var J8=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,Y8=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,i0=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function Tp(t){if(!J8.test(t))throw new v("INVALID_NAME",`invalid skill name: ${t}`)}s(Tp,"checkName");function uS(t){if(!Y8.test(t)||t.includes("..")||t.includes("//"))throw new v("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(uS,"checkSupportPath");async function ug(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new v("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(ug,"atomicWrite");var a0=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),xp=s((t,e)=>resolve(a0(t),e),"skillDir"),Ua={async list(t){let e;try{e=(await readdir(a0(t.projectRoot),{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name);}catch{return []}let r=[];for(let n of e)try{let o=await readFile(resolve(xp(t.projectRoot,n),"SKILL.md"),"utf8"),i=Ii(o).frontmatter;r.push({name:n,description:i.description??null});}catch{}return r},async get(t,{name:e}){Tp(e);let r=xp(t.projectRoot,e);try{let n=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:o,body:i}=Ii(n),l=(await readdir(r)).filter(c=>c!=="SKILL.md").sort();return {name:e,frontmatter:o,body:i,supportingFiles:l}}catch(n){throw n.code==="ENOENT"?new v("NOT_FOUND",`skill "${e}" not found`):new v("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Tp(e),uS(r),{content:await r0({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Tp(e.name);let r=i0.safeParse(e.frontmatter);if(!r.success)throw new v("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let n=xp(t.projectRoot,e.name),o=false;try{await stat(n),o=!0;}catch{}if(o)throw new v("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(uS),a.length+1>1e3)throw new v("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:n,written:false,supportingFilesWritten:[]};let l=resolve(n,"SKILL.md");await ug(l,Dc(e.frontmatter,e.body));for(let[c,m]of Object.entries(i))await ug(resolve(n,c),m);return {path:n,written:true,supportingFilesWritten:a}},async update(t,e){Tp(e.name);let r=xp(t.projectRoot,e.name),n;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");n=Ii(p);}catch(p){throw p.code==="ENOENT"?new v("NOT_FOUND",`skill "${e.name}" not found`):new v("IO_ERROR","failed to read skill")}let o=e.frontmatter===void 0?n.frontmatter:e.merge===true?{...n.frontmatter,...e.frontmatter}:e.frontmatter,i=i0.safeParse(o);if(!i.success)throw new v("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:n.body,l=e.supportingFiles??{};Object.keys(l).forEach(uS);let c=[],m=[];if(e.dry_run===true)return Object.entries(l).forEach(([p,u])=>(u===null?m:c).push(p)),{path:r,written:false,supportingFilesAffected:{written:c,deleted:m}};await ug(resolve(r,"SKILL.md"),Dc(o,a));for(let[p,u]of Object.entries(l)){let f=resolve(r,p);if(u===null)try{await rm$1(f),m.push(p);}catch{}else await ug(f,u),c.push(p);}return {path:r,written:true,supportingFilesAffected:{written:c,deleted:m}}},async delete(t,{name:e,dry_run:r}){Tp(e);let n=xp(t.projectRoot,e);try{await stat(n);}catch{throw new v("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:n,deleted:false}:(await rm$1(n,{recursive:true}),{path:n,deleted:true})}};var X8=z$1.object({}).strict(),Z8=z$1.object({name:z$1.string().describe("Item name")}),l0=[{name:"list_skills",description:"List skills",inputSchema:X8,handler:s(t=>Ua.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:Z8,handler:s((t,e)=>Ua.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)=>Ua.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)=>Ua.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)=>Ua.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)=>Ua.delete(t,e),"handler")}];async function c0(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new v("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new v("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(c0,"safeConfigWrite");So();Xc();async function Dp(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new v("IO_ERROR","failed to read yaml")}}s(Dp,"readYaml");async function vc(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new v("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(vc,"atomicWrite");var rr={async getConfig(t){let e=await Dp(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new v("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await jr(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await Dp(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Dp(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 Dp(resolve(t.projectRoot,"agentsmesh.yaml"))??{},n={...r},o=s((c,m)=>{m!==void 0&&(n[c]=e.merge===true&&Array.isArray(r[c])?Array.from(new Set([...r[c],...m])):m);},"apply");o("targets",e.targets),o("features",e.features),e.conversions!==void 0&&(n.conversions=e.merge===true&&r.conversions!==void 0?{...r.conversions,...e.conversions}:e.conversions);let i=Li.safeParse(n);if(!i.success)throw new v("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(n);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await c0({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await jr(r).catch(()=>null)??{mcpServers:{}};if(n.mcpServers[e.name]!==void 0)throw new v("ALREADY_EXISTS",`server "${e.name}" exists`);return n.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await vc(r,JSON.stringify(n,null,2)+`
597
+ `),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await jr(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new v("NOT_FOUND",`server "${e.name}" not found`);return n.mcpServers[e.name]=e.merge===true?{...n.mcpServers[e.name],...e.server}:e.server,e.dry_run===true?{path:r,written:false}:(await vc(r,JSON.stringify(n,null,2)+`
598
+ `),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await jr(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new v("NOT_FOUND",`server "${e.name}" not found`);return delete n.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await vc(r,JSON.stringify(n,null,2)+`
599
+ `),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),n=await Dp(r)??{allow:[],deny:[],ask:[]},o={...n},i=s((a,l)=>{l!==void 0&&(o[a]=e.mode==="append"?Array.from(new Set([...n[a]??[],...l])):l);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await vc(r,stringify(o)),{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 vc(r,stringify(e.hooks)),{path:r,written:true})},async updateIgnore(t,e){let r=resolve(t.projectRoot,".agentsmesh/ignore"),n;if(e.mode==="append"){let o=(await readFile(r,"utf8").catch(()=>"")).split(/\r?\n/).filter(Boolean);n=Array.from(new Set([...o,...e.patterns]));}else n=e.patterns;return e.dry_run===true?{path:r,written:false}:(await vc(r,n.join(`
597
600
  `)+`
598
- `),{path:r,written:true})}};var z8=/[;&|`$<>!\\\r\n]/u,V8=/^[A-Za-z_][A-Za-z0-9_]*$/u,J8=/^[A-Za-z][A-Za-z0-9_-]*$/u,Y8=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,QU=/[\r\n]/u,qU=/[\0\r\n]/u;function X8(t){return qU.test(t)?false:!t.split(/[/\\]/u).includes("..")}s(X8,"isSafeMcpCwd");function Z8(t){return z.string().min(1).max(512).refine(e=>!z8.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(Z8,"noShellMeta");var lS=z.object({type:z.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z.string().max(1024).refine(t=>!qU.test(t),{message:"description must not contain NUL or newline characters"}).optional(),command:Z8("command").optional(),args:z.array(z.string().max(2048)).max(100).optional(),env:z.record(z.string().regex(V8,"env key must be a valid identifier"),z.string().max(8192)).optional(),url:z.string().url().max(2048).refine(t=>/^https?:\/\//u.test(t),{message:"url must use http(s) protocol"}).optional(),headers:z.record(z.string().regex(J8,"header name must be a valid identifier"),z.string().max(8192)).optional(),cwd:z.string().max(2048).refine(X8,{message:'cwd must not contain "..", NUL, or newline characters'}).optional(),disabled:z.boolean().optional(),timeout:z.number().int().nonnegative().max(36e5).optional()}).strict(),Q8=z.object({type:z.enum(["command","prompt"]).optional(),command:z.string().min(1).max(8192).optional(),prompt:z.string().min(1).max(8192).optional(),timeout:z.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"}),t0=z.string().max(256).refine(t=>!QU.test(t),{message:"hook matcher must not contain newlines"}),q8=z.object({matcher:t0,type:z.enum(["command","prompt"]).optional(),command:z.string().min(1).max(8192).optional(),prompt:z.string().min(1).max(8192).optional(),timeout:z.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"}),t9=z.object({matcher:t0,hooks:z.array(Q8).min(1).max(50)}).strict(),e9=z.union([q8,t9]),e0=z.record(z.string().min(1).max(64),z.array(e9).max(100)),r9=z.string().min(1).max(256).refine(t=>!QU.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>Y8.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),eg=z.array(r9).max(500);var Cp=z.object({}).strict(),n9=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Cp,handler:s(t=>Xe.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Cp,handler:s(t=>Xe.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Cp,handler:s(t=>Xe.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Cp,handler:s(t=>Xe.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Cp,handler:s(t=>Xe.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],o9=[{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.object({targets:z.array(z.string()).optional().describe('Target tool IDs (e.g. ["claude-code", "cursor"])'),features:z.array(z.string()).optional().describe('Feature names (e.g. ["rules", "commands", "mcp"])'),conversions:z.record(z.string(),z.unknown()).optional().describe("Conversion overrides"),merge:z.boolean().optional().describe("If true, union arrays and shallow-merge objects instead of replacing"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Xe.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.object({name:z.string().describe('Server name (e.g. "github", "filesystem")'),server:lS.describe('Server config (e.g. { type: "stdio", command: "npx", args: [...], env: {...} })'),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Xe.addMcpServer(t,e),"handler")},{name:"update_mcp_server",description:"Update an MCP server entry (replace or merge)",inputSchema:z.object({name:z.string(),server:lS,merge:z.boolean().optional(),dry_run:z.boolean().optional()}),handler:s((t,e)=>Xe.updateMcpServer(t,e),"handler")},{name:"remove_mcp_server",description:"Remove an MCP server entry",inputSchema:z.object({name:z.string(),dry_run:z.boolean().optional()}),handler:s((t,e)=>Xe.removeMcpServer(t,e),"handler")},{name:"update_permissions",description:"Update permissions.yaml. mode=replace (default) overwrites listed fields; mode=append unions and dedups.",inputSchema:z.object({allow:eg.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:eg.optional().describe("Denied tool patterns"),ask:eg.optional().describe("Tools requiring confirmation"),mode:z.enum(["replace","append"]).optional().describe("replace=overwrite, append=union+dedup (default: replace)"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Xe.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.object({hooks:e0.describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Xe.updateHooks(t,e),"handler")},{name:"update_ignore",description:"Update .agentsmesh/ignore patterns. mode=replace (default) overwrites; mode=append adds new patterns.",inputSchema:z.object({patterns:z.array(z.string()).describe('Gitignore-syntax patterns (e.g. ["node_modules/", "dist/", ".env*"])'),mode:z.enum(["replace","append"]).optional().describe("replace=overwrite, append=add (default: replace)"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Xe.updateIgnore(t,e),"handler")}],r0=[...n9,...o9];VR();Rn();function s9(){return Object.fromEntries(Ft.map(t=>[t,Object.fromEntries(Object.entries(o$).map(([e,r])=>[e,r[t]]))]))}s(s9,"buildTargetIndex");var n0=s9(),cS={async list(){return n0},async get(t){let e=n0[t.targetId];if(e===void 0)throw new G("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};_o();_o();Dp();Yt();fo();fn();se();Rn();async function mS(t,e){let r=et(t);if(!r)throw new _n(t,{supported:[...Ft,...Yp().map(n=>n.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(mS,"importFrom");async function xc(t,e={}){let r=e.scope??"project",{config:n,context:o}=await yt(t,r);await Wt(n,t);let{canonical:i}=await ke(n,o.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},o.canonicalDir);return {config:n,canonical:i,projectRoot:o.rootBase,scope:r,configDir:o.configDir,canonicalDir:o.canonicalDir}}s(xc,"loadProjectContext");async function pS(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return Of(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(pS,"lint");async function uS(t){let e=await Tr(t);return {...Ef(e),results:e}}s(uS,"diff");async function dS(t){return Af(t)}s(dS,"check");_o();fo();Ai();Dp();Pt();se();Et();w();function Ii(t){if(t instanceof G)throw t;if(t instanceof _n)throw new G("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new G("VALIDATION_FAILED",e):/lock/i.test(e)?new G("LOCK_HELD","generate lock is held"):new G("IO_ERROR","engine failure",{reason:e})}s(Ii,"wrapEngineError");async function o0(t,e){if(e.dry_run===true)throw new G("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 mS(e.from,{root:t.projectRoot,scope:"project"});return {imported:r.length,files:r.map(n=>({fromPath:n.fromPath,toPath:n.toPath,feature:n.feature})),warnings:[],errors:[]}}catch(r){if(r instanceof _n)throw new G("VALIDATION_FAILED",`unknown target "${e.from}"`);let n=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(n))throw new G("VALIDATION_FAILED",n);Ii(r);}}s(o0,"importFromTarget");async function s0(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},n=await Vf(r,t.projectRoot);return {filesAffected:n.data.summary.created+n.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let n=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(n))throw new G("VALIDATION_FAILED",n);Ii(r);}}s(s0,"convert");async function c9(t,e){try{let r=await xc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,i=(await Tr({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:n})).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=yc(r.projectRoot,m.path,m.target);await I(p,m.content);}let l={};for(let m of a){let p=l[m.target]??{filesWritten:0};l[m.target]={filesWritten:p.filesWritten+1};}let c={filesWritten:a.length,byTarget:l,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(c.files=i.map(m=>m.path)),c}catch(r){Ii(r);}}s(c9,"generate");async function m9(t,e){try{let r=await xc(t.projectRoot),n=await pS({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope});return {issues:(e.severity?n.diagnostics.filter(i=>i.level===e.severity):n.diagnostics).map(i=>({level:i.level,file:i.file,target:i.target,message:i.message}))}}catch(r){Ii(r);}}s(m9,"lint");async function p9(t){try{let e=await xc(t.projectRoot),r=await dS({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){Ii(e);}}s(p9,"check");async function u9(t,e){try{let r=await xc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,o=await uS({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:n});return {willCreate:o.summary.new,willModify:o.summary.updated,willDelete:o.summary.deleted}}catch(r){Ii(r);}}s(u9,"diff");var Ga={generate:c9,lint:m9,check:p9,diff:u9,import:o0,convert:s0};var i0=z.object({}).strict(),a0=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:i0,handler:s(()=>cS.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.object({targetId:z.string().describe('Target tool ID (e.g. "claude-code", "cursor")')}),handler:s((t,e)=>cS.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.object({targets:z.array(z.string()).optional().describe("Filter to specific targets (default: all from agentsmesh.yaml)"),features:z.array(z.string()).optional().describe("Filter to specific features"),verbose:z.boolean().optional().describe("Include full file list in response"),dry_run:z.boolean().optional().describe("Preview without writing files")}),handler:s((t,e)=>Ga.generate(t,e),"handler")},{name:"lint",description:"Lint canonical .agentsmesh/ files for schema errors, missing frontmatter, and other issues",inputSchema:z.object({severity:z.enum(["error","warning","info"]).optional().describe("Filter results by minimum severity")}),handler:s((t,e)=>Ga.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:i0,handler:s(t=>Ga.check(t),"handler")},{name:"diff",description:"Preview what generate would create, modify, or delete without writing",inputSchema:z.object({targets:z.array(z.string()).optional().describe("Filter to specific targets"),features:z.array(z.string()).optional().describe("Filter to specific features")}),handler:s((t,e)=>Ga.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.object({from:z.string().describe('Source target ID to import from (e.g. "cursor", "claude-code")'),features:z.array(z.string()).optional().describe("Restrict import to specific features"),dry_run:z.boolean().optional().describe("NOT SUPPORTED \u2014 will throw VALIDATION_FAILED. Use diff instead.")}),handler:s((t,e)=>Ga.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.object({from:z.string().describe('Source target ID (e.g. "cursor")'),to:z.string().describe('Destination target ID (e.g. "claude-code")'),dry_run:z.boolean().optional().describe("Preview conversion without writing files")}),handler:s((t,e)=>Ga.convert(t,e),"handler")}];function fS(t){if(t instanceof G)throw t;let e=t instanceof Error?t.message:String(t),r=Jf(e);throw /lock|LockAcquisitionError/i.test(r)?new G("LOCK_HELD",".install.lock is held by another process"):/missing source|usage:|non-interactive|invalid|unknown|not found|escapes the source root/i.test(r)?new G("VALIDATION_FAILED",r):new G("IO_ERROR","install pipeline failure",{reason:r})}s(fS,"wrapInstallError");function d9(t){let e={force:true};return t.path!==void 0&&(e.path=t.path),t.target!==void 0&&(e.target=t.target),t.as!==void 0&&(e.as=t.as),t.name!==void 0&&(e.name=t.name),t.extends===true&&(e.extends=true),t.all===true&&(e.all=true),t.sync===true&&(e.sync=true),t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(d9,"toInstallFlags");function f9(t){let e={force:true};return t.all===true&&(e.all=true),t.keep_pack===true&&(e["keep-pack"]=true),t.keep_generated===true&&(e["keep-generated"]=true),t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(f9,"toUninstallFlags");async function g9(t,e){if(typeof e.source!="string"||e.source.trim().length===0)throw new G("VALIDATION_FAILED","install: `source` is required");try{let r=await _p(d9(e),[e.source],t.projectRoot);if(r.exitCode!==0)throw new G("IO_ERROR",`install exited ${r.exitCode}`);return r.data}catch(r){fS(r);}}s(g9,"install");async function h9(t,e){if(e.all!==true&&(!Array.isArray(e.names)||e.names.length===0))throw new G("VALIDATION_FAILED","uninstall: pass `names: [...]` or set `all: true`");try{return (await Kf(f9(e),e.names??[],t.projectRoot)).data}catch(r){fS(r);}}s(h9,"uninstall");async function y9(t,e={}){try{let r={};return e.global===!0&&(r.global=!0),(await Wf(r,t.projectRoot)).data}catch(r){fS(r);}}s(y9,"installsList");var rg={install:g9,uninstall:h9,installsList:y9};var _9=z.object({source:z.string().min(1).describe("Pack source \u2014 GitHub/GitLab shorthand (`github:org/repo[@ref]`), git URL, SSH URL, or local path (`local:./relative/dir`)."),path:z.string().optional().describe("Subdirectory within the source repo to install from. Combined with `as` for manual single-category installs."),target:z.string().optional().describe("Target tool ID hint for native-format auto-discovery (e.g. `claude-code`, `cursor`). Bypasses the multi-signal classifier."),as:z.enum(["rules","commands","agents","skills"]).optional().describe("Manual install kind. When set, the source is treated as a flat collection of that category (skips the auto-classifier)."),name:z.string().optional().describe("Override the generated install entry name (default: derived from `org-repo` shorthand or the source path)."),extends:z.boolean().optional().describe("Record as an `extends:` entry in `agentsmesh.yaml` instead of materializing a pack in `.agentsmesh/packs/`. Always-on-latest semantics; resolved every `generate`."),all:z.boolean().optional().describe("Install every sub-pack from a marketplace source (`.claude-plugin/marketplace.json`) or every flat collection in a multi-collection layout."),sync:z.boolean().optional().describe("Reinstall missing packs from `.agentsmesh/installs.yaml` instead of from `source`."),dry_run:z.boolean().optional().describe("Preview what would be installed without writing."),global:z.boolean().optional().describe("Install into the global scope (`~/.agentsmesh/`) instead of the project scope. Regenerates user-level outputs.")}),R9=z.object({names:z.array(z.string().min(1)).default([]).describe("Install names to remove (from `installs.yaml`). Required unless `all: true`. Each name removes the pack directory under `.agentsmesh/packs/`, the matching `installs.yaml` row, and the matching `agentsmesh.yaml` `extends:` row when present."),all:z.boolean().optional().describe("Remove every install in the current scope. `names` is ignored when `all: true`."),keep_pack:z.boolean().optional().describe("Leave `.agentsmesh/packs/<name>/` on disk; only drop yaml entries. Useful when the user has locally-modified files."),keep_generated:z.boolean().optional().describe("Skip the post-uninstall `generate` pass. Target trees keep now-stale files until the next manual `generate`; a warning lists what will be cleaned then."),dry_run:z.boolean().optional().describe("Preview the removal plan; no writes. Legacy-manifest migration runs in memory only."),global:z.boolean().optional().describe("Uninstall from the global scope (`~/.agentsmesh/`) instead of the project scope.")}),I9=z.object({global:z.boolean().optional().describe("Read from `~/.agentsmesh/installs.yaml` instead of the project scope.")}),l0=[{name:"install",description:"Install a community pack from a URL or local path. Auto-classifies the source layout (anthropic-skill-pack, canonical-agentsmesh, tool-native, or unknown) and dispatches accordingly; `--target` / `--as` override the classifier. Always runs non-interactively (every prompt accepts its documented `--force` default).",inputSchema:_9,handler:s((t,e)=>rg.install(t,e),"handler")},{name:"uninstall",description:"Remove one or more installed packs. Drops the pack directory, the `installs.yaml` row, and the matching `agentsmesh.yaml` `extends:` row (when present), then runs `generate` so stale target files are cleaned. Mid-batch failures are isolated; survivors still apply and the response surfaces failures in `data.failed[]`.",inputSchema:R9,handler:s((t,e)=>rg.uninstall(t,e),"handler")},{name:"installs_list",description:"List installed packs in the current scope. Read-only. Hydrates `installed_at` and `source_type` from each pack manifest where available; both are `null` for legacy packs without `.agentsmesh-install-manifest.json`.",inputSchema:I9,handler:s((t,e)=>rg.installsList(t,e),"handler"),resourceUri:"agentsmesh://installs"}];function c0(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(c0,"zodToMcpSchema");var ng=[...jU,...JU,...r0,...a0,...l0],gS=ng.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")}));Ai();async function E9(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 G("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(E9,"findProjectRoot");async function hS(t){let e=await E9(t.cwd);return {projectRoot:e,loadCanonical:s(()=>Ee(e),"loadCanonical")}}s(hS,"resolveContext");async function N9(){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(N9,"pkgVersion");function F9(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(F9,"matchTemplate");function v9(t,e){let r=[...t.matchAll(/\{([^}]+)\}/g)].map(i=>i[1]),o=new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").exec(e);return o?Object.fromEntries(r.map((i,a)=>[i,o[a+1]])):{}}s(v9,"extractTemplateParams");async function p0(){let t=new Server({name:"agentsmesh-mcp",version:await N9()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:ng.map(e=>({name:e.name,description:e.description,inputSchema:c0(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=ng.find(n=>n.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 n=r.inputSchema.safeParse(e.params.arguments??{});if(!n.success)throw new G("VALIDATION_FAILED","invalid input",n.error.issues);let o=await hS({cwd:process.cwd()}),i=await r.handler(o,n.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(n){let o=n instanceof G?n.toEnvelope():{code:"IO_ERROR",message:Jf(n instanceof Error?n.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(o)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:gS.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=gS.find(a=>a.uri===e.params.uri||F9(a.uri,e.params.uri));if(!r)throw new G("NOT_FOUND",`resource not found: ${e.params.uri}`);let n=await hS({cwd:process.cwd()}),o=v9(r.uri,e.params.uri),i=await r.read(n,o);return {contents:[{uri:e.params.uri,mimeType:"application/json",text:JSON.stringify(i)}]}}),await t.connect(new StdioServerTransport);}s(p0,"startServer");ot();async function u0(t,e){CS(),await p0();}s(u0,"runMcp");var d0={generate:s(async(t,e)=>{let r=await _c(t,void 0,{printMatrix:t.json!==true});ge("generate",r,t,()=>Rc(r));},"generate"),init:s(async(t,e)=>{let r=await k$(process.cwd(),{yes:t.yes===true,global:t.global===true});ge("init",r,t,()=>E$(r));},"init"),import:s(async(t,e)=>{let r=await O$(t);ge("import",r,t,()=>v$(r));},"import"),diff:s(async(t,e)=>{let r=await w$(t);ge("diff",r,t,()=>M$(r));},"diff"),lint:s(async(t,e)=>{let r=await D$(t);ge("lint",r,t,()=>N$(r));},"lint"),check:s(async(t,e)=>{let r=await U$(t);ge("check",r,t,()=>F$(r));},"check"),merge:s(async(t,e)=>{let r=await W$(t);ge("merge",r,t,()=>$$(r));},"merge"),matrix:s(async(t,e)=>{let r=await ip(t);ge("matrix",r,t,()=>lp(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){Ha("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await j$(t),n=s(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",n),process.on("SIGTERM",n);},"watch"),install:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await Qj(t,e,process.cwd());ge("install",r,t,()=>qj(r));},"install"),uninstall:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await fU(t,e,process.cwd());ge("uninstall",r,t,()=>gU(r));},"uninstall"),installs:s(async(t,e)=>{let r=await yU(t,e,process.cwd());ge("installs",r,t,()=>_U(r));},"installs"),plugin:s(async(t,e)=>{let r=await CU(t,e,process.cwd());ge("plugin",r,t,()=>kU(r));},"plugin"),target:s(async(t,e)=>{let r=await xU(t,e,process.cwd());ge("target",r,t,()=>DU(r));},"target"),convert:s(async(t,e)=>{let r=await Vf(t);ge("convert",r,t,()=>NU(r));},"convert"),mcp:s(async(t,e)=>{await u0();},"mcp")};function G9(t){let e={},r=[],n="help";for(let o=0;o<t.length;o++){let i=t[o];if(n==="help"&&i==="--version")return {command:"version",flags:{},args:[]};if(n==="help"&&i==="--help")return {command:"help",flags:{},args:[]};if(i.startsWith("--")){let a=i.slice(2),l=t[o+1];l===void 0||l.startsWith("--")?e[a]=true:(e[a]=l,o++);continue}n==="help"?n=i:r.push(i);}return {command:n,flags:e,args:r}}s(G9,"parseArgs");var j9=RS(d0);async function U9(t){let{command:e,flags:r,args:n}=t;if(e==="help"){ag();return}if(e==="version"){ES();return}if(r.help===true){Lp(e);return}r.json===true&&SS(),await j9.route(e,r,n);}s(U9,"main");function B9(){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(B9,"isMainModule");if(B9()){let t=G9(process.argv.slice(2));U9(t).catch(e=>LS(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
599
- export{G9 as parseArgs};
601
+ `),{path:r,written:true})}};var d9=/[;&|`$<>!\\\r\n]/u,f9=/^[A-Za-z_][A-Za-z0-9_]*$/u,g9=/^[A-Za-z][A-Za-z0-9_-]*$/u,h9=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,u0=/[\r\n]/u,d0=/[\0\r\n]/u;function y9(t){return d0.test(t)?false:!t.split(/[/\\]/u).includes("..")}s(y9,"isSafeMcpCwd");function _9(t){return z$1.string().min(1).max(512).refine(e=>!d9.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(_9,"noShellMeta");var gS=z$1.object({type:z$1.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z$1.string().max(1024).refine(t=>!d0.test(t),{message:"description must not contain NUL or newline characters"}).optional(),command:_9("command").optional(),args:z$1.array(z$1.string().max(2048)).max(100).optional(),env:z$1.record(z$1.string().regex(f9,"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(g9,"header name must be a valid identifier"),z$1.string().max(8192)).optional(),cwd:z$1.string().max(2048).refine(y9,{message:'cwd must not contain "..", NUL, or newline characters'}).optional(),disabled:z$1.boolean().optional(),timeout:z$1.number().int().nonnegative().max(36e5).optional()}).strict(),R9=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"}),f0=z$1.string().max(256).refine(t=>!u0.test(t),{message:"hook matcher must not contain newlines"}),I9=z$1.object({matcher:f0,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"}),S9=z$1.object({matcher:f0,hooks:z$1.array(R9).min(1).max(50)}).strict(),C9=z$1.union([I9,S9]),g0=z$1.record(z$1.string().min(1).max(64),z$1.array(C9).max(100)),k9=z$1.string().min(1).max(256).refine(t=>!u0.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>h9.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),fg=z$1.array(k9).max(500);var Np=z$1.object({}).strict(),E9=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Np,handler:s(t=>rr.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Np,handler:s(t=>rr.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Np,handler:s(t=>rr.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Np,handler:s(t=>rr.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Np,handler:s(t=>rr.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],L9=[{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)=>rr.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:gS.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)=>rr.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:gS,merge:z$1.boolean().optional(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>rr.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)=>rr.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:fg.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:fg.optional().describe("Denied tool patterns"),ask:fg.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)=>rr.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:g0.describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>rr.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)=>rr.updateIgnore(t,e),"handler")}],h0=[...E9,...L9];aI();Sn();function O9(){return Object.fromEntries(vt.map(t=>[t,Object.fromEntries(Object.entries(p$).map(([e,r])=>[e,r[t]]))]))}s(O9,"buildTargetIndex");var y0=O9(),hS={async list(){return y0},async get(t){let e=y0[t.targetId];if(e===void 0)throw new v("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};Io();Io();zp();Zt();ho();Mr();ae();Sn();async function yS(t,e){let r=ot(t);if(!r)throw new In(t,{supported:[...vt,...lu().map(n=>n.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(yS,"importFrom");async function Mc(t,e={}){let r=e.scope??"project",{config:n,context:o}=await yt(t,r);await Gt(n,t);let{canonical:i}=await Ee(n,o.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},o.canonicalDir);return {config:n,canonical:i,projectRoot:o.rootBase,scope:r,configDir:o.configDir,canonicalDir:o.canonicalDir}}s(Mc,"loadProjectContext");async function _S(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return Gf(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(_S,"lint");async function RS(t){let e=await vr(t);return {...Mf(e),results:e}}s(RS,"diff");async function IS(t){return jf(t)}s(IS,"check");Io();ho();bi();zp();Pt();ae();Ot();A();function Si(t){if(t instanceof v)throw t;if(t instanceof In)throw new v("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new v("VALIDATION_FAILED",e):/lock/i.test(e)?new v("LOCK_HELD","generate lock is held"):new v("IO_ERROR","engine failure",{reason:e})}s(Si,"wrapEngineError");async function _0(t,e){if(e.dry_run===true)throw new v("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 yS(e.from,{root:t.projectRoot,scope:"project"});return {imported:r.length,files:r.map(n=>({fromPath:n.fromPath,toPath:n.toPath,feature:n.feature})),warnings:[],errors:[]}}catch(r){if(r instanceof In)throw new v("VALIDATION_FAILED",`unknown target "${e.from}"`);let n=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(n))throw new v("VALIDATION_FAILED",n);Si(r);}}s(_0,"importFromTarget");async function R0(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},n=await ag(r,t.projectRoot);return {filesAffected:n.data.summary.created+n.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let n=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(n))throw new v("VALIDATION_FAILED",n);Si(r);}}s(R0,"convert");async function P9(t,e){try{let r=await Mc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,i=(await vr({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:n})).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=_c(r.projectRoot,m.path,m.target);await S(p,m.content);}let l={};for(let m of a){let p=l[m.target]??{filesWritten:0};l[m.target]={filesWritten:p.filesWritten+1};}let c={filesWritten:a.length,byTarget:l,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(c.files=i.map(m=>m.path)),c}catch(r){Si(r);}}s(P9,"generate");async function T9(t,e){try{let r=await Mc(t.projectRoot),n=await _S({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope});return {issues:(e.severity?n.diagnostics.filter(i=>i.level===e.severity):n.diagnostics).map(i=>({level:i.level,file:i.file,target:i.target,message:i.message}))}}catch(r){Si(r);}}s(T9,"lint");async function x9(t){try{let e=await Mc(t.projectRoot),r=await IS({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){Si(e);}}s(x9,"check");async function D9(t,e){try{let r=await Mc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,o=await RS({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:n});return {willCreate:o.summary.new,willModify:o.summary.updated,willDelete:o.summary.deleted}}catch(r){Si(r);}}s(D9,"diff");var Ba={generate:P9,lint:T9,check:x9,diff:D9,import:_0,convert:R0};var I0=z$1.object({}).strict(),S0=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:I0,handler:s(()=>hS.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)=>hS.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:I0,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 SS(t){if(t instanceof v)throw t;let e=t instanceof Error?t.message:String(t),r=xc(e);throw /lock|LockAcquisitionError/i.test(r)?new v("LOCK_HELD",".install.lock is held by another process"):/missing source|usage:|non-interactive|invalid|unknown|not found|escapes the source root/i.test(r)?new v("VALIDATION_FAILED",r):new v("IO_ERROR","install pipeline failure",{reason:r})}s(SS,"wrapInstallError");function N9(t){let e={force:true};return t.path!==void 0&&(e.path=t.path),t.target!==void 0&&(e.target=t.target),t.as!==void 0&&(e.as=t.as),t.name!==void 0&&(e.name=t.name),t.extends===true&&(e.extends=true),t.all===true&&(e.all=true),t.sync===true&&(e.sync=true),t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(N9,"toInstallFlags");function F9(t){let e={force:true};return t.all===true&&(e.all=true),t.keep_pack===true&&(e["keep-pack"]=true),t.keep_generated===true&&(e["keep-generated"]=true),t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(F9,"toUninstallFlags");async function v9(t,e){if(typeof e.source!="string"||e.source.trim().length===0)throw new v("VALIDATION_FAILED","install: `source` is required");try{let r=await Ga(N9(e),[e.source],t.projectRoot);if(r.exitCode!==0)throw new v("IO_ERROR",`install exited ${r.exitCode}`);return r.data}catch(r){SS(r);}}s(v9,"install");async function M9(t,e){if(e.all!==true&&(!Array.isArray(e.names)||e.names.length===0))throw new v("VALIDATION_FAILED","uninstall: pass `names: [...]` or set `all: true`");try{return (await rg(F9(e),e.names??[],t.projectRoot)).data}catch(r){SS(r);}}s(M9,"uninstall");async function $9(t,e={}){try{let r={};return e.global===!0&&(r.global=!0),(await og(r,t.projectRoot)).data}catch(r){SS(r);}}s($9,"installsList");var gg={install:v9,uninstall:M9,installsList:$9};function G9(t){let e={force:true};return t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(G9,"toRefreshFlags");function j9(t){if(t instanceof v)throw t;let e=t instanceof Error?t.message:String(t),r=xc(e);throw /lock|LockAcquisitionError/i.test(r)?new v("LOCK_HELD",".install.lock is held by another process"):/unknown pack|not found|usage:/i.test(r)?new v("VALIDATION_FAILED",r):/resolve|network|fetch/i.test(r)?new v("REFRESH_RESOLVE_FAILED",r):/materialize|apply|manifest-update/i.test(r)?new v("REFRESH_APPLY_FAILED",r):new v("IO_ERROR","refresh pipeline failure",{reason:r})}s(j9,"wrapRefreshError");async function U9(t,e={}){try{let r=await ng(G9(e),[...e.names??[]],t.projectRoot);if(r.exitCode===2){let n=r.data.failed[0],o=e.names??[],i=n?.error??(o.length>0?`unknown pack(s): ${o.join(", ")}`:"refresh validation failed");throw new v("VALIDATION_FAILED",i)}return r.data}catch(r){j9(r);}}s(U9,"refresh");var C0={refresh:U9};var B9=z$1.object({source:z$1.string().min(1).describe("Pack source \u2014 GitHub/GitLab shorthand (`github:org/repo[@ref]`), git URL, SSH URL, or local path (`local:./relative/dir`)."),path:z$1.string().optional().describe("Subdirectory within the source repo to install from. Combined with `as` for manual single-category installs."),target:z$1.string().optional().describe("Target tool ID hint for native-format auto-discovery (e.g. `claude-code`, `cursor`). Bypasses the multi-signal classifier."),as:z$1.enum(["rules","commands","agents","skills"]).optional().describe("Manual install kind. When set, the source is treated as a flat collection of that category (skips the auto-classifier)."),name:z$1.string().optional().describe("Override the generated install entry name (default: derived from `org-repo` shorthand or the source path)."),extends:z$1.boolean().optional().describe("Record as an `extends:` entry in `agentsmesh.yaml` instead of materializing a pack in `.agentsmesh/packs/`. Always-on-latest semantics; resolved every `generate`."),all:z$1.boolean().optional().describe("Install every sub-pack from a marketplace source (`.claude-plugin/marketplace.json`) or every flat collection in a multi-collection layout."),sync:z$1.boolean().optional().describe("Reinstall missing packs from `.agentsmesh/installs.yaml` instead of from `source`."),dry_run:z$1.boolean().optional().describe("Preview what would be installed without writing."),global:z$1.boolean().optional().describe("Install into the global scope (`~/.agentsmesh/`) instead of the project scope. Regenerates user-level outputs.")}),K9=z$1.object({names:z$1.array(z$1.string().min(1)).default([]).describe("Install names to remove (from `installs.yaml`). Required unless `all: true`. Each name removes the pack directory under `.agentsmesh/packs/`, the matching `installs.yaml` row, and the matching `agentsmesh.yaml` `extends:` row when present."),all:z$1.boolean().optional().describe("Remove every install in the current scope. `names` is ignored when `all: true`."),keep_pack:z$1.boolean().optional().describe("Leave `.agentsmesh/packs/<name>/` on disk; only drop yaml entries. Useful when the user has locally-modified files."),keep_generated:z$1.boolean().optional().describe("Skip the post-uninstall `generate` pass. Target trees keep now-stale files until the next manual `generate`; a warning lists what will be cleaned then."),dry_run:z$1.boolean().optional().describe("Preview the removal plan; no writes. Legacy-manifest migration runs in memory only."),global:z$1.boolean().optional().describe("Uninstall from the global scope (`~/.agentsmesh/`) instead of the project scope.")}),W9=z$1.object({global:z$1.boolean().optional().describe("Read from `~/.agentsmesh/installs.yaml` instead of the project scope.")}),H9=z$1.object({names:z$1.array(z$1.string().min(1)).optional().describe("Pack names to refresh. Omit or pass empty array to refresh every installed pack in the current scope."),dry_run:z$1.boolean().optional().describe("Preview the refresh plan (resolved refs, drift detection) without writing."),global:z$1.boolean().optional().describe("Refresh packs in the global scope (`~/.agentsmesh/`) instead of the project scope.")}),k0=[{name:"install",description:"Install a community pack from a URL or local path. Auto-classifies the source layout (anthropic-skill-pack, canonical-agentsmesh, tool-native, or unknown) and dispatches accordingly; `--target` / `--as` override the classifier. Always runs non-interactively (every prompt accepts its documented `--force` default).",inputSchema:B9,handler:s((t,e)=>gg.install(t,e),"handler")},{name:"uninstall",description:"Remove one or more installed packs. Drops the pack directory, the `installs.yaml` row, and the matching `agentsmesh.yaml` `extends:` row (when present), then runs `generate` so stale target files are cleaned. Mid-batch failures are isolated; survivors still apply and the response surfaces failures in `data.failed[]`.",inputSchema:K9,handler:s((t,e)=>gg.uninstall(t,e),"handler")},{name:"installs_list",description:"List installed packs in the current scope. Read-only. Hydrates `installed_at` and `source_type` from each pack manifest where available; both are `null` for legacy packs without `.agentsmesh-install-manifest.json`.",inputSchema:W9,handler:s((t,e)=>gg.installsList(t,e),"handler"),resourceUri:"agentsmesh://installs"},{name:"refresh",description:"Re-fetch and re-apply installed packs against their originally-recorded source/ref. Branch pins re-resolve to the current tip; tag pins re-resolve in case the tag moved; SHA pins stay put. Per-pack atomic via `materializePack` \u2014 a failure leaves the affected pack at its prior state. Always runs non-interactively (force: true) over MCP.",inputSchema:H9,handler:s((t,e)=>C0.refresh(t,e),"handler")}];function E0(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(E0,"zodToMcpSchema");var hg=[...t0,...l0,...h0,...S0,...k0],CS=hg.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")}));bi();async function Y9(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 v("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(Y9,"findProjectRoot");async function kS(t){let e=await Y9(t.cwd);return {projectRoot:e,loadCanonical:s(()=>Oe(e),"loadCanonical")}}s(kS,"resolveContext");async function s6(){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(s6,"pkgVersion");function i6(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(i6,"matchTemplate");function a6(t,e){let r=[...t.matchAll(/\{([^}]+)\}/g)].map(i=>i[1]),o=new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").exec(e);return o?Object.fromEntries(r.map((i,a)=>[i,o[a+1]])):{}}s(a6,"extractTemplateParams");async function O0(){let t=new Server({name:"agentsmesh-mcp",version:await s6()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:hg.map(e=>({name:e.name,description:e.description,inputSchema:E0(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=hg.find(n=>n.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 n=r.inputSchema.safeParse(e.params.arguments??{});if(!n.success)throw new v("VALIDATION_FAILED","invalid input",n.error.issues);let o=await kS({cwd:process.cwd()}),i=await r.handler(o,n.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(n){let o=n instanceof v?n.toEnvelope():{code:"IO_ERROR",message:xc(n instanceof Error?n.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(o)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:CS.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=CS.find(a=>a.uri===e.params.uri||i6(a.uri,e.params.uri));if(!r)throw new v("NOT_FOUND",`resource not found: ${e.params.uri}`);let n=await kS({cwd:process.cwd()}),o=a6(r.uri,e.params.uri),i=await r.read(n,o);return {contents:[{uri:e.params.uri,mimeType:"application/json",text:JSON.stringify(i)}]}}),await t.connect(new StdioServerTransport);}s(O0,"startServer");st();async function w0(t,e){bS(),await O0();}s(w0,"runMcp");var A0={generate:s(async(t,e)=>{let r=await Rc(t,void 0,{printMatrix:t.json!==true});ie("generate",r,t,()=>Ic(r));},"generate"),init:s(async(t,e)=>{let r=await P$(process.cwd(),{yes:t.yes===true,global:t.global===true});ie("init",r,t,()=>T$(r));},"init"),import:s(async(t,e)=>{let r=await D$(t);ie("import",r,t,()=>K$(r));},"import"),diff:s(async(t,e)=>{let r=await F$(t);ie("diff",r,t,()=>W$(r));},"diff"),lint:s(async(t,e)=>{let r=await j$(t);ie("lint",r,t,()=>U$(r));},"lint"),check:s(async(t,e)=>{let r=await J$(t);ie("check",r,t,()=>B$(r));},"check"),merge:s(async(t,e)=>{let r=await Z$(t);ie("merge",r,t,()=>H$(r));},"merge"),matrix:s(async(t,e)=>{let r=await mp(t);ie("matrix",r,t,()=>up(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){za("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await V$(t),n=s(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",n),process.on("SIGTERM",n);},"watch"),install:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await nU(t,e,process.cwd());ie("install",r,t,()=>oU(r));},"install"),uninstall:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await _U(t,e,process.cwd());ie("uninstall",r,t,()=>RU(r));},"uninstall"),refresh:s(async(t,e)=>{let r=await AU(t,e,process.cwd());ie("refresh",r,t,()=>bU(r));},"refresh"),installs:s(async(t,e)=>{let r=await TU(t,e,process.cwd());ie("installs",r,t,()=>xU(r));},"installs"),plugin:s(async(t,e)=>{let r=await vU(t,e,process.cwd());ie("plugin",r,t,()=>MU(r));},"plugin"),target:s(async(t,e)=>{let r=await zU(t,e,process.cwd());ie("target",r,t,()=>VU(r));},"target"),convert:s(async(t,e)=>{let r=await ag(t);ie("convert",r,t,()=>JU(r));},"convert"),mcp:s(async(t,e)=>{await w0();},"mcp")};function m6(t){let e={},r=[],n="help";for(let o=0;o<t.length;o++){let i=t[o];if(n==="help"&&i==="--version")return {command:"version",flags:{},args:[]};if(n==="help"&&i==="--help")return {command:"help",flags:{},args:[]};if(i.startsWith("--")){let a=i.slice(2),l=t[o+1];l===void 0||l.startsWith("--")?e[a]=true:(e[a]=l,o++);continue}n==="help"?n=i:r.push(i);}return {command:n,flags:e,args:r}}s(m6,"parseArgs");var p6=OS(A0);async function u6(t){let{command:e,flags:r,args:n}=t;if(e==="help"){Sg();return}if(e==="version"){TS();return}if(r.help===true){$p(e);return}r.json===true&&AS(),await p6.route(e,r,n);}s(u6,"main");function d6(){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(d6,"isMainModule");if(d6()){let t=m6(process.argv.slice(2));u6(t).catch(e=>xS(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
602
+ export{m6 as parseArgs};