agentsmesh 0.10.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 +24 -0
- package/README.md +22 -22
- package/dist/canonical.d.ts +2 -2
- package/dist/canonical.js +1635 -709
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +119 -118
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +1777 -851
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1789 -863
- package/dist/index.js.map +1 -1
- package/dist/{schema-qelg8gw8.d.ts → schema-BTitJKiN.d.ts} +4 -0
- package/dist/{target-descriptor-Dhdg8s2o.d.ts → target-descriptor-D-Y6BzCL.d.ts} +1 -1
- package/dist/targets.d.ts +3 -3
- package/dist/targets.js +1649 -723
- package/dist/targets.js.map +1 -1
- package/package.json +1 -1
- package/schemas/agentsmesh.json +6 -0
- package/schemas/pack.json +2 -0
package/dist/cli.js
CHANGED
|
@@ -1,172 +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}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
|
|
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:`${hr}/${e.name}.md`,content:o}})}function Lg(t){return qt(t,$n)}function bg(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ri,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function xg(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 _e(e?.body.trim()??"",r)}var Pg=f(()=>{Bt();zr();Gn();i(Eg,"generateRules");i(Ag,"generateCommands");i(Lg,"generateSkills");i(bg,"generateMcp");i(xg,"renderAntigravityGlobalInstructions");});async function Ke(t,e,r){let n=join(t,e),s={...await ML(n),...r};await k(dirname(n)),await S(n,JSON.stringify({mcpServers:s},null,2));}async function ML(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 Ko=f(()=>{E();i(Ke,"writeMcpWithMerge");i(ML,"readExistingServers");});function Ir(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function Qt(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 Wo(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function Bo(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var Ce=f(()=>{i(Ir,"toGlobsArray");i(Qt,"toToolsArray");i(Wo,"toStringArray");i(Bo,"toStringRecord");});function UL(t,e){return e.some(r=>t.endsWith(r))}async function q(t){let r=(await P(t.srcDir)).filter(o=>UL(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 S(l.destPath,l.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:l.toPath,feature:l.feature}));}return n}var Re=f(()=>{E();i(UL,"matchesExtension");i(q,"importFileDirectory");});function Tg(t){return typeof t=="string"?t:void 0}function KL(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function mm(t,e){return e?e(t):t}function WL(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=O(e.normalizeTo(r)),s=mm(n,t.frontmatterRemap),a=KL({root:false,description:Tg(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 BL(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=O(e.normalizeTo(r)),s=mm(n,t.frontmatterRemap),a=await Z(r,{hasDescription:true,description:Tg(s.description),hasAllowedTools:true,allowedTools:Wo(s["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function HL(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=O(e.normalizeTo(r)),s=mm(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await _t(r,s,o)}}}function Ng(t){if(t.map)return t.map;switch(t.preset){case "rule":return WL(t);case "command":return BL(t);case "agent":return HL(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Dg=f(()=>{F();Y();Ce();i(Tg,"pickString");i(KL,"pruneUndefined");i(mm,"applyRemap");i(WL,"ruleMapper");i(BL,"commandMapper");i(HL,"agentMapper");i(Ng,"resolveMapper");});function pm(t,e){return t?t[e]??[]:[]}var Fg,vg=f(()=>{Fg=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];i(pm,"resolveScopedSources");});async function JL(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),p=i(R=>o(c,l,R),"normalizeTo");if(t.map){let R=await t.map({absolutePath:l,relativePath:a,content:c,destDir:s,normalizeTo:p});if(!R)continue;return await S(R.destPath,R.content),[{fromTool:n,fromPath:l,toPath:R.toPath,feature:t.feature}]}let{frontmatter:u,body:d}=O(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 YL(t,e,r,n,o){let s=Ng(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),p=await q({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(R=>h(R),"normalizeTo")});return C?{destPath:C.destPath,toPath:C.toPath,feature:t.feature,content:C.content}:null},"mapEntry")});l.push(...p);}return l}function Mg(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function XL(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=Mg(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 S(c,l.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function ZL(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:Wo(a.args),env:Bo(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:Bo(a.headers),env:Bo(a.env),description:l});}return n}async function qL(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=Mg(t);for(let s of e){let a=join(r,s),l=await I(a);if(l===null)continue;let c=ZL(l);return Object.keys(c).length===0?[]:(await Ke(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function $g(t,e,r,n,o){switch(t.mode){case "singleFile":return JL(t,e,r,n,o);case "directory":return YL(t,e,r,n,o);case "flatFile":return XL(t,e,r,n);case "mcpJson":return qL(t,e,r,n)}}async function QL(t,e,r,n,o){let s=pm(t.source,e),a=pm(t.fallbacks,e);if(s.length===0&&a.length===0)return [];if(s.length>0){let l=await $g(t,s,r,n,o);if(l.length>0)return l}return a.length>0?$g(t,a,r,n,o):[]}function tb(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function ct(t,e,r,n){let o=t.importer;if(!o)return [];let s=n?.normalize??await V(t.id,e,r),a=[];for(let l of Fg)for(let c of tb(o,l))a.push(...await QL(c,r,e,t.id,s));return a}var ke=f(()=>{At();E();Ko();F();Ce();Y();Re();Dg();vg();i(JL,"runSingleFile");i(YL,"runDirectory");i(Mg,"resolveCanonicalFilePath");i(XL,"runFlatFile");i(ZL,"parseMcpJson");i(qL,"runMcpJson");i($g,"dispatchSpec");i(QL,"runSpec");i(tb,"specsForFeature");i(ct,"runDescriptorImport");});function eb(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function We(t){let e=Ig(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=eb(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 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 Ho=f(()=>{E();F();zr();Y();i(eb,"canonicalRulePath");i(We,"splitEmbeddedRulesToCanonical");});async function rb(t,e,r,n){let o=n==="global"?Ue:Se,s=n==="project"?[o,ei]:[o];for(let a of s){let l=join(t,a),c=await I(l);if(c===null)continue;let m=join(t,lm),p=await We({content:c,projectRoot:t,rulesDir:Mn,sourcePath:l,fromTool:vn,normalize:r});e.push(...p.results);let{body:u}=O(r(p.rootContent,l,m)),d=await M(m,{root:true},u);await k(join(t,Mn)),await S(m,d),e.push({fromTool:vn,fromPath:l,toPath:lm,feature:"rules"});return}}async function jg(t,e={}){let r=e.scope??"project",n=[],o=await V(vn,t,r);return await rb(t,n,o,r),n.push(...await ct(Da,t,r,{normalize:o})),await Wt(t,r==="global"?yr:$n,vn,n,o),n}var Ug=f(()=>{At();E();F();Bt();ke();Y();Ho();Gn();dm();i(rb,"importRootRule");i(jg,"importFromAntigravity");});var Bg,Hg,zg=f(()=>{F();Y();Gn();Bg=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:`${Mn}/${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"),Hg=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=O(e(n));return {destPath:n,toPath:`${Na}/${t}`,content:await Z(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"workflowMapper");});function nb(t,e){return Jg(e).some(n=>ob(t,n))}function Vg(t,e){return t.filter(r=>nb(r,e))}function Jg(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 Jg(r+l+o))a.push(c);return a}function ob(t,e){return sb(e).test(t)}function sb(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 Yg=f(()=>{i(nb,"globMatch");i(Vg,"globFilter");i(Jg,"expandBraces");i(ob,"matchOne");i(sb,"globToRegex");});function ot(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(Vg(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 te=f(()=>{Yg();i(ot,"validateRules");});function Zg(t,e,r,n){return ot(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:vn}))}var qg=f(()=>{te();Gn();i(Zg,"lintRules");});function ib(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 Vo(t){return `${zo}${t}`}function Qg(t){let e={name:Vo(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 th(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(zo)?e.slice(zo.length):e.startsWith(oi)?e.slice(oi.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:ib(t["x-agentsmesh-allowed-tools"])}:null}function eh(t,e){return T({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var zo,oi,si=f(()=>{F();zo="am-command-",oi="ab-command-";i(ib,"toStringArray");i(Vo,"commandSkillDirName");i(Qg,"serializeCommandSkill");i(th,"parseCommandSkillFrontmatter");i(eh,"serializeImportedCommand");});function Fa(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 ab(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 Ft(t){return `${Jo}${t}`}function va(t){let e={name:Ft(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 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(Jo)?e.slice(Jo.length):e.startsWith(ii)?e.slice(ii.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:Fa(t["x-agentsmesh-tools"]),disallowedTools:Fa(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:Fa(t["x-agentsmesh-mcp-servers"]),hooks:ab(t["x-agentsmesh-hooks"]),skills:Fa(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function Be(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 Jo,ii,ee=f(()=>{F();Jo="am-agent-",ii="ab-agent-";i(Fa,"toStringArray");i(ab,"toHooks");i(Ft,"projectedAgentSkillDirName");i(va,"serializeProjectedAgentSkill");i(Jr,"parseProjectedAgentSkillFrontmatter");i(Be,"serializeImportedAgent");});function L(t,e){return W(t).relative(t,e).replace(/\\/g,"/")}async function b(t,e){return P(W(t).join(t,e)).catch(()=>[])}function nh(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function db(t,e,r,n){let o=posix.dirname(e),s=posix.dirname(r);for(;o!==n&&o!==".";)nh(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 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 u=basename(n,".md");t.set(e,`${rh}/${u}/SKILL.md`);return}let[o,...s]=n.split("/"),a=s.join("/");if(!o||!a)return;let l=o.startsWith(zo)?zo:o.startsWith(oi)?oi:null;if(l&&a==="SKILL.md"){t.set(e,`${pb}/${o.slice(l.length)}.md`);return}let c=o.startsWith(Jo)?Jo:o.startsWith(ii)?ii:null;if(c&&a==="SKILL.md"){t.set(e,`${ub}/${o.slice(c.length)}.md`);return}let m=`${rh}/${o}`;a==="SKILL.md"&&nh(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&db(t,e,p,`${r}/${o}`);}function fb(t){return t.split("/").filter(Boolean)[0]??""}async function gb(){if(fm!==void 0)return fm;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(nt(),oh)),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=fb(n);o.startsWith(".")&&e.add(o);}return fm=e,e}function hm(t){return t.split("/").some(e=>e.startsWith("."))}async function hb(t){let e=[],r=await gb(),n=W(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)||hm(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)||hm(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 $a(t,e){let r=await hb(e);for(let n of r){let o=L(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(hm(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${mb}/${c}.md`);}}var mb,pb,ub,rh,fm,vt=f(()=>{wt();E();si();ee();mb=".agentsmesh/rules",pb=".agentsmesh/commands",ub=".agentsmesh/agents",rh=".agentsmesh/skills";i(L,"rel");i(b,"listFiles");i(nh,"addDirectoryMapping");i(db,"addAncestorMappings");i($,"addSimpleFileMapping");i(z,"addSkillLikeMapping");i(fb,"firstPathSegment");i(gb,"targetRootSegments");i(hm,"hasHiddenSegment");i(hb,"listScopedAgentsFiles");i($a,"addScopedAgentsMappings");});var D,X,dt,$t=f(()=>{D=".agentsmesh/rules",X=".agentsmesh/commands",dt=".agentsmesh/agents";});async function ym(t,e,r="project"){if(r==="global"){t.set(Ue,`${D}/_root.md`);for(let n of await b(e,yr))z(t,L(e,n),yr);t.set(Uo,".agentsmesh/mcp.json");return}t.set(Se,`${D}/_root.md`),t.set(ei,`${D}/_root.md`);for(let n of await b(e,je)){let o=L(e,n);o===Se||o===ei||$(t,o,D,".md");}for(let n of await b(e,hr))$(t,L(e,n),X,".md");for(let n of await b(e,$n))z(t,L(e,n),$n);}var sh=f(()=>{vt();Gn();$t();i(ym,"buildAntigravityImportPaths");});var ih,Yr,ah,li,ci,mi,pi,ui,_r,Im,di,Yo,fi,gi,Ma,Ga,_m,hi,Sm,jn,lh,Sr=f(()=>{ih="claude-code",Yr=".claude/CLAUDE.md",ah="CLAUDE.md",li=".claude/rules",ci=".claude/commands",mi=".claude/agents",pi=".claude/skills",ui=".claude/settings.json",_r=".claude/hooks.json",Im=".claude/output-styles",di=".claudeignore",Yo=".mcp.json",fi=".claude.json",gi=".agentsmesh/rules",Ma=".agentsmesh/commands",Ga=".agentsmesh/agents",_m=".agentsmesh/skills",hi=".agentsmesh/mcp.json",Sm=".agentsmesh/permissions.yaml",jn=".agentsmesh/hooks.yaml",lh=".agentsmesh/ignore";});async function Cm(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${D}/_root.md`),t.set(_r,jn),r==="project"&&t.set("CLAUDE.md",`${D}/_root.md`),r==="global")for(let n of await b(e,".agents/skills"))z(t,L(e,n),".agents/skills");for(let n of await b(e,".claude/rules"))$(t,L(e,n),D,".md");for(let n of await b(e,".claude/commands"))$(t,L(e,n),X,".md");for(let n of await b(e,".claude/agents"))$(t,L(e,n),dt,".md");for(let n of await b(e,".claude/skills"))z(t,L(e,n),".claude/skills");}var ch=f(()=>{vt();Sr();$t();i(Cm,"buildClaudeCodeImportPaths");});var Xr,Cr,Un,Rr,mh,St,He,Zr,Kn,Wn,Bn,Hn,Rm,qr,ja,km,Om,wm,ph,re=f(()=>{Xr="cline",Cr=".clinerules",Un=".clineignore",Rr=".cline/cline_mcp_settings.json",mh=".cline/mcp_settings.json",St=".cline/skills",He=".clinerules/workflows",Zr="AGENTS.md",Kn=".clinerules/hooks",Wn="Documents/Cline/Rules",Bn="Documents/Cline/Workflows",Hn="Documents/Cline/Hooks",Rm=".agentsmesh/hooks.yaml",qr=".agentsmesh/rules",ja=".agentsmesh/commands",km=".agentsmesh/ignore",Om=".agentsmesh/mcp.json",wm=".agentsmesh/agents",ph=".agentsmesh/skills";});async function Em(t,e,r="project"){if(r==="global"){for(let n of await b(e,Wn))$(t,L(e,n),D,".md");for(let n of await b(e,Bn))$(t,L(e,n),X,".md");for(let n of await b(e,St))z(t,L(e,n),St);t.set(Rr,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${D}/_root.md`);for(let n of await b(e,".clinerules")){let o=L(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||$(t,o,D,".md");}for(let n of await b(e,".clinerules/workflows"))$(t,L(e,n),X,".md");for(let n of await b(e,".cline/skills"))z(t,L(e,n),".cline/skills");}var uh=f(()=>{vt();re();$t();i(Em,"buildClineImportPaths");});async function Am(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${D}/_root.md`),t.set(".codex/AGENTS.override.md",`${D}/_root.md`)):(t.set("AGENTS.md",`${D}/_root.md`),t.set("codex.md",`${D}/_root.md`),await $a(t,e)),r==="project")for(let n of await b(e,".codex/instructions"))$(t,L(e,n),D,".md");for(let n of await b(e,".codex/rules")){let o=L(e,n);o.endsWith(".rules")?$(t,o,D,".rules"):o.endsWith(".md")&&$(t,o,D,".md");}for(let n of await b(e,".codex/agents"))$(t,L(e,n),dt,".toml");for(let n of await b(e,".agents/skills"))z(t,L(e,n),".agents/skills");}var dh=f(()=>{vt();$t();i(Am,"buildCodexCliImportPaths");});var Xo,Oe,ze,Lm,Ua,kr,bm,Ve,Zo,yi,Ka,Wa,xm,Je=f(()=>{Xo="continue",Oe=".continue/rules",ze=".continue/prompts",Lm=".continue/mcpServers",Ua=`${Lm}/agentsmesh.json`,kr=`${Oe}/general.md`,bm=`${Oe}/_root.md`,Ve=".continue/skills",Zo=".continue/AGENTS.md",yi=".continue/config.yaml",Ka=".agentsmesh/rules",Wa=".agentsmesh/commands",xm=".agentsmesh/mcp.json";});async function Pm(t,e,r="project"){t.set(kr,`${D}/_root.md`),t.set(bm,`${D}/_root.md`);for(let n of await b(e,".continue/rules")){let o=L(e,n);o===kr||o===bm||$(t,o,D,".md");}for(let n of await b(e,".continue/prompts"))t.set(L(e,n),`${X}/${basename(n,".md")}.md`);for(let n of await b(e,".continue/skills"))z(t,L(e,n),".continue/skills");if(r==="global")for(let n of await b(e,".agents/skills"))z(t,L(e,n),".agents/skills");}var fh=f(()=>{vt();Je();$t();i(Pm,"buildContinueImportPaths");});function _b(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${D}/${basename(e,".instructions.md")}.md`);return}$(t,e,D,".md");}async function Tm(t,e){t.set(".github/copilot-instructions.md",`${D}/_root.md`);for(let r of await b(e,".github/copilot"))t.set(L(e,r),`${D}/${basename(r,".instructions.md")}.md`);for(let r of await b(e,".github/instructions"))_b(t,L(e,r));for(let r of await b(e,".github/prompts"))t.set(L(e,r),`${X}/${basename(r,".prompt.md")}.md`);for(let r of await b(e,".github/agents"))t.set(L(e,r),`${dt}/${basename(r,".agent.md")}.md`);for(let r of await b(e,".github/skills"))z(t,L(e,r),".github/skills");}var gh=f(()=>{vt();$t();i(_b,"addCopilotInstructionMapping");i(Tm,"buildCopilotImportPaths");});var hh,Qr,yh,ne,Or,oe,qo,Ye,Xe,Ze,Ha,we,Nm,Sb,Qo,Ee,Ii,tn,en,qe,rn,nn,Ih,ts,Dm,_i,Fm,mt=f(()=>{hh="cursor",Qr="AGENTS.md",yh=".cursorrules",ne=".cursor/rules",Or=`${ne}/general.mdc`,oe=".cursor/commands",qo=".cursor/agents",Ye=".cursor/skills",Xe=".cursor/mcp.json",Ze=".cursor/hooks.json",Ha=".cursor/settings.json",we=".cursorignore",Nm=".cursorindexingignore",Sb=".agentsmesh-exports/cursor",Qo=`${Sb}/user-rules.md`,Ee=".cursor/AGENTS.md",Ii=Xe,tn=Ye,en=qo,qe=".agentsmesh/rules",rn=".agentsmesh/commands",nn=".agentsmesh/agents",Ih=".agentsmesh/skills",ts=".agentsmesh/mcp.json",Dm=".agentsmesh/permissions.yaml",_i=".agentsmesh/hooks.yaml",Fm=".agentsmesh/ignore";});async function vm(t,e,r="project"){if(r==="global"){t.set(Xe,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${D}/_root.md`);for(let n of await b(e,".cursor/rules"))$(t,L(e,n),D,".mdc");for(let n of await b(e,".cursor/commands"))$(t,L(e,n),X,".md");for(let n of await b(e,".cursor/agents"))$(t,L(e,n),dt,".md");for(let n of await b(e,".cursor/skills"))z(t,L(e,n),".cursor/skills");return}t.set("AGENTS.md",`${D}/_root.md`);for(let n of await b(e,".cursor/rules"))$(t,L(e,n),D,".mdc");for(let n of await b(e,".cursor/commands"))$(t,L(e,n),X,".md");for(let n of await b(e,".cursor/agents"))$(t,L(e,n),dt,".md");for(let n of await b(e,".cursor/skills"))z(t,L(e,n),".cursor/skills");}var _h=f(()=>{vt();mt();$t();i(vm,"buildCursorImportPaths");});async function $m(t,e){for(let r of await b(e,".gemini/rules"))$(t,L(e,r),D,".md");for(let r of await b(e,".gemini/commands")){let n=L(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),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 b(e,".gemini/agents"))$(t,L(e,r),dt,".md");for(let r of await b(e,".gemini/skills"))z(t,L(e,r),".gemini/skills");}var Sh=f(()=>{vt();$t();i($m,"buildGeminiCliImportPaths");});var zn,on,za,Ch,Qe,Rh,Cb,Si,Vn,Ci,es,rs,Ri,ki,Oi,wi,Ei,Rb,Va,Jn,kh,Mm,Ja,Oh,wh,Eh,Ah,ns=f(()=>{zn="junie",on=".junie",za=`${on}/guidelines.md`,Ch=`${on}/ci-guidelines.md`,Qe=`${on}/AGENTS.md`,Rh="AGENTS.md",Cb=`${on}/mcp`,Si=`${Cb}/mcp.json`,Vn=`${on}/skills`,Ci=`${on}/rules`,es=`${on}/commands`,rs=`${on}/agents`,Ri=".aiignore",ki=".junie",Oi=`${ki}/skills`,wi=`${ki}/agents`,Ei=`${ki}/commands`,Rb=`${ki}/mcp`,Va=`${Rb}/mcp.json`,Jn=`${ki}/AGENTS.md`,kh=".agents/skills",Mm=".agentsmesh/rules/_root.md",Ja=".agentsmesh/rules",Oh=".agentsmesh/commands",wh=".agentsmesh/agents",Eh=".agentsmesh/mcp.json",Ah=".agentsmesh/ignore";});async function Gm(t,e){t.set(za,`${D}/_root.md`),t.set(Qe,`${D}/_root.md`),t.set("AGENTS.md",`${D}/_root.md`);for(let r of await b(e,".junie/rules"))$(t,L(e,r),D,".md");for(let r of await b(e,".junie/commands"))$(t,L(e,r),X,".md");for(let r of await b(e,".junie/agents"))$(t,L(e,r),dt,".md");for(let r of await b(e,".junie/skills"))z(t,L(e,r),".junie/skills");}var Lh=f(()=>{vt();ns();$t();i(Gm,"buildJunieImportPaths");});var Pt,Ai,tr,wr,Er,Ar,Ae,sn,os,Ya,Yn,ss,Xn,Li,Xa,is,an,Zn,qn,Qn,ln,as,Za,bh,cn,ls,to,xh,Ph,eo=f(()=>{Pt="kilo-code",Ai=".kilo",tr="AGENTS.md",wr=`${Ai}/rules`,Er=`${Ai}/commands`,Ar=`${Ai}/agents`,Ae=`${Ai}/skills`,sn=`${Ai}/mcp.json`,os=".kilocodeignore",Ya=".kilocode",Yn=`${Ya}/rules`,ss=`${Ya}/workflows`,Xn=`${Ya}/skills`,Li=`${Ya}/mcp.json`,Xa=".kilocodemodes",is=".kilo",an=`${is}/AGENTS.md`,Zn=`${is}/rules`,qn=`${is}/commands`,Qn=`${is}/agents`,ln=`${is}/skills`,as=`${is}/mcp.json`,Za=".kilocodeignore",bh=".agents/skills",cn=".agentsmesh/rules",ls=".agentsmesh/commands",to=".agentsmesh/agents",xh=".agentsmesh/mcp.json",Ph=".agentsmesh/ignore";});async function jm(t,e,r="project"){if(r==="global"){t.set(an,`${D}/_root.md`);for(let n of await b(e,Zn))$(t,L(e,n),D,".md");for(let n of await b(e,qn))$(t,L(e,n),X,".md");for(let n of await b(e,Qn))$(t,L(e,n),dt,".md");for(let n of await b(e,ln))z(t,L(e,n),ln);t.set(as,".agentsmesh/mcp.json");return}t.set(tr,`${D}/_root.md`);for(let n of await b(e,wr))$(t,L(e,n),D,".md");for(let n of await b(e,Er))$(t,L(e,n),X,".md");for(let n of await b(e,Ar))$(t,L(e,n),dt,".md");for(let n of await b(e,Ae))z(t,L(e,n),Ae);t.set(sn,".agentsmesh/mcp.json");for(let n of await b(e,Yn)){let o=L(e,n);if(basename(o)==="00-root.md"){t.set(o,`${D}/_root.md`);continue}$(t,o,D,".md");}for(let n of await b(e,ss))$(t,L(e,n),X,".md");for(let n of await b(e,Xn))z(t,L(e,n),Xn);t.set(Li,".agentsmesh/mcp.json");}var Th=f(()=>{vt();eo();$t();i(jm,"buildKiloCodeImportPaths");});var Ht,Le,bi,be,se,xe,mn,Nh,cs,ms,ro,Pe,pn,no,xi,Pi,Dh,Um,Km,Fh,vh,Wm,$h,ps=f(()=>{Ht="kiro",Le="AGENTS.md",bi=".kiro",be=`${bi}/steering`,se=`${bi}/skills`,xe=`${bi}/agents`,mn=`${bi}/hooks`,Nh=`${bi}/settings`,cs=`${Nh}/mcp.json`,ms=".kiroignore",ro=".kiro/steering",Pe=".kiro/steering/AGENTS.md",pn=".kiro/skills",no=".kiro/agents",xi=".kiro/settings/mcp.json",Pi=".kiro/settings/kiroignore",Dh=".agents/skills",Um=".agentsmesh/rules/_root.md",Km=".agentsmesh/rules",Fh=".agentsmesh/agents",vh=".agentsmesh/mcp.json",Wm=".agentsmesh/hooks.yaml",$h=".agentsmesh/ignore";});async function Bm(t,e,r="project"){if(r==="global"){t.set(Pe,`${D}/_root.md`);for(let n of await b(e,ro)){let o=L(e,n);o!==Pe&&$(t,o,D,".md");}for(let n of await b(e,pn))z(t,L(e,n),pn);for(let n of await b(e,no))$(t,L(e,n),dt,".md");return}t.set(Le,`${D}/_root.md`);for(let n of await b(e,be))$(t,L(e,n),D,".md");for(let n of await b(e,se))z(t,L(e,n),se);for(let n of await b(e,xe))$(t,L(e,n),dt,".md");}var Mh=f(()=>{vt();ps();$t();i(Bm,"buildKiroImportPaths");});var un,oo,Te,Ti,Lr,br,er,Ni,Di,us,Fi,qa,dn,fn,xr,so,vi,gn,Gh,io,Qa,jh,Uh,ao=f(()=>{un="roo-code",oo=".roo",Te=`${oo}/rules/00-root.md`,Ti=".roorules",Lr=`${oo}/rules`,br=`${oo}/commands`,er=`${oo}/skills`,Ni=`${oo}/mcp.json`,Di=".rooignore",us=".roomodes",Fi="settings/custom_modes.yaml",qa=".roo",dn=`${qa}/rules`,fn=`${qa}/commands`,xr=`${qa}/skills`,so="mcp_settings.json",vi=".rooignore",gn=`${qa}/AGENTS.md`,Gh=".agents/skills",io=".agentsmesh/rules",Qa=".agentsmesh/commands",jh=".agentsmesh/mcp.json",Uh=".agentsmesh/ignore";});async function Hm(t,e,r="project"){if(r==="global"){t.set(gn,`${D}/_root.md`);for(let n of await b(e,dn))$(t,L(e,n),D,".md");for(let n of await b(e,fn))$(t,L(e,n),X,".md");for(let n of await b(e,xr))z(t,L(e,n),xr);t.set(so,".agentsmesh/mcp.json");return}t.set(Te,`${D}/_root.md`),t.set(Ti,`${D}/_root.md`);for(let n of await b(e,Lr)){let o=L(e,n);o!==Te&&$(t,o,D,".md");}for(let n of await b(e,".roo")){let o=L(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&$(t,o,D,".md");}for(let n of await b(e,br))$(t,L(e,n),X,".md");for(let n of await b(e,er))z(t,L(e,n),er);}var Kh=f(()=>{vt();ao();$t();i(Hm,"buildRooCodeImportPaths");});async function zm(t,e){t.set("AGENTS.md",`${D}/_root.md`),t.set(".windsurfrules",`${D}/_root.md`),await $a(t,e);for(let r of await b(e,".windsurf/rules"))$(t,L(e,r),D,".md");for(let r of await b(e,".windsurf/workflows"))$(t,L(e,r),X,".md");for(let r of await b(e,".windsurf/skills"))z(t,L(e,r),".windsurf/skills");}var Wh=f(()=>{vt();$t();i(zm,"buildWindsurfImportPaths");});var Bh=f(()=>{sh();ch();uh();dh();fh();gh();_h();Sh();Lh();Th();Mh();Kh();Wh();});var Mt=f(()=>{Bh();});var Ob,wb,Eb,Ab,Da,dm=f(()=>{Fn();Pg();Gn();Ug();zg();qg();Mt();Ob={name:"antigravity",primaryRootInstructionPath:Se,generateRules:Eg,generateCommands:Ag,generateSkills:Lg,generateMcp:bg,importFrom:jg},wb={rootInstructionPath:Se,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===ri?null:t},paths:{rulePath(t,e){return `${je}/${t}.md`},commandPath(t,e){return `${hr}/${t}.md`},agentPath(t,e){return null}}},Eb={rootInstructionPath:Ue,renderPrimaryRootInstruction:xg,skillDir:yr,managedOutputs:{dirs:[yr,ni],files:[Ue,Uo]},rewriteGeneratedPath(t){return t===Se?Ue:t.startsWith(`${je}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",yr):t.startsWith(`${hr}/`)?t.replace(hr,ni):t===ri?Uo:t},paths:{rulePath(t,e){return Ue},commandPath(t,e){return `${ni}/${t}.md`},agentPath(t,e){return null}}},Ab={rules:"native",additionalRules:"embedded",commands:Ie("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Da={id:"antigravity",generators:Ob,capabilities:{rules:"native",additionalRules:"native",commands:Ie("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:Zg,project:wb,globalSupport:{capabilities:Ab,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:Eb},importer:{rules:{feature:"rules",mode:"directory",source:{project:[je]},canonicalDir:Mn,extensions:[".md"],map:Bg},commands:{feature:"commands",mode:"directory",source:{project:[hr],global:[ni]},canonicalDir:Na,extensions:[".md"],map:Hg},mcp:{feature:"mcp",mode:"flatFile",source:{global:[Uo]},canonicalDir:".agentsmesh",canonicalFilename:wg}},buildImportPaths:ym,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function Hh(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(!Me(s))continue;let a=ut(s),l=bt(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 zh=f(()=>{fe();i(Hh,"buildClaudeHooksObjectFromCanonical");});function Vh(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Yr,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:`${li}/${s}.md`,content:l});}return e}function Jh(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:`${ci}/${e.name}.md`,content:n}})}function Yh(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=T(r,o);return {path:`${
|
|
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=T(n,s);e.push({path:`${
|
|
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
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:`${
|
|
62
|
-
`)),e.push({fromTool:"cline",fromPath:o,toPath:
|
|
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===Zy){l=true;continue}if(m===qy){l=false;continue}l&&m.startsWith(op)&&a.push(m.slice(op.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 yI=f(()=>{Lt();i(hI,"tryParseEmbeddedCanonicalFromCodexRules");});async function _I(t,e,r){let n=[],o=join(t,nr);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 p=relative(o,c).replace(/\\/g,"/"),u=join(e,p),{frontmatter:d,body:g}=O(r(m,c,u));await k(e);let h=d.root===!0?d:{...d,root:!1},C=await M(u,h,g);await S(u,C),n.push({fromTool:Rt,fromPath:c,toPath:`${Dr}/${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 k(e);let d=hI(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:Rt,fromPath:c,toPath:`${Dr}/${p}`,feature:"rules"});}}catch{}return n}var SI=f(()=>{E();F();Y();Lt();yI();i(_I,"importCodexNonRootRuleFiles");});async function RI(t,e,r,n,o){let s=join(t,Vy),a=join(t,Nr),l=join(t,Jy),c=join(t,lo),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,Dr),C=m??p??u??d;if(C!==null){await k(h);let R=join(h,"_root.md"),_=g===a||g===c||g===l?eI(C):C,w=await We({content:_,projectRoot:t,rulesDir:Dr,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...w.results);let v=r(g===a||g===c||g===l?n(w.rootContent,g,R):w.rootContent,g,R),{frontmatter:A,body:x}=O(v),H=A.root===true?A:{...A,root:true},j=await M(R,H,x);await S(R,j),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${Dr}/_root.md`,feature:"rules"});}await gx(t,h,e,r),e.push(...await _I(t,h,r)),o!=="global"&&e.push(...await q({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:i(async({srcPath:R,normalizeTo:_})=>{let w=relative(t,dirname(R)).replace(/\\/g,"/"),v=basename(R),A=v==="AGENTS.override.md";if(!w||w==="."||!A&&v!=="AGENTS.md")return null;let x=w.replace(/\//g,"-");if(!ml(w))return await Fr(join(h,`${x}.md`)),null;let H=join(h,`${x}.md`),{frontmatter:j,body:K}=O(_(H));return {destPath:H,toPath:`${Dr}/${x}.md`,feature:"rules",content:await M(H,{...j,root:false,globs:[`${w}/**`],...A?{codex_instruction:"override"}:{}},K)}},"mapEntry")}));}async function gx(t,e,r,n){try{let s=(await P(join(t,co))).filter(l=>l.endsWith(".md")),a=join(t,co);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}=O(n(m,l,p));await k(e);let g=u.root===!0?u:{...u,root:!1},h=await M(p,g,d);await S(p,h),r.push({fromTool:Rt,fromPath:l,toPath:`${Dr}/${c}`,feature:"rules"});}}catch{}}var kI=f(()=>{E();F();Y();Ho();Re();ji();Lt();SI();al();i(RI,"importCodexRules");i(gx,"importInstructionMirrors");});async function pl(t,e){let r=e?.scope??"project",n=[],o=await V(Rt,t,r),s=await V("windsurf",t,r);return await RI(t,n,o,s,r),await uI(t,n,o),await fI(t,n,o),await mI(t,n),n}var hp=f(()=>{At();Lt();pI();dI();gI();kI();i(pl,"importFromCodex");});function OI(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:Rt,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var wI=f(()=>{Lt();i(OI,"lintRules");});function EI(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(J(".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(J(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var AI=f(()=>{Gt();i(EI,"lintMcp");});function LI(t){return Gi(t)}var bI=f(()=>{al();i(LI,"codexAdvisoryInstructionPath");});var yx,Ix,_x,Sx,PI,TI=f(()=>{cI();Lt();hp();wI();AI();Mt();$o();bI();si();yx={name:"codex-cli",primaryRootInstructionPath:Nr,generateRules:lp,generateCommands:pp,generateAgents:up,generateSkills:mp,generateMcp:dp,importFrom:pl},Ix={rootInstructionPath:Nr,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${nr}/${e}.rules`]},skillDir:".agents/skills",managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/instructions"],files:["AGENTS.md",".codex/config.toml"]},paths:{rulePath(t,e){return LI(e)},commandPath(t,e){return Zs(e,"codex-cli")?`${Ne}/${Vo(t)}/SKILL.md`:null},agentPath(t,e){return `${mo}/${t}.toml`}}},_x={rootInstructionPath:lo,renderPrimaryRootInstruction:cp,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${nr}/${e}.rules`]},skillDir:Ne,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[lo,".codex/config.toml"]},rewriteGeneratedPath(t){return t===Nr?lo:t.startsWith(`${co}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${nr}/${t}.rules`:lo},commandPath(t,e){return Zs(e,"codex-cli")?`${Ne}/${Vo(t)}/SKILL.md`:null},agentPath(t,e){return `${mo}/${t}.toml`}}},Sx={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},PI={id:"codex-cli",generators:yx,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:OI,lint:{mcp:EI},project:Ix,globalSupport:{capabilities:Sx,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:_x},buildImportPaths:Am,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function Rx(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 NI(t){return `${ze}/${t}.md`}function DI(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 FI(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:Rx(t["x-agentsmesh-allowed-tools"])}}function vI(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 ul=f(()=>{F();Je();i(Rx,"toStringArray");i(NI,"continueCommandRulePath");i(DI,"serializeCommandRule");i(FI,"parseCommandRuleFrontmatter");i(vI,"serializeImportedCommand");});function $I(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:kr,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:`${Oe}/${o}.md`,content:T(s,n.body.trim()||"")});}return e}function MI(t){return t.commands.map(e=>({path:`${ze}/${e.name}.md`,content:DI(e)}))}function GI(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ua,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function jI(t){return qt(t,Ve)}var UI=f(()=>{Bt();F();ul();Je();i($I,"generateRules");i(MI,"generateCommands");i(GI,"generateMcp");i(jI,"generateSkills");});function Ex(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:Wo(l.args),env:Bo(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function Ax(t,e){let r=(await P(join(t,Lm))).filter(s=>[".json",".yaml",".yml"].includes(extname(s))),n={},o=[];for(let s of r){let a=await I(s);a&&(Object.assign(n,Ex(a,extname(s))),o.push(s));}if(Object.keys(n).length!==0){await Ke(t,xm,n);for(let s of o)e.push({fromTool:Xo,fromPath:s,toPath:xm,feature:"mcp"});}}async function dl(t){let e=[],r=await V(Xo,t);return e.push(...await ct(fl,t,"project",{normalize:r})),await Wt(t,Ve,Xo,e,r),await Ax(t,e),e}var yp=f(()=>{At();E();Bt();ke();Ko();Ce();Je();Ip();i(Ex,"readMcpServers");i(Ax,"importMcp");i(dl,"importFromContinue");});function Lx(t){return t==="general.md"||t==="_root.md"}var WI,BI,HI=f(()=>{F();Y();ul();Je();i(Lx,"isContinueRootRulePath");WI=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=Lx(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:`${Ka}/${o}`,content:await M(s,c,l)}},"continueRuleMapper"),BI=i(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:s,body:a}=O(r(o)),l=FI(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 Z(u,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},O(vI(l,a)).body);return {destPath:u,toPath:`${Wa}/${p}`,content:d}},"continueCommandMapper");});function zI(t,e,r,n){return ot(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Xo}))}var VI=f(()=>{te();Je();i(zI,"lintRules");});function JI(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>J(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var YI=f(()=>{Gt();i(JI,"lintCommands");});function Tx(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var XI,ZI=f(()=>{E();Je();i(Tx,"computeStatus");XI=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,yi));return [{target:"continue",path:yi,content:m,currentContent:p??void 0,status:Tx(p,m)}]},"generateContinueGlobalConfig");});function Dx(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var qI,QI=f(()=>{E();Je();ZI();i(Dx,"computeStatus");qI=i(async(t,e,r,n)=>{let o=await XI(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,Zo));return [...o,{target:"continue",path:Zo,content:a,currentContent:l??void 0,status:Dx(l,a)}]},"generateContinueScopeExtras");});var Fx,vx,$x,Mx,fl,Ip=f(()=>{UI();Je();yp();HI();VI();YI();ul();Mt();QI();Fx={name:"continue",primaryRootInstructionPath:kr,generateRules:$I,generateCommands:MI,generateSkills:jI,generateMcp:GI,importFrom:dl},vx={rootInstructionPath:kr,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Oe}/${t}.md`},commandPath(t,e){return NI(t)},agentPath(t,e){return null}}},$x={rootInstructionPath:kr,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Zo]}],skillDir:Ve,managedOutputs:{dirs:[Oe,ze,Ve,".agents/skills"],files:[Ua,Zo,yi]},mirrorGlobalPath(t,e){return t.startsWith(`${Ve}/`)?`.agents/skills/${t.slice(Ve.length+1)}`:null},paths:{rulePath(t,e){return `${Oe}/${t}.md`},commandPath(t,e){return `${ze}/${t}.md`},agentPath(t,e){return null}}},Mx={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},fl={id:"continue",generators:Fx,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:zI,lint:{commands:JI},project:vx,globalSupport:{capabilities:Mx,detectionPaths:[Oe,ze,".continue/mcpServers",Ve],layout:$x,scopeExtras:qI},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Oe],global:[Oe]},canonicalDir:Ka,extensions:[".md"],map:WI},commands:{feature:"commands",mode:"directory",source:{project:[ze],global:[ze]},canonicalDir:Wa,extensions:[".md"],map:BI}},buildImportPaths:Pm,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var vr,po,t_,uo,yn,sr,ir,fo,go,gl,hl,e_,Sp,r_,In,hs,$r,ys,ho,Cp,Rp,ie=f(()=>{vr="copilot",po=".github/copilot-instructions.md",t_=".github/copilot",uo=".github/instructions",yn=".github/prompts",sr=".github/hooks",ir=".github/skills",fo=".github/agents",go=".agentsmesh/rules",gl=".agentsmesh/commands",hl=".agentsmesh/agents",e_=".agentsmesh/skills",Sp=".agentsmesh/hooks.yaml",r_=".github/copilot-hooks",In=".copilot/copilot-instructions.md",hs=".copilot/agents",$r=".copilot/skills",ys=".copilot/prompts",ho=".copilot/AGENTS.md",Cp=".claude/skills",Rp=".agents/skills";});function n_(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 yl(t){return `${yn}/${t}.prompt.md`}function o_(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 s_(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=n_(t["x-agentsmesh-allowed-tools"]),s=o.length>0?o:n_(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:s}}var Il=f(()=>{F();ie();i(n_,"toStringArray");i(yl,"commandPromptPath");i(o_,"serializeCommandPrompt");i(s_,"parseCommandPromptFrontmatter");});function _l(t){return fr(t)}var kp=f(()=>{fe();i(_l,"hasHookCommand");});function Ux(t){let e=basename(t,".md");return e==="_root"?"root":e}function Kx(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function i_(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:_n,fromPath:join(t,Pl),toPath:Wp,feature:"permissions"}),e}var MS=f(()=>{E();ft();i(xP,"unescapeRegexLiteral");i(PP,"toolNameToPermissionBase");i(TP,"commandPrefixToBashExpr");i(NP,"argsPatternToReadExpr");i($S,"importGeminiPolicies");});function ru(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 jS=f(()=>{i(ru,"stripProjectRootCanonicalPrefix");});async function KS(t,e,r){let n=join(t,Wi),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)),p=O(c),u=Jr(p.frontmatter,m);if(u){let w=join(t,Bi);await k(w);let v=join(w,`${u.name}.md`);await S(v,Be(u,r(p.body,l,v))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Bi}/${u.name}.md`,feature:"agents"});continue}let d=join(t,Hi,m,"SKILL.md"),g=r(c,l,d),h=join(t,Hi,m);await k(h);let{frontmatter:C,body:R}=O(g);await S(d,await Ge(d,{...C,name:m},R)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Hi}/${m}/SKILL.md`,feature:"skills"});let _=await P(dirname(l));for(let w of _){if(w===l)continue;let v=await I(w);if(v===null)continue;let A=relative(dirname(l),w).replace(/\\/g,"/"),x=join(h,A);await k(dirname(x)),await S(x,r(v,w,x)),e.push({fromTool:"gemini-cli",fromPath:w,toPath:`${Hi}/${m}/${A}`,feature:"skills"});}}let a=join(t,Sn);try{let c=(await P(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await I(m);if(!p)continue;let{frontmatter:u,body:d}=O(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),C=join(t,Bi);await k(C);let R=join(C,h),_=r(d,m,R);await S(R,await _t(R,{...u,name:typeof u.name=="string"?u.name:basename(h,".md"),maxTurns:u.maxTurns??u["max-turns"]??u.max_turns,permissionMode:u.permissionMode??u["permission-mode"]??u.permission_mode,disallowedTools:u.disallowedTools??u["disallowed-tools"]??u.disallowed_tools},_)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${Bi}/${h}`,feature:"agents"});}}catch{}}var WS=f(()=>{E();F();Y();ee();ft();i(KS,"importGeminiSkillsAndAgents");});async function DP(t,e,r){let n=await V("codex-cli",t),o=join(t,Cn),s=join(t,ar),a=join(t,SS),l=[s,a,join(t,ae),join(t,CS)],c=null,m=l[l.length-1];for(let A of l){let x=await I(A);if(x!==null){c=x,m=A;break}}if(c===null)return;await k(o);let p=join(o,"_root.md"),u=m===s||m===a?n(c,m,p):c,d=await We({content:u,projectRoot:t,rulesDir:Cn,sourcePath:m,fromTool:_n,normalize:r});e.push(...d.results);let g=r(d.rootContent,m,p),h=ru(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:C,body:R}=O(h),w=C.root===true?C:{...C,root:true},v=ru(await M(p,w,R),t);await S(p,v),e.push({fromTool:_n,fromPath:m,toPath:`${Cn}/_root.md`,feature:"rules"});}async function Ml(t){let e=[],r=await V(_n,t);return await DP(t,e,r),e.push(...await ct(Gl,t,"project",{normalize:r})),await KS(t,e,r),await Qp(t,e),await vS(t,e),e.push(...await $S(t)),e}var su=f(()=>{At();E();F();Y();Ho();ke();ft();iu();eu();MS();jS();WS();i(DP,"importRootRule");i(Ml,"importFromGemini");});async function HS(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:s,body:a}=vl(r(o)),l=Ir(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:`${Cn}/${n}`,feature:"rules",content:await M(o,c,a)}}async function zS(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")?vP(s):vl(s),c=Qt(a.allowedTools),m=Qt(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${Nl}/${n}`,feature:"commands",content:await Z(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 vP(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var VS=f(()=>{Y();Ce();eu();ft();i(HS,"mapGeminiRuleFile");i(zS,"mapGeminiCommandFile");i(vP,"parseTomlCommand");});var JS,YS,XS=f(()=>{VS();JS=i(({relativePath:t,destDir:e,normalizeTo:r})=>HS(t,e,r),"geminiRuleMapper"),YS=i(({relativePath:t,destDir:e,normalizeTo:r})=>zS(t,e,r),"geminiCommandMapper");});function ZS(t,e,r,n){return ot(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(s=>({...s,target:_n}))}var qS=f(()=>{te();ft();i(ZS,"lintRules");});function QS(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>J(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function tC(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification"],r=new Set(e);return Object.keys(t.hooks).filter(n=>!r.has(n)).map(n=>fs(n,"gemini-cli",e))}var eC=f(()=>{Gt();i(QS,"lintCommands");i(tC,"lintHooks");});function rC(t,e){return e==="project"&&Rn("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:Jp(t)}var nC=f(()=>{nt();Yp();i(rC,"emitScopedGeminiSettings");});function sC(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function iC(t,e){let r=sC(t),n=$P.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 aC(t,e){let r=sC(t),n=MP.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 oC,$P,MP,au=f(()=>{oC=[".claude/settings.json",".gemini/settings.json"],$P=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(),MP=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(sC,"parseJsonObject");i(iC,"mergeSettingsJson");i(aC,"mergeGeminiSettingsJson");});var GP,jP,UP,KP,Gl,iu=f(()=>{PS();Fn();DS();ft();su();XS();qS();Mt();$o();ee();eC();nC();Pr();au();GP={name:"gemini-cli",primaryRootInstructionPath:ae,generateRules:Bp,generateCommands:Hp,generateAgents:zp,generateSkills:Vp,generateIgnore:Xp,generatePermissions:NS,importFrom:Ml},jP={rootInstructionPath:ae,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[ar]}],extraRuleOutputPaths(){return [ar]},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 Ct(t,".gemini/skills",e)},paths:{rulePath(t,e){return ae},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${zt}/${r.join("/")}/${n}.toml`}return `${zt}/${t}.toml`},agentPath(t,e){return he(e,"gemini-cli")?`.gemini/skills/${Ft(t)}/SKILL.md`:`${Sn}/${t}.md`}}},UP={rootInstructionPath:Cs,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Rs]}],extraRuleOutputPaths(){return [Rs]},skillDir:Io,managedOutputs:{dirs:[ks,Io,zi],files:[Cs,Rs,Dl]},rewriteGeneratedPath(t){return t===ae?Cs:t===ar?Rs:t===yo?Dl:t.startsWith(`${zt}/`)?t.replace(`${zt}/`,`${ks}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${Io}/`):t.startsWith(`${Sn}/`)?t.replace(`${Sn}/`,`${zi}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return Ct(t,Io,e)},paths:{rulePath(t,e){return Cs},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${ks}/${r.join("/")}/${n}.toml`}return `${ks}/${t}.toml`},agentPath(t,e){return he(e,"gemini-cli")?`${Io}/${Ft(t)}/SKILL.md`:`${zi}/${t}.md`}}},KP={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},Gl={id:"gemini-cli",generators:GP,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:Ie("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:ZS,lint:{commands:QS,hooks:tC},emitScopedSettings:rC,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===yo?aC(o,r):null},project:jP,globalSupport:{capabilities:KP,detectionPaths:[Cs,Rs,Dl,ks,Io,zi],layout:UP},importer:{rules:{feature:"rules",mode:"directory",source:{project:[_S]},canonicalDir:Cn,extensions:[".md"],map:JS},commands:{feature:"commands",mode:"directory",source:{project:[zt]},canonicalDir:Nl,extensions:[".md",".toml"],map:YS}},buildImportPaths:$m,detectionPaths:["GEMINI.md",".gemini"]};});function lC(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Qe,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:`${Ci}/${o}.md`,content:n.body.trim()||""});}return e}function BP(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),ll(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 cC(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,BP(n)]));return [{path:Si,content:JSON.stringify({mcpServers:e},null,2)}]}function mC(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${es}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function pC(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:`${rs}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function uC(t){return t.ignore.length===0?[]:[{path:Ri,content:t.ignore.join(`
|
|
111
|
-
`)}]}
|
|
112
|
-
`)}]}function
|
|
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}
|
|
113
114
|
|
|
114
115
|
## When to use
|
|
115
116
|
|
|
116
|
-
${d}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let C=await
|
|
117
|
-
`)}]}var JC=f(()=>{Bt();F();hu();ps();i(mT,"steeringFrontmatter");i(KC,"generateRules");i(WC,"generateSkills");i(BC,"generateMcp");i(HC,"generateHooks");i(zC,"generateAgents");i(VC,"generateIgnore");});function uT(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:Ir(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function dT(t,e,r,n){let o=n==="global"?[Pe,Le]:[Le,Pe];for(let s of o){let a=join(t,s),l=await I(a);if(l===null)continue;let c=join(t,Um),{frontmatter:m,body:p}=O(r(l,a,c));await S(c,await M(c,{...m,root:true},p)),e.push({fromTool:Ht,fromPath:a,toPath:Um,feature:"rules"});return}}async function fT(t,e,r){let n=join(t,Km);e.push(...await q({srcDir:join(t,be),destDir:n,extensions:[".md"],fromTool:Ht,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}=O(s(a));return {destPath:a,toPath:`${Km}/${o}`,feature:"rules",content:await M(a,uT(l),c)}},"mapEntry")}));}async function gT(t,e){let r={};for(let o of await P(join(t,mn))){if(!o.endsWith(".kiro.hook"))continue;let s=jC(await I(o)??"");s&&(r[s.event]??=[],r[s.event].push(s.entry));}if(Object.keys(r).length===0)return;let n=join(t,Wm);await k(join(t,".agentsmesh")),await S(n,UC(r)),e.push({fromTool:Ht,fromPath:join(t,mn),toPath:Wm,feature:"hooks"});}async function zl(t,e={}){let r=e.scope??"project",n=[],o=await V(Ht,t,r);return await dT(t,n,o,r),await fT(t,n,o),n.push(...await ct(Vl,t,r,{normalize:o})),await Wt(t,se,Ht,n,o),r==="project"&&await gT(t,n),n}var yu=f(()=>{At();Bt();Re();ke();Y();Ce();E();F();hu();ps();Iu();i(uT,"canonicalRuleMeta");i(dT,"importRoot");i(fT,"importNonRootRules");i(gT,"importHooks");i(zl,"importFromKiro");});function YC(t,e,r,n){return ot(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Ht}))}var XC=f(()=>{te();ps();i(YC,"lintRules");});function ZC(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","UserPromptSubmit","SubagentStop"],r=new Set(e);return Object.keys(t.hooks).filter(n=>!r.has(n)).map(n=>fs(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var qC=f(()=>{Gt();i(ZC,"lintHooks");});var hT,yT,IT,_T,Vl,Iu=f(()=>{JC();Pr();yu();XC();qC();Mt();ps();hT={name:Ht,primaryRootInstructionPath:Le,generateRules:KC,generateAgents:zC,generateSkills:WC,generateMcp:BC,generateHooks:HC,generateIgnore:VC,importFrom:zl},yT={rootInstructionPath:Le,skillDir:se,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${be}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return `${xe}/${t}.md`}}},IT={rootInstructionPath:Pe,skillDir:pn,managedOutputs:{dirs:[ro,pn,no,Dh],files:[Pe,xi,Pi]},rewriteGeneratedPath(t){return t===Le?Pe:t.startsWith(`${be}/`)?t.replace(`${be}/`,`${ro}/`):t.startsWith(`${se}/`)?t.replace(`${se}/`,`${pn}/`):t.startsWith(`${xe}/`)?t.replace(`${xe}/`,`${no}/`):t===cs?xi:t===ms?Pi:t.startsWith(`${mn}/`)?null:t},mirrorGlobalPath(t,e){return Ct(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${ro}/${t}.md`},commandPath(t,e){return null},agentPath(t,e){return `${no}/${t}.md`}}},_T={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Vl={id:Ht,generators:hT,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).",lintRules:YC,lint:{hooks:ZC},project:yT,globalSupport:{capabilities:_T,detectionPaths:[ro,Pe,pn,no,xi,Pi],layout:IT},importer:{agents:{feature:"agents",mode:"directory",source:{project:[xe],global:[xe]},canonicalDir:Fh,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[cs],global:[xi]},canonicalDir:".agentsmesh",canonicalFilename:vh},ignore:{feature:"ignore",mode:"flatFile",source:{project:[ms],global:[Pi]},canonicalDir:".agentsmesh",canonicalFilename:$h}},buildImportPaths:Bm,detectionPaths:[be,se,xe,mn,cs,ms]};});function tR(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Te,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(un))continue;let o=basename(n.source,".md");e.push({path:`${Lr}/${o}.md`,content:n.body.trim()||""});}return e}function eR(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${br}/${e.name}.md`,content:T(r,e.body.trim()||"")}})}function rR(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Ni,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function nR(t){return t.ignore.length===0?[]:[{path:Di,content:t.ignore.join(`
|
|
118
|
-
`)}]}function
|
|
119
|
-
`)}]}var
|
|
120
|
-
`)),n.push({fromTool:"windsurf",fromPath:p,toPath:Eu,feature:"ignore"});}}return await ER(t,n,o),await LR(t,n,o),await PR(t,n),await TR(t,n),n}var $u=f(()=>{At();E();F();Y();Re();ji();Tt();AR();bR();NR();i(tc,"importFromWindsurf");});function DR(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:lr,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:lr,message:`Windsurf cannot project these features yet: ${s.join(", ")}.`}),n}var FR=f(()=>{Tt();i(DR,"lintRules");});function vR(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>J(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function $R(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[J(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var MR=f(()=>{Gt();i(vR,"lintCommands");i($R,"lintMcp");});function HT(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 zT,VT,JT,YT,GR,jR=f(()=>{OR();Fn();Tt();Pr();$u();FR();MR();Mt();$o();ee();i(HT,"directoryScopedRuleDir");zT={name:"windsurf",primaryRootInstructionPath:cr,generateRules:bu,generateCommands:Pu,generateAgents:Tu,generateSkills:Fu,generateMcp:Nu,generateHooks:Du,generateIgnore:xu,importFrom:tc},VT={rootInstructionPath:cr,extraRuleOutputPaths(t){if(t.root)return [cr];let e=HT(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:Fe,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 `${On}/${t}.md`},commandPath(t,e){return `${wn}/${t}.md`},agentPath(t,e){return he(e,"windsurf")?`.windsurf/skills/${Ft(t)}/SKILL.md`:null}}},JT={rootInstructionPath:bs,skillDir:xs,managedOutputs:{dirs:[xs,Vi,gR],files:[bs,Xl,Zl,ql]},rewriteGeneratedPath(t){return t===cr?bs:t.startsWith(`${On}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${Fe}/`)?t.replace(`${Fe}/`,`${xs}/`):t.startsWith(`${wn}/`)?t.replace(`${wn}/`,`${Vi}/`):t===Es?Xl:t===As?Zl:t===ws?ql:t},mirrorGlobalPath(t,e){return Ct(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return bs},commandPath(t,e){return `${Vi}/${t}.md`},agentPath(t,e){return he(e,"windsurf")?`${xs}/${Ft(t)}/SKILL.md`:null}}},YT={rules:"native",additionalRules:"partial",commands:Ie("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},GR={id:"windsurf",generators:zT,capabilities:{rules:"native",additionalRules:"native",commands:Ie("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:DR,lint:{commands:vR,mcp:$R},project:VT,globalSupport:{capabilities:YT,detectionPaths:[bs,xs,Vi,Xl,Zl,ql],layout:JT},buildImportPaths:zm,detectionPaths:[".windsurfrules",".windsurf"]};});var oh={};wE(oh,{BUILTIN_TARGETS:()=>Et,TARGET_IDS:()=>yt,getBuiltinTargetDefinition:()=>le,getEffectiveTargetSupportLevel:()=>ec,getTargetCapabilities:()=>Rn,getTargetDetectionPaths:()=>Gu,getTargetLayout:()=>gt,getTargetManagedOutputs:()=>ju,getTargetPrimaryRootInstructionPath:()=>ZT,getTargetSkillDir:()=>Yi,isBuiltinTargetId:()=>Hr,resolveTargetFeatureGenerator:()=>Ps,rewriteGeneratedOutputPath:()=>Uu});function XT(){return Mu||(ug(Et),Mu=new Map(Et.map(t=>[t.id,t]))),Mu}function le(t){return XT().get(t)}function Rn(t,e="project"){let r=le(t)??Q(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return mg(n)}function Gu(t,e="project"){let r=le(t)??Q(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function gt(t,e="project"){let r=le(t)??Q(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function ZT(t,e="project"){return gt(t,e)?.rootInstructionPath}function Yi(t,e="project"){return gt(t,e)?.skillDir}function ju(t,e="project"){return gt(t,e)?.managedOutputs}function Uu(t,e,r="project"){let n=gt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function UR(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!Zs(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!he(r,t.id,true,n):false}function ec(t,e,r,n="project"){let o=Rn(t,n)?.[e]?.level??"none";if(o!=="embedded")return o;let s=le(t)??Q(t);return UR(s,e,r,n)?"none":o}function Ps(t,e,r,n="project"){let o=le(t)??Q(t);if(!o?.generators||UR(o,e,r,n))return;let s=qT[e];return s===null?void 0:s(o.generators)}var Et,Mu,qT,nt=f(()=>{$o();Fn();mr();Qc();dr();dm();Jm();zy();TI();Ip();wp();jp();iu();cu();gu();Iu();Cu();jR();Et=[Da,tl,Hy,PI,fl,Cl,xl,Gl,Ul,Hl,Vl,Yl,GR];i(XT,"builtinTargetsMap");i(le,"getBuiltinTargetDefinition");i(Rn,"getTargetCapabilities");i(Gu,"getTargetDetectionPaths");i(gt,"getTargetLayout");i(ZT,"getTargetPrimaryRootInstructionPath");i(Yi,"getTargetSkillDir");i(ju,"getTargetManagedOutputs");i(Uu,"rewriteGeneratedOutputPath");i(UR,"isFeatureSuppressedByConversion");i(ec,"getEffectiveTargetSupportLevel");qT={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(Ps,"resolveTargetFeatureGenerator");});function sN(t){return typeof t=="string"?t:t.level}function KR(t){return oN.includes(t)}function WR(t,e,r,n){for(let o of nN){let s=sN(e[o.feature]);if(s==="none")continue;let a=typeof t.generators[o.generator]=="function",l=KR(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}`+(KR(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function rc(t){return aN.parse(t)}var Ur,BR,QT,tN,HR,eN,rN,nN,oN,iN,aN,Ku=f(()=>{Ur=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()})]),BR=z$1.object({rules:Ur,additionalRules:Ur,commands:Ur,agents:Ur,skills:Ur,mcp:Ur,hooks:Ur,ignore:Ur,permissions:Ur}),QT=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(),tN=z$1.object({rulePath:z$1.function(),commandPath:z$1.function(),agentPath:z$1.function()}),HR=z$1.object({paths:tN}).passthrough(),eN=z$1.object({capabilities:BR,detectionPaths:z$1.array(z$1.string()),layout:HR,scopeExtras:z$1.function().optional()}).passthrough(),rN=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],nN=[{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"}],oN=["mcp","hooks","ignore","permissions"];i(sN,"capabilityLevel");i(KR,"canUseScopedSettings");i(WR,"validateCapabilityImplementations");iN=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:QT,capabilities:BR,emptyImportMessage:z$1.string(),lintRules:z$1.union([z$1.function(),z$1.null()]),project:HR,globalSupport:eN.optional(),buildImportPaths:z$1.function(),detectionPaths:z$1.array(z$1.string())}).passthrough(),aN=iN.superRefine((t,e)=>{for(let r of rN)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});WR(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&WR(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});i(rc,"validateDescriptor");});function lN(){return Wu||(Wu=new Map(Et.map(t=>[t.id,t]))),Wu}function VR(t){let e=rc(t);zR.set(e.id,e);}function Q(t){return zR.get(t)??lN().get(t)}var zR,Wu,mr=f(()=>{nt();Ku();zR=new Map;i(lN,"builtinDescriptors");i(VR,"registerTargetDescriptor");i(Q,"getDescriptor");});async function JR(t,e,r="project"){let n=new Map,o=Q(t);return o&&await o.buildImportPaths(n,e,r),n}var YR=f(()=>{mr();i(JR,"buildImportReferenceMap");});function pN(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 uN(){let t=new Set([".agentsmesh/"]);for(let e of Et)for(let r of pN(e))t.add(r);return Array.from(t)}function dN(){let t=new Set([...uN(),...Bu.rootRelativePrefixes]),e=new Set([...mN,...Bu.meshRootSegments]);return {protectedSchemes:[...cN,...Bu.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function nc(){return Hu||(Hu=dN()),Hu}var cN,mN,Bu,Hu,XR=f(()=>{nt();cN=[/\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],mN=new Set(["skills","rules","commands","agents","packs"]),Bu={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};i(pN,"topLevelDotfilePrefixes");i(uN,"buildDefaultRootRelativePrefixes");i(dN,"rebuild");i(nc,"getLinkFormatRegistry");});function ve(t){let e=et(t);return nc().rootRelativePrefixes.some(r=>e.startsWith(r))}function gN(t){let e=et(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||ge.test(e)||/^[a-zA-Z]:/.test(e)||ve(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&nc().meshRootSegments.has(r)}function Xi(t,e,r){let n=W(e),o=G(e,e),s=G(e,r),a=et(t);if(ge.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=ig(a,o);return c&&c!==l?[l,c]:[l]}if(ve(a))return [G(e,n.join(o,a))];if(a.includes("/")){let l=G(e,n.join(o,".agentsmesh")),c=gN(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 hN.has(a)?[]:a.includes(".")?[G(e,n.join(n.dirname(s),a))]:[]}function Zi(t,e){let r=[e];if(!sg(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 tk(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function oc(t){let e=[];for(let r of nc().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(yN))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(IN))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(_N))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var hN,yN,IN,_N,QR,Ts,En=f(()=>{wt();XR();i(ve,"isRootRelativePathToken");i(gN,"isMeshRootRelativePathToken");hN=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),yN=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,IN=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,_N=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,QR=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,Ts=/(?::(\d+)){1,2}$/;i(Xi,"resolveProjectPath");i(Zi,"expandResolvedPaths");i(tk,"isGlobAdjacent");i(oc,"protectedRanges");});function SN(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 ek(t){return SN(t.tokenContext)}function zu(t,e){let r=W(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 rk(t){let e=W(t);return G(t,e.join(t,".agentsmesh"))}function $e(t,e){let r=W(t),n=rk(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 nk(t,e,r){let n=W(t),o=rk(t),s=G(t,e);if(!$e(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 Vu(t,e,r){let o=W(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 Ns(t,e,r){let n=Vu(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function Ju(t,e,r,n,o){let s=W(t),a=G(t,t),l=G(t,e),c=G(t,r);if(!zu(t,c))return Ns(t,c,n)?.text??null;let m=G(t,s.dirname(l));if(!zu(t,m)&&m!==a)return Ns(t,c,n)?.text??null;let p=s.relative(m,c).replace(/\\/g,"/");if(s.isAbsolute(p)||ge.test(p))return Vu(t,c,n);let u=G(t,s.join(m,p));return zu(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):Vu(t,c,n)}var Yu=f(()=>{wt();i(SN,"isReadingContext");i(ek,"isReadingContextOptions");i(zu,"isUnderProjectRoot");i(rk,"agentsMeshRoot");i($e,"isUnderAgentsMesh");i(nk,"toAgentsMeshRootRelative");i(Vu,"toProjectRootRelative");i(Ns,"toProjectRootReference");i(Ju,"formatLinkPathForDestinationLegacy");});function ok(t,e,r,n,o={}){let s=o.scope??"project",a=G(t,r);if(ek(o)&&$e(t,e)&&$e(t,a)){let m=W(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 Ju(t,e,r,n,o);if(s==="global"&&!$e(t,e))return Ns(t,a,n)?.text??null;let l=(()=>{if($e(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&$e(t,G(t,m))?G(t,m):null})();if(!l)return Ns(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=nk(t,l,n);return m!==null?m:Ns(t,l,n)?.text??null}return Ju(t,e,r,n,o)}var sk=f(()=>{En();wt();Yu();Yu();i(ok,"formatLinkPathForDestination");});function ik(t,e,r,n){let o=W(e),s=et(t);if(!ve(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 ak=f(()=>{wt();En();i(ik,"resolveByDestinationSuffixStrip");});function lk(t){let e=null,r=false,n=null,o=null,s=null;for(let c of Xi(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of Zi(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=ik(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=et(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&et(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var ck=f(()=>{wt();En();ak();i(lk,"resolveLinkTarget");});function mk(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function pk(t,e,r){if(e<=0||t[e-1]!=="(")return false;let n=e+r.length,o=t[n];return o!==")"&&o!=="#"&&o!=="?"&&o!==" "&&o!==" "?false:t[e-2]==="]"}function uk(t){let e=et(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||ge.test(e)||ve(e)?false:e.includes("/")}var dk=f(()=>{wt();En();i(mk,"isTildeHomeRelativePathToken");i(pk,"isMarkdownLinkDestinationToken");i(uk,"isRelativePathToken");});function CN(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===`
|
|
121
|
-
`)break;s+=a,o++;}return s===r}function
|
|
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(`
|
|
122
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===`
|
|
123
|
-
`||s==="\r"||s===">"||s===" "||s===" "||s==='"'||s==="'"||s===":"||s==="#"||s==="?"}function
|
|
124
|
-
`);},warn(t){process.stderr.write(
|
|
125
|
-
`);},error(t){process.stderr.write(
|
|
126
|
-
`);},success(t){process.stdout.write(
|
|
127
|
-
`);},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+`
|
|
128
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+`
|
|
129
|
-
`);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+`
|
|
130
131
|
`);}process.stdout.write(n+`
|
|
131
|
-
`);}};var
|
|
132
|
-
`)}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}
|
|
133
134
|
Usage: ${e.usage}
|
|
134
|
-
${
|
|
135
|
+
${Zf(e.flags)}`).join(`
|
|
135
136
|
|
|
136
137
|
`);y.info(`agentsmesh <command> [flags]
|
|
137
138
|
|
|
138
139
|
Global flags:
|
|
139
|
-
${
|
|
140
|
+
${Zf(Yf)}
|
|
140
141
|
|
|
141
142
|
Commands:
|
|
142
143
|
${t}
|
|
143
144
|
|
|
144
|
-
Tip: run "agentsmesh <command> --help" for this same command reference.`);}i(
|
|
145
|
-
`);}i(
|
|
146
|
-
`):y.error(t.message),process.exit(1);}i(yf,"handleError");E();Hs();dr();var kf=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],Zt=z$1.enum(yt),xo=z$1.enum(kf),Js=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(),ZE=z$1.object({name:z$1.string(),source:z$1.string(),version:z$1.string().optional(),target:Zt.optional(),features:z$1.array(xo),path:z$1.string().optional(),pick:Js.optional()}),qE=z$1.object({strategy:z$1.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z$1.array(z$1.string()).default([])}),Vs=z$1.union([z$1.boolean(),z$1.object({project:z$1.boolean().optional(),global:z$1.boolean().optional()}).strict()]),QE=z$1.object({commands_to_skills:z$1.object({"codex-cli":Vs.optional()}).passthrough().optional(),agents_to_skills:z$1.object({"gemini-cli":Vs.optional(),cline:Vs.optional(),"codex-cli":Vs.optional(),windsurf:Vs.optional()}).passthrough().optional()}).strict().optional(),tA=z$1.object({id:z$1.string().regex(/^[a-z][a-z0-9-]*$/),source:z$1.string(),version:z$1.string().optional()}).strict(),Mc=z$1.object({version:z$1.literal(1),targets:z$1.array(Zt).default([...yt]),features:z$1.array(xo).default([...kf]),extends:z$1.array(ZE).default([]),overrides:z$1.record(z$1.string(),z$1.record(z$1.string(),z$1.unknown())).default({}),collaboration:qE.default({strategy:"merge",lock_features:[]}),conversions:QE,plugins:z$1.array(tA).default([]),pluginTargets:z$1.array(z$1.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});var jc="agentsmesh.yaml",rA="agentsmesh.local.yaml";async function nA(t){let e=resolve(t);for(;;){let r=join(e,jc);if(await N(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}i(nA,"findConfigPath");async function oA(t){let e=await I(t);if(e===null)throw new Br(t);let r=parse(e),n=Mc.safeParse(r);if(!n.success){let o=n.error.issues.map(s=>s.message);throw new Sa(t,o,{cause:n.error})}return n.data}i(oA,"loadConfig");function Gc(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]=Gc(s,o):r[n]=o;}return r}i(Gc,"deepMergeObjects");function sA(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=Gc(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=Gc(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}i(sA,"mergeLocalConfig");async function Uc(t){let e=join(t,jc),r=await oA(e),n=join(t,rA),o=await I(n);if(o!==null){let s=parse(o);if(typeof s=="object"&&s!==null&&!Array.isArray(s)){let a=sA(r,s),l=Mc.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(Uc,"loadConfigFromExactDir");async function Ef(t){let e=await nA(t);if(e===null)throw new Br(join(t,jc));return Uc(dirname(e))}i(Ef,"loadConfigFromDir");Hs();function Ys(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(Ys,"resolveScopeContext");async function lt(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await Ef(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Ys(t,e);try{let{config:n}=await Uc(r.configDir);return {config:n,context:r}}catch(n){throw n instanceof Br?new Br(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(lt,"loadScopedConfig");E();E();var uA=promisify(execFile),Af="repo";async function ka(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,Af),u=`${m}.tmp`,d=join(u,Af);if(!r.refresh&&await Lf(p))return Hc(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await fA(dA(t),d),t.ref&&await gA(d,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),Hc(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await Lf(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),Hc(p);throw g}}i(ka,"fetchGitRemoteExtend");async function Hc(t){return {resolvedPath:t,version:await hA(t)}}i(Hc,"readCachedRepo");async function Lf(t){return N(t)}i(Lf,"hasCachedRepo");function dA(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(dA,"resolveCloneUrl");async function fA(t,e){await zc(["clone",t,e]);}i(fA,"cloneRepo");async function gA(t,e){await zc(["checkout",e],t);}i(gA,"checkoutRef");async function hA(t){return zc(["rev-parse","HEAD"],t)}i(hA,"getHeadSha");async function zc(t,e){let{stdout:r}=await uA("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}i(zc,"runGit");E();async function Tf(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(Tf,"resolveLatestTag");async function Nf(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 Tf(t.org,t.repo,a);}catch(_){if(!s)throw _;return CA(t,e,r,n,o,a)}let m=o("github",`${t.org}/${t.repo}`,c),p=join(n,m);if(!l&&await N(p)){let _=await Vc(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 N(p)){let v=await Vc(p);if(v)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${_ instanceof Error?_.message:String(_)}`),{resolvedPath:join(p,v),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 Pf.extract({file:h,cwd:p,strict:!0,filter:i((_,w)=>!(SA(_)||w&&"type"in w&&(w.type==="Link"||w.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let C=await Vc(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(Nf,"fetchGithubRemoteExtend");async function Vc(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}i(Vc,"findExtractTopDir");function xf(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}i(xf,"buildGithubCloneUrl");function SA(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}i(SA,"isZipSlipPath");async function CA(t,e,r,n,o,s){let a=s?[xf(t.org,t.repo,s)]:[xf(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 ka(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}i(CA,"fetchGithubDefaultBranch");function Df(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(Df,"splitSourceRef");function Ff(t){let e=Df(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(Ff,"parseGithubSource");function vf(t){let e=Df(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(vf,"parseGitlabSource");function $f(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($f,"parseGitSource");function bn(t){let e=Ff(t);if(e)return {kind:"github",...e};let r=vf(t);if(r)return {kind:"gitlab",...r};let n=$f(t);return n?{kind:"git",...n}:null}i(bn,"parseRemoteSource");function Jc(t){return bn(t)!==null}i(Jc,"isSupportedRemoteSource");function wA(t){let e=bn(t);return e?e.kind==="github"?Po("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?Po("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):Po("git",e.url,e.ref??"HEAD"):null}i(wA,"cacheKeyFromSource");async function jf(t,e){let r=wA(t);if(!r)return;let n=e??Dt(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}i(jf,"cleanInstallCache");async function Uf(t,e){let r=t??Dt(),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(Uf,"sweepStaleCache");var Kf=80;function Po(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>Kf){let s=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,Kf-18)}--${s}`;}return o}i(Po,"buildCacheKey");function Dt(){let t=process.env.AGENTSMESH_CACHE;return t||join(homedir(),".agentsmesh","cache")}i(Dt,"getCacheDir");async function To(t,e,r={}){let n=bn(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??Dt();return Uf(o).catch(()=>{}),n.kind==="github"?Nf(n,e,r,o,Po,!t.includes("@")):ka(n,e,r,o,Po)}i(To,"fetchRemoteExtend");function TA(t){return t.startsWith("http://")||t.startsWith("https://")}i(TA,"isOtherRemoteSource");async function No(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Jc(o.source))){let o=Dt();await rm$1(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(TA(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(Jc(o.source)){let a=await To(o.source,o.name,{cacheDir:Dt(),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 N(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(No,"resolveExtendPaths");E();F();var FA=["always_on","model_decision","glob","manual"];function Bf(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}i(Bf,"toStrArray");async function xn(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",p=a.root===true,u=a.trigger,d=typeof u=="string"&&FA.includes(u)?u:void 0,g=a.codex_emit,h=g==="execution"?"execution":g==="advisory"?"advisory":void 0,R=a.codex_instruction==="override"?"override":void 0;n.push({source:o,root:m||p,targets:Bf(a.targets),description:typeof a.description=="string"?a.description:"",globs:Bf(a.globs),body:l,...d!==void 0&&{trigger:d},...h!==void 0&&{codexEmit:h},...R!==void 0&&{codexInstructionVariant:R}});}return n}i(xn,"parseRules");E();F();function zf(t){return t===true||t==="true"||t===1||t==="1"}i(zf,"toBool");function Vf(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(Vf,"toToolsArray");async function Pn(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=Vf(a.allowedTools),p=Vf(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:zf(a.outputStyle)||zf(a["output-style"]),body:l});}return n}i(Pn,"parseCommands");E();F();function Tn(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(Tn,"toStrArray");function Yf(t){return t===true||t==="true"||t===1||t==="1"}i(Yf,"toBool");function Xf(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(Xf,"toInt");function vA(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}i(vA,"toHooks");async function Nn(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=Tn(a.tools),p=Tn(a.tools),u=m.length>0?m:p,d=Tn(a.disallowedTools),g=Tn(a["disallowed-tools"]),h=d.length>0?d:g,C=Tn(a.mcpServers),R=Tn(a["mcp-servers"]),_=C.length>0?C:R,w=Tn(a.skills),v=Xf(a.maxTurns),A=Xf(a["max-turns"]),x=v>0?v:A>0?A: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:x,mcpServers:_,hooks:vA(a.hooks),skills:w,memory:typeof a.memory=="string"?a.memory:"",outputStyle:Yf(a.outputStyle)||Yf(a["output-style"]),body:l});}return n}i(Nn,"parseAgents");E();F();async function GA(t){return await I(t)??""}i(GA,"readContent");var Oa="SKILL.md",jA=[".git","node_modules"];function UA(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}i(UA,"sanitizeSkillName");async function Zf(t){let e=await P(t),r=[];for(let n of e){let s=n.slice(t.length+1).replace(/\\/g,"/");if(s===Oa||s.endsWith(`/${Oa}`))continue;let a=s.split("/")[0];if(jA.some(c=>a===c)||s===".DS_Store"||s.endsWith("/.DS_Store"))continue;let l=await GA(n);r.push({relativePath:s,absolutePath:n,content:l});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}i(Zf,"listSupportingFiles");async function qf(t){let e=join(t,Oa),r=await I(e);if(!r)return null;let{frontmatter:n,body:o}=O(r),s=await Zf(t),a=typeof n.name=="string"?UA(n.name):"";return {source:e,name:a||basename(t),description:typeof n.description=="string"?n.description:"",body:o,supportingFiles:s}}i(qf,"parseSkillDirectory");async function Do(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,Oa),a=await I(s);if(!a)continue;let{frontmatter:l,body:c}=O(a),m=await Zf(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(Do,"parseSkills");E();function Qf(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}i(Qf,"parseStringMap");function KA(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=Qf(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:Qf(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(KA,"parseServer");async function wa(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=KA(a);l&&(o[s]=l);}return {mcpServers:o}}i(wa,"parseMcp");E();function Xc(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}i(Xc,"ensureStringArray");async function Ea(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=Xc(n.allow),s=Xc(n.deny),a=Xc(n.ask);return {allow:o,deny:s,ask:a}}i(Ea,"parsePermissions");E();fe();var HA=["command","prompt"];function zA(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=Zc(e);if(!n)return null;let o=typeof e.type=="string"&&HA.includes(e.type)?e.type:void 0,s=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=bt(e)||void 0;return {matcher:r,command:n,...s!==void 0&&{timeout:s},...o&&{type:o},...a&&{prompt:a}}}i(zA,"toHookEntry");async function Aa(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=zA(c);m&&l.push(m);}l.length>0&&(n[s]=l);}return n}i(Aa,"parseHooks");E();async function La(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(La,"parseIgnore");E();async function Dn(t){let e=join(t,".agentsmesh"),r=await N(e)?e:t,[n,o,s,a,l,c,m,p]=await Promise.all([xn(join(r,"rules")),Pn(join(r,"commands")),Nn(join(r,"agents")),Do(join(r,"skills")),wa(join(r,"mcp.json")),Ea(join(r,"permissions.yaml")),Aa(join(r,"hooks.yaml")),La(join(r,"ignore"))]);return {rules:n,commands:o,agents:s,skills:a,mcp:l,permissions:c,hooks:m,ignore:p}}i(Dn,"loadCanonicalFiles");function eg(t){return basename(t.source,".md")}i(eg,"ruleSlug");function Fo(t,e){let r=new Map(t.rules.map(p=>[eg(p),p]));for(let p of e.rules)r.set(eg(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=JA(t.mcp,e.mcp),l=YA(t.permissions,e.permissions),c=XA(t.hooks,e.hooks),m=ZA(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(Fo,"mergeCanonicalFiles");function JA(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}i(JA,"mergeMcp");function YA(t,e){if(!t&&!e)return null;let r=qc(t?.allow??[],e?.allow??[]),n=qc(t?.deny??[],e?.deny??[]),o=qc(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}i(YA,"mergePermissions");function qc(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(qc,"mergeUniqueStrings");function XA(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(XA,"mergeHooks");function ZA(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(ZA,"mergeIgnore");E();var rg=[{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 ba(t){let e=null,r=0;for(let n of rg){let o=0;for(let s of n.paths)await N(join(t,s))&&o++;o>r&&(r=o,e=n.target);}return r>0?e:null}i(ba,"detectNativeFormat");var ng=rg.map(t=>t.paths[0]).filter(t=>t!==void 0);E();Ym();Gp();Op();su();hp();$u();tp();yp();lu();yu();fu();var wN={"claude-code":el,cursor:bl,copilot:Sl,"gemini-cli":Ml,"codex-cli":pl,windsurf:tc,cline:sl,continue:dl,junie:jl,kiro:zl,"kilo-code":Bl};async function Qi(t,e){let r=wN[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}i(Qi,"importNativeToCanonical");E();var td="SKILL.md";async function Co(t){if(!await N(t))return false;if(await N(join(t,td)))return true;try{let e=await readdir(t,{withFileTypes:!0});for(let r of e)if(!(!r.isDirectory()||r.name.startsWith("."))&&await N(join(t,r.name,td)))return !0}catch{return false}return false}i(Co,"isSkillPackLayout");async function ta(t){if(!await N(t))return [];if(await N(join(t,td))){let e=await qf(t);return e?[e]:[]}return Do(t)}i(ta,"loadSkillsAtExtendPath");E();function bN(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(bN,"emptyCanonical");function xN(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(xN,"isCanonicalSliceEmpty");async function ac(t){if(!await N(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(ac,"normalizeSlicePath");async function PN(t){if(basename(t)==="rules")return xn(t);let r=join(t,"rules");return await N(r)?xn(r):[]}i(PN,"parseRulesAt");async function TN(t){if(basename(t)==="commands")return Pn(t);let r=join(t,"commands");return await N(r)?Pn(r):[]}i(TN,"parseCommandsAt");async function NN(t){if(basename(t)==="agents")return Nn(t);let r=join(t,"agents");return await N(r)?Nn(r):[]}i(NN,"parseAgentsAt");async function DN(t){if(await Co(t))return ta(t);let e=join(t,"skills");return await Co(e)?ta(e):[]}i(DN,"loadSkillsForPartialSlice");async function lc(t){let e=join(t,".agentsmesh");if(await N(e))return Dn(t);let r=bN();if(r.rules=await PN(t),r.commands=await TN(t),r.agents=await NN(t),r.skills=await DN(t),xN(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}i(lc,"loadCanonicalSliceAtPath");function FN(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}i(FN,"emptyCanonical");async function Lk(t){let e=t.resolvedPath;if(!t.path){let o=join(e,".agentsmesh");if(!await N(o)){if(await Co(e)){let a=await ta(e);return {...FN(),skills:a}}let s=t.target??await ba(e);if(!s)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
147
|
-
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.
|
|
148
149
|
# Tracks the state of all config files for team conflict resolution.
|
|
149
150
|
|
|
150
|
-
`+stringify(n);await S(r,o);}i(
|
|
151
|
-
`),a=na(s),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}i(Ro,"buildExtendChecksums");nt();mr();function QN(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}i(QN,"addDirectoryMapping");function vk(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)QN(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}i(vk,"addSkillDirectoryMappings");nt();function $k(t,e,r="project"){let n=gt(t,r);if(!n)return null;if(e.root)return n.rootInstructionPath??null;if(e.targets.length>0&&!e.targets.includes(t))return null;let o=posix.basename(e.source.replace(/\\/g,"/"),".md");return n.paths.rulePath(o,e)}i($k,"ruleTargetPath");function Mk(t,e,r,n="project"){let o=gt(t,n);return o?o.paths.commandPath(e,r):null}i(Mk,"commandTargetPath");function Gk(t,e,r,n="project"){let o=gt(t,n);return o?o.paths.agentPath(e,r):null}i(Gk,"agentTargetPath");Lt();ft();Tt();nt();function rD(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}i(rD,"addDirectoryMapping");function ia(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=$k(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=Mk(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=Gk(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let s=Yi(t,n);if(!s)return o;for(let a of e.skills){rD(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),vk(o,m,p);}}return o}i(ia,"buildReferenceMap");dr();var An="AGENTS.md";function nD(t){return t.target===zs&&t.path.endsWith(An)}i(nD,"isCodexAgents");function jk(t){return t.target==="windsurf"&&t.path.endsWith(An)}i(jk,"isWindsurfAgents");function Uk(t){return t.target==="cline"&&t.path.endsWith(An)}i(Uk,"isClineAgents");function id(t){return t.target==="cursor"&&t.path.endsWith(An)}i(id,"isCursorAgents");function ad(t){return t.target==="gemini-cli"&&t.path.endsWith(An)}i(ad,"isGeminiAgents");function oD(t){return t.target==="kiro"&&t.path.endsWith(An)}i(oD,"isKiroAgents");function sD(t){return t.target==="kilo-code"&&t.path.endsWith(An)}i(sD,"isKiloCodeAgents");function iD(t){return id(t)||ad(t)}i(iD,"isCompatibilityAgents");function hc(t,e,r,n){let o=n.get(t);if(o)return o;let s=new Map;for(let[a,l]of ia(t,e,r))s.has(l)||s.set(l,a);return n.set(t,s),s}i(hc,"reverseReferenceMap");function yc(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(yc,"normalizeContent");function aD(t,e,r,n,o){let s=hc(t.target,r,n,o),a=hc(e.target,r,n,o);return yc(t.content,s)===yc(e.content,a)}i(aD,"hasEquivalentCanonicalContent");function lD(t,e,r,n,o){let s=hc(t.target,r,n,o),a=hc(e.target,r,n,o),l=yc(t.content,s).trim(),c=yc(e.content,a).trim();return l.length>c.length&&l.includes(c)}i(lD,"hasCanonicalSupersetContent");function Kk(t,e,r){let n=new Map;for(let a of t){if(!a.path.endsWith(An))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)nD(a)&&o.set(a.path,a);let s=new Map;return t.filter(a=>{if(id(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"))return false}if(ad(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!jk(a)&&!Uk(a)&&!id(a)&&!ad(a)&&!oD(a)&&!sD(a))return true;let l=o.get(a.path);return l?iD(a)||jk(a)||Uk(a)?false:!(aD(l,a,e,r,s)||lD(l,a,e,r,s)):true})}i(Kk,"preferEquivalentCodexAgents");wt();Xu();wt();wt();nt();function Bk(t,e,r,n){let o=n.normalize(e),s=n.normalize(r);t.set(o,s),t.set(`${o}/`,`${s}/`);}i(Bk,"addPackAbsoluteDirMapping");function cD(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(cD,"skillSupportingDirPrefixes");function Hk(t,e,r,n,o){let s=Yi(e,o);if(!s)return;let a=W(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));Bk(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 cD(c.supportingFiles))Bk(t,a.join(m,u),a.join(p,u),a);}}i(Hk,"addPackSkillArtifactMappings");wt();function mD(t){return `.agentsmesh/rules/${basename(t.source)}`}i(mD,"canonicalRulePath");function pD(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}i(pD,"copilotInstructionsPath");function Vk(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let s=W(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(s.normalize(s.join(r,mD(a))),s.normalize(s.join(r,pD(a))));}i(Vk,"applyCopilotInstructionArtifactRefs");nt();function Ic(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}i(Ic,"getAdditionalRootDecorationPaths");function Jk(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(Jk,"resolveRewriteFamilyId");function ld(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}i(ld,"pushUnique");function Yk(t,e,r,n){let o=[],s=r.get(`.agentsmesh/rules/${basename(e.source)}`);ld(o,s);let a=gt(t,n);if(e.root)for(let l of Ic(a))ld(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])ld(o,l);return o}i(Yk,"extraRuleOutputPaths");nt();function Xk(t,e,r,n,o,s){let a=gt(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(Xk,"addSkillMirrorSourceEntry");function dD(t){return `.agentsmesh/commands/${t.name}.md`}i(dD,"canonicalCommandPath");function fD(t){return `.agentsmesh/agents/${t.name}.md`}i(fD,"canonicalAgentPath");function gD(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}i(gD,"canonicalSkillPath");function Zk(t,e,r,n,o,s){let a=s?.scope??"project",l=W(n),c=new Map([...ia(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return Vk(t,c,n,o,e),Hk(c,t,e,n,a),c}i(Zk,"buildArtifactPathMap");function qk(t,e,r,n="project",o){let s=ia(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of Yk(t,l,s,n))a.set(c,l.source);for(let l of e.commands){let c=s.get(dD(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=s.get(fD(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=s.get(gD(l));c&&(a.set(c,l.source),Xk(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),Xk(t,n,u,m.absolutePath,a,o));}}return a}i(qk,"buildOutputSourceMap");nt();mr();Qc();function ID(t,e){if(!e)return null;for(let r of e){let n=Q(r);if(n?.sharedArtifacts){for(let[o,s]of Object.entries(n.sharedArtifacts))if(s==="owner"&&t.startsWith(o))return r}}return null}i(ID,"findSharedArtifactOwner");function Qk(t,e,r){if(e==="global"){let n=ID(t.path,r);if(n)return n;let o=pg(t.path);if(o)return o}return t.target}i(Qk,"artifactMapTargetForResult");function _D(t,e){return `${t}\0${(e??[]).join(",")}`}i(_D,"sourceMapCacheKey");function cd(t,e){let r=W(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(cd,"collectPlannedPaths");function SD(t,e,r){let n=gt(t.target,e),o=Jk(n,t.path);if(o!=="default")return `${t.target}:${o}`;let s=Qk(t,e,r);return s===t.target?t.target:`${t.target}~via~${s}`}i(SD,"artifactCacheKey");function tO(t,e,r,n,o="project",s){let a=cd(n,t),l=new Map,c=new Map;return t.map(m=>{let p=_D(m.target,s),d=(c.get(p)??(()=>{let _=qk(m.target,e,r,o,s);return c.set(p,_),_})()).get(m.path);if(!d)return m;let g=Qk(m,o,s),h=SD(m,o,s),C=l.get(h)??(()=>{let _=Zk(g,e,r,n,m.path,{scope:o});return l.set(h,_),_})(),R=sc({content:m.content,projectRoot:n,sourceFile:d,destinationFile:W(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 R.content===m.content?m:{...m,content:R.content}})}i(tO,"rewriteGeneratedReferences");wt();En();var RD=/!?\[[^\]]*\]\(([^)]+)\)/g,kD=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function OD(t){return t.endsWith(".md")||t.endsWith(".mdc")}i(OD,"isMarkdownLikeOutput");function wD(t,e){return e.some(([r,n])=>t>=r&&t<n)}i(wD,"isOffsetInRanges");function ED(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(ED,"parseMarkdownLinkDestination");function AD(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(AD,"shouldSkipLocalValidation");function LD(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}i(LD,"pathExistsForGenerate");function bD(t,e,r){let o=ED(t).split("#")[0]??"",{candidate:s}=vo(o),a=s,l=Ts.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(AD(c))return [];let m=Xi(c,e,r);if(m.length===0){let u=W(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 Zi(e,u)){let g=G(e,d);p.includes(g)||p.push(g);}return p}i(bD,"resolveMarkdownLinkTargets");function xD(t,e){let r=cd(e,t),n=[];for(let o of t){if(!OD(o.path))continue;let s=G(e,W(e).join(e,o.path)),a=oc(o.content),l=i((c,m)=>{if(wD(m,a))return;let p=bD(c,e,s);p.length!==0&&(p.some(u=>LD(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:p}));},"visitDestination");for(let c of o.content.matchAll(RD)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(kD)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}i(xD,"findBrokenMarkdownLinks");function eO(t,e){let r=xD(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:
|
|
152
153
|
${n.join(`
|
|
153
154
|
`)}
|
|
154
|
-
Fix canonical sources or generators so every local link targets an existing file or folder.`)}i(eO,"validateGeneratedMarkdownLinks");dr();var nO="AGENTS.md";function rO(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}i(rO,"statusRank");function PD(t,e){return rO(e.status)<=rO(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}i(PD,"mergeDuplicateMetadata");function _c(t){return t.trim()}i(_c,"trimmedContent");function TD(t,e){if(!t.path.endsWith(nO)||t.path!==e.path)return null;let r=_c(t.content),n=_c(e.content);if(!r||!n)return null;let o=r.includes(n),s=n.includes(r);return o===s?null:o?t:e}i(TD,"richerAgentsResult");function ND(t,e){if(!t.path.endsWith(nO)||t.path!==e.path)return null;let r=t.target===zs?t:e.target===zs?e:null,n=r===t?e:t;return r&&_c(r.content).length>_c(n.content).length?r:null}i(ND,"richerCodexAgentsResult");function oO(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=TD(o,r);if(s){e[n]=s;continue}let a=ND(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]=PD(o,r);}return e}i(oO,"resolveOutputCollisions");function sO(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}i(sO,"refreshResultStatus");E();nt();mr();function aO(t,e){return t===null?"created":t!==e?"updated":"unchanged"}i(aO,"computeStatus");function DD(t,e,r){let n=Uu(t,e,r);if(n!==null)return n;let o=Q(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(DD,"resolveGeneratedOutputPath");async function aa(t,e,r,n,o,s){let a=DD(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:aO(l,p)}),a}i(aa,"emitGeneratedOutput");function md(t,e,r){return {capability:Rn(t,r)?.[e]??{level:"none"},scope:r}}i(md,"featureContext");async function ko(t,e,r,n,o,s,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=md(c,a,s);for(let u of m(r,p)){let d=await aa(t,c,u,n,s);if(d===null)continue;let g=gt(c,s);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(d,e),C=h===null?[]:Array.isArray(h)?h:[h];for(let R of C){let _=await I(join(n,R));t.push({target:c,path:R,content:u.content,currentContent:_??void 0,status:aO(_,u.content)});}}}}}i(ko,"generateFeature");om();nt();function FD(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Ic(t)]:[]}i(FD,"rootDecorationPaths");function lO(t,e,r="project"){return t.map(n=>{let o=gt(n.target,r);if(!o)return n;let s=FD(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=Sg(l);return c===n.content?n:{...n,content:c}})}i(lO,"decoratePrimaryRootInstructions");nt();mr();au();function pd(t,e,r,n,o){let a=(le(t)??Q(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&oC.includes(o)?iC(l,n):n}i(pd,"mergeOutputContent");async function cO(t,e,r,n,o){for(let s of e){let a=Ps(s,"permissions",void 0,o)??Q(s)?.generators.generatePermissions;if(a)for(let l of a(r))await aa(t,s,l,n,o,{mergeContent:i((c,m,p,u)=>pd(s,c,m,p,u),"mergeContent")});}}i(cO,"generatePermissionsFeature");async function mO(t,e,r,n,o,s){for(let a of e){let l=Ps(a,"hooks",s,o)??Q(a)?.generators.generateHooks;if(!l)continue;let c=md(a,"hooks",o),m=[...l(r,c)],u=(le(a)??Q(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let d of m)await aa(t,a,d,n,o,{mergeContent:i((g,h,C,R)=>pd(a,g,h,C,R),"mergeContent")});}}i(mO,"generateHooksFeature");async function pO(t,e,r,n,o){for(let s of e){let l=(le(s)??Q(s))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await aa(t,s,m,n,o,{mergeContent:i((p,u,d,g)=>pd(s,p,u,d,g),"mergeContent")});}}i(pO,"generateScopedSettingsFeature");async function Sc(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,H){return Ps(x,H,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"),R=e.features.includes("ignore"),_=[];await ko(_,l,r,n,m,o,"rules",x=>c(x,"rules")),await ko(_,l,r,n,p,o,"commands",x=>c(x,"commands")),await ko(_,l,r,n,u,o,"agents",x=>c(x,"agents")),await ko(_,l,r,n,d,o,"skills",x=>c(x,"skills")),await ko(_,l,r,n,g,o,"mcp",x=>c(x,"mcp")),h&&await cO(_,l,r,n,o),C&&await mO(_,l,r,n,o,e),await ko(_,l,r,n,R,o,"ignore",x=>c(x,"ignore"));let w=new Set(e.features);for(let x of l){let j=(le(x)??Q(x))?.globalSupport?.scopeExtras;if(j){let K=await j(r,n,o,w);_.push(...K);}}(g||R||C||u||h)&&await pO(_,l,r,n,o);let v=lO(_,r,o),A=tO(v,r,e,n,o,l);return eO(A,n),oO(Kk(A.map(sO),r,e))}i(Sc,"generate");E();nt();async function uO(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 uO(s,e));continue}n.push(relative(e,s).replace(/\\/g,"/"));}return n}i(uO,"listFiles");async function GD(t,e,r){if(r.has(e))return;let n=join(t,e);await N(n)&&await rm$1(n,{recursive:true,force:true});}i(GD,"removeIfStale");async function dO(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let s=ju(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 N(l))for(let c of await uO(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await GD(t.projectRoot,o,e);}i(dO,"cleanupStaleGeneratedOutputs");E();Hs();var zD=6e4,VD=30,JD=200,YD=2e3;async function dd(t,e={}){let r=e.retries??VD,n=e.retryDelayMs??JD,o=e.staleMs??zD;await mkdir(dirname(t),{recursive:true});let s=0;for(;;){let a=await XD(t);if(a)return a;let l=await ZD(t);if(l!=="young"&&qD(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(s>=r){let c=l==="young"?null:l;throw new Ca(t,tF(c))}s++,await rF(n);}}i(dd,"acquireProcessLock");async function XD(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:yO()};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(XD,"tryAcquire");async function ZD(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return eF(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<YD)return "young"}catch{}return null}}i(ZD,"inspectLock");function qD(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==yO()?false:!QD(t.pid)}i(qD,"isStale");function QD(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}i(QD,"isProcessAlive");function tF(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}i(tF,"describeHolder");function eF(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}i(eF,"isLockMetadata");function yO(){return hostname()}i(yO,"getHostname");function rF(t){return new Promise(e=>setTimeout(e,t))}i(rF,"sleep");Ku();mr();async function iF(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(iF,"importPluginModule");function aF(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}i(aF,"extractDescriptors");async function Cc(t,e){let r;try{r=await iF(t,e);}catch(s){throw new Error(`Plugin '${t.source}' failed to import: ${s instanceof Error?s.message:String(s)}`,{cause:s})}let n=aF(r),o=[];for(let s of n)try{let a=rc(s);VR(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(Cc,"loadPlugin");async function IO(t,e){let r=[];return await Promise.all(t.map(async n=>{try{let o=await Cc(n,e);r.push(o);}catch(o){y.warn(`Plugin '${n.source}' failed to load: ${o instanceof Error?o.message:String(o)}`);}})),r}i(IO,"loadAllPlugins");async function pe(t,e){t.plugins.length!==0&&await IO(t.plugins,e);}i(pe,"bootstrapPlugins");nt();function fd(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=lF(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]=ec(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]=ec(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}i(fd,"buildCompatibilityMatrix");function lF(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}i(lF,"countHooks");var cF={"claude-code":"Claude"};function _O(t){return cF[t]??t}i(_O,"matrixColumnLabel");dr();nt();var mF=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];function SO(t){return Object.fromEntries(mF.map(e=>[e,Object.fromEntries(yt.map(r=>{let o=Rn(r,t)?.[e];return [r,o??{level:"none"}]}))]))}i(SO,"buildSupportMatrix");SO("project");SO("global");var gd={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},la={green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",dim:"\x1B[2m",reset:"\x1B[0m"};function pF(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}i(pF,"noColor");function uF(t,e){return pF()?e:`${t}${e}${la.reset}`}i(uF,"colorize");var dF={native:la.green,embedded:la.blue,partial:la.yellow,none:la.dim};function CO(t){let e=gd[t];return uF(dF[t],e)}i(CO,"coloredSymbol");function hd(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,K)=>r?K:`${j}${K}${n.reset}`,"c"),s=i(j=>j.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=i((j,K)=>{let tt=s(j),pt=Math.max(0,K-tt);return j+" ".repeat(pt)},"padWithColor"),l=Math.max(12,...e.map(j=>j.length)),c=e.map(j=>_O(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(K=>"\u2500".repeat(K)).join("\u252C")+"\u2510"),"border"),d=i(j=>o(n.dim,"\u251C"+j.map(K=>"\u2500".repeat(K)).join("\u253C")+"\u2524"),"sep"),g=i(j=>o(n.dim,"\u2514"+j.map(K=>"\u2500".repeat(K)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],C=u(h),R=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(j=>a(o(n.bold+n.magenta,j),m))],_=o(n.dim,"\u2502")+R.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),w=d(h),v=t.map(j=>{let K=[a(o(n.cyan,j.feature),p)];for(let tt of e){let pt=j.support[tt]??"none",rt=r?gd[pt]:CO(pt);K.push(a(` ${rt} `,m));}return o(n.dim,"\u2502")+K.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),A=g(h),x=[C,_,w,...v,A];x.push("");let H=[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: ")+H.join(" ")),x.join(`
|
|
155
|
-
`)}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?"":`
|
|
156
157
|
Per-file details:
|
|
157
158
|
`+e.join(`
|
|
158
159
|
`)+`
|
|
159
|
-
`}i(
|
|
160
|
-
`),t.verbose===true){let d=
|
|
161
|
-
`));}}i(
|
|
162
|
-
`),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(`
|
|
163
164
|
`);return `# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
164
165
|
version: 1
|
|
165
166
|
targets:
|
|
166
167
|
${r}
|
|
167
168
|
features:
|
|
168
169
|
${n}
|
|
169
|
-
`}i(
|
|
170
|
+
`}i(em,"buildConfig");var rm=`---
|
|
170
171
|
root: true
|
|
171
172
|
description: "Project rules"
|
|
172
173
|
---
|
|
@@ -175,7 +176,7 @@ description: "Project rules"
|
|
|
175
176
|
|
|
176
177
|
Add your project-wide instructions here.
|
|
177
178
|
This file is always included in AI tool context and synced to all configured tools.
|
|
178
|
-
`,
|
|
179
|
+
`,sf=`---
|
|
179
180
|
description: "Example contextual rule \u2014 rename and customize"
|
|
180
181
|
# targets: [claude-code, cursor] # limit to specific tools (optional)
|
|
181
182
|
# globs: ["src/**/*.ts"] # activate only for matching files (optional)
|
|
@@ -184,14 +185,14 @@ description: "Example contextual rule \u2014 rename and customize"
|
|
|
184
185
|
# Example Rule
|
|
185
186
|
|
|
186
187
|
Replace this with your coding standards, conventions, or domain-specific guidelines.
|
|
187
|
-
`,
|
|
188
|
+
`,af=`---
|
|
188
189
|
description: "Example command \u2014 rename and customize"
|
|
189
190
|
# allowed-tools: [Read, Grep, Glob, Bash]
|
|
190
191
|
---
|
|
191
192
|
|
|
192
193
|
Describe the task for this command here.
|
|
193
194
|
Commands are invoked on-demand (e.g. /example) with a focused tool set.
|
|
194
|
-
`,
|
|
195
|
+
`,lf=`---
|
|
195
196
|
name: example-agent
|
|
196
197
|
description: "Example subagent \u2014 rename and customize"
|
|
197
198
|
# tools: [Read, Grep, Glob]
|
|
@@ -202,7 +203,7 @@ description: "Example subagent \u2014 rename and customize"
|
|
|
202
203
|
|
|
203
204
|
Describe this agent's role and instructions here.
|
|
204
205
|
Agents are specialized subagents with restricted tools and a specific purpose.
|
|
205
|
-
`,
|
|
206
|
+
`,cf=`---
|
|
206
207
|
name: example-skill
|
|
207
208
|
description: "Example skill \u2014 rename and customize"
|
|
208
209
|
---
|
|
@@ -211,7 +212,7 @@ description: "Example skill \u2014 rename and customize"
|
|
|
211
212
|
|
|
212
213
|
Describe the skill procedure here.
|
|
213
214
|
Skills are reusable multi-step procedures that commands and agents can reference.
|
|
214
|
-
`,
|
|
215
|
+
`,mf=`{
|
|
215
216
|
"mcpServers": {
|
|
216
217
|
// "github": {
|
|
217
218
|
// "type": "stdio",
|
|
@@ -226,7 +227,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
226
227
|
// }
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
|
-
`,
|
|
230
|
+
`,pf=`# Lifecycle hooks \u2014 run shell commands before/after AI tool use
|
|
230
231
|
# Events: PreToolUse, PostToolUse, SubagentStart, SubagentStop
|
|
231
232
|
# Matcher: tool name pattern (e.g. "Edit|Write", "Bash", "*")
|
|
232
233
|
#
|
|
@@ -239,7 +240,7 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
239
240
|
# - matcher: Edit|Write
|
|
240
241
|
# type: command
|
|
241
242
|
# command: npm test --passWithNoTests
|
|
242
|
-
`,
|
|
243
|
+
`,uf=`# Tool permission allow/deny lists
|
|
243
244
|
#
|
|
244
245
|
# allow:
|
|
245
246
|
# - Bash(npm run:*)
|
|
@@ -255,14 +256,14 @@ Skills are reusable multi-step procedures that commands and agents can reference
|
|
|
255
256
|
allow: []
|
|
256
257
|
deny: []
|
|
257
258
|
ask: []
|
|
258
|
-
`,
|
|
259
|
+
`,df=`# Patterns ignored by all configured AI tools (gitignore syntax)
|
|
259
260
|
#
|
|
260
261
|
# node_modules/
|
|
261
262
|
# dist/
|
|
262
263
|
# .env*
|
|
263
264
|
# *.log
|
|
264
265
|
# coverage/
|
|
265
|
-
`,
|
|
266
|
+
`,QE=`# yaml-language-server: $schema=https://unpkg.com/agentsmesh/schemas/agentsmesh.json
|
|
266
267
|
# Personal overrides \u2014 NOT committed to git
|
|
267
268
|
# Uncomment and customize for your local setup:
|
|
268
269
|
|
|
@@ -281,25 +282,25 @@ ask: []
|
|
|
281
282
|
# overrides:
|
|
282
283
|
# claude-code:
|
|
283
284
|
# model: opus
|
|
284
|
-
`;
|
|
285
|
-
`).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(`
|
|
286
287
|
`)||r===""?"":`
|
|
287
288
|
`;await S(e,r+s+o.join(`
|
|
288
289
|
`)+`
|
|
289
|
-
`);}i(OF,"appendToGitignore");async function NO(t,e={}){let r=e.global===true?"global":"project",n=Ys(t,r),o=join(n.configDir,ca);if(await N(o))throw new Error(`Already initialized. ${ca} exists. Remove it first to re-init.`);let s=await LO(n.rootBase,r),a=r==="global"?s.filter(m=>TO.includes(m)):s,l=r==="global"?TO: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=RF[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 xO(n.canonicalDir),await S(o,Rc(a,l)),y.success(`Created ${ca} (targets: ${a.join(", ")})`);}else y.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),await bd(n.canonicalDir),await S(o,Rc([],l)),y.success(`Created ${ca}`);else await bd(n.canonicalDir),await S(o,Rc([],l)),y.success(`Created ${ca}`);let c=join(n.configDir,PO);await S(c,wO),y.success(`Created ${PO}`),r==="project"&&(await OF(t),y.success("Updated .gitignore"));}i(NO,"runInit");nt();var wF=Object.fromEntries(Et.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Oc(t){let e=wF[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}i(Oc,"getTargetCatalogEntry");mr();function DO(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(DO,"formatImportResults");async function FO(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(Hr(o)){let p=Ys(r,s),u=Oc(o),d=await u.importFrom(p.rootBase,{scope:s});if(d.length===0){y.info(u.emptyImportMessage);return}DO(d,p.rootBase,s);return}let a,l;try{({config:a,context:l}=await lt(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: ${yt.join(", ")}.`)}await pe(a,r);let c=Q(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...yt,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:s});if(m.length===0){y.info(c.emptyImportMessage);return}DO(m,l.rootBase,s);}i(FO,"runImport");function $O(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($O,"computeDiff");function MO(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}i(MO,"formatDiffSummary");async function GO(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 lt(r,n);await pe(a,r);let{canonical:c}=await me(a,l.configDir,{},l.canonicalDir),m=await Sc({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}=$O(m);for(let d of p)process.stdout.write(d.patch);y.info(MO(u));}i(GO,"runDiff");E();mr();Fn();Gt();var AF=[{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 jO(t){let e=new Set(t.enabledFeatures),r=[];for(let n of AF)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||ye(t.capabilities[n.capabilityKey]).level!=="none"||r.push(J(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(jO,"lintSilentFeatureDrops");Gt();var LF=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function bF(t){let r=t.match(LF)?.groups?.path;return typeof r=="string"?r:null}i(bF,"extractScriptToken");function UO(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=bF(o.command);s&&r.push(J(".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(UO,"lintHookScriptReferences");Gt();function KO(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(J(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(KO,"lintRuleScopeInversion");var xF=["node_modules",".git","dist","coverage",".agentsmesh"];async function PF(t){return (await P(t)).filter(n=>{let o=relative(t,n);return !xF.some(s=>o.includes(`/${s}/`)||o.startsWith(`${s}/`))}).map(n=>relative(t,n))}i(PF,"getProjectFiles");async function BO(t,e,r,n,o={}){let s=o.scope??"project",a=[...t.targets,...t.pluginTargets??[]],l=n?a.filter(R=>n.includes(R)):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 PF(r);for(let R of l){let _=Q(R),w=Hr(R)?Oc(R):_;w?.capabilities&&g.push(...jO({target:R,capabilities:w.capabilities,canonical:e,enabledFeatures:t.features})),d&&g.push(...UO({target:R,canonical:e,hasScriptProjection:_?.postProcessHookOutputs!==void 0})),c&&g.push(...KO({target:R,canonical:e,preservesManualActivation:_?.preservesManualActivation===true})),c&&w?.lintRules&&g.push(...w.lintRules(e,r,h,{scope:s})),_?.generators.lint&&g.push(..._.generators.lint(e));let v={scope:s};m&&w?.lint?.commands&&g.push(...w.lint.commands(e,v)),p&&w?.lint?.mcp&&g.push(...w.lint.mcp(e,v)),u&&w?.lint?.permissions&&g.push(...w.lint.permissions(e,v)),d&&w?.lint?.hooks&&g.push(...w.lint.hooks(e,v));}let C=g.some(R=>R.level==="error");return {diagnostics:g,hasErrors:C}}i(BO,"runLint");async function HO(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 lt(r,n);await pe(a,r);let{canonical:c}=await me(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await BO(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(HO,"runLintCmd");var DF=300;function FF(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}i(FF,"normalizeWatchPath");function vF(t,e,r){let n=FF(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(vF,"shouldIgnoreWatchPath");function $F(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($F,"featureFingerprint");async function VO(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{context:o}=await lt(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:R}=await lt(r,n),{canonical:_}=await me(C,R.configDir,{},R.canonicalDir),w=_.mcp?Object.keys(_.mcp.mcpServers).length:0,v=_.permissions?_.permissions.allow.length+_.permissions.deny.length:0,A=_.hooks?Object.values(_.hooks).reduce((K,tt)=>K+(Array.isArray(tt)?tt.length:0),0):0,x=_.ignore.length,H=$F(C.features,_.rules.length,_.commands.length,_.agents.length,_.skills.length,w,v,A,x),j=l!==null&&l!==H;l=H,!c&&(await vs(t,r,{printMatrix:false}),!c&&(j?await Oo(t,r):y.info("Regenerated.")));},"run"),d=i(()=>{let C=u().catch(R=>{if(!c){let _=R instanceof Error?R.message:String(R);y.error(_);}}).finally(()=>{m===C&&(m=null);});m=C;},"scheduleRun"),g=i(()=>{c||(a&&clearTimeout(a),a=setTimeout(d,DF));},"schedule"),h=NF.watch(s,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(C,R)=>{vF(o.canonicalDir,R)||g();}),await new Promise((C,R)=>{h.once("ready",C),h.once("error",R);}),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(VO,"runWatch");async function JO(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await dc(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let s=await Wr(n),a=await No(e,r),l=a.length>0?await Ro(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(s)),p=[],u=[],d=[];for(let _ of c){let w=s[_];w===void 0?d.push(_):w!==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=fc(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(JO,"checkLockSync");async function YO(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:s}=await lt(r,n);await pe(o,r);let a=await JO({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(YO,"runCheck");E();var GF=".lock",jF="<<<<<<<";async function Pd(t){let e=join(t,GF),r=await I(e);return r===null?false:r.includes(jF)}i(Pd,"hasLockConflict");async function ZO(t,e,r){if(!await Pd(t))throw new Error("No conflict to resolve.");let o=await Wr(t),s=dirname(t),a=r?await No(r,s):[],l=a.length>0?await Ro(a):{},c=await sa(join(t,"packs")),m=process.env.USER??process.env.USERNAME??"unknown";await oa(t,{generatedAt:new Date().toISOString(),generatedBy:m,libVersion:e,checksums:o,extends:l,packs:c});}i(ZO,"resolveLockConflict");async function qO(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:s}=await lt(r,n),a=s.canonicalDir;if(!await Pd(a)){y.info("No conflicts to resolve.");return}await ZO(a,Bs(),o),y.success("Lock file conflict resolved.");}i(qO,"runMerge");E();var WF=promisify(execFile);async function Td(t){let{stdout:e}=await WF("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}i(Td,"runGit");async function QO(){try{return await Td(["--version"]),!0}catch{return false}}i(QO,"isGitAvailable");async function BF(t,e){let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await Td(["ls-remote",t,o])).split(`
|
|
290
|
-
`).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(
|
|
291
|
-
`).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 BF(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 To(l,"install",{cacheDir:Dt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}if(t.kind==="gitlab"){let l=`gitlab:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await To(l,"install",{cacheDir:Dt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,s=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await To(s,"install",{cacheDir:Dt(),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 Nd(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(Nd,"parseGithubTreeUrl");function Dd(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(Dd,"parseGithubBlobUrl");function Fd(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(Fd,"parseGitlabTreeUrl");function vd(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(vd,"parseGitlabBlobUrl");var HF=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function $d(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||HF.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}i($d,"parseGithubRepoUrl");function Md(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(Md,"parseGitlabRepoUrl");function Gd(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}i(Gd,"parseGitSshGithub");function jd(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(jd,"parseGitSshGitlab");E();var JF=/^[A-Za-z]:[\\/]/,YF=/^[A-Za-z]:\//;function nw(...t){return t.some(e=>e.includes("\\")||JF.test(e))?win32:posix}i(nw,"pathApiFor");function pa(t){return t.replace(/\\/g,"/")}i(pa,"toPosixPath");function ma(t){return pa(t).replace(/^\/+|\/+$/g,"")}i(ma,"normalizeInstallPathField");function wc(t){let e=pa(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||YF.test(e)?e:`./${e}`}i(wc,"normalizeLocalSourceForYaml");function Ln(t){return {...t,source:t.source_kind==="local"?wc(t.source):t.source,...t.path!==void 0?{path:ma(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>ma(e))}:{}}}i(Ln,"normalizePersistedInstallPaths");function ow(t,e,r){let n=nw(t,e),o=n.normalize(t),s=n.normalize(e),a=ma(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=ma(u),g=pa(n.relative(s,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||d.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:wc(g)}}let m=pa(n.relative(s,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:wc(m)}}i(ow,"localParsedFromAbsPath");async function Ud(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=Nd(n)??Dd(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=$d(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=Fd(n)??vd(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=Md(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=Gd(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=jd(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 N(l))throw new Error(`Path does not exist: ${l}`);return ow(l,e,o)}i(Ud,"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(xo).min(1),pick:Js.optional(),target:Zt.optional(),path:z$1.string().optional(),paths:z$1.array(z$1.string().min(1)).min(1).optional(),as:Ds.optional()}),tv=z$1.object({version:z$1.literal(1),installs:z$1.array(sw).default([])});function ev(t,e){return t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n])}i(ev,"sameFeatures");function rv(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&ev(t.features,e.features)}i(rv,"sameInstallIdentity");function iw(t){return join(t,"installs.yaml")}i(iw,"manifestPath");async function Kd(t){let e=await I(iw(t));if(e===null)return [];try{return tv.parse(parse(e)).installs.map(r=>Ln(r))}catch{return []}}i(Kd,"readInstallManifest");async function aw(t,e){let r=Ln(e),o=(await Kd(t)).filter(s=>s.name!==r.name&&!rv(s,r));o.push(r),await S(iw(t),stringify({version:1,installs:o.sort((s,a)=>s.name.localeCompare(a.name))}));}i(aw,"upsertInstallManifestEntry");function lw(t){return Ln(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 ov(t){let e=await Kd(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 N(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(ov,"syncInstalledPacks");async function cw(t){return t.sync?(await ov({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"?Ds.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}i(mw,"readInstallFlags");function wo(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(wo,"featuresFromCanonical");async function Ec(t){let{sliceRoot:e,implicitPick:r}=await ac(t),n=await lc(e);return {canonical:n,features:wo(n),implicitPick:r}}i(Ec,"discoverFromContentRoot");function pw(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}i(pw,"validateSkill");function uw(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}i(uw,"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 de(t){return basename(t.source).replace(/\.md$/i,"")}i(de,"ruleSlug");function iv(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(iv,"featuresFromImplicitPick");function Ms(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??iv(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(de(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(Ms,"narrowDiscoveredForInstallScope");E();E();F();var cv=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"]),mv=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function Ac(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(Ac,"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 !(mv.has(o)||!n.includes("/")&&cv.has(n))},"filter")});}i(gw,"cpFilteredSkill");async function gv(){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(gv,"createStageRoot");async function hv(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(hv,"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 yv(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 Co(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await hw(t,e,r.preferredSkillNames??[]))return;let l=await Ac(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(yv,"stageSkills");async function yw(t,e,r={}){let n=await gv();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await yv(t,o,r):await hv(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 Ec(o.discoveryRoot),a=Ms(s,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:o.cleanup},narrowed:a,discoveredFeatures:wo(a)}}i(Iw,"resolveManualDiscoveredForInstall");E();var Iv=[{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 _v(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}i(_v,"norm");function bc(t){let e=_v(t),r=[...Iv].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(bc,"targetHintFromNativePath");function Bd(t,e){return bc(t)===e}i(Bd,"pathSupportsNativePick");function _w(t,e){if(!t||!e)return;let r=bc(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(_w,"validateTargetMatchesPath");function Sw(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}i(Sw,"extendPickHasArrays");E();E();ft();async function Rw(t,e){let r=join(t,...zt.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(Rw,"inferGeminiCommandNamesFromFiles");ft();re();E();async function Eo(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(Eo,"skillNamesFromNativeSkillDir");E();ie();async function kw(t,e){let r=join(t,...e.split("/"));if(e.startsWith(yn)){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 Eo(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 Yt(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(Yt,"mdNames");async function ww(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===zt||n.startsWith(`${zt}/`)){let s=await Rw(t,n);return s.length?{commands:s}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let s=await Yt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".claude/rules")){let s=await Yt(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".claude/agents")){let s=await Yt(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 Yt(o,".mdc");return s.length?{rules:s}:{}}if(n.startsWith(".cursor/commands")){let s=await Yt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".cursor/agents")){let s=await Yt(o,".md");return s.length?{agents:s}:{}}if(n.startsWith(".cursor/skills")){let s=await Eo(o);return s.length?{skills:s}:{}}return {}}if(r==="copilot")return kw(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let s=await Yt(o,".md");return s.length?{rules:s}:{}}if(r==="cline"){if(n.startsWith(St)){let s=await Eo(o);return s.length?{skills:s}:{}}if(n.startsWith(He)){let s=await Yt(o,".md");return s.length?{commands:s}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let s=await Yt(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".continue/prompts")){let s=await Yt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".continue/skills")){let s=await Eo(o);return s.length?{skills:s}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let s=await Yt(o,".md");return s.length?{commands:s}:{}}if(n.startsWith(".junie/rules")){let s=await Yt(o,".md");return s.length?{rules:s}:{}}if(n.startsWith(".junie/agents")){let s=await Yt(o,".md");return s.length?{agents:s}:{}}if(n.startsWith(".junie/skills")){let s=await Eo(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(ww,"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 fa(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}i(fa,"normalizePath");function bv(t,e){let r=fa(t),n=fa(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}i(bv,"overlapsPath");function xc(t,e){let r=t??[];return r.includes(e)||r.push(e),r}i(xc,"addUnique");async function xv(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(xv,"makeStageRoot");function Pv(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:xc(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let s=fa(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:xc(r?.commands,s.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:xc(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=fa(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:xc(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(Pv,"buildPickFromResults");function Tv(t,e,r,n){let o=join(e,...fa(t).split("/")),s=r.filter(a=>bv(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:Pv(s,e)}}i(Tv,"scopeImportedResults");async function zd(t,e){let{stageRoot:r,cleanup:n}=await xv(t);try{let o=await Qi(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}i(zd,"stageImportedNativeRepo");async function Vd(t,e,r){let n=await zd(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...Tv(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}i(Vd,"stageNativeInstallScope");async function xw(t,e,r,n){let o=n.explicitTarget?.trim();o&&Zt.parse(o);let s=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");_w(o,s);let a=join(t,".agentsmesh"),l=await N(a),c=s?bc(s):void 0,m=!l&&!o?await ba(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 w=await Vd(t,s,p);return {discoveryRoot:w.stageRoot,implicitPick:w.pick,scopedFeatures:w.features,yamlTarget:p,importHappened:true,cleanup:w.cleanup}}let _=await zd(t,p);return {discoveryRoot:s?join(_.stageRoot,s):_.stageRoot,yamlTarget:p,importHappened:true,cleanup:_.cleanup}}let d;l?s?p&&Bd(s,p)?d=t:d=e:d=t:d=e;let g,h,C;if(u&&p){let _=await Vd(t,s,p);d=_.stageRoot,g=_.pick,h=_.features,C=_.cleanup;}else if(d===t&&s&&p&&Bd(s,p)&&(g=await ww(t,s,p),Ew(g)))throw new Error(`No installable native resources found under "${s}" for target "${p}".`);let R;return o?R=o:p&&(g&&Sw(g)||(h?.length??0)>0)&&(R=p),{discoveryRoot:d,implicitPick:g,scopedFeatures:h,yamlTarget:R,importHappened:C!==void 0,cleanup:C}}i(xw,"prepareInstallDiscovery");async function Pw(t,e,r,n){let o=await xw(t,e,r,{explicitTarget:n}),{canonical:s,implicitPick:a}=await Ec(o.discoveryRoot),l=a??o.implicitPick,c=Ms(s,{implicitPick:l,scopedFeatures:o.scopedFeatures}),m=wo(c);return {prep:o,discovered:s,implicitPick:l,narrowed:c,discoveredFeatures:m}}i(Pw,"resolveDiscoveredForInstall");async function Tw(t){return t.explicitAs?{implicitPick:void 0,...await Iw(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:Pw(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}i(Tw,"resolveInstallDiscovery");function js(t){return t==="."||t===""?void 0:t}i(js,"trimDot");function Dv(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}i(Dv,"markdownPick");async function Dw(t){if(!t.as)return {pathInRepo:js(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:js(dirname(e)),pick:Dv(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:js(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 Ac(o);return {pathInRepo:js(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:js(e)}}}}return {pathInRepo:js(e)}}i(Dw,"resolveManualInstallPersistence");async function pr(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(pr,"confirm");function Fv(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}i(Fv,"hasArrayResources");function vw(t){return Fv(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=>pw(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 pr(`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=>uw(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 pr(`Include invalid rule "${de(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 pr(`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 pr(`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=>de(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 pr(`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=de(a);t.rules.some(c=>de(c)===l)&&(await pr(`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 pr(`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 pr(`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 Kw(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(Kw,"pickForSelectedResources");function vv(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}i(vv,"pathEndsWithName");function Pc(t,e,r){return r!==1||e.length!==1?false:vv(t,e[0])}i(Pc,"inferSingleNamePick");function Ww(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||Pc(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||Pc(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||Pc(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||Pc(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(Ww,"buildInstallPick");function Bw(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(Bw,"deriveInstallFeatures");function $v(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}i($v,"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($v(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 Mv(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(Mv,"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=Mv(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 S(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(`
|
|
292
293
|
`)?a:`${a}
|
|
293
|
-
`);}i(
|
|
294
|
-
${JSON.stringify(s,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await
|
|
295
|
-
`);return `sha256:${
|
|
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)}
|
|
296
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(`
|
|
297
298
|
`)}
|
|
298
|
-
`);}i(
|
|
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)}
|
|
299
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(`
|
|
300
301
|
`)}
|
|
301
|
-
`);}i(
|
|
302
|
-
`,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(
|
|
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}';
|
|
303
304
|
|
|
304
305
|
// Project-level paths
|
|
305
306
|
export const ${e}_DIR = '.${t.id}';
|
|
@@ -312,7 +313,7 @@ export const ${e}_GLOBAL_RULES_DIR = '~/.${t.id}/rules';
|
|
|
312
313
|
// Canonical paths
|
|
313
314
|
export const ${e}_CANONICAL_ROOT_RULE = '.agentsmesh/rules/_root.md';
|
|
314
315
|
export const ${e}_CANONICAL_RULES_DIR = '.agentsmesh/rules';
|
|
315
|
-
`}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';
|
|
316
317
|
import type { TargetDescriptor, TargetLayout } from '../catalog/target-descriptor.js';
|
|
317
318
|
import { generateRules } from './generator.js';
|
|
318
319
|
import { importFrom${r} } from './importer.js';
|
|
@@ -409,21 +410,21 @@ export const descriptor = {
|
|
|
409
410
|
buildImportPaths: build${r}ImportPaths,
|
|
410
411
|
detectionPaths: [${e}_DIR],
|
|
411
412
|
} satisfies TargetDescriptor;
|
|
412
|
-
`}i(
|
|
413
|
+
`}i(GL,"TEMPLATE_INDEX");function jL(t){let e=hi(t.id);return `import type { CanonicalFiles } from '../../core/types.js';
|
|
413
414
|
import { ${e}_TARGET, ${e}_DIR } from './constants.js';
|
|
414
415
|
|
|
415
|
-
export interface ${
|
|
416
|
+
export interface ${gi(t.id)}Output {
|
|
416
417
|
path: string;
|
|
417
418
|
content: string;
|
|
418
419
|
}
|
|
419
420
|
|
|
420
|
-
export function generateRules(_canonical: CanonicalFiles): ${
|
|
421
|
+
export function generateRules(_canonical: CanonicalFiles): ${gi(t.id)}Output[] {
|
|
421
422
|
// TODO(agentsmesh-scaffold): implement generateRules for ${t.displayName}
|
|
422
423
|
void ${e}_TARGET;
|
|
423
424
|
void ${e}_DIR;
|
|
424
425
|
return [];
|
|
425
426
|
}
|
|
426
|
-
`}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';
|
|
427
428
|
import type { TargetLayoutScope } from '../catalog/target-descriptor.js';
|
|
428
429
|
import { ${r}_TARGET } from './constants.js';
|
|
429
430
|
|
|
@@ -435,7 +436,7 @@ export async function importFrom${e}(
|
|
|
435
436
|
void ${r}_TARGET;
|
|
436
437
|
return [];
|
|
437
438
|
}
|
|
438
|
-
`}i(
|
|
439
|
+
`}i(UL,"TEMPLATE_IMPORTER");function KL(t){let e=hi(t.id);return `/** Lint rules for the ${t.id} target. */
|
|
439
440
|
import type { CanonicalFiles, LintDiagnostic } from '../../core/types.js';
|
|
440
441
|
import { validateRules } from '../../core/lint/validate-rules.js';
|
|
441
442
|
import { ${e}_TARGET } from './constants.js';
|
|
@@ -453,7 +454,7 @@ export function lintRules(
|
|
|
453
454
|
target: ${e}_TARGET,
|
|
454
455
|
}));
|
|
455
456
|
}
|
|
456
|
-
`}i(
|
|
457
|
+
`}i(KL,"TEMPLATE_LINTER");function WL(t){return `/**
|
|
457
458
|
* ${t.displayName}-specific lint hooks.
|
|
458
459
|
*/
|
|
459
460
|
|
|
@@ -463,7 +464,7 @@ export function lintHooks(_canonical: CanonicalFiles): LintDiagnostic[] {
|
|
|
463
464
|
// TODO(agentsmesh-scaffold): implement target-specific hook validation for ${t.displayName}
|
|
464
465
|
return [];
|
|
465
466
|
}
|
|
466
|
-
`}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';
|
|
467
468
|
import { ${r}_DIR } from '../../../targets/${t.id}/constants.js';
|
|
468
469
|
|
|
469
470
|
export async function build${e}ImportPaths(
|
|
@@ -475,7 +476,7 @@ export async function build${e}ImportPaths(
|
|
|
475
476
|
// Reference: src/core/reference/import-maps/kiro.ts for a full example
|
|
476
477
|
void ${r}_DIR;
|
|
477
478
|
}
|
|
478
|
-
`}i(
|
|
479
|
+
`}i(BL,"TEMPLATE_IMPORT_MAP");function HL(t){return `import { describe, it, expect } from 'vitest';
|
|
479
480
|
import type { CanonicalFiles } from '../../../../src/core/types.js';
|
|
480
481
|
import { generateRules } from '../../../../src/targets/${t.id}/generator.js';
|
|
481
482
|
|
|
@@ -504,7 +505,7 @@ describe('generateRules (${t.id})', () => {
|
|
|
504
505
|
expect(result).toHaveLength(0);
|
|
505
506
|
});
|
|
506
507
|
});
|
|
507
|
-
`}i(
|
|
508
|
+
`}i(HL,"TEMPLATE_GENERATOR_TEST");function zL(t){let e=gi(t.id);return `import { describe, it, expect } from 'vitest';
|
|
508
509
|
import { importFrom${e} } from '../../../../src/targets/${t.id}/importer.js';
|
|
509
510
|
|
|
510
511
|
describe('importFrom${e} (${t.id})', () => {
|
|
@@ -518,7 +519,7 @@ describe('importFrom${e} (${t.id})', () => {
|
|
|
518
519
|
expect(result).toHaveLength(0);
|
|
519
520
|
});
|
|
520
521
|
});
|
|
521
|
-
`}i(
|
|
522
|
+
`}i(zL,"TEMPLATE_IMPORTER_TEST");function VL(t){return `# ${t.displayName} Workspace
|
|
522
523
|
|
|
523
524
|
Follow the ${t.displayName} configuration files and keep changes small.
|
|
524
|
-
`}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};
|