agentsmesh 0.21.0 → 0.22.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,203 +1,207 @@
1
1
  #!/usr/bin/env node
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,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 iC 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 WZ from'chokidar';import*as mj 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 xS=Object.defineProperty;var s=(t,e)=>xS(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Cg=(t,e)=>{for(var r in e)xS(t,r,{get:e[r],enumerable:true});};function FS(){Li=true;}function vS(){NS=true;}function za(t){NS?process.stderr.write(t):process.stdout.write(t);}function M0(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function Uc(t,e){return M0()?e:`${t}${e}${Va.reset}`}function $0(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Va,Li,NS,y,ot=d(()=>{Va={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},Li=false,NS=false;s(FS,"muteLogger");s(vS,"redirectLoggerToStderr");s(za,"out");s(M0,"noColor");s(Uc,"c");s($0,"pad");y={info(t){Li||za(Uc(Va.cyan,t)+`
3
- `);},warn(t){Li||process.stderr.write(Uc(Va.yellow,"\u26A0 ")+t+`
4
- `);},error(t){Li||process.stderr.write(Uc(Va.red,"\u2717 ")+t+`
5
- `);},success(t){Li||za(Uc(Va.green,"\u2713 ")+t+`
6
- `);},debug(t){Li||process.env.AGENTSMESH_DEBUG==="1"&&za(Uc(Va.cyan,"[debug] ")+t+`
7
- `);},table(t){if(Li||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("+")+"+";za(n+`
8
- `);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>$0(l,r[c])).join(" | ")+" |";za(a+`
9
- `);}za(n+`
10
- `);}};});var Ro,$r,Ya,In,Xa,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;}},Ya=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;}},Xa=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 Kp(t){let e=extname(t).toLowerCase();if(e.length>0)return H0.has(e);let r=basename(t).toLowerCase();return z0.has(r)}function Wp(t){return t.replace(/\r\n?/g,`
11
- `)}function Og(t){return V0.has(extname(t).toLowerCase())?493:void 0}var Za,H0,z0,V0,Hp=d(()=>{Za="\uFEFF",H0=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),z0=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(Kp,"shouldNormalizeLineEndings");s(Wp,"normalizeLineEndings");V0=new Set([".sh",".bash",".zsh"]);s(Og,"executableModeFor");});function HS(t){if(t.length>eB)return true;let e=new Map;for(let r of t){let n=(e.get(r)??0)+1;if(n>=rB)return true;e.set(r,n);}return false}async function G(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(HS(u))continue;l.push(...await G(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 Es(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(HS(l))continue;o.push(...await Es(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 wg(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 eB,rB,Ag=d(()=>{Io();eB=32,rB=3;s(HS,"shouldSkipRecursiveBranch");s(G,"readDirRecursive");s(Es,"readDirRecursiveNoSymlinks");s(wg,"ensureCacheSymlink");});async function _(t){try{let e=await readFile(t,"utf-8");return e.startsWith(Za)?e.slice(Za.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=Kp(t)?Wp(e):e,a=r?.mode??Og(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();Hp();Ag();Hp();s(_,"readFileSafe");s(S,"writeFileAtomic");s(j,"exists");s(O,"mkdirp");});function Fe(t){return bg.includes(t)}var bg,YS=d(()=>{bg=["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 $t,Pg,Sn=d(()=>{YS();$t=bg,Pg="codex-cli";});var XS,nr,Qa,pB,Kc,uB,dB,Bc,fB,gB,wi,So=d(()=>{Sn();XS=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],nr=z$1.enum($t),Qa=z$1.enum(XS),pB=z$1.enum(["rules","commands","agents","skills"]),Kc=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(),uB=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:nr.optional(),as:pB.optional(),features:z$1.array(Qa),path:z$1.string().optional(),pick:Kc.optional()}),dB=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),Bc=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),fB=z$1.object({commands_to_skills:z$1.object({"codex-cli":Bc.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":Bc.optional(),cline:Bc.optional(),"codex-cli":Bc.optional(),windsurf:Bc.optional()}).passthrough().optional()}).strict().optional(),gB=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(),wi=z$1.object({version:z$1.literal(1),targets:z$1.array(nr).default([...$t]),features:z$1.array(Qa).default([...XS]),extends:z$1.array(uB).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:dB.default({strategy:"merge",lock_features:[]}),conversions:fB,plugins:z$1.array(gB).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function _B(t){let e=resolve(t);for(;;){let r=join(e,xg);if(await j(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}async function RB(t){let e=await _(t);if(e===null)throw new $r(t);let r=parse(e),n=wi.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new Ya(t,o,{cause:n.error})}return n.data}function Tg(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null||IB.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]=Tg(i,o):r[n]=o;}return r}function SB(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=Tg(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Tg(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function Vp(t){let e=join(t,xg),r=await RB(e),n=join(t,yB),o=await _(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=SB(r,i),l=wi.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 Jp(t){let e=await _B(t);if(e===null)throw new $r(join(t,xg));return Vp(dirname(e))}var xg,yB,IB,Yp=d(()=>{A();ot();Io();So();xg="agentsmesh.yaml",yB="agentsmesh.local.yaml";s(_B,"findConfigPath");s(RB,"loadConfig");IB=new Set(["__proto__","constructor","prototype"]);s(Tg,"deepMergeObjects");s(SB,"mergeLocalConfig");s(Vp,"loadConfigFromExactDir");s(Jp,"loadConfigFromDir");});function Ai(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 Jp(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Ai(t,e);try{let{config:n}=await Vp(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(()=>{Yp();Io();s(Ai,"resolveScopeContext");s(yt,"loadScopedConfig");});function qa(t){return t.replace(kB,(e,r,n,o)=>`${r}***@${o}`)}var kB,Ng=d(()=>{kB=/([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^/@\s"'<>]+)@([^\s"'<>]+)/g;s(qa,"redactUrlSecrets");});function eC(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function Xp(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,qS),u=`${m}.tmp`,f=join(u,qS);if(!r.refresh&&await tC(p))return Mg(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await TB(PB(t),f),t.ref&&await xB(f,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),Mg(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await tC(p)){let R=g instanceof Error?g.message:String(g);return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${qa(R)}`),Mg(p)}throw g instanceof Error?Object.assign(new Error(qa(g.message)),{cause:g.cause}):g}}async function Mg(t){return {resolvedPath:t,version:await DB(t)}}async function tC(t){return j(t)}function PB(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 TB(t,e){eC(t,"clone-url"),await $g(["clone",t,e]);}async function xB(t,e){eC(e,"ref"),await $g(["checkout",e],t);}async function DB(t){return $g(["rev-parse","HEAD"],t)}async function $g(t,e){let{stdout:r}=await bB("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var bB,qS,Gg=d(()=>{A();Ng();bB=promisify(execFile),qS="repo";s(eC,"ensureNotFlag");s(Xp,"fetchGitRemoteExtend");s(Mg,"readCachedRepo");s(tC,"hasCachedRepo");s(PB,"resolveCloneUrl");s(TB,"cloneRepo");s(xB,"checkoutRef");s(DB,"getHeadSha");s($g,"runGit");});function MB(){let t=process.env.AGENTSMESH_MAX_TARBALL_MB;if(t===void 0||t==="")return Hc*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 ${Hc} MiB.`),Hc*1024*1024):e<nC||e>oC?(console.warn(`[agentsmesh] AGENTSMESH_MAX_TARBALL_MB=${e} is outside [${nC}, ${oC}]; using default ${Hc} MiB.`),Hc*1024*1024):e*1024*1024}async function GB(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 aC(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 lC(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 aC(t.org,t.repo,a);}catch(I){if(!i)throw I;return UB(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 I=await jg(p);if(I)return {resolvedPath:join(p,I),version:c}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,f={};a&&(f.Authorization=`Bearer ${a}`);let g;try{let I=await globalThis.fetch(u,{headers:f,redirect:"follow"});if(!I.ok)throw new Error(`HTTP ${I.status}: ${I.statusText}`);g=await GB(I,$B);}catch(I){if(r.allowOfflineFallback!==false&&await j(p)){let b=await jg(p);if(b){let N=I instanceof Error?I.message:String(I);return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${qa(N)}`),{resolvedPath:join(p,b),version:c}}}throw I instanceof Error?Object.assign(new Error(qa(I.message)),{cause:I.cause}):I}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 iC.extract({file:h,cwd:p,strict:!0,filter:s((I,C)=>{if(jB(I))return !1;let b=C&&"type"in C?C.type:void 0;return b==="File"||b==="Directory"},"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let R=await jg(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 jg(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}function sC(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function jB(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function UB(t,e,r,n,o,i){let a=i?[sC(t.org,t.repo,i)]:[sC(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 Xp(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}var Hc,nC,oC,$B,cC=d(()=>{A();Ng();Gg();Hc=500,nC=1,oC=4096;s(MB,"resolveMaxTarballBytes");$B=MB();s(GB,"readBoundedResponse");s(aC,"resolveLatestTag");s(lC,"fetchGithubRemoteExtend");s(jg,"findExtractTopDir");s(sC,"buildGithubCloneUrl");s(jB,"isZipSlipPath");s(UB,"fetchGithubDefaultBranch");});function mC(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 pC(t){let e=mC(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 uC(t){let e=mC(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 dC(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}let a=process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="1"||process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="true",l=process.env.AGENTSMESH_ALLOW_LOCAL_GIT==="1"||process.env.AGENTSMESH_ALLOW_LOCAL_GIT==="true",c=["https:","ssh:"];return a&&c.push("http:"),l&&c.push("file:"),c.includes(i.protocol)?{url:n,ref:o}:null}function bi(t){let e=pC(t);if(e)return {kind:"github",...e};let r=uC(t);if(r)return {kind:"gitlab",...r};let n=dC(t);return n?{kind:"git",...n}:null}function Ug(t){return bi(t)!==null}var zc=d(()=>{s(mC,"splitSourceRef");s(pC,"parseGithubSource");s(uC,"parseGitlabSource");s(dC,"parseGitSource");s(bi,"parseRemoteSource");s(Ug,"isSupportedRemoteSource");});function HB(t){let e=bi(t);return e?e.kind==="github"?tl("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?tl("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):tl("git",e.url,e.ref??"HEAD"):null}async function hC(t,e){let r=HB(t);if(!r)return;let n=e??ve(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}async function yC(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 Bg=d(()=>{Vc();zc();s(HB,"cacheKeyFromSource");s(hC,"cleanInstallCache");s(yC,"sweepStaleCache");});function tl(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>IC){let i=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,IC-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 el(t,e,r={}){let n=bi(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 yC(o).catch(()=>{}),n.kind==="github"?lC(n,e,r,o,tl,!t.includes("@")):Xp(n,e,r,o,tl)}var IC,Vc=d(()=>{Gg();cC();zc();Bg();IC=80;s(tl,"buildCacheKey");s(ve,"getCacheDir");s(el,"fetchRemoteExtend");});function XB(t){return t.startsWith("http://")||t.startsWith("https://")}async function rl(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Ug(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(XB(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(Ug(o.source)){let a=await el(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 Zp=d(()=>{A();Vc();zc();s(XB,"isOtherRemoteSource");s(rl,"resolveExtendPaths");});function P(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 qB(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:P(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:qB(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 x(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,writeFileSync}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 IC 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 DQ from'chokidar';import*as Nj 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';import'picomatch';var VI=Object.defineProperty;var s=(t,e)=>VI(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Dg=(t,e)=>{for(var r in e)VI(t,r,{get:e[r],enumerable:true});};function XI(){wi=true;}function ZI(){YI=true;}function Ya(t){YI?process.stderr.write(t):process.stdout.write(t);}function cB(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function Hc(t,e){return cB()?e:`${t}${e}${Xa.reset}`}function mB(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Xa,wi,YI,y,ot=d(()=>{Xa={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},wi=false,YI=false;s(XI,"muteLogger");s(ZI,"redirectLoggerToStderr");s(Ya,"out");s(cB,"noColor");s(Hc,"c");s(mB,"pad");y={info(t){wi||Ya(Hc(Xa.cyan,t)+`
3
+ `);},warn(t){wi||process.stderr.write(Hc(Xa.yellow,"\u26A0 ")+t+`
4
+ `);},error(t){wi||process.stderr.write(Hc(Xa.red,"\u2717 ")+t+`
5
+ `);},success(t){wi||Ya(Hc(Xa.green,"\u2713 ")+t+`
6
+ `);},debug(t){wi||process.env.AGENTSMESH_DEBUG==="1"&&Ya(Hc(Xa.cyan,"[debug] ")+t+`
7
+ `);},table(t){if(wi||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("+")+"+";Ya(n+`
8
+ `);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>mB(l,r[c])).join(" | ")+" |";Ya(a+`
9
+ `);}Ya(n+`
10
+ `);}};});var So,Gr,Qa,Cn,qa,Fe,Io=d(()=>{So=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},Gr=class extends So{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;}},Qa=class extends So{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;}},Cn=class extends So{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;}},qa=class extends So{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;}},Fe=class extends So{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 Xp(t){let e=extname(t).toLowerCase();if(e.length>0)return yB.has(e);let r=basename(t).toLowerCase();return _B.has(r)}function Zp(t){return t.replace(/\r\n?/g,`
11
+ `)}function Mg(t){return RB.has(extname(t).toLowerCase())?493:void 0}var tl,yB,_B,RB,Qp=d(()=>{tl="\uFEFF",yB=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),_B=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(Xp,"shouldNormalizeLineEndings");s(Zp,"normalizeLineEndings");RB=new Set([".sh",".bash",".zsh"]);s(Mg,"executableModeFor");});function iC(t){if(t.length>wB)return true;let e=new Map;for(let r of t){let n=(e.get(r)??0)+1;if(n>=AB)return true;e.set(r,n);}return false}async function G(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 Fe(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(iC(u))continue;l.push(...await G(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 Fe(t,`Failed to read directory ${t}: ${l.message}. Check permissions.`,{cause:a,errnoCode:l.code})}}async function Os(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(iC(l))continue;o.push(...await Os(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 Fe(t,`Failed to read directory ${t}: ${o.message}. Check permissions.`,{cause:n,errnoCode:o.code})}}async function $g(t,e){let r=resolve(t);try{if(!(await lstat(e)).isSymbolicLink()||resolve(dirname(e),await readlink(e))===r)return;await unlink(e);}catch(n){if(n.code!=="ENOENT")throw n}await symlink(r,e,"dir");}var wB,AB,Gg=d(()=>{Io();wB=32,AB=3;s(iC,"shouldSkipRecursiveBranch");s(G,"readDirRecursive");s(Os,"readDirRecursiveNoSymlinks");s($g,"ensureCacheSymlink");});async function _(t){try{let e=await readFile(t,"utf-8");return e.startsWith(tl)?e.slice(tl.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new Fe(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 Fe(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 Fe||l.code!=="ENOENT")throw l}let o=`${t}.tmp`,i=Xp(t)?Zp(e):e,a=r?.mode??Mg(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 Fe(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();Qp();Gg();Qp();s(_,"readFileSafe");s(I,"writeFileAtomic");s(j,"exists");s(O,"mkdirp");});function ve(t){return jg.includes(t)}var jg,mC=d(()=>{jg=["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(ve,"isBuiltinTargetId");});var $t,Ug,kn=d(()=>{mC();$t=jg,Ug="codex-cli";});var pC,or,el,MB,Vc,$B,GB,zc,jB,UB,bi,Co=d(()=>{kn();pC=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],or=z$1.enum($t),el=z$1.enum(pC),MB=z$1.enum(["rules","commands","agents","skills"]),Vc=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(),$B=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:or.optional(),as:MB.optional(),features:z$1.array(el),path:z$1.string().optional(),pick:Vc.optional()}),GB=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),zc=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),jB=z$1.object({commands_to_skills:z$1.object({"codex-cli":zc.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":zc.optional(),cline:zc.optional(),"codex-cli":zc.optional(),windsurf:zc.optional()}).passthrough().optional()}).strict().optional(),UB=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(),bi=z$1.object({version:z$1.literal(1),targets:z$1.array(or).default([...$t]),features:z$1.array(el).default([...pC]),extends:z$1.array($B).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:GB.default({strategy:"merge",lock_features:[]}),conversions:jB,plugins:z$1.array(UB).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function WB(t){let e=resolve(t);for(;;){let r=join(e,Kg);if(await j(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}async function HB(t){let e=await _(t);if(e===null)throw new Gr(t);let r=parse(e),n=bi.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new Qa(t,o,{cause:n.error})}return n.data}function Bg(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null||zB.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]=Bg(i,o):r[n]=o;}return r}function VB(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=Bg(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Bg(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function tu(t){let e=join(t,Kg),r=await HB(e),n=join(t,KB),o=await _(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=VB(r,i),l=bi.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 eu(t){let e=await WB(t);if(e===null)throw new Gr(join(t,Kg));return tu(dirname(e))}var Kg,KB,zB,ru=d(()=>{A();ot();Io();Co();Kg="agentsmesh.yaml",KB="agentsmesh.local.yaml";s(WB,"findConfigPath");s(HB,"loadConfig");zB=new Set(["__proto__","constructor","prototype"]);s(Bg,"deepMergeObjects");s(VB,"mergeLocalConfig");s(tu,"loadConfigFromExactDir");s(eu,"loadConfigFromDir");});function Pi(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 eu(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Pi(t,e);try{let{config:n}=await tu(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof Gr?new Gr(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(()=>{ru();Io();s(Pi,"resolveScopeContext");s(yt,"loadScopedConfig");});function rl(t){return t.replace(YB,(e,r,n,o)=>`${r}***@${o}`)}var YB,Hg=d(()=>{YB=/([a-zA-Z][a-zA-Z0-9+.-]*:\/\/)([^/@\s"'<>]+)@([^\s"'<>]+)/g;s(rl,"redactUrlSecrets");});function hC(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function nu(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,fC),u=`${m}.tmp`,f=join(u,fC);if(!r.refresh&&await gC(p))return Jg(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await nK(rK(t),f),t.ref&&await oK(f,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),Jg(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await gC(p)){let S=g instanceof Error?g.message:String(g);return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${rl(S)}`),Jg(p)}throw g instanceof Error?Object.assign(new Error(rl(g.message)),{cause:g.cause}):g}}async function Jg(t){return {resolvedPath:t,version:await sK(t)}}async function gC(t){return j(t)}function rK(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 nK(t,e){hC(t,"clone-url"),await Yg(["clone",t,e]);}async function oK(t,e){hC(e,"ref"),await Yg(["checkout",e],t);}async function sK(t){return Yg(["rev-parse","HEAD"],t)}async function Yg(t,e){let{stdout:r}=await eK("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var eK,fC,Xg=d(()=>{A();Hg();eK=promisify(execFile),fC="repo";s(hC,"ensureNotFlag");s(nu,"fetchGitRemoteExtend");s(Jg,"readCachedRepo");s(gC,"hasCachedRepo");s(rK,"resolveCloneUrl");s(nK,"cloneRepo");s(oK,"checkoutRef");s(sK,"getHeadSha");s(Yg,"runGit");});function cK(){let t=process.env.AGENTSMESH_MAX_TARBALL_MB;if(t===void 0||t==="")return Yc*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 ${Yc} MiB.`),Yc*1024*1024):e<_C||e>RC?(console.warn(`[agentsmesh] AGENTSMESH_MAX_TARBALL_MB=${e} is outside [${_C}, ${RC}]; using default ${Yc} MiB.`),Yc*1024*1024):e*1024*1024}async function pK(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 CC(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 kC(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 CC(t.org,t.repo,a);}catch(R){if(!i)throw R;return dK(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 R=await Zg(p);if(R)return {resolvedPath:join(p,R),version:c}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,f={};a&&(f.Authorization=`Bearer ${a}`);let g;try{let R=await globalThis.fetch(u,{headers:f,redirect:"follow"});if(!R.ok)throw new Error(`HTTP ${R.status}: ${R.statusText}`);g=await pK(R,mK);}catch(R){if(r.allowOfflineFallback!==false&&await j(p)){let b=await Zg(p);if(b){let N=R instanceof Error?R.message:String(R);return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${rl(N)}`),{resolvedPath:join(p,b),version:c}}}throw R instanceof Error?Object.assign(new Error(rl(R.message)),{cause:R.cause}):R}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 IC.extract({file:h,cwd:p,strict:!0,filter:s((R,k)=>{if(uK(R))return !1;let b=k&&"type"in k?k.type:void 0;return b==="File"||b==="Directory"},"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let S=await Zg(p);if(!S)throw new Error(`Extend "${e}": archive has no top-level directory. Expected a single top-level directory inside the archive.`);return {resolvedPath:join(p,S),version:c}}async function Zg(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}function SC(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function uK(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function dK(t,e,r,n,o,i){let a=i?[SC(t.org,t.repo,i)]:[SC(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 nu(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}var Yc,_C,RC,mK,EC=d(()=>{A();Hg();Xg();Yc=500,_C=1,RC=4096;s(cK,"resolveMaxTarballBytes");mK=cK();s(pK,"readBoundedResponse");s(CC,"resolveLatestTag");s(kC,"fetchGithubRemoteExtend");s(Zg,"findExtractTopDir");s(SC,"buildGithubCloneUrl");s(uK,"isZipSlipPath");s(dK,"fetchGithubDefaultBranch");});function LC(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 OC(t){let e=LC(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 wC(t){let e=LC(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}let a=process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="1"||process.env.AGENTSMESH_ALLOW_INSECURE_GIT==="true",l=process.env.AGENTSMESH_ALLOW_LOCAL_GIT==="1"||process.env.AGENTSMESH_ALLOW_LOCAL_GIT==="true",c=["https:","ssh:"];return a&&c.push("http:"),l&&c.push("file:"),c.includes(i.protocol)?{url:n,ref:o}:null}function xi(t){let e=OC(t);if(e)return {kind:"github",...e};let r=wC(t);if(r)return {kind:"gitlab",...r};let n=AC(t);return n?{kind:"git",...n}:null}function Qg(t){return xi(t)!==null}var Xc=d(()=>{s(LC,"splitSourceRef");s(OC,"parseGithubSource");s(wC,"parseGitlabSource");s(AC,"parseGitSource");s(xi,"parseRemoteSource");s(Qg,"isSupportedRemoteSource");});function yK(t){let e=xi(t);return e?e.kind==="github"?nl("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?nl("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):nl("git",e.url,e.ref??"HEAD"):null}async function xC(t,e){let r=yK(t);if(!r)return;let n=e??Me(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}async function TC(t,e){let r=t??Me(),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 qg=d(()=>{Zc();Xc();s(yK,"cacheKeyFromSource");s(xC,"cleanInstallCache");s(TC,"sweepStaleCache");});function nl(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 Me(){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 ol(t,e,r={}){let n=xi(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??Me();return TC(o).catch(()=>{}),n.kind==="github"?kC(n,e,r,o,nl,!t.includes("@")):nu(n,e,r,o,nl)}var FC,Zc=d(()=>{Xg();EC();Xc();qg();FC=80;s(nl,"buildCacheKey");s(Me,"getCacheDir");s(ol,"fetchRemoteExtend");});function CK(t){return t.startsWith("http://")||t.startsWith("https://")}async function sl(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Qg(o.source))){let o=Me();await rm$1(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(CK(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(Qg(o.source)){let a=await ol(o.source,o.name,{cacheDir:Me(),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 ou=d(()=>{A();Zc();Xc();s(CK,"isOtherRemoteSource");s(sl,"resolveExtendPaths");});function P(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 LK(t){if(t.indexOf("---")!==0)return t.trim();let e=t.indexOf("---",3);return e===-1?t.trim():t.slice(e+3).trim()}function jr(t,e){try{return {ok:!0,value:P(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:LK(t)}}}function ko(t,e,r){let n=jr(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 U=d(()=>{s(P,"parseFrontmatter");s(qB,"extractBody");s(Gr,"tryParseFrontmatter");s(Co,"parseOrSkipFrontmatter");s(x,"serializeFrontmatter");});function rK(t){let e=t.replace(/\.[^.]*$/,"").toUpperCase();return tK.has(e)}function SC(t){let e=[],r=t.split(/[\\/]/);for(let n of r)if(!(n===""||n==="."||n==="..")){if(eK.test(n)){e.push({segment:n,reason:"illegal-character"});continue}if(/[. ]$/.test(n)){e.push({segment:n,reason:"trailing-dot-or-space"});continue}rK(n)&&e.push({segment:n,reason:"reserved-name"});}return e}var tK,eK,CC=d(()=>{tK=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]),eK=new RegExp('[<>:"|?*\\u0000-\\u001F]');s(rK,"segmentReservedName");s(SC,"findWindowsPathIssues");});function ko(t,e){let r=SC(e);if(r.length===0)return;let n=r.map(o=>`${o.segment} (${o.reason})`).join(", ");throw new Qp(t,e,`canonical ${t} name "${e}" is not portable to Windows: ${n}. Rename the file.`)}function qp(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 Qp(t,m,`canonical ${t} files collide on slug "${m}": ${p} vs ${o}. Rename one.`);n.set(m,o);}}var Qp,Jc=d(()=>{CC();Qp=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(qp,"assertNoBasenameCollisions");});function nl(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();sK.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 sK,tu=d(()=>{ot();sK=new Set([".toml",".yaml",".yml",".json"]);s(nl,"warnIfUnrecognizedResourceFormats");});function EC(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function Ls(t,e={}){let r=await G(t),n=r.filter(i=>{if(!i.endsWith(".md"))return false;let a=basename(i,".md");return a==="_root"||!a.startsWith("_")});nl("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"&&iK.includes(g)?g:void 0,R=c.codex_emit,k=R==="execution"?"execution":R==="advisory"?"advisory":void 0,C=c.codex_instruction==="override"?"override":void 0;o.push({source:i,root:u||f,targets:EC(c.targets),description:typeof c.description=="string"?c.description:"",globs:EC(c.globs),body:m,...h!==void 0&&{trigger:h},...k!==void 0&&{codexEmit:k},...C!==void 0&&{codexInstructionVariant:C}});}return o}var iK,Yc=d(()=>{A();U();Jc();tu();iK=["always_on","model_decision","glob","manual"];s(EC,"toStrArray");s(Ls,"parseRules");});function OC(t){return t===true||t==="true"||t===1||t==="1"}function wC(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 Os(t,e={}){let r=await G(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));nl("commands",t,r,n,{handledByOtherReader:e.handledByOtherReader}),qp("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=wC(c.allowedTools),f=wC(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:OC(c.outputStyle)||OC(c["output-style"]),body:m});}return o}var Xc=d(()=>{A();U();Jc();tu();s(OC,"toBool");s(wC,"toToolsArray");s(Os,"parseCommands");});function Pi(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 bC(t){return t===true||t==="true"||t===1||t==="1"}function PC(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 aK(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function ws(t,e={}){let r=await G(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));nl("agents",t,r,n,{handledByOtherReader:e.handledByOtherReader}),qp("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=Pi(c.tools),f=Pi(c.tools),g=u.length>0?u:f,h=Pi(c.disallowedTools),R=Pi(c["disallowed-tools"]),k=h.length>0?h:R,I=Pi(c.mcpServers),C=Pi(c["mcp-servers"]),b=I.length>0?I:C,N=Pi(c.skills),T=PC(c.maxTurns),B=PC(c["max-turns"]),H=T>0?T: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:H,mcpServers:b,hooks:aK(c.hooks),skills:N,memory:typeof c.memory=="string"?c.memory:"",outputStyle:bC(c.outputStyle)||bC(c["output-style"]),body:m});}return o}var Zc=d(()=>{A();U();Jc();tu();s(Pi,"toStrArray");s(bC,"toBool");s(PC,"toInt");s(aK,"toHooks");s(ws,"parseAgents");});function Kg(t){let e=t.toLowerCase(),r=e.lastIndexOf("."),n=r>0?e.slice(0,r):e;return lK.get(n)}function Cn(t){return Kg(t)!==void 0}function eu(t){return Kg(t)==="preserved"}function ru(t){return Kg(t)==="noise"}function TC(t){return cK.has(t)}function xC(t){return mK.has(t)}var lK,cK,mK,Eo=d(()=>{lK=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"]]),cK=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]),mK=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]);s(Kg,"boilerplateKind");s(Cn,"isBoilerplate");s(eu,"isPreservedBoilerplate");s(ru,"isNoiseBoilerplate");s(TC,"isRepoNonContentDir");s(xC,"isRepoNonContentFile");});async function dK(t){return await _(t)??""}function gK(t){let e=t.lastIndexOf(".");return e<0?true:fK.has(t.slice(e).toLowerCase())}function yK(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function DC(t){let e=await Es(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===nu||i.endsWith(`/${nu}`))continue;let a=i.split("/")[0];if(hK.some(m=>a===m)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let l=i.includes("/")?i.slice(i.lastIndexOf("/")+1):i;if(gK(l)&&ru(l))continue;let c=await dK(n);r.push({relativePath:i,absolutePath:n,content:c});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}async function ou(t,e={}){let r=join(t,nu),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 DC(t),m=(typeof i.name=="string"?yK(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 As(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,nu),l=await _(a);if(!l)continue;let c=Co(l,a,e.onParseError);if(!c)continue;let{frontmatter:m,body:p}=c,u=await DC(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 nu,fK,hK,ol=d(()=>{A();Ag();U();Eo();Jc();s(dK,"readContent");nu="SKILL.md",fK=new Set([".md",".mdx",".rst",".txt"]);s(gK,"isMarkdownLikeDoc");hK=[".git","node_modules"];s(yK,"sanitizeSkillName");s(DC,"listSupportingFiles");s(ou,"parseSkillDirectory");s(As,"parseSkills");});function NC(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function _K(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=NC(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:NC(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 RK(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(RK(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=_K(a);l&&(o[i]=l);}return {mcpServers:o}}var Qc=d(()=>{A();s(NC,"parseStringMap");s(_K,"parseServer");s(RK,"stripJsonComments");s(jr,"parseMcp");});function Hg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function su(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=Hg(n.allow),i=Hg(n.deny),a=Hg(n.ask);return {allow:o,deny:i,ask:a}}var zg=d(()=>{A();s(Hg,"ensureStringArray");s(su,"parsePermissions");});function FC(t){return typeof t=="string"?t.trim():""}function Jt(t){return FC(t.command)}function Re(t){return FC(t.prompt)}function Vg(t){let e=Jt(t),r=Re(t);return t.type==="prompt"?r||e:e||r}function Lo(t){return Jt(t).length>0}function kn(t){return Vg(t).length>0}var Ur=d(()=>{s(FC,"trimString");s(Jt,"getHookCommand");s(Re,"getHookPrompt");s(Vg,"getHookText");s(Lo,"hasHookCommand");s(kn,"hasHookText");});function kK(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=Vg(e);if(!n)return null;let o=typeof e.type=="string"&&CK.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=Re(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}async function iu(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=kK(c);m&&l.push(m);}l.length>0&&(n[i]=l);}return n}var CK,Jg=d(()=>{A();Ur();CK=["command","prompt"];s(kK,"toHookEntry");s(iu,"parseHooks");});async function au(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 Yg=d(()=>{A();s(au,"parseIgnore");});async function we(t,e={}){let r=join(t,".agentsmesh"),n=await j(r)?r:t,[o,i,a,l,c,m,p,u]=await Promise.all([Ls(join(n,"rules"),e),Os(join(n,"commands"),e),ws(join(n,"agents"),e),As(join(n,"skills"),e),jr(join(n,"mcp.json")),su(join(n,"permissions.yaml")),iu(join(n,"hooks.yaml")),au(join(n,"ignore"))]);return {rules:o,commands:i,agents:a,skills:l,mcp:c,permissions:m,hooks:p,ignore:u}}var Ti=d(()=>{Yc();Xc();Zc();ol();Qc();zg();Jg();Yg();A();s(we,"loadCanonicalFiles");});function vC(t){return basename(t.source,".md")}function sl(t,e){let r=new Map(t.rules.map(p=>[vC(p),p]));for(let p of e.rules)r.set(vC(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=LK(t.mcp,e.mcp),l=OK(t.permissions,e.permissions),c=wK(t.hooks,e.hooks),m=AK(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 LK(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=Xg(t?.allow??[],e?.allow??[]),n=Xg(t?.deny??[],e?.deny??[]),o=Xg(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}function Xg(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 wK(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 AK(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 Zg=d(()=>{s(vC,"ruleSlug");s(sl,"mergeCanonicalFiles");s(LK,"mergeMcp");s(OK,"mergePermissions");s(Xg,"mergeUniqueStrings");s(wK,"mergeHooks");s(AK,"mergeIgnore");});function FK(t){return typeof t=="string"?t:t.level}function MC(t){return NK.includes(t)}function $C(t,e,r,n){for(let o of DK){let i=FK(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",l=MC(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}`+(MC(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function lu(t){return GK.parse(t)}var wo,GC,bK,PK,jC,TK,xK,DK,NK,vK,MK,$K,GK,Qg=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()})]),GC=z$1.object({rules:wo,additionalRules:wo,commands:wo,agents:wo,skills:wo,mcp:wo,hooks:wo,ignore:wo,permissions:wo}),bK=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(),PK=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),jC=z$1.object({paths:PK}).passthrough(),TK=z$1.object({capabilities:GC,detectionPaths:z$1.array(z$1.string()),layout:jC,scopeExtras:z$1.function().optional()}).passthrough(),xK=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],DK=[{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"}],NK=["mcp","hooks","ignore","permissions"];s(FK,"capabilityLevel");s(MC,"canUseScopedSettings");s($C,"validateCapabilityImplementations");vK=z$1.object({commandsToSkills:z$1.boolean().optional(),agentsToSkills:z$1.boolean().optional()}).strict(),MK=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(),$K=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),metadata:MK,generators:bK,capabilities:GC,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:jC,globalSupport:TK.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string()),excludeFromStarterInit:z$1.boolean().optional(),conversionDefaults:vK.optional(),emitScopedSettings:z$1.function().optional(),mergeGeneratedOutputContent:z$1.function().optional(),postProcessHookOutputs:z$1.function().optional(),preservesManualActivation:z$1.boolean().optional()}).passthrough(),GK=$K.superRefine((t,e)=>{for(let r of xK)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});$C(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&$C(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(lu,"validateDescriptor");});function UC(){if(qg)return qg;let t=Pt.filter(r=>r!==void 0&&typeof r.id=="string"),e=new Map(t.map(r=>[r.id,r]));return t.length===Pt.length&&(qg=e),e}function mu(t){let e=lu(t);cu.set(e.id,e);}function nt(t){return cu.get(t)??UC().get(t)}function pu(){return [...cu.values()]}function BC(){return [...new Set([...UC().keys(),...cu.keys()])]}var cu,qg,ce=d(()=>{Tt();Qg();cu=new Map;s(UC,"builtinDescriptors");s(mu,"registerTargetDescriptor");s(nt,"getDescriptor");s(pu,"getAllDescriptors");s(BC,"getAllRegisteredDescriptorIds");});function KC(t,e){return nt(t)?.conversionDefaults?.[e]}function WC(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function il(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=WC(o,n);if(i!==void 0)return i;let a=KC(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=WC(o,n);if(i!==void 0)return i;let a=KC(e,"agentsToSkills");return a!==void 0?a:r??false}var al=d(()=>{ce();s(KC,"builtinDefault");s(WC,"resolveConversionValue");s(il,"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 HC(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 xi=d(()=>{s(Kr,"cap");s(Br,"normalizeCapabilityValue");s(HC,"normalizeTargetCapabilities");});function zC(t){for(let e of Pt)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function jK(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 VC(t){let e=jK(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 U=d(()=>{s(P,"parseFrontmatter");s(LK,"extractBody");s(jr,"tryParseFrontmatter");s(ko,"parseOrSkipFrontmatter");s(T,"serializeFrontmatter");});function AK(t){let e=t.replace(/\.[^.]*$/,"").toUpperCase();return OK.has(e)}function vC(t){let e=[],r=t.split(/[\\/]/);for(let n of r)if(!(n===""||n==="."||n==="..")){if(wK.test(n)){e.push({segment:n,reason:"illegal-character"});continue}if(/[. ]$/.test(n)){e.push({segment:n,reason:"trailing-dot-or-space"});continue}AK(n)&&e.push({segment:n,reason:"reserved-name"});}return e}var OK,wK,MC=d(()=>{OK=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]),wK=new RegExp('[<>:"|?*\\u0000-\\u001F]');s(AK,"segmentReservedName");s(vC,"findWindowsPathIssues");});function Eo(t,e){let r=vC(e);if(r.length===0)return;let n=r.map(o=>`${o.segment} (${o.reason})`).join(", ");throw new su(t,e,`canonical ${t} name "${e}" is not portable to Windows: ${n}. Rename the file.`)}function iu(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 su(t,m,`canonical ${t} files collide on slug "${m}": ${p} vs ${o}. Rename one.`);n.set(m,o);}}var su,Qc=d(()=>{MC();su=class extends Error{static{s(this,"CanonicalNameError");}feature;name;constructor(e,r,n){super(n),this.feature=e,this.name=r;}};s(Eo,"assertCanonicalName");s(iu,"assertNoBasenameCollisions");});function il(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();xK.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 xK,au=d(()=>{ot();xK=new Set([".toml",".yaml",".yml",".json"]);s(il,"warnIfUnrecognizedResourceFormats");});function GC(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function ws(t,e={}){let r=await G(t),n=r.filter(i=>{if(!i.endsWith(".md"))return false;let a=basename(i,".md");return a==="_root"||!a.startsWith("_")});il("rules",t,r,n,{handledByOtherReader:e.handledByOtherReader});let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=ko(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");Eo("rule",p);let u=p==="_root",f=c.root===true,g=c.trigger,h=typeof g=="string"&&TK.includes(g)?g:void 0,S=c.codex_emit,C=S==="execution"?"execution":S==="advisory"?"advisory":void 0,k=c.codex_instruction==="override"?"override":void 0;o.push({source:i,root:u||f,targets:GC(c.targets),description:typeof c.description=="string"?c.description:"",globs:GC(c.globs),body:m,...h!==void 0&&{trigger:h},...C!==void 0&&{codexEmit:C},...k!==void 0&&{codexInstructionVariant:k}});}return o}var TK,qc=d(()=>{A();U();Qc();au();TK=["always_on","model_decision","glob","manual"];s(GC,"toStrArray");s(ws,"parseRules");});function UC(t){return t===true||t==="true"||t===1||t==="1"}function BC(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 As(t,e={}){let r=await G(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));il("commands",t,r,n,{handledByOtherReader:e.handledByOtherReader}),iu("command",n,".md");let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=ko(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");Eo("command",p);let u=BC(c.allowedTools),f=BC(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:UC(c.outputStyle)||UC(c["output-style"]),body:m});}return o}var tm=d(()=>{A();U();Qc();au();s(UC,"toBool");s(BC,"toToolsArray");s(As,"parseCommands");});function Ti(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 WC(t){return t===true||t==="true"||t===1||t==="1"}function HC(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 DK(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function bs(t,e={}){let r=await G(t),n=r.filter(i=>i.endsWith(".md")&&!basename(i).startsWith("_"));il("agents",t,r,n,{handledByOtherReader:e.handledByOtherReader}),iu("agent",n,".md");let o=[];for(let i of n){let a=await _(i);if(!a)continue;let l=ko(a,i,e.onParseError);if(!l)continue;let{frontmatter:c,body:m}=l,p=basename(i,".md");Eo("agent",p);let u=Ti(c.tools),f=Ti(c.tools),g=u.length>0?u:f,h=Ti(c.disallowedTools),S=Ti(c["disallowed-tools"]),C=h.length>0?h:S,R=Ti(c.mcpServers),k=Ti(c["mcp-servers"]),b=R.length>0?R:k,N=Ti(c.skills),x=HC(c.maxTurns),B=HC(c["max-turns"]),H=x>0?x:B>0?B: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:H,mcpServers:b,hooks:DK(c.hooks),skills:N,memory:typeof c.memory=="string"?c.memory:"",outputStyle:WC(c.outputStyle)||WC(c["output-style"]),body:m});}return o}var em=d(()=>{A();U();Qc();au();s(Ti,"toStrArray");s(WC,"toBool");s(HC,"toInt");s(DK,"toHooks");s(bs,"parseAgents");});function th(t){let e=t.toLowerCase(),r=e.lastIndexOf("."),n=r>0?e.slice(0,r):e;return NK.get(n)}function En(t){return th(t)!==void 0}function lu(t){return th(t)==="preserved"}function cu(t){return th(t)==="noise"}function zC(t){return FK.has(t)}function VC(t){return vK.has(t)}var NK,FK,vK,Lo=d(()=>{NK=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"]]),FK=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]),vK=new Set(["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]);s(th,"boilerplateKind");s(En,"isBoilerplate");s(lu,"isPreservedBoilerplate");s(cu,"isNoiseBoilerplate");s(zC,"isRepoNonContentDir");s(VC,"isRepoNonContentFile");});async function GK(t){return await _(t)??""}function UK(t){let e=t.lastIndexOf(".");return e<0?true:jK.has(t.slice(e).toLowerCase())}function KK(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function JC(t){let e=await Os(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===mu||i.endsWith(`/${mu}`))continue;let a=i.split("/")[0];if(BK.some(m=>a===m)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let l=i.includes("/")?i.slice(i.lastIndexOf("/")+1):i;if(UK(l)&&cu(l))continue;let c=await GK(n);r.push({relativePath:i,absolutePath:n,content:c});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}async function pu(t,e={}){let r=join(t,mu),n=await _(r);if(!n)return null;let o=ko(n,r,e.onParseError);if(!o)return null;let{frontmatter:i,body:a}=o,l=await JC(t),m=(typeof i.name=="string"?KK(i.name):"")||basename(t);return Eo("skill",m),{source:r,name:m,description:typeof i.description=="string"?i.description:"",body:a,supportingFiles:l}}async function Ps(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;Eo("skill",o.name);let i=join(t,o.name),a=join(i,mu),l=await _(a);if(!l)continue;let c=ko(l,a,e.onParseError);if(!c)continue;let{frontmatter:m,body:p}=c,u=await JC(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 mu,jK,BK,al=d(()=>{A();Gg();U();Lo();Qc();s(GK,"readContent");mu="SKILL.md",jK=new Set([".md",".mdx",".rst",".txt"]);s(UK,"isMarkdownLikeDoc");BK=[".git","node_modules"];s(KK,"sanitizeSkillName");s(JC,"listSupportingFiles");s(pu,"parseSkillDirectory");s(Ps,"parseSkills");});function YC(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function WK(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=YC(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:YC(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 HK(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 Ur(t){let e=await _(t);if(!e)return null;let r;try{r=JSON.parse(HK(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=WK(a);l&&(o[i]=l);}return {mcpServers:o}}var rm=d(()=>{A();s(YC,"parseStringMap");s(WK,"parseServer");s(HK,"stripJsonComments");s(Ur,"parseMcp");});function rh(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function uu(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=rh(n.allow),i=rh(n.deny),a=rh(n.ask);return {allow:o,deny:i,ask:a}}var nh=d(()=>{A();s(rh,"ensureStringArray");s(uu,"parsePermissions");});function XC(t){return typeof t=="string"?t.trim():""}function Jt(t){return XC(t.command)}function Re(t){return XC(t.prompt)}function oh(t){let e=Jt(t),r=Re(t);return t.type==="prompt"?r||e:e||r}function Oo(t){return Jt(t).length>0}function Ln(t){return oh(t).length>0}var Br=d(()=>{s(XC,"trimString");s(Jt,"getHookCommand");s(Re,"getHookPrompt");s(oh,"getHookText");s(Oo,"hasHookCommand");s(Ln,"hasHookText");});function YK(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=oh(e);if(!n)return null;let o=typeof e.type=="string"&&JK.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=Re(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}async function du(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=YK(c);m&&l.push(m);}l.length>0&&(n[i]=l);}return n}var JK,sh=d(()=>{A();Br();JK=["command","prompt"];s(YK,"toHookEntry");s(du,"parseHooks");});async function fu(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 ih=d(()=>{A();s(fu,"parseIgnore");});async function we(t,e={}){let r=join(t,".agentsmesh"),n=await j(r)?r:t,[o,i,a,l,c,m,p,u]=await Promise.all([ws(join(n,"rules"),e),As(join(n,"commands"),e),bs(join(n,"agents"),e),Ps(join(n,"skills"),e),Ur(join(n,"mcp.json")),uu(join(n,"permissions.yaml")),du(join(n,"hooks.yaml")),fu(join(n,"ignore"))]);return {rules:o,commands:i,agents:a,skills:l,mcp:c,permissions:m,hooks:p,ignore:u}}var Di=d(()=>{qc();tm();em();al();rm();nh();sh();ih();A();s(we,"loadCanonicalFiles");});function ZC(t){return basename(t.source,".md")}function ll(t,e){let r=new Map(t.rules.map(p=>[ZC(p),p]));for(let p of e.rules)r.set(ZC(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=ZK(t.mcp,e.mcp),l=QK(t.permissions,e.permissions),c=qK(t.hooks,e.hooks),m=tW(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 ZK(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}function QK(t,e){if(!t&&!e)return null;let r=ah(t?.allow??[],e?.allow??[]),n=ah(t?.deny??[],e?.deny??[]),o=ah(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}function ah(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 qK(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 tW(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 lh=d(()=>{s(ZC,"ruleSlug");s(ll,"mergeCanonicalFiles");s(ZK,"mergeMcp");s(QK,"mergePermissions");s(ah,"mergeUniqueStrings");s(qK,"mergeHooks");s(tW,"mergeIgnore");});function aW(t){return typeof t=="string"?t:t.level}function QC(t){return iW.includes(t)}function qC(t,e,r,n){for(let o of sW){let i=aW(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",l=QC(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}`+(QC(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function gu(t){return pW.parse(t)}var Ao,tk,eW,rW,ek,nW,oW,sW,iW,lW,cW,mW,pW,ch=d(()=>{Ao=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()})]),tk=z$1.object({rules:Ao,additionalRules:Ao,commands:Ao,agents:Ao,skills:Ao,mcp:Ao,hooks:Ao,ignore:Ao,permissions:Ao}),eW=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(),rW=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),ek=z$1.object({paths:rW}).passthrough(),nW=z$1.object({capabilities:tk,detectionPaths:z$1.array(z$1.string()),layout:ek,scopeExtras:z$1.function().optional()}).passthrough(),oW=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],sW=[{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"}],iW=["mcp","hooks","ignore","permissions"];s(aW,"capabilityLevel");s(QC,"canUseScopedSettings");s(qC,"validateCapabilityImplementations");lW=z$1.object({commandsToSkills:z$1.boolean().optional(),agentsToSkills:z$1.boolean().optional()}).strict(),cW=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(),mW=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),metadata:cW,generators:eW,capabilities:tk,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:ek,globalSupport:nW.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string()),excludeFromStarterInit:z$1.boolean().optional(),conversionDefaults:lW.optional(),emitScopedSettings:z$1.function().optional(),mergeGeneratedOutputContent:z$1.function().optional(),postProcessHookOutputs:z$1.function().optional(),preservesManualActivation:z$1.boolean().optional()}).passthrough(),pW=mW.superRefine((t,e)=>{for(let r of oW)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});qC(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&qC(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(gu,"validateDescriptor");});function rk(){if(mh)return mh;let t=Pt.filter(r=>r!==void 0&&typeof r.id=="string"),e=new Map(t.map(r=>[r.id,r]));return t.length===Pt.length&&(mh=e),e}function yu(t){let e=gu(t);hu.set(e.id,e);}function nt(t){return hu.get(t)??rk().get(t)}function _u(){return [...hu.values()]}function nk(){return [...new Set([...rk().keys(),...hu.keys()])]}var hu,mh,ce=d(()=>{xt();ch();hu=new Map;s(rk,"builtinDescriptors");s(yu,"registerTargetDescriptor");s(nt,"getDescriptor");s(_u,"getAllDescriptors");s(nk,"getAllRegisteredDescriptorIds");});function ok(t,e){return nt(t)?.conversionDefaults?.[e]}function sk(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function cl(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=sk(o,n);if(i!==void 0)return i;let a=ok(e,"commandsToSkills");return a!==void 0?a:r??false}function sr(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],i=sk(o,n);if(i!==void 0)return i;let a=ok(e,"agentsToSkills");return a!==void 0?a:r??false}var ml=d(()=>{ce();s(ok,"builtinDefault");s(sk,"resolveConversionValue");s(cl,"shouldConvertCommandsToSkills");s(sr,"shouldConvertAgentsToSkills");});function Wr(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Kr(t){return typeof t=="string"?{level:t}:t}function ik(t){return {rules:Kr(t.rules),additionalRules:Kr(t.additionalRules),commands:Kr(t.commands),agents:Kr(t.agents),skills:Kr(t.skills),mcp:Kr(t.mcp),hooks:Kr(t.hooks),ignore:Kr(t.ignore),permissions:Kr(t.permissions)}}var Ni=d(()=>{s(Wr,"cap");s(Kr,"normalizeCapabilityValue");s(ik,"normalizeTargetCapabilities");});function ak(t){for(let e of Pt)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function uW(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 lk(t){let e=uW(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 th=d(()=>{Tt();s(zC,"ownerTargetIdForSharedPath");s(jK,"findSharedArtifactOwnershipConflicts");s(VC,"assertSharedArtifactOwnersUnique");});function UK(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 `${ll}${t}`}function Mt(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"],x(e,t.body.trim()||"")}function uu(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(ll)?e.slice(ll.length):e.startsWith(qc)?e.slice(qc.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:UK(t["x-agentsmesh-allowed-tools"])}:null}function du(t,e){return x({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var ll,qc,Lt=d(()=>{U();ll="am-command-",qc="ab-command-";s(UK,"toStringArray");s(V,"commandSkillDirName");s(Mt,"serializeCommandSkill");s(uu,"parseCommandSkillFrontmatter");s(du,"serializeImportedCommand");});function fu(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 BK(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 K(t){return `${cl}${t}`}function xt(t){let e={name:K(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];}),x(e,t.body.trim()||"")}function ml(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(cl)?e.slice(cl.length):e.startsWith(tm)?e.slice(tm.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:fu(t["x-agentsmesh-tools"]),disallowedTools:fu(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:fu(t["x-agentsmesh-mcp-servers"]),hooks:BK(t["x-agentsmesh-hooks"]),skills:fu(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function bs(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];}),x(r,e.trim()||"")}var cl,tm,ut=d(()=>{U();cl="am-agent-",tm="ab-agent-";s(fu,"toStringArray");s(BK,"toHooks");s(K,"projectedAgentSkillDirName");s(xt,"serializeProjectedAgentSkill");s(ml,"parseProjectedAgentSkillFrontmatter");s(bs,"serializeImportedAgent");});function em(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function eh(t,e){return new RegExp(`${em(t)}[\\s\\S]*?${em(e)}`,"g")}function QC(t,e,r,n){let o=eh(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 ph=d(()=>{xt();s(ak,"ownerTargetIdForSharedPath");s(uW,"findSharedArtifactOwnershipConflicts");s(lk,"assertSharedArtifactOwnersUnique");});function dW(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 `${pl}${t}`}function Mt(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 Ru(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(pl)?e.slice(pl.length):e.startsWith(nm)?e.slice(nm.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:dW(t["x-agentsmesh-allowed-tools"])}:null}function Su(t,e){return T({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var pl,nm,Lt=d(()=>{U();pl="am-command-",nm="ab-command-";s(dW,"toStringArray");s(V,"commandSkillDirName");s(Mt,"serializeCommandSkill");s(Ru,"parseCommandSkillFrontmatter");s(Su,"serializeImportedCommand");});function Iu(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 fW(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 K(t){return `${ul}${t}`}function Tt(t){let e={name:K(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 dl(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(ul)?e.slice(ul.length):e.startsWith(om)?e.slice(om.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:Iu(t["x-agentsmesh-tools"]),disallowedTools:Iu(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:Iu(t["x-agentsmesh-mcp-servers"]),hooks:fW(t["x-agentsmesh-hooks"]),skills:Iu(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function xs(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 ul,om,ut=d(()=>{U();ul="am-agent-",om="ab-agent-";s(Iu,"toStringArray");s(fW,"toHooks");s(K,"projectedAgentSkillDirName");s(Tt,"serializeProjectedAgentSkill");s(dl,"parseProjectedAgentSkillFrontmatter");s(xs,"serializeImportedAgent");});function sm(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uh(t,e){return new RegExp(`${sm(t)}[\\s\\S]*?${sm(e)}`,"g")}function dk(t,e,r,n){let o=uh(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 rh(t,e,r){return t.replace(eh(e,r),"").trim()}function HK(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 zK(t){return {source:HK(t.source),description:t.description,globs:t.globs,targets:t.targets}}function VK(t){return `${XC}${JSON.stringify(zK(t))}${ZC}`}function JK(t){let e=[VK(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),YC),e.filter(r=>r.length>0).join(`
22
- `)}function YK(t){return t.length===0?"":[gu,...t.map(JK),hu].join(`
23
- `)}function mt(t,e){let r=YK(e),n=rh(t,gu,hu);return r?n?`${n}
21
+ ${n}`:n}function dh(t,e,r){return t.replace(uh(e,r),"").trim()}function yW(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 _W(t){return {source:yW(t.source),description:t.description,globs:t.globs,targets:t.targets}}function RW(t){return `${pk}${JSON.stringify(_W(t))}${uk}`}function SW(t){let e=[RW(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),mk),e.filter(r=>r.length>0).join(`
22
+ `)}function IW(t){return t.length===0?"":[Cu,...t.map(SW),ku].join(`
23
+ `)}function at(t,e){let r=IW(e),n=dh(t,Cu,ku);return r?n?`${n}
24
24
 
25
- ${r}`:r:n}function JC(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function XK(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:JC(r.globs),targets:JC(r.targets)}}catch{return null}}function ZK(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 qC(t){let e=[],r=eh(gu,hu);return {rootContent:t.replace(r,o=>{let i=o.replace(gu,"").replace(hu,"").trim(),a=new RegExp(`${em(XC)}([\\s\\S]*?)${em(ZC)}([\\s\\S]*?)${em(YC)}`,"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=XK(c);p&&e.push({...p,body:ZK(m,p.description)});}return ""}).trim(),rules:e}}var rm,nm,gu,hu,YC,XC,ZC,Wt=d(()=>{rm="<!-- agentsmesh:root-generation-contract:start -->",nm="<!-- agentsmesh:root-generation-contract:end -->",gu="<!-- agentsmesh:embedded-rules:start -->",hu="<!-- agentsmesh:embedded-rules:end -->",YC="<!-- agentsmesh:embedded-rule:end -->",XC="<!-- agentsmesh:embedded-rule:start ",ZC=" -->";s(em,"escapeRegExp");s(eh,"managedBlockPattern");s(QC,"replaceManagedBlock");s(rh,"stripManagedBlock");s(HK,"ruleSource");s(zK,"markerForRule");s(VK,"embeddedRuleStart");s(JK,"renderRule");s(YK,"renderEmbeddedRulesBlock");s(mt,"appendEmbeddedRulesBlock");s(JC,"toStringArray");s(XK,"parseMarker");s(ZK,"stripGeneratedHeading");s(qC,"extractEmbeddedRules");});function nh(t){return t.replace(/\s+/g," ").trim()}function ek(t){let e=t.trim();if(e.includes(rm)&&e.includes(nm))return QC(e,rm,nm,pl);let r=nh(e);if(r.includes(nh(pl)))return e;for(let n of tk)if(r.includes(nh(n)))return e.replace(n,pl);return e?`${e}
25
+ ${r}`:r:n}function ck(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function CW(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:ck(r.globs),targets:ck(r.targets)}}catch{return null}}function kW(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 fk(t){let e=[],r=uh(Cu,ku);return {rootContent:t.replace(r,o=>{let i=o.replace(Cu,"").replace(ku,"").trim(),a=new RegExp(`${sm(pk)}([\\s\\S]*?)${sm(uk)}([\\s\\S]*?)${sm(mk)}`,"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=CW(c);p&&e.push({...p,body:kW(m,p.description)});}return ""}).trim(),rules:e}}var im,am,Cu,ku,mk,pk,uk,Kt=d(()=>{im="<!-- agentsmesh:root-generation-contract:start -->",am="<!-- agentsmesh:root-generation-contract:end -->",Cu="<!-- agentsmesh:embedded-rules:start -->",ku="<!-- agentsmesh:embedded-rules:end -->",mk="<!-- agentsmesh:embedded-rule:end -->",pk="<!-- agentsmesh:embedded-rule:start ",uk=" -->";s(sm,"escapeRegExp");s(uh,"managedBlockPattern");s(dk,"replaceManagedBlock");s(dh,"stripManagedBlock");s(yW,"ruleSource");s(_W,"markerForRule");s(RW,"embeddedRuleStart");s(SW,"renderRule");s(IW,"renderEmbeddedRulesBlock");s(at,"appendEmbeddedRulesBlock");s(ck,"toStringArray");s(CW,"parseMarker");s(kW,"stripGeneratedHeading");s(fk,"extractEmbeddedRules");});function fh(t){return t.replace(/\s+/g," ").trim()}function hk(t){let e=t.trim();if(e.includes(im)&&e.includes(am))return dk(e,im,am,fl);let r=fh(e);if(r.includes(fh(fl)))return e;for(let n of gk)if(r.includes(fh(n)))return e.replace(n,fl);return e?`${e}
26
26
 
27
- ${pl}`:pl}function rk(t){let e=rh(t,rm,nm);e=e.replace(`
27
+ ${fl}`:fl}function yk(t){let e=dh(t,im,am);e=e.replace(`
28
28
 
29
- ${pl}`,"");for(let r of tk)e=e.replace(`
29
+ ${fl}`,"");for(let r of gk)e=e.replace(`
30
30
 
31
- ${r}`,"");return e.trim()}var oh,QK,qK,tW,eW,rW,nW,oW,sW,iW,aW,lW,cW,mW,pW,uW,dW,fW,gW,pl,tk,sh=d(()=>{Wt();oh="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.",QK="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.",qK="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.",tW="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.",eW="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`.",rW="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`.",nW="`.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`.",oW="`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.",sW="`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.",iW=oh,aW=`## Project-Specific Rules
31
+ ${r}`,"");return e.trim()}var gh,EW,LW,OW,wW,AW,bW,PW,xW,TW,DW,NW,FW,vW,MW,$W,GW,jW,UW,BW,KW,WW,HW,fl,gk,hh=d(()=>{Kt();gh="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.",EW="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.",LW="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.",OW="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.",wW="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`.",AW="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`.",bW="`.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`.",PW="`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.",xW="`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.",TW="**MUST follow when changing any rule, agent, command, skill, hook, MCP server, permission, or ignore pattern.** `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.",DW="**NEVER edit generated files** (`.claude/`, `.cursor/`, `AGENTS.md`, `.github/copilot-instructions.md`, and similar target outputs) \u2014 `agentsmesh generate` overwrites them. **All changes MUST go through `.agentsmesh` first**: edit `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; `agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally); 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.",NW=gh,FW=`## Project-Specific Rules
32
32
 
33
- ${oh}`,lW=`## AgentsMesh Generation Contract
33
+ ${gh}`,vW=`## AgentsMesh Generation Contract
34
34
 
35
- ${oh}`,cW=`## AgentsMesh Generation Contract
35
+ ${gh}`,MW=`## AgentsMesh Generation Contract
36
36
 
37
- ${QK}`,mW=`## AgentsMesh Generation Contract
37
+ ${EW}`,$W=`## AgentsMesh Generation Contract
38
38
 
39
- ${qK}`,pW=`## AgentsMesh Generation Contract
39
+ ${LW}`,GW=`## AgentsMesh Generation Contract
40
40
 
41
- ${tW}`,uW=`## AgentsMesh Generation Contract
41
+ ${OW}`,jW=`## AgentsMesh Generation Contract
42
42
 
43
- ${eW}`,dW=`## AgentsMesh Generation Contract
43
+ ${wW}`,UW=`## AgentsMesh Generation Contract
44
44
 
45
- ${rW}`,fW=`## AgentsMesh Generation Contract
45
+ ${AW}`,BW=`## AgentsMesh Generation Contract
46
46
 
47
- ${nW}`,gW=`## AgentsMesh Generation Contract
47
+ ${bW}`,KW=`## AgentsMesh Generation Contract
48
48
 
49
- ${oW}`,pl=`${rm}
49
+ ${PW}`,WW=`## AgentsMesh Generation Contract
50
+
51
+ ${xW}`,HW=`## AgentsMesh Generation Contract
52
+
53
+ ${TW}`,fl=`${im}
50
54
  ## AgentsMesh Generation Contract
51
55
 
52
- ${sW}
53
- ${nm}`;s(nh,"normalizeWhitespace");tk=[gW,fW,dW,uW,pW,mW,cW,lW,aW,iW];s(ek,"appendAgentsmeshRootInstructionParagraph");s(rk,"stripAgentsmeshRootInstructionParagraph");});function Ie(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 ul(t){let e=await _(t);return e?P(e).frontmatter:{}}function qt(t,e){return typeof t[e]=="string"?t[e]:void 0}function ih(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function hW(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function yW(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 ul(t),o=basename(t,".md")==="_root"?rk(r):r.trim(),i=yW(t,hW({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=Ie(i.globs));for(let[l,c]of Object.entries(i))l==="root"||l==="description"||l==="globs"||c===void 0||(a[l]=c);return x(a,o||"")}var ah=d(()=>{A();U();sh();s(Ie,"toStringArray");s(ul,"readExistingFrontmatter");s(qt,"readString");s(ih,"readHooks");s(hW,"pruneUndefined");s(yW,"serializeCanonicalRuleFrontmatter");s(z,"serializeImportedRuleWithFallback");});async function It(t,e,r){let n=await ul(t),o=(()=>{let l=Ie(n.allowedTools);return l.length>0?l:Ie(n["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return x({description:i,"allowed-tools":a},r.trim()||"")}async function En(t,e,r){let n=await ul(t),o=basename(dirname(t)),i=qt(e,"name")??qt(n,"name")??o,a=qt(e,"description")??qt(n,"description")??"";return x({name:i,description:a},r.trim()||"")}async function Yt(t,e,r){let n=await ul(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?Ie(e.tools):(()=>{let R=Ie(n.tools);return R.length>0?R:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?Ie(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?Ie(e["disallowed-tools"]):Ie(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?Ie(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?Ie(e["mcp-servers"]):Ie(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?Ie(e.skills):Ie(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=ih(e)??ih(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),x(u,r.trim()||"")}var sk=d(()=>{U();ah();s(It,"serializeImportedCommandWithFallback");s(En,"serializeImportedSkillWithFallback");s(Yt,"serializeImportedAgentWithFallback");});var ft=d(()=>{ah();sk();});function yu(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 om=d(()=>{s(yu,"shouldImportScopedAgentsRule");s(Ln,"removePathIfExists");});function st(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:x(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,sm,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=P(o(m,c,u)),h=uu(f,a.name);if(h){await Ln(join(t,sm,a.name));let C=join(t,ik);await O(C);let b=join(C,`${h.name}.md`);await S(b,du(h,o(g,c,b))),n.push({fromTool:r,fromPath:c,toPath:`${ik}/${h.name}.md`,feature:"commands"});continue}let R=ml(f,a.name);if(R){await Ln(join(t,sm,a.name));let C=join(t,ak);await O(C);let b=join(C,`${R.name}.md`);await S(b,bs(R,o(g,c,b))),n.push({fromTool:r,fromPath:c,toPath:`${ak}/${R.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:`${sm}/${a.name}/SKILL.md`,feature:"skills"});let I=await G(l);for(let C of I){if(C===c)continue;let b=relative(l,C).replace(/\\/g,"/"),N=await _(C);if(N===null)continue;let T=join(p,b);await O(dirname(T)),await S(T,o(N,C,T)),n.push({fromTool:r,fromPath:C,toPath:`${sm}/${a.name}/${b}`,feature:"skills"});}}}var sm,ik,ak,rt=d(()=>{A();U();ft();ut();Lt();om();sm=".agentsmesh/skills",ik=".agentsmesh/commands",ak=".agentsmesh/agents";s(st,"generateEmbeddedSkills");s(et,"importEmbeddedSkills");});var On,ir,me,Ao,bo,ar,Di,lk,ck,dl=d(()=>{On="aider",ir="CONVENTIONS.md",me=".aider/skills",Ao=".aiderignore",bo="CONVENTIONS.md",ar=".aider/skills",Di=".aiderignore",lk=".agentsmesh/rules",ck=".agentsmesh/ignore";});function mk(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 pk(t){return st(t,me)}function uk(t){return t.commands.map(e=>({path:`${me}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function dk(t){return t.agents.map(e=>({path:`${me}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function fk(t){return t.ignore.length===0?[]:[{path:Ao,content:t.ignore.join(`
54
- `)}]}var gk=d(()=>{rt();Wt();ut();Lt();dl();s(mk,"generateRules");s(pk,"generateSkills");s(uk,"generateCommands");s(dk,"generateAgents");s(fk,"generateIgnore");});function at(t){return t.includes("\\")||Wr.test(t)?win32:posix}function Gt(t){return t.replace(/\\/g,"/")}function X(t,e){let r=at(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):Gt(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function yk(t,e){return at(t).isAbsolute(e)||Wr.test(e)}function fl(t){let e=t,r="";for(;EW.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function _k(t,e){let r=at(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?X(e,r.join(e,n)):null}var Wr,EW,pe=d(()=>{Wr=/^[A-Za-z]:[\\/]/,EW=/[.!?:;]+$/;s(at,"pathApi");s(Gt,"normalizeSeparators");s(X,"normalizeForProject");s(yk,"isAbsoluteForProject");s(fl,"stripTrailingPunctuation");s(_k,"rootFallbackPath");});async function Rk(t,e,r="project"){let n=new Map,o=nt(t);return o&&await o.buildImportPaths(n,e,r),n}var Ik=d(()=>{ce();s(Rk,"buildImportReferenceMap");});function wW(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 AW(){let t=new Set([".agentsmesh/"]);for(let e of Pt)for(let r of wW(e))t.add(r);return Array.from(t)}function bW(){let t=new Set([...AW(),...lh.rootRelativePrefixes]),e=new Set([...OW,...lh.meshRootSegments]);return {protectedSchemes:[...LW,...lh.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function _u(){return ch||(ch=bW()),ch}var LW,OW,lh,ch,Sk=d(()=>{Tt();LW=[/\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],OW=new Set(["skills","rules","commands","agents","packs"]),lh={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(wW,"topLevelDotfilePrefixes");s(AW,"buildDefaultRootRelativePrefixes");s(bW,"rebuild");s(_u,"getLinkFormatRegistry");});function Hr(t){let e=Gt(t);return _u().rootRelativePrefixes.some(r=>e.startsWith(r))}function TW(t){let e=Gt(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&&_u().meshRootSegments.has(r)}function im(t,e,r){let n=at(e),o=X(e,e),i=X(e,r),a=Gt(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=_k(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=TW(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 xW.has(a)?[]:a.includes(".")?[X(e,n.join(n.dirname(i),a))]:[]}function am(t,e){let r=[e];if(!yk(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 Lk(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function Ru(t){let e=[];for(let r of _u().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(DW))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(NW))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(FW))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var xW,DW,NW,FW,Ek,gl,Ps=d(()=>{pe();Sk();s(Hr,"isRootRelativePathToken");s(TW,"isMeshRootRelativePathToken");xW=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),DW=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,NW=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,FW=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,Ek=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,gl=/(?::(\d+)){1,2}$/;s(im,"resolveProjectPath");s(am,"expandResolvedPaths");s(Lk,"isGlobAdjacent");s(Ru,"protectedRanges");});function vW(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 Ok(t){return vW(t.tokenContext)}function mh(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 wk(t){let e=at(t);return X(t,e.join(t,".agentsmesh"))}function zr(t,e){let r=at(t),n=wk(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 Ak(t,e,r){let n=at(t),o=wk(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 ph(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 hl(t,e,r){let n=ph(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function uh(t,e,r,n,o){let i=at(t),a=X(t,t),l=X(t,e),c=X(t,r);if(!mh(t,c))return hl(t,c,n)?.text??null;let m=X(t,i.dirname(l));if(!mh(t,m)&&m!==a)return hl(t,c,n)?.text??null;let p=i.relative(m,c).replace(/\\/g,"/");if(i.isAbsolute(p)||Wr.test(p))return ph(t,c,n);let u=X(t,i.join(m,p));return mh(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):ph(t,c,n)}var dh=d(()=>{pe();s(vW,"isReadingContext");s(Ok,"isReadingContextOptions");s(mh,"isUnderProjectRoot");s(wk,"agentsMeshRoot");s(zr,"isUnderAgentsMesh");s(Ak,"toAgentsMeshRootRelative");s(ph,"toProjectRootRelative");s(hl,"toProjectRootReference");s(uh,"formatLinkPathForDestinationLegacy");});function bk(t,e,r,n,o={}){let i=o.scope??"project",a=X(t,r);if(Ok(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 uh(t,e,r,n,o);if(i==="global"&&!zr(t,e))return hl(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 hl(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=Ak(t,l,n);return m!==null?m:hl(t,l,n)?.text??null}return uh(t,e,r,n,o)}var Pk=d(()=>{Ps();pe();dh();dh();s(bk,"formatLinkPathForDestination");});function Tk(t,e,r,n){let o=at(e),i=Gt(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 xk=d(()=>{pe();Ps();s(Tk,"resolveByDestinationSuffixStrip");});function Dk(t){let e=null,r=false,n=null,o=null,i=null;for(let c of im(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of am(t.projectRoot,c)){let f=X(t.projectRoot,u),g=X(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=Tk(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=Gt(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&Gt(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var Nk=d(()=>{pe();Ps();xk();s(Dk,"resolveLinkTarget");});function Fk(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function vk(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 Mk(t){let e=Gt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Wr.test(e)||Hr(e)?false:e.includes("/")}var $k=d(()=>{pe();Ps();s(Fk,"isTildeHomeRelativePathToken");s(vk,"isMarkdownLinkDestinationToken");s(Mk,"isRelativePathToken");});function MW(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 Gk(t,e,r){let n=t.lastIndexOf(`
56
+ ${DW}
57
+ ${am}`;s(fh,"normalizeWhitespace");gk=[HW,WW,KW,BW,UW,jW,GW,$W,MW,vW,FW,NW];s(hk,"appendAgentsmeshRootInstructionParagraph");s(yk,"stripAgentsmeshRootInstructionParagraph");});function Se(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 gl(t){let e=await _(t);return e?P(e).frontmatter:{}}function qt(t,e){return typeof t[e]=="string"?t[e]:void 0}function yh(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function zW(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function VW(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 gl(t),o=basename(t,".md")==="_root"?yk(r):r.trim(),i=VW(t,zW({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=Se(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 _h=d(()=>{A();U();hh();s(Se,"toStringArray");s(gl,"readExistingFrontmatter");s(qt,"readString");s(yh,"readHooks");s(zW,"pruneUndefined");s(VW,"serializeCanonicalRuleFrontmatter");s(z,"serializeImportedRuleWithFallback");});async function St(t,e,r){let n=await gl(t),o=(()=>{let l=Se(n.allowedTools);return l.length>0?l:Se(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 On(t,e,r){let n=await gl(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 Yt(t,e,r){let n=await gl(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?Se(e.tools):(()=>{let S=Se(n.tools);return S.length>0?S:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?Se(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?Se(e["disallowed-tools"]):Se(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?Se(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?Se(e["mcp-servers"]):Se(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?Se(e.skills):Se(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=yh(e)??yh(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 Sk=d(()=>{U();_h();s(St,"serializeImportedCommandWithFallback");s(On,"serializeImportedSkillWithFallback");s(Yt,"serializeImportedAgentWithFallback");});var ft=d(()=>{_h();Sk();});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 wn(t){await rm$1(t,{recursive:true,force:true});}var lm=d(()=>{s(Eu,"shouldImportScopedAgentsRule");s(wn,"removePathIfExists");});function st(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,cm,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=P(o(m,c,u)),h=Ru(f,a.name);if(h){await wn(join(t,cm,a.name));let k=join(t,Ik);await O(k);let b=join(k,`${h.name}.md`);await I(b,Su(h,o(g,c,b))),n.push({fromTool:r,fromPath:c,toPath:`${Ik}/${h.name}.md`,feature:"commands"});continue}let S=dl(f,a.name);if(S){await wn(join(t,cm,a.name));let k=join(t,Ck);await O(k);let b=join(k,`${S.name}.md`);await I(b,xs(S,o(g,c,b))),n.push({fromTool:r,fromPath:c,toPath:`${Ck}/${S.name}.md`,feature:"agents"});continue}let C=await On(u,{...f,name:a.name},g);await O(p),await I(u,C),n.push({fromTool:r,fromPath:c,toPath:`${cm}/${a.name}/SKILL.md`,feature:"skills"});let R=await G(l);for(let k of R){if(k===c)continue;let b=relative(l,k).replace(/\\/g,"/"),N=await _(k);if(N===null)continue;let x=join(p,b);await O(dirname(x)),await I(x,o(N,k,x)),n.push({fromTool:r,fromPath:k,toPath:`${cm}/${a.name}/${b}`,feature:"skills"});}}}var cm,Ik,Ck,rt=d(()=>{A();U();ft();ut();Lt();lm();cm=".agentsmesh/skills",Ik=".agentsmesh/commands",Ck=".agentsmesh/agents";s(st,"generateEmbeddedSkills");s(et,"importEmbeddedSkills");});var An,ar,me,bo,Po,lr,Fi,kk,Ek,hl=d(()=>{An="aider",ar="CONVENTIONS.md",me=".aider/skills",bo=".aiderignore",Po="CONVENTIONS.md",lr=".aider/skills",Fi=".aiderignore",kk=".agentsmesh/rules",Ek=".agentsmesh/ignore";});function Lk(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(An)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:ar,content:o}]:[]}function Ok(t){return st(t,me)}function wk(t){return t.commands.map(e=>({path:`${me}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function Ak(t){return t.agents.map(e=>({path:`${me}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function bk(t){return t.ignore.length===0?[]:[{path:bo,content:t.ignore.join(`
58
+ `)}]}var Pk=d(()=>{rt();Kt();ut();Lt();hl();s(Lk,"generateRules");s(Ok,"generateSkills");s(wk,"generateCommands");s(Ak,"generateAgents");s(bk,"generateIgnore");});function lt(t){return t.includes("\\")||Hr.test(t)?win32:posix}function Gt(t){return t.replace(/\\/g,"/")}function X(t,e){let r=lt(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):Gt(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function Tk(t,e){return lt(t).isAbsolute(e)||Hr.test(e)}function yl(t){let e=t,r="";for(;tH.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function Dk(t,e){let r=lt(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?X(e,r.join(e,n)):null}var Hr,tH,pe=d(()=>{Hr=/^[A-Za-z]:[\\/]/,tH=/[.!?:;]+$/;s(lt,"pathApi");s(Gt,"normalizeSeparators");s(X,"normalizeForProject");s(Tk,"isAbsoluteForProject");s(yl,"stripTrailingPunctuation");s(Dk,"rootFallbackPath");});async function Nk(t,e,r="project"){let n=new Map,o=nt(t);return o&&await o.buildImportPaths(n,e,r),n}var Fk=d(()=>{ce();s(Nk,"buildImportReferenceMap");});function nH(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 oH(){let t=new Set([".agentsmesh/"]);for(let e of Pt)for(let r of nH(e))t.add(r);return Array.from(t)}function sH(){let t=new Set([...oH(),...Rh.rootRelativePrefixes]),e=new Set([...rH,...Rh.meshRootSegments]);return {protectedSchemes:[...eH,...Rh.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function Lu(){return Sh||(Sh=sH()),Sh}var eH,rH,Rh,Sh,vk=d(()=>{xt();eH=[/\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],rH=new Set(["skills","rules","commands","agents","packs"]),Rh={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(nH,"topLevelDotfilePrefixes");s(oH,"buildDefaultRootRelativePrefixes");s(sH,"rebuild");s(Lu,"getLinkFormatRegistry");});function zr(t){let e=Gt(t);return Lu().rootRelativePrefixes.some(r=>e.startsWith(r))}function aH(t){let e=Gt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Hr.test(e)||/^[a-zA-Z]:/.test(e)||zr(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&Lu().meshRootSegments.has(r)}function mm(t,e,r){let n=lt(e),o=X(e,e),i=X(e,r),a=Gt(t);if(Hr.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=Dk(a,o);return c&&c!==l?[l,c]:[l]}if(zr(a))return [X(e,n.join(o,a))];if(a.includes("/")){let l=X(e,n.join(o,".agentsmesh")),c=aH(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 lH.has(a)?[]:a.includes(".")?[X(e,n.join(n.dirname(i),a))]:[]}function pm(t,e){let r=[e];if(!Tk(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 jk(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function Ou(t){let e=[];for(let r of Lu().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(cH))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(mH))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(pH))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var lH,cH,mH,pH,Gk,_l,Ts=d(()=>{pe();vk();s(zr,"isRootRelativePathToken");s(aH,"isMeshRootRelativePathToken");lH=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),cH=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,mH=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,pH=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,Gk=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,_l=/(?::(\d+)){1,2}$/;s(mm,"resolveProjectPath");s(pm,"expandResolvedPaths");s(jk,"isGlobAdjacent");s(Ou,"protectedRanges");});function uH(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 Uk(t){return uH(t.tokenContext)}function Ih(t,e){let r=lt(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 Bk(t){let e=lt(t);return X(t,e.join(t,".agentsmesh"))}function Vr(t,e){let r=lt(t),n=Bk(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 Kk(t,e,r){let n=lt(t),o=Bk(t),i=X(t,e);if(!Vr(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 Ch(t,e,r){let o=lt(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 Rl(t,e,r){let n=Ch(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function kh(t,e,r,n,o){let i=lt(t),a=X(t,t),l=X(t,e),c=X(t,r);if(!Ih(t,c))return Rl(t,c,n)?.text??null;let m=X(t,i.dirname(l));if(!Ih(t,m)&&m!==a)return Rl(t,c,n)?.text??null;let p=i.relative(m,c).replace(/\\/g,"/");if(i.isAbsolute(p)||Hr.test(p))return Ch(t,c,n);let u=X(t,i.join(m,p));return Ih(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):Ch(t,c,n)}var Eh=d(()=>{pe();s(uH,"isReadingContext");s(Uk,"isReadingContextOptions");s(Ih,"isUnderProjectRoot");s(Bk,"agentsMeshRoot");s(Vr,"isUnderAgentsMesh");s(Kk,"toAgentsMeshRootRelative");s(Ch,"toProjectRootRelative");s(Rl,"toProjectRootReference");s(kh,"formatLinkPathForDestinationLegacy");});function Wk(t,e,r,n,o={}){let i=o.scope??"project",a=X(t,r);if(Uk(o)&&Vr(t,e)&&Vr(t,a)){let m=lt(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 kh(t,e,r,n,o);if(i==="global"&&!Vr(t,e))return Rl(t,a,n)?.text??null;let l=(()=>{if(Vr(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&Vr(t,X(t,m))?X(t,m):null})();if(!l)return Rl(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=Kk(t,l,n);return m!==null?m:Rl(t,l,n)?.text??null}return kh(t,e,r,n,o)}var Hk=d(()=>{Ts();pe();Eh();Eh();s(Wk,"formatLinkPathForDestination");});function zk(t,e,r,n){let o=lt(e),i=Gt(t);if(!zr(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 Vk=d(()=>{pe();Ts();s(zk,"resolveByDestinationSuffixStrip");});function Jk(t){let e=null,r=false,n=null,o=null,i=null;for(let c of mm(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of pm(t.projectRoot,c)){let f=X(t.projectRoot,u),g=X(t.projectRoot,t.translatePath(f)),h=t.pathExists(f),S=t.pathExists(g);if(S&&g!==f){e=g,n=f,r=true;break}(h||S)&&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=zk(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=Gt(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&Gt(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var Yk=d(()=>{pe();Ts();Vk();s(Jk,"resolveLinkTarget");});function Xk(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function Zk(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 Qk(t){let e=Gt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Hr.test(e)||zr(e)?false:e.includes("/")}var qk=d(()=>{pe();Ts();s(Xk,"isTildeHomeRelativePathToken");s(Zk,"isMarkdownLinkDestinationToken");s(Qk,"isRelativePathToken");});function dH(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===`
59
+ `)break;i+=a,o++;}return i===r}function tE(t,e,r){let n=t.lastIndexOf(`
56
60
  `,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===`
57
- `||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function jk(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:Gk(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 Uk(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=fl(n),a=i.replace(gl,""),l=Gt(a),c=e+a.length,m=t[e-1],p=t[r];return Gk(t,e,c)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!Hr(l)&&MW(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 Bk=d(()=>{pe();Ps();s(MW,"markdownBracketLabelDuplicatesDestination");s(Gk,"isMarkdownReferenceDefinitionDestination");s(jk,"getTokenContext");s(Uk,"shouldRewritePathToken");});function Iu(t){let e=new Set,r=Ru(t.content);return {content:t.content.replace(Ek,(o,i,a)=>{if(r.some(([bt,Ft])=>i>=bt&&i<Ft)||!Uk(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||Fk(a,i,o)||Lk(a,i,i+o.length))return o;let{candidate:l,suffix:c}=fl(o);if(!l)return o;let m=gl.exec(l),p=m?l.slice(0,m.index):l,u=m?m[0]:"";if(!p)return o;let f=jk(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&Wr.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:R}=Dk({candidate:p,rawToken:l,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),k=h;if(!R||!g)return g&&e.add(g),o;let I=Gt(p),C=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(C&&!I.includes("/")&&!I.includes("\\"))return o;if(k===null){let bt=Gt(l);if(bt.startsWith("agentsmesh/")&&(bt=`.${bt}`),bt.startsWith(".agentsmesh/")||bt.includes("/.agentsmesh/")){let Ft=at(t.projectRoot),Qt=X(t.projectRoot,t.projectRoot),Ei=bt.replace(/^\.\//,"");k=X(t.projectRoot,Ft.join(Qt,Ei));}}let b=at(t.projectRoot);if(t.scope==="global"){let bt=Gt(l),Ft=bt.startsWith(".agentsmesh/")||bt.includes("/.agentsmesh/"),Qt=Hr(bt)||Mk(bt),Ei=k!==null&&zr(t.projectRoot,k),Mp=zr(t.projectRoot,g);if(k===g&&!Mp&&!Ei&&!Ft){let jc=Gt(b.relative(t.projectRoot,X(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",$p=(k!==null?Gt(b.relative(t.projectRoot,k)):"").split("/").filter(Boolean)[0]??"";if(jc.length>0&&jc===$p)return o}if(!Qt&&!Ft&&!Ei&&!Mp)return o}let N=X(t.projectRoot,t.destinationFile),T=X(t.projectRoot,g),B=Gt(b.relative(t.projectRoot,N)),H=Gt(b.relative(t.projectRoot,T)),tt=B.split("/").filter(Boolean)[0]??"",it=H.split("/").filter(Boolean)[0]??"",vt=!Gt(p).startsWith(".agentsmesh/")&&!C&&tt.length>0&&tt===it&&tt.startsWith(".")&&tt!==".agentsmesh"||f.role==="markdown-link-dest"||vk(a,i,p),ae=bk(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||vt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:C?null:k,forceRelative:vt,tokenContext:f,originalToken:p});return ae?`${ae}${u}${c}`:o}),missing:[...e]}}var fh=d(()=>{pe();Ps();Pk();Nk();$k();Bk();s(Iu,"rewriteFileLinks");});function Wk(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 W(t,e,r="project"){let n=at(e),o=new Map,i=Array.from(new Set([t,...$t]));for(let c of i){let m=await Rk(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 Wk(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 Wk(n,m))l.add(n.normalize(p));}return (c,m,p)=>Iu({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(()=>{pe();Ik();fh();Sn();s(Wk,"pathVariants");s(W,"createImportReferenceNormalizer");});async function Ht(t,e,r){let n=join(t,e),i={...await UW(n),...r};await O(dirname(n)),await S(n,JSON.stringify({mcpServers:i},null,2));}async function UW(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(Ht,"writeMcpWithMerge");s(UW,"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 Ts(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(Ts,"toStringArray");s(wn,"toStringRecord");});function WW(t,e){return e.some(r=>t.endsWith(r))}async function St(t){let r=(await G(t.srcDir)).filter(o=>WW(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(WW,"matchesExtension");s(St,"importFileDirectory");});function zk(t){return typeof t=="string"?t:void 0}function HW(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function hh(t,e){return e?e(t):t}function zW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=P(e.normalizeTo(r)),i=hh(n,t.frontmatterRemap),a=HW({root:false,description:zk(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 VW(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=P(e.normalizeTo(r)),i=hh(n,t.frontmatterRemap),a=await It(r,{hasDescription:true,description:zk(i.description),hasAllowedTools:true,allowedTools:Ts(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}=P(e.normalizeTo(r)),i=hh(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Yt(r,i,o)}}}function Vk(t){if(t.map)return t.map;switch(t.preset){case "rule":return zW(t);case "command":return VW(t);case "agent":return JW(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Jk=d(()=>{U();ft();cr();s(zk,"pickString");s(HW,"pruneUndefined");s(hh,"applyRemap");s(zW,"ruleMapper");s(VW,"commandMapper");s(JW,"agentMapper");s(Vk,"resolveMapper");});function yh(t,e){return t?t[e]??[]:[]}var Yk,Xk=d(()=>{Yk=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(yh,"resolveScopedSources");});async function QW(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(I=>o(c,l,I),"normalizeTo");if(t.map){let I;try{I=await t.map({absolutePath:l,relativePath:a,content:c,destDir:i,normalizeTo:p});}catch(C){let b=C instanceof Error?C.message:String(C);process.stderr.write(`\u26A0 skipping ${l}: ${b}
58
- `);continue}if(!I)continue;return await S(I.destPath,I.content),[{fromTool:n,fromPath:l,toPath:I.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,R=t.markAsRoot?{...h,root:true}:h,k=await z(m,R,g);return await S(m,k),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function qW(t,e,r,n,o){let i=Vk(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(eu(basename(u)))return null;let R;try{R=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(k=>h(k),"normalizeTo")});}catch(k){let I=k instanceof Error?k.message:String(k);return process.stderr.write(`\u26A0 skipping ${u}: ${I}
60
- `),null}return R?{destPath:R.destPath,toPath:R.toPath,feature:t.feature,content:R.content}:null},"mapEntry")});l.push(...p);}return l}function Qk(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function tH(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=Qk(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 eH(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:Ts(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 rH(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=Qk(t);for(let i of e){let a=join(r,i),l=await _(a);if(l===null)continue;let c=eH(l);return Object.keys(c).length===0?[]:(await Ht(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function Zk(t,e,r,n,o){switch(t.mode){case "singleFile":return QW(t,e,r,n,o);case "directory":return qW(t,e,r,n,o);case "flatFile":return tH(t,e,r,n);case "mcpJson":return rH(t,e,r,n)}}async function nH(t,e,r,n,o){let i=yh(t.source,e),a=yh(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let l=await Zk(t,i,r,n,o);if(l.length>0)return l}return a.length>0?Zk(t,a,r,n,o):[]}function oH(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 W(t.id,e,r),a=[];for(let l of Yk)for(let c of oH(o,l))a.push(...await nH(c,r,e,t.id,i));return a}var Ot=d(()=>{gt();A();Vr();U();cr();ft();Me();Jk();Eo();Xk();s(QW,"runSingleFile");s(qW,"runDirectory");s(Qk,"resolveCanonicalFilePath");s(tH,"runFlatFile");s(eH,"parseMcpJson");s(rH,"runMcpJson");s(Zk,"dispatchSpec");s(nH,"runSpec");s(oH,"specsForFeature");s(Y,"runDescriptorImport");});async function qk(t,e={}){let r=e.scope??"project",n=[],o=await W(On,t,r);return n.push(...await Y(Su,t,r,{normalize:o})),await et(t,r==="global"?ar:me,On,n,o),n}var tE=d(()=>{gt();rt();Ot();dl();_h();s(qk,"importFromAider");});function sH(t,e){return rE(e).some(n=>iH(t,n))}function eE(t,e){return t.filter(r=>sH(r,e))}function rE(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 rE(r+l+o))a.push(c);return a}function iH(t,e){return aH(e).test(t)}function aH(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 nE=d(()=>{s(sH,"globMatch");s(eE,"globFilter");s(rE,"expandBraces");s(iH,"matchOne");s(aH,"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(eE(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(()=>{nE();s(J,"validateRules");});function sE(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:On}))}var iE=d(()=>{Ct();dl();s(sE,"lintRules");});function D(t,e,r){return {level:"warning",file:t,target:e,message:r}}function lH(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 Ds(t,e,r,n){let o=n?.unsupportedBy??e,i=lH(r);return D(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var wt=d(()=>{s(D,"createWarning");s(lH,"formatOxfordComma");s(Ds,"createUnsupportedHookWarning");});function aE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function lE(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?[]:[D(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function cE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var mE=d(()=>{wt();s(aE,"lintHooks");s(lE,"lintPermissions");s(cE,"lintMcp");});function E(t,e){return at(t).relative(t,e).replace(/\\/g,"/")}async function L(t,e){return G(at(t).join(t,e)).catch(()=>[])}function uE(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function fH(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)uE(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function F(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function $(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,`${pE}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let l=o.startsWith(ll)?ll:o.startsWith(qc)?qc:null;if(l&&a==="SKILL.md"){t.set(e,`${uH}/${o.slice(l.length)}.md`);return}let c=o.startsWith(cl)?cl:o.startsWith(tm)?tm:null;if(c&&a==="SKILL.md"){t.set(e,`${dH}/${o.slice(c.length)}.md`);return}let m=`${pE}/${o}`;a==="SKILL.md"&&uE(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&fH(t,e,p,`${r}/${o}`);}function gH(t){return t.split("/").filter(Boolean)[0]??""}async function hH(){if(Rh!==void 0)return Rh;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(Tt(),dE)),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=gH(n);o.startsWith(".")&&e.add(o);}return Rh=e,e}function Sh(t){return t.split("/").some(e=>e.startsWith("."))}async function yH(t){let e=[],r=await hH(),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)||Sh(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)||Sh(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 Cu(t,e){let r=await yH(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(Sh(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${pH}/${c}.md`);}}var pH,uH,dH,pE,Rh,kt=d(()=>{pe();A();Lt();ut();pH=".agentsmesh/rules",uH=".agentsmesh/commands",dH=".agentsmesh/agents",pE=".agentsmesh/skills";s(E,"rel");s(L,"listFiles");s(uE,"addDirectoryMapping");s(fH,"addAncestorMappings");s(F,"addSimpleFileMapping");s($,"addSkillLikeMapping");s(gH,"firstPathSegment");s(hH,"targetRootSegments");s(Sh,"hasHiddenSegment");s(yH,"listScopedAgentsFiles");s(Cu,"addScopedAgentsMappings");});var w,lt,At,Rt=d(()=>{w=".agentsmesh/rules",lt=".agentsmesh/commands",At=".agentsmesh/agents";});async function Ch(t,e,r="project"){if(r==="global"){t.set(bo,`${w}/_root.md`);for(let n of await L(e,ar))$(t,E(e,n),ar);t.set(Di,".agentsmesh/ignore");return}t.set(ir,`${w}/_root.md`);for(let n of await L(e,me))$(t,E(e,n),me);t.set(Ao,".agentsmesh/ignore");}var fE=d(()=>{kt();dl();Rt();s(Ch,"buildAiderImportPaths");});var Ni,Jr,Fi,Ns,cm,gE,hE,mm=d(()=>{Ni="amazon-q",Jr=".amazonq/rules",Fi=".amazonq/mcp.json",Ns=".aws/amazonq/rules",cm=".aws/amazonq/mcp.json",gE=".agentsmesh/rules",hE=".agentsmesh/mcp.json";});async function kh(t,e,r="project"){let n=r==="global"?Ns:Jr;for(let o of await L(e,n)){let i=E(e,o);F(t,i,w,".md");}}var yE=d(()=>{kt();mm();Rt();s(kh,"buildAmazonQImportPaths");});var mr,ue,An,Eh,To,pr,xo,_E,vi=d(()=>{mr="AGENTS.md",ue=".agents/skills",An=".amp/settings.json",Eh=".config/amp",To=`${Eh}/AGENTS.md`,pr=`${Eh}/skills`,xo=`${Eh}/settings.json`,_E=".agentsmesh/rules";});async function Lh(t,e,r="project"){if(r==="global"){t.set(To,`${w}/_root.md`);for(let n of await L(e,pr))$(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,ue))$(t,E(e,n),ue);t.set(An,".agentsmesh/mcp.json");}var RE=d(()=>{kt();vi();Rt();s(Lh,"buildAmpImportPaths");});var Mi,ku,Yr,ur,pm,Xr,bn,um,Pn,Tn,dm,yl,Oh,$i,Eu,IE,Gi=d(()=>{Mi="antigravity",ku=".agents",Yr=`${ku}/rules`,ur=`${Yr}/general.md`,pm=`${Yr}/_root.md`,Xr=`${ku}/skills`,bn=`${ku}/workflows`,um=`${ku}/antigravity/mcp_config.json`,Pn=".gemini/antigravity/GEMINI.md",Tn=".gemini/antigravity/skills",dm=".gemini/antigravity/workflows",yl=".gemini/antigravity/mcp_config.json",Oh=".agentsmesh/rules/_root.md",$i=".agentsmesh/rules",Eu=".agentsmesh/commands",IE=".agentsmesh/mcp.json";});async function wh(t,e,r="project"){if(r==="global"){t.set(Pn,`${w}/_root.md`);for(let n of await L(e,Tn))$(t,E(e,n),Tn);t.set(yl,".agentsmesh/mcp.json");return}t.set(ur,`${w}/_root.md`),t.set(pm,`${w}/_root.md`);for(let n of await L(e,Yr)){let o=E(e,n);o===ur||o===pm||F(t,o,w,".md");}for(let n of await L(e,bn))F(t,E(e,n),lt,".md");for(let n of await L(e,Xr))$(t,E(e,n),Xr);}var SE=d(()=>{kt();Gi();Rt();s(wh,"buildAntigravityImportPaths");});var de,Lu,$e,dr,Ge,xn,Dn,Ou,Do,No,Nn,Fo,Ah,bh,Ph,Th,ji=d(()=>{de="augment-code",Lu=".augment",$e=`${Lu}/rules`,dr=`${Lu}/commands`,Ge=`${Lu}/skills`,xn=`${Lu}/settings.json`,Dn=".augmentignore",Ou=".augment",Do=`${Ou}/rules`,No=`${Ou}/commands`,Nn=`${Ou}/skills`,Fo=`${Ou}/settings.json`,Ah=".agentsmesh/rules",bh=".agentsmesh/mcp.json",Ph=".agentsmesh/hooks.yaml",Th=".agentsmesh/ignore";});async function xh(t,e,r="project"){if(r==="global"){for(let n of await L(e,Do))F(t,E(e,n),w,".md");for(let n of await L(e,No))F(t,E(e,n),lt,".md");for(let n of await L(e,Nn))$(t,E(e,n),Nn);t.set(Fo,".agentsmesh/mcp.json");return}for(let n of await L(e,$e))F(t,E(e,n),w,".md");for(let n of await L(e,dr))F(t,E(e,n),lt,".md");for(let n of await L(e,Ge))$(t,E(e,n),Ge);t.set(xn,".agentsmesh/mcp.json"),t.set(Dn,".agentsmesh/ignore");}var CE=d(()=>{kt();ji();Rt();s(xh,"buildAugmentCodeImportPaths");});var kE,Fs,EE,fm,gm,hm,ym,_m,vo,Dh,Rm,_l,Im,Sm,wu,Au,Nh,Cm,Fh,Ui,LE,Mo=d(()=>{kE="claude-code",Fs=".claude/CLAUDE.md",EE="CLAUDE.md",fm=".claude/rules",gm=".claude/commands",hm=".claude/agents",ym=".claude/skills",_m=".claude/settings.json",vo=".claude/hooks.json",Dh=".claude/output-styles",Rm=".claudeignore",_l=".mcp.json",Im=".claude.json",Sm=".agentsmesh/rules",wu=".agentsmesh/commands",Au=".agentsmesh/agents",Nh=".agentsmesh/skills",Cm=".agentsmesh/mcp.json",Fh=".agentsmesh/permissions.yaml",Ui=".agentsmesh/hooks.yaml",LE=".agentsmesh/ignore";});async function vh(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${w}/_root.md`),t.set(vo,Ui),r==="project"&&t.set("CLAUDE.md",`${w}/_root.md`),r==="global")for(let n of await L(e,".agents/skills"))$(t,E(e,n),".agents/skills");for(let n of await L(e,".claude/rules"))F(t,E(e,n),w,".md");for(let n of await L(e,".claude/commands"))F(t,E(e,n),lt,".md");for(let n of await L(e,".claude/agents"))F(t,E(e,n),At,".md");for(let n of await L(e,".claude/skills"))$(t,E(e,n),".claude/skills");}var OE=d(()=>{kt();Mo();Rt();s(vh,"buildClaudeCodeImportPaths");});var vs,$o,Bi,Go,wE,te,Fn,Ms,Ki,Wi,Hi,zi,Mh,$s,bu,$h,Gh,AE,bE,fr=d(()=>{vs="cline",$o=".clinerules",Bi=".clineignore",Go=".cline/cline_mcp_settings.json",wE=".cline/mcp_settings.json",te=".cline/skills",Fn=".clinerules/workflows",Ms="AGENTS.md",Ki=".clinerules/hooks",Wi="Documents/Cline/Rules",Hi="Documents/Cline/Workflows",zi="Documents/Cline/Hooks",Mh=".agentsmesh/hooks.yaml",$s=".agentsmesh/rules",bu=".agentsmesh/commands",$h=".agentsmesh/ignore",Gh=".agentsmesh/mcp.json",AE=".agentsmesh/agents",bE=".agentsmesh/skills";});async function jh(t,e,r="project"){if(r==="global"){for(let n of await L(e,Wi))F(t,E(e,n),w,".md");for(let n of await L(e,Hi))F(t,E(e,n),lt,".md");for(let n of await L(e,te))$(t,E(e,n),te);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"||F(t,o,w,".md");}for(let n of await L(e,".clinerules/workflows"))F(t,E(e,n),lt,".md");for(let n of await L(e,".cline/skills"))$(t,E(e,n),".cline/skills");}var PE=d(()=>{kt();fr();Rt();s(jh,"buildClineImportPaths");});async function Uh(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 Cu(t,e)),r==="project")for(let n of await L(e,".codex/instructions"))F(t,E(e,n),w,".md");for(let n of await L(e,".codex/rules")){let o=E(e,n);o.endsWith(".rules")?F(t,o,w,".rules"):o.endsWith(".md")&&F(t,o,w,".md");}for(let n of await L(e,".codex/agents"))F(t,E(e,n),At,".toml");for(let n of await L(e,".agents/skills"))$(t,E(e,n),".agents/skills");}var TE=d(()=>{kt();Rt();s(Uh,"buildCodexCliImportPaths");});var Rl,Zr,vn,Bh,Pu,jo,Kh,je,Il,km,Tu,xu,Wh,Mn=d(()=>{Rl="continue",Zr=".continue/rules",vn=".continue/prompts",Bh=".continue/mcpServers",Pu=`${Bh}/agentsmesh.json`,jo=`${Zr}/general.md`,Kh=`${Zr}/_root.md`,je=".continue/skills",Il=".continue/AGENTS.md",km=".continue/config.yaml",Tu=".agentsmesh/rules",xu=".agentsmesh/commands",Wh=".agentsmesh/mcp.json";});async function Hh(t,e,r="project"){t.set(jo,`${w}/_root.md`),t.set(Kh,`${w}/_root.md`);for(let n of await L(e,".continue/rules")){let o=E(e,n);o===jo||o===Kh||F(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"))$(t,E(e,n),".continue/skills");if(r==="global")for(let n of await L(e,".agents/skills"))$(t,E(e,n),".agents/skills");}var xE=d(()=>{kt();Mn();Rt();s(Hh,"buildContinueImportPaths");});function IH(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${w}/${basename(e,".instructions.md")}.md`);return}F(t,e,w,".md");}async function zh(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"))IH(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"))$(t,E(e,r),".github/skills");}var DE=d(()=>{kt();Rt();s(IH,"addCopilotInstructionMapping");s(zh,"buildCopilotImportPaths");});var gr,hr,ee,Ue,Uo,NE,Nu,Be,Vi,Fu,vu,Mu,Sl=d(()=>{gr="crush",hr="CRUSH.md",ee=".crush/skills",Ue="crush.json",Uo=".crushignore",NE=".config/crush",Nu=`${NE}/crush.json`,Be=".config/crush/skills",Vi=`${NE}/CRUSH.md`,Fu=".agentsmesh/rules",vu=".agentsmesh/ignore",Mu=".agentsmesh/mcp.json";});async function Vh(t,e,r="project"){if(r==="global"){for(let n of await L(e,Be))$(t,E(e,n),Be);return}t.set(hr,`${Fu}/_root.md`),t.set(Ue,Mu),t.set(Uo,vu);for(let n of await L(e,ee))$(t,E(e,n),ee);}var FE=d(()=>{kt();Sl();s(Vh,"buildCrushImportPaths");});var vE,Gs,ME,yr,Bo,_r,Rr,fe,Ke,$n,$u,Qr,Jh,SH,Cl,qr,Gn,js,Us,$E,kl,Yh,Em,Xh,zt=d(()=>{vE="cursor",Gs="AGENTS.md",ME=".cursorrules",yr=".cursor/rules",Bo=`${yr}/general.mdc`,_r=".cursor/commands",Rr=".cursor/agents",fe=".cursor/skills",Ke=".cursor/mcp.json",$n=".cursor/hooks.json",$u=".cursor/settings.json",Qr=".cursorignore",Jh=".cursorindexingignore",SH=".agentsmesh-exports/cursor",Cl=`${SH}/user-rules.md`,qr=".cursor/AGENTS.md",Gn=".agentsmesh/rules",js=".agentsmesh/commands",Us=".agentsmesh/agents",$E=".agentsmesh/skills",kl=".agentsmesh/mcp.json",Yh=".agentsmesh/permissions.yaml",Em=".agentsmesh/hooks.yaml",Xh=".agentsmesh/ignore";});async function Zh(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"))F(t,E(e,n),w,".mdc");for(let n of await L(e,".cursor/commands"))F(t,E(e,n),lt,".md");for(let n of await L(e,".cursor/agents"))F(t,E(e,n),At,".md");for(let n of await L(e,".cursor/skills"))$(t,E(e,n),".cursor/skills");return}t.set("AGENTS.md",`${w}/_root.md`);for(let n of await L(e,".cursor/rules"))F(t,E(e,n),w,".mdc");for(let n of await L(e,".cursor/commands"))F(t,E(e,n),lt,".md");for(let n of await L(e,".cursor/agents"))F(t,E(e,n),At,".md");for(let n of await L(e,".cursor/skills"))$(t,E(e,n),".cursor/skills");}var GE=d(()=>{kt();zt();Rt();s(Zh,"buildCursorImportPaths");});var jn,Ir,ge,Ko,Wo,tn,Ji,jE,El=d(()=>{jn="deepagents-cli",Ir=".deepagents/AGENTS.md",ge=".deepagents/skills",Ko=".mcp.json",Wo=".deepagents/AGENTS.md",tn=".deepagents/skills",Ji=".deepagents/.mcp.json",jE=".agentsmesh/rules";});async function Qh(t,e,r="project"){if(r==="global"){t.set(Wo,`${w}/_root.md`);for(let n of await L(e,tn))$(t,E(e,n),tn);t.set(Ji,".agentsmesh/mcp.json");return}t.set(Ir,`${w}/_root.md`);for(let n of await L(e,ge))$(t,E(e,n),ge);t.set(Ko,".agentsmesh/mcp.json");}var UE=d(()=>{kt();El();Rt();s(Qh,"buildDeepagentsCliImportPaths");});var Sr,Cr,Ae,Un,Bn,Ho,Kn,Yi,Bs,BE,Xi=d(()=>{Sr="factory-droid",Cr="AGENTS.md",Ae=".factory/skills",Un=".factory/droids",Bn=".factory/mcp.json",Ho=".factory/AGENTS.md",Kn=".factory/skills",Yi=".factory/droids",Bs=".factory/mcp.json",BE=".agentsmesh/rules";});async function qh(t,e,r="project"){if(r==="global"){t.set(Ho,`${w}/_root.md`);for(let n of await L(e,Yi))F(t,E(e,n),At,".md");for(let n of await L(e,Kn))$(t,E(e,n),Kn);t.set(Bs,".agentsmesh/mcp.json");return}t.set(Cr,`${w}/_root.md`);for(let n of await L(e,Un))F(t,E(e,n),At,".md");for(let n of await L(e,Ae))$(t,E(e,n),Ae);t.set(Bn,".agentsmesh/mcp.json");}var KE=d(()=>{kt();Xi();Rt();s(qh,"buildFactoryDroidImportPaths");});async function ty(t,e){for(let r of await L(e,".gemini/rules"))F(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"))F(t,E(e,r),At,".md");for(let r of await L(e,".gemini/skills"))$(t,E(e,r),".gemini/skills");}var WE=d(()=>{kt();Rt();s(ty,"buildGeminiCliImportPaths");});var Wn,kr,be,zo,HE,Vo,Zi,Er,zE,VE,Ll=d(()=>{Wn="goose",kr=".goosehints",be=".agents/skills",zo=".gooseignore",HE=".config/goose",Vo=`${HE}/.goosehints`,Zi=`${HE}/.gooseignore`,Er=".agents/skills",zE=".agentsmesh/rules",VE=".agentsmesh/ignore";});async function ey(t,e,r="project"){if(r==="global"){t.set(Vo,`${w}/_root.md`);for(let n of await L(e,Er))$(t,E(e,n),Er);t.set(Zi,".agentsmesh/ignore");return}t.set(kr,`${w}/_root.md`);for(let n of await L(e,be))$(t,E(e,n),be);t.set(zo,".agentsmesh/ignore");}var JE=d(()=>{kt();Ll();Rt();s(ey,"buildGooseImportPaths");});var Jo,en,YE,Ol=d(()=>{Jo="jules",en="AGENTS.md",YE=".agentsmesh/rules";});async function ry(t,e,r="project"){r!=="global"&&t.set(en,`${w}/_root.md`);}var XE=d(()=>{Ol();Rt();s(ry,"buildJulesImportPaths");});var Qi,Ks,Gu,ZE,Hn,QE,CH,Lm,qi,Om,wl,Al,wm,Am,bm,Pm,Tm,kH,ju,ta,qE,ny,Uu,tL,eL,rL,nL,bl=d(()=>{Qi="junie",Ks=".junie",Gu=`${Ks}/guidelines.md`,ZE=`${Ks}/ci-guidelines.md`,Hn=`${Ks}/AGENTS.md`,QE="AGENTS.md",CH=`${Ks}/mcp`,Lm=`${CH}/mcp.json`,qi=`${Ks}/skills`,Om=`${Ks}/rules`,wl=`${Ks}/commands`,Al=`${Ks}/agents`,wm=".aiignore",Am=".junie",bm=`${Am}/skills`,Pm=`${Am}/agents`,Tm=`${Am}/commands`,kH=`${Am}/mcp`,ju=`${kH}/mcp.json`,ta=`${Am}/AGENTS.md`,qE=".agents/skills",ny=".agentsmesh/rules/_root.md",Uu=".agentsmesh/rules",tL=".agentsmesh/commands",eL=".agentsmesh/agents",rL=".agentsmesh/mcp.json",nL=".agentsmesh/ignore";});async function oy(t,e){t.set(Gu,`${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"))F(t,E(e,r),w,".md");for(let r of await L(e,".junie/commands"))F(t,E(e,r),lt,".md");for(let r of await L(e,".junie/agents"))F(t,E(e,r),At,".md");for(let r of await L(e,".junie/skills"))$(t,E(e,r),".junie/skills");}var oL=d(()=>{kt();bl();Rt();s(oy,"buildJunieImportPaths");});var Se,xm,zn,Yo,Xo,Zo,rn,Ws,Pl,Bu,ea,Tl,ra,Dm,Ku,xl,Hs,na,oa,sa,zs,Dl,Wu,sL,Vs,Nl,ia,iL,aL,aa=d(()=>{Se="kilo-code",xm=".kilo",zn="AGENTS.md",Yo=`${xm}/rules`,Xo=`${xm}/commands`,Zo=`${xm}/agents`,rn=`${xm}/skills`,Ws=`${xm}/mcp.json`,Pl=".kilocodeignore",Bu=".kilocode",ea=`${Bu}/rules`,Tl=`${Bu}/workflows`,ra=`${Bu}/skills`,Dm=`${Bu}/mcp.json`,Ku=".kilocodemodes",xl=".kilo",Hs=`${xl}/AGENTS.md`,na=`${xl}/rules`,oa=`${xl}/commands`,sa=`${xl}/agents`,zs=`${xl}/skills`,Dl=`${xl}/mcp.json`,Wu=".kilocodeignore",sL=".agents/skills",Vs=".agentsmesh/rules",Nl=".agentsmesh/commands",ia=".agentsmesh/agents",iL=".agentsmesh/mcp.json",aL=".agentsmesh/ignore";});async function sy(t,e,r="project"){if(r==="global"){t.set(Hs,`${w}/_root.md`);for(let n of await L(e,na))F(t,E(e,n),w,".md");for(let n of await L(e,oa))F(t,E(e,n),lt,".md");for(let n of await L(e,sa))F(t,E(e,n),At,".md");for(let n of await L(e,zs))$(t,E(e,n),zs);t.set(Dl,".agentsmesh/mcp.json");return}t.set(zn,`${w}/_root.md`);for(let n of await L(e,Yo))F(t,E(e,n),w,".md");for(let n of await L(e,Xo))F(t,E(e,n),lt,".md");for(let n of await L(e,Zo))F(t,E(e,n),At,".md");for(let n of await L(e,rn))$(t,E(e,n),rn);t.set(Ws,".agentsmesh/mcp.json");for(let n of await L(e,ea)){let o=E(e,n);if(basename(o)==="00-root.md"){t.set(o,`${w}/_root.md`);continue}F(t,o,w,".md");}for(let n of await L(e,Tl))F(t,E(e,n),lt,".md");for(let n of await L(e,ra))$(t,E(e,n),ra);t.set(Dm,".agentsmesh/mcp.json");}var lL=d(()=>{kt();aa();Rt();s(sy,"buildKiloCodeImportPaths");});var We,nn,Nm,on,Ce,sn,Js,LH,Fl,vl,la,an,Ys,ca,Fm,vm,cL,iy,ay,mL,pL,ly,uL,Ml=d(()=>{We="kiro",nn="AGENTS.md",Nm=".kiro",on=`${Nm}/steering`,Ce=`${Nm}/skills`,sn=`${Nm}/agents`,Js=`${Nm}/hooks`,LH=`${Nm}/settings`,Fl=`${LH}/mcp.json`,vl=".kiroignore",la=".kiro/steering",an=".kiro/steering/AGENTS.md",Ys=".kiro/skills",ca=".kiro/agents",Fm=".kiro/settings/mcp.json",vm=".kiro/settings/kiroignore",cL=".agents/skills",iy=".agentsmesh/rules/_root.md",ay=".agentsmesh/rules",mL=".agentsmesh/agents",pL=".agentsmesh/mcp.json",ly=".agentsmesh/hooks.yaml",uL=".agentsmesh/ignore";});async function cy(t,e,r="project"){if(r==="global"){t.set(an,`${w}/_root.md`);for(let n of await L(e,la)){let o=E(e,n);o!==an&&F(t,o,w,".md");}for(let n of await L(e,Ys))$(t,E(e,n),Ys);for(let n of await L(e,ca))F(t,E(e,n),At,".md");return}t.set(nn,`${w}/_root.md`);for(let n of await L(e,on))F(t,E(e,n),w,".md");for(let n of await L(e,Ce))$(t,E(e,n),Ce);for(let n of await L(e,sn))F(t,E(e,n),At,".md");}var dL=d(()=>{kt();Ml();Rt();s(cy,"buildKiroImportPaths");});var ln,Hu,Vn,Qo,qo,ts,cn,Jn,$l,Xs,ma,pa,ua,Zs,Qs,fL,Mm,zu,Vu,my,da=d(()=>{ln="opencode",Hu=".opencode",Vn="AGENTS.md",Qo=`${Hu}/rules`,qo=`${Hu}/commands`,ts=`${Hu}/agents`,cn=`${Hu}/skills`,Jn="opencode.json",$l=".config/opencode",Xs=`${$l}/AGENTS.md`,ma=`${$l}/rules`,pa=`${$l}/commands`,ua=`${$l}/agents`,Zs=`${$l}/skills`,Qs=`${$l}/opencode.json`,fL=".agents/skills",Mm=".agentsmesh/rules",zu=".agentsmesh/commands",Vu=".agentsmesh/agents",my=".agentsmesh/mcp.json";});async function py(t,e,r="project"){if(r==="global"){t.set(Xs,`${w}/_root.md`);for(let n of await L(e,ma))F(t,E(e,n),w,".md");for(let n of await L(e,pa))F(t,E(e,n),lt,".md");for(let n of await L(e,ua))F(t,E(e,n),At,".md");for(let n of await L(e,Zs))$(t,E(e,n),Zs);t.set(Qs,".agentsmesh/mcp.json");return}t.set(Vn,`${w}/_root.md`);for(let n of await L(e,Qo))F(t,E(e,n),w,".md");for(let n of await L(e,qo))F(t,E(e,n),lt,".md");for(let n of await L(e,ts))F(t,E(e,n),At,".md");for(let n of await L(e,cn))$(t,E(e,n),cn);t.set(Jn,".agentsmesh/mcp.json");}var gL=d(()=>{kt();da();Rt();s(py,"buildOpencodeImportPaths");});var Yn,Lr,re,hL,es,Or,yL,Gl=d(()=>{Yn="pi-agent",Lr="AGENTS.md",re=".pi/skills",hL=".pi/agent",es=`${hL}/AGENTS.md`,Or=`${hL}/skills`,yL=".agentsmesh/rules";});async function uy(t,e,r="project"){if(r==="global"){t.set(es,`${w}/_root.md`);for(let n of await L(e,Or))$(t,E(e,n),Or);return}t.set(Lr,`${w}/_root.md`);for(let n of await L(e,re))$(t,E(e,n),re);}var dy=d(()=>{kt();Gl();Rt();s(uy,"buildPiAgentImportPaths");});var Xn,wr,rs,Zn,Qn,He,qs,ti,ns,fa,ei,qn,ri,fy,_L,RL,jl=d(()=>{Xn="qwen-code",wr="QWEN.md",rs=".qwen/rules",Zn=".qwen/commands",Qn=".qwen/agents",He=".qwen/skills",qs=".qwen/settings.json",ti=".qwenignore",ns=".qwen/QWEN.md",fa=".qwen/settings.json",ei=".qwen/commands",qn=".qwen/skills",ri=".qwen/agents",fy=".agentsmesh/rules",_L=".agentsmesh/commands",RL=".agentsmesh/agents";});async function gy(t,e,r="project"){if(r==="global"){t.set(ns,`${w}/_root.md`),t.set(fa,".agentsmesh/mcp.json");for(let n of await L(e,ei))F(t,E(e,n),lt,".md");for(let n of await L(e,ri))F(t,E(e,n),At,".md");for(let n of await L(e,qn))$(t,E(e,n),qn);return}t.set(wr,`${w}/_root.md`),t.set(qs,".agentsmesh/mcp.json"),t.set(ti,".agentsmesh/ignore");for(let n of await L(e,rs))F(t,E(e,n),w,".md");for(let n of await L(e,Zn))F(t,E(e,n),lt,".md");for(let n of await L(e,Qn))F(t,E(e,n),At,".md");for(let n of await L(e,He))$(t,E(e,n),He);}var IL=d(()=>{kt();Rt();jl();s(gy,"buildQwenCodeImportPaths");});var to,mn,Pe,SL,Ul=d(()=>{to="replit-agent",mn="replit.md",Pe=".agents/skills",SL=".agentsmesh/rules";});async function hy(t,e,r="project"){if(r!=="global"){t.set(mn,`${w}/_root.md`);for(let n of await L(e,Pe))$(t,E(e,n),Pe);}}var yy=d(()=>{kt();Ul();Rt();s(hy,"buildReplitAgentImportPaths");});var ni,ga,pn,$m,os,ss,eo,Gm,jm,Bl,Um,Ju,oi,si,is,ha,Bm,ii,CL,ya,Yu,kL,EL,_a=d(()=>{ni="roo-code",ga=".roo",pn=`${ga}/rules/00-root.md`,$m=".roorules",os=`${ga}/rules`,ss=`${ga}/commands`,eo=`${ga}/skills`,Gm=`${ga}/mcp.json`,jm=".rooignore",Bl=".roomodes",Um="settings/custom_modes.yaml",Ju=".roo",oi=`${Ju}/rules`,si=`${Ju}/commands`,is=`${Ju}/skills`,ha="mcp_settings.json",Bm=".rooignore",ii=`${Ju}/AGENTS.md`,CL=".agents/skills",ya=".agentsmesh/rules",Yu=".agentsmesh/commands",kL=".agentsmesh/mcp.json",EL=".agentsmesh/ignore";});async function _y(t,e,r="project"){if(r==="global"){t.set(ii,`${w}/_root.md`);for(let n of await L(e,oi))F(t,E(e,n),w,".md");for(let n of await L(e,si))F(t,E(e,n),lt,".md");for(let n of await L(e,is))$(t,E(e,n),is);t.set(ha,".agentsmesh/mcp.json");return}t.set(pn,`${w}/_root.md`),t.set($m,`${w}/_root.md`);for(let n of await L(e,os)){let o=E(e,n);o!==pn&&F(t,o,w,".md");}for(let n of await L(e,".roo")){let o=E(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&F(t,o,w,".md");}for(let n of await L(e,ss))F(t,E(e,n),lt,".md");for(let n of await L(e,eo))$(t,E(e,n),eo);}var LL=d(()=>{kt();_a();Rt();s(_y,"buildRooCodeImportPaths");});var ro,Ar,OL,ne,as,wL,ls,ze,Kl,AL,Wl=d(()=>{ro="rovodev",Ar="AGENTS.md",OL=".rovodev",ne=`${OL}/skills`,as=`${OL}/mcp.json`,wL=".rovodev",ls=".rovodev/AGENTS.md",ze=".rovodev/skills",Kl=".rovodev/mcp.json",AL=".agentsmesh/rules";});async function Ry(t,e,r="project"){if(r==="global"){t.set(ls,`${w}/_root.md`);for(let n of await L(e,ze))$(t,E(e,n),ze);t.set(Kl,".agentsmesh/mcp.json");return}t.set(Ar,`${w}/_root.md`);for(let n of await L(e,ne))$(t,E(e,n),ne);t.set(as,".agentsmesh/mcp.json");}var bL=d(()=>{kt();Wl();Rt();s(Ry,"buildRovodevImportPaths");});var br,Xu,Ve,Je,Pr,Ra,Hl,cs,Tr,un,Km,PL,Wm,TL,xL,zl=d(()=>{br="trae",Xu=".trae",Ve=`${Xu}/rules`,Je=`${Ve}/project_rules.md`,Pr=`${Xu}/skills`,Ra=`${Xu}/mcp.json`,Hl=`${Xu}/.ignore`,cs=".trae/user_rules",Tr=".trae/user_rules/rules.md",un=".trae/skills",Km=".trae/mcp.json",PL=".agents/skills",Wm=".agentsmesh/rules",TL=".agentsmesh/mcp.json",xL=".agentsmesh/ignore";});async function Iy(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&&F(t,o,w,".md");}for(let n of await L(e,un))$(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&&F(t,o,w,".md");}for(let n of await L(e,Pr))$(t,E(e,n),Pr);}var DL=d(()=>{kt();zl();Rt();s(Iy,"buildTraeImportPaths");});var no,dn,Sy,he,ai,Ye,NL,Vl=d(()=>{no="warp",dn="AGENTS.md",Sy="WARP.md",he=".warp/skills",ai=".mcp.json",Ye=".warp/skills",NL=".agentsmesh/rules";});async function Cy(t,e,r="project"){if(r==="global"){for(let n of await L(e,Ye))$(t,E(e,n),Ye);return}t.set(dn,`${w}/_root.md`);for(let n of await L(e,he))$(t,E(e,n),he);t.set(ai,".agentsmesh/mcp.json");}var FL=d(()=>{kt();Vl();Rt();s(Cy,"buildWarpImportPaths");});async function ky(t,e){t.set("AGENTS.md",`${w}/_root.md`),t.set(".windsurfrules",`${w}/_root.md`),await Cu(t,e);for(let r of await L(e,".windsurf/rules"))F(t,E(e,r),w,".md");for(let r of await L(e,".windsurf/workflows"))F(t,E(e,r),lt,".md");for(let r of await L(e,".windsurf/skills"))$(t,E(e,r),".windsurf/skills");}var vL=d(()=>{kt();Rt();s(ky,"buildWindsurfImportPaths");});var fn,oo,OH,so,ML,Ia=d(()=>{fn=".rules",oo=".zed/settings.json",OH=".config/zed",so=`${OH}/settings.json`,ML=".agentsmesh/rules";});async function Ey(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 $L=d(()=>{Ia();Rt();s(Ey,"buildZedImportPaths");});var GL=d(()=>{fE();yE();RE();SE();CE();OE();PE();TE();xE();DE();FE();GE();UE();KE();WE();JE();XE();oL();lL();dL();gL();dy();IL();yy();LL();bL();DL();FL();vL();$L();});var Et=d(()=>{GL();});var wH,AH,bH,jL,Su,_h=d(()=>{Lt();ut();gk();tE();iE();mE();Et();dl();wH={name:On,primaryRootInstructionPath:ir,generateRules:mk,generateCommands:uk,generateAgents:dk,generateSkills:pk,generateIgnore:fk,importFrom:qk},AH={rootInstructionPath:ir,skillDir:me,managedOutputs:{dirs:[me],files:[ir,Ao]},paths:{rulePath(t){return ir},commandPath(t){return `${me}/${V(t)}/SKILL.md`},agentPath(t){return `${me}/${K(t)}/SKILL.md`}}},bH={rootInstructionPath:bo,skillDir:ar,managedOutputs:{dirs:[ar],files:[bo,Di]},rewriteGeneratedPath(t){return t===ir?bo:t===Ao?Di:t.startsWith(`${me}/`)?t.replace(`${me}/`,`${ar}/`):t},paths:{rulePath(t){return bo},commandPath(t){return `${ar}/${V(t)}/SKILL.md`},agentPath(t){return `${ar}/${K(t)}/SKILL.md`}}},jL={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Su={id:On,metadata:{displayName:"Aider",category:"cli",officialUrl:"https://aider.chat",shortDescription:"Open-source terminal AI pair programmer"},generators:wH,capabilities:jL,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:sE,lint:{hooks:aE,permissions:lE,mcp:cE},supportsConversion:{commands:true,agents:true},project:AH,globalSupport:{capabilities:jL,detectionPaths:[bo,Di,ar],layout:bH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[ir],global:[bo]},canonicalDir:lk,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ao],global:[Di]},canonicalDir:".agentsmesh",canonicalFilename:ck}},buildImportPaths:Ch,detectionPaths:[ir,Ao]};});function UL(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(Ni))continue;let n=r.root?"_root":basename(r.source,".md");e.push({path:`${Jr}/${n}.md`,content:r.body.trim()});}return e}function BL(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Fi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var KL=d(()=>{mm();s(UL,"generateRules");s(BL,"generateMcp");});async function WL(t,e){let r=e?.scope??"project";return Y(Zu,t,r)}var HL=d(()=>{Ot();Ly();s(WL,"importFromAmazonQ");});function zL(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Ni}))}var VL=d(()=>{Ct();mm();s(zL,"lintRules");});var TH,xH,DH,NH,Zu,Ly=d(()=>{KL();HL();VL();Et();mm();TH={name:Ni,generateRules:UL,generateMcp:BL,importFrom:WL},xH={managedOutputs:{dirs:[Jr],files:[Fi]},paths:{rulePath(t,e){return `${Jr}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},DH={managedOutputs:{dirs:[Ns],files:[cm]},rewriteGeneratedPath(t){return t.startsWith(`${Jr}/`)?t.replace(`${Jr}/`,`${Ns}/`):t===Fi?cm:t},paths:{rulePath(t,e){return `${Ns}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},NH={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Zu={id:Ni,metadata:{displayName:"Amazon Q Developer",category:"ide",officialUrl:"https://aws.amazon.com/q/developer",shortDescription:"AWS AI coding assistant"},generators:TH,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:zL,project:xH,globalSupport:{capabilities:NH,detectionPaths:[Ns,cm],layout:DH},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Jr],global:[Ns]},canonicalDir:gE,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Fi],global:[cm]},canonicalDir:".agentsmesh",canonicalFilename:hE}},buildImportPaths:kh,detectionPaths:[Jr,Fi]};});function JL(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 YL(t){return st(t,ue)}function XL(t){return t.commands.map(e=>({path:`${ue}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function ZL(t){return t.agents.map(e=>({path:`${ue}/${K(e.name)}/SKILL.md`,content:xt(e)}))}var QL=d(()=>{rt();Wt();ut();Lt();vi();s(JL,"generateRules");s(YL,"generateSkills");s(XL,"generateCommands");s(ZL,"generateAgents");});function dt(t,e,r){let n=r.some(o=>FH.includes(o));return t.startsWith(`${e}/`)&&!n?`.agents/skills/${t.slice(e.length+1)}`:null}var FH,oe=d(()=>{FH=["amp","antigravity","codex-cli","goose","replit-agent"];s(dt,"mirrorSkillsToAgents");});async function tO(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 Ht(t,qL,l),r.push({fromTool:"amp",fromPath:e,toPath:qL,feature:"mcp"}));}var qL,eO=d(()=>{A();Vr();vi();qL=".agentsmesh/mcp.json";s(tO,"importAmpMcp");});async function rO(t,e={}){let r=e.scope??"project",n=[],o=await W("amp",t,r);return n.push(...await Y(Qu,t,r,{normalize:o})),await et(t,r==="global"?pr:ue,"amp",n,o),await tO(t,r==="global"?xo:An,n),n}var nO=d(()=>{gt();rt();Ot();eO();vi();Oy();s(rO,"importFromAmp");});function oO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var sO=d(()=>{Ct();vi();s(oO,"lintRules");});function iO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function aO(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?[]:[D(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function lO(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var cO=d(()=>{wt();s(iO,"lintHooks");s(aO,"lintPermissions");s(lO,"lintIgnore");});function jH(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 MH,$H,GH,mO,Qu,Oy=d(()=>{Lt();ut();QL();oe();nO();sO();cO();Et();vi();MH={name:"amp",primaryRootInstructionPath:mr,generateRules:JL,generateCommands:XL,generateAgents:ZL,generateSkills:YL,importFrom:rO},$H={rootInstructionPath:mr,skillDir:ue,managedOutputs:{dirs:[ue],files:[mr,An]},paths:{rulePath(t){return mr},commandPath(t){return `${ue}/${V(t)}/SKILL.md`},agentPath(t){return `${ue}/${K(t)}/SKILL.md`}}},GH={rootInstructionPath:To,skillDir:pr,managedOutputs:{dirs:[pr],files:[To,xo]},rewriteGeneratedPath(t){return t===mr?To:t===An?xo:t.startsWith(`${ue}/`)?t.replace(`${ue}/`,`${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}/${K(t)}/SKILL.md`}}},mO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(jH,"mergeAmpSettings");Qu={id:"amp",metadata:{displayName:"Amp",category:"cli",officialUrl:"https://ampcode.com",shortDescription:"Sourcegraph's coding agent"},generators:MH,capabilities:mO,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:oO,lint:{hooks:iO,permissions:aO,ignore:lO},supportsConversion:{commands:true,agents:true},project:$H,globalSupport:{capabilities:mO,detectionPaths:[To,xo],layout:GH},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[mr],global:[To]},canonicalDir:_E,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?jH(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Lh,detectionPaths:[mr,An],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function pO(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 uO(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
61
+ `||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function eE(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:tE(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 rE(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=yl(n),a=i.replace(_l,""),l=Gt(a),c=e+a.length,m=t[e-1],p=t[r];return tE(t,e,c)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!zr(l)&&dH(t,e,n)):m==="@"?true:m==="("&&t[e-2]==="]"?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?zr(l)?true:l.includes("/")||l.includes("\\")?l.startsWith("./")||l.startsWith("../")?true:(l.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var nE=d(()=>{pe();Ts();s(dH,"markdownBracketLabelDuplicatesDestination");s(tE,"isMarkdownReferenceDefinitionDestination");s(eE,"getTokenContext");s(rE,"shouldRewritePathToken");});function wu(t){let e=new Set,r=Ou(t.content);return {content:t.content.replace(Gk,(o,i,a)=>{if(r.some(([bt,Ft])=>i>=bt&&i<Ft)||!rE(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||Xk(a,i,o)||jk(a,i,i+o.length))return o;let{candidate:l,suffix:c}=yl(o);if(!l)return o;let m=_l.exec(l),p=m?l.slice(0,m.index):l,u=m?m[0]:"";if(!p)return o;let f=eE(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&Hr.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:S}=Jk({candidate:p,rawToken:l,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),C=h;if(!S||!g)return g&&e.add(g),o;let R=Gt(p),k=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(k&&!R.includes("/")&&!R.includes("\\"))return o;if(C===null){let bt=Gt(l);if(bt.startsWith("agentsmesh/")&&(bt=`.${bt}`),bt.startsWith(".agentsmesh/")||bt.includes("/.agentsmesh/")){let Ft=lt(t.projectRoot),Qt=X(t.projectRoot,t.projectRoot),Oi=bt.replace(/^\.\//,"");C=X(t.projectRoot,Ft.join(Qt,Oi));}}let b=lt(t.projectRoot);if(t.scope==="global"){let bt=Gt(l),Ft=bt.startsWith(".agentsmesh/")||bt.includes("/.agentsmesh/"),Qt=zr(bt)||Qk(bt),Oi=C!==null&&Vr(t.projectRoot,C),Wp=Vr(t.projectRoot,g);if(C===g&&!Wp&&!Oi&&!Ft){let Wc=Gt(b.relative(t.projectRoot,X(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",Hp=(C!==null?Gt(b.relative(t.projectRoot,C)):"").split("/").filter(Boolean)[0]??"";if(Wc.length>0&&Wc===Hp)return o}if(!Qt&&!Ft&&!Oi&&!Wp)return o}let N=X(t.projectRoot,t.destinationFile),x=X(t.projectRoot,g),B=Gt(b.relative(t.projectRoot,N)),H=Gt(b.relative(t.projectRoot,x)),tt=B.split("/").filter(Boolean)[0]??"",it=H.split("/").filter(Boolean)[0]??"",vt=!Gt(p).startsWith(".agentsmesh/")&&!k&&tt.length>0&&tt===it&&tt.startsWith(".")&&tt!==".agentsmesh"||f.role==="markdown-link-dest"||Zk(a,i,p),ae=Wk(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||vt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:k?null:C,forceRelative:vt,tokenContext:f,originalToken:p});return ae?`${ae}${u}${c}`:o}),missing:[...e]}}var Lh=d(()=>{pe();Ts();Hk();Yk();qk();nE();s(wu,"rewriteFileLinks");});function sE(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 W(t,e,r="project"){let n=lt(e),o=new Map,i=Array.from(new Set([t,...$t]));for(let c of i){let m=await Nk(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 sE(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 sE(n,m))l.add(n.normalize(p));}return (c,m,p)=>wu({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(()=>{pe();Fk();Lh();kn();s(sE,"pathVariants");s(W,"createImportReferenceNormalizer");});async function Ht(t,e,r){let n=join(t,e),i={...await yH(n),...r};await O(dirname(n)),await I(n,JSON.stringify({mcpServers:i},null,2));}async function yH(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 Jr=d(()=>{A();s(Ht,"writeMcpWithMerge");s(yH,"readExistingServers");});function xo(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function cr(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 Ds(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function bn(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var mr=d(()=>{s(xo,"toGlobsArray");s(cr,"toToolsArray");s(Ds,"toStringArray");s(bn,"toStringRecord");});function SH(t,e){return e.some(r=>t.endsWith(r))}async function It(t){let r=(await G(t.srcDir)).filter(o=>SH(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 $e=d(()=>{A();s(SH,"matchesExtension");s(It,"importFileDirectory");});function aE(t){return typeof t=="string"?t:void 0}function IH(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function wh(t,e){return e?e(t):t}function CH(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=P(e.normalizeTo(r)),i=wh(n,t.frontmatterRemap),a=IH({root:false,description:aE(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 kH(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=P(e.normalizeTo(r)),i=wh(n,t.frontmatterRemap),a=await St(r,{hasDescription:true,description:aE(i.description),hasAllowedTools:true,allowedTools:Ds(i["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function EH(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=P(e.normalizeTo(r)),i=wh(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Yt(r,i,o)}}}function lE(t){if(t.map)return t.map;switch(t.preset){case "rule":return CH(t);case "command":return kH(t);case "agent":return EH(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var cE=d(()=>{U();ft();mr();s(aE,"pickString");s(IH,"pruneUndefined");s(wh,"applyRemap");s(CH,"ruleMapper");s(kH,"commandMapper");s(EH,"agentMapper");s(lE,"resolveMapper");});function Ah(t,e){return t?t[e]??[]:[]}var mE,pE=d(()=>{mE=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(Ah,"resolveScopedSources");});async function AH(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(R=>o(c,l,R),"normalizeTo");if(t.map){let R;try{R=await t.map({absolutePath:l,relativePath:a,content:c,destDir:i,normalizeTo:p});}catch(k){let b=k instanceof Error?k.message:String(k);process.stderr.write(`\u26A0 skipping ${l}: ${b}
62
+ `);continue}if(!R)continue;return await I(R.destPath,R.content),[{fromTool:n,fromPath:l,toPath:R.toPath,feature:t.feature}]}let u=jr(p(m),l);if(!u.ok){process.stderr.write(`\u26A0 skipping ${l}: ${u.error.message}
63
+ `);continue}let{frontmatter:f,body:g}=u.value,h=t.frontmatterRemap?t.frontmatterRemap(f):f,S=t.markAsRoot?{...h,root:true}:h,C=await z(m,S,g);return await I(m,C),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function bH(t,e,r,n,o){let i=lE(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),p=await It({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:s(async({srcPath:u,relativePath:f,content:g,normalizeTo:h})=>{if(lu(basename(u)))return null;let S;try{S=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(C=>h(C),"normalizeTo")});}catch(C){let R=C instanceof Error?C.message:String(C);return process.stderr.write(`\u26A0 skipping ${u}: ${R}
64
+ `),null}return S?{destPath:S.destPath,toPath:S.toPath,feature:t.feature,content:S.content}:null},"mapEntry")});l.push(...p);}return l}function dE(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function PH(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=dE(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 xH(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:Ds(a.args),env:bn(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:bn(a.headers),env:bn(a.env),description:l});}return n}async function TH(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=dE(t);for(let i of e){let a=join(r,i),l=await _(a);if(l===null)continue;let c=xH(l);return Object.keys(c).length===0?[]:(await Ht(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function uE(t,e,r,n,o){switch(t.mode){case "singleFile":return AH(t,e,r,n,o);case "directory":return bH(t,e,r,n,o);case "flatFile":return PH(t,e,r,n);case "mcpJson":return TH(t,e,r,n)}}async function DH(t,e,r,n,o){let i=Ah(t.source,e),a=Ah(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let l=await uE(t,i,r,n,o);if(l.length>0)return l}return a.length>0?uE(t,a,r,n,o):[]}function NH(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 W(t.id,e,r),a=[];for(let l of mE)for(let c of NH(o,l))a.push(...await DH(c,r,e,t.id,i));return a}var Ot=d(()=>{gt();A();Jr();U();mr();ft();$e();cE();Lo();pE();s(AH,"runSingleFile");s(bH,"runDirectory");s(dE,"resolveCanonicalFilePath");s(PH,"runFlatFile");s(xH,"parseMcpJson");s(TH,"runMcpJson");s(uE,"dispatchSpec");s(DH,"runSpec");s(NH,"specsForFeature");s(Y,"runDescriptorImport");});async function fE(t,e={}){let r=e.scope??"project",n=[],o=await W(An,t,r);return n.push(...await Y(Au,t,r,{normalize:o})),await et(t,r==="global"?lr:me,An,n,o),n}var gE=d(()=>{gt();rt();Ot();hl();bh();s(fE,"importFromAider");});function FH(t,e){return yE(e).some(n=>vH(t,n))}function hE(t,e){return t.filter(r=>FH(r,e))}function yE(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 yE(r+l+o))a.push(c);return a}function vH(t,e){return MH(e).test(t)}function MH(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 _E=d(()=>{s(FH,"globMatch");s(hE,"globFilter");s(yE,"expandBraces");s(vH,"matchOne");s(MH,"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(hE(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(()=>{_E();s(J,"validateRules");});function SE(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:An}))}var IE=d(()=>{Ct();hl();s(SE,"lintRules");});function D(t,e,r){return {level:"warning",file:t,target:e,message:r}}function $H(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 Fs(t,e,r,n){let o=n?.unsupportedBy??e,i=$H(r);return D(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var wt=d(()=>{s(D,"createWarning");s($H,"formatOxfordComma");s(Fs,"createUnsupportedHookWarning");});function CE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function kE(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?[]:[D(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function EE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var LE=d(()=>{wt();s(CE,"lintHooks");s(kE,"lintPermissions");s(EE,"lintMcp");});function E(t,e){return lt(t).relative(t,e).replace(/\\/g,"/")}async function L(t,e){return G(lt(t).join(t,e)).catch(()=>[])}function wE(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function WH(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)wE(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function F(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function $(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,`${OE}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let l=o.startsWith(pl)?pl:o.startsWith(nm)?nm:null;if(l&&a==="SKILL.md"){t.set(e,`${BH}/${o.slice(l.length)}.md`);return}let c=o.startsWith(ul)?ul:o.startsWith(om)?om:null;if(c&&a==="SKILL.md"){t.set(e,`${KH}/${o.slice(c.length)}.md`);return}let m=`${OE}/${o}`;a==="SKILL.md"&&wE(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&WH(t,e,p,`${r}/${o}`);}function HH(t){return t.split("/").filter(Boolean)[0]??""}async function zH(){if(Ph!==void 0)return Ph;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(xt(),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=HH(n);o.startsWith(".")&&e.add(o);}return Ph=e,e}function Th(t){return t.split("/").some(e=>e.startsWith("."))}async function VH(t){let e=[],r=await zH(),n=lt(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)||Th(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)||Th(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 bu(t,e){let r=await VH(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(Th(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${UH}/${c}.md`);}}var UH,BH,KH,OE,Ph,kt=d(()=>{pe();A();Lt();ut();UH=".agentsmesh/rules",BH=".agentsmesh/commands",KH=".agentsmesh/agents",OE=".agentsmesh/skills";s(E,"rel");s(L,"listFiles");s(wE,"addDirectoryMapping");s(WH,"addAncestorMappings");s(F,"addSimpleFileMapping");s($,"addSkillLikeMapping");s(HH,"firstPathSegment");s(zH,"targetRootSegments");s(Th,"hasHiddenSegment");s(VH,"listScopedAgentsFiles");s(bu,"addScopedAgentsMappings");});var w,ct,At,Rt=d(()=>{w=".agentsmesh/rules",ct=".agentsmesh/commands",At=".agentsmesh/agents";});async function Dh(t,e,r="project"){if(r==="global"){t.set(Po,`${w}/_root.md`);for(let n of await L(e,lr))$(t,E(e,n),lr);t.set(Fi,".agentsmesh/ignore");return}t.set(ar,`${w}/_root.md`);for(let n of await L(e,me))$(t,E(e,n),me);t.set(bo,".agentsmesh/ignore");}var bE=d(()=>{kt();hl();Rt();s(Dh,"buildAiderImportPaths");});var vi,Yr,Mi,vs,dm,PE,xE,fm=d(()=>{vi="amazon-q",Yr=".amazonq/rules",Mi=".amazonq/mcp.json",vs=".aws/amazonq/rules",dm=".aws/amazonq/mcp.json",PE=".agentsmesh/rules",xE=".agentsmesh/mcp.json";});async function Nh(t,e,r="project"){let n=r==="global"?vs:Yr;for(let o of await L(e,n)){let i=E(e,o);F(t,i,w,".md");}}var TE=d(()=>{kt();fm();Rt();s(Nh,"buildAmazonQImportPaths");});var pr,ue,Pn,Fh,To,ur,Do,DE,$i=d(()=>{pr="AGENTS.md",ue=".agents/skills",Pn=".amp/settings.json",Fh=".config/amp",To=`${Fh}/AGENTS.md`,ur=`${Fh}/skills`,Do=`${Fh}/settings.json`,DE=".agentsmesh/rules";});async function vh(t,e,r="project"){if(r==="global"){t.set(To,`${w}/_root.md`);for(let n of await L(e,ur))$(t,E(e,n),ur);t.set(Do,".agentsmesh/mcp.json");return}t.set(pr,`${w}/_root.md`);for(let n of await L(e,ue))$(t,E(e,n),ue);t.set(Pn,".agentsmesh/mcp.json");}var NE=d(()=>{kt();$i();Rt();s(vh,"buildAmpImportPaths");});var Gi,Pu,Xr,dr,gm,Zr,xn,hm,Tn,Dn,ym,Sl,Mh,ji,xu,FE,Ui=d(()=>{Gi="antigravity",Pu=".agents",Xr=`${Pu}/rules`,dr=`${Xr}/general.md`,gm=`${Xr}/_root.md`,Zr=`${Pu}/skills`,xn=`${Pu}/workflows`,hm=`${Pu}/antigravity/mcp_config.json`,Tn=".gemini/antigravity/GEMINI.md",Dn=".gemini/antigravity/skills",ym=".gemini/antigravity/workflows",Sl=".gemini/antigravity/mcp_config.json",Mh=".agentsmesh/rules/_root.md",ji=".agentsmesh/rules",xu=".agentsmesh/commands",FE=".agentsmesh/mcp.json";});async function $h(t,e,r="project"){if(r==="global"){t.set(Tn,`${w}/_root.md`);for(let n of await L(e,Dn))$(t,E(e,n),Dn);t.set(Sl,".agentsmesh/mcp.json");return}t.set(dr,`${w}/_root.md`),t.set(gm,`${w}/_root.md`);for(let n of await L(e,Xr)){let o=E(e,n);o===dr||o===gm||F(t,o,w,".md");}for(let n of await L(e,xn))F(t,E(e,n),ct,".md");for(let n of await L(e,Zr))$(t,E(e,n),Zr);}var vE=d(()=>{kt();Ui();Rt();s($h,"buildAntigravityImportPaths");});var de,Tu,Ge,fr,je,Nn,Fn,Du,No,Fo,vn,vo,Gh,jh,Uh,Bh,Bi=d(()=>{de="augment-code",Tu=".augment",Ge=`${Tu}/rules`,fr=`${Tu}/commands`,je=`${Tu}/skills`,Nn=`${Tu}/settings.json`,Fn=".augmentignore",Du=".augment",No=`${Du}/rules`,Fo=`${Du}/commands`,vn=`${Du}/skills`,vo=`${Du}/settings.json`,Gh=".agentsmesh/rules",jh=".agentsmesh/mcp.json",Uh=".agentsmesh/hooks.yaml",Bh=".agentsmesh/ignore";});async function Kh(t,e,r="project"){if(r==="global"){for(let n of await L(e,No))F(t,E(e,n),w,".md");for(let n of await L(e,Fo))F(t,E(e,n),ct,".md");for(let n of await L(e,vn))$(t,E(e,n),vn);t.set(vo,".agentsmesh/mcp.json");return}for(let n of await L(e,Ge))F(t,E(e,n),w,".md");for(let n of await L(e,fr))F(t,E(e,n),ct,".md");for(let n of await L(e,je))$(t,E(e,n),je);t.set(Nn,".agentsmesh/mcp.json"),t.set(Fn,".agentsmesh/ignore");}var ME=d(()=>{kt();Bi();Rt();s(Kh,"buildAugmentCodeImportPaths");});var $E,Ms,GE,_m,Rm,Sm,Im,Cm,Mo,Wh,km,Il,Em,Lm,Nu,Fu,Hh,Om,zh,Ki,jE,$o=d(()=>{$E="claude-code",Ms=".claude/CLAUDE.md",GE="CLAUDE.md",_m=".claude/rules",Rm=".claude/commands",Sm=".claude/agents",Im=".claude/skills",Cm=".claude/settings.json",Mo=".claude/hooks.json",Wh=".claude/output-styles",km=".claudeignore",Il=".mcp.json",Em=".claude.json",Lm=".agentsmesh/rules",Nu=".agentsmesh/commands",Fu=".agentsmesh/agents",Hh=".agentsmesh/skills",Om=".agentsmesh/mcp.json",zh=".agentsmesh/permissions.yaml",Ki=".agentsmesh/hooks.yaml",jE=".agentsmesh/ignore";});async function Vh(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${w}/_root.md`),t.set(Mo,Ki),r==="project"&&t.set("CLAUDE.md",`${w}/_root.md`),r==="global")for(let n of await L(e,".agents/skills"))$(t,E(e,n),".agents/skills");for(let n of await L(e,".claude/rules"))F(t,E(e,n),w,".md");for(let n of await L(e,".claude/commands"))F(t,E(e,n),ct,".md");for(let n of await L(e,".claude/agents"))F(t,E(e,n),At,".md");for(let n of await L(e,".claude/skills"))$(t,E(e,n),".claude/skills");}var UE=d(()=>{kt();$o();Rt();s(Vh,"buildClaudeCodeImportPaths");});var $s,Go,Wi,jo,BE,te,Mn,Gs,Hi,zi,Vi,Ji,Jh,js,vu,Yh,Xh,KE,WE,gr=d(()=>{$s="cline",Go=".clinerules",Wi=".clineignore",jo=".cline/cline_mcp_settings.json",BE=".cline/mcp_settings.json",te=".cline/skills",Mn=".clinerules/workflows",Gs="AGENTS.md",Hi=".clinerules/hooks",zi="Documents/Cline/Rules",Vi="Documents/Cline/Workflows",Ji="Documents/Cline/Hooks",Jh=".agentsmesh/hooks.yaml",js=".agentsmesh/rules",vu=".agentsmesh/commands",Yh=".agentsmesh/ignore",Xh=".agentsmesh/mcp.json",KE=".agentsmesh/agents",WE=".agentsmesh/skills";});async function Zh(t,e,r="project"){if(r==="global"){for(let n of await L(e,zi))F(t,E(e,n),w,".md");for(let n of await L(e,Vi))F(t,E(e,n),ct,".md");for(let n of await L(e,te))$(t,E(e,n),te);t.set(jo,".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"||F(t,o,w,".md");}for(let n of await L(e,".clinerules/workflows"))F(t,E(e,n),ct,".md");for(let n of await L(e,".cline/skills"))$(t,E(e,n),".cline/skills");}var HE=d(()=>{kt();gr();Rt();s(Zh,"buildClineImportPaths");});async function Qh(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 bu(t,e)),r==="project")for(let n of await L(e,".codex/instructions"))F(t,E(e,n),w,".md");for(let n of await L(e,".codex/rules")){let o=E(e,n);o.endsWith(".rules")?F(t,o,w,".rules"):o.endsWith(".md")&&F(t,o,w,".md");}for(let n of await L(e,".codex/agents"))F(t,E(e,n),At,".toml");for(let n of await L(e,".agents/skills"))$(t,E(e,n),".agents/skills");}var zE=d(()=>{kt();Rt();s(Qh,"buildCodexCliImportPaths");});var Cl,Qr,$n,qh,Mu,Uo,ty,Ue,kl,wm,$u,Gu,ey,Gn=d(()=>{Cl="continue",Qr=".continue/rules",$n=".continue/prompts",qh=".continue/mcpServers",Mu=`${qh}/agentsmesh.json`,Uo=`${Qr}/general.md`,ty=`${Qr}/_root.md`,Ue=".continue/skills",kl=".continue/AGENTS.md",wm=".continue/config.yaml",$u=".agentsmesh/rules",Gu=".agentsmesh/commands",ey=".agentsmesh/mcp.json";});async function ry(t,e,r="project"){t.set(Uo,`${w}/_root.md`),t.set(ty,`${w}/_root.md`);for(let n of await L(e,".continue/rules")){let o=E(e,n);o===Uo||o===ty||F(t,o,w,".md");}for(let n of await L(e,".continue/prompts"))t.set(E(e,n),`${ct}/${basename(n,".md")}.md`);for(let n of await L(e,".continue/skills"))$(t,E(e,n),".continue/skills");if(r==="global")for(let n of await L(e,".agents/skills"))$(t,E(e,n),".agents/skills");}var VE=d(()=>{kt();Gn();Rt();s(ry,"buildContinueImportPaths");});function XH(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${w}/${basename(e,".instructions.md")}.md`);return}F(t,e,w,".md");}async function ny(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"))XH(t,E(e,r));for(let r of await L(e,".github/prompts"))t.set(E(e,r),`${ct}/${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"))$(t,E(e,r),".github/skills");}var JE=d(()=>{kt();Rt();s(XH,"addCopilotInstructionMapping");s(ny,"buildCopilotImportPaths");});var hr,yr,ee,Be,Bo,YE,Uu,Ke,Yi,Bu,Ku,Wu,El=d(()=>{hr="crush",yr="CRUSH.md",ee=".crush/skills",Be="crush.json",Bo=".crushignore",YE=".config/crush",Uu=`${YE}/crush.json`,Ke=".config/crush/skills",Yi=`${YE}/CRUSH.md`,Bu=".agentsmesh/rules",Ku=".agentsmesh/ignore",Wu=".agentsmesh/mcp.json";});async function oy(t,e,r="project"){if(r==="global"){for(let n of await L(e,Ke))$(t,E(e,n),Ke);return}t.set(yr,`${Bu}/_root.md`),t.set(Be,Wu),t.set(Bo,Ku);for(let n of await L(e,ee))$(t,E(e,n),ee);}var XE=d(()=>{kt();El();s(oy,"buildCrushImportPaths");});var ZE,Us,QE,_r,Ko,Rr,Sr,fe,We,jn,Hu,qr,sy,ZH,Ll,tn,Un,Bs,Ks,qE,Ol,iy,Am,ay,zt=d(()=>{ZE="cursor",Us="AGENTS.md",QE=".cursorrules",_r=".cursor/rules",Ko=`${_r}/general.mdc`,Rr=".cursor/commands",Sr=".cursor/agents",fe=".cursor/skills",We=".cursor/mcp.json",jn=".cursor/hooks.json",Hu=".cursor/settings.json",qr=".cursorignore",sy=".cursorindexingignore",ZH=".agentsmesh-exports/cursor",Ll=`${ZH}/user-rules.md`,tn=".cursor/AGENTS.md",Un=".agentsmesh/rules",Bs=".agentsmesh/commands",Ks=".agentsmesh/agents",qE=".agentsmesh/skills",Ol=".agentsmesh/mcp.json",iy=".agentsmesh/permissions.yaml",Am=".agentsmesh/hooks.yaml",ay=".agentsmesh/ignore";});async function ly(t,e,r="project"){if(r==="global"){t.set(We,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${w}/_root.md`);for(let n of await L(e,".cursor/rules"))F(t,E(e,n),w,".mdc");for(let n of await L(e,".cursor/commands"))F(t,E(e,n),ct,".md");for(let n of await L(e,".cursor/agents"))F(t,E(e,n),At,".md");for(let n of await L(e,".cursor/skills"))$(t,E(e,n),".cursor/skills");return}t.set("AGENTS.md",`${w}/_root.md`);for(let n of await L(e,".cursor/rules"))F(t,E(e,n),w,".mdc");for(let n of await L(e,".cursor/commands"))F(t,E(e,n),ct,".md");for(let n of await L(e,".cursor/agents"))F(t,E(e,n),At,".md");for(let n of await L(e,".cursor/skills"))$(t,E(e,n),".cursor/skills");}var tL=d(()=>{kt();zt();Rt();s(ly,"buildCursorImportPaths");});var Bn,Ir,ge,Wo,Ho,en,Xi,eL,wl=d(()=>{Bn="deepagents-cli",Ir=".deepagents/AGENTS.md",ge=".deepagents/skills",Wo=".mcp.json",Ho=".deepagents/AGENTS.md",en=".deepagents/skills",Xi=".deepagents/.mcp.json",eL=".agentsmesh/rules";});async function cy(t,e,r="project"){if(r==="global"){t.set(Ho,`${w}/_root.md`);for(let n of await L(e,en))$(t,E(e,n),en);t.set(Xi,".agentsmesh/mcp.json");return}t.set(Ir,`${w}/_root.md`);for(let n of await L(e,ge))$(t,E(e,n),ge);t.set(Wo,".agentsmesh/mcp.json");}var rL=d(()=>{kt();wl();Rt();s(cy,"buildDeepagentsCliImportPaths");});var Cr,kr,Ae,Kn,Wn,zo,Hn,Zi,Ws,nL,Qi=d(()=>{Cr="factory-droid",kr="AGENTS.md",Ae=".factory/skills",Kn=".factory/droids",Wn=".factory/mcp.json",zo=".factory/AGENTS.md",Hn=".factory/skills",Zi=".factory/droids",Ws=".factory/mcp.json",nL=".agentsmesh/rules";});async function my(t,e,r="project"){if(r==="global"){t.set(zo,`${w}/_root.md`);for(let n of await L(e,Zi))F(t,E(e,n),At,".md");for(let n of await L(e,Hn))$(t,E(e,n),Hn);t.set(Ws,".agentsmesh/mcp.json");return}t.set(kr,`${w}/_root.md`);for(let n of await L(e,Kn))F(t,E(e,n),At,".md");for(let n of await L(e,Ae))$(t,E(e,n),Ae);t.set(Wn,".agentsmesh/mcp.json");}var oL=d(()=>{kt();Qi();Rt();s(my,"buildFactoryDroidImportPaths");});async function py(t,e){for(let r of await L(e,".gemini/rules"))F(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,`${ct}/${c}.md`);}for(let r of await L(e,".gemini/agents"))F(t,E(e,r),At,".md");for(let r of await L(e,".gemini/skills"))$(t,E(e,r),".gemini/skills");}var sL=d(()=>{kt();Rt();s(py,"buildGeminiCliImportPaths");});var zn,Er,be,Vo,iL,Jo,qi,Lr,aL,lL,Al=d(()=>{zn="goose",Er=".goosehints",be=".agents/skills",Vo=".gooseignore",iL=".config/goose",Jo=`${iL}/.goosehints`,qi=`${iL}/.gooseignore`,Lr=".agents/skills",aL=".agentsmesh/rules",lL=".agentsmesh/ignore";});async function uy(t,e,r="project"){if(r==="global"){t.set(Jo,`${w}/_root.md`);for(let n of await L(e,Lr))$(t,E(e,n),Lr);t.set(qi,".agentsmesh/ignore");return}t.set(Er,`${w}/_root.md`);for(let n of await L(e,be))$(t,E(e,n),be);t.set(Vo,".agentsmesh/ignore");}var cL=d(()=>{kt();Al();Rt();s(uy,"buildGooseImportPaths");});var Yo,rn,mL,bl=d(()=>{Yo="jules",rn="AGENTS.md",mL=".agentsmesh/rules";});async function dy(t,e,r="project"){r!=="global"&&t.set(rn,`${w}/_root.md`);}var pL=d(()=>{bl();Rt();s(dy,"buildJulesImportPaths");});var ta,Hs,zu,uL,Vn,dL,QH,bm,ea,Pm,Pl,xl,xm,Tm,Dm,Nm,Fm,qH,Vu,ra,fL,fy,Ju,gL,hL,yL,_L,Tl=d(()=>{ta="junie",Hs=".junie",zu=`${Hs}/guidelines.md`,uL=`${Hs}/ci-guidelines.md`,Vn=`${Hs}/AGENTS.md`,dL="AGENTS.md",QH=`${Hs}/mcp`,bm=`${QH}/mcp.json`,ea=`${Hs}/skills`,Pm=`${Hs}/rules`,Pl=`${Hs}/commands`,xl=`${Hs}/agents`,xm=".aiignore",Tm=".junie",Dm=`${Tm}/skills`,Nm=`${Tm}/agents`,Fm=`${Tm}/commands`,qH=`${Tm}/mcp`,Vu=`${qH}/mcp.json`,ra=`${Tm}/AGENTS.md`,fL=".agents/skills",fy=".agentsmesh/rules/_root.md",Ju=".agentsmesh/rules",gL=".agentsmesh/commands",hL=".agentsmesh/agents",yL=".agentsmesh/mcp.json",_L=".agentsmesh/ignore";});async function gy(t,e){t.set(zu,`${w}/_root.md`),t.set(Vn,`${w}/_root.md`),t.set("AGENTS.md",`${w}/_root.md`);for(let r of await L(e,".junie/rules"))F(t,E(e,r),w,".md");for(let r of await L(e,".junie/commands"))F(t,E(e,r),ct,".md");for(let r of await L(e,".junie/agents"))F(t,E(e,r),At,".md");for(let r of await L(e,".junie/skills"))$(t,E(e,r),".junie/skills");}var RL=d(()=>{kt();Tl();Rt();s(gy,"buildJunieImportPaths");});var Ie,vm,Jn,Xo,Zo,Qo,nn,zs,Dl,Yu,na,Nl,oa,Mm,Xu,Fl,Vs,sa,ia,aa,Js,vl,Zu,SL,Ys,Ml,la,IL,CL,ca=d(()=>{Ie="kilo-code",vm=".kilo",Jn="AGENTS.md",Xo=`${vm}/rules`,Zo=`${vm}/commands`,Qo=`${vm}/agents`,nn=`${vm}/skills`,zs=`${vm}/mcp.json`,Dl=".kilocodeignore",Yu=".kilocode",na=`${Yu}/rules`,Nl=`${Yu}/workflows`,oa=`${Yu}/skills`,Mm=`${Yu}/mcp.json`,Xu=".kilocodemodes",Fl=".kilo",Vs=`${Fl}/AGENTS.md`,sa=`${Fl}/rules`,ia=`${Fl}/commands`,aa=`${Fl}/agents`,Js=`${Fl}/skills`,vl=`${Fl}/mcp.json`,Zu=".kilocodeignore",SL=".agents/skills",Ys=".agentsmesh/rules",Ml=".agentsmesh/commands",la=".agentsmesh/agents",IL=".agentsmesh/mcp.json",CL=".agentsmesh/ignore";});async function hy(t,e,r="project"){if(r==="global"){t.set(Vs,`${w}/_root.md`);for(let n of await L(e,sa))F(t,E(e,n),w,".md");for(let n of await L(e,ia))F(t,E(e,n),ct,".md");for(let n of await L(e,aa))F(t,E(e,n),At,".md");for(let n of await L(e,Js))$(t,E(e,n),Js);t.set(vl,".agentsmesh/mcp.json");return}t.set(Jn,`${w}/_root.md`);for(let n of await L(e,Xo))F(t,E(e,n),w,".md");for(let n of await L(e,Zo))F(t,E(e,n),ct,".md");for(let n of await L(e,Qo))F(t,E(e,n),At,".md");for(let n of await L(e,nn))$(t,E(e,n),nn);t.set(zs,".agentsmesh/mcp.json");for(let n of await L(e,na)){let o=E(e,n);if(basename(o)==="00-root.md"){t.set(o,`${w}/_root.md`);continue}F(t,o,w,".md");}for(let n of await L(e,Nl))F(t,E(e,n),ct,".md");for(let n of await L(e,oa))$(t,E(e,n),oa);t.set(Mm,".agentsmesh/mcp.json");}var kL=d(()=>{kt();ca();Rt();s(hy,"buildKiloCodeImportPaths");});var He,on,$m,sn,Ce,an,Xs,ez,$l,Gl,ma,ln,Zs,pa,Gm,jm,EL,yy,_y,LL,OL,Ry,wL,jl=d(()=>{He="kiro",on="AGENTS.md",$m=".kiro",sn=`${$m}/steering`,Ce=`${$m}/skills`,an=`${$m}/agents`,Xs=`${$m}/hooks`,ez=`${$m}/settings`,$l=`${ez}/mcp.json`,Gl=".kiroignore",ma=".kiro/steering",ln=".kiro/steering/AGENTS.md",Zs=".kiro/skills",pa=".kiro/agents",Gm=".kiro/settings/mcp.json",jm=".kiro/settings/kiroignore",EL=".agents/skills",yy=".agentsmesh/rules/_root.md",_y=".agentsmesh/rules",LL=".agentsmesh/agents",OL=".agentsmesh/mcp.json",Ry=".agentsmesh/hooks.yaml",wL=".agentsmesh/ignore";});async function Sy(t,e,r="project"){if(r==="global"){t.set(ln,`${w}/_root.md`);for(let n of await L(e,ma)){let o=E(e,n);o!==ln&&F(t,o,w,".md");}for(let n of await L(e,Zs))$(t,E(e,n),Zs);for(let n of await L(e,pa))F(t,E(e,n),At,".md");return}t.set(on,`${w}/_root.md`);for(let n of await L(e,sn))F(t,E(e,n),w,".md");for(let n of await L(e,Ce))$(t,E(e,n),Ce);for(let n of await L(e,an))F(t,E(e,n),At,".md");}var AL=d(()=>{kt();jl();Rt();s(Sy,"buildKiroImportPaths");});var cn,Qu,Yn,qo,ts,es,mn,Xn,Ul,Qs,ua,da,fa,qs,ti,bL,Um,qu,td,Iy,ga=d(()=>{cn="opencode",Qu=".opencode",Yn="AGENTS.md",qo=`${Qu}/rules`,ts=`${Qu}/commands`,es=`${Qu}/agents`,mn=`${Qu}/skills`,Xn="opencode.json",Ul=".config/opencode",Qs=`${Ul}/AGENTS.md`,ua=`${Ul}/rules`,da=`${Ul}/commands`,fa=`${Ul}/agents`,qs=`${Ul}/skills`,ti=`${Ul}/opencode.json`,bL=".agents/skills",Um=".agentsmesh/rules",qu=".agentsmesh/commands",td=".agentsmesh/agents",Iy=".agentsmesh/mcp.json";});async function Cy(t,e,r="project"){if(r==="global"){t.set(Qs,`${w}/_root.md`);for(let n of await L(e,ua))F(t,E(e,n),w,".md");for(let n of await L(e,da))F(t,E(e,n),ct,".md");for(let n of await L(e,fa))F(t,E(e,n),At,".md");for(let n of await L(e,qs))$(t,E(e,n),qs);t.set(ti,".agentsmesh/mcp.json");return}t.set(Yn,`${w}/_root.md`);for(let n of await L(e,qo))F(t,E(e,n),w,".md");for(let n of await L(e,ts))F(t,E(e,n),ct,".md");for(let n of await L(e,es))F(t,E(e,n),At,".md");for(let n of await L(e,mn))$(t,E(e,n),mn);t.set(Xn,".agentsmesh/mcp.json");}var PL=d(()=>{kt();ga();Rt();s(Cy,"buildOpencodeImportPaths");});var Zn,Or,re,xL,rs,wr,TL,Bl=d(()=>{Zn="pi-agent",Or="AGENTS.md",re=".pi/skills",xL=".pi/agent",rs=`${xL}/AGENTS.md`,wr=`${xL}/skills`,TL=".agentsmesh/rules";});async function ky(t,e,r="project"){if(r==="global"){t.set(rs,`${w}/_root.md`);for(let n of await L(e,wr))$(t,E(e,n),wr);return}t.set(Or,`${w}/_root.md`);for(let n of await L(e,re))$(t,E(e,n),re);}var Ey=d(()=>{kt();Bl();Rt();s(ky,"buildPiAgentImportPaths");});var pn,Ar,ns,Qn,qn,ze,ei,ri,os,ha,ni,to,oi,Ly,DL,NL,Kl=d(()=>{pn="qwen-code",Ar="QWEN.md",ns=".qwen/rules",Qn=".qwen/commands",qn=".qwen/agents",ze=".qwen/skills",ei=".qwen/settings.json",ri=".qwenignore",os=".qwen/QWEN.md",ha=".qwen/settings.json",ni=".qwen/commands",to=".qwen/skills",oi=".qwen/agents",Ly=".agentsmesh/rules",DL=".agentsmesh/commands",NL=".agentsmesh/agents";});async function Oy(t,e,r="project"){if(r==="global"){t.set(os,`${w}/_root.md`),t.set(ha,".agentsmesh/mcp.json");for(let n of await L(e,ni))F(t,E(e,n),ct,".md");for(let n of await L(e,oi))F(t,E(e,n),At,".md");for(let n of await L(e,to))$(t,E(e,n),to);return}t.set(Ar,`${w}/_root.md`),t.set(ei,".agentsmesh/mcp.json"),t.set(ri,".agentsmesh/ignore");for(let n of await L(e,ns))F(t,E(e,n),w,".md");for(let n of await L(e,Qn))F(t,E(e,n),ct,".md");for(let n of await L(e,qn))F(t,E(e,n),At,".md");for(let n of await L(e,ze))$(t,E(e,n),ze);}var FL=d(()=>{kt();Rt();Kl();s(Oy,"buildQwenCodeImportPaths");});var eo,un,Pe,vL,Wl=d(()=>{eo="replit-agent",un="replit.md",Pe=".agents/skills",vL=".agentsmesh/rules";});async function wy(t,e,r="project"){if(r!=="global"){t.set(un,`${w}/_root.md`);for(let n of await L(e,Pe))$(t,E(e,n),Pe);}}var Ay=d(()=>{kt();Wl();Rt();s(wy,"buildReplitAgentImportPaths");});var si,ya,dn,Bm,ss,is,ro,Km,Wm,Hl,Hm,ed,ii,ai,as,_a,zm,li,ML,Ra,rd,$L,GL,Sa=d(()=>{si="roo-code",ya=".roo",dn=`${ya}/rules/00-root.md`,Bm=".roorules",ss=`${ya}/rules`,is=`${ya}/commands`,ro=`${ya}/skills`,Km=`${ya}/mcp.json`,Wm=".rooignore",Hl=".roomodes",Hm="settings/custom_modes.yaml",ed=".roo",ii=`${ed}/rules`,ai=`${ed}/commands`,as=`${ed}/skills`,_a="mcp_settings.json",zm=".rooignore",li=`${ed}/AGENTS.md`,ML=".agents/skills",Ra=".agentsmesh/rules",rd=".agentsmesh/commands",$L=".agentsmesh/mcp.json",GL=".agentsmesh/ignore";});async function by(t,e,r="project"){if(r==="global"){t.set(li,`${w}/_root.md`);for(let n of await L(e,ii))F(t,E(e,n),w,".md");for(let n of await L(e,ai))F(t,E(e,n),ct,".md");for(let n of await L(e,as))$(t,E(e,n),as);t.set(_a,".agentsmesh/mcp.json");return}t.set(dn,`${w}/_root.md`),t.set(Bm,`${w}/_root.md`);for(let n of await L(e,ss)){let o=E(e,n);o!==dn&&F(t,o,w,".md");}for(let n of await L(e,".roo")){let o=E(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&F(t,o,w,".md");}for(let n of await L(e,is))F(t,E(e,n),ct,".md");for(let n of await L(e,ro))$(t,E(e,n),ro);}var jL=d(()=>{kt();Sa();Rt();s(by,"buildRooCodeImportPaths");});var no,br,UL,ne,ls,BL,cs,Ve,zl,KL,Vl=d(()=>{no="rovodev",br="AGENTS.md",UL=".rovodev",ne=`${UL}/skills`,ls=`${UL}/mcp.json`,BL=".rovodev",cs=".rovodev/AGENTS.md",Ve=".rovodev/skills",zl=".rovodev/mcp.json",KL=".agentsmesh/rules";});async function Py(t,e,r="project"){if(r==="global"){t.set(cs,`${w}/_root.md`);for(let n of await L(e,Ve))$(t,E(e,n),Ve);t.set(zl,".agentsmesh/mcp.json");return}t.set(br,`${w}/_root.md`);for(let n of await L(e,ne))$(t,E(e,n),ne);t.set(ls,".agentsmesh/mcp.json");}var WL=d(()=>{kt();Vl();Rt();s(Py,"buildRovodevImportPaths");});var Pr,nd,Je,Ye,xr,Ia,Jl,ms,Tr,fn,Vm,HL,Jm,zL,VL,Yl=d(()=>{Pr="trae",nd=".trae",Je=`${nd}/rules`,Ye=`${Je}/project_rules.md`,xr=`${nd}/skills`,Ia=`${nd}/mcp.json`,Jl=`${nd}/.ignore`,ms=".trae/user_rules",Tr=".trae/user_rules/rules.md",fn=".trae/skills",Vm=".trae/mcp.json",HL=".agents/skills",Jm=".agentsmesh/rules",zL=".agentsmesh/mcp.json",VL=".agentsmesh/ignore";});async function xy(t,e,r="project"){if(r==="global"){t.set(Tr,`${w}/_root.md`);for(let n of await L(e,ms)){let o=E(e,n);o!==Tr&&F(t,o,w,".md");}for(let n of await L(e,fn))$(t,E(e,n),fn);return}t.set(Ye,`${w}/_root.md`);for(let n of await L(e,Je)){let o=E(e,n);o!==Ye&&F(t,o,w,".md");}for(let n of await L(e,xr))$(t,E(e,n),xr);}var JL=d(()=>{kt();Yl();Rt();s(xy,"buildTraeImportPaths");});var oo,gn,Ty,he,ci,Xe,YL,Xl=d(()=>{oo="warp",gn="AGENTS.md",Ty="WARP.md",he=".warp/skills",ci=".mcp.json",Xe=".warp/skills",YL=".agentsmesh/rules";});async function Dy(t,e,r="project"){if(r==="global"){for(let n of await L(e,Xe))$(t,E(e,n),Xe);return}t.set(gn,`${w}/_root.md`);for(let n of await L(e,he))$(t,E(e,n),he);t.set(ci,".agentsmesh/mcp.json");}var XL=d(()=>{kt();Xl();Rt();s(Dy,"buildWarpImportPaths");});async function Ny(t,e){t.set("AGENTS.md",`${w}/_root.md`),t.set(".windsurfrules",`${w}/_root.md`),await bu(t,e);for(let r of await L(e,".windsurf/rules"))F(t,E(e,r),w,".md");for(let r of await L(e,".windsurf/workflows"))F(t,E(e,r),ct,".md");for(let r of await L(e,".windsurf/skills"))$(t,E(e,r),".windsurf/skills");}var ZL=d(()=>{kt();Rt();s(Ny,"buildWindsurfImportPaths");});var hn,so,rz,io,QL,Ca=d(()=>{hn=".rules",so=".zed/settings.json",rz=".config/zed",io=`${rz}/settings.json`,QL=".agentsmesh/rules";});async function Fy(t,e,r="project"){if(r==="global"){t.set(io,".agentsmesh/mcp.json");return}t.set(hn,`${w}/_root.md`),t.set(so,".agentsmesh/mcp.json");}var qL=d(()=>{Ca();Rt();s(Fy,"buildZedImportPaths");});var tO=d(()=>{bE();TE();NE();vE();ME();UE();HE();zE();VE();JE();XE();tL();rL();oL();sL();cL();pL();RL();kL();AL();PL();Ey();FL();Ay();jL();WL();JL();XL();ZL();qL();});var Et=d(()=>{tO();});var nz,oz,sz,eO,Au,bh=d(()=>{Lt();ut();Pk();gE();IE();LE();Et();hl();nz={name:An,primaryRootInstructionPath:ar,generateRules:Lk,generateCommands:wk,generateAgents:Ak,generateSkills:Ok,generateIgnore:bk,importFrom:fE},oz={rootInstructionPath:ar,skillDir:me,managedOutputs:{dirs:[me],files:[ar,bo]},paths:{rulePath(t){return ar},commandPath(t){return `${me}/${V(t)}/SKILL.md`},agentPath(t){return `${me}/${K(t)}/SKILL.md`}}},sz={rootInstructionPath:Po,skillDir:lr,managedOutputs:{dirs:[lr],files:[Po,Fi]},rewriteGeneratedPath(t){return t===ar?Po:t===bo?Fi:t.startsWith(`${me}/`)?t.replace(`${me}/`,`${lr}/`):t},paths:{rulePath(t){return Po},commandPath(t){return `${lr}/${V(t)}/SKILL.md`},agentPath(t){return `${lr}/${K(t)}/SKILL.md`}}},eO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Au={id:An,metadata:{displayName:"Aider",category:"cli",officialUrl:"https://aider.chat",shortDescription:"Open-source terminal AI pair programmer"},generators:nz,capabilities:eO,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:SE,lint:{hooks:CE,permissions:kE,mcp:EE},supportsConversion:{commands:true,agents:true},project:oz,globalSupport:{capabilities:eO,detectionPaths:[Po,Fi,lr],layout:sz},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[ar],global:[Po]},canonicalDir:kk,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[bo],global:[Fi]},canonicalDir:".agentsmesh",canonicalFilename:Ek}},buildImportPaths:Dh,detectionPaths:[ar,bo]};});function rO(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(vi))continue;let n=r.root?"_root":basename(r.source,".md");e.push({path:`${Yr}/${n}.md`,content:r.body.trim()});}return e}function nO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Mi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var oO=d(()=>{fm();s(rO,"generateRules");s(nO,"generateMcp");});async function sO(t,e){let r=e?.scope??"project";return Y(od,t,r)}var iO=d(()=>{Ot();vy();s(sO,"importFromAmazonQ");});function aO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:vi}))}var lO=d(()=>{Ct();fm();s(aO,"lintRules");});var az,lz,cz,mz,od,vy=d(()=>{oO();iO();lO();Et();fm();az={name:vi,generateRules:rO,generateMcp:nO,importFrom:sO},lz={managedOutputs:{dirs:[Yr],files:[Mi]},paths:{rulePath(t,e){return `${Yr}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},cz={managedOutputs:{dirs:[vs],files:[dm]},rewriteGeneratedPath(t){return t.startsWith(`${Yr}/`)?t.replace(`${Yr}/`,`${vs}/`):t===Mi?dm:t},paths:{rulePath(t,e){return `${vs}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},mz={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},od={id:vi,metadata:{displayName:"Amazon Q Developer",category:"ide",officialUrl:"https://aws.amazon.com/q/developer",shortDescription:"AWS AI coding assistant"},generators:az,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:aO,project:lz,globalSupport:{capabilities:mz,detectionPaths:[vs,dm],layout:cz},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Yr],global:[vs]},canonicalDir:PE,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Mi],global:[dm]},canonicalDir:".agentsmesh",canonicalFilename:xE}},buildImportPaths:Nh,detectionPaths:[Yr,Mi]};});function cO(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=at(n,r);return o?[{path:pr,content:o}]:[]}function mO(t){return st(t,ue)}function pO(t){return t.commands.map(e=>({path:`${ue}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function uO(t){return t.agents.map(e=>({path:`${ue}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}var dO=d(()=>{rt();Kt();ut();Lt();$i();s(cO,"generateRules");s(mO,"generateSkills");s(pO,"generateCommands");s(uO,"generateAgents");});function dt(t,e,r){let n=r.some(o=>pz.includes(o));return t.startsWith(`${e}/`)&&!n?`.agents/skills/${t.slice(e.length+1)}`:null}var pz,oe=d(()=>{pz=["amp","antigravity","codex-cli","goose","replit-agent"];s(dt,"mirrorSkillsToAgents");});async function gO(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 Ht(t,fO,l),r.push({fromTool:"amp",fromPath:e,toPath:fO,feature:"mcp"}));}var fO,hO=d(()=>{A();Jr();$i();fO=".agentsmesh/mcp.json";s(gO,"importAmpMcp");});async function yO(t,e={}){let r=e.scope??"project",n=[],o=await W("amp",t,r);return n.push(...await Y(sd,t,r,{normalize:o})),await et(t,r==="global"?ur:ue,"amp",n,o),await gO(t,r==="global"?Do:Pn,n),n}var _O=d(()=>{gt();rt();Ot();hO();$i();My();s(yO,"importFromAmp");});function RO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var SO=d(()=>{Ct();$i();s(RO,"lintRules");});function IO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function CO(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?[]:[D(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function kO(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var EO=d(()=>{wt();s(IO,"lintHooks");s(CO,"lintPermissions");s(kO,"lintIgnore");});function hz(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 dz,fz,gz,LO,sd,My=d(()=>{Lt();ut();dO();oe();_O();SO();EO();Et();$i();dz={name:"amp",primaryRootInstructionPath:pr,generateRules:cO,generateCommands:pO,generateAgents:uO,generateSkills:mO,importFrom:yO},fz={rootInstructionPath:pr,skillDir:ue,managedOutputs:{dirs:[ue],files:[pr,Pn]},paths:{rulePath(t){return pr},commandPath(t){return `${ue}/${V(t)}/SKILL.md`},agentPath(t){return `${ue}/${K(t)}/SKILL.md`}}},gz={rootInstructionPath:To,skillDir:ur,managedOutputs:{dirs:[ur],files:[To,Do]},rewriteGeneratedPath(t){return t===pr?To:t===Pn?Do:t.startsWith(`${ue}/`)?t.replace(`${ue}/`,`${ur}/`):t},mirrorGlobalPath(t,e){return dt(t,ur,e)},paths:{rulePath(t){return To},commandPath(t){return `${ur}/${V(t)}/SKILL.md`},agentPath(t){return `${ur}/${K(t)}/SKILL.md`}}},LO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(hz,"mergeAmpSettings");sd={id:"amp",metadata:{displayName:"Amp",category:"cli",officialUrl:"https://ampcode.com",shortDescription:"Sourcegraph's coding agent"},generators:dz,capabilities:LO,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:RO,lint:{hooks:IO,permissions:CO,ignore:kO},supportsConversion:{commands:true,agents:true},project:fz,globalSupport:{capabilities:LO,detectionPaths:[To,Do],layout:gz},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[pr],global:[To]},canonicalDir:DE,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Pn,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===Pn||n===Do?hz(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:vh,detectionPaths:[pr,Pn],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function OO(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:dr,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:`${Xr}/${o}.md`,content:n.body.trim()||""});}return r}function wO(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
61
65
 
62
- ${n}`:n||r;return {path:`${bn}/${e.name}.md`,content:o}})}function dO(t){return st(t,Xr)}function fO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:um,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function gO(t){return t.agents.map(e=>({path:`${Xr}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function hO(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 yO=d(()=>{rt();Wt();ut();Gi();s(pO,"generateRules");s(uO,"generateCommands");s(dO,"generateSkills");s(fO,"generateMcp");s(gO,"generateAgents");s(hO,"renderAntigravityGlobalInstructions");});function BH(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function io(t){let e=qC(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=BH(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}=P(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 Jl=d(()=>{A();U();Wt();ft();s(BH,"canonicalRulePath");s(io,"splitEmbeddedRulesToCanonical");});async function KH(t,e,r,n){let o=n==="global"?Pn:ur,i=n==="project"?[o,pm]:[o];for(let a of i){let l=join(t,a),c=await _(l);if(c===null)continue;let m=join(t,Oh),p=await io({content:c,projectRoot:t,rulesDir:$i,sourcePath:l,fromTool:Mi,normalize:r});e.push(...p.results);let{body:u}=P(r(p.rootContent,l,m)),f=await z(m,{root:true},u);await O(join(t,$i)),await S(m,f),e.push({fromTool:Mi,fromPath:l,toPath:Oh,feature:"rules"});return}}async function RO(t,e={}){let r=e.scope??"project",n=[],o=await W(Mi,t,r);return await KH(t,n,o,r),n.push(...await Y(qu,t,r,{normalize:o})),await et(t,r==="global"?Tn:Xr,Mi,n,o),n}var IO=d(()=>{gt();A();U();rt();Ot();ft();Jl();Gi();Ay();s(KH,"importRootRule");s(RO,"importFromAntigravity");});var kO,EO,LO=d(()=>{U();ft();Gi();kO=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}=P(e(n));return {destPath:n,toPath:`${$i}/${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"),EO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Eu}/${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 OO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Mi}))}var wO=d(()=>{Ct();Gi();s(OO,"lintRules");});var WH,HH,zH,VH,qu,Ay=d(()=>{xi();ut();yO();Gi();IO();LO();wO();Et();WH={name:"antigravity",primaryRootInstructionPath:ur,generateRules:pO,generateCommands:uO,generateAgents:gO,generateSkills:dO,generateMcp:fO,importFrom:RO},HH={rootInstructionPath:ur,skillDir:".agents/skills",managedOutputs:{dirs:[Yr,bn,Xr],files:[ur]},rewriteGeneratedPath(t){return t===um?null:t},paths:{rulePath(t,e){return `${Yr}/${t}.md`},commandPath(t,e){return `${bn}/${t}.md`},agentPath(t){return `${Xr}/${K(t)}/SKILL.md`}}},zH={rootInstructionPath:Pn,renderPrimaryRootInstruction:hO,skillDir:Tn,managedOutputs:{dirs:[Tn,dm],files:[Pn,yl]},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,dm):t===um?yl:t},paths:{rulePath(t,e){return Pn},commandPath(t,e){return `${dm}/${t}.md`},agentPath(t){return `${Tn}/${K(t)}/SKILL.md`}}},VH={rules:"native",additionalRules:"embedded",commands:Kr("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},qu={id:"antigravity",metadata:{displayName:"Antigravity",category:"ide",officialUrl:"https://antigravity.google",shortDescription:"Google's agentic IDE"},generators:WH,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:OO,project:HH,globalSupport:{capabilities:VH,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:zH},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Yr]},canonicalDir:$i,extensions:[".md"],map:kO},commands:{feature:"commands",mode:"directory",source:{project:[bn],global:[dm]},canonicalDir:Eu,extensions:[".md"],map:EO},mcp:{feature:"mcp",mode:"flatFile",source:{global:[yl]},canonicalDir:".agentsmesh",canonicalFilename:IE}},buildImportPaths:wh,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"],conversionDefaults:{agentsToSkills:true}};});function YH(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 XH(t){let e={};return t.description&&(e.description=t.description),e}function AO(t){let e=[];for(let r of t.rules)if(!(r.targets.length>0&&!r.targets.includes(de)))if(r.root){let n={always_apply:true};r.description&&(n.description=r.description),e.push({path:`${$e}/_root.md`,content:x(n,r.body.trim())});}else {let n=basename(r.source,".md");e.push({path:`${$e}/${n}.md`,content:x(YH(r),r.body.trim())});}return e}function bO(t){return t.commands.map(e=>({path:`${dr}/${e.name}.md`,content:x(XH(e),e.body.trim())}))}function PO(t){return st(t,Ge)}function TO(t){return t.ignore.length===0?[]:[{path:Dn,content:t.ignore.join(`
63
- `)}]}var xO=d(()=>{rt();U();ji();s(YH,"ruleFrontmatter");s(XH,"commandFrontmatter");s(AO,"generateRules");s(bO,"generateCommands");s(PO,"generateSkills");s(TO,"generateIgnore");});function QH(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 NO(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 Ht(t,bh,a),r.push({fromTool:de,fromPath:join(t,e),toPath:bh,feature:"mcp"});}let i=o.hooks;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=QH(i);if(Object.keys(a).length>0){let l=join(t,Ph);await O(dirname(l)),await S(l,stringify(a)),r.push({fromTool:de,fromPath:join(t,e),toPath:Ph,feature:"hooks"});}}}async function FO(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,Th);await O(dirname(i)),await S(i,o.join(`
65
- `)),r.push({fromTool:de,fromPath:join(t,e),toPath:Th,feature:"ignore"});}var vO=d(()=>{A();Vr();ji();s(QH,"augmentHooksToCanonical");s(NO,"importAugmentSettings");s(FO,"importAugmentIgnore");});function qH(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 tz(t,e,r,n){let o=n==="global"?Do:$e,i=join(t,Ah);e.push(...await St({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:de,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}=P(l(m));return {destPath:m,toPath:`${Ah}/${a}`,feature:"rules",content:await z(m,qH(p,c),u)}},"mapEntry")}));}async function ez(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:de,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=basename(a,".md"),m=join(i,`${c}.md`),{frontmatter:p,body:u}=P(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 $O(t,e={}){let r=e.scope??"project",n=[],o=await W(de,t,r);return await tz(t,n,o,r),await ez(t,n,o,r),await et(t,r==="global"?Nn:Ge,de,n,o),await NO(t,r==="global"?Fo:xn,n),r==="project"&&await FO(t,Dn,n),n}var GO=d(()=>{gt();Me();rt();ft();U();vO();ji();s(qH,"canonicalRuleMeta");s(tz,"importRules");s(ez,"importCommands");s($O,"importFromAugmentCode");});function jO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:de}))}var UO=d(()=>{Ct();ji();s(jO,"lintRules");});function KO(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=>Ds(r,"augment-code",BO,{unsupportedBy:"AugmentCode hooks"}))}var BO,WO=d(()=>{wt();BO=["PreToolUse","PostToolUse","SessionStart","SessionEnd","Stop"];s(KO,"lintHooks");});function nz(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 oz(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 sz(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=nz(t.hooks)),Object.keys(e).length===0?null:JSON.stringify(e,null,2)}var rz,iz,az,lz,cz,HO,zO=d(()=>{xO();GO();UO();WO();Et();ji();rz={name:de,generateRules:AO,generateCommands:bO,generateSkills:PO,generateIgnore:TO,importFrom:$O};s(nz,"serializeHooksForSettings");s(oz,"mergeAugmentSettings");s(sz,"buildSettingsContent");iz={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}}},az={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}}},lz={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},cz={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},HO={id:de,metadata:{displayName:"Augment Code",category:"ide",officialUrl:"https://www.augmentcode.com",shortDescription:"Codebase-aware AI for IDEs"},generators:rz,capabilities:lz,emptyImportMessage:"No AugmentCode config found (.augment/rules, .augment/commands, .augment/skills, .augment/settings.json, or .augmentignore).",lintRules:jO,lint:{hooks:KO},project:iz,globalSupport:{capabilities:cz,detectionPaths:[Do,No,Nn,Fo],layout:az},emitScopedSettings(t){let e=sz(t);return e===null?[]:[{path:xn,content:e}]},mergeGeneratedOutputContent(t,e,r,n){return n===xn||n===Fo?oz(t,r):null},buildImportPaths:xh,detectionPaths:[$e,dr,Ge,xn,Dn]};});function VO(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=Jt(i),l=Re(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 JO=d(()=>{Ur();s(VO,"buildClaudeHooksObjectFromCanonical");});function YO(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Fs,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=x(a,o.body.trim()||"");e.push({path:`${fm}/${i}.md`,content:l});}return e}function XO(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=x(r,e.body.trim()||"");return {path:`${gm}/${e.name}.md`,content:n}})}function ZO(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
66
+ ${n}`:n||r;return {path:`${xn}/${e.name}.md`,content:o}})}function AO(t){return st(t,Zr)}function bO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:hm,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function PO(t){return t.agents.map(e=>({path:`${Zr}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function xO(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 at(e?.body.trim()??"",r)}var TO=d(()=>{rt();Kt();ut();Ui();s(OO,"generateRules");s(wO,"generateCommands");s(AO,"generateSkills");s(bO,"generateMcp");s(PO,"generateAgents");s(xO,"renderAntigravityGlobalInstructions");});function _z(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function ao(t){let e=fk(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=_z(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}=P(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 I(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();U();Kt();ft();s(_z,"canonicalRulePath");s(ao,"splitEmbeddedRulesToCanonical");});async function Rz(t,e,r,n){let o=n==="global"?Tn:dr,i=n==="project"?[o,gm]:[o];for(let a of i){let l=join(t,a),c=await _(l);if(c===null)continue;let m=join(t,Mh),p=await ao({content:c,projectRoot:t,rulesDir:ji,sourcePath:l,fromTool:Gi,normalize:r});e.push(...p.results);let{body:u}=P(r(p.rootContent,l,m)),f=await z(m,{root:true},u);await O(join(t,ji)),await I(m,f),e.push({fromTool:Gi,fromPath:l,toPath:Mh,feature:"rules"});return}}async function NO(t,e={}){let r=e.scope??"project",n=[],o=await W(Gi,t,r);return await Rz(t,n,o,r),n.push(...await Y(id,t,r,{normalize:o})),await et(t,r==="global"?Dn:Zr,Gi,n,o),n}var FO=d(()=>{gt();A();U();rt();Ot();ft();Zl();Ui();Gy();s(Rz,"importRootRule");s(NO,"importFromAntigravity");});var $O,GO,jO=d(()=>{U();ft();Ui();$O=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}=P(e(n));return {destPath:n,toPath:`${ji}/${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"),GO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${xu}/${t}`,content:await St(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function UO(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Gi}))}var BO=d(()=>{Ct();Ui();s(UO,"lintRules");});var Sz,Iz,Cz,kz,id,Gy=d(()=>{Ni();ut();TO();Ui();FO();jO();BO();Et();Sz={name:"antigravity",primaryRootInstructionPath:dr,generateRules:OO,generateCommands:wO,generateAgents:PO,generateSkills:AO,generateMcp:bO,importFrom:NO},Iz={rootInstructionPath:dr,skillDir:".agents/skills",managedOutputs:{dirs:[Xr,xn,Zr],files:[dr]},rewriteGeneratedPath(t){return t===hm?null:t},paths:{rulePath(t,e){return `${Xr}/${t}.md`},commandPath(t,e){return `${xn}/${t}.md`},agentPath(t){return `${Zr}/${K(t)}/SKILL.md`}}},Cz={rootInstructionPath:Tn,renderPrimaryRootInstruction:xO,skillDir:Dn,managedOutputs:{dirs:[Dn,ym],files:[Tn,Sl]},rewriteGeneratedPath(t){return t===dr?Tn:t.startsWith(`${Xr}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",Dn):t.startsWith(`${xn}/`)?t.replace(xn,ym):t===hm?Sl:t},paths:{rulePath(t,e){return Tn},commandPath(t,e){return `${ym}/${t}.md`},agentPath(t){return `${Dn}/${K(t)}/SKILL.md`}}},kz={rules:"native",additionalRules:"embedded",commands:Wr("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},id={id:"antigravity",metadata:{displayName:"Antigravity",category:"ide",officialUrl:"https://antigravity.google",shortDescription:"Google's agentic IDE"},generators:Sz,capabilities:{rules:"native",additionalRules:"native",commands:Wr("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:UO,project:Iz,globalSupport:{capabilities:kz,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:Cz},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Xr]},canonicalDir:ji,extensions:[".md"],map:$O},commands:{feature:"commands",mode:"directory",source:{project:[xn],global:[ym]},canonicalDir:xu,extensions:[".md"],map:GO},mcp:{feature:"mcp",mode:"flatFile",source:{global:[Sl]},canonicalDir:".agentsmesh",canonicalFilename:FE}},buildImportPaths:$h,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"],conversionDefaults:{agentsToSkills:true}};});function Lz(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 Oz(t){let e={};return t.description&&(e.description=t.description),e}function KO(t){let e=[];for(let r of t.rules)if(!(r.targets.length>0&&!r.targets.includes(de)))if(r.root){let n={always_apply:true};r.description&&(n.description=r.description),e.push({path:`${Ge}/_root.md`,content:T(n,r.body.trim())});}else {let n=basename(r.source,".md");e.push({path:`${Ge}/${n}.md`,content:T(Lz(r),r.body.trim())});}return e}function WO(t){return t.commands.map(e=>({path:`${fr}/${e.name}.md`,content:T(Oz(e),e.body.trim())}))}function HO(t){return st(t,je)}function zO(t){return t.ignore.length===0?[]:[{path:Fn,content:t.ignore.join(`
67
+ `)}]}var VO=d(()=>{rt();U();Bi();s(Lz,"ruleFrontmatter");s(Oz,"commandFrontmatter");s(KO,"generateRules");s(WO,"generateCommands");s(HO,"generateSkills");s(zO,"generateIgnore");});function Az(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 YO(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 Ht(t,jh,a),r.push({fromTool:de,fromPath:join(t,e),toPath:jh,feature:"mcp"});}let i=o.hooks;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=Az(i);if(Object.keys(a).length>0){let l=join(t,Uh);await O(dirname(l)),await I(l,stringify(a)),r.push({fromTool:de,fromPath:join(t,e),toPath:Uh,feature:"hooks"});}}}async function XO(t,e,r){let n=await _(join(t,e));if(n===null)return;let o=n.split(`
68
+ `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"));if(o.length===0)return;let i=join(t,Bh);await O(dirname(i)),await I(i,o.join(`
69
+ `)),r.push({fromTool:de,fromPath:join(t,e),toPath:Bh,feature:"ignore"});}var ZO=d(()=>{A();Jr();Bi();s(Az,"augmentHooksToCanonical");s(YO,"importAugmentSettings");s(XO,"importAugmentIgnore");});function bz(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 Pz(t,e,r,n){let o=n==="global"?No:Ge,i=join(t,Gh);e.push(...await It({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:de,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}=P(l(m));return {destPath:m,toPath:`${Gh}/${a}`,feature:"rules",content:await z(m,bz(p,c),u)}},"mapEntry")}));}async function xz(t,e,r,n){let o=n==="global"?Fo:fr,i=join(t,".agentsmesh/commands");e.push(...await It({srcDir:join(t,o),destDir:i,extensions:[".md"],fromTool:de,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:l})=>{let c=basename(a,".md"),m=join(i,`${c}.md`),{frontmatter:p,body:u}=P(l(m)),f=typeof p.description=="string"?p.description:"";return {destPath:m,toPath:`.agentsmesh/commands/${c}.md`,feature:"commands",content:await St(m,{description:f,hasDescription:true,hasAllowedTools:false},u)}},"mapEntry")}));}async function qO(t,e={}){let r=e.scope??"project",n=[],o=await W(de,t,r);return await Pz(t,n,o,r),await xz(t,n,o,r),await et(t,r==="global"?vn:je,de,n,o),await YO(t,r==="global"?vo:Nn,n),r==="project"&&await XO(t,Fn,n),n}var tw=d(()=>{gt();$e();rt();ft();U();ZO();Bi();s(bz,"canonicalRuleMeta");s(Pz,"importRules");s(xz,"importCommands");s(qO,"importFromAugmentCode");});function ew(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:de}))}var rw=d(()=>{Ct();Bi();s(ew,"lintRules");});function ow(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=new Set(nw);return Object.keys(t.hooks).filter(r=>!e.has(r)).map(r=>Fs(r,"augment-code",nw,{unsupportedBy:"AugmentCode hooks"}))}var nw,sw=d(()=>{wt();nw=["PreToolUse","PostToolUse","SessionStart","SessionEnd","Stop"];s(ow,"lintHooks");});function Dz(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 Nz(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 Fz(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=Dz(t.hooks)),Object.keys(e).length===0?null:JSON.stringify(e,null,2)}var Tz,vz,Mz,$z,Gz,iw,aw=d(()=>{VO();tw();rw();sw();Et();Bi();Tz={name:de,generateRules:KO,generateCommands:WO,generateSkills:HO,generateIgnore:zO,importFrom:qO};s(Dz,"serializeHooksForSettings");s(Nz,"mergeAugmentSettings");s(Fz,"buildSettingsContent");vz={skillDir:je,managedOutputs:{dirs:[Ge,fr,je],files:[Nn,Fn]},paths:{rulePath(t){return `${Ge}/${t}.md`},commandPath(t){return `${fr}/${t}.md`},agentPath(t){return null}}},Mz={skillDir:vn,managedOutputs:{dirs:[No,Fo,vn],files:[vo]},rewriteGeneratedPath(t){return t.startsWith(`${Ge}/`)?t.replace(`${Ge}/`,`${No}/`):t.startsWith(`${fr}/`)?t.replace(`${fr}/`,`${Fo}/`):t.startsWith(`${je}/`)?t.replace(`${je}/`,`${vn}/`):t===Nn?vo:t===Fn?null:t},paths:{rulePath(t){return `${No}/${t}.md`},commandPath(t){return `${Fo}/${t}.md`},agentPath(t){return null}}},$z={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Gz={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},iw={id:de,metadata:{displayName:"Augment Code",category:"ide",officialUrl:"https://www.augmentcode.com",shortDescription:"Codebase-aware AI for IDEs"},generators:Tz,capabilities:$z,emptyImportMessage:"No AugmentCode config found (.augment/rules, .augment/commands, .augment/skills, .augment/settings.json, or .augmentignore).",lintRules:ew,lint:{hooks:ow},project:vz,globalSupport:{capabilities:Gz,detectionPaths:[No,Fo,vn,vo],layout:Mz},emitScopedSettings(t){let e=Fz(t);return e===null?[]:[{path:Nn,content:e}]},mergeGeneratedOutputContent(t,e,r,n){return n===Nn||n===vo?Nz(t,r):null},buildImportPaths:Kh,detectionPaths:[Ge,fr,je,Nn,Fn]};});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=[];for(let i of n){if(!Ln(i))continue;let a=Jt(i),l=Re(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 cw=d(()=>{Br();s(lw,"buildClaudeHooksObjectFromCanonical");});function mw(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Ms,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:`${_m}/${i}.md`,content:l});}return e}function pw(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:`${Rm}/${e.name}.md`,content:n}})}function uw(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
66
70
 
67
- ${n}`,i=x(r,o);return {path:`${hm}/${e.name}.md`,content:i}})}function QO(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:_l,content:e}]}function qO(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
71
+ ${n}`,i=T(r,o);return {path:`${Sm}/${e.name}.md`,content:i}})}function dw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Il,content:e}]}function fw(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
68
72
 
69
- ${o}`,a=x(n,i);e.push({path:`${ym}/${r.name}/SKILL.md`,content:a});for(let l of r.supportingFiles){let c=l.relativePath.replace(/\\/g,"/");e.push({path:`${ym}/${r.name}/${c}`,content:l.content});}}return e}function tw(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:_m,content:o}]}function ew(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=VO(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:_m,content:n}]}function rw(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
70
- `);return [{path:Rm,content:e}]}var nw=d(()=>{U();Mo();JO();s(YO,"generateRules");s(XO,"generateCommands");s(ZO,"generateAgents");s(QO,"generateMcp");s(qO,"generateSkills");s(tw,"generatePermissions");s(ew,"generateHooks");s(rw,"generateIgnore");});function uz(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function ow(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
73
+ ${o}`,a=T(n,i);e.push({path:`${Im}/${r.name}/SKILL.md`,content:a});for(let l of r.supportingFiles){let c=l.relativePath.replace(/\\/g,"/");e.push({path:`${Im}/${r.name}/${c}`,content:l.content});}}return e}function gw(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:Cm,content:o}]}function hw(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=lw(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:Mo,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:Cm,content:n}]}function yw(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
74
+ `);return [{path:km,content:e}]}var _w=d(()=>{U();$o();cw();s(mw,"generateRules");s(pw,"generateCommands");s(uw,"generateAgents");s(dw,"generateMcp");s(fw,"generateSkills");s(gw,"generatePermissions");s(hw,"generateHooks");s(yw,"generateIgnore");});function Bz(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function Rw(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
71
75
 
72
- ## ${e?uz(e):"Guidance"}
76
+ ## ${e?Bz(e):"Guidance"}
73
77
 
74
78
  ${r}
75
- `:""}var sw=d(()=>{s(uz,"ruleSectionTitle");s(ow,"renderClaudeGlobalPrimaryInstructions");});function aw(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function lw(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=x(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:aw(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=x(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:aw(u,m)});}return a}var cw=d(()=>{A();U();Mo();s(aw,"computeStatus");s(lw,"generateClaudeGlobalExtras");});function mw(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"?Re(m)||Jt(m):Jt(m)||Re(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 pw(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=mw(o);if(Object.keys(i).length===0)return false;let a=stringify(i),l=join(t,Ui);return await O(dirname(l)),await S(l,a),e.push({fromTool:"claude-code",fromPath:r,toPath:Ui,feature:"hooks"}),true}async function uw(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(vo)),n=join(t,_m),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 Ht(t,Cm,m),e.push({fromTool:"claude-code",fromPath:n,toPath:Cm,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,Fh);await O(dirname(h)),await S(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:Fh,feature:"permissions"});}}let c=i.hooks;if(!r&&c&&typeof c=="object"&&!Array.isArray(c)){let m=mw(c);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,Ui);await O(dirname(u)),await S(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:Ui,feature:"hooks"});}}}var dw=d(()=>{Ur();A();Vr();Mo();s(mw,"claudeHooksToCanonical");s(pw,"importClaudeHooksJson");s(uw,"importSettings");});async function gw(t,e,r){let n=join(t,ym),o=join(t,Nh),a=(await G(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 G(c);for(let R of h){let k=await _(R);if(k===null)continue;let I=relative(c,R),C=join(p,I);await O(dirname(C));let b=r(k,R,C);await S(C,I==="SKILL.md"?await En(C,g.value.frontmatter,g.value.body):b);let N=`${Nh}/${m}/${I}`;e.push({fromTool:"claude-code",fromPath:R,toPath:N,feature:"skills"});}}}var hw=d(()=>{A();U();ft();Mo();s(gw,"importClaudeSkills");});async function yw(t,e={}){let r=e.scope??"project",n=[],o=await W("claude-code",t,r);return n.push(...await Y(td,t,r,{normalize:o})),await gw(t,n,o),await pw(t,n),await uw(t,n),n}var _w=d(()=>{gt();Ot();dw();hw();Ty();s(yw,"importFromClaudeCode");});var Rw,Iw,Sw,Cw=d(()=>{U();ft();cr();Mo();Rw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Sm}/${t}`,content:await z(n,{...o,root:false},i)}},"claudeRuleMapper"),Iw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n)),a=lr(o.allowedTools),l=a.length>0?a:lr(o["allowed-tools"]);return {destPath:n,toPath:`${wu}/${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"),Sw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Au}/${t}`,content:await Yt(n,o,i)}},"claudeAgentMapper");});function kw(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:kE}))}var Ew=d(()=>{Ct();Mo();s(kw,"lintRules");});var gz,Lw,hz,yz,td,Ty=d(()=>{nw();Mo();oe();sw();cw();_w();Cw();Ew();Et();gz={name:"claude-code",primaryRootInstructionPath:Fs,generateRules:YO,generateCommands:XO,generateAgents:ZO,generateSkills:qO,generateMcp:QO,generatePermissions:tw,generateHooks:ew,generateIgnore:rw,importFrom:yw},Lw={rootInstructionPath:Fs,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`}}},hz={rootInstructionPath:Fs,skillDir:".claude/skills",renderPrimaryRootInstruction:ow,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",Im,vo,".claudeignore"]},rewriteGeneratedPath(t){return t===_l?Im:t},mirrorGlobalPath(t,e){return dt(t,".claude/skills",e)},paths:Lw.paths},yz={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},td={id:"claude-code",metadata:{displayName:"Claude Code",category:"cli",officialUrl:"https://www.anthropic.com/claude-code",shortDescription:"Anthropic's terminal coding agent"},generators:gz,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:kw,project:Lw,globalSupport:{capabilities:yz,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:hz,scopeExtras:lw},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Fs,EE],global:[Fs]},canonicalDir:Sm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[fm],global:[fm]},canonicalDir:Sm,extensions:[".md"],map:Rw}],commands:{feature:"commands",mode:"directory",source:{project:[gm],global:[gm]},canonicalDir:wu,extensions:[".md"],map:Iw},agents:{feature:"agents",mode:"directory",source:{project:[hm],global:[hm]},canonicalDir:Au,extensions:[".md"],map:Sw},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[_l],global:[Im]},canonicalDir:".agentsmesh",canonicalFilename:Cm},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Rm],global:[Rm]},canonicalDir:".agentsmesh",canonicalFilename:LE}},buildImportPaths:vh,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function Rz(t){let e=basename(t,".md");return e==="_root"?"root":e}function Ow(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:Ms,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=Rz(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?x(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${$o}/${o}.md`,content:a});}return e}function ww(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
79
+ `:""}var Sw=d(()=>{s(Bz,"ruleSectionTitle");s(Rw,"renderClaudeGlobalPrimaryInstructions");});function Cw(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function kw(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:Cw(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:Cw(u,m)});}return a}var Ew=d(()=>{A();U();$o();s(Cw,"computeStatus");s(kw,"generateClaudeGlobalExtras");});function Lw(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(!Ln({...m,type:p}))continue;let u=p==="prompt"?Re(m)||Jt(m):Jt(m)||Re(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 Ow(t,e){let r=join(t,Mo),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=Lw(o);if(Object.keys(i).length===0)return false;let a=stringify(i),l=join(t,Ki);return await O(dirname(l)),await I(l,a),e.push({fromTool:"claude-code",fromPath:r,toPath:Ki,feature:"hooks"}),true}async function ww(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(Mo)),n=join(t,Cm),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 Ht(t,Om,m),e.push({fromTool:"claude-code",fromPath:n,toPath:Om,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,zh);await O(dirname(h)),await I(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:zh,feature:"permissions"});}}let c=i.hooks;if(!r&&c&&typeof c=="object"&&!Array.isArray(c)){let m=Lw(c);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,Ki);await O(dirname(u)),await I(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:Ki,feature:"hooks"});}}}var Aw=d(()=>{Br();A();Jr();$o();s(Lw,"claudeHooksToCanonical");s(Ow,"importClaudeHooksJson");s(ww,"importSettings");});async function Pw(t,e,r){let n=join(t,Im),o=join(t,Hh),a=(await G(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=jr(f,l);if(!g.ok){process.stderr.write(`\u26A0 skipping ${l}: ${g.error.message}
80
+ `);continue}let h=await G(c);for(let S of h){let C=await _(S);if(C===null)continue;let R=relative(c,S),k=join(p,R);await O(dirname(k));let b=r(C,S,k);await I(k,R==="SKILL.md"?await On(k,g.value.frontmatter,g.value.body):b);let N=`${Hh}/${m}/${R}`;e.push({fromTool:"claude-code",fromPath:S,toPath:N,feature:"skills"});}}}var xw=d(()=>{A();U();ft();$o();s(Pw,"importClaudeSkills");});async function Tw(t,e={}){let r=e.scope??"project",n=[],o=await W("claude-code",t,r);return n.push(...await Y(ad,t,r,{normalize:o})),await Pw(t,n,o),await Ow(t,n),await ww(t,n),n}var Dw=d(()=>{gt();Ot();Aw();xw();By();s(Tw,"importFromClaudeCode");});var Nw,Fw,vw,Mw=d(()=>{U();ft();mr();$o();Nw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Lm}/${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}=P(e(n)),a=cr(o.allowedTools),l=a.length>0?a:cr(o["allowed-tools"]);return {destPath:n,toPath:`${Nu}/${t}`,content:await St(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"),vw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Fu}/${t}`,content:await Yt(n,o,i)}},"claudeAgentMapper");});function $w(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:$E}))}var Gw=d(()=>{Ct();$o();s($w,"lintRules");});var Hz,jw,zz,Vz,ad,By=d(()=>{_w();$o();oe();Sw();Ew();Dw();Mw();Gw();Et();Hz={name:"claude-code",primaryRootInstructionPath:Ms,generateRules:mw,generateCommands:pw,generateAgents:uw,generateSkills:fw,generateMcp:dw,generatePermissions:gw,generateHooks:hw,generateIgnore:yw,importFrom:Tw},jw={rootInstructionPath:Ms,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`}}},zz={rootInstructionPath:Ms,skillDir:".claude/skills",renderPrimaryRootInstruction:Rw,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",Em,Mo,".claudeignore"]},rewriteGeneratedPath(t){return t===Il?Em:t},mirrorGlobalPath(t,e){return dt(t,".claude/skills",e)},paths:jw.paths},Vz={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},ad={id:"claude-code",metadata:{displayName:"Claude Code",category:"cli",officialUrl:"https://www.anthropic.com/claude-code",shortDescription:"Anthropic's terminal coding agent"},generators:Hz,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:$w,project:jw,globalSupport:{capabilities:Vz,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:zz,scopeExtras:kw},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Ms,GE],global:[Ms]},canonicalDir:Lm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[_m],global:[_m]},canonicalDir:Lm,extensions:[".md"],map:Nw}],commands:{feature:"commands",mode:"directory",source:{project:[Rm],global:[Rm]},canonicalDir:Nu,extensions:[".md"],map:Fw},agents:{feature:"agents",mode:"directory",source:{project:[Sm],global:[Sm]},canonicalDir:Fu,extensions:[".md"],map:vw},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Il],global:[Em]},canonicalDir:".agentsmesh",canonicalFilename:Om},ignore:{feature:"ignore",mode:"flatFile",source:{project:[km],global:[km]},canonicalDir:".agentsmesh",canonicalFilename:jE}},buildImportPaths:Vh,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function Yz(t){let e=basename(t,".md");return e==="_root"?"root":e}function Uw(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:Gs,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=Yz(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:`${Go}/${o}.md`,content:a});}return e}function Bw(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
77
81
 
78
- ${n}`:r||n;return {path:`${Fn}/${e.name}.md`,content:o}})}function Aw(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
79
- `);return [{path:Bi,content:e}]}function bw(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 Pw(t){return t.agents.map(e=>({path:`${te}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function Iz(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function Dy(t){return t.replace(/[\r\n]+/g," ")}function Sz(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${Dy(t)}`,`# agentsmesh-matcher: ${Dy(r)}`,`# agentsmesh-command: ${Dy(e)}`,"set -eu",e,""].join(`
80
- `)}function Tw(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:`${Ki}/${Iz(r)}-${o}.sh`,content:Sz(r,i.command,i.matcher)}),o++);}return e}function xw(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=x(n,r.body.trim()||"");e.push({path:`${te}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${te}/${r.name}/${a}`,content:i.content});}}return e}var Dw=d(()=>{Ur();U();ut();fr();s(Rz,"ruleSlug");s(Ow,"generateRules");s(ww,"generateCommands");s(Aw,"generateIgnore");s(bw,"generateMcp");s(Pw,"generateAgents");s(Iz,"safeEventName");s(Dy,"safeShellLine");s(Sz,"buildHookScript");s(Tw,"generateHooks");s(xw,"generateSkills");});async function Fw(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}=P(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:`${$s}/${n}`,feature:"rules",content:await z(o,c,a)}}async function vw(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=P(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(`
82
+ ${n}`:r||n;return {path:`${Mn}/${e.name}.md`,content:o}})}function Kw(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
83
+ `);return [{path:Wi,content:e}]}function Ww(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:jo,content:e}]}function Hw(t){return t.agents.map(e=>({path:`${te}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function Xz(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function Wy(t){return t.replace(/[\r\n]+/g," ")}function Zz(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${Wy(t)}`,`# agentsmesh-matcher: ${Wy(r)}`,`# agentsmesh-command: ${Wy(e)}`,"set -eu",e,""].join(`
84
+ `)}function zw(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)Oo(i)&&(e.push({path:`${Hi}/${Xz(r)}-${o}.sh`,content:Zz(r,i.command,i.matcher)}),o++);}return e}function Vw(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:`${te}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${te}/${r.name}/${a}`,content:i.content});}}return e}var Jw=d(()=>{Br();U();ut();gr();s(Yz,"ruleSlug");s(Uw,"generateRules");s(Bw,"generateCommands");s(Kw,"generateIgnore");s(Ww,"generateMcp");s(Hw,"generateAgents");s(Xz,"safeEventName");s(Wy,"safeShellLine");s(Zz,"buildHookScript");s(zw,"generateHooks");s(Vw,"generateSkills");});async function Xw(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}=P(r(o)),l=xo(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:`${js}/${n}`,feature:"rules",content:await z(o,c,a)}}async function Zw(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=P(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(`
81
85
 
82
86
  `);if(p>0){let u=i.slice(0,p).trim();u&&!u.includes(`
83
- `)&&(l=u,c=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${bu}/${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 Ny=d(()=>{U();ft();cr();fr();s(Fw,"mapClineRuleFile");s(vw,"mapClineWorkflowFile");});async function Mw(t,e,r){let n=join(t,$s),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}=P(r(p,i,u)),R=f.root===true?f:{...f,root:true},k=await z(u,R,g);await S(u,k),e.push({fromTool:"cline",fromPath:i,toPath:`${$s}/_root.md`,feature:"rules"});}return a}let l=null,c=join(o,"_root.md"),m=await _(c);if(m===null){let p=join(t,Ms),u=await _(p);if(u!==null){l=p,await O(n);let f=join(n,"_root.md"),{frontmatter:g,body:h}=P(r(u,p,f)),k=g.root===true?g:{...g,root:true},I=await z(f,k,h);await S(f,I),e.push({fromTool:"cline",fromPath:p,toPath:`${$s}/_root.md`,feature:"rules"});}else {let h=(await G(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 k=join(n,"_root.md"),{frontmatter:I,body:C}=P(r(R,h,k)),N=I.root===true?I:{...I,root:true},T=await z(k,N,C);await S(k,T),e.push({fromTool:"cline",fromPath:h,toPath:`${$s}/_root.md`,feature:"rules"});}}}}else {l=c,await O(n);let p=join(n,"_root.md"),{frontmatter:u,body:f}=P(r(m,c,p)),h=u.root===true?u:{...u,root:true},R=await z(p,h,f);await S(p,R),e.push({fromTool:"cline",fromPath:c,toPath:`${$s}/_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:Fw(u,n,f),"mapEntry")})),a}var $w=d(()=>{A();U();ft();Me();Ny();fr();s(Mw,"importClineRules");});function kz(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 Gw(t,e){let r=[Go,wE].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=kz(p);u&&(c[m]=u);}Object.keys(c).length>0&&(await O(join(t,".agentsmesh")),await S(join(t,Gh),JSON.stringify({mcpServers:c},null,2)),e.push({fromTool:vs,fromPath:i,toPath:Gh,feature:"mcp"}));}}var jw=d(()=>{A();fr();s(kz,"mapClineServerToCanonical");s(Gw,"importClineMcp");});function Uw(t){return Ez.some(e=>e.test(t))}var Ez,Bw=d(()=>{Ez=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(Uw,"isReservedArtifactName");});async function Oz(t){let e=await G(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(Uw(i))continue;let a=await _(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Vm(t,e,r){let n=await Oz(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}=P(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 Ww(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}=P(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 Jm(t){let e=new Map;try{let n=(await G(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 Xl(t,e,r=[]){for(let n of t){let o=join(e.projectRoot,n),i=await Jm(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}=P(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 Vm(l,c,e);}if(a)return}}function Zl(t){return {async recognize(e){let r=ml(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,bs(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalAgentsDir}/${r.name}.md`,feature:"agents"}),true}}}function Hw(t){return {async recognize(e){let r=uu(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,du(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalCommandsDir}/${r.name}.md`,feature:"commands"}),true}}}var Ql=d(()=>{A();U();ft();Bw();ut();Lt();om();s(Oz,"readNativeSkill");s(Vm,"importDirectorySkill");s(Ww,"importFlatSkill");s(Jm,"findDirectorySkills");s(Xl,"importSkillsDirectory");s(Zl,"projectedAgentRecognizer");s(Hw,"commandSkillRecognizer");});async function zw(t,e,r,n=te){await Xl([n],{projectRoot:t,destCanonicalSkillsDir:bE,targetName:"cline",normalize:r,results:e},[Zl({canonicalAgentsDir:AE})]);}var Vw=d(()=>{Ql();fr();s(zw,"importClineSkills");});function My(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function Jw(t,e){let n=(await G(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=My(i,"event"),l=My(i,"command");if(!a||!l)continue;let c=My(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:c,command:l});}}async function Xw(t,e){let r={};if(await Jw(join(t,Ki),r),await Jw(join(t,zi),r),Object.keys(r).length===0)return;let n=join(t,Mh);await O(dirname(n)),await S(n,stringify(r)),e.push({fromTool:vs,fromPath:join(t,zi),toPath:Mh,feature:"hooks"});}var Zw=d(()=>{A();fr();s(My,"extractMeta");s(Jw,"loadHooksFromDir");s(Xw,"importClineHooks");});async function Qw(t){let e=[],r=await W(vs,t),n=await Mw(t,e,r),o=join(t,Bi),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 S(m,c.join(`
84
- `)),e.push({fromTool:"cline",fromPath:o,toPath:$h,feature:"ignore"});}}await Gw(t,e);let a=join(t,bu);return n||e.push(...await St({srcDir:join(t,Fn),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:l,normalizeTo:c})=>vw(l,a,c),"mapEntry")})),await zw(t,e,r),await Xw(t,e),e}var qw=d(()=>{gt();A();Me();Ny();$w();fr();jw();Vw();Zw();s(Qw,"importFromCline");});function tA(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:vs}))}var eA=d(()=>{Ct();fr();s(tA,"lintRules");});function rA(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>D(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function nA(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".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 oA=d(()=>{wt();s(rA,"lintCommands");s(nA,"lintHooks");});var bz,Pz,Tz,xz,sA,iA=d(()=>{Dw();xi();fr();qw();eA();oA();Et();al();ut();bz={name:"cline",primaryRootInstructionPath:Ms,generateRules:Ow,generateCommands:ww,generateAgents:Pw,generateSkills:xw,generateMcp:bw,generateHooks:Tw,generateIgnore:Aw,importFrom:Qw},Pz={rootInstructionPath:Ms,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/${K(t)}/SKILL.md`:null}}},Tz={skillDir:te,managedOutputs:{dirs:[Wi,Hi,zi,te,".agents/skills"],files:[Go,Bi]},rewriteGeneratedPath(t){return t===Ms?null:t.startsWith(`${Ki}/`)?`${zi}/${t.slice(Ki.length+1)}`:t.startsWith(`${Fn}/`)?`${Hi}/${t.slice(Fn.length+1)}`:t.startsWith(`${$o}/`)?`${Wi}/${t.slice($o.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${te}/`)?`.agents/skills/${t.slice(te.length+1)}`:null},paths:{rulePath(t,e){return `${Wi}/${t}.md`},commandPath(t,e){return `${Hi}/${t}.md`},agentPath(t,e){return or(e,"cline")?`.cline/skills/${K(t)}/SKILL.md`:null}}},xz={rules:"native",additionalRules:"native",commands:Kr("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},sA={id:"cline",metadata:{displayName:"Cline",category:"ide",officialUrl:"https://cline.bot",shortDescription:"Autonomous coding agent for VS Code"},generators:bz,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:tA,lint:{commands:rA,hooks:nA},project:Pz,globalSupport:{capabilities:xz,detectionPaths:[Wi,Hi,zi,te,Go,Bi],layout:Tz},buildImportPaths:jh,detectionPaths:[".clinerules",".cline"],conversionDefaults:{agentsToSkills:true}};});var ke,aA,ps,Ca,lA,ao,cA,rd,ka,lo,Ea,us,mA,Xm,pA,$y,uA,Gy,dA,fA,jy,Uy,By,ye=d(()=>{ke="codex-cli",aA="codex.md",ps="AGENTS.md",Ca=".codex/AGENTS.md",lA=".codex/AGENTS.override.md",ao=".agents/skills",cA=".codex/skills",rd=".codex/config.toml",ka=".codex/instructions",lo=".codex/rules",Ea=".codex/agents",us=".agentsmesh/rules",mA=".agentsmesh/commands",Xm=".agentsmesh/agents",pA=".agentsmesh/skills",$y=".agentsmesh/mcp.json",uA="am-codex-rule:v1",Gy="# am-json: ",dA="# am-body-b64-begin",fA="# am-body-b64-end",jy="# am64:",Uy="<!-- agentsmesh:codex-rule-index:start -->",By="<!-- agentsmesh:codex-rule-index:end -->";});function Ky(t){return basename(t,".md")}function Zm(t){return `${ka}/${Ky(t.source)}.md`}function gA(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];}),x(e,t.body.trim()||"")}function Nz(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}/${Ky(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function hA(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)}](${Zm(a)}): ${Nz(a)}`),i=[Uy,"## Additional Rule Files",...o,By].join(`
87
+ `)&&(l=u,c=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${vu}/${t}`,feature:"commands",content:await St(n,{description:l,hasDescription:c,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var Hy=d(()=>{U();ft();mr();gr();s(Xw,"mapClineRuleFile");s(Zw,"mapClineWorkflowFile");});async function Qw(t,e,r){let n=join(t,js),o=join(t,Go),i=join(t,Go),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}=P(r(p,i,u)),S=f.root===true?f:{...f,root:true},C=await z(u,S,g);await I(u,C),e.push({fromTool:"cline",fromPath:i,toPath:`${js}/_root.md`,feature:"rules"});}return a}let l=null,c=join(o,"_root.md"),m=await _(c);if(m===null){let p=join(t,Gs),u=await _(p);if(u!==null){l=p,await O(n);let f=join(n,"_root.md"),{frontmatter:g,body:h}=P(r(u,p,f)),C=g.root===true?g:{...g,root:true},R=await z(f,C,h);await I(f,R),e.push({fromTool:"cline",fromPath:p,toPath:`${js}/_root.md`,feature:"rules"});}else {let h=(await G(o)).filter(S=>S.endsWith(".md")&&!S.includes("/workflows/")).sort()[0];if(h){let S=await _(h);if(S!==null){l=h,await O(n);let C=join(n,"_root.md"),{frontmatter:R,body:k}=P(r(S,h,C)),N=R.root===true?R:{...R,root:true},x=await z(C,N,k);await I(C,x),e.push({fromTool:"cline",fromPath:h,toPath:`${js}/_root.md`,feature:"rules"});}}}}else {l=c,await O(n);let p=join(n,"_root.md"),{frontmatter:u,body:f}=P(r(m,c,p)),h=u.root===true?u:{...u,root:true},S=await z(p,h,f);await I(p,S),e.push({fromTool:"cline",fromPath:c,toPath:`${js}/_root.md`,feature:"rules"});}return e.push(...await It({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:f})=>p===l?null:Xw(u,n,f),"mapEntry")})),a}var qw=d(()=>{A();U();ft();$e();Hy();gr();s(Qw,"importClineRules");});function qz(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 tA(t,e){let r=[jo,BE].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=qz(p);u&&(c[m]=u);}Object.keys(c).length>0&&(await O(join(t,".agentsmesh")),await I(join(t,Xh),JSON.stringify({mcpServers:c},null,2)),e.push({fromTool:$s,fromPath:i,toPath:Xh,feature:"mcp"}));}}var eA=d(()=>{A();gr();s(qz,"mapClineServerToCanonical");s(tA,"importClineMcp");});function rA(t){return tV.some(e=>e.test(t))}var tV,nA=d(()=>{tV=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(rA,"isReservedArtifactName");});async function rV(t){let e=await G(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(rA(i))continue;let a=await _(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Zm(t,e,r){let n=await rV(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}=P(l),p=await On(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 sA(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}=P(a),m=await On(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 Qm(t){let e=new Map;try{let n=(await G(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 ql(t,e,r=[]){for(let n of t){let o=join(e.projectRoot,n),i=await Qm(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}=P(p),g={skillName:l,skillDir:c,skillMdPath:m,rawContent:p,frontmatter:u,rawBody:f,options:e},h=false;for(let S of r)if(await S.recognize(g)){h=true;break}h||await Zm(l,c,e);}if(a)return}}function tc(t){return {async recognize(e){let r=dl(e.frontmatter,e.skillName);if(!r)return false;let{options:n}=e;await wn(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,xs(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalAgentsDir}/${r.name}.md`,feature:"agents"}),true}}}function iA(t){return {async recognize(e){let r=Ru(e.frontmatter,e.skillName);if(!r)return false;let{options:n}=e;await wn(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,Su(r,a)),n.results.push({fromTool:n.targetName,fromPath:e.skillMdPath,toPath:`${t.canonicalCommandsDir}/${r.name}.md`,feature:"commands"}),true}}}var ec=d(()=>{A();U();ft();nA();ut();Lt();lm();s(rV,"readNativeSkill");s(Zm,"importDirectorySkill");s(sA,"importFlatSkill");s(Qm,"findDirectorySkills");s(ql,"importSkillsDirectory");s(tc,"projectedAgentRecognizer");s(iA,"commandSkillRecognizer");});async function aA(t,e,r,n=te){await ql([n],{projectRoot:t,destCanonicalSkillsDir:WE,targetName:"cline",normalize:r,results:e},[tc({canonicalAgentsDir:KE})]);}var lA=d(()=>{ec();gr();s(aA,"importClineSkills");});function Jy(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function cA(t,e){let n=(await G(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=Jy(i,"event"),l=Jy(i,"command");if(!a||!l)continue;let c=Jy(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:c,command:l});}}async function pA(t,e){let r={};if(await cA(join(t,Hi),r),await cA(join(t,Ji),r),Object.keys(r).length===0)return;let n=join(t,Jh);await O(dirname(n)),await I(n,stringify(r)),e.push({fromTool:$s,fromPath:join(t,Ji),toPath:Jh,feature:"hooks"});}var uA=d(()=>{A();gr();s(Jy,"extractMeta");s(cA,"loadHooksFromDir");s(pA,"importClineHooks");});async function dA(t){let e=[],r=await W($s,t),n=await Qw(t,e,r),o=join(t,Wi),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,Yh);await I(m,c.join(`
88
+ `)),e.push({fromTool:"cline",fromPath:o,toPath:Yh,feature:"ignore"});}}await tA(t,e);let a=join(t,vu);return n||e.push(...await It({srcDir:join(t,Mn),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:l,normalizeTo:c})=>Zw(l,a,c),"mapEntry")})),await aA(t,e,r),await pA(t,e),e}var fA=d(()=>{gt();A();$e();Hy();qw();gr();eA();lA();uA();s(dA,"importFromCline");});function gA(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:$s}))}var hA=d(()=>{Ct();gr();s(gA,"lintRules");});function yA(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>D(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function _A(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".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 RA=d(()=>{wt();s(yA,"lintCommands");s(_A,"lintHooks");});var sV,iV,aV,lV,SA,IA=d(()=>{Jw();Ni();gr();fA();hA();RA();Et();ml();ut();sV={name:"cline",primaryRootInstructionPath:Gs,generateRules:Uw,generateCommands:Bw,generateAgents:Hw,generateSkills:Vw,generateMcp:Ww,generateHooks:zw,generateIgnore:Kw,importFrom:dA},iV={rootInstructionPath:Gs,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 `${Go}/${t}.md`},commandPath(t,e){return `${Mn}/${t}.md`},agentPath(t,e){return sr(e,"cline")?`.cline/skills/${K(t)}/SKILL.md`:null}}},aV={skillDir:te,managedOutputs:{dirs:[zi,Vi,Ji,te,".agents/skills"],files:[jo,Wi]},rewriteGeneratedPath(t){return t===Gs?null:t.startsWith(`${Hi}/`)?`${Ji}/${t.slice(Hi.length+1)}`:t.startsWith(`${Mn}/`)?`${Vi}/${t.slice(Mn.length+1)}`:t.startsWith(`${Go}/`)?`${zi}/${t.slice(Go.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${te}/`)?`.agents/skills/${t.slice(te.length+1)}`:null},paths:{rulePath(t,e){return `${zi}/${t}.md`},commandPath(t,e){return `${Vi}/${t}.md`},agentPath(t,e){return sr(e,"cline")?`.cline/skills/${K(t)}/SKILL.md`:null}}},lV={rules:"native",additionalRules:"native",commands:Wr("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},SA={id:"cline",metadata:{displayName:"Cline",category:"ide",officialUrl:"https://cline.bot",shortDescription:"Autonomous coding agent for VS Code"},generators:sV,capabilities:{rules:"native",additionalRules:"native",commands:Wr("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:gA,lint:{commands:yA,hooks:_A},project:iV,globalSupport:{capabilities:lV,detectionPaths:[zi,Vi,Ji,te,jo,Wi],layout:aV},buildImportPaths:Zh,detectionPaths:[".clinerules",".cline"],conversionDefaults:{agentsToSkills:true}};});var ke,CA,us,Ea,kA,lo,EA,cd,La,co,Oa,ds,LA,tp,OA,Yy,wA,Xy,AA,bA,Zy,Qy,qy,ye=d(()=>{ke="codex-cli",CA="codex.md",us="AGENTS.md",Ea=".codex/AGENTS.md",kA=".codex/AGENTS.override.md",lo=".agents/skills",EA=".codex/skills",cd=".codex/config.toml",La=".codex/instructions",co=".codex/rules",Oa=".codex/agents",ds=".agentsmesh/rules",LA=".agentsmesh/commands",tp=".agentsmesh/agents",OA=".agentsmesh/skills",Yy=".agentsmesh/mcp.json",wA="am-codex-rule:v1",Xy="# am-json: ",AA="# am-body-b64-begin",bA="# am-body-b64-end",Zy="# am64:",Qy="<!-- agentsmesh:codex-rule-index:start -->",qy="<!-- agentsmesh:codex-rule-index:end -->";});function t_(t){return basename(t,".md")}function ep(t){return `${La}/${t_(t.source)}.md`}function PA(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 mV(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 \`${co}/${t_(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function xA(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||t_(a.source)}](${ep(a)}): ${mV(a)}`),i=[Qy,"## Additional Rule Files",...o,qy].join(`
85
89
  `);return r?`${r}
86
90
 
87
- ${i}`:i}function yA(t){let e=Uy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=By.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
88
- `).trim()}var nd=d(()=>{U();ye();s(Ky,"ruleSlug");s(Zm,"codexInstructionMirrorPath");s(gA,"serializeCodexInstructionMirror");s(Nz,"summarizeRule");s(hA,"appendCodexRuleIndex");s(yA,"stripCodexRuleIndex");});function vz(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function Mz(t){return t.split(`
91
+ ${i}`:i}function TA(t){let e=Qy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=qy.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
92
+ `).trim()}var md=d(()=>{U();ye();s(t_,"ruleSlug");s(ep,"codexInstructionMirrorPath");s(PA,"serializeCodexInstructionMirror");s(mV,"summarizeRule");s(xA,"appendCodexRuleIndex");s(TA,"stripCodexRuleIndex");});function uV(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function dV(t){return t.split(`
89
93
  `).map(e=>e.length>0?`# ${e}`:"#").join(`
90
- `)}function $z(t){let e=t.trim();return e?vz(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.","#",...Mz(e).split(`
94
+ `)}function fV(t){let e=t.trim();return e?uV(e)?`${e}
95
+ `:`${["# 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.","#",...dV(e).split(`
92
96
  `),"#","# Example template:","# prefix_rule(",'# pattern = ["git", "status"],','# decision = "allow",','# justification = "Allow safe status checks",',"# )"].join(`
93
97
  `)}
94
- `:""}function Wy(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:ps,content:hA(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:$z(n.body)}),r.push({path:Zm(n),content:gA(n)}));}return r}function Hy(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 _A=d(()=>{Wt();ye();nd();s(vz,"looksLikeCodexRulesDsl");s(Mz,"toCodexRulesComments");s($z,"toSafeCodexRulesContent");s(Wy,"generateRules");s(Hy,"renderCodexGlobalInstructions");});function zy(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=x(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 Gz(t){return {path:`${ao}/${V(t.name)}/SKILL.md`,content:Mt(t)}}function Vy(t){return t.commands.map(Gz)}var RA=d(()=>{U();ye();Lt();s(zy,"generateSkills");s(Gz,"commandToSkillOutput");s(Vy,"generateCommands");});function Jy(t){return t.agents.map(e=>({path:`${Ea}/${e.name}.toml`,content:jz(e)}))}function jz(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 = """
98
+ `:""}function e_(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:us,content:xA(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:`${co}/${o}.rules`,content:fV(n.body)}),r.push({path:ep(n),content:PA(n)}));}return r}function r_(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 at(e?.body.trim()??"",r)}var DA=d(()=>{Kt();ye();md();s(uV,"looksLikeCodexRulesDsl");s(dV,"toCodexRulesComments");s(fV,"toSafeCodexRulesContent");s(e_,"generateRules");s(r_,"renderCodexGlobalInstructions");});function n_(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 gV(t){return {path:`${lo}/${V(t.name)}/SKILL.md`,content:Mt(t)}}function o_(t){return t.commands.map(gV)}var NA=d(()=>{U();ye();Lt();s(n_,"generateSkills");s(gV,"commandToSkillOutput");s(o_,"generateCommands");});function s_(t){return t.agents.map(e=>({path:`${Oa}/${e.name}.toml`,content:hV(e)}))}function hV(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 = """
95
99
  ${n}
96
100
  """`);}else e.push(`developer_instructions = '''
97
101
  ${r}
98
102
  '''`);return e.join(`
99
103
  `)+`
100
- `}var IA=d(()=>{ye();s(Jy,"generateAgents");s(jz,"serializeAgentToCodexToml");});function od(t){return "command"in t}function SA(t){return "url"in t}var sd=d(()=>{s(od,"isStdioMcpServer");s(SA,"isUrlMcpServer");});function Yy(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>od(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=Uz(e);return [{path:rd,content:r}]}function Uz(t){let e=[];for(let[r,n]of Object.entries(t)){let o=CA(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])=>`${CA(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${c} }`);}e.push(i.join(`
104
+ `}var FA=d(()=>{ye();s(s_,"generateAgents");s(hV,"serializeAgentToCodexToml");});function pd(t){return "command"in t}function vA(t){return "url"in t}var ud=d(()=>{s(pd,"isStdioMcpServer");s(vA,"isUrlMcpServer");});function i_(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>pd(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=yV(e);return [{path:cd,content:r}]}function yV(t){let e=[];for(let[r,n]of Object.entries(t)){let o=MA(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])=>`${MA(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${c} }`);}e.push(i.join(`
101
105
  `));}return e.join(`
102
106
 
103
107
  `)+`
104
- `}function CA(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var kA=d(()=>{sd();ye();s(Yy,"generateMcp");s(Uz,"serializeMcpToToml");s(CA,"needsTomlQuoting");});var EA=d(()=>{_A();RA();IA();kA();});var LA=d(()=>{EA();});function Wz(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 OA(t,e){let r=join(t,rd),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=Wz(c);m&&(a[l]=m);}Object.keys(a).length!==0&&(await Ht(t,$y,a),e.push({fromTool:ke,fromPath:r,toPath:$y,feature:"mcp"}));}var wA=d(()=>{A();Vr();ye();s(Wz,"mapTomlServerToCanonical");s(OA,"importMcp");});async function AA(t,e,r){await Xl([ao,cA],{projectRoot:t,destCanonicalSkillsDir:pA,targetName:ke,normalize:r,results:e},[Hw({canonicalCommandsDir:mA}),Zl({canonicalAgentsDir:Xm})]);}var bA=d(()=>{Ql();ye();s(AA,"importSkills");});async function PA(t,e,r){let n=join(t,Ea),o=join(t,Xm);try{let a=(await G(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":"",k=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(T=>typeof T=="string"):[];await O(o);let I=join(o,`${p}.md`),C=r(f,l,I),N=bs({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:R,maxTurns:0,mcpServers:k,hooks:{},skills:[],memory:""},C);await S(I,N),e.push({fromTool:ke,fromPath:l,toPath:`${Xm}/${p}.md`,feature:"agents"});}}catch{}}var TA=d(()=>{A();ut();ye();s(PA,"importCodexAgentsFromToml");});function xA(t){if(!t.includes(uA))return null;let e=t.split(`
105
- `).find(c=>c.startsWith(Gy));if(!e)return null;let r;try{r=JSON.parse(e.slice(Gy.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===dA){l=true;continue}if(m===fA){l=false;continue}l&&m.startsWith(jy)&&a.push(m.slice(jy.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 DA=d(()=>{ye();s(xA,"tryParseEmbeddedCanonicalFromCodexRules");});async function FA(t,e,r){let n=[],o=join(t,lo);try{let i=await G(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}=P(r(m,c,u));await O(e);let h=f.root===!0?f:{...f,root:!1},R=await z(u,h,g);await S(u,R),n.push({fromTool:ke,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=xA(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:ke,fromPath:c,toPath:`${us}/${p}`,feature:"rules"});}}catch{}return n}var vA=d(()=>{A();U();ft();ye();DA();s(FA,"importCodexNonRootRuleFiles");});async function $A(t,e,r,n,o){let i=join(t,aA),a=join(t,ps),l=join(t,lA),c=join(t,Ca),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),R=m??p??u??f;if(R!==null){await O(h);let k=join(h,"_root.md"),I=g===a||g===c||g===l?yA(R):R,C=await io({content:I,projectRoot:t,rulesDir:us,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...C.results);let b=r(g===a||g===c||g===l?n(C.rootContent,g,k):C.rootContent,g,k),{frontmatter:N,body:T}=P(b),B=N.root===true?N:{...N,root:true},H=await z(k,B,T);await S(k,H),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${us}/_root.md`,feature:"rules"});}await Xz(t,h,e,r),e.push(...await FA(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:I})=>{let C=relative(t,dirname(k)).replace(/\\/g,"/"),b=basename(k),N=b==="AGENTS.override.md";if(!C||C==="."||!N&&b!=="AGENTS.md")return null;let T=C.replace(/\//g,"-");if(!yu(C))return await Ln(join(h,`${T}.md`)),null;let B=join(h,`${T}.md`),{frontmatter:H,body:tt}=P(I(B));return {destPath:B,toPath:`${us}/${T}.md`,feature:"rules",content:await z(B,{...H,root:false,globs:[`${C}/**`],...N?{codex_instruction:"override"}:{}},tt)}},"mapEntry")}));}async function Xz(t,e,r,n){try{let i=(await G(join(t,ka))).filter(l=>l.endsWith(".md")),a=join(t,ka);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}=P(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:ke,fromPath:l,toPath:`${us}/${c}`,feature:"rules"});}}catch{}}var GA=d(()=>{A();U();ft();Jl();Me();om();ye();vA();nd();s($A,"importCodexRules");s(Xz,"importInstructionMirrors");});async function jA(t,e){let r=e?.scope??"project",n=[],o=await W(ke,t,r),i=await W("windsurf",t,r);return await $A(t,n,o,i,r),await AA(t,n,o),await PA(t,n,o),await OA(t,n),n}var UA=d(()=>{gt();ye();wA();bA();TA();GA();s(jA,"importFromCodex");});function BA(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:ke,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var KA=d(()=>{ye();s(BA,"lintRules");});function WA(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(D(".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(D(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var HA=d(()=>{wt();s(WA,"lintMcp");});function zA(t){return Zm(t)}var VA=d(()=>{nd();s(zA,"codexAdvisoryInstructionPath");});var Qz,qz,tV,eV,YA,XA=d(()=>{LA();ye();UA();KA();HA();Et();al();VA();Lt();Qz={name:"codex-cli",primaryRootInstructionPath:ps,generateRules:Wy,generateCommands:Vy,generateAgents:Jy,generateSkills:zy,generateMcp:Yy,importFrom:jA},qz={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 zA(e)},commandPath(t,e){return il(e,"codex-cli")?`${ao}/${V(t)}/SKILL.md`:null},agentPath(t,e){return `${Ea}/${t}.toml`}}},tV={rootInstructionPath:Ca,renderPrimaryRootInstruction:Hy,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:[Ca,".codex/config.toml"]},rewriteGeneratedPath(t){return t===ps?Ca:t.startsWith(`${ka}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${lo}/${t}.rules`:Ca},commandPath(t,e){return il(e,"codex-cli")?`${ao}/${V(t)}/SKILL.md`:null},agentPath(t,e){return `${Ea}/${t}.toml`}}},eV={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},YA={id:"codex-cli",metadata:{displayName:"Codex CLI",category:"cli",officialUrl:"https://github.com/openai/codex",shortDescription:"OpenAI's terminal coding agent"},generators:Qz,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:BA,lint:{mcp:WA},project:qz,globalSupport:{capabilities:eV,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:tV},buildImportPaths:Uh,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 nV(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function ZA(t){return `${vn}/${t}.md`}function QA(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"],x(e,t.body.trim()||"")}function qA(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:nV(t["x-agentsmesh-allowed-tools"])}}function tb(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"],x(r,e.trim()||"")}var id=d(()=>{U();Mn();s(nV,"toStringArray");s(ZA,"continueCommandRulePath");s(QA,"serializeCommandRule");s(qA,"parseCommandRuleFrontmatter");s(tb,"serializeImportedCommand");});function eb(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:x(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:x(i,n.body.trim()||"")});}return e}function rb(t){return t.commands.map(e=>({path:`${vn}/${e.name}.md`,content:QA(e)}))}function nb(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Pu,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function ob(t){return t.agents.map(e=>({path:`${je}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function sb(t){return st(t,je)}var ib=d(()=>{rt();ut();U();id();Mn();s(eb,"generateRules");s(rb,"generateCommands");s(nb,"generateMcp");s(ob,"generateAgents");s(sb,"generateSkills");});function aV(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:Ts(l.args),env:wn(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function lV(t,e){let r=(await G(join(t,Bh))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await _(i);a&&(Object.assign(n,aV(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Ht(t,Wh,n);for(let i of o)e.push({fromTool:Rl,fromPath:i,toPath:Wh,feature:"mcp"});}}async function lb(t){let e=[],r=await W(Rl,t);return e.push(...await Y(ad,t,"project",{normalize:r})),await et(t,je,Rl,e,r),await lV(t,e),e}var cb=d(()=>{gt();A();rt();Ot();Vr();cr();Mn();Qy();s(aV,"readMcpServers");s(lV,"importMcp");s(lb,"importFromContinue");});function cV(t){return t==="general.md"||t==="_root.md"}var mb,pb,ub=d(()=>{U();ft();id();Mn();s(cV,"isContinueRootRulePath");mb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=cV(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:l}=P(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:`${Tu}/${o}`,content:await z(i,c,l)}},"continueRuleMapper"),pb=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=P(r(o)),l=qA(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},P(tb(l,a)).body);return {destPath:u,toPath:`${xu}/${p}`,content:f}},"continueCommandMapper");});function db(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Rl}))}var fb=d(()=>{Ct();Mn();s(db,"lintRules");});function gb(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>D(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var hb=d(()=>{wt();s(gb,"lintCommands");});function dV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var yb,_b=d(()=>{A();Mn();s(dV,"computeStatus");yb=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,km));return [{target:"continue",path:km,content:m,currentContent:p??void 0,status:dV(p,m)}]},"generateContinueGlobalConfig");});function gV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Rb,Ib=d(()=>{A();Mn();_b();s(gV,"computeStatus");Rb=s(async(t,e,r,n)=>{let o=await yb(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,Il));return [...o,{target:"continue",path:Il,content:a,currentContent:l??void 0,status:gV(l,a)}]},"generateContinueScopeExtras");});var hV,yV,_V,RV,ad,Qy=d(()=>{ut();ib();Mn();cb();ub();fb();hb();id();Et();Ib();hV={name:"continue",primaryRootInstructionPath:jo,generateRules:eb,generateCommands:rb,generateAgents:ob,generateSkills:sb,generateMcp:nb,importFrom:lb},yV={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 ZA(t)},agentPath(t){return `${je}/${K(t)}/SKILL.md`}}},_V={rootInstructionPath:jo,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Il]}],skillDir:je,managedOutputs:{dirs:[Zr,vn,je,".agents/skills"],files:[Pu,Il,km]},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}/${K(t)}/SKILL.md`}}},RV={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ad={id:"continue",metadata:{displayName:"Continue",category:"ide",officialUrl:"https://continue.dev",shortDescription:"Open-source AI code assistant"},generators:hV,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:db,lint:{commands:gb},project:yV,globalSupport:{capabilities:RV,detectionPaths:[Zr,vn,".continue/mcpServers",je],layout:_V,scopeExtras:Rb},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Zr],global:[Zr]},canonicalDir:Tu,extensions:[".md"],map:mb},commands:{feature:"commands",mode:"directory",source:{project:[vn],global:[vn]},canonicalDir:xu,extensions:[".md"],map:pb}},buildImportPaths:Hh,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"],conversionDefaults:{agentsToSkills:true}};});var ds,La,Sb,Oa,li,co,mo,wa,Aa,ld,cd,Cb,t_,kb,ci,ql,fs,tc,ba,e_,r_,Dr=d(()=>{ds="copilot",La=".github/copilot-instructions.md",Sb=".github/copilot",Oa=".github/instructions",li=".github/prompts",co=".github/hooks",mo=".github/skills",wa=".github/agents",Aa=".agentsmesh/rules",ld=".agentsmesh/commands",cd=".agentsmesh/agents",Cb=".agentsmesh/skills",t_=".agentsmesh/hooks.yaml",kb=".github/copilot-hooks",ci=".copilot/copilot-instructions.md",ql=".copilot/agents",fs=".copilot/skills",tc=".copilot/prompts",ba=".copilot/AGENTS.md",e_=".claude/skills",r_=".agents/skills";});function Eb(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 md(t){return `${li}/${t}.prompt.md`}function Lb(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"],x(e,t.body.trim()||"")}function Ob(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=Eb(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:Eb(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var pd=d(()=>{U();Dr();s(Eb,"toStringArray");s(md,"commandPromptPath");s(Lb,"serializeCommandPrompt");s(Ob,"parseCommandPromptFrontmatter");});function ud(t){return Lo(t)}var n_=d(()=>{Ur();s(ud,"hasHookCommand");});function CV(t){let e=basename(t,".md");return e==="_root"?"root":e}function kV(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function wb(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}
108
+ `}function MA(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var $A=d(()=>{ud();ye();s(i_,"generateMcp");s(yV,"serializeMcpToToml");s(MA,"needsTomlQuoting");});var GA=d(()=>{DA();NA();FA();$A();});var jA=d(()=>{GA();});function SV(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 UA(t,e){let r=join(t,cd),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=SV(c);m&&(a[l]=m);}Object.keys(a).length!==0&&(await Ht(t,Yy,a),e.push({fromTool:ke,fromPath:r,toPath:Yy,feature:"mcp"}));}var BA=d(()=>{A();Jr();ye();s(SV,"mapTomlServerToCanonical");s(UA,"importMcp");});async function KA(t,e,r){await ql([lo,EA],{projectRoot:t,destCanonicalSkillsDir:OA,targetName:ke,normalize:r,results:e},[iA({canonicalCommandsDir:LA}),tc({canonicalAgentsDir:tp})]);}var WA=d(()=>{ec();ye();s(KA,"importSkills");});async function HA(t,e,r){let n=join(t,Oa),o=join(t,tp);try{let a=(await G(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:"",S=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",C=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(x=>typeof x=="string"):[];await O(o);let R=join(o,`${p}.md`),k=r(f,l,R),N=xs({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:S,maxTurns:0,mcpServers:C,hooks:{},skills:[],memory:""},k);await I(R,N),e.push({fromTool:ke,fromPath:l,toPath:`${tp}/${p}.md`,feature:"agents"});}}catch{}}var zA=d(()=>{A();ut();ye();s(HA,"importCodexAgentsFromToml");});function VA(t){if(!t.includes(wA))return null;let e=t.split(`
109
+ `).find(c=>c.startsWith(Xy));if(!e)return null;let r;try{r=JSON.parse(e.slice(Xy.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(`
110
+ `)){let m=c.trimEnd();if(m===AA){l=true;continue}if(m===bA){l=false;continue}l&&m.startsWith(Zy)&&a.push(m.slice(Zy.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 JA=d(()=>{ye();s(VA,"tryParseEmbeddedCanonicalFromCodexRules");});async function XA(t,e,r){let n=[],o=join(t,co);try{let i=await G(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}=P(r(m,c,u));await O(e);let h=f.root===!0?f:{...f,root:!1},S=await z(u,h,g);await I(u,S),n.push({fromTool:ke,fromPath:c,toPath:`${ds}/${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=VA(m);if(f){let g=await z(u,{description:f.meta.description,globs:f.meta.globs,root:!1},r(f.body,c,u));await I(u,g);}else {let g=await z(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),c,u));await I(u,g);}n.push({fromTool:ke,fromPath:c,toPath:`${ds}/${p}`,feature:"rules"});}}catch{}return n}var ZA=d(()=>{A();U();ft();ye();JA();s(XA,"importCodexNonRootRuleFiles");});async function qA(t,e,r,n,o){let i=join(t,CA),a=join(t,us),l=join(t,kA),c=join(t,Ea),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,ds),S=m??p??u??f;if(S!==null){await O(h);let C=join(h,"_root.md"),R=g===a||g===c||g===l?TA(S):S,k=await ao({content:R,projectRoot:t,rulesDir:ds,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...k.results);let b=r(g===a||g===c||g===l?n(k.rootContent,g,C):k.rootContent,g,C),{frontmatter:N,body:x}=P(b),B=N.root===true?N:{...N,root:true},H=await z(C,B,x);await I(C,H),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${ds}/_root.md`,feature:"rules"});}await OV(t,h,e,r),e.push(...await XA(t,h,r)),o!=="global"&&e.push(...await It({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:C,normalizeTo:R})=>{let k=relative(t,dirname(C)).replace(/\\/g,"/"),b=basename(C),N=b==="AGENTS.override.md";if(!k||k==="."||!N&&b!=="AGENTS.md")return null;let x=k.replace(/\//g,"-");if(!Eu(k))return await wn(join(h,`${x}.md`)),null;let B=join(h,`${x}.md`),{frontmatter:H,body:tt}=P(R(B));return {destPath:B,toPath:`${ds}/${x}.md`,feature:"rules",content:await z(B,{...H,root:false,globs:[`${k}/**`],...N?{codex_instruction:"override"}:{}},tt)}},"mapEntry")}));}async function OV(t,e,r,n){try{let i=(await G(join(t,La))).filter(l=>l.endsWith(".md")),a=join(t,La);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}=P(n(m,l,p));await O(e);let g=u.root===!0?u:{...u,root:!1},h=await z(p,g,f);await I(p,h),r.push({fromTool:ke,fromPath:l,toPath:`${ds}/${c}`,feature:"rules"});}}catch{}}var tb=d(()=>{A();U();ft();Zl();$e();lm();ye();ZA();md();s(qA,"importCodexRules");s(OV,"importInstructionMirrors");});async function eb(t,e){let r=e?.scope??"project",n=[],o=await W(ke,t,r),i=await W("windsurf",t,r);return await qA(t,n,o,i,r),await KA(t,n,o),await HA(t,n,o),await UA(t,n),n}var rb=d(()=>{gt();ye();BA();WA();zA();tb();s(eb,"importFromCodex");});function nb(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:ke,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var ob=d(()=>{ye();s(nb,"lintRules");});function sb(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(D(".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(D(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var ib=d(()=>{wt();s(sb,"lintMcp");});function ab(t){return ep(t)}var lb=d(()=>{md();s(ab,"codexAdvisoryInstructionPath");});var AV,bV,PV,xV,mb,pb=d(()=>{jA();ye();rb();ob();ib();Et();ml();lb();Lt();AV={name:"codex-cli",primaryRootInstructionPath:us,generateRules:e_,generateCommands:o_,generateAgents:s_,generateSkills:n_,generateMcp:i_,importFrom:eb},bV={rootInstructionPath:us,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${co}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return ab(e)},commandPath(t,e){return cl(e,"codex-cli")?`${lo}/${V(t)}/SKILL.md`:null},agentPath(t,e){return `${Oa}/${t}.toml`}}},PV={rootInstructionPath:Ea,renderPrimaryRootInstruction:r_,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${co}/${e}.rules`]},skillDir:lo,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Ea,".codex/config.toml"]},rewriteGeneratedPath(t){return t===us?Ea:t.startsWith(`${La}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${co}/${t}.rules`:Ea},commandPath(t,e){return cl(e,"codex-cli")?`${lo}/${V(t)}/SKILL.md`:null},agentPath(t,e){return `${Oa}/${t}.toml`}}},xV={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},mb={id:"codex-cli",metadata:{displayName:"Codex CLI",category:"cli",officialUrl:"https://github.com/openai/codex",shortDescription:"OpenAI's terminal coding agent"},generators:AV,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:nb,lint:{mcp:sb},project:bV,globalSupport:{capabilities:xV,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:PV},buildImportPaths:Qh,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 DV(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 ub(t){return `${$n}/${t}.md`}function db(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 fb(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:DV(t["x-agentsmesh-allowed-tools"])}}function gb(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 dd=d(()=>{U();Gn();s(DV,"toStringArray");s(ub,"continueCommandRulePath");s(db,"serializeCommandRule");s(fb,"parseCommandRuleFrontmatter");s(gb,"serializeImportedCommand");});function hb(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:Uo,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:`${Qr}/${o}.md`,content:T(i,n.body.trim()||"")});}return e}function yb(t){return t.commands.map(e=>({path:`${$n}/${e.name}.md`,content:db(e)}))}function _b(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Mu,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Rb(t){return t.agents.map(e=>({path:`${Ue}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function Sb(t){return st(t,Ue)}var Ib=d(()=>{rt();ut();U();dd();Gn();s(hb,"generateRules");s(yb,"generateCommands");s(_b,"generateMcp");s(Rb,"generateAgents");s(Sb,"generateSkills");});function MV(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:Ds(l.args),env:bn(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function $V(t,e){let r=(await G(join(t,qh))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await _(i);a&&(Object.assign(n,MV(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Ht(t,ey,n);for(let i of o)e.push({fromTool:Cl,fromPath:i,toPath:ey,feature:"mcp"});}}async function kb(t){let e=[],r=await W(Cl,t);return e.push(...await Y(fd,t,"project",{normalize:r})),await et(t,Ue,Cl,e,r),await $V(t,e),e}var Eb=d(()=>{gt();A();rt();Ot();Jr();mr();Gn();c_();s(MV,"readMcpServers");s($V,"importMcp");s(kb,"importFromContinue");});function GV(t){return t==="general.md"||t==="_root.md"}var Lb,Ob,wb=d(()=>{U();ft();dd();Gn();s(GV,"isContinueRootRulePath");Lb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=GV(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:l}=P(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:`${$u}/${o}`,content:await z(i,c,l)}},"continueRuleMapper"),Ob=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=P(r(o)),l=fb(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 St(u,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},P(gb(l,a)).body);return {destPath:u,toPath:`${Gu}/${p}`,content:f}},"continueCommandMapper");});function Ab(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Cl}))}var bb=d(()=>{Ct();Gn();s(Ab,"lintRules");});function Pb(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>D(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var xb=d(()=>{wt();s(Pb,"lintCommands");});function KV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Tb,Db=d(()=>{A();Gn();s(KV,"computeStatus");Tb=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,wm));return [{target:"continue",path:wm,content:m,currentContent:p??void 0,status:KV(p,m)}]},"generateContinueGlobalConfig");});function HV(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Nb,Fb=d(()=>{A();Gn();Db();s(HV,"computeStatus");Nb=s(async(t,e,r,n)=>{let o=await Tb(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,kl));return [...o,{target:"continue",path:kl,content:a,currentContent:l??void 0,status:HV(l,a)}]},"generateContinueScopeExtras");});var zV,VV,JV,YV,fd,c_=d(()=>{ut();Ib();Gn();Eb();wb();bb();xb();dd();Et();Fb();zV={name:"continue",primaryRootInstructionPath:Uo,generateRules:hb,generateCommands:yb,generateAgents:Rb,generateSkills:Sb,generateMcp:_b,importFrom:kb},VV={rootInstructionPath:Uo,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Qr}/${t}.md`},commandPath(t,e){return ub(t)},agentPath(t){return `${Ue}/${K(t)}/SKILL.md`}}},JV={rootInstructionPath:Uo,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[kl]}],skillDir:Ue,managedOutputs:{dirs:[Qr,$n,Ue,".agents/skills"],files:[Mu,kl,wm]},mirrorGlobalPath(t,e){return t.startsWith(`${Ue}/`)?`.agents/skills/${t.slice(Ue.length+1)}`:null},paths:{rulePath(t,e){return `${Qr}/${t}.md`},commandPath(t,e){return `${$n}/${t}.md`},agentPath(t){return `${Ue}/${K(t)}/SKILL.md`}}},YV={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},fd={id:"continue",metadata:{displayName:"Continue",category:"ide",officialUrl:"https://continue.dev",shortDescription:"Open-source AI code assistant"},generators:zV,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:Pb},project:VV,globalSupport:{capabilities:YV,detectionPaths:[Qr,$n,".continue/mcpServers",Ue],layout:JV,scopeExtras:Nb},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Qr],global:[Qr]},canonicalDir:$u,extensions:[".md"],map:Lb},commands:{feature:"commands",mode:"directory",source:{project:[$n],global:[$n]},canonicalDir:Gu,extensions:[".md"],map:Ob}},buildImportPaths:ry,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"],conversionDefaults:{agentsToSkills:true}};});var fs,wa,vb,Aa,mi,mo,po,ba,Pa,gd,hd,Mb,p_,$b,pi,rc,gs,nc,xa,u_,d_,Nr=d(()=>{fs="copilot",wa=".github/copilot-instructions.md",vb=".github/copilot",Aa=".github/instructions",mi=".github/prompts",mo=".github/hooks",po=".github/skills",ba=".github/agents",Pa=".agentsmesh/rules",gd=".agentsmesh/commands",hd=".agentsmesh/agents",Mb=".agentsmesh/skills",p_=".agentsmesh/hooks.yaml",$b=".github/copilot-hooks",pi=".copilot/copilot-instructions.md",rc=".copilot/agents",gs=".copilot/skills",nc=".copilot/prompts",xa=".copilot/AGENTS.md",u_=".claude/skills",d_=".agents/skills";});function Gb(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 yd(t){return `${mi}/${t}.prompt.md`}function jb(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 Ub(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=Gb(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:Gb(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var _d=d(()=>{U();Nr();s(Gb,"toStringArray");s(yd,"commandPromptPath");s(jb,"serializeCommandPrompt");s(Ub,"parseCommandPromptFrontmatter");});function Rd(t){return Oo(t)}var f_=d(()=>{Br();s(Rd,"hasHookCommand");});function QV(t){let e=basename(t,".md");return e==="_root"?"root":e}function qV(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function Bb(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}
107
111
 
108
112
  ${o}`):e.push(o);}return e.join(`
109
113
 
110
- `)}function Ab(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:La,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=CV(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=x(i,n.body.trim()||"");r.push({path:`${Oa}/${o}.instructions.md`,content:a});}return r}function bb(t){return t.commands.map(e=>({path:md(e.name),content:Lb(e)}))}function Pb(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=x(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 Tb(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=x(r,e.body.trim()||"");return {path:`${wa}/${e.name}.agent.md`,content:n}})}function xb(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=kV(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&ud(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 Db=d(()=>{U();Dr();pd();n_();s(CV,"ruleSlug");s(kV,"mapHookEvent");s(wb,"renderCopilotGlobalInstructions");s(Ab,"generateRules");s(bb,"generateCommands");s(Pb,"generateSkills");s(Tb,"generateAgents");s(xb,"generateHooks");});function LV(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function OV(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function vb(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 Mb(t,e){let r=join(t,co),o=(await G(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=LV(g);if(!(!R||!Array.isArray(h)))for(let k of h){if(!k||typeof k!="object")continue;let I=k,C=typeof I.bash=="string"?I.bash:"";if(!C)continue;let b=join(r,C.replace(/^\.\//,"")),N=await _(b);if(!N)continue;let T=vb(N);T&&(i[R]||(i[R]=[]),i[R].push({matcher:OV(I.comment),command:T,type:"command"}));}}}let a=join(t,kb),c=(await G(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:vb(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,t_);await O(dirname(m)),await S(m,stringify(i)),e.push({fromTool:ds,fromPath:join(t,co),toPath:t_,feature:"hooks"});}var $b=d(()=>{A();Dr();s(LV,"mapCopilotHookEvent");s(OV,"extractMatcher");s(vb,"extractWrapperCommand");s(Mb,"importHooks");});async function Gb(t,e,r,n=mo){let o=join(t,n),i=await Jm(o),a={projectRoot:t,destCanonicalSkillsDir:Cb,targetName:ds,normalize:r,results:e};for(let[l,c]of i)await Vm(l,c,a);}var jb=d(()=>{Ql();Dr();s(Gb,"importSkills");});async function Ub(t,e={}){let r=e.scope??"project",n=[],o=await W(ds,t,r);return n.push(...await Y(dd,t,r,{normalize:o})),await Gb(t,n,o,r==="global"?fs:mo),r==="project"&&await Mb(t,n),n}var Bb=d(()=>{gt();Ot();Dr();$b();jb();o_();s(Ub,"importFromCopilot");});function Kb(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var Wb,Hb,zb,Vb,Jb=d(()=>{U();ft();cr();pd();Dr();s(Kb,"pruneUndefined");Wb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=P(e(o)),l=Po(i.globs),c=Kb({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Aa}/${n}`,content:await z(o,c,a)}},"copilotLegacyRuleMapper"),Hb=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}=P(e(o)),l=Po(i.applyTo!==void 0?i.applyTo:i.globs),c=Kb({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Aa}/${n}`,content:await z(o,c,a)}},"copilotNewRuleMapper"),zb=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}=P(r(i)),c=Ob(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:`${ld}/${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"),Vb=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}=P(e(i));return {destPath:i,toPath:`${cd}/${n}`,content:await Yt(i,{...a,name:typeof a.name=="string"?a.name:o},l)}},"copilotAgentMapper");});function Yb(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 Xb=d(()=>{Ct();Dr();s(Yb,"lintRules");});function Zb(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>D(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function Qb(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=>Ds(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(D(".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 qb=d(()=>{wt();s(Zb,"lintCommands");s(Qb,"lintHooks");});function TV(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function xV(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function DV(t,e){let r=t.match(eP);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function NV(t,e){let n=e.match(eP)?.groups?.path;if(!n)return null;let o=join(t,n),i=await _(o);if(i===null)return null;let a=xV(t,o);return a?{assetPath:`${co}/scripts/${a}`,content:i,rewrittenCommand:DV(e,a)}:null}function FV(t,e){return `${co}/scripts/${TV(t)}-${e}.sh`}function tP(t){return t.replace(/[\r\n]+/g," ")}function vV(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${tP(e)}`,`# agentsmesh-command: ${tP(t)}`,"set -eu",t,""].join(`
111
- `)}async function rP(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(!ud(c))continue;let m=FV(i,l),p=c.command,u=await NV(t,c.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=vV(p,c.matcher).replace(`set -eu
114
+ `)}function Kb(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:wa,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=QV(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:`${Aa}/${o}.instructions.md`,content:a});}return r}function Wb(t){return t.commands.map(e=>({path:yd(e.name),content:jb(e)}))}function Hb(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:`${po}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${po}/${r.name}/${a}`,content:i.content});}}return e}function zb(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:`${ba}/${e.name}.agent.md`,content:n}})}function Vb(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=qV(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&Rd(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:`${mo}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var Jb=d(()=>{U();Nr();_d();f_();s(QV,"ruleSlug");s(qV,"mapHookEvent");s(Bb,"renderCopilotGlobalInstructions");s(Kb,"generateRules");s(Wb,"generateCommands");s(Hb,"generateSkills");s(zb,"generateAgents");s(Vb,"generateHooks");});function e1(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function r1(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function Zb(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 Qb(t,e){let r=join(t,mo),o=(await G(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 S=e1(g);if(!(!S||!Array.isArray(h)))for(let C of h){if(!C||typeof C!="object")continue;let R=C,k=typeof R.bash=="string"?R.bash:"";if(!k)continue;let b=join(r,k.replace(/^\.\//,"")),N=await _(b);if(!N)continue;let x=Zb(N);x&&(i[S]||(i[S]=[]),i[S].push({matcher:r1(R.comment),command:x,type:"command"}));}}}let a=join(t,$b),c=(await G(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:Zb(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,p_);await O(dirname(m)),await I(m,stringify(i)),e.push({fromTool:fs,fromPath:join(t,mo),toPath:p_,feature:"hooks"});}var qb=d(()=>{A();Nr();s(e1,"mapCopilotHookEvent");s(r1,"extractMatcher");s(Zb,"extractWrapperCommand");s(Qb,"importHooks");});async function tP(t,e,r,n=po){let o=join(t,n),i=await Qm(o),a={projectRoot:t,destCanonicalSkillsDir:Mb,targetName:fs,normalize:r,results:e};for(let[l,c]of i)await Zm(l,c,a);}var eP=d(()=>{ec();Nr();s(tP,"importSkills");});async function rP(t,e={}){let r=e.scope??"project",n=[],o=await W(fs,t,r);return n.push(...await Y(Sd,t,r,{normalize:o})),await tP(t,n,o,r==="global"?gs:po),r==="project"&&await Qb(t,n),n}var nP=d(()=>{gt();Ot();Nr();qb();eP();g_();s(rP,"importFromCopilot");});function oP(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var sP,iP,aP,lP,cP=d(()=>{U();ft();mr();_d();Nr();s(oP,"pruneUndefined");sP=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=P(e(o)),l=xo(i.globs),c=oP({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Pa}/${n}`,content:await z(o,c,a)}},"copilotLegacyRuleMapper"),iP=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}=P(e(o)),l=xo(i.applyTo!==void 0?i.applyTo:i.globs),c=oP({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Pa}/${n}`,content:await z(o,c,a)}},"copilotNewRuleMapper"),aP=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}=P(r(i)),c=Ub(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:`${gd}/${u}`,content:await St(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"),lP=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}=P(e(i));return {destPath:i,toPath:`${hd}/${n}`,content:await Yt(i,{...a,name:typeof a.name=="string"?a.name:o},l)}},"copilotAgentMapper");});function mP(t,e,r,n){let i=J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(l=>({...l,target:fs})),a=t.rules.filter(l=>!l.root&&l.globs.length===0);return [...i,...a.map(l=>({level:"warning",file:l.source,target:fs,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var pP=d(()=>{Ct();Nr();s(mP,"lintRules");});function uP(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>D(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function dP(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=>Fs(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(D(".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 fP=d(()=>{wt();s(uP,"lintCommands");s(dP,"lintHooks");});function a1(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function l1(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function c1(t,e){let r=t.match(hP);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function m1(t,e){let n=e.match(hP)?.groups?.path;if(!n)return null;let o=join(t,n),i=await _(o);if(i===null)return null;let a=l1(t,o);return a?{assetPath:`${mo}/scripts/${a}`,content:i,rewrittenCommand:c1(e,a)}:null}function p1(t,e){return `${mo}/scripts/${a1(t)}-${e}.sh`}function gP(t){return t.replace(/[\r\n]+/g," ")}function u1(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${gP(e)}`,`# agentsmesh-command: ${gP(t)}`,"set -eu",t,""].join(`
115
+ `)}async function yP(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(!Rd(c))continue;let m=p1(i,l),p=c.command,u=await m1(t,c.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=u1(p,c.matcher).replace(`set -eu
112
116
  `,`set -eu
113
117
  HOOK_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
114
- `);n.push({path:m,content:f}),l++;}}return [...r,...n,...o.values()]}var eP,nP=d(()=>{A();Dr();n_();eP=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(TV,"safePhaseName");s(xV,"toRepoRelative");s(DV,"rewriteWrapperCommand");s(NV,"buildAssetOutput");s(FV,"wrapperPath");s(tP,"safeShellLine");s(vV,"buildWrapper");s(rP,"addHookScriptAssets");});function $V(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var oP,sP=d(()=>{A();Dr();s($V,"computeStatus");oP=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,ba));return [{target:"copilot",path:ba,content:i,currentContent:a??void 0,status:$V(a,i)}]},"generateCopilotGlobalExtras");});var jV,UV,BV,KV,dd,o_=d(()=>{Db();Dr();Bb();Jb();Xb();Et();pd();qb();nP();sP();jV={name:"copilot",primaryRootInstructionPath:La,generateRules:Ab,generateCommands:bb,generateAgents:Tb,generateSkills:Pb,generateHooks:xb,importFrom:Ub},UV={rootInstructionPath:La,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 [`${Oa}/${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 `${Oa}/${t}.instructions.md`},commandPath(t,e){return md(t)},agentPath(t,e){return `${wa}/${t}.agent.md`}}},BV={rootInstructionPath:ci,renderPrimaryRootInstruction:wb,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[ba]}],skillDir:fs,managedOutputs:{dirs:[ql,fs,tc,r_,e_],files:[ci,ba]},rewriteGeneratedPath(t){return t===La?ci:t.startsWith(`${Oa}/`)?ci:t.startsWith(`${li}/`)?t.replace(`${li}/`,`${tc}/`):t.startsWith(`${wa}/`)?t.replace(`${wa}/`,`${ql}/`):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}`,`${e_}/${r}`]}return null},paths:{rulePath(t,e){return ci},commandPath(t,e){return `${tc}/${t}.prompt.md`},agentPath(t,e){return `${ql}/${t}.agent.md`}}},KV={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},dd={id:"copilot",metadata:{displayName:"GitHub Copilot",category:"ide",officialUrl:"https://github.com/features/copilot",shortDescription:"GitHub's AI pair programmer"},generators:jV,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:Yb,lint:{commands:Zb,hooks:Qb},postProcessHookOutputs:s(async(t,e,r)=>rP(t,e,[...r]),"postProcessHookOutputs"),project:UV,globalSupport:{capabilities:KV,detectionPaths:[ci,ba,ql,fs,tc,r_],layout:BV,scopeExtras:oP},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[La],global:[ci]},canonicalDir:Aa,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Sb]},canonicalDir:Aa,extensions:[".instructions.md"],map:Wb},{feature:"rules",mode:"directory",source:{project:[Oa]},canonicalDir:Aa,extensions:[".instructions.md",".md"],map:Hb}],commands:{feature:"commands",mode:"directory",source:{project:[li],global:[tc]},canonicalDir:ld,extensions:[".prompt.md"],map:zb},agents:{feature:"agents",mode:"directory",source:{project:[wa],global:[ql]},canonicalDir:cd,extensions:[".agent.md"],map:Vb}},buildImportPaths:zh,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function fd(t){return {$schema:"https://charm.land/crush.json",...t}}var iP=d(()=>{s(fd,"buildCrushConfigJson");});function aP(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 lP(t){return st(t,ee)}function cP(t){return t.commands.map(e=>({path:`${ee}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function mP(t){return t.agents.map(e=>({path:`${ee}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function pP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=fd({mcp:t.mcp.mcpServers});return [{path:Ue,content:JSON.stringify(e,null,2)}]}function uP(t){if(!t.hooks)return [];let e=WV(t);if(Object.keys(e).length===0)return [];let r=fd({hooks:e});return [{path:Ue,content:JSON.stringify(r,null,2)}]}function dP(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=fd({permissions:o});return [{path:Ue,content:JSON.stringify(i,null,2)}]}function fP(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
115
- `);return [{path:Uo,content:e}]}function WV(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 gP=d(()=>{rt();Wt();ut();Lt();Sl();iP();s(aP,"generateRules");s(lP,"generateSkills");s(cP,"generateCommands");s(mP,"generateAgents");s(pP,"generateMcp");s(uP,"generateHooks");s(dP,"generatePermissions");s(fP,"generateIgnore");s(WV,"buildCrushHooksFromCanonical");});async function yP(t,e={}){let r=e.scope??"project",n=[],o=await W(gr,t,r);return n.push(...await Y(gd,t,r,{normalize:o})),await et(t,r==="global"?Be:ee,gr,n,o),await HV(t,n),n}async function HV(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=zV(i.mcp);if(Object.keys(a).length>0){let c=Mu,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=VV(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 zV(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:Ts(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 VV(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 _P=d(()=>{gt();rt();Ot();A();cr();i_();Sl();s(yP,"importFromCrush");s(HV,"importCrushConfigJson");s(zV,"parseCrushMcpServers");s(VV,"parseCrushHooks");s(JV,"serializeHooksYaml");});function RP(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:gr}))}var IP=d(()=>{Ct();Sl();s(RP,"lintRules");});function SP(t){return t.commands.length===0?[]:[D(".agentsmesh/commands","crush","Crush has no native slash-command format; commands are projected as skills via supportsConversion.")]}var CP=d(()=>{wt();s(SP,"lintCommands");});function a_(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function EP(t,e){let r=a_(t),n=XV.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 LP(t,e){let r=a_(t),n=ZV.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 OP(t,e){let r=a_(t),n=YV.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 kP,YV,XV,ZV,hd=d(()=>{kP=[".claude/settings.json",".gemini/settings.json"],YV=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(),XV=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(),ZV=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(a_,"parseJsonObject");s(EP,"mergeSettingsJson");s(LP,"mergeGeminiSettingsJson");s(OP,"mergeCrushConfigJson");});var QV,qV,t1,e1,r1,gd,i_=d(()=>{Lt();ut();gP();oe();_P();IP();CP();Et();hd();Sl();QV={name:gr,primaryRootInstructionPath:hr,generateRules:aP,generateCommands:cP,generateAgents:mP,generateSkills:lP,generateMcp:pP,generateHooks:uP,generatePermissions:dP,generateIgnore:fP,importFrom:yP},qV={rootInstructionPath:hr,skillDir:ee,managedOutputs:{dirs:[ee],files:[hr,Ue,Uo]},paths:{rulePath(t){return hr},commandPath(t){return `${ee}/${V(t)}/SKILL.md`},agentPath(t){return `${ee}/${K(t)}/SKILL.md`}}},t1={rootInstructionPath:Vi,skillDir:Be,managedOutputs:{dirs:[Be],files:[Vi,Nu]},rewriteGeneratedPath(t){return t===hr?Vi:t===Ue?Nu:t===Uo?null:t.startsWith(`${ee}/`)?t.replace(`${ee}/`,`${Be}/`):t},mirrorGlobalPath(t,e){return dt(t,Be,e)},paths:{rulePath(t){return Vi},commandPath(t){return `${Be}/${V(t)}/SKILL.md`},agentPath(t){return `${Be}/${K(t)}/SKILL.md`}}},e1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},r1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"none",permissions:"none"},gd={id:gr,metadata:{displayName:"Crush",category:"cli",officialUrl:"https://github.com/charmbracelet/crush",shortDescription:"Charm's TUI coding agent"},generators:QV,capabilities:e1,emptyImportMessage:"No Crush config found (CRUSH.md, .crush/skills/, crush.json, or .crushignore).",lintRules:RP,lint:{commands:SP},supportsConversion:{commands:true,agents:true},project:qV,globalSupport:{capabilities:r1,detectionPaths:[Vi,Nu,Be],layout:t1},mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Ue?OP(o,r):null},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[hr],global:[Vi]},canonicalDir:Fu,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Uo]},canonicalDir:".agentsmesh",canonicalFilename:vu}},buildImportPaths:Vh,detectionPaths:[hr,Ue,ee,Uo],sharedArtifacts:{".crush/skills/":"owner"}};});function l_(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:Gs,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let l=x(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=x(c,i.body.trim()||"");e.push({path:`${yr}/${a}.mdc`,content:m});}let o=wP(t);return o.trim()&&e.push({path:qr,content:o}),e}function wP(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(`
118
+ `);n.push({path:m,content:f}),l++;}}return [...r,...n,...o.values()]}var hP,_P=d(()=>{A();Nr();f_();hP=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(a1,"safePhaseName");s(l1,"toRepoRelative");s(c1,"rewriteWrapperCommand");s(m1,"buildAssetOutput");s(p1,"wrapperPath");s(gP,"safeShellLine");s(u1,"buildWrapper");s(yP,"addHookScriptAssets");});function f1(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var RP,SP=d(()=>{A();Nr();s(f1,"computeStatus");RP=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,xa));return [{target:"copilot",path:xa,content:i,currentContent:a??void 0,status:f1(a,i)}]},"generateCopilotGlobalExtras");});var h1,y1,_1,R1,Sd,g_=d(()=>{Jb();Nr();nP();cP();pP();Et();_d();fP();_P();SP();h1={name:"copilot",primaryRootInstructionPath:wa,generateRules:Kb,generateCommands:Wb,generateAgents:zb,generateSkills:Hb,generateHooks:Vb,importFrom:rP},y1={rootInstructionPath:wa,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 [`${Aa}/${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 `${Aa}/${t}.instructions.md`},commandPath(t,e){return yd(t)},agentPath(t,e){return `${ba}/${t}.agent.md`}}},_1={rootInstructionPath:pi,renderPrimaryRootInstruction:Bb,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[xa]}],skillDir:gs,managedOutputs:{dirs:[rc,gs,nc,d_,u_],files:[pi,xa]},rewriteGeneratedPath(t){return t===wa?pi:t.startsWith(`${Aa}/`)?pi:t.startsWith(`${mi}/`)?t.replace(`${mi}/`,`${nc}/`):t.startsWith(`${ba}/`)?t.replace(`${ba}/`,`${rc}/`):t.startsWith(`${po}/`)?t.replace(`${po}/`,`${gs}/`):t.startsWith(`${mo}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${gs}/`)&&!e.includes("codex-cli")){let r=t.slice(gs.length+1);return [`.agents/skills/${r}`,`${u_}/${r}`]}return null},paths:{rulePath(t,e){return pi},commandPath(t,e){return `${nc}/${t}.prompt.md`},agentPath(t,e){return `${rc}/${t}.agent.md`}}},R1={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Sd={id:"copilot",metadata:{displayName:"GitHub Copilot",category:"ide",officialUrl:"https://github.com/features/copilot",shortDescription:"GitHub's AI pair programmer"},generators:h1,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:mP,lint:{commands:uP,hooks:dP},postProcessHookOutputs:s(async(t,e,r)=>yP(t,e,[...r]),"postProcessHookOutputs"),project:y1,globalSupport:{capabilities:R1,detectionPaths:[pi,xa,rc,gs,nc,d_],layout:_1,scopeExtras:RP},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[wa],global:[pi]},canonicalDir:Pa,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[vb]},canonicalDir:Pa,extensions:[".instructions.md"],map:sP},{feature:"rules",mode:"directory",source:{project:[Aa]},canonicalDir:Pa,extensions:[".instructions.md",".md"],map:iP}],commands:{feature:"commands",mode:"directory",source:{project:[mi],global:[nc]},canonicalDir:gd,extensions:[".prompt.md"],map:aP},agents:{feature:"agents",mode:"directory",source:{project:[ba],global:[rc]},canonicalDir:hd,extensions:[".agent.md"],map:lP}},buildImportPaths:ny,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function Id(t){return {$schema:"https://charm.land/crush.json",...t}}var IP=d(()=>{s(Id,"buildCrushConfigJson");});function CP(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=at(n,r);return o?[{path:yr,content:o}]:[]}function kP(t){return st(t,ee)}function EP(t){return t.commands.map(e=>({path:`${ee}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function LP(t){return t.agents.map(e=>({path:`${ee}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function OP(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Id({mcp:t.mcp.mcpServers});return [{path:Be,content:JSON.stringify(e,null,2)}]}function wP(t){if(!t.hooks)return [];let e=S1(t);if(Object.keys(e).length===0)return [];let r=Id({hooks:e});return [{path:Be,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=Id({permissions:o});return [{path:Be,content:JSON.stringify(i,null,2)}]}function bP(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
119
+ `);return [{path:Bo,content:e}]}function S1(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 PP=d(()=>{rt();Kt();ut();Lt();El();IP();s(CP,"generateRules");s(kP,"generateSkills");s(EP,"generateCommands");s(LP,"generateAgents");s(OP,"generateMcp");s(wP,"generateHooks");s(AP,"generatePermissions");s(bP,"generateIgnore");s(S1,"buildCrushHooksFromCanonical");});async function TP(t,e={}){let r=e.scope??"project",n=[],o=await W(hr,t,r);return n.push(...await Y(Cd,t,r,{normalize:o})),await et(t,r==="global"?Ke:ee,hr,n,o),await I1(t,n),n}async function I1(t,e){let r=join(t,Be),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=C1(i.mcp);if(Object.keys(a).length>0){let c=Wu,m=join(t,c);await O(dirname(m)),await I(m,JSON.stringify({mcpServers:a},null,2)),e.push({fromTool:hr,fromPath:r,toPath:c,feature:"mcp"});}let l=k1(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=E1(l);await I(m,p),e.push({fromTool:hr,fromPath:r,toPath:c,feature:"hooks"});}}function C1(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:Ds(o.args),env:bn(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:bn(o.headers),env:bn(o.env),...i!==void 0?{description:i}:{}});}return e}function k1(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 E1(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(`
120
+ `)}var DP=d(()=>{gt();rt();Ot();A();mr();y_();El();s(TP,"importFromCrush");s(I1,"importCrushConfigJson");s(C1,"parseCrushMcpServers");s(k1,"parseCrushHooks");s(E1,"serializeHooksYaml");});function NP(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:hr}))}var FP=d(()=>{Ct();El();s(NP,"lintRules");});function vP(t){return t.commands.length===0?[]:[D(".agentsmesh/commands","crush","Crush has no native slash-command format; commands are projected as skills via supportsConversion.")]}var MP=d(()=>{wt();s(vP,"lintCommands");});function __(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function GP(t,e){let r=__(t),n=O1.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 jP(t,e){let r=__(t),n=w1.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 UP(t,e){let r=__(t),n=L1.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 $P,L1,O1,w1,kd=d(()=>{$P=[".claude/settings.json",".gemini/settings.json"],L1=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(),O1=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(),w1=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(__,"parseJsonObject");s(GP,"mergeSettingsJson");s(jP,"mergeGeminiSettingsJson");s(UP,"mergeCrushConfigJson");});var A1,b1,P1,x1,T1,Cd,y_=d(()=>{Lt();ut();PP();oe();DP();FP();MP();Et();kd();El();A1={name:hr,primaryRootInstructionPath:yr,generateRules:CP,generateCommands:EP,generateAgents:LP,generateSkills:kP,generateMcp:OP,generateHooks:wP,generatePermissions:AP,generateIgnore:bP,importFrom:TP},b1={rootInstructionPath:yr,skillDir:ee,managedOutputs:{dirs:[ee],files:[yr,Be,Bo]},paths:{rulePath(t){return yr},commandPath(t){return `${ee}/${V(t)}/SKILL.md`},agentPath(t){return `${ee}/${K(t)}/SKILL.md`}}},P1={rootInstructionPath:Yi,skillDir:Ke,managedOutputs:{dirs:[Ke],files:[Yi,Uu]},rewriteGeneratedPath(t){return t===yr?Yi:t===Be?Uu:t===Bo?null:t.startsWith(`${ee}/`)?t.replace(`${ee}/`,`${Ke}/`):t},mirrorGlobalPath(t,e){return dt(t,Ke,e)},paths:{rulePath(t){return Yi},commandPath(t){return `${Ke}/${V(t)}/SKILL.md`},agentPath(t){return `${Ke}/${K(t)}/SKILL.md`}}},x1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},T1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"none",permissions:"none"},Cd={id:hr,metadata:{displayName:"Crush",category:"cli",officialUrl:"https://github.com/charmbracelet/crush",shortDescription:"Charm's TUI coding agent"},generators:A1,capabilities:x1,emptyImportMessage:"No Crush config found (CRUSH.md, .crush/skills/, crush.json, or .crushignore).",lintRules:NP,lint:{commands:vP},supportsConversion:{commands:true,agents:true},project:b1,globalSupport:{capabilities:T1,detectionPaths:[Yi,Uu,Ke],layout:P1},mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Be?UP(o,r):null},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[yr],global:[Yi]},canonicalDir:Bu,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Bo]},canonicalDir:".agentsmesh",canonicalFilename:Ku}},buildImportPaths:oy,detectionPaths:[yr,Be,ee,Bo],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:Us,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let l=T(a,i);e.push({path:Ko,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:`${_r}/${a}.mdc`,content:m});}let o=BP(t);return o.trim()&&e.push({path:tn,content:o}),e}function BP(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(at(e.body,r)):r.length>0&&n.push(at("",r)),n.filter(Boolean).join(`
117
121
 
118
- `)}var AP=d(()=>{U();Wt();zt();s(l_,"generateRules");s(wP,"renderCursorGlobalUserRules");});function c_(t){return t.commands.map(e=>({path:`${_r}/${e.name}.md`,content:e.body.trim()||""}))}var bP=d(()=>{zt();s(c_,"generateCommands");});function m_(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 PP=d(()=>{zt();s(m_,"generateMcp");});function p_(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=x(n,r.body.trim()||"");e.push({path:`${fe}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${fe}/${r.name}/${a}`,content:i.content});}}return e}var TP=d(()=>{U();zt();s(p_,"generateSkills");});function u_(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=x(r,e.body.trim()||"");return {path:`${Rr}/${e.name}.md`,content:n}})}var xP=d(()=>{U();zt();s(u_,"generateAgents");});function d_(t){return []}var DP=d(()=>{s(d_,"generatePermissions");});function o1(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=Jt(i),l=Re(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 f_(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=o1(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 NP=d(()=>{Ur();zt();s(o1,"toCursorHooks");s(f_,"generateHooks");});function g_(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
119
- `);return [{path:Qr,content:e}]}var FP=d(()=>{zt();s(g_,"generateIgnore");});var vP=d(()=>{AP();bP();PP();TP();xP();DP();NP();FP();});var MP=d(()=>{vP();});async function _d(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),l=P(r(i)).frontmatter.alwaysApply===true,c=l?join(e,"_root.md"):i,{frontmatter:m,body:p}=P(r(c));l&&n();let u={...m,root:l};if(delete u.alwaysApply,!l){let f=s1(m);f!==null&&(u.trigger=f);}return {destPath:c,toPath:`${Gn}/${l?"_root.md":o}`,feature:"rules",content:await z(c,u,p)}}function s1(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 $P(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=P(r(n)),a=lr(o.allowedTools),l=a.length>0?a:lr(o["allowed-tools"]);return {destPath:n,toPath:`${js}/${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 GP(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=P(r(n));return {destPath:n,toPath:`${Us}/${t}`,feature:"agents",content:await Yt(n,o,i)}}var h_=d(()=>{U();ft();cr();zt();s(_d,"mapCursorRuleFile");s(s1,"deriveCursorTrigger");s($P,"mapCursorCommandFile");s(GP,"mapCursorAgentFile");});async function ec(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}=P(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 y_=d(()=>{A();U();Jl();ft();zt();s(ec,"importCursorRootFile");});async function UP(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}=P(m);if(p.alwaysApply===true)return null}}return _d(l,n,c,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,Gs),l=await _(a);l!==null&&(o=await ec({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r}));}if(!o){let a=join(t,ME),l=await _(a);l!==null&&await ec({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r});}}var BP=d(()=>{A();U();Me();h_();y_();zt();s(UP,"importCursorRules");});function KP(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"?Re(m)||Jt(m):Jt(m)||Re(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,$n),o=await _(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=KP(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,Em);await O(dirname(g)),await S(g,f),e.push({fromTool:"cursor",fromPath:n,toPath:Em,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,$u),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,Yh);await O(dirname(h)),await S(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:Yh,feature:"permissions"});}}let m=r?void 0:l.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=KP(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,Em);await O(dirname(f)),await S(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:Em,feature:"hooks"});}}}async function Cd(t,e){let r=[{path:join(t,Qr),label:Qr},{path:join(t,Jh),label:Jh}],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,Xh);await O(dirname(i)),await S(i,n.join(`
122
+ `)}var KP=d(()=>{U();Kt();zt();s(R_,"generateRules");s(BP,"renderCursorGlobalUserRules");});function S_(t){return t.commands.map(e=>({path:`${Rr}/${e.name}.md`,content:e.body.trim()||""}))}var WP=d(()=>{zt();s(S_,"generateCommands");});function I_(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:We,content:e}]}var HP=d(()=>{zt();s(I_,"generateMcp");});function C_(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:`${fe}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${fe}/${r.name}/${a}`,content:i.content});}}return e}var zP=d(()=>{U();zt();s(C_,"generateSkills");});function k_(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:`${Sr}/${e.name}.md`,content:n}})}var VP=d(()=>{U();zt();s(k_,"generateAgents");});function E_(t){return []}var JP=d(()=>{s(E_,"generatePermissions");});function N1(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Ln(i))continue;let a=Jt(i),l=Re(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=N1(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:jn,content:r}]}var YP=d(()=>{Br();zt();s(N1,"toCursorHooks");s(L_,"generateHooks");});function O_(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
123
+ `);return [{path:qr,content:e}]}var XP=d(()=>{zt();s(O_,"generateIgnore");});var ZP=d(()=>{KP();WP();HP();zP();VP();JP();YP();XP();});var QP=d(()=>{ZP();});async function Ld(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),l=P(r(i)).frontmatter.alwaysApply===true,c=l?join(e,"_root.md"):i,{frontmatter:m,body:p}=P(r(c));l&&n();let u={...m,root:l};if(delete u.alwaysApply,!l){let f=F1(m);f!==null&&(u.trigger=f);}return {destPath:c,toPath:`${Un}/${l?"_root.md":o}`,feature:"rules",content:await z(c,u,p)}}function F1(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 qP(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=P(r(n)),a=cr(o.allowedTools),l=a.length>0?a:cr(o["allowed-tools"]);return {destPath:n,toPath:`${Bs}/${t}`,feature:"commands",content:await St(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 tx(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=P(r(n));return {destPath:n,toPath:`${Ks}/${t}`,feature:"agents",content:await Yt(n,o,i)}}var w_=d(()=>{U();ft();mr();zt();s(Ld,"mapCursorRuleFile");s(F1,"deriveCursorTrigger");s(qP,"mapCursorCommandFile");s(tx,"mapCursorAgentFile");});async function oc(t){let e=join(t.projectRoot,Un);await O(e);let r=join(e,"_root.md"),n=await ao({content:t.content,projectRoot:t.projectRoot,rulesDir:Un,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}=P(o),l=i.root===true?i:{...i,root:true},c=await z(r,l,a);return await I(r,c),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${Un}/_root.md`,feature:"rules"}),true}var A_=d(()=>{A();U();Zl();ft();zt();s(oc,"importCursorRootFile");});async function rx(t,e,r){let n=join(t,Un),o=false,i=join(t,_r);if(e.push(...await It({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}=P(m);if(p.alwaysApply===true)return null}}return Ld(l,n,c,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,Us),l=await _(a);l!==null&&(o=await oc({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r}));}if(!o){let a=join(t,QE),l=await _(a);l!==null&&await oc({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r});}}var nx=d(()=>{A();U();$e();w_();A_();zt();s(rx,"importCursorRules");});function ox(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(!Ln({...m,type:p}))continue;let u=p==="prompt"?Re(m)||Jt(m):Jt(m)||Re(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 Ad(t,e){let r=false,n=join(t,jn),o=await _(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=ox(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,Am);await O(dirname(g)),await I(g,f),e.push({fromTool:"cursor",fromPath:n,toPath:Am,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,Hu),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,iy);await O(dirname(h)),await I(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:iy,feature:"permissions"});}}let m=r?void 0:l.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=ox(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,Am);await O(dirname(f)),await I(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:Am,feature:"hooks"});}}}async function bd(t,e){let r=[{path:join(t,qr),label:qr},{path:join(t,sy),label:sy}],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,ay);await O(dirname(i)),await I(i,n.join(`
120
124
  `)+`
121
- `),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:Xh,feature:"ignore"});}var R_=d(()=>{Ur();A();zt();s(KP,"cursorHooksToCanonical");s(Sd,"importSettings");s(Cd,"importIgnore");});async function kd(t,e,r,n=fe){let o=join(t,n),i=await Jm(o),a={projectRoot:t,destCanonicalSkillsDir:$E,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Vm(p,u,a);let l=await G(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 Ww(f,p,u,a);}}var I_=d(()=>{A();Ql();zt();s(kd,"importSkills");});async function WP(t){if(await j(join(t,yr)))return true;let e=[join(t,qr),join(t,Cl),join(t,Ke),join(t,$n),join(t,Qr),join(t,fe),join(t,Rr),join(t,_r)];for(let i of e){let a=await _(i);if(a!==null&&a.trim()!=="")return true}return !!((await G(join(t,fe))).some(i=>i.endsWith(".md"))||(await G(join(t,Rr))).some(i=>i.endsWith(".md"))||(await G(join(t,_r))).some(i=>i.endsWith(".md")))}async function HP(t,e,r){let n=join(t,Gn),o=false,i=join(t,yr),a=await St({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:rc,normalize:r,mapEntry:s(async({srcPath:l,relativePath:c,normalizeTo:m})=>{if(o){let p=await _(l);if(p!==null){let{frontmatter:u}=P(p);if(u.alwaysApply===true)return null}}return _d(c,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function zP(t,e,r){let n=join(t,Cl),o=await _(n);return o===null||o.trim()===""?false:ec({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function VP(t,e,r){let n=join(t,qr),o=await _(n);return o===null||o.trim()===""?false:ec({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function JP(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,kl);await O(dirname(i)),await S(i,n),e.push({fromTool:rc,fromPath:r,toPath:kl,feature:"mcp"});}async function YP(t,e,r){let n=join(t,Rr),o=join(t,Us);e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:rc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>GP(i,o,a),"mapEntry")}));}async function XP(t,e,r){let n=join(t,_r),o=join(t,js);e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:rc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>$P(i,o,a),"mapEntry")}));}var rc,ZP=d(()=>{A();U();Me();zt();y_();h_();rc="cursor";s(WP,"hasGlobalCursorArtifacts");s(HP,"importGlobalCursorRulesFromDir");s(zP,"importGlobalUserRules");s(VP,"importGlobalDotCursorAgents");s(JP,"importGlobalMcp");s(YP,"importGlobalAgents");s(XP,"importGlobalCommands");});async function QP(t){if(!await WP(t))return [];let e=[],r=await W(rc,t,"global"),n=await HP(t,e,r);return n||(n=await zP(t,e,r)),n||await VP(t,e,r),await JP(t,e),await kd(t,e,r,fe),await YP(t,e,r),await XP(t,e,r),await Sd(t,e),await Cd(t,e),e}var qP=d(()=>{gt();zt();I_();R_();ZP();s(QP,"importFromCursorGlobalExports");});async function m1(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 Ht(t,kl,i),e.push({fromTool:"cursor",fromPath:r,toPath:kl,feature:"mcp"});}async function tT(t,e={}){if(e.scope==="global")return QP(t);let r=[],n=await W("cursor",t);return await UP(t,r,n),r.push(...await Y(Ed,t,"project",{normalize:n})),await kd(t,r,n),await m1(t,r),await Sd(t,r),await Cd(t,r),r}var eT=d(()=>{gt();A();Ot();Vr();BP();R_();I_();qP();zt();S_();s(m1,"importMcp");s(tT,"importFromCursor");});var nT,oT,sT=d(()=>{U();ft();cr();zt();nT=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n)),a=lr(o.allowedTools),l=a.length>0?a:lr(o["allowed-tools"]);return {destPath:n,toPath:`${js}/${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"),oT=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Us}/${t}`,content:await Yt(n,o,i)}},"cursorAgentMapper");});function iT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:vE}))}var aT=d(()=>{Ct();zt();s(iT,"lintRules");});function lT(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>D(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function cT(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(D(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function mT(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?[D(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var pT=d(()=>{wt();s(lT,"lintCommands");s(cT,"lintMcp");s(mT,"lintPermissions");});var p1,u1,d1,f1,Ed,S_=d(()=>{MP();zt();oe();eT();sT();aT();Et();pT();p1={name:"cursor",primaryRootInstructionPath:Bo,generateRules:l_,generateCommands:c_,generateAgents:u_,generateSkills:p_,generateMcp:m_,generatePermissions:d_,generateHooks:f_,generateIgnore:g_,importFrom:tT},u1={rootInstructionPath:Bo,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Gs,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`}}},d1={rootInstructionPath:Bo,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Gs,qr]}],skillDir:fe,managedOutputs:{dirs:[yr,_r,Rr,fe],files:[Bo,qr,Ke,$n,Qr,Cl]},rewriteGeneratedPath(t){return t===Gs?null:t===qr||t===Bo||t.startsWith(`${yr}/`)||t.startsWith(`${_r}/`)||t.startsWith(`${Rr}/`)||t.startsWith(`${fe}/`)||t===Ke||t===$n||t===Qr?t:t===$u?null:t},mirrorGlobalPath(t,e){return dt(t,fe,e)},paths:{rulePath(t,e){return `${yr}/${t}.mdc`},commandPath(t,e){return `${_r}/${t}.md`},agentPath(t,e){return `${Rr}/${t}.md`}}},f1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Ed={id:"cursor",metadata:{displayName:"Cursor",category:"ide",officialUrl:"https://cursor.com",shortDescription:"AI-first code editor"},generators:p1,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:iT,lint:{commands:lT,mcp:cT,permissions:mT},project:u1,globalSupport:{capabilities:f1,detectionPaths:[Bo,qr,Ke,$n,Qr,fe,Rr,_r,Cl],layout:d1},importer:{commands:{feature:"commands",mode:"directory",source:{project:[_r]},canonicalDir:js,extensions:[".md"],map:nT},agents:{feature:"agents",mode:"directory",source:{project:[Rr]},canonicalDir:Us,extensions:[".md"],map:oT}},buildImportPaths:Zh,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});function uT(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 dT(t){return st(t,ge)}function fT(t){return t.commands.map(e=>({path:`${ge}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function gT(t){return t.agents.map(e=>({path:`${ge}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function hT(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 yT=d(()=>{rt();Wt();ut();Lt();El();s(uT,"generateRules");s(dT,"generateSkills");s(fT,"generateCommands");s(gT,"generateAgents");s(hT,"generateMcp");});async function _T(t,e={}){let r=e.scope??"project",n=[],o=await W(jn,t,r);return n.push(...await Y(Ld,t,r,{normalize:o})),await et(t,r==="global"?tn:ge,jn,n,o),n}var RT=d(()=>{gt();rt();Ot();El();C_();s(_T,"importFromDeepagentsCli");});function IT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:jn}))}var ST=d(()=>{Ct();El();s(IT,"lintRules");});function CT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","deepagents-cli","Deep Agents CLI hooks are global-only (~/.deepagents/hooks.json); project-level canonical hooks are not projected.")]:[]:[]}function kT(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?[]:[D(".agentsmesh/permissions.yaml","deepagents-cli","Deep Agents CLI permissions are managed via shell allow-lists (--shell-allow-list); canonical permissions are not projected.")]}function ET(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","deepagents-cli","Deep Agents CLI has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var LT=d(()=>{wt();s(CT,"lintHooks");s(kT,"lintPermissions");s(ET,"lintIgnore");});var g1,h1,y1,_1,R1,Ld,C_=d(()=>{Lt();ut();yT();RT();ST();LT();Et();El();g1={name:jn,primaryRootInstructionPath:Ir,generateRules:uT,generateCommands:fT,generateAgents:gT,generateSkills:dT,generateMcp:hT,importFrom:_T},h1={rootInstructionPath:Ir,skillDir:ge,managedOutputs:{dirs:[ge],files:[Ir,Ko]},paths:{rulePath(t){return Ir},commandPath(t){return `${ge}/${V(t)}/SKILL.md`},agentPath(t){return `${ge}/${K(t)}/SKILL.md`}}},y1={rootInstructionPath:Wo,skillDir:tn,managedOutputs:{dirs:[tn],files:[Wo,Ji]},rewriteGeneratedPath(t){return t===Ir?Wo:t===Ko?Ji:t.startsWith(`${ge}/`)?t.replace(`${ge}/`,`${tn}/`):t},paths:{rulePath(t){return Wo},commandPath(t){return `${tn}/${V(t)}/SKILL.md`},agentPath(t){return `${tn}/${K(t)}/SKILL.md`}}},_1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},R1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Ld={id:jn,metadata:{displayName:"Deep Agents CLI",category:"cli",officialUrl:"https://github.com/langchain-ai/deepagents",shortDescription:"LangChain Deep Agents framework CLI"},generators:g1,capabilities:_1,emptyImportMessage:"No Deep Agents CLI config found (.deepagents/AGENTS.md, .deepagents/skills, or .mcp.json).",lintRules:IT,lint:{hooks:CT,permissions:kT,ignore:ET},supportsConversion:{commands:true,agents:true},project:h1,globalSupport:{capabilities:R1,detectionPaths:[Wo,Ji],layout:y1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ir],global:[Wo]},canonicalDir:jE,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ko],global:[Ji]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Qh,detectionPaths:[Ir,Ko]};});function OT(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),x(e,t.body.trim()||"")}var wT=d(()=>{U();s(OT,"serializeDroid");});function AT(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 bT(t){return st(t,Ae)}function PT(t){return t.commands.map(e=>({path:`${Ae}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function TT(t){return t.agents.map(e=>({path:`${Un}/${e.name}.md`,content:OT(e)}))}function xT(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Bn,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var DT=d(()=>{rt();Wt();Lt();wT();Xi();s(AT,"generateRules");s(bT,"generateSkills");s(PT,"generateCommands");s(TT,"generateAgents");s(xT,"generateMcp");});async function FT(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 Ht(t,NT,l),r.push({fromTool:Sr,fromPath:e,toPath:NT,feature:"mcp"}));}var NT,vT=d(()=>{A();Vr();Xi();NT=".agentsmesh/mcp.json";s(FT,"importFactoryDroidMcp");});async function MT(t,e={}){let r=e.scope??"project",n=[],o=await W(Sr,t,r);return n.push(...await Y(Od,t,r,{normalize:o})),await et(t,r==="global"?Kn:Ae,Sr,n,o),await FT(t,r==="global"?Bs:Bn,n),n}var $T=d(()=>{gt();rt();Ot();vT();Xi();k_();s(MT,"importFromFactoryDroid");});function GT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Sr}))}var jT=d(()=>{Ct();Xi();s(GT,"lintRules");});function UT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".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?[]:[D(".agentsmesh/permissions.yaml","factory-droid","Factory Droid permissions are managed via CLI flags (--skip-permissions-unsafe); canonical permissions are not projected.")]}function KT(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","factory-droid","Factory Droid has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var WT=d(()=>{wt();s(UT,"lintHooks");s(BT,"lintPermissions");s(KT,"lintIgnore");});var S1,C1,k1,HT,Od,k_=d(()=>{DT();Xi();$T();jT();WT();Et();Lt();S1={name:Sr,primaryRootInstructionPath:Cr,generateRules:AT,generateCommands:PT,generateAgents:TT,generateSkills:bT,generateMcp:xT,importFrom:MT},C1={rootInstructionPath:Cr,skillDir:Ae,managedOutputs:{dirs:[Ae,Un],files:[Cr,Bn]},paths:{rulePath(t){return Cr},commandPath(t){return `${Ae}/${V(t)}/SKILL.md`},agentPath(t){return `${Un}/${t}.md`}}},k1={rootInstructionPath:Ho,skillDir:Kn,managedOutputs:{dirs:[Kn,Yi],files:[Ho,Bs]},rewriteGeneratedPath(t){return t===Cr?Ho:t===Bn?Bs:t.startsWith(`${Ae}/`)?t.replace(`${Ae}/`,`${Kn}/`):t.startsWith(`${Un}/`)?t.replace(`${Un}/`,`${Yi}/`):t},paths:{rulePath(t){return Ho},commandPath(t){return `${Kn}/${V(t)}/SKILL.md`},agentPath(t){return `${Yi}/${t}.md`}}},HT={rules:"native",additionalRules:"embedded",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Od={id:Sr,metadata:{displayName:"Factory Droid",category:"agent-platform",officialUrl:"https://www.factory.ai",shortDescription:"Factory.ai's coding droid"},generators:S1,capabilities:HT,emptyImportMessage:"No Factory Droid config found (AGENTS.md, .factory/skills, or .factory/mcp.json).",lintRules:GT,lint:{hooks:UT,permissions:BT,ignore:KT},supportsConversion:{commands:true},project:C1,globalSupport:{capabilities:HT,detectionPaths:[Ho,Bs,Yi],layout:k1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Cr],global:[Ho]},canonicalDir:BE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:qh,detectionPaths:[Cr,Bn,Un]};});var mi,Nr,po,zT,VT,Xe,wd,Pa,Ad,tp,pi,JT,YT,ui,bd,ep,rp,E_,L_,nc,O_,oc,sc,Pd,ic,Ta,np,Xt=d(()=>{mi="gemini-cli",Nr="GEMINI.md",po="AGENTS.md",zT=".gemini/rules",VT=".gemini/GEMINI.md",Xe=".gemini/commands",wd=".gemini/policies",Pa=".gemini/settings.json",Ad=".geminiignore",tp=".gemini/skills",pi=".gemini/agents",JT=".gemini/system.md",YT=`${wd}/permissions.toml`,ui=".agentsmesh/rules",bd=".agentsmesh/commands",ep=".agentsmesh/agents",rp=".agentsmesh/skills",E_=".agentsmesh/mcp.json",L_=".agentsmesh/hooks.yaml",nc=".agentsmesh/ignore",O_=".agentsmesh/permissions.yaml",oc=".gemini/GEMINI.md",sc=".gemini/AGENTS.md",Pd=".gemini/settings.json",ic=".gemini/commands",Ta=".gemini/skills",np=".gemini/agents";});function w_(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 XT=d(()=>{Wt();Xt();s(w_,"generateRules");});function ZT(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var QT=d(()=>{s(ZT,"canonicalCommandNameToGeminiTomlPath");});function E1(t){let e=t.replace(/\r\n/g,`
125
+ `),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:ay,feature:"ignore"});}var P_=d(()=>{Br();A();zt();s(ox,"cursorHooksToCanonical");s(Ad,"importSettings");s(bd,"importIgnore");});async function Pd(t,e,r,n=fe){let o=join(t,n),i=await Qm(o),a={projectRoot:t,destCanonicalSkillsDir:qE,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Zm(p,u,a);let l=await G(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 sA(f,p,u,a);}}var x_=d(()=>{A();ec();zt();s(Pd,"importSkills");});async function sx(t){if(await j(join(t,_r)))return true;let e=[join(t,tn),join(t,Ll),join(t,We),join(t,jn),join(t,qr),join(t,fe),join(t,Sr),join(t,Rr)];for(let i of e){let a=await _(i);if(a!==null&&a.trim()!=="")return true}return !!((await G(join(t,fe))).some(i=>i.endsWith(".md"))||(await G(join(t,Sr))).some(i=>i.endsWith(".md"))||(await G(join(t,Rr))).some(i=>i.endsWith(".md")))}async function ix(t,e,r){let n=join(t,Un),o=false,i=join(t,_r),a=await It({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:sc,normalize:r,mapEntry:s(async({srcPath:l,relativePath:c,normalizeTo:m})=>{if(o){let p=await _(l);if(p!==null){let{frontmatter:u}=P(p);if(u.alwaysApply===true)return null}}return Ld(c,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function ax(t,e,r){let n=join(t,Ll),o=await _(n);return o===null||o.trim()===""?false:oc({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function lx(t,e,r){let n=join(t,tn),o=await _(n);return o===null||o.trim()===""?false:oc({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function cx(t,e){let r=join(t,We),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,Ol);await O(dirname(i)),await I(i,n),e.push({fromTool:sc,fromPath:r,toPath:Ol,feature:"mcp"});}async function mx(t,e,r){let n=join(t,Sr),o=join(t,Ks);e.push(...await It({srcDir:n,destDir:o,extensions:[".md"],fromTool:sc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>tx(i,o,a),"mapEntry")}));}async function px(t,e,r){let n=join(t,Rr),o=join(t,Bs);e.push(...await It({srcDir:n,destDir:o,extensions:[".md"],fromTool:sc,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>qP(i,o,a),"mapEntry")}));}var sc,ux=d(()=>{A();U();$e();zt();A_();w_();sc="cursor";s(sx,"hasGlobalCursorArtifacts");s(ix,"importGlobalCursorRulesFromDir");s(ax,"importGlobalUserRules");s(lx,"importGlobalDotCursorAgents");s(cx,"importGlobalMcp");s(mx,"importGlobalAgents");s(px,"importGlobalCommands");});async function dx(t){if(!await sx(t))return [];let e=[],r=await W(sc,t,"global"),n=await ix(t,e,r);return n||(n=await ax(t,e,r)),n||await lx(t,e,r),await cx(t,e),await Pd(t,e,r,fe),await mx(t,e,r),await px(t,e,r),await Ad(t,e),await bd(t,e),e}var fx=d(()=>{gt();zt();x_();P_();ux();s(dx,"importFromCursorGlobalExports");});async function j1(t,e){let r=join(t,We),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 Ht(t,Ol,i),e.push({fromTool:"cursor",fromPath:r,toPath:Ol,feature:"mcp"});}async function gx(t,e={}){if(e.scope==="global")return dx(t);let r=[],n=await W("cursor",t);return await rx(t,r,n),r.push(...await Y(xd,t,"project",{normalize:n})),await Pd(t,r,n),await j1(t,r),await Ad(t,r),await bd(t,r),r}var hx=d(()=>{gt();A();Ot();Jr();nx();P_();x_();fx();zt();T_();s(j1,"importMcp");s(gx,"importFromCursor");});var _x,Rx,Sx=d(()=>{U();ft();mr();zt();_x=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n)),a=cr(o.allowedTools),l=a.length>0?a:cr(o["allowed-tools"]);return {destPath:n,toPath:`${Bs}/${t}`,content:await St(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"),Rx=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Ks}/${t}`,content:await Yt(n,o,i)}},"cursorAgentMapper");});function Ix(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:ZE}))}var Cx=d(()=>{Ct();zt();s(Ix,"lintRules");});function kx(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>D(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function Ex(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(D(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function Lx(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?[D(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var Ox=d(()=>{wt();s(kx,"lintCommands");s(Ex,"lintMcp");s(Lx,"lintPermissions");});var U1,B1,K1,W1,xd,T_=d(()=>{QP();zt();oe();hx();Sx();Cx();Et();Ox();U1={name:"cursor",primaryRootInstructionPath:Ko,generateRules:R_,generateCommands:S_,generateAgents:k_,generateSkills:C_,generateMcp:I_,generatePermissions:E_,generateHooks:L_,generateIgnore:O_,importFrom:gx},B1={rootInstructionPath:Ko,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Us,tn]}],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`}}},K1={rootInstructionPath:Ko,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Us,tn]}],skillDir:fe,managedOutputs:{dirs:[_r,Rr,Sr,fe],files:[Ko,tn,We,jn,qr,Ll]},rewriteGeneratedPath(t){return t===Us?null:t===tn||t===Ko||t.startsWith(`${_r}/`)||t.startsWith(`${Rr}/`)||t.startsWith(`${Sr}/`)||t.startsWith(`${fe}/`)||t===We||t===jn||t===qr?t:t===Hu?null:t},mirrorGlobalPath(t,e){return dt(t,fe,e)},paths:{rulePath(t,e){return `${_r}/${t}.mdc`},commandPath(t,e){return `${Rr}/${t}.md`},agentPath(t,e){return `${Sr}/${t}.md`}}},W1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},xd={id:"cursor",metadata:{displayName:"Cursor",category:"ide",officialUrl:"https://cursor.com",shortDescription:"AI-first code editor"},generators:U1,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:Ix,lint:{commands:kx,mcp:Ex,permissions:Lx},project:B1,globalSupport:{capabilities:W1,detectionPaths:[Ko,tn,We,jn,qr,fe,Sr,Rr,Ll],layout:K1},importer:{commands:{feature:"commands",mode:"directory",source:{project:[Rr]},canonicalDir:Bs,extensions:[".md"],map:_x},agents:{feature:"agents",mode:"directory",source:{project:[Sr]},canonicalDir:Ks,extensions:[".md"],map:Rx}},buildImportPaths:ly,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});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(Bn)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:Ir,content:o}]:[]}function Ax(t){return st(t,ge)}function bx(t){return t.commands.map(e=>({path:`${ge}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function Px(t){return t.agents.map(e=>({path:`${ge}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function xx(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Wo,content:e}]}var Tx=d(()=>{rt();Kt();ut();Lt();wl();s(wx,"generateRules");s(Ax,"generateSkills");s(bx,"generateCommands");s(Px,"generateAgents");s(xx,"generateMcp");});async function Dx(t,e={}){let r=e.scope??"project",n=[],o=await W(Bn,t,r);return n.push(...await Y(Td,t,r,{normalize:o})),await et(t,r==="global"?en:ge,Bn,n,o),n}var Nx=d(()=>{gt();rt();Ot();wl();D_();s(Dx,"importFromDeepagentsCli");});function Fx(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Bn}))}var vx=d(()=>{Ct();wl();s(Fx,"lintRules");});function Mx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","deepagents-cli","Deep Agents CLI hooks are global-only (~/.deepagents/hooks.json); project-level 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?[]:[D(".agentsmesh/permissions.yaml","deepagents-cli","Deep Agents CLI permissions are managed via shell allow-lists (--shell-allow-list); canonical permissions are not projected.")]}function Gx(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","deepagents-cli","Deep Agents CLI has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var jx=d(()=>{wt();s(Mx,"lintHooks");s($x,"lintPermissions");s(Gx,"lintIgnore");});var H1,z1,V1,J1,Y1,Td,D_=d(()=>{Lt();ut();Tx();Nx();vx();jx();Et();wl();H1={name:Bn,primaryRootInstructionPath:Ir,generateRules:wx,generateCommands:bx,generateAgents:Px,generateSkills:Ax,generateMcp:xx,importFrom:Dx},z1={rootInstructionPath:Ir,skillDir:ge,managedOutputs:{dirs:[ge],files:[Ir,Wo]},paths:{rulePath(t){return Ir},commandPath(t){return `${ge}/${V(t)}/SKILL.md`},agentPath(t){return `${ge}/${K(t)}/SKILL.md`}}},V1={rootInstructionPath:Ho,skillDir:en,managedOutputs:{dirs:[en],files:[Ho,Xi]},rewriteGeneratedPath(t){return t===Ir?Ho:t===Wo?Xi:t.startsWith(`${ge}/`)?t.replace(`${ge}/`,`${en}/`):t},paths:{rulePath(t){return Ho},commandPath(t){return `${en}/${V(t)}/SKILL.md`},agentPath(t){return `${en}/${K(t)}/SKILL.md`}}},J1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Y1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Td={id:Bn,metadata:{displayName:"Deep Agents CLI",category:"cli",officialUrl:"https://github.com/langchain-ai/deepagents",shortDescription:"LangChain Deep Agents framework CLI"},generators:H1,capabilities:J1,emptyImportMessage:"No Deep Agents CLI config found (.deepagents/AGENTS.md, .deepagents/skills, or .mcp.json).",lintRules:Fx,lint:{hooks:Mx,permissions:$x,ignore:Gx},supportsConversion:{commands:true,agents:true},project:z1,globalSupport:{capabilities:Y1,detectionPaths:[Ho,Xi],layout:V1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ir],global:[Ho]},canonicalDir:eL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Wo],global:[Xi]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:cy,detectionPaths:[Ir,Wo]};});function Ux(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 Bx=d(()=>{U();s(Ux,"serializeDroid");});function Kx(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Cr)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:kr,content:o}]:[]}function Wx(t){return st(t,Ae)}function Hx(t){return t.commands.map(e=>({path:`${Ae}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function zx(t){return t.agents.map(e=>({path:`${Kn}/${e.name}.md`,content:Ux(e)}))}function Vx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Wn,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var Jx=d(()=>{rt();Kt();Lt();Bx();Qi();s(Kx,"generateRules");s(Wx,"generateSkills");s(Hx,"generateCommands");s(zx,"generateAgents");s(Vx,"generateMcp");});async function Xx(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 Ht(t,Yx,l),r.push({fromTool:Cr,fromPath:e,toPath:Yx,feature:"mcp"}));}var Yx,Zx=d(()=>{A();Jr();Qi();Yx=".agentsmesh/mcp.json";s(Xx,"importFactoryDroidMcp");});async function Qx(t,e={}){let r=e.scope??"project",n=[],o=await W(Cr,t,r);return n.push(...await Y(Dd,t,r,{normalize:o})),await et(t,r==="global"?Hn:Ae,Cr,n,o),await Xx(t,r==="global"?Ws:Wn,n),n}var qx=d(()=>{gt();rt();Ot();Zx();Qi();N_();s(Qx,"importFromFactoryDroid");});function tT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Cr}))}var eT=d(()=>{Ct();Qi();s(tT,"lintRules");});function rT(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".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 nT(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?[]:[D(".agentsmesh/permissions.yaml","factory-droid","Factory Droid permissions are managed via CLI flags (--skip-permissions-unsafe); canonical permissions are not projected.")]}function oT(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","factory-droid","Factory Droid has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var sT=d(()=>{wt();s(rT,"lintHooks");s(nT,"lintPermissions");s(oT,"lintIgnore");});var Z1,Q1,q1,iT,Dd,N_=d(()=>{Jx();Qi();qx();eT();sT();Et();Lt();Z1={name:Cr,primaryRootInstructionPath:kr,generateRules:Kx,generateCommands:Hx,generateAgents:zx,generateSkills:Wx,generateMcp:Vx,importFrom:Qx},Q1={rootInstructionPath:kr,skillDir:Ae,managedOutputs:{dirs:[Ae,Kn],files:[kr,Wn]},paths:{rulePath(t){return kr},commandPath(t){return `${Ae}/${V(t)}/SKILL.md`},agentPath(t){return `${Kn}/${t}.md`}}},q1={rootInstructionPath:zo,skillDir:Hn,managedOutputs:{dirs:[Hn,Zi],files:[zo,Ws]},rewriteGeneratedPath(t){return t===kr?zo:t===Wn?Ws:t.startsWith(`${Ae}/`)?t.replace(`${Ae}/`,`${Hn}/`):t.startsWith(`${Kn}/`)?t.replace(`${Kn}/`,`${Zi}/`):t},paths:{rulePath(t){return zo},commandPath(t){return `${Hn}/${V(t)}/SKILL.md`},agentPath(t){return `${Zi}/${t}.md`}}},iT={rules:"native",additionalRules:"embedded",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Dd={id:Cr,metadata:{displayName:"Factory Droid",category:"agent-platform",officialUrl:"https://www.factory.ai",shortDescription:"Factory.ai's coding droid"},generators:Z1,capabilities:iT,emptyImportMessage:"No Factory Droid config found (AGENTS.md, .factory/skills, or .factory/mcp.json).",lintRules:tT,lint:{hooks:rT,permissions:nT,ignore:oT},supportsConversion:{commands:true},project:Q1,globalSupport:{capabilities:iT,detectionPaths:[zo,Ws,Zi],layout:q1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[kr],global:[zo]},canonicalDir:nL,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:my,detectionPaths:[kr,Wn,Kn]};});var ui,Fr,uo,aT,lT,Ze,Nd,Ta,Fd,op,di,cT,mT,fi,vd,sp,ip,F_,v_,ic,M_,ac,lc,Md,cc,Da,ap,Xt=d(()=>{ui="gemini-cli",Fr="GEMINI.md",uo="AGENTS.md",aT=".gemini/rules",lT=".gemini/GEMINI.md",Ze=".gemini/commands",Nd=".gemini/policies",Ta=".gemini/settings.json",Fd=".geminiignore",op=".gemini/skills",di=".gemini/agents",cT=".gemini/system.md",mT=`${Nd}/permissions.toml`,fi=".agentsmesh/rules",vd=".agentsmesh/commands",sp=".agentsmesh/agents",ip=".agentsmesh/skills",F_=".agentsmesh/mcp.json",v_=".agentsmesh/hooks.yaml",ic=".agentsmesh/ignore",M_=".agentsmesh/permissions.yaml",ac=".gemini/GEMINI.md",lc=".gemini/AGENTS.md",Md=".gemini/settings.json",cc=".gemini/commands",Da=".gemini/skills",ap=".gemini/agents";});function $_(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=at(e?.body.trim()??"",r),o=[{path:Fr,content:n}];return e&&o.push({path:uo,content:e.body.trim()}),o}var pT=d(()=>{Kt();Xt();s($_,"generateRules");});function uT(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var dT=d(()=>{s(uT,"canonicalCommandNameToGeminiTomlPath");});function tJ(t){let e=t.replace(/\r\n/g,`
122
126
  `);return e.includes('"""')?JSON.stringify(e):`"""
123
127
  ${e}
124
- """`}function L1(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${E1(t.body.trim()||"")}`].join(`
128
+ """`}function eJ(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${tJ(t.body.trim()||"")}`].join(`
125
129
  `)+`
126
- `}function A_(t){return t.commands.map(e=>({path:ZT(e.name,Xe),content:L1(e)}))}var qT=d(()=>{Xt();QT();s(E1,"serializeTomlMultilineLiteral");s(L1,"serializeGeminiCommand");s(A_,"generateCommands");});function b_(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=x(r,e.body.trim()||"");return {path:`${pi}/${e.name}.md`,content:n}})}var tx=d(()=>{U();Xt();s(b_,"generateAgents");});function P_(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=x(n,r.body.trim()||"");e.push({path:`${tp}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${tp}/${r.name}/${a}`,content:i.content});}}return e}var ex=d(()=>{U();Xt();s(P_,"generateSkills");});function O1(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function T_(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=O1(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:Jt(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:Pa,content:JSON.stringify(e,null,2)}]}var x_=d(()=>{Ur();Xt();s(O1,"mapHookEvent");s(T_,"generateGeminiSettingsFiles");});function D_(t){return !t.ignore||t.ignore.length===0?[]:[{path:Ad,content:t.ignore.join(`
127
- `)}]}var rx=d(()=>{Xt();s(D_,"generateIgnore");});var nx=d(()=>{XT();qT();tx();ex();x_();rx();});var ox=d(()=>{nx();});function xa(t){return JSON.stringify(t)}function w1(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function A1(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 Td(t,e,r){return ["[[rule]]",`decision = ${xa(t)}`,`priority = ${e}`,...r,""].join(`
128
- `)}function sx(t,e,r){let n=A1(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 Td(e,r,[`toolName = ${xa(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return Td(e,r,[`toolName = ${xa(o.Bash)}`,`commandPrefix = ${xa(i)}`])}return n.kind==="read"?Td(e,r,[`toolName = ${xa(o.Read)}`,`argsPattern = ${xa(w1(n.path))}`]):Td(e,r,[`toolName = ${xa(n.raw)}`])}function ix(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=sx(i,"allow",100+a);l&&o.push(l);}),r.forEach((i,a)=>{let l=sx(i,"deny",200+a);l&&o.push(l);}),o.length===0?[]:[{path:YT,content:o.join(`
129
- `)}]}var ax=d(()=>{Xt();s(xa,"escapeTomlBasicString");s(w1,"escapeRegexLiteral");s(A1,"parsePermissionExpr");s(Td,"ruleForDecision");s(sx,"permissionExprToGeminiRule");s(ix,"generateGeminiPermissionsPolicies");});function N_(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 xd(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return P(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 F_=d(()=>{U();s(N_,"mapGeminiHookEvent");s(xd,"parseFlexibleFrontmatter");});async function v_(t,e){let r=join(t,Pa),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,E_);await O(join(t,".agentsmesh")),await S(c,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:E_,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(c=>typeof c=="string")){let c=join(t,nc);await O(join(t,".agentsmesh")),await S(c,a.join(`
130
+ `}function G_(t){return t.commands.map(e=>({path:uT(e.name,Ze),content:eJ(e)}))}var fT=d(()=>{Xt();dT();s(tJ,"serializeTomlMultilineLiteral");s(eJ,"serializeGeminiCommand");s(G_,"generateCommands");});function j_(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:`${di}/${e.name}.md`,content:n}})}var gT=d(()=>{U();Xt();s(j_,"generateAgents");});function U_(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:`${op}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${op}/${r.name}/${a}`,content:i.content});}}return e}var hT=d(()=>{U();Xt();s(U_,"generateSkills");});function rJ(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function B_(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=rJ(o);if(!a||!Array.isArray(i))return [];let l=i.filter(c=>typeof c=="object"&&c!==null&&Oo(c)).map((c,m)=>({matcher:c.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:Jt(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:[Fr,uo]}),Object.keys(e).length===0?[]:[{path:Ta,content:JSON.stringify(e,null,2)}]}var K_=d(()=>{Br();Xt();s(rJ,"mapHookEvent");s(B_,"generateGeminiSettingsFiles");});function W_(t){return !t.ignore||t.ignore.length===0?[]:[{path:Fd,content:t.ignore.join(`
131
+ `)}]}var yT=d(()=>{Xt();s(W_,"generateIgnore");});var _T=d(()=>{pT();fT();gT();hT();K_();yT();});var RT=d(()=>{_T();});function Na(t){return JSON.stringify(t)}function nJ(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oJ(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 $d(t,e,r){return ["[[rule]]",`decision = ${Na(t)}`,`priority = ${e}`,...r,""].join(`
132
+ `)}function ST(t,e,r){let n=oJ(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 $d(e,r,[`toolName = ${Na(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return $d(e,r,[`toolName = ${Na(o.Bash)}`,`commandPrefix = ${Na(i)}`])}return n.kind==="read"?$d(e,r,[`toolName = ${Na(o.Read)}`,`argsPattern = ${Na(nJ(n.path))}`]):$d(e,r,[`toolName = ${Na(n.raw)}`])}function IT(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=ST(i,"allow",100+a);l&&o.push(l);}),r.forEach((i,a)=>{let l=ST(i,"deny",200+a);l&&o.push(l);}),o.length===0?[]:[{path:mT,content:o.join(`
133
+ `)}]}var CT=d(()=>{Xt();s(Na,"escapeTomlBasicString");s(nJ,"escapeRegexLiteral");s(oJ,"parsePermissionExpr");s($d,"ruleForDecision");s(ST,"permissionExprToGeminiRule");s(IT,"generateGeminiPermissionsPolicies");});function H_(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 Gd(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return P(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 z_=d(()=>{U();s(H_,"mapGeminiHookEvent");s(Gd,"parseFlexibleFrontmatter");});async function V_(t,e){let r=join(t,Ta),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,F_);await O(join(t,".agentsmesh")),await I(c,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:F_,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(c=>typeof c=="string")){let c=join(t,ic);await O(join(t,".agentsmesh")),await I(c,a.join(`
130
134
  `)+`
131
- `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:nc,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=N_(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:Jt(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:Jt(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,L_);await O(join(t,".agentsmesh")),await S(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:L_,feature:"hooks"});}}}var lx=d(()=>{Ur();A();Xt();F_();s(v_,"importGeminiSettings");});async function cx(t,e){let r=join(t,Ad),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,nc);await S(i,o.join(`
135
+ `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:ic,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=H_(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"&&Oo(h)).map(h=>({matcher:g.matcher,command:Jt(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"&&Oo(h)).map(h=>({matcher:h.matcher,command:Jt(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,v_);await O(join(t,".agentsmesh")),await I(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:v_,feature:"hooks"});}}}var kT=d(()=>{Br();A();Xt();z_();s(V_,"importGeminiSettings");});async function ET(t,e){let r=join(t,Fd),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,ic);await I(i,o.join(`
132
136
  `)+`
133
- `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:nc,feature:"ignore"});}}}var $_=d(()=>{A();Xt();F_();lx();s(cx,"importGeminiIgnore");});function D1(t){return t.replace(/\\(.)/g,"$1")}function N1(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 F1(t){return `Bash(${t}:*)`}function v1(t){return `Read(${D1(t)})`}async function mx(t){let e=[],r=join(t,wd),n;try{n=await G(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 k=R,I=typeof k.toolName=="string"?k.toolName:null,C=typeof k.decision=="string"?k.decision:null;if(!I||!C)continue;let b=N1(I);if(!b)continue;let N=null;b==="Bash"?typeof k.commandPrefix=="string"&&k.commandPrefix.trim()&&(N=F1(k.commandPrefix.trim())):b==="Read"?typeof k.argsPattern=="string"&&k.argsPattern.trim()?N=v1(k.argsPattern.trim()):N="Read":N=b,N&&(C==="allow"?l.has(N)||(l.add(N),i.push(N)):C==="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,O_),p=stringify({allow:i,deny:a});return await S(m,p.trimEnd()+`
134
- `),e.push({fromTool:mi,fromPath:join(t,wd),toPath:O_,feature:"permissions"}),e}var px=d(()=>{A();Xt();s(D1,"unescapeRegexLiteral");s(N1,"toolNameToPermissionBase");s(F1,"commandPrefixToBashExpr");s(v1,"argsPatternToReadExpr");s(mx,"importGeminiPolicies");});function G_(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 dx=d(()=>{s(G_,"stripProjectRootCanonicalPrefix");});async function gx(t,e,r){let n=join(t,tp),i=(await G(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=P(c),u=ml(p.frontmatter,m);if(u){let C=join(t,ep);await O(C);let b=join(C,`${u.name}.md`);await S(b,bs(u,r(p.body,l,b))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${ep}/${u.name}.md`,feature:"agents"});continue}let f=join(t,rp,m,"SKILL.md"),g=r(c,l,f),h=join(t,rp,m);await O(h);let{frontmatter:R,body:k}=P(g);await S(f,await En(f,{...R,name:m},k)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${rp}/${m}/SKILL.md`,feature:"skills"});let I=await G(dirname(l));for(let C of I){if(C===l)continue;let b=await _(C);if(b===null)continue;let N=relative(dirname(l),C).replace(/\\/g,"/"),T=join(h,N);await O(dirname(T)),await S(T,r(b,C,T)),e.push({fromTool:"gemini-cli",fromPath:C,toPath:`${rp}/${m}/${N}`,feature:"skills"});}}let a=join(t,pi);try{let c=(await G(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await _(m);if(!p)continue;let{frontmatter:u,body:f}=P(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),R=join(t,ep);await O(R);let k=join(R,h),I=r(f,m,k);await S(k,await Yt(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},I)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${ep}/${h}`,feature:"agents"});}}catch{}}var hx=d(()=>{A();U();ft();ut();Xt();s(gx,"importGeminiSkillsAndAgents");});async function M1(t,e,r){let n=await W("codex-cli",t),o=join(t,ui),i=join(t,po),a=join(t,VT),l=[i,a,join(t,Nr),join(t,JT)],c=null,m=l[l.length-1];for(let N of l){let T=await _(N);if(T!==null){c=T,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:ui,sourcePath:m,fromTool:mi,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=G_(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:R,body:k}=P(h),C=R.root===true?R:{...R,root:true},b=G_(await z(p,C,k),t);await S(p,b),e.push({fromTool:mi,fromPath:m,toPath:`${ui}/_root.md`,feature:"rules"});}async function yx(t){let e=[],r=await W(mi,t);return await M1(t,e,r),e.push(...await Y(Nd,t,"project",{normalize:r})),await gx(t,e,r),await v_(t,e),await cx(t,e),e.push(...await mx(t)),e}var _x=d(()=>{gt();A();U();ft();Jl();Ot();Xt();B_();$_();px();dx();hx();s(M1,"importRootRule");s(yx,"importFromGemini");});async function Ix(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=xd(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:`${ui}/${n}`,feature:"rules",content:await z(o,c,a)}}async function Sx(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):xd(i),c=lr(a.allowedTools),m=lr(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${bd}/${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 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(()=>{ft();cr();$_();Xt();s(Ix,"mapGeminiRuleFile");s(Sx,"mapGeminiCommandFile");s(G1,"parseTomlCommand");});var kx,Ex,Lx=d(()=>{Cx();kx=s(({relativePath:t,destDir:e,normalizeTo:r})=>Ix(t,e,r),"geminiRuleMapper"),Ex=s(({relativePath:t,destDir:e,normalizeTo:r})=>Sx(t,e,r),"geminiCommandMapper");});function Ox(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:mi}))}var wx=d(()=>{Ct();Xt();s(Ox,"lintRules");});function Ax(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>D(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function bx(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=>Ds(n,"gemini-cli",e))}var Px=d(()=>{wt();s(Ax,"lintCommands");s(bx,"lintHooks");});function Tx(t,e){return e==="project"&&di("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:T_(t)}var xx=d(()=>{Tt();x_();s(Tx,"emitScopedGeminiSettings");});var j1,U1,B1,K1,Nd,B_=d(()=>{ox();xi();ax();Xt();_x();Lx();wx();Et();al();ut();Px();xx();oe();hd();j1={name:"gemini-cli",primaryRootInstructionPath:Nr,generateRules:w_,generateCommands:A_,generateAgents:b_,generateSkills:P_,generateIgnore:D_,generatePermissions:ix,importFrom:yx},U1={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/${K(t)}/SKILL.md`:`${pi}/${t}.md`}}},B1={rootInstructionPath:oc,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[sc]}],extraRuleOutputPaths(){return [sc]},skillDir:Ta,managedOutputs:{dirs:[ic,Ta,np],files:[oc,sc,Pd]},rewriteGeneratedPath(t){return t===Nr?oc:t===po?sc:t===Pa?Pd:t.startsWith(`${Xe}/`)?t.replace(`${Xe}/`,`${ic}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Ta}/`):t.startsWith(`${pi}/`)?t.replace(`${pi}/`,`${np}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return dt(t,Ta,e)},paths:{rulePath(t,e){return oc},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${ic}/${r.join("/")}/${n}.toml`}return `${ic}/${t}.toml`},agentPath(t,e){return or(e,"gemini-cli")?`${Ta}/${K(t)}/SKILL.md`:`${np}/${t}.md`}}},K1={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},Nd={id:"gemini-cli",metadata:{displayName:"Gemini CLI",category:"cli",officialUrl:"https://github.com/google-gemini/gemini-cli",shortDescription:"Google's terminal Gemini agent"},generators:j1,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:Ox,lint:{commands:Ax,hooks:bx},emitScopedSettings:Tx,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Pa?LP(o,r):null},project:U1,globalSupport:{capabilities:K1,detectionPaths:[oc,sc,Pd,ic,Ta,np],layout:B1},importer:{rules:{feature:"rules",mode:"directory",source:{project:[zT]},canonicalDir:ui,extensions:[".md"],map:kx},commands:{feature:"commands",mode:"directory",source:{project:[Xe]},canonicalDir:bd,extensions:[".md",".toml"],map:Ex}},buildImportPaths:ty,detectionPaths:["GEMINI.md",".gemini"],conversionDefaults:{agentsToSkills:false}};});function Dx(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 Nx(t){return st(t,be)}function Fx(t){return t.commands.map(e=>({path:`${be}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function vx(t){return t.agents.map(e=>({path:`${be}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function Mx(t){return t.ignore.length===0?[]:[{path:zo,content:t.ignore.join(`
135
- `)}]}var $x=d(()=>{rt();Wt();ut();Lt();Ll();s(Dx,"generateRules");s(Nx,"generateSkills");s(Fx,"generateCommands");s(vx,"generateAgents");s(Mx,"generateIgnore");});async function Gx(t,e={}){let r=e.scope??"project",n=[],o=await W(Wn,t,r);return n.push(...await Y(Fd,t,r,{normalize:o})),await et(t,r==="global"?Er:be,Wn,n,o),n}var jx=d(()=>{gt();rt();Ot();Ll();K_();s(Gx,"importFromGoose");});function Ux(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Wn}))}var Bx=d(()=>{Ct();Ll();s(Ux,"lintRules");});function Kx(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Wx(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?[]:[D(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function Hx(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var zx=d(()=>{wt();s(Kx,"lintHooks");s(Wx,"lintPermissions");s(Hx,"lintMcp");});var W1,H1,z1,Vx,Fd,K_=d(()=>{Lt();ut();$x();oe();jx();Bx();zx();Et();Ll();W1={name:Wn,primaryRootInstructionPath:kr,generateRules:Dx,generateCommands:Fx,generateAgents:vx,generateSkills:Nx,generateIgnore:Mx,importFrom:Gx},H1={rootInstructionPath:kr,skillDir:be,managedOutputs:{dirs:[be],files:[kr,zo]},paths:{rulePath(t){return kr},commandPath(t){return `${be}/${V(t)}/SKILL.md`},agentPath(t){return `${be}/${K(t)}/SKILL.md`}}},z1={rootInstructionPath:Vo,skillDir:Er,managedOutputs:{dirs:[Er],files:[Vo,Zi]},rewriteGeneratedPath(t){return t===kr?Vo:t===zo?Zi: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}/${K(t)}/SKILL.md`}}},Vx={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Fd={id:Wn,metadata:{displayName:"Goose",category:"cli",officialUrl:"https://block.github.io/goose",shortDescription:"Block's open-source AI agent"},generators:W1,capabilities:Vx,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:Ux,lint:{hooks:Kx,permissions:Wx,mcp:Hx},supportsConversion:{commands:true,agents:true},project:H1,globalSupport:{capabilities:Vx,detectionPaths:[Vo,Zi,Er],layout:z1},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[kr],global:[Vo]},canonicalDir:zE,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[zo],global:[Zi]},canonicalDir:".agentsmesh",canonicalFilename:VE}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:ey,detectionPaths:[kr,zo],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function Jx(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 Yx=d(()=>{Wt();Ol();s(Jx,"generateRules");});async function Xx(t,e={}){let r=e.scope??"project",n=await W(Jo,t,r);return Y(vd,t,r,{normalize:n})}var Zx=d(()=>{gt();Ot();Ol();W_();s(Xx,"importFromJules");});function Qx(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Jo}))}var qx=d(()=>{Ct();Ol();s(Qx,"lintRules");});function tD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","jules","Jules has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function eD(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?[]:[D(".agentsmesh/permissions.yaml","jules","Jules has no permissions system; canonical permissions are not projected.")]}function rD(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","jules","Jules is a cloud-based agent with no dedicated ignore file; canonical ignore patterns are not projected.")]}function nD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","jules","Jules is a cloud-based agent with no MCP support; canonical MCP servers are not projected.")]}function oD(t){return t.commands.length===0?[]:[D(".agentsmesh/commands","jules","Jules has no command system; canonical commands are not projected.")]}var sD=d(()=>{wt();s(tD,"lintHooks");s(eD,"lintPermissions");s(rD,"lintIgnore");s(nD,"lintMcp");s(oD,"lintCommands");});var V1,J1,Y1,vd,W_=d(()=>{Yx();Zx();qx();sD();Et();Ol();V1={name:Jo,primaryRootInstructionPath:en,generateRules:Jx,importFrom:Xx},J1={rootInstructionPath:en,managedOutputs:{dirs:[],files:[en]},paths:{rulePath(t){return en},commandPath(){return null},agentPath(){return null}}},Y1={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},vd={id:Jo,metadata:{displayName:"Jules",category:"agent-platform",officialUrl:"https://jules.google",shortDescription:"Google's autonomous coding agent"},generators:V1,capabilities:Y1,emptyImportMessage:"No Jules config found (AGENTS.md).",lintRules:Qx,lint:{hooks:tD,permissions:eD,ignore:rD,mcp:nD,commands:oD},project:J1,importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[en]},canonicalDir:YE,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:ry,detectionPaths:[en]};});function iD(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:`${Om}/${o}.md`,content:n.body.trim()||""});}return e}function Z1(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),od(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 aD(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,Z1(n)]));return [{path:Lm,content:JSON.stringify({mcpServers:e},null,2)}]}function lD(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${wl}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function cD(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:`${Al}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function mD(t){return t.ignore.length===0?[]:[{path:wm,content:t.ignore.join(`
136
- `)}]}function pD(t){return st(t,qi)}function uD(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 dD=d(()=>{sd();rt();Wt();U();bl();s(iD,"generateRules");s(Z1,"toJunieMcpServer");s(aD,"generateMcp");s(lD,"generateCommands");s(cD,"generateAgents");s(mD,"generateIgnore");s(pD,"generateSkills");s(uD,"renderJunieGlobalInstructions");});async function Q1(t,e,r){let n=[Hn,Gu,ZE,QE],o=join(t,ny);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:Uu,sourcePath:a,fromTool:Qi,normalize:r});e.push(...c.results);let{frontmatter:m,body:p}=P(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:Qi,fromPath:a,toPath:ny,feature:"rules"});return}}async function gD(t){let e=[],r=await W(Qi,t);return await Q1(t,e,r),e.push(...await Y(Md,t,"project",{normalize:r})),await et(t,qi,Qi,e,r),e}var hD=d(()=>{gt();A();U();rt();Jl();ft();Ot();bl();H_();s(Q1,"importRootRule");s(gD,"importFromJunie");});function yD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Qi}))}var _D=d(()=>{Ct();bl();s(yD,"lintRules");});function RD(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))SA(n)&&e.push(D(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${n.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var ID=d(()=>{sd();wt();s(RD,"lintMcp");});var q1,tJ,eJ,rJ,Md,H_=d(()=>{dD();bl();oe();hD();_D();ID();Et();q1={name:"junie",primaryRootInstructionPath:Hn,generateRules:iD,generateCommands:lD,generateAgents:cD,generateSkills:pD,generateMcp:aD,generateIgnore:mD,importFrom:gD},tJ={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 `${Om}/${t}.md`},commandPath(t,e){return `${wl}/${t}.md`},agentPath(t,e){return `${Al}/${t}.md`}}},eJ={rootInstructionPath:ta,renderPrimaryRootInstruction:uD,skillDir:bm,managedOutputs:{dirs:[bm,Pm,Tm,qE],files:[ta,ju]},rewriteGeneratedPath(t){return t===Hn?ta:t.startsWith(`${Om}/`)?ta:t.startsWith(`${qi}/`)?t.replace(`${qi}/`,`${bm}/`):t.startsWith(`${wl}/`)?t.replace(`${wl}/`,`${Tm}/`):t.startsWith(`${Al}/`)?t.replace(`${Al}/`,`${Pm}/`):t===Lm?ju:t===wm?null:t},mirrorGlobalPath(t,e){return dt(t,".junie/skills",e)},paths:{rulePath(t,e){return ta},commandPath(t,e){return `${Tm}/${t}.md`},agentPath(t,e){return `${Pm}/${t}.md`}}},rJ={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Md={id:"junie",metadata:{displayName:"Junie",category:"ide",officialUrl:"https://www.jetbrains.com/junie",shortDescription:"JetBrains AI coding agent"},generators:q1,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:yD,lint:{mcp:RD},project:tJ,globalSupport:{capabilities:rJ,detectionPaths:[ta,bm,Pm,Tm,ju],layout:eJ},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Uu,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:tL,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:eL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Lm]},canonicalDir:".agentsmesh",canonicalFilename:rL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[wm]},canonicalDir:".agentsmesh",canonicalFilename:nL}},buildImportPaths:oy,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:zn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Se))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?x(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Yo}/${o}.md`,content:a});}return e}function kD(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Xo}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function ED(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:x(n,e.body.trim()||"")}})}function LD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ws,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function OD(t){return t.ignore.length===0?[]:[{path:Pl,content:t.ignore.join(`
137
- `)}]}function wD(t){return st(t,rn)}var AD=d(()=>{rt();U();aa();s(CD,"generateRules");s(kD,"generateCommands");s(ED,"generateAgents");s(LD,"generateMcp");s(OD,"generateIgnore");s(wD,"generateSkills");});var $d,Gd,bD,V_=d(()=>{U();ft();aa();$d=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Vs}/${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"),Gd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Nl}/${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"),bD=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${ia}/${t}`,content:await Yt(n,o,i)}},"kiloAgentMapper");});async function PD(t){try{return await stat(t),!0}catch{return false}}async function sJ(t,e,r){let n=join(t,ea);if(!await PD(n))return;let o=join(t,Vs),i=join(n,Y_),l=e.some(c=>c.toPath===J_)?null:await _(i);if(l!==null){let c=join(t,J_),m=r(l,i,c),{body:p}=P(m),u=await z(c,{root:true},p);await S(c,u),e.push({feature:"rules",fromTool:Se,fromPath:`${ea}/${Y_}`,toPath:J_});}e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:Se,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await $d({absolutePath:c,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===Y_||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function iJ(t,e,r){let n=join(t,Tl);if(!await PD(n))return;let o=join(t,Nl);e.push(...await St({srcDir:n,destDir:o,extensions:[".md"],fromTool:Se,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:l,normalizeTo:c})=>{let m=await Gd({absolutePath:i,relativePath:a,content:l,destDir:o,normalizeTo:c});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function aJ(t,e,r){let n=join(t,Ku),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,ia,`${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}
137
+ `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:ic,feature:"ignore"});}}}var Y_=d(()=>{A();Xt();z_();kT();s(ET,"importGeminiIgnore");});function cJ(t){return t.replace(/\\(.)/g,"$1")}function mJ(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 pJ(t){return `Bash(${t}:*)`}function uJ(t){return `Read(${cJ(t)})`}async function LT(t){let e=[],r=join(t,Nd),n;try{n=await G(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 S of h){if(!S||typeof S!="object")continue;let C=S,R=typeof C.toolName=="string"?C.toolName:null,k=typeof C.decision=="string"?C.decision:null;if(!R||!k)continue;let b=mJ(R);if(!b)continue;let N=null;b==="Bash"?typeof C.commandPrefix=="string"&&C.commandPrefix.trim()&&(N=pJ(C.commandPrefix.trim())):b==="Read"?typeof C.argsPattern=="string"&&C.argsPattern.trim()?N=uJ(C.argsPattern.trim()):N="Read":N=b,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,M_),p=stringify({allow:i,deny:a});return await I(m,p.trimEnd()+`
138
+ `),e.push({fromTool:ui,fromPath:join(t,Nd),toPath:M_,feature:"permissions"}),e}var OT=d(()=>{A();Xt();s(cJ,"unescapeRegexLiteral");s(mJ,"toolNameToPermissionBase");s(pJ,"commandPrefixToBashExpr");s(uJ,"argsPatternToReadExpr");s(LT,"importGeminiPolicies");});function X_(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 AT=d(()=>{s(X_,"stripProjectRootCanonicalPrefix");});async function PT(t,e,r){let n=join(t,op),i=(await G(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=P(c),u=dl(p.frontmatter,m);if(u){let k=join(t,sp);await O(k);let b=join(k,`${u.name}.md`);await I(b,xs(u,r(p.body,l,b))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${sp}/${u.name}.md`,feature:"agents"});continue}let f=join(t,ip,m,"SKILL.md"),g=r(c,l,f),h=join(t,ip,m);await O(h);let{frontmatter:S,body:C}=P(g);await I(f,await On(f,{...S,name:m},C)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${ip}/${m}/SKILL.md`,feature:"skills"});let R=await G(dirname(l));for(let k of R){if(k===l)continue;let b=await _(k);if(b===null)continue;let N=relative(dirname(l),k).replace(/\\/g,"/"),x=join(h,N);await O(dirname(x)),await I(x,r(b,k,x)),e.push({fromTool:"gemini-cli",fromPath:k,toPath:`${ip}/${m}/${N}`,feature:"skills"});}}let a=join(t,di);try{let c=(await G(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await _(m);if(!p)continue;let{frontmatter:u,body:f}=P(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),S=join(t,sp);await O(S);let C=join(S,h),R=r(f,m,C);await I(C,await Yt(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},R)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${sp}/${h}`,feature:"agents"});}}catch{}}var xT=d(()=>{A();U();ft();ut();Xt();s(PT,"importGeminiSkillsAndAgents");});async function dJ(t,e,r){let n=await W("codex-cli",t),o=join(t,fi),i=join(t,uo),a=join(t,lT),l=[i,a,join(t,Fr),join(t,cT)],c=null,m=l[l.length-1];for(let N of l){let x=await _(N);if(x!==null){c=x,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 ao({content:u,projectRoot:t,rulesDir:fi,sourcePath:m,fromTool:ui,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=X_(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:S,body:C}=P(h),k=S.root===true?S:{...S,root:true},b=X_(await z(p,k,C),t);await I(p,b),e.push({fromTool:ui,fromPath:m,toPath:`${fi}/_root.md`,feature:"rules"});}async function TT(t){let e=[],r=await W(ui,t);return await dJ(t,e,r),e.push(...await Y(Ud,t,"project",{normalize:r})),await PT(t,e,r),await V_(t,e),await ET(t,e),e.push(...await LT(t)),e}var DT=d(()=>{gt();A();U();ft();Zl();Ot();Xt();q_();Y_();OT();AT();xT();s(dJ,"importRootRule");s(TT,"importFromGemini");});async function FT(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=Gd(r(o)),l=xo(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:`${fi}/${n}`,feature:"rules",content:await z(o,c,a)}}async function vT(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")?gJ(i):Gd(i),c=cr(a.allowedTools),m=cr(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${vd}/${n}`,feature:"commands",content:await St(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 gJ(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var MT=d(()=>{ft();mr();Y_();Xt();s(FT,"mapGeminiRuleFile");s(vT,"mapGeminiCommandFile");s(gJ,"parseTomlCommand");});var $T,GT,jT=d(()=>{MT();$T=s(({relativePath:t,destDir:e,normalizeTo:r})=>FT(t,e,r),"geminiRuleMapper"),GT=s(({relativePath:t,destDir:e,normalizeTo:r})=>vT(t,e,r),"geminiCommandMapper");});function UT(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:ui}))}var BT=d(()=>{Ct();Xt();s(UT,"lintRules");});function KT(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>D(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function WT(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=>Fs(n,"gemini-cli",e))}var HT=d(()=>{wt();s(KT,"lintCommands");s(WT,"lintHooks");});function zT(t,e){return e==="project"&&gi("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:B_(t)}var VT=d(()=>{xt();K_();s(zT,"emitScopedGeminiSettings");});var hJ,yJ,_J,RJ,Ud,q_=d(()=>{RT();Ni();CT();Xt();DT();jT();BT();Et();ml();ut();HT();VT();oe();kd();hJ={name:"gemini-cli",primaryRootInstructionPath:Fr,generateRules:$_,generateCommands:G_,generateAgents:j_,generateSkills:U_,generateIgnore:W_,generatePermissions:IT,importFrom:TT},yJ={rootInstructionPath:Fr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[uo]}],extraRuleOutputPaths(){return [uo]},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 Fr},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${Ze}/${r.join("/")}/${n}.toml`}return `${Ze}/${t}.toml`},agentPath(t,e){return sr(e,"gemini-cli")?`.gemini/skills/${K(t)}/SKILL.md`:`${di}/${t}.md`}}},_J={rootInstructionPath:ac,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[lc]}],extraRuleOutputPaths(){return [lc]},skillDir:Da,managedOutputs:{dirs:[cc,Da,ap],files:[ac,lc,Md]},rewriteGeneratedPath(t){return t===Fr?ac:t===uo?lc:t===Ta?Md:t.startsWith(`${Ze}/`)?t.replace(`${Ze}/`,`${cc}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Da}/`):t.startsWith(`${di}/`)?t.replace(`${di}/`,`${ap}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return dt(t,Da,e)},paths:{rulePath(t,e){return ac},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${cc}/${r.join("/")}/${n}.toml`}return `${cc}/${t}.toml`},agentPath(t,e){return sr(e,"gemini-cli")?`${Da}/${K(t)}/SKILL.md`:`${ap}/${t}.md`}}},RJ={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},Ud={id:"gemini-cli",metadata:{displayName:"Gemini CLI",category:"cli",officialUrl:"https://github.com/google-gemini/gemini-cli",shortDescription:"Google's terminal Gemini agent"},generators:hJ,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Wr("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:UT,lint:{commands:KT,hooks:WT},emitScopedSettings:zT,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Ta?jP(o,r):null},project:yJ,globalSupport:{capabilities:RJ,detectionPaths:[ac,lc,Md,cc,Da,ap],layout:_J},importer:{rules:{feature:"rules",mode:"directory",source:{project:[aT]},canonicalDir:fi,extensions:[".md"],map:$T},commands:{feature:"commands",mode:"directory",source:{project:[Ze]},canonicalDir:vd,extensions:[".md",".toml"],map:GT}},buildImportPaths:py,detectionPaths:["GEMINI.md",".gemini"],conversionDefaults:{agentsToSkills:false}};});function JT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(zn)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:Er,content:o}]:[]}function YT(t){return st(t,be)}function XT(t){return t.commands.map(e=>({path:`${be}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function ZT(t){return t.agents.map(e=>({path:`${be}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function QT(t){return t.ignore.length===0?[]:[{path:Vo,content:t.ignore.join(`
139
+ `)}]}var qT=d(()=>{rt();Kt();ut();Lt();Al();s(JT,"generateRules");s(YT,"generateSkills");s(XT,"generateCommands");s(ZT,"generateAgents");s(QT,"generateIgnore");});async function tD(t,e={}){let r=e.scope??"project",n=[],o=await W(zn,t,r);return n.push(...await Y(Bd,t,r,{normalize:o})),await et(t,r==="global"?Lr:be,zn,n,o),n}var eD=d(()=>{gt();rt();Ot();Al();tR();s(tD,"importFromGoose");});function rD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:zn}))}var nD=d(()=>{Ct();Al();s(rD,"lintRules");});function oD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function sD(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?[]:[D(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function iD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var aD=d(()=>{wt();s(oD,"lintHooks");s(sD,"lintPermissions");s(iD,"lintMcp");});var SJ,IJ,CJ,lD,Bd,tR=d(()=>{Lt();ut();qT();oe();eD();nD();aD();Et();Al();SJ={name:zn,primaryRootInstructionPath:Er,generateRules:JT,generateCommands:XT,generateAgents:ZT,generateSkills:YT,generateIgnore:QT,importFrom:tD},IJ={rootInstructionPath:Er,skillDir:be,managedOutputs:{dirs:[be],files:[Er,Vo]},paths:{rulePath(t){return Er},commandPath(t){return `${be}/${V(t)}/SKILL.md`},agentPath(t){return `${be}/${K(t)}/SKILL.md`}}},CJ={rootInstructionPath:Jo,skillDir:Lr,managedOutputs:{dirs:[Lr],files:[Jo,qi]},rewriteGeneratedPath(t){return t===Er?Jo:t===Vo?qi:t},mirrorGlobalPath(t,e){return dt(t,Lr,e)},paths:{rulePath(t){return Jo},commandPath(t){return `${Lr}/${V(t)}/SKILL.md`},agentPath(t){return `${Lr}/${K(t)}/SKILL.md`}}},lD={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Bd={id:zn,metadata:{displayName:"Goose",category:"cli",officialUrl:"https://block.github.io/goose",shortDescription:"Block's open-source AI agent"},generators:SJ,capabilities:lD,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:rD,lint:{hooks:oD,permissions:sD,mcp:iD},supportsConversion:{commands:true,agents:true},project:IJ,globalSupport:{capabilities:lD,detectionPaths:[Jo,qi,Lr],layout:CJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Er],global:[Jo]},canonicalDir:aL,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Vo],global:[qi]},canonicalDir:".agentsmesh",canonicalFilename:lL}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:uy,detectionPaths:[Er,Vo],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});function cD(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Yo)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:rn,content:o}]:[]}var mD=d(()=>{Kt();bl();s(cD,"generateRules");});async function pD(t,e={}){let r=e.scope??"project",n=await W(Yo,t,r);return Y(Kd,t,r,{normalize:n})}var uD=d(()=>{gt();Ot();bl();eR();s(pD,"importFromJules");});function dD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Yo}))}var fD=d(()=>{Ct();bl();s(dD,"lintRules");});function gD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","jules","Jules has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function hD(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?[]:[D(".agentsmesh/permissions.yaml","jules","Jules has no permissions system; canonical permissions are not projected.")]}function yD(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","jules","Jules is a cloud-based agent with no dedicated ignore file; canonical ignore patterns are not projected.")]}function _D(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","jules","Jules is a cloud-based agent with no MCP support; canonical MCP servers are not projected.")]}function RD(t){return t.commands.length===0?[]:[D(".agentsmesh/commands","jules","Jules has no command system; canonical commands are not projected.")]}var SD=d(()=>{wt();s(gD,"lintHooks");s(hD,"lintPermissions");s(yD,"lintIgnore");s(_D,"lintMcp");s(RD,"lintCommands");});var kJ,EJ,LJ,Kd,eR=d(()=>{mD();uD();fD();SD();Et();bl();kJ={name:Yo,primaryRootInstructionPath:rn,generateRules:cD,importFrom:pD},EJ={rootInstructionPath:rn,managedOutputs:{dirs:[],files:[rn]},paths:{rulePath(t){return rn},commandPath(){return null},agentPath(){return null}}},LJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Kd={id:Yo,metadata:{displayName:"Jules",category:"agent-platform",officialUrl:"https://jules.google",shortDescription:"Google's autonomous coding agent"},generators:kJ,capabilities:LJ,emptyImportMessage:"No Jules config found (AGENTS.md).",lintRules:dD,lint:{hooks:gD,permissions:hD,ignore:yD,mcp:_D,commands:RD},project:EJ,importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[rn]},canonicalDir:mL,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:dy,detectionPaths:[rn]};});function ID(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Vn,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:`${Pm}/${o}.md`,content:n.body.trim()||""});}return e}function wJ(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),pd(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 CD(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,wJ(n)]));return [{path:bm,content:JSON.stringify({mcpServers:e},null,2)}]}function kD(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${Pl}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function ED(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:`${xl}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function LD(t){return t.ignore.length===0?[]:[{path:xm,content:t.ignore.join(`
140
+ `)}]}function OD(t){return st(t,ea)}function wD(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 at(e?.body.trim()??"",r)}var AD=d(()=>{ud();rt();Kt();U();Tl();s(ID,"generateRules");s(wJ,"toJunieMcpServer");s(CD,"generateMcp");s(kD,"generateCommands");s(ED,"generateAgents");s(LD,"generateIgnore");s(OD,"generateSkills");s(wD,"renderJunieGlobalInstructions");});async function AJ(t,e,r){let n=[Vn,zu,uL,dL],o=join(t,fy);for(let i of n){let a=join(t,i),l=await _(a);if(l===null)continue;let c=await ao({content:l,projectRoot:t,rulesDir:Ju,sourcePath:a,fromTool:ta,normalize:r});e.push(...c.results);let{frontmatter:m,body:p}=P(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 I(o,u),e.push({fromTool:ta,fromPath:a,toPath:fy,feature:"rules"});return}}async function PD(t){let e=[],r=await W(ta,t);return await AJ(t,e,r),e.push(...await Y(Wd,t,"project",{normalize:r})),await et(t,ea,ta,e,r),e}var xD=d(()=>{gt();A();U();rt();Zl();ft();Ot();Tl();rR();s(AJ,"importRootRule");s(PD,"importFromJunie");});function TD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ta}))}var DD=d(()=>{Ct();Tl();s(TD,"lintRules");});function ND(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))vA(n)&&e.push(D(".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(()=>{ud();wt();s(ND,"lintMcp");});var bJ,PJ,xJ,TJ,Wd,rR=d(()=>{AD();Tl();oe();xD();DD();FD();Et();bJ={name:"junie",primaryRootInstructionPath:Vn,generateRules:ID,generateCommands:kD,generateAgents:ED,generateSkills:OD,generateMcp:CD,generateIgnore:LD,importFrom:PD},PJ={rootInstructionPath:Vn,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 `${Pm}/${t}.md`},commandPath(t,e){return `${Pl}/${t}.md`},agentPath(t,e){return `${xl}/${t}.md`}}},xJ={rootInstructionPath:ra,renderPrimaryRootInstruction:wD,skillDir:Dm,managedOutputs:{dirs:[Dm,Nm,Fm,fL],files:[ra,Vu]},rewriteGeneratedPath(t){return t===Vn?ra:t.startsWith(`${Pm}/`)?ra:t.startsWith(`${ea}/`)?t.replace(`${ea}/`,`${Dm}/`):t.startsWith(`${Pl}/`)?t.replace(`${Pl}/`,`${Fm}/`):t.startsWith(`${xl}/`)?t.replace(`${xl}/`,`${Nm}/`):t===bm?Vu:t===xm?null:t},mirrorGlobalPath(t,e){return dt(t,".junie/skills",e)},paths:{rulePath(t,e){return ra},commandPath(t,e){return `${Fm}/${t}.md`},agentPath(t,e){return `${Nm}/${t}.md`}}},TJ={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Wd={id:"junie",metadata:{displayName:"Junie",category:"ide",officialUrl:"https://www.jetbrains.com/junie",shortDescription:"JetBrains AI coding agent"},generators:bJ,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:TD,lint:{mcp:ND},project:PJ,globalSupport:{capabilities:TJ,detectionPaths:[ra,Dm,Nm,Fm,Vu],layout:xJ},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Ju,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:gL,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:hL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[bm]},canonicalDir:".agentsmesh",canonicalFilename:yL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[xm]},canonicalDir:".agentsmesh",canonicalFilename:_L}},buildImportPaths:gy,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function MD(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Jn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Ie))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 $D(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 GD(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 jD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:zs,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function UD(t){return t.ignore.length===0?[]:[{path:Dl,content:t.ignore.join(`
141
+ `)}]}function BD(t){return st(t,nn)}var KD=d(()=>{rt();U();ca();s(MD,"generateRules");s($D,"generateCommands");s(GD,"generateAgents");s(jD,"generateMcp");s(UD,"generateIgnore");s(BD,"generateSkills");});var Hd,zd,WD,oR=d(()=>{U();ft();ca();Hd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Ys}/${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"),zd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Ml}/${t}`,content:await St(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),WD=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${la}/${t}`,content:await Yt(n,o,i)}},"kiloAgentMapper");});async function HD(t){try{return await stat(t),!0}catch{return false}}async function FJ(t,e,r){let n=join(t,na);if(!await HD(n))return;let o=join(t,Ys),i=join(n,iR),l=e.some(c=>c.toPath===sR)?null:await _(i);if(l!==null){let c=join(t,sR),m=r(l,i,c),{body:p}=P(m),u=await z(c,{root:true},p);await I(c,u),e.push({feature:"rules",fromTool:Ie,fromPath:`${na}/${iR}`,toPath:sR});}e.push(...await It({srcDir:n,destDir:o,extensions:[".md"],fromTool:Ie,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await Hd({absolutePath:c,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===iR||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function vJ(t,e,r){let n=join(t,Nl);if(!await HD(n))return;let o=join(t,Ml);e.push(...await It({srcDir:n,destDir:o,extensions:[".md"],fromTool:Ie,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:l,normalizeTo:c})=>{let m=await zd({absolutePath:i,relativePath:a,content:l,destDir:o,normalizeTo:c});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function MJ(t,e,r){let n=join(t,Xu),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,la,`${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}
138
142
 
139
143
  ## When to use
140
144
 
141
- ${f}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let R=await Yt(m,h,g),k=r(R,n,m);await S(m,k),e.push({feature:"agents",fromTool:Se,fromPath:n,toPath:`${ia}/${c}.md`});}}async function TD(t,e={}){let r=e.scope??"project",n=[],o=await W(Se,t,r);return n.push(...await Y(jd,t,r,{normalize:o})),await et(t,rn,Se,n,o),r==="project"&&(await sJ(t,n,o),await iJ(t,n,o),await aJ(t,n,o),await et(t,ra,Se,n,o)),n}var J_,Y_,xD=d(()=>{gt();rt();Me();Ot();A();ft();U();V_();aa();X_();J_=`${Vs}/_root.md`,Y_="00-root.md";s(PD,"pathExists");s(sJ,"importLegacyRules");s(iJ,"importLegacyWorkflows");s(aJ,"importLegacyModes");s(TD,"importFromKiloCode");});function DD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Se}))}var ND=d(()=>{Ct();aa();s(DD,"lintRules");});function FD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function vD(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?[]:[D(".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 MD=d(()=>{wt();s(FD,"lintHooks");s(vD,"lintPermissions");});var lJ,cJ,mJ,$D,jd,X_=d(()=>{AD();aa();oe();xD();V_();ND();MD();Et();lJ={name:Se,primaryRootInstructionPath:zn,generateRules:CD,generateCommands:kD,generateAgents:ED,generateSkills:wD,generateMcp:LD,generateIgnore:OD,importFrom:TD},cJ={rootInstructionPath:zn,skillDir:rn,managedOutputs:{dirs:[Yo,Xo,Zo,rn],files:[zn,Ws,Pl]},paths:{rulePath(t,e){return `${Yo}/${t}.md`},commandPath(t,e){return `${Xo}/${t}.md`},agentPath(t,e){return `${Zo}/${t}.md`}}},mJ={rootInstructionPath:Hs,skillDir:zs,managedOutputs:{dirs:[na,oa,sa,zs,sL],files:[Hs,Dl,Wu]},rewriteGeneratedPath(t){return t===zn?Hs:t},mirrorGlobalPath(t,e){return dt(t,zs,e)},paths:{rulePath(t,e){return `${na}/${t}.md`},commandPath(t,e){return `${oa}/${t}.md`},agentPath(t,e){return `${sa}/${t}.md`}}},$D={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},jd={id:Se,metadata:{displayName:"Kilo Code",category:"ide",officialUrl:"https://kilocode.ai",shortDescription:"Open-source AI coding agent for VS Code"},generators:lJ,capabilities:$D,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:DD,lint:{hooks:FD,permissions:vD},project:cJ,globalSupport:{capabilities:$D,detectionPaths:[Hs,na,oa,sa,zs,Dl,Wu],layout:mJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[zn],global:[Hs]},canonicalDir:Vs,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Yo],global:[na]},canonicalDir:Vs,extensions:[".md"],map:$d}],commands:{feature:"commands",mode:"directory",source:{project:[Xo],global:[oa]},canonicalDir:Nl,extensions:[".md"],map:Gd},agents:{feature:"agents",mode:"directory",source:{project:[Zo],global:[sa]},canonicalDir:ia,extensions:[".md"],map:bD},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ws,Dm],global:[Dl]},canonicalDir:".agentsmesh",canonicalFilename:iL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Pl],global:[Wu]},canonicalDir:".agentsmesh",canonicalFilename:aL}},buildImportPaths:sy,detectionPaths:[Yo,Xo,Zo,rn,Ws,ea,Tl,ra,Dm,Ku,Pl,"kilo.jsonc","kilo.json"]};});function GD(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function dJ(t){return t.type==="prompt"?t.prompt:t.command}function fJ(t,e){let r=jD[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function UD(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in jD)||!Array.isArray(n))continue;let i=1;for(let a of n){let l=dJ(a);if(!l)continue;let c={name:`${GD(r)} ${i}`,version:"1",when:fJ(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:l}:{type:"shellCommand",command:l}};e.push({name:`${GD(r)}-${i}.kiro.hook`,content:JSON.stringify(c,null,2)}),i+=1;}}return e}function gJ(t){let e=uJ.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:gJ(r)}function KD(t){return stringify(t).trimEnd()}var jD,uJ,Z_=d(()=>{jD={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},uJ=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(GD,"toKebab");s(dJ,"hookText");s(fJ,"toWhen");s(UD,"generateKiroHooks");s(gJ,"toCanonicalEntry");s(BD,"parseKiroHookFile");s(KD,"serializeCanonicalHooks");});function yJ(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 WD(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:x(yJ(n),n.body.trim()||"")});}return e}function HD(t){return t.commands.map(e=>({path:`${Ce}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function zD(t){return st(t,Ce)}function VD(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Fl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function JD(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:UD(t.hooks).map(e=>({path:`${Js}/${e.name}`,content:e.content}))}function YD(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=x(r,e.body.trim()||"");return {path:`${sn}/${e.name}.md`,content:n}})}function XD(t){return t.ignore.length===0?[]:[{path:vl,content:t.ignore.join(`
142
- `)}]}var ZD=d(()=>{rt();Lt();U();Z_();Ml();s(yJ,"steeringFrontmatter");s(WD,"generateRules");s(HD,"generateCommands");s(zD,"generateSkills");s(VD,"generateMcp");s(JD,"generateHooks");s(YD,"generateAgents");s(XD,"generateIgnore");});function RJ(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 IJ(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,iy),{frontmatter:m,body:p}=P(r(l,a,c));await S(c,await z(c,{...m,root:true},p)),e.push({fromTool:We,fromPath:a,toPath:iy,feature:"rules"});return}}async function SJ(t,e,r){let n=join(t,ay);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}=P(i(a));return {destPath:a,toPath:`${ay}/${o}`,feature:"rules",content:await z(a,RJ(l),c)}},"mapEntry")}));}async function CJ(t,e){let r={};for(let o of await G(join(t,Js))){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,ly);await O(join(t,".agentsmesh")),await S(n,KD(r)),e.push({fromTool:We,fromPath:join(t,Js),toPath:ly,feature:"hooks"});}async function QD(t,e={}){let r=e.scope??"project",n=[],o=await W(We,t,r);return await IJ(t,n,o,r),await SJ(t,n,o),n.push(...await Y(Ud,t,r,{normalize:o})),await et(t,Ce,We,n,o),r==="project"&&await CJ(t,n),n}var qD=d(()=>{gt();rt();Me();Ot();ft();cr();A();U();Z_();Ml();Q_();s(RJ,"canonicalRuleMeta");s(IJ,"importRoot");s(SJ,"importNonRootRules");s(CJ,"importHooks");s(QD,"importFromKiro");});function tN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:We}))}var eN=d(()=>{Ct();Ml();s(tN,"lintRules");});function rN(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=>Ds(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var nN=d(()=>{wt();s(rN,"lintHooks");});var kJ,EJ,LJ,OJ,Ud,Q_=d(()=>{Lt();ZD();oe();qD();eN();nN();Et();Ml();kJ={name:We,primaryRootInstructionPath:nn,generateRules:WD,generateCommands:HD,generateAgents:YD,generateSkills:zD,generateMcp:VD,generateHooks:JD,generateIgnore:XD,importFrom:QD},EJ={rootInstructionPath:nn,skillDir:Ce,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 `${Ce}/${V(t)}/SKILL.md`},agentPath(t,e){return `${sn}/${t}.md`}}},LJ={rootInstructionPath:an,skillDir:Ys,managedOutputs:{dirs:[la,Ys,ca,cL],files:[an,Fm,vm]},rewriteGeneratedPath(t){return t===nn?an:t.startsWith(`${on}/`)?t.replace(`${on}/`,`${la}/`):t.startsWith(`${Ce}/`)?t.replace(`${Ce}/`,`${Ys}/`):t.startsWith(`${sn}/`)?t.replace(`${sn}/`,`${ca}/`):t===Fl?Fm:t===vl?vm:t.startsWith(`${Js}/`)?null:t},mirrorGlobalPath(t,e){return dt(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${la}/${t}.md`},commandPath(t){return `${Ce}/${V(t)}/SKILL.md`},agentPath(t,e){return `${ca}/${t}.md`}}},OJ={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Ud={id:We,metadata:{displayName:"Kiro",category:"ide",officialUrl:"https://kiro.dev",shortDescription:"AWS spec-driven AI IDE"},generators:kJ,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:tN,lint:{hooks:rN},project:EJ,globalSupport:{capabilities:OJ,detectionPaths:[la,an,Ys,ca,Fm,vm],layout:LJ},importer:{agents:{feature:"agents",mode:"directory",source:{project:[sn],global:[sn]},canonicalDir:mL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Fl],global:[Fm]},canonicalDir:".agentsmesh",canonicalFilename:pL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[vl],global:[vm]},canonicalDir:".agentsmesh",canonicalFilename:uL}},buildImportPaths:cy,detectionPaths:[on,Ce,sn,Js,Fl,vl],conversionDefaults:{commandsToSkills:true}};});function sN(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?x(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Qo}/${o}.md`,content:a});}return e}function iN(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${qo}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function aN(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:x(n,e.body.trim()||"")}})}function wJ(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 lN(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]=wJ(n);return [{path:Jn,content:JSON.stringify({mcp:e},null,2)}]}function cN(t){return st(t,cn)}var mN=d(()=>{rt();U();da();s(sN,"generateRules");s(iN,"generateCommands");s(aN,"generateAgents");s(wJ,"toOpenCodeMcpServer");s(lN,"generateMcp");s(cN,"generateSkills");});function q_(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 bJ(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:q_(a.headers),env:q_(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:q_(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function PJ(t,e,r){let o=join(t,e==="global"?Qs:Jn),i=await _(o);if(i===null)return;let a=bJ(i);Object.keys(a).length!==0&&(await Ht(t,my,a),r.push({feature:"mcp",fromTool:ln,fromPath:o,toPath:my}));}async function pN(t,e={}){let r=e.scope??"project",n=[],o=await W(ln,t,r);return n.push(...await Y(Bd,t,r,{normalize:o})),await et(t,cn,ln,n,o),await PJ(t,r,n),n}var uN=d(()=>{gt();rt();Ot();Vr();A();da();tR();s(q_,"toStringRecord");s(bJ,"parseOpenCodeMcp");s(PJ,"importMcp");s(pN,"importFromOpenCode");});var dN,fN,gN,hN=d(()=>{U();ft();da();dN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Mm}/${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"),fN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${zu}/${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"),gN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Vu}/${t}`,content:await Yt(n,o,i)}},"opencodeAgentMapper");});function yN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ln}))}var _N=d(()=>{Ct();da();s(yN,"lintRules");});function RN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function IN(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?[]:[D(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function SN(t){return t.ignore.length===0?[]:[D(".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(()=>{wt();s(RN,"lintHooks");s(IN,"lintPermissions");s(SN,"lintIgnore");});var TJ,xJ,DJ,kN,Bd,tR=d(()=>{mN();da();oe();uN();hN();_N();CN();Et();TJ={name:ln,primaryRootInstructionPath:Vn,generateRules:sN,generateCommands:iN,generateAgents:aN,generateSkills:cN,generateMcp:lN,importFrom:pN},xJ={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`}}},DJ={rootInstructionPath:Xs,skillDir:Zs,managedOutputs:{dirs:[ma,pa,ua,Zs,fL],files:[Xs,Qs]},rewriteGeneratedPath(t){return t===Vn?Xs:t===Jn?Qs:t},mirrorGlobalPath(t,e){return dt(t,Zs,e)},paths:{rulePath(t){return `${ma}/${t}.md`},commandPath(t){return `${pa}/${t}.md`},agentPath(t){return `${ua}/${t}.md`}}},kN={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Bd={id:ln,metadata:{displayName:"OpenCode",category:"cli",officialUrl:"https://opencode.ai",shortDescription:"Open-source terminal AI agent"},generators:TJ,capabilities:kN,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:yN,lint:{hooks:RN,permissions:IN,ignore:SN},project:xJ,globalSupport:{capabilities:kN,detectionPaths:[Xs,ma,pa,ua,Zs,Qs],layout:DJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Vn],global:[Xs]},canonicalDir:Mm,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Qo],global:[ma]},canonicalDir:Mm,extensions:[".md"],map:dN}],commands:{feature:"commands",mode:"directory",source:{project:[qo],global:[pa]},canonicalDir:zu,extensions:[".md"],map:fN},agents:{feature:"agents",mode:"directory",source:{project:[ts],global:[ua]},canonicalDir:Vu,extensions:[".md"],map:gN}},buildImportPaths:py,detectionPaths:[Qo,qo,ts,cn,Jn,"opencode.jsonc"]};});function EN(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 LN(t){return st(t,re)}function ON(t){return t.commands.map(e=>({path:`${re}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function wN(t){return t.agents.map(e=>({path:`${re}/${K(e.name)}/SKILL.md`,content:xt(e)}))}var AN=d(()=>{rt();Wt();ut();Lt();Gl();s(EN,"generateRules");s(LN,"generateSkills");s(ON,"generateCommands");s(wN,"generateAgents");});async function bN(t,e={}){let r=e.scope??"project",n=[],o=await W(Yn,t,r);return n.push(...await Y(Kd,t,r,{normalize:o})),await et(t,r==="global"?Or:re,Yn,n,o),n}var PN=d(()=>{gt();rt();Ot();Gl();rR();s(bN,"importFromPiAgent");});function TN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Yn}))}var xN=d(()=>{Ct();Gl();s(TN,"lintRules");});function DN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","pi-agent","Pi Coding Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function NN(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?[]:[D(".agentsmesh/permissions.yaml","pi-agent","Pi Coding Agent has no dedicated permissions config; canonical permissions are not projected.")]}function FN(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","pi-agent","Pi Coding Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function vN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".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 MN=d(()=>{wt();s(DN,"lintHooks");s(NN,"lintPermissions");s(FN,"lintIgnore");s(vN,"lintMcp");});var NJ,FJ,vJ,$N,Kd,rR=d(()=>{Lt();ut();AN();oe();PN();xN();MN();dy();Gl();NJ={name:Yn,primaryRootInstructionPath:Lr,generateRules:EN,generateCommands:ON,generateAgents:wN,generateSkills:LN,importFrom:bN},FJ={rootInstructionPath:Lr,skillDir:re,managedOutputs:{dirs:[re],files:[Lr]},paths:{rulePath(t){return Lr},commandPath(t){return `${re}/${V(t)}/SKILL.md`},agentPath(t){return `${re}/${K(t)}/SKILL.md`}}},vJ={rootInstructionPath:es,skillDir:Or,managedOutputs:{dirs:[Or],files:[es]},rewriteGeneratedPath(t){return t===Lr?es:t.startsWith(`${re}/`)?t.replace(`${re}/`,`${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}/${K(t)}/SKILL.md`}}},$N={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Kd={id:Yn,metadata:{displayName:"Pi Agent",category:"cli",officialUrl:"https://github.com/pi-labs/pi-agent",shortDescription:"Pi coding agent"},generators:NJ,capabilities:$N,emptyImportMessage:"No Pi Coding Agent config found (AGENTS.md or .pi/skills).",lintRules:TN,lint:{hooks:DN,permissions:NN,ignore:FN,mcp:vN},supportsConversion:{commands:true,agents:true},project:FJ,globalSupport:{capabilities:$N,detectionPaths:[es],layout:vJ},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Lr],global:[es]},canonicalDir:yL,canonicalRootFilename:"_root.md",markAsRoot:true}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:uy,detectionPaths:[Lr,re]};});function GN(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=x(a,o.body.trim()||"");e.push({path:`${rs}/${i}.md`,content:l});}return e}function jN(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=x(r,e.body.trim()||"");return {path:`${Zn}/${e.name}.md`,content:n}})}function UN(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=x(r,e.body.trim()||"");return {path:`${Qn}/${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=x(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 KN(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:qs,content:e}]}function WN(t){return !t.ignore||t.ignore.length===0?[]:[{path:ti,content:t.ignore.join(`
143
- `)}]}var HN=d(()=>{U();jl();s(GN,"generateRules");s(jN,"generateCommands");s(UN,"generateAgents");s(BN,"generateSkills");s(KN,"generateMcp");s(WN,"generateIgnore");});async function zN(t,e={}){let r=e.scope??"project",n=[],o=await W(Xn,t,r);return n.push(...await Y(Wd,t,r,{normalize:o})),await et(t,r==="global"?qn:He,Xn,n,o),n}var VN=d(()=>{gt();Ot();rt();jl();nR();s(zN,"importFromQwenCode");});function JN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Xn}))}var YN=d(()=>{Ct();jl();s(JN,"lintRules");});var $J,GJ,jJ,UJ,BJ,Wd,nR=d(()=>{HN();VN();YN();Et();jl();$J={name:Xn,primaryRootInstructionPath:wr,generateRules:GN,generateCommands:jN,generateAgents:UN,generateSkills:BN,generateMcp:KN,generateIgnore:WN,importFrom:zN},GJ={rootInstructionPath:wr,skillDir:He,managedOutputs:{dirs:[rs,Zn,Qn,He],files:[wr,qs,ti]},paths:{rulePath(t,e){return e.root?wr:`${rs}/${t}.md`},commandPath(t){return `${Zn}/${t}.md`},agentPath(t){return `${Qn}/${t}.md`}}},jJ={rootInstructionPath:ns,skillDir:qn,managedOutputs:{dirs:[ei,ri,qn],files:[ns,fa]},rewriteGeneratedPath(t){return t===wr?ns:t===qs?fa:t===ti?null:t.startsWith(`${Zn}/`)?t.replace(`${Zn}/`,`${ei}/`):t.startsWith(`${Qn}/`)?t.replace(`${Qn}/`,`${ri}/`):t.startsWith(`${He}/`)?t.replace(`${He}/`,`${qn}/`):t.startsWith(`${rs}/`)?null:t},paths:{rulePath(t,e){return ns},commandPath(t){return `${ei}/${t}.md`},agentPath(t){return `${ri}/${t}.md`}}},UJ={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},BJ={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Wd={id:Xn,metadata:{displayName:"Qwen Code",category:"cli",officialUrl:"https://github.com/QwenLM/qwen-code",shortDescription:"Alibaba's Qwen coding CLI"},generators:$J,capabilities:UJ,emptyImportMessage:"No Qwen Code config found (QWEN.md or .qwen/rules, .qwen/commands, .qwen/settings.json).",lintRules:JN,project:GJ,globalSupport:{capabilities:BJ,detectionPaths:[ns,fa,ei,ri,qn],layout:jJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[wr],global:[ns]},canonicalDir:fy,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[rs],global:[]},canonicalDir:fy,extensions:[".md"],preset:"rule"}],commands:{feature:"commands",mode:"directory",source:{project:[Zn],global:[ei]},canonicalDir:_L,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[Qn],global:[ri]},canonicalDir:RL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[qs],global:[fa]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/mcp.json"},ignore:{feature:"ignore",mode:"flatFile",source:{project:[ti],global:[]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/ignore"}},buildImportPaths:gy,detectionPaths:[wr,".qwen/settings.json",".qwen/commands",".qwen/rules"]};});function XN(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 ZN(t){return st(t,Pe)}function QN(t){return t.commands.map(e=>({path:`${Pe}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function qN(t){return t.agents.map(e=>({path:`${Pe}/${K(e.name)}/SKILL.md`,content:xt(e)}))}var tF=d(()=>{rt();Wt();ut();Lt();Ul();s(XN,"generateRules");s(ZN,"generateSkills");s(QN,"generateCommands");s(qN,"generateAgents");});async function eF(t,e={}){let r=e.scope??"project",n=[],o=await W(to,t,r);return n.push(...await Y(Hd,t,r,{normalize:o})),await et(t,Pe,to,n,o),n}var rF=d(()=>{gt();rt();Ot();Ul();oR();s(eF,"importFromReplitAgent");});function nF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:to}))}var oF=d(()=>{Ct();Ul();s(nF,"lintRules");});function sF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","replit-agent","Replit Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function iF(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?[]:[D(".agentsmesh/permissions.yaml","replit-agent","Replit Agent permissions are managed in the cloud UI; canonical permissions are not projected.")]}function aF(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","replit-agent","Replit Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function lF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".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 cF=d(()=>{wt();s(sF,"lintHooks");s(iF,"lintPermissions");s(aF,"lintIgnore");s(lF,"lintMcp");});var KJ,WJ,HJ,Hd,oR=d(()=>{Lt();ut();tF();rF();oF();cF();yy();Ul();KJ={name:to,primaryRootInstructionPath:mn,generateRules:XN,generateCommands:QN,generateAgents:qN,generateSkills:ZN,importFrom:eF},WJ={rootInstructionPath:mn,skillDir:Pe,managedOutputs:{dirs:[Pe],files:[mn]},paths:{rulePath(t){return mn},commandPath(t){return `${Pe}/${V(t)}/SKILL.md`},agentPath(t){return `${Pe}/${K(t)}/SKILL.md`}}},HJ={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Hd={id:to,metadata:{displayName:"Replit Agent",category:"agent-platform",officialUrl:"https://replit.com",shortDescription:"Replit's autonomous coding agent"},generators:KJ,capabilities:HJ,emptyImportMessage:"No Replit Agent config found (replit.md or .agents/skills).",lintRules:nF,lint:{hooks:sF,permissions:iF,ignore:aF,mcp:lF},supportsConversion:{commands:true,agents:true},project:WJ,sharedArtifacts:{".agents/skills/":"consumer"},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[mn]},canonicalDir:SL,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:hy,detectionPaths:[mn]};});function pF(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(ni))continue;let o=basename(n.source,".md");e.push({path:`${os}/${o}.md`,content:n.body.trim()||""});}return e}function uF(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${ss}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function dF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Gm,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function fF(t){return t.ignore.length===0?[]:[{path:jm,content:t.ignore.join(`
144
- `)}]}function gF(t){return st(t,eo)}function hF(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:Bl,content:stringify({customModes:e})}]}var yF=d(()=>{rt();U();_a();s(pF,"generateRules");s(uF,"generateCommands");s(dF,"generateMcp");s(fF,"generateIgnore");s(gF,"generateSkills");s(hF,"generateAgents");});var zd,RF,sR=d(()=>{U();ft();_a();zd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${ya}/${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"),RF=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Yu}/${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,ga),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,ya);for(let l of i)e.push(...await St({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:ni,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await zd({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function IF(t,e={}){let r=e.scope??"project",n=[],o=await W(ni,t,r);return n.push(...await Y(Vd,t,r,{normalize:o})),await JJ(t,n,o),await et(t,eo,ni,n,o),n}var SF=d(()=>{gt();rt();Me();Ot();sR();_a();aR();s(JJ,"importPerModeRules");s(IF,"importFromRooCode");});function CF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ni}))}var kF=d(()=>{Ct();_a();s(CF,"lintRules");});function tY(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var QJ,qJ,eY,rY,nY,Vd,aR=d(()=>{A();yF();_a();oe();SF();sR();kF();Et();QJ={name:"roo-code",primaryRootInstructionPath:pn,generateRules:pF,generateCommands:uF,generateSkills:gF,generateMcp:dF,generateIgnore:fF,generateAgents:hF,importFrom:IF},qJ={rootInstructionPath:pn,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Bl]},paths:{rulePath(t,e){return `${os}/${t}.md`},commandPath(t,e){return `${ss}/${t}.md`},agentPath(t,e){return null}}};s(tY,"computeStatus");eY=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,Um));return [{target:"roo-code",path:Um,content:i,currentContent:a??void 0,status:tY(a,i)}]},"generateRooGlobalExtras"),rY={rootInstructionPath:ii,skillDir:is,managedOutputs:{dirs:[oi,si,is,CL],files:[ii,ha,Bm,Um]},rewriteGeneratedPath(t){return t===pn?ii:t===Bl?null:t.startsWith(`${os}/`)?t.replace(`${os}/`,`${oi}/`):t.startsWith(`${ss}/`)?t.replace(`${ss}/`,`${si}/`):t.startsWith(`${eo}/`)?t.replace(`${eo}/`,`${is}/`):t===Gm?ha:t===jm?Bm:t},mirrorGlobalPath(t,e){return dt(t,is,e)},paths:{rulePath(t,e){return `${oi}/${t}.md`},commandPath(t,e){return `${si}/${t}.md`},agentPath(t,e){return null}}},nY={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Vd={id:"roo-code",metadata:{displayName:"Roo Code",category:"ide",officialUrl:"https://roocode.com",shortDescription:"Open-source AI VS Code extension"},generators:QJ,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:qJ,globalSupport:{capabilities:nY,detectionPaths:[oi,si,is,ha,Bm,ii,Um],layout:rY,scopeExtras:eY},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[pn,$m],global:[ii,pn,$m]},canonicalDir:ya,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:[oi]},canonicalDir:ya,extensions:[".md"],map:zd}],commands:{feature:"commands",mode:"directory",source:{project:[ss],global:[si]},canonicalDir:Yu,extensions:[".md"],map:RF},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Gm],global:[ha]},canonicalDir:".agentsmesh",canonicalFilename:kL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[jm],global:[Bm]},canonicalDir:".agentsmesh",canonicalFilename:EL}},buildImportPaths:_y,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Bl]};});function EF(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 LF(t){return st(t,ne)}function OF(t){return t.commands.map(e=>({path:`${ne}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function wF(t){return t.agents.map(e=>({path:`${ne}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function AF(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 bF=d(()=>{rt();Wt();ut();Lt();Wl();s(EF,"generateRules");s(LF,"generateSkills");s(OF,"generateCommands");s(wF,"generateAgents");s(AF,"generateMcp");});async function PF(t,e={}){let r=e.scope??"project",n=[],o=await W(ro,t,r);return n.push(...await Y(Jd,t,r,{normalize:o})),await et(t,r==="global"?ze:ne,ro,n,o),n}var TF=d(()=>{gt();rt();Ot();Wl();lR();s(PF,"importFromRovodev");});function xF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ro}))}var DF=d(()=>{Ct();Wl();s(xF,"lintRules");});function NF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","rovodev","Rovo Dev has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function FF(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?[]:[D(".agentsmesh/permissions.yaml","rovodev","Rovo Dev permissions are managed in config.yaml; canonical permissions are not projected.")]}function vF(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","rovodev","Rovo Dev has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var MF=d(()=>{wt();s(NF,"lintHooks");s(FF,"lintPermissions");s(vF,"lintIgnore");});var oY,sY,iY,aY,lY,Jd,lR=d(()=>{Lt();ut();bF();oe();TF();DF();MF();Et();Wl();oY={name:ro,primaryRootInstructionPath:Ar,generateRules:EF,generateCommands:OF,generateAgents:wF,generateSkills:LF,generateMcp:AF,importFrom:PF},sY={rootInstructionPath:Ar,skillDir:ne,managedOutputs:{dirs:[ne],files:[Ar,as]},paths:{rulePath(t){return Ar},commandPath(t){return `${ne}/${V(t)}/SKILL.md`},agentPath(t){return `${ne}/${K(t)}/SKILL.md`}}},iY={rootInstructionPath:ls,skillDir:ze,managedOutputs:{dirs:[ze],files:[ls,Kl]},rewriteGeneratedPath(t){return t===Ar?ls:t.startsWith(`${ne}/`)?t.replace(`${ne}/`,`${ze}/`):t===as?Kl: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}/${K(t)}/SKILL.md`}}},aY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},lY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Jd={id:ro,metadata:{displayName:"Rovo Dev",category:"cli",officialUrl:"https://www.atlassian.com/solutions/devops/rovo-dev",shortDescription:"Atlassian's coding agent"},generators:oY,capabilities:aY,emptyImportMessage:"No Rovo Dev config found (AGENTS.md, .rovodev/skills, or .rovodev/mcp.json).",lintRules:xF,lint:{hooks:NF,permissions:FF,ignore:vF},supportsConversion:{commands:true,agents:true},project:sY,globalSupport:{capabilities:lY,detectionPaths:[wL,ls,ze],layout:iY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ar],global:[ls]},canonicalDir:AL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[as],global:[Kl]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Ry,detectionPaths:[Ar,ne,as]};});function $F(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 GF(t){return st(t,Pr)}function jF(t){return t.mcp===null||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ra,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function UF(t){return t.ignore.length===0?[]:[{path:Hl,content:t.ignore.join(`
145
- `)}]}var BF=d(()=>{rt();zl();s($F,"generateRules");s(GF,"generateSkills");s(jF,"generateMcp");s(UF,"generateIgnore");});async function pY(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,KF),{frontmatter:m,body:p}=P(r(l,a,c));await O(join(t,Wm)),await S(c,await z(c,{...m,root:true},p)),e.push({fromTool:br,fromPath:a,toPath:KF,feature:"rules"});return}}async function uY(t,e,r,n){let o=join(t,n==="global"?cs:Ve),i=join(t,Wm);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}=P(l(m));return {destPath:m,toPath:`${Wm}/${a}`,feature:"rules",content:await z(m,{...p,root:false},u)}},"mapEntry")}));}async function WF(t,e={}){let r=e.scope??"project",n=[],o=await W(br,t,r);return await pY(t,n,o,r),await uY(t,n,o,r),n.push(...await Y(Yd,t,r,{normalize:o})),await et(t,r==="global"?un:Pr,br,n,o),n}var KF,HF=d(()=>{gt();rt();Me();Ot();ft();A();U();zl();cR();KF=`${Wm}/_root.md`;s(pY,"importRoot");s(uY,"importNonRootRules");s(WF,"importFromTrae");});function zF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:br}))}var VF=d(()=>{Ct();zl();s(zF,"lintRules");});var dY,fY,gY,hY,Yd,cR=d(()=>{BF();oe();HF();VF();Et();zl();dY={name:br,primaryRootInstructionPath:Je,generateRules:$F,generateSkills:GF,generateMcp:jF,generateIgnore:UF,importFrom:WF},fY={rootInstructionPath:Je,skillDir:Pr,managedOutputs:{dirs:[Ve,Pr],files:[Ra,Hl]},paths:{rulePath(t,e){return `${Ve}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},gY={rootInstructionPath:Tr,skillDir:un,managedOutputs:{dirs:[cs,un,PL],files:[Tr,Km]},rewriteGeneratedPath(t){return t===Je?Tr:t.startsWith(`${Ve}/`)?t.replace(`${Ve}/`,`${cs}/`):t.startsWith(`${Pr}/`)?t.replace(`${Pr}/`,`${un}/`):t===Ra?Km:t===Hl?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}}},hY={rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Yd={id:br,metadata:{displayName:"Trae",category:"ide",officialUrl:"https://www.trae.ai",shortDescription:"ByteDance's adaptive AI IDE"},generators:dY,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:zF,project:fY,globalSupport:{capabilities:hY,detectionPaths:[Tr,cs,un,Km],layout:gY},importer:{mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ra],global:[Km]},canonicalDir:".agentsmesh",canonicalFilename:TL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Hl]},canonicalDir:".agentsmesh",canonicalFilename:xL}},buildImportPaths:Iy,detectionPaths:[Ve,Ra,Je]};});function JF(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 YF(t){return st(t,he)}function XF(t){return t.commands.map(e=>({path:`${he}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function ZF(t){return t.agents.map(e=>({path:`${he}/${K(e.name)}/SKILL.md`,content:xt(e)}))}function QF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ai,content:e}]}var qF=d(()=>{rt();Wt();ut();Lt();Vl();s(JF,"generateRules");s(YF,"generateSkills");s(XF,"generateCommands");s(ZF,"generateAgents");s(QF,"generateMcp");});async function tv(t,e={}){let r=e.scope??"project",n=[],o=await W(no,t,r);return n.push(...await Y(Xd,t,r,{normalize:o})),await et(t,r==="global"?Ye:he,no,n,o),n}var ev=d(()=>{gt();rt();Ot();Vl();mR();s(tv,"importFromWarp");});function rv(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:no}))}var nv=d(()=>{Ct();Vl();s(rv,"lintRules");});function ov(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function sv(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?[]:[D(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function iv(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var av=d(()=>{wt();s(ov,"lintHooks");s(sv,"lintPermissions");s(iv,"lintIgnore");});var yY,_Y,RY,IY,SY,Xd,mR=d(()=>{Lt();ut();qF();oe();ev();nv();av();Et();Vl();yY={name:no,primaryRootInstructionPath:dn,generateRules:JF,generateCommands:XF,generateAgents:ZF,generateSkills:YF,generateMcp:QF,importFrom:tv},_Y={rootInstructionPath:dn,skillDir:he,managedOutputs:{dirs:[he],files:[dn,ai]},paths:{rulePath(t){return dn},commandPath(t){return `${he}/${V(t)}/SKILL.md`},agentPath(t){return `${he}/${K(t)}/SKILL.md`}}},RY={rootInstructionPath:void 0,skillDir:Ye,managedOutputs:{dirs:[Ye],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${he}/`)?t.replace(`${he}/`,`${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}/${K(t)}/SKILL.md`}}},IY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},SY={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Xd={id:no,metadata:{displayName:"Warp",category:"cli",officialUrl:"https://www.warp.dev",shortDescription:"AI-powered terminal"},generators:yY,capabilities:IY,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:rv,lint:{hooks:ov,permissions:sv,ignore:iv},supportsConversion:{commands:true,agents:true},project:_Y,globalSupport:{capabilities:SY,detectionPaths:[Ye],layout:RY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Sy,dn]},canonicalDir:NL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ai]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Cy,detectionPaths:[dn,Sy,ai],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});var uo,pR,gi,lv,cc,fo,mc,pc,cv,hi,yn,uc,uR,mv,pv,dR,fR,gR,dc,fc,op,Zd,Qd,qd,uv,Ee=d(()=>{uo="windsurf",pR=".windsurfrules",gi=".windsurf/rules",lv=".windsurfignore",cc=".codeiumignore",fo="AGENTS.md",mc=".windsurf/hooks.json",pc=".windsurf/mcp_config.example.json",cv=".windsurf/mcp_config.json",hi=".windsurf/workflows",yn=".windsurf/skills",uc=".agentsmesh/rules",uR=".agentsmesh/commands",mv=".agentsmesh/agents",pv=".agentsmesh/skills",dR=".agentsmesh/ignore",fR=".agentsmesh/hooks.yaml",gR=".agentsmesh/mcp.json",dc=".codeium/windsurf/memories/global_rules.md",fc=".codeium/windsurf/skills",op=".codeium/windsurf/global_workflows",Zd=".codeium/windsurf/hooks.json",Qd=".codeium/windsurf/mcp_config.json",qd=".codeium/.codeiumignore",uv=".agents/skills";});function kY(t){let e=basename(t,".md");return e==="_root"?"root":e}function EY(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 hR(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=kY(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?x(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${gi}/${o}.md`,content:l});let c=EY(n.globs);c&&(c!==o&&e.push({path:`${gi}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var dv=d(()=>{U();Ee();s(kY,"ruleSlug");s(EY,"directoryScopedRuleDir");s(hR,"generateRules");});function yR(t){return !t.ignore||t.ignore.length===0?[]:[{path:cc,content:t.ignore.join(`
146
- `)}]}var fv=d(()=>{Ee();s(yR,"generateIgnore");});function _R(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?x(r,e.body.trim()||""):e.body.trim();return {path:`${hi}/${e.name}.md`,content:n}})}var gv=d(()=>{U();Ee();s(_R,"generateCommands");});function RR(t){return t.agents.map(e=>({path:`${yn}/${K(e.name)}/SKILL.md`,content:xt(e)}))}var hv=d(()=>{ut();Ee();s(RR,"generateAgents");});function IR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:pc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var yv=d(()=>{Ee();s(IR,"generateMcp");});function LY(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 OY(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=Jt(i),l=Re(i),c=i.type==="prompt"?l||a:a||l;c&&o.push({command:c,show_output:true});}o.length>0&&(e[LY(r)]=o);}return e}function SR(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=OY(t.hooks);return Object.keys(e).length===0?[]:[{path:mc,content:JSON.stringify({hooks:e},null,2)}]}var _v=d(()=>{Ur();Ee();s(LY,"windsurfEventName");s(OY,"toWindsurfHooks");s(SR,"generateHooks");});function CR(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?x(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 Rv=d(()=>{U();Ee();s(CR,"generateSkills");});var Iv=d(()=>{dv();fv();gv();hv();yv();_v();Rv();});var Sv=d(()=>{Iv();});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 kv(t,e,r){let n=join(t,hi),i=(await G(n)).filter(l=>l.endsWith(".md")),a=join(t,uR);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}=P(u),h=await It(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 S(p,h),e.push({fromTool:uo,fromPath:l,toPath:`${uR}/${m}`,feature:"commands"});}}var Ev=d(()=>{A();U();ft();Ee();s(Cv,"toStringArray");s(kv,"importWorkflows");});async function Lv(t,e,r,n=yn){await Xl([n],{projectRoot:t,destCanonicalSkillsDir:pv,targetName:"windsurf",normalize:r,results:e},[Zl({canonicalAgentsDir:mv})]);}var Ov=d(()=>{Ql();Ee();s(Lv,"importSkills");});async function Av(t,e){let r=join(t,mc),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=PY(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,fR);await O(dirname(a)),await S(a,stringify(i)),e.push({fromTool:uo,fromPath:r,toPath:fR,feature:"hooks"});}catch{}}function bY(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 PY(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=bY(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 bv(t,e){let r=[pc,cv];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,gR);await O(dirname(l)),await S(l,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:uo,fromPath:o,toPath:gR,feature:"mcp"});return}catch{}}}var Pv=d(()=>{A();Ee();s(Av,"importWindsurfHooks");s(bY,"canonicalHookEventName");s(PY,"windsurfHooksToCanonical");s(bv,"importWindsurfMcp");});async function Tv(t,e){let r=e?.scope??"project",n=[],o=await W(uo,t),i=await W("codex-cli",t),a=join(t,uc),l=join(t,pR),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:`${uc}/_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"),R=o(i(g,f,h),f,h).trim(),k=await z(h,{root:true},R);await S(h,k),n.push({fromTool:"windsurf",fromPath:f,toPath:`${uc}/_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 R=h.replace(/\//g,"-");if(!yu(h))return await Ln(join(a,`${R}.md`)),null;let k=join(a,`${R}.md`);return {destPath:k,toPath:`${uc}/${R}.md`,feature:"rules",content:await z(k,{root:false,globs:[`${h}/**`]},g(k))}},"mapEntry")}));let m=join(t,gi);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:R,body:k}=P(g(h)),I={...R};return typeof I.glob=="string"&&I.glob.trim()&&(I.globs=[I.glob],delete I.glob),{destPath:h,toPath:`${uc}/${f}`,feature:"rules",content:await z(h,{...I,root:false},k)}},"mapEntry")}));let p=join(t,lv),u=await _(p);if((u===null||!u.trim())&&(p=join(t,cc),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,dR);await S(h,g.join(`
147
- `)),n.push({fromTool:"windsurf",fromPath:p,toPath:dR,feature:"ignore"});}}return await kv(t,n,o),await Lv(t,n,o),await Av(t,n),await bv(t,n),n}var xv=d(()=>{gt();A();U();ft();Me();om();Ee();Ev();Ov();Pv();s(Tv,"importFromWindsurf");});function Dv(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 Nv=d(()=>{Ee();s(Dv,"lintRules");});function Fv(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>D(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function vv(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var Mv=d(()=>{wt();s(Fv,"lintCommands");s(vv,"lintMcp");});function FY(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 vY,MY,$Y,GY,$v,Gv=d(()=>{Sv();xi();Ee();oe();xv();Nv();Mv();Et();al();ut();s(FY,"directoryScopedRuleDir");vY={name:"windsurf",primaryRootInstructionPath:fo,generateRules:hR,generateCommands:_R,generateAgents:RR,generateSkills:CR,generateMcp:IR,generateHooks:SR,generateIgnore:yR,importFrom:Tv},MY={rootInstructionPath:fo,extraRuleOutputPaths(t){if(t.root)return [fo];let e=FY(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 `${gi}/${t}.md`},commandPath(t,e){return `${hi}/${t}.md`},agentPath(t,e){return or(e,"windsurf")?`.windsurf/skills/${K(t)}/SKILL.md`:null}}},$Y={rootInstructionPath:dc,skillDir:fc,managedOutputs:{dirs:[fc,op,uv],files:[dc,Zd,Qd,qd]},rewriteGeneratedPath(t){return t===fo?dc:t.startsWith(`${gi}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${yn}/`)?t.replace(`${yn}/`,`${fc}/`):t.startsWith(`${hi}/`)?t.replace(`${hi}/`,`${op}/`):t===mc?Zd:t===pc?Qd:t===cc?qd:t},mirrorGlobalPath(t,e){return dt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return dc},commandPath(t,e){return `${op}/${t}.md`},agentPath(t,e){return or(e,"windsurf")?`${fc}/${K(t)}/SKILL.md`:null}}},GY={rules:"native",additionalRules:"partial",commands:Kr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},$v={id:"windsurf",metadata:{displayName:"Windsurf",category:"ide",officialUrl:"https://windsurf.com",shortDescription:"Codeium's agentic IDE"},generators:vY,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:Dv,lint:{commands:Fv,mcp:vv},project:MY,globalSupport:{capabilities:GY,detectionPaths:[dc,fc,op,Zd,Qd,qd],layout:$Y},buildImportPaths:ky,detectionPaths:[".windsurfrules",".windsurf"],conversionDefaults:{agentsToSkills:true}};});function jv(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 Uv=d(()=>{Wt();Ia();s(jv,"generateRules");});async function Kv(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 Ht(t,Bv,l),r.push({fromTool:"zed",fromPath:e,toPath:Bv,feature:"mcp"}));}var Bv,Wv=d(()=>{A();Vr();Ia();Bv=".agentsmesh/mcp.json";s(Kv,"importZedMcp");});async function Hv(t,e={}){let r=e.scope??"project",n=[],o=await W("zed",t,r);return n.push(...await Y(ef,t,r,{normalize:o})),await Kv(t,r==="global"?so:oo,n),n}var zv=d(()=>{gt();Ot();Wv();Ia();ER();s(Hv,"importFromZed");});function Vv(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var Jv=d(()=>{Ct();Ia();s(Vv,"lintRules");});function Yv(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Xv(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?[]:[D(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function Zv(t){return t.ignore.length===0?[]:[D(".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 Qv=d(()=>{wt();s(Yv,"lintHooks");s(Xv,"lintPermissions");s(Zv,"lintIgnore");});function zY(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 UY,BY,KY,WY,HY,ef,ER=d(()=>{Uv();zv();Jv();Qv();Et();Ia();UY={name:"zed",primaryRootInstructionPath:fn,generateRules:jv,importFrom:Hv},BY={rootInstructionPath:fn,managedOutputs:{dirs:[],files:[fn,oo]},paths:{rulePath(t){return fn},commandPath(){return null},agentPath(){return null}}},KY={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[so]},rewriteGeneratedPath(t){return t===oo?so:t},paths:{rulePath(){return so},commandPath(){return null},agentPath(){return null}}},WY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},HY={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(zY,"mergeZedSettings");ef={id:"zed",metadata:{displayName:"Zed",category:"ide",officialUrl:"https://zed.dev",shortDescription:"Collaborative AI editor"},generators:UY,capabilities:WY,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:Vv,lint:{hooks:Yv,permissions:Xv,ignore:Zv},project:BY,globalSupport:{capabilities:HY,detectionPaths:[so],layout:KY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[fn],global:[]},canonicalDir:ML,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?zY(t,r):null},buildImportPaths:Ey,detectionPaths:[fn,oo]};});var dE={};Cg(dE,{BUILTIN_TARGETS:()=>Pt,TARGET_IDS:()=>$t,getBuiltinTargetDefinition:()=>Fr,getEffectiveTargetSupportLevel:()=>rf,getTargetCapabilities:()=>di,getTargetDetectionPaths:()=>OR,getTargetLayout:()=>Kt,getTargetManagedOutputs:()=>wR,getTargetPrimaryRootInstructionPath:()=>JY,getTargetSkillDir:()=>sp,isBuiltinTargetId:()=>Fe,resolveTargetFeatureGenerator:()=>gc,rewriteGeneratedOutputPath:()=>AR});function VY(){return LR||(VC(Pt),LR=new Map(Pt.map(t=>[t.id,t]))),LR}function Fr(t){return VY().get(t)}function di(t,e="project"){let r=Fr(t)??nt(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return HC(n)}function OR(t,e="project"){let r=Fr(t)??nt(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function Kt(t,e="project"){let r=Fr(t)??nt(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function JY(t,e="project"){return Kt(t,e)?.rootInstructionPath}function sp(t,e="project"){return Kt(t,e)?.skillDir}function wR(t,e="project"){return Kt(t,e)?.managedOutputs}function AR(t,e,r="project"){let n=Kt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function qv(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!il(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!or(r,t.id,true,n):false}function YY(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?il(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?or(r,t.id,true,n):false}function rf(t,e,r,n="project"){let o=di(t,n)?.[e]?.level??"none",i=Fr(t)??nt(t);return o==="none"&&YY(i,e,r,n)?"embedded":o!=="embedded"?o:qv(i,e,r,n)?"none":o}function gc(t,e,r,n="project"){let o=Fr(t)??nt(t);if(!o?.generators||qv(o,e,r,n))return;let i=XY[e];return i===null?void 0:i(o.generators)}var Pt,LR,XY,Tt=d(()=>{al();xi();ce();th();Sn();_h();Ly();Oy();Ay();zO();Ty();iA();XA();Qy();o_();i_();S_();C_();k_();B_();K_();W_();H_();X_();Q_();tR();rR();nR();oR();aR();lR();cR();mR();Gv();ER();Pt=[Su,Zu,Qu,qu,HO,td,sA,YA,ad,dd,gd,Ed,Ld,Od,Nd,Fd,vd,Md,jd,Ud,Bd,Kd,Wd,Hd,Vd,Jd,Yd,Xd,$v,ef];s(VY,"builtinTargetsMap");s(Fr,"getBuiltinTargetDefinition");s(di,"getTargetCapabilities");s(OR,"getTargetDetectionPaths");s(Kt,"getTargetLayout");s(JY,"getTargetPrimaryRootInstructionPath");s(sp,"getTargetSkillDir");s(wR,"getTargetManagedOutputs");s(AR,"rewriteGeneratedOutputPath");s(qv,"isFeatureSuppressedByConversion");s(YY,"isConversionUpgrading");s(rf,"getEffectiveTargetSupportLevel");XY={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(gc,"resolveTargetFeatureGenerator");});function qY(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 nf(t){let e=[];for(let n of Pt){let o=0,i=0;for(let a of n.detectionPaths){if(!await j(join(t,a)))continue;let l=QY.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(qY);let r=e[0];return r.uniqueHits===0?null:r.id}var QY,tM,bR=d(()=>{A();Tt();QY=(()=>{let t=new Map;for(let e of Pt)for(let r of e.detectionPaths)t.set(r,(t.get(r)??0)+1);return t})();s(qY,"compare");s(nf,"detectNativeFormat");tM=Pt.map(t=>t.detectionPaths[0]).filter(t=>t!==void 0);});async function ip(t,e){let r=nt(e);if(!r)throw new Error(`No importer registered for native target: ${e}`);return r.generators.importFrom(t)}var PR=d(()=>{ce();s(ip,"importNativeToCanonical");});async function Na(t){if(!await j(t))return false;if(await j(join(t,xR)))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,xR)))return !0}catch{return false}return false}async function ap(t,e={}){if(!await j(t))return [];if(await j(join(t,xR))){let r=await ou(t,e);return r?[r]:[]}return As(t,e)}var xR,of=d(()=>{A();ol();xR="SKILL.md";s(Na,"isSkillPackLayout");s(ap,"loadSkillsAtExtendPath");});async function sf(t,e={}){return (await ws(t,e)).filter(n=>!Cn(basename(n.source)))}async function af(t,e={}){return (await Os(t,e)).filter(n=>!Cn(basename(n.source)))}async function lf(t,e={}){return (await Ls(t,e)).filter(n=>!Cn(basename(n.source)))}async function eM(t,e={}){return As(t,e)}var cf=d(()=>{Zc();Xc();Yc();ol();Eo();s(sf,"importAgents");s(af,"importCommands");s(lf,"importRules");s(eM,"importSkills");});function NR(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 FR(t){return t.toLowerCase().endsWith(".md")}function nM(t,e){for(let r of NR(nt(t)?.importer,e))if(r.extensions.some(n=>!FR(n)))return true;return false}function a2(t,e){let r=new Set;for(let n of NR(nt(t)?.importer,e))for(let o of n.extensions)FR(o)||r.add(o.toLowerCase());return r}function l2(t){return BC().filter(e=>nM(e,t))}async function p2(t,e,r){return c2[t](e,r)}async function u2(t,e,r){return m2[t](e,r)}async function d2(t,e,r,n={}){let o=NR(nt(e)?.importer,r),i=await G(t),a=new Set;for(let p of o)for(let u of p.extensions)FR(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 R of o){if(!R.extensions.some(C=>u.toLowerCase().endsWith(C.toLowerCase())))continue;let I=await R.map({absolutePath:u,relativePath:g,content:f,destDir:c,normalizeTo:s(()=>f,"normalizeTo")});if(I){h=I;break}}h&&(await O(dirname(h.destPath)),await S(h.destPath,h.content));}return {entities:await p2(r,c,n),cleanup:m}}catch(p){throw await m(),p}}async function vR(t,e,r={}){let n=r.restrictToTarget,o=n?nM(n,e)?[n]:[]:l2(e),i=new Set;for(let f of o)for(let g of a2(f,e))i.add(g);let a=await u2(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 d2(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 mf(t,e={}){let r=await vR(t,"commands",e);return {commands:[...r.entities],cleanup:r.cleanup}}async function pf(t,e={}){let r=await vR(t,"rules",e);return {rules:[...r.entities],cleanup:r.cleanup}}async function uf(t,e={}){let r=await vR(t,"agents",e);return {agents:[...r.entities],cleanup:r.cleanup}}var c2,m2,df=d(()=>{Zc();Xc();Yc();A();ce();Eo();cf();s(NR,"directorySpecsFor");s(FR,"isMarkdownExtension");s(nM,"hasNonMdEntityMapper");s(a2,"nonMdEntityExtensions");s(l2,"targetsWithNonMdEntityMapper");c2={rules:Ls,commands:Os,agents:ws},m2={rules:lf,commands:af,agents:sf};s(p2,"parseEntityDir");s(u2,"importEntities");s(d2,"readToolNativeEntities");s(vR,"readEntityDirWithMappers");s(mf,"readCommandsDirWithMappers");s(pf,"readRulesDirWithMappers");s(uf,"readAgentsDirWithMappers");});function h2(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function y2(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 ff(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 GR(t,e){if(basename(t)===e)return t;let r=join(t,e);return await j(r)?r:null}async function _2(t,e,r){let n=s(async()=>{},"noop"),o=await GR(t,"rules");if(!o)return {rules:[],cleanup:n};if(!r)return {rules:await lf(o,e),cleanup:n};let i=await pf(o,{parseOpts:e});return {rules:[...i.rules],cleanup:i.cleanup}}async function R2(t,e,r){let n=s(async()=>{},"noop"),o=await GR(t,"commands");if(!o)return {commands:[],cleanup:n};if(!r)return {commands:await af(o,e),cleanup:n};let i=await mf(o,{parseOpts:e});return {commands:[...i.commands],cleanup:i.cleanup}}async function I2(t,e,r){let n=s(async()=>{},"noop"),o=await GR(t,"agents");if(!o)return {agents:[],cleanup:n};if(!r)return {agents:await sf(o,e),cleanup:n};let i=await uf(o,{parseOpts:e});return {agents:[...i.agents],cleanup:i.cleanup}}async function S2(t,e){if(await Na(t))return ap(t,e);let r=join(t,"skills");return await Na(r)?ap(r,e):[]}async function gf(t,e={}){let r=s(async()=>{},"noop"),n=join(t,".agentsmesh");if(await j(n))return {canonical:await we(t,e),cleanup:r};let o=e.enableTargetEntityMappers??false,i=h2(),a=await _2(t,e,o);i.rules=a.rules;let l=await R2(t,e,o);i.commands=l.commands;let c=await I2(t,e,o);i.agents=c.agents,i.skills=await S2(t,e);let m=s(async()=>{await Promise.allSettled([a.cleanup(),l.cleanup(),c.cleanup()]);},"mergedCleanup");if(y2(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 jR=d(()=>{A();cf();df();Ti();of();s(h2,"emptyCanonical");s(y2,"isCanonicalSliceEmpty");s(ff,"normalizeSlicePath");s(GR,"resolveEntityDir");s(_2,"parseRulesAt");s(R2,"parseCommandsAt");s(I2,"parseAgentsAt");s(S2,"loadSkillsForPartialSlice");s(gf,"loadCanonicalSliceAtPath");});async function hf(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 oM(t,e){await cp(t,e,{recursive:true,filter:s(r=>{let n=relative(t,r).replace(/\\/g,"/");if(n==="")return true;let o=n.split("/")[0];return !(TC(o)||!n.includes("/")&&(ru(n)||xC(n)))},"filter")});}var UR=d(()=>{A();U();Eo();s(hf,"readSkillFrontmatterName");s(oM,"cpFilteredSkill");});function BR(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function E2(t){let e={...t},r=t.alwaysApply===true;if(e.root=r,delete e.alwaysApply,!r){let n=BR(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 L2(t){let e={...t};return e.trigger==="always"&&(e.trigger="always_on"),typeof e.glob=="string"&&(e.globs=BR(e.globs).length>0?BR(e.globs):[e.glob],delete e.glob),e}function KR(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=E2(r):"trigger"in r||"glob"in r?o=L2(r):o=r,x(o,n.trim())}var sM=d(()=>{U();s(BR,"toStrArray");s(E2,"normalizeCursorKeys");s(L2,"normalizeWindsurfKeys");s(KR,"normalizeMdcToCanonical");});function WR(t){return t.toLowerCase().replace(/[^a-z0-9.-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function HR(t){return t.toLowerCase().endsWith(".mdc")?basename(t).replace(/\.mdc$/i,".md"):basename(t)}function aM(t,e,r){let o=relative(t,e).replace(/\\/g,"/").split("/");if(o.pop(),o.length===0)return r;let i=WR(o[o.length-1]);return i?`${i}-${r}`:r}var lM=d(()=>{s(WR,"sanitizeNameSegment");s(HR,"computeDestName");s(aM,"namespacedName");});async function P2(){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 uM(t,e){let r=t.toLowerCase();return !!(r.endsWith(".md")||e&&r.endsWith(".mdc"))}async function T2(t,e,r){if(!uM(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(t,join(e,basename(t)));}async function x2(t,e,r){if((await stat(t)).isFile())return T2(t,e,r);let o=(await G(t)).filter(l=>uM(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=HR(l);i.set(c,(i.get(c)??0)+1);}let a=new Map;await O(e);for(let l of o){let c=HR(l),p=(i.get(c)??0)>1?aM(t,l,c):c;if(a.has(p)&&a.get(p)!==l){let f=relative(t,l).replace(/\\/g,"/").split("/").map(WR).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(l,join(e,p));}}async function cM(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await G(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(o.get(i),join(e,i),{recursive:true});return true}async function D2(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(dirname(t),i,{recursive:true});return}if(await Na(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await cM(t,e,r.preferredSkillNames??[]))return;let l=await hf(join(t,"SKILL.md"))||basename(t),c=join(e,l);await O(e),await oM(t,c);return}if(await cM(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await G(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(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 _f(t,e,r={}){let n=await P2();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await D2(t,o,r):await x2(t,o,e==="rules"),n}catch(o){throw await n.cleanup(),o}}var VR=d(()=>{A();of();UR();Eo();sM();lM();s(P2,"createStageRoot");s(uM,"isAcceptedFile");s(T2,"stageSingleFile");s(x2,"stageMarkdownCollection");s(cM,"stagePreferredSkills");s(D2,"stageSkills");s(_f,"stageManualInstallScope");});function N2(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function dM(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 _f(o,t.as);try{return we(join(i.discoveryRoot,".agentsmesh"))}finally{await i.cleanup();}}if(!t.path){let o=join(e,".agentsmesh");if(!await j(o)){if(await Na(e)){let a=await ap(e);return {...N2(),skills:a}}let i=t.target??await nf(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
148
- Expected one of: .agentsmesh/, ${tM.join(", ")}.`);y.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await ip(e,i);}return we(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 ip(e,t.target)),we(e)}let{sliceRoot:n}=await ff(r);try{let{canonical:o}=await gf(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 fM=d(()=>{bR();A();ot();Ti();PR();of();jR();VR();s(N2,"emptyCanonical");s(dM,"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 JR=d(()=>{ot();s(Rf,"applyExtendPick");});var M2,hc,If=d(()=>{M2=["rules","commands","agents","skills"],hc=z$1.enum(M2);});var $2,gM,hM=d(()=>{So();If();$2=z$1.enum(["github","gitlab","git","local"]),gM=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:$2,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(Qa).min(1),pick:Kc.optional(),target:nr.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:hc.optional(),content_hash:z$1.string(),license:z$1.string().nullable().optional()});});function yM(t){let e=bi(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 j2(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}async function yi(t){let e=join(t,"pack.yaml"),r=await _(e);if(r===null)return null;try{let n=parse(r);return gM.parse(n)}catch{return null}}async function RM(t,e,r){if(!await j(t))return null;let n=yM(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 yi(a);if(l&&yM(l.source)===n&&l.target===r.target&&l.as===r.as&&j2(l.features,r.features))return {meta:l,packDir:a,name:l.name}}return null}async function Sf(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 yi(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}var yc=d(()=>{A();hM();zc();s(yM,"sourceIdentity");s(j2,"sameFeatures");s(yi,"readPackMetadata");s(RM,"findExistingPack");s(Sf,"listPacks");});function IM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function U2(t){let[e,r,n,o,i,a,l,c]=await Promise.all([Ls(join(t,"rules")),Os(join(t,"commands")),ws(join(t,"agents")),As(join(t,"skills")),jr(join(t,"mcp.json")),su(join(t,"permissions.yaml")),iu(join(t,"hooks.yaml")),au(join(t,"ignore"))]);return {...IM(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:l,ignore:c}}async function SM(t){let e=join(t,"packs"),r=await Sf(e),n=IM();for(let{meta:o,packDir:i}of r){let a=await U2(i),l=XR(a,o.features),c=Rf(l,o.features,o.pick,o.name);n=sl(n,c);}return n}var CM=d(()=>{Yc();Xc();Zc();ol();Qc();zg();Jg();Yg();Zg();ho();JR();yc();s(IM,"emptyCanonical");s(U2,"loadPackCanonical");s(SM,"loadPacksCanonical");});function XR(t,e){if(e.length===0)return kM();let r=new Set(e.flatMap(n=>K2[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 kM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function Oe(t,e,r={},n=join(e,".agentsmesh")){let o=await rl(t,e,{refreshCache:r.refreshRemoteCache===true}),i=kM();for(let c of o){let m=await dM(c),p=XR(m,c.features),u=Rf(p,c.features,c.pick,c.name);i=sl(i,u);}let a=await SM(n);i=sl(i,a);let l=await we(n);return i=sl(i,l),{canonical:i,resolvedExtends:o}}var K2,ho=d(()=>{Zp();Ti();Zg();fM();JR();CM();K2={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(XR,"filterCanonicalByFeatures");s(kM,"emptyCanonical");s(Oe,"loadCanonicalWithExtends");});function jX(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 UX(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}function r$(t){try{return realpathSync(t)}catch{return t}}function n$(t,e){let r=r$(resolve(e)),n=r$(t);if(!(n===r||n.startsWith(`${r}${sep}`)))throw new Error(`Plugin source resolves outside project root (escapes ${r}): ${n}`)}async function BX(t,e){let{source:r}=t,n;if(UX(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);n$(a,e),n=pathToFileURL(a).href;}else {let i=jX(r,e);n$(i,e),n=pathToFileURL(i).href;}return await import(n)}function KX(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function Nf(t,e){let r;try{r=await BX(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=KX(r),o=[];for(let i of n)try{let a=lu(i);mu(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 o$(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 Nf(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(`
145
+ ${f}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let S=await Yt(m,h,g),C=r(S,n,m);await I(m,C),e.push({feature:"agents",fromTool:Ie,fromPath:n,toPath:`${la}/${c}.md`});}}async function zD(t,e={}){let r=e.scope??"project",n=[],o=await W(Ie,t,r);return n.push(...await Y(Vd,t,r,{normalize:o})),await et(t,nn,Ie,n,o),r==="project"&&(await FJ(t,n,o),await vJ(t,n,o),await MJ(t,n,o),await et(t,oa,Ie,n,o)),n}var sR,iR,VD=d(()=>{gt();rt();$e();Ot();A();ft();U();oR();ca();aR();sR=`${Ys}/_root.md`,iR="00-root.md";s(HD,"pathExists");s(FJ,"importLegacyRules");s(vJ,"importLegacyWorkflows");s(MJ,"importLegacyModes");s(zD,"importFromKiloCode");});function JD(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Ie}))}var YD=d(()=>{Ct();ca();s(JD,"lintRules");});function XD(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function ZD(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?[]:[D(".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 QD=d(()=>{wt();s(XD,"lintHooks");s(ZD,"lintPermissions");});var $J,GJ,jJ,qD,Vd,aR=d(()=>{KD();ca();oe();VD();oR();YD();QD();Et();$J={name:Ie,primaryRootInstructionPath:Jn,generateRules:MD,generateCommands:$D,generateAgents:GD,generateSkills:BD,generateMcp:jD,generateIgnore:UD,importFrom:zD},GJ={rootInstructionPath:Jn,skillDir:nn,managedOutputs:{dirs:[Xo,Zo,Qo,nn],files:[Jn,zs,Dl]},paths:{rulePath(t,e){return `${Xo}/${t}.md`},commandPath(t,e){return `${Zo}/${t}.md`},agentPath(t,e){return `${Qo}/${t}.md`}}},jJ={rootInstructionPath:Vs,skillDir:Js,managedOutputs:{dirs:[sa,ia,aa,Js,SL],files:[Vs,vl,Zu]},rewriteGeneratedPath(t){return t===Jn?Vs:t},mirrorGlobalPath(t,e){return dt(t,Js,e)},paths:{rulePath(t,e){return `${sa}/${t}.md`},commandPath(t,e){return `${ia}/${t}.md`},agentPath(t,e){return `${aa}/${t}.md`}}},qD={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Vd={id:Ie,metadata:{displayName:"Kilo Code",category:"ide",officialUrl:"https://kilocode.ai",shortDescription:"Open-source AI coding agent for VS Code"},generators:$J,capabilities:qD,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:JD,lint:{hooks:XD,permissions:ZD},project:GJ,globalSupport:{capabilities:qD,detectionPaths:[Vs,sa,ia,aa,Js,vl,Zu],layout:jJ},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Jn],global:[Vs]},canonicalDir:Ys,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Xo],global:[sa]},canonicalDir:Ys,extensions:[".md"],map:Hd}],commands:{feature:"commands",mode:"directory",source:{project:[Zo],global:[ia]},canonicalDir:Ml,extensions:[".md"],map:zd},agents:{feature:"agents",mode:"directory",source:{project:[Qo],global:[aa]},canonicalDir:la,extensions:[".md"],map:WD},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[zs,Mm],global:[vl]},canonicalDir:".agentsmesh",canonicalFilename:IL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Dl],global:[Zu]},canonicalDir:".agentsmesh",canonicalFilename:CL}},buildImportPaths:hy,detectionPaths:[Xo,Zo,Qo,nn,zs,na,Nl,oa,Mm,Xu,Dl,"kilo.jsonc","kilo.json"]};});function tN(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function KJ(t){return t.type==="prompt"?t.prompt:t.command}function WJ(t,e){let r=eN[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function rN(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in eN)||!Array.isArray(n))continue;let i=1;for(let a of n){let l=KJ(a);if(!l)continue;let c={name:`${tN(r)} ${i}`,version:"1",when:WJ(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:l}:{type:"shellCommand",command:l}};e.push({name:`${tN(r)}-${i}.kiro.hook`,content:JSON.stringify(c,null,2)}),i+=1;}}return e}function HJ(t){let e=BJ.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 nN(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:HJ(r)}function oN(t){return stringify(t).trimEnd()}var eN,BJ,lR=d(()=>{eN={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},BJ=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(tN,"toKebab");s(KJ,"hookText");s(WJ,"toWhen");s(rN,"generateKiroHooks");s(HJ,"toCanonicalEntry");s(nN,"parseKiroHookFile");s(oN,"serializeCanonicalHooks");});function VJ(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 sN(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:on,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(He))continue;let o=basename(n.source,".md");e.push({path:`${sn}/${o}.md`,content:T(VJ(n),n.body.trim()||"")});}return e}function iN(t){return t.commands.map(e=>({path:`${Ce}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function aN(t){return st(t,Ce)}function lN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:$l,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function cN(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:rN(t.hooks).map(e=>({path:`${Xs}/${e.name}`,content:e.content}))}function mN(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:`${an}/${e.name}.md`,content:n}})}function pN(t){return t.ignore.length===0?[]:[{path:Gl,content:t.ignore.join(`
146
+ `)}]}var uN=d(()=>{rt();Lt();U();lR();jl();s(VJ,"steeringFrontmatter");s(sN,"generateRules");s(iN,"generateCommands");s(aN,"generateSkills");s(lN,"generateMcp");s(cN,"generateHooks");s(mN,"generateAgents");s(pN,"generateIgnore");});function YJ(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:xo(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function XJ(t,e,r,n){let o=n==="global"?[ln,on]:[on,ln];for(let i of o){let a=join(t,i),l=await _(a);if(l===null)continue;let c=join(t,yy),{frontmatter:m,body:p}=P(r(l,a,c));await I(c,await z(c,{...m,root:true},p)),e.push({fromTool:He,fromPath:a,toPath:yy,feature:"rules"});return}}async function ZJ(t,e,r){let n=join(t,_y);e.push(...await It({srcDir:join(t,sn),destDir:n,extensions:[".md"],fromTool:He,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}=P(i(a));return {destPath:a,toPath:`${_y}/${o}`,feature:"rules",content:await z(a,YJ(l),c)}},"mapEntry")}));}async function QJ(t,e){let r={};for(let o of await G(join(t,Xs))){if(!o.endsWith(".kiro.hook"))continue;let i=nN(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 I(n,oN(r)),e.push({fromTool:He,fromPath:join(t,Xs),toPath:Ry,feature:"hooks"});}async function dN(t,e={}){let r=e.scope??"project",n=[],o=await W(He,t,r);return await XJ(t,n,o,r),await ZJ(t,n,o),n.push(...await Y(Jd,t,r,{normalize:o})),await et(t,Ce,He,n,o),r==="project"&&await QJ(t,n),n}var fN=d(()=>{gt();rt();$e();Ot();ft();mr();A();U();lR();jl();cR();s(YJ,"canonicalRuleMeta");s(XJ,"importRoot");s(ZJ,"importNonRootRules");s(QJ,"importHooks");s(dN,"importFromKiro");});function gN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:He}))}var hN=d(()=>{Ct();jl();s(gN,"lintRules");});function yN(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=>Fs(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var _N=d(()=>{wt();s(yN,"lintHooks");});var qJ,tY,eY,rY,Jd,cR=d(()=>{Lt();uN();oe();fN();hN();_N();Et();jl();qJ={name:He,primaryRootInstructionPath:on,generateRules:sN,generateCommands:iN,generateAgents:mN,generateSkills:aN,generateMcp:lN,generateHooks:cN,generateIgnore:pN,importFrom:dN},tY={rootInstructionPath:on,skillDir:Ce,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${sn}/${t}.md`},commandPath(t){return `${Ce}/${V(t)}/SKILL.md`},agentPath(t,e){return `${an}/${t}.md`}}},eY={rootInstructionPath:ln,skillDir:Zs,managedOutputs:{dirs:[ma,Zs,pa,EL],files:[ln,Gm,jm]},rewriteGeneratedPath(t){return t===on?ln:t.startsWith(`${sn}/`)?t.replace(`${sn}/`,`${ma}/`):t.startsWith(`${Ce}/`)?t.replace(`${Ce}/`,`${Zs}/`):t.startsWith(`${an}/`)?t.replace(`${an}/`,`${pa}/`):t===$l?Gm:t===Gl?jm:t.startsWith(`${Xs}/`)?null:t},mirrorGlobalPath(t,e){return dt(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${ma}/${t}.md`},commandPath(t){return `${Ce}/${V(t)}/SKILL.md`},agentPath(t,e){return `${pa}/${t}.md`}}},rY={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Jd={id:He,metadata:{displayName:"Kiro",category:"ide",officialUrl:"https://kiro.dev",shortDescription:"AWS spec-driven AI IDE"},generators:qJ,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:gN,lint:{hooks:yN},project:tY,globalSupport:{capabilities:rY,detectionPaths:[ma,ln,Zs,pa,Gm,jm],layout:eY},importer:{agents:{feature:"agents",mode:"directory",source:{project:[an],global:[an]},canonicalDir:LL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[$l],global:[Gm]},canonicalDir:".agentsmesh",canonicalFilename:OL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Gl],global:[jm]},canonicalDir:".agentsmesh",canonicalFilename:wL}},buildImportPaths:Sy,detectionPaths:[sn,Ce,an,Xs,$l,Gl],conversionDefaults:{commandsToSkills:true}};});function SN(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Yn,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(cn))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 IN(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${ts}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function CN(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:`${es}/${r}.md`,content:T(n,e.body.trim()||"")}})}function nY(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 kN(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]=nY(n);return [{path:Xn,content:JSON.stringify({mcp:e},null,2)}]}function EN(t){return st(t,mn)}var LN=d(()=>{rt();U();ga();s(SN,"generateRules");s(IN,"generateCommands");s(CN,"generateAgents");s(nY,"toOpenCodeMcpServer");s(kN,"generateMcp");s(EN,"generateSkills");});function mR(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 sY(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:mR(a.headers),env:mR(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:mR(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function iY(t,e,r){let o=join(t,e==="global"?ti:Xn),i=await _(o);if(i===null)return;let a=sY(i);Object.keys(a).length!==0&&(await Ht(t,Iy,a),r.push({feature:"mcp",fromTool:cn,fromPath:o,toPath:Iy}));}async function ON(t,e={}){let r=e.scope??"project",n=[],o=await W(cn,t,r);return n.push(...await Y(Yd,t,r,{normalize:o})),await et(t,mn,cn,n,o),await iY(t,r,n),n}var wN=d(()=>{gt();rt();Ot();Jr();A();ga();pR();s(mR,"toStringRecord");s(sY,"parseOpenCodeMcp");s(iY,"importMcp");s(ON,"importFromOpenCode");});var AN,bN,PN,xN=d(()=>{U();ft();ga();AN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Um}/${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"),bN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${qu}/${t}`,content:await St(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),PN=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${td}/${t}`,content:await Yt(n,o,i)}},"opencodeAgentMapper");});function TN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:cn}))}var DN=d(()=>{Ct();ga();s(TN,"lintRules");});function NN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".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?[]:[D(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function vN(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var MN=d(()=>{wt();s(NN,"lintHooks");s(FN,"lintPermissions");s(vN,"lintIgnore");});var aY,lY,cY,$N,Yd,pR=d(()=>{LN();ga();oe();wN();xN();DN();MN();Et();aY={name:cn,primaryRootInstructionPath:Yn,generateRules:SN,generateCommands:IN,generateAgents:CN,generateSkills:EN,generateMcp:kN,importFrom:ON},lY={rootInstructionPath:Yn,skillDir:mn,managedOutputs:{dirs:[qo,ts,es,mn],files:[Yn,Xn]},paths:{rulePath(t){return `${qo}/${t}.md`},commandPath(t){return `${ts}/${t}.md`},agentPath(t){return `${es}/${t}.md`}}},cY={rootInstructionPath:Qs,skillDir:qs,managedOutputs:{dirs:[ua,da,fa,qs,bL],files:[Qs,ti]},rewriteGeneratedPath(t){return t===Yn?Qs:t===Xn?ti:t},mirrorGlobalPath(t,e){return dt(t,qs,e)},paths:{rulePath(t){return `${ua}/${t}.md`},commandPath(t){return `${da}/${t}.md`},agentPath(t){return `${fa}/${t}.md`}}},$N={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Yd={id:cn,metadata:{displayName:"OpenCode",category:"cli",officialUrl:"https://opencode.ai",shortDescription:"Open-source terminal AI agent"},generators:aY,capabilities:$N,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:TN,lint:{hooks:NN,permissions:FN,ignore:vN},project:lY,globalSupport:{capabilities:$N,detectionPaths:[Qs,ua,da,fa,qs,ti],layout:cY},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Yn],global:[Qs]},canonicalDir:Um,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[qo],global:[ua]},canonicalDir:Um,extensions:[".md"],map:AN}],commands:{feature:"commands",mode:"directory",source:{project:[ts],global:[da]},canonicalDir:qu,extensions:[".md"],map:bN},agents:{feature:"agents",mode:"directory",source:{project:[es],global:[fa]},canonicalDir:td,extensions:[".md"],map:PN}},buildImportPaths:Cy,detectionPaths:[qo,ts,es,mn,Xn,"opencode.jsonc"]};});function GN(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Zn)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:Or,content:o}]:[]}function jN(t){return st(t,re)}function UN(t){return t.commands.map(e=>({path:`${re}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function BN(t){return t.agents.map(e=>({path:`${re}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}var KN=d(()=>{rt();Kt();ut();Lt();Bl();s(GN,"generateRules");s(jN,"generateSkills");s(UN,"generateCommands");s(BN,"generateAgents");});async function WN(t,e={}){let r=e.scope??"project",n=[],o=await W(Zn,t,r);return n.push(...await Y(Xd,t,r,{normalize:o})),await et(t,r==="global"?wr:re,Zn,n,o),n}var HN=d(()=>{gt();rt();Ot();Bl();dR();s(WN,"importFromPiAgent");});function zN(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Zn}))}var VN=d(()=>{Ct();Bl();s(zN,"lintRules");});function JN(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","pi-agent","Pi Coding Agent has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function YN(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?[]:[D(".agentsmesh/permissions.yaml","pi-agent","Pi Coding Agent has no dedicated permissions config; canonical permissions are not projected.")]}function XN(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","pi-agent","Pi Coding Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function ZN(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".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 QN=d(()=>{wt();s(JN,"lintHooks");s(YN,"lintPermissions");s(XN,"lintIgnore");s(ZN,"lintMcp");});var mY,pY,uY,qN,Xd,dR=d(()=>{Lt();ut();KN();oe();HN();VN();QN();Ey();Bl();mY={name:Zn,primaryRootInstructionPath:Or,generateRules:GN,generateCommands:UN,generateAgents:BN,generateSkills:jN,importFrom:WN},pY={rootInstructionPath:Or,skillDir:re,managedOutputs:{dirs:[re],files:[Or]},paths:{rulePath(t){return Or},commandPath(t){return `${re}/${V(t)}/SKILL.md`},agentPath(t){return `${re}/${K(t)}/SKILL.md`}}},uY={rootInstructionPath:rs,skillDir:wr,managedOutputs:{dirs:[wr],files:[rs]},rewriteGeneratedPath(t){return t===Or?rs:t.startsWith(`${re}/`)?t.replace(`${re}/`,`${wr}/`):t},mirrorGlobalPath(t,e){return dt(t,wr,e)},paths:{rulePath(t){return rs},commandPath(t){return `${wr}/${V(t)}/SKILL.md`},agentPath(t){return `${wr}/${K(t)}/SKILL.md`}}},qN={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Xd={id:Zn,metadata:{displayName:"Pi Agent",category:"cli",officialUrl:"https://github.com/pi-labs/pi-agent",shortDescription:"Pi coding agent"},generators:mY,capabilities:qN,emptyImportMessage:"No Pi Coding Agent config found (AGENTS.md or .pi/skills).",lintRules:zN,lint:{hooks:JN,permissions:YN,ignore:XN,mcp:ZN},supportsConversion:{commands:true,agents:true},project:pY,globalSupport:{capabilities:qN,detectionPaths:[rs],layout:uY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Or],global:[rs]},canonicalDir:TL,canonicalRootFilename:"_root.md",markAsRoot:true}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:ky,detectionPaths:[Or,re]};});function tF(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Ar,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes(pn)));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:`${ns}/${i}.md`,content:l});}return e}function eF(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:`${Qn}/${e.name}.md`,content:n}})}function rF(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 nF(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:`${ze}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${ze}/${r.name}/${a}`,content:i.content});}}return e}function oF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ei,content:e}]}function sF(t){return !t.ignore||t.ignore.length===0?[]:[{path:ri,content:t.ignore.join(`
147
+ `)}]}function iF(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes(pn));return at(e?.body.trim()??"",r)}var aF=d(()=>{U();Kt();Kl();s(tF,"generateRules");s(eF,"generateCommands");s(rF,"generateAgents");s(nF,"generateSkills");s(oF,"generateMcp");s(sF,"generateIgnore");s(iF,"renderQwenGlobalInstructions");});async function lF(t,e={}){let r=e.scope??"project",n=[],o=await W(pn,t,r);return n.push(...await Y(Zd,t,r,{normalize:o})),await et(t,r==="global"?to:ze,pn,n,o),n}var cF=d(()=>{gt();Ot();rt();Kl();fR();s(lF,"importFromQwenCode");});function mF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:pn}))}var pF=d(()=>{Ct();Kl();s(mF,"lintRules");});var fY,gY,hY,yY,_Y,Zd,fR=d(()=>{aF();cF();pF();Et();Kl();fY={name:pn,primaryRootInstructionPath:Ar,generateRules:tF,generateCommands:eF,generateAgents:rF,generateSkills:nF,generateMcp:oF,generateIgnore:sF,importFrom:lF},gY={rootInstructionPath:Ar,skillDir:ze,managedOutputs:{dirs:[ns,Qn,qn,ze],files:[Ar,ei,ri]},paths:{rulePath(t,e){return e.root?Ar:`${ns}/${t}.md`},commandPath(t){return `${Qn}/${t}.md`},agentPath(t){return `${qn}/${t}.md`}}},hY={rootInstructionPath:os,renderPrimaryRootInstruction:iF,skillDir:to,managedOutputs:{dirs:[ni,oi,to],files:[os,ha]},rewriteGeneratedPath(t){return t===Ar?os:t===ei?ha:t===ri?null:t.startsWith(`${Qn}/`)?t.replace(`${Qn}/`,`${ni}/`):t.startsWith(`${qn}/`)?t.replace(`${qn}/`,`${oi}/`):t.startsWith(`${ze}/`)?t.replace(`${ze}/`,`${to}/`):t.startsWith(`${ns}/`)?null:t},paths:{rulePath(t,e){return os},commandPath(t){return `${ni}/${t}.md`},agentPath(t){return `${oi}/${t}.md`}}},yY={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},_Y={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Zd={id:pn,metadata:{displayName:"Qwen Code",category:"cli",officialUrl:"https://github.com/QwenLM/qwen-code",shortDescription:"Alibaba's Qwen coding CLI"},generators:fY,capabilities:yY,emptyImportMessage:"No Qwen Code config found (QWEN.md or .qwen/rules, .qwen/commands, .qwen/settings.json).",lintRules:mF,project:gY,globalSupport:{capabilities:_Y,detectionPaths:[os,ha,ni,oi,to],layout:hY},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Ar],global:[os]},canonicalDir:Ly,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[ns],global:[]},canonicalDir:Ly,extensions:[".md"],preset:"rule"}],commands:{feature:"commands",mode:"directory",source:{project:[Qn],global:[ni]},canonicalDir:DL,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[qn],global:[oi]},canonicalDir:NL,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ei],global:[ha]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/mcp.json"},ignore:{feature:"ignore",mode:"flatFile",source:{project:[ri],global:[]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/ignore"}},buildImportPaths:Oy,detectionPaths:[Ar,".qwen/settings.json",".qwen/commands",".qwen/rules"]};});function uF(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=at(n,r);return o?[{path:un,content:o}]:[]}function dF(t){return st(t,Pe)}function fF(t){return t.commands.map(e=>({path:`${Pe}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function gF(t){return t.agents.map(e=>({path:`${Pe}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}var hF=d(()=>{rt();Kt();ut();Lt();Wl();s(uF,"generateRules");s(dF,"generateSkills");s(fF,"generateCommands");s(gF,"generateAgents");});async function yF(t,e={}){let r=e.scope??"project",n=[],o=await W(eo,t,r);return n.push(...await Y(Qd,t,r,{normalize:o})),await et(t,Pe,eo,n,o),n}var _F=d(()=>{gt();rt();Ot();Wl();gR();s(yF,"importFromReplitAgent");});function RF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:eo}))}var SF=d(()=>{Ct();Wl();s(RF,"lintRules");});function IF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","replit-agent","Replit Agent 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?[]:[D(".agentsmesh/permissions.yaml","replit-agent","Replit Agent permissions are managed in the cloud UI; canonical permissions are not projected.")]}function kF(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","replit-agent","Replit Agent has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}function EF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".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 LF=d(()=>{wt();s(IF,"lintHooks");s(CF,"lintPermissions");s(kF,"lintIgnore");s(EF,"lintMcp");});var RY,SY,IY,Qd,gR=d(()=>{Lt();ut();hF();_F();SF();LF();Ay();Wl();RY={name:eo,primaryRootInstructionPath:un,generateRules:uF,generateCommands:fF,generateAgents:gF,generateSkills:dF,importFrom:yF},SY={rootInstructionPath:un,skillDir:Pe,managedOutputs:{dirs:[Pe],files:[un]},paths:{rulePath(t){return un},commandPath(t){return `${Pe}/${V(t)}/SKILL.md`},agentPath(t){return `${Pe}/${K(t)}/SKILL.md`}}},IY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Qd={id:eo,metadata:{displayName:"Replit Agent",category:"agent-platform",officialUrl:"https://replit.com",shortDescription:"Replit's autonomous coding agent"},generators:RY,capabilities:IY,emptyImportMessage:"No Replit Agent config found (replit.md or .agents/skills).",lintRules:RF,lint:{hooks:IF,permissions:CF,ignore:kF,mcp:EF},supportsConversion:{commands:true,agents:true},project:SY,sharedArtifacts:{".agents/skills/":"consumer"},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[un]},canonicalDir:vL,canonicalRootFilename:"_root.md",markAsRoot:true}},buildImportPaths:wy,detectionPaths:[un]};});function wF(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:dn,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(si))continue;let o=basename(n.source,".md");e.push({path:`${ss}/${o}.md`,content:n.body.trim()||""});}return e}function AF(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${is}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function bF(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Km,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function PF(t){return t.ignore.length===0?[]:[{path:Wm,content:t.ignore.join(`
148
+ `)}]}function xF(t){return st(t,ro)}function TF(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:Hl,content:stringify({customModes:e})}]}var DF=d(()=>{rt();U();Sa();s(wF,"generateRules");s(AF,"generateCommands");s(bF,"generateMcp");s(PF,"generateIgnore");s(xF,"generateSkills");s(TF,"generateAgents");});var qd,FF,hR=d(()=>{U();ft();Sa();qd=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${Ra}/${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"),FF=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=P(e(n));return {destPath:n,toPath:`${rd}/${t}`,content:await St(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function EY(t,e,r){let n=join(t,ya),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,Ra);for(let l of i)e.push(...await It({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:si,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let f=await qd({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function vF(t,e={}){let r=e.scope??"project",n=[],o=await W(si,t,r);return n.push(...await Y(tf,t,r,{normalize:o})),await EY(t,n,o),await et(t,ro,si,n,o),n}var MF=d(()=>{gt();rt();$e();Ot();hR();Sa();_R();s(EY,"importPerModeRules");s(vF,"importFromRooCode");});function $F(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:si}))}var GF=d(()=>{Ct();Sa();s($F,"lintRules");});function PY(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var AY,bY,xY,TY,DY,tf,_R=d(()=>{A();DF();Sa();oe();MF();hR();GF();Et();AY={name:"roo-code",primaryRootInstructionPath:dn,generateRules:wF,generateCommands:AF,generateSkills:xF,generateMcp:bF,generateIgnore:PF,generateAgents:TF,importFrom:vF},bY={rootInstructionPath:dn,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Hl]},paths:{rulePath(t,e){return `${ss}/${t}.md`},commandPath(t,e){return `${is}/${t}.md`},agentPath(t,e){return null}}};s(PY,"computeStatus");xY=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,Hm));return [{target:"roo-code",path:Hm,content:i,currentContent:a??void 0,status:PY(a,i)}]},"generateRooGlobalExtras"),TY={rootInstructionPath:li,skillDir:as,managedOutputs:{dirs:[ii,ai,as,ML],files:[li,_a,zm,Hm]},rewriteGeneratedPath(t){return t===dn?li:t===Hl?null:t.startsWith(`${ss}/`)?t.replace(`${ss}/`,`${ii}/`):t.startsWith(`${is}/`)?t.replace(`${is}/`,`${ai}/`):t.startsWith(`${ro}/`)?t.replace(`${ro}/`,`${as}/`):t===Km?_a:t===Wm?zm:t},mirrorGlobalPath(t,e){return dt(t,as,e)},paths:{rulePath(t,e){return `${ii}/${t}.md`},commandPath(t,e){return `${ai}/${t}.md`},agentPath(t,e){return null}}},DY={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},tf={id:"roo-code",metadata:{displayName:"Roo Code",category:"ide",officialUrl:"https://roocode.com",shortDescription:"Open-source AI VS Code extension"},generators:AY,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:$F,project:bY,globalSupport:{capabilities:DY,detectionPaths:[ii,ai,as,_a,zm,li,Hm],layout:TY,scopeExtras:xY},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[dn,Bm],global:[li,dn,Bm]},canonicalDir:Ra,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:[ss],global:[ii]},canonicalDir:Ra,extensions:[".md"],map:qd}],commands:{feature:"commands",mode:"directory",source:{project:[is],global:[ai]},canonicalDir:rd,extensions:[".md"],map:FF},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Km],global:[_a]},canonicalDir:".agentsmesh",canonicalFilename:$L},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Wm],global:[zm]},canonicalDir:".agentsmesh",canonicalFilename:GL}},buildImportPaths:by,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Hl]};});function jF(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=at(n,r);return o?[{path:br,content:o}]:[]}function UF(t){return st(t,ne)}function BF(t){return t.commands.map(e=>({path:`${ne}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function KF(t){return t.agents.map(e=>({path:`${ne}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function WF(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ls,content:e}]}var HF=d(()=>{rt();Kt();ut();Lt();Vl();s(jF,"generateRules");s(UF,"generateSkills");s(BF,"generateCommands");s(KF,"generateAgents");s(WF,"generateMcp");});async function zF(t,e={}){let r=e.scope??"project",n=[],o=await W(no,t,r);return n.push(...await Y(ef,t,r,{normalize:o})),await et(t,r==="global"?Ve:ne,no,n,o),n}var VF=d(()=>{gt();rt();Ot();Vl();RR();s(zF,"importFromRovodev");});function JF(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:no}))}var YF=d(()=>{Ct();Vl();s(JF,"lintRules");});function XF(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","rovodev","Rovo Dev 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?[]:[D(".agentsmesh/permissions.yaml","rovodev","Rovo Dev permissions are managed in config.yaml; canonical permissions are not projected.")]}function QF(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","rovodev","Rovo Dev has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var qF=d(()=>{wt();s(XF,"lintHooks");s(ZF,"lintPermissions");s(QF,"lintIgnore");});var NY,FY,vY,MY,$Y,ef,RR=d(()=>{Lt();ut();HF();oe();VF();YF();qF();Et();Vl();NY={name:no,primaryRootInstructionPath:br,generateRules:jF,generateCommands:BF,generateAgents:KF,generateSkills:UF,generateMcp:WF,importFrom:zF},FY={rootInstructionPath:br,skillDir:ne,managedOutputs:{dirs:[ne],files:[br,ls]},paths:{rulePath(t){return br},commandPath(t){return `${ne}/${V(t)}/SKILL.md`},agentPath(t){return `${ne}/${K(t)}/SKILL.md`}}},vY={rootInstructionPath:cs,skillDir:Ve,managedOutputs:{dirs:[Ve],files:[cs,zl]},rewriteGeneratedPath(t){return t===br?cs:t.startsWith(`${ne}/`)?t.replace(`${ne}/`,`${Ve}/`):t===ls?zl:t},mirrorGlobalPath(t,e){return dt(t,Ve,e)},paths:{rulePath(t){return cs},commandPath(t){return `${Ve}/${V(t)}/SKILL.md`},agentPath(t){return `${Ve}/${K(t)}/SKILL.md`}}},MY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},$Y={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ef={id:no,metadata:{displayName:"Rovo Dev",category:"cli",officialUrl:"https://www.atlassian.com/solutions/devops/rovo-dev",shortDescription:"Atlassian's coding agent"},generators:NY,capabilities:MY,emptyImportMessage:"No Rovo Dev config found (AGENTS.md, .rovodev/skills, or .rovodev/mcp.json).",lintRules:JF,lint:{hooks:XF,permissions:ZF,ignore:QF},supportsConversion:{commands:true,agents:true},project:FY,globalSupport:{capabilities:$Y,detectionPaths:[BL,cs,Ve],layout:vY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[br],global:[cs]},canonicalDir:KL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ls],global:[zl]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Py,detectionPaths:[br,ne,ls]};});function tv(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Ye,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Pr))continue;let o=basename(n.source,".md");e.push({path:`${Je}/${o}.md`,content:n.body.trim()});}return e}function ev(t){return st(t,xr)}function rv(t){return t.mcp===null||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ia,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function nv(t){return t.ignore.length===0?[]:[{path:Jl,content:t.ignore.join(`
149
+ `)}]}var ov=d(()=>{rt();Yl();s(tv,"generateRules");s(ev,"generateSkills");s(rv,"generateMcp");s(nv,"generateIgnore");});async function UY(t,e,r,n){let o=n==="global"?[Tr,Ye]:[Ye,Tr];for(let i of o){let a=join(t,i),l=await _(a);if(l===null)continue;let c=join(t,sv),{frontmatter:m,body:p}=P(r(l,a,c));await O(join(t,Jm)),await I(c,await z(c,{...m,root:true},p)),e.push({fromTool:Pr,fromPath:a,toPath:sv,feature:"rules"});return}}async function BY(t,e,r,n){let o=join(t,n==="global"?ms:Je),i=join(t,Jm);e.push(...await It({srcDir:o,destDir:i,extensions:[".md"],fromTool:Pr,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}=P(l(m));return {destPath:m,toPath:`${Jm}/${a}`,feature:"rules",content:await z(m,{...p,root:false},u)}},"mapEntry")}));}async function iv(t,e={}){let r=e.scope??"project",n=[],o=await W(Pr,t,r);return await UY(t,n,o,r),await BY(t,n,o,r),n.push(...await Y(rf,t,r,{normalize:o})),await et(t,r==="global"?fn:xr,Pr,n,o),n}var sv,av=d(()=>{gt();rt();$e();Ot();ft();A();U();Yl();SR();sv=`${Jm}/_root.md`;s(UY,"importRoot");s(BY,"importNonRootRules");s(iv,"importFromTrae");});function lv(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Pr}))}var cv=d(()=>{Ct();Yl();s(lv,"lintRules");});var KY,WY,HY,zY,rf,SR=d(()=>{ov();oe();av();cv();Et();Yl();KY={name:Pr,primaryRootInstructionPath:Ye,generateRules:tv,generateSkills:ev,generateMcp:rv,generateIgnore:nv,importFrom:iv},WY={rootInstructionPath:Ye,skillDir:xr,managedOutputs:{dirs:[Je,xr],files:[Ia,Jl]},paths:{rulePath(t,e){return `${Je}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},HY={rootInstructionPath:Tr,skillDir:fn,managedOutputs:{dirs:[ms,fn,HL],files:[Tr,Vm]},rewriteGeneratedPath(t){return t===Ye?Tr:t.startsWith(`${Je}/`)?t.replace(`${Je}/`,`${ms}/`):t.startsWith(`${xr}/`)?t.replace(`${xr}/`,`${fn}/`):t===Ia?Vm:t===Jl?null:t},mirrorGlobalPath(t,e){return dt(t,fn,e)},paths:{rulePath(t,e){return t==="_root"?Tr:`${ms}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},zY={rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},rf={id:Pr,metadata:{displayName:"Trae",category:"ide",officialUrl:"https://www.trae.ai",shortDescription:"ByteDance's adaptive AI IDE"},generators:KY,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:lv,project:WY,globalSupport:{capabilities:zY,detectionPaths:[Tr,ms,fn,Vm],layout:HY},importer:{mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ia],global:[Vm]},canonicalDir:".agentsmesh",canonicalFilename:zL},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Jl]},canonicalDir:".agentsmesh",canonicalFilename:VL}},buildImportPaths:xy,detectionPaths:[Je,Ia,Ye]};});function mv(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(oo)),n=e?.body.trim()??"",o=at(n,r);return o?[{path:gn,content:o}]:[]}function pv(t){return st(t,he)}function uv(t){return t.commands.map(e=>({path:`${he}/${V(e.name)}/SKILL.md`,content:Mt(e)}))}function dv(t){return t.agents.map(e=>({path:`${he}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}function fv(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ci,content:e}]}var gv=d(()=>{rt();Kt();ut();Lt();Xl();s(mv,"generateRules");s(pv,"generateSkills");s(uv,"generateCommands");s(dv,"generateAgents");s(fv,"generateMcp");});async function hv(t,e={}){let r=e.scope??"project",n=[],o=await W(oo,t,r);return n.push(...await Y(nf,t,r,{normalize:o})),await et(t,r==="global"?Xe:he,oo,n,o),n}var yv=d(()=>{gt();rt();Ot();Xl();IR();s(hv,"importFromWarp");});function _v(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:oo}))}var Rv=d(()=>{Ct();Xl();s(_v,"lintRules");});function Sv(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Iv(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?[]:[D(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function Cv(t){return t.ignore.length===0?[]:[D(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var kv=d(()=>{wt();s(Sv,"lintHooks");s(Iv,"lintPermissions");s(Cv,"lintIgnore");});var VY,JY,YY,XY,ZY,nf,IR=d(()=>{Lt();ut();gv();oe();yv();Rv();kv();Et();Xl();VY={name:oo,primaryRootInstructionPath:gn,generateRules:mv,generateCommands:uv,generateAgents:dv,generateSkills:pv,generateMcp:fv,importFrom:hv},JY={rootInstructionPath:gn,skillDir:he,managedOutputs:{dirs:[he],files:[gn,ci]},paths:{rulePath(t){return gn},commandPath(t){return `${he}/${V(t)}/SKILL.md`},agentPath(t){return `${he}/${K(t)}/SKILL.md`}}},YY={rootInstructionPath:void 0,skillDir:Xe,managedOutputs:{dirs:[Xe],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${he}/`)?t.replace(`${he}/`,`${Xe}/`):t},mirrorGlobalPath(t,e){return dt(t,Xe,e)},paths:{rulePath(){return null},commandPath(t){return `${Xe}/${V(t)}/SKILL.md`},agentPath(t){return `${Xe}/${K(t)}/SKILL.md`}}},XY={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ZY={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},nf={id:oo,metadata:{displayName:"Warp",category:"cli",officialUrl:"https://www.warp.dev",shortDescription:"AI-powered terminal"},generators:VY,capabilities:XY,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:_v,lint:{hooks:Sv,permissions:Iv,ignore:Cv},supportsConversion:{commands:true,agents:true},project:JY,globalSupport:{capabilities:ZY,detectionPaths:[Xe],layout:YY},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ty,gn]},canonicalDir:YL,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ci]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Dy,detectionPaths:[gn,Ty,ci],conversionDefaults:{commandsToSkills:true,agentsToSkills:true}};});var fo,CR,yi,Ev,uc,go,dc,fc,Lv,_i,Rn,gc,kR,Ov,wv,ER,LR,OR,hc,yc,lp,of,sf,af,Av,Ee=d(()=>{fo="windsurf",CR=".windsurfrules",yi=".windsurf/rules",Ev=".windsurfignore",uc=".codeiumignore",go="AGENTS.md",dc=".windsurf/hooks.json",fc=".windsurf/mcp_config.example.json",Lv=".windsurf/mcp_config.json",_i=".windsurf/workflows",Rn=".windsurf/skills",gc=".agentsmesh/rules",kR=".agentsmesh/commands",Ov=".agentsmesh/agents",wv=".agentsmesh/skills",ER=".agentsmesh/ignore",LR=".agentsmesh/hooks.yaml",OR=".agentsmesh/mcp.json",hc=".codeium/windsurf/memories/global_rules.md",yc=".codeium/windsurf/skills",lp=".codeium/windsurf/global_workflows",of=".codeium/windsurf/hooks.json",sf=".codeium/windsurf/mcp_config.json",af=".codeium/.codeiumignore",Av=".agents/skills";});function qY(t){let e=basename(t,".md");return e==="_root"?"root":e}function t2(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 wR(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:go,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=qY(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:`${yi}/${o}.md`,content:l});let c=t2(n.globs);c&&(c!==o&&e.push({path:`${yi}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var bv=d(()=>{U();Ee();s(qY,"ruleSlug");s(t2,"directoryScopedRuleDir");s(wR,"generateRules");});function AR(t){return !t.ignore||t.ignore.length===0?[]:[{path:uc,content:t.ignore.join(`
150
+ `)}]}var Pv=d(()=>{Ee();s(AR,"generateIgnore");});function bR(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:`${_i}/${e.name}.md`,content:n}})}var xv=d(()=>{U();Ee();s(bR,"generateCommands");});function PR(t){return t.agents.map(e=>({path:`${Rn}/${K(e.name)}/SKILL.md`,content:Tt(e)}))}var Tv=d(()=>{ut();Ee();s(PR,"generateAgents");});function xR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:fc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var Dv=d(()=>{Ee();s(xR,"generateMcp");});function e2(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 r2(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Ln(i))continue;let a=Jt(i),l=Re(i),c=i.type==="prompt"?l||a:a||l;c&&o.push({command:c,show_output:true});}o.length>0&&(e[e2(r)]=o);}return e}function TR(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=r2(t.hooks);return Object.keys(e).length===0?[]:[{path:dc,content:JSON.stringify({hooks:e},null,2)}]}var Nv=d(()=>{Br();Ee();s(e2,"windsurfEventName");s(r2,"toWindsurfHooks");s(TR,"generateHooks");});function DR(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:`${Rn}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles)e.push({path:`${Rn}/${r.name}/${i.relativePath}`,content:i.content});}return e}var Fv=d(()=>{U();Ee();s(DR,"generateSkills");});var vv=d(()=>{bv();Pv();xv();Tv();Dv();Nv();Fv();});var Mv=d(()=>{vv();});function $v(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 Gv(t,e,r){let n=join(t,_i),i=(await G(n)).filter(l=>l.endsWith(".md")),a=join(t,kR);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}=P(u),h=await St(p,{description:typeof f.description=="string"?f.description:"",hasDescription:Object.prototype.hasOwnProperty.call(f,"description"),allowedTools:(()=>{let S=$v(f.allowedTools);return S.length>0?S:$v(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:fo,fromPath:l,toPath:`${kR}/${m}`,feature:"commands"});}}var jv=d(()=>{A();U();ft();Ee();s($v,"toStringArray");s(Gv,"importWorkflows");});async function Uv(t,e,r,n=Rn){await ql([n],{projectRoot:t,destCanonicalSkillsDir:wv,targetName:"windsurf",normalize:r,results:e},[tc({canonicalAgentsDir:Ov})]);}var Bv=d(()=>{ec();Ee();s(Uv,"importSkills");});async function Wv(t,e){let r=join(t,dc),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=i2(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,LR);await O(dirname(a)),await I(a,stringify(i)),e.push({fromTool:fo,fromPath:r,toPath:LR,feature:"hooks"});}catch{}}function s2(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 i2(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=s2(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=[fc,Lv];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,OR);await O(dirname(l)),await I(l,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:fo,fromPath:o,toPath:OR,feature:"mcp"});return}catch{}}}var zv=d(()=>{A();Ee();s(Wv,"importWindsurfHooks");s(s2,"canonicalHookEventName");s(i2,"windsurfHooksToCanonical");s(Hv,"importWindsurfMcp");});async function Vv(t,e){let r=e?.scope??"project",n=[],o=await W(fo,t),i=await W("codex-cli",t),a=join(t,gc),l=join(t,CR),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 I(f,h),n.push({fromTool:"windsurf",fromPath:l,toPath:`${gc}/_root.md`,feature:"rules"});}if(c===null){let f=join(t,go),g=await _(f);if(g!==null){await O(a);let h=join(a,"_root.md"),S=o(i(g,f,h),f,h).trim(),C=await z(h,{root:true},S);await I(h,C),n.push({fromTool:"windsurf",fromPath:f,toPath:`${gc}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await It({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 S=h.replace(/\//g,"-");if(!Eu(h))return await wn(join(a,`${S}.md`)),null;let C=join(a,`${S}.md`);return {destPath:C,toPath:`${gc}/${S}.md`,feature:"rules",content:await z(C,{root:false,globs:[`${h}/**`]},g(C))}},"mapEntry")}));let m=join(t,yi);n.push(...await It({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:S,body:C}=P(g(h)),R={...S};return typeof R.glob=="string"&&R.glob.trim()&&(R.globs=[R.glob],delete R.glob),{destPath:h,toPath:`${gc}/${f}`,feature:"rules",content:await z(h,{...R,root:false},C)}},"mapEntry")}));let p=join(t,Ev),u=await _(p);if((u===null||!u.trim())&&(p=join(t,uc),u=await _(p)),u!==null&&u.trim()){let f=u.split(/\r?\n/),g=[];for(let h of f){let S=h.trim();S&&!S.startsWith("#")&&g.push(S);}if(g.length>0){await O(join(t,".agentsmesh"));let h=join(t,ER);await I(h,g.join(`
151
+ `)),n.push({fromTool:"windsurf",fromPath:p,toPath:ER,feature:"ignore"});}}return await Gv(t,n,o),await Uv(t,n,o),await Wv(t,n),await Hv(t,n),n}var Jv=d(()=>{gt();A();U();ft();$e();lm();Ee();jv();Bv();zv();s(Vv,"importFromWindsurf");});function Yv(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:fo,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:fo,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),n}var Xv=d(()=>{Ee();s(Yv,"lintRules");});function Zv(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>D(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function Qv(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[D(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var qv=d(()=>{wt();s(Zv,"lintCommands");s(Qv,"lintMcp");});function p2(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 u2,d2,f2,g2,tM,eM=d(()=>{Mv();Ni();Ee();oe();Jv();Xv();qv();Et();ml();ut();s(p2,"directoryScopedRuleDir");u2={name:"windsurf",primaryRootInstructionPath:go,generateRules:wR,generateCommands:bR,generateAgents:PR,generateSkills:DR,generateMcp:xR,generateHooks:TR,generateIgnore:AR,importFrom:Vv},d2={rootInstructionPath:go,extraRuleOutputPaths(t){if(t.root)return [go];let e=p2(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:Rn,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 `${yi}/${t}.md`},commandPath(t,e){return `${_i}/${t}.md`},agentPath(t,e){return sr(e,"windsurf")?`.windsurf/skills/${K(t)}/SKILL.md`:null}}},f2={rootInstructionPath:hc,skillDir:yc,managedOutputs:{dirs:[yc,lp,Av],files:[hc,of,sf,af]},rewriteGeneratedPath(t){return t===go?hc:t.startsWith(`${yi}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${Rn}/`)?t.replace(`${Rn}/`,`${yc}/`):t.startsWith(`${_i}/`)?t.replace(`${_i}/`,`${lp}/`):t===dc?of:t===fc?sf:t===uc?af:t},mirrorGlobalPath(t,e){return dt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return hc},commandPath(t,e){return `${lp}/${t}.md`},agentPath(t,e){return sr(e,"windsurf")?`${yc}/${K(t)}/SKILL.md`:null}}},g2={rules:"native",additionalRules:"partial",commands:Wr("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},tM={id:"windsurf",metadata:{displayName:"Windsurf",category:"ide",officialUrl:"https://windsurf.com",shortDescription:"Codeium's agentic IDE"},generators:u2,capabilities:{rules:"native",additionalRules:"native",commands:Wr("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:Yv,lint:{commands:Zv,mcp:Qv},project:d2,globalSupport:{capabilities:g2,detectionPaths:[hc,yc,lp,of,sf,af],layout:f2},buildImportPaths:Ny,detectionPaths:[".windsurfrules",".windsurf"],conversionDefaults:{agentsToSkills:true}};});function rM(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=at(n,r);return o?[{path:hn,content:o}]:[]}var nM=d(()=>{Kt();Ca();s(rM,"generateRules");});async function sM(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 Ht(t,oM,l),r.push({fromTool:"zed",fromPath:e,toPath:oM,feature:"mcp"}));}var oM,iM=d(()=>{A();Jr();Ca();oM=".agentsmesh/mcp.json";s(sM,"importZedMcp");});async function aM(t,e={}){let r=e.scope??"project",n=[],o=await W("zed",t,r);return n.push(...await Y(cf,t,r,{normalize:o})),await sM(t,r==="global"?io:so,n),n}var lM=d(()=>{gt();Ot();iM();Ca();FR();s(aM,"importFromZed");});function cM(t,e,r,n){return J(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var mM=d(()=>{Ct();Ca();s(cM,"lintRules");});function pM(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[D(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function uM(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?[]:[D(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function dM(t){return t.ignore.length===0?[]:[D(".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 fM=d(()=>{wt();s(pM,"lintHooks");s(uM,"lintPermissions");s(dM,"lintIgnore");});function C2(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 y2,_2,R2,S2,I2,cf,FR=d(()=>{nM();lM();mM();fM();Et();Ca();y2={name:"zed",primaryRootInstructionPath:hn,generateRules:rM,importFrom:aM},_2={rootInstructionPath:hn,managedOutputs:{dirs:[],files:[hn,so]},paths:{rulePath(t){return hn},commandPath(){return null},agentPath(){return null}}},R2={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[io]},rewriteGeneratedPath(t){return t===so?io:t},paths:{rulePath(){return io},commandPath(){return null},agentPath(){return null}}},S2={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},I2={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(C2,"mergeZedSettings");cf={id:"zed",metadata:{displayName:"Zed",category:"ide",officialUrl:"https://zed.dev",shortDescription:"Collaborative AI editor"},generators:y2,capabilities:S2,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:cM,lint:{hooks:pM,permissions:uM,ignore:dM},project:_2,globalSupport:{capabilities:I2,detectionPaths:[io],layout:R2},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[hn],global:[]},canonicalDir:QL,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:so,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===so||n===io?C2(t,r):null},buildImportPaths:Fy,detectionPaths:[hn,so]};});var AE={};Dg(AE,{BUILTIN_TARGETS:()=>Pt,TARGET_IDS:()=>$t,getBuiltinTargetDefinition:()=>vr,getEffectiveTargetSupportLevel:()=>mf,getTargetCapabilities:()=>gi,getTargetDetectionPaths:()=>MR,getTargetLayout:()=>Wt,getTargetManagedOutputs:()=>$R,getTargetPrimaryRootInstructionPath:()=>E2,getTargetSkillDir:()=>cp,isBuiltinTargetId:()=>ve,resolveTargetFeatureGenerator:()=>_c,rewriteGeneratedOutputPath:()=>GR});function k2(){return vR||(lk(Pt),vR=new Map(Pt.map(t=>[t.id,t]))),vR}function vr(t){return k2().get(t)}function gi(t,e="project"){let r=vr(t)??nt(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return ik(n)}function MR(t,e="project"){let r=vr(t)??nt(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function Wt(t,e="project"){let r=vr(t)??nt(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function E2(t,e="project"){return Wt(t,e)?.rootInstructionPath}function cp(t,e="project"){return Wt(t,e)?.skillDir}function $R(t,e="project"){return Wt(t,e)?.managedOutputs}function GR(t,e,r="project"){let n=Wt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function gM(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!cl(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!sr(r,t.id,true,n):false}function L2(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?cl(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?sr(r,t.id,true,n):false}function mf(t,e,r,n="project"){let o=gi(t,n)?.[e]?.level??"none",i=vr(t)??nt(t);return o==="none"&&L2(i,e,r,n)?"embedded":o!=="embedded"?o:gM(i,e,r,n)?"none":o}function _c(t,e,r,n="project"){let o=vr(t)??nt(t);if(!o?.generators||gM(o,e,r,n))return;let i=O2[e];return i===null?void 0:i(o.generators)}var Pt,vR,O2,xt=d(()=>{ml();Ni();ce();ph();kn();bh();vy();My();Gy();aw();By();IA();pb();c_();g_();y_();T_();D_();N_();q_();tR();eR();rR();aR();cR();pR();dR();fR();gR();_R();RR();SR();IR();eM();FR();Pt=[Au,od,sd,id,iw,ad,SA,mb,fd,Sd,Cd,xd,Td,Dd,Ud,Bd,Kd,Wd,Vd,Jd,Yd,Xd,Zd,Qd,tf,ef,rf,nf,tM,cf];s(k2,"builtinTargetsMap");s(vr,"getBuiltinTargetDefinition");s(gi,"getTargetCapabilities");s(MR,"getTargetDetectionPaths");s(Wt,"getTargetLayout");s(E2,"getTargetPrimaryRootInstructionPath");s(cp,"getTargetSkillDir");s($R,"getTargetManagedOutputs");s(GR,"rewriteGeneratedOutputPath");s(gM,"isFeatureSuppressedByConversion");s(L2,"isConversionUpgrading");s(mf,"getEffectiveTargetSupportLevel");O2={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(_c,"resolveTargetFeatureGenerator");});function b2(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 pf(t){let e=[];for(let n of Pt){let o=0,i=0;for(let a of n.detectionPaths){if(!await j(join(t,a)))continue;let l=A2.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(b2);let r=e[0];return r.uniqueHits===0?null:r.id}var A2,hM,jR=d(()=>{A();xt();A2=(()=>{let t=new Map;for(let e of Pt)for(let r of e.detectionPaths)t.set(r,(t.get(r)??0)+1);return t})();s(b2,"compare");s(pf,"detectNativeFormat");hM=Pt.map(t=>t.detectionPaths[0]).filter(t=>t!==void 0);});async function mp(t,e){let r=nt(e);if(!r)throw new Error(`No importer registered for native target: ${e}`);return r.generators.importFrom(t)}var UR=d(()=>{ce();s(mp,"importNativeToCanonical");});async function va(t){if(!await j(t))return false;if(await j(join(t,KR)))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,KR)))return !0}catch{return false}return false}async function pp(t,e={}){if(!await j(t))return [];if(await j(join(t,KR))){let r=await pu(t,e);return r?[r]:[]}return Ps(t,e)}var KR,uf=d(()=>{A();al();KR="SKILL.md";s(va,"isSkillPackLayout");s(pp,"loadSkillsAtExtendPath");});async function df(t,e={}){return (await bs(t,e)).filter(n=>!En(basename(n.source)))}async function ff(t,e={}){return (await As(t,e)).filter(n=>!En(basename(n.source)))}async function gf(t,e={}){return (await ws(t,e)).filter(n=>!En(basename(n.source)))}async function yM(t,e={}){return Ps(t,e)}var hf=d(()=>{em();tm();qc();al();Lo();s(df,"importAgents");s(ff,"importCommands");s(gf,"importRules");s(yM,"importSkills");});function HR(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 zR(t){return t.toLowerCase().endsWith(".md")}function RM(t,e){for(let r of HR(nt(t)?.importer,e))if(r.extensions.some(n=>!zR(n)))return true;return false}function M2(t,e){let r=new Set;for(let n of HR(nt(t)?.importer,e))for(let o of n.extensions)zR(o)||r.add(o.toLowerCase());return r}function $2(t){return nk().filter(e=>RM(e,t))}async function U2(t,e,r){return G2[t](e,r)}async function B2(t,e,r){return j2[t](e,r)}async function K2(t,e,r,n={}){let o=HR(nt(e)?.importer,r),i=await G(t),a=new Set;for(let p of o)for(let u of p.extensions)zR(u)||a.add(u.toLowerCase());let l=i.filter(p=>[...a].some(u=>p.toLowerCase().endsWith(u))&&!En(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 S of o){if(!S.extensions.some(k=>u.toLowerCase().endsWith(k.toLowerCase())))continue;let R=await S.map({absolutePath:u,relativePath:g,content:f,destDir:c,normalizeTo:s(()=>f,"normalizeTo")});if(R){h=R;break}}h&&(await O(dirname(h.destPath)),await I(h.destPath,h.content));}return {entities:await U2(r,c,n),cleanup:m}}catch(p){throw await m(),p}}async function VR(t,e,r={}){let n=r.restrictToTarget,o=n?RM(n,e)?[n]:[]:$2(e),i=new Set;for(let f of o)for(let g of M2(f,e))i.add(g);let a=await B2(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 K2(t,f,e,r.parseOpts??{});l.push(g.cleanup);for(let h of g.entities){let S=c(h);m.has(S)||m.set(S,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 yf(t,e={}){let r=await VR(t,"commands",e);return {commands:[...r.entities],cleanup:r.cleanup}}async function _f(t,e={}){let r=await VR(t,"rules",e);return {rules:[...r.entities],cleanup:r.cleanup}}async function Rf(t,e={}){let r=await VR(t,"agents",e);return {agents:[...r.entities],cleanup:r.cleanup}}var G2,j2,Sf=d(()=>{em();tm();qc();A();ce();Lo();hf();s(HR,"directorySpecsFor");s(zR,"isMarkdownExtension");s(RM,"hasNonMdEntityMapper");s(M2,"nonMdEntityExtensions");s($2,"targetsWithNonMdEntityMapper");G2={rules:ws,commands:As,agents:bs},j2={rules:gf,commands:ff,agents:df};s(U2,"parseEntityDir");s(B2,"importEntities");s(K2,"readToolNativeEntities");s(VR,"readEntityDirWithMappers");s(yf,"readCommandsDirWithMappers");s(_f,"readRulesDirWithMappers");s(Rf,"readAgentsDirWithMappers");});function z2(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function V2(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 If(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 XR(t,e){if(basename(t)===e)return t;let r=join(t,e);return await j(r)?r:null}async function J2(t,e,r){let n=s(async()=>{},"noop"),o=await XR(t,"rules");if(!o)return {rules:[],cleanup:n};if(!r)return {rules:await gf(o,e),cleanup:n};let i=await _f(o,{parseOpts:e});return {rules:[...i.rules],cleanup:i.cleanup}}async function Y2(t,e,r){let n=s(async()=>{},"noop"),o=await XR(t,"commands");if(!o)return {commands:[],cleanup:n};if(!r)return {commands:await ff(o,e),cleanup:n};let i=await yf(o,{parseOpts:e});return {commands:[...i.commands],cleanup:i.cleanup}}async function X2(t,e,r){let n=s(async()=>{},"noop"),o=await XR(t,"agents");if(!o)return {agents:[],cleanup:n};if(!r)return {agents:await df(o,e),cleanup:n};let i=await Rf(o,{parseOpts:e});return {agents:[...i.agents],cleanup:i.cleanup}}async function Z2(t,e){if(await va(t))return pp(t,e);let r=join(t,"skills");return await va(r)?pp(r,e):[]}async function Cf(t,e={}){let r=s(async()=>{},"noop"),n=join(t,".agentsmesh");if(await j(n))return {canonical:await we(t,e),cleanup:r};let o=e.enableTargetEntityMappers??false,i=z2(),a=await J2(t,e,o);i.rules=a.rules;let l=await Y2(t,e,o);i.commands=l.commands;let c=await X2(t,e,o);i.agents=c.agents,i.skills=await Z2(t,e);let m=s(async()=>{await Promise.allSettled([a.cleanup(),l.cleanup(),c.cleanup()]);},"mergedCleanup");if(V2(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 ZR=d(()=>{A();hf();Sf();Di();uf();s(z2,"emptyCanonical");s(V2,"isCanonicalSliceEmpty");s(If,"normalizeSlicePath");s(XR,"resolveEntityDir");s(J2,"parseRulesAt");s(Y2,"parseCommandsAt");s(X2,"parseAgentsAt");s(Z2,"loadSkillsForPartialSlice");s(Cf,"loadCanonicalSliceAtPath");});async function kf(t){let e=await _(t);if(!e)return "";let r=jr(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 SM(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 !(zC(o)||!n.includes("/")&&(cu(n)||VC(n)))},"filter")});}var QR=d(()=>{A();U();Lo();s(kf,"readSkillFrontmatterName");s(SM,"cpFilteredSkill");});function qR(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=qR(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=qR(e.globs).length>0?qR(e.globs):[e.glob],delete e.glob),e}function tS(t){let e=jr(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 IM=d(()=>{U();s(qR,"toStrArray");s(tX,"normalizeCursorKeys");s(eX,"normalizeWindsurfKeys");s(tS,"normalizeMdcToCanonical");});function eS(t){return t.toLowerCase().replace(/[^a-z0-9.-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function rS(t){return t.toLowerCase().endsWith(".mdc")?basename(t).replace(/\.mdc$/i,".md"):basename(t)}function kM(t,e,r){let o=relative(t,e).replace(/\\/g,"/").split("/");if(o.pop(),o.length===0)return r;let i=eS(o[o.length-1]);return i?`${i}-${r}`:r}var EM=d(()=>{s(eS,"sanitizeNameSegment");s(rS,"computeDestName");s(kM,"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$1(t,{recursive:true,force:true});},"cleanup")}}function AM(t,e){let r=t.toLowerCase();return !!(r.endsWith(".md")||e&&r.endsWith(".mdc"))}async function aX(t,e,r){if(!AM(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),tS(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 G(t)).filter(l=>AM(l,r)&&!En(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=rS(l);i.set(c,(i.get(c)??0)+1);}let a=new Map;await O(e);for(let l of o){let c=rS(l),p=(i.get(c)??0)>1?kM(t,l,c):c;if(a.has(p)&&a.get(p)!==l){let f=relative(t,l).replace(/\\/g,"/").split("/").map(eS).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),tS(f));}else await cp$1(l,join(e,p));}}async function LM(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await G(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 va(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await LM(t,e,r.preferredSkillNames??[]))return;let l=await kf(join(t,"SKILL.md"))||basename(t),c=join(e,l);await O(e),await SM(t,c);return}if(await LM(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await G(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 Lf(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 oS=d(()=>{A();uf();QR();Lo();IM();EM();s(iX,"createStageRoot");s(AM,"isAcceptedFile");s(aX,"stageSingleFile");s(lX,"stageMarkdownCollection");s(LM,"stagePreferredSkills");s(cX,"stageSkills");s(Lf,"stageManualInstallScope");});function mX(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function bM(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 Lf(o,t.as);try{return we(join(i.discoveryRoot,".agentsmesh"))}finally{await i.cleanup();}}if(!t.path){let o=join(e,".agentsmesh");if(!await j(o)){if(await va(e)){let a=await pp(e);return {...mX(),skills:a}}let i=t.target??await pf(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
152
+ Expected one of: .agentsmesh/, ${hM.join(", ")}.`);y.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await mp(e,i);}return we(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 mp(e,t.target)),we(e)}let{sliceRoot:n}=await If(r);try{let{canonical:o}=await Cf(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 PM=d(()=>{jR();A();ot();Di();UR();uf();ZR();oS();s(mX,"emptyCanonical");s(bM,"loadCanonicalForExtend");});function Of(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 sS=d(()=>{ot();s(Of,"applyExtendPick");});var dX,Rc,wf=d(()=>{dX=["rules","commands","agents","skills"],Rc=z$1.enum(dX);});var fX,xM,TM=d(()=>{Co();wf();fX=z$1.enum(["github","gitlab","git","local"]),xM=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:fX,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(el).min(1),pick:Vc.optional(),target:or.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:Rc.optional(),content_hash:z$1.string(),license:z$1.string().nullable().optional()});});function DM(t){let e=xi(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 Ri(t){let e=join(t,"pack.yaml"),r=await _(e);if(r===null)return null;try{let n=parse(r);return xM.parse(n)}catch{return null}}async function FM(t,e,r){if(!await j(t))return null;let n=DM(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 Ri(a);if(l&&DM(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 Af(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 Ri(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}var Sc=d(()=>{A();TM();Xc();s(DM,"sourceIdentity");s(hX,"sameFeatures");s(Ri,"readPackMetadata");s(FM,"findExistingPack");s(Af,"listPacks");});function vM(){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([ws(join(t,"rules")),As(join(t,"commands")),bs(join(t,"agents")),Ps(join(t,"skills")),Ur(join(t,"mcp.json")),uu(join(t,"permissions.yaml")),du(join(t,"hooks.yaml")),fu(join(t,"ignore"))]);return {...vM(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:l,ignore:c}}async function MM(t){let e=join(t,"packs"),r=await Af(e),n=vM();for(let{meta:o,packDir:i}of r){let a=await yX(i),l=aS(a,o.features),c=Of(l,o.features,o.pick,o.name);n=ll(n,c);}return n}var $M=d(()=>{qc();tm();em();al();rm();nh();sh();ih();lh();yo();sS();Sc();s(vM,"emptyCanonical");s(yX,"loadPackCanonical");s(MM,"loadPacksCanonical");});function aS(t,e){if(e.length===0)return GM();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 GM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function Oe(t,e,r={},n=join(e,".agentsmesh")){let o=await sl(t,e,{refreshCache:r.refreshRemoteCache===true}),i=GM();for(let c of o){let m=await bM(c),p=aS(m,c.features),u=Of(p,c.features,c.pick,c.name);i=ll(i,u);}let a=await MM(n);i=ll(i,a);let l=await we(n);return i=ll(i,l),{canonical:i,resolvedExtends:o}}var RX,yo=d(()=>{ou();Di();lh();PM();sS();$M();RX={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(aS,"filterCanonicalByFeatures");s(GM,"emptyCanonical");s(Oe,"loadCanonicalWithExtends");});function hZ(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 yZ(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}function _$(t){try{return realpathSync(t)}catch{return t}}function R$(t,e){let r=_$(resolve(e)),n=_$(t);if(!(n===r||n.startsWith(`${r}${sep}`)))throw new Error(`Plugin source resolves outside project root (escapes ${r}): ${n}`)}async function _Z(t,e){let{source:r}=t,n;if(yZ(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);R$(a,e),n=pathToFileURL(a).href;}else {let i=hZ(r,e);R$(i,e),n=pathToFileURL(i).href;}return await import(n)}function RZ(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function Uf(t,e){let r;try{r=await _Z(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=RZ(r),o=[];for(let i of n)try{let a=gu(i);yu(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 S$(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 Uf(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(`
149
153
  `);throw new Error(`agentsmesh: ${i.length} plugin(s) failed strict load:
150
- ${a}`)}return r}var lI=d(()=>{Qg();ce();ot();s(jX,"resolveNpmSpecifier");s(UX,"isLocalSource");s(r$,"canonicalize");s(n$,"assertSourceInsideProjectRoot");s(BX,"importPluginModule");s(KX,"extractDescriptors");s(Nf,"loadPlugin");s(o$,"loadAllPlugins");});async function Ut(t,e){t.plugins.length!==0&&await o$(t.plugins,e);}var Mr=d(()=>{lI();s(Ut,"bootstrapPlugins");});function pI(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=uZ(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]=rf(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]=rf(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}function uZ(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var d$=d(()=>{Tt();s(pI,"buildCompatibilityMatrix");s(uZ,"countHooks");});function f$(t){return dZ[t]??t}var dZ,g$=d(()=>{dZ={"claude-code":"Claude"};s(f$,"matrixColumnLabel");});function h$(t){return Object.fromEntries(fZ.map(e=>[e,Object.fromEntries($t.map(r=>{let o=di(r,t)?.[e];return [r,o??{level:"none"}]}))]))}function gZ(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function hZ(t,e){return gZ()?e:`${t}${e}${pp.reset}`}function _$(t){let e=uI[t];return hZ(yZ[t],e)}var fZ,y$,uI,pp,yZ,dI=d(()=>{Sn();Tt();fZ=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(h$,"buildSupportMatrix");y$=h$("project"),h$("global"),uI={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},pp={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(gZ,"noColor");s(hZ,"colorize");yZ={native:pp.green,embedded:pp.blue,partial:pp.yellow,none:pp.dim};s(_$,"coloredSymbol");});function fI(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((H,tt)=>r?tt:`${H}${tt}${n.reset}`,"c"),i=s(H=>H.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((H,tt)=>{let it=i(H),v=Math.max(0,tt-it);return H+" ".repeat(v)},"padWithColor"),l=Math.max(12,...e.map(H=>H.length)),c=e.map(H=>f$(H)),m=Math.max(8,l),p=Math.max(12,...t.map(H=>H.feature.length)),u=s(H=>o(n.dim,"\u250C"+H.map(tt=>"\u2500".repeat(tt)).join("\u252C")+"\u2510"),"border"),f=s(H=>o(n.dim,"\u251C"+H.map(tt=>"\u2500".repeat(tt)).join("\u253C")+"\u2524"),"sep"),g=s(H=>o(n.dim,"\u2514"+H.map(tt=>"\u2500".repeat(tt)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],R=u(h),k=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(H=>a(o(n.bold+n.magenta,H),m))],I=o(n.dim,"\u2502")+k.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),C=f(h),b=t.map(H=>{let tt=[a(o(n.cyan,H.feature),p)];for(let it of e){let v=H.support[it]??"none",q=r?uI[v]:_$(v);tt.push(a(` ${q} `,m));}return o(n.dim,"\u2502")+tt.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),N=g(h),T=[R,I,C,...b,N];T.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 T.push(o(n.bold,"Legend: ")+B.join(" ")),T.join(`
151
- `)}var R$=d(()=>{g$();dI();s(fI,"formatMatrix");});function hI(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?"":`
154
+ ${a}`)}return r}var RS=d(()=>{ch();ce();ot();s(hZ,"resolveNpmSpecifier");s(yZ,"isLocalSource");s(_$,"canonicalize");s(R$,"assertSourceInsideProjectRoot");s(_Z,"importPluginModule");s(RZ,"extractDescriptors");s(Uf,"loadPlugin");s(S$,"loadAllPlugins");});async function Ut(t,e){t.plugins.length!==0&&await S$(t.plugins,e);}var $r=d(()=>{RS();s(Ut,"bootstrapPlugins");});function CS(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=BZ(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]=mf(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]=mf(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}function BZ(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var b$=d(()=>{xt();s(CS,"buildCompatibilityMatrix");s(BZ,"countHooks");});function P$(t){return KZ[t]??t}var KZ,x$=d(()=>{KZ={"claude-code":"Claude"};s(P$,"matrixColumnLabel");});function T$(t){return Object.fromEntries(WZ.map(e=>[e,Object.fromEntries($t.map(r=>{let o=gi(r,t)?.[e];return [r,o??{level:"none"}]}))]))}function HZ(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function zZ(t,e){return HZ()?e:`${t}${e}${gp.reset}`}function N$(t){let e=kS[t];return zZ(VZ[t],e)}var WZ,D$,kS,gp,VZ,ES=d(()=>{kn();xt();WZ=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(T$,"buildSupportMatrix");D$=T$("project"),T$("global"),kS={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},gp={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(HZ,"noColor");s(zZ,"colorize");VZ={native:gp.green,embedded:gp.blue,partial:gp.yellow,none:gp.dim};s(N$,"coloredSymbol");});function LS(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((H,tt)=>r?tt:`${H}${tt}${n.reset}`,"c"),i=s(H=>H.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((H,tt)=>{let it=i(H),v=Math.max(0,tt-it);return H+" ".repeat(v)},"padWithColor"),l=Math.max(12,...e.map(H=>H.length)),c=e.map(H=>P$(H)),m=Math.max(8,l),p=Math.max(12,...t.map(H=>H.feature.length)),u=s(H=>o(n.dim,"\u250C"+H.map(tt=>"\u2500".repeat(tt)).join("\u252C")+"\u2510"),"border"),f=s(H=>o(n.dim,"\u251C"+H.map(tt=>"\u2500".repeat(tt)).join("\u253C")+"\u2524"),"sep"),g=s(H=>o(n.dim,"\u2514"+H.map(tt=>"\u2500".repeat(tt)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],S=u(h),C=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(H=>a(o(n.bold+n.magenta,H),m))],R=o(n.dim,"\u2502")+C.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),k=f(h),b=t.map(H=>{let tt=[a(o(n.cyan,H.feature),p)];for(let it of e){let v=H.support[it]??"none",q=r?kS[v]:N$(v);tt.push(a(` ${q} `,m));}return o(n.dim,"\u2502")+tt.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),N=g(h),x=[S,R,k,...b,N];x.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 x.push(o(n.bold,"Legend: ")+B.join(" ")),x.join(`
155
+ `)}var F$=d(()=>{x$();ES();s(LS,"formatMatrix");});function wS(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?"":`
152
156
  Per-file details:
153
157
  `+e.join(`
154
158
  `)+`
155
- `}var I$=d(()=>{s(hI,"formatVerboseDetails");});var yI=d(()=>{d$();R$();I$();});var _I={};Cg(_I,{runMatrix:()=>up});async function up(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 Ut(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=pI(a,c,n),u=hI(c);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var dp=d(()=>{Zt();ho();yI();Mr();s(up,"runMatrix");});var RI={};Cg(RI,{renderMatrix:()=>fp});function fp(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=fI(r,t.data.targets);process.stdout.write(n),process.stdout.write(`
159
+ `}var v$=d(()=>{s(wS,"formatVerboseDetails");});var AS=d(()=>{b$();F$();v$();});var bS={};Dg(bS,{runMatrix:()=>hp});async function hp(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 Ut(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=CS(a,c,n),u=wS(c);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var yp=d(()=>{Zt();yo();AS();$r();s(hp,"runMatrix");});var PS={};Dg(PS,{renderMatrix:()=>_p});function _p(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=LS(r,t.data.targets);process.stdout.write(n),process.stdout.write(`
156
160
  `),e?.verbose&&t.verboseDetails&&(process.stdout.write(t.verboseDetails),process.stdout.write(`
157
- `));}var gp=d(()=>{ot();yI();s(fp,"renderMatrix");});function DS(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(DS,"createRouter");ot();var kg=[{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)"}],Eg=[{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:"--accept-hooks",description:"Trust hooks.yaml from a non-local source. Stripped by default \u2014 hook commands run as shell on tool events."},{name:"--accept-permissions",description:"Trust permissions.yaml from a non-local source. Stripped by default \u2014 grants allowlist tool capabilities."},{name:"--accept-mcp",description:"Trust mcp.json from a non-local source. Stripped by default \u2014 MCP launch specs spawn child processes."},{name:"--accept-elevated",description:"Convenience for --accept-hooks --accept-permissions --accept-mcp together."}]},{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 jp(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
158
- `)}s(jp,"formatFlags");function Lg(){let t=Eg.map(e=>`- ${e.name.padEnd(8)} ${e.description}
161
+ `));}var Rp=d(()=>{ot();AS();s(_p,"renderMatrix");});function JI(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(JI,"createRouter");ot();var Ng=[{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)"}],Fg=[{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:"--lessons",description:"Scaffold the lessons recall + capture subsystem under .agentsmesh/lessons/ and append the procedural rule to .agentsmesh/rules/_root.md. Project mode only. Safe to run on an already-initialized project to retroactively add the subsystem."}]},{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:"--accept-hooks",description:"Trust hooks.yaml from a non-local source. Stripped by default \u2014 hook commands run as shell on tool events."},{name:"--accept-permissions",description:"Trust permissions.yaml from a non-local source. Stripped by default \u2014 grants allowlist tool capabilities."},{name:"--accept-mcp",description:"Trust mcp.json from a non-local source. Stripped by default \u2014 MCP launch specs spawn child processes."},{name:"--accept-elevated",description:"Convenience for --accept-hooks --accept-permissions --accept-mcp together."}]},{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 Vp(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
162
+ `)}s(Vp,"formatFlags");function vg(){let t=Fg.map(e=>`- ${e.name.padEnd(8)} ${e.description}
159
163
  Usage: ${e.usage}
160
- ${jp(e.flags)}`).join(`
164
+ ${Vp(e.flags)}`).join(`
161
165
 
162
166
  `);y.info(`agentsmesh <command> [flags]
163
167
 
164
168
  Global flags:
165
- ${jp(kg)}
169
+ ${Vp(Ng)}
166
170
 
167
171
  Commands:
168
172
  ${t}
169
173
 
170
- Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(Lg,"printHelp");function Up(t){let e=Eg.find(r=>r.name===t);if(!e){Lg();return}y.info(`${e.usage}
174
+ Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(vg,"printHelp");function Jp(t){let e=Fg.find(r=>r.name===t);if(!e){vg();return}y.info(`${e.usage}
171
175
 
172
176
  ${e.description}
173
177
 
174
178
  Command flags:
175
- ${jp(e.flags)}
179
+ ${Vp(e.flags)}
176
180
 
177
181
  Global flags:
178
- ${jp(kg)}`);}s(Up,"printCommandHelp");var Bp;function B0(){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(B0,"readPackageVersion");function K0(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(K0,"getVersionFallback");function Oi(){return Bp||(Bp=B0()??K0(),Bp)}s(Oi,"getVersion");function $S(){process.stdout.write(`agentsmesh v${Oi()}
179
- `);}s($S,"printVersion");ot();function Ja(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(Ja,"emitJson");var Rn=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function GS(t,e){let r=t instanceof Rn?2:1;if(e?.json)return Ja(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(GS,"handleError");ot();function le(t,e,r,n){if(r.json===true){let o=e.exitCode===0;Ja(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(le,"handleResult");Zt();ho();A();Hp();function kf(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(kf,"hashContent");async function Ef(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(Ef,"hashFile");async function Lf(t){try{if(!Kp(t)){let r=await readFile(t);return createHash("sha256").update(r).digest("hex")}let e=await readFile(t,"utf-8");return e.startsWith(Za)&&(e=e.slice(Za.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(Lf,"hashFileForManifest");yc();var qR=".lock",V2=[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:V2.some(e=>e(t))}s(J2,"isCanonical");var Y2={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 Of(t){let e=join(t,qR),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(Of,"readLock");async function wf(t,e){let r=join(t,qR),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.
182
+ ${Vp(Ng)}`);}s(Jp,"printCommandHelp");var Yp;function fB(){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(fB,"readPackageVersion");function gB(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(gB,"getVersionFallback");function Ai(){return Yp||(Yp=fB()??gB(),Yp)}s(Ai,"getVersion");function qI(){process.stdout.write(`agentsmesh v${Ai()}
183
+ `);}s(qI,"printVersion");ot();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)+`
184
+ `);}s(Za,"emitJson");var In=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function tC(t,e){let r=t instanceof In?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+`
185
+ `):y.error(t.message),process.exit(r);}s(tC,"handleError");ot();function le(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(le,"handleResult");Zt();yo();A();Qp();function Pf(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(Pf,"hashContent");async function xf(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(xf,"hashFile");async function Tf(t){try{if(!Xp(t)){let r=await readFile(t);return createHash("sha256").update(r).digest("hex")}let e=await readFile(t,"utf-8");return e.startsWith(tl)&&(e=e.slice(tl.length)),e=Zp(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(Tf,"hashFileForManifest");Sc();var mS=".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 Df(t){let e=join(t,mS),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(Df,"readLock");async function Nf(t,e){let r=join(t,mS),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.
182
186
  # Tracks the state of all config files for team conflict resolution.
183
187
 
184
- `+stringify(n);await S(r,o);}s(wf,"writeLock");async function Rs(t){if(!await j(t))return {};let e=await G(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===qR||!J2(o))continue;let i=await Ef(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(Rs,"buildChecksums");function Af(t,e,r){if(r.length===0)return [];let n=r.map(a=>Y2[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(Af,"detectLockedFeatureViolations");async function bf(t){let e=await Sf(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(bf,"buildPackChecksums");async function _c(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=kf(i),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}s(_c,"buildExtendChecksums");Tt();ce();function Rc(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Rc,"getAdditionalRootDecorationPaths");function EM(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(EM,"resolveRewriteFamilyId");pe();fh();function X2(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(X2,"addDirectoryMapping");function LM(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)X2(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}s(LM,"addSkillDirectoryMappings");Tt();function OM(t,e,r="project"){let n=Kt(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(OM,"ruleTargetPath");function wM(t,e,r,n="project"){let o=Kt(t,n);return o?o.paths.commandPath(e,r):null}s(wM,"commandTargetPath");function AM(t,e,r,n="project"){let o=Kt(t,n);return o?o.paths.agentPath(e,r):null}s(AM,"agentTargetPath");ye();Xt();Ee();Tt();function q2(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(q2,"addDirectoryMapping");function tI(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=OM(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=wM(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=AM(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let i=sp(t,n);if(!i)return o;for(let a of e.skills){q2(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),LM(o,m,p);}}return o}s(tI,"buildReferenceMap");pe();pe();Tt();function PM(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(PM,"addPackAbsoluteDirMapping");function tX(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(tX,"skillSupportingDirPrefixes");function TM(t,e,r,n,o){let i=sp(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));PM(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 tX(c.supportingFiles))PM(t,a.join(m,u),a.join(p,u),a);}}s(TM,"addPackSkillArtifactMappings");pe();function eX(t){return `.agentsmesh/rules/${basename(t.source)}`}s(eX,"canonicalRulePath");function rX(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(rX,"copilotInstructionsPath");function DM(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,eX(a))),i.normalize(i.join(r,rX(a))));}s(DM,"applyCopilotInstructionArtifactRefs");Tt();function eI(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(eI,"pushUnique");function NM(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);eI(o,i);let a=Kt(t,n);if(e.root)for(let l of Rc(a))eI(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])eI(o,l);return o}s(NM,"extraRuleOutputPaths");Tt();function FM(t,e,r,n,o,i){let a=Kt(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(FM,"addSkillMirrorSourceEntry");function oX(t){return `.agentsmesh/commands/${t.name}.md`}s(oX,"canonicalCommandPath");function sX(t){return `.agentsmesh/agents/${t.name}.md`}s(sX,"canonicalAgentPath");function iX(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(iX,"canonicalSkillPath");function vM(t,e,r,n,o,i){let a=i?.scope??"project",l=at(n),c=new Map([...tI(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return DM(t,c,n,o,e),TM(c,t,e,n,a),c}s(vM,"buildArtifactPathMap");function MM(t,e,r,n="project",o){let i=tI(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of NM(t,l,i,n))a.set(c,l.source);for(let l of e.commands){let c=i.get(oX(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=i.get(sX(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=i.get(iX(l));c&&(a.set(c,l.source),FM(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),FM(t,n,u,m.absolutePath,a,o));}}return a}s(MM,"buildOutputSourceMap");Tt();ce();th();function cX(t,e){if(!e)return null;for(let r of e){let n=nt(r);if(n?.sharedArtifacts){for(let[o,i]of Object.entries(n.sharedArtifacts))if(i==="owner"&&t.startsWith(o))return r}}return null}s(cX,"findSharedArtifactOwner");function $M(t,e,r){if(e==="global"){let n=cX(t.path,r);if(n)return n;let o=zC(t.path);if(o)return o}return t.target}s($M,"artifactMapTargetForResult");function mX(t,e){return `${t}\0${(e??[]).join(",")}`}s(mX,"sourceMapCacheKey");function rI(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(rI,"collectPlannedPaths");function pX(t,e,r){let n=Kt(t.target,e),o=EM(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=$M(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(pX,"artifactCacheKey");function GM(t,e,r,n,o="project",i,a){let l=rI(n,t),c=new Map,m=new Map;return t.map(p=>{if(a?.has(p.path))return p;let u=mX(p.target,i),g=(m.get(u)??(()=>{let C=MM(p.target,e,r,o,i);return m.set(u,C),C})()).get(p.path);if(!g)return p;let h=$M(p,o,i),R=pX(p,o,i),k=c.get(R)??(()=>{let C=vM(h,e,r,n,p.path,{scope:o});return c.set(R,C),C})(),I=Iu({content:p.content,projectRoot:n,sourceFile:g,destinationFile:at(n).join(n,p.path),translatePath:s(C=>k.get(C)??C,"translatePath"),pathExists:s(C=>l.has(C)||existsSync(C),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:s(C=>{try{return statSync(C).isDirectory()}catch{return false}},"pathIsDirectory")});return I.content===p.content?p:{...p,content:I.content}})}s(GM,"rewriteGeneratedReferences");pe();Ps();ot();var dX=/!?\[[^\]]*\]\(([^)]+)\)/g,fX=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function gX(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(gX,"isMarkdownLikeOutput");function hX(t,e){return e.some(([r,n])=>t>=r&&t<n)}s(hX,"isOffsetInRanges");function yX(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(yX,"parseMarkdownLinkDestination");function _X(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(_X,"shouldSkipLocalValidation");function RX(t){return /(?:^|\/)[^/]+\/skills\/[^/]+\//.test(t)}s(RX,"isSkillGeneratedOutput");var IX={rules:"rules",steering:"rules",commands:"commands",agents:"agents",skills:"skills",droids:"agents",instructions:"rules",prompts:"commands"},SX={".clinerules":"rules"},CX=[".agent.md",".instructions.md",".prompt.md"];function jM(t){for(let e of CX)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(jM,"stripMarkdownExt");function kX(t){let e=/^[^/]+\/([^/]+)\/([^/]+)/.exec(t);if(e){let n=IX[e[1]??""];if(n){let o=e[2]??"";return n!=="skills"&&(o=jM(o)),`${n}/${o}`}}let r=/^([^/]+)\/([^/]+)/.exec(t);if(r){let n=SX[r[1]??""];if(n)return `${n}/${jM(r[2]??"")}`}return null}s(kX,"canonicalKeyFromOutputPath");function EX(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(EX,"pathExistsForGenerate");function LX(t,e,r){let o=yX(t).split("#")[0]??"",{candidate:i}=fl(o),a=i,l=gl.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(_X(c,e))return [];let m=im(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 am(e,u)){let g=X(e,f);p.includes(g)||p.push(g);}return p}s(LX,"resolveMarkdownLinkTargets");function OX(t,e){let r=rI(e,t),n=[];for(let o of t){if(!gX(o.path))continue;let i=X(e,at(e).join(e,o.path)),a=Ru(o.content),l=s((c,m)=>{if(hX(m,a))return;let p=LX(c,e,i);p.length!==0&&(p.some(u=>EX(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:p}));},"visitDestination");for(let c of o.content.matchAll(dX)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(fX)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}s(OX,"findBrokenMarkdownLinks");function UM(t,e,r={}){let n=OX(t,e);if(n.length===0)return;let o=r.packOriginatedKeys,i=[],a=[];for(let c of n){let m=kX(c.generatePath),p=o!==void 0&&m!==null&&o.has(m);RX(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):
188
+ `+stringify(n);await I(r,o);}s(Nf,"writeLock");async function Ss(t){if(!await j(t))return {};let e=await G(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===mS||!EX(o))continue;let i=await xf(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(Ss,"buildChecksums");function Ff(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(Ff,"detectLockedFeatureViolations");async function vf(t){let e=await Af(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(vf,"buildPackChecksums");async function Ic(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 Ss(n),i=Object.keys(o).sort().map(c=>`${c}:${o[c]}`).join(`
189
+ `),a=Pf(i),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}s(Ic,"buildExtendChecksums");xt();ce();function Cc(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Cc,"getAdditionalRootDecorationPaths");function jM(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(jM,"resolveRewriteFamilyId");pe();Lh();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");xt();function BM(t,e,r="project"){let n=Wt(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(BM,"ruleTargetPath");function KM(t,e,r,n="project"){let o=Wt(t,n);return o?o.paths.commandPath(e,r):null}s(KM,"commandTargetPath");function WM(t,e,r,n="project"){let o=Wt(t,n);return o?o.paths.agentPath(e,r):null}s(WM,"agentTargetPath");ye();Xt();Ee();xt();function bX(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(bX,"addDirectoryMapping");function pS(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=BM(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=KM(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=WM(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let i=cp(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(pS,"buildReferenceMap");pe();pe();xt();function zM(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(zM,"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 VM(t,e,r,n,o){let i=cp(e,o);if(!i)return;let a=lt(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));zM(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))zM(t,a.join(m,u),a.join(p,u),a);}}s(VM,"addPackSkillArtifactMappings");pe();function xX(t){return `.agentsmesh/rules/${basename(t.source)}`}s(xX,"canonicalRulePath");function TX(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(TX,"copilotInstructionsPath");function YM(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let i=lt(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,xX(a))),i.normalize(i.join(r,TX(a))));}s(YM,"applyCopilotInstructionArtifactRefs");xt();function uS(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(uS,"pushUnique");function XM(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);uS(o,i);let a=Wt(t,n);if(e.root)for(let l of Cc(a))uS(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])uS(o,l);return o}s(XM,"extraRuleOutputPaths");xt();function ZM(t,e,r,n,o,i){let a=Wt(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(ZM,"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 QM(t,e,r,n,o,i){let a=i?.scope??"project",l=lt(n),c=new Map([...pS(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return YM(t,c,n,o,e),VM(c,t,e,n,a),c}s(QM,"buildArtifactPathMap");function qM(t,e,r,n="project",o){let i=pS(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of XM(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),ZM(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),ZM(t,n,u,m.absolutePath,a,o));}}return a}s(qM,"buildOutputSourceMap");xt();ce();ph();function GX(t,e){if(!e)return null;for(let r of e){let n=nt(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 t$(t,e,r){if(e==="global"){let n=GX(t.path,r);if(n)return n;let o=ak(t.path);if(o)return o}return t.target}s(t$,"artifactMapTargetForResult");function jX(t,e){return `${t}\0${(e??[]).join(",")}`}s(jX,"sourceMapCacheKey");function dS(t,e){let r=lt(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(dS,"collectPlannedPaths");function UX(t,e,r){let n=Wt(t.target,e),o=jM(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=t$(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(UX,"artifactCacheKey");function e$(t,e,r,n,o="project",i,a){let l=dS(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=qM(p.target,e,r,o,i);return m.set(u,k),k})()).get(p.path);if(!g)return p;let h=t$(p,o,i),S=UX(p,o,i),C=c.get(S)??(()=>{let k=QM(h,e,r,n,p.path,{scope:o});return c.set(S,k),k})(),R=wu({content:p.content,projectRoot:n,sourceFile:g,destinationFile:lt(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 R.content===p.content?p:{...p,content:R.content}})}s(e$,"rewriteGeneratedReferences");pe();Ts();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=X(e,e),o=X(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 r$(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(r$,"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=r$(o)),`${n}/${o}`}}let r=/^([^/]+)\/([^/]+)/.exec(t);if(r){let n=ZX[r[1]??""];if(n)return `${n}/${r$(r[2]??"")}`}return null}s(qX,"canonicalKeyFromOutputPath");function tZ(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(tZ,"pathExistsForGenerate");function eZ(t,e,r){let o=VX(t).split("#")[0]??"",{candidate:i}=yl(o),a=i,l=_l.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=mm(c,e,r);if(m.length===0){let u=lt(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 pm(e,u)){let g=X(e,f);p.includes(g)||p.push(g);}return p}s(eZ,"resolveMarkdownLinkTargets");function rZ(t,e){let r=dS(e,t),n=[];for(let o of t){if(!HX(o.path))continue;let i=X(e,lt(e).join(e,o.path)),a=Ou(o.content),l=s((c,m)=>{if(zX(m,a))return;let p=eZ(c,e,i);p.length!==0&&(p.some(u=>tZ(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(rZ,"findBrokenMarkdownLinks");function n$(t,e,r={}){let n=rZ(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):
186
190
  ${c.join(`
187
191
  `)}`);}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:
188
192
  ${l.join(`
189
193
  `)}
190
- Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(UM,"validateGeneratedMarkdownLinks");var wX=[`${sep}.agentsmesh${sep}packs${sep}`,"/.agentsmesh/packs/"];function Tf(t){return wX.some(e=>t.includes(e))}s(Tf,"isUnderPacks");function BM(t){let e=new Set;for(let r of t.rules)if(Tf(r.source)){let n=r.root?"_root":AX(r.source);n&&e.add(`rules/${n}`);}for(let r of t.agents)Tf(r.source)&&e.add(`agents/${r.name}`);for(let r of t.commands)Tf(r.source)&&e.add(`commands/${r.name}`);for(let r of t.skills)Tf(r.source)&&e.add(`skills/${r.name}`);return e}s(BM,"buildPackOriginatedKeys");function AX(t){let r=t.replace(/\\/g,"/").split("/").pop()??"";return r.endsWith(".md")?r.slice(0,-3):r}s(AX,"ruleNameFromSource");Sn();var zM="AGENTS.md";function KM(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(KM,"statusRank");function bX(t,e){return KM(e.status)<=KM(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(bX,"mergeDuplicateMetadata");function xf(t){return t.trim()}s(xf,"trimmedContent");var PX=[/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->\n*/g];function WM(t){let e=t;for(let r of PX)e=e.replace(r,"");return e.trim().replace(/\n{2,}/g,`
194
+ Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(n$,"validateGeneratedMarkdownLinks");var nZ=[`${sep}.agentsmesh${sep}packs${sep}`,"/.agentsmesh/packs/"];function $f(t){return nZ.some(e=>t.includes(e))}s($f,"isUnderPacks");function o$(t){let e=new Set;for(let r of t.rules)if($f(r.source)){let n=r.root?"_root":oZ(r.source);n&&e.add(`rules/${n}`);}for(let r of t.agents)$f(r.source)&&e.add(`agents/${r.name}`);for(let r of t.commands)$f(r.source)&&e.add(`commands/${r.name}`);for(let r of t.skills)$f(r.source)&&e.add(`skills/${r.name}`);return e}s(o$,"buildPackOriginatedKeys");function oZ(t){let r=t.replace(/\\/g,"/").split("/").pop()??"";return r.endsWith(".md")?r.slice(0,-3):r}s(oZ,"ruleNameFromSource");kn();var l$="AGENTS.md";function s$(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(s$,"statusRank");function sZ(t,e){return s$(e.status)<=s$(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(sZ,"mergeDuplicateMetadata");function Gf(t){return t.trim()}s(Gf,"trimmedContent");var iZ=[/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->\n*/g];function i$(t){let e=t;for(let r of iZ)e=e.replace(r,"");return e.trim().replace(/\n{2,}/g,`
191
195
 
192
- `)}s(WM,"normalizeAgentsContent");function HM(t){return /<!-- agentsmesh:embedded-rules:start -->/.test(t)}s(HM,"hasOptionalAgentsBlock");function TX(t,e){if(!t.path.endsWith(zM)||t.path!==e.path)return null;let r=xf(t.content),n=xf(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);if(o!==i)return o?t:e;if(WM(t.content)===WM(e.content)){let a=HM(t.content),l=HM(e.content);if(a!==l)return a?t:e}return null}s(TX,"richerAgentsResult");function xX(t,e){if(!t.path.endsWith(zM)||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=xf(r.content).length,i=xf(n.content).length;return o===i?null:o>i?r:n}s(xX,"richerCodexAgentsResult");function Df(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=TX(o,r);if(i){e[n]=i;continue}let a=xX(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]=bX(o,r);}return e}s(Df,"resolveOutputCollisions");function VM(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(VM,"refreshResultStatus");A();Tt();ce();function YM(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(YM,"computeStatus");function DX(t,e,r){let n=AR(t,e,r);if(n!==null)return n;let o=nt(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(DX,"resolveGeneratedOutputPath");async function mp(t,e,r,n,o,i){let a=DX(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:YM(l,p)}),a}s(mp,"emitGeneratedOutput");function oI(t,e,r){return {capability:di(t,r)?.[e]??{level:"none"},scope:r}}s(oI,"featureContext");async function va(t,e,r,n,o,i,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=oI(c,a,i);for(let u of m(r,p)){let f=await mp(t,c,u,n,i);if(f===null)continue;let g=Kt(c,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),R=h===null?[]:Array.isArray(h)?h:[h];for(let k of R){let I=await _(join(n,k));t.push({target:c,path:k,content:u.content,currentContent:I??void 0,status:YM(I,u.content)});}}}}}s(va,"generateFeature");sh();Tt();function NX(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Rc(t)]:[]}s(NX,"rootDecorationPaths");function XM(t,e,r="project"){return t.map(n=>{let o=Kt(n.target,r);if(!o)return n;let i=NX(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=ek(l);return c===n.content?n:{...n,content:c}})}s(XM,"decoratePrimaryRootInstructions");Tt();ce();hd();function sI(t,e,r,n,o){let a=(Fr(t)??nt(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&kP.includes(o)?EP(l,n):n}s(sI,"mergeOutputContent");async function ZM(t,e,r,n,o){for(let i of e){let a=gc(i,"permissions",void 0,o)??nt(i)?.generators.generatePermissions;if(a)for(let l of a(r))await mp(t,i,l,n,o,{mergeContent:s((c,m,p,u)=>sI(i,c,m,p,u),"mergeContent")});}}s(ZM,"generatePermissionsFeature");async function QM(t,e,r,n,o,i){for(let a of e){let l=gc(a,"hooks",i,o)??nt(a)?.generators.generateHooks;if(!l)continue;let c=oI(a,"hooks",o),m=[...l(r,c)],u=(Fr(a)??nt(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let f of m)await mp(t,a,f,n,o,{mergeContent:s((g,h,R,k)=>sI(a,g,h,R,k),"mergeContent")});}}s(QM,"generateHooksFeature");async function qM(t,e,r,n,o){for(let i of e){let l=(Fr(i)??nt(i))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await mp(t,i,m,n,o,{mergeContent:s((p,u,f,g)=>sI(i,p,u,f,g),"mergeContent")});}}s(qM,"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,H){return gc(B,H,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"),k=e.features.includes("ignore"),I=[];await va(I,l,r,n,m,o,"rules",B=>c(B,"rules")),await va(I,l,r,n,p,o,"commands",B=>c(B,"commands")),await va(I,l,r,n,u,o,"agents",B=>c(B,"agents")),await va(I,l,r,n,f,o,"skills",B=>c(B,"skills")),await va(I,l,r,n,g,o,"mcp",B=>c(B,"mcp")),h&&await ZM(I,l,r,n,o),R&&await QM(I,l,r,n,o,e),await va(I,l,r,n,k,o,"ignore",B=>c(B,"ignore"));let C=new Set(e.features);for(let B of l){let tt=(Fr(B)??nt(B))?.globalSupport?.scopeExtras;if(tt){let it=await tt(r,n,o,C);I.push(...it);}}(g||k||R||u||h)&&await qM(I,l,r,n,o);let b=XM(I,r,o),N=FX(b,o),T=GM(b,r,e,n,o,l,N);return UM(T,n,{packOriginatedKeys:BM(r)}),Df(T.map(VM))}s(vr,"generate");function FX(t,e){let r=new Map;function n(a){let l=r.get(a);if(l)return l;let c=Kt(a,e),m=new Set;if(c?.rootInstructionPath){m.add(c.rootInstructionPath);for(let p of Rc(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(FX,"computeSharedRootInstructionPaths");Mr();ot();A();Io();var XX=6e4,ZX=30,QX=200,qX=2e3;async function Ff(t,e={}){let r=e.retries??ZX,n=e.retryDelayMs??QX,o=e.staleMs??XX;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await tZ(t);if(a)return a;let l=await eZ(t);if(l!=="young"&&rZ(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let c=l==="young"?null:l;throw new Xa(t,oZ(c))}i++,await iZ(n);}}s(Ff,"acquireProcessLock");async function tZ(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:l$()};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(tZ,"tryAcquire");async function eZ(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return sZ(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<qX)return "young"}catch{}return null}}s(eZ,"inspectLock");function rZ(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==l$()?false:!nZ(t.pid)}s(rZ,"isStale");function nZ(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(nZ,"isProcessAlive");function oZ(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(oZ,"describeHolder");function sZ(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(sZ,"isLockMetadata");function l$(){return hostname()}s(l$,"getHostname");function iZ(t){return new Promise(e=>setTimeout(e,t))}s(iZ,"sleep");A();Tt();async function c$(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 c$(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(c$,"listFiles");async function mZ(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(mZ,"removeIfStale");async function m$(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let i=wR(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 c$(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await mZ(t.projectRoot,o,e);}s(m$,"cleanupStaleGeneratedOutputs");function Ic(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(Ic,"ensurePathInsideRoot");Vc();A();ot();async function mI(t,e){let r=await Rs(t.canonicalDir),n=e.length>0?await _c(e):{},o=await bf(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await wf(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:Oi(),checksums:r,extends:n,packs:o});try{await wg(ve(),join(t.configDir,".agentsmeshcache"));}catch(a){y.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(mI,"writeLockFile");async function S$(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:vf([])}};if(n||await mI(o,i),c.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(dp(),_I)),{renderMatrix:p}=await Promise.resolve().then(()=>(gp(),RI)),u=await m(a,l);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:vf([])}}}s(S$,"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:vf(r)}}}s(C$,"buildCheckResult");async function k$(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 Ff(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let R=Ic(i.rootBase,h.path,h.target);await S(R,h.content);}await m$({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:n}),await mI(i,l);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(dp(),_I)),{renderMatrix:R}=await Promise.resolve().then(()=>(gp(),RI)),k=await h(c,m);R(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:vf(f)}}}s(k$,"handleGenerateOrDryRun");function vf(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(vf,"buildSummary");async function Sc(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 Ut(f,n);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let N=await Of(g.canonicalDir);if(N!==null){let T=await Rs(g.canonicalDir),B=Af(N.checksums,T,h);if(B.length>0){y.error("Locked feature violation (strategy: lock). Modified files:");for(let H of B)y.error(` ${H}`);throw y.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:R,resolvedExtends:k}=await Oe(f,g.configDir,{refreshRemoteCache:c},g.canonicalDir),I=[...f.targets,...f.pluginTargets??[]];if(p){let N=p.filter(T=>!I.includes(T));if(N.length>0)throw new Error(`Unknown target(s) in --targets: ${N.join(", ")}. Available: ${I.join(", ")}`)}let C=p?I.filter(N=>p.includes(N)):I,b=await vr({config:f,canonical:R,projectRoot:g.rootBase,scope:l,targetFilter:p});return b.length===0?S$({mode:u,scope:l,dryRun:i,context:g,resolvedExtends:k,flags:t,root:n,options:r}):o?C$(b,l):k$({results:b,dryRun:i,scope:l,mode:u,context:g,activeTargets:C,resolvedExtends:k,flags:t,root:n,options:r})}s(Sc,"runGenerate");ot();function II(t,e){return t==="global"?`~/${e}`:e}s(II,"formatDisplayPath");function Cc(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} ${II(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} ${II(r,c.path)} (${c.target})`);return}for(let c of o)(c.status==="created"||c.status==="updated")&&y.success(`${c.status} ${II(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(Cc,"renderGenerate");A();Tt();Tt();Sn();function E$(){return Pt.filter(t=>!t.excludeFromStarterInit).map(t=>t.id).filter(Fe)}s(E$,"starterInitTargetIds");var L$=/^# yaml-language-server: \$schema=[^\n]*\n?/;function RZ(){let t=Oi();return `https://unpkg.com/agentsmesh${t&&t!=="unknown"?`@${t}`:""}/schemas`}s(RZ,"schemaBaseUrl");function O$(t){return `${RZ()}/${t}.json`}s(O$,"schemaUrl");function kc(t){return `# yaml-language-server: $schema=${O$(t)}
193
- `}s(kc,"yamlSchemaDirective");function Ma(t,e){let r=kc(e);return L$.test(t)?t.replace(L$,r):`${r}${t}`}s(Ma,"prependYamlSchemaDirective");function w$(t,e){let{$schema:r,...n}=t;return {$schema:O$(e),...n}}s(w$,"stampJsonSchemaField");var IZ=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],SZ=E$();function Mf(t,e=SZ){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
194
- `),n=IZ.map(o=>` - ${o}`).join(`
195
- `);return `${kc("agentsmesh")}version: 1
196
+ `)}s(i$,"normalizeAgentsContent");function a$(t){return /<!-- agentsmesh:embedded-rules:start -->/.test(t)}s(a$,"hasOptionalAgentsBlock");function aZ(t,e){if(!t.path.endsWith(l$)||t.path!==e.path)return null;let r=Gf(t.content),n=Gf(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);if(o!==i)return o?t:e;if(i$(t.content)===i$(e.content)){let a=a$(t.content),l=a$(e.content);if(a!==l)return a?t:e}return null}s(aZ,"richerAgentsResult");function lZ(t,e){if(!t.path.endsWith(l$)||t.path!==e.path)return null;let r=t.target===Ug?t:e.target===Ug?e:null,n=r===t?e:t;if(!r)return null;let o=Gf(r.content).length,i=Gf(n.content).length;return o===i?null:o>i?r:n}s(lZ,"richerCodexAgentsResult");function jf(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=aZ(o,r);if(i){e[n]=i;continue}let a=lZ(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]=sZ(o,r);}return e}s(jf,"resolveOutputCollisions");function c$(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(c$,"refreshResultStatus");A();xt();ce();function p$(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(p$,"computeStatus");function cZ(t,e,r){let n=GR(t,e,r);if(n!==null)return n;let o=nt(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(cZ,"resolveGeneratedOutputPath");async function fp(t,e,r,n,o,i){let a=cZ(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:p$(l,p)}),a}s(fp,"emitGeneratedOutput");function gS(t,e,r){return {capability:gi(t,r)?.[e]??{level:"none"},scope:r}}s(gS,"featureContext");async function $a(t,e,r,n,o,i,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=gS(c,a,i);for(let u of m(r,p)){let f=await fp(t,c,u,n,i);if(f===null)continue;let g=Wt(c,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),S=h===null?[]:Array.isArray(h)?h:[h];for(let C of S){let R=await _(join(n,C));t.push({target:c,path:C,content:u.content,currentContent:R??void 0,status:p$(R,u.content)});}}}}}s($a,"generateFeature");hh();xt();function mZ(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Cc(t)]:[]}s(mZ,"rootDecorationPaths");function u$(t,e,r="project"){return t.map(n=>{let o=Wt(n.target,r);if(!o)return n;let i=mZ(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=hk(l);return c===n.content?n:{...n,content:c}})}s(u$,"decoratePrimaryRootInstructions");xt();ce();kd();function hS(t,e,r,n,o){let a=(vr(t)??nt(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&$P.includes(o)?GP(l,n):n}s(hS,"mergeOutputContent");async function d$(t,e,r,n,o){for(let i of e){let a=_c(i,"permissions",void 0,o)??nt(i)?.generators.generatePermissions;if(a)for(let l of a(r))await fp(t,i,l,n,o,{mergeContent:s((c,m,p,u)=>hS(i,c,m,p,u),"mergeContent")});}}s(d$,"generatePermissionsFeature");async function f$(t,e,r,n,o,i){for(let a of e){let l=_c(a,"hooks",i,o)??nt(a)?.generators.generateHooks;if(!l)continue;let c=gS(a,"hooks",o),m=[...l(r,c)],u=(vr(a)??nt(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let f of m)await fp(t,a,f,n,o,{mergeContent:s((g,h,S,C)=>hS(a,g,h,S,C),"mergeContent")});}}s(f$,"generateHooksFeature");async function g$(t,e,r,n,o){for(let i of e){let l=(vr(i)??nt(i))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await fp(t,i,m,n,o,{mergeContent:s((p,u,f,g)=>hS(i,p,u,f,g),"mergeContent")});}}s(g$,"generateScopedSettingsFeature");async function Mr(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,H){return _c(B,H,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"),S=e.features.includes("hooks"),C=e.features.includes("ignore"),R=[];await $a(R,l,r,n,m,o,"rules",B=>c(B,"rules")),await $a(R,l,r,n,p,o,"commands",B=>c(B,"commands")),await $a(R,l,r,n,u,o,"agents",B=>c(B,"agents")),await $a(R,l,r,n,f,o,"skills",B=>c(B,"skills")),await $a(R,l,r,n,g,o,"mcp",B=>c(B,"mcp")),h&&await d$(R,l,r,n,o),S&&await f$(R,l,r,n,o,e),await $a(R,l,r,n,C,o,"ignore",B=>c(B,"ignore"));let k=new Set(e.features);for(let B of l){let tt=(vr(B)??nt(B))?.globalSupport?.scopeExtras;if(tt){let it=await tt(r,n,o,k);R.push(...it);}}(g||C||S||u||h)&&await g$(R,l,r,n,o);let b=u$(R,r,o),N=pZ(b,o),x=e$(b,r,e,n,o,l,N);return n$(x,n,{packOriginatedKeys:o$(r)}),jf(x.map(c$))}s(Mr,"generate");function pZ(t,e){let r=new Map;function n(a){let l=r.get(a);if(l)return l;let c=Wt(a,e),m=new Set;if(c?.rootInstructionPath){m.add(c.rootInstructionPath);for(let p of Cc(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(pZ,"computeSharedRootInstructionPaths");$r();ot();A();Io();var OZ=6e4,wZ=30,AZ=200,bZ=2e3;async function Bf(t,e={}){let r=e.retries??wZ,n=e.retryDelayMs??AZ,o=e.staleMs??OZ;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await PZ(t);if(a)return a;let l=await xZ(t);if(l!=="young"&&TZ(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let c=l==="young"?null:l;throw new qa(t,NZ(c))}i++,await vZ(n);}}s(Bf,"acquireProcessLock");async function PZ(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:E$()};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(PZ,"tryAcquire");async function xZ(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return FZ(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<bZ)return "young"}catch{}return null}}s(xZ,"inspectLock");function TZ(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==E$()?false:!DZ(t.pid)}s(TZ,"isStale");function DZ(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(DZ,"isProcessAlive");function NZ(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(NZ,"describeHolder");function FZ(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(FZ,"isLockMetadata");function E$(){return hostname()}s(E$,"getHostname");function vZ(t){return new Promise(e=>setTimeout(e,t))}s(vZ,"sleep");A();xt();async function L$(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 L$(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(L$,"listFiles");async function jZ(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(jZ,"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=$R(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 L$(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await jZ(t.projectRoot,o,e);}s(O$,"cleanupStaleGeneratedOutputs");function kc(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(kc,"ensurePathInsideRoot");Zc();A();ot();async function IS(t,e){let r=await Ss(t.canonicalDir),n=e.length>0?await Ic(e):{},o=await vf(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await Nf(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:Ai(),checksums:r,extends:n,packs:o});try{await $g(Me(),join(t.configDir,".agentsmeshcache"));}catch(a){y.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(IS,"writeLockFile");async function M$(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:Kf([])}};if(n||await IS(o,i),c.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(yp(),bS)),{renderMatrix:p}=await Promise.resolve().then(()=>(Rp(),PS)),u=await m(a,l);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Kf([])}}}s(M$,"handleEmptyResults");function $$(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:Kf(r)}}}s($$,"buildCheckResult");async function G$(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 Bf(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let S=kc(i.rootBase,h.path,h.target);await I(S,h.content);}await O$({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:n}),await IS(i,l);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(yp(),bS)),{renderMatrix:S}=await Promise.resolve().then(()=>(Rp(),PS)),C=await h(c,m);S(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:Kf(f)}}}s(G$,"handleGenerateOrDryRun");function Kf(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(Kf,"buildSummary");async function Ec(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 Ut(f,n);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let N=await Df(g.canonicalDir);if(N!==null){let x=await Ss(g.canonicalDir),B=Ff(N.checksums,x,h);if(B.length>0){y.error("Locked feature violation (strategy: lock). Modified files:");for(let H of B)y.error(` ${H}`);throw y.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:S,resolvedExtends:C}=await Oe(f,g.configDir,{refreshRemoteCache:c},g.canonicalDir),R=[...f.targets,...f.pluginTargets??[]];if(p){let N=p.filter(x=>!R.includes(x));if(N.length>0)throw new Error(`Unknown target(s) in --targets: ${N.join(", ")}. Available: ${R.join(", ")}`)}let k=p?R.filter(N=>p.includes(N)):R,b=await Mr({config:f,canonical:S,projectRoot:g.rootBase,scope:l,targetFilter:p});return b.length===0?M$({mode:u,scope:l,dryRun:i,context:g,resolvedExtends:C,flags:t,root:n,options:r}):o?$$(b,l):G$({results:b,dryRun:i,scope:l,mode:u,context:g,activeTargets:k,resolvedExtends:C,flags:t,root:n,options:r})}s(Ec,"runGenerate");ot();function xS(t,e){return t==="global"?`~/${e}`:e}s(xS,"formatDisplayPath");function Lc(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} ${xS(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} ${xS(r,c.path)} (${c.target})`);return}for(let c of o)(c.status==="created"||c.status==="updated")&&y.success(`${c.status} ${xS(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(Lc,"renderGenerate");A();xt();xt();kn();function j$(){return Pt.filter(t=>!t.excludeFromStarterInit).map(t=>t.id).filter(ve)}s(j$,"starterInitTargetIds");var U$=/^# yaml-language-server: \$schema=[^\n]*\n?/;function YZ(){let t=Ai();return `https://unpkg.com/agentsmesh${t&&t!=="unknown"?`@${t}`:""}/schemas`}s(YZ,"schemaBaseUrl");function B$(t){return `${YZ()}/${t}.json`}s(B$,"schemaUrl");function Oc(t){return `# yaml-language-server: $schema=${B$(t)}
197
+ `}s(Oc,"yamlSchemaDirective");function Ga(t,e){let r=Oc(e);return U$.test(t)?t.replace(U$,r):`${r}${t}`}s(Ga,"prependYamlSchemaDirective");function K$(t,e){let{$schema:r,...n}=t;return {$schema:B$(e),...n}}s(K$,"stampJsonSchemaField");var XZ=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],ZZ=j$();function Wf(t,e=ZZ){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
198
+ `),n=XZ.map(o=>` - ${o}`).join(`
199
+ `);return `${Oc("agentsmesh")}version: 1
196
200
  targets:
197
201
  ${r}
198
202
  features:
199
203
  ${n}
200
- `}s(Mf,"buildConfig");var $f=`---
204
+ `}s(Wf,"buildConfig");var Hf=`---
201
205
  root: true
202
206
  description: "Project rules"
203
207
  ---
@@ -206,7 +210,7 @@ description: "Project rules"
206
210
 
207
211
  Add your project-wide instructions here.
208
212
  This file is always included in AI tool context and synced to all configured tools.
209
- `,SI=`---
213
+ `,TS=`---
210
214
  description: "Example contextual rule \u2014 rename and customize"
211
215
  # targets: [claude-code, cursor] # limit to specific tools (optional)
212
216
  # globs: ["src/**/*.ts"] # activate only for matching files (optional)
@@ -215,14 +219,14 @@ description: "Example contextual rule \u2014 rename and customize"
215
219
  # Example Rule
216
220
 
217
221
  Replace this with your coding standards, conventions, or domain-specific guidelines.
218
- `,CI=`---
222
+ `,DS=`---
219
223
  description: "Example command \u2014 rename and customize"
220
224
  # allowed-tools: [Read, Grep, Glob, Bash]
221
225
  ---
222
226
 
223
227
  Describe the task for this command here.
224
228
  Commands are invoked on-demand (e.g. /example) with a focused tool set.
225
- `,kI=`---
229
+ `,NS=`---
226
230
  name: example-agent
227
231
  description: "Example subagent \u2014 rename and customize"
228
232
  # tools: [Read, Grep, Glob]
@@ -233,7 +237,7 @@ description: "Example subagent \u2014 rename and customize"
233
237
 
234
238
  Describe this agent's role and instructions here.
235
239
  Agents are specialized subagents with restricted tools and a specific purpose.
236
- `,EI=`---
240
+ `,FS=`---
237
241
  name: example-skill
238
242
  description: "Example skill \u2014 rename and customize"
239
243
  ---
@@ -242,7 +246,7 @@ description: "Example skill \u2014 rename and customize"
242
246
 
243
247
  Describe the skill procedure here.
244
248
  Skills are reusable multi-step procedures that commands and agents can reference.
245
- `,LI=`{
249
+ `,vS=`{
246
250
  "mcpServers": {
247
251
  // agentsmesh self-serve MCP server \u2014 exposes your canonical config to AI agents.
248
252
  // Lets agents introspect rules/commands/agents/skills and trigger generate.
@@ -269,7 +273,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
269
273
  // }
270
274
  }
271
275
  }
272
- `,OI=`${kc("hooks")}# Lifecycle hooks \u2014 run shell commands before/after AI tool use
276
+ `,MS=`${Oc("hooks")}# Lifecycle hooks \u2014 run shell commands before/after AI tool use
273
277
  # Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
274
278
  # Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
275
279
  #
@@ -282,7 +286,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
282
286
  # - matcher: Edit|Write
283
287
  # type: command
284
288
  # command: npm test --passWithNoTests
285
- `,wI=`${kc("permissions")}# Tool permission allow/deny lists
289
+ `,$S=`${Oc("permissions")}# Tool permission allow/deny lists
286
290
  #
287
291
  # allow:
288
292
  # - Bash(npm run:*)
@@ -298,14 +302,14 @@ Skills are reusable multi-step procedures that commands and agents can reference
298
302
  allow: []
299
303
  deny: []
300
304
  ask: []
301
- `,AI=`# Patterns ignored by all configured AI tools (gitignore syntax)
305
+ `,GS=`# Patterns ignored by all configured AI tools (gitignore syntax)
302
306
  #
303
307
  # node_modules/
304
308
  # dist/
305
309
  # .env*
306
310
  # *.log
307
311
  # coverage/
308
- `,A$=`${kc("agentsmesh")}# Personal overrides \u2014 NOT committed to git
312
+ `,W$=`${Oc("agentsmesh")}# Personal overrides \u2014 NOT committed to git
309
313
  # Uncomment and customize for your local setup:
310
314
 
311
315
  # targets:
@@ -323,47 +327,85 @@ ask: []
323
327
  # overrides:
324
328
  # claude-code:
325
329
  # model: opus
326
- `;A();Tt();function b$(t){let e=[];for(let r of Pt)for(let n of OR(r.id,t))e.push({target:r.id,path:n});return e}s(b$,"collectDetectionPaths");function P$(t){let e=new Map;for(let{target:r,path:n}of b$(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}s(P$,"toolIndicators");P$("project");async function T$(t,e="project"){let r=[];for(let{id:n,paths:o}of P$(e))for(let i of o){let a=join(t,i);if(await j(a)){r.push(n);break}}return [...new Set(r)]}s(T$,"detectExistingConfigs");A();ot();function se(t,e){return join(t,e)}s(se,"ab");async function bI(t){return await j(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(bI,"countMdFiles");async function kZ(t){let e=se(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(kZ,"hasAnyImportedSkill");async function PI(t){let e=se(t,"rules");await O(e),await S(join(e,"_root.md"),$f),y.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),SI),y.success("Created .agentsmesh/rules/_example.md");let r=se(t,"commands");await O(r),await S(join(r,"_example.md"),CI),y.success("Created .agentsmesh/commands/_example.md");let n=se(t,"agents");await O(n),await S(join(n,"_example.md"),kI),y.success("Created .agentsmesh/agents/_example.md");let o=se(t,join("skills","_example"));await O(o),await S(join(o,"SKILL.md"),EI),y.success("Created .agentsmesh/skills/_example/SKILL.md"),await S(se(t,"mcp.json"),LI),y.success("Created .agentsmesh/mcp.json"),await S(se(t,"hooks.yaml"),OI),y.success("Created .agentsmesh/hooks.yaml"),await S(se(t,"permissions.yaml"),wI),y.success("Created .agentsmesh/permissions.yaml"),await S(se(t,"ignore"),AI),y.success("Created .agentsmesh/ignore");}s(PI,"writeScaffoldFull");async function D$(t){let e=se(t,"rules"),r=await bI(e),n=join(e,"_root.md"),o=await j(n);await O(e),r===0?(await S(n,$f),y.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),SI),y.success("Created .agentsmesh/rules/_example.md")):o||(await S(n,$f),y.success("Created .agentsmesh/rules/_root.md"));let i=se(t,"commands");await bI(i)===0&&(await O(i),await S(join(i,"_example.md"),CI),y.success("Created .agentsmesh/commands/_example.md"));let a=se(t,"agents");if(await bI(a)===0&&(await O(a),await S(join(a,"_example.md"),kI),y.success("Created .agentsmesh/agents/_example.md")),!await kZ(t)){let u=se(t,join("skills","_example"));await O(u),await S(join(u,"SKILL.md"),EI),y.success("Created .agentsmesh/skills/_example/SKILL.md");}let l=se(t,"mcp.json");await j(l)||(await S(l,LI),y.success("Created .agentsmesh/mcp.json"));let c=se(t,"hooks.yaml");await j(c)||(await S(c,OI),y.success("Created .agentsmesh/hooks.yaml"));let m=se(t,"permissions.yaml");await j(m)||(await S(m,wI),y.success("Created .agentsmesh/permissions.yaml"));let p=se(t,"ignore");await j(p)||(await S(p,AI),y.success("Created .agentsmesh/ignore"));}s(D$,"writeScaffoldGapFill");Zt();var TI="agentsmesh.yaml",N$="agentsmesh.local.yaml",LZ=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],OZ=Object.fromEntries(Pt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),F$=Pt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function wZ(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(wZ,"isCoveredByExisting");async function AZ(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=LZ.filter(a=>!wZ(a,n));if(o.length===0)return false;let i=r.endsWith(`
330
+ `;A();xt();function H$(t){let e=[];for(let r of Pt)for(let n of MR(r.id,t))e.push({target:r.id,path:n});return e}s(H$,"collectDetectionPaths");function z$(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(z$,"toolIndicators");z$("project");async function V$(t,e="project"){let r=[];for(let{id:n,paths:o}of z$(e))for(let i of o){let a=join(t,i);if(await j(a)){r.push(n);break}}return [...new Set(r)]}s(V$,"detectExistingConfigs");A();ot();function se(t,e){return join(t,e)}s(se,"ab");async function jS(t){return await j(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(jS,"countMdFiles");async function qZ(t){let e=se(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(qZ,"hasAnyImportedSkill");async function US(t){let e=se(t,"rules");await O(e),await I(join(e,"_root.md"),Hf),y.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),TS),y.success("Created .agentsmesh/rules/_example.md");let r=se(t,"commands");await O(r),await I(join(r,"_example.md"),DS),y.success("Created .agentsmesh/commands/_example.md");let n=se(t,"agents");await O(n),await I(join(n,"_example.md"),NS),y.success("Created .agentsmesh/agents/_example.md");let o=se(t,join("skills","_example"));await O(o),await I(join(o,"SKILL.md"),FS),y.success("Created .agentsmesh/skills/_example/SKILL.md"),await I(se(t,"mcp.json"),vS),y.success("Created .agentsmesh/mcp.json"),await I(se(t,"hooks.yaml"),MS),y.success("Created .agentsmesh/hooks.yaml"),await I(se(t,"permissions.yaml"),$S),y.success("Created .agentsmesh/permissions.yaml"),await I(se(t,"ignore"),GS),y.success("Created .agentsmesh/ignore");}s(US,"writeScaffoldFull");async function Y$(t){let e=se(t,"rules"),r=await jS(e),n=join(e,"_root.md"),o=await j(n);await O(e),r===0?(await I(n,Hf),y.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),TS),y.success("Created .agentsmesh/rules/_example.md")):o||(await I(n,Hf),y.success("Created .agentsmesh/rules/_root.md"));let i=se(t,"commands");await jS(i)===0&&(await O(i),await I(join(i,"_example.md"),DS),y.success("Created .agentsmesh/commands/_example.md"));let a=se(t,"agents");if(await jS(a)===0&&(await O(a),await I(join(a,"_example.md"),NS),y.success("Created .agentsmesh/agents/_example.md")),!await qZ(t)){let u=se(t,join("skills","_example"));await O(u),await I(join(u,"SKILL.md"),FS),y.success("Created .agentsmesh/skills/_example/SKILL.md");}let l=se(t,"mcp.json");await j(l)||(await I(l,vS),y.success("Created .agentsmesh/mcp.json"));let c=se(t,"hooks.yaml");await j(c)||(await I(c,MS),y.success("Created .agentsmesh/hooks.yaml"));let m=se(t,"permissions.yaml");await j(m)||(await I(m,$S),y.success("Created .agentsmesh/permissions.yaml"));let p=se(t,"ignore");await j(p)||(await I(p,GS),y.success("Created .agentsmesh/ignore"));}s(Y$,"writeScaffoldGapFill");Zt();var tQ=".agentsmesh/lessons";function Is(t){let e=join(t,tQ);return {base:e,journal:join(e,"journal.md"),index:join(e,"index.yaml"),ledger:join(e,"distill-ledger.yaml"),proposal:join(e,"distill-proposal.md"),topicsDir:join(e,"topics")}}s(Is,"lessonsPaths");var zf=`# Lessons Learned
331
+
332
+ `,Vf=`version: 1
333
+ clusters: []
334
+ `,Sp=`## Lessons (MUST do \u2014 non-negotiable)
335
+
336
+ Two rituals. Universal across every agent harness \u2014 described in tool-agnostic action verbs ("read a file", "edit a file", "run a shell command"); use whatever read / write-patch / shell-exec tool your harness exposes. Skipping either ritual is a process violation; the same paid-for failure recurs next session.
337
+
338
+ **Recall \u2014 BEFORE editing any file or running any shell command:**
339
+
340
+ 1. Read \`.agentsmesh/lessons/index.yaml\`.
341
+ 2. For every cluster whose triggers match \u2014 \`file_globs\` against the target file path, \`command_patterns\` (regex) against the shell command, or \`keywords\` (case-insensitive substring) against the active task description \u2014 read its \`file\` (e.g. \`.agentsmesh/lessons/topics/<topic>.md\`).
342
+ 3. Apply the loaded rules to the action.
343
+ 4. Then \u2014 and only then \u2014 perform the edit or run the command.
344
+
345
+ Rejected excuses: *"the edit is small"* \u2192 apply it. *"I read this earlier in the session"* \u2192 context may have compacted; re-read. *"no trigger fires"* \u2192 proceed; you've done your part.
346
+
347
+ **Capture \u2014 IMMEDIATELY after any failure** (test, CI, lint, code review, user correction, regression you spotted yourself, OR any mistake by anyone in the loop):
348
+
349
+ 1. Append one bullet to \`.agentsmesh/lessons/journal.md\` in this exact shape:
350
+ \`- **<short heading>**: <what went wrong>. <root cause>. <imperative rule that prevents recurrence>.\`
351
+ 2. Read \`.agentsmesh/lessons/index.yaml\` and identify which topic the lesson belongs to (use the \`summary:\` fields).
352
+ 3. If the lesson teaches a NEW rule: edit that topic's \`## Rules\` section to add it, citing \`(Evidence: L<journal-line>)\`. If it only reinforces an existing rule, the journal entry alone suffices.
353
+
354
+ Rejected excuses: *"it wasn't really a failure"* \u2192 if you fixed something, it was. *"I'll capture it later"* \u2192 no; do it now while context is fresh. *"no topic fits"* \u2192 still record in journal; an unrouted bullet is recoverable, a forgotten one is not.
355
+
356
+ **These two rituals are load-bearing. Treat them with the same discipline as TDD.**`;function ja(t){let e=Is(t),r=[],n=[];mkdirSync(e.topicsDir,{recursive:true});for(let[i,a]of [[e.journal,zf],[e.index,Vf]])existsSync(i)?n.push(i):(mkdirSync(dirname(i),{recursive:true}),writeFileSync(i,a,"utf8"),r.push(i));let o=nQ(t);return {created:r,skipped:n,rootRuleUpdated:o}}s(ja,"scaffoldLessons");function nQ(t){let e=join(t,".agentsmesh/rules/_root.md");if(!existsSync(e)){mkdirSync(dirname(e),{recursive:true});let o=`---
357
+ root: true
358
+ description: ""
359
+ ---
360
+
361
+ # Operational Guidelines
362
+
363
+ ${Sp}
364
+ `;return writeFileSync(e,o,"utf8"),true}let r=readFileSync(e,"utf8");if(/^## Lessons \(/m.test(r))return false;let n=r.endsWith(`
365
+ `)?r:`${r}
366
+ `;return writeFileSync(e,`${n}
367
+ ${Sp}
368
+ `,"utf8"),true}s(nQ,"appendProceduralRule");var Jf="agentsmesh.yaml",WS="agentsmesh.local.yaml",sQ=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],iQ=Object.fromEntries(Pt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),Q$=Pt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function aQ(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(aQ,"isCoveredByExisting");async function lQ(t){let e=join(t,".gitignore"),r=await _(e)??"",n=new Set(r.split(`
369
+ `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=sQ.filter(a=>!aQ(a,n));if(o.length===0)return false;let i=r.endsWith(`
328
370
  `)||r===""?"":`
329
- `;return await S(e,r+i+o.join(`
371
+ `;return await I(e,r+i+o.join(`
330
372
  `)+`
331
- `),true}s(AZ,"appendToGitignore");async function v$(t,e={}){let r=e.global===true?"global":"project",n=Ai(t,r),o=join(n.configDir,TI);if(await j(o))throw new Error(`Already initialized. ${TI} exists. Remove it first to re-init.`);let i=await T$(n.rootBase,r),a=r==="global"?i.filter(g=>F$.includes(g)):i,l=r==="global"?F$:void 0,c=[],m,p=0;if(a.length>0)if(e.yes){for(let g of a){let h=OZ[g];if(!h)continue;let R=await h(n.rootBase,r);for(let k of R)c.push({from:relative(n.rootBase,k.fromPath).replaceAll("\\","/"),to:k.toPath.replaceAll("\\","/")});}p=a.length,await D$(n.canonicalDir),m="gap-fill",await S(o,Mf(a,l));}else await PI(n.canonicalDir),m="full",await S(o,Mf([],l));else await PI(n.canonicalDir),m="full",await S(o,Mf([],l));let u=join(n.configDir,N$);await S(u,A$);let f=false;return r==="project"&&(f=await AZ(t)),{exitCode:0,data:{scope:r,configFile:TI,localConfigFile:N$,detectedConfigs:a,imported:c,importedToolCount:p,scaffoldType:m,gitignoreUpdated:f}}}s(v$,"runInit");ot();function M$(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(M$,"renderInit");Zt();Tt();var bZ=Object.fromEntries(Pt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Gf(t){return bZ[t]}s(Gf,"getTargetCatalogEntry");ce();Mr();Qc();var FZ={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function vZ(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=FZ,true)}s(vZ,"injectAgentsmeshEntry");async function DI(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await jr(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!vZ(r))return !1;let n=JSON.stringify(r,null,2)+`
373
+ `),true}s(lQ,"appendToGitignore");async function q$(t,e={}){let r=e.global===true?"global":"project",n=e.lessons===true;if(n&&r==="global")throw new Error("--lessons is project-mode only. Lessons live in the project tree.");let o=Pi(t,r),i=join(o.configDir,Jf),a=await j(i);if(a&&n){let C=ja(t);return {exitCode:0,data:{scope:r,configFile:Jf,localConfigFile:WS,detectedConfigs:[],imported:[],importedToolCount:0,scaffoldType:"none",gitignoreUpdated:false,lessons:C,lessonsOnly:true}}}if(a)throw new Error(`Already initialized. ${Jf} exists. Remove it first to re-init.`);let l=await V$(o.rootBase,r),c=r==="global"?l.filter(C=>Q$.includes(C)):l,m=r==="global"?Q$:void 0,p=[],u,f=0;if(c.length>0)if(e.yes){for(let C of c){let R=iQ[C];if(!R)continue;let k=await R(o.rootBase,r);for(let b of k)p.push({from:relative(o.rootBase,b.fromPath).replaceAll("\\","/"),to:b.toPath.replaceAll("\\","/")});}f=c.length,await Y$(o.canonicalDir),u="gap-fill",await I(i,Wf(c,m));}else await US(o.canonicalDir),u="full",await I(i,Wf([],m));else await US(o.canonicalDir),u="full",await I(i,Wf([],m));let g=join(o.configDir,WS);await I(g,W$);let h=false;r==="project"&&(h=await lQ(t));let S=n?ja(t):void 0;return {exitCode:0,data:{scope:r,configFile:Jf,localConfigFile:WS,detectedConfigs:c,imported:p,importedToolCount:f,scaffoldType:u,gitignoreUpdated:h,lessons:S}}}s(q$,"runInit");ot();function eG(t){let{data:e}=t;if(e.lessonsOnly===true&&e.lessons!==void 0){tG(e.lessons),y.info("Run 'agentsmesh generate' to project the new lessons rule to every target.");return}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"),e.lessons!==void 0&&tG(e.lessons);}s(eG,"renderInit");function tG(t){let e=process.cwd(),r=s(n=>relative(e,n).replaceAll("\\","/"),"rel");for(let n of t.created)y.success(` Created ${r(n)}`);for(let n of t.skipped)y.info(` Kept ${r(n)} (already exists)`);t.rootRuleUpdated?y.success(" Appended Lessons recall paragraph to .agentsmesh/rules/_root.md"):y.info(" .agentsmesh/rules/_root.md already contains the Lessons paragraph"),y.success("Lessons subsystem ready (.agentsmesh/lessons/).");}s(tG,"renderLessons");Zt();xt();var mQ=Object.fromEntries(Pt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Yf(t){return mQ[t]}s(Yf,"getTargetCatalogEntry");ce();$r();rm();var hQ={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function yQ(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=hQ,true)}s(yQ,"injectAgentsmeshEntry");async function zS(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await Ur(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!yQ(r))return !1;let n=JSON.stringify(r,null,2)+`
332
374
  `;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)}
333
- `),false}}s(DI,"seedAgentsmeshMcpEntry");function $$(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s($$,"mapResults");async function G$(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=Ai(r,i),f=await Gf(o).importFrom(p.rootBase,{scope:i});return f.length>0&&await DI(p.rootBase),{exitCode:0,data:{scope:i,target:o,files:$$(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: ${$t.join(", ")}.`)}await Ut(a,r);let c=nt(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...$t,...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:$$(m,l.rootBase)}}}s(G$,"runImport");Zt();ho();function jf(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(jf,"computeDiff");function Uf(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(Uf,"formatDiffSummary");Mr();async function U$(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 Ut(a,r);let{canonical:c}=await Oe(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}=jf(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(U$,"runDiff");Zt();ho();A();ce();xi();wt();var $Z=[{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 $Z)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Br(t.capabilities[n.capabilityKey]).level!=="none"||r.push(D(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");wt();var GZ=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function jZ(t){let r=t.match(GZ)?.groups?.path;return typeof r=="string"?r:null}s(jZ,"extractScriptToken");function K$(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=jZ(o.command);i&&r.push(D(".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(K$,"lintHookScriptReferences");wt();function W$(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(D(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(W$,"lintRuleScopeInversion");var UZ=["node_modules",".git","dist","coverage",".agentsmesh"];async function BZ(t){return (await G(t)).filter(n=>{let o=relative(t,n);return !UZ.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(BZ,"getProjectFiles");async function Bf(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 BZ(r);for(let k of l){let I=nt(k),C=Fe(k)?Gf(k):I;C?.capabilities&&g.push(...B$({target:k,capabilities:C.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...K$({target:k,canonical:e,hasScriptProjection:I?.postProcessHookOutputs!==void 0})),c&&g.push(...W$({target:k,canonical:e,preservesManualActivation:I?.preservesManualActivation===true})),c&&C?.lintRules&&g.push(...C.lintRules(e,r,h,{scope:i})),I?.generators.lint&&g.push(...I.generators.lint(e));let b={scope:i};m&&C?.lint?.commands&&g.push(...C.lint.commands(e,b)),p&&C?.lint?.mcp&&g.push(...C.lint.mcp(e,b)),u&&C?.lint?.permissions&&g.push(...C.lint.permissions(e,b)),f&&C?.lint?.hooks&&g.push(...C.lint.hooks(e,b));}let R=g.some(k=>k.level==="error");return {diagnostics:g,hasErrors:R}}s(Bf,"runLint");Mr();async function z$(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 Ut(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await Bf(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(z$,"runLintCmd");ot();function V$(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(V$,"renderLint");ot();function J$(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(J$,"renderCheck");ot();function Y$(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(Y$,"renderImport");ot();function X$(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(Uf({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(X$,"renderDiff");ot();function Z$(t){if(!t.data.hadConflict){y.info("No conflicts to resolve.");return}y.success("Lock file conflict resolved.");}s(Z$,"renderMerge");dp();gp();Zt();ho();dp();gp();ot();var HZ=300;function zZ(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(zZ,"normalizeWatchPath");function VZ(t,e){let r=zZ(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(VZ,"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 q$(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:I}=await yt(n,o),{canonical:C}=await Oe(k,I.configDir,{},I.canonicalDir),b=C.mcp?Object.keys(C.mcp.mcpServers).length:0,N=C.permissions?C.permissions.allow.length+C.permissions.deny.length:0,T=C.hooks?Object.values(C.hooks).reduce((v,q)=>v+(Array.isArray(q)?q.length:0),0):0,B=C.ignore.length,H=JZ(k.features,C.rules.length,C.commands.length,C.agents.length,C.skills.length,b,N,T,B),tt=c!==null&&c!==H;if(c=H,m)return;let it=await Sc(t,n,{printMatrix:false});if(Cc(it),!m){if(tt){let v=await up(t,n);fp(v,{verbose:t.verbose===true});}else y.info("Regenerated.");r.onCycle?.({featuresChanged:tt});}},"run"),f=s(()=>{let k=u().catch(I=>{if(!m){let C=I instanceof Error?I.message:String(I);y.error(C);}}).finally(()=>{p===k&&(p=null);});p=k;},"scheduleRun"),g=s(()=>{m||(l&&clearTimeout(l),l=setTimeout(f,HZ));},"schedule"),h=r.usePolling??process.platform==="win32",R=WZ.watch(a,{ignoreInitial:true,usePolling:h,...h&&r.pollIntervalMs!==void 0?{interval:r.pollIntervalMs}:{}});return R.on("all",(k,I)=>{VZ(i.canonicalDir,I)||g();}),await new Promise((k,I)=>{R.once("ready",k),R.once("error",I);}),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(q$,"runWatch");Zt();Zp();async function Kf(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await Of(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await Rs(n),a=await rl(e,r),l=a.length>0?await _c(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let I of c){let C=i[I];C===void 0?f.push(I):C!==o.checksums[I]&&p.push(I);}for(let I of m)c.has(I)||u.push(I);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let I of g)l[I]!==o.extends[I]&&h.push(I);let R=Af(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(Kf,"checkLockSync");Mr();async function tG(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n);await Ut(o,r);let a=await Kf({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(tG,"runCheck");Zt();A();Zp();var XZ=".lock",ZZ="<<<<<<<";async function NI(t){let e=join(t,XZ),r=await _(e);return r===null?false:r.includes(ZZ)}s(NI,"hasLockConflict");async function rG(t,e,r){if(!await NI(t))throw new Error("No conflict to resolve.");let o=await Rs(t),i=dirname(t),a=r?await rl(r,i):[],l=a.length>0?await _c(a):{},c=await bf(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await wf(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}s(rG,"resolveLockConflict");async function nG(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 NI(a)?(await rG(a,Oi(),o),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(nG,"runMerge");Zt();If();function oG(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,o=t["accept-elevated"]===true;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?hc.parse(n):void 0,nameOverride:typeof t.name=="string"?t.name.trim():"",acceptHooks:o||t["accept-hooks"]===true,acceptPermissions:o||t["accept-permissions"]===true,acceptMcp:o||t["accept-mcp"]===true}}s(oG,"readInstallFlags");var tQ=".install.lock";async function Ec(t,e={}){return await mkdir(t,{recursive:true}),Ff(join(t,tQ),e)}s(Ec,"acquireInstallLock");Zt();A();Vc();var nQ=promisify(execFile);function Wf(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(Wf,"ensureNotFlag");async function FI(t){let{stdout:e}=await nQ("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(FI,"runGit");async function sG(){try{return await FI(["--version"]),!0}catch{return false}}s(sG,"isGitAvailable");async function oQ(t,e){Wf(t,"remote-url"),Wf(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await FI(["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(oQ,"gitLsRemoteResolve");async function Hf(t,e){Wf(e,"remote-url");let r=t===""?"HEAD":t;if(Wf(r,"ref"),/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await FI(["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 oQ(e,r)}s(Hf,"resolveRemoteRefForInstall");async function iG(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 Hf(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await el(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 el(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 el(i,"install",{cacheDir:ve(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(iG,"fetchInstallSource");async function aG(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await iG(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(aG,"resolveInstallResolvedPath");function hp(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(hp,"parseGithubTreeUrl");function yp(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(yp,"parseGithubBlobUrl");function _p(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(_p,"parseGitlabTreeUrl");function Rp(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(Rp,"parseGitlabBlobUrl");var sQ=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function Ip(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||sQ.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(Ip,"parseGithubRepoUrl");function Sp(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(Sp,"parseGitlabRepoUrl");function Cp(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(Cp,"parseGitSshGithub");function kp(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(kp,"parseGitSshGitlab");A();var lQ=/^[A-Za-z]:[\\/]/,cQ=/^[A-Za-z]:\//;function lG(...t){return t.some(e=>e.includes("\\")||lQ.test(e))?win32:posix}s(lG,"pathApiFor");function Lp(t){return t.replace(/\\/g,"/")}s(Lp,"toPosixPath");function Ep(t){return Lp(t).replace(/^\/+|\/+$/g,"")}s(Ep,"normalizeInstallPathField");function zf(t){let e=Lp(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||cQ.test(e)?e:`./${e}`}s(zf,"normalizeLocalSourceForYaml");function _i(t){return {...t,source:t.source_kind==="local"?zf(t.source):t.source,...t.path!==void 0?{path:Ep(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>Ep(e))}:{}}}s(_i,"normalizePersistedInstallPaths");function cG(t,e,r){let n=lG(t,e),o=n.normalize(t),i=n.normalize(e),a=Ep(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=Ep(u),g=Lp(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:zf(g)}}let m=Lp(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:zf(m)}}s(cG,"localParsedFromAbsPath");async function vI(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=hp(n)??yp(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=Ip(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=_p(n)??Rp(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=Sp(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=Cp(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=kp(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 cG(m,e,o)}s(vI,"parseInstallSource");function Op(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=hp(e)??yp(e);if(a!==null)return {kind:"github",remoteUrl:`https://github.com/${a.org}/${a.repo}.git`,ref:a.ref};let l=Ip(e);if(l!==null)return {kind:"github",remoteUrl:`https://github.com/${l.org}/${l.repo}.git`,ref:"HEAD"};let c=_p(e)??Rp(e);if(c!==null)return {kind:"gitlab",remoteUrl:`https://gitlab.com/${c.namespace}/${c.project}.git`,ref:c.ref};let m=Sp(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=Cp(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=kp(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(Op,"parseSourceUrl");jR();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 Vf(t,e={}){let{sliceRoot:r,implicitPick:n}=await ff(t),{canonical:o,cleanup:i}=await gf(r,{...e,enableTargetEntityMappers:true});return {canonical:o,features:_n(o),implicitPick:n,cleanup:i}}s(Vf,"discoverFromContentRoot");function mG(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(mG,"validateSkill");function pG(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(pG,"validateRule");function uG(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(uG,"validateCommand");function dG(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(dG,"validateAgent");function ie(t){return basename(t.source).replace(/\.md$/i,"")}s(ie,"ruleSlug");function uQ(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(uQ,"featuresFromImplicitPick");function Oc(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??uQ(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(ie(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(Oc,"narrowDiscoveredForInstallScope");VR();async function fG(t,e,r,n,o={}){let i=await _f(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:a,cleanup:l}=await Vf(i.discoveryRoot,o),c=Oc(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(fG,"resolveManualDiscoveredForInstall");So();bR();A();Tt();var dQ=(()=>{let t=new Map;for(let r of Pt){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 fQ(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(fQ,"norm");function Jf(t){let e=fQ(t);if(e){for(let{prefix:r,target:n}of dQ)if(e===r||e.startsWith(`${r}/`))return n}}s(Jf,"targetHintFromNativePath");function MI(t,e){return Jf(t)===e}s(MI,"pathSupportsNativePick");function gG(t,e){if(!t||!e)return;let r=Jf(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(gG,"validateTargetMatchesPath");function hG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(hG,"extendPickHasArrays");A();A();Xt();async function _G(t,e){let r=join(t,...Xe.split("/")),n=join(t,...e.split("/")),o=await G(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(_G,"inferGeminiCommandNamesFromFiles");Xt();fr();A();async function $a(t){let e=await G(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($a,"skillNamesFromNativeSkillDir");A();Dr();async function RG(t,e){let r=join(t,...e.split("/"));if(e.startsWith(li)){let n=await G(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 G(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 G(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 $a(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await G(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(RG,"inferCopilotPickFromPath");async function qe(t,e){let r=await G(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 SG(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 _G(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 $a(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return RG(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(te)){let i=await $a(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 $a(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 $a(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await G(o),a=[...new Set(i.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(SG,"inferImplicitPickFromNativePath");function CG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(CG,"isImplicitPickEmpty");PR();function Ap(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(Ap,"normalizePath");function EQ(t,e){let r=Ap(t),n=Ap(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(EQ,"overlapsPath");function Yf(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(Yf,"addUnique");async function LQ(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(t,r,{recursive:!0}),{stageRoot:r,cleanup:n}}catch(o){throw await n(),o}}s(LQ,"makeStageRoot");function OQ(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:Yf(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=Ap(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:Yf(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:Yf(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=Ap(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:Yf(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(OQ,"buildPickFromResults");function wQ(t,e,r,n){let o=join(e,...Ap(t).split("/")),i=r.filter(a=>EQ(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:OQ(i,e)}}s(wQ,"scopeImportedResults");async function GI(t,e){let{stageRoot:r,cleanup:n}=await LQ(t);try{let o=await ip(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s(GI,"stageImportedNativeRepo");async function jI(t,e,r){let n=await GI(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...wQ(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(jI,"stageNativeInstallScope");async function OG(t,e,r,n){let o=n.explicitTarget?.trim();o&&nr.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");gG(o,i);let a=join(t,".agentsmesh"),l=await j(a),c=i?Jf(i):void 0,p=!l&&!o&&(!i||c!==void 0)?await nf(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 b=await jI(t,i,u);return {discoveryRoot:b.stageRoot,implicitPick:b.pick,scopedFeatures:b.features,yamlTarget:u,importHappened:true,cleanup:b.cleanup}}let C=await GI(t,u);return {discoveryRoot:i?join(C.stageRoot,i):C.stageRoot,yamlTarget:u,importHappened:true,cleanup:C.cleanup}}let g;l?i?u&&MI(i,u)?g=t:g=e:g=t:g=e;let h,R,k;if(f&&u){let C=await jI(t,i,u);g=C.stageRoot,h=C.pick,R=C.features,k=C.cleanup;}else if(g===t&&i&&u&&MI(i,u)&&(h=await SG(t,i,u),CG(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 I;return o?I=o:u&&(h&&hG(h)||(R?.length??0)>0)&&(I=u),{discoveryRoot:g,implicitPick:h,scopedFeatures:R,yamlTarget:I,importHappened:k!==void 0,cleanup:k}}s(OG,"prepareInstallDiscovery");async function UI(t,e,r,n,o={}){let i=await OG(t,e,r,{explicitTarget:n}),{canonical:a,implicitPick:l,cleanup:c}=await Vf(i.discoveryRoot,o),m=i.cleanup,u={...i,cleanup:s(async()=>{await Promise.allSettled([c(),...m?[m()]:[]]);},"mergedCleanup")},f=l??i.implicitPick,g=Oc(a,{implicitPick:f,scopedFeatures:i.scopedFeatures}),h=_n(g);return {prep:u,discovered:a,implicitPick:f,narrowed:g,discoveredFeatures:h}}s(UI,"resolveDiscoveredForInstall");var PQ=[".claude-plugin","marketplace.json"];async function TQ(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(TQ,"dirExists");function xQ(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(xQ,"normalizeSource");async function AG(t,e,r){let n=join(t,...PQ),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=xQ(c.source);if(!m)continue;let p=join(t,m);if(!await TQ(p))continue;let u=await e(p,m);r(u)&&l.push({path:m,layout:u});}return l}s(AG,"detectMarketplaceSubPacks");async function bp(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(bp,"dirExists");async function Ri(t){try{return (await readdir(t,{withFileTypes:!0})).map(r=>({name:r.name,isDir:r.isDirectory(),isFile:r.isFile()}))}catch{return []}}s(Ri,"listDirEntries");function bG(t){return t.endsWith(".instructions.md")?"copilot-instructions":t.endsWith(".md")?"md":t.endsWith(".mdc")?"mdc":t.endsWith(".toml")?"toml":null}s(bG,"classifyFileShape");var FQ=["rules","commands","agents","skills","mcp.json","hooks.yaml","permissions.yaml","ignore"],vQ=[".cursorrules",".windsurfrules"];async function TG(t){let e=join(t,".agentsmesh");if(!await bp(e))return null;let r=await Ri(e),n=new Set(r.map(o=>o.name));for(let o of FQ)if(n.has(o))return {path:".agentsmesh"};return null}s(TG,"detectCanonical");async function xG(t){for(let e of vQ)try{if((await stat(join(t,e))).isFile())return {path:e}}catch{}return null}s(xG,"detectRootRule");async function DG(t){try{if((await stat(join(t,"SKILL.md"))).isFile())return {path:"SKILL.md"}}catch{}return null}s(DG,"detectRootSkill");Eo();var $Q={rules:"rules",commands:"commands",agents:"agents",skills:"skills"},GQ=[".claude-plugin",".codex-plugin",".cursor-plugin"],jQ=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;async function NG(t){let e=join(t,"skills"),r=await Ri(e);for(let n of r)if(!(!n.isDir||n.name.startsWith("_")||!jQ.test(n.name))&&await bp(join(e,n.name)))try{if((await stat(join(e,n.name,"SKILL.md"))).isFile())return {path:"skills"}}catch{continue}return null}s(NG,"detectSkillPack");async function FG(t){let e=[];for(let[r,n]of Object.entries($Q)){let o=join(t,r),i=await Ri(o),a=new Set;for(let l of i){if(!l.isFile||Cn(l.name))continue;let c=bG(l.name);c&&a.add(c);}for(let l of a)e.push({path:r,suggestedAs:n,fileShape:l});}return e}s(FG,"detectFlatCollections");async function vG(t){let e=[];for(let r of GQ)await bp(join(t,r))&&e.push({path:r});return e}s(vG,"detectToolNativeManifests");async function WI(t,e){let r=await TG(t);if(r)return {canonical:r,skillPack:null,rootSkill:null,rootRule:null,flatCollections:[],toolNativeManifests:[]};let n=await NG(t),o=n?null:await DG(t),i=await FG(t),a=n||o||i.length>0?null:await xG(t),l=await vG(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(WI,"detectFlatLayout");function KI(t){return t.canonical!==null||t.skillPack!==null||t.rootSkill!==null||t.rootRule!==null||t.flatCollections.length>0}s(KI,"hasContent");async function MG(t,e){let r=await Ri(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 WI(i,a);KI(l)&&n.push({path:a,layout:l});}return n}s(MG,"collectSubPackCandidates");async function UQ(t,e){if(KI(e))return [];let r=await AG(t,WI,KI);if(r&&r.length>0)return r;let n=await MG(t,"");if(n.length>=2)return n;let o=await Ri(t);for(let i of o){if(!i.isDir||i.name.startsWith("."))continue;let a=await MG(join(t,i.name),i.name);if(a.length>=2)return a}return []}s(UQ,"detectSubPacks");async function GG(t){let e=await WI(t,"");if(e.canonical)return {...e,subPacks:[]};let r=await UQ(t,e);return {...e,subPacks:r}}s(GG,"detectLayout");A();U();async function UG(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(UG,"inferMdcTarget");cf();df();function VQ(t){let e=t.indexOf("#");return e<0?{path:t,anchor:""}:{path:t.slice(0,e),anchor:t.slice(e)}}s(VQ,"splitAnchor");function JQ(t){return t.split(sep).join("/")}s(JQ,"toForwardSlash");async function YQ(t){try{return await stat(t),!0}catch{return false}}s(YQ,"pathExists");async function HG(t){let{link:e,fromFile:r,contentRoot:n,includedPaths:o}=t,{path:i,anchor:a}=VQ(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 YQ(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(HG,"resolveLink");var XQ=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,ZQ=/(!?)\[[^\]\n]*\]\(([^)\n]+)\)/g,QQ=/^\s*\[([^\]\n]+)\]:\s*(.+?)\s*$/gm;function qQ(t){let e=[];for(let r of t.matchAll(XQ)){let n=r.index??0;e.push([n,n+r[0].length]);}return e}s(qQ,"getFencedCodeRanges");function zG(t,e){for(let[r,n]of e)if(t>=r&&t<n)return true;return false}s(zG,"isInRanges");function VG(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(VG,"normalizeDestination");function Xf(t){let e=qQ(t),r=[];for(let n of t.matchAll(ZQ)){let o=n.index??0;if(zG(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:VG(a),destinationOffset:c,destinationLength:a.length});}for(let n of t.matchAll(QQ)){let o=n.index??0;if(zG(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:VG(a),label:i,destinationOffset:m,destinationLength:a.trimEnd().length});}return r}s(Xf,"scanMarkdownLinks");function JG(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(JG,"applyRangeRewrites");function tq(t){return !(t.length===0||t.startsWith("#")||t.startsWith("/")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))}s(tq,"isCandidateRelativePath");function eq(t){let e=t.replaceAll("\\","/");return e==="{baseDir}"?".":e.startsWith("{baseDir}/")?e.slice(10):e}s(eq,"stripPath");function rq(t){let e=t.destination;return tq(e)?{raw:e,path:eq(e),kind:t.kind,...t.label!==void 0?{label:t.label}:{}}:null}s(rq,"toScannedLink");function YG(t){let e=[];for(let r of Xf(t)){let n=rq(r);n!==null&&e.push(n);}return e}s(YG,"scanRelativeLinks");function wc(t,e){let r=t.replaceAll("\\","/"),n=e.replaceAll("\\","/"),o=r.endsWith("/")?r:`${r}/`;return n.startsWith(o)?n.slice(o.length):n}s(wc,"toForwardSlashRelative");function XG(t,e,r,n,o){let i=new Set;for(let a of e){i.add(wc(t,a.source));for(let l of a.supportingFiles)i.add(wc(t,l.absolutePath));}for(let a of r)i.add(wc(t,a.source));for(let a of n)i.add(wc(t,a.source));for(let a of o)i.add(wc(t,a.source));return i}s(XG,"buildIncludedPaths");function oq(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(oq,"listScannables");async function ZG(t,e,r,n,o,i){let a=oq(e,r,n,o),l=[];for(let c of a){let m=YG(c.body);if(m.length===0)continue;let p=wc(t,c.sourcePath),u=[];for(let f of m){let g=await HG({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(ZG,"detectBrokenLinks");df();async function QG(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 mf(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(QG,"mergeCommands");async function qG(t,e,r={}){let[n,o,i,a]=await Promise.all([eM(`${t}/skills`,r),uf(`${t}/agents`,{parseOpts:r}),pf(`${t}/rules`,{parseOpts:r}),QG(t,e.mergeFromToolDirs,r)]),l=[...o.agents],c=[...i.rules],m=XG(t,n,l,a.commands,c),p=await ZG(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(qG,"aggregateAnthropicSkillPack");var tj={mergeFromToolDirs:[{dir:"commands",precedence:0},{dir:".claude/commands",target:"claude-code",precedence:1},{dir:".gemini/commands",target:"gemini-cli",precedence:2}]};ol();function aq(t){return {rules:[...t.rules],commands:[...t.commands],agents:[...t.agents],skills:[...t.skills],mcp:null,permissions:null,hooks:null,ignore:[]}}s(aq,"aggregateToCanonical");function Zf(){return {}}s(Zf,"emptyPrep");async function lq(t,e){let r=[];for(let n of e)if(n.fileShape==="mdc"&&!n.inferredTarget){let o=await UG(join(t,n.path));r.push(o?{...n,inferredTarget:o}:n);}else r.push(n);return r}s(lq,"enrichMdcTargets");function rj(t){return t.canonical?"canonical-agentsmesh":t.skillPack||t.rootSkill?"anthropic-skill-pack":t.rootRule||t.toolNativeManifests.length>0?"tool-native":"unknown"}s(rj,"deriveSourceType");async function cq(t,e){let r=await ou(t,e);return {rules:[],commands:[],agents:[],skills:r?[r]:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(cq,"rootSkillToCanonical");async function mq(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(mq,"rootRuleToCanonical");async function nj(t){let e=t.parseOpts??{};if(t.explicitAs)return {implicitPick:void 0,...await fG(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick,e)};if(t.explicitTarget)return UI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e);let r=await GG(t.contentRoot),n=await lq(t.contentRoot,r.flatCollections),o={...r,flatCollections:n};if(o.skillPack&&!o.canonical){let a=await qG(t.contentRoot,tj,e),l=aq(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 cq(t.contentRoot,e);return {prep:Zf(),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 mq(t.contentRoot,o.rootRule.path);return {prep:Zf(),implicitPick:void 0,narrowed:a,discoveredFeatures:_n(a),layout:o}}return o.subPacks.length>0?{prep:Zf(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:o.flatCollections.length>0?{prep:Zf(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:{...await UI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e),layout:o}}s(nj,"resolveInstallDiscovery");function sj(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(sj,"featuresFromLayout");function pq(t){return t.replace(/[/\\]+/g,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}s(pq,"subPackSlug");function oj(t,e,r){let n=sj(t.layout),o=n[0];return {name:`${e}-${pq(t.path)}`,source:r,path:t.path,as:o,features:n}}s(oj,"targetFromSubPack");function ij(t,e,r){return {name:e,source:r,path:t.path,as:t.suggestedAs,target:t.inferredTarget,features:[t.suggestedAs]}}s(ij,"targetFromCollection");function aj(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 uq(t);if(e.flatCollections.length===1){let l=e.flatCollections[0];return {targets:[ij(l,r,n)],isMarketplace:false}}return e.flatCollections.length>1?dq(t):{targets:[],isMarketplace:false}}s(aj,"selectInstallCandidates");function uq(t){let{layout:e,sourceName:r,sourceForYaml:n}=t;if(t.all)return {targets:e.subPacks.map(a=>oj(a,r,n)),isMarketplace:true};if(t.force||!t.tty){let a=e.subPacks.map(l=>({path:l.path,features:sj(l.layout)})).map(l=>` - ${l.path} (${l.features.join(", ")})`).join(`
375
+ `),false}}s(zS,"seedAgentsmeshMcpEntry");function nG(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(nG,"mapResults");function oG(t,e){if(e!=="project"||existsSync(Is(t).index))return;let r=join(t,".agentsmesh/rules/_root.md");existsSync(r)&&/^## Lessons \(/m.test(readFileSync(r,"utf8"))&&ja(t);}s(oG,"ensureImportedLessonsSubsystem");async function sG(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(ve(o)){let p=Pi(r,i),f=await Yf(o).importFrom(p.rootBase,{scope:i});return f.length>0&&(await zS(p.rootBase),oG(p.rootBase,i)),{exitCode:0,data:{scope:i,target:o,files:nG(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: ${$t.join(", ")}.`)}await Ut(a,r);let c=nt(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...$t,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:i});return m.length>0&&(await zS(l.rootBase),oG(l.rootBase,i)),{exitCode:0,data:{scope:i,target:o,files:nG(m,l.rootBase)}}}s(sG,"runImport");Zt();yo();function Xf(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(Xf,"computeDiff");function Zf(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(Zf,"formatDiffSummary");$r();async function aG(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 Ut(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),m=await Mr({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}=Xf(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(aG,"runDiff");Zt();yo();A();ce();Ni();wt();var IQ=[{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 lG(t){let e=new Set(t.enabledFeatures),r=[];for(let n of IQ)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Kr(t.capabilities[n.capabilityKey]).level!=="none"||r.push(D(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(lG,"lintSilentFeatureDrops");wt();var CQ=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function kQ(t){let r=t.match(CQ)?.groups?.path;return typeof r=="string"?r:null}s(kQ,"extractScriptToken");function cG(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=kQ(o.command);i&&r.push(D(".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(cG,"lintHookScriptReferences");wt();function mG(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(D(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(mG,"lintRuleScopeInversion");var EQ=z$1.object({file_globs:z$1.array(z$1.string()),command_patterns:z$1.array(z$1.string()),keywords:z$1.array(z$1.string())}).refine(t=>t.file_globs.length+t.command_patterns.length+t.keywords.length>0,{message:"cluster must declare at least one trigger of any type"}),LQ=z$1.object({topic:z$1.string().regex(/^[a-z0-9-]+$/,"topic must be kebab-case"),file:z$1.string().regex(/\.md$/,"file must be a .md path"),summary:z$1.string().min(1),triggers:EQ}),Qf=z$1.object({version:z$1.literal(1),clusters:z$1.array(LQ)});var wQ="lessons",uG=".agentsmesh/lessons/index.yaml",dG=".agentsmesh/rules/_root.md",AQ=/^## Lessons \(/m,bQ=/^## Rules\b/m;function fG(t,e){if(e==="global")return [];let r=Is(t);if(!existsSync(r.index))return [];let n=[],o=Qf.safeParse(parse(readFileSync(r.index,"utf8")));if(!o.success)return [Ip("error",uG,`index.yaml is invalid: ${o.error.issues[0].message}`)];for(let l of o.data.clusters){let c=join(t,l.file);if(!existsSync(c)){n.push(Ip("error",l.file,`topic file for cluster "${l.topic}" does not exist.`));continue}bQ.test(readFileSync(c,"utf8"))||n.push(Ip("warning",l.file,`topic "${l.topic}" is missing a "## Rules" section.`));for(let m of l.triggers.command_patterns)try{new RegExp(m);}catch{n.push(Ip("warning",uG,`cluster "${l.topic}" command_patterns entry is not a valid regex: ${m}`));}}let i=join(t,dG),a=existsSync(i)?readFileSync(i,"utf8"):"";return AQ.test(a)||n.push(Ip("warning",dG,'lessons procedural rule ("## Lessons (...)") is missing from _root.md \u2014 recall/capture enforcement will not fire.')),n}s(fG,"lintLessonsSubsystem");function Ip(t,e,r){return {level:t,file:e,target:wQ,message:r}}s(Ip,"diag");var PQ=["node_modules",".git","dist","coverage",".agentsmesh"];async function xQ(t){return (await G(t)).filter(n=>{let o=relative(t,n);return !PQ.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(xQ,"getProjectFiles");async function qf(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=[...fG(r,i)],h=i==="global"?[]:await xQ(r);for(let C of l){let R=nt(C),k=ve(C)?Yf(C):R;k?.capabilities&&g.push(...lG({target:C,capabilities:k.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...cG({target:C,canonical:e,hasScriptProjection:R?.postProcessHookOutputs!==void 0})),c&&g.push(...mG({target:C,canonical:e,preservesManualActivation:R?.preservesManualActivation===true})),c&&k?.lintRules&&g.push(...k.lintRules(e,r,h,{scope:i})),R?.generators.lint&&g.push(...R.generators.lint(e));let b={scope:i};m&&k?.lint?.commands&&g.push(...k.lint.commands(e,b)),p&&k?.lint?.mcp&&g.push(...k.lint.mcp(e,b)),u&&k?.lint?.permissions&&g.push(...k.lint.permissions(e,b)),f&&k?.lint?.hooks&&g.push(...k.lint.hooks(e,b));}let S=g.some(C=>C.level==="error");return {diagnostics:g,hasErrors:S}}s(qf,"runLint");$r();async function hG(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 Ut(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await qf(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(hG,"runLintCmd");ot();function yG(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(yG,"renderLint");ot();function _G(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(_G,"renderCheck");ot();function RG(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(RG,"renderImport");ot();function SG(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(Zf({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(SG,"renderDiff");ot();function IG(t){if(!t.data.hadConflict){y.info("No conflicts to resolve.");return}y.success("Lock file conflict resolved.");}s(IG,"renderMerge");yp();Rp();Zt();yo();yp();Rp();ot();var NQ=300;function FQ(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(FQ,"normalizeWatchPath");function vQ(t,e){let r=FQ(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(vQ,"shouldIgnoreWatchPath");function MQ(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(MQ,"featureFingerprint");async function kG(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:R}=await yt(n,o),{canonical:k}=await Oe(C,R.configDir,{},R.canonicalDir),b=k.mcp?Object.keys(k.mcp.mcpServers).length:0,N=k.permissions?k.permissions.allow.length+k.permissions.deny.length:0,x=k.hooks?Object.values(k.hooks).reduce((v,q)=>v+(Array.isArray(q)?q.length:0),0):0,B=k.ignore.length,H=MQ(C.features,k.rules.length,k.commands.length,k.agents.length,k.skills.length,b,N,x,B),tt=c!==null&&c!==H;if(c=H,m)return;let it=await Ec(t,n,{printMatrix:false});if(Lc(it),!m){if(tt){let v=await hp(t,n);_p(v,{verbose:t.verbose===true});}else y.info("Regenerated.");r.onCycle?.({featuresChanged:tt});}},"run"),f=s(()=>{let C=u().catch(R=>{if(!m){let k=R instanceof Error?R.message:String(R);y.error(k);}}).finally(()=>{p===C&&(p=null);});p=C;},"scheduleRun"),g=s(()=>{m||(l&&clearTimeout(l),l=setTimeout(f,NQ));},"schedule"),h=r.usePolling??process.platform==="win32",S=DQ.watch(a,{ignoreInitial:true,usePolling:h,...h&&r.pollIntervalMs!==void 0?{interval:r.pollIntervalMs}:{}});return S.on("all",(C,R)=>{vQ(i.canonicalDir,R)||g();}),await new Promise((C,R)=>{S.once("ready",C),S.once("error",R);}),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 S.close(),p&&await p;},"stop")}}s(kG,"runWatch");Zt();ou();async function tg(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await Df(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await Ss(n),a=await sl(e,r),l=a.length>0?await Ic(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let R of c){let k=i[R];k===void 0?f.push(R):k!==o.checksums[R]&&p.push(R);}for(let R of m)c.has(R)||u.push(R);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let R of g)l[R]!==o.extends[R]&&h.push(R);let S=Ff(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:S}}s(tg,"checkLockSync");$r();async function EG(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n);await Ut(o,r);let a=await tg({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(EG,"runCheck");Zt();A();ou();var GQ=".lock",jQ="<<<<<<<";async function YS(t){let e=join(t,GQ),r=await _(e);return r===null?false:r.includes(jQ)}s(YS,"hasLockConflict");async function OG(t,e,r){if(!await YS(t))throw new Error("No conflict to resolve.");let o=await Ss(t),i=dirname(t),a=r?await sl(r,i):[],l=a.length>0?await Ic(a):{},c=await vf(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await Nf(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}s(OG,"resolveLockConflict");async function wG(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 YS(a)?(await OG(a,Ai(),o),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(wG,"runMerge");Zt();wf();function AG(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,o=t["accept-elevated"]===true;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?Rc.parse(n):void 0,nameOverride:typeof t.name=="string"?t.name.trim():"",acceptHooks:o||t["accept-hooks"]===true,acceptPermissions:o||t["accept-permissions"]===true,acceptMcp:o||t["accept-mcp"]===true}}s(AG,"readInstallFlags");var KQ=".install.lock";async function Ac(t,e={}){return await mkdir(t,{recursive:true}),Bf(join(t,KQ),e)}s(Ac,"acquireInstallLock");Zt();A();Zc();var zQ=promisify(execFile);function eg(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(eg,"ensureNotFlag");async function XS(t){let{stdout:e}=await zQ("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(XS,"runGit");async function bG(){try{return await XS(["--version"]),!0}catch{return false}}s(bG,"isGitAvailable");async function VQ(t,e){eg(t,"remote-url"),eg(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await XS(["ls-remote",t,o])).split(`
376
+ `).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(VQ,"gitLsRemoteResolve");async function rg(t,e){eg(e,"remote-url");let r=t===""?"HEAD":t;if(eg(r,"ref"),/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await XS(["ls-remote",e,"HEAD"])).split(`
377
+ `).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 VQ(e,r)}s(rg,"resolveRemoteRefForInstall");async function PG(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 rg(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await ol(l,"install",{cacheDir:Me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}if(t.kind==="gitlab"){let l=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await ol(l,"install",{cacheDir:Me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await ol(i,"install",{cacheDir:Me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(PG,"fetchInstallSource");async function xG(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await PG(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(xG,"resolveInstallResolvedPath");function Cp(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(Cp,"parseGithubTreeUrl");function kp(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(kp,"parseGithubBlobUrl");function Ep(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(Ep,"parseGitlabTreeUrl");function Lp(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(Lp,"parseGitlabBlobUrl");var JQ=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function Op(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||JQ.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(Op,"parseGithubRepoUrl");function wp(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(wp,"parseGitlabRepoUrl");function Ap(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(Ap,"parseGitSshGithub");function bp(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(bp,"parseGitSshGitlab");A();var ZQ=/^[A-Za-z]:[\\/]/,QQ=/^[A-Za-z]:\//;function TG(...t){return t.some(e=>e.includes("\\")||ZQ.test(e))?win32:posix}s(TG,"pathApiFor");function xp(t){return t.replace(/\\/g,"/")}s(xp,"toPosixPath");function Pp(t){return xp(t).replace(/^\/+|\/+$/g,"")}s(Pp,"normalizeInstallPathField");function ng(t){let e=xp(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||QQ.test(e)?e:`./${e}`}s(ng,"normalizeLocalSourceForYaml");function Si(t){return {...t,source:t.source_kind==="local"?ng(t.source):t.source,...t.path!==void 0?{path:Pp(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>Pp(e))}:{}}}s(Si,"normalizePersistedInstallPaths");function DG(t,e,r){let n=TG(t,e),o=n.normalize(t),i=n.normalize(e),a=Pp(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=Pp(u),g=xp(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:ng(g)}}let m=xp(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:ng(m)}}s(DG,"localParsedFromAbsPath");async function ZS(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=Cp(n)??kp(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=Op(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=Ep(n)??Lp(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=wp(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=Ap(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=bp(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 DG(m,e,o)}s(ZS,"parseInstallSource");function Tp(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=Cp(e)??kp(e);if(a!==null)return {kind:"github",remoteUrl:`https://github.com/${a.org}/${a.repo}.git`,ref:a.ref};let l=Op(e);if(l!==null)return {kind:"github",remoteUrl:`https://github.com/${l.org}/${l.repo}.git`,ref:"HEAD"};let c=Ep(e)??Lp(e);if(c!==null)return {kind:"gitlab",remoteUrl:`https://gitlab.com/${c.namespace}/${c.project}.git`,ref:c.ref};let m=wp(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=Ap(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=bp(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(Tp,"parseSourceUrl");ZR();function Sn(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(Sn,"featuresFromCanonical");async function og(t,e={}){let{sliceRoot:r,implicitPick:n}=await If(t),{canonical:o,cleanup:i}=await Cf(r,{...e,enableTargetEntityMappers:true});return {canonical:o,features:Sn(o),implicitPick:n,cleanup:i}}s(og,"discoverFromContentRoot");function NG(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(NG,"validateSkill");function FG(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(FG,"validateRule");function vG(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(vG,"validateCommand");function MG(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(MG,"validateAgent");function ie(t){return basename(t.source).replace(/\.md$/i,"")}s(ie,"ruleSlug");function eq(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(eq,"featuresFromImplicitPick");function Pc(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??eq(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(ie(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(Pc,"narrowDiscoveredForInstallScope");oS();async function $G(t,e,r,n,o={}){let i=await Lf(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:a,cleanup:l}=await og(i.discoveryRoot,o),c=Pc(a,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:s(async()=>{await Promise.allSettled([l(),i.cleanup()]);},"combinedCleanup")},narrowed:c,discoveredFeatures:Sn(c)}}s($G,"resolveManualDiscoveredForInstall");Co();jR();A();xt();var rq=(()=>{let t=new Map;for(let r of Pt){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 nq(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(nq,"norm");function sg(t){let e=nq(t);if(e){for(let{prefix:r,target:n}of rq)if(e===r||e.startsWith(`${r}/`))return n}}s(sg,"targetHintFromNativePath");function QS(t,e){return sg(t)===e}s(QS,"pathSupportsNativePick");function GG(t,e){if(!t||!e)return;let r=sg(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(GG,"validateTargetMatchesPath");function jG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(jG,"extendPickHasArrays");A();A();Xt();async function BG(t,e){let r=join(t,...Ze.split("/")),n=join(t,...e.split("/")),o=await G(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(BG,"inferGeminiCommandNamesFromFiles");Xt();gr();A();async function Ua(t){let e=await G(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(Ua,"skillNamesFromNativeSkillDir");A();Nr();async function KG(t,e){let r=join(t,...e.split("/"));if(e.startsWith(mi)){let n=await G(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 G(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 G(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 Ua(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await G(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(KG,"inferCopilotPickFromPath");async function tr(t,e){let r=await G(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}s(tr,"mdNames");async function HG(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===Ze||n.startsWith(`${Ze}/`)){let i=await BG(t,n);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let i=await tr(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".claude/rules")){let i=await tr(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".claude/agents")){let i=await tr(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 tr(o,".mdc");return i.length?{rules:i}:{}}if(n.startsWith(".cursor/commands")){let i=await tr(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".cursor/agents")){let i=await tr(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".cursor/skills")){let i=await Ua(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return KG(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let i=await tr(o,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(n.startsWith(te)){let i=await Ua(o);return i.length?{skills:i}:{}}if(n.startsWith(Mn)){let i=await tr(o,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let i=await tr(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".continue/prompts")){let i=await tr(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".continue/skills")){let i=await Ua(o);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let i=await tr(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".junie/rules")){let i=await tr(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".junie/agents")){let i=await tr(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".junie/skills")){let i=await Ua(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await G(o),a=[...new Set(i.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(HG,"inferImplicitPickFromNativePath");function zG(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(zG,"isImplicitPickEmpty");UR();function Np(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(Np,"normalizePath");function dq(t,e){let r=Np(t),n=Np(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(dq,"overlapsPath");function ig(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(ig,"addUnique");async function fq(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(fq,"makeStageRoot");function gq(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:ig(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=Np(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:ig(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:ig(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=Np(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:ig(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(gq,"buildPickFromResults");function hq(t,e,r,n){let o=join(e,...Np(t).split("/")),i=r.filter(a=>dq(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:gq(i,e)}}s(hq,"scopeImportedResults");async function tI(t,e){let{stageRoot:r,cleanup:n}=await fq(t);try{let o=await mp(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s(tI,"stageImportedNativeRepo");async function eI(t,e,r){let n=await tI(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...hq(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(eI,"stageNativeInstallScope");async function XG(t,e,r,n){let o=n.explicitTarget?.trim();o&&or.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");GG(o,i);let a=join(t,".agentsmesh"),l=await j(a),c=i?sg(i):void 0,p=!l&&!o&&(!i||c!==void 0)?await pf(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 b=await eI(t,i,u);return {discoveryRoot:b.stageRoot,implicitPick:b.pick,scopedFeatures:b.features,yamlTarget:u,importHappened:true,cleanup:b.cleanup}}let k=await tI(t,u);return {discoveryRoot:i?join(k.stageRoot,i):k.stageRoot,yamlTarget:u,importHappened:true,cleanup:k.cleanup}}let g;l?i?u&&QS(i,u)?g=t:g=e:g=t:g=e;let h,S,C;if(f&&u){let k=await eI(t,i,u);g=k.stageRoot,h=k.pick,S=k.features,C=k.cleanup;}else if(g===t&&i&&u&&QS(i,u)&&(h=await HG(t,i,u),zG(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 R;return o?R=o:u&&(h&&jG(h)||(S?.length??0)>0)&&(R=u),{discoveryRoot:g,implicitPick:h,scopedFeatures:S,yamlTarget:R,importHappened:C!==void 0,cleanup:C}}s(XG,"prepareInstallDiscovery");async function rI(t,e,r,n,o={}){let i=await XG(t,e,r,{explicitTarget:n}),{canonical:a,implicitPick:l,cleanup:c}=await og(i.discoveryRoot,o),m=i.cleanup,u={...i,cleanup:s(async()=>{await Promise.allSettled([c(),...m?[m()]:[]]);},"mergedCleanup")},f=l??i.implicitPick,g=Pc(a,{implicitPick:f,scopedFeatures:i.scopedFeatures}),h=Sn(g);return {prep:u,discovered:a,implicitPick:f,narrowed:g,discoveredFeatures:h}}s(rI,"resolveDiscoveredForInstall");var Rq=[".claude-plugin","marketplace.json"];async function Sq(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(Sq,"dirExists");function Iq(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(Iq,"normalizeSource");async function QG(t,e,r){let n=join(t,...Rq),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=Iq(c.source);if(!m)continue;let p=join(t,m);if(!await Sq(p))continue;let u=await e(p,m);r(u)&&l.push({path:m,layout:u});}return l}s(QG,"detectMarketplaceSubPacks");async function Fp(t){try{return (await stat(t)).isDirectory()}catch{return false}}s(Fp,"dirExists");async function Ii(t){try{return (await readdir(t,{withFileTypes:!0})).map(r=>({name:r.name,isDir:r.isDirectory(),isFile:r.isFile()}))}catch{return []}}s(Ii,"listDirEntries");function qG(t){return t.endsWith(".instructions.md")?"copilot-instructions":t.endsWith(".md")?"md":t.endsWith(".mdc")?"mdc":t.endsWith(".toml")?"toml":null}s(qG,"classifyFileShape");var Eq=["rules","commands","agents","skills","mcp.json","hooks.yaml","permissions.yaml","ignore"],Lq=[".cursorrules",".windsurfrules"];async function ej(t){let e=join(t,".agentsmesh");if(!await Fp(e))return null;let r=await Ii(e),n=new Set(r.map(o=>o.name));for(let o of Eq)if(n.has(o))return {path:".agentsmesh"};return null}s(ej,"detectCanonical");async function rj(t){for(let e of Lq)try{if((await stat(join(t,e))).isFile())return {path:e}}catch{}return null}s(rj,"detectRootRule");async function nj(t){try{if((await stat(join(t,"SKILL.md"))).isFile())return {path:"SKILL.md"}}catch{}return null}s(nj,"detectRootSkill");Lo();var wq={rules:"rules",commands:"commands",agents:"agents",skills:"skills"},Aq=[".claude-plugin",".codex-plugin",".cursor-plugin"],bq=/^[a-z0-9]+(?:-[a-z0-9]+)*$/;async function oj(t){let e=join(t,"skills"),r=await Ii(e);for(let n of r)if(!(!n.isDir||n.name.startsWith("_")||!bq.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(oj,"detectSkillPack");async function sj(t){let e=[];for(let[r,n]of Object.entries(wq)){let o=join(t,r),i=await Ii(o),a=new Set;for(let l of i){if(!l.isFile||En(l.name))continue;let c=qG(l.name);c&&a.add(c);}for(let l of a)e.push({path:r,suggestedAs:n,fileShape:l});}return e}s(sj,"detectFlatCollections");async function ij(t){let e=[];for(let r of Aq)await Fp(join(t,r))&&e.push({path:r});return e}s(ij,"detectToolNativeManifests");async function sI(t,e){let r=await ej(t);if(r)return {canonical:r,skillPack:null,rootSkill:null,rootRule:null,flatCollections:[],toolNativeManifests:[]};let n=await oj(t),o=n?null:await nj(t),i=await sj(t),a=n||o||i.length>0?null:await rj(t),l=await ij(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(sI,"detectFlatLayout");function oI(t){return t.canonical!==null||t.skillPack!==null||t.rootSkill!==null||t.rootRule!==null||t.flatCollections.length>0}s(oI,"hasContent");async function aj(t,e){let r=await Ii(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 sI(i,a);oI(l)&&n.push({path:a,layout:l});}return n}s(aj,"collectSubPackCandidates");async function Pq(t,e){if(oI(e))return [];let r=await QG(t,sI,oI);if(r&&r.length>0)return r;let n=await aj(t,"");if(n.length>=2)return n;let o=await Ii(t);for(let i of o){if(!i.isDir||i.name.startsWith("."))continue;let a=await aj(join(t,i.name),i.name);if(a.length>=2)return a}return []}s(Pq,"detectSubPacks");async function cj(t){let e=await sI(t,"");if(e.canonical)return {...e,subPacks:[]};let r=await Pq(t,e);return {...e,subPacks:r}}s(cj,"detectLayout");A();U();async function pj(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=jr(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(pj,"inferMdcTarget");hf();Sf();function vq(t){let e=t.indexOf("#");return e<0?{path:t,anchor:""}:{path:t.slice(0,e),anchor:t.slice(e)}}s(vq,"splitAnchor");function Mq(t){return t.split(sep).join("/")}s(Mq,"toForwardSlash");async function $q(t){try{return await stat(t),!0}catch{return false}}s($q,"pathExists");async function gj(t){let{link:e,fromFile:r,contentRoot:n,includedPaths:o}=t,{path:i,anchor:a}=vq(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=Mq(p);return await $q(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(gj,"resolveLink");var Gq=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,jq=/(!?)\[[^\]\n]*\]\(([^)\n]+)\)/g,Uq=/^\s*\[([^\]\n]+)\]:\s*(.+?)\s*$/gm;function Bq(t){let e=[];for(let r of t.matchAll(Gq)){let n=r.index??0;e.push([n,n+r[0].length]);}return e}s(Bq,"getFencedCodeRanges");function hj(t,e){for(let[r,n]of e)if(t>=r&&t<n)return true;return false}s(hj,"isInRanges");function yj(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(yj,"normalizeDestination");function ag(t){let e=Bq(t),r=[];for(let n of t.matchAll(jq)){let o=n.index??0;if(hj(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:yj(a),destinationOffset:c,destinationLength:a.length});}for(let n of t.matchAll(Uq)){let o=n.index??0;if(hj(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:yj(a),label:i,destinationOffset:m,destinationLength:a.trimEnd().length});}return r}s(ag,"scanMarkdownLinks");function _j(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(_j,"applyRangeRewrites");function Kq(t){return !(t.length===0||t.startsWith("#")||t.startsWith("/")||/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(t))}s(Kq,"isCandidateRelativePath");function Wq(t){let e=t.replaceAll("\\","/");return e==="{baseDir}"?".":e.startsWith("{baseDir}/")?e.slice(10):e}s(Wq,"stripPath");function Hq(t){let e=t.destination;return Kq(e)?{raw:e,path:Wq(e),kind:t.kind,...t.label!==void 0?{label:t.label}:{}}:null}s(Hq,"toScannedLink");function Rj(t){let e=[];for(let r of ag(t)){let n=Hq(r);n!==null&&e.push(n);}return e}s(Rj,"scanRelativeLinks");function xc(t,e){let r=t.replaceAll("\\","/"),n=e.replaceAll("\\","/"),o=r.endsWith("/")?r:`${r}/`;return n.startsWith(o)?n.slice(o.length):n}s(xc,"toForwardSlashRelative");function Sj(t,e,r,n,o){let i=new Set;for(let a of e){i.add(xc(t,a.source));for(let l of a.supportingFiles)i.add(xc(t,l.absolutePath));}for(let a of r)i.add(xc(t,a.source));for(let a of n)i.add(xc(t,a.source));for(let a of o)i.add(xc(t,a.source));return i}s(Sj,"buildIncludedPaths");function Vq(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(Vq,"listScannables");async function Ij(t,e,r,n,o,i){let a=Vq(e,r,n,o),l=[];for(let c of a){let m=Rj(c.body);if(m.length===0)continue;let p=xc(t,c.sourcePath),u=[];for(let f of m){let g=await gj({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(Ij,"detectBrokenLinks");Sf();async function Cj(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 yf(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 S=o.get(g.name)??[];S.push({path:g.source,precedence:p.precedence}),o.set(g.name,S);}}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(Cj,"mergeCommands");async function kj(t,e,r={}){let[n,o,i,a]=await Promise.all([yM(`${t}/skills`,r),Rf(`${t}/agents`,{parseOpts:r}),_f(`${t}/rules`,{parseOpts:r}),Cj(t,e.mergeFromToolDirs,r)]),l=[...o.agents],c=[...i.rules],m=Sj(t,n,l,a.commands,c),p=await Ij(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(kj,"aggregateAnthropicSkillPack");var Ej={mergeFromToolDirs:[{dir:"commands",precedence:0},{dir:".claude/commands",target:"claude-code",precedence:1},{dir:".gemini/commands",target:"gemini-cli",precedence:2}]};al();function Xq(t){return {rules:[...t.rules],commands:[...t.commands],agents:[...t.agents],skills:[...t.skills],mcp:null,permissions:null,hooks:null,ignore:[]}}s(Xq,"aggregateToCanonical");function lg(){return {}}s(lg,"emptyPrep");async function Zq(t,e){let r=[];for(let n of e)if(n.fileShape==="mdc"&&!n.inferredTarget){let o=await pj(join(t,n.path));r.push(o?{...n,inferredTarget:o}:n);}else r.push(n);return r}s(Zq,"enrichMdcTargets");function Oj(t){return t.canonical?"canonical-agentsmesh":t.skillPack||t.rootSkill?"anthropic-skill-pack":t.rootRule||t.toolNativeManifests.length>0?"tool-native":"unknown"}s(Oj,"deriveSourceType");async function Qq(t,e){let r=await pu(t,e);return {rules:[],commands:[],agents:[],skills:r?[r]:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(Qq,"rootSkillToCanonical");async function qq(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(qq,"rootRuleToCanonical");async function wj(t){let e=t.parseOpts??{};if(t.explicitAs)return {implicitPick:void 0,...await $G(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick,e)};if(t.explicitTarget)return rI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e);let r=await cj(t.contentRoot),n=await Zq(t.contentRoot,r.flatCollections),o={...r,flatCollections:n};if(o.skillPack&&!o.canonical){let a=await kj(t.contentRoot,Ej,e),l=Xq(a);return {prep:{cleanup:a.cleanup},implicitPick:void 0,narrowed:l,discoveredFeatures:Sn(l),layout:o,aggregate:a}}if(o.rootSkill&&!o.canonical&&!o.skillPack){let a=await Qq(t.contentRoot,e);return {prep:lg(),implicitPick:void 0,narrowed:a,discoveredFeatures:Sn(a),layout:o}}if(o.rootRule&&!o.canonical&&!o.skillPack&&!o.rootSkill&&o.flatCollections.length===0){let a=await qq(t.contentRoot,o.rootRule.path);return {prep:lg(),implicitPick:void 0,narrowed:a,discoveredFeatures:Sn(a),layout:o}}return o.subPacks.length>0?{prep:lg(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:o.flatCollections.length>0?{prep:lg(),implicitPick:void 0,narrowed:{rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]},discoveredFeatures:[],layout:o}:{...await rI(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget,e),layout:o}}s(wj,"resolveInstallDiscovery");function bj(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(bj,"featuresFromLayout");function t8(t){return t.replace(/[/\\]+/g,"-").replace(/[^a-z0-9-]/gi,"").toLowerCase()}s(t8,"subPackSlug");function Aj(t,e,r){let n=bj(t.layout),o=!t.layout.skillPack&&!t.layout.rootSkill&&n.length>0;return {name:`${e}-${t8(t.path)}`,source:r,path:t.path,...o?{as:n[0]}:{},features:n}}s(Aj,"targetFromSubPack");function Pj(t,e,r){return {name:e,source:r,path:t.path,as:t.suggestedAs,target:t.inferredTarget,features:[t.suggestedAs]}}s(Pj,"targetFromCollection");function xj(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 e8(t);if(e.flatCollections.length===1){let l=e.flatCollections[0];return {targets:[Pj(l,r,n)],isMarketplace:false}}return e.flatCollections.length>1?r8(t):{targets:[],isMarketplace:false}}s(xj,"selectInstallCandidates");function e8(t){let{layout:e,sourceName:r,sourceForYaml:n}=t;if(t.all)return {targets:e.subPacks.map(a=>Aj(a,r,n)),isMarketplace:true};if(t.force||!t.tty){let a=e.subPacks.map(l=>({path:l.path,features:bj(l.layout)})).map(l=>` - ${l.path} (${l.features.join(", ")})`).join(`
336
378
  `);throw new Error(`Marketplace source with ${e.subPacks.length} sub-packs. Pass --all to install all, or use --path <subpath>:
337
- ${a}`)}return {targets:e.subPacks.map(i=>oj(i,r,n)),isMarketplace:true}}s(uq,"selectMarketplace");function dq(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(`
379
+ ${a}`)}return {targets:e.subPacks.map(i=>Aj(i,r,n)),isMarketplace:true}}s(e8,"selectMarketplace");function r8(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(`
338
380
  `);throw new Error(`Ambiguous source with ${e.flatCollections.length} resource collections. Pass --as <kind> to select, or --path <subpath>:
339
- ${i}`)}return {targets:e.flatCollections.map(i=>ij(i,r,n)),isMarketplace:false}}s(dq,"selectMultipleCollections");Mr();UR();function Ac(t){return t==="."||t===""?void 0:t}s(Ac,"trimDot");function gq(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(gq,"markdownPick");async function cj(t){if(!t.as)return {pathInRepo:Ac(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:Ac(dirname(e)),pick:gq(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:Ac(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 hf(o);return {pathInRepo:Ac(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:Ac(e)}}}}return {pathInRepo:Ac(e)}}s(cj,"resolveManualInstallPersistence");ho();ot();ot();async function bc(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 Sc(e==="global"?{global:!0}:{},r,{printMatrix:!1});Cc(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(bc,"runPostOperationGenerate");async function yo(t){return process.stdin.isTTY?new Promise(e=>{let r=mj.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 hq(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(hq,"hasArrayResources");function pj(t){return hq(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(pj,"hasInstallableResources");async function uj(t,e,r,n){let o=t.skills.map(l=>mG(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(uj,"resolveSkillPool");async function dj(t,e,r,n){let o=t.rules.map(l=>pG(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 "${ie(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(dj,"resolveRulePool");async function fj(t,e,r,n){let o=t.commands.map(l=>uG(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(fj,"resolveCommandPool");async function gj(t,e,r,n){let o=t.agents.map(l=>dG(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(gj,"resolveAgentPool");async function hj(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>ie(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=ie(a);t.rules.some(c=>ie(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(hj,"resolveInstallConflicts");function yj(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(yj,"pickForSelectedResources");function yq(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(yq,"pathEndsWithName");function Qf(t,e,r){return r!==1||e.length!==1?false:yq(t,e[0])}s(Qf,"inferSingleNamePick");function _j(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||Qf(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||Qf(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||Qf(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||Qf(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(_j,"buildInstallPick");function Rj(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(Rj,"deriveInstallFeatures");function _q(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(_q,"isEmptyInstallSelection");function Ij(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(_q(e)&&!a)throw new Error("No resources selected to install.")}s(Ij,"ensureInstallSelection");So();function Sj(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(Sj,"assertExtendNameAvailable");function Rq(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(Rq,"mergePick");function Cj(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=Rq(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(Cj,"mergeExtendList");A();async function kj(t,e,r){let n=await _(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=Cj(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await S(t,a.endsWith(`
381
+ ${i}`)}return {targets:e.flatCollections.map(i=>Pj(i,r,n)),isMarketplace:false}}s(r8,"selectMultipleCollections");$r();QR();function Tc(t){return t==="."||t===""?void 0:t}s(Tc,"trimDot");function o8(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(o8,"markdownPick");async function Dj(t){if(!t.as)return {pathInRepo:Tc(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:Tc(dirname(e)),pick:o8(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:Tc(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 kf(o);return {pathInRepo:Tc(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:Tc(e)}}}}return {pathInRepo:Tc(e)}}s(Dj,"resolveManualInstallPersistence");yo();ot();ot();async function Dc(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 Ec(e==="global"?{global:!0}:{},r,{printMatrix:!1});Lc(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(Dc,"runPostOperationGenerate");async function _o(t){return process.stdin.isTTY?new Promise(e=>{let r=Nj.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(_o,"confirm");function s8(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(s8,"hasArrayResources");function Fj(t){return s8(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(Fj,"hasInstallableResources");async function vj(t,e,r,n){let o=t.skills.map(l=>NG(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 _o(`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(vj,"resolveSkillPool");async function Mj(t,e,r,n){let o=t.rules.map(l=>FG(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 _o(`Include invalid rule "${ie(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(Mj,"resolveRulePool");async function $j(t,e,r,n){let o=t.commands.map(l=>vG(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 _o(`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($j,"resolveCommandPool");async function Gj(t,e,r,n){let o=t.agents.map(l=>MG(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 _o(`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(Gj,"resolveAgentPool");async function jj(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>ie(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 _o(`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=ie(a);t.rules.some(c=>ie(c)===l)&&(await _o(`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 _o(`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 _o(`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(jj,"resolveInstallConflicts");function Uj(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(Uj,"pickForSelectedResources");function i8(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(i8,"pathEndsWithName");function cg(t,e,r){return r!==1||e.length!==1?false:i8(t,e[0])}s(cg,"inferSingleNamePick");function Bj(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||cg(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||cg(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||cg(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||cg(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(Bj,"buildInstallPick");function Kj(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(Kj,"deriveInstallFeatures");function a8(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(a8,"isEmptyInstallSelection");function Wj(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(a8(e)&&!a)throw new Error("No resources selected to install.")}s(Wj,"ensureInstallSelection");Co();function Hj(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(Hj,"assertExtendNameAvailable");function l8(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(l8,"mergePick");function zj(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=l8(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(zj,"mergeExtendList");A();async function Vj(t,e,r){let n=await _(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=zj(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await I(t,a.endsWith(`
340
382
  `)?a:`${a}
341
- `);}s(kj,"writeAgentsmeshWithNewExtend");ot();async function Ej(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=kq(n);if(Sj(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 kj(a,r,i),y.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(Ej,"writeInstallAsExtend");function kq(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(kq,"toNewExtendEntry");A();A();var Lq="pack.yaml";async function qf(t){let e=await G(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===Lq)continue;let l=await Ef(i);l!==null&&r.push(`${a}:${l}`);}let n=r.join(`
343
- `);return `sha256:${kf(n)}`}s(qf,"hashPackContent");A();var tr=".agentsmesh-install-manifest.json",wq=["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 Aq(t,e){return relative(t,e).replaceAll("\\","/")}s(Aq,"toForwardSlashRelative");async function tg(t){let e=await Es(t),r=[];for(let n of e){let o=Aq(t,n);if(wq.includes(o))continue;let i=await Lf(n);i!==null&&r.push([o,`sha256:${i}`]);}return r.sort(([n],[o])=>n.localeCompare(o)),Object.fromEntries(r)}s(tg,"hashPackFiles");A();var bq=/spdx-license-identifier:\s*([A-Za-z0-9.+-]+)/i,Pq=[{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 Lj(t){if(t.trim().length===0)return null;let e=bq.exec(t);if(e)return e[1]??null;for(let{id:r,pattern:n}of Pq)if(n.test(t))return r;return null}s(Lj,"detectSpdxLicense");var xq=["LICENSE","COPYING","NOTICE","COPYRIGHT"],Dq=["",".md",".txt",".rst"];async function Oj(t){for(let e of xq)for(let r of Dq){let n=await _(join(t,`${e}${r}`));if(n===null)continue;let o=Lj(n);if(o!==null)return o}return null}s(Oj,"detectLicenseInPackDir");async function vq(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(vq,"writeRules");async function Mq(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(Mq,"writeCommands");async function $q(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($q,"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 jq(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(jq,"writePreservedRootFiles");async function Uq(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(`
383
+ `);}s(Vj,"writeAgentsmeshWithNewExtend");ot();async function Jj(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=u8(n);if(Hj(r.extends,i),o){y.info(`[dry-run] Would add extend:
384
+ ${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await Vj(a,r,i),y.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(Jj,"writeInstallAsExtend");function u8(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?or.parse(t.yamlTarget):void 0,as:t.as}}s(u8,"toNewExtendEntry");A();A();var f8="pack.yaml";async function mg(t){let e=await G(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===f8)continue;let l=await xf(i);l!==null&&r.push(`${a}:${l}`);}let n=r.join(`
385
+ `);return `sha256:${Pf(n)}`}s(mg,"hashPackContent");A();var er=".agentsmesh-install-manifest.json",h8=["pack.yaml",er];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 y8(t,e){return relative(t,e).replaceAll("\\","/")}s(y8,"toForwardSlashRelative");async function pg(t){let e=await Os(t),r=[];for(let n of e){let o=y8(t,n);if(h8.includes(o))continue;let i=await Tf(n);i!==null&&r.push([o,`sha256:${i}`]);}return r.sort(([n],[o])=>n.localeCompare(o)),Object.fromEntries(r)}s(pg,"hashPackFiles");A();var _8=/spdx-license-identifier:\s*([A-Za-z0-9.+-]+)/i,R8=[{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 Yj(t){if(t.trim().length===0)return null;let e=_8.exec(t);if(e)return e[1]??null;for(let{id:r,pattern:n}of R8)if(n.test(t))return r;return null}s(Yj,"detectSpdxLicense");var I8=["LICENSE","COPYING","NOTICE","COPYRIGHT"],C8=["",".md",".txt",".rst"];async function Xj(t){for(let e of I8)for(let r of C8){let n=await _(join(t,`${e}${r}`));if(n===null)continue;let o=Yj(n);if(o!==null)return o}return null}s(Xj,"detectLicenseInPackDir");async function L8(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(L8,"writeRules");async function O8(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(O8,"writeCommands");async function w8(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(w8,"writeAgents");async function A8(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(A8,"writeSkills");async function b8(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(b8,"writePreservedRootFiles");async function P8(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
386
+ `),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(`
345
387
  `)}
346
- `);}s(Uq,"writeSettings");function Bq(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(Bq,"validatePackName");async function Kq(t,e,r){let n=await tg(t),o=w$({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(Kq,"writeInstallManifest");async function wj(t,e,r,n,o={},i=[]){Bq(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 vq(r,a),await Mq(r,a),await $q(r,a),await Gq(r,a),await Uq(r,a),await jq(i,a);let u=await qf(a),f=await Oj(a);m=_i({...n,content_hash:u,license:f}),await S(join(a,"pack.yaml"),Ma(stringify(m),"pack")),await Kq(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(wj,"materializePack");yc();A();function XI(t,e){return [...new Set([...t,...e])]}s(XI,"union");function Hq(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=XI(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(Hq,"mergePathScope");function zq(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=XI(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(zq,"mergePick");async function Vq(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(Vq,"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 Yq(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(Yq,"mergeAgents");async function Xq(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(Xq,"mergeSkills");async function Zq(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(Zq,"mergePreservedRootFiles");async function Qq(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(`
388
+ `);}s(P8,"writeSettings");function x8(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(x8,"validatePackName");async function T8(t,e,r){let n=await pg(t),o=K$({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,er),`${JSON.stringify(o,null,2)}
389
+ `);}s(T8,"writeInstallManifest");async function Zj(t,e,r,n,o={},i=[]){x8(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 L8(r,a),await O8(r,a),await w8(r,a),await A8(r,a),await P8(r,a),await b8(i,a);let u=await mg(a),f=await Xj(a);m=Si({...n,content_hash:u,license:f}),await I(join(a,"pack.yaml"),Ga(stringify(m),"pack")),await T8(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(Zj,"materializePack");Sc();A();function pI(t,e){return [...new Set([...t,...e])]}s(pI,"union");function N8(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=pI(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(N8,"mergePathScope");function F8(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=pI(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(F8,"mergePick");async function v8(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(v8,"mergeRules");async function M8(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(M8,"mergeCommands");async function $8(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($8,"mergeAgents");async function G8(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(G8,"mergeSkills");async function j8(t,e){for(let r of t)await copyFile(r.absolutePath,join(e,r.relativePath));}s(j8,"mergePreservedRootFiles");async function U8(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
390
+ `),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(`
349
391
  `)}
350
- `);}s(Qq,"mergeSettings");async function Aj(t,e,r,n,o,i,a=[]){await Vq(r,t),await Jq(r,t),await Yq(r,t),await Xq(r,t),await Qq(r,t),await Zq(a,t);let l=XI(e.features,n),c=zq(e.pick,n,o),m=Hq(e,i?.path),p=await qf(t),u=new Date().toISOString(),f=_i({...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"),Ma(stringify(f),"pack")),f}s(Aj,"mergeIntoPack");Bg();Eo();async function bj(t){let e=[];try{let r=await readdir(t,{withFileTypes:!0});for(let n of r)n.isFile()&&eu(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(bj,"collectPreservedRootFiles");So();ot();So();A();If();function r3(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(r3,"sanitize");function n3(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(n3,"gitUrlLastSegments");function Pj(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=n3(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=r3(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(Pj,"suggestExtendName");function Tj(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||Pj(r,{featureHint:n.length===1?n[0]:void 0},i)}s(Tj,"selectInstallEntryName");function xj(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(xj,"canonicalRemoteIdentity");function o3(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?xj(t.gitRemoteUrl):null}s(o3,"parsedSourceIdentity");function Dj(t,e){let r=o3(e);if(r===null)return null;for(let n of t){let o=xj(n.source);if(o!==null&&o===r)return n.name}return null}s(Dj,"findExistingInstallName");function ZI(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(ZI,"sameFeatureSet");function Nj(t){let{manifest:e,parsed:r,entryFeatures:n,yamlTarget:o,explicitAs:i}=t,a=Dj(e,r);if(a===null)return null;let l=e.find(c=>c.name===a);return l.target!==o||l.as!==i||!ZI(l.features,n)?null:l.name}s(Nj,"pickReuseEntryName");var a3=s(t=>!t.includes("/")&&!t.includes("\\")&&!t.includes("\0")&&t!=="."&&t!=="..","isSafeInstallName"),vj=z$1.object({name:z$1.string().min(1).refine(a3,{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(Qa).min(1),pick:Kc.optional(),target:nr.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:hc.optional(),refreshed_at:z$1.string().min(1).optional(),original_ref:z$1.string().optional()}),l3=z$1.object({version:z$1.literal(1),installs:z$1.array(vj).default([])});function c3(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&ZI(t.features,e.features)}s(c3,"sameInstallIdentity");function QI(t){return join(t,"installs.yaml")}s(QI,"manifestPath");async function De(t){let e=await _(QI(t));if(e===null)return [];try{return l3.parse(parse(e)).installs.map(r=>_i(r))}catch{return []}}s(De,"readInstallManifest");async function rg(t,e){let r=_i(e),o=(await De(t)).filter(i=>i.name!==r.name&&!c3(i,r));o.push(r),await S(QI(t),Ma(stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}),"installs"));}s(rg,"upsertInstallManifestEntry");async function Mj(t,e){let r=await De(t),n=r.filter(o=>o.name!==e);return n.length===r.length?false:(await S(QI(t),Ma(stringify({version:1,installs:n.sort((o,i)=>o.name.localeCompare(i.name))}),"installs")),true)}s(Mj,"removeInstallManifestEntry");function $j(t){return _i(vj.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($j,"buildInstallManifestEntry");A();function p3(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(p3,"pathScope");function u3(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(ie(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(u3,"applySelection");async function Gj(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,forceFreshMaterialize:k,originalRef:I}=t,C=join(e,"packs"),b=u3(n,o),N=R?await bj(R):[],T=new Date().toISOString(),B=p!==void 0?nr.parse(p):void 0,H=k?null:await RM(C,i,{target:B,as:f,features:c}),tt=r,it=c,v=m,q=u,vt;if(H){let ae=H.packDir,bt=H.meta;if(g&&H.name!==r){let Qt=join(C,r);if(await j(Qt))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(H.packDir,Qt),ae=Qt,bt={...H.meta,name:r};}let Ft=await Aj(ae,bt,b,c,m,{source:i,...a!==void 0?{version:a}:{},...B!==void 0?{target:B}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}},N);tt=Ft.name,it=Ft.features,v=Ft.pick,q=Ft.path,vt=Ft.paths,y.success(`Updated pack "${Ft.name}" in .agentsmesh/packs/.`);}else {if(!k&&await yi(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 wj(C,r,b,{name:r,source:i,...a!==void 0&&{version:a},source_kind:l,installed_at:T,updated_at:T,features:c,...m!==void 0&&{pick:m},...B!==void 0&&{target:B},...p3(u),...f!==void 0&&{as:f}},h!==void 0?{source_type:h}:{},N),y.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await rg(e,$j({name:tt,source:i,version:a,sourceKind:l,features:it,pick:v,target:B,path:q,paths:vt,as:f,originalRef:I})),l!=="local"&&await hC(i);}s(Gj,"installAsPack");function jj(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=Oc(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:_n(n)}}s(jj,"applyReplayInstallScope");function Uj(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(Uj,"buildInstalledList");function Bj(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=ie(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(Bj,"buildSkippedList");function Kj(t,e){if(e.sourceKind==="local")return {canonical:t,stripped:[]};let r=[],n=t.hooks,o=t.permissions,i=t.mcp;return n!==null&&!e.acceptHooks&&(n=null,r.push("hooks")),o!==null&&!e.acceptPermissions&&(o=null,r.push("permissions")),i!==null&&!e.acceptMcp&&(i=null,r.push("mcp")),r.length===0?{canonical:t,stripped:[]}:{canonical:{...t,hooks:n,permissions:o,mcp:i},stripped:r}}s(Kj,"stripUntrustedElevatedArtifacts");async function Wj(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,forceFreshMaterialize:a,nameOverride:l,explicitAs:c}=t,{acceptHooks:m,acceptPermissions:p,acceptMcp:u}=t,{config:f,context:g,parsed:h,sourceForYaml:R,version:k,pathInRepo:I,contentRoot:C,persisted:b}=t,{replay:N,prep:T,implicitPick:B,narrowed:H,discoveredFeatures:tt,sourceType:it}=t,v=Kj(H,{sourceKind:h.kind,acceptHooks:m,acceptPermissions:p,acceptMcp:u});v.stripped.length>0&&y.warn(`[agentsmesh] Stripped ${v.stripped.join(", ")} from untrusted ${h.kind} source.
392
+ `);}s(U8,"mergeSettings");async function Qj(t,e,r,n,o,i,a=[]){await v8(r,t),await M8(r,t),await $8(r,t),await G8(r,t),await U8(r,t),await j8(a,t);let l=pI(e.features,n),c=F8(e.pick,n,o),m=N8(e,i?.path),p=await mg(t),u=new Date().toISOString(),f=Si({...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"),Ga(stringify(f),"pack")),f}s(Qj,"mergeIntoPack");qg();Lo();async function qj(t){let e=[];try{let r=await readdir(t,{withFileTypes:!0});for(let n of r)n.isFile()&&lu(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(qj,"collectPreservedRootFiles");Co();ot();Co();A();wf();function H8(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(H8,"sanitize");function z8(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(z8,"gitUrlLastSegments");function tU(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=z8(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=H8(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(tU,"suggestExtendName");function eU(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||tU(r,{featureHint:n.length===1?n[0]:void 0},i)}s(eU,"selectInstallEntryName");function rU(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(rU,"canonicalRemoteIdentity");function V8(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?rU(t.gitRemoteUrl):null}s(V8,"parsedSourceIdentity");function nU(t,e){let r=V8(e);if(r===null)return null;for(let n of t){let o=rU(n.source);if(o!==null&&o===r)return n.name}return null}s(nU,"findExistingInstallName");function uI(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(uI,"sameFeatureSet");function oU(t){let{manifest:e,parsed:r,entryFeatures:n,yamlTarget:o,explicitAs:i}=t,a=nU(e,r);if(a===null)return null;let l=e.find(c=>c.name===a);return l.target!==o||l.as!==i||!uI(l.features,n)?null:l.name}s(oU,"pickReuseEntryName");var X8=s(t=>!t.includes("/")&&!t.includes("\\")&&!t.includes("\0")&&t!=="."&&t!=="..","isSafeInstallName"),iU=z$1.object({name:z$1.string().min(1).refine(X8,{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(el).min(1),pick:Vc.optional(),target:or.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:Rc.optional(),refreshed_at:z$1.string().min(1).optional(),original_ref:z$1.string().optional()}),Z8=z$1.object({version:z$1.literal(1),installs:z$1.array(iU).default([])});function Q8(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&uI(t.features,e.features)}s(Q8,"sameInstallIdentity");function dI(t){return join(t,"installs.yaml")}s(dI,"manifestPath");async function Ne(t){let e=await _(dI(t));if(e===null)return [];try{return Z8.parse(parse(e)).installs.map(r=>Si(r))}catch{return []}}s(Ne,"readInstallManifest");async function dg(t,e){let r=Si(e),o=(await Ne(t)).filter(i=>i.name!==r.name&&!Q8(i,r));o.push(r),await I(dI(t),Ga(stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}),"installs"));}s(dg,"upsertInstallManifestEntry");async function aU(t,e){let r=await Ne(t),n=r.filter(o=>o.name!==e);return n.length===r.length?false:(await I(dI(t),Ga(stringify({version:1,installs:n.sort((o,i)=>o.name.localeCompare(i.name))}),"installs")),true)}s(aU,"removeInstallManifestEntry");function lU(t){return Si(iU.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(lU,"buildInstallManifestEntry");A();function t3(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(t3,"pathScope");function e3(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(ie(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(e3,"applySelection");async function cU(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:S,forceFreshMaterialize:C,originalRef:R}=t,k=join(e,"packs"),b=e3(n,o),N=S?await qj(S):[],x=new Date().toISOString(),B=p!==void 0?or.parse(p):void 0,H=C?null:await FM(k,i,{target:B,as:f,features:c}),tt=r,it=c,v=m,q=u,vt;if(H){let ae=H.packDir,bt=H.meta;if(g&&H.name!==r){let Qt=join(k,r);if(await j(Qt))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(H.packDir,Qt),ae=Qt,bt={...H.meta,name:r};}let Ft=await Qj(ae,bt,b,c,m,{source:i,...a!==void 0?{version:a}:{},...B!==void 0?{target:B}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}},N);tt=Ft.name,it=Ft.features,v=Ft.pick,q=Ft.path,vt=Ft.paths,y.success(`Updated pack "${Ft.name}" in .agentsmesh/packs/.`);}else {if(!C&&await Ri(join(k,r)))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await Zj(k,r,b,{name:r,source:i,...a!==void 0&&{version:a},source_kind:l,installed_at:x,updated_at:x,features:c,...m!==void 0&&{pick:m},...B!==void 0&&{target:B},...t3(u),...f!==void 0&&{as:f}},h!==void 0?{source_type:h}:{},N),y.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await dg(e,lU({name:tt,source:i,version:a,sourceKind:l,features:it,pick:v,target:B,path:q,paths:vt,as:f,originalRef:R})),l!=="local"&&await xC(i);}s(cU,"installAsPack");function mU(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=Pc(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:Sn(n)}}s(mU,"applyReplayInstallScope");function pU(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(pU,"buildInstalledList");function uU(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=ie(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(uU,"buildSkippedList");function dU(t,e){if(e.sourceKind==="local")return {canonical:t,stripped:[]};let r=[],n=t.hooks,o=t.permissions,i=t.mcp;return n!==null&&!e.acceptHooks&&(n=null,r.push("hooks")),o!==null&&!e.acceptPermissions&&(o=null,r.push("permissions")),i!==null&&!e.acceptMcp&&(i=null,r.push("mcp")),r.length===0?{canonical:t,stripped:[]}:{canonical:{...t,hooks:n,permissions:o,mcp:i},stripped:r}}s(dU,"stripUntrustedElevatedArtifacts");async function fU(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,forceFreshMaterialize:a,nameOverride:l,explicitAs:c}=t,{acceptHooks:m,acceptPermissions:p,acceptMcp:u}=t,{config:f,context:g,parsed:h,sourceForYaml:S,version:C,pathInRepo:R,contentRoot:k,persisted:b}=t,{replay:N,prep:x,implicitPick:B,narrowed:H,discoveredFeatures:tt,sourceType:it}=t,v=dU(H,{sourceKind:h.kind,acceptHooks:m,acceptPermissions:p,acceptMcp:u});v.stripped.length>0&&y.warn(`[agentsmesh] Stripped ${v.stripped.join(", ")} from untrusted ${h.kind} source.
351
393
  These artifacts control your tool settings (shell hooks, granted permissions, MCP launch specs).
352
- To accept them explicitly, re-run with: ${v.stripped.map(_o=>`--accept-${_o}`).join(" ")} (or --accept-elevated for all three).`);let{narrowed:q,discoveredFeatures:vt}=jj(v.canonical,tt,N);if(!pj(q))throw new Error(B||T.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 ae=await uj(q,r,n,o),bt=await dj(q,r,n,o),Ft=await fj(q,r,n,o),Qt=await gj(q,r,n,o),Ei={skills:ae.length,rules:bt.length,commands:Ft.length,agents:Qt.length},{canonical:Mp}=await Oe(f,g.configDir,{},g.canonicalDir),ks=!r&&!n&&o?await hj(Mp,{skills:ae,rules:bt,commands:Ft,agents:Qt}):{skillNames:ae.map(_o=>_o.name),ruleSlugs:bt.map(_o=>ie(_o)),commandNames:Ft.map(_o=>_o.name),agentNames:Qt.map(_o=>_o.name)};Ij({selected:ks,discoveredFeatures:vt,preConflict:Ei});let Ha=N?.features??Rj(vt,ks);if(Ha.length===0)throw new Error("No features left to install after selection.");let jc=yj(N?.pick,ks)??b.pick??_j({pathInRepo:b.pathInRepo??I,implicitPick:B,preConflictCounts:Ei,selected:ks}),TS=await De(g.canonicalDir),$p=Nj({manifest:TS,parsed:h,entryFeatures:Ha,yamlTarget:T.yamlTarget,explicitAs:c}),Gp=Tj({config:f,parsed:h,entryFeatures:Ha,nameOverride:l||$p||""}),Ig=Uj(ks,Gp),Sg=Bj(ae,bt,Ft,Qt,ks);if(i){if(await Ej({configDir:g.configDir,config:f,entryArgs:{name:Gp,source:R,version:k,features:Ha,path:b.pathInRepo,pick:jc,yamlTarget:T.yamlTarget,as:c},dryRun:n}),n)return {installed:Ig,skipped:Sg}}else {if(n)return y.info(`[dry-run] Would install pack "${Gp}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:Ig,skipped:Sg};await Gj({canonicalDir:g.canonicalDir,packName:Gp,narrowed:q,selected:ks,sourceForYaml:R,version:k,sourceKind:h.kind,entryFeatures:Ha,pick:jc,yamlTarget:T.yamlTarget,pathInRepo:b.pathInRepo,manualAs:c,renameExistingPack:l===""&&$p===null,sourceType:it,contentRoot:C,forceFreshMaterialize:a,originalRef:h.rawRef!==""?h.rawRef:void 0});}return await bc("install",e,g.rootBase),{installed:Ig,skipped:Sg}}s(Wj,"executeRunInstallPoolsAndWrite");function xc(t,e){let r=e?.input??process.stdin,n=e?.output??process.stdout;return new Promise(o=>{let i=mj.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(xc,"readLine");function zj(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(`
394
+ To accept them explicitly, re-run with: ${v.stripped.map(Ro=>`--accept-${Ro}`).join(" ")} (or --accept-elevated for all three).`);let{narrowed:q,discoveredFeatures:vt}=mU(v.canonical,tt,N);if(!Fj(q))throw new Error(B||x.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 ae=await vj(q,r,n,o),bt=await Mj(q,r,n,o),Ft=await $j(q,r,n,o),Qt=await Gj(q,r,n,o),Oi={skills:ae.length,rules:bt.length,commands:Ft.length,agents:Qt.length},{canonical:Wp}=await Oe(f,g.configDir,{},g.canonicalDir),Ls=!r&&!n&&o?await jj(Wp,{skills:ae,rules:bt,commands:Ft,agents:Qt}):{skillNames:ae.map(Ro=>Ro.name),ruleSlugs:bt.map(Ro=>ie(Ro)),commandNames:Ft.map(Ro=>Ro.name),agentNames:Qt.map(Ro=>Ro.name)};Wj({selected:Ls,discoveredFeatures:vt,preConflict:Oi});let Ja=N?.features??Kj(vt,Ls);if(Ja.length===0)throw new Error("No features left to install after selection.");let Wc=Uj(N?.pick,Ls)??b.pick??Bj({pathInRepo:b.pathInRepo??R,implicitPick:B,preConflictCounts:Oi,selected:Ls}),zI=await Ne(g.canonicalDir),Hp=oU({manifest:zI,parsed:h,entryFeatures:Ja,yamlTarget:x.yamlTarget,explicitAs:c}),zp=eU({config:f,parsed:h,entryFeatures:Ja,nameOverride:l||Hp||""}),xg=pU(Ls,zp),Tg=uU(ae,bt,Ft,Qt,Ls);if(i){if(await Jj({configDir:g.configDir,config:f,entryArgs:{name:zp,source:S,version:C,features:Ja,path:b.pathInRepo,pick:Wc,yamlTarget:x.yamlTarget,as:c},dryRun:n}),n)return {installed:xg,skipped:Tg}}else {if(n)return y.info(`[dry-run] Would install pack "${zp}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:xg,skipped:Tg};await cU({canonicalDir:g.canonicalDir,packName:zp,narrowed:q,selected:Ls,sourceForYaml:S,version:C,sourceKind:h.kind,entryFeatures:Ja,pick:Wc,yamlTarget:x.yamlTarget,pathInRepo:b.pathInRepo,manualAs:c,renameExistingPack:l===""&&Hp===null,sourceType:it,contentRoot:k,forceFreshMaterialize:a,originalRef:h.rawRef!==""?h.rawRef:void 0});}return await Dc("install",e,g.rootBase),{installed:xg,skipped:Tg}}s(fU,"executeRunInstallPoolsAndWrite");function vc(t,e){let r=e?.input??process.stdin,n=e?.output??process.stdout;return new Promise(o=>{let i=Nj.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(vc,"readLine");function hU(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(`
353
395
  `)}
354
- `);}s(zj,"writeBanner");async function Vj(t,e,r){let n=[];for(let o of t){if(o.resolved.length===0)continue;if(e.bypass){zj(r,o),n.push({entityKind:o.entityKind,entityName:o.entityName,action:"leave-with-warnings"});continue}zj(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(Vj,"runBrokenLinkPrompt");var tS=["skills","agents","commands","rules"],eS={skills:"skill",agents:"agent",commands:"command",rules:"rule"},Xj={skills:"skills",agents:"agents",commands:"commands",rules:"rules"};function ja(t){return {skills:[],agents:[],commands:[],rules:[],aborted:t}}s(ja,"emptySelection");function Jj(t){return {skills:[...t.skills],agents:[...t.agents],commands:[...t.commands],rules:[...t.rules],aborted:false}}s(Jj,"selectAll");function Yj(t,e,r){let n=[`Found in ${e}:`];for(let o of tS){let i=r[o];if(i.length===0)continue;let a=i.length===1?eS[o]:Xj[o];n.push(` - ${i.length} ${a}`);}n.push(""),t.write(`${n.join(`
396
+ `);}s(hU,"writeBanner");async function yU(t,e,r){let n=[];for(let o of t){if(o.resolved.length===0)continue;if(e.bypass){hU(r,o),n.push({entityKind:o.entityKind,entityName:o.entityName,action:"leave-with-warnings"});continue}hU(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(yU,"runBrokenLinkPrompt");var gI=["skills","agents","commands","rules"],hI={skills:"skill",agents:"agent",commands:"command",rules:"rule"},SU={skills:"skills",agents:"agents",commands:"commands",rules:"rules"};function Ka(t){return {skills:[],agents:[],commands:[],rules:[],aborted:t}}s(Ka,"emptySelection");function _U(t){return {skills:[...t.skills],agents:[...t.agents],commands:[...t.commands],rules:[...t.rules],aborted:false}}s(_U,"selectAll");function RU(t,e,r){let n=[`Found in ${e}:`];for(let o of gI){let i=r[o];if(i.length===0)continue;let a=i.length===1?hI[o]:SU[o];n.push(` - ${i.length} ${a}`);}n.push(""),t.write(`${n.join(`
355
397
  `)}
356
- `);}s(Yj,"writeBanner");async function d3(t,e,r){if(r.length===0)return {selected:[],aborted:false};let n=Xj[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=eS[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(d3,"walkType");function f3(t){let e=null;for(let r of tS)for(let n of t[r]){if(e!==null)return null;e={kind:r,id:n};}return e}s(f3,"findSingleEntity");async function g3(t,e){let r=eS[e.kind],n=(await t.ask(`Install ${r} "${e.id}"? [y/N] `)).trim().toLowerCase();return n==="y"?{...ja(false),[e.kind]:[e.id]}:ja(!(n===""||n==="n"))}s(g3,"runSingleEntityPrompt");async function Zj(t,e,r){if(e.bypass)return Jj(t);let n=t.skills.length+t.agents.length+t.commands.length+t.rules.length;if(n===0)return ja(false);if(n===1){let a=f3(t);if(a!==null)return Yj(r,e.packName,t),g3(r,a)}Yj(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 Jj(t);if(o==="n")return ja(false);if(o!=="s")return ja(true);let i={skills:[],agents:[],commands:[],rules:[]};for(let a of tS){let{selected:l,aborted:c}=await d3(r,a,t[a]);if(c)return ja(true);i[a]=l;}return {...i,aborted:false}}s(Zj,"runBulkPrompt");ot();function R3(t,e,r){let n=[];for(let o of Xf(t))o.destination===e&&n.push({offset:o.destinationOffset,length:o.destinationLength,replacement:r});return n}s(R3,"buildLinkRewrites");function qj(t,e,r){t.warn(`Broken link in ${e.entityKind} "${e.entityName}": ${r.link.path} (${r.classification})`);}s(qj,"warnLink");function I3(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(I3,"allocateSupportingFileNames");function Qj(t,e,r){return t.find(n=>n.entityKind===e&&n.entityName===r)}s(Qj,"findEntity");async function S3(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(S3,"buildSupportingFiles");async function C3(t,e,r,n){let o=r.resolved.filter(p=>p.classification==="resolvable-outside"),i=I3(o),a=await S3(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(...R3(e.body,p.link.raw,f));}else qj(n,r,p);let m=JG(e.body,l);return {...e,body:m,supportingFiles:a}}s(C3,"applySkillDecision");async function tU(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)?Qj(r.brokenLinks,"skill",l.name):void 0;a.push(c?await C3(e,l,c,o):l);}for(let l of n){if(l.entityKind==="skill"&&l.action==="include-resolvable")continue;let c=Qj(r.brokenLinks,l.entityKind,l.entityName);if(c)for(let m of c.resolved)qj(o,c,m);}return {...r,skills:a}}s(tU,"applyBrokenLinkDecisions");var Dc=class extends Error{static{s(this,"InstallAbortError");}aborted=true;constructor(e){super(e),this.name="InstallAbortError";}};function E3(){return {ask:s(t=>xc(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(E3,"defaultAdapter");function L3(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=>ie(e))}}s(L3,"bulkCandidatesFrom");function eU(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(ie(a))),mcp:null,permissions:null,hooks:null,ignore:[]}}s(eU,"filterCanonical");function O3(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(O3,"discoveredFeaturesOf");async function w3(t){let e=t.adapter??E3(),r=await Vj(t.aggregate.brokenLinks,{bypass:t.bypass},e);if(r.aborted)throw new Dc("User aborted at broken-link prompt.");let n=[...r.decisions],o=await tU({contentRoot:t.contentRoot,aggregate:t.aggregate,decisions:n,logger:y}),i=L3(o);if(i.skills.length+i.agents.length+i.commands.length+i.rules.length===0)return {aggregate:o,narrowed:eU(o,{skills:[],agents:[],commands:[],rules:[]}),discoveredFeatures:[]};let l=await Zj(i,{packName:t.displayName,bypass:t.bypass},e);if(l.aborted)throw new Dc("User aborted at bulk-select prompt.");let c=eU(o,l);return {aggregate:o,narrowed:c,discoveredFeatures:O3(c)}}s(w3,"runSkillPackPromptFlow");function A3(t){return basename(t)||"install source"}s(A3,"displayNameForContentRoot");async function rU(t){if(!t.discovery.aggregate)return {aborted:false};try{let e=await w3({contentRoot:t.contentRoot,aggregate:t.discovery.aggregate,narrowed:t.discovery.narrowed,bypass:t.bypass,displayName:A3(t.contentRoot)});return {aborted:!1,narrowed:e.narrowed,discoveredFeatures:e.discoveredFeatures}}catch(e){if(e instanceof Dc)return y.warn(e.message),{aborted:true};throw e}}s(rU,"runPromptFlowWithAbort");async function nU(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:R,nameOverride:k,acceptHooks:I,acceptPermissions:C,acceptMcp:b,scope:N,sourceArg:T,replay:B}=t,H=process.stdin.isTTY,{prep:tt,implicitPick:it}=e,{narrowed:v,discoveredFeatures:q}=e;try{let vt=await rU({discovery:e,contentRoot:c,bypass:f||u||!H});if(vt.aborted)return {exitCode:130,data:{source:T,mode:"install",installed:[],skipped:[],dryRun:u}};if(v=vt.narrowed??v,q=vt.discoveredFeatures??q,q.length===0&&r.brokenResources.length>0){let bt=r.brokenResources.map(Ft=>` - ${Ft.path}: ${Ft.reason}`).join(`
398
+ `);}s(RU,"writeBanner");async function r3(t,e,r){if(r.length===0)return {selected:[],aborted:false};let n=SU[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=hI[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(r3,"walkType");function n3(t){let e=null;for(let r of gI)for(let n of t[r]){if(e!==null)return null;e={kind:r,id:n};}return e}s(n3,"findSingleEntity");async function o3(t,e){let r=hI[e.kind],n=(await t.ask(`Install ${r} "${e.id}"? [y/N] `)).trim().toLowerCase();return n==="y"?{...Ka(false),[e.kind]:[e.id]}:Ka(!(n===""||n==="n"))}s(o3,"runSingleEntityPrompt");async function IU(t,e,r){if(e.bypass)return _U(t);let n=t.skills.length+t.agents.length+t.commands.length+t.rules.length;if(n===0)return Ka(false);if(n===1){let a=n3(t);if(a!==null)return RU(r,e.packName,t),o3(r,a)}RU(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 _U(t);if(o==="n")return Ka(false);if(o!=="s")return Ka(true);let i={skills:[],agents:[],commands:[],rules:[]};for(let a of gI){let{selected:l,aborted:c}=await r3(r,a,t[a]);if(c)return Ka(true);i[a]=l;}return {...i,aborted:false}}s(IU,"runBulkPrompt");ot();function l3(t,e,r){let n=[];for(let o of ag(t))o.destination===e&&n.push({offset:o.destinationOffset,length:o.destinationLength,replacement:r});return n}s(l3,"buildLinkRewrites");function kU(t,e,r){t.warn(`Broken link in ${e.entityKind} "${e.entityName}": ${r.link.path} (${r.classification})`);}s(kU,"warnLink");function c3(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(c3,"allocateSupportingFileNames");function CU(t,e,r){return t.find(n=>n.entityKind===e&&n.entityName===r)}s(CU,"findEntity");async function m3(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(m3,"buildSupportingFiles");async function p3(t,e,r,n){let o=r.resolved.filter(p=>p.classification==="resolvable-outside"),i=c3(o),a=await m3(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(...l3(e.body,p.link.raw,f));}else kU(n,r,p);let m=_j(e.body,l);return {...e,body:m,supportingFiles:a}}s(p3,"applySkillDecision");async function EU(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)?CU(r.brokenLinks,"skill",l.name):void 0;a.push(c?await p3(e,l,c,o):l);}for(let l of n){if(l.entityKind==="skill"&&l.action==="include-resolvable")continue;let c=CU(r.brokenLinks,l.entityKind,l.entityName);if(c)for(let m of c.resolved)kU(o,c,m);}return {...r,skills:a}}s(EU,"applyBrokenLinkDecisions");var Mc=class extends Error{static{s(this,"InstallAbortError");}aborted=true;constructor(e){super(e),this.name="InstallAbortError";}};function d3(){return {ask:s(t=>vc(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(d3,"defaultAdapter");function f3(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=>ie(e))}}s(f3,"bulkCandidatesFrom");function LU(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(ie(a))),mcp:null,permissions:null,hooks:null,ignore:[]}}s(LU,"filterCanonical");function g3(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(g3,"discoveredFeaturesOf");async function h3(t){let e=t.adapter??d3(),r=await yU(t.aggregate.brokenLinks,{bypass:t.bypass},e);if(r.aborted)throw new Mc("User aborted at broken-link prompt.");let n=[...r.decisions],o=await EU({contentRoot:t.contentRoot,aggregate:t.aggregate,decisions:n,logger:y}),i=f3(o);if(i.skills.length+i.agents.length+i.commands.length+i.rules.length===0)return {aggregate:o,narrowed:LU(o,{skills:[],agents:[],commands:[],rules:[]}),discoveredFeatures:[]};let l=await IU(i,{packName:t.displayName,bypass:t.bypass},e);if(l.aborted)throw new Mc("User aborted at bulk-select prompt.");let c=LU(o,l);return {aggregate:o,narrowed:c,discoveredFeatures:g3(c)}}s(h3,"runSkillPackPromptFlow");function y3(t){return basename(t)||"install source"}s(y3,"displayNameForContentRoot");async function OU(t){if(!t.discovery.aggregate)return {aborted:false};try{let e=await h3({contentRoot:t.contentRoot,aggregate:t.discovery.aggregate,narrowed:t.discovery.narrowed,bypass:t.bypass,displayName:y3(t.contentRoot)});return {aborted:!1,narrowed:e.narrowed,discoveredFeatures:e.discoveredFeatures}}catch(e){if(e instanceof Mc)return y.warn(e.message),{aborted:true};throw e}}s(OU,"runPromptFlowWithAbort");async function wU(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:S,nameOverride:C,acceptHooks:R,acceptPermissions:k,acceptMcp:b,scope:N,sourceArg:x,replay:B}=t,H=process.stdin.isTTY,{prep:tt,implicitPick:it}=e,{narrowed:v,discoveredFeatures:q}=e;try{let vt=await OU({discovery:e,contentRoot:c,bypass:f||u||!H});if(vt.aborted)return {exitCode:130,data:{source:x,mode:"install",installed:[],skipped:[],dryRun:u}};if(v=vt.narrowed??v,q=vt.discoveredFeatures??q,q.length===0&&r.brokenResources.length>0){let bt=r.brokenResources.map(Ft=>` - ${Ft.path}: ${Ft.reason}`).join(`
357
399
  `);throw new Error(`No installable resources after skipping invalid files (${r.brokenResources.length}):
358
400
  ${bt}
359
- 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 ae=await Wj({scope:N,force:f,dryRun:u,tty:H,useExtends:g,forceFreshMaterialize:h,nameOverride:k,explicitAs:R,acceptHooks:I,acceptPermissions:C,acceptMcp:b,config:m,context:p,parsed:o,sourceForYaml:i,version:a,pathInRepo:l,contentRoot:c,persisted:n,replay:B,prep:tt,implicitPick:it,narrowed:v,discoveredFeatures:q,sourceType:e.layout?rj(e.layout):void 0});return {exitCode:0,data:{source:T,mode:"install",installed:ae.installed,skipped:ae.skipped,dryRun:u,...r.brokenResources.length>0?{brokenResources:r.brokenResources}:{}}}}finally{tt.cleanup&&await tt.cleanup();}}s(nU,"runSinglePackInstall");async function oU(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(oU,"runInstallMarketplace");async function sU(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 oU(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(sU,"routePickerResult");Zt();A();ot();async function P3(t){let e=await De(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(P3,"syncInstalledPacks");async function iU(t){return t.sync?(await P3({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(iU,"maybeRunInstallSync");async function aU(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 iU({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(aU,"handleSync");function lU(){return {brokenResources:[],subPackFailures:[]}}s(lU,"createInstallReport");function D3(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(D3,"assertPathStaysInRepo");async function cU(t){let e=await aU(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,acceptHooks:g,acceptPermissions:h,acceptMcp:R,scope:k,sourceArg:I}=t;if(!I)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let C=process.stdin.isTTY;if(!C&&!i&&!o)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:b,context:N}=await yt(r,k);await Ut(b,r);let T=await vI(I,N.configDir,m);if(T.kind!=="local"&&!await sG())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:B,sourceForYaml:H,version:tt}=await aG(T,I),it=T.pathInRepo.replaceAll("\\","/").replace(/^\/+|\/+$/g,"");D3(it,T.pathInRepo);let v=it?join(B,it):B;if(!await j(v))throw new Error(`Install path does not exist: ${v}`);let q=await cj({as:u,contentRoot:v,pathInRepo:it}),vt=lU(),ae={onParseError:s((Ft,Qt)=>{vt.brokenResources.push({path:Qt,kind:"frontmatter",reason:Ft.message});},"onParseError")},bt=await nj({resolvedPath:B,contentRoot:v,pathInRepo:it,explicitTarget:p,explicitAs:u,replayPick:n?.pick,parseOpts:ae});if(bt.layout&&!u&&!p&&!m){let Ft=aj({layout:bt.layout,sourceName:f||(T.org&&T.repo?`${T.org}-${T.repo}`:"source"),sourceForYaml:H,explicitPath:m,explicitAs:u,explicitTarget:p,all:l,force:i,tty:C}),Qt=await sU({pickerResult:Ft,installReport:vt,sourceArg:I,projectRoot:r,dryRun:o,force:i,useExtends:a,nameOverride:f,replay:n,recurseInstall:t.recurseInstall});if(Qt!==null)return Qt}return nU({discovery:bt,installReport:vt,persisted:q,parsed:T,sourceForYaml:H,version:tt,pathInRepo:it,contentRoot:v,config:b,context:N,dryRun:o,force:i,useExtends:a,forceFreshMaterialize:c,explicitAs:u,nameOverride:f,acceptHooks:g,acceptPermissions:h,acceptMcp:R,scope:k,sourceArg:I,replay:n})}s(cU,"runInstallLocked");async function Ua(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,acceptHooks:h,acceptPermissions:R,acceptMcp:k}=oG(t),I=t.global===true?"global":"project",C=e[0]?.trim(),b;if(n===void 0){let{context:N}=await yt(r,I);b=await Ec(N.canonicalDir);}try{return await cU({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,acceptHooks:h,acceptPermissions:R,acceptMcp:k,scope:I,sourceArg:C,recurseInstall:Ua})}finally{await b?.();}}s(Ua,"runInstall");async function mU(t,e,r){return Ua(t,e,r)}s(mU,"runInstall");ot();function pU(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(pU,"renderInstall");Zt();Mr();ot();function uU(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(uU,"detectDuplicates");function ng(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(ng,"buildPlan");function dU(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=uU(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=>ng(m.name,m,t,e));for(let m of t.extends)r.has(m.name)||c.push(ng(m.name,null,t,e));return {removals:c,skipped:[]}}let n=uU(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(ng(a,l,t,e));continue}if(e.has(a)){o.push(ng(a,null,t,e));continue}i.push(a);}return {removals:o,skipped:i}}s(dU,"planUninstall");A();A();yc();async function fU(t,e){let r=join(t,tr);if(await j(r))return null;let n=await yi(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 tg(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)}
360
- `),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(fU,"migrateLegacyManifest");A();var M3=["pack.yaml",tr];function $3(t,e){return relative(t,e).replaceAll("\\","/")}s($3,"toForwardSlashRelative");async function og(t,e){let r=await Es(t),n=new Map;for(let i of r){let a=$3(t,i);M3.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 Lf(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(og,"detectModifiedFiles");function gU(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(`
401
+ 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 ae=await fU({scope:N,force:f,dryRun:u,tty:H,useExtends:g,forceFreshMaterialize:h,nameOverride:C,explicitAs:S,acceptHooks:R,acceptPermissions:k,acceptMcp:b,config:m,context:p,parsed:o,sourceForYaml:i,version:a,pathInRepo:l,contentRoot:c,persisted:n,replay:B,prep:tt,implicitPick:it,narrowed:v,discoveredFeatures:q,sourceType:e.layout?Oj(e.layout):void 0});return {exitCode:0,data:{source:x,mode:"install",installed:ae.installed,skipped:ae.skipped,dryRun:u,...r.brokenResources.length>0?{brokenResources:r.brokenResources}:{}}}}finally{tt.cleanup&&await tt.cleanup();}}s(wU,"runSinglePackInstall");async function AU(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(AU,"runInstallMarketplace");async function bU(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 AU(e.targets,async f=>(await p({force:!0,"dry-run":i,path:f.path??"",as:f.as??"",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}:{},...r.subPackFailures.length>0?{subPackFailures:r.subPackFailures}:{}}}}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(bU,"routePickerResult");Zt();A();ot();async function R3(t){let e=await Ne(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(R3,"syncInstalledPacks");async function PU(t){return t.sync?(await R3({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(PU,"maybeRunInstallSync");async function xU(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 PU({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(xU,"handleSync");function TU(){return {brokenResources:[],subPackFailures:[]}}s(TU,"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 DU(t){let e=await xU(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,acceptHooks:g,acceptPermissions:h,acceptMcp:S,scope:C,sourceArg:R}=t;if(!R)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let k=process.stdin.isTTY;if(!k&&!i&&!o)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:b,context:N}=await yt(r,C);await Ut(b,r);let x=await ZS(R,N.configDir,m);if(x.kind!=="local"&&!await bG())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:B,sourceForYaml:H,version:tt}=await xG(x,R),it=x.pathInRepo.replaceAll("\\","/").replace(/^\/+|\/+$/g,"");C3(it,x.pathInRepo);let v=it?join(B,it):B;if(!await j(v))throw new Error(`Install path does not exist: ${v}`);let q=await Dj({as:u,contentRoot:v,pathInRepo:it}),vt=TU(),ae={onParseError:s((Ft,Qt)=>{vt.brokenResources.push({path:Qt,kind:"frontmatter",reason:Ft.message});},"onParseError")},bt=await wj({resolvedPath:B,contentRoot:v,pathInRepo:it,explicitTarget:p,explicitAs:u,replayPick:n?.pick,parseOpts:ae});if(bt.layout&&!u&&!p&&!m){let Ft=xj({layout:bt.layout,sourceName:f||(x.org&&x.repo?`${x.org}-${x.repo}`:"source"),sourceForYaml:H,explicitPath:m,explicitAs:u,explicitTarget:p,all:l,force:i,tty:k}),Qt=await bU({pickerResult:Ft,installReport:vt,sourceArg:R,projectRoot:r,dryRun:o,force:i,useExtends:a,nameOverride:f,replay:n,recurseInstall:t.recurseInstall});if(Qt!==null)return Qt}return wU({discovery:bt,installReport:vt,persisted:q,parsed:x,sourceForYaml:H,version:tt,pathInRepo:it,contentRoot:v,config:b,context:N,dryRun:o,force:i,useExtends:a,forceFreshMaterialize:c,explicitAs:u,nameOverride:f,acceptHooks:g,acceptPermissions:h,acceptMcp:S,scope:C,sourceArg:R,replay:n})}s(DU,"runInstallLocked");async function Wa(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,acceptHooks:h,acceptPermissions:S,acceptMcp:C}=AG(t),R=t.global===true?"global":"project",k=e[0]?.trim(),b;if(n===void 0){let{context:N}=await yt(r,R);b=await Ac(N.canonicalDir);}try{return await DU({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,acceptHooks:h,acceptPermissions:S,acceptMcp:C,scope:R,sourceArg:k,recurseInstall:Wa})}finally{await b?.();}}s(Wa,"runInstall");async function NU(t,e,r){return Wa(t,e,r)}s(NU,"runInstall");ot();function FU(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.`);}if(e.subPackFailures&&e.subPackFailures.length>0)for(let r of e.subPackFailures)y.warn(`Sub-pack "${r.name}" (${r.path}) failed: ${r.error}`);}}s(FU,"renderInstall");Zt();$r();ot();function vU(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(vU,"detectDuplicates");function fg(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(fg,"buildPlan");function MU(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=vU(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=>fg(m.name,m,t,e));for(let m of t.extends)r.has(m.name)||c.push(fg(m.name,null,t,e));return {removals:c,skipped:[]}}let n=vU(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(fg(a,l,t,e));continue}if(e.has(a)){o.push(fg(a,null,t,e));continue}i.push(a);}return {removals:o,skipped:i}}s(MU,"planUninstall");A();A();Sc();async function $U(t,e){let r=join(t,er);if(await j(r))return null;let n=await Ri(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 pg(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)}
402
+ `),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($U,"migrateLegacyManifest");A();var O3=["pack.yaml",er];function w3(t,e){return relative(t,e).replaceAll("\\","/")}s(w3,"toForwardSlashRelative");async function gg(t,e){let r=await Os(t),n=new Map;for(let i of r){let a=w3(t,i);O3.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 Tf(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(gg,"detectModifiedFiles");function GU(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(`
361
403
  `)}
362
- `);}s(gU,"writeBanner");async function hU(t,e,r){if(t.modifications.length===0)return {action:"proceed"};if(e.bypass)return gU(r,t),{action:"delete-anyway"};gU(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(hU,"runModifiedFilesPrompt");async function G3(t){let e=await _(join(t,tr));if(e===null)return null;try{return JSON.parse(e).files??{}}catch{return null}}s(G3,"readManifestFiles");async function j3(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 fU(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 og(n,a);if(r.keepPack||l.length===0)return {plan:t,modifications:l,action:"proceed",legacyMigrated:i,packDirMissing:false};let c=await hU({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(j3,"decideOne");async function _U(t,e,r){let n=[];for(let o of t){let i=await j3(o,e,r);if(i==="abort")return {decisions:n,aborted:true};n.push(i);}return {decisions:n,aborted:false}}s(_U,"gatherUninstallDecisions");A();A();async function RU(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(`
404
+ `);}s(GU,"writeBanner");async function jU(t,e,r){if(t.modifications.length===0)return {action:"proceed"};if(e.bypass)return GU(r,t),{action:"delete-anyway"};GU(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(jU,"runModifiedFilesPrompt");async function A3(t){let e=await _(join(t,er));if(e===null)return null;try{return JSON.parse(e).files??{}}catch{return null}}s(A3,"readManifestFiles");async function b3(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 $U(n,{warn:r.warn,dryRun:r.dryRun===true}),i=o!==null,a=o!==null&&r.dryRun===true?o.manifest.files:await A3(n);if(a===null)return {plan:t,modifications:[],action:"proceed",legacyMigrated:i,packDirMissing:false};let l=await gg(n,a);if(r.keepPack||l.length===0)return {plan:t,modifications:l,action:"proceed",legacyMigrated:i,packDirMissing:false};let c=await jU({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(b3,"decideOne");async function BU(t,e,r){let n=[];for(let o of t){let i=await b3(o,e,r);if(i==="abort")return {decisions:n,aborted:true};n.push(i);}return {decisions:n,aborted:false}}s(BU,"gatherUninstallDecisions");A();A();async function KU(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(`
363
405
  `)?l:`${l}
364
- `),true}s(RU,"removeAgentsmeshExtendByName");async function IU(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 Mj(r,e.name),l=false;e.extendsEntry!==null&&(l=await RU(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(IU,"applyUninstall");function z3(t,e){return relative(t,e).replaceAll("\\","/")}s(z3,"toForwardSlashRel");function rS(t){return t.map(e=>({name:e,reason:"not found in installs.yaml"}))}s(rS,"buildSkipped");function SU(t,e,r){return t.plan.manifestEntry===null?null:z3(e,join(r,t.plan.name))}s(SU,"packPathFor");function CU(t,e,r){return t.map(n=>({name:n.plan.name,pack_path:SU(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(CU,"previewEntries");function kU(t,e,r,n){let o=t.action==="keep-modified"||!e.packDirRemoved;return {name:e.name,pack_path:SU(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(kU,"appliedEntry");function V3(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(V3,"parseNames");function J3(){return {ask:s(t=>xc(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(J3,"defaultAdapter");async function sg(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=V3(e),f=t.json===true;function g(I){return f||y.error(I),{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 Ut(h,r);let k=await Ec(R.canonicalDir);try{let I=await De(R.canonicalDir),C=join(R.canonicalDir,"packs"),b=dU({names:u,all:i,keepPack:c,keepGenerated:m,installs:I,extends:h.extends,packsDir:C}),{decisions:N,aborted:T}=await _U(b.removals,C,{adapter:n.promptAdapter??J3(),warn:s(it=>y.warn(it),"warn"),bypassPrompts:a||l||!p,keepPack:c,dryRun:l});if(T)return y.warn("Uninstall aborted at modification prompt."),{exitCode:130,data:{scope:o,mode:"uninstall",removed:[],skipped:[],failed:[],dryRun:l}};for(let it of b.removals)for(let v of it.warnings)y.warn(v);if(l){for(let it of N)y.info(`[dry-run] Would uninstall pack "${it.plan.name}".`);return {exitCode:0,data:{scope:o,mode:"uninstall",removed:CU(N,R.rootBase,C),skipped:rS(b.skipped),failed:[],dryRun:!0}}}let B=join(R.configDir,"agentsmesh.yaml"),H=[],tt=[];for(let it of N){let v=it.action==="keep-modified"?{...it.plan,packDir:null}:it.plan;try{let q=await IU({plan:v,canonicalDir:R.canonicalDir,configPath:B,config:h});H.push(kU(it,q,R.rootBase,C));}catch(q){let vt=q instanceof Error?q.message:String(q);tt.push({name:it.plan.name,reason:vt}),f||y.error(`Failed to uninstall "${it.plan.name}": ${vt}`);}}return !m&&H.length>0?await bc("uninstall",o,R.rootBase):m&&H.length>0&&y.warn("--keep-generated: target files derived from the removed pack(s) may be stale until the next generate."),{exitCode:tt.length>0?1:0,data:{scope:o,mode:"uninstall",removed:H,skipped:rS(b.skipped),failed:tt,dryRun:!1}}}finally{await k();}}s(sg,"runUninstall");async function LU(t,e,r){return sg(t,e,r)}s(LU,"runUninstall");ot();function OU(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(OU,"renderUninstall");Zt();Mr();ot();function wU(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(wU,"readRefreshFlags");function AU(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(AU,"parseRefreshNames");A();function Y3(t){return t.modifications.length>0?"needs-consent":t.oldSha===t.newSha?"unchanged":"clean-update"}s(Y3,"classifyRefreshPlan");async function PU(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 og(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:Y3({modifications:c,oldSha:o,newSha:m})}}s(PU,"planSinglePack");function TU(){return async t=>{if(t.source_kind==="local")return t.version??"local";let e=Op(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 Hf(r,e.remoteUrl)}}s(TU,"createDefaultResolveRef");async function xU(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 De(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 rg(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(xU,"applySinglePack");async function X3(t,e,r={}){let n=r.readLine??xc,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":Z3(a)}finally{o&&clearTimeout(o);}}s(X3,"promptWithTimeout");function Z3(t){let e=t.trim().toLowerCase();return e==="y"||e==="yes"?"y":e==="per-pack"?"per-pack":"n"}s(Z3,"normalize");async function nS(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(`
365
- `);switch(await X3(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(nS,"runConsentPrompt");function Q3(t,e){let r=Op(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(Q3,"buildSourceForRefresh");function DU(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=Q3(e,r),a=await Ua(n,[i],t.projectRoot,o);if(a.exitCode!==0)throw new Error(`Install for refresh "${e.name}" failed with exit code ${a.exitCode}`)}}s(DU,"createRunInstallForRefresh");var NU=300*1e3;async function ig(t,e,r){let{dryRun:n,force:o,global:i,json:a}=wU(t),l=i?"global":"project",c=AU(e),m=s(()=>({scope:l,mode:"refresh",refreshed:[],unchanged:[],skipped:[],failed:[],dryRun:n}),"emptyData"),{config:p,context:u}=await yt(r,l);await Ut(p,r);let f=await Ec(u.canonicalDir);try{let g=await De(u.canonicalDir);if(c.length>0){let v=new Set(g.map(vt=>vt.name)),q=c.filter(vt=>!v.has(vt));if(q.length>0)return a||y.error(`Unknown pack(s): ${q.join(", ")}`),{exitCode:2,data:m()}}let h=c.length>0?g.filter(v=>c.includes(v.name)):g;if(h.length===0)return a||y.info("No packs to refresh."),{exitCode:0,data:m()};let R=join(u.canonicalDir,"packs"),k=TU(),I=[];for(let v of h)I.push(await PU(v,R,{resolveRef:k}));let C=I.filter(v=>v.classification==="error"),b=I.filter(v=>v.classification==="unchanged"),N=I.filter(v=>v.classification==="clean-update"),T=I.filter(v=>v.classification==="needs-consent"),B=m();if(B.unchanged=b.map(v=>({name:v.name,ref:v.newSha})),B.failed=C.map(v=>({name:v.name,phase:"plan",error:v.error?.message??"unknown plan error"})),n){for(let v of N)B.refreshed.push({name:v.name,oldRef:v.oldSha,newRef:v.newSha,oldSha:v.oldSha,newSha:v.newSha,changedFiles:{added:[],removed:[],modified:[]}});for(let v of T)B.refreshed.push({name:v.name,oldRef:v.oldSha,newRef:v.newSha,oldSha:v.oldSha,newSha:v.newSha,changedFiles:{added:[],removed:[],modified:[]}});return {exitCode:C.length>0?1:0,data:B}}let H=new Set(N.map(v=>v.name));if(T.length>0)if(o)for(let v of T)H.add(v.name);else {let v=await nS(T.map(q=>({name:q.name,modifiedCount:q.modifications.length})),{timeoutMs:NU});if(v.proceed&&!v.perPack)for(let q of T)H.add(q.name);else if(v.proceed&&v.perPack)for(let q of T)(await nS([{name:q.name,modifiedCount:q.modifications.length}],{timeoutMs:NU})).proceed?H.add(q.name):B.skipped.push({name:q.name,reason:"user-declined"});else for(let q of v.declined)B.skipped.push({name:q,reason:"user-declined"});}let tt=DU({projectRoot:r,scope:l});for(let v of [...N,...T]){if(!H.has(v.name))continue;let q=await xU(v,u.canonicalDir,{runInstallForRefresh:tt});q.success?B.refreshed.push({name:v.name,oldRef:v.oldSha,newRef:v.newSha,oldSha:v.oldSha,newSha:v.newSha,changedFiles:{added:[],removed:[],modified:[]}}):B.failed.push({name:v.name,phase:q.phase??"apply",error:q.error??"unknown"});}return B.refreshed.length>0&&await bc("refresh",l,u.rootBase),{exitCode:B.failed.length>0?1:0,data:B}}finally{await f();}}s(ig,"runRefresh");async function FU(t,e,r){return ig(t,e,r)}s(FU,"runRefresh");ot();function vU(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(vU,"renderRefresh");Zt();A();yc();async function e8(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(e8,"readPackManifestMeta");function r8(t,e){return relative(t,e).replaceAll("\\","/")}s(r8,"toForwardSlashRel");async function ag(t,e){let r=t.global===true?"global":"project",n=Ai(e,r),o=await De(n.canonicalDir),i=join(n.canonicalDir,"packs"),a=[];for(let l of o){let c=join(i,l.name),m=await e8(c),p=await yi(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:r8(n.rootBase,c),license:p?.license??null});}return {exitCode:0,data:{scope:r,subcommand:"list",installs:a}}}s(ag,"runInstallsList");var n8=["list"];function MU(t){return {scope:t,subcommand:"list",installs:[]}}s(MU,"emptyData");async function $U(t,e,r){let n=t.global===true?"global":"project",o=e[0];return o===void 0||o===""?{exitCode:0,data:MU(n),showHelp:true}:o==="list"?ag(t,r):{exitCode:2,data:MU(n),showHelp:true,error:`Unknown installs subcommand: "${o}". Available: ${n8.join(", ")}. Did you mean \`agentsmesh install ${o}\`?`}}s($U,"runInstalls");ot();var lg=[{key:"name",label:"NAME"},{key:"source",label:"SOURCE"},{key:"features",label:"FEATURES"},{key:"license",label:"LICENSE"},{key:"installed",label:"LAST TOUCHED"}];function o8(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(o8,"toRow");function s8(t){let e={name:0,source:0,features:0,license:0,installed:0};for(let n of lg)e[n.key]=n.label.length;for(let n of t)for(let o of lg)e[o.key]=Math.max(e[o.key],n[o.key].length);let r=lg.map(n=>n.label.padEnd(e[n.key])).join(" ");y.info(r);for(let n of t)y.info(lg.map(o=>n[o.key].padEnd(e[o.key])).join(" "));}s(s8,"renderTable");function GU(t){if(t.error&&y.error(t.error),t.showHelp){Up("installs");return}let{data:e}=t;if(e.installs.length===0){y.info("No installed packs.");return}s8(e.installs.map(o8));}s(GU,"renderInstalls");lI();A();var aS="agentsmesh.yaml";async function lS(t){let e=join(t,aS),r=await _(e);return r===null?{}:parse(r)??{}}s(lS,"readScopedConfigRaw");async function UU(t,e){let r=join(t,aS),n=await _(r)??`version: 1
366
- `,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(UU,"writePluginEntry");async function BU(t,e){let r=join(t,aS),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(BU,"removePluginEntry");async function KU(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 i8(t,e.slice(1),r);case "list":return a8(r);case "remove":return l8(e.slice(1),r);case "info":return c8(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${n}`}}}s(KU,"runPlugin");async function i8(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)??m8(n);return await UU(r,{id:a,source:n,version:o==="latest"?void 0:o}),{exitCode:0,data:{subcommand:"add",id:a,package:n,version:o}}}s(i8,"runPluginAdd");async function a8(t){let r=(await lS(t)).plugins??[],n=[];for(let o of r){let i="\u2717",a="";try{let l=await Nf(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(a8,"runPluginList");async function l8(t,e){let r=t[0];if(!r)throw new Rn("Usage: agentsmesh plugin remove <id>");let n=await BU(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:n}}}s(l8,"runPluginRemove");async function c8(t,e){let r=t[0];if(!r)throw new Rn("Usage: agentsmesh plugin info <id>");let o=((await lS(e)).plugins??[]).find(l=>l.id===r);if(!o)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await Nf(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(c8,"runPluginInfo");function m8(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(m8,"derivePluginId");ot();function WU(t){if(t.error&&y.error(t.error),t.showHelp){g8();return}let{data:e}=t;switch(e.subcommand){case "add":p8(e.id,e.package,e.version);break;case "list":u8(e.plugins);break;case "remove":d8(e.id,e.found);break;case "info":f8(e,t.exitCode);break}}s(WU,"renderPlugin");function p8(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(p8,"renderAdd");function u8(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(u8,"renderList");function d8(t,e){e?y.success(`Plugin '${t}' removed from agentsmesh.yaml`):y.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s(d8,"renderRemove");function f8(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(f8,"renderInfo");function g8(){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(g8,"printPluginHelp");A();Sn();function Ii(t){return t.toUpperCase().replace(/-/g,"_")}s(Ii,"toPrefix");function Ss(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(Ss,"toPascal");function cS(t){let e=Ii(t.id),r=Ss(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
406
+ `),true}s(KU,"removeAgentsmeshExtendByName");async function WU(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 aU(r,e.name),l=false;e.extendsEntry!==null&&(l=await KU(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(WU,"applyUninstall");function F3(t,e){return relative(t,e).replaceAll("\\","/")}s(F3,"toForwardSlashRel");function yI(t){return t.map(e=>({name:e,reason:"not found in installs.yaml"}))}s(yI,"buildSkipped");function HU(t,e,r){return t.plan.manifestEntry===null?null:F3(e,join(r,t.plan.name))}s(HU,"packPathFor");function zU(t,e,r){return t.map(n=>({name:n.plan.name,pack_path:HU(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(zU,"previewEntries");function VU(t,e,r,n){let o=t.action==="keep-modified"||!e.packDirRemoved;return {name:e.name,pack_path:HU(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(VU,"appliedEntry");function v3(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(v3,"parseNames");function M3(){return {ask:s(t=>vc(t),"ask"),write:s(t=>process.stdout.write(t),"write")}}s(M3,"defaultAdapter");async function hg(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=v3(e),f=t.json===true;function g(R){return f||y.error(R),{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:S}=await yt(r,o);await Ut(h,r);let C=await Ac(S.canonicalDir);try{let R=await Ne(S.canonicalDir),k=join(S.canonicalDir,"packs"),b=MU({names:u,all:i,keepPack:c,keepGenerated:m,installs:R,extends:h.extends,packsDir:k}),{decisions:N,aborted:x}=await BU(b.removals,k,{adapter:n.promptAdapter??M3(),warn:s(it=>y.warn(it),"warn"),bypassPrompts:a||l||!p,keepPack:c,dryRun:l});if(x)return y.warn("Uninstall aborted at modification prompt."),{exitCode:130,data:{scope:o,mode:"uninstall",removed:[],skipped:[],failed:[],dryRun:l}};for(let it of b.removals)for(let v of it.warnings)y.warn(v);if(l){for(let it of N)y.info(`[dry-run] Would uninstall pack "${it.plan.name}".`);return {exitCode:0,data:{scope:o,mode:"uninstall",removed:zU(N,S.rootBase,k),skipped:yI(b.skipped),failed:[],dryRun:!0}}}let B=join(S.configDir,"agentsmesh.yaml"),H=[],tt=[];for(let it of N){let v=it.action==="keep-modified"?{...it.plan,packDir:null}:it.plan;try{let q=await WU({plan:v,canonicalDir:S.canonicalDir,configPath:B,config:h});H.push(VU(it,q,S.rootBase,k));}catch(q){let vt=q instanceof Error?q.message:String(q);tt.push({name:it.plan.name,reason:vt}),f||y.error(`Failed to uninstall "${it.plan.name}": ${vt}`);}}return !m&&H.length>0?await Dc("uninstall",o,S.rootBase):m&&H.length>0&&y.warn("--keep-generated: target files derived from the removed pack(s) may be stale until the next generate."),{exitCode:tt.length>0?1:0,data:{scope:o,mode:"uninstall",removed:H,skipped:yI(b.skipped),failed:tt,dryRun:!1}}}finally{await C();}}s(hg,"runUninstall");async function YU(t,e,r){return hg(t,e,r)}s(YU,"runUninstall");ot();function XU(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(XU,"renderUninstall");Zt();$r();ot();function ZU(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(ZU,"readRefreshFlags");function QU(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(QU,"parseRefreshNames");A();function $3(t){return t.modifications.length>0?"needs-consent":t.oldSha===t.newSha?"unchanged":"clean-update"}s($3,"classifyRefreshPlan");async function t0(t,e,r){let n=join(e,t.name),o=t.version??null,i=join(n,er),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 gg(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:$3({modifications:c,oldSha:o,newSha:m})}}s(t0,"planSinglePack");function e0(){return async t=>{if(t.source_kind==="local")return t.version??"local";let e=Tp(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 rg(r,e.remoteUrl)}}s(e0,"createDefaultResolveRef");async function r0(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 Ne(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 dg(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(r0,"applySinglePack");async function G3(t,e,r={}){let n=r.readLine??vc,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":j3(a)}finally{o&&clearTimeout(o);}}s(G3,"promptWithTimeout");function j3(t){let e=t.trim().toLowerCase();return e==="y"||e==="yes"?"y":e==="per-pack"?"per-pack":"n"}s(j3,"normalize");async function _I(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(`
407
+ `);switch(await G3(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(_I,"runConsentPrompt");function U3(t,e){let r=Tp(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(U3,"buildSourceForRefresh");function n0(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=U3(e,r),a=await Wa(n,[i],t.projectRoot,o);if(a.exitCode!==0)throw new Error(`Install for refresh "${e.name}" failed with exit code ${a.exitCode}`)}}s(n0,"createRunInstallForRefresh");var o0=300*1e3;async function yg(t,e,r){let{dryRun:n,force:o,global:i,json:a}=ZU(t),l=i?"global":"project",c=QU(e),m=s(()=>({scope:l,mode:"refresh",refreshed:[],unchanged:[],skipped:[],failed:[],dryRun:n}),"emptyData"),{config:p,context:u}=await yt(r,l);await Ut(p,r);let f=await Ac(u.canonicalDir);try{let g=await Ne(u.canonicalDir);if(c.length>0){let v=new Set(g.map(vt=>vt.name)),q=c.filter(vt=>!v.has(vt));if(q.length>0)return a||y.error(`Unknown pack(s): ${q.join(", ")}`),{exitCode:2,data:m()}}let h=c.length>0?g.filter(v=>c.includes(v.name)):g;if(h.length===0)return a||y.info("No packs to refresh."),{exitCode:0,data:m()};let S=join(u.canonicalDir,"packs"),C=e0(),R=[];for(let v of h)R.push(await t0(v,S,{resolveRef:C}));let k=R.filter(v=>v.classification==="error"),b=R.filter(v=>v.classification==="unchanged"),N=R.filter(v=>v.classification==="clean-update"),x=R.filter(v=>v.classification==="needs-consent"),B=m();if(B.unchanged=b.map(v=>({name:v.name,ref:v.newSha})),B.failed=k.map(v=>({name:v.name,phase:"plan",error:v.error?.message??"unknown plan error"})),n){for(let v of N)B.refreshed.push({name:v.name,oldRef:v.oldSha,newRef:v.newSha,oldSha:v.oldSha,newSha:v.newSha,changedFiles:{added:[],removed:[],modified:[]}});for(let v of x)B.refreshed.push({name:v.name,oldRef:v.oldSha,newRef:v.newSha,oldSha:v.oldSha,newSha:v.newSha,changedFiles:{added:[],removed:[],modified:[]}});return {exitCode:k.length>0?1:0,data:B}}let H=new Set(N.map(v=>v.name));if(x.length>0)if(o)for(let v of x)H.add(v.name);else {let v=await _I(x.map(q=>({name:q.name,modifiedCount:q.modifications.length})),{timeoutMs:o0});if(v.proceed&&!v.perPack)for(let q of x)H.add(q.name);else if(v.proceed&&v.perPack)for(let q of x)(await _I([{name:q.name,modifiedCount:q.modifications.length}],{timeoutMs:o0})).proceed?H.add(q.name):B.skipped.push({name:q.name,reason:"user-declined"});else for(let q of v.declined)B.skipped.push({name:q,reason:"user-declined"});}let tt=n0({projectRoot:r,scope:l});for(let v of [...N,...x]){if(!H.has(v.name))continue;let q=await r0(v,u.canonicalDir,{runInstallForRefresh:tt});q.success?B.refreshed.push({name:v.name,oldRef:v.oldSha,newRef:v.newSha,oldSha:v.oldSha,newSha:v.newSha,changedFiles:{added:[],removed:[],modified:[]}}):B.failed.push({name:v.name,phase:q.phase??"apply",error:q.error??"unknown"});}return B.refreshed.length>0&&await Dc("refresh",l,u.rootBase),{exitCode:B.failed.length>0?1:0,data:B}}finally{await f();}}s(yg,"runRefresh");async function s0(t,e,r){return yg(t,e,r)}s(s0,"runRefresh");ot();function i0(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(i0,"renderRefresh");Zt();A();Sc();async function W3(t){let e=await _(join(t,er));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(W3,"readPackManifestMeta");function H3(t,e){return relative(t,e).replaceAll("\\","/")}s(H3,"toForwardSlashRel");async function _g(t,e){let r=t.global===true?"global":"project",n=Pi(e,r),o=await Ne(n.canonicalDir),i=join(n.canonicalDir,"packs"),a=[];for(let l of o){let c=join(i,l.name),m=await W3(c),p=await Ri(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:H3(n.rootBase,c),license:p?.license??null});}return {exitCode:0,data:{scope:r,subcommand:"list",installs:a}}}s(_g,"runInstallsList");var z3=["list"];function a0(t){return {scope:t,subcommand:"list",installs:[]}}s(a0,"emptyData");async function l0(t,e,r){let n=t.global===true?"global":"project",o=e[0];return o===void 0||o===""?{exitCode:0,data:a0(n),showHelp:true}:o==="list"?_g(t,r):{exitCode:2,data:a0(n),showHelp:true,error:`Unknown installs subcommand: "${o}". Available: ${z3.join(", ")}. Did you mean \`agentsmesh install ${o}\`?`}}s(l0,"runInstalls");ot();var Rg=[{key:"name",label:"NAME"},{key:"source",label:"SOURCE"},{key:"features",label:"FEATURES"},{key:"license",label:"LICENSE"},{key:"installed",label:"LAST TOUCHED"}];function V3(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(V3,"toRow");function J3(t){let e={name:0,source:0,features:0,license:0,installed:0};for(let n of Rg)e[n.key]=n.label.length;for(let n of t)for(let o of Rg)e[o.key]=Math.max(e[o.key],n[o.key].length);let r=Rg.map(n=>n.label.padEnd(e[n.key])).join(" ");y.info(r);for(let n of t)y.info(Rg.map(o=>n[o.key].padEnd(e[o.key])).join(" "));}s(J3,"renderTable");function c0(t){if(t.error&&y.error(t.error),t.showHelp){Jp("installs");return}let{data:e}=t;if(e.installs.length===0){y.info("No installed packs.");return}J3(e.installs.map(V3));}s(c0,"renderInstalls");RS();A();var CI="agentsmesh.yaml";async function kI(t){let e=join(t,CI),r=await _(e);return r===null?{}:parse(r)??{}}s(kI,"readScopedConfigRaw");async function p0(t,e){let r=join(t,CI),n=await _(r)??`version: 1
408
+ `,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(p0,"writePluginEntry");async function u0(t,e){let r=join(t,CI),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(u0,"removePluginEntry");async function d0(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 Y3(t,e.slice(1),r);case "list":return X3(r);case "remove":return Z3(e.slice(1),r);case "info":return Q3(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${n}`}}}s(d0,"runPlugin");async function Y3(t,e,r){let n=e[0];if(!n)throw new In("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)??q3(n);return await p0(r,{id:a,source:n,version:o==="latest"?void 0:o}),{exitCode:0,data:{subcommand:"add",id:a,package:n,version:o}}}s(Y3,"runPluginAdd");async function X3(t){let r=(await kI(t)).plugins??[],n=[];for(let o of r){let i="\u2717",a="";try{let l=await Uf(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 Z3(t,e){let r=t[0];if(!r)throw new In("Usage: agentsmesh plugin remove <id>");let n=await u0(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:n}}}s(Z3,"runPluginRemove");async function Q3(t,e){let r=t[0];if(!r)throw new In("Usage: agentsmesh plugin info <id>");let o=((await kI(e)).plugins??[]).find(l=>l.id===r);if(!o)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await Uf(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(Q3,"runPluginInfo");function q3(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(q3,"derivePluginId");ot();function f0(t){if(t.error&&y.error(t.error),t.showHelp){o9();return}let{data:e}=t;switch(e.subcommand){case "add":t9(e.id,e.package,e.version);break;case "list":e9(e.plugins);break;case "remove":r9(e.id,e.found);break;case "info":n9(e,t.exitCode);break}}s(f0,"renderPlugin");function t9(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(t9,"renderAdd");function e9(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(e9,"renderList");function r9(t,e){e?y.success(`Plugin '${t}' removed from agentsmesh.yaml`):y.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s(r9,"renderRemove");function n9(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(n9,"renderInfo");function o9(){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(o9,"printPluginHelp");A();kn();function Ci(t){return t.toUpperCase().replace(/-/g,"_")}s(Ci,"toPrefix");function ks(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(ks,"toPascal");function EI(t){let e=Ci(t.id),r=ks(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
367
409
  import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
368
410
  import { generateRules } from './generator.js';
369
411
  import { importFrom${r} } from './importer.js';
@@ -466,7 +508,7 @@ export const descriptor = {
466
508
  buildImportPaths: build${r}ImportPaths,
467
509
  detectionPaths: [${e}_DIR],
468
510
  } satisfies TargetDescriptor;
469
- `}s(cS,"TEMPLATE_INDEX");function mS(t){return `import { describe, it, expect } from 'vitest';
511
+ `}s(EI,"TEMPLATE_INDEX");function LI(t){return `import { describe, it, expect } from 'vitest';
470
512
  import type { CanonicalFiles } from '../../../../src/core/types.js';
471
513
  import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
472
514
 
@@ -495,7 +537,7 @@ describe('generateRules (${t.id})', () => {
495
537
  expect(result).toHaveLength(0);
496
538
  });
497
539
  });
498
- `}s(mS,"TEMPLATE_GENERATOR_TEST");function pS(t){let e=Ss(t.id);return `import { describe, it, expect } from 'vitest';
540
+ `}s(LI,"TEMPLATE_GENERATOR_TEST");function OI(t){let e=ks(t.id);return `import { describe, it, expect } from 'vitest';
499
541
  import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
500
542
 
501
543
  describe('importFrom${e} (${t.id})', () => {
@@ -509,10 +551,10 @@ describe('importFrom${e} (${t.id})', () => {
509
551
  expect(result).toHaveLength(0);
510
552
  });
511
553
  });
512
- `}s(pS,"TEMPLATE_IMPORTER_TEST");function uS(t){return `# ${t.displayName} Workspace
554
+ `}s(OI,"TEMPLATE_IMPORTER_TEST");function wI(t){return `# ${t.displayName} Workspace
513
555
 
514
556
  Follow the ${t.displayName} configuration files and keep changes small.
515
- `}s(uS,"TEMPLATE_FIXTURE_ROOT_MD");function HU(t){let e=Ii(t.id);return `export const ${e}_TARGET = '${t.id}';
557
+ `}s(wI,"TEMPLATE_FIXTURE_ROOT_MD");function g0(t){let e=Ci(t.id);return `export const ${e}_TARGET = '${t.id}';
516
558
 
517
559
  // Project-level paths
518
560
  export const ${e}_DIR = '.${t.id}';
@@ -525,21 +567,21 @@ export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
525
567
  // Canonical paths
526
568
  export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
527
569
  export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
528
- `}s(HU,"TEMPLATE_CONSTANTS");function zU(t){let e=Ii(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
570
+ `}s(g0,"TEMPLATE_CONSTANTS");function h0(t){let e=Ci(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
529
571
  import { ${e}_TARGET, ${e}_DIR } from './constants.js';
530
572
 
531
- export interface ${Ss(t.id)}Output {
573
+ export interface ${ks(t.id)}Output {
532
574
  path: string;
533
575
  content: string;
534
576
  }
535
577
 
536
- export function generateRules(_canonical: CanonicalFiles): ${Ss(t.id)}Output[] {
578
+ export function generateRules(_canonical: CanonicalFiles): ${ks(t.id)}Output[] {
537
579
  // TODO(agentsmesh-scaffold): implement generateRules for ${t.displayName}
538
580
  void ${e}_TARGET;
539
581
  void ${e}_DIR;
540
582
  return [];
541
583
  }
542
- `}s(zU,"TEMPLATE_GENERATOR");function VU(t){let e=Ss(t.id),r=Ii(t.id);return `import type { ImportResult } from '../../core/types.js';
584
+ `}s(h0,"TEMPLATE_GENERATOR");function y0(t){let e=ks(t.id),r=Ci(t.id);return `import type { ImportResult } from '../../core/types.js';
543
585
  import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
544
586
  import { ${r}_TARGET } from './constants.js';
545
587
 
@@ -551,7 +593,7 @@ export async function importFrom${e}(
551
593
  void ${r}_TARGET;
552
594
  return [];
553
595
  }
554
- `}s(VU,"TEMPLATE_IMPORTER");function JU(t){let e=Ii(t.id);return `/** Lint rules for the ${t.id} target. */
596
+ `}s(y0,"TEMPLATE_IMPORTER");function _0(t){let e=Ci(t.id);return `/** Lint rules for the ${t.id} target. */
555
597
  import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
556
598
  import { validateRules } from '../../core/lint/validate-rules.js';
557
599
  import { ${e}_TARGET } from './constants.js';
@@ -569,7 +611,7 @@ export function lintRules(
569
611
  target: ${e}_TARGET,
570
612
  }));
571
613
  }
572
- `}s(JU,"TEMPLATE_LINTER");function YU(t){return `/**
614
+ `}s(_0,"TEMPLATE_LINTER");function R0(t){return `/**
573
615
  * ${t.displayName}-specific lint hooks.
574
616
  */
575
617
 
@@ -579,7 +621,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
579
621
  // TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
580
622
  return [];
581
623
  }
582
- `}s(YU,"TEMPLATE_LINT_HOOKS");function XU(t){let e=Ss(t.id),r=Ii(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
624
+ `}s(R0,"TEMPLATE_LINT_HOOKS");function S0(t){let e=ks(t.id),r=Ci(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
583
625
  import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
584
626
 
585
627
  export async function build${e}ImportPaths(
@@ -591,14 +633,14 @@ export async function build${e}ImportPaths(
591
633
  // Reference: src/core/reference/import-maps/kiro.ts for a full example
592
634
  void ${r}_DIR;
593
635
  }
594
- `}s(XU,"TEMPLATE_IMPORT_MAP");var y8=/^[a-z][a-z0-9-]*$/;async function ZU(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!y8.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($t.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:HU(i)},{rel:`src/targets/${e}/index.ts`,content:cS(i)},{rel:`src/targets/${e}/generator.ts`,content:zU(i)},{rel:`src/targets/${e}/importer.ts`,content:VU(i)},{rel:`src/targets/${e}/linter.ts`,content:JU(i)},{rel:`src/targets/${e}/lint.ts`,content:YU(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:XU(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:mS(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:pS(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:uS(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(ZU,"writeTargetScaffold");async function qU(t,e,r){let n=e[0];return n===void 0||n===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:n==="scaffold"?_8(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${n}`}}s(qU,"runTarget");async function _8(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 ZU({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=>QU(l,r)),skipped:a.skipped.map(l=>QU(l,r)),postSteps:a.postSteps}}}s(_8,"runScaffold");function QU(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(QU,"relativize");ot();function t0(t){if(t.error&&y.error(t.error),t.showHelp){R8();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(t0,"renderTarget");function R8(){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(R8,"printTargetHelp");ce();Ti();A();Zt();Mr();So();function w8(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(w8,"shouldSymlink");function A8(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let n of r){if(!w8(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(A8,"createTempProjectRoot");async function mg(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 Ut(k,r);}catch{let k=[];throw m||k.push(`--from "${i}"`),p||k.push(`--to "${a}"`),new Error(`Unknown ${k.join(" and ")}. Supported: ${$t.join(", ")}.`)}let u=nt(l);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${$t.join(", ")}.`);if(!nt(c))throw new Error(`Unknown --to "${a}". Supported: ${$t.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",R=A8(o);try{await u.generators.importFrom(R,{scope:n});let k=await we(R),I=wi.parse({version:1,targets:p?[c]:[],pluginTargets:p?[]:[c]}),C=await vr({config:I,canonical:k,projectRoot:o,scope:n,targetFilter:[c]});if(!g){for(let T of C)if(T.status==="created"||T.status==="updated"){let B=Ic(o,T.path,T.target);await S(B,T.content);}}let b=C.filter(T=>T.status!=="skipped"),N=b.map(T=>({path:T.path,target:T.target,status:T.status}));return {exitCode:0,data:{from:l,to:c,mode:h,files:N,summary:{created:b.filter(T=>T.status==="created").length,updated:b.filter(T=>T.status==="updated").length,unchanged:b.filter(T=>T.status==="unchanged").length}}}}finally{rmSync(R,{recursive:true,force:true});}}s(mg,"runConvert");ot();function e0(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(e0,"renderConvert");var b8=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,M=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,n){if(b8.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 Nc(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(Nc,"redactAbsolutePaths");async function dS(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new M("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new M("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(dS,"safeWrite");var M8=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function Ci(t){let e=M8.exec(t);if(!e)return {frontmatter:{},body:t};let[,r,n]=e;return {frontmatter:parse(r)??{},body:n}}s(Ci,"parseMd");function Fc(t,e){return Object.keys(t).length===0?e:`---
636
+ `}s(S0,"TEMPLATE_IMPORT_MAP");var i9=/^[a-z][a-z0-9-]*$/;async function I0(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!i9.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($t.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:g0(i)},{rel:`src/targets/${e}/index.ts`,content:EI(i)},{rel:`src/targets/${e}/generator.ts`,content:h0(i)},{rel:`src/targets/${e}/importer.ts`,content:y0(i)},{rel:`src/targets/${e}/linter.ts`,content:_0(i)},{rel:`src/targets/${e}/lint.ts`,content:R0(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:S0(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:LI(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:OI(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:wI(i)}],l=[],c=[];for(let p of a){let u=join(r,p.rel);if(!n&&await j(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(I0,"writeTargetScaffold");async function k0(t,e,r){let n=e[0];return n===void 0||n===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:n==="scaffold"?a9(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${n}`}}s(k0,"runTarget");async function a9(t,e,r){let n=e[0];if(!n)throw new In("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 I0({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=>C0(l,r)),skipped:a.skipped.map(l=>C0(l,r)),postSteps:a.postSteps}}}s(a9,"runScaffold");function C0(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(C0,"relativize");ot();function E0(t){if(t.error&&y.error(t.error),t.showHelp){l9();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(E0,"renderTarget");function l9(){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(l9,"printTargetHelp");ce();Di();A();Zt();$r();Co();function h9(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(h9,"shouldSymlink");function y9(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let n of r){if(!h9(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(y9,"createTempProjectRoot");async function Ig(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=ve(l),p=ve(c);if(!m||!p)try{let{config:C}=await yt(r,"project");await Ut(C,r);}catch{let C=[];throw m||C.push(`--from "${i}"`),p||C.push(`--to "${a}"`),new Error(`Unknown ${C.join(" and ")}. Supported: ${$t.join(", ")}.`)}let u=nt(l);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${$t.join(", ")}.`);if(!nt(c))throw new Error(`Unknown --to "${a}". Supported: ${$t.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",S=y9(o);try{await u.generators.importFrom(S,{scope:n});let C=await we(S),R=bi.parse({version:1,targets:p?[c]:[],pluginTargets:p?[]:[c]}),k=await Mr({config:R,canonical:C,projectRoot:o,scope:n,targetFilter:[c]});if(!g){for(let x of k)if(x.status==="created"||x.status==="updated"){let B=kc(o,x.path,x.target);await I(B,x.content);}}let b=k.filter(x=>x.status!=="skipped"),N=b.map(x=>({path:x.path,target:x.target,status:x.status}));return {exitCode:0,data:{from:l,to:c,mode:h,files:N,summary:{created:b.filter(x=>x.status==="created").length,updated:b.filter(x=>x.status==="updated").length,unchanged:b.filter(x=>x.status==="unchanged").length}}}}finally{rmSync(S,{recursive:true,force:true});}}s(Ig,"runConvert");ot();function L0(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(L0,"renderConvert");var _9=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,M=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,n){if(_9.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 $c(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($c,"redactAbsolutePaths");async function AI(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new M("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new M("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(AI,"safeWrite");var O9=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function Ei(t){let e=O9.exec(t);if(!e)return {frontmatter:{},body:t};let[,r,n]=e;return {frontmatter:parse(r)??{},body:n}}s(Ei,"parseMd");function Gc(t,e){return Object.keys(t).length===0?e:`---
595
637
  ${stringify(t).trimEnd()}
596
638
  ---
597
639
 
598
- ${e}`}s(Fc,"serializeMd");var B8=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,K8={rules:"_root"};function pg(t){if(!B8.test(t)||t.includes(".."))throw new M("INVALID_NAME",`invalid name: ${t}`)}s(pg,"checkName");function ug(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(ug,"pathFor");function vc(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}=Ci(f);m.push(n(u,g));}return m},async get(l,{name:c}){pg(c);let m=ug(l.projectRoot,e,c);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=Ci(p);return {name:c,frontmatter:u,body:f}}catch(p){let u=p.code;throw u==="ENOENT"?new M("NOT_FOUND",`${e} "${c}" not found`):new M("IO_ERROR",`failed to read ${e}`,{errno:u})}},async create(l,{name:c,frontmatter:m,body:p,dry_run:u}){pg(c);let f=r.safeParse(m);if(!f.success)throw new M("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=ug(l.projectRoot,e,c);if(await a(g))throw new M("ALREADY_EXISTS",`${e} "${c}" exists`);if((await i(l.projectRoot)).length>=1e3)throw new M("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let R=Fc(m,p);return u===true?{path:g,written:false}:(await dS({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}){pg(c);let g=ug(l.projectRoot,e,c),h;try{let b=await readFile(g,"utf8");h=Ci(b);}catch(b){let N=b.code;throw N==="ENOENT"?new M("NOT_FOUND",`${e} "${c}" not found`):new M("IO_ERROR",`failed to read ${e}`,{errno:N})}let R=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,k=r.safeParse(R);if(!k.success)throw new M("VALIDATION_FAILED","invalid frontmatter",k.error.issues);let I=p!==void 0?p:h.body,C=Fc(R,I);return f===true?{path:g,written:false}:(await dS({projectRoot:l.projectRoot,feature:e,relativePath:`${c}.md`,content:C}),{path:g,written:true})},async delete(l,{name:c,force:m,dry_run:p}){if(pg(c),K8[e]===c&&m!==true)throw new M("PROTECTED_FILE",`${e} "${c}" requires force: true`);let u=ug(l.projectRoot,e,c);if(!await a(u))throw new M("NOT_FOUND",`${e} "${c}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(vc,"createCanonicalHandlers");var W8=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(),o0=vc({feature:"rules",frontmatterSchema:W8,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$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),s0=vc({feature:"commands",frontmatterSchema:H8,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var z8=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(),i0=vc({feature:"agents",frontmatterSchema:z8,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var V8=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")}),Y8=z$1.object({}).strict();function gS(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:Y8,handler:s(n=>e.list(n),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:V8,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(gS,"canonicalTools");var a0=[...gS("rule",o0),...gS("command",s0),...gS("agent",i0)];async function c0(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new M("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(n){throw n.code==="ENOENT"?new M("NOT_FOUND",`skill file not found: ${t.filePath}`):new M("IO_ERROR","failed to read skill file")}}s(c0,"safeRead");var r9=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,n9=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,d0=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function Dp(t){if(!r9.test(t))throw new M("INVALID_NAME",`invalid skill name: ${t}`)}s(Dp,"checkName");function _S(t){if(!n9.test(t)||t.includes("..")||t.includes("//"))throw new M("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(_S,"checkSupportPath");async function gg(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new M("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(gg,"atomicWrite");var f0=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),Np=s((t,e)=>resolve(f0(t),e),"skillDir"),Ka={async list(t){let e;try{e=(await readdir(f0(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(Np(t.projectRoot,n),"SKILL.md"),"utf8"),i=Ci(o).frontmatter;r.push({name:n,description:i.description??null});}catch{}return r},async get(t,{name:e}){Dp(e);let r=Np(t.projectRoot,e);try{let n=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:o,body:i}=Ci(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 M("NOT_FOUND",`skill "${e}" not found`):new M("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Dp(e),_S(r),{content:await c0({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Dp(e.name);let r=d0.safeParse(e.frontmatter);if(!r.success)throw new M("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let n=Np(t.projectRoot,e.name),o=false;try{await stat(n),o=!0;}catch{}if(o)throw new M("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(_S),a.length+1>1e3)throw new M("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:n,written:false,supportingFilesWritten:[]};let l=resolve(n,"SKILL.md");await gg(l,Fc(e.frontmatter,e.body));for(let[c,m]of Object.entries(i))await gg(resolve(n,c),m);return {path:n,written:true,supportingFilesWritten:a}},async update(t,e){Dp(e.name);let r=Np(t.projectRoot,e.name),n;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");n=Ci(p);}catch(p){throw p.code==="ENOENT"?new M("NOT_FOUND",`skill "${e.name}" not found`):new M("IO_ERROR","failed to read skill")}let o=e.frontmatter===void 0?n.frontmatter:e.merge===true?{...n.frontmatter,...e.frontmatter}:e.frontmatter,i=d0.safeParse(o);if(!i.success)throw new M("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:n.body,l=e.supportingFiles??{};Object.keys(l).forEach(_S);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 gg(resolve(r,"SKILL.md"),Fc(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 gg(f,u),c.push(p);}return {path:r,written:true,supportingFilesAffected:{written:c,deleted:m}}},async delete(t,{name:e,dry_run:r}){Dp(e);let n=Np(t.projectRoot,e);try{await stat(n);}catch{throw new M("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:n,deleted:false}:(await rm$1(n,{recursive:true}),{path:n,deleted:true})}};var o9=z$1.object({}).strict(),s9=z$1.object({name:z$1.string().describe("Item name")}),g0=[{name:"list_skills",description:"List skills",inputSchema:o9,handler:s(t=>Ka.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:s9,handler:s((t,e)=>Ka.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)=>Ka.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)=>Ka.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)=>Ka.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)=>Ka.delete(t,e),"handler")}];async function h0(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new M("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new M("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(h0,"safeConfigWrite");So();Qc();async function Fp(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new M("IO_ERROR","failed to read yaml")}}s(Fp,"readYaml");async function $c(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new M("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($c,"atomicWrite");var rr={async getConfig(t){let e=await Fp(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new M("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 Fp(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Fp(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 Fp(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=wi.safeParse(n);if(!i.success)throw new M("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 h0({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 M("ALREADY_EXISTS",`server "${e.name}" exists`);return n.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await $c(r,JSON.stringify(n,null,2)+`
599
- `),{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 M("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 $c(r,JSON.stringify(n,null,2)+`
600
- `),{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 M("NOT_FOUND",`server "${e.name}" not found`);return delete n.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await $c(r,JSON.stringify(n,null,2)+`
601
- `),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),n=await Fp(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 $c(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 $c(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 $c(r,n.join(`
640
+ ${e}`}s(Gc,"serializeMd");var x9=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,T9={rules:"_root"};function Cg(t){if(!x9.test(t)||t.includes(".."))throw new M("INVALID_NAME",`invalid name: ${t}`)}s(Cg,"checkName");function kg(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(kg,"pathFor");function jc(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}=Ei(f);m.push(n(u,g));}return m},async get(l,{name:c}){Cg(c);let m=kg(l.projectRoot,e,c);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=Ei(p);return {name:c,frontmatter:u,body:f}}catch(p){let u=p.code;throw u==="ENOENT"?new M("NOT_FOUND",`${e} "${c}" not found`):new M("IO_ERROR",`failed to read ${e}`,{errno:u})}},async create(l,{name:c,frontmatter:m,body:p,dry_run:u}){Cg(c);let f=r.safeParse(m);if(!f.success)throw new M("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=kg(l.projectRoot,e,c);if(await a(g))throw new M("ALREADY_EXISTS",`${e} "${c}" exists`);if((await i(l.projectRoot)).length>=1e3)throw new M("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let S=Gc(m,p);return u===true?{path:g,written:false}:(await AI({projectRoot:l.projectRoot,feature:e,relativePath:`${c}.md`,content:S}),{path:g,written:true})},async update(l,{name:c,frontmatter:m,body:p,merge:u,dry_run:f}){Cg(c);let g=kg(l.projectRoot,e,c),h;try{let b=await readFile(g,"utf8");h=Ei(b);}catch(b){let N=b.code;throw N==="ENOENT"?new M("NOT_FOUND",`${e} "${c}" not found`):new M("IO_ERROR",`failed to read ${e}`,{errno:N})}let S=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,C=r.safeParse(S);if(!C.success)throw new M("VALIDATION_FAILED","invalid frontmatter",C.error.issues);let R=p!==void 0?p:h.body,k=Gc(S,R);return f===true?{path:g,written:false}:(await AI({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(Cg(c),T9[e]===c&&m!==true)throw new M("PROTECTED_FILE",`${e} "${c}" requires force: true`);let u=kg(l.projectRoot,e,c);if(!await a(u))throw new M("NOT_FOUND",`${e} "${c}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(jc,"createCanonicalHandlers");var D9=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(),A0=jc({feature:"rules",frontmatterSchema:D9,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var N9=z$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),b0=jc({feature:"commands",frontmatterSchema:N9,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var F9=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(),P0=jc({feature:"agents",frontmatterSchema:F9,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var v9=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")')}),M9=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")}),$9=z$1.object({}).strict();function PI(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:$9,handler:s(n=>e.list(n),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:v9,handler:s((n,o)=>e.get(n,o),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:M9,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(PI,"canonicalTools");var x0=[...PI("rule",A0),...PI("command",b0),...PI("agent",P0)];async function D0(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new M("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(n){throw n.code==="ENOENT"?new M("NOT_FOUND",`skill file not found: ${t.filePath}`):new M("IO_ERROR","failed to read skill file")}}s(D0,"safeRead");var H9=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,z9=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,M0=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function Gp(t){if(!H9.test(t))throw new M("INVALID_NAME",`invalid skill name: ${t}`)}s(Gp,"checkName");function DI(t){if(!z9.test(t)||t.includes("..")||t.includes("//"))throw new M("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(DI,"checkSupportPath");async function Og(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new M("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(Og,"atomicWrite");var $0=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),jp=s((t,e)=>resolve($0(t),e),"skillDir"),za={async list(t){let e;try{e=(await readdir($0(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(jp(t.projectRoot,n),"SKILL.md"),"utf8"),i=Ei(o).frontmatter;r.push({name:n,description:i.description??null});}catch{}return r},async get(t,{name:e}){Gp(e);let r=jp(t.projectRoot,e);try{let n=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:o,body:i}=Ei(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 M("NOT_FOUND",`skill "${e}" not found`):new M("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Gp(e),DI(r),{content:await D0({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Gp(e.name);let r=M0.safeParse(e.frontmatter);if(!r.success)throw new M("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let n=jp(t.projectRoot,e.name),o=false;try{await stat(n),o=!0;}catch{}if(o)throw new M("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(DI),a.length+1>1e3)throw new M("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:n,written:false,supportingFilesWritten:[]};let l=resolve(n,"SKILL.md");await Og(l,Gc(e.frontmatter,e.body));for(let[c,m]of Object.entries(i))await Og(resolve(n,c),m);return {path:n,written:true,supportingFilesWritten:a}},async update(t,e){Gp(e.name);let r=jp(t.projectRoot,e.name),n;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");n=Ei(p);}catch(p){throw p.code==="ENOENT"?new M("NOT_FOUND",`skill "${e.name}" not found`):new M("IO_ERROR","failed to read skill")}let o=e.frontmatter===void 0?n.frontmatter:e.merge===true?{...n.frontmatter,...e.frontmatter}:e.frontmatter,i=M0.safeParse(o);if(!i.success)throw new M("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:n.body,l=e.supportingFiles??{};Object.keys(l).forEach(DI);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 Og(resolve(r,"SKILL.md"),Gc(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 Og(f,u),c.push(p);}return {path:r,written:true,supportingFilesAffected:{written:c,deleted:m}}},async delete(t,{name:e,dry_run:r}){Gp(e);let n=jp(t.projectRoot,e);try{await stat(n);}catch{throw new M("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:n,deleted:false}:(await rm$1(n,{recursive:true}),{path:n,deleted:true})}};var V9=z$1.object({}).strict(),J9=z$1.object({name:z$1.string().describe("Item name")}),G0=[{name:"list_skills",description:"List skills",inputSchema:V9,handler:s(t=>za.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:J9,handler:s((t,e)=>za.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)=>za.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)=>za.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)=>za.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)=>za.delete(t,e),"handler")}];async function j0(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new M("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new M("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(j0,"safeConfigWrite");Co();rm();async function Up(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new M("IO_ERROR","failed to read yaml")}}s(Up,"readYaml");async function Bc(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new M("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(Bc,"atomicWrite");var nr={async getConfig(t){let e=await Up(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new M("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await Ur(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await Up(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Up(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 Up(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=bi.safeParse(n);if(!i.success)throw new M("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 j0({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ur(r).catch(()=>null)??{mcpServers:{}};if(n.mcpServers[e.name]!==void 0)throw new M("ALREADY_EXISTS",`server "${e.name}" exists`);return n.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await Bc(r,JSON.stringify(n,null,2)+`
641
+ `),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ur(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new M("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 Bc(r,JSON.stringify(n,null,2)+`
642
+ `),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ur(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new M("NOT_FOUND",`server "${e.name}" not found`);return delete n.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await Bc(r,JSON.stringify(n,null,2)+`
643
+ `),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),n=await Up(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 Bc(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 Bc(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 Bc(r,n.join(`
602
644
  `)+`
603
- `),{path:r,written:true})}};var S9=/[;&|`$<>!\\\r\n]/u,C9=/^[A-Za-z_][A-Za-z0-9_]*$/u,k9=/^[A-Za-z][A-Za-z0-9_-]*$/u,E9=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,R0=/[\r\n]/u,I0=/[\0\r\n]/u;function L9(t){return I0.test(t)?false:!t.split(/[/\\]/u).includes("..")}s(L9,"isSafeMcpCwd");function O9(t){return z$1.string().min(1).max(512).refine(e=>!S9.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(O9,"noShellMeta");var SS=z$1.object({type:z$1.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z$1.string().max(1024).refine(t=>!I0.test(t),{message:"description must not contain NUL or newline characters"}).optional(),command:O9("command").optional(),args:z$1.array(z$1.string().max(2048)).max(100).optional(),env:z$1.record(z$1.string().regex(C9,"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(k9,"header name must be a valid identifier"),z$1.string().max(8192)).optional(),cwd:z$1.string().max(2048).refine(L9,{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(),w9=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"}),S0=z$1.string().max(256).refine(t=>!R0.test(t),{message:"hook matcher must not contain newlines"}),A9=z$1.object({matcher:S0,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"}),b9=z$1.object({matcher:S0,hooks:z$1.array(w9).min(1).max(50)}).strict(),P9=z$1.union([A9,b9]),C0=z$1.record(z$1.string().min(1).max(64),z$1.array(P9).max(100)),T9=z$1.string().min(1).max(256).refine(t=>!R0.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>E9.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),yg=z$1.array(T9).max(500);var vp=z$1.object({}).strict(),x9=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:vp,handler:s(t=>rr.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:vp,handler:s(t=>rr.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:vp,handler:s(t=>rr.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:vp,handler:s(t=>rr.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:vp,handler:s(t=>rr.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],D9=[{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:SS.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:SS,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:yg.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:yg.optional().describe("Denied tool patterns"),ask:yg.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:C0.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")}],k0=[...x9,...D9];dI();Sn();function N9(){return Object.fromEntries($t.map(t=>[t,Object.fromEntries(Object.entries(y$).map(([e,r])=>[e,r[t]]))]))}s(N9,"buildTargetIndex");var E0=N9(),CS={async list(){return E0},async get(t){let e=E0[t.targetId];if(e===void 0)throw new M("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};Io();Io();Yp();Zt();ho();Mr();ce();Sn();async function kS(t,e){let r=nt(t);if(!r)throw new In(t,{supported:[...$t,...pu().map(n=>n.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(kS,"importFrom");async function Gc(t,e={}){let r=e.scope??"project",{config:n,context:o}=await yt(t,r);await Ut(n,t);let{canonical:i}=await Oe(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(Gc,"loadProjectContext");async function ES(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return Bf(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(ES,"lint");async function LS(t){let e=await vr(t);return {...jf(e),results:e}}s(LS,"diff");async function OS(t){return Kf(t)}s(OS,"check");Io();ho();Ti();Yp();Tt();ce();Ot();A();function ki(t){if(t instanceof M)throw t;if(t instanceof In)throw new M("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new M("VALIDATION_FAILED",e):/lock/i.test(e)?new M("LOCK_HELD","generate lock is held"):new M("IO_ERROR","engine failure",{reason:e})}s(ki,"wrapEngineError");async function L0(t,e){if(e.dry_run===true)throw new M("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 kS(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 M("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 M("VALIDATION_FAILED",n);ki(r);}}s(L0,"importFromTarget");async function O0(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},n=await mg(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 M("VALIDATION_FAILED",n);ki(r);}}s(O0,"convert");async function $9(t,e){try{let r=await Gc(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=Ic(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){ki(r);}}s($9,"generate");async function G9(t,e){try{let r=await Gc(t.projectRoot),n=await ES({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){ki(r);}}s(G9,"lint");async function j9(t){try{let e=await Gc(t.projectRoot),r=await OS({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){ki(e);}}s(j9,"check");async function U9(t,e){try{let r=await Gc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,o=await LS({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){ki(r);}}s(U9,"diff");var Wa={generate:$9,lint:G9,check:j9,diff:U9,import:L0,convert:O0};var w0=z$1.object({}).strict(),A0=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:w0,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$1.object({targetId:z$1.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$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)=>Wa.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)=>Wa.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:w0,handler:s(t=>Wa.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)=>Wa.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)=>Wa.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)=>Wa.convert(t,e),"handler")}];function wS(t){if(t instanceof M)throw t;let e=t instanceof Error?t.message:String(t),r=Nc(e);throw /lock|LockAcquisitionError/i.test(r)?new M("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 M("VALIDATION_FAILED",r):new M("IO_ERROR","install pipeline failure",{reason:r})}s(wS,"wrapInstallError");function B9(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(B9,"toInstallFlags");function K9(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(K9,"toUninstallFlags");async function W9(t,e){if(typeof e.source!="string"||e.source.trim().length===0)throw new M("VALIDATION_FAILED","install: `source` is required");try{let r=await Ua(B9(e),[e.source],t.projectRoot);if(r.exitCode!==0)throw new M("IO_ERROR",`install exited ${r.exitCode}`);return r.data}catch(r){wS(r);}}s(W9,"install");async function H9(t,e){if(e.all!==true&&(!Array.isArray(e.names)||e.names.length===0))throw new M("VALIDATION_FAILED","uninstall: pass `names: [...]` or set `all: true`");try{return (await sg(K9(e),e.names??[],t.projectRoot)).data}catch(r){wS(r);}}s(H9,"uninstall");async function z9(t,e={}){try{let r={};return e.global===!0&&(r.global=!0),(await ag(r,t.projectRoot)).data}catch(r){wS(r);}}s(z9,"installsList");var _g={install:W9,uninstall:H9,installsList:z9};function V9(t){let e={force:true};return t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(V9,"toRefreshFlags");function J9(t){if(t instanceof M)throw t;let e=t instanceof Error?t.message:String(t),r=Nc(e);throw /lock|LockAcquisitionError/i.test(r)?new M("LOCK_HELD",".install.lock is held by another process"):/unknown pack|not found|usage:/i.test(r)?new M("VALIDATION_FAILED",r):/resolve|network|fetch/i.test(r)?new M("REFRESH_RESOLVE_FAILED",r):/materialize|apply|manifest-update/i.test(r)?new M("REFRESH_APPLY_FAILED",r):new M("IO_ERROR","refresh pipeline failure",{reason:r})}s(J9,"wrapRefreshError");async function Y9(t,e={}){try{let r=await ig(V9(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 M("VALIDATION_FAILED",i)}return r.data}catch(r){J9(r);}}s(Y9,"refresh");var b0={refresh:Y9};var X9=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.")}),Z9=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.")}),Q9=z$1.object({global:z$1.boolean().optional().describe("Read from `~/.agentsmesh/installs.yaml` instead of the project scope.")}),q9=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.")}),P0=[{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:X9,handler:s((t,e)=>_g.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:Z9,handler:s((t,e)=>_g.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:Q9,handler:s((t,e)=>_g.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:q9,handler:s((t,e)=>b0.refresh(t,e),"handler")}];function T0(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(T0,"zodToMcpSchema");var Rg=[...a0,...g0,...k0,...A0,...P0],AS=Rg.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")}));Ti();async function n6(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 M("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(n6,"findProjectRoot");async function bS(t){let e=await n6(t.cwd);return {projectRoot:e,loadCanonical:s(()=>we(e),"loadCanonical")}}s(bS,"resolveContext");async function d6(){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(d6,"pkgVersion");function f6(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(f6,"matchTemplate");function g6(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(g6,"extractTemplateParams");async function D0(){let t=new Server({name:"agentsmesh-mcp",version:await d6()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:Rg.map(e=>({name:e.name,description:e.description,inputSchema:T0(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=Rg.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 M("VALIDATION_FAILED","invalid input",n.error.issues);let o=await bS({cwd:process.cwd()}),i=await r.handler(o,n.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(n){let o=n instanceof M?n.toEnvelope():{code:"IO_ERROR",message:Nc(n instanceof Error?n.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(o)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:AS.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=AS.find(a=>a.uri===e.params.uri||f6(a.uri,e.params.uri));if(!r)throw new M("NOT_FOUND",`resource not found: ${e.params.uri}`);let n=await bS({cwd:process.cwd()}),o=g6(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(D0,"startServer");ot();async function N0(t,e){vS(),await D0();}s(N0,"runMcp");var F0={generate:s(async(t,e)=>{let r=await Sc(t,void 0,{printMatrix:t.json!==true});le("generate",r,t,()=>Cc(r));},"generate"),init:s(async(t,e)=>{let r=await v$(process.cwd(),{yes:t.yes===true,global:t.global===true});le("init",r,t,()=>M$(r));},"init"),import:s(async(t,e)=>{let r=await G$(t);le("import",r,t,()=>Y$(r));},"import"),diff:s(async(t,e)=>{let r=await U$(t);le("diff",r,t,()=>X$(r));},"diff"),lint:s(async(t,e)=>{let r=await z$(t);le("lint",r,t,()=>V$(r));},"lint"),check:s(async(t,e)=>{let r=await tG(t);le("check",r,t,()=>J$(r));},"check"),merge:s(async(t,e)=>{let r=await nG(t);le("merge",r,t,()=>Z$(r));},"merge"),matrix:s(async(t,e)=>{let r=await up(t);le("matrix",r,t,()=>fp(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){Ja("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await q$(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 mU(t,e,process.cwd());le("install",r,t,()=>pU(r));},"install"),uninstall:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await LU(t,e,process.cwd());le("uninstall",r,t,()=>OU(r));},"uninstall"),refresh:s(async(t,e)=>{let r=await FU(t,e,process.cwd());le("refresh",r,t,()=>vU(r));},"refresh"),installs:s(async(t,e)=>{let r=await $U(t,e,process.cwd());le("installs",r,t,()=>GU(r));},"installs"),plugin:s(async(t,e)=>{let r=await KU(t,e,process.cwd());le("plugin",r,t,()=>WU(r));},"plugin"),target:s(async(t,e)=>{let r=await qU(t,e,process.cwd());le("target",r,t,()=>t0(r));},"target"),convert:s(async(t,e)=>{let r=await mg(t);le("convert",r,t,()=>e0(r));},"convert"),mcp:s(async(t,e)=>{await N0();},"mcp")};function _6(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(_6,"parseArgs");var R6=DS(F0);async function I6(t){let{command:e,flags:r,args:n}=t;if(e==="help"){Lg();return}if(e==="version"){$S();return}if(r.help===true){Up(e);return}r.json===true&&FS(),await R6.route(e,r,n);}s(I6,"main");function S6(){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(S6,"isMainModule");if(S6()){let t=_6(process.argv.slice(2));I6(t).catch(e=>GS(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
604
- export{_6 as parseArgs};
645
+ `),{path:r,written:true})}};var m6=/[;&|`$<>!\\\r\n]/u,p6=/^[A-Za-z_][A-Za-z0-9_]*$/u,u6=/^[A-Za-z][A-Za-z0-9_-]*$/u,d6=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,K0=/[\r\n]/u,W0=/[\0\r\n]/u;function f6(t){return W0.test(t)?false:!t.split(/[/\\]/u).includes("..")}s(f6,"isSafeMcpCwd");function g6(t){return z$1.string().min(1).max(512).refine(e=>!m6.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(g6,"noShellMeta");var vI=z$1.object({type:z$1.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z$1.string().max(1024).refine(t=>!W0.test(t),{message:"description must not contain NUL or newline characters"}).optional(),command:g6("command").optional(),args:z$1.array(z$1.string().max(2048)).max(100).optional(),env:z$1.record(z$1.string().regex(p6,"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(u6,"header name must be a valid identifier"),z$1.string().max(8192)).optional(),cwd:z$1.string().max(2048).refine(f6,{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(),h6=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"}),H0=z$1.string().max(256).refine(t=>!K0.test(t),{message:"hook matcher must not contain newlines"}),y6=z$1.object({matcher:H0,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"}),_6=z$1.object({matcher:H0,hooks:z$1.array(h6).min(1).max(50)}).strict(),R6=z$1.union([y6,_6]),z0=z$1.record(z$1.string().min(1).max(64),z$1.array(R6).max(100)),S6=z$1.string().min(1).max(256).refine(t=>!K0.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>d6.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),Ag=z$1.array(S6).max(500);var Bp=z$1.object({}).strict(),I6=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Bp,handler:s(t=>nr.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Bp,handler:s(t=>nr.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Bp,handler:s(t=>nr.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Bp,handler:s(t=>nr.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Bp,handler:s(t=>nr.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],C6=[{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)=>nr.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:vI.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)=>nr.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:vI,merge:z$1.boolean().optional(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>nr.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)=>nr.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:Ag.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:Ag.optional().describe("Denied tool patterns"),ask:Ag.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)=>nr.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:z0.describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>nr.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)=>nr.updateIgnore(t,e),"handler")}],V0=[...I6,...C6];ES();kn();function k6(){return Object.fromEntries($t.map(t=>[t,Object.fromEntries(Object.entries(D$).map(([e,r])=>[e,r[t]]))]))}s(k6,"buildTargetIndex");var J0=k6(),MI={async list(){return J0},async get(t){let e=J0[t.targetId];if(e===void 0)throw new M("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};Io();Io();ru();Zt();yo();$r();ce();kn();async function $I(t,e){let r=nt(t);if(!r)throw new Cn(t,{supported:[...$t,..._u().map(n=>n.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s($I,"importFrom");async function Kc(t,e={}){let r=e.scope??"project",{config:n,context:o}=await yt(t,r);await Ut(n,t);let{canonical:i}=await Oe(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(Kc,"loadProjectContext");async function GI(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return qf(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(GI,"lint");async function jI(t){let e=await Mr(t);return {...Xf(e),results:e}}s(jI,"diff");async function UI(t){return tg(t)}s(UI,"check");Io();yo();Di();ru();xt();ce();Ot();z$1.object({version:z$1.literal(1),assignments:z$1.record(z$1.string(),z$1.string())});A();function Li(t){if(t instanceof M)throw t;if(t instanceof Cn)throw new M("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new M("VALIDATION_FAILED",e):/lock/i.test(e)?new M("LOCK_HELD","generate lock is held"):new M("IO_ERROR","engine failure",{reason:e})}s(Li,"wrapEngineError");async function Z0(t,e){if(e.dry_run===true)throw new M("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 $I(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 Cn)throw new M("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 M("VALIDATION_FAILED",n);Li(r);}}s(Z0,"importFromTarget");async function Q0(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},n=await Ig(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 M("VALIDATION_FAILED",n);Li(r);}}s(Q0,"convert");async function M6(t,e){try{let r=await Kc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,i=(await Mr({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=kc(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){Li(r);}}s(M6,"generate");async function $6(t,e){try{let r=await Kc(t.projectRoot),n=await GI({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){Li(r);}}s($6,"lint");async function G6(t){try{let e=await Kc(t.projectRoot),r=await UI({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){Li(e);}}s(G6,"check");async function j6(t,e){try{let r=await Kc(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,o=await jI({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){Li(r);}}s(j6,"diff");var Va={generate:M6,lint:$6,check:G6,diff:j6,import:Z0,convert:Q0};var q0=z$1.object({}).strict(),tB=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:q0,handler:s(()=>MI.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)=>MI.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)=>Va.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)=>Va.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:q0,handler:s(t=>Va.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)=>Va.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)=>Va.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)=>Va.convert(t,e),"handler")}];function BI(t){if(t instanceof M)throw t;let e=t instanceof Error?t.message:String(t),r=$c(e);throw /lock|LockAcquisitionError/i.test(r)?new M("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 M("VALIDATION_FAILED",r):new M("IO_ERROR","install pipeline failure",{reason:r})}s(BI,"wrapInstallError");function U6(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(U6,"toInstallFlags");function B6(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(B6,"toUninstallFlags");async function K6(t,e){if(typeof e.source!="string"||e.source.trim().length===0)throw new M("VALIDATION_FAILED","install: `source` is required");try{let r=await Wa(U6(e),[e.source],t.projectRoot);if(r.exitCode!==0)throw new M("IO_ERROR",`install exited ${r.exitCode}`);return r.data}catch(r){BI(r);}}s(K6,"install");async function W6(t,e){if(e.all!==true&&(!Array.isArray(e.names)||e.names.length===0))throw new M("VALIDATION_FAILED","uninstall: pass `names: [...]` or set `all: true`");try{return (await hg(B6(e),e.names??[],t.projectRoot)).data}catch(r){BI(r);}}s(W6,"uninstall");async function H6(t,e={}){try{let r={};return e.global===!0&&(r.global=!0),(await _g(r,t.projectRoot)).data}catch(r){BI(r);}}s(H6,"installsList");var bg={install:K6,uninstall:W6,installsList:H6};function z6(t){let e={force:true};return t.dry_run===true&&(e["dry-run"]=true),t.global===true&&(e.global=true),e}s(z6,"toRefreshFlags");function V6(t){if(t instanceof M)throw t;let e=t instanceof Error?t.message:String(t),r=$c(e);throw /lock|LockAcquisitionError/i.test(r)?new M("LOCK_HELD",".install.lock is held by another process"):/unknown pack|not found|usage:/i.test(r)?new M("VALIDATION_FAILED",r):/resolve|network|fetch/i.test(r)?new M("REFRESH_RESOLVE_FAILED",r):/materialize|apply|manifest-update/i.test(r)?new M("REFRESH_APPLY_FAILED",r):new M("IO_ERROR","refresh pipeline failure",{reason:r})}s(V6,"wrapRefreshError");async function J6(t,e={}){try{let r=await yg(z6(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 M("VALIDATION_FAILED",i)}return r.data}catch(r){V6(r);}}s(J6,"refresh");var eB={refresh:J6};var Y6=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.")}),X6=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.")}),Z6=z$1.object({global:z$1.boolean().optional().describe("Read from `~/.agentsmesh/installs.yaml` instead of the project scope.")}),Q6=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.")}),rB=[{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:Y6,handler:s((t,e)=>bg.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:X6,handler:s((t,e)=>bg.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:Z6,handler:s((t,e)=>bg.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:Q6,handler:s((t,e)=>eB.refresh(t,e),"handler")}];function nB(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(nB,"zodToMcpSchema");var Pg=[...x0,...G0,...V0,...tB,...rB],KI=Pg.filter(t=>t.resourceUri!==void 0).map(t=>({uri:t.resourceUri,name:t.name,description:t.description,read:s((e,r)=>t.handler(e,r),"read")}));Di();async function r4(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 M("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(r4,"findProjectRoot");async function WI(t){let e=await r4(t.cwd);return {projectRoot:e,loadCanonical:s(()=>we(e),"loadCanonical")}}s(WI,"resolveContext");async function u4(){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(u4,"pkgVersion");function d4(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(d4,"matchTemplate");function f4(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(f4,"extractTemplateParams");async function sB(){let t=new Server({name:"agentsmesh-mcp",version:await u4()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:Pg.map(e=>({name:e.name,description:e.description,inputSchema:nB(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=Pg.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 M("VALIDATION_FAILED","invalid input",n.error.issues);let o=await WI({cwd:process.cwd()}),i=await r.handler(o,n.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(n){let o=n instanceof M?n.toEnvelope():{code:"IO_ERROR",message:$c(n instanceof Error?n.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(o)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:KI.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=KI.find(a=>a.uri===e.params.uri||d4(a.uri,e.params.uri));if(!r)throw new M("NOT_FOUND",`resource not found: ${e.params.uri}`);let n=await WI({cwd:process.cwd()}),o=f4(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(sB,"startServer");ot();async function iB(t,e){ZI(),await sB();}s(iB,"runMcp");var aB={generate:s(async(t,e)=>{let r=await Ec(t,void 0,{printMatrix:t.json!==true});le("generate",r,t,()=>Lc(r));},"generate"),init:s(async(t,e)=>{let r=await q$(process.cwd(),{yes:t.yes===true,global:t.global===true,lessons:t.lessons===true});le("init",r,t,()=>eG(r));},"init"),import:s(async(t,e)=>{let r=await sG(t);le("import",r,t,()=>RG(r));},"import"),diff:s(async(t,e)=>{let r=await aG(t);le("diff",r,t,()=>SG(r));},"diff"),lint:s(async(t,e)=>{let r=await hG(t);le("lint",r,t,()=>yG(r));},"lint"),check:s(async(t,e)=>{let r=await EG(t);le("check",r,t,()=>_G(r));},"check"),merge:s(async(t,e)=>{let r=await wG(t);le("merge",r,t,()=>IG(r));},"merge"),matrix:s(async(t,e)=>{let r=await hp(t);le("matrix",r,t,()=>_p(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 kG(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());le("install",r,t,()=>FU(r));},"install"),uninstall:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await YU(t,e,process.cwd());le("uninstall",r,t,()=>XU(r));},"uninstall"),refresh:s(async(t,e)=>{let r=await s0(t,e,process.cwd());le("refresh",r,t,()=>i0(r));},"refresh"),installs:s(async(t,e)=>{let r=await l0(t,e,process.cwd());le("installs",r,t,()=>c0(r));},"installs"),plugin:s(async(t,e)=>{let r=await d0(t,e,process.cwd());le("plugin",r,t,()=>f0(r));},"plugin"),target:s(async(t,e)=>{let r=await k0(t,e,process.cwd());le("target",r,t,()=>E0(r));},"target"),convert:s(async(t,e)=>{let r=await Ig(t);le("convert",r,t,()=>L0(r));},"convert"),mcp:s(async(t,e)=>{await iB();},"mcp")};function y4(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(y4,"parseArgs");var _4=JI(aB);async function R4(t){let{command:e,flags:r,args:n}=t;if(e==="help"){vg();return}if(e==="version"){qI();return}if(r.help===true){Jp(e);return}r.json===true&&XI(),await _4.route(e,r,n);}s(R4,"main");function S4(){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(S4,"isMainModule");if(S4()){let t=y4(process.argv.slice(2));R4(t).catch(e=>tC(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
646
+ export{y4 as parseArgs};