agentsmesh 0.9.0 → 0.11.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 +47 -0
- package/README.md +25 -23
- package/dist/canonical.d.ts +2 -2
- package/dist/canonical.js +2805 -1190
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +126 -120
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +2787 -1169
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2799 -1181
- package/dist/index.js.map +1 -1
- package/dist/{schema-BeGiBqbB.d.ts → schema-BTitJKiN.d.ts} +6 -0
- package/dist/{target-descriptor-CkH4Z43u.d.ts → target-descriptor-D-Y6BzCL.d.ts} +1 -1
- package/dist/targets.d.ts +3 -3
- package/dist/targets.js +2800 -1202
- package/dist/targets.js.map +1 -1
- package/package.json +2 -2
- package/schemas/agentsmesh.json +9 -0
- package/schemas/pack.json +3 -0
package/dist/cli.js
CHANGED
|
@@ -1,167 +1,173 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {access,mkdir,lstat,unlink,writeFile,rename,rm as rm$1,readlink,symlink,stat,readFile,readdir,realpath,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {dirname,join,resolve,relative,normalize,basename,sep,extname,win32,posix
|
|
3
|
-
`)}async function I(t){try{let e=await readFile(t,"utf-8");return e.startsWith(
|
|
2
|
+
import {access,mkdir,lstat,unlink,writeFile,rename,rm as rm$1,readlink,symlink,stat,readFile,readdir,realpath,mkdtemp,cp as cp$1,copyFile}from'fs/promises';import {dirname,join,resolve,relative,normalize,basename,sep,extname,win32,posix}from'path';import {realpathSync,constants,statSync,existsSync,rmSync}from'fs';import {parse,stringify}from'yaml';import {parse as parse$1}from'smol-toml';import {Buffer}from'buffer';import {z as z$1}from'zod';import {fileURLToPath,pathToFileURL,URL}from'url';import {createRequire}from'module';import {homedir,hostname,tmpdir}from'os';import {createHash}from'crypto';import {execFile}from'child_process';import {promisify}from'util';import*as hg from'tar';import {createTwoFilesPatch}from'diff';import I$ from'chokidar';import*as cL from'readline';var Vf=Object.defineProperty;var i=(t,e)=>Vf(t,"name",{value:e,configurable:true});var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var QL=(t,e)=>{for(var r in e)Vf(t,r,{get:e[r],enumerable:true});};var es,pn,Va,Ja,Ar,_i=f(()=>{es=class extends Error{static{i(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},pn=class extends es{static{i(this,"ConfigNotFoundError");}path;constructor(e,r){super("AM_CONFIG_NOT_FOUND",r?.message??`agentsmesh.yaml not found at ${e}. Run 'agentsmesh init' to create one.`,r),this.name="ConfigNotFoundError",this.path=e;}},Va=class extends es{static{i(this,"ConfigValidationError");}issues;constructor(e,r,n){super("AM_CONFIG_INVALID",`Invalid config at ${e}: ${r.join("; ")}. Fix the YAML and try again.`,n),this.name="ConfigValidationError",this.issues=r;}},Ja=class extends es{static{i(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,n){super("AM_LOCK_ACQUISITION_FAILED",`Could not acquire generate lock at ${e}: currently held by ${r}. Wait for the other process to finish, or remove ${e} manually if you are sure no agentsmesh process is running.`,n),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},Ar=class extends es{static{i(this,"FileSystemError");}path;errnoCode;constructor(e,r,n){super("AM_FILESYSTEM",r,n),this.name="FileSystemError",this.path=e,this.errnoCode=n?.errnoCode;}};});function RA(t){let e=extname(t).toLowerCase();if(e.length>0)return CA.has(e);let r=basename(t).toLowerCase();return OA.has(r)}function kA(t){return t.replace(/\r\n?/g,`
|
|
3
|
+
`)}async function I(t){try{let e=await readFile(t,"utf-8");return e.startsWith(og)?e.slice(og.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new Ar(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 s=await lstat(t);if(s.isDirectory())throw new Ar(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});s.isSymbolicLink()&&await unlink(t).catch(a=>{if(a.code!=="ENOENT")throw a});}catch(s){if(s instanceof Ar||s.code!=="ENOENT")throw s}let n=`${t}.tmp`,o=RA(t)?kA(e):e;try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(s){if(s.code!=="ENOENT")throw s}await writeFile(n,o,{encoding:"utf-8",flag:"w"}),await rename(n,t);}catch(s){await rm$1(n,{force:true}).catch(()=>{});let a=s;throw new Ar(t,`Failed to write ${t}: ${a.message}. Check permissions and disk space.`,{cause:s,errnoCode:a.code})}}async function F(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function R(t){await mkdir(t,{recursive:true});}async function x(t,e){let r;try{r=await realpath(t);}catch(o){let s=o;if(s.code==="ENOENT"||s.code==="ENOTDIR"||s.code==="ELOOP")return [];throw new Ar(t,`Failed to read directory ${t}: ${s.message}. Check permissions.`,{cause:o,errnoCode:s.code})}let n=e??new Set;if(n.has(r))return [];n.add(r);try{let o=await readdir(t,{withFileTypes:!0}),s=[];for(let a of o){let l=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(l).then(m=>m.isDirectory(),()=>!1)?s.push(...await x(l,n)):s.push(l);}return s}catch(o){let s=o;if(s.code==="ENOENT"||s.code==="ENOTDIR"||s.code==="EACCES")return [];throw new Ar(t,`Failed to read directory ${t}: ${s.message}. Check permissions.`,{cause:o,errnoCode:s.code})}}async function gm(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 og,CA,OA,A=f(()=>{_i();og="\uFEFF",CA=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),OA=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);i(RA,"shouldNormalizeLineEndings");i(kA,"normalizeLineEndings");i(I,"readFileSafe");i(S,"writeFileAtomic");i(F,"exists");i(R,"mkdirp");i(x,"readDirRecursive");i(gm,"ensureCacheSymlink");});function un(t){return hm.includes(t)}var hm,ag=f(()=>{hm=["antigravity","claude-code","cline","codex-cli","continue","copilot","cursor","gemini-cli","goose","junie","kilo-code","kiro","opencode","roo-code","windsurf"];i(un,"isBuiltinTargetId");});var Ot,Si,br=f(()=>{ag();Ot=hm,Si="codex-cli";});function E(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 T(t,e){return Object.keys(t).length===0?e:`---
|
|
4
4
|
${stringify(t,{lineWidth:0}).trimEnd()}
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
${e}`}var
|
|
7
|
+
${e}`}var v=f(()=>{i(E,"parseFrontmatter");i(T,"serializeFrontmatter");});function Gg(t){return typeof t=="string"?t.trim():""}function gt(t){return Gg(t.command)}function Gt(t){return Gg(t.prompt)}function Pm(t){let e=gt(t),r=Gt(t);return t.type==="prompt"?r||e:e||r}function Pr(t){return gt(t).length>0}function Ze(t){return Pm(t).length>0}var we=f(()=>{i(Gg,"trimString");i(gt,"getHookCommand");i(Gt,"getHookPrompt");i(Pm,"getHookText");i(Pr,"hasHookCommand");i(Ze,"hasHookText");});function H(t){return t.includes("\\")||Le.test(t)?win32:posix}function ot(t){return t.replace(/\\/g,"/")}function G(t,e){let r=H(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):ot(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function Bg(t,e){return H(t).isAbsolute(e)||Le.test(e)}function ls(t){let e=t,r="";for(;Ab.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function Hg(t,e){let r=H(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?G(e,r.join(e,n)):null}var Le,Ab,Pt=f(()=>{Le=/^[A-Za-z]:[\\/]/,Ab=/[.!?:;]+$/;i(H,"pathApi");i(ot,"normalizeSeparators");i(G,"normalizeForProject");i(Bg,"isAbsoluteForProject");i(ls,"stripTrailingPunctuation");i(Hg,"rootFallbackPath");});function bb(t){return Object.prototype.hasOwnProperty.call(zg,t)}function Pb(t){return Object.prototype.hasOwnProperty.call(Vg,t)}function Jg(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function cs(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],s=Jg(o,n);return s!==void 0?s:bb(e)?zg[e]:r??false}function ae(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],s=Jg(o,n);return s!==void 0?s:Pb(e)?Vg[e]:r??false}var zg,Vg,ms=f(()=>{zg={"codex-cli":true,goose:true,kiro:true},Vg={"gemini-cli":false,cline:true,"codex-cli":false,windsurf:true,goose:true,antigravity:true,continue:true};i(bb,"usesCommandSkillProjection");i(Pb,"usesAgentSkillProjection");i(Jg,"resolveConversionValue");i(cs,"shouldConvertCommandsToSkills");i(ae,"shouldConvertAgentsToSkills");});function be(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Ae(t){return typeof t=="string"?{level:t}:t}function Yg(t){return {rules:Ae(t.rules),additionalRules:Ae(t.additionalRules),commands:Ae(t.commands),agents:Ae(t.agents),skills:Ae(t.skills),mcp:Ae(t.mcp),hooks:Ae(t.hooks),ignore:Ae(t.ignore),permissions:Ae(t.permissions)}}var ro=f(()=>{i(be,"cap");i(Ae,"normalizeCapabilityValue");i(Yg,"normalizeTargetCapabilities");});function Xg(t){for(let e of xt)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function xb(t){let e=[];for(let n of t)if(n.sharedArtifacts)for(let[o,s]of Object.entries(n.sharedArtifacts))s==="owner"&&e.push({targetId:n.id,prefix:o});let r=[];for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++){let s=e[n],a=e[o];s===void 0||a===void 0||(s.prefix===a.prefix||s.prefix.startsWith(a.prefix)||a.prefix.startsWith(s.prefix))&&r.push({a:s,b:a});}return r}function Zg(t){let e=xb(t);if(e.length===0)return;let r=e.map(({a:n,b:o})=>` - "${n.targetId}" owns "${n.prefix}" and "${o.targetId}" owns "${o.prefix}"`);throw new Error(`Shared-artifact ownership conflict: two targets claim the same or overlapping prefix.
|
|
8
8
|
`+r.join(`
|
|
9
9
|
`)+`
|
|
10
|
-
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var
|
|
10
|
+
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`)}var Tm=f(()=>{it();i(Xg,"ownerTargetIdForSharedPath");i(xb,"findSharedArtifactOwnershipConflicts");i(Zg,"assertSharedArtifactOwnersUnique");});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 Tb(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t))Array.isArray(n)&&(e[r]=n.filter(o=>o!==null&&typeof o=="object"&&typeof o.matcher=="string"&&typeof o.command=="string"));return e}function Z(t){return `${ps}${t}`}function qe(t){let e={name:Z(t.name),description:t.description||void 0,"x-agentsmesh-kind":"agent","x-agentsmesh-name":t.name,"x-agentsmesh-tools":t.tools.length>0?t.tools:void 0,"x-agentsmesh-disallowed-tools":t.disallowedTools.length>0?t.disallowedTools:void 0,"x-agentsmesh-model":t.model||void 0,"x-agentsmesh-permission-mode":t.permissionMode||void 0,"x-agentsmesh-max-turns":t.maxTurns>0?t.maxTurns:void 0,"x-agentsmesh-mcp-servers":t.mcpServers.length>0?t.mcpServers:void 0,"x-agentsmesh-hooks":Object.keys(t.hooks).length>0?t.hooks:void 0,"x-agentsmesh-skills":t.skills.length>0?t.skills:void 0,"x-agentsmesh-memory":t.memory||void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),T(e,t.body.trim()||"")}function Qe(t,e){if(t["x-agentsmesh-kind"]!=="agent")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(ps)?e.slice(ps.length):e.startsWith(Ei)?e.slice(Ei.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:nl(t["x-agentsmesh-tools"]),disallowedTools:nl(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:nl(t["x-agentsmesh-mcp-servers"]),hooks:Tb(t["x-agentsmesh-hooks"]),skills:nl(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function le(t,e){let r={name:t.name,description:t.description,tools:t.tools,disallowedTools:t.disallowedTools.length>0?t.disallowedTools:void 0,model:t.model||void 0,permissionMode:t.permissionMode||void 0,maxTurns:t.maxTurns>0?t.maxTurns:void 0,mcpServers:t.mcpServers.length>0?t.mcpServers:void 0,hooks:Object.keys(t.hooks).length>0?t.hooks:void 0,skills:t.skills.length>0?t.skills:void 0,memory:t.memory||void 0};return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];}),T(r,e.trim()||"")}var ps,Ei,ht=f(()=>{v();ps="am-agent-",Ei="ab-agent-";i(nl,"toStringArray");i(Tb,"toHooks");i(Z,"projectedAgentSkillDirName");i(qe,"serializeProjectedAgentSkill");i(Qe,"parseProjectedAgentSkillFrontmatter");i(le,"serializeImportedAgent");});function wi(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Nm(t,e){return new RegExp(`${wi(t)}[\\s\\S]*?${wi(e)}`,"g")}function rh(t,e,r,n){let o=Nm(e,r);if(o.test(t))return t.replace(o,n).trim();let s=t.trim();return s?`${s}
|
|
11
11
|
|
|
12
|
-
${n}`:n}function
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
12
|
+
${n}`:n}function Dm(t,e,r){return t.replace(Nm(e,r),"").trim()}function Fb(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 vb(t){return {source:Fb(t.source),description:t.description,globs:t.globs,targets:t.targets}}function $b(t){return `${th}${JSON.stringify(vb(t))}${eh}`}function Mb(t){let e=[$b(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),Qg),e.filter(r=>r.length>0).join(`
|
|
13
|
+
`)}function Gb(t){return t.length===0?"":[ol,...t.map(Mb),sl].join(`
|
|
14
|
+
`)}function Zt(t,e){let r=Gb(e),n=Dm(t,ol,sl);return r?n?`${n}
|
|
15
15
|
|
|
16
|
-
${r}`:r:n}function
|
|
16
|
+
${r}`:r:n}function qg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function jb(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:qg(r.globs),targets:qg(r.targets)}}catch{return null}}function Ub(t,e){let r=t.trim();if(!e.trim())return r;let n=`## ${e.trim()}`;return r.startsWith(n)?r.slice(n.length).trim():r}function nh(t){let e=[],r=Nm(ol,sl);return {rootContent:t.replace(r,o=>{let s=o.replace(ol,"").replace(sl,"").trim(),a=new RegExp(`${wi(th)}([\\s\\S]*?)${wi(eh)}([\\s\\S]*?)${wi(Qg)}`,"g");for(let l of s.matchAll(a)){let c=l[1],m=l[2];if(c===void 0||m===void 0)continue;let p=jb(c);p&&e.push({...p,body:Ub(m,p.description)});}return ""}).trim(),rules:e}}var Li,Ai,ol,sl,Qg,th,eh,Tr=f(()=>{Li="<!-- agentsmesh:root-generation-contract:start -->",Ai="<!-- agentsmesh:root-generation-contract:end -->",ol="<!-- agentsmesh:embedded-rules:start -->",sl="<!-- agentsmesh:embedded-rules:end -->",Qg="<!-- agentsmesh:embedded-rule:end -->",th="<!-- agentsmesh:embedded-rule:start ",eh=" -->";i(wi,"escapeRegExp");i(Nm,"managedBlockPattern");i(rh,"replaceManagedBlock");i(Dm,"stripManagedBlock");i(Fb,"ruleSource");i(vb,"markerForRule");i($b,"embeddedRuleStart");i(Mb,"renderRule");i(Gb,"renderEmbeddedRulesBlock");i(Zt,"appendEmbeddedRulesBlock");i(qg,"toStringArray");i(jb,"parseMarker");i(Ub,"stripGeneratedHeading");i(nh,"extractEmbeddedRules");});function Fm(t){return t.replace(/\s+/g," ").trim()}function sh(t){let e=t.trim();if(e.includes(Li)&&e.includes(Ai))return rh(e,Li,Ai,us);let r=Fm(e);if(r.includes(Fm(us)))return e;for(let n of oh)if(r.includes(Fm(n)))return e.replace(n,us);return e?`${e}
|
|
17
17
|
|
|
18
|
-
${
|
|
18
|
+
${us}`:us}function ih(t){let e=Dm(t,Li,Ai);e=e.replace(`
|
|
19
19
|
|
|
20
|
-
${
|
|
20
|
+
${us}`,"");for(let r of oh)e=e.replace(`
|
|
21
21
|
|
|
22
|
-
${r}`,"");return e.trim()}var
|
|
22
|
+
${r}`,"");return e.trim()}var vm,Kb,Wb,Bb,Hb,zb,Vb,Jb,Yb,Xb,Zb,qb,Qb,tP,eP,rP,nP,us,oh,$m=f(()=>{Tr();vm="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.",Kb="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.",Wb="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.",Bb="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.",Hb="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`.",zb="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`.",Vb="`.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`.",Jb="`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.",Yb=vm,Xb=`## Project-Specific Rules
|
|
23
23
|
|
|
24
|
-
${
|
|
24
|
+
${vm}`,Zb=`## AgentsMesh Generation Contract
|
|
25
25
|
|
|
26
|
-
${
|
|
26
|
+
${vm}`,qb=`## AgentsMesh Generation Contract
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${Kb}`,Qb=`## AgentsMesh Generation Contract
|
|
29
29
|
|
|
30
|
-
${
|
|
30
|
+
${Wb}`,tP=`## AgentsMesh Generation Contract
|
|
31
31
|
|
|
32
|
-
${
|
|
32
|
+
${Bb}`,eP=`## AgentsMesh Generation Contract
|
|
33
33
|
|
|
34
|
-
${
|
|
34
|
+
${Hb}`,rP=`## AgentsMesh Generation Contract
|
|
35
35
|
|
|
36
|
-
${
|
|
36
|
+
${zb}`,nP=`## AgentsMesh Generation Contract
|
|
37
37
|
|
|
38
|
-
${
|
|
38
|
+
${Vb}`,us=`${Li}
|
|
39
39
|
## AgentsMesh Generation Contract
|
|
40
40
|
|
|
41
|
-
${
|
|
42
|
-
${
|
|
41
|
+
${Jb}
|
|
42
|
+
${Ai}`;i(Fm,"normalizeWhitespace");oh=[nP,rP,eP,tP,Qb,qb,Zb,Xb,Yb];i(sh,"appendAgentsmeshRootInstructionParagraph");i(ih,"stripAgentsmeshRootInstructionParagraph");});function jt(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 ds(t){let e=await I(t);return e?E(e).frontmatter:{}}function Rt(t,e){return typeof t[e]=="string"?t[e]:void 0}function Mm(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function oP(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function sP(t,e){let r=basename(t,".md")==="_root",n={...e};return delete n.root,{root:r,...n}}async function M(t,e,r){let n=await ds(t),o=basename(t,".md")==="_root"?ih(r):r.trim(),s=sP(t,oP({...n,...e})),a={root:s.root===true,description:typeof s.description=="string"?s.description:""};a.root===false&&(a.globs=jt(s.globs));for(let[l,c]of Object.entries(s))l==="root"||l==="description"||l==="globs"||c===void 0||(a[l]=c);return T(a,o||"")}var Gm=f(()=>{A();v();$m();i(jt,"toStringArray");i(ds,"readExistingFrontmatter");i(Rt,"readString");i(Mm,"readHooks");i(oP,"pruneUndefined");i(sP,"serializeCanonicalRuleFrontmatter");i(M,"serializeImportedRuleWithFallback");});async function q(t,e,r){let n=await ds(t),o=(()=>{let l=jt(n.allowedTools);return l.length>0?l:jt(n["allowed-tools"])})(),s=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return T({description:s,"allowed-tools":a},r.trim()||"")}async function tr(t,e,r){let n=await ds(t),o=basename(dirname(t)),s=Rt(e,"name")??Rt(n,"name")??o,a=Rt(e,"description")??Rt(n,"description")??"";return T({name:s,description:a},r.trim()||"")}async function yt(t,e,r){let n=await ds(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?jt(e.tools):(()=>{let C=jt(n.tools);return C.length>0?C:[]})(),s=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?jt(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?jt(e["disallowed-tools"]):jt(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?jt(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?jt(e["mcp-servers"]):jt(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?jt(e.skills):jt(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=Mm(e)??Mm(n),u={name:Rt(e,"name")??Rt(n,"name")??basename(t,".md"),description:Rt(e,"description")??Rt(n,"description")??"",tools:o};s.length>0&&(u.disallowedTools=s);let d=Rt(e,"model")??Rt(n,"model");d&&(u.model=d);let g=Rt(e,"permissionMode")??Rt(e,"permission-mode")??Rt(n,"permissionMode")??Rt(n,"permission-mode");g&&(u.permissionMode=g),Number.isInteger(m)&&m>0&&(u.maxTurns=m),a.length>0&&(u.mcpServers=a),p&&Object.keys(p).length>0&&(u.hooks=p),l.length>0&&(u.skills=l);let h=Rt(e,"memory")??Rt(n,"memory");return h&&(u.memory=h),T(u,r.trim()||"")}var ch=f(()=>{v();Gm();i(q,"serializeImportedCommandWithFallback");i(tr,"serializeImportedSkillWithFallback");i(yt,"serializeImportedAgentWithFallback");});var Y=f(()=>{Gm();ch();});function aP(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 Tt(t){return `${fs}${t}`}function gs(t){let e={name:Tt(t.name),description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],T(e,t.body.trim()||"")}function il(t,e){if(t["x-agentsmesh-kind"]!=="command")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(fs)?e.slice(fs.length):e.startsWith(bi)?e.slice(bi.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:aP(t["x-agentsmesh-allowed-tools"])}:null}function al(t,e){return T({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var fs,bi,er=f(()=>{v();fs="am-command-",bi="ab-command-";i(aP,"toStringArray");i(Tt,"commandSkillDirName");i(gs,"serializeCommandSkill");i(il,"parseCommandSkillFrontmatter");i(al,"serializeImportedCommand");});function ll(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 ce(t){await rm$1(t,{recursive:true,force:true});}var hs=f(()=>{i(ll,"shouldImportScopedAgentsRule");i(ce,"removePathIfExists");});function Nt(t,e){let r=[];for(let n of t.skills){let o={name:n.name,description:n.description||void 0};o.description===void 0&&delete o.description,r.push({path:`${e}/${n.name}/SKILL.md`,content:T(o,n.body.trim()||"")});for(let s of n.supportingFiles){let a=s.relativePath.replace(/\\/g,"/");r.push({path:`${e}/${n.name}/${a}`,content:s.content});}}return r}async function kt(t,e,r,n,o){let s=await readdir(join(t,e),{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(s!==null)for(let a of s){if(!a.isDirectory())continue;let l=join(t,e,a.name),c=join(l,"SKILL.md"),m=await I(c);if(m===null)continue;let p=join(t,Pi,a.name),u=join(p,"SKILL.md"),{frontmatter:d,body:g}=E(o(m,c,u)),h=il(d,a.name);if(h){await ce(join(t,Pi,a.name));let k=join(t,mh);await R(k);let D=join(k,`${h.name}.md`);await S(D,al(h,o(g,c,D))),n.push({fromTool:r,fromPath:c,toPath:`${mh}/${h.name}.md`,feature:"commands"});continue}let C=Qe(d,a.name);if(C){await ce(join(t,Pi,a.name));let k=join(t,ph);await R(k);let D=join(k,`${C.name}.md`);await S(D,le(C,o(g,c,D))),n.push({fromTool:r,fromPath:c,toPath:`${ph}/${C.name}.md`,feature:"agents"});continue}let O=await tr(u,{...d,name:a.name},g);await R(p),await S(u,O),n.push({fromTool:r,fromPath:c,toPath:`${Pi}/${a.name}/SKILL.md`,feature:"skills"});let _=await x(l);for(let k of _){if(k===c)continue;let D=relative(l,k).replace(/\\/g,"/"),b=await I(k);if(b===null)continue;let P=join(p,D);await R(dirname(P)),await S(P,o(b,k,P)),n.push({fromTool:r,fromPath:k,toPath:`${Pi}/${a.name}/${D}`,feature:"skills"});}}}var Pi,mh,ph,Et=f(()=>{A();v();Y();ht();er();hs();Pi=".agentsmesh/skills",mh=".agentsmesh/commands",ph=".agentsmesh/agents";i(Nt,"generateEmbeddedSkills");i(kt,"importEmbeddedSkills");});var no,cl,rr,Pe,xi,xe,Nr,Ti,nr,Dr,Ni,ys,jm,oo,ml,uh,so=f(()=>{no="antigravity",cl=".agents",rr=`${cl}/rules`,Pe=`${rr}/general.md`,xi=`${rr}/_root.md`,xe=`${cl}/skills`,Nr=`${cl}/workflows`,Ti=`${cl}/antigravity/mcp_config.json`,nr=".gemini/antigravity/GEMINI.md",Dr=".gemini/antigravity/skills",Ni=".gemini/antigravity/workflows",ys=".gemini/antigravity/mcp_config.json",jm=".agentsmesh/rules/_root.md",oo=".agentsmesh/rules",ml=".agentsmesh/commands",uh=".agentsmesh/mcp.json";});function dh(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:Pe,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:`${rr}/${o}.md`,content:n.body.trim()||""});}return r}function fh(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
|
|
43
43
|
|
|
44
|
-
${n}`:n||r;return {path:`${ur}/${e.name}.md`,content:o}})}function Bf(t){return Ne(t,wn)}function Kf(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ns,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function Hf(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("antigravity"));return de(e?.body.trim()??"",r)}var zf=f(()=>{fe();Gr();En();i(Uf,"generateRules");i(Wf,"generateCommands");i(Bf,"generateSkills");i(Kf,"generateMcp");i(Hf,"renderAntigravityGlobalInstructions");});function dr(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function Yt(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 Co(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function ko(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var he=f(()=>{i(dr,"toGlobsArray");i(Yt,"toToolsArray");i(Co,"toStringArray");i(ko,"toStringRecord");});function vb(t,e){return e.some(r=>t.endsWith(r))}async function st(t){let r=(await P(t.srcDir)).filter(o=>vb(o,t.extensions)),n=[];for(let o of r){let s=await I(o);if(!s)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),l=await t.mapEntry({srcPath:o,relativePath:a,content:s,normalizeTo:i((c,m=s)=>t.normalize(m,o,c),"normalizeTo")});l&&(await k(dirname(l.destPath)),await _(l.destPath,l.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:l.toPath,feature:l.feature}));}return n}var $e=f(()=>{E();i(vb,"matchesExtension");i(st,"importFileDirectory");});function Vf(t){return typeof t=="string"?t:void 0}function $b(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function Nc(t,e){return e?e(t):t}function Mb(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=O(e.normalizeTo(r)),s=Nc(n,t.frontmatterRemap),a=$b({root:false,description:Vf(s.description),globs:Array.isArray(s.globs)?s.globs:void 0,...s});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await $(r,a,o)}}}function Gb(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=O(e.normalizeTo(r)),s=Nc(n,t.frontmatterRemap),a=await Q(r,{hasDescription:true,description:Vf(s.description),hasAllowedTools:true,allowedTools:Co(s["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function jb(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=O(e.normalizeTo(r)),s=Nc(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await $t(r,s,o)}}}function Jf(t){if(t.map)return t.map;switch(t.preset){case "rule":return Mb(t);case "command":return Gb(t);case "agent":return jb(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Yf=f(()=>{F();Y();he();i(Vf,"pickString");i($b,"pruneUndefined");i(Nc,"applyRemap");i(Mb,"ruleMapper");i(Gb,"commandMapper");i(jb,"agentMapper");i(Jf,"resolveMapper");});function Dc(t,e){return t?t[e]??[]:[]}var Xf,Zf=f(()=>{Xf=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];i(Dc,"resolveScopedSources");});async function Wb(t,e,r,n,o){if(!t.canonicalRootFilename)throw new Error(`singleFile spec for ${t.feature} must set canonicalRootFilename`);let s=join(r,t.canonicalDir);for(let a of e){let l=join(r,a),c=await I(l);if(c===null)continue;await k(s);let m=join(s,t.canonicalRootFilename),u=i(C=>o(c,l,C),"normalizeTo");if(t.map){let C=await t.map({absolutePath:l,relativePath:a,content:c,destDir:s,normalizeTo:u});if(!C)continue;return await _(C.destPath,C.content),[{fromTool:n,fromPath:l,toPath:C.toPath,feature:t.feature}]}let{frontmatter:p,body:d}=O(u(m)),g=t.frontmatterRemap?t.frontmatterRemap(p):p,h=t.markAsRoot?{...g,root:true}:g,R=await $(m,h,d);return await _(m,R),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function Bb(t,e,r,n,o){let s=Jf(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),u=await st({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:i(async({srcPath:p,relativePath:d,content:g,normalizeTo:h})=>{let R=await s({absolutePath:p,relativePath:d,content:g,destDir:a,normalizeTo:i(C=>h(C),"normalizeTo")});return R?{destPath:R.destPath,toPath:R.toPath,feature:t.feature,content:R.content}:null},"mapEntry")});l.push(...u);}return l}function tg(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function Kb(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=tg(t);for(let s of e){let a=join(r,s),l=await I(a);if(l===null)continue;let c=join(r,o);return await k(dirname(c)),await _(c,l.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function Hb(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,s]of Object.entries(r)){if(!s||typeof s!="object"||Array.isArray(s))continue;let a=s,l=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){n[o]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:Co(a.args),env:ko(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:ko(a.headers),env:ko(a.env),description:l});}return n}async function zb(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=tg(t);for(let s of e){let a=join(r,s),l=await I(a);if(l===null)continue;let c=Hb(l);if(Object.keys(c).length===0)return [];let m=join(r,o);return await k(dirname(m)),await _(m,JSON.stringify({mcpServers:c},null,2)),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function qf(t,e,r,n,o){switch(t.mode){case "singleFile":return Wb(t,e,r,n,o);case "directory":return Bb(t,e,r,n,o);case "flatFile":return Kb(t,e,r,n);case "mcpJson":return zb(t,e,r,n)}}async function Vb(t,e,r,n,o){let s=Dc(t.source,e),a=Dc(t.fallbacks,e);if(s.length===0&&a.length===0)return [];if(s.length>0){let l=await qf(t,s,r,n,o);if(l.length>0)return l}return a.length>0?qf(t,a,r,n,o):[]}function Jb(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function gt(t,e,r,n){let o=t.importer;if(!o)return [];let s=n?.normalize??await H(t.id,e,r),a=[];for(let l of Xf)for(let c of Jb(o,l))a.push(...await Vb(c,r,e,t.id,s));return a}var Me=f(()=>{bt();E();F();he();Y();$e();Yf();Zf();i(Wb,"runSingleFile");i(Bb,"runDirectory");i(tg,"resolveCanonicalFilePath");i(Kb,"runFlatFile");i(Hb,"parseMcpJson");i(zb,"runMcpJson");i(qf,"dispatchSpec");i(Vb,"runSpec");i(Jb,"specsForFeature");i(gt,"runDescriptorImport");});function Yb(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function Ge(t){let e=Nf(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await k(join(t.projectRoot,t.rulesDir));for(let n of e.rules){let o=Yb(n.source);if(o===null||o==="rules/_root.md")continue;let s=join(t.projectRoot,".agentsmesh",o),a=t.normalize(n.body,t.sourcePath,s),{frontmatter:l,body:c}=O(a),m=await $(s,{...l,root:false,description:n.description||void 0,globs:n.globs.length>0?n.globs:void 0,targets:n.targets.length>0?n.targets:void 0},c);await _(s,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var wo=f(()=>{E();F();Gr();Y();i(Yb,"canonicalRulePath");i(Ge,"splitEmbeddedRulesToCanonical");});async function Xb(t,e,r,n){let o=n==="global"?ve:ge,s=n==="project"?[o,Ls]:[o];for(let a of s){let l=join(t,a),c=await I(l);if(c===null)continue;let m=join(t,Tc),u=await Ge({content:c,projectRoot:t,rulesDir:On,sourcePath:l,fromTool:kn,normalize:r});e.push(...u.results);let{body:p}=O(r(u.rootContent,l,m)),d=await $(m,{root:true},p);await k(join(t,On)),await _(m,d),e.push({fromTool:kn,fromPath:l,toPath:Tc,feature:"rules"});return}}async function rg(t,e={}){let r=e.scope??"project",n=[],o=await H(kn,t,r);return await Xb(t,n,o,r),n.push(...await gt(la,t,r,{normalize:o})),await De(t,r==="global"?pr:wn,kn,n,o),n}var ng=f(()=>{bt();E();F();fe();Me();Y();wo();En();vc();i(Xb,"importRootRule");i(rg,"importFromAntigravity");});var ig,ag,lg=f(()=>{F();Y();En();ig=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let n=join(r,t),{frontmatter:o,body:s}=O(e(n));return {destPath:n,toPath:`${On}/${t}`,content:await $(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},s)}},"nonRootRuleMapper"),ag=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=O(e(n));return {destPath:n,toPath:`${aa}/${t}`,content:await Q(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"workflowMapper");});function Zb(t,e){return mg(e).some(n=>qb(t,n))}function cg(t,e){return t.filter(r=>Zb(r,e))}function mg(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let s=n.split(",").map(l=>l.trim()),a=[];for(let l of s)for(let c of mg(r+l+o))a.push(c);return a}function qb(t,e){return Qb(e).test(t)}function Qb(t){let e=[],r=0;for(;r<t.length;){if(t.startsWith("**",r)){let s=t.slice(r+2);if(s.length===0&&e.length===0)e.push(".*");else if(e.push(s.startsWith("/")?"(?:[^/]+/)*":"(?:/[^/]+)*?"),s.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 ug=f(()=>{i(Zb,"globMatch");i(cg,"globFilter");i(mg,"expandBraces");i(qb,"matchOne");i(Qb,"globToRegex");});function lt(t,e,r,n={}){let o=[],{rules:s}=t;if(s.length===0)return [];if(s.some(l=>l.root)||o.push({level:"error",file:relative(e,s[0].source),message:"Rules exist but no root rule (_root.md or root: true). Add a root rule."}),n.checkGlobMatches===false)return o;for(let l of s){if(l.globs.length===0)continue;let c=false;for(let m of l.globs)if(cg(r,m).length>0){c=true;break}c||o.push({level:"warning",file:relative(e,l.source),message:`globs "${l.globs.join(", ")}" match 0 files in project`});}return o}var ye=f(()=>{ug();i(lt,"validateRules");});function dg(t,e,r,n){return lt(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:kn}))}var fg=f(()=>{ye();En();i(dg,"lintRules");});function tx(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 Eo(t){return `${Oo}${t}`}function gg(t){let e={name:Eo(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"],N(e,t.body.trim()||"")}function hg(t,e){if(t["x-agentsmesh-kind"]!=="command")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(Oo)?e.slice(Oo.length):e.startsWith(Fs)?e.slice(Fs.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:tx(t["x-agentsmesh-allowed-tools"])}:null}function yg(t,e){return N({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var Oo,Fs,vs=f(()=>{F();Oo="am-command-",Fs="ab-command-";i(tx,"toStringArray");i(Eo,"commandSkillDirName");i(gg,"serializeCommandSkill");i(hg,"parseCommandSkillFrontmatter");i(yg,"serializeImportedCommand");});function ca(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 ex(t){if(!t||typeof t!="object"||Array.isArray(t))return {};let e={};for(let[r,n]of Object.entries(t))Array.isArray(n)&&(e[r]=n.filter(o=>o!==null&&typeof o=="object"&&typeof o.matcher=="string"&&typeof o.command=="string"));return e}function Lt(t){return `${bo}${t}`}function ma(t){let e={name:Lt(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];}),N(e,t.body.trim()||"")}function jr(t,e){if(t["x-agentsmesh-kind"]!=="agent")return null;let r=typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"",n=e.startsWith(bo)?e.slice(bo.length):e.startsWith($s)?e.slice($s.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:ca(t["x-agentsmesh-tools"]),disallowedTools:ca(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:ca(t["x-agentsmesh-mcp-servers"]),hooks:ex(t["x-agentsmesh-hooks"]),skills:ca(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function je(t,e){let r={name:t.name,description:t.description,tools:t.tools,disallowedTools:t.disallowedTools.length>0?t.disallowedTools:void 0,model:t.model||void 0,permissionMode:t.permissionMode||void 0,maxTurns:t.maxTurns>0?t.maxTurns:void 0,mcpServers:t.mcpServers.length>0?t.mcpServers:void 0,hooks:Object.keys(t.hooks).length>0?t.hooks:void 0,skills:t.skills.length>0?t.skills:void 0,memory:t.memory||void 0};return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];}),N(r,e.trim()||"")}var bo,$s,Xt=f(()=>{F();bo="am-agent-",$s="ab-agent-";i(ca,"toStringArray");i(ex,"toHooks");i(Lt,"projectedAgentSkillDirName");i(ma,"serializeProjectedAgentSkill");i(jr,"parseProjectedAgentSkillFrontmatter");i(je,"serializeImportedAgent");});function A(t,e){return relative(t,e).replace(/\\/g,"/")}async function T(t,e){return P(join(t,e)).catch(()=>[])}function Sg(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function lx(t,e,r,n){let o=dirname(e),s=dirname(r);for(;o!==n&&o!==".";)Sg(t,o,s),o=dirname(o),s=dirname(s);}function G(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function z(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 p=basename(n,".md");t.set(e,`${Ig}/${p}/SKILL.md`);return}let[o,...s]=n.split("/"),a=s.join("/");if(!o||!a)return;let l=o.startsWith(Oo)?Oo:o.startsWith(Fs)?Fs:null;if(l&&a==="SKILL.md"){t.set(e,`${ix}/${o.slice(l.length)}.md`);return}let c=o.startsWith(bo)?bo:o.startsWith($s)?$s:null;if(c&&a==="SKILL.md"){t.set(e,`${ax}/${o.slice(c.length)}.md`);return}let m=`${Ig}/${o}`;a==="SKILL.md"&&Sg(t,`${r}/${o}`,m);let u=`${m}/${a}`;t.set(e,u),a!=="SKILL.md"&&lx(t,e,u,`${r}/${o}`);}function cx(t){return t.split("/").filter(Boolean)[0]??""}async function mx(){if($c!==void 0)return $c;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(rt(),_g)),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=cx(n);o.startsWith(".")&&e.add(o);}return $c=e,e}function Gc(t){return t.split("/").some(e=>e.startsWith("."))}async function ux(t){let e=[],r=await mx();async function n(o){let s=join(t,o),a=await readdir(s,{withFileTypes:true}).catch(()=>[]);for(let l of a){let c=o?`${o}/${l.name}`:l.name;if(l.isDirectory()){if(r.has(l.name)||Gc(c))continue;await n(c);continue}if(l.isSymbolicLink()&&await stat(join(t,c)).then(m=>m.isDirectory(),()=>false)){if(r.has(l.name)||Gc(c))continue;await n(c);continue}(l.name==="AGENTS.md"||l.name==="AGENTS.override.md")&&e.push(join(t,c));}}return i(n,"walk"),await n(""),e}async function pa(t,e){let r=await ux(e);for(let n of r){let o=A(e,n),s=o.endsWith("/AGENTS.md")&&o!=="AGENTS.md"&&!o.endsWith("/AGENTS.override.md"),a=o.endsWith("/AGENTS.override.md")&&o!=="AGENTS.override.md";if(!s&&!a)continue;let l=dirname(o);if(Gc(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${sx}/${c}.md`);}}var sx,ix,ax,Ig,$c,Mt=f(()=>{E();vs();Xt();sx=".agentsmesh/rules",ix=".agentsmesh/commands",ax=".agentsmesh/agents",Ig=".agentsmesh/skills";i(A,"rel");i(T,"listFiles");i(Sg,"addDirectoryMapping");i(lx,"addAncestorMappings");i(G,"addSimpleFileMapping");i(z,"addSkillLikeMapping");i(cx,"firstPathSegment");i(mx,"targetRootSegments");i(Gc,"hasHiddenSegment");i(ux,"listScopedAgentsFiles");i(pa,"addScopedAgentsMappings");});var v,tt,kt,Gt=f(()=>{v=".agentsmesh/rules",tt=".agentsmesh/commands",kt=".agentsmesh/agents";});async function jc(t,e,r="project"){if(r==="global"){t.set(ve,`${v}/_root.md`);for(let n of await T(e,pr))z(t,A(e,n),pr);t.set(Ro,".agentsmesh/mcp.json");return}t.set(ge,`${v}/_root.md`),t.set(Ls,`${v}/_root.md`);for(let n of await T(e,Fe)){let o=A(e,n);o===ge||o===Ls||G(t,o,v,".md");}for(let n of await T(e,ur))G(t,A(e,n),tt,".md");for(let n of await T(e,wn))z(t,A(e,n),wn);}var Rg=f(()=>{Mt();En();Gt();i(jc,"buildAntigravityImportPaths");});var Cg,Ur,kg,Gs,js,Us,Ws,Bs,gr,Uc,Ks,xo,Hs,zs,da,fa,Wc,Vs,Bc,bn,wg,hr=f(()=>{Cg="claude-code",Ur=".claude/CLAUDE.md",kg="CLAUDE.md",Gs=".claude/rules",js=".claude/commands",Us=".claude/agents",Ws=".claude/skills",Bs=".claude/settings.json",gr=".claude/hooks.json",Uc=".claude/output-styles",Ks=".claudeignore",xo=".mcp.json",Hs=".claude.json",zs=".agentsmesh/rules",da=".agentsmesh/commands",fa=".agentsmesh/agents",Wc=".agentsmesh/skills",Vs=".agentsmesh/mcp.json",Bc=".agentsmesh/permissions.yaml",bn=".agentsmesh/hooks.yaml",wg=".agentsmesh/ignore";});async function Kc(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${v}/_root.md`),t.set(gr,bn),r==="project"&&t.set("CLAUDE.md",`${v}/_root.md`),r==="global")for(let n of await T(e,".agents/skills"))z(t,A(e,n),".agents/skills");for(let n of await T(e,".claude/rules"))G(t,A(e,n),v,".md");for(let n of await T(e,".claude/commands"))G(t,A(e,n),tt,".md");for(let n of await T(e,".claude/agents"))G(t,A(e,n),kt,".md");for(let n of await T(e,".claude/skills"))z(t,A(e,n),".claude/skills");}var Og=f(()=>{Mt();hr();Gt();i(Kc,"buildClaudeCodeImportPaths");});var Wr,yr,xn,Ir,Eg,It,Ue,Br,Pn,An,Tn,Ln,Hc,Kr,ga,zc,Vc,Jc,bg,Zt=f(()=>{Wr="cline",yr=".clinerules",xn=".clineignore",Ir=".cline/cline_mcp_settings.json",Eg=".cline/mcp_settings.json",It=".cline/skills",Ue=".clinerules/workflows",Br="AGENTS.md",Pn=".clinerules/hooks",An="Documents/Cline/Rules",Tn="Documents/Cline/Workflows",Ln="Documents/Cline/Hooks",Hc=".agentsmesh/hooks.yaml",Kr=".agentsmesh/rules",ga=".agentsmesh/commands",zc=".agentsmesh/ignore",Vc=".agentsmesh/mcp.json",Jc=".agentsmesh/agents",bg=".agentsmesh/skills";});async function Yc(t,e,r="project"){if(r==="global"){for(let n of await T(e,An))G(t,A(e,n),v,".md");for(let n of await T(e,Tn))G(t,A(e,n),tt,".md");for(let n of await T(e,It))z(t,A(e,n),It);t.set(Ir,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${v}/_root.md`);for(let n of await T(e,".clinerules")){let o=A(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||G(t,o,v,".md");}for(let n of await T(e,".clinerules/workflows"))G(t,A(e,n),tt,".md");for(let n of await T(e,".cline/skills"))z(t,A(e,n),".cline/skills");}var xg=f(()=>{Mt();Zt();Gt();i(Yc,"buildClineImportPaths");});async function Xc(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${v}/_root.md`),t.set(".codex/AGENTS.override.md",`${v}/_root.md`)):(t.set("AGENTS.md",`${v}/_root.md`),t.set("codex.md",`${v}/_root.md`),await pa(t,e)),r==="project")for(let n of await T(e,".codex/instructions"))G(t,A(e,n),v,".md");for(let n of await T(e,".codex/rules")){let o=A(e,n);o.endsWith(".rules")?G(t,o,v,".rules"):o.endsWith(".md")&&G(t,o,v,".md");}for(let n of await T(e,".codex/agents"))G(t,A(e,n),kt,".toml");for(let n of await T(e,".agents/skills"))z(t,A(e,n),".agents/skills");}var Pg=f(()=>{Mt();Gt();i(Xc,"buildCodexCliImportPaths");});var Po,Ie,We,Zc,ha,Sr,qc,Be,Ao,Js,ya,Ia,Qc,Ke=f(()=>{Po="continue",Ie=".continue/rules",We=".continue/prompts",Zc=".continue/mcpServers",ha=`${Zc}/agentsmesh.json`,Sr=`${Ie}/general.md`,qc=`${Ie}/_root.md`,Be=".continue/skills",Ao=".continue/AGENTS.md",Js=".continue/config.yaml",ya=".agentsmesh/rules",Ia=".agentsmesh/commands",Qc=".agentsmesh/mcp.json";});async function tm(t,e,r="project"){t.set(Sr,`${v}/_root.md`),t.set(qc,`${v}/_root.md`);for(let n of await T(e,".continue/rules")){let o=A(e,n);o===Sr||o===qc||G(t,o,v,".md");}for(let n of await T(e,".continue/prompts"))t.set(A(e,n),`${tt}/${basename(n,".md")}.md`);for(let n of await T(e,".continue/skills"))z(t,A(e,n),".continue/skills");if(r==="global")for(let n of await T(e,".agents/skills"))z(t,A(e,n),".agents/skills");}var Ag=f(()=>{Mt();Ke();Gt();i(tm,"buildContinueImportPaths");});function fx(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${v}/${basename(e,".instructions.md")}.md`);return}G(t,e,v,".md");}async function em(t,e){t.set(".github/copilot-instructions.md",`${v}/_root.md`);for(let r of await T(e,".github/copilot"))t.set(A(e,r),`${v}/${basename(r,".instructions.md")}.md`);for(let r of await T(e,".github/instructions"))fx(t,A(e,r));for(let r of await T(e,".github/prompts"))t.set(A(e,r),`${tt}/${basename(r,".prompt.md")}.md`);for(let r of await T(e,".github/agents"))t.set(A(e,r),`${kt}/${basename(r,".agent.md")}.md`);for(let r of await T(e,".github/skills"))z(t,A(e,r),".github/skills");}var Tg=f(()=>{Mt();Gt();i(fx,"addCopilotInstructionMapping");i(em,"buildCopilotImportPaths");});var Lg,Hr,Ng,qt,_r,Qt,To,He,ze,Ve,_a,Se,rm,gx,Lo,_e,Ys,zr,Vr,Je,Jr,Yr,Dg,No,nm,Xs,om,ct=f(()=>{Lg="cursor",Hr="AGENTS.md",Ng=".cursorrules",qt=".cursor/rules",_r=`${qt}/general.mdc`,Qt=".cursor/commands",To=".cursor/agents",He=".cursor/skills",ze=".cursor/mcp.json",Ve=".cursor/hooks.json",_a=".cursor/settings.json",Se=".cursorignore",rm=".cursorindexingignore",gx=".agentsmesh-exports/cursor",Lo=`${gx}/user-rules.md`,_e=".cursor/AGENTS.md",Ys=ze,zr=He,Vr=To,Je=".agentsmesh/rules",Jr=".agentsmesh/commands",Yr=".agentsmesh/agents",Dg=".agentsmesh/skills",No=".agentsmesh/mcp.json",nm=".agentsmesh/permissions.yaml",Xs=".agentsmesh/hooks.yaml",om=".agentsmesh/ignore";});async function sm(t,e,r="project"){if(r==="global"){t.set(ze,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${v}/_root.md`);for(let n of await T(e,".cursor/rules"))G(t,A(e,n),v,".mdc");for(let n of await T(e,".cursor/commands"))G(t,A(e,n),tt,".md");for(let n of await T(e,".cursor/agents"))G(t,A(e,n),kt,".md");for(let n of await T(e,".cursor/skills"))z(t,A(e,n),".cursor/skills");return}t.set("AGENTS.md",`${v}/_root.md`);for(let n of await T(e,".cursor/rules"))G(t,A(e,n),v,".mdc");for(let n of await T(e,".cursor/commands"))G(t,A(e,n),tt,".md");for(let n of await T(e,".cursor/agents"))G(t,A(e,n),kt,".md");for(let n of await T(e,".cursor/skills"))z(t,A(e,n),".cursor/skills");}var Fg=f(()=>{Mt();ct();Gt();i(sm,"buildCursorImportPaths");});async function im(t,e){for(let r of await T(e,".gemini/rules"))G(t,A(e,r),v,".md");for(let r of await T(e,".gemini/commands")){let n=A(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),s=".gemini/commands/",c=(o.startsWith(s)?o.slice(s.length):o).split("/").filter(Boolean).join(":");t.set(n,`${tt}/${c}.md`);}for(let r of await T(e,".gemini/agents"))G(t,A(e,r),kt,".md");for(let r of await T(e,".gemini/skills"))z(t,A(e,r),".gemini/skills");}var vg=f(()=>{Mt();Gt();i(im,"buildGeminiCliImportPaths");});var Nn,Xr,Ra,$g,Ye,Mg,hx,Zs,Dn,qs,Do,Fo,Qs,ti,ei,ri,ni,yx,Ca,Fn,Gg,am,ka,jg,Ug,Wg,Bg,vo=f(()=>{Nn="junie",Xr=".junie",Ra=`${Xr}/guidelines.md`,$g=`${Xr}/ci-guidelines.md`,Ye=`${Xr}/AGENTS.md`,Mg="AGENTS.md",hx=`${Xr}/mcp`,Zs=`${hx}/mcp.json`,Dn=`${Xr}/skills`,qs=`${Xr}/rules`,Do=`${Xr}/commands`,Fo=`${Xr}/agents`,Qs=".aiignore",ti=".junie",ei=`${ti}/skills`,ri=`${ti}/agents`,ni=`${ti}/commands`,yx=`${ti}/mcp`,Ca=`${yx}/mcp.json`,Fn=`${ti}/AGENTS.md`,Gg=".agents/skills",am=".agentsmesh/rules/_root.md",ka=".agentsmesh/rules",jg=".agentsmesh/commands",Ug=".agentsmesh/agents",Wg=".agentsmesh/mcp.json",Bg=".agentsmesh/ignore";});async function lm(t,e){t.set(Ra,`${v}/_root.md`),t.set(Ye,`${v}/_root.md`),t.set("AGENTS.md",`${v}/_root.md`);for(let r of await T(e,".junie/rules"))G(t,A(e,r),v,".md");for(let r of await T(e,".junie/commands"))G(t,A(e,r),tt,".md");for(let r of await T(e,".junie/agents"))G(t,A(e,r),kt,".md");for(let r of await T(e,".junie/skills"))z(t,A(e,r),".junie/skills");}var Kg=f(()=>{Mt();vo();Gt();i(lm,"buildJunieImportPaths");});var jt,Re,oi,Ce,te,ke,Zr,Hg,$o,Mo,vn,we,qr,$n,si,ii,zg,cm,mm,Vg,Jg,um,Yg,Go=f(()=>{jt="kiro",Re="AGENTS.md",oi=".kiro",Ce=`${oi}/steering`,te=`${oi}/skills`,ke=`${oi}/agents`,Zr=`${oi}/hooks`,Hg=`${oi}/settings`,$o=`${Hg}/mcp.json`,Mo=".kiroignore",vn=".kiro/steering",we=".kiro/steering/AGENTS.md",qr=".kiro/skills",$n=".kiro/agents",si=".kiro/settings/mcp.json",ii=".kiro/settings/kiroignore",zg=".agents/skills",cm=".agentsmesh/rules/_root.md",mm=".agentsmesh/rules",Vg=".agentsmesh/agents",Jg=".agentsmesh/mcp.json",um=".agentsmesh/hooks.yaml",Yg=".agentsmesh/ignore";});async function pm(t,e,r="project"){if(r==="global"){t.set(we,`${v}/_root.md`);for(let n of await T(e,vn)){let o=A(e,n);o!==we&&G(t,o,v,".md");}for(let n of await T(e,qr))z(t,A(e,n),qr);for(let n of await T(e,$n))G(t,A(e,n),kt,".md");return}t.set(Re,`${v}/_root.md`);for(let n of await T(e,Ce))G(t,A(e,n),v,".md");for(let n of await T(e,te))z(t,A(e,n),te);for(let n of await T(e,ke))G(t,A(e,n),kt,".md");}var Xg=f(()=>{Mt();Go();Gt();i(pm,"buildKiroImportPaths");});var Qr,Mn,Oe,ai,Rr,Cr,Xe,li,ci,jo,mi,wa,tn,en,kr,Gn,ui,rn,Zg,jn,Oa,qg,Qg,Un=f(()=>{Qr="roo-code",Mn=".roo",Oe=`${Mn}/rules/00-root.md`,ai=".roorules",Rr=`${Mn}/rules`,Cr=`${Mn}/commands`,Xe=`${Mn}/skills`,li=`${Mn}/mcp.json`,ci=".rooignore",jo=".roomodes",mi="settings/custom_modes.yaml",wa=".roo",tn=`${wa}/rules`,en=`${wa}/commands`,kr=`${wa}/skills`,Gn="mcp_settings.json",ui=".rooignore",rn=`${wa}/AGENTS.md`,Zg=".agents/skills",jn=".agentsmesh/rules",Oa=".agentsmesh/commands",qg=".agentsmesh/mcp.json",Qg=".agentsmesh/ignore";});async function dm(t,e,r="project"){if(r==="global"){t.set(rn,`${v}/_root.md`);for(let n of await T(e,tn))G(t,A(e,n),v,".md");for(let n of await T(e,en))G(t,A(e,n),tt,".md");for(let n of await T(e,kr))z(t,A(e,n),kr);t.set(Gn,".agentsmesh/mcp.json");return}t.set(Oe,`${v}/_root.md`),t.set(ai,`${v}/_root.md`);for(let n of await T(e,Rr)){let o=A(e,n);o!==Oe&&G(t,o,v,".md");}for(let n of await T(e,".roo")){let o=A(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&G(t,o,v,".md");}for(let n of await T(e,Cr))G(t,A(e,n),tt,".md");for(let n of await T(e,Xe))z(t,A(e,n),Xe);}var th=f(()=>{Mt();Un();Gt();i(dm,"buildRooCodeImportPaths");});async function fm(t,e){t.set("AGENTS.md",`${v}/_root.md`),t.set(".windsurfrules",`${v}/_root.md`),await pa(t,e);for(let r of await T(e,".windsurf/rules"))G(t,A(e,r),v,".md");for(let r of await T(e,".windsurf/workflows"))G(t,A(e,r),tt,".md");for(let r of await T(e,".windsurf/skills"))z(t,A(e,r),".windsurf/skills");}var eh=f(()=>{Mt();Gt();i(fm,"buildWindsurfImportPaths");});var rh=f(()=>{Rg();Og();xg();Pg();Ag();Tg();Fg();vg();Kg();Xg();th();eh();});var Ut=f(()=>{rh();});var Ix,Sx,_x,Rx,la,vc=f(()=>{Cn();zf();En();ng();lg();fg();Ut();Ix={name:"antigravity",primaryRootInstructionPath:ge,generateRules:Uf,generateCommands:Wf,generateSkills:Bf,generateMcp:Kf,importFrom:rg},Sx={rootInstructionPath:ge,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===Ns?null:t},paths:{rulePath(t,e){return `${Fe}/${t}.md`},commandPath(t,e){return `${ur}/${t}.md`},agentPath(t,e){return null}}},_x={rootInstructionPath:ve,renderPrimaryRootInstruction:Hf,skillDir:pr,managedOutputs:{dirs:[pr,Ds],files:[ve,Ro]},rewriteGeneratedPath(t){return t===ge?ve:t.startsWith(`${Fe}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",pr):t.startsWith(`${ur}/`)?t.replace(ur,Ds):t===Ns?Ro:t},paths:{rulePath(t,e){return ve},commandPath(t,e){return `${Ds}/${t}.md`},agentPath(t,e){return null}}},Rx={rules:"native",additionalRules:"embedded",commands:pe("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},la={id:"antigravity",generators:Ix,capabilities:{rules:"native",additionalRules:"native",commands:pe("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/).",lintRules:dg,project:Sx,globalSupport:{capabilities:Rx,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:_x},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Fe]},canonicalDir:On,extensions:[".md"],map:ig},commands:{feature:"commands",mode:"directory",source:{project:[ur],global:[Ds]},canonicalDir:aa,extensions:[".md"],map:ag},mcp:{feature:"mcp",mode:"flatFile",source:{global:[Ro]},canonicalDir:".agentsmesh",canonicalFilename:jf}},buildImportPaths:jc,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function nh(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let s of n){if(!Te(s))continue;let a=ut(s),l=Ot(s),c=s.type==="prompt"?l||a:a||l,m={type:s.type==="prompt"?"prompt":"command",[s.type==="prompt"?"prompt":"command"]:c};s.timeout!==void 0&&(m.timeout=s.timeout),o.push({matcher:s.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var oh=f(()=>{ce();i(nh,"buildClaudeHooksObjectFromCanonical");});function sh(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Ur,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("claude-code")));for(let o of n){let s=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=N(a,o.body.trim()||"");e.push({path:`${Gs}/${s}.md`,content:l});}return e}function ih(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let n=N(r,e.body.trim()||"");return {path:`${js}/${e.name}.md`,content:n}})}function ah(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(a=>{r[a]===void 0&&delete r[a];});let n=e.body.trim()||"",o=/^##\s*Role\b/m.test(n)?n:`## Role
|
|
44
|
+
${n}`:n||r;return {path:`${Nr}/${e.name}.md`,content:o}})}function gh(t){return Nt(t,xe)}function hh(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ti,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function yh(t){return t.agents.map(e=>({path:`${xe}/${Z(e.name)}/SKILL.md`,content:qe(e)}))}function Ih(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("antigravity"));return Zt(e?.body.trim()??"",r)}var _h=f(()=>{Et();Tr();ht();so();i(dh,"generateRules");i(fh,"generateCommands");i(gh,"generateSkills");i(hh,"generateMcp");i(yh,"generateAgents");i(Ih,"renderAntigravityGlobalInstructions");});async function pe(t,e,r){let n=join(t,e),s={...await gP(n),...r};await R(dirname(n)),await S(n,JSON.stringify({mcpServers:s},null,2));}async function gP(t){let e=await I(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[s,a]of Object.entries(n))!a||typeof a!="object"||Array.isArray(a)||(o[s]=a);return o}var io=f(()=>{A();i(pe,"writeMcpWithMerge");i(gP,"readExistingServers");});function Fr(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function ue(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 Is(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function _s(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var Te=f(()=>{i(Fr,"toGlobsArray");i(ue,"toToolsArray");i(Is,"toStringArray");i(_s,"toStringRecord");});function IP(t,e){return e.some(r=>t.endsWith(r))}async function tt(t){let r=(await x(t.srcDir)).filter(o=>IP(o,t.extensions)),n=[];for(let o of r){let s=await I(o);if(!s)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),l=await t.mapEntry({srcPath:o,relativePath:a,content:s,normalizeTo:i((c,m=s)=>t.normalize(m,o,c),"normalizeTo")});l&&(await R(dirname(l.destPath)),await S(l.destPath,l.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:l.toPath,feature:l.feature}));}return n}var Ne=f(()=>{A();i(IP,"matchesExtension");i(tt,"importFileDirectory");});function Sh(t){return typeof t=="string"?t:void 0}function _P(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function Km(t,e){return e?e(t):t}function SP(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=E(e.normalizeTo(r)),s=Km(n,t.frontmatterRemap),a=_P({root:false,description:Sh(s.description),globs:Array.isArray(s.globs)?s.globs:void 0,...s});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await M(r,a,o)}}}function CP(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=E(e.normalizeTo(r)),s=Km(n,t.frontmatterRemap),a=await q(r,{hasDescription:true,description:Sh(s.description),hasAllowedTools:true,allowedTools:Is(s["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function OP(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=E(e.normalizeTo(r)),s=Km(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await yt(r,s,o)}}}function Ch(t){if(t.map)return t.map;switch(t.preset){case "rule":return SP(t);case "command":return CP(t);case "agent":return OP(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Oh=f(()=>{v();Y();Te();i(Sh,"pickString");i(_P,"pruneUndefined");i(Km,"applyRemap");i(SP,"ruleMapper");i(CP,"commandMapper");i(OP,"agentMapper");i(Ch,"resolveMapper");});function Wm(t,e){return t?t[e]??[]:[]}var Rh,kh=f(()=>{Rh=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];i(Wm,"resolveScopedSources");});async function EP(t,e,r,n,o){if(!t.canonicalRootFilename)throw new Error(`singleFile spec for ${t.feature} must set canonicalRootFilename`);let s=join(r,t.canonicalDir);for(let a of e){let l=join(r,a),c=await I(l);if(c===null)continue;await R(s);let m=join(s,t.canonicalRootFilename),p=i(O=>o(c,l,O),"normalizeTo");if(t.map){let O=await t.map({absolutePath:l,relativePath:a,content:c,destDir:s,normalizeTo:p});if(!O)continue;return await S(O.destPath,O.content),[{fromTool:n,fromPath:l,toPath:O.toPath,feature:t.feature}]}let{frontmatter:u,body:d}=E(p(m)),g=t.frontmatterRemap?t.frontmatterRemap(u):u,h=t.markAsRoot?{...g,root:true}:g,C=await M(m,h,d);return await S(m,C),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function wP(t,e,r,n,o){let s=Ch(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),p=await tt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:i(async({srcPath:u,relativePath:d,content:g,normalizeTo:h})=>{let C=await s({absolutePath:u,relativePath:d,content:g,destDir:a,normalizeTo:i(O=>h(O),"normalizeTo")});return C?{destPath:C.destPath,toPath:C.toPath,feature:t.feature,content:C.content}:null},"mapEntry")});l.push(...p);}return l}function wh(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function LP(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=wh(t);for(let s of e){let a=join(r,s),l=await I(a);if(l===null)continue;let c=join(r,o);return await R(dirname(c)),await S(c,l.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function AP(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,s]of Object.entries(r)){if(!s||typeof s!="object"||Array.isArray(s))continue;let a=s,l=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){n[o]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:Is(a.args),env:_s(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:_s(a.headers),env:_s(a.env),description:l});}return n}async function bP(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=wh(t);for(let s of e){let a=join(r,s),l=await I(a);if(l===null)continue;let c=AP(l);return Object.keys(c).length===0?[]:(await pe(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function Eh(t,e,r,n,o){switch(t.mode){case "singleFile":return EP(t,e,r,n,o);case "directory":return wP(t,e,r,n,o);case "flatFile":return LP(t,e,r,n);case "mcpJson":return bP(t,e,r,n)}}async function PP(t,e,r,n,o){let s=Wm(t.source,e),a=Wm(t.fallbacks,e);if(s.length===0&&a.length===0)return [];if(s.length>0){let l=await Eh(t,s,r,n,o);if(l.length>0)return l}return a.length>0?Eh(t,a,r,n,o):[]}function xP(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function et(t,e,r,n){let o=t.importer;if(!o)return [];let s=n?.normalize??await z(t.id,e,r),a=[];for(let l of Rh)for(let c of xP(o,l))a.push(...await PP(c,r,e,t.id,s));return a}var qt=f(()=>{Ct();A();io();v();Te();Y();Ne();Oh();kh();i(EP,"runSingleFile");i(wP,"runDirectory");i(wh,"resolveCanonicalFilePath");i(LP,"runFlatFile");i(AP,"parseMcpJson");i(bP,"runMcpJson");i(Eh,"dispatchSpec");i(PP,"runSpec");i(xP,"specsForFeature");i(et,"runDescriptorImport");});function TP(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function or(t){let e=nh(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await R(join(t.projectRoot,t.rulesDir));for(let n of e.rules){let o=TP(n.source);if(o===null||o==="rules/_root.md")continue;let s=join(t.projectRoot,".agentsmesh",o),a=t.normalize(n.body,t.sourcePath,s),{frontmatter:l,body:c}=E(a),m=await M(s,{...l,root:false,description:n.description||void 0,globs:n.globs.length>0?n.globs:void 0,targets:n.targets.length>0?n.targets:void 0},c);await S(s,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var Ss=f(()=>{A();v();Tr();Y();i(TP,"canonicalRulePath");i(or,"splitEmbeddedRulesToCanonical");});async function NP(t,e,r,n){let o=n==="global"?nr:Pe,s=n==="project"?[o,xi]:[o];for(let a of s){let l=join(t,a),c=await I(l);if(c===null)continue;let m=join(t,jm),p=await or({content:c,projectRoot:t,rulesDir:oo,sourcePath:l,fromTool:no,normalize:r});e.push(...p.results);let{body:u}=E(r(p.rootContent,l,m)),d=await M(m,{root:true},u);await R(join(t,oo)),await S(m,d),e.push({fromTool:no,fromPath:l,toPath:jm,feature:"rules"});return}}async function Ah(t,e={}){let r=e.scope??"project",n=[],o=await z(no,t,r);return await NP(t,n,o,r),n.push(...await et(pl,t,r,{normalize:o})),await kt(t,r==="global"?Dr:xe,no,n,o),n}var bh=f(()=>{Ct();A();v();Et();qt();Y();Ss();so();Hm();i(NP,"importRootRule");i(Ah,"importFromAntigravity");});var Th,Nh,Dh=f(()=>{v();Y();so();Th=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${oo}/${t}`,content:await M(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},s)}},"nonRootRuleMapper"),Nh=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${ml}/${t}`,content:await q(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"workflowMapper");});function DP(t,e){return vh(e).some(n=>FP(t,n))}function Fh(t,e){return t.filter(r=>DP(r,e))}function vh(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let s=n.split(",").map(l=>l.trim()),a=[];for(let l of s)for(let c of vh(r+l+o))a.push(c);return a}function FP(t,e){return vP(e).test(t)}function vP(t){let e=[],r=0;for(;r<t.length;){if(t.startsWith("**",r)){let s=t.slice(r+2);if(s.length===0&&e.length===0)e.push(".*");else if(e.push(s.startsWith("/")?"(?:[^/]+/)*":"(?:/[^/]+)*?"),s.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 $h=f(()=>{i(DP,"globMatch");i(Fh,"globFilter");i(vh,"expandBraces");i(FP,"matchOne");i(vP,"globToRegex");});function Q(t,e,r,n={}){let o=[],{rules:s}=t;if(s.length===0)return [];if(s.some(l=>l.root)||o.push({level:"error",file:relative(e,s[0].source),message:"Rules exist but no root rule (_root.md or root: true). Add a root rule."}),n.checkGlobMatches===false)return o;for(let l of s){if(l.globs.length===0)continue;let c=false;for(let m of l.globs)if(Fh(r,m).length>0){c=true;break}c||o.push({level:"warning",file:relative(e,l.source),message:`globs "${l.globs.join(", ")}" match 0 files in project`});}return o}var Vt=f(()=>{$h();i(Q,"validateRules");});function Gh(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:no}))}var jh=f(()=>{Vt();so();i(Gh,"lintRules");});function w(t,e){return H(t).relative(t,e).replace(/\\/g,"/")}async function L(t,e){return x(H(t).join(t,e)).catch(()=>[])}function Kh(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function KP(t,e,r,n){let o=posix.dirname(e),s=posix.dirname(r);for(;o!==n&&o!==".";)Kh(t,o,s),o=posix.dirname(o),s=posix.dirname(s);}function $(t,e,r,n){t.set(e,`${r}/${basename(e,n)}.md`);}function K(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,`${Uh}/${u}/SKILL.md`);return}let[o,...s]=n.split("/"),a=s.join("/");if(!o||!a)return;let l=o.startsWith(fs)?fs:o.startsWith(bi)?bi:null;if(l&&a==="SKILL.md"){t.set(e,`${jP}/${o.slice(l.length)}.md`);return}let c=o.startsWith(ps)?ps:o.startsWith(Ei)?Ei:null;if(c&&a==="SKILL.md"){t.set(e,`${UP}/${o.slice(c.length)}.md`);return}let m=`${Uh}/${o}`;a==="SKILL.md"&&Kh(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&KP(t,e,p,`${r}/${o}`);}function WP(t){return t.split("/").filter(Boolean)[0]??""}async function BP(){if(zm!==void 0)return zm;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(it(),Wh)),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=WP(n);o.startsWith(".")&&e.add(o);}return zm=e,e}function Jm(t){return t.split("/").some(e=>e.startsWith("."))}async function HP(t){let e=[],r=await BP(),n=H(t);async function o(s){let a=n.join(t,s),l=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let c of l){let m=s?`${s}/${c.name}`:c.name;if(c.isDirectory()){if(r.has(c.name)||Jm(m))continue;await o(m);continue}if(c.isSymbolicLink()&&await stat(n.join(t,m)).then(p=>p.isDirectory(),()=>false)){if(r.has(c.name)||Jm(m))continue;await o(m);continue}(c.name==="AGENTS.md"||c.name==="AGENTS.override.md")&&e.push(n.join(t,m));}}return i(o,"walk"),await o(""),e}async function ul(t,e){let r=await HP(e);for(let n of r){let o=w(e,n),s=o.endsWith("/AGENTS.md")&&o!=="AGENTS.md"&&!o.endsWith("/AGENTS.override.md"),a=o.endsWith("/AGENTS.override.md")&&o!=="AGENTS.override.md";if(!s&&!a)continue;let l=posix.dirname(o);if(Jm(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${GP}/${c}.md`);}}var GP,jP,UP,Uh,zm,Dt=f(()=>{Pt();A();er();ht();GP=".agentsmesh/rules",jP=".agentsmesh/commands",UP=".agentsmesh/agents",Uh=".agentsmesh/skills";i(w,"rel");i(L,"listFiles");i(Kh,"addDirectoryMapping");i(KP,"addAncestorMappings");i($,"addSimpleFileMapping");i(K,"addSkillLikeMapping");i(WP,"firstPathSegment");i(BP,"targetRootSegments");i(Jm,"hasHiddenSegment");i(HP,"listScopedAgentsFiles");i(ul,"addScopedAgentsMappings");});var N,X,at,Ft=f(()=>{N=".agentsmesh/rules",X=".agentsmesh/commands",at=".agentsmesh/agents";});async function Ym(t,e,r="project"){if(r==="global"){t.set(nr,`${N}/_root.md`);for(let n of await L(e,Dr))K(t,w(e,n),Dr);t.set(ys,".agentsmesh/mcp.json");return}t.set(Pe,`${N}/_root.md`),t.set(xi,`${N}/_root.md`);for(let n of await L(e,rr)){let o=w(e,n);o===Pe||o===xi||$(t,o,N,".md");}for(let n of await L(e,Nr))$(t,w(e,n),X,".md");for(let n of await L(e,xe))K(t,w(e,n),xe);}var Bh=f(()=>{Dt();so();Ft();i(Ym,"buildAntigravityImportPaths");});var Hh,fn,zh,Fi,vi,$i,Mi,Gi,vr,Xm,ji,Cs,Ui,Ki,dl,fl,Zm,Wi,qm,ao,Vh,$r=f(()=>{Hh="claude-code",fn=".claude/CLAUDE.md",zh="CLAUDE.md",Fi=".claude/rules",vi=".claude/commands",$i=".claude/agents",Mi=".claude/skills",Gi=".claude/settings.json",vr=".claude/hooks.json",Xm=".claude/output-styles",ji=".claudeignore",Cs=".mcp.json",Ui=".claude.json",Ki=".agentsmesh/rules",dl=".agentsmesh/commands",fl=".agentsmesh/agents",Zm=".agentsmesh/skills",Wi=".agentsmesh/mcp.json",qm=".agentsmesh/permissions.yaml",ao=".agentsmesh/hooks.yaml",Vh=".agentsmesh/ignore";});async function Qm(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${N}/_root.md`),t.set(vr,ao),r==="project"&&t.set("CLAUDE.md",`${N}/_root.md`),r==="global")for(let n of await L(e,".agents/skills"))K(t,w(e,n),".agents/skills");for(let n of await L(e,".claude/rules"))$(t,w(e,n),N,".md");for(let n of await L(e,".claude/commands"))$(t,w(e,n),X,".md");for(let n of await L(e,".claude/agents"))$(t,w(e,n),at,".md");for(let n of await L(e,".claude/skills"))K(t,w(e,n),".claude/skills");}var Jh=f(()=>{Dt();$r();Ft();i(Qm,"buildClaudeCodeImportPaths");});var gn,Mr,lo,Gr,Yh,wt,sr,hn,co,mo,po,uo,tp,yn,gl,ep,rp,np,Xh,de=f(()=>{gn="cline",Mr=".clinerules",lo=".clineignore",Gr=".cline/cline_mcp_settings.json",Yh=".cline/mcp_settings.json",wt=".cline/skills",sr=".clinerules/workflows",hn="AGENTS.md",co=".clinerules/hooks",mo="Documents/Cline/Rules",po="Documents/Cline/Workflows",uo="Documents/Cline/Hooks",tp=".agentsmesh/hooks.yaml",yn=".agentsmesh/rules",gl=".agentsmesh/commands",ep=".agentsmesh/ignore",rp=".agentsmesh/mcp.json",np=".agentsmesh/agents",Xh=".agentsmesh/skills";});async function op(t,e,r="project"){if(r==="global"){for(let n of await L(e,mo))$(t,w(e,n),N,".md");for(let n of await L(e,po))$(t,w(e,n),X,".md");for(let n of await L(e,wt))K(t,w(e,n),wt);t.set(Gr,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${N}/_root.md`);for(let n of await L(e,".clinerules")){let o=w(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||$(t,o,N,".md");}for(let n of await L(e,".clinerules/workflows"))$(t,w(e,n),X,".md");for(let n of await L(e,".cline/skills"))K(t,w(e,n),".cline/skills");}var Zh=f(()=>{Dt();de();Ft();i(op,"buildClineImportPaths");});async function sp(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${N}/_root.md`),t.set(".codex/AGENTS.override.md",`${N}/_root.md`)):(t.set("AGENTS.md",`${N}/_root.md`),t.set("codex.md",`${N}/_root.md`),await ul(t,e)),r==="project")for(let n of await L(e,".codex/instructions"))$(t,w(e,n),N,".md");for(let n of await L(e,".codex/rules")){let o=w(e,n);o.endsWith(".rules")?$(t,o,N,".rules"):o.endsWith(".md")&&$(t,o,N,".md");}for(let n of await L(e,".codex/agents"))$(t,w(e,n),at,".toml");for(let n of await L(e,".agents/skills"))K(t,w(e,n),".agents/skills");}var qh=f(()=>{Dt();Ft();i(sp,"buildCodexCliImportPaths");});var Os,De,ir,ip,hl,jr,ap,Qt,Rs,Bi,yl,Il,lp,ar=f(()=>{Os="continue",De=".continue/rules",ir=".continue/prompts",ip=".continue/mcpServers",hl=`${ip}/agentsmesh.json`,jr=`${De}/general.md`,ap=`${De}/_root.md`,Qt=".continue/skills",Rs=".continue/AGENTS.md",Bi=".continue/config.yaml",yl=".agentsmesh/rules",Il=".agentsmesh/commands",lp=".agentsmesh/mcp.json";});async function cp(t,e,r="project"){t.set(jr,`${N}/_root.md`),t.set(ap,`${N}/_root.md`);for(let n of await L(e,".continue/rules")){let o=w(e,n);o===jr||o===ap||$(t,o,N,".md");}for(let n of await L(e,".continue/prompts"))t.set(w(e,n),`${X}/${basename(n,".md")}.md`);for(let n of await L(e,".continue/skills"))K(t,w(e,n),".continue/skills");if(r==="global")for(let n of await L(e,".agents/skills"))K(t,w(e,n),".agents/skills");}var Qh=f(()=>{Dt();ar();Ft();i(cp,"buildContinueImportPaths");});function JP(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${N}/${basename(e,".instructions.md")}.md`);return}$(t,e,N,".md");}async function mp(t,e){t.set(".github/copilot-instructions.md",`${N}/_root.md`);for(let r of await L(e,".github/copilot"))t.set(w(e,r),`${N}/${basename(r,".instructions.md")}.md`);for(let r of await L(e,".github/instructions"))JP(t,w(e,r));for(let r of await L(e,".github/prompts"))t.set(w(e,r),`${X}/${basename(r,".prompt.md")}.md`);for(let r of await L(e,".github/agents"))t.set(w(e,r),`${at}/${basename(r,".agent.md")}.md`);for(let r of await L(e,".github/skills"))K(t,w(e,r),".github/skills");}var ty=f(()=>{Dt();Ft();i(JP,"addCopilotInstructionMapping");i(mp,"buildCopilotImportPaths");});var ey,In,ry,fe,Ur,ge,ks,lr,cr,mr,Sl,Fe,pp,YP,Es,ve,Hi,_n,Sn,pr,Cn,On,ny,ws,up,zi,dp,dt=f(()=>{ey="cursor",In="AGENTS.md",ry=".cursorrules",fe=".cursor/rules",Ur=`${fe}/general.mdc`,ge=".cursor/commands",ks=".cursor/agents",lr=".cursor/skills",cr=".cursor/mcp.json",mr=".cursor/hooks.json",Sl=".cursor/settings.json",Fe=".cursorignore",pp=".cursorindexingignore",YP=".agentsmesh-exports/cursor",Es=`${YP}/user-rules.md`,ve=".cursor/AGENTS.md",Hi=cr,_n=lr,Sn=ks,pr=".agentsmesh/rules",Cn=".agentsmesh/commands",On=".agentsmesh/agents",ny=".agentsmesh/skills",ws=".agentsmesh/mcp.json",up=".agentsmesh/permissions.yaml",zi=".agentsmesh/hooks.yaml",dp=".agentsmesh/ignore";});async function fp(t,e,r="project"){if(r==="global"){t.set(cr,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${N}/_root.md`);for(let n of await L(e,".cursor/rules"))$(t,w(e,n),N,".mdc");for(let n of await L(e,".cursor/commands"))$(t,w(e,n),X,".md");for(let n of await L(e,".cursor/agents"))$(t,w(e,n),at,".md");for(let n of await L(e,".cursor/skills"))K(t,w(e,n),".cursor/skills");return}t.set("AGENTS.md",`${N}/_root.md`);for(let n of await L(e,".cursor/rules"))$(t,w(e,n),N,".mdc");for(let n of await L(e,".cursor/commands"))$(t,w(e,n),X,".md");for(let n of await L(e,".cursor/agents"))$(t,w(e,n),at,".md");for(let n of await L(e,".cursor/skills"))K(t,w(e,n),".cursor/skills");}var oy=f(()=>{Dt();dt();Ft();i(fp,"buildCursorImportPaths");});async function gp(t,e){for(let r of await L(e,".gemini/rules"))$(t,w(e,r),N,".md");for(let r of await L(e,".gemini/commands")){let n=w(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),s=".gemini/commands/",c=(o.startsWith(s)?o.slice(s.length):o).split("/").filter(Boolean).join(":");t.set(n,`${X}/${c}.md`);}for(let r of await L(e,".gemini/agents"))$(t,w(e,r),at,".md");for(let r of await L(e,".gemini/skills"))K(t,w(e,r),".gemini/skills");}var sy=f(()=>{Dt();Ft();i(gp,"buildGeminiCliImportPaths");});var ur,he,Ut,Kr,iy,Wr,fo,ye,ay,ly,Ls=f(()=>{ur="goose",he=".goosehints",Ut=".agents/skills",Kr=".gooseignore",iy=".config/goose",Wr=`${iy}/.goosehints`,fo=`${iy}/.gooseignore`,ye=".agents/skills",ay=".agentsmesh/rules",ly=".agentsmesh/ignore";});async function hp(t,e,r="project"){if(r==="global"){t.set(Wr,`${N}/_root.md`);for(let n of await L(e,ye))K(t,w(e,n),ye);t.set(fo,".agentsmesh/ignore");return}t.set(he,`${N}/_root.md`);for(let n of await L(e,Ut))K(t,w(e,n),Ut);t.set(Kr,".agentsmesh/ignore");}var cy=f(()=>{Dt();Ls();Ft();i(hp,"buildGooseImportPaths");});var go,Rn,Cl,my,dr,py,XP,Vi,ho,Ji,As,bs,Yi,Xi,Zi,qi,Qi,ZP,Ol,yo,uy,yp,Rl,dy,fy,gy,hy,Ps=f(()=>{go="junie",Rn=".junie",Cl=`${Rn}/guidelines.md`,my=`${Rn}/ci-guidelines.md`,dr=`${Rn}/AGENTS.md`,py="AGENTS.md",XP=`${Rn}/mcp`,Vi=`${XP}/mcp.json`,ho=`${Rn}/skills`,Ji=`${Rn}/rules`,As=`${Rn}/commands`,bs=`${Rn}/agents`,Yi=".aiignore",Xi=".junie",Zi=`${Xi}/skills`,qi=`${Xi}/agents`,Qi=`${Xi}/commands`,ZP=`${Xi}/mcp`,Ol=`${ZP}/mcp.json`,yo=`${Xi}/AGENTS.md`,uy=".agents/skills",yp=".agentsmesh/rules/_root.md",Rl=".agentsmesh/rules",dy=".agentsmesh/commands",fy=".agentsmesh/agents",gy=".agentsmesh/mcp.json",hy=".agentsmesh/ignore";});async function Ip(t,e){t.set(Cl,`${N}/_root.md`),t.set(dr,`${N}/_root.md`),t.set("AGENTS.md",`${N}/_root.md`);for(let r of await L(e,".junie/rules"))$(t,w(e,r),N,".md");for(let r of await L(e,".junie/commands"))$(t,w(e,r),X,".md");for(let r of await L(e,".junie/agents"))$(t,w(e,r),at,".md");for(let r of await L(e,".junie/skills"))K(t,w(e,r),".junie/skills");}var yy=f(()=>{Dt();Ps();Ft();i(Ip,"buildJunieImportPaths");});var Kt,ta,fr,Br,Hr,zr,$e,kn,xs,kl,Io,Ts,_o,ea,El,Ns,En,So,Co,Oo,wn,Ds,wl,Iy,Ln,Fs,Ro,_y,Sy,ko=f(()=>{Kt="kilo-code",ta=".kilo",fr="AGENTS.md",Br=`${ta}/rules`,Hr=`${ta}/commands`,zr=`${ta}/agents`,$e=`${ta}/skills`,kn=`${ta}/mcp.json`,xs=".kilocodeignore",kl=".kilocode",Io=`${kl}/rules`,Ts=`${kl}/workflows`,_o=`${kl}/skills`,ea=`${kl}/mcp.json`,El=".kilocodemodes",Ns=".kilo",En=`${Ns}/AGENTS.md`,So=`${Ns}/rules`,Co=`${Ns}/commands`,Oo=`${Ns}/agents`,wn=`${Ns}/skills`,Ds=`${Ns}/mcp.json`,wl=".kilocodeignore",Iy=".agents/skills",Ln=".agentsmesh/rules",Fs=".agentsmesh/commands",Ro=".agentsmesh/agents",_y=".agentsmesh/mcp.json",Sy=".agentsmesh/ignore";});async function _p(t,e,r="project"){if(r==="global"){t.set(En,`${N}/_root.md`);for(let n of await L(e,So))$(t,w(e,n),N,".md");for(let n of await L(e,Co))$(t,w(e,n),X,".md");for(let n of await L(e,Oo))$(t,w(e,n),at,".md");for(let n of await L(e,wn))K(t,w(e,n),wn);t.set(Ds,".agentsmesh/mcp.json");return}t.set(fr,`${N}/_root.md`);for(let n of await L(e,Br))$(t,w(e,n),N,".md");for(let n of await L(e,Hr))$(t,w(e,n),X,".md");for(let n of await L(e,zr))$(t,w(e,n),at,".md");for(let n of await L(e,$e))K(t,w(e,n),$e);t.set(kn,".agentsmesh/mcp.json");for(let n of await L(e,Io)){let o=w(e,n);if(basename(o)==="00-root.md"){t.set(o,`${N}/_root.md`);continue}$(t,o,N,".md");}for(let n of await L(e,Ts))$(t,w(e,n),X,".md");for(let n of await L(e,_o))K(t,w(e,n),_o);t.set(ea,".agentsmesh/mcp.json");}var Cy=f(()=>{Dt();ko();Ft();i(_p,"buildKiloCodeImportPaths");});var te,Me,ra,Ge,Wt,je,An,Oy,vs,$s,Eo,Ue,bn,wo,na,oa,Ry,Sp,Cp,ky,Ey,Op,wy,Ms=f(()=>{te="kiro",Me="AGENTS.md",ra=".kiro",Ge=`${ra}/steering`,Wt=`${ra}/skills`,je=`${ra}/agents`,An=`${ra}/hooks`,Oy=`${ra}/settings`,vs=`${Oy}/mcp.json`,$s=".kiroignore",Eo=".kiro/steering",Ue=".kiro/steering/AGENTS.md",bn=".kiro/skills",wo=".kiro/agents",na=".kiro/settings/mcp.json",oa=".kiro/settings/kiroignore",Ry=".agents/skills",Sp=".agentsmesh/rules/_root.md",Cp=".agentsmesh/rules",ky=".agentsmesh/agents",Ey=".agentsmesh/mcp.json",Op=".agentsmesh/hooks.yaml",wy=".agentsmesh/ignore";});async function Rp(t,e,r="project"){if(r==="global"){t.set(Ue,`${N}/_root.md`);for(let n of await L(e,Eo)){let o=w(e,n);o!==Ue&&$(t,o,N,".md");}for(let n of await L(e,bn))K(t,w(e,n),bn);for(let n of await L(e,wo))$(t,w(e,n),at,".md");return}t.set(Me,`${N}/_root.md`);for(let n of await L(e,Ge))$(t,w(e,n),N,".md");for(let n of await L(e,Wt))K(t,w(e,n),Wt);for(let n of await L(e,je))$(t,w(e,n),at,".md");}var Ly=f(()=>{Dt();Ms();Ft();i(Rp,"buildKiroImportPaths");});var Ke,Ll,gr,Vr,Jr,Yr,We,hr,Gs,Pn,Lo,Ao,bo,xn,Tn,Ay,sa,Al,bl,kp,Po=f(()=>{Ke="opencode",Ll=".opencode",gr="AGENTS.md",Vr=`${Ll}/rules`,Jr=`${Ll}/commands`,Yr=`${Ll}/agents`,We=`${Ll}/skills`,hr="opencode.json",Gs=".config/opencode",Pn=`${Gs}/AGENTS.md`,Lo=`${Gs}/rules`,Ao=`${Gs}/commands`,bo=`${Gs}/agents`,xn=`${Gs}/skills`,Tn=`${Gs}/opencode.json`,Ay=".agents/skills",sa=".agentsmesh/rules",Al=".agentsmesh/commands",bl=".agentsmesh/agents",kp=".agentsmesh/mcp.json";});async function Ep(t,e,r="project"){if(r==="global"){t.set(Pn,`${N}/_root.md`);for(let n of await L(e,Lo))$(t,w(e,n),N,".md");for(let n of await L(e,Ao))$(t,w(e,n),X,".md");for(let n of await L(e,bo))$(t,w(e,n),at,".md");for(let n of await L(e,xn))K(t,w(e,n),xn);t.set(Tn,".agentsmesh/mcp.json");return}t.set(gr,`${N}/_root.md`);for(let n of await L(e,Vr))$(t,w(e,n),N,".md");for(let n of await L(e,Jr))$(t,w(e,n),X,".md");for(let n of await L(e,Yr))$(t,w(e,n),at,".md");for(let n of await L(e,We))K(t,w(e,n),We);t.set(hr,".agentsmesh/mcp.json");}var by=f(()=>{Dt();Po();Ft();i(Ep,"buildOpencodeImportPaths");});var Nn,xo,Be,ia,Xr,Zr,yr,aa,la,js,ca,Pl,Dn,Fn,qr,To,ma,vn,Py,No,xl,xy,Ty,Do=f(()=>{Nn="roo-code",xo=".roo",Be=`${xo}/rules/00-root.md`,ia=".roorules",Xr=`${xo}/rules`,Zr=`${xo}/commands`,yr=`${xo}/skills`,aa=`${xo}/mcp.json`,la=".rooignore",js=".roomodes",ca="settings/custom_modes.yaml",Pl=".roo",Dn=`${Pl}/rules`,Fn=`${Pl}/commands`,qr=`${Pl}/skills`,To="mcp_settings.json",ma=".rooignore",vn=`${Pl}/AGENTS.md`,Py=".agents/skills",No=".agentsmesh/rules",xl=".agentsmesh/commands",xy=".agentsmesh/mcp.json",Ty=".agentsmesh/ignore";});async function wp(t,e,r="project"){if(r==="global"){t.set(vn,`${N}/_root.md`);for(let n of await L(e,Dn))$(t,w(e,n),N,".md");for(let n of await L(e,Fn))$(t,w(e,n),X,".md");for(let n of await L(e,qr))K(t,w(e,n),qr);t.set(To,".agentsmesh/mcp.json");return}t.set(Be,`${N}/_root.md`),t.set(ia,`${N}/_root.md`);for(let n of await L(e,Xr)){let o=w(e,n);o!==Be&&$(t,o,N,".md");}for(let n of await L(e,".roo")){let o=w(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&$(t,o,N,".md");}for(let n of await L(e,Zr))$(t,w(e,n),X,".md");for(let n of await L(e,yr))K(t,w(e,n),yr);}var Ny=f(()=>{Dt();Do();Ft();i(wp,"buildRooCodeImportPaths");});async function Lp(t,e){t.set("AGENTS.md",`${N}/_root.md`),t.set(".windsurfrules",`${N}/_root.md`),await ul(t,e);for(let r of await L(e,".windsurf/rules"))$(t,w(e,r),N,".md");for(let r of await L(e,".windsurf/workflows"))$(t,w(e,r),X,".md");for(let r of await L(e,".windsurf/skills"))K(t,w(e,r),".windsurf/skills");}var Dy=f(()=>{Dt();Ft();i(Lp,"buildWindsurfImportPaths");});var Fy=f(()=>{Bh();Jh();Zh();qh();Qh();ty();oy();sy();cy();yy();Cy();Ly();by();Ny();Dy();});var vt=f(()=>{Fy();});var QP,tx,ex,rx,pl,Hm=f(()=>{ro();ht();_h();so();bh();Dh();jh();vt();QP={name:"antigravity",primaryRootInstructionPath:Pe,generateRules:dh,generateCommands:fh,generateAgents:yh,generateSkills:gh,generateMcp:hh,importFrom:Ah},tx={rootInstructionPath:Pe,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===Ti?null:t},paths:{rulePath(t,e){return `${rr}/${t}.md`},commandPath(t,e){return `${Nr}/${t}.md`},agentPath(t){return `${xe}/${Z(t)}/SKILL.md`}}},ex={rootInstructionPath:nr,renderPrimaryRootInstruction:Ih,skillDir:Dr,managedOutputs:{dirs:[Dr,Ni],files:[nr,ys]},rewriteGeneratedPath(t){return t===Pe?nr:t.startsWith(`${rr}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",Dr):t.startsWith(`${Nr}/`)?t.replace(Nr,Ni):t===Ti?ys:t},paths:{rulePath(t,e){return nr},commandPath(t,e){return `${Ni}/${t}.md`},agentPath(t){return `${xe}/${Z(t)}/SKILL.md`}}},rx={rules:"native",additionalRules:"embedded",commands:be("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},pl={id:"antigravity",generators:QP,capabilities:{rules:"native",additionalRules:"native",commands:be("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:Gh,project:tx,globalSupport:{capabilities:rx,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:ex},importer:{rules:{feature:"rules",mode:"directory",source:{project:[rr]},canonicalDir:oo,extensions:[".md"],map:Th},commands:{feature:"commands",mode:"directory",source:{project:[Nr],global:[Ni]},canonicalDir:ml,extensions:[".md"],map:Nh},mcp:{feature:"mcp",mode:"flatFile",source:{global:[ys]},canonicalDir:".agentsmesh",canonicalFilename:uh}},buildImportPaths:Ym,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function vy(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let s of n){if(!Ze(s))continue;let a=gt(s),l=Gt(s),c=s.type==="prompt"?l||a:a||l,m={type:s.type==="prompt"?"prompt":"command",[s.type==="prompt"?"prompt":"command"]:c};s.timeout!==void 0&&(m.timeout=s.timeout),o.push({matcher:s.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var $y=f(()=>{we();i(vy,"buildClaudeHooksObjectFromCanonical");});function My(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:fn,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("claude-code")));for(let o of n){let s=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=T(a,o.body.trim()||"");e.push({path:`${Fi}/${s}.md`,content:l});}return e}function Gy(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let n=T(r,e.body.trim()||"");return {path:`${vi}/${e.name}.md`,content:n}})}function jy(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(a=>{r[a]===void 0&&delete r[a];});let n=e.body.trim()||"",o=/^##\s*Role\b/m.test(n)?n:`## Role
|
|
45
45
|
|
|
46
|
-
${n}`,s=
|
|
46
|
+
${n}`,s=T(r,o);return {path:`${$i}/${e.name}.md`,content:s}})}function Uy(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Cs,content:e}]}function Ky(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=r.body.trim()||"",s=!o||/^##\s*Purpose\b/m.test(o)?o:`## Purpose
|
|
47
47
|
|
|
48
|
-
${o}`,a=
|
|
49
|
-
`);return [{path:
|
|
48
|
+
${o}`,a=T(n,s);e.push({path:`${Mi}/${r.name}/SKILL.md`,content:a});for(let l of r.supportingFiles){let c=l.relativePath.replace(/\\/g,"/");e.push({path:`${Mi}/${r.name}/${c}`,content:l.content});}}return e}function Wy(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions,n=t.permissions.ask??[];if(e.length===0&&r.length===0&&n.length===0)return [];let o=JSON.stringify({permissions:{allow:e,deny:r,ask:n}},null,2);return [{path:Gi,content:o}]}function By(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=vy(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:vr,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:Gi,content:n}]}function Hy(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
49
|
+
`);return [{path:ji,content:e}]}var zy=f(()=>{v();$r();$y();i(My,"generateRules");i(Gy,"generateCommands");i(jy,"generateAgents");i(Uy,"generateMcp");i(Ky,"generateSkills");i(Wy,"generatePermissions");i(By,"generateHooks");i(Hy,"generateIgnore");});function mt(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var He=f(()=>{i(mt,"mirrorSkillsToAgents");});function sx(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function Vy(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
|
|
50
50
|
|
|
51
|
-
## ${e?
|
|
51
|
+
## ${e?sx(e):"Guidance"}
|
|
52
52
|
|
|
53
53
|
${r}
|
|
54
|
-
`:""}var
|
|
54
|
+
`:""}var Jy=f(()=>{i(sx,"ruleSectionTitle");i(Vy,"renderClaudeGlobalPrimaryInstructions");});function Xy(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function Zy(t,e,r,n){if(r!=="global")return [];let o=n.has("agents"),s=n.has("commands");if(!o&&!s)return [];let a=[];if(o)for(let l of t.agents){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=T(c,l.body.trim()),p=`${Xm}/${l.name}.md`,u=await I(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:Xy(u,m)});}if(s)for(let l of t.commands){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=T(c,l.body.trim()),p=`${Xm}/${l.name}.md`,u=await I(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:Xy(u,m)});}return a}var qy=f(()=>{A();v();$r();i(Xy,"computeStatus");i(Zy,"generateClaudeGlobalExtras");});var Qy,tI,eI,rI=f(()=>{v();Y();Te();$r();Qy=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${Ki}/${t}`,content:await M(n,{...o,root:false},s)}},"claudeRuleMapper"),tI=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n)),a=ue(o.allowedTools),l=a.length>0?a:ue(o["allowed-tools"]);return {destPath:n,toPath:`${dl}/${t}`,content:await q(n,{description:typeof o.description=="string"?o.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},s)}},"claudeCommandMapper"),eI=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${fl}/${t}`,content:await yt(n,o,s)}},"claudeAgentMapper");});function nI(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(s=>({...s,target:Hh}))}var oI=f(()=>{Vt();$r();i(nI,"lintRules");});var ix,sI,ax,lx,Tl,bp=f(()=>{zy();$r();He();Jy();qy();Pp();rI();oI();vt();ix={name:"claude-code",primaryRootInstructionPath:fn,generateRules:My,generateCommands:Gy,generateAgents:jy,generateSkills:Ky,generateMcp:Uy,generatePermissions:Wy,generateHooks:By,generateIgnore:Hy,importFrom:Nl},sI={rootInstructionPath:fn,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`}}},ax={rootInstructionPath:fn,skillDir:".claude/skills",renderPrimaryRootInstruction:Vy,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",Ui,vr,".claudeignore"]},rewriteGeneratedPath(t){return t===Cs?Ui:t},mirrorGlobalPath(t,e){return mt(t,".claude/skills",e)},paths:sI.paths},lx={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},Tl={id:"claude-code",generators:ix,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:nI,project:sI,globalSupport:{capabilities:lx,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:ax,scopeExtras:Zy},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[fn,zh],global:[fn]},canonicalDir:Ki,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Fi],global:[Fi]},canonicalDir:Ki,extensions:[".md"],map:Qy}],commands:{feature:"commands",mode:"directory",source:{project:[vi],global:[vi]},canonicalDir:dl,extensions:[".md"],map:tI},agents:{feature:"agents",mode:"directory",source:{project:[$i],global:[$i]},canonicalDir:fl,extensions:[".md"],map:eI},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Cs],global:[Ui]},canonicalDir:".agentsmesh",canonicalFilename:Wi},ignore:{feature:"ignore",mode:"flatFile",source:{project:[ji],global:[ji]},canonicalDir:".agentsmesh",canonicalFilename:Vh}},buildImportPaths:Qm,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function mx(t){let e=basename(t,".md");return e==="_root"?"root":e}function iI(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:hn,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=mx(n.source),s={description:n.description||void 0,paths:n.globs.length>0?n.globs:void 0};Object.keys(s).forEach(l=>{s[l]===void 0&&delete s[l];});let a=Object.keys(s).length>0?T(s,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Mr}/${o}.md`,content:a});}return e}function aI(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n?`${r}
|
|
55
55
|
|
|
56
|
-
${n}`:r||n;return {path:`${
|
|
57
|
-
`);return [{path:
|
|
58
|
-
`)}function
|
|
56
|
+
${n}`:r||n;return {path:`${sr}/${e.name}.md`,content:o}})}function lI(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
57
|
+
`);return [{path:lo,content:e}]}function cI(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Gr,content:e}]}function mI(t){return t.agents.map(e=>({path:`${wt}/${Z(e.name)}/SKILL.md`,content:qe(e)}))}function px(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function ux(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${t}`,`# agentsmesh-matcher: ${r}`,`# agentsmesh-command: ${e}`,"set -e",e,""].join(`
|
|
58
|
+
`)}function pI(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=0;for(let s of n)Pr(s)&&(e.push({path:`${co}/${px(r)}-${o}.sh`,content:ux(r,s.command,s.matcher)}),o++);}return e}function uI(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${wt}/${r.name}/SKILL.md`,content:o});for(let s of r.supportingFiles){let a=s.relativePath.replace(/\\/g,"/");e.push({path:`${wt}/${r.name}/${a}`,content:s.content});}}return e}var dI=f(()=>{we();v();ht();de();i(mx,"ruleSlug");i(iI,"generateRules");i(aI,"generateCommands");i(lI,"generateIgnore");i(cI,"generateMcp");i(mI,"generateAgents");i(px,"safeEventName");i(ux,"buildHookScript");i(pI,"generateHooks");i(uI,"generateSkills");});async function gI(t,e,r){if(t==="workflows"||t.startsWith("workflows/"))return null;let n=t.replace(/\\/g,"/");if(n==="_root.md")return null;let o=join(e,n),{frontmatter:s,body:a}=E(r(o)),l=Fr(s.paths??s.globs),c={root:false,description:typeof s.description=="string"?s.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${yn}/${n}`,feature:"rules",content:await M(o,c,a)}}async function hI(t,e,r){let n=join(e,t),{frontmatter:o,body:s}=E(r(n)),a=Object.prototype.hasOwnProperty.call(o,"description"),l=a&&typeof o.description=="string"?o.description:"",c=a,m=s;if(!c){let p=s.indexOf(`
|
|
59
59
|
|
|
60
|
-
`);if(
|
|
61
|
-
`)&&(l=
|
|
62
|
-
`)),e.push({fromTool:"cline",fromPath:o,toPath:
|
|
60
|
+
`);if(p>0){let u=s.slice(0,p).trim();u&&!u.includes(`
|
|
61
|
+
`)&&(l=u,c=true,m=s.slice(p+2));}}return {destPath:n,toPath:`${gl}/${t}`,feature:"commands",content:await q(n,{description:l,hasDescription:c,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var xp=f(()=>{v();Y();Te();de();i(gI,"mapClineRuleFile");i(hI,"mapClineWorkflowFile");});async function yI(t,e,r){let n=join(t,yn),o=join(t,Mr),s=join(t,Mr),a=false;try{a=(await stat(s)).isFile();}catch{}if(a){let p=await I(s);if(p!==null){await R(n);let u=join(n,"_root.md"),{frontmatter:d,body:g}=E(r(p,s,u)),C=d.root===true?d:{...d,root:true},O=await M(u,C,g);await S(u,O),e.push({fromTool:"cline",fromPath:s,toPath:`${yn}/_root.md`,feature:"rules"});}return a}let l=null,c=join(o,"_root.md"),m=await I(c);if(m===null){let p=join(t,hn),u=await I(p);if(u!==null){l=p,await R(n);let d=join(n,"_root.md"),{frontmatter:g,body:h}=E(r(u,p,d)),O=g.root===true?g:{...g,root:true},_=await M(d,O,h);await S(d,_),e.push({fromTool:"cline",fromPath:p,toPath:`${yn}/_root.md`,feature:"rules"});}else {let h=(await x(o)).filter(C=>C.endsWith(".md")&&!C.includes("/workflows/")).sort()[0];if(h){let C=await I(h);if(C!==null){l=h,await R(n);let O=join(n,"_root.md"),{frontmatter:_,body:k}=E(r(C,h,O)),b=_.root===true?_:{..._,root:true},P=await M(O,b,k);await S(O,P),e.push({fromTool:"cline",fromPath:h,toPath:`${yn}/_root.md`,feature:"rules"});}}}}else {l=c,await R(n);let p=join(n,"_root.md"),{frontmatter:u,body:d}=E(r(m,c,p)),h=u.root===true?u:{...u,root:true},C=await M(p,h,d);await S(p,C),e.push({fromTool:"cline",fromPath:c,toPath:`${yn}/_root.md`,feature:"rules"});}return e.push(...await tt({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:i(async({srcPath:p,relativePath:u,normalizeTo:d})=>p===l?null:gI(u,n,d),"mapEntry")})),a}var II=f(()=>{A();v();Y();Ne();xp();de();i(yI,"importClineRules");});function fx(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let n=typeof e.type=="string"?e.type:typeof e.transportType=="string"?e.transportType:"stdio",o=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[],s=e.env,a=s!==null&&typeof s=="object"&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).filter(c=>typeof c[1]=="string")):{},l=typeof e.description=="string"?e.description:void 0;return {...l!==void 0&&{description:l},type:n,command:r,args:o,env:a}}async function _I(t,e){let r=[Gr,Yh].map(c=>join(t,c)),n=null,o=null;for(let c of r){let m=await I(c);if(m!==null){n=c,o=m;break}}if(o===null)return;let s=n??r[0],a;try{a=JSON.parse(o);}catch{}let l=a?.mcpServers;if(l!==void 0&&typeof l=="object"&&l!==null&&Object.keys(l).length>0){let c={};for(let[m,p]of Object.entries(l)){let u=fx(p);u&&(c[m]=u);}Object.keys(c).length>0&&(await R(join(t,".agentsmesh")),await S(join(t,rp),JSON.stringify({mcpServers:c},null,2)),e.push({fromTool:gn,fromPath:s,toPath:rp,feature:"mcp"}));}}var SI=f(()=>{A();de();i(fx,"mapClineServerToCanonical");i(_I,"importClineMcp");});function CI(t){return gx.some(e=>e.test(t))}var gx,OI=f(()=>{gx=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];i(CI,"isReservedArtifactName");});async function yx(t){let e=await x(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),s=basename(o);if(CI(s))continue;let a=await I(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Ir(t,e,r){let n=await yx(e),o=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let s of n){let a=join(o,s.relativePath);await R(dirname(a));let l=r.normalize(s.content,s.absolutePath,a);if(s.relativePath==="SKILL.md"){let{frontmatter:c,body:m}=E(l),p=await tr(a,{...c,name:t},m);await S(a,p);}else await S(a,l);r.results.push({fromTool:r.targetName,fromPath:s.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${s.relativePath}`,feature:"skills"});}}async function kI(t,e,r,n){let o=join(n.projectRoot,n.destCanonicalSkillsDir,t);await R(o);let s=join(o,"SKILL.md"),a=n.normalize(r,e,s),{frontmatter:l,body:c}=E(a),m=await tr(s,{...l,name:t},c);await S(s,m),n.results.push({fromTool:n.targetName,fromPath:e,toPath:`${n.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function $n(t){let e=new Map;try{let n=(await x(t)).filter(o=>basename(o)==="SKILL.md");for(let o of n){let s=dirname(o),a=basename(s);e.set(a,s);}}catch{}return e}var Us=f(()=>{A();v();Y();OI();i(yx,"readNativeSkill");i(Ir,"importDirectorySkill");i(kI,"importFlatSkill");i($n,"findDirectorySkills");});async function EI(t,e,r,n=wt){let o=join(t,n),s=await $n(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:Xh,targetName:"cline",normalize:r,results:e};for(let[l,c]of s){let m=join(c,"SKILL.md"),p=await I(m);if(!p)continue;let u=E(p),d=Qe(u.frontmatter,l);if(d){let g=join(t,np);await R(g);let h=join(g,`${d.name}.md`);await S(h,le(d,r(u.body,m,h))),e.push({fromTool:"cline",fromPath:m,toPath:`${np}/${d.name}.md`,feature:"agents"});continue}await Ir(l,c,a);}}var wI=f(()=>{A();v();ht();Us();de();i(EI,"importClineSkills");});function Dp(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function LI(t,e){let n=(await x(t).catch(()=>[])).filter(o=>basename(o).endsWith(".sh")&&dirname(o)===t);for(let o of n){let s=await I(o);if(!s)continue;let a=Dp(s,"event"),l=Dp(s,"command");if(!a||!l)continue;let c=Dp(s,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:c,command:l});}}async function bI(t,e){let r={};if(await LI(join(t,co),r),await LI(join(t,uo),r),Object.keys(r).length===0)return;let n=join(t,tp);await R(dirname(n)),await S(n,stringify(r)),e.push({fromTool:gn,fromPath:join(t,uo),toPath:tp,feature:"hooks"});}var PI=f(()=>{A();de();i(Dp,"extractMeta");i(LI,"loadHooksFromDir");i(bI,"importClineHooks");});async function $l(t){let e=[],r=await z(gn,t),n=await yI(t,e,r),o=join(t,lo),s=await I(o);if(s!==null&&s.trim()){let l=s.split(/\r?\n/),c=[];for(let m of l){let p=m.trim();p&&!p.startsWith("#")&&c.push(p);}if(c.length>0){await R(join(t,".agentsmesh"));let m=join(t,ep);await S(m,c.join(`
|
|
62
|
+
`)),e.push({fromTool:"cline",fromPath:o,toPath:ep,feature:"ignore"});}}await _I(t,e);let a=join(t,gl);return n||e.push(...await tt({srcDir:join(t,sr),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:i(({relativePath:l,normalizeTo:c})=>hI(l,a,c),"mapEntry")})),await EI(t,e,r),await bI(t,e),e}var Fp=f(()=>{Ct();A();Ne();xp();II();de();SI();wI();PI();i($l,"importFromCline");});function xI(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(s=>({...s,target:gn}))}var TI=f(()=>{Vt();de();i(xI,"lintRules");});function B(t,e,r){return {level:"warning",file:t,target:e,message:r}}function Sx(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 Ks(t,e,r,n){let o=n?.unsupportedBy??e,s=Sx(r);return B(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${s} are projected.`)}var $t=f(()=>{i(B,"createWarning");i(Sx,"formatOxfordComma");i(Ks,"createUnsupportedHookWarning");});function NI(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>B(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function DI(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[B(".agentsmesh/hooks.yaml","cline","cline hooks are emitted as .clinerules/hooks/*.sh wrapper scripts with a `#!/usr/bin/env bash` header; they require a POSIX shell (git-bash or WSL) to execute on Windows.")]:[]:[]}var FI=f(()=>{$t();i(NI,"lintCommands");i(DI,"lintHooks");});var Cx,Ox,Rx,kx,vI,$I=f(()=>{dI();ro();de();Fp();TI();FI();vt();ms();ht();Cx={name:"cline",primaryRootInstructionPath:hn,generateRules:iI,generateCommands:aI,generateAgents:mI,generateSkills:uI,generateMcp:cI,generateHooks:pI,generateIgnore:lI,importFrom:$l},Ox={rootInstructionPath:hn,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 `${Mr}/${t}.md`},commandPath(t,e){return `${sr}/${t}.md`},agentPath(t,e){return ae(e,"cline")?`.cline/skills/${Z(t)}/SKILL.md`:null}}},Rx={skillDir:wt,managedOutputs:{dirs:[mo,po,uo,wt,".agents/skills"],files:[Gr,lo]},rewriteGeneratedPath(t){return t===hn?null:t.startsWith(`${co}/`)?`${uo}/${t.slice(co.length+1)}`:t.startsWith(`${sr}/`)?`${po}/${t.slice(sr.length+1)}`:t.startsWith(`${Mr}/`)?`${mo}/${t.slice(Mr.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${wt}/`)?`.agents/skills/${t.slice(wt.length+1)}`:null},paths:{rulePath(t,e){return `${mo}/${t}.md`},commandPath(t,e){return `${po}/${t}.md`},agentPath(t,e){return ae(e,"cline")?`.cline/skills/${Z(t)}/SKILL.md`:null}}},kx={rules:"native",additionalRules:"native",commands:be("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},vI={id:"cline",generators:Cx,capabilities:{rules:"native",additionalRules:"native",commands:be("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:xI,lint:{commands:NI,hooks:DI},project:Ox,globalSupport:{capabilities:kx,detectionPaths:[mo,po,uo,wt,Gr,lo],layout:Rx},buildImportPaths:op,detectionPaths:[".clinerules",".cline"]};});var Lt,MI,tn,Fo,GI,ze,jI,Ml,vo,_r,$o,en,vp,Ws,ua,$p,UI,Mp,KI,WI,Gp,jp,Up,Mt=f(()=>{Lt="codex-cli",MI="codex.md",tn="AGENTS.md",Fo=".codex/AGENTS.md",GI=".codex/AGENTS.override.md",ze=".agents/skills",jI=".codex/skills",Ml=".codex/config.toml",vo=".codex/instructions",_r=".codex/rules",$o=".codex/agents",en=".agentsmesh/rules",vp=".agentsmesh/commands",Ws=".agentsmesh/agents",ua=".agentsmesh/skills",$p=".agentsmesh/mcp.json",UI="am-codex-rule:v1",Mp="# am-json: ",KI="# am-body-b64-begin",WI="# am-body-b64-end",Gp="# am64:",jp="<!-- agentsmesh:codex-rule-index:start -->",Up="<!-- agentsmesh:codex-rule-index:end -->";});function Kp(t){return basename(t,".md")}function da(t){return `${vo}/${Kp(t.source)}.md`}function BI(t){let e={root:t.root,description:t.description||void 0,globs:t.globs.length>0?t.globs:void 0,targets:t.targets.length>0?t.targets:void 0,codex_emit:t.codexEmit||void 0,codex_instruction:t.codexInstructionVariant&&t.codexInstructionVariant!=="default"?t.codexInstructionVariant:void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),T(e,t.body.trim()||"")}function wx(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 \`${_r}/${Kp(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function HI(t,e){let r=t.trim(),n=e.filter(a=>!a.root);if(n.length===0)return r;let o=n.map(a=>`- [${a.description||Kp(a.source)}](${da(a)}): ${wx(a)}`),s=[jp,"## Additional Rule Files",...o,Up].join(`
|
|
63
63
|
`);return r?`${r}
|
|
64
64
|
|
|
65
|
-
${s}`:s}function
|
|
66
|
-
`).trim()}var
|
|
65
|
+
${s}`:s}function zI(t){let e=jp.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=Up.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
|
|
66
|
+
`).trim()}var Gl=f(()=>{v();Mt();i(Kp,"ruleSlug");i(da,"codexInstructionMirrorPath");i(BI,"serializeCodexInstructionMirror");i(wx,"summarizeRule");i(HI,"appendCodexRuleIndex");i(zI,"stripCodexRuleIndex");});function Ax(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function bx(t){return t.split(`
|
|
67
67
|
`).map(e=>e.length>0?`# ${e}`:"#").join(`
|
|
68
|
-
`)}function
|
|
69
|
-
`:`${["# 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.","#",...
|
|
68
|
+
`)}function Px(t){let e=t.trim();return e?Ax(e)?`${e}
|
|
69
|
+
`:`${["# 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.","#",...bx(e).split(`
|
|
70
70
|
`),"#","# Example template:","# prefix_rule(",'# pattern = ["git", "status"],','# decision = "allow",','# justification = "Allow safe status checks",',"# )"].join(`
|
|
71
71
|
`)}
|
|
72
|
-
`:""}function
|
|
72
|
+
`:""}function Wp(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:tn,content:HI(e.body,t.rules)});for(let n of t.rules){if(n.root)continue;let o=basename(n.source,".md");n.targets.length>0&&!n.targets.includes("codex-cli")||(n.codexEmit==="execution"&&r.push({path:`${_r}/${o}.rules`,content:Px(n.body)}),r.push({path:da(n),content:BI(n)}));}return r}function Bp(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root||n.codexEmit==="execution"?false:n.targets.length===0||n.targets.includes("codex-cli"));return Zt(e?.body.trim()??"",r)}var VI=f(()=>{Tr();Mt();Gl();i(Ax,"looksLikeCodexRulesDsl");i(bx,"toCodexRulesComments");i(Px,"toSafeCodexRulesContent");i(Wp,"generateRules");i(Bp,"renderCodexGlobalInstructions");});function Hp(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${ze}/${r.name}/SKILL.md`,content:o});for(let s of r.supportingFiles){let a=s.relativePath.replace(/\\/g,"/");e.push({path:`${ze}/${r.name}/${a}`,content:s.content});}}return e}function xx(t){return {path:`${ze}/${Tt(t.name)}/SKILL.md`,content:gs(t)}}function zp(t){return t.commands.map(xx)}var JI=f(()=>{v();Mt();er();i(Hp,"generateSkills");i(xx,"commandToSkillOutput");i(zp,"generateCommands");});function Vp(t){return t.agents.map(e=>({path:`${$o}/${e.name}.toml`,content:Tx(e)}))}function Tx(t){let e=[];e.push(`name = ${JSON.stringify(t.name)}`),t.description&&e.push(`description = ${JSON.stringify(t.description)}`),t.model&&e.push(`model = ${JSON.stringify(t.model)}`),t.permissionMode==="read-only"||t.permissionMode==="deny"?e.push('sandbox_mode = "read-only"'):t.permissionMode==="allow"&&e.push('sandbox_mode = "workspace-write"');let r=t.body.trim()||"";if(r.includes("'''")){let n=r.replace(/\\/g,"\\\\").replace(/"/g,'\\"');e.push(`developer_instructions = """
|
|
73
73
|
${n}
|
|
74
74
|
"""`);}else e.push(`developer_instructions = '''
|
|
75
75
|
${r}
|
|
76
76
|
'''`);return e.join(`
|
|
77
77
|
`)+`
|
|
78
|
-
`}var
|
|
78
|
+
`}var YI=f(()=>{Mt();i(Vp,"generateAgents");i(Tx,"serializeAgentToCodexToml");});function jl(t){return "command"in t}function XI(t){return "url"in t}var Ul=f(()=>{i(jl,"isStdioMcpServer");i(XI,"isUrlMcpServer");});function Jp(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>jl(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=Nx(e);return [{path:Ml,content:r}]}function Nx(t){let e=[];for(let[r,n]of Object.entries(t)){let o=ZI(r)?`"${r}"`:r,s=[];s.push(`[mcp_servers.${o}]`),s.push(`command = ${JSON.stringify(n.command)}`);let a="["+n.args.map(c=>JSON.stringify(c)).join(", ")+"]";s.push(`args = ${a}`);let l=Object.entries(n.env);if(l.length>0){let c=l.map(([m,p])=>`${ZI(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");s.push(`env = { ${c} }`);}e.push(s.join(`
|
|
79
79
|
`));}return e.join(`
|
|
80
80
|
|
|
81
81
|
`)+`
|
|
82
|
-
`}function
|
|
83
|
-
`).find(c=>c.startsWith(
|
|
84
|
-
`)){let m=c.trimEnd();if(m===cy){l=true;continue}if(m===my){l=false;continue}l&&m.startsWith(Em)&&a.push(m.slice(Em.length));}if(a.length===0)return null;try{let c=Buffer.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:s},body:c}}catch{return null}}var Py=f(()=>{wt();i(xy,"tryParseEmbeddedCanonicalFromCodexRules");});async function Ty(t,e,r){let n=[],o=join(t,qe);try{let s=await P(o),a=s.filter(c=>c.endsWith(".md"));for(let c of a){let m=await I(c);if(!m)continue;let u=relative(o,c).replace(/\\/g,"/"),p=join(e,u),{frontmatter:d,body:g}=O(r(m,c,p));await k(e);let h=d.root===!0?d:{...d,root:!1},R=await $(p,h,g);await _(p,R),n.push({fromTool:St,fromPath:c,toPath:`${Er}/${u}`,feature:"rules"});}let l=s.filter(c=>c.endsWith(".rules"));for(let c of l){let m=await I(c);if(!m)continue;let u=relative(o,c).replace(/\\/g,"/").replace(/\.rules$/i,".md"),p=join(e,u);await k(e);let d=xy(m);if(d){let g=await $(p,{description:d.meta.description,globs:d.meta.globs,root:!1},r(d.body,c,p));await _(p,g);}else {let g=await $(p,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),c,p));await _(p,g);}n.push({fromTool:St,fromPath:c,toPath:`${Er}/${u}`,feature:"rules"});}}catch{}return n}var Ly=f(()=>{E();F();Y();wt();Py();i(Ty,"importCodexNonRootRuleFiles");});async function Dy(t,e,r,n,o){let s=join(t,sy),a=join(t,Or),l=join(t,iy),c=join(t,Wn),m=o==="global"?await I(l):null,u=o==="global"?await I(c):null,p=o==="project"?await I(a):null,d=o==="project"?await I(s):null,g=m!==null?l:u!==null?c:p!==null?a:s,h=join(t,Er),R=m??u??p??d;if(R!==null){await k(h);let C=join(h,"_root.md"),S=g===a||g===c||g===l?dy(R):R,w=await Ge({content:S,projectRoot:t,rulesDir:Er,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...w.results);let D=r(g===a||g===c||g===l?n(w.rootContent,g,C):w.rootContent,g,C),{frontmatter:b,body:x}=O(D),K=b.root===true?b:{...b,root:true},M=await $(C,K,x);await _(C,M),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${Er}/_root.md`,feature:"rules"});}await lP(t,h,e,r),e.push(...await Ty(t,h,r)),o!=="global"&&e.push(...await st({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:i(async({srcPath:C,normalizeTo:S})=>{let w=relative(t,dirname(C)).replace(/\\/g,"/"),D=basename(C),b=D==="AGENTS.override.md";if(!w||w==="."||!b&&D!=="AGENTS.md")return null;let x=w.replace(/\//g,"-");if(!va(w))return await br(join(h,`${x}.md`)),null;let K=join(h,`${x}.md`),{frontmatter:M,body:W}=O(S(K));return {destPath:K,toPath:`${Er}/${x}.md`,feature:"rules",content:await $(K,{...M,root:false,globs:[`${w}/**`],...b?{codex_instruction:"override"}:{}},W)}},"mapEntry")}));}async function lP(t,e,r,n){try{let s=(await P(join(t,Bn))).filter(l=>l.endsWith(".md")),a=join(t,Bn);for(let l of s){let c=relative(a,l).replace(/\\/g,"/");if(c==="_root.md")continue;let m=await I(l);if(!m)continue;let u=join(e,c),{frontmatter:p,body:d}=O(n(m,l,u));await k(e);let g=p.root===!0?p:{...p,root:!1},h=await $(u,g,d);await _(u,h),r.push({fromTool:St,fromPath:l,toPath:`${Er}/${c}`,feature:"rules"});}}catch{}}var Fy=f(()=>{E();F();Y();wo();$e();gi();wt();Ly();Na();i(Dy,"importCodexRules");i(lP,"importInstructionMirrors");});async function $a(t,e){let r=e?.scope??"project",n=[],o=await H(St,t,r),s=await H("windsurf",t,r);return await Dy(t,n,o,s,r),await wy(t,n,o),await Ey(t,n,o),await Cy(t,n),n}var Gm=f(()=>{bt();wt();ky();Oy();by();Fy();i($a,"importFromCodex");});function vy(t,e,r){let{rules:n}=t;return n.length===0?[]:n.some(s=>s.root)?[]:[{level:"warning",file:relative(e,n[0].source),target:St,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var $y=f(()=>{wt();i(vy,"lintRules");});function My(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(V(".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(V(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var Gy=f(()=>{Wt();i(My,"lintMcp");});function jy(t){return fi(t)}var Uy=f(()=>{Na();i(jy,"codexAdvisoryInstructionPath");});var mP,uP,pP,dP,By,Ky=f(()=>{Ry();wt();Gm();$y();Gy();Ut();yo();Uy();vs();mP={name:"codex-cli",primaryRootInstructionPath:Or,generateRules:Am,generateCommands:Nm,generateAgents:Dm,generateSkills:Lm,generateMcp:Fm,importFrom:$a},uP={rootInstructionPath:Or,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${qe}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return jy(e)},commandPath(t,e){return xs(e,"codex-cli")?`${Ee}/${Eo(t)}/SKILL.md`:null},agentPath(t,e){return `${Kn}/${t}.toml`}}},pP={rootInstructionPath:Wn,renderPrimaryRootInstruction:Tm,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${qe}/${e}.rules`]},skillDir:Ee,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Wn,".codex/config.toml"]},rewriteGeneratedPath(t){return t===Or?Wn:t.startsWith(`${Bn}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${qe}/${t}.rules`:Wn},commandPath(t,e){return xs(e,"codex-cli")?`${Ee}/${Eo(t)}/SKILL.md`:null},agentPath(t,e){return `${Kn}/${t}.toml`}}},dP={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},By={id:"codex-cli",generators:mP,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:vy,lint:{mcp:My},project:uP,globalSupport:{capabilities:dP,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:pP},buildImportPaths:Xc,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function gP(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 Hy(t){return `${We}/${t}.md`}function zy(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"],N(e,t.body.trim()||"")}function Vy(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:gP(t["x-agentsmesh-allowed-tools"])}}function Jy(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"],N(r,e.trim()||"")}var Ma=f(()=>{F();Ke();i(gP,"toStringArray");i(Hy,"continueCommandRulePath");i(zy,"serializeCommandRule");i(Vy,"parseCommandRuleFrontmatter");i(Jy,"serializeImportedCommand");});function Yy(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:Sr,content:N(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"),s={};n.description&&(s.description=n.description),n.globs.length>0&&(s.globs=n.globs),e.push({path:`${Ie}/${o}.md`,content:N(s,n.body.trim()||"")});}return e}function Xy(t){return t.commands.map(e=>({path:`${We}/${e.name}.md`,content:zy(e)}))}function Zy(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ha,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function qy(t){return Ne(t,Be)}var Qy=f(()=>{fe();F();Ma();Ke();i(Yy,"generateRules");i(Xy,"generateCommands");i(Zy,"generateMcp");i(qy,"generateSkills");});function IP(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[s,a]of Object.entries(n)){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a;typeof l.command=="string"&&(o[s]={type:typeof l.type=="string"?l.type:"stdio",command:l.command,args:Co(l.args),env:ko(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function SP(t,e){let r=(await P(join(t,Zc))).filter(s=>[".json",".yaml",".yml"].includes(extname(s))),n={},o=[];for(let s of r){let a=await I(s);a&&(Object.assign(n,IP(a,extname(s))),o.push(s));}if(Object.keys(n).length!==0){await _(join(t,Qc),JSON.stringify({mcpServers:n},null,2));for(let s of o)e.push({fromTool:Po,fromPath:s,toPath:Qc,feature:"mcp"});}}async function Ga(t){let e=[],r=await H(Po,t);return e.push(...await gt(ja,t,"project",{normalize:r})),await De(t,Be,Po,e,r),await SP(t,e),e}var jm=f(()=>{bt();E();fe();Me();he();Ke();Um();i(IP,"readMcpServers");i(SP,"importMcp");i(Ga,"importFromContinue");});function _P(t){return t==="general.md"||t==="_root.md"}var rI,nI,oI=f(()=>{F();Y();Ma();Ke();i(_P,"isContinueRootRulePath");rI=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=_P(t),o=n?"_root.md":t,s=join(r,o),{frontmatter:a,body:l}=O(e(s)),c={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return c.description===void 0&&delete c.description,c.globs===void 0&&delete c.globs,{destPath:s,toPath:`${ya}/${o}`,content:await $(s,c,l)}},"continueRuleMapper"),nI=i(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:s,body:a}=O(r(o)),l=Vy(s,t),c=l.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",u=m?`${m}/${c}.md`:`${c}.md`,p=join(n,u),d=await Q(p,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},O(Jy(l,a)).body);return {destPath:p,toPath:`${Ia}/${u}`,content:d}},"continueCommandMapper");});function sI(t,e,r,n){return lt(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Po}))}var iI=f(()=>{ye();Ke();i(sI,"lintRules");});function aI(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>V(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var lI=f(()=>{Wt();i(aI,"lintCommands");});function wP(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var cI,mI=f(()=>{E();Ke();i(wP,"computeStatus");cI=i(async(t,e,r,n)=>{if(r!=="global")return [];let o=n.has("rules"),s=n.has("commands"),a=n.has("mcp");if(!(o&&t.rules.length>0||s&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let c={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(c.rules=t.rules.map(p=>({name:p.description||basename(p.source,".md"),rule:p.body.trim()}))),s&&t.commands.length>0&&(c.prompts=t.commands.map(p=>{let d={name:p.name};return p.description&&(d.description=p.description),d.prompt=p.body.trim(),d})),a&&t.mcp!==null){let p=Object.entries(t.mcp.mcpServers);p.length>0&&(c.mcpServers=p.map(([d,g])=>({name:d,...g})));}let m=stringify(c),u=await I(join(e,Js));return [{target:"continue",path:Js,content:m,currentContent:u??void 0,status:wP(u,m)}]},"generateContinueGlobalConfig");});function EP(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var uI,pI=f(()=>{E();Ke();mI();i(EP,"computeStatus");uI=i(async(t,e,r,n)=>{let o=await cI(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let s=t.rules.find(c=>c.root);if(!s)return o;let a=s.body.trim(),l=await I(join(e,Ao));return [...o,{target:"continue",path:Ao,content:a,currentContent:l??void 0,status:EP(l,a)}]},"generateContinueScopeExtras");});var bP,xP,PP,AP,ja,Um=f(()=>{Qy();Ke();jm();oI();iI();lI();Ma();Ut();pI();bP={name:"continue",primaryRootInstructionPath:Sr,generateRules:Yy,generateCommands:Xy,generateSkills:qy,generateMcp:Zy,importFrom:Ga},xP={rootInstructionPath:Sr,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Ie}/${t}.md`},commandPath(t,e){return Hy(t)},agentPath(t,e){return null}}},PP={rootInstructionPath:Sr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Ao]}],skillDir:Be,managedOutputs:{dirs:[Ie,We,Be,".agents/skills"],files:[ha,Ao,Js]},mirrorGlobalPath(t,e){return t.startsWith(`${Be}/`)?`.agents/skills/${t.slice(Be.length+1)}`:null},paths:{rulePath(t,e){return `${Ie}/${t}.md`},commandPath(t,e){return `${We}/${t}.md`},agentPath(t,e){return null}}},AP={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},ja={id:"continue",generators:bP,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/*).",lintRules:sI,lint:{commands:aI},project:xP,globalSupport:{capabilities:AP,detectionPaths:[Ie,We,".continue/mcpServers",Be],layout:PP,scopeExtras:uI},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Ie],global:[Ie]},canonicalDir:ya,extensions:[".md"],map:rI},commands:{feature:"commands",mode:"directory",source:{project:[We],global:[We]},canonicalDir:Ia,extensions:[".md"],map:nI}},buildImportPaths:tm,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var xr,Hn,dI,zn,sn,tr,er,Vn,Jn,Ua,Wa,fI,Bm,gI,an,Ko,Pr,Ho,Yn,Km,Hm,ee=f(()=>{xr="copilot",Hn=".github/copilot-instructions.md",dI=".github/copilot",zn=".github/instructions",sn=".github/prompts",tr=".github/hooks",er=".github/skills",Vn=".github/agents",Jn=".agentsmesh/rules",Ua=".agentsmesh/commands",Wa=".agentsmesh/agents",fI=".agentsmesh/skills",Bm=".agentsmesh/hooks.yaml",gI=".github/copilot-hooks",an=".copilot/copilot-instructions.md",Ko=".copilot/agents",Pr=".copilot/skills",Ho=".copilot/prompts",Yn=".copilot/AGENTS.md",Km=".claude/skills",Hm=".agents/skills";});function hI(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 Ba(t){return `${sn}/${t}.prompt.md`}function yI(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"],N(e,t.body.trim()||"")}function II(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=hI(t["x-agentsmesh-allowed-tools"]),s=o.length>0?o:hI(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:s}}var Ka=f(()=>{F();ee();i(hI,"toStringArray");i(Ba,"commandPromptPath");i(yI,"serializeCommandPrompt");i(II,"parseCommandPromptFrontmatter");});function Ha(t){return cr(t)}var zm=f(()=>{ce();i(Ha,"hasHookCommand");});function NP(t){let e=basename(t,".md");return e==="_root"?"root":e}function DP(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function SI(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 s=n.description?`## ${n.description}`:null;s?e.push(`${s}
|
|
82
|
+
`}function ZI(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var qI=f(()=>{Ul();Mt();i(Jp,"generateMcp");i(Nx,"serializeMcpToToml");i(ZI,"needsTomlQuoting");});var QI=f(()=>{VI();JI();YI();qI();});var t_=f(()=>{QI();});function vx(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let n=Array.isArray(e.args)?e.args.filter(a=>typeof a=="string"):[],o=e.env,s=o!==null&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).filter(a=>typeof a[1]=="string")):{};return {type:"stdio",command:r,args:n,env:s}}async function e_(t,e){let r=join(t,Ml),n=await I(r);if(n===null)return;let o;try{o=parse$1(n);}catch{return}let s=o.mcp_servers;if(!s||typeof s!="object"||Array.isArray(s)||Object.keys(s).length===0)return;let a={};for(let[l,c]of Object.entries(s)){let m=vx(c);m&&(a[l]=m);}Object.keys(a).length!==0&&(await pe(t,$p,a),e.push({fromTool:Lt,fromPath:r,toPath:$p,feature:"mcp"}));}var r_=f(()=>{A();io();Mt();i(vx,"mapTomlServerToCanonical");i(e_,"importMcp");});async function n_(t,e,r){let n={projectRoot:t,sourceSkillsDir:ze,destCanonicalSkillsDir:ua,targetName:Lt,normalize:r,results:e};for(let o of [ze,jI]){let s=join(t,o),a=await readdir(s,{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(a===null)continue;let l=false;for(let c of a){if(!c.isDirectory()&&!c.isSymbolicLink())continue;let m=join(s,c.name),p=join(m,"SKILL.md"),u=await I(p);if(!u)continue;l=true;let d=c.name,g=join(t,ua,d,"SKILL.md"),h=r(u,p,g),{frontmatter:C,body:O}=E(h),_=il(C,c.name);if(_){await ce(join(t,ua,d));let D=join(t,vp);await R(D);let b=join(D,`${_.name}.md`);await S(b,al(_,r(O,p,b))),e.push({fromTool:Lt,fromPath:p,toPath:`${vp}/${_.name}.md`,feature:"commands"});continue}let k=Qe(C,c.name);if(k){await ce(join(t,ua,d));let D=join(t,Ws);await R(D);let b=join(D,`${k.name}.md`);await S(b,le(k,r(O,p,b))),e.push({fromTool:Lt,fromPath:p,toPath:`${Ws}/${k.name}.md`,feature:"agents"});continue}await Ir(d,m,n);}if(l)return}}var o_=f(()=>{A();v();er();ht();hs();Us();Mt();i(n_,"importSkills");});async function s_(t,e,r){let n=join(t,$o),o=join(t,Ws);try{let a=(await x(n)).filter(l=>l.endsWith(".toml"));for(let l of a){let c=await I(l);if(!c)continue;let m=parse$1(c);if(!m||typeof m!="object")continue;let p=typeof m.name=="string"?m.name:basename(l,".toml"),u=typeof m.description=="string"?m.description:"",d=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":"",O=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(P=>typeof P=="string"):[];await R(o);let _=join(o,`${p}.md`),k=r(d,l,_),b=le({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:C,maxTurns:0,mcpServers:O,hooks:{},skills:[],memory:""},k);await S(_,b),e.push({fromTool:Lt,fromPath:l,toPath:`${Ws}/${p}.md`,feature:"agents"});}}catch{}}var i_=f(()=>{A();ht();Mt();i(s_,"importCodexAgentsFromToml");});function a_(t){if(!t.includes(UI))return null;let e=t.split(`
|
|
83
|
+
`).find(c=>c.startsWith(Mp));if(!e)return null;let r;try{r=JSON.parse(e.slice(Mp.length));}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=typeof n.description=="string"?n.description:"",s=Array.isArray(n.globs)?n.globs.filter(c=>typeof c=="string"):[],a=[],l=false;for(let c of t.split(`
|
|
84
|
+
`)){let m=c.trimEnd();if(m===KI){l=true;continue}if(m===WI){l=false;continue}l&&m.startsWith(Gp)&&a.push(m.slice(Gp.length));}if(a.length===0)return null;try{let c=Buffer.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:s},body:c}}catch{return null}}var l_=f(()=>{Mt();i(a_,"tryParseEmbeddedCanonicalFromCodexRules");});async function m_(t,e,r){let n=[],o=join(t,_r);try{let s=await x(o),a=s.filter(c=>c.endsWith(".md"));for(let c of a){let m=await I(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/"),u=join(e,p),{frontmatter:d,body:g}=E(r(m,c,u));await R(e);let h=d.root===!0?d:{...d,root:!1},C=await M(u,h,g);await S(u,C),n.push({fromTool:Lt,fromPath:c,toPath:`${en}/${p}`,feature:"rules"});}let l=s.filter(c=>c.endsWith(".rules"));for(let c of l){let m=await I(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await R(e);let d=a_(m);if(d){let g=await M(u,{description:d.meta.description,globs:d.meta.globs,root:!1},r(d.body,c,u));await S(u,g);}else {let g=await M(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),c,u));await S(u,g);}n.push({fromTool:Lt,fromPath:c,toPath:`${en}/${p}`,feature:"rules"});}}catch{}return n}var p_=f(()=>{A();v();Y();Mt();l_();i(m_,"importCodexNonRootRuleFiles");});async function d_(t,e,r,n,o){let s=join(t,MI),a=join(t,tn),l=join(t,GI),c=join(t,Fo),m=o==="global"?await I(l):null,p=o==="global"?await I(c):null,u=o==="project"?await I(a):null,d=o==="project"?await I(s):null,g=m!==null?l:p!==null?c:u!==null?a:s,h=join(t,en),C=m??p??u??d;if(C!==null){await R(h);let O=join(h,"_root.md"),_=g===a||g===c||g===l?zI(C):C,k=await or({content:_,projectRoot:t,rulesDir:en,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...k.results);let D=r(g===a||g===c||g===l?n(k.rootContent,g,O):k.rootContent,g,O),{frontmatter:b,body:P}=E(D),J=b.root===true?b:{...b,root:true},j=await M(O,J,P);await S(O,j),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${en}/_root.md`,feature:"rules"});}await Wx(t,h,e,r),e.push(...await m_(t,h,r)),o!=="global"&&e.push(...await tt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:i(async({srcPath:O,normalizeTo:_})=>{let k=relative(t,dirname(O)).replace(/\\/g,"/"),D=basename(O),b=D==="AGENTS.override.md";if(!k||k==="."||!b&&D!=="AGENTS.md")return null;let P=k.replace(/\//g,"-");if(!ll(k))return await ce(join(h,`${P}.md`)),null;let J=join(h,`${P}.md`),{frontmatter:j,body:W}=E(_(J));return {destPath:J,toPath:`${en}/${P}.md`,feature:"rules",content:await M(J,{...j,root:false,globs:[`${k}/**`],...b?{codex_instruction:"override"}:{}},W)}},"mapEntry")}));}async function Wx(t,e,r,n){try{let s=(await x(join(t,vo))).filter(l=>l.endsWith(".md")),a=join(t,vo);for(let l of s){let c=relative(a,l).replace(/\\/g,"/");if(c==="_root.md")continue;let m=await I(l);if(!m)continue;let p=join(e,c),{frontmatter:u,body:d}=E(n(m,l,p));await R(e);let g=u.root===!0?u:{...u,root:!1},h=await M(p,g,d);await S(p,h),r.push({fromTool:Lt,fromPath:l,toPath:`${en}/${c}`,feature:"rules"});}}catch{}}var f_=f(()=>{A();v();Y();Ss();Ne();hs();Mt();p_();Gl();i(d_,"importCodexRules");i(Wx,"importInstructionMirrors");});async function Kl(t,e){let r=e?.scope??"project",n=[],o=await z(Lt,t,r),s=await z("windsurf",t,r);return await d_(t,n,o,s,r),await n_(t,n,o),await s_(t,n,o),await e_(t,n),n}var Zp=f(()=>{Ct();Mt();r_();o_();i_();f_();i(Kl,"importFromCodex");});function g_(t,e,r){let{rules:n}=t;return n.length===0?[]:n.some(s=>s.root)?[]:[{level:"warning",file:relative(e,n[0].source),target:Lt,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var h_=f(()=>{Mt();i(g_,"lintRules");});function y_(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(B(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" has a description, but codex-cli does not project MCP descriptions into .codex/config.toml.`)),"url"in n||"type"in n){let o="type"in n?n.type:"url";e.push(B(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var I_=f(()=>{$t();i(y_,"lintMcp");});function __(t){return da(t)}var S_=f(()=>{Gl();i(__,"codexAdvisoryInstructionPath");});var Hx,zx,Vx,Jx,O_,R_=f(()=>{t_();Mt();Zp();h_();I_();vt();ms();S_();er();Hx={name:"codex-cli",primaryRootInstructionPath:tn,generateRules:Wp,generateCommands:zp,generateAgents:Vp,generateSkills:Hp,generateMcp:Jp,importFrom:Kl},zx={rootInstructionPath:tn,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${_r}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return __(e)},commandPath(t,e){return cs(e,"codex-cli")?`${ze}/${Tt(t)}/SKILL.md`:null},agentPath(t,e){return `${$o}/${t}.toml`}}},Vx={rootInstructionPath:Fo,renderPrimaryRootInstruction:Bp,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${_r}/${e}.rules`]},skillDir:ze,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[Fo,".codex/config.toml"]},rewriteGeneratedPath(t){return t===tn?Fo:t.startsWith(`${vo}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${_r}/${t}.rules`:Fo},commandPath(t,e){return cs(e,"codex-cli")?`${ze}/${Tt(t)}/SKILL.md`:null},agentPath(t,e){return `${$o}/${t}.toml`}}},Jx={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},O_={id:"codex-cli",generators:Hx,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:g_,lint:{mcp:y_},project:zx,globalSupport:{capabilities:Jx,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:Vx},buildImportPaths:sp,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function Xx(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 k_(t){return `${ir}/${t}.md`}function E_(t){let e={description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],T(e,t.body.trim()||"")}function w_(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:Xx(t["x-agentsmesh-allowed-tools"])}}function L_(t,e){let r={description:t.description||void 0,"allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return r.description===void 0&&delete r.description,r["allowed-tools"]===void 0&&delete r["allowed-tools"],T(r,e.trim()||"")}var Wl=f(()=>{v();ar();i(Xx,"toStringArray");i(k_,"continueCommandRulePath");i(E_,"serializeCommandRule");i(w_,"parseCommandRuleFrontmatter");i(L_,"serializeImportedCommand");});function A_(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:jr,content:T(n,r.body.trim()||"")});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("continue"))continue;let o=basename(n.source,".md"),s={};n.description&&(s.description=n.description),n.globs.length>0&&(s.globs=n.globs),e.push({path:`${De}/${o}.md`,content:T(s,n.body.trim()||"")});}return e}function b_(t){return t.commands.map(e=>({path:`${ir}/${e.name}.md`,content:E_(e)}))}function P_(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:hl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function x_(t){return t.agents.map(e=>({path:`${Qt}/${Z(e.name)}/SKILL.md`,content:qe(e)}))}function T_(t){return Nt(t,Qt)}var N_=f(()=>{Et();ht();v();Wl();ar();i(A_,"generateRules");i(b_,"generateCommands");i(P_,"generateMcp");i(x_,"generateAgents");i(T_,"generateSkills");});function tT(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[s,a]of Object.entries(n)){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a;typeof l.command=="string"&&(o[s]={type:typeof l.type=="string"?l.type:"stdio",command:l.command,args:Is(l.args),env:_s(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function eT(t,e){let r=(await x(join(t,ip))).filter(s=>[".json",".yaml",".yml"].includes(extname(s))),n={},o=[];for(let s of r){let a=await I(s);a&&(Object.assign(n,tT(a,extname(s))),o.push(s));}if(Object.keys(n).length!==0){await pe(t,lp,n);for(let s of o)e.push({fromTool:Os,fromPath:s,toPath:lp,feature:"mcp"});}}async function Bl(t){let e=[],r=await z(Os,t);return e.push(...await et(Hl,t,"project",{normalize:r})),await kt(t,Qt,Os,e,r),await eT(t,e),e}var qp=f(()=>{Ct();A();Et();qt();io();Te();ar();Qp();i(tT,"readMcpServers");i(eT,"importMcp");i(Bl,"importFromContinue");});function rT(t){return t==="general.md"||t==="_root.md"}var F_,v_,$_=f(()=>{v();Y();Wl();ar();i(rT,"isContinueRootRulePath");F_=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=rT(t),o=n?"_root.md":t,s=join(r,o),{frontmatter:a,body:l}=E(e(s)),c={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return c.description===void 0&&delete c.description,c.globs===void 0&&delete c.globs,{destPath:s,toPath:`${yl}/${o}`,content:await M(s,c,l)}},"continueRuleMapper"),v_=i(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:s,body:a}=E(r(o)),l=w_(s,t),c=l.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${c}.md`:`${c}.md`,u=join(n,p),d=await q(u,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},E(L_(l,a)).body);return {destPath:u,toPath:`${Il}/${p}`,content:d}},"continueCommandMapper");});function M_(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Os}))}var G_=f(()=>{Vt();ar();i(M_,"lintRules");});function j_(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>B(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var U_=f(()=>{$t();i(j_,"lintCommands");});function iT(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var K_,W_=f(()=>{A();ar();i(iT,"computeStatus");K_=i(async(t,e,r,n)=>{if(r!=="global")return [];let o=n.has("rules"),s=n.has("commands"),a=n.has("mcp");if(!(o&&t.rules.length>0||s&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let c={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(c.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),s&&t.commands.length>0&&(c.prompts=t.commands.map(u=>{let d={name:u.name};return u.description&&(d.description=u.description),d.prompt=u.body.trim(),d})),a&&t.mcp!==null){let u=Object.entries(t.mcp.mcpServers);u.length>0&&(c.mcpServers=u.map(([d,g])=>({name:d,...g})));}let m=stringify(c),p=await I(join(e,Bi));return [{target:"continue",path:Bi,content:m,currentContent:p??void 0,status:iT(p,m)}]},"generateContinueGlobalConfig");});function lT(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var B_,H_=f(()=>{A();ar();W_();i(lT,"computeStatus");B_=i(async(t,e,r,n)=>{let o=await K_(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let s=t.rules.find(c=>c.root);if(!s)return o;let a=s.body.trim(),l=await I(join(e,Rs));return [...o,{target:"continue",path:Rs,content:a,currentContent:l??void 0,status:lT(l,a)}]},"generateContinueScopeExtras");});var cT,mT,pT,uT,Hl,Qp=f(()=>{ht();N_();ar();qp();$_();G_();U_();Wl();vt();H_();cT={name:"continue",primaryRootInstructionPath:jr,generateRules:A_,generateCommands:b_,generateAgents:x_,generateSkills:T_,generateMcp:P_,importFrom:Bl},mT={rootInstructionPath:jr,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${De}/${t}.md`},commandPath(t,e){return k_(t)},agentPath(t){return `${Qt}/${Z(t)}/SKILL.md`}}},pT={rootInstructionPath:jr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Rs]}],skillDir:Qt,managedOutputs:{dirs:[De,ir,Qt,".agents/skills"],files:[hl,Rs,Bi]},mirrorGlobalPath(t,e){return t.startsWith(`${Qt}/`)?`.agents/skills/${t.slice(Qt.length+1)}`:null},paths:{rulePath(t,e){return `${De}/${t}.md`},commandPath(t,e){return `${ir}/${t}.md`},agentPath(t){return `${Qt}/${Z(t)}/SKILL.md`}}},uT={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Hl={id:"continue",generators:cT,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:M_,lint:{commands:j_},project:mT,globalSupport:{capabilities:uT,detectionPaths:[De,ir,".continue/mcpServers",Qt],layout:pT,scopeExtras:B_},importer:{rules:{feature:"rules",mode:"directory",source:{project:[De],global:[De]},canonicalDir:yl,extensions:[".md"],map:F_},commands:{feature:"commands",mode:"directory",source:{project:[ir],global:[ir]},canonicalDir:Il,extensions:[".md"],map:v_}},buildImportPaths:cp,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var rn,Mo,z_,Go,Mn,Cr,Or,jo,Uo,zl,Vl,V_,eu,J_,Gn,Bs,nn,Hs,Ko,ru,nu,Ie=f(()=>{rn="copilot",Mo=".github/copilot-instructions.md",z_=".github/copilot",Go=".github/instructions",Mn=".github/prompts",Cr=".github/hooks",Or=".github/skills",jo=".github/agents",Uo=".agentsmesh/rules",zl=".agentsmesh/commands",Vl=".agentsmesh/agents",V_=".agentsmesh/skills",eu=".agentsmesh/hooks.yaml",J_=".github/copilot-hooks",Gn=".copilot/copilot-instructions.md",Bs=".copilot/agents",nn=".copilot/skills",Hs=".copilot/prompts",Ko=".copilot/AGENTS.md",ru=".claude/skills",nu=".agents/skills";});function Y_(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 Jl(t){return `${Mn}/${t}.prompt.md`}function X_(t){let e={agent:"agent",description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],T(e,t.body.trim()||"")}function Z_(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=Y_(t["x-agentsmesh-allowed-tools"]),s=o.length>0?o:Y_(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:s}}var Yl=f(()=>{v();Ie();i(Y_,"toStringArray");i(Jl,"commandPromptPath");i(X_,"serializeCommandPrompt");i(Z_,"parseCommandPromptFrontmatter");});function Xl(t){return Pr(t)}var ou=f(()=>{we();i(Xl,"hasHookCommand");});function gT(t){let e=basename(t,".md");return e==="_root"?"root":e}function hT(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function q_(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 s=n.description?`## ${n.description}`:null;s?e.push(`${s}
|
|
85
85
|
|
|
86
86
|
${o}`):e.push(o);}return e.join(`
|
|
87
87
|
|
|
88
|
-
`)}function
|
|
89
|
-
`)}async function
|
|
88
|
+
`)}function Q_(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:Mo,content:e.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("copilot")||n.globs.length===0)continue;let o=gT(n.source),s={description:n.description||void 0,applyTo:n.globs.length===1?n.globs[0]:n.globs};Object.keys(s).forEach(l=>{s[l]===void 0&&delete s[l];});let a=T(s,n.body.trim()||"");r.push({path:`${Go}/${o}.instructions.md`,content:a});}return r}function tS(t){return t.commands.map(e=>({path:Jl(e.name),content:X_(e)}))}function eS(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${Or}/${r.name}/SKILL.md`,content:o});for(let s of r.supportingFiles){let a=s.relativePath.replace(/\\/g,"/");e.push({path:`${Or}/${r.name}/${a}`,content:s.content});}}return e}function rS(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0,"mcp-servers":e.mcpServers.length>0?e.mcpServers:void 0,skills:e.skills.length>0?e.skills:void 0};Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${jo}/${e.name}.agent.md`,content:n}})}function nS(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=hT(r);if(!o||!Array.isArray(n))return [];let s=n.filter(a=>typeof a=="object"&&a!==null&&Xl(a)).map((a,l)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${l}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return s.length>0?[[o,s]]:[]}));return Object.keys(e).length===0?[]:[{path:`${Cr}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var oS=f(()=>{v();Ie();Yl();ou();i(gT,"ruleSlug");i(hT,"mapHookEvent");i(q_,"renderCopilotGlobalInstructions");i(Q_,"generateRules");i(tS,"generateCommands");i(eS,"generateSkills");i(rS,"generateAgents");i(nS,"generateHooks");});function IT(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function _T(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function aS(t){let e=t.match(/^# agentsmesh-command:\s*(.+)$/m);return e?.[1]?e[1].trim():t.replace(/^#!.*\n/,"").replace(/^#.*\n/gm,"").replace(/^HOOK_DIR=.*\n/gm,"").replace(/^set -e\n?/m,"").trim()}async function lS(t,e){let r=join(t,Cr),o=(await x(r).catch(()=>[])).filter(p=>p.endsWith(".json")),s={};for(let p of o){let u=await I(p);if(!u)continue;let d;try{d=JSON.parse(u);}catch{continue}if(!(!d||typeof d.hooks!="object"||d.hooks===null))for(let[g,h]of Object.entries(d.hooks)){let C=IT(g);if(!(!C||!Array.isArray(h)))for(let O of h){if(!O||typeof O!="object")continue;let _=O,k=typeof _.bash=="string"?_.bash:"";if(!k)continue;let D=join(r,k.replace(/^\.\//,"")),b=await I(D);if(!b)continue;let P=aS(b);P&&(s[C]||(s[C]=[]),s[C].push({matcher:_T(_.comment),command:P,type:"command"}));}}}let a=join(t,J_),c=(await x(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of c){let u=await I(p);if(!u)continue;let d=basename(p,".sh"),g=d.lastIndexOf("-"),h=g>0?d.slice(0,g):d;s[h]||(s[h]=[]),s[h].push({matcher:"*",command:aS(u),type:"command"});}if(Object.keys(s).length===0)return;let m=join(t,eu);await R(dirname(m)),await S(m,stringify(s)),e.push({fromTool:rn,fromPath:join(t,Cr),toPath:eu,feature:"hooks"});}var cS=f(()=>{A();Ie();i(IT,"mapCopilotHookEvent");i(_T,"extractMatcher");i(aS,"extractWrapperCommand");i(lS,"importHooks");});async function mS(t,e,r,n=Or){let o=join(t,n),s=await $n(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:V_,targetName:rn,normalize:r,results:e};for(let[l,c]of s)await Ir(l,c,a);}var pS=f(()=>{Us();Ie();i(mS,"importSkills");});async function Zl(t,e={}){let r=e.scope??"project",n=[],o=await z(rn,t,r);return n.push(...await et(ql,t,r,{normalize:o})),await mS(t,n,o,r==="global"?nn:Or),r==="project"&&await lS(t,n),n}var su=f(()=>{Ct();qt();Ie();cS();pS();iu();i(Zl,"importFromCopilot");});function uS(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var dS,fS,gS,hS,yS=f(()=>{v();Y();Te();Yl();Ie();i(uS,"pruneUndefined");dS=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:s,body:a}=E(e(o)),l=Fr(s.globs),c=uS({root:false,description:typeof s.description=="string"?s.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Uo}/${n}`,content:await M(o,c,a)}},"copilotLegacyRuleMapper"),fS=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.endsWith(".instructions.md")?t.replace(/\.instructions\.md$/i,".md"):t,o=join(r,n),{frontmatter:s,body:a}=E(e(o)),l=Fr(s.applyTo!==void 0?s.applyTo:s.globs),c=uS({root:false,description:typeof s.description=="string"?s.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${Uo}/${n}`,content:await M(o,c,a)}},"copilotNewRuleMapper"),gS=i(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=e.replace(/\.prompt\.md$/i,".md"),s=join(n,o),{frontmatter:a,body:l}=E(r(s)),c=Z_(a,t),m=o.includes("/")?o.slice(0,o.lastIndexOf("/")):"",p=`${c.name}.md`,u=m?`${m}/${p}`:p,d=join(n,u);return {destPath:d,toPath:`${zl}/${u}`,content:await q(d,{description:c.description,hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:c.allowedTools,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"tools")||Object.prototype.hasOwnProperty.call(a,"x-agentsmesh-allowed-tools")},l)}},"copilotCommandMapper"),hS=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(!t.endsWith(".agent.md"))return null;let n=t.replace(/\.agent\.md$/i,".md"),o=basename(n,".md"),s=join(r,n),{frontmatter:a,body:l}=E(e(s));return {destPath:s,toPath:`${Vl}/${n}`,content:await yt(s,{...a,name:typeof a.name=="string"?a.name:o},l)}},"copilotAgentMapper");});function IS(t,e,r,n){let s=Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(l=>({...l,target:rn})),a=t.rules.filter(l=>!l.root&&l.globs.length===0);return [...s,...a.map(l=>({level:"warning",file:l.source,target:rn,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var _S=f(()=>{Vt();Ie();i(IS,"lintRules");});function SS(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>B(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function CS(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification","UserPromptSubmit"],r=new Set(e),n=Object.keys(t.hooks).filter(s=>!r.has(s)).map(s=>Ks(s,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(s=>Array.isArray(s)&&s.length>0)&&n.push(B(".agentsmesh/hooks.yaml","copilot","copilot hooks are emitted as .github/hooks/scripts/*.sh wrapper scripts with a `#!/usr/bin/env bash` header; they require a POSIX shell (git-bash or WSL) to execute on Windows.")),n}var OS=f(()=>{$t();i(SS,"lintCommands");i(CS,"lintHooks");});function kT(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function ET(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function wT(t,e){let r=t.match(RS);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function LT(t,e){let n=e.match(RS)?.groups?.path;if(!n)return null;let o=join(t,n),s=await I(o);if(s===null)return null;let a=ET(t,o);return a?{assetPath:`${Cr}/scripts/${a}`,content:s,rewrittenCommand:wT(e,a)}:null}function AT(t,e){return `${Cr}/scripts/${kT(t)}-${e}.sh`}function bT(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${e}`,`# agentsmesh-command: ${t}`,"set -e",t,""].join(`
|
|
89
|
+
`)}async function kS(t,e,r){if(!e.hooks)return r;let n=[],o=new Map;for(let[s,a]of Object.entries(e.hooks)){if(!Array.isArray(a))continue;let l=0;for(let c of a){if(!Xl(c))continue;let m=AT(s,l),p=c.command,u=await LT(t,c.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let d=bT(p,c.matcher).replace(`set -e
|
|
90
90
|
`,`set -e
|
|
91
91
|
HOOK_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
|
|
92
|
-
`);n.push({path:m,content:d}),l++;}}return [...r,...n,...o.values()]}var
|
|
92
|
+
`);n.push({path:m,content:d}),l++;}}return [...r,...n,...o.values()]}var RS,ES=f(()=>{A();Ie();ou();RS=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;i(kT,"safePhaseName");i(ET,"toRepoRelative");i(wT,"rewriteWrapperCommand");i(LT,"buildAssetOutput");i(AT,"wrapperPath");i(bT,"buildWrapper");i(kS,"addHookScriptAssets");});function xT(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var wS,LS=f(()=>{A();Ie();i(xT,"computeStatus");wS=i(async(t,e,r,n)=>{if(r!=="global"||!n.has("rules"))return [];let o=t.rules.find(l=>l.root);if(!o)return [];let s=o.body.trim(),a=await I(join(e,Ko));return [{target:"copilot",path:Ko,content:s,currentContent:a??void 0,status:xT(a,s)}]},"generateCopilotGlobalExtras");});var NT,DT,FT,vT,ql,iu=f(()=>{oS();Ie();su();yS();_S();vt();Yl();OS();ES();LS();NT={name:"copilot",primaryRootInstructionPath:Mo,generateRules:Q_,generateCommands:tS,generateAgents:rS,generateSkills:eS,generateHooks:nS,importFrom:Zl},DT={rootInstructionPath:Mo,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 [`${Go}/${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 `${Go}/${t}.instructions.md`},commandPath(t,e){return Jl(t)},agentPath(t,e){return `${jo}/${t}.agent.md`}}},FT={rootInstructionPath:Gn,renderPrimaryRootInstruction:q_,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Ko]}],skillDir:nn,managedOutputs:{dirs:[Bs,nn,Hs,nu,ru],files:[Gn,Ko]},rewriteGeneratedPath(t){return t===Mo?Gn:t.startsWith(`${Go}/`)?Gn:t.startsWith(`${Mn}/`)?t.replace(`${Mn}/`,`${Hs}/`):t.startsWith(`${jo}/`)?t.replace(`${jo}/`,`${Bs}/`):t.startsWith(`${Or}/`)?t.replace(`${Or}/`,`${nn}/`):t.startsWith(`${Cr}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${nn}/`)&&!e.includes("codex-cli")){let r=t.slice(nn.length+1);return [`.agents/skills/${r}`,`${ru}/${r}`]}return null},paths:{rulePath(t,e){return Gn},commandPath(t,e){return `${Hs}/${t}.prompt.md`},agentPath(t,e){return `${Bs}/${t}.agent.md`}}},vT={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},ql={id:"copilot",generators:NT,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:IS,lint:{commands:SS,hooks:CS},postProcessHookOutputs:i(async(t,e,r)=>kS(t,e,[...r]),"postProcessHookOutputs"),project:DT,globalSupport:{capabilities:vT,detectionPaths:[Gn,Ko,Bs,nn,Hs,nu],layout:FT,scopeExtras:wS},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Mo],global:[Gn]},canonicalDir:Uo,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[z_]},canonicalDir:Uo,extensions:[".instructions.md"],map:dS},{feature:"rules",mode:"directory",source:{project:[Go]},canonicalDir:Uo,extensions:[".instructions.md",".md"],map:fS}],commands:{feature:"commands",mode:"directory",source:{project:[Mn],global:[Hs]},canonicalDir:zl,extensions:[".prompt.md"],map:gS},agents:{feature:"agents",mode:"directory",source:{project:[jo],global:[Bs]},canonicalDir:Vl,extensions:[".agent.md"],map:hS}},buildImportPaths:mp,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function au(t){let e=[],r=t.rules.find(s=>s.root);if(r){let s=r.body.trim()?r.body:"";e.push({path:In,content:s});let a={alwaysApply:true};r.description&&(a.description=r.description);let l=T(a,s);e.push({path:Ur,content:l});}let n=t.rules.filter(s=>!s.root&&(s.targets.length===0||s.targets.includes("cursor")));for(let s of n){let a=basename(s.source,".md"),c={alwaysApply:s.trigger==="always_on"};s.description&&(c.description=s.description),s.globs.length>0&&(c.globs=s.globs);let m=T(c,s.body.trim()||"");e.push({path:`${fe}/${a}.mdc`,content:m});}let o=AS(t);return o.trim()&&e.push({path:ve,content:o}),e}function AS(t){let e=t.rules.find(o=>o.root),r=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("cursor"))),n=[];return e?.body.trim()?n.push(Zt(e.body,r)):r.length>0&&n.push(Zt("",r)),n.filter(Boolean).join(`
|
|
93
93
|
|
|
94
|
-
`)}var
|
|
95
|
-
`);return [{path:
|
|
94
|
+
`)}var bS=f(()=>{v();Tr();dt();i(au,"generateRules");i(AS,"renderCursorGlobalUserRules");});function lu(t){return t.commands.map(e=>({path:`${ge}/${e.name}.md`,content:e.body.trim()||""}))}var PS=f(()=>{dt();i(lu,"generateCommands");});function cu(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:cr,content:e}]}var xS=f(()=>{dt();i(cu,"generateMcp");});function mu(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${lr}/${r.name}/SKILL.md`,content:o});for(let s of r.supportingFiles){let a=s.relativePath.replace(/\\/g,"/");e.push({path:`${lr}/${r.name}/${a}`,content:s.content});}}return e}var TS=f(()=>{v();dt();i(mu,"generateSkills");});function pu(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,permissionMode:e.permissionMode||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,mcpServers:e.mcpServers.length>0?e.mcpServers:void 0,hooks:Object.keys(e.hooks).length>0?e.hooks:void 0,skills:e.skills.length>0?e.skills:void 0,memory:e.memory||void 0};Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${ks}/${e.name}.md`,content:n}})}var NS=f(()=>{v();dt();i(pu,"generateAgents");});function uu(t){return []}var DS=f(()=>{i(uu,"generatePermissions");});function MT(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let s of n){if(!Ze(s))continue;let a=gt(s),l=Gt(s),c=s.type==="prompt"?l||a:a||l,m={type:s.type==="prompt"?"prompt":"command",[s.type==="prompt"?"prompt":"command"]:c};s.timeout!==void 0&&(m.timeout=s.timeout),o.push({matcher:s.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}function du(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=MT(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:mr,content:r}]}var FS=f(()=>{we();dt();i(MT,"toCursorHooks");i(du,"generateHooks");});function fu(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
95
|
+
`);return [{path:Fe,content:e}]}var vS=f(()=>{dt();i(fu,"generateIgnore");});var $S=f(()=>{bS();PS();xS();TS();NS();DS();FS();vS();});var MS=f(()=>{$S();});async function tc(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),s=join(e,o),l=E(r(s)).frontmatter.alwaysApply===true,c=l?join(e,"_root.md"):s,{frontmatter:m,body:p}=E(r(c));l&&n();let u={...m,root:l};if(delete u.alwaysApply,!l){let d=GT(m);d!==null&&(u.trigger=d);}return {destPath:c,toPath:`${pr}/${l?"_root.md":o}`,feature:"rules",content:await M(c,u,p)}}function GT(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 GS(t,e,r){let n=join(e,t),{frontmatter:o,body:s}=E(r(n)),a=ue(o.allowedTools),l=a.length>0?a:ue(o["allowed-tools"]);return {destPath:n,toPath:`${Cn}/${t}`,feature:"commands",content:await q(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},s)}}async function jS(t,e,r){let n=join(e,t),{frontmatter:o,body:s}=E(r(n));return {destPath:n,toPath:`${On}/${t}`,feature:"agents",content:await yt(n,o,s)}}var gu=f(()=>{v();Y();Te();dt();i(tc,"mapCursorRuleFile");i(GT,"deriveCursorTrigger");i(GS,"mapCursorCommandFile");i(jS,"mapCursorAgentFile");});async function zs(t){let e=join(t.projectRoot,pr);await R(e);let r=join(e,"_root.md"),n=await or({content:t.content,projectRoot:t.projectRoot,rulesDir:pr,sourcePath:t.sourcePath,fromTool:"cursor",normalize:t.normalize});t.results.push(...n.results);let o=t.normalize(n.rootContent,t.sourcePath,r);if(!o.trim()&&n.results.length>0)return true;let{frontmatter:s,body:a}=E(o),l=s.root===true?s:{...s,root:true},c=await M(r,l,a);return await S(r,c),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${pr}/_root.md`,feature:"rules"}),true}var hu=f(()=>{A();v();Ss();Y();dt();i(zs,"importCursorRootFile");});async function KS(t,e,r){let n=join(t,pr),o=false,s=join(t,fe);if(e.push(...await tt({srcDir:s,destDir:n,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:i(async({srcPath:a,relativePath:l,normalizeTo:c})=>{if(o){let m=await I(a);if(m!==null){let{frontmatter:p}=E(m);if(p.alwaysApply===true)return null}}return tc(l,n,c,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,In),l=await I(a);l!==null&&(o=await zs({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r}));}if(!o){let a=join(t,ry),l=await I(a);l!==null&&await zs({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r});}}var WS=f(()=>{A();v();Ne();gu();hu();dt();i(KS,"importCursorRules");});function BS(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let s of n){if(!s||typeof s!="object")continue;let a=s,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!Ze({...m,type:p}))continue;let u=p==="prompt"?Gt(m)||gt(m):gt(m)||Gt(m),d={matcher:l,type:p,command:u};typeof m.timeout=="number"&&(d.timeout=m.timeout),o.push(d);}}o.length>0&&(e[r]=o);}return e}async function nc(t,e){let r=false,n=join(t,mr),o=await I(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=BS(p.hooks);if(Object.keys(u).length>0){let d=stringify(u),g=join(t,zi);await R(dirname(g)),await S(g,d),e.push({fromTool:"cursor",fromPath:n,toPath:zi,feature:"hooks"}),r=!0;}}}catch{}let s=join(t,Sl),a=await I(s);if(!a)return;let l;try{l=JSON.parse(a);}catch{return}let c=l.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let p=c,u=Array.isArray(p.allow)?p.allow.filter(g=>typeof g=="string"):[],d=Array.isArray(p.deny)?p.deny.filter(g=>typeof g=="string"):[];if(u.length>0||d.length>0){let g=stringify({allow:u,deny:d}),h=join(t,up);await R(dirname(h)),await S(h,g),e.push({fromTool:"cursor",fromPath:s,toPath:up,feature:"permissions"});}}let m=r?void 0:l.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=BS(m);if(Object.keys(p).length>0){let u=stringify(p),d=join(t,zi);await R(dirname(d)),await S(d,u),e.push({fromTool:"cursor",fromPath:s,toPath:zi,feature:"hooks"});}}}async function oc(t,e){let r=[{path:join(t,Fe),label:Fe},{path:join(t,pp),label:pp}],n=[],o=[];for(let a of r){let l=await I(a.path);if(l!==null){o.push(a.label);for(let c of l.split(/\r?\n/)){let m=c.trim();m&&!n.includes(m)&&n.push(m);}}}if(n.length===0)return;let s=join(t,dp);await R(dirname(s)),await S(s,n.join(`
|
|
96
96
|
`)+`
|
|
97
|
-
`),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:
|
|
97
|
+
`),e.push({fromTool:"cursor",fromPath:join(t,o[0]),toPath:dp,feature:"ignore"});}var Iu=f(()=>{we();A();dt();i(BS,"cursorHooksToCanonical");i(nc,"importSettings");i(oc,"importIgnore");});async function sc(t,e,r,n=lr){let o=join(t,n),s=await $n(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:ny,targetName:"cursor",normalize:r,results:e};for(let[p,u]of s)await Ir(p,u,a);let l=await x(o).catch(()=>[]),c=l.filter(p=>p.endsWith(".md")),m=new Set(Array.from(s.values()).flatMap(p=>l.filter(u=>u.startsWith(p))));for(let p of c){if(m.has(p))continue;let u=await I(p);if(!u)continue;let d=basename(p,".md");await kI(d,p,u,a);}}var _u=f(()=>{A();Us();dt();i(sc,"importSkills");});async function HS(t){if(await F(join(t,fe)))return true;let e=[join(t,ve),join(t,Es),join(t,Hi),join(t,mr),join(t,Fe),join(t,_n),join(t,Sn),join(t,ge)];for(let s of e){let a=await I(s);if(a!==null&&a.trim()!=="")return true}return !!((await x(join(t,_n))).some(s=>s.endsWith(".md"))||(await x(join(t,Sn))).some(s=>s.endsWith(".md"))||(await x(join(t,ge))).some(s=>s.endsWith(".md")))}async function zS(t,e,r){let n=join(t,pr),o=false,s=join(t,fe),a=await tt({srcDir:s,destDir:n,extensions:[".mdc"],fromTool:Vs,normalize:r,mapEntry:i(async({srcPath:l,relativePath:c,normalizeTo:m})=>{if(o){let p=await I(l);if(p!==null){let{frontmatter:u}=E(p);if(u.alwaysApply===true)return null}}return tc(c,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function VS(t,e,r){let n=join(t,Es),o=await I(n);return o===null||o.trim()===""?false:zs({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function JS(t,e,r){let n=join(t,ve),o=await I(n);return o===null||o.trim()===""?false:zs({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function YS(t,e){let r=join(t,Hi),n=await I(r);if(n===null||n.trim()==="")return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let s=join(t,ws);await R(dirname(s)),await S(s,n),e.push({fromTool:Vs,fromPath:r,toPath:ws,feature:"mcp"});}async function XS(t,e,r){let n=join(t,Sn),o=join(t,On);e.push(...await tt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Vs,normalize:r,mapEntry:i(({relativePath:s,normalizeTo:a})=>jS(s,o,a),"mapEntry")}));}async function ZS(t,e,r){let n=join(t,ge),o=join(t,Cn);e.push(...await tt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Vs,normalize:r,mapEntry:i(({relativePath:s,normalizeTo:a})=>GS(s,o,a),"mapEntry")}));}var Vs,qS=f(()=>{A();v();Ne();dt();hu();gu();Vs="cursor";i(HS,"hasGlobalCursorArtifacts");i(zS,"importGlobalCursorRulesFromDir");i(VS,"importGlobalUserRules");i(JS,"importGlobalDotCursorAgents");i(YS,"importGlobalMcp");i(XS,"importGlobalAgents");i(ZS,"importGlobalCommands");});async function QS(t){if(!await HS(t))return [];let e=[],r=await z(Vs,t,"global"),n=await zS(t,e,r);return n||(n=await VS(t,e,r)),n||await JS(t,e,r),await YS(t,e),await sc(t,e,r,_n),await XS(t,e,r),await ZS(t,e,r),await nc(t,e),await oc(t,e),e}var tC=f(()=>{Ct();dt();_u();Iu();qS();i(QS,"importFromCursorGlobalExports");});async function BT(t,e){let r=join(t,cr),n=await I(r);if(!n)return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let s=o.mcpServers;await pe(t,ws,s),e.push({fromTool:"cursor",fromPath:r,toPath:ws,feature:"mcp"});}async function ic(t,e={}){if(e.scope==="global")return QS(t);let r=[],n=await z("cursor",t);return await KS(t,r,n),r.push(...await et(ac,t,"project",{normalize:n})),await sc(t,r,n),await BT(t,r),await nc(t,r),await oc(t,r),r}var Su=f(()=>{Ct();A();qt();io();WS();Iu();_u();tC();dt();Cu();i(BT,"importMcp");i(ic,"importFromCursor");});var rC,nC,oC=f(()=>{v();Y();Te();dt();rC=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n)),a=ue(o.allowedTools),l=a.length>0?a:ue(o["allowed-tools"]);return {destPath:n,toPath:`${Cn}/${t}`,content:await q(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},s)}},"cursorCommandMapper"),nC=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${On}/${t}`,content:await yt(n,o,s)}},"cursorAgentMapper");});function sC(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(s=>({...s,target:ey}))}var iC=f(()=>{Vt();dt();i(sC,"lintRules");});function aC(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>B(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function lC(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers)){let o=n.env&&Object.keys(n.env).length>0,s="url"in n,a="headers"in n;(o||s||a)&&e.push(B(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function cC(t){if(!t.permissions)return [];let e=t.permissions.ask?.length??0;return t.permissions.allow.length>0||t.permissions.deny.length>0||e>0?[B(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var mC=f(()=>{$t();i(aC,"lintCommands");i(lC,"lintMcp");i(cC,"lintPermissions");});var HT,zT,VT,JT,ac,Cu=f(()=>{MS();dt();He();Su();oC();iC();vt();mC();HT={name:"cursor",primaryRootInstructionPath:Ur,generateRules:au,generateCommands:lu,generateAgents:pu,generateSkills:mu,generateMcp:cu,generatePermissions:uu,generateHooks:du,generateIgnore:fu,importFrom:ic},zT={rootInstructionPath:Ur,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[In,ve]}],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`}}},VT={rootInstructionPath:Ur,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[In,ve]}],skillDir:_n,managedOutputs:{dirs:[fe,ge,Sn,_n],files:[Ur,ve,Hi,mr,Fe,Es]},rewriteGeneratedPath(t){return t===In?null:t===ve||t===Ur||t.startsWith(`${fe}/`)||t.startsWith(`${ge}/`)||t.startsWith(`${ks}/`)||t.startsWith(`${lr}/`)||t===cr||t===mr||t===Fe?t:t===Sl?null:t},mirrorGlobalPath(t,e){return mt(t,lr,e)},paths:{rulePath(t,e){return `${fe}/${t}.mdc`},commandPath(t,e){return `${ge}/${t}.md`},agentPath(t,e){return `${Sn}/${t}.md`}}},JT={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},ac={id:"cursor",generators:HT,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:sC,lint:{commands:aC,mcp:lC,permissions:cC},project:zT,globalSupport:{capabilities:JT,detectionPaths:[Ur,ve,cr,mr,Fe,lr,Sn,ge,Es],layout:VT},importer:{commands:{feature:"commands",mode:"directory",source:{project:[ge]},canonicalDir:Cn,extensions:[".md"],map:rC},agents:{feature:"agents",mode:"directory",source:{project:[ks]},canonicalDir:On,extensions:[".md"],map:nC}},buildImportPaths:fp,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});var jn,_e,Rr,pC,uC,ee,lc,Wo,cc,ha,Un,dC,fC,Kn,mc,ya,Ia,Ou,Ru,Js,ku,Ys,Xs,pc,Zs,Bo,_a,It=f(()=>{jn="gemini-cli",_e="GEMINI.md",Rr="AGENTS.md",pC=".gemini/rules",uC=".gemini/GEMINI.md",ee=".gemini/commands",lc=".gemini/policies",Wo=".gemini/settings.json",cc=".geminiignore",ha=".gemini/skills",Un=".gemini/agents",dC=".gemini/system.md",fC=`${lc}/permissions.toml`,Kn=".agentsmesh/rules",mc=".agentsmesh/commands",ya=".agentsmesh/agents",Ia=".agentsmesh/skills",Ou=".agentsmesh/mcp.json",Ru=".agentsmesh/hooks.yaml",Js=".agentsmesh/ignore",ku=".agentsmesh/permissions.yaml",Ys=".gemini/GEMINI.md",Xs=".gemini/AGENTS.md",pc=".gemini/settings.json",Zs=".gemini/commands",Bo=".gemini/skills",_a=".gemini/agents";});function Eu(t){let e=t.rules.find(s=>s.root),r=t.rules.filter(s=>!(s.root||s.targets.length>0&&!s.targets.includes("gemini-cli")));if(!e&&r.length===0)return [];let n=Zt(e?.body.trim()??"",r),o=[{path:_e,content:n}];if(e){let s=e.body.trim().replace(/\.agentsmesh\/skills\//g,".agents/skills/");o.push({path:Rr,content:s});}return o}var gC=f(()=>{Tr();It();i(Eu,"generateRules");});function hC(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var yC=f(()=>{i(hC,"canonicalCommandNameToGeminiTomlPath");});function YT(t){let e=t.replace(/\r\n/g,`
|
|
98
98
|
`);return e.includes('"""')?JSON.stringify(e):`"""
|
|
99
99
|
${e}
|
|
100
|
-
"""`}function
|
|
100
|
+
"""`}function XT(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${YT(t.body.trim()||"")}`].join(`
|
|
101
101
|
`)+`
|
|
102
|
-
`}function
|
|
103
|
-
`)}]}var
|
|
104
|
-
`)}function
|
|
105
|
-
`)}]}var
|
|
102
|
+
`}function wu(t){return t.commands.map(e=>({path:hC(e.name,ee),content:XT(e)}))}var IC=f(()=>{It();yC();i(YT,"serializeTomlMultilineLiteral");i(XT,"serializeGeminiCommand");i(wu,"generateCommands");});function Lu(t){return t.agents.map(e=>{let r={name:e.name,kind:"local",description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0,maxTurns:e.maxTurns>0?e.maxTurns:void 0,permissionMode:e.permissionMode||void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0};Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${Un}/${e.name}.md`,content:n}})}var _C=f(()=>{v();It();i(Lu,"generateAgents");});function Au(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=T(n,r.body.trim()||"");e.push({path:`${ha}/${r.name}/SKILL.md`,content:o});for(let s of r.supportingFiles){let a=s.relativePath.replace(/\\/g,"/");e.push({path:`${ha}/${r.name}/${a}`,content:s.content});}}return e}var SC=f(()=>{v();It();i(Au,"generateSkills");});function ZT(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function bu(t){let e={},r=false;if(t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&(e.mcpServers=t.mcp.mcpServers,r=true),t.agents.length>0&&(e.experimental={enableAgents:true},r=true),t.hooks){let n=Object.entries(t.hooks).flatMap(([o,s])=>{let a=ZT(o);if(!a||!Array.isArray(s))return [];let l=s.filter(c=>typeof c=="object"&&c!==null&&Pr(c)).map((c,m)=>({matcher:c.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:gt(c),timeout:c.timeout}]}));return l.length>0?[[a,l]]:[]});n.length>0&&(e.hooks=Object.fromEntries(n),r=true);}return r&&(e.context={fileName:[_e,Rr]}),Object.keys(e).length===0?[]:[{path:Wo,content:JSON.stringify(e,null,2)}]}var Pu=f(()=>{we();It();i(ZT,"mapHookEvent");i(bu,"generateGeminiSettingsFiles");});function xu(t){return !t.ignore||t.ignore.length===0?[]:[{path:cc,content:t.ignore.join(`
|
|
103
|
+
`)}]}var CC=f(()=>{It();i(xu,"generateIgnore");});var OC=f(()=>{gC();IC();_C();SC();Pu();CC();});var RC=f(()=>{OC();});function Ho(t){return JSON.stringify(t)}function qT(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function QT(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 uc(t,e,r){return ["[[rule]]",`decision = ${Ho(t)}`,`priority = ${e}`,...r,""].join(`
|
|
104
|
+
`)}function kC(t,e,r){let n=QT(t),o={Read:"read_file",Grep:"grep_search",LS:"list_directory",WebFetch:"web_fetch",Bash:"run_shell_command"};if(n.kind==="tool"){let s=o[n.tool]??n.tool;return uc(e,r,[`toolName = ${Ho(s)}`])}if(n.kind==="bash"){let s=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return uc(e,r,[`toolName = ${Ho(o.Bash)}`,`commandPrefix = ${Ho(s)}`])}return n.kind==="read"?uc(e,r,[`toolName = ${Ho(o.Read)}`,`argsPattern = ${Ho(qT(n.path))}`]):uc(e,r,[`toolName = ${Ho(n.raw)}`])}function EC(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions;if(e.length+r.length===0)return [];let o=[];return e.forEach((s,a)=>{let l=kC(s,"allow",100+a);l&&o.push(l);}),r.forEach((s,a)=>{let l=kC(s,"deny",200+a);l&&o.push(l);}),o.length===0?[]:[{path:fC,content:o.join(`
|
|
105
|
+
`)}]}var wC=f(()=>{It();i(Ho,"escapeTomlBasicString");i(qT,"escapeRegexLiteral");i(QT,"parsePermissionExpr");i(uc,"ruleForDecision");i(kC,"permissionExprToGeminiRule");i(EC,"generateGeminiPermissionsPolicies");});function Tu(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 dc(t){let e=t.indexOf("---"),r=t.indexOf("+++");if(e===0&&(r===-1||e<=r))return E(t);if(r===0){let n=t.indexOf("+++",3);if(n!==-1)try{let o=t.slice(3,n).trim(),s=t.slice(n+3).trim();return {frontmatter:o===""?{}:parse$1(o)??{},body:s}}catch{return {frontmatter:{},body:t.trim()}}}return {frontmatter:{},body:t.trim()}}var Nu=f(()=>{v();i(Tu,"mapGeminiHookEvent");i(dc,"parseFlexibleFrontmatter");});async function Du(t,e){let r=join(t,Wo),n=await I(r);if(n===null)return;let o;try{o=JSON.parse(n);}catch{}if(!o)return;let s=o.mcpServers;if(s!==void 0&&typeof s=="object"&&s!==null&&Object.keys(s).length>0){let c=join(t,Ou);await R(join(t,".agentsmesh")),await S(c,JSON.stringify({mcpServers:s},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Ou,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(c=>typeof c=="string")){let c=join(t,Js);await R(join(t,".agentsmesh")),await S(c,a.join(`
|
|
106
106
|
`)+`
|
|
107
|
-
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:
|
|
107
|
+
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Js,feature:"ignore"});}let l=o.hooks;if(l!==void 0&&typeof l=="object"&&l!==null){let c=Object.entries(l).flatMap(([m,p])=>{let u=Tu(m);if(!u||!Array.isArray(p))return [];let d=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"&&Pr(h)).map(h=>({matcher:g.matcher,command:gt(h),type:"command",timeout:typeof h.timeout=="number"?h.timeout:void 0})));if(d.length===0){let g=p.filter(h=>h!==null&&typeof h=="object"&&typeof h.matcher=="string"&&Pr(h)).map(h=>({matcher:h.matcher,command:gt(h),type:"command"}));return g.length>0?[[u,g]]:[]}return d.length>0?[[u,d]]:[]});if(c.length>0){let m=Object.fromEntries(c),p=join(t,Ru);await R(join(t,".agentsmesh")),await S(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Ru,feature:"hooks"});}}}var LC=f(()=>{we();A();It();Nu();i(Du,"importGeminiSettings");});async function AC(t,e){let r=join(t,cc),n=await I(r);if(n!==null&&n.trim()){let o=n.split(/\r?\n/).map(s=>s.trim()).filter(s=>s&&!s.startsWith("#"));if(o.length>0){await R(join(t,".agentsmesh"));let s=join(t,Js);await S(s,o.join(`
|
|
108
108
|
`)+`
|
|
109
|
-
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:
|
|
110
|
-
`),e.push({fromTool:ln,fromPath:join(t,nl),toPath:pu,feature:"permissions"}),e}var qS=f(()=>{E();pt();i(CA,"unescapeRegexLiteral");i(kA,"toolNameToPermissionBase");i(wA,"commandPrefixToBashExpr");i(OA,"argsPatternToReadExpr");i(ZS,"importGeminiPolicies");});function Ou(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,s)=>{let a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return o.replace(new RegExp(`${a}[/\\\\]\\.agentsmesh[/\\\\]`,"g"),".agentsmesh/").replaceAll(`${s}/.agentsmesh`,".agentsmesh").replaceAll(`${s}\\.agentsmesh`,".agentsmesh")},t).replace(/(?:[A-Za-z]:)?[^\s"'`()<>]+[/\\]\.agentsmesh[/\\]/g,".agentsmesh/")}var t_=f(()=>{i(Ou,"stripProjectRootCanonicalPrefix");});async function r_(t,e,r){let n=join(t,Ii),s=(await P(n)).filter(l=>basename(l)==="SKILL.md");for(let l of s){let c=await I(l);if(!c)continue;let m=basename(l.slice(0,-9)),u=O(c),p=jr(u.frontmatter,m);if(p){let w=join(t,Si);await k(w);let D=join(w,`${p.name}.md`);await _(D,je(p,r(u.body,l,D))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Si}/${p.name}.md`,feature:"agents"});continue}let d=join(t,_i,m,"SKILL.md"),g=r(c,l,d),h=join(t,_i,m);await k(h);let{frontmatter:R,body:C}=O(g);await _(d,await Le(d,{...R,name:m},C)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${_i}/${m}/SKILL.md`,feature:"skills"});let S=await P(dirname(l));for(let w of S){if(w===l)continue;let D=await I(w);if(D===null)continue;let b=relative(dirname(l),w).replace(/\\/g,"/"),x=join(h,b);await k(dirname(x)),await _(x,r(D,w,x)),e.push({fromTool:"gemini-cli",fromPath:w,toPath:`${_i}/${m}/${b}`,feature:"skills"});}}let a=join(t,cn);try{let c=(await P(a)).filter(m=>m.endsWith(".md"));for(let m of c){let u=await I(m);if(!u)continue;let{frontmatter:p,body:d}=O(u),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),R=join(t,Si);await k(R);let C=join(R,h),S=r(d,m,C);await _(C,await $t(C,{...p,name:typeof p.name=="string"?p.name:basename(h,".md"),maxTurns:p.maxTurns??p["max-turns"]??p.max_turns,permissionMode:p.permissionMode??p["permission-mode"]??p.permission_mode,disallowedTools:p.disallowedTools??p["disallowed-tools"]??p.disallowed_tools},S)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${Si}/${h}`,feature:"agents"});}}catch{}}var n_=f(()=>{E();F();Y();Xt();pt();i(r_,"importGeminiSkillsAndAgents");});async function EA(t,e,r){let n=await H("codex-cli",t),o=join(t,mn),s=join(t,rr),a=join(t,DS),l=[s,a,join(t,re),join(t,FS)],c=null,m=l[l.length-1];for(let b of l){let x=await I(b);if(x!==null){c=x,m=b;break}}if(c===null)return;await k(o);let u=join(o,"_root.md"),p=m===s||m===a?n(c,m,u):c,d=await Ge({content:p,projectRoot:t,rulesDir:mn,sourcePath:m,fromTool:ln,normalize:r});e.push(...d.results);let g=r(d.rootContent,m,u),h=Ou(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:R,body:C}=O(h),w=R.root===true?R:{...R,root:true},D=Ou(await $(u,w,C),t);await _(u,D),e.push({fromTool:ln,fromPath:m,toPath:`${mn}/_root.md`,feature:"rules"});}async function ml(t){let e=[],r=await H(ln,t);return await EA(t,e,r),e.push(...await gt(ul,t,"project",{normalize:r})),await r_(t,e,r),await Cu(t,e),await XS(t,e),e.push(...await ZS(t)),e}var xu=f(()=>{bt();E();F();Y();wo();Me();pt();Pu();wu();qS();t_();n_();i(EA,"importRootRule");i(ml,"importFromGemini");});async function s_(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:s,body:a}=ll(r(o)),l=dr(s.globs),c={root:false,description:typeof s.description=="string"?s.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${mn}/${n}`,feature:"rules",content:await $(o,c,a)}}async function i_(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),s=r(o),{frontmatter:a,body:l}=t.endsWith(".toml")?xA(s):ll(s),c=Yt(a.allowedTools),m=Yt(a["allowed-tools"]),u=c.length>0?c:m;return {destPath:o,toPath:`${sl}/${n}`,feature:"commands",content:await Q(o,{description:typeof a.description=="string"?a.description:"",hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:u,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"allowedTools")||Object.prototype.hasOwnProperty.call(a,"allowed-tools")},l)}}function xA(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var a_=f(()=>{Y();he();wu();pt();i(s_,"mapGeminiRuleFile");i(i_,"mapGeminiCommandFile");i(xA,"parseTomlCommand");});var l_,c_,m_=f(()=>{a_();l_=i(({relativePath:t,destDir:e,normalizeTo:r})=>s_(t,e,r),"geminiRuleMapper"),c_=i(({relativePath:t,destDir:e,normalizeTo:r})=>i_(t,e,r),"geminiCommandMapper");});function u_(t,e,r,n){return lt(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(s=>({...s,target:ln}))}var p_=f(()=>{ye();pt();i(u_,"lintRules");});function d_(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>V(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function f_(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=>Wo(n,"gemini-cli",e))}var g_=f(()=>{Wt();i(d_,"lintCommands");i(f_,"lintHooks");});function h_(t,e){return e==="project"&&un("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:yu(t)}var y_=f(()=>{rt();Iu();i(h_,"emitScopedGeminiSettings");});function S_(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function __(t,e){let r=S_(t),n=PA.parse(JSON.parse(e)),o={...r};n.permissions!==void 0&&(o.permissions=n.permissions),n.hooks!==void 0&&(o.hooks=n.hooks);let s=o.permissions;return s&&typeof s=="object"&&!Array.isArray(s)&&!("ask"in s)&&(s.ask=[]),JSON.stringify(o,null,2)}function R_(t,e){let r=S_(t),n=AA.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 I_,PA,AA,Au=f(()=>{I_=[".claude/settings.json",".gemini/settings.json"],PA=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(),AA=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();i(S_,"parseJsonObject");i(__,"mergeSettingsJson");i(R_,"mergeGeminiSettingsJson");});var TA,LA,NA,DA,ul,Pu=f(()=>{HS();Cn();JS();pt();xu();m_();p_();Ut();yo();Xt();g_();y_();nn();Au();TA={name:"gemini-cli",primaryRootInstructionPath:re,generateRules:du,generateCommands:fu,generateAgents:gu,generateSkills:hu,generateIgnore:Su,generatePermissions:VS,importFrom:ml},LA={rootInstructionPath:re,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[rr]}],extraRuleOutputPaths(){return [rr]},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 xt(t,".gemini/skills",e)},paths:{rulePath(t,e){return re},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${Bt}/${r.join("/")}/${n}.toml`}return `${Bt}/${t}.toml`},agentPath(t,e){return me(e,"gemini-cli")?`.gemini/skills/${Lt(t)}/SKILL.md`:`${cn}/${t}.md`}}},NA={rootInstructionPath:Yo,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Xo]}],extraRuleOutputPaths(){return [Xo]},skillDir:Zn,managedOutputs:{dirs:[Zo,Zn,Ri],files:[Yo,Xo,il]},rewriteGeneratedPath(t){return t===re?Yo:t===rr?Xo:t===Xn?il:t.startsWith(`${Bt}/`)?t.replace(`${Bt}/`,`${Zo}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Zn}/`):t.startsWith(`${cn}/`)?t.replace(`${cn}/`,`${Ri}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return xt(t,Zn,e)},paths:{rulePath(t,e){return Yo},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${Zo}/${r.join("/")}/${n}.toml`}return `${Zo}/${t}.toml`},agentPath(t,e){return me(e,"gemini-cli")?`${Zn}/${Lt(t)}/SKILL.md`:`${Ri}/${t}.md`}}},DA={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},ul={id:"gemini-cli",generators:TA,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:pe("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:u_,lint:{commands:d_,hooks:f_},emitScopedSettings:h_,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Xn?R_(o,r):null},project:LA,globalSupport:{capabilities:DA,detectionPaths:[Yo,Xo,il,Zo,Zn,Ri],layout:NA},importer:{rules:{feature:"rules",mode:"directory",source:{project:[NS]},canonicalDir:mn,extensions:[".md"],map:l_},commands:{feature:"commands",mode:"directory",source:{project:[Bt]},canonicalDir:sl,extensions:[".md",".toml"],map:c_}},buildImportPaths:im,detectionPaths:["GEMINI.md",".gemini"]};});function C_(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Ye,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("junie"))continue;let o=basename(n.source,".md");e.push({path:`${qs}/${o}.md`,content:n.body.trim()||""});}return e}function vA(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),Da(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 k_(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).map(([r,n])=>[r,vA(n)]));return [{path:Zs,content:JSON.stringify({mcpServers:e},null,2)}]}function w_(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${Do}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function O_(t){return t.agents.map(e=>{let r={name:e.name,description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,skills:e.skills.length>0?e.skills:void 0};return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];}),{path:`${Fo}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function E_(t){return t.ignore.length===0?[]:[{path:Qs,content:t.ignore.join(`
|
|
111
|
-
`)}]}
|
|
112
|
-
`)}]}var
|
|
113
|
-
`)}]}function
|
|
114
|
-
|
|
115
|
-
`)),n.push({fromTool:"windsurf",fromPath:u,toPath:Bu,feature:"ignore"});}}return await wR(t,n,o),await ER(t,n,o),await PR(t,n),await AR(t,n),n}var tp=f(()=>{bt();E();F();Y();$e();gi();Pt();OR();bR();TR();i(Cl,"importFromWindsurf");});function LR(t,e,r){let n=[],{rules:o}=t;o.length>0&&(o.some(l=>l.root)||n.push({level:"warning",file:relative(e,o[0].source),target:nr,message:"Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."}));let s=[];return t.permissions&&(t.permissions.allow.length>0||t.permissions.deny.length>0)&&s.push("permissions"),s.length>0&&n.push({level:"warning",file:".agentsmesh",target:nr,message:`Windsurf cannot project these features yet: ${s.join(", ")}.`}),n}var NR=f(()=>{Pt();i(LR,"lintRules");});function DR(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>V(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function FR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[V(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var vR=f(()=>{Wt();i(DR,"lintCommands");i(FR,"lintMcp");});function PT(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 AT,TT,LT,NT,$R,MR=f(()=>{CR();Cn();Pt();nn();tp();NR();vR();Ut();yo();Xt();i(PT,"directoryScopedRuleDir");AT={name:"windsurf",primaryRootInstructionPath:or,generateRules:zu,generateCommands:Ju,generateAgents:Yu,generateSkills:qu,generateMcp:Xu,generateHooks:Zu,generateIgnore:Vu,importFrom:Cl},TT={rootInstructionPath:or,extraRuleOutputPaths(t){if(t.root)return [or];let e=PT(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:xe,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 `${pn}/${t}.md`},commandPath(t,e){return `${dn}/${t}.md`},agentPath(t,e){return me(e,"windsurf")?`.windsurf/skills/${Lt(t)}/SKILL.md`:null}}},LT={rootInstructionPath:ns,skillDir:os,managedOutputs:{dirs:[os,Ci,dR],files:[ns,Il,Sl,_l]},rewriteGeneratedPath(t){return t===or?ns:t.startsWith(`${pn}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${xe}/`)?t.replace(`${xe}/`,`${os}/`):t.startsWith(`${dn}/`)?t.replace(`${dn}/`,`${Ci}/`):t===ts?Il:t===es?Sl:t===Qo?_l:t},mirrorGlobalPath(t,e){return xt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return ns},commandPath(t,e){return `${Ci}/${t}.md`},agentPath(t,e){return me(e,"windsurf")?`${os}/${Lt(t)}/SKILL.md`:null}}},NT={rules:"native",additionalRules:"partial",commands:pe("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},$R={id:"windsurf",generators:AT,capabilities:{rules:"native",additionalRules:"native",commands:pe("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:LR,lint:{commands:DR,mcp:FR},project:TT,globalSupport:{capabilities:NT,detectionPaths:[ns,os,Ci,Il,Sl,_l],layout:LT},buildImportPaths:fm,detectionPaths:[".windsurfrules",".windsurf"]};});var _g={};OO(_g,{BUILTIN_TARGETS:()=>Ct,TARGET_IDS:()=>ht,getBuiltinTargetDefinition:()=>ne,getEffectiveTargetSupportLevel:()=>kl,getTargetCapabilities:()=>un,getTargetDetectionPaths:()=>rp,getTargetLayout:()=>dt,getTargetManagedOutputs:()=>np,getTargetPrimaryRootInstructionPath:()=>FT,getTargetSkillDir:()=>wi,isBuiltinTargetId:()=>Mr,resolveTargetFeatureGenerator:()=>ss,rewriteGeneratedOutputPath:()=>op});function DT(){return ep||(bf(Ct),ep=new Map(Ct.map(t=>[t.id,t]))),ep}function ne(t){return DT().get(t)}function un(t,e="project"){let r=ne(t)??Z(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return Of(n)}function rp(t,e="project"){let r=ne(t)??Z(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function dt(t,e="project"){let r=ne(t)??Z(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function FT(t,e="project"){return dt(t,e)?.rootInstructionPath}function wi(t,e="project"){return dt(t,e)?.skillDir}function np(t,e="project"){return dt(t,e)?.managedOutputs}function op(t,e,r="project"){let n=dt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function GR(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!xs(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!me(r,t.id,true,n):false}function kl(t,e,r,n="project"){let o=un(t,n)?.[e]?.level??"none";if(o!=="embedded")return o;let s=ne(t)??Z(t);return GR(s,e,r,n)?"none":o}function ss(t,e,r,n="project"){let o=ne(t)??Z(t);if(!o?.generators||GR(o,e,r,n))return;let s=vT[e];return s===null?void 0:s(o.generators)}var Ct,ep,vT,rt=f(()=>{yo();Cn();sr();Cc();lr();vc();hm();oy();Ky();Um();Jm();cu();Pu();Lu();Fu();Mu();MR();Ct=[la,Ea,ny,By,ja,Va,rl,ul,dl,gl,yl,$R];i(DT,"builtinTargetsMap");i(ne,"getBuiltinTargetDefinition");i(un,"getTargetCapabilities");i(rp,"getTargetDetectionPaths");i(dt,"getTargetLayout");i(FT,"getTargetPrimaryRootInstructionPath");i(wi,"getTargetSkillDir");i(np,"getTargetManagedOutputs");i(op,"rewriteGeneratedOutputPath");i(GR,"isFeatureSuppressedByConversion");i(kl,"getEffectiveTargetSupportLevel");vT={rules:i(t=>t.generateRules,"rules"),additionalRules:null,commands:i(t=>t.generateCommands,"commands"),agents:i(t=>t.generateAgents,"agents"),skills:i(t=>t.generateSkills,"skills"),mcp:i(t=>t.generateMcp,"mcp"),permissions:i(t=>t.generatePermissions,"permissions"),hooks:i(t=>t.generateHooks,"hooks"),ignore:i(t=>t.generateIgnore,"ignore")};i(ss,"resolveTargetFeatureGenerator");});function BT(t){return typeof t=="string"?t:t.level}function jR(t){return WT.includes(t)}function UR(t,e,r,n){for(let o of UT){let s=BT(e[o.feature]);if(s==="none")continue;let a=typeof t.generators[o.generator]=="function",l=jR(o.feature)&&typeof t.emitScopedSettings=="function";a||l||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${s}" but generators.${o.generator}`+(jR(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function wl(t){return HT.parse(t)}var Nr,WR,$T,MT,BR,GT,jT,UT,WT,KT,HT,sp=f(()=>{Nr=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()})]),WR=z$1.object({rules:Nr,additionalRules:Nr,commands:Nr,agents:Nr,skills:Nr,mcp:Nr,hooks:Nr,ignore:Nr,permissions:Nr}),$T=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(),MT=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),BR=z$1.object({paths:MT}).passthrough(),GT=z$1.object({capabilities:WR,detectionPaths:z$1.array(z$1.string()),layout:BR,scopeExtras:z$1.function().optional()}).passthrough(),jT=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],UT=[{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"}],WT=["mcp","hooks","ignore","permissions"];i(BT,"capabilityLevel");i(jR,"canUseScopedSettings");i(UR,"validateCapabilityImplementations");KT=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:$T,capabilities:WR,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:BR,globalSupport:GT.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),HT=KT.superRefine((t,e)=>{for(let r of jT)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});UR(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&UR(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});i(wl,"validateDescriptor");});function zT(){return ip||(ip=new Map(Ct.map(t=>[t.id,t]))),ip}function HR(t){let e=wl(t);KR.set(e.id,e);}function Z(t){return KR.get(t)??zT().get(t)}var KR,ip,sr=f(()=>{rt();sp();KR=new Map;i(zT,"builtinDescriptors");i(HR,"registerTargetDescriptor");i(Z,"getDescriptor");});async function zR(t,e,r="project"){let n=new Map,o=Z(t);return o&&await o.buildImportPaths(n,e,r),n}var VR=f(()=>{sr();i(zR,"buildImportReferenceMap");});function J(t){return t.includes("\\")||Pe.test(t)?win32:posix}function X(t){return t.replace(/\\/g,"/")}function j(t,e){let r=J(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):X(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function YR(t,e){return J(t).isAbsolute(e)||Pe.test(e)}function is(t){let e=t,r="";for(;JT.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function XR(t,e){let r=J(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?j(e,r.join(e,n)):null}var Pe,JT,Nt=f(()=>{Pe=/^[A-Za-z]:[\\/]/,JT=/[.!?:;]+$/;i(J,"pathApi");i(X,"normalizeSeparators");i(j,"normalizeForProject");i(YR,"isAbsoluteForProject");i(is,"stripTrailingPunctuation");i(XR,"rootFallbackPath");});function ZT(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 s=o.split("/")[0];s&&s.startsWith(".")&&s.length>1&&n.add(`${s}/`);}return n}function qT(){let t=new Set([".agentsmesh/"]);for(let e of Ct)for(let r of ZT(e))t.add(r);return Array.from(t)}function QT(){let t=new Set([...qT(),...ap.rootRelativePrefixes]),e=new Set([...XT,...ap.meshRootSegments]);return {protectedSchemes:[...YT,...ap.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function Ol(){return lp||(lp=QT()),lp}var YT,XT,ap,lp,ZR=f(()=>{rt();YT=[/\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],XT=new Set(["skills","rules","commands","agents","packs"]),ap={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};i(ZT,"topLevelDotfilePrefixes");i(qT,"buildDefaultRootRelativePrefixes");i(QT,"rebuild");i(Ol,"getLinkFormatRegistry");});function Ae(t){let e=X(t);return Ol().rootRelativePrefixes.some(r=>e.startsWith(r))}function rL(t){let e=X(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Pe.test(e)||/^[a-zA-Z]:/.test(e)||Ae(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&Ol().meshRootSegments.has(r)}function Oi(t,e,r){let n=J(e),o=j(e,e),s=j(e,r),a=X(t);if(Pe.test(t)){let l=j(e,t);return n===win32||l.startsWith(`${o}${n.sep}`)?[l]:[l]}if(isAbsolute(t)){let l=j(e,t);return l.startsWith(o)||existsSync(t)?[l]:[j(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let l=j(e,n.join(n.dirname(s),a)),c=XR(a,o);return c&&c!==l?[l,c]:[l]}if(Ae(a))return [j(e,n.join(o,a))];if(a.includes("/")){let l=j(e,n.join(o,".agentsmesh")),c=rL(a)?j(e,n.join(l,a)):null,m=j(e,n.join(o,a)),u=j(e,n.join(n.dirname(s),a));return c!==null?[c,m,u]:[m,u]}return nL.has(a)?[]:a.includes(".")?[j(e,n.join(n.dirname(s),a))]:[]}function Ei(t,e){let r=[e];if(!YR(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 eC(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function El(t){let e=[];for(let r of Ol().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(oL))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(sL))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(iL))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var nL,oL,sL,iL,tC,as,fn=f(()=>{Nt();ZR();i(Ae,"isRootRelativePathToken");i(rL,"isMeshRootRelativePathToken");nL=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),oL=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,sL=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,iL=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,tC=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,as=/(?::(\d+)){1,2}$/;i(Oi,"resolveProjectPath");i(Ei,"expandResolvedPaths");i(eC,"isGlobAdjacent");i(El,"protectedRanges");});function lL(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 cp(t,e){let r=J(t),n=j(t,t),o=j(t,e);if(o===n)return true;let s=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(s)}function rC(t){let e=J(t);return j(t,e.join(t,".agentsmesh"))}function Dr(t,e){let r=J(t),n=rC(t),o=j(t,e);if(o===n)return true;let s=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(s)}function nC(t,e,r){let n=J(t),o=rC(t),s=j(t,e);if(!Dr(t,s))return null;let a=n.relative(o,s).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function mp(t,e,r){let o=J(t).relative(j(t,t),j(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let s=o.length>0?o:".";return r&&!s.endsWith("/")?`${s}/`:s}function oC(t,e,r){return !lL(r.tokenContext)||r.originalToken===void 0?false:X(r.originalToken).startsWith(".agentsmesh/")}function ls(t,e,r){let n=mp(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function up(t,e,r,n,o){let s=J(t),a=j(t,t),l=j(t,e),c=j(t,r);if(!cp(t,c))return ls(t,c,n)?.text??null;let m=j(t,dirname(l));if(!cp(t,m)&&m!==a)return ls(t,c,n)?.text??null;let u=s.relative(m,c).replace(/\\/g,"/");if(s.isAbsolute(u)||Pe.test(u))return mp(t,c,n);let p=j(t,s.join(m,u));return cp(t,p)?(u===""||u==="."?u=".":o.explicitCurrentDirLinks===true&&m!==a&&!u.startsWith("../")&&!u.startsWith("./")&&(u=`./${u}`),n&&!u.endsWith("/")?`${u}/`:u):mp(t,c,n)}var pp=f(()=>{Nt();i(lL,"isReadingContext");i(cp,"isUnderProjectRoot");i(rC,"agentsMeshRoot");i(Dr,"isUnderAgentsMesh");i(nC,"toAgentsMeshRootRelative");i(mp,"toProjectRootRelative");i(oC,"shouldPreserveAgentsMeshAnchor");i(ls,"toProjectRootReference");i(up,"formatLinkPathForDestinationLegacy");});function sC(t,e,r,n,o={}){let s=o.scope??"project",a=j(t,r);if(oC(t,e,o))return X(o.originalToken??"");if(o.forceRelative)return up(t,e,r,n,o);if(s==="global"&&!Dr(t,e))return ls(t,a,n)?.text??null;let l=(()=>{if(Dr(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&Dr(t,j(t,m))?j(t,m):null})();if(!l)return ls(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=nC(t,l,n);return m!==null?m:ls(t,l,n)?.text??null}return up(t,e,r,n,o)}var iC=f(()=>{fn();Nt();pp();pp();i(sC,"formatLinkPathForDestination");});function aC(t,e,r,n){let o=J(e),s=X(t);if(!Ae(s))return null;let a=s.split("/").filter(m=>m.length>0);if(a.length<3)return null;let l=j(e,r),c=o.dirname(l);for(let m=1;m<=a.length-1;m++){let u=a.slice(m).join("/"),p=j(e,o.join(c,u));if(p!==l&&n(p))return p}return null}var lC=f(()=>{Nt();fn();i(aC,"resolveByDestinationSuffixStrip");});function cC(t){let e=null,r=false,n=null,o=null,s=null;for(let c of Oi(t.candidate,t.projectRoot,t.sourceFile)){let m=null,u=null;for(let p of Ei(t.projectRoot,c)){let d=j(t.projectRoot,p),g=j(t.projectRoot,t.translatePath(d)),h=t.pathExists(d),R=t.pathExists(g);if(R&&g!==d){e=g,n=d,r=true;break}(h||R)&&m===null&&(m=g,u=d),e===null&&(e=g);}if(!r&&m!==null&&o===null&&(o=m,s=u),r)break}if(!r){let c=aC(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);c!==null&&(e=c,r=true);}!r&&o!==null&&(e=o,s!==null&&(n=s),r=true);let a=X(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&X(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var mC=f(()=>{Nt();fn();lC();i(cC,"resolveLinkTarget");});function uC(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function pC(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 dC(t){let e=X(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Pe.test(e)||Ae(e)?false:e.includes("/")}var fC=f(()=>{Nt();fn();i(uC,"isTildeHomeRelativePathToken");i(pC,"isMarkdownLinkDestinationToken");i(dC,"isRelativePathToken");});function cL(t,e,r){let n=e+r.length;if(t[n]!=="]"||t[n+1]!=="(")return false;let o=n+2,s="";for(;o<t.length;){let a=t[o];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
|
|
116
|
-
|
|
109
|
+
`),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Js,feature:"ignore"});}}}var vu=f(()=>{A();It();Nu();LC();i(AC,"importGeminiIgnore");});function oN(t){return t.replace(/\\(.)/g,"$1")}function sN(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 iN(t){return `Bash(${t}:*)`}function aN(t){return `Read(${oN(t)})`}async function bC(t){let e=[],r=join(t,lc),n;try{n=await x(r);}catch{return e}let o=n.filter(u=>u.endsWith(".toml"));if(o.length===0)return e;let s=[],a=[],l=new Set,c=new Set;for(let u of o){let d=await I(u);if(!d)continue;let g;try{g=parse$1(d);}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 O=C,_=typeof O.toolName=="string"?O.toolName:null,k=typeof O.decision=="string"?O.decision:null;if(!_||!k)continue;let D=sN(_);if(!D)continue;let b=null;D==="Bash"?typeof O.commandPrefix=="string"&&O.commandPrefix.trim()&&(b=iN(O.commandPrefix.trim())):D==="Read"?typeof O.argsPattern=="string"&&O.argsPattern.trim()?b=aN(O.argsPattern.trim()):b="Read":b=D,b&&(k==="allow"?l.has(b)||(l.add(b),s.push(b)):k==="deny"&&(c.has(b)||(c.add(b),a.push(b))));}}if(s.length===0&&a.length===0)return e;await R(join(t,".agentsmesh"));let m=join(t,ku),p=stringify({allow:s,deny:a});return await S(m,p.trimEnd()+`
|
|
110
|
+
`),e.push({fromTool:jn,fromPath:join(t,lc),toPath:ku,feature:"permissions"}),e}var PC=f(()=>{A();It();i(oN,"unescapeRegexLiteral");i(sN,"toolNameToPermissionBase");i(iN,"commandPrefixToBashExpr");i(aN,"argsPatternToReadExpr");i(bC,"importGeminiPolicies");});function $u(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,s)=>{let a=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return o.replace(new RegExp(`${a}[/\\\\]\\.agentsmesh[/\\\\]`,"g"),".agentsmesh/").replaceAll(`${s}/.agentsmesh`,".agentsmesh").replaceAll(`${s}\\.agentsmesh`,".agentsmesh")},t).replace(/(?:[A-Za-z]:)?[^\s"'`()<>]+[/\\]\.agentsmesh[/\\]/g,".agentsmesh/")}var TC=f(()=>{i($u,"stripProjectRootCanonicalPrefix");});async function DC(t,e,r){let n=join(t,ha),s=(await x(n)).filter(l=>basename(l)==="SKILL.md");for(let l of s){let c=await I(l);if(!c)continue;let m=basename(l.slice(0,-9)),p=E(c),u=Qe(p.frontmatter,m);if(u){let k=join(t,ya);await R(k);let D=join(k,`${u.name}.md`);await S(D,le(u,r(p.body,l,D))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${ya}/${u.name}.md`,feature:"agents"});continue}let d=join(t,Ia,m,"SKILL.md"),g=r(c,l,d),h=join(t,Ia,m);await R(h);let{frontmatter:C,body:O}=E(g);await S(d,await tr(d,{...C,name:m},O)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Ia}/${m}/SKILL.md`,feature:"skills"});let _=await x(dirname(l));for(let k of _){if(k===l)continue;let D=await I(k);if(D===null)continue;let b=relative(dirname(l),k).replace(/\\/g,"/"),P=join(h,b);await R(dirname(P)),await S(P,r(D,k,P)),e.push({fromTool:"gemini-cli",fromPath:k,toPath:`${Ia}/${m}/${b}`,feature:"skills"});}}let a=join(t,Un);try{let c=(await x(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await I(m);if(!p)continue;let{frontmatter:u,body:d}=E(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),C=join(t,ya);await R(C);let O=join(C,h),_=r(d,m,O);await S(O,await yt(O,{...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:`${ya}/${h}`,feature:"agents"});}}catch{}}var FC=f(()=>{A();v();Y();ht();It();i(DC,"importGeminiSkillsAndAgents");});async function lN(t,e,r){let n=await z("codex-cli",t),o=join(t,Kn),s=join(t,Rr),a=join(t,uC),l=[s,a,join(t,_e),join(t,dC)],c=null,m=l[l.length-1];for(let b of l){let P=await I(b);if(P!==null){c=P,m=b;break}}if(c===null)return;await R(o);let p=join(o,"_root.md"),u=m===s||m===a?n(c,m,p):c,d=await or({content:u,projectRoot:t,rulesDir:Kn,sourcePath:m,fromTool:jn,normalize:r});e.push(...d.results);let g=r(d.rootContent,m,p),h=$u(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:C,body:O}=E(h),k=C.root===true?C:{...C,root:true},D=$u(await M(p,k,O),t);await S(p,D),e.push({fromTool:jn,fromPath:m,toPath:`${Kn}/_root.md`,feature:"rules"});}async function gc(t){let e=[],r=await z(jn,t);return await lN(t,e,r),e.push(...await et(hc,t,"project",{normalize:r})),await DC(t,e,r),await Du(t,e),await AC(t,e),e.push(...await bC(t)),e}var ju=f(()=>{Ct();A();v();Y();Ss();qt();It();Uu();vu();PC();TC();FC();i(lN,"importRootRule");i(gc,"importFromGemini");});async function $C(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:s,body:a}=dc(r(o)),l=Fr(s.globs),c={root:false,description:typeof s.description=="string"?s.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${Kn}/${n}`,feature:"rules",content:await M(o,c,a)}}async function MC(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),s=r(o),{frontmatter:a,body:l}=t.endsWith(".toml")?mN(s):dc(s),c=ue(a.allowedTools),m=ue(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${mc}/${n}`,feature:"commands",content:await q(o,{description:typeof a.description=="string"?a.description:"",hasDescription:Object.prototype.hasOwnProperty.call(a,"description"),allowedTools:p,hasAllowedTools:Object.prototype.hasOwnProperty.call(a,"allowedTools")||Object.prototype.hasOwnProperty.call(a,"allowed-tools")},l)}}function mN(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var GC=f(()=>{Y();Te();vu();It();i($C,"mapGeminiRuleFile");i(MC,"mapGeminiCommandFile");i(mN,"parseTomlCommand");});var jC,UC,KC=f(()=>{GC();jC=i(({relativePath:t,destDir:e,normalizeTo:r})=>$C(t,e,r),"geminiRuleMapper"),UC=i(({relativePath:t,destDir:e,normalizeTo:r})=>MC(t,e,r),"geminiCommandMapper");});function WC(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(s=>({...s,target:jn}))}var BC=f(()=>{Vt();It();i(WC,"lintRules");});function HC(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>B(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function zC(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=>Ks(n,"gemini-cli",e))}var VC=f(()=>{$t();i(HC,"lintCommands");i(zC,"lintHooks");});function JC(t,e){return e==="project"&&Wn("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:bu(t)}var YC=f(()=>{it();Pu();i(JC,"emitScopedGeminiSettings");});function ZC(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function qC(t,e){let r=ZC(t),n=pN.parse(JSON.parse(e)),o={...r};n.permissions!==void 0&&(o.permissions=n.permissions),n.hooks!==void 0&&(o.hooks=n.hooks);let s=o.permissions;return s&&typeof s=="object"&&!Array.isArray(s)&&!("ask"in s)&&(s.ask=[]),JSON.stringify(o,null,2)}function QC(t,e){let r=ZC(t),n=uN.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 XC,pN,uN,Ku=f(()=>{XC=[".claude/settings.json",".gemini/settings.json"],pN=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(),uN=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();i(ZC,"parseJsonObject");i(qC,"mergeSettingsJson");i(QC,"mergeGeminiSettingsJson");});var dN,fN,gN,hN,hc,Uu=f(()=>{RC();ro();wC();It();ju();KC();BC();vt();ms();ht();VC();YC();He();Ku();dN={name:"gemini-cli",primaryRootInstructionPath:_e,generateRules:Eu,generateCommands:wu,generateAgents:Lu,generateSkills:Au,generateIgnore:xu,generatePermissions:EC,importFrom:gc},fN={rootInstructionPath:_e,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Rr]}],extraRuleOutputPaths(){return [Rr]},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 mt(t,".gemini/skills",e)},paths:{rulePath(t,e){return _e},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${ee}/${r.join("/")}/${n}.toml`}return `${ee}/${t}.toml`},agentPath(t,e){return ae(e,"gemini-cli")?`.gemini/skills/${Z(t)}/SKILL.md`:`${Un}/${t}.md`}}},gN={rootInstructionPath:Ys,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Xs]}],extraRuleOutputPaths(){return [Xs]},skillDir:Bo,managedOutputs:{dirs:[Zs,Bo,_a],files:[Ys,Xs,pc]},rewriteGeneratedPath(t){return t===_e?Ys:t===Rr?Xs:t===Wo?pc:t.startsWith(`${ee}/`)?t.replace(`${ee}/`,`${Zs}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Bo}/`):t.startsWith(`${Un}/`)?t.replace(`${Un}/`,`${_a}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return mt(t,Bo,e)},paths:{rulePath(t,e){return Ys},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${Zs}/${r.join("/")}/${n}.toml`}return `${Zs}/${t}.toml`},agentPath(t,e){return ae(e,"gemini-cli")?`${Bo}/${Z(t)}/SKILL.md`:`${_a}/${t}.md`}}},hN={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},hc={id:"gemini-cli",generators:dN,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:be("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:WC,lint:{commands:HC,hooks:zC},emitScopedSettings:JC,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===Wo?QC(o,r):null},project:fN,globalSupport:{capabilities:hN,detectionPaths:[Ys,Xs,pc,Zs,Bo,_a],layout:gN},importer:{rules:{feature:"rules",mode:"directory",source:{project:[pC]},canonicalDir:Kn,extensions:[".md"],map:jC},commands:{feature:"commands",mode:"directory",source:{project:[ee]},canonicalDir:mc,extensions:[".md",".toml"],map:UC}},buildImportPaths:gp,detectionPaths:["GEMINI.md",".gemini"]};});function tO(t){let e=t.rules.find(s=>s.root),r=t.rules.filter(s=>s.root?false:s.targets.length===0||s.targets.includes(ur)),n=e?.body.trim()??"",o=Zt(n,r);return o?[{path:he,content:o}]:[]}function eO(t){return Nt(t,Ut)}function rO(t){return t.commands.map(e=>({path:`${Ut}/${Tt(e.name)}/SKILL.md`,content:gs(e)}))}function nO(t){return t.agents.map(e=>({path:`${Ut}/${Z(e.name)}/SKILL.md`,content:qe(e)}))}function oO(t){return t.ignore.length===0?[]:[{path:Kr,content:t.ignore.join(`
|
|
111
|
+
`)}]}var sO=f(()=>{Et();Tr();ht();er();Ls();i(tO,"generateRules");i(eO,"generateSkills");i(rO,"generateCommands");i(nO,"generateAgents");i(oO,"generateIgnore");});async function iO(t,e={}){let r=e.scope??"project",n=[],o=await z(ur,t,r);return n.push(...await et(yc,t,r,{normalize:o})),await kt(t,r==="global"?ye:Ut,ur,n,o),n}var aO=f(()=>{Ct();Et();qt();Ls();Wu();i(iO,"importFromGoose");});function lO(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ur}))}var cO=f(()=>{Vt();Ls();i(lO,"lintRules");});function mO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[B(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function pO(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?[]:[B(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function uO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[B(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var dO=f(()=>{$t();i(mO,"lintHooks");i(pO,"lintPermissions");i(uO,"lintMcp");});var yN,IN,_N,fO,yc,Wu=f(()=>{er();ht();sO();He();aO();cO();dO();vt();Ls();yN={name:ur,primaryRootInstructionPath:he,generateRules:tO,generateCommands:rO,generateAgents:nO,generateSkills:eO,generateIgnore:oO,importFrom:iO},IN={rootInstructionPath:he,skillDir:Ut,managedOutputs:{dirs:[Ut],files:[he,Kr]},paths:{rulePath(t){return he},commandPath(t){return `${Ut}/${Tt(t)}/SKILL.md`},agentPath(t){return `${Ut}/${Z(t)}/SKILL.md`}}},_N={rootInstructionPath:Wr,skillDir:ye,managedOutputs:{dirs:[ye],files:[Wr,fo]},rewriteGeneratedPath(t){return t===he?Wr:t===Kr?fo:(t.startsWith(`${Ut}/`),t)},mirrorGlobalPath(t,e){return mt(t,ye,e)},paths:{rulePath(t){return Wr},commandPath(t){return `${ye}/${Tt(t)}/SKILL.md`},agentPath(t){return `${ye}/${Z(t)}/SKILL.md`}}},fO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},yc={id:ur,generators:yN,capabilities:fO,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:lO,lint:{hooks:mO,permissions:pO,mcp:uO},supportsConversion:{commands:true,agents:true},project:IN,globalSupport:{capabilities:fO,detectionPaths:[Wr,fo,ye],layout:_N},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[he],global:[Wr]},canonicalDir:ay,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Kr],global:[fo]},canonicalDir:".agentsmesh",canonicalFilename:ly}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:hp,detectionPaths:[he,Kr]};});function gO(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("junie"))continue;let o=basename(n.source,".md");e.push({path:`${Ji}/${o}.md`,content:n.body.trim()||""});}return e}function CN(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),jl(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 hO(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).map(([r,n])=>[r,CN(n)]));return [{path:Vi,content:JSON.stringify({mcpServers:e},null,2)}]}function yO(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${As}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function IO(t){return t.agents.map(e=>{let r={name:e.name,description:e.description||void 0,tools:e.tools.length>0?e.tools:void 0,disallowedTools:e.disallowedTools.length>0?e.disallowedTools:void 0,model:e.model||void 0,skills:e.skills.length>0?e.skills:void 0};return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];}),{path:`${bs}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function _O(t){return t.ignore.length===0?[]:[{path:Yi,content:t.ignore.join(`
|
|
112
|
+
`)}]}function SO(t){return Nt(t,ho)}function CO(t){let e=t.rules.find(n=>n.root),r=t.rules.filter(n=>n.root?false:n.targets.length===0||n.targets.includes("junie"));return Zt(e?.body.trim()??"",r)}var OO=f(()=>{Ul();Et();Tr();v();Ps();i(gO,"generateRules");i(CN,"toJunieMcpServer");i(hO,"generateMcp");i(yO,"generateCommands");i(IO,"generateAgents");i(_O,"generateIgnore");i(SO,"generateSkills");i(CO,"renderJunieGlobalInstructions");});async function ON(t,e,r){let n=[dr,Cl,my,py],o=join(t,yp);for(let s of n){let a=join(t,s),l=await I(a);if(l===null)continue;let c=await or({content:l,projectRoot:t,rulesDir:Rl,sourcePath:a,fromTool:go,normalize:r});e.push(...c.results);let{frontmatter:m,body:p}=E(r(c.rootContent,a,o)),u=await M(o,{root:true,description:typeof m.description=="string"?m.description:void 0,globs:Array.isArray(m.globs)?m.globs:void 0},p);await S(o,u),e.push({fromTool:go,fromPath:a,toPath:yp,feature:"rules"});return}}async function Ic(t){let e=[],r=await z(go,t);return await ON(t,e,r),e.push(...await et(_c,t,"project",{normalize:r})),await kt(t,ho,go,e,r),e}var Bu=f(()=>{Ct();A();v();Et();Ss();Y();qt();Ps();Hu();i(ON,"importRootRule");i(Ic,"importFromJunie");});function kO(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:go}))}var EO=f(()=>{Vt();Ps();i(kO,"lintRules");});function wO(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))XI(n)&&e.push(B(".agentsmesh/mcp.json","junie",`MCP server "${r}" uses ${n.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`));return e}var LO=f(()=>{Ul();$t();i(wO,"lintMcp");});var RN,kN,EN,wN,_c,Hu=f(()=>{OO();Ps();He();Bu();EO();LO();vt();RN={name:"junie",primaryRootInstructionPath:dr,generateRules:gO,generateCommands:yO,generateAgents:IO,generateSkills:SO,generateMcp:hO,generateIgnore:_O,importFrom:Ic},kN={rootInstructionPath:dr,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 `${Ji}/${t}.md`},commandPath(t,e){return `${As}/${t}.md`},agentPath(t,e){return `${bs}/${t}.md`}}},EN={rootInstructionPath:yo,renderPrimaryRootInstruction:CO,skillDir:Zi,managedOutputs:{dirs:[Zi,qi,Qi,uy],files:[yo,Ol]},rewriteGeneratedPath(t){return t===dr?yo:t.startsWith(`${Ji}/`)?yo:t.startsWith(`${ho}/`)?t.replace(`${ho}/`,`${Zi}/`):t.startsWith(`${As}/`)?t.replace(`${As}/`,`${Qi}/`):t.startsWith(`${bs}/`)?t.replace(`${bs}/`,`${qi}/`):t===Vi?Ol:t===Yi?null:t},mirrorGlobalPath(t,e){return mt(t,".junie/skills",e)},paths:{rulePath(t,e){return yo},commandPath(t,e){return `${Qi}/${t}.md`},agentPath(t,e){return `${qi}/${t}.md`}}},wN={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},_c={id:"junie",generators:RN,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:kO,lint:{mcp:wO},project:kN,globalSupport:{capabilities:wN,detectionPaths:[yo,Zi,qi,Qi,Ol],layout:EN},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Rl,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:dy,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:fy,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Vi]},canonicalDir:".agentsmesh",canonicalFilename:gy},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Yi]},canonicalDir:".agentsmesh",canonicalFilename:hy}},buildImportPaths:Ip,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function bO(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:fr,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Kt))continue;let o=basename(n.source,".md"),s={};n.description&&(s.description=n.description),n.globs.length>0&&(s.globs=n.globs);let a=Object.keys(s).length>0?T(s,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Br}/${o}.md`,content:a});}return e}function PO(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Hr}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function xO(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:`${zr}/${r}.md`,content:T(n,e.body.trim()||"")}})}function TO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:kn,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function NO(t){return t.ignore.length===0?[]:[{path:xs,content:t.ignore.join(`
|
|
113
|
+
`)}]}function DO(t){return Nt(t,$e)}var FO=f(()=>{Et();v();ko();i(bO,"generateRules");i(PO,"generateCommands");i(xO,"generateAgents");i(TO,"generateMcp");i(NO,"generateIgnore");i(DO,"generateSkills");});var Sc,Cc,vO,Vu=f(()=>{v();Y();ko();Sc=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${Ln}/${t}`,content:await M(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},s)}},"kiloNonRootRuleMapper"),Cc=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${Fs}/${t}`,content:await q(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"kiloCommandMapper"),vO=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${Ro}/${t}`,content:await yt(n,o,s)}},"kiloAgentMapper");});async function $O(t){try{return await stat(t),!0}catch{return false}}async function bN(t,e,r){let n=join(t,Io);if(!await $O(n))return;let o=join(t,Ln),s=join(n,Yu),l=e.some(c=>c.toPath===Ju)?null:await I(s);if(l!==null){let c=join(t,Ju),m=r(l,s,c),{body:p}=E(m),u=await M(c,{root:true},p);await S(c,u),e.push({feature:"rules",fromTool:Kt,fromPath:`${Io}/${Yu}`,toPath:Ju});}e.push(...await tt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Kt,normalize:r,mapEntry:i(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let d=await Sc({absolutePath:c,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===Yu||!d?null:{...d,feature:"rules"}},"mapEntry")}));}async function PN(t,e,r){let n=join(t,Ts);if(!await $O(n))return;let o=join(t,Fs);e.push(...await tt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Kt,normalize:r,mapEntry:i(async({srcPath:s,relativePath:a,content:l,normalizeTo:c})=>{let m=await Cc({absolutePath:s,relativePath:a,content:l,destDir:o,normalizeTo:c});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function xN(t,e,r){let n=join(t,El),o=await I(n);if(o===null)return;let s;try{s=parse(o);}catch{return}if(!(!s||!Array.isArray(s.customModes)))for(let a of s.customModes){if(!a||typeof a!="object")continue;let l=a;if(typeof l.slug!="string"||l.slug.length===0)continue;let c=l.slug,m=join(t,Ro,`${c}.md`),p=typeof l.description=="string"?l.description:"",u=typeof l.roleDefinition=="string"?l.roleDefinition.trim():"",d=typeof l.whenToUse=="string"?l.whenToUse.trim():"",g=d?`${u}
|
|
114
|
+
|
|
115
|
+
## When to use
|
|
116
|
+
|
|
117
|
+
${d}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let C=await yt(m,h,g),O=r(C,n,m);await S(m,O),e.push({feature:"agents",fromTool:Kt,fromPath:n,toPath:`${Ro}/${c}.md`});}}async function Oc(t,e={}){let r=e.scope??"project",n=[],o=await z(Kt,t,r);return n.push(...await et(Rc,t,r,{normalize:o})),await kt(t,$e,Kt,n,o),r==="project"&&(await bN(t,n,o),await PN(t,n,o),await xN(t,n,o),await kt(t,_o,Kt,n,o)),n}var Ju,Yu,Xu=f(()=>{Ct();Et();Ne();qt();A();Y();v();Vu();ko();Zu();Ju=`${Ln}/_root.md`,Yu="00-root.md";i($O,"pathExists");i(bN,"importLegacyRules");i(PN,"importLegacyWorkflows");i(xN,"importLegacyModes");i(Oc,"importFromKiloCode");});function MO(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Kt}))}var GO=f(()=>{Vt();ko();i(MO,"lintRules");});function jO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[B(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function UO(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?[]:[B(".agentsmesh/permissions.yaml","kilo-code","kilo-code permissions live in kilo.jsonc, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}var KO=f(()=>{$t();i(jO,"lintHooks");i(UO,"lintPermissions");});var TN,NN,DN,WO,Rc,Zu=f(()=>{FO();ko();He();Xu();Vu();GO();KO();vt();TN={name:Kt,primaryRootInstructionPath:fr,generateRules:bO,generateCommands:PO,generateAgents:xO,generateSkills:DO,generateMcp:TO,generateIgnore:NO,importFrom:Oc},NN={rootInstructionPath:fr,skillDir:$e,managedOutputs:{dirs:[Br,Hr,zr,$e],files:[fr,kn,xs]},paths:{rulePath(t,e){return `${Br}/${t}.md`},commandPath(t,e){return `${Hr}/${t}.md`},agentPath(t,e){return `${zr}/${t}.md`}}},DN={rootInstructionPath:En,skillDir:wn,managedOutputs:{dirs:[So,Co,Oo,wn,Iy],files:[En,Ds,wl]},rewriteGeneratedPath(t){return t===fr?En:t},mirrorGlobalPath(t,e){return mt(t,wn,e)},paths:{rulePath(t,e){return `${So}/${t}.md`},commandPath(t,e){return `${Co}/${t}.md`},agentPath(t,e){return `${Oo}/${t}.md`}}},WO={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Rc={id:Kt,generators:TN,capabilities:WO,emptyImportMessage:"No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",lintRules:MO,lint:{hooks:jO,permissions:UO},project:NN,globalSupport:{capabilities:WO,detectionPaths:[En,So,Co,Oo,wn,Ds,wl],layout:DN},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[fr],global:[En]},canonicalDir:Ln,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Br],global:[So]},canonicalDir:Ln,extensions:[".md"],map:Sc}],commands:{feature:"commands",mode:"directory",source:{project:[Hr],global:[Co]},canonicalDir:Fs,extensions:[".md"],map:Cc},agents:{feature:"agents",mode:"directory",source:{project:[zr],global:[Oo]},canonicalDir:Ro,extensions:[".md"],map:vO},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[kn,ea],global:[Ds]},canonicalDir:".agentsmesh",canonicalFilename:_y},ignore:{feature:"ignore",mode:"flatFile",source:{project:[xs],global:[wl]},canonicalDir:".agentsmesh",canonicalFilename:Sy}},buildImportPaths:_p,detectionPaths:[Br,Hr,zr,$e,kn,Io,Ts,_o,ea,El,xs,"kilo.jsonc","kilo.json"]};});function BO(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function $N(t){return t.type==="prompt"?t.prompt:t.command}function MN(t,e){let r=HO[t];return t==="PreToolUse"||t==="PostToolUse"?{type:r,tools:[e||"*"]}:{type:r}}function zO(t){let e=[];for(let[r,n]of Object.entries(t)){let o=r;if(!(o in HO)||!Array.isArray(n))continue;let s=1;for(let a of n){let l=$N(a);if(!l)continue;let c={name:`${BO(r)} ${s}`,version:"1",when:MN(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:l}:{type:"shellCommand",command:l}};e.push({name:`${BO(r)}-${s}.kiro.hook`,content:JSON.stringify(c,null,2)}),s+=1;}}return e}function GN(t){let e=vN.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 VO(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:GN(r)}function JO(t){return stringify(t).trimEnd()}var HO,vN,qu=f(()=>{HO={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},vN=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);i(BO,"toKebab");i($N,"hookText");i(MN,"toWhen");i(zO,"generateKiroHooks");i(GN,"toCanonicalEntry");i(VO,"parseKiroHookFile");i(JO,"serializeCanonicalHooks");});function UN(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 YO(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Me,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(te))continue;let o=basename(n.source,".md");e.push({path:`${Ge}/${o}.md`,content:T(UN(n),n.body.trim()||"")});}return e}function XO(t){return t.commands.map(e=>({path:`${Wt}/${Tt(e.name)}/SKILL.md`,content:gs(e)}))}function ZO(t){return Nt(t,Wt)}function qO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:vs,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function QO(t){return !t.hooks||Object.keys(t.hooks).length===0?[]:zO(t.hooks).map(e=>({path:`${An}/${e.name}`,content:e.content}))}function tR(t){return t.agents.map(e=>{let r={name:e.name,description:e.description,tools:e.tools.length>0?e.tools:void 0,model:e.model||void 0};Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];});let n=T(r,e.body.trim()||"");return {path:`${je}/${e.name}.md`,content:n}})}function eR(t){return t.ignore.length===0?[]:[{path:$s,content:t.ignore.join(`
|
|
118
|
+
`)}]}var rR=f(()=>{Et();er();v();qu();Ms();i(UN,"steeringFrontmatter");i(YO,"generateRules");i(XO,"generateCommands");i(ZO,"generateSkills");i(qO,"generateMcp");i(QO,"generateHooks");i(tR,"generateAgents");i(eR,"generateIgnore");});function WN(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:Fr(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function BN(t,e,r,n){let o=n==="global"?[Ue,Me]:[Me,Ue];for(let s of o){let a=join(t,s),l=await I(a);if(l===null)continue;let c=join(t,Sp),{frontmatter:m,body:p}=E(r(l,a,c));await S(c,await M(c,{...m,root:true},p)),e.push({fromTool:te,fromPath:a,toPath:Sp,feature:"rules"});return}}async function HN(t,e,r){let n=join(t,Cp);e.push(...await tt({srcDir:join(t,Ge),destDir:n,extensions:[".md"],fromTool:te,normalize:r,mapEntry:i(async({relativePath:o,normalizeTo:s})=>{if(basename(o)==="AGENTS.md")return null;let a=join(n,o),{frontmatter:l,body:c}=E(s(a));return {destPath:a,toPath:`${Cp}/${o}`,feature:"rules",content:await M(a,WN(l),c)}},"mapEntry")}));}async function zN(t,e){let r={};for(let o of await x(join(t,An))){if(!o.endsWith(".kiro.hook"))continue;let s=VO(await I(o)??"");s&&(r[s.event]??=[],r[s.event].push(s.entry));}if(Object.keys(r).length===0)return;let n=join(t,Op);await R(join(t,".agentsmesh")),await S(n,JO(r)),e.push({fromTool:te,fromPath:join(t,An),toPath:Op,feature:"hooks"});}async function kc(t,e={}){let r=e.scope??"project",n=[],o=await z(te,t,r);return await BN(t,n,o,r),await HN(t,n,o),n.push(...await et(Ec,t,r,{normalize:o})),await kt(t,Wt,te,n,o),r==="project"&&await zN(t,n),n}var Qu=f(()=>{Ct();Et();Ne();qt();Y();Te();A();v();qu();Ms();td();i(WN,"canonicalRuleMeta");i(BN,"importRoot");i(HN,"importNonRootRules");i(zN,"importHooks");i(kc,"importFromKiro");});function nR(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:te}))}var oR=f(()=>{Vt();Ms();i(nR,"lintRules");});function sR(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=>Ks(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var iR=f(()=>{$t();i(sR,"lintHooks");});var VN,JN,YN,XN,Ec,td=f(()=>{er();rR();He();Qu();oR();iR();vt();Ms();VN={name:te,primaryRootInstructionPath:Me,generateRules:YO,generateCommands:XO,generateAgents:tR,generateSkills:ZO,generateMcp:qO,generateHooks:QO,generateIgnore:eR,importFrom:kc},JN={rootInstructionPath:Me,skillDir:Wt,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${Ge}/${t}.md`},commandPath(t){return `${Wt}/${Tt(t)}/SKILL.md`},agentPath(t,e){return `${je}/${t}.md`}}},YN={rootInstructionPath:Ue,skillDir:bn,managedOutputs:{dirs:[Eo,bn,wo,Ry],files:[Ue,na,oa]},rewriteGeneratedPath(t){return t===Me?Ue:t.startsWith(`${Ge}/`)?t.replace(`${Ge}/`,`${Eo}/`):t.startsWith(`${Wt}/`)?t.replace(`${Wt}/`,`${bn}/`):t.startsWith(`${je}/`)?t.replace(`${je}/`,`${wo}/`):t===vs?na:t===$s?oa:t.startsWith(`${An}/`)?null:t},mirrorGlobalPath(t,e){return mt(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${Eo}/${t}.md`},commandPath(t){return `${Wt}/${Tt(t)}/SKILL.md`},agentPath(t,e){return `${wo}/${t}.md`}}},XN={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Ec={id:te,generators:VN,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:nR,lint:{hooks:sR},project:JN,globalSupport:{capabilities:XN,detectionPaths:[Eo,Ue,bn,wo,na,oa],layout:YN},importer:{agents:{feature:"agents",mode:"directory",source:{project:[je],global:[je]},canonicalDir:ky,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[vs],global:[na]},canonicalDir:".agentsmesh",canonicalFilename:Ey},ignore:{feature:"ignore",mode:"flatFile",source:{project:[$s],global:[oa]},canonicalDir:".agentsmesh",canonicalFilename:wy}},buildImportPaths:Rp,detectionPaths:[Ge,Wt,je,An,vs,$s]};});function lR(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:gr,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Ke))continue;let o=basename(n.source,".md"),s={};n.description&&(s.description=n.description),n.globs.length>0&&(s.globs=n.globs);let a=Object.keys(s).length>0?T(s,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Vr}/${o}.md`,content:a});}return e}function cR(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Jr}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function mR(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:`${Yr}/${r}.md`,content:T(n,e.body.trim()||"")}})}function ZN(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 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))e[r]=ZN(n);return [{path:hr,content:JSON.stringify({mcp:e},null,2)}]}function uR(t){return Nt(t,We)}var dR=f(()=>{Et();v();Po();i(lR,"generateRules");i(cR,"generateCommands");i(mR,"generateAgents");i(ZN,"toOpenCodeMcpServer");i(pR,"generateMcp");i(uR,"generateSkills");});function ed(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 QN(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,s]of Object.entries(r)){if(!s||typeof s!="object"||Array.isArray(s))continue;let a=s;if(typeof a.url=="string"){n[o]={type:"url",url:a.url,headers:ed(a.headers),env:ed(a.environment),...typeof a.description=="string"?{description:a.description}:{}};continue}if(Array.isArray(a.command)&&a.command.length>0){let l=a.command,c=l[0];if(c===void 0)continue;let m=l.slice(1);n[o]={type:"stdio",command:c,args:m,env:ed(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function tD(t,e,r){let o=join(t,e==="global"?Tn:hr),s=await I(o);if(s===null)return;let a=QN(s);Object.keys(a).length!==0&&(await pe(t,kp,a),r.push({feature:"mcp",fromTool:Ke,fromPath:o,toPath:kp}));}async function fR(t,e={}){let r=e.scope??"project",n=[],o=await z(Ke,t,r);return n.push(...await et(wc,t,r,{normalize:o})),await kt(t,We,Ke,n,o),await tD(t,r,n),n}var gR=f(()=>{Ct();Et();qt();io();A();Po();rd();i(ed,"toStringRecord");i(QN,"parseOpenCodeMcp");i(tD,"importMcp");i(fR,"importFromOpenCode");});var hR,yR,IR,_R=f(()=>{v();Y();Po();hR=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${sa}/${t}`,content:await M(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},s)}},"opencodeNonRootRuleMapper"),yR=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${Al}/${t}`,content:await q(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"opencodeCommandMapper"),IR=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${bl}/${t}`,content:await yt(n,o,s)}},"opencodeAgentMapper");});function SR(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Ke}))}var CR=f(()=>{Vt();Po();i(SR,"lintRules");});function OR(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[B(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function RR(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?[]:[B(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function kR(t){return t.ignore.length===0?[]:[B(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var ER=f(()=>{$t();i(OR,"lintHooks");i(RR,"lintPermissions");i(kR,"lintIgnore");});var eD,rD,nD,wR,wc,rd=f(()=>{dR();Po();He();gR();_R();CR();ER();vt();eD={name:Ke,primaryRootInstructionPath:gr,generateRules:lR,generateCommands:cR,generateAgents:mR,generateSkills:uR,generateMcp:pR,importFrom:fR},rD={rootInstructionPath:gr,skillDir:We,managedOutputs:{dirs:[Vr,Jr,Yr,We],files:[gr,hr]},paths:{rulePath(t){return `${Vr}/${t}.md`},commandPath(t){return `${Jr}/${t}.md`},agentPath(t){return `${Yr}/${t}.md`}}},nD={rootInstructionPath:Pn,skillDir:xn,managedOutputs:{dirs:[Lo,Ao,bo,xn,Ay],files:[Pn,Tn]},rewriteGeneratedPath(t){return t===gr?Pn:t===hr?Tn:t},mirrorGlobalPath(t,e){return mt(t,xn,e)},paths:{rulePath(t){return `${Lo}/${t}.md`},commandPath(t){return `${Ao}/${t}.md`},agentPath(t){return `${bo}/${t}.md`}}},wR={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},wc={id:Ke,generators:eD,capabilities:wR,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:SR,lint:{hooks:OR,permissions:RR,ignore:kR},project:rD,globalSupport:{capabilities:wR,detectionPaths:[Pn,Lo,Ao,bo,xn,Tn],layout:nD},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[gr],global:[Pn]},canonicalDir:sa,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[Vr],global:[Lo]},canonicalDir:sa,extensions:[".md"],map:hR}],commands:{feature:"commands",mode:"directory",source:{project:[Jr],global:[Ao]},canonicalDir:Al,extensions:[".md"],map:yR},agents:{feature:"agents",mode:"directory",source:{project:[Yr],global:[bo]},canonicalDir:bl,extensions:[".md"],map:IR}},buildImportPaths:Ep,detectionPaths:[Vr,Jr,Yr,We,hr,"opencode.jsonc"]};});function AR(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Be,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Nn))continue;let o=basename(n.source,".md");e.push({path:`${Xr}/${o}.md`,content:n.body.trim()||""});}return e}function bR(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${Zr}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function PR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:aa,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function xR(t){return t.ignore.length===0?[]:[{path:la,content:t.ignore.join(`
|
|
119
|
+
`)}]}function TR(t){return Nt(t,yr)}function NR(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:js,content:stringify({customModes:e})}]}var DR=f(()=>{Et();v();Do();i(AR,"generateRules");i(bR,"generateCommands");i(PR,"generateMcp");i(xR,"generateIgnore");i(TR,"generateSkills");i(NR,"generateAgents");});var Lc,vR,od=f(()=>{v();Y();Do();Lc=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${No}/${t}`,content:await M(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},s)}},"rooNonRootRuleMapper"),vR=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=E(e(n));return {destPath:n,toPath:`${xl}/${t}`,content:await q(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"rooCommandMapper");});async function iD(t,e,r){let n=join(t,xo),o;try{o=await readdir(n,{withFileTypes:!0});}catch{return}let s=o.filter(l=>l.isDirectory()&&l.name.startsWith("rules-")).map(l=>l.name),a=join(t,No);for(let l of s)e.push(...await tt({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:Nn,normalize:r,mapEntry:i(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let d=await Lc({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return d?{...d,feature:"rules"}:null},"mapEntry")}));}async function $R(t,e={}){let r=e.scope??"project",n=[],o=await z(Nn,t,r);return n.push(...await et(Ac,t,r,{normalize:o})),await iD(t,n,o),await kt(t,yr,Nn,n,o),n}var MR=f(()=>{Ct();Et();Ne();qt();od();Do();id();i(iD,"importPerModeRules");i($R,"importFromRooCode");});function GR(t,e,r,n){return Q(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Nn}))}var jR=f(()=>{Vt();Do();i(GR,"lintRules");});function uD(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var mD,pD,dD,fD,gD,Ac,id=f(()=>{A();DR();Do();He();MR();od();jR();vt();mD={name:"roo-code",primaryRootInstructionPath:Be,generateRules:AR,generateCommands:bR,generateSkills:TR,generateMcp:PR,generateIgnore:xR,generateAgents:NR,importFrom:$R},pD={rootInstructionPath:Be,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",js]},paths:{rulePath(t,e){return `${Xr}/${t}.md`},commandPath(t,e){return `${Zr}/${t}.md`},agentPath(t,e){return null}}};i(uD,"computeStatus");dD=i(async(t,e,r,n)=>{if(r!=="global")return [];if(!n.has("agents")||t.agents.length===0)return [];let o=t.agents.map(l=>{let m={slug:basename(l.source,".md"),name:l.name};return l.description&&(m.description=l.description),l.body.trim()&&(m.roleDefinition=l.body.trim()),m}),s=stringify({customModes:o}),a=await I(join(e,ca));return [{target:"roo-code",path:ca,content:s,currentContent:a??void 0,status:uD(a,s)}]},"generateRooGlobalExtras"),fD={rootInstructionPath:vn,skillDir:qr,managedOutputs:{dirs:[Dn,Fn,qr,Py],files:[vn,To,ma,ca]},rewriteGeneratedPath(t){return t===Be?vn:t===js?null:t.startsWith(`${Xr}/`)?t.replace(`${Xr}/`,`${Dn}/`):t.startsWith(`${Zr}/`)?t.replace(`${Zr}/`,`${Fn}/`):t.startsWith(`${yr}/`)?t.replace(`${yr}/`,`${qr}/`):t===aa?To:t===la?ma:t},mirrorGlobalPath(t,e){return mt(t,qr,e)},paths:{rulePath(t,e){return `${Dn}/${t}.md`},commandPath(t,e){return `${Fn}/${t}.md`},agentPath(t,e){return null}}},gD={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Ac={id:"roo-code",generators:mD,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:GR,project:pD,globalSupport:{capabilities:gD,detectionPaths:[Dn,Fn,qr,To,ma,vn,ca],layout:fD,scopeExtras:dD},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Be,ia],global:[vn,Be,ia]},canonicalDir:No,canonicalRootFilename:"_root.md",markAsRoot:true,frontmatterRemap:i(({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:[Xr],global:[Dn]},canonicalDir:No,extensions:[".md"],map:Lc}],commands:{feature:"commands",mode:"directory",source:{project:[Zr],global:[Fn]},canonicalDir:xl,extensions:[".md"],map:vR},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[aa],global:[To]},canonicalDir:".agentsmesh",canonicalFilename:xy},ignore:{feature:"ignore",mode:"flatFile",source:{project:[la],global:[ma]},canonicalDir:".agentsmesh",canonicalFilename:Ty}},buildImportPaths:wp,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",js]};});var kr,ad,Hn,UR,Qs,Er,ti,ei,KR,zn,Je,ri,ld,cd,md,pd,ud,dd,ni,oi,Sa,bc,Pc,xc,WR,Bt=f(()=>{kr="windsurf",ad=".windsurfrules",Hn=".windsurf/rules",UR=".windsurfignore",Qs=".codeiumignore",Er="AGENTS.md",ti=".windsurf/hooks.json",ei=".windsurf/mcp_config.example.json",KR=".windsurf/mcp_config.json",zn=".windsurf/workflows",Je=".windsurf/skills",ri=".agentsmesh/rules",ld=".agentsmesh/commands",cd=".agentsmesh/agents",md=".agentsmesh/skills",pd=".agentsmesh/ignore",ud=".agentsmesh/hooks.yaml",dd=".agentsmesh/mcp.json",ni=".codeium/windsurf/memories/global_rules.md",oi=".codeium/windsurf/skills",Sa=".codeium/windsurf/global_workflows",bc=".codeium/windsurf/hooks.json",Pc=".codeium/windsurf/mcp_config.json",xc=".codeium/.codeiumignore",WR=".agents/skills";});function yD(t){let e=basename(t,".md");return e==="_root"?"root":e}function ID(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 fd(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:Er,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=yD(n.source),s=n.trigger||(n.globs.length>0?"glob":void 0),a={description:n.description||void 0,trigger:s,glob:n.globs.length===1?n.globs[0]:void 0,globs:n.globs.length>1?n.globs:void 0};Object.keys(a).forEach(m=>{a[m]===void 0&&delete a[m];});let l=Object.keys(a).length>0?T(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${Hn}/${o}.md`,content:l});let c=ID(n.globs);c&&(c!==o&&e.push({path:`${Hn}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var BR=f(()=>{v();Bt();i(yD,"ruleSlug");i(ID,"directoryScopedRuleDir");i(fd,"generateRules");});function gd(t){return !t.ignore||t.ignore.length===0?[]:[{path:Qs,content:t.ignore.join(`
|
|
120
|
+
`)}]}var HR=f(()=>{Bt();i(gd,"generateIgnore");});function hd(t){return t.commands.map(e=>{let r={description:e.description.trim()||void 0,allowedTools:e.allowedTools.length>0?e.allowedTools:void 0};Object.keys(r).forEach(o=>{r[o]===void 0&&delete r[o];});let n=Object.keys(r).length>0?T(r,e.body.trim()||""):e.body.trim();return {path:`${zn}/${e.name}.md`,content:n}})}var zR=f(()=>{v();Bt();i(hd,"generateCommands");});function yd(t){return t.agents.map(e=>({path:`${Je}/${Z(e.name)}/SKILL.md`,content:qe(e)}))}var VR=f(()=>{ht();Bt();i(yd,"generateAgents");});function Id(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ei,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var JR=f(()=>{Bt();i(Id,"generateMcp");});function _D(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 SD(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let s of n){if(!Ze(s))continue;let a=gt(s),l=Gt(s),c=s.type==="prompt"?l||a:a||l;c&&o.push({command:c,show_output:true});}o.length>0&&(e[_D(r)]=o);}return e}function _d(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=SD(t.hooks);return Object.keys(e).length===0?[]:[{path:ti,content:JSON.stringify({hooks:e},null,2)}]}var YR=f(()=>{we();Bt();i(_D,"windsurfEventName");i(SD,"toWindsurfHooks");i(_d,"generateHooks");});function Sd(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=Object.keys(n).length>0?T(n,r.body.trim()||""):r.body.trim()||"";e.push({path:`${Je}/${r.name}/SKILL.md`,content:o});for(let s of r.supportingFiles)e.push({path:`${Je}/${r.name}/${s.relativePath}`,content:s.content});}return e}var XR=f(()=>{v();Bt();i(Sd,"generateSkills");});var ZR=f(()=>{BR();HR();zR();VR();JR();YR();XR();});var qR=f(()=>{ZR();});function QR(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 tk(t,e,r){let n=join(t,zn),s=(await x(n)).filter(l=>l.endsWith(".md")),a=join(t,ld);for(let l of s){let c=await I(l);if(!c)continue;let m=relative(n,l).replace(/\\/g,"/");await R(a);let p=join(a,m),u=r(c,l,p),{frontmatter:d,body:g}=E(u),h=await q(p,{description:typeof d.description=="string"?d.description:"",hasDescription:Object.prototype.hasOwnProperty.call(d,"description"),allowedTools:(()=>{let C=QR(d.allowedTools);return C.length>0?C:QR(d["allowed-tools"])})(),hasAllowedTools:Object.prototype.hasOwnProperty.call(d,"allowedTools")||Object.prototype.hasOwnProperty.call(d,"allowed-tools")},g);await S(p,h),e.push({fromTool:kr,fromPath:l,toPath:`${ld}/${m}`,feature:"commands"});}}var ek=f(()=>{A();v();Y();Bt();i(QR,"toStringArray");i(tk,"importWorkflows");});async function rk(t,e,r,n=Je){let o=join(t,n),s=await $n(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:md,targetName:"windsurf",normalize:r,results:e};for(let[l,c]of s){let m=join(c,"SKILL.md"),p=await I(m);if(!p)continue;let u=E(p),d=Qe(u.frontmatter,l);if(d){await ce(join(t,md,l));let g=join(t,cd);await R(g);let h=join(g,`${d.name}.md`);await S(h,le(d,r(u.body,m,h))),e.push({fromTool:"windsurf",fromPath:m,toPath:`${cd}/${d.name}.md`,feature:"agents"});continue}await Ir(l,c,a);}}var nk=f(()=>{A();v();ht();hs();Us();Bt();i(rk,"importSkills");});async function sk(t,e){let r=join(t,ti),n=await I(r);if(n)try{let o=JSON.parse(n);if(!o.hooks||typeof o.hooks!="object"||Array.isArray(o.hooks))return;let s=kD(o.hooks);if(Object.keys(s).length===0)return;let a=join(t,ud);await R(dirname(a)),await S(a,stringify(s)),e.push({fromTool:kr,fromPath:r,toPath:ud,feature:"hooks"});}catch{}}function RD(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 kD(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=RD(r),s=[];for(let a of n){if(!a||typeof a!="object")continue;let l=a;if(typeof l.command=="string"&&l.command.trim()){s.push({matcher:".*",type:"command",command:l.command});continue}let c=typeof l.matcher=="string"&&l.matcher.trim()?l.matcher:".*",m=Array.isArray(l.hooks)?l.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let u=p,d=typeof u.command=="string"?u.command:typeof u.prompt=="string"?u.prompt:"";if(!d.trim())continue;let g={matcher:c,type:u.type==="prompt"?"prompt":"command",command:d};typeof u.timeout=="number"&&(g.timeout=u.timeout),s.push(g);}}s.length>0&&(e[o]=s);}return e}async function ik(t,e){let r=[ei,KR];for(let n of r){let o=join(t,n),s=await I(o);if(s)try{let a=JSON.parse(s);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let l=join(t,dd);await R(dirname(l)),await S(l,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:kr,fromPath:o,toPath:dd,feature:"mcp"});return}catch{}}}var ak=f(()=>{A();Bt();i(sk,"importWindsurfHooks");i(RD,"canonicalHookEventName");i(kD,"windsurfHooksToCanonical");i(ik,"importWindsurfMcp");});async function Nc(t,e){let r=e?.scope??"project",n=[],o=await z(kr,t),s=await z("codex-cli",t),a=join(t,ri),l=join(t,ad),c=await I(l);if(c!==null){await R(a);let d=join(a,"_root.md"),g=o(c,l,d).trim(),h=await M(d,{root:true},g);await S(d,h),n.push({fromTool:"windsurf",fromPath:l,toPath:`${ri}/_root.md`,feature:"rules"});}if(c===null){let d=join(t,Er),g=await I(d);if(g!==null){await R(a);let h=join(a,"_root.md"),C=o(s(g,d,h),d,h).trim(),O=await M(h,{root:true},C);await S(h,O),n.push({fromTool:"windsurf",fromPath:d,toPath:`${ri}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await tt({srcDir:t,destDir:a,extensions:["AGENTS.md"],fromTool:"windsurf",normalize:o,mapEntry:i(async({srcPath:d,normalizeTo:g})=>{let h=relative(t,dirname(d)).replace(/\\/g,"/");if(!h||h==="."||basename(d)!=="AGENTS.md")return null;let C=h.replace(/\//g,"-");if(!ll(h))return await ce(join(a,`${C}.md`)),null;let O=join(a,`${C}.md`);return {destPath:O,toPath:`${ri}/${C}.md`,feature:"rules",content:await M(O,{root:false,globs:[`${h}/**`]},g(O))}},"mapEntry")}));let m=join(t,Hn);n.push(...await tt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:o,mapEntry:i(async({relativePath:d,normalizeTo:g})=>{if(d==="_root.md"&&c!==null)return null;let h=join(a,d),{frontmatter:C,body:O}=E(g(h)),_={...C};return typeof _.glob=="string"&&_.glob.trim()&&(_.globs=[_.glob],delete _.glob),{destPath:h,toPath:`${ri}/${d}`,feature:"rules",content:await M(h,{..._,root:false},O)}},"mapEntry")}));let p=join(t,UR),u=await I(p);if((u===null||!u.trim())&&(p=join(t,Qs),u=await I(p)),u!==null&&u.trim()){let d=u.split(/\r?\n/),g=[];for(let h of d){let C=h.trim();C&&!C.startsWith("#")&&g.push(C);}if(g.length>0){await R(join(t,".agentsmesh"));let h=join(t,pd);await S(h,g.join(`
|
|
121
|
+
`)),n.push({fromTool:"windsurf",fromPath:p,toPath:pd,feature:"ignore"});}}return await tk(t,n,o),await rk(t,n,o),await sk(t,n),await ik(t,n),n}var Od=f(()=>{Ct();A();v();Y();Ne();hs();Bt();ek();nk();ak();i(Nc,"importFromWindsurf");});function lk(t,e,r){let n=[],{rules:o}=t;o.length>0&&(o.some(l=>l.root)||n.push({level:"warning",file:relative(e,o[0].source),target:kr,message:"Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."}));let s=[];return t.permissions&&(t.permissions.allow.length>0||t.permissions.deny.length>0)&&s.push("permissions"),s.length>0&&n.push({level:"warning",file:".agentsmesh",target:kr,message:`Windsurf cannot project these features yet: ${s.join(", ")}.`}),n}var ck=f(()=>{Bt();i(lk,"lintRules");});function mk(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>B(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function pk(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[B(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var uk=f(()=>{$t();i(mk,"lintCommands");i(pk,"lintMcp");});function bD(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 PD,xD,TD,ND,dk,fk=f(()=>{qR();ro();Bt();He();Od();ck();uk();vt();ms();ht();i(bD,"directoryScopedRuleDir");PD={name:"windsurf",primaryRootInstructionPath:Er,generateRules:fd,generateCommands:hd,generateAgents:yd,generateSkills:Sd,generateMcp:Id,generateHooks:_d,generateIgnore:gd,importFrom:Nc},xD={rootInstructionPath:Er,extraRuleOutputPaths(t){if(t.root)return [Er];let e=bD(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:Je,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 `${Hn}/${t}.md`},commandPath(t,e){return `${zn}/${t}.md`},agentPath(t,e){return ae(e,"windsurf")?`.windsurf/skills/${Z(t)}/SKILL.md`:null}}},TD={rootInstructionPath:ni,skillDir:oi,managedOutputs:{dirs:[oi,Sa,WR],files:[ni,bc,Pc,xc]},rewriteGeneratedPath(t){return t===Er?ni:t.startsWith(`${Hn}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${Je}/`)?t.replace(`${Je}/`,`${oi}/`):t.startsWith(`${zn}/`)?t.replace(`${zn}/`,`${Sa}/`):t===ti?bc:t===ei?Pc:t===Qs?xc:t},mirrorGlobalPath(t,e){return mt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return ni},commandPath(t,e){return `${Sa}/${t}.md`},agentPath(t,e){return ae(e,"windsurf")?`${oi}/${Z(t)}/SKILL.md`:null}}},ND={rules:"native",additionalRules:"partial",commands:be("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},dk={id:"windsurf",generators:PD,capabilities:{rules:"native",additionalRules:"native",commands:be("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:lk,lint:{commands:mk,mcp:pk},project:xD,globalSupport:{capabilities:ND,detectionPaths:[ni,oi,Sa,bc,Pc,xc],layout:TD},buildImportPaths:Lp,detectionPaths:[".windsurfrules",".windsurf"]};});var Wh={};QL(Wh,{BUILTIN_TARGETS:()=>xt,TARGET_IDS:()=>Ot,getBuiltinTargetDefinition:()=>Se,getEffectiveTargetSupportLevel:()=>Dc,getTargetCapabilities:()=>Wn,getTargetDetectionPaths:()=>kd,getTargetLayout:()=>_t,getTargetManagedOutputs:()=>Ed,getTargetPrimaryRootInstructionPath:()=>FD,getTargetSkillDir:()=>Oa,isBuiltinTargetId:()=>un,resolveTargetFeatureGenerator:()=>si,rewriteGeneratedOutputPath:()=>wd});function DD(){return Rd||(Zg(xt),Rd=new Map(xt.map(t=>[t.id,t]))),Rd}function Se(t){return DD().get(t)}function Wn(t,e="project"){let r=Se(t)??rt(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return Yg(n)}function kd(t,e="project"){let r=Se(t)??rt(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function _t(t,e="project"){let r=Se(t)??rt(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function FD(t,e="project"){return _t(t,e)?.rootInstructionPath}function Oa(t,e="project"){return _t(t,e)?.skillDir}function Ed(t,e="project"){return _t(t,e)?.managedOutputs}function wd(t,e,r="project"){let n=_t(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function gk(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!cs(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!ae(r,t.id,true,n):false}function vD(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?cs(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?ae(r,t.id,true,n):false}function Dc(t,e,r,n="project"){let o=Wn(t,n)?.[e]?.level??"none",s=Se(t)??rt(t);return o==="none"&&vD(s,e,r,n)?"embedded":o!=="embedded"?o:gk(s,e,r,n)?"none":o}function si(t,e,r,n="project"){let o=Se(t)??rt(t);if(!o?.generators||gk(o,e,r,n))return;let s=$D[e];return s===null?void 0:s(o.generators)}var xt,Rd,$D,it=f(()=>{ms();ro();wr();Tm();br();Hm();bp();$I();R_();Qp();iu();Cu();Uu();Wu();Hu();Zu();td();rd();id();fk();xt=[pl,Tl,vI,O_,Hl,ql,ac,hc,yc,_c,Rc,Ec,wc,Ac,dk];i(DD,"builtinTargetsMap");i(Se,"getBuiltinTargetDefinition");i(Wn,"getTargetCapabilities");i(kd,"getTargetDetectionPaths");i(_t,"getTargetLayout");i(FD,"getTargetPrimaryRootInstructionPath");i(Oa,"getTargetSkillDir");i(Ed,"getTargetManagedOutputs");i(wd,"rewriteGeneratedOutputPath");i(gk,"isFeatureSuppressedByConversion");i(vD,"isConversionUpgrading");i(Dc,"getEffectiveTargetSupportLevel");$D={rules:i(t=>t.generateRules,"rules"),additionalRules:null,commands:i(t=>t.generateCommands,"commands"),agents:i(t=>t.generateAgents,"agents"),skills:i(t=>t.generateSkills,"skills"),mcp:i(t=>t.generateMcp,"mcp"),permissions:i(t=>t.generatePermissions,"permissions"),hooks:i(t=>t.generateHooks,"hooks"),ignore:i(t=>t.generateIgnore,"ignore")};i(si,"resolveTargetFeatureGenerator");});function BD(t){return typeof t=="string"?t:t.level}function hk(t){return WD.includes(t)}function yk(t,e,r,n){for(let o of KD){let s=BD(e[o.feature]);if(s==="none")continue;let a=typeof t.generators[o.generator]=="function",l=hk(o.feature)&&typeof t.emitScopedSettings=="function";a||l||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${s}" but generators.${o.generator}`+(hk(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function Fc(t){return zD.parse(t)}var ln,Ik,MD,GD,_k,jD,UD,KD,WD,HD,zD,Ld=f(()=>{ln=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()})]),Ik=z$1.object({rules:ln,additionalRules:ln,commands:ln,agents:ln,skills:ln,mcp:ln,hooks:ln,ignore:ln,permissions:ln}),MD=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(),GD=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),_k=z$1.object({paths:GD}).passthrough(),jD=z$1.object({capabilities:Ik,detectionPaths:z$1.array(z$1.string()),layout:_k,scopeExtras:z$1.function().optional()}).passthrough(),UD=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],KD=[{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"}],WD=["mcp","hooks","ignore","permissions"];i(BD,"capabilityLevel");i(hk,"canUseScopedSettings");i(yk,"validateCapabilityImplementations");HD=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:MD,capabilities:Ik,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:_k,globalSupport:jD.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),zD=HD.superRefine((t,e)=>{for(let r of UD)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});yk(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&yk(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});i(Fc,"validateDescriptor");});function VD(){return Ad||(Ad=new Map(xt.map(t=>[t.id,t]))),Ad}function Ck(t){let e=Fc(t);Sk.set(e.id,e);}function rt(t){return Sk.get(t)??VD().get(t)}var Sk,Ad,wr=f(()=>{it();Ld();Sk=new Map;i(VD,"builtinDescriptors");i(Ck,"registerTargetDescriptor");i(rt,"getDescriptor");});async function Ok(t,e,r="project"){let n=new Map,o=rt(t);return o&&await o.buildImportPaths(n,e,r),n}var Rk=f(()=>{wr();i(Ok,"buildImportReferenceMap");});function XD(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 s=o.split("/")[0];s&&s.startsWith(".")&&s.length>1&&n.add(`${s}/`);}return n}function ZD(){let t=new Set([".agentsmesh/"]);for(let e of xt)for(let r of XD(e))t.add(r);return Array.from(t)}function qD(){let t=new Set([...ZD(),...bd.rootRelativePrefixes]),e=new Set([...YD,...bd.meshRootSegments]);return {protectedSchemes:[...JD,...bd.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function vc(){return Pd||(Pd=qD()),Pd}var JD,YD,bd,Pd,kk=f(()=>{it();JD=[/\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],YD=new Set(["skills","rules","commands","agents","packs"]),bd={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};i(XD,"topLevelDotfilePrefixes");i(ZD,"buildDefaultRootRelativePrefixes");i(qD,"rebuild");i(vc,"getLinkFormatRegistry");});function Ye(t){let e=ot(t);return vc().rootRelativePrefixes.some(r=>e.startsWith(r))}function tF(t){let e=ot(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||Le.test(e)||/^[a-zA-Z]:/.test(e)||Ye(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&vc().meshRootSegments.has(r)}function Ra(t,e,r){let n=H(e),o=G(e,e),s=G(e,r),a=ot(t);if(Le.test(t)){let l=G(e,t);return n===win32||l.startsWith(`${o}${n.sep}`)?[l]:[l]}if(n.isAbsolute(t)){let l=G(e,t);return l.startsWith(o)||existsSync(t)?[l]:[G(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let l=G(e,n.join(n.dirname(s),a)),c=Hg(a,o);return c&&c!==l?[l,c]:[l]}if(Ye(a))return [G(e,n.join(o,a))];if(a.includes("/")){let l=G(e,n.join(o,".agentsmesh")),c=tF(a)?G(e,n.join(l,a)):null,m=G(e,n.join(o,a)),p=G(e,n.join(n.dirname(s),a));return c!==null?[c,m,p]:[m,p]}return eF.has(a)?[]:a.includes(".")?[G(e,n.join(n.dirname(s),a))]:[]}function ka(t,e){let r=[e];if(!Bg(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 Ak(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function $c(t){let e=[];for(let r of vc().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(rF))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(nF))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(oF))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var eF,rF,nF,oF,Lk,ii,Vn=f(()=>{Pt();kk();i(Ye,"isRootRelativePathToken");i(tF,"isMeshRootRelativePathToken");eF=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),rF=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,nF=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,oF=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,Lk=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,ii=/(?::(\d+)){1,2}$/;i(Ra,"resolveProjectPath");i(ka,"expandResolvedPaths");i(Ak,"isGlobAdjacent");i($c,"protectedRanges");});function sF(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 bk(t){return sF(t.tokenContext)}function xd(t,e){let r=H(t),n=G(t,t),o=G(t,e);if(o===n)return true;let s=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(s)}function Pk(t){let e=H(t);return G(t,e.join(t,".agentsmesh"))}function Xe(t,e){let r=H(t),n=Pk(t),o=G(t,e);if(o===n)return true;let s=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(s)}function xk(t,e,r){let n=H(t),o=Pk(t),s=G(t,e);if(!Xe(t,s))return null;let a=n.relative(o,s).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function Td(t,e,r){let o=H(t).relative(G(t,t),G(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let s=o.length>0?o:".";return r&&!s.endsWith("/")?`${s}/`:s}function ai(t,e,r){let n=Td(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function Nd(t,e,r,n,o){let s=H(t),a=G(t,t),l=G(t,e),c=G(t,r);if(!xd(t,c))return ai(t,c,n)?.text??null;let m=G(t,s.dirname(l));if(!xd(t,m)&&m!==a)return ai(t,c,n)?.text??null;let p=s.relative(m,c).replace(/\\/g,"/");if(s.isAbsolute(p)||Le.test(p))return Td(t,c,n);let u=G(t,s.join(m,p));return xd(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):Td(t,c,n)}var Dd=f(()=>{Pt();i(sF,"isReadingContext");i(bk,"isReadingContextOptions");i(xd,"isUnderProjectRoot");i(Pk,"agentsMeshRoot");i(Xe,"isUnderAgentsMesh");i(xk,"toAgentsMeshRootRelative");i(Td,"toProjectRootRelative");i(ai,"toProjectRootReference");i(Nd,"formatLinkPathForDestinationLegacy");});function Tk(t,e,r,n,o={}){let s=o.scope??"project",a=G(t,r);if(bk(o)&&Xe(t,e)&&Xe(t,a)){let m=H(t),p=G(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 Nd(t,e,r,n,o);if(s==="global"&&!Xe(t,e))return ai(t,a,n)?.text??null;let l=(()=>{if(Xe(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&Xe(t,G(t,m))?G(t,m):null})();if(!l)return ai(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=xk(t,l,n);return m!==null?m:ai(t,l,n)?.text??null}return Nd(t,e,r,n,o)}var Nk=f(()=>{Vn();Pt();Dd();Dd();i(Tk,"formatLinkPathForDestination");});function Dk(t,e,r,n){let o=H(e),s=ot(t);if(!Ye(s))return null;let a=s.split("/").filter(m=>m.length>0);if(a.length<3)return null;let l=G(e,r),c=o.dirname(l);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=G(e,o.join(c,p));if(u!==l&&n(u))return u}return null}var Fk=f(()=>{Pt();Vn();i(Dk,"resolveByDestinationSuffixStrip");});function vk(t){let e=null,r=false,n=null,o=null,s=null;for(let c of Ra(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of ka(t.projectRoot,c)){let d=G(t.projectRoot,u),g=G(t.projectRoot,t.translatePath(d)),h=t.pathExists(d),C=t.pathExists(g);if(C&&g!==d){e=g,n=d,r=true;break}(h||C)&&m===null&&(m=g,p=d),e===null&&(e=g);}if(!r&&m!==null&&o===null&&(o=m,s=p),r)break}if(!r){let c=Dk(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);c!==null&&(e=c,r=true);}!r&&o!==null&&(e=o,s!==null&&(n=s),r=true);let a=ot(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&ot(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var $k=f(()=>{Pt();Vn();Fk();i(vk,"resolveLinkTarget");});function Mk(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function Gk(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 jk(t){let e=ot(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||Le.test(e)||Ye(e)?false:e.includes("/")}var Uk=f(()=>{Pt();Vn();i(Mk,"isTildeHomeRelativePathToken");i(Gk,"isMarkdownLinkDestinationToken");i(jk,"isRelativePathToken");});function iF(t,e,r){let n=e+r.length;if(t[n]!=="]"||t[n+1]!=="(")return false;let o=n+2,s="";for(;o<t.length;){let a=t[o];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
|
|
122
|
+
`)break;s+=a,o++;}return s===r}function Kk(t,e,r){let n=t.lastIndexOf(`
|
|
117
123
|
`,e-1)+1,o=t.slice(n,e);if(!/^\s*\[[^\]\n]+\]:\s*<?\s*$/.test(o))return false;let s=r<t.length?t[r]:"";return s===""||s===`
|
|
118
|
-
`||s==="\r"||s===">"||s===" "||s===" "||s==='"'||s==="'"||s===":"||s==="#"||s==="?"}function
|
|
119
|
-
`);},warn(t){process.stderr.write(
|
|
120
|
-
`);},error(t){process.stderr.write(
|
|
121
|
-
`);},success(t){process.stdout.write(
|
|
122
|
-
`);},debug(t){process.env.AGENTSMESH_DEBUG==="1"&&process.stdout.write(
|
|
124
|
+
`||s==="\r"||s===">"||s===" "||s===" "||s==='"'||s==="'"||s===":"||s==="#"||s==="?"}function Wk(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:Kk(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 Bk(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:s}=ls(n),a=s.replace(ii,""),l=ot(a),c=e+a.length,m=t[e-1],p=t[r];return Kk(t,e,c)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!Ye(l)&&iF(t,e,n)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?Ye(l)?true:l.includes("/")||l.includes("\\")?l.startsWith("./")||l.startsWith("../")?true:(l.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var Hk=f(()=>{Pt();Vn();i(iF,"markdownBracketLabelDuplicatesDestination");i(Kk,"isMarkdownReferenceDefinitionDestination");i(Wk,"getTokenContext");i(Bk,"shouldRewritePathToken");});function Mc(t){let e=new Set,r=$c(t.content);return {content:t.content.replace(Lk,(o,s,a)=>{if(r.some(([St,Xt])=>s>=St&&s<Xt)||!Bk(a,s,s+o.length,o,t.rewriteBarePathTokens===true)||Mk(a,s,o)||Ak(a,s,s+o.length))return o;let{candidate:l,suffix:c}=ls(o);if(!l)return o;let m=ii.exec(l),p=m?l.slice(0,m.index):l,u=m?m[0]:"";if(!p)return o;let d=Wk(a,s,s+p.length);if(d.role!=="markdown-link-dest"&&Le.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:C}=vk({candidate:p,rawToken:l,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),O=h;if(!C||!g)return g&&e.add(g),o;let _=ot(p),k=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(k&&!_.includes("/")&&!_.includes("\\"))return o;if(O===null){let St=ot(l);if(St.startsWith("agentsmesh/")&&(St=`.${St}`),St.startsWith(".agentsmesh/")||St.includes("/.agentsmesh/")){let Xt=H(t.projectRoot),za=G(t.projectRoot,t.projectRoot),se=St.replace(/^\.\//,"");O=G(t.projectRoot,Xt.join(za,se));}}let D=H(t.projectRoot);if(t.scope==="global"){let St=ot(l),Xt=St.startsWith(".agentsmesh/")||St.includes("/.agentsmesh/"),za=Ye(St)||jk(St),se=O!==null&&Xe(t.projectRoot,O),Hf=Xe(t.projectRoot,g);if(O===g&&!Hf&&!se&&!Xt){let zf=ot(D.relative(t.projectRoot,G(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",qL=(O!==null?ot(D.relative(t.projectRoot,O)):"").split("/").filter(Boolean)[0]??"";if(zf.length>0&&zf===qL)return o}if(!za&&!Xt&&!se&&!Hf)return o}let b=G(t.projectRoot,t.destinationFile),P=G(t.projectRoot,g),J=ot(D.relative(t.projectRoot,b)),j=ot(D.relative(t.projectRoot,P)),W=J.split("/").filter(Boolean)[0]??"",nt=j.split("/").filter(Boolean)[0]??"",Yt=!ot(p).startsWith(".agentsmesh/")&&!k&&W.length>0&&W===nt&&W.startsWith(".")&&W!==".agentsmesh"||d.role==="markdown-link-dest"||Gk(a,s,p),pt=Tk(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||Yt,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:k?null:O,forceRelative:Yt,tokenContext:d,originalToken:p});return pt?`${pt}${u}${c}`:o}),missing:[...e]}}var Fd=f(()=>{Pt();Vn();Nk();$k();Uk();Hk();i(Mc,"rewriteFileLinks");});function Vk(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 s=t.normalize(o);r.includes(s)||r.push(s);}}catch{}return r}async function z(t,e,r="project"){let n=H(e),o=new Map,s=Array.from(new Set([t,...Ot]));for(let c of s){let m=await Ok(c,e,r);for(let[p,u]of m.entries())o.set(p,u);}let a=new Map;for(let[c,m]of o.entries()){let p=n.normalize(n.join(e,m));for(let u of Vk(n,n.join(e,c)))a.set(u,p);}let l=new Set;for(let c of new Set(o.values())){let m=n.normalize(n.join(e,c));l.add(m);for(let p of Vk(n,m))l.add(n.normalize(p));}return (c,m,p)=>Mc({content:c,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:i(u=>a.get(u)??u,"translatePath"),pathExists:i(u=>{let d=n.normalize(u);return a.has(u)||a.has(d)||existsSync(u)||l.has(d)},"pathExists"),explicitCurrentDirLinks:false,rewriteBarePathTokens:true,scope:r,pathIsDirectory:i(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var Ct=f(()=>{Pt();Rk();Fd();br();i(Vk,"pathVariants");i(z,"createImportReferenceNormalizer");});function Yk(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let s of n){if(!s||typeof s!="object")continue;let a=s,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!Ze({...m,type:p}))continue;let u=p==="prompt"?Gt(m)||gt(m):gt(m)||Gt(m),d={matcher:l,type:p,command:u};typeof m.timeout=="number"&&(d.timeout=m.timeout),o.push(d);}}o.length>0&&(e[r]=o);}return e}async function Xk(t,e){let r=join(t,vr),n=await I(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 s=Yk(o);if(Object.keys(s).length===0)return false;let a=stringify(s),l=join(t,ao);return await R(dirname(l)),await S(l,a),e.push({fromTool:"claude-code",fromPath:r,toPath:ao,feature:"hooks"}),true}async function Zk(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(vr)),n=join(t,Gi),o=await I(n);if(!o)return;let s;try{s=JSON.parse(o);}catch{return}if(!e.some(m=>m.feature==="mcp")&&s.mcpServers&&typeof s.mcpServers=="object"){let m=s.mcpServers;await pe(t,Wi,m),e.push({fromTool:"claude-code",fromPath:n,toPath:Wi,feature:"mcp"});}let l=s.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let m=l,p=Array.isArray(m.allow)?m.allow.filter(g=>typeof g=="string"):[],u=Array.isArray(m.deny)?m.deny.filter(g=>typeof g=="string"):[],d=Array.isArray(m.ask)?m.ask.filter(g=>typeof g=="string"):[];if(p.length>0||u.length>0||d.length>0){let g=stringify({allow:p,deny:u,ask:d}),h=join(t,qm);await R(dirname(h)),await S(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:qm,feature:"permissions"});}}let c=s.hooks;if(!r&&c&&typeof c=="object"&&!Array.isArray(c)){let m=Yk(c);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,ao);await R(dirname(u)),await S(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:ao,feature:"hooks"});}}}var qk=f(()=>{we();A();io();$r();i(Yk,"claudeHooksToCanonical");i(Xk,"importClaudeHooksJson");i(Zk,"importSettings");});async function tE(t,e,r){let n=join(t,Mi),o=join(t,Zm),a=(await x(n)).filter(l=>l.endsWith("SKILL.md"));for(let l of a){let c=dirname(l),m=basename(c),p=join(o,m),u=await x(c);for(let d of u){let g=await I(d);if(g===null)continue;let h=relative(c,d),C=join(p,h);await R(dirname(C));let O=r(g,d,C),_=h==="SKILL.md"?E(O):null;await S(C,h==="SKILL.md"?await tr(C,_?.frontmatter??{},_?.body??""):O);let k=`${Zm}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:d,toPath:k,feature:"skills"});}}}var eE=f(()=>{A();v();Y();$r();i(tE,"importClaudeSkills");});async function Nl(t,e={}){let r=e.scope??"project",n=[],o=await z("claude-code",t,r);return n.push(...await et(Tl,t,r,{normalize:o})),await tE(t,n,o),await Xk(t,n),await Zk(t,n),n}var Pp=f(()=>{Ct();qt();qk();eE();bp();i(Nl,"importFromClaudeCode");});function Jf(t){let e=Object.keys(t);return {async route(r,n,o){let s=t[r];if(s){await s(n,o);return}throw new Error(`Unknown command "${r}". Available: ${e.join(", ")}`)},commands:i(()=>[...e],"commands")}}i(Jf,"createRouter");var ts={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"};function tA(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}i(tA,"noColor");function yi(t,e){return tA()?e:`${t}${e}${ts.reset}`}i(yi,"c");function eA(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}i(eA,"pad");var y={info(t){process.stdout.write(yi(ts.cyan,t)+`
|
|
125
|
+
`);},warn(t){process.stderr.write(yi(ts.yellow,"\u26A0 ")+t+`
|
|
126
|
+
`);},error(t){process.stderr.write(yi(ts.red,"\u2717 ")+t+`
|
|
127
|
+
`);},success(t){process.stdout.write(yi(ts.green,"\u2713 ")+t+`
|
|
128
|
+
`);},debug(t){process.env.AGENTSMESH_DEBUG==="1"&&process.stdout.write(yi(ts.cyan,"[debug] ")+t+`
|
|
123
129
|
`);},table(t){if(t.length===0)return;let e=t[0].length,r=[];for(let o=0;o<e;o++){let s=0;for(let a=0;a<t.length;a++){let l=[...t[a][o]].length;l>s&&(s=l);}r[o]=s;}let n="+"+r.map(o=>"-".repeat(o+2)).join("+")+"+";process.stdout.write(n+`
|
|
124
|
-
`);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>
|
|
130
|
+
`);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>eA(l,r[c])).join(" | ")+" |";process.stdout.write(a+`
|
|
125
131
|
`);}process.stdout.write(n+`
|
|
126
|
-
`);}};var
|
|
127
|
-
`)}i(
|
|
132
|
+
`);}};var Yf=[{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"}],Xf=[{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:"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"}]},{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)"}]}];function Zf(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
|
|
133
|
+
`)}i(Zf,"formatFlags");function qf(){let t=Xf.map(e=>`- ${e.name.padEnd(8)} ${e.description}
|
|
128
134
|
Usage: ${e.usage}
|
|
129
|
-
${
|
|
135
|
+
${Zf(e.flags)}`).join(`
|
|
130
136
|
|
|
131
137
|
`);y.info(`agentsmesh <command> [flags]
|
|
132
138
|
|
|
133
139
|
Global flags:
|
|
134
|
-
${
|
|
140
|
+
${Zf(Yf)}
|
|
135
141
|
|
|
136
142
|
Commands:
|
|
137
143
|
${t}
|
|
138
144
|
|
|
139
|
-
Tip: run "agentsmesh <command> --help" for this same command reference.`);}i(
|
|
140
|
-
`);}i(
|
|
141
|
-
`):y.error(t.message),process.exit(1);}i(Dd,"handleError");E();Cs();lr();var jd=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],Jt=z$1.enum(ht),mo=z$1.enum(jd),Os=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(),ZO=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:Jt.optional(),features:z$1.array(mo),path:z$1.string().optional(),pick:Os.optional()}),qO=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),ws=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),QO=z$1.object({commands_to_skills:z$1.object({"codex-cli":ws.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":ws.optional(),cline:ws.optional(),"codex-cli":ws.optional(),windsurf:ws.optional()}).passthrough().optional()}).strict().optional(),tE=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional()}).strict(),ac=z$1.object({version:z$1.literal(1),targets:z$1.array(Jt).default([...ht]),features:z$1.array(mo).default([...jd]),extends:z$1.array(ZO).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:qO.default({strategy:"merge",lock_features:[]}),conversions:QO,plugins:z$1.array(tE).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});var cc="agentsmesh.yaml",rE="agentsmesh.local.yaml";async function nE(t){let e=resolve(t);for(;;){let r=join(e,cc);if(await L(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}i(nE,"findConfigPath");async function oE(t){let e=await I(t);if(e===null)throw new $r(t);let r=parse(e),n=ac.safeParse(r);if(!n.success){let o=n.error.issues.map(s=>s.message);throw new Ji(t,o,{cause:n.error})}return n.data}i(oE,"loadConfig");function lc(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null)continue;let s=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof s=="object"&&s!==null&&!Array.isArray(s)?r[n]=lc(s,o):r[n]=o;}return r}i(lc,"deepMergeObjects");function sE(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=lc(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=lc(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}i(sE,"mergeLocalConfig");async function mc(t){let e=join(t,cc),r=await oE(e),n=join(t,rE),o=await I(n);if(o!==null){let s=parse(o);if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let a=sE(r,s),l=ac.safeParse(a);if(l.success)r=l.data;else {let c=l.error.issues.map(m=>m.message).join("; ");y.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${c}. Using project config instead.`);}}}return {config:r,configDir:t}}i(mc,"loadConfigFromExactDir");async function Bd(t){let e=await nE(t);if(e===null)throw new $r(join(t,cc));return mc(dirname(e))}i(Bd,"loadConfigFromDir");Cs();function Es(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}}i(Es,"resolveScopeContext");async function at(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await Bd(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Es(t,e);try{let{config:n}=await mc(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof $r?new $r(n.path,{cause:n,message:`agentsmesh.yaml not found at ${n.path} (global scope). Run 'agentsmesh init --global' to create it under ~/.agentsmesh, or drop the --global flag to operate on the current project.`}):n}}i(at,"loadScopedConfig");E();E();var pE=promisify(execFile),Kd="repo";async function Zi(t,e,r,n,o){let s="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,l=t.ref??"HEAD",c=o(s,a,l),m=join(n,c),u=join(m,Kd),p=`${m}.tmp`,d=join(p,Kd);if(!r.refresh&&await Hd(u))return fc(u);try{return await rm$1(p,{recursive:!0,force:!0}),await mkdir(p,{recursive:!0}),await fE(dE(t),d),t.ref&&await gE(d,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(p,m),fc(u)}catch(g){if(await rm$1(p,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await Hd(u))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),fc(u);throw g}}i(Zi,"fetchGitRemoteExtend");async function fc(t){return {resolvedPath:t,version:await hE(t)}}i(fc,"readCachedRepo");async function Hd(t){return L(t)}i(Hd,"hasCachedRepo");function dE(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}i(dE,"resolveCloneUrl");async function fE(t,e){await gc(["clone",t,e]);}i(fE,"cloneRepo");async function gE(t,e){await gc(["checkout",e],t);}i(gE,"checkoutRef");async function hE(t){return gc(["rev-parse","HEAD"],t)}i(hE,"getHeadSha");async function gc(t,e){let{stdout:r}=await pE("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}i(gc,"runGit");E();async function Yd(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 s=await globalThis.fetch(n,{headers:o});if(!s.ok)throw new Error(`Failed to resolve latest release for ${t}/${e}: ${s.status} ${s.statusText}`);let a=await s.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}i(Yd,"resolveLatestTag");async function Xd(t,e,r,n,o,s=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,l=r.refresh===true,c=t.tag;if(c==="latest")try{c=await Yd(t.org,t.repo,a);}catch(S){if(!s)throw S;return RE(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,c),u=join(n,m);if(!l&&await L(u)){let S=await hc(u);if(S)return {resolvedPath:join(u,S),version:c}}let p=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,d={};a&&(d.Authorization=`Bearer ${a}`);let g;try{let S=await globalThis.fetch(p,{headers:d,redirect:"follow"});if(!S.ok)throw new Error(`HTTP ${S.status}: ${S.statusText}`);g=await S.arrayBuffer();}catch(S){if(r.allowOfflineFallback!==false&&await L(u)){let D=await hc(u);if(D)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${S instanceof Error?S.message:String(S)}`),{resolvedPath:join(u,D),version:c}}throw S}await rm$1(u,{recursive:true,force:true}),await mkdir(u,{recursive:true});let h=join(u,"archive.tar.gz");await writeFile(h,new Uint8Array(g));try{await Jd.extract({file:h,cwd:u,strict:!0,filter:i((S,w)=>!(_E(S)||w&&"type"in w&&(w.type==="Link"||w.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let R=await hc(u);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(u,R),version:c}}i(Xd,"fetchGithubRemoteExtend");async function hc(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}i(hc,"findExtractTopDir");function Vd(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}i(Vd,"buildGithubCloneUrl");function _E(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}i(_E,"isZipSlipPath");async function RE(t,e,r,n,o,s){let a=s?[Vd(t.org,t.repo,s)]:[Vd(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],l;for(let c of a){let m={url:c};try{return await Zi(m,e,r,n,o)}catch(u){l=u;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}i(RE,"fetchGithubDefaultBranch");function Zd(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 s=n.slice(0,o).trim(),a=n.slice(o+1).trim();return !s||!a?null:[s,a]}i(Zd,"splitSourceRef");function qd(t){let e=Zd(t,"github:","latest");if(!e)return null;let[r,n]=e,o=r.indexOf("/");if(o<0)return null;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !s||!a||!n?null:{org:s,repo:a,tag:n}}i(qd,"parseGithubSource");function Qd(t){let e=Zd(t,"gitlab:");if(!e)return null;let[r,n]=e,o=r.lastIndexOf("/");if(o<0)return null;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !s||!a?null:{namespace:s,project:a,ref:n,cloneUrl:`https://gitlab.com/${s}/${a}.git`}}i(Qd,"parseGitlabSource");function tf(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 s;try{s=new URL(n);}catch{return null}return ["https:","http:","ssh:","file:"].includes(s.protocol)?{url:n,ref:o}:null}i(tf,"parseGitSource");function hn(t){let e=qd(t);if(e)return {kind:"github",...e};let r=Qd(t);if(r)return {kind:"gitlab",...r};let n=tf(t);return n?{kind:"git",...n}:null}i(hn,"parseRemoteSource");function yc(t){return hn(t)!==null}i(yc,"isSupportedRemoteSource");function OE(t){let e=hn(t);return e?e.kind==="github"?uo("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?uo("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):uo("git",e.url,e.ref??"HEAD"):null}i(OE,"cacheKeyFromSource");async function nf(t,e){let r=OE(t);if(!r)return;let n=e??Tt(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}i(nf,"cleanInstallCache");async function of(t,e){let r=t??Tt(),n=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,o;try{o=await readdir(r);}catch{return}let s=Date.now();await Promise.all(o.map(async a=>{let l=join(r,a);try{let{mtimeMs:c}=await stat(l);s-c>n&&await rm$1(l,{recursive:!0,force:!0});}catch{}}));}i(of,"sweepStaleCache");var sf=80;function uo(t,e,r){let n=i(s=>s.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),o;if(t==="github"){let[s,a]=e.split("/",2);s&&a?o=`${n(s)}--${n(a)}--${n(r)}`:o=`${n(t)}__${n(e)}__${n(r)}`;}else o=`${n(t)}__${n(e)}__${n(r)}`;if(o.length>sf){let s=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,sf-18)}--${s}`;}return o}i(uo,"buildCacheKey");function Tt(){let t=process.env.AGENTSMESH_CACHE;return t||join(homedir(),".agentsmesh","cache")}i(Tt,"getCacheDir");async function po(t,e,r={}){let n=hn(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??Tt();return of(o).catch(()=>{}),n.kind==="github"?Xd(n,e,r,o,uo,!t.includes("@")):Zi(n,e,r,o,uo)}i(po,"fetchRemoteExtend");function LE(t){return t.startsWith("http://")||t.startsWith("https://")}i(LE,"isOtherRemoteSource");async function fo(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>yc(o.source))){let o=Tt();await rm$1(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(LE(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(yc(o.source)){let a=await po(o.source,o.name,{cacheDir:Tt(),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 s=resolve(e,o.source);if(!await L(s))throw new Error(`Extend "${o.name}": path does not exist: ${s}. Check extends.source in agentsmesh.yaml.`);n.push({name:o.name,resolvedPath:s,features:[...o.features],target:o.target,path:o.path,pick:o.pick});}return n}i(fo,"resolveExtendPaths");E();F();var FE=["always_on","model_decision","glob","manual"];function lf(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}i(lf,"toStrArray");async function yn(t){let r=(await P(t)).filter(o=>{if(!o.endsWith(".md"))return false;let s=basename(o,".md");return s==="_root"||!s.startsWith("_")}),n=[];for(let o of r){let s=await I(o);if(!s)continue;let{frontmatter:a,body:l}=O(s),m=basename(o,".md")==="_root",u=a.root===true,p=a.trigger,d=typeof p=="string"&&FE.includes(p)?p:void 0,g=a.codex_emit,h=g==="execution"?"execution":g==="advisory"?"advisory":void 0,C=a.codex_instruction==="override"?"override":void 0;n.push({source:o,root:m||u,targets:lf(a.targets),description:typeof a.description=="string"?a.description:"",globs:lf(a.globs),body:l,...d!==void 0&&{trigger:d},...h!==void 0&&{codexEmit:h},...C!==void 0&&{codexInstructionVariant:C}});}return n}i(yn,"parseRules");E();F();function mf(t){return t===true||t==="true"||t===1||t==="1"}i(mf,"toBool");function uf(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):[]}i(uf,"toToolsArray");async function In(t){let r=(await P(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let s=await I(o);if(!s)continue;let{frontmatter:a,body:l}=O(s),c=basename(o,".md"),m=uf(a.allowedTools),u=uf(a["allowed-tools"]),p=m.length>0?m:u;n.push({source:o,name:c,description:typeof a.description=="string"?a.description:"",allowedTools:p,outputStyle:mf(a.outputStyle)||mf(a["output-style"]),body:l});}return n}i(In,"parseCommands");E();F();function Sn(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):[]}i(Sn,"toStrArray");function df(t){return t===true||t==="true"||t===1||t==="1"}i(df,"toBool");function ff(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}i(ff,"toInt");function vE(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}i(vE,"toHooks");async function _n(t){let r=(await P(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let s=await I(o);if(!s)continue;let{frontmatter:a,body:l}=O(s),c=basename(o,".md"),m=Sn(a.tools),u=Sn(a.tools),p=m.length>0?m:u,d=Sn(a.disallowedTools),g=Sn(a["disallowed-tools"]),h=d.length>0?d:g,R=Sn(a.mcpServers),C=Sn(a["mcp-servers"]),S=R.length>0?R:C,w=Sn(a.skills),D=ff(a.maxTurns),b=ff(a["max-turns"]),x=D>0?D:b>0?b:0;n.push({source:o,name:c,description:typeof a.description=="string"?a.description:"",tools:p,disallowedTools:h,model:typeof a.model=="string"?a.model:"",permissionMode:typeof a.permissionMode=="string"?a.permissionMode:typeof a["permission-mode"]=="string"?a["permission-mode"]:"",maxTurns:x,mcpServers:S,hooks:vE(a.hooks),skills:w,memory:typeof a.memory=="string"?a.memory:"",outputStyle:df(a.outputStyle)||df(a["output-style"]),body:l});}return n}i(_n,"parseAgents");E();F();async function GE(t){return await I(t)??""}i(GE,"readContent");var qi="SKILL.md",jE=[".git","node_modules"];function UE(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(UE,"sanitizeSkillName");async function gf(t){let e=await P(t),r=[];for(let n of e){let s=n.slice(t.length+1).replace(/\\/g,"/");if(s===qi||s.endsWith(`/${qi}`))continue;let a=s.split("/")[0];if(jE.some(c=>a===c)||s===".DS_Store"||s.endsWith("/.DS_Store"))continue;let l=await GE(n);r.push({relativePath:s,absolutePath:n,content:l});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}i(gf,"listSupportingFiles");async function hf(t){let e=join(t,qi),r=await I(e);if(!r)return null;let{frontmatter:n,body:o}=O(r),s=await gf(t),a=typeof n.name=="string"?UE(n.name):"";return {source:e,name:a||basename(t),description:typeof n.description=="string"?n.description:"",body:o,supportingFiles:s}}i(hf,"parseSkillDirectory");async function go(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory()||n.name.startsWith("_"))continue;let o=join(t,n.name),s=join(o,qi),a=await I(s);if(!a)continue;let{frontmatter:l,body:c}=O(a),m=await gf(o);r.push({source:s,name:n.name,description:typeof l.description=="string"?l.description:"",body:c,supportingFiles:m});}return r.sort((n,o)=>n.name.localeCompare(o.name))}i(go,"parseSkills");E();function yf(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}i(yf,"parseStringMap");function WE(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=yf(e.env),o=typeof e.description=="string"?e.description:void 0,s=typeof e.url=="string"?e.url:"";if(s)return {...o!==void 0&&{description:o},type:r,url:s,headers:yf(e.headers),env:n};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let l=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[];return {...o!==void 0&&{description:o},type:r,command:a,args:l,env:n}}i(WE,"parseServer");async function Qi(t){let e=await I(t);if(!e)return null;let r;try{r=JSON.parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r.mcpServers;if(n===void 0||typeof n!="object"||n===null)return null;let o={};for(let[s,a]of Object.entries(n)){let l=WE(a);l&&(o[s]=l);}return {mcpServers:o}}i(Qi,"parseMcp");E();function Sc(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}i(Sc,"ensureStringArray");async function ta(t){let e=await I(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=Sc(n.allow),s=Sc(n.deny),a=Sc(n.ask);return {allow:o,deny:s,ask:a}}i(ta,"parsePermissions");E();ce();var HE=["command","prompt"];function zE(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=_c(e);if(!n)return null;let o=typeof e.type=="string"&&HE.includes(e.type)?e.type:void 0,s=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=Ot(e)||void 0;return {matcher:r,command:n,...s!==void 0&&{timeout:s},...o&&{type:o},...a&&{prompt:a}}}i(zE,"toHookEntry");async function ea(t){let e=await I(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n={},o=r;for(let[s,a]of Object.entries(o)){if(!Array.isArray(a))continue;let l=[];for(let c of a){let m=zE(c);m&&l.push(m);}l.length>0&&(n[s]=l);}return n}i(ea,"parseHooks");E();async function ra(t){let e=await I(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),n=[];for(let o of r){let s=o.trim();s===""||s.startsWith("#")||n.push(s);}return n}i(ra,"parseIgnore");E();async function Rn(t){let e=join(t,".agentsmesh"),r=await L(e)?e:t,[n,o,s,a,l,c,m,u]=await Promise.all([yn(join(r,"rules")),In(join(r,"commands")),_n(join(r,"agents")),go(join(r,"skills")),Qi(join(r,"mcp.json")),ta(join(r,"permissions.yaml")),ea(join(r,"hooks.yaml")),ra(join(r,"ignore"))]);return {rules:n,commands:o,agents:s,skills:a,mcp:l,permissions:c,hooks:m,ignore:u}}i(Rn,"loadCanonicalFiles");function Sf(t){return basename(t.source,".md")}i(Sf,"ruleSlug");function ho(t,e){let r=new Map(t.rules.map(u=>[Sf(u),u]));for(let u of e.rules)r.set(Sf(u),u);let n=new Map(t.commands.map(u=>[u.name,u]));for(let u of e.commands)n.set(u.name,u);let o=new Map(t.agents.map(u=>[u.name,u]));for(let u of e.agents)o.set(u.name,u);let s=new Map(t.skills.map(u=>[u.name,u]));for(let u of e.skills)s.set(u.name,u);let a=JE(t.mcp,e.mcp),l=YE(t.permissions,e.permissions),c=XE(t.hooks,e.hooks),m=ZE(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(n.values()),agents:Array.from(o.values()),skills:Array.from(s.values()),mcp:a,permissions:l,hooks:c,ignore:m}}i(ho,"mergeCanonicalFiles");function JE(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}i(JE,"mergeMcp");function YE(t,e){if(!t&&!e)return null;let r=Rc(t?.allow??[],e?.allow??[]),n=Rc(t?.deny??[],e?.deny??[]),o=Rc(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}i(YE,"mergePermissions");function Rc(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}i(Rc,"mergeUniqueStrings");function XE(t,e){if(!t&&!e)return null;let r={},n=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let o of n){let s=e?.[o],a=t?.[o];r[o]=s!==void 0&&s.length>0?s:a??[];}return r}i(XE,"mergeHooks");function ZE(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}i(ZE,"mergeIgnore");E();var _f=[{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"]}];async function na(t){let e=null,r=0;for(let n of _f){let o=0;for(let s of n.paths)await L(join(t,s))&&o++;o>r&&(r=o,e=n.target);}return r>0?e:null}i(na,"detectNativeFormat");var Rf=_f.map(t=>t.paths[0]).filter(t=>t!==void 0);E();ym();lu();Vm();xu();Gm();tp();Cm();jm();Tu();Du();var dL={"claude-code":ba,cursor:el,copilot:za,"gemini-cli":ml,"codex-cli":$a,windsurf:Cl,cline:Ta,continue:Ga,junie:pl,kiro:fl};async function bi(t,e){let r=dL[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}i(bi,"importNativeToCanonical");E();var yp="SKILL.md";async function to(t){if(!await L(t))return false;if(await L(join(t,yp)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await L(join(t,r.name,yp)))return !0}catch{return false}return false}i(to,"isSkillPackLayout");async function xi(t){if(!await L(t))return [];if(await L(join(t,yp))){let e=await hf(t);return e?[e]:[]}return go(t)}i(xi,"loadSkillsAtExtendPath");E();function yL(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(yL,"emptyCanonical");function IL(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}i(IL,"isCanonicalSliceEmpty");async function Al(t){if(!await L(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),s=basename(t).replace(/\.md$/i,"");if(n==="rules")return {sliceRoot:r,implicitPick:{rules:[s]}};if(n==="commands")return {sliceRoot:r,implicitPick:{commands:[s]}};if(n==="agents")return {sliceRoot:r,implicitPick:{agents:[s]}};throw new Error(`Single-file install only supports .md files under rules/, commands/, or agents/. Got: ${t}`)}i(Al,"normalizeSlicePath");async function SL(t){if(basename(t)==="rules")return yn(t);let r=join(t,"rules");return await L(r)?yn(r):[]}i(SL,"parseRulesAt");async function _L(t){if(basename(t)==="commands")return In(t);let r=join(t,"commands");return await L(r)?In(r):[]}i(_L,"parseCommandsAt");async function RL(t){if(basename(t)==="agents")return _n(t);let r=join(t,"agents");return await L(r)?_n(r):[]}i(RL,"parseAgentsAt");async function CL(t){if(await to(t))return xi(t);let e=join(t,"skills");return await to(e)?xi(e):[]}i(CL,"loadSkillsForPartialSlice");async function Tl(t){let e=join(t,".agentsmesh");if(await L(e))return Rn(t);let r=yL();if(r.rules=await SL(t),r.commands=await _L(t),r.agents=await RL(t),r.skills=await CL(t),IL(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}i(Tl,"loadCanonicalSliceAtPath");function kL(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(kL,"emptyCanonical");async function PC(t){let e=t.resolvedPath;if(!t.path){let o=join(e,".agentsmesh");if(!await L(o)){if(await to(e)){let a=await xi(e);return {...kL(),skills:a}}let s=t.target??await na(e);if(!s)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
142
|
-
Expected one of: .agentsmesh/, ${
|
|
145
|
+
Tip: run "agentsmesh <command> --help" for this same command reference.`);}i(qf,"printHelp");var sA=createRequire(import.meta.url),um=dirname(fileURLToPath(import.meta.url)),iA=um.endsWith("dist")?join(um,"..","package.json"):join(um,"..","..","package.json"),tg=sA(iA);function Ii(){return tg.version}i(Ii,"getVersion");function eg(){process.stdout.write(`agentsmesh v${tg.version}
|
|
146
|
+
`);}i(eg,"printVersion");function rg(t,e){e?.verbose&&t.stack?process.stderr.write(t.stack+`
|
|
147
|
+
`):y.error(t.message),process.exit(1);}i(rg,"handleError");A();_i();br();var lg=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],ie=z$1.enum(Ot),rs=z$1.enum(lg),Oi=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(),EA=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:ie.optional(),features:z$1.array(rs),path:z$1.string().optional(),pick:Oi.optional()}),wA=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),Ci=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),LA=z$1.object({commands_to_skills:z$1.object({"codex-cli":Ci.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":Ci.optional(),cline:Ci.optional(),"codex-cli":Ci.optional(),windsurf:Ci.optional()}).passthrough().optional()}).strict().optional(),AA=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional()}).strict(),ym=z$1.object({version:z$1.literal(1),targets:z$1.array(ie).default([...Ot]),features:z$1.array(rs).default([...lg]),extends:z$1.array(EA).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:wA.default({strategy:"merge",lock_features:[]}),conversions:LA,plugins:z$1.array(AA).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});var _m="agentsmesh.yaml",PA="agentsmesh.local.yaml";async function xA(t){let e=resolve(t);for(;;){let r=join(e,_m);if(await F(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}i(xA,"findConfigPath");async function TA(t){let e=await I(t);if(e===null)throw new pn(t);let r=parse(e),n=ym.safeParse(r);if(!n.success){let o=n.error.issues.map(s=>s.message);throw new Va(t,o,{cause:n.error})}return n.data}i(TA,"loadConfig");function Im(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null)continue;let s=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof s=="object"&&s!==null&&!Array.isArray(s)?r[n]=Im(s,o):r[n]=o;}return r}i(Im,"deepMergeObjects");function NA(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=Im(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Im(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}i(NA,"mergeLocalConfig");async function Sm(t){let e=join(t,_m),r=await TA(e),n=join(t,PA),o=await I(n);if(o!==null){let s=parse(o);if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let a=NA(r,s),l=ym.safeParse(a);if(l.success)r=l.data;else {let c=l.error.issues.map(m=>m.message).join("; ");y.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${c}. Using project config instead.`);}}}return {config:r,configDir:t}}i(Sm,"loadConfigFromExactDir");async function pg(t){let e=await xA(t);if(e===null)throw new pn(join(t,_m));return Sm(dirname(e))}i(pg,"loadConfigFromDir");_i();function Ri(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}}i(Ri,"resolveScopeContext");async function ut(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await pg(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Ri(t,e);try{let{config:n}=await Sm(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof pn?new pn(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}}i(ut,"loadScopedConfig");A();A();var jA=promisify(execFile),ug="repo";async function Xa(t,e,r,n,o){let s="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,l=t.ref??"HEAD",c=o(s,a,l),m=join(n,c),p=join(m,ug),u=`${m}.tmp`,d=join(u,ug);if(!r.refresh&&await dg(p))return km(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await KA(UA(t),d),t.ref&&await WA(d,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),km(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await dg(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),km(p);throw g}}i(Xa,"fetchGitRemoteExtend");async function km(t){return {resolvedPath:t,version:await BA(t)}}i(km,"readCachedRepo");async function dg(t){return F(t)}i(dg,"hasCachedRepo");function UA(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}i(UA,"resolveCloneUrl");async function KA(t,e){await Em(["clone",t,e]);}i(KA,"cloneRepo");async function WA(t,e){await Em(["checkout",e],t);}i(WA,"checkoutRef");async function BA(t){return Em(["rev-parse","HEAD"],t)}i(BA,"getHeadSha");async function Em(t,e){let{stdout:r}=await jA("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}i(Em,"runGit");A();async function yg(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 s=await globalThis.fetch(n,{headers:o});if(!s.ok)throw new Error(`Failed to resolve latest release for ${t}/${e}: ${s.status} ${s.statusText}`);let a=await s.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}i(yg,"resolveLatestTag");async function Ig(t,e,r,n,o,s=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,l=r.refresh===true,c=t.tag;if(c==="latest")try{c=await yg(t.org,t.repo,a);}catch(_){if(!s)throw _;return YA(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,c),p=join(n,m);if(!l&&await F(p)){let _=await wm(p);if(_)return {resolvedPath:join(p,_),version:c}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,d={};a&&(d.Authorization=`Bearer ${a}`);let g;try{let _=await globalThis.fetch(u,{headers:d,redirect:"follow"});if(!_.ok)throw new Error(`HTTP ${_.status}: ${_.statusText}`);g=await _.arrayBuffer();}catch(_){if(r.allowOfflineFallback!==false&&await F(p)){let D=await wm(p);if(D)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${_ instanceof Error?_.message:String(_)}`),{resolvedPath:join(p,D),version:c}}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 hg.extract({file:h,cwd:p,strict:!0,filter:i((_,k)=>!(JA(_)||k&&"type"in k&&(k.type==="Link"||k.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let C=await wm(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:c}}i(Ig,"fetchGithubRemoteExtend");async function wm(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}i(wm,"findExtractTopDir");function gg(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}i(gg,"buildGithubCloneUrl");function JA(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}i(JA,"isZipSlipPath");async function YA(t,e,r,n,o,s){let a=s?[gg(t.org,t.repo,s)]:[gg(t.org,t.repo),`ssh://git@github.com/${t.org}/${t.repo}.git`],l;for(let c of a){let m={url:c};try{return await Xa(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}i(YA,"fetchGithubDefaultBranch");function _g(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 s=n.slice(0,o).trim(),a=n.slice(o+1).trim();return !s||!a?null:[s,a]}i(_g,"splitSourceRef");function Sg(t){let e=_g(t,"github:","latest");if(!e)return null;let[r,n]=e,o=r.indexOf("/");if(o<0)return null;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !s||!a||!n?null:{org:s,repo:a,tag:n}}i(Sg,"parseGithubSource");function Cg(t){let e=_g(t,"gitlab:");if(!e)return null;let[r,n]=e,o=r.lastIndexOf("/");if(o<0)return null;let s=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !s||!a?null:{namespace:s,project:a,ref:n,cloneUrl:`https://gitlab.com/${s}/${a}.git`}}i(Cg,"parseGitlabSource");function Og(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 s;try{s=new URL(n);}catch{return null}return ["https:","http:","ssh:","file:"].includes(s.protocol)?{url:n,ref:o}:null}i(Og,"parseGitSource");function Xn(t){let e=Sg(t);if(e)return {kind:"github",...e};let r=Cg(t);if(r)return {kind:"gitlab",...r};let n=Og(t);return n?{kind:"git",...n}:null}i(Xn,"parseRemoteSource");function Lm(t){return Xn(t)!==null}i(Lm,"isSupportedRemoteSource");function QA(t){let e=Xn(t);return e?e.kind==="github"?ns("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?ns("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):ns("git",e.url,e.ref??"HEAD"):null}i(QA,"cacheKeyFromSource");async function Eg(t,e){let r=QA(t);if(!r)return;let n=e??zt(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}i(Eg,"cleanInstallCache");async function wg(t,e){let r=t??zt(),n=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,o;try{o=await readdir(r);}catch{return}let s=Date.now();await Promise.all(o.map(async a=>{let l=join(r,a);try{let{mtimeMs:c}=await stat(l);s-c>n&&await rm$1(l,{recursive:!0,force:!0});}catch{}}));}i(wg,"sweepStaleCache");var Lg=80;function ns(t,e,r){let n=i(s=>s.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),o;if(t==="github"){let[s,a]=e.split("/",2);s&&a?o=`${n(s)}--${n(a)}--${n(r)}`:o=`${n(t)}__${n(e)}__${n(r)}`;}else o=`${n(t)}__${n(e)}__${n(r)}`;if(o.length>Lg){let s=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,Lg-18)}--${s}`;}return o}i(ns,"buildCacheKey");function zt(){let t=process.env.AGENTSMESH_CACHE;return t||join(homedir(),".agentsmesh","cache")}i(zt,"getCacheDir");async function os(t,e,r={}){let n=Xn(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??zt();return wg(o).catch(()=>{}),n.kind==="github"?Ig(n,e,r,o,ns,!t.includes("@")):Xa(n,e,r,o,ns)}i(os,"fetchRemoteExtend");function ib(t){return t.startsWith("http://")||t.startsWith("https://")}i(ib,"isOtherRemoteSource");async function ss(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Lm(o.source))){let o=zt();await rm$1(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(ib(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(Lm(o.source)){let a=await os(o.source,o.name,{cacheDir:zt(),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 s=resolve(e,o.source);if(!await F(s))throw new Error(`Extend "${o.name}": path does not exist: ${s}. Check extends.source in agentsmesh.yaml.`);n.push({name:o.name,resolvedPath:s,features:[...o.features],target:o.target,path:o.path,pick:o.pick});}return n}i(ss,"resolveExtendPaths");A();v();var cb=["always_on","model_decision","glob","manual"];function bg(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}i(bg,"toStrArray");async function Zn(t){let r=(await x(t)).filter(o=>{if(!o.endsWith(".md"))return false;let s=basename(o,".md");return s==="_root"||!s.startsWith("_")}),n=[];for(let o of r){let s=await I(o);if(!s)continue;let{frontmatter:a,body:l}=E(s),m=basename(o,".md")==="_root",p=a.root===true,u=a.trigger,d=typeof u=="string"&&cb.includes(u)?u:void 0,g=a.codex_emit,h=g==="execution"?"execution":g==="advisory"?"advisory":void 0,O=a.codex_instruction==="override"?"override":void 0;n.push({source:o,root:m||p,targets:bg(a.targets),description:typeof a.description=="string"?a.description:"",globs:bg(a.globs),body:l,...d!==void 0&&{trigger:d},...h!==void 0&&{codexEmit:h},...O!==void 0&&{codexInstructionVariant:O}});}return n}i(Zn,"parseRules");A();v();function xg(t){return t===true||t==="true"||t===1||t==="1"}i(xg,"toBool");function Tg(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):[]}i(Tg,"toToolsArray");async function qn(t){let r=(await x(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let s=await I(o);if(!s)continue;let{frontmatter:a,body:l}=E(s),c=basename(o,".md"),m=Tg(a.allowedTools),p=Tg(a["allowed-tools"]),u=m.length>0?m:p;n.push({source:o,name:c,description:typeof a.description=="string"?a.description:"",allowedTools:u,outputStyle:xg(a.outputStyle)||xg(a["output-style"]),body:l});}return n}i(qn,"parseCommands");A();v();function Qn(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):[]}i(Qn,"toStrArray");function Dg(t){return t===true||t==="true"||t===1||t==="1"}i(Dg,"toBool");function Fg(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}i(Fg,"toInt");function mb(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}i(mb,"toHooks");async function to(t){let r=(await x(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let s=await I(o);if(!s)continue;let{frontmatter:a,body:l}=E(s),c=basename(o,".md"),m=Qn(a.tools),p=Qn(a.tools),u=m.length>0?m:p,d=Qn(a.disallowedTools),g=Qn(a["disallowed-tools"]),h=d.length>0?d:g,C=Qn(a.mcpServers),O=Qn(a["mcp-servers"]),_=C.length>0?C:O,k=Qn(a.skills),D=Fg(a.maxTurns),b=Fg(a["max-turns"]),P=D>0?D:b>0?b:0;n.push({source:o,name:c,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:P,mcpServers:_,hooks:mb(a.hooks),skills:k,memory:typeof a.memory=="string"?a.memory:"",outputStyle:Dg(a.outputStyle)||Dg(a["output-style"]),body:l});}return n}i(to,"parseAgents");A();v();async function db(t){return await I(t)??""}i(db,"readContent");var Za="SKILL.md",fb=[".git","node_modules"];function gb(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(gb,"sanitizeSkillName");async function vg(t){let e=await x(t),r=[];for(let n of e){let s=n.slice(t.length+1).replace(/\\/g,"/");if(s===Za||s.endsWith(`/${Za}`))continue;let a=s.split("/")[0];if(fb.some(c=>a===c)||s===".DS_Store"||s.endsWith("/.DS_Store"))continue;let l=await db(n);r.push({relativePath:s,absolutePath:n,content:l});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}i(vg,"listSupportingFiles");async function $g(t){let e=join(t,Za),r=await I(e);if(!r)return null;let{frontmatter:n,body:o}=E(r),s=await vg(t),a=typeof n.name=="string"?gb(n.name):"";return {source:e,name:a||basename(t),description:typeof n.description=="string"?n.description:"",body:o,supportingFiles:s}}i($g,"parseSkillDirectory");async function is(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory()||n.name.startsWith("_"))continue;let o=join(t,n.name),s=join(o,Za),a=await I(s);if(!a)continue;let{frontmatter:l,body:c}=E(a),m=await vg(o);r.push({source:s,name:n.name,description:typeof l.description=="string"?l.description:"",body:c,supportingFiles:m});}return r.sort((n,o)=>n.name.localeCompare(o.name))}i(is,"parseSkills");A();function Mg(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}i(Mg,"parseStringMap");function hb(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=Mg(e.env),o=typeof e.description=="string"?e.description:void 0,s=typeof e.url=="string"?e.url:"";if(s)return {...o!==void 0&&{description:o},type:r,url:s,headers:Mg(e.headers),env:n};let a=typeof e.command=="string"?e.command:"";if(!a)return null;let l=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[];return {...o!==void 0&&{description:o},type:r,command:a,args:l,env:n}}i(hb,"parseServer");async function qa(t){let e=await I(t);if(!e)return null;let r;try{r=JSON.parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r.mcpServers;if(n===void 0||typeof n!="object"||n===null)return null;let o={};for(let[s,a]of Object.entries(n)){let l=hb(a);l&&(o[s]=l);}return {mcpServers:o}}i(qa,"parseMcp");A();function bm(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}i(bm,"ensureStringArray");async function Qa(t){let e=await I(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=bm(n.allow),s=bm(n.deny),a=bm(n.ask);return {allow:o,deny:s,ask:a}}i(Qa,"parsePermissions");A();we();var _b=["command","prompt"];function Sb(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=Pm(e);if(!n)return null;let o=typeof e.type=="string"&&_b.includes(e.type)?e.type:void 0,s=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=Gt(e)||void 0;return {matcher:r,command:n,...s!==void 0&&{timeout:s},...o&&{type:o},...a&&{prompt:a}}}i(Sb,"toHookEntry");async function tl(t){let e=await I(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n={},o=r;for(let[s,a]of Object.entries(o)){if(!Array.isArray(a))continue;let l=[];for(let c of a){let m=Sb(c);m&&l.push(m);}l.length>0&&(n[s]=l);}return n}i(tl,"parseHooks");A();async function el(t){let e=await I(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),n=[];for(let o of r){let s=o.trim();s===""||s.startsWith("#")||n.push(s);}return n}i(el,"parseIgnore");A();async function eo(t){let e=join(t,".agentsmesh"),r=await F(e)?e:t,[n,o,s,a,l,c,m,p]=await Promise.all([Zn(join(r,"rules")),qn(join(r,"commands")),to(join(r,"agents")),is(join(r,"skills")),qa(join(r,"mcp.json")),Qa(join(r,"permissions.yaml")),tl(join(r,"hooks.yaml")),el(join(r,"ignore"))]);return {rules:n,commands:o,agents:s,skills:a,mcp:l,permissions:c,hooks:m,ignore:p}}i(eo,"loadCanonicalFiles");function jg(t){return basename(t.source,".md")}i(jg,"ruleSlug");function as(t,e){let r=new Map(t.rules.map(p=>[jg(p),p]));for(let p of e.rules)r.set(jg(p),p);let n=new Map(t.commands.map(p=>[p.name,p]));for(let p of e.commands)n.set(p.name,p);let o=new Map(t.agents.map(p=>[p.name,p]));for(let p of e.agents)o.set(p.name,p);let s=new Map(t.skills.map(p=>[p.name,p]));for(let p of e.skills)s.set(p.name,p);let a=Ob(t.mcp,e.mcp),l=Rb(t.permissions,e.permissions),c=kb(t.hooks,e.hooks),m=Eb(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(n.values()),agents:Array.from(o.values()),skills:Array.from(s.values()),mcp:a,permissions:l,hooks:c,ignore:m}}i(as,"mergeCanonicalFiles");function Ob(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}i(Ob,"mergeMcp");function Rb(t,e){if(!t&&!e)return null;let r=xm(t?.allow??[],e?.allow??[]),n=xm(t?.deny??[],e?.deny??[]),o=xm(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}i(Rb,"mergePermissions");function xm(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}i(xm,"mergeUniqueStrings");function kb(t,e){if(!t&&!e)return null;let r={},n=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let o of n){let s=e?.[o],a=t?.[o];r[o]=s!==void 0&&s.length>0?s:a??[];}return r}i(kb,"mergeHooks");function Eb(t,e){let r=new Set(t),n=[...t];for(let o of e)r.has(o)||(r.add(o),n.push(o));return n}i(Eb,"mergeIgnore");A();var Ug=[{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"]}];async function rl(t){let e=null,r=0;for(let n of Ug){let o=0;for(let s of n.paths)await F(join(t,s))&&o++;o>r&&(r=o,e=n.target);}return r>0?e:null}i(rl,"detectNativeFormat");var Kg=Ug.map(t=>t.paths[0]).filter(t=>t!==void 0);A();Pp();Su();su();ju();Zp();Od();Fp();qp();Bu();Qu();Xu();var mF={"claude-code":Nl,cursor:ic,copilot:Zl,"gemini-cli":gc,"codex-cli":Kl,windsurf:Nc,cline:$l,continue:Bl,junie:Ic,kiro:kc,"kilo-code":Oc};async function wa(t,e){let r=mF[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}i(wa,"importNativeToCanonical");A();var Gd="SKILL.md";async function Vo(t){if(!await F(t))return false;if(await F(join(t,Gd)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await F(join(t,r.name,Gd)))return !0}catch{return false}return false}i(Vo,"isSkillPackLayout");async function La(t){if(!await F(t))return [];if(await F(join(t,Gd))){let e=await $g(t);return e?[e]:[]}return is(t)}i(La,"loadSkillsAtExtendPath");A();function fF(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(fF,"emptyCanonical");function gF(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}i(gF,"isCanonicalSliceEmpty");async function jc(t){if(!await F(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),s=basename(t).replace(/\.md$/i,"");if(n==="rules")return {sliceRoot:r,implicitPick:{rules:[s]}};if(n==="commands")return {sliceRoot:r,implicitPick:{commands:[s]}};if(n==="agents")return {sliceRoot:r,implicitPick:{agents:[s]}};throw new Error(`Single-file install only supports .md files under rules/, commands/, or agents/. Got: ${t}`)}i(jc,"normalizeSlicePath");async function hF(t){if(basename(t)==="rules")return Zn(t);let r=join(t,"rules");return await F(r)?Zn(r):[]}i(hF,"parseRulesAt");async function yF(t){if(basename(t)==="commands")return qn(t);let r=join(t,"commands");return await F(r)?qn(r):[]}i(yF,"parseCommandsAt");async function IF(t){if(basename(t)==="agents")return to(t);let r=join(t,"agents");return await F(r)?to(r):[]}i(IF,"parseAgentsAt");async function _F(t){if(await Vo(t))return La(t);let e=join(t,"skills");return await Vo(e)?La(e):[]}i(_F,"loadSkillsForPartialSlice");async function Uc(t){let e=join(t,".agentsmesh");if(await F(e))return eo(t);let r=fF();if(r.rules=await hF(t),r.commands=await yF(t),r.agents=await IF(t),r.skills=await _F(t),gF(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}i(Uc,"loadCanonicalSliceAtPath");function SF(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(SF,"emptyCanonical");async function rE(t){let e=t.resolvedPath;if(!t.path){let o=join(e,".agentsmesh");if(!await F(o)){if(await Vo(e)){let a=await La(e);return {...SF(),skills:a}}let s=t.target??await rl(e);if(!s)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
148
|
+
Expected one of: .agentsmesh/, ${Kg.join(", ")}.`);y.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${s} format, importing to .agentsmesh/...`),await wa(e,s);}return eo(e)}let r=join(e,t.path);if(!await F(r))throw new Error(`Extend "${t.name}": path does not exist: ${r}`);if(t.target){let o=join(e,".agentsmesh");return await F(o)||(y.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await wa(e,t.target)),eo(e)}let{sliceRoot:n}=await jc(r);try{return await Uc(n)}catch(o){let s=o instanceof Error?o.message:String(o),a=new Error(`Extend "${t.name}": ${s}`);throw o instanceof Error&&(a.cause=o),a}}i(rE,"loadCanonicalForExtend");function Kc(t,e,r,n){if(!r)return t;let o={...t};if(r.skills?.length&&e.includes("skills")){let s=new Set(r.skills),a=o.skills;o={...o,skills:a.filter(l=>s.has(l.name))};for(let l of r.skills)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in skills from extend "${n}".`);}if(r.commands?.length&&e.includes("commands")){let s=new Set(r.commands),a=o.commands;o={...o,commands:a.filter(l=>s.has(l.name))};for(let l of r.commands)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in commands from extend "${n}".`);}if(r.agents?.length&&e.includes("agents")){let s=new Set(r.agents),a=o.agents;o={...o,agents:a.filter(l=>s.has(l.name))};for(let l of r.agents)a.some(c=>c.name===l)||y.warn(`[agentsmesh] pick name "${l}" not found in agents from extend "${n}".`);}if(r.rules?.length&&e.includes("rules")){let s=new Set(r.rules),a=o.rules,l=i(c=>basename(c).replace(/\.md$/i,""),"stem");o={...o,rules:a.filter(c=>s.has(l(c.source)))};for(let c of r.rules)a.some(m=>l(m.source)===c)||y.warn(`[agentsmesh] pick name "${c}" not found in rules from extend "${n}".`);}return o}i(Kc,"applyExtendPick");A();var RF=["rules","commands","agents","skills"],li=z$1.enum(RF);var kF=z$1.enum(["github","gitlab","git","local"]),nE=z$1.object({name:z$1.string().min(1),source:z$1.string().min(1),version:z$1.string().optional(),source_kind:kF,installed_at:z$1.string(),updated_at:z$1.string(),features:z$1.array(rs).min(1),pick:Oi.optional(),target:ie.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:li.optional(),content_hash:z$1.string()});function oE(t){let e=Xn(t);return e?e.kind==="github"?`github:${e.org}/${e.repo}`:e.kind==="gitlab"?`gitlab:${e.namespace}/${e.project}`:`git+${e.url}`:t.trim()}i(oE,"sourceIdentity");function wF(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}i(wF,"sameFeatures");async function Wc(t){let e=join(t,"pack.yaml"),r=await I(e);if(r===null)return null;try{let n=parse(r);return nE.parse(n)}catch{return null}}i(Wc,"readPackMetadata");async function iE(t,e,r){if(!await F(t))return null;let n=oE(e),o;try{o=await readdir(t,{withFileTypes:!0});}catch{return null}for(let s of o){if(!s.isDirectory())continue;let a=join(t,s.name),l=await Wc(a);if(l&&oE(l.source)===n&&l.target===r.target&&l.as===r.as&&wF(l.features,r.features))return {meta:l,packDir:a,name:l.name}}return null}i(iE,"findExistingPack");async function Bc(t){if(!await F(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),s=await Wc(o);s&&r.push({meta:s,packDir:o,name:s.name});}return r}i(Bc,"listPacks");function aE(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(aE,"emptyCanonical");async function LF(t){let[e,r,n,o,s,a,l,c]=await Promise.all([Zn(join(t,"rules")),qn(join(t,"commands")),to(join(t,"agents")),is(join(t,"skills")),qa(join(t,"mcp.json")),Qa(join(t,"permissions.yaml")),tl(join(t,"hooks.yaml")),el(join(t,"ignore"))]);return {...aE(),rules:e,commands:r,agents:n,skills:o,mcp:s,permissions:a,hooks:l,ignore:c}}i(LF,"loadPackCanonical");async function lE(t){let e=join(t,"packs"),r=await Bc(e),n=aE();for(let{meta:o,packDir:s}of r){let a=await LF(s),l=Kd(a,o.features),c=Kc(l,o.features,o.pick,o.name);n=as(n,c);}return n}i(lE,"loadPacksCanonical");var bF={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};function Kd(t,e){if(e.length===0)return cE();let r=new Set(e.flatMap(n=>bF[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:[]}}i(Kd,"filterCanonicalByFeatures");function cE(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(cE,"emptyCanonical");async function Oe(t,e,r={},n=join(e,".agentsmesh")){let o=await ss(t,e,{refreshCache:r.refreshRemoteCache===true}),s=cE();for(let c of o){let m=await rE(c),p=Kd(m,c.features),u=Kc(p,c.features,c.pick,c.name);s=as(s,u);}let a=await lE(n);s=as(s,a);let l=await eo(n);return s=as(s,l),{canonical:s,resolvedExtends:o}}i(Oe,"loadCanonicalWithExtends");A();function Pa(t){return createHash("sha256").update(t,"utf8").digest("hex")}i(Pa,"hashContent");async function Hc(t){try{let e=await readFile(t,"utf8");return Pa(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}i(Hc,"hashFile");var Bd=".lock",FF=[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 vF(t){return t.startsWith("packs/")?false:FF.some(e=>e(t))}i(vF,"isCanonical");var $F={rules:i(t=>t.startsWith("rules/"),"rules"),commands:i(t=>t.startsWith("commands/"),"commands"),agents:i(t=>t.startsWith("agents/"),"agents"),skills:i(t=>/^skills\/[^/]+\/.+$/.test(t),"skills"),mcp:i(t=>t==="mcp.json","mcp"),permissions:i(t=>t==="permissions.yaml","permissions"),hooks:i(t=>t==="hooks.yaml","hooks"),ignore:i(t=>t==="ignore","ignore")};async function zc(t){let e=join(t,Bd),r=await I(e);if(r===null)return null;try{let n=parse(r);return !n||typeof n!="object"?null:{generatedAt:String(n.generated_at??""),generatedBy:String(n.generated_by??""),libVersion:String(n.lib_version??""),checksums:n.checksums&&typeof n.checksums=="object"?n.checksums:{},extends:n.extends&&typeof n.extends=="object"?n.extends:{},packs:n.packs&&typeof n.packs=="object"?n.packs:{}}}catch{return null}}i(zc,"readLock");async function xa(t,e){let r=join(t,Bd),n={generated_at:e.generatedAt,generated_by:e.generatedBy,lib_version:e.libVersion,checksums:e.checksums,extends:e.extends,packs:e.packs},o=`# Auto-generated. DO NOT EDIT MANUALLY.
|
|
143
149
|
# Tracks the state of all config files for team conflict resolution.
|
|
144
150
|
|
|
145
|
-
`+stringify(n);await
|
|
146
|
-
`),a=Ti(s),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}i(eo,"buildExtendChecksums");rt();sr();function UL(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}i(UL,"addDirectoryMapping");function $C(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)UL(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}i($C,"addSkillDirectoryMappings");rt();function MC(t,e,r="project"){let n=dt(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)}i(MC,"ruleTargetPath");function GC(t,e,r,n="project"){let o=dt(t,n);return o?o.paths.commandPath(e,r):null}i(GC,"commandTargetPath");function jC(t,e,r,n="project"){let o=dt(t,n);return o?o.paths.agentPath(e,r):null}i(jC,"agentTargetPath");wt();pt();Pt();rt();function KL(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}i(KL,"addDirectoryMapping");function Di(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=MC(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=GC(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=jC(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let s=wi(t,n);if(!s)return o;for(let a of e.skills){KL(o,`.agentsmesh/skills/${a.name}`,`${s}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${s}/${a.name}/SKILL.md`);for(let l of a.supportingFiles){let c=l.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${c}`,u=`${s}/${a.name}/${c}`;o.set(m,u),$C(o,m,u);}}return o}i(Di,"buildReferenceMap");lr();var ro="AGENTS.md";function HL(t){return t.target===ks&&t.path.endsWith(ro)}i(HL,"isCodexAgents");function UC(t){return t.target==="windsurf"&&t.path.endsWith(ro)}i(UC,"isWindsurfAgents");function WC(t){return t.target==="cline"&&t.path.endsWith(ro)}i(WC,"isClineAgents");function kp(t){return t.target==="cursor"&&t.path.endsWith(ro)}i(kp,"isCursorAgents");function wp(t){return t.target==="gemini-cli"&&t.path.endsWith(ro)}i(wp,"isGeminiAgents");function zL(t){return t.target==="kiro"&&t.path.endsWith(ro)}i(zL,"isKiroAgents");function VL(t){return kp(t)||wp(t)}i(VL,"isCompatibilityAgents");function Gl(t,e,r,n){let o=n.get(t);if(o)return o;let s=new Map;for(let[a,l]of Di(t,e,r))s.has(l)||s.set(l,a);return n.set(t,s),s}i(Gl,"reverseReferenceMap");function jl(t,e){let r=[...e.entries()].sort(([o],[s])=>s.length-o.length),n=t;for(let[o,s]of r)n=n.split(o).join(s);return n}i(jl,"normalizeContent");function JL(t,e,r,n,o){let s=Gl(t.target,r,n,o),a=Gl(e.target,r,n,o);return jl(t.content,s)===jl(e.content,a)}i(JL,"hasEquivalentCanonicalContent");function YL(t,e,r,n,o){let s=Gl(t.target,r,n,o),a=Gl(e.target,r,n,o),l=jl(t.content,s).trim(),c=jl(e.content,a).trim();return l.length>c.length&&l.includes(c)}i(YL,"hasCanonicalSupersetContent");function BC(t,e,r){let n=new Map;for(let a of t){if(!a.path.endsWith(ro))continue;let l=n.get(a.path)??new Set;l.add(a.target),n.set(a.path,l);}let o=new Map;for(let a of t)HL(a)&&o.set(a.path,a);let s=new Map;return t.filter(a=>{if(kp(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"))return false}if(wp(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!UC(a)&&!WC(a)&&!kp(a)&&!wp(a)&&!zL(a))return true;let l=o.get(a.path);return l?VL(a)||UC(a)||WC(a)?false:!(JL(l,a,e,r,s)||YL(l,a,e,r,s)):true})}i(BC,"preferEquivalentCodexAgents");Nt();dp();Nt();Nt();rt();function KC(t,e,r,n){let o=n.normalize(e),s=n.normalize(r);t.set(o,s),t.set(`${o}/`,`${s}/`);}i(KC,"addPackAbsoluteDirMapping");function XL(t){let e=new Set;for(let{relativePath:r}of t){let n=r.replace(/\\/g,"/"),o=dirname(n);for(;o!=="."&&o.length>0;){e.add(o);let s=dirname(o);if(s===o)break;o=s;}}return [...e]}i(XL,"skillSupportingDirPrefixes");function HC(t,e,r,n,o){let s=wi(e,o);if(!s)return;let a=J(n),l=a.join(n,".agentsmesh","packs");for(let c of r.skills){let m=dirname(c.source);if(!m.startsWith(l))continue;let u=a.normalize(a.join(n,s,c.name));KC(t,m,u,a),t.set(a.normalize(c.source),a.normalize(a.join(u,"SKILL.md")));for(let p of c.supportingFiles){let d=a.normalize(a.join(u,p.relativePath));t.set(a.normalize(p.absolutePath),d);}for(let p of XL(c.supportingFiles))KC(t,a.join(m,p),a.join(u,p),a);}}i(HC,"addPackSkillArtifactMappings");Nt();function ZL(t){return `.agentsmesh/rules/${basename(t.source)}`}i(ZL,"canonicalRulePath");function qL(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}i(qL,"copilotInstructionsPath");function VC(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let s=J(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(s.normalize(s.join(r,ZL(a))),s.normalize(s.join(r,qL(a))));}i(VC,"applyCopilotInstructionArtifactRefs");rt();function Ul(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}i(Ul,"getAdditionalRootDecorationPaths");function JC(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"}i(JC,"resolveRewriteFamilyId");function Ep(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}i(Ep,"pushUnique");function YC(t,e,r,n){let o=[],s=r.get(`.agentsmesh/rules/${basename(e.source)}`);Ep(o,s);let a=dt(t,n);if(e.root)for(let l of Ul(a))Ep(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])Ep(o,l);return o}i(YC,"extraRuleOutputPaths");rt();function XC(t,e,r,n,o,s){let a=dt(t,e);if(!a?.mirrorGlobalPath)return;let l=a.mirrorGlobalPath(r,s??[]),c=l===null?[]:Array.isArray(l)?l:[l];for(let m of c)m!==r&&o.set(m,n);}i(XC,"addSkillMirrorSourceEntry");function tN(t){return `.agentsmesh/commands/${t.name}.md`}i(tN,"canonicalCommandPath");function eN(t){return `.agentsmesh/agents/${t.name}.md`}i(eN,"canonicalAgentPath");function rN(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}i(rN,"canonicalSkillPath");function ZC(t,e,r,n,o,s){let a=s?.scope??"project",l=J(n),c=new Map([...Di(t,e,r,a)].map(([m,u])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,u))]));return VC(t,c,n,o,e),HC(c,t,e,n,a),c}i(ZC,"buildArtifactPathMap");function qC(t,e,r,n="project",o){let s=Di(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of YC(t,l,s,n))a.set(c,l.source);for(let l of e.commands){let c=s.get(tN(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=s.get(eN(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=s.get(rN(l));c&&(a.set(c,l.source),XC(t,n,c,l.source,a,o));for(let m of l.supportingFiles){let u=`.agentsmesh/skills/${l.name}/${m.relativePath.replace(/\\/g,"/")}`,p=s.get(u);p&&(a.set(p,m.absolutePath),XC(t,n,p,m.absolutePath,a,o));}}return a}i(qC,"buildOutputSourceMap");rt();sr();Cc();function sN(t,e){if(!e)return null;for(let r of e){let n=Z(r);if(n?.sharedArtifacts){for(let[o,s]of Object.entries(n.sharedArtifacts))if(s==="owner"&&t.startsWith(o))return r}}return null}i(sN,"findSharedArtifactOwner");function QC(t,e,r){if(e==="global"){let n=sN(t.path,r);if(n)return n;let o=Ef(t.path);if(o)return o}return t.target}i(QC,"artifactMapTargetForResult");function iN(t,e){return `${t}\0${(e??[]).join(",")}`}i(iN,"sourceMapCacheKey");function bp(t,e){let r=J(t),n=new Set;for(let o of e){let s=r.join(t,o.path);n.add(s);let a=r.dirname(s);for(;a.startsWith(t)&&!n.has(a)&&(n.add(a),a!==t);)a=r.dirname(a);}return n}i(bp,"collectPlannedPaths");function aN(t,e,r){let n=dt(t.target,e),o=JC(n,t.path);if(o!=="default")return `${t.target}:${o}`;let s=QC(t,e,r);return s===t.target?t.target:`${t.target}~via~${s}`}i(aN,"artifactCacheKey");function tk(t,e,r,n,o="project",s){let a=bp(n,t),l=new Map,c=new Map;return t.map(m=>{let u=iN(m.target,s),d=(c.get(u)??(()=>{let S=qC(m.target,e,r,o,s);return c.set(u,S),S})()).get(m.path);if(!d)return m;let g=QC(m,o,s),h=aN(m,o,s),R=l.get(h)??(()=>{let S=ZC(g,e,r,n,m.path,{scope:o});return l.set(h,S),S})(),C=bl({content:m.content,projectRoot:n,sourceFile:d,destinationFile:J(n).join(n,m.path),translatePath:i(S=>R.get(S)??S,"translatePath"),pathExists:i(S=>a.has(S)||existsSync(S),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:i(S=>{try{return statSync(S).isDirectory()}catch{return false}},"pathIsDirectory")});return C.content===m.content?m:{...m,content:C.content}})}i(tk,"rewriteGeneratedReferences");Nt();fn();var cN=/!?\[[^\]]*\]\(([^)]+)\)/g,mN=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function uN(t){return t.endsWith(".md")||t.endsWith(".mdc")}i(uN,"isMarkdownLikeOutput");function pN(t,e){return e.some(([r,n])=>t>=r&&t<n)}i(pN,"isOffsetInRanges");function dN(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}i(dN,"parseMarkdownLinkDestination");function fN(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)}i(fN,"shouldSkipLocalValidation");function gN(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}i(gN,"pathExistsForGenerate");function hN(t,e,r){let o=dN(t).split("#")[0]??"",{candidate:s}=is(o),a=s,l=as.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(fN(c))return [];let m=Oi(c,e,r);if(m.length===0){let p=J(e),d=j(e,r);m=[j(e,p.join(p.dirname(d),c)),j(e,p.join(e,c))];}let u=[];for(let p of m)for(let d of Ei(e,p)){let g=j(e,d);u.includes(g)||u.push(g);}return u}i(hN,"resolveMarkdownLinkTargets");function yN(t,e){let r=bp(e,t),n=[];for(let o of t){if(!uN(o.path))continue;let s=j(e,J(e).join(e,o.path)),a=El(o.content),l=i((c,m)=>{if(pN(m,a))return;let u=hN(c,e,s);u.length!==0&&(u.some(p=>gN(p,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:u}));},"visitDestination");for(let c of o.content.matchAll(cN)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(mN)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}i(yN,"findBrokenMarkdownLinks");function ek(t,e){let r=yN(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:
|
|
151
|
+
`+stringify(n);await S(r,o);}i(xa,"writeLock");async function mn(t){if(!await F(t))return {};let e=await x(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===Bd||!vF(o))continue;let s=await Hc(n);s!==null&&(r[o]=s.startsWith("sha256:")?s:`sha256:${s}`);}return r}i(mn,"buildChecksums");function Vc(t,e,r){if(r.length===0)return [];let n=r.map(a=>$F[a]).filter(a=>a!==void 0);if(n.length===0)return [];let o=new Set([...Object.keys(t),...Object.keys(e)]),s=[];for(let a of o)n.some(l=>l(a))&&t[a]!==e[a]&&s.push(a);return s}i(Vc,"detectLockedFeatureViolations");async function Ta(t){let e=await Bc(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}i(Ta,"buildPackChecksums");async function Jo(t){let e={};for(let r of t){if(r.version!==void 0){e[r.name]=r.version;continue}let n=join(r.resolvedPath,".agentsmesh"),o=await mn(n),s=Object.keys(o).sort().map(c=>`${c}:${o[c]}`).join(`
|
|
152
|
+
`),a=Pa(s),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}i(Jo,"buildExtendChecksums");it();wr();function MF(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}i(MF,"addDirectoryMapping");function mE(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)MF(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}i(mE,"addSkillDirectoryMappings");it();function pE(t,e,r="project"){let n=_t(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)}i(pE,"ruleTargetPath");function uE(t,e,r,n="project"){let o=_t(t,n);return o?o.paths.commandPath(e,r):null}i(uE,"commandTargetPath");function dE(t,e,r,n="project"){let o=_t(t,n);return o?o.paths.agentPath(e,r):null}i(dE,"agentTargetPath");Mt();It();Bt();it();function UF(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}i(UF,"addDirectoryMapping");function Na(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=pE(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=uE(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=dE(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let s=Oa(t,n);if(!s)return o;for(let a of e.skills){UF(o,`.agentsmesh/skills/${a.name}`,`${s}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${s}/${a.name}/SKILL.md`);for(let l of a.supportingFiles){let c=l.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${c}`,p=`${s}/${a.name}/${c}`;o.set(m,p),mE(o,m,p);}}return o}i(Na,"buildReferenceMap");br();var Jn="AGENTS.md";function KF(t){return t.target===Si&&t.path.endsWith(Jn)}i(KF,"isCodexAgents");function fE(t){return t.target==="windsurf"&&t.path.endsWith(Jn)}i(fE,"isWindsurfAgents");function gE(t){return t.target==="cline"&&t.path.endsWith(Jn)}i(gE,"isClineAgents");function Hd(t){return t.target==="cursor"&&t.path.endsWith(Jn)}i(Hd,"isCursorAgents");function zd(t){return t.target==="gemini-cli"&&t.path.endsWith(Jn)}i(zd,"isGeminiAgents");function WF(t){return t.target==="kiro"&&t.path.endsWith(Jn)}i(WF,"isKiroAgents");function BF(t){return t.target==="kilo-code"&&t.path.endsWith(Jn)}i(BF,"isKiloCodeAgents");function HF(t){return Hd(t)||zd(t)}i(HF,"isCompatibilityAgents");function Yc(t,e,r,n){let o=n.get(t);if(o)return o;let s=new Map;for(let[a,l]of Na(t,e,r))s.has(l)||s.set(l,a);return n.set(t,s),s}i(Yc,"reverseReferenceMap");function Xc(t,e){let r=[...e.entries()].sort(([o],[s])=>s.length-o.length),n=t;for(let[o,s]of r)n=n.split(o).join(s);return n}i(Xc,"normalizeContent");function zF(t,e,r,n,o){let s=Yc(t.target,r,n,o),a=Yc(e.target,r,n,o);return Xc(t.content,s)===Xc(e.content,a)}i(zF,"hasEquivalentCanonicalContent");function VF(t,e,r,n,o){let s=Yc(t.target,r,n,o),a=Yc(e.target,r,n,o),l=Xc(t.content,s).trim(),c=Xc(e.content,a).trim();return l.length>c.length&&l.includes(c)}i(VF,"hasCanonicalSupersetContent");function hE(t,e,r){let n=new Map;for(let a of t){if(!a.path.endsWith(Jn))continue;let l=n.get(a.path)??new Set;l.add(a.target),n.set(a.path,l);}let o=new Map;for(let a of t)KF(a)&&o.set(a.path,a);let s=new Map;return t.filter(a=>{if(Hd(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"))return false}if(zd(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!fE(a)&&!gE(a)&&!Hd(a)&&!zd(a)&&!WF(a)&&!BF(a))return true;let l=o.get(a.path);return l?HF(a)||fE(a)||gE(a)?false:!(zF(l,a,e,r,s)||VF(l,a,e,r,s)):true})}i(hE,"preferEquivalentCodexAgents");Pt();Fd();Pt();Pt();it();function IE(t,e,r,n){let o=n.normalize(e),s=n.normalize(r);t.set(o,s),t.set(`${o}/`,`${s}/`);}i(IE,"addPackAbsoluteDirMapping");function JF(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 s=posix.dirname(o);if(s===o)break;o=s;}}return [...e]}i(JF,"skillSupportingDirPrefixes");function _E(t,e,r,n,o){let s=Oa(e,o);if(!s)return;let a=H(n),l=a.join(n,".agentsmesh","packs");for(let c of r.skills){let m=a.dirname(c.source);if(!m.startsWith(l))continue;let p=a.normalize(a.join(n,s,c.name));IE(t,m,p,a),t.set(a.normalize(c.source),a.normalize(a.join(p,"SKILL.md")));for(let u of c.supportingFiles){let d=a.normalize(a.join(p,u.relativePath));t.set(a.normalize(u.absolutePath),d);}for(let u of JF(c.supportingFiles))IE(t,a.join(m,u),a.join(p,u),a);}}i(_E,"addPackSkillArtifactMappings");Pt();function YF(t){return `.agentsmesh/rules/${basename(t.source)}`}i(YF,"canonicalRulePath");function XF(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}i(XF,"copilotInstructionsPath");function CE(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let s=H(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(s.normalize(s.join(r,YF(a))),s.normalize(s.join(r,XF(a))));}i(CE,"applyCopilotInstructionArtifactRefs");it();function Zc(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}i(Zc,"getAdditionalRootDecorationPaths");function OE(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"}i(OE,"resolveRewriteFamilyId");function Vd(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}i(Vd,"pushUnique");function RE(t,e,r,n){let o=[],s=r.get(`.agentsmesh/rules/${basename(e.source)}`);Vd(o,s);let a=_t(t,n);if(e.root)for(let l of Zc(a))Vd(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])Vd(o,l);return o}i(RE,"extraRuleOutputPaths");it();function kE(t,e,r,n,o,s){let a=_t(t,e);if(!a?.mirrorGlobalPath)return;let l=a.mirrorGlobalPath(r,s??[]),c=l===null?[]:Array.isArray(l)?l:[l];for(let m of c)m!==r&&o.set(m,n);}i(kE,"addSkillMirrorSourceEntry");function qF(t){return `.agentsmesh/commands/${t.name}.md`}i(qF,"canonicalCommandPath");function QF(t){return `.agentsmesh/agents/${t.name}.md`}i(QF,"canonicalAgentPath");function tv(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}i(tv,"canonicalSkillPath");function EE(t,e,r,n,o,s){let a=s?.scope??"project",l=H(n),c=new Map([...Na(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return CE(t,c,n,o,e),_E(c,t,e,n,a),c}i(EE,"buildArtifactPathMap");function wE(t,e,r,n="project",o){let s=Na(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of RE(t,l,s,n))a.set(c,l.source);for(let l of e.commands){let c=s.get(qF(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=s.get(QF(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=s.get(tv(l));c&&(a.set(c,l.source),kE(t,n,c,l.source,a,o));for(let m of l.supportingFiles){let p=`.agentsmesh/skills/${l.name}/${m.relativePath.replace(/\\/g,"/")}`,u=s.get(p);u&&(a.set(u,m.absolutePath),kE(t,n,u,m.absolutePath,a,o));}}return a}i(wE,"buildOutputSourceMap");it();wr();Tm();function nv(t,e){if(!e)return null;for(let r of e){let n=rt(r);if(n?.sharedArtifacts){for(let[o,s]of Object.entries(n.sharedArtifacts))if(s==="owner"&&t.startsWith(o))return r}}return null}i(nv,"findSharedArtifactOwner");function LE(t,e,r){if(e==="global"){let n=nv(t.path,r);if(n)return n;let o=Xg(t.path);if(o)return o}return t.target}i(LE,"artifactMapTargetForResult");function ov(t,e){return `${t}\0${(e??[]).join(",")}`}i(ov,"sourceMapCacheKey");function Jd(t,e){let r=H(t),n=new Set;for(let o of e){let s=r.join(t,o.path);n.add(s);let a=r.dirname(s);for(;a.startsWith(t)&&!n.has(a)&&(n.add(a),a!==t);)a=r.dirname(a);}return n}i(Jd,"collectPlannedPaths");function sv(t,e,r){let n=_t(t.target,e),o=OE(n,t.path);if(o!=="default")return `${t.target}:${o}`;let s=LE(t,e,r);return s===t.target?t.target:`${t.target}~via~${s}`}i(sv,"artifactCacheKey");function AE(t,e,r,n,o="project",s){let a=Jd(n,t),l=new Map,c=new Map;return t.map(m=>{let p=ov(m.target,s),d=(c.get(p)??(()=>{let _=wE(m.target,e,r,o,s);return c.set(p,_),_})()).get(m.path);if(!d)return m;let g=LE(m,o,s),h=sv(m,o,s),C=l.get(h)??(()=>{let _=EE(g,e,r,n,m.path,{scope:o});return l.set(h,_),_})(),O=Mc({content:m.content,projectRoot:n,sourceFile:d,destinationFile:H(n).join(n,m.path),translatePath:i(_=>C.get(_)??_,"translatePath"),pathExists:i(_=>a.has(_)||existsSync(_),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:i(_=>{try{return statSync(_).isDirectory()}catch{return false}},"pathIsDirectory")});return O.content===m.content?m:{...m,content:O.content}})}i(AE,"rewriteGeneratedReferences");Pt();Vn();var av=/!?\[[^\]]*\]\(([^)]+)\)/g,lv=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function cv(t){return t.endsWith(".md")||t.endsWith(".mdc")}i(cv,"isMarkdownLikeOutput");function mv(t,e){return e.some(([r,n])=>t>=r&&t<n)}i(mv,"isOffsetInRanges");function pv(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}i(pv,"parseMarkdownLinkDestination");function uv(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)}i(uv,"shouldSkipLocalValidation");function dv(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}i(dv,"pathExistsForGenerate");function fv(t,e,r){let o=pv(t).split("#")[0]??"",{candidate:s}=ls(o),a=s,l=ii.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(uv(c))return [];let m=Ra(c,e,r);if(m.length===0){let u=H(e),d=G(e,r);m=[G(e,u.join(u.dirname(d),c)),G(e,u.join(e,c))];}let p=[];for(let u of m)for(let d of ka(e,u)){let g=G(e,d);p.includes(g)||p.push(g);}return p}i(fv,"resolveMarkdownLinkTargets");function gv(t,e){let r=Jd(e,t),n=[];for(let o of t){if(!cv(o.path))continue;let s=G(e,H(e).join(e,o.path)),a=$c(o.content),l=i((c,m)=>{if(mv(m,a))return;let p=fv(c,e,s);p.length!==0&&(p.some(u=>dv(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:p}));},"visitDestination");for(let c of o.content.matchAll(av)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(lv)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}i(gv,"findBrokenMarkdownLinks");function bE(t,e){let r=gv(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:
|
|
147
153
|
${n.join(`
|
|
148
154
|
`)}
|
|
149
|
-
Fix canonical sources or generators so every local link targets an existing file or folder.`)}i(ek,"validateGeneratedMarkdownLinks");lr();var nk="AGENTS.md";function rk(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}i(rk,"statusRank");function IN(t,e){return rk(e.status)<=rk(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}i(IN,"mergeDuplicateMetadata");function Wl(t){return t.trim()}i(Wl,"trimmedContent");function SN(t,e){if(!t.path.endsWith(nk)||t.path!==e.path)return null;let r=Wl(t.content),n=Wl(e.content);if(!r||!n)return null;let o=r.includes(n),s=n.includes(r);return o===s?null:o?t:e}i(SN,"richerAgentsResult");function _N(t,e){if(!t.path.endsWith(nk)||t.path!==e.path)return null;let r=t.target===ks?t:e.target===ks?e:null,n=r===t?e:t;return r&&Wl(r.content).length>Wl(n.content).length?r:null}i(_N,"richerCodexAgentsResult");function ok(t){let e=[];for(let r of t){let n=e.findIndex(s=>s.path===r.path);if(n===-1){e.push(r);continue}let o=e[n];if(o.content!==r.content){let s=SN(o,r);if(s){e[n]=s;continue}let a=_N(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]=IN(o,r);}return e}i(ok,"resolveOutputCollisions");function sk(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}i(sk,"refreshResultStatus");E();rt();sr();function ak(t,e){return t===null?"created":t!==e?"updated":"unchanged"}i(ak,"computeStatus");function RN(t,e,r){let n=op(t,e,r);if(n!==null)return n;let o=Z(t);if(!o)return null;let s=r==="global"?o.globalSupport?.layout:o.project;return s?(n=s.rewriteGeneratedPath?s.rewriteGeneratedPath(e):e,n):null}i(RN,"resolveGeneratedOutputPath");async function Fi(t,e,r,n,o,s){let a=RN(e,r.path,o);if(a===null)return null;let l=await I(join(n,a)),c=t.findIndex(p=>p.path===a&&p.target===e),m=c>=0?t[c]:void 0,u=s?.mergeContent?.(l,m,r.content,a)??r.content;return c>=0&&t.splice(c,1),t.push({target:e,path:a,content:u,currentContent:l??void 0,status:ak(l,u)}),a}i(Fi,"emitGeneratedOutput");function xp(t,e,r){return {capability:un(t,r)?.[e]??{level:"none"},scope:r}}i(xp,"featureContext");async function no(t,e,r,n,o,s,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let u=xp(c,a,s);for(let p of m(r,u)){let d=await Fi(t,c,p,n,s);if(d===null)continue;let g=dt(c,s);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(d,e),R=h===null?[]:Array.isArray(h)?h:[h];for(let C of R){let S=await I(join(n,C));t.push({target:c,path:C,content:p.content,currentContent:S??void 0,status:ak(S,p.content)});}}}}}i(no,"generateFeature");bc();rt();function CN(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Ul(t)]:[]}i(CN,"rootDecorationPaths");function lk(t,e,r="project"){return t.map(n=>{let o=dt(n.target,r);if(!o)return n;let s=CN(o);if(s.length===0||!s.includes(n.path))return n;let l=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,c=Ff(l);return c===n.content?n:{...n,content:c}})}i(lk,"decoratePrimaryRootInstructions");rt();sr();Au();function Pp(t,e,r,n,o){let a=(ne(t)??Z(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&I_.includes(o)?__(l,n):n}i(Pp,"mergeOutputContent");async function ck(t,e,r,n,o){for(let s of e){let a=ss(s,"permissions",void 0,o)??Z(s)?.generators.generatePermissions;if(a)for(let l of a(r))await Fi(t,s,l,n,o,{mergeContent:i((c,m,u,p)=>Pp(s,c,m,u,p),"mergeContent")});}}i(ck,"generatePermissionsFeature");async function mk(t,e,r,n,o,s){for(let a of e){let l=ss(a,"hooks",s,o)??Z(a)?.generators.generateHooks;if(!l)continue;let c=xp(a,"hooks",o),m=[...l(r,c)],p=(ne(a)??Z(a))?.postProcessHookOutputs;p&&(m=[...await p(n,r,m)]);for(let d of m)await Fi(t,a,d,n,o,{mergeContent:i((g,h,R,C)=>Pp(a,g,h,R,C),"mergeContent")});}}i(mk,"generateHooksFeature");async function uk(t,e,r,n,o){for(let s of e){let l=(ne(s)??Z(s))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await Fi(t,s,m,n,o,{mergeContent:i((u,p,d,g)=>Pp(s,u,p,d,g),"mergeContent")});}}i(uk,"generateScopedSettingsFeature");async function Bl(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:s}=t,a=[...e.targets,...e.pluginTargets??[]],l=s?a.filter(x=>s.includes(x)):a;function c(x,K){return ss(x,K,e,o)}i(c,"resolveGen");let m=e.features.includes("rules"),u=e.features.includes("commands"),p=e.features.includes("agents"),d=e.features.includes("skills"),g=e.features.includes("mcp"),h=e.features.includes("permissions"),R=e.features.includes("hooks"),C=e.features.includes("ignore"),S=[];await no(S,l,r,n,m,o,"rules",x=>c(x,"rules")),await no(S,l,r,n,u,o,"commands",x=>c(x,"commands")),await no(S,l,r,n,p,o,"agents",x=>c(x,"agents")),await no(S,l,r,n,d,o,"skills",x=>c(x,"skills")),await no(S,l,r,n,g,o,"mcp",x=>c(x,"mcp")),h&&await ck(S,l,r,n,o),R&&await mk(S,l,r,n,o,e),await no(S,l,r,n,C,o,"ignore",x=>c(x,"ignore"));let w=new Set(e.features);for(let x of l){let M=(ne(x)??Z(x))?.globalSupport?.scopeExtras;if(M){let W=await M(r,n,o,w);S.push(...W);}}(g||C||R||p||h)&&await uk(S,l,r,n,o);let D=lk(S,r,o),b=tk(D,r,e,n,o,l);return ek(b,n),ok(BC(b.map(sk),r,e))}i(Bl,"generate");E();rt();async function pk(t,e=t){let r=await readdir(t,{withFileTypes:true}),n=[];for(let o of r){let s=join(t,o.name);if(o.isDirectory()){n.push(...await pk(s,e));continue}n.push(relative(e,s).replace(/\\/g,"/"));}return n}i(pk,"listFiles");async function EN(t,e,r){if(r.has(e))return;let n=join(t,e);await L(n)&&await rm$1(n,{recursive:true,force:true});}i(EN,"removeIfStale");async function dk(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let s=np(o,n);if(s){for(let a of s.files)r.add(a);for(let a of s.dirs){let l=join(t.projectRoot,a);if(await L(l))for(let c of await pk(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await EN(t.projectRoot,o,e);}i(dk,"cleanupStaleGeneratedOutputs");E();Cs();var NN=6e4,DN=30,FN=200,vN=2e3;async function Tp(t,e={}){let r=e.retries??DN,n=e.retryDelayMs??FN,o=e.staleMs??NN;await mkdir(dirname(t),{recursive:true});let s=0;for(;;){let a=await $N(t);if(a)return a;let l=await MN(t);if(l!=="young"&&GN(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(s>=r){let c=l==="young"?null:l;throw new Yi(t,UN(c))}s++,await BN(n);}}i(Tp,"acquireProcessLock");async function $N(t){try{await mkdir(t,{recursive:!1});}catch(s){if(s.code==="EEXIST")return null;throw s}let e=join(t,"holder.json"),r={pid:process.pid,started:Date.now(),hostname:yk()};await writeFile(e,JSON.stringify(r),"utf-8");let n=false,o=i(()=>{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(()=>{}));}}i($N,"tryAcquire");async function MN(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return WN(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<vN)return "young"}catch{}return null}}i(MN,"inspectLock");function GN(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==yk()?false:!jN(t.pid)}i(GN,"isStale");function jN(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}i(jN,"isProcessAlive");function UN(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}i(UN,"describeHolder");function WN(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}i(WN,"isLockMetadata");function yk(){return hostname()}i(yk,"getHostname");function BN(t){return new Promise(e=>setTimeout(e,t))}i(BN,"sleep");sp();sr();async function VN(t,e){let{source:r}=t,n;if(r.startsWith("file:")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")){let s=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,s);n=pathToFileURL(a).href;}else n=r;return await import(n)}i(VN,"importPluginModule");function JN(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}i(JN,"extractDescriptors");async function Kl(t,e){let r;try{r=await VN(t,e);}catch(s){throw new Error(`Plugin '${t.source}' failed to import: ${s instanceof Error?s.message:String(s)}`,{cause:s})}let n=JN(r),o=[];for(let s of n)try{let a=wl(s);HR(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}}i(Kl,"loadPlugin");async function Ik(t,e){let r=[];return await Promise.all(t.map(async n=>{try{let o=await Kl(n,e);r.push(o);}catch(o){y.warn(`Plugin '${n.source}' failed to load: ${o instanceof Error?o.message:String(o)}`);}})),r}i(Ik,"loadAllPlugins");async function ie(t,e){t.plugins.length!==0&&await Ik(t.plugins,e);}i(ie,"bootstrapPlugins");rt();function Lp(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let s of t.features){let a,l;switch(s){case "rules":l=e.rules.length,a="rules";break;case "commands":l=e.commands.length,a=l>0?`commands (${l})`:"commands";break;case "agents":l=e.agents.length,a=l>0?`agents (${l})`:"agents";break;case "skills":l=e.skills.length,a=l>0?`skills (${l})`:"skills";break;case "mcp":l=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=l>0?`mcp (${l} servers)`:"mcp";break;case "hooks":l=YN(e.hooks),a=l>0?`hooks (${l})`:"hooks";break;case "ignore":l=e.ignore.length>0?1:0,a="ignore";break;case "permissions":l=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let c={};for(let m of o)c[m]=kl(m,s,t,r);if(n.push({feature:a,count:l,support:c}),s==="rules"){let m=e.rules.filter(u=>!u.root);if(m.length>0){let u={};for(let p of o)u[p]=kl(p,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:u});}}}return n}i(Lp,"buildCompatibilityMatrix");function YN(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}i(YN,"countHooks");var XN={"claude-code":"Claude"};function Sk(t){return XN[t]??t}i(Sk,"matrixColumnLabel");lr();rt();var ZN=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];function _k(t){return Object.fromEntries(ZN.map(e=>[e,Object.fromEntries(ht.map(r=>{let o=un(r,t)?.[e];return [r,o??{level:"none"}]}))]))}i(_k,"buildSupportMatrix");_k("project");_k("global");var Np={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},vi={green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",dim:"\x1B[2m",reset:"\x1B[0m"};function qN(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}i(qN,"noColor");function QN(t,e){return qN()?e:`${t}${e}${vi.reset}`}i(QN,"colorize");var tD={native:vi.green,embedded:vi.blue,partial:vi.yellow,none:vi.dim};function Rk(t){let e=Np[t];return QN(tD[t],e)}i(Rk,"coloredSymbol");function Dp(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=i((M,W)=>r?W:`${M}${W}${n.reset}`,"c"),s=i(M=>M.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=i((M,W)=>{let q=s(M),mt=Math.max(0,W-q);return M+" ".repeat(mt)},"padWithColor"),l=Math.max(12,...e.map(M=>M.length)),c=e.map(M=>Sk(M)),m=Math.max(8,l),u=Math.max(12,...t.map(M=>M.feature.length)),p=i(M=>o(n.dim,"\u250C"+M.map(W=>"\u2500".repeat(W)).join("\u252C")+"\u2510"),"border"),d=i(M=>o(n.dim,"\u251C"+M.map(W=>"\u2500".repeat(W)).join("\u253C")+"\u2524"),"sep"),g=i(M=>o(n.dim,"\u2514"+M.map(W=>"\u2500".repeat(W)).join("\u2534")+"\u2518"),"bottom"),h=[u,...e.map(()=>m)],R=p(h),C=[a(o(n.bold+n.cyan,"Feature"),u),...c.map(M=>a(o(n.bold+n.magenta,M),m))],S=o(n.dim,"\u2502")+C.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),w=d(h),D=t.map(M=>{let W=[a(o(n.cyan,M.feature),u)];for(let q of e){let mt=M.support[q]??"none",et=r?Np[mt]:Rk(mt);W.push(a(` ${et} `,m));}return o(n.dim,"\u2502")+W.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),b=g(h),x=[R,S,w,...D,b];x.push("");let K=[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: ")+K.join(" ")),x.join(`
|
|
150
|
-
`)}i(
|
|
155
|
+
Fix canonical sources or generators so every local link targets an existing file or folder.`)}i(bE,"validateGeneratedMarkdownLinks");br();var xE="AGENTS.md";function PE(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}i(PE,"statusRank");function hv(t,e){return PE(e.status)<=PE(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}i(hv,"mergeDuplicateMetadata");function qc(t){return t.trim()}i(qc,"trimmedContent");function yv(t,e){if(!t.path.endsWith(xE)||t.path!==e.path)return null;let r=qc(t.content),n=qc(e.content);if(!r||!n)return null;let o=r.includes(n),s=n.includes(r);return o===s?null:o?t:e}i(yv,"richerAgentsResult");function Iv(t,e){if(!t.path.endsWith(xE)||t.path!==e.path)return null;let r=t.target===Si?t:e.target===Si?e:null,n=r===t?e:t;return r&&qc(r.content).length>qc(n.content).length?r:null}i(Iv,"richerCodexAgentsResult");function TE(t){let e=[];for(let r of t){let n=e.findIndex(s=>s.path===r.path);if(n===-1){e.push(r);continue}let o=e[n];if(o.content!==r.content){let s=yv(o,r);if(s){e[n]=s;continue}let a=Iv(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]=hv(o,r);}return e}i(TE,"resolveOutputCollisions");function NE(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}i(NE,"refreshResultStatus");A();it();wr();function FE(t,e){return t===null?"created":t!==e?"updated":"unchanged"}i(FE,"computeStatus");function _v(t,e,r){let n=wd(t,e,r);if(n!==null)return n;let o=rt(t);if(!o)return null;let s=r==="global"?o.globalSupport?.layout:o.project;return s?(n=s.rewriteGeneratedPath?s.rewriteGeneratedPath(e):e,n):null}i(_v,"resolveGeneratedOutputPath");async function Da(t,e,r,n,o,s){let a=_v(e,r.path,o);if(a===null)return null;let l=await I(join(n,a)),c=t.findIndex(u=>u.path===a&&u.target===e),m=c>=0?t[c]:void 0,p=s?.mergeContent?.(l,m,r.content,a)??r.content;return c>=0&&t.splice(c,1),t.push({target:e,path:a,content:p,currentContent:l??void 0,status:FE(l,p)}),a}i(Da,"emitGeneratedOutput");function Yd(t,e,r){return {capability:Wn(t,r)?.[e]??{level:"none"},scope:r}}i(Yd,"featureContext");async function Yo(t,e,r,n,o,s,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=Yd(c,a,s);for(let u of m(r,p)){let d=await Da(t,c,u,n,s);if(d===null)continue;let g=_t(c,s);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(d,e),C=h===null?[]:Array.isArray(h)?h:[h];for(let O of C){let _=await I(join(n,O));t.push({target:c,path:O,content:u.content,currentContent:_??void 0,status:FE(_,u.content)});}}}}}i(Yo,"generateFeature");$m();it();function Sv(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Zc(t)]:[]}i(Sv,"rootDecorationPaths");function vE(t,e,r="project"){return t.map(n=>{let o=_t(n.target,r);if(!o)return n;let s=Sv(o);if(s.length===0||!s.includes(n.path))return n;let l=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,c=sh(l);return c===n.content?n:{...n,content:c}})}i(vE,"decoratePrimaryRootInstructions");it();wr();Ku();function Xd(t,e,r,n,o){let a=(Se(t)??rt(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&XC.includes(o)?qC(l,n):n}i(Xd,"mergeOutputContent");async function $E(t,e,r,n,o){for(let s of e){let a=si(s,"permissions",void 0,o)??rt(s)?.generators.generatePermissions;if(a)for(let l of a(r))await Da(t,s,l,n,o,{mergeContent:i((c,m,p,u)=>Xd(s,c,m,p,u),"mergeContent")});}}i($E,"generatePermissionsFeature");async function ME(t,e,r,n,o,s){for(let a of e){let l=si(a,"hooks",s,o)??rt(a)?.generators.generateHooks;if(!l)continue;let c=Yd(a,"hooks",o),m=[...l(r,c)],u=(Se(a)??rt(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let d of m)await Da(t,a,d,n,o,{mergeContent:i((g,h,C,O)=>Xd(a,g,h,C,O),"mergeContent")});}}i(ME,"generateHooksFeature");async function GE(t,e,r,n,o){for(let s of e){let l=(Se(s)??rt(s))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await Da(t,s,m,n,o,{mergeContent:i((p,u,d,g)=>Xd(s,p,u,d,g),"mergeContent")});}}i(GE,"generateScopedSettingsFeature");async function Qc(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:s}=t,a=[...e.targets,...e.pluginTargets??[]],l=s?a.filter(P=>s.includes(P)):a;function c(P,J){return si(P,J,e,o)}i(c,"resolveGen");let m=e.features.includes("rules"),p=e.features.includes("commands"),u=e.features.includes("agents"),d=e.features.includes("skills"),g=e.features.includes("mcp"),h=e.features.includes("permissions"),C=e.features.includes("hooks"),O=e.features.includes("ignore"),_=[];await Yo(_,l,r,n,m,o,"rules",P=>c(P,"rules")),await Yo(_,l,r,n,p,o,"commands",P=>c(P,"commands")),await Yo(_,l,r,n,u,o,"agents",P=>c(P,"agents")),await Yo(_,l,r,n,d,o,"skills",P=>c(P,"skills")),await Yo(_,l,r,n,g,o,"mcp",P=>c(P,"mcp")),h&&await $E(_,l,r,n,o),C&&await ME(_,l,r,n,o,e),await Yo(_,l,r,n,O,o,"ignore",P=>c(P,"ignore"));let k=new Set(e.features);for(let P of l){let j=(Se(P)??rt(P))?.globalSupport?.scopeExtras;if(j){let W=await j(r,n,o,k);_.push(...W);}}(g||O||C||u||h)&&await GE(_,l,r,n,o);let D=vE(_,r,o),b=AE(D,r,e,n,o,l);return bE(b,n),TE(hE(b.map(NE),r,e))}i(Qc,"generate");A();it();async function jE(t,e=t){let r=await readdir(t,{withFileTypes:true}),n=[];for(let o of r){let s=join(t,o.name);if(o.isDirectory()){n.push(...await jE(s,e));continue}n.push(relative(e,s).replace(/\\/g,"/"));}return n}i(jE,"listFiles");async function kv(t,e,r){if(r.has(e))return;let n=join(t,e);await F(n)&&await rm$1(n,{recursive:true,force:true});}i(kv,"removeIfStale");async function UE(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let s=Ed(o,n);if(s){for(let a of s.files)r.add(a);for(let a of s.dirs){let l=join(t.projectRoot,a);if(await F(l))for(let c of await jE(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await kv(t.projectRoot,o,e);}i(UE,"cleanupStaleGeneratedOutputs");A();_i();var xv=6e4,Tv=30,Nv=200,Dv=2e3;async function qd(t,e={}){let r=e.retries??Tv,n=e.retryDelayMs??Nv,o=e.staleMs??xv;await mkdir(dirname(t),{recursive:true});let s=0;for(;;){let a=await Fv(t);if(a)return a;let l=await vv(t);if(l!=="young"&&$v(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(s>=r){let c=l==="young"?null:l;throw new Ja(t,Gv(c))}s++,await Uv(n);}}i(qd,"acquireProcessLock");async function Fv(t){try{await mkdir(t,{recursive:!1});}catch(s){if(s.code==="EEXIST")return null;throw s}let e=join(t,"holder.json"),r={pid:process.pid,started:Date.now(),hostname:HE()};await writeFile(e,JSON.stringify(r),"utf-8");let n=false,o=i(()=>{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(()=>{}));}}i(Fv,"tryAcquire");async function vv(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return jv(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<Dv)return "young"}catch{}return null}}i(vv,"inspectLock");function $v(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==HE()?false:!Mv(t.pid)}i($v,"isStale");function Mv(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}i(Mv,"isProcessAlive");function Gv(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}i(Gv,"describeHolder");function jv(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}i(jv,"isLockMetadata");function HE(){return hostname()}i(HE,"getHostname");function Uv(t){return new Promise(e=>setTimeout(e,t))}i(Uv,"sleep");Ld();wr();async function Hv(t,e){let{source:r}=t,n;if(r.startsWith("file:")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")){let s=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,s);n=pathToFileURL(a).href;}else n=r;return await import(n)}i(Hv,"importPluginModule");function zv(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}i(zv,"extractDescriptors");async function tm(t,e){let r;try{r=await Hv(t,e);}catch(s){throw new Error(`Plugin '${t.source}' failed to import: ${s instanceof Error?s.message:String(s)}`,{cause:s})}let n=zv(r),o=[];for(let s of n)try{let a=Fc(s);Ck(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}}i(tm,"loadPlugin");async function zE(t,e){let r=[];return await Promise.all(t.map(async n=>{try{let o=await tm(n,e);r.push(o);}catch(o){y.warn(`Plugin '${n.source}' failed to load: ${o instanceof Error?o.message:String(o)}`);}})),r}i(zE,"loadAllPlugins");async function Re(t,e){t.plugins.length!==0&&await zE(t.plugins,e);}i(Re,"bootstrapPlugins");it();function Qd(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let s of t.features){let a,l;switch(s){case "rules":l=e.rules.length,a="rules";break;case "commands":l=e.commands.length,a=l>0?`commands (${l})`:"commands";break;case "agents":l=e.agents.length,a=l>0?`agents (${l})`:"agents";break;case "skills":l=e.skills.length,a=l>0?`skills (${l})`:"skills";break;case "mcp":l=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=l>0?`mcp (${l} servers)`:"mcp";break;case "hooks":l=Vv(e.hooks),a=l>0?`hooks (${l})`:"hooks";break;case "ignore":l=e.ignore.length>0?1:0,a="ignore";break;case "permissions":l=e.permissions&&(e.permissions.allow.length>0||e.permissions.deny.length>0)?1:0,a="permissions";break;default:continue}let c={};for(let m of o)c[m]=Dc(m,s,t,r);if(n.push({feature:a,count:l,support:c}),s==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of o)p[u]=Dc(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}i(Qd,"buildCompatibilityMatrix");function Vv(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}i(Vv,"countHooks");var Jv={"claude-code":"Claude"};function VE(t){return Jv[t]??t}i(VE,"matrixColumnLabel");br();it();var Yv=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];function JE(t){return Object.fromEntries(Yv.map(e=>[e,Object.fromEntries(Ot.map(r=>{let o=Wn(r,t)?.[e];return [r,o??{level:"none"}]}))]))}i(JE,"buildSupportMatrix");JE("project");JE("global");var tf={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},Fa={green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",dim:"\x1B[2m",reset:"\x1B[0m"};function Xv(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}i(Xv,"noColor");function Zv(t,e){return Xv()?e:`${t}${e}${Fa.reset}`}i(Zv,"colorize");var qv={native:Fa.green,embedded:Fa.blue,partial:Fa.yellow,none:Fa.dim};function YE(t){let e=tf[t];return Zv(qv[t],e)}i(YE,"coloredSymbol");function ef(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=i((j,W)=>r?W:`${j}${W}${n.reset}`,"c"),s=i(j=>j.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=i((j,W)=>{let nt=s(j),ft=Math.max(0,W-nt);return j+" ".repeat(ft)},"padWithColor"),l=Math.max(12,...e.map(j=>j.length)),c=e.map(j=>VE(j)),m=Math.max(8,l),p=Math.max(12,...t.map(j=>j.feature.length)),u=i(j=>o(n.dim,"\u250C"+j.map(W=>"\u2500".repeat(W)).join("\u252C")+"\u2510"),"border"),d=i(j=>o(n.dim,"\u251C"+j.map(W=>"\u2500".repeat(W)).join("\u253C")+"\u2524"),"sep"),g=i(j=>o(n.dim,"\u2514"+j.map(W=>"\u2500".repeat(W)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],C=u(h),O=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(j=>a(o(n.bold+n.magenta,j),m))],_=o(n.dim,"\u2502")+O.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),k=d(h),D=t.map(j=>{let W=[a(o(n.cyan,j.feature),p)];for(let nt of e){let ft=j.support[nt]??"none",st=r?tf[ft]:YE(ft);W.push(a(` ${st} `,m));}return o(n.dim,"\u2502")+W.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),b=g(h),P=[C,_,k,...D,b];P.push("");let J=[o(n.green,"\u2713")+" = native",o(n.blue,"\u25C6")+" = embedded",o(n.yellow,"\u25D0")+" = partial",o(n.dim,"\u2013")+" = not supported"];return P.push(o(n.bold,"Legend: ")+J.join(" ")),P.join(`
|
|
156
|
+
`)}i(ef,"formatMatrix");function nf(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?"":`
|
|
151
157
|
Per-file details:
|
|
152
158
|
`+e.join(`
|
|
153
159
|
`)+`
|
|
154
|
-
`}i(
|
|
155
|
-
`),t.verbose===true){let d=
|
|
156
|
-
`));}}i(
|
|
157
|
-
`),n=
|
|
160
|
+
`}i(nf,"formatVerboseDetails");async function Xo(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,s=typeof o=="string"&&o?o.split(",").map(d=>d.trim()).filter(Boolean):void 0,{config:a,context:l}=await ut(r,n);await Re(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),m=s??[...a.targets,...a.pluginTargets??[]],p=Qd(a,c,n);if(p.length===0){y.info("No features enabled. Enable features in agentsmesh.yaml.");return}let u=ef(p,m);if(process.stdout.write(u),process.stdout.write(`
|
|
161
|
+
`),t.verbose===true){let d=nf(c);d&&(process.stdout.write(d),process.stdout.write(`
|
|
162
|
+
`));}}i(Xo,"runMatrix");function ZE(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}`)}i(ZE,"ensurePathInsideRoot");function of(t,e){return t==="global"?`~/${e}`:e}i(of,"formatDisplayPath");async function mi(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,s=t["dry-run"]===true,a=t.force===true,l=t.global===true?"global":"project",c=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(b=>b.trim()).filter(Boolean):void 0,{config:u,context:d}=await ut(n,l);await Re(u,n);let g=u.collaboration?.lock_features??[];if(u.collaboration?.strategy==="lock"&&!a&&g.length>0){let b=await zc(d.canonicalDir);if(b!==null){let P=await mn(d.canonicalDir),J=Vc(b.checksums,P,g);if(J.length>0){y.error("Locked feature violation (strategy: lock). Modified files:");for(let j of J)y.error(` ${j}`);throw y.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:h,resolvedExtends:C}=await Oe(u,d.configDir,{refreshRemoteCache:c},d.canonicalDir),O=[...u.targets,...u.pluginTargets??[]];if(p){let b=p.filter(P=>!O.includes(P));if(b.length>0)throw new Error(`Unknown target(s) in --targets: ${b.join(", ")}. Available: ${O.join(", ")}`)}let _=p?O.filter(b=>p.includes(b)):O,k=await Qc({config:u,canonical:h,projectRoot:d.rootBase,scope:l,targetFilter:p});if(k.length===0){if(y.info("No files to generate (no root rule or rules feature disabled)."),o)return y.success("Generated files are in sync."),0;if(!s){let b=await qd(join(d.canonicalDir,".generate.lock"));try{let P=await mn(d.canonicalDir),J=C.length>0?await Jo(C):{},j=await Ta(join(d.canonicalDir,"packs")),W=process.env.USER??process.env.USERNAME??"unknown";await xa(d.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:W,libVersion:Ii(),checksums:P,extends:J,packs:j});try{await gm(zt(),join(d.configDir,".agentsmeshcache"));}catch(nt){y.warn(`Could not create .agentsmeshcache symlink: ${nt instanceof Error?nt.message:String(nt)}`);}}finally{await b();}}return r.printMatrix!==false&&await Xo(t,n),0}if(o){let b=k.filter(P=>P.status!=="unchanged");if(b.length===0)return y.success("Generated files are in sync."),0;for(let P of b)y.error(`[check] ${P.status} ${of(l,P.path)} (${P.target})`);return y.error("Generated files are out of sync. Run 'agentsmesh generate' to update them."),1}let D=s?null:await qd(join(d.canonicalDir,".generate.lock"));try{for(let b of k)if(s)y.info(`[dry-run] ${b.status} ${of(l,b.path)} (${b.target})`);else if(b.status==="created"||b.status==="updated"){let P=ZE(d.rootBase,b.path,b.target);await S(P,b.content),y.success(`${b.status} ${of(l,b.path)}`);}if(!s){let b=k.filter(st=>st.status==="created").length,P=k.filter(st=>st.status==="updated").length,J=k.filter(st=>st.status==="unchanged").length;await UE({projectRoot:d.rootBase,targets:_,expectedPaths:k.map(st=>st.path),scope:l}),b>0||P>0?y.info(`Generated: ${b} created, ${P} updated, ${J} unchanged`):y.info(`Nothing changed. (${J} unchanged)`);let j=await mn(d.canonicalDir),W=C.length>0?await Jo(C):{},nt=await Ta(join(d.canonicalDir,"packs")),ft=process.env.USER??process.env.USERNAME??"unknown";await xa(d.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:ft,libVersion:Ii(),checksums:j,extends:W,packs:nt});try{await gm(zt(),join(d.configDir,".agentsmeshcache"));}catch(st){y.warn(`Could not create .agentsmeshcache symlink: ${st instanceof Error?st.message:String(st)}`);}}}finally{D&&await D();}return r.printMatrix!==false&&await Xo(t,n),0}i(mi,"runGenerate");A();it();br();var t$=["codex-cli"];function qE(){return Ot.filter(t=>!t$.includes(t))}i(qE,"starterInitTargetIds");var e$=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],r$=qE();function em(t,e=r$){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
|
|
163
|
+
`),n=e$.map(o=>` - ${o}`).join(`
|
|
158
164
|
`);return `# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
159
165
|
version: 1
|
|
160
166
|
targets:
|
|
161
167
|
${r}
|
|
162
168
|
features:
|
|
163
169
|
${n}
|
|
164
|
-
`}i(
|
|
170
|
+
`}i(em,"buildConfig");var rm=`---
|
|
165
171
|
root: true
|
|
166
172
|
description: "Project rules"
|
|
167
173
|
---
|
|
@@ -170,7 +176,7 @@ description: "Project rules"
|
|
|
170
176
|
|
|
171
177
|
Add your project-wide instructions here.
|
|
172
178
|
This file is always included in AI tool context and synced to all configured tools.
|
|
173
|
-
`,
|
|
179
|
+
`,sf=`---
|
|
174
180
|
description: "Example contextual rule \u2014 rename and customize"
|
|
175
181
|
# targets: [claude-code, cursor] # limit to specific tools (optional)
|
|
176
182
|
# globs: ["src/**/*.ts"] # activate only for matching files (optional)
|
|
@@ -179,14 +185,14 @@ description: "Example contextual rule \u2014 rename and customize"
|
|
|
179
185
|
# Example Rule
|
|
180
186
|
|
|
181
187
|
Replace this with your coding standards, conventions, or domain-specific guidelines.
|
|
182
|
-
`,
|
|
188
|
+
`,af=`---
|
|
183
189
|
description: "Example command \u2014 rename and customize"
|
|
184
190
|
# allowed-tools: [Read, Grep, Glob, Bash]
|
|
185
191
|
---
|
|
186
192
|
|
|
187
193
|
Describe the task for this command here.
|
|
188
194
|
Commands are invoked on-demand (e.g. /example) with a focused tool set.
|
|
189
|
-
`,
|
|
195
|
+
`,lf=`---
|
|
190
196
|
name: example-agent
|
|
191
197
|
description: "Example subagent \u2014 rename and customize"
|
|
192
198
|
# tools: [Read, Grep, Glob]
|
|
@@ -197,7 +203,7 @@ description: "Example subagent \u2014 rename and customize"
|
|
|
197
203
|
|
|
198
204
|
Describe this agent's role and instructions here.
|
|
199
205
|
Agents are specialized subagents with restricted tools and a specific purpose.
|
|
200
|
-
`,
|
|
206
|
+
`,cf=`---
|
|
201
207
|
name: example-skill
|
|
202
208
|
description: "Example skill \u2014 rename and customize"
|
|
203
209
|
---
|
|
@@ -206,7 +212,7 @@ description: "Example skill \u2014 rename and customize"
|
|
|
206
212
|
|
|
207
213
|
Describe the skill procedure here.
|
|
208
214
|
Skills are reusable multi-step procedures that commands and agents can reference.
|
|
209
|
-
`,
|
|
215
|
+
`,mf=`{
|
|
210
216
|
"mcpServers": {
|
|
211
217
|
// "github": {
|
|
212
218
|
// "type": "stdio",
|
|
@@ -221,7 +227,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
221
227
|
// }
|
|
222
228
|
}
|
|
223
229
|
}
|
|
224
|
-
`,
|
|
230
|
+
`,pf=`# Lifecycle hooks \u2014 run shell commands before/after AI tool use
|
|
225
231
|
# Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
|
|
226
232
|
# Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
|
|
227
233
|
#
|
|
@@ -234,7 +240,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
234
240
|
# - matcher: Edit|Write
|
|
235
241
|
# type: command
|
|
236
242
|
# command: npm test --passWithNoTests
|
|
237
|
-
`,
|
|
243
|
+
`,uf=`# Tool permission allow/deny lists
|
|
238
244
|
#
|
|
239
245
|
# allow:
|
|
240
246
|
# - Bash(npm run:*)
|
|
@@ -250,14 +256,14 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
250
256
|
allow: []
|
|
251
257
|
deny: []
|
|
252
258
|
ask: []
|
|
253
|
-
`,
|
|
259
|
+
`,df=`# Patterns ignored by all configured AI tools (gitignore syntax)
|
|
254
260
|
#
|
|
255
261
|
# node_modules/
|
|
256
262
|
# dist/
|
|
257
263
|
# .env*
|
|
258
264
|
# *.log
|
|
259
265
|
# coverage/
|
|
260
|
-
`,
|
|
266
|
+
`,QE=`# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
261
267
|
# Personal overrides \u2014 NOT committed to git
|
|
262
268
|
# Uncomment and customize for your local setup:
|
|
263
269
|
|
|
@@ -276,25 +282,25 @@ ask: []
|
|
|
276
282
|
# overrides:
|
|
277
283
|
# claude-code:
|
|
278
284
|
# model: opus
|
|
279
|
-
`;
|
|
280
|
-
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=
|
|
285
|
+
`;A();it();function tw(t){let e=[];for(let r of xt)for(let n of kd(r.id,t))e.push({target:r.id,path:n});return e}i(tw,"collectDetectionPaths");function ew(t){let e=new Map;for(let{target:r,path:n}of tw(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}i(ew,"toolIndicators");ew("project");async function rw(t,e="project"){let r=[];for(let{id:n,paths:o}of ew(e))for(let s of o){let a=join(t,s);if(await F(a)){r.push(n);break}}return [...new Set(r)]}i(rw,"detectExistingConfigs");A();function At(t,e){return join(t,e)}i(At,"ab");async function ff(t){return await F(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}i(ff,"countMdFiles");async function o$(t){let e=At(t,"skills");if(!await F(e))return false;let r=await readdir(e,{withFileTypes:true});for(let n of r)if(n.isDirectory()&&!n.name.startsWith("_")&&await F(join(e,n.name,"SKILL.md")))return true;return false}i(o$,"hasAnyImportedSkill");async function gf(t){let e=At(t,"rules");await R(e),await S(join(e,"_root.md"),rm),y.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),sf),y.success("Created .agentsmesh/rules/_example.md");let r=At(t,"commands");await R(r),await S(join(r,"_example.md"),af),y.success("Created .agentsmesh/commands/_example.md");let n=At(t,"agents");await R(n),await S(join(n,"_example.md"),lf),y.success("Created .agentsmesh/agents/_example.md");let o=At(t,join("skills","_example"));await R(o),await S(join(o,"SKILL.md"),cf),y.success("Created .agentsmesh/skills/_example/SKILL.md"),await S(At(t,"mcp.json"),mf),y.success("Created .agentsmesh/mcp.json"),await S(At(t,"hooks.yaml"),pf),y.success("Created .agentsmesh/hooks.yaml"),await S(At(t,"permissions.yaml"),uf),y.success("Created .agentsmesh/permissions.yaml"),await S(At(t,"ignore"),df),y.success("Created .agentsmesh/ignore");}i(gf,"writeScaffoldFull");async function ow(t){let e=At(t,"rules"),r=await ff(e),n=join(e,"_root.md"),o=await F(n);await R(e),r===0?(await S(n,rm),y.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),sf),y.success("Created .agentsmesh/rules/_example.md")):o||(await S(n,rm),y.success("Created .agentsmesh/rules/_root.md"));let s=At(t,"commands");await ff(s)===0&&(await R(s),await S(join(s,"_example.md"),af),y.success("Created .agentsmesh/commands/_example.md"));let a=At(t,"agents");if(await ff(a)===0&&(await R(a),await S(join(a,"_example.md"),lf),y.success("Created .agentsmesh/agents/_example.md")),!await o$(t)){let u=At(t,join("skills","_example"));await R(u),await S(join(u,"SKILL.md"),cf),y.success("Created .agentsmesh/skills/_example/SKILL.md");}let l=At(t,"mcp.json");await F(l)||(await S(l,mf),y.success("Created .agentsmesh/mcp.json"));let c=At(t,"hooks.yaml");await F(c)||(await S(c,pf),y.success("Created .agentsmesh/hooks.yaml"));let m=At(t,"permissions.yaml");await F(m)||(await S(m,uf),y.success("Created .agentsmesh/permissions.yaml"));let p=At(t,"ignore");await F(p)||(await S(p,df),y.success("Created .agentsmesh/ignore"));}i(ow,"writeScaffoldGapFill");var va="agentsmesh.yaml",sw="agentsmesh.local.yaml",i$=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],a$=Object.fromEntries(xt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),iw=xt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function l$(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}i(l$,"isCoveredByExisting");async function c$(t){let e=join(t,".gitignore"),r=await I(e)??"",n=new Set(r.split(`
|
|
286
|
+
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=i$.filter(a=>!l$(a,n));if(o.length===0)return;let s=r.endsWith(`
|
|
281
287
|
`)||r===""?"":`
|
|
282
|
-
`;await
|
|
288
|
+
`;await S(e,r+s+o.join(`
|
|
283
289
|
`)+`
|
|
284
|
-
`);}i(uD,"appendToGitignore");async function Nk(t,e={}){let r=e.global===true?"global":"project",n=Es(t,r),o=join(n.configDir,$i);if(await L(o))throw new Error(`Already initialized. ${$i} exists. Remove it first to re-init.`);let s=await xk(n.rootBase,r),a=r==="global"?s.filter(m=>Lk.includes(m)):s,l=r==="global"?Lk:void 0;if(a.length>0)if(y.info(`Found existing configurations: ${a.join(", ")}`),e.yes){y.info("Auto-importing existing configurations (--yes)...");let m=0;for(let u of a){let p=cD[u];if(!p)continue;let d=await p(n.rootBase,r);for(let g of d){let h=relative(n.rootBase,g.fromPath).replaceAll("\\","/"),R=g.toPath.replaceAll("\\","/");y.success(` ${h} \u2192 ${R}`);}m+=d.length;}m>0&&y.info(`Imported ${m} file(s) from ${a.length} tool(s).`),await Ak(n.canonicalDir),await _(o,Hl(a,l)),y.success(`Created ${$i} (targets: ${a.join(", ")})`);}else y.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),await Vp(n.canonicalDir),await _(o,Hl([],l)),y.success(`Created ${$i}`);else await Vp(n.canonicalDir),await _(o,Hl([],l)),y.success(`Created ${$i}`);let c=join(n.configDir,Tk);await _(c,Ok),y.success(`Created ${Tk}`),r==="project"&&(await uD(t),y.success("Updated .gitignore"));}i(Nk,"runInit");rt();var pD=Object.fromEntries(Ct.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Vl(t){let e=pD[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}i(Vl,"getTargetCatalogEntry");sr();function Dk(t,e,r){for(let n of t){let o=relative(e,n.fromPath);y.success(`${o} \u2192 ${n.toPath}`);}y.info(`Imported ${t.length} file(s). Run 'agentsmesh generate${r==="global"?" --global":""}' to sync to other tools.`);}i(Dk,"formatImportResults");async function Fk(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(),s=t.global===true?"global":"project";if(Mr(o)){let u=Es(r,s),p=Vl(o),d=await p.importFrom(u.rootBase,{scope:s});if(d.length===0){y.info(p.emptyImportMessage);return}Dk(d,u.rootBase,s);return}let a,l;try{({config:a,context:l}=await at(r,s));}catch{throw new Error(`Unknown --from "${n}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${ht.join(", ")}.`)}await ie(a,r);let c=Z(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...ht,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:s});if(m.length===0){y.info(c.emptyImportMessage);return}Dk(m,l.rootBase,s);}i(Fk,"runImport");function $k(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}}i($k,"computeDiff");function Mk(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}i(Mk,"formatDiffSummary");async function Gk(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,s=typeof o=="string"&&o?o.split(",").map(d=>d.trim()).filter(Boolean):void 0,{config:a,context:l}=await at(r,n);await ie(a,r);let{canonical:c}=await se(a,l.configDir,{},l.canonicalDir),m=await Bl({config:a,canonical:c,projectRoot:l.rootBase,scope:n,targetFilter:s});if(m.length===0){y.info("No files to generate (no root rule or rules feature disabled).");return}let{diffs:u,summary:p}=$k(m);for(let d of u)process.stdout.write(d.patch);y.info(Mk(p));}i(Gk,"runDiff");E();sr();Cn();Wt();var fD=[{canonicalKey:"permissions",capabilityKey:"permissions",featureFlag:"permissions",file:".agentsmesh/permissions.yaml",label:"permissions",hasContent:i(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:i(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:i(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:i(t=>t.commands.length>0,"hasContent")},{canonicalKey:"agents",capabilityKey:"agents",featureFlag:"agents",file:".agentsmesh/agents",label:"agents",hasContent:i(t=>t.agents.length>0,"hasContent")},{canonicalKey:"skills",capabilityKey:"skills",featureFlag:"skills",file:".agentsmesh/skills",label:"skills",hasContent:i(t=>t.skills.length>0,"hasContent")},{canonicalKey:"ignore",capabilityKey:"ignore",featureFlag:"ignore",file:".agentsmesh/ignore",label:"ignore patterns",hasContent:i(t=>t.ignore.length>0,"hasContent")}];function jk(t){let e=new Set(t.enabledFeatures),r=[];for(let n of fD)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||ue(t.capabilities[n.capabilityKey]).level!=="none"||r.push(V(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}i(jk,"lintSilentFeatureDrops");Wt();var gD=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function hD(t){let r=t.match(gD)?.groups?.path;return typeof r=="string"?r:null}i(hD,"extractScriptToken");function Uk(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 s=hD(o.command);s&&r.push(V(".agentsmesh/hooks.yaml",t.target,`${t.target} hook command references script "${s}"; 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}i(Uk,"lintHookScriptReferences");Wt();function Wk(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(V(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}i(Wk,"lintRuleScopeInversion");var yD=["node_modules",".git","dist","coverage",".agentsmesh"];async function ID(t){return (await P(t)).filter(n=>{let o=relative(t,n);return !yD.some(s=>o.includes(`/${s}/`)||o.startsWith(`${s}/`))}).map(n=>relative(t,n))}i(ID,"getProjectFiles");async function Kk(t,e,r,n,o={}){let s=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],l=n?a.filter(C=>n.includes(C)):a,c=t.features.includes("rules"),m=t.features.includes("commands"),u=t.features.includes("mcp"),p=t.features.includes("permissions"),d=t.features.includes("hooks"),g=[],h=s==="global"?[]:await ID(r);for(let C of l){let S=Z(C),w=Mr(C)?Vl(C):S;w?.capabilities&&g.push(...jk({target:C,capabilities:w.capabilities,canonical:e,enabledFeatures:t.features})),d&&g.push(...Uk({target:C,canonical:e,hasScriptProjection:S?.postProcessHookOutputs!==void 0})),c&&g.push(...Wk({target:C,canonical:e,preservesManualActivation:S?.preservesManualActivation===true})),c&&w?.lintRules&&g.push(...w.lintRules(e,r,h,{scope:s})),S?.generators.lint&&g.push(...S.generators.lint(e));let D={scope:s};m&&w?.lint?.commands&&g.push(...w.lint.commands(e,D)),u&&w?.lint?.mcp&&g.push(...w.lint.mcp(e,D)),p&&w?.lint?.permissions&&g.push(...w.lint.permissions(e,D)),d&&w?.lint?.hooks&&g.push(...w.lint.hooks(e,D));}let R=g.some(C=>C.level==="error");return {diagnostics:g,hasErrors:R}}i(Kk,"runLint");async function Hk(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,s=typeof o=="string"&&o?o.split(",").map(R=>R.trim()).filter(Boolean):void 0,{config:a,context:l}=await at(r,n);await ie(a,r);let{canonical:c}=await se(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:u}=await Kk(a,c,l.configDir,s,{scope:n});if(m.length===0)return y.success("All checks passed."),0;let p=m.filter(R=>R.level==="error"),d=m.filter(R=>R.level==="warning");if(p.length>0)for(let R of p)y.error(`${R.file} (${R.target}): ${R.message}`);if(d.length>0)for(let R of d)y.warn(`${R.file} (${R.target}): ${R.message}`);let g=p.length,h=d.length;return y.info(`${g} error${g!==1?"s":""}, ${h} warning${h!==1?"s":""}`),u?1:0}i(Hk,"runLintCmd");var RD=300;function CD(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}i(CD,"normalizeWatchPath");function kD(t,e,r){let n=CD(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/")}i(kD,"shouldIgnoreWatchPath");function wD(t,e,r,n,o,s,a,l,c){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:s,permissionsCount:a,hooksCount:l,ignoreCount:c})}i(wD,"featureFingerprint");async function Vk(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{context:o}=await at(r,n),s=[o.canonicalDir,join(o.configDir,"agentsmesh.yaml"),join(o.configDir,"agentsmesh.local.yaml")],a=null,l=null,c=false,m=null,p=i(async()=>{if(c)return;a=null;let{config:R,context:C}=await at(r,n),{canonical:S}=await se(R,C.configDir,{},C.canonicalDir),w=S.mcp?Object.keys(S.mcp.mcpServers).length:0,D=S.permissions?S.permissions.allow.length+S.permissions.deny.length:0,b=S.hooks?Object.values(S.hooks).reduce((W,q)=>W+(Array.isArray(q)?q.length:0),0):0,x=S.ignore.length,K=wD(R.features,S.rules.length,S.commands.length,S.agents.length,S.skills.length,w,D,b,x),M=l!==null&&l!==K;l=K,!c&&(await ds(t,r,{printMatrix:false}),!c&&(M?await oo(t,r):y.info("Regenerated.")));},"run"),d=i(()=>{let R=p().catch(C=>{if(!c){let S=C instanceof Error?C.message:String(C);y.error(S);}}).finally(()=>{m===R&&(m=null);});m=R;},"scheduleRun"),g=i(()=>{c||(a&&clearTimeout(a),a=setTimeout(d,RD));},"schedule"),h=_D.watch(s,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(R,C)=>{kD(o.canonicalDir,C)||g();}),await new Promise((R,C)=>{h.once("ready",R),h.once("error",C);}),y.info(n==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=p(),await m,m=null,{stop:i(async()=>{c=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}i(Vk,"runWatch");async function Jk(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await vl(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let s=await vr(n),a=await fo(e,r),l=a.length>0?await eo(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(s)),u=[],p=[],d=[];for(let S of c){let w=s[S];w===void 0?d.push(S):w!==o.checksums[S]&&u.push(S);}for(let S of m)c.has(S)||p.push(S);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let S of g)l[S]!==o.extends[S]&&h.push(S);let R=$l(o.checksums,s,e.collaboration?.lock_features??[]);return {inSync:u.length===0&&p.length===0&&d.length===0&&h.length===0,hasLock:true,modified:u,added:p,removed:d,extendsModified:h,lockedViolations:R}}i(Jk,"checkLockSync");async function Yk(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:s}=await at(r,n);await ie(o,r);let a=await Jk({config:o,configDir:s.configDir,canonicalDir:s.canonicalDir});if(!a.hasLock)return y.error("Not initialized for collaboration. Run 'agentsmesh generate' first."),1;if(a.inSync)return y.success("Lock file is in sync."),0;let l=new Set(a.lockedViolations);y.error("Conflict detected:");for(let c of a.extendsModified)y.error(` extend "${c}" was modified`);for(let c of a.modified){let m=l.has(c)?" [LOCKED]":"";y.error(` ${c} was modified${m}`);}for(let c of a.added){let m=l.has(c)?" [LOCKED]":"";y.error(` ${c} was added${m}`);}for(let c of a.removed){let m=l.has(c)?" [LOCKED]":"";y.error(` ${c} was removed${m}`);}return y.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state."),1}i(Yk,"runCheck");E();var ED=".lock",bD="<<<<<<<";async function Yp(t){let e=join(t,ED),r=await I(e);return r===null?false:r.includes(bD)}i(Yp,"hasLockConflict");async function Zk(t,e,r){if(!await Yp(t))throw new Error("No conflict to resolve.");let o=await vr(t),s=dirname(t),a=r?await fo(r,s):[],l=a.length>0?await eo(a):{},c=await Ni(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await Li(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}i(Zk,"resolveLockConflict");async function qk(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:s}=await at(r,n),a=s.canonicalDir;if(!await Yp(a)){y.info("No conflicts to resolve.");return}await Zk(a,Rs(),o),y.success("Lock file conflict resolved.");}i(qk,"runMerge");E();var AD=promisify(execFile);async function Xp(t){let{stdout:e}=await AD("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}i(Xp,"runGit");async function Qk(){try{return await Xp(["--version"]),!0}catch{return false}}i(Qk,"isGitAvailable");async function TD(t,e){let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await Xp(["ls-remote",t,o])).split(`
|
|
285
|
-
`).map(c=>c.trim()).find(c=>c.length>0);if(!a)continue;let l=a.split(/\s+/)[0];if(l&&/^[0-9a-f]{40}$/i.test(l))return l}catch(s){n=s;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}i(
|
|
286
|
-
`).find(a=>a.trim().length>0);if(!o)throw new Error(`Could not resolve HEAD for ${e}`);let s=o.split(/\s+/)[0];if(!s||!/^[0-9a-f]{40}$/i.test(s))throw new Error(`Invalid ls-remote HEAD line for ${e}`);return s.toLowerCase()}return TD(e,r)}i(tw,"resolveRemoteRefForInstall");async function ew(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 tw(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await po(l,"install",{cacheDir:Tt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}if(t.kind==="gitlab"){let l=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await po(l,"install",{cacheDir:Tt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,s=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await po(s,"install",{cacheDir:Tt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:s,version:r}}i(ew,"fetchInstallSource");async function rw(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await ew(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}}i(rw,"resolveInstallResolvedPath");function Zp(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],s=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!s||!a?null:{org:o,repo:s,ref:a,path:l||""}}catch{return null}}i(Zp,"parseGithubTreeUrl");function qp(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],s=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!s||!a||!l?null:{org:o,repo:s,ref:a,path:l}}catch{return null}}i(qp,"parseGithubBlobUrl");function Qp(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 s=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!s?null:{namespace:m,project:c,ref:s,path:a||""}}catch{return null}}i(Qp,"parseGitlabTreeUrl");function td(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 s=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!s||!a?null:{namespace:m,project:c,ref:s,path:a}}catch{return null}}i(td,"parseGitlabBlobUrl");var LD=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function ed(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean).map(s=>s.replace(/\.git$/i,""));if(r.length<2||r.length>2||LD.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}i(ed,"parseGithubRepoUrl");function rd(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean).map(s=>s.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}}i(rd,"parseGitlabRepoUrl");function nd(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}i(nd,"parseGitSshGithub");function od(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}}i(od,"parseGitSshGitlab");E();var FD=/^[A-Za-z]:[\\/]/,vD=/^[A-Za-z]:\//;function nw(...t){return t.some(e=>e.includes("\\")||FD.test(e))?win32:posix}i(nw,"pathApiFor");function Gi(t){return t.replace(/\\/g,"/")}i(Gi,"toPosixPath");function Mi(t){return Gi(t).replace(/^\/+|\/+$/g,"")}i(Mi,"normalizeInstallPathField");function Jl(t){let e=Gi(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||vD.test(e)?e:`./${e}`}i(Jl,"normalizeLocalSourceForYaml");function gn(t){return {...t,source:t.source_kind==="local"?Jl(t.source):t.source,...t.path!==void 0?{path:Mi(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>Mi(e))}:{}}}i(gn,"normalizePersistedInstallPaths");function ow(t,e,r){let n=nw(t,e),o=n.normalize(t),s=n.normalize(e),a=Mi(r),l=`${n.sep}.agentsmesh${n.sep}`,c=o.indexOf(l);if(c>=0){let u=o.slice(0,c),p=o.slice(c+l.length),d=Mi(p),g=Gi(n.relative(s,u))||".";return {kind:"local",rawRef:"",pathInRepo:a||d.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:u,localSourceForYaml:Jl(g)}}let m=Gi(n.relative(s,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:Jl(m)}}i(ow,"localParsedFromAbsPath");async function sd(t,e,r){let n=t.trim(),o=r?.trim().replace(/\\/g,"/")??"";if(n.startsWith("git+")){let c=n.lastIndexOf("#"),m=c<0?n:n.slice(0,c),u=c<0?"HEAD":n.slice(c+1),p=m.slice(4);return {kind:"git",rawRef:u,gitPlusBase:p,gitRemoteUrl:p,pathInRepo:o}}if(n.startsWith("https://")||n.startsWith("http://")){let c=Zp(n)??qp(n);if(c)return {kind:"github",rawRef:c.ref,org:c.org,repo:c.repo,gitRemoteUrl:`https://github.com/${c.org}/${c.repo}.git`,pathInRepo:o||c.path};let m=ed(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 u=Qp(n)??td(n);if(u)return {kind:"gitlab",rawRef:u.ref,org:u.namespace,repo:u.project,gitRemoteUrl:`https://gitlab.com/${u.namespace}/${u.project}.git`,pathInRepo:o||u.path};let p=rd(n);if(p)return {kind:"gitlab",rawRef:"HEAD",org:p.namespace,repo:p.project,gitRemoteUrl:`https://gitlab.com/${p.namespace}/${p.project}.git`,pathInRepo:o}}if(n.startsWith("git@github.com:")){let c=nd(n);if(!c)throw new Error(`Invalid GitHub SSH URL: ${n}`);return {kind:"github",rawRef:"HEAD",org:c.org,repo:c.repo,gitRemoteUrl:`https://github.com/${c.org}/${c.repo}.git`,pathInRepo:o}}if(n.startsWith("git@gitlab.com:")){let c=od(n);if(!c)throw new Error(`Invalid GitLab SSH URL: ${n}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${c.namespace}/${c.project}.git`,pathInRepo:o}}if(n.startsWith("git@")){let c=n.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!c)throw new Error(`Invalid SSH git URL: ${n}`);let m=c[1],u=c[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${u}.git`,pathInRepo:o}}let s=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(s){let c=s[1],m=s[2];return {kind:"github",rawRef:s[3],org:c,repo:m,gitRemoteUrl:`https://github.com/${c}/${m}.git`,pathInRepo:o}}let a=n.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let c=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:c,repo:m,gitRemoteUrl:`https://gitlab.com/${c}/${m}.git`,pathInRepo:o}}let l=resolve(e,n);if(!await L(l))throw new Error(`Path does not exist: ${l}`);return ow(l,e,o)}i(sd,"parseInstallSource");E();E();var sw=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(mo).min(1),pick:Os.optional(),target:Jt.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:us.optional()}),UD=z$1.object({version:z$1.literal(1),installs:z$1.array(sw).default([])});function WD(t,e){return t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n])}i(WD,"sameFeatures");function BD(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&WD(t.features,e.features)}i(BD,"sameInstallIdentity");function iw(t){return join(t,"installs.yaml")}i(iw,"manifestPath");async function id(t){let e=await I(iw(t));if(e===null)return [];try{return UD.parse(parse(e)).installs.map(r=>gn(r))}catch{return []}}i(id,"readInstallManifest");async function aw(t,e){let r=gn(e),o=(await id(t)).filter(s=>s.name!==r.name&&!BD(s,r));o.push(r),await _(iw(t),stringify({version:1,installs:o.sort((s,a)=>s.name.localeCompare(a.name))}));}i(aw,"upsertInstallManifestEntry");function lw(t){return gn(sw.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}))}i(lw,"buildInstallManifestEntry");async function HD(t){let e=await id(t.canonicalDir);if(e.length===0){y.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let n of e){let o=join(t.canonicalDir,"packs",n.name);await L(o)||r.push(n);}if(r.length===0){y.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);y.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}i(HD,"syncInstalledPacks");async function cw(t){return t.sync?(await HD({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}i(cw,"maybeRunInstallSync");function mw(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"?us.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}i(mw,"readInstallFlags");function so(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}i(so,"featuresFromCanonical");async function Yl(t){let{sliceRoot:e,implicitPick:r}=await Al(t),n=await Tl(e);return {canonical:n,features:so(n),implicitPick:r}}i(Yl,"discoverFromContentRoot");function uw(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}i(uw,"validateSkill");function pw(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}i(pw,"validateRule");function dw(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}i(dw,"validateCommand");function fw(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}i(fw,"validateAgent");function le(t){return basename(t.source).replace(/\.md$/i,"")}i(le,"ruleSlug");function VD(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}i(VD,"featuresFromImplicitPick");function gs(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??VD(r);if(!r&&!n)return t;let o=new Set(n??[]),s={...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);s={...s,skills:r.skills.length===0?[]:s.skills.filter(l=>a.has(l.name))};}else n&&!o.has("skills")&&(s={...s,skills:[]});if(r?.rules!==void 0){let a=new Set(r.rules);s={...s,rules:r.rules.length===0?[]:s.rules.filter(l=>a.has(le(l)))};}else n&&!o.has("rules")&&(s={...s,rules:[]});if(r?.commands!==void 0){let a=new Set(r.commands);s={...s,commands:r.commands.length===0?[]:s.commands.filter(l=>a.has(l.name))};}else n&&!o.has("commands")&&(s={...s,commands:[]});if(r?.agents!==void 0){let a=new Set(r.agents);s={...s,agents:r.agents.length===0?[]:s.agents.filter(l=>a.has(l.name))};}else n&&!o.has("agents")&&(s={...s,agents:[]});return s}i(gs,"narrowDiscoveredForInstallScope");E();E();F();var XD=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"]),ZD=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function Xl(t){let e=await I(t);if(!e)return "";let{frontmatter:r}=O(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(Xl,"readSkillFrontmatterName");async function gw(t,e){await cp$1(t,e,{recursive:true,filter:i(r=>{let n=relative(t,r).replace(/\\/g,"/");if(n==="")return true;let o=n.split("/")[0];return !(ZD.has(o)||!n.includes("/")&&XD.has(n))},"filter")});}i(gw,"cpFilteredSkill");async function rF(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await k(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:i(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}i(rF,"createStageRoot");async function nF(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 n=(await P(t)).filter(s=>s.toLowerCase().endsWith(".md"));if(n.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let o=new Map;await k(e);for(let s of n){let a=basename(s),l=o.get(a);if(l)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${l} and ${s}).`);o.set(a,s),await cp$1(s,join(e,a));}}i(nF,"stageMarkdownCollection");async function hw(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let s of await P(t)){if(!s.endsWith("/SKILL.md")&&!s.endsWith("\\SKILL.md"))continue;let a=dirname(s),l=basename(a);if(!n.has(l))continue;let c=o.get(l);if(c&&c!==a)throw new Error(`Manual skill replay found duplicate skill "${l}" under ${t} (${c} and ${a}).`);o.set(l,a);}if(o.size!==r.length)return false;await k(e);for(let s of r)await cp$1(o.get(s),join(e,s),{recursive:true});return true}i(hw,"stagePreferredSkills");async function oF(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)),s=join(e,o);await k(s),await cp$1(dirname(t),s,{recursive:true});return}if(await to(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await hw(t,e,r.preferredSkillNames??[]))return;let l=await Xl(join(t,"SKILL.md"))||basename(t),c=join(e,l);await k(e),await gw(t,c);return}if(await hw(t,e,r.preferredSkillNames??[]))return;await k(e);let o=await P(t),s=new Set;for(let a of o.filter(l=>l.endsWith("/SKILL.md")||l.endsWith("\\SKILL.md")))s.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of s)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}.`)}i(oF,"stageSkills");async function yw(t,e,r={}){let n=await rF();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await oF(t,o,r):await nF(t,o),n}catch(o){throw await n.cleanup(),o}}i(yw,"stageManualInstallScope");async function Iw(t,e,r,n){let o=await yw(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:s}=await Yl(o.discoveryRoot),a=gs(s,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:o.cleanup},narrowed:a,discoveredFeatures:so(a)}}i(Iw,"resolveManualDiscoveredForInstall");E();var sF=[{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:".cline/skills",target:"cline"},{prefix:".clinerules/workflows",target:"cline"},{prefix:".windsurf/rules",target:"windsurf"},{prefix:".codex",target:"codex-cli"}];function iF(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}i(iF,"norm");function ql(t){let e=iF(t),r=[...sF].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}i(ql,"targetHintFromNativePath");function ld(t,e){return ql(t)===e}i(ld,"pathSupportsNativePick");function Sw(t,e){if(!t||!e)return;let r=ql(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.`)}i(Sw,"validateTargetMatchesPath");function _w(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}i(_w,"extendPickHasArrays");E();E();pt();async function Cw(t,e){let r=join(t,...Bt.split("/")),n=join(t,...e.split("/")),o=await P(n),s=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let l=relative(r,a).replace(/\\/g,"/");if(l.startsWith("..")||l==="")continue;let m=l.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&s.push(m);}return [...new Set(s)].sort()}i(Cw,"inferGeminiCommandNamesFromFiles");pt();Zt();E();async function io(t){let e=await P(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()}i(io,"skillNamesFromNativeSkillDir");E();ee();async function kw(t,e){let r=join(t,...e.split("/"));if(e.startsWith(sn)){let n=await P(r),o=[...new Set(n.filter(s=>s.toLowerCase().endsWith(".prompt.md")).map(s=>basename(s,".prompt.md")))].sort();return o.length?{commands:o}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let n=await P(r),o=[...new Set(n.filter(s=>s.includes(".instructions.md")).map(s=>basename(s).replace(/\.instructions\.md$/i,"")))].sort();return o.length?{rules:o}:{}}if(e.startsWith(".github/instructions")){let n=await P(r),o=new Set;for(let a of n){let l=basename(a);l.toLowerCase().endsWith(".instructions.md")?o.add(l.replace(/\.instructions\.md$/i,"")):l.toLowerCase().endsWith(".md")&&o.add(basename(a,".md"));}let s=[...o].sort();return s.length?{rules:s}:{}}if(e.startsWith(".github/skills")){let n=await io(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await P(r),o=[...new Set(n.filter(s=>s.toLowerCase().endsWith(".agent.md")).map(s=>basename(s,".agent.md")))].sort();return o.length?{agents:o}:{}}return {}}i(kw,"inferCopilotPickFromPath");async function zt(t,e){let r=await P(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}i(zt,"mdNames");async function Ow(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===Bt||n.startsWith(`${Bt}/`)){let s=await Cw(t,n);return s.length?{commands:s}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let s=await zt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".claude/rules")){let s=await zt(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".claude/agents")){let s=await zt(o,".md");return s.length?{agents:s}:{}}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 s=await zt(o,".mdc");return s.length?{rules:s}:{}}if(n.startsWith(".cursor/commands")){let s=await zt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".cursor/agents")){let s=await zt(o,".md");return s.length?{agents:s}:{}}if(n.startsWith(".cursor/skills")){let s=await io(o);return s.length?{skills:s}:{}}return {}}if(r==="copilot")return kw(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let s=await zt(o,".md");return s.length?{rules:s}:{}}if(r==="cline"){if(n.startsWith(It)){let s=await io(o);return s.length?{skills:s}:{}}if(n.startsWith(Ue)){let s=await zt(o,".md");return s.length?{commands:s}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let s=await zt(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".continue/prompts")){let s=await zt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".continue/skills")){let s=await io(o);return s.length?{skills:s}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let s=await zt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".junie/rules")){let s=await zt(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".junie/agents")){let s=await zt(o,".md");return s.length?{agents:s}:{}}if(n.startsWith(".junie/skills")){let s=await io(o);return s.length?{skills:s}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let s=await P(o),a=[...new Set(s.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}i(Ow,"inferImplicitPickFromNativePath");function Ew(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}i(Ew,"isImplicitPickEmpty");function Wi(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}i(Wi,"normalizePath");function hF(t,e){let r=Wi(t),n=Wi(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}i(hF,"overlapsPath");function Ql(t,e){let r=t??[];return r.includes(e)||r.push(e),r}i(Ql,"addUnique");async function yF(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),n=i(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}}i(yF,"makeStageRoot");function IF(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:Ql(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let s=Wi(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:Ql(r?.commands,s.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:Ql(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=Wi(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:Ql(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}i(IF,"buildPickFromResults");function SF(t,e,r,n){let o=join(e,...Wi(t).split("/")),s=r.filter(a=>hF(o,a.fromPath));if(s.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}".`);return {features:[...new Set(s.map(a=>a.feature))],pick:IF(s,e)}}i(SF,"scopeImportedResults");async function md(t,e){let{stageRoot:r,cleanup:n}=await yF(t);try{let o=await bi(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}i(md,"stageImportedNativeRepo");async function ud(t,e,r){let n=await md(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...SF(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}i(ud,"stageNativeInstallScope");async function Aw(t,e,r,n){let o=n.explicitTarget?.trim();o&&Jt.parse(o);let s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");Sw(o,s);let a=join(t,".agentsmesh"),l=await L(a),c=s?ql(s):void 0,m=!l&&!o?await na(t)??void 0:void 0;if(!o&&c&&m&&c!==m)throw new Error(`Install path suggests native layout "${c}" but auto-detect imported "${m}". Use --target ${c} for this path, or install from the repo root without a conflicting subtree path.`);let u=o??c??m,p=!!s&&!!u&&!s.startsWith(".agentsmesh");if(!l&&u){if(p){let w=await ud(t,s,u);return {discoveryRoot:w.stageRoot,implicitPick:w.pick,scopedFeatures:w.features,yamlTarget:u,importHappened:true,cleanup:w.cleanup}}let S=await md(t,u);return {discoveryRoot:s?join(S.stageRoot,s):S.stageRoot,yamlTarget:u,importHappened:true,cleanup:S.cleanup}}let d;l?s?u&&ld(s,u)?d=t:d=e:d=t:d=e;let g,h,R;if(p&&u){let S=await ud(t,s,u);d=S.stageRoot,g=S.pick,h=S.features,R=S.cleanup;}else if(d===t&&s&&u&&ld(s,u)&&(g=await Ow(t,s,u),Ew(g)))throw new Error(`No installable native resources found under "${s}" for target "${u}".`);let C;return o?C=o:u&&(g&&_w(g)||(h?.length??0)>0)&&(C=u),{discoveryRoot:d,implicitPick:g,scopedFeatures:h,yamlTarget:C,importHappened:R!==void 0,cleanup:R}}i(Aw,"prepareInstallDiscovery");async function Tw(t,e,r,n){let o=await Aw(t,e,r,{explicitTarget:n}),{canonical:s,implicitPick:a}=await Yl(o.discoveryRoot),l=a??o.implicitPick,c=gs(s,{implicitPick:l,scopedFeatures:o.scopedFeatures}),m=so(c);return {prep:o,discovered:s,implicitPick:l,narrowed:c,discoveredFeatures:m}}i(Tw,"resolveDiscoveredForInstall");async function Lw(t){return t.explicitAs?{implicitPick:void 0,...await Iw(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:Tw(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}i(Lw,"resolveInstallDiscovery");function ys(t){return t==="."||t===""?void 0:t}i(ys,"trimDot");function RF(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}i(RF,"markdownPick");async function Dw(t){if(!t.as)return {pathInRepo:ys(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:ys(dirname(e)),pick:RF(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:ys(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 Xl(o);return {pathInRepo:ys(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:ys(e)}}}}return {pathInRepo:ys(e)}}i(Dw,"resolveManualInstallPersistence");async function ir(t){return process.stdin.isTTY?new Promise(e=>{let r=Fw.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}i(ir,"confirm");function CF(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}i(CF,"hasArrayResources");function vw(t){return CF(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}i(vw,"hasInstallableResources");async function $w(t,e,r,n){let o=t.skills.map(l=>uw(l)),s=o.filter(l=>l.ok).map(l=>l.skill),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await ir(`Include invalid skill "${l.skill.name}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.skill);else e&&(s=o.map(l=>l.skill));return r&&(s=o.filter(l=>l.ok).map(l=>l.skill)),s}i($w,"resolveSkillPool");async function Mw(t,e,r,n){let o=t.rules.map(l=>pw(l)),s=o.filter(l=>l.ok).map(l=>l.rule),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await ir(`Include invalid rule "${le(l.rule)}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.rule);else e&&(s=o.map(l=>l.rule));return r&&(s=o.filter(l=>l.ok).map(l=>l.rule)),s}i(Mw,"resolveRulePool");async function Gw(t,e,r,n){let o=t.commands.map(l=>dw(l)),s=o.filter(l=>l.ok).map(l=>l.command),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await ir(`Include invalid command "${l.command.name}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.command);else e&&(s=o.map(l=>l.command));return r&&(s=o.filter(l=>l.ok).map(l=>l.command)),s}i(Gw,"resolveCommandPool");async function jw(t,e,r,n){let o=t.agents.map(l=>fw(l)),s=o.filter(l=>l.ok).map(l=>l.agent),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await ir(`Include invalid agent "${l.agent.name}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.agent);else e&&(s=o.map(l=>l.agent));return r&&(s=o.filter(l=>l.ok).map(l=>l.agent)),s}i(jw,"resolveAgentPool");async function Uw(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>le(a)),o=e.commands.map(a=>a.name),s=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(l=>l.name===a.name)&&(await ir(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(c=>c!==a.name)));for(let a of e.rules){let l=le(a);t.rules.some(c=>le(c)===l)&&(await ir(`Rule "${l}" already exists in merged config. Add extend anyway?`)||(n=n.filter(m=>m!==l)));}for(let a of e.commands)t.commands.some(l=>l.name===a.name)&&(await ir(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(o=o.filter(c=>c!==a.name)));for(let a of e.agents)t.agents.some(l=>l.name===a.name)&&(await ir(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(s=s.filter(c=>c!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:s}}i(Uw,"resolveInstallConflicts");function Ww(t,e){if(!t)return;let r={},n=t.skills?.filter(l=>e.skillNames.includes(l)),o=t.rules?.filter(l=>e.ruleSlugs.includes(l)),s=t.commands?.filter(l=>e.commandNames.includes(l)),a=t.agents?.filter(l=>e.agentNames.includes(l));return n&&n.length>0&&(r.skills=n),o&&o.length>0&&(r.rules=o),s&&s.length>0&&(r.commands=s),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}i(Ww,"pickForSelectedResources");function kF(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}i(kF,"pathEndsWithName");function tc(t,e,r){return r!==1||e.length!==1?false:kF(t,e[0])}i(tc,"inferSingleNamePick");function Bw(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:n,selected:o}=t,s={},a=o.skillNames.length>0&&(!!r?.skills?.length||o.skillNames.length<n.skills||tc(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||tc(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||tc(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||tc(e,o.agentNames,n.agents));return a&&(s.skills=[...o.skillNames]),l&&(s.rules=[...o.ruleSlugs]),c&&(s.commands=[...o.commandNames]),m&&(s.agents=[...o.agentNames]),Object.keys(s).length?s:void 0}i(Bw,"buildInstallPick");function Kw(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]}i(Kw,"deriveInstallFeatures");function wF(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}i(wF,"isEmptyInstallSelection");function Hw(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=i(l=>r.includes(l),"had"),s=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(s)throw new Error(`No ${s} selected to install.`);let a=r.some(l=>["mcp","permissions","hooks","ignore"].includes(l));if(wF(e)&&!a)throw new Error("No resources selected to install.")}i(Hw,"ensureInstallSelection");function zw(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.`)}i(zw,"assertExtendNameAvailable");function OF(t,e,r){if(r===void 0){if(!t)return;let o={...t};for(let s of ["skills","commands","rules","agents"])e.includes(s)&&delete o[s];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 s=r[o];if(s===void 0||s.length===0){delete n[o];continue}n[o]=[...new Set([...t?.[o]??[],...s])];}return Object.keys(n).length?n:void 0}i(OF,"mergePick");function Vw(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])],s=OF(n.pick,e.features,e.pick);return t.map((a,l)=>l===r?{name:e.name,source:e.source,version:e.version??n.version,features:o,path:e.path!==void 0?e.path:n.path,pick:s,target:e.target??n.target}:a)}i(Vw,"mergeExtendList");E();async function Jw(t,e,r){let n=await I(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),s=Vw(e.extends,r);o.extends=s;let a=stringify(o,{indent:2,lineWidth:0});await _(t,a.endsWith(`
|
|
290
|
+
`);}i(c$,"appendToGitignore");async function aw(t,e={}){let r=e.global===true?"global":"project",n=Ri(t,r),o=join(n.configDir,va);if(await F(o))throw new Error(`Already initialized. ${va} exists. Remove it first to re-init.`);let s=await rw(n.rootBase,r),a=r==="global"?s.filter(m=>iw.includes(m)):s,l=r==="global"?iw:void 0;if(a.length>0)if(y.info(`Found existing configurations: ${a.join(", ")}`),e.yes){y.info("Auto-importing existing configurations (--yes)...");let m=0;for(let p of a){let u=a$[p];if(!u)continue;let d=await u(n.rootBase,r);for(let g of d){let h=relative(n.rootBase,g.fromPath).replaceAll("\\","/"),C=g.toPath.replaceAll("\\","/");y.success(` ${h} \u2192 ${C}`);}m+=d.length;}m>0&&y.info(`Imported ${m} file(s) from ${a.length} tool(s).`),await ow(n.canonicalDir),await S(o,em(a,l)),y.success(`Created ${va} (targets: ${a.join(", ")})`);}else y.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),await gf(n.canonicalDir),await S(o,em([],l)),y.success(`Created ${va}`);else await gf(n.canonicalDir),await S(o,em([],l)),y.success(`Created ${va}`);let c=join(n.configDir,sw);await S(c,QE),y.success(`Created ${sw}`),r==="project"&&(await c$(t),y.success("Updated .gitignore"));}i(aw,"runInit");it();var m$=Object.fromEntries(xt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function nm(t){let e=m$[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}i(nm,"getTargetCatalogEntry");wr();function lw(t,e,r){for(let n of t){let o=relative(e,n.fromPath);y.success(`${o} \u2192 ${n.toPath}`);}y.info(`Imported ${t.length} file(s). Run 'agentsmesh generate${r==="global"?" --global":""}' to sync to other tools.`);}i(lw,"formatImportResults");async function cw(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(),s=t.global===true?"global":"project";if(un(o)){let p=Ri(r,s),u=nm(o),d=await u.importFrom(p.rootBase,{scope:s});if(d.length===0){y.info(u.emptyImportMessage);return}lw(d,p.rootBase,s);return}let a,l;try{({config:a,context:l}=await ut(r,s));}catch{throw new Error(`Unknown --from "${n}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${Ot.join(", ")}.`)}await Re(a,r);let c=rt(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...Ot,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:s});if(m.length===0){y.info(c.emptyImportMessage);return}lw(m,l.rootBase,s);}i(cw,"runImport");function pw(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}}i(pw,"computeDiff");function uw(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}i(uw,"formatDiffSummary");async function dw(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,s=typeof o=="string"&&o?o.split(",").map(d=>d.trim()).filter(Boolean):void 0,{config:a,context:l}=await ut(r,n);await Re(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),m=await Qc({config:a,canonical:c,projectRoot:l.rootBase,scope:n,targetFilter:s});if(m.length===0){y.info("No files to generate (no root rule or rules feature disabled).");return}let{diffs:p,summary:u}=pw(m);for(let d of p)process.stdout.write(d.patch);y.info(uw(u));}i(dw,"runDiff");A();wr();ro();$t();var u$=[{canonicalKey:"permissions",capabilityKey:"permissions",featureFlag:"permissions",file:".agentsmesh/permissions.yaml",label:"permissions",hasContent:i(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:i(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:i(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:i(t=>t.commands.length>0,"hasContent")},{canonicalKey:"agents",capabilityKey:"agents",featureFlag:"agents",file:".agentsmesh/agents",label:"agents",hasContent:i(t=>t.agents.length>0,"hasContent")},{canonicalKey:"skills",capabilityKey:"skills",featureFlag:"skills",file:".agentsmesh/skills",label:"skills",hasContent:i(t=>t.skills.length>0,"hasContent")},{canonicalKey:"ignore",capabilityKey:"ignore",featureFlag:"ignore",file:".agentsmesh/ignore",label:"ignore patterns",hasContent:i(t=>t.ignore.length>0,"hasContent")}];function fw(t){let e=new Set(t.enabledFeatures),r=[];for(let n of u$)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Ae(t.capabilities[n.capabilityKey]).level!=="none"||r.push(B(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}i(fw,"lintSilentFeatureDrops");$t();var d$=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function f$(t){let r=t.match(d$)?.groups?.path;return typeof r=="string"?r:null}i(f$,"extractScriptToken");function gw(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 s=f$(o.command);s&&r.push(B(".agentsmesh/hooks.yaml",t.target,`${t.target} hook command references script "${s}"; 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}i(gw,"lintHookScriptReferences");$t();function hw(t){if(t.preservesManualActivation)return [];let e=[];for(let r of t.canonical.rules)r.root||r.trigger==="manual"&&(r.targets.length>0&&!r.targets.includes(t.target)||e.push(B(r.source,t.target,`Rule has trigger: 'manual' (Cursor-style "@-mention only" activation), but ${t.target} loads every rule unconditionally. The rule will become always-on for ${t.target} \u2014 restrict it with \`targets: [cursor]\`, convert it to a skill with manual invocation, or remove it.`)));return e}i(hw,"lintRuleScopeInversion");var g$=["node_modules",".git","dist","coverage",".agentsmesh"];async function h$(t){return (await x(t)).filter(n=>{let o=relative(t,n);return !g$.some(s=>o.includes(`/${s}/`)||o.startsWith(`${s}/`))}).map(n=>relative(t,n))}i(h$,"getProjectFiles");async function Iw(t,e,r,n,o={}){let s=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],l=n?a.filter(O=>n.includes(O)):a,c=t.features.includes("rules"),m=t.features.includes("commands"),p=t.features.includes("mcp"),u=t.features.includes("permissions"),d=t.features.includes("hooks"),g=[],h=s==="global"?[]:await h$(r);for(let O of l){let _=rt(O),k=un(O)?nm(O):_;k?.capabilities&&g.push(...fw({target:O,capabilities:k.capabilities,canonical:e,enabledFeatures:t.features})),d&&g.push(...gw({target:O,canonical:e,hasScriptProjection:_?.postProcessHookOutputs!==void 0})),c&&g.push(...hw({target:O,canonical:e,preservesManualActivation:_?.preservesManualActivation===true})),c&&k?.lintRules&&g.push(...k.lintRules(e,r,h,{scope:s})),_?.generators.lint&&g.push(..._.generators.lint(e));let D={scope:s};m&&k?.lint?.commands&&g.push(...k.lint.commands(e,D)),p&&k?.lint?.mcp&&g.push(...k.lint.mcp(e,D)),u&&k?.lint?.permissions&&g.push(...k.lint.permissions(e,D)),d&&k?.lint?.hooks&&g.push(...k.lint.hooks(e,D));}let C=g.some(O=>O.level==="error");return {diagnostics:g,hasErrors:C}}i(Iw,"runLint");async function _w(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,s=typeof o=="string"&&o?o.split(",").map(C=>C.trim()).filter(Boolean):void 0,{config:a,context:l}=await ut(r,n);await Re(a,r);let{canonical:c}=await Oe(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await Iw(a,c,l.configDir,s,{scope:n});if(m.length===0)return y.success("All checks passed."),0;let u=m.filter(C=>C.level==="error"),d=m.filter(C=>C.level==="warning");if(u.length>0)for(let C of u)y.error(`${C.file} (${C.target}): ${C.message}`);if(d.length>0)for(let C of d)y.warn(`${C.file} (${C.target}): ${C.message}`);let g=u.length,h=d.length;return y.info(`${g} error${g!==1?"s":""}, ${h} warning${h!==1?"s":""}`),p?1:0}i(_w,"runLintCmd");var _$=300;function S$(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}i(S$,"normalizeWatchPath");function C$(t,e,r){let n=S$(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/")}i(C$,"shouldIgnoreWatchPath");function O$(t,e,r,n,o,s,a,l,c){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:s,permissionsCount:a,hooksCount:l,ignoreCount:c})}i(O$,"featureFingerprint");async function Cw(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{context:o}=await ut(r,n),s=[o.canonicalDir,join(o.configDir,"agentsmesh.yaml"),join(o.configDir,"agentsmesh.local.yaml")],a=null,l=null,c=false,m=null,u=i(async()=>{if(c)return;a=null;let{config:C,context:O}=await ut(r,n),{canonical:_}=await Oe(C,O.configDir,{},O.canonicalDir),k=_.mcp?Object.keys(_.mcp.mcpServers).length:0,D=_.permissions?_.permissions.allow.length+_.permissions.deny.length:0,b=_.hooks?Object.values(_.hooks).reduce((W,nt)=>W+(Array.isArray(nt)?nt.length:0),0):0,P=_.ignore.length,J=O$(C.features,_.rules.length,_.commands.length,_.agents.length,_.skills.length,k,D,b,P),j=l!==null&&l!==J;l=J,!c&&(await mi(t,r,{printMatrix:false}),!c&&(j?await Xo(t,r):y.info("Regenerated.")));},"run"),d=i(()=>{let C=u().catch(O=>{if(!c){let _=O instanceof Error?O.message:String(O);y.error(_);}}).finally(()=>{m===C&&(m=null);});m=C;},"scheduleRun"),g=i(()=>{c||(a&&clearTimeout(a),a=setTimeout(d,_$));},"schedule"),h=I$.watch(s,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(C,O)=>{C$(o.canonicalDir,O)||g();}),await new Promise((C,O)=>{h.once("ready",C),h.once("error",O);}),y.info(n==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=u(),await m,m=null,{stop:i(async()=>{c=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}i(Cw,"runWatch");async function Ow(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await zc(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let s=await mn(n),a=await ss(e,r),l=a.length>0?await Jo(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(s)),p=[],u=[],d=[];for(let _ of c){let k=s[_];k===void 0?d.push(_):k!==o.checksums[_]&&p.push(_);}for(let _ of m)c.has(_)||u.push(_);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let _ of g)l[_]!==o.extends[_]&&h.push(_);let C=Vc(o.checksums,s,e.collaboration?.lock_features??[]);return {inSync:p.length===0&&u.length===0&&d.length===0&&h.length===0,hasLock:true,modified:p,added:u,removed:d,extendsModified:h,lockedViolations:C}}i(Ow,"checkLockSync");async function Rw(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:s}=await ut(r,n);await Re(o,r);let a=await Ow({config:o,configDir:s.configDir,canonicalDir:s.canonicalDir});if(!a.hasLock)return y.error("Not initialized for collaboration. Run 'agentsmesh generate' first."),1;if(a.inSync)return y.success("Lock file is in sync."),0;let l=new Set(a.lockedViolations);y.error("Conflict detected:");for(let c of a.extendsModified)y.error(` extend "${c}" was modified`);for(let c of a.modified){let m=l.has(c)?" [LOCKED]":"";y.error(` ${c} was modified${m}`);}for(let c of a.added){let m=l.has(c)?" [LOCKED]":"";y.error(` ${c} was added${m}`);}for(let c of a.removed){let m=l.has(c)?" [LOCKED]":"";y.error(` ${c} was removed${m}`);}return y.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state."),1}i(Rw,"runCheck");A();var k$=".lock",E$="<<<<<<<";async function yf(t){let e=join(t,k$),r=await I(e);return r===null?false:r.includes(E$)}i(yf,"hasLockConflict");async function Ew(t,e,r){if(!await yf(t))throw new Error("No conflict to resolve.");let o=await mn(t),s=dirname(t),a=r?await ss(r,s):[],l=a.length>0?await Jo(a):{},c=await Ta(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await xa(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}i(Ew,"resolveLockConflict");async function ww(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:s}=await ut(r,n),a=s.canonicalDir;if(!await yf(a)){y.info("No conflicts to resolve.");return}await Ew(a,Ii(),o),y.success("Lock file conflict resolved.");}i(ww,"runMerge");A();var A$=promisify(execFile);async function If(t){let{stdout:e}=await A$("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}i(If,"runGit");async function Lw(){try{return await If(["--version"]),!0}catch{return false}}i(Lw,"isGitAvailable");async function b$(t,e){let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await If(["ls-remote",t,o])).split(`
|
|
291
|
+
`).map(c=>c.trim()).find(c=>c.length>0);if(!a)continue;let l=a.split(/\s+/)[0];if(l&&/^[0-9a-f]{40}$/i.test(l))return l}catch(s){n=s;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}i(b$,"gitLsRemoteResolve");async function Aw(t,e){let r=t===""?"HEAD":t;if(/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await If(["ls-remote",e,"HEAD"])).split(`
|
|
292
|
+
`).find(a=>a.trim().length>0);if(!o)throw new Error(`Could not resolve HEAD for ${e}`);let s=o.split(/\s+/)[0];if(!s||!/^[0-9a-f]{40}$/i.test(s))throw new Error(`Invalid ls-remote HEAD line for ${e}`);return s.toLowerCase()}return b$(e,r)}i(Aw,"resolveRemoteRefForInstall");async function bw(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 Aw(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await os(l,"install",{cacheDir:zt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}if(t.kind==="gitlab"){let l=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await os(l,"install",{cacheDir:zt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,s=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await os(s,"install",{cacheDir:zt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:s,version:r}}i(bw,"fetchInstallSource");async function Pw(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await bw(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}}i(Pw,"resolveInstallResolvedPath");function _f(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],s=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!s||!a?null:{org:o,repo:s,ref:a,path:l||""}}catch{return null}}i(_f,"parseGithubTreeUrl");function Sf(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],s=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!s||!a||!l?null:{org:o,repo:s,ref:a,path:l}}catch{return null}}i(Sf,"parseGithubBlobUrl");function Cf(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 s=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!s?null:{namespace:m,project:c,ref:s,path:a||""}}catch{return null}}i(Cf,"parseGitlabTreeUrl");function Of(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 s=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!s||!a?null:{namespace:m,project:c,ref:s,path:a}}catch{return null}}i(Of,"parseGitlabBlobUrl");var P$=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function Rf(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean).map(s=>s.replace(/\.git$/i,""));if(r.length<2||r.length>2||P$.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}i(Rf,"parseGithubRepoUrl");function kf(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean).map(s=>s.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}}i(kf,"parseGitlabRepoUrl");function Ef(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}i(Ef,"parseGitSshGithub");function wf(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}}i(wf,"parseGitSshGitlab");A();var N$=/^[A-Za-z]:[\\/]/,D$=/^[A-Za-z]:\//;function xw(...t){return t.some(e=>e.includes("\\")||N$.test(e))?win32:posix}i(xw,"pathApiFor");function Ma(t){return t.replace(/\\/g,"/")}i(Ma,"toPosixPath");function $a(t){return Ma(t).replace(/^\/+|\/+$/g,"")}i($a,"normalizeInstallPathField");function om(t){let e=Ma(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||D$.test(e)?e:`./${e}`}i(om,"normalizeLocalSourceForYaml");function Yn(t){return {...t,source:t.source_kind==="local"?om(t.source):t.source,...t.path!==void 0?{path:$a(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>$a(e))}:{}}}i(Yn,"normalizePersistedInstallPaths");function Tw(t,e,r){let n=xw(t,e),o=n.normalize(t),s=n.normalize(e),a=$a(r),l=`${n.sep}.agentsmesh${n.sep}`,c=o.indexOf(l);if(c>=0){let p=o.slice(0,c),u=o.slice(c+l.length),d=$a(u),g=Ma(n.relative(s,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||d.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:om(g)}}let m=Ma(n.relative(s,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:om(m)}}i(Tw,"localParsedFromAbsPath");async function Lf(t,e,r){let n=t.trim(),o=r?.trim().replace(/\\/g,"/")??"";if(n.startsWith("git+")){let c=n.lastIndexOf("#"),m=c<0?n:n.slice(0,c),p=c<0?"HEAD":n.slice(c+1),u=m.slice(4);return {kind:"git",rawRef:p,gitPlusBase:u,gitRemoteUrl:u,pathInRepo:o}}if(n.startsWith("https://")||n.startsWith("http://")){let c=_f(n)??Sf(n);if(c)return {kind:"github",rawRef:c.ref,org:c.org,repo:c.repo,gitRemoteUrl:`https://github.com/${c.org}/${c.repo}.git`,pathInRepo:o||c.path};let m=Rf(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=Cf(n)??Of(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=kf(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 c=Ef(n);if(!c)throw new Error(`Invalid GitHub SSH URL: ${n}`);return {kind:"github",rawRef:"HEAD",org:c.org,repo:c.repo,gitRemoteUrl:`https://github.com/${c.org}/${c.repo}.git`,pathInRepo:o}}if(n.startsWith("git@gitlab.com:")){let c=wf(n);if(!c)throw new Error(`Invalid GitLab SSH URL: ${n}`);return {kind:"gitlab",rawRef:"HEAD",gitRemoteUrl:`https://gitlab.com/${c.namespace}/${c.project}.git`,pathInRepo:o}}if(n.startsWith("git@")){let c=n.match(/^git@([^:]+):(.+?)(?:\.git)?$/);if(!c)throw new Error(`Invalid SSH git URL: ${n}`);let m=c[1],p=c[2].replace(/\.git$/i,"");return {kind:"git",rawRef:"HEAD",gitRemoteUrl:`ssh://git@${m}/${p}.git`,pathInRepo:o}}let s=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(s){let c=s[1],m=s[2];return {kind:"github",rawRef:s[3],org:c,repo:m,gitRemoteUrl:`https://github.com/${c}/${m}.git`,pathInRepo:o}}let a=n.match(/^gitlab:(.+)\/([^/@]+)@([^/@]+)$/);if(a){let c=a[1],m=a[2];return {kind:"gitlab",rawRef:a[3],org:c,repo:m,gitRemoteUrl:`https://gitlab.com/${c}/${m}.git`,pathInRepo:o}}let l=resolve(e,n);if(!await F(l))throw new Error(`Path does not exist: ${l}`);return Tw(l,e,o)}i(Lf,"parseInstallSource");A();A();var Nw=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(rs).min(1),pick:Oi.optional(),target:ie.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:li.optional()}),G$=z$1.object({version:z$1.literal(1),installs:z$1.array(Nw).default([])});function j$(t,e){return t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n])}i(j$,"sameFeatures");function U$(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&j$(t.features,e.features)}i(U$,"sameInstallIdentity");function Dw(t){return join(t,"installs.yaml")}i(Dw,"manifestPath");async function Af(t){let e=await I(Dw(t));if(e===null)return [];try{return G$.parse(parse(e)).installs.map(r=>Yn(r))}catch{return []}}i(Af,"readInstallManifest");async function Fw(t,e){let r=Yn(e),o=(await Af(t)).filter(s=>s.name!==r.name&&!U$(s,r));o.push(r),await S(Dw(t),stringify({version:1,installs:o.sort((s,a)=>s.name.localeCompare(a.name))}));}i(Fw,"upsertInstallManifestEntry");function vw(t){return Yn(Nw.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}))}i(vw,"buildInstallManifestEntry");async function W$(t){let e=await Af(t.canonicalDir);if(e.length===0){y.info("No recorded installs found in .agentsmesh/installs.yaml.");return}let r=[];for(let n of e){let o=join(t.canonicalDir,"packs",n.name);await F(o)||r.push(n);}if(r.length===0){y.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);y.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}i(W$,"syncInstalledPacks");async function $w(t){return t.sync?(await W$({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}i($w,"maybeRunInstallSync");function Mw(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"?li.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}i(Mw,"readInstallFlags");function Zo(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}i(Zo,"featuresFromCanonical");async function sm(t){let{sliceRoot:e,implicitPick:r}=await jc(t),n=await Uc(e);return {canonical:n,features:Zo(n),implicitPick:r}}i(sm,"discoverFromContentRoot");function Gw(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}i(Gw,"validateSkill");function jw(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}i(jw,"validateRule");function Uw(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}i(Uw,"validateCommand");function Kw(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}i(Kw,"validateAgent");function Ee(t){return basename(t.source).replace(/\.md$/i,"")}i(Ee,"ruleSlug");function H$(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}i(H$,"featuresFromImplicitPick");function ui(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??H$(r);if(!r&&!n)return t;let o=new Set(n??[]),s={...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);s={...s,skills:r.skills.length===0?[]:s.skills.filter(l=>a.has(l.name))};}else n&&!o.has("skills")&&(s={...s,skills:[]});if(r?.rules!==void 0){let a=new Set(r.rules);s={...s,rules:r.rules.length===0?[]:s.rules.filter(l=>a.has(Ee(l)))};}else n&&!o.has("rules")&&(s={...s,rules:[]});if(r?.commands!==void 0){let a=new Set(r.commands);s={...s,commands:r.commands.length===0?[]:s.commands.filter(l=>a.has(l.name))};}else n&&!o.has("commands")&&(s={...s,commands:[]});if(r?.agents!==void 0){let a=new Set(r.agents);s={...s,agents:r.agents.length===0?[]:s.agents.filter(l=>a.has(l.name))};}else n&&!o.has("agents")&&(s={...s,agents:[]});return s}i(ui,"narrowDiscoveredForInstallScope");A();A();v();var J$=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"]),Y$=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function im(t){let e=await I(t);if(!e)return "";let{frontmatter:r}=E(e);return typeof r.name!="string"?"":r.name.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(im,"readSkillFrontmatterName");async function Ww(t,e){await cp$1(t,e,{recursive:true,filter:i(r=>{let n=relative(t,r).replace(/\\/g,"/");if(n==="")return true;let o=n.split("/")[0];return !(Y$.has(o)||!n.includes("/")&&J$.has(n))},"filter")});}i(Ww,"cpFilteredSkill");async function tM(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await R(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:i(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}i(tM,"createStageRoot");async function eM(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 R(e),await cp$1(t,join(e,basename(t)));return}let n=(await x(t)).filter(s=>s.toLowerCase().endsWith(".md"));if(n.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let o=new Map;await R(e);for(let s of n){let a=basename(s),l=o.get(a);if(l)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${l} and ${s}).`);o.set(a,s),await cp$1(s,join(e,a));}}i(eM,"stageMarkdownCollection");async function Bw(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let s of await x(t)){if(!s.endsWith("/SKILL.md")&&!s.endsWith("\\SKILL.md"))continue;let a=dirname(s),l=basename(a);if(!n.has(l))continue;let c=o.get(l);if(c&&c!==a)throw new Error(`Manual skill replay found duplicate skill "${l}" under ${t} (${c} and ${a}).`);o.set(l,a);}if(o.size!==r.length)return false;await R(e);for(let s of r)await cp$1(o.get(s),join(e,s),{recursive:true});return true}i(Bw,"stagePreferredSkills");async function rM(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)),s=join(e,o);await R(s),await cp$1(dirname(t),s,{recursive:true});return}if(await Vo(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await Bw(t,e,r.preferredSkillNames??[]))return;let l=await im(join(t,"SKILL.md"))||basename(t),c=join(e,l);await R(e),await Ww(t,c);return}if(await Bw(t,e,r.preferredSkillNames??[]))return;await R(e);let o=await x(t),s=new Set;for(let a of o.filter(l=>l.endsWith("/SKILL.md")||l.endsWith("\\SKILL.md")))s.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of s)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}.`)}i(rM,"stageSkills");async function Hw(t,e,r={}){let n=await tM();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await rM(t,o,r):await eM(t,o),n}catch(o){throw await n.cleanup(),o}}i(Hw,"stageManualInstallScope");async function zw(t,e,r,n){let o=await Hw(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:s}=await sm(o.discoveryRoot),a=ui(s,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:o.cleanup},narrowed:a,discoveredFeatures:Zo(a)}}i(zw,"resolveManualDiscoveredForInstall");A();var nM=[{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 oM(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}i(oM,"norm");function lm(t){let e=oM(t),r=[...nM].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}i(lm,"targetHintFromNativePath");function Pf(t,e){return lm(t)===e}i(Pf,"pathSupportsNativePick");function Vw(t,e){if(!t||!e)return;let r=lm(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.`)}i(Vw,"validateTargetMatchesPath");function Jw(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}i(Jw,"extendPickHasArrays");A();A();It();async function Xw(t,e){let r=join(t,...ee.split("/")),n=join(t,...e.split("/")),o=await x(n),s=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let l=relative(r,a).replace(/\\/g,"/");if(l.startsWith("..")||l==="")continue;let m=l.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&s.push(m);}return [...new Set(s)].sort()}i(Xw,"inferGeminiCommandNamesFromFiles");It();de();A();async function qo(t){let e=await x(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()}i(qo,"skillNamesFromNativeSkillDir");A();Ie();async function Zw(t,e){let r=join(t,...e.split("/"));if(e.startsWith(Mn)){let n=await x(r),o=[...new Set(n.filter(s=>s.toLowerCase().endsWith(".prompt.md")).map(s=>basename(s,".prompt.md")))].sort();return o.length?{commands:o}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let n=await x(r),o=[...new Set(n.filter(s=>s.includes(".instructions.md")).map(s=>basename(s).replace(/\.instructions\.md$/i,"")))].sort();return o.length?{rules:o}:{}}if(e.startsWith(".github/instructions")){let n=await x(r),o=new Set;for(let a of n){let l=basename(a);l.toLowerCase().endsWith(".instructions.md")?o.add(l.replace(/\.instructions\.md$/i,"")):l.toLowerCase().endsWith(".md")&&o.add(basename(a,".md"));}let s=[...o].sort();return s.length?{rules:s}:{}}if(e.startsWith(".github/skills")){let n=await qo(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await x(r),o=[...new Set(n.filter(s=>s.toLowerCase().endsWith(".agent.md")).map(s=>basename(s,".agent.md")))].sort();return o.length?{agents:o}:{}}return {}}i(Zw,"inferCopilotPickFromPath");async function oe(t,e){let r=await x(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}i(oe,"mdNames");async function Qw(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===ee||n.startsWith(`${ee}/`)){let s=await Xw(t,n);return s.length?{commands:s}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let s=await oe(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".claude/rules")){let s=await oe(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".claude/agents")){let s=await oe(o,".md");return s.length?{agents:s}:{}}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 s=await oe(o,".mdc");return s.length?{rules:s}:{}}if(n.startsWith(".cursor/commands")){let s=await oe(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".cursor/agents")){let s=await oe(o,".md");return s.length?{agents:s}:{}}if(n.startsWith(".cursor/skills")){let s=await qo(o);return s.length?{skills:s}:{}}return {}}if(r==="copilot")return Zw(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let s=await oe(o,".md");return s.length?{rules:s}:{}}if(r==="cline"){if(n.startsWith(wt)){let s=await qo(o);return s.length?{skills:s}:{}}if(n.startsWith(sr)){let s=await oe(o,".md");return s.length?{commands:s}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let s=await oe(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".continue/prompts")){let s=await oe(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".continue/skills")){let s=await qo(o);return s.length?{skills:s}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let s=await oe(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".junie/rules")){let s=await oe(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".junie/agents")){let s=await oe(o,".md");return s.length?{agents:s}:{}}if(n.startsWith(".junie/skills")){let s=await qo(o);return s.length?{skills:s}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let s=await x(o),a=[...new Set(s.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}i(Qw,"inferImplicitPickFromNativePath");function tL(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}i(tL,"isImplicitPickEmpty");function Ua(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}i(Ua,"normalizePath");function fM(t,e){let r=Ua(t),n=Ua(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}i(fM,"overlapsPath");function cm(t,e){let r=t??[];return r.includes(e)||r.push(e),r}i(cm,"addUnique");async function gM(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),n=i(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}}i(gM,"makeStageRoot");function hM(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:cm(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let s=Ua(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:cm(r?.commands,s.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:cm(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=Ua(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:cm(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}i(hM,"buildPickFromResults");function yM(t,e,r,n){let o=join(e,...Ua(t).split("/")),s=r.filter(a=>fM(o,a.fromPath));if(s.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}".`);return {features:[...new Set(s.map(a=>a.feature))],pick:hM(s,e)}}i(yM,"scopeImportedResults");async function Tf(t,e){let{stageRoot:r,cleanup:n}=await gM(t);try{let o=await wa(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}i(Tf,"stageImportedNativeRepo");async function Nf(t,e,r){let n=await Tf(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...yM(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}i(Nf,"stageNativeInstallScope");async function oL(t,e,r,n){let o=n.explicitTarget?.trim();o&&ie.parse(o);let s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");Vw(o,s);let a=join(t,".agentsmesh"),l=await F(a),c=s?lm(s):void 0,m=!l&&!o?await rl(t)??void 0:void 0;if(!o&&c&&m&&c!==m)throw new Error(`Install path suggests native layout "${c}" but auto-detect imported "${m}". Use --target ${c} for this path, or install from the repo root without a conflicting subtree path.`);let p=o??c??m,u=!!s&&!!p&&!s.startsWith(".agentsmesh");if(!l&&p){if(u){let k=await Nf(t,s,p);return {discoveryRoot:k.stageRoot,implicitPick:k.pick,scopedFeatures:k.features,yamlTarget:p,importHappened:true,cleanup:k.cleanup}}let _=await Tf(t,p);return {discoveryRoot:s?join(_.stageRoot,s):_.stageRoot,yamlTarget:p,importHappened:true,cleanup:_.cleanup}}let d;l?s?p&&Pf(s,p)?d=t:d=e:d=t:d=e;let g,h,C;if(u&&p){let _=await Nf(t,s,p);d=_.stageRoot,g=_.pick,h=_.features,C=_.cleanup;}else if(d===t&&s&&p&&Pf(s,p)&&(g=await Qw(t,s,p),tL(g)))throw new Error(`No installable native resources found under "${s}" for target "${p}".`);let O;return o?O=o:p&&(g&&Jw(g)||(h?.length??0)>0)&&(O=p),{discoveryRoot:d,implicitPick:g,scopedFeatures:h,yamlTarget:O,importHappened:C!==void 0,cleanup:C}}i(oL,"prepareInstallDiscovery");async function sL(t,e,r,n){let o=await oL(t,e,r,{explicitTarget:n}),{canonical:s,implicitPick:a}=await sm(o.discoveryRoot),l=a??o.implicitPick,c=ui(s,{implicitPick:l,scopedFeatures:o.scopedFeatures}),m=Zo(c);return {prep:o,discovered:s,implicitPick:l,narrowed:c,discoveredFeatures:m}}i(sL,"resolveDiscoveredForInstall");async function iL(t){return t.explicitAs?{implicitPick:void 0,...await zw(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:sL(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}i(iL,"resolveInstallDiscovery");function fi(t){return t==="."||t===""?void 0:t}i(fi,"trimDot");function _M(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}i(_M,"markdownPick");async function lL(t){if(!t.as)return {pathInRepo:fi(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:fi(dirname(e)),pick:_M(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:fi(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 im(o);return {pathInRepo:fi(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:fi(e)}}}}return {pathInRepo:fi(e)}}i(lL,"resolveManualInstallPersistence");async function Lr(t){return process.stdin.isTTY?new Promise(e=>{let r=cL.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}i(Lr,"confirm");function SM(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}i(SM,"hasArrayResources");function mL(t){return SM(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}i(mL,"hasInstallableResources");async function pL(t,e,r,n){let o=t.skills.map(l=>Gw(l)),s=o.filter(l=>l.ok).map(l=>l.skill),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Lr(`Include invalid skill "${l.skill.name}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.skill);else e&&(s=o.map(l=>l.skill));return r&&(s=o.filter(l=>l.ok).map(l=>l.skill)),s}i(pL,"resolveSkillPool");async function uL(t,e,r,n){let o=t.rules.map(l=>jw(l)),s=o.filter(l=>l.ok).map(l=>l.rule),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Lr(`Include invalid rule "${Ee(l.rule)}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.rule);else e&&(s=o.map(l=>l.rule));return r&&(s=o.filter(l=>l.ok).map(l=>l.rule)),s}i(uL,"resolveRulePool");async function dL(t,e,r,n){let o=t.commands.map(l=>Uw(l)),s=o.filter(l=>l.ok).map(l=>l.command),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Lr(`Include invalid command "${l.command.name}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.command);else e&&(s=o.map(l=>l.command));return r&&(s=o.filter(l=>l.ok).map(l=>l.command)),s}i(dL,"resolveCommandPool");async function fL(t,e,r,n){let o=t.agents.map(l=>Kw(l)),s=o.filter(l=>l.ok).map(l=>l.agent),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Lr(`Include invalid agent "${l.agent.name}" anyway? (${l.reason}). You can fix it later.`)&&s.push(l.agent);else e&&(s=o.map(l=>l.agent));return r&&(s=o.filter(l=>l.ok).map(l=>l.agent)),s}i(fL,"resolveAgentPool");async function gL(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>Ee(a)),o=e.commands.map(a=>a.name),s=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(l=>l.name===a.name)&&(await Lr(`Skill "${a.name}" already exists in merged config. Add extend anyway?`)||(r=r.filter(c=>c!==a.name)));for(let a of e.rules){let l=Ee(a);t.rules.some(c=>Ee(c)===l)&&(await Lr(`Rule "${l}" already exists in merged config. Add extend anyway?`)||(n=n.filter(m=>m!==l)));}for(let a of e.commands)t.commands.some(l=>l.name===a.name)&&(await Lr(`Command "${a.name}" already exists in merged config. Add extend anyway?`)||(o=o.filter(c=>c!==a.name)));for(let a of e.agents)t.agents.some(l=>l.name===a.name)&&(await Lr(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(s=s.filter(c=>c!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:s}}i(gL,"resolveInstallConflicts");function hL(t,e){if(!t)return;let r={},n=t.skills?.filter(l=>e.skillNames.includes(l)),o=t.rules?.filter(l=>e.ruleSlugs.includes(l)),s=t.commands?.filter(l=>e.commandNames.includes(l)),a=t.agents?.filter(l=>e.agentNames.includes(l));return n&&n.length>0&&(r.skills=n),o&&o.length>0&&(r.rules=o),s&&s.length>0&&(r.commands=s),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}i(hL,"pickForSelectedResources");function CM(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}i(CM,"pathEndsWithName");function mm(t,e,r){return r!==1||e.length!==1?false:CM(t,e[0])}i(mm,"inferSingleNamePick");function yL(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:n,selected:o}=t,s={},a=o.skillNames.length>0&&(!!r?.skills?.length||o.skillNames.length<n.skills||mm(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||mm(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||mm(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||mm(e,o.agentNames,n.agents));return a&&(s.skills=[...o.skillNames]),l&&(s.rules=[...o.ruleSlugs]),c&&(s.commands=[...o.commandNames]),m&&(s.agents=[...o.agentNames]),Object.keys(s).length?s:void 0}i(yL,"buildInstallPick");function IL(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]}i(IL,"deriveInstallFeatures");function OM(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}i(OM,"isEmptyInstallSelection");function _L(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=i(l=>r.includes(l),"had"),s=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(s)throw new Error(`No ${s} selected to install.`);let a=r.some(l=>["mcp","permissions","hooks","ignore"].includes(l));if(OM(e)&&!a)throw new Error("No resources selected to install.")}i(_L,"ensureInstallSelection");function SL(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.`)}i(SL,"assertExtendNameAvailable");function RM(t,e,r){if(r===void 0){if(!t)return;let o={...t};for(let s of ["skills","commands","rules","agents"])e.includes(s)&&delete o[s];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 s=r[o];if(s===void 0||s.length===0){delete n[o];continue}n[o]=[...new Set([...t?.[o]??[],...s])];}return Object.keys(n).length?n:void 0}i(RM,"mergePick");function CL(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])],s=RM(n.pick,e.features,e.pick);return t.map((a,l)=>l===r?{name:e.name,source:e.source,version:e.version??n.version,features:o,path:e.path!==void 0?e.path:n.path,pick:s,target:e.target??n.target}:a)}i(CL,"mergeExtendList");A();async function OL(t,e,r){let n=await I(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),s=CL(e.extends,r);o.extends=s;let a=stringify(o,{indent:2,lineWidth:0});await S(t,a.endsWith(`
|
|
287
293
|
`)?a:`${a}
|
|
288
|
-
`);}i(
|
|
289
|
-
${JSON.stringify(s,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await
|
|
290
|
-
`);return `sha256:${
|
|
291
|
-
`),t.permissions!==null&&await
|
|
294
|
+
`);}i(OL,"writeAgentsmeshWithNewExtend");async function RL(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,s=LM(n);if(SL(r.extends,s),o){y.info(`[dry-run] Would add extend:
|
|
295
|
+
${JSON.stringify(s,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await OL(a,r,s),y.success(`Wrote extends entry "${s.name}" to agentsmesh.yaml.`);}i(RL,"writeInstallAsExtend");function LM(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?ie.parse(t.yamlTarget):void 0}}i(LM,"toNewExtendEntry");A();A();var bM="pack.yaml";async function pm(t){let e=await x(t),r=[];for(let s of e.sort()){let a=relative(t,s).replace(/\\/g,"/");if(a===bM)continue;let l=await Hc(s);l!==null&&r.push(`${a}:${l}`);}let n=r.join(`
|
|
296
|
+
`);return `sha256:${Pa(n)}`}i(pm,"hashPackContent");async function NM(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await R(r);for(let n of t.rules){let o=join(r,basename(n.source));await copyFile(n.source,o);}}i(NM,"writeRules");async function DM(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await R(r);for(let n of t.commands){let o=join(r,basename(n.source));await copyFile(n.source,o);}}i(DM,"writeCommands");async function FM(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await R(r);for(let n of t.agents){let o=join(r,basename(n.source));await copyFile(n.source,o);}}i(FM,"writeAgents");async function vM(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await R(r);for(let n of t.skills){let o=join(r,n.name);await R(o),await copyFile(n.source,join(o,"SKILL.md"));for(let s of n.supportingFiles){let a=join(o,s.relativePath);await R(dirname(a)),await copyFile(s.absolutePath,a);}}}i(vM,"writeSkills");async function $M(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
|
|
297
|
+
`),t.permissions!==null&&await S(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await S(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await S(join(e,"ignore"),`${t.ignore.join(`
|
|
292
298
|
`)}
|
|
293
|
-
`);}i(
|
|
294
|
-
`),t.permissions!==null&&await
|
|
299
|
+
`);}i($M,"writeSettings");function MM(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.`)}i(MM,"validatePackName");async function EL(t,e,r,n){MM(e);let o=join(t,`${e}.tmp`),s=join(t,e);await F(o)&&await rm$1(o,{recursive:true,force:true}),await R(o),await NM(r,o),await DM(r,o),await FM(r,o),await vM(r,o),await $M(r,o);let a=await pm(o),l=Yn({...n,content_hash:a});return await S(join(o,"pack.yaml"),stringify(l)),await F(s)&&await rm$1(s,{recursive:true,force:true}),await mkdir(t,{recursive:true}),await rename(o,s),l}i(EL,"materializePack");A();function Mf(t,e){return [...new Set([...t,...e])]}i(Mf,"union");function jM(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=Mf(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}i(jM,"mergePathScope");function UM(t,e,r){let n={...t};for(let s of e)r&&r[s]!==void 0?n[s]=Mf(n[s]??[],r[s]):delete n[s];return (n.skills?.length??0)>0||(n.rules?.length??0)>0||(n.commands?.length??0)>0||(n.agents?.length??0)>0?n:void 0}i(UM,"mergePick");async function KM(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await R(r);for(let n of t.rules)await copyFile(n.source,join(r,basename(n.source)));}i(KM,"mergeRules");async function WM(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await R(r);for(let n of t.commands)await copyFile(n.source,join(r,basename(n.source)));}i(WM,"mergeCommands");async function BM(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await R(r);for(let n of t.agents)await copyFile(n.source,join(r,basename(n.source)));}i(BM,"mergeAgents");async function HM(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await R(r);for(let n of t.skills){let o=join(r,n.name);await R(o),await copyFile(n.source,join(o,"SKILL.md"));for(let s of n.supportingFiles){let a=join(o,s.relativePath);await R(dirname(a)),await copyFile(s.absolutePath,a);}}}i(HM,"mergeSkills");async function zM(t,e){t.mcp!==null&&await S(join(e,"mcp.json"),`${JSON.stringify(t.mcp,null,2)}
|
|
300
|
+
`),t.permissions!==null&&await S(join(e,"permissions.yaml"),stringify(t.permissions)),t.hooks!==null&&await S(join(e,"hooks.yaml"),stringify(t.hooks)),t.ignore.length>0&&await S(join(e,"ignore"),`${t.ignore.join(`
|
|
295
301
|
`)}
|
|
296
|
-
`);}i(
|
|
297
|
-
`,o=parse(n)??{};if(o.plugins||(o.plugins=[]),o.plugins.some(a=>a.id===e.id))return;let s={id:e.id,source:e.source};e.version!==void 0&&(s.version=e.version),o.plugins.push(s),await
|
|
302
|
+
`);}i(zM,"mergeSettings");async function wL(t,e,r,n,o,s){await KM(r,t),await WM(r,t),await BM(r,t),await HM(r,t),await zM(r,t);let a=Mf(e.features,n),l=UM(e.pick,n,o),c=jM(e,s?.path),m=await pm(t),p=new Date().toISOString(),u=Yn({...e,source:s?.source??e.source,...s?.version!==void 0?{version:s.version}:e.version!==void 0?{version:e.version}:{},features:a,pick:l,...s?.target!==void 0?{target:s.target}:e.target!==void 0?{target:e.target}:{},...c,...s?.as!==void 0?{as:s.as}:e.as!==void 0?{as:e.as}:{},updated_at:p,content_hash:m});return await S(join(t,"pack.yaml"),stringify(u)),u}i(wL,"mergeIntoPack");A();function JM(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}i(JM,"pathScope");function YM(t,e){let r=new Set(e.skillNames),n=new Set(e.ruleSlugs),o=new Set(e.commandNames),s=new Set(e.agentNames);return {...t,skills:t.skills.filter(a=>r.has(a.name)),rules:t.rules.filter(a=>n.has(Ee(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>s.has(a.name))}}i(YM,"applySelection");async function LL(t){let{canonicalDir:e,packName:r,narrowed:n,selected:o,sourceForYaml:s,version:a,sourceKind:l,entryFeatures:c,pick:m,yamlTarget:p,pathInRepo:u,manualAs:d,renameExistingPack:g}=t,h=join(e,"packs"),C=YM(n,o),O=new Date().toISOString(),_=p!==void 0?ie.parse(p):void 0,k=await iE(h,s,{target:_,as:d,features:c}),D=r,b=c,P=m,J=u,j;if(k){let W=k.packDir,nt=k.meta;if(g&&k.name!==r){let st=join(h,r);if(await F(st))throw new Error(`Auto-generated pack name "${r}" collides with an existing incompatible pack. Use --name to choose a different pack name.`);await rename(k.packDir,st),W=st,nt={...k.meta,name:r};}let ft=await wL(W,nt,C,c,m,{source:s,...a!==void 0?{version:a}:{},..._!==void 0?{target:_}:{},...u?{path:u}:{},...d!==void 0?{as:d}:{}});D=ft.name,b=ft.features,P=ft.pick,J=ft.path,j=ft.paths,y.success(`Updated pack "${ft.name}" in .agentsmesh/packs/.`);}else {if(await Wc(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 EL(h,r,C,{name:r,source:s,...a!==void 0&&{version:a},source_kind:l,installed_at:O,updated_at:O,features:c,...m!==void 0&&{pick:m},..._!==void 0&&{target:_},...JM(u),...d!==void 0&&{as:d}}),y.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await Fw(e,vw({name:D,source:s,version:a,sourceKind:l,features:b,pick:P,target:_,path:J,paths:j,as:d})),l!=="local"&&await Eg(s);}i(LL,"installAsPack");function ZM(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(ZM,"sanitize");function qM(t){try{let r=new URL(t.replace(/^git\+/,"https://").replace(/^ssh:\/\/git@/,"https://")).pathname.split("/").filter(Boolean);if(r.length===0)return "repo";let n=r[r.length-1].replace(/\.git$/i,"");return r.length>=2?`${r[r.length-2].replace(/\.git$/i,"")}-${n}`:n}catch{return "repo"}}i(qM,"gitUrlLastSegments");function AL(t,e,r){let n;if(t.kind==="local"){let l=(t.localRoot??"local").split(/[/\\]/).filter(Boolean);n=l[l.length-1]??"local";}else t.kind==="github"&&t.org&&t.repo?n=`${t.org}-${t.repo}`:t.kind==="gitlab"&&t.org&&t.repo?n=`${t.org.replace(/\//g,"-")}-${t.repo}`:t.gitRemoteUrl?n=qM(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=ZM(n)||"extend";if(!r.has(o))return o;let s=2;for(;r.has(`${o}-${s}`);)s++;return `${o}-${s}`}i(AL,"suggestExtendName");function bL(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,s=new Set(e.extends.map(a=>a.name));return o||AL(r,{featureHint:n.length===1?n[0]:void 0},s)}i(bL,"selectInstallEntryName");function PL(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=ui(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:Zo(n)}}i(PL,"applyReplayInstallScope");async function xL(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:s,nameOverride:a,explicitAs:l,config:c,context:m,parsed:p,sourceForYaml:u,version:d,pathInRepo:g,persisted:h,replay:C,prep:O,implicitPick:_,narrowed:k,discoveredFeatures:D}=t,{narrowed:b,discoveredFeatures:P}=PL(k,D,C);if(!mL(b))throw new Error(_||O.scopedFeatures?"No resources match the install path or implicit selection (check pick names exist at that path).":"No supported resources found to install (skills, rules, commands, agents).");let J=await pL(b,r,n,o),j=await uL(b,r,n,o),W=await dL(b,r,n,o),nt=await fL(b,r,n,o),ft={skills:J.length,rules:j.length,commands:W.length,agents:nt.length},{canonical:st}=await Oe(c,m.configDir,{},m.canonicalDir),Yt=!r&&!n&&o?await gL(st,{skills:J,rules:j,commands:W,agents:nt}):{skillNames:J.map(se=>se.name),ruleSlugs:j.map(se=>Ee(se)),commandNames:W.map(se=>se.name),agentNames:nt.map(se=>se.name)};_L({selected:Yt,discoveredFeatures:P,preConflict:ft});let pt=C?.features??IL(P,Yt);if(pt.length===0)throw new Error("No features left to install after selection.");let St=hL(C?.pick,Yt)??h.pick??yL({pathInRepo:h.pathInRepo??g,implicitPick:_,preConflictCounts:ft,selected:Yt}),Xt=bL({config:c,parsed:p,entryFeatures:pt,nameOverride:a});if(s){if(await RL({configDir:m.configDir,config:c,entryArgs:{name:Xt,source:u,version:d,features:pt,path:h.pathInRepo,pick:St,yamlTarget:O.yamlTarget},dryRun:n}),n)return}else {if(n){y.info(`[dry-run] Would install pack "${Xt}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`);return}await LL({canonicalDir:m.canonicalDir,packName:Xt,narrowed:b,selected:Yt,sourceForYaml:u,version:d,sourceKind:p.kind,entryFeatures:pt,pick:St,yamlTarget:O.yamlTarget,pathInRepo:h.pathInRepo,manualAs:l,renameExistingPack:a===""});}await mi(e==="global"?{global:true}:{},m.rootBase)!==0&&y.warn(`Generate failed after install. Fix the issue and run agentsmesh generate${e==="global"?" --global":""}.`);}i(xL,"executeRunInstallPoolsAndWrite");async function jf(t,e,r,n){let{sync:o,dryRun:s,force:a,useExtends:l,explicitPath:c,explicitTarget:m,explicitAs:p,nameOverride:u}=Mw(t),d=t.global===true?"global":"project",g=e[0]?.trim();if(o){let{context:Yt}=await ut(r,d);if(await $w({sync:o,canonicalDir:Yt.canonicalDir,reinstall:i(async pt=>{let St=pt.paths&&pt.paths.length>0?pt.paths:[pt.path];for(let Xt of St)await jf({...a?{force:true}:{},...s?{"dry-run":true}:{},...d==="global"?{global:true}:{},name:pt.name,...pt.target?{target:pt.target}:{},...Xt?{path:Xt}:{},...pt.as?{as:pt.as}:{}},[pt.source],r,{features:pt.features,pick:pt.pick});},"reinstall")}))return}if(!g)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let h=process.stdin.isTTY;if(!h&&!a&&!s)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:C,context:O}=await ut(r,d),_=await Lf(g,O.configDir,c);if(_.kind!=="local"&&!await Lw())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:k,sourceForYaml:D,version:b}=await Pw(_,g),P=_.pathInRepo.replace(/^\/+|\/+$/g,"");if(P){let Yt=normalize(P).replace(/\\/g,"/");if(Yt===".."||Yt.startsWith("../"))throw new Error(`Install --path "${_.pathInRepo}" escapes the source root. Path must stay within the source.`)}let J=P?join(k,P):k;if(!await F(J))throw new Error(`Install path does not exist: ${J}`);let j=await lL({as:p,contentRoot:J,pathInRepo:P}),{prep:W,implicitPick:nt,narrowed:ft,discoveredFeatures:st}=await iL({resolvedPath:k,contentRoot:J,pathInRepo:P,explicitTarget:m,explicitAs:p,replayPick:n?.pick});try{await xL({scope:d,force:a,dryRun:s,tty:h,useExtends:l,nameOverride:u,explicitAs:p,config:C,context:O,parsed:_,sourceForYaml:D,version:b,pathInRepo:P,persisted:j,replay:n,prep:W,implicitPick:nt,narrowed:ft,discoveredFeatures:st});}finally{W.cleanup&&await W.cleanup();}}i(jf,"runInstall");async function TL(t,e,r){await jf(t,e,r);}i(TL,"runInstall");A();var Wf="agentsmesh.yaml";async function Bf(t){let e=join(t,Wf),r=await I(e);return r===null?{}:parse(r)??{}}i(Bf,"readScopedConfigRaw");async function DL(t,e){let r=join(t,Wf),n=await I(r)??`version: 1
|
|
303
|
+
`,o=parse(n)??{};if(o.plugins||(o.plugins=[]),o.plugins.some(a=>a.id===e.id))return;let s={id:e.id,source:e.source};e.version!==void 0&&(s.version=e.version),o.plugins.push(s),await S(r,stringify(o));}i(DL,"writePluginEntry");async function FL(t,e){let r=join(t,Wf),n=await I(r);if(n===null)return false;let o=parse(n)??{},s=(o.plugins??[]).length;o.plugins=(o.plugins??[]).filter(l=>l.id!==e),o.pluginTargets&&(o.pluginTargets=o.pluginTargets.filter(l=>l!==e));let a=o.plugins.length<s;return a&&await S(r,stringify(o)),a}i(FL,"removePluginEntry");async function $L(t,e,r){let n=e[0];if(n===void 0||n==="")return vL(),0;switch(n){case "add":return eG(t,e.slice(1),r);case "list":return rG(r);case "remove":return nG(e.slice(1),r);case "info":return oG(e.slice(1),r);default:return y.error(`Unknown plugin subcommand: ${n}`),vL(),2}}i($L,"runPlugin");async function eG(t,e,r){let n=e[0];if(!n)return y.error("Usage: agentsmesh plugin add <source> [--version <v>] [--id <id>]"),2;let o=typeof t.version=="string"?t.version:void 0,a=(typeof t.id=="string"?t.id:void 0)??sG(n);try{await DL(r,{id:a,source:n,version:o});}catch(l){return y.error(`Failed to update config: ${l instanceof Error?l.message:String(l)}`),1}return y.success(`Plugin '${a}' added to agentsmesh.yaml`),y.warn("Plugins load as trusted Node.js modules and run with full process privileges. Only install plugins from sources you trust."),y.info(`Next: npm install ${n}${o!==void 0?`@${o}`:"@latest"}`),y.info(`Then add '${a}' to pluginTargets in agentsmesh.yaml to enable it.`),0}i(eG,"runPluginAdd");async function rG(t){let e;try{e=await Bf(t);}catch(n){return y.error(`Failed to read config: ${n instanceof Error?n.message:String(n)}`),1}let r=e.plugins??[];if(r.length===0)return y.info("No plugins configured. Use: agentsmesh plugin add <source>"),0;y.info("Configured plugins:");for(let n of r){let o="\u2717",s="";try{let l=await tm(n,t);o=l.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",s=l.descriptors.map(c=>c.id).join(", ");}catch{}let a=n.version!==void 0?`@${n.version}`:"";y.info(` ${n.id} | ${n.source}${a} | ${o} | ${s}`);}return 0}i(rG,"runPluginList");async function nG(t,e){let r=t[0];if(!r)return y.error("Usage: agentsmesh plugin remove <id>"),2;try{await FL(e,r)?y.success(`Plugin '${r}' removed from agentsmesh.yaml`):y.warn(`Plugin '${r}' was not found in agentsmesh.yaml`);}catch(n){return y.error(`Failed to update config: ${n instanceof Error?n.message:String(n)}`),1}return 0}i(nG,"runPluginRemove");async function oG(t,e){let r=t[0];if(!r)return y.error("Usage: agentsmesh plugin info <id>"),2;let n;try{n=await Bf(e);}catch(a){return y.error(`Failed to read config: ${a instanceof Error?a.message:String(a)}`),1}let o=(n.plugins??[]).find(a=>a.id===r);if(!o)return y.error(`Plugin '${r}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`),1;let s;try{s=await tm(o,e);}catch(a){return y.error(`Failed to load plugin '${r}': ${a instanceof Error?a.message:String(a)}`),1}y.info(`Plugin: ${o.id}`),y.info(`Source: ${o.source}${o.version!==void 0?`@${o.version}`:""}`),y.info(`Descriptors: ${s.descriptors.length}`);for(let a of s.descriptors)y.info(` - ${a.id}: ${a.emptyImportMessage}`);return 0}i(oG,"runPluginInfo");function sG(t){let e=t;if(e.startsWith("@")){let n=e.indexOf("/");n!==-1&&(e=e.slice(n+1));}e.startsWith("agentsmesh-target-")&&(e=e.slice(18)),e.startsWith("file:")&&(e=e.slice(5));let r=e.replace(/\\/g,"/").split("/");return e=r[r.length-1]??e,e=e.replace(/\.(js|ts)$/,""),e=e.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),e||"plugin"}i(sG,"derivePluginId");function vL(){y.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),y.info(""),y.info("Subcommands:"),y.info(" add <source> Register a plugin package in agentsmesh.yaml"),y.info(" list Show all configured plugins and load status"),y.info(" remove <id> Remove a plugin from agentsmesh.yaml"),y.info(" info <id> Show descriptor details for a configured plugin"),y.info(""),y.info("Flags (add):"),y.info(" --version <v> Pin plugin version"),y.info(" --id <id> Override derived plugin id"),y.info(""),y.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),y.info(" Only install plugins from sources you trust.");}i(vL,"printPluginHelp");A();br();function hi(t){return t.toUpperCase().replace(/-/g,"_")}i(hi,"toPrefix");function gi(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}i(gi,"toPascal");function ML(t){let e=hi(t.id);return `export const ${e}_TARGET = '${t.id}';
|
|
298
304
|
|
|
299
305
|
// Project-level paths
|
|
300
306
|
export const ${e}_DIR = '.${t.id}';
|
|
@@ -307,7 +313,7 @@ export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
|
|
|
307
313
|
// Canonical paths
|
|
308
314
|
export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
|
|
309
315
|
export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
|
|
310
|
-
`}i(
|
|
316
|
+
`}i(ML,"TEMPLATE_CONSTANTS");function GL(t){let e=hi(t.id),r=gi(t.id);return `import type { TargetGenerators } from '../catalog/target.interface.js';
|
|
311
317
|
import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
|
|
312
318
|
import { generateRules } from './generator.js';
|
|
313
319
|
import { importFrom${r} } from './importer.js';
|
|
@@ -404,21 +410,21 @@ export const descriptor = {
|
|
|
404
410
|
buildImportPaths: build${r}ImportPaths,
|
|
405
411
|
detectionPaths: [${e}_DIR],
|
|
406
412
|
} satisfies TargetDescriptor;
|
|
407
|
-
`}i(
|
|
413
|
+
`}i(GL,"TEMPLATE_INDEX");function jL(t){let e=hi(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
|
|
408
414
|
import { ${e}_TARGET, ${e}_DIR } from './constants.js';
|
|
409
415
|
|
|
410
|
-
export interface ${
|
|
416
|
+
export interface ${gi(t.id)}Output {
|
|
411
417
|
path: string;
|
|
412
418
|
content: string;
|
|
413
419
|
}
|
|
414
420
|
|
|
415
|
-
export function generateRules(_canonical: CanonicalFiles): ${
|
|
421
|
+
export function generateRules(_canonical: CanonicalFiles): ${gi(t.id)}Output[] {
|
|
416
422
|
// TODO(agentsmesh-scaffold): implement generateRules for ${t.displayName}
|
|
417
423
|
void ${e}_TARGET;
|
|
418
424
|
void ${e}_DIR;
|
|
419
425
|
return [];
|
|
420
426
|
}
|
|
421
|
-
`}i(
|
|
427
|
+
`}i(jL,"TEMPLATE_GENERATOR");function UL(t){let e=gi(t.id),r=hi(t.id);return `import type { ImportResult } from '../../core/types.js';
|
|
422
428
|
import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
|
|
423
429
|
import { ${r}_TARGET } from './constants.js';
|
|
424
430
|
|
|
@@ -430,7 +436,7 @@ export async function importFrom${e}(
|
|
|
430
436
|
void ${r}_TARGET;
|
|
431
437
|
return [];
|
|
432
438
|
}
|
|
433
|
-
`}i(
|
|
439
|
+
`}i(UL,"TEMPLATE_IMPORTER");function KL(t){let e=hi(t.id);return `/** Lint rules for the ${t.id} target. */
|
|
434
440
|
import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
|
|
435
441
|
import { validateRules } from '../../core/lint/validate-rules.js';
|
|
436
442
|
import { ${e}_TARGET } from './constants.js';
|
|
@@ -448,7 +454,7 @@ export function lintRules(
|
|
|
448
454
|
target: ${e}_TARGET,
|
|
449
455
|
}));
|
|
450
456
|
}
|
|
451
|
-
`}i(
|
|
457
|
+
`}i(KL,"TEMPLATE_LINTER");function WL(t){return `/**
|
|
452
458
|
* ${t.displayName}-specific lint hooks.
|
|
453
459
|
*/
|
|
454
460
|
|
|
@@ -458,7 +464,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
|
|
|
458
464
|
// TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
|
|
459
465
|
return [];
|
|
460
466
|
}
|
|
461
|
-
`}i(
|
|
467
|
+
`}i(WL,"TEMPLATE_LINT_HOOKS");function BL(t){let e=gi(t.id),r=hi(t.id);return `import type { TargetLayoutScope } from '../../../targets/catalog/target-descriptor.js';
|
|
462
468
|
import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
|
|
463
469
|
|
|
464
470
|
export async function build${e}ImportPaths(
|
|
@@ -470,7 +476,7 @@ export async function build${e}ImportPaths(
|
|
|
470
476
|
// Reference: src/core/reference/import-maps/kiro.ts for a full example
|
|
471
477
|
void ${r}_DIR;
|
|
472
478
|
}
|
|
473
|
-
`}i(
|
|
479
|
+
`}i(BL,"TEMPLATE_IMPORT_MAP");function HL(t){return `import { describe, it, expect } from 'vitest';
|
|
474
480
|
import type { CanonicalFiles } from '../../../../src/core/types.js';
|
|
475
481
|
import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
|
|
476
482
|
|
|
@@ -499,7 +505,7 @@ describe('generateRules (${t.id})', () => {
|
|
|
499
505
|
expect(result).toHaveLength(0);
|
|
500
506
|
});
|
|
501
507
|
});
|
|
502
|
-
`}i(
|
|
508
|
+
`}i(HL,"TEMPLATE_GENERATOR_TEST");function zL(t){let e=gi(t.id);return `import { describe, it, expect } from 'vitest';
|
|
503
509
|
import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
|
|
504
510
|
|
|
505
511
|
describe('importFrom${e} (${t.id})', () => {
|
|
@@ -513,7 +519,7 @@ describe('importFrom${e} (${t.id})', () => {
|
|
|
513
519
|
expect(result).toHaveLength(0);
|
|
514
520
|
});
|
|
515
521
|
});
|
|
516
|
-
`}i(
|
|
522
|
+
`}i(zL,"TEMPLATE_IMPORTER_TEST");function VL(t){return `# ${t.displayName} Workspace
|
|
517
523
|
|
|
518
524
|
Follow the ${t.displayName} configuration files and keep changes small.
|
|
519
|
-
`}i(
|
|
525
|
+
`}i(VL,"TEMPLATE_FIXTURE_ROOT_MD");var aG=/^[a-z][a-z0-9-]*$/;async function JL(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,s={id:e,displayName:o};if(!aG.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(Ot.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:ML(s)},{rel:`src/targets/${e}/index.ts`,content:GL(s)},{rel:`src/targets/${e}/generator.ts`,content:jL(s)},{rel:`src/targets/${e}/importer.ts`,content:UL(s)},{rel:`src/targets/${e}/linter.ts`,content:KL(s)},{rel:`src/targets/${e}/lint.ts`,content:WL(s)},{rel:`src/core/reference/import-maps/${e}.ts`,content:BL(s)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:HL(s)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:zL(s)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:VL(s)}],l=[],c=[];for(let p of a){let u=join(r,p.rel);if(!n&&await F(u)){c.push(u);continue}await S(u,p.content),l.push(u);}let m=["1. Run: pnpm catalog:generate (auto-discovers the new target \u2014 updates IDs, descriptors, and import-map barrel)",`2. Fill in TODO(agentsmesh-scaffold) markers in src/targets/${e}/`,`3. Run: pnpm typecheck && pnpm test -- tests/unit/targets/${e}`,"4. Run: pnpm schemas:generate && pnpm matrix:generate"];return {written:l,skipped:c,postSteps:m}}i(JL,"writeTargetScaffold");async function XL(t,e,r){let n=e[0];return n===void 0||n===""?(YL(),0):n==="scaffold"?lG(t,e.slice(1),r):(y.error(`Unknown target subcommand: ${n}`),YL(),2)}i(XL,"runTarget");async function lG(t,e,r){let n=e[0];if(!n)return y.error("Usage: agentsmesh target scaffold <id> [--name <displayName>] [--force]"),2;let o=typeof t.name=="string"?t.name:void 0,s=t.force===true,a;try{a=await JL({id:n,displayName:o,projectRoot:r,force:s});}catch(l){return y.error(l instanceof Error?l.message:String(l)),1}if(a.written.length>0)for(let l of a.written){let c=l.startsWith(r)?l.slice(r.length+1):l;y.success(`created ${c.replaceAll("\\","/")}`);}if(a.skipped.length>0)for(let l of a.skipped){let c=l.startsWith(r)?l.slice(r.length+1):l;y.warn(`skipped ${c.replaceAll("\\","/")} (already exists \u2014 use --force to overwrite)`);}if(a.written.length>0){y.info(""),y.info("Next steps:");for(let l of a.postSteps)y.info(` ${l}`);}return 0}i(lG,"runScaffold");function YL(){y.info("Usage: agentsmesh target <subcommand> [args] [flags]"),y.info(""),y.info("Subcommands:"),y.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),y.info(""),y.info("Flags (scaffold):"),y.info(" --name <displayName> Human-readable name (defaults to id)"),y.info(" --force Overwrite existing files");}i(YL,"printTargetHelp");function pG(t){let e={},r=[],n="help";for(let o=0;o<t.length;o++){let s=t[o];if(n==="help"&&s==="--version")return {command:"version",flags:{},args:[]};if(n==="help"&&s==="--help")return {command:"help",flags:{},args:[]};if(s.startsWith("--")){let a=s.slice(2),l=t[o+1];l===void 0||l.startsWith("--")?e[a]=true:(e[a]=l,o++);continue}n==="help"?n=s:r.push(s);}return {command:n,flags:e,args:r}}i(pG,"parseArgs");var uG=["init","generate","import","diff","lint","watch","check","merge","matrix","install","plugin","target"];function dG(t){return async(e,r)=>{y.info(`Not implemented yet: ${t}`);}}i(dG,"stub");var fG={...Object.fromEntries(uG.map(t=>[t,dG(t)])),generate:i(async(t,e)=>{let r=await mi(t);r!==0&&process.exit(r);},"generate"),init:i(async(t,e)=>{await aw(process.cwd(),{yes:t.yes===true,global:t.global===true});},"init"),import:i((t,e)=>cw(t),"import"),diff:i((t,e)=>dw(t),"diff"),lint:i(async(t,e)=>{let r=await _w(t);r!==0&&process.exit(r);},"lint"),check:i(async(t,e)=>{let r=await Rw(t);r!==0&&process.exit(r);},"check"),merge:i((t,e)=>ww(t),"merge"),matrix:i((t,e)=>Xo(t),"matrix"),watch:i(async(t,e)=>{let r=await Cw(t),n=i(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",n),process.on("SIGTERM",n);},"watch"),install:i((t,e)=>TL(t,e,process.cwd()),"install"),plugin:i(async(t,e)=>{let r=await $L(t,e,process.cwd());r!==0&&process.exit(r);},"plugin"),target:i(async(t,e)=>{let r=await XL(t,e,process.cwd());r!==0&&process.exit(r);},"target")},gG=Jf(fG);async function hG(t){let{command:e,flags:r,args:n}=t;if(e==="help"){qf();return}if(e==="version"){eg();return}await gG.route(e,r,n);}i(hG,"main");function yG(){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")}}i(yG,"isMainModule");if(yG()){let t=pG(process.argv.slice(2));hG(t).catch(e=>rg(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true}));}export{pG as parseArgs};
|