agentsmesh 0.15.0 → 0.17.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/CHANGELOG.md +42 -0
- package/README.md +24 -24
- package/dist/canonical.d.ts +2 -2
- package/dist/canonical.js +6808 -4402
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +205 -195
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +7133 -4716
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7145 -4728
- package/dist/index.js.map +1 -1
- package/dist/{schema-o4oXUVBP.d.ts → schema-CDrgr5fq.d.ts} +13 -0
- package/dist/{target-descriptor--Nw5i4v3.d.ts → target-descriptor-CYgyhcco.d.ts} +1 -1
- package/dist/targets.d.ts +3 -3
- package/dist/targets.js +10029 -7793
- package/dist/targets.js.map +1 -1
- package/package.json +1 -1
- package/schemas/agentsmesh.json +21 -0
- package/schemas/pack.json +6 -0
package/dist/cli.js
CHANGED
|
@@ -1,175 +1,185 @@
|
|
|
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 {
|
|
3
|
-
`);},warn(t){
|
|
4
|
-
`);},error(t){
|
|
5
|
-
`);},success(t){
|
|
6
|
-
`);},debug(t){
|
|
7
|
-
`);},table(t){if(
|
|
8
|
-
`);for(let
|
|
9
|
-
`);}
|
|
10
|
-
`);}};});var
|
|
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:`---
|
|
2
|
+
import {resolve,join,sep,dirname,extname,basename,relative,win32,posix,normalize}from'path';import {rm as rm$1,readFile,readdir,stat,mkdir,writeFile,rename,lstat,unlink,chmod,access,realpath,readlink,symlink,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {realpathSync,rmSync,statSync,existsSync,mkdtempSync,readdirSync,symlinkSync,mkdirSync,constants,readFileSync}from'fs';import {z}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 JI 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 az from'chokidar';import*as HD 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 II=Object.defineProperty;var s=(t,e)=>II(t,"name",{value:e,configurable:true});var d=(t,e)=>()=>(t&&(e=t(t=0)),e);var wd=(t,e)=>{for(var r in e)II(t,r,{get:e[r],enumerable:true});};function CI(){Gs=true;}function EI(){RI=true;}function qi(t){RI?process.stderr.write(t):process.stdout.write(t);}function fv(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function wc(t,e){return fv()?e:`${t}${e}${ta.reset}`}function gv(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}var ta,Gs,RI,S,lt=d(()=>{ta={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"},Gs=false,RI=false;s(CI,"muteLogger");s(EI,"redirectLoggerToStderr");s(qi,"out");s(fv,"noColor");s(wc,"c");s(gv,"pad");S={info(t){Gs||qi(wc(ta.cyan,t)+`
|
|
3
|
+
`);},warn(t){Gs||process.stderr.write(wc(ta.yellow,"\u26A0 ")+t+`
|
|
4
|
+
`);},error(t){Gs||process.stderr.write(wc(ta.red,"\u2717 ")+t+`
|
|
5
|
+
`);},success(t){Gs||qi(wc(ta.green,"\u2713 ")+t+`
|
|
6
|
+
`);},debug(t){Gs||process.env.AGENTSMESH_DEBUG==="1"&&qi(wc(ta.cyan,"[debug] ")+t+`
|
|
7
|
+
`);},table(t){if(Gs||t.length===0)return;let e=t[0].length,r=[];for(let n=0;n<e;n++){let i=0;for(let a=0;a<t.length;a++){let c=[...t[a][n]].length;c>i&&(i=c);}r[n]=i;}let o="+"+r.map(n=>"-".repeat(n+2)).join("+")+"+";qi(o+`
|
|
8
|
+
`);for(let n=0;n<t.length;n++){let a="| "+t[n].map((c,l)=>gv(c,r[l])).join(" | ")+" |";qi(a+`
|
|
9
|
+
`);}qi(o+`
|
|
10
|
+
`);}};});var Ko,hr,ra,Xr,oa,$e,Bo=d(()=>{Ko=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,o){super(r,o),this.name="AgentsMeshError",this.code=e;}},hr=class extends Ko{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;}},ra=class extends Ko{static{s(this,"ConfigValidationError");}issues;constructor(e,r,o){super("AM_CONFIG_INVALID",`Invalid config at ${e}: ${r.join("; ")}. Fix the YAML and try again.`,o),this.name="ConfigValidationError",this.issues=r;}},Xr=class extends Ko{static{s(this,"TargetNotFoundError");}target;constructor(e,r){let o=r?.supported?` Supported: ${r.supported.join(", ")}.`:"";super("AM_TARGET_NOT_FOUND",`Unknown target "${e}".${o}`,r),this.name="TargetNotFoundError",this.target=e;}},oa=class extends Ko{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,o){super("AM_LOCK_ACQUISITION_FAILED",`Could not acquire generate lock at ${e}: currently held by ${r}. Wait for the other process to finish, or remove ${e} manually if you are sure no agentsmesh process is running.`,o),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},$e=class extends Ko{static{s(this,"FileSystemError");}path;errnoCode;constructor(e,r,o){super("AM_FILESYSTEM",r,o),this.name="FileSystemError",this.path=e,this.errnoCode=o?.errnoCode;}};});function PI(t){let e=extname(t).toLowerCase();if(e.length>0)return Cv.has(e);let r=basename(t).toLowerCase();return Ev.has(r)}function NI(t){return t.replace(/\r\n?/g,`
|
|
11
|
+
`)}function Td(t){return Ov.has(extname(t).toLowerCase())?493:void 0}var bd,Cv,Ev,Ov,xd=d(()=>{bd="\uFEFF",Cv=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),Ev=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(PI,"shouldNormalizeLineEndings");s(NI,"normalizeLineEndings");Ov=new Set([".sh",".bash",".zsh"]);s(Td,"executableModeFor");});async function F(t,e){let r;try{r=await realpath(t);}catch(n){let i=n;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="ELOOP")return [];throw new $e(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:n,errnoCode:i.code})}let o=e??new Set;if(o.has(r))return [];o.add(r);try{let n=await readdir(t,{withFileTypes:!0}),i=[];for(let a of n){let c=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(c).then(m=>m.isDirectory(),()=>!1)?i.push(...await F(c,o)):i.push(c);}return i}catch(n){let i=n;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="EACCES")return [];throw new $e(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:n,errnoCode:i.code})}}async function Pd(t,e){let r=resolve(t);try{if(!(await lstat(e)).isSymbolicLink()||resolve(dirname(e),await readlink(e))===r)return;await unlink(e);}catch(o){if(o.code!=="ENOENT")throw o}await symlink(r,e,"dir");}var FI=d(()=>{Bo();s(F,"readDirRecursive");s(Pd,"ensureCacheSymlink");});async function y(t){try{let e=await readFile(t,"utf-8");return e.startsWith(bd)?e.slice(bd.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new $e(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function I(t,e,r){let o=dirname(t);await mkdir(o,{recursive:true});try{let c=await lstat(t);if(c.isDirectory())throw new $e(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});c.isSymbolicLink()&&await unlink(t).catch(l=>{if(l.code!=="ENOENT")throw l});}catch(c){if(c instanceof $e||c.code!=="ENOENT")throw c}let n=`${t}.tmp`,i=PI(t)?NI(e):e,a=r?.mode??Td(t);try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(l){if(l.code!=="ENOENT")throw l}let c={encoding:"utf-8",flag:"w"};a!==void 0&&(c.mode=a),await writeFile(n,i,c),await rename(n,t),a!==void 0&&await chmod(t,a);}catch(c){await rm$1(n,{force:true}).catch(()=>{});let l=c;throw new $e(t,`Failed to write ${t}: ${l.message}. Check permissions and disk space.`,{cause:c,errnoCode:l.code})}}async function M(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function k(t){await mkdir(t,{recursive:true});}var w=d(()=>{Bo();xd();FI();xd();s(y,"readFileSafe");s(I,"writeFileAtomic");s(M,"exists");s(k,"mkdirp");});function yr(t){return Nd.includes(t)}var Nd,$I=d(()=>{Nd=["aider","amazon-q","amp","antigravity","augment-code","claude-code","cline","codex-cli","continue","copilot","crush","cursor","gemini-cli","goose","junie","kilo-code","kiro","opencode","qwen-code","roo-code","trae","warp","windsurf","zed"];s(yr,"isBuiltinTargetId");});var yt,Tc,_r=d(()=>{$I();yt=Nd,Tc="codex-cli";});var jI,je,na,Pc,Wv,Kv,xc,Bv,Hv,$s,Ho=d(()=>{_r();jI=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],je=z.enum(yt),na=z.enum(jI),Pc=z.object({skills:z.array(z.string()).optional(),commands:z.array(z.string()).optional(),rules:z.array(z.string()).optional(),agents:z.array(z.string()).optional()}).strict(),Wv=z.object({name:z.string(),source:z.string(),version:z.string().optional(),target:je.optional(),features:z.array(na),path:z.string().optional(),pick:Pc.optional()}),Kv=z.object({strategy:z.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z.array(z.string()).default([])}),xc=z.union([z.boolean(),z.object({project:z.boolean().optional(),global:z.boolean().optional()}).strict()]),Bv=z.object({commands_to_skills:z.object({"codex-cli":xc.optional()}).passthrough().optional(),agents_to_skills:z.object({"gemini-cli":xc.optional(),cline:xc.optional(),"codex-cli":xc.optional(),windsurf:xc.optional()}).passthrough().optional()}).strict().optional(),Hv=z.object({id:z.string().regex(/^[a-z][a-z0-9-]*$/),source:z.string(),version:z.string().optional(),strict:z.boolean().optional()}).strict(),$s=z.object({version:z.literal(1),targets:z.array(je).default([...yt]),features:z.array(na).default([...jI]),extends:z.array(Wv).default([]),overrides:z.record(z.string(),z.record(z.string(),z.unknown())).default({}),collaboration:Kv.default({strategy:"merge",lock_features:[]}),conversions:Bv,plugins:z.array(Hv).default([]),pluginTargets:z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});});async function Jv(t){let e=resolve(t);for(;;){let r=join(e,Fd);if(await M(r))return r;let o=dirname(e);if(o===e)return null;e=o;}}async function Yv(t){let e=await y(t);if(e===null)throw new hr(t);let r=parse(e),o=$s.safeParse(r);if(!o.success){let n=o.error.issues.map(i=>i.message);throw new ra(t,n,{cause:o.error})}return o.data}function Dd(t,e){let r={...t};for(let[o,n]of Object.entries(e)){if(n==null)continue;let i=r[o];typeof n=="object"&&!Array.isArray(n)&&n!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[o]=Dd(i,n):r[o]=n;}return r}function Xv(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=Dd(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Dd(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}async function ym(t){let e=join(t,Fd),r=await Yv(e),o=join(t,Vv),n=await y(o);if(n!==null){let i=parse(n);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=Xv(r,i),c=$s.safeParse(a);if(c.success)r=c.data;else {let l=c.error.issues.map(m=>m.message).join("; ");S.warn(`Ignoring invalid agentsmesh.local.yaml at ${o}: ${l}. Using project config instead.`);}}}return {config:r,configDir:t}}async function _m(t){let e=await Jv(t);if(e===null)throw new hr(join(t,Fd));return ym(dirname(e))}var Fd,Vv,Im=d(()=>{w();lt();Bo();Ho();Fd="agentsmesh.yaml",Vv="agentsmesh.local.yaml";s(Jv,"findConfigPath");s(Yv,"loadConfig");s(Dd,"deepMergeObjects");s(Xv,"mergeLocalConfig");s(ym,"loadConfigFromExactDir");s(_m,"loadConfigFromDir");});function Nc(t,e="project"){if(e==="project")return {scope:e,rootBase:t,configDir:t,canonicalDir:join(t,".agentsmesh")};let r=homedir(),o=join(r,".agentsmesh");return {scope:e,rootBase:r,configDir:o,canonicalDir:o}}async function Rt(t,e="project"){if(e==="project"){let{config:o,configDir:n}=await _m(t);return {config:o,context:{scope:e,rootBase:n,configDir:n,canonicalDir:join(n,".agentsmesh")}}}let r=Nc(t,e);try{let{config:o}=await ym(r.configDir);return {config:o,context:r}}catch(o){throw o instanceof hr?new hr(o.path,{cause:o,message:`agentsmesh.yaml not found at ${o.path} (global scope). Run 'agentsmesh init --global' to create it under ~/.agentsmesh, or drop the --global flag to operate on the current project.`}):o}}var Ie=d(()=>{Im();Bo();s(Nc,"resolveScopeContext");s(Rt,"loadScopedConfig");});function HI(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}async function Sm(t,e,r,o,n){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,c=t.ref??"HEAD",l=n(i,a,c),m=join(o,l),p=join(m,KI),u=`${m}.tmp`,f=join(u,KI);if(!r.refresh&&await BI(p))return $d(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await sM(nM(t),f),t.ref&&await iM(f,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),$d(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await BI(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),$d(p);throw g}}async function $d(t){return {resolvedPath:t,version:await aM(t)}}async function BI(t){return M(t)}function nM(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 sM(t,e){HI(t,"clone-url"),await jd(["clone",t,e]);}async function iM(t,e){HI(e,"ref"),await jd(["checkout",e],t);}async function aM(t){return jd(["rev-parse","HEAD"],t)}async function jd(t,e){let{stdout:r}=await oM("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}var oM,KI,Ud=d(()=>{w();oM=promisify(execFile),KI="repo";s(HI,"ensureNotFlag");s(Sm,"fetchGitRemoteExtend");s($d,"readCachedRepo");s(BI,"hasCachedRepo");s(nM,"resolveCloneUrl");s(sM,"cloneRepo");s(iM,"checkoutRef");s(aM,"getHeadSha");s(jd,"runGit");});async function uM(t,e){let r=typeof t.headers?.get=="function"?t.headers.get("content-length"):null;if(r!==null){let m=Number(r);if(Number.isFinite(m)&&m>e)throw new Error(`remote response declared ${m} bytes; exceeds cap of ${e}`)}let o=t.body;if(!o){let m=await t.arrayBuffer();if(m.byteLength>e)throw new Error(`remote response is ${m.byteLength} bytes; exceeds cap of ${e}`);return new Uint8Array(m)}let n=o.getReader(),i=[],a=0;for(;;){let{done:m,value:p}=await n.read();if(m)break;if(p){if(a+=p.byteLength,a>e)throw await n.cancel().catch(()=>{}),new Error(`remote response exceeded cap of ${e} bytes during streaming`);i.push(p);}}let c=new Uint8Array(a),l=0;for(let m of i)c.set(m,l),l+=m.byteLength;return c}async function YI(t,e,r){let o=`https://api.github.com/repos/${t}/${e}/releases/latest`,n={Accept:"application/vnd.github+json"};r&&(n.Authorization=`Bearer ${r}`);let i=await globalThis.fetch(o,{headers:n});if(!i.ok)throw new Error(`Failed to resolve latest release for ${t}/${e}: ${i.status} ${i.statusText}`);let a=await i.json();if(!a.tag_name||typeof a.tag_name!="string")throw new Error(`No tag_name in releases/latest response for ${t}/${e}`);return a.tag_name}async function XI(t,e,r,o,n,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,c=r.refresh===true,l=t.tag;if(l==="latest")try{l=await YI(t.org,t.repo,a);}catch(_){if(!i)throw _;return fM(t,e,r,o,n,a)}let m=n("github",`${t.org}/${t.repo}`,l),p=join(o,m);if(!c&&await M(p)){let _=await Wd(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 uM(_,pM);}catch(_){if(r.allowOfflineFallback!==false&&await M(p)){let D=await Wd(p);if(D)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${_ instanceof Error?_.message:String(_)}`),{resolvedPath:join(p,D),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,g);try{await JI.extract({file:h,cwd:p,strict:!0,filter:s((_,A)=>!(dM(_)||A&&"type"in A&&(A.type==="Link"||A.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let C=await Wd(p);if(!C)throw new Error(`Extend "${e}": archive has no top-level directory. Expected a single top-level directory inside the archive.`);return {resolvedPath:join(p,C),version:l}}async function Wd(t){let r=(await readdir(t,{withFileTypes:true})).filter(o=>o.isDirectory()&&!o.name.startsWith("."));return r.length===1?r[0].name:null}function VI(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}function dM(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}async function fM(t,e,r,o,n,i){let a=i?[VI(t.org,t.repo,i)]:[VI(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 Sm(m,e,r,o,n)}catch(p){c=p;}}throw c instanceof Error?c:new Error("Failed to clone GitHub default branch")}var pM,ZI=d(()=>{w();Ud();pM=500*1024*1024;s(uM,"readBoundedResponse");s(YI,"resolveLatestTag");s(XI,"fetchGithubRemoteExtend");s(Wd,"findExtractTopDir");s(VI,"buildGithubCloneUrl");s(dM,"isZipSlipPath");s(fM,"fetchGithubDefaultBranch");});function QI(t,e,r){if(!t.startsWith(e))return null;let o=t.slice(e.length).trim();if(!o)return null;let n=o.lastIndexOf("@");if(n<0)return [o,r];let i=o.slice(0,n).trim(),a=o.slice(n+1).trim();return !i||!a?null:[i,a]}function qI(t){let e=QI(t,"github:","latest");if(!e)return null;let[r,o]=e,n=r.indexOf("/");if(n<0)return null;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();return !i||!a||!o?null:{org:i,repo:a,tag:o}}function tS(t){let e=QI(t,"gitlab:");if(!e)return null;let[r,o]=e,n=r.lastIndexOf("/");if(n<0)return null;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();return !i||!a?null:{namespace:i,project:a,ref:o,cloneUrl:`https://gitlab.com/${i}/${a}.git`}}function eS(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),o=(r<0?e:e.slice(0,r)).trim(),n=r<0?void 0:e.slice(r+1).trim();if(!o||r>=0&&!n)return null;let i;try{i=new URL(o);}catch{return null}return ["https:","http:","ssh:","file:"].includes(i.protocol)?{url:o,ref:n}:null}function js(t){let e=qI(t);if(e)return {kind:"github",...e};let r=tS(t);if(r)return {kind:"gitlab",...r};let o=eS(t);return o?{kind:"git",...o}:null}function Kd(t){return js(t)!==null}var Fc=d(()=>{s(QI,"splitSourceRef");s(qI,"parseGithubSource");s(tS,"parseGitlabSource");s(eS,"parseGitSource");s(js,"parseRemoteSource");s(Kd,"isSupportedRemoteSource");});function _M(t){let e=js(t);return e?e.kind==="github"?sa("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?sa("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):sa("git",e.url,e.ref??"HEAD"):null}async function nS(t,e){let r=_M(t);if(!r)return;let o=e??Se(),n=join(o,r);await rm$1(n,{recursive:true,force:true});}async function sS(t,e){let r=t??Se(),o=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,n;try{n=await readdir(r);}catch{return}let i=Date.now();await Promise.all(n.map(async a=>{let c=join(r,a);try{let{mtimeMs:l}=await stat(c);i-l>o&&await rm$1(c,{recursive:!0,force:!0});}catch{}}));}var Bd=d(()=>{vc();Fc();s(_M,"cacheKeyFromSource");s(nS,"cleanInstallCache");s(sS,"sweepStaleCache");});function sa(t,e,r){let o=s(i=>i.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),n;if(t==="github"){let[i,a]=e.split("/",2);i&&a?n=`${o(i)}--${o(a)}--${o(r)}`:n=`${o(t)}__${o(e)}__${o(r)}`;}else n=`${o(t)}__${o(e)}__${o(r)}`;if(n.length>cS){let i=createHash("sha256").update(n).digest("hex").slice(0,16);n=`${n.slice(0,cS-18)}--${i}`;}return n}function Se(){let t=process.env.AGENTSMESH_CACHE;if(t){let e=t.trim();if(!e)return join(homedir(),".agentsmesh","cache");if(!/^([A-Za-z]:[\\/]|\/)/.test(e))throw new Error(`AGENTSMESH_CACHE must be an absolute path (got: "${e}").`);if(e==="/"||/^[A-Za-z]:[\\/]?$/.test(e))throw new Error(`AGENTSMESH_CACHE must not be the filesystem root (got: "${e}").`);return e}return join(homedir(),".agentsmesh","cache")}async function ia(t,e,r={}){let o=js(t);if(!o)throw t.startsWith("github:")?new Error(`Invalid github: source: "${t}" for extend "${e}"`):t.startsWith("gitlab:")?new Error(`Invalid gitlab: source: "${t}" for extend "${e}"`):t.startsWith("git+")?new Error(`Invalid git+ source: "${t}" for extend "${e}"`):new Error(`Invalid remote source: "${t}" for extend "${e}". Use github:org/repo@tag, gitlab:group/project@ref, or git+https://host/org/repo.git#ref.`);let n=r.cacheDir??Se();return sS(n).catch(()=>{}),o.kind==="github"?XI(o,e,r,n,sa,!t.includes("@")):Sm(o,e,r,n,sa)}var cS,vc=d(()=>{Ud();ZI();Fc();Bd();cS=80;s(sa,"buildCacheKey");s(Se,"getCacheDir");s(ia,"fetchRemoteExtend");});function EM(t){return t.startsWith("http://")||t.startsWith("https://")}async function aa(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(n=>Kd(n.source))){let n=Se();await rm$1(n,{recursive:true,force:true}),await mkdir(n,{recursive:true});}let o=[];for(let n of t.extends){if(EM(n.source))throw new Error(`Remote extends (http/https) not supported: "${n.source}" for extend "${n.name}". Use github:org/repo@tag, gitlab:group/project@ref, git+https://host/org/repo.git#ref, or a local path (e.g. ./shared/).`);if(Kd(n.source)){let a=await ia(n.source,n.name,{cacheDir:Se(),refresh:r.refreshCache===true});o.push({name:n.name,resolvedPath:a.resolvedPath,features:[...n.features],target:n.target,version:a.version,path:n.path,pick:n.pick});continue}let i=resolve(e,n.source);if(!await M(i))throw new Error(`Extend "${n.name}": path does not exist: ${i}. Check extends.source in agentsmesh.yaml.`);o.push({name:n.name,resolvedPath:i,features:[...n.features],target:n.target,path:n.path,pick:n.pick});}return o}var Rm=d(()=>{w();vc();Fc();s(EM,"isOtherRemoteSource");s(aa,"resolveExtendPaths");});function L(t){if(t.indexOf("---")!==0)return {frontmatter:{},body:t.trim()};let r=t.indexOf("---",3);if(r===-1)return {frontmatter:{},body:t.trim()};let o=t.slice(3,r).trim(),n=t.slice(r+3).trim();return {frontmatter:o===""?{}:parse(o)??{},body:n}}function x(t,e){return Object.keys(t).length===0?e:`---
|
|
12
12
|
${stringify(t,{lineWidth:0}).trimEnd()}
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
${e}`}var
|
|
16
|
-
`;)r++;continue}e+=
|
|
15
|
+
${e}`}var v=d(()=>{s(L,"parseFrontmatter");s(x,"serializeFrontmatter");});function wM(t){let e=t.replace(/\.[^.]*$/,"").toUpperCase();return LM.has(e)}function lS(t){let e=[],r=t.split(/[\\/]/);for(let o of r)if(!(o===""||o==="."||o==="..")){if(AM.test(o)){e.push({segment:o,reason:"illegal-character"});continue}if(/[. ]$/.test(o)){e.push({segment:o,reason:"trailing-dot-or-space"});continue}wM(o)&&e.push({segment:o,reason:"reserved-name"});}return e}var LM,AM,mS=d(()=>{LM=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"]),AM=new RegExp('[<>:"|?*\\u0000-\\u001F]');s(wM,"segmentReservedName");s(lS,"findWindowsPathIssues");});function zo(t,e){let r=lS(e);if(r.length===0)return;let o=r.map(n=>`${n.segment} (${n.reason})`).join(", ");throw new Cm(t,e,`canonical ${t} name "${e}" is not portable to Windows: ${o}. Rename the file.`)}function Em(t,e,r){let o=new Map;for(let n of e){let i=n.lastIndexOf("/"),a=n.lastIndexOf("\\"),c=Math.max(i,a),l=c===-1?n:n.slice(c+1),m=l.endsWith(r)?l.slice(0,-r.length):l,p=o.get(m);if(p!==void 0&&p!==n)throw new Cm(t,m,`canonical ${t} files collide on slug "${m}": ${p} vs ${n}. Rename one.`);o.set(m,n);}}var Cm,Mc=d(()=>{mS();Cm=class extends Error{static{s(this,"CanonicalNameError");}feature;name;constructor(e,r,o){super(o),this.feature=e,this.name=r;}};s(zo,"assertCanonicalName");s(Em,"assertNoBasenameCollisions");});function uS(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}async function Us(t){let r=(await F(t)).filter(n=>{if(!n.endsWith(".md"))return false;let i=basename(n,".md");return i==="_root"||!i.startsWith("_")}),o=[];for(let n of r){let i=await y(n);if(!i)continue;let{frontmatter:a,body:c}=L(i),l=basename(n,".md");zo("rule",l);let m=l==="_root",p=a.root===true,u=a.trigger,f=typeof u=="string"&&bM.includes(u)?u:void 0,g=a.codex_emit,h=g==="execution"?"execution":g==="advisory"?"advisory":void 0,R=a.codex_instruction==="override"?"override":void 0;o.push({source:n,root:m||p,targets:uS(a.targets),description:typeof a.description=="string"?a.description:"",globs:uS(a.globs),body:c,...f!==void 0&&{trigger:f},...h!==void 0&&{codexEmit:h},...R!==void 0&&{codexInstructionVariant:R}});}return o}var bM,Om=d(()=>{w();v();Mc();bM=["always_on","model_decision","glob","manual"];s(uS,"toStrArray");s(Us,"parseRules");});function fS(t){return t===true||t==="true"||t===1||t==="1"}function gS(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 Ws(t){let r=(await F(t)).filter(n=>n.endsWith(".md")&&!basename(n).startsWith("_"));Em("command",r,".md");let o=[];for(let n of r){let i=await y(n);if(!i)continue;let{frontmatter:a,body:c}=L(i),l=basename(n,".md");zo("command",l);let m=gS(a.allowedTools),p=gS(a["allowed-tools"]),u=m.length>0?m:p;o.push({source:n,name:l,description:typeof a.description=="string"?a.description:"",allowedTools:u,outputStyle:fS(a.outputStyle)||fS(a["output-style"]),body:c});}return o}var km=d(()=>{w();v();Mc();s(fS,"toBool");s(gS,"toToolsArray");s(Ws,"parseCommands");});function Ks(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 yS(t){return t===true||t==="true"||t===1||t==="1"}function _S(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 TM(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}async function Bs(t){let r=(await F(t)).filter(n=>n.endsWith(".md")&&!basename(n).startsWith("_"));Em("agent",r,".md");let o=[];for(let n of r){let i=await y(n);if(!i)continue;let{frontmatter:a,body:c}=L(i),l=basename(n,".md");zo("agent",l);let m=Ks(a.tools),p=Ks(a.tools),u=m.length>0?m:p,f=Ks(a.disallowedTools),g=Ks(a["disallowed-tools"]),h=f.length>0?f:g,C=Ks(a.mcpServers),R=Ks(a["mcp-servers"]),_=C.length>0?C:R,A=Ks(a.skills),D=_S(a.maxTurns),N=_S(a["max-turns"]),T=D>0?D:N>0?N:0;o.push({source:n,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:T,mcpServers:_,hooks:TM(a.hooks),skills:A,memory:typeof a.memory=="string"?a.memory:"",outputStyle:yS(a.outputStyle)||yS(a["output-style"]),body:c});}return o}var Lm=d(()=>{w();v();Mc();s(Ks,"toStrArray");s(yS,"toBool");s(_S,"toInt");s(TM,"toHooks");s(Bs,"parseAgents");});async function NM(t){return await y(t)??""}function FM(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}async function IS(t){let e=await F(t),r=[];for(let o of e){let i=o.slice(t.length+1).replace(/\\/g,"/");if(i===Am||i.endsWith(`/${Am}`))continue;let a=i.split("/")[0];if(DM.some(l=>a===l)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let c=await NM(o);r.push({relativePath:i,absolutePath:o,content:c});}return r.sort((o,n)=>o.relativePath.localeCompare(n.relativePath))}async function SS(t){let e=join(t,Am),r=await y(e);if(!r)return null;let{frontmatter:o,body:n}=L(r),i=await IS(t),c=(typeof o.name=="string"?FM(o.name):"")||basename(t);return zo("skill",c),{source:e,name:c,description:typeof o.description=="string"?o.description:"",body:n,supportingFiles:i}}async function ca(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let o of e){if(!o.isDirectory()||o.name.startsWith("_"))continue;zo("skill",o.name);let n=join(t,o.name),i=join(n,Am),a=await y(i);if(!a)continue;let{frontmatter:c,body:l}=L(a),m=await IS(n);r.push({source:i,name:o.name,description:typeof c.description=="string"?c.description:"",body:l,supportingFiles:m});}return r.sort((o,n)=>o.name.localeCompare(n.name))}var Am,DM,wm=d(()=>{w();v();Mc();s(NM,"readContent");Am="SKILL.md",DM=[".git","node_modules"];s(FM,"sanitizeSkillName");s(IS,"listSupportingFiles");s(SS,"parseSkillDirectory");s(ca,"parseSkills");});function RS(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}function vM(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",o=RS(e.env),n=typeof e.description=="string"?e.description:void 0,i=typeof e.url=="string"?e.url:"";if(i)return {...n!==void 0&&{description:n},type:r,url:i,headers:RS(e.headers),env:o};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let c=Array.isArray(e.args)?e.args.filter(l=>typeof l=="string"):[];return {...n!==void 0&&{description:n},type:r,command:a,args:c,env:o}}function MM(t){let e="",r=0,o=t.length;for(;r<o;){let n=t[r];if(n==='"'){for(e+=n,r++;r<o;){let i=t[r];if(e+=i,i==="\\")r++,r<o&&(e+=t[r]);else if(i==='"')break;r++;}r++;continue}if(n==="/"&&t[r+1]==="*"){for(r+=2;r<o;){if(t[r]==="*"&&t[r+1]==="/"){r+=2;break}r++;}continue}if(n==="/"&&t[r+1]==="/"){for(r+=2;r<o&&t[r]!==`
|
|
16
|
+
`;)r++;continue}e+=n,r++;}return e}async function Ir(t){let e=await y(t);if(!e)return null;let r;try{r=JSON.parse(MM(e));}catch{return null}if(!r||typeof r!="object")return null;let o=r.mcpServers;if(o===void 0||typeof o!="object"||o===null)return null;let n={};for(let[i,a]of Object.entries(o)){let c=vM(a);c&&(n[i]=c);}return {mcpServers:n}}var Gc=d(()=>{w();s(RS,"parseStringMap");s(vM,"parseServer");s(MM,"stripJsonComments");s(Ir,"parseMcp");});function zd(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}async function bm(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let o=r,n=zd(o.allow),i=zd(o.deny),a=zd(o.ask);return {allow:n,deny:i,ask:a}}var Vd=d(()=>{w();s(zd,"ensureStringArray");s(bm,"parsePermissions");});function CS(t){return typeof t=="string"?t.trim():""}function vt(t){return CS(t.command)}function ne(t){return CS(t.prompt)}function Jd(t){let e=vt(t),r=ne(t);return t.type==="prompt"?r||e:e||r}function Vo(t){return vt(t).length>0}function Zr(t){return Jd(t).length>0}var Sr=d(()=>{s(CS,"trimString");s(vt,"getHookCommand");s(ne,"getHookPrompt");s(Jd,"getHookText");s(Vo,"hasHookCommand");s(Zr,"hasHookText");});function UM(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let o=Jd(e);if(!o)return null;let n=typeof e.type=="string"&&jM.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=ne(e)||void 0;return {matcher:r,command:o,...i!==void 0&&{timeout:i},...n&&{type:n},...a&&{prompt:a}}}async function Tm(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let o={},n=r;for(let[i,a]of Object.entries(n)){if(!Array.isArray(a))continue;let c=[];for(let l of a){let m=UM(l);m&&c.push(m);}c.length>0&&(o[i]=c);}return o}var jM,Yd=d(()=>{w();Sr();jM=["command","prompt"];s(UM,"toHookEntry");s(Tm,"parseHooks");});async function xm(t){let e=await y(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),o=[];for(let n of r){let i=n.trim();i===""||i.startsWith("#")||o.push(i);}return o}var Xd=d(()=>{w();s(xm,"parseIgnore");});async function Re(t){let e=join(t,".agentsmesh"),r=await M(e)?e:t,[o,n,i,a,c,l,m,p]=await Promise.all([Us(join(r,"rules")),Ws(join(r,"commands")),Bs(join(r,"agents")),ca(join(r,"skills")),Ir(join(r,"mcp.json")),bm(join(r,"permissions.yaml")),Tm(join(r,"hooks.yaml")),xm(join(r,"ignore"))]);return {rules:o,commands:n,agents:i,skills:a,mcp:c,permissions:l,hooks:m,ignore:p}}var Hs=d(()=>{Om();km();Lm();wm();Gc();Vd();Yd();Xd();w();s(Re,"loadCanonicalFiles");});function ES(t){return basename(t.source,".md")}function la(t,e){let r=new Map(t.rules.map(p=>[ES(p),p]));for(let p of e.rules)r.set(ES(p),p);let o=new Map(t.commands.map(p=>[p.name,p]));for(let p of e.commands)o.set(p.name,p);let n=new Map(t.agents.map(p=>[p.name,p]));for(let p of e.agents)n.set(p.name,p);let i=new Map(t.skills.map(p=>[p.name,p]));for(let p of e.skills)i.set(p.name,p);let a=KM(t.mcp,e.mcp),c=BM(t.permissions,e.permissions),l=HM(t.hooks,e.hooks),m=zM(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(o.values()),agents:Array.from(n.values()),skills:Array.from(i.values()),mcp:a,permissions:c,hooks:l,ignore:m}}function KM(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},o=e?.mcpServers??{};return {mcpServers:{...r,...o}}}function BM(t,e){if(!t&&!e)return null;let r=Zd(t?.allow??[],e?.allow??[]),o=Zd(t?.deny??[],e?.deny??[]),n=Zd(t?.ask??[],e?.ask??[]);return {allow:r,deny:o,ask:n}}function Zd(t,e){let r=new Set(t),o=[...t];for(let n of e)r.has(n)||(r.add(n),o.push(n));return o}function HM(t,e){if(!t&&!e)return null;let r={},o=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let n of o){let i=e?.[n],a=t?.[n];r[n]=i!==void 0&&i.length>0?i:a??[];}return r}function zM(t,e){let r=new Set(t),o=[...t];for(let n of e)r.has(n)||(r.add(n),o.push(n));return o}var Qd=d(()=>{s(ES,"ruleSlug");s(la,"mergeCanonicalFiles");s(KM,"mergeMcp");s(BM,"mergePermissions");s(Zd,"mergeUniqueStrings");s(HM,"mergeHooks");s(zM,"mergeIgnore");});async function Pm(t){let e=null,r=0;for(let o of OS){let n=0;for(let i of o.paths)await M(join(t,i))&&n++;n>r&&(r=n,e=o.target);}return r>0?e:null}var OS,kS,qd=d(()=>{w();OS=[{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(Pm,"detectNativeFormat");kS=OS.map(t=>t.paths[0]).filter(t=>t!==void 0);});function X(t){return t.includes("\\")||Rr.test(t)?win32:posix}function Ot(t){return t.replace(/\\/g,"/")}function K(t,e){let r=X(t),o=r.normalize(r===win32?e.replace(/\//g,"\\"):Ot(e));return o.endsWith(r.sep)&&o.length>1?o.slice(0,-1):o}function AS(t,e){return X(t).isAbsolute(e)||Rr.test(e)}function ma(t){let e=t,r="";for(;YM.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function wS(t,e){let r=X(e),o=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return o&&o!==t?K(e,r.join(e,o)):null}var Rr,YM,Zt=d(()=>{Rr=/^[A-Za-z]:[\\/]/,YM=/[.!?:;]+$/;s(X,"pathApi");s(Ot,"normalizeSeparators");s(K,"normalizeForProject");s(AS,"isAbsoluteForProject");s(ma,"stripTrailingPunctuation");s(wS,"rootFallbackPath");});function XM(t){return Object.prototype.hasOwnProperty.call(bS,t)}function ZM(t){return Object.prototype.hasOwnProperty.call(TS,t)}function xS(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function pa(t,e,r,o="project"){let n=t.conversions?.commands_to_skills?.[e],i=xS(n,o);return i!==void 0?i:XM(e)?bS[e]:r??false}function Ue(t,e,r,o="project"){let n=t.conversions?.agents_to_skills?.[e],i=xS(n,o);return i!==void 0?i:ZM(e)?TS[e]:r??false}var bS,TS,ua=d(()=>{bS={amp:true,"codex-cli":true,goose:true,kiro:true,warp:true},TS={amp:true,"gemini-cli":false,cline:true,"codex-cli":false,windsurf:true,goose:true,antigravity:true,continue:true,warp:true};s(XM,"usesCommandSkillProjection");s(ZM,"usesAgentSkillProjection");s(xS,"resolveConversionValue");s(pa,"shouldConvertCommandsToSkills");s(Ue,"shouldConvertAgentsToSkills");});function Er(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Cr(t){return typeof t=="string"?{level:t}:t}function PS(t){return {rules:Cr(t.rules),additionalRules:Cr(t.additionalRules),commands:Cr(t.commands),agents:Cr(t.agents),skills:Cr(t.skills),mcp:Cr(t.mcp),hooks:Cr(t.hooks),ignore:Cr(t.ignore),permissions:Cr(t.permissions)}}var zs=d(()=>{s(Er,"cap");s(Cr,"normalizeCapabilityValue");s(PS,"normalizeTargetCapabilities");});function NS(t){for(let e of Bt)if(e.sharedArtifacts){for(let[r,o]of Object.entries(e.sharedArtifacts))if(o==="owner"&&t.startsWith(r))return e.id}return null}function QM(t){let e=[];for(let o of t)if(o.sharedArtifacts)for(let[n,i]of Object.entries(o.sharedArtifacts))i==="owner"&&e.push({targetId:o.id,prefix:n});let r=[];for(let o=0;o<e.length;o++)for(let n=o+1;n<e.length;n++){let i=e[o],a=e[n];i===void 0||a===void 0||(i.prefix===a.prefix||i.prefix.startsWith(a.prefix)||a.prefix.startsWith(i.prefix))&&r.push({a:i,b:a});}return r}function DS(t){let e=QM(t);if(e.length===0)return;let r=e.map(({a:o,b:n})=>` - "${o.targetId}" owns "${o.prefix}" and "${n.targetId}" owns "${n.prefix}"`);throw new Error(`Shared-artifact ownership conflict: two targets claim the same or overlapping prefix.
|
|
17
17
|
`+r.join(`
|
|
18
18
|
`)+`
|
|
19
|
-
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var
|
|
19
|
+
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var tf=d(()=>{kt();s(NS,"ownerTargetIdForSharedPath");s(QM,"findSharedArtifactOwnershipConflicts");s(DS,"assertSharedArtifactOwnersUnique");});function qM(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 Z(t){return `${da}${t}`}function de(t){let e={name:Z(t.name),description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],x(e,t.body.trim()||"")}function Nm(t,e){if(t["x-agentsmesh-kind"]!=="command")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",o=e.startsWith(da)?e.slice(da.length):e.startsWith($c)?e.slice($c.length):"",n=(r||o).trim();return n?{name:n,description:typeof t.description=="string"?t.description:"",allowedTools:qM(t["x-agentsmesh-allowed-tools"])}:null}function Dm(t,e){return x({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var da,$c,Ut=d(()=>{v();da="am-command-",$c="ab-command-";s(qM,"toStringArray");s(Z,"commandSkillDirName");s(de,"serializeCommandSkill");s(Nm,"parseCommandSkillFrontmatter");s(Dm,"serializeImportedCommand");});function Fm(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 tG(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t))Array.isArray(o)&&(e[r]=o.filter(n=>n!==null&&typeof n=="object"&&typeof n.matcher=="string"&&typeof n.command=="string"));return e}function B(t){return `${fa}${t}`}function Wt(t){let e={name:B(t.name),description:t.description||void 0,"x-agentsmesh-kind":"agent","x-agentsmesh-name":t.name,"x-agentsmesh-tools":t.tools.length>0?t.tools:void 0,"x-agentsmesh-disallowed-tools":t.disallowedTools.length>0?t.disallowedTools:void 0,"x-agentsmesh-model":t.model||void 0,"x-agentsmesh-permission-mode":t.permissionMode||void 0,"x-agentsmesh-max-turns":t.maxTurns>0?t.maxTurns:void 0,"x-agentsmesh-mcp-servers":t.mcpServers.length>0?t.mcpServers:void 0,"x-agentsmesh-hooks":Object.keys(t.hooks).length>0?t.hooks:void 0,"x-agentsmesh-skills":t.skills.length>0?t.skills:void 0,"x-agentsmesh-memory":t.memory||void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),x(e,t.body.trim()||"")}function Qr(t,e){if(t["x-agentsmesh-kind"]!=="agent")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",o=e.startsWith(fa)?e.slice(fa.length):e.startsWith(jc)?e.slice(jc.length):"",n=(r||o).trim();return n?{name:n,description:typeof t.description=="string"?t.description:"",tools:Fm(t["x-agentsmesh-tools"]),disallowedTools:Fm(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:Fm(t["x-agentsmesh-mcp-servers"]),hooks:tG(t["x-agentsmesh-hooks"]),skills:Fm(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function We(t,e){let r={name:t.name,description:t.description,tools:t.tools,disallowedTools:t.disallowedTools.length>0?t.disallowedTools:void 0,model:t.model||void 0,permissionMode:t.permissionMode||void 0,maxTurns:t.maxTurns>0?t.maxTurns:void 0,mcpServers:t.mcpServers.length>0?t.mcpServers:void 0,hooks:Object.keys(t.hooks).length>0?t.hooks:void 0,skills:t.skills.length>0?t.skills:void 0,memory:t.memory||void 0};return Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];}),x(r,e.trim()||"")}var fa,jc,ft=d(()=>{v();fa="am-agent-",jc="ab-agent-";s(Fm,"toStringArray");s(tG,"toHooks");s(B,"projectedAgentSkillDirName");s(Wt,"serializeProjectedAgentSkill");s(Qr,"parseProjectedAgentSkillFrontmatter");s(We,"serializeImportedAgent");});function Uc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ef(t,e){return new RegExp(`${Uc(t)}[\\s\\S]*?${Uc(e)}`,"g")}function $S(t,e,r,o){let n=ef(e,r);if(n.test(t))return t.replace(n,o).trim();let i=t.trim();return i?`${i}
|
|
20
20
|
|
|
21
|
-
${
|
|
22
|
-
`)}function
|
|
23
|
-
`)}function
|
|
21
|
+
${o}`:o}function rf(t,e,r){return t.replace(ef(e,r),"").trim()}function oG(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 nG(t){return {source:oG(t.source),description:t.description,globs:t.globs,targets:t.targets}}function sG(t){return `${MS}${JSON.stringify(nG(t))}${GS}`}function iG(t){let e=[sG(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),vS),e.filter(r=>r.length>0).join(`
|
|
22
|
+
`)}function aG(t){return t.length===0?"":[vm,...t.map(iG),Mm].join(`
|
|
23
|
+
`)}function Lt(t,e){let r=aG(e),o=rf(t,vm,Mm);return r?o?`${o}
|
|
24
24
|
|
|
25
|
-
${r}`:r:
|
|
25
|
+
${r}`:r:o}function FS(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function cG(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:FS(r.globs),targets:FS(r.targets)}}catch{return null}}function lG(t,e){let r=t.trim();if(!e.trim())return r;let o=`## ${e.trim()}`;return r.startsWith(o)?r.slice(o.length).trim():r}function jS(t){let e=[],r=ef(vm,Mm);return {rootContent:t.replace(r,n=>{let i=n.replace(vm,"").replace(Mm,"").trim(),a=new RegExp(`${Uc(MS)}([\\s\\S]*?)${Uc(GS)}([\\s\\S]*?)${Uc(vS)}`,"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=cG(l);p&&e.push({...p,body:lG(m,p.description)});}return ""}).trim(),rules:e}}var Wc,Kc,vm,Mm,vS,MS,GS,fe=d(()=>{Wc="<!-- agentsmesh:root-generation-contract:start -->",Kc="<!-- agentsmesh:root-generation-contract:end -->",vm="<!-- agentsmesh:embedded-rules:start -->",Mm="<!-- agentsmesh:embedded-rules:end -->",vS="<!-- agentsmesh:embedded-rule:end -->",MS="<!-- agentsmesh:embedded-rule:start ",GS=" -->";s(Uc,"escapeRegExp");s(ef,"managedBlockPattern");s($S,"replaceManagedBlock");s(rf,"stripManagedBlock");s(oG,"ruleSource");s(nG,"markerForRule");s(sG,"embeddedRuleStart");s(iG,"renderRule");s(aG,"renderEmbeddedRulesBlock");s(Lt,"appendEmbeddedRulesBlock");s(FS,"toStringArray");s(cG,"parseMarker");s(lG,"stripGeneratedHeading");s(jS,"extractEmbeddedRules");});function of(t){return t.replace(/\s+/g," ").trim()}function WS(t){let e=t.trim();if(e.includes(Wc)&&e.includes(Kc))return $S(e,Wc,Kc,ga);let r=of(e);if(r.includes(of(ga)))return e;for(let o of US)if(r.includes(of(o)))return e.replace(o,ga);return e?`${e}
|
|
26
26
|
|
|
27
|
-
${
|
|
27
|
+
${ga}`:ga}function KS(t){let e=rf(t,Wc,Kc);e=e.replace(`
|
|
28
28
|
|
|
29
|
-
${
|
|
29
|
+
${ga}`,"");for(let r of US)e=e.replace(`
|
|
30
30
|
|
|
31
|
-
${r}`,"");return e.trim()}var
|
|
31
|
+
${r}`,"");return e.trim()}var nf,mG,pG,uG,dG,fG,gG,hG,yG,_G,IG,SG,RG,CG,EG,OG,kG,ga,US,sf=d(()=>{fe();nf="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.",mG="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.",pG="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.",uG="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.",dG="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`.",fG="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`.",gG="`.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`.",hG="`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.",yG=nf,_G=`## Project-Specific Rules
|
|
32
32
|
|
|
33
|
-
${
|
|
33
|
+
${nf}`,IG=`## AgentsMesh Generation Contract
|
|
34
34
|
|
|
35
|
-
${
|
|
35
|
+
${nf}`,SG=`## AgentsMesh Generation Contract
|
|
36
36
|
|
|
37
|
-
${
|
|
37
|
+
${mG}`,RG=`## AgentsMesh Generation Contract
|
|
38
38
|
|
|
39
|
-
${
|
|
39
|
+
${pG}`,CG=`## AgentsMesh Generation Contract
|
|
40
40
|
|
|
41
|
-
${
|
|
41
|
+
${uG}`,EG=`## AgentsMesh Generation Contract
|
|
42
42
|
|
|
43
|
-
${
|
|
43
|
+
${dG}`,OG=`## AgentsMesh Generation Contract
|
|
44
44
|
|
|
45
|
-
${
|
|
45
|
+
${fG}`,kG=`## AgentsMesh Generation Contract
|
|
46
46
|
|
|
47
|
-
${
|
|
47
|
+
${gG}`,ga=`${Wc}
|
|
48
48
|
## AgentsMesh Generation Contract
|
|
49
49
|
|
|
50
|
-
${
|
|
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}
|
|
50
|
+
${hG}
|
|
51
|
+
${Kc}`;s(of,"normalizeWhitespace");US=[kG,OG,EG,CG,RG,SG,IG,_G,yG];s(WS,"appendAgentsmeshRootInstructionParagraph");s(KS,"stripAgentsmeshRootInstructionParagraph");});function se(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function ha(t){let e=await y(t);return e?L(e).frontmatter:{}}function Ht(t,e){return typeof t[e]=="string"?t[e]:void 0}function af(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function LG(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function AG(t,e){let r=basename(t,".md")==="_root",o={...e};return delete o.root,{root:r,...o}}async function G(t,e,r){let o=await ha(t),n=basename(t,".md")==="_root"?KS(r):r.trim(),i=AG(t,LG({...o,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=se(i.globs));for(let[c,l]of Object.entries(i))c==="root"||c==="description"||c==="globs"||l===void 0||(a[c]=l);return x(a,n||"")}var cf=d(()=>{w();v();sf();s(se,"toStringArray");s(ha,"readExistingFrontmatter");s(Ht,"readString");s(af,"readHooks");s(LG,"pruneUndefined");s(AG,"serializeCanonicalRuleFrontmatter");s(G,"serializeImportedRuleWithFallback");});async function mt(t,e,r){let o=await ha(t),n=(()=>{let c=se(o.allowedTools);return c.length>0?c:se(o["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof o.description=="string"?o.description:"",a=e.hasAllowedTools?e.allowedTools??[]:n;return x({description:i,"allowed-tools":a},r.trim()||"")}async function qr(t,e,r){let o=await ha(t),n=basename(dirname(t)),i=Ht(e,"name")??Ht(o,"name")??n,a=Ht(e,"description")??Ht(o,"description")??"";return x({name:i,description:a},r.trim()||"")}async function Mt(t,e,r){let o=await ha(t),n=Object.prototype.hasOwnProperty.call(e,"tools")?se(e.tools):(()=>{let C=se(o.tools);return C.length>0?C:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?se(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?se(e["disallowed-tools"]):se(o.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?se(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?se(e["mcp-servers"]):se(o.mcpServers),c=Object.prototype.hasOwnProperty.call(e,"skills")?se(e.skills):se(o.skills),l=e.maxTurns??e["max-turns"]??o.maxTurns,m=typeof l=="number"?l:Number(l??0),p=af(e)??af(o),u={name:Ht(e,"name")??Ht(o,"name")??basename(t,".md"),description:Ht(e,"description")??Ht(o,"description")??"",tools:n};i.length>0&&(u.disallowedTools=i);let f=Ht(e,"model")??Ht(o,"model");f&&(u.model=f);let g=Ht(e,"permissionMode")??Ht(e,"permission-mode")??Ht(o,"permissionMode")??Ht(o,"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=Ht(e,"memory")??Ht(o,"memory");return h&&(u.memory=h),x(u,r.trim()||"")}var zS=d(()=>{v();cf();s(mt,"serializeImportedCommandWithFallback");s(qr,"serializeImportedSkillWithFallback");s(Mt,"serializeImportedAgentWithFallback");});var ot=d(()=>{cf();zS();});function Gm(t){let e=t.split("/").filter(Boolean);return e.length===0||e.some(o=>o.startsWith("."))?false:!e.join("/").startsWith("tests/e2e/fixtures/")}async function Ke(t){await rm$1(t,{recursive:true,force:true});}var ya=d(()=>{s(Gm,"shouldImportScopedAgentsRule");s(Ke,"removePathIfExists");});function dt(t,e){let r=[];for(let o of t.skills){let n={name:o.name,description:o.description||void 0};n.description===void 0&&delete n.description,r.push({path:`${e}/${o.name}/SKILL.md`,content:x(n,o.body.trim()||"")});for(let i of o.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");r.push({path:`${e}/${o.name}/${a}`,content:i.content});}}return r}async function st(t,e,r,o,n){let i=await readdir(join(t,e),{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(i!==null)for(let a of i){if(!a.isDirectory())continue;let c=join(t,e,a.name),l=join(c,"SKILL.md"),m=await y(l);if(m===null)continue;let p=join(t,Bc,a.name),u=join(p,"SKILL.md"),{frontmatter:f,body:g}=L(n(m,l,u)),h=Nm(f,a.name);if(h){await Ke(join(t,Bc,a.name));let A=join(t,VS);await k(A);let D=join(A,`${h.name}.md`);await I(D,Dm(h,n(g,l,D))),o.push({fromTool:r,fromPath:l,toPath:`${VS}/${h.name}.md`,feature:"commands"});continue}let C=Qr(f,a.name);if(C){await Ke(join(t,Bc,a.name));let A=join(t,JS);await k(A);let D=join(A,`${C.name}.md`);await I(D,We(C,n(g,l,D))),o.push({fromTool:r,fromPath:l,toPath:`${JS}/${C.name}.md`,feature:"agents"});continue}let R=await qr(u,{...f,name:a.name},g);await k(p),await I(u,R),o.push({fromTool:r,fromPath:l,toPath:`${Bc}/${a.name}/SKILL.md`,feature:"skills"});let _=await F(c);for(let A of _){if(A===l)continue;let D=relative(c,A).replace(/\\/g,"/"),N=await y(A);if(N===null)continue;let T=join(p,D);await k(dirname(T)),await I(T,n(N,A,T)),o.push({fromTool:r,fromPath:A,toPath:`${Bc}/${a.name}/${D}`,feature:"skills"});}}}var Bc,VS,JS,ct=d(()=>{w();v();ot();ft();Ut();ya();Bc=".agentsmesh/skills",VS=".agentsmesh/commands",JS=".agentsmesh/agents";s(dt,"generateEmbeddedSkills");s(st,"importEmbeddedSkills");});var to,He,Qt,Yo,Xo,ze,Vs,YS,XS,_a=d(()=>{to="aider",He="CONVENTIONS.md",Qt=".aider/skills",Yo=".aiderignore",Xo="CONVENTIONS.md",ze=".aider/skills",Vs=".aiderignore",YS=".agentsmesh/rules",XS=".agentsmesh/ignore";});function ZS(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(to)),o=e?.body.trim()??"",n=Lt(o,r);return n?[{path:He,content:n}]:[]}function QS(t){return dt(t,Qt)}function qS(t){return t.commands.map(e=>({path:`${Qt}/${Z(e.name)}/SKILL.md`,content:de(e)}))}function tR(t){return t.agents.map(e=>({path:`${Qt}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function eR(t){return t.ignore.length===0?[]:[{path:Yo,content:t.ignore.join(`
|
|
52
|
+
`)}]}var rR=d(()=>{ct();fe();ft();Ut();_a();s(ZS,"generateRules");s(QS,"generateSkills");s(qS,"generateCommands");s(tR,"generateAgents");s(eR,"generateIgnore");});async function Kt(t,e,r){let o=join(t,e),i={...await FG(o),...r};await k(dirname(o)),await I(o,JSON.stringify({mcpServers:i},null,2));}async function FG(t){let e=await y(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let o=r.mcpServers;if(!o||typeof o!="object"||Array.isArray(o))return {};let n={};for(let[i,a]of Object.entries(o))!a||typeof a!="object"||Array.isArray(a)||(n[i]=a);return n}var eo=d(()=>{w();s(Kt,"writeMcpWithMerge");s(FG,"readExistingServers");});function Zo(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function Ve(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 Bn(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function ro(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var Je=d(()=>{s(Zo,"toGlobsArray");s(Ve,"toToolsArray");s(Bn,"toStringArray");s(ro,"toStringRecord");});function GG(t,e){return e.some(r=>t.endsWith(r))}async function pt(t){let r=(await F(t.srcDir)).filter(n=>GG(n,t.extensions)),o=[];for(let n of r){let i=await y(n);if(!i)continue;let a=relative(t.srcDir,n).replace(/\\/g,"/"),c=await t.mapEntry({srcPath:n,relativePath:a,content:i,normalizeTo:s((l,m=i)=>t.normalize(m,n,l),"normalizeTo")});c&&(await k(dirname(c.destPath)),await I(c.destPath,c.content),o.push({fromTool:t.fromTool,fromPath:n,toPath:c.toPath,feature:c.feature}));}return o}var Ce=d(()=>{w();s(GG,"matchesExtension");s(pt,"importFileDirectory");});function oR(t){return typeof t=="string"?t:void 0}function $G(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function mf(t,e){return e?e(t):t}function jG(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=L(e.normalizeTo(r)),i=mf(o,t.frontmatterRemap),a=$G({root:false,description:oR(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await G(r,a,n)}}}function UG(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=L(e.normalizeTo(r)),i=mf(o,t.frontmatterRemap),a=await mt(r,{hasDescription:true,description:oR(i.description),hasAllowedTools:true,allowedTools:Bn(i["allowed-tools"])},n);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function WG(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:o,body:n}=L(e.normalizeTo(r)),i=mf(o,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Mt(r,i,n)}}}function nR(t){if(t.map)return t.map;switch(t.preset){case "rule":return jG(t);case "command":return UG(t);case "agent":return WG(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var sR=d(()=>{v();ot();Je();s(oR,"pickString");s($G,"pruneUndefined");s(mf,"applyRemap");s(jG,"ruleMapper");s(UG,"commandMapper");s(WG,"agentMapper");s(nR,"resolveMapper");});function pf(t,e){return t?t[e]??[]:[]}var iR,aR=d(()=>{iR=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(pf,"resolveScopedSources");});async function HG(t,e,r,o,n){if(!t.canonicalRootFilename)throw new Error(`singleFile spec for ${t.feature} must set canonicalRootFilename`);let i=join(r,t.canonicalDir);for(let a of e){let c=join(r,a),l=await y(c);if(l===null)continue;await k(i);let m=join(i,t.canonicalRootFilename),p=s(R=>n(l,c,R),"normalizeTo");if(t.map){let R=await t.map({absolutePath:c,relativePath:a,content:l,destDir:i,normalizeTo:p});if(!R)continue;return await I(R.destPath,R.content),[{fromTool:o,fromPath:c,toPath:R.toPath,feature:t.feature}]}let{frontmatter:u,body:f}=L(p(m)),g=t.frontmatterRemap?t.frontmatterRemap(u):u,h=t.markAsRoot?{...g,root:true}:g,C=await G(m,h,f);return await I(m,C),[{fromTool:o,fromPath:c,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function zG(t,e,r,o,n){let i=nR(t),a=join(r,t.canonicalDir),c=[];for(let l of e){let m=join(r,l),p=await pt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:o,normalize:n,mapEntry:s(async({srcPath:u,relativePath:f,content:g,normalizeTo:h})=>{let C=await i({absolutePath:u,relativePath:f,content:g,destDir:a,normalizeTo:s(R=>h(R),"normalizeTo")});return C?{destPath:C.destPath,toPath:C.toPath,feature:t.feature,content:C.content}:null},"mapEntry")});c.push(...p);}return c}function lR(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function VG(t,e,r,o){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let n=lR(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=join(r,n);return await k(dirname(l)),await I(l,c.trimEnd()),[{fromTool:o,fromPath:a,toPath:n,feature:t.feature}]}return []}function JG(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object")return {};let r=e.mcpServers;if(!r||typeof r!="object"||Array.isArray(r))return {};let o={};for(let[n,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){o[n]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:Bn(a.args),env:ro(a.env),description:c};continue}typeof a.url=="string"&&(o[n]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:ro(a.headers),env:ro(a.env),description:c});}return o}async function YG(t,e,r,o){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let n=lR(t);for(let i of e){let a=join(r,i),c=await y(a);if(c===null)continue;let l=JG(c);return Object.keys(l).length===0?[]:(await Kt(r,n,l),[{fromTool:o,fromPath:a,toPath:n,feature:t.feature}])}return []}function cR(t,e,r,o,n){switch(t.mode){case "singleFile":return HG(t,e,r,o,n);case "directory":return zG(t,e,r,o,n);case "flatFile":return VG(t,e,r,o);case "mcpJson":return YG(t,e,r,o)}}async function XG(t,e,r,o,n){let i=pf(t.source,e),a=pf(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let c=await cR(t,i,r,o,n);if(c.length>0)return c}return a.length>0?cR(t,a,r,o,n):[]}function ZG(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function J(t,e,r,o){let n=t.importer;if(!n)return [];let i=o?.normalize??await W(t.id,e,r),a=[];for(let c of iR)for(let l of ZG(n,c))a.push(...await XG(l,r,e,t.id,i));return a}var wt=d(()=>{gt();w();eo();v();Je();ot();Ce();sR();aR();s(HG,"runSingleFile");s(zG,"runDirectory");s(lR,"resolveCanonicalFilePath");s(VG,"runFlatFile");s(JG,"parseMcpJson");s(YG,"runMcpJson");s(cR,"dispatchSpec");s(XG,"runSpec");s(ZG,"specsForFeature");s(J,"runDescriptorImport");});async function mR(t,e={}){let r=e.scope??"project",o=[],n=await W(to,t,r);return o.push(...await J($m,t,r,{normalize:n})),await st(t,r==="global"?ze:Qt,to,o,n),o}var pR=d(()=>{gt();ct();wt();_a();uf();s(mR,"importFromAider");});function QG(t,e){return dR(e).some(o=>qG(t,o))}function uR(t,e){return t.filter(r=>QG(r,e))}function dR(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,o,n]=e;if(!o)return [t];let i=o.split(",").map(c=>c.trim()),a=[];for(let c of i)for(let l of dR(r+c+n))a.push(l);return a}function qG(t,e){return t$(e).test(t)}function t$(t){let e=[],r=0;for(;r<t.length;){if(t.startsWith("**",r)){let i=t.slice(r+2);if(i.length===0&&e.length===0)e.push(".*");else if(e.push(i.startsWith("/")?"(?:[^/]+/)*":"(?:/[^/]+)*?"),i.startsWith("/")){r+=3;continue}r+=2;continue}if(t[r]==="*"){e.push("[^/]*"),r+=1;continue}if(t[r]==="?"){e.push("[^/]"),r+=1;continue}if(t[r]==="{"){e.push("(?:"),r+=1;continue}if(t[r]==="}"){e.push(")"),r+=1;continue}if(t[r]===","){e.push("|"),r+=1;continue}".^$+?()[]{}|\\".includes(t[r])?e.push("\\"+t[r]):e.push(t[r]),r+=1;}let o="^"+e.join("")+"$";return new RegExp(o)}var fR=d(()=>{s(QG,"globMatch");s(uR,"globFilter");s(dR,"expandBraces");s(qG,"matchOne");s(t$,"globToRegex");});function V(t,e,r,o={}){let n=[],{rules:i}=t;if(i.length===0)return [];if(i.some(c=>c.root)||n.push({level:"error",file:relative(e,i[0].source),message:"Rules exist but no root rule (_root.md or root: true). Add a root rule."}),o.checkGlobMatches===false)return n;for(let c of i){if(c.globs.length===0)continue;let l=false;for(let m of c.globs)if(uR(r,m).length>0){l=true;break}l||n.push({level:"warning",file:relative(e,c.source),message:`globs "${c.globs.join(", ")}" match 0 files in project`});}return n}var At=d(()=>{fR();s(V,"validateRules");});function hR(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:to}))}var yR=d(()=>{At();_a();s(hR,"lintRules");});function U(t,e,r){return {level:"warning",file:t,target:e,message:r}}function e$(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 zn(t,e,r,o){let n=o?.unsupportedBy??e,i=e$(r);return U(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${n}; only ${i} are projected.`)}var bt=d(()=>{s(U,"createWarning");s(e$,"formatOxfordComma");s(zn,"createUnsupportedHookWarning");});function _R(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[U(".agentsmesh/hooks.yaml","aider","Aider has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function IR(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[U(".agentsmesh/permissions.yaml","aider","Aider has no permissions config; canonical permissions are not projected.")]}function SR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[U(".agentsmesh/mcp.json","aider","Aider has no MCP config file; canonical MCP servers are not projected.")]}var RR=d(()=>{bt();s(_R,"lintHooks");s(IR,"lintPermissions");s(SR,"lintMcp");});function E(t,e){return X(t).relative(t,e).replace(/\\/g,"/")}async function O(t,e){return F(X(t).join(t,e)).catch(()=>[])}function ER(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function a$(t,e,r,o){let n=posix.dirname(e),i=posix.dirname(r);for(;n!==o&&n!==".";)ER(t,n,i),n=posix.dirname(n),i=posix.dirname(i);}function P(t,e,r,o){t.set(e,`${r}/${basename(e,o)}.md`);}function j(t,e,r){if(!e.startsWith(`${r}/`))return;let o=e.slice(r.length+1);if(!o)return;if(!o.includes("/")){if(!o.endsWith(".md")||basename(o)==="SKILL.md")return;let u=basename(o,".md");t.set(e,`${CR}/${u}/SKILL.md`);return}let[n,...i]=o.split("/"),a=i.join("/");if(!n||!a)return;let c=n.startsWith(da)?da:n.startsWith($c)?$c:null;if(c&&a==="SKILL.md"){t.set(e,`${s$}/${n.slice(c.length)}.md`);return}let l=n.startsWith(fa)?fa:n.startsWith(jc)?jc:null;if(l&&a==="SKILL.md"){t.set(e,`${i$}/${n.slice(l.length)}.md`);return}let m=`${CR}/${n}`;a==="SKILL.md"&&ER(t,`${r}/${n}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&a$(t,e,p,`${r}/${n}`);}function c$(t){return t.split("/").filter(Boolean)[0]??""}async function l$(){if(df!==void 0)return df;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(kt(),OR)),e=new Set;for(let r of t)for(let o of [r.project.rootInstructionPath,r.project.skillDir,...r.project.managedOutputs?.dirs??[],...r.project.managedOutputs?.files??[],...r.detectionPaths,r.globalSupport?.layout.rootInstructionPath,r.globalSupport?.layout.skillDir,...r.globalSupport?.layout.managedOutputs?.dirs??[],...r.globalSupport?.layout.managedOutputs?.files??[],...r.globalSupport?.detectionPaths??[]])if(o!==void 0){let n=c$(o);n.startsWith(".")&&e.add(n);}return df=e,e}function gf(t){return t.split("/").some(e=>e.startsWith("."))}async function m$(t){let e=[],r=await l$(),o=X(t);async function n(i){let a=o.join(t,i),c=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let l of c){let m=i?`${i}/${l.name}`:l.name;if(l.isDirectory()){if(r.has(l.name)||gf(m))continue;await n(m);continue}if(l.isSymbolicLink()&&await stat(o.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(l.name)||gf(m))continue;await n(m);continue}(l.name==="AGENTS.md"||l.name==="AGENTS.override.md")&&e.push(o.join(t,m));}}return s(n,"walk"),await n(""),e}async function jm(t,e){let r=await m$(e);for(let o of r){let n=E(e,o),i=n.endsWith("/AGENTS.md")&&n!=="AGENTS.md"&&!n.endsWith("/AGENTS.override.md"),a=n.endsWith("/AGENTS.override.md")&&n!=="AGENTS.override.md";if(!i&&!a)continue;let c=posix.dirname(n);if(gf(c))continue;let l=c.replace(/\//g,"-");t.set(n,`${n$}/${l}.md`);}}var n$,s$,i$,CR,df,Ct=d(()=>{Zt();w();Ut();ft();n$=".agentsmesh/rules",s$=".agentsmesh/commands",i$=".agentsmesh/agents",CR=".agentsmesh/skills";s(E,"rel");s(O,"listFiles");s(ER,"addDirectoryMapping");s(a$,"addAncestorMappings");s(P,"addSimpleFileMapping");s(j,"addSkillLikeMapping");s(c$,"firstPathSegment");s(l$,"targetRootSegments");s(gf,"hasHiddenSegment");s(m$,"listScopedAgentsFiles");s(jm,"addScopedAgentsMappings");});var b,Q,_t,Et=d(()=>{b=".agentsmesh/rules",Q=".agentsmesh/commands",_t=".agentsmesh/agents";});async function hf(t,e,r="project"){if(r==="global"){t.set(Xo,`${b}/_root.md`);for(let o of await O(e,ze))j(t,E(e,o),ze);t.set(Vs,".agentsmesh/ignore");return}t.set(He,`${b}/_root.md`);for(let o of await O(e,Qt))j(t,E(e,o),Qt);t.set(Yo,".agentsmesh/ignore");}var kR=d(()=>{Ct();_a();Et();s(hf,"buildAiderImportPaths");});var Js,Or,Ys,Vn,zc,LR,AR,Vc=d(()=>{Js="amazon-q",Or=".amazonq/rules",Ys=".amazonq/mcp.json",Vn=".aws/amazonq/rules",zc=".aws/amazonq/mcp.json",LR=".agentsmesh/rules",AR=".agentsmesh/mcp.json";});async function yf(t,e,r="project"){let o=r==="global"?Vn:Or;for(let n of await O(e,o)){let i=E(e,n);P(t,i,b,".md");}}var wR=d(()=>{Ct();Vc();Et();s(yf,"buildAmazonQImportPaths");});var Ye,qt,oo,_f,Qo,Xe,qo,bR,Xs=d(()=>{Ye="AGENTS.md",qt=".agents/skills",oo=".amp/settings.json",_f=".config/amp",Qo=`${_f}/AGENTS.md`,Xe=`${_f}/skills`,qo=`${_f}/settings.json`,bR=".agentsmesh/rules";});async function If(t,e,r="project"){if(r==="global"){t.set(Qo,`${b}/_root.md`);for(let o of await O(e,Xe))j(t,E(e,o),Xe);t.set(qo,".agentsmesh/mcp.json");return}t.set(Ye,`${b}/_root.md`);for(let o of await O(e,qt))j(t,E(e,o),qt);t.set(oo,".agentsmesh/mcp.json");}var TR=d(()=>{Ct();Xs();Et();s(If,"buildAmpImportPaths");});var Zs,Um,no,kr,Jc,Lr,tn,Yc,so,en,Xc,Ia,Sf,Qs,Wm,xR,qs=d(()=>{Zs="antigravity",Um=".agents",no=`${Um}/rules`,kr=`${no}/general.md`,Jc=`${no}/_root.md`,Lr=`${Um}/skills`,tn=`${Um}/workflows`,Yc=`${Um}/antigravity/mcp_config.json`,so=".gemini/antigravity/GEMINI.md",en=".gemini/antigravity/skills",Xc=".gemini/antigravity/workflows",Ia=".gemini/antigravity/mcp_config.json",Sf=".agentsmesh/rules/_root.md",Qs=".agentsmesh/rules",Wm=".agentsmesh/commands",xR=".agentsmesh/mcp.json";});async function Rf(t,e,r="project"){if(r==="global"){t.set(so,`${b}/_root.md`);for(let o of await O(e,en))j(t,E(e,o),en);t.set(Ia,".agentsmesh/mcp.json");return}t.set(kr,`${b}/_root.md`),t.set(Jc,`${b}/_root.md`);for(let o of await O(e,no)){let n=E(e,o);n===kr||n===Jc||P(t,n,b,".md");}for(let o of await O(e,tn))P(t,E(e,o),Q,".md");for(let o of await O(e,Lr))j(t,E(e,o),Lr);}var PR=d(()=>{Ct();qs();Et();s(Rf,"buildAntigravityImportPaths");});var te,Km,Ee,Ze,Oe,io,ao,Bm,rn,on,co,nn,Cf,Ef,Of,kf,ti=d(()=>{te="augment-code",Km=".augment",Ee=`${Km}/rules`,Ze=`${Km}/commands`,Oe=`${Km}/skills`,io=`${Km}/settings.json`,ao=".augmentignore",Bm=".augment",rn=`${Bm}/rules`,on=`${Bm}/commands`,co=`${Bm}/skills`,nn=`${Bm}/settings.json`,Cf=".agentsmesh/rules",Ef=".agentsmesh/mcp.json",Of=".agentsmesh/hooks.yaml",kf=".agentsmesh/ignore";});async function Lf(t,e,r="project"){if(r==="global"){for(let o of await O(e,rn))P(t,E(e,o),b,".md");for(let o of await O(e,on))P(t,E(e,o),Q,".md");for(let o of await O(e,co))j(t,E(e,o),co);t.set(nn,".agentsmesh/mcp.json");return}for(let o of await O(e,Ee))P(t,E(e,o),b,".md");for(let o of await O(e,Ze))P(t,E(e,o),Q,".md");for(let o of await O(e,Oe))j(t,E(e,o),Oe);t.set(io,".agentsmesh/mcp.json"),t.set(ao,".agentsmesh/ignore");}var NR=d(()=>{Ct();ti();Et();s(Lf,"buildAugmentCodeImportPaths");});var DR,Jn,FR,Zc,Qc,qc,tl,el,sn,Af,rl,Sa,ol,nl,Hm,zm,wf,sl,bf,ei,vR,an=d(()=>{DR="claude-code",Jn=".claude/CLAUDE.md",FR="CLAUDE.md",Zc=".claude/rules",Qc=".claude/commands",qc=".claude/agents",tl=".claude/skills",el=".claude/settings.json",sn=".claude/hooks.json",Af=".claude/output-styles",rl=".claudeignore",Sa=".mcp.json",ol=".claude.json",nl=".agentsmesh/rules",Hm=".agentsmesh/commands",zm=".agentsmesh/agents",wf=".agentsmesh/skills",sl=".agentsmesh/mcp.json",bf=".agentsmesh/permissions.yaml",ei=".agentsmesh/hooks.yaml",vR=".agentsmesh/ignore";});async function Tf(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${b}/_root.md`),t.set(sn,ei),r==="project"&&t.set("CLAUDE.md",`${b}/_root.md`),r==="global")for(let o of await O(e,".agents/skills"))j(t,E(e,o),".agents/skills");for(let o of await O(e,".claude/rules"))P(t,E(e,o),b,".md");for(let o of await O(e,".claude/commands"))P(t,E(e,o),Q,".md");for(let o of await O(e,".claude/agents"))P(t,E(e,o),_t,".md");for(let o of await O(e,".claude/skills"))j(t,E(e,o),".claude/skills");}var MR=d(()=>{Ct();an();Et();s(Tf,"buildClaudeCodeImportPaths");});var Yn,cn,ri,ln,GR,zt,lo,Xn,oi,ni,si,ii,xf,Zn,Vm,Pf,Nf,Df,$R,Qe=d(()=>{Yn="cline",cn=".clinerules",ri=".clineignore",ln=".cline/cline_mcp_settings.json",GR=".cline/mcp_settings.json",zt=".cline/skills",lo=".clinerules/workflows",Xn="AGENTS.md",oi=".clinerules/hooks",ni="Documents/Cline/Rules",si="Documents/Cline/Workflows",ii="Documents/Cline/Hooks",xf=".agentsmesh/hooks.yaml",Zn=".agentsmesh/rules",Vm=".agentsmesh/commands",Pf=".agentsmesh/ignore",Nf=".agentsmesh/mcp.json",Df=".agentsmesh/agents",$R=".agentsmesh/skills";});async function Ff(t,e,r="project"){if(r==="global"){for(let o of await O(e,ni))P(t,E(e,o),b,".md");for(let o of await O(e,si))P(t,E(e,o),Q,".md");for(let o of await O(e,zt))j(t,E(e,o),zt);t.set(ln,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${b}/_root.md`);for(let o of await O(e,".clinerules")){let n=E(e,o);!n.endsWith(".md")||n.includes("/workflows/")||basename(n)==="_root.md"||P(t,n,b,".md");}for(let o of await O(e,".clinerules/workflows"))P(t,E(e,o),Q,".md");for(let o of await O(e,".cline/skills"))j(t,E(e,o),".cline/skills");}var jR=d(()=>{Ct();Qe();Et();s(Ff,"buildClineImportPaths");});async function vf(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${b}/_root.md`),t.set(".codex/AGENTS.override.md",`${b}/_root.md`)):(t.set("AGENTS.md",`${b}/_root.md`),t.set("codex.md",`${b}/_root.md`),await jm(t,e)),r==="project")for(let o of await O(e,".codex/instructions"))P(t,E(e,o),b,".md");for(let o of await O(e,".codex/rules")){let n=E(e,o);n.endsWith(".rules")?P(t,n,b,".rules"):n.endsWith(".md")&&P(t,n,b,".md");}for(let o of await O(e,".codex/agents"))P(t,E(e,o),_t,".toml");for(let o of await O(e,".agents/skills"))j(t,E(e,o),".agents/skills");}var UR=d(()=>{Ct();Et();s(vf,"buildCodexCliImportPaths");});var Ra,Ar,mo,Mf,Jm,mn,Gf,ke,Ca,il,Ym,Xm,$f,po=d(()=>{Ra="continue",Ar=".continue/rules",mo=".continue/prompts",Mf=".continue/mcpServers",Jm=`${Mf}/agentsmesh.json`,mn=`${Ar}/general.md`,Gf=`${Ar}/_root.md`,ke=".continue/skills",Ca=".continue/AGENTS.md",il=".continue/config.yaml",Ym=".agentsmesh/rules",Xm=".agentsmesh/commands",$f=".agentsmesh/mcp.json";});async function jf(t,e,r="project"){t.set(mn,`${b}/_root.md`),t.set(Gf,`${b}/_root.md`);for(let o of await O(e,".continue/rules")){let n=E(e,o);n===mn||n===Gf||P(t,n,b,".md");}for(let o of await O(e,".continue/prompts"))t.set(E(e,o),`${Q}/${basename(o,".md")}.md`);for(let o of await O(e,".continue/skills"))j(t,E(e,o),".continue/skills");if(r==="global")for(let o of await O(e,".agents/skills"))j(t,E(e,o),".agents/skills");}var WR=d(()=>{Ct();po();Et();s(jf,"buildContinueImportPaths");});function d$(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${b}/${basename(e,".instructions.md")}.md`);return}P(t,e,b,".md");}async function Uf(t,e){t.set(".github/copilot-instructions.md",`${b}/_root.md`);for(let r of await O(e,".github/copilot"))t.set(E(e,r),`${b}/${basename(r,".instructions.md")}.md`);for(let r of await O(e,".github/instructions"))d$(t,E(e,r));for(let r of await O(e,".github/prompts"))t.set(E(e,r),`${Q}/${basename(r,".prompt.md")}.md`);for(let r of await O(e,".github/agents"))t.set(E(e,r),`${_t}/${basename(r,".agent.md")}.md`);for(let r of await O(e,".github/skills"))j(t,E(e,r),".github/skills");}var KR=d(()=>{Ct();Et();s(d$,"addCopilotInstructionMapping");s(Uf,"buildCopilotImportPaths");});var qe,tr,Vt,Le,pn,BR,Qm,Ae,ai,qm,tp,ep,Ea=d(()=>{qe="crush",tr="CRUSH.md",Vt=".crush/skills",Le="crush.json",pn=".crushignore",BR=".config/crush",Qm=`${BR}/crush.json`,Ae=".config/crush/skills",ai=`${BR}/CRUSH.md`,qm=".agentsmesh/rules",tp=".agentsmesh/ignore",ep=".agentsmesh/mcp.json";});async function Wf(t,e,r="project"){if(r==="global"){for(let o of await O(e,Ae))j(t,E(e,o),Ae);return}t.set(tr,`${qm}/_root.md`),t.set(Le,ep),t.set(pn,tp);for(let o of await O(e,Vt))j(t,E(e,o),Vt);}var HR=d(()=>{Ct();Ea();s(Wf,"buildCrushImportPaths");});var zR,Qn,VR,er,un,rr,Oa,uo,fo,go,rp,wr,Kf,f$,ka,br,al,qn,ts,ho,es,rs,JR,La,Bf,cl,Hf,Nt=d(()=>{zR="cursor",Qn="AGENTS.md",VR=".cursorrules",er=".cursor/rules",un=`${er}/general.mdc`,rr=".cursor/commands",Oa=".cursor/agents",uo=".cursor/skills",fo=".cursor/mcp.json",go=".cursor/hooks.json",rp=".cursor/settings.json",wr=".cursorignore",Kf=".cursorindexingignore",f$=".agentsmesh-exports/cursor",ka=`${f$}/user-rules.md`,br=".cursor/AGENTS.md",al=fo,qn=uo,ts=Oa,ho=".agentsmesh/rules",es=".agentsmesh/commands",rs=".agentsmesh/agents",JR=".agentsmesh/skills",La=".agentsmesh/mcp.json",Bf=".agentsmesh/permissions.yaml",cl=".agentsmesh/hooks.yaml",Hf=".agentsmesh/ignore";});async function zf(t,e,r="project"){if(r==="global"){t.set(fo,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${b}/_root.md`);for(let o of await O(e,".cursor/rules"))P(t,E(e,o),b,".mdc");for(let o of await O(e,".cursor/commands"))P(t,E(e,o),Q,".md");for(let o of await O(e,".cursor/agents"))P(t,E(e,o),_t,".md");for(let o of await O(e,".cursor/skills"))j(t,E(e,o),".cursor/skills");return}t.set("AGENTS.md",`${b}/_root.md`);for(let o of await O(e,".cursor/rules"))P(t,E(e,o),b,".mdc");for(let o of await O(e,".cursor/commands"))P(t,E(e,o),Q,".md");for(let o of await O(e,".cursor/agents"))P(t,E(e,o),_t,".md");for(let o of await O(e,".cursor/skills"))j(t,E(e,o),".cursor/skills");}var YR=d(()=>{Ct();Nt();Et();s(zf,"buildCursorImportPaths");});async function Vf(t,e){for(let r of await O(e,".gemini/rules"))P(t,E(e,r),b,".md");for(let r of await O(e,".gemini/commands")){let o=E(e,r);if(!o.endsWith(".toml")&&!o.endsWith(".md"))continue;let n=o.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",l=(n.startsWith(i)?n.slice(i.length):n).split("/").filter(Boolean).join(":");t.set(o,`${Q}/${l}.md`);}for(let r of await O(e,".gemini/agents"))P(t,E(e,r),_t,".md");for(let r of await O(e,".gemini/skills"))j(t,E(e,r),".gemini/skills");}var XR=d(()=>{Ct();Et();s(Vf,"buildGeminiCliImportPaths");});var yo,or,ie,dn,ZR,fn,ci,nr,QR,qR,Aa=d(()=>{yo="goose",or=".goosehints",ie=".agents/skills",dn=".gooseignore",ZR=".config/goose",fn=`${ZR}/.goosehints`,ci=`${ZR}/.gooseignore`,nr=".agents/skills",QR=".agentsmesh/rules",qR=".agentsmesh/ignore";});async function Jf(t,e,r="project"){if(r==="global"){t.set(fn,`${b}/_root.md`);for(let o of await O(e,nr))j(t,E(e,o),nr);t.set(ci,".agentsmesh/ignore");return}t.set(or,`${b}/_root.md`);for(let o of await O(e,ie))j(t,E(e,o),ie);t.set(dn,".agentsmesh/ignore");}var tC=d(()=>{Ct();Aa();Et();s(Jf,"buildGooseImportPaths");});var li,os,op,eC,_o,rC,g$,ll,mi,ml,wa,ba,pl,ul,dl,fl,gl,h$,np,pi,oC,Yf,sp,nC,sC,iC,aC,Ta=d(()=>{li="junie",os=".junie",op=`${os}/guidelines.md`,eC=`${os}/ci-guidelines.md`,_o=`${os}/AGENTS.md`,rC="AGENTS.md",g$=`${os}/mcp`,ll=`${g$}/mcp.json`,mi=`${os}/skills`,ml=`${os}/rules`,wa=`${os}/commands`,ba=`${os}/agents`,pl=".aiignore",ul=".junie",dl=`${ul}/skills`,fl=`${ul}/agents`,gl=`${ul}/commands`,h$=`${ul}/mcp`,np=`${h$}/mcp.json`,pi=`${ul}/AGENTS.md`,oC=".agents/skills",Yf=".agentsmesh/rules/_root.md",sp=".agentsmesh/rules",nC=".agentsmesh/commands",sC=".agentsmesh/agents",iC=".agentsmesh/mcp.json",aC=".agentsmesh/ignore";});async function Xf(t,e){t.set(op,`${b}/_root.md`),t.set(_o,`${b}/_root.md`),t.set("AGENTS.md",`${b}/_root.md`);for(let r of await O(e,".junie/rules"))P(t,E(e,r),b,".md");for(let r of await O(e,".junie/commands"))P(t,E(e,r),Q,".md");for(let r of await O(e,".junie/agents"))P(t,E(e,r),_t,".md");for(let r of await O(e,".junie/skills"))j(t,E(e,r),".junie/skills");}var cC=d(()=>{Ct();Ta();Et();s(Xf,"buildJunieImportPaths");});var ae,hl,Io,gn,hn,yn,Tr,ns,xa,ip,ui,Pa,di,yl,ap,Na,ss,fi,gi,hi,is,Da,cp,lC,as,Fa,yi,mC,pC,_i=d(()=>{ae="kilo-code",hl=".kilo",Io="AGENTS.md",gn=`${hl}/rules`,hn=`${hl}/commands`,yn=`${hl}/agents`,Tr=`${hl}/skills`,ns=`${hl}/mcp.json`,xa=".kilocodeignore",ip=".kilocode",ui=`${ip}/rules`,Pa=`${ip}/workflows`,di=`${ip}/skills`,yl=`${ip}/mcp.json`,ap=".kilocodemodes",Na=".kilo",ss=`${Na}/AGENTS.md`,fi=`${Na}/rules`,gi=`${Na}/commands`,hi=`${Na}/agents`,is=`${Na}/skills`,Da=`${Na}/mcp.json`,cp=".kilocodeignore",lC=".agents/skills",as=".agentsmesh/rules",Fa=".agentsmesh/commands",yi=".agentsmesh/agents",mC=".agentsmesh/mcp.json",pC=".agentsmesh/ignore";});async function Zf(t,e,r="project"){if(r==="global"){t.set(ss,`${b}/_root.md`);for(let o of await O(e,fi))P(t,E(e,o),b,".md");for(let o of await O(e,gi))P(t,E(e,o),Q,".md");for(let o of await O(e,hi))P(t,E(e,o),_t,".md");for(let o of await O(e,is))j(t,E(e,o),is);t.set(Da,".agentsmesh/mcp.json");return}t.set(Io,`${b}/_root.md`);for(let o of await O(e,gn))P(t,E(e,o),b,".md");for(let o of await O(e,hn))P(t,E(e,o),Q,".md");for(let o of await O(e,yn))P(t,E(e,o),_t,".md");for(let o of await O(e,Tr))j(t,E(e,o),Tr);t.set(ns,".agentsmesh/mcp.json");for(let o of await O(e,ui)){let n=E(e,o);if(basename(n)==="00-root.md"){t.set(n,`${b}/_root.md`);continue}P(t,n,b,".md");}for(let o of await O(e,Pa))P(t,E(e,o),Q,".md");for(let o of await O(e,di))j(t,E(e,o),di);t.set(yl,".agentsmesh/mcp.json");}var uC=d(()=>{Ct();_i();Et();s(Zf,"buildKiloCodeImportPaths");});var we,xr,_l,Pr,ce,Nr,cs,dC,va,Ma,Ii,Dr,ls,Si,Il,Sl,fC,Qf,qf,gC,hC,tg,yC,Ga=d(()=>{we="kiro",xr="AGENTS.md",_l=".kiro",Pr=`${_l}/steering`,ce=`${_l}/skills`,Nr=`${_l}/agents`,cs=`${_l}/hooks`,dC=`${_l}/settings`,va=`${dC}/mcp.json`,Ma=".kiroignore",Ii=".kiro/steering",Dr=".kiro/steering/AGENTS.md",ls=".kiro/skills",Si=".kiro/agents",Il=".kiro/settings/mcp.json",Sl=".kiro/settings/kiroignore",fC=".agents/skills",Qf=".agentsmesh/rules/_root.md",qf=".agentsmesh/rules",gC=".agentsmesh/agents",hC=".agentsmesh/mcp.json",tg=".agentsmesh/hooks.yaml",yC=".agentsmesh/ignore";});async function eg(t,e,r="project"){if(r==="global"){t.set(Dr,`${b}/_root.md`);for(let o of await O(e,Ii)){let n=E(e,o);n!==Dr&&P(t,n,b,".md");}for(let o of await O(e,ls))j(t,E(e,o),ls);for(let o of await O(e,Si))P(t,E(e,o),_t,".md");return}t.set(xr,`${b}/_root.md`);for(let o of await O(e,Pr))P(t,E(e,o),b,".md");for(let o of await O(e,ce))j(t,E(e,o),ce);for(let o of await O(e,Nr))P(t,E(e,o),_t,".md");}var _C=d(()=>{Ct();Ga();Et();s(eg,"buildKiroImportPaths");});var Fr,lp,So,_n,In,Sn,vr,Ro,$a,ms,Ri,Ci,Ei,ps,us,IC,Rl,mp,pp,rg,Oi=d(()=>{Fr="opencode",lp=".opencode",So="AGENTS.md",_n=`${lp}/rules`,In=`${lp}/commands`,Sn=`${lp}/agents`,vr=`${lp}/skills`,Ro="opencode.json",$a=".config/opencode",ms=`${$a}/AGENTS.md`,Ri=`${$a}/rules`,Ci=`${$a}/commands`,Ei=`${$a}/agents`,ps=`${$a}/skills`,us=`${$a}/opencode.json`,IC=".agents/skills",Rl=".agentsmesh/rules",mp=".agentsmesh/commands",pp=".agentsmesh/agents",rg=".agentsmesh/mcp.json";});async function og(t,e,r="project"){if(r==="global"){t.set(ms,`${b}/_root.md`);for(let o of await O(e,Ri))P(t,E(e,o),b,".md");for(let o of await O(e,Ci))P(t,E(e,o),Q,".md");for(let o of await O(e,Ei))P(t,E(e,o),_t,".md");for(let o of await O(e,ps))j(t,E(e,o),ps);t.set(us,".agentsmesh/mcp.json");return}t.set(So,`${b}/_root.md`);for(let o of await O(e,_n))P(t,E(e,o),b,".md");for(let o of await O(e,In))P(t,E(e,o),Q,".md");for(let o of await O(e,Sn))P(t,E(e,o),_t,".md");for(let o of await O(e,vr))j(t,E(e,o),vr);t.set(Ro,".agentsmesh/mcp.json");}var SC=d(()=>{Ct();Oi();Et();s(og,"buildOpencodeImportPaths");});var Co,sr,Rn,Eo,Oo,be,ds,fs,Cn,ki,gs,ko,hs,ng,RC,CC,ja=d(()=>{Co="qwen-code",sr="QWEN.md",Rn=".qwen/rules",Eo=".qwen/commands",Oo=".qwen/agents",be=".qwen/skills",ds=".qwen/settings.json",fs=".qwenignore",Cn=".qwen/QWEN.md",ki=".qwen/settings.json",gs=".qwen/commands",ko=".qwen/skills",hs=".qwen/agents",ng=".agentsmesh/rules",RC=".agentsmesh/commands",CC=".agentsmesh/agents";});async function sg(t,e,r="project"){if(r==="global"){t.set(Cn,`${b}/_root.md`),t.set(ki,".agentsmesh/mcp.json");for(let o of await O(e,gs))P(t,E(e,o),Q,".md");for(let o of await O(e,hs))P(t,E(e,o),_t,".md");for(let o of await O(e,ko))j(t,E(e,o),ko);return}t.set(sr,`${b}/_root.md`),t.set(ds,".agentsmesh/mcp.json"),t.set(fs,".agentsmesh/ignore");for(let o of await O(e,Rn))P(t,E(e,o),b,".md");for(let o of await O(e,Eo))P(t,E(e,o),Q,".md");for(let o of await O(e,Oo))P(t,E(e,o),_t,".md");for(let o of await O(e,be))j(t,E(e,o),be);}var EC=d(()=>{Ct();Et();ja();s(sg,"buildQwenCodeImportPaths");});var ys,Li,Mr,Cl,En,On,Lo,El,Ol,Ua,kl,up,_s,Is,kn,Ai,Ll,Ss,OC,wi,dp,kC,LC,bi=d(()=>{ys="roo-code",Li=".roo",Mr=`${Li}/rules/00-root.md`,Cl=".roorules",En=`${Li}/rules`,On=`${Li}/commands`,Lo=`${Li}/skills`,El=`${Li}/mcp.json`,Ol=".rooignore",Ua=".roomodes",kl="settings/custom_modes.yaml",up=".roo",_s=`${up}/rules`,Is=`${up}/commands`,kn=`${up}/skills`,Ai="mcp_settings.json",Ll=".rooignore",Ss=`${up}/AGENTS.md`,OC=".agents/skills",wi=".agentsmesh/rules",dp=".agentsmesh/commands",kC=".agentsmesh/mcp.json",LC=".agentsmesh/ignore";});async function ig(t,e,r="project"){if(r==="global"){t.set(Ss,`${b}/_root.md`);for(let o of await O(e,_s))P(t,E(e,o),b,".md");for(let o of await O(e,Is))P(t,E(e,o),Q,".md");for(let o of await O(e,kn))j(t,E(e,o),kn);t.set(Ai,".agentsmesh/mcp.json");return}t.set(Mr,`${b}/_root.md`),t.set(Cl,`${b}/_root.md`);for(let o of await O(e,En)){let n=E(e,o);n!==Mr&&P(t,n,b,".md");}for(let o of await O(e,".roo")){let n=E(e,o);/^\.roo\/rules-[^/]+\/.+\.md$/.test(n)&&P(t,n,b,".md");}for(let o of await O(e,On))P(t,E(e,o),Q,".md");for(let o of await O(e,Lo))j(t,E(e,o),Lo);}var AC=d(()=>{Ct();bi();Et();s(ig,"buildRooCodeImportPaths");});var ir,fp,Te,xe,ar,Ti,Wa,Ln,cr,Gr,Al,wC,wl,bC,TC,Ka=d(()=>{ir="trae",fp=".trae",Te=`${fp}/rules`,xe=`${Te}/project_rules.md`,ar=`${fp}/skills`,Ti=`${fp}/mcp.json`,Wa=`${fp}/.ignore`,Ln=".trae/user_rules",cr=".trae/user_rules/rules.md",Gr=".trae/skills",Al=".trae/mcp.json",wC=".agents/skills",wl=".agentsmesh/rules",bC=".agentsmesh/mcp.json",TC=".agentsmesh/ignore";});async function ag(t,e,r="project"){if(r==="global"){t.set(cr,`${b}/_root.md`);for(let o of await O(e,Ln)){let n=E(e,o);n!==cr&&P(t,n,b,".md");}for(let o of await O(e,Gr))j(t,E(e,o),Gr);return}t.set(xe,`${b}/_root.md`);for(let o of await O(e,Te)){let n=E(e,o);n!==xe&&P(t,n,b,".md");}for(let o of await O(e,ar))j(t,E(e,o),ar);}var xC=d(()=>{Ct();Ka();Et();s(ag,"buildTraeImportPaths");});var Ao,$r,cg,ee,Rs,ge,PC,Ba=d(()=>{Ao="warp",$r="AGENTS.md",cg="WARP.md",ee=".warp/skills",Rs=".mcp.json",ge=".warp/skills",PC=".agentsmesh/rules";});async function lg(t,e,r="project"){if(r==="global"){for(let o of await O(e,ge))j(t,E(e,o),ge);return}t.set($r,`${b}/_root.md`);for(let o of await O(e,ee))j(t,E(e,o),ee);t.set(Rs,".agentsmesh/mcp.json");}var NC=d(()=>{Ct();Ba();Et();s(lg,"buildWarpImportPaths");});async function mg(t,e){t.set("AGENTS.md",`${b}/_root.md`),t.set(".windsurfrules",`${b}/_root.md`),await jm(t,e);for(let r of await O(e,".windsurf/rules"))P(t,E(e,r),b,".md");for(let r of await O(e,".windsurf/workflows"))P(t,E(e,r),Q,".md");for(let r of await O(e,".windsurf/skills"))j(t,E(e,r),".windsurf/skills");}var DC=d(()=>{Ct();Et();s(mg,"buildWindsurfImportPaths");});var jr,wo,_$,bo,FC,xi=d(()=>{jr=".rules",wo=".zed/settings.json",_$=".config/zed",bo=`${_$}/settings.json`,FC=".agentsmesh/rules";});async function pg(t,e,r="project"){if(r==="global"){t.set(bo,".agentsmesh/mcp.json");return}t.set(jr,`${b}/_root.md`),t.set(wo,".agentsmesh/mcp.json");}var vC=d(()=>{xi();Et();s(pg,"buildZedImportPaths");});var MC=d(()=>{kR();wR();TR();PR();NR();MR();jR();UR();WR();KR();HR();YR();XR();tC();cC();uC();_C();SC();EC();AC();xC();NC();DC();vC();});var It=d(()=>{MC();});var I$,S$,R$,GC,$m,uf=d(()=>{Ut();ft();rR();pR();yR();RR();It();_a();I$={name:to,primaryRootInstructionPath:He,generateRules:ZS,generateCommands:qS,generateAgents:tR,generateSkills:QS,generateIgnore:eR,importFrom:mR},S$={rootInstructionPath:He,skillDir:Qt,managedOutputs:{dirs:[Qt],files:[He,Yo]},paths:{rulePath(t){return He},commandPath(t){return `${Qt}/${Z(t)}/SKILL.md`},agentPath(t){return `${Qt}/${B(t)}/SKILL.md`}}},R$={rootInstructionPath:Xo,skillDir:ze,managedOutputs:{dirs:[ze],files:[Xo,Vs]},rewriteGeneratedPath(t){return t===He?Xo:t===Yo?Vs:t.startsWith(`${Qt}/`)?t.replace(`${Qt}/`,`${ze}/`):t},paths:{rulePath(t){return Xo},commandPath(t){return `${ze}/${Z(t)}/SKILL.md`},agentPath(t){return `${ze}/${B(t)}/SKILL.md`}}},GC={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},$m={id:to,generators:I$,capabilities:GC,emptyImportMessage:"No Aider config found (CONVENTIONS.md, .aider/skills, or .aiderignore).",lintRules:hR,lint:{hooks:_R,permissions:IR,mcp:SR},supportsConversion:{commands:true,agents:true},project:S$,globalSupport:{capabilities:GC,detectionPaths:[Xo,Vs,ze],layout:R$},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[He],global:[Xo]},canonicalDir:YS,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Yo],global:[Vs]},canonicalDir:".agentsmesh",canonicalFilename:XS}},buildImportPaths:hf,detectionPaths:[He,Yo]};});function $C(t){let e=[];for(let r of t.rules){if(r.targets.length>0&&!r.targets.includes(Js))continue;let o=r.root?"_root":basename(r.source,".md");e.push({path:`${Or}/${o}.md`,content:r.body.trim()});}return e}function jC(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ys,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var UC=d(()=>{Vc();s($C,"generateRules");s(jC,"generateMcp");});async function WC(t,e){let r=e?.scope??"project";return J(gp,t,r)}var KC=d(()=>{wt();ug();s(WC,"importFromAmazonQ");});function BC(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Js}))}var HC=d(()=>{At();Vc();s(BC,"lintRules");});var E$,O$,k$,L$,gp,ug=d(()=>{UC();KC();HC();It();Vc();E$={name:Js,generateRules:$C,generateMcp:jC,importFrom:WC},O$={managedOutputs:{dirs:[Or],files:[Ys]},paths:{rulePath(t,e){return `${Or}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},k$={managedOutputs:{dirs:[Vn],files:[zc]},rewriteGeneratedPath(t){return t.startsWith(`${Or}/`)?t.replace(`${Or}/`,`${Vn}/`):t===Ys?zc:t},paths:{rulePath(t,e){return `${Vn}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},L$={rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},gp={id:Js,generators:E$,capabilities:{rules:"native",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},emptyImportMessage:"No Amazon Q Developer config found (.amazonq/rules/ or .amazonq/mcp.json).",lintRules:BC,project:O$,globalSupport:{capabilities:L$,detectionPaths:[Vn,zc],layout:k$},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Or],global:[Vn]},canonicalDir:LR,extensions:[".md"],preset:"rule"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ys],global:[zc]},canonicalDir:".agentsmesh",canonicalFilename:AR}},buildImportPaths:yf,detectionPaths:[Or,Ys]};});function zC(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("amp")),o=e?.body.trim()??"",n=Lt(o,r);return n?[{path:Ye,content:n}]:[]}function VC(t){return dt(t,qt)}function JC(t){return t.commands.map(e=>({path:`${qt}/${Z(e.name)}/SKILL.md`,content:de(e)}))}function YC(t){return t.agents.map(e=>({path:`${qt}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}var XC=d(()=>{ct();fe();ft();Ut();Xs();s(zC,"generateRules");s(VC,"generateSkills");s(JC,"generateCommands");s(YC,"generateAgents");});function ut(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var le=d(()=>{s(ut,"mirrorSkillsToAgents");});async function QC(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let i=n,a=i["amp.mcpServers"]??i.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(c[l]=m);Object.keys(c).length!==0&&(await Kt(t,ZC,c),r.push({fromTool:"amp",fromPath:e,toPath:ZC,feature:"mcp"}));}var ZC,qC=d(()=>{w();eo();Xs();ZC=".agentsmesh/mcp.json";s(QC,"importAmpMcp");});async function tE(t,e={}){let r=e.scope??"project",o=[],n=await W("amp",t,r);return o.push(...await J(hp,t,r,{normalize:n})),await st(t,r==="global"?Xe:qt,"amp",o,n),await QC(t,r==="global"?qo:oo,o),o}var eE=d(()=>{gt();ct();wt();qC();Xs();dg();s(tE,"importFromAmp");});function rE(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:"amp"}))}var oE=d(()=>{At();Xs();s(rE,"lintRules");});function nE(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 sE(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[U(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function iE(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 aE=d(()=>{bt();s(nE,"lintHooks");s(sE,"lintPermissions");s(iE,"lintIgnore");});function x$(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n["amp.mcpServers"]!==void 0&&(r["amp.mcpServers"]=n["amp.mcpServers"]),JSON.stringify(r,null,2)}var w$,b$,T$,cE,hp,dg=d(()=>{Ut();ft();XC();le();eE();oE();aE();It();Xs();w$={name:"amp",primaryRootInstructionPath:Ye,generateRules:zC,generateCommands:JC,generateAgents:YC,generateSkills:VC,importFrom:tE},b$={rootInstructionPath:Ye,skillDir:qt,managedOutputs:{dirs:[qt],files:[Ye,oo]},paths:{rulePath(t){return Ye},commandPath(t){return `${qt}/${Z(t)}/SKILL.md`},agentPath(t){return `${qt}/${B(t)}/SKILL.md`}}},T$={rootInstructionPath:Qo,skillDir:Xe,managedOutputs:{dirs:[Xe],files:[Qo,qo]},rewriteGeneratedPath(t){return t===Ye?Qo:t===oo?qo:t.startsWith(`${qt}/`)?t.replace(`${qt}/`,`${Xe}/`):t},mirrorGlobalPath(t,e){return ut(t,Xe,e)},paths:{rulePath(t){return Qo},commandPath(t){return `${Xe}/${Z(t)}/SKILL.md`},agentPath(t){return `${Xe}/${B(t)}/SKILL.md`}}},cE={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(x$,"mergeAmpSettings");hp={id:"amp",generators:w$,capabilities:cE,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:rE,lint:{hooks:nE,permissions:sE,ignore:iE},supportsConversion:{commands:true,agents:true},project:b$,globalSupport:{capabilities:cE,detectionPaths:[Qo,qo],layout:T$},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ye],global:[Qo]},canonicalDir:bR,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:oo,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,o){return o===oo||o===qo?x$(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:If,detectionPaths:[Ye,oo]};});function lE(t){let e=t.rules.find(o=>o.root);if(!e)return [];let r=[{path:kr,content:e.body.trim()||""}];for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("antigravity"))continue;let n=basename(o.source,".md");r.push({path:`${no}/${n}.md`,content:o.body.trim()||""});}return r}function mE(t){return t.commands.map(e=>{let r=e.description.trim(),o=e.body.trim(),n=r&&o&&!o.startsWith(r)?`${r}
|
|
52
53
|
|
|
53
|
-
${
|
|
54
|
+
${o}`:o||r;return {path:`${tn}/${e.name}.md`,content:n}})}function pE(t){return dt(t,Lr)}function uE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Yc,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function dE(t){return t.agents.map(e=>({path:`${Lr}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function fE(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>o.root?false:o.targets.length===0||o.targets.includes("antigravity"));return Lt(e?.body.trim()??"",r)}var gE=d(()=>{ct();fe();ft();qs();s(lE,"generateRules");s(mE,"generateCommands");s(pE,"generateSkills");s(uE,"generateMcp");s(dE,"generateAgents");s(fE,"renderAntigravityGlobalInstructions");});function N$(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function To(t){let e=jS(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await k(join(t.projectRoot,t.rulesDir));for(let o of e.rules){let n=N$(o.source);if(n===null||n==="rules/_root.md")continue;let i=join(t.projectRoot,".agentsmesh",n),a=t.normalize(o.body,t.sourcePath,i),{frontmatter:c,body:l}=L(a),m=await G(i,{...c,root:false,description:o.description||void 0,globs:o.globs.length>0?o.globs:void 0,targets:o.targets.length>0?o.targets:void 0},l);await I(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${n}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var Ha=d(()=>{w();v();fe();ot();s(N$,"canonicalRulePath");s(To,"splitEmbeddedRulesToCanonical");});async function D$(t,e,r,o){let n=o==="global"?so:kr,i=o==="project"?[n,Jc]:[n];for(let a of i){let c=join(t,a),l=await y(c);if(l===null)continue;let m=join(t,Sf),p=await To({content:l,projectRoot:t,rulesDir:Qs,sourcePath:c,fromTool:Zs,normalize:r});e.push(...p.results);let{body:u}=L(r(p.rootContent,c,m)),f=await G(m,{root:true},u);await k(join(t,Qs)),await I(m,f),e.push({fromTool:Zs,fromPath:c,toPath:Sf,feature:"rules"});return}}async function yE(t,e={}){let r=e.scope??"project",o=[],n=await W(Zs,t,r);return await D$(t,o,n,r),o.push(...await J(yp,t,r,{normalize:n})),await st(t,r==="global"?en:Lr,Zs,o,n),o}var _E=d(()=>{gt();w();v();ct();wt();ot();Ha();qs();gg();s(D$,"importRootRule");s(yE,"importFromAntigravity");});var RE,CE,EE=d(()=>{v();ot();qs();RE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${Qs}/${t}`,content:await G(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"nonRootRuleMapper"),CE=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${Wm}/${t}`,content:await mt(o,{hasDescription:typeof n.description=="string",description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function OE(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Zs}))}var kE=d(()=>{At();qs();s(OE,"lintRules");});var F$,v$,M$,G$,yp,gg=d(()=>{zs();ft();gE();qs();_E();EE();kE();It();F$={name:"antigravity",primaryRootInstructionPath:kr,generateRules:lE,generateCommands:mE,generateAgents:dE,generateSkills:pE,generateMcp:uE,importFrom:yE},v$={rootInstructionPath:kr,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===Yc?null:t},paths:{rulePath(t,e){return `${no}/${t}.md`},commandPath(t,e){return `${tn}/${t}.md`},agentPath(t){return `${Lr}/${B(t)}/SKILL.md`}}},M$={rootInstructionPath:so,renderPrimaryRootInstruction:fE,skillDir:en,managedOutputs:{dirs:[en,Xc],files:[so,Ia]},rewriteGeneratedPath(t){return t===kr?so:t.startsWith(`${no}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",en):t.startsWith(`${tn}/`)?t.replace(tn,Xc):t===Yc?Ia:t},paths:{rulePath(t,e){return so},commandPath(t,e){return `${Xc}/${t}.md`},agentPath(t){return `${Lr}/${B(t)}/SKILL.md`}}},G$={rules:"native",additionalRules:"embedded",commands:Er("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},yp={id:"antigravity",generators:F$,capabilities:{rules:"native",additionalRules:"native",commands:Er("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:OE,project:v$,globalSupport:{capabilities:G$,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:M$},importer:{rules:{feature:"rules",mode:"directory",source:{project:[no]},canonicalDir:Qs,extensions:[".md"],map:RE},commands:{feature:"commands",mode:"directory",source:{project:[tn],global:[Xc]},canonicalDir:Wm,extensions:[".md"],map:CE},mcp:{feature:"mcp",mode:"flatFile",source:{global:[Ia]},canonicalDir:".agentsmesh",canonicalFilename:xR}},buildImportPaths:Rf,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function j$(t){let e={};return t.description&&(e.description=t.description),t.globs.length>0||t.trigger==="manual"||t.trigger==="model_decision"?(e.agent_requested=true,t.globs.length>0&&(e.globs=t.globs)):e.always_apply=true,e}function U$(t){let e={};return t.description&&(e.description=t.description),e}function LE(t){let e=[];for(let r of t.rules)if(!(r.targets.length>0&&!r.targets.includes(te)))if(r.root){let o={always_apply:true};r.description&&(o.description=r.description),e.push({path:`${Ee}/_root.md`,content:x(o,r.body.trim())});}else {let o=basename(r.source,".md");e.push({path:`${Ee}/${o}.md`,content:x(j$(r),r.body.trim())});}return e}function AE(t){return t.commands.map(e=>({path:`${Ze}/${e.name}.md`,content:x(U$(e),e.body.trim())}))}function wE(t){return dt(t,Oe)}function bE(t){return t.ignore.length===0?[]:[{path:ao,content:t.ignore.join(`
|
|
55
|
+
`)}]}var TE=d(()=>{ct();v();ti();s(j$,"ruleFrontmatter");s(U$,"commandFrontmatter");s(LE,"generateRules");s(AE,"generateCommands");s(wE,"generateSkills");s(bE,"generateIgnore");});function K$(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:".*",l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=typeof m.command=="string"?m.command:void 0;if(!p)continue;let u={matcher:c,type:"command",command:p};typeof m.timeout=="number"&&(u.timeout=m.timeout),n.push(u);}}n.length>0&&(e[r]=n);}return e}async function PE(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n.mcpServers&&typeof n.mcpServers=="object"){let a=n.mcpServers;await Kt(t,Ef,a),r.push({fromTool:te,fromPath:join(t,e),toPath:Ef,feature:"mcp"});}let i=n.hooks;if(i&&typeof i=="object"&&!Array.isArray(i)){let a=K$(i);if(Object.keys(a).length>0){let c=join(t,Of);await k(dirname(c)),await I(c,stringify(a)),r.push({fromTool:te,fromPath:join(t,e),toPath:Of,feature:"hooks"});}}}async function NE(t,e,r){let o=await y(join(t,e));if(o===null)return;let n=o.split(`
|
|
56
|
+
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"));if(n.length===0)return;let i=join(t,kf);await k(dirname(i)),await I(i,n.join(`
|
|
57
|
+
`)),r.push({fromTool:te,fromPath:join(t,e),toPath:kf,feature:"ignore"});}var DE=d(()=>{w();eo();ti();s(K$,"augmentHooksToCanonical");s(PE,"importAugmentSettings");s(NE,"importAugmentIgnore");});function B$(t,e){let r={root:e,description:typeof t.description=="string"?t.description:void 0,globs:Array.isArray(t.globs)?t.globs:[]};return t.agent_requested===true&&(r.trigger="model_decision"),r}async function H$(t,e,r,o){let n=o==="global"?rn:Ee,i=join(t,Cf);e.push(...await pt({srcDir:join(t,n),destDir:i,extensions:[".md"],fromTool:te,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:c})=>{let l=a==="_root.md"||basename(a)==="_root.md",m=join(i,a),{frontmatter:p,body:u}=L(c(m));return {destPath:m,toPath:`${Cf}/${a}`,feature:"rules",content:await G(m,B$(p,l),u)}},"mapEntry")}));}async function z$(t,e,r,o){let n=o==="global"?on:Ze,i=join(t,".agentsmesh/commands");e.push(...await pt({srcDir:join(t,n),destDir:i,extensions:[".md"],fromTool:te,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:c})=>{let l=basename(a,".md"),m=join(i,`${l}.md`),{frontmatter:p,body:u}=L(c(m)),f=typeof p.description=="string"?p.description:"";return {destPath:m,toPath:`.agentsmesh/commands/${l}.md`,feature:"commands",content:await mt(m,{description:f,hasDescription:true,hasAllowedTools:false},u)}},"mapEntry")}));}async function vE(t,e={}){let r=e.scope??"project",o=[],n=await W(te,t,r);return await H$(t,o,n,r),await z$(t,o,n,r),await st(t,r==="global"?co:Oe,te,o,n),await PE(t,r==="global"?nn:io,o),r==="project"&&await NE(t,ao,o),o}var ME=d(()=>{gt();Ce();ct();ot();v();DE();ti();s(B$,"canonicalRuleMeta");s(H$,"importRules");s(z$,"importCommands");s(vE,"importFromAugmentCode");});function GE(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:te}))}var $E=d(()=>{At();ti();s(GE,"lintRules");});function UE(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=new Set(jE);return Object.keys(t.hooks).filter(r=>!e.has(r)).map(r=>zn(r,"augment-code",jE,{unsupportedBy:"AugmentCode hooks"}))}var jE,WE=d(()=>{bt();jE=["PreToolUse","PostToolUse","SessionStart","SessionEnd","Stop"];s(UE,"lintHooks");});function J$(t){let e={};for(let[r,o]of Object.entries(t)){if(!o||o.length===0)continue;let n=o.map(i=>({matcher:i.matcher,hooks:[{type:"command",command:i.command,...i.timeout!==void 0?{timeout:i.timeout}:{}}]}));e[r]=n;}return e}function Y$(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n.mcpServers!==void 0&&(r.mcpServers=n.mcpServers),n.hooks!==void 0&&(r.hooks=n.hooks),JSON.stringify(r,null,2)}function X$(t){let e={};return t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&(e.mcpServers=t.mcp.mcpServers),t.hooks&&Object.keys(t.hooks).length>0&&(e.hooks=J$(t.hooks)),Object.keys(e).length===0?null:JSON.stringify(e,null,2)}var V$,Z$,Q$,q$,tj,KE,BE=d(()=>{TE();ME();$E();WE();It();ti();V$={name:te,generateRules:LE,generateCommands:AE,generateSkills:wE,generateIgnore:bE,importFrom:vE};s(J$,"serializeHooksForSettings");s(Y$,"mergeAugmentSettings");s(X$,"buildSettingsContent");Z$={skillDir:Oe,managedOutputs:{dirs:[Ee,Ze,Oe],files:[io,ao]},paths:{rulePath(t){return `${Ee}/${t}.md`},commandPath(t){return `${Ze}/${t}.md`},agentPath(t){return null}}},Q$={skillDir:co,managedOutputs:{dirs:[rn,on,co],files:[nn]},rewriteGeneratedPath(t){return t.startsWith(`${Ee}/`)?t.replace(`${Ee}/`,`${rn}/`):t.startsWith(`${Ze}/`)?t.replace(`${Ze}/`,`${on}/`):t.startsWith(`${Oe}/`)?t.replace(`${Oe}/`,`${co}/`):t===io?nn:t===ao?null:t},paths:{rulePath(t){return `${rn}/${t}.md`},commandPath(t){return `${on}/${t}.md`},agentPath(t){return null}}},q$={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},tj={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},KE={id:te,generators:V$,capabilities:q$,emptyImportMessage:"No AugmentCode config found (.augment/rules, .augment/commands, .augment/skills, .augment/settings.json, or .augmentignore).",lintRules:GE,lint:{hooks:UE},project:Z$,globalSupport:{capabilities:tj,detectionPaths:[rn,on,co,nn],layout:Q$},emitScopedSettings(t){let e=X$(t);return e===null?[]:[{path:io,content:e}]},mergeGeneratedOutputContent(t,e,r,o){return o===io||o===nn?Y$(t,r):null},buildImportPaths:Lf,detectionPaths:[Ee,Ze,Oe,io,ao]};});function HE(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,o]of Object.entries(t.hooks)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!Zr(i))continue;let a=vt(i),c=ne(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),n.push({matcher:i.matcher,hooks:[m]});}n.length>0&&(e[r]=n);}return e}var zE=d(()=>{Sr();s(HE,"buildClaudeHooksObjectFromCanonical");});function VE(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Jn,content:r.body.trim()?r.body:""});let o=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes("claude-code")));for(let n of o){let i=basename(n.source,".md"),a={};n.description&&(a.description=n.description),n.globs.length>0&&(a.globs=n.globs);let c=x(a,n.body.trim()||"");e.push({path:`${Zc}/${i}.md`,content:c});}return e}function JE(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let o=x(r,e.body.trim()||"");return {path:`${Qc}/${e.name}.md`,content:o}})}function YE(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(a=>{r[a]===void 0&&delete r[a];});let o=e.body.trim()||"",n=/^##\s*Role\b/m.test(o)?o:`## Role
|
|
54
58
|
|
|
55
|
-
${
|
|
59
|
+
${o}`,i=x(r,n);return {path:`${qc}/${e.name}.md`,content:i}})}function XE(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Sa,content:e}]}function ZE(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=r.body.trim()||"",i=!n||/^##\s*Purpose\b/m.test(n)?n:`## Purpose
|
|
56
60
|
|
|
57
|
-
${
|
|
58
|
-
`);return [{path:
|
|
61
|
+
${n}`,a=x(o,i);e.push({path:`${tl}/${r.name}/SKILL.md`,content:a});for(let c of r.supportingFiles){let l=c.relativePath.replace(/\\/g,"/");e.push({path:`${tl}/${r.name}/${l}`,content:c.content});}}return e}function QE(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];if(e.length===0&&r.length===0&&o.length===0)return [];let n=JSON.stringify({permissions:{allow:e,deny:r,ask:o}},null,2);return [{path:el,content:n}]}function qE(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=HE(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:sn,content:JSON.stringify(r,null,2)}];let o=JSON.stringify({hooks:r},null,2);return [{path:el,content:o}]}function tO(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
62
|
+
`);return [{path:rl,content:e}]}var eO=d(()=>{v();an();zE();s(VE,"generateRules");s(JE,"generateCommands");s(YE,"generateAgents");s(XE,"generateMcp");s(ZE,"generateSkills");s(QE,"generatePermissions");s(qE,"generateHooks");s(tO,"generateIgnore");});function oj(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function rO(t){let e=t.rules.find(n=>n.root),r=(e?.body??"").trim();return r?`# Global Instructions
|
|
59
63
|
|
|
60
|
-
## ${e?
|
|
64
|
+
## ${e?oj(e):"Guidance"}
|
|
61
65
|
|
|
62
66
|
${r}
|
|
63
|
-
`:""}var
|
|
67
|
+
`:""}var oO=d(()=>{s(oj,"ruleSectionTitle");s(rO,"renderClaudeGlobalPrimaryInstructions");});function sO(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function iO(t,e,r,o){if(r!=="global")return [];let n=o.has("agents"),i=o.has("commands");if(!n&&!i)return [];let a=[];if(n)for(let c of t.agents){if(!c.outputStyle)continue;let l={name:c.name,description:c.description||void 0},m=x(l,c.body.trim()),p=`${Af}/${c.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:sO(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=x(l,c.body.trim()),p=`${Af}/${c.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:sO(u,m)});}return a}var aO=d(()=>{w();v();an();s(sO,"computeStatus");s(iO,"generateClaudeGlobalExtras");});var cO,lO,mO,pO=d(()=>{v();ot();Je();an();cO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${nl}/${t}`,content:await G(o,{...n,root:false},i)}},"claudeRuleMapper"),lO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o)),a=Ve(n.allowedTools),c=a.length>0?a:Ve(n["allowed-tools"]);return {destPath:o,toPath:`${Hm}/${t}`,content:await mt(o,{description:typeof n.description=="string"?n.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}},"claudeCommandMapper"),mO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${zm}/${t}`,content:await Mt(o,n,i)}},"claudeAgentMapper");});function uO(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:DR}))}var dO=d(()=>{At();an();s(uO,"lintRules");});var nj,fO,sj,ij,_p,yg=d(()=>{eO();an();le();oO();aO();_g();pO();dO();It();nj={name:"claude-code",primaryRootInstructionPath:Jn,generateRules:VE,generateCommands:JE,generateAgents:YE,generateSkills:ZE,generateMcp:XE,generatePermissions:QE,generateHooks:qE,generateIgnore:tO,importFrom:Ip},fO={rootInstructionPath:Jn,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`}}},sj={rootInstructionPath:Jn,skillDir:".claude/skills",renderPrimaryRootInstruction:rO,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",ol,sn,".claudeignore"]},rewriteGeneratedPath(t){return t===Sa?ol:t},mirrorGlobalPath(t,e){return ut(t,".claude/skills",e)},paths:fO.paths},ij={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},_p={id:"claude-code",generators:nj,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:uO,project:fO,globalSupport:{capabilities:ij,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:sj,scopeExtras:iO},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Jn,FR],global:[Jn]},canonicalDir:nl,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Zc],global:[Zc]},canonicalDir:nl,extensions:[".md"],map:cO}],commands:{feature:"commands",mode:"directory",source:{project:[Qc],global:[Qc]},canonicalDir:Hm,extensions:[".md"],map:lO},agents:{feature:"agents",mode:"directory",source:{project:[qc],global:[qc]},canonicalDir:zm,extensions:[".md"],map:mO},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Sa],global:[ol]},canonicalDir:".agentsmesh",canonicalFilename:sl},ignore:{feature:"ignore",mode:"flatFile",source:{project:[rl],global:[rl]},canonicalDir:".agentsmesh",canonicalFilename:vR}},buildImportPaths:Tf,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function cj(t){let e=basename(t,".md");return e==="_root"?"root":e}function gO(t){let e=[],r=t.rules.find(o=>o.root);if(r){let o=r.body.trim()?r.body:"";e.push({path:Xn,content:o});}for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("cline"))continue;let n=cj(o.source),i={description:o.description||void 0,paths:o.globs.length>0?o.globs:void 0};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=Object.keys(i).length>0?x(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${cn}/${n}.md`,content:a});}return e}function hO(t){return t.commands.map(e=>{let r=e.description.trim(),o=e.body.trim(),n=r&&o?`${r}
|
|
64
68
|
|
|
65
|
-
${
|
|
66
|
-
`);return [{path:
|
|
67
|
-
`)}function
|
|
69
|
+
${o}`:r||o;return {path:`${lo}/${e.name}.md`,content:n}})}function yO(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
70
|
+
`);return [{path:ri,content:e}]}function _O(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ln,content:e}]}function IO(t){return t.agents.map(e=>({path:`${zt}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function lj(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function Ig(t){return t.replace(/[\r\n]+/g," ")}function mj(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${Ig(t)}`,`# agentsmesh-matcher: ${Ig(r)}`,`# agentsmesh-command: ${Ig(e)}`,"set -eu",e,""].join(`
|
|
71
|
+
`)}function SO(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.hooks)){if(!Array.isArray(o))continue;let n=0;for(let i of o)Vo(i)&&(e.push({path:`${oi}/${lj(r)}-${n}.sh`,content:mj(r,i.command,i.matcher)}),n++);}return e}function RO(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=x(o,r.body.trim()||"");e.push({path:`${zt}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${zt}/${r.name}/${a}`,content:i.content});}}return e}var CO=d(()=>{Sr();v();ft();Qe();s(cj,"ruleSlug");s(gO,"generateRules");s(hO,"generateCommands");s(yO,"generateIgnore");s(_O,"generateMcp");s(IO,"generateAgents");s(lj,"safeEventName");s(Ig,"safeShellLine");s(mj,"buildHookScript");s(SO,"generateHooks");s(RO,"generateSkills");});async function OO(t,e,r){if(t==="workflows"||t.startsWith("workflows/"))return null;let o=t.replace(/\\/g,"/");if(o==="_root.md")return null;let n=join(e,o),{frontmatter:i,body:a}=L(r(n)),c=Zo(i.paths??i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:n,toPath:`${Zn}/${o}`,feature:"rules",content:await G(n,l,a)}}async function kO(t,e,r){let o=join(e,t),{frontmatter:n,body:i}=L(r(o)),a=Object.prototype.hasOwnProperty.call(n,"description"),c=a&&typeof n.description=="string"?n.description:"",l=a,m=i;if(!l){let p=i.indexOf(`
|
|
68
72
|
|
|
69
73
|
`);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:
|
|
71
|
-
`)),e.push({fromTool:"cline",fromPath:
|
|
74
|
+
`)&&(c=u,l=true,m=i.slice(p+2));}}return {destPath:o,toPath:`${Vm}/${t}`,feature:"commands",content:await mt(o,{description:c,hasDescription:l,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},m)}}var Sg=d(()=>{v();ot();Je();Qe();s(OO,"mapClineRuleFile");s(kO,"mapClineWorkflowFile");});async function LO(t,e,r){let o=join(t,Zn),n=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 k(o);let u=join(o,"_root.md"),{frontmatter:f,body:g}=L(r(p,i,u)),C=f.root===true?f:{...f,root:true},R=await G(u,C,g);await I(u,R),e.push({fromTool:"cline",fromPath:i,toPath:`${Zn}/_root.md`,feature:"rules"});}return a}let c=null,l=join(n,"_root.md"),m=await y(l);if(m===null){let p=join(t,Xn),u=await y(p);if(u!==null){c=p,await k(o);let f=join(o,"_root.md"),{frontmatter:g,body:h}=L(r(u,p,f)),R=g.root===true?g:{...g,root:true},_=await G(f,R,h);await I(f,_),e.push({fromTool:"cline",fromPath:p,toPath:`${Zn}/_root.md`,feature:"rules"});}else {let h=(await F(n)).filter(C=>C.endsWith(".md")&&!C.includes("/workflows/")).sort()[0];if(h){let C=await y(h);if(C!==null){c=h,await k(o);let R=join(o,"_root.md"),{frontmatter:_,body:A}=L(r(C,h,R)),N=_.root===true?_:{..._,root:true},T=await G(R,N,A);await I(R,T),e.push({fromTool:"cline",fromPath:h,toPath:`${Zn}/_root.md`,feature:"rules"});}}}}else {c=l,await k(o);let p=join(o,"_root.md"),{frontmatter:u,body:f}=L(r(m,l,p)),h=u.root===true?u:{...u,root:true},C=await G(p,h,f);await I(p,C),e.push({fromTool:"cline",fromPath:l,toPath:`${Zn}/_root.md`,feature:"rules"});}return e.push(...await pt({srcDir:n,destDir:o,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:f})=>p===c?null:OO(u,o,f),"mapEntry")})),a}var AO=d(()=>{w();v();ot();Ce();Sg();Qe();s(LO,"importClineRules");});function uj(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let o=typeof e.type=="string"?e.type:typeof e.transportType=="string"?e.transportType:"stdio",n=Array.isArray(e.args)?e.args.filter(l=>typeof l=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(l=>typeof l[1]=="string")):{},c=typeof e.description=="string"?e.description:void 0;return {...c!==void 0&&{description:c},type:o,command:r,args:n,env:a}}async function wO(t,e){let r=[ln,GR].map(l=>join(t,l)),o=null,n=null;for(let l of r){let m=await y(l);if(m!==null){o=l,n=m;break}}if(n===null)return;let i=o??r[0],a;try{a=JSON.parse(n);}catch{}let c=a?.mcpServers;if(c!==void 0&&typeof c=="object"&&c!==null&&Object.keys(c).length>0){let l={};for(let[m,p]of Object.entries(c)){let u=uj(p);u&&(l[m]=u);}Object.keys(l).length>0&&(await k(join(t,".agentsmesh")),await I(join(t,Nf),JSON.stringify({mcpServers:l},null,2)),e.push({fromTool:Yn,fromPath:i,toPath:Nf,feature:"mcp"}));}}var bO=d(()=>{w();Qe();s(uj,"mapClineServerToCanonical");s(wO,"importClineMcp");});function TO(t){return dj.some(e=>e.test(t))}var dj,xO=d(()=>{dj=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(TO,"isReservedArtifactName");});async function gj(t){let e=await F(t).catch(()=>[]),r=[];for(let o of e){let n=relative(t,o).replace(/\\/g,"/"),i=basename(n);if(TO(i))continue;let a=await y(o);a!==null&&r.push({absolutePath:o,relativePath:n,content:a});}return r}async function xo(t,e,r){let o=await gj(e),n=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of o){let a=join(n,i.relativePath);await k(dirname(a));let c=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:l,body:m}=L(c),p=await qr(a,{...l,name:t},m);await I(a,p);}else await I(a,c);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function NO(t,e,r,o){let n=join(o.projectRoot,o.destCanonicalSkillsDir,t);await k(n);let i=join(n,"SKILL.md"),a=o.normalize(r,e,i),{frontmatter:c,body:l}=L(a),m=await qr(i,{...c,name:t},l);await I(i,m),o.results.push({fromTool:o.targetName,fromPath:e,toPath:`${o.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function Cs(t){let e=new Map;try{let o=(await F(t)).filter(n=>basename(n)==="SKILL.md");for(let n of o){let i=dirname(n),a=basename(i);e.set(a,i);}}catch{}return e}var Va=d(()=>{w();v();ot();xO();s(gj,"readNativeSkill");s(xo,"importDirectorySkill");s(NO,"importFlatSkill");s(Cs,"findDirectorySkills");});async function DO(t,e,r,o=zt){let n=join(t,o),i=await Cs(n),a={projectRoot:t,sourceSkillsDir:o,destCanonicalSkillsDir:$R,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=L(p),f=Qr(u.frontmatter,c);if(f){let g=join(t,Df);await k(g);let h=join(g,`${f.name}.md`);await I(h,We(f,r(u.body,m,h))),e.push({fromTool:"cline",fromPath:m,toPath:`${Df}/${f.name}.md`,feature:"agents"});continue}await xo(c,l,a);}}var FO=d(()=>{w();v();ft();Va();Qe();s(DO,"importClineSkills");});function Eg(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function vO(t,e){let o=(await F(t).catch(()=>[])).filter(n=>basename(n).endsWith(".sh")&&dirname(n)===t);for(let n of o){let i=await y(n);if(!i)continue;let a=Eg(i,"event"),c=Eg(i,"command");if(!a||!c)continue;let l=Eg(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:l,command:c});}}async function GO(t,e){let r={};if(await vO(join(t,oi),r),await vO(join(t,ii),r),Object.keys(r).length===0)return;let o=join(t,xf);await k(dirname(o)),await I(o,stringify(r)),e.push({fromTool:Yn,fromPath:join(t,ii),toPath:xf,feature:"hooks"});}var $O=d(()=>{w();Qe();s(Eg,"extractMeta");s(vO,"loadHooksFromDir");s(GO,"importClineHooks");});async function Ep(t){let e=[],r=await W(Yn,t),o=await LO(t,e,r),n=join(t,ri),i=await y(n);if(i!==null&&i.trim()){let c=i.split(/\r?\n/),l=[];for(let m of c){let p=m.trim();p&&!p.startsWith("#")&&l.push(p);}if(l.length>0){await k(join(t,".agentsmesh"));let m=join(t,Pf);await I(m,l.join(`
|
|
75
|
+
`)),e.push({fromTool:"cline",fromPath:n,toPath:Pf,feature:"ignore"});}}await wO(t,e);let a=join(t,Vm);return o||e.push(...await pt({srcDir:join(t,lo),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:c,normalizeTo:l})=>kO(c,a,l),"mapEntry")})),await DO(t,e,r),await GO(t,e),e}var Og=d(()=>{gt();w();Ce();Sg();AO();Qe();bO();FO();$O();s(Ep,"importFromCline");});function jO(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:Yn}))}var UO=d(()=>{At();Qe();s(jO,"lintRules");});function WO(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 KO(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 BO=d(()=>{bt();s(WO,"lintCommands");s(KO,"lintHooks");});var _j,Ij,Sj,Rj,HO,zO=d(()=>{CO();zs();Qe();Og();UO();BO();It();ua();ft();_j={name:"cline",primaryRootInstructionPath:Xn,generateRules:gO,generateCommands:hO,generateAgents:IO,generateSkills:RO,generateMcp:_O,generateHooks:SO,generateIgnore:yO,importFrom:Ep},Ij={rootInstructionPath:Xn,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 `${lo}/${t}.md`},agentPath(t,e){return Ue(e,"cline")?`.cline/skills/${B(t)}/SKILL.md`:null}}},Sj={skillDir:zt,managedOutputs:{dirs:[ni,si,ii,zt,".agents/skills"],files:[ln,ri]},rewriteGeneratedPath(t){return t===Xn?null:t.startsWith(`${oi}/`)?`${ii}/${t.slice(oi.length+1)}`:t.startsWith(`${lo}/`)?`${si}/${t.slice(lo.length+1)}`:t.startsWith(`${cn}/`)?`${ni}/${t.slice(cn.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${zt}/`)?`.agents/skills/${t.slice(zt.length+1)}`:null},paths:{rulePath(t,e){return `${ni}/${t}.md`},commandPath(t,e){return `${si}/${t}.md`},agentPath(t,e){return Ue(e,"cline")?`.cline/skills/${B(t)}/SKILL.md`:null}}},Rj={rules:"native",additionalRules:"native",commands:Er("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},HO={id:"cline",generators:_j,capabilities:{rules:"native",additionalRules:"native",commands:Er("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:jO,lint:{commands:WO,hooks:KO},project:Ij,globalSupport:{capabilities:Rj,detectionPaths:[ni,si,ii,zt,ln,ri],layout:Sj},buildImportPaths:Ff,detectionPaths:[".clinerules",".cline"]};});var Jt,VO,wn,Ni,JO,Wr,YO,Op,Di,Po,Fi,bn,kg,Ja,Tl,Lg,XO,Ag,ZO,QO,wg,bg,Tg,re=d(()=>{Jt="codex-cli",VO="codex.md",wn="AGENTS.md",Ni=".codex/AGENTS.md",JO=".codex/AGENTS.override.md",Wr=".agents/skills",YO=".codex/skills",Op=".codex/config.toml",Di=".codex/instructions",Po=".codex/rules",Fi=".codex/agents",bn=".agentsmesh/rules",kg=".agentsmesh/commands",Ja=".agentsmesh/agents",Tl=".agentsmesh/skills",Lg=".agentsmesh/mcp.json",XO="am-codex-rule:v1",Ag="# am-json: ",ZO="# am-body-b64-begin",QO="# am-body-b64-end",wg="# am64:",bg="<!-- agentsmesh:codex-rule-index:start -->",Tg="<!-- agentsmesh:codex-rule-index:end -->";});function xg(t){return basename(t,".md")}function xl(t){return `${Di}/${xg(t.source)}.md`}function qO(t){let e={root:t.root,description:t.description||void 0,globs:t.globs.length>0?t.globs:void 0,targets:t.targets.length>0?t.targets:void 0,codex_emit:t.codexEmit||void 0,codex_instruction:t.codexInstructionVariant&&t.codexInstructionVariant!=="default"?t.codexInstructionVariant:void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),x(e,t.body.trim()||"")}function Ej(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 \`${Po}/${xg(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function tk(t,e){let r=t.trim(),o=e.filter(a=>!a.root);if(o.length===0)return r;let n=o.map(a=>`- [${a.description||xg(a.source)}](${xl(a)}): ${Ej(a)}`),i=[bg,"## Additional Rule Files",...n,Tg].join(`
|
|
72
76
|
`);return r?`${r}
|
|
73
77
|
|
|
74
|
-
${i}`:i}function
|
|
75
|
-
`).trim()}var
|
|
78
|
+
${i}`:i}function ek(t){let e=bg.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=Tg.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
|
|
79
|
+
`).trim()}var kp=d(()=>{v();re();s(xg,"ruleSlug");s(xl,"codexInstructionMirrorPath");s(qO,"serializeCodexInstructionMirror");s(Ej,"summarizeRule");s(tk,"appendCodexRuleIndex");s(ek,"stripCodexRuleIndex");});function kj(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function Lj(t){return t.split(`
|
|
76
80
|
`).map(e=>e.length>0?`# ${e}`:"#").join(`
|
|
77
|
-
`)}function
|
|
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.","#",...
|
|
81
|
+
`)}function Aj(t){let e=t.trim();return e?kj(e)?`${e}
|
|
82
|
+
`:`${["# agentsmesh: canonical execution rule body is not Codex DSL","# The original body is preserved below as comments.","# Replace with Codex rules DSL (for example prefix_rule(...)) to enforce behavior.","#",...Lj(e).split(`
|
|
79
83
|
`),"#","# Example template:","# prefix_rule(",'# pattern = ["git", "status"],','# decision = "allow",','# justification = "Allow safe status checks",',"# )"].join(`
|
|
80
84
|
`)}
|
|
81
|
-
`:""}function
|
|
82
|
-
${
|
|
85
|
+
`:""}function Pg(t){let e=t.rules.find(o=>o.root),r=[];e&&r.push({path:wn,content:tk(e.body,t.rules)});for(let o of t.rules){if(o.root)continue;let n=basename(o.source,".md");o.targets.length>0&&!o.targets.includes("codex-cli")||(o.codexEmit==="execution"&&r.push({path:`${Po}/${n}.rules`,content:Aj(o.body)}),r.push({path:xl(o),content:qO(o)}));}return r}function Ng(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>o.root||o.codexEmit==="execution"?false:o.targets.length===0||o.targets.includes("codex-cli"));return Lt(e?.body.trim()??"",r)}var rk=d(()=>{fe();re();kp();s(kj,"looksLikeCodexRulesDsl");s(Lj,"toCodexRulesComments");s(Aj,"toSafeCodexRulesContent");s(Pg,"generateRules");s(Ng,"renderCodexGlobalInstructions");});function Dg(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=x(o,r.body.trim()||"");e.push({path:`${Wr}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Wr}/${r.name}/${a}`,content:i.content});}}return e}function wj(t){return {path:`${Wr}/${Z(t.name)}/SKILL.md`,content:de(t)}}function Fg(t){return t.commands.map(wj)}var ok=d(()=>{v();re();Ut();s(Dg,"generateSkills");s(wj,"commandToSkillOutput");s(Fg,"generateCommands");});function vg(t){return t.agents.map(e=>({path:`${Fi}/${e.name}.toml`,content:bj(e)}))}function bj(t){let e=[];e.push(`name = ${JSON.stringify(t.name)}`),t.description&&e.push(`description = ${JSON.stringify(t.description)}`),t.model&&e.push(`model = ${JSON.stringify(t.model)}`),t.permissionMode==="read-only"||t.permissionMode==="deny"?e.push('sandbox_mode = "read-only"'):t.permissionMode==="allow"&&e.push('sandbox_mode = "workspace-write"');let r=t.body.trim()||"";if(r.includes("'''")){let o=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`developer_instructions = """
|
|
86
|
+
${o}
|
|
83
87
|
"""`);}else e.push(`developer_instructions = '''
|
|
84
88
|
${r}
|
|
85
89
|
'''`);return e.join(`
|
|
86
90
|
`)+`
|
|
87
|
-
`}var
|
|
91
|
+
`}var nk=d(()=>{re();s(vg,"generateAgents");s(bj,"serializeAgentToCodexToml");});function Lp(t){return "command"in t}function sk(t){return "url"in t}var Ap=d(()=>{s(Lp,"isStdioMcpServer");s(sk,"isUrlMcpServer");});function Mg(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([o,n])=>Lp(n)?[[o,n]]:[]));if(Object.keys(e).length===0)return [];let r=Tj(e);return [{path:Op,content:r}]}function Tj(t){let e=[];for(let[r,o]of Object.entries(t)){let n=ik(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${n}]`),i.push(`command = ${JSON.stringify(o.command)}`);let a="["+o.args.map(l=>JSON.stringify(l)).join(", ")+"]";i.push(`args = ${a}`);let c=Object.entries(o.env);if(c.length>0){let l=c.map(([m,p])=>`${ik(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${l} }`);}e.push(i.join(`
|
|
88
92
|
`));}return e.join(`
|
|
89
93
|
|
|
90
94
|
`)+`
|
|
91
|
-
`}function
|
|
92
|
-
`).find(l=>l.startsWith(
|
|
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}
|
|
95
|
+
`}function ik(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var ak=d(()=>{Ap();re();s(Mg,"generateMcp");s(Tj,"serializeMcpToToml");s(ik,"needsTomlQuoting");});var ck=d(()=>{rk();ok();nk();ak();});var lk=d(()=>{ck();});function Nj(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let o=Array.isArray(e.args)?e.args.filter(a=>typeof a=="string"):[],n=e.env,i=n!==null&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).filter(a=>typeof a[1]=="string")):{};return {type:"stdio",command:r,args:o,env:i}}async function mk(t,e){let r=join(t,Op),o=await y(r);if(o===null)return;let n;try{n=parse$1(o);}catch{return}let i=n.mcp_servers;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0)return;let a={};for(let[c,l]of Object.entries(i)){let m=Nj(l);m&&(a[c]=m);}Object.keys(a).length!==0&&(await Kt(t,Lg,a),e.push({fromTool:Jt,fromPath:r,toPath:Lg,feature:"mcp"}));}var pk=d(()=>{w();eo();re();s(Nj,"mapTomlServerToCanonical");s(mk,"importMcp");});async function uk(t,e,r){let o={projectRoot:t,sourceSkillsDir:Wr,destCanonicalSkillsDir:Tl,targetName:Jt,normalize:r,results:e};for(let n of [Wr,YO]){let i=join(t,n),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,Tl,f,"SKILL.md"),h=r(u,p,g),{frontmatter:C,body:R}=L(h),_=Nm(C,l.name);if(_){await Ke(join(t,Tl,f));let D=join(t,kg);await k(D);let N=join(D,`${_.name}.md`);await I(N,Dm(_,r(R,p,N))),e.push({fromTool:Jt,fromPath:p,toPath:`${kg}/${_.name}.md`,feature:"commands"});continue}let A=Qr(C,l.name);if(A){await Ke(join(t,Tl,f));let D=join(t,Ja);await k(D);let N=join(D,`${A.name}.md`);await I(N,We(A,r(R,p,N))),e.push({fromTool:Jt,fromPath:p,toPath:`${Ja}/${A.name}.md`,feature:"agents"});continue}await xo(f,m,o);}if(c)return}}var dk=d(()=>{w();v();Ut();ft();ya();Va();re();s(uk,"importSkills");});async function fk(t,e,r){let o=join(t,Fi),n=join(t,Ja);try{let a=(await F(o)).filter(c=>c.endsWith(".toml"));for(let c of a){let l=await y(c);if(!l)continue;let m=parse$1(l);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(c,".toml"),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:"",C=h==="read-only"?"read-only":h==="workspace-write"?"allow":"",R=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(T=>typeof T=="string"):[];await k(n);let _=join(n,`${p}.md`),A=r(f,c,_),N=We({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:C,maxTurns:0,mcpServers:R,hooks:{},skills:[],memory:""},A);await I(_,N),e.push({fromTool:Jt,fromPath:c,toPath:`${Ja}/${p}.md`,feature:"agents"});}}catch{}}var gk=d(()=>{w();ft();re();s(fk,"importCodexAgentsFromToml");});function hk(t){if(!t.includes(XO))return null;let e=t.split(`
|
|
96
|
+
`).find(l=>l.startsWith(Ag));if(!e)return null;let r;try{r=JSON.parse(e.slice(Ag.length));}catch{return null}if(!r||typeof r!="object")return null;let o=r,n=typeof o.description=="string"?o.description:"",i=Array.isArray(o.globs)?o.globs.filter(l=>typeof l=="string"):[],a=[],c=false;for(let l of t.split(`
|
|
97
|
+
`)){let m=l.trimEnd();if(m===ZO){c=true;continue}if(m===QO){c=false;continue}c&&m.startsWith(wg)&&a.push(m.slice(wg.length));}if(a.length===0)return null;try{let l=Buffer$1.from(a.join(""),"base64").toString("utf8");return {meta:{description:n,globs:i},body:l}}catch{return null}}var yk=d(()=>{re();s(hk,"tryParseEmbeddedCanonicalFromCodexRules");});async function Ik(t,e,r){let o=[],n=join(t,Po);try{let i=await F(n),a=i.filter(l=>l.endsWith(".md"));for(let l of a){let m=await y(l);if(!m)continue;let p=relative(n,l).replace(/\\/g,"/"),u=join(e,p),{frontmatter:f,body:g}=L(r(m,l,u));await k(e);let h=f.root===!0?f:{...f,root:!1},C=await G(u,h,g);await I(u,C),o.push({fromTool:Jt,fromPath:l,toPath:`${bn}/${p}`,feature:"rules"});}let c=i.filter(l=>l.endsWith(".rules"));for(let l of c){let m=await y(l);if(!m)continue;let p=relative(n,l).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await k(e);let f=hk(m);if(f){let g=await G(u,{description:f.meta.description,globs:f.meta.globs,root:!1},r(f.body,l,u));await I(u,g);}else {let g=await G(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),l,u));await I(u,g);}o.push({fromTool:Jt,fromPath:l,toPath:`${bn}/${p}`,feature:"rules"});}}catch{}return o}var Sk=d(()=>{w();v();ot();re();yk();s(Ik,"importCodexNonRootRuleFiles");});async function Ck(t,e,r,o,n){let i=join(t,VO),a=join(t,wn),c=join(t,JO),l=join(t,Ni),m=n==="global"?await y(c):null,p=n==="global"?await y(l):null,u=n==="project"?await y(a):null,f=n==="project"?await y(i):null,g=m!==null?c:p!==null?l:u!==null?a:i,h=join(t,bn),C=m??p??u??f;if(C!==null){await k(h);let R=join(h,"_root.md"),_=g===a||g===l||g===c?ek(C):C,A=await To({content:_,projectRoot:t,rulesDir:bn,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...A.results);let D=r(g===a||g===l||g===c?o(A.rootContent,g,R):A.rootContent,g,R),{frontmatter:N,body:T}=L(D),rt=N.root===true?N:{...N,root:true},z=await G(R,rt,T);await I(R,z),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${bn}/_root.md`,feature:"rules"});}await jj(t,h,e,r),e.push(...await Ik(t,h,r)),n!=="global"&&e.push(...await pt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:R,normalizeTo:_})=>{let A=relative(t,dirname(R)).replace(/\\/g,"/"),D=basename(R),N=D==="AGENTS.override.md";if(!A||A==="."||!N&&D!=="AGENTS.md")return null;let T=A.replace(/\//g,"-");if(!Gm(A))return await Ke(join(h,`${T}.md`)),null;let rt=join(h,`${T}.md`),{frontmatter:z,body:Y}=L(_(rt));return {destPath:rt,toPath:`${bn}/${T}.md`,feature:"rules",content:await G(rt,{...z,root:false,globs:[`${A}/**`],...N?{codex_instruction:"override"}:{}},Y)}},"mapEntry")}));}async function jj(t,e,r,o){try{let i=(await F(join(t,Di))).filter(c=>c.endsWith(".md")),a=join(t,Di);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}=L(o(m,c,p));await k(e);let g=u.root===!0?u:{...u,root:!1},h=await G(p,g,f);await I(p,h),r.push({fromTool:Jt,fromPath:c,toPath:`${bn}/${l}`,feature:"rules"});}}catch{}}var Ek=d(()=>{w();v();ot();Ha();Ce();ya();re();Sk();kp();s(Ck,"importCodexRules");s(jj,"importInstructionMirrors");});async function wp(t,e){let r=e?.scope??"project",o=[],n=await W(Jt,t,r),i=await W("windsurf",t,r);return await Ck(t,o,n,i,r),await uk(t,o,n),await fk(t,o,n),await mk(t,o),o}var jg=d(()=>{gt();re();pk();dk();gk();Ek();s(wp,"importFromCodex");});function Ok(t,e,r){let{rules:o}=t;return o.length===0?[]:o.some(i=>i.root)?[]:[{level:"warning",file:relative(e,o[0].source),target:Jt,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var kk=d(()=>{re();s(Ok,"lintRules");});function Lk(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers))if(typeof o.description=="string"&&o.description&&e.push(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 o||"type"in o){let n="type"in o?o.type:"url";e.push(U(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${n} transport; codex-cli only generates stdio MCP servers.`));}return e}var Ak=d(()=>{bt();s(Lk,"lintMcp");});function wk(t){return xl(t)}var bk=d(()=>{kp();s(wk,"codexAdvisoryInstructionPath");});var Wj,Kj,Bj,Hj,xk,Pk=d(()=>{lk();re();jg();kk();Ak();It();ua();bk();Ut();Wj={name:"codex-cli",primaryRootInstructionPath:wn,generateRules:Pg,generateCommands:Fg,generateAgents:vg,generateSkills:Dg,generateMcp:Mg,importFrom:wp},Kj={rootInstructionPath:wn,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Po}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return wk(e)},commandPath(t,e){return pa(e,"codex-cli")?`${Wr}/${Z(t)}/SKILL.md`:null},agentPath(t,e){return `${Fi}/${t}.toml`}}},Bj={rootInstructionPath:Ni,renderPrimaryRootInstruction:Ng,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Po}/${e}.rules`]},skillDir:Wr,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Ni,".codex/config.toml"]},rewriteGeneratedPath(t){return t===wn?Ni:t.startsWith(`${Di}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${Po}/${t}.rules`:Ni},commandPath(t,e){return pa(e,"codex-cli")?`${Wr}/${Z(t)}/SKILL.md`:null},agentPath(t,e){return `${Fi}/${t}.toml`}}},Hj={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},xk={id:"codex-cli",generators:Wj,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:Ok,lint:{mcp:Lk},project:Kj,globalSupport:{capabilities:Hj,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:Bj},buildImportPaths:vf,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function Vj(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"&&e.length>0):typeof t=="string"&&t.length>0?t.split(",").map(e=>e.trim()).filter(Boolean):[]}function Nk(t){return `${mo}/${t}.md`}function Dk(t){let e={description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],x(e,t.body.trim()||"")}function Fk(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:Vj(t["x-agentsmesh-allowed-tools"])}}function vk(t,e){let r={description:t.description||void 0,"allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return r.description===void 0&&delete r.description,r["allowed-tools"]===void 0&&delete r["allowed-tools"],x(r,e.trim()||"")}var bp=d(()=>{v();po();s(Vj,"toStringArray");s(Nk,"continueCommandRulePath");s(Dk,"serializeCommandRule");s(Fk,"parseCommandRuleFrontmatter");s(vk,"serializeImportedCommand");});function Mk(t){let e=[],r=t.rules.find(o=>o.root);if(r){let o={};r.description&&(o.description=r.description),e.push({path:mn,content:x(o,r.body.trim()||"")});}for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("continue"))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs),e.push({path:`${Ar}/${n}.md`,content:x(i,o.body.trim()||"")});}return e}function Gk(t){return t.commands.map(e=>({path:`${mo}/${e.name}.md`,content:Dk(e)}))}function $k(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Jm,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function jk(t){return t.agents.map(e=>({path:`${ke}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function Uk(t){return dt(t,ke)}var Wk=d(()=>{ct();ft();v();bp();po();s(Mk,"generateRules");s(Gk,"generateCommands");s($k,"generateMcp");s(jk,"generateAgents");s(Uk,"generateSkills");});function Zj(t,e){let o=(e===".json"?JSON.parse(t):parse(t)??{}).mcpServers;if(!o||typeof o!="object"||Array.isArray(o))return {};let n={};for(let[i,a]of Object.entries(o)){if(!a||typeof a!="object"||Array.isArray(a))continue;let c=a;typeof c.command=="string"&&(n[i]={type:typeof c.type=="string"?c.type:"stdio",command:c.command,args:Bn(c.args),env:ro(c.env),description:typeof c.description=="string"?c.description:void 0});}return n}async function Qj(t,e){let r=(await F(join(t,Mf))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),o={},n=[];for(let i of r){let a=await y(i);a&&(Object.assign(o,Zj(a,extname(i))),n.push(i));}if(Object.keys(o).length!==0){await Kt(t,$f,o);for(let i of n)e.push({fromTool:Ra,fromPath:i,toPath:$f,feature:"mcp"});}}async function Tp(t){let e=[],r=await W(Ra,t);return e.push(...await J(xp,t,"project",{normalize:r})),await st(t,ke,Ra,e,r),await Qj(t,e),e}var Ug=d(()=>{gt();w();ct();wt();eo();Je();po();Wg();s(Zj,"readMcpServers");s(Qj,"importMcp");s(Tp,"importFromContinue");});function qj(t){return t==="general.md"||t==="_root.md"}var Bk,Hk,zk=d(()=>{v();ot();bp();po();s(qj,"isContinueRootRulePath");Bk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=qj(t),n=o?"_root.md":t,i=join(r,n),{frontmatter:a,body:c}=L(e(i)),l={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:o};return l.description===void 0&&delete l.description,l.globs===void 0&&delete l.globs,{destPath:i,toPath:`${Ym}/${n}`,content:await G(i,l,c)}},"continueRuleMapper"),Hk=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:o})=>{let n=join(o,e),{frontmatter:i,body:a}=L(r(n)),c=Fk(i,t),l=c.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${l}.md`:`${l}.md`,u=join(o,p),f=await mt(u,{description:c.description,hasDescription:!!c.description,allowedTools:c.allowedTools,hasAllowedTools:c.allowedTools.length>0},L(vk(c,a)).body);return {destPath:u,toPath:`${Xm}/${p}`,content:f}},"continueCommandMapper");});function Vk(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Ra}))}var Jk=d(()=>{At();po();s(Vk,"lintRules");});function Yk(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 Xk=d(()=>{bt();s(Yk,"lintCommands");});function oU(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var Zk,Qk=d(()=>{w();po();s(oU,"computeStatus");Zk=s(async(t,e,r,o)=>{if(r!=="global")return [];let n=o.has("rules"),i=o.has("commands"),a=o.has("mcp");if(!(n&&t.rules.length>0||i&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let l={name:"agentsmesh",version:1,schema:"v1"};if(n&&t.rules.length>0&&(l.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(l.prompts=t.commands.map(u=>{let 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,il));return [{target:"continue",path:il,content:m,currentContent:p??void 0,status:oU(p,m)}]},"generateContinueGlobalConfig");});function sU(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var qk,tL=d(()=>{w();po();Qk();s(sU,"computeStatus");qk=s(async(t,e,r,o)=>{let n=await Zk(t,e,r,o);if(r!=="global"||!o.has("rules"))return n;let i=t.rules.find(l=>l.root);if(!i)return n;let a=i.body.trim(),c=await y(join(e,Ca));return [...n,{target:"continue",path:Ca,content:a,currentContent:c??void 0,status:sU(c,a)}]},"generateContinueScopeExtras");});var iU,aU,cU,lU,xp,Wg=d(()=>{ft();Wk();po();Ug();zk();Jk();Xk();bp();It();tL();iU={name:"continue",primaryRootInstructionPath:mn,generateRules:Mk,generateCommands:Gk,generateAgents:jk,generateSkills:Uk,generateMcp:$k,importFrom:Tp},aU={rootInstructionPath:mn,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Ar}/${t}.md`},commandPath(t,e){return Nk(t)},agentPath(t){return `${ke}/${B(t)}/SKILL.md`}}},cU={rootInstructionPath:mn,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Ca]}],skillDir:ke,managedOutputs:{dirs:[Ar,mo,ke,".agents/skills"],files:[Jm,Ca,il]},mirrorGlobalPath(t,e){return t.startsWith(`${ke}/`)?`.agents/skills/${t.slice(ke.length+1)}`:null},paths:{rulePath(t,e){return `${Ar}/${t}.md`},commandPath(t,e){return `${mo}/${t}.md`},agentPath(t){return `${ke}/${B(t)}/SKILL.md`}}},lU={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},xp={id:"continue",generators:iU,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:Vk,lint:{commands:Yk},project:aU,globalSupport:{capabilities:lU,detectionPaths:[Ar,mo,".continue/mcpServers",ke],layout:cU,scopeExtras:qk},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Ar],global:[Ar]},canonicalDir:Ym,extensions:[".md"],map:Bk},commands:{feature:"commands",mode:"directory",source:{project:[mo],global:[mo]},canonicalDir:Xm,extensions:[".md"],map:Hk}},buildImportPaths:jf,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var Tn,vi,eL,Mi,Es,Do,Fo,Gi,$i,Pp,Np,rL,Bg,oL,Os,Ya,xn,Xa,ji,Hg,zg,lr=d(()=>{Tn="copilot",vi=".github/copilot-instructions.md",eL=".github/copilot",Mi=".github/instructions",Es=".github/prompts",Do=".github/hooks",Fo=".github/skills",Gi=".github/agents",$i=".agentsmesh/rules",Pp=".agentsmesh/commands",Np=".agentsmesh/agents",rL=".agentsmesh/skills",Bg=".agentsmesh/hooks.yaml",oL=".github/copilot-hooks",Os=".copilot/copilot-instructions.md",Ya=".copilot/agents",xn=".copilot/skills",Xa=".copilot/prompts",ji=".copilot/AGENTS.md",Hg=".claude/skills",zg=".agents/skills";});function nL(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 Dp(t){return `${Es}/${t}.prompt.md`}function sL(t){let e={agent:"agent",description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],x(e,t.body.trim()||"")}function iL(t,e){let o=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),n=nL(t["x-agentsmesh-allowed-tools"]),i=n.length>0?n:nL(t.tools);return {name:o,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var Fp=d(()=>{v();lr();s(nL,"toStringArray");s(Dp,"commandPromptPath");s(sL,"serializeCommandPrompt");s(iL,"parseCommandPromptFrontmatter");});function vp(t){return Vo(t)}var Vg=d(()=>{Sr();s(vp,"hasHookCommand");});function uU(t){let e=basename(t,".md");return e==="_root"?"root":e}function dU(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function aL(t){let e=[],r=t.rules.find(o=>o.root);r?.body.trim()&&e.push(r.body.trim());for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("copilot"))continue;let n=o.body.trim();if(!n)continue;let i=o.description?`## ${o.description}`:null;i?e.push(`${i}
|
|
94
98
|
|
|
95
|
-
${
|
|
99
|
+
${n}`):e.push(n);}return e.join(`
|
|
96
100
|
|
|
97
|
-
`)}function
|
|
98
|
-
`)}async function
|
|
99
|
-
`,`set -
|
|
101
|
+
`)}function cL(t){let e=t.rules.find(o=>o.root),r=[];e&&r.push({path:vi,content:e.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("copilot")||o.globs.length===0)continue;let n=uU(o.source),i={description:o.description||void 0,applyTo:o.globs.length===1?o.globs[0]:o.globs};Object.keys(i).forEach(c=>{i[c]===void 0&&delete i[c];});let a=x(i,o.body.trim()||"");r.push({path:`${Mi}/${n}.instructions.md`,content:a});}return r}function lL(t){return t.commands.map(e=>({path:Dp(e.name),content:sL(e)}))}function mL(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=x(o,r.body.trim()||"");e.push({path:`${Fo}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Fo}/${r.name}/${a}`,content:i.content});}}return e}function pL(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0,"mcp-servers":e.mcpServers.length>0?e.mcpServers:void 0,skills:e.skills.length>0?e.skills:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=x(r,e.body.trim()||"");return {path:`${Gi}/${e.name}.agent.md`,content:o}})}function uL(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,o])=>{let n=dU(r);if(!n||!Array.isArray(o))return [];let i=o.filter(a=>typeof a=="object"&&a!==null&&vp(a)).map((a,c)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${c}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[n,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${Do}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var dL=d(()=>{v();lr();Fp();Vg();s(uU,"ruleSlug");s(dU,"mapHookEvent");s(aL,"renderCopilotGlobalInstructions");s(cL,"generateRules");s(lL,"generateCommands");s(mL,"generateSkills");s(pL,"generateAgents");s(uL,"generateHooks");});function gU(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function hU(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function hL(t){let e=t.match(/^# agentsmesh-command:\s*(.+)$/m);return e?.[1]?e[1].trim():t.replace(/^#!.*\n/,"").replace(/^#.*\n/gm,"").replace(/^HOOK_DIR=.*\n/gm,"").replace(/^set -e[u]?\n?/m,"").trim()}async function yL(t,e){let r=join(t,Do),n=(await F(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of n){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 C=gU(g);if(!(!C||!Array.isArray(h)))for(let R of h){if(!R||typeof R!="object")continue;let _=R,A=typeof _.bash=="string"?_.bash:"";if(!A)continue;let D=join(r,A.replace(/^\.\//,"")),N=await y(D);if(!N)continue;let T=hL(N);T&&(i[C]||(i[C]=[]),i[C].push({matcher:hU(_.comment),command:T,type:"command"}));}}}let a=join(t,oL),l=(await F(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:hL(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Bg);await k(dirname(m)),await I(m,stringify(i)),e.push({fromTool:Tn,fromPath:join(t,Do),toPath:Bg,feature:"hooks"});}var _L=d(()=>{w();lr();s(gU,"mapCopilotHookEvent");s(hU,"extractMatcher");s(hL,"extractWrapperCommand");s(yL,"importHooks");});async function IL(t,e,r,o=Fo){let n=join(t,o),i=await Cs(n),a={projectRoot:t,sourceSkillsDir:o,destCanonicalSkillsDir:rL,targetName:Tn,normalize:r,results:e};for(let[c,l]of i)await xo(c,l,a);}var SL=d(()=>{Va();lr();s(IL,"importSkills");});async function Mp(t,e={}){let r=e.scope??"project",o=[],n=await W(Tn,t,r);return o.push(...await J(Gp,t,r,{normalize:n})),await IL(t,o,n,r==="global"?xn:Fo),r==="project"&&await yL(t,o),o}var Jg=d(()=>{gt();wt();lr();_L();SL();Yg();s(Mp,"importFromCopilot");});function RL(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var CL,EL,OL,kL,LL=d(()=>{v();ot();Je();Fp();lr();s(RL,"pruneUndefined");CL=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=t.replace(/\.instructions\.md$/i,".md"),n=join(r,o),{frontmatter:i,body:a}=L(e(n)),c=Zo(i.globs),l=RL({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:n,toPath:`${$i}/${o}`,content:await G(n,l,a)}},"copilotLegacyRuleMapper"),EL=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=t.endsWith(".instructions.md")?t.replace(/\.instructions\.md$/i,".md"):t,n=join(r,o),{frontmatter:i,body:a}=L(e(n)),c=Zo(i.applyTo!==void 0?i.applyTo:i.globs),l=RL({root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0});return {destPath:n,toPath:`${$i}/${o}`,content:await G(n,l,a)}},"copilotNewRuleMapper"),OL=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:o})=>{let n=e.replace(/\.prompt\.md$/i,".md"),i=join(o,n),{frontmatter:a,body:c}=L(r(i)),l=iL(a,t),m=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",p=`${l.name}.md`,u=m?`${m}/${p}`:p,f=join(o,u);return {destPath:f,toPath:`${Pp}/${u}`,content:await mt(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"),kL=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(!t.endsWith(".agent.md"))return null;let o=t.replace(/\.agent\.md$/i,".md"),n=basename(o,".md"),i=join(r,o),{frontmatter:a,body:c}=L(e(i));return {destPath:i,toPath:`${Np}/${o}`,content:await Mt(i,{...a,name:typeof a.name=="string"?a.name:n},c)}},"copilotAgentMapper");});function AL(t,e,r,o){let i=V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(c=>({...c,target:Tn})),a=t.rules.filter(c=>!c.root&&c.globs.length===0);return [...i,...a.map(c=>({level:"warning",file:c.source,target:Tn,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var wL=d(()=>{At();lr();s(AL,"lintRules");});function bL(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 TL(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification","UserPromptSubmit"],r=new Set(e),o=Object.keys(t.hooks).filter(i=>!r.has(i)).map(i=>zn(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&o.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.")),o}var xL=d(()=>{bt();s(bL,"lintCommands");s(TL,"lintHooks");});function RU(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function CU(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function EU(t,e){let r=t.match(NL);if(!r?.groups)return t;let o=r.groups.prefix??"",n=r.groups.suffix??"";return `${o}"$HOOK_DIR/${e}"${n}`}async function OU(t,e){let o=e.match(NL)?.groups?.path;if(!o)return null;let n=join(t,o),i=await y(n);if(i===null)return null;let a=CU(t,n);return a?{assetPath:`${Do}/scripts/${a}`,content:i,rewrittenCommand:EU(e,a)}:null}function kU(t,e){return `${Do}/scripts/${RU(t)}-${e}.sh`}function PL(t){return t.replace(/[\r\n]+/g," ")}function LU(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${PL(e)}`,`# agentsmesh-command: ${PL(t)}`,"set -eu",t,""].join(`
|
|
102
|
+
`)}async function DL(t,e,r){if(!e.hooks)return r;let o=[],n=new Map;for(let[i,a]of Object.entries(e.hooks)){if(!Array.isArray(a))continue;let c=0;for(let l of a){if(!vp(l))continue;let m=kU(i,c),p=l.command,u=await OU(t,l.command);u&&(p=u.rewrittenCommand,n.has(u.assetPath)||n.set(u.assetPath,{path:u.assetPath,content:u.content}));let f=LU(p,l.matcher).replace(`set -eu
|
|
103
|
+
`,`set -eu
|
|
100
104
|
HOOK_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
101
|
-
`);
|
|
105
|
+
`);o.push({path:m,content:f}),c++;}}return [...r,...o,...n.values()]}var NL,FL=d(()=>{w();lr();Vg();NL=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(RU,"safePhaseName");s(CU,"toRepoRelative");s(EU,"rewriteWrapperCommand");s(OU,"buildAssetOutput");s(kU,"wrapperPath");s(PL,"safeShellLine");s(LU,"buildWrapper");s(DL,"addHookScriptAssets");});function wU(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var vL,ML=d(()=>{w();lr();s(wU,"computeStatus");vL=s(async(t,e,r,o)=>{if(r!=="global"||!o.has("rules"))return [];let n=t.rules.find(c=>c.root);if(!n)return [];let i=n.body.trim(),a=await y(join(e,ji));return [{target:"copilot",path:ji,content:i,currentContent:a??void 0,status:wU(a,i)}]},"generateCopilotGlobalExtras");});var TU,xU,PU,NU,Gp,Yg=d(()=>{dL();lr();Jg();LL();wL();It();Fp();xL();FL();ML();TU={name:"copilot",primaryRootInstructionPath:vi,generateRules:cL,generateCommands:lL,generateAgents:pL,generateSkills:mL,generateHooks:uL,importFrom:Mp},xU={rootInstructionPath:vi,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 [`${Mi}/${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 `${Mi}/${t}.instructions.md`},commandPath(t,e){return Dp(t)},agentPath(t,e){return `${Gi}/${t}.agent.md`}}},PU={rootInstructionPath:Os,renderPrimaryRootInstruction:aL,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[ji]}],skillDir:xn,managedOutputs:{dirs:[Ya,xn,Xa,zg,Hg],files:[Os,ji]},rewriteGeneratedPath(t){return t===vi?Os:t.startsWith(`${Mi}/`)?Os:t.startsWith(`${Es}/`)?t.replace(`${Es}/`,`${Xa}/`):t.startsWith(`${Gi}/`)?t.replace(`${Gi}/`,`${Ya}/`):t.startsWith(`${Fo}/`)?t.replace(`${Fo}/`,`${xn}/`):t.startsWith(`${Do}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${xn}/`)&&!e.includes("codex-cli")){let r=t.slice(xn.length+1);return [`.agents/skills/${r}`,`${Hg}/${r}`]}return null},paths:{rulePath(t,e){return Os},commandPath(t,e){return `${Xa}/${t}.prompt.md`},agentPath(t,e){return `${Ya}/${t}.agent.md`}}},NU={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Gp={id:"copilot",generators:TU,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:AL,lint:{commands:bL,hooks:TL},postProcessHookOutputs:s(async(t,e,r)=>DL(t,e,[...r]),"postProcessHookOutputs"),project:xU,globalSupport:{capabilities:NU,detectionPaths:[Os,ji,Ya,xn,Xa,zg],layout:PU,scopeExtras:vL},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[vi],global:[Os]},canonicalDir:$i,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[eL]},canonicalDir:$i,extensions:[".instructions.md"],map:CL},{feature:"rules",mode:"directory",source:{project:[Mi]},canonicalDir:$i,extensions:[".instructions.md",".md"],map:EL}],commands:{feature:"commands",mode:"directory",source:{project:[Es],global:[Xa]},canonicalDir:Pp,extensions:[".prompt.md"],map:OL},agents:{feature:"agents",mode:"directory",source:{project:[Gi],global:[Ya]},canonicalDir:Np,extensions:[".agent.md"],map:kL}},buildImportPaths:Uf,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function $p(t){return {$schema:"https://charm.land/crush.json",...t}}var GL=d(()=>{s($p,"buildCrushConfigJson");});function $L(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(qe)),o=e?.body.trim()??"",n=Lt(o,r);return n?[{path:tr,content:n}]:[]}function jL(t){return dt(t,Vt)}function UL(t){return t.commands.map(e=>({path:`${Vt}/${Z(e.name)}/SKILL.md`,content:de(e)}))}function WL(t){return t.agents.map(e=>({path:`${Vt}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function KL(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=$p({mcp:t.mcp.mcpServers});return [{path:Le,content:JSON.stringify(e,null,2)}]}function BL(t){if(!t.hooks)return [];let e=DU(t);if(Object.keys(e).length===0)return [];let r=$p({hooks:e});return [{path:Le,content:JSON.stringify(r,null,2)}]}function HL(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];if(e.length===0&&r.length===0&&o.length===0)return [];let n={};e.length>0&&(n.allowed_tools=e),r.length>0&&(n.denied_tools=r);let i=$p({permissions:n});return [{path:Le,content:JSON.stringify(i,null,2)}]}function zL(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
106
|
+
`);return [{path:pn,content:e}]}function DU(t){if(!t.hooks)return {};let e={};for(let[r,o]of Object.entries(t.hooks)){if(!Array.isArray(o))continue;let n=[];for(let i of o){let a=typeof i.command=="string"?i.command.trim():"";if(!a)continue;let c={matcher:i.matcher,command:a};i.timeout!==void 0&&(c.timeout=i.timeout),n.push(c);}n.length>0&&(e[r]=n);}return e}var VL=d(()=>{ct();fe();ft();Ut();Ea();GL();s($L,"generateRules");s(jL,"generateSkills");s(UL,"generateCommands");s(WL,"generateAgents");s(KL,"generateMcp");s(BL,"generateHooks");s(HL,"generatePermissions");s(zL,"generateIgnore");s(DU,"buildCrushHooksFromCanonical");});async function YL(t,e={}){let r=e.scope??"project",o=[],n=await W(qe,t,r);return o.push(...await J(jp,t,r,{normalize:n})),await st(t,r==="global"?Ae:Vt,qe,o,n),await FU(t,o),o}async function FU(t,e){let r=join(t,Le),o=await y(r);if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||Array.isArray(n))return;let i=n,a=vU(i.mcp);if(Object.keys(a).length>0){let l=ep,m=join(t,l);await k(dirname(m)),await I(m,JSON.stringify({mcpServers:a},null,2)),e.push({fromTool:qe,fromPath:r,toPath:l,feature:"mcp"});}let c=MU(i.hooks);if(c!==null&&Object.keys(c).length>0){let l=".agentsmesh/hooks.yaml",m=join(t,l);await k(dirname(m));let p=GU(c);await I(m,p),e.push({fromTool:qe,fromPath:r,toPath:l,feature:"hooks"});}}function vU(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t)){if(!o||typeof o!="object"||Array.isArray(o))continue;let n=o,i=typeof n.description=="string"?n.description:void 0;if(typeof n.command=="string"){e[r]={type:typeof n.type=="string"?n.type:"stdio",command:n.command,args:Bn(n.args),env:ro(n.env),...i!==void 0?{description:i}:{}};continue}typeof n.url=="string"&&(e[r]={type:typeof n.type=="string"?n.type:"http",url:n.url,headers:ro(n.headers),env:ro(n.env),...i!==void 0?{description:i}:{}});}return e}function MU(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=typeof a.command=="string"?a.command.trim():"";if(!c)continue;let m={matcher:typeof a.matcher=="string"?a.matcher:"",command:c};typeof a.timeout=="number"&&(m.timeout=a.timeout),n.push(m);}n.length>0&&(e[r]=n);}return Object.keys(e).length>0?e:null}function GU(t){let e=[];for(let[r,o]of Object.entries(t)){e.push(`${r}:`);for(let n of o)e.push(` - matcher: ${JSON.stringify(n.matcher)}`),e.push(` command: ${JSON.stringify(n.command)}`),n.timeout!==void 0&&e.push(` timeout: ${n.timeout}`);}return e.join(`
|
|
107
|
+
`)}var XL=d(()=>{gt();ct();wt();w();Je();Zg();Ea();s(YL,"importFromCrush");s(FU,"importCrushConfigJson");s(vU,"parseCrushMcpServers");s(MU,"parseCrushHooks");s(GU,"serializeHooksYaml");});function ZL(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:qe}))}var QL=d(()=>{At();Ea();s(ZL,"lintRules");});function qL(t){return t.commands.length===0?[]:[U(".agentsmesh/commands","crush","Crush has no native slash-command format; commands are projected as skills via supportsConversion.")]}var tA=d(()=>{bt();s(qL,"lintCommands");});function Qg(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function rA(t,e){let r=Qg(t),o=jU.parse(JSON.parse(e)),n={...r};o.permissions!==void 0&&(n.permissions=o.permissions),o.hooks!==void 0&&(n.hooks=o.hooks);let i=n.permissions;return i&&typeof i=="object"&&!Array.isArray(i)&&!("ask"in i)&&(i.ask=[]),JSON.stringify(n,null,2)}function oA(t,e){let r=Qg(t),o=UU.parse(JSON.parse(e)),n={...r};return o.mcpServers!==void 0&&(n.mcpServers=o.mcpServers),o.hooks!==void 0&&(n.hooks=o.hooks),o.experimental!==void 0&&(n.experimental=o.experimental),o.context!==void 0&&(n.context=o.context),JSON.stringify(n,null,2)}function nA(t,e){let r=Qg(t),o=$U.parse(JSON.parse(e)),n={...r};return o.$schema!==void 0&&(n.$schema=o.$schema),o.mcp!==void 0&&(n.mcp=o.mcp),o.hooks!==void 0&&(n.hooks=o.hooks),o.permissions!==void 0&&(n.permissions=o.permissions),o.options!==void 0&&(n.options=o.options),JSON.stringify(n,null,2)}var eA,$U,jU,UU,Up=d(()=>{eA=[".claude/settings.json",".gemini/settings.json"],$U=z.object({$schema:z.string().optional(),mcp:z.record(z.string(),z.unknown()).optional(),hooks:z.record(z.string(),z.unknown()).optional(),permissions:z.record(z.string(),z.unknown()).optional(),options:z.record(z.string(),z.unknown()).optional()}).passthrough(),jU=z.object({permissions:z.object({allow:z.array(z.string()).optional(),deny:z.array(z.string()).optional()}).passthrough().optional(),hooks:z.record(z.string(),z.unknown()).optional()}).passthrough(),UU=z.object({mcpServers:z.record(z.string(),z.unknown()).optional(),hooks:z.record(z.string(),z.unknown()).optional(),experimental:z.record(z.string(),z.unknown()).optional(),context:z.record(z.string(),z.unknown()).optional()}).passthrough();s(Qg,"parseJsonObject");s(rA,"mergeSettingsJson");s(oA,"mergeGeminiSettingsJson");s(nA,"mergeCrushConfigJson");});var WU,KU,BU,HU,zU,jp,Zg=d(()=>{Ut();ft();VL();le();XL();QL();tA();It();Up();Ea();WU={name:qe,primaryRootInstructionPath:tr,generateRules:$L,generateCommands:UL,generateAgents:WL,generateSkills:jL,generateMcp:KL,generateHooks:BL,generatePermissions:HL,generateIgnore:zL,importFrom:YL},KU={rootInstructionPath:tr,skillDir:Vt,managedOutputs:{dirs:[Vt],files:[tr,Le,pn]},paths:{rulePath(t){return tr},commandPath(t){return `${Vt}/${Z(t)}/SKILL.md`},agentPath(t){return `${Vt}/${B(t)}/SKILL.md`}}},BU={rootInstructionPath:ai,skillDir:Ae,managedOutputs:{dirs:[Ae],files:[ai,Qm]},rewriteGeneratedPath(t){return t===tr?ai:t===Le?Qm:t===pn?null:t.startsWith(`${Vt}/`)?t.replace(`${Vt}/`,`${Ae}/`):t},mirrorGlobalPath(t,e){return ut(t,Ae,e)},paths:{rulePath(t){return ai},commandPath(t){return `${Ae}/${Z(t)}/SKILL.md`},agentPath(t){return `${Ae}/${B(t)}/SKILL.md`}}},HU={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"partial"},zU={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"native",ignore:"none",permissions:"none"},jp={id:qe,generators:WU,capabilities:HU,emptyImportMessage:"No Crush config found (CRUSH.md, .crush/skills/, crush.json, or .crushignore).",lintRules:ZL,lint:{commands:qL},supportsConversion:{commands:true,agents:true},project:KU,globalSupport:{capabilities:zU,detectionPaths:[ai,Qm,Ae],layout:BU},mergeGeneratedOutputContent(t,e,r,o){let n=e?.content??t;return n!==null&&o===Le?nA(n,r):null},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[tr],global:[ai]},canonicalDir:qm,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[pn]},canonicalDir:".agentsmesh",canonicalFilename:tp}},buildImportPaths:Wf,detectionPaths:[tr,Le,Vt,pn],sharedArtifacts:{".crush/skills/":"owner"}};});function qg(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:Qn,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let c=x(a,i);e.push({path:un,content:c});}let o=t.rules.filter(i=>!i.root&&(i.targets.length===0||i.targets.includes("cursor")));for(let i of o){let a=basename(i.source,".md"),l={alwaysApply:i.trigger==="always_on"};i.description&&(l.description=i.description),i.globs.length>0&&(l.globs=i.globs);let m=x(l,i.body.trim()||"");e.push({path:`${er}/${a}.mdc`,content:m});}let n=sA(t);return n.trim()&&e.push({path:br,content:n}),e}function sA(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes("cursor"))),o=[];return e?.body.trim()?o.push(Lt(e.body,r)):r.length>0&&o.push(Lt("",r)),o.filter(Boolean).join(`
|
|
102
108
|
|
|
103
|
-
`)}var
|
|
104
|
-
`);return [{path:
|
|
109
|
+
`)}var iA=d(()=>{v();fe();Nt();s(qg,"generateRules");s(sA,"renderCursorGlobalUserRules");});function th(t){return t.commands.map(e=>({path:`${rr}/${e.name}.md`,content:e.body.trim()||""}))}var aA=d(()=>{Nt();s(th,"generateCommands");});function eh(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:fo,content:e}]}var cA=d(()=>{Nt();s(eh,"generateMcp");});function rh(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=x(o,r.body.trim()||"");e.push({path:`${uo}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${uo}/${r.name}/${a}`,content:i.content});}}return e}var lA=d(()=>{v();Nt();s(rh,"generateSkills");});function oh(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=x(r,e.body.trim()||"");return {path:`${Oa}/${e.name}.md`,content:o}})}var mA=d(()=>{v();Nt();s(oh,"generateAgents");});function nh(t){return []}var pA=d(()=>{s(nh,"generatePermissions");});function JU(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!Zr(i))continue;let a=vt(i),c=ne(i),l=i.type==="prompt"?c||a:a||c,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:l};i.timeout!==void 0&&(m.timeout=i.timeout),n.push({matcher:i.matcher,hooks:[m]});}n.length>0&&(e[r]=n);}return e}function sh(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=JU(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:go,content:r}]}var uA=d(()=>{Sr();Nt();s(JU,"toCursorHooks");s(sh,"generateHooks");});function ih(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
110
|
+
`);return [{path:wr,content:e}]}var dA=d(()=>{Nt();s(ih,"generateIgnore");});var fA=d(()=>{iA();aA();cA();lA();mA();pA();uA();dA();});var gA=d(()=>{fA();});async function Kp(t,e,r,o){let n=t.replace(/\.mdc$/i,".md"),i=join(e,n),c=L(r(i)).frontmatter.alwaysApply===true,l=c?join(e,"_root.md"):i,{frontmatter:m,body:p}=L(r(l));c&&o();let u={...m,root:c};if(delete u.alwaysApply,!c){let f=YU(m);f!==null&&(u.trigger=f);}return {destPath:l,toPath:`${ho}/${c?"_root.md":n}`,feature:"rules",content:await G(l,u,p)}}function YU(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 hA(t,e,r){let o=join(e,t),{frontmatter:n,body:i}=L(r(o)),a=Ve(n.allowedTools),c=a.length>0?a:Ve(n["allowed-tools"]);return {destPath:o,toPath:`${es}/${t}`,feature:"commands",content:await mt(o,{description:typeof n.description=="string"?n.description:"",hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}}async function yA(t,e,r){let o=join(e,t),{frontmatter:n,body:i}=L(r(o));return {destPath:o,toPath:`${rs}/${t}`,feature:"agents",content:await Mt(o,n,i)}}var ah=d(()=>{v();ot();Je();Nt();s(Kp,"mapCursorRuleFile");s(YU,"deriveCursorTrigger");s(hA,"mapCursorCommandFile");s(yA,"mapCursorAgentFile");});async function Za(t){let e=join(t.projectRoot,ho);await k(e);let r=join(e,"_root.md"),o=await To({content:t.content,projectRoot:t.projectRoot,rulesDir:ho,sourcePath:t.sourcePath,fromTool:"cursor",normalize:t.normalize});t.results.push(...o.results);let n=t.normalize(o.rootContent,t.sourcePath,r);if(!n.trim()&&o.results.length>0)return true;let{frontmatter:i,body:a}=L(n),c=i.root===true?i:{...i,root:true},l=await G(r,c,a);return await I(r,l),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${ho}/_root.md`,feature:"rules"}),true}var ch=d(()=>{w();v();Ha();ot();Nt();s(Za,"importCursorRootFile");});async function IA(t,e,r){let o=join(t,ho),n=false,i=join(t,er);if(e.push(...await pt({srcDir:i,destDir:o,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:c,normalizeTo:l})=>{if(n){let m=await y(a);if(m!==null){let{frontmatter:p}=L(m);if(p.alwaysApply===true)return null}}return Kp(c,o,l,()=>{n=true;})},"mapEntry")})),!n){let a=join(t,Qn),c=await y(a);c!==null&&(n=await Za({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r}));}if(!n){let a=join(t,VR),c=await y(a);c!==null&&await Za({projectRoot:t,results:e,sourcePath:a,content:c,normalize:r});}}var SA=d(()=>{w();v();Ce();ah();ch();Nt();s(IA,"importCursorRules");});function RA(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!Zr({...m,type:p}))continue;let u=p==="prompt"?ne(m)||vt(m):vt(m)||ne(m),f={matcher:c,type:p,command:u};typeof m.timeout=="number"&&(f.timeout=m.timeout),n.push(f);}}n.length>0&&(e[r]=n);}return e}async function zp(t,e){let r=false,o=join(t,go),n=await y(o);if(n)try{let p=JSON.parse(n);if(p.hooks&&typeof p.hooks=="object"){let u=RA(p.hooks);if(Object.keys(u).length>0){let f=stringify(u),g=join(t,cl);await k(dirname(g)),await I(g,f),e.push({fromTool:"cursor",fromPath:o,toPath:cl,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,rp),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,Bf);await k(dirname(h)),await I(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:Bf,feature:"permissions"});}}let m=r?void 0:c.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=RA(m);if(Object.keys(p).length>0){let u=stringify(p),f=join(t,cl);await k(dirname(f)),await I(f,u),e.push({fromTool:"cursor",fromPath:i,toPath:cl,feature:"hooks"});}}}async function Vp(t,e){let r=[{path:join(t,wr),label:wr},{path:join(t,Kf),label:Kf}],o=[],n=[];for(let a of r){let c=await y(a.path);if(c!==null){n.push(a.label);for(let l of c.split(/\r?\n/)){let m=l.trim();m&&!o.includes(m)&&o.push(m);}}}if(o.length===0)return;let i=join(t,Hf);await k(dirname(i)),await I(i,o.join(`
|
|
105
111
|
`)+`
|
|
106
|
-
`),e.push({fromTool:"cursor",fromPath:join(t,
|
|
112
|
+
`),e.push({fromTool:"cursor",fromPath:join(t,n[0]),toPath:Hf,feature:"ignore"});}var mh=d(()=>{Sr();w();Nt();s(RA,"cursorHooksToCanonical");s(zp,"importSettings");s(Vp,"importIgnore");});async function Jp(t,e,r,o=uo){let n=join(t,o),i=await Cs(n),a={projectRoot:t,sourceSkillsDir:o,destCanonicalSkillsDir:JR,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await xo(p,u,a);let c=await F(n).catch(()=>[]),l=c.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>c.filter(u=>u.startsWith(p))));for(let p of l){if(m.has(p))continue;let u=await y(p);if(!u)continue;let f=basename(p,".md");await NO(f,p,u,a);}}var ph=d(()=>{w();Va();Nt();s(Jp,"importSkills");});async function CA(t){if(await M(join(t,er)))return true;let e=[join(t,br),join(t,ka),join(t,al),join(t,go),join(t,wr),join(t,qn),join(t,ts),join(t,rr)];for(let i of e){let a=await y(i);if(a!==null&&a.trim()!=="")return true}return !!((await F(join(t,qn))).some(i=>i.endsWith(".md"))||(await F(join(t,ts))).some(i=>i.endsWith(".md"))||(await F(join(t,rr))).some(i=>i.endsWith(".md")))}async function EA(t,e,r){let o=join(t,ho),n=false,i=join(t,er),a=await pt({srcDir:i,destDir:o,extensions:[".mdc"],fromTool:Qa,normalize:r,mapEntry:s(async({srcPath:c,relativePath:l,normalizeTo:m})=>{if(n){let p=await y(c);if(p!==null){let{frontmatter:u}=L(p);if(u.alwaysApply===true)return null}}return Kp(l,o,m,()=>{n=true;})},"mapEntry")});return e.push(...a),n}async function OA(t,e,r){let o=join(t,ka),n=await y(o);return n===null||n.trim()===""?false:Za({projectRoot:t,results:e,sourcePath:o,content:n.trim(),normalize:r})}async function kA(t,e,r){let o=join(t,br),n=await y(o);return n===null||n.trim()===""?false:Za({projectRoot:t,results:e,sourcePath:o,content:n.trim(),normalize:r})}async function LA(t,e){let r=join(t,al),o=await y(r);if(o===null||o.trim()==="")return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||!("mcpServers"in n))return;let i=join(t,La);await k(dirname(i)),await I(i,o),e.push({fromTool:Qa,fromPath:r,toPath:La,feature:"mcp"});}async function AA(t,e,r){let o=join(t,ts),n=join(t,rs);e.push(...await pt({srcDir:o,destDir:n,extensions:[".md"],fromTool:Qa,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>yA(i,n,a),"mapEntry")}));}async function wA(t,e,r){let o=join(t,rr),n=join(t,es);e.push(...await pt({srcDir:o,destDir:n,extensions:[".md"],fromTool:Qa,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>hA(i,n,a),"mapEntry")}));}var Qa,bA=d(()=>{w();v();Ce();Nt();ch();ah();Qa="cursor";s(CA,"hasGlobalCursorArtifacts");s(EA,"importGlobalCursorRulesFromDir");s(OA,"importGlobalUserRules");s(kA,"importGlobalDotCursorAgents");s(LA,"importGlobalMcp");s(AA,"importGlobalAgents");s(wA,"importGlobalCommands");});async function TA(t){if(!await CA(t))return [];let e=[],r=await W(Qa,t,"global"),o=await EA(t,e,r);return o||(o=await OA(t,e,r)),o||await kA(t,e,r),await LA(t,e),await Jp(t,e,r,qn),await AA(t,e,r),await wA(t,e,r),await zp(t,e),await Vp(t,e),e}var xA=d(()=>{gt();Nt();ph();mh();bA();s(TA,"importFromCursorGlobalExports");});async function t0(t,e){let r=join(t,fo),o=await y(r);if(!o)return;let n;try{n=JSON.parse(o);}catch{return}if(!n||typeof n!="object"||!("mcpServers"in n))return;let i=n.mcpServers;await Kt(t,La,i),e.push({fromTool:"cursor",fromPath:r,toPath:La,feature:"mcp"});}async function Yp(t,e={}){if(e.scope==="global")return TA(t);let r=[],o=await W("cursor",t);return await IA(t,r,o),r.push(...await J(Xp,t,"project",{normalize:o})),await Jp(t,r,o),await t0(t,r),await zp(t,r),await Vp(t,r),r}var uh=d(()=>{gt();w();wt();eo();SA();mh();ph();xA();Nt();dh();s(t0,"importMcp");s(Yp,"importFromCursor");});var NA,DA,FA=d(()=>{v();ot();Je();Nt();NA=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o)),a=Ve(n.allowedTools),c=a.length>0?a:Ve(n["allowed-tools"]);return {destPath:o,toPath:`${es}/${t}`,content:await mt(o,{description:typeof n.description=="string"?n.description:"",hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),allowedTools:c,hasAllowedTools:Object.prototype.hasOwnProperty.call(n,"allowedTools")||Object.prototype.hasOwnProperty.call(n,"allowed-tools")},i)}},"cursorCommandMapper"),DA=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${rs}/${t}`,content:await Mt(o,n,i)}},"cursorAgentMapper");});function vA(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:zR}))}var MA=d(()=>{At();Nt();s(vA,"lintRules");});function GA(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 $A(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers)){let n=o.env&&Object.keys(o.env).length>0,i="url"in o,a="headers"in o;(n||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 jA(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 UA=d(()=>{bt();s(GA,"lintCommands");s($A,"lintMcp");s(jA,"lintPermissions");});var e0,r0,o0,n0,Xp,dh=d(()=>{gA();Nt();le();uh();FA();MA();It();UA();e0={name:"cursor",primaryRootInstructionPath:un,generateRules:qg,generateCommands:th,generateAgents:oh,generateSkills:rh,generateMcp:eh,generatePermissions:nh,generateHooks:sh,generateIgnore:ih,importFrom:Yp},r0={rootInstructionPath:un,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Qn,br]}],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`}}},o0={rootInstructionPath:un,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[Qn,br]}],skillDir:qn,managedOutputs:{dirs:[er,rr,ts,qn],files:[un,br,al,go,wr,ka]},rewriteGeneratedPath(t){return t===Qn?null:t===br||t===un||t.startsWith(`${er}/`)||t.startsWith(`${rr}/`)||t.startsWith(`${Oa}/`)||t.startsWith(`${uo}/`)||t===fo||t===go||t===wr?t:t===rp?null:t},mirrorGlobalPath(t,e){return ut(t,uo,e)},paths:{rulePath(t,e){return `${er}/${t}.mdc`},commandPath(t,e){return `${rr}/${t}.md`},agentPath(t,e){return `${ts}/${t}.md`}}},n0={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Xp={id:"cursor",generators:e0,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:vA,lint:{commands:GA,mcp:$A,permissions:jA},project:r0,globalSupport:{capabilities:n0,detectionPaths:[un,br,fo,go,wr,uo,ts,rr,ka],layout:o0},importer:{commands:{feature:"commands",mode:"directory",source:{project:[rr]},canonicalDir:es,extensions:[".md"],map:NA},agents:{feature:"agents",mode:"directory",source:{project:[Oa]},canonicalDir:rs,extensions:[".md"],map:DA}},buildImportPaths:zf,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});var ks,mr,vo,WA,KA,Pe,Zp,Ui,Qp,Dl,Ls,BA,HA,As,qp,Fl,vl,fh,gh,qa,hh,tc,ec,tu,rc,Wi,Ml,Gt=d(()=>{ks="gemini-cli",mr="GEMINI.md",vo="AGENTS.md",WA=".gemini/rules",KA=".gemini/GEMINI.md",Pe=".gemini/commands",Zp=".gemini/policies",Ui=".gemini/settings.json",Qp=".geminiignore",Dl=".gemini/skills",Ls=".gemini/agents",BA=".gemini/system.md",HA=`${Zp}/permissions.toml`,As=".agentsmesh/rules",qp=".agentsmesh/commands",Fl=".agentsmesh/agents",vl=".agentsmesh/skills",fh=".agentsmesh/mcp.json",gh=".agentsmesh/hooks.yaml",qa=".agentsmesh/ignore",hh=".agentsmesh/permissions.yaml",tc=".gemini/GEMINI.md",ec=".gemini/AGENTS.md",tu=".gemini/settings.json",rc=".gemini/commands",Wi=".gemini/skills",Ml=".gemini/agents";});function yh(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>!(i.root||i.targets.length>0&&!i.targets.includes("gemini-cli")));if(!e&&r.length===0)return [];let o=Lt(e?.body.trim()??"",r),n=[{path:mr,content:o}];if(e){let i=e.body.trim().replace(/\.agentsmesh\/skills\//g,".agents/skills/");n.push({path:vo,content:i});}return n}var zA=d(()=>{fe();Gt();s(yh,"generateRules");});function VA(t,e){let r=t.split(":").filter(Boolean),o=r.length>0?r.pop():t;return [e,...r,`${o}.toml`].join("/")}var JA=d(()=>{s(VA,"canonicalCommandNameToGeminiTomlPath");});function s0(t){let e=t.replace(/\r\n/g,`
|
|
107
113
|
`);return e.includes('"""')?JSON.stringify(e):`"""
|
|
108
114
|
${e}
|
|
109
|
-
"""`}function
|
|
115
|
+
"""`}function i0(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${s0(t.body.trim()||"")}`].join(`
|
|
110
116
|
`)+`
|
|
111
|
-
`}function
|
|
112
|
-
`)}]}var
|
|
113
|
-
`)}function
|
|
114
|
-
`)}]}var
|
|
117
|
+
`}function _h(t){return t.commands.map(e=>({path:VA(e.name,Pe),content:i0(e)}))}var YA=d(()=>{Gt();JA();s(s0,"serializeTomlMultilineLiteral");s(i0,"serializeGeminiCommand");s(_h,"generateCommands");});function Ih(t){return t.agents.map(e=>{let r={name:e.name,kind:"local",description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,permissionMode:e.permissionMode||void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=x(r,e.body.trim()||"");return {path:`${Ls}/${e.name}.md`,content:o}})}var XA=d(()=>{v();Gt();s(Ih,"generateAgents");});function Sh(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=x(o,r.body.trim()||"");e.push({path:`${Dl}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Dl}/${r.name}/${a}`,content:i.content});}}return e}var ZA=d(()=>{v();Gt();s(Sh,"generateSkills");});function a0(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function Rh(t){let e={},r=false;if(t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&(e.mcpServers=t.mcp.mcpServers,r=true),t.agents.length>0&&(e.experimental={enableAgents:true},r=true),t.hooks){let o=Object.entries(t.hooks).flatMap(([n,i])=>{let a=a0(n);if(!a||!Array.isArray(i))return [];let c=i.filter(l=>typeof l=="object"&&l!==null&&Vo(l)).map((l,m)=>({matcher:l.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:vt(l),timeout:l.timeout}]}));return c.length>0?[[a,c]]:[]});o.length>0&&(e.hooks=Object.fromEntries(o),r=true);}return r&&(e.context={fileName:[mr,vo]}),Object.keys(e).length===0?[]:[{path:Ui,content:JSON.stringify(e,null,2)}]}var Ch=d(()=>{Sr();Gt();s(a0,"mapHookEvent");s(Rh,"generateGeminiSettingsFiles");});function Eh(t){return !t.ignore||t.ignore.length===0?[]:[{path:Qp,content:t.ignore.join(`
|
|
118
|
+
`)}]}var QA=d(()=>{Gt();s(Eh,"generateIgnore");});var qA=d(()=>{zA();YA();XA();ZA();Ch();QA();});var tw=d(()=>{qA();});function Ki(t){return JSON.stringify(t)}function c0(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function l0(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 eu(t,e,r){return ["[[rule]]",`decision = ${Ki(t)}`,`priority = ${e}`,...r,""].join(`
|
|
119
|
+
`)}function ew(t,e,r){let o=l0(t),n={Read:"read_file",Grep:"grep_search",LS:"list_directory",WebFetch:"web_fetch",Bash:"run_shell_command"};if(o.kind==="tool"){let i=n[o.tool]??o.tool;return eu(e,r,[`toolName = ${Ki(i)}`])}if(o.kind==="bash"){let i=o.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return eu(e,r,[`toolName = ${Ki(n.Bash)}`,`commandPrefix = ${Ki(i)}`])}return o.kind==="read"?eu(e,r,[`toolName = ${Ki(n.Read)}`,`argsPattern = ${Ki(c0(o.path))}`]):eu(e,r,[`toolName = ${Ki(o.raw)}`])}function rw(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions;if(e.length+r.length===0)return [];let n=[];return e.forEach((i,a)=>{let c=ew(i,"allow",100+a);c&&n.push(c);}),r.forEach((i,a)=>{let c=ew(i,"deny",200+a);c&&n.push(c);}),n.length===0?[]:[{path:HA,content:n.join(`
|
|
120
|
+
`)}]}var ow=d(()=>{Gt();s(Ki,"escapeTomlBasicString");s(c0,"escapeRegexLiteral");s(l0,"parsePermissionExpr");s(eu,"ruleForDecision");s(ew,"permissionExprToGeminiRule");s(rw,"generateGeminiPermissionsPolicies");});function Oh(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 ru(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return L(t);if(r===0){let o=t.indexOf("+++",3);if(o!==-1)try{let n=t.slice(3,o).trim(),i=t.slice(o+3).trim();return {frontmatter:n===""?{}:parse$1(n)??{},body:i}}catch{return {frontmatter:{},body:t.trim()}}}return {frontmatter:{},body:t.trim()}}var kh=d(()=>{v();s(Oh,"mapGeminiHookEvent");s(ru,"parseFlexibleFrontmatter");});async function Lh(t,e){let r=join(t,Ui),o=await y(r);if(o===null)return;let n;try{n=JSON.parse(o);}catch{}if(!n)return;let i=n.mcpServers;if(i!==void 0&&typeof i=="object"&&i!==null&&Object.keys(i).length>0){let l=join(t,fh);await k(join(t,".agentsmesh")),await I(l,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:fh,feature:"mcp"});}let a=n.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(l=>typeof l=="string")){let l=join(t,qa);await k(join(t,".agentsmesh")),await I(l,a.join(`
|
|
115
121
|
`)+`
|
|
116
|
-
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:
|
|
122
|
+
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:qa,feature:"ignore"});}let c=n.hooks;if(c!==void 0&&typeof c=="object"&&c!==null){let l=Object.entries(c).flatMap(([m,p])=>{let u=Oh(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"&&Vo(h)).map(h=>({matcher:g.matcher,command:vt(h),type:"command",timeout:typeof h.timeout=="number"?h.timeout:void 0})));if(f.length===0){let g=p.filter(h=>h!==null&&typeof h=="object"&&typeof h.matcher=="string"&&Vo(h)).map(h=>({matcher:h.matcher,command:vt(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,gh);await k(join(t,".agentsmesh")),await I(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:gh,feature:"hooks"});}}}var nw=d(()=>{Sr();w();Gt();kh();s(Lh,"importGeminiSettings");});async function sw(t,e){let r=join(t,Qp),o=await y(r);if(o!==null&&o.trim()){let n=o.split(/\r?\n/).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#"));if(n.length>0){await k(join(t,".agentsmesh"));let i=join(t,qa);await I(i,n.join(`
|
|
117
123
|
`)+`
|
|
118
|
-
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:
|
|
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
|
|
121
|
-
`)}]}function
|
|
122
|
-
`)}]}function
|
|
124
|
+
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:qa,feature:"ignore"});}}}var wh=d(()=>{w();Gt();kh();nw();s(sw,"importGeminiIgnore");});function f0(t){return t.replace(/\\(.)/g,"$1")}function g0(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 h0(t){return `Bash(${t}:*)`}function y0(t){return `Read(${f0(t)})`}async function iw(t){let e=[],r=join(t,Zp),o;try{o=await F(r);}catch{return e}let n=o.filter(u=>u.endsWith(".toml"));if(n.length===0)return e;let i=[],a=[],c=new Set,l=new Set;for(let u of n){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 C of h){if(!C||typeof C!="object")continue;let R=C,_=typeof R.toolName=="string"?R.toolName:null,A=typeof R.decision=="string"?R.decision:null;if(!_||!A)continue;let D=g0(_);if(!D)continue;let N=null;D==="Bash"?typeof R.commandPrefix=="string"&&R.commandPrefix.trim()&&(N=h0(R.commandPrefix.trim())):D==="Read"?typeof R.argsPattern=="string"&&R.argsPattern.trim()?N=y0(R.argsPattern.trim()):N="Read":N=D,N&&(A==="allow"?c.has(N)||(c.add(N),i.push(N)):A==="deny"&&(l.has(N)||(l.add(N),a.push(N))));}}if(i.length===0&&a.length===0)return e;await k(join(t,".agentsmesh"));let m=join(t,hh),p=stringify({allow:i,deny:a});return await I(m,p.trimEnd()+`
|
|
125
|
+
`),e.push({fromTool:ks,fromPath:join(t,Zp),toPath:hh,feature:"permissions"}),e}var aw=d(()=>{w();Gt();s(f0,"unescapeRegexLiteral");s(g0,"toolNameToPermissionBase");s(h0,"commandPrefixToBashExpr");s(y0,"argsPatternToReadExpr");s(iw,"importGeminiPolicies");});function bh(t,e){let r=new Set([e,e.replace(/\\/g,"/"),e.replace(/\//g,"\\")]);try{r.add(realpathSync(e)),r.add(realpathSync.native(e));}catch{}return Array.from(r).reduce((n,i)=>{let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n.replace(new RegExp(`${a}[/\\\\]\\.agentsmesh[/\\\\]`,"g"),".agentsmesh/").replaceAll(`${i}/.agentsmesh`,".agentsmesh").replaceAll(`${i}\\.agentsmesh`,".agentsmesh")},t).replace(/(?:[A-Za-z]:)?[^\s"'`()<>]+[/\\]\.agentsmesh[/\\]/g,".agentsmesh/")}var lw=d(()=>{s(bh,"stripProjectRootCanonicalPrefix");});async function pw(t,e,r){let o=join(t,Dl),i=(await F(o)).filter(c=>basename(c)==="SKILL.md");for(let c of i){let l=await y(c);if(!l)continue;let m=basename(c.slice(0,-9)),p=L(l),u=Qr(p.frontmatter,m);if(u){let A=join(t,Fl);await k(A);let D=join(A,`${u.name}.md`);await I(D,We(u,r(p.body,c,D))),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${Fl}/${u.name}.md`,feature:"agents"});continue}let f=join(t,vl,m,"SKILL.md"),g=r(l,c,f),h=join(t,vl,m);await k(h);let{frontmatter:C,body:R}=L(g);await I(f,await qr(f,{...C,name:m},R)),e.push({fromTool:"gemini-cli",fromPath:c,toPath:`${vl}/${m}/SKILL.md`,feature:"skills"});let _=await F(dirname(c));for(let A of _){if(A===c)continue;let D=await y(A);if(D===null)continue;let N=relative(dirname(c),A).replace(/\\/g,"/"),T=join(h,N);await k(dirname(T)),await I(T,r(D,A,T)),e.push({fromTool:"gemini-cli",fromPath:A,toPath:`${vl}/${m}/${N}`,feature:"skills"});}}let a=join(t,Ls);try{let l=(await F(a)).filter(m=>m.endsWith(".md"));for(let m of l){let p=await y(m);if(!p)continue;let{frontmatter:u,body:f}=L(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),C=join(t,Fl);await k(C);let R=join(C,h),_=r(f,m,R);await I(R,await Mt(R,{...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:`${Fl}/${h}`,feature:"agents"});}}catch{}}var uw=d(()=>{w();v();ot();ft();Gt();s(pw,"importGeminiSkillsAndAgents");});async function _0(t,e,r){let o=await W("codex-cli",t),n=join(t,As),i=join(t,vo),a=join(t,KA),c=[i,a,join(t,mr),join(t,BA)],l=null,m=c[c.length-1];for(let N of c){let T=await y(N);if(T!==null){l=T,m=N;break}}if(l===null)return;await k(n);let p=join(n,"_root.md"),u=m===i||m===a?o(l,m,p):l,f=await To({content:u,projectRoot:t,rulesDir:As,sourcePath:m,fromTool:ks,normalize:r});e.push(...f.results);let g=r(f.rootContent,m,p),h=bh(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:C,body:R}=L(h),A=C.root===true?C:{...C,root:true},D=bh(await G(p,A,R),t);await I(p,D),e.push({fromTool:ks,fromPath:m,toPath:`${As}/_root.md`,feature:"rules"});}async function nu(t){let e=[],r=await W(ks,t);return await _0(t,e,r),e.push(...await J(su,t,"project",{normalize:r})),await pw(t,e,r),await Lh(t,e),await sw(t,e),e.push(...await iw(t)),e}var Ph=d(()=>{gt();w();v();ot();Ha();wt();Gt();Nh();wh();aw();lw();uw();s(_0,"importRootRule");s(nu,"importFromGemini");});async function fw(t,e,r){let o=t.replace(/\\/g,"/"),n=join(e,o),{frontmatter:i,body:a}=ru(r(n)),c=Zo(i.globs),l={root:false,description:typeof i.description=="string"?i.description:void 0,globs:c.length>0?c:void 0};return Object.keys(l).forEach(m=>{l[m]===void 0&&delete l[m];}),{destPath:n,toPath:`${As}/${o}`,feature:"rules",content:await G(n,l,a)}}async function gw(t,e,r){let o=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),n=join(e,o),i=r(n),{frontmatter:a,body:c}=t.endsWith(".toml")?S0(i):ru(i),l=Ve(a.allowedTools),m=Ve(a["allowed-tools"]),p=l.length>0?l:m;return {destPath:n,toPath:`${qp}/${o}`,feature:"commands",content:await mt(n,{description:typeof a.description=="string"?a.description:"",hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:p,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"allowedTools")||Object.prototype.hasOwnProperty.call(a,"allowed-tools")},c)}}function S0(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var hw=d(()=>{ot();Je();wh();Gt();s(fw,"mapGeminiRuleFile");s(gw,"mapGeminiCommandFile");s(S0,"parseTomlCommand");});var yw,_w,Iw=d(()=>{hw();yw=s(({relativePath:t,destDir:e,normalizeTo:r})=>fw(t,e,r),"geminiRuleMapper"),_w=s(({relativePath:t,destDir:e,normalizeTo:r})=>gw(t,e,r),"geminiCommandMapper");});function Sw(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(i=>({...i,target:ks}))}var Rw=d(()=>{At();Gt();s(Sw,"lintRules");});function Cw(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 Ew(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification"],r=new Set(e);return Object.keys(t.hooks).filter(o=>!r.has(o)).map(o=>zn(o,"gemini-cli",e))}var Ow=d(()=>{bt();s(Cw,"lintCommands");s(Ew,"lintHooks");});function kw(t,e){return e==="project"&&ws("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:Rh(t)}var Lw=d(()=>{kt();Ch();s(kw,"emitScopedGeminiSettings");});var R0,C0,E0,O0,su,Nh=d(()=>{tw();zs();ow();Gt();Ph();Iw();Rw();It();ua();ft();Ow();Lw();le();Up();R0={name:"gemini-cli",primaryRootInstructionPath:mr,generateRules:yh,generateCommands:_h,generateAgents:Ih,generateSkills:Sh,generateIgnore:Eh,generatePermissions:rw,importFrom:nu},C0={rootInstructionPath:mr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[vo]}],extraRuleOutputPaths(){return [vo]},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 ut(t,".gemini/skills",e)},paths:{rulePath(t,e){return mr},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),o=r.pop()??t;return `${Pe}/${r.join("/")}/${o}.toml`}return `${Pe}/${t}.toml`},agentPath(t,e){return Ue(e,"gemini-cli")?`.gemini/skills/${B(t)}/SKILL.md`:`${Ls}/${t}.md`}}},E0={rootInstructionPath:tc,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[ec]}],extraRuleOutputPaths(){return [ec]},skillDir:Wi,managedOutputs:{dirs:[rc,Wi,Ml],files:[tc,ec,tu]},rewriteGeneratedPath(t){return t===mr?tc:t===vo?ec:t===Ui?tu:t.startsWith(`${Pe}/`)?t.replace(`${Pe}/`,`${rc}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Wi}/`):t.startsWith(`${Ls}/`)?t.replace(`${Ls}/`,`${Ml}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return ut(t,Wi,e)},paths:{rulePath(t,e){return tc},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),o=r.pop()??t;return `${rc}/${r.join("/")}/${o}.toml`}return `${rc}/${t}.toml`},agentPath(t,e){return Ue(e,"gemini-cli")?`${Wi}/${B(t)}/SKILL.md`:`${Ml}/${t}.md`}}},O0={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},su={id:"gemini-cli",generators:R0,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Er("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:Sw,lint:{commands:Cw,hooks:Ew},emitScopedSettings:kw,mergeGeneratedOutputContent(t,e,r,o){let n=e?.content??t;return n!==null&&o===Ui?oA(n,r):null},project:C0,globalSupport:{capabilities:O0,detectionPaths:[tc,ec,tu,rc,Wi,Ml],layout:E0},importer:{rules:{feature:"rules",mode:"directory",source:{project:[WA]},canonicalDir:As,extensions:[".md"],map:yw},commands:{feature:"commands",mode:"directory",source:{project:[Pe]},canonicalDir:qp,extensions:[".md",".toml"],map:_w}},buildImportPaths:Vf,detectionPaths:["GEMINI.md",".gemini"]};});function Aw(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(yo)),o=e?.body.trim()??"",n=Lt(o,r);return n?[{path:or,content:n}]:[]}function ww(t){return dt(t,ie)}function bw(t){return t.commands.map(e=>({path:`${ie}/${Z(e.name)}/SKILL.md`,content:de(e)}))}function Tw(t){return t.agents.map(e=>({path:`${ie}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function xw(t){return t.ignore.length===0?[]:[{path:dn,content:t.ignore.join(`
|
|
126
|
+
`)}]}var Pw=d(()=>{ct();fe();ft();Ut();Aa();s(Aw,"generateRules");s(ww,"generateSkills");s(bw,"generateCommands");s(Tw,"generateAgents");s(xw,"generateIgnore");});async function Nw(t,e={}){let r=e.scope??"project",o=[],n=await W(yo,t,r);return o.push(...await J(iu,t,r,{normalize:n})),await st(t,r==="global"?nr:ie,yo,o,n),o}var Dw=d(()=>{gt();ct();wt();Aa();Dh();s(Nw,"importFromGoose");});function Fw(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:yo}))}var vw=d(()=>{At();Aa();s(Fw,"lintRules");});function Mw(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 Gw(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[U(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function $w(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 jw=d(()=>{bt();s(Mw,"lintHooks");s(Gw,"lintPermissions");s($w,"lintMcp");});var k0,L0,A0,Uw,iu,Dh=d(()=>{Ut();ft();Pw();le();Dw();vw();jw();It();Aa();k0={name:yo,primaryRootInstructionPath:or,generateRules:Aw,generateCommands:bw,generateAgents:Tw,generateSkills:ww,generateIgnore:xw,importFrom:Nw},L0={rootInstructionPath:or,skillDir:ie,managedOutputs:{dirs:[ie],files:[or,dn]},paths:{rulePath(t){return or},commandPath(t){return `${ie}/${Z(t)}/SKILL.md`},agentPath(t){return `${ie}/${B(t)}/SKILL.md`}}},A0={rootInstructionPath:fn,skillDir:nr,managedOutputs:{dirs:[nr],files:[fn,ci]},rewriteGeneratedPath(t){return t===or?fn:t===dn?ci:(t.startsWith(`${ie}/`),t)},mirrorGlobalPath(t,e){return ut(t,nr,e)},paths:{rulePath(t){return fn},commandPath(t){return `${nr}/${Z(t)}/SKILL.md`},agentPath(t){return `${nr}/${B(t)}/SKILL.md`}}},Uw={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},iu={id:yo,generators:k0,capabilities:Uw,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:Fw,lint:{hooks:Mw,permissions:Gw,mcp:$w},supportsConversion:{commands:true,agents:true},project:L0,globalSupport:{capabilities:Uw,detectionPaths:[fn,ci,nr],layout:A0},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[or],global:[fn]},canonicalDir:QR,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[dn],global:[ci]},canonicalDir:".agentsmesh",canonicalFilename:qR}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Jf,detectionPaths:[or,dn]};});function Ww(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:_o,content:r.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("junie"))continue;let n=basename(o.source,".md");e.push({path:`${ml}/${n}.md`,content:o.body.trim()||""});}return e}function b0(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),Lp(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 Kw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).map(([r,o])=>[r,b0(o)]));return [{path:ll,content:JSON.stringify({mcpServers:e},null,2)}]}function Bw(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${wa}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function Hw(t){return t.agents.map(e=>{let r={name:e.name,description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,skills:e.skills.length>0?e.skills:void 0};return Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];}),{path:`${ba}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function zw(t){return t.ignore.length===0?[]:[{path:pl,content:t.ignore.join(`
|
|
127
|
+
`)}]}function Vw(t){return dt(t,mi)}function Jw(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>o.root?false:o.targets.length===0||o.targets.includes("junie"));return Lt(e?.body.trim()??"",r)}var Yw=d(()=>{Ap();ct();fe();v();Ta();s(Ww,"generateRules");s(b0,"toJunieMcpServer");s(Kw,"generateMcp");s(Bw,"generateCommands");s(Hw,"generateAgents");s(zw,"generateIgnore");s(Vw,"generateSkills");s(Jw,"renderJunieGlobalInstructions");});async function T0(t,e,r){let o=[_o,op,eC,rC],n=join(t,Yf);for(let i of o){let a=join(t,i),c=await y(a);if(c===null)continue;let l=await To({content:c,projectRoot:t,rulesDir:sp,sourcePath:a,fromTool:li,normalize:r});e.push(...l.results);let{frontmatter:m,body:p}=L(r(l.rootContent,a,n)),u=await G(n,{root:true,description:typeof m.description=="string"?m.description:void 0,globs:Array.isArray(m.globs)?m.globs:void 0},p);await I(n,u),e.push({fromTool:li,fromPath:a,toPath:Yf,feature:"rules"});return}}async function au(t){let e=[],r=await W(li,t);return await T0(t,e,r),e.push(...await J(cu,t,"project",{normalize:r})),await st(t,mi,li,e,r),e}var Fh=d(()=>{gt();w();v();ct();Ha();ot();wt();Ta();vh();s(T0,"importRootRule");s(au,"importFromJunie");});function Zw(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:li}))}var Qw=d(()=>{At();Ta();s(Zw,"lintRules");});function qw(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,o]of Object.entries(t.mcp.mcpServers))sk(o)&&e.push(U(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${o.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var tb=d(()=>{Ap();bt();s(qw,"lintMcp");});var x0,P0,N0,D0,cu,vh=d(()=>{Yw();Ta();le();Fh();Qw();tb();It();x0={name:"junie",primaryRootInstructionPath:_o,generateRules:Ww,generateCommands:Bw,generateAgents:Hw,generateSkills:Vw,generateMcp:Kw,generateIgnore:zw,importFrom:au},P0={rootInstructionPath:_o,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 `${ml}/${t}.md`},commandPath(t,e){return `${wa}/${t}.md`},agentPath(t,e){return `${ba}/${t}.md`}}},N0={rootInstructionPath:pi,renderPrimaryRootInstruction:Jw,skillDir:dl,managedOutputs:{dirs:[dl,fl,gl,oC],files:[pi,np]},rewriteGeneratedPath(t){return t===_o?pi:t.startsWith(`${ml}/`)?pi:t.startsWith(`${mi}/`)?t.replace(`${mi}/`,`${dl}/`):t.startsWith(`${wa}/`)?t.replace(`${wa}/`,`${gl}/`):t.startsWith(`${ba}/`)?t.replace(`${ba}/`,`${fl}/`):t===ll?np:t===pl?null:t},mirrorGlobalPath(t,e){return ut(t,".junie/skills",e)},paths:{rulePath(t,e){return pi},commandPath(t,e){return `${gl}/${t}.md`},agentPath(t,e){return `${fl}/${t}.md`}}},D0={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},cu={id:"junie",generators:x0,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:Zw,lint:{mcp:qw},project:P0,globalSupport:{capabilities:D0,detectionPaths:[pi,dl,fl,gl,np],layout:N0},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:sp,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:nC,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:sC,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ll]},canonicalDir:".agentsmesh",canonicalFilename:iC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[pl]},canonicalDir:".agentsmesh",canonicalFilename:aC}},buildImportPaths:Xf,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function rb(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Io,content:r.body.trim()?r.body:""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(ae))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs);let a=Object.keys(i).length>0?x(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${gn}/${n}.md`,content:a});}return e}function ob(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${hn}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function nb(t){return t.agents.map(e=>{let r=basename(e.source,".md"),o={mode:"subagent"};return e.description&&(o.description=e.description),e.model&&(o.model=e.model),e.tools.length>0&&(o.tools=e.tools),e.disallowedTools.length>0&&(o.disallowedTools=e.disallowedTools),{path:`${yn}/${r}.md`,content:x(o,e.body.trim()||"")}})}function sb(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ns,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function ib(t){return t.ignore.length===0?[]:[{path:xa,content:t.ignore.join(`
|
|
128
|
+
`)}]}function ab(t){return dt(t,Tr)}var cb=d(()=>{ct();v();_i();s(rb,"generateRules");s(ob,"generateCommands");s(nb,"generateAgents");s(sb,"generateMcp");s(ib,"generateIgnore");s(ab,"generateSkills");});var lu,mu,lb,Gh=d(()=>{v();ot();_i();lu=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${as}/${t}`,content:await G(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"kiloNonRootRuleMapper"),mu=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${Fa}/${t}`,content:await mt(o,{hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),lb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${yi}/${t}`,content:await Mt(o,n,i)}},"kiloAgentMapper");});async function mb(t){try{return await stat(t),!0}catch{return false}}async function M0(t,e,r){let o=join(t,ui);if(!await mb(o))return;let n=join(t,as),i=join(o,jh),c=e.some(l=>l.toPath===$h)?null:await y(i);if(c!==null){let l=join(t,$h),m=r(c,i,l),{body:p}=L(m),u=await G(l,{root:true},p);await I(l,u),e.push({feature:"rules",fromTool:ae,fromPath:`${ui}/${jh}`,toPath:$h});}e.push(...await pt({srcDir:o,destDir:n,extensions:[".md"],fromTool:ae,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:u})=>{let f=await lu({absolutePath:l,relativePath:m,content:p,destDir:n,normalizeTo:u});return m===jh||!f?null:{...f,feature:"rules"}},"mapEntry")}));}async function G0(t,e,r){let o=join(t,Pa);if(!await mb(o))return;let n=join(t,Fa);e.push(...await pt({srcDir:o,destDir:n,extensions:[".md"],fromTool:ae,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:c,normalizeTo:l})=>{let m=await mu({absolutePath:i,relativePath:a,content:c,destDir:n,normalizeTo:l});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function $0(t,e,r){let o=join(t,ap),n=await y(o);if(n===null)return;let i;try{i=parse(n);}catch{return}if(!(!i||!Array.isArray(i.customModes)))for(let a of i.customModes){if(!a||typeof a!="object")continue;let c=a;if(typeof c.slug!="string"||c.slug.length===0)continue;let l=c.slug,m=join(t,yi,`${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
129
|
|
|
124
130
|
## When to use
|
|
125
131
|
|
|
126
|
-
${f}`:u,h={};p&&(h.description=p),typeof c.name=="string"&&c.name.length>0&&(h.name=c.name);let
|
|
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
|
-
`)}]}
|
|
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
|
-
`)
|
|
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)&&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?"":`
|
|
132
|
+
${f}`:u,h={};p&&(h.description=p),typeof c.name=="string"&&c.name.length>0&&(h.name=c.name);let C=await Mt(m,h,g),R=r(C,o,m);await I(m,R),e.push({feature:"agents",fromTool:ae,fromPath:o,toPath:`${yi}/${l}.md`});}}async function pu(t,e={}){let r=e.scope??"project",o=[],n=await W(ae,t,r);return o.push(...await J(uu,t,r,{normalize:n})),await st(t,Tr,ae,o,n),r==="project"&&(await M0(t,o,n),await G0(t,o,n),await $0(t,o,n),await st(t,di,ae,o,n)),o}var $h,jh,Uh=d(()=>{gt();ct();Ce();wt();w();ot();v();Gh();_i();Wh();$h=`${as}/_root.md`,jh="00-root.md";s(mb,"pathExists");s(M0,"importLegacyRules");s(G0,"importLegacyWorkflows");s($0,"importLegacyModes");s(pu,"importFromKiloCode");});function pb(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:ae}))}var ub=d(()=>{At();_i();s(pb,"lintRules");});function db(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 fb(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[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 gb=d(()=>{bt();s(db,"lintHooks");s(fb,"lintPermissions");});var j0,U0,W0,hb,uu,Wh=d(()=>{cb();_i();le();Uh();Gh();ub();gb();It();j0={name:ae,primaryRootInstructionPath:Io,generateRules:rb,generateCommands:ob,generateAgents:nb,generateSkills:ab,generateMcp:sb,generateIgnore:ib,importFrom:pu},U0={rootInstructionPath:Io,skillDir:Tr,managedOutputs:{dirs:[gn,hn,yn,Tr],files:[Io,ns,xa]},paths:{rulePath(t,e){return `${gn}/${t}.md`},commandPath(t,e){return `${hn}/${t}.md`},agentPath(t,e){return `${yn}/${t}.md`}}},W0={rootInstructionPath:ss,skillDir:is,managedOutputs:{dirs:[fi,gi,hi,is,lC],files:[ss,Da,cp]},rewriteGeneratedPath(t){return t===Io?ss:t},mirrorGlobalPath(t,e){return ut(t,is,e)},paths:{rulePath(t,e){return `${fi}/${t}.md`},commandPath(t,e){return `${gi}/${t}.md`},agentPath(t,e){return `${hi}/${t}.md`}}},hb={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},uu={id:ae,generators:j0,capabilities:hb,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:pb,lint:{hooks:db,permissions:fb},project:U0,globalSupport:{capabilities:hb,detectionPaths:[ss,fi,gi,hi,is,Da,cp],layout:W0},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Io],global:[ss]},canonicalDir:as,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[gn],global:[fi]},canonicalDir:as,extensions:[".md"],map:lu}],commands:{feature:"commands",mode:"directory",source:{project:[hn],global:[gi]},canonicalDir:Fa,extensions:[".md"],map:mu},agents:{feature:"agents",mode:"directory",source:{project:[yn],global:[hi]},canonicalDir:yi,extensions:[".md"],map:lb},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ns,yl],global:[Da]},canonicalDir:".agentsmesh",canonicalFilename:mC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[xa],global:[cp]},canonicalDir:".agentsmesh",canonicalFilename:pC}},buildImportPaths:Zf,detectionPaths:[gn,hn,yn,Tr,ns,ui,Pa,di,yl,ap,xa,"kilo.jsonc","kilo.json"]};});function yb(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function H0(t){return t.type==="prompt"?t.prompt:t.command}function z0(t,e){let r=_b[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function Ib(t){let e=[];for(let[r,o]of Object.entries(t)){let n=r;if(!(n in _b)||!Array.isArray(o))continue;let i=1;for(let a of o){let c=H0(a);if(!c)continue;let l={name:`${yb(r)} ${i}`,version:"1",when:z0(n,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:c}:{type:"shellCommand",command:c}};e.push({name:`${yb(r)}-${i}.kiro.hook`,content:JSON.stringify(l,null,2)}),i+=1;}}return e}function V0(t){let e=B0.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 Sb(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:V0(r)}function Rb(t){return stringify(t).trimEnd()}var _b,B0,Kh=d(()=>{_b={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},B0=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(yb,"toKebab");s(H0,"hookText");s(z0,"toWhen");s(Ib,"generateKiroHooks");s(V0,"toCanonicalEntry");s(Sb,"parseKiroHookFile");s(Rb,"serializeCanonicalHooks");});function Y0(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 Cb(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:xr,content:r.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(we))continue;let n=basename(o.source,".md");e.push({path:`${Pr}/${n}.md`,content:x(Y0(o),o.body.trim()||"")});}return e}function Eb(t){return t.commands.map(e=>({path:`${ce}/${Z(e.name)}/SKILL.md`,content:de(e)}))}function Ob(t){return dt(t,ce)}function kb(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:va,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Lb(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:Ib(t.hooks).map(e=>({path:`${cs}/${e.name}`,content:e.content}))}function Ab(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=x(r,e.body.trim()||"");return {path:`${Nr}/${e.name}.md`,content:o}})}function wb(t){return t.ignore.length===0?[]:[{path:Ma,content:t.ignore.join(`
|
|
133
|
+
`)}]}var bb=d(()=>{ct();Ut();v();Kh();Ga();s(Y0,"steeringFrontmatter");s(Cb,"generateRules");s(Eb,"generateCommands");s(Ob,"generateSkills");s(kb,"generateMcp");s(Lb,"generateHooks");s(Ab,"generateAgents");s(wb,"generateIgnore");});function Z0(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:Zo(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function Q0(t,e,r,o){let n=o==="global"?[Dr,xr]:[xr,Dr];for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,Qf),{frontmatter:m,body:p}=L(r(c,a,l));await I(l,await G(l,{...m,root:true},p)),e.push({fromTool:we,fromPath:a,toPath:Qf,feature:"rules"});return}}async function q0(t,e,r){let o=join(t,qf);e.push(...await pt({srcDir:join(t,Pr),destDir:o,extensions:[".md"],fromTool:we,normalize:r,mapEntry:s(async({relativePath:n,normalizeTo:i})=>{if(basename(n)==="AGENTS.md")return null;let a=join(o,n),{frontmatter:c,body:l}=L(i(a));return {destPath:a,toPath:`${qf}/${n}`,feature:"rules",content:await G(a,Z0(c),l)}},"mapEntry")}));}async function tW(t,e){let r={};for(let n of await F(join(t,cs))){if(!n.endsWith(".kiro.hook"))continue;let i=Sb(await y(n)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let o=join(t,tg);await k(join(t,".agentsmesh")),await I(o,Rb(r)),e.push({fromTool:we,fromPath:join(t,cs),toPath:tg,feature:"hooks"});}async function du(t,e={}){let r=e.scope??"project",o=[],n=await W(we,t,r);return await Q0(t,o,n,r),await q0(t,o,n),o.push(...await J(fu,t,r,{normalize:n})),await st(t,ce,we,o,n),r==="project"&&await tW(t,o),o}var Bh=d(()=>{gt();ct();Ce();wt();ot();Je();w();v();Kh();Ga();Hh();s(Z0,"canonicalRuleMeta");s(Q0,"importRoot");s(q0,"importNonRootRules");s(tW,"importHooks");s(du,"importFromKiro");});function Tb(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:we}))}var xb=d(()=>{At();Ga();s(Tb,"lintRules");});function Pb(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","UserPromptSubmit","SubagentStop"],r=new Set(e);return Object.keys(t.hooks).filter(o=>!r.has(o)).map(o=>zn(o,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var Nb=d(()=>{bt();s(Pb,"lintHooks");});var eW,rW,oW,nW,fu,Hh=d(()=>{Ut();bb();le();Bh();xb();Nb();It();Ga();eW={name:we,primaryRootInstructionPath:xr,generateRules:Cb,generateCommands:Eb,generateAgents:Ab,generateSkills:Ob,generateMcp:kb,generateHooks:Lb,generateIgnore:wb,importFrom:du},rW={rootInstructionPath:xr,skillDir:ce,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${Pr}/${t}.md`},commandPath(t){return `${ce}/${Z(t)}/SKILL.md`},agentPath(t,e){return `${Nr}/${t}.md`}}},oW={rootInstructionPath:Dr,skillDir:ls,managedOutputs:{dirs:[Ii,ls,Si,fC],files:[Dr,Il,Sl]},rewriteGeneratedPath(t){return t===xr?Dr:t.startsWith(`${Pr}/`)?t.replace(`${Pr}/`,`${Ii}/`):t.startsWith(`${ce}/`)?t.replace(`${ce}/`,`${ls}/`):t.startsWith(`${Nr}/`)?t.replace(`${Nr}/`,`${Si}/`):t===va?Il:t===Ma?Sl:t.startsWith(`${cs}/`)?null:t},mirrorGlobalPath(t,e){return ut(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${Ii}/${t}.md`},commandPath(t){return `${ce}/${Z(t)}/SKILL.md`},agentPath(t,e){return `${Si}/${t}.md`}}},nW={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},fu={id:we,generators:eW,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:Tb,lint:{hooks:Pb},project:rW,globalSupport:{capabilities:nW,detectionPaths:[Ii,Dr,ls,Si,Il,Sl],layout:oW},importer:{agents:{feature:"agents",mode:"directory",source:{project:[Nr],global:[Nr]},canonicalDir:gC,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[va],global:[Il]},canonicalDir:".agentsmesh",canonicalFilename:hC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ma],global:[Sl]},canonicalDir:".agentsmesh",canonicalFilename:yC}},buildImportPaths:eg,detectionPaths:[Pr,ce,Nr,cs,va,Ma]};});function Fb(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:So,content:r.body.trim()?r.body:""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(Fr))continue;let n=basename(o.source,".md"),i={};o.description&&(i.description=o.description),o.globs.length>0&&(i.globs=o.globs);let a=Object.keys(i).length>0?x(i,o.body.trim()||""):o.body.trim()||"";e.push({path:`${_n}/${n}.md`,content:a});}return e}function vb(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${In}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function Mb(t){return t.agents.map(e=>{let r=basename(e.source,".md"),o={mode:"subagent"};return e.description&&(o.description=e.description),e.model&&(o.model=e.model),e.tools.length>0&&(o.tools=e.tools),e.disallowedTools.length>0&&(o.disallowedTools=e.disallowedTools),{path:`${Sn}/${r}.md`,content:x(o,e.body.trim()||"")}})}function sW(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 Gb(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e={};for(let[r,o]of Object.entries(t.mcp.mcpServers))e[r]=sW(o);return [{path:Ro,content:JSON.stringify({mcp:e},null,2)}]}function $b(t){return dt(t,vr)}var jb=d(()=>{ct();v();Oi();s(Fb,"generateRules");s(vb,"generateCommands");s(Mb,"generateAgents");s(sW,"toOpenCodeMcpServer");s(Gb,"generateMcp");s($b,"generateSkills");});function zh(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,o]of Object.entries(t))typeof o=="string"&&(e[r]=o);return e}function aW(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object"||Array.isArray(e))return {};let r=e.mcp;if(!r||typeof r!="object"||Array.isArray(r))return {};let o={};for(let[n,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i;if(typeof a.url=="string"){o[n]={type:"url",url:a.url,headers:zh(a.headers),env:zh(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let c=a.command,l=c[0];if(l===void 0)continue;let m=c.slice(1);o[n]={type:"stdio",command:l,args:m,env:zh(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return o}async function cW(t,e,r){let n=join(t,e==="global"?us:Ro),i=await y(n);if(i===null)return;let a=aW(i);Object.keys(a).length!==0&&(await Kt(t,rg,a),r.push({feature:"mcp",fromTool:Fr,fromPath:n,toPath:rg}));}async function Ub(t,e={}){let r=e.scope??"project",o=[],n=await W(Fr,t,r);return o.push(...await J(gu,t,r,{normalize:n})),await st(t,vr,Fr,o,n),await cW(t,r,o),o}var Wb=d(()=>{gt();ct();wt();eo();w();Oi();Vh();s(zh,"toStringRecord");s(aW,"parseOpenCodeMcp");s(cW,"importMcp");s(Ub,"importFromOpenCode");});var Kb,Bb,Hb,zb=d(()=>{v();ot();Oi();Kb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${Rl}/${t}`,content:await G(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"opencodeNonRootRuleMapper"),Bb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${mp}/${t}`,content:await mt(o,{hasDescription:Object.prototype.hasOwnProperty.call(n,"description"),description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),Hb=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${pp}/${t}`,content:await Mt(o,n,i)}},"opencodeAgentMapper");});function Vb(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Fr}))}var Jb=d(()=>{At();Oi();s(Vb,"lintRules");});function Yb(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 Xb(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[U(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function Zb(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 Qb=d(()=>{bt();s(Yb,"lintHooks");s(Xb,"lintPermissions");s(Zb,"lintIgnore");});var lW,mW,pW,qb,gu,Vh=d(()=>{jb();Oi();le();Wb();zb();Jb();Qb();It();lW={name:Fr,primaryRootInstructionPath:So,generateRules:Fb,generateCommands:vb,generateAgents:Mb,generateSkills:$b,generateMcp:Gb,importFrom:Ub},mW={rootInstructionPath:So,skillDir:vr,managedOutputs:{dirs:[_n,In,Sn,vr],files:[So,Ro]},paths:{rulePath(t){return `${_n}/${t}.md`},commandPath(t){return `${In}/${t}.md`},agentPath(t){return `${Sn}/${t}.md`}}},pW={rootInstructionPath:ms,skillDir:ps,managedOutputs:{dirs:[Ri,Ci,Ei,ps,IC],files:[ms,us]},rewriteGeneratedPath(t){return t===So?ms:t===Ro?us:t},mirrorGlobalPath(t,e){return ut(t,ps,e)},paths:{rulePath(t){return `${Ri}/${t}.md`},commandPath(t){return `${Ci}/${t}.md`},agentPath(t){return `${Ei}/${t}.md`}}},qb={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},gu={id:Fr,generators:lW,capabilities:qb,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:Vb,lint:{hooks:Yb,permissions:Xb,ignore:Zb},project:mW,globalSupport:{capabilities:qb,detectionPaths:[ms,Ri,Ci,Ei,ps,us],layout:pW},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[So],global:[ms]},canonicalDir:Rl,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[_n],global:[Ri]},canonicalDir:Rl,extensions:[".md"],map:Kb}],commands:{feature:"commands",mode:"directory",source:{project:[In],global:[Ci]},canonicalDir:mp,extensions:[".md"],map:Bb},agents:{feature:"agents",mode:"directory",source:{project:[Sn],global:[Ei]},canonicalDir:pp,extensions:[".md"],map:Hb}},buildImportPaths:og,detectionPaths:[_n,In,Sn,vr,Ro,"opencode.jsonc"]};});function tT(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:sr,content:r.body.trim()?r.body:""});let o=t.rules.filter(n=>!n.root&&(n.targets.length===0||n.targets.includes(Co)));for(let n of o){let i=basename(n.source,".md"),a={};n.description&&(a.description=n.description),n.globs.length>0&&(a.globs=n.globs);let c=x(a,n.body.trim()||"");e.push({path:`${Rn}/${i}.md`,content:c});}return e}function eT(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let o=x(r,e.body.trim()||"");return {path:`${Eo}/${e.name}.md`,content:o}})}function rT(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=x(r,e.body.trim()||"");return {path:`${Oo}/${e.name}.md`,content:o}})}function oT(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=x(o,r.body.trim()||"");e.push({path:`${be}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${be}/${r.name}/${a}`,content:i.content});}}return e}function nT(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:ds,content:e}]}function sT(t){return !t.ignore||t.ignore.length===0?[]:[{path:fs,content:t.ignore.join(`
|
|
134
|
+
`)}]}var iT=d(()=>{v();ja();s(tT,"generateRules");s(eT,"generateCommands");s(rT,"generateAgents");s(oT,"generateSkills");s(nT,"generateMcp");s(sT,"generateIgnore");});async function aT(t,e={}){let r=e.scope??"project",o=[],n=await W(Co,t,r);return o.push(...await J(hu,t,r,{normalize:n})),await st(t,r==="global"?ko:be,Co,o,n),o}var cT=d(()=>{gt();wt();ct();ja();Yh();s(aT,"importFromQwenCode");});function lT(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Co}))}var mT=d(()=>{At();ja();s(lT,"lintRules");});var dW,fW,gW,hW,yW,hu,Yh=d(()=>{iT();cT();mT();It();ja();dW={name:Co,primaryRootInstructionPath:sr,generateRules:tT,generateCommands:eT,generateAgents:rT,generateSkills:oT,generateMcp:nT,generateIgnore:sT,importFrom:aT},fW={rootInstructionPath:sr,skillDir:be,managedOutputs:{dirs:[Rn,Eo,Oo,be],files:[sr,ds,fs]},paths:{rulePath(t,e){return e.root?sr:`${Rn}/${t}.md`},commandPath(t){return `${Eo}/${t}.md`},agentPath(t){return `${Oo}/${t}.md`}}},gW={rootInstructionPath:Cn,skillDir:ko,managedOutputs:{dirs:[gs,hs,ko],files:[Cn,ki]},rewriteGeneratedPath(t){return t===sr?Cn:t===ds?ki:t===fs?null:t.startsWith(`${Eo}/`)?t.replace(`${Eo}/`,`${gs}/`):t.startsWith(`${Oo}/`)?t.replace(`${Oo}/`,`${hs}/`):t.startsWith(`${be}/`)?t.replace(`${be}/`,`${ko}/`):t.startsWith(`${Rn}/`)?null:t},paths:{rulePath(t,e){return Cn},commandPath(t){return `${gs}/${t}.md`},agentPath(t){return `${hs}/${t}.md`}}},hW={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},yW={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},hu={id:Co,generators:dW,capabilities:hW,emptyImportMessage:"No Qwen Code config found (QWEN.md or .qwen/rules, .qwen/commands, .qwen/settings.json).",lintRules:lT,project:fW,globalSupport:{capabilities:yW,detectionPaths:[Cn,ki,gs,hs,ko],layout:gW},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[sr],global:[Cn]},canonicalDir:ng,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Rn],global:[]},canonicalDir:ng,extensions:[".md"],preset:"rule"}],commands:{feature:"commands",mode:"directory",source:{project:[Eo],global:[gs]},canonicalDir:RC,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[Oo],global:[hs]},canonicalDir:CC,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ds],global:[ki]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/mcp.json"},ignore:{feature:"ignore",mode:"flatFile",source:{project:[fs],global:[]},canonicalDir:".agentsmesh",canonicalFilename:".agentsmesh/ignore"}},buildImportPaths:sg,detectionPaths:[sr,".qwen/settings.json",".qwen/commands",".qwen/rules"]};});function uT(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Mr,content:r.body.trim()||""});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(ys))continue;let n=basename(o.source,".md");e.push({path:`${En}/${n}.md`,content:o.body.trim()||""});}return e}function dT(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${On}/${e.name}.md`,content:x(r,e.body.trim()||"")}})}function fT(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:El,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function gT(t){return t.ignore.length===0?[]:[{path:Ol,content:t.ignore.join(`
|
|
135
|
+
`)}]}function hT(t){return dt(t,Lo)}function yT(t){if(t.agents.length===0)return [];let e=t.agents.map(r=>{let n={slug:basename(r.source,".md"),name:r.name};return r.description&&(n.description=r.description),r.body.trim()&&(n.roleDefinition=r.body.trim()),n});return [{path:Ua,content:stringify({customModes:e})}]}var _T=d(()=>{ct();v();bi();s(uT,"generateRules");s(dT,"generateCommands");s(fT,"generateMcp");s(gT,"generateIgnore");s(hT,"generateSkills");s(yT,"generateAgents");});var yu,ST,Xh=d(()=>{v();ot();bi();yu=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${wi}/${t}`,content:await G(o,{root:false,description:typeof n.description=="string"?n.description:void 0,globs:Array.isArray(n.globs)?n.globs:void 0},i)}},"rooNonRootRuleMapper"),ST=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let o=join(r,t),{frontmatter:n,body:i}=L(e(o));return {destPath:o,toPath:`${dp}/${t}`,content:await mt(o,{hasDescription:true,description:typeof n.description=="string"?n.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function SW(t,e,r){let o=join(t,Li),n;try{n=await readdir(o,{withFileTypes:!0});}catch{return}let i=n.filter(c=>c.isDirectory()&&c.name.startsWith("rules-")).map(c=>c.name),a=join(t,wi);for(let c of i)e.push(...await pt({srcDir:join(o,c),destDir:a,extensions:[".md"],fromTool:ys,normalize:r,mapEntry:s(async({srcPath:l,relativePath:m,content:p,normalizeTo:u})=>{let f=await yu({absolutePath:l,relativePath:m,content:p,destDir:a,normalizeTo:u});return f?{...f,feature:"rules"}:null},"mapEntry")}));}async function RT(t,e={}){let r=e.scope??"project",o=[],n=await W(ys,t,r);return o.push(...await J(_u,t,r,{normalize:n})),await SW(t,o,n),await st(t,Lo,ys,o,n),o}var CT=d(()=>{gt();ct();Ce();wt();Xh();bi();Qh();s(SW,"importPerModeRules");s(RT,"importFromRooCode");});function ET(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:ys}))}var OT=d(()=>{At();bi();s(ET,"lintRules");});function LW(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var OW,kW,AW,wW,bW,_u,Qh=d(()=>{w();_T();bi();le();CT();Xh();OT();It();OW={name:"roo-code",primaryRootInstructionPath:Mr,generateRules:uT,generateCommands:dT,generateSkills:hT,generateMcp:fT,generateIgnore:gT,generateAgents:yT,importFrom:RT},kW={rootInstructionPath:Mr,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",Ua]},paths:{rulePath(t,e){return `${En}/${t}.md`},commandPath(t,e){return `${On}/${t}.md`},agentPath(t,e){return null}}};s(LW,"computeStatus");AW=s(async(t,e,r,o)=>{if(r!=="global")return [];if(!o.has("agents")||t.agents.length===0)return [];let n=t.agents.map(c=>{let m={slug:basename(c.source,".md"),name:c.name};return c.description&&(m.description=c.description),c.body.trim()&&(m.roleDefinition=c.body.trim()),m}),i=stringify({customModes:n}),a=await y(join(e,kl));return [{target:"roo-code",path:kl,content:i,currentContent:a??void 0,status:LW(a,i)}]},"generateRooGlobalExtras"),wW={rootInstructionPath:Ss,skillDir:kn,managedOutputs:{dirs:[_s,Is,kn,OC],files:[Ss,Ai,Ll,kl]},rewriteGeneratedPath(t){return t===Mr?Ss:t===Ua?null:t.startsWith(`${En}/`)?t.replace(`${En}/`,`${_s}/`):t.startsWith(`${On}/`)?t.replace(`${On}/`,`${Is}/`):t.startsWith(`${Lo}/`)?t.replace(`${Lo}/`,`${kn}/`):t===El?Ai:t===Ol?Ll:t},mirrorGlobalPath(t,e){return ut(t,kn,e)},paths:{rulePath(t,e){return `${_s}/${t}.md`},commandPath(t,e){return `${Is}/${t}.md`},agentPath(t,e){return null}}},bW={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},_u={id:"roo-code",generators:OW,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:ET,project:kW,globalSupport:{capabilities:bW,detectionPaths:[_s,Is,kn,Ai,Ll,Ss,kl],layout:wW,scopeExtras:AW},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Mr,Cl],global:[Ss,Mr,Cl]},canonicalDir:wi,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:[En],global:[_s]},canonicalDir:wi,extensions:[".md"],map:yu}],commands:{feature:"commands",mode:"directory",source:{project:[On],global:[Is]},canonicalDir:dp,extensions:[".md"],map:ST},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[El],global:[Ai]},canonicalDir:".agentsmesh",canonicalFilename:kC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ol],global:[Ll]},canonicalDir:".agentsmesh",canonicalFilename:LC}},buildImportPaths:ig,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",Ua]};});function kT(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:xe,content:r.body.trim()});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes(ir))continue;let n=basename(o.source,".md");e.push({path:`${Te}/${n}.md`,content:o.body.trim()});}return e}function LT(t){return dt(t,ar)}function AT(t){return t.mcp===null||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ti,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function wT(t){return t.ignore.length===0?[]:[{path:Wa,content:t.ignore.join(`
|
|
136
|
+
`)}]}var bT=d(()=>{ct();Ka();s(kT,"generateRules");s(LT,"generateSkills");s(AT,"generateMcp");s(wT,"generateIgnore");});async function PW(t,e,r,o){let n=o==="global"?[cr,xe]:[xe,cr];for(let i of n){let a=join(t,i),c=await y(a);if(c===null)continue;let l=join(t,TT),{frontmatter:m,body:p}=L(r(c,a,l));await k(join(t,wl)),await I(l,await G(l,{...m,root:true},p)),e.push({fromTool:ir,fromPath:a,toPath:TT,feature:"rules"});return}}async function NW(t,e,r,o){let n=join(t,o==="global"?Ln:Te),i=join(t,wl);e.push(...await pt({srcDir:n,destDir:i,extensions:[".md"],fromTool:ir,normalize:r,mapEntry:s(async({relativePath:a,normalizeTo:c})=>{let l=basename(a);if(l==="project_rules.md"||l==="rules.md")return null;let m=join(i,a),{frontmatter:p,body:u}=L(c(m));return {destPath:m,toPath:`${wl}/${a}`,feature:"rules",content:await G(m,{...p,root:false},u)}},"mapEntry")}));}async function xT(t,e={}){let r=e.scope??"project",o=[],n=await W(ir,t,r);return await PW(t,o,n,r),await NW(t,o,n,r),o.push(...await J(Iu,t,r,{normalize:n})),await st(t,r==="global"?Gr:ar,ir,o,n),o}var TT,PT=d(()=>{gt();ct();Ce();wt();ot();w();v();Ka();qh();TT=`${wl}/_root.md`;s(PW,"importRoot");s(NW,"importNonRootRules");s(xT,"importFromTrae");});function NT(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:ir}))}var DT=d(()=>{At();Ka();s(NT,"lintRules");});var DW,FW,vW,MW,Iu,qh=d(()=>{bT();le();PT();DT();It();Ka();DW={name:ir,primaryRootInstructionPath:xe,generateRules:kT,generateSkills:LT,generateMcp:AT,generateIgnore:wT,importFrom:xT},FW={rootInstructionPath:xe,skillDir:ar,managedOutputs:{dirs:[Te,ar],files:[Ti,Wa]},paths:{rulePath(t,e){return `${Te}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},vW={rootInstructionPath:cr,skillDir:Gr,managedOutputs:{dirs:[Ln,Gr,wC],files:[cr,Al]},rewriteGeneratedPath(t){return t===xe?cr:t.startsWith(`${Te}/`)?t.replace(`${Te}/`,`${Ln}/`):t.startsWith(`${ar}/`)?t.replace(`${ar}/`,`${Gr}/`):t===Ti?Al:t===Wa?null:t},mirrorGlobalPath(t,e){return ut(t,Gr,e)},paths:{rulePath(t,e){return t==="_root"?cr:`${Ln}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return null}}},MW={rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Iu={id:ir,generators:DW,capabilities:{rules:"native",additionalRules:"native",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},emptyImportMessage:"No Trae config found (.trae/rules/project_rules.md, .trae/rules/*.md, .trae/skills/, .trae/mcp.json, or .trae/.ignore).",lintRules:NT,project:FW,globalSupport:{capabilities:MW,detectionPaths:[cr,Ln,Gr,Al],layout:vW},importer:{mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ti],global:[Al]},canonicalDir:".agentsmesh",canonicalFilename:bC},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Wa]},canonicalDir:".agentsmesh",canonicalFilename:TC}},buildImportPaths:ag,detectionPaths:[Te,Ti,xe]};});function FT(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Ao)),o=e?.body.trim()??"",n=Lt(o,r);return n?[{path:$r,content:n}]:[]}function vT(t){return dt(t,ee)}function MT(t){return t.commands.map(e=>({path:`${ee}/${Z(e.name)}/SKILL.md`,content:de(e)}))}function GT(t){return t.agents.map(e=>({path:`${ee}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}function $T(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Rs,content:e}]}var jT=d(()=>{ct();fe();ft();Ut();Ba();s(FT,"generateRules");s(vT,"generateSkills");s(MT,"generateCommands");s(GT,"generateAgents");s($T,"generateMcp");});async function UT(t,e={}){let r=e.scope??"project",o=[],n=await W(Ao,t,r);return o.push(...await J(Su,t,r,{normalize:n})),await st(t,r==="global"?ge:ee,Ao,o,n),o}var WT=d(()=>{gt();ct();wt();Ba();ty();s(UT,"importFromWarp");});function KT(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:Ao}))}var BT=d(()=>{At();Ba();s(KT,"lintRules");});function HT(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 zT(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[U(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function VT(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 JT=d(()=>{bt();s(HT,"lintHooks");s(zT,"lintPermissions");s(VT,"lintIgnore");});var GW,$W,jW,UW,WW,Su,ty=d(()=>{Ut();ft();jT();le();WT();BT();JT();It();Ba();GW={name:Ao,primaryRootInstructionPath:$r,generateRules:FT,generateCommands:MT,generateAgents:GT,generateSkills:vT,generateMcp:$T,importFrom:UT},$W={rootInstructionPath:$r,skillDir:ee,managedOutputs:{dirs:[ee],files:[$r,Rs]},paths:{rulePath(t){return $r},commandPath(t){return `${ee}/${Z(t)}/SKILL.md`},agentPath(t){return `${ee}/${B(t)}/SKILL.md`}}},jW={rootInstructionPath:void 0,skillDir:ge,managedOutputs:{dirs:[ge],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${ee}/`)?t.replace(`${ee}/`,`${ge}/`):t},mirrorGlobalPath(t,e){return ut(t,ge,e)},paths:{rulePath(){return ge},commandPath(t){return `${ge}/${Z(t)}/SKILL.md`},agentPath(t){return `${ge}/${B(t)}/SKILL.md`}}},UW={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},WW={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Su={id:Ao,generators:GW,capabilities:UW,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:KT,lint:{hooks:HT,permissions:zT,ignore:VT},supportsConversion:{commands:true,agents:true},project:$W,globalSupport:{capabilities:WW,detectionPaths:[ge],layout:jW},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[cg,$r]},canonicalDir:PC,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Rs]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:lg,detectionPaths:[$r,cg,Rs]};});var Mo,ey,Ts,YT,sc,Go,ic,ac,XT,xs,Br,cc,ry,oy,ny,sy,iy,ay,lc,mc,Gl,Ru,Cu,Eu,ZT,me=d(()=>{Mo="windsurf",ey=".windsurfrules",Ts=".windsurf/rules",YT=".windsurfignore",sc=".codeiumignore",Go="AGENTS.md",ic=".windsurf/hooks.json",ac=".windsurf/mcp_config.example.json",XT=".windsurf/mcp_config.json",xs=".windsurf/workflows",Br=".windsurf/skills",cc=".agentsmesh/rules",ry=".agentsmesh/commands",oy=".agentsmesh/agents",ny=".agentsmesh/skills",sy=".agentsmesh/ignore",iy=".agentsmesh/hooks.yaml",ay=".agentsmesh/mcp.json",lc=".codeium/windsurf/memories/global_rules.md",mc=".codeium/windsurf/skills",Gl=".codeium/windsurf/global_workflows",Ru=".codeium/windsurf/hooks.json",Cu=".codeium/windsurf/mcp_config.json",Eu=".codeium/.codeiumignore",ZT=".agents/skills";});function BW(t){let e=basename(t,".md");return e==="_root"?"root":e}function HW(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 cy(t){let e=[],r=t.rules.find(o=>o.root);if(!r)return [];e.push({path:Go,content:r.body.trim()});for(let o of t.rules){if(o.root||o.targets.length>0&&!o.targets.includes("windsurf"))continue;let n=BW(o.source),i=o.trigger||(o.globs.length>0?"glob":void 0),a={description:o.description||void 0,trigger:i,glob:o.globs.length===1?o.globs[0]:void 0,globs:o.globs.length>1?o.globs:void 0};Object.keys(a).forEach(m=>{a[m]===void 0&&delete a[m];});let c=Object.keys(a).length>0?x(a,o.body.trim()||""):o.body.trim()||"";e.push({path:`${Ts}/${n}.md`,content:c});let l=HW(o.globs);l&&(l!==n&&e.push({path:`${Ts}/${l}.md`,content:c}),e.push({path:`${l}/AGENTS.md`,content:o.body.trim()||""}));}return e}var QT=d(()=>{v();me();s(BW,"ruleSlug");s(HW,"directoryScopedRuleDir");s(cy,"generateRules");});function ly(t){return !t.ignore||t.ignore.length===0?[]:[{path:sc,content:t.ignore.join(`
|
|
137
|
+
`)}]}var qT=d(()=>{me();s(ly,"generateIgnore");});function my(t){return t.commands.map(e=>{let r={description:e.description.trim()||void 0,allowedTools:e.allowedTools.length>0?e.allowedTools:void 0};Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];});let o=Object.keys(r).length>0?x(r,e.body.trim()||""):e.body.trim();return {path:`${xs}/${e.name}.md`,content:o}})}var tx=d(()=>{v();me();s(my,"generateCommands");});function py(t){return t.agents.map(e=>({path:`${Br}/${B(e.name)}/SKILL.md`,content:Wt(e)}))}var ex=d(()=>{ft();me();s(py,"generateAgents");});function uy(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ac,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var rx=d(()=>{me();s(uy,"generateMcp");});function zW(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 VW(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!Zr(i))continue;let a=vt(i),c=ne(i),l=i.type==="prompt"?c||a:a||c;l&&n.push({command:l,show_output:true});}n.length>0&&(e[zW(r)]=n);}return e}function dy(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=VW(t.hooks);return Object.keys(e).length===0?[]:[{path:ic,content:JSON.stringify({hooks:e},null,2)}]}var ox=d(()=>{Sr();me();s(zW,"windsurfEventName");s(VW,"toWindsurfHooks");s(dy,"generateHooks");});function fy(t){let e=[];for(let r of t.skills){let o={name:r.name,description:r.description||void 0};o.description===void 0&&delete o.description;let n=Object.keys(o).length>0?x(o,r.body.trim()||""):r.body.trim()||"";e.push({path:`${Br}/${r.name}/SKILL.md`,content:n});for(let i of r.supportingFiles)e.push({path:`${Br}/${r.name}/${i.relativePath}`,content:i.content});}return e}var nx=d(()=>{v();me();s(fy,"generateSkills");});var sx=d(()=>{QT();qT();tx();ex();rx();ox();nx();});var ix=d(()=>{sx();});function ax(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 cx(t,e,r){let o=join(t,xs),i=(await F(o)).filter(c=>c.endsWith(".md")),a=join(t,ry);for(let c of i){let l=await y(c);if(!l)continue;let m=relative(o,c).replace(/\\/g,"/");await k(a);let p=join(a,m),u=r(l,c,p),{frontmatter:f,body:g}=L(u),h=await mt(p,{description:typeof f.description=="string"?f.description:"",hasDescription:Object.prototype.hasOwnProperty.call(f,"description"),allowedTools:(()=>{let C=ax(f.allowedTools);return C.length>0?C:ax(f["allowed-tools"])})(),hasAllowedTools:Object.prototype.hasOwnProperty.call(f,"allowedTools")||Object.prototype.hasOwnProperty.call(f,"allowed-tools")},g);await I(p,h),e.push({fromTool:Mo,fromPath:c,toPath:`${ry}/${m}`,feature:"commands"});}}var lx=d(()=>{w();v();ot();me();s(ax,"toStringArray");s(cx,"importWorkflows");});async function mx(t,e,r,o=Br){let n=join(t,o),i=await Cs(n),a={projectRoot:t,sourceSkillsDir:o,destCanonicalSkillsDir:ny,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=L(p),f=Qr(u.frontmatter,c);if(f){await Ke(join(t,ny,c));let g=join(t,oy);await k(g);let h=join(g,`${f.name}.md`);await I(h,We(f,r(u.body,m,h))),e.push({fromTool:"windsurf",fromPath:m,toPath:`${oy}/${f.name}.md`,feature:"agents"});continue}await xo(c,l,a);}}var px=d(()=>{w();v();ft();ya();Va();me();s(mx,"importSkills");});async function dx(t,e){let r=join(t,ic),o=await y(r);if(o)try{let n=JSON.parse(o);if(!n.hooks||typeof n.hooks!="object"||Array.isArray(n.hooks))return;let i=ZW(n.hooks);if(Object.keys(i).length===0)return;let a=join(t,iy);await k(dirname(a)),await I(a,stringify(i)),e.push({fromTool:Mo,fromPath:r,toPath:iy,feature:"hooks"});}catch{}}function XW(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 ZW(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=XW(r),i=[];for(let a of o){if(!a||typeof a!="object")continue;let c=a;if(typeof c.command=="string"&&c.command.trim()){i.push({matcher:".*",type:"command",command:c.command});continue}let l=typeof c.matcher=="string"&&c.matcher.trim()?c.matcher:".*",m=Array.isArray(c.hooks)?c.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let 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[n]=i);}return e}async function fx(t,e){let r=[ac,XT];for(let o of r){let n=join(t,o),i=await y(n);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let c=join(t,ay);await k(dirname(c)),await I(c,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:Mo,fromPath:n,toPath:ay,feature:"mcp"});return}catch{}}}var gx=d(()=>{w();me();s(dx,"importWindsurfHooks");s(XW,"canonicalHookEventName");s(ZW,"windsurfHooksToCanonical");s(fx,"importWindsurfMcp");});async function ku(t,e){let r=e?.scope??"project",o=[],n=await W(Mo,t),i=await W("codex-cli",t),a=join(t,cc),c=join(t,ey),l=await y(c);if(l!==null){await k(a);let f=join(a,"_root.md"),g=n(l,c,f).trim(),h=await G(f,{root:true},g);await I(f,h),o.push({fromTool:"windsurf",fromPath:c,toPath:`${cc}/_root.md`,feature:"rules"});}if(l===null){let f=join(t,Go),g=await y(f);if(g!==null){await k(a);let h=join(a,"_root.md"),C=n(i(g,f,h),f,h).trim(),R=await G(h,{root:true},C);await I(h,R),o.push({fromTool:"windsurf",fromPath:f,toPath:`${cc}/_root.md`,feature:"rules"});}}r!=="global"&&o.push(...await pt({srcDir:t,destDir:a,extensions:["AGENTS.md"],fromTool:"windsurf",normalize:n,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 C=h.replace(/\//g,"-");if(!Gm(h))return await Ke(join(a,`${C}.md`)),null;let R=join(a,`${C}.md`);return {destPath:R,toPath:`${cc}/${C}.md`,feature:"rules",content:await G(R,{root:false,globs:[`${h}/**`]},g(R))}},"mapEntry")}));let m=join(t,Ts);o.push(...await pt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:n,mapEntry:s(async({relativePath:f,normalizeTo:g})=>{if(f==="_root.md"&&l!==null)return null;let h=join(a,f),{frontmatter:C,body:R}=L(g(h)),_={...C};return typeof _.glob=="string"&&_.glob.trim()&&(_.globs=[_.glob],delete _.glob),{destPath:h,toPath:`${cc}/${f}`,feature:"rules",content:await G(h,{..._,root:false},R)}},"mapEntry")}));let p=join(t,YT),u=await y(p);if((u===null||!u.trim())&&(p=join(t,sc),u=await y(p)),u!==null&&u.trim()){let f=u.split(/\r?\n/),g=[];for(let h of f){let C=h.trim();C&&!C.startsWith("#")&&g.push(C);}if(g.length>0){await k(join(t,".agentsmesh"));let h=join(t,sy);await I(h,g.join(`
|
|
138
|
+
`)),o.push({fromTool:"windsurf",fromPath:p,toPath:sy,feature:"ignore"});}}return await cx(t,o,n),await mx(t,o,n),await dx(t,o),await fx(t,o),o}var hy=d(()=>{gt();w();v();ot();Ce();ya();me();lx();px();gx();s(ku,"importFromWindsurf");});function hx(t,e,r){let o=[],{rules:n}=t;n.length>0&&(n.some(c=>c.root)||o.push({level:"warning",file:relative(e,n[0].source),target:Mo,message:"Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."}));let i=[];return t.permissions&&(t.permissions.allow.length>0||t.permissions.deny.length>0)&&i.push("permissions"),i.length>0&&o.push({level:"warning",file:".agentsmesh",target:Mo,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),o}var yx=d(()=>{me();s(hx,"lintRules");});function _x(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 Ix(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 Sx=d(()=>{bt();s(_x,"lintCommands");s(Ix,"lintMcp");});function rK(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 oK,nK,sK,iK,Rx,Cx=d(()=>{ix();zs();me();le();hy();yx();Sx();It();ua();ft();s(rK,"directoryScopedRuleDir");oK={name:"windsurf",primaryRootInstructionPath:Go,generateRules:cy,generateCommands:my,generateAgents:py,generateSkills:fy,generateMcp:uy,generateHooks:dy,generateIgnore:ly,importFrom:ku},nK={rootInstructionPath:Go,extraRuleOutputPaths(t){if(t.root)return [Go];let e=rK(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:Br,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 `${Ts}/${t}.md`},commandPath(t,e){return `${xs}/${t}.md`},agentPath(t,e){return Ue(e,"windsurf")?`.windsurf/skills/${B(t)}/SKILL.md`:null}}},sK={rootInstructionPath:lc,skillDir:mc,managedOutputs:{dirs:[mc,Gl,ZT],files:[lc,Ru,Cu,Eu]},rewriteGeneratedPath(t){return t===Go?lc:t.startsWith(`${Ts}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${Br}/`)?t.replace(`${Br}/`,`${mc}/`):t.startsWith(`${xs}/`)?t.replace(`${xs}/`,`${Gl}/`):t===ic?Ru:t===ac?Cu:t===sc?Eu:t},mirrorGlobalPath(t,e){return ut(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return lc},commandPath(t,e){return `${Gl}/${t}.md`},agentPath(t,e){return Ue(e,"windsurf")?`${mc}/${B(t)}/SKILL.md`:null}}},iK={rules:"native",additionalRules:"partial",commands:Er("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},Rx={id:"windsurf",generators:oK,capabilities:{rules:"native",additionalRules:"native",commands:Er("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:hx,lint:{commands:_x,mcp:Ix},project:nK,globalSupport:{capabilities:iK,detectionPaths:[lc,mc,Gl,Ru,Cu,Eu],layout:sK},buildImportPaths:mg,detectionPaths:[".windsurfrules",".windsurf"]};});function Ex(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("zed")),o=e?.body.trim()??"",n=Lt(o,r);return n?[{path:jr,content:n}]:[]}var Ox=d(()=>{fe();xi();s(Ex,"generateRules");});async function Lx(t,e,r){let o=await y(join(t,e));if(o===null)return;let n;try{n=JSON.parse(o);}catch{return}if(n===null||typeof n!="object"||Array.isArray(n))return;let a=n.context_servers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let c={};for(let[l,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,c[l]=p;}Object.keys(c).length!==0&&(await Kt(t,kx,c),r.push({fromTool:"zed",fromPath:e,toPath:kx,feature:"mcp"}));}var kx,Ax=d(()=>{w();eo();xi();kx=".agentsmesh/mcp.json";s(Lx,"importZedMcp");});async function wx(t,e={}){let r=e.scope??"project",o=[],n=await W("zed",t,r);return o.push(...await J(Lu,t,r,{normalize:n})),await Lx(t,r==="global"?bo:wo,o),o}var bx=d(()=>{gt();wt();Ax();xi();yy();s(wx,"importFromZed");});function Tx(t,e,r,o){return V(t,e,r,{checkGlobMatches:o?.scope!=="global"}).map(n=>({...n,target:"zed"}))}var xx=d(()=>{At();xi();s(Tx,"lintRules");});function Px(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 Nx(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,o=t.permissions.ask??[];return e.length===0&&r.length===0&&o.length===0?[]:[U(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function Dx(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 Fx=d(()=>{bt();s(Px,"lintHooks");s(Nx,"lintPermissions");s(Dx,"lintIgnore");});function dK(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let o=JSON.parse(e);if(o===null||typeof o!="object"||Array.isArray(o))return t;let n=o;return n.context_servers!==void 0&&(r.context_servers=n.context_servers),JSON.stringify(r,null,2)}var cK,lK,mK,pK,uK,Lu,yy=d(()=>{Ox();bx();xx();Fx();It();xi();cK={name:"zed",primaryRootInstructionPath:jr,generateRules:Ex,importFrom:wx},lK={rootInstructionPath:jr,managedOutputs:{dirs:[],files:[jr,wo]},paths:{rulePath(t){return jr},commandPath(){return null},agentPath(){return null}}},mK={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[bo]},rewriteGeneratedPath(t){return t===wo?bo:t},paths:{rulePath(){return bo},commandPath(){return null},agentPath(){return null}}},pK={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},uK={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(dK,"mergeZedSettings");Lu={id:"zed",generators:cK,capabilities:pK,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:Tx,lint:{hooks:Px,permissions:Nx,ignore:Dx},project:lK,globalSupport:{capabilities:uK,detectionPaths:[bo],layout:mK},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[jr],global:[]},canonicalDir:FC,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let r={};for(let[o,n]of Object.entries(t.mcp.mcpServers))r[o]=n;return [{path:wo,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,o){return o===wo||o===bo?dK(t,r):null},buildImportPaths:pg,detectionPaths:[jr,wo]};});var OR={};wd(OR,{BUILTIN_TARGETS:()=>Bt,TARGET_IDS:()=>yt,getBuiltinTargetDefinition:()=>pr,getEffectiveTargetSupportLevel:()=>Au,getTargetCapabilities:()=>ws,getTargetDetectionPaths:()=>Iy,getTargetLayout:()=>$t,getTargetManagedOutputs:()=>Sy,getTargetPrimaryRootInstructionPath:()=>gK,getTargetSkillDir:()=>jl,isBuiltinTargetId:()=>yr,resolveTargetFeatureGenerator:()=>pc,rewriteGeneratedOutputPath:()=>Ry});function fK(){return _y||(DS(Bt),_y=new Map(Bt.map(t=>[t.id,t]))),_y}function pr(t){return fK().get(t)}function ws(t,e="project"){let r=pr(t)??it(t);if(!r)return;let o=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return PS(o)}function Iy(t,e="project"){let r=pr(t)??it(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function $t(t,e="project"){let r=pr(t)??it(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function gK(t,e="project"){return $t(t,e)?.rootInstructionPath}function jl(t,e="project"){return $t(t,e)?.skillDir}function Sy(t,e="project"){return $t(t,e)?.managedOutputs}function Ry(t,e,r="project"){let o=$t(t,r);return o?o.rewriteGeneratedPath?o.rewriteGeneratedPath(e):e:null}function vx(t,e,r,o){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!pa(r,t.id,true,o):e==="agents"&&t.supportsConversion?.agents?!Ue(r,t.id,true,o):false}function hK(t,e,r,o){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?pa(r,t.id,true,o):e==="agents"&&t.supportsConversion?.agents?Ue(r,t.id,true,o):false}function Au(t,e,r,o="project"){let n=ws(t,o)?.[e]?.level??"none",i=pr(t)??it(t);return n==="none"&&hK(i,e,r,o)?"embedded":n!=="embedded"?n:vx(i,e,r,o)?"none":n}function pc(t,e,r,o="project"){let n=pr(t)??it(t);if(!n?.generators||vx(n,e,r,o))return;let i=yK[e];return i===null?void 0:i(n.generators)}var Bt,_y,yK,kt=d(()=>{ua();zs();De();tf();_r();uf();ug();dg();gg();BE();yg();zO();Pk();Wg();Yg();Zg();dh();Nh();Dh();vh();Wh();Hh();Vh();Yh();Qh();qh();ty();Cx();yy();Bt=[$m,gp,hp,yp,KE,_p,HO,xk,xp,Gp,jp,Xp,su,iu,cu,uu,fu,gu,hu,_u,Iu,Su,Rx,Lu];s(fK,"builtinTargetsMap");s(pr,"getBuiltinTargetDefinition");s(ws,"getTargetCapabilities");s(Iy,"getTargetDetectionPaths");s($t,"getTargetLayout");s(gK,"getTargetPrimaryRootInstructionPath");s(jl,"getTargetSkillDir");s(Sy,"getTargetManagedOutputs");s(Ry,"rewriteGeneratedOutputPath");s(vx,"isFeatureSuppressedByConversion");s(hK,"isConversionUpgrading");s(Au,"getEffectiveTargetSupportLevel");yK={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(pc,"resolveTargetFeatureGenerator");});function OK(t){return typeof t=="string"?t:t.level}function Mx(t){return EK.includes(t)}function Gx(t,e,r,o){for(let n of CK){let i=OK(e[n.feature]);if(i==="none")continue;let a=typeof t.generators[n.generator]=="function",c=Mx(n.feature)&&typeof t.emitScopedSettings=="function";a||c||r.addIssue({code:"custom",path:[...o,n.feature],message:`Capability "${n.feature}" is "${i}" but generators.${n.generator}`+(Mx(n.feature)?" or emitScopedSettings":"")+" is missing."});}}function wu(t){return LK.parse(t)}var Fn,$x,_K,IK,jx,SK,RK,CK,EK,kK,LK,Cy=d(()=>{Fn=z.union([z.enum(["native","embedded","partial","none"]),z.object({level:z.enum(["native","embedded","partial","none"]),flavor:z.string().optional()})]),$x=z.object({rules:Fn,additionalRules:Fn,commands:Fn,agents:Fn,skills:Fn,mcp:Fn,hooks:Fn,ignore:Fn,permissions:Fn}),_K=z.object({name:z.string(),generateRules:z.function(),importFrom:z.function(),generateCommands:z.function().optional(),generateAgents:z.function().optional(),generateSkills:z.function().optional(),generateMcp:z.function().optional(),generatePermissions:z.function().optional(),generateHooks:z.function().optional(),generateIgnore:z.function().optional(),lint:z.function().optional()}).passthrough(),IK=z.object({rulePath:z.function(),commandPath:z.function(),agentPath:z.function()}),jx=z.object({paths:IK}).passthrough(),SK=z.object({capabilities:$x,detectionPaths:z.array(z.string()),layout:jx,scopeExtras:z.function().optional()}).passthrough(),RK=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],CK=[{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"}],EK=["mcp","hooks","ignore","permissions"];s(OK,"capabilityLevel");s(Mx,"canUseScopedSettings");s(Gx,"validateCapabilityImplementations");kK=z.object({id:z.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:_K,capabilities:$x,emptyImportMessage:z.string(),lintRules:z.union([z.function(),z.null()]),project:jx,globalSupport:SK.optional(),buildImportPaths:z.function(),detectionPaths:z.array(z.string())}).passthrough(),LK=kK.superRefine((t,e)=>{for(let r of RK)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});Gx(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&Gx(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(wu,"validateDescriptor");});function AK(){return Ey||(Ey=new Map(Bt.map(t=>[t.id,t]))),Ey}function bu(t){let e=wu(t);Oy.set(e.id,e);}function it(t){return Oy.get(t)??AK().get(t)}function Tu(){return [...Oy.values()]}var Oy,Ey,De=d(()=>{kt();Cy();Oy=new Map;s(AK,"builtinDescriptors");s(bu,"registerTargetDescriptor");s(it,"getDescriptor");s(Tu,"getAllDescriptors");});async function Ux(t,e,r="project"){let o=new Map,n=it(t);return n&&await n.buildImportPaths(o,e,r),o}var Wx=d(()=>{De();s(Ux,"buildImportReferenceMap");});function TK(t){let e=[t.project,t.globalSupport?.layout].filter(n=>n!==void 0),r=[...t.detectionPaths,...e.flatMap(n=>n.managedOutputs?.dirs??[]),...e.flatMap(n=>n.managedOutputs?.files??[])],o=new Set;for(let n of r){let i=n.split("/")[0];i&&i.startsWith(".")&&i.length>1&&o.add(`${i}/`);}return o}function xK(){let t=new Set([".agentsmesh/"]);for(let e of Bt)for(let r of TK(e))t.add(r);return Array.from(t)}function PK(){let t=new Set([...xK(),...ky.rootRelativePrefixes]),e=new Set([...bK,...ky.meshRootSegments]);return {protectedSchemes:[...wK,...ky.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function xu(){return Ly||(Ly=PK()),Ly}var wK,bK,ky,Ly,Kx=d(()=>{kt();wK=[/\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],bK=new Set(["skills","rules","commands","agents","packs"]),ky={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(TK,"topLevelDotfilePrefixes");s(xK,"buildDefaultRootRelativePrefixes");s(PK,"rebuild");s(xu,"getLinkFormatRegistry");});function Hr(t){let e=Ot(t);return xu().rootRelativePrefixes.some(r=>e.startsWith(r))}function DK(t){let e=Ot(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Rr.test(e)||/^[a-zA-Z]:/.test(e)||Hr(e))return false;let r=e.split("/").filter(o=>o.length>0)[0];return r!==void 0&&xu().meshRootSegments.has(r)}function Ul(t,e,r){let o=X(e),n=K(e,e),i=K(e,r),a=Ot(t);if(Rr.test(t)){let c=K(e,t);return o===win32||c.startsWith(`${n}${o.sep}`)?[c]:[c]}if(o.isAbsolute(t)){let c=K(e,t);return c.startsWith(n)||existsSync(t)?[c]:[K(e,o.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let c=K(e,o.join(o.dirname(i),a)),l=wS(a,n);return l&&l!==c?[c,l]:[c]}if(Hr(a))return [K(e,o.join(n,a))];if(a.includes("/")){let c=K(e,o.join(n,".agentsmesh")),l=DK(a)?K(e,o.join(c,a)):null,m=K(e,o.join(n,a)),p=K(e,o.join(o.dirname(i),a));return l!==null?[l,m,p]:[m,p]}return FK.has(a)?[]:a.includes(".")?[K(e,o.join(o.dirname(i),a))]:[]}function Wl(t,e){let r=[e];if(!AS(t,e)||!existsSync(e))return r;try{let o=[realpathSync(e),realpathSync.native(e)];for(let n of o)n!==e&&!r.includes(n)&&r.push(n);}catch{}return r}function Vx(t,e,r){let o=e>0?t.at(e-1):"",n=r<t.length?t.at(r):"";return o==="*"||n==="*"}function Pu(t){let e=[];for(let r of xu().protectedSchemes){let o=r.flags.includes("g")?r:new RegExp(r.source,`${r.flags}g`);for(let n of t.matchAll(o))e.push([n.index??0,(n.index??0)+n[0].length]);}for(let r of t.matchAll(vK))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(MK))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(GK))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var FK,vK,MK,GK,zx,uc,Ps=d(()=>{Zt();Kx();s(Hr,"isRootRelativePathToken");s(DK,"isMeshRootRelativePathToken");FK=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),vK=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,MK=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,GK=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,zx=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,uc=/(?::(\d+)){1,2}$/;s(Ul,"resolveProjectPath");s(Wl,"expandResolvedPaths");s(Vx,"isGlobAdjacent");s(Pu,"protectedRanges");});function $K(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 Jx(t){return $K(t.tokenContext)}function Ay(t,e){let r=X(t),o=K(t,t),n=K(t,e);if(n===o)return true;let i=o.endsWith(r.sep)?o:`${o}${r.sep}`;return n.startsWith(i)}function Yx(t){let e=X(t);return K(t,e.join(t,".agentsmesh"))}function zr(t,e){let r=X(t),o=Yx(t),n=K(t,e);if(n===o)return true;let i=o.endsWith(r.sep)?o:`${o}${r.sep}`;return n.startsWith(i)}function Xx(t,e,r){let o=X(t),n=Yx(t),i=K(t,e);if(!zr(t,i))return null;let a=o.relative(n,i).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function wy(t,e,r){let n=X(t).relative(K(t,t),K(t,e)).replace(/\\/g,"/");if(n.startsWith(".."))return null;let i=n.length>0?n:".";return r&&!i.endsWith("/")?`${i}/`:i}function dc(t,e,r){let o=wy(t,e,r);return o===null?null:{kind:"projectRoot",rest:o,text:o}}function by(t,e,r,o,n){let i=X(t),a=K(t,t),c=K(t,e),l=K(t,r);if(!Ay(t,l))return dc(t,l,o)?.text??null;let m=K(t,i.dirname(c));if(!Ay(t,m)&&m!==a)return dc(t,l,o)?.text??null;let p=i.relative(m,l).replace(/\\/g,"/");if(i.isAbsolute(p)||Rr.test(p))return wy(t,l,o);let u=K(t,i.join(m,p));return Ay(t,u)?(p===""||p==="."?p=".":n.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),o&&!p.endsWith("/")?`${p}/`:p):wy(t,l,o)}var Ty=d(()=>{Zt();s($K,"isReadingContext");s(Jx,"isReadingContextOptions");s(Ay,"isUnderProjectRoot");s(Yx,"agentsMeshRoot");s(zr,"isUnderAgentsMesh");s(Xx,"toAgentsMeshRootRelative");s(wy,"toProjectRootRelative");s(dc,"toProjectRootReference");s(by,"formatLinkPathForDestinationLegacy");});function Zx(t,e,r,o,n={}){let i=n.scope??"project",a=K(t,r);if(Jx(n)&&zr(t,e)&&zr(t,a)){let m=X(t),p=K(t,t),u=m.relative(p,a).replace(/\\/g,"/");if(!u.startsWith("..")&&u.length>0)return o&&!u.endsWith("/")?`${u}/`:u}if(n.forceRelative)return by(t,e,r,o,n);if(i==="global"&&!zr(t,e))return dc(t,a,o)?.text??null;let c=(()=>{if(zr(t,a))return a;let m=n.logicalMeshSourceAbsolute;return m&&zr(t,K(t,m))?K(t,m):null})();if(!c)return dc(t,a,o)?.text??null;if(o||(n.pathIsDirectory?.(a)??false)){let m=Xx(t,c,o);return m!==null?m:dc(t,c,o)?.text??null}return by(t,e,r,o,n)}var Qx=d(()=>{Ps();Zt();Ty();Ty();s(Zx,"formatLinkPathForDestination");});function qx(t,e,r,o){let n=X(e),i=Ot(t);if(!Hr(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let c=K(e,r),l=n.dirname(c);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=K(e,n.join(l,p));if(u!==c&&o(u))return u}return null}var tP=d(()=>{Zt();Ps();s(qx,"resolveByDestinationSuffixStrip");});function eP(t){let e=null,r=false,o=null,n=null,i=null;for(let l of Ul(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of Wl(t.projectRoot,l)){let f=K(t.projectRoot,u),g=K(t.projectRoot,t.translatePath(f)),h=t.pathExists(f),C=t.pathExists(g);if(C&&g!==f){e=g,o=f,r=true;break}(h||C)&&m===null&&(m=g,p=f),e===null&&(e=g);}if(!r&&m!==null&&n===null&&(n=m,i=p),r)break}if(!r){let l=qx(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);l!==null&&(e=l,r=true);}!r&&n!==null&&(e=n,i!==null&&(o=i),r=true);let a=Ot(t.destinationFile),c=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&Ot(t.rawToken).startsWith(".agentsmesh/")&&c&&(r=true),{translatedPath:e,resolvedBeforeTranslate:o,matchedPath:r}}var rP=d(()=>{Zt();Ps();tP();s(eP,"resolveLinkTarget");});function oP(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function nP(t,e,r){if(e<=0||t[e-1]!=="(")return false;let o=e+r.length,n=t[o];return n!==")"&&n!=="#"&&n!=="?"&&n!==" "&&n!==" "?false:t[e-2]==="]"}function sP(t){let e=Ot(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Rr.test(e)||Hr(e)?false:e.includes("/")}var iP=d(()=>{Zt();Ps();s(oP,"isTildeHomeRelativePathToken");s(nP,"isMarkdownLinkDestinationToken");s(sP,"isRelativePathToken");});function jK(t,e,r){let o=e+r.length;if(t[o]!=="]"||t[o+1]!=="(")return false;let n=o+2,i="";for(;n<t.length;){let a=t[n];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
|
|
139
|
+
`)break;i+=a,n++;}return i===r}function aP(t,e,r){let o=t.lastIndexOf(`
|
|
140
|
+
`,e-1)+1,n=t.slice(o,e);if(!/^\s*\[[^\]\n]+\]:\s*<?\s*$/.test(n))return false;let i=r<t.length?t[r]:"";return i===""||i===`
|
|
141
|
+
`||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function cP(t,e,r){let o=e>0?t[e-1]:"",n=r<t.length?t[r]:"";return o==="`"&&n==="`"?{role:"inline-code"}:aP(t,e,r)?{role:"markdown-link-dest"}:o==="<"&&n===">"?{role:"bracketed"}:o==="'"&&n==="'"||o==='"'&&n==='"'?{role:"quoted"}:o==="@"?{role:"at-prefix"}:o==="("&&t[e-2]==="]"?{role:"markdown-link-dest"}:o==="["&&n==="]"?{role:"bracket-label"}:{role:"bare-prose"}}function lP(t,e,r,o,n){if(e<0||r>t.length)return false;let{candidate:i}=ma(o),a=i.replace(uc,""),c=Ot(a),l=e+a.length,m=t[e-1],p=t[r];return aP(t,e,l)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!n&&!Hr(c)&&jK(t,e,o)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":n?Hr(c)?true:c.includes("/")||c.includes("\\")?c.startsWith("./")||c.startsWith("../")?true:(c.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var mP=d(()=>{Zt();Ps();s(jK,"markdownBracketLabelDuplicatesDestination");s(aP,"isMarkdownReferenceDefinitionDestination");s(cP,"getTokenContext");s(lP,"shouldRewritePathToken");});function Nu(t){let e=new Set,r=Pu(t.content);return {content:t.content.replace(zx,(n,i,a)=>{if(r.some(([Ft,St])=>i>=Ft&&i<St)||!lP(a,i,i+n.length,n,t.rewriteBarePathTokens===true)||oP(a,i,n)||Vx(a,i,i+n.length))return n;let{candidate:c,suffix:l}=ma(n);if(!c)return n;let m=uc.exec(c),p=m?c.slice(0,m.index):c,u=m?m[0]:"";if(!p)return n;let f=cP(a,i,i+p.length);if(f.role!=="markdown-link-dest"&&Rr.test(p))return n;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:C}=eP({candidate:p,rawToken:c,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),R=h;if(!C||!g)return g&&e.add(g),n;let _=Ot(p),A=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(A&&!_.includes("/")&&!_.includes("\\"))return n;if(R===null){let Ft=Ot(c);if(Ft.startsWith("agentsmesh/")&&(Ft=`.${Ft}`),Ft.startsWith(".agentsmesh/")||Ft.includes("/.agentsmesh/")){let St=X(t.projectRoot),Wo=K(t.projectRoot,t.projectRoot),gr=Ft.replace(/^\.\//,"");R=K(t.projectRoot,St.join(Wo,gr));}}let D=X(t.projectRoot);if(t.scope==="global"){let Ft=Ot(c),St=Ft.startsWith(".agentsmesh/")||Ft.includes("/.agentsmesh/"),Wo=Hr(Ft)||sP(Ft),gr=R!==null&&zr(t.projectRoot,R),Wn=zr(t.projectRoot,g);if(R===g&&!Wn&&!gr&&!St){let _I=Ot(D.relative(t.projectRoot,K(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",dv=(R!==null?Ot(D.relative(t.projectRoot,R)):"").split("/").filter(Boolean)[0]??"";if(_I.length>0&&_I===dv)return n}if(!Wo&&!St&&!gr&&!Wn)return n}let N=K(t.projectRoot,t.destinationFile),T=K(t.projectRoot,g),rt=Ot(D.relative(t.projectRoot,N)),z=Ot(D.relative(t.projectRoot,T)),Y=rt.split("/").filter(Boolean)[0]??"",Dt=z.split("/").filter(Boolean)[0]??"",jt=!Ot(p).startsWith(".agentsmesh/")&&!A&&Y.length>0&&Y===Dt&&Y.startsWith(".")&&Y!==".agentsmesh"||f.role==="markdown-link-dest"||nP(a,i,p),Jr=Zx(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||jt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:A?null:R,forceRelative:jt,tokenContext:f,originalToken:p});return Jr?`${Jr}${u}${l}`:n}),missing:[...e]}}var xy=d(()=>{Zt();Ps();Qx();rP();iP();mP();s(Nu,"rewriteFileLinks");});function uP(t,e){let r=[t.normalize(e)];if(!existsSync(e))return r;try{let o=[realpathSync(e),realpathSync.native(e)];for(let n of o){let i=t.normalize(n);r.includes(i)||r.push(i);}}catch{}return r}async function W(t,e,r="project"){let o=X(e),n=new Map,i=Array.from(new Set([t,...yt]));for(let l of i){let m=await Ux(l,e,r);for(let[p,u]of m.entries())n.set(p,u);}let a=new Map;for(let[l,m]of n.entries()){let p=o.normalize(o.join(e,m));for(let u of uP(o,o.join(e,l)))a.set(u,p);}let c=new Set;for(let l of new Set(n.values())){let m=o.normalize(o.join(e,l));c.add(m);for(let p of uP(o,m))c.add(o.normalize(p));}return (l,m,p)=>Nu({content:l,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:s(u=>a.get(u)??u,"translatePath"),pathExists:s(u=>{let f=o.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 gt=d(()=>{Zt();Wx();xy();_r();s(uP,"pathVariants");s(W,"createImportReferenceNormalizer");});function fP(t){let e={};for(let[r,o]of Object.entries(t)){if(!Array.isArray(o))continue;let n=[];for(let i of o){if(!i||typeof i!="object")continue;let a=i,c=typeof a.matcher=="string"?a.matcher:"";if(!c)continue;let l=Array.isArray(a.hooks)?a.hooks:[];for(let m of l){let p=m.type==="prompt"?"prompt":"command";if(!Zr({...m,type:p}))continue;let u=p==="prompt"?ne(m)||vt(m):vt(m)||ne(m),f={matcher:c,type:p,command:u};typeof m.timeout=="number"&&(f.timeout=m.timeout),n.push(f);}}n.length>0&&(e[r]=n);}return e}async function gP(t,e){let r=join(t,sn),o=await y(r);if(o===null)return false;let n;try{n=JSON.parse(o);}catch{return false}if(!n||typeof n!="object"||Array.isArray(n))return false;let i=fP(n);if(Object.keys(i).length===0)return false;let a=stringify(i),c=join(t,ei);return await k(dirname(c)),await I(c,a),e.push({fromTool:"claude-code",fromPath:r,toPath:ei,feature:"hooks"}),true}async function hP(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(sn)),o=join(t,el),n=await y(o);if(!n)return;let i;try{i=JSON.parse(n);}catch{return}if(!e.some(m=>m.feature==="mcp")&&i.mcpServers&&typeof i.mcpServers=="object"){let m=i.mcpServers;await Kt(t,sl,m),e.push({fromTool:"claude-code",fromPath:o,toPath:sl,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,bf);await k(dirname(h)),await I(h,g),e.push({fromTool:"claude-code",fromPath:o,toPath:bf,feature:"permissions"});}}let l=i.hooks;if(!r&&l&&typeof l=="object"&&!Array.isArray(l)){let m=fP(l);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,ei);await k(dirname(u)),await I(u,p),e.push({fromTool:"claude-code",fromPath:o,toPath:ei,feature:"hooks"});}}}var yP=d(()=>{Sr();w();eo();an();s(fP,"claudeHooksToCanonical");s(gP,"importClaudeHooksJson");s(hP,"importSettings");});async function IP(t,e,r){let o=join(t,tl),n=join(t,wf),a=(await F(o)).filter(c=>c.endsWith("SKILL.md"));for(let c of a){let l=dirname(c),m=basename(l),p=join(n,m),u=await F(l);for(let f of u){let g=await y(f);if(g===null)continue;let h=relative(l,f),C=join(p,h);await k(dirname(C));let R=r(g,f,C),_=h==="SKILL.md"?L(R):null;await I(C,h==="SKILL.md"?await qr(C,_?.frontmatter??{},_?.body??""):R);let A=`${wf}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:f,toPath:A,feature:"skills"});}}}var SP=d(()=>{w();v();ot();an();s(IP,"importClaudeSkills");});async function Ip(t,e={}){let r=e.scope??"project",o=[],n=await W("claude-code",t,r);return o.push(...await J(_p,t,r,{normalize:n})),await IP(t,o,n),await gP(t,o),await hP(t,o),o}var _g=d(()=>{gt();wt();yP();SP();yg();s(Ip,"importFromClaudeCode");});async function Bl(t,e){let r=BK[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}var BK,Dy=d(()=>{_g();uh();Jg();Ph();jg();hy();Og();Ug();Fh();Bh();Uh();BK={"claude-code":Ip,cursor:Yp,copilot:Mp,"gemini-cli":nu,"codex-cli":wp,windsurf:ku,cline:Ep,continue:Tp,junie:au,kiro:du,"kilo-code":pu};s(Bl,"importNativeToCanonical");});async function Hi(t){if(!await M(t))return false;if(await M(join(t,vy)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await M(join(t,r.name,vy)))return !0}catch{return false}return false}async function Hl(t){if(!await M(t))return [];if(await M(join(t,vy))){let e=await SS(t);return e?[e]:[]}return ca(t)}var vy,Fu=d(()=>{w();wm();vy="SKILL.md";s(Hi,"isSkillPackLayout");s(Hl,"loadSkillsAtExtendPath");});function JK(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}function YK(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 vu(t){if(!await M(t))throw new Error(`Path does not exist: ${t}`);let e=await stat(t);if(e.isDirectory())return {sliceRoot:t};if(!e.isFile()||!t.toLowerCase().endsWith(".md"))throw new Error(`Install path must be a directory or a .md file inside rules/, commands/, or agents/: ${t}`);let r=dirname(t),o=basename(r),i=basename(t).replace(/\.md$/i,"");if(o==="rules")return {sliceRoot:r,implicitPick:{rules:[i]}};if(o==="commands")return {sliceRoot:r,implicitPick:{commands:[i]}};if(o==="agents")return {sliceRoot:r,implicitPick:{agents:[i]}};throw new Error(`Single-file install only supports .md files under rules/, commands/, or agents/. Got: ${t}`)}async function XK(t){if(basename(t)==="rules")return Us(t);let r=join(t,"rules");return await M(r)?Us(r):[]}async function ZK(t){if(basename(t)==="commands")return Ws(t);let r=join(t,"commands");return await M(r)?Ws(r):[]}async function QK(t){if(basename(t)==="agents")return Bs(t);let r=join(t,"agents");return await M(r)?Bs(r):[]}async function qK(t){if(await Hi(t))return Hl(t);let e=join(t,"skills");return await Hi(e)?Hl(e):[]}async function Mu(t){let e=join(t,".agentsmesh");if(await M(e))return Re(t);let r=JK();if(r.rules=await XK(t),r.commands=await ZK(t),r.agents=await QK(t),r.skills=await qK(t),YK(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}var My=d(()=>{w();Lm();Hs();km();Om();Fu();s(JK,"emptyCanonical");s(YK,"isCanonicalSliceEmpty");s(vu,"normalizeSlicePath");s(XK,"parseRulesAt");s(ZK,"parseCommandsAt");s(QK,"parseAgentsAt");s(qK,"loadSkillsForPartialSlice");s(Mu,"loadCanonicalSliceAtPath");});function tB(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function RP(t){let e=t.resolvedPath;if(!t.path){let n=join(e,".agentsmesh");if(!await M(n)){if(await Hi(e)){let a=await Hl(e);return {...tB(),skills:a}}let i=t.target??await Pm(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
142
|
+
Expected one of: .agentsmesh/, ${kS.join(", ")}.`);S.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await Bl(e,i);}return Re(e)}let r=join(e,t.path);if(!await M(r))throw new Error(`Extend "${t.name}": path does not exist: ${r}`);if(t.target){let n=join(e,".agentsmesh");return await M(n)||(S.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await Bl(e,t.target)),Re(e)}let{sliceRoot:o}=await vu(r);try{return await Mu(o)}catch(n){let i=n instanceof Error?n.message:String(n),a=new Error(`Extend "${t.name}": ${i}`);throw n instanceof Error&&(a.cause=n),a}}var CP=d(()=>{qd();w();lt();Hs();Dy();Fu();My();s(tB,"emptyCanonical");s(RP,"loadCanonicalForExtend");});function Gu(t,e,r,o){if(!r)return t;let n={...t};if(r.skills?.length&&e.includes("skills")){let i=new Set(r.skills),a=n.skills;n={...n,skills:a.filter(c=>i.has(c.name))};for(let c of r.skills)a.some(l=>l.name===c)||S.warn(`[agentsmesh] pick name "${c}" not found in skills from extend "${o}".`);}if(r.commands?.length&&e.includes("commands")){let i=new Set(r.commands),a=n.commands;n={...n,commands:a.filter(c=>i.has(c.name))};for(let c of r.commands)a.some(l=>l.name===c)||S.warn(`[agentsmesh] pick name "${c}" not found in commands from extend "${o}".`);}if(r.agents?.length&&e.includes("agents")){let i=new Set(r.agents),a=n.agents;n={...n,agents:a.filter(c=>i.has(c.name))};for(let c of r.agents)a.some(l=>l.name===c)||S.warn(`[agentsmesh] pick name "${c}" not found in agents from extend "${o}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=n.rules,c=s(l=>basename(l).replace(/\.md$/i,""),"stem");n={...n,rules:a.filter(l=>i.has(c(l.source)))};for(let l of r.rules)a.some(m=>c(m.source)===l)||S.warn(`[agentsmesh] pick name "${l}" not found in rules from extend "${o}".`);}return n}var $y=d(()=>{lt();s(Gu,"applyExtendPick");});var oB,fc,$u=d(()=>{oB=["rules","commands","agents","skills"],fc=z.enum(oB);});var nB,EP,OP=d(()=>{Ho();$u();nB=z.enum(["github","gitlab","git","local"]),EP=z.object({name:z.string().min(1),source:z.string().min(1),version:z.string().optional(),source_kind:nB,installed_at:z.string(),updated_at:z.string(),features:z.array(na).min(1),pick:Pc.optional(),target:je.optional(),path:z.string().optional(),paths:z.array(z.string().min(1)).min(1).optional(),as:fc.optional(),content_hash:z.string()});});function kP(t){let e=js(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 iB(t,e){return e?t.length===e.length&&[...t].sort().every((r,o)=>r===[...e].sort()[o]):true}async function ju(t){let e=join(t,"pack.yaml"),r=await y(e);if(r===null)return null;try{let o=parse(r);return EP.parse(o)}catch{return null}}async function AP(t,e,r){if(!await M(t))return null;let o=kP(e),n;try{n=await readdir(t,{withFileTypes:!0});}catch{return null}for(let i of n){if(!i.isDirectory())continue;let a=join(t,i.name),c=await ju(a);if(c&&kP(c.source)===o&&c.target===r.target&&c.as===r.as&&iB(c.features,r.features))return {meta:c,packDir:a,name:c.name}}return null}async function Uu(t){if(!await M(t))return [];let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let o of e){if(!o.isDirectory())continue;let n=join(t,o.name),i=await ju(n);i&&r.push({meta:i,packDir:n,name:i.name});}return r}var Wu=d(()=>{w();OP();Fc();s(kP,"sourceIdentity");s(iB,"sameFeatures");s(ju,"readPackMetadata");s(AP,"findExistingPack");s(Uu,"listPacks");});function wP(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function aB(t){let[e,r,o,n,i,a,c,l]=await Promise.all([Us(join(t,"rules")),Ws(join(t,"commands")),Bs(join(t,"agents")),ca(join(t,"skills")),Ir(join(t,"mcp.json")),bm(join(t,"permissions.yaml")),Tm(join(t,"hooks.yaml")),xm(join(t,"ignore"))]);return {...wP(),rules:e,commands:r,agents:o,skills:n,mcp:i,permissions:a,hooks:c,ignore:l}}async function bP(t){let e=join(t,"packs"),r=await Uu(e),o=wP();for(let{meta:n,packDir:i}of r){let a=await aB(i),c=Uy(a,n.features),l=Gu(c,n.features,n.pick,n.name);o=la(o,l);}return o}var TP=d(()=>{Om();km();Lm();wm();Gc();Vd();Yd();Xd();Qd();jo();$y();Wu();s(wP,"emptyCanonical");s(aB,"loadPackCanonical");s(bP,"loadPacksCanonical");});function Uy(t,e){if(e.length===0)return xP();let r=new Set(e.flatMap(o=>lB[o]??[]));return {rules:r.has("rules")?t.rules:[],commands:r.has("commands")?t.commands:[],agents:r.has("agents")?t.agents:[],skills:r.has("skills")?t.skills:[],mcp:r.has("mcp")?t.mcp:null,permissions:r.has("permissions")?t.permissions:null,hooks:r.has("hooks")?t.hooks:null,ignore:r.has("ignore")?t.ignore:[]}}function xP(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}async function pe(t,e,r={},o=join(e,".agentsmesh")){let n=await aa(t,e,{refreshCache:r.refreshRemoteCache===true}),i=xP();for(let l of n){let m=await RP(l),p=Uy(m,l.features),u=Gu(p,l.features,l.pick,l.name);i=la(i,u);}let a=await bP(o);i=la(i,a);let c=await Re(o);return i=la(i,c),{canonical:i,resolvedExtends:n}}var lB,jo=d(()=>{Rm();Hs();Qd();CP();$y();TP();lB={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};s(Uy,"filterCanonicalByFeatures");s(xP,"emptyCanonical");s(pe,"loadCanonicalWithExtends");});function oH(t,e){let r=join(e,"node_modules",t),o=join(r,"package.json");if(!existsSync(o))throw new Error(`Cannot find package '${t}' in ${join(e,"node_modules")}`);let n=JSON.parse(readFileSync(o,"utf-8")),i=(typeof n.exports=="string"?n.exports:null)??(typeof n.main=="string"?n.main:null)??"index.js",a=resolve(r,i);if(!existsSync(a))throw new Error(`Package '${t}' entry '${i}' does not exist at ${a}`);return a}function nH(t){return t.startsWith("file:")||t.startsWith("./")||t.startsWith("../")||t.startsWith("/")||/^[A-Za-z]:[/\\]/.test(t)}async function sH(t,e){let{source:r}=t,o;if(nH(r)){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);o=pathToFileURL(a).href;}else {let i=oH(r,e);o=pathToFileURL(i).href;}return await import(o)}function iH(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}async function td(t,e){let r;try{r=await sH(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let o=iH(r),n=[];for(let i of o)try{let a=wu(i);bu(a),n.push(a);}catch(a){throw new Error(`Plugin '${t.source}' exported an invalid descriptor: ${a instanceof Error?a.message:String(a)}`,{cause:a})}return {entry:t,descriptors:n}}async function pN(t,e){let r=[],o=process.env.AGENTSMESH_STRICT_PLUGINS==="1"||process.env.AGENTSMESH_STRICT_PLUGINS==="true",i=(await Promise.all(t.map(async a=>{try{let c=await td(a,e);return r.push(c),null}catch(c){let l=`Plugin '${a.source}' failed to load: ${c instanceof Error?c.message:String(c)}`;return a.strict===true||o?new Error(l):(S.warn(l),null)}}))).filter(a=>a!==null);if(i.length>0){let a=i.map(c=>` - ${c.message}`).join(`
|
|
143
|
+
`);throw new Error(`agentsmesh: ${i.length} plugin(s) failed strict load:
|
|
144
|
+
${a}`)}return r}var Zy=d(()=>{Cy();De();lt();s(oH,"resolveNpmSpecifier");s(nH,"isLocalSource");s(sH,"importPluginModule");s(iH,"extractDescriptors");s(td,"loadPlugin");s(pN,"loadAllPlugins");});async function oe(t,e){t.plugins.length!==0&&await pN(t.plugins,e);}var $n=d(()=>{Zy();s(oe,"bootstrapPlugins");});function t_(t,e,r="project"){let o=[],n=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,c;switch(i){case "rules":c=e.rules.length,a="rules";break;case "commands":c=e.commands.length,a=c>0?`commands (${c})`:"commands";break;case "agents":c=e.agents.length,a=c>0?`agents (${c})`:"agents";break;case "skills":c=e.skills.length,a=c>0?`skills (${c})`:"skills";break;case "mcp":c=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=c>0?`mcp (${c} servers)`:"mcp";break;case "hooks":c=bH(e.hooks),a=c>0?`hooks (${c})`:"hooks";break;case "ignore":c=e.ignore.length>0?1:0,a="ignore";break;case "permissions":c=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let l={};for(let m of n)l[m]=Au(m,i,t,r);if(o.push({feature:a,count:c,support:l}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of n)p[u]=Au(u,"additionalRules",t,r);o.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return o}function bH(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}var RN=d(()=>{kt();s(t_,"buildCompatibilityMatrix");s(bH,"countHooks");});function CN(t){return TH[t]??t}var TH,EN=d(()=>{TH={"claude-code":"Claude"};s(CN,"matrixColumnLabel");});function ON(t){return Object.fromEntries(xH.map(e=>[e,Object.fromEntries(yt.map(r=>{let n=ws(r,t)?.[e];return [r,n??{level:"none"}]}))]))}function PH(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}function NH(t,e){return PH()?e:`${t}${e}${Zl.reset}`}function LN(t){let e=e_[t];return NH(DH[t],e)}var xH,kN,e_,Zl,DH,r_=d(()=>{_r();kt();xH=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];s(ON,"buildSupportMatrix");kN=ON("project"),ON("global"),e_={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},Zl={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(PH,"noColor");s(NH,"colorize");DH={native:Zl.green,embedded:Zl.blue,partial:Zl.yellow,none:Zl.dim};s(LN,"coloredSymbol");});function o_(t,e){let r=process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!=="",o={cyan:"\x1B[36m",magenta:"\x1B[35m",bold:"\x1B[1m",dim:"\x1B[2m",green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",reset:"\x1B[0m"},n=s((z,Y)=>r?Y:`${z}${Y}${o.reset}`,"c"),i=s(z=>z.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((z,Y)=>{let Dt=i(z),Pt=Math.max(0,Y-Dt);return z+" ".repeat(Pt)},"padWithColor"),c=Math.max(12,...e.map(z=>z.length)),l=e.map(z=>CN(z)),m=Math.max(8,c),p=Math.max(12,...t.map(z=>z.feature.length)),u=s(z=>n(o.dim,"\u250C"+z.map(Y=>"\u2500".repeat(Y)).join("\u252C")+"\u2510"),"border"),f=s(z=>n(o.dim,"\u251C"+z.map(Y=>"\u2500".repeat(Y)).join("\u253C")+"\u2524"),"sep"),g=s(z=>n(o.dim,"\u2514"+z.map(Y=>"\u2500".repeat(Y)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],C=u(h),R=[a(n(o.bold+o.cyan,"Feature"),p),...l.map(z=>a(n(o.bold+o.magenta,z),m))],_=n(o.dim,"\u2502")+R.join(n(o.dim,"\u2502"))+n(o.dim,"\u2502"),A=f(h),D=t.map(z=>{let Y=[a(n(o.cyan,z.feature),p)];for(let Dt of e){let Pt=z.support[Dt]??"none",Vr=r?e_[Pt]:LN(Pt);Y.push(a(` ${Vr} `,m));}return n(o.dim,"\u2502")+Y.join(n(o.dim,"\u2502"))+n(o.dim,"\u2502")}),N=g(h),T=[C,_,A,...D,N];T.push("");let rt=[n(o.green,"\u2713")+" = native",n(o.blue,"\u25C6")+" = embedded",n(o.yellow,"\u25D0")+" = partial",n(o.dim,"\u2013")+" = not supported"];return T.push(n(o.bold,"Legend: ")+rt.join(" ")),T.join(`
|
|
145
|
+
`)}var AN=d(()=>{EN();r_();s(o_,"formatMatrix");});function s_(t){let e=[];if(t.rules.length>0&&e.push(`rules: ${t.rules.map(r=>basename(r.source)).join(", ")}`),t.commands.length>0&&e.push(`commands: ${t.commands.map(r=>basename(r.source)).join(", ")}`),t.agents.length>0&&e.push(`agents: ${t.agents.map(r=>basename(r.source)).join(", ")}`),t.skills.length>0&&e.push(`skills: ${t.skills.map(r=>r.name).join(", ")}`),t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&e.push(`mcp: ${Object.keys(t.mcp.mcpServers).join(", ")}`),t.hooks){let r=Object.values(t.hooks).reduce((o,n)=>o+(Array.isArray(n)?n.length:0),0);r>0&&e.push(`hooks: ${r} entries in hooks.yaml`);}return t.ignore.length>0&&e.push("ignore: .agentsmesh/ignore"),t.permissions&&t.permissions.allow.length+t.permissions.deny.length>0&&e.push("permissions: .agentsmesh/permissions.yaml"),e.length===0?"":`
|
|
136
146
|
Per-file details:
|
|
137
147
|
`+e.join(`
|
|
138
148
|
`)+`
|
|
139
|
-
`}var
|
|
149
|
+
`}var wN=d(()=>{s(s_,"formatVerboseDetails");});var i_=d(()=>{RN();AN();wN();});var a_={};wd(a_,{runMatrix:()=>Ql});async function Ql(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(f=>f.trim()).filter(Boolean):void 0,{config:a,context:c}=await Rt(r,o);await oe(a,r);let{canonical:l}=await pe(a,c.configDir,{},c.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=t_(a,l,o),u=s_(l);return {exitCode:0,data:{targets:m,features:p.map(f=>({name:f.feature,support:f.support}))},verboseDetails:u||void 0}}var ql=d(()=>{Ie();jo();i_();$n();s(Ql,"runMatrix");});var c_={};wd(c_,{renderMatrix:()=>tm});function tm(t,e){if(t.data.features.length===0){S.info("No features enabled. Enable features in agentsmesh.yaml.");return}let r=t.data.features.map(n=>({feature:n.name,count:0,support:n.support})),o=o_(r,t.data.targets);process.stdout.write(o),process.stdout.write(`
|
|
140
150
|
`),e?.verbose&&t.verboseDetails&&(process.stdout.write(t.verboseDetails),process.stdout.write(`
|
|
141
|
-
`));}var
|
|
142
|
-
`)}s(
|
|
151
|
+
`));}var em=d(()=>{lt();i_();s(tm,"renderMatrix");});function SI(t){let e=Object.keys(t);return {async route(r,o,n){let i=t[r];if(i){await i(o,n);return}throw new Error(`Unknown command "${r}". Available: ${e.join(", ")}`)},commands:s(()=>[...e],"commands")}}s(SI,"createRouter");lt();var OI=[{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)"}],kI=[{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 LI(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
|
|
152
|
+
`)}s(LI,"formatFlags");function AI(){let t=kI.map(e=>`- ${e.name.padEnd(8)} ${e.description}
|
|
143
153
|
Usage: ${e.usage}
|
|
144
|
-
${
|
|
154
|
+
${LI(e.flags)}`).join(`
|
|
145
155
|
|
|
146
|
-
`);
|
|
156
|
+
`);S.info(`agentsmesh <command> [flags]
|
|
147
157
|
|
|
148
158
|
Global flags:
|
|
149
|
-
${
|
|
159
|
+
${LI(OI)}
|
|
150
160
|
|
|
151
161
|
Commands:
|
|
152
162
|
${t}
|
|
153
163
|
|
|
154
|
-
Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(
|
|
155
|
-
`);}s(
|
|
156
|
-
`);}s(
|
|
157
|
-
`):
|
|
164
|
+
Tip: run "agentsmesh <command> --help" for this same command reference.`);}s(AI,"printHelp");var gm;function Iv(){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(Iv,"readPackageVersion");function Sv(){if(typeof __AGENTSMESH_VERSION__<"u")return __AGENTSMESH_VERSION__;let t=globalThis.__AGENTSMESH_VERSION__;return typeof t=="string"?t:"unknown"}s(Sv,"getVersionFallback");function bc(){return gm||(gm=Iv()??Sv(),gm)}s(bc,"getVersion");function bI(){process.stdout.write(`agentsmesh v${bc()}
|
|
165
|
+
`);}s(bI,"printVersion");lt();function ea(t,e){let r={success:e.success,command:t};e.success?r.data=e.data:(r.error=e.error,e.data!==void 0&&(r.data=e.data)),process.stdout.write(JSON.stringify(r)+`
|
|
166
|
+
`);}s(ea,"emitJson");var Yr=class extends Error{static{s(this,"CliUsageError");}constructor(e){super(e),this.name="CliUsageError";}};function TI(t,e){let r=t instanceof Yr?2:1;if(e?.json)return ea(e.command??"unknown",{success:false,error:t.message}),process.exit(r);e?.verbose&&t.stack?process.stderr.write(t.stack+`
|
|
167
|
+
`):S.error(t.message),process.exit(r);}s(TI,"handleError");lt();function _e(t,e,r,o){if(r.json===true){let n=e.exitCode===0;ea(t,n?{success:true,data:e.data}:{success:false,error:`Command '${t}' failed`,data:e.data}),process.exit(e.exitCode);return}o(),e.exitCode!==0&&process.exit(e.exitCode);}s(_e,"handleResult");Ie();jo();w();function Jl(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(Jl,"hashContent");async function Ku(t){try{let e=await readFile(t,"utf8");return Jl(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(Ku,"hashFile");Wu();var Ky=".lock",gB=[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 hB(t){return t.startsWith("packs/")?false:gB.some(e=>e(t))}s(hB,"isCanonical");var yB={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 Bu(t){let e=join(t,Ky),r=await y(e);if(r===null)return null;try{let o=parse(r);return !o||typeof o!="object"?null:{generatedAt:String(o.generated_at??""),generatedBy:String(o.generated_by??""),libVersion:String(o.lib_version??""),checksums:o.checksums&&typeof o.checksums=="object"?o.checksums:{},extends:o.extends&&typeof o.extends=="object"?o.extends:{},packs:o.packs&&typeof o.packs=="object"?o.packs:{}}}catch{return null}}s(Bu,"readLock");async function Hu(t,e){let r=join(t,Ky),o={generated_at:e.generatedAt,generated_by:e.generatedBy,lib_version:e.libVersion,checksums:e.checksums,extends:e.extends,packs:e.packs},n=`# Auto-generated. DO NOT EDIT MANUALLY.
|
|
158
168
|
# Tracks the state of all config files for team conflict resolution.
|
|
159
169
|
|
|
160
|
-
`+stringify(
|
|
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
|
-
${
|
|
170
|
+
`+stringify(o);await I(r,n);}s(Hu,"writeLock");async function Mn(t){if(!await M(t))return {};let e=await F(t),r={};for(let o of e){let n=relative(t,o).replace(/\\/g,"/");if(n===Ky||!hB(n))continue;let i=await Ku(o);i!==null&&(r[n]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(Mn,"buildChecksums");function zu(t,e,r){if(r.length===0)return [];let o=r.map(a=>yB[a]).filter(a=>a!==void 0);if(o.length===0)return [];let n=new Set([...Object.keys(t),...Object.keys(e)]),i=[];for(let a of n)o.some(c=>c(a))&&t[a]!==e[a]&&i.push(a);return i}s(zu,"detectLockedFeatureViolations");async function Vu(t){let e=await Uu(t),r={};for(let{meta:o}of e)r[o.name]=o.content_hash;return r}s(Vu,"buildPackChecksums");async function gc(t){let e={};for(let r of t){if(r.version!==void 0){e[r.name]=r.version;continue}let o=join(r.resolvedPath,".agentsmesh"),n=await Mn(o),i=Object.keys(n).sort().map(l=>`${l}:${n[l]}`).join(`
|
|
171
|
+
`),a=Jl(i),c=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${c}`;}return e}s(gc,"buildExtendChecksums");kt();De();function _B(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(_B,"addDirectoryMapping");function PP(t,e,r){let o=posix.dirname(e),n=posix.dirname(r);for(;o!==".agentsmesh/skills"&&o!==".";)_B(t,o,n),o=posix.dirname(o),n=posix.dirname(n);}s(PP,"addSkillDirectoryMappings");kt();function NP(t,e,r="project"){let o=$t(t,r);if(!o)return null;if(e.root)return o.rootInstructionPath??null;if(e.targets.length>0&&!e.targets.includes(t))return null;let n=posix.basename(e.source.replace(/\\/g,"/"),".md");return o.paths.rulePath(n,e)}s(NP,"ruleTargetPath");function DP(t,e,r,o="project"){let n=$t(t,o);return n?n.paths.commandPath(e,r):null}s(DP,"commandTargetPath");function FP(t,e,r,o="project"){let n=$t(t,o);return n?n.paths.agentPath(e,r):null}s(FP,"agentTargetPath");re();Gt();me();kt();function RB(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(RB,"addDirectoryMapping");function Yl(t,e,r,o="project"){let n=new Map;for(let a of e.rules){let c=NP(t,a,o);c&&n.set(`.agentsmesh/rules/${basename(a.source)}`,c);}for(let a of e.commands){let c=DP(t,a.name,r,o);c&&n.set(`.agentsmesh/commands/${a.name}.md`,c);}for(let a of e.agents){let c=FP(t,a.name,r,o);c&&n.set(`.agentsmesh/agents/${a.name}.md`,c);}let i=jl(t,o);if(!i)return n;for(let a of e.skills){RB(n,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),n.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let c of a.supportingFiles){let l=c.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${l}`,p=`${i}/${a.name}/${l}`;n.set(m,p),PP(n,m,p);}}return n}s(Yl,"buildReferenceMap");_r();var Gn="AGENTS.md";function CB(t){return t.target===Tc&&t.path.endsWith(Gn)}s(CB,"isCodexAgents");function vP(t){return t.target==="windsurf"&&t.path.endsWith(Gn)}s(vP,"isWindsurfAgents");function MP(t){return t.target==="cline"&&t.path.endsWith(Gn)}s(MP,"isClineAgents");function By(t){return t.target==="cursor"&&t.path.endsWith(Gn)}s(By,"isCursorAgents");function Hy(t){return t.target==="gemini-cli"&&t.path.endsWith(Gn)}s(Hy,"isGeminiAgents");function EB(t){return t.target==="kiro"&&t.path.endsWith(Gn)}s(EB,"isKiroAgents");function OB(t){return t.target==="kilo-code"&&t.path.endsWith(Gn)}s(OB,"isKiloCodeAgents");function GP(t){return t.target==="warp"&&t.path.endsWith(Gn)}s(GP,"isWarpAgents");function kB(t){return By(t)||Hy(t)}s(kB,"isCompatibilityAgents");function Yu(t,e,r,o){let n=o.get(t);if(n)return n;let i=new Map;for(let[a,c]of Yl(t,e,r))i.has(c)||i.set(c,a);return o.set(t,i),i}s(Yu,"reverseReferenceMap");function Xu(t,e){let r=[...e.entries()].sort(([n],[i])=>i.length-n.length),o=t;for(let[n,i]of r)o=o.split(n).join(i);return o}s(Xu,"normalizeContent");function LB(t,e,r,o,n){let i=Yu(t.target,r,o,n),a=Yu(e.target,r,o,n);return Xu(t.content,i)===Xu(e.content,a)}s(LB,"hasEquivalentCanonicalContent");function AB(t,e,r,o,n){let i=Yu(t.target,r,o,n),a=Yu(e.target,r,o,n),c=Xu(t.content,i).trim(),l=Xu(e.content,a).trim();return c.length>l.length&&c.includes(l)}s(AB,"hasCanonicalSupersetContent");function $P(t,e,r){let o=new Map;for(let a of t){if(!a.path.endsWith(Gn))continue;let c=o.get(a.path)??new Set;c.add(a.target),o.set(a.path,c);}let n=new Map;for(let a of t)CB(a)&&n.set(a.path,a);let i=new Map;return t.filter(a=>{if(By(a)){let l=o.get(a.path);if(l&&[...l].some(m=>m!=="cursor"))return false}if(Hy(a)){let l=o.get(a.path);if(l&&[...l].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!vP(a)&&!MP(a)&&!By(a)&&!Hy(a)&&!EB(a)&&!OB(a)&&!GP(a))return true;let c=n.get(a.path);return c?kB(a)||vP(a)||MP(a)||GP(a)?false:!(LB(c,a,e,r,i)||AB(c,a,e,r,i)):true})}s($P,"preferEquivalentCodexAgents");Zt();xy();Zt();Zt();kt();function UP(t,e,r,o){let n=o.normalize(e),i=o.normalize(r);t.set(n,i),t.set(`${n}/`,`${i}/`);}s(UP,"addPackAbsoluteDirMapping");function wB(t){let e=new Set;for(let{relativePath:r}of t){let o=r.replace(/\\/g,"/"),n=posix.dirname(o);for(;n!=="."&&n.length>0;){e.add(n);let i=posix.dirname(n);if(i===n)break;n=i;}}return [...e]}s(wB,"skillSupportingDirPrefixes");function WP(t,e,r,o,n){let i=jl(e,n);if(!i)return;let a=X(o),c=a.join(o,".agentsmesh","packs");for(let l of r.skills){let m=a.dirname(l.source);if(!m.startsWith(c))continue;let p=a.normalize(a.join(o,i,l.name));UP(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 wB(l.supportingFiles))UP(t,a.join(m,u),a.join(p,u),a);}}s(WP,"addPackSkillArtifactMappings");Zt();function bB(t){return `.agentsmesh/rules/${basename(t.source)}`}s(bB,"canonicalRulePath");function TB(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(TB,"copilotInstructionsPath");function BP(t,e,r,o,n){if(t!=="copilot"||!o?.startsWith(".github/instructions/"))return;let i=X(r);for(let a of n.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,bB(a))),i.normalize(i.join(r,TB(a))));}s(BP,"applyCopilotInstructionArtifactRefs");kt();function Zu(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Zu,"getAdditionalRootDecorationPaths");function HP(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(HP,"resolveRewriteFamilyId");function zy(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(zy,"pushUnique");function zP(t,e,r,o){let n=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);zy(n,i);let a=$t(t,o);if(e.root)for(let c of Zu(a))zy(n,c);for(let c of a?.extraRuleOutputPaths?.(e,{refs:r,scope:o})??[])zy(n,c);return n}s(zP,"extraRuleOutputPaths");kt();function VP(t,e,r,o,n,i){let a=$t(t,e);if(!a?.mirrorGlobalPath)return;let c=a.mirrorGlobalPath(r,i??[]),l=c===null?[]:Array.isArray(c)?c:[c];for(let m of l)m!==r&&n.set(m,o);}s(VP,"addSkillMirrorSourceEntry");function PB(t){return `.agentsmesh/commands/${t.name}.md`}s(PB,"canonicalCommandPath");function NB(t){return `.agentsmesh/agents/${t.name}.md`}s(NB,"canonicalAgentPath");function DB(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(DB,"canonicalSkillPath");function JP(t,e,r,o,n,i){let a=i?.scope??"project",c=X(o),l=new Map([...Yl(t,e,r,a)].map(([m,p])=>[c.normalize(c.join(o,m)),c.normalize(c.join(o,p))]));return BP(t,l,o,n,e),WP(l,t,e,o,a),l}s(JP,"buildArtifactPathMap");function YP(t,e,r,o="project",n){let i=Yl(t,e,r,o),a=new Map;for(let c of e.rules)for(let l of zP(t,c,i,o))a.set(l,c.source);for(let c of e.commands){let l=i.get(PB(c));l&&a.set(l,c.source);}for(let c of e.agents){let l=i.get(NB(c));l&&a.set(l,c.source);}for(let c of e.skills){let l=i.get(DB(c));l&&(a.set(l,c.source),VP(t,o,l,c.source,a,n));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),VP(t,o,u,m.absolutePath,a,n));}}return a}s(YP,"buildOutputSourceMap");kt();De();tf();function MB(t,e){if(!e)return null;for(let r of e){let o=it(r);if(o?.sharedArtifacts){for(let[n,i]of Object.entries(o.sharedArtifacts))if(i==="owner"&&t.startsWith(n))return r}}return null}s(MB,"findSharedArtifactOwner");function XP(t,e,r){if(e==="global"){let o=MB(t.path,r);if(o)return o;let n=NS(t.path);if(n)return n}return t.target}s(XP,"artifactMapTargetForResult");function GB(t,e){return `${t}\0${(e??[]).join(",")}`}s(GB,"sourceMapCacheKey");function Vy(t,e){let r=X(t),o=new Set;for(let n of e){let i=r.join(t,n.path);o.add(i);let a=r.dirname(i);for(;a.startsWith(t)&&!o.has(a)&&(o.add(a),a!==t);)a=r.dirname(a);}return o}s(Vy,"collectPlannedPaths");function $B(t,e,r){let o=$t(t.target,e),n=HP(o,t.path);if(n!=="default")return `${t.target}:${n}`;let i=XP(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s($B,"artifactCacheKey");function ZP(t,e,r,o,n="project",i){let a=Vy(o,t),c=new Map,l=new Map;return t.map(m=>{let p=GB(m.target,i),f=(l.get(p)??(()=>{let _=YP(m.target,e,r,n,i);return l.set(p,_),_})()).get(m.path);if(!f)return m;let g=XP(m,n,i),h=$B(m,n,i),C=c.get(h)??(()=>{let _=JP(g,e,r,o,m.path,{scope:n});return c.set(h,_),_})(),R=Nu({content:m.content,projectRoot:o,sourceFile:f,destinationFile:X(o).join(o,m.path),translatePath:s(_=>C.get(_)??_,"translatePath"),pathExists:s(_=>a.has(_)||existsSync(_),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:n,pathIsDirectory:s(_=>{try{return statSync(_).isDirectory()}catch{return false}},"pathIsDirectory")});return R.content===m.content?m:{...m,content:R.content}})}s(ZP,"rewriteGeneratedReferences");Zt();Ps();var UB=/!?\[[^\]]*\]\(([^)]+)\)/g,WB=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function KB(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(KB,"isMarkdownLikeOutput");function BB(t,e){return e.some(([r,o])=>t>=r&&t<o)}s(BB,"isOffsetInRanges");function HB(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(HB,"parseMarkdownLinkDestination");function zB(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(zB,"shouldSkipLocalValidation");function VB(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(VB,"pathExistsForGenerate");function JB(t,e,r){let n=HB(t).split("#")[0]??"",{candidate:i}=ma(n),a=i,c=uc.exec(a);c&&(a=a.slice(0,c.index));let l;try{l=decodeURIComponent(a);}catch{l=a;}if(zB(l))return [];let m=Ul(l,e,r);if(m.length===0){let u=X(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 Wl(e,u)){let g=K(e,f);p.includes(g)||p.push(g);}return p}s(JB,"resolveMarkdownLinkTargets");function YB(t,e){let r=Vy(e,t),o=[];for(let n of t){if(!KB(n.path))continue;let i=K(e,X(e).join(e,n.path)),a=Pu(n.content),c=s((l,m)=>{if(BB(m,a))return;let p=JB(l,e,i);p.length!==0&&(p.some(u=>VB(u,r))||o.push({generatePath:n.path,target:n.target,rawLink:l.trim(),checkedPaths:p}));},"visitDestination");for(let l of n.content.matchAll(UB)){let m=l[1];m!==void 0&&c(m,l.index??0);}for(let l of n.content.matchAll(WB)){let m=(l[1]??l[2]??"").trim();m&&c(m,l.index??0);}}return o}s(YB,"findBrokenMarkdownLinks");function QP(t,e){let r=YB(t,e);if(r.length===0)return;let o=r.map(n=>` ${n.generatePath} (${n.target}): "${n.rawLink}" \u2192 not found (tried: ${n.checkedPaths.join(", ")})`);throw new Error(`Generated markdown contains broken local links:
|
|
172
|
+
${o.join(`
|
|
163
173
|
`)}
|
|
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
|
-
`),
|
|
174
|
+
Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(QP,"validateGeneratedMarkdownLinks");_r();var tN="AGENTS.md";function qP(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(qP,"statusRank");function XB(t,e){return qP(e.status)<=qP(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(XB,"mergeDuplicateMetadata");function Qu(t){return t.trim()}s(Qu,"trimmedContent");function ZB(t,e){if(!t.path.endsWith(tN)||t.path!==e.path)return null;let r=Qu(t.content),o=Qu(e.content);if(!r||!o)return null;let n=r.includes(o),i=o.includes(r);return n===i?null:n?t:e}s(ZB,"richerAgentsResult");function QB(t,e){if(!t.path.endsWith(tN)||t.path!==e.path)return null;let r=t.target===Tc?t:e.target===Tc?e:null,o=r===t?e:t;if(!r)return null;let n=Qu(r.content).length,i=Qu(o.content).length;return n===i?null:n>i?r:o}s(QB,"richerCodexAgentsResult");function qu(t){let e=[];for(let r of t){let o=e.findIndex(i=>i.path===r.path);if(o===-1){e.push(r);continue}let n=e[o];if(n.content!==r.content){let i=ZB(n,r);if(i){e[o]=i;continue}let a=QB(n,r);if(a){e[o]=a;continue}throw new Error(`Conflicting generated outputs for ${r.path}: ${n.target} and ${r.target} produce different content.`)}e[o]=XB(n,r);}return e}s(qu,"resolveOutputCollisions");function eN(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(eN,"refreshResultStatus");w();kt();De();function oN(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(oN,"computeStatus");function qB(t,e,r){let o=Ry(t,e,r);if(o!==null)return o;let n=it(t);if(!n)return null;let i=r==="global"?n.globalSupport?.layout:n.project;return i?(o=i.rewriteGeneratedPath?i.rewriteGeneratedPath(e):e,o):null}s(qB,"resolveGeneratedOutputPath");async function Xl(t,e,r,o,n,i){let a=qB(e,r.path,n);if(a===null)return null;let c=await y(join(o,a)),l=t.findIndex(u=>u.path===a&&u.target===e),m=l>=0?t[l]:void 0,p=i?.mergeContent?.(c,m,r.content,a)??r.content;return l>=0&&t.splice(l,1),t.push({target:e,path:a,content:p,currentContent:c??void 0,status:oN(c,p)}),a}s(Xl,"emitGeneratedOutput");function Jy(t,e,r){return {capability:ws(t,r)?.[e]??{level:"none"},scope:r}}s(Jy,"featureContext");async function zi(t,e,r,o,n,i,a,c){if(n)for(let l of e){let m=c(l);if(!m)continue;let p=Jy(l,a,i);for(let u of m(r,p)){let f=await Xl(t,l,u,o,i);if(f===null)continue;let g=$t(l,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(f,e),C=h===null?[]:Array.isArray(h)?h:[h];for(let R of C){let _=await y(join(o,R));t.push({target:l,path:R,content:u.content,currentContent:_??void 0,status:oN(_,u.content)});}}}}}s(zi,"generateFeature");sf();kt();function tH(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Zu(t)]:[]}s(tH,"rootDecorationPaths");function nN(t,e,r="project"){return t.map(o=>{let n=$t(o.target,r);if(!n)return o;let i=tH(n);if(i.length===0||!i.includes(o.path))return o;let c=o.path===n.rootInstructionPath&&n.renderPrimaryRootInstruction?n.renderPrimaryRootInstruction(e):o.content,l=WS(c);return l===o.content?o:{...o,content:l}})}s(nN,"decoratePrimaryRootInstructions");kt();De();Up();function Yy(t,e,r,o,n){let a=(pr(t)??it(t))?.mergeGeneratedOutputContent?.(e,r,o,n);if(a!=null)return a;let c=r?.content??e;return c!==null&&eA.includes(n)?rA(c,o):o}s(Yy,"mergeOutputContent");async function sN(t,e,r,o,n){for(let i of e){let a=pc(i,"permissions",void 0,n)??it(i)?.generators.generatePermissions;if(a)for(let c of a(r))await Xl(t,i,c,o,n,{mergeContent:s((l,m,p,u)=>Yy(i,l,m,p,u),"mergeContent")});}}s(sN,"generatePermissionsFeature");async function iN(t,e,r,o,n,i){for(let a of e){let c=pc(a,"hooks",i,n)??it(a)?.generators.generateHooks;if(!c)continue;let l=Jy(a,"hooks",n),m=[...c(r,l)],u=(pr(a)??it(a))?.postProcessHookOutputs;u&&(m=[...await u(o,r,m)]);for(let f of m)await Xl(t,a,f,o,n,{mergeContent:s((g,h,C,R)=>Yy(a,g,h,C,R),"mergeContent")});}}s(iN,"generateHooksFeature");async function aN(t,e,r,o,n){for(let i of e){let c=(pr(i)??it(i))?.emitScopedSettings;if(!c)continue;let l=c(r,n);if(l.length!==0)for(let m of l)await Xl(t,i,m,o,n,{mergeContent:s((p,u,f,g)=>Yy(i,p,u,f,g),"mergeContent")});}}s(aN,"generateScopedSettingsFeature");async function dr(t){let{config:e,canonical:r,projectRoot:o,scope:n="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],c=i?a.filter(T=>i.includes(T)):a;function l(T,rt){return pc(T,rt,e,n)}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"),C=e.features.includes("hooks"),R=e.features.includes("ignore"),_=[];await zi(_,c,r,o,m,n,"rules",T=>l(T,"rules")),await zi(_,c,r,o,p,n,"commands",T=>l(T,"commands")),await zi(_,c,r,o,u,n,"agents",T=>l(T,"agents")),await zi(_,c,r,o,f,n,"skills",T=>l(T,"skills")),await zi(_,c,r,o,g,n,"mcp",T=>l(T,"mcp")),h&&await sN(_,c,r,o,n),C&&await iN(_,c,r,o,n,e),await zi(_,c,r,o,R,n,"ignore",T=>l(T,"ignore"));let A=new Set(e.features);for(let T of c){let z=(pr(T)??it(T))?.globalSupport?.scopeExtras;if(z){let Y=await z(r,o,n,A);_.push(...Y);}}(g||R||C||u||h)&&await aN(_,c,r,o,n);let D=nN(_,r,n),N=ZP(D,r,e,o,n,c);return QP(N,o),qu($P(N.map(eN),r,e))}s(dr,"generate");$n();lt();w();Bo();var dH=6e4,fH=30,gH=200,hH=2e3;async function gN(t,e={}){let r=e.retries??fH,o=e.retryDelayMs??gH,n=e.staleMs??dH;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await yH(t);if(a)return a;let c=await _H(t);if(c!=="young"&&IH(c,n)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let l=c==="young"?null:c;throw new oa(t,RH(l))}i++,await EH(o);}}s(gN,"acquireProcessLock");async function yH(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:hN()};await writeFile(e,JSON.stringify(r),"utf-8");let o=false,n=s(()=>{if(!o){o=true;try{rmSync(t,{recursive:!0,force:!0});}catch{}}},"signalHandler");return process.once("SIGINT",n),process.once("SIGTERM",n),process.once("exit",n),async()=>{o||(o=true,process.off("SIGINT",n),process.off("SIGTERM",n),process.off("exit",n),await rm$1(t,{recursive:true,force:true}).catch(()=>{}));}}s(yH,"tryAcquire");async function _H(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return CH(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<hH)return "young"}catch{}return null}}s(_H,"inspectLock");function IH(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==hN()?false:!SH(t.pid)}s(IH,"isStale");function SH(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(SH,"isProcessAlive");function RH(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(RH,"describeHolder");function CH(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(CH,"isLockMetadata");function hN(){return hostname()}s(hN,"getHostname");function EH(t){return new Promise(e=>setTimeout(e,t))}s(EH,"sleep");w();kt();async function yN(t,e=t){let r=await readdir(t,{withFileTypes:true}),o=[];for(let n of r){let i=join(t,n.name);if(n.isDirectory()){o.push(...await yN(i,e));continue}o.push(relative(e,i).replace(/\\/g,"/"));}return o}s(yN,"listFiles");async function AH(t,e,r){if(r.has(e))return;let o=join(t,e);await M(o)&&await rm$1(o,{recursive:true,force:true});}s(AH,"removeIfStale");async function _N(t){let e=new Set(t.expectedPaths),r=new Set,o=t.scope??"project";for(let n of t.targets){let i=Sy(n,o);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let c=join(t.projectRoot,a);if(await M(c))for(let l of await yN(c))r.add(`${a}/${l}`.replace(/\/+/g,"/"));}}}for(let n of r)await AH(t.projectRoot,n,e);}s(_N,"cleanupStaleGeneratedOutputs");function hc(t,e,r){let o=resolve(t),n=resolve(t,e);if(n===o||n.startsWith(`${o}${sep}`))return n;throw new Error(`Unsafe generated output path for ${r}: ${e}`)}s(hc,"ensurePathInsideRoot");vc();w();lt();async function qy(t,e){let r=await Mn(t.canonicalDir),o=e.length>0?await gc(e):{},n=await Vu(join(t.canonicalDir,"packs")),i=process.env.USER??process.env.USERNAME??"unknown";await Hu(t.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:i,libVersion:bc(),checksums:r,extends:o,packs:n});try{await Pd(Se(),join(t.configDir,".agentsmeshcache"));}catch(a){S.warn(`Could not create .agentsmeshcache symlink: ${a instanceof Error?a.message:String(a)}`);}}s(qy,"writeLockFile");async function bN(t){let{mode:e,scope:r,dryRun:o,context:n,resolvedExtends:i,flags:a,root:c,options:l}=t;if(e==="check")return {exitCode:0,data:{scope:r,mode:e,files:[],summary:ed([])}};if(o||await qy(n,i),l.printMatrix!==false){let{runMatrix:m}=await Promise.resolve().then(()=>(ql(),a_)),{renderMatrix:p}=await Promise.resolve().then(()=>(em(),c_)),u=await m(a,c);p(u,{verbose:a.verbose===true});}return {exitCode:0,data:{scope:r,mode:e,files:[],summary:ed([])}}}s(bN,"handleEmptyResults");function TN(t,e){let r=t.filter(a=>a.status!=="skipped"),o=r.filter(a=>a.status!=="unchanged"),n=r.map(a=>({path:a.path,target:a.target,status:a.status}));return {exitCode:o.length===0?0:1,data:{scope:e,mode:"check",files:n,summary:ed(r)}}}s(TN,"buildCheckResult");async function xN(t){let{results:e,dryRun:r,scope:o,mode:n,context:i,activeTargets:a,resolvedExtends:c,flags:l,root:m,options:p}=t,u=r?null:await gN(join(i.canonicalDir,".generate.lock"));try{if(!r){for(let h of e)if(h.status==="created"||h.status==="updated"){let C=hc(i.rootBase,h.path,h.target);await I(C,h.content);}await _N({projectRoot:i.rootBase,targets:a,expectedPaths:e.map(h=>h.path),scope:o}),await qy(i,c);}}finally{u&&await u();}if(p.printMatrix!==false){let{runMatrix:h}=await Promise.resolve().then(()=>(ql(),a_)),{renderMatrix:C}=await Promise.resolve().then(()=>(em(),c_)),R=await h(l,m);C(R,{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:o,mode:n,files:g,summary:ed(f)}}}s(xN,"handleGenerateOrDryRun");function ed(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(ed,"buildSummary");async function yc(t,e,r={}){if(t.features!==void 0)throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");let o=e??process.cwd(),n=t.check===true,i=t["dry-run"]===true,a=t.force===true,c=t.global===true?"global":"project",l=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(N=>N.trim()).filter(Boolean):void 0,u=n?"check":i?"dry-run":"generate",{config:f,context:g}=await Rt(o,c);await oe(f,o);let h=f.collaboration?.lock_features??[];if(f.collaboration?.strategy==="lock"&&!a&&h.length>0){let N=await Bu(g.canonicalDir);if(N!==null){let T=await Mn(g.canonicalDir),rt=zu(N.checksums,T,h);if(rt.length>0){S.error("Locked feature violation (strategy: lock). Modified files:");for(let z of rt)S.error(` ${z}`);throw S.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:C,resolvedExtends:R}=await pe(f,g.configDir,{refreshRemoteCache:l},g.canonicalDir),_=[...f.targets,...f.pluginTargets??[]];if(p){let N=p.filter(T=>!_.includes(T));if(N.length>0)throw new Error(`Unknown target(s) in --targets: ${N.join(", ")}. Available: ${_.join(", ")}`)}let A=p?_.filter(N=>p.includes(N)):_,D=await dr({config:f,canonical:C,projectRoot:g.rootBase,scope:c,targetFilter:p});return D.length===0?bN({mode:u,scope:c,dryRun:i,context:g,resolvedExtends:R,flags:t,root:o,options:r}):n?TN(D,c):xN({results:D,dryRun:i,scope:c,mode:u,context:g,activeTargets:A,resolvedExtends:R,flags:t,root:o,options:r})}s(yc,"runGenerate");lt();function l_(t,e){return t==="global"?`~/${e}`:e}s(l_,"formatDisplayPath");function _c(t){let{data:e}=t,{scope:r,mode:o,files:n}=e;if(n.length===0){S.info("No files to generate (no root rule or rules feature disabled)."),o==="check"&&S.success("Generated files are in sync.");return}if(o==="check"){let l=n.filter(m=>m.status!=="unchanged");if(l.length===0){S.success("Generated files are in sync.");return}for(let m of l)S.error(`[check] ${m.status} ${l_(r,m.path)} (${m.target})`);S.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");return}if(o==="dry-run"){for(let l of n)S.info(`[dry-run] ${l.status} ${l_(r,l.path)} (${l.target})`);return}for(let l of n)(l.status==="created"||l.status==="updated")&&S.success(`${l.status} ${l_(r,l.path)}`);let{created:i,updated:a,unchanged:c}=e.summary;i>0||a>0?S.info(`Generated: ${i} created, ${a} updated, ${c} unchanged`):S.info(`Nothing changed. (${c} unchanged)`);}s(_c,"renderGenerate");w();kt();_r();var vH=["codex-cli"];function PN(){return yt.filter(t=>!vH.includes(t))}s(PN,"starterInitTargetIds");var MH=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],GH=PN();function rd(t,e=GH){let r=(t.length>0?t:e).map(n=>` - ${n}`).join(`
|
|
175
|
+
`),o=MH.map(n=>` - ${n}`).join(`
|
|
166
176
|
`);return `# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
167
177
|
version: 1
|
|
168
178
|
targets:
|
|
169
179
|
${r}
|
|
170
180
|
features:
|
|
171
|
-
${
|
|
172
|
-
`}s(
|
|
181
|
+
${o}
|
|
182
|
+
`}s(rd,"buildConfig");var od=`---
|
|
173
183
|
root: true
|
|
174
184
|
description: "Project rules"
|
|
175
185
|
---
|
|
@@ -178,7 +188,7 @@ description: "Project rules"
|
|
|
178
188
|
|
|
179
189
|
Add your project-wide instructions here.
|
|
180
190
|
This file is always included in AI tool context and synced to all configured tools.
|
|
181
|
-
`,
|
|
191
|
+
`,m_=`---
|
|
182
192
|
description: "Example contextual rule \u2014 rename and customize"
|
|
183
193
|
# targets: [claude-code, cursor] # limit to specific tools (optional)
|
|
184
194
|
# globs: ["src/**/*.ts"] # activate only for matching files (optional)
|
|
@@ -187,14 +197,14 @@ description: "Example contextual rule \u2014 rename and customize"
|
|
|
187
197
|
# Example Rule
|
|
188
198
|
|
|
189
199
|
Replace this with your coding standards, conventions, or domain-specific guidelines.
|
|
190
|
-
`,
|
|
200
|
+
`,p_=`---
|
|
191
201
|
description: "Example command \u2014 rename and customize"
|
|
192
202
|
# allowed-tools: [Read, Grep, Glob, Bash]
|
|
193
203
|
---
|
|
194
204
|
|
|
195
205
|
Describe the task for this command here.
|
|
196
206
|
Commands are invoked on-demand (e.g. /example) with a focused tool set.
|
|
197
|
-
`,
|
|
207
|
+
`,u_=`---
|
|
198
208
|
name: example-agent
|
|
199
209
|
description: "Example subagent \u2014 rename and customize"
|
|
200
210
|
# tools: [Read, Grep, Glob]
|
|
@@ -205,7 +215,7 @@ description: "Example subagent \u2014 rename and customize"
|
|
|
205
215
|
|
|
206
216
|
Describe this agent's role and instructions here.
|
|
207
217
|
Agents are specialized subagents with restricted tools and a specific purpose.
|
|
208
|
-
`,
|
|
218
|
+
`,d_=`---
|
|
209
219
|
name: example-skill
|
|
210
220
|
description: "Example skill \u2014 rename and customize"
|
|
211
221
|
---
|
|
@@ -214,7 +224,7 @@ description: "Example skill \u2014 rename and customize"
|
|
|
214
224
|
|
|
215
225
|
Describe the skill procedure here.
|
|
216
226
|
Skills are reusable multi-step procedures that commands and agents can reference.
|
|
217
|
-
`,
|
|
227
|
+
`,f_=`{
|
|
218
228
|
"mcpServers": {
|
|
219
229
|
// agentsmesh self-serve MCP server \u2014 exposes your canonical config to AI agents.
|
|
220
230
|
// Lets agents introspect rules/commands/agents/skills and trigger generate.
|
|
@@ -241,7 +251,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
241
251
|
// }
|
|
242
252
|
}
|
|
243
253
|
}
|
|
244
|
-
`,
|
|
254
|
+
`,g_=`# Lifecycle hooks \u2014 run shell commands before/after AI tool use
|
|
245
255
|
# Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
|
|
246
256
|
# Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
|
|
247
257
|
#
|
|
@@ -254,7 +264,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
254
264
|
# - matcher: Edit|Write
|
|
255
265
|
# type: command
|
|
256
266
|
# command: npm test --passWithNoTests
|
|
257
|
-
`,
|
|
267
|
+
`,h_=`# Tool permission allow/deny lists
|
|
258
268
|
#
|
|
259
269
|
# allow:
|
|
260
270
|
# - Bash(npm run:*)
|
|
@@ -270,14 +280,14 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
270
280
|
allow: []
|
|
271
281
|
deny: []
|
|
272
282
|
ask: []
|
|
273
|
-
`,
|
|
283
|
+
`,y_=`# Patterns ignored by all configured AI tools (gitignore syntax)
|
|
274
284
|
#
|
|
275
285
|
# node_modules/
|
|
276
286
|
# dist/
|
|
277
287
|
# .env*
|
|
278
288
|
# *.log
|
|
279
289
|
# coverage/
|
|
280
|
-
`,
|
|
290
|
+
`,NN=`# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
281
291
|
# Personal overrides \u2014 NOT committed to git
|
|
282
292
|
# Uncomment and customize for your local setup:
|
|
283
293
|
|
|
@@ -296,40 +306,27 @@ ask: []
|
|
|
296
306
|
# overrides:
|
|
297
307
|
# claude-code:
|
|
298
308
|
# model: opus
|
|
299
|
-
`;
|
|
300
|
-
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),
|
|
309
|
+
`;w();kt();function DN(t){let e=[];for(let r of Bt)for(let o of Iy(r.id,t))e.push({target:r.id,path:o});return e}s(DN,"collectDetectionPaths");function FN(t){let e=new Map;for(let{target:r,path:o}of DN(t)){let n=e.get(r)??[];n.push(o),e.set(r,n);}return [...e.entries()].map(([r,o])=>({id:r,paths:o}))}s(FN,"toolIndicators");FN("project");async function vN(t,e="project"){let r=[];for(let{id:o,paths:n}of FN(e))for(let i of n){let a=join(t,i);if(await M(a)){r.push(o);break}}return [...new Set(r)]}s(vN,"detectExistingConfigs");w();lt();function Yt(t,e){return join(t,e)}s(Yt,"ab");async function __(t){return await M(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(__,"countMdFiles");async function jH(t){let e=Yt(t,"skills");if(!await M(e))return false;let r=await readdir(e,{withFileTypes:true});for(let o of r)if(o.isDirectory()&&!o.name.startsWith("_")&&await M(join(e,o.name,"SKILL.md")))return true;return false}s(jH,"hasAnyImportedSkill");async function I_(t){let e=Yt(t,"rules");await k(e),await I(join(e,"_root.md"),od),S.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),m_),S.success("Created .agentsmesh/rules/_example.md");let r=Yt(t,"commands");await k(r),await I(join(r,"_example.md"),p_),S.success("Created .agentsmesh/commands/_example.md");let o=Yt(t,"agents");await k(o),await I(join(o,"_example.md"),u_),S.success("Created .agentsmesh/agents/_example.md");let n=Yt(t,join("skills","_example"));await k(n),await I(join(n,"SKILL.md"),d_),S.success("Created .agentsmesh/skills/_example/SKILL.md"),await I(Yt(t,"mcp.json"),f_),S.success("Created .agentsmesh/mcp.json"),await I(Yt(t,"hooks.yaml"),g_),S.success("Created .agentsmesh/hooks.yaml"),await I(Yt(t,"permissions.yaml"),h_),S.success("Created .agentsmesh/permissions.yaml"),await I(Yt(t,"ignore"),y_),S.success("Created .agentsmesh/ignore");}s(I_,"writeScaffoldFull");async function GN(t){let e=Yt(t,"rules"),r=await __(e),o=join(e,"_root.md"),n=await M(o);await k(e),r===0?(await I(o,od),S.success("Created .agentsmesh/rules/_root.md"),await I(join(e,"_example.md"),m_),S.success("Created .agentsmesh/rules/_example.md")):n||(await I(o,od),S.success("Created .agentsmesh/rules/_root.md"));let i=Yt(t,"commands");await __(i)===0&&(await k(i),await I(join(i,"_example.md"),p_),S.success("Created .agentsmesh/commands/_example.md"));let a=Yt(t,"agents");if(await __(a)===0&&(await k(a),await I(join(a,"_example.md"),u_),S.success("Created .agentsmesh/agents/_example.md")),!await jH(t)){let u=Yt(t,join("skills","_example"));await k(u),await I(join(u,"SKILL.md"),d_),S.success("Created .agentsmesh/skills/_example/SKILL.md");}let c=Yt(t,"mcp.json");await M(c)||(await I(c,f_),S.success("Created .agentsmesh/mcp.json"));let l=Yt(t,"hooks.yaml");await M(l)||(await I(l,g_),S.success("Created .agentsmesh/hooks.yaml"));let m=Yt(t,"permissions.yaml");await M(m)||(await I(m,h_),S.success("Created .agentsmesh/permissions.yaml"));let p=Yt(t,"ignore");await M(p)||(await I(p,y_),S.success("Created .agentsmesh/ignore"));}s(GN,"writeScaffoldGapFill");Ie();var S_="agentsmesh.yaml",$N="agentsmesh.local.yaml",WH=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],KH=Object.fromEntries(Bt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),jN=Bt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function BH(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(BH,"isCoveredByExisting");async function HH(t){let e=join(t,".gitignore"),r=await y(e)??"",o=new Set(r.split(`
|
|
310
|
+
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),n=WH.filter(a=>!BH(a,o));if(n.length===0)return false;let i=r.endsWith(`
|
|
301
311
|
`)||r===""?"":`
|
|
302
|
-
`;return await
|
|
312
|
+
`;return await I(e,r+i+n.join(`
|
|
303
313
|
`)+`
|
|
304
|
-
`),true}s(
|
|
305
|
-
`;await mkdir(dirname(e),{recursive:!0});let
|
|
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){
|
|
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(`
|
|
314
|
+
`),true}s(HH,"appendToGitignore");async function UN(t,e={}){let r=e.global===true?"global":"project",o=Nc(t,r),n=join(o.configDir,S_);if(await M(n))throw new Error(`Already initialized. ${S_} exists. Remove it first to re-init.`);let i=await vN(o.rootBase,r),a=r==="global"?i.filter(g=>jN.includes(g)):i,c=r==="global"?jN:void 0,l=[],m,p=0;if(a.length>0)if(e.yes){for(let g of a){let h=KH[g];if(!h)continue;let C=await h(o.rootBase,r);for(let R of C)l.push({from:relative(o.rootBase,R.fromPath).replaceAll("\\","/"),to:R.toPath.replaceAll("\\","/")});}p=a.length,await GN(o.canonicalDir),m="gap-fill",await I(n,rd(a,c));}else await I_(o.canonicalDir),m="full",await I(n,rd([],c));else await I_(o.canonicalDir),m="full",await I(n,rd([],c));let u=join(o.configDir,$N);await I(u,NN);let f=false;return r==="project"&&(f=await HH(t)),{exitCode:0,data:{scope:r,configFile:S_,localConfigFile:$N,detectedConfigs:a,imported:l,importedToolCount:p,scaffoldType:m,gitignoreUpdated:f}}}s(UN,"runInit");lt();function WN(t){let{data:e}=t;if(e.detectedConfigs.length>0&&S.info(`Found existing configurations: ${e.detectedConfigs.join(", ")}`),e.detectedConfigs.length>0&&e.imported.length===0&&S.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),e.imported.length>0){S.info("Auto-importing existing configurations (--yes)...");for(let o of e.imported)S.success(` ${o.from} \u2192 ${o.to}`);S.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(", ")})`:"";S.success(`Created ${e.configFile}${r}`),S.success(`Created ${e.localConfigFile}`),e.gitignoreUpdated&&S.success("Updated .gitignore");}s(WN,"renderInit");Ie();kt();var zH=Object.fromEntries(Bt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function nd(t){let e=zH[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}s(nd,"getTargetCatalogEntry");De();$n();Gc();var QH={type:"stdio",command:"npx",args:["-y","agentsmesh","mcp"]};function qH(t){return t.mcpServers.agentsmesh!==void 0?false:(t.mcpServers.agentsmesh=QH,true)}s(qH,"injectAgentsmeshEntry");async function C_(t){let e=resolve(t,".agentsmesh/mcp.json");try{let r;try{r=await Ir(e)??{mcpServers:{}};}catch{r={mcpServers:{}};}if(!qH(r))return !1;let o=JSON.stringify(r,null,2)+`
|
|
315
|
+
`;await mkdir(dirname(e),{recursive:!0});let n=`${e}.tmp.${process.pid}.${Date.now()}`;return await writeFile(n,o,"utf8"),await rename(n,e),!0}catch(r){return process.stderr.write(`[agentsmesh] warning: could not seed agentsmesh MCP server entry into mcp.json: ${r instanceof Error?r.message:String(r)}
|
|
316
|
+
`),false}}s(C_,"seedAgentsmeshMcpEntry");function KN(t,e){return t.map(r=>({from:relative(e,r.fromPath).replaceAll("\\","/"),to:r.toPath}))}s(KN,"mapResults");async function BN(t,e){let r=e??process.cwd(),o=t.from;if(typeof o!="string"||!o)throw new Error("--from is required. Example: agentsmesh import --from claude-code");let n=o.toLowerCase().trim(),i=t.global===true?"global":"project";if(yr(n)){let p=Nc(r,i),f=await nd(n).importFrom(p.rootBase,{scope:i});return f.length>0&&await C_(p.rootBase),{exitCode:0,data:{scope:i,target:n,files:KN(f,p.rootBase)}}}let a,c;try{({config:a,context:c}=await Rt(r,i));}catch{throw new Error(`Unknown --from "${o}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${yt.join(", ")}.`)}await oe(a,r);let l=it(n);if(!l)throw new Error(`Unknown --from "${o}". Supported: ${[...yt,...a.pluginTargets??[]].join(", ")}.`);let m=await l.generators.importFrom(c.rootBase,{scope:i});return m.length>0&&await C_(c.rootBase),{exitCode:0,data:{scope:i,target:n,files:KN(m,c.rootBase)}}}s(BN,"runImport");Ie();jo();function sd(t){let e=[],r={new:0,updated:0,unchanged:0,deleted:0};for(let o of t){if(o.status==="unchanged"){r.unchanged++;continue}if(o.status==="created"){r.new++;let n=createTwoFilesPatch(`${o.path} (current)`,`${o.path} (generated)`,"",o.content,void 0,void 0,{context:3});e.push({path:o.path,patch:n});continue}if(o.status==="updated"&&o.currentContent!==void 0){r.updated++;let n=createTwoFilesPatch(`${o.path} (current)`,`${o.path} (generated)`,o.currentContent,o.content,void 0,void 0,{context:3});e.push({path:o.path,patch:n});continue}}return {diffs:e,summary:r}}s(sd,"computeDiff");function id(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(id,"formatDiffSummary");$n();async function zN(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(g=>g.trim()).filter(Boolean):void 0,{config:a,context:c}=await Rt(r,o);await oe(a,r);let{canonical:l}=await pe(a,c.configDir,{},c.canonicalDir),m=await dr({config:a,canonical:l,projectRoot:c.rootBase,scope:o,targetFilter:i});if(m.length===0)return {exitCode:0,data:{files:[],patches:[],summary:{created:0,updated:0,unchanged:0,deleted:0}}};let{diffs:p,summary:u}=sd(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(zN,"runDiff");Ie();jo();w();De();zs();bt();var ez=[{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 VN(t){let e=new Set(t.enabledFeatures),r=[];for(let o of ez)!e.has(o.featureFlag)||!o.hasContent(t.canonical)||Cr(t.capabilities[o.capabilityKey]).level!=="none"||r.push(U(o.file,t.target,`${t.target} does not support ${o.label}; canonical entries are silently dropped during generation. Disable the feature for this target or remove the canonical content.`));return r}s(VN,"lintSilentFeatureDrops");bt();var rz=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function oz(t){let r=t.match(rz)?.groups?.path;return typeof r=="string"?r:null}s(oz,"extractScriptToken");function JN(t){if(t.hasScriptProjection)return [];let e=t.canonical.hooks;if(!e)return [];let r=[];for(let o of Object.values(e))if(Array.isArray(o))for(let n of o){if(typeof n?.command!="string")continue;let i=oz(n.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(JN,"lintHookScriptReferences");bt();function YN(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(YN,"lintRuleScopeInversion");var nz=["node_modules",".git","dist","coverage",".agentsmesh"];async function sz(t){return (await F(t)).filter(o=>{let n=relative(t,o);return !nz.some(i=>n.includes(`/${i}/`)||n.startsWith(`${i}/`))}).map(o=>relative(t,o))}s(sz,"getProjectFiles");async function ad(t,e,r,o,n={}){let i=n.scope??"project",a=[...t.targets,...t.pluginTargets??[]],c=o?a.filter(R=>o.includes(R)):a,l=t.features.includes("rules"),m=t.features.includes("commands"),p=t.features.includes("mcp"),u=t.features.includes("permissions"),f=t.features.includes("hooks"),g=[],h=i==="global"?[]:await sz(r);for(let R of c){let _=it(R),A=yr(R)?nd(R):_;A?.capabilities&&g.push(...VN({target:R,capabilities:A.capabilities,canonical:e,enabledFeatures:t.features})),f&&g.push(...JN({target:R,canonical:e,hasScriptProjection:_?.postProcessHookOutputs!==void 0})),l&&g.push(...YN({target:R,canonical:e,preservesManualActivation:_?.preservesManualActivation===true})),l&&A?.lintRules&&g.push(...A.lintRules(e,r,h,{scope:i})),_?.generators.lint&&g.push(..._.generators.lint(e));let D={scope:i};m&&A?.lint?.commands&&g.push(...A.lint.commands(e,D)),p&&A?.lint?.mcp&&g.push(...A.lint.mcp(e,D)),u&&A?.lint?.permissions&&g.push(...A.lint.permissions(e,D)),f&&A?.lint?.hooks&&g.push(...A.lint.hooks(e,D));}let C=g.some(R=>R.level==="error");return {diagnostics:g,hasErrors:C}}s(ad,"runLint");$n();async function ZN(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=t.targets,i=typeof n=="string"&&n?n.split(",").map(u=>u.trim()).filter(Boolean):void 0,{config:a,context:c}=await Rt(r,o);await oe(a,r);let{canonical:l}=await pe(a,c.configDir,{},c.canonicalDir),{diagnostics:m,hasErrors:p}=await ad(a,l,c.configDir,i,{scope:o});return {exitCode:p?1:0,data:{diagnostics:m.map(u=>({level:u.level,file:u.file,target:u.target,message:u.message})),summary:{errors:m.filter(u=>u.level==="error").length,warnings:m.filter(u=>u.level==="warning").length}}}}s(ZN,"runLintCmd");lt();function QN(t){let{data:e}=t;if(e.diagnostics.length===0){S.success("All checks passed.");return}let r=e.diagnostics.filter(a=>a.level==="error"),o=e.diagnostics.filter(a=>a.level==="warning");for(let a of r)S.error(`${a.file} (${a.target}): ${a.message}`);for(let a of o)S.warn(`${a.file} (${a.target}): ${a.message}`);let n=e.summary.errors,i=e.summary.warnings;S.info(`${n} error${n!==1?"s":""}, ${i} warning${i!==1?"s":""}`);}s(QN,"renderLint");lt();function qN(t){let{data:e}=t;if(!e.hasLock){S.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");return}if(e.inSync){S.success("Lock file is in sync.");return}let r=new Set(e.lockedViolations);S.error("Conflict detected:");for(let o of e.extendsModified)S.error(` extend "${o}" was modified`);for(let o of e.modified){let n=r.has(o)?" [LOCKED]":"";S.error(` ${o} was modified${n}`);}for(let o of e.added){let n=r.has(o)?" [LOCKED]":"";S.error(` ${o} was added${n}`);}for(let o of e.removed){let n=r.has(o)?" [LOCKED]":"";S.error(` ${o} was removed${n}`);}S.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state.");}s(qN,"renderCheck");lt();function tD(t){let{data:e}=t;if(e.files.length===0){S.info(`Nothing to import from ${e.target}.`);return}for(let o of e.files)S.success(`${o.from} \u2192 ${o.to}`);let r=e.scope==="global"?" --global":"";S.info(`Imported ${e.files.length} file(s). Run 'agentsmesh generate${r}' to sync to other tools.`);}s(tD,"renderImport");lt();function eD(t){let{summary:e}=t.data;if(e.created+e.updated+e.unchanged+e.deleted===0){S.info("No files to generate (no root rule or rules feature disabled).");return}for(let o of t.data.patches)process.stdout.write(o.patch);S.info(id({new:e.created,updated:e.updated,unchanged:e.unchanged,deleted:e.deleted}));}s(eD,"renderDiff");lt();function rD(t){if(!t.data.hadConflict){S.info("No conflicts to resolve.");return}S.success("Lock file conflict resolved.");}s(rD,"renderMerge");ql();em();Ie();jo();ql();em();lt();var cz=300;function lz(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(lz,"normalizeWatchPath");function mz(t,e,r){let o=lz(relative(t,e));return o===""?true:o===".lock"||o===".lock.tmp"||o===".generate.lock"||o.endsWith("/.lock")||o.endsWith("/.lock.tmp")||o.endsWith("/.generate.lock")||o.includes("/.generate.lock/")||o.startsWith(".generate.lock/")}s(mz,"shouldIgnoreWatchPath");function pz(t,e,r,o,n,i,a,c,l){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:o,skillsCount:n,mcpServerCount:i,permissionsCount:a,hooksCount:c,ignoreCount:l})}s(pz,"featureFingerprint");async function nD(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{context:n}=await Rt(r,o),i=[n.canonicalDir,join(n.configDir,"agentsmesh.yaml"),join(n.configDir,"agentsmesh.local.yaml")],a=null,c=null,l=false,m=null,u=s(async()=>{if(l)return;a=null;let{config:C,context:R}=await Rt(r,o),{canonical:_}=await pe(C,R.configDir,{},R.canonicalDir),A=_.mcp?Object.keys(_.mcp.mcpServers).length:0,D=_.permissions?_.permissions.allow.length+_.permissions.deny.length:0,N=_.hooks?Object.values(_.hooks).reduce((Dt,Pt)=>Dt+(Array.isArray(Pt)?Pt.length:0),0):0,T=_.ignore.length,rt=pz(C.features,_.rules.length,_.commands.length,_.agents.length,_.skills.length,A,D,N,T),z=c!==null&&c!==rt;if(c=rt,l)return;let Y=await yc(t,r,{printMatrix:false});if(_c(Y),!l)if(z){let Dt=await Ql(t,r);tm(Dt,{verbose:t.verbose===true});}else S.info("Regenerated.");},"run"),f=s(()=>{let C=u().catch(R=>{if(!l){let _=R instanceof Error?R.message:String(R);S.error(_);}}).finally(()=>{m===C&&(m=null);});m=C;},"scheduleRun"),g=s(()=>{l||(a&&clearTimeout(a),a=setTimeout(f,cz));},"schedule"),h=az.watch(i,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(C,R)=>{mz(n.canonicalDir,R)||g();}),await new Promise((C,R)=>{h.once("ready",C),h.once("error",R);}),S.info(o==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=u(),await m,m=null,{stop:s(async()=>{l=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}s(nD,"runWatch");Ie();Rm();async function cd(t){let{config:e,configDir:r,canonicalDir:o}=t,n=await Bu(o);if(n===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await Mn(o),a=await aa(e,r),c=a.length>0?await gc(a):{},l=new Set(Object.keys(n.checksums)),m=new Set(Object.keys(i)),p=[],u=[],f=[];for(let _ of l){let A=i[_];A===void 0?f.push(_):A!==n.checksums[_]&&p.push(_);}for(let _ of m)l.has(_)||u.push(_);let g=new Set([...Object.keys(n.extends),...Object.keys(c)]),h=[];for(let _ of g)c[_]!==n.extends[_]&&h.push(_);let C=zu(n.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:C}}s(cd,"checkLockSync");$n();async function sD(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{config:n,context:i}=await Rt(r,o);await oe(n,r);let a=await cd({config:n,configDir:i.configDir,canonicalDir:i.canonicalDir});return a.hasLock?{exitCode:a.inSync?0:1,data:{hasLock:true,inSync:a.inSync,modified:[...a.modified],added:[...a.added],removed:[...a.removed],extendsModified:[...a.extendsModified],lockedViolations:[...a.lockedViolations]}}:{exitCode:1,data:{hasLock:false,inSync:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]}}}s(sD,"runCheck");Ie();w();Rm();var dz=".lock",fz="<<<<<<<";async function E_(t){let e=join(t,dz),r=await y(e);return r===null?false:r.includes(fz)}s(E_,"hasLockConflict");async function aD(t,e,r){if(!await E_(t))throw new Error("No conflict to resolve.");let n=await Mn(t),i=dirname(t),a=r?await aa(r,i):[],c=a.length>0?await gc(a):{},l=await Vu(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await Hu(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:n,extends:c,packs:l});}s(aD,"resolveLockConflict");async function cD(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",{config:n,context:i}=await Rt(r,o),a=i.canonicalDir;return await E_(a)?(await aD(a,bc(),n),{exitCode:0,data:{hadConflict:true,resolved:true}}):{exitCode:0,data:{hadConflict:false,resolved:false}}}s(cD,"runMerge");Ie();w();vc();var yz=promisify(execFile);function ld(t,e){if(t.startsWith("-"))throw new Error(`agentsmesh refuses ${e} starting with "-" (option-injection guard): ${t}`)}s(ld,"ensureNotFlag");async function O_(t){let{stdout:e}=await yz("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(O_,"runGit");async function lD(){try{return await O_(["--version"]),!0}catch{return false}}s(lD,"isGitAvailable");async function _z(t,e){ld(t,"remote-url"),ld(e,"ref");let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],o;for(let n of r)try{let a=(await O_(["ls-remote",t,n])).split(`
|
|
317
|
+
`).map(l=>l.trim()).find(l=>l.length>0);if(!a)continue;let c=a.split(/\s+/)[0];if(c&&/^[0-9a-f]{40}$/i.test(c))return c}catch(i){o=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${o instanceof Error?o.message:String(o)}`)}s(_z,"gitLsRemoteResolve");async function mD(t,e){ld(e,"remote-url");let r=t===""?"HEAD":t;if(ld(r,"ref"),/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let n=(await O_(["ls-remote",e,"HEAD"])).split(`
|
|
318
|
+
`).find(a=>a.trim().length>0);if(!n)throw new Error(`Could not resolve HEAD for ${e}`);let i=n.split(/\s+/)[0];if(!i||!/^[0-9a-f]{40}$/i.test(i))throw new Error(`Invalid ls-remote HEAD line for ${e}`);return i.toLowerCase()}return _z(e,r)}s(mD,"resolveRemoteRefForInstall");async function pD(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 mD(t.rawRef||"HEAD",e);if(t.kind==="github"){let c=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await ia(c,"install",{cacheDir:Se(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}if(t.kind==="gitlab"){let c=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await ia(c,"install",{cacheDir:Se(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:c,version:r}}let o=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${o}`;return {resolvedPath:(await ia(i,"install",{cacheDir:Se(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(pD,"fetchInstallSource");async function uD(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await pD(t);return {resolvedPath:r.resolvedPath,sourceForYaml:r.sourceForYaml,version:r.version}}catch(r){let o=r instanceof Error?r.message:String(r),n=new Error(`Failed to fetch from ${e}: ${o}. Check your network connection and try again.`);throw r instanceof Error&&(n.cause=r),n}}s(uD,"resolveInstallResolvedPath");function k_(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("tree");if(o<2||o+1>=r.length)return null;let n=r[0],i=r[1],a=r[o+1],c=r.slice(o+2).join("/");return !n||!i||!a?null:{org:n,repo:i,ref:a,path:c||""}}catch{return null}}s(k_,"parseGithubTreeUrl");function L_(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("blob");if(o<2||o+1>=r.length)return null;let n=r[0],i=r[1],a=r[o+1],c=r.slice(o+2).join("/");return !n||!i||!a||!c?null:{org:n,repo:i,ref:a,path:c}}catch{return null}}s(L_,"parseGithubBlobUrl");function A_(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("-");if(o<0||r[o+1]!=="tree")return null;let n=o+1;if(n+1>=r.length)return null;let i=r[n+1],a=r.slice(n+2).join("/"),c=r.slice(0,o);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i?null:{namespace:m,project:l,ref:i,path:a||""}}catch{return null}}s(A_,"parseGitlabTreeUrl");function w_(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),o=r.indexOf("-");if(o<0||r[o+1]!=="blob")return null;let n=o+1;if(n+1>=r.length)return null;let i=r[n+1],a=r.slice(n+2).join("/"),c=r.slice(0,o);if(c.length<2)return null;let l=c[c.length-1],m=c.slice(0,-1).join("/");return !m||!l||!i||!a?null:{namespace:m,project:l,ref:i,path:a}}catch{return null}}s(w_,"parseGitlabBlobUrl");var Iz=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function b_(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||Iz.has(r[1]))return null;let o=r[0],n=r[1];return {org:o,repo:n}}catch{return null}}s(b_,"parseGithubRepoUrl");function T_(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.includes("-"))return null;let o=r[r.length-1],n=r.slice(0,-1).join("/");return !n||!o?null:{namespace:n,project:o}}catch{return null}}s(T_,"parseGitlabRepoUrl");function x_(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(x_,"parseGitSshGithub");function P_(t){let e=t.match(/^git@gitlab\.com:(.+?)(?:\.git)?$/i);if(!e)return null;let o=e[1].replace(/\.git$/i,"").split("/").filter(Boolean);if(o.length<2)return null;let n=o[o.length-1];return {namespace:o.slice(0,-1).join("/"),project:n}}s(P_,"parseGitSshGitlab");w();var Cz=/^[A-Za-z]:[\\/]/,Ez=/^[A-Za-z]:\//;function dD(...t){return t.some(e=>e.includes("\\")||Cz.test(e))?win32:posix}s(dD,"pathApiFor");function om(t){return t.replace(/\\/g,"/")}s(om,"toPosixPath");function rm(t){return om(t).replace(/^\/+|\/+$/g,"")}s(rm,"normalizeInstallPathField");function md(t){let e=om(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||Ez.test(e)?e:`./${e}`}s(md,"normalizeLocalSourceForYaml");function Ns(t){return {...t,source:t.source_kind==="local"?md(t.source):t.source,...t.path!==void 0?{path:rm(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>rm(e))}:{}}}s(Ns,"normalizePersistedInstallPaths");function fD(t,e,r){let o=dD(t,e),n=o.normalize(t),i=o.normalize(e),a=rm(r),c=`${o.sep}.agentsmesh${o.sep}`,l=n.indexOf(c);if(l>=0){let p=n.slice(0,l),u=n.slice(l+c.length),f=rm(u),g=om(o.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||f.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:md(g)}}let m=om(o.relative(i,n))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:n,localSourceForYaml:md(m)}}s(fD,"localParsedFromAbsPath");async function N_(t,e,r){let o=t.trim(),n=r?.trim().replace(/\\/g,"/")??"";if(o.startsWith("git+")){let l=o.lastIndexOf("#"),m=l<0?o:o.slice(0,l),p=l<0?"HEAD":o.slice(l+1),u=m.slice(4);return {kind:"git",rawRef:p,gitPlusBase:u,gitRemoteUrl:u,pathInRepo:n}}if(o.startsWith("https://")||o.startsWith("http://")){let l=k_(o)??L_(o);if(l)return {kind:"github",rawRef:l.ref,org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:n||l.path};let m=b_(o);if(m)return {kind:"github",rawRef:"HEAD",org:m.org,repo:m.repo,gitRemoteUrl:`https://github.com/${m.org}/${m.repo}.git`,pathInRepo:n};let p=A_(o)??w_(o);if(p)return {kind:"gitlab",rawRef:p.ref,org:p.namespace,repo:p.project,gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:n||p.path};let u=T_(o);if(u)return {kind:"gitlab",rawRef:"HEAD",org:u.namespace,repo:u.project,gitRemoteUrl:`https://gitlab.com/${u.namespace}/${u.project}.git`,pathInRepo:n}}if(o.startsWith("git@github.com:")){let l=x_(o);if(!l)throw new Error(`Invalid GitHub SSH URL: ${o}`);return {kind:"github",rawRef:"HEAD",org:l.org,repo:l.repo,gitRemoteUrl:`https://github.com/${l.org}/${l.repo}.git`,pathInRepo:n}}if(o.startsWith("git@gitlab.com:")){let l=P_(o);if(!l)throw new Error(`Invalid GitLab SSH URL: ${o}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${l.namespace}/${l.project}.git`,pathInRepo:n}}if(o.startsWith("git@")){let l=o.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!l)throw new Error(`Invalid SSH git URL: ${o}`);let m=l[1],p=l[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${p}.git`,pathInRepo:n}}let i=o.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let l=i[1],m=i[2];return {kind:"github",rawRef:i[3],org:l,repo:m,gitRemoteUrl:`https://github.com/${l}/${m}.git`,pathInRepo:n}}let a=o.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let l=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:l,repo:m,gitRemoteUrl:`https://gitlab.com/${l}/${m}.git`,pathInRepo:n}}let c=resolve(e,o);if(!await M(c))throw new Error(`Path does not exist: ${c}`);return fD(c,e,n)}s(N_,"parseInstallSource");w();lt();Ho();w();$u();var gD=z.object({name:z.string().min(1),source:z.string().min(1),version:z.string().optional(),source_kind:z.enum(["github","gitlab","git","local"]),features:z.array(na).min(1),pick:Pc.optional(),target:je.optional(),path:z.string().optional(),paths:z.array(z.string().min(1)).min(1).optional(),as:fc.optional()}),wz=z.object({version:z.literal(1),installs:z.array(gD).default([])});function bz(t,e){return t.length===e.length&&[...t].sort().every((r,o)=>r===[...e].sort()[o])}s(bz,"sameFeatures");function Tz(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&bz(t.features,e.features)}s(Tz,"sameInstallIdentity");function hD(t){return join(t,"installs.yaml")}s(hD,"manifestPath");async function D_(t){let e=await y(hD(t));if(e===null)return [];try{return wz.parse(parse(e)).installs.map(r=>Ns(r))}catch{return []}}s(D_,"readInstallManifest");async function yD(t,e){let r=Ns(e),n=(await D_(t)).filter(i=>i.name!==r.name&&!Tz(i,r));n.push(r),await I(hD(t),stringify({version:1,installs:n.sort((i,a)=>i.name.localeCompare(a.name))}));}s(yD,"upsertInstallManifestEntry");function _D(t){return Ns(gD.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(_D,"buildInstallManifestEntry");async function Pz(t){let e=await D_(t.canonicalDir);if(e.length===0){S.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let o of e){let n=join(t.canonicalDir,"packs",o.name);await M(n)||r.push(o);}if(r.length===0){S.info("All recorded packs are already installed.");return}for(let o of r)await t.reinstall(o);S.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(Pz,"syncInstalledPacks");async function ID(t){return t.sync?(await Pz({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(ID,"maybeRunInstallSync");$u();function SD(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"?fc.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(SD,"readInstallFlags");My();function Vi(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(Vi,"featuresFromCanonical");async function pd(t){let{sliceRoot:e,implicitPick:r}=await vu(t),o=await Mu(e);return {canonical:o,features:Vi(o),implicitPick:r}}s(pd,"discoverFromContentRoot");function RD(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(RD,"validateSkill");function CD(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(CD,"validateRule");function ED(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(ED,"validateCommand");function OD(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(OD,"validateAgent");function ye(t){return basename(t.source).replace(/\.md$/i,"")}s(ye,"ruleSlug");function Dz(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(Dz,"featuresFromImplicitPick");function Sc(t,e){let{implicitPick:r}=e,o=e.scopedFeatures??Dz(r);if(!r&&!o)return t;let n=new Set(o??[]),i={...t,mcp:!o||n.has("mcp")?t.mcp:null,permissions:!o||n.has("permissions")?t.permissions:null,hooks:!o||n.has("hooks")?t.hooks:null,ignore:!o||n.has("ignore")?t.ignore:[]};if(r?.skills!==void 0){let a=new Set(r.skills);i={...i,skills:r.skills.length===0?[]:i.skills.filter(c=>a.has(c.name))};}else o&&!n.has("skills")&&(i={...i,skills:[]});if(r?.rules!==void 0){let a=new Set(r.rules);i={...i,rules:r.rules.length===0?[]:i.rules.filter(c=>a.has(ye(c)))};}else o&&!n.has("rules")&&(i={...i,rules:[]});if(r?.commands!==void 0){let a=new Set(r.commands);i={...i,commands:r.commands.length===0?[]:i.commands.filter(c=>a.has(c.name))};}else o&&!n.has("commands")&&(i={...i,commands:[]});if(r?.agents!==void 0){let a=new Set(r.agents);i={...i,agents:r.agents.length===0?[]:i.agents.filter(c=>a.has(c.name))};}else o&&!n.has("agents")&&(i={...i,agents:[]});return i}s(Sc,"narrowDiscoveredForInstallScope");w();Fu();w();v();var Mz=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"]),Gz=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function ud(t){let e=await y(t);if(!e)return "";let{frontmatter:r}=L(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(ud,"readSkillFrontmatterName");async function kD(t,e){await cp$1(t,e,{recursive:true,filter:s(r=>{let o=relative(t,r).replace(/\\/g,"/");if(o==="")return true;let n=o.split("/")[0];return !(Gz.has(n)||!o.includes("/")&&Mz.has(o))},"filter")});}s(kD,"cpFilteredSkill");async function Kz(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await k(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:s(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}s(Kz,"createStageRoot");async function Bz(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 k(e),await cp$1(t,join(e,basename(t)));return}let o=(await F(t)).filter(i=>i.toLowerCase().endsWith(".md"));if(o.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let n=new Map;await k(e);for(let i of o){let a=basename(i),c=n.get(a);if(c)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${c} and ${i}).`);n.set(a,i),await cp$1(i,join(e,a));}}s(Bz,"stageMarkdownCollection");async function LD(t,e,r){if(r.length===0)return false;let o=new Set(r),n=new Map;for(let i of await F(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),c=basename(a);if(!o.has(c))continue;let l=n.get(c);if(l&&l!==a)throw new Error(`Manual skill replay found duplicate skill "${c}" under ${t} (${l} and ${a}).`);n.set(c,a);}if(n.size!==r.length)return false;await k(e);for(let i of r)await cp$1(n.get(i),join(e,i),{recursive:true});return true}s(LD,"stagePreferredSkills");async function Hz(t,e,r={}){if((await stat(t)).isFile()){if(basename(t)!=="SKILL.md")throw new Error(`Manual skill install expects SKILL.md or a skill directory: ${t}`);let n=basename(dirname(t)),i=join(e,n);await k(i),await cp$1(dirname(t),i,{recursive:true});return}if(await Hi(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await LD(t,e,r.preferredSkillNames??[]))return;let c=await ud(join(t,"SKILL.md"))||basename(t),l=join(e,c);await k(e),await kD(t,l);return}if(await LD(t,e,r.preferredSkillNames??[]))return;await k(e);let n=await F(t),i=new Set;for(let a of n.filter(c=>c.endsWith("/SKILL.md")||c.endsWith("\\SKILL.md")))i.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of i)await cp$1(join(t,a),join(e,a),{recursive:true});return}throw new Error(`Manual skill install expects a skill directory or skills collection at ${t}.`)}s(Hz,"stageSkills");async function AD(t,e,r={}){let o=await Kz();try{let n=join(o.discoveryRoot,".agentsmesh",e);return e==="skills"?await Hz(t,n,r):await Bz(t,n),o}catch(n){throw await o.cleanup(),n}}s(AD,"stageManualInstallScope");async function wD(t,e,r,o){let n=await AD(t,e,{preferredSkillNames:e==="skills"?o?.skills:void 0}),{canonical:i}=await pd(n.discoveryRoot),a=Sc(i,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:n.cleanup},narrowed:a,discoveredFeatures:Vi(a)}}s(wD,"resolveManualDiscoveredForInstall");Ho();qd();w();var zz=[{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 Vz(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(Vz,"norm");function fd(t){let e=Vz(t),r=[...zz].sort((o,n)=>n.prefix.length-o.prefix.length);for(let{prefix:o,target:n}of r)if(e===o||e.startsWith(`${o}/`))return n}s(fd,"targetHintFromNativePath");function v_(t,e){return fd(t)===e}s(v_,"pathSupportsNativePick");function bD(t,e){if(!t||!e)return;let r=fd(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(bD,"validateTargetMatchesPath");function TD(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(TD,"extendPickHasArrays");w();w();Gt();async function PD(t,e){let r=join(t,...Pe.split("/")),o=join(t,...e.split("/")),n=await F(o),i=[];for(let a of n){if(!/\.(toml|md)$/i.test(a))continue;let c=relative(r,a).replace(/\\/g,"/");if(c.startsWith("..")||c==="")continue;let m=c.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(PD,"inferGeminiCommandNamesFromFiles");Gt();Qe();w();async function Ji(t){let e=await F(t),r=new Set;for(let o of e){if(basename(o)==="SKILL.md"){r.add(basename(dirname(o)));continue}!relative(t,o).replace(/\\/g,"/").includes("/")&&o.toLowerCase().endsWith(".md")&&r.add(basename(o,".md"));}return [...r].filter(Boolean).sort()}s(Ji,"skillNamesFromNativeSkillDir");w();lr();async function ND(t,e){let r=join(t,...e.split("/"));if(e.startsWith(Es)){let o=await F(r),n=[...new Set(o.filter(i=>i.toLowerCase().endsWith(".prompt.md")).map(i=>basename(i,".prompt.md")))].sort();return n.length?{commands:n}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let o=await F(r),n=[...new Set(o.filter(i=>i.includes(".instructions.md")).map(i=>basename(i).replace(/\.instructions\.md$/i,"")))].sort();return n.length?{rules:n}:{}}if(e.startsWith(".github/instructions")){let o=await F(r),n=new Set;for(let a of o){let c=basename(a);c.toLowerCase().endsWith(".instructions.md")?n.add(c.replace(/\.instructions\.md$/i,"")):c.toLowerCase().endsWith(".md")&&n.add(basename(a,".md"));}let i=[...n].sort();return i.length?{rules:i}:{}}if(e.startsWith(".github/skills")){let o=await Ji(r);return o.length?{skills:o}:{}}if(e.startsWith(".github/agents")){let o=await F(r),n=[...new Set(o.filter(i=>i.toLowerCase().endsWith(".agent.md")).map(i=>basename(i,".agent.md")))].sort();return n.length?{agents:n}:{}}return {}}s(ND,"inferCopilotPickFromPath");async function ve(t,e){let r=await F(t),o=e.toLowerCase();return [...new Set(r.filter(n=>n.toLowerCase().endsWith(o)).map(n=>basename(n,e)))].sort()}s(ve,"mdNames");async function FD(t,e,r){let o=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),n=join(t,...o.split("/"));if(r==="gemini-cli"){if(o===Pe||o.startsWith(`${Pe}/`)){let i=await PD(t,o);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(o.startsWith(".claude/commands")){let i=await ve(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".claude/rules")){let i=await ve(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".claude/agents")){let i=await ve(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".claude/skills/")){let a=o.replace(/^\.claude\/skills\/?/,"").split("/").filter(Boolean)[0];return a?{skills:[a]}:{}}return {}}if(r==="cursor"){if(o.startsWith(".cursor/rules")){let i=await ve(n,".mdc");return i.length?{rules:i}:{}}if(o.startsWith(".cursor/commands")){let i=await ve(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".cursor/agents")){let i=await ve(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".cursor/skills")){let i=await Ji(n);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return ND(t,o);if(r==="windsurf"&&o.startsWith(".windsurf/rules")){let i=await ve(n,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(o.startsWith(zt)){let i=await Ji(n);return i.length?{skills:i}:{}}if(o.startsWith(lo)){let i=await ve(n,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(o.startsWith(".continue/rules")){let i=await ve(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".continue/prompts")){let i=await ve(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".continue/skills")){let i=await Ji(n);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(o.startsWith(".junie/commands")){let i=await ve(n,".md");return i.length?{commands:i}:{}}if(o.startsWith(".junie/rules")){let i=await ve(n,".md");return i.length?{rules:i}:{}}if(o.startsWith(".junie/agents")){let i=await ve(n,".md");return i.length?{agents:i}:{}}if(o.startsWith(".junie/skills")){let i=await Ji(n);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&o.startsWith(".codex")){let i=await F(n),a=[...new Set(i.filter(c=>c.toLowerCase().endsWith(".md")).map(c=>basename(c,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(FD,"inferImplicitPickFromNativePath");function vD(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(vD,"isImplicitPickEmpty");Dy();function im(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(im,"normalizePath");function oV(t,e){let r=im(t),o=im(e);return r===o||r.startsWith(`${o}/`)||o.startsWith(`${r}/`)}s(oV,"overlapsPath");function gd(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(gd,"addUnique");async function nV(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),o=s(async()=>{await rm$1(e,{recursive:true,force:true});},"cleanup");try{return await cp$1(t,r,{recursive:!0}),{stageRoot:r,cleanup:o}}catch(n){throw await o(),n}}s(nV,"makeStageRoot");function sV(t,e){let r;for(let n of t){if(n.feature==="rules"&&n.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:gd(r?.rules,basename(n.toPath,".md"))};continue}if(n.feature==="commands"&&n.toPath.startsWith(".agentsmesh/commands/")){let i=im(relative(join(e,".agentsmesh","commands"),join(e,n.toPath)));r={...r,commands:gd(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(n.feature==="agents"&&n.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:gd(r?.agents,basename(n.toPath,".md"))};continue}if(n.feature==="skills"&&n.toPath.startsWith(".agentsmesh/skills/")){let a=im(relative(join(e,".agentsmesh","skills"),join(e,n.toPath))).split("/")[0];a&&(r={...r,skills:gd(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(sV,"buildPickFromResults");function iV(t,e,r,o){let n=join(e,...im(t).split("/")),i=r.filter(a=>oV(n,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${o}".`);return {features:[...new Set(i.map(a=>a.feature))],pick:sV(i,e)}}s(iV,"scopeImportedResults");async function G_(t,e){let{stageRoot:r,cleanup:o}=await nV(t);try{let n=await Bl(r,e);return {stageRoot:r,results:n,cleanup:o}}catch(n){throw await o(),n}}s(G_,"stageImportedNativeRepo");async function $_(t,e,r){let o=await G_(t,r);try{return {stageRoot:o.stageRoot,cleanup:o.cleanup,...iV(e,o.stageRoot,o.results,r)}}catch(n){throw await o.cleanup(),n}}s($_,"stageNativeInstallScope");async function jD(t,e,r,o){let n=o.explicitTarget?.trim();n&&je.parse(n);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");bD(n,i);let a=join(t,".agentsmesh"),c=await M(a),l=i?fd(i):void 0,m=!c&&!n?await Pm(t)??void 0:void 0;if(!n&&l&&m&&l!==m)throw new Error(`Install path suggests native layout "${l}" but auto-detect imported "${m}". Use --target ${l} for this path, or install from the repo root without a conflicting subtree path.`);let p=n??l??m,u=!!i&&!!p&&!i.startsWith(".agentsmesh");if(!c&&p){if(u){let A=await $_(t,i,p);return {discoveryRoot:A.stageRoot,implicitPick:A.pick,scopedFeatures:A.features,yamlTarget:p,importHappened:true,cleanup:A.cleanup}}let _=await G_(t,p);return {discoveryRoot:i?join(_.stageRoot,i):_.stageRoot,yamlTarget:p,importHappened:true,cleanup:_.cleanup}}let f;c?i?p&&v_(i,p)?f=t:f=e:f=t:f=e;let g,h,C;if(u&&p){let _=await $_(t,i,p);f=_.stageRoot,g=_.pick,h=_.features,C=_.cleanup;}else if(f===t&&i&&p&&v_(i,p)&&(g=await FD(t,i,p),vD(g)))throw new Error(`No installable native resources found under "${i}" for target "${p}".`);let R;return n?R=n:p&&(g&&TD(g)||(h?.length??0)>0)&&(R=p),{discoveryRoot:f,implicitPick:g,scopedFeatures:h,yamlTarget:R,importHappened:C!==void 0,cleanup:C}}s(jD,"prepareInstallDiscovery");async function UD(t,e,r,o){let n=await jD(t,e,r,{explicitTarget:o}),{canonical:i,implicitPick:a}=await pd(n.discoveryRoot),c=a??n.implicitPick,l=Sc(i,{implicitPick:c,scopedFeatures:n.scopedFeatures}),m=Vi(l);return {prep:n,discovered:i,implicitPick:c,narrowed:l,discoveredFeatures:m}}s(UD,"resolveDiscoveredForInstall");async function WD(t){return t.explicitAs?{implicitPick:void 0,...await wD(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:UD(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}s(WD,"resolveInstallDiscovery");function Cc(t){return t==="."||t===""?void 0:t}s(Cc,"trimDot");function cV(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(cV,"markdownPick");async function BD(t){if(!t.as)return {pathInRepo:Cc(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:Cc(dirname(e)),pick:cV(t.as,e||t.contentRoot)};if(t.as==="skills"){if(r.isFile()&&basename(t.contentRoot)==="SKILL.md"){let o=e?dirname(e):dirname(t.contentRoot);return {pathInRepo:Cc(dirname(o)),pick:{skills:[basename(o)]}}}if(r.isDirectory()){let o=e||basename(t.contentRoot),n=join(t.contentRoot.replace(/\/+$/g,""),"SKILL.md");try{if((await stat(n)).isFile()){let a=await ud(n);return {pathInRepo:Cc(dirname(o)),pick:{skills:[a||basename(o)]}}}}catch{return {pathInRepo:Cc(e)}}}}return {pathInRepo:Cc(e)}}s(BD,"resolveManualInstallPersistence");jo();lt();async function Uo(t){return process.stdin.isTTY?new Promise(e=>{let r=HD.createInterface({input:process.stdin,output:process.stdout});r.question(`${t} (y/n) `,o=>{r.close();let n=o.trim().toLowerCase();e(n==="y"||n==="yes");});}):false}s(Uo,"confirm");function lV(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(lV,"hasArrayResources");function zD(t){return lV(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(zD,"hasInstallableResources");async function VD(t,e,r,o){let n=t.skills.map(c=>RD(c)),i=n.filter(c=>c.ok).map(c=>c.skill),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await Uo(`Include invalid skill "${c.skill.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.skill);else e&&(i=n.map(c=>c.skill));return r&&(i=n.filter(c=>c.ok).map(c=>c.skill)),i}s(VD,"resolveSkillPool");async function JD(t,e,r,o){let n=t.rules.map(c=>CD(c)),i=n.filter(c=>c.ok).map(c=>c.rule),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await Uo(`Include invalid rule "${ye(c.rule)}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.rule);else e&&(i=n.map(c=>c.rule));return r&&(i=n.filter(c=>c.ok).map(c=>c.rule)),i}s(JD,"resolveRulePool");async function YD(t,e,r,o){let n=t.commands.map(c=>ED(c)),i=n.filter(c=>c.ok).map(c=>c.command),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await Uo(`Include invalid command "${c.command.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.command);else e&&(i=n.map(c=>c.command));return r&&(i=n.filter(c=>c.ok).map(c=>c.command)),i}s(YD,"resolveCommandPool");async function XD(t,e,r,o){let n=t.agents.map(c=>OD(c)),i=n.filter(c=>c.ok).map(c=>c.agent),a=n.filter(c=>!c.ok);if(!e&&!r&&o)for(let c of a)await Uo(`Include invalid agent "${c.agent.name}" anyway? (${c.reason}). You can fix it later.`)&&i.push(c.agent);else e&&(i=n.map(c=>c.agent));return r&&(i=n.filter(c=>c.ok).map(c=>c.agent)),i}s(XD,"resolveAgentPool");async function ZD(t,e){let r=e.skills.map(a=>a.name),o=e.rules.map(a=>ye(a)),n=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(c=>c.name===a.name)&&(await Uo(`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=ye(a);t.rules.some(l=>ye(l)===c)&&(await Uo(`Rule "${c}" already exists in merged config. Add extend anyway?`)||(o=o.filter(m=>m!==c)));}for(let a of e.commands)t.commands.some(c=>c.name===a.name)&&(await Uo(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(n=n.filter(l=>l!==a.name)));for(let a of e.agents)t.agents.some(c=>c.name===a.name)&&(await Uo(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(l=>l!==a.name)));return {skillNames:r,ruleSlugs:o,commandNames:n,agentNames:i}}s(ZD,"resolveInstallConflicts");function QD(t,e){if(!t)return;let r={},o=t.skills?.filter(c=>e.skillNames.includes(c)),n=t.rules?.filter(c=>e.ruleSlugs.includes(c)),i=t.commands?.filter(c=>e.commandNames.includes(c)),a=t.agents?.filter(c=>e.agentNames.includes(c));return o&&o.length>0&&(r.skills=o),n&&n.length>0&&(r.rules=n),i&&i.length>0&&(r.commands=i),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}s(QD,"pickForSelectedResources");function mV(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(mV,"pathEndsWithName");function hd(t,e,r){return r!==1||e.length!==1?false:mV(t,e[0])}s(hd,"inferSingleNamePick");function qD(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:o,selected:n}=t,i={},a=n.skillNames.length>0&&(!!r?.skills?.length||n.skillNames.length<o.skills||hd(e,n.skillNames,o.skills)),c=n.ruleSlugs.length>0&&(!!r?.rules?.length||n.ruleSlugs.length<o.rules||hd(e,n.ruleSlugs,o.rules)),l=n.commandNames.length>0&&(!!r?.commands?.length||n.commandNames.length<o.commands||hd(e,n.commandNames,o.commands)),m=n.agentNames.length>0&&(!!r?.agents?.length||n.agentNames.length<o.agents||hd(e,n.agentNames,o.agents));return a&&(i.skills=[...n.skillNames]),c&&(i.rules=[...n.ruleSlugs]),l&&(i.commands=[...n.commandNames]),m&&(i.agents=[...n.agentNames]),Object.keys(i).length?i:void 0}s(qD,"buildInstallPick");function tF(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(tF,"deriveInstallFeatures");function pV(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(pV,"isEmptyInstallSelection");function eF(t){let{selected:e,discoveredFeatures:r,preConflict:o}=t,n=s(c=>r.includes(c),"had"),i=n("skills")&&e.skillNames.length===0&&o.skills>0&&"skills"||n("rules")&&e.ruleSlugs.length===0&&o.rules>0&&"rules"||n("commands")&&e.commandNames.length===0&&o.commands>0&&"commands"||n("agents")&&e.agentNames.length===0&&o.agents>0&&"agents";if(i)throw new Error(`No ${i} selected to install.`);let a=r.some(c=>["mcp","permissions","hooks","ignore"].includes(c));if(pV(e)&&!a)throw new Error("No resources selected to install.")}s(eF,"ensureInstallSelection");Ho();function rF(t,e){if(t.find(o=>o.name===e.name&&o.source!==e.source))throw new Error(`Extends entry "${e.name}" already exists with a different source. Use --name to provide a different name.`)}s(rF,"assertExtendNameAvailable");function uV(t,e,r){if(r===void 0){if(!t)return;let n={...t};for(let i of ["skills","commands","rules","agents"])e.includes(i)&&delete n[i];return Object.keys(n).length?n:void 0}let o={...t};for(let n of ["skills","commands","rules","agents"]){if(!(n in r))continue;let i=r[n];if(i===void 0||i.length===0){delete o[n];continue}o[n]=[...new Set([...t?.[n]??[],...i])];}return Object.keys(o).length?o:void 0}s(uV,"mergePick");function oF(t,e){let r=t.findIndex(a=>a.source===e.source);if(r<0)return [...t,{name:e.name,source:e.source,version:e.version,features:e.features,path:e.path,pick:e.pick,target:e.target}];let o=t[r],n=[...new Set([...o.features,...e.features])],i=uV(o.pick,e.features,e.pick);return t.map((a,c)=>c===r?{name:e.name,source:e.source,version:e.version??o.version,features:n,path:e.path!==void 0?e.path:o.path,pick:i,target:e.target??o.target}:a)}s(oF,"mergeExtendList");w();async function nF(t,e,r){let o=await y(t);if(o===null)throw new Error(`Missing config: ${t}`);let n=parse(o),i=oF(e.extends,r);n.extends=i;let a=stringify(n,{indent:2,lineWidth:0});await I(t,a.endsWith(`
|
|
309
319
|
`)?a:`${a}
|
|
310
|
-
`);}s(
|
|
311
|
-
${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await
|
|
312
|
-
`);return `sha256:${
|
|
313
|
-
`),t.permissions!==null&&await
|
|
320
|
+
`);}s(nF,"writeAgentsmeshWithNewExtend");lt();async function sF(t){let{configDir:e,config:r,entryArgs:o,dryRun:n}=t,i=hV(o);if(rF(r.extends,i),n){S.info(`[dry-run] Would add extend:
|
|
321
|
+
${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await nF(a,r,i),S.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(sF,"writeInstallAsExtend");function hV(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?je.parse(t.yamlTarget):void 0}}s(hV,"toNewExtendEntry");w();w();var _V="pack.yaml";async function yd(t){let e=await F(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===_V)continue;let c=await Ku(i);c!==null&&r.push(`${a}:${c}`);}let o=r.join(`
|
|
322
|
+
`);return `sha256:${Jl(o)}`}s(yd,"hashPackContent");async function CV(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await k(r);for(let o of t.rules){let n=join(r,basename(o.source));await copyFile(o.source,n);}}s(CV,"writeRules");async function EV(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await k(r);for(let o of t.commands){let n=join(r,basename(o.source));await copyFile(o.source,n);}}s(EV,"writeCommands");async function OV(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await k(r);for(let o of t.agents){let n=join(r,basename(o.source));await copyFile(o.source,n);}}s(OV,"writeAgents");async function kV(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await k(r);for(let o of t.skills){let n=join(r,o.name);await k(n),await copyFile(o.source,join(n,"SKILL.md"));for(let i of o.supportingFiles){let a=join(n,i.relativePath);await k(dirname(a)),await copyFile(i.absolutePath,a);}}}s(kV,"writeSkills");async function LV(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
|
|
323
|
+
`),t.permissions!==null&&await I(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await I(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await I(join(e,"ignore"),`${t.ignore.join(`
|
|
314
324
|
`)}
|
|
315
|
-
`);}s(
|
|
316
|
-
`),t.permissions!==null&&await
|
|
325
|
+
`);}s(LV,"writeSettings");function AV(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(AV,"validatePackName");async function aF(t,e,r,o){AV(e);let n=join(t,`${e}.tmp`),i=join(t,e);await M(n)&&await rm$1(n,{recursive:true,force:true}),await k(n),await CV(r,n),await EV(r,n),await OV(r,n),await kV(r,n),await LV(r,n);let a=await yd(n),c=Ns({...o,content_hash:a});return await I(join(n,"pack.yaml"),stringify(c)),await M(i)&&await rm$1(i,{recursive:true,force:true}),await mkdir(t,{recursive:true}),await rename(n,i),c}s(aF,"materializePack");Wu();w();function B_(t,e){return [...new Set([...t,...e])]}s(B_,"union");function bV(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let o=B_(t.paths??(t.path?[t.path]:[]),[e]);return o.length===1?{path:o[0],paths:void 0}:{path:void 0,paths:o}}s(bV,"mergePathScope");function TV(t,e,r){let o={...t};for(let i of e)r&&r[i]!==void 0?o[i]=B_(o[i]??[],r[i]):delete o[i];return (o.skills?.length??0)>0||(o.rules?.length??0)>0||(o.commands?.length??0)>0||(o.agents?.length??0)>0?o:void 0}s(TV,"mergePick");async function xV(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await k(r);for(let o of t.rules)await copyFile(o.source,join(r,basename(o.source)));}s(xV,"mergeRules");async function PV(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await k(r);for(let o of t.commands)await copyFile(o.source,join(r,basename(o.source)));}s(PV,"mergeCommands");async function NV(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await k(r);for(let o of t.agents)await copyFile(o.source,join(r,basename(o.source)));}s(NV,"mergeAgents");async function DV(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await k(r);for(let o of t.skills){let n=join(r,o.name);await k(n),await copyFile(o.source,join(n,"SKILL.md"));for(let i of o.supportingFiles){let a=join(n,i.relativePath);await k(dirname(a)),await copyFile(i.absolutePath,a);}}}s(DV,"mergeSkills");async function FV(t,e){t.mcp!==null&&await I(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
|
|
326
|
+
`),t.permissions!==null&&await I(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await I(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await I(join(e,"ignore"),`${t.ignore.join(`
|
|
317
327
|
`)}
|
|
318
|
-
`);}s(
|
|
319
|
-
`,
|
|
320
|
-
|
|
321
|
-
// Project-level paths
|
|
322
|
-
export const ${e}_DIR = '.${t.id}';
|
|
323
|
-
export const ${e}_RULES_DIR = '.${t.id}/rules';
|
|
324
|
-
|
|
325
|
-
// Global-level paths
|
|
326
|
-
export const ${e}_GLOBAL_DIR = '~/.${t.id}';
|
|
327
|
-
export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
|
|
328
|
-
|
|
329
|
-
// Canonical paths
|
|
330
|
-
export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
|
|
331
|
-
export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
|
|
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';
|
|
328
|
+
`);}s(FV,"mergeSettings");async function cF(t,e,r,o,n,i){await xV(r,t),await PV(r,t),await NV(r,t),await DV(r,t),await FV(r,t);let a=B_(e.features,o),c=TV(e.pick,o,n),l=bV(e,i?.path),m=await yd(t),p=new Date().toISOString(),u=Ns({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:a,pick:c,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...l,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:p,content_hash:m});return await I(join(t,"pack.yaml"),stringify(u)),u}s(cF,"mergeIntoPack");Bd();Ho();lt();w();function MV(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(MV,"pathScope");function GV(t,e){let r=new Set(e.skillNames),o=new Set(e.ruleSlugs),n=new Set(e.commandNames),i=new Set(e.agentNames);return {...t,skills:t.skills.filter(a=>r.has(a.name)),rules:t.rules.filter(a=>o.has(ye(a))),commands:t.commands.filter(a=>n.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(GV,"applySelection");async function lF(t){let{canonicalDir:e,packName:r,narrowed:o,selected:n,sourceForYaml:i,version:a,sourceKind:c,entryFeatures:l,pick:m,yamlTarget:p,pathInRepo:u,manualAs:f,renameExistingPack:g}=t,h=join(e,"packs"),C=GV(o,n),R=new Date().toISOString(),_=p!==void 0?je.parse(p):void 0,A=await AP(h,i,{target:_,as:f,features:l}),D=r,N=l,T=m,rt=u,z;if(A){let Y=A.packDir,Dt=A.meta;if(g&&A.name!==r){let Vr=join(h,r);if(await M(Vr))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(A.packDir,Vr),Y=Vr,Dt={...A.meta,name:r};}let Pt=await cF(Y,Dt,C,l,m,{source:i,...a!==void 0?{version:a}:{},..._!==void 0?{target:_}:{},...u?{path:u}:{},...f!==void 0?{as:f}:{}});D=Pt.name,N=Pt.features,T=Pt.pick,rt=Pt.path,z=Pt.paths,S.success(`Updated pack "${Pt.name}" in .agentsmesh/packs/.`);}else {if(await ju(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 aF(h,r,C,{name:r,source:i,...a!==void 0&&{version:a},source_kind:c,installed_at:R,updated_at:R,features:l,...m!==void 0&&{pick:m},..._!==void 0&&{target:_},...MV(u),...f!==void 0&&{as:f}}),S.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await yD(e,_D({name:D,source:i,version:a,sourceKind:c,features:N,pick:T,target:_,path:rt,paths:z,as:f})),c!=="local"&&await nS(i);}s(lF,"installAsPack");function jV(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(jV,"sanitize");function UV(t){try{let r=new URL(t.replace(/^git\+/,"https://").replace(/^ssh:\/\/git@/,"https://")).pathname.split("/").filter(Boolean);if(r.length===0)return "repo";let o=r[r.length-1].replace(/\.git$/i,"");return r.length>=2?`${r[r.length-2].replace(/\.git$/i,"")}-${o}`:o}catch{return "repo"}}s(UV,"gitUrlLastSegments");function mF(t,e,r){let o;if(t.kind==="local"){let c=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);o=c[c.length-1]??"local";}else t.kind==="github"&&t.org&&t.repo?o=`${t.org}-${t.repo}`:t.kind==="gitlab"&&t.org&&t.repo?o=`${t.org.replace(/\//g,"-")}-${t.repo}`:t.gitRemoteUrl?o=UV(t.gitRemoteUrl):o="extend";e.featureHint?o=`${o}-${e.featureHint}`:o=`${o}-pack`;let n=jV(o)||"extend";if(!r.has(n))return n;let i=2;for(;r.has(`${n}-${i}`);)i++;return `${n}-${i}`}s(mF,"suggestExtendName");function pF(t){let{config:e,parsed:r,entryFeatures:o,nameOverride:n}=t,i=new Set(e.extends.map(a=>a.name));return n||mF(r,{featureHint:o.length===1?o[0]:void 0},i)}s(pF,"selectInstallEntryName");function uF(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let o=Sc(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:o,discoveredFeatures:Vi(o)}}s(uF,"applyReplayInstallScope");function dF(t,e){let r=[];for(let o of t.skillNames)r.push({kind:"skill",name:o,path:e});for(let o of t.ruleSlugs)r.push({kind:"rule",name:o,path:e});for(let o of t.commandNames)r.push({kind:"command",name:o,path:e});for(let o of t.agentNames)r.push({kind:"agent",name:o,path:e});return r}s(dF,"buildInstalledList");function fF(t,e,r,o,n){let i=[];for(let a of t)n.skillNames.includes(a.name)||i.push({kind:"skill",name:a.name,reason:"conflict"});for(let a of e){let c=ye(a);n.ruleSlugs.includes(c)||i.push({kind:"rule",name:c,reason:"conflict"});}for(let a of r)n.commandNames.includes(a.name)||i.push({kind:"command",name:a.name,reason:"conflict"});for(let a of o)n.agentNames.includes(a.name)||i.push({kind:"agent",name:a.name,reason:"conflict"});return i}s(fF,"buildSkippedList");async function gF(t){let{scope:e,force:r,dryRun:o,tty:n,useExtends:i,nameOverride:a,explicitAs:c,config:l,context:m,parsed:p,sourceForYaml:u,version:f,pathInRepo:g,persisted:h,replay:C,prep:R,implicitPick:_,narrowed:A,discoveredFeatures:D}=t,{narrowed:N,discoveredFeatures:T}=uF(A,D,C);if(!zD(N))throw new Error(_||R.scopedFeatures?"No resources match the install path or implicit selection (check pick names exist at that path).":"No supported resources found to install (skills, rules, commands, agents).");let rt=await VD(N,r,o,n),z=await JD(N,r,o,n),Y=await YD(N,r,o,n),Dt=await XD(N,r,o,n),Pt={skills:rt.length,rules:z.length,commands:Y.length,agents:Dt.length},{canonical:Vr}=await pe(l,m.configDir,{},m.canonicalDir),jt=!r&&!o&&n?await ZD(Vr,{skills:rt,rules:z,commands:Y,agents:Dt}):{skillNames:rt.map(Kn=>Kn.name),ruleSlugs:z.map(Kn=>ye(Kn)),commandNames:Y.map(Kn=>Kn.name),agentNames:Dt.map(Kn=>Kn.name)};eF({selected:jt,discoveredFeatures:T,preConflict:Pt});let Jr=C?.features??tF(T,jt);if(Jr.length===0)throw new Error("No features left to install after selection.");let Ft=QD(C?.pick,jt)??h.pick??qD({pathInRepo:h.pathInRepo??g,implicitPick:_,preConflictCounts:Pt,selected:jt}),St=pF({config:l,parsed:p,entryFeatures:Jr,nameOverride:a}),Wo=dF(jt,St),gr=fF(rt,z,Y,Dt,jt);if(i){if(await sF({configDir:m.configDir,config:l,entryArgs:{name:St,source:u,version:f,features:Jr,path:h.pathInRepo,pick:Ft,yamlTarget:R.yamlTarget},dryRun:o}),o)return {installed:Wo,skipped:gr}}else {if(o)return S.info(`[dry-run] Would install pack "${St}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`),{installed:Wo,skipped:gr};await lF({canonicalDir:m.canonicalDir,packName:St,narrowed:N,selected:jt,sourceForYaml:u,version:f,sourceKind:p.kind,entryFeatures:Jr,pick:Ft,yamlTarget:R.yamlTarget,pathInRepo:h.pathInRepo,manualAs:c,renameExistingPack:a===""});}let Wn=await yc(e==="global"?{global:true}:{},m.rootBase);return _c(Wn),Wn.exitCode!==0&&S.warn(`Generate failed after install. Fix the issue and run agentsmesh generate${e==="global"?" --global":""}.`),{installed:Wo,skipped:gr}}s(gF,"executeRunInstallPoolsAndWrite");async function z_(t,e,r,o){let{sync:n,dryRun:i,force:a,useExtends:c,explicitPath:l,explicitTarget:m,explicitAs:p,nameOverride:u}=SD(t),f=t.global===true?"global":"project",g=e[0]?.trim();if(n){let{context:jt}=await Rt(r,f),Jr=[],Ft=[];if(await ID({sync:n,canonicalDir:jt.canonicalDir,reinstall:s(async St=>{let Wo=St.paths&&St.paths.length>0?St.paths:[St.path];for(let gr of Wo){let Wn=await z_({...a?{force:true}:{},...i?{"dry-run":true}:{},...f==="global"?{global:true}:{},name:St.name,...St.target?{target:St.target}:{},...gr?{path:gr}:{},...St.as?{as:St.as}:{}},[St.source],r,{features:St.features,pick:St.pick});Jr.push(...Wn.data.installed),Ft.push(...Wn.data.skipped);}},"reinstall")}))return {exitCode:0,data:{source:"",mode:"sync",installed:Jr,skipped:Ft,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:C,context:R}=await Rt(r,f),_=await N_(g,R.configDir,l);if(_.kind!=="local"&&!await lD())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:A,sourceForYaml:D,version:N}=await uD(_,g),T=_.pathInRepo.replace(/^\/+|\/+$/g,"");if(T){let jt=normalize(T).replace(/\\/g,"/");if(jt===".."||jt.startsWith("../"))throw new Error(`Install --path "${_.pathInRepo}" escapes the source root. Path must stay within the source.`)}let rt=T?join(A,T):A;if(!await M(rt))throw new Error(`Install path does not exist: ${rt}`);let z=await BD({as:p,contentRoot:rt,pathInRepo:T}),{prep:Y,implicitPick:Dt,narrowed:Pt,discoveredFeatures:Vr}=await WD({resolvedPath:A,contentRoot:rt,pathInRepo:T,explicitTarget:m,explicitAs:p,replayPick:o?.pick});try{let jt=await gF({scope:f,force:a,dryRun:i,tty:h,useExtends:c,nameOverride:u,explicitAs:p,config:C,context:R,parsed:_,sourceForYaml:D,version:N,pathInRepo:T,persisted:z,replay:o,prep:Y,implicitPick:Dt,narrowed:Pt,discoveredFeatures:Vr});return {exitCode:0,data:{source:g,mode:"install",installed:jt.installed,skipped:jt.skipped,dryRun:i}}}finally{Y.cleanup&&await Y.cleanup();}}s(z_,"runInstall");async function hF(t,e,r){return z_(t,e,r)}s(hF,"runInstall");lt();function yF(t){let{data:e}=t;if(!(e.mode==="sync"&&e.installed.length===0&&e.skipped.length===0)){if(e.installed.length>0&&!e.dryRun){let o=[...new Set(e.installed.map(n=>n.kind))].map(n=>{let i=e.installed.filter(a=>a.kind===n).length;return `${i} ${n}${i>1?"s":""}`}).join(", ");S.success(`Installed ${o}.`);}if(e.skipped.length>0)for(let r of e.skipped)S.warn(`Skipped ${r.kind} "${r.name}": ${r.reason}`);}}s(yF,"renderInstall");Zy();w();var Y_="agentsmesh.yaml";async function X_(t){let e=join(t,Y_),r=await y(e);return r===null?{}:parse(r)??{}}s(X_,"readScopedConfigRaw");async function IF(t,e){let r=join(t,Y_),o=await y(r)??`version: 1
|
|
329
|
+
`,n=parse(o)??{};if(n.plugins||(n.plugins=[]),n.plugins.some(a=>a.id===e.id))return;let i={id:e.id,source:e.source};e.version!==void 0&&(i.version=e.version),n.plugins.push(i),await I(r,stringify(n));}s(IF,"writePluginEntry");async function SF(t,e){let r=join(t,Y_),o=await y(r);if(o===null)return false;let n=parse(o)??{},i=(n.plugins??[]).length;n.plugins=(n.plugins??[]).filter(c=>c.id!==e),n.pluginTargets&&(n.pluginTargets=n.pluginTargets.filter(c=>c!==e));let a=n.plugins.length<i;return a&&await I(r,stringify(n)),a}s(SF,"removePluginEntry");async function RF(t,e,r){let o=e[0];if(o===void 0||o==="")return {exitCode:0,data:{subcommand:"list",plugins:[]},showHelp:true};switch(o){case "add":return BV(t,e.slice(1),r);case "list":return HV(r);case "remove":return zV(e.slice(1),r);case "info":return VV(e.slice(1),r);default:return {exitCode:2,data:{subcommand:"list",plugins:[]},showHelp:true,error:`Unknown plugin subcommand: ${o}`}}}s(RF,"runPlugin");async function BV(t,e,r){let o=e[0];if(!o)throw new Yr("Usage: agentsmesh plugin add <source> [--version <v>] [--id <id>]");let n=typeof t.version=="string"?t.version:"latest",a=(typeof t.id=="string"?t.id:void 0)??JV(o);return await IF(r,{id:a,source:o,version:n==="latest"?void 0:n}),{exitCode:0,data:{subcommand:"add",id:a,package:o,version:n}}}s(BV,"runPluginAdd");async function HV(t){let r=(await X_(t)).plugins??[],o=[];for(let n of r){let i="\u2717",a="";try{let c=await td(n,t);i=c.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",a=c.descriptors.map(l=>l.id).join(", ");}catch{}o.push({id:n.id,package:n.source,version:n.version,status:i,targets:a});}return {exitCode:0,data:{subcommand:"list",plugins:o}}}s(HV,"runPluginList");async function zV(t,e){let r=t[0];if(!r)throw new Yr("Usage: agentsmesh plugin remove <id>");let o=await SF(e,r);return {exitCode:0,data:{subcommand:"remove",id:r,found:o}}}s(zV,"runPluginRemove");async function VV(t,e){let r=t[0];if(!r)throw new Yr("Usage: agentsmesh plugin info <id>");let n=((await X_(e)).plugins??[]).find(c=>c.id===r);if(!n)return {exitCode:1,data:{subcommand:"info",id:r,package:"",descriptors:[]}};let i;try{i=await td(n,e);}catch{return {exitCode:1,data:{subcommand:"info",id:r,package:n.source,version:n.version,descriptors:[]}}}let a=i.descriptors.map(c=>({id:c.id,description:c.emptyImportMessage}));return {exitCode:0,data:{subcommand:"info",id:r,package:n.source,version:n.version,descriptors:a}}}s(VV,"runPluginInfo");function JV(t){let e=t;if(e.startsWith("@")){let o=e.indexOf("/");o!==-1&&(e=e.slice(o+1));}e.startsWith("agentsmesh-target-")&&(e=e.slice(18)),e.startsWith("file:")&&(e=e.slice(5));let r=e.replace(/\\/g,"/").split("/");return e=r[r.length-1]??e,e=e.replace(/\.(js|ts)$/,""),e=e.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),e||"plugin"}s(JV,"derivePluginId");lt();function CF(t){if(t.error&&S.error(t.error),t.showHelp){qV();return}let{data:e}=t;switch(e.subcommand){case "add":YV(e.id,e.package,e.version);break;case "list":XV(e.plugins);break;case "remove":ZV(e.id,e.found);break;case "info":QV(e,t.exitCode);break}}s(CF,"renderPlugin");function YV(t,e,r){S.success(`Plugin '${t}' added to agentsmesh.yaml`),S.warn("Plugins load as trusted Node.js modules and run with full process privileges. Only install plugins from sources you trust.");let o=r!=="latest"?`@${r}`:"@latest";S.info(`Next: npm install ${e}${o}`),S.info(`Then add '${t}' to pluginTargets in agentsmesh.yaml to enable it.`);}s(YV,"renderAdd");function XV(t){if(t.length===0){S.info("No plugins configured. Use: agentsmesh plugin add <source>");return}S.info("Configured plugins:");for(let e of t){let r=e.version!==void 0?`@${e.version}`:"",o=e.status??"",n=e.targets??"";S.info(` ${e.id} | ${e.package}${r} | ${o} | ${n}`);}}s(XV,"renderList");function ZV(t,e){e?S.success(`Plugin '${t}' removed from agentsmesh.yaml`):S.warn(`Plugin '${t}' was not found in agentsmesh.yaml`);}s(ZV,"renderRemove");function QV(t,e){if(e!==0&&t.package===""){S.error(`Plugin '${t.id}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`);return}if(e!==0){S.error(`Failed to load plugin '${t.id}'`);return}S.info(`Plugin: ${t.id}`),S.info(`Source: ${t.package}${t.version!==void 0?`@${t.version}`:""}`),S.info(`Descriptors: ${t.descriptors.length}`);for(let r of t.descriptors)S.info(` - ${r.id}: ${r.description}`);}s(QV,"renderInfo");function qV(){S.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),S.info(""),S.info("Subcommands:"),S.info(" add <source> Register a plugin package in agentsmesh.yaml"),S.info(" list Show all configured plugins and load status"),S.info(" remove <id> Remove a plugin from agentsmesh.yaml"),S.info(" info <id> Show descriptor details for a configured plugin"),S.info(""),S.info("Flags (add):"),S.info(" --version <v> Pin plugin version"),S.info(" --id <id> Override derived plugin id"),S.info(""),S.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),S.info(" Only install plugins from sources you trust.");}s(qV,"printPluginHelp");w();_r();function Ds(t){return t.toUpperCase().replace(/-/g,"_")}s(Ds,"toPrefix");function jn(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(jn,"toPascal");function Z_(t){let e=Ds(t.id),r=jn(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
|
|
333
330
|
import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
|
|
334
331
|
import { generateRules } from './generator.js';
|
|
335
332
|
import { importFrom${r} } from './importer.js';
|
|
@@ -426,21 +423,80 @@ export const descriptor = {
|
|
|
426
423
|
buildImportPaths: build${r}ImportPaths,
|
|
427
424
|
detectionPaths: [${e}_DIR],
|
|
428
425
|
} satisfies TargetDescriptor;
|
|
429
|
-
`}s(
|
|
426
|
+
`}s(Z_,"TEMPLATE_INDEX");function Q_(t){return `import { describe, it, expect } from 'vitest';
|
|
427
|
+
import type { CanonicalFiles } from '../../../../src/core/types.js';
|
|
428
|
+
import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
|
|
429
|
+
|
|
430
|
+
function makeCanonical(overrides: Partial<CanonicalFiles> = {}): CanonicalFiles {
|
|
431
|
+
return {
|
|
432
|
+
rules: [],
|
|
433
|
+
commands: [],
|
|
434
|
+
agents: [],
|
|
435
|
+
skills: [],
|
|
436
|
+
mcp: null,
|
|
437
|
+
permissions: null,
|
|
438
|
+
hooks: null,
|
|
439
|
+
ignore: [],
|
|
440
|
+
...overrides,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
describe('generateRules (${t.id})', () => {
|
|
445
|
+
it('returns an array', () => {
|
|
446
|
+
const result = generateRules(makeCanonical());
|
|
447
|
+
expect(Array.isArray(result)).toBe(true);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('returns empty array when no rules', () => {
|
|
451
|
+
const result = generateRules(makeCanonical({ rules: [] }));
|
|
452
|
+
expect(result).toHaveLength(0);
|
|
453
|
+
});
|
|
454
|
+
});
|
|
455
|
+
`}s(Q_,"TEMPLATE_GENERATOR_TEST");function q_(t){let e=jn(t.id);return `import { describe, it, expect } from 'vitest';
|
|
456
|
+
import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
|
|
457
|
+
|
|
458
|
+
describe('importFrom${e} (${t.id})', () => {
|
|
459
|
+
it('returns an array', async () => {
|
|
460
|
+
const result = await importFrom${e}('/tmp/stub-project');
|
|
461
|
+
expect(Array.isArray(result)).toBe(true);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
it('returns empty array by default', async () => {
|
|
465
|
+
const result = await importFrom${e}('/tmp/stub-project', { scope: 'project' });
|
|
466
|
+
expect(result).toHaveLength(0);
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
`}s(q_,"TEMPLATE_IMPORTER_TEST");function tI(t){return `# ${t.displayName} Workspace
|
|
470
|
+
|
|
471
|
+
Follow the ${t.displayName} configuration files and keep changes small.
|
|
472
|
+
`}s(tI,"TEMPLATE_FIXTURE_ROOT_MD");function EF(t){let e=Ds(t.id);return `export const ${e}_TARGET = '${t.id}';
|
|
473
|
+
|
|
474
|
+
// Project-level paths
|
|
475
|
+
export const ${e}_DIR = '.${t.id}';
|
|
476
|
+
export const ${e}_RULES_DIR = '.${t.id}/rules';
|
|
477
|
+
|
|
478
|
+
// Global-level paths
|
|
479
|
+
export const ${e}_GLOBAL_DIR = '~/.${t.id}';
|
|
480
|
+
export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
|
|
481
|
+
|
|
482
|
+
// Canonical paths
|
|
483
|
+
export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
|
|
484
|
+
export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
|
|
485
|
+
`}s(EF,"TEMPLATE_CONSTANTS");function OF(t){let e=Ds(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
|
|
430
486
|
import { ${e}_TARGET, ${e}_DIR } from './constants.js';
|
|
431
487
|
|
|
432
|
-
export interface ${
|
|
488
|
+
export interface ${jn(t.id)}Output {
|
|
433
489
|
path: string;
|
|
434
490
|
content: string;
|
|
435
491
|
}
|
|
436
492
|
|
|
437
|
-
export function generateRules(_canonical: CanonicalFiles): ${
|
|
493
|
+
export function generateRules(_canonical: CanonicalFiles): ${jn(t.id)}Output[] {
|
|
438
494
|
// TODO(agentsmesh-scaffold): implement generateRules for ${t.displayName}
|
|
439
495
|
void ${e}_TARGET;
|
|
440
496
|
void ${e}_DIR;
|
|
441
497
|
return [];
|
|
442
498
|
}
|
|
443
|
-
`}s(
|
|
499
|
+
`}s(OF,"TEMPLATE_GENERATOR");function kF(t){let e=jn(t.id),r=Ds(t.id);return `import type { ImportResult } from '../../core/types.js';
|
|
444
500
|
import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
|
|
445
501
|
import { ${r}_TARGET } from './constants.js';
|
|
446
502
|
|
|
@@ -452,7 +508,7 @@ export async function importFrom${e}(
|
|
|
452
508
|
void ${r}_TARGET;
|
|
453
509
|
return [];
|
|
454
510
|
}
|
|
455
|
-
`}s(
|
|
511
|
+
`}s(kF,"TEMPLATE_IMPORTER");function LF(t){let e=Ds(t.id);return `/** Lint rules for the ${t.id} target. */
|
|
456
512
|
import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
|
|
457
513
|
import { validateRules } from '../../core/lint/validate-rules.js';
|
|
458
514
|
import { ${e}_TARGET } from './constants.js';
|
|
@@ -470,7 +526,7 @@ export function lintRules(
|
|
|
470
526
|
target: ${e}_TARGET,
|
|
471
527
|
}));
|
|
472
528
|
}
|
|
473
|
-
`}s(
|
|
529
|
+
`}s(LF,"TEMPLATE_LINTER");function AF(t){return `/**
|
|
474
530
|
* ${t.displayName}-specific lint hooks.
|
|
475
531
|
*/
|
|
476
532
|
|
|
@@ -480,7 +536,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
|
|
|
480
536
|
// TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
|
|
481
537
|
return [];
|
|
482
538
|
}
|
|
483
|
-
`}s(
|
|
539
|
+
`}s(AF,"TEMPLATE_LINT_HOOKS");function wF(t){let e=jn(t.id),r=Ds(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
|
|
484
540
|
import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
|
|
485
541
|
|
|
486
542
|
export async function build${e}ImportPaths(
|
|
@@ -492,60 +548,14 @@ export async function build${e}ImportPaths(
|
|
|
492
548
|
// Reference: src/core/reference/import-maps/kiro.ts for a full example
|
|
493
549
|
void ${r}_DIR;
|
|
494
550
|
}
|
|
495
|
-
`}s(
|
|
496
|
-
import type { CanonicalFiles } from '../../../../src/core/types.js';
|
|
497
|
-
import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
|
|
498
|
-
|
|
499
|
-
function makeCanonical(overrides: Partial<CanonicalFiles> = {}): CanonicalFiles {
|
|
500
|
-
return {
|
|
501
|
-
rules: [],
|
|
502
|
-
commands: [],
|
|
503
|
-
agents: [],
|
|
504
|
-
skills: [],
|
|
505
|
-
mcp: null,
|
|
506
|
-
permissions: null,
|
|
507
|
-
hooks: null,
|
|
508
|
-
ignore: [],
|
|
509
|
-
...overrides,
|
|
510
|
-
};
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
describe('generateRules (${t.id})', () => {
|
|
514
|
-
it('returns an array', () => {
|
|
515
|
-
const result = generateRules(makeCanonical());
|
|
516
|
-
expect(Array.isArray(result)).toBe(true);
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
it('returns empty array when no rules', () => {
|
|
520
|
-
const result = generateRules(makeCanonical({ rules: [] }));
|
|
521
|
-
expect(result).toHaveLength(0);
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
`}s(xP,"TEMPLATE_GENERATOR_TEST");function PP(t){let e=ua(t.id);return `import { describe, it, expect } from 'vitest';
|
|
525
|
-
import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
|
|
526
|
-
|
|
527
|
-
describe('importFrom${e} (${t.id})', () => {
|
|
528
|
-
it('returns an array', async () => {
|
|
529
|
-
const result = await importFrom${e}('/tmp/stub-project');
|
|
530
|
-
expect(Array.isArray(result)).toBe(true);
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
it('returns empty array by default', async () => {
|
|
534
|
-
const result = await importFrom${e}('/tmp/stub-project', { scope: 'project' });
|
|
535
|
-
expect(result).toHaveLength(0);
|
|
536
|
-
});
|
|
537
|
-
});
|
|
538
|
-
`}s(PP,"TEMPLATE_IMPORTER_TEST");function TP(t){return `# ${t.displayName} Workspace
|
|
539
|
-
|
|
540
|
-
Follow the ${t.displayName} configuration files and keep changes small.
|
|
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:`---
|
|
551
|
+
`}s(wF,"TEMPLATE_IMPORT_MAP");var eJ=/^[a-z][a-z0-9-]*$/;async function bF(t){let{id:e,projectRoot:r,force:o=false}=t,n=t.displayName??e,i={id:e,displayName:n};if(!eJ.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(yt.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:EF(i)},{rel:`src/targets/${e}/index.ts`,content:Z_(i)},{rel:`src/targets/${e}/generator.ts`,content:OF(i)},{rel:`src/targets/${e}/importer.ts`,content:kF(i)},{rel:`src/targets/${e}/linter.ts`,content:LF(i)},{rel:`src/targets/${e}/lint.ts`,content:AF(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:wF(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:Q_(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:q_(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:tI(i)}],c=[],l=[];for(let p of a){let u=join(r,p.rel);if(!o&&await M(u)){l.push(u);continue}await I(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(bF,"writeTargetScaffold");async function xF(t,e,r){let o=e[0];return o===void 0||o===""?{exitCode:0,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true}:o==="scaffold"?rJ(t,e.slice(1),r):{exitCode:2,data:{id:"",written:[],skipped:[],postSteps:[]},showHelp:true,error:`Unknown target subcommand: ${o}`}}s(xF,"runTarget");async function rJ(t,e,r){let o=e[0];if(!o)throw new Yr("Usage: agentsmesh target scaffold <id> [--name <displayName>] [--force]");let n=typeof t.name=="string"?t.name:void 0,i=t.force===true,a;try{a=await bF({id:o,displayName:n,projectRoot:r,force:i});}catch(c){return {exitCode:1,data:{id:o,written:[],skipped:[],postSteps:[]},error:c instanceof Error?c.message:String(c)}}return {exitCode:0,data:{id:o,written:a.written.map(c=>TF(c,r)),skipped:a.skipped.map(c=>TF(c,r)),postSteps:a.postSteps}}}s(rJ,"runScaffold");function TF(t,e){return (t.startsWith(e)?t.slice(e.length+1):t).replaceAll("\\","/")}s(TF,"relativize");lt();function PF(t){if(t.error&&S.error(t.error),t.showHelp){oJ();return}let{data:e}=t;for(let r of e.written)S.success(`created ${r}`);for(let r of e.skipped)S.warn(`skipped ${r} (already exists \u2014 use --force to overwrite)`);if(e.written.length>0){S.info(""),S.info("Next steps:");for(let r of e.postSteps)S.info(` ${r}`);}}s(PF,"renderTarget");function oJ(){S.info("Usage: agentsmesh target <subcommand> [args] [flags]"),S.info(""),S.info("Subcommands:"),S.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),S.info(""),S.info("Flags (scaffold):"),S.info(" --name <displayName> Human-readable name (defaults to id)"),S.info(" --force Overwrite existing files");}s(oJ,"printTargetHelp");De();Hs();w();Ie();$n();Ho();function pJ(t,e){return t===".agentsmesh"?false:!!(t.startsWith(".")||!e)}s(pJ,"shouldSymlink");function uJ(t){let e=mkdtempSync(join(tmpdir(),"am-convert-")),r=readdirSync(t,{withFileTypes:true});for(let o of r){if(!pJ(o.name,o.isDirectory()))continue;let n=join(t,o.name),i=join(e,o.name);symlinkSync(n,i,o.isDirectory()?"dir":"file");}return mkdirSync(join(e,".agentsmesh"),{recursive:true}),e}s(uJ,"createTempProjectRoot");async function Id(t,e){let r=e??process.cwd(),o=t.global===true?"global":"project",n=o==="global"?homedir():r,i=t.from,a=t.to;if(typeof i!="string"||!i)throw new Error("--from is required. Example: agentsmesh convert --from cursor --to claude-code");if(typeof a!="string"||!a)throw new Error("--to is required. Example: agentsmesh convert --from cursor --to claude-code");let c=i.toLowerCase().trim(),l=a.toLowerCase().trim();if(c===l)throw new Error("--from and --to must be different targets.");let m=yr(c),p=yr(l);if(!m||!p)try{let{config:R}=await Rt(r,"project");await oe(R,r);}catch{let R=[];throw m||R.push(`--from "${i}"`),p||R.push(`--to "${a}"`),new Error(`Unknown ${R.join(" and ")}. Supported: ${yt.join(", ")}.`)}let u=it(c);if(!u)throw new Error(`Unknown --from "${i}". Supported: ${yt.join(", ")}.`);if(!it(l))throw new Error(`Unknown --to "${a}". Supported: ${yt.join(", ")}.`);let g=t["dry-run"]===true,h=g?"dry-run":"convert",C=uJ(n);try{await u.generators.importFrom(C,{scope:o});let R=await Re(C),_=$s.parse({version:1,targets:p?[l]:[],pluginTargets:p?[]:[l]}),A=await dr({config:_,canonical:R,projectRoot:n,scope:o,targetFilter:[l]});if(!g){for(let T of A)if(T.status==="created"||T.status==="updated"){let rt=hc(n,T.path,T.target);await I(rt,T.content);}}let D=A.filter(T=>T.status!=="skipped"),N=D.map(T=>({path:T.path,target:T.target,status:T.status}));return {exitCode:0,data:{from:c,to:l,mode:h,files:N,summary:{created:D.filter(T=>T.status==="created").length,updated:D.filter(T=>T.status==="updated").length,unchanged:D.filter(T=>T.status==="unchanged").length}}}}finally{rmSync(C,{recursive:true,force:true});}}s(Id,"runConvert");lt();function NF(t){let{data:e}=t;if(e.files.length===0){S.info(`No files found to convert from ${e.from}.`);return}if(e.mode==="dry-run"){for(let i of e.files)S.info(`[dry-run] ${i.status} ${i.path} (${i.target})`);return}for(let i of e.files)(i.status==="created"||i.status==="updated")&&S.success(`${i.status} ${i.path}`);let{created:r,updated:o,unchanged:n}=e.summary;r>0||o>0?S.info(`Converted from ${e.from} \u2192 ${e.to}: ${r} created, ${o} updated, ${n} unchanged`):S.info(`Nothing changed. (${n} unchanged)`);}s(NF,"renderConvert");var dJ=/(^|\s)\/[A-Za-z]|^[A-Z]:[\\/]/,$=class extends Error{static{s(this,"McpError");}code;details;constructor(e,r,o){if(dJ.test(r))throw new Error(`McpError refuses absolute fs path in message: ${r}`);super(r),this.code=e,this.details=o;}toEnvelope(){return this.details===void 0?{code:this.code,message:this.message}:{code:this.code,message:this.message,details:this.details}}};function DF(t){return t.replace(/(['"`])\/[^'"`\s]+\1/gu,"$1<redacted>$1").replace(/(\s|^)\/[A-Za-z][^\s'"`]*/gu,"$1<redacted>").replace(/(\s|^)[A-Z]:[\\/][^\s'"`]*/gu,"$1<redacted>")}s(DF,"redactAbsolutePaths");async function eI(t){let e=resolve(t.projectRoot,".agentsmesh",t.feature),r=resolve(e,t.relativePath);if(!r.startsWith(e+sep)&&r!==e)throw new $("PATH_TRAVERSAL",`path escapes ${t.feature} directory`);if(Buffer.byteLength(t.content,"utf8")>1048576)throw new $("LIMIT_EXCEEDED","file body exceeds 1 MiB cap",{limit:1048576,actual:Buffer.byteLength(t.content,"utf8")});await mkdir(dirname(r),{recursive:true});let o=`${r}.tmp.${process.pid}.${Date.now()}`;return await writeFile(o,t.content,"utf8"),await rename(o,r),r}s(eI,"safeWrite");var RJ=/^---\r?\n([\s\S]*?)\r?\n---\r?\n\r?\n?([\s\S]*)$/;function vs(t){let e=RJ.exec(t);return e?{frontmatter:parse(e[1]??"")??{},body:e[2]??""}:{frontmatter:{},body:t}}s(vs,"parseMd");function Ec(t,e){return Object.keys(t).length===0?e:`---
|
|
542
552
|
${stringify(t).trimEnd()}
|
|
543
553
|
---
|
|
544
554
|
|
|
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
|
-
`),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),
|
|
547
|
-
`),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),
|
|
548
|
-
`),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),
|
|
555
|
+
${e}`}s(Ec,"serializeMd");var LJ=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,AJ={rules:"_root"};function Sd(t){if(!LJ.test(t)||t.includes(".."))throw new $("INVALID_NAME",`invalid name: ${t}`)}s(Sd,"checkName");function Rd(t,e,r){return resolve(t,".agentsmesh",e,`${r}.md`)}s(Rd,"pathFor");function Oc(t){let{feature:e,frontmatterSchema:r,toSummary:o}=t,n=s(c=>resolve(c,".agentsmesh",e),"featureDir");async function i(c){try{return (await readdir(n(c),{withFileTypes:!0})).filter(m=>m.isFile()&&m.name.endsWith(".md")).map(m=>m.name)}catch{return []}}s(i,"listFiles");async function a(c){try{return await stat(c),!0}catch{return false}}return s(a,"exists"),{async list(c){let l=await i(c.projectRoot),m=[];for(let p of l){let u=p.replace(/\.md$/,""),f=await readFile(join(n(c.projectRoot),p),"utf8"),{frontmatter:g}=vs(f);m.push(o(u,g));}return m},async get(c,{name:l}){Sd(l);let m=Rd(c.projectRoot,e,l);try{let p=await readFile(m,"utf8"),{frontmatter:u,body:f}=vs(p);return {name:l,frontmatter:u,body:f}}catch(p){let u=p.code;throw u==="ENOENT"?new $("NOT_FOUND",`${e} "${l}" not found`):new $("IO_ERROR",`failed to read ${e}`,{errno:u})}},async create(c,{name:l,frontmatter:m,body:p,dry_run:u}){Sd(l);let f=r.safeParse(m);if(!f.success)throw new $("VALIDATION_FAILED","invalid frontmatter",f.error.issues);let g=Rd(c.projectRoot,e,l);if(await a(g))throw new $("ALREADY_EXISTS",`${e} "${l}" exists`);if((await i(c.projectRoot)).length>=1e3)throw new $("LIMIT_EXCEEDED",`${e} dir at ${1e3} entries`);let C=Ec(m,p);return u===true?{path:g,written:false}:(await eI({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:C}),{path:g,written:true})},async update(c,{name:l,frontmatter:m,body:p,merge:u,dry_run:f}){Sd(l);let g=Rd(c.projectRoot,e,l),h;try{let D=await readFile(g,"utf8");h=vs(D);}catch(D){let N=D.code;throw N==="ENOENT"?new $("NOT_FOUND",`${e} "${l}" not found`):new $("IO_ERROR",`failed to read ${e}`,{errno:N})}let C=m===void 0?h.frontmatter:u===true?{...h.frontmatter,...m}:m,R=r.safeParse(C);if(!R.success)throw new $("VALIDATION_FAILED","invalid frontmatter",R.error.issues);let _=p!==void 0?p:h.body,A=Ec(C,_);return f===true?{path:g,written:false}:(await eI({projectRoot:c.projectRoot,feature:e,relativePath:`${l}.md`,content:A}),{path:g,written:true})},async delete(c,{name:l,force:m,dry_run:p}){if(Sd(l),AJ[e]===l&&m!==true)throw new $("PROTECTED_FILE",`${e} "${l}" requires force: true`);let u=Rd(c.projectRoot,e,l);if(!await a(u))throw new $("NOT_FOUND",`${e} "${l}" not found`);return p===true?{path:u,deleted:false}:(await rm$1(u),{path:u,deleted:true})}}}s(Oc,"createCanonicalHandlers");var wJ=z.object({description:z.string().optional(),root:z.boolean().optional(),globs:z.array(z.string()).nullable().optional(),targets:z.array(z.string()).nullable().optional()}).passthrough(),MF=Oc({feature:"rules",frontmatterSchema:wJ,toSummary:s((t,e)=>({name:t,description:e.description??null,root:!!e.root,globs:e.globs??null,targets:e.targets??null}),"toSummary")});var bJ=z.object({description:z.string().optional(),"allowed-tools":z.array(z.string()).optional()}).passthrough(),GF=Oc({feature:"commands",frontmatterSchema:bJ,toSummary:s((t,e)=>({name:t,description:e.description??null,allowedTools:e["allowed-tools"]??null}),"toSummary")});var TJ=z.object({name:z.string().optional(),description:z.string().optional(),tools:z.array(z.string()).optional(),model:z.string().optional()}).passthrough(),$F=Oc({feature:"agents",frontmatterSchema:TJ,toSummary:s((t,e)=>({name:t,description:e.description??null,tools:e.tools??null,model:e.model??null}),"toSummary")});var xJ=z.object({name:z.string().describe('Item name (e.g. "auth", "code-review")')}),PJ=z.object({name:z.string().describe('Item name (e.g. "auth", "code-review")'),frontmatter:z.record(z.string(),z.unknown()).describe("YAML frontmatter fields (e.g. { description, globs, targets })"),body:z.string().describe("Markdown body content"),dry_run:z.boolean().optional().describe("Preview changes without writing to disk")}),NJ=z.object({}).strict();function oI(t,e){let r=t==="rule"?"rules":t==="command"?"commands":"agents";return [{name:`list_${r}`,description:`List ${r} with summary metadata`,inputSchema:NJ,handler:s(o=>e.list(o),"handler"),resourceUri:`agentsmesh://canonical/${r}`},{name:`get_${t}`,description:`Get a single ${t} by name`,inputSchema:xJ,handler:s((o,n)=>e.get(o,n),"handler"),resourceUri:`agentsmesh://canonical/${r}/{name}`},{name:`create_${t}`,description:`Create a new ${t}`,inputSchema:PJ,handler:s((o,n)=>e.create(o,n),"handler")},{name:`update_${t}`,description:`Update a ${t}. Default: replace frontmatter entirely. Set merge=true to shallow-merge. Omitting body preserves the existing body.`,inputSchema:z.object({name:z.string().describe("Name of the item to update"),frontmatter:z.record(z.string(),z.unknown()).optional().describe("New frontmatter fields (replaces by default; set merge=true to shallow-merge)"),body:z.string().optional().describe("New markdown body (omit to preserve existing)"),merge:z.boolean().optional().describe("If true, shallow-merge frontmatter instead of replacing"),dry_run:z.boolean().optional().describe("Preview changes without writing to disk")}),handler:s((o,n)=>e.update(o,n),"handler")},{name:`delete_${t}`,description:`Delete a ${t}. For rules: deleting _root requires force=true.`,inputSchema:z.object({name:z.string().describe("Name of the item to delete"),force:z.boolean().optional().describe("Required to delete protected files like _root"),dry_run:z.boolean().optional().describe("Preview without deleting")}),handler:s((o,n)=>e.delete(o,n),"handler")}]}s(oI,"canonicalTools");var jF=[...oI("rule",MF),...oI("command",GF),...oI("agent",$F)];async function WF(t){let e=resolve(t.projectRoot,".agentsmesh/skills",t.skillName),r=resolve(e,t.filePath);if(!r.startsWith(e+sep)&&r!==e)throw new $("PATH_TRAVERSAL","file escapes skill directory");try{return await readFile(r,"utf8")}catch(o){throw o.code==="ENOENT"?new $("NOT_FOUND",`skill file not found: ${t.filePath}`):new $("IO_ERROR","failed to read skill file")}}s(WF,"safeRead");var jJ=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,UJ=/^[a-zA-Z0-9_][a-zA-Z0-9_/-]*\.[a-zA-Z0-9]+$/,zF=z.object({name:z.string().optional(),description:z.string().optional()}).passthrough();function pm(t){if(!jJ.test(t))throw new $("INVALID_NAME",`invalid skill name: ${t}`)}s(pm,"checkName");function iI(t){if(!UJ.test(t)||t.includes("..")||t.includes("//"))throw new $("PATH_TRAVERSAL",`invalid supporting-file path: ${t}`)}s(iI,"checkSupportPath");async function Od(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new $("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(Od,"atomicWrite");var VF=s(t=>resolve(t,".agentsmesh/skills"),"skillsDir"),um=s((t,e)=>resolve(VF(t),e),"skillDir"),Zi={async list(t){let e;try{e=(await readdir(VF(t.projectRoot),{withFileTypes:!0})).filter(o=>o.isDirectory()).map(o=>o.name);}catch{return []}let r=[];for(let o of e)try{let n=await readFile(resolve(um(t.projectRoot,o),"SKILL.md"),"utf8"),i=vs(n).frontmatter;r.push({name:o,description:i.description??null});}catch{}return r},async get(t,{name:e}){pm(e);let r=um(t.projectRoot,e);try{let o=await readFile(resolve(r,"SKILL.md"),"utf8"),{frontmatter:n,body:i}=vs(o),c=(await readdir(r)).filter(l=>l!=="SKILL.md").sort();return {name:e,frontmatter:n,body:i,supportingFiles:c}}catch(o){throw o.code==="ENOENT"?new $("NOT_FOUND",`skill "${e}" not found`):new $("IO_ERROR","failed to read skill")}},async getFile(t,{name:e,path:r}){return pm(e),iI(r),{content:await WF({projectRoot:t.projectRoot,skillName:e,filePath:r}),encoding:"utf-8"}},async create(t,e){pm(e.name);let r=zF.safeParse(e.frontmatter);if(!r.success)throw new $("VALIDATION_FAILED","invalid frontmatter",r.error.issues);let o=um(t.projectRoot,e.name),n=false;try{await stat(o),n=!0;}catch{}if(n)throw new $("ALREADY_EXISTS",`skill "${e.name}" exists`);let i=e.supportingFiles??{},a=Object.keys(i);if(a.forEach(iI),a.length+1>1e3)throw new $("LIMIT_EXCEEDED","supporting files exceed cap");if(e.dry_run===true)return {path:o,written:false,supportingFilesWritten:[]};let c=resolve(o,"SKILL.md");await Od(c,Ec(e.frontmatter,e.body));for(let[l,m]of Object.entries(i))await Od(resolve(o,l),m);return {path:o,written:true,supportingFilesWritten:a}},async update(t,e){pm(e.name);let r=um(t.projectRoot,e.name),o;try{let p=await readFile(resolve(r,"SKILL.md"),"utf8");o=vs(p);}catch(p){throw p.code==="ENOENT"?new $("NOT_FOUND",`skill "${e.name}" not found`):new $("IO_ERROR","failed to read skill")}let n=e.frontmatter===void 0?o.frontmatter:e.merge===true?{...o.frontmatter,...e.frontmatter}:e.frontmatter,i=zF.safeParse(n);if(!i.success)throw new $("VALIDATION_FAILED","invalid frontmatter",i.error.issues);let a=e.body!==void 0?e.body:o.body,c=e.supportingFiles??{};Object.keys(c).forEach(iI);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 Od(resolve(r,"SKILL.md"),Ec(n,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 Od(f,u),l.push(p);}return {path:r,written:true,supportingFilesAffected:{written:l,deleted:m}}},async delete(t,{name:e,dry_run:r}){pm(e);let o=um(t.projectRoot,e);try{await stat(o);}catch{throw new $("NOT_FOUND",`skill "${e}" not found`)}return r===true?{path:o,deleted:false}:(await rm$1(o,{recursive:true}),{path:o,deleted:true})}};var WJ=z.object({}).strict(),KJ=z.object({name:z.string().describe("Item name")}),JF=[{name:"list_skills",description:"List skills",inputSchema:WJ,handler:s(t=>Zi.list(t),"handler"),resourceUri:"agentsmesh://canonical/skills"},{name:"get_skill",description:"Get one skill (frontmatter + body + supporting filenames)",inputSchema:KJ,handler:s((t,e)=>Zi.get(t,e),"handler"),resourceUri:"agentsmesh://canonical/skills/{name}"},{name:"get_skill_file",description:"Read a skill supporting file by name and relative path",inputSchema:z.object({name:z.string().describe("Skill name"),path:z.string().describe('Relative path within the skill directory (e.g. "helper.md")')}),handler:s((t,e)=>Zi.getFile(t,e),"handler"),resourceUri:"agentsmesh://canonical/skills/{name}/files/{path}"},{name:"create_skill",description:"Create a skill directory with SKILL.md and optional supporting files",inputSchema:z.object({name:z.string().describe("Skill name (becomes directory name)"),frontmatter:z.record(z.string(),z.unknown()).describe("YAML frontmatter for SKILL.md"),body:z.string().describe("Markdown body for SKILL.md"),supportingFiles:z.record(z.string(),z.string()).optional().describe("Map of relative-path \u2192 content for supporting files"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Zi.create(t,e),"handler")},{name:"update_skill",description:"Update a skill. supportingFiles: string value writes/replaces, null deletes, unlisted files are untouched.",inputSchema:z.object({name:z.string().describe("Skill name"),frontmatter:z.record(z.string(),z.unknown()).optional().describe("New frontmatter (replaces by default; merge=true to shallow-merge)"),body:z.string().optional().describe("New body (omit to preserve existing)"),merge:z.boolean().optional().describe("Shallow-merge frontmatter instead of replacing"),supportingFiles:z.record(z.string(),z.union([z.string(),z.null()])).optional().describe("Map of path \u2192 content (string=write, null=delete, absent=keep)"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Zi.update(t,e),"handler")},{name:"delete_skill",description:"Delete a skill",inputSchema:z.object({name:z.string(),dry_run:z.boolean().optional()}),handler:s((t,e)=>Zi.delete(t,e),"handler")}];async function YF(t){if(t.filename!==void 0&&t.filename!=="agentsmesh.yaml")throw new $("PATH_TRAVERSAL","only agentsmesh.yaml is writable");if(Buffer.byteLength(t.content,"utf8")>1048576)throw new $("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(YF,"safeConfigWrite");Ho();Gc();async function dm(t){try{return parse(await readFile(t,"utf8"))}catch(e){if(e.code==="ENOENT")return null;throw new $("IO_ERROR","failed to read yaml")}}s(dm,"readYaml");async function Lc(t,e){if(Buffer.byteLength(e,"utf8")>1048576)throw new $("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(Lc,"atomicWrite");var Ge={async getConfig(t){let e=await dm(resolve(t.projectRoot,"agentsmesh.yaml"));if(e===null)throw new $("NO_PROJECT","agentsmesh.yaml missing");return e},async listMcpServers(t){let e=resolve(t.projectRoot,".agentsmesh/mcp.json");try{return {servers:(await Ir(e))?.mcpServers??null}}catch{return {servers:null}}},async getPermissions(t){return await dm(resolve(t.projectRoot,".agentsmesh/permissions.yaml"))??null},async getHooks(t){return await dm(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 dm(resolve(t.projectRoot,"agentsmesh.yaml"))??{},o={...r},n=s((l,m)=>{m!==void 0&&(o[l]=e.merge===true&&Array.isArray(r[l])?Array.from(new Set([...r[l],...m])):m);},"apply");n("targets",e.targets),n("features",e.features),e.conversions!==void 0&&(o.conversions=e.merge===true&&r.conversions!==void 0?{...r.conversions,...e.conversions}:e.conversions);let i=$s.safeParse(o);if(!i.success)throw new $("VALIDATION_FAILED","invalid config",i.error.issues);let a=stringify(o);return e.dry_run===true?{path:resolve(t.projectRoot,"agentsmesh.yaml"),written:false}:{path:await YF({projectRoot:t.projectRoot,content:a,filename:e.filename}),written:true}},async addMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await Ir(r).catch(()=>null)??{mcpServers:{}};if(o.mcpServers[e.name]!==void 0)throw new $("ALREADY_EXISTS",`server "${e.name}" exists`);return o.mcpServers[e.name]=e.server,e.dry_run===true?{path:r,written:false}:(await Lc(r,JSON.stringify(o,null,2)+`
|
|
556
|
+
`),{path:r,written:true})},async updateMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await Ir(r).catch(()=>null);if(o===null||o.mcpServers[e.name]===void 0)throw new $("NOT_FOUND",`server "${e.name}" not found`);return o.mcpServers[e.name]=e.merge===true?{...o.mcpServers[e.name],...e.server}:e.server,e.dry_run===true?{path:r,written:false}:(await Lc(r,JSON.stringify(o,null,2)+`
|
|
557
|
+
`),{path:r,written:true})},async removeMcpServer(t,e){let r=resolve(t.projectRoot,".agentsmesh/mcp.json"),o=await Ir(r).catch(()=>null);if(o===null||o.mcpServers[e.name]===void 0)throw new $("NOT_FOUND",`server "${e.name}" not found`);return delete o.mcpServers[e.name],e.dry_run===true?{path:r,removed:false}:(await Lc(r,JSON.stringify(o,null,2)+`
|
|
558
|
+
`),{path:r,removed:true})},async updatePermissions(t,e){let r=resolve(t.projectRoot,".agentsmesh/permissions.yaml"),o=await dm(r)??{allow:[],deny:[],ask:[]},n={...o},i=s((a,c)=>{c!==void 0&&(n[a]=e.mode==="append"?Array.from(new Set([...o[a]??[],...c])):c);},"apply");return i("allow",e.allow),i("deny",e.deny),i("ask",e.ask),e.dry_run===true?{path:r,written:false}:(await Lc(r,stringify(n)),{path:r,written:true})},async updateHooks(t,e){let r=resolve(t.projectRoot,".agentsmesh/hooks.yaml");return e.dry_run===true?{path:r,written:false}:(await Lc(r,stringify(e.hooks)),{path:r,written:true})},async updateIgnore(t,e){let r=resolve(t.projectRoot,".agentsmesh/ignore"),o;if(e.mode==="append"){let n=(await readFile(r,"utf8").catch(()=>"")).split(/\r?\n/).filter(Boolean);o=Array.from(new Set([...n,...e.patterns]));}else o=e.patterns;return e.dry_run===true?{path:r,written:false}:(await Lc(r,o.join(`
|
|
549
559
|
`)+`
|
|
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{
|
|
560
|
+
`),{path:r,written:true})}};var s1=/[;&|`$<>!\\\r\n]/u,i1=/^[A-Za-z_][A-Za-z0-9_]*$/u,a1=/^[A-Za-z][A-Za-z0-9_-]*$/u,c1=/^[A-Za-z][A-Za-z0-9_-]*(\([^)]*\))?$/u,QF=/[\r\n]/u;function l1(t){return z.string().min(1).max(512).refine(e=>!s1.test(e),{message:`${t} must not contain shell metacharacters (;&|\`$<>!\\\\, newlines)`})}s(l1,"noShellMeta");var lI=z.object({type:z.enum(["stdio","sse","http","streamable-http","streamable_http"]).optional(),description:z.string().max(1024).optional(),command:l1("command").optional(),args:z.array(z.string().max(2048)).max(100).optional(),env:z.record(z.string().regex(i1,"env key must be a valid identifier"),z.string().max(8192)).optional(),url:z.string().url().max(2048).refine(t=>/^https?:\/\//u.test(t),{message:"url must use http(s) protocol"}).optional(),headers:z.record(z.string().regex(a1,"header name must be a valid identifier"),z.string().max(8192)).optional(),cwd:z.string().max(2048).optional(),disabled:z.boolean().optional(),timeout:z.number().int().nonnegative().max(36e5).optional()}).strict(),m1=z.object({type:z.enum(["command","prompt"]).optional(),command:z.string().min(1).max(8192).optional(),prompt:z.string().min(1).max(8192).optional(),timeout:z.number().int().nonnegative().max(36e5).optional()}).strict().refine(t=>(t.command??"").length>0||(t.prompt??"").length>0,{message:"hook entry must define command or prompt"}),qF=z.string().max(256).refine(t=>!QF.test(t),{message:"hook matcher must not contain newlines"}),p1=z.object({matcher:qF,type:z.enum(["command","prompt"]).optional(),command:z.string().min(1).max(8192).optional(),prompt:z.string().min(1).max(8192).optional(),timeout:z.number().int().nonnegative().max(36e5).optional()}).strict().refine(t=>(t.command??"").length>0||(t.prompt??"").length>0,{message:"hook entry must define command or prompt"}),u1=z.object({matcher:qF,hooks:z.array(m1).min(1).max(50)}).strict(),d1=z.union([p1,u1]),tv=z.record(z.string().min(1).max(64),z.array(d1).max(100)),f1=z.string().min(1).max(256).refine(t=>!QF.test(t),{message:"permission pattern must not contain newlines"}).refine(t=>c1.test(t),{message:"permission pattern must match Tool or Tool(matcher) form"}),Ld=z.array(f1).max(500);var fm=z.object({}).strict(),g1=[{name:"get_config",description:"Read agentsmesh.yaml",inputSchema:fm,handler:s(t=>Ge.getConfig(t),"handler"),resourceUri:"agentsmesh://config"},{name:"list_mcp_servers",description:"List MCP servers in canonical mcp.json",inputSchema:fm,handler:s(t=>Ge.listMcpServers(t),"handler"),resourceUri:"agentsmesh://canonical/mcp"},{name:"get_permissions",description:"Read permissions.yaml",inputSchema:fm,handler:s(t=>Ge.getPermissions(t),"handler"),resourceUri:"agentsmesh://canonical/permissions"},{name:"get_hooks",description:"Read hooks.yaml",inputSchema:fm,handler:s(t=>Ge.getHooks(t),"handler"),resourceUri:"agentsmesh://canonical/hooks"},{name:"get_ignore",description:"Read ignore patterns",inputSchema:fm,handler:s(t=>Ge.getIgnore(t),"handler"),resourceUri:"agentsmesh://canonical/ignore"}],h1=[{name:"update_config",description:"Update agentsmesh.yaml. Default: replace listed fields. Set merge=true to union arrays and shallow-merge objects. Only writes agentsmesh.yaml, never agentsmesh.local.yaml.",inputSchema:z.object({targets:z.array(z.string()).optional().describe('Target tool IDs (e.g. ["claude-code", "cursor"])'),features:z.array(z.string()).optional().describe('Feature names (e.g. ["rules", "commands", "mcp"])'),conversions:z.record(z.string(),z.unknown()).optional().describe("Conversion overrides"),merge:z.boolean().optional().describe("If true, union arrays and shallow-merge objects instead of replacing"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ge.updateConfig(t,e),"handler")},{name:"add_mcp_server",description:"Add an MCP server entry to .agentsmesh/mcp.json. Fails if name already exists.",inputSchema:z.object({name:z.string().describe('Server name (e.g. "github", "filesystem")'),server:lI.describe('Server config (e.g. { type: "stdio", command: "npx", args: [...], env: {...} })'),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ge.addMcpServer(t,e),"handler")},{name:"update_mcp_server",description:"Update an MCP server entry (replace or merge)",inputSchema:z.object({name:z.string(),server:lI,merge:z.boolean().optional(),dry_run:z.boolean().optional()}),handler:s((t,e)=>Ge.updateMcpServer(t,e),"handler")},{name:"remove_mcp_server",description:"Remove an MCP server entry",inputSchema:z.object({name:z.string(),dry_run:z.boolean().optional()}),handler:s((t,e)=>Ge.removeMcpServer(t,e),"handler")},{name:"update_permissions",description:"Update permissions.yaml. mode=replace (default) overwrites listed fields; mode=append unions and dedups.",inputSchema:z.object({allow:Ld.optional().describe('Allowed tool patterns (e.g. ["Bash(npm run:*)"])'),deny:Ld.optional().describe("Denied tool patterns"),ask:Ld.optional().describe("Tools requiring confirmation"),mode:z.enum(["replace","append"]).optional().describe("replace=overwrite, append=union+dedup (default: replace)"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ge.updatePermissions(t,e),"handler")},{name:"update_hooks",description:"Replace hooks.yaml content entirely. Read current hooks with get_hooks, modify, then write back.",inputSchema:z.object({hooks:tv.describe("Full hooks structure (e.g. { PreToolUse: [...], PostToolUse: [...] })"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ge.updateHooks(t,e),"handler")},{name:"update_ignore",description:"Update .agentsmesh/ignore patterns. mode=replace (default) overwrites; mode=append adds new patterns.",inputSchema:z.object({patterns:z.array(z.string()).describe('Gitignore-syntax patterns (e.g. ["node_modules/", "dist/", ".env*"])'),mode:z.enum(["replace","append"]).optional().describe("replace=overwrite, append=add (default: replace)"),dry_run:z.boolean().optional().describe("Preview without writing")}),handler:s((t,e)=>Ge.updateIgnore(t,e),"handler")}],ev=[...g1,...h1];r_();_r();function y1(){return Object.fromEntries(yt.map(t=>[t,Object.fromEntries(Object.entries(kN).map(([e,r])=>[e,r[t]]))]))}s(y1,"buildTargetIndex");var rv=y1(),mI={async list(){return rv},async get(t){let e=rv[t.targetId];if(e===void 0)throw new $("NOT_FOUND",`unknown target: ${t.targetId}`);return {targetId:t.targetId,capabilities:e}}};Bo();Bo();Im();Ie();jo();$n();De();_r();async function pI(t,e){let r=it(t);if(!r)throw new Xr(t,{supported:[...yt,...Tu().map(o=>o.id)]});return r.generators.importFrom(e.root,{scope:e.scope??"project"})}s(pI,"importFrom");async function Ac(t,e={}){let r=e.scope??"project",{config:o,context:n}=await Rt(t,r);await oe(o,t);let{canonical:i}=await pe(o,n.configDir,{refreshRemoteCache:e.refreshRemoteCache===true},n.canonicalDir);return {config:o,canonical:i,projectRoot:n.rootBase,scope:r,configDir:n.configDir,canonicalDir:n.canonicalDir}}s(Ac,"loadProjectContext");async function uI(t){let e=t.targetFilter?[...t.targetFilter]:void 0;return ad(t.config,t.canonical,t.projectRoot,e,{scope:t.scope})}s(uI,"lint");async function dI(t){let e=await dr(t);return {...sd(e),results:e}}s(dI,"diff");async function fI(t){return cd(t)}s(fI,"check");Bo();jo();Hs();Im();kt();De();wt();w();function Ms(t){if(t instanceof $)throw t;if(t instanceof Xr)throw new $("VALIDATION_FAILED",t.message);let e=t instanceof Error?t.message:String(t);throw /unknown.*--from|unknown.*--to|unknown target/i.test(e)?new $("VALIDATION_FAILED",e):/lock/i.test(e)?new $("LOCK_HELD","generate lock is held"):new $("IO_ERROR","engine failure",{reason:e})}s(Ms,"wrapEngineError");async function ov(t,e){if(e.dry_run===true)throw new $("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 pI(e.from,{root:t.projectRoot,scope:"project"});return {imported:r.length,files:r.map(o=>({fromPath:o.fromPath,toPath:o.toPath,feature:o.feature})),warnings:[],errors:[]}}catch(r){if(r instanceof Xr)throw new $("VALIDATION_FAILED",`unknown target "${e.from}"`);let o=r instanceof Error?r.message:String(r);if(/unknown target|invalid target|not found/i.test(o))throw new $("VALIDATION_FAILED",o);Ms(r);}}s(ov,"importFromTarget");async function nv(t,e){try{let r={from:e.from,to:e.to,"dry-run":e.dry_run===!0},o=await Id(r,t.projectRoot);return {filesAffected:o.data.summary.created+o.data.summary.updated,dryRun:e.dry_run===!0,warnings:[],errors:[]}}catch(r){let o=r instanceof Error?r.message:String(r);if(/unknown.*--from|unknown.*--to|unknown target/i.test(o))throw new $("VALIDATION_FAILED",o);Ms(r);}}s(nv,"convert");async function R1(t,e){try{let r=await Ac(t.projectRoot),o=e.targets&&e.targets.length>0?e.targets:void 0,i=(await dr({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:o})).filter(m=>m.status!=="skipped"),a=i.filter(m=>m.status==="created"||m.status==="updated");if(!e.dry_run)for(let m of a){let p=hc(r.projectRoot,m.path,m.target);await I(p,m.content);}let c={};for(let m of a){let p=c[m.target]??{filesWritten:0};c[m.target]={filesWritten:p.filesWritten+1};}let l={filesWritten:a.length,byTarget:c,lockfileUpdated:!e.dry_run&&a.length>=0,errors:[],warnings:[]};return e.verbose===!0&&(l.files=i.map(m=>m.path)),l}catch(r){Ms(r);}}s(R1,"generate");async function C1(t,e){try{let r=await Ac(t.projectRoot),o=await uI({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope});return {issues:(e.severity?o.diagnostics.filter(i=>i.level===e.severity):o.diagnostics).map(i=>({level:i.level,file:i.file,target:i.target,message:i.message}))}}catch(r){Ms(r);}}s(C1,"lint");async function E1(t){try{let e=await Ac(t.projectRoot),r=await fI({config:e.config,configDir:e.configDir,canonicalDir:e.canonicalDir});return {drift:!r.inSync,missing:[...r.removed],extra:[...r.added],modified:[...r.modified]}}catch(e){Ms(e);}}s(E1,"check");async function O1(t,e){try{let r=await Ac(t.projectRoot),o=e.targets&&e.targets.length>0?e.targets:void 0,n=await dI({config:r.config,canonical:r.canonical,projectRoot:r.projectRoot,scope:r.scope,targetFilter:o});return {willCreate:n.summary.new,willModify:n.summary.updated,willDelete:n.summary.deleted}}catch(r){Ms(r);}}s(O1,"diff");var Qi={generate:R1,lint:C1,check:E1,diff:O1,import:ov,convert:nv};var sv=z.object({}).strict(),iv=[{name:"list_target_capabilities",description:"List support matrix for all targets",inputSchema:sv,handler:s(()=>mI.list(),"handler"),resourceUri:"agentsmesh://capabilities"},{name:"get_target_capabilities",description:"Get feature support levels for a specific target (e.g. which features are native, mapped, or unsupported)",inputSchema:z.object({targetId:z.string().describe('Target tool ID (e.g. "claude-code", "cursor")')}),handler:s((t,e)=>mI.get(e),"handler"),resourceUri:"agentsmesh://capabilities/{targetId}"},{name:"generate",description:"Generate target-native config files from canonical .agentsmesh/ content. Propagates rules, commands, agents, skills, MCP, hooks, ignore, and permissions to all configured targets.",inputSchema:z.object({targets:z.array(z.string()).optional().describe("Filter to specific targets (default: all from agentsmesh.yaml)"),features:z.array(z.string()).optional().describe("Filter to specific features"),verbose:z.boolean().optional().describe("Include full file list in response"),dry_run:z.boolean().optional().describe("Preview without writing files")}),handler:s((t,e)=>Qi.generate(t,e),"handler")},{name:"lint",description:"Lint canonical .agentsmesh/ files for schema errors, missing frontmatter, and other issues",inputSchema:z.object({severity:z.enum(["error","warning","info"]).optional().describe("Filter results by minimum severity")}),handler:s((t,e)=>Qi.lint(t,e),"handler")},{name:"check",description:"Detect drift between canonical and lockfile",inputSchema:sv,handler:s(t=>Qi.check(t),"handler")},{name:"diff",description:"Preview what generate would create, modify, or delete without writing",inputSchema:z.object({targets:z.array(z.string()).optional().describe("Filter to specific targets"),features:z.array(z.string()).optional().describe("Filter to specific features")}),handler:s((t,e)=>Qi.diff(t,e),"handler")},{name:"import",description:"Import another tool's native config into canonical .agentsmesh/. Note: dry_run is not supported (the engine writes directly).",inputSchema:z.object({from:z.string().describe('Source target ID to import from (e.g. "cursor", "claude-code")'),features:z.array(z.string()).optional().describe("Restrict import to specific features"),dry_run:z.boolean().optional().describe("NOT SUPPORTED \u2014 will throw VALIDATION_FAILED. Use diff instead.")}),handler:s((t,e)=>Qi.import(t,e),"handler")},{name:"convert",description:"Convert config directly from one tool to another (e.g. Cursor \u2192 Claude Code) without creating canonical .agentsmesh/ files",inputSchema:z.object({from:z.string().describe('Source target ID (e.g. "cursor")'),to:z.string().describe('Destination target ID (e.g. "claude-code")'),dry_run:z.boolean().optional().describe("Preview conversion without writing files")}),handler:s((t,e)=>Qi.convert(t,e),"handler")}];function av(t){let e=toJSONSchema(t,{target:"draft-07"});return delete e.$schema,e}s(av,"zodToMcpSchema");var Ad=[...jF,...JF,...ev,...iv],gI=Ad.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")}));Hs();async function w1(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 $("NO_PROJECT","agentsmesh.yaml not found");e=r;}}s(w1,"findProjectRoot");async function hI(t){let e=await w1(t.cwd);return {projectRoot:e,loadCanonical:s(()=>Re(e),"loadCanonical")}}s(hI,"resolveContext");async function G1(){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(G1,"pkgVersion");function $1(t,e){return new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").test(e)}s($1,"matchTemplate");function j1(t,e){let r=[...t.matchAll(/\{([^}]+)\}/g)].map(i=>i[1]),n=new RegExp("^"+t.replace(/\{[^}]+\}/g,"([^/]+)")+"$").exec(e);return n?Object.fromEntries(r.map((i,a)=>[i,n[a+1]])):{}}s(j1,"extractTemplateParams");async function lv(){let t=new Server({name:"agentsmesh-mcp",version:await G1()},{capabilities:{tools:{},resources:{}}});t.setRequestHandler(ListToolsRequestSchema,async()=>({tools:Ad.map(e=>({name:e.name,description:e.description,inputSchema:av(e.inputSchema)}))})),t.setRequestHandler(CallToolRequestSchema,async e=>{let r=Ad.find(o=>o.name===e.params.name);if(!r)return {isError:true,content:[{type:"text",text:JSON.stringify({code:"NOT_FOUND",message:`unknown tool: ${e.params.name}`})}]};try{let o=r.inputSchema.safeParse(e.params.arguments??{});if(!o.success)throw new $("VALIDATION_FAILED","invalid input",o.error.issues);let n=await hI({cwd:process.cwd()}),i=await r.handler(n,o.data);return {content:[{type:"text",text:JSON.stringify(i)}]}}catch(o){let n=o instanceof $?o.toEnvelope():{code:"IO_ERROR",message:DF(o instanceof Error?o.message:"unknown error")};return {isError:true,content:[{type:"text",text:JSON.stringify(n)}]}}}),t.setRequestHandler(ListResourcesRequestSchema,async()=>({resources:gI.map(e=>({uri:e.uri,name:e.name,description:e.description}))})),t.setRequestHandler(ReadResourceRequestSchema,async e=>{let r=gI.find(a=>a.uri===e.params.uri||$1(a.uri,e.params.uri));if(!r)throw new $("NOT_FOUND",`resource not found: ${e.params.uri}`);let o=await hI({cwd:process.cwd()}),n=j1(r.uri,e.params.uri),i=await r.read(o,n);return {contents:[{uri:e.params.uri,mimeType:"application/json",text:JSON.stringify(i)}]}}),await t.connect(new StdioServerTransport);}s(lv,"startServer");lt();async function mv(t,e){EI(),await lv();}s(mv,"runMcp");var pv={generate:s(async(t,e)=>{let r=await yc(t,void 0,{printMatrix:t.json!==true});_e("generate",r,t,()=>_c(r));},"generate"),init:s(async(t,e)=>{let r=await UN(process.cwd(),{yes:t.yes===true,global:t.global===true});_e("init",r,t,()=>WN(r));},"init"),import:s(async(t,e)=>{let r=await BN(t);_e("import",r,t,()=>tD(r));},"import"),diff:s(async(t,e)=>{let r=await zN(t);_e("diff",r,t,()=>eD(r));},"diff"),lint:s(async(t,e)=>{let r=await ZN(t);_e("lint",r,t,()=>QN(r));},"lint"),check:s(async(t,e)=>{let r=await sD(t);_e("check",r,t,()=>qN(r));},"check"),merge:s(async(t,e)=>{let r=await cD(t);_e("merge",r,t,()=>rD(r));},"merge"),matrix:s(async(t,e)=>{let r=await Ql(t);_e("matrix",r,t,()=>tm(r,{verbose:t.verbose===true}));},"matrix"),watch:s(async(t,e)=>{if(t.json===true){ea("watch",{success:false,error:"--json is not supported with watch"}),process.exit(1);return}let r=await nD(t),o=s(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",o),process.on("SIGTERM",o);},"watch"),install:s(async(t,e)=>{t.json===true&&(t.force=true);let r=await hF(t,e,process.cwd());_e("install",r,t,()=>yF(r));},"install"),plugin:s(async(t,e)=>{let r=await RF(t,e,process.cwd());_e("plugin",r,t,()=>CF(r));},"plugin"),target:s(async(t,e)=>{let r=await xF(t,e,process.cwd());_e("target",r,t,()=>PF(r));},"target"),convert:s(async(t,e)=>{let r=await Id(t);_e("convert",r,t,()=>NF(r));},"convert"),mcp:s(async(t,e)=>{await mv();},"mcp")};function K1(t){let e={},r=[],o="help";for(let n=0;n<t.length;n++){let i=t[n];if(o==="help"&&i==="--version")return {command:"version",flags:{},args:[]};if(o==="help"&&i==="--help")return {command:"help",flags:{},args:[]};if(i.startsWith("--")){let a=i.slice(2),c=t[n+1];c===void 0||c.startsWith("--")?e[a]=true:(e[a]=c,n++);continue}o==="help"?o=i:r.push(i);}return {command:o,flags:e,args:r}}s(K1,"parseArgs");var B1=SI(pv);async function H1(t){let{command:e,flags:r,args:o}=t;if(e==="help"){AI();return}if(e==="version"){bI();return}r.json===true&&CI(),await B1.route(e,r,o);}s(H1,"main");function z1(){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(z1,"isMainModule");if(z1()){let t=K1(process.argv.slice(2));H1(t).catch(e=>TI(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true,json:t.flags.json===true,command:t.command}));}
|
|
561
|
+
export{K1 as parseArgs};
|