agentsmesh 0.14.0 → 0.15.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,175 +1,175 @@
1
1
  #!/usr/bin/env node
2
- import {rm as rm$1,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,access,realpath,readlink,symlink,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {dirname,join,resolve,sep,extname,basename,relative,win32,posix,normalize}from'path';import {realpathSync,rmSync,mkdtempSync,readdirSync,symlinkSync,mkdirSync,statSync,existsSync,constants}from'fs';import {z as z$1}from'zod';import {parse,stringify}from'yaml';import {homedir,tmpdir,hostname}from'os';import {execFile}from'child_process';import {fileURLToPath,pathToFileURL,URL}from'url';import {promisify}from'util';import*as jy 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 JU from'chokidar';import*as Kx 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 fy=Object.defineProperty;var s=(t,e)=>fy(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Jp=(t,e)=>{for(var r in e)fy(t,r,{get:e[r],enumerable:true});};function yy(){Go=true;}function _y(){hy=true;}function zs(t){hy?process.stderr.write(t):process.stdout.write(t);}function nT(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function Ca(t,e){return nT()?e:`${t}${e}${Vs.reset}`}function oT(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Vs,Go,hy,I,nt=d(()=>{Vs={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},Go=false,hy=false;s(yy,"muteLogger");s(_y,"redirectLoggerToStderr");s(zs,"out");s(nT,"noColor");s(Ca,"c");s(oT,"pad");I={info(t){Go||zs(Ca(Vs.cyan,t)+`
2
+ import {rm as rm$1,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,access,realpath,readlink,symlink,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {resolve,join,sep,dirname,extname,basename,relative,win32,posix,normalize}from'path';import {realpathSync,rmSync,mkdtempSync,readdirSync,symlinkSync,mkdirSync,statSync,existsSync,constants,readFileSync}from'fs';import {z as z$1}from'zod';import {parse,stringify}from'yaml';import {homedir,tmpdir,hostname}from'os';import {execFile}from'child_process';import {fileURLToPath,pathToFileURL,URL}from'url';import {promisify}from'util';import*as jy 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 qU from'chokidar';import*as Hx 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 gy=Object.defineProperty;var s=(t,e)=>gy(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var Yp=(t,e)=>{for(var r in e)gy(t,r,{get:e[r],enumerable:true});};function _y(){Go=true;}function Iy(){yy=true;}function zs(t){yy?process.stderr.write(t):process.stdout.write(t);}function iT(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function Ca(t,e){return iT()?e:`${t}${e}${Vs.reset}`}function aT(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var Vs,Go,yy,I,nt=d(()=>{Vs={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},Go=false,yy=false;s(_y,"muteLogger");s(Iy,"redirectLoggerToStderr");s(zs,"out");s(iT,"noColor");s(Ca,"c");s(aT,"pad");I={info(t){Go||zs(Ca(Vs.cyan,t)+`
3
3
  `);},warn(t){Go||process.stderr.write(Ca(Vs.yellow,"\u26A0 ")+t+`
4
4
  `);},error(t){Go||process.stderr.write(Ca(Vs.red,"\u2717 ")+t+`
5
5
  `);},success(t){Go||zs(Ca(Vs.green,"\u2713 ")+t+`
6
6
  `);},debug(t){Go||process.env.AGENTSMESH_DEBUG==="1"&&zs(Ca(Vs.cyan,"[debug] ")+t+`
7
7
  `);},table(t){if(Go||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 c=[...t[a][o]].length;c>i&&(i=c);}r[o]=i;}let n="+"+r.map(o=>"-".repeat(o+2)).join("+")+"+";zs(n+`
8
- `);for(let o=0;o<t.length;o++){let a="| "+t[o].map((c,l)=>oT(c,r[l])).join(" | ")+" |";zs(a+`
8
+ `);for(let o=0;o<t.length;o++){let a="| "+t[o].map((c,l)=>aT(c,r[l])).join(" | ")+" |";zs(a+`
9
9
  `);}zs(n+`
10
- `);}};});var an,We,Ys,cn,Xs,Be,qn=d(()=>{an=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},We=class extends an{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;}},Ys=class extends an{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 an{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;}},Xs=class extends an{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,n){super("AM_LOCK_ACQUISITION_FAILED",`Could not acquire generate lock at ${e}: currently held by ${r}. Wait for the other process to finish, or remove ${e} manually if you are sure no agentsmesh process is running.`,n),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},Be=class extends an{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 ET(t){let e=extname(t).toLowerCase();if(e.length>0)return OT.has(e);let r=basename(t).toLowerCase();return wT.has(r)}function LT(t){return t.replace(/\r\n?/g,`
11
- `)}async function y(t){try{let e=await readFile(t,"utf-8");return e.startsWith(by)?e.slice(by.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new Be(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function S(t,e){let r=dirname(t);await mkdir(r,{recursive:true});try{let i=await lstat(t);if(i.isDirectory())throw new Be(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});i.isSymbolicLink()&&await unlink(t).catch(a=>{if(a.code!=="ENOENT")throw a});}catch(i){if(i instanceof Be||i.code!=="ENOENT")throw i}let n=`${t}.tmp`,o=ET(t)?LT(e):e;try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(i){if(i.code!=="ENOENT")throw i}await writeFile(n,o,{encoding:"utf-8",flag:"w"}),await rename(n,t);}catch(i){await rm$1(n,{force:true}).catch(()=>{});let a=i;throw new Be(t,`Failed to write ${t}: ${a.message}. Check permissions and disk space.`,{cause:i,errnoCode:a.code})}}async function v(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function O(t){await mkdir(t,{recursive:true});}async function N(t,e){let r;try{r=await realpath(t);}catch(o){let i=o;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="ELOOP")return [];throw new Be(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:o,errnoCode:i.code})}let n=e??new Set;if(n.has(r))return [];n.add(r);try{let o=await readdir(t,{withFileTypes:!0}),i=[];for(let a of o){let c=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(c).then(m=>m.isDirectory(),()=>!1)?i.push(...await N(c,n)):i.push(c);}return i}catch(o){let i=o;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="EACCES")return [];throw new Be(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:o,errnoCode:i.code})}}async function Py(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 by,OT,wT,A=d(()=>{qn();by="\uFEFF",OT=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),wT=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(ET,"shouldNormalizeLineEndings");s(LT,"normalizeLineEndings");s(y,"readFileSafe");s(S,"writeFileAtomic");s(v,"exists");s(O,"mkdirp");s(N,"readDirRecursive");s(Py,"ensureCacheSymlink");});function He(t){return qp.includes(t)}var qp,Ty=d(()=>{qp=["amp","antigravity","claude-code","cline","codex-cli","continue","copilot","cursor","gemini-cli","goose","junie","kilo-code","kiro","opencode","roo-code","warp","windsurf","zed"];s(He,"isBuiltinTargetId");});var it,Sa,ze=d(()=>{Ty();it=qp,Sa="codex-cli";});var Dy,Re,Zs,ka,bT,AT,Ra,xT,PT,jo,ln=d(()=>{ze();Dy=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],Re=z$1.enum(it),Zs=z$1.enum(Dy),ka=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(),bT=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:Re.optional(),features:z$1.array(Zs),path:z$1.string().optional(),pick:ka.optional()}),AT=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),Ra=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),xT=z$1.object({commands_to_skills:z$1.object({"codex-cli":Ra.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":Ra.optional(),cline:Ra.optional(),"codex-cli":Ra.optional(),windsurf:Ra.optional()}).passthrough().optional()}).strict().optional(),PT=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional()}).strict(),jo=z$1.object({version:z$1.literal(1),targets:z$1.array(Re).default([...it]),features:z$1.array(Zs).default([...Dy]),extends:z$1.array(bT).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:AT.default({strategy:"merge",lock_features:[]}),conversions:xT,plugins:z$1.array(PT).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function NT(t){let e=resolve(t);for(;;){let r=join(e,tu);if(await v(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}async function FT(t){let e=await y(t);if(e===null)throw new We(t);let r=parse(e),n=jo.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new Ys(t,o,{cause:n.error})}return n.data}function Qp(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null)continue;let i=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[n]=Qp(i,o):r[n]=o;}return r}function vT(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=Qp(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Qp(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function rl(t){let e=join(t,tu),r=await FT(e),n=join(t,DT),o=await y(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=vT(r,i),c=jo.safeParse(a);if(c.success)r=c.data;else {let l=c.error.issues.map(m=>m.message).join("; ");I.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${l}. Using project config instead.`);}}}return {config:r,configDir:t}}async function nl(t){let e=await NT(t);if(e===null)throw new We(join(t,tu));return rl(dirname(e))}var tu,DT,ol=d(()=>{A();nt();qn();ln();tu="agentsmesh.yaml",DT="agentsmesh.local.yaml";s(NT,"findConfigPath");s(FT,"loadConfig");s(Qp,"deepMergeObjects");s(vT,"mergeLocalConfig");s(rl,"loadConfigFromExactDir");s(nl,"loadConfigFromDir");});function Oa(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 lt(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await nl(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Oa(t,e);try{let{config:n}=await rl(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof We?new We(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 le=d(()=>{ol();qn();s(Oa,"resolveScopeContext");s(lt,"loadScopedConfig");});async function sl(t,e,r,n,o){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,c=t.ref??"HEAD",l=o(i,a,c),m=join(n,l),p=join(m,vy),u=`${m}.tmp`,f=join(u,vy);if(!r.refresh&&await My(p))return ou(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await HT(BT(t),f),t.ref&&await zT(f,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),ou(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await My(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),ou(p);throw g}}async function ou(t){return {resolvedPath:t,version:await VT(t)}}async function My(t){return v(t)}function BT(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 HT(t,e){await su(["clone",t,e]);}async function zT(t,e){await su(["checkout",e],t);}async function VT(t){return su(["rev-parse","HEAD"],t)}async function su(t,e){let{stdout:r}=await WT("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var WT,vy,iu=d(()=>{A();WT=promisify(execFile),vy="repo";s(sl,"fetchGitRemoteExtend");s(ou,"readCachedRepo");s(My,"hasCachedRepo");s(BT,"resolveCloneUrl");s(HT,"cloneRepo");s(zT,"checkoutRef");s(VT,"getHeadSha");s(su,"runGit");});async function Uy(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 Ky(t,e,r,n,o,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,c=r.refresh===true,l=t.tag;if(l==="latest")try{l=await Uy(t.org,t.repo,a);}catch(_){if(!i)throw _;return qT(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,l),p=join(n,m);if(!c&&await v(p)){let _=await au(p);if(_)return {resolvedPath:join(p,_),version:l}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${l}`,f={};a&&(f.Authorization=`Bearer ${a}`);let g;try{let _=await globalThis.fetch(u,{headers:f,redirect:"follow"});if(!_.ok)throw new Error(`HTTP ${_.status}: ${_.statusText}`);g=await _.arrayBuffer();}catch(_){if(r.allowOfflineFallback!==false&&await v(p)){let T=await au(p);if(T)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${_ instanceof Error?_.message:String(_)}`),{resolvedPath:join(p,T),version:l}}throw _}await rm$1(p,{recursive:true,force:true}),await mkdir(p,{recursive:true});let h=join(p,"archive.tar.gz");await writeFile(h,new Uint8Array(g));try{await jy.extract({file:h,cwd:p,strict:!0,filter:s((_,E)=>!(ZT(_)||E&&"type"in E&&(E.type==="Link"||E.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let R=await au(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:l}}async function au(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}function Gy(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function ZT(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function qT(t,e,r,n,o,i){let a=i?[Gy(t.org,t.repo,i)]:[Gy(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],c;for(let l of a){let m={url:l};try{return await sl(m,e,r,n,o)}catch(p){c=p;}}throw c instanceof Error?c:new Error("Failed to clone GitHub default branch")}var Wy=d(()=>{A();iu();s(Uy,"resolveLatestTag");s(Ky,"fetchGithubRemoteExtend");s(au,"findExtractTopDir");s(Gy,"buildGithubCloneUrl");s(ZT,"isZipSlipPath");s(qT,"fetchGithubDefaultBranch");});function By(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 Hy(t){let e=By(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 zy(t){let e=By(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 Vy(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),n=(r<0?e:e.slice(0,r)).trim(),o=r<0?void 0:e.slice(r+1).trim();if(!n||r>=0&&!o)return null;let i;try{i=new URL(n);}catch{return null}return ["https:","http:","ssh:","file:"].includes(i.protocol)?{url:n,ref:o}:null}function Uo(t){let e=Hy(t);if(e)return {kind:"github",...e};let r=zy(t);if(r)return {kind:"gitlab",...r};let n=Vy(t);return n?{kind:"git",...n}:null}function cu(t){return Uo(t)!==null}var Ea=d(()=>{s(By,"splitSourceRef");s(Hy,"parseGithubSource");s(zy,"parseGitlabSource");s(Vy,"parseGitSource");s(Uo,"parseRemoteSource");s(cu,"isSupportedRemoteSource");});function rD(t){let e=Uo(t);return e?e.kind==="github"?qs("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?qs("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):qs("git",e.url,e.ref??"HEAD"):null}async function Xy(t,e){let r=rD(t);if(!r)return;let n=e??me(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}async function Zy(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 c=join(r,a);try{let{mtimeMs:l}=await stat(c);i-l>n&&await rm$1(c,{recursive:!0,force:!0});}catch{}}));}var lu=d(()=>{La();Ea();s(rD,"cacheKeyFromSource");s(Xy,"cleanInstallCache");s(Zy,"sweepStaleCache");});function qs(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>qy){let i=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,qy-18)}--${i}`;}return o}function me(){let t=process.env.AGENTSMESH_CACHE;return t||join(homedir(),".agentsmesh","cache")}async function Qs(t,e,r={}){let n=Uo(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 Zy(o).catch(()=>{}),n.kind==="github"?Ky(n,e,r,o,qs,!t.includes("@")):sl(n,e,r,o,qs)}var qy,La=d(()=>{iu();Wy();Ea();lu();qy=80;s(qs,"buildCacheKey");s(me,"getCacheDir");s(Qs,"fetchRemoteExtend");});function lD(t){return t.startsWith("http://")||t.startsWith("https://")}async function ti(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>cu(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(lD(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(cu(o.source)){let a=await Qs(o.source,o.name,{cacheDir:me(),refresh:r.refreshCache===true});n.push({name:o.name,resolvedPath:a.resolvedPath,features:[...o.features],target:o.target,version:a.version,path:o.path,pick:o.pick});continue}let i=resolve(e,o.source);if(!await v(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,path:o.path,pick:o.pick});}return n}var il=d(()=>{A();La();Ea();s(lD,"isOtherRemoteSource");s(ti,"resolveExtendPaths");});function w(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let n=t.slice(3,r).trim(),o=t.slice(r+3).trim();return {frontmatter:n===""?{}:parse(n)??{},body:o}}function F(t,e){return Object.keys(t).length===0?e:`---
10
+ `);}};});var an,We,Ys,cn,Xs,Be,qn=d(()=>{an=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},We=class extends an{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;}},Ys=class extends an{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 an{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;}},Xs=class extends an{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,n){super("AM_LOCK_ACQUISITION_FAILED",`Could not acquire generate lock at ${e}: currently held by ${r}. Wait for the other process to finish, or remove ${e} manually if you are sure no agentsmesh process is running.`,n),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},Be=class extends an{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 AT(t){let e=extname(t).toLowerCase();if(e.length>0)return LT.has(e);let r=basename(t).toLowerCase();return bT.has(r)}function xT(t){return t.replace(/\r\n?/g,`
11
+ `)}async function y(t){try{let e=await readFile(t,"utf-8");return e.startsWith(by)?e.slice(by.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new Be(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function S(t,e){let r=dirname(t);await mkdir(r,{recursive:true});try{let i=await lstat(t);if(i.isDirectory())throw new Be(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});i.isSymbolicLink()&&await unlink(t).catch(a=>{if(a.code!=="ENOENT")throw a});}catch(i){if(i instanceof Be||i.code!=="ENOENT")throw i}let n=`${t}.tmp`,o=AT(t)?xT(e):e;try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(i){if(i.code!=="ENOENT")throw i}await writeFile(n,o,{encoding:"utf-8",flag:"w"}),await rename(n,t);}catch(i){await rm$1(n,{force:true}).catch(()=>{});let a=i;throw new Be(t,`Failed to write ${t}: ${a.message}. Check permissions and disk space.`,{cause:i,errnoCode:a.code})}}async function v(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function O(t){await mkdir(t,{recursive:true});}async function N(t,e){let r;try{r=await realpath(t);}catch(o){let i=o;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="ELOOP")return [];throw new Be(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:o,errnoCode:i.code})}let n=e??new Set;if(n.has(r))return [];n.add(r);try{let o=await readdir(t,{withFileTypes:!0}),i=[];for(let a of o){let c=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(c).then(m=>m.isDirectory(),()=>!1)?i.push(...await N(c,n)):i.push(c);}return i}catch(o){let i=o;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="EACCES")return [];throw new Be(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:o,errnoCode:i.code})}}async function Py(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 by,LT,bT,A=d(()=>{qn();by="\uFEFF",LT=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),bT=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(AT,"shouldNormalizeLineEndings");s(xT,"normalizeLineEndings");s(y,"readFileSafe");s(S,"writeFileAtomic");s(v,"exists");s(O,"mkdirp");s(N,"readDirRecursive");s(Py,"ensureCacheSymlink");});function He(t){return qp.includes(t)}var qp,Ty=d(()=>{qp=["amp","antigravity","claude-code","cline","codex-cli","continue","copilot","cursor","gemini-cli","goose","junie","kilo-code","kiro","opencode","roo-code","warp","windsurf","zed"];s(He,"isBuiltinTargetId");});var it,Ra,ze=d(()=>{Ty();it=qp,Ra="codex-cli";});var Dy,Re,Zs,Oa,PT,TT,ka,DT,NT,jo,ln=d(()=>{ze();Dy=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],Re=z$1.enum(it),Zs=z$1.enum(Dy),Oa=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(),PT=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:Re.optional(),features:z$1.array(Zs),path:z$1.string().optional(),pick:Oa.optional()}),TT=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),ka=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),DT=z$1.object({commands_to_skills:z$1.object({"codex-cli":ka.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":ka.optional(),cline:ka.optional(),"codex-cli":ka.optional(),windsurf:ka.optional()}).passthrough().optional()}).strict().optional(),NT=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional()}).strict(),jo=z$1.object({version:z$1.literal(1),targets:z$1.array(Re).default([...it]),features:z$1.array(Zs).default([...Dy]),extends:z$1.array(PT).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:TT.default({strategy:"merge",lock_features:[]}),conversions:DT,plugins:z$1.array(NT).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function MT(t){let e=resolve(t);for(;;){let r=join(e,tu);if(await v(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}async function $T(t){let e=await y(t);if(e===null)throw new We(t);let r=parse(e),n=jo.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new Ys(t,o,{cause:n.error})}return n.data}function Qp(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null)continue;let i=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[n]=Qp(i,o):r[n]=o;}return r}function GT(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=Qp(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Qp(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function nl(t){let e=join(t,tu),r=await $T(e),n=join(t,vT),o=await y(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=GT(r,i),c=jo.safeParse(a);if(c.success)r=c.data;else {let l=c.error.issues.map(m=>m.message).join("; ");I.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${l}. Using project config instead.`);}}}return {config:r,configDir:t}}async function ol(t){let e=await MT(t);if(e===null)throw new We(join(t,tu));return nl(dirname(e))}var tu,vT,sl=d(()=>{A();nt();qn();ln();tu="agentsmesh.yaml",vT="agentsmesh.local.yaml";s(MT,"findConfigPath");s($T,"loadConfig");s(Qp,"deepMergeObjects");s(GT,"mergeLocalConfig");s(nl,"loadConfigFromExactDir");s(ol,"loadConfigFromDir");});function wa(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 lt(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await ol(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=wa(t,e);try{let{config:n}=await nl(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof We?new We(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 le=d(()=>{sl();qn();s(wa,"resolveScopeContext");s(lt,"loadScopedConfig");});async function il(t,e,r,n,o){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,c=t.ref??"HEAD",l=o(i,a,c),m=join(n,l),p=join(m,vy),u=`${m}.tmp`,f=join(u,vy);if(!r.refresh&&await My(p))return ou(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await JT(VT(t),f),t.ref&&await YT(f,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),ou(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await My(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),ou(p);throw g}}async function ou(t){return {resolvedPath:t,version:await XT(t)}}async function My(t){return v(t)}function VT(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 JT(t,e){await su(["clone",t,e]);}async function YT(t,e){await su(["checkout",e],t);}async function XT(t){return su(["rev-parse","HEAD"],t)}async function su(t,e){let{stdout:r}=await zT("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var zT,vy,iu=d(()=>{A();zT=promisify(execFile),vy="repo";s(il,"fetchGitRemoteExtend");s(ou,"readCachedRepo");s(My,"hasCachedRepo");s(VT,"resolveCloneUrl");s(JT,"cloneRepo");s(YT,"checkoutRef");s(XT,"getHeadSha");s(su,"runGit");});async function Uy(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 Ky(t,e,r,n,o,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,c=r.refresh===true,l=t.tag;if(l==="latest")try{l=await Uy(t.org,t.repo,a);}catch(_){if(!i)throw _;return eD(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,l),p=join(n,m);if(!c&&await v(p)){let _=await au(p);if(_)return {resolvedPath:join(p,_),version:l}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${l}`,f={};a&&(f.Authorization=`Bearer ${a}`);let g;try{let _=await globalThis.fetch(u,{headers:f,redirect:"follow"});if(!_.ok)throw new Error(`HTTP ${_.status}: ${_.statusText}`);g=await _.arrayBuffer();}catch(_){if(r.allowOfflineFallback!==false&&await v(p)){let T=await au(p);if(T)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${_ instanceof Error?_.message:String(_)}`),{resolvedPath:join(p,T),version:l}}throw _}await rm$1(p,{recursive:true,force:true}),await mkdir(p,{recursive:true});let h=join(p,"archive.tar.gz");await writeFile(h,new Uint8Array(g));try{await jy.extract({file:h,cwd:p,strict:!0,filter:s((_,E)=>!(tD(_)||E&&"type"in E&&(E.type==="Link"||E.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let R=await au(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:l}}async function au(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}function Gy(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function tD(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function eD(t,e,r,n,o,i){let a=i?[Gy(t.org,t.repo,i)]:[Gy(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],c;for(let l of a){let m={url:l};try{return await il(m,e,r,n,o)}catch(p){c=p;}}throw c instanceof Error?c:new Error("Failed to clone GitHub default branch")}var Wy=d(()=>{A();iu();s(Uy,"resolveLatestTag");s(Ky,"fetchGithubRemoteExtend");s(au,"findExtractTopDir");s(Gy,"buildGithubCloneUrl");s(tD,"isZipSlipPath");s(eD,"fetchGithubDefaultBranch");});function By(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 Hy(t){let e=By(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 zy(t){let e=By(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 Vy(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),n=(r<0?e:e.slice(0,r)).trim(),o=r<0?void 0:e.slice(r+1).trim();if(!n||r>=0&&!o)return null;let i;try{i=new URL(n);}catch{return null}return ["https:","http:","ssh:","file:"].includes(i.protocol)?{url:n,ref:o}:null}function Uo(t){let e=Hy(t);if(e)return {kind:"github",...e};let r=zy(t);if(r)return {kind:"gitlab",...r};let n=Vy(t);return n?{kind:"git",...n}:null}function cu(t){return Uo(t)!==null}var La=d(()=>{s(By,"splitSourceRef");s(Hy,"parseGithubSource");s(zy,"parseGitlabSource");s(Vy,"parseGitSource");s(Uo,"parseRemoteSource");s(cu,"isSupportedRemoteSource");});function sD(t){let e=Uo(t);return e?e.kind==="github"?qs("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?qs("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):qs("git",e.url,e.ref??"HEAD"):null}async function Xy(t,e){let r=sD(t);if(!r)return;let n=e??me(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}async function Zy(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 c=join(r,a);try{let{mtimeMs:l}=await stat(c);i-l>n&&await rm$1(c,{recursive:!0,force:!0});}catch{}}));}var lu=d(()=>{ba();La();s(sD,"cacheKeyFromSource");s(Xy,"cleanInstallCache");s(Zy,"sweepStaleCache");});function qs(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>qy){let i=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,qy-18)}--${i}`;}return o}function me(){let t=process.env.AGENTSMESH_CACHE;return t||join(homedir(),".agentsmesh","cache")}async function Qs(t,e,r={}){let n=Uo(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 Zy(o).catch(()=>{}),n.kind==="github"?Ky(n,e,r,o,qs,!t.includes("@")):il(n,e,r,o,qs)}var qy,ba=d(()=>{iu();Wy();La();lu();qy=80;s(qs,"buildCacheKey");s(me,"getCacheDir");s(Qs,"fetchRemoteExtend");});function uD(t){return t.startsWith("http://")||t.startsWith("https://")}async function ti(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>cu(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(uD(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(cu(o.source)){let a=await Qs(o.source,o.name,{cacheDir:me(),refresh:r.refreshCache===true});n.push({name:o.name,resolvedPath:a.resolvedPath,features:[...o.features],target:o.target,version:a.version,path:o.path,pick:o.pick});continue}let i=resolve(e,o.source);if(!await v(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,path:o.path,pick:o.pick});}return n}var al=d(()=>{A();ba();La();s(uD,"isOtherRemoteSource");s(ti,"resolveExtendPaths");});function w(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let n=t.slice(3,r).trim(),o=t.slice(r+3).trim();return {frontmatter:n===""?{}:parse(n)??{},body:o}}function F(t,e){return Object.keys(t).length===0?e:`---
12
12
  ${stringify(t,{lineWidth:0}).trimEnd()}
13
13
  ---
14
14
 
15
- ${e}`}var M=d(()=>{s(w,"parseFrontmatter");s(F,"serializeFrontmatter");});function t_(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function Ko(t){let r=(await N(t)).filter(o=>{if(!o.endsWith(".md"))return false;let i=basename(o,".md");return i==="_root"||!i.startsWith("_")}),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:c}=w(i),m=basename(o,".md")==="_root",p=a.root===true,u=a.trigger,f=typeof u=="string"&&uD.includes(u)?u:void 0,g=a.codex_emit,h=g==="execution"?"execution":g==="advisory"?"advisory":void 0,C=a.codex_instruction==="override"?"override":void 0;n.push({source:o,root:m||p,targets:t_(a.targets),description:typeof a.description=="string"?a.description:"",globs:t_(a.globs),body:c,...f!==void 0&&{trigger:f},...h!==void 0&&{codexEmit:h},...C!==void 0&&{codexInstructionVariant:C}});}return n}var uD,al=d(()=>{A();M();uD=["always_on","model_decision","glob","manual"];s(t_,"toStrArray");s(Ko,"parseRules");});function r_(t){return t===true||t==="true"||t===1||t==="1"}function n_(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 Wo(t){let r=(await N(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(o,".md"),m=n_(a.allowedTools),p=n_(a["allowed-tools"]),u=m.length>0?m:p;n.push({source:o,name:l,description:typeof a.description=="string"?a.description:"",allowedTools:u,outputStyle:r_(a.outputStyle)||r_(a["output-style"]),body:c});}return n}var cl=d(()=>{A();M();s(r_,"toBool");s(n_,"toToolsArray");s(Wo,"parseCommands");});function Bo(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function s_(t){return t===true||t==="true"||t===1||t==="1"}function i_(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 dD(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function Ho(t){let r=(await N(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(o,".md"),m=Bo(a.tools),p=Bo(a.tools),u=m.length>0?m:p,f=Bo(a.disallowedTools),g=Bo(a["disallowed-tools"]),h=f.length>0?f:g,R=Bo(a.mcpServers),C=Bo(a["mcp-servers"]),_=R.length>0?R:C,E=Bo(a.skills),T=i_(a.maxTurns),D=i_(a["max-turns"]),x=T>0?T:D>0?D:0;n.push({source:o,name:l,description:typeof a.description=="string"?a.description:"",tools:u,disallowedTools:h,model:typeof a.model=="string"?a.model:"",permissionMode:typeof a.permissionMode=="string"?a.permissionMode:typeof a["permission-mode"]=="string"?a["permission-mode"]:"",maxTurns:x,mcpServers:_,hooks:dD(a.hooks),skills:E,memory:typeof a.memory=="string"?a.memory:"",outputStyle:s_(a.outputStyle)||s_(a["output-style"]),body:c});}return n}var ll=d(()=>{A();M();s(Bo,"toStrArray");s(s_,"toBool");s(i_,"toInt");s(dD,"toHooks");s(Ho,"parseAgents");});async function hD(t){return await y(t)??""}function _D(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function a_(t){let e=await N(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===ml||i.endsWith(`/${ml}`))continue;let a=i.split("/")[0];if(yD.some(l=>a===l)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let c=await hD(n);r.push({relativePath:i,absolutePath:n,content:c});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}async function c_(t){let e=join(t,ml),r=await y(e);if(!r)return null;let{frontmatter:n,body:o}=w(r),i=await a_(t),a=typeof n.name=="string"?_D(n.name):"";return {source:e,name:a||basename(t),description:typeof n.description=="string"?n.description:"",body:o,supportingFiles:i}}async function ei(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory()||n.name.startsWith("_"))continue;let o=join(t,n.name),i=join(o,ml),a=await y(i);if(!a)continue;let{frontmatter:c,body:l}=w(a),m=await a_(o);r.push({source:i,name:n.name,description:typeof c.description=="string"?c.description:"",body:l,supportingFiles:m});}return r.sort((n,o)=>n.name.localeCompare(o.name))}var ml,yD,pl=d(()=>{A();M();s(hD,"readContent");ml="SKILL.md",yD=[".git","node_modules"];s(_D,"sanitizeSkillName");s(a_,"listSupportingFiles");s(c_,"parseSkillDirectory");s(ei,"parseSkills");});function l_(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function ID(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=l_(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:l_(e.headers),env:n};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let c=Array.isArray(e.args)?e.args.filter(l=>typeof l=="string"):[];return {...o!==void 0&&{description:o},type:r,command:a,args:c,env:n}}function CD(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 Ve(t){let e=await y(t);if(!e)return null;let r;try{r=JSON.parse(CD(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 c=ID(a);c&&(o[i]=c);}return {mcpServers:o}}var ba=d(()=>{A();s(l_,"parseStringMap");s(ID,"parseServer");s(CD,"stripJsonComments");s(Ve,"parseMcp");});function pu(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function ul(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=pu(n.allow),i=pu(n.deny),a=pu(n.ask);return {allow:o,deny:i,ask:a}}var uu=d(()=>{A();s(pu,"ensureStringArray");s(ul,"parsePermissions");});function m_(t){return typeof t=="string"?t.trim():""}function wt(t){return m_(t.command)}function Yt(t){return m_(t.prompt)}function du(t){let e=wt(t),r=Yt(t);return t.type==="prompt"?r||e:e||r}function mn(t){return wt(t).length>0}function Or(t){return du(t).length>0}var Je=d(()=>{s(m_,"trimString");s(wt,"getHookCommand");s(Yt,"getHookPrompt");s(du,"getHookText");s(mn,"hasHookCommand");s(Or,"hasHookText");});function OD(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=du(e);if(!n)return null;let o=typeof e.type=="string"&&kD.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=Yt(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}async function dl(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n={},o=r;for(let[i,a]of Object.entries(o)){if(!Array.isArray(a))continue;let c=[];for(let l of a){let m=OD(l);m&&c.push(m);}c.length>0&&(n[i]=c);}return n}var kD,fu=d(()=>{A();Je();kD=["command","prompt"];s(OD,"toHookEntry");s(dl,"parseHooks");});async function fl(t){let e=await y(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 gu=d(()=>{A();s(fl,"parseIgnore");});async function pe(t){let e=join(t,".agentsmesh"),r=await v(e)?e:t,[n,o,i,a,c,l,m,p]=await Promise.all([Ko(join(r,"rules")),Wo(join(r,"commands")),Ho(join(r,"agents")),ei(join(r,"skills")),Ve(join(r,"mcp.json")),ul(join(r,"permissions.yaml")),dl(join(r,"hooks.yaml")),fl(join(r,"ignore"))]);return {rules:n,commands:o,agents:i,skills:a,mcp:c,permissions:l,hooks:m,ignore:p}}var zo=d(()=>{al();cl();ll();pl();ba();uu();fu();gu();A();s(pe,"loadCanonicalFiles");});function p_(t){return basename(t.source,".md")}function ri(t,e){let r=new Map(t.rules.map(p=>[p_(p),p]));for(let p of e.rules)r.set(p_(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=ED(t.mcp,e.mcp),c=LD(t.permissions,e.permissions),l=bD(t.hooks,e.hooks),m=AD(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:c,hooks:l,ignore:m}}function ED(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}function LD(t,e){if(!t&&!e)return null;let r=hu(t?.allow??[],e?.allow??[]),n=hu(t?.deny??[],e?.deny??[]),o=hu(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}function hu(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 bD(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 AD(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 yu=d(()=>{s(p_,"ruleSlug");s(ri,"mergeCanonicalFiles");s(ED,"mergeMcp");s(LD,"mergePermissions");s(hu,"mergeUniqueStrings");s(bD,"mergeHooks");s(AD,"mergeIgnore");});async function gl(t){let e=null,r=0;for(let n of u_){let o=0;for(let i of n.paths)await v(join(t,i))&&o++;o>r&&(r=o,e=n.target);}return r>0?e:null}var u_,d_,_u=d(()=>{A();u_=[{target:"claude-code",paths:["CLAUDE.md",".claude/rules",".claude/commands",".claude/agents",".claude/skills",".claude/settings.json",".claudeignore"]},{target:"cursor",paths:[".cursorrules",".cursor/rules",".cursor",".cursor/mcp.json"]},{target:"copilot",paths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]},{target:"gemini-cli",paths:["GEMINI.md",".gemini",".gemini/settings.json"]},{target:"codex-cli",paths:[".codex",".codex/config.toml","AGENTS.md","codex.md"]},{target:"windsurf",paths:[".windsurfrules",".windsurf",".windsurf/workflows"]},{target:"cline",paths:[".clinerules",".cline"]},{target:"continue",paths:[".continue",".continuerc.json"]},{target:"junie",paths:[".junie",".junie/guidelines.md"]},{target:"kiro",paths:[".kiro",".kiro/steering",".kiro/settings/mcp.json"]},{target:"kilo-code",paths:[".kilo",".kilo/rules",".kilo/commands",".kilo/agents",".kilo/skills",".kilocodeignore",".kilocode",".kilocodemodes","kilo.jsonc","kilo.json"]}];s(gl,"detectNativeFormat");d_=u_.map(t=>t.paths[0]).filter(t=>t!==void 0);});function Y(t){return t.includes("\\")||Ye.test(t)?win32:posix}function pt(t){return t.replace(/\\/g,"/")}function K(t,e){let r=Y(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):pt(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function g_(t,e){return Y(t).isAbsolute(e)||Ye.test(e)}function ni(t){let e=t,r="";for(;TD.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function h_(t,e){let r=Y(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?K(e,r.join(e,n)):null}var Ye,TD,Wt=d(()=>{Ye=/^[A-Za-z]:[\\/]/,TD=/[.!?:;]+$/;s(Y,"pathApi");s(pt,"normalizeSeparators");s(K,"normalizeForProject");s(g_,"isAbsoluteForProject");s(ni,"stripTrailingPunctuation");s(h_,"rootFallbackPath");});function DD(t){return Object.prototype.hasOwnProperty.call(y_,t)}function ND(t){return Object.prototype.hasOwnProperty.call(__,t)}function I_(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function oi(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=I_(o,n);return i!==void 0?i:DD(e)?y_[e]:r??false}function ke(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],i=I_(o,n);return i!==void 0?i:ND(e)?__[e]:r??false}var y_,__,si=d(()=>{y_={amp:true,"codex-cli":true,goose:true,kiro:true,warp:true},__={amp:true,"gemini-cli":false,cline:true,"codex-cli":false,windsurf:true,goose:true,antigravity:true,continue:true,warp:true};s(DD,"usesCommandSkillProjection");s(ND,"usesAgentSkillProjection");s(I_,"resolveConversionValue");s(oi,"shouldConvertCommandsToSkills");s(ke,"shouldConvertAgentsToSkills");});function Ze(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Xe(t){return typeof t=="string"?{level:t}:t}function C_(t){return {rules:Xe(t.rules),additionalRules:Xe(t.additionalRules),commands:Xe(t.commands),agents:Xe(t.agents),skills:Xe(t.skills),mcp:Xe(t.mcp),hooks:Xe(t.hooks),ignore:Xe(t.ignore),permissions:Xe(t.permissions)}}var Vo=d(()=>{s(Ze,"cap");s(Xe,"normalizeCapabilityValue");s(C_,"normalizeTargetCapabilities");});function S_(t){for(let e of Ft)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function FD(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 R_(t){let e=FD(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 M=d(()=>{s(w,"parseFrontmatter");s(F,"serializeFrontmatter");});function t_(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function Ko(t){let r=(await N(t)).filter(o=>{if(!o.endsWith(".md"))return false;let i=basename(o,".md");return i==="_root"||!i.startsWith("_")}),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:c}=w(i),m=basename(o,".md")==="_root",p=a.root===true,u=a.trigger,f=typeof u=="string"&&gD.includes(u)?u:void 0,g=a.codex_emit,h=g==="execution"?"execution":g==="advisory"?"advisory":void 0,C=a.codex_instruction==="override"?"override":void 0;n.push({source:o,root:m||p,targets:t_(a.targets),description:typeof a.description=="string"?a.description:"",globs:t_(a.globs),body:c,...f!==void 0&&{trigger:f},...h!==void 0&&{codexEmit:h},...C!==void 0&&{codexInstructionVariant:C}});}return n}var gD,cl=d(()=>{A();M();gD=["always_on","model_decision","glob","manual"];s(t_,"toStrArray");s(Ko,"parseRules");});function r_(t){return t===true||t==="true"||t===1||t==="1"}function n_(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 Wo(t){let r=(await N(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(o,".md"),m=n_(a.allowedTools),p=n_(a["allowed-tools"]),u=m.length>0?m:p;n.push({source:o,name:l,description:typeof a.description=="string"?a.description:"",allowedTools:u,outputStyle:r_(a.outputStyle)||r_(a["output-style"]),body:c});}return n}var ll=d(()=>{A();M();s(r_,"toBool");s(n_,"toToolsArray");s(Wo,"parseCommands");});function Bo(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function s_(t){return t===true||t==="true"||t===1||t==="1"}function i_(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 hD(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function Ho(t){let r=(await N(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:c}=w(i),l=basename(o,".md"),m=Bo(a.tools),p=Bo(a.tools),u=m.length>0?m:p,f=Bo(a.disallowedTools),g=Bo(a["disallowed-tools"]),h=f.length>0?f:g,R=Bo(a.mcpServers),C=Bo(a["mcp-servers"]),_=R.length>0?R:C,E=Bo(a.skills),T=i_(a.maxTurns),D=i_(a["max-turns"]),x=T>0?T:D>0?D:0;n.push({source:o,name:l,description:typeof a.description=="string"?a.description:"",tools:u,disallowedTools:h,model:typeof a.model=="string"?a.model:"",permissionMode:typeof a.permissionMode=="string"?a.permissionMode:typeof a["permission-mode"]=="string"?a["permission-mode"]:"",maxTurns:x,mcpServers:_,hooks:hD(a.hooks),skills:E,memory:typeof a.memory=="string"?a.memory:"",outputStyle:s_(a.outputStyle)||s_(a["output-style"]),body:c});}return n}var ml=d(()=>{A();M();s(Bo,"toStrArray");s(s_,"toBool");s(i_,"toInt");s(hD,"toHooks");s(Ho,"parseAgents");});async function ID(t){return await y(t)??""}function SD(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function a_(t){let e=await N(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===pl||i.endsWith(`/${pl}`))continue;let a=i.split("/")[0];if(CD.some(l=>a===l)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let c=await ID(n);r.push({relativePath:i,absolutePath:n,content:c});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}async function c_(t){let e=join(t,pl),r=await y(e);if(!r)return null;let{frontmatter:n,body:o}=w(r),i=await a_(t),a=typeof n.name=="string"?SD(n.name):"";return {source:e,name:a||basename(t),description:typeof n.description=="string"?n.description:"",body:o,supportingFiles:i}}async function ei(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory()||n.name.startsWith("_"))continue;let o=join(t,n.name),i=join(o,pl),a=await y(i);if(!a)continue;let{frontmatter:c,body:l}=w(a),m=await a_(o);r.push({source:i,name:n.name,description:typeof c.description=="string"?c.description:"",body:l,supportingFiles:m});}return r.sort((n,o)=>n.name.localeCompare(o.name))}var pl,CD,ul=d(()=>{A();M();s(ID,"readContent");pl="SKILL.md",CD=[".git","node_modules"];s(SD,"sanitizeSkillName");s(a_,"listSupportingFiles");s(c_,"parseSkillDirectory");s(ei,"parseSkills");});function l_(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function RD(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=l_(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:l_(e.headers),env:n};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let c=Array.isArray(e.args)?e.args.filter(l=>typeof l=="string"):[];return {...o!==void 0&&{description:o},type:r,command:a,args:c,env:n}}function kD(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 Ve(t){let e=await y(t);if(!e)return null;let r;try{r=JSON.parse(kD(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 c=RD(a);c&&(o[i]=c);}return {mcpServers:o}}var Aa=d(()=>{A();s(l_,"parseStringMap");s(RD,"parseServer");s(kD,"stripJsonComments");s(Ve,"parseMcp");});function pu(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function dl(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=pu(n.allow),i=pu(n.deny),a=pu(n.ask);return {allow:o,deny:i,ask:a}}var uu=d(()=>{A();s(pu,"ensureStringArray");s(dl,"parsePermissions");});function m_(t){return typeof t=="string"?t.trim():""}function wt(t){return m_(t.command)}function Yt(t){return m_(t.prompt)}function du(t){let e=wt(t),r=Yt(t);return t.type==="prompt"?r||e:e||r}function mn(t){return wt(t).length>0}function Or(t){return du(t).length>0}var Je=d(()=>{s(m_,"trimString");s(wt,"getHookCommand");s(Yt,"getHookPrompt");s(du,"getHookText");s(mn,"hasHookCommand");s(Or,"hasHookText");});function LD(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=du(e);if(!n)return null;let o=typeof e.type=="string"&&ED.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=Yt(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}async function fl(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n={},o=r;for(let[i,a]of Object.entries(o)){if(!Array.isArray(a))continue;let c=[];for(let l of a){let m=LD(l);m&&c.push(m);}c.length>0&&(n[i]=c);}return n}var ED,fu=d(()=>{A();Je();ED=["command","prompt"];s(LD,"toHookEntry");s(fl,"parseHooks");});async function gl(t){let e=await y(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 gu=d(()=>{A();s(gl,"parseIgnore");});async function pe(t){let e=join(t,".agentsmesh"),r=await v(e)?e:t,[n,o,i,a,c,l,m,p]=await Promise.all([Ko(join(r,"rules")),Wo(join(r,"commands")),Ho(join(r,"agents")),ei(join(r,"skills")),Ve(join(r,"mcp.json")),dl(join(r,"permissions.yaml")),fl(join(r,"hooks.yaml")),gl(join(r,"ignore"))]);return {rules:n,commands:o,agents:i,skills:a,mcp:c,permissions:l,hooks:m,ignore:p}}var zo=d(()=>{cl();ll();ml();ul();Aa();uu();fu();gu();A();s(pe,"loadCanonicalFiles");});function p_(t){return basename(t.source,".md")}function ri(t,e){let r=new Map(t.rules.map(p=>[p_(p),p]));for(let p of e.rules)r.set(p_(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=AD(t.mcp,e.mcp),c=xD(t.permissions,e.permissions),l=PD(t.hooks,e.hooks),m=TD(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:c,hooks:l,ignore:m}}function AD(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}function xD(t,e){if(!t&&!e)return null;let r=hu(t?.allow??[],e?.allow??[]),n=hu(t?.deny??[],e?.deny??[]),o=hu(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}function hu(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 PD(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 TD(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 yu=d(()=>{s(p_,"ruleSlug");s(ri,"mergeCanonicalFiles");s(AD,"mergeMcp");s(xD,"mergePermissions");s(hu,"mergeUniqueStrings");s(PD,"mergeHooks");s(TD,"mergeIgnore");});async function hl(t){let e=null,r=0;for(let n of u_){let o=0;for(let i of n.paths)await v(join(t,i))&&o++;o>r&&(r=o,e=n.target);}return r>0?e:null}var u_,d_,_u=d(()=>{A();u_=[{target:"claude-code",paths:["CLAUDE.md",".claude/rules",".claude/commands",".claude/agents",".claude/skills",".claude/settings.json",".claudeignore"]},{target:"cursor",paths:[".cursorrules",".cursor/rules",".cursor",".cursor/mcp.json"]},{target:"copilot",paths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]},{target:"gemini-cli",paths:["GEMINI.md",".gemini",".gemini/settings.json"]},{target:"codex-cli",paths:[".codex",".codex/config.toml","AGENTS.md","codex.md"]},{target:"windsurf",paths:[".windsurfrules",".windsurf",".windsurf/workflows"]},{target:"cline",paths:[".clinerules",".cline"]},{target:"continue",paths:[".continue",".continuerc.json"]},{target:"junie",paths:[".junie",".junie/guidelines.md"]},{target:"kiro",paths:[".kiro",".kiro/steering",".kiro/settings/mcp.json"]},{target:"kilo-code",paths:[".kilo",".kilo/rules",".kilo/commands",".kilo/agents",".kilo/skills",".kilocodeignore",".kilocode",".kilocodemodes","kilo.jsonc","kilo.json"]}];s(hl,"detectNativeFormat");d_=u_.map(t=>t.paths[0]).filter(t=>t!==void 0);});function Y(t){return t.includes("\\")||Ye.test(t)?win32:posix}function pt(t){return t.replace(/\\/g,"/")}function K(t,e){let r=Y(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):pt(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function g_(t,e){return Y(t).isAbsolute(e)||Ye.test(e)}function ni(t){let e=t,r="";for(;FD.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function h_(t,e){let r=Y(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?K(e,r.join(e,n)):null}var Ye,FD,Wt=d(()=>{Ye=/^[A-Za-z]:[\\/]/,FD=/[.!?:;]+$/;s(Y,"pathApi");s(pt,"normalizeSeparators");s(K,"normalizeForProject");s(g_,"isAbsoluteForProject");s(ni,"stripTrailingPunctuation");s(h_,"rootFallbackPath");});function vD(t){return Object.prototype.hasOwnProperty.call(y_,t)}function MD(t){return Object.prototype.hasOwnProperty.call(__,t)}function I_(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function oi(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=I_(o,n);return i!==void 0?i:vD(e)?y_[e]:r??false}function ke(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],i=I_(o,n);return i!==void 0?i:MD(e)?__[e]:r??false}var y_,__,si=d(()=>{y_={amp:true,"codex-cli":true,goose:true,kiro:true,warp:true},__={amp:true,"gemini-cli":false,cline:true,"codex-cli":false,windsurf:true,goose:true,antigravity:true,continue:true,warp:true};s(vD,"usesCommandSkillProjection");s(MD,"usesAgentSkillProjection");s(I_,"resolveConversionValue");s(oi,"shouldConvertCommandsToSkills");s(ke,"shouldConvertAgentsToSkills");});function Ze(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Xe(t){return typeof t=="string"?{level:t}:t}function C_(t){return {rules:Xe(t.rules),additionalRules:Xe(t.additionalRules),commands:Xe(t.commands),agents:Xe(t.agents),skills:Xe(t.skills),mcp:Xe(t.mcp),hooks:Xe(t.hooks),ignore:Xe(t.ignore),permissions:Xe(t.permissions)}}var Vo=d(()=>{s(Ze,"cap");s(Xe,"normalizeCapabilityValue");s(C_,"normalizeTargetCapabilities");});function S_(t){for(let e of Ft)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function $D(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 R_(t){let e=$D(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 Iu=d(()=>{ut();s(S_,"ownerTargetIdForSharedPath");s(FD,"findSharedArtifactOwnershipConflicts");s(R_,"assertSharedArtifactOwnersUnique");});function vD(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 st(t){return `${ii}${t}`}function wr(t){let e={name:st(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"],F(e,t.body.trim()||"")}function hl(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(ii)?e.slice(ii.length):e.startsWith(Aa)?e.slice(Aa.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:vD(t["x-agentsmesh-allowed-tools"])}:null}function yl(t,e){return F({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var ii,Aa,ne=d(()=>{M();ii="am-command-",Aa="ab-command-";s(vD,"toStringArray");s(st,"commandSkillDirName");s(wr,"serializeCommandSkill");s(hl,"parseCommandSkillFrontmatter");s(yl,"serializeImportedCommand");});function _l(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){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 V(t){return `${ai}${t}`}function oe(t){let e={name:V(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];}),F(e,t.body.trim()||"")}function Er(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(ai)?e.slice(ai.length):e.startsWith(xa)?e.slice(xa.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:_l(t["x-agentsmesh-tools"]),disallowedTools:_l(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:_l(t["x-agentsmesh-mcp-servers"]),hooks:MD(t["x-agentsmesh-hooks"]),skills:_l(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function Oe(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];}),F(r,e.trim()||"")}var ai,xa,dt=d(()=>{M();ai="am-agent-",xa="ab-agent-";s(_l,"toStringArray");s(MD,"toHooks");s(V,"projectedAgentSkillDirName");s(oe,"serializeProjectedAgentSkill");s(Er,"parseProjectedAgentSkillFrontmatter");s(Oe,"serializeImportedAgent");});function Pa(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cu(t,e){return new RegExp(`${Pa(t)}[\\s\\S]*?${Pa(e)}`,"g")}function L_(t,e,r,n){let o=Cu(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 Iu=d(()=>{ut();s(S_,"ownerTargetIdForSharedPath");s($D,"findSharedArtifactOwnershipConflicts");s(R_,"assertSharedArtifactOwnersUnique");});function GD(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 st(t){return `${ii}${t}`}function wr(t){let e={name:st(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"],F(e,t.body.trim()||"")}function yl(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(ii)?e.slice(ii.length):e.startsWith(xa)?e.slice(xa.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:GD(t["x-agentsmesh-allowed-tools"])}:null}function _l(t,e){return F({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var ii,xa,ne=d(()=>{M();ii="am-command-",xa="ab-command-";s(GD,"toStringArray");s(st,"commandSkillDirName");s(wr,"serializeCommandSkill");s(yl,"parseCommandSkillFrontmatter");s(_l,"serializeImportedCommand");});function Il(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 jD(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 V(t){return `${ai}${t}`}function oe(t){let e={name:V(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];}),F(e,t.body.trim()||"")}function Er(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(ai)?e.slice(ai.length):e.startsWith(Pa)?e.slice(Pa.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:Il(t["x-agentsmesh-tools"]),disallowedTools:Il(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:Il(t["x-agentsmesh-mcp-servers"]),hooks:jD(t["x-agentsmesh-hooks"]),skills:Il(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function Oe(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];}),F(r,e.trim()||"")}var ai,Pa,dt=d(()=>{M();ai="am-agent-",Pa="ab-agent-";s(Il,"toStringArray");s(jD,"toHooks");s(V,"projectedAgentSkillDirName");s(oe,"serializeProjectedAgentSkill");s(Er,"parseProjectedAgentSkillFrontmatter");s(Oe,"serializeImportedAgent");});function Ta(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cu(t,e){return new RegExp(`${Ta(t)}[\\s\\S]*?${Ta(e)}`,"g")}function L_(t,e,r,n){let o=Cu(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 Su(t,e,r){return t.replace(Cu(e,r),"").trim()}function jD(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 UD(t){return {source:jD(t.source),description:t.description,globs:t.globs,targets:t.targets}}function KD(t){return `${w_}${JSON.stringify(UD(t))}${E_}`}function WD(t){let e=[KD(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),O_),e.filter(r=>r.length>0).join(`
22
- `)}function BD(t){return t.length===0?"":[Il,...t.map(WD),Cl].join(`
23
- `)}function Et(t,e){let r=BD(e),n=Su(t,Il,Cl);return r?n?`${n}
21
+ ${n}`:n}function Su(t,e,r){return t.replace(Cu(e,r),"").trim()}function WD(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 BD(t){return {source:WD(t.source),description:t.description,globs:t.globs,targets:t.targets}}function HD(t){return `${w_}${JSON.stringify(BD(t))}${E_}`}function zD(t){let e=[HD(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),O_),e.filter(r=>r.length>0).join(`
22
+ `)}function VD(t){return t.length===0?"":[Cl,...t.map(zD),Sl].join(`
23
+ `)}function Et(t,e){let r=VD(e),n=Su(t,Cl,Sl);return r?n?`${n}
24
24
 
25
- ${r}`:r:n}function k_(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function HD(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:k_(r.globs),targets:k_(r.targets)}}catch{return null}}function zD(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 b_(t){let e=[],r=Cu(Il,Cl);return {rootContent:t.replace(r,o=>{let i=o.replace(Il,"").replace(Cl,"").trim(),a=new RegExp(`${Pa(w_)}([\\s\\S]*?)${Pa(E_)}([\\s\\S]*?)${Pa(O_)}`,"g");for(let c of i.matchAll(a)){let l=c[1],m=c[2];if(l===void 0||m===void 0)continue;let p=HD(l);p&&e.push({...p,body:zD(m,p.description)});}return ""}).trim(),rules:e}}var Ta,Da,Il,Cl,O_,w_,E_,we=d(()=>{Ta="<!-- agentsmesh:root-generation-contract:start -->",Da="<!-- agentsmesh:root-generation-contract:end -->",Il="<!-- agentsmesh:embedded-rules:start -->",Cl="<!-- agentsmesh:embedded-rules:end -->",O_="<!-- agentsmesh:embedded-rule:end -->",w_="<!-- agentsmesh:embedded-rule:start ",E_=" -->";s(Pa,"escapeRegExp");s(Cu,"managedBlockPattern");s(L_,"replaceManagedBlock");s(Su,"stripManagedBlock");s(jD,"ruleSource");s(UD,"markerForRule");s(KD,"embeddedRuleStart");s(WD,"renderRule");s(BD,"renderEmbeddedRulesBlock");s(Et,"appendEmbeddedRulesBlock");s(k_,"toStringArray");s(HD,"parseMarker");s(zD,"stripGeneratedHeading");s(b_,"extractEmbeddedRules");});function Ru(t){return t.replace(/\s+/g," ").trim()}function x_(t){let e=t.trim();if(e.includes(Ta)&&e.includes(Da))return L_(e,Ta,Da,ci);let r=Ru(e);if(r.includes(Ru(ci)))return e;for(let n of A_)if(r.includes(Ru(n)))return e.replace(n,ci);return e?`${e}
25
+ ${r}`:r:n}function k_(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function JD(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:k_(r.globs),targets:k_(r.targets)}}catch{return null}}function YD(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 b_(t){let e=[],r=Cu(Cl,Sl);return {rootContent:t.replace(r,o=>{let i=o.replace(Cl,"").replace(Sl,"").trim(),a=new RegExp(`${Ta(w_)}([\\s\\S]*?)${Ta(E_)}([\\s\\S]*?)${Ta(O_)}`,"g");for(let c of i.matchAll(a)){let l=c[1],m=c[2];if(l===void 0||m===void 0)continue;let p=JD(l);p&&e.push({...p,body:YD(m,p.description)});}return ""}).trim(),rules:e}}var Da,Na,Cl,Sl,O_,w_,E_,we=d(()=>{Da="<!-- agentsmesh:root-generation-contract:start -->",Na="<!-- agentsmesh:root-generation-contract:end -->",Cl="<!-- agentsmesh:embedded-rules:start -->",Sl="<!-- agentsmesh:embedded-rules:end -->",O_="<!-- agentsmesh:embedded-rule:end -->",w_="<!-- agentsmesh:embedded-rule:start ",E_=" -->";s(Ta,"escapeRegExp");s(Cu,"managedBlockPattern");s(L_,"replaceManagedBlock");s(Su,"stripManagedBlock");s(WD,"ruleSource");s(BD,"markerForRule");s(HD,"embeddedRuleStart");s(zD,"renderRule");s(VD,"renderEmbeddedRulesBlock");s(Et,"appendEmbeddedRulesBlock");s(k_,"toStringArray");s(JD,"parseMarker");s(YD,"stripGeneratedHeading");s(b_,"extractEmbeddedRules");});function Ru(t){return t.replace(/\s+/g," ").trim()}function x_(t){let e=t.trim();if(e.includes(Da)&&e.includes(Na))return L_(e,Da,Na,ci);let r=Ru(e);if(r.includes(Ru(ci)))return e;for(let n of A_)if(r.includes(Ru(n)))return e.replace(n,ci);return e?`${e}
26
26
 
27
- ${ci}`:ci}function P_(t){let e=Su(t,Ta,Da);e=e.replace(`
27
+ ${ci}`:ci}function P_(t){let e=Su(t,Da,Na);e=e.replace(`
28
28
 
29
29
  ${ci}`,"");for(let r of A_)e=e.replace(`
30
30
 
31
- ${r}`,"");return e.trim()}var ku,VD,JD,YD,XD,ZD,qD,QD,tN,eN,rN,nN,oN,sN,iN,aN,cN,ci,A_,Ou=d(()=>{we();ku="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.",VD="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.",JD="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.",YD="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.",XD="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`.",ZD="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`.",qD="`.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`.",QD="`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.",tN=ku,eN=`## Project-Specific Rules
31
+ ${r}`,"");return e.trim()}var ku,XD,ZD,qD,QD,tN,eN,rN,nN,oN,sN,iN,aN,cN,lN,mN,pN,ci,A_,Ou=d(()=>{we();ku="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.",XD="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.",ZD="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.",qD="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.",QD="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`.",tN="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`.",eN="`.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`.",rN="`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.",nN=ku,oN=`## Project-Specific Rules
32
32
 
33
- ${ku}`,rN=`## AgentsMesh Generation Contract
33
+ ${ku}`,sN=`## AgentsMesh Generation Contract
34
34
 
35
- ${ku}`,nN=`## AgentsMesh Generation Contract
35
+ ${ku}`,iN=`## AgentsMesh Generation Contract
36
36
 
37
- ${VD}`,oN=`## AgentsMesh Generation Contract
37
+ ${XD}`,aN=`## AgentsMesh Generation Contract
38
38
 
39
- ${JD}`,sN=`## AgentsMesh Generation Contract
39
+ ${ZD}`,cN=`## AgentsMesh Generation Contract
40
40
 
41
- ${YD}`,iN=`## AgentsMesh Generation Contract
41
+ ${qD}`,lN=`## AgentsMesh Generation Contract
42
42
 
43
- ${XD}`,aN=`## AgentsMesh Generation Contract
43
+ ${QD}`,mN=`## AgentsMesh Generation Contract
44
44
 
45
- ${ZD}`,cN=`## AgentsMesh Generation Contract
45
+ ${tN}`,pN=`## AgentsMesh Generation Contract
46
46
 
47
- ${qD}`,ci=`${Ta}
47
+ ${eN}`,ci=`${Da}
48
48
  ## AgentsMesh Generation Contract
49
49
 
50
- ${QD}
51
- ${Da}`;s(Ru,"normalizeWhitespace");A_=[cN,aN,iN,sN,oN,nN,rN,eN,tN];s(x_,"appendAgentsmeshRootInstructionParagraph");s(P_,"stripAgentsmeshRootInstructionParagraph");});function Xt(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 li(t){let e=await y(t);return e?w(e).frontmatter:{}}function vt(t,e){return typeof t[e]=="string"?t[e]:void 0}function wu(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function lN(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function mN(t,e){let r=basename(t,".md")==="_root",n={...e};return delete n.root,{root:r,...n}}async function j(t,e,r){let n=await li(t),o=basename(t,".md")==="_root"?P_(r):r.trim(),i=mN(t,lN({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=Xt(i.globs));for(let[c,l]of Object.entries(i))c==="root"||c==="description"||c==="globs"||l===void 0||(a[c]=l);return F(a,o||"")}var Eu=d(()=>{A();M();Ou();s(Xt,"toStringArray");s(li,"readExistingFrontmatter");s(vt,"readString");s(wu,"readHooks");s(lN,"pruneUndefined");s(mN,"serializeCanonicalRuleFrontmatter");s(j,"serializeImportedRuleWithFallback");});async function ot(t,e,r){let n=await li(t),o=(()=>{let c=Xt(n.allowedTools);return c.length>0?c:Xt(n["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return F({description:i,"allowed-tools":a},r.trim()||"")}async function Lr(t,e,r){let n=await li(t),o=basename(dirname(t)),i=vt(e,"name")??vt(n,"name")??o,a=vt(e,"description")??vt(n,"description")??"";return F({name:i,description:a},r.trim()||"")}async function Lt(t,e,r){let n=await li(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?Xt(e.tools):(()=>{let R=Xt(n.tools);return R.length>0?R:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?Xt(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?Xt(e["disallowed-tools"]):Xt(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?Xt(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?Xt(e["mcp-servers"]):Xt(n.mcpServers),c=Object.prototype.hasOwnProperty.call(e,"skills")?Xt(e.skills):Xt(n.skills),l=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof l=="number"?l:Number(l??0),p=wu(e)??wu(n),u={name:vt(e,"name")??vt(n,"name")??basename(t,".md"),description:vt(e,"description")??vt(n,"description")??"",tools:o};i.length>0&&(u.disallowedTools=i);let f=vt(e,"model")??vt(n,"model");f&&(u.model=f);let g=vt(e,"permissionMode")??vt(e,"permission-mode")??vt(n,"permissionMode")??vt(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),c.length>0&&(u.skills=c);let h=vt(e,"memory")??vt(n,"memory");return h&&(u.memory=h),F(u,r.trim()||"")}var N_=d(()=>{M();Eu();s(ot,"serializeImportedCommandWithFallback");s(Lr,"serializeImportedSkillWithFallback");s(Lt,"serializeImportedAgentWithFallback");});var et=d(()=>{Eu();N_();});function Sl(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 Ee(t){await rm$1(t,{recursive:true,force:true});}var mi=d(()=>{s(Sl,"shouldImportScopedAgentsRule");s(Ee,"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:F(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 yt(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 c=join(t,e,a.name),l=join(c,"SKILL.md"),m=await y(l);if(m===null)continue;let p=join(t,Na,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=w(o(m,l,u)),h=hl(f,a.name);if(h){await Ee(join(t,Na,a.name));let E=join(t,F_);await O(E);let T=join(E,`${h.name}.md`);await S(T,yl(h,o(g,l,T))),n.push({fromTool:r,fromPath:l,toPath:`${F_}/${h.name}.md`,feature:"commands"});continue}let R=Er(f,a.name);if(R){await Ee(join(t,Na,a.name));let E=join(t,v_);await O(E);let T=join(E,`${R.name}.md`);await S(T,Oe(R,o(g,l,T))),n.push({fromTool:r,fromPath:l,toPath:`${v_}/${R.name}.md`,feature:"agents"});continue}let C=await Lr(u,{...f,name:a.name},g);await O(p),await S(u,C),n.push({fromTool:r,fromPath:l,toPath:`${Na}/${a.name}/SKILL.md`,feature:"skills"});let _=await N(c);for(let E of _){if(E===l)continue;let T=relative(c,E).replace(/\\/g,"/"),D=await y(E);if(D===null)continue;let x=join(p,T);await O(dirname(x)),await S(x,o(D,E,x)),n.push({fromTool:r,fromPath:E,toPath:`${Na}/${a.name}/${T}`,feature:"skills"});}}}var Na,F_,v_,_t=d(()=>{A();M();et();dt();ne();mi();Na=".agentsmesh/skills",F_=".agentsmesh/commands",v_=".agentsmesh/agents";s(St,"generateEmbeddedSkills");s(yt,"importEmbeddedSkills");});var be,Bt,br,Lu,un,Ae,dn,M_,Jo=d(()=>{be="AGENTS.md",Bt=".agents/skills",br=".amp/settings.json",Lu=".config/amp",un=`${Lu}/AGENTS.md`,Ae=`${Lu}/skills`,dn=`${Lu}/settings.json`,M_=".agentsmesh/rules";});function $_(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=Et(n,r);return o?[{path:be,content:o}]:[]}function G_(t){return St(t,Bt)}function j_(t){return t.commands.map(e=>({path:`${Bt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function U_(t){return t.agents.map(e=>({path:`${Bt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}var K_=d(()=>{_t();we();dt();ne();Jo();s($_,"generateRules");s(G_,"generateSkills");s(j_,"generateCommands");s(U_,"generateAgents");});function at(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var ue=d(()=>{s(at,"mirrorSkillsToAgents");});async function Ht(t,e,r){let n=join(t,e),i={...await _N(n),...r};await O(dirname(n)),await S(n,JSON.stringify({mcpServers:i},null,2));}async function _N(t){let e=await y(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let 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 fn=d(()=>{A();s(Ht,"writeMcpWithMerge");s(_N,"readExistingServers");});function gn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function xe(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 pi(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function ui(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var Qe=d(()=>{s(gn,"toGlobsArray");s(xe,"toToolsArray");s(pi,"toStringArray");s(ui,"toStringRecord");});function SN(t,e){return e.some(r=>t.endsWith(r))}async function mt(t){let r=(await N(t.srcDir)).filter(o=>SN(o,t.extensions)),n=[];for(let o of r){let i=await y(o);if(!i)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),c=await t.mapEntry({srcPath:o,relativePath:a,content:i,normalizeTo:s((l,m=i)=>t.normalize(m,o,l),"normalizeTo")});c&&(await O(dirname(c.destPath)),await S(c.destPath,c.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:c.toPath,feature:c.feature}));}return n}var tr=d(()=>{A();s(SN,"matchesExtension");s(mt,"importFileDirectory");});function W_(t){return typeof t=="string"?t:void 0}function RN(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function Au(t,e){return e?e(t):t}function kN(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=w(e.normalizeTo(r)),i=Au(n,t.frontmatterRemap),a=RN({root:false,description:W_(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await j(r,a,o)}}}function ON(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=w(e.normalizeTo(r)),i=Au(n,t.frontmatterRemap),a=await ot(r,{hasDescription:true,description:W_(i.description),hasAllowedTools:true,allowedTools:pi(i["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function wN(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=w(e.normalizeTo(r)),i=Au(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Lt(r,i,o)}}}function B_(t){if(t.map)return t.map;switch(t.preset){case "rule":return kN(t);case "command":return ON(t);case "agent":return wN(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var H_=d(()=>{M();et();Qe();s(W_,"pickString");s(RN,"pruneUndefined");s(Au,"applyRemap");s(kN,"ruleMapper");s(ON,"commandMapper");s(wN,"agentMapper");s(B_,"resolveMapper");});function xu(t,e){return t?t[e]??[]:[]}var z_,V_=d(()=>{z_=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(xu,"resolveScopedSources");});async function bN(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 c=join(r,a),l=await y(c);if(l===null)continue;await O(i);let m=join(i,t.canonicalRootFilename),p=s(C=>o(l,c,C),"normalizeTo");if(t.map){let C=await t.map({absolutePath:c,relativePath:a,content:l,destDir:i,normalizeTo:p});if(!C)continue;return await S(C.destPath,C.content),[{fromTool:n,fromPath:c,toPath:C.toPath,feature:t.feature}]}let{frontmatter:u,body:f}=w(p(m)),g=t.frontmatterRemap?t.frontmatterRemap(u):u,h=t.markAsRoot?{...g,root:true}:g,R=await j(m,h,f);return await S(m,R),[{fromTool:n,fromPath:c,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function AN(t,e,r,n,o){let i=B_(t),a=join(r,t.canonicalDir),c=[];for(let l of e){let m=join(r,l),p=await mt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:s(async({srcPath:u,relativePath:f,content:g,normalizeTo:h})=>{let R=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(C=>h(C),"normalizeTo")});return R?{destPath:R.destPath,toPath:R.toPath,feature:t.feature,content:R.content}:null},"mapEntry")});c.push(...p);}return c}function Y_(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function xN(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=Y_(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=join(r,o);return await O(dirname(l)),await S(l,c.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function PN(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,c=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:pi(a.args),env:ui(a.env),description:c};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:ui(a.headers),env:ui(a.env),description:c});}return n}async function TN(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=Y_(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=PN(c);return Object.keys(l).length===0?[]:(await Ht(r,o,l),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function J_(t,e,r,n,o){switch(t.mode){case "singleFile":return bN(t,e,r,n,o);case "directory":return AN(t,e,r,n,o);case "flatFile":return xN(t,e,r,n);case "mcpJson":return TN(t,e,r,n)}}async function DN(t,e,r,n,o){let i=xu(t.source,e),a=xu(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let c=await J_(t,i,r,n,o);if(c.length>0)return c}return a.length>0?J_(t,a,r,n,o):[]}function NN(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function Q(t,e,r,n){let o=t.importer;if(!o)return [];let i=n?.normalize??await z(t.id,e,r),a=[];for(let c of z_)for(let l of NN(o,c))a.push(...await DN(l,r,e,t.id,i));return a}var Mt=d(()=>{It();A();fn();M();Qe();et();tr();H_();V_();s(bN,"runSingleFile");s(AN,"runDirectory");s(Y_,"resolveCanonicalFilePath");s(xN,"runFlatFile");s(PN,"parseMcpJson");s(TN,"runMcpJson");s(J_,"dispatchSpec");s(DN,"runSpec");s(NN,"specsForFeature");s(Q,"runDescriptorImport");});async function Z_(t,e,r){let n=await y(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 c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await Ht(t,X_,c),r.push({fromTool:"amp",fromPath:e,toPath:X_,feature:"mcp"}));}var X_,q_=d(()=>{A();fn();Jo();X_=".agentsmesh/mcp.json";s(Z_,"importAmpMcp");});async function Q_(t,e={}){let r=e.scope??"project",n=[],o=await z("amp",t,r);return n.push(...await Q(Rl,t,r,{normalize:o})),await yt(t,r==="global"?Ae:Bt,"amp",n,o),await Z_(t,r==="global"?dn:br,n),n}var tI=d(()=>{It();_t();Mt();q_();Jo();Pu();s(Q_,"importFromAmp");});function vN(t,e){return rI(e).some(n=>MN(t,n))}function eI(t,e){return t.filter(r=>vN(r,e))}function rI(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let i=n.split(",").map(c=>c.trim()),a=[];for(let c of i)for(let l of rI(r+c+o))a.push(l);return a}function MN(t,e){return $N(e).test(t)}function $N(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 nI=d(()=>{s(vN,"globMatch");s(eI,"globFilter");s(rI,"expandBraces");s(MN,"matchOne");s($N,"globToRegex");});function q(t,e,r,n={}){let o=[],{rules:i}=t;if(i.length===0)return [];if(i.some(c=>c.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 c of i){if(c.globs.length===0)continue;let l=false;for(let m of c.globs)if(eI(r,m).length>0){l=true;break}l||o.push({level:"warning",file:relative(e,c.source),message:`globs "${c.globs.join(", ")}" match 0 files in project`});}return o}var $t=d(()=>{nI();s(q,"validateRules");});function sI(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var iI=d(()=>{$t();Jo();s(sI,"lintRules");});function U(t,e,r){return {level:"warning",file:t,target:e,message:r}}function GN(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 di(t,e,r,n){let o=n?.unsupportedBy??e,i=GN(r);return U(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var bt=d(()=>{s(U,"createWarning");s(GN,"formatOxfordComma");s(di,"createUnsupportedHookWarning");});function aI(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function cI(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?[]:[U(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function lI(t){return t.ignore.length===0?[]:[U(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var mI=d(()=>{bt();s(aI,"lintHooks");s(cI,"lintPermissions");s(lI,"lintIgnore");});function L(t,e){return Y(t).relative(t,e).replace(/\\/g,"/")}async function b(t,e){return N(Y(t).join(t,e)).catch(()=>[])}function uI(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function HN(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)uI(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function $(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function W(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,`${pI}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let c=o.startsWith(ii)?ii:o.startsWith(Aa)?Aa:null;if(c&&a==="SKILL.md"){t.set(e,`${WN}/${o.slice(c.length)}.md`);return}let l=o.startsWith(ai)?ai:o.startsWith(xa)?xa:null;if(l&&a==="SKILL.md"){t.set(e,`${BN}/${o.slice(l.length)}.md`);return}let m=`${pI}/${o}`;a==="SKILL.md"&&uI(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&HN(t,e,p,`${r}/${o}`);}function zN(t){return t.split("/").filter(Boolean)[0]??""}async function VN(){if(Tu!==void 0)return Tu;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(ut(),dI)),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=zN(n);o.startsWith(".")&&e.add(o);}return Tu=e,e}function Nu(t){return t.split("/").some(e=>e.startsWith("."))}async function JN(t){let e=[],r=await VN(),n=Y(t);async function o(i){let a=n.join(t,i),c=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let l of c){let m=i?`${i}/${l.name}`:l.name;if(l.isDirectory()){if(r.has(l.name)||Nu(m))continue;await o(m);continue}if(l.isSymbolicLink()&&await stat(n.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(l.name)||Nu(m))continue;await o(m);continue}(l.name==="AGENTS.md"||l.name==="AGENTS.override.md")&&e.push(n.join(t,m));}}return s(o,"walk"),await o(""),e}async function kl(t,e){let r=await JN(e);for(let n of r){let o=L(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 c=posix.dirname(o);if(Nu(c))continue;let l=c.replace(/\//g,"-");t.set(o,`${KN}/${l}.md`);}}var KN,WN,BN,pI,Tu,Nt=d(()=>{Wt();A();ne();dt();KN=".agentsmesh/rules",WN=".agentsmesh/commands",BN=".agentsmesh/agents",pI=".agentsmesh/skills";s(L,"rel");s(b,"listFiles");s(uI,"addDirectoryMapping");s(HN,"addAncestorMappings");s($,"addSimpleFileMapping");s(W,"addSkillLikeMapping");s(zN,"firstPathSegment");s(VN,"targetRootSegments");s(Nu,"hasHiddenSegment");s(JN,"listScopedAgentsFiles");s(kl,"addScopedAgentsMappings");});var P,rt,ft,At=d(()=>{P=".agentsmesh/rules",rt=".agentsmesh/commands",ft=".agentsmesh/agents";});async function Fu(t,e,r="project"){if(r==="global"){t.set(un,`${P}/_root.md`);for(let n of await b(e,Ae))W(t,L(e,n),Ae);t.set(dn,".agentsmesh/mcp.json");return}t.set(be,`${P}/_root.md`);for(let n of await b(e,Bt))W(t,L(e,n),Bt);t.set(br,".agentsmesh/mcp.json");}var fI=d(()=>{Nt();Jo();At();s(Fu,"buildAmpImportPaths");});var Yo,Ol,Ar,er,va,rr,hn,Ma,xr,yn,$a,fi,vu,Xo,wl,gI,Zo=d(()=>{Yo="antigravity",Ol=".agents",Ar=`${Ol}/rules`,er=`${Ar}/general.md`,va=`${Ar}/_root.md`,rr=`${Ol}/skills`,hn=`${Ol}/workflows`,Ma=`${Ol}/antigravity/mcp_config.json`,xr=".gemini/antigravity/GEMINI.md",yn=".gemini/antigravity/skills",$a=".gemini/antigravity/workflows",fi=".gemini/antigravity/mcp_config.json",vu=".agentsmesh/rules/_root.md",Xo=".agentsmesh/rules",wl=".agentsmesh/commands",gI=".agentsmesh/mcp.json";});async function Mu(t,e,r="project"){if(r==="global"){t.set(xr,`${P}/_root.md`);for(let n of await b(e,yn))W(t,L(e,n),yn);t.set(fi,".agentsmesh/mcp.json");return}t.set(er,`${P}/_root.md`),t.set(va,`${P}/_root.md`);for(let n of await b(e,Ar)){let o=L(e,n);o===er||o===va||$(t,o,P,".md");}for(let n of await b(e,hn))$(t,L(e,n),rt,".md");for(let n of await b(e,rr))W(t,L(e,n),rr);}var hI=d(()=>{Nt();Zo();At();s(Mu,"buildAntigravityImportPaths");});var yI,to,_I,Ga,ja,Ua,Ka,Wa,_n,$u,Ba,gi,Ha,za,El,Ll,Gu,Va,ju,qo,II,In=d(()=>{yI="claude-code",to=".claude/CLAUDE.md",_I="CLAUDE.md",Ga=".claude/rules",ja=".claude/commands",Ua=".claude/agents",Ka=".claude/skills",Wa=".claude/settings.json",_n=".claude/hooks.json",$u=".claude/output-styles",Ba=".claudeignore",gi=".mcp.json",Ha=".claude.json",za=".agentsmesh/rules",El=".agentsmesh/commands",Ll=".agentsmesh/agents",Gu=".agentsmesh/skills",Va=".agentsmesh/mcp.json",ju=".agentsmesh/permissions.yaml",qo=".agentsmesh/hooks.yaml",II=".agentsmesh/ignore";});async function Uu(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${P}/_root.md`),t.set(_n,qo),r==="project"&&t.set("CLAUDE.md",`${P}/_root.md`),r==="global")for(let n of await b(e,".agents/skills"))W(t,L(e,n),".agents/skills");for(let n of await b(e,".claude/rules"))$(t,L(e,n),P,".md");for(let n of await b(e,".claude/commands"))$(t,L(e,n),rt,".md");for(let n of await b(e,".claude/agents"))$(t,L(e,n),ft,".md");for(let n of await b(e,".claude/skills"))W(t,L(e,n),".claude/skills");}var CI=d(()=>{Nt();In();At();s(Uu,"buildClaudeCodeImportPaths");});var eo,Cn,Qo,Sn,SI,Gt,Pr,ro,ts,es,rs,ns,Ku,no,bl,Wu,Bu,Hu,RI,Pe=d(()=>{eo="cline",Cn=".clinerules",Qo=".clineignore",Sn=".cline/cline_mcp_settings.json",SI=".cline/mcp_settings.json",Gt=".cline/skills",Pr=".clinerules/workflows",ro="AGENTS.md",ts=".clinerules/hooks",es="Documents/Cline/Rules",rs="Documents/Cline/Workflows",ns="Documents/Cline/Hooks",Ku=".agentsmesh/hooks.yaml",no=".agentsmesh/rules",bl=".agentsmesh/commands",Wu=".agentsmesh/ignore",Bu=".agentsmesh/mcp.json",Hu=".agentsmesh/agents",RI=".agentsmesh/skills";});async function zu(t,e,r="project"){if(r==="global"){for(let n of await b(e,es))$(t,L(e,n),P,".md");for(let n of await b(e,rs))$(t,L(e,n),rt,".md");for(let n of await b(e,Gt))W(t,L(e,n),Gt);t.set(Sn,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${P}/_root.md`);for(let n of await b(e,".clinerules")){let o=L(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||$(t,o,P,".md");}for(let n of await b(e,".clinerules/workflows"))$(t,L(e,n),rt,".md");for(let n of await b(e,".cline/skills"))W(t,L(e,n),".cline/skills");}var kI=d(()=>{Nt();Pe();At();s(zu,"buildClineImportPaths");});async function Vu(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${P}/_root.md`),t.set(".codex/AGENTS.override.md",`${P}/_root.md`)):(t.set("AGENTS.md",`${P}/_root.md`),t.set("codex.md",`${P}/_root.md`),await kl(t,e)),r==="project")for(let n of await b(e,".codex/instructions"))$(t,L(e,n),P,".md");for(let n of await b(e,".codex/rules")){let o=L(e,n);o.endsWith(".rules")?$(t,o,P,".rules"):o.endsWith(".md")&&$(t,o,P,".md");}for(let n of await b(e,".codex/agents"))$(t,L(e,n),ft,".toml");for(let n of await b(e,".agents/skills"))W(t,L(e,n),".agents/skills");}var OI=d(()=>{Nt();At();s(Vu,"buildCodexCliImportPaths");});var hi,nr,Tr,Ju,Al,Rn,Yu,de,yi,Ja,xl,Pl,Xu,Dr=d(()=>{hi="continue",nr=".continue/rules",Tr=".continue/prompts",Ju=".continue/mcpServers",Al=`${Ju}/agentsmesh.json`,Rn=`${nr}/general.md`,Yu=`${nr}/_root.md`,de=".continue/skills",yi=".continue/AGENTS.md",Ja=".continue/config.yaml",xl=".agentsmesh/rules",Pl=".agentsmesh/commands",Xu=".agentsmesh/mcp.json";});async function Zu(t,e,r="project"){t.set(Rn,`${P}/_root.md`),t.set(Yu,`${P}/_root.md`);for(let n of await b(e,".continue/rules")){let o=L(e,n);o===Rn||o===Yu||$(t,o,P,".md");}for(let n of await b(e,".continue/prompts"))t.set(L(e,n),`${rt}/${basename(n,".md")}.md`);for(let n of await b(e,".continue/skills"))W(t,L(e,n),".continue/skills");if(r==="global")for(let n of await b(e,".agents/skills"))W(t,L(e,n),".agents/skills");}var wI=d(()=>{Nt();Dr();At();s(Zu,"buildContinueImportPaths");});function ZN(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${P}/${basename(e,".instructions.md")}.md`);return}$(t,e,P,".md");}async function qu(t,e){t.set(".github/copilot-instructions.md",`${P}/_root.md`);for(let r of await b(e,".github/copilot"))t.set(L(e,r),`${P}/${basename(r,".instructions.md")}.md`);for(let r of await b(e,".github/instructions"))ZN(t,L(e,r));for(let r of await b(e,".github/prompts"))t.set(L(e,r),`${rt}/${basename(r,".prompt.md")}.md`);for(let r of await b(e,".github/agents"))t.set(L(e,r),`${ft}/${basename(r,".agent.md")}.md`);for(let r of await b(e,".github/skills"))W(t,L(e,r),".github/skills");}var EI=d(()=>{Nt();At();s(ZN,"addCopilotInstructionMapping");s(qu,"buildCopilotImportPaths");});var LI,oo,bI,Te,kn,De,_i,Nr,Fr,vr,Dl,or,Qu,qN,Ii,sr,Ya,so,io,Mr,ao,co,AI,Ci,td,Xa,ed,Rt=d(()=>{LI="cursor",oo="AGENTS.md",bI=".cursorrules",Te=".cursor/rules",kn=`${Te}/general.mdc`,De=".cursor/commands",_i=".cursor/agents",Nr=".cursor/skills",Fr=".cursor/mcp.json",vr=".cursor/hooks.json",Dl=".cursor/settings.json",or=".cursorignore",Qu=".cursorindexingignore",qN=".agentsmesh-exports/cursor",Ii=`${qN}/user-rules.md`,sr=".cursor/AGENTS.md",Ya=Fr,so=Nr,io=_i,Mr=".agentsmesh/rules",ao=".agentsmesh/commands",co=".agentsmesh/agents",AI=".agentsmesh/skills",Ci=".agentsmesh/mcp.json",td=".agentsmesh/permissions.yaml",Xa=".agentsmesh/hooks.yaml",ed=".agentsmesh/ignore";});async function rd(t,e,r="project"){if(r==="global"){t.set(Fr,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${P}/_root.md`);for(let n of await b(e,".cursor/rules"))$(t,L(e,n),P,".mdc");for(let n of await b(e,".cursor/commands"))$(t,L(e,n),rt,".md");for(let n of await b(e,".cursor/agents"))$(t,L(e,n),ft,".md");for(let n of await b(e,".cursor/skills"))W(t,L(e,n),".cursor/skills");return}t.set("AGENTS.md",`${P}/_root.md`);for(let n of await b(e,".cursor/rules"))$(t,L(e,n),P,".mdc");for(let n of await b(e,".cursor/commands"))$(t,L(e,n),rt,".md");for(let n of await b(e,".cursor/agents"))$(t,L(e,n),ft,".md");for(let n of await b(e,".cursor/skills"))W(t,L(e,n),".cursor/skills");}var xI=d(()=>{Nt();Rt();At();s(rd,"buildCursorImportPaths");});async function nd(t,e){for(let r of await b(e,".gemini/rules"))$(t,L(e,r),P,".md");for(let r of await b(e,".gemini/commands")){let n=L(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",l=(o.startsWith(i)?o.slice(i.length):o).split("/").filter(Boolean).join(":");t.set(n,`${rt}/${l}.md`);}for(let r of await b(e,".gemini/agents"))$(t,L(e,r),ft,".md");for(let r of await b(e,".gemini/skills"))W(t,L(e,r),".gemini/skills");}var PI=d(()=>{Nt();At();s(nd,"buildGeminiCliImportPaths");});var $r,Ne,Zt,On,TI,wn,os,Fe,DI,NI,Si=d(()=>{$r="goose",Ne=".goosehints",Zt=".agents/skills",On=".gooseignore",TI=".config/goose",wn=`${TI}/.goosehints`,os=`${TI}/.gooseignore`,Fe=".agents/skills",DI=".agentsmesh/rules",NI=".agentsmesh/ignore";});async function od(t,e,r="project"){if(r==="global"){t.set(wn,`${P}/_root.md`);for(let n of await b(e,Fe))W(t,L(e,n),Fe);t.set(os,".agentsmesh/ignore");return}t.set(Ne,`${P}/_root.md`);for(let n of await b(e,Zt))W(t,L(e,n),Zt);t.set(On,".agentsmesh/ignore");}var FI=d(()=>{Nt();Si();At();s(od,"buildGooseImportPaths");});var ss,lo,Nl,vI,Gr,MI,QN,Za,is,qa,Ri,ki,Qa,tc,ec,rc,nc,tF,Fl,as,$I,sd,vl,GI,jI,UI,KI,Oi=d(()=>{ss="junie",lo=".junie",Nl=`${lo}/guidelines.md`,vI=`${lo}/ci-guidelines.md`,Gr=`${lo}/AGENTS.md`,MI="AGENTS.md",QN=`${lo}/mcp`,Za=`${QN}/mcp.json`,is=`${lo}/skills`,qa=`${lo}/rules`,Ri=`${lo}/commands`,ki=`${lo}/agents`,Qa=".aiignore",tc=".junie",ec=`${tc}/skills`,rc=`${tc}/agents`,nc=`${tc}/commands`,tF=`${tc}/mcp`,Fl=`${tF}/mcp.json`,as=`${tc}/AGENTS.md`,$I=".agents/skills",sd=".agentsmesh/rules/_root.md",vl=".agentsmesh/rules",GI=".agentsmesh/commands",jI=".agentsmesh/agents",UI=".agentsmesh/mcp.json",KI=".agentsmesh/ignore";});async function id(t,e){t.set(Nl,`${P}/_root.md`),t.set(Gr,`${P}/_root.md`),t.set("AGENTS.md",`${P}/_root.md`);for(let r of await b(e,".junie/rules"))$(t,L(e,r),P,".md");for(let r of await b(e,".junie/commands"))$(t,L(e,r),rt,".md");for(let r of await b(e,".junie/agents"))$(t,L(e,r),ft,".md");for(let r of await b(e,".junie/skills"))W(t,L(e,r),".junie/skills");}var WI=d(()=>{Nt();Oi();At();s(id,"buildJunieImportPaths");});var qt,oc,jr,En,Ln,bn,ir,mo,wi,Ml,cs,Ei,ls,sc,$l,Li,po,ms,ps,us,uo,bi,Gl,BI,fo,Ai,ds,HI,zI,fs=d(()=>{qt="kilo-code",oc=".kilo",jr="AGENTS.md",En=`${oc}/rules`,Ln=`${oc}/commands`,bn=`${oc}/agents`,ir=`${oc}/skills`,mo=`${oc}/mcp.json`,wi=".kilocodeignore",Ml=".kilocode",cs=`${Ml}/rules`,Ei=`${Ml}/workflows`,ls=`${Ml}/skills`,sc=`${Ml}/mcp.json`,$l=".kilocodemodes",Li=".kilo",po=`${Li}/AGENTS.md`,ms=`${Li}/rules`,ps=`${Li}/commands`,us=`${Li}/agents`,uo=`${Li}/skills`,bi=`${Li}/mcp.json`,Gl=".kilocodeignore",BI=".agents/skills",fo=".agentsmesh/rules",Ai=".agentsmesh/commands",ds=".agentsmesh/agents",HI=".agentsmesh/mcp.json",zI=".agentsmesh/ignore";});async function ad(t,e,r="project"){if(r==="global"){t.set(po,`${P}/_root.md`);for(let n of await b(e,ms))$(t,L(e,n),P,".md");for(let n of await b(e,ps))$(t,L(e,n),rt,".md");for(let n of await b(e,us))$(t,L(e,n),ft,".md");for(let n of await b(e,uo))W(t,L(e,n),uo);t.set(bi,".agentsmesh/mcp.json");return}t.set(jr,`${P}/_root.md`);for(let n of await b(e,En))$(t,L(e,n),P,".md");for(let n of await b(e,Ln))$(t,L(e,n),rt,".md");for(let n of await b(e,bn))$(t,L(e,n),ft,".md");for(let n of await b(e,ir))W(t,L(e,n),ir);t.set(mo,".agentsmesh/mcp.json");for(let n of await b(e,cs)){let o=L(e,n);if(basename(o)==="00-root.md"){t.set(o,`${P}/_root.md`);continue}$(t,o,P,".md");}for(let n of await b(e,Ei))$(t,L(e,n),rt,".md");for(let n of await b(e,ls))W(t,L(e,n),ls);t.set(sc,".agentsmesh/mcp.json");}var VI=d(()=>{Nt();fs();At();s(ad,"buildKiloCodeImportPaths");});var fe,ar,ic,cr,Qt,lr,go,JI,xi,Pi,gs,mr,ho,hs,ac,cc,YI,cd,ld,XI,ZI,md,qI,Ti=d(()=>{fe="kiro",ar="AGENTS.md",ic=".kiro",cr=`${ic}/steering`,Qt=`${ic}/skills`,lr=`${ic}/agents`,go=`${ic}/hooks`,JI=`${ic}/settings`,xi=`${JI}/mcp.json`,Pi=".kiroignore",gs=".kiro/steering",mr=".kiro/steering/AGENTS.md",ho=".kiro/skills",hs=".kiro/agents",ac=".kiro/settings/mcp.json",cc=".kiro/settings/kiroignore",YI=".agents/skills",cd=".agentsmesh/rules/_root.md",ld=".agentsmesh/rules",XI=".agentsmesh/agents",ZI=".agentsmesh/mcp.json",md=".agentsmesh/hooks.yaml",qI=".agentsmesh/ignore";});async function pd(t,e,r="project"){if(r==="global"){t.set(mr,`${P}/_root.md`);for(let n of await b(e,gs)){let o=L(e,n);o!==mr&&$(t,o,P,".md");}for(let n of await b(e,ho))W(t,L(e,n),ho);for(let n of await b(e,hs))$(t,L(e,n),ft,".md");return}t.set(ar,`${P}/_root.md`);for(let n of await b(e,cr))$(t,L(e,n),P,".md");for(let n of await b(e,Qt))W(t,L(e,n),Qt);for(let n of await b(e,lr))$(t,L(e,n),ft,".md");}var QI=d(()=>{Nt();Ti();At();s(pd,"buildKiroImportPaths");});var pr,jl,Ur,An,xn,Pn,ur,Kr,Di,yo,ys,_s,Is,_o,Io,tC,lc,Ul,Kl,ud,Cs=d(()=>{pr="opencode",jl=".opencode",Ur="AGENTS.md",An=`${jl}/rules`,xn=`${jl}/commands`,Pn=`${jl}/agents`,ur=`${jl}/skills`,Kr="opencode.json",Di=".config/opencode",yo=`${Di}/AGENTS.md`,ys=`${Di}/rules`,_s=`${Di}/commands`,Is=`${Di}/agents`,_o=`${Di}/skills`,Io=`${Di}/opencode.json`,tC=".agents/skills",lc=".agentsmesh/rules",Ul=".agentsmesh/commands",Kl=".agentsmesh/agents",ud=".agentsmesh/mcp.json";});async function dd(t,e,r="project"){if(r==="global"){t.set(yo,`${P}/_root.md`);for(let n of await b(e,ys))$(t,L(e,n),P,".md");for(let n of await b(e,_s))$(t,L(e,n),rt,".md");for(let n of await b(e,Is))$(t,L(e,n),ft,".md");for(let n of await b(e,_o))W(t,L(e,n),_o);t.set(Io,".agentsmesh/mcp.json");return}t.set(Ur,`${P}/_root.md`);for(let n of await b(e,An))$(t,L(e,n),P,".md");for(let n of await b(e,xn))$(t,L(e,n),rt,".md");for(let n of await b(e,Pn))$(t,L(e,n),ft,".md");for(let n of await b(e,ur))W(t,L(e,n),ur);t.set(Kr,".agentsmesh/mcp.json");}var eC=d(()=>{Nt();Cs();At();s(dd,"buildOpencodeImportPaths");});var Co,Ss,dr,mc,Tn,Dn,Wr,pc,uc,Ni,dc,Wl,So,Ro,Nn,Rs,fc,ko,rC,ks,Bl,nC,oC,Os=d(()=>{Co="roo-code",Ss=".roo",dr=`${Ss}/rules/00-root.md`,mc=".roorules",Tn=`${Ss}/rules`,Dn=`${Ss}/commands`,Wr=`${Ss}/skills`,pc=`${Ss}/mcp.json`,uc=".rooignore",Ni=".roomodes",dc="settings/custom_modes.yaml",Wl=".roo",So=`${Wl}/rules`,Ro=`${Wl}/commands`,Nn=`${Wl}/skills`,Rs="mcp_settings.json",fc=".rooignore",ko=`${Wl}/AGENTS.md`,rC=".agents/skills",ks=".agentsmesh/rules",Bl=".agentsmesh/commands",nC=".agentsmesh/mcp.json",oC=".agentsmesh/ignore";});async function fd(t,e,r="project"){if(r==="global"){t.set(ko,`${P}/_root.md`);for(let n of await b(e,So))$(t,L(e,n),P,".md");for(let n of await b(e,Ro))$(t,L(e,n),rt,".md");for(let n of await b(e,Nn))W(t,L(e,n),Nn);t.set(Rs,".agentsmesh/mcp.json");return}t.set(dr,`${P}/_root.md`),t.set(mc,`${P}/_root.md`);for(let n of await b(e,Tn)){let o=L(e,n);o!==dr&&$(t,o,P,".md");}for(let n of await b(e,".roo")){let o=L(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&$(t,o,P,".md");}for(let n of await b(e,Dn))$(t,L(e,n),rt,".md");for(let n of await b(e,Wr))W(t,L(e,n),Wr);}var sC=d(()=>{Nt();Os();At();s(fd,"buildRooCodeImportPaths");});var Br,fr,gd,zt,Oo,se,iC,Fi=d(()=>{Br="warp",fr="AGENTS.md",gd="WARP.md",zt=".warp/skills",Oo=".mcp.json",se=".warp/skills",iC=".agentsmesh/rules";});async function hd(t,e,r="project"){if(r==="global"){for(let n of await b(e,se))W(t,L(e,n),se);return}t.set(fr,`${P}/_root.md`);for(let n of await b(e,zt))W(t,L(e,n),zt);t.set(Oo,".agentsmesh/mcp.json");}var aC=d(()=>{Nt();Fi();At();s(hd,"buildWarpImportPaths");});async function yd(t,e){t.set("AGENTS.md",`${P}/_root.md`),t.set(".windsurfrules",`${P}/_root.md`),await kl(t,e);for(let r of await b(e,".windsurf/rules"))$(t,L(e,r),P,".md");for(let r of await b(e,".windsurf/workflows"))$(t,L(e,r),rt,".md");for(let r of await b(e,".windsurf/skills"))W(t,L(e,r),".windsurf/skills");}var cC=d(()=>{Nt();At();s(yd,"buildWindsurfImportPaths");});var gr,Hr,rF,zr,lC,ws=d(()=>{gr=".rules",Hr=".zed/settings.json",rF=".config/zed",zr=`${rF}/settings.json`,lC=".agentsmesh/rules";});async function _d(t,e,r="project"){if(r==="global"){t.set(zr,".agentsmesh/mcp.json");return}t.set(gr,`${P}/_root.md`),t.set(Hr,".agentsmesh/mcp.json");}var mC=d(()=>{ws();At();s(_d,"buildZedImportPaths");});var pC=d(()=>{fI();hI();CI();kI();OI();wI();EI();xI();PI();FI();WI();VI();QI();eC();sC();aC();cC();mC();});var xt=d(()=>{pC();});function iF(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 nF,oF,sF,uC,Rl,Pu=d(()=>{ne();dt();K_();ue();tI();iI();mI();xt();Jo();nF={name:"amp",primaryRootInstructionPath:be,generateRules:$_,generateCommands:j_,generateAgents:U_,generateSkills:G_,importFrom:Q_},oF={rootInstructionPath:be,skillDir:Bt,managedOutputs:{dirs:[Bt],files:[be,br]},paths:{rulePath(t){return be},commandPath(t){return `${Bt}/${st(t)}/SKILL.md`},agentPath(t){return `${Bt}/${V(t)}/SKILL.md`}}},sF={rootInstructionPath:un,skillDir:Ae,managedOutputs:{dirs:[Ae],files:[un,dn]},rewriteGeneratedPath(t){return t===be?un:t===br?dn:t.startsWith(`${Bt}/`)?t.replace(`${Bt}/`,`${Ae}/`):t},mirrorGlobalPath(t,e){return at(t,Ae,e)},paths:{rulePath(t){return un},commandPath(t){return `${Ae}/${st(t)}/SKILL.md`},agentPath(t){return `${Ae}/${V(t)}/SKILL.md`}}},uC={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(iF,"mergeAmpSettings");Rl={id:"amp",generators:nF,capabilities:uC,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:sI,lint:{hooks:aI,permissions:cI,ignore:lI},supportsConversion:{commands:true,agents:true},project:oF,globalSupport:{capabilities:uC,detectionPaths:[un,dn],layout:sF},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[be],global:[un]},canonicalDir:M_,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:br,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===br||n===dn?iF(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Fu,detectionPaths:[be,br]};});function dC(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:er,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:`${Ar}/${o}.md`,content:n.body.trim()||""});}return r}function fC(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
50
+ ${rN}
51
+ ${Na}`;s(Ru,"normalizeWhitespace");A_=[pN,mN,lN,cN,aN,iN,sN,oN,nN];s(x_,"appendAgentsmeshRootInstructionParagraph");s(P_,"stripAgentsmeshRootInstructionParagraph");});function Xt(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 li(t){let e=await y(t);return e?w(e).frontmatter:{}}function vt(t,e){return typeof t[e]=="string"?t[e]:void 0}function wu(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function uN(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function dN(t,e){let r=basename(t,".md")==="_root",n={...e};return delete n.root,{root:r,...n}}async function j(t,e,r){let n=await li(t),o=basename(t,".md")==="_root"?P_(r):r.trim(),i=dN(t,uN({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=Xt(i.globs));for(let[c,l]of Object.entries(i))c==="root"||c==="description"||c==="globs"||l===void 0||(a[c]=l);return F(a,o||"")}var Eu=d(()=>{A();M();Ou();s(Xt,"toStringArray");s(li,"readExistingFrontmatter");s(vt,"readString");s(wu,"readHooks");s(uN,"pruneUndefined");s(dN,"serializeCanonicalRuleFrontmatter");s(j,"serializeImportedRuleWithFallback");});async function ot(t,e,r){let n=await li(t),o=(()=>{let c=Xt(n.allowedTools);return c.length>0?c:Xt(n["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return F({description:i,"allowed-tools":a},r.trim()||"")}async function Lr(t,e,r){let n=await li(t),o=basename(dirname(t)),i=vt(e,"name")??vt(n,"name")??o,a=vt(e,"description")??vt(n,"description")??"";return F({name:i,description:a},r.trim()||"")}async function Lt(t,e,r){let n=await li(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?Xt(e.tools):(()=>{let R=Xt(n.tools);return R.length>0?R:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?Xt(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?Xt(e["disallowed-tools"]):Xt(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?Xt(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?Xt(e["mcp-servers"]):Xt(n.mcpServers),c=Object.prototype.hasOwnProperty.call(e,"skills")?Xt(e.skills):Xt(n.skills),l=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof l=="number"?l:Number(l??0),p=wu(e)??wu(n),u={name:vt(e,"name")??vt(n,"name")??basename(t,".md"),description:vt(e,"description")??vt(n,"description")??"",tools:o};i.length>0&&(u.disallowedTools=i);let f=vt(e,"model")??vt(n,"model");f&&(u.model=f);let g=vt(e,"permissionMode")??vt(e,"permission-mode")??vt(n,"permissionMode")??vt(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),c.length>0&&(u.skills=c);let h=vt(e,"memory")??vt(n,"memory");return h&&(u.memory=h),F(u,r.trim()||"")}var N_=d(()=>{M();Eu();s(ot,"serializeImportedCommandWithFallback");s(Lr,"serializeImportedSkillWithFallback");s(Lt,"serializeImportedAgentWithFallback");});var et=d(()=>{Eu();N_();});function Rl(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 Ee(t){await rm$1(t,{recursive:true,force:true});}var mi=d(()=>{s(Rl,"shouldImportScopedAgentsRule");s(Ee,"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:F(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 yt(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 c=join(t,e,a.name),l=join(c,"SKILL.md"),m=await y(l);if(m===null)continue;let p=join(t,Fa,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=w(o(m,l,u)),h=yl(f,a.name);if(h){await Ee(join(t,Fa,a.name));let E=join(t,F_);await O(E);let T=join(E,`${h.name}.md`);await S(T,_l(h,o(g,l,T))),n.push({fromTool:r,fromPath:l,toPath:`${F_}/${h.name}.md`,feature:"commands"});continue}let R=Er(f,a.name);if(R){await Ee(join(t,Fa,a.name));let E=join(t,v_);await O(E);let T=join(E,`${R.name}.md`);await S(T,Oe(R,o(g,l,T))),n.push({fromTool:r,fromPath:l,toPath:`${v_}/${R.name}.md`,feature:"agents"});continue}let C=await Lr(u,{...f,name:a.name},g);await O(p),await S(u,C),n.push({fromTool:r,fromPath:l,toPath:`${Fa}/${a.name}/SKILL.md`,feature:"skills"});let _=await N(c);for(let E of _){if(E===l)continue;let T=relative(c,E).replace(/\\/g,"/"),D=await y(E);if(D===null)continue;let x=join(p,T);await O(dirname(x)),await S(x,o(D,E,x)),n.push({fromTool:r,fromPath:E,toPath:`${Fa}/${a.name}/${T}`,feature:"skills"});}}}var Fa,F_,v_,_t=d(()=>{A();M();et();dt();ne();mi();Fa=".agentsmesh/skills",F_=".agentsmesh/commands",v_=".agentsmesh/agents";s(St,"generateEmbeddedSkills");s(yt,"importEmbeddedSkills");});var be,Bt,br,Lu,un,Ae,dn,M_,Jo=d(()=>{be="AGENTS.md",Bt=".agents/skills",br=".amp/settings.json",Lu=".config/amp",un=`${Lu}/AGENTS.md`,Ae=`${Lu}/skills`,dn=`${Lu}/settings.json`,M_=".agentsmesh/rules";});function $_(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=Et(n,r);return o?[{path:be,content:o}]:[]}function G_(t){return St(t,Bt)}function j_(t){return t.commands.map(e=>({path:`${Bt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function U_(t){return t.agents.map(e=>({path:`${Bt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}var K_=d(()=>{_t();we();dt();ne();Jo();s($_,"generateRules");s(G_,"generateSkills");s(j_,"generateCommands");s(U_,"generateAgents");});function at(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var ue=d(()=>{s(at,"mirrorSkillsToAgents");});async function Ht(t,e,r){let n=join(t,e),i={...await SN(n),...r};await O(dirname(n)),await S(n,JSON.stringify({mcpServers:i},null,2));}async function SN(t){let e=await y(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let 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 fn=d(()=>{A();s(Ht,"writeMcpWithMerge");s(SN,"readExistingServers");});function gn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function xe(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 pi(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function ui(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var Qe=d(()=>{s(gn,"toGlobsArray");s(xe,"toToolsArray");s(pi,"toStringArray");s(ui,"toStringRecord");});function ON(t,e){return e.some(r=>t.endsWith(r))}async function mt(t){let r=(await N(t.srcDir)).filter(o=>ON(o,t.extensions)),n=[];for(let o of r){let i=await y(o);if(!i)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),c=await t.mapEntry({srcPath:o,relativePath:a,content:i,normalizeTo:s((l,m=i)=>t.normalize(m,o,l),"normalizeTo")});c&&(await O(dirname(c.destPath)),await S(c.destPath,c.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:c.toPath,feature:c.feature}));}return n}var tr=d(()=>{A();s(ON,"matchesExtension");s(mt,"importFileDirectory");});function W_(t){return typeof t=="string"?t:void 0}function wN(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function Au(t,e){return e?e(t):t}function EN(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=w(e.normalizeTo(r)),i=Au(n,t.frontmatterRemap),a=wN({root:false,description:W_(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await j(r,a,o)}}}function LN(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=w(e.normalizeTo(r)),i=Au(n,t.frontmatterRemap),a=await ot(r,{hasDescription:true,description:W_(i.description),hasAllowedTools:true,allowedTools:pi(i["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function bN(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=w(e.normalizeTo(r)),i=Au(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Lt(r,i,o)}}}function B_(t){if(t.map)return t.map;switch(t.preset){case "rule":return EN(t);case "command":return LN(t);case "agent":return bN(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var H_=d(()=>{M();et();Qe();s(W_,"pickString");s(wN,"pruneUndefined");s(Au,"applyRemap");s(EN,"ruleMapper");s(LN,"commandMapper");s(bN,"agentMapper");s(B_,"resolveMapper");});function xu(t,e){return t?t[e]??[]:[]}var z_,V_=d(()=>{z_=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(xu,"resolveScopedSources");});async function PN(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 c=join(r,a),l=await y(c);if(l===null)continue;await O(i);let m=join(i,t.canonicalRootFilename),p=s(C=>o(l,c,C),"normalizeTo");if(t.map){let C=await t.map({absolutePath:c,relativePath:a,content:l,destDir:i,normalizeTo:p});if(!C)continue;return await S(C.destPath,C.content),[{fromTool:n,fromPath:c,toPath:C.toPath,feature:t.feature}]}let{frontmatter:u,body:f}=w(p(m)),g=t.frontmatterRemap?t.frontmatterRemap(u):u,h=t.markAsRoot?{...g,root:true}:g,R=await j(m,h,f);return await S(m,R),[{fromTool:n,fromPath:c,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function TN(t,e,r,n,o){let i=B_(t),a=join(r,t.canonicalDir),c=[];for(let l of e){let m=join(r,l),p=await mt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:s(async({srcPath:u,relativePath:f,content:g,normalizeTo:h})=>{let R=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(C=>h(C),"normalizeTo")});return R?{destPath:R.destPath,toPath:R.toPath,feature:t.feature,content:R.content}:null},"mapEntry")});c.push(...p);}return c}function Y_(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function DN(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=Y_(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=join(r,o);return await O(dirname(l)),await S(l,c.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function NN(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,c=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:pi(a.args),env:ui(a.env),description:c};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:ui(a.headers),env:ui(a.env),description:c});}return n}async function FN(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=Y_(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=NN(c);return Object.keys(l).length===0?[]:(await Ht(r,o,l),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function J_(t,e,r,n,o){switch(t.mode){case "singleFile":return PN(t,e,r,n,o);case "directory":return TN(t,e,r,n,o);case "flatFile":return DN(t,e,r,n);case "mcpJson":return FN(t,e,r,n)}}async function vN(t,e,r,n,o){let i=xu(t.source,e),a=xu(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let c=await J_(t,i,r,n,o);if(c.length>0)return c}return a.length>0?J_(t,a,r,n,o):[]}function MN(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function Q(t,e,r,n){let o=t.importer;if(!o)return [];let i=n?.normalize??await z(t.id,e,r),a=[];for(let c of z_)for(let l of MN(o,c))a.push(...await vN(l,r,e,t.id,i));return a}var Mt=d(()=>{It();A();fn();M();Qe();et();tr();H_();V_();s(PN,"runSingleFile");s(TN,"runDirectory");s(Y_,"resolveCanonicalFilePath");s(DN,"runFlatFile");s(NN,"parseMcpJson");s(FN,"runMcpJson");s(J_,"dispatchSpec");s(vN,"runSpec");s(MN,"specsForFeature");s(Q,"runDescriptorImport");});async function Z_(t,e,r){let n=await y(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 c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await Ht(t,X_,c),r.push({fromTool:"amp",fromPath:e,toPath:X_,feature:"mcp"}));}var X_,q_=d(()=>{A();fn();Jo();X_=".agentsmesh/mcp.json";s(Z_,"importAmpMcp");});async function Q_(t,e={}){let r=e.scope??"project",n=[],o=await z("amp",t,r);return n.push(...await Q(kl,t,r,{normalize:o})),await yt(t,r==="global"?Ae:Bt,"amp",n,o),await Z_(t,r==="global"?dn:br,n),n}var tI=d(()=>{It();_t();Mt();q_();Jo();Pu();s(Q_,"importFromAmp");});function GN(t,e){return rI(e).some(n=>jN(t,n))}function eI(t,e){return t.filter(r=>GN(r,e))}function rI(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let i=n.split(",").map(c=>c.trim()),a=[];for(let c of i)for(let l of rI(r+c+o))a.push(l);return a}function jN(t,e){return UN(e).test(t)}function UN(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 nI=d(()=>{s(GN,"globMatch");s(eI,"globFilter");s(rI,"expandBraces");s(jN,"matchOne");s(UN,"globToRegex");});function q(t,e,r,n={}){let o=[],{rules:i}=t;if(i.length===0)return [];if(i.some(c=>c.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 c of i){if(c.globs.length===0)continue;let l=false;for(let m of c.globs)if(eI(r,m).length>0){l=true;break}l||o.push({level:"warning",file:relative(e,c.source),message:`globs "${c.globs.join(", ")}" match 0 files in project`});}return o}var $t=d(()=>{nI();s(q,"validateRules");});function sI(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var iI=d(()=>{$t();Jo();s(sI,"lintRules");});function U(t,e,r){return {level:"warning",file:t,target:e,message:r}}function KN(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 di(t,e,r,n){let o=n?.unsupportedBy??e,i=KN(r);return U(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var bt=d(()=>{s(U,"createWarning");s(KN,"formatOxfordComma");s(di,"createUnsupportedHookWarning");});function aI(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function cI(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?[]:[U(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function lI(t){return t.ignore.length===0?[]:[U(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var mI=d(()=>{bt();s(aI,"lintHooks");s(cI,"lintPermissions");s(lI,"lintIgnore");});function L(t,e){return Y(t).relative(t,e).replace(/\\/g,"/")}async function b(t,e){return N(Y(t).join(t,e)).catch(()=>[])}function uI(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function JN(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)uI(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function $(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function W(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,`${pI}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let c=o.startsWith(ii)?ii:o.startsWith(xa)?xa:null;if(c&&a==="SKILL.md"){t.set(e,`${zN}/${o.slice(c.length)}.md`);return}let l=o.startsWith(ai)?ai:o.startsWith(Pa)?Pa:null;if(l&&a==="SKILL.md"){t.set(e,`${VN}/${o.slice(l.length)}.md`);return}let m=`${pI}/${o}`;a==="SKILL.md"&&uI(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&JN(t,e,p,`${r}/${o}`);}function YN(t){return t.split("/").filter(Boolean)[0]??""}async function XN(){if(Tu!==void 0)return Tu;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(ut(),dI)),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=YN(n);o.startsWith(".")&&e.add(o);}return Tu=e,e}function Nu(t){return t.split("/").some(e=>e.startsWith("."))}async function ZN(t){let e=[],r=await XN(),n=Y(t);async function o(i){let a=n.join(t,i),c=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let l of c){let m=i?`${i}/${l.name}`:l.name;if(l.isDirectory()){if(r.has(l.name)||Nu(m))continue;await o(m);continue}if(l.isSymbolicLink()&&await stat(n.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(l.name)||Nu(m))continue;await o(m);continue}(l.name==="AGENTS.md"||l.name==="AGENTS.override.md")&&e.push(n.join(t,m));}}return s(o,"walk"),await o(""),e}async function Ol(t,e){let r=await ZN(e);for(let n of r){let o=L(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 c=posix.dirname(o);if(Nu(c))continue;let l=c.replace(/\//g,"-");t.set(o,`${HN}/${l}.md`);}}var HN,zN,VN,pI,Tu,Nt=d(()=>{Wt();A();ne();dt();HN=".agentsmesh/rules",zN=".agentsmesh/commands",VN=".agentsmesh/agents",pI=".agentsmesh/skills";s(L,"rel");s(b,"listFiles");s(uI,"addDirectoryMapping");s(JN,"addAncestorMappings");s($,"addSimpleFileMapping");s(W,"addSkillLikeMapping");s(YN,"firstPathSegment");s(XN,"targetRootSegments");s(Nu,"hasHiddenSegment");s(ZN,"listScopedAgentsFiles");s(Ol,"addScopedAgentsMappings");});var P,rt,ft,At=d(()=>{P=".agentsmesh/rules",rt=".agentsmesh/commands",ft=".agentsmesh/agents";});async function Fu(t,e,r="project"){if(r==="global"){t.set(un,`${P}/_root.md`);for(let n of await b(e,Ae))W(t,L(e,n),Ae);t.set(dn,".agentsmesh/mcp.json");return}t.set(be,`${P}/_root.md`);for(let n of await b(e,Bt))W(t,L(e,n),Bt);t.set(br,".agentsmesh/mcp.json");}var fI=d(()=>{Nt();Jo();At();s(Fu,"buildAmpImportPaths");});var Yo,wl,Ar,er,Ma,rr,hn,$a,xr,yn,Ga,fi,vu,Xo,El,gI,Zo=d(()=>{Yo="antigravity",wl=".agents",Ar=`${wl}/rules`,er=`${Ar}/general.md`,Ma=`${Ar}/_root.md`,rr=`${wl}/skills`,hn=`${wl}/workflows`,$a=`${wl}/antigravity/mcp_config.json`,xr=".gemini/antigravity/GEMINI.md",yn=".gemini/antigravity/skills",Ga=".gemini/antigravity/workflows",fi=".gemini/antigravity/mcp_config.json",vu=".agentsmesh/rules/_root.md",Xo=".agentsmesh/rules",El=".agentsmesh/commands",gI=".agentsmesh/mcp.json";});async function Mu(t,e,r="project"){if(r==="global"){t.set(xr,`${P}/_root.md`);for(let n of await b(e,yn))W(t,L(e,n),yn);t.set(fi,".agentsmesh/mcp.json");return}t.set(er,`${P}/_root.md`),t.set(Ma,`${P}/_root.md`);for(let n of await b(e,Ar)){let o=L(e,n);o===er||o===Ma||$(t,o,P,".md");}for(let n of await b(e,hn))$(t,L(e,n),rt,".md");for(let n of await b(e,rr))W(t,L(e,n),rr);}var hI=d(()=>{Nt();Zo();At();s(Mu,"buildAntigravityImportPaths");});var yI,to,_I,ja,Ua,Ka,Wa,Ba,_n,$u,Ha,gi,za,Va,Ll,bl,Gu,Ja,ju,qo,II,In=d(()=>{yI="claude-code",to=".claude/CLAUDE.md",_I="CLAUDE.md",ja=".claude/rules",Ua=".claude/commands",Ka=".claude/agents",Wa=".claude/skills",Ba=".claude/settings.json",_n=".claude/hooks.json",$u=".claude/output-styles",Ha=".claudeignore",gi=".mcp.json",za=".claude.json",Va=".agentsmesh/rules",Ll=".agentsmesh/commands",bl=".agentsmesh/agents",Gu=".agentsmesh/skills",Ja=".agentsmesh/mcp.json",ju=".agentsmesh/permissions.yaml",qo=".agentsmesh/hooks.yaml",II=".agentsmesh/ignore";});async function Uu(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${P}/_root.md`),t.set(_n,qo),r==="project"&&t.set("CLAUDE.md",`${P}/_root.md`),r==="global")for(let n of await b(e,".agents/skills"))W(t,L(e,n),".agents/skills");for(let n of await b(e,".claude/rules"))$(t,L(e,n),P,".md");for(let n of await b(e,".claude/commands"))$(t,L(e,n),rt,".md");for(let n of await b(e,".claude/agents"))$(t,L(e,n),ft,".md");for(let n of await b(e,".claude/skills"))W(t,L(e,n),".claude/skills");}var CI=d(()=>{Nt();In();At();s(Uu,"buildClaudeCodeImportPaths");});var eo,Cn,Qo,Sn,SI,Gt,Pr,ro,ts,es,rs,ns,Ku,no,Al,Wu,Bu,Hu,RI,Pe=d(()=>{eo="cline",Cn=".clinerules",Qo=".clineignore",Sn=".cline/cline_mcp_settings.json",SI=".cline/mcp_settings.json",Gt=".cline/skills",Pr=".clinerules/workflows",ro="AGENTS.md",ts=".clinerules/hooks",es="Documents/Cline/Rules",rs="Documents/Cline/Workflows",ns="Documents/Cline/Hooks",Ku=".agentsmesh/hooks.yaml",no=".agentsmesh/rules",Al=".agentsmesh/commands",Wu=".agentsmesh/ignore",Bu=".agentsmesh/mcp.json",Hu=".agentsmesh/agents",RI=".agentsmesh/skills";});async function zu(t,e,r="project"){if(r==="global"){for(let n of await b(e,es))$(t,L(e,n),P,".md");for(let n of await b(e,rs))$(t,L(e,n),rt,".md");for(let n of await b(e,Gt))W(t,L(e,n),Gt);t.set(Sn,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${P}/_root.md`);for(let n of await b(e,".clinerules")){let o=L(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||$(t,o,P,".md");}for(let n of await b(e,".clinerules/workflows"))$(t,L(e,n),rt,".md");for(let n of await b(e,".cline/skills"))W(t,L(e,n),".cline/skills");}var kI=d(()=>{Nt();Pe();At();s(zu,"buildClineImportPaths");});async function Vu(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${P}/_root.md`),t.set(".codex/AGENTS.override.md",`${P}/_root.md`)):(t.set("AGENTS.md",`${P}/_root.md`),t.set("codex.md",`${P}/_root.md`),await Ol(t,e)),r==="project")for(let n of await b(e,".codex/instructions"))$(t,L(e,n),P,".md");for(let n of await b(e,".codex/rules")){let o=L(e,n);o.endsWith(".rules")?$(t,o,P,".rules"):o.endsWith(".md")&&$(t,o,P,".md");}for(let n of await b(e,".codex/agents"))$(t,L(e,n),ft,".toml");for(let n of await b(e,".agents/skills"))W(t,L(e,n),".agents/skills");}var OI=d(()=>{Nt();At();s(Vu,"buildCodexCliImportPaths");});var hi,nr,Tr,Ju,xl,Rn,Yu,de,yi,Ya,Pl,Tl,Xu,Dr=d(()=>{hi="continue",nr=".continue/rules",Tr=".continue/prompts",Ju=".continue/mcpServers",xl=`${Ju}/agentsmesh.json`,Rn=`${nr}/general.md`,Yu=`${nr}/_root.md`,de=".continue/skills",yi=".continue/AGENTS.md",Ya=".continue/config.yaml",Pl=".agentsmesh/rules",Tl=".agentsmesh/commands",Xu=".agentsmesh/mcp.json";});async function Zu(t,e,r="project"){t.set(Rn,`${P}/_root.md`),t.set(Yu,`${P}/_root.md`);for(let n of await b(e,".continue/rules")){let o=L(e,n);o===Rn||o===Yu||$(t,o,P,".md");}for(let n of await b(e,".continue/prompts"))t.set(L(e,n),`${rt}/${basename(n,".md")}.md`);for(let n of await b(e,".continue/skills"))W(t,L(e,n),".continue/skills");if(r==="global")for(let n of await b(e,".agents/skills"))W(t,L(e,n),".agents/skills");}var wI=d(()=>{Nt();Dr();At();s(Zu,"buildContinueImportPaths");});function tF(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${P}/${basename(e,".instructions.md")}.md`);return}$(t,e,P,".md");}async function qu(t,e){t.set(".github/copilot-instructions.md",`${P}/_root.md`);for(let r of await b(e,".github/copilot"))t.set(L(e,r),`${P}/${basename(r,".instructions.md")}.md`);for(let r of await b(e,".github/instructions"))tF(t,L(e,r));for(let r of await b(e,".github/prompts"))t.set(L(e,r),`${rt}/${basename(r,".prompt.md")}.md`);for(let r of await b(e,".github/agents"))t.set(L(e,r),`${ft}/${basename(r,".agent.md")}.md`);for(let r of await b(e,".github/skills"))W(t,L(e,r),".github/skills");}var EI=d(()=>{Nt();At();s(tF,"addCopilotInstructionMapping");s(qu,"buildCopilotImportPaths");});var LI,oo,bI,Te,kn,De,_i,Nr,Fr,vr,Nl,or,Qu,eF,Ii,sr,Xa,so,io,Mr,ao,co,AI,Ci,td,Za,ed,Rt=d(()=>{LI="cursor",oo="AGENTS.md",bI=".cursorrules",Te=".cursor/rules",kn=`${Te}/general.mdc`,De=".cursor/commands",_i=".cursor/agents",Nr=".cursor/skills",Fr=".cursor/mcp.json",vr=".cursor/hooks.json",Nl=".cursor/settings.json",or=".cursorignore",Qu=".cursorindexingignore",eF=".agentsmesh-exports/cursor",Ii=`${eF}/user-rules.md`,sr=".cursor/AGENTS.md",Xa=Fr,so=Nr,io=_i,Mr=".agentsmesh/rules",ao=".agentsmesh/commands",co=".agentsmesh/agents",AI=".agentsmesh/skills",Ci=".agentsmesh/mcp.json",td=".agentsmesh/permissions.yaml",Za=".agentsmesh/hooks.yaml",ed=".agentsmesh/ignore";});async function rd(t,e,r="project"){if(r==="global"){t.set(Fr,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${P}/_root.md`);for(let n of await b(e,".cursor/rules"))$(t,L(e,n),P,".mdc");for(let n of await b(e,".cursor/commands"))$(t,L(e,n),rt,".md");for(let n of await b(e,".cursor/agents"))$(t,L(e,n),ft,".md");for(let n of await b(e,".cursor/skills"))W(t,L(e,n),".cursor/skills");return}t.set("AGENTS.md",`${P}/_root.md`);for(let n of await b(e,".cursor/rules"))$(t,L(e,n),P,".mdc");for(let n of await b(e,".cursor/commands"))$(t,L(e,n),rt,".md");for(let n of await b(e,".cursor/agents"))$(t,L(e,n),ft,".md");for(let n of await b(e,".cursor/skills"))W(t,L(e,n),".cursor/skills");}var xI=d(()=>{Nt();Rt();At();s(rd,"buildCursorImportPaths");});async function nd(t,e){for(let r of await b(e,".gemini/rules"))$(t,L(e,r),P,".md");for(let r of await b(e,".gemini/commands")){let n=L(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",l=(o.startsWith(i)?o.slice(i.length):o).split("/").filter(Boolean).join(":");t.set(n,`${rt}/${l}.md`);}for(let r of await b(e,".gemini/agents"))$(t,L(e,r),ft,".md");for(let r of await b(e,".gemini/skills"))W(t,L(e,r),".gemini/skills");}var PI=d(()=>{Nt();At();s(nd,"buildGeminiCliImportPaths");});var $r,Ne,Zt,On,TI,wn,os,Fe,DI,NI,Si=d(()=>{$r="goose",Ne=".goosehints",Zt=".agents/skills",On=".gooseignore",TI=".config/goose",wn=`${TI}/.goosehints`,os=`${TI}/.gooseignore`,Fe=".agents/skills",DI=".agentsmesh/rules",NI=".agentsmesh/ignore";});async function od(t,e,r="project"){if(r==="global"){t.set(wn,`${P}/_root.md`);for(let n of await b(e,Fe))W(t,L(e,n),Fe);t.set(os,".agentsmesh/ignore");return}t.set(Ne,`${P}/_root.md`);for(let n of await b(e,Zt))W(t,L(e,n),Zt);t.set(On,".agentsmesh/ignore");}var FI=d(()=>{Nt();Si();At();s(od,"buildGooseImportPaths");});var ss,lo,Fl,vI,Gr,MI,rF,qa,is,Qa,Ri,ki,tc,ec,rc,nc,oc,nF,vl,as,$I,sd,Ml,GI,jI,UI,KI,Oi=d(()=>{ss="junie",lo=".junie",Fl=`${lo}/guidelines.md`,vI=`${lo}/ci-guidelines.md`,Gr=`${lo}/AGENTS.md`,MI="AGENTS.md",rF=`${lo}/mcp`,qa=`${rF}/mcp.json`,is=`${lo}/skills`,Qa=`${lo}/rules`,Ri=`${lo}/commands`,ki=`${lo}/agents`,tc=".aiignore",ec=".junie",rc=`${ec}/skills`,nc=`${ec}/agents`,oc=`${ec}/commands`,nF=`${ec}/mcp`,vl=`${nF}/mcp.json`,as=`${ec}/AGENTS.md`,$I=".agents/skills",sd=".agentsmesh/rules/_root.md",Ml=".agentsmesh/rules",GI=".agentsmesh/commands",jI=".agentsmesh/agents",UI=".agentsmesh/mcp.json",KI=".agentsmesh/ignore";});async function id(t,e){t.set(Fl,`${P}/_root.md`),t.set(Gr,`${P}/_root.md`),t.set("AGENTS.md",`${P}/_root.md`);for(let r of await b(e,".junie/rules"))$(t,L(e,r),P,".md");for(let r of await b(e,".junie/commands"))$(t,L(e,r),rt,".md");for(let r of await b(e,".junie/agents"))$(t,L(e,r),ft,".md");for(let r of await b(e,".junie/skills"))W(t,L(e,r),".junie/skills");}var WI=d(()=>{Nt();Oi();At();s(id,"buildJunieImportPaths");});var qt,sc,jr,En,Ln,bn,ir,mo,wi,$l,cs,Ei,ls,ic,Gl,Li,po,ms,ps,us,uo,bi,jl,BI,fo,Ai,ds,HI,zI,fs=d(()=>{qt="kilo-code",sc=".kilo",jr="AGENTS.md",En=`${sc}/rules`,Ln=`${sc}/commands`,bn=`${sc}/agents`,ir=`${sc}/skills`,mo=`${sc}/mcp.json`,wi=".kilocodeignore",$l=".kilocode",cs=`${$l}/rules`,Ei=`${$l}/workflows`,ls=`${$l}/skills`,ic=`${$l}/mcp.json`,Gl=".kilocodemodes",Li=".kilo",po=`${Li}/AGENTS.md`,ms=`${Li}/rules`,ps=`${Li}/commands`,us=`${Li}/agents`,uo=`${Li}/skills`,bi=`${Li}/mcp.json`,jl=".kilocodeignore",BI=".agents/skills",fo=".agentsmesh/rules",Ai=".agentsmesh/commands",ds=".agentsmesh/agents",HI=".agentsmesh/mcp.json",zI=".agentsmesh/ignore";});async function ad(t,e,r="project"){if(r==="global"){t.set(po,`${P}/_root.md`);for(let n of await b(e,ms))$(t,L(e,n),P,".md");for(let n of await b(e,ps))$(t,L(e,n),rt,".md");for(let n of await b(e,us))$(t,L(e,n),ft,".md");for(let n of await b(e,uo))W(t,L(e,n),uo);t.set(bi,".agentsmesh/mcp.json");return}t.set(jr,`${P}/_root.md`);for(let n of await b(e,En))$(t,L(e,n),P,".md");for(let n of await b(e,Ln))$(t,L(e,n),rt,".md");for(let n of await b(e,bn))$(t,L(e,n),ft,".md");for(let n of await b(e,ir))W(t,L(e,n),ir);t.set(mo,".agentsmesh/mcp.json");for(let n of await b(e,cs)){let o=L(e,n);if(basename(o)==="00-root.md"){t.set(o,`${P}/_root.md`);continue}$(t,o,P,".md");}for(let n of await b(e,Ei))$(t,L(e,n),rt,".md");for(let n of await b(e,ls))W(t,L(e,n),ls);t.set(ic,".agentsmesh/mcp.json");}var VI=d(()=>{Nt();fs();At();s(ad,"buildKiloCodeImportPaths");});var fe,ar,ac,cr,Qt,lr,go,JI,xi,Pi,gs,mr,ho,hs,cc,lc,YI,cd,ld,XI,ZI,md,qI,Ti=d(()=>{fe="kiro",ar="AGENTS.md",ac=".kiro",cr=`${ac}/steering`,Qt=`${ac}/skills`,lr=`${ac}/agents`,go=`${ac}/hooks`,JI=`${ac}/settings`,xi=`${JI}/mcp.json`,Pi=".kiroignore",gs=".kiro/steering",mr=".kiro/steering/AGENTS.md",ho=".kiro/skills",hs=".kiro/agents",cc=".kiro/settings/mcp.json",lc=".kiro/settings/kiroignore",YI=".agents/skills",cd=".agentsmesh/rules/_root.md",ld=".agentsmesh/rules",XI=".agentsmesh/agents",ZI=".agentsmesh/mcp.json",md=".agentsmesh/hooks.yaml",qI=".agentsmesh/ignore";});async function pd(t,e,r="project"){if(r==="global"){t.set(mr,`${P}/_root.md`);for(let n of await b(e,gs)){let o=L(e,n);o!==mr&&$(t,o,P,".md");}for(let n of await b(e,ho))W(t,L(e,n),ho);for(let n of await b(e,hs))$(t,L(e,n),ft,".md");return}t.set(ar,`${P}/_root.md`);for(let n of await b(e,cr))$(t,L(e,n),P,".md");for(let n of await b(e,Qt))W(t,L(e,n),Qt);for(let n of await b(e,lr))$(t,L(e,n),ft,".md");}var QI=d(()=>{Nt();Ti();At();s(pd,"buildKiroImportPaths");});var pr,Ul,Ur,An,xn,Pn,ur,Kr,Di,yo,ys,_s,Is,_o,Io,tC,mc,Kl,Wl,ud,Cs=d(()=>{pr="opencode",Ul=".opencode",Ur="AGENTS.md",An=`${Ul}/rules`,xn=`${Ul}/commands`,Pn=`${Ul}/agents`,ur=`${Ul}/skills`,Kr="opencode.json",Di=".config/opencode",yo=`${Di}/AGENTS.md`,ys=`${Di}/rules`,_s=`${Di}/commands`,Is=`${Di}/agents`,_o=`${Di}/skills`,Io=`${Di}/opencode.json`,tC=".agents/skills",mc=".agentsmesh/rules",Kl=".agentsmesh/commands",Wl=".agentsmesh/agents",ud=".agentsmesh/mcp.json";});async function dd(t,e,r="project"){if(r==="global"){t.set(yo,`${P}/_root.md`);for(let n of await b(e,ys))$(t,L(e,n),P,".md");for(let n of await b(e,_s))$(t,L(e,n),rt,".md");for(let n of await b(e,Is))$(t,L(e,n),ft,".md");for(let n of await b(e,_o))W(t,L(e,n),_o);t.set(Io,".agentsmesh/mcp.json");return}t.set(Ur,`${P}/_root.md`);for(let n of await b(e,An))$(t,L(e,n),P,".md");for(let n of await b(e,xn))$(t,L(e,n),rt,".md");for(let n of await b(e,Pn))$(t,L(e,n),ft,".md");for(let n of await b(e,ur))W(t,L(e,n),ur);t.set(Kr,".agentsmesh/mcp.json");}var eC=d(()=>{Nt();Cs();At();s(dd,"buildOpencodeImportPaths");});var Co,Ss,dr,pc,Tn,Dn,Wr,uc,dc,Ni,fc,Bl,So,Ro,Nn,Rs,gc,ko,rC,ks,Hl,nC,oC,Os=d(()=>{Co="roo-code",Ss=".roo",dr=`${Ss}/rules/00-root.md`,pc=".roorules",Tn=`${Ss}/rules`,Dn=`${Ss}/commands`,Wr=`${Ss}/skills`,uc=`${Ss}/mcp.json`,dc=".rooignore",Ni=".roomodes",fc="settings/custom_modes.yaml",Bl=".roo",So=`${Bl}/rules`,Ro=`${Bl}/commands`,Nn=`${Bl}/skills`,Rs="mcp_settings.json",gc=".rooignore",ko=`${Bl}/AGENTS.md`,rC=".agents/skills",ks=".agentsmesh/rules",Hl=".agentsmesh/commands",nC=".agentsmesh/mcp.json",oC=".agentsmesh/ignore";});async function fd(t,e,r="project"){if(r==="global"){t.set(ko,`${P}/_root.md`);for(let n of await b(e,So))$(t,L(e,n),P,".md");for(let n of await b(e,Ro))$(t,L(e,n),rt,".md");for(let n of await b(e,Nn))W(t,L(e,n),Nn);t.set(Rs,".agentsmesh/mcp.json");return}t.set(dr,`${P}/_root.md`),t.set(pc,`${P}/_root.md`);for(let n of await b(e,Tn)){let o=L(e,n);o!==dr&&$(t,o,P,".md");}for(let n of await b(e,".roo")){let o=L(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&$(t,o,P,".md");}for(let n of await b(e,Dn))$(t,L(e,n),rt,".md");for(let n of await b(e,Wr))W(t,L(e,n),Wr);}var sC=d(()=>{Nt();Os();At();s(fd,"buildRooCodeImportPaths");});var Br,fr,gd,zt,Oo,se,iC,Fi=d(()=>{Br="warp",fr="AGENTS.md",gd="WARP.md",zt=".warp/skills",Oo=".mcp.json",se=".warp/skills",iC=".agentsmesh/rules";});async function hd(t,e,r="project"){if(r==="global"){for(let n of await b(e,se))W(t,L(e,n),se);return}t.set(fr,`${P}/_root.md`);for(let n of await b(e,zt))W(t,L(e,n),zt);t.set(Oo,".agentsmesh/mcp.json");}var aC=d(()=>{Nt();Fi();At();s(hd,"buildWarpImportPaths");});async function yd(t,e){t.set("AGENTS.md",`${P}/_root.md`),t.set(".windsurfrules",`${P}/_root.md`),await Ol(t,e);for(let r of await b(e,".windsurf/rules"))$(t,L(e,r),P,".md");for(let r of await b(e,".windsurf/workflows"))$(t,L(e,r),rt,".md");for(let r of await b(e,".windsurf/skills"))W(t,L(e,r),".windsurf/skills");}var cC=d(()=>{Nt();At();s(yd,"buildWindsurfImportPaths");});var gr,Hr,sF,zr,lC,ws=d(()=>{gr=".rules",Hr=".zed/settings.json",sF=".config/zed",zr=`${sF}/settings.json`,lC=".agentsmesh/rules";});async function _d(t,e,r="project"){if(r==="global"){t.set(zr,".agentsmesh/mcp.json");return}t.set(gr,`${P}/_root.md`),t.set(Hr,".agentsmesh/mcp.json");}var mC=d(()=>{ws();At();s(_d,"buildZedImportPaths");});var pC=d(()=>{fI();hI();CI();kI();OI();wI();EI();xI();PI();FI();WI();VI();QI();eC();sC();aC();cC();mC();});var xt=d(()=>{pC();});function lF(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 iF,aF,cF,uC,kl,Pu=d(()=>{ne();dt();K_();ue();tI();iI();mI();xt();Jo();iF={name:"amp",primaryRootInstructionPath:be,generateRules:$_,generateCommands:j_,generateAgents:U_,generateSkills:G_,importFrom:Q_},aF={rootInstructionPath:be,skillDir:Bt,managedOutputs:{dirs:[Bt],files:[be,br]},paths:{rulePath(t){return be},commandPath(t){return `${Bt}/${st(t)}/SKILL.md`},agentPath(t){return `${Bt}/${V(t)}/SKILL.md`}}},cF={rootInstructionPath:un,skillDir:Ae,managedOutputs:{dirs:[Ae],files:[un,dn]},rewriteGeneratedPath(t){return t===be?un:t===br?dn:t.startsWith(`${Bt}/`)?t.replace(`${Bt}/`,`${Ae}/`):t},mirrorGlobalPath(t,e){return at(t,Ae,e)},paths:{rulePath(t){return un},commandPath(t){return `${Ae}/${st(t)}/SKILL.md`},agentPath(t){return `${Ae}/${V(t)}/SKILL.md`}}},uC={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(lF,"mergeAmpSettings");kl={id:"amp",generators:iF,capabilities:uC,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:sI,lint:{hooks:aI,permissions:cI,ignore:lI},supportsConversion:{commands:true,agents:true},project:aF,globalSupport:{capabilities:uC,detectionPaths:[un,dn],layout:cF},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[be],global:[un]},canonicalDir:M_,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:br,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===br||n===dn?lF(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Fu,detectionPaths:[be,br]};});function dC(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:er,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:`${Ar}/${o}.md`,content:n.body.trim()||""});}return r}function fC(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
52
52
 
53
- ${n}`:n||r;return {path:`${hn}/${e.name}.md`,content:o}})}function gC(t){return St(t,rr)}function hC(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ma,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function yC(t){return t.agents.map(e=>({path:`${rr}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function _C(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 Et(e?.body.trim()??"",r)}var IC=d(()=>{_t();we();dt();Zo();s(dC,"generateRules");s(fC,"generateCommands");s(gC,"generateSkills");s(hC,"generateMcp");s(yC,"generateAgents");s(_C,"renderAntigravityGlobalInstructions");});function cF(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function Vr(t){let e=b_(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=cF(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:c,body:l}=w(a),m=await j(i,{...c,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},l);await S(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var vi=d(()=>{A();M();we();et();s(cF,"canonicalRulePath");s(Vr,"splitEmbeddedRulesToCanonical");});async function lF(t,e,r,n){let o=n==="global"?xr:er,i=n==="project"?[o,va]:[o];for(let a of i){let c=join(t,a),l=await y(c);if(l===null)continue;let m=join(t,vu),p=await Vr({content:l,projectRoot:t,rulesDir:Xo,sourcePath:c,fromTool:Yo,normalize:r});e.push(...p.results);let{body:u}=w(r(p.rootContent,c,m)),f=await j(m,{root:true},u);await O(join(t,Xo)),await S(m,f),e.push({fromTool:Yo,fromPath:c,toPath:vu,feature:"rules"});return}}async function SC(t,e={}){let r=e.scope??"project",n=[],o=await z(Yo,t,r);return await lF(t,n,o,r),n.push(...await Q(Hl,t,r,{normalize:o})),await yt(t,r==="global"?yn:rr,Yo,n,o),n}var RC=d(()=>{It();A();M();_t();Mt();et();vi();Zo();Cd();s(lF,"importRootRule");s(SC,"importFromAntigravity");});var wC,EC,LC=d(()=>{M();et();Zo();wC=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}=w(e(n));return {destPath:n,toPath:`${Xo}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"nonRootRuleMapper"),EC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${wl}/${t}`,content:await ot(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function bC(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Yo}))}var AC=d(()=>{$t();Zo();s(bC,"lintRules");});var mF,pF,uF,dF,Hl,Cd=d(()=>{Vo();dt();IC();Zo();RC();LC();AC();xt();mF={name:"antigravity",primaryRootInstructionPath:er,generateRules:dC,generateCommands:fC,generateAgents:yC,generateSkills:gC,generateMcp:hC,importFrom:SC},pF={rootInstructionPath:er,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===Ma?null:t},paths:{rulePath(t,e){return `${Ar}/${t}.md`},commandPath(t,e){return `${hn}/${t}.md`},agentPath(t){return `${rr}/${V(t)}/SKILL.md`}}},uF={rootInstructionPath:xr,renderPrimaryRootInstruction:_C,skillDir:yn,managedOutputs:{dirs:[yn,$a],files:[xr,fi]},rewriteGeneratedPath(t){return t===er?xr:t.startsWith(`${Ar}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",yn):t.startsWith(`${hn}/`)?t.replace(hn,$a):t===Ma?fi:t},paths:{rulePath(t,e){return xr},commandPath(t,e){return `${$a}/${t}.md`},agentPath(t){return `${rr}/${V(t)}/SKILL.md`}}},dF={rules:"native",additionalRules:"embedded",commands:Ze("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Hl={id:"antigravity",generators:mF,capabilities:{rules:"native",additionalRules:"native",commands:Ze("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:bC,project:pF,globalSupport:{capabilities:dF,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:uF},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Ar]},canonicalDir:Xo,extensions:[".md"],map:wC},commands:{feature:"commands",mode:"directory",source:{project:[hn],global:[$a]},canonicalDir:wl,extensions:[".md"],map:EC},mcp:{feature:"mcp",mode:"flatFile",source:{global:[fi]},canonicalDir:".agentsmesh",canonicalFilename:gI}},buildImportPaths:Mu,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function xC(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(!Or(i))continue;let a=wt(i),c=Yt(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var PC=d(()=>{Je();s(xC,"buildClaudeHooksObjectFromCanonical");});function TC(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:to,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 c=F(a,o.body.trim()||"");e.push({path:`${Ga}/${i}.md`,content:c});}return e}function DC(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=F(r,e.body.trim()||"");return {path:`${ja}/${e.name}.md`,content:n}})}function NC(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
53
+ ${n}`:n||r;return {path:`${hn}/${e.name}.md`,content:o}})}function gC(t){return St(t,rr)}function hC(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:$a,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function yC(t){return t.agents.map(e=>({path:`${rr}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function _C(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 Et(e?.body.trim()??"",r)}var IC=d(()=>{_t();we();dt();Zo();s(dC,"generateRules");s(fC,"generateCommands");s(gC,"generateSkills");s(hC,"generateMcp");s(yC,"generateAgents");s(_C,"renderAntigravityGlobalInstructions");});function pF(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function Vr(t){let e=b_(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=pF(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:c,body:l}=w(a),m=await j(i,{...c,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},l);await S(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var vi=d(()=>{A();M();we();et();s(pF,"canonicalRulePath");s(Vr,"splitEmbeddedRulesToCanonical");});async function uF(t,e,r,n){let o=n==="global"?xr:er,i=n==="project"?[o,Ma]:[o];for(let a of i){let c=join(t,a),l=await y(c);if(l===null)continue;let m=join(t,vu),p=await Vr({content:l,projectRoot:t,rulesDir:Xo,sourcePath:c,fromTool:Yo,normalize:r});e.push(...p.results);let{body:u}=w(r(p.rootContent,c,m)),f=await j(m,{root:true},u);await O(join(t,Xo)),await S(m,f),e.push({fromTool:Yo,fromPath:c,toPath:vu,feature:"rules"});return}}async function SC(t,e={}){let r=e.scope??"project",n=[],o=await z(Yo,t,r);return await uF(t,n,o,r),n.push(...await Q(zl,t,r,{normalize:o})),await yt(t,r==="global"?yn:rr,Yo,n,o),n}var RC=d(()=>{It();A();M();_t();Mt();et();vi();Zo();Cd();s(uF,"importRootRule");s(SC,"importFromAntigravity");});var wC,EC,LC=d(()=>{M();et();Zo();wC=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}=w(e(n));return {destPath:n,toPath:`${Xo}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"nonRootRuleMapper"),EC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${El}/${t}`,content:await ot(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function bC(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Yo}))}var AC=d(()=>{$t();Zo();s(bC,"lintRules");});var dF,fF,gF,hF,zl,Cd=d(()=>{Vo();dt();IC();Zo();RC();LC();AC();xt();dF={name:"antigravity",primaryRootInstructionPath:er,generateRules:dC,generateCommands:fC,generateAgents:yC,generateSkills:gC,generateMcp:hC,importFrom:SC},fF={rootInstructionPath:er,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===$a?null:t},paths:{rulePath(t,e){return `${Ar}/${t}.md`},commandPath(t,e){return `${hn}/${t}.md`},agentPath(t){return `${rr}/${V(t)}/SKILL.md`}}},gF={rootInstructionPath:xr,renderPrimaryRootInstruction:_C,skillDir:yn,managedOutputs:{dirs:[yn,Ga],files:[xr,fi]},rewriteGeneratedPath(t){return t===er?xr:t.startsWith(`${Ar}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",yn):t.startsWith(`${hn}/`)?t.replace(hn,Ga):t===$a?fi:t},paths:{rulePath(t,e){return xr},commandPath(t,e){return `${Ga}/${t}.md`},agentPath(t){return `${rr}/${V(t)}/SKILL.md`}}},hF={rules:"native",additionalRules:"embedded",commands:Ze("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},zl={id:"antigravity",generators:dF,capabilities:{rules:"native",additionalRules:"native",commands:Ze("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:bC,project:fF,globalSupport:{capabilities:hF,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:gF},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Ar]},canonicalDir:Xo,extensions:[".md"],map:wC},commands:{feature:"commands",mode:"directory",source:{project:[hn],global:[Ga]},canonicalDir:El,extensions:[".md"],map:EC},mcp:{feature:"mcp",mode:"flatFile",source:{global:[fi]},canonicalDir:".agentsmesh",canonicalFilename:gI}},buildImportPaths:Mu,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function xC(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(!Or(i))continue;let a=wt(i),c=Yt(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var PC=d(()=>{Je();s(xC,"buildClaudeHooksObjectFromCanonical");});function TC(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:to,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 c=F(a,o.body.trim()||"");e.push({path:`${ja}/${i}.md`,content:c});}return e}function DC(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=F(r,e.body.trim()||"");return {path:`${Ua}/${e.name}.md`,content:n}})}function NC(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
54
54
 
55
- ${n}`,i=F(r,o);return {path:`${Ua}/${e.name}.md`,content:i}})}function FC(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:gi,content:e}]}function vC(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
55
+ ${n}`,i=F(r,o);return {path:`${Ka}/${e.name}.md`,content:i}})}function FC(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:gi,content:e}]}function vC(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
56
56
 
57
- ${o}`,a=F(n,i);e.push({path:`${Ka}/${r.name}/SKILL.md`,content:a});for(let c of r.supportingFiles){let l=c.relativePath.replace(/\\/g,"/");e.push({path:`${Ka}/${r.name}/${l}`,content:c.content});}}return e}function MC(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:Wa,content:o}]}function $C(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=xC(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:_n,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:Wa,content:n}]}function GC(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
58
- `);return [{path:Ba,content:e}]}var jC=d(()=>{M();In();PC();s(TC,"generateRules");s(DC,"generateCommands");s(NC,"generateAgents");s(FC,"generateMcp");s(vC,"generateSkills");s(MC,"generatePermissions");s($C,"generateHooks");s(GC,"generateIgnore");});function hF(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function UC(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
57
+ ${o}`,a=F(n,i);e.push({path:`${Wa}/${r.name}/SKILL.md`,content:a});for(let c of r.supportingFiles){let l=c.relativePath.replace(/\\/g,"/");e.push({path:`${Wa}/${r.name}/${l}`,content:c.content});}}return e}function MC(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:Ba,content:o}]}function $C(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=xC(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:_n,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:Ba,content:n}]}function GC(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
58
+ `);return [{path:Ha,content:e}]}var jC=d(()=>{M();In();PC();s(TC,"generateRules");s(DC,"generateCommands");s(NC,"generateAgents");s(FC,"generateMcp");s(vC,"generateSkills");s(MC,"generatePermissions");s($C,"generateHooks");s(GC,"generateIgnore");});function IF(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function UC(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
59
59
 
60
- ## ${e?hF(e):"Guidance"}
60
+ ## ${e?IF(e):"Guidance"}
61
61
 
62
62
  ${r}
63
- `:""}var KC=d(()=>{s(hF,"ruleSectionTitle");s(UC,"renderClaudeGlobalPrimaryInstructions");});function BC(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function HC(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 c of t.agents){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=F(l,c.body.trim()),p=`${$u}/${c.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:BC(u,m)});}if(i)for(let c of t.commands){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=F(l,c.body.trim()),p=`${$u}/${c.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:BC(u,m)});}return a}var zC=d(()=>{A();M();In();s(BC,"computeStatus");s(HC,"generateClaudeGlobalExtras");});var VC,JC,YC,XC=d(()=>{M();et();Qe();In();VC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${za}/${t}`,content:await j(n,{...o,root:false},i)}},"claudeRuleMapper"),JC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n)),a=xe(o.allowedTools),c=a.length>0?a:xe(o["allowed-tools"]);return {destPath:n,toPath:`${El}/${t}`,content:await ot(n,{description:typeof o.description=="string"?o.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"claudeCommandMapper"),YC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Ll}/${t}`,content:await Lt(n,o,i)}},"claudeAgentMapper");});function ZC(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:yI}))}var qC=d(()=>{$t();In();s(ZC,"lintRules");});var yF,QC,_F,IF,zl,Rd=d(()=>{jC();In();ue();KC();zC();kd();XC();qC();xt();yF={name:"claude-code",primaryRootInstructionPath:to,generateRules:TC,generateCommands:DC,generateAgents:NC,generateSkills:vC,generateMcp:FC,generatePermissions:MC,generateHooks:$C,generateIgnore:GC,importFrom:Vl},QC={rootInstructionPath:to,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`}}},_F={rootInstructionPath:to,skillDir:".claude/skills",renderPrimaryRootInstruction:UC,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",Ha,_n,".claudeignore"]},rewriteGeneratedPath(t){return t===gi?Ha:t},mirrorGlobalPath(t,e){return at(t,".claude/skills",e)},paths:QC.paths},IF={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},zl={id:"claude-code",generators:yF,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:ZC,project:QC,globalSupport:{capabilities:IF,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:_F,scopeExtras:HC},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[to,_I],global:[to]},canonicalDir:za,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Ga],global:[Ga]},canonicalDir:za,extensions:[".md"],map:VC}],commands:{feature:"commands",mode:"directory",source:{project:[ja],global:[ja]},canonicalDir:El,extensions:[".md"],map:JC},agents:{feature:"agents",mode:"directory",source:{project:[Ua],global:[Ua]},canonicalDir:Ll,extensions:[".md"],map:YC},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[gi],global:[Ha]},canonicalDir:".agentsmesh",canonicalFilename:Va},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ba],global:[Ba]},canonicalDir:".agentsmesh",canonicalFilename:II}},buildImportPaths:Uu,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function SF(t){let e=basename(t,".md");return e==="_root"?"root":e}function tS(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:ro,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=SF(n.source),i={description:n.description||void 0,paths:n.globs.length>0?n.globs:void 0};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=Object.keys(i).length>0?F(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Cn}/${o}.md`,content:a});}return e}function eS(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
63
+ `:""}var KC=d(()=>{s(IF,"ruleSectionTitle");s(UC,"renderClaudeGlobalPrimaryInstructions");});function BC(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function HC(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 c of t.agents){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=F(l,c.body.trim()),p=`${$u}/${c.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:BC(u,m)});}if(i)for(let c of t.commands){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=F(l,c.body.trim()),p=`${$u}/${c.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:BC(u,m)});}return a}var zC=d(()=>{A();M();In();s(BC,"computeStatus");s(HC,"generateClaudeGlobalExtras");});var VC,JC,YC,XC=d(()=>{M();et();Qe();In();VC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Va}/${t}`,content:await j(n,{...o,root:false},i)}},"claudeRuleMapper"),JC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n)),a=xe(o.allowedTools),c=a.length>0?a:xe(o["allowed-tools"]);return {destPath:n,toPath:`${Ll}/${t}`,content:await ot(n,{description:typeof o.description=="string"?o.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"claudeCommandMapper"),YC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${bl}/${t}`,content:await Lt(n,o,i)}},"claudeAgentMapper");});function ZC(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:yI}))}var qC=d(()=>{$t();In();s(ZC,"lintRules");});var CF,QC,SF,RF,Vl,Rd=d(()=>{jC();In();ue();KC();zC();kd();XC();qC();xt();CF={name:"claude-code",primaryRootInstructionPath:to,generateRules:TC,generateCommands:DC,generateAgents:NC,generateSkills:vC,generateMcp:FC,generatePermissions:MC,generateHooks:$C,generateIgnore:GC,importFrom:Jl},QC={rootInstructionPath:to,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`}}},SF={rootInstructionPath:to,skillDir:".claude/skills",renderPrimaryRootInstruction:UC,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",za,_n,".claudeignore"]},rewriteGeneratedPath(t){return t===gi?za:t},mirrorGlobalPath(t,e){return at(t,".claude/skills",e)},paths:QC.paths},RF={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},Vl={id:"claude-code",generators:CF,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:ZC,project:QC,globalSupport:{capabilities:RF,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:SF,scopeExtras:HC},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[to,_I],global:[to]},canonicalDir:Va,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[ja],global:[ja]},canonicalDir:Va,extensions:[".md"],map:VC}],commands:{feature:"commands",mode:"directory",source:{project:[Ua],global:[Ua]},canonicalDir:Ll,extensions:[".md"],map:JC},agents:{feature:"agents",mode:"directory",source:{project:[Ka],global:[Ka]},canonicalDir:bl,extensions:[".md"],map:YC},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[gi],global:[za]},canonicalDir:".agentsmesh",canonicalFilename:Ja},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ha],global:[Ha]},canonicalDir:".agentsmesh",canonicalFilename:II}},buildImportPaths:Uu,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function OF(t){let e=basename(t,".md");return e==="_root"?"root":e}function tS(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:ro,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=OF(n.source),i={description:n.description||void 0,paths:n.globs.length>0?n.globs:void 0};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=Object.keys(i).length>0?F(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Cn}/${o}.md`,content:a});}return e}function eS(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
64
64
 
65
65
  ${n}`:r||n;return {path:`${Pr}/${e.name}.md`,content:o}})}function rS(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
66
- `);return [{path:Qo,content:e}]}function nS(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Sn,content:e}]}function oS(t){return t.agents.map(e=>({path:`${Gt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function RF(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function kF(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${t}`,`# agentsmesh-matcher: ${r}`,`# agentsmesh-command: ${e}`,"set -e",e,""].join(`
67
- `)}function sS(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)mn(i)&&(e.push({path:`${ts}/${RF(r)}-${o}.sh`,content:kF(r,i.command,i.matcher)}),o++);}return e}function iS(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=F(n,r.body.trim()||"");e.push({path:`${Gt}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Gt}/${r.name}/${a}`,content:i.content});}}return e}var aS=d(()=>{Je();M();dt();Pe();s(SF,"ruleSlug");s(tS,"generateRules");s(eS,"generateCommands");s(rS,"generateIgnore");s(nS,"generateMcp");s(oS,"generateAgents");s(RF,"safeEventName");s(kF,"buildHookScript");s(sS,"generateHooks");s(iS,"generateSkills");});async function lS(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}=w(r(o)),c=gn(i.paths??i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:o,toPath:`${no}/${n}`,feature:"rules",content:await j(o,l,a)}}async function mS(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=w(r(n)),a=Object.prototype.hasOwnProperty.call(o,"description"),c=a&&typeof o.description=="string"?o.description:"",l=a,m=i;if(!l){let p=i.indexOf(`
66
+ `);return [{path:Qo,content:e}]}function nS(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Sn,content:e}]}function oS(t){return t.agents.map(e=>({path:`${Gt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function wF(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function EF(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${t}`,`# agentsmesh-matcher: ${r}`,`# agentsmesh-command: ${e}`,"set -e",e,""].join(`
67
+ `)}function sS(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)mn(i)&&(e.push({path:`${ts}/${wF(r)}-${o}.sh`,content:EF(r,i.command,i.matcher)}),o++);}return e}function iS(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=F(n,r.body.trim()||"");e.push({path:`${Gt}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Gt}/${r.name}/${a}`,content:i.content});}}return e}var aS=d(()=>{Je();M();dt();Pe();s(OF,"ruleSlug");s(tS,"generateRules");s(eS,"generateCommands");s(rS,"generateIgnore");s(nS,"generateMcp");s(oS,"generateAgents");s(wF,"safeEventName");s(EF,"buildHookScript");s(sS,"generateHooks");s(iS,"generateSkills");});async function lS(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}=w(r(o)),c=gn(i.paths??i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:o,toPath:`${no}/${n}`,feature:"rules",content:await j(o,l,a)}}async function mS(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=w(r(n)),a=Object.prototype.hasOwnProperty.call(o,"description"),c=a&&typeof o.description=="string"?o.description:"",l=a,m=i;if(!l){let p=i.indexOf(`
68
68
 
69
69
  `);if(p>0){let u=i.slice(0,p).trim();u&&!u.includes(`
70
- `)&&(c=u,l=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${bl}/${t}`,feature:"commands",content:await ot(n,{description:c,hasDescription:l,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var Od=d(()=>{M();et();Qe();Pe();s(lS,"mapClineRuleFile");s(mS,"mapClineWorkflowFile");});async function pS(t,e,r){let n=join(t,no),o=join(t,Cn),i=join(t,Cn),a=false;try{a=(await stat(i)).isFile();}catch{}if(a){let p=await y(i);if(p!==null){await O(n);let u=join(n,"_root.md"),{frontmatter:f,body:g}=w(r(p,i,u)),R=f.root===true?f:{...f,root:true},C=await j(u,R,g);await S(u,C),e.push({fromTool:"cline",fromPath:i,toPath:`${no}/_root.md`,feature:"rules"});}return a}let c=null,l=join(o,"_root.md"),m=await y(l);if(m===null){let p=join(t,ro),u=await y(p);if(u!==null){c=p,await O(n);let f=join(n,"_root.md"),{frontmatter:g,body:h}=w(r(u,p,f)),C=g.root===true?g:{...g,root:true},_=await j(f,C,h);await S(f,_),e.push({fromTool:"cline",fromPath:p,toPath:`${no}/_root.md`,feature:"rules"});}else {let h=(await N(o)).filter(R=>R.endsWith(".md")&&!R.includes("/workflows/")).sort()[0];if(h){let R=await y(h);if(R!==null){c=h,await O(n);let C=join(n,"_root.md"),{frontmatter:_,body:E}=w(r(R,h,C)),D=_.root===true?_:{..._,root:true},x=await j(C,D,E);await S(C,x),e.push({fromTool:"cline",fromPath:h,toPath:`${no}/_root.md`,feature:"rules"});}}}}else {c=l,await O(n);let p=join(n,"_root.md"),{frontmatter:u,body:f}=w(r(m,l,p)),h=u.root===true?u:{...u,root:true},R=await j(p,h,f);await S(p,R),e.push({fromTool:"cline",fromPath:l,toPath:`${no}/_root.md`,feature:"rules"});}return e.push(...await mt({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:f})=>p===c?null:lS(u,n,f),"mapEntry")})),a}var uS=d(()=>{A();M();et();tr();Od();Pe();s(pS,"importClineRules");});function wF(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(l=>typeof l=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(l=>typeof l[1]=="string")):{},c=typeof e.description=="string"?e.description:void 0;return {...c!==void 0&&{description:c},type:n,command:r,args:o,env:a}}async function dS(t,e){let r=[Sn,SI].map(l=>join(t,l)),n=null,o=null;for(let l of r){let m=await y(l);if(m!==null){n=l,o=m;break}}if(o===null)return;let i=n??r[0],a;try{a=JSON.parse(o);}catch{}let c=a?.mcpServers;if(c!==void 0&&typeof c=="object"&&c!==null&&Object.keys(c).length>0){let l={};for(let[m,p]of Object.entries(c)){let u=wF(p);u&&(l[m]=u);}Object.keys(l).length>0&&(await O(join(t,".agentsmesh")),await S(join(t,Bu),JSON.stringify({mcpServers:l},null,2)),e.push({fromTool:eo,fromPath:i,toPath:Bu,feature:"mcp"}));}}var fS=d(()=>{A();Pe();s(wF,"mapClineServerToCanonical");s(dS,"importClineMcp");});function gS(t){return EF.some(e=>e.test(t))}var EF,hS=d(()=>{EF=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(gS,"isReservedArtifactName");});async function bF(t){let e=await N(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(gS(i))continue;let a=await y(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Jr(t,e,r){let n=await bF(e),o=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of n){let a=join(o,i.relativePath);await O(dirname(a));let c=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:l,body:m}=w(c),p=await Lr(a,{...l,name:t},m);await S(a,p);}else await S(a,c);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function _S(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:c,body:l}=w(a),m=await Lr(i,{...c,name:t},l);await S(i,m),n.results.push({fromTool:n.targetName,fromPath:e,toPath:`${n.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function wo(t){let e=new Map;try{let n=(await N(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}var Mi=d(()=>{A();M();et();hS();s(bF,"readNativeSkill");s(Jr,"importDirectorySkill");s(_S,"importFlatSkill");s(wo,"findDirectorySkills");});async function IS(t,e,r,n=Gt){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:RI,targetName:"cline",normalize:r,results:e};for(let[c,l]of i){let m=join(l,"SKILL.md"),p=await y(m);if(!p)continue;let u=w(p),f=Er(u.frontmatter,c);if(f){let g=join(t,Hu);await O(g);let h=join(g,`${f.name}.md`);await S(h,Oe(f,r(u.body,m,h))),e.push({fromTool:"cline",fromPath:m,toPath:`${Hu}/${f.name}.md`,feature:"agents"});continue}await Jr(c,l,a);}}var CS=d(()=>{A();M();dt();Mi();Pe();s(IS,"importClineSkills");});function Ld(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function SS(t,e){let n=(await N(t).catch(()=>[])).filter(o=>basename(o).endsWith(".sh")&&dirname(o)===t);for(let o of n){let i=await y(o);if(!i)continue;let a=Ld(i,"event"),c=Ld(i,"command");if(!a||!c)continue;let l=Ld(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:l,command:c});}}async function kS(t,e){let r={};if(await SS(join(t,ts),r),await SS(join(t,ns),r),Object.keys(r).length===0)return;let n=join(t,Ku);await O(dirname(n)),await S(n,stringify(r)),e.push({fromTool:eo,fromPath:join(t,ns),toPath:Ku,feature:"hooks"});}var OS=d(()=>{A();Pe();s(Ld,"extractMeta");s(SS,"loadHooksFromDir");s(kS,"importClineHooks");});async function Zl(t){let e=[],r=await z(eo,t),n=await pS(t,e,r),o=join(t,Qo),i=await y(o);if(i!==null&&i.trim()){let c=i.split(/\r?\n/),l=[];for(let m of c){let p=m.trim();p&&!p.startsWith("#")&&l.push(p);}if(l.length>0){await O(join(t,".agentsmesh"));let m=join(t,Wu);await S(m,l.join(`
71
- `)),e.push({fromTool:"cline",fromPath:o,toPath:Wu,feature:"ignore"});}}await dS(t,e);let a=join(t,bl);return n||e.push(...await mt({srcDir:join(t,Pr),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:c,normalizeTo:l})=>mS(c,a,l),"mapEntry")})),await IS(t,e,r),await kS(t,e),e}var bd=d(()=>{It();A();tr();Od();uS();Pe();fS();CS();OS();s(Zl,"importFromCline");});function wS(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:eo}))}var ES=d(()=>{$t();Pe();s(wS,"lintRules");});function LS(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>U(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function bS(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".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 AS=d(()=>{bt();s(LS,"lintCommands");s(bS,"lintHooks");});var PF,TF,DF,NF,xS,PS=d(()=>{aS();Vo();Pe();bd();ES();AS();xt();si();dt();PF={name:"cline",primaryRootInstructionPath:ro,generateRules:tS,generateCommands:eS,generateAgents:oS,generateSkills:iS,generateMcp:nS,generateHooks:sS,generateIgnore:rS,importFrom:Zl},TF={rootInstructionPath:ro,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 `${Cn}/${t}.md`},commandPath(t,e){return `${Pr}/${t}.md`},agentPath(t,e){return ke(e,"cline")?`.cline/skills/${V(t)}/SKILL.md`:null}}},DF={skillDir:Gt,managedOutputs:{dirs:[es,rs,ns,Gt,".agents/skills"],files:[Sn,Qo]},rewriteGeneratedPath(t){return t===ro?null:t.startsWith(`${ts}/`)?`${ns}/${t.slice(ts.length+1)}`:t.startsWith(`${Pr}/`)?`${rs}/${t.slice(Pr.length+1)}`:t.startsWith(`${Cn}/`)?`${es}/${t.slice(Cn.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${Gt}/`)?`.agents/skills/${t.slice(Gt.length+1)}`:null},paths:{rulePath(t,e){return `${es}/${t}.md`},commandPath(t,e){return `${rs}/${t}.md`},agentPath(t,e){return ke(e,"cline")?`.cline/skills/${V(t)}/SKILL.md`:null}}},NF={rules:"native",additionalRules:"native",commands:Ze("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},xS={id:"cline",generators:PF,capabilities:{rules:"native",additionalRules:"native",commands:Ze("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:wS,lint:{commands:LS,hooks:bS},project:TF,globalSupport:{capabilities:NF,detectionPaths:[es,rs,ns,Gt,Sn,Qo],layout:DF},buildImportPaths:zu,detectionPaths:[".clinerules",".cline"]};});var jt,TS,vn,Es,DS,hr,NS,ql,Ls,Yr,bs,Mn,Ad,$i,hc,xd,FS,Pd,vS,MS,Td,Dd,Nd,Vt=d(()=>{jt="codex-cli",TS="codex.md",vn="AGENTS.md",Es=".codex/AGENTS.md",DS=".codex/AGENTS.override.md",hr=".agents/skills",NS=".codex/skills",ql=".codex/config.toml",Ls=".codex/instructions",Yr=".codex/rules",bs=".codex/agents",Mn=".agentsmesh/rules",Ad=".agentsmesh/commands",$i=".agentsmesh/agents",hc=".agentsmesh/skills",xd=".agentsmesh/mcp.json",FS="am-codex-rule:v1",Pd="# am-json: ",vS="# am-body-b64-begin",MS="# am-body-b64-end",Td="# am64:",Dd="<!-- agentsmesh:codex-rule-index:start -->",Nd="<!-- agentsmesh:codex-rule-index:end -->";});function Fd(t){return basename(t,".md")}function yc(t){return `${Ls}/${Fd(t.source)}.md`}function $S(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];}),F(e,t.body.trim()||"")}function vF(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 \`${Yr}/${Fd(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function GS(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||Fd(a.source)}](${yc(a)}): ${vF(a)}`),i=[Dd,"## Additional Rule Files",...o,Nd].join(`
70
+ `)&&(c=u,l=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${Al}/${t}`,feature:"commands",content:await ot(n,{description:c,hasDescription:l,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var Od=d(()=>{M();et();Qe();Pe();s(lS,"mapClineRuleFile");s(mS,"mapClineWorkflowFile");});async function pS(t,e,r){let n=join(t,no),o=join(t,Cn),i=join(t,Cn),a=false;try{a=(await stat(i)).isFile();}catch{}if(a){let p=await y(i);if(p!==null){await O(n);let u=join(n,"_root.md"),{frontmatter:f,body:g}=w(r(p,i,u)),R=f.root===true?f:{...f,root:true},C=await j(u,R,g);await S(u,C),e.push({fromTool:"cline",fromPath:i,toPath:`${no}/_root.md`,feature:"rules"});}return a}let c=null,l=join(o,"_root.md"),m=await y(l);if(m===null){let p=join(t,ro),u=await y(p);if(u!==null){c=p,await O(n);let f=join(n,"_root.md"),{frontmatter:g,body:h}=w(r(u,p,f)),C=g.root===true?g:{...g,root:true},_=await j(f,C,h);await S(f,_),e.push({fromTool:"cline",fromPath:p,toPath:`${no}/_root.md`,feature:"rules"});}else {let h=(await N(o)).filter(R=>R.endsWith(".md")&&!R.includes("/workflows/")).sort()[0];if(h){let R=await y(h);if(R!==null){c=h,await O(n);let C=join(n,"_root.md"),{frontmatter:_,body:E}=w(r(R,h,C)),D=_.root===true?_:{..._,root:true},x=await j(C,D,E);await S(C,x),e.push({fromTool:"cline",fromPath:h,toPath:`${no}/_root.md`,feature:"rules"});}}}}else {c=l,await O(n);let p=join(n,"_root.md"),{frontmatter:u,body:f}=w(r(m,l,p)),h=u.root===true?u:{...u,root:true},R=await j(p,h,f);await S(p,R),e.push({fromTool:"cline",fromPath:l,toPath:`${no}/_root.md`,feature:"rules"});}return e.push(...await mt({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:f})=>p===c?null:lS(u,n,f),"mapEntry")})),a}var uS=d(()=>{A();M();et();tr();Od();Pe();s(pS,"importClineRules");});function bF(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(l=>typeof l=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(l=>typeof l[1]=="string")):{},c=typeof e.description=="string"?e.description:void 0;return {...c!==void 0&&{description:c},type:n,command:r,args:o,env:a}}async function dS(t,e){let r=[Sn,SI].map(l=>join(t,l)),n=null,o=null;for(let l of r){let m=await y(l);if(m!==null){n=l,o=m;break}}if(o===null)return;let i=n??r[0],a;try{a=JSON.parse(o);}catch{}let c=a?.mcpServers;if(c!==void 0&&typeof c=="object"&&c!==null&&Object.keys(c).length>0){let l={};for(let[m,p]of Object.entries(c)){let u=bF(p);u&&(l[m]=u);}Object.keys(l).length>0&&(await O(join(t,".agentsmesh")),await S(join(t,Bu),JSON.stringify({mcpServers:l},null,2)),e.push({fromTool:eo,fromPath:i,toPath:Bu,feature:"mcp"}));}}var fS=d(()=>{A();Pe();s(bF,"mapClineServerToCanonical");s(dS,"importClineMcp");});function gS(t){return AF.some(e=>e.test(t))}var AF,hS=d(()=>{AF=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(gS,"isReservedArtifactName");});async function PF(t){let e=await N(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(gS(i))continue;let a=await y(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Jr(t,e,r){let n=await PF(e),o=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of n){let a=join(o,i.relativePath);await O(dirname(a));let c=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:l,body:m}=w(c),p=await Lr(a,{...l,name:t},m);await S(a,p);}else await S(a,c);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function _S(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:c,body:l}=w(a),m=await Lr(i,{...c,name:t},l);await S(i,m),n.results.push({fromTool:n.targetName,fromPath:e,toPath:`${n.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function wo(t){let e=new Map;try{let n=(await N(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}var Mi=d(()=>{A();M();et();hS();s(PF,"readNativeSkill");s(Jr,"importDirectorySkill");s(_S,"importFlatSkill");s(wo,"findDirectorySkills");});async function IS(t,e,r,n=Gt){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:RI,targetName:"cline",normalize:r,results:e};for(let[c,l]of i){let m=join(l,"SKILL.md"),p=await y(m);if(!p)continue;let u=w(p),f=Er(u.frontmatter,c);if(f){let g=join(t,Hu);await O(g);let h=join(g,`${f.name}.md`);await S(h,Oe(f,r(u.body,m,h))),e.push({fromTool:"cline",fromPath:m,toPath:`${Hu}/${f.name}.md`,feature:"agents"});continue}await Jr(c,l,a);}}var CS=d(()=>{A();M();dt();Mi();Pe();s(IS,"importClineSkills");});function Ld(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function SS(t,e){let n=(await N(t).catch(()=>[])).filter(o=>basename(o).endsWith(".sh")&&dirname(o)===t);for(let o of n){let i=await y(o);if(!i)continue;let a=Ld(i,"event"),c=Ld(i,"command");if(!a||!c)continue;let l=Ld(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:l,command:c});}}async function kS(t,e){let r={};if(await SS(join(t,ts),r),await SS(join(t,ns),r),Object.keys(r).length===0)return;let n=join(t,Ku);await O(dirname(n)),await S(n,stringify(r)),e.push({fromTool:eo,fromPath:join(t,ns),toPath:Ku,feature:"hooks"});}var OS=d(()=>{A();Pe();s(Ld,"extractMeta");s(SS,"loadHooksFromDir");s(kS,"importClineHooks");});async function ql(t){let e=[],r=await z(eo,t),n=await pS(t,e,r),o=join(t,Qo),i=await y(o);if(i!==null&&i.trim()){let c=i.split(/\r?\n/),l=[];for(let m of c){let p=m.trim();p&&!p.startsWith("#")&&l.push(p);}if(l.length>0){await O(join(t,".agentsmesh"));let m=join(t,Wu);await S(m,l.join(`
71
+ `)),e.push({fromTool:"cline",fromPath:o,toPath:Wu,feature:"ignore"});}}await dS(t,e);let a=join(t,Al);return n||e.push(...await mt({srcDir:join(t,Pr),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:c,normalizeTo:l})=>mS(c,a,l),"mapEntry")})),await IS(t,e,r),await kS(t,e),e}var bd=d(()=>{It();A();tr();Od();uS();Pe();fS();CS();OS();s(ql,"importFromCline");});function wS(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:eo}))}var ES=d(()=>{$t();Pe();s(wS,"lintRules");});function LS(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>U(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function bS(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".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 AS=d(()=>{bt();s(LS,"lintCommands");s(bS,"lintHooks");});var NF,FF,vF,MF,xS,PS=d(()=>{aS();Vo();Pe();bd();ES();AS();xt();si();dt();NF={name:"cline",primaryRootInstructionPath:ro,generateRules:tS,generateCommands:eS,generateAgents:oS,generateSkills:iS,generateMcp:nS,generateHooks:sS,generateIgnore:rS,importFrom:ql},FF={rootInstructionPath:ro,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 `${Cn}/${t}.md`},commandPath(t,e){return `${Pr}/${t}.md`},agentPath(t,e){return ke(e,"cline")?`.cline/skills/${V(t)}/SKILL.md`:null}}},vF={skillDir:Gt,managedOutputs:{dirs:[es,rs,ns,Gt,".agents/skills"],files:[Sn,Qo]},rewriteGeneratedPath(t){return t===ro?null:t.startsWith(`${ts}/`)?`${ns}/${t.slice(ts.length+1)}`:t.startsWith(`${Pr}/`)?`${rs}/${t.slice(Pr.length+1)}`:t.startsWith(`${Cn}/`)?`${es}/${t.slice(Cn.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${Gt}/`)?`.agents/skills/${t.slice(Gt.length+1)}`:null},paths:{rulePath(t,e){return `${es}/${t}.md`},commandPath(t,e){return `${rs}/${t}.md`},agentPath(t,e){return ke(e,"cline")?`.cline/skills/${V(t)}/SKILL.md`:null}}},MF={rules:"native",additionalRules:"native",commands:Ze("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},xS={id:"cline",generators:NF,capabilities:{rules:"native",additionalRules:"native",commands:Ze("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:wS,lint:{commands:LS,hooks:bS},project:FF,globalSupport:{capabilities:MF,detectionPaths:[es,rs,ns,Gt,Sn,Qo],layout:vF},buildImportPaths:zu,detectionPaths:[".clinerules",".cline"]};});var jt,TS,vn,Es,DS,hr,NS,Ql,Ls,Yr,bs,Mn,Ad,$i,yc,xd,FS,Pd,vS,MS,Td,Dd,Nd,Vt=d(()=>{jt="codex-cli",TS="codex.md",vn="AGENTS.md",Es=".codex/AGENTS.md",DS=".codex/AGENTS.override.md",hr=".agents/skills",NS=".codex/skills",Ql=".codex/config.toml",Ls=".codex/instructions",Yr=".codex/rules",bs=".codex/agents",Mn=".agentsmesh/rules",Ad=".agentsmesh/commands",$i=".agentsmesh/agents",yc=".agentsmesh/skills",xd=".agentsmesh/mcp.json",FS="am-codex-rule:v1",Pd="# am-json: ",vS="# am-body-b64-begin",MS="# am-body-b64-end",Td="# am64:",Dd="<!-- agentsmesh:codex-rule-index:start -->",Nd="<!-- agentsmesh:codex-rule-index:end -->";});function Fd(t){return basename(t,".md")}function _c(t){return `${Ls}/${Fd(t.source)}.md`}function $S(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];}),F(e,t.body.trim()||"")}function GF(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 \`${Yr}/${Fd(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function GS(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||Fd(a.source)}](${_c(a)}): ${GF(a)}`),i=[Dd,"## Additional Rule Files",...o,Nd].join(`
72
72
  `);return r?`${r}
73
73
 
74
74
  ${i}`:i}function jS(t){let e=Dd.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=Nd.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
75
- `).trim()}var Ql=d(()=>{M();Vt();s(Fd,"ruleSlug");s(yc,"codexInstructionMirrorPath");s($S,"serializeCodexInstructionMirror");s(vF,"summarizeRule");s(GS,"appendCodexRuleIndex");s(jS,"stripCodexRuleIndex");});function $F(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function GF(t){return t.split(`
75
+ `).trim()}var tm=d(()=>{M();Vt();s(Fd,"ruleSlug");s(_c,"codexInstructionMirrorPath");s($S,"serializeCodexInstructionMirror");s(GF,"summarizeRule");s(GS,"appendCodexRuleIndex");s(jS,"stripCodexRuleIndex");});function UF(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function KF(t){return t.split(`
76
76
  `).map(e=>e.length>0?`# ${e}`:"#").join(`
77
- `)}function jF(t){let e=t.trim();return e?$F(e)?`${e}
78
- `:`${["# 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.","#",...GF(e).split(`
77
+ `)}function WF(t){let e=t.trim();return e?UF(e)?`${e}
78
+ `:`${["# 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.","#",...KF(e).split(`
79
79
  `),"#","# Example template:","# prefix_rule(",'# pattern = ["git", "status"],','# decision = "allow",','# justification = "Allow safe status checks",',"# )"].join(`
80
80
  `)}
81
- `:""}function vd(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:vn,content:GS(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:`${Yr}/${o}.rules`,content:jF(n.body)}),r.push({path:yc(n),content:$S(n)}));}return r}function Md(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 Et(e?.body.trim()??"",r)}var US=d(()=>{we();Vt();Ql();s($F,"looksLikeCodexRulesDsl");s(GF,"toCodexRulesComments");s(jF,"toSafeCodexRulesContent");s(vd,"generateRules");s(Md,"renderCodexGlobalInstructions");});function $d(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=F(n,r.body.trim()||"");e.push({path:`${hr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${hr}/${r.name}/${a}`,content:i.content});}}return e}function UF(t){return {path:`${hr}/${st(t.name)}/SKILL.md`,content:wr(t)}}function Gd(t){return t.commands.map(UF)}var KS=d(()=>{M();Vt();ne();s($d,"generateSkills");s(UF,"commandToSkillOutput");s(Gd,"generateCommands");});function jd(t){return t.agents.map(e=>({path:`${bs}/${e.name}.toml`,content:KF(e)}))}function KF(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 = """
81
+ `:""}function vd(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:vn,content:GS(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:`${Yr}/${o}.rules`,content:WF(n.body)}),r.push({path:_c(n),content:$S(n)}));}return r}function Md(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 Et(e?.body.trim()??"",r)}var US=d(()=>{we();Vt();tm();s(UF,"looksLikeCodexRulesDsl");s(KF,"toCodexRulesComments");s(WF,"toSafeCodexRulesContent");s(vd,"generateRules");s(Md,"renderCodexGlobalInstructions");});function $d(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=F(n,r.body.trim()||"");e.push({path:`${hr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${hr}/${r.name}/${a}`,content:i.content});}}return e}function BF(t){return {path:`${hr}/${st(t.name)}/SKILL.md`,content:wr(t)}}function Gd(t){return t.commands.map(BF)}var KS=d(()=>{M();Vt();ne();s($d,"generateSkills");s(BF,"commandToSkillOutput");s(Gd,"generateCommands");});function jd(t){return t.agents.map(e=>({path:`${bs}/${e.name}.toml`,content:HF(e)}))}function HF(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 = """
82
82
  ${n}
83
83
  """`);}else e.push(`developer_instructions = '''
84
84
  ${r}
85
85
  '''`);return e.join(`
86
86
  `)+`
87
- `}var WS=d(()=>{Vt();s(jd,"generateAgents");s(KF,"serializeAgentToCodexToml");});function tm(t){return "command"in t}function BS(t){return "url"in t}var em=d(()=>{s(tm,"isStdioMcpServer");s(BS,"isUrlMcpServer");});function Ud(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>tm(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=WF(e);return [{path:ql,content:r}]}function WF(t){let e=[];for(let[r,n]of Object.entries(t)){let o=HS(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${o}]`),i.push(`command = ${JSON.stringify(n.command)}`);let a="["+n.args.map(l=>JSON.stringify(l)).join(", ")+"]";i.push(`args = ${a}`);let c=Object.entries(n.env);if(c.length>0){let l=c.map(([m,p])=>`${HS(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${l} }`);}e.push(i.join(`
87
+ `}var WS=d(()=>{Vt();s(jd,"generateAgents");s(HF,"serializeAgentToCodexToml");});function em(t){return "command"in t}function BS(t){return "url"in t}var rm=d(()=>{s(em,"isStdioMcpServer");s(BS,"isUrlMcpServer");});function Ud(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>em(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=zF(e);return [{path:Ql,content:r}]}function zF(t){let e=[];for(let[r,n]of Object.entries(t)){let o=HS(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${o}]`),i.push(`command = ${JSON.stringify(n.command)}`);let a="["+n.args.map(l=>JSON.stringify(l)).join(", ")+"]";i.push(`args = ${a}`);let c=Object.entries(n.env);if(c.length>0){let l=c.map(([m,p])=>`${HS(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${l} }`);}e.push(i.join(`
88
88
  `));}return e.join(`
89
89
 
90
90
  `)+`
91
- `}function HS(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var zS=d(()=>{em();Vt();s(Ud,"generateMcp");s(WF,"serializeMcpToToml");s(HS,"needsTomlQuoting");});var VS=d(()=>{US();KS();WS();zS();});var JS=d(()=>{VS();});function zF(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 YS(t,e){let r=join(t,ql),n=await y(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[c,l]of Object.entries(i)){let m=zF(l);m&&(a[c]=m);}Object.keys(a).length!==0&&(await Ht(t,xd,a),e.push({fromTool:jt,fromPath:r,toPath:xd,feature:"mcp"}));}var XS=d(()=>{A();fn();Vt();s(zF,"mapTomlServerToCanonical");s(YS,"importMcp");});async function ZS(t,e,r){let n={projectRoot:t,sourceSkillsDir:hr,destCanonicalSkillsDir:hc,targetName:jt,normalize:r,results:e};for(let o of [hr,NS]){let i=join(t,o),a=await readdir(i,{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(a===null)continue;let c=false;for(let l of a){if(!l.isDirectory()&&!l.isSymbolicLink())continue;let m=join(i,l.name),p=join(m,"SKILL.md"),u=await y(p);if(!u)continue;c=true;let f=l.name,g=join(t,hc,f,"SKILL.md"),h=r(u,p,g),{frontmatter:R,body:C}=w(h),_=hl(R,l.name);if(_){await Ee(join(t,hc,f));let T=join(t,Ad);await O(T);let D=join(T,`${_.name}.md`);await S(D,yl(_,r(C,p,D))),e.push({fromTool:jt,fromPath:p,toPath:`${Ad}/${_.name}.md`,feature:"commands"});continue}let E=Er(R,l.name);if(E){await Ee(join(t,hc,f));let T=join(t,$i);await O(T);let D=join(T,`${E.name}.md`);await S(D,Oe(E,r(C,p,D))),e.push({fromTool:jt,fromPath:p,toPath:`${$i}/${E.name}.md`,feature:"agents"});continue}await Jr(f,m,n);}if(c)return}}var qS=d(()=>{A();M();ne();dt();mi();Mi();Vt();s(ZS,"importSkills");});async function QS(t,e,r){let n=join(t,bs),o=join(t,$i);try{let a=(await N(n)).filter(c=>c.endsWith(".toml"));for(let c of a){let l=await y(c);if(!l)continue;let m=parse$1(l);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(c,".toml"),u=typeof m.description=="string"?m.description:"",f=typeof m.developer_instructions=="string"?m.developer_instructions.trim():"",g=typeof m.model=="string"?m.model:"",h=typeof m.sandbox_mode=="string"?m.sandbox_mode:"",R=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",C=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(x=>typeof x=="string"):[];await O(o);let _=join(o,`${p}.md`),E=r(f,c,_),D=Oe({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:R,maxTurns:0,mcpServers:C,hooks:{},skills:[],memory:""},E);await S(_,D),e.push({fromTool:jt,fromPath:c,toPath:`${$i}/${p}.md`,feature:"agents"});}}catch{}}var tR=d(()=>{A();dt();Vt();s(QS,"importCodexAgentsFromToml");});function eR(t){if(!t.includes(FS))return null;let e=t.split(`
91
+ `}function HS(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var zS=d(()=>{rm();Vt();s(Ud,"generateMcp");s(zF,"serializeMcpToToml");s(HS,"needsTomlQuoting");});var VS=d(()=>{US();KS();WS();zS();});var JS=d(()=>{VS();});function YF(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 YS(t,e){let r=join(t,Ql),n=await y(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[c,l]of Object.entries(i)){let m=YF(l);m&&(a[c]=m);}Object.keys(a).length!==0&&(await Ht(t,xd,a),e.push({fromTool:jt,fromPath:r,toPath:xd,feature:"mcp"}));}var XS=d(()=>{A();fn();Vt();s(YF,"mapTomlServerToCanonical");s(YS,"importMcp");});async function ZS(t,e,r){let n={projectRoot:t,sourceSkillsDir:hr,destCanonicalSkillsDir:yc,targetName:jt,normalize:r,results:e};for(let o of [hr,NS]){let i=join(t,o),a=await readdir(i,{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(a===null)continue;let c=false;for(let l of a){if(!l.isDirectory()&&!l.isSymbolicLink())continue;let m=join(i,l.name),p=join(m,"SKILL.md"),u=await y(p);if(!u)continue;c=true;let f=l.name,g=join(t,yc,f,"SKILL.md"),h=r(u,p,g),{frontmatter:R,body:C}=w(h),_=yl(R,l.name);if(_){await Ee(join(t,yc,f));let T=join(t,Ad);await O(T);let D=join(T,`${_.name}.md`);await S(D,_l(_,r(C,p,D))),e.push({fromTool:jt,fromPath:p,toPath:`${Ad}/${_.name}.md`,feature:"commands"});continue}let E=Er(R,l.name);if(E){await Ee(join(t,yc,f));let T=join(t,$i);await O(T);let D=join(T,`${E.name}.md`);await S(D,Oe(E,r(C,p,D))),e.push({fromTool:jt,fromPath:p,toPath:`${$i}/${E.name}.md`,feature:"agents"});continue}await Jr(f,m,n);}if(c)return}}var qS=d(()=>{A();M();ne();dt();mi();Mi();Vt();s(ZS,"importSkills");});async function QS(t,e,r){let n=join(t,bs),o=join(t,$i);try{let a=(await N(n)).filter(c=>c.endsWith(".toml"));for(let c of a){let l=await y(c);if(!l)continue;let m=parse$1(l);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(c,".toml"),u=typeof m.description=="string"?m.description:"",f=typeof m.developer_instructions=="string"?m.developer_instructions.trim():"",g=typeof m.model=="string"?m.model:"",h=typeof m.sandbox_mode=="string"?m.sandbox_mode:"",R=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",C=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(x=>typeof x=="string"):[];await O(o);let _=join(o,`${p}.md`),E=r(f,c,_),D=Oe({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:R,maxTurns:0,mcpServers:C,hooks:{},skills:[],memory:""},E);await S(_,D),e.push({fromTool:jt,fromPath:c,toPath:`${$i}/${p}.md`,feature:"agents"});}}catch{}}var tR=d(()=>{A();dt();Vt();s(QS,"importCodexAgentsFromToml");});function eR(t){if(!t.includes(FS))return null;let e=t.split(`
92
92
  `).find(l=>l.startsWith(Pd));if(!e)return null;let r;try{r=JSON.parse(e.slice(Pd.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(l=>typeof l=="string"):[],a=[],c=false;for(let l of t.split(`
93
- `)){let m=l.trimEnd();if(m===vS){c=true;continue}if(m===MS){c=false;continue}c&&m.startsWith(Td)&&a.push(m.slice(Td.length));}if(a.length===0)return null;try{let l=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:i},body:l}}catch{return null}}var rR=d(()=>{Vt();s(eR,"tryParseEmbeddedCanonicalFromCodexRules");});async function oR(t,e,r){let n=[],o=join(t,Yr);try{let i=await N(o),a=i.filter(l=>l.endsWith(".md"));for(let l of a){let m=await y(l);if(!m)continue;let p=relative(o,l).replace(/\\/g,"/"),u=join(e,p),{frontmatter:f,body:g}=w(r(m,l,u));await O(e);let h=f.root===!0?f:{...f,root:!1},R=await j(u,h,g);await S(u,R),n.push({fromTool:jt,fromPath:l,toPath:`${Mn}/${p}`,feature:"rules"});}let c=i.filter(l=>l.endsWith(".rules"));for(let l of c){let m=await y(l);if(!m)continue;let p=relative(o,l).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await O(e);let f=eR(m);if(f){let g=await j(u,{description:f.meta.description,globs:f.meta.globs,root:!1},r(f.body,l,u));await S(u,g);}else {let g=await j(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),l,u));await S(u,g);}n.push({fromTool:jt,fromPath:l,toPath:`${Mn}/${p}`,feature:"rules"});}}catch{}return n}var sR=d(()=>{A();M();et();Vt();rR();s(oR,"importCodexNonRootRuleFiles");});async function aR(t,e,r,n,o){let i=join(t,TS),a=join(t,vn),c=join(t,DS),l=join(t,Es),m=o==="global"?await y(c):null,p=o==="global"?await y(l):null,u=o==="project"?await y(a):null,f=o==="project"?await y(i):null,g=m!==null?c:p!==null?l:u!==null?a:i,h=join(t,Mn),R=m??p??u??f;if(R!==null){await O(h);let C=join(h,"_root.md"),_=g===a||g===l||g===c?jS(R):R,E=await Vr({content:_,projectRoot:t,rulesDir:Mn,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...E.results);let T=r(g===a||g===l||g===c?n(E.rootContent,g,C):E.rootContent,g,C),{frontmatter:D,body:x}=w(T),Z=D.root===true?D:{...D,root:true},B=await j(C,Z,x);await S(C,B),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${Mn}/_root.md`,feature:"rules"});}await QF(t,h,e,r),e.push(...await oR(t,h,r)),o!=="global"&&e.push(...await mt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:C,normalizeTo:_})=>{let E=relative(t,dirname(C)).replace(/\\/g,"/"),T=basename(C),D=T==="AGENTS.override.md";if(!E||E==="."||!D&&T!=="AGENTS.md")return null;let x=E.replace(/\//g,"-");if(!Sl(E))return await Ee(join(h,`${x}.md`)),null;let Z=join(h,`${x}.md`),{frontmatter:B,body:J}=w(_(Z));return {destPath:Z,toPath:`${Mn}/${x}.md`,feature:"rules",content:await j(Z,{...B,root:false,globs:[`${E}/**`],...D?{codex_instruction:"override"}:{}},J)}},"mapEntry")}));}async function QF(t,e,r,n){try{let i=(await N(join(t,Ls))).filter(c=>c.endsWith(".md")),a=join(t,Ls);for(let c of i){let l=relative(a,c).replace(/\\/g,"/");if(l==="_root.md")continue;let m=await y(c);if(!m)continue;let p=join(e,l),{frontmatter:u,body:f}=w(n(m,c,p));await O(e);let g=u.root===!0?u:{...u,root:!1},h=await j(p,g,f);await S(p,h),r.push({fromTool:jt,fromPath:c,toPath:`${Mn}/${l}`,feature:"rules"});}}catch{}}var cR=d(()=>{A();M();et();vi();tr();mi();Vt();sR();Ql();s(aR,"importCodexRules");s(QF,"importInstructionMirrors");});async function rm(t,e){let r=e?.scope??"project",n=[],o=await z(jt,t,r),i=await z("windsurf",t,r);return await aR(t,n,o,i,r),await ZS(t,n,o),await QS(t,n,o),await YS(t,n),n}var Bd=d(()=>{It();Vt();XS();qS();tR();cR();s(rm,"importFromCodex");});function lR(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:jt,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var mR=d(()=>{Vt();s(lR,"lintRules");});function pR(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(U(".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(U(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var uR=d(()=>{bt();s(pR,"lintMcp");});function dR(t){return yc(t)}var fR=d(()=>{Ql();s(dR,"codexAdvisoryInstructionPath");});var ev,rv,nv,ov,hR,yR=d(()=>{JS();Vt();Bd();mR();uR();xt();si();fR();ne();ev={name:"codex-cli",primaryRootInstructionPath:vn,generateRules:vd,generateCommands:Gd,generateAgents:jd,generateSkills:$d,generateMcp:Ud,importFrom:rm},rv={rootInstructionPath:vn,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Yr}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return dR(e)},commandPath(t,e){return oi(e,"codex-cli")?`${hr}/${st(t)}/SKILL.md`:null},agentPath(t,e){return `${bs}/${t}.toml`}}},nv={rootInstructionPath:Es,renderPrimaryRootInstruction:Md,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Yr}/${e}.rules`]},skillDir:hr,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Es,".codex/config.toml"]},rewriteGeneratedPath(t){return t===vn?Es:t.startsWith(`${Ls}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${Yr}/${t}.rules`:Es},commandPath(t,e){return oi(e,"codex-cli")?`${hr}/${st(t)}/SKILL.md`:null},agentPath(t,e){return `${bs}/${t}.toml`}}},ov={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},hR={id:"codex-cli",generators:ev,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:lR,lint:{mcp:pR},project:rv,globalSupport:{capabilities:ov,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:nv},buildImportPaths:Vu,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function iv(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 _R(t){return `${Tr}/${t}.md`}function IR(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"],F(e,t.body.trim()||"")}function CR(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:iv(t["x-agentsmesh-allowed-tools"])}}function SR(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"],F(r,e.trim()||"")}var nm=d(()=>{M();Dr();s(iv,"toStringArray");s(_R,"continueCommandRulePath");s(IR,"serializeCommandRule");s(CR,"parseCommandRuleFrontmatter");s(SR,"serializeImportedCommand");});function RR(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:Rn,content:F(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:`${nr}/${o}.md`,content:F(i,n.body.trim()||"")});}return e}function kR(t){return t.commands.map(e=>({path:`${Tr}/${e.name}.md`,content:IR(e)}))}function OR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Al,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function wR(t){return t.agents.map(e=>({path:`${de}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function ER(t){return St(t,de)}var LR=d(()=>{_t();dt();M();nm();Dr();s(RR,"generateRules");s(kR,"generateCommands");s(OR,"generateMcp");s(wR,"generateAgents");s(ER,"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 c=a;typeof c.command=="string"&&(o[i]={type:typeof c.type=="string"?c.type:"stdio",command:c.command,args:pi(c.args),env:ui(c.env),description:typeof c.description=="string"?c.description:void 0});}return o}async function pv(t,e){let r=(await N(join(t,Ju))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await y(i);a&&(Object.assign(n,mv(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Ht(t,Xu,n);for(let i of o)e.push({fromTool:hi,fromPath:i,toPath:Xu,feature:"mcp"});}}async function om(t){let e=[],r=await z(hi,t);return e.push(...await Q(sm,t,"project",{normalize:r})),await yt(t,de,hi,e,r),await pv(t,e),e}var Hd=d(()=>{It();A();_t();Mt();fn();Qe();Dr();zd();s(mv,"readMcpServers");s(pv,"importMcp");s(om,"importFromContinue");});function uv(t){return t==="general.md"||t==="_root.md"}var AR,xR,PR=d(()=>{M();et();nm();Dr();s(uv,"isContinueRootRulePath");AR=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=uv(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:c}=w(e(i)),l={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return l.description===void 0&&delete l.description,l.globs===void 0&&delete l.globs,{destPath:i,toPath:`${xl}/${o}`,content:await j(i,l,c)}},"continueRuleMapper"),xR=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=w(r(o)),c=CR(i,t),l=c.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${l}.md`:`${l}.md`,u=join(n,p),f=await ot(u,{description:c.description,hasDescription:!!c.description,allowedTools:c.allowedTools,hasAllowedTools:c.allowedTools.length>0},w(SR(c,a)).body);return {destPath:u,toPath:`${Pl}/${p}`,content:f}},"continueCommandMapper");});function TR(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:hi}))}var DR=d(()=>{$t();Dr();s(TR,"lintRules");});function NR(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>U(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var FR=d(()=>{bt();s(NR,"lintCommands");});function hv(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var vR,MR=d(()=>{A();Dr();s(hv,"computeStatus");vR=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 l={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(l.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(l.prompts=t.commands.map(u=>{let 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&&(l.mcpServers=u.map(([f,g])=>({name:f,...g})));}let m=stringify(l),p=await y(join(e,Ja));return [{target:"continue",path:Ja,content:m,currentContent:p??void 0,status:hv(p,m)}]},"generateContinueGlobalConfig");});function _v(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var $R,GR=d(()=>{A();Dr();MR();s(_v,"computeStatus");$R=s(async(t,e,r,n)=>{let o=await vR(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let i=t.rules.find(l=>l.root);if(!i)return o;let a=i.body.trim(),c=await y(join(e,yi));return [...o,{target:"continue",path:yi,content:a,currentContent:c??void 0,status:_v(c,a)}]},"generateContinueScopeExtras");});var Iv,Cv,Sv,Rv,sm,zd=d(()=>{dt();LR();Dr();Hd();PR();DR();FR();nm();xt();GR();Iv={name:"continue",primaryRootInstructionPath:Rn,generateRules:RR,generateCommands:kR,generateAgents:wR,generateSkills:ER,generateMcp:OR,importFrom:om},Cv={rootInstructionPath:Rn,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${nr}/${t}.md`},commandPath(t,e){return _R(t)},agentPath(t){return `${de}/${V(t)}/SKILL.md`}}},Sv={rootInstructionPath:Rn,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[yi]}],skillDir:de,managedOutputs:{dirs:[nr,Tr,de,".agents/skills"],files:[Al,yi,Ja]},mirrorGlobalPath(t,e){return t.startsWith(`${de}/`)?`.agents/skills/${t.slice(de.length+1)}`:null},paths:{rulePath(t,e){return `${nr}/${t}.md`},commandPath(t,e){return `${Tr}/${t}.md`},agentPath(t){return `${de}/${V(t)}/SKILL.md`}}},Rv={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},sm={id:"continue",generators:Iv,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:TR,lint:{commands:NR},project:Cv,globalSupport:{capabilities:Rv,detectionPaths:[nr,Tr,".continue/mcpServers",de],layout:Sv,scopeExtras:$R},importer:{rules:{feature:"rules",mode:"directory",source:{project:[nr],global:[nr]},canonicalDir:xl,extensions:[".md"],map:AR},commands:{feature:"commands",mode:"directory",source:{project:[Tr],global:[Tr]},canonicalDir:Pl,extensions:[".md"],map:xR}},buildImportPaths:Zu,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var $n,As,jR,xs,Eo,Zr,qr,Ps,Ts,im,am,UR,Jd,KR,Lo,Gi,Gn,ji,Ds,Yd,Xd,ve=d(()=>{$n="copilot",As=".github/copilot-instructions.md",jR=".github/copilot",xs=".github/instructions",Eo=".github/prompts",Zr=".github/hooks",qr=".github/skills",Ps=".github/agents",Ts=".agentsmesh/rules",im=".agentsmesh/commands",am=".agentsmesh/agents",UR=".agentsmesh/skills",Jd=".agentsmesh/hooks.yaml",KR=".github/copilot-hooks",Lo=".copilot/copilot-instructions.md",Gi=".copilot/agents",Gn=".copilot/skills",ji=".copilot/prompts",Ds=".copilot/AGENTS.md",Yd=".claude/skills",Xd=".agents/skills";});function WR(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 cm(t){return `${Eo}/${t}.prompt.md`}function BR(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"],F(e,t.body.trim()||"")}function HR(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=WR(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:WR(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var lm=d(()=>{M();ve();s(WR,"toStringArray");s(cm,"commandPromptPath");s(BR,"serializeCommandPrompt");s(HR,"parseCommandPromptFrontmatter");});function mm(t){return mn(t)}var Zd=d(()=>{Je();s(mm,"hasHookCommand");});function wv(t){let e=basename(t,".md");return e==="_root"?"root":e}function Ev(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function zR(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}
93
+ `)){let m=l.trimEnd();if(m===vS){c=true;continue}if(m===MS){c=false;continue}c&&m.startsWith(Td)&&a.push(m.slice(Td.length));}if(a.length===0)return null;try{let l=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:i},body:l}}catch{return null}}var rR=d(()=>{Vt();s(eR,"tryParseEmbeddedCanonicalFromCodexRules");});async function oR(t,e,r){let n=[],o=join(t,Yr);try{let i=await N(o),a=i.filter(l=>l.endsWith(".md"));for(let l of a){let m=await y(l);if(!m)continue;let p=relative(o,l).replace(/\\/g,"/"),u=join(e,p),{frontmatter:f,body:g}=w(r(m,l,u));await O(e);let h=f.root===!0?f:{...f,root:!1},R=await j(u,h,g);await S(u,R),n.push({fromTool:jt,fromPath:l,toPath:`${Mn}/${p}`,feature:"rules"});}let c=i.filter(l=>l.endsWith(".rules"));for(let l of c){let m=await y(l);if(!m)continue;let p=relative(o,l).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await O(e);let f=eR(m);if(f){let g=await j(u,{description:f.meta.description,globs:f.meta.globs,root:!1},r(f.body,l,u));await S(u,g);}else {let g=await j(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),l,u));await S(u,g);}n.push({fromTool:jt,fromPath:l,toPath:`${Mn}/${p}`,feature:"rules"});}}catch{}return n}var sR=d(()=>{A();M();et();Vt();rR();s(oR,"importCodexNonRootRuleFiles");});async function aR(t,e,r,n,o){let i=join(t,TS),a=join(t,vn),c=join(t,DS),l=join(t,Es),m=o==="global"?await y(c):null,p=o==="global"?await y(l):null,u=o==="project"?await y(a):null,f=o==="project"?await y(i):null,g=m!==null?c:p!==null?l:u!==null?a:i,h=join(t,Mn),R=m??p??u??f;if(R!==null){await O(h);let C=join(h,"_root.md"),_=g===a||g===l||g===c?jS(R):R,E=await Vr({content:_,projectRoot:t,rulesDir:Mn,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...E.results);let T=r(g===a||g===l||g===c?n(E.rootContent,g,C):E.rootContent,g,C),{frontmatter:D,body:x}=w(T),Z=D.root===true?D:{...D,root:true},B=await j(C,Z,x);await S(C,B),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${Mn}/_root.md`,feature:"rules"});}await rv(t,h,e,r),e.push(...await oR(t,h,r)),o!=="global"&&e.push(...await mt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:C,normalizeTo:_})=>{let E=relative(t,dirname(C)).replace(/\\/g,"/"),T=basename(C),D=T==="AGENTS.override.md";if(!E||E==="."||!D&&T!=="AGENTS.md")return null;let x=E.replace(/\//g,"-");if(!Rl(E))return await Ee(join(h,`${x}.md`)),null;let Z=join(h,`${x}.md`),{frontmatter:B,body:J}=w(_(Z));return {destPath:Z,toPath:`${Mn}/${x}.md`,feature:"rules",content:await j(Z,{...B,root:false,globs:[`${E}/**`],...D?{codex_instruction:"override"}:{}},J)}},"mapEntry")}));}async function rv(t,e,r,n){try{let i=(await N(join(t,Ls))).filter(c=>c.endsWith(".md")),a=join(t,Ls);for(let c of i){let l=relative(a,c).replace(/\\/g,"/");if(l==="_root.md")continue;let m=await y(c);if(!m)continue;let p=join(e,l),{frontmatter:u,body:f}=w(n(m,c,p));await O(e);let g=u.root===!0?u:{...u,root:!1},h=await j(p,g,f);await S(p,h),r.push({fromTool:jt,fromPath:c,toPath:`${Mn}/${l}`,feature:"rules"});}}catch{}}var cR=d(()=>{A();M();et();vi();tr();mi();Vt();sR();tm();s(aR,"importCodexRules");s(rv,"importInstructionMirrors");});async function nm(t,e){let r=e?.scope??"project",n=[],o=await z(jt,t,r),i=await z("windsurf",t,r);return await aR(t,n,o,i,r),await ZS(t,n,o),await QS(t,n,o),await YS(t,n),n}var Bd=d(()=>{It();Vt();XS();qS();tR();cR();s(nm,"importFromCodex");});function lR(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:jt,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var mR=d(()=>{Vt();s(lR,"lintRules");});function pR(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(U(".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(U(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var uR=d(()=>{bt();s(pR,"lintMcp");});function dR(t){return _c(t)}var fR=d(()=>{tm();s(dR,"codexAdvisoryInstructionPath");});var ov,sv,iv,av,hR,yR=d(()=>{JS();Vt();Bd();mR();uR();xt();si();fR();ne();ov={name:"codex-cli",primaryRootInstructionPath:vn,generateRules:vd,generateCommands:Gd,generateAgents:jd,generateSkills:$d,generateMcp:Ud,importFrom:nm},sv={rootInstructionPath:vn,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Yr}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return dR(e)},commandPath(t,e){return oi(e,"codex-cli")?`${hr}/${st(t)}/SKILL.md`:null},agentPath(t,e){return `${bs}/${t}.toml`}}},iv={rootInstructionPath:Es,renderPrimaryRootInstruction:Md,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Yr}/${e}.rules`]},skillDir:hr,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Es,".codex/config.toml"]},rewriteGeneratedPath(t){return t===vn?Es:t.startsWith(`${Ls}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${Yr}/${t}.rules`:Es},commandPath(t,e){return oi(e,"codex-cli")?`${hr}/${st(t)}/SKILL.md`:null},agentPath(t,e){return `${bs}/${t}.toml`}}},av={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},hR={id:"codex-cli",generators:ov,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:lR,lint:{mcp:pR},project:sv,globalSupport:{capabilities:av,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:iv},buildImportPaths:Vu,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function lv(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 _R(t){return `${Tr}/${t}.md`}function IR(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"],F(e,t.body.trim()||"")}function CR(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:lv(t["x-agentsmesh-allowed-tools"])}}function SR(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"],F(r,e.trim()||"")}var om=d(()=>{M();Dr();s(lv,"toStringArray");s(_R,"continueCommandRulePath");s(IR,"serializeCommandRule");s(CR,"parseCommandRuleFrontmatter");s(SR,"serializeImportedCommand");});function RR(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:Rn,content:F(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:`${nr}/${o}.md`,content:F(i,n.body.trim()||"")});}return e}function kR(t){return t.commands.map(e=>({path:`${Tr}/${e.name}.md`,content:IR(e)}))}function OR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:xl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function wR(t){return t.agents.map(e=>({path:`${de}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function ER(t){return St(t,de)}var LR=d(()=>{_t();dt();M();om();Dr();s(RR,"generateRules");s(kR,"generateCommands");s(OR,"generateMcp");s(wR,"generateAgents");s(ER,"generateSkills");});function dv(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 c=a;typeof c.command=="string"&&(o[i]={type:typeof c.type=="string"?c.type:"stdio",command:c.command,args:pi(c.args),env:ui(c.env),description:typeof c.description=="string"?c.description:void 0});}return o}async function fv(t,e){let r=(await N(join(t,Ju))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await y(i);a&&(Object.assign(n,dv(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Ht(t,Xu,n);for(let i of o)e.push({fromTool:hi,fromPath:i,toPath:Xu,feature:"mcp"});}}async function sm(t){let e=[],r=await z(hi,t);return e.push(...await Q(im,t,"project",{normalize:r})),await yt(t,de,hi,e,r),await fv(t,e),e}var Hd=d(()=>{It();A();_t();Mt();fn();Qe();Dr();zd();s(dv,"readMcpServers");s(fv,"importMcp");s(sm,"importFromContinue");});function gv(t){return t==="general.md"||t==="_root.md"}var AR,xR,PR=d(()=>{M();et();om();Dr();s(gv,"isContinueRootRulePath");AR=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=gv(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:c}=w(e(i)),l={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return l.description===void 0&&delete l.description,l.globs===void 0&&delete l.globs,{destPath:i,toPath:`${Pl}/${o}`,content:await j(i,l,c)}},"continueRuleMapper"),xR=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=w(r(o)),c=CR(i,t),l=c.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${l}.md`:`${l}.md`,u=join(n,p),f=await ot(u,{description:c.description,hasDescription:!!c.description,allowedTools:c.allowedTools,hasAllowedTools:c.allowedTools.length>0},w(SR(c,a)).body);return {destPath:u,toPath:`${Tl}/${p}`,content:f}},"continueCommandMapper");});function TR(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:hi}))}var DR=d(()=>{$t();Dr();s(TR,"lintRules");});function NR(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>U(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var FR=d(()=>{bt();s(NR,"lintCommands");});function Iv(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var vR,MR=d(()=>{A();Dr();s(Iv,"computeStatus");vR=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 l={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(l.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(l.prompts=t.commands.map(u=>{let 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&&(l.mcpServers=u.map(([f,g])=>({name:f,...g})));}let m=stringify(l),p=await y(join(e,Ya));return [{target:"continue",path:Ya,content:m,currentContent:p??void 0,status:Iv(p,m)}]},"generateContinueGlobalConfig");});function Sv(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var $R,GR=d(()=>{A();Dr();MR();s(Sv,"computeStatus");$R=s(async(t,e,r,n)=>{let o=await vR(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let i=t.rules.find(l=>l.root);if(!i)return o;let a=i.body.trim(),c=await y(join(e,yi));return [...o,{target:"continue",path:yi,content:a,currentContent:c??void 0,status:Sv(c,a)}]},"generateContinueScopeExtras");});var Rv,kv,Ov,wv,im,zd=d(()=>{dt();LR();Dr();Hd();PR();DR();FR();om();xt();GR();Rv={name:"continue",primaryRootInstructionPath:Rn,generateRules:RR,generateCommands:kR,generateAgents:wR,generateSkills:ER,generateMcp:OR,importFrom:sm},kv={rootInstructionPath:Rn,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${nr}/${t}.md`},commandPath(t,e){return _R(t)},agentPath(t){return `${de}/${V(t)}/SKILL.md`}}},Ov={rootInstructionPath:Rn,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[yi]}],skillDir:de,managedOutputs:{dirs:[nr,Tr,de,".agents/skills"],files:[xl,yi,Ya]},mirrorGlobalPath(t,e){return t.startsWith(`${de}/`)?`.agents/skills/${t.slice(de.length+1)}`:null},paths:{rulePath(t,e){return `${nr}/${t}.md`},commandPath(t,e){return `${Tr}/${t}.md`},agentPath(t){return `${de}/${V(t)}/SKILL.md`}}},wv={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},im={id:"continue",generators:Rv,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:TR,lint:{commands:NR},project:kv,globalSupport:{capabilities:wv,detectionPaths:[nr,Tr,".continue/mcpServers",de],layout:Ov,scopeExtras:$R},importer:{rules:{feature:"rules",mode:"directory",source:{project:[nr],global:[nr]},canonicalDir:Pl,extensions:[".md"],map:AR},commands:{feature:"commands",mode:"directory",source:{project:[Tr],global:[Tr]},canonicalDir:Tl,extensions:[".md"],map:xR}},buildImportPaths:Zu,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var $n,As,jR,xs,Eo,Zr,qr,Ps,Ts,am,cm,UR,Jd,KR,Lo,Gi,Gn,ji,Ds,Yd,Xd,ve=d(()=>{$n="copilot",As=".github/copilot-instructions.md",jR=".github/copilot",xs=".github/instructions",Eo=".github/prompts",Zr=".github/hooks",qr=".github/skills",Ps=".github/agents",Ts=".agentsmesh/rules",am=".agentsmesh/commands",cm=".agentsmesh/agents",UR=".agentsmesh/skills",Jd=".agentsmesh/hooks.yaml",KR=".github/copilot-hooks",Lo=".copilot/copilot-instructions.md",Gi=".copilot/agents",Gn=".copilot/skills",ji=".copilot/prompts",Ds=".copilot/AGENTS.md",Yd=".claude/skills",Xd=".agents/skills";});function WR(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 lm(t){return `${Eo}/${t}.prompt.md`}function BR(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"],F(e,t.body.trim()||"")}function HR(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=WR(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:WR(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var mm=d(()=>{M();ve();s(WR,"toStringArray");s(lm,"commandPromptPath");s(BR,"serializeCommandPrompt");s(HR,"parseCommandPromptFrontmatter");});function pm(t){return mn(t)}var Zd=d(()=>{Je();s(pm,"hasHookCommand");});function bv(t){let e=basename(t,".md");return e==="_root"?"root":e}function Av(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function zR(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}
94
94
 
95
95
  ${o}`):e.push(o);}return e.join(`
96
96
 
97
- `)}function VR(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:As,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=wv(n.source),i={description:n.description||void 0,applyTo:n.globs.length===1?n.globs[0]:n.globs};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=F(i,n.body.trim()||"");r.push({path:`${xs}/${o}.instructions.md`,content:a});}return r}function JR(t){return t.commands.map(e=>({path:cm(e.name),content:BR(e)}))}function YR(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=F(n,r.body.trim()||"");e.push({path:`${qr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${qr}/${r.name}/${a}`,content:i.content});}}return e}function XR(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=F(r,e.body.trim()||"");return {path:`${Ps}/${e.name}.agent.md`,content:n}})}function ZR(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=Ev(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&mm(a)).map((a,c)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${c}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[o,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${Zr}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var qR=d(()=>{M();ve();lm();Zd();s(wv,"ruleSlug");s(Ev,"mapHookEvent");s(zR,"renderCopilotGlobalInstructions");s(VR,"generateRules");s(JR,"generateCommands");s(YR,"generateSkills");s(XR,"generateAgents");s(ZR,"generateHooks");});function bv(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function Av(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function ek(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\n?/m,"").trim()}async function rk(t,e){let r=join(t,Zr),o=(await N(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of o){let u=await y(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=bv(g);if(!(!R||!Array.isArray(h)))for(let C of h){if(!C||typeof C!="object")continue;let _=C,E=typeof _.bash=="string"?_.bash:"";if(!E)continue;let T=join(r,E.replace(/^\.\//,"")),D=await y(T);if(!D)continue;let x=ek(D);x&&(i[R]||(i[R]=[]),i[R].push({matcher:Av(_.comment),command:x,type:"command"}));}}}let a=join(t,KR),l=(await N(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of l){let u=await y(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:ek(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Jd);await O(dirname(m)),await S(m,stringify(i)),e.push({fromTool:$n,fromPath:join(t,Zr),toPath:Jd,feature:"hooks"});}var nk=d(()=>{A();ve();s(bv,"mapCopilotHookEvent");s(Av,"extractMatcher");s(ek,"extractWrapperCommand");s(rk,"importHooks");});async function ok(t,e,r,n=qr){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:UR,targetName:$n,normalize:r,results:e};for(let[c,l]of i)await Jr(c,l,a);}var sk=d(()=>{Mi();ve();s(ok,"importSkills");});async function pm(t,e={}){let r=e.scope??"project",n=[],o=await z($n,t,r);return n.push(...await Q(um,t,r,{normalize:o})),await ok(t,n,o,r==="global"?Gn:qr),r==="project"&&await rk(t,n),n}var qd=d(()=>{It();Mt();ve();nk();sk();Qd();s(pm,"importFromCopilot");});function ik(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var ak,ck,lk,mk,pk=d(()=>{M();et();Qe();lm();ve();s(ik,"pruneUndefined");ak=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=w(e(o)),c=gn(i.globs),l=ik({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:o,toPath:`${Ts}/${n}`,content:await j(o,l,a)}},"copilotLegacyRuleMapper"),ck=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}=w(e(o)),c=gn(i.applyTo!==void 0?i.applyTo:i.globs),l=ik({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:o,toPath:`${Ts}/${n}`,content:await j(o,l,a)}},"copilotNewRuleMapper"),lk=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:c}=w(r(i)),l=HR(a,t),m=o.includes("/")?o.slice(0,o.lastIndexOf("/")):"",p=`${l.name}.md`,u=m?`${m}/${p}`:p,f=join(n,u);return {destPath:f,toPath:`${im}/${u}`,content:await ot(f,{description:l.description,hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:l.allowedTools,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"tools")||Object.prototype.hasOwnProperty.call(a,"x-agentsmesh-allowed-tools")},c)}},"copilotCommandMapper"),mk=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:c}=w(e(i));return {destPath:i,toPath:`${am}/${n}`,content:await Lt(i,{...a,name:typeof a.name=="string"?a.name:o},c)}},"copilotAgentMapper");});function uk(t,e,r,n){let i=q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(c=>({...c,target:$n})),a=t.rules.filter(c=>!c.root&&c.globs.length===0);return [...i,...a.map(c=>({level:"warning",file:c.source,target:$n,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var dk=d(()=>{$t();ve();s(uk,"lintRules");});function fk(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>U(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function gk(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=>di(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(U(".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 hk=d(()=>{bt();s(fk,"lintCommands");s(gk,"lintHooks");});function Nv(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function Fv(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function vv(t,e){let r=t.match(yk);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function Mv(t,e){let n=e.match(yk)?.groups?.path;if(!n)return null;let o=join(t,n),i=await y(o);if(i===null)return null;let a=Fv(t,o);return a?{assetPath:`${Zr}/scripts/${a}`,content:i,rewrittenCommand:vv(e,a)}:null}function $v(t,e){return `${Zr}/scripts/${Nv(t)}-${e}.sh`}function Gv(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${e}`,`# agentsmesh-command: ${t}`,"set -e",t,""].join(`
98
- `)}async function _k(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 c=0;for(let l of a){if(!mm(l))continue;let m=$v(i,c),p=l.command,u=await Mv(t,l.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=Gv(p,l.matcher).replace(`set -e
97
+ `)}function VR(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:As,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=bv(n.source),i={description:n.description||void 0,applyTo:n.globs.length===1?n.globs[0]:n.globs};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=F(i,n.body.trim()||"");r.push({path:`${xs}/${o}.instructions.md`,content:a});}return r}function JR(t){return t.commands.map(e=>({path:lm(e.name),content:BR(e)}))}function YR(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=F(n,r.body.trim()||"");e.push({path:`${qr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${qr}/${r.name}/${a}`,content:i.content});}}return e}function XR(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=F(r,e.body.trim()||"");return {path:`${Ps}/${e.name}.agent.md`,content:n}})}function ZR(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=Av(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&pm(a)).map((a,c)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${c}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[o,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${Zr}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var qR=d(()=>{M();ve();mm();Zd();s(bv,"ruleSlug");s(Av,"mapHookEvent");s(zR,"renderCopilotGlobalInstructions");s(VR,"generateRules");s(JR,"generateCommands");s(YR,"generateSkills");s(XR,"generateAgents");s(ZR,"generateHooks");});function Pv(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function Tv(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function ek(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\n?/m,"").trim()}async function rk(t,e){let r=join(t,Zr),o=(await N(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of o){let u=await y(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=Pv(g);if(!(!R||!Array.isArray(h)))for(let C of h){if(!C||typeof C!="object")continue;let _=C,E=typeof _.bash=="string"?_.bash:"";if(!E)continue;let T=join(r,E.replace(/^\.\//,"")),D=await y(T);if(!D)continue;let x=ek(D);x&&(i[R]||(i[R]=[]),i[R].push({matcher:Tv(_.comment),command:x,type:"command"}));}}}let a=join(t,KR),l=(await N(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of l){let u=await y(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:ek(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Jd);await O(dirname(m)),await S(m,stringify(i)),e.push({fromTool:$n,fromPath:join(t,Zr),toPath:Jd,feature:"hooks"});}var nk=d(()=>{A();ve();s(Pv,"mapCopilotHookEvent");s(Tv,"extractMatcher");s(ek,"extractWrapperCommand");s(rk,"importHooks");});async function ok(t,e,r,n=qr){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:UR,targetName:$n,normalize:r,results:e};for(let[c,l]of i)await Jr(c,l,a);}var sk=d(()=>{Mi();ve();s(ok,"importSkills");});async function um(t,e={}){let r=e.scope??"project",n=[],o=await z($n,t,r);return n.push(...await Q(dm,t,r,{normalize:o})),await ok(t,n,o,r==="global"?Gn:qr),r==="project"&&await rk(t,n),n}var qd=d(()=>{It();Mt();ve();nk();sk();Qd();s(um,"importFromCopilot");});function ik(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var ak,ck,lk,mk,pk=d(()=>{M();et();Qe();mm();ve();s(ik,"pruneUndefined");ak=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=w(e(o)),c=gn(i.globs),l=ik({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:o,toPath:`${Ts}/${n}`,content:await j(o,l,a)}},"copilotLegacyRuleMapper"),ck=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}=w(e(o)),c=gn(i.applyTo!==void 0?i.applyTo:i.globs),l=ik({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:o,toPath:`${Ts}/${n}`,content:await j(o,l,a)}},"copilotNewRuleMapper"),lk=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:c}=w(r(i)),l=HR(a,t),m=o.includes("/")?o.slice(0,o.lastIndexOf("/")):"",p=`${l.name}.md`,u=m?`${m}/${p}`:p,f=join(n,u);return {destPath:f,toPath:`${am}/${u}`,content:await ot(f,{description:l.description,hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:l.allowedTools,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"tools")||Object.prototype.hasOwnProperty.call(a,"x-agentsmesh-allowed-tools")},c)}},"copilotCommandMapper"),mk=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:c}=w(e(i));return {destPath:i,toPath:`${cm}/${n}`,content:await Lt(i,{...a,name:typeof a.name=="string"?a.name:o},c)}},"copilotAgentMapper");});function uk(t,e,r,n){let i=q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(c=>({...c,target:$n})),a=t.rules.filter(c=>!c.root&&c.globs.length===0);return [...i,...a.map(c=>({level:"warning",file:c.source,target:$n,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var dk=d(()=>{$t();ve();s(uk,"lintRules");});function fk(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>U(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function gk(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=>di(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(U(".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 hk=d(()=>{bt();s(fk,"lintCommands");s(gk,"lintHooks");});function Mv(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function $v(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function Gv(t,e){let r=t.match(yk);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function jv(t,e){let n=e.match(yk)?.groups?.path;if(!n)return null;let o=join(t,n),i=await y(o);if(i===null)return null;let a=$v(t,o);return a?{assetPath:`${Zr}/scripts/${a}`,content:i,rewrittenCommand:Gv(e,a)}:null}function Uv(t,e){return `${Zr}/scripts/${Mv(t)}-${e}.sh`}function Kv(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${e}`,`# agentsmesh-command: ${t}`,"set -e",t,""].join(`
98
+ `)}async function _k(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 c=0;for(let l of a){if(!pm(l))continue;let m=Uv(i,c),p=l.command,u=await jv(t,l.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=Kv(p,l.matcher).replace(`set -e
99
99
  `,`set -e
100
100
  HOOK_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
101
- `);n.push({path:m,content:f}),c++;}}return [...r,...n,...o.values()]}var yk,Ik=d(()=>{A();ve();Zd();yk=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(Nv,"safePhaseName");s(Fv,"toRepoRelative");s(vv,"rewriteWrapperCommand");s(Mv,"buildAssetOutput");s($v,"wrapperPath");s(Gv,"buildWrapper");s(_k,"addHookScriptAssets");});function Uv(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Ck,Sk=d(()=>{A();ve();s(Uv,"computeStatus");Ck=s(async(t,e,r,n)=>{if(r!=="global"||!n.has("rules"))return [];let o=t.rules.find(c=>c.root);if(!o)return [];let i=o.body.trim(),a=await y(join(e,Ds));return [{target:"copilot",path:Ds,content:i,currentContent:a??void 0,status:Uv(a,i)}]},"generateCopilotGlobalExtras");});var Wv,Bv,Hv,zv,um,Qd=d(()=>{qR();ve();qd();pk();dk();xt();lm();hk();Ik();Sk();Wv={name:"copilot",primaryRootInstructionPath:As,generateRules:VR,generateCommands:JR,generateAgents:XR,generateSkills:YR,generateHooks:ZR,importFrom:pm},Bv={rootInstructionPath:As,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 [`${xs}/${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 `${xs}/${t}.instructions.md`},commandPath(t,e){return cm(t)},agentPath(t,e){return `${Ps}/${t}.agent.md`}}},Hv={rootInstructionPath:Lo,renderPrimaryRootInstruction:zR,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Ds]}],skillDir:Gn,managedOutputs:{dirs:[Gi,Gn,ji,Xd,Yd],files:[Lo,Ds]},rewriteGeneratedPath(t){return t===As?Lo:t.startsWith(`${xs}/`)?Lo:t.startsWith(`${Eo}/`)?t.replace(`${Eo}/`,`${ji}/`):t.startsWith(`${Ps}/`)?t.replace(`${Ps}/`,`${Gi}/`):t.startsWith(`${qr}/`)?t.replace(`${qr}/`,`${Gn}/`):t.startsWith(`${Zr}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${Gn}/`)&&!e.includes("codex-cli")){let r=t.slice(Gn.length+1);return [`.agents/skills/${r}`,`${Yd}/${r}`]}return null},paths:{rulePath(t,e){return Lo},commandPath(t,e){return `${ji}/${t}.prompt.md`},agentPath(t,e){return `${Gi}/${t}.agent.md`}}},zv={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},um={id:"copilot",generators:Wv,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:uk,lint:{commands:fk,hooks:gk},postProcessHookOutputs:s(async(t,e,r)=>_k(t,e,[...r]),"postProcessHookOutputs"),project:Bv,globalSupport:{capabilities:zv,detectionPaths:[Lo,Ds,Gi,Gn,ji,Xd],layout:Hv,scopeExtras:Ck},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[As],global:[Lo]},canonicalDir:Ts,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[jR]},canonicalDir:Ts,extensions:[".instructions.md"],map:ak},{feature:"rules",mode:"directory",source:{project:[xs]},canonicalDir:Ts,extensions:[".instructions.md",".md"],map:ck}],commands:{feature:"commands",mode:"directory",source:{project:[Eo],global:[ji]},canonicalDir:im,extensions:[".prompt.md"],map:lk},agents:{feature:"agents",mode:"directory",source:{project:[Ps],global:[Gi]},canonicalDir:am,extensions:[".agent.md"],map:mk}},buildImportPaths:qu,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function tf(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:oo,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let c=F(a,i);e.push({path:kn,content:c});}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"),l={alwaysApply:i.trigger==="always_on"};i.description&&(l.description=i.description),i.globs.length>0&&(l.globs=i.globs);let m=F(l,i.body.trim()||"");e.push({path:`${Te}/${a}.mdc`,content:m});}let o=Rk(t);return o.trim()&&e.push({path:sr,content:o}),e}function Rk(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(Et(e.body,r)):r.length>0&&n.push(Et("",r)),n.filter(Boolean).join(`
101
+ `);n.push({path:m,content:f}),c++;}}return [...r,...n,...o.values()]}var yk,Ik=d(()=>{A();ve();Zd();yk=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(Mv,"safePhaseName");s($v,"toRepoRelative");s(Gv,"rewriteWrapperCommand");s(jv,"buildAssetOutput");s(Uv,"wrapperPath");s(Kv,"buildWrapper");s(_k,"addHookScriptAssets");});function Bv(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Ck,Sk=d(()=>{A();ve();s(Bv,"computeStatus");Ck=s(async(t,e,r,n)=>{if(r!=="global"||!n.has("rules"))return [];let o=t.rules.find(c=>c.root);if(!o)return [];let i=o.body.trim(),a=await y(join(e,Ds));return [{target:"copilot",path:Ds,content:i,currentContent:a??void 0,status:Bv(a,i)}]},"generateCopilotGlobalExtras");});var zv,Vv,Jv,Yv,dm,Qd=d(()=>{qR();ve();qd();pk();dk();xt();mm();hk();Ik();Sk();zv={name:"copilot",primaryRootInstructionPath:As,generateRules:VR,generateCommands:JR,generateAgents:XR,generateSkills:YR,generateHooks:ZR,importFrom:um},Vv={rootInstructionPath:As,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 [`${xs}/${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 `${xs}/${t}.instructions.md`},commandPath(t,e){return lm(t)},agentPath(t,e){return `${Ps}/${t}.agent.md`}}},Jv={rootInstructionPath:Lo,renderPrimaryRootInstruction:zR,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Ds]}],skillDir:Gn,managedOutputs:{dirs:[Gi,Gn,ji,Xd,Yd],files:[Lo,Ds]},rewriteGeneratedPath(t){return t===As?Lo:t.startsWith(`${xs}/`)?Lo:t.startsWith(`${Eo}/`)?t.replace(`${Eo}/`,`${ji}/`):t.startsWith(`${Ps}/`)?t.replace(`${Ps}/`,`${Gi}/`):t.startsWith(`${qr}/`)?t.replace(`${qr}/`,`${Gn}/`):t.startsWith(`${Zr}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${Gn}/`)&&!e.includes("codex-cli")){let r=t.slice(Gn.length+1);return [`.agents/skills/${r}`,`${Yd}/${r}`]}return null},paths:{rulePath(t,e){return Lo},commandPath(t,e){return `${ji}/${t}.prompt.md`},agentPath(t,e){return `${Gi}/${t}.agent.md`}}},Yv={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},dm={id:"copilot",generators:zv,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:uk,lint:{commands:fk,hooks:gk},postProcessHookOutputs:s(async(t,e,r)=>_k(t,e,[...r]),"postProcessHookOutputs"),project:Vv,globalSupport:{capabilities:Yv,detectionPaths:[Lo,Ds,Gi,Gn,ji,Xd],layout:Jv,scopeExtras:Ck},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[As],global:[Lo]},canonicalDir:Ts,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[jR]},canonicalDir:Ts,extensions:[".instructions.md"],map:ak},{feature:"rules",mode:"directory",source:{project:[xs]},canonicalDir:Ts,extensions:[".instructions.md",".md"],map:ck}],commands:{feature:"commands",mode:"directory",source:{project:[Eo],global:[ji]},canonicalDir:am,extensions:[".prompt.md"],map:lk},agents:{feature:"agents",mode:"directory",source:{project:[Ps],global:[Gi]},canonicalDir:cm,extensions:[".agent.md"],map:mk}},buildImportPaths:qu,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function tf(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:oo,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let c=F(a,i);e.push({path:kn,content:c});}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"),l={alwaysApply:i.trigger==="always_on"};i.description&&(l.description=i.description),i.globs.length>0&&(l.globs=i.globs);let m=F(l,i.body.trim()||"");e.push({path:`${Te}/${a}.mdc`,content:m});}let o=Rk(t);return o.trim()&&e.push({path:sr,content:o}),e}function Rk(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(Et(e.body,r)):r.length>0&&n.push(Et("",r)),n.filter(Boolean).join(`
102
102
 
103
- `)}var kk=d(()=>{M();we();Rt();s(tf,"generateRules");s(Rk,"renderCursorGlobalUserRules");});function ef(t){return t.commands.map(e=>({path:`${De}/${e.name}.md`,content:e.body.trim()||""}))}var Ok=d(()=>{Rt();s(ef,"generateCommands");});function rf(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Fr,content:e}]}var wk=d(()=>{Rt();s(rf,"generateMcp");});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=F(n,r.body.trim()||"");e.push({path:`${Nr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Nr}/${r.name}/${a}`,content:i.content});}}return e}var Ek=d(()=>{M();Rt();s(nf,"generateSkills");});function of(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=F(r,e.body.trim()||"");return {path:`${_i}/${e.name}.md`,content:n}})}var Lk=d(()=>{M();Rt();s(of,"generateAgents");});function sf(t){return []}var bk=d(()=>{s(sf,"generatePermissions");});function Jv(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Or(i))continue;let a=wt(i),c=Yt(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}function af(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=Jv(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:vr,content:r}]}var Ak=d(()=>{Je();Rt();s(Jv,"toCursorHooks");s(af,"generateHooks");});function cf(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
104
- `);return [{path:or,content:e}]}var xk=d(()=>{Rt();s(cf,"generateIgnore");});var Pk=d(()=>{kk();Ok();wk();Ek();Lk();bk();Ak();xk();});var Tk=d(()=>{Pk();});async function fm(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),c=w(r(i)).frontmatter.alwaysApply===true,l=c?join(e,"_root.md"):i,{frontmatter:m,body:p}=w(r(l));c&&n();let u={...m,root:c};if(delete u.alwaysApply,!c){let f=Yv(m);f!==null&&(u.trigger=f);}return {destPath:l,toPath:`${Mr}/${c?"_root.md":o}`,feature:"rules",content:await j(l,u,p)}}function Yv(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 Dk(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=w(r(n)),a=xe(o.allowedTools),c=a.length>0?a:xe(o["allowed-tools"]);return {destPath:n,toPath:`${ao}/${t}`,feature:"commands",content:await ot(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}}async function Nk(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=w(r(n));return {destPath:n,toPath:`${co}/${t}`,feature:"agents",content:await Lt(n,o,i)}}var lf=d(()=>{M();et();Qe();Rt();s(fm,"mapCursorRuleFile");s(Yv,"deriveCursorTrigger");s(Dk,"mapCursorCommandFile");s(Nk,"mapCursorAgentFile");});async function Ui(t){let e=join(t.projectRoot,Mr);await O(e);let r=join(e,"_root.md"),n=await Vr({content:t.content,projectRoot:t.projectRoot,rulesDir:Mr,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}=w(o),c=i.root===true?i:{...i,root:true},l=await j(r,c,a);return await S(r,l),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${Mr}/_root.md`,feature:"rules"}),true}var mf=d(()=>{A();M();vi();et();Rt();s(Ui,"importCursorRootFile");});async function vk(t,e,r){let n=join(t,Mr),o=false,i=join(t,Te);if(e.push(...await mt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:c,normalizeTo:l})=>{if(o){let m=await y(a);if(m!==null){let{frontmatter:p}=w(m);if(p.alwaysApply===true)return null}}return fm(c,n,l,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,oo),c=await y(a);c!==null&&(o=await Ui({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r}));}if(!o){let a=join(t,bI),c=await y(a);c!==null&&await Ui({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r});}}var Mk=d(()=>{A();M();tr();lf();mf();Rt();s(vk,"importCursorRules");});function $k(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,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!Or({...m,type:p}))continue;let u=p==="prompt"?Yt(m)||wt(m):wt(m)||Yt(m),f={matcher:c,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 ym(t,e){let r=false,n=join(t,vr),o=await y(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=$k(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,Xa);await O(dirname(g)),await S(g,f),e.push({fromTool:"cursor",fromPath:n,toPath:Xa,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,Dl),a=await y(i);if(!a)return;let c;try{c=JSON.parse(a);}catch{return}let l=c.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let p=l,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,td);await O(dirname(h)),await S(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:td,feature:"permissions"});}}let m=r?void 0:c.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=$k(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,Xa);await O(dirname(f)),await S(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:Xa,feature:"hooks"});}}}async function _m(t,e){let r=[{path:join(t,or),label:or},{path:join(t,Qu),label:Qu}],n=[],o=[];for(let a of r){let c=await y(a.path);if(c!==null){o.push(a.label);for(let l of c.split(/\r?\n/)){let m=l.trim();m&&!n.includes(m)&&n.push(m);}}}if(n.length===0)return;let i=join(t,ed);await O(dirname(i)),await S(i,n.join(`
103
+ `)}var kk=d(()=>{M();we();Rt();s(tf,"generateRules");s(Rk,"renderCursorGlobalUserRules");});function ef(t){return t.commands.map(e=>({path:`${De}/${e.name}.md`,content:e.body.trim()||""}))}var Ok=d(()=>{Rt();s(ef,"generateCommands");});function rf(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Fr,content:e}]}var wk=d(()=>{Rt();s(rf,"generateMcp");});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=F(n,r.body.trim()||"");e.push({path:`${Nr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Nr}/${r.name}/${a}`,content:i.content});}}return e}var Ek=d(()=>{M();Rt();s(nf,"generateSkills");});function of(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=F(r,e.body.trim()||"");return {path:`${_i}/${e.name}.md`,content:n}})}var Lk=d(()=>{M();Rt();s(of,"generateAgents");});function sf(t){return []}var bk=d(()=>{s(sf,"generatePermissions");});function Zv(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Or(i))continue;let a=wt(i),c=Yt(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}function af(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=Zv(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:vr,content:r}]}var Ak=d(()=>{Je();Rt();s(Zv,"toCursorHooks");s(af,"generateHooks");});function cf(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
104
+ `);return [{path:or,content:e}]}var xk=d(()=>{Rt();s(cf,"generateIgnore");});var Pk=d(()=>{kk();Ok();wk();Ek();Lk();bk();Ak();xk();});var Tk=d(()=>{Pk();});async function gm(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),c=w(r(i)).frontmatter.alwaysApply===true,l=c?join(e,"_root.md"):i,{frontmatter:m,body:p}=w(r(l));c&&n();let u={...m,root:c};if(delete u.alwaysApply,!c){let f=qv(m);f!==null&&(u.trigger=f);}return {destPath:l,toPath:`${Mr}/${c?"_root.md":o}`,feature:"rules",content:await j(l,u,p)}}function qv(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 Dk(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=w(r(n)),a=xe(o.allowedTools),c=a.length>0?a:xe(o["allowed-tools"]);return {destPath:n,toPath:`${ao}/${t}`,feature:"commands",content:await ot(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}}async function Nk(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=w(r(n));return {destPath:n,toPath:`${co}/${t}`,feature:"agents",content:await Lt(n,o,i)}}var lf=d(()=>{M();et();Qe();Rt();s(gm,"mapCursorRuleFile");s(qv,"deriveCursorTrigger");s(Dk,"mapCursorCommandFile");s(Nk,"mapCursorAgentFile");});async function Ui(t){let e=join(t.projectRoot,Mr);await O(e);let r=join(e,"_root.md"),n=await Vr({content:t.content,projectRoot:t.projectRoot,rulesDir:Mr,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}=w(o),c=i.root===true?i:{...i,root:true},l=await j(r,c,a);return await S(r,l),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${Mr}/_root.md`,feature:"rules"}),true}var mf=d(()=>{A();M();vi();et();Rt();s(Ui,"importCursorRootFile");});async function vk(t,e,r){let n=join(t,Mr),o=false,i=join(t,Te);if(e.push(...await mt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:c,normalizeTo:l})=>{if(o){let m=await y(a);if(m!==null){let{frontmatter:p}=w(m);if(p.alwaysApply===true)return null}}return gm(c,n,l,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,oo),c=await y(a);c!==null&&(o=await Ui({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r}));}if(!o){let a=join(t,bI),c=await y(a);c!==null&&await Ui({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r});}}var Mk=d(()=>{A();M();tr();lf();mf();Rt();s(vk,"importCursorRules");});function $k(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,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!Or({...m,type:p}))continue;let u=p==="prompt"?Yt(m)||wt(m):wt(m)||Yt(m),f={matcher:c,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 _m(t,e){let r=false,n=join(t,vr),o=await y(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=$k(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,Za);await O(dirname(g)),await S(g,f),e.push({fromTool:"cursor",fromPath:n,toPath:Za,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,Nl),a=await y(i);if(!a)return;let c;try{c=JSON.parse(a);}catch{return}let l=c.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let p=l,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,td);await O(dirname(h)),await S(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:td,feature:"permissions"});}}let m=r?void 0:c.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=$k(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,Za);await O(dirname(f)),await S(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:Za,feature:"hooks"});}}}async function Im(t,e){let r=[{path:join(t,or),label:or},{path:join(t,Qu),label:Qu}],n=[],o=[];for(let a of r){let c=await y(a.path);if(c!==null){o.push(a.label);for(let l of c.split(/\r?\n/)){let m=l.trim();m&&!n.includes(m)&&n.push(m);}}}if(n.length===0)return;let i=join(t,ed);await O(dirname(i)),await S(i,n.join(`
105
105
  `)+`
106
- `),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:ed,feature:"ignore"});}var uf=d(()=>{Je();A();Rt();s($k,"cursorHooksToCanonical");s(ym,"importSettings");s(_m,"importIgnore");});async function Im(t,e,r,n=Nr){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:AI,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Jr(p,u,a);let c=await N(o).catch(()=>[]),l=c.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>c.filter(u=>u.startsWith(p))));for(let p of l){if(m.has(p))continue;let u=await y(p);if(!u)continue;let f=basename(p,".md");await _S(f,p,u,a);}}var df=d(()=>{A();Mi();Rt();s(Im,"importSkills");});async function Gk(t){if(await v(join(t,Te)))return true;let e=[join(t,sr),join(t,Ii),join(t,Ya),join(t,vr),join(t,or),join(t,so),join(t,io),join(t,De)];for(let i of e){let a=await y(i);if(a!==null&&a.trim()!=="")return true}return !!((await N(join(t,so))).some(i=>i.endsWith(".md"))||(await N(join(t,io))).some(i=>i.endsWith(".md"))||(await N(join(t,De))).some(i=>i.endsWith(".md")))}async function jk(t,e,r){let n=join(t,Mr),o=false,i=join(t,Te),a=await mt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:Ki,normalize:r,mapEntry:s(async({srcPath:c,relativePath:l,normalizeTo:m})=>{if(o){let p=await y(c);if(p!==null){let{frontmatter:u}=w(p);if(u.alwaysApply===true)return null}}return fm(l,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function Uk(t,e,r){let n=join(t,Ii),o=await y(n);return o===null||o.trim()===""?false:Ui({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function Kk(t,e,r){let n=join(t,sr),o=await y(n);return o===null||o.trim()===""?false:Ui({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function Wk(t,e){let r=join(t,Ya),n=await y(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,Ci);await O(dirname(i)),await S(i,n),e.push({fromTool:Ki,fromPath:r,toPath:Ci,feature:"mcp"});}async function Bk(t,e,r){let n=join(t,io),o=join(t,co);e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Ki,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>Nk(i,o,a),"mapEntry")}));}async function Hk(t,e,r){let n=join(t,De),o=join(t,ao);e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Ki,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>Dk(i,o,a),"mapEntry")}));}var Ki,zk=d(()=>{A();M();tr();Rt();mf();lf();Ki="cursor";s(Gk,"hasGlobalCursorArtifacts");s(jk,"importGlobalCursorRulesFromDir");s(Uk,"importGlobalUserRules");s(Kk,"importGlobalDotCursorAgents");s(Wk,"importGlobalMcp");s(Bk,"importGlobalAgents");s(Hk,"importGlobalCommands");});async function Vk(t){if(!await Gk(t))return [];let e=[],r=await z(Ki,t,"global"),n=await jk(t,e,r);return n||(n=await Uk(t,e,r)),n||await Kk(t,e,r),await Wk(t,e),await Im(t,e,r,so),await Bk(t,e,r),await Hk(t,e,r),await ym(t,e),await _m(t,e),e}var Jk=d(()=>{It();Rt();df();uf();zk();s(Vk,"importFromCursorGlobalExports");});async function tM(t,e){let r=join(t,Fr),n=await y(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,Ci,i),e.push({fromTool:"cursor",fromPath:r,toPath:Ci,feature:"mcp"});}async function Cm(t,e={}){if(e.scope==="global")return Vk(t);let r=[],n=await z("cursor",t);return await vk(t,r,n),r.push(...await Q(Sm,t,"project",{normalize:n})),await Im(t,r,n),await tM(t,r),await ym(t,r),await _m(t,r),r}var ff=d(()=>{It();A();Mt();fn();Mk();uf();df();Jk();Rt();gf();s(tM,"importMcp");s(Cm,"importFromCursor");});var Xk,Zk,qk=d(()=>{M();et();Qe();Rt();Xk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n)),a=xe(o.allowedTools),c=a.length>0?a:xe(o["allowed-tools"]);return {destPath:n,toPath:`${ao}/${t}`,content:await ot(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"cursorCommandMapper"),Zk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${co}/${t}`,content:await Lt(n,o,i)}},"cursorAgentMapper");});function Qk(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:LI}))}var tO=d(()=>{$t();Rt();s(Qk,"lintRules");});function eO(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>U(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function rO(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(U(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function nO(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?[U(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var oO=d(()=>{bt();s(eO,"lintCommands");s(rO,"lintMcp");s(nO,"lintPermissions");});var eM,rM,nM,oM,Sm,gf=d(()=>{Tk();Rt();ue();ff();qk();tO();xt();oO();eM={name:"cursor",primaryRootInstructionPath:kn,generateRules:tf,generateCommands:ef,generateAgents:of,generateSkills:nf,generateMcp:rf,generatePermissions:sf,generateHooks:af,generateIgnore:cf,importFrom:Cm},rM={rootInstructionPath:kn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[oo,sr]}],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`}}},nM={rootInstructionPath:kn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[oo,sr]}],skillDir:so,managedOutputs:{dirs:[Te,De,io,so],files:[kn,sr,Ya,vr,or,Ii]},rewriteGeneratedPath(t){return t===oo?null:t===sr||t===kn||t.startsWith(`${Te}/`)||t.startsWith(`${De}/`)||t.startsWith(`${_i}/`)||t.startsWith(`${Nr}/`)||t===Fr||t===vr||t===or?t:t===Dl?null:t},mirrorGlobalPath(t,e){return at(t,Nr,e)},paths:{rulePath(t,e){return `${Te}/${t}.mdc`},commandPath(t,e){return `${De}/${t}.md`},agentPath(t,e){return `${io}/${t}.md`}}},oM={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Sm={id:"cursor",generators:eM,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:Qk,lint:{commands:eO,mcp:rO,permissions:nO},project:rM,globalSupport:{capabilities:oM,detectionPaths:[kn,sr,Fr,vr,or,Nr,io,De,Ii],layout:nM},importer:{commands:{feature:"commands",mode:"directory",source:{project:[De]},canonicalDir:ao,extensions:[".md"],map:Xk},agents:{feature:"agents",mode:"directory",source:{project:[_i]},canonicalDir:co,extensions:[".md"],map:Zk}},buildImportPaths:rd,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});var bo,Me,Qr,sO,iO,ge,Rm,Ns,km,Cc,Ao,aO,cO,xo,Om,Sc,Rc,hf,yf,Wi,_f,Bi,Hi,wm,zi,Fs,kc,Pt=d(()=>{bo="gemini-cli",Me="GEMINI.md",Qr="AGENTS.md",sO=".gemini/rules",iO=".gemini/GEMINI.md",ge=".gemini/commands",Rm=".gemini/policies",Ns=".gemini/settings.json",km=".geminiignore",Cc=".gemini/skills",Ao=".gemini/agents",aO=".gemini/system.md",cO=`${Rm}/permissions.toml`,xo=".agentsmesh/rules",Om=".agentsmesh/commands",Sc=".agentsmesh/agents",Rc=".agentsmesh/skills",hf=".agentsmesh/mcp.json",yf=".agentsmesh/hooks.yaml",Wi=".agentsmesh/ignore",_f=".agentsmesh/permissions.yaml",Bi=".gemini/GEMINI.md",Hi=".gemini/AGENTS.md",wm=".gemini/settings.json",zi=".gemini/commands",Fs=".gemini/skills",kc=".gemini/agents";});function If(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=Et(e?.body.trim()??"",r),o=[{path:Me,content:n}];if(e){let i=e.body.trim().replace(/\.agentsmesh\/skills\//g,".agents/skills/");o.push({path:Qr,content:i});}return o}var lO=d(()=>{we();Pt();s(If,"generateRules");});function mO(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var pO=d(()=>{s(mO,"canonicalCommandNameToGeminiTomlPath");});function sM(t){let e=t.replace(/\r\n/g,`
106
+ `),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:ed,feature:"ignore"});}var uf=d(()=>{Je();A();Rt();s($k,"cursorHooksToCanonical");s(_m,"importSettings");s(Im,"importIgnore");});async function Cm(t,e,r,n=Nr){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:AI,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Jr(p,u,a);let c=await N(o).catch(()=>[]),l=c.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>c.filter(u=>u.startsWith(p))));for(let p of l){if(m.has(p))continue;let u=await y(p);if(!u)continue;let f=basename(p,".md");await _S(f,p,u,a);}}var df=d(()=>{A();Mi();Rt();s(Cm,"importSkills");});async function Gk(t){if(await v(join(t,Te)))return true;let e=[join(t,sr),join(t,Ii),join(t,Xa),join(t,vr),join(t,or),join(t,so),join(t,io),join(t,De)];for(let i of e){let a=await y(i);if(a!==null&&a.trim()!=="")return true}return !!((await N(join(t,so))).some(i=>i.endsWith(".md"))||(await N(join(t,io))).some(i=>i.endsWith(".md"))||(await N(join(t,De))).some(i=>i.endsWith(".md")))}async function jk(t,e,r){let n=join(t,Mr),o=false,i=join(t,Te),a=await mt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:Ki,normalize:r,mapEntry:s(async({srcPath:c,relativePath:l,normalizeTo:m})=>{if(o){let p=await y(c);if(p!==null){let{frontmatter:u}=w(p);if(u.alwaysApply===true)return null}}return gm(l,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function Uk(t,e,r){let n=join(t,Ii),o=await y(n);return o===null||o.trim()===""?false:Ui({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function Kk(t,e,r){let n=join(t,sr),o=await y(n);return o===null||o.trim()===""?false:Ui({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function Wk(t,e){let r=join(t,Xa),n=await y(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,Ci);await O(dirname(i)),await S(i,n),e.push({fromTool:Ki,fromPath:r,toPath:Ci,feature:"mcp"});}async function Bk(t,e,r){let n=join(t,io),o=join(t,co);e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Ki,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>Nk(i,o,a),"mapEntry")}));}async function Hk(t,e,r){let n=join(t,De),o=join(t,ao);e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Ki,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>Dk(i,o,a),"mapEntry")}));}var Ki,zk=d(()=>{A();M();tr();Rt();mf();lf();Ki="cursor";s(Gk,"hasGlobalCursorArtifacts");s(jk,"importGlobalCursorRulesFromDir");s(Uk,"importGlobalUserRules");s(Kk,"importGlobalDotCursorAgents");s(Wk,"importGlobalMcp");s(Bk,"importGlobalAgents");s(Hk,"importGlobalCommands");});async function Vk(t){if(!await Gk(t))return [];let e=[],r=await z(Ki,t,"global"),n=await jk(t,e,r);return n||(n=await Uk(t,e,r)),n||await Kk(t,e,r),await Wk(t,e),await Cm(t,e,r,so),await Bk(t,e,r),await Hk(t,e,r),await _m(t,e),await Im(t,e),e}var Jk=d(()=>{It();Rt();df();uf();zk();s(Vk,"importFromCursorGlobalExports");});async function nM(t,e){let r=join(t,Fr),n=await y(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,Ci,i),e.push({fromTool:"cursor",fromPath:r,toPath:Ci,feature:"mcp"});}async function Sm(t,e={}){if(e.scope==="global")return Vk(t);let r=[],n=await z("cursor",t);return await vk(t,r,n),r.push(...await Q(Rm,t,"project",{normalize:n})),await Cm(t,r,n),await nM(t,r),await _m(t,r),await Im(t,r),r}var ff=d(()=>{It();A();Mt();fn();Mk();uf();df();Jk();Rt();gf();s(nM,"importMcp");s(Sm,"importFromCursor");});var Xk,Zk,qk=d(()=>{M();et();Qe();Rt();Xk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n)),a=xe(o.allowedTools),c=a.length>0?a:xe(o["allowed-tools"]);return {destPath:n,toPath:`${ao}/${t}`,content:await ot(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"cursorCommandMapper"),Zk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${co}/${t}`,content:await Lt(n,o,i)}},"cursorAgentMapper");});function Qk(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:LI}))}var tO=d(()=>{$t();Rt();s(Qk,"lintRules");});function eO(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>U(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function rO(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(U(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function nO(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?[U(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var oO=d(()=>{bt();s(eO,"lintCommands");s(rO,"lintMcp");s(nO,"lintPermissions");});var oM,sM,iM,aM,Rm,gf=d(()=>{Tk();Rt();ue();ff();qk();tO();xt();oO();oM={name:"cursor",primaryRootInstructionPath:kn,generateRules:tf,generateCommands:ef,generateAgents:of,generateSkills:nf,generateMcp:rf,generatePermissions:sf,generateHooks:af,generateIgnore:cf,importFrom:Sm},sM={rootInstructionPath:kn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[oo,sr]}],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`}}},iM={rootInstructionPath:kn,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[oo,sr]}],skillDir:so,managedOutputs:{dirs:[Te,De,io,so],files:[kn,sr,Xa,vr,or,Ii]},rewriteGeneratedPath(t){return t===oo?null:t===sr||t===kn||t.startsWith(`${Te}/`)||t.startsWith(`${De}/`)||t.startsWith(`${_i}/`)||t.startsWith(`${Nr}/`)||t===Fr||t===vr||t===or?t:t===Nl?null:t},mirrorGlobalPath(t,e){return at(t,Nr,e)},paths:{rulePath(t,e){return `${Te}/${t}.mdc`},commandPath(t,e){return `${De}/${t}.md`},agentPath(t,e){return `${io}/${t}.md`}}},aM={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Rm={id:"cursor",generators:oM,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:Qk,lint:{commands:eO,mcp:rO,permissions:nO},project:sM,globalSupport:{capabilities:aM,detectionPaths:[kn,sr,Fr,vr,or,Nr,io,De,Ii],layout:iM},importer:{commands:{feature:"commands",mode:"directory",source:{project:[De]},canonicalDir:ao,extensions:[".md"],map:Xk},agents:{feature:"agents",mode:"directory",source:{project:[_i]},canonicalDir:co,extensions:[".md"],map:Zk}},buildImportPaths:rd,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});var bo,Me,Qr,sO,iO,ge,km,Ns,Om,Sc,Ao,aO,cO,xo,wm,Rc,kc,hf,yf,Wi,_f,Bi,Hi,Em,zi,Fs,Oc,Pt=d(()=>{bo="gemini-cli",Me="GEMINI.md",Qr="AGENTS.md",sO=".gemini/rules",iO=".gemini/GEMINI.md",ge=".gemini/commands",km=".gemini/policies",Ns=".gemini/settings.json",Om=".geminiignore",Sc=".gemini/skills",Ao=".gemini/agents",aO=".gemini/system.md",cO=`${km}/permissions.toml`,xo=".agentsmesh/rules",wm=".agentsmesh/commands",Rc=".agentsmesh/agents",kc=".agentsmesh/skills",hf=".agentsmesh/mcp.json",yf=".agentsmesh/hooks.yaml",Wi=".agentsmesh/ignore",_f=".agentsmesh/permissions.yaml",Bi=".gemini/GEMINI.md",Hi=".gemini/AGENTS.md",Em=".gemini/settings.json",zi=".gemini/commands",Fs=".gemini/skills",Oc=".gemini/agents";});function If(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=Et(e?.body.trim()??"",r),o=[{path:Me,content:n}];if(e){let i=e.body.trim().replace(/\.agentsmesh\/skills\//g,".agents/skills/");o.push({path:Qr,content:i});}return o}var lO=d(()=>{we();Pt();s(If,"generateRules");});function mO(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var pO=d(()=>{s(mO,"canonicalCommandNameToGeminiTomlPath");});function cM(t){let e=t.replace(/\r\n/g,`
107
107
  `);return e.includes('"""')?JSON.stringify(e):`"""
108
108
  ${e}
109
- """`}function iM(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${sM(t.body.trim()||"")}`].join(`
109
+ """`}function lM(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${cM(t.body.trim()||"")}`].join(`
110
110
  `)+`
111
- `}function Cf(t){return t.commands.map(e=>({path:mO(e.name,ge),content:iM(e)}))}var uO=d(()=>{Pt();pO();s(sM,"serializeTomlMultilineLiteral");s(iM,"serializeGeminiCommand");s(Cf,"generateCommands");});function Sf(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=F(r,e.body.trim()||"");return {path:`${Ao}/${e.name}.md`,content:n}})}var dO=d(()=>{M();Pt();s(Sf,"generateAgents");});function Rf(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=F(n,r.body.trim()||"");e.push({path:`${Cc}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Cc}/${r.name}/${a}`,content:i.content});}}return e}var fO=d(()=>{M();Pt();s(Rf,"generateSkills");});function aM(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function kf(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=aM(o);if(!a||!Array.isArray(i))return [];let c=i.filter(l=>typeof l=="object"&&l!==null&&mn(l)).map((l,m)=>({matcher:l.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:wt(l),timeout:l.timeout}]}));return c.length>0?[[a,c]]:[]});n.length>0&&(e.hooks=Object.fromEntries(n),r=true);}return r&&(e.context={fileName:[Me,Qr]}),Object.keys(e).length===0?[]:[{path:Ns,content:JSON.stringify(e,null,2)}]}var Of=d(()=>{Je();Pt();s(aM,"mapHookEvent");s(kf,"generateGeminiSettingsFiles");});function wf(t){return !t.ignore||t.ignore.length===0?[]:[{path:km,content:t.ignore.join(`
112
- `)}]}var gO=d(()=>{Pt();s(wf,"generateIgnore");});var hO=d(()=>{lO();uO();dO();fO();Of();gO();});var yO=d(()=>{hO();});function vs(t){return JSON.stringify(t)}function cM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lM(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 Em(t,e,r){return ["[[rule]]",`decision = ${vs(t)}`,`priority = ${e}`,...r,""].join(`
113
- `)}function _O(t,e,r){let n=lM(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 Em(e,r,[`toolName = ${vs(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return Em(e,r,[`toolName = ${vs(o.Bash)}`,`commandPrefix = ${vs(i)}`])}return n.kind==="read"?Em(e,r,[`toolName = ${vs(o.Read)}`,`argsPattern = ${vs(cM(n.path))}`]):Em(e,r,[`toolName = ${vs(n.raw)}`])}function IO(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 c=_O(i,"allow",100+a);c&&o.push(c);}),r.forEach((i,a)=>{let c=_O(i,"deny",200+a);c&&o.push(c);}),o.length===0?[]:[{path:cO,content:o.join(`
114
- `)}]}var CO=d(()=>{Pt();s(vs,"escapeTomlBasicString");s(cM,"escapeRegexLiteral");s(lM,"parsePermissionExpr");s(Em,"ruleForDecision");s(_O,"permissionExprToGeminiRule");s(IO,"generateGeminiPermissionsPolicies");});function Ef(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 Lm(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return w(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 Lf=d(()=>{M();s(Ef,"mapGeminiHookEvent");s(Lm,"parseFlexibleFrontmatter");});async function bf(t,e){let r=join(t,Ns),n=await y(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 l=join(t,hf);await O(join(t,".agentsmesh")),await S(l,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:hf,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(l=>typeof l=="string")){let l=join(t,Wi);await O(join(t,".agentsmesh")),await S(l,a.join(`
111
+ `}function Cf(t){return t.commands.map(e=>({path:mO(e.name,ge),content:lM(e)}))}var uO=d(()=>{Pt();pO();s(cM,"serializeTomlMultilineLiteral");s(lM,"serializeGeminiCommand");s(Cf,"generateCommands");});function Sf(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=F(r,e.body.trim()||"");return {path:`${Ao}/${e.name}.md`,content:n}})}var dO=d(()=>{M();Pt();s(Sf,"generateAgents");});function Rf(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=F(n,r.body.trim()||"");e.push({path:`${Sc}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Sc}/${r.name}/${a}`,content:i.content});}}return e}var fO=d(()=>{M();Pt();s(Rf,"generateSkills");});function mM(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function kf(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=mM(o);if(!a||!Array.isArray(i))return [];let c=i.filter(l=>typeof l=="object"&&l!==null&&mn(l)).map((l,m)=>({matcher:l.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:wt(l),timeout:l.timeout}]}));return c.length>0?[[a,c]]:[]});n.length>0&&(e.hooks=Object.fromEntries(n),r=true);}return r&&(e.context={fileName:[Me,Qr]}),Object.keys(e).length===0?[]:[{path:Ns,content:JSON.stringify(e,null,2)}]}var Of=d(()=>{Je();Pt();s(mM,"mapHookEvent");s(kf,"generateGeminiSettingsFiles");});function wf(t){return !t.ignore||t.ignore.length===0?[]:[{path:Om,content:t.ignore.join(`
112
+ `)}]}var gO=d(()=>{Pt();s(wf,"generateIgnore");});var hO=d(()=>{lO();uO();dO();fO();Of();gO();});var yO=d(()=>{hO();});function vs(t){return JSON.stringify(t)}function pM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function uM(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 Lm(t,e,r){return ["[[rule]]",`decision = ${vs(t)}`,`priority = ${e}`,...r,""].join(`
113
+ `)}function _O(t,e,r){let n=uM(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 Lm(e,r,[`toolName = ${vs(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return Lm(e,r,[`toolName = ${vs(o.Bash)}`,`commandPrefix = ${vs(i)}`])}return n.kind==="read"?Lm(e,r,[`toolName = ${vs(o.Read)}`,`argsPattern = ${vs(pM(n.path))}`]):Lm(e,r,[`toolName = ${vs(n.raw)}`])}function IO(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 c=_O(i,"allow",100+a);c&&o.push(c);}),r.forEach((i,a)=>{let c=_O(i,"deny",200+a);c&&o.push(c);}),o.length===0?[]:[{path:cO,content:o.join(`
114
+ `)}]}var CO=d(()=>{Pt();s(vs,"escapeTomlBasicString");s(pM,"escapeRegexLiteral");s(uM,"parsePermissionExpr");s(Lm,"ruleForDecision");s(_O,"permissionExprToGeminiRule");s(IO,"generateGeminiPermissionsPolicies");});function Ef(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 bm(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return w(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 Lf=d(()=>{M();s(Ef,"mapGeminiHookEvent");s(bm,"parseFlexibleFrontmatter");});async function bf(t,e){let r=join(t,Ns),n=await y(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 l=join(t,hf);await O(join(t,".agentsmesh")),await S(l,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:hf,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(l=>typeof l=="string")){let l=join(t,Wi);await O(join(t,".agentsmesh")),await S(l,a.join(`
115
115
  `)+`
116
- `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Wi,feature:"ignore"});}let c=o.hooks;if(c!==void 0&&typeof c=="object"&&c!==null){let l=Object.entries(c).flatMap(([m,p])=>{let u=Ef(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"&&mn(h)).map(h=>({matcher:g.matcher,command:wt(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"&&mn(h)).map(h=>({matcher:h.matcher,command:wt(h),type:"command"}));return g.length>0?[[u,g]]:[]}return f.length>0?[[u,f]]:[]});if(l.length>0){let m=Object.fromEntries(l),p=join(t,yf);await O(join(t,".agentsmesh")),await S(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:yf,feature:"hooks"});}}}var SO=d(()=>{Je();A();Pt();Lf();s(bf,"importGeminiSettings");});async function RO(t,e){let r=join(t,km),n=await y(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,Wi);await S(i,o.join(`
116
+ `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Wi,feature:"ignore"});}let c=o.hooks;if(c!==void 0&&typeof c=="object"&&c!==null){let l=Object.entries(c).flatMap(([m,p])=>{let u=Ef(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"&&mn(h)).map(h=>({matcher:g.matcher,command:wt(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"&&mn(h)).map(h=>({matcher:h.matcher,command:wt(h),type:"command"}));return g.length>0?[[u,g]]:[]}return f.length>0?[[u,f]]:[]});if(l.length>0){let m=Object.fromEntries(l),p=join(t,yf);await O(join(t,".agentsmesh")),await S(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:yf,feature:"hooks"});}}}var SO=d(()=>{Je();A();Pt();Lf();s(bf,"importGeminiSettings");});async function RO(t,e){let r=join(t,Om),n=await y(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,Wi);await S(i,o.join(`
117
117
  `)+`
118
- `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Wi,feature:"ignore"});}}}var xf=d(()=>{A();Pt();Lf();SO();s(RO,"importGeminiIgnore");});function fM(t){return t.replace(/\\(.)/g,"$1")}function gM(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 hM(t){return `Bash(${t}:*)`}function yM(t){return `Read(${fM(t)})`}async function kO(t){let e=[],r=join(t,Rm),n;try{n=await N(r);}catch{return e}let o=n.filter(u=>u.endsWith(".toml"));if(o.length===0)return e;let i=[],a=[],c=new Set,l=new Set;for(let u of o){let f=await y(u);if(!f)continue;let g;try{g=parse$1(f);}catch{continue}let h=g&&typeof g=="object"&&"rule"in g?g.rule:void 0;if(Array.isArray(h))for(let R of h){if(!R||typeof R!="object")continue;let C=R,_=typeof C.toolName=="string"?C.toolName:null,E=typeof C.decision=="string"?C.decision:null;if(!_||!E)continue;let T=gM(_);if(!T)continue;let D=null;T==="Bash"?typeof C.commandPrefix=="string"&&C.commandPrefix.trim()&&(D=hM(C.commandPrefix.trim())):T==="Read"?typeof C.argsPattern=="string"&&C.argsPattern.trim()?D=yM(C.argsPattern.trim()):D="Read":D=T,D&&(E==="allow"?c.has(D)||(c.add(D),i.push(D)):E==="deny"&&(l.has(D)||(l.add(D),a.push(D))));}}if(i.length===0&&a.length===0)return e;await O(join(t,".agentsmesh"));let m=join(t,_f),p=stringify({allow:i,deny:a});return await S(m,p.trimEnd()+`
119
- `),e.push({fromTool:bo,fromPath:join(t,Rm),toPath:_f,feature:"permissions"}),e}var OO=d(()=>{A();Pt();s(fM,"unescapeRegexLiteral");s(gM,"toolNameToPermissionBase");s(hM,"commandPrefixToBashExpr");s(yM,"argsPatternToReadExpr");s(kO,"importGeminiPolicies");});function Pf(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 EO=d(()=>{s(Pf,"stripProjectRootCanonicalPrefix");});async function bO(t,e,r){let n=join(t,Cc),i=(await N(n)).filter(c=>basename(c)==="SKILL.md");for(let c of i){let l=await y(c);if(!l)continue;let m=basename(c.slice(0,-9)),p=w(l),u=Er(p.frontmatter,m);if(u){let E=join(t,Sc);await O(E);let T=join(E,`${u.name}.md`);await S(T,Oe(u,r(p.body,c,T))),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${Sc}/${u.name}.md`,feature:"agents"});continue}let f=join(t,Rc,m,"SKILL.md"),g=r(l,c,f),h=join(t,Rc,m);await O(h);let{frontmatter:R,body:C}=w(g);await S(f,await Lr(f,{...R,name:m},C)),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${Rc}/${m}/SKILL.md`,feature:"skills"});let _=await N(dirname(c));for(let E of _){if(E===c)continue;let T=await y(E);if(T===null)continue;let D=relative(dirname(c),E).replace(/\\/g,"/"),x=join(h,D);await O(dirname(x)),await S(x,r(T,E,x)),e.push({fromTool:"gemini-cli",fromPath:E,toPath:`${Rc}/${m}/${D}`,feature:"skills"});}}let a=join(t,Ao);try{let l=(await N(a)).filter(m=>m.endsWith(".md"));for(let m of l){let p=await y(m);if(!p)continue;let{frontmatter:u,body:f}=w(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),R=join(t,Sc);await O(R);let C=join(R,h),_=r(f,m,C);await S(C,await Lt(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},_)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${Sc}/${h}`,feature:"agents"});}}catch{}}var AO=d(()=>{A();M();et();dt();Pt();s(bO,"importGeminiSkillsAndAgents");});async function _M(t,e,r){let n=await z("codex-cli",t),o=join(t,xo),i=join(t,Qr),a=join(t,iO),c=[i,a,join(t,Me),join(t,aO)],l=null,m=c[c.length-1];for(let D of c){let x=await y(D);if(x!==null){l=x,m=D;break}}if(l===null)return;await O(o);let p=join(o,"_root.md"),u=m===i||m===a?n(l,m,p):l,f=await Vr({content:u,projectRoot:t,rulesDir:xo,sourcePath:m,fromTool:bo,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=Pf(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:R,body:C}=w(h),E=R.root===true?R:{...R,root:true},T=Pf(await j(p,E,C),t);await S(p,T),e.push({fromTool:bo,fromPath:m,toPath:`${xo}/_root.md`,feature:"rules"});}async function Am(t){let e=[],r=await z(bo,t);return await _M(t,e,r),e.push(...await Q(xm,t,"project",{normalize:r})),await bO(t,e,r),await bf(t,e),await RO(t,e),e.push(...await kO(t)),e}var Nf=d(()=>{It();A();M();et();vi();Mt();Pt();Ff();xf();OO();EO();AO();s(_M,"importRootRule");s(Am,"importFromGemini");});async function PO(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=Lm(r(o)),c=gn(i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:o,toPath:`${xo}/${n}`,feature:"rules",content:await j(o,l,a)}}async function TO(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),i=r(o),{frontmatter:a,body:c}=t.endsWith(".toml")?CM(i):Lm(i),l=xe(a.allowedTools),m=xe(a["allowed-tools"]),p=l.length>0?l:m;return {destPath:o,toPath:`${Om}/${n}`,feature:"commands",content:await ot(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")},c)}}function CM(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var DO=d(()=>{et();Qe();xf();Pt();s(PO,"mapGeminiRuleFile");s(TO,"mapGeminiCommandFile");s(CM,"parseTomlCommand");});var NO,FO,vO=d(()=>{DO();NO=s(({relativePath:t,destDir:e,normalizeTo:r})=>PO(t,e,r),"geminiRuleMapper"),FO=s(({relativePath:t,destDir:e,normalizeTo:r})=>TO(t,e,r),"geminiCommandMapper");});function MO(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:bo}))}var $O=d(()=>{$t();Pt();s(MO,"lintRules");});function GO(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>U(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function jO(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=>di(n,"gemini-cli",e))}var UO=d(()=>{bt();s(GO,"lintCommands");s(jO,"lintHooks");});function KO(t,e){return e==="project"&&Po("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:kf(t)}var WO=d(()=>{ut();Of();s(KO,"emitScopedGeminiSettings");});function HO(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function zO(t,e){let r=HO(t),n=SM.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 VO(t,e){let r=HO(t),n=RM.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)}var BO,SM,RM,vf=d(()=>{BO=[".claude/settings.json",".gemini/settings.json"],SM=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(),RM=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(HO,"parseJsonObject");s(zO,"mergeSettingsJson");s(VO,"mergeGeminiSettingsJson");});var kM,OM,wM,EM,xm,Ff=d(()=>{yO();Vo();CO();Pt();Nf();vO();$O();xt();si();dt();UO();WO();ue();vf();kM={name:"gemini-cli",primaryRootInstructionPath:Me,generateRules:If,generateCommands:Cf,generateAgents:Sf,generateSkills:Rf,generateIgnore:wf,generatePermissions:IO,importFrom:Am},OM={rootInstructionPath:Me,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Qr]}],extraRuleOutputPaths(){return [Qr]},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 at(t,".gemini/skills",e)},paths:{rulePath(t,e){return Me},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${ge}/${r.join("/")}/${n}.toml`}return `${ge}/${t}.toml`},agentPath(t,e){return ke(e,"gemini-cli")?`.gemini/skills/${V(t)}/SKILL.md`:`${Ao}/${t}.md`}}},wM={rootInstructionPath:Bi,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Hi]}],extraRuleOutputPaths(){return [Hi]},skillDir:Fs,managedOutputs:{dirs:[zi,Fs,kc],files:[Bi,Hi,wm]},rewriteGeneratedPath(t){return t===Me?Bi:t===Qr?Hi:t===Ns?wm:t.startsWith(`${ge}/`)?t.replace(`${ge}/`,`${zi}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Fs}/`):t.startsWith(`${Ao}/`)?t.replace(`${Ao}/`,`${kc}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return at(t,Fs,e)},paths:{rulePath(t,e){return Bi},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${zi}/${r.join("/")}/${n}.toml`}return `${zi}/${t}.toml`},agentPath(t,e){return ke(e,"gemini-cli")?`${Fs}/${V(t)}/SKILL.md`:`${kc}/${t}.md`}}},EM={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},xm={id:"gemini-cli",generators:kM,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Ze("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:MO,lint:{commands:GO,hooks:jO},emitScopedSettings:KO,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Ns?VO(o,r):null},project:OM,globalSupport:{capabilities:EM,detectionPaths:[Bi,Hi,wm,zi,Fs,kc],layout:wM},importer:{rules:{feature:"rules",mode:"directory",source:{project:[sO]},canonicalDir:xo,extensions:[".md"],map:NO},commands:{feature:"commands",mode:"directory",source:{project:[ge]},canonicalDir:Om,extensions:[".md",".toml"],map:FO}},buildImportPaths:nd,detectionPaths:["GEMINI.md",".gemini"]};});function JO(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes($r)),n=e?.body.trim()??"",o=Et(n,r);return o?[{path:Ne,content:o}]:[]}function YO(t){return St(t,Zt)}function XO(t){return t.commands.map(e=>({path:`${Zt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function ZO(t){return t.agents.map(e=>({path:`${Zt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function qO(t){return t.ignore.length===0?[]:[{path:On,content:t.ignore.join(`
120
- `)}]}var QO=d(()=>{_t();we();dt();ne();Si();s(JO,"generateRules");s(YO,"generateSkills");s(XO,"generateCommands");s(ZO,"generateAgents");s(qO,"generateIgnore");});async function tw(t,e={}){let r=e.scope??"project",n=[],o=await z($r,t,r);return n.push(...await Q(Pm,t,r,{normalize:o})),await yt(t,r==="global"?Fe:Zt,$r,n,o),n}var ew=d(()=>{It();_t();Mt();Si();Mf();s(tw,"importFromGoose");});function rw(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:$r}))}var nw=d(()=>{$t();Si();s(rw,"lintRules");});function ow(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function sw(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?[]:[U(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function iw(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[U(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var aw=d(()=>{bt();s(ow,"lintHooks");s(sw,"lintPermissions");s(iw,"lintMcp");});var LM,bM,AM,cw,Pm,Mf=d(()=>{ne();dt();QO();ue();ew();nw();aw();xt();Si();LM={name:$r,primaryRootInstructionPath:Ne,generateRules:JO,generateCommands:XO,generateAgents:ZO,generateSkills:YO,generateIgnore:qO,importFrom:tw},bM={rootInstructionPath:Ne,skillDir:Zt,managedOutputs:{dirs:[Zt],files:[Ne,On]},paths:{rulePath(t){return Ne},commandPath(t){return `${Zt}/${st(t)}/SKILL.md`},agentPath(t){return `${Zt}/${V(t)}/SKILL.md`}}},AM={rootInstructionPath:wn,skillDir:Fe,managedOutputs:{dirs:[Fe],files:[wn,os]},rewriteGeneratedPath(t){return t===Ne?wn:t===On?os:(t.startsWith(`${Zt}/`),t)},mirrorGlobalPath(t,e){return at(t,Fe,e)},paths:{rulePath(t){return wn},commandPath(t){return `${Fe}/${st(t)}/SKILL.md`},agentPath(t){return `${Fe}/${V(t)}/SKILL.md`}}},cw={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Pm={id:$r,generators:LM,capabilities:cw,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:rw,lint:{hooks:ow,permissions:sw,mcp:iw},supportsConversion:{commands:true,agents:true},project:bM,globalSupport:{capabilities:cw,detectionPaths:[wn,os,Fe],layout:AM},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ne],global:[wn]},canonicalDir:DI,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[On],global:[os]},canonicalDir:".agentsmesh",canonicalFilename:NI}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:od,detectionPaths:[Ne,On]};});function lw(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Gr,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:`${qa}/${o}.md`,content:n.body.trim()||""});}return e}function PM(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),tm(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 mw(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,PM(n)]));return [{path:Za,content:JSON.stringify({mcpServers:e},null,2)}]}function pw(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${Ri}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function uw(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:`${ki}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function dw(t){return t.ignore.length===0?[]:[{path:Qa,content:t.ignore.join(`
121
- `)}]}function fw(t){return St(t,is)}function gw(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 Et(e?.body.trim()??"",r)}var hw=d(()=>{em();_t();we();M();Oi();s(lw,"generateRules");s(PM,"toJunieMcpServer");s(mw,"generateMcp");s(pw,"generateCommands");s(uw,"generateAgents");s(dw,"generateIgnore");s(fw,"generateSkills");s(gw,"renderJunieGlobalInstructions");});async function TM(t,e,r){let n=[Gr,Nl,vI,MI],o=join(t,sd);for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=await Vr({content:c,projectRoot:t,rulesDir:vl,sourcePath:a,fromTool:ss,normalize:r});e.push(...l.results);let{frontmatter:m,body:p}=w(r(l.rootContent,a,o)),u=await j(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:ss,fromPath:a,toPath:sd,feature:"rules"});return}}async function Tm(t){let e=[],r=await z(ss,t);return await TM(t,e,r),e.push(...await Q(Dm,t,"project",{normalize:r})),await yt(t,is,ss,e,r),e}var $f=d(()=>{It();A();M();_t();vi();et();Mt();Oi();Gf();s(TM,"importRootRule");s(Tm,"importFromJunie");});function _w(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ss}))}var Iw=d(()=>{$t();Oi();s(_w,"lintRules");});function Cw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))BS(n)&&e.push(U(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${n.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var Sw=d(()=>{em();bt();s(Cw,"lintMcp");});var DM,NM,FM,vM,Dm,Gf=d(()=>{hw();Oi();ue();$f();Iw();Sw();xt();DM={name:"junie",primaryRootInstructionPath:Gr,generateRules:lw,generateCommands:pw,generateAgents:uw,generateSkills:fw,generateMcp:mw,generateIgnore:dw,importFrom:Tm},NM={rootInstructionPath:Gr,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 `${qa}/${t}.md`},commandPath(t,e){return `${Ri}/${t}.md`},agentPath(t,e){return `${ki}/${t}.md`}}},FM={rootInstructionPath:as,renderPrimaryRootInstruction:gw,skillDir:ec,managedOutputs:{dirs:[ec,rc,nc,$I],files:[as,Fl]},rewriteGeneratedPath(t){return t===Gr?as:t.startsWith(`${qa}/`)?as:t.startsWith(`${is}/`)?t.replace(`${is}/`,`${ec}/`):t.startsWith(`${Ri}/`)?t.replace(`${Ri}/`,`${nc}/`):t.startsWith(`${ki}/`)?t.replace(`${ki}/`,`${rc}/`):t===Za?Fl:t===Qa?null:t},mirrorGlobalPath(t,e){return at(t,".junie/skills",e)},paths:{rulePath(t,e){return as},commandPath(t,e){return `${nc}/${t}.md`},agentPath(t,e){return `${rc}/${t}.md`}}},vM={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Dm={id:"junie",generators:DM,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:_w,lint:{mcp:Cw},project:NM,globalSupport:{capabilities:vM,detectionPaths:[as,ec,rc,nc,Fl],layout:FM},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:vl,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:GI,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:jI,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Za]},canonicalDir:".agentsmesh",canonicalFilename:UI},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Qa]},canonicalDir:".agentsmesh",canonicalFilename:KI}},buildImportPaths:id,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function kw(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:jr,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(qt))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?F(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${En}/${o}.md`,content:a});}return e}function Ow(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Ln}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function ww(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:`${bn}/${r}.md`,content:F(n,e.body.trim()||"")}})}function Ew(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:mo,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Lw(t){return t.ignore.length===0?[]:[{path:wi,content:t.ignore.join(`
122
- `)}]}function bw(t){return St(t,ir)}var Aw=d(()=>{_t();M();fs();s(kw,"generateRules");s(Ow,"generateCommands");s(ww,"generateAgents");s(Ew,"generateMcp");s(Lw,"generateIgnore");s(bw,"generateSkills");});var Nm,Fm,xw,Uf=d(()=>{M();et();fs();Nm=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${fo}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"kiloNonRootRuleMapper"),Fm=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Ai}/${t}`,content:await ot(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),xw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${ds}/${t}`,content:await Lt(n,o,i)}},"kiloAgentMapper");});async function Pw(t){try{return await stat(t),!0}catch{return false}}async function GM(t,e,r){let n=join(t,cs);if(!await Pw(n))return;let o=join(t,fo),i=join(n,Wf),c=e.some(l=>l.toPath===Kf)?null:await y(i);if(c!==null){let l=join(t,Kf),m=r(c,i,l),{body:p}=w(m),u=await j(l,{root:true},p);await S(l,u),e.push({feature:"rules",fromTool:qt,fromPath:`${cs}/${Wf}`,toPath:Kf});}e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:qt,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:u})=>{let f=await Nm({absolutePath:l,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===Wf||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function jM(t,e,r){let n=join(t,Ei);if(!await Pw(n))return;let o=join(t,Ai);e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:qt,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:c,normalizeTo:l})=>{let m=await Fm({absolutePath:i,relativePath:a,content:c,destDir:o,normalizeTo:l});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function UM(t,e,r){let n=join(t,$l),o=await y(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 c=a;if(typeof c.slug!="string"||c.slug.length===0)continue;let l=c.slug,m=join(t,ds,`${l}.md`),p=typeof c.description=="string"?c.description:"",u=typeof c.roleDefinition=="string"?c.roleDefinition.trim():"",f=typeof c.whenToUse=="string"?c.whenToUse.trim():"",g=f?`${u}
118
+ `),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Wi,feature:"ignore"});}}}var xf=d(()=>{A();Pt();Lf();SO();s(RO,"importGeminiIgnore");});function yM(t){return t.replace(/\\(.)/g,"$1")}function _M(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 IM(t){return `Bash(${t}:*)`}function CM(t){return `Read(${yM(t)})`}async function kO(t){let e=[],r=join(t,km),n;try{n=await N(r);}catch{return e}let o=n.filter(u=>u.endsWith(".toml"));if(o.length===0)return e;let i=[],a=[],c=new Set,l=new Set;for(let u of o){let f=await y(u);if(!f)continue;let g;try{g=parse$1(f);}catch{continue}let h=g&&typeof g=="object"&&"rule"in g?g.rule:void 0;if(Array.isArray(h))for(let R of h){if(!R||typeof R!="object")continue;let C=R,_=typeof C.toolName=="string"?C.toolName:null,E=typeof C.decision=="string"?C.decision:null;if(!_||!E)continue;let T=_M(_);if(!T)continue;let D=null;T==="Bash"?typeof C.commandPrefix=="string"&&C.commandPrefix.trim()&&(D=IM(C.commandPrefix.trim())):T==="Read"?typeof C.argsPattern=="string"&&C.argsPattern.trim()?D=CM(C.argsPattern.trim()):D="Read":D=T,D&&(E==="allow"?c.has(D)||(c.add(D),i.push(D)):E==="deny"&&(l.has(D)||(l.add(D),a.push(D))));}}if(i.length===0&&a.length===0)return e;await O(join(t,".agentsmesh"));let m=join(t,_f),p=stringify({allow:i,deny:a});return await S(m,p.trimEnd()+`
119
+ `),e.push({fromTool:bo,fromPath:join(t,km),toPath:_f,feature:"permissions"}),e}var OO=d(()=>{A();Pt();s(yM,"unescapeRegexLiteral");s(_M,"toolNameToPermissionBase");s(IM,"commandPrefixToBashExpr");s(CM,"argsPatternToReadExpr");s(kO,"importGeminiPolicies");});function Pf(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 EO=d(()=>{s(Pf,"stripProjectRootCanonicalPrefix");});async function bO(t,e,r){let n=join(t,Sc),i=(await N(n)).filter(c=>basename(c)==="SKILL.md");for(let c of i){let l=await y(c);if(!l)continue;let m=basename(c.slice(0,-9)),p=w(l),u=Er(p.frontmatter,m);if(u){let E=join(t,Rc);await O(E);let T=join(E,`${u.name}.md`);await S(T,Oe(u,r(p.body,c,T))),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${Rc}/${u.name}.md`,feature:"agents"});continue}let f=join(t,kc,m,"SKILL.md"),g=r(l,c,f),h=join(t,kc,m);await O(h);let{frontmatter:R,body:C}=w(g);await S(f,await Lr(f,{...R,name:m},C)),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${kc}/${m}/SKILL.md`,feature:"skills"});let _=await N(dirname(c));for(let E of _){if(E===c)continue;let T=await y(E);if(T===null)continue;let D=relative(dirname(c),E).replace(/\\/g,"/"),x=join(h,D);await O(dirname(x)),await S(x,r(T,E,x)),e.push({fromTool:"gemini-cli",fromPath:E,toPath:`${kc}/${m}/${D}`,feature:"skills"});}}let a=join(t,Ao);try{let l=(await N(a)).filter(m=>m.endsWith(".md"));for(let m of l){let p=await y(m);if(!p)continue;let{frontmatter:u,body:f}=w(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),R=join(t,Rc);await O(R);let C=join(R,h),_=r(f,m,C);await S(C,await Lt(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},_)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${Rc}/${h}`,feature:"agents"});}}catch{}}var AO=d(()=>{A();M();et();dt();Pt();s(bO,"importGeminiSkillsAndAgents");});async function SM(t,e,r){let n=await z("codex-cli",t),o=join(t,xo),i=join(t,Qr),a=join(t,iO),c=[i,a,join(t,Me),join(t,aO)],l=null,m=c[c.length-1];for(let D of c){let x=await y(D);if(x!==null){l=x,m=D;break}}if(l===null)return;await O(o);let p=join(o,"_root.md"),u=m===i||m===a?n(l,m,p):l,f=await Vr({content:u,projectRoot:t,rulesDir:xo,sourcePath:m,fromTool:bo,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=Pf(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:R,body:C}=w(h),E=R.root===true?R:{...R,root:true},T=Pf(await j(p,E,C),t);await S(p,T),e.push({fromTool:bo,fromPath:m,toPath:`${xo}/_root.md`,feature:"rules"});}async function xm(t){let e=[],r=await z(bo,t);return await SM(t,e,r),e.push(...await Q(Pm,t,"project",{normalize:r})),await bO(t,e,r),await bf(t,e),await RO(t,e),e.push(...await kO(t)),e}var Nf=d(()=>{It();A();M();et();vi();Mt();Pt();Ff();xf();OO();EO();AO();s(SM,"importRootRule");s(xm,"importFromGemini");});async function PO(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=bm(r(o)),c=gn(i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:o,toPath:`${xo}/${n}`,feature:"rules",content:await j(o,l,a)}}async function TO(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),i=r(o),{frontmatter:a,body:c}=t.endsWith(".toml")?kM(i):bm(i),l=xe(a.allowedTools),m=xe(a["allowed-tools"]),p=l.length>0?l:m;return {destPath:o,toPath:`${wm}/${n}`,feature:"commands",content:await ot(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")},c)}}function kM(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var DO=d(()=>{et();Qe();xf();Pt();s(PO,"mapGeminiRuleFile");s(TO,"mapGeminiCommandFile");s(kM,"parseTomlCommand");});var NO,FO,vO=d(()=>{DO();NO=s(({relativePath:t,destDir:e,normalizeTo:r})=>PO(t,e,r),"geminiRuleMapper"),FO=s(({relativePath:t,destDir:e,normalizeTo:r})=>TO(t,e,r),"geminiCommandMapper");});function MO(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:bo}))}var $O=d(()=>{$t();Pt();s(MO,"lintRules");});function GO(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>U(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function jO(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=>di(n,"gemini-cli",e))}var UO=d(()=>{bt();s(GO,"lintCommands");s(jO,"lintHooks");});function KO(t,e){return e==="project"&&Po("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:kf(t)}var WO=d(()=>{ut();Of();s(KO,"emitScopedGeminiSettings");});function HO(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function zO(t,e){let r=HO(t),n=OM.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 VO(t,e){let r=HO(t),n=wM.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)}var BO,OM,wM,vf=d(()=>{BO=[".claude/settings.json",".gemini/settings.json"],OM=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(),wM=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(HO,"parseJsonObject");s(zO,"mergeSettingsJson");s(VO,"mergeGeminiSettingsJson");});var EM,LM,bM,AM,Pm,Ff=d(()=>{yO();Vo();CO();Pt();Nf();vO();$O();xt();si();dt();UO();WO();ue();vf();EM={name:"gemini-cli",primaryRootInstructionPath:Me,generateRules:If,generateCommands:Cf,generateAgents:Sf,generateSkills:Rf,generateIgnore:wf,generatePermissions:IO,importFrom:xm},LM={rootInstructionPath:Me,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Qr]}],extraRuleOutputPaths(){return [Qr]},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 at(t,".gemini/skills",e)},paths:{rulePath(t,e){return Me},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${ge}/${r.join("/")}/${n}.toml`}return `${ge}/${t}.toml`},agentPath(t,e){return ke(e,"gemini-cli")?`.gemini/skills/${V(t)}/SKILL.md`:`${Ao}/${t}.md`}}},bM={rootInstructionPath:Bi,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Hi]}],extraRuleOutputPaths(){return [Hi]},skillDir:Fs,managedOutputs:{dirs:[zi,Fs,Oc],files:[Bi,Hi,Em]},rewriteGeneratedPath(t){return t===Me?Bi:t===Qr?Hi:t===Ns?Em:t.startsWith(`${ge}/`)?t.replace(`${ge}/`,`${zi}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Fs}/`):t.startsWith(`${Ao}/`)?t.replace(`${Ao}/`,`${Oc}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return at(t,Fs,e)},paths:{rulePath(t,e){return Bi},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${zi}/${r.join("/")}/${n}.toml`}return `${zi}/${t}.toml`},agentPath(t,e){return ke(e,"gemini-cli")?`${Fs}/${V(t)}/SKILL.md`:`${Oc}/${t}.md`}}},AM={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},Pm={id:"gemini-cli",generators:EM,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Ze("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:MO,lint:{commands:GO,hooks:jO},emitScopedSettings:KO,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Ns?VO(o,r):null},project:LM,globalSupport:{capabilities:AM,detectionPaths:[Bi,Hi,Em,zi,Fs,Oc],layout:bM},importer:{rules:{feature:"rules",mode:"directory",source:{project:[sO]},canonicalDir:xo,extensions:[".md"],map:NO},commands:{feature:"commands",mode:"directory",source:{project:[ge]},canonicalDir:wm,extensions:[".md",".toml"],map:FO}},buildImportPaths:nd,detectionPaths:["GEMINI.md",".gemini"]};});function JO(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes($r)),n=e?.body.trim()??"",o=Et(n,r);return o?[{path:Ne,content:o}]:[]}function YO(t){return St(t,Zt)}function XO(t){return t.commands.map(e=>({path:`${Zt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function ZO(t){return t.agents.map(e=>({path:`${Zt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function qO(t){return t.ignore.length===0?[]:[{path:On,content:t.ignore.join(`
120
+ `)}]}var QO=d(()=>{_t();we();dt();ne();Si();s(JO,"generateRules");s(YO,"generateSkills");s(XO,"generateCommands");s(ZO,"generateAgents");s(qO,"generateIgnore");});async function tw(t,e={}){let r=e.scope??"project",n=[],o=await z($r,t,r);return n.push(...await Q(Tm,t,r,{normalize:o})),await yt(t,r==="global"?Fe:Zt,$r,n,o),n}var ew=d(()=>{It();_t();Mt();Si();Mf();s(tw,"importFromGoose");});function rw(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:$r}))}var nw=d(()=>{$t();Si();s(rw,"lintRules");});function ow(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function sw(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?[]:[U(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function iw(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[U(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var aw=d(()=>{bt();s(ow,"lintHooks");s(sw,"lintPermissions");s(iw,"lintMcp");});var xM,PM,TM,cw,Tm,Mf=d(()=>{ne();dt();QO();ue();ew();nw();aw();xt();Si();xM={name:$r,primaryRootInstructionPath:Ne,generateRules:JO,generateCommands:XO,generateAgents:ZO,generateSkills:YO,generateIgnore:qO,importFrom:tw},PM={rootInstructionPath:Ne,skillDir:Zt,managedOutputs:{dirs:[Zt],files:[Ne,On]},paths:{rulePath(t){return Ne},commandPath(t){return `${Zt}/${st(t)}/SKILL.md`},agentPath(t){return `${Zt}/${V(t)}/SKILL.md`}}},TM={rootInstructionPath:wn,skillDir:Fe,managedOutputs:{dirs:[Fe],files:[wn,os]},rewriteGeneratedPath(t){return t===Ne?wn:t===On?os:(t.startsWith(`${Zt}/`),t)},mirrorGlobalPath(t,e){return at(t,Fe,e)},paths:{rulePath(t){return wn},commandPath(t){return `${Fe}/${st(t)}/SKILL.md`},agentPath(t){return `${Fe}/${V(t)}/SKILL.md`}}},cw={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Tm={id:$r,generators:xM,capabilities:cw,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:rw,lint:{hooks:ow,permissions:sw,mcp:iw},supportsConversion:{commands:true,agents:true},project:PM,globalSupport:{capabilities:cw,detectionPaths:[wn,os,Fe],layout:TM},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ne],global:[wn]},canonicalDir:DI,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[On],global:[os]},canonicalDir:".agentsmesh",canonicalFilename:NI}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:od,detectionPaths:[Ne,On]};});function lw(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Gr,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:`${Qa}/${o}.md`,content:n.body.trim()||""});}return e}function NM(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),em(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 mw(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,NM(n)]));return [{path:qa,content:JSON.stringify({mcpServers:e},null,2)}]}function pw(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${Ri}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function uw(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:`${ki}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function dw(t){return t.ignore.length===0?[]:[{path:tc,content:t.ignore.join(`
121
+ `)}]}function fw(t){return St(t,is)}function gw(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 Et(e?.body.trim()??"",r)}var hw=d(()=>{rm();_t();we();M();Oi();s(lw,"generateRules");s(NM,"toJunieMcpServer");s(mw,"generateMcp");s(pw,"generateCommands");s(uw,"generateAgents");s(dw,"generateIgnore");s(fw,"generateSkills");s(gw,"renderJunieGlobalInstructions");});async function FM(t,e,r){let n=[Gr,Fl,vI,MI],o=join(t,sd);for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=await Vr({content:c,projectRoot:t,rulesDir:Ml,sourcePath:a,fromTool:ss,normalize:r});e.push(...l.results);let{frontmatter:m,body:p}=w(r(l.rootContent,a,o)),u=await j(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:ss,fromPath:a,toPath:sd,feature:"rules"});return}}async function Dm(t){let e=[],r=await z(ss,t);return await FM(t,e,r),e.push(...await Q(Nm,t,"project",{normalize:r})),await yt(t,is,ss,e,r),e}var $f=d(()=>{It();A();M();_t();vi();et();Mt();Oi();Gf();s(FM,"importRootRule");s(Dm,"importFromJunie");});function _w(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ss}))}var Iw=d(()=>{$t();Oi();s(_w,"lintRules");});function Cw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))BS(n)&&e.push(U(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${n.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var Sw=d(()=>{rm();bt();s(Cw,"lintMcp");});var vM,MM,$M,GM,Nm,Gf=d(()=>{hw();Oi();ue();$f();Iw();Sw();xt();vM={name:"junie",primaryRootInstructionPath:Gr,generateRules:lw,generateCommands:pw,generateAgents:uw,generateSkills:fw,generateMcp:mw,generateIgnore:dw,importFrom:Dm},MM={rootInstructionPath:Gr,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 `${Qa}/${t}.md`},commandPath(t,e){return `${Ri}/${t}.md`},agentPath(t,e){return `${ki}/${t}.md`}}},$M={rootInstructionPath:as,renderPrimaryRootInstruction:gw,skillDir:rc,managedOutputs:{dirs:[rc,nc,oc,$I],files:[as,vl]},rewriteGeneratedPath(t){return t===Gr?as:t.startsWith(`${Qa}/`)?as:t.startsWith(`${is}/`)?t.replace(`${is}/`,`${rc}/`):t.startsWith(`${Ri}/`)?t.replace(`${Ri}/`,`${oc}/`):t.startsWith(`${ki}/`)?t.replace(`${ki}/`,`${nc}/`):t===qa?vl:t===tc?null:t},mirrorGlobalPath(t,e){return at(t,".junie/skills",e)},paths:{rulePath(t,e){return as},commandPath(t,e){return `${oc}/${t}.md`},agentPath(t,e){return `${nc}/${t}.md`}}},GM={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Nm={id:"junie",generators:vM,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:_w,lint:{mcp:Cw},project:MM,globalSupport:{capabilities:GM,detectionPaths:[as,rc,nc,oc,vl],layout:$M},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Ml,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:GI,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:jI,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[qa]},canonicalDir:".agentsmesh",canonicalFilename:UI},ignore:{feature:"ignore",mode:"flatFile",source:{project:[tc]},canonicalDir:".agentsmesh",canonicalFilename:KI}},buildImportPaths:id,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function kw(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:jr,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(qt))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?F(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${En}/${o}.md`,content:a});}return e}function Ow(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Ln}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function ww(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:`${bn}/${r}.md`,content:F(n,e.body.trim()||"")}})}function Ew(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:mo,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Lw(t){return t.ignore.length===0?[]:[{path:wi,content:t.ignore.join(`
122
+ `)}]}function bw(t){return St(t,ir)}var Aw=d(()=>{_t();M();fs();s(kw,"generateRules");s(Ow,"generateCommands");s(ww,"generateAgents");s(Ew,"generateMcp");s(Lw,"generateIgnore");s(bw,"generateSkills");});var Fm,vm,xw,Uf=d(()=>{M();et();fs();Fm=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${fo}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"kiloNonRootRuleMapper"),vm=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Ai}/${t}`,content:await ot(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),xw=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${ds}/${t}`,content:await Lt(n,o,i)}},"kiloAgentMapper");});async function Pw(t){try{return await stat(t),!0}catch{return false}}async function KM(t,e,r){let n=join(t,cs);if(!await Pw(n))return;let o=join(t,fo),i=join(n,Wf),c=e.some(l=>l.toPath===Kf)?null:await y(i);if(c!==null){let l=join(t,Kf),m=r(c,i,l),{body:p}=w(m),u=await j(l,{root:true},p);await S(l,u),e.push({feature:"rules",fromTool:qt,fromPath:`${cs}/${Wf}`,toPath:Kf});}e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:qt,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:u})=>{let f=await Fm({absolutePath:l,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===Wf||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function WM(t,e,r){let n=join(t,Ei);if(!await Pw(n))return;let o=join(t,Ai);e.push(...await mt({srcDir:n,destDir:o,extensions:[".md"],fromTool:qt,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:c,normalizeTo:l})=>{let m=await vm({absolutePath:i,relativePath:a,content:c,destDir:o,normalizeTo:l});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function BM(t,e,r){let n=join(t,Gl),o=await y(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 c=a;if(typeof c.slug!="string"||c.slug.length===0)continue;let l=c.slug,m=join(t,ds,`${l}.md`),p=typeof c.description=="string"?c.description:"",u=typeof c.roleDefinition=="string"?c.roleDefinition.trim():"",f=typeof c.whenToUse=="string"?c.whenToUse.trim():"",g=f?`${u}
123
123
 
124
124
  ## When to use
125
125
 
126
- ${f}`:u,h={};p&&(h.description=p),typeof c.name=="string"&&c.name.length>0&&(h.name=c.name);let R=await Lt(m,h,g),C=r(R,n,m);await S(m,C),e.push({feature:"agents",fromTool:qt,fromPath:n,toPath:`${ds}/${l}.md`});}}async function vm(t,e={}){let r=e.scope??"project",n=[],o=await z(qt,t,r);return n.push(...await Q(Mm,t,r,{normalize:o})),await yt(t,ir,qt,n,o),r==="project"&&(await GM(t,n,o),await jM(t,n,o),await UM(t,n,o),await yt(t,ls,qt,n,o)),n}var Kf,Wf,Bf=d(()=>{It();_t();tr();Mt();A();et();M();Uf();fs();Hf();Kf=`${fo}/_root.md`,Wf="00-root.md";s(Pw,"pathExists");s(GM,"importLegacyRules");s(jM,"importLegacyWorkflows");s(UM,"importLegacyModes");s(vm,"importFromKiloCode");});function Tw(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:qt}))}var Dw=d(()=>{$t();fs();s(Tw,"lintRules");});function Nw(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function Fw(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?[]:[U(".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 vw=d(()=>{bt();s(Nw,"lintHooks");s(Fw,"lintPermissions");});var KM,WM,BM,Mw,Mm,Hf=d(()=>{Aw();fs();ue();Bf();Uf();Dw();vw();xt();KM={name:qt,primaryRootInstructionPath:jr,generateRules:kw,generateCommands:Ow,generateAgents:ww,generateSkills:bw,generateMcp:Ew,generateIgnore:Lw,importFrom:vm},WM={rootInstructionPath:jr,skillDir:ir,managedOutputs:{dirs:[En,Ln,bn,ir],files:[jr,mo,wi]},paths:{rulePath(t,e){return `${En}/${t}.md`},commandPath(t,e){return `${Ln}/${t}.md`},agentPath(t,e){return `${bn}/${t}.md`}}},BM={rootInstructionPath:po,skillDir:uo,managedOutputs:{dirs:[ms,ps,us,uo,BI],files:[po,bi,Gl]},rewriteGeneratedPath(t){return t===jr?po:t},mirrorGlobalPath(t,e){return at(t,uo,e)},paths:{rulePath(t,e){return `${ms}/${t}.md`},commandPath(t,e){return `${ps}/${t}.md`},agentPath(t,e){return `${us}/${t}.md`}}},Mw={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Mm={id:qt,generators:KM,capabilities:Mw,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:Tw,lint:{hooks:Nw,permissions:Fw},project:WM,globalSupport:{capabilities:Mw,detectionPaths:[po,ms,ps,us,uo,bi,Gl],layout:BM},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[jr],global:[po]},canonicalDir:fo,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[En],global:[ms]},canonicalDir:fo,extensions:[".md"],map:Nm}],commands:{feature:"commands",mode:"directory",source:{project:[Ln],global:[ps]},canonicalDir:Ai,extensions:[".md"],map:Fm},agents:{feature:"agents",mode:"directory",source:{project:[bn],global:[us]},canonicalDir:ds,extensions:[".md"],map:xw},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[mo,sc],global:[bi]},canonicalDir:".agentsmesh",canonicalFilename:HI},ignore:{feature:"ignore",mode:"flatFile",source:{project:[wi],global:[Gl]},canonicalDir:".agentsmesh",canonicalFilename:zI}},buildImportPaths:ad,detectionPaths:[En,Ln,bn,ir,mo,cs,Ei,ls,sc,$l,wi,"kilo.jsonc","kilo.json"]};});function $w(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function VM(t){return t.type==="prompt"?t.prompt:t.command}function JM(t,e){let r=Gw[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function jw(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in Gw)||!Array.isArray(n))continue;let i=1;for(let a of n){let c=VM(a);if(!c)continue;let l={name:`${$w(r)} ${i}`,version:"1",when:JM(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:c}:{type:"shellCommand",command:c}};e.push({name:`${$w(r)}-${i}.kiro.hook`,content:JSON.stringify(l,null,2)}),i+=1;}}return e}function YM(t){let e=zM.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 Uw(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:YM(r)}function Kw(t){return stringify(t).trimEnd()}var Gw,zM,zf=d(()=>{Gw={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},zM=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s($w,"toKebab");s(VM,"hookText");s(JM,"toWhen");s(jw,"generateKiroHooks");s(YM,"toCanonicalEntry");s(Uw,"parseKiroHookFile");s(Kw,"serializeCanonicalHooks");});function ZM(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 Ww(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:ar,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(fe))continue;let o=basename(n.source,".md");e.push({path:`${cr}/${o}.md`,content:F(ZM(n),n.body.trim()||"")});}return e}function Bw(t){return t.commands.map(e=>({path:`${Qt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function Hw(t){return St(t,Qt)}function zw(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:xi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Vw(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:jw(t.hooks).map(e=>({path:`${go}/${e.name}`,content:e.content}))}function Jw(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=F(r,e.body.trim()||"");return {path:`${lr}/${e.name}.md`,content:n}})}function Yw(t){return t.ignore.length===0?[]:[{path:Pi,content:t.ignore.join(`
127
- `)}]}var Xw=d(()=>{_t();ne();M();zf();Ti();s(ZM,"steeringFrontmatter");s(Ww,"generateRules");s(Bw,"generateCommands");s(Hw,"generateSkills");s(zw,"generateMcp");s(Vw,"generateHooks");s(Jw,"generateAgents");s(Yw,"generateIgnore");});function QM(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:gn(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function t$(t,e,r,n){let o=n==="global"?[mr,ar]:[ar,mr];for(let i of o){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,cd),{frontmatter:m,body:p}=w(r(c,a,l));await S(l,await j(l,{...m,root:true},p)),e.push({fromTool:fe,fromPath:a,toPath:cd,feature:"rules"});return}}async function e$(t,e,r){let n=join(t,ld);e.push(...await mt({srcDir:join(t,cr),destDir:n,extensions:[".md"],fromTool:fe,normalize:r,mapEntry:s(async({relativePath:o,normalizeTo:i})=>{if(basename(o)==="AGENTS.md")return null;let a=join(n,o),{frontmatter:c,body:l}=w(i(a));return {destPath:a,toPath:`${ld}/${o}`,feature:"rules",content:await j(a,QM(c),l)}},"mapEntry")}));}async function r$(t,e){let r={};for(let o of await N(join(t,go))){if(!o.endsWith(".kiro.hook"))continue;let i=Uw(await y(o)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let n=join(t,md);await O(join(t,".agentsmesh")),await S(n,Kw(r)),e.push({fromTool:fe,fromPath:join(t,go),toPath:md,feature:"hooks"});}async function $m(t,e={}){let r=e.scope??"project",n=[],o=await z(fe,t,r);return await t$(t,n,o,r),await e$(t,n,o),n.push(...await Q(Gm,t,r,{normalize:o})),await yt(t,Qt,fe,n,o),r==="project"&&await r$(t,n),n}var Vf=d(()=>{It();_t();tr();Mt();et();Qe();A();M();zf();Ti();Jf();s(QM,"canonicalRuleMeta");s(t$,"importRoot");s(e$,"importNonRootRules");s(r$,"importHooks");s($m,"importFromKiro");});function Zw(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:fe}))}var qw=d(()=>{$t();Ti();s(Zw,"lintRules");});function Qw(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=>di(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var tE=d(()=>{bt();s(Qw,"lintHooks");});var n$,o$,s$,i$,Gm,Jf=d(()=>{ne();Xw();ue();Vf();qw();tE();xt();Ti();n$={name:fe,primaryRootInstructionPath:ar,generateRules:Ww,generateCommands:Bw,generateAgents:Jw,generateSkills:Hw,generateMcp:zw,generateHooks:Vw,generateIgnore:Yw,importFrom:$m},o$={rootInstructionPath:ar,skillDir:Qt,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${cr}/${t}.md`},commandPath(t){return `${Qt}/${st(t)}/SKILL.md`},agentPath(t,e){return `${lr}/${t}.md`}}},s$={rootInstructionPath:mr,skillDir:ho,managedOutputs:{dirs:[gs,ho,hs,YI],files:[mr,ac,cc]},rewriteGeneratedPath(t){return t===ar?mr:t.startsWith(`${cr}/`)?t.replace(`${cr}/`,`${gs}/`):t.startsWith(`${Qt}/`)?t.replace(`${Qt}/`,`${ho}/`):t.startsWith(`${lr}/`)?t.replace(`${lr}/`,`${hs}/`):t===xi?ac:t===Pi?cc:t.startsWith(`${go}/`)?null:t},mirrorGlobalPath(t,e){return at(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${gs}/${t}.md`},commandPath(t){return `${Qt}/${st(t)}/SKILL.md`},agentPath(t,e){return `${hs}/${t}.md`}}},i$={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Gm={id:fe,generators:n$,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:Zw,lint:{hooks:Qw},project:o$,globalSupport:{capabilities:i$,detectionPaths:[gs,mr,ho,hs,ac,cc],layout:s$},importer:{agents:{feature:"agents",mode:"directory",source:{project:[lr],global:[lr]},canonicalDir:XI,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[xi],global:[ac]},canonicalDir:".agentsmesh",canonicalFilename:ZI},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Pi],global:[cc]},canonicalDir:".agentsmesh",canonicalFilename:qI}},buildImportPaths:pd,detectionPaths:[cr,Qt,lr,go,xi,Pi]};});function rE(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Ur,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(pr))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?F(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${An}/${o}.md`,content:a});}return e}function nE(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${xn}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function oE(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:`${Pn}/${r}.md`,content:F(n,e.body.trim()||"")}})}function a$(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 sE(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]=a$(n);return [{path:Kr,content:JSON.stringify({mcp:e},null,2)}]}function iE(t){return St(t,ur)}var aE=d(()=>{_t();M();Cs();s(rE,"generateRules");s(nE,"generateCommands");s(oE,"generateAgents");s(a$,"toOpenCodeMcpServer");s(sE,"generateMcp");s(iE,"generateSkills");});function Yf(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 l$(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:Yf(a.headers),env:Yf(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let c=a.command,l=c[0];if(l===void 0)continue;let m=c.slice(1);n[o]={type:"stdio",command:l,args:m,env:Yf(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function m$(t,e,r){let o=join(t,e==="global"?Io:Kr),i=await y(o);if(i===null)return;let a=l$(i);Object.keys(a).length!==0&&(await Ht(t,ud,a),r.push({feature:"mcp",fromTool:pr,fromPath:o,toPath:ud}));}async function cE(t,e={}){let r=e.scope??"project",n=[],o=await z(pr,t,r);return n.push(...await Q(jm,t,r,{normalize:o})),await yt(t,ur,pr,n,o),await m$(t,r,n),n}var lE=d(()=>{It();_t();Mt();fn();A();Cs();Xf();s(Yf,"toStringRecord");s(l$,"parseOpenCodeMcp");s(m$,"importMcp");s(cE,"importFromOpenCode");});var mE,pE,uE,dE=d(()=>{M();et();Cs();mE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${lc}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"opencodeNonRootRuleMapper"),pE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Ul}/${t}`,content:await ot(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),uE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Kl}/${t}`,content:await Lt(n,o,i)}},"opencodeAgentMapper");});function fE(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:pr}))}var gE=d(()=>{$t();Cs();s(fE,"lintRules");});function hE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function yE(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?[]:[U(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function _E(t){return t.ignore.length===0?[]:[U(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var IE=d(()=>{bt();s(hE,"lintHooks");s(yE,"lintPermissions");s(_E,"lintIgnore");});var p$,u$,d$,CE,jm,Xf=d(()=>{aE();Cs();ue();lE();dE();gE();IE();xt();p$={name:pr,primaryRootInstructionPath:Ur,generateRules:rE,generateCommands:nE,generateAgents:oE,generateSkills:iE,generateMcp:sE,importFrom:cE},u$={rootInstructionPath:Ur,skillDir:ur,managedOutputs:{dirs:[An,xn,Pn,ur],files:[Ur,Kr]},paths:{rulePath(t){return `${An}/${t}.md`},commandPath(t){return `${xn}/${t}.md`},agentPath(t){return `${Pn}/${t}.md`}}},d$={rootInstructionPath:yo,skillDir:_o,managedOutputs:{dirs:[ys,_s,Is,_o,tC],files:[yo,Io]},rewriteGeneratedPath(t){return t===Ur?yo:t===Kr?Io:t},mirrorGlobalPath(t,e){return at(t,_o,e)},paths:{rulePath(t){return `${ys}/${t}.md`},commandPath(t){return `${_s}/${t}.md`},agentPath(t){return `${Is}/${t}.md`}}},CE={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},jm={id:pr,generators:p$,capabilities:CE,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:fE,lint:{hooks:hE,permissions:yE,ignore:_E},project:u$,globalSupport:{capabilities:CE,detectionPaths:[yo,ys,_s,Is,_o,Io],layout:d$},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Ur],global:[yo]},canonicalDir:lc,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[An],global:[ys]},canonicalDir:lc,extensions:[".md"],map:mE}],commands:{feature:"commands",mode:"directory",source:{project:[xn],global:[_s]},canonicalDir:Ul,extensions:[".md"],map:pE},agents:{feature:"agents",mode:"directory",source:{project:[Pn],global:[Is]},canonicalDir:Kl,extensions:[".md"],map:uE}},buildImportPaths:dd,detectionPaths:[An,xn,Pn,ur,Kr,"opencode.jsonc"]};});function RE(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:dr,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Co))continue;let o=basename(n.source,".md");e.push({path:`${Tn}/${o}.md`,content:n.body.trim()||""});}return e}function kE(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Dn}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function OE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:pc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function wE(t){return t.ignore.length===0?[]:[{path:uc,content:t.ignore.join(`
128
- `)}]}function EE(t){return St(t,Wr)}function LE(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:Ni,content:stringify({customModes:e})}]}var bE=d(()=>{_t();M();Os();s(RE,"generateRules");s(kE,"generateCommands");s(OE,"generateMcp");s(wE,"generateIgnore");s(EE,"generateSkills");s(LE,"generateAgents");});var Um,xE,qf=d(()=>{M();et();Os();Um=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${ks}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"rooNonRootRuleMapper"),xE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Bl}/${t}`,content:await ot(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function h$(t,e,r){let n=join(t,Ss),o;try{o=await readdir(n,{withFileTypes:!0});}catch{return}let i=o.filter(c=>c.isDirectory()&&c.name.startsWith("rules-")).map(c=>c.name),a=join(t,ks);for(let c of i)e.push(...await mt({srcDir:join(n,c),destDir:a,extensions:[".md"],fromTool:Co,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:u})=>{let f=await Um({absolutePath:l,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function PE(t,e={}){let r=e.scope??"project",n=[],o=await z(Co,t,r);return n.push(...await Q(Km,t,r,{normalize:o})),await h$(t,n,o),await yt(t,Wr,Co,n,o),n}var TE=d(()=>{It();_t();tr();Mt();qf();Os();tg();s(h$,"importPerModeRules");s(PE,"importFromRooCode");});function DE(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Co}))}var NE=d(()=>{$t();Os();s(DE,"lintRules");});function R$(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var C$,S$,k$,O$,w$,Km,tg=d(()=>{A();bE();Os();ue();TE();qf();NE();xt();C$={name:"roo-code",primaryRootInstructionPath:dr,generateRules:RE,generateCommands:kE,generateSkills:EE,generateMcp:OE,generateIgnore:wE,generateAgents:LE,importFrom:PE},S$={rootInstructionPath:dr,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Ni]},paths:{rulePath(t,e){return `${Tn}/${t}.md`},commandPath(t,e){return `${Dn}/${t}.md`},agentPath(t,e){return null}}};s(R$,"computeStatus");k$=s(async(t,e,r,n)=>{if(r!=="global")return [];if(!n.has("agents")||t.agents.length===0)return [];let o=t.agents.map(c=>{let m={slug:basename(c.source,".md"),name:c.name};return c.description&&(m.description=c.description),c.body.trim()&&(m.roleDefinition=c.body.trim()),m}),i=stringify({customModes:o}),a=await y(join(e,dc));return [{target:"roo-code",path:dc,content:i,currentContent:a??void 0,status:R$(a,i)}]},"generateRooGlobalExtras"),O$={rootInstructionPath:ko,skillDir:Nn,managedOutputs:{dirs:[So,Ro,Nn,rC],files:[ko,Rs,fc,dc]},rewriteGeneratedPath(t){return t===dr?ko:t===Ni?null:t.startsWith(`${Tn}/`)?t.replace(`${Tn}/`,`${So}/`):t.startsWith(`${Dn}/`)?t.replace(`${Dn}/`,`${Ro}/`):t.startsWith(`${Wr}/`)?t.replace(`${Wr}/`,`${Nn}/`):t===pc?Rs:t===uc?fc:t},mirrorGlobalPath(t,e){return at(t,Nn,e)},paths:{rulePath(t,e){return `${So}/${t}.md`},commandPath(t,e){return `${Ro}/${t}.md`},agentPath(t,e){return null}}},w$={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Km={id:"roo-code",generators:C$,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:DE,project:S$,globalSupport:{capabilities:w$,detectionPaths:[So,Ro,Nn,Rs,fc,ko,dc],layout:O$,scopeExtras:k$},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[dr,mc],global:[ko,dr,mc]},canonicalDir:ks,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:[Tn],global:[So]},canonicalDir:ks,extensions:[".md"],map:Um}],commands:{feature:"commands",mode:"directory",source:{project:[Dn],global:[Ro]},canonicalDir:Bl,extensions:[".md"],map:xE},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[pc],global:[Rs]},canonicalDir:".agentsmesh",canonicalFilename:nC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[uc],global:[fc]},canonicalDir:".agentsmesh",canonicalFilename:oC}},buildImportPaths:fd,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Ni]};});function FE(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Br)),n=e?.body.trim()??"",o=Et(n,r);return o?[{path:fr,content:o}]:[]}function vE(t){return St(t,zt)}function ME(t){return t.commands.map(e=>({path:`${zt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function $E(t){return t.agents.map(e=>({path:`${zt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function GE(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Oo,content:e}]}var jE=d(()=>{_t();we();dt();ne();Fi();s(FE,"generateRules");s(vE,"generateSkills");s(ME,"generateCommands");s($E,"generateAgents");s(GE,"generateMcp");});async function UE(t,e={}){let r=e.scope??"project",n=[],o=await z(Br,t,r);return n.push(...await Q(Wm,t,r,{normalize:o})),await yt(t,r==="global"?se:zt,Br,n,o),n}var KE=d(()=>{It();_t();Mt();Fi();eg();s(UE,"importFromWarp");});function WE(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Br}))}var BE=d(()=>{$t();Fi();s(WE,"lintRules");});function HE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function zE(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?[]:[U(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function VE(t){return t.ignore.length===0?[]:[U(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var JE=d(()=>{bt();s(HE,"lintHooks");s(zE,"lintPermissions");s(VE,"lintIgnore");});var E$,L$,b$,A$,x$,Wm,eg=d(()=>{ne();dt();jE();ue();KE();BE();JE();xt();Fi();E$={name:Br,primaryRootInstructionPath:fr,generateRules:FE,generateCommands:ME,generateAgents:$E,generateSkills:vE,generateMcp:GE,importFrom:UE},L$={rootInstructionPath:fr,skillDir:zt,managedOutputs:{dirs:[zt],files:[fr,Oo]},paths:{rulePath(t){return fr},commandPath(t){return `${zt}/${st(t)}/SKILL.md`},agentPath(t){return `${zt}/${V(t)}/SKILL.md`}}},b$={rootInstructionPath:void 0,skillDir:se,managedOutputs:{dirs:[se],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${zt}/`)?t.replace(`${zt}/`,`${se}/`):t},mirrorGlobalPath(t,e){return at(t,se,e)},paths:{rulePath(){return se},commandPath(t){return `${se}/${st(t)}/SKILL.md`},agentPath(t){return `${se}/${V(t)}/SKILL.md`}}},A$={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},x$={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Wm={id:Br,generators:E$,capabilities:A$,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:WE,lint:{hooks:HE,permissions:zE,ignore:VE},supportsConversion:{commands:true,agents:true},project:L$,globalSupport:{capabilities:x$,detectionPaths:[se],layout:b$},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gd,fr]},canonicalDir:iC,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Oo]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:hd,detectionPaths:[fr,gd,Oo]};});var tn,rg,Do,YE,Ji,en,Yi,Xi,XE,No,_r,Zi,ng,og,sg,ig,ag,cg,qi,Qi,Oc,Bm,Hm,zm,ZE,te=d(()=>{tn="windsurf",rg=".windsurfrules",Do=".windsurf/rules",YE=".windsurfignore",Ji=".codeiumignore",en="AGENTS.md",Yi=".windsurf/hooks.json",Xi=".windsurf/mcp_config.example.json",XE=".windsurf/mcp_config.json",No=".windsurf/workflows",_r=".windsurf/skills",Zi=".agentsmesh/rules",ng=".agentsmesh/commands",og=".agentsmesh/agents",sg=".agentsmesh/skills",ig=".agentsmesh/ignore",ag=".agentsmesh/hooks.yaml",cg=".agentsmesh/mcp.json",qi=".codeium/windsurf/memories/global_rules.md",Qi=".codeium/windsurf/skills",Oc=".codeium/windsurf/global_workflows",Bm=".codeium/windsurf/hooks.json",Hm=".codeium/windsurf/mcp_config.json",zm=".codeium/.codeiumignore",ZE=".agents/skills";});function T$(t){let e=basename(t,".md");return e==="_root"?"root":e}function D$(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 lg(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:en,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=T$(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 c=Object.keys(a).length>0?F(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Do}/${o}.md`,content:c});let l=D$(n.globs);l&&(l!==o&&e.push({path:`${Do}/${l}.md`,content:c}),e.push({path:`${l}/AGENTS.md`,content:n.body.trim()||""}));}return e}var qE=d(()=>{M();te();s(T$,"ruleSlug");s(D$,"directoryScopedRuleDir");s(lg,"generateRules");});function mg(t){return !t.ignore||t.ignore.length===0?[]:[{path:Ji,content:t.ignore.join(`
129
- `)}]}var QE=d(()=>{te();s(mg,"generateIgnore");});function pg(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?F(r,e.body.trim()||""):e.body.trim();return {path:`${No}/${e.name}.md`,content:n}})}var tL=d(()=>{M();te();s(pg,"generateCommands");});function ug(t){return t.agents.map(e=>({path:`${_r}/${V(e.name)}/SKILL.md`,content:oe(e)}))}var eL=d(()=>{dt();te();s(ug,"generateAgents");});function dg(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Xi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var rL=d(()=>{te();s(dg,"generateMcp");});function N$(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 F$(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Or(i))continue;let a=wt(i),c=Yt(i),l=i.type==="prompt"?c||a:a||c;l&&o.push({command:l,show_output:true});}o.length>0&&(e[N$(r)]=o);}return e}function fg(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=F$(t.hooks);return Object.keys(e).length===0?[]:[{path:Yi,content:JSON.stringify({hooks:e},null,2)}]}var nL=d(()=>{Je();te();s(N$,"windsurfEventName");s(F$,"toWindsurfHooks");s(fg,"generateHooks");});function gg(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?F(n,r.body.trim()||""):r.body.trim()||"";e.push({path:`${_r}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles)e.push({path:`${_r}/${r.name}/${i.relativePath}`,content:i.content});}return e}var oL=d(()=>{M();te();s(gg,"generateSkills");});var sL=d(()=>{qE();QE();tL();eL();rL();nL();oL();});var iL=d(()=>{sL();});function aL(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function cL(t,e,r){let n=join(t,No),i=(await N(n)).filter(c=>c.endsWith(".md")),a=join(t,ng);for(let c of i){let l=await y(c);if(!l)continue;let m=relative(n,c).replace(/\\/g,"/");await O(a);let p=join(a,m),u=r(l,c,p),{frontmatter:f,body:g}=w(u),h=await ot(p,{description:typeof f.description=="string"?f.description:"",hasDescription:Object.prototype.hasOwnProperty.call(f,"description"),allowedTools:(()=>{let R=aL(f.allowedTools);return R.length>0?R:aL(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:tn,fromPath:c,toPath:`${ng}/${m}`,feature:"commands"});}}var lL=d(()=>{A();M();et();te();s(aL,"toStringArray");s(cL,"importWorkflows");});async function mL(t,e,r,n=_r){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:sg,targetName:"windsurf",normalize:r,results:e};for(let[c,l]of i){let m=join(l,"SKILL.md"),p=await y(m);if(!p)continue;let u=w(p),f=Er(u.frontmatter,c);if(f){await Ee(join(t,sg,c));let g=join(t,og);await O(g);let h=join(g,`${f.name}.md`);await S(h,Oe(f,r(u.body,m,h))),e.push({fromTool:"windsurf",fromPath:m,toPath:`${og}/${f.name}.md`,feature:"agents"});continue}await Jr(c,l,a);}}var pL=d(()=>{A();M();dt();mi();Mi();te();s(mL,"importSkills");});async function dL(t,e){let r=join(t,Yi),n=await y(r);if(n)try{let o=JSON.parse(n);if(!o.hooks||typeof o.hooks!="object"||Array.isArray(o.hooks))return;let i=G$(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,ag);await O(dirname(a)),await S(a,stringify(i)),e.push({fromTool:tn,fromPath:r,toPath:ag,feature:"hooks"});}catch{}}function $$(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 G$(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=$$(r),i=[];for(let a of n){if(!a||typeof a!="object")continue;let c=a;if(typeof c.command=="string"&&c.command.trim()){i.push({matcher:".*",type:"command",command:c.command});continue}let l=typeof c.matcher=="string"&&c.matcher.trim()?c.matcher:".*",m=Array.isArray(c.hooks)?c.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let u=p,f=typeof u.command=="string"?u.command:typeof u.prompt=="string"?u.prompt:"";if(!f.trim())continue;let g={matcher:l,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 fL(t,e){let r=[Xi,XE];for(let n of r){let o=join(t,n),i=await y(o);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let c=join(t,cg);await O(dirname(c)),await S(c,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:tn,fromPath:o,toPath:cg,feature:"mcp"});return}catch{}}}var gL=d(()=>{A();te();s(dL,"importWindsurfHooks");s($$,"canonicalHookEventName");s(G$,"windsurfHooksToCanonical");s(fL,"importWindsurfMcp");});async function Jm(t,e){let r=e?.scope??"project",n=[],o=await z(tn,t),i=await z("codex-cli",t),a=join(t,Zi),c=join(t,rg),l=await y(c);if(l!==null){await O(a);let f=join(a,"_root.md"),g=o(l,c,f).trim(),h=await j(f,{root:true},g);await S(f,h),n.push({fromTool:"windsurf",fromPath:c,toPath:`${Zi}/_root.md`,feature:"rules"});}if(l===null){let f=join(t,en),g=await y(f);if(g!==null){await O(a);let h=join(a,"_root.md"),R=o(i(g,f,h),f,h).trim(),C=await j(h,{root:true},R);await S(h,C),n.push({fromTool:"windsurf",fromPath:f,toPath:`${Zi}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await mt({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(!Sl(h))return await Ee(join(a,`${R}.md`)),null;let C=join(a,`${R}.md`);return {destPath:C,toPath:`${Zi}/${R}.md`,feature:"rules",content:await j(C,{root:false,globs:[`${h}/**`]},g(C))}},"mapEntry")}));let m=join(t,Do);n.push(...await mt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({relativePath:f,normalizeTo:g})=>{if(f==="_root.md"&&l!==null)return null;let h=join(a,f),{frontmatter:R,body:C}=w(g(h)),_={...R};return typeof _.glob=="string"&&_.glob.trim()&&(_.globs=[_.glob],delete _.glob),{destPath:h,toPath:`${Zi}/${f}`,feature:"rules",content:await j(h,{..._,root:false},C)}},"mapEntry")}));let p=join(t,YE),u=await y(p);if((u===null||!u.trim())&&(p=join(t,Ji),u=await y(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,ig);await S(h,g.join(`
130
- `)),n.push({fromTool:"windsurf",fromPath:p,toPath:ig,feature:"ignore"});}}return await cL(t,n,o),await mL(t,n,o),await dL(t,n),await fL(t,n),n}var yg=d(()=>{It();A();M();et();tr();mi();te();lL();pL();gL();s(Jm,"importFromWindsurf");});function hL(t,e,r){let n=[],{rules:o}=t;o.length>0&&(o.some(c=>c.root)||n.push({level:"warning",file:relative(e,o[0].source),target:tn,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:tn,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),n}var yL=d(()=>{te();s(hL,"lintRules");});function _L(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>U(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function IL(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[U(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var CL=d(()=>{bt();s(_L,"lintCommands");s(IL,"lintMcp");});function B$(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 H$,z$,V$,J$,SL,RL=d(()=>{iL();Vo();te();ue();yg();yL();CL();xt();si();dt();s(B$,"directoryScopedRuleDir");H$={name:"windsurf",primaryRootInstructionPath:en,generateRules:lg,generateCommands:pg,generateAgents:ug,generateSkills:gg,generateMcp:dg,generateHooks:fg,generateIgnore:mg,importFrom:Jm},z$={rootInstructionPath:en,extraRuleOutputPaths(t){if(t.root)return [en];let e=B$(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:_r,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 `${Do}/${t}.md`},commandPath(t,e){return `${No}/${t}.md`},agentPath(t,e){return ke(e,"windsurf")?`.windsurf/skills/${V(t)}/SKILL.md`:null}}},V$={rootInstructionPath:qi,skillDir:Qi,managedOutputs:{dirs:[Qi,Oc,ZE],files:[qi,Bm,Hm,zm]},rewriteGeneratedPath(t){return t===en?qi:t.startsWith(`${Do}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${_r}/`)?t.replace(`${_r}/`,`${Qi}/`):t.startsWith(`${No}/`)?t.replace(`${No}/`,`${Oc}/`):t===Yi?Bm:t===Xi?Hm:t===Ji?zm:t},mirrorGlobalPath(t,e){return at(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return qi},commandPath(t,e){return `${Oc}/${t}.md`},agentPath(t,e){return ke(e,"windsurf")?`${Qi}/${V(t)}/SKILL.md`:null}}},J$={rules:"native",additionalRules:"partial",commands:Ze("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},SL={id:"windsurf",generators:H$,capabilities:{rules:"native",additionalRules:"native",commands:Ze("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:hL,lint:{commands:_L,mcp:IL},project:z$,globalSupport:{capabilities:J$,detectionPaths:[qi,Qi,Oc,Bm,Hm,zm],layout:V$},buildImportPaths:yd,detectionPaths:[".windsurfrules",".windsurf"]};});function kL(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=Et(n,r);return o?[{path:gr,content:o}]:[]}var OL=d(()=>{we();ws();s(kL,"generateRules");});async function EL(t,e,r){let n=await y(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 c={};for(let[l,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,c[l]=p;}Object.keys(c).length!==0&&(await Ht(t,wL,c),r.push({fromTool:"zed",fromPath:e,toPath:wL,feature:"mcp"}));}var wL,LL=d(()=>{A();fn();ws();wL=".agentsmesh/mcp.json";s(EL,"importZedMcp");});async function bL(t,e={}){let r=e.scope??"project",n=[],o=await z("zed",t,r);return n.push(...await Q(Ym,t,r,{normalize:o})),await EL(t,r==="global"?zr:Hr,n),n}var AL=d(()=>{It();Mt();LL();ws();_g();s(bL,"importFromZed");});function xL(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var PL=d(()=>{$t();ws();s(xL,"lintRules");});function TL(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function DL(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?[]:[U(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function NL(t){return t.ignore.length===0?[]:[U(".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 FL=d(()=>{bt();s(TL,"lintHooks");s(DL,"lintPermissions");s(NL,"lintIgnore");});function eG(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 X$,Z$,q$,Q$,tG,Ym,_g=d(()=>{OL();AL();PL();FL();xt();ws();X$={name:"zed",primaryRootInstructionPath:gr,generateRules:kL,importFrom:bL},Z$={rootInstructionPath:gr,managedOutputs:{dirs:[],files:[gr,Hr]},paths:{rulePath(t){return gr},commandPath(){return null},agentPath(){return null}}},q$={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[zr]},rewriteGeneratedPath(t){return t===Hr?zr:t},paths:{rulePath(){return zr},commandPath(){return null},agentPath(){return null}}},Q$={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},tG={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(eG,"mergeZedSettings");Ym={id:"zed",generators:X$,capabilities:Q$,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:xL,lint:{hooks:TL,permissions:DL,ignore:NL},project:Z$,globalSupport:{capabilities:tG,detectionPaths:[zr],layout:q$},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gr],global:[]},canonicalDir:lC,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:Hr,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===Hr||n===zr?eG(t,r):null},buildImportPaths:_d,detectionPaths:[gr,Hr]};});var dI={};Jp(dI,{BUILTIN_TARGETS:()=>Ft,TARGET_IDS:()=>it,getBuiltinTargetDefinition:()=>$e,getEffectiveTargetSupportLevel:()=>Xm,getTargetCapabilities:()=>Po,getTargetDetectionPaths:()=>Cg,getTargetLayout:()=>Tt,getTargetManagedOutputs:()=>Sg,getTargetPrimaryRootInstructionPath:()=>nG,getTargetSkillDir:()=>Ec,isBuiltinTargetId:()=>He,resolveTargetFeatureGenerator:()=>ta,rewriteGeneratedOutputPath:()=>Rg});function rG(){return Ig||(R_(Ft),Ig=new Map(Ft.map(t=>[t.id,t]))),Ig}function $e(t){return rG().get(t)}function Po(t,e="project"){let r=$e(t)??tt(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return C_(n)}function Cg(t,e="project"){let r=$e(t)??tt(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function Tt(t,e="project"){let r=$e(t)??tt(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function nG(t,e="project"){return Tt(t,e)?.rootInstructionPath}function Ec(t,e="project"){return Tt(t,e)?.skillDir}function Sg(t,e="project"){return Tt(t,e)?.managedOutputs}function Rg(t,e,r="project"){let n=Tt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function vL(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!oi(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!ke(r,t.id,true,n):false}function oG(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?oi(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?ke(r,t.id,true,n):false}function Xm(t,e,r,n="project"){let o=Po(t,n)?.[e]?.level??"none",i=$e(t)??tt(t);return o==="none"&&oG(i,e,r,n)?"embedded":o!=="embedded"?o:vL(i,e,r,n)?"none":o}function ta(t,e,r,n="project"){let o=$e(t)??tt(t);if(!o?.generators||vL(o,e,r,n))return;let i=sG[e];return i===null?void 0:i(o.generators)}var Ft,Ig,sG,ut=d(()=>{si();Vo();ye();Iu();ze();Pu();Cd();Rd();PS();yR();zd();Qd();gf();Ff();Mf();Gf();Hf();Jf();Xf();tg();eg();RL();_g();Ft=[Rl,Hl,zl,xS,hR,sm,um,Sm,xm,Pm,Dm,Mm,Gm,jm,Km,Wm,SL,Ym];s(rG,"builtinTargetsMap");s($e,"getBuiltinTargetDefinition");s(Po,"getTargetCapabilities");s(Cg,"getTargetDetectionPaths");s(Tt,"getTargetLayout");s(nG,"getTargetPrimaryRootInstructionPath");s(Ec,"getTargetSkillDir");s(Sg,"getTargetManagedOutputs");s(Rg,"rewriteGeneratedOutputPath");s(vL,"isFeatureSuppressedByConversion");s(oG,"isConversionUpgrading");s(Xm,"getEffectiveTargetSupportLevel");sG={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(ta,"resolveTargetFeatureGenerator");});function uG(t){return typeof t=="string"?t:t.level}function ML(t){return pG.includes(t)}function $L(t,e,r,n){for(let o of mG){let i=uG(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",c=ML(o.feature)&&typeof t.emitScopedSettings=="function";a||c||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${i}" but generators.${o.generator}`+(ML(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function Zm(t){return fG.parse(t)}var Wn,GL,iG,aG,jL,cG,lG,mG,pG,dG,fG,kg=d(()=>{Wn=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()})]),GL=z$1.object({rules:Wn,additionalRules:Wn,commands:Wn,agents:Wn,skills:Wn,mcp:Wn,hooks:Wn,ignore:Wn,permissions:Wn}),iG=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(),aG=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),jL=z$1.object({paths:aG}).passthrough(),cG=z$1.object({capabilities:GL,detectionPaths:z$1.array(z$1.string()),layout:jL,scopeExtras:z$1.function().optional()}).passthrough(),lG=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],mG=[{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"}],pG=["mcp","hooks","ignore","permissions"];s(uG,"capabilityLevel");s(ML,"canUseScopedSettings");s($L,"validateCapabilityImplementations");dG=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:iG,capabilities:GL,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:jL,globalSupport:cG.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),fG=dG.superRefine((t,e)=>{for(let r of lG)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});$L(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&$L(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(Zm,"validateDescriptor");});function gG(){return Og||(Og=new Map(Ft.map(t=>[t.id,t]))),Og}function qm(t){let e=Zm(t);wg.set(e.id,e);}function tt(t){return wg.get(t)??gG().get(t)}function Qm(){return [...wg.values()]}var wg,Og,ye=d(()=>{ut();kg();wg=new Map;s(gG,"builtinDescriptors");s(qm,"registerTargetDescriptor");s(tt,"getDescriptor");s(Qm,"getAllDescriptors");});async function UL(t,e,r="project"){let n=new Map,o=tt(t);return o&&await o.buildImportPaths(n,e,r),n}var KL=d(()=>{ye();s(UL,"buildImportReferenceMap");});function _G(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 IG(){let t=new Set([".agentsmesh/"]);for(let e of Ft)for(let r of _G(e))t.add(r);return Array.from(t)}function CG(){let t=new Set([...IG(),...Eg.rootRelativePrefixes]),e=new Set([...yG,...Eg.meshRootSegments]);return {protectedSchemes:[...hG,...Eg.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function tp(){return Lg||(Lg=CG()),Lg}var hG,yG,Eg,Lg,WL=d(()=>{ut();hG=[/\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],yG=new Set(["skills","rules","commands","agents","packs"]),Eg={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(_G,"topLevelDotfilePrefixes");s(IG,"buildDefaultRootRelativePrefixes");s(CG,"rebuild");s(tp,"getLinkFormatRegistry");});function Ir(t){let e=pt(t);return tp().rootRelativePrefixes.some(r=>e.startsWith(r))}function RG(t){let e=pt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Ye.test(e)||/^[a-zA-Z]:/.test(e)||Ir(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&tp().meshRootSegments.has(r)}function Lc(t,e,r){let n=Y(e),o=K(e,e),i=K(e,r),a=pt(t);if(Ye.test(t)){let c=K(e,t);return n===win32||c.startsWith(`${o}${n.sep}`)?[c]:[c]}if(n.isAbsolute(t)){let c=K(e,t);return c.startsWith(o)||existsSync(t)?[c]:[K(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let c=K(e,n.join(n.dirname(i),a)),l=h_(a,o);return l&&l!==c?[c,l]:[c]}if(Ir(a))return [K(e,n.join(o,a))];if(a.includes("/")){let c=K(e,n.join(o,".agentsmesh")),l=RG(a)?K(e,n.join(c,a)):null,m=K(e,n.join(o,a)),p=K(e,n.join(n.dirname(i),a));return l!==null?[l,m,p]:[m,p]}return kG.has(a)?[]:a.includes(".")?[K(e,n.join(n.dirname(i),a))]:[]}function bc(t,e){let r=[e];if(!g_(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 VL(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function ep(t){let e=[];for(let r of tp().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(OG))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(wG))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(EG))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var kG,OG,wG,EG,zL,ea,Fo=d(()=>{Wt();WL();s(Ir,"isRootRelativePathToken");s(RG,"isMeshRootRelativePathToken");kG=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),OG=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,wG=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,EG=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,zL=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,ea=/(?::(\d+)){1,2}$/;s(Lc,"resolveProjectPath");s(bc,"expandResolvedPaths");s(VL,"isGlobAdjacent");s(ep,"protectedRanges");});function LG(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 JL(t){return LG(t.tokenContext)}function bg(t,e){let r=Y(t),n=K(t,t),o=K(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function YL(t){let e=Y(t);return K(t,e.join(t,".agentsmesh"))}function Cr(t,e){let r=Y(t),n=YL(t),o=K(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function XL(t,e,r){let n=Y(t),o=YL(t),i=K(t,e);if(!Cr(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 Ag(t,e,r){let o=Y(t).relative(K(t,t),K(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let i=o.length>0?o:".";return r&&!i.endsWith("/")?`${i}/`:i}function ra(t,e,r){let n=Ag(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function xg(t,e,r,n,o){let i=Y(t),a=K(t,t),c=K(t,e),l=K(t,r);if(!bg(t,l))return ra(t,l,n)?.text??null;let m=K(t,i.dirname(c));if(!bg(t,m)&&m!==a)return ra(t,l,n)?.text??null;let p=i.relative(m,l).replace(/\\/g,"/");if(i.isAbsolute(p)||Ye.test(p))return Ag(t,l,n);let u=K(t,i.join(m,p));return bg(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):Ag(t,l,n)}var Pg=d(()=>{Wt();s(LG,"isReadingContext");s(JL,"isReadingContextOptions");s(bg,"isUnderProjectRoot");s(YL,"agentsMeshRoot");s(Cr,"isUnderAgentsMesh");s(XL,"toAgentsMeshRootRelative");s(Ag,"toProjectRootRelative");s(ra,"toProjectRootReference");s(xg,"formatLinkPathForDestinationLegacy");});function ZL(t,e,r,n,o={}){let i=o.scope??"project",a=K(t,r);if(JL(o)&&Cr(t,e)&&Cr(t,a)){let m=Y(t),p=K(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 xg(t,e,r,n,o);if(i==="global"&&!Cr(t,e))return ra(t,a,n)?.text??null;let c=(()=>{if(Cr(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&Cr(t,K(t,m))?K(t,m):null})();if(!c)return ra(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=XL(t,c,n);return m!==null?m:ra(t,c,n)?.text??null}return xg(t,e,r,n,o)}var qL=d(()=>{Fo();Wt();Pg();Pg();s(ZL,"formatLinkPathForDestination");});function QL(t,e,r,n){let o=Y(e),i=pt(t);if(!Ir(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let c=K(e,r),l=o.dirname(c);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=K(e,o.join(l,p));if(u!==c&&n(u))return u}return null}var tb=d(()=>{Wt();Fo();s(QL,"resolveByDestinationSuffixStrip");});function eb(t){let e=null,r=false,n=null,o=null,i=null;for(let l of Lc(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of bc(t.projectRoot,l)){let f=K(t.projectRoot,u),g=K(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 l=QL(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);l!==null&&(e=l,r=true);}!r&&o!==null&&(e=o,i!==null&&(n=i),r=true);let a=pt(t.destinationFile),c=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&pt(t.rawToken).startsWith(".agentsmesh/")&&c&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var rb=d(()=>{Wt();Fo();tb();s(eb,"resolveLinkTarget");});function nb(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function ob(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 sb(t){let e=pt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Ye.test(e)||Ir(e)?false:e.includes("/")}var ib=d(()=>{Wt();Fo();s(nb,"isTildeHomeRelativePathToken");s(ob,"isMarkdownLinkDestinationToken");s(sb,"isRelativePathToken");});function bG(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===`
126
+ ${f}`:u,h={};p&&(h.description=p),typeof c.name=="string"&&c.name.length>0&&(h.name=c.name);let R=await Lt(m,h,g),C=r(R,n,m);await S(m,C),e.push({feature:"agents",fromTool:qt,fromPath:n,toPath:`${ds}/${l}.md`});}}async function Mm(t,e={}){let r=e.scope??"project",n=[],o=await z(qt,t,r);return n.push(...await Q($m,t,r,{normalize:o})),await yt(t,ir,qt,n,o),r==="project"&&(await KM(t,n,o),await WM(t,n,o),await BM(t,n,o),await yt(t,ls,qt,n,o)),n}var Kf,Wf,Bf=d(()=>{It();_t();tr();Mt();A();et();M();Uf();fs();Hf();Kf=`${fo}/_root.md`,Wf="00-root.md";s(Pw,"pathExists");s(KM,"importLegacyRules");s(WM,"importLegacyWorkflows");s(BM,"importLegacyModes");s(Mm,"importFromKiloCode");});function Tw(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:qt}))}var Dw=d(()=>{$t();fs();s(Tw,"lintRules");});function Nw(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function Fw(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?[]:[U(".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 vw=d(()=>{bt();s(Nw,"lintHooks");s(Fw,"lintPermissions");});var HM,zM,VM,Mw,$m,Hf=d(()=>{Aw();fs();ue();Bf();Uf();Dw();vw();xt();HM={name:qt,primaryRootInstructionPath:jr,generateRules:kw,generateCommands:Ow,generateAgents:ww,generateSkills:bw,generateMcp:Ew,generateIgnore:Lw,importFrom:Mm},zM={rootInstructionPath:jr,skillDir:ir,managedOutputs:{dirs:[En,Ln,bn,ir],files:[jr,mo,wi]},paths:{rulePath(t,e){return `${En}/${t}.md`},commandPath(t,e){return `${Ln}/${t}.md`},agentPath(t,e){return `${bn}/${t}.md`}}},VM={rootInstructionPath:po,skillDir:uo,managedOutputs:{dirs:[ms,ps,us,uo,BI],files:[po,bi,jl]},rewriteGeneratedPath(t){return t===jr?po:t},mirrorGlobalPath(t,e){return at(t,uo,e)},paths:{rulePath(t,e){return `${ms}/${t}.md`},commandPath(t,e){return `${ps}/${t}.md`},agentPath(t,e){return `${us}/${t}.md`}}},Mw={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},$m={id:qt,generators:HM,capabilities:Mw,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:Tw,lint:{hooks:Nw,permissions:Fw},project:zM,globalSupport:{capabilities:Mw,detectionPaths:[po,ms,ps,us,uo,bi,jl],layout:VM},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[jr],global:[po]},canonicalDir:fo,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[En],global:[ms]},canonicalDir:fo,extensions:[".md"],map:Fm}],commands:{feature:"commands",mode:"directory",source:{project:[Ln],global:[ps]},canonicalDir:Ai,extensions:[".md"],map:vm},agents:{feature:"agents",mode:"directory",source:{project:[bn],global:[us]},canonicalDir:ds,extensions:[".md"],map:xw},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[mo,ic],global:[bi]},canonicalDir:".agentsmesh",canonicalFilename:HI},ignore:{feature:"ignore",mode:"flatFile",source:{project:[wi],global:[jl]},canonicalDir:".agentsmesh",canonicalFilename:zI}},buildImportPaths:ad,detectionPaths:[En,Ln,bn,ir,mo,cs,Ei,ls,ic,Gl,wi,"kilo.jsonc","kilo.json"]};});function $w(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function XM(t){return t.type==="prompt"?t.prompt:t.command}function ZM(t,e){let r=Gw[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function jw(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in Gw)||!Array.isArray(n))continue;let i=1;for(let a of n){let c=XM(a);if(!c)continue;let l={name:`${$w(r)} ${i}`,version:"1",when:ZM(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:c}:{type:"shellCommand",command:c}};e.push({name:`${$w(r)}-${i}.kiro.hook`,content:JSON.stringify(l,null,2)}),i+=1;}}return e}function qM(t){let e=YM.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 Uw(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:qM(r)}function Kw(t){return stringify(t).trimEnd()}var Gw,YM,zf=d(()=>{Gw={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},YM=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s($w,"toKebab");s(XM,"hookText");s(ZM,"toWhen");s(jw,"generateKiroHooks");s(qM,"toCanonicalEntry");s(Uw,"parseKiroHookFile");s(Kw,"serializeCanonicalHooks");});function t$(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 Ww(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:ar,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(fe))continue;let o=basename(n.source,".md");e.push({path:`${cr}/${o}.md`,content:F(t$(n),n.body.trim()||"")});}return e}function Bw(t){return t.commands.map(e=>({path:`${Qt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function Hw(t){return St(t,Qt)}function zw(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:xi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Vw(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:jw(t.hooks).map(e=>({path:`${go}/${e.name}`,content:e.content}))}function Jw(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=F(r,e.body.trim()||"");return {path:`${lr}/${e.name}.md`,content:n}})}function Yw(t){return t.ignore.length===0?[]:[{path:Pi,content:t.ignore.join(`
127
+ `)}]}var Xw=d(()=>{_t();ne();M();zf();Ti();s(t$,"steeringFrontmatter");s(Ww,"generateRules");s(Bw,"generateCommands");s(Hw,"generateSkills");s(zw,"generateMcp");s(Vw,"generateHooks");s(Jw,"generateAgents");s(Yw,"generateIgnore");});function r$(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:gn(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function n$(t,e,r,n){let o=n==="global"?[mr,ar]:[ar,mr];for(let i of o){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,cd),{frontmatter:m,body:p}=w(r(c,a,l));await S(l,await j(l,{...m,root:true},p)),e.push({fromTool:fe,fromPath:a,toPath:cd,feature:"rules"});return}}async function o$(t,e,r){let n=join(t,ld);e.push(...await mt({srcDir:join(t,cr),destDir:n,extensions:[".md"],fromTool:fe,normalize:r,mapEntry:s(async({relativePath:o,normalizeTo:i})=>{if(basename(o)==="AGENTS.md")return null;let a=join(n,o),{frontmatter:c,body:l}=w(i(a));return {destPath:a,toPath:`${ld}/${o}`,feature:"rules",content:await j(a,r$(c),l)}},"mapEntry")}));}async function s$(t,e){let r={};for(let o of await N(join(t,go))){if(!o.endsWith(".kiro.hook"))continue;let i=Uw(await y(o)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let n=join(t,md);await O(join(t,".agentsmesh")),await S(n,Kw(r)),e.push({fromTool:fe,fromPath:join(t,go),toPath:md,feature:"hooks"});}async function Gm(t,e={}){let r=e.scope??"project",n=[],o=await z(fe,t,r);return await n$(t,n,o,r),await o$(t,n,o),n.push(...await Q(jm,t,r,{normalize:o})),await yt(t,Qt,fe,n,o),r==="project"&&await s$(t,n),n}var Vf=d(()=>{It();_t();tr();Mt();et();Qe();A();M();zf();Ti();Jf();s(r$,"canonicalRuleMeta");s(n$,"importRoot");s(o$,"importNonRootRules");s(s$,"importHooks");s(Gm,"importFromKiro");});function Zw(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:fe}))}var qw=d(()=>{$t();Ti();s(Zw,"lintRules");});function Qw(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=>di(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var tE=d(()=>{bt();s(Qw,"lintHooks");});var i$,a$,c$,l$,jm,Jf=d(()=>{ne();Xw();ue();Vf();qw();tE();xt();Ti();i$={name:fe,primaryRootInstructionPath:ar,generateRules:Ww,generateCommands:Bw,generateAgents:Jw,generateSkills:Hw,generateMcp:zw,generateHooks:Vw,generateIgnore:Yw,importFrom:Gm},a$={rootInstructionPath:ar,skillDir:Qt,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${cr}/${t}.md`},commandPath(t){return `${Qt}/${st(t)}/SKILL.md`},agentPath(t,e){return `${lr}/${t}.md`}}},c$={rootInstructionPath:mr,skillDir:ho,managedOutputs:{dirs:[gs,ho,hs,YI],files:[mr,cc,lc]},rewriteGeneratedPath(t){return t===ar?mr:t.startsWith(`${cr}/`)?t.replace(`${cr}/`,`${gs}/`):t.startsWith(`${Qt}/`)?t.replace(`${Qt}/`,`${ho}/`):t.startsWith(`${lr}/`)?t.replace(`${lr}/`,`${hs}/`):t===xi?cc:t===Pi?lc:t.startsWith(`${go}/`)?null:t},mirrorGlobalPath(t,e){return at(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${gs}/${t}.md`},commandPath(t){return `${Qt}/${st(t)}/SKILL.md`},agentPath(t,e){return `${hs}/${t}.md`}}},l$={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},jm={id:fe,generators:i$,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:Zw,lint:{hooks:Qw},project:a$,globalSupport:{capabilities:l$,detectionPaths:[gs,mr,ho,hs,cc,lc],layout:c$},importer:{agents:{feature:"agents",mode:"directory",source:{project:[lr],global:[lr]},canonicalDir:XI,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[xi],global:[cc]},canonicalDir:".agentsmesh",canonicalFilename:ZI},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Pi],global:[lc]},canonicalDir:".agentsmesh",canonicalFilename:qI}},buildImportPaths:pd,detectionPaths:[cr,Qt,lr,go,xi,Pi]};});function rE(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Ur,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(pr))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?F(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${An}/${o}.md`,content:a});}return e}function nE(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${xn}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function oE(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:`${Pn}/${r}.md`,content:F(n,e.body.trim()||"")}})}function m$(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 sE(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]=m$(n);return [{path:Kr,content:JSON.stringify({mcp:e},null,2)}]}function iE(t){return St(t,ur)}var aE=d(()=>{_t();M();Cs();s(rE,"generateRules");s(nE,"generateCommands");s(oE,"generateAgents");s(m$,"toOpenCodeMcpServer");s(sE,"generateMcp");s(iE,"generateSkills");});function Yf(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 u$(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:Yf(a.headers),env:Yf(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let c=a.command,l=c[0];if(l===void 0)continue;let m=c.slice(1);n[o]={type:"stdio",command:l,args:m,env:Yf(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function d$(t,e,r){let o=join(t,e==="global"?Io:Kr),i=await y(o);if(i===null)return;let a=u$(i);Object.keys(a).length!==0&&(await Ht(t,ud,a),r.push({feature:"mcp",fromTool:pr,fromPath:o,toPath:ud}));}async function cE(t,e={}){let r=e.scope??"project",n=[],o=await z(pr,t,r);return n.push(...await Q(Um,t,r,{normalize:o})),await yt(t,ur,pr,n,o),await d$(t,r,n),n}var lE=d(()=>{It();_t();Mt();fn();A();Cs();Xf();s(Yf,"toStringRecord");s(u$,"parseOpenCodeMcp");s(d$,"importMcp");s(cE,"importFromOpenCode");});var mE,pE,uE,dE=d(()=>{M();et();Cs();mE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${mc}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"opencodeNonRootRuleMapper"),pE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Kl}/${t}`,content:await ot(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),uE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Wl}/${t}`,content:await Lt(n,o,i)}},"opencodeAgentMapper");});function fE(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:pr}))}var gE=d(()=>{$t();Cs();s(fE,"lintRules");});function hE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function yE(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?[]:[U(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function _E(t){return t.ignore.length===0?[]:[U(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var IE=d(()=>{bt();s(hE,"lintHooks");s(yE,"lintPermissions");s(_E,"lintIgnore");});var f$,g$,h$,CE,Um,Xf=d(()=>{aE();Cs();ue();lE();dE();gE();IE();xt();f$={name:pr,primaryRootInstructionPath:Ur,generateRules:rE,generateCommands:nE,generateAgents:oE,generateSkills:iE,generateMcp:sE,importFrom:cE},g$={rootInstructionPath:Ur,skillDir:ur,managedOutputs:{dirs:[An,xn,Pn,ur],files:[Ur,Kr]},paths:{rulePath(t){return `${An}/${t}.md`},commandPath(t){return `${xn}/${t}.md`},agentPath(t){return `${Pn}/${t}.md`}}},h$={rootInstructionPath:yo,skillDir:_o,managedOutputs:{dirs:[ys,_s,Is,_o,tC],files:[yo,Io]},rewriteGeneratedPath(t){return t===Ur?yo:t===Kr?Io:t},mirrorGlobalPath(t,e){return at(t,_o,e)},paths:{rulePath(t){return `${ys}/${t}.md`},commandPath(t){return `${_s}/${t}.md`},agentPath(t){return `${Is}/${t}.md`}}},CE={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Um={id:pr,generators:f$,capabilities:CE,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:fE,lint:{hooks:hE,permissions:yE,ignore:_E},project:g$,globalSupport:{capabilities:CE,detectionPaths:[yo,ys,_s,Is,_o,Io],layout:h$},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Ur],global:[yo]},canonicalDir:mc,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[An],global:[ys]},canonicalDir:mc,extensions:[".md"],map:mE}],commands:{feature:"commands",mode:"directory",source:{project:[xn],global:[_s]},canonicalDir:Kl,extensions:[".md"],map:pE},agents:{feature:"agents",mode:"directory",source:{project:[Pn],global:[Is]},canonicalDir:Wl,extensions:[".md"],map:uE}},buildImportPaths:dd,detectionPaths:[An,xn,Pn,ur,Kr,"opencode.jsonc"]};});function RE(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:dr,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Co))continue;let o=basename(n.source,".md");e.push({path:`${Tn}/${o}.md`,content:n.body.trim()||""});}return e}function kE(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Dn}/${e.name}.md`,content:F(r,e.body.trim()||"")}})}function OE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:uc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function wE(t){return t.ignore.length===0?[]:[{path:dc,content:t.ignore.join(`
128
+ `)}]}function EE(t){return St(t,Wr)}function LE(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:Ni,content:stringify({customModes:e})}]}var bE=d(()=>{_t();M();Os();s(RE,"generateRules");s(kE,"generateCommands");s(OE,"generateMcp");s(wE,"generateIgnore");s(EE,"generateSkills");s(LE,"generateAgents");});var Km,xE,qf=d(()=>{M();et();Os();Km=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${ks}/${t}`,content:await j(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"rooNonRootRuleMapper"),xE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=w(e(n));return {destPath:n,toPath:`${Hl}/${t}`,content:await ot(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function I$(t,e,r){let n=join(t,Ss),o;try{o=await readdir(n,{withFileTypes:!0});}catch{return}let i=o.filter(c=>c.isDirectory()&&c.name.startsWith("rules-")).map(c=>c.name),a=join(t,ks);for(let c of i)e.push(...await mt({srcDir:join(n,c),destDir:a,extensions:[".md"],fromTool:Co,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:u})=>{let f=await Km({absolutePath:l,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function PE(t,e={}){let r=e.scope??"project",n=[],o=await z(Co,t,r);return n.push(...await Q(Wm,t,r,{normalize:o})),await I$(t,n,o),await yt(t,Wr,Co,n,o),n}var TE=d(()=>{It();_t();tr();Mt();qf();Os();tg();s(I$,"importPerModeRules");s(PE,"importFromRooCode");});function DE(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Co}))}var NE=d(()=>{$t();Os();s(DE,"lintRules");});function w$(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var k$,O$,E$,L$,b$,Wm,tg=d(()=>{A();bE();Os();ue();TE();qf();NE();xt();k$={name:"roo-code",primaryRootInstructionPath:dr,generateRules:RE,generateCommands:kE,generateSkills:EE,generateMcp:OE,generateIgnore:wE,generateAgents:LE,importFrom:PE},O$={rootInstructionPath:dr,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Ni]},paths:{rulePath(t,e){return `${Tn}/${t}.md`},commandPath(t,e){return `${Dn}/${t}.md`},agentPath(t,e){return null}}};s(w$,"computeStatus");E$=s(async(t,e,r,n)=>{if(r!=="global")return [];if(!n.has("agents")||t.agents.length===0)return [];let o=t.agents.map(c=>{let m={slug:basename(c.source,".md"),name:c.name};return c.description&&(m.description=c.description),c.body.trim()&&(m.roleDefinition=c.body.trim()),m}),i=stringify({customModes:o}),a=await y(join(e,fc));return [{target:"roo-code",path:fc,content:i,currentContent:a??void 0,status:w$(a,i)}]},"generateRooGlobalExtras"),L$={rootInstructionPath:ko,skillDir:Nn,managedOutputs:{dirs:[So,Ro,Nn,rC],files:[ko,Rs,gc,fc]},rewriteGeneratedPath(t){return t===dr?ko:t===Ni?null:t.startsWith(`${Tn}/`)?t.replace(`${Tn}/`,`${So}/`):t.startsWith(`${Dn}/`)?t.replace(`${Dn}/`,`${Ro}/`):t.startsWith(`${Wr}/`)?t.replace(`${Wr}/`,`${Nn}/`):t===uc?Rs:t===dc?gc:t},mirrorGlobalPath(t,e){return at(t,Nn,e)},paths:{rulePath(t,e){return `${So}/${t}.md`},commandPath(t,e){return `${Ro}/${t}.md`},agentPath(t,e){return null}}},b$={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Wm={id:"roo-code",generators:k$,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:DE,project:O$,globalSupport:{capabilities:b$,detectionPaths:[So,Ro,Nn,Rs,gc,ko,fc],layout:L$,scopeExtras:E$},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[dr,pc],global:[ko,dr,pc]},canonicalDir:ks,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:[Tn],global:[So]},canonicalDir:ks,extensions:[".md"],map:Km}],commands:{feature:"commands",mode:"directory",source:{project:[Dn],global:[Ro]},canonicalDir:Hl,extensions:[".md"],map:xE},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[uc],global:[Rs]},canonicalDir:".agentsmesh",canonicalFilename:nC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[dc],global:[gc]},canonicalDir:".agentsmesh",canonicalFilename:oC}},buildImportPaths:fd,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Ni]};});function FE(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Br)),n=e?.body.trim()??"",o=Et(n,r);return o?[{path:fr,content:o}]:[]}function vE(t){return St(t,zt)}function ME(t){return t.commands.map(e=>({path:`${zt}/${st(e.name)}/SKILL.md`,content:wr(e)}))}function $E(t){return t.agents.map(e=>({path:`${zt}/${V(e.name)}/SKILL.md`,content:oe(e)}))}function GE(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Oo,content:e}]}var jE=d(()=>{_t();we();dt();ne();Fi();s(FE,"generateRules");s(vE,"generateSkills");s(ME,"generateCommands");s($E,"generateAgents");s(GE,"generateMcp");});async function UE(t,e={}){let r=e.scope??"project",n=[],o=await z(Br,t,r);return n.push(...await Q(Bm,t,r,{normalize:o})),await yt(t,r==="global"?se:zt,Br,n,o),n}var KE=d(()=>{It();_t();Mt();Fi();eg();s(UE,"importFromWarp");});function WE(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Br}))}var BE=d(()=>{$t();Fi();s(WE,"lintRules");});function HE(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function zE(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?[]:[U(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function VE(t){return t.ignore.length===0?[]:[U(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var JE=d(()=>{bt();s(HE,"lintHooks");s(zE,"lintPermissions");s(VE,"lintIgnore");});var A$,x$,P$,T$,D$,Bm,eg=d(()=>{ne();dt();jE();ue();KE();BE();JE();xt();Fi();A$={name:Br,primaryRootInstructionPath:fr,generateRules:FE,generateCommands:ME,generateAgents:$E,generateSkills:vE,generateMcp:GE,importFrom:UE},x$={rootInstructionPath:fr,skillDir:zt,managedOutputs:{dirs:[zt],files:[fr,Oo]},paths:{rulePath(t){return fr},commandPath(t){return `${zt}/${st(t)}/SKILL.md`},agentPath(t){return `${zt}/${V(t)}/SKILL.md`}}},P$={rootInstructionPath:void 0,skillDir:se,managedOutputs:{dirs:[se],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${zt}/`)?t.replace(`${zt}/`,`${se}/`):t},mirrorGlobalPath(t,e){return at(t,se,e)},paths:{rulePath(){return se},commandPath(t){return `${se}/${st(t)}/SKILL.md`},agentPath(t){return `${se}/${V(t)}/SKILL.md`}}},T$={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},D$={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Bm={id:Br,generators:A$,capabilities:T$,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:WE,lint:{hooks:HE,permissions:zE,ignore:VE},supportsConversion:{commands:true,agents:true},project:x$,globalSupport:{capabilities:D$,detectionPaths:[se],layout:P$},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gd,fr]},canonicalDir:iC,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Oo]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:hd,detectionPaths:[fr,gd,Oo]};});var tn,rg,Do,YE,Ji,en,Yi,Xi,XE,No,_r,Zi,ng,og,sg,ig,ag,cg,qi,Qi,wc,Hm,zm,Vm,ZE,te=d(()=>{tn="windsurf",rg=".windsurfrules",Do=".windsurf/rules",YE=".windsurfignore",Ji=".codeiumignore",en="AGENTS.md",Yi=".windsurf/hooks.json",Xi=".windsurf/mcp_config.example.json",XE=".windsurf/mcp_config.json",No=".windsurf/workflows",_r=".windsurf/skills",Zi=".agentsmesh/rules",ng=".agentsmesh/commands",og=".agentsmesh/agents",sg=".agentsmesh/skills",ig=".agentsmesh/ignore",ag=".agentsmesh/hooks.yaml",cg=".agentsmesh/mcp.json",qi=".codeium/windsurf/memories/global_rules.md",Qi=".codeium/windsurf/skills",wc=".codeium/windsurf/global_workflows",Hm=".codeium/windsurf/hooks.json",zm=".codeium/windsurf/mcp_config.json",Vm=".codeium/.codeiumignore",ZE=".agents/skills";});function F$(t){let e=basename(t,".md");return e==="_root"?"root":e}function v$(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 lg(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:en,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=F$(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 c=Object.keys(a).length>0?F(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Do}/${o}.md`,content:c});let l=v$(n.globs);l&&(l!==o&&e.push({path:`${Do}/${l}.md`,content:c}),e.push({path:`${l}/AGENTS.md`,content:n.body.trim()||""}));}return e}var qE=d(()=>{M();te();s(F$,"ruleSlug");s(v$,"directoryScopedRuleDir");s(lg,"generateRules");});function mg(t){return !t.ignore||t.ignore.length===0?[]:[{path:Ji,content:t.ignore.join(`
129
+ `)}]}var QE=d(()=>{te();s(mg,"generateIgnore");});function pg(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?F(r,e.body.trim()||""):e.body.trim();return {path:`${No}/${e.name}.md`,content:n}})}var tL=d(()=>{M();te();s(pg,"generateCommands");});function ug(t){return t.agents.map(e=>({path:`${_r}/${V(e.name)}/SKILL.md`,content:oe(e)}))}var eL=d(()=>{dt();te();s(ug,"generateAgents");});function dg(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Xi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var rL=d(()=>{te();s(dg,"generateMcp");});function M$(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 $$(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!Or(i))continue;let a=wt(i),c=Yt(i),l=i.type==="prompt"?c||a:a||c;l&&o.push({command:l,show_output:true});}o.length>0&&(e[M$(r)]=o);}return e}function fg(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=$$(t.hooks);return Object.keys(e).length===0?[]:[{path:Yi,content:JSON.stringify({hooks:e},null,2)}]}var nL=d(()=>{Je();te();s(M$,"windsurfEventName");s($$,"toWindsurfHooks");s(fg,"generateHooks");});function gg(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?F(n,r.body.trim()||""):r.body.trim()||"";e.push({path:`${_r}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles)e.push({path:`${_r}/${r.name}/${i.relativePath}`,content:i.content});}return e}var oL=d(()=>{M();te();s(gg,"generateSkills");});var sL=d(()=>{qE();QE();tL();eL();rL();nL();oL();});var iL=d(()=>{sL();});function aL(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function cL(t,e,r){let n=join(t,No),i=(await N(n)).filter(c=>c.endsWith(".md")),a=join(t,ng);for(let c of i){let l=await y(c);if(!l)continue;let m=relative(n,c).replace(/\\/g,"/");await O(a);let p=join(a,m),u=r(l,c,p),{frontmatter:f,body:g}=w(u),h=await ot(p,{description:typeof f.description=="string"?f.description:"",hasDescription:Object.prototype.hasOwnProperty.call(f,"description"),allowedTools:(()=>{let R=aL(f.allowedTools);return R.length>0?R:aL(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:tn,fromPath:c,toPath:`${ng}/${m}`,feature:"commands"});}}var lL=d(()=>{A();M();et();te();s(aL,"toStringArray");s(cL,"importWorkflows");});async function mL(t,e,r,n=_r){let o=join(t,n),i=await wo(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:sg,targetName:"windsurf",normalize:r,results:e};for(let[c,l]of i){let m=join(l,"SKILL.md"),p=await y(m);if(!p)continue;let u=w(p),f=Er(u.frontmatter,c);if(f){await Ee(join(t,sg,c));let g=join(t,og);await O(g);let h=join(g,`${f.name}.md`);await S(h,Oe(f,r(u.body,m,h))),e.push({fromTool:"windsurf",fromPath:m,toPath:`${og}/${f.name}.md`,feature:"agents"});continue}await Jr(c,l,a);}}var pL=d(()=>{A();M();dt();mi();Mi();te();s(mL,"importSkills");});async function dL(t,e){let r=join(t,Yi),n=await y(r);if(n)try{let o=JSON.parse(n);if(!o.hooks||typeof o.hooks!="object"||Array.isArray(o.hooks))return;let i=K$(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,ag);await O(dirname(a)),await S(a,stringify(i)),e.push({fromTool:tn,fromPath:r,toPath:ag,feature:"hooks"});}catch{}}function U$(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 K$(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=U$(r),i=[];for(let a of n){if(!a||typeof a!="object")continue;let c=a;if(typeof c.command=="string"&&c.command.trim()){i.push({matcher:".*",type:"command",command:c.command});continue}let l=typeof c.matcher=="string"&&c.matcher.trim()?c.matcher:".*",m=Array.isArray(c.hooks)?c.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let u=p,f=typeof u.command=="string"?u.command:typeof u.prompt=="string"?u.prompt:"";if(!f.trim())continue;let g={matcher:l,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 fL(t,e){let r=[Xi,XE];for(let n of r){let o=join(t,n),i=await y(o);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let c=join(t,cg);await O(dirname(c)),await S(c,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:tn,fromPath:o,toPath:cg,feature:"mcp"});return}catch{}}}var gL=d(()=>{A();te();s(dL,"importWindsurfHooks");s(U$,"canonicalHookEventName");s(K$,"windsurfHooksToCanonical");s(fL,"importWindsurfMcp");});async function Ym(t,e){let r=e?.scope??"project",n=[],o=await z(tn,t),i=await z("codex-cli",t),a=join(t,Zi),c=join(t,rg),l=await y(c);if(l!==null){await O(a);let f=join(a,"_root.md"),g=o(l,c,f).trim(),h=await j(f,{root:true},g);await S(f,h),n.push({fromTool:"windsurf",fromPath:c,toPath:`${Zi}/_root.md`,feature:"rules"});}if(l===null){let f=join(t,en),g=await y(f);if(g!==null){await O(a);let h=join(a,"_root.md"),R=o(i(g,f,h),f,h).trim(),C=await j(h,{root:true},R);await S(h,C),n.push({fromTool:"windsurf",fromPath:f,toPath:`${Zi}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await mt({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(!Rl(h))return await Ee(join(a,`${R}.md`)),null;let C=join(a,`${R}.md`);return {destPath:C,toPath:`${Zi}/${R}.md`,feature:"rules",content:await j(C,{root:false,globs:[`${h}/**`]},g(C))}},"mapEntry")}));let m=join(t,Do);n.push(...await mt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({relativePath:f,normalizeTo:g})=>{if(f==="_root.md"&&l!==null)return null;let h=join(a,f),{frontmatter:R,body:C}=w(g(h)),_={...R};return typeof _.glob=="string"&&_.glob.trim()&&(_.globs=[_.glob],delete _.glob),{destPath:h,toPath:`${Zi}/${f}`,feature:"rules",content:await j(h,{..._,root:false},C)}},"mapEntry")}));let p=join(t,YE),u=await y(p);if((u===null||!u.trim())&&(p=join(t,Ji),u=await y(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,ig);await S(h,g.join(`
130
+ `)),n.push({fromTool:"windsurf",fromPath:p,toPath:ig,feature:"ignore"});}}return await cL(t,n,o),await mL(t,n,o),await dL(t,n),await fL(t,n),n}var yg=d(()=>{It();A();M();et();tr();mi();te();lL();pL();gL();s(Ym,"importFromWindsurf");});function hL(t,e,r){let n=[],{rules:o}=t;o.length>0&&(o.some(c=>c.root)||n.push({level:"warning",file:relative(e,o[0].source),target:tn,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:tn,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),n}var yL=d(()=>{te();s(hL,"lintRules");});function _L(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>U(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function IL(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[U(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var CL=d(()=>{bt();s(_L,"lintCommands");s(IL,"lintMcp");});function V$(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 J$,Y$,X$,Z$,SL,RL=d(()=>{iL();Vo();te();ue();yg();yL();CL();xt();si();dt();s(V$,"directoryScopedRuleDir");J$={name:"windsurf",primaryRootInstructionPath:en,generateRules:lg,generateCommands:pg,generateAgents:ug,generateSkills:gg,generateMcp:dg,generateHooks:fg,generateIgnore:mg,importFrom:Ym},Y$={rootInstructionPath:en,extraRuleOutputPaths(t){if(t.root)return [en];let e=V$(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:_r,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 `${Do}/${t}.md`},commandPath(t,e){return `${No}/${t}.md`},agentPath(t,e){return ke(e,"windsurf")?`.windsurf/skills/${V(t)}/SKILL.md`:null}}},X$={rootInstructionPath:qi,skillDir:Qi,managedOutputs:{dirs:[Qi,wc,ZE],files:[qi,Hm,zm,Vm]},rewriteGeneratedPath(t){return t===en?qi:t.startsWith(`${Do}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${_r}/`)?t.replace(`${_r}/`,`${Qi}/`):t.startsWith(`${No}/`)?t.replace(`${No}/`,`${wc}/`):t===Yi?Hm:t===Xi?zm:t===Ji?Vm:t},mirrorGlobalPath(t,e){return at(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return qi},commandPath(t,e){return `${wc}/${t}.md`},agentPath(t,e){return ke(e,"windsurf")?`${Qi}/${V(t)}/SKILL.md`:null}}},Z$={rules:"native",additionalRules:"partial",commands:Ze("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},SL={id:"windsurf",generators:J$,capabilities:{rules:"native",additionalRules:"native",commands:Ze("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:hL,lint:{commands:_L,mcp:IL},project:Y$,globalSupport:{capabilities:Z$,detectionPaths:[qi,Qi,wc,Hm,zm,Vm],layout:X$},buildImportPaths:yd,detectionPaths:[".windsurfrules",".windsurf"]};});function kL(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=Et(n,r);return o?[{path:gr,content:o}]:[]}var OL=d(()=>{we();ws();s(kL,"generateRules");});async function EL(t,e,r){let n=await y(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 c={};for(let[l,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,c[l]=p;}Object.keys(c).length!==0&&(await Ht(t,wL,c),r.push({fromTool:"zed",fromPath:e,toPath:wL,feature:"mcp"}));}var wL,LL=d(()=>{A();fn();ws();wL=".agentsmesh/mcp.json";s(EL,"importZedMcp");});async function bL(t,e={}){let r=e.scope??"project",n=[],o=await z("zed",t,r);return n.push(...await Q(Xm,t,r,{normalize:o})),await EL(t,r==="global"?zr:Hr,n),n}var AL=d(()=>{It();Mt();LL();ws();_g();s(bL,"importFromZed");});function xL(t,e,r,n){return q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var PL=d(()=>{$t();ws();s(xL,"lintRules");});function TL(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function DL(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?[]:[U(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function NL(t){return t.ignore.length===0?[]:[U(".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 FL=d(()=>{bt();s(TL,"lintHooks");s(DL,"lintPermissions");s(NL,"lintIgnore");});function oG(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 Q$,tG,eG,rG,nG,Xm,_g=d(()=>{OL();AL();PL();FL();xt();ws();Q$={name:"zed",primaryRootInstructionPath:gr,generateRules:kL,importFrom:bL},tG={rootInstructionPath:gr,managedOutputs:{dirs:[],files:[gr,Hr]},paths:{rulePath(t){return gr},commandPath(){return null},agentPath(){return null}}},eG={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[zr]},rewriteGeneratedPath(t){return t===Hr?zr:t},paths:{rulePath(){return zr},commandPath(){return null},agentPath(){return null}}},rG={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},nG={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(oG,"mergeZedSettings");Xm={id:"zed",generators:Q$,capabilities:rG,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:xL,lint:{hooks:TL,permissions:DL,ignore:NL},project:tG,globalSupport:{capabilities:nG,detectionPaths:[zr],layout:eG},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[gr],global:[]},canonicalDir:lC,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:Hr,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===Hr||n===zr?oG(t,r):null},buildImportPaths:_d,detectionPaths:[gr,Hr]};});var dI={};Yp(dI,{BUILTIN_TARGETS:()=>Ft,TARGET_IDS:()=>it,getBuiltinTargetDefinition:()=>$e,getEffectiveTargetSupportLevel:()=>Zm,getTargetCapabilities:()=>Po,getTargetDetectionPaths:()=>Cg,getTargetLayout:()=>Tt,getTargetManagedOutputs:()=>Sg,getTargetPrimaryRootInstructionPath:()=>iG,getTargetSkillDir:()=>Lc,isBuiltinTargetId:()=>He,resolveTargetFeatureGenerator:()=>ta,rewriteGeneratedOutputPath:()=>Rg});function sG(){return Ig||(R_(Ft),Ig=new Map(Ft.map(t=>[t.id,t]))),Ig}function $e(t){return sG().get(t)}function Po(t,e="project"){let r=$e(t)??tt(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return C_(n)}function Cg(t,e="project"){let r=$e(t)??tt(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function Tt(t,e="project"){let r=$e(t)??tt(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function iG(t,e="project"){return Tt(t,e)?.rootInstructionPath}function Lc(t,e="project"){return Tt(t,e)?.skillDir}function Sg(t,e="project"){return Tt(t,e)?.managedOutputs}function Rg(t,e,r="project"){let n=Tt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function vL(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!oi(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!ke(r,t.id,true,n):false}function aG(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?oi(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?ke(r,t.id,true,n):false}function Zm(t,e,r,n="project"){let o=Po(t,n)?.[e]?.level??"none",i=$e(t)??tt(t);return o==="none"&&aG(i,e,r,n)?"embedded":o!=="embedded"?o:vL(i,e,r,n)?"none":o}function ta(t,e,r,n="project"){let o=$e(t)??tt(t);if(!o?.generators||vL(o,e,r,n))return;let i=cG[e];return i===null?void 0:i(o.generators)}var Ft,Ig,cG,ut=d(()=>{si();Vo();ye();Iu();ze();Pu();Cd();Rd();PS();yR();zd();Qd();gf();Ff();Mf();Gf();Hf();Jf();Xf();tg();eg();RL();_g();Ft=[kl,zl,Vl,xS,hR,im,dm,Rm,Pm,Tm,Nm,$m,jm,Um,Wm,Bm,SL,Xm];s(sG,"builtinTargetsMap");s($e,"getBuiltinTargetDefinition");s(Po,"getTargetCapabilities");s(Cg,"getTargetDetectionPaths");s(Tt,"getTargetLayout");s(iG,"getTargetPrimaryRootInstructionPath");s(Lc,"getTargetSkillDir");s(Sg,"getTargetManagedOutputs");s(Rg,"rewriteGeneratedOutputPath");s(vL,"isFeatureSuppressedByConversion");s(aG,"isConversionUpgrading");s(Zm,"getEffectiveTargetSupportLevel");cG={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(ta,"resolveTargetFeatureGenerator");});function gG(t){return typeof t=="string"?t:t.level}function ML(t){return fG.includes(t)}function $L(t,e,r,n){for(let o of dG){let i=gG(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",c=ML(o.feature)&&typeof t.emitScopedSettings=="function";a||c||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${i}" but generators.${o.generator}`+(ML(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function qm(t){return yG.parse(t)}var Wn,GL,lG,mG,jL,pG,uG,dG,fG,hG,yG,kg=d(()=>{Wn=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()})]),GL=z$1.object({rules:Wn,additionalRules:Wn,commands:Wn,agents:Wn,skills:Wn,mcp:Wn,hooks:Wn,ignore:Wn,permissions:Wn}),lG=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(),mG=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),jL=z$1.object({paths:mG}).passthrough(),pG=z$1.object({capabilities:GL,detectionPaths:z$1.array(z$1.string()),layout:jL,scopeExtras:z$1.function().optional()}).passthrough(),uG=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],dG=[{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"}],fG=["mcp","hooks","ignore","permissions"];s(gG,"capabilityLevel");s(ML,"canUseScopedSettings");s($L,"validateCapabilityImplementations");hG=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:lG,capabilities:GL,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:jL,globalSupport:pG.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),yG=hG.superRefine((t,e)=>{for(let r of uG)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});$L(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&$L(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(qm,"validateDescriptor");});function _G(){return Og||(Og=new Map(Ft.map(t=>[t.id,t]))),Og}function Qm(t){let e=qm(t);wg.set(e.id,e);}function tt(t){return wg.get(t)??_G().get(t)}function tp(){return [...wg.values()]}var wg,Og,ye=d(()=>{ut();kg();wg=new Map;s(_G,"builtinDescriptors");s(Qm,"registerTargetDescriptor");s(tt,"getDescriptor");s(tp,"getAllDescriptors");});async function UL(t,e,r="project"){let n=new Map,o=tt(t);return o&&await o.buildImportPaths(n,e,r),n}var KL=d(()=>{ye();s(UL,"buildImportReferenceMap");});function SG(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 RG(){let t=new Set([".agentsmesh/"]);for(let e of Ft)for(let r of SG(e))t.add(r);return Array.from(t)}function kG(){let t=new Set([...RG(),...Eg.rootRelativePrefixes]),e=new Set([...CG,...Eg.meshRootSegments]);return {protectedSchemes:[...IG,...Eg.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function ep(){return Lg||(Lg=kG()),Lg}var IG,CG,Eg,Lg,WL=d(()=>{ut();IG=[/\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],CG=new Set(["skills","rules","commands","agents","packs"]),Eg={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(SG,"topLevelDotfilePrefixes");s(RG,"buildDefaultRootRelativePrefixes");s(kG,"rebuild");s(ep,"getLinkFormatRegistry");});function Ir(t){let e=pt(t);return ep().rootRelativePrefixes.some(r=>e.startsWith(r))}function wG(t){let e=pt(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Ye.test(e)||/^[a-zA-Z]:/.test(e)||Ir(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&ep().meshRootSegments.has(r)}function bc(t,e,r){let n=Y(e),o=K(e,e),i=K(e,r),a=pt(t);if(Ye.test(t)){let c=K(e,t);return n===win32||c.startsWith(`${o}${n.sep}`)?[c]:[c]}if(n.isAbsolute(t)){let c=K(e,t);return c.startsWith(o)||existsSync(t)?[c]:[K(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let c=K(e,n.join(n.dirname(i),a)),l=h_(a,o);return l&&l!==c?[c,l]:[c]}if(Ir(a))return [K(e,n.join(o,a))];if(a.includes("/")){let c=K(e,n.join(o,".agentsmesh")),l=wG(a)?K(e,n.join(c,a)):null,m=K(e,n.join(o,a)),p=K(e,n.join(n.dirname(i),a));return l!==null?[l,m,p]:[m,p]}return EG.has(a)?[]:a.includes(".")?[K(e,n.join(n.dirname(i),a))]:[]}function Ac(t,e){let r=[e];if(!g_(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 VL(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function rp(t){let e=[];for(let r of ep().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(LG))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(bG))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(AG))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var EG,LG,bG,AG,zL,ea,Fo=d(()=>{Wt();WL();s(Ir,"isRootRelativePathToken");s(wG,"isMeshRootRelativePathToken");EG=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),LG=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,bG=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,AG=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,zL=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,ea=/(?::(\d+)){1,2}$/;s(bc,"resolveProjectPath");s(Ac,"expandResolvedPaths");s(VL,"isGlobAdjacent");s(rp,"protectedRanges");});function xG(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 JL(t){return xG(t.tokenContext)}function bg(t,e){let r=Y(t),n=K(t,t),o=K(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function YL(t){let e=Y(t);return K(t,e.join(t,".agentsmesh"))}function Cr(t,e){let r=Y(t),n=YL(t),o=K(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function XL(t,e,r){let n=Y(t),o=YL(t),i=K(t,e);if(!Cr(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 Ag(t,e,r){let o=Y(t).relative(K(t,t),K(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let i=o.length>0?o:".";return r&&!i.endsWith("/")?`${i}/`:i}function ra(t,e,r){let n=Ag(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function xg(t,e,r,n,o){let i=Y(t),a=K(t,t),c=K(t,e),l=K(t,r);if(!bg(t,l))return ra(t,l,n)?.text??null;let m=K(t,i.dirname(c));if(!bg(t,m)&&m!==a)return ra(t,l,n)?.text??null;let p=i.relative(m,l).replace(/\\/g,"/");if(i.isAbsolute(p)||Ye.test(p))return Ag(t,l,n);let u=K(t,i.join(m,p));return bg(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):Ag(t,l,n)}var Pg=d(()=>{Wt();s(xG,"isReadingContext");s(JL,"isReadingContextOptions");s(bg,"isUnderProjectRoot");s(YL,"agentsMeshRoot");s(Cr,"isUnderAgentsMesh");s(XL,"toAgentsMeshRootRelative");s(Ag,"toProjectRootRelative");s(ra,"toProjectRootReference");s(xg,"formatLinkPathForDestinationLegacy");});function ZL(t,e,r,n,o={}){let i=o.scope??"project",a=K(t,r);if(JL(o)&&Cr(t,e)&&Cr(t,a)){let m=Y(t),p=K(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 xg(t,e,r,n,o);if(i==="global"&&!Cr(t,e))return ra(t,a,n)?.text??null;let c=(()=>{if(Cr(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&Cr(t,K(t,m))?K(t,m):null})();if(!c)return ra(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=XL(t,c,n);return m!==null?m:ra(t,c,n)?.text??null}return xg(t,e,r,n,o)}var qL=d(()=>{Fo();Wt();Pg();Pg();s(ZL,"formatLinkPathForDestination");});function QL(t,e,r,n){let o=Y(e),i=pt(t);if(!Ir(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let c=K(e,r),l=o.dirname(c);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=K(e,o.join(l,p));if(u!==c&&n(u))return u}return null}var tb=d(()=>{Wt();Fo();s(QL,"resolveByDestinationSuffixStrip");});function eb(t){let e=null,r=false,n=null,o=null,i=null;for(let l of bc(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of Ac(t.projectRoot,l)){let f=K(t.projectRoot,u),g=K(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 l=QL(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);l!==null&&(e=l,r=true);}!r&&o!==null&&(e=o,i!==null&&(n=i),r=true);let a=pt(t.destinationFile),c=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&pt(t.rawToken).startsWith(".agentsmesh/")&&c&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var rb=d(()=>{Wt();Fo();tb();s(eb,"resolveLinkTarget");});function nb(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function ob(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 sb(t){let e=pt(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Ye.test(e)||Ir(e)?false:e.includes("/")}var ib=d(()=>{Wt();Fo();s(nb,"isTildeHomeRelativePathToken");s(ob,"isMarkdownLinkDestinationToken");s(sb,"isRelativePathToken");});function PG(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===`
131
131
  `)break;i+=a,o++;}return i===r}function ab(t,e,r){let n=t.lastIndexOf(`
132
132
  `,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===`
133
- `||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function cb(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:ab(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 lb(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=ni(n),a=i.replace(ea,""),c=pt(a),l=e+a.length,m=t[e-1],p=t[r];return ab(t,e,l)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!Ir(c)&&bG(t,e,n)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?Ir(c)?true:c.includes("/")||c.includes("\\")?c.startsWith("./")||c.startsWith("../")?true:(c.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var mb=d(()=>{Wt();Fo();s(bG,"markdownBracketLabelDuplicatesDestination");s(ab,"isMarkdownReferenceDefinitionDestination");s(cb,"getTokenContext");s(lb,"shouldRewritePathToken");});function rp(t){let e=new Set,r=ep(t.content);return {content:t.content.replace(zL,(o,i,a)=>{if(r.some(([Ot,ct])=>i>=Ot&&i<ct)||!lb(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||nb(a,i,o)||VL(a,i,i+o.length))return o;let{candidate:c,suffix:l}=ni(o);if(!c)return o;let m=ea.exec(c),p=m?c.slice(0,m.index):c,u=m?m[0]:"";if(!p)return o;let f=cb(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&Ye.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:R}=eb({candidate:p,rawToken:c,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),C=h;if(!R||!g)return g&&e.add(g),o;let _=pt(p),E=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(E&&!_.includes("/")&&!_.includes("\\"))return o;if(C===null){let Ot=pt(c);if(Ot.startsWith("agentsmesh/")&&(Ot=`.${Ot}`),Ot.startsWith(".agentsmesh/")||Ot.includes("/.agentsmesh/")){let ct=Y(t.projectRoot),sn=K(t.projectRoot,t.projectRoot),Ke=Ot.replace(/^\.\//,"");C=K(t.projectRoot,ct.join(sn,Ke));}}let T=Y(t.projectRoot);if(t.scope==="global"){let Ot=pt(c),ct=Ot.startsWith(".agentsmesh/")||Ot.includes("/.agentsmesh/"),sn=Ir(Ot)||sb(Ot),Ke=C!==null&&Cr(t.projectRoot,C),Xn=Cr(t.projectRoot,g);if(C===g&&!Xn&&!Ke&&!ct){let dy=pt(T.relative(t.projectRoot,K(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",rT=(C!==null?pt(T.relative(t.projectRoot,C)):"").split("/").filter(Boolean)[0]??"";if(dy.length>0&&dy===rT)return o}if(!sn&&!ct&&!Ke&&!Xn)return o}let D=K(t.projectRoot,t.destinationFile),x=K(t.projectRoot,g),Z=pt(T.relative(t.projectRoot,D)),B=pt(T.relative(t.projectRoot,x)),J=Z.split("/").filter(Boolean)[0]??"",kt=B.split("/").filter(Boolean)[0]??"",Dt=!pt(p).startsWith(".agentsmesh/")&&!E&&J.length>0&&J===kt&&J.startsWith(".")&&J!==".agentsmesh"||f.role==="markdown-link-dest"||ob(a,i,p),Rr=ZL(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||Dt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:E?null:C,forceRelative:Dt,tokenContext:f,originalToken:p});return Rr?`${Rr}${u}${l}`:o}),missing:[...e]}}var Tg=d(()=>{Wt();Fo();qL();rb();ib();mb();s(rp,"rewriteFileLinks");});function ub(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 z(t,e,r="project"){let n=Y(e),o=new Map,i=Array.from(new Set([t,...it]));for(let l of i){let m=await UL(l,e,r);for(let[p,u]of m.entries())o.set(p,u);}let a=new Map;for(let[l,m]of o.entries()){let p=n.normalize(n.join(e,m));for(let u of ub(n,n.join(e,l)))a.set(u,p);}let c=new Set;for(let l of new Set(o.values())){let m=n.normalize(n.join(e,l));c.add(m);for(let p of ub(n,m))c.add(n.normalize(p));}return (l,m,p)=>rp({content:l,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)||c.has(f)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:s(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var It=d(()=>{Wt();KL();Tg();ze();s(ub,"pathVariants");s(z,"createImportReferenceNormalizer");});function fb(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,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!Or({...m,type:p}))continue;let u=p==="prompt"?Yt(m)||wt(m):wt(m)||Yt(m),f={matcher:c,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 gb(t,e){let r=join(t,_n),n=await y(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=fb(o);if(Object.keys(i).length===0)return false;let a=stringify(i),c=join(t,qo);return await O(dirname(c)),await S(c,a),e.push({fromTool:"claude-code",fromPath:r,toPath:qo,feature:"hooks"}),true}async function hb(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(_n)),n=join(t,Wa),o=await y(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,Va,m),e.push({fromTool:"claude-code",fromPath:n,toPath:Va,feature:"mcp"});}let c=i.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let m=c,p=Array.isArray(m.allow)?m.allow.filter(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,ju);await O(dirname(h)),await S(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:ju,feature:"permissions"});}}let l=i.hooks;if(!r&&l&&typeof l=="object"&&!Array.isArray(l)){let m=fb(l);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,qo);await O(dirname(u)),await S(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:qo,feature:"hooks"});}}}var yb=d(()=>{Je();A();fn();In();s(fb,"claudeHooksToCanonical");s(gb,"importClaudeHooksJson");s(hb,"importSettings");});async function Ib(t,e,r){let n=join(t,Ka),o=join(t,Gu),a=(await N(n)).filter(c=>c.endsWith("SKILL.md"));for(let c of a){let l=dirname(c),m=basename(l),p=join(o,m),u=await N(l);for(let f of u){let g=await y(f);if(g===null)continue;let h=relative(l,f),R=join(p,h);await O(dirname(R));let C=r(g,f,R),_=h==="SKILL.md"?w(C):null;await S(R,h==="SKILL.md"?await Lr(R,_?.frontmatter??{},_?.body??""):C);let E=`${Gu}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:f,toPath:E,feature:"skills"});}}}var Cb=d(()=>{A();M();et();In();s(Ib,"importClaudeSkills");});async function Vl(t,e={}){let r=e.scope??"project",n=[],o=await z("claude-code",t,r);return n.push(...await Q(zl,t,r,{normalize:o})),await Ib(t,n,o),await gb(t,n),await hb(t,n),n}var kd=d(()=>{It();Mt();yb();Cb();Rd();s(Vl,"importFromClaudeCode");});async function xc(t,e){let r=TG[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}var TG,Fg=d(()=>{kd();ff();qd();Nf();Bd();yg();bd();Hd();$f();Vf();Bf();TG={"claude-code":Vl,cursor:Cm,copilot:pm,"gemini-cli":Am,"codex-cli":rm,windsurf:Jm,cline:Zl,continue:om,junie:Tm,kiro:$m,"kilo-code":vm};s(xc,"importNativeToCanonical");});async function $s(t){if(!await v(t))return false;if(await v(join(t,Mg)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await v(join(t,r.name,Mg)))return !0}catch{return false}return false}async function Pc(t){if(!await v(t))return [];if(await v(join(t,Mg))){let e=await c_(t);return e?[e]:[]}return ei(t)}var Mg,op=d(()=>{A();pl();Mg="SKILL.md";s($s,"isSkillPackLayout");s(Pc,"loadSkillsAtExtendPath");});function vG(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function MG(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 sp(t){if(!await v(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 $G(t){if(basename(t)==="rules")return Ko(t);let r=join(t,"rules");return await v(r)?Ko(r):[]}async function GG(t){if(basename(t)==="commands")return Wo(t);let r=join(t,"commands");return await v(r)?Wo(r):[]}async function jG(t){if(basename(t)==="agents")return Ho(t);let r=join(t,"agents");return await v(r)?Ho(r):[]}async function UG(t){if(await $s(t))return Pc(t);let e=join(t,"skills");return await $s(e)?Pc(e):[]}async function ip(t){let e=join(t,".agentsmesh");if(await v(e))return pe(t);let r=vG();if(r.rules=await $G(t),r.commands=await GG(t),r.agents=await jG(t),r.skills=await UG(t),MG(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}var $g=d(()=>{A();ll();zo();cl();al();op();s(vG,"emptyCanonical");s(MG,"isCanonicalSliceEmpty");s(sp,"normalizeSlicePath");s($G,"parseRulesAt");s(GG,"parseCommandsAt");s(jG,"parseAgentsAt");s(UG,"loadSkillsForPartialSlice");s(ip,"loadCanonicalSliceAtPath");});function KG(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function Sb(t){let e=t.resolvedPath;if(!t.path){let o=join(e,".agentsmesh");if(!await v(o)){if(await $s(e)){let a=await Pc(e);return {...KG(),skills:a}}let i=t.target??await gl(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
134
- Expected one of: .agentsmesh/, ${d_.join(", ")}.`);I.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await xc(e,i);}return pe(e)}let r=join(e,t.path);if(!await v(r))throw new Error(`Extend "${t.name}": path does not exist: ${r}`);if(t.target){let o=join(e,".agentsmesh");return await v(o)||(I.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await xc(e,t.target)),pe(e)}let{sliceRoot:n}=await sp(r);try{return await ip(n)}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 Rb=d(()=>{_u();A();nt();zo();Fg();op();$g();s(KG,"emptyCanonical");s(Sb,"loadCanonicalForExtend");});function ap(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(c=>i.has(c.name))};for(let c of r.skills)a.some(l=>l.name===c)||I.warn(`[agentsmesh] pick name "${c}" 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(c=>i.has(c.name))};for(let c of r.commands)a.some(l=>l.name===c)||I.warn(`[agentsmesh] pick name "${c}" 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(c=>i.has(c.name))};for(let c of r.agents)a.some(l=>l.name===c)||I.warn(`[agentsmesh] pick name "${c}" not found in agents from extend "${n}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=o.rules,c=s(l=>basename(l).replace(/\.md$/i,""),"stem");o={...o,rules:a.filter(l=>i.has(c(l.source)))};for(let l of r.rules)a.some(m=>c(m.source)===l)||I.warn(`[agentsmesh] pick name "${l}" not found in rules from extend "${n}".`);}return o}var jg=d(()=>{nt();s(ap,"applyExtendPick");});var HG,na,cp=d(()=>{HG=["rules","commands","agents","skills"],na=z$1.enum(HG);});var zG,kb,Ob=d(()=>{ln();cp();zG=z$1.enum(["github","gitlab","git","local"]),kb=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:zG,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(Zs).min(1),pick:ka.optional(),target:Re.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:na.optional(),content_hash:z$1.string()});});function wb(t){let e=Uo(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 JG(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}async function lp(t){let e=join(t,"pack.yaml"),r=await y(e);if(r===null)return null;try{let n=parse(r);return kb.parse(n)}catch{return null}}async function Lb(t,e,r){if(!await v(t))return null;let n=wb(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),c=await lp(a);if(c&&wb(c.source)===n&&c.target===r.target&&c.as===r.as&&JG(c.features,r.features))return {meta:c,packDir:a,name:c.name}}return null}async function mp(t){if(!await v(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 lp(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}var pp=d(()=>{A();Ob();Ea();s(wb,"sourceIdentity");s(JG,"sameFeatures");s(lp,"readPackMetadata");s(Lb,"findExistingPack");s(mp,"listPacks");});function bb(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function YG(t){let[e,r,n,o,i,a,c,l]=await Promise.all([Ko(join(t,"rules")),Wo(join(t,"commands")),Ho(join(t,"agents")),ei(join(t,"skills")),Ve(join(t,"mcp.json")),ul(join(t,"permissions.yaml")),dl(join(t,"hooks.yaml")),fl(join(t,"ignore"))]);return {...bb(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:c,ignore:l}}async function Ab(t){let e=join(t,"packs"),r=await mp(e),n=bb();for(let{meta:o,packDir:i}of r){let a=await YG(i),c=Kg(a,o.features),l=ap(c,o.features,o.pick,o.name);n=ri(n,l);}return n}var xb=d(()=>{al();cl();ll();pl();ba();uu();fu();gu();yu();nn();jg();pp();s(bb,"emptyCanonical");s(YG,"loadPackCanonical");s(Ab,"loadPacksCanonical");});function Kg(t,e){if(e.length===0)return Pb();let r=new Set(e.flatMap(n=>ZG[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 Pb(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function ee(t,e,r={},n=join(e,".agentsmesh")){let o=await ti(t,e,{refreshCache:r.refreshRemoteCache===true}),i=Pb();for(let l of o){let m=await Sb(l),p=Kg(m,l.features),u=ap(p,l.features,l.pick,l.name);i=ri(i,u);}let a=await Ab(n);i=ri(i,a);let c=await pe(n);return i=ri(i,c),{canonical:i,resolvedExtends:o}}var ZG,nn=d(()=>{il();zo();yu();Rb();jg();xb();ZG={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(Kg,"filterCanonicalByFeatures");s(Pb,"emptyCanonical");s(ee,"loadCanonicalWithExtends");});async function zj(t,e){let{source:r}=t,n;if(r.startsWith("file:")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);n=pathToFileURL(a).href;}else n=r;return await import(n)}function Vj(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function kp(t,e){let r;try{r=await zj(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=Vj(r),o=[];for(let i of n)try{let a=Zm(i);qm(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 cA(t,e){let r=[];return await Promise.all(t.map(async n=>{try{let o=await kp(n,e);r.push(o);}catch(o){I.warn(`Plugin '${n.source}' failed to load: ${o instanceof Error?o.message:String(o)}`);}})),r}var Zg=d(()=>{kg();ye();nt();s(zj,"importPluginModule");s(Vj,"extractDescriptors");s(kp,"loadPlugin");s(cA,"loadAllPlugins");});async function Jt(t,e){t.plugins.length!==0&&await cA(t.plugins,e);}var Vn=d(()=>{Zg();s(Jt,"bootstrapPlugins");});function th(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,c;switch(i){case "rules":c=e.rules.length,a="rules";break;case "commands":c=e.commands.length,a=c>0?`commands (${c})`:"commands";break;case "agents":c=e.agents.length,a=c>0?`agents (${c})`:"agents";break;case "skills":c=e.skills.length,a=c>0?`skills (${c})`:"skills";break;case "mcp":c=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=c>0?`mcp (${c} servers)`:"mcp";break;case "hooks":c=hU(e.hooks),a=c>0?`hooks (${c})`:"hooks";break;case "ignore":c=e.ignore.length>0?1:0,a="ignore";break;case "permissions":c=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let l={};for(let m of o)l[m]=Xm(m,i,t,r);if(n.push({feature:a,count:c,support:l}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of o)p[u]=Xm(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}function hU(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var _A=d(()=>{ut();s(th,"buildCompatibilityMatrix");s(hU,"countHooks");});function IA(t){return yU[t]??t}var yU,CA=d(()=>{yU={"claude-code":"Claude"};s(IA,"matrixColumnLabel");});function SA(t){return Object.fromEntries(_U.map(e=>[e,Object.fromEntries(it.map(r=>{let o=Po(r,t)?.[e];return [r,o??{level:"none"}]}))]))}function IU(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function CU(t,e){return IU()?e:`${t}${e}${Mc.reset}`}function kA(t){let e=eh[t];return CU(SU[t],e)}var _U,RA,eh,Mc,SU,rh=d(()=>{ze();ut();_U=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(SA,"buildSupportMatrix");RA=SA("project"),SA("global"),eh={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},Mc={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(IU,"noColor");s(CU,"colorize");SU={native:Mc.green,embedded:Mc.blue,partial:Mc.yellow,none:Mc.dim};s(kA,"coloredSymbol");});function nh(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((B,J)=>r?J:`${B}${J}${n.reset}`,"c"),i=s(B=>B.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((B,J)=>{let kt=i(B),Ct=Math.max(0,J-kt);return B+" ".repeat(Ct)},"padWithColor"),c=Math.max(12,...e.map(B=>B.length)),l=e.map(B=>IA(B)),m=Math.max(8,c),p=Math.max(12,...t.map(B=>B.feature.length)),u=s(B=>o(n.dim,"\u250C"+B.map(J=>"\u2500".repeat(J)).join("\u252C")+"\u2510"),"border"),f=s(B=>o(n.dim,"\u251C"+B.map(J=>"\u2500".repeat(J)).join("\u253C")+"\u2524"),"sep"),g=s(B=>o(n.dim,"\u2514"+B.map(J=>"\u2500".repeat(J)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],R=u(h),C=[a(o(n.bold+n.cyan,"Feature"),p),...l.map(B=>a(o(n.bold+n.magenta,B),m))],_=o(n.dim,"\u2502")+C.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),E=f(h),T=t.map(B=>{let J=[a(o(n.cyan,B.feature),p)];for(let kt of e){let Ct=B.support[kt]??"none",Sr=r?eh[Ct]:kA(Ct);J.push(a(` ${Sr} `,m));}return o(n.dim,"\u2502")+J.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),D=g(h),x=[R,_,E,...T,D];x.push("");let Z=[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: ")+Z.join(" ")),x.join(`
135
- `)}var OA=d(()=>{CA();rh();s(nh,"formatMatrix");});function sh(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?"":`
133
+ `||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function cb(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:ab(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 lb(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=ni(n),a=i.replace(ea,""),c=pt(a),l=e+a.length,m=t[e-1],p=t[r];return ab(t,e,l)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!Ir(c)&&PG(t,e,n)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?Ir(c)?true:c.includes("/")||c.includes("\\")?c.startsWith("./")||c.startsWith("../")?true:(c.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var mb=d(()=>{Wt();Fo();s(PG,"markdownBracketLabelDuplicatesDestination");s(ab,"isMarkdownReferenceDefinitionDestination");s(cb,"getTokenContext");s(lb,"shouldRewritePathToken");});function np(t){let e=new Set,r=rp(t.content);return {content:t.content.replace(zL,(o,i,a)=>{if(r.some(([Ot,ct])=>i>=Ot&&i<ct)||!lb(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||nb(a,i,o)||VL(a,i,i+o.length))return o;let{candidate:c,suffix:l}=ni(o);if(!c)return o;let m=ea.exec(c),p=m?c.slice(0,m.index):c,u=m?m[0]:"";if(!p)return o;let f=cb(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&Ye.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:R}=eb({candidate:p,rawToken:c,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),C=h;if(!R||!g)return g&&e.add(g),o;let _=pt(p),E=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(E&&!_.includes("/")&&!_.includes("\\"))return o;if(C===null){let Ot=pt(c);if(Ot.startsWith("agentsmesh/")&&(Ot=`.${Ot}`),Ot.startsWith(".agentsmesh/")||Ot.includes("/.agentsmesh/")){let ct=Y(t.projectRoot),sn=K(t.projectRoot,t.projectRoot),Ke=Ot.replace(/^\.\//,"");C=K(t.projectRoot,ct.join(sn,Ke));}}let T=Y(t.projectRoot);if(t.scope==="global"){let Ot=pt(c),ct=Ot.startsWith(".agentsmesh/")||Ot.includes("/.agentsmesh/"),sn=Ir(Ot)||sb(Ot),Ke=C!==null&&Cr(t.projectRoot,C),Xn=Cr(t.projectRoot,g);if(C===g&&!Xn&&!Ke&&!ct){let fy=pt(T.relative(t.projectRoot,K(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",sT=(C!==null?pt(T.relative(t.projectRoot,C)):"").split("/").filter(Boolean)[0]??"";if(fy.length>0&&fy===sT)return o}if(!sn&&!ct&&!Ke&&!Xn)return o}let D=K(t.projectRoot,t.destinationFile),x=K(t.projectRoot,g),Z=pt(T.relative(t.projectRoot,D)),B=pt(T.relative(t.projectRoot,x)),J=Z.split("/").filter(Boolean)[0]??"",kt=B.split("/").filter(Boolean)[0]??"",Dt=!pt(p).startsWith(".agentsmesh/")&&!E&&J.length>0&&J===kt&&J.startsWith(".")&&J!==".agentsmesh"||f.role==="markdown-link-dest"||ob(a,i,p),Rr=ZL(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||Dt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:E?null:C,forceRelative:Dt,tokenContext:f,originalToken:p});return Rr?`${Rr}${u}${l}`:o}),missing:[...e]}}var Tg=d(()=>{Wt();Fo();qL();rb();ib();mb();s(np,"rewriteFileLinks");});function ub(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 z(t,e,r="project"){let n=Y(e),o=new Map,i=Array.from(new Set([t,...it]));for(let l of i){let m=await UL(l,e,r);for(let[p,u]of m.entries())o.set(p,u);}let a=new Map;for(let[l,m]of o.entries()){let p=n.normalize(n.join(e,m));for(let u of ub(n,n.join(e,l)))a.set(u,p);}let c=new Set;for(let l of new Set(o.values())){let m=n.normalize(n.join(e,l));c.add(m);for(let p of ub(n,m))c.add(n.normalize(p));}return (l,m,p)=>np({content:l,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)||c.has(f)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:s(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var It=d(()=>{Wt();KL();Tg();ze();s(ub,"pathVariants");s(z,"createImportReferenceNormalizer");});function fb(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,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!Or({...m,type:p}))continue;let u=p==="prompt"?Yt(m)||wt(m):wt(m)||Yt(m),f={matcher:c,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 gb(t,e){let r=join(t,_n),n=await y(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=fb(o);if(Object.keys(i).length===0)return false;let a=stringify(i),c=join(t,qo);return await O(dirname(c)),await S(c,a),e.push({fromTool:"claude-code",fromPath:r,toPath:qo,feature:"hooks"}),true}async function hb(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(_n)),n=join(t,Ba),o=await y(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,Ja,m),e.push({fromTool:"claude-code",fromPath:n,toPath:Ja,feature:"mcp"});}let c=i.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let m=c,p=Array.isArray(m.allow)?m.allow.filter(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,ju);await O(dirname(h)),await S(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:ju,feature:"permissions"});}}let l=i.hooks;if(!r&&l&&typeof l=="object"&&!Array.isArray(l)){let m=fb(l);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,qo);await O(dirname(u)),await S(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:qo,feature:"hooks"});}}}var yb=d(()=>{Je();A();fn();In();s(fb,"claudeHooksToCanonical");s(gb,"importClaudeHooksJson");s(hb,"importSettings");});async function Ib(t,e,r){let n=join(t,Wa),o=join(t,Gu),a=(await N(n)).filter(c=>c.endsWith("SKILL.md"));for(let c of a){let l=dirname(c),m=basename(l),p=join(o,m),u=await N(l);for(let f of u){let g=await y(f);if(g===null)continue;let h=relative(l,f),R=join(p,h);await O(dirname(R));let C=r(g,f,R),_=h==="SKILL.md"?w(C):null;await S(R,h==="SKILL.md"?await Lr(R,_?.frontmatter??{},_?.body??""):C);let E=`${Gu}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:f,toPath:E,feature:"skills"});}}}var Cb=d(()=>{A();M();et();In();s(Ib,"importClaudeSkills");});async function Jl(t,e={}){let r=e.scope??"project",n=[],o=await z("claude-code",t,r);return n.push(...await Q(Vl,t,r,{normalize:o})),await Ib(t,n,o),await gb(t,n),await hb(t,n),n}var kd=d(()=>{It();Mt();yb();Cb();Rd();s(Jl,"importFromClaudeCode");});async function Pc(t,e){let r=FG[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}var FG,Fg=d(()=>{kd();ff();qd();Nf();Bd();yg();bd();Hd();$f();Vf();Bf();FG={"claude-code":Jl,cursor:Sm,copilot:um,"gemini-cli":xm,"codex-cli":nm,windsurf:Ym,cline:ql,continue:sm,junie:Dm,kiro:Gm,"kilo-code":Mm};s(Pc,"importNativeToCanonical");});async function $s(t){if(!await v(t))return false;if(await v(join(t,Mg)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await v(join(t,r.name,Mg)))return !0}catch{return false}return false}async function Tc(t){if(!await v(t))return [];if(await v(join(t,Mg))){let e=await c_(t);return e?[e]:[]}return ei(t)}var Mg,sp=d(()=>{A();ul();Mg="SKILL.md";s($s,"isSkillPackLayout");s(Tc,"loadSkillsAtExtendPath");});function GG(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function jG(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 ip(t){if(!await v(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 UG(t){if(basename(t)==="rules")return Ko(t);let r=join(t,"rules");return await v(r)?Ko(r):[]}async function KG(t){if(basename(t)==="commands")return Wo(t);let r=join(t,"commands");return await v(r)?Wo(r):[]}async function WG(t){if(basename(t)==="agents")return Ho(t);let r=join(t,"agents");return await v(r)?Ho(r):[]}async function BG(t){if(await $s(t))return Tc(t);let e=join(t,"skills");return await $s(e)?Tc(e):[]}async function ap(t){let e=join(t,".agentsmesh");if(await v(e))return pe(t);let r=GG();if(r.rules=await UG(t),r.commands=await KG(t),r.agents=await WG(t),r.skills=await BG(t),jG(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}var $g=d(()=>{A();ml();zo();ll();cl();sp();s(GG,"emptyCanonical");s(jG,"isCanonicalSliceEmpty");s(ip,"normalizeSlicePath");s(UG,"parseRulesAt");s(KG,"parseCommandsAt");s(WG,"parseAgentsAt");s(BG,"loadSkillsForPartialSlice");s(ap,"loadCanonicalSliceAtPath");});function HG(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function Sb(t){let e=t.resolvedPath;if(!t.path){let o=join(e,".agentsmesh");if(!await v(o)){if(await $s(e)){let a=await Tc(e);return {...HG(),skills:a}}let i=t.target??await hl(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
134
+ Expected one of: .agentsmesh/, ${d_.join(", ")}.`);I.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await Pc(e,i);}return pe(e)}let r=join(e,t.path);if(!await v(r))throw new Error(`Extend "${t.name}": path does not exist: ${r}`);if(t.target){let o=join(e,".agentsmesh");return await v(o)||(I.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await Pc(e,t.target)),pe(e)}let{sliceRoot:n}=await ip(r);try{return await ap(n)}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 Rb=d(()=>{_u();A();nt();zo();Fg();sp();$g();s(HG,"emptyCanonical");s(Sb,"loadCanonicalForExtend");});function cp(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(c=>i.has(c.name))};for(let c of r.skills)a.some(l=>l.name===c)||I.warn(`[agentsmesh] pick name "${c}" 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(c=>i.has(c.name))};for(let c of r.commands)a.some(l=>l.name===c)||I.warn(`[agentsmesh] pick name "${c}" 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(c=>i.has(c.name))};for(let c of r.agents)a.some(l=>l.name===c)||I.warn(`[agentsmesh] pick name "${c}" not found in agents from extend "${n}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=o.rules,c=s(l=>basename(l).replace(/\.md$/i,""),"stem");o={...o,rules:a.filter(l=>i.has(c(l.source)))};for(let l of r.rules)a.some(m=>c(m.source)===l)||I.warn(`[agentsmesh] pick name "${l}" not found in rules from extend "${n}".`);}return o}var jg=d(()=>{nt();s(cp,"applyExtendPick");});var JG,na,lp=d(()=>{JG=["rules","commands","agents","skills"],na=z$1.enum(JG);});var YG,kb,Ob=d(()=>{ln();lp();YG=z$1.enum(["github","gitlab","git","local"]),kb=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:YG,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(Zs).min(1),pick:Oa.optional(),target:Re.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:na.optional(),content_hash:z$1.string()});});function wb(t){let e=Uo(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 ZG(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}async function mp(t){let e=join(t,"pack.yaml"),r=await y(e);if(r===null)return null;try{let n=parse(r);return kb.parse(n)}catch{return null}}async function Lb(t,e,r){if(!await v(t))return null;let n=wb(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),c=await mp(a);if(c&&wb(c.source)===n&&c.target===r.target&&c.as===r.as&&ZG(c.features,r.features))return {meta:c,packDir:a,name:c.name}}return null}async function pp(t){if(!await v(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 mp(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}var up=d(()=>{A();Ob();La();s(wb,"sourceIdentity");s(ZG,"sameFeatures");s(mp,"readPackMetadata");s(Lb,"findExistingPack");s(pp,"listPacks");});function bb(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function qG(t){let[e,r,n,o,i,a,c,l]=await Promise.all([Ko(join(t,"rules")),Wo(join(t,"commands")),Ho(join(t,"agents")),ei(join(t,"skills")),Ve(join(t,"mcp.json")),dl(join(t,"permissions.yaml")),fl(join(t,"hooks.yaml")),gl(join(t,"ignore"))]);return {...bb(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:c,ignore:l}}async function Ab(t){let e=join(t,"packs"),r=await pp(e),n=bb();for(let{meta:o,packDir:i}of r){let a=await qG(i),c=Kg(a,o.features),l=cp(c,o.features,o.pick,o.name);n=ri(n,l);}return n}var xb=d(()=>{cl();ll();ml();ul();Aa();uu();fu();gu();yu();nn();jg();up();s(bb,"emptyCanonical");s(qG,"loadPackCanonical");s(Ab,"loadPacksCanonical");});function Kg(t,e){if(e.length===0)return Pb();let r=new Set(e.flatMap(n=>tj[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 Pb(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function ee(t,e,r={},n=join(e,".agentsmesh")){let o=await ti(t,e,{refreshCache:r.refreshRemoteCache===true}),i=Pb();for(let l of o){let m=await Sb(l),p=Kg(m,l.features),u=cp(p,l.features,l.pick,l.name);i=ri(i,u);}let a=await Ab(n);i=ri(i,a);let c=await pe(n);return i=ri(i,c),{canonical:i,resolvedExtends:o}}var tj,nn=d(()=>{al();zo();yu();Rb();jg();xb();tj={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(Kg,"filterCanonicalByFeatures");s(Pb,"emptyCanonical");s(ee,"loadCanonicalWithExtends");});function Jj(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 Yj(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}async function Xj(t,e){let{source:r}=t,n;if(Yj(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);n=pathToFileURL(a).href;}else {let i=Jj(r,e);n=pathToFileURL(i).href;}return await import(n)}function Zj(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function Op(t,e){let r;try{r=await Xj(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=Zj(r),o=[];for(let i of n)try{let a=qm(i);Qm(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 pA(t,e){let r=[];return await Promise.all(t.map(async n=>{try{let o=await Op(n,e);r.push(o);}catch(o){I.warn(`Plugin '${n.source}' failed to load: ${o instanceof Error?o.message:String(o)}`);}})),r}var qg=d(()=>{kg();ye();nt();s(Jj,"resolveNpmSpecifier");s(Yj,"isLocalSource");s(Xj,"importPluginModule");s(Zj,"extractDescriptors");s(Op,"loadPlugin");s(pA,"loadAllPlugins");});async function Jt(t,e){t.plugins.length!==0&&await pA(t.plugins,e);}var Vn=d(()=>{qg();s(Jt,"bootstrapPlugins");});function eh(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,c;switch(i){case "rules":c=e.rules.length,a="rules";break;case "commands":c=e.commands.length,a=c>0?`commands (${c})`:"commands";break;case "agents":c=e.agents.length,a=c>0?`agents (${c})`:"agents";break;case "skills":c=e.skills.length,a=c>0?`skills (${c})`:"skills";break;case "mcp":c=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=c>0?`mcp (${c} servers)`:"mcp";break;case "hooks":c=CU(e.hooks),a=c>0?`hooks (${c})`:"hooks";break;case "ignore":c=e.ignore.length>0?1:0,a="ignore";break;case "permissions":c=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let l={};for(let m of o)l[m]=Zm(m,i,t,r);if(n.push({feature:a,count:c,support:l}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of o)p[u]=Zm(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}function CU(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var SA=d(()=>{ut();s(eh,"buildCompatibilityMatrix");s(CU,"countHooks");});function RA(t){return SU[t]??t}var SU,kA=d(()=>{SU={"claude-code":"Claude"};s(RA,"matrixColumnLabel");});function OA(t){return Object.fromEntries(RU.map(e=>[e,Object.fromEntries(it.map(r=>{let o=Po(r,t)?.[e];return [r,o??{level:"none"}]}))]))}function kU(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function OU(t,e){return kU()?e:`${t}${e}${$c.reset}`}function EA(t){let e=rh[t];return OU(wU[t],e)}var RU,wA,rh,$c,wU,nh=d(()=>{ze();ut();RU=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(OA,"buildSupportMatrix");wA=OA("project"),OA("global"),rh={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},$c={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(kU,"noColor");s(OU,"colorize");wU={native:$c.green,embedded:$c.blue,partial:$c.yellow,none:$c.dim};s(EA,"coloredSymbol");});function oh(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((B,J)=>r?J:`${B}${J}${n.reset}`,"c"),i=s(B=>B.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((B,J)=>{let kt=i(B),Ct=Math.max(0,J-kt);return B+" ".repeat(Ct)},"padWithColor"),c=Math.max(12,...e.map(B=>B.length)),l=e.map(B=>RA(B)),m=Math.max(8,c),p=Math.max(12,...t.map(B=>B.feature.length)),u=s(B=>o(n.dim,"\u250C"+B.map(J=>"\u2500".repeat(J)).join("\u252C")+"\u2510"),"border"),f=s(B=>o(n.dim,"\u251C"+B.map(J=>"\u2500".repeat(J)).join("\u253C")+"\u2524"),"sep"),g=s(B=>o(n.dim,"\u2514"+B.map(J=>"\u2500".repeat(J)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],R=u(h),C=[a(o(n.bold+n.cyan,"Feature"),p),...l.map(B=>a(o(n.bold+n.magenta,B),m))],_=o(n.dim,"\u2502")+C.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),E=f(h),T=t.map(B=>{let J=[a(o(n.cyan,B.feature),p)];for(let kt of e){let Ct=B.support[kt]??"none",Sr=r?rh[Ct]:EA(Ct);J.push(a(` ${Sr} `,m));}return o(n.dim,"\u2502")+J.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),D=g(h),x=[R,_,E,...T,D];x.push("");let Z=[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: ")+Z.join(" ")),x.join(`
135
+ `)}var LA=d(()=>{kA();nh();s(oh,"formatMatrix");});function ih(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?"":`
136
136
  Per-file details:
137
137
  `+e.join(`
138
138
  `)+`
139
- `}var wA=d(()=>{s(sh,"formatVerboseDetails");});var ih=d(()=>{_A();OA();wA();});var ah={};Jp(ah,{runMatrix:()=>$c});async function $c(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:c}=await lt(r,n);await Jt(a,r);let{canonical:l}=await ee(a,c.configDir,{},c.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=th(a,l,n),u=sh(l);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var Gc=d(()=>{le();nn();ih();Vn();s($c,"runMatrix");});var ch={};Jp(ch,{renderMatrix:()=>jc});function jc(t,e){if(t.data.features.length===0){I.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=nh(r,t.data.targets);process.stdout.write(n),process.stdout.write(`
139
+ `}var bA=d(()=>{s(ih,"formatVerboseDetails");});var ah=d(()=>{SA();LA();bA();});var ch={};Yp(ch,{runMatrix:()=>Gc});async function Gc(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:c}=await lt(r,n);await Jt(a,r);let{canonical:l}=await ee(a,c.configDir,{},c.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=eh(a,l,n),u=ih(l);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var jc=d(()=>{le();nn();ah();Vn();s(Gc,"runMatrix");});var lh={};Yp(lh,{renderMatrix:()=>Uc});function Uc(t,e){if(t.data.features.length===0){I.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=oh(r,t.data.targets);process.stdout.write(n),process.stdout.write(`
140
140
  `),e?.verbose&&t.verboseDetails&&(process.stdout.write(t.verboseDetails),process.stdout.write(`
141
- `));}var Uc=d(()=>{nt();ih();s(jc,"renderMatrix");});function gy(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(gy,"createRouter");nt();var Iy=[{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)"}],Cy=[{name:"init",usage:"agentsmesh init [flags]",description:"Create agentsmesh.yaml, agentsmesh.local.yaml, and canonical .agentsmesh scaffold",flags:[{name:"--global",description:"Initialize canonical home config under ~/.agentsmesh/ (global targets include claude-code, antigravity, codex-cli, cursor, gemini-cli, kilo-code)"},{name:"--yes",description:"Auto-import detected tool configs, then add example scaffold only under empty canonical paths"}]},{name:"generate",usage:"agentsmesh generate [flags]",description:"Generate target files from canonical sources",flags:[{name:"--global",description:"Generate user-level config from ~/.agentsmesh/ (e.g. claude-code, antigravity, codex-cli, gemini-cli, kilo-code; Cursor writes ~/.cursor/rules, ~/.cursor/AGENTS.md, hooks, ignore, MCP, skills, agents, commands; legacy ~/.agentsmesh-exports/cursor/user-rules.md is import-only)"},{name:"--targets <csv>",description:"Limit generation to target IDs (comma-separated)"},{name:"--check",description:"Check drift only; exit non-zero when out of sync"},{name:"--dry-run",description:"Preview file changes without writing outputs"},{name:"--force",description:"Bypass lock-strategy blocked feature violations"},{name:"--refresh-cache",description:"Refresh remote extends cache before loading"},{name:"--no-cache",description:"Alias for --refresh-cache"}]},{name:"import",usage:"agentsmesh import --from <target> [flags]",description:"Import existing tool config into canonical .agentsmesh files",flags:[{name:"--from <target>",description:"Source tool ID to import from (required)"},{name:"--global",description:"Import from user-level paths into ~/.agentsmesh/ (claude-code, antigravity, codex-cli, gemini-cli, kilo-code; cursor reads ~/.cursor/{rules,AGENTS.md,mcp.json,hooks.json,cursorignore,skills,agents,commands} and legacy ~/.agentsmesh-exports/cursor/user-rules.md)"}]},{name:"convert",usage:"agentsmesh convert --from <target> --to <target> [flags]",description:"Convert configuration directly from one tool to another",flags:[{name:"--from <target>",description:"Source tool ID to convert from (required)"},{name:"--to <target>",description:"Destination tool ID to convert to (required)"},{name:"--global",description:"Convert user-level config (use home directory paths)"},{name:"--dry-run",description:"Preview conversion without writing files"}]},{name:"install",usage:"agentsmesh install <source> [flags]",description:"Install canonical resources from local/remote sources",flags:[{name:"<source>",description:"GitHub/GitLab/tree/blob URL, git+ URL, SSH, or local path"},{name:"--sync",description:"Reinstall missing packs recorded in .agentsmesh/installs.yaml"},{name:"--path <dir>",description:"Subdirectory inside source repo when not embedded in URL"},{name:"--target <id>",description:"Native format used for import-at-root discovery (same as extends.target)"},{name:"--as <kind>",description:"Manual collection mode: rules, commands, agents, or skills"},{name:"--name <id>",description:"Override generated install entry/pack name"},{name:"--extends",description:"Write install as extends entry instead of materialized pack"},{name:"--dry-run",description:"Preview only (no YAML write, no pack write, no generate)"},{name:"--global",description:"Install into ~/.agentsmesh/ and regenerate user-level config"},{name:"--force",description:"Non-interactive mode; include invalid resources and skip selection prompts (implied by --json)"}]},{name:"diff",usage:"agentsmesh diff [flags]",description:"Show patch-style output for what generate would change",flags:[{name:"--global",description:"Diff against outputs generated from ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit diff to target IDs (comma-separated)"}]},{name:"lint",usage:"agentsmesh lint [flags]",description:"Validate canonical files against target constraints",flags:[{name:"--global",description:"Lint canonical home config under ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit linting to target IDs (comma-separated)"}]},{name:"watch",usage:"agentsmesh watch [flags]",description:"Watch canonical files and regenerate on change",flags:[{name:"--global",description:"Watch ~/.agentsmesh/ and regenerate user-level config"},{name:"--targets <csv>",description:"Limit watched generate/matrix output to target IDs"}]},{name:"check",usage:"agentsmesh check",description:"Verify canonical files still match .agentsmesh/.lock",flags:[{name:"--global",description:"Check ~/.agentsmesh/.lock"}]},{name:"merge",usage:"agentsmesh merge",description:"Resolve .agentsmesh/.lock merge conflicts from current canonical state",flags:[{name:"--global",description:"Resolve ~/.agentsmesh/.lock conflicts"}]},{name:"matrix",usage:"agentsmesh matrix [flags]",description:"Print compatibility matrix for enabled features and targets",flags:[{name:"--global",description:"Show matrix for canonical home config under ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit matrix columns to target IDs"},{name:"--verbose",description:"Include expanded feature details in matrix output"}]},{name:"target",usage:"agentsmesh target scaffold <id> [--name <displayName>] [--force]",description:"Generate a new target skeleton (files, tests, fixture) under src/targets/<id>/.",flags:[{name:"--name <displayName>",description:"Human-readable name (defaults to id)"},{name:"--force",description:"Overwrite existing files"}]},{name:"plugin",usage:"agentsmesh plugin <add|list|remove|info> [args] [flags]",description:"Manage plugin-provided targets (npm packages exporting a TargetDescriptor).",flags:[{name:"--version <v>",description:"Pin plugin version (add)"},{name:"--id <id>",description:"Override derived plugin id (add)"}]},{name:"mcp",usage:"agentsmesh mcp",description:"Start the agentsmesh MCP server (stdio)",flags:[]}];function Sy(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
142
- `)}s(Sy,"formatFlags");function Ry(){let t=Cy.map(e=>`- ${e.name.padEnd(8)} ${e.description}
141
+ `));}var Kc=d(()=>{nt();ah();s(Uc,"renderMatrix");});function hy(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(hy,"createRouter");nt();var Cy=[{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)"}],Sy=[{name:"init",usage:"agentsmesh init [flags]",description:"Create agentsmesh.yaml, agentsmesh.local.yaml, and canonical .agentsmesh scaffold",flags:[{name:"--global",description:"Initialize canonical home config under ~/.agentsmesh/ (global targets include claude-code, antigravity, codex-cli, cursor, gemini-cli, kilo-code)"},{name:"--yes",description:"Auto-import detected tool configs, then add example scaffold only under empty canonical paths"}]},{name:"generate",usage:"agentsmesh generate [flags]",description:"Generate target files from canonical sources",flags:[{name:"--global",description:"Generate user-level config from ~/.agentsmesh/ (e.g. claude-code, antigravity, codex-cli, gemini-cli, kilo-code; Cursor writes ~/.cursor/rules, ~/.cursor/AGENTS.md, hooks, ignore, MCP, skills, agents, commands; legacy ~/.agentsmesh-exports/cursor/user-rules.md is import-only)"},{name:"--targets <csv>",description:"Limit generation to target IDs (comma-separated)"},{name:"--check",description:"Check drift only; exit non-zero when out of sync"},{name:"--dry-run",description:"Preview file changes without writing outputs"},{name:"--force",description:"Bypass lock-strategy blocked feature violations"},{name:"--refresh-cache",description:"Refresh remote extends cache before loading"},{name:"--no-cache",description:"Alias for --refresh-cache"}]},{name:"import",usage:"agentsmesh import --from <target> [flags]",description:"Import existing tool config into canonical .agentsmesh files",flags:[{name:"--from <target>",description:"Source tool ID to import from (required)"},{name:"--global",description:"Import from user-level paths into ~/.agentsmesh/ (claude-code, antigravity, codex-cli, gemini-cli, kilo-code; cursor reads ~/.cursor/{rules,AGENTS.md,mcp.json,hooks.json,cursorignore,skills,agents,commands} and legacy ~/.agentsmesh-exports/cursor/user-rules.md)"}]},{name:"convert",usage:"agentsmesh convert --from <target> --to <target> [flags]",description:"Convert configuration directly from one tool to another",flags:[{name:"--from <target>",description:"Source tool ID to convert from (required)"},{name:"--to <target>",description:"Destination tool ID to convert to (required)"},{name:"--global",description:"Convert user-level config (use home directory paths)"},{name:"--dry-run",description:"Preview conversion without writing files"}]},{name:"install",usage:"agentsmesh install <source> [flags]",description:"Install canonical resources from local/remote sources",flags:[{name:"<source>",description:"GitHub/GitLab/tree/blob URL, git+ URL, SSH, or local path"},{name:"--sync",description:"Reinstall missing packs recorded in .agentsmesh/installs.yaml"},{name:"--path <dir>",description:"Subdirectory inside source repo when not embedded in URL"},{name:"--target <id>",description:"Native format used for import-at-root discovery (same as extends.target)"},{name:"--as <kind>",description:"Manual collection mode: rules, commands, agents, or skills"},{name:"--name <id>",description:"Override generated install entry/pack name"},{name:"--extends",description:"Write install as extends entry instead of materialized pack"},{name:"--dry-run",description:"Preview only (no YAML write, no pack write, no generate)"},{name:"--global",description:"Install into ~/.agentsmesh/ and regenerate user-level config"},{name:"--force",description:"Non-interactive mode; include invalid resources and skip selection prompts (implied by --json)"}]},{name:"diff",usage:"agentsmesh diff [flags]",description:"Show patch-style output for what generate would change",flags:[{name:"--global",description:"Diff against outputs generated from ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit diff to target IDs (comma-separated)"}]},{name:"lint",usage:"agentsmesh lint [flags]",description:"Validate canonical files against target constraints",flags:[{name:"--global",description:"Lint canonical home config under ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit linting to target IDs (comma-separated)"}]},{name:"watch",usage:"agentsmesh watch [flags]",description:"Watch canonical files and regenerate on change",flags:[{name:"--global",description:"Watch ~/.agentsmesh/ and regenerate user-level config"},{name:"--targets <csv>",description:"Limit watched generate/matrix output to target IDs"}]},{name:"check",usage:"agentsmesh check",description:"Verify canonical files still match .agentsmesh/.lock",flags:[{name:"--global",description:"Check ~/.agentsmesh/.lock"}]},{name:"merge",usage:"agentsmesh merge",description:"Resolve .agentsmesh/.lock merge conflicts from current canonical state",flags:[{name:"--global",description:"Resolve ~/.agentsmesh/.lock conflicts"}]},{name:"matrix",usage:"agentsmesh matrix [flags]",description:"Print compatibility matrix for enabled features and targets",flags:[{name:"--global",description:"Show matrix for canonical home config under ~/.agentsmesh/"},{name:"--targets <csv>",description:"Limit matrix columns to target IDs"},{name:"--verbose",description:"Include expanded feature details in matrix output"}]},{name:"target",usage:"agentsmesh target scaffold <id> [--name <displayName>] [--force]",description:"Generate a new target skeleton (files, tests, fixture) under src/targets/<id>/.",flags:[{name:"--name <displayName>",description:"Human-readable name (defaults to id)"},{name:"--force",description:"Overwrite existing files"}]},{name:"plugin",usage:"agentsmesh plugin <add|list|remove|info> [args] [flags]",description:"Manage plugin-provided targets (npm packages exporting a TargetDescriptor).",flags:[{name:"--version <v>",description:"Pin plugin version (add)"},{name:"--id <id>",description:"Override derived plugin id (add)"}]},{name:"mcp",usage:"agentsmesh mcp",description:"Start the agentsmesh MCP server (stdio)",flags:[]}];function Ry(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
142
+ `)}s(Ry,"formatFlags");function ky(){let t=Sy.map(e=>`- ${e.name.padEnd(8)} ${e.description}
143
143
  Usage: ${e.usage}
144
- ${Sy(e.flags)}`).join(`
144
+ ${Ry(e.flags)}`).join(`
145
145
 
146
146
  `);I.info(`agentsmesh <command> [flags]
147
147
 
148
148
  Global flags:
149
- ${Sy(Iy)}
149
+ ${Ry(Cy)}
150
150
 
151
151
  Commands:
152
152
  ${t}
153
153
 
154
- Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(Ry,"printHelp");var cT=createRequire(import.meta.url),Yp=dirname(fileURLToPath(import.meta.url)),lT=Yp.endsWith("dist")?join(Yp,"..","package.json"):join(Yp,"..","..","package.json"),Oy=cT(lT);function tl(){return Oy.version}s(tl,"getVersion");function wy(){process.stdout.write(`agentsmesh v${Oy.version}
154
+ Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(ky,"printHelp");var el;function pT(){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(pT,"readPackageVersion");function uT(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(uT,"getVersionFallback");function Sa(){return el||(el=pT()??uT(),el)}s(Sa,"getVersion");function wy(){process.stdout.write(`agentsmesh v${Sa()}
155
155
  `);}s(wy,"printVersion");nt();function Js(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)+`
156
156
  `);}s(Js,"emitJson");var kr=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function Ey(t,e){let r=t instanceof kr?2:1;if(e?.json)return Js(e.command??"unknown",{success:false,error:t.message}),process.exit(r);e?.verbose&&t.stack?process.stderr.write(t.stack+`
157
- `):I.error(t.message),process.exit(r);}s(Ey,"handleError");nt();function ce(t,e,r,n){if(r.json===true){let o=e.exitCode===0;Js(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(ce,"handleResult");le();nn();A();function Nc(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(Nc,"hashContent");async function up(t){try{let e=await readFile(t,"utf8");return Nc(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(up,"hashFile");pp();var Bg=".lock",nj=[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 oj(t){return t.startsWith("packs/")?false:nj.some(e=>e(t))}s(oj,"isCanonical");var sj={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 dp(t){let e=join(t,Bg),r=await y(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(dp,"readLock");async function fp(t,e){let r=join(t,Bg),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.
157
+ `):I.error(t.message),process.exit(r);}s(Ey,"handleError");nt();function ce(t,e,r,n){if(r.json===true){let o=e.exitCode===0;Js(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(ce,"handleResult");le();nn();A();function Fc(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(Fc,"hashContent");async function dp(t){try{let e=await readFile(t,"utf8");return Fc(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(dp,"hashFile");up();var Bg=".lock",ij=[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 aj(t){return t.startsWith("packs/")?false:ij.some(e=>e(t))}s(aj,"isCanonical");var cj={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 fp(t){let e=join(t,Bg),r=await y(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(fp,"readLock");async function gp(t,e){let r=join(t,Bg),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.
158
158
  # Tracks the state of all config files for team conflict resolution.
159
159
 
160
- `+stringify(n);await S(r,o);}s(fp,"writeLock");async function Hn(t){if(!await v(t))return {};let e=await N(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===Bg||!oj(o))continue;let i=await up(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(Hn,"buildChecksums");function gp(t,e,r){if(r.length===0)return [];let n=r.map(a=>sj[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(c=>c(a))&&t[a]!==e[a]&&i.push(a);return i}s(gp,"detectLockedFeatureViolations");async function hp(t){let e=await mp(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(hp,"buildPackChecksums");async function oa(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 Hn(n),i=Object.keys(o).sort().map(l=>`${l}:${o[l]}`).join(`
161
- `),a=Nc(i),c=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${c}`;}return e}s(oa,"buildExtendChecksums");ut();ye();function ij(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(ij,"addDirectoryMapping");function Tb(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)ij(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}s(Tb,"addSkillDirectoryMappings");ut();function Db(t,e,r="project"){let n=Tt(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(Db,"ruleTargetPath");function Nb(t,e,r,n="project"){let o=Tt(t,n);return o?o.paths.commandPath(e,r):null}s(Nb,"commandTargetPath");function Fb(t,e,r,n="project"){let o=Tt(t,n);return o?o.paths.agentPath(e,r):null}s(Fb,"agentTargetPath");Vt();Pt();te();ut();function lj(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(lj,"addDirectoryMapping");function Fc(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let c=Db(t,a,n);c&&o.set(`.agentsmesh/rules/${basename(a.source)}`,c);}for(let a of e.commands){let c=Nb(t,a.name,r,n);c&&o.set(`.agentsmesh/commands/${a.name}.md`,c);}for(let a of e.agents){let c=Fb(t,a.name,r,n);c&&o.set(`.agentsmesh/agents/${a.name}.md`,c);}let i=Ec(t,n);if(!i)return o;for(let a of e.skills){lj(o,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let c of a.supportingFiles){let l=c.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${l}`,p=`${i}/${a.name}/${l}`;o.set(m,p),Tb(o,m,p);}}return o}s(Fc,"buildReferenceMap");ze();var zn="AGENTS.md";function mj(t){return t.target===Sa&&t.path.endsWith(zn)}s(mj,"isCodexAgents");function vb(t){return t.target==="windsurf"&&t.path.endsWith(zn)}s(vb,"isWindsurfAgents");function Mb(t){return t.target==="cline"&&t.path.endsWith(zn)}s(Mb,"isClineAgents");function Hg(t){return t.target==="cursor"&&t.path.endsWith(zn)}s(Hg,"isCursorAgents");function zg(t){return t.target==="gemini-cli"&&t.path.endsWith(zn)}s(zg,"isGeminiAgents");function pj(t){return t.target==="kiro"&&t.path.endsWith(zn)}s(pj,"isKiroAgents");function uj(t){return t.target==="kilo-code"&&t.path.endsWith(zn)}s(uj,"isKiloCodeAgents");function $b(t){return t.target==="warp"&&t.path.endsWith(zn)}s($b,"isWarpAgents");function dj(t){return Hg(t)||zg(t)}s(dj,"isCompatibilityAgents");function _p(t,e,r,n){let o=n.get(t);if(o)return o;let i=new Map;for(let[a,c]of Fc(t,e,r))i.has(c)||i.set(c,a);return n.set(t,i),i}s(_p,"reverseReferenceMap");function Ip(t,e){let r=[...e.entries()].sort(([o],[i])=>i.length-o.length),n=t;for(let[o,i]of r)n=n.split(o).join(i);return n}s(Ip,"normalizeContent");function fj(t,e,r,n,o){let i=_p(t.target,r,n,o),a=_p(e.target,r,n,o);return Ip(t.content,i)===Ip(e.content,a)}s(fj,"hasEquivalentCanonicalContent");function gj(t,e,r,n,o){let i=_p(t.target,r,n,o),a=_p(e.target,r,n,o),c=Ip(t.content,i).trim(),l=Ip(e.content,a).trim();return c.length>l.length&&c.includes(l)}s(gj,"hasCanonicalSupersetContent");function Gb(t,e,r){let n=new Map;for(let a of t){if(!a.path.endsWith(zn))continue;let c=n.get(a.path)??new Set;c.add(a.target),n.set(a.path,c);}let o=new Map;for(let a of t)mj(a)&&o.set(a.path,a);let i=new Map;return t.filter(a=>{if(Hg(a)){let l=n.get(a.path);if(l&&[...l].some(m=>m!=="cursor"))return false}if(zg(a)){let l=n.get(a.path);if(l&&[...l].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!vb(a)&&!Mb(a)&&!Hg(a)&&!zg(a)&&!pj(a)&&!uj(a)&&!$b(a))return true;let c=o.get(a.path);return c?dj(a)||vb(a)||Mb(a)||$b(a)?false:!(fj(c,a,e,r,i)||gj(c,a,e,r,i)):true})}s(Gb,"preferEquivalentCodexAgents");Wt();Tg();Wt();Wt();ut();function Ub(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(Ub,"addPackAbsoluteDirMapping");function hj(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(hj,"skillSupportingDirPrefixes");function Kb(t,e,r,n,o){let i=Ec(e,o);if(!i)return;let a=Y(n),c=a.join(n,".agentsmesh","packs");for(let l of r.skills){let m=a.dirname(l.source);if(!m.startsWith(c))continue;let p=a.normalize(a.join(n,i,l.name));Ub(t,m,p,a),t.set(a.normalize(l.source),a.normalize(a.join(p,"SKILL.md")));for(let u of l.supportingFiles){let f=a.normalize(a.join(p,u.relativePath));t.set(a.normalize(u.absolutePath),f);}for(let u of hj(l.supportingFiles))Ub(t,a.join(m,u),a.join(p,u),a);}}s(Kb,"addPackSkillArtifactMappings");Wt();function yj(t){return `.agentsmesh/rules/${basename(t.source)}`}s(yj,"canonicalRulePath");function _j(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(_j,"copilotInstructionsPath");function Bb(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let i=Y(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,yj(a))),i.normalize(i.join(r,_j(a))));}s(Bb,"applyCopilotInstructionArtifactRefs");ut();function Cp(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Cp,"getAdditionalRootDecorationPaths");function Hb(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(Hb,"resolveRewriteFamilyId");function Vg(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(Vg,"pushUnique");function zb(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);Vg(o,i);let a=Tt(t,n);if(e.root)for(let c of Cp(a))Vg(o,c);for(let c of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])Vg(o,c);return o}s(zb,"extraRuleOutputPaths");ut();function Vb(t,e,r,n,o,i){let a=Tt(t,e);if(!a?.mirrorGlobalPath)return;let c=a.mirrorGlobalPath(r,i??[]),l=c===null?[]:Array.isArray(c)?c:[c];for(let m of l)m!==r&&o.set(m,n);}s(Vb,"addSkillMirrorSourceEntry");function Cj(t){return `.agentsmesh/commands/${t.name}.md`}s(Cj,"canonicalCommandPath");function Sj(t){return `.agentsmesh/agents/${t.name}.md`}s(Sj,"canonicalAgentPath");function Rj(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(Rj,"canonicalSkillPath");function Jb(t,e,r,n,o,i){let a=i?.scope??"project",c=Y(n),l=new Map([...Fc(t,e,r,a)].map(([m,p])=>[c.normalize(c.join(n,m)),c.normalize(c.join(n,p))]));return Bb(t,l,n,o,e),Kb(l,t,e,n,a),l}s(Jb,"buildArtifactPathMap");function Yb(t,e,r,n="project",o){let i=Fc(t,e,r,n),a=new Map;for(let c of e.rules)for(let l of zb(t,c,i,n))a.set(l,c.source);for(let c of e.commands){let l=i.get(Cj(c));l&&a.set(l,c.source);}for(let c of e.agents){let l=i.get(Sj(c));l&&a.set(l,c.source);}for(let c of e.skills){let l=i.get(Rj(c));l&&(a.set(l,c.source),Vb(t,n,l,c.source,a,o));for(let m of c.supportingFiles){let p=`.agentsmesh/skills/${c.name}/${m.relativePath.replace(/\\/g,"/")}`,u=i.get(p);u&&(a.set(u,m.absolutePath),Vb(t,n,u,m.absolutePath,a,o));}}return a}s(Yb,"buildOutputSourceMap");ut();ye();Iu();function wj(t,e){if(!e)return null;for(let r of e){let n=tt(r);if(n?.sharedArtifacts){for(let[o,i]of Object.entries(n.sharedArtifacts))if(i==="owner"&&t.startsWith(o))return r}}return null}s(wj,"findSharedArtifactOwner");function Xb(t,e,r){if(e==="global"){let n=wj(t.path,r);if(n)return n;let o=S_(t.path);if(o)return o}return t.target}s(Xb,"artifactMapTargetForResult");function Ej(t,e){return `${t}\0${(e??[]).join(",")}`}s(Ej,"sourceMapCacheKey");function Jg(t,e){let r=Y(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(Jg,"collectPlannedPaths");function Lj(t,e,r){let n=Tt(t.target,e),o=Hb(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=Xb(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(Lj,"artifactCacheKey");function Zb(t,e,r,n,o="project",i){let a=Jg(n,t),c=new Map,l=new Map;return t.map(m=>{let p=Ej(m.target,i),f=(l.get(p)??(()=>{let _=Yb(m.target,e,r,o,i);return l.set(p,_),_})()).get(m.path);if(!f)return m;let g=Xb(m,o,i),h=Lj(m,o,i),R=c.get(h)??(()=>{let _=Jb(g,e,r,n,m.path,{scope:o});return c.set(h,_),_})(),C=rp({content:m.content,projectRoot:n,sourceFile:f,destinationFile:Y(n).join(n,m.path),translatePath:s(_=>R.get(_)??_,"translatePath"),pathExists:s(_=>a.has(_)||existsSync(_),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:s(_=>{try{return statSync(_).isDirectory()}catch{return false}},"pathIsDirectory")});return C.content===m.content?m:{...m,content:C.content}})}s(Zb,"rewriteGeneratedReferences");Wt();Fo();var Aj=/!?\[[^\]]*\]\(([^)]+)\)/g,xj=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function Pj(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(Pj,"isMarkdownLikeOutput");function Tj(t,e){return e.some(([r,n])=>t>=r&&t<n)}s(Tj,"isOffsetInRanges");function Dj(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(Dj,"parseMarkdownLinkDestination");function Nj(t){let e=t.trim();return !e||e.startsWith("#")||/^https?:\/\//i.test(e)||/^mailto:/i.test(e)||/^data:/i.test(e)||/^javascript:/i.test(e)||/^ftp:/i.test(e)?true:/^[a-zA-Z]:[\\/]/.test(e)?false:!!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)}s(Nj,"shouldSkipLocalValidation");function Fj(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(Fj,"pathExistsForGenerate");function vj(t,e,r){let o=Dj(t).split("#")[0]??"",{candidate:i}=ni(o),a=i,c=ea.exec(a);c&&(a=a.slice(0,c.index));let l;try{l=decodeURIComponent(a);}catch{l=a;}if(Nj(l))return [];let m=Lc(l,e,r);if(m.length===0){let u=Y(e),f=K(e,r);m=[K(e,u.join(u.dirname(f),l)),K(e,u.join(e,l))];}let p=[];for(let u of m)for(let f of bc(e,u)){let g=K(e,f);p.includes(g)||p.push(g);}return p}s(vj,"resolveMarkdownLinkTargets");function Mj(t,e){let r=Jg(e,t),n=[];for(let o of t){if(!Pj(o.path))continue;let i=K(e,Y(e).join(e,o.path)),a=ep(o.content),c=s((l,m)=>{if(Tj(m,a))return;let p=vj(l,e,i);p.length!==0&&(p.some(u=>Fj(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:l.trim(),checkedPaths:p}));},"visitDestination");for(let l of o.content.matchAll(Aj)){let m=l[1];m!==void 0&&c(m,l.index??0);}for(let l of o.content.matchAll(xj)){let m=(l[1]??l[2]??"").trim();m&&c(m,l.index??0);}}return n}s(Mj,"findBrokenMarkdownLinks");function qb(t,e){let r=Mj(t,e);if(r.length===0)return;let n=r.map(o=>` ${o.generatePath} (${o.target}): "${o.rawLink}" \u2192 not found (tried: ${o.checkedPaths.join(", ")})`);throw new Error(`Generated markdown contains broken local links:
160
+ `+stringify(n);await S(r,o);}s(gp,"writeLock");async function Hn(t){if(!await v(t))return {};let e=await N(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===Bg||!aj(o))continue;let i=await dp(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(Hn,"buildChecksums");function hp(t,e,r){if(r.length===0)return [];let n=r.map(a=>cj[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(c=>c(a))&&t[a]!==e[a]&&i.push(a);return i}s(hp,"detectLockedFeatureViolations");async function yp(t){let e=await pp(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(yp,"buildPackChecksums");async function oa(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 Hn(n),i=Object.keys(o).sort().map(l=>`${l}:${o[l]}`).join(`
161
+ `),a=Fc(i),c=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${c}`;}return e}s(oa,"buildExtendChecksums");ut();ye();function lj(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(lj,"addDirectoryMapping");function Tb(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)lj(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}s(Tb,"addSkillDirectoryMappings");ut();function Db(t,e,r="project"){let n=Tt(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(Db,"ruleTargetPath");function Nb(t,e,r,n="project"){let o=Tt(t,n);return o?o.paths.commandPath(e,r):null}s(Nb,"commandTargetPath");function Fb(t,e,r,n="project"){let o=Tt(t,n);return o?o.paths.agentPath(e,r):null}s(Fb,"agentTargetPath");Vt();Pt();te();ut();function uj(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(uj,"addDirectoryMapping");function vc(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let c=Db(t,a,n);c&&o.set(`.agentsmesh/rules/${basename(a.source)}`,c);}for(let a of e.commands){let c=Nb(t,a.name,r,n);c&&o.set(`.agentsmesh/commands/${a.name}.md`,c);}for(let a of e.agents){let c=Fb(t,a.name,r,n);c&&o.set(`.agentsmesh/agents/${a.name}.md`,c);}let i=Lc(t,n);if(!i)return o;for(let a of e.skills){uj(o,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let c of a.supportingFiles){let l=c.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${l}`,p=`${i}/${a.name}/${l}`;o.set(m,p),Tb(o,m,p);}}return o}s(vc,"buildReferenceMap");ze();var zn="AGENTS.md";function dj(t){return t.target===Ra&&t.path.endsWith(zn)}s(dj,"isCodexAgents");function vb(t){return t.target==="windsurf"&&t.path.endsWith(zn)}s(vb,"isWindsurfAgents");function Mb(t){return t.target==="cline"&&t.path.endsWith(zn)}s(Mb,"isClineAgents");function Hg(t){return t.target==="cursor"&&t.path.endsWith(zn)}s(Hg,"isCursorAgents");function zg(t){return t.target==="gemini-cli"&&t.path.endsWith(zn)}s(zg,"isGeminiAgents");function fj(t){return t.target==="kiro"&&t.path.endsWith(zn)}s(fj,"isKiroAgents");function gj(t){return t.target==="kilo-code"&&t.path.endsWith(zn)}s(gj,"isKiloCodeAgents");function $b(t){return t.target==="warp"&&t.path.endsWith(zn)}s($b,"isWarpAgents");function hj(t){return Hg(t)||zg(t)}s(hj,"isCompatibilityAgents");function Ip(t,e,r,n){let o=n.get(t);if(o)return o;let i=new Map;for(let[a,c]of vc(t,e,r))i.has(c)||i.set(c,a);return n.set(t,i),i}s(Ip,"reverseReferenceMap");function Cp(t,e){let r=[...e.entries()].sort(([o],[i])=>i.length-o.length),n=t;for(let[o,i]of r)n=n.split(o).join(i);return n}s(Cp,"normalizeContent");function yj(t,e,r,n,o){let i=Ip(t.target,r,n,o),a=Ip(e.target,r,n,o);return Cp(t.content,i)===Cp(e.content,a)}s(yj,"hasEquivalentCanonicalContent");function _j(t,e,r,n,o){let i=Ip(t.target,r,n,o),a=Ip(e.target,r,n,o),c=Cp(t.content,i).trim(),l=Cp(e.content,a).trim();return c.length>l.length&&c.includes(l)}s(_j,"hasCanonicalSupersetContent");function Gb(t,e,r){let n=new Map;for(let a of t){if(!a.path.endsWith(zn))continue;let c=n.get(a.path)??new Set;c.add(a.target),n.set(a.path,c);}let o=new Map;for(let a of t)dj(a)&&o.set(a.path,a);let i=new Map;return t.filter(a=>{if(Hg(a)){let l=n.get(a.path);if(l&&[...l].some(m=>m!=="cursor"))return false}if(zg(a)){let l=n.get(a.path);if(l&&[...l].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!vb(a)&&!Mb(a)&&!Hg(a)&&!zg(a)&&!fj(a)&&!gj(a)&&!$b(a))return true;let c=o.get(a.path);return c?hj(a)||vb(a)||Mb(a)||$b(a)?false:!(yj(c,a,e,r,i)||_j(c,a,e,r,i)):true})}s(Gb,"preferEquivalentCodexAgents");Wt();Tg();Wt();Wt();ut();function Ub(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(Ub,"addPackAbsoluteDirMapping");function Ij(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(Ij,"skillSupportingDirPrefixes");function Kb(t,e,r,n,o){let i=Lc(e,o);if(!i)return;let a=Y(n),c=a.join(n,".agentsmesh","packs");for(let l of r.skills){let m=a.dirname(l.source);if(!m.startsWith(c))continue;let p=a.normalize(a.join(n,i,l.name));Ub(t,m,p,a),t.set(a.normalize(l.source),a.normalize(a.join(p,"SKILL.md")));for(let u of l.supportingFiles){let f=a.normalize(a.join(p,u.relativePath));t.set(a.normalize(u.absolutePath),f);}for(let u of Ij(l.supportingFiles))Ub(t,a.join(m,u),a.join(p,u),a);}}s(Kb,"addPackSkillArtifactMappings");Wt();function Cj(t){return `.agentsmesh/rules/${basename(t.source)}`}s(Cj,"canonicalRulePath");function Sj(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(Sj,"copilotInstructionsPath");function Bb(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let i=Y(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,Cj(a))),i.normalize(i.join(r,Sj(a))));}s(Bb,"applyCopilotInstructionArtifactRefs");ut();function Sp(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Sp,"getAdditionalRootDecorationPaths");function Hb(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(Hb,"resolveRewriteFamilyId");function Vg(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(Vg,"pushUnique");function zb(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);Vg(o,i);let a=Tt(t,n);if(e.root)for(let c of Sp(a))Vg(o,c);for(let c of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])Vg(o,c);return o}s(zb,"extraRuleOutputPaths");ut();function Vb(t,e,r,n,o,i){let a=Tt(t,e);if(!a?.mirrorGlobalPath)return;let c=a.mirrorGlobalPath(r,i??[]),l=c===null?[]:Array.isArray(c)?c:[c];for(let m of l)m!==r&&o.set(m,n);}s(Vb,"addSkillMirrorSourceEntry");function kj(t){return `.agentsmesh/commands/${t.name}.md`}s(kj,"canonicalCommandPath");function Oj(t){return `.agentsmesh/agents/${t.name}.md`}s(Oj,"canonicalAgentPath");function wj(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(wj,"canonicalSkillPath");function Jb(t,e,r,n,o,i){let a=i?.scope??"project",c=Y(n),l=new Map([...vc(t,e,r,a)].map(([m,p])=>[c.normalize(c.join(n,m)),c.normalize(c.join(n,p))]));return Bb(t,l,n,o,e),Kb(l,t,e,n,a),l}s(Jb,"buildArtifactPathMap");function Yb(t,e,r,n="project",o){let i=vc(t,e,r,n),a=new Map;for(let c of e.rules)for(let l of zb(t,c,i,n))a.set(l,c.source);for(let c of e.commands){let l=i.get(kj(c));l&&a.set(l,c.source);}for(let c of e.agents){let l=i.get(Oj(c));l&&a.set(l,c.source);}for(let c of e.skills){let l=i.get(wj(c));l&&(a.set(l,c.source),Vb(t,n,l,c.source,a,o));for(let m of c.supportingFiles){let p=`.agentsmesh/skills/${c.name}/${m.relativePath.replace(/\\/g,"/")}`,u=i.get(p);u&&(a.set(u,m.absolutePath),Vb(t,n,u,m.absolutePath,a,o));}}return a}s(Yb,"buildOutputSourceMap");ut();ye();Iu();function bj(t,e){if(!e)return null;for(let r of e){let n=tt(r);if(n?.sharedArtifacts){for(let[o,i]of Object.entries(n.sharedArtifacts))if(i==="owner"&&t.startsWith(o))return r}}return null}s(bj,"findSharedArtifactOwner");function Xb(t,e,r){if(e==="global"){let n=bj(t.path,r);if(n)return n;let o=S_(t.path);if(o)return o}return t.target}s(Xb,"artifactMapTargetForResult");function Aj(t,e){return `${t}\0${(e??[]).join(",")}`}s(Aj,"sourceMapCacheKey");function Jg(t,e){let r=Y(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(Jg,"collectPlannedPaths");function xj(t,e,r){let n=Tt(t.target,e),o=Hb(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=Xb(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(xj,"artifactCacheKey");function Zb(t,e,r,n,o="project",i){let a=Jg(n,t),c=new Map,l=new Map;return t.map(m=>{let p=Aj(m.target,i),f=(l.get(p)??(()=>{let _=Yb(m.target,e,r,o,i);return l.set(p,_),_})()).get(m.path);if(!f)return m;let g=Xb(m,o,i),h=xj(m,o,i),R=c.get(h)??(()=>{let _=Jb(g,e,r,n,m.path,{scope:o});return c.set(h,_),_})(),C=np({content:m.content,projectRoot:n,sourceFile:f,destinationFile:Y(n).join(n,m.path),translatePath:s(_=>R.get(_)??_,"translatePath"),pathExists:s(_=>a.has(_)||existsSync(_),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:s(_=>{try{return statSync(_).isDirectory()}catch{return false}},"pathIsDirectory")});return C.content===m.content?m:{...m,content:C.content}})}s(Zb,"rewriteGeneratedReferences");Wt();Fo();var Tj=/!?\[[^\]]*\]\(([^)]+)\)/g,Dj=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function Nj(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(Nj,"isMarkdownLikeOutput");function Fj(t,e){return e.some(([r,n])=>t>=r&&t<n)}s(Fj,"isOffsetInRanges");function vj(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(vj,"parseMarkdownLinkDestination");function Mj(t){let e=t.trim();return !e||e.startsWith("#")||/^https?:\/\//i.test(e)||/^mailto:/i.test(e)||/^data:/i.test(e)||/^javascript:/i.test(e)||/^ftp:/i.test(e)?true:/^[a-zA-Z]:[\\/]/.test(e)?false:!!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)}s(Mj,"shouldSkipLocalValidation");function $j(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s($j,"pathExistsForGenerate");function Gj(t,e,r){let o=vj(t).split("#")[0]??"",{candidate:i}=ni(o),a=i,c=ea.exec(a);c&&(a=a.slice(0,c.index));let l;try{l=decodeURIComponent(a);}catch{l=a;}if(Mj(l))return [];let m=bc(l,e,r);if(m.length===0){let u=Y(e),f=K(e,r);m=[K(e,u.join(u.dirname(f),l)),K(e,u.join(e,l))];}let p=[];for(let u of m)for(let f of Ac(e,u)){let g=K(e,f);p.includes(g)||p.push(g);}return p}s(Gj,"resolveMarkdownLinkTargets");function jj(t,e){let r=Jg(e,t),n=[];for(let o of t){if(!Nj(o.path))continue;let i=K(e,Y(e).join(e,o.path)),a=rp(o.content),c=s((l,m)=>{if(Fj(m,a))return;let p=Gj(l,e,i);p.length!==0&&(p.some(u=>$j(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:l.trim(),checkedPaths:p}));},"visitDestination");for(let l of o.content.matchAll(Tj)){let m=l[1];m!==void 0&&c(m,l.index??0);}for(let l of o.content.matchAll(Dj)){let m=(l[1]??l[2]??"").trim();m&&c(m,l.index??0);}}return n}s(jj,"findBrokenMarkdownLinks");function qb(t,e){let r=jj(t,e);if(r.length===0)return;let n=r.map(o=>` ${o.generatePath} (${o.target}): "${o.rawLink}" \u2192 not found (tried: ${o.checkedPaths.join(", ")})`);throw new Error(`Generated markdown contains broken local links:
162
162
  ${n.join(`
163
163
  `)}
164
- Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(qb,"validateGeneratedMarkdownLinks");ze();var tA="AGENTS.md";function Qb(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(Qb,"statusRank");function $j(t,e){return Qb(e.status)<=Qb(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s($j,"mergeDuplicateMetadata");function Sp(t){return t.trim()}s(Sp,"trimmedContent");function Gj(t,e){if(!t.path.endsWith(tA)||t.path!==e.path)return null;let r=Sp(t.content),n=Sp(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);return o===i?null:o?t:e}s(Gj,"richerAgentsResult");function jj(t,e){if(!t.path.endsWith(tA)||t.path!==e.path)return null;let r=t.target===Sa?t:e.target===Sa?e:null,n=r===t?e:t;if(!r)return null;let o=Sp(r.content).length,i=Sp(n.content).length;return o===i?null:o>i?r:n}s(jj,"richerCodexAgentsResult");function Rp(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=Gj(o,r);if(i){e[n]=i;continue}let a=jj(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]=$j(o,r);}return e}s(Rp,"resolveOutputCollisions");function eA(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(eA,"refreshResultStatus");A();ut();ye();function nA(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(nA,"computeStatus");function Uj(t,e,r){let n=Rg(t,e,r);if(n!==null)return n;let o=tt(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(Uj,"resolveGeneratedOutputPath");async function vc(t,e,r,n,o,i){let a=Uj(e,r.path,o);if(a===null)return null;let c=await y(join(n,a)),l=t.findIndex(u=>u.path===a&&u.target===e),m=l>=0?t[l]:void 0,p=i?.mergeContent?.(c,m,r.content,a)??r.content;return l>=0&&t.splice(l,1),t.push({target:e,path:a,content:p,currentContent:c??void 0,status:nA(c,p)}),a}s(vc,"emitGeneratedOutput");function Yg(t,e,r){return {capability:Po(t,r)?.[e]??{level:"none"},scope:r}}s(Yg,"featureContext");async function Gs(t,e,r,n,o,i,a,c){if(o)for(let l of e){let m=c(l);if(!m)continue;let p=Yg(l,a,i);for(let u of m(r,p)){let f=await vc(t,l,u,n,i);if(f===null)continue;let g=Tt(l,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),R=h===null?[]:Array.isArray(h)?h:[h];for(let C of R){let _=await y(join(n,C));t.push({target:l,path:C,content:u.content,currentContent:_??void 0,status:nA(_,u.content)});}}}}}s(Gs,"generateFeature");Ou();ut();function Kj(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Cp(t)]:[]}s(Kj,"rootDecorationPaths");function oA(t,e,r="project"){return t.map(n=>{let o=Tt(n.target,r);if(!o)return n;let i=Kj(o);if(i.length===0||!i.includes(n.path))return n;let c=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,l=x_(c);return l===n.content?n:{...n,content:l}})}s(oA,"decoratePrimaryRootInstructions");ut();ye();vf();function Xg(t,e,r,n,o){let a=($e(t)??tt(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let c=r?.content??e;return c!==null&&BO.includes(o)?zO(c,n):n}s(Xg,"mergeOutputContent");async function sA(t,e,r,n,o){for(let i of e){let a=ta(i,"permissions",void 0,o)??tt(i)?.generators.generatePermissions;if(a)for(let c of a(r))await vc(t,i,c,n,o,{mergeContent:s((l,m,p,u)=>Xg(i,l,m,p,u),"mergeContent")});}}s(sA,"generatePermissionsFeature");async function iA(t,e,r,n,o,i){for(let a of e){let c=ta(a,"hooks",i,o)??tt(a)?.generators.generateHooks;if(!c)continue;let l=Yg(a,"hooks",o),m=[...c(r,l)],u=($e(a)??tt(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let f of m)await vc(t,a,f,n,o,{mergeContent:s((g,h,R,C)=>Xg(a,g,h,R,C),"mergeContent")});}}s(iA,"generateHooksFeature");async function aA(t,e,r,n,o){for(let i of e){let c=($e(i)??tt(i))?.emitScopedSettings;if(!c)continue;let l=c(r,o);if(l.length!==0)for(let m of l)await vc(t,i,m,n,o,{mergeContent:s((p,u,f,g)=>Xg(i,p,u,f,g),"mergeContent")});}}s(aA,"generateScopedSettingsFeature");async function je(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],c=i?a.filter(x=>i.includes(x)):a;function l(x,Z){return ta(x,Z,e,o)}s(l,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),u=e.features.includes("agents"),f=e.features.includes("skills"),g=e.features.includes("mcp"),h=e.features.includes("permissions"),R=e.features.includes("hooks"),C=e.features.includes("ignore"),_=[];await Gs(_,c,r,n,m,o,"rules",x=>l(x,"rules")),await Gs(_,c,r,n,p,o,"commands",x=>l(x,"commands")),await Gs(_,c,r,n,u,o,"agents",x=>l(x,"agents")),await Gs(_,c,r,n,f,o,"skills",x=>l(x,"skills")),await Gs(_,c,r,n,g,o,"mcp",x=>l(x,"mcp")),h&&await sA(_,c,r,n,o),R&&await iA(_,c,r,n,o,e),await Gs(_,c,r,n,C,o,"ignore",x=>l(x,"ignore"));let E=new Set(e.features);for(let x of c){let B=($e(x)??tt(x))?.globalSupport?.scopeExtras;if(B){let J=await B(r,n,o,E);_.push(...J);}}(g||C||R||u||h)&&await aA(_,c,r,n,o);let T=oA(_,r,o),D=Zb(T,r,e,n,o,c);return qb(D,n),Rp(Gb(D.map(eA),r,e))}s(je,"generate");Vn();nt();A();qn();var tU=6e4,eU=30,rU=200,nU=2e3;async function uA(t,e={}){let r=e.retries??eU,n=e.retryDelayMs??rU,o=e.staleMs??tU;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await oU(t);if(a)return a;let c=await sU(t);if(c!=="young"&&iU(c,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let l=c==="young"?null:c;throw new Xs(t,cU(l))}i++,await mU(n);}}s(uA,"acquireProcessLock");async function oU(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:dA()};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(oU,"tryAcquire");async function sU(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return lU(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<nU)return "young"}catch{}return null}}s(sU,"inspectLock");function iU(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==dA()?false:!aU(t.pid)}s(iU,"isStale");function aU(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(aU,"isProcessAlive");function cU(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(cU,"describeHolder");function lU(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(lU,"isLockMetadata");function dA(){return hostname()}s(dA,"getHostname");function mU(t){return new Promise(e=>setTimeout(e,t))}s(mU,"sleep");A();ut();async function fA(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 fA(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(fA,"listFiles");async function fU(t,e,r){if(r.has(e))return;let n=join(t,e);await v(n)&&await rm$1(n,{recursive:true,force:true});}s(fU,"removeIfStale");async function gA(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let i=Sg(o,n);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let c=join(t.projectRoot,a);if(await v(c))for(let l of await fA(c))r.add(`${a}/${l}`.replace(/\/+/g,"/"));}}}for(let o of r)await fU(t.projectRoot,o,e);}s(gA,"cleanupStaleGeneratedOutputs");function sa(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(sa,"ensurePathInsideRoot");La();A();nt();async function Qg(t,e){let r=await Hn(t.canonicalDir),n=e.length>0?await oa(e):{},o=await hp(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await fp(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:tl(),checksums:r,extends:n,packs:o});try{await Py(me(),join(t.configDir,".agentsmeshcache"));}catch(a){I.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(Qg,"writeLockFile");async function EA(t){let{mode:e,scope:r,dryRun:n,context:o,resolvedExtends:i,flags:a,root:c,options:l}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Op([])}};if(n||await Qg(o,i),l.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(Gc(),ah)),{renderMatrix:p}=await Promise.resolve().then(()=>(Uc(),ch)),u=await m(a,c);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:Op([])}}}s(EA,"handleEmptyResults");function LA(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:Op(r)}}}s(LA,"buildCheckResult");async function bA(t){let{results:e,dryRun:r,scope:n,mode:o,context:i,activeTargets:a,resolvedExtends:c,flags:l,root:m,options:p}=t,u=r?null:await uA(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let R=sa(i.rootBase,h.path,h.target);await S(R,h.content);}await gA({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:n}),await Qg(i,c);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(Gc(),ah)),{renderMatrix:R}=await Promise.resolve().then(()=>(Uc(),ch)),C=await h(l,m);R(C,{verbose:l.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:Op(f)}}}s(bA,"handleGenerateOrDryRun");function Op(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(Op,"buildSummary");async function ia(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,c=t.global===true?"global":"project",l=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(D=>D.trim()).filter(Boolean):void 0,u=o?"check":i?"dry-run":"generate",{config:f,context:g}=await lt(n,c);await Jt(f,n);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let D=await dp(g.canonicalDir);if(D!==null){let x=await Hn(g.canonicalDir),Z=gp(D.checksums,x,h);if(Z.length>0){I.error("Locked feature violation (strategy: lock). Modified files:");for(let B of Z)I.error(` ${B}`);throw I.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:R,resolvedExtends:C}=await ee(f,g.configDir,{refreshRemoteCache:l},g.canonicalDir),_=[...f.targets,...f.pluginTargets??[]];if(p){let D=p.filter(x=>!_.includes(x));if(D.length>0)throw new Error(`Unknown target(s) in --targets: ${D.join(", ")}. Available: ${_.join(", ")}`)}let E=p?_.filter(D=>p.includes(D)):_,T=await je({config:f,canonical:R,projectRoot:g.rootBase,scope:c,targetFilter:p});return T.length===0?EA({mode:u,scope:c,dryRun:i,context:g,resolvedExtends:C,flags:t,root:n,options:r}):o?LA(T,c):bA({results:T,dryRun:i,scope:c,mode:u,context:g,activeTargets:E,resolvedExtends:C,flags:t,root:n,options:r})}s(ia,"runGenerate");nt();function lh(t,e){return t==="global"?`~/${e}`:e}s(lh,"formatDisplayPath");function aa(t){let{data:e}=t,{scope:r,mode:n,files:o}=e;if(o.length===0){I.info("No files to generate (no root rule or rules feature disabled)."),n==="check"&&I.success("Generated files are in sync.");return}if(n==="check"){let l=o.filter(m=>m.status!=="unchanged");if(l.length===0){I.success("Generated files are in sync.");return}for(let m of l)I.error(`[check] ${m.status} ${lh(r,m.path)} (${m.target})`);I.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(n==="dry-run"){for(let l of o)I.info(`[dry-run] ${l.status} ${lh(r,l.path)} (${l.target})`);return}for(let l of o)(l.status==="created"||l.status==="updated")&&I.success(`${l.status} ${lh(r,l.path)}`);let{created:i,updated:a,unchanged:c}=e.summary;i>0||a>0?I.info(`Generated: ${i} created, ${a} updated, ${c} unchanged`):I.info(`Nothing changed. (${c} unchanged)`);}s(aa,"renderGenerate");A();ut();ze();var kU=["codex-cli"];function AA(){return it.filter(t=>!kU.includes(t))}s(AA,"starterInitTargetIds");var OU=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],wU=AA();function wp(t,e=wU){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
165
- `),n=OU.map(o=>` - ${o}`).join(`
164
+ Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(qb,"validateGeneratedMarkdownLinks");ze();var tA="AGENTS.md";function Qb(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(Qb,"statusRank");function Uj(t,e){return Qb(e.status)<=Qb(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(Uj,"mergeDuplicateMetadata");function Rp(t){return t.trim()}s(Rp,"trimmedContent");function Kj(t,e){if(!t.path.endsWith(tA)||t.path!==e.path)return null;let r=Rp(t.content),n=Rp(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);return o===i?null:o?t:e}s(Kj,"richerAgentsResult");function Wj(t,e){if(!t.path.endsWith(tA)||t.path!==e.path)return null;let r=t.target===Ra?t:e.target===Ra?e:null,n=r===t?e:t;if(!r)return null;let o=Rp(r.content).length,i=Rp(n.content).length;return o===i?null:o>i?r:n}s(Wj,"richerCodexAgentsResult");function kp(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=Kj(o,r);if(i){e[n]=i;continue}let a=Wj(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]=Uj(o,r);}return e}s(kp,"resolveOutputCollisions");function eA(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(eA,"refreshResultStatus");A();ut();ye();function nA(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(nA,"computeStatus");function Bj(t,e,r){let n=Rg(t,e,r);if(n!==null)return n;let o=tt(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(Bj,"resolveGeneratedOutputPath");async function Mc(t,e,r,n,o,i){let a=Bj(e,r.path,o);if(a===null)return null;let c=await y(join(n,a)),l=t.findIndex(u=>u.path===a&&u.target===e),m=l>=0?t[l]:void 0,p=i?.mergeContent?.(c,m,r.content,a)??r.content;return l>=0&&t.splice(l,1),t.push({target:e,path:a,content:p,currentContent:c??void 0,status:nA(c,p)}),a}s(Mc,"emitGeneratedOutput");function Yg(t,e,r){return {capability:Po(t,r)?.[e]??{level:"none"},scope:r}}s(Yg,"featureContext");async function Gs(t,e,r,n,o,i,a,c){if(o)for(let l of e){let m=c(l);if(!m)continue;let p=Yg(l,a,i);for(let u of m(r,p)){let f=await Mc(t,l,u,n,i);if(f===null)continue;let g=Tt(l,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),R=h===null?[]:Array.isArray(h)?h:[h];for(let C of R){let _=await y(join(n,C));t.push({target:l,path:C,content:u.content,currentContent:_??void 0,status:nA(_,u.content)});}}}}}s(Gs,"generateFeature");Ou();ut();function Hj(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Sp(t)]:[]}s(Hj,"rootDecorationPaths");function oA(t,e,r="project"){return t.map(n=>{let o=Tt(n.target,r);if(!o)return n;let i=Hj(o);if(i.length===0||!i.includes(n.path))return n;let c=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,l=x_(c);return l===n.content?n:{...n,content:l}})}s(oA,"decoratePrimaryRootInstructions");ut();ye();vf();function Xg(t,e,r,n,o){let a=($e(t)??tt(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let c=r?.content??e;return c!==null&&BO.includes(o)?zO(c,n):n}s(Xg,"mergeOutputContent");async function sA(t,e,r,n,o){for(let i of e){let a=ta(i,"permissions",void 0,o)??tt(i)?.generators.generatePermissions;if(a)for(let c of a(r))await Mc(t,i,c,n,o,{mergeContent:s((l,m,p,u)=>Xg(i,l,m,p,u),"mergeContent")});}}s(sA,"generatePermissionsFeature");async function iA(t,e,r,n,o,i){for(let a of e){let c=ta(a,"hooks",i,o)??tt(a)?.generators.generateHooks;if(!c)continue;let l=Yg(a,"hooks",o),m=[...c(r,l)],u=($e(a)??tt(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let f of m)await Mc(t,a,f,n,o,{mergeContent:s((g,h,R,C)=>Xg(a,g,h,R,C),"mergeContent")});}}s(iA,"generateHooksFeature");async function aA(t,e,r,n,o){for(let i of e){let c=($e(i)??tt(i))?.emitScopedSettings;if(!c)continue;let l=c(r,o);if(l.length!==0)for(let m of l)await Mc(t,i,m,n,o,{mergeContent:s((p,u,f,g)=>Xg(i,p,u,f,g),"mergeContent")});}}s(aA,"generateScopedSettingsFeature");async function je(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],c=i?a.filter(x=>i.includes(x)):a;function l(x,Z){return ta(x,Z,e,o)}s(l,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),u=e.features.includes("agents"),f=e.features.includes("skills"),g=e.features.includes("mcp"),h=e.features.includes("permissions"),R=e.features.includes("hooks"),C=e.features.includes("ignore"),_=[];await Gs(_,c,r,n,m,o,"rules",x=>l(x,"rules")),await Gs(_,c,r,n,p,o,"commands",x=>l(x,"commands")),await Gs(_,c,r,n,u,o,"agents",x=>l(x,"agents")),await Gs(_,c,r,n,f,o,"skills",x=>l(x,"skills")),await Gs(_,c,r,n,g,o,"mcp",x=>l(x,"mcp")),h&&await sA(_,c,r,n,o),R&&await iA(_,c,r,n,o,e),await Gs(_,c,r,n,C,o,"ignore",x=>l(x,"ignore"));let E=new Set(e.features);for(let x of c){let B=($e(x)??tt(x))?.globalSupport?.scopeExtras;if(B){let J=await B(r,n,o,E);_.push(...J);}}(g||C||R||u||h)&&await aA(_,c,r,n,o);let T=oA(_,r,o),D=Zb(T,r,e,n,o,c);return qb(D,n),kp(Gb(D.map(eA),r,e))}s(je,"generate");Vn();nt();A();qn();var oU=6e4,sU=30,iU=200,aU=2e3;async function gA(t,e={}){let r=e.retries??sU,n=e.retryDelayMs??iU,o=e.staleMs??oU;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await cU(t);if(a)return a;let c=await lU(t);if(c!=="young"&&mU(c,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let l=c==="young"?null:c;throw new Xs(t,uU(l))}i++,await fU(n);}}s(gA,"acquireProcessLock");async function cU(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:hA()};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(cU,"tryAcquire");async function lU(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return dU(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<aU)return "young"}catch{}return null}}s(lU,"inspectLock");function mU(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==hA()?false:!pU(t.pid)}s(mU,"isStale");function pU(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(pU,"isProcessAlive");function uU(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(uU,"describeHolder");function dU(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(dU,"isLockMetadata");function hA(){return hostname()}s(hA,"getHostname");function fU(t){return new Promise(e=>setTimeout(e,t))}s(fU,"sleep");A();ut();async function yA(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 yA(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(yA,"listFiles");async function _U(t,e,r){if(r.has(e))return;let n=join(t,e);await v(n)&&await rm$1(n,{recursive:true,force:true});}s(_U,"removeIfStale");async function _A(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let i=Sg(o,n);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let c=join(t.projectRoot,a);if(await v(c))for(let l of await yA(c))r.add(`${a}/${l}`.replace(/\/+/g,"/"));}}}for(let o of r)await _U(t.projectRoot,o,e);}s(_A,"cleanupStaleGeneratedOutputs");function sa(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(sa,"ensurePathInsideRoot");ba();A();nt();async function th(t,e){let r=await Hn(t.canonicalDir),n=e.length>0?await oa(e):{},o=await yp(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await gp(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:Sa(),checksums:r,extends:n,packs:o});try{await Py(me(),join(t.configDir,".agentsmeshcache"));}catch(a){I.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(th,"writeLockFile");async function AA(t){let{mode:e,scope:r,dryRun:n,context:o,resolvedExtends:i,flags:a,root:c,options:l}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:wp([])}};if(n||await th(o,i),l.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(jc(),ch)),{renderMatrix:p}=await Promise.resolve().then(()=>(Kc(),lh)),u=await m(a,c);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:wp([])}}}s(AA,"handleEmptyResults");function xA(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:wp(r)}}}s(xA,"buildCheckResult");async function PA(t){let{results:e,dryRun:r,scope:n,mode:o,context:i,activeTargets:a,resolvedExtends:c,flags:l,root:m,options:p}=t,u=r?null:await gA(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let R=sa(i.rootBase,h.path,h.target);await S(R,h.content);}await _A({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:n}),await th(i,c);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(jc(),ch)),{renderMatrix:R}=await Promise.resolve().then(()=>(Kc(),lh)),C=await h(l,m);R(C,{verbose:l.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:wp(f)}}}s(PA,"handleGenerateOrDryRun");function wp(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(wp,"buildSummary");async function ia(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,c=t.global===true?"global":"project",l=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(D=>D.trim()).filter(Boolean):void 0,u=o?"check":i?"dry-run":"generate",{config:f,context:g}=await lt(n,c);await Jt(f,n);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let D=await fp(g.canonicalDir);if(D!==null){let x=await Hn(g.canonicalDir),Z=hp(D.checksums,x,h);if(Z.length>0){I.error("Locked feature violation (strategy: lock). Modified files:");for(let B of Z)I.error(` ${B}`);throw I.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:R,resolvedExtends:C}=await ee(f,g.configDir,{refreshRemoteCache:l},g.canonicalDir),_=[...f.targets,...f.pluginTargets??[]];if(p){let D=p.filter(x=>!_.includes(x));if(D.length>0)throw new Error(`Unknown target(s) in --targets: ${D.join(", ")}. Available: ${_.join(", ")}`)}let E=p?_.filter(D=>p.includes(D)):_,T=await je({config:f,canonical:R,projectRoot:g.rootBase,scope:c,targetFilter:p});return T.length===0?AA({mode:u,scope:c,dryRun:i,context:g,resolvedExtends:C,flags:t,root:n,options:r}):o?xA(T,c):PA({results:T,dryRun:i,scope:c,mode:u,context:g,activeTargets:E,resolvedExtends:C,flags:t,root:n,options:r})}s(ia,"runGenerate");nt();function mh(t,e){return t==="global"?`~/${e}`:e}s(mh,"formatDisplayPath");function aa(t){let{data:e}=t,{scope:r,mode:n,files:o}=e;if(o.length===0){I.info("No files to generate (no root rule or rules feature disabled)."),n==="check"&&I.success("Generated files are in sync.");return}if(n==="check"){let l=o.filter(m=>m.status!=="unchanged");if(l.length===0){I.success("Generated files are in sync.");return}for(let m of l)I.error(`[check] ${m.status} ${mh(r,m.path)} (${m.target})`);I.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(n==="dry-run"){for(let l of o)I.info(`[dry-run] ${l.status} ${mh(r,l.path)} (${l.target})`);return}for(let l of o)(l.status==="created"||l.status==="updated")&&I.success(`${l.status} ${mh(r,l.path)}`);let{created:i,updated:a,unchanged:c}=e.summary;i>0||a>0?I.info(`Generated: ${i} created, ${a} updated, ${c} unchanged`):I.info(`Nothing changed. (${c} unchanged)`);}s(aa,"renderGenerate");A();ut();ze();var LU=["codex-cli"];function TA(){return it.filter(t=>!LU.includes(t))}s(TA,"starterInitTargetIds");var bU=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],AU=TA();function Ep(t,e=AU){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
165
+ `),n=bU.map(o=>` - ${o}`).join(`
166
166
  `);return `# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
167
167
  version: 1
168
168
  targets:
169
169
  ${r}
170
170
  features:
171
171
  ${n}
172
- `}s(wp,"buildConfig");var Ep=`---
172
+ `}s(Ep,"buildConfig");var Lp=`---
173
173
  root: true
174
174
  description: "Project rules"
175
175
  ---
@@ -178,7 +178,7 @@ description: "Project rules"
178
178
 
179
179
  Add your project-wide instructions here.
180
180
  This file is always included in AI tool context and synced to all configured tools.
181
- `,mh=`---
181
+ `,ph=`---
182
182
  description: "Example contextual rule \u2014 rename and customize"
183
183
  # targets: [claude-code, cursor] # limit to specific tools (optional)
184
184
  # globs: ["src/**/*.ts"] # activate only for matching files (optional)
@@ -187,14 +187,14 @@ description: "Example contextual rule \u2014 rename and customize"
187
187
  # Example Rule
188
188
 
189
189
  Replace this with your coding standards, conventions, or domain-specific guidelines.
190
- `,ph=`---
190
+ `,uh=`---
191
191
  description: "Example command \u2014 rename and customize"
192
192
  # allowed-tools: [Read, Grep, Glob, Bash]
193
193
  ---
194
194
 
195
195
  Describe the task for this command here.
196
196
  Commands are invoked on-demand (e.g. /example) with a focused tool set.
197
- `,uh=`---
197
+ `,dh=`---
198
198
  name: example-agent
199
199
  description: "Example subagent \u2014 rename and customize"
200
200
  # tools: [Read, Grep, Glob]
@@ -205,7 +205,7 @@ description: "Example subagent \u2014 rename and customize"
205
205
 
206
206
  Describe this agent's role and instructions here.
207
207
  Agents are specialized subagents with restricted tools and a specific purpose.
208
- `,dh=`---
208
+ `,fh=`---
209
209
  name: example-skill
210
210
  description: "Example skill \u2014 rename and customize"
211
211
  ---
@@ -214,7 +214,7 @@ description: "Example skill \u2014 rename and customize"
214
214
 
215
215
  Describe the skill procedure here.
216
216
  Skills are reusable multi-step procedures that commands and agents can reference.
217
- `,fh=`{
217
+ `,gh=`{
218
218
  "mcpServers": {
219
219
  // agentsmesh self-serve MCP server \u2014 exposes your canonical config to AI agents.
220
220
  // Lets agents introspect rules/commands/agents/skills and trigger generate.
@@ -241,7 +241,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
241
241
  // }
242
242
  }
243
243
  }
244
- `,gh=`# Lifecycle hooks \u2014 run shell commands before/after AI tool use
244
+ `,hh=`# Lifecycle hooks \u2014 run shell commands before/after AI tool use
245
245
  # Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
246
246
  # Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
247
247
  #
@@ -254,7 +254,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
254
254
  # - matcher: Edit|Write
255
255
  # type: command
256
256
  # command: npm test --passWithNoTests
257
- `,hh=`# Tool permission allow/deny lists
257
+ `,yh=`# Tool permission allow/deny lists
258
258
  #
259
259
  # allow:
260
260
  # - Bash(npm run:*)
@@ -270,14 +270,14 @@ Skills are reusable multi-step procedures that commands and agents can reference
270
270
  allow: []
271
271
  deny: []
272
272
  ask: []
273
- `,yh=`# Patterns ignored by all configured AI tools (gitignore syntax)
273
+ `,_h=`# Patterns ignored by all configured AI tools (gitignore syntax)
274
274
  #
275
275
  # node_modules/
276
276
  # dist/
277
277
  # .env*
278
278
  # *.log
279
279
  # coverage/
280
- `,xA=`# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
280
+ `,DA=`# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
281
281
  # Personal overrides \u2014 NOT committed to git
282
282
  # Uncomment and customize for your local setup:
283
283
 
@@ -296,27 +296,27 @@ ask: []
296
296
  # overrides:
297
297
  # claude-code:
298
298
  # model: opus
299
- `;A();ut();function PA(t){let e=[];for(let r of Ft)for(let n of Cg(r.id,t))e.push({target:r.id,path:n});return e}s(PA,"collectDetectionPaths");function TA(t){let e=new Map;for(let{target:r,path:n}of PA(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}s(TA,"toolIndicators");TA("project");async function DA(t,e="project"){let r=[];for(let{id:n,paths:o}of TA(e))for(let i of o){let a=join(t,i);if(await v(a)){r.push(n);break}}return [...new Set(r)]}s(DA,"detectExistingConfigs");A();nt();function Ut(t,e){return join(t,e)}s(Ut,"ab");async function _h(t){return await v(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(_h,"countMdFiles");async function LU(t){let e=Ut(t,"skills");if(!await v(e))return false;let r=await readdir(e,{withFileTypes:true});for(let n of r)if(n.isDirectory()&&!n.name.startsWith("_")&&await v(join(e,n.name,"SKILL.md")))return true;return false}s(LU,"hasAnyImportedSkill");async function Ih(t){let e=Ut(t,"rules");await O(e),await S(join(e,"_root.md"),Ep),I.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),mh),I.success("Created .agentsmesh/rules/_example.md");let r=Ut(t,"commands");await O(r),await S(join(r,"_example.md"),ph),I.success("Created .agentsmesh/commands/_example.md");let n=Ut(t,"agents");await O(n),await S(join(n,"_example.md"),uh),I.success("Created .agentsmesh/agents/_example.md");let o=Ut(t,join("skills","_example"));await O(o),await S(join(o,"SKILL.md"),dh),I.success("Created .agentsmesh/skills/_example/SKILL.md"),await S(Ut(t,"mcp.json"),fh),I.success("Created .agentsmesh/mcp.json"),await S(Ut(t,"hooks.yaml"),gh),I.success("Created .agentsmesh/hooks.yaml"),await S(Ut(t,"permissions.yaml"),hh),I.success("Created .agentsmesh/permissions.yaml"),await S(Ut(t,"ignore"),yh),I.success("Created .agentsmesh/ignore");}s(Ih,"writeScaffoldFull");async function FA(t){let e=Ut(t,"rules"),r=await _h(e),n=join(e,"_root.md"),o=await v(n);await O(e),r===0?(await S(n,Ep),I.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),mh),I.success("Created .agentsmesh/rules/_example.md")):o||(await S(n,Ep),I.success("Created .agentsmesh/rules/_root.md"));let i=Ut(t,"commands");await _h(i)===0&&(await O(i),await S(join(i,"_example.md"),ph),I.success("Created .agentsmesh/commands/_example.md"));let a=Ut(t,"agents");if(await _h(a)===0&&(await O(a),await S(join(a,"_example.md"),uh),I.success("Created .agentsmesh/agents/_example.md")),!await LU(t)){let u=Ut(t,join("skills","_example"));await O(u),await S(join(u,"SKILL.md"),dh),I.success("Created .agentsmesh/skills/_example/SKILL.md");}let c=Ut(t,"mcp.json");await v(c)||(await S(c,fh),I.success("Created .agentsmesh/mcp.json"));let l=Ut(t,"hooks.yaml");await v(l)||(await S(l,gh),I.success("Created .agentsmesh/hooks.yaml"));let m=Ut(t,"permissions.yaml");await v(m)||(await S(m,hh),I.success("Created .agentsmesh/permissions.yaml"));let p=Ut(t,"ignore");await v(p)||(await S(p,yh),I.success("Created .agentsmesh/ignore"));}s(FA,"writeScaffoldGapFill");le();var Ch="agentsmesh.yaml",vA="agentsmesh.local.yaml",AU=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],xU=Object.fromEntries(Ft.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),MA=Ft.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function PU(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(PU,"isCoveredByExisting");async function TU(t){let e=join(t,".gitignore"),r=await y(e)??"",n=new Set(r.split(`
300
- `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=AU.filter(a=>!PU(a,n));if(o.length===0)return false;let i=r.endsWith(`
299
+ `;A();ut();function NA(t){let e=[];for(let r of Ft)for(let n of Cg(r.id,t))e.push({target:r.id,path:n});return e}s(NA,"collectDetectionPaths");function FA(t){let e=new Map;for(let{target:r,path:n}of NA(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}s(FA,"toolIndicators");FA("project");async function vA(t,e="project"){let r=[];for(let{id:n,paths:o}of FA(e))for(let i of o){let a=join(t,i);if(await v(a)){r.push(n);break}}return [...new Set(r)]}s(vA,"detectExistingConfigs");A();nt();function Ut(t,e){return join(t,e)}s(Ut,"ab");async function Ih(t){return await v(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(Ih,"countMdFiles");async function PU(t){let e=Ut(t,"skills");if(!await v(e))return false;let r=await readdir(e,{withFileTypes:true});for(let n of r)if(n.isDirectory()&&!n.name.startsWith("_")&&await v(join(e,n.name,"SKILL.md")))return true;return false}s(PU,"hasAnyImportedSkill");async function Ch(t){let e=Ut(t,"rules");await O(e),await S(join(e,"_root.md"),Lp),I.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),ph),I.success("Created .agentsmesh/rules/_example.md");let r=Ut(t,"commands");await O(r),await S(join(r,"_example.md"),uh),I.success("Created .agentsmesh/commands/_example.md");let n=Ut(t,"agents");await O(n),await S(join(n,"_example.md"),dh),I.success("Created .agentsmesh/agents/_example.md");let o=Ut(t,join("skills","_example"));await O(o),await S(join(o,"SKILL.md"),fh),I.success("Created .agentsmesh/skills/_example/SKILL.md"),await S(Ut(t,"mcp.json"),gh),I.success("Created .agentsmesh/mcp.json"),await S(Ut(t,"hooks.yaml"),hh),I.success("Created .agentsmesh/hooks.yaml"),await S(Ut(t,"permissions.yaml"),yh),I.success("Created .agentsmesh/permissions.yaml"),await S(Ut(t,"ignore"),_h),I.success("Created .agentsmesh/ignore");}s(Ch,"writeScaffoldFull");async function $A(t){let e=Ut(t,"rules"),r=await Ih(e),n=join(e,"_root.md"),o=await v(n);await O(e),r===0?(await S(n,Lp),I.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),ph),I.success("Created .agentsmesh/rules/_example.md")):o||(await S(n,Lp),I.success("Created .agentsmesh/rules/_root.md"));let i=Ut(t,"commands");await Ih(i)===0&&(await O(i),await S(join(i,"_example.md"),uh),I.success("Created .agentsmesh/commands/_example.md"));let a=Ut(t,"agents");if(await Ih(a)===0&&(await O(a),await S(join(a,"_example.md"),dh),I.success("Created .agentsmesh/agents/_example.md")),!await PU(t)){let u=Ut(t,join("skills","_example"));await O(u),await S(join(u,"SKILL.md"),fh),I.success("Created .agentsmesh/skills/_example/SKILL.md");}let c=Ut(t,"mcp.json");await v(c)||(await S(c,gh),I.success("Created .agentsmesh/mcp.json"));let l=Ut(t,"hooks.yaml");await v(l)||(await S(l,hh),I.success("Created .agentsmesh/hooks.yaml"));let m=Ut(t,"permissions.yaml");await v(m)||(await S(m,yh),I.success("Created .agentsmesh/permissions.yaml"));let p=Ut(t,"ignore");await v(p)||(await S(p,_h),I.success("Created .agentsmesh/ignore"));}s($A,"writeScaffoldGapFill");le();var Sh="agentsmesh.yaml",GA="agentsmesh.local.yaml",DU=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],NU=Object.fromEntries(Ft.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),jA=Ft.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function FU(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(FU,"isCoveredByExisting");async function vU(t){let e=join(t,".gitignore"),r=await y(e)??"",n=new Set(r.split(`
300
+ `).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=DU.filter(a=>!FU(a,n));if(o.length===0)return false;let i=r.endsWith(`
301
301
  `)||r===""?"":`
302
302
  `;return await S(e,r+i+o.join(`
303
303
  `)+`
304
- `),true}s(TU,"appendToGitignore");async function $A(t,e={}){let r=e.global===true?"global":"project",n=Oa(t,r),o=join(n.configDir,Ch);if(await v(o))throw new Error(`Already initialized. ${Ch} exists. Remove it first to re-init.`);let i=await DA(n.rootBase,r),a=r==="global"?i.filter(g=>MA.includes(g)):i,c=r==="global"?MA:void 0,l=[],m,p=0;if(a.length>0)if(e.yes){for(let g of a){let h=xU[g];if(!h)continue;let R=await h(n.rootBase,r);for(let C of R)l.push({from:relative(n.rootBase,C.fromPath).replaceAll("\\","/"),to:C.toPath.replaceAll("\\","/")});}p=a.length,await FA(n.canonicalDir),m="gap-fill",await S(o,wp(a,c));}else await Ih(n.canonicalDir),m="full",await S(o,wp([],c));else await Ih(n.canonicalDir),m="full",await S(o,wp([],c));let u=join(n.configDir,vA);await S(u,xA);let f=false;return r==="project"&&(f=await TU(t)),{exitCode:0,data:{scope:r,configFile:Ch,localConfigFile:vA,detectedConfigs:a,imported:l,importedToolCount:p,scaffoldType:m,gitignoreUpdated:f}}}s($A,"runInit");nt();function GA(t){let{data:e}=t;if(e.detectedConfigs.length>0&&I.info(`Found existing configurations: ${e.detectedConfigs.join(", ")}`),e.detectedConfigs.length>0&&e.imported.length===0&&I.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),e.imported.length>0){I.info("Auto-importing existing configurations (--yes)...");for(let n of e.imported)I.success(` ${n.from} \u2192 ${n.to}`);I.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(", ")})`:"";I.success(`Created ${e.configFile}${r}`),I.success(`Created ${e.localConfigFile}`),e.gitignoreUpdated&&I.success("Updated .gitignore");}s(GA,"renderInit");le();ut();var DU=Object.fromEntries(Ft.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Lp(t){let e=DU[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}s(Lp,"getTargetCatalogEntry");ye();Vn();ba();var GU={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function jU(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=GU,true)}s(jU,"injectAgentsmeshEntry");async function Rh(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await Ve(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!jU(r))return !1;let n=JSON.stringify(r,null,2)+`
304
+ `),true}s(vU,"appendToGitignore");async function UA(t,e={}){let r=e.global===true?"global":"project",n=wa(t,r),o=join(n.configDir,Sh);if(await v(o))throw new Error(`Already initialized. ${Sh} exists. Remove it first to re-init.`);let i=await vA(n.rootBase,r),a=r==="global"?i.filter(g=>jA.includes(g)):i,c=r==="global"?jA:void 0,l=[],m,p=0;if(a.length>0)if(e.yes){for(let g of a){let h=NU[g];if(!h)continue;let R=await h(n.rootBase,r);for(let C of R)l.push({from:relative(n.rootBase,C.fromPath).replaceAll("\\","/"),to:C.toPath.replaceAll("\\","/")});}p=a.length,await $A(n.canonicalDir),m="gap-fill",await S(o,Ep(a,c));}else await Ch(n.canonicalDir),m="full",await S(o,Ep([],c));else await Ch(n.canonicalDir),m="full",await S(o,Ep([],c));let u=join(n.configDir,GA);await S(u,DA);let f=false;return r==="project"&&(f=await vU(t)),{exitCode:0,data:{scope:r,configFile:Sh,localConfigFile:GA,detectedConfigs:a,imported:l,importedToolCount:p,scaffoldType:m,gitignoreUpdated:f}}}s(UA,"runInit");nt();function KA(t){let{data:e}=t;if(e.detectedConfigs.length>0&&I.info(`Found existing configurations: ${e.detectedConfigs.join(", ")}`),e.detectedConfigs.length>0&&e.imported.length===0&&I.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),e.imported.length>0){I.info("Auto-importing existing configurations (--yes)...");for(let n of e.imported)I.success(` ${n.from} \u2192 ${n.to}`);I.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(", ")})`:"";I.success(`Created ${e.configFile}${r}`),I.success(`Created ${e.localConfigFile}`),e.gitignoreUpdated&&I.success("Updated .gitignore");}s(KA,"renderInit");le();ut();var MU=Object.fromEntries(Ft.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function bp(t){let e=MU[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}s(bp,"getTargetCatalogEntry");ye();Vn();Aa();var WU={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function BU(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=WU,true)}s(BU,"injectAgentsmeshEntry");async function kh(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await Ve(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!BU(r))return !1;let n=JSON.stringify(r,null,2)+`
305
305
  `;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)}
306
- `),false}}s(Rh,"seedAgentsmeshMcpEntry");function jA(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(jA,"mapResults");async function UA(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(He(o)){let p=Oa(r,i),f=await Lp(o).importFrom(p.rootBase,{scope:i});return f.length>0&&await Rh(p.rootBase),{exitCode:0,data:{scope:i,target:o,files:jA(f,p.rootBase)}}}let a,c;try{({config:a,context:c}=await lt(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: ${it.join(", ")}.`)}await Jt(a,r);let l=tt(o);if(!l)throw new Error(`Unknown --from "${n}". Supported: ${[...it,...a.pluginTargets??[]].join(", ")}.`);let m=await l.generators.importFrom(c.rootBase,{scope:i});return m.length>0&&await Rh(c.rootBase),{exitCode:0,data:{scope:i,target:o,files:jA(m,c.rootBase)}}}s(UA,"runImport");le();nn();function bp(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(bp,"computeDiff");function Ap(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(Ap,"formatDiffSummary");Vn();async function WA(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:c}=await lt(r,n);await Jt(a,r);let{canonical:l}=await ee(a,c.configDir,{},c.canonicalDir),m=await je({config:a,canonical:l,projectRoot:c.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}=bp(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(WA,"runDiff");le();nn();A();ye();Vo();bt();var KU=[{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 BA(t){let e=new Set(t.enabledFeatures),r=[];for(let n of KU)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Xe(t.capabilities[n.capabilityKey]).level!=="none"||r.push(U(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(BA,"lintSilentFeatureDrops");bt();var WU=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function BU(t){let r=t.match(WU)?.groups?.path;return typeof r=="string"?r:null}s(BU,"extractScriptToken");function HA(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=BU(o.command);i&&r.push(U(".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(HA,"lintHookScriptReferences");bt();function zA(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(U(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(zA,"lintRuleScopeInversion");var HU=["node_modules",".git","dist","coverage",".agentsmesh"];async function zU(t){return (await N(t)).filter(n=>{let o=relative(t,n);return !HU.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(zU,"getProjectFiles");async function xp(t,e,r,n,o={}){let i=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],c=n?a.filter(C=>n.includes(C)):a,l=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 zU(r);for(let C of c){let _=tt(C),E=He(C)?Lp(C):_;E?.capabilities&&g.push(...BA({target:C,capabilities:E.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...HA({target:C,canonical:e,hasScriptProjection:_?.postProcessHookOutputs!==void 0})),l&&g.push(...zA({target:C,canonical:e,preservesManualActivation:_?.preservesManualActivation===true})),l&&E?.lintRules&&g.push(...E.lintRules(e,r,h,{scope:i})),_?.generators.lint&&g.push(..._.generators.lint(e));let T={scope:i};m&&E?.lint?.commands&&g.push(...E.lint.commands(e,T)),p&&E?.lint?.mcp&&g.push(...E.lint.mcp(e,T)),u&&E?.lint?.permissions&&g.push(...E.lint.permissions(e,T)),f&&E?.lint?.hooks&&g.push(...E.lint.hooks(e,T));}let R=g.some(C=>C.level==="error");return {diagnostics:g,hasErrors:R}}s(xp,"runLint");Vn();async function JA(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:c}=await lt(r,n);await Jt(a,r);let{canonical:l}=await ee(a,c.configDir,{},c.canonicalDir),{diagnostics:m,hasErrors:p}=await xp(a,l,c.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(JA,"runLintCmd");nt();function YA(t){let{data:e}=t;if(e.diagnostics.length===0){I.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),n=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)I.error(`${a.file} (${a.target}): ${a.message}`);for(let a of n)I.warn(`${a.file} (${a.target}): ${a.message}`);let o=e.summary.errors,i=e.summary.warnings;I.info(`${o} error${o!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(YA,"renderLint");nt();function XA(t){let{data:e}=t;if(!e.hasLock){I.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){I.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);I.error("Conflict detected:");for(let n of e.extendsModified)I.error(` extend "${n}" was modified`);for(let n of e.modified){let o=r.has(n)?" [LOCKED]":"";I.error(` ${n} was modified${o}`);}for(let n of e.added){let o=r.has(n)?" [LOCKED]":"";I.error(` ${n} was added${o}`);}for(let n of e.removed){let o=r.has(n)?" [LOCKED]":"";I.error(` ${n} was removed${o}`);}I.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(XA,"renderCheck");nt();function ZA(t){let{data:e}=t;if(e.files.length===0){I.info(`Nothing to import from ${e.target}.`);return}for(let n of e.files)I.success(`${n.from} \u2192 ${n.to}`);let r=e.scope==="global"?" --global":"";I.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(ZA,"renderImport");nt();function qA(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){I.info("No files to generate (no root rule or rules feature disabled).");return}for(let n of t.data.patches)process.stdout.write(n.patch);I.info(Ap({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(qA,"renderDiff");nt();function QA(t){if(!t.data.hadConflict){I.info("No conflicts to resolve.");return}I.success("Lock file conflict resolved.");}s(QA,"renderMerge");Gc();Uc();le();nn();Gc();Uc();nt();var YU=300;function XU(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(XU,"normalizeWatchPath");function ZU(t,e,r){let n=XU(relative(t,e));return n===".lock"||n===".lock.tmp"||n===".generate.lock"||n.endsWith("/.lock")||n.endsWith("/.lock.tmp")||n.endsWith("/.generate.lock")||n.includes("/.generate.lock/")||n.startsWith(".generate.lock/")}s(ZU,"shouldIgnoreWatchPath");function qU(t,e,r,n,o,i,a,c,l){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:i,permissionsCount:a,hooksCount:c,ignoreCount:l})}s(qU,"featureFingerprint");async function ex(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{context:o}=await lt(r,n),i=[o.canonicalDir,join(o.configDir,"agentsmesh.yaml"),join(o.configDir,"agentsmesh.local.yaml")],a=null,c=null,l=false,m=null,u=s(async()=>{if(l)return;a=null;let{config:R,context:C}=await lt(r,n),{canonical:_}=await ee(R,C.configDir,{},C.canonicalDir),E=_.mcp?Object.keys(_.mcp.mcpServers).length:0,T=_.permissions?_.permissions.allow.length+_.permissions.deny.length:0,D=_.hooks?Object.values(_.hooks).reduce((kt,Ct)=>kt+(Array.isArray(Ct)?Ct.length:0),0):0,x=_.ignore.length,Z=qU(R.features,_.rules.length,_.commands.length,_.agents.length,_.skills.length,E,T,D,x),B=c!==null&&c!==Z;if(c=Z,l)return;let J=await ia(t,r,{printMatrix:false});if(aa(J),!l)if(B){let kt=await $c(t,r);jc(kt,{verbose:t.verbose===true});}else I.info("Regenerated.");},"run"),f=s(()=>{let R=u().catch(C=>{if(!l){let _=C instanceof Error?C.message:String(C);I.error(_);}}).finally(()=>{m===R&&(m=null);});m=R;},"scheduleRun"),g=s(()=>{l||(a&&clearTimeout(a),a=setTimeout(f,YU));},"schedule"),h=JU.watch(i,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(R,C)=>{ZU(o.canonicalDir,C)||g();}),await new Promise((R,C)=>{h.once("ready",R),h.once("error",C);}),I.info(n==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=u(),await m,m=null,{stop:s(async()=>{l=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}s(ex,"runWatch");le();il();async function Pp(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await dp(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await Hn(n),a=await ti(e,r),c=a.length>0?await oa(a):{},l=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let _ of l){let E=i[_];E===void 0?f.push(_):E!==o.checksums[_]&&p.push(_);}for(let _ of m)l.has(_)||u.push(_);let g=new Set([...Object.keys(o.extends),...Object.keys(c)]),h=[];for(let _ of g)c[_]!==o.extends[_]&&h.push(_);let R=gp(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(Pp,"checkLockSync");Vn();async function rx(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await lt(r,n);await Jt(o,r);let a=await Pp({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(rx,"runCheck");le();A();il();var t0=".lock",e0="<<<<<<<";async function kh(t){let e=join(t,t0),r=await y(e);return r===null?false:r.includes(e0)}s(kh,"hasLockConflict");async function ox(t,e,r){if(!await kh(t))throw new Error("No conflict to resolve.");let o=await Hn(t),i=dirname(t),a=r?await ti(r,i):[],c=a.length>0?await oa(a):{},l=await hp(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await fp(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:c,packs:l});}s(ox,"resolveLockConflict");async function sx(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await lt(r,n),a=i.canonicalDir;return await kh(a)?(await ox(a,tl(),o),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(sx,"runMerge");le();A();La();var o0=promisify(execFile);async function Oh(t){let{stdout:e}=await o0("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(Oh,"runGit");async function ix(){try{return await Oh(["--version"]),!0}catch{return false}}s(ix,"isGitAvailable");async function s0(t,e){let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await Oh(["ls-remote",t,o])).split(`
307
- `).map(l=>l.trim()).find(l=>l.length>0);if(!a)continue;let c=a.split(/\s+/)[0];if(c&&/^[0-9a-f]{40}$/i.test(c))return c}catch(i){n=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}s(s0,"gitLsRemoteResolve");async function ax(t,e){let r=t===""?"HEAD":t;if(/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await Oh(["ls-remote",e,"HEAD"])).split(`
308
- `).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 s0(e,r)}s(ax,"resolveRemoteRefForInstall");async function cx(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 ax(t.rawRef||"HEAD",e);if(t.kind==="github"){let c=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Qs(c,"install",{cacheDir:me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}if(t.kind==="gitlab"){let c=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Qs(c,"install",{cacheDir:me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}let n=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await Qs(i,"install",{cacheDir:me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(cx,"fetchInstallSource");async function lx(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await cx(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(lx,"resolveInstallResolvedPath");function wh(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],c=r.slice(n+2).join("/");return !o||!i||!a?null:{org:o,repo:i,ref:a,path:c||""}}catch{return null}}s(wh,"parseGithubTreeUrl");function Eh(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],c=r.slice(n+2).join("/");return !o||!i||!a||!c?null:{org:o,repo:i,ref:a,path:c}}catch{return null}}s(Eh,"parseGithubBlobUrl");function Lh(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("/"),c=r.slice(0,n);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i?null:{namespace:m,project:l,ref:i,path:a||""}}catch{return null}}s(Lh,"parseGitlabTreeUrl");function bh(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("/"),c=r.slice(0,n);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i||!a?null:{namespace:m,project:l,ref:i,path:a}}catch{return null}}s(bh,"parseGitlabBlobUrl");var i0=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function Ah(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||i0.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(Ah,"parseGithubRepoUrl");function xh(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(xh,"parseGitlabRepoUrl");function Ph(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(Ph,"parseGitSshGithub");function Th(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(Th,"parseGitSshGitlab");A();var l0=/^[A-Za-z]:[\\/]/,m0=/^[A-Za-z]:\//;function mx(...t){return t.some(e=>e.includes("\\")||l0.test(e))?win32:posix}s(mx,"pathApiFor");function Wc(t){return t.replace(/\\/g,"/")}s(Wc,"toPosixPath");function Kc(t){return Wc(t).replace(/^\/+|\/+$/g,"")}s(Kc,"normalizeInstallPathField");function Tp(t){let e=Wc(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||m0.test(e)?e:`./${e}`}s(Tp,"normalizeLocalSourceForYaml");function vo(t){return {...t,source:t.source_kind==="local"?Tp(t.source):t.source,...t.path!==void 0?{path:Kc(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>Kc(e))}:{}}}s(vo,"normalizePersistedInstallPaths");function px(t,e,r){let n=mx(t,e),o=n.normalize(t),i=n.normalize(e),a=Kc(r),c=`${n.sep}.agentsmesh${n.sep}`,l=o.indexOf(c);if(l>=0){let p=o.slice(0,l),u=o.slice(l+c.length),f=Kc(u),g=Wc(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Tp(g)}}let m=Wc(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:Tp(m)}}s(px,"localParsedFromAbsPath");async function Dh(t,e,r){let n=t.trim(),o=r?.trim().replace(/\\/g,"/")??"";if(n.startsWith("git+")){let l=n.lastIndexOf("#"),m=l<0?n:n.slice(0,l),p=l<0?"HEAD":n.slice(l+1),u=m.slice(4);return {kind:"git",rawRef:p,gitPlusBase:u,gitRemoteUrl:u,pathInRepo:o}}if(n.startsWith("https://")||n.startsWith("http://")){let l=wh(n)??Eh(n);if(l)return {kind:"github",rawRef:l.ref,org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:o||l.path};let m=Ah(n);if(m)return {kind:"github",rawRef:"HEAD",org:m.org,repo:m.repo,gitRemoteUrl:`https://github.com/${m.org}/${m.repo}.git`,pathInRepo:o};let p=Lh(n)??bh(n);if(p)return {kind:"gitlab",rawRef:p.ref,org:p.namespace,repo:p.project,gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:o||p.path};let u=xh(n);if(u)return {kind:"gitlab",rawRef:"HEAD",org:u.namespace,repo:u.project,gitRemoteUrl:`https://gitlab.com/${u.namespace}/${u.project}.git`,pathInRepo:o}}if(n.startsWith("git@github.com:")){let l=Ph(n);if(!l)throw new Error(`Invalid GitHub SSH URL: ${n}`);return {kind:"github",rawRef:"HEAD",org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:o}}if(n.startsWith("git@gitlab.com:")){let l=Th(n);if(!l)throw new Error(`Invalid GitLab SSH URL: ${n}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${l.namespace}/${l.project}.git`,pathInRepo:o}}if(n.startsWith("git@")){let l=n.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!l)throw new Error(`Invalid SSH git URL: ${n}`);let m=l[1],p=l[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${p}.git`,pathInRepo:o}}let i=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let l=i[1],m=i[2];return {kind:"github",rawRef:i[3],org:l,repo:m,gitRemoteUrl:`https://github.com/${l}/${m}.git`,pathInRepo:o}}let a=n.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let l=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:l,repo:m,gitRemoteUrl:`https://gitlab.com/${l}/${m}.git`,pathInRepo:o}}let c=resolve(e,n);if(!await v(c))throw new Error(`Path does not exist: ${c}`);return px(c,e,o)}s(Dh,"parseInstallSource");A();nt();ln();A();cp();var ux=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:z$1.enum(["github","gitlab","git","local"]),features:z$1.array(Zs).min(1),pick:ka.optional(),target:Re.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:na.optional()}),g0=z$1.object({version:z$1.literal(1),installs:z$1.array(ux).default([])});function h0(t,e){return t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n])}s(h0,"sameFeatures");function y0(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&h0(t.features,e.features)}s(y0,"sameInstallIdentity");function dx(t){return join(t,"installs.yaml")}s(dx,"manifestPath");async function Nh(t){let e=await y(dx(t));if(e===null)return [];try{return g0.parse(parse(e)).installs.map(r=>vo(r))}catch{return []}}s(Nh,"readInstallManifest");async function fx(t,e){let r=vo(e),o=(await Nh(t)).filter(i=>i.name!==r.name&&!y0(i,r));o.push(r),await S(dx(t),stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}));}s(fx,"upsertInstallManifestEntry");function gx(t){return vo(ux.parse({name:t.name,source:t.source,version:t.version,source_kind:t.sourceKind,features:t.features,pick:t.pick,target:t.target,path:t.path,paths:t.paths,as:t.as}))}s(gx,"buildInstallManifestEntry");async function I0(t){let e=await Nh(t.canonicalDir);if(e.length===0){I.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 v(o)||r.push(n);}if(r.length===0){I.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);I.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(I0,"syncInstalledPacks");async function hx(t){return t.sync?(await I0({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(hx,"maybeRunInstallSync");cp();function yx(t){return {sync:t.sync===true,dryRun:t["dry-run"]===true,force:t.force===true,useExtends:t.extends===true,explicitPath:typeof t.path=="string"?t.path:void 0,explicitTarget:typeof t.target=="string"?t.target.trim():void 0,explicitAs:typeof t.as=="string"?na.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(yx,"readInstallFlags");$g();function js(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(js,"featuresFromCanonical");async function Dp(t){let{sliceRoot:e,implicitPick:r}=await sp(t),n=await ip(e);return {canonical:n,features:js(n),implicitPick:r}}s(Dp,"discoverFromContentRoot");function _x(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(_x,"validateSkill");function Ix(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(Ix,"validateRule");function Cx(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(Cx,"validateCommand");function Sx(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(Sx,"validateAgent");function ae(t){return basename(t.source).replace(/\.md$/i,"")}s(ae,"ruleSlug");function S0(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(S0,"featuresFromImplicitPick");function la(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??S0(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(c=>a.has(c.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(c=>a.has(ae(c)))};}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(c=>a.has(c.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(c=>a.has(c.name))};}else n&&!o.has("agents")&&(i={...i,agents:[]});return i}s(la,"narrowDiscoveredForInstallScope");A();op();A();M();var O0=new Set(["README.md","README.rst","README.txt","README","LICENSE","LICENSE.md","LICENSE.txt","LICENSE-MIT","LICENSE-APACHE","CONTRIBUTING.md","CHANGELOG.md","CODE_OF_CONDUCT.md","package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]),w0=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function Np(t){let e=await y(t);if(!e)return "";let{frontmatter:r}=w(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Np,"readSkillFrontmatterName");async function Rx(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 !(w0.has(o)||!n.includes("/")&&O0.has(n))},"filter")});}s(Rx,"cpFilteredSkill");async function x0(){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")}}s(x0,"createStageRoot");async function P0(t,e){if((await stat(t)).isFile()){if(!t.toLowerCase().endsWith(".md"))throw new Error(`Manual install only supports .md files for this collection: ${t}`);await O(e),await cp$1(t,join(e,basename(t)));return}let n=(await N(t)).filter(i=>i.toLowerCase().endsWith(".md"));if(n.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let o=new Map;await O(e);for(let i of n){let a=basename(i),c=o.get(a);if(c)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${c} and ${i}).`);o.set(a,i),await cp$1(i,join(e,a));}}s(P0,"stageMarkdownCollection");async function kx(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await N(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),c=basename(a);if(!n.has(c))continue;let l=o.get(c);if(l&&l!==a)throw new Error(`Manual skill replay found duplicate skill "${c}" under ${t} (${l} and ${a}).`);o.set(c,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}s(kx,"stagePreferredSkills");async function T0(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 $s(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await kx(t,e,r.preferredSkillNames??[]))return;let c=await Np(join(t,"SKILL.md"))||basename(t),l=join(e,c);await O(e),await Rx(t,l);return}if(await kx(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await N(t),i=new Set;for(let a of o.filter(c=>c.endsWith("/SKILL.md")||c.endsWith("\\SKILL.md")))i.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of i)await cp$1(join(t,a),join(e,a),{recursive:true});return}throw new Error(`Manual skill install expects a skill directory or skills collection at ${t}.`)}s(T0,"stageSkills");async function Ox(t,e,r={}){let n=await x0();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await T0(t,o,r):await P0(t,o),n}catch(o){throw await n.cleanup(),o}}s(Ox,"stageManualInstallScope");async function wx(t,e,r,n){let o=await Ox(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:i}=await Dp(o.discoveryRoot),a=la(i,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:o.cleanup},narrowed:a,discoveredFeatures:js(a)}}s(wx,"resolveManualDiscoveredForInstall");ln();_u();A();var D0=[{prefix:".gemini/commands",target:"gemini-cli"},{prefix:".github/instructions",target:"copilot"},{prefix:".github/copilot-instructions.md",target:"copilot"},{prefix:".github/copilot",target:"copilot"},{prefix:".github/prompts",target:"copilot"},{prefix:".github/skills",target:"copilot"},{prefix:".github/agents",target:"copilot"},{prefix:".github/hooks",target:"copilot"},{prefix:".claude/commands",target:"claude-code"},{prefix:".claude/rules",target:"claude-code"},{prefix:".claude/skills",target:"claude-code"},{prefix:".claude/agents",target:"claude-code"},{prefix:".cursor/commands",target:"cursor"},{prefix:".cursor/rules",target:"cursor"},{prefix:".cursor/agents",target:"cursor"},{prefix:".cursor/skills",target:"cursor"},{prefix:".continue/prompts",target:"continue"},{prefix:".continue/rules",target:"continue"},{prefix:".continue/skills",target:"continue"},{prefix:".junie/commands",target:"junie"},{prefix:".junie/rules",target:"junie"},{prefix:".junie/agents",target:"junie"},{prefix:".junie/skills",target:"junie"},{prefix:".kiro/steering",target:"kiro"},{prefix:".kiro/skills",target:"kiro"},{prefix:".kilo/commands",target:"kilo-code"},{prefix:".kilo/rules",target:"kilo-code"},{prefix:".kilo/skills",target:"kilo-code"},{prefix:".kilo/agents",target:"kilo-code"},{prefix:".kilocode/workflows",target:"kilo-code"},{prefix:".kilocode/rules",target:"kilo-code"},{prefix:".kilocode/skills",target:"kilo-code"},{prefix:".kilocodemodes",target:"kilo-code"},{prefix:".kilocodeignore",target:"kilo-code"},{prefix:".cline/skills",target:"cline"},{prefix:".clinerules/workflows",target:"cline"},{prefix:".windsurf/rules",target:"windsurf"},{prefix:".codex",target:"codex-cli"}];function N0(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(N0,"norm");function vp(t){let e=N0(t),r=[...D0].sort((n,o)=>o.prefix.length-n.prefix.length);for(let{prefix:n,target:o}of r)if(e===n||e.startsWith(`${n}/`))return o}s(vp,"targetHintFromNativePath");function vh(t,e){return vp(t)===e}s(vh,"pathSupportsNativePick");function Ex(t,e){if(!t||!e)return;let r=vp(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(Ex,"validateTargetMatchesPath");function Lx(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(Lx,"extendPickHasArrays");A();A();Pt();async function Ax(t,e){let r=join(t,...ge.split("/")),n=join(t,...e.split("/")),o=await N(n),i=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let c=relative(r,a).replace(/\\/g,"/");if(c.startsWith("..")||c==="")continue;let m=c.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(Ax,"inferGeminiCommandNamesFromFiles");Pt();Pe();A();async function Us(t){let e=await N(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(Us,"skillNamesFromNativeSkillDir");A();ve();async function xx(t,e){let r=join(t,...e.split("/"));if(e.startsWith(Eo)){let n=await N(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 N(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 N(r),o=new Set;for(let a of n){let c=basename(a);c.toLowerCase().endsWith(".instructions.md")?o.add(c.replace(/\.instructions\.md$/i,"")):c.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 Us(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await N(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(xx,"inferCopilotPickFromPath");async function Ie(t,e){let r=await N(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}s(Ie,"mdNames");async function Tx(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===ge||n.startsWith(`${ge}/`)){let i=await Ax(t,n);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".claude/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".claude/agents")){let i=await Ie(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 Ie(o,".mdc");return i.length?{rules:i}:{}}if(n.startsWith(".cursor/commands")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".cursor/agents")){let i=await Ie(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".cursor/skills")){let i=await Us(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return xx(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(n.startsWith(Gt)){let i=await Us(o);return i.length?{skills:i}:{}}if(n.startsWith(Pr)){let i=await Ie(o,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".continue/prompts")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".continue/skills")){let i=await Us(o);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".junie/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".junie/agents")){let i=await Ie(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".junie/skills")){let i=await Us(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await N(o),a=[...new Set(i.filter(c=>c.toLowerCase().endsWith(".md")).map(c=>basename(c,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(Tx,"inferImplicitPickFromNativePath");function Dx(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(Dx,"isImplicitPickEmpty");Fg();function zc(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(zc,"normalizePath");function B0(t,e){let r=zc(t),n=zc(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(B0,"overlapsPath");function Mp(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(Mp,"addUnique");async function H0(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(H0,"makeStageRoot");function z0(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:Mp(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=zc(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:Mp(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:Mp(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=zc(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:Mp(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(z0,"buildPickFromResults");function V0(t,e,r,n){let o=join(e,...zc(t).split("/")),i=r.filter(a=>B0(o,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}".`);return {features:[...new Set(i.map(a=>a.feature))],pick:z0(i,e)}}s(V0,"scopeImportedResults");async function $h(t,e){let{stageRoot:r,cleanup:n}=await H0(t);try{let o=await xc(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s($h,"stageImportedNativeRepo");async function Gh(t,e,r){let n=await $h(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...V0(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(Gh,"stageNativeInstallScope");async function Mx(t,e,r,n){let o=n.explicitTarget?.trim();o&&Re.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");Ex(o,i);let a=join(t,".agentsmesh"),c=await v(a),l=i?vp(i):void 0,m=!c&&!o?await gl(t)??void 0:void 0;if(!o&&l&&m&&l!==m)throw new Error(`Install path suggests native layout "${l}" but auto-detect imported "${m}". Use --target ${l} for this path, or install from the repo root without a conflicting subtree path.`);let p=o??l??m,u=!!i&&!!p&&!i.startsWith(".agentsmesh");if(!c&&p){if(u){let E=await Gh(t,i,p);return {discoveryRoot:E.stageRoot,implicitPick:E.pick,scopedFeatures:E.features,yamlTarget:p,importHappened:true,cleanup:E.cleanup}}let _=await $h(t,p);return {discoveryRoot:i?join(_.stageRoot,i):_.stageRoot,yamlTarget:p,importHappened:true,cleanup:_.cleanup}}let f;c?i?p&&vh(i,p)?f=t:f=e:f=t:f=e;let g,h,R;if(u&&p){let _=await Gh(t,i,p);f=_.stageRoot,g=_.pick,h=_.features,R=_.cleanup;}else if(f===t&&i&&p&&vh(i,p)&&(g=await Tx(t,i,p),Dx(g)))throw new Error(`No installable native resources found under "${i}" for target "${p}".`);let C;return o?C=o:p&&(g&&Lx(g)||(h?.length??0)>0)&&(C=p),{discoveryRoot:f,implicitPick:g,scopedFeatures:h,yamlTarget:C,importHappened:R!==void 0,cleanup:R}}s(Mx,"prepareInstallDiscovery");async function $x(t,e,r,n){let o=await Mx(t,e,r,{explicitTarget:n}),{canonical:i,implicitPick:a}=await Dp(o.discoveryRoot),c=a??o.implicitPick,l=la(i,{implicitPick:c,scopedFeatures:o.scopedFeatures}),m=js(l);return {prep:o,discovered:i,implicitPick:c,narrowed:l,discoveredFeatures:m}}s($x,"resolveDiscoveredForInstall");async function Gx(t){return t.explicitAs?{implicitPick:void 0,...await wx(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:$x(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}s(Gx,"resolveInstallDiscovery");function pa(t){return t==="."||t===""?void 0:t}s(pa,"trimDot");function Y0(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(Y0,"markdownPick");async function Ux(t){if(!t.as)return {pathInRepo:pa(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:pa(dirname(e)),pick:Y0(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:pa(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 Np(o);return {pathInRepo:pa(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:pa(e)}}}}return {pathInRepo:pa(e)}}s(Ux,"resolveManualInstallPersistence");nn();nt();async function on(t){return process.stdin.isTTY?new Promise(e=>{let r=Kx.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(on,"confirm");function X0(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(X0,"hasArrayResources");function Wx(t){return X0(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(Wx,"hasInstallableResources");async function Bx(t,e,r,n){let o=t.skills.map(c=>_x(c)),i=o.filter(c=>c.ok).map(c=>c.skill),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid skill "${c.skill.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.skill);else e&&(i=o.map(c=>c.skill));return r&&(i=o.filter(c=>c.ok).map(c=>c.skill)),i}s(Bx,"resolveSkillPool");async function Hx(t,e,r,n){let o=t.rules.map(c=>Ix(c)),i=o.filter(c=>c.ok).map(c=>c.rule),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid rule "${ae(c.rule)}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.rule);else e&&(i=o.map(c=>c.rule));return r&&(i=o.filter(c=>c.ok).map(c=>c.rule)),i}s(Hx,"resolveRulePool");async function zx(t,e,r,n){let o=t.commands.map(c=>Cx(c)),i=o.filter(c=>c.ok).map(c=>c.command),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid command "${c.command.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.command);else e&&(i=o.map(c=>c.command));return r&&(i=o.filter(c=>c.ok).map(c=>c.command)),i}s(zx,"resolveCommandPool");async function Vx(t,e,r,n){let o=t.agents.map(c=>Sx(c)),i=o.filter(c=>c.ok).map(c=>c.agent),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid agent "${c.agent.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.agent);else e&&(i=o.map(c=>c.agent));return r&&(i=o.filter(c=>c.ok).map(c=>c.agent)),i}s(Vx,"resolveAgentPool");async function Jx(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>ae(a)),o=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(c=>c.name===a.name)&&(await on(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(l=>l!==a.name)));for(let a of e.rules){let c=ae(a);t.rules.some(l=>ae(l)===c)&&(await on(`Rule "${c}" already exists in merged config. Add extend anyway?`)||(n=n.filter(m=>m!==c)));}for(let a of e.commands)t.commands.some(c=>c.name===a.name)&&(await on(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(o=o.filter(l=>l!==a.name)));for(let a of e.agents)t.agents.some(c=>c.name===a.name)&&(await on(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(l=>l!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:i}}s(Jx,"resolveInstallConflicts");function Yx(t,e){if(!t)return;let r={},n=t.skills?.filter(c=>e.skillNames.includes(c)),o=t.rules?.filter(c=>e.ruleSlugs.includes(c)),i=t.commands?.filter(c=>e.commandNames.includes(c)),a=t.agents?.filter(c=>e.agentNames.includes(c));return 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(Yx,"pickForSelectedResources");function Z0(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(Z0,"pathEndsWithName");function $p(t,e,r){return r!==1||e.length!==1?false:Z0(t,e[0])}s($p,"inferSingleNamePick");function Xx(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||$p(e,o.skillNames,n.skills)),c=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||$p(e,o.ruleSlugs,n.rules)),l=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||$p(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||$p(e,o.agentNames,n.agents));return a&&(i.skills=[...o.skillNames]),c&&(i.rules=[...o.ruleSlugs]),l&&(i.commands=[...o.commandNames]),m&&(i.agents=[...o.agentNames]),Object.keys(i).length?i:void 0}s(Xx,"buildInstallPick");function Zx(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(Zx,"deriveInstallFeatures");function q0(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(q0,"isEmptyInstallSelection");function qx(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=s(c=>r.includes(c),"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(c=>["mcp","permissions","hooks","ignore"].includes(c));if(q0(e)&&!a)throw new Error("No resources selected to install.")}s(qx,"ensureInstallSelection");ln();function Qx(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(Qx,"assertExtendNameAvailable");function Q0(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(Q0,"mergePick");function tP(t,e){let r=t.findIndex(a=>a.source===e.source);if(r<0)return [...t,{name:e.name,source:e.source,version:e.version,features:e.features,path:e.path,pick:e.pick,target:e.target}];let n=t[r],o=[...new Set([...n.features,...e.features])],i=Q0(n.pick,e.features,e.pick);return t.map((a,c)=>c===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}:a)}s(tP,"mergeExtendList");A();async function eP(t,e,r){let n=await y(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=tP(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await S(t,a.endsWith(`
306
+ `),false}}s(kh,"seedAgentsmeshMcpEntry");function WA(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(WA,"mapResults");async function BA(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(He(o)){let p=wa(r,i),f=await bp(o).importFrom(p.rootBase,{scope:i});return f.length>0&&await kh(p.rootBase),{exitCode:0,data:{scope:i,target:o,files:WA(f,p.rootBase)}}}let a,c;try{({config:a,context:c}=await lt(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: ${it.join(", ")}.`)}await Jt(a,r);let l=tt(o);if(!l)throw new Error(`Unknown --from "${n}". Supported: ${[...it,...a.pluginTargets??[]].join(", ")}.`);let m=await l.generators.importFrom(c.rootBase,{scope:i});return m.length>0&&await kh(c.rootBase),{exitCode:0,data:{scope:i,target:o,files:WA(m,c.rootBase)}}}s(BA,"runImport");le();nn();function Ap(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(Ap,"computeDiff");function xp(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(xp,"formatDiffSummary");Vn();async function zA(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:c}=await lt(r,n);await Jt(a,r);let{canonical:l}=await ee(a,c.configDir,{},c.canonicalDir),m=await je({config:a,canonical:l,projectRoot:c.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}=Ap(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(zA,"runDiff");le();nn();A();ye();Vo();bt();var zU=[{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 VA(t){let e=new Set(t.enabledFeatures),r=[];for(let n of zU)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Xe(t.capabilities[n.capabilityKey]).level!=="none"||r.push(U(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(VA,"lintSilentFeatureDrops");bt();var VU=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function JU(t){let r=t.match(VU)?.groups?.path;return typeof r=="string"?r:null}s(JU,"extractScriptToken");function JA(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=JU(o.command);i&&r.push(U(".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(JA,"lintHookScriptReferences");bt();function YA(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(U(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(YA,"lintRuleScopeInversion");var YU=["node_modules",".git","dist","coverage",".agentsmesh"];async function XU(t){return (await N(t)).filter(n=>{let o=relative(t,n);return !YU.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(XU,"getProjectFiles");async function Pp(t,e,r,n,o={}){let i=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],c=n?a.filter(C=>n.includes(C)):a,l=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 XU(r);for(let C of c){let _=tt(C),E=He(C)?bp(C):_;E?.capabilities&&g.push(...VA({target:C,capabilities:E.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...JA({target:C,canonical:e,hasScriptProjection:_?.postProcessHookOutputs!==void 0})),l&&g.push(...YA({target:C,canonical:e,preservesManualActivation:_?.preservesManualActivation===true})),l&&E?.lintRules&&g.push(...E.lintRules(e,r,h,{scope:i})),_?.generators.lint&&g.push(..._.generators.lint(e));let T={scope:i};m&&E?.lint?.commands&&g.push(...E.lint.commands(e,T)),p&&E?.lint?.mcp&&g.push(...E.lint.mcp(e,T)),u&&E?.lint?.permissions&&g.push(...E.lint.permissions(e,T)),f&&E?.lint?.hooks&&g.push(...E.lint.hooks(e,T));}let R=g.some(C=>C.level==="error");return {diagnostics:g,hasErrors:R}}s(Pp,"runLint");Vn();async function ZA(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:c}=await lt(r,n);await Jt(a,r);let{canonical:l}=await ee(a,c.configDir,{},c.canonicalDir),{diagnostics:m,hasErrors:p}=await Pp(a,l,c.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(ZA,"runLintCmd");nt();function qA(t){let{data:e}=t;if(e.diagnostics.length===0){I.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),n=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)I.error(`${a.file} (${a.target}): ${a.message}`);for(let a of n)I.warn(`${a.file} (${a.target}): ${a.message}`);let o=e.summary.errors,i=e.summary.warnings;I.info(`${o} error${o!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(qA,"renderLint");nt();function QA(t){let{data:e}=t;if(!e.hasLock){I.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){I.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);I.error("Conflict detected:");for(let n of e.extendsModified)I.error(` extend "${n}" was modified`);for(let n of e.modified){let o=r.has(n)?" [LOCKED]":"";I.error(` ${n} was modified${o}`);}for(let n of e.added){let o=r.has(n)?" [LOCKED]":"";I.error(` ${n} was added${o}`);}for(let n of e.removed){let o=r.has(n)?" [LOCKED]":"";I.error(` ${n} was removed${o}`);}I.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(QA,"renderCheck");nt();function tx(t){let{data:e}=t;if(e.files.length===0){I.info(`Nothing to import from ${e.target}.`);return}for(let n of e.files)I.success(`${n.from} \u2192 ${n.to}`);let r=e.scope==="global"?" --global":"";I.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(tx,"renderImport");nt();function ex(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){I.info("No files to generate (no root rule or rules feature disabled).");return}for(let n of t.data.patches)process.stdout.write(n.patch);I.info(xp({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(ex,"renderDiff");nt();function rx(t){if(!t.data.hadConflict){I.info("No conflicts to resolve.");return}I.success("Lock file conflict resolved.");}s(rx,"renderMerge");jc();Kc();le();nn();jc();Kc();nt();var QU=300;function t0(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(t0,"normalizeWatchPath");function e0(t,e,r){let n=t0(relative(t,e));return n===".lock"||n===".lock.tmp"||n===".generate.lock"||n.endsWith("/.lock")||n.endsWith("/.lock.tmp")||n.endsWith("/.generate.lock")||n.includes("/.generate.lock/")||n.startsWith(".generate.lock/")}s(e0,"shouldIgnoreWatchPath");function r0(t,e,r,n,o,i,a,c,l){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:i,permissionsCount:a,hooksCount:c,ignoreCount:l})}s(r0,"featureFingerprint");async function ox(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{context:o}=await lt(r,n),i=[o.canonicalDir,join(o.configDir,"agentsmesh.yaml"),join(o.configDir,"agentsmesh.local.yaml")],a=null,c=null,l=false,m=null,u=s(async()=>{if(l)return;a=null;let{config:R,context:C}=await lt(r,n),{canonical:_}=await ee(R,C.configDir,{},C.canonicalDir),E=_.mcp?Object.keys(_.mcp.mcpServers).length:0,T=_.permissions?_.permissions.allow.length+_.permissions.deny.length:0,D=_.hooks?Object.values(_.hooks).reduce((kt,Ct)=>kt+(Array.isArray(Ct)?Ct.length:0),0):0,x=_.ignore.length,Z=r0(R.features,_.rules.length,_.commands.length,_.agents.length,_.skills.length,E,T,D,x),B=c!==null&&c!==Z;if(c=Z,l)return;let J=await ia(t,r,{printMatrix:false});if(aa(J),!l)if(B){let kt=await Gc(t,r);Uc(kt,{verbose:t.verbose===true});}else I.info("Regenerated.");},"run"),f=s(()=>{let R=u().catch(C=>{if(!l){let _=C instanceof Error?C.message:String(C);I.error(_);}}).finally(()=>{m===R&&(m=null);});m=R;},"scheduleRun"),g=s(()=>{l||(a&&clearTimeout(a),a=setTimeout(f,QU));},"schedule"),h=qU.watch(i,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(R,C)=>{e0(o.canonicalDir,C)||g();}),await new Promise((R,C)=>{h.once("ready",R),h.once("error",C);}),I.info(n==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=u(),await m,m=null,{stop:s(async()=>{l=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}s(ox,"runWatch");le();al();async function Tp(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await fp(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await Hn(n),a=await ti(e,r),c=a.length>0?await oa(a):{},l=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let _ of l){let E=i[_];E===void 0?f.push(_):E!==o.checksums[_]&&p.push(_);}for(let _ of m)l.has(_)||u.push(_);let g=new Set([...Object.keys(o.extends),...Object.keys(c)]),h=[];for(let _ of g)c[_]!==o.extends[_]&&h.push(_);let R=hp(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(Tp,"checkLockSync");Vn();async function sx(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await lt(r,n);await Jt(o,r);let a=await Tp({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(sx,"runCheck");le();A();al();var o0=".lock",s0="<<<<<<<";async function Oh(t){let e=join(t,o0),r=await y(e);return r===null?false:r.includes(s0)}s(Oh,"hasLockConflict");async function ax(t,e,r){if(!await Oh(t))throw new Error("No conflict to resolve.");let o=await Hn(t),i=dirname(t),a=r?await ti(r,i):[],c=a.length>0?await oa(a):{},l=await yp(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await gp(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:c,packs:l});}s(ax,"resolveLockConflict");async function cx(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await lt(r,n),a=i.canonicalDir;return await Oh(a)?(await ax(a,Sa(),o),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(cx,"runMerge");le();A();ba();var c0=promisify(execFile);async function wh(t){let{stdout:e}=await c0("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(wh,"runGit");async function lx(){try{return await wh(["--version"]),!0}catch{return false}}s(lx,"isGitAvailable");async function l0(t,e){let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await wh(["ls-remote",t,o])).split(`
307
+ `).map(l=>l.trim()).find(l=>l.length>0);if(!a)continue;let c=a.split(/\s+/)[0];if(c&&/^[0-9a-f]{40}$/i.test(c))return c}catch(i){n=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}s(l0,"gitLsRemoteResolve");async function mx(t,e){let r=t===""?"HEAD":t;if(/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await wh(["ls-remote",e,"HEAD"])).split(`
308
+ `).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 l0(e,r)}s(mx,"resolveRemoteRefForInstall");async function px(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 mx(t.rawRef||"HEAD",e);if(t.kind==="github"){let c=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Qs(c,"install",{cacheDir:me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}if(t.kind==="gitlab"){let c=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Qs(c,"install",{cacheDir:me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}let n=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await Qs(i,"install",{cacheDir:me(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(px,"fetchInstallSource");async function ux(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await px(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(ux,"resolveInstallResolvedPath");function Eh(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],c=r.slice(n+2).join("/");return !o||!i||!a?null:{org:o,repo:i,ref:a,path:c||""}}catch{return null}}s(Eh,"parseGithubTreeUrl");function Lh(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],c=r.slice(n+2).join("/");return !o||!i||!a||!c?null:{org:o,repo:i,ref:a,path:c}}catch{return null}}s(Lh,"parseGithubBlobUrl");function bh(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("/"),c=r.slice(0,n);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i?null:{namespace:m,project:l,ref:i,path:a||""}}catch{return null}}s(bh,"parseGitlabTreeUrl");function Ah(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("/"),c=r.slice(0,n);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i||!a?null:{namespace:m,project:l,ref:i,path:a}}catch{return null}}s(Ah,"parseGitlabBlobUrl");var m0=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function xh(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||m0.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(xh,"parseGithubRepoUrl");function Ph(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(Ph,"parseGitlabRepoUrl");function Th(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(Th,"parseGitSshGithub");function Dh(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(Dh,"parseGitSshGitlab");A();var d0=/^[A-Za-z]:[\\/]/,f0=/^[A-Za-z]:\//;function dx(...t){return t.some(e=>e.includes("\\")||d0.test(e))?win32:posix}s(dx,"pathApiFor");function Bc(t){return t.replace(/\\/g,"/")}s(Bc,"toPosixPath");function Wc(t){return Bc(t).replace(/^\/+|\/+$/g,"")}s(Wc,"normalizeInstallPathField");function Dp(t){let e=Bc(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||f0.test(e)?e:`./${e}`}s(Dp,"normalizeLocalSourceForYaml");function vo(t){return {...t,source:t.source_kind==="local"?Dp(t.source):t.source,...t.path!==void 0?{path:Wc(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>Wc(e))}:{}}}s(vo,"normalizePersistedInstallPaths");function fx(t,e,r){let n=dx(t,e),o=n.normalize(t),i=n.normalize(e),a=Wc(r),c=`${n.sep}.agentsmesh${n.sep}`,l=o.indexOf(c);if(l>=0){let p=o.slice(0,l),u=o.slice(l+c.length),f=Wc(u),g=Bc(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Dp(g)}}let m=Bc(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:Dp(m)}}s(fx,"localParsedFromAbsPath");async function Nh(t,e,r){let n=t.trim(),o=r?.trim().replace(/\\/g,"/")??"";if(n.startsWith("git+")){let l=n.lastIndexOf("#"),m=l<0?n:n.slice(0,l),p=l<0?"HEAD":n.slice(l+1),u=m.slice(4);return {kind:"git",rawRef:p,gitPlusBase:u,gitRemoteUrl:u,pathInRepo:o}}if(n.startsWith("https://")||n.startsWith("http://")){let l=Eh(n)??Lh(n);if(l)return {kind:"github",rawRef:l.ref,org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:o||l.path};let m=xh(n);if(m)return {kind:"github",rawRef:"HEAD",org:m.org,repo:m.repo,gitRemoteUrl:`https://github.com/${m.org}/${m.repo}.git`,pathInRepo:o};let p=bh(n)??Ah(n);if(p)return {kind:"gitlab",rawRef:p.ref,org:p.namespace,repo:p.project,gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:o||p.path};let u=Ph(n);if(u)return {kind:"gitlab",rawRef:"HEAD",org:u.namespace,repo:u.project,gitRemoteUrl:`https://gitlab.com/${u.namespace}/${u.project}.git`,pathInRepo:o}}if(n.startsWith("git@github.com:")){let l=Th(n);if(!l)throw new Error(`Invalid GitHub SSH URL: ${n}`);return {kind:"github",rawRef:"HEAD",org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:o}}if(n.startsWith("git@gitlab.com:")){let l=Dh(n);if(!l)throw new Error(`Invalid GitLab SSH URL: ${n}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${l.namespace}/${l.project}.git`,pathInRepo:o}}if(n.startsWith("git@")){let l=n.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!l)throw new Error(`Invalid SSH git URL: ${n}`);let m=l[1],p=l[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${p}.git`,pathInRepo:o}}let i=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let l=i[1],m=i[2];return {kind:"github",rawRef:i[3],org:l,repo:m,gitRemoteUrl:`https://github.com/${l}/${m}.git`,pathInRepo:o}}let a=n.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let l=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:l,repo:m,gitRemoteUrl:`https://gitlab.com/${l}/${m}.git`,pathInRepo:o}}let c=resolve(e,n);if(!await v(c))throw new Error(`Path does not exist: ${c}`);return fx(c,e,o)}s(Nh,"parseInstallSource");A();nt();ln();A();lp();var gx=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:z$1.enum(["github","gitlab","git","local"]),features:z$1.array(Zs).min(1),pick:Oa.optional(),target:Re.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:na.optional()}),I0=z$1.object({version:z$1.literal(1),installs:z$1.array(gx).default([])});function C0(t,e){return t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n])}s(C0,"sameFeatures");function S0(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&C0(t.features,e.features)}s(S0,"sameInstallIdentity");function hx(t){return join(t,"installs.yaml")}s(hx,"manifestPath");async function Fh(t){let e=await y(hx(t));if(e===null)return [];try{return I0.parse(parse(e)).installs.map(r=>vo(r))}catch{return []}}s(Fh,"readInstallManifest");async function yx(t,e){let r=vo(e),o=(await Fh(t)).filter(i=>i.name!==r.name&&!S0(i,r));o.push(r),await S(hx(t),stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}));}s(yx,"upsertInstallManifestEntry");function _x(t){return vo(gx.parse({name:t.name,source:t.source,version:t.version,source_kind:t.sourceKind,features:t.features,pick:t.pick,target:t.target,path:t.path,paths:t.paths,as:t.as}))}s(_x,"buildInstallManifestEntry");async function k0(t){let e=await Fh(t.canonicalDir);if(e.length===0){I.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 v(o)||r.push(n);}if(r.length===0){I.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);I.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(k0,"syncInstalledPacks");async function Ix(t){return t.sync?(await k0({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(Ix,"maybeRunInstallSync");lp();function Cx(t){return {sync:t.sync===true,dryRun:t["dry-run"]===true,force:t.force===true,useExtends:t.extends===true,explicitPath:typeof t.path=="string"?t.path:void 0,explicitTarget:typeof t.target=="string"?t.target.trim():void 0,explicitAs:typeof t.as=="string"?na.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(Cx,"readInstallFlags");$g();function js(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(js,"featuresFromCanonical");async function Np(t){let{sliceRoot:e,implicitPick:r}=await ip(t),n=await ap(e);return {canonical:n,features:js(n),implicitPick:r}}s(Np,"discoverFromContentRoot");function Sx(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(Sx,"validateSkill");function Rx(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(Rx,"validateRule");function kx(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(kx,"validateCommand");function Ox(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(Ox,"validateAgent");function ae(t){return basename(t.source).replace(/\.md$/i,"")}s(ae,"ruleSlug");function w0(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(w0,"featuresFromImplicitPick");function la(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??w0(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(c=>a.has(c.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(c=>a.has(ae(c)))};}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(c=>a.has(c.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(c=>a.has(c.name))};}else n&&!o.has("agents")&&(i={...i,agents:[]});return i}s(la,"narrowDiscoveredForInstallScope");A();sp();A();M();var b0=new Set(["README.md","README.rst","README.txt","README","LICENSE","LICENSE.md","LICENSE.txt","LICENSE-MIT","LICENSE-APACHE","CONTRIBUTING.md","CHANGELOG.md","CODE_OF_CONDUCT.md","package.json","package-lock.json","pnpm-lock.yaml","yarn.lock",".gitignore",".gitattributes",".editorconfig",".DS_Store"]),A0=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function Fp(t){let e=await y(t);if(!e)return "";let{frontmatter:r}=w(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Fp,"readSkillFrontmatterName");async function wx(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 !(A0.has(o)||!n.includes("/")&&b0.has(n))},"filter")});}s(wx,"cpFilteredSkill");async function N0(){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")}}s(N0,"createStageRoot");async function F0(t,e){if((await stat(t)).isFile()){if(!t.toLowerCase().endsWith(".md"))throw new Error(`Manual install only supports .md files for this collection: ${t}`);await O(e),await cp$1(t,join(e,basename(t)));return}let n=(await N(t)).filter(i=>i.toLowerCase().endsWith(".md"));if(n.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let o=new Map;await O(e);for(let i of n){let a=basename(i),c=o.get(a);if(c)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${c} and ${i}).`);o.set(a,i),await cp$1(i,join(e,a));}}s(F0,"stageMarkdownCollection");async function Ex(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await N(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),c=basename(a);if(!n.has(c))continue;let l=o.get(c);if(l&&l!==a)throw new Error(`Manual skill replay found duplicate skill "${c}" under ${t} (${l} and ${a}).`);o.set(c,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}s(Ex,"stagePreferredSkills");async function v0(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 $s(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await Ex(t,e,r.preferredSkillNames??[]))return;let c=await Fp(join(t,"SKILL.md"))||basename(t),l=join(e,c);await O(e),await wx(t,l);return}if(await Ex(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await N(t),i=new Set;for(let a of o.filter(c=>c.endsWith("/SKILL.md")||c.endsWith("\\SKILL.md")))i.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of i)await cp$1(join(t,a),join(e,a),{recursive:true});return}throw new Error(`Manual skill install expects a skill directory or skills collection at ${t}.`)}s(v0,"stageSkills");async function Lx(t,e,r={}){let n=await N0();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await v0(t,o,r):await F0(t,o),n}catch(o){throw await n.cleanup(),o}}s(Lx,"stageManualInstallScope");async function bx(t,e,r,n){let o=await Lx(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:i}=await Np(o.discoveryRoot),a=la(i,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:o.cleanup},narrowed:a,discoveredFeatures:js(a)}}s(bx,"resolveManualDiscoveredForInstall");ln();_u();A();var M0=[{prefix:".gemini/commands",target:"gemini-cli"},{prefix:".github/instructions",target:"copilot"},{prefix:".github/copilot-instructions.md",target:"copilot"},{prefix:".github/copilot",target:"copilot"},{prefix:".github/prompts",target:"copilot"},{prefix:".github/skills",target:"copilot"},{prefix:".github/agents",target:"copilot"},{prefix:".github/hooks",target:"copilot"},{prefix:".claude/commands",target:"claude-code"},{prefix:".claude/rules",target:"claude-code"},{prefix:".claude/skills",target:"claude-code"},{prefix:".claude/agents",target:"claude-code"},{prefix:".cursor/commands",target:"cursor"},{prefix:".cursor/rules",target:"cursor"},{prefix:".cursor/agents",target:"cursor"},{prefix:".cursor/skills",target:"cursor"},{prefix:".continue/prompts",target:"continue"},{prefix:".continue/rules",target:"continue"},{prefix:".continue/skills",target:"continue"},{prefix:".junie/commands",target:"junie"},{prefix:".junie/rules",target:"junie"},{prefix:".junie/agents",target:"junie"},{prefix:".junie/skills",target:"junie"},{prefix:".kiro/steering",target:"kiro"},{prefix:".kiro/skills",target:"kiro"},{prefix:".kilo/commands",target:"kilo-code"},{prefix:".kilo/rules",target:"kilo-code"},{prefix:".kilo/skills",target:"kilo-code"},{prefix:".kilo/agents",target:"kilo-code"},{prefix:".kilocode/workflows",target:"kilo-code"},{prefix:".kilocode/rules",target:"kilo-code"},{prefix:".kilocode/skills",target:"kilo-code"},{prefix:".kilocodemodes",target:"kilo-code"},{prefix:".kilocodeignore",target:"kilo-code"},{prefix:".cline/skills",target:"cline"},{prefix:".clinerules/workflows",target:"cline"},{prefix:".windsurf/rules",target:"windsurf"},{prefix:".codex",target:"codex-cli"}];function $0(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s($0,"norm");function Mp(t){let e=$0(t),r=[...M0].sort((n,o)=>o.prefix.length-n.prefix.length);for(let{prefix:n,target:o}of r)if(e===n||e.startsWith(`${n}/`))return o}s(Mp,"targetHintFromNativePath");function Mh(t,e){return Mp(t)===e}s(Mh,"pathSupportsNativePick");function Ax(t,e){if(!t||!e)return;let r=Mp(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(Ax,"validateTargetMatchesPath");function xx(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(xx,"extendPickHasArrays");A();A();Pt();async function Tx(t,e){let r=join(t,...ge.split("/")),n=join(t,...e.split("/")),o=await N(n),i=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let c=relative(r,a).replace(/\\/g,"/");if(c.startsWith("..")||c==="")continue;let m=c.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(Tx,"inferGeminiCommandNamesFromFiles");Pt();Pe();A();async function Us(t){let e=await N(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(Us,"skillNamesFromNativeSkillDir");A();ve();async function Dx(t,e){let r=join(t,...e.split("/"));if(e.startsWith(Eo)){let n=await N(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 N(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 N(r),o=new Set;for(let a of n){let c=basename(a);c.toLowerCase().endsWith(".instructions.md")?o.add(c.replace(/\.instructions\.md$/i,"")):c.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 Us(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await N(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(Dx,"inferCopilotPickFromPath");async function Ie(t,e){let r=await N(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}s(Ie,"mdNames");async function Fx(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===ge||n.startsWith(`${ge}/`)){let i=await Tx(t,n);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".claude/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".claude/agents")){let i=await Ie(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 Ie(o,".mdc");return i.length?{rules:i}:{}}if(n.startsWith(".cursor/commands")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".cursor/agents")){let i=await Ie(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".cursor/skills")){let i=await Us(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return Dx(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(n.startsWith(Gt)){let i=await Us(o);return i.length?{skills:i}:{}}if(n.startsWith(Pr)){let i=await Ie(o,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".continue/prompts")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".continue/skills")){let i=await Us(o);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let i=await Ie(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".junie/rules")){let i=await Ie(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".junie/agents")){let i=await Ie(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".junie/skills")){let i=await Us(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await N(o),a=[...new Set(i.filter(c=>c.toLowerCase().endsWith(".md")).map(c=>basename(c,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(Fx,"inferImplicitPickFromNativePath");function vx(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(vx,"isImplicitPickEmpty");Fg();function Vc(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(Vc,"normalizePath");function J0(t,e){let r=Vc(t),n=Vc(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(J0,"overlapsPath");function $p(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s($p,"addUnique");async function Y0(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(Y0,"makeStageRoot");function X0(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:$p(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=Vc(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:$p(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:$p(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=Vc(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:$p(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(X0,"buildPickFromResults");function Z0(t,e,r,n){let o=join(e,...Vc(t).split("/")),i=r.filter(a=>J0(o,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}".`);return {features:[...new Set(i.map(a=>a.feature))],pick:X0(i,e)}}s(Z0,"scopeImportedResults");async function Gh(t,e){let{stageRoot:r,cleanup:n}=await Y0(t);try{let o=await Pc(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s(Gh,"stageImportedNativeRepo");async function jh(t,e,r){let n=await Gh(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...Z0(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(jh,"stageNativeInstallScope");async function jx(t,e,r,n){let o=n.explicitTarget?.trim();o&&Re.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");Ax(o,i);let a=join(t,".agentsmesh"),c=await v(a),l=i?Mp(i):void 0,m=!c&&!o?await hl(t)??void 0:void 0;if(!o&&l&&m&&l!==m)throw new Error(`Install path suggests native layout "${l}" but auto-detect imported "${m}". Use --target ${l} for this path, or install from the repo root without a conflicting subtree path.`);let p=o??l??m,u=!!i&&!!p&&!i.startsWith(".agentsmesh");if(!c&&p){if(u){let E=await jh(t,i,p);return {discoveryRoot:E.stageRoot,implicitPick:E.pick,scopedFeatures:E.features,yamlTarget:p,importHappened:true,cleanup:E.cleanup}}let _=await Gh(t,p);return {discoveryRoot:i?join(_.stageRoot,i):_.stageRoot,yamlTarget:p,importHappened:true,cleanup:_.cleanup}}let f;c?i?p&&Mh(i,p)?f=t:f=e:f=t:f=e;let g,h,R;if(u&&p){let _=await jh(t,i,p);f=_.stageRoot,g=_.pick,h=_.features,R=_.cleanup;}else if(f===t&&i&&p&&Mh(i,p)&&(g=await Fx(t,i,p),vx(g)))throw new Error(`No installable native resources found under "${i}" for target "${p}".`);let C;return o?C=o:p&&(g&&xx(g)||(h?.length??0)>0)&&(C=p),{discoveryRoot:f,implicitPick:g,scopedFeatures:h,yamlTarget:C,importHappened:R!==void 0,cleanup:R}}s(jx,"prepareInstallDiscovery");async function Ux(t,e,r,n){let o=await jx(t,e,r,{explicitTarget:n}),{canonical:i,implicitPick:a}=await Np(o.discoveryRoot),c=a??o.implicitPick,l=la(i,{implicitPick:c,scopedFeatures:o.scopedFeatures}),m=js(l);return {prep:o,discovered:i,implicitPick:c,narrowed:l,discoveredFeatures:m}}s(Ux,"resolveDiscoveredForInstall");async function Kx(t){return t.explicitAs?{implicitPick:void 0,...await bx(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:Ux(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}s(Kx,"resolveInstallDiscovery");function pa(t){return t==="."||t===""?void 0:t}s(pa,"trimDot");function Q0(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(Q0,"markdownPick");async function Bx(t){if(!t.as)return {pathInRepo:pa(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:pa(dirname(e)),pick:Q0(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:pa(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 Fp(o);return {pathInRepo:pa(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:pa(e)}}}}return {pathInRepo:pa(e)}}s(Bx,"resolveManualInstallPersistence");nn();nt();async function on(t){return process.stdin.isTTY?new Promise(e=>{let r=Hx.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(on,"confirm");function tK(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(tK,"hasArrayResources");function zx(t){return tK(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(zx,"hasInstallableResources");async function Vx(t,e,r,n){let o=t.skills.map(c=>Sx(c)),i=o.filter(c=>c.ok).map(c=>c.skill),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid skill "${c.skill.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.skill);else e&&(i=o.map(c=>c.skill));return r&&(i=o.filter(c=>c.ok).map(c=>c.skill)),i}s(Vx,"resolveSkillPool");async function Jx(t,e,r,n){let o=t.rules.map(c=>Rx(c)),i=o.filter(c=>c.ok).map(c=>c.rule),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid rule "${ae(c.rule)}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.rule);else e&&(i=o.map(c=>c.rule));return r&&(i=o.filter(c=>c.ok).map(c=>c.rule)),i}s(Jx,"resolveRulePool");async function Yx(t,e,r,n){let o=t.commands.map(c=>kx(c)),i=o.filter(c=>c.ok).map(c=>c.command),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid command "${c.command.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.command);else e&&(i=o.map(c=>c.command));return r&&(i=o.filter(c=>c.ok).map(c=>c.command)),i}s(Yx,"resolveCommandPool");async function Xx(t,e,r,n){let o=t.agents.map(c=>Ox(c)),i=o.filter(c=>c.ok).map(c=>c.agent),a=o.filter(c=>!c.ok);if(!e&&!r&&n)for(let c of a)await on(`Include invalid agent "${c.agent.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.agent);else e&&(i=o.map(c=>c.agent));return r&&(i=o.filter(c=>c.ok).map(c=>c.agent)),i}s(Xx,"resolveAgentPool");async function Zx(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>ae(a)),o=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(c=>c.name===a.name)&&(await on(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(l=>l!==a.name)));for(let a of e.rules){let c=ae(a);t.rules.some(l=>ae(l)===c)&&(await on(`Rule "${c}" already exists in merged config. Add extend anyway?`)||(n=n.filter(m=>m!==c)));}for(let a of e.commands)t.commands.some(c=>c.name===a.name)&&(await on(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(o=o.filter(l=>l!==a.name)));for(let a of e.agents)t.agents.some(c=>c.name===a.name)&&(await on(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(l=>l!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:i}}s(Zx,"resolveInstallConflicts");function qx(t,e){if(!t)return;let r={},n=t.skills?.filter(c=>e.skillNames.includes(c)),o=t.rules?.filter(c=>e.ruleSlugs.includes(c)),i=t.commands?.filter(c=>e.commandNames.includes(c)),a=t.agents?.filter(c=>e.agentNames.includes(c));return 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(qx,"pickForSelectedResources");function eK(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(eK,"pathEndsWithName");function Gp(t,e,r){return r!==1||e.length!==1?false:eK(t,e[0])}s(Gp,"inferSingleNamePick");function Qx(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||Gp(e,o.skillNames,n.skills)),c=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||Gp(e,o.ruleSlugs,n.rules)),l=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||Gp(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||Gp(e,o.agentNames,n.agents));return a&&(i.skills=[...o.skillNames]),c&&(i.rules=[...o.ruleSlugs]),l&&(i.commands=[...o.commandNames]),m&&(i.agents=[...o.agentNames]),Object.keys(i).length?i:void 0}s(Qx,"buildInstallPick");function tP(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(tP,"deriveInstallFeatures");function rK(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(rK,"isEmptyInstallSelection");function eP(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=s(c=>r.includes(c),"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(c=>["mcp","permissions","hooks","ignore"].includes(c));if(rK(e)&&!a)throw new Error("No resources selected to install.")}s(eP,"ensureInstallSelection");ln();function rP(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(rP,"assertExtendNameAvailable");function nK(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(nK,"mergePick");function nP(t,e){let r=t.findIndex(a=>a.source===e.source);if(r<0)return [...t,{name:e.name,source:e.source,version:e.version,features:e.features,path:e.path,pick:e.pick,target:e.target}];let n=t[r],o=[...new Set([...n.features,...e.features])],i=nK(n.pick,e.features,e.pick);return t.map((a,c)=>c===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}:a)}s(nP,"mergeExtendList");A();async function oP(t,e,r){let n=await y(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=nP(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await S(t,a.endsWith(`
309
309
  `)?a:`${a}
310
- `);}s(eP,"writeAgentsmeshWithNewExtend");nt();async function rP(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=nK(n);if(Qx(r.extends,i),o){I.info(`[dry-run] Would add extend:
311
- ${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await eP(a,r,i),I.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(rP,"writeInstallAsExtend");function nK(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?Re.parse(t.yamlTarget):void 0}}s(nK,"toNewExtendEntry");A();A();var sK="pack.yaml";async function Gp(t){let e=await N(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===sK)continue;let c=await up(i);c!==null&&r.push(`${a}:${c}`);}let n=r.join(`
312
- `);return `sha256:${Nc(n)}`}s(Gp,"hashPackContent");async function lK(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(lK,"writeRules");async function mK(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(mK,"writeCommands");async function pK(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(pK,"writeAgents");async function uK(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(uK,"writeSkills");async function dK(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
310
+ `);}s(oP,"writeAgentsmeshWithNewExtend");nt();async function sP(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=aK(n);if(rP(r.extends,i),o){I.info(`[dry-run] Would add extend:
311
+ ${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await oP(a,r,i),I.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(sP,"writeInstallAsExtend");function aK(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?Re.parse(t.yamlTarget):void 0}}s(aK,"toNewExtendEntry");A();A();var lK="pack.yaml";async function jp(t){let e=await N(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===lK)continue;let c=await dp(i);c!==null&&r.push(`${a}:${c}`);}let n=r.join(`
312
+ `);return `sha256:${Fc(n)}`}s(jp,"hashPackContent");async function dK(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(dK,"writeRules");async function fK(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(fK,"writeCommands");async function gK(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(gK,"writeAgents");async function hK(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(hK,"writeSkills");async function yK(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
313
313
  `),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(`
314
314
  `)}
315
- `);}s(dK,"writeSettings");function fK(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(fK,"validatePackName");async function oP(t,e,r,n){fK(e);let o=join(t,`${e}.tmp`),i=join(t,e);await v(o)&&await rm$1(o,{recursive:true,force:true}),await O(o),await lK(r,o),await mK(r,o),await pK(r,o),await uK(r,o),await dK(r,o);let a=await Gp(o),c=vo({...n,content_hash:a});return await S(join(o,"pack.yaml"),stringify(c)),await v(i)&&await rm$1(i,{recursive:true,force:true}),await mkdir(t,{recursive:true}),await rename(o,i),c}s(oP,"materializePack");pp();A();function Bh(t,e){return [...new Set([...t,...e])]}s(Bh,"union");function hK(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=Bh(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(hK,"mergePathScope");function yK(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=Bh(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(yK,"mergePick");async function _K(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(_K,"mergeRules");async function IK(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(IK,"mergeCommands");async function CK(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(CK,"mergeAgents");async function SK(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(SK,"mergeSkills");async function RK(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
315
+ `);}s(yK,"writeSettings");function _K(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(_K,"validatePackName");async function aP(t,e,r,n){_K(e);let o=join(t,`${e}.tmp`),i=join(t,e);await v(o)&&await rm$1(o,{recursive:true,force:true}),await O(o),await dK(r,o),await fK(r,o),await gK(r,o),await hK(r,o),await yK(r,o);let a=await jp(o),c=vo({...n,content_hash:a});return await S(join(o,"pack.yaml"),stringify(c)),await v(i)&&await rm$1(i,{recursive:true,force:true}),await mkdir(t,{recursive:true}),await rename(o,i),c}s(aP,"materializePack");up();A();function Hh(t,e){return [...new Set([...t,...e])]}s(Hh,"union");function CK(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=Hh(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(CK,"mergePathScope");function SK(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=Hh(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(SK,"mergePick");async function RK(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(RK,"mergeRules");async function kK(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(kK,"mergeCommands");async function OK(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(OK,"mergeAgents");async function wK(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(wK,"mergeSkills");async function EK(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
316
316
  `),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(`
317
317
  `)}
318
- `);}s(RK,"mergeSettings");async function sP(t,e,r,n,o,i){await _K(r,t),await IK(r,t),await CK(r,t),await SK(r,t),await RK(r,t);let a=Bh(e.features,n),c=yK(e.pick,n,o),l=hK(e,i?.path),m=await Gp(t),p=new Date().toISOString(),u=vo({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:a,pick:c,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...l,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:p,content_hash:m});return await S(join(t,"pack.yaml"),stringify(u)),u}s(sP,"mergeIntoPack");lu();ln();nt();A();function OK(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(OK,"pathScope");function wK(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(ae(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(wK,"applySelection");async function iP(t){let{canonicalDir:e,packName:r,narrowed:n,selected:o,sourceForYaml:i,version:a,sourceKind:c,entryFeatures:l,pick:m,yamlTarget:p,pathInRepo:u,manualAs:f,renameExistingPack:g}=t,h=join(e,"packs"),R=wK(n,o),C=new Date().toISOString(),_=p!==void 0?Re.parse(p):void 0,E=await Lb(h,i,{target:_,as:f,features:l}),T=r,D=l,x=m,Z=u,B;if(E){let J=E.packDir,kt=E.meta;if(g&&E.name!==r){let Sr=join(h,r);if(await v(Sr))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(E.packDir,Sr),J=Sr,kt={...E.meta,name:r};}let Ct=await sP(J,kt,R,l,m,{source:i,...a!==void 0?{version:a}:{},..._!==void 0?{target:_}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}});T=Ct.name,D=Ct.features,x=Ct.pick,Z=Ct.path,B=Ct.paths,I.success(`Updated pack "${Ct.name}" in .agentsmesh/packs/.`);}else {if(await lp(join(h,r)))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await oP(h,r,R,{name:r,source:i,...a!==void 0&&{version:a},source_kind:c,installed_at:C,updated_at:C,features:l,...m!==void 0&&{pick:m},..._!==void 0&&{target:_},...OK(u),...f!==void 0&&{as:f}}),I.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await fx(e,gx({name:T,source:i,version:a,sourceKind:c,features:D,pick:x,target:_,path:Z,paths:B,as:f})),c!=="local"&&await Xy(i);}s(iP,"installAsPack");function LK(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(LK,"sanitize");function bK(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(bK,"gitUrlLastSegments");function aP(t,e,r){let n;if(t.kind==="local"){let c=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);n=c[c.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=bK(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=LK(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(aP,"suggestExtendName");function cP(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||aP(r,{featureHint:n.length===1?n[0]:void 0},i)}s(cP,"selectInstallEntryName");function lP(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=la(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:js(n)}}s(lP,"applyReplayInstallScope");function mP(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(mP,"buildInstalledList");function pP(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 c=ae(a);o.ruleSlugs.includes(c)||i.push({kind:"rule",name:c,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(pP,"buildSkippedList");async function uP(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,nameOverride:a,explicitAs:c,config:l,context:m,parsed:p,sourceForYaml:u,version:f,pathInRepo:g,persisted:h,replay:R,prep:C,implicitPick:_,narrowed:E,discoveredFeatures:T}=t,{narrowed:D,discoveredFeatures:x}=lP(E,T,R);if(!Wx(D))throw new Error(_||C.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 Z=await Bx(D,r,n,o),B=await Hx(D,r,n,o),J=await zx(D,r,n,o),kt=await Vx(D,r,n,o),Ct={skills:Z.length,rules:B.length,commands:J.length,agents:kt.length},{canonical:Sr}=await ee(l,m.configDir,{},m.canonicalDir),Dt=!r&&!n&&o?await Jx(Sr,{skills:Z,rules:B,commands:J,agents:kt}):{skillNames:Z.map(Zn=>Zn.name),ruleSlugs:B.map(Zn=>ae(Zn)),commandNames:J.map(Zn=>Zn.name),agentNames:kt.map(Zn=>Zn.name)};qx({selected:Dt,discoveredFeatures:x,preConflict:Ct});let Rr=R?.features??Zx(x,Dt);if(Rr.length===0)throw new Error("No features left to install after selection.");let Ot=Yx(R?.pick,Dt)??h.pick??Xx({pathInRepo:h.pathInRepo??g,implicitPick:_,preConflictCounts:Ct,selected:Dt}),ct=cP({config:l,parsed:p,entryFeatures:Rr,nameOverride:a}),sn=mP(Dt,ct),Ke=pP(Z,B,J,kt,Dt);if(i){if(await rP({configDir:m.configDir,config:l,entryArgs:{name:ct,source:u,version:f,features:Rr,path:h.pathInRepo,pick:Ot,yamlTarget:C.yamlTarget},dryRun:n}),n)return {installed:sn,skipped:Ke}}else {if(n)return I.info(`[dry-run] Would install pack "${ct}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:sn,skipped:Ke};await iP({canonicalDir:m.canonicalDir,packName:ct,narrowed:D,selected:Dt,sourceForYaml:u,version:f,sourceKind:p.kind,entryFeatures:Rr,pick:Ot,yamlTarget:C.yamlTarget,pathInRepo:h.pathInRepo,manualAs:c,renameExistingPack:a===""});}let Xn=await ia(e==="global"?{global:true}:{},m.rootBase);return aa(Xn),Xn.exitCode!==0&&I.warn(`Generate failed after install. Fix the issue and run agentsmesh generate${e==="global"?" --global":""}.`),{installed:sn,skipped:Ke}}s(uP,"executeRunInstallPoolsAndWrite");async function zh(t,e,r,n){let{sync:o,dryRun:i,force:a,useExtends:c,explicitPath:l,explicitTarget:m,explicitAs:p,nameOverride:u}=yx(t),f=t.global===true?"global":"project",g=e[0]?.trim();if(o){let{context:Dt}=await lt(r,f),Rr=[],Ot=[];if(await hx({sync:o,canonicalDir:Dt.canonicalDir,reinstall:s(async ct=>{let sn=ct.paths&&ct.paths.length>0?ct.paths:[ct.path];for(let Ke of sn){let Xn=await zh({...a?{force:true}:{},...i?{"dry-run":true}:{},...f==="global"?{global:true}:{},name:ct.name,...ct.target?{target:ct.target}:{},...Ke?{path:Ke}:{},...ct.as?{as:ct.as}:{}},[ct.source],r,{features:ct.features,pick:ct.pick});Rr.push(...Xn.data.installed),Ot.push(...Xn.data.skipped);}},"reinstall")}))return {exitCode:0,data:{source:"",mode:"sync",installed:Rr,skipped:Ot,dryRun:i}}}if(!g)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let h=process.stdin.isTTY;if(!h&&!a&&!i)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:R,context:C}=await lt(r,f),_=await Dh(g,C.configDir,l);if(_.kind!=="local"&&!await ix())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:E,sourceForYaml:T,version:D}=await lx(_,g),x=_.pathInRepo.replace(/^\/+|\/+$/g,"");if(x){let Dt=normalize(x).replace(/\\/g,"/");if(Dt===".."||Dt.startsWith("../"))throw new Error(`Install --path "${_.pathInRepo}" escapes the source root. Path must stay within the source.`)}let Z=x?join(E,x):E;if(!await v(Z))throw new Error(`Install path does not exist: ${Z}`);let B=await Ux({as:p,contentRoot:Z,pathInRepo:x}),{prep:J,implicitPick:kt,narrowed:Ct,discoveredFeatures:Sr}=await Gx({resolvedPath:E,contentRoot:Z,pathInRepo:x,explicitTarget:m,explicitAs:p,replayPick:n?.pick});try{let Dt=await uP({scope:f,force:a,dryRun:i,tty:h,useExtends:c,nameOverride:u,explicitAs:p,config:R,context:C,parsed:_,sourceForYaml:T,version:D,pathInRepo:x,persisted:B,replay:n,prep:J,implicitPick:kt,narrowed:Ct,discoveredFeatures:Sr});return {exitCode:0,data:{source:g,mode:"install",installed:Dt.installed,skipped:Dt.skipped,dryRun:i}}}finally{J.cleanup&&await J.cleanup();}}s(zh,"runInstall");async function dP(t,e,r){return zh(t,e,r)}s(dP,"runInstall");nt();function fP(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(", ");I.success(`Installed ${n}.`);}if(e.skipped.length>0)for(let r of e.skipped)I.warn(`Skipped ${r.kind} "${r.name}": ${r.reason}`);}}s(fP,"renderInstall");Zg();A();var Yh="agentsmesh.yaml";async function Xh(t){let e=join(t,Yh),r=await y(e);return r===null?{}:parse(r)??{}}s(Xh,"readScopedConfigRaw");async function hP(t,e){let r=join(t,Yh),n=await y(r)??`version: 1
319
- `,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(hP,"writePluginEntry");async function yP(t,e){let r=join(t,Yh),n=await y(r);if(n===null)return false;let o=parse(n)??{},i=(o.plugins??[]).length;o.plugins=(o.plugins??[]).filter(c=>c.id!==e),o.pluginTargets&&(o.pluginTargets=o.pluginTargets.filter(c=>c!==e));let a=o.plugins.length<i;return a&&await S(r,stringify(o)),a}s(yP,"removePluginEntry");async function _P(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 PK(t,e.slice(1),r);case "list":return TK(r);case "remove":return DK(e.slice(1),r);case "info":return NK(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${n}`}}}s(_P,"runPlugin");async function PK(t,e,r){let n=e[0];if(!n)throw new kr("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)??FK(n);return await hP(r,{id:a,source:n,version:o==="latest"?void 0:o}),{exitCode:0,data:{subcommand:"add",id:a,package:n,version:o}}}s(PK,"runPluginAdd");async function TK(t){let r=(await Xh(t)).plugins??[],n=[];for(let o of r){let i="\u2717",a="";try{let c=await kp(o,t);i=c.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",a=c.descriptors.map(l=>l.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(TK,"runPluginList");async function DK(t,e){let r=t[0];if(!r)throw new kr("Usage: agentsmesh plugin remove <id>");let n=await yP(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:n}}}s(DK,"runPluginRemove");async function NK(t,e){let r=t[0];if(!r)throw new kr("Usage: agentsmesh plugin info <id>");let o=((await Xh(e)).plugins??[]).find(c=>c.id===r);if(!o)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await kp(o,e);}catch{return {exitCode:1,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:[]}}}let a=i.descriptors.map(c=>({id:c.id,description:c.emptyImportMessage}));return {exitCode:0,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:a}}}s(NK,"runPluginInfo");function FK(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(FK,"derivePluginId");nt();function IP(t){if(t.error&&I.error(t.error),t.showHelp){jK();return}let{data:e}=t;switch(e.subcommand){case "add":vK(e.id,e.package,e.version);break;case "list":MK(e.plugins);break;case "remove":$K(e.id,e.found);break;case "info":GK(e,t.exitCode);break}}s(IP,"renderPlugin");function vK(t,e,r){I.success(`Plugin '${t}' added to agentsmesh.yaml`),I.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";I.info(`Next: npm install ${e}${n}`),I.info(`Then add '${t}' to pluginTargets in agentsmesh.yaml to enable it.`);}s(vK,"renderAdd");function MK(t){if(t.length===0){I.info("No plugins configured. Use: agentsmesh plugin add <source>");return}I.info("Configured plugins:");for(let e of t){let r=e.version!==void 0?`@${e.version}`:"",n=e.status??"",o=e.targets??"";I.info(` ${e.id} | ${e.package}${r} | ${n} | ${o}`);}}s(MK,"renderList");function $K(t,e){e?I.success(`Plugin '${t}' removed from agentsmesh.yaml`):I.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s($K,"renderRemove");function GK(t,e){if(e!==0&&t.package===""){I.error(`Plugin '${t.id}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`);return}if(e!==0){I.error(`Failed to load plugin '${t.id}'`);return}I.info(`Plugin: ${t.id}`),I.info(`Source: ${t.package}${t.version!==void 0?`@${t.version}`:""}`),I.info(`Descriptors: ${t.descriptors.length}`);for(let r of t.descriptors)I.info(` - ${r.id}: ${r.description}`);}s(GK,"renderInfo");function jK(){I.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),I.info(""),I.info("Subcommands:"),I.info(" add <source> Register a plugin package in agentsmesh.yaml"),I.info(" list Show all configured plugins and load status"),I.info(" remove <id> Remove a plugin from agentsmesh.yaml"),I.info(" info <id> Show descriptor details for a configured plugin"),I.info(""),I.info("Flags (add):"),I.info(" --version <v> Pin plugin version"),I.info(" --id <id> Override derived plugin id"),I.info(""),I.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),I.info(" Only install plugins from sources you trust.");}s(jK,"printPluginHelp");A();ze();function da(t){return t.toUpperCase().replace(/-/g,"_")}s(da,"toPrefix");function ua(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(ua,"toPascal");function CP(t){let e=da(t.id);return `export const ${e}_TARGET = '${t.id}';
318
+ `);}s(EK,"mergeSettings");async function cP(t,e,r,n,o,i){await RK(r,t),await kK(r,t),await OK(r,t),await wK(r,t),await EK(r,t);let a=Hh(e.features,n),c=SK(e.pick,n,o),l=CK(e,i?.path),m=await jp(t),p=new Date().toISOString(),u=vo({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:a,pick:c,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...l,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:p,content_hash:m});return await S(join(t,"pack.yaml"),stringify(u)),u}s(cP,"mergeIntoPack");lu();ln();nt();A();function bK(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(bK,"pathScope");function AK(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(ae(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(AK,"applySelection");async function lP(t){let{canonicalDir:e,packName:r,narrowed:n,selected:o,sourceForYaml:i,version:a,sourceKind:c,entryFeatures:l,pick:m,yamlTarget:p,pathInRepo:u,manualAs:f,renameExistingPack:g}=t,h=join(e,"packs"),R=AK(n,o),C=new Date().toISOString(),_=p!==void 0?Re.parse(p):void 0,E=await Lb(h,i,{target:_,as:f,features:l}),T=r,D=l,x=m,Z=u,B;if(E){let J=E.packDir,kt=E.meta;if(g&&E.name!==r){let Sr=join(h,r);if(await v(Sr))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(E.packDir,Sr),J=Sr,kt={...E.meta,name:r};}let Ct=await cP(J,kt,R,l,m,{source:i,...a!==void 0?{version:a}:{},..._!==void 0?{target:_}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}});T=Ct.name,D=Ct.features,x=Ct.pick,Z=Ct.path,B=Ct.paths,I.success(`Updated pack "${Ct.name}" in .agentsmesh/packs/.`);}else {if(await mp(join(h,r)))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await aP(h,r,R,{name:r,source:i,...a!==void 0&&{version:a},source_kind:c,installed_at:C,updated_at:C,features:l,...m!==void 0&&{pick:m},..._!==void 0&&{target:_},...bK(u),...f!==void 0&&{as:f}}),I.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await yx(e,_x({name:T,source:i,version:a,sourceKind:c,features:D,pick:x,target:_,path:Z,paths:B,as:f})),c!=="local"&&await Xy(i);}s(lP,"installAsPack");function PK(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(PK,"sanitize");function TK(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(TK,"gitUrlLastSegments");function mP(t,e,r){let n;if(t.kind==="local"){let c=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);n=c[c.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=TK(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=PK(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(mP,"suggestExtendName");function pP(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||mP(r,{featureHint:n.length===1?n[0]:void 0},i)}s(pP,"selectInstallEntryName");function uP(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=la(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:js(n)}}s(uP,"applyReplayInstallScope");function dP(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(dP,"buildInstalledList");function fP(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 c=ae(a);o.ruleSlugs.includes(c)||i.push({kind:"rule",name:c,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(fP,"buildSkippedList");async function gP(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,nameOverride:a,explicitAs:c,config:l,context:m,parsed:p,sourceForYaml:u,version:f,pathInRepo:g,persisted:h,replay:R,prep:C,implicitPick:_,narrowed:E,discoveredFeatures:T}=t,{narrowed:D,discoveredFeatures:x}=uP(E,T,R);if(!zx(D))throw new Error(_||C.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 Z=await Vx(D,r,n,o),B=await Jx(D,r,n,o),J=await Yx(D,r,n,o),kt=await Xx(D,r,n,o),Ct={skills:Z.length,rules:B.length,commands:J.length,agents:kt.length},{canonical:Sr}=await ee(l,m.configDir,{},m.canonicalDir),Dt=!r&&!n&&o?await Zx(Sr,{skills:Z,rules:B,commands:J,agents:kt}):{skillNames:Z.map(Zn=>Zn.name),ruleSlugs:B.map(Zn=>ae(Zn)),commandNames:J.map(Zn=>Zn.name),agentNames:kt.map(Zn=>Zn.name)};eP({selected:Dt,discoveredFeatures:x,preConflict:Ct});let Rr=R?.features??tP(x,Dt);if(Rr.length===0)throw new Error("No features left to install after selection.");let Ot=qx(R?.pick,Dt)??h.pick??Qx({pathInRepo:h.pathInRepo??g,implicitPick:_,preConflictCounts:Ct,selected:Dt}),ct=pP({config:l,parsed:p,entryFeatures:Rr,nameOverride:a}),sn=dP(Dt,ct),Ke=fP(Z,B,J,kt,Dt);if(i){if(await sP({configDir:m.configDir,config:l,entryArgs:{name:ct,source:u,version:f,features:Rr,path:h.pathInRepo,pick:Ot,yamlTarget:C.yamlTarget},dryRun:n}),n)return {installed:sn,skipped:Ke}}else {if(n)return I.info(`[dry-run] Would install pack "${ct}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:sn,skipped:Ke};await lP({canonicalDir:m.canonicalDir,packName:ct,narrowed:D,selected:Dt,sourceForYaml:u,version:f,sourceKind:p.kind,entryFeatures:Rr,pick:Ot,yamlTarget:C.yamlTarget,pathInRepo:h.pathInRepo,manualAs:c,renameExistingPack:a===""});}let Xn=await ia(e==="global"?{global:true}:{},m.rootBase);return aa(Xn),Xn.exitCode!==0&&I.warn(`Generate failed after install. Fix the issue and run agentsmesh generate${e==="global"?" --global":""}.`),{installed:sn,skipped:Ke}}s(gP,"executeRunInstallPoolsAndWrite");async function Vh(t,e,r,n){let{sync:o,dryRun:i,force:a,useExtends:c,explicitPath:l,explicitTarget:m,explicitAs:p,nameOverride:u}=Cx(t),f=t.global===true?"global":"project",g=e[0]?.trim();if(o){let{context:Dt}=await lt(r,f),Rr=[],Ot=[];if(await Ix({sync:o,canonicalDir:Dt.canonicalDir,reinstall:s(async ct=>{let sn=ct.paths&&ct.paths.length>0?ct.paths:[ct.path];for(let Ke of sn){let Xn=await Vh({...a?{force:true}:{},...i?{"dry-run":true}:{},...f==="global"?{global:true}:{},name:ct.name,...ct.target?{target:ct.target}:{},...Ke?{path:Ke}:{},...ct.as?{as:ct.as}:{}},[ct.source],r,{features:ct.features,pick:ct.pick});Rr.push(...Xn.data.installed),Ot.push(...Xn.data.skipped);}},"reinstall")}))return {exitCode:0,data:{source:"",mode:"sync",installed:Rr,skipped:Ot,dryRun:i}}}if(!g)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let h=process.stdin.isTTY;if(!h&&!a&&!i)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:R,context:C}=await lt(r,f),_=await Nh(g,C.configDir,l);if(_.kind!=="local"&&!await lx())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:E,sourceForYaml:T,version:D}=await ux(_,g),x=_.pathInRepo.replace(/^\/+|\/+$/g,"");if(x){let Dt=normalize(x).replace(/\\/g,"/");if(Dt===".."||Dt.startsWith("../"))throw new Error(`Install --path "${_.pathInRepo}" escapes the source root. Path must stay within the source.`)}let Z=x?join(E,x):E;if(!await v(Z))throw new Error(`Install path does not exist: ${Z}`);let B=await Bx({as:p,contentRoot:Z,pathInRepo:x}),{prep:J,implicitPick:kt,narrowed:Ct,discoveredFeatures:Sr}=await Kx({resolvedPath:E,contentRoot:Z,pathInRepo:x,explicitTarget:m,explicitAs:p,replayPick:n?.pick});try{let Dt=await gP({scope:f,force:a,dryRun:i,tty:h,useExtends:c,nameOverride:u,explicitAs:p,config:R,context:C,parsed:_,sourceForYaml:T,version:D,pathInRepo:x,persisted:B,replay:n,prep:J,implicitPick:kt,narrowed:Ct,discoveredFeatures:Sr});return {exitCode:0,data:{source:g,mode:"install",installed:Dt.installed,skipped:Dt.skipped,dryRun:i}}}finally{J.cleanup&&await J.cleanup();}}s(Vh,"runInstall");async function hP(t,e,r){return Vh(t,e,r)}s(hP,"runInstall");nt();function yP(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(", ");I.success(`Installed ${n}.`);}if(e.skipped.length>0)for(let r of e.skipped)I.warn(`Skipped ${r.kind} "${r.name}": ${r.reason}`);}}s(yP,"renderInstall");qg();A();var Xh="agentsmesh.yaml";async function Zh(t){let e=join(t,Xh),r=await y(e);return r===null?{}:parse(r)??{}}s(Zh,"readScopedConfigRaw");async function IP(t,e){let r=join(t,Xh),n=await y(r)??`version: 1
319
+ `,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(IP,"writePluginEntry");async function CP(t,e){let r=join(t,Xh),n=await y(r);if(n===null)return false;let o=parse(n)??{},i=(o.plugins??[]).length;o.plugins=(o.plugins??[]).filter(c=>c.id!==e),o.pluginTargets&&(o.pluginTargets=o.pluginTargets.filter(c=>c!==e));let a=o.plugins.length<i;return a&&await S(r,stringify(o)),a}s(CP,"removePluginEntry");async function SP(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 FK(t,e.slice(1),r);case "list":return vK(r);case "remove":return MK(e.slice(1),r);case "info":return $K(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${n}`}}}s(SP,"runPlugin");async function FK(t,e,r){let n=e[0];if(!n)throw new kr("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)??GK(n);return await IP(r,{id:a,source:n,version:o==="latest"?void 0:o}),{exitCode:0,data:{subcommand:"add",id:a,package:n,version:o}}}s(FK,"runPluginAdd");async function vK(t){let r=(await Zh(t)).plugins??[],n=[];for(let o of r){let i="\u2717",a="";try{let c=await Op(o,t);i=c.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",a=c.descriptors.map(l=>l.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(vK,"runPluginList");async function MK(t,e){let r=t[0];if(!r)throw new kr("Usage: agentsmesh plugin remove <id>");let n=await CP(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:n}}}s(MK,"runPluginRemove");async function $K(t,e){let r=t[0];if(!r)throw new kr("Usage: agentsmesh plugin info <id>");let o=((await Zh(e)).plugins??[]).find(c=>c.id===r);if(!o)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await Op(o,e);}catch{return {exitCode:1,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:[]}}}let a=i.descriptors.map(c=>({id:c.id,description:c.emptyImportMessage}));return {exitCode:0,data:{subcommand:"info",id:r,package:o.source,version:o.version,descriptors:a}}}s($K,"runPluginInfo");function GK(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(GK,"derivePluginId");nt();function RP(t){if(t.error&&I.error(t.error),t.showHelp){BK();return}let{data:e}=t;switch(e.subcommand){case "add":jK(e.id,e.package,e.version);break;case "list":UK(e.plugins);break;case "remove":KK(e.id,e.found);break;case "info":WK(e,t.exitCode);break}}s(RP,"renderPlugin");function jK(t,e,r){I.success(`Plugin '${t}' added to agentsmesh.yaml`),I.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";I.info(`Next: npm install ${e}${n}`),I.info(`Then add '${t}' to pluginTargets in agentsmesh.yaml to enable it.`);}s(jK,"renderAdd");function UK(t){if(t.length===0){I.info("No plugins configured. Use: agentsmesh plugin add <source>");return}I.info("Configured plugins:");for(let e of t){let r=e.version!==void 0?`@${e.version}`:"",n=e.status??"",o=e.targets??"";I.info(` ${e.id} | ${e.package}${r} | ${n} | ${o}`);}}s(UK,"renderList");function KK(t,e){e?I.success(`Plugin '${t}' removed from agentsmesh.yaml`):I.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s(KK,"renderRemove");function WK(t,e){if(e!==0&&t.package===""){I.error(`Plugin '${t.id}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`);return}if(e!==0){I.error(`Failed to load plugin '${t.id}'`);return}I.info(`Plugin: ${t.id}`),I.info(`Source: ${t.package}${t.version!==void 0?`@${t.version}`:""}`),I.info(`Descriptors: ${t.descriptors.length}`);for(let r of t.descriptors)I.info(` - ${r.id}: ${r.description}`);}s(WK,"renderInfo");function BK(){I.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),I.info(""),I.info("Subcommands:"),I.info(" add <source> Register a plugin package in agentsmesh.yaml"),I.info(" list Show all configured plugins and load status"),I.info(" remove <id> Remove a plugin from agentsmesh.yaml"),I.info(" info <id> Show descriptor details for a configured plugin"),I.info(""),I.info("Flags (add):"),I.info(" --version <v> Pin plugin version"),I.info(" --id <id> Override derived plugin id"),I.info(""),I.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),I.info(" Only install plugins from sources you trust.");}s(BK,"printPluginHelp");A();ze();function da(t){return t.toUpperCase().replace(/-/g,"_")}s(da,"toPrefix");function ua(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(ua,"toPascal");function kP(t){let e=da(t.id);return `export const ${e}_TARGET = '${t.id}';
320
320
 
321
321
  // Project-level paths
322
322
  export const ${e}_DIR = '.${t.id}';
@@ -329,7 +329,7 @@ export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
329
329
  // Canonical paths
330
330
  export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
331
331
  export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
332
- `}s(CP,"TEMPLATE_CONSTANTS");function SP(t){let e=da(t.id),r=ua(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
332
+ `}s(kP,"TEMPLATE_CONSTANTS");function OP(t){let e=da(t.id),r=ua(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
333
333
  import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
334
334
  import { generateRules } from './generator.js';
335
335
  import { importFrom${r} } from './importer.js';
@@ -426,7 +426,7 @@ export const descriptor = {
426
426
  buildImportPaths: build${r}ImportPaths,
427
427
  detectionPaths: [${e}_DIR],
428
428
  } satisfies TargetDescriptor;
429
- `}s(SP,"TEMPLATE_INDEX");function RP(t){let e=da(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
429
+ `}s(OP,"TEMPLATE_INDEX");function wP(t){let e=da(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
430
430
  import { ${e}_TARGET, ${e}_DIR } from './constants.js';
431
431
 
432
432
  export interface ${ua(t.id)}Output {
@@ -440,7 +440,7 @@ export function generateRules(_canonical: CanonicalFiles): ${ua(t.id)}Output[] {
440
440
  void ${e}_DIR;
441
441
  return [];
442
442
  }
443
- `}s(RP,"TEMPLATE_GENERATOR");function kP(t){let e=ua(t.id),r=da(t.id);return `import type { ImportResult } from '../../core/types.js';
443
+ `}s(wP,"TEMPLATE_GENERATOR");function EP(t){let e=ua(t.id),r=da(t.id);return `import type { ImportResult } from '../../core/types.js';
444
444
  import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
445
445
  import { ${r}_TARGET } from './constants.js';
446
446
 
@@ -452,7 +452,7 @@ export async function importFrom${e}(
452
452
  void ${r}_TARGET;
453
453
  return [];
454
454
  }
455
- `}s(kP,"TEMPLATE_IMPORTER");function OP(t){let e=da(t.id);return `/** Lint rules for the ${t.id} target. */
455
+ `}s(EP,"TEMPLATE_IMPORTER");function LP(t){let e=da(t.id);return `/** Lint rules for the ${t.id} target. */
456
456
  import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
457
457
  import { validateRules } from '../../core/lint/validate-rules.js';
458
458
  import { ${e}_TARGET } from './constants.js';
@@ -470,7 +470,7 @@ export function lintRules(
470
470
  target: ${e}_TARGET,
471
471
  }));
472
472
  }
473
- `}s(OP,"TEMPLATE_LINTER");function wP(t){return `/**
473
+ `}s(LP,"TEMPLATE_LINTER");function bP(t){return `/**
474
474
  * ${t.displayName}-specific lint hooks.
475
475
  */
476
476
 
@@ -480,7 +480,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
480
480
  // TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
481
481
  return [];
482
482
  }
483
- `}s(wP,"TEMPLATE_LINT_HOOKS");function EP(t){let e=ua(t.id),r=da(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
483
+ `}s(bP,"TEMPLATE_LINT_HOOKS");function AP(t){let e=ua(t.id),r=da(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
484
484
  import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
485
485
 
486
486
  export async function build${e}ImportPaths(
@@ -492,7 +492,7 @@ export async function build${e}ImportPaths(
492
492
  // Reference: src/core/reference/import-maps/kiro.ts for a full example
493
493
  void ${r}_DIR;
494
494
  }
495
- `}s(EP,"TEMPLATE_IMPORT_MAP");function LP(t){return `import { describe, it, expect } from 'vitest';
495
+ `}s(AP,"TEMPLATE_IMPORT_MAP");function xP(t){return `import { describe, it, expect } from 'vitest';
496
496
  import type { CanonicalFiles } from '../../../../src/core/types.js';
497
497
  import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
498
498
 
@@ -521,7 +521,7 @@ describe('generateRules (${t.id})', () => {
521
521
  expect(result).toHaveLength(0);
522
522
  });
523
523
  });
524
- `}s(LP,"TEMPLATE_GENERATOR_TEST");function bP(t){let e=ua(t.id);return `import { describe, it, expect } from 'vitest';
524
+ `}s(xP,"TEMPLATE_GENERATOR_TEST");function PP(t){let e=ua(t.id);return `import { describe, it, expect } from 'vitest';
525
525
  import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
526
526
 
527
527
  describe('importFrom${e} (${t.id})', () => {
@@ -535,17 +535,17 @@ describe('importFrom${e} (${t.id})', () => {
535
535
  expect(result).toHaveLength(0);
536
536
  });
537
537
  });
538
- `}s(bP,"TEMPLATE_IMPORTER_TEST");function AP(t){return `# ${t.displayName} Workspace
538
+ `}s(PP,"TEMPLATE_IMPORTER_TEST");function TP(t){return `# ${t.displayName} Workspace
539
539
 
540
540
  Follow the ${t.displayName} configuration files and keep changes small.
541
- `}s(AP,"TEMPLATE_FIXTURE_ROOT_MD");var KK=/^[a-z][a-z0-9-]*$/;async function xP(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!KK.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(it.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:CP(i)},{rel:`src/targets/${e}/index.ts`,content:SP(i)},{rel:`src/targets/${e}/generator.ts`,content:RP(i)},{rel:`src/targets/${e}/importer.ts`,content:kP(i)},{rel:`src/targets/${e}/linter.ts`,content:OP(i)},{rel:`src/targets/${e}/lint.ts`,content:wP(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:EP(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:LP(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:bP(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:AP(i)}],c=[],l=[];for(let p of a){let u=join(r,p.rel);if(!n&&await v(u)){l.push(u);continue}await S(u,p.content),c.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:c,skipped:l,postSteps:m}}s(xP,"writeTargetScaffold");async function TP(t,e,r){let n=e[0];return n===void 0||n===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:n==="scaffold"?WK(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${n}`}}s(TP,"runTarget");async function WK(t,e,r){let n=e[0];if(!n)throw new kr("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 xP({id:n,displayName:o,projectRoot:r,force:i});}catch(c){return {exitCode:1,data:{id:n,written:[],skipped:[],postSteps:[]},error:c instanceof Error?c.message:String(c)}}return {exitCode:0,data:{id:n,written:a.written.map(c=>PP(c,r)),skipped:a.skipped.map(c=>PP(c,r)),postSteps:a.postSteps}}}s(WK,"runScaffold");function PP(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(PP,"relativize");nt();function DP(t){if(t.error&&I.error(t.error),t.showHelp){BK();return}let{data:e}=t;for(let r of e.written)I.success(`created ${r}`);for(let r of e.skipped)I.warn(`skipped ${r} (already exists \u2014 use --force to overwrite)`);if(e.written.length>0){I.info(""),I.info("Next steps:");for(let r of e.postSteps)I.info(` ${r}`);}}s(DP,"renderTarget");function BK(){I.info("Usage: agentsmesh target <subcommand> [args] [flags]"),I.info(""),I.info("Subcommands:"),I.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),I.info(""),I.info("Flags (scaffold):"),I.info(" --name <displayName> Human-readable name (defaults to id)"),I.info(" --force Overwrite existing files");}s(BK,"printTargetHelp");ye();zo();A();le();Vn();ln();function qK(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(qK,"shouldSymlink");function QK(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let n of r){if(!qK(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(QK,"createTempProjectRoot");async function Up(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 c=i.toLowerCase().trim(),l=a.toLowerCase().trim();if(c===l)throw new Error("--from and --to must be different targets.");let m=He(c),p=He(l);if(!m||!p)try{let{config:C}=await lt(r,"project");await Jt(C,r);}catch{let C=[];throw m||C.push(`--from "${i}"`),p||C.push(`--to "${a}"`),new Error(`Unknown ${C.join(" and ")}. Supported: ${it.join(", ")}.`)}let u=tt(c);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${it.join(", ")}.`);if(!tt(l))throw new Error(`Unknown --to "${a}". Supported: ${it.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",R=QK(o);try{await u.generators.importFrom(R,{scope:n});let C=await pe(R),_=jo.parse({version:1,targets:p?[l]:[],pluginTargets:p?[]:[l]}),E=await je({config:_,canonical:C,projectRoot:o,scope:n,targetFilter:[l]});if(!g){for(let x of E)if(x.status==="created"||x.status==="updated"){let Z=sa(o,x.path,x.target);await S(Z,x.content);}}let T=E.filter(x=>x.status!=="skipped"),D=T.map(x=>({path:x.path,target:x.target,status:x.status}));return {exitCode:0,data:{from:c,to:l,mode:h,files:D,summary:{created:T.filter(x=>x.status==="created").length,updated:T.filter(x=>x.status==="updated").length,unchanged:T.filter(x=>x.status==="unchanged").length}}}}finally{rmSync(R,{recursive:true,force:true});}}s(Up,"runConvert");nt();function NP(t){let{data:e}=t;if(e.files.length===0){I.info(`No files found to convert from ${e.from}.`);return}if(e.mode==="dry-run"){for(let i of e.files)I.info(`[dry-run] ${i.status} ${i.path} (${i.target})`);return}for(let i of e.files)(i.status==="created"||i.status==="updated")&&I.success(`${i.status} ${i.path}`);let{created:r,updated:n,unchanged:o}=e.summary;r>0||n>0?I.info(`Converted from ${e.from} \u2192 ${e.to}: ${r} created, ${n} updated, ${o} unchanged`):I.info(`Nothing changed. (${o} unchanged)`);}s(NP,"renderConvert");var tW=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,G=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,n){if(tW.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}}};async function Zh(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new G("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file body exceeds 1 MiB cap",{limit:1048576,actual:Buffer.byteLength(t.content,"utf8")});await mkdir(dirname(r),{recursive:true});let n=`${r}.tmp.${process.pid}.${Date.now()}`;return await writeFile(n,t.content,"utf8"),await rename(n,r),r}s(Zh,"safeWrite");var cW=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function $o(t){let e=cW.exec(t);return e?{frontmatter:parse(e[1]??"")??{},body:e[2]??""}:{frontmatter:{},body:t}}s($o,"parseMd");function fa(t,e){return Object.keys(t).length===0?e:`---
541
+ `}s(TP,"TEMPLATE_FIXTURE_ROOT_MD");var zK=/^[a-z][a-z0-9-]*$/;async function DP(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!zK.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(it.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:kP(i)},{rel:`src/targets/${e}/index.ts`,content:OP(i)},{rel:`src/targets/${e}/generator.ts`,content:wP(i)},{rel:`src/targets/${e}/importer.ts`,content:EP(i)},{rel:`src/targets/${e}/linter.ts`,content:LP(i)},{rel:`src/targets/${e}/lint.ts`,content:bP(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:AP(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:xP(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:PP(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:TP(i)}],c=[],l=[];for(let p of a){let u=join(r,p.rel);if(!n&&await v(u)){l.push(u);continue}await S(u,p.content),c.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:c,skipped:l,postSteps:m}}s(DP,"writeTargetScaffold");async function FP(t,e,r){let n=e[0];return n===void 0||n===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:n==="scaffold"?VK(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${n}`}}s(FP,"runTarget");async function VK(t,e,r){let n=e[0];if(!n)throw new kr("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 DP({id:n,displayName:o,projectRoot:r,force:i});}catch(c){return {exitCode:1,data:{id:n,written:[],skipped:[],postSteps:[]},error:c instanceof Error?c.message:String(c)}}return {exitCode:0,data:{id:n,written:a.written.map(c=>NP(c,r)),skipped:a.skipped.map(c=>NP(c,r)),postSteps:a.postSteps}}}s(VK,"runScaffold");function NP(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(NP,"relativize");nt();function vP(t){if(t.error&&I.error(t.error),t.showHelp){JK();return}let{data:e}=t;for(let r of e.written)I.success(`created ${r}`);for(let r of e.skipped)I.warn(`skipped ${r} (already exists \u2014 use --force to overwrite)`);if(e.written.length>0){I.info(""),I.info("Next steps:");for(let r of e.postSteps)I.info(` ${r}`);}}s(vP,"renderTarget");function JK(){I.info("Usage: agentsmesh target <subcommand> [args] [flags]"),I.info(""),I.info("Subcommands:"),I.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),I.info(""),I.info("Flags (scaffold):"),I.info(" --name <displayName> Human-readable name (defaults to id)"),I.info(" --force Overwrite existing files");}s(JK,"printTargetHelp");ye();zo();A();le();Vn();ln();function rW(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(rW,"shouldSymlink");function nW(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let n of r){if(!rW(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(nW,"createTempProjectRoot");async function Kp(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 c=i.toLowerCase().trim(),l=a.toLowerCase().trim();if(c===l)throw new Error("--from and --to must be different targets.");let m=He(c),p=He(l);if(!m||!p)try{let{config:C}=await lt(r,"project");await Jt(C,r);}catch{let C=[];throw m||C.push(`--from "${i}"`),p||C.push(`--to "${a}"`),new Error(`Unknown ${C.join(" and ")}. Supported: ${it.join(", ")}.`)}let u=tt(c);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${it.join(", ")}.`);if(!tt(l))throw new Error(`Unknown --to "${a}". Supported: ${it.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",R=nW(o);try{await u.generators.importFrom(R,{scope:n});let C=await pe(R),_=jo.parse({version:1,targets:p?[l]:[],pluginTargets:p?[]:[l]}),E=await je({config:_,canonical:C,projectRoot:o,scope:n,targetFilter:[l]});if(!g){for(let x of E)if(x.status==="created"||x.status==="updated"){let Z=sa(o,x.path,x.target);await S(Z,x.content);}}let T=E.filter(x=>x.status!=="skipped"),D=T.map(x=>({path:x.path,target:x.target,status:x.status}));return {exitCode:0,data:{from:c,to:l,mode:h,files:D,summary:{created:T.filter(x=>x.status==="created").length,updated:T.filter(x=>x.status==="updated").length,unchanged:T.filter(x=>x.status==="unchanged").length}}}}finally{rmSync(R,{recursive:true,force:true});}}s(Kp,"runConvert");nt();function MP(t){let{data:e}=t;if(e.files.length===0){I.info(`No files found to convert from ${e.from}.`);return}if(e.mode==="dry-run"){for(let i of e.files)I.info(`[dry-run] ${i.status} ${i.path} (${i.target})`);return}for(let i of e.files)(i.status==="created"||i.status==="updated")&&I.success(`${i.status} ${i.path}`);let{created:r,updated:n,unchanged:o}=e.summary;r>0||n>0?I.info(`Converted from ${e.from} \u2192 ${e.to}: ${r} created, ${n} updated, ${o} unchanged`):I.info(`Nothing changed. (${o} unchanged)`);}s(MP,"renderConvert");var oW=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,G=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,n){if(oW.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}}};async function qh(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new G("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file body exceeds 1 MiB cap",{limit:1048576,actual:Buffer.byteLength(t.content,"utf8")});await mkdir(dirname(r),{recursive:true});let n=`${r}.tmp.${process.pid}.${Date.now()}`;return await writeFile(n,t.content,"utf8"),await rename(n,r),r}s(qh,"safeWrite");var uW=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function $o(t){let e=uW.exec(t);return e?{frontmatter:parse(e[1]??"")??{},body:e[2]??""}:{frontmatter:{},body:t}}s($o,"parseMd");function fa(t,e){return Object.keys(t).length===0?e:`---
542
542
  ${stringify(t).trimEnd()}
543
543
  ---
544
544
 
545
- ${e}`}s(fa,"serializeMd");var dW=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*$/,fW={rules:"_root"};function Kp(t){if(!dW.test(t)||t.includes("..")||t.includes("//")||t.endsWith("/"))throw new G("INVALID_NAME",`invalid name: ${t}`)}s(Kp,"checkName");function Wp(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(Wp,"pathFor");function ga(t){let{feature:e,frontmatterSchema:r,toSummary:n}=t,o=s(c=>resolve(c,".agentsmesh",e),"featureDir");async function i(c){try{return (await readdir(o(c),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(c){try{return await stat(c),!0}catch{return false}}return s(a,"exists"),{async list(c){let l=await i(c.projectRoot),m=[];for(let p of l){let u=p.replace(/\.md$/,""),f=await readFile(join(o(c.projectRoot),p),"utf8"),{frontmatter:g}=$o(f);m.push(n(u,g));}return m},async get(c,{name:l}){Kp(l);let m=Wp(c.projectRoot,e,l);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=$o(p);return {name:l,frontmatter:u,body:f}}catch(p){throw p.code==="ENOENT"?new G("NOT_FOUND",`${e} "${l}" not found`):new G("IO_ERROR",`failed to read ${e}`)}},async create(c,{name:l,frontmatter:m,body:p,dry_run:u}){Kp(l);let f=r.safeParse(m);if(!f.success)throw new G("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=Wp(c.projectRoot,e,l);if(await a(g))throw new G("ALREADY_EXISTS",`${e} "${l}" exists`);if((await i(c.projectRoot)).length>=1e3)throw new G("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let R=fa(m,p);return u===true?{path:g,written:false}:(await Zh({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:R}),{path:g,written:true})},async update(c,{name:l,frontmatter:m,body:p,merge:u,dry_run:f}){Kp(l);let g=Wp(c.projectRoot,e,l),h;try{let T=await readFile(g,"utf8");h=$o(T);}catch(T){throw T.code==="ENOENT"?new G("NOT_FOUND",`${e} "${l}" not found`):new G("IO_ERROR",`failed to read ${e}`)}let R=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,C=r.safeParse(R);if(!C.success)throw new G("VALIDATION_FAILED","invalid frontmatter",C.error.issues);let _=p!==void 0?p:h.body,E=fa(R,_);return f===true?{path:g,written:false}:(await Zh({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:E}),{path:g,written:true})},async delete(c,{name:l,force:m,dry_run:p}){if(Kp(l),fW[e]===l&&m!==true)throw new G("PROTECTED_FILE",`${e} "${l}" requires force: true`);let u=Wp(c.projectRoot,e,l);if(!await a(u))throw new G("NOT_FOUND",`${e} "${l}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(ga,"createCanonicalHandlers");var gW=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(),MP=ga({feature:"rules",frontmatterSchema:gW,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var hW=z$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),$P=ga({feature:"commands",frontmatterSchema:hW,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var yW=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(),GP=ga({feature:"agents",frontmatterSchema:yW,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});async function UP(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new G("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(n){throw n.code==="ENOENT"?new G("NOT_FOUND",`skill file not found: ${t.filePath}`):new G("IO_ERROR","failed to read skill file")}}s(UP,"safeRead");var OW=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,wW=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,HP=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function Zc(t){if(!OW.test(t))throw new G("INVALID_NAME",`invalid skill name: ${t}`)}s(Zc,"checkName");function ey(t){if(!wW.test(t)||t.includes("..")||t.includes("//"))throw new G("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(ey,"checkSupportPath");async function zp(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file body exceeds 1 MiB cap");await mkdir(dirname(t),{recursive:true});let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(zp,"atomicWrite");var zP=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),qc=s((t,e)=>resolve(zP(t),e),"skillDir"),Bs={async list(t){let e;try{e=(await readdir(zP(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(qc(t.projectRoot,n),"SKILL.md"),"utf8"),i=$o(o).frontmatter;r.push({name:n,description:i.description??null});}catch{}return r},async get(t,{name:e}){Zc(e);let r=qc(t.projectRoot,e);try{let n=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:o,body:i}=$o(n),c=(await readdir(r)).filter(l=>l!=="SKILL.md").sort();return {name:e,frontmatter:o,body:i,supportingFiles:c}}catch(n){throw n.code==="ENOENT"?new G("NOT_FOUND",`skill "${e}" not found`):new G("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return Zc(e),ey(r),{content:await UP({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){Zc(e.name);let r=HP.safeParse(e.frontmatter);if(!r.success)throw new G("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let n=qc(t.projectRoot,e.name),o=false;try{await stat(n),o=!0;}catch{}if(o)throw new G("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(ey),a.length+1>1e3)throw new G("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:n,written:false,supportingFilesWritten:[]};let c=resolve(n,"SKILL.md");await zp(c,fa(e.frontmatter,e.body));for(let[l,m]of Object.entries(i))await zp(resolve(n,l),m);return {path:n,written:true,supportingFilesWritten:a}},async update(t,e){Zc(e.name);let r=qc(t.projectRoot,e.name),n;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");n=$o(p);}catch(p){throw p.code==="ENOENT"?new G("NOT_FOUND",`skill "${e.name}" not found`):new G("IO_ERROR","failed to read skill")}let o=e.frontmatter===void 0?n.frontmatter:e.merge===true?{...n.frontmatter,...e.frontmatter}:e.frontmatter,i=HP.safeParse(o);if(!i.success)throw new G("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:n.body,c=e.supportingFiles??{};Object.keys(c).forEach(ey);let l=[],m=[];if(e.dry_run===true)return Object.entries(c).forEach(([p,u])=>(u===null?m:l).push(p)),{path:r,written:false,supportingFilesAffected:{written:l,deleted:m}};await zp(resolve(r,"SKILL.md"),fa(o,a));for(let[p,u]of Object.entries(c)){let f=resolve(r,p);if(u===null)try{await rm$1(f),m.push(p);}catch{}else await zp(f,u),l.push(p);}return {path:r,written:true,supportingFilesAffected:{written:l,deleted:m}}},async delete(t,{name:e,dry_run:r}){Zc(e);let n=qc(t.projectRoot,e);try{await stat(n);}catch{throw new G("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:n,deleted:false}:(await rm$1(n,{recursive:true}),{path:n,deleted:true})}};async function VP(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new G("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","config exceeds 1 MiB cap");let e=resolve(t.projectRoot,"agentsmesh.yaml"),r=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(r,t.content,"utf8"),await rename(r,e),e}s(VP,"safeConfigWrite");ln();ba();async function Qc(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new G("IO_ERROR","failed to read yaml")}}s(Qc,"readYaml");async function ya(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file exceeds 1 MiB cap");let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(ya,"atomicWrite");var Se={async getConfig(t){let e=await Qc(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new G("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await Ve(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await Qc(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await Qc(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 Qc(resolve(t.projectRoot,"agentsmesh.yaml"))??{},n={...r},o=s((l,m)=>{m!==void 0&&(n[l]=e.merge===true&&Array.isArray(r[l])?Array.from(new Set([...r[l],...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=jo.safeParse(n);if(!i.success)throw new G("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(n);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await VP({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ve(r).catch(()=>null)??{mcpServers:{}};if(n.mcpServers[e.name]!==void 0)throw new G("ALREADY_EXISTS",`server "${e.name}" exists`);return n.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await ya(r,JSON.stringify(n,null,2)+`
545
+ ${e}`}s(fa,"serializeMd");var yW=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*$/,_W={rules:"_root"};function Wp(t){if(!yW.test(t)||t.includes("..")||t.includes("//")||t.endsWith("/"))throw new G("INVALID_NAME",`invalid name: ${t}`)}s(Wp,"checkName");function Bp(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(Bp,"pathFor");function ga(t){let{feature:e,frontmatterSchema:r,toSummary:n}=t,o=s(c=>resolve(c,".agentsmesh",e),"featureDir");async function i(c){try{return (await readdir(o(c),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(c){try{return await stat(c),!0}catch{return false}}return s(a,"exists"),{async list(c){let l=await i(c.projectRoot),m=[];for(let p of l){let u=p.replace(/\.md$/,""),f=await readFile(join(o(c.projectRoot),p),"utf8"),{frontmatter:g}=$o(f);m.push(n(u,g));}return m},async get(c,{name:l}){Wp(l);let m=Bp(c.projectRoot,e,l);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=$o(p);return {name:l,frontmatter:u,body:f}}catch(p){throw p.code==="ENOENT"?new G("NOT_FOUND",`${e} "${l}" not found`):new G("IO_ERROR",`failed to read ${e}`)}},async create(c,{name:l,frontmatter:m,body:p,dry_run:u}){Wp(l);let f=r.safeParse(m);if(!f.success)throw new G("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=Bp(c.projectRoot,e,l);if(await a(g))throw new G("ALREADY_EXISTS",`${e} "${l}" exists`);if((await i(c.projectRoot)).length>=1e3)throw new G("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let R=fa(m,p);return u===true?{path:g,written:false}:(await qh({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:R}),{path:g,written:true})},async update(c,{name:l,frontmatter:m,body:p,merge:u,dry_run:f}){Wp(l);let g=Bp(c.projectRoot,e,l),h;try{let T=await readFile(g,"utf8");h=$o(T);}catch(T){throw T.code==="ENOENT"?new G("NOT_FOUND",`${e} "${l}" not found`):new G("IO_ERROR",`failed to read ${e}`)}let R=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,C=r.safeParse(R);if(!C.success)throw new G("VALIDATION_FAILED","invalid frontmatter",C.error.issues);let _=p!==void 0?p:h.body,E=fa(R,_);return f===true?{path:g,written:false}:(await qh({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:E}),{path:g,written:true})},async delete(c,{name:l,force:m,dry_run:p}){if(Wp(l),_W[e]===l&&m!==true)throw new G("PROTECTED_FILE",`${e} "${l}" requires force: true`);let u=Bp(c.projectRoot,e,l);if(!await a(u))throw new G("NOT_FOUND",`${e} "${l}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(ga,"createCanonicalHandlers");var IW=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(),jP=ga({feature:"rules",frontmatterSchema:IW,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var CW=z$1.object({description:z$1.string().optional(),"allowed-tools":z$1.array(z$1.string()).optional()}).passthrough(),UP=ga({feature:"commands",frontmatterSchema:CW,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var SW=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(),KP=ga({feature:"agents",frontmatterSchema:SW,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});async function BP(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new G("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(n){throw n.code==="ENOENT"?new G("NOT_FOUND",`skill file not found: ${t.filePath}`):new G("IO_ERROR","failed to read skill file")}}s(BP,"safeRead");var bW=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,AW=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,JP=z$1.object({name:z$1.string().optional(),description:z$1.string().optional()}).passthrough();function qc(t){if(!bW.test(t))throw new G("INVALID_NAME",`invalid skill name: ${t}`)}s(qc,"checkName");function ry(t){if(!AW.test(t)||t.includes("..")||t.includes("//"))throw new G("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(ry,"checkSupportPath");async function Vp(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file body exceeds 1 MiB cap");await mkdir(dirname(t),{recursive:true});let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(Vp,"atomicWrite");var YP=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),Qc=s((t,e)=>resolve(YP(t),e),"skillDir"),Bs={async list(t){let e;try{e=(await readdir(YP(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(Qc(t.projectRoot,n),"SKILL.md"),"utf8"),i=$o(o).frontmatter;r.push({name:n,description:i.description??null});}catch{}return r},async get(t,{name:e}){qc(e);let r=Qc(t.projectRoot,e);try{let n=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:o,body:i}=$o(n),c=(await readdir(r)).filter(l=>l!=="SKILL.md").sort();return {name:e,frontmatter:o,body:i,supportingFiles:c}}catch(n){throw n.code==="ENOENT"?new G("NOT_FOUND",`skill "${e}" not found`):new G("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return qc(e),ry(r),{content:await BP({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){qc(e.name);let r=JP.safeParse(e.frontmatter);if(!r.success)throw new G("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let n=Qc(t.projectRoot,e.name),o=false;try{await stat(n),o=!0;}catch{}if(o)throw new G("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(ry),a.length+1>1e3)throw new G("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:n,written:false,supportingFilesWritten:[]};let c=resolve(n,"SKILL.md");await Vp(c,fa(e.frontmatter,e.body));for(let[l,m]of Object.entries(i))await Vp(resolve(n,l),m);return {path:n,written:true,supportingFilesWritten:a}},async update(t,e){qc(e.name);let r=Qc(t.projectRoot,e.name),n;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");n=$o(p);}catch(p){throw p.code==="ENOENT"?new G("NOT_FOUND",`skill "${e.name}" not found`):new G("IO_ERROR","failed to read skill")}let o=e.frontmatter===void 0?n.frontmatter:e.merge===true?{...n.frontmatter,...e.frontmatter}:e.frontmatter,i=JP.safeParse(o);if(!i.success)throw new G("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:n.body,c=e.supportingFiles??{};Object.keys(c).forEach(ry);let l=[],m=[];if(e.dry_run===true)return Object.entries(c).forEach(([p,u])=>(u===null?m:l).push(p)),{path:r,written:false,supportingFilesAffected:{written:l,deleted:m}};await Vp(resolve(r,"SKILL.md"),fa(o,a));for(let[p,u]of Object.entries(c)){let f=resolve(r,p);if(u===null)try{await rm$1(f),m.push(p);}catch{}else await Vp(f,u),l.push(p);}return {path:r,written:true,supportingFilesAffected:{written:l,deleted:m}}},async delete(t,{name:e,dry_run:r}){qc(e);let n=Qc(t.projectRoot,e);try{await stat(n);}catch{throw new G("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:n,deleted:false}:(await rm$1(n,{recursive:true}),{path:n,deleted:true})}};async function XP(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new G("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","config exceeds 1 MiB cap");let e=resolve(t.projectRoot,"agentsmesh.yaml"),r=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(r,t.content,"utf8"),await rename(r,e),e}s(XP,"safeConfigWrite");ln();Aa();async function tl(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new G("IO_ERROR","failed to read yaml")}}s(tl,"readYaml");async function ya(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new G("LIMIT_EXCEEDED","file exceeds 1 MiB cap");let r=`${t}.tmp.${process.pid}.${Date.now()}`;await writeFile(r,e,"utf8"),await rename(r,t);}s(ya,"atomicWrite");var Se={async getConfig(t){let e=await tl(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new G("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await Ve(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await tl(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await tl(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 tl(resolve(t.projectRoot,"agentsmesh.yaml"))??{},n={...r},o=s((l,m)=>{m!==void 0&&(n[l]=e.merge===true&&Array.isArray(r[l])?Array.from(new Set([...r[l],...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=jo.safeParse(n);if(!i.success)throw new G("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(n);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await XP({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ve(r).catch(()=>null)??{mcpServers:{}};if(n.mcpServers[e.name]!==void 0)throw new G("ALREADY_EXISTS",`server "${e.name}" exists`);return n.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await ya(r,JSON.stringify(n,null,2)+`
546
546
  `),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ve(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new G("NOT_FOUND",`server "${e.name}" not found`);return n.mcpServers[e.name]=e.merge===true?{...n.mcpServers[e.name],...e.server}:e.server,e.dry_run===true?{path:r,written:false}:(await ya(r,JSON.stringify(n,null,2)+`
547
547
  `),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),n=await Ve(r).catch(()=>null);if(n===null||n.mcpServers[e.name]===void 0)throw new G("NOT_FOUND",`server "${e.name}" not found`);return delete n.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await ya(r,JSON.stringify(n,null,2)+`
548
- `),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),n=await Qc(r)??{allow:[],deny:[],ask:[]},o={...n},i=s((a,c)=>{c!==void 0&&(o[a]=e.mode==="append"?Array.from(new Set([...n[a]??[],...c])):c);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await ya(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 ya(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 ya(r,n.join(`
548
+ `),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),n=await tl(r)??{allow:[],deny:[],ask:[]},o={...n},i=s((a,c)=>{c!==void 0&&(o[a]=e.mode==="append"?Array.from(new Set([...n[a]??[],...c])):c);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await ya(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 ya(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 ya(r,n.join(`
549
549
  `)+`
550
- `),{path:r,written:true})}};rh();ze();function TW(){return Object.fromEntries(it.map(t=>[t,Object.fromEntries(Object.entries(RA).map(([e,r])=>[e,r[t]]))]))}s(TW,"buildTargetIndex");var JP=TW(),oy={async list(){return JP},async get(t){let e=JP[t.targetId];if(e===void 0)throw new G("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};qn();qn();ol();le();nn();Vn();ye();ze();async function sy(t,e){let r=tt(t);if(!r)throw new cn(t,{supported:[...it,...Qm().map(n=>n.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(sy,"importFrom");async function _a(t,e={}){let r=e.scope??"project",{config:n,context:o}=await lt(t,r);await Jt(n,t);let{canonical:i}=await ee(n,o.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},o.canonicalDir);return {config:n,canonical:i,projectRoot:o.rootBase,scope:r,configDir:o.configDir,canonicalDir:o.canonicalDir}}s(_a,"loadProjectContext");async function iy(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return xp(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(iy,"lint");async function ay(t){let e=await je(t);return {...bp(e),results:e}}s(ay,"diff");async function cy(t){return Pp(t)}s(cy,"check");qn();nn();zo();ol();ut();ye();Mt();A();function Ia(t){if(t instanceof G)throw t;if(t instanceof cn)throw new G("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new G("VALIDATION_FAILED",e):/lock/i.test(e)?new G("LOCK_HELD","generate lock is held"):new G("IO_ERROR","engine failure",{reason:e})}s(Ia,"wrapEngineError");var Hs={async generate(t,e){try{let r=await _a(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,i=(await je({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=sa(r.projectRoot,m.path,m.target);await S(p,m.content);}let c={};for(let m of a){let p=c[m.target]??{filesWritten:0};c[m.target]={filesWritten:p.filesWritten+1};}let l={filesWritten:a.length,byTarget:c,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(l.files=i.map(m=>m.path)),l}catch(r){Ia(r);}},async lint(t,e){try{let r=await _a(t.projectRoot),n=await iy({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope}),o=e.severity;return {issues:(o?n.diagnostics.filter(a=>a.level===o):n.diagnostics).map(a=>({level:a.level,file:a.file,target:a.target,message:a.message}))}}catch(r){Ia(r);}},async check(t){try{let e=await _a(t.projectRoot),r=await cy({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){Ia(e);}},async diff(t,e){try{let r=await _a(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,o=await ay({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){Ia(r);}},async import(t,e){if(e.dry_run===true)throw new G("VALIDATION_FAILED","dry_run is not supported for import \u2014 the engine writes files directly. Use diff to preview changes instead.");try{let r=await sy(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 G("VALIDATION_FAILED",`unknown target "${e.from}"`);let n=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(n))throw new G("VALIDATION_FAILED",n);Ia(r);}},async convert(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},n=await Up(r,t.projectRoot);return {filesAffected:n.data.summary.created+n.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let n=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(n))throw new G("VALIDATION_FAILED",n);Ia(r);}}};function YP(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(YP,"zodToMcpSchema");var Yn=z$1.object({}).strict(),XP=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")')}),MW=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")});function ly(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:Yn,handler:s(n=>e.list(n),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:XP,handler:s((n,o)=>e.get(n,o),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:MW,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(ly,"canonicalTools");var Vp=[...ly("rule",MP),...ly("command",$P),...ly("agent",GP),{name:"list_skills",description:"List skills",inputSchema:Yn,handler:s(t=>Bs.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:XP,handler:s((t,e)=>Bs.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)=>Bs.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)=>Bs.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)=>Bs.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)=>Bs.delete(t,e),"handler")},{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Yn,handler:s(t=>Se.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Yn,handler:s(t=>Se.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Yn,handler:s(t=>Se.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Yn,handler:s(t=>Se.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Yn,handler:s(t=>Se.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"},{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)=>Se.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:z$1.record(z$1.string(),z$1.unknown()).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)=>Se.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:z$1.record(z$1.string(),z$1.unknown()),merge:z$1.boolean().optional(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>Se.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)=>Se.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:z$1.array(z$1.string()).optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:z$1.array(z$1.string()).optional().describe("Denied tool patterns"),ask:z$1.array(z$1.string()).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)=>Se.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:z$1.record(z$1.string(),z$1.array(z$1.unknown())).describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Se.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)=>Se.updateIgnore(t,e),"handler")},{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:Yn,handler:s(()=>oy.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)=>oy.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)=>Hs.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)=>Hs.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:Yn,handler:s(t=>Hs.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)=>Hs.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)=>Hs.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)=>Hs.convert(t,e),"handler")}],my=Vp.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")}));zo();async function jW(t){let e=resolve(t);for(;;){try{return await stat(resolve(e,"agentsmesh.yaml")),e}catch{}let r=dirname(e);if(r===e)throw new G("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(jW,"findProjectRoot");async function py(t){let e=await jW(t.cwd);return {projectRoot:e,loadCanonical:s(()=>pe(e),"loadCanonical")}}s(py,"resolveContext");async function XW(){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(XW,"pkgVersion");function ZW(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(ZW,"matchTemplate");function qW(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(qW,"extractTemplateParams");async function qP(){let t=new Server({name:"agentsmesh-mcp",version:await XW()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:Vp.map(e=>({name:e.name,description:e.description,inputSchema:YP(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=Vp.find(n=>n.name===e.params.name);if(!r)return {isError:true,content:[{type:"text",text:JSON.stringify({code:"NOT_FOUND",message:`unknown tool: ${e.params.name}`})}]};try{let n=r.inputSchema.safeParse(e.params.arguments??{});if(!n.success)throw new G("VALIDATION_FAILED","invalid input",n.error.issues);let o=await py({cwd:process.cwd()}),i=await r.handler(o,n.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(n){let o=n instanceof G?n.toEnvelope():{code:"IO_ERROR",message:n instanceof Error?n.message:"unknown error"};return {isError:true,content:[{type:"text",text:JSON.stringify(o)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:my.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=my.find(a=>a.uri===e.params.uri||ZW(a.uri,e.params.uri));if(!r)throw new G("NOT_FOUND",`resource not found: ${e.params.uri}`);let n=await py({cwd:process.cwd()}),o=qW(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(qP,"startServer");nt();async function QP(t,e){_y(),await qP();}s(QP,"runMcp");var tT={generate:s(async(t,e)=>{let r=await ia(t,void 0,{printMatrix:t.json!==true});ce("generate",r,t,()=>aa(r));},"generate"),init:s(async(t,e)=>{let r=await $A(process.cwd(),{yes:t.yes===true,global:t.global===true});ce("init",r,t,()=>GA(r));},"init"),import:s(async(t,e)=>{let r=await UA(t);ce("import",r,t,()=>ZA(r));},"import"),diff:s(async(t,e)=>{let r=await WA(t);ce("diff",r,t,()=>qA(r));},"diff"),lint:s(async(t,e)=>{let r=await JA(t);ce("lint",r,t,()=>YA(r));},"lint"),check:s(async(t,e)=>{let r=await rx(t);ce("check",r,t,()=>XA(r));},"check"),merge:s(async(t,e)=>{let r=await sx(t);ce("merge",r,t,()=>QA(r));},"merge"),matrix:s(async(t,e)=>{let r=await $c(t);ce("matrix",r,t,()=>jc(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){Js("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await ex(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 dP(t,e,process.cwd());ce("install",r,t,()=>fP(r));},"install"),plugin:s(async(t,e)=>{let r=await _P(t,e,process.cwd());ce("plugin",r,t,()=>IP(r));},"plugin"),target:s(async(t,e)=>{let r=await TP(t,e,process.cwd());ce("target",r,t,()=>DP(r));},"target"),convert:s(async(t,e)=>{let r=await Up(t);ce("convert",r,t,()=>NP(r));},"convert"),mcp:s(async(t,e)=>{await QP();},"mcp")};function eB(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),c=t[o+1];c===void 0||c.startsWith("--")?e[a]=true:(e[a]=c,o++);continue}n==="help"?n=i:r.push(i);}return {command:n,flags:e,args:r}}s(eB,"parseArgs");var rB=gy(tT);async function nB(t){let{command:e,flags:r,args:n}=t;if(e==="help"){Ry();return}if(e==="version"){wy();return}r.json===true&&yy(),await rB.route(e,r,n);}s(nB,"main");function oB(){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(oB,"isMainModule");if(oB()){let t=eB(process.argv.slice(2));nB(t).catch(e=>Ey(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
551
- export{eB as parseArgs};
550
+ `),{path:r,written:true})}};nh();ze();function vW(){return Object.fromEntries(it.map(t=>[t,Object.fromEntries(Object.entries(wA).map(([e,r])=>[e,r[t]]))]))}s(vW,"buildTargetIndex");var ZP=vW(),sy={async list(){return ZP},async get(t){let e=ZP[t.targetId];if(e===void 0)throw new G("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};qn();qn();sl();le();nn();Vn();ye();ze();async function iy(t,e){let r=tt(t);if(!r)throw new cn(t,{supported:[...it,...tp().map(n=>n.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(iy,"importFrom");async function _a(t,e={}){let r=e.scope??"project",{config:n,context:o}=await lt(t,r);await Jt(n,t);let{canonical:i}=await ee(n,o.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},o.canonicalDir);return {config:n,canonical:i,projectRoot:o.rootBase,scope:r,configDir:o.configDir,canonicalDir:o.canonicalDir}}s(_a,"loadProjectContext");async function ay(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return Pp(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(ay,"lint");async function cy(t){let e=await je(t);return {...Ap(e),results:e}}s(cy,"diff");async function ly(t){return Tp(t)}s(ly,"check");qn();nn();zo();sl();ut();ye();Mt();A();function Ia(t){if(t instanceof G)throw t;if(t instanceof cn)throw new G("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new G("VALIDATION_FAILED",e):/lock/i.test(e)?new G("LOCK_HELD","generate lock is held"):new G("IO_ERROR","engine failure",{reason:e})}s(Ia,"wrapEngineError");var Hs={async generate(t,e){try{let r=await _a(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,i=(await je({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=sa(r.projectRoot,m.path,m.target);await S(p,m.content);}let c={};for(let m of a){let p=c[m.target]??{filesWritten:0};c[m.target]={filesWritten:p.filesWritten+1};}let l={filesWritten:a.length,byTarget:c,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(l.files=i.map(m=>m.path)),l}catch(r){Ia(r);}},async lint(t,e){try{let r=await _a(t.projectRoot),n=await ay({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope}),o=e.severity;return {issues:(o?n.diagnostics.filter(a=>a.level===o):n.diagnostics).map(a=>({level:a.level,file:a.file,target:a.target,message:a.message}))}}catch(r){Ia(r);}},async check(t){try{let e=await _a(t.projectRoot),r=await ly({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){Ia(e);}},async diff(t,e){try{let r=await _a(t.projectRoot),n=e.targets&&e.targets.length>0?e.targets:void 0,o=await cy({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){Ia(r);}},async import(t,e){if(e.dry_run===true)throw new G("VALIDATION_FAILED","dry_run is not supported for import \u2014 the engine writes files directly. Use diff to preview changes instead.");try{let r=await iy(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 G("VALIDATION_FAILED",`unknown target "${e.from}"`);let n=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(n))throw new G("VALIDATION_FAILED",n);Ia(r);}},async convert(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},n=await Kp(r,t.projectRoot);return {filesAffected:n.data.summary.created+n.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let n=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(n))throw new G("VALIDATION_FAILED",n);Ia(r);}}};function qP(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(qP,"zodToMcpSchema");var Yn=z$1.object({}).strict(),QP=z$1.object({name:z$1.string().describe('Item name (e.g. "auth", "code-review")')}),UW=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")});function my(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:Yn,handler:s(n=>e.list(n),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:QP,handler:s((n,o)=>e.get(n,o),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:UW,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(my,"canonicalTools");var Jp=[...my("rule",jP),...my("command",UP),...my("agent",KP),{name:"list_skills",description:"List skills",inputSchema:Yn,handler:s(t=>Bs.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:QP,handler:s((t,e)=>Bs.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)=>Bs.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)=>Bs.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)=>Bs.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)=>Bs.delete(t,e),"handler")},{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:Yn,handler:s(t=>Se.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:Yn,handler:s(t=>Se.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:Yn,handler:s(t=>Se.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:Yn,handler:s(t=>Se.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:Yn,handler:s(t=>Se.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"},{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)=>Se.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:z$1.record(z$1.string(),z$1.unknown()).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)=>Se.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:z$1.record(z$1.string(),z$1.unknown()),merge:z$1.boolean().optional(),dry_run:z$1.boolean().optional()}),handler:s((t,e)=>Se.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)=>Se.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:z$1.array(z$1.string()).optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:z$1.array(z$1.string()).optional().describe("Denied tool patterns"),ask:z$1.array(z$1.string()).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)=>Se.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:z$1.record(z$1.string(),z$1.array(z$1.unknown())).describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z$1.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Se.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)=>Se.updateIgnore(t,e),"handler")},{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:Yn,handler:s(()=>sy.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)=>sy.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)=>Hs.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)=>Hs.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:Yn,handler:s(t=>Hs.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)=>Hs.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)=>Hs.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)=>Hs.convert(t,e),"handler")}],py=Jp.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")}));zo();async function BW(t){let e=resolve(t);for(;;){try{return await stat(resolve(e,"agentsmesh.yaml")),e}catch{}let r=dirname(e);if(r===e)throw new G("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(BW,"findProjectRoot");async function uy(t){let e=await BW(t.cwd);return {projectRoot:e,loadCanonical:s(()=>pe(e),"loadCanonical")}}s(uy,"resolveContext");async function tB(){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(tB,"pkgVersion");function eB(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s(eB,"matchTemplate");function rB(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(rB,"extractTemplateParams");async function eT(){let t=new Server({name:"agentsmesh-mcp",version:await tB()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:Jp.map(e=>({name:e.name,description:e.description,inputSchema:qP(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=Jp.find(n=>n.name===e.params.name);if(!r)return {isError:true,content:[{type:"text",text:JSON.stringify({code:"NOT_FOUND",message:`unknown tool: ${e.params.name}`})}]};try{let n=r.inputSchema.safeParse(e.params.arguments??{});if(!n.success)throw new G("VALIDATION_FAILED","invalid input",n.error.issues);let o=await uy({cwd:process.cwd()}),i=await r.handler(o,n.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(n){let o=n instanceof G?n.toEnvelope():{code:"IO_ERROR",message:n instanceof Error?n.message:"unknown error"};return {isError:true,content:[{type:"text",text:JSON.stringify(o)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:py.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=py.find(a=>a.uri===e.params.uri||eB(a.uri,e.params.uri));if(!r)throw new G("NOT_FOUND",`resource not found: ${e.params.uri}`);let n=await uy({cwd:process.cwd()}),o=rB(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(eT,"startServer");nt();async function rT(t,e){Iy(),await eT();}s(rT,"runMcp");var nT={generate:s(async(t,e)=>{let r=await ia(t,void 0,{printMatrix:t.json!==true});ce("generate",r,t,()=>aa(r));},"generate"),init:s(async(t,e)=>{let r=await UA(process.cwd(),{yes:t.yes===true,global:t.global===true});ce("init",r,t,()=>KA(r));},"init"),import:s(async(t,e)=>{let r=await BA(t);ce("import",r,t,()=>tx(r));},"import"),diff:s(async(t,e)=>{let r=await zA(t);ce("diff",r,t,()=>ex(r));},"diff"),lint:s(async(t,e)=>{let r=await ZA(t);ce("lint",r,t,()=>qA(r));},"lint"),check:s(async(t,e)=>{let r=await sx(t);ce("check",r,t,()=>QA(r));},"check"),merge:s(async(t,e)=>{let r=await cx(t);ce("merge",r,t,()=>rx(r));},"merge"),matrix:s(async(t,e)=>{let r=await Gc(t);ce("matrix",r,t,()=>Uc(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){Js("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await ox(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 hP(t,e,process.cwd());ce("install",r,t,()=>yP(r));},"install"),plugin:s(async(t,e)=>{let r=await SP(t,e,process.cwd());ce("plugin",r,t,()=>RP(r));},"plugin"),target:s(async(t,e)=>{let r=await FP(t,e,process.cwd());ce("target",r,t,()=>vP(r));},"target"),convert:s(async(t,e)=>{let r=await Kp(t);ce("convert",r,t,()=>MP(r));},"convert"),mcp:s(async(t,e)=>{await rT();},"mcp")};function sB(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),c=t[o+1];c===void 0||c.startsWith("--")?e[a]=true:(e[a]=c,o++);continue}n==="help"?n=i:r.push(i);}return {command:n,flags:e,args:r}}s(sB,"parseArgs");var iB=hy(nT);async function aB(t){let{command:e,flags:r,args:n}=t;if(e==="help"){ky();return}if(e==="version"){wy();return}r.json===true&&_y(),await iB.route(e,r,n);}s(aB,"main");function cB(){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(cB,"isMainModule");if(cB()){let t=sB(process.argv.slice(2));aB(t).catch(e=>Ey(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
551
+ export{sB as parseArgs};