agentsmesh 0.10.0 → 0.12.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 +56 -0
- package/README.md +22 -22
- package/dist/canonical.d.ts +2 -2
- package/dist/canonical.js +6761 -4856
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +124 -123
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +9028 -7117
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +9040 -7129
- package/dist/index.js.map +1 -1
- package/dist/{schema-qelg8gw8.d.ts → schema-o4oXUVBP.d.ts} +10 -0
- package/dist/{target-descriptor-Dhdg8s2o.d.ts → target-descriptor--Nw5i4v3.d.ts} +1 -1
- package/dist/targets.d.ts +3 -3
- package/dist/targets.js +8896 -6991
- package/dist/targets.js.map +1 -1
- package/package.json +1 -1
- package/schemas/agentsmesh.json +18 -3
- package/schemas/pack.json +6 -1
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
|
|
3
|
-
`)}async function
|
|
2
|
+
import {access,mkdir,lstat,unlink,writeFile,rename,rm as rm$1,readlink,symlink,stat,readFile,readdir,realpath,mkdtemp,cp,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}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 cG from'chokidar';import*as vw from'readline';var Og=Object.defineProperty;var s=(t,e)=>Og(t,"name",{value:e,configurable:true});var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var LP=(t,e)=>{for(var r in e)Og(t,r,{get:e[r],enumerable:true});};var Ss,Pn,ul,dl,Wr,$i=f(()=>{Ss=class extends Error{static{s(this,"AgentsMeshError");}code;constructor(e,r,n){super(r,n),this.name="AgentsMeshError",this.code=e;}},Pn=class extends Ss{static{s(this,"ConfigNotFoundError");}path;constructor(e,r){super("AM_CONFIG_NOT_FOUND",r?.message??`agentsmesh.yaml not found at ${e}. Run 'agentsmesh init' to create one.`,r),this.name="ConfigNotFoundError",this.path=e;}},ul=class extends Ss{static{s(this,"ConfigValidationError");}issues;constructor(e,r,n){super("AM_CONFIG_INVALID",`Invalid config at ${e}: ${r.join("; ")}. Fix the YAML and try again.`,n),this.name="ConfigValidationError",this.issues=r;}},dl=class extends Ss{static{s(this,"LockAcquisitionError");}lockPath;holder;constructor(e,r,n){super("AM_LOCK_ACQUISITION_FAILED",`Could not acquire generate lock at ${e}: currently held by ${r}. Wait for the other process to finish, or remove ${e} manually if you are sure no agentsmesh process is running.`,n),this.name="LockAcquisitionError",this.lockPath=e,this.holder=r;}},Wr=class extends Ss{static{s(this,"FileSystemError");}path;errnoCode;constructor(e,r,n){super("AM_FILESYSTEM",r,n),this.name="FileSystemError",this.path=e,this.errnoCode=n?.errnoCode;}};});function XP(t){let e=extname(t).toLowerCase();if(e.length>0)return JP.has(e);let r=basename(t).toLowerCase();return YP.has(r)}function ZP(t){return t.replace(/\r\n?/g,`
|
|
3
|
+
`)}async function y(t){try{let e=await readFile(t,"utf-8");return e.startsWith(Dg)?e.slice(Dg.length):e}catch(e){let r=e;if(r.code==="ENOENT")return null;throw new Wr(t,`Failed to read ${t}: ${r.message}. Ensure the file exists and is readable.`,{cause:e,errnoCode:r.code})}}async function S(t,e){let r=dirname(t);await mkdir(r,{recursive:true});try{let i=await lstat(t);if(i.isDirectory())throw new Wr(t,`Failed to write ${t}: target exists and is a directory. Remove it or choose a different path.`,{errnoCode:"EISDIR"});i.isSymbolicLink()&&await unlink(t).catch(a=>{if(a.code!=="ENOENT")throw a});}catch(i){if(i instanceof Wr||i.code!=="ENOENT")throw i}let n=`${t}.tmp`,o=XP(t)?ZP(e):e;try{try{(await lstat(n)).isSymbolicLink()&&await unlink(n);}catch(i){if(i.code!=="ENOENT")throw i}await writeFile(n,o,{encoding:"utf-8",flag:"w"}),await rename(n,t);}catch(i){await rm$1(n,{force:true}).catch(()=>{});let a=i;throw new Wr(t,`Failed to write ${t}: ${a.message}. Check permissions and disk space.`,{cause:i,errnoCode:a.code})}}async function F(t){try{return await access(t,constants.F_OK),!0}catch{return false}}async function O(t){await mkdir(t,{recursive:true});}async function T(t,e){let r;try{r=await realpath(t);}catch(o){let i=o;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="ELOOP")return [];throw new Wr(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:o,errnoCode:i.code})}let n=e??new Set;if(n.has(r))return [];n.add(r);try{let o=await readdir(t,{withFileTypes:!0}),i=[];for(let a of o){let l=join(t,a.name);a.isDirectory()||a.isSymbolicLink()&&await stat(l).then(m=>m.isDirectory(),()=>!1)?i.push(...await T(l,n)):i.push(l);}return i}catch(o){let i=o;if(i.code==="ENOENT"||i.code==="ENOTDIR"||i.code==="EACCES")return [];throw new Wr(t,`Failed to read directory ${t}: ${i.message}. Check permissions.`,{cause:o,errnoCode:i.code})}}async function Mm(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 Dg,JP,YP,w=f(()=>{$i();Dg="\uFEFF",JP=new Set([".md",".mdc",".mdx",".markdown",".txt",".json",".jsonc",".yaml",".yml",".toml",".ini",".sh",".bash",".zsh",".ps1",".js",".mjs",".cjs",".ts",".tsx",".html",".css"]),YP=new Set([".gitignore",".cursorignore",".cursorindexingignore",".aiignore",".agentignore",".clineignore",".geminiignore",".codeiumignore",".continueignore",".copilotignore",".windsurfignore",".junieignore",".kiroignore",".rooignore",".antigravityignore"]);s(XP,"shouldNormalizeLineEndings");s(ZP,"normalizeLineEndings");s(y,"readFileSafe");s(S,"writeFileAtomic");s(F,"exists");s(O,"mkdirp");s(T,"readDirRecursive");s(Mm,"ensureCacheSymlink");});function bn(t){return $m.includes(t)}var $m,Mg=f(()=>{$m=["amp","antigravity","claude-code","cline","codex-cli","continue","copilot","cursor","gemini-cli","goose","junie","kilo-code","kiro","opencode","roo-code","warp","windsurf","zed"];s(bn,"isBuiltinTargetId");});var xt,Gi,Br=f(()=>{Mg();xt=$m,Gi="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 N(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(()=>{s(E,"parseFrontmatter");s(N,"serializeFrontmatter");});function gh(t){return typeof t=="string"?t.trim():""}function Ct(t){return gh(t.command)}function zt(t){return gh(t.prompt)}function qm(t){let e=Ct(t),r=zt(t);return t.type==="prompt"?r||e:e||r}function zr(t){return Ct(t).length>0}function lr(t){return qm(t).length>0}var Fe=f(()=>{s(gh,"trimString");s(Ct,"getHookCommand");s(zt,"getHookPrompt");s(qm,"getHookText");s(zr,"hasHookCommand");s(lr,"hasHookText");});function V(t){return t.includes("\\")||ve.test(t)?win32:posix}function it(t){return t.replace(/\\/g,"/")}function j(t,e){let r=V(t),n=r.normalize(r===win32?e.replace(/\//g,"\\"):it(e));return n.endsWith(r.sep)&&n.length>1?n.slice(0,-1):n}function Sh(t,e){return V(t).isAbsolute(e)||ve.test(e)}function As(t){let e=t,r="";for(;ex.test(e);)r=e.at(-1)+r,e=e.slice(0,-1);return {candidate:e,suffix:r}}function Ch(t,e){let r=V(e),n=t.replace(/^(\.\.\/)+/,"").replace(/^\.\//,"");return n&&n!==t?j(e,r.join(e,n)):null}var ve,ex,$t=f(()=>{ve=/^[A-Za-z]:[\\/]/,ex=/[.!?:;]+$/;s(V,"pathApi");s(it,"normalizeSeparators");s(j,"normalizeForProject");s(Sh,"isAbsoluteForProject");s(As,"stripTrailingPunctuation");s(Ch,"rootFallbackPath");});function rx(t){return Object.prototype.hasOwnProperty.call(Rh,t)}function nx(t){return Object.prototype.hasOwnProperty.call(Oh,t)}function kh(t,e){if(t!==void 0)return typeof t=="boolean"?t:t[e]}function ws(t,e,r,n="project"){let o=t.conversions?.commands_to_skills?.[e],i=kh(o,n);return i!==void 0?i:rx(e)?Rh[e]:r??false}function fe(t,e,r,n="project"){let o=t.conversions?.agents_to_skills?.[e],i=kh(o,n);return i!==void 0?i:nx(e)?Oh[e]:r??false}var Rh,Oh,Ps=f(()=>{Rh={amp:true,"codex-cli":true,goose:true,kiro:true,warp:true},Oh={amp:true,"gemini-cli":false,cline:true,"codex-cli":false,windsurf:true,goose:true,antigravity:true,continue:true,warp:true};s(rx,"usesCommandSkillProjection");s(nx,"usesAgentSkillProjection");s(kh,"resolveConversionValue");s(ws,"shouldConvertCommandsToSkills");s(fe,"shouldConvertAgentsToSkills");});function $e(t,e){return e!==void 0?{level:t,flavor:e}:{level:t}}function Me(t){return typeof t=="string"?{level:t}:t}function Eh(t){return {rules:Me(t.rules),additionalRules:Me(t.additionalRules),commands:Me(t.commands),agents:Me(t.agents),skills:Me(t.skills),mcp:Me(t.mcp),hooks:Me(t.hooks),ignore:Me(t.ignore),permissions:Me(t.permissions)}}var Co=f(()=>{s($e,"cap");s(Me,"normalizeCapabilityValue");s(Eh,"normalizeTargetCapabilities");});function Lh(t){for(let e of Gt)if(e.sharedArtifacts){for(let[r,n]of Object.entries(e.sharedArtifacts))if(n==="owner"&&t.startsWith(r))return e.id}return null}function ox(t){let e=[];for(let n of t)if(n.sharedArtifacts)for(let[o,i]of Object.entries(n.sharedArtifacts))i==="owner"&&e.push({targetId:n.id,prefix:o});let r=[];for(let n=0;n<e.length;n++)for(let o=n+1;o<e.length;o++){let i=e[n],a=e[o];i===void 0||a===void 0||(i.prefix===a.prefix||i.prefix.startsWith(a.prefix)||a.prefix.startsWith(i.prefix))&&r.push({a:i,b:a});}return r}function Ah(t){let e=ox(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 tp=f(()=>{ct();s(Lh,"ownerTargetIdForSharedPath");s(ox,"findSharedArtifactOwnershipConflicts");s(Ah,"assertSharedArtifactOwnersUnique");});function sx(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 et(t){return `${bs}${t}`}function cr(t){let e={name:et(t.name),description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],N(e,t.body.trim()||"")}function Rl(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(bs)?e.slice(bs.length):e.startsWith(Bi)?e.slice(Bi.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",allowedTools:sx(t["x-agentsmesh-allowed-tools"])}:null}function Ol(t,e){return N({description:t.description,"allowed-tools":t.allowedTools},e.trim()||"")}var bs,Bi,Qt=f(()=>{v();bs="am-command-",Bi="ab-command-";s(sx,"toStringArray");s(et,"commandSkillDirName");s(cr,"serializeCommandSkill");s(Rl,"parseCommandSkillFrontmatter");s(Ol,"serializeImportedCommand");});function kl(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 ix(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 H(t){return `${xs}${t}`}function te(t){let e={name:H(t.name),description:t.description||void 0,"x-agentsmesh-kind":"agent","x-agentsmesh-name":t.name,"x-agentsmesh-tools":t.tools.length>0?t.tools:void 0,"x-agentsmesh-disallowed-tools":t.disallowedTools.length>0?t.disallowedTools:void 0,"x-agentsmesh-model":t.model||void 0,"x-agentsmesh-permission-mode":t.permissionMode||void 0,"x-agentsmesh-max-turns":t.maxTurns>0?t.maxTurns:void 0,"x-agentsmesh-mcp-servers":t.mcpServers.length>0?t.mcpServers:void 0,"x-agentsmesh-hooks":Object.keys(t.hooks).length>0?t.hooks:void 0,"x-agentsmesh-skills":t.skills.length>0?t.skills:void 0,"x-agentsmesh-memory":t.memory||void 0};return Object.keys(e).forEach(r=>{e[r]===void 0&&delete e[r];}),N(e,t.body.trim()||"")}function mr(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(xs)?e.slice(xs.length):e.startsWith(zi)?e.slice(zi.length):"",o=(r||n).trim();return o?{name:o,description:typeof t.description=="string"?t.description:"",tools:kl(t["x-agentsmesh-tools"]),disallowedTools:kl(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:kl(t["x-agentsmesh-mcp-servers"]),hooks:ix(t["x-agentsmesh-hooks"]),skills:kl(t["x-agentsmesh-skills"]),memory:typeof t["x-agentsmesh-memory"]=="string"?t["x-agentsmesh-memory"]:""}:null}function ge(t,e){let r={name:t.name,description:t.description,tools:t.tools,disallowedTools:t.disallowedTools.length>0?t.disallowedTools:void 0,model:t.model||void 0,permissionMode:t.permissionMode||void 0,maxTurns:t.maxTurns>0?t.maxTurns:void 0,mcpServers:t.mcpServers.length>0?t.mcpServers:void 0,hooks:Object.keys(t.hooks).length>0?t.hooks:void 0,skills:t.skills.length>0?t.skills:void 0,memory:t.memory||void 0};return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n];}),N(r,e.trim()||"")}var xs,zi,at=f(()=>{v();xs="am-agent-",zi="ab-agent-";s(kl,"toStringArray");s(ix,"toHooks");s(H,"projectedAgentSkillDirName");s(te,"serializeProjectedAgentSkill");s(mr,"parseProjectedAgentSkillFrontmatter");s(ge,"serializeImportedAgent");});function Hi(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ep(t,e){return new RegExp(`${Hi(t)}[\\s\\S]*?${Hi(e)}`,"g")}function Th(t,e,r,n){let o=ep(e,r);if(o.test(t))return t.replace(o,n).trim();let i=t.trim();return i?`${i}
|
|
11
11
|
|
|
12
|
-
${n}`:n}function
|
|
13
|
-
`)}function
|
|
14
|
-
`)}function
|
|
12
|
+
${n}`:n}function rp(t,e,r){return t.replace(ep(e,r),"").trim()}function cx(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 mx(t){return {source:cx(t.source),description:t.description,globs:t.globs,targets:t.targets}}function px(t){return `${bh}${JSON.stringify(mx(t))}${xh}`}function ux(t){let e=[px(t)];return t.description.trim()&&e.push(`## ${t.description.trim()}`,""),e.push(t.body.trim(),Ph),e.filter(r=>r.length>0).join(`
|
|
13
|
+
`)}function dx(t){return t.length===0?"":[El,...t.map(ux),Ll].join(`
|
|
14
|
+
`)}function Rt(t,e){let r=dx(e),n=rp(t,El,Ll);return r?n?`${n}
|
|
15
15
|
|
|
16
|
-
${r}`:r:n}function
|
|
16
|
+
${r}`:r:n}function wh(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function fx(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:wh(r.globs),targets:wh(r.targets)}}catch{return null}}function gx(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=ep(El,Ll);return {rootContent:t.replace(r,o=>{let i=o.replace(El,"").replace(Ll,"").trim(),a=new RegExp(`${Hi(bh)}([\\s\\S]*?)${Hi(xh)}([\\s\\S]*?)${Hi(Ph)}`,"g");for(let l of i.matchAll(a)){let c=l[1],m=l[2];if(c===void 0||m===void 0)continue;let p=fx(c);p&&e.push({...p,body:gx(m,p.description)});}return ""}).trim(),rules:e}}var Vi,Ji,El,Ll,Ph,bh,xh,he=f(()=>{Vi="<!-- agentsmesh:root-generation-contract:start -->",Ji="<!-- agentsmesh:root-generation-contract:end -->",El="<!-- agentsmesh:embedded-rules:start -->",Ll="<!-- agentsmesh:embedded-rules:end -->",Ph="<!-- agentsmesh:embedded-rule:end -->",bh="<!-- agentsmesh:embedded-rule:start ",xh=" -->";s(Hi,"escapeRegExp");s(ep,"managedBlockPattern");s(Th,"replaceManagedBlock");s(rp,"stripManagedBlock");s(cx,"ruleSource");s(mx,"markerForRule");s(px,"embeddedRuleStart");s(ux,"renderRule");s(dx,"renderEmbeddedRulesBlock");s(Rt,"appendEmbeddedRulesBlock");s(wh,"toStringArray");s(fx,"parseMarker");s(gx,"stripGeneratedHeading");s(Nh,"extractEmbeddedRules");});function np(t){return t.replace(/\s+/g," ").trim()}function Fh(t){let e=t.trim();if(e.includes(Vi)&&e.includes(Ji))return Th(e,Vi,Ji,Ts);let r=np(e);if(r.includes(np(Ts)))return e;for(let n of Dh)if(r.includes(np(n)))return e.replace(n,Ts);return e?`${e}
|
|
17
17
|
|
|
18
|
-
${
|
|
18
|
+
${Ts}`:Ts}function vh(t){let e=rp(t,Vi,Ji);e=e.replace(`
|
|
19
19
|
|
|
20
|
-
${
|
|
20
|
+
${Ts}`,"");for(let r of Dh)e=e.replace(`
|
|
21
21
|
|
|
22
|
-
${r}`,"");return e.trim()}var
|
|
22
|
+
${r}`,"");return e.trim()}var op,hx,yx,_x,Ix,Sx,Cx,Rx,Ox,kx,Ex,Lx,Ax,wx,Px,bx,xx,Ts,Dh,sp=f(()=>{he();op="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.",hx="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.",yx="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.",_x="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.",Ix="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`.",Sx="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`.",Cx="`.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`.",Rx="`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.",Ox=op,kx=`## Project-Specific Rules
|
|
23
23
|
|
|
24
|
-
${
|
|
24
|
+
${op}`,Ex=`## AgentsMesh Generation Contract
|
|
25
25
|
|
|
26
|
-
${
|
|
26
|
+
${op}`,Lx=`## AgentsMesh Generation Contract
|
|
27
27
|
|
|
28
|
-
${
|
|
28
|
+
${hx}`,Ax=`## AgentsMesh Generation Contract
|
|
29
29
|
|
|
30
|
-
${
|
|
30
|
+
${yx}`,wx=`## AgentsMesh Generation Contract
|
|
31
31
|
|
|
32
|
-
${
|
|
32
|
+
${_x}`,Px=`## AgentsMesh Generation Contract
|
|
33
33
|
|
|
34
|
-
${
|
|
34
|
+
${Ix}`,bx=`## AgentsMesh Generation Contract
|
|
35
35
|
|
|
36
|
-
${
|
|
36
|
+
${Sx}`,xx=`## AgentsMesh Generation Contract
|
|
37
37
|
|
|
38
|
-
${
|
|
38
|
+
${Cx}`,Ts=`${Vi}
|
|
39
39
|
## AgentsMesh Generation Contract
|
|
40
40
|
|
|
41
|
-
${
|
|
42
|
-
${ti}`;i(rm,"normalizeWhitespace");_g=[LL,AL,EL,wL,OL,kL,RL,CL,SL];i(Sg,"appendAgentsmeshRootInstructionParagraph");i(Cg,"stripAgentsmeshRootInstructionParagraph");});function xt(t){return Array.isArray(t)?t.filter(e=>typeof e=="string").map(e=>e.trim()).filter(Boolean):typeof t=="string"?t.split(",").map(e=>e.trim()).filter(Boolean):[]}async function Go(t){let e=await I(t);return e?O(e).frontmatter:{}}function It(t,e){return typeof t[e]=="string"?t[e]:void 0}function sm(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function bL(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function xL(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 Go(t),o=basename(t,".md")==="_root"?Cg(r):r.trim(),s=xL(t,bL({...n,...e})),a={root:s.root===true,description:typeof s.description=="string"?s.description:""};a.root===false&&(a.globs=xt(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 im=f(()=>{E();F();om();i(xt,"toStringArray");i(Go,"readExistingFrontmatter");i(It,"readString");i(sm,"readHooks");i(bL,"pruneUndefined");i(xL,"serializeCanonicalRuleFrontmatter");i(M,"serializeImportedRuleWithFallback");});async function Z(t,e,r){let n=await Go(t),o=(()=>{let l=xt(n.allowedTools);return l.length>0?l:xt(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 Ge(t,e,r){let n=await Go(t),o=basename(dirname(t)),s=It(e,"name")??It(n,"name")??o,a=It(e,"description")??It(n,"description")??"";return T({name:s,description:a},r.trim()||"")}async function _t(t,e,r){let n=await Go(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?xt(e.tools):(()=>{let C=xt(n.tools);return C.length>0?C:[]})(),s=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?xt(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?xt(e["disallowed-tools"]):xt(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?xt(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?xt(e["mcp-servers"]):xt(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?xt(e.skills):xt(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=sm(e)??sm(n),u={name:It(e,"name")??It(n,"name")??basename(t,".md"),description:It(e,"description")??It(n,"description")??"",tools:o};s.length>0&&(u.disallowedTools=s);let d=It(e,"model")??It(n,"model");d&&(u.model=d);let g=It(e,"permissionMode")??It(e,"permission-mode")??It(n,"permissionMode")??It(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=It(e,"memory")??It(n,"memory");return h&&(u.memory=h),T(u,r.trim()||"")}var Og=f(()=>{F();im();i(Z,"serializeImportedCommandWithFallback");i(Ge,"serializeImportedSkillWithFallback");i(_t,"serializeImportedAgentWithFallback");});var Y=f(()=>{im();Og();});function qt(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 Wt(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,am,a.name),u=join(p,"SKILL.md"),{frontmatter:d,body:g}=O(o(m,c,u)),h=await Ge(u,{...d,name:a.name},g);await k(p),await S(u,h),n.push({fromTool:r,fromPath:c,toPath:`${am}/${a.name}/SKILL.md`,feature:"skills"});let C=await P(l);for(let R of C){if(R===c)continue;let _=relative(l,R).replace(/\\/g,"/"),w=await I(R);if(w===null)continue;let v=join(p,_);await k(dirname(v)),await S(v,o(w,R,v)),n.push({fromTool:r,fromPath:R,toPath:`${am}/${a.name}/${_}`,feature:"skills"});}}}var am,Bt=f(()=>{E();F();Y();am=".agentsmesh/skills";i(qt,"generateEmbeddedSkills");i(Wt,"importEmbeddedSkills");});var vn,Ta,je,Se,ei,$n,hr,ri,Ue,yr,ni,Uo,lm,Mn,Na,wg,Gn=f(()=>{vn="antigravity",Ta=".agents",je=`${Ta}/rules`,Se=`${je}/general.md`,ei=`${je}/_root.md`,$n=`${Ta}/skills`,hr=`${Ta}/workflows`,ri=`${Ta}/antigravity/mcp_config.json`,Ue=".gemini/antigravity/GEMINI.md",yr=".gemini/antigravity/skills",ni=".gemini/antigravity/workflows",Uo=".gemini/antigravity/mcp_config.json",lm=".agentsmesh/rules/_root.md",Mn=".agentsmesh/rules",Na=".agentsmesh/commands",wg=".agentsmesh/mcp.json";});function Eg(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:Se,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:`${je}/${o}.md`,content:n.body.trim()||""});}return r}function Ag(t){return t.commands.map(e=>{let r=e.description.trim(),n=e.body.trim(),o=r&&n&&!n.startsWith(r)?`${r}
|
|
41
|
+
${Rx}
|
|
42
|
+
${Ji}`;s(np,"normalizeWhitespace");Dh=[xx,bx,Px,wx,Ax,Lx,Ex,kx,Ox];s(Fh,"appendAgentsmeshRootInstructionParagraph");s(vh,"stripAgentsmeshRootInstructionParagraph");});function Ht(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 Ns(t){let e=await y(t);return e?E(e).frontmatter:{}}function Tt(t,e){return typeof t[e]=="string"?t[e]:void 0}function ip(t){let e=t.hooks;return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Tx(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function Nx(t,e){let r=basename(t,".md")==="_root",n={...e};return delete n.root,{root:r,...n}}async function $(t,e,r){let n=await Ns(t),o=basename(t,".md")==="_root"?vh(r):r.trim(),i=Nx(t,Tx({...n,...e})),a={root:i.root===true,description:typeof i.description=="string"?i.description:""};a.root===false&&(a.globs=Ht(i.globs));for(let[l,c]of Object.entries(i))l==="root"||l==="description"||l==="globs"||c===void 0||(a[l]=c);return N(a,o||"")}var ap=f(()=>{w();v();sp();s(Ht,"toStringArray");s(Ns,"readExistingFrontmatter");s(Tt,"readString");s(ip,"readHooks");s(Tx,"pruneUndefined");s(Nx,"serializeCanonicalRuleFrontmatter");s($,"serializeImportedRuleWithFallback");});async function tt(t,e,r){let n=await Ns(t),o=(()=>{let l=Ht(n.allowedTools);return l.length>0?l:Ht(n["allowed-tools"])})(),i=e.hasDescription?e.description??"":typeof n.description=="string"?n.description:"",a=e.hasAllowedTools?e.allowedTools??[]:o;return N({description:i,"allowed-tools":a},r.trim()||"")}async function pr(t,e,r){let n=await Ns(t),o=basename(dirname(t)),i=Tt(e,"name")??Tt(n,"name")??o,a=Tt(e,"description")??Tt(n,"description")??"";return N({name:i,description:a},r.trim()||"")}async function Ot(t,e,r){let n=await Ns(t),o=Object.prototype.hasOwnProperty.call(e,"tools")?Ht(e.tools):(()=>{let C=Ht(n.tools);return C.length>0?C:[]})(),i=Object.prototype.hasOwnProperty.call(e,"disallowedTools")?Ht(e.disallowedTools):Object.prototype.hasOwnProperty.call(e,"disallowed-tools")?Ht(e["disallowed-tools"]):Ht(n.disallowedTools),a=Object.prototype.hasOwnProperty.call(e,"mcpServers")?Ht(e.mcpServers):Object.prototype.hasOwnProperty.call(e,"mcp-servers")?Ht(e["mcp-servers"]):Ht(n.mcpServers),l=Object.prototype.hasOwnProperty.call(e,"skills")?Ht(e.skills):Ht(n.skills),c=e.maxTurns??e["max-turns"]??n.maxTurns,m=typeof c=="number"?c:Number(c??0),p=ip(e)??ip(n),u={name:Tt(e,"name")??Tt(n,"name")??basename(t,".md"),description:Tt(e,"description")??Tt(n,"description")??"",tools:o};i.length>0&&(u.disallowedTools=i);let d=Tt(e,"model")??Tt(n,"model");d&&(u.model=d);let g=Tt(e,"permissionMode")??Tt(e,"permission-mode")??Tt(n,"permissionMode")??Tt(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=Tt(e,"memory")??Tt(n,"memory");return h&&(u.memory=h),N(u,r.trim()||"")}var Gh=f(()=>{v();ap();s(tt,"serializeImportedCommandWithFallback");s(pr,"serializeImportedSkillWithFallback");s(Ot,"serializeImportedAgentWithFallback");});var Z=f(()=>{ap();Gh();});function Al(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 ye(t){await rm$1(t,{recursive:true,force:true});}var Ds=f(()=>{s(Al,"shouldImportScopedAgentsRule");s(ye,"removePathIfExists");});function _t(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:N(o,n.body.trim()||"")});for(let i of n.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");r.push({path:`${e}/${n.name}/${a}`,content:i.content});}}return r}async function dt(t,e,r,n,o){let i=await readdir(join(t,e),{encoding:"utf8",withFileTypes:true}).catch(()=>null);if(i!==null)for(let a of i){if(!a.isDirectory())continue;let l=join(t,e,a.name),c=join(l,"SKILL.md"),m=await y(c);if(m===null)continue;let p=join(t,Yi,a.name),u=join(p,"SKILL.md"),{frontmatter:d,body:g}=E(o(m,c,u)),h=Rl(d,a.name);if(h){await ye(join(t,Yi,a.name));let k=join(t,jh);await O(k);let D=join(k,`${h.name}.md`);await S(D,Ol(h,o(g,c,D))),n.push({fromTool:r,fromPath:c,toPath:`${jh}/${h.name}.md`,feature:"commands"});continue}let C=mr(d,a.name);if(C){await ye(join(t,Yi,a.name));let k=join(t,Uh);await O(k);let D=join(k,`${C.name}.md`);await S(D,ge(C,o(g,c,D))),n.push({fromTool:r,fromPath:c,toPath:`${Uh}/${C.name}.md`,feature:"agents"});continue}let R=await pr(u,{...d,name:a.name},g);await O(p),await S(u,R),n.push({fromTool:r,fromPath:c,toPath:`${Yi}/${a.name}/SKILL.md`,feature:"skills"});let I=await T(l);for(let k of I){if(k===c)continue;let D=relative(l,k).replace(/\\/g,"/"),P=await y(k);if(P===null)continue;let b=join(p,D);await O(dirname(b)),await S(b,o(P,k,b)),n.push({fromTool:r,fromPath:k,toPath:`${Yi}/${a.name}/${D}`,feature:"skills"});}}}var Yi,jh,Uh,ft=f(()=>{w();v();Z();at();Qt();Ds();Yi=".agentsmesh/skills",jh=".agentsmesh/commands",Uh=".agentsmesh/agents";s(_t,"generateEmbeddedSkills");s(dt,"importEmbeddedSkills");});var Ie,jt,ur,lp,Vr,Se,Jr,Kh,Ro=f(()=>{Ie="AGENTS.md",jt=".agents/skills",ur=".amp/settings.json",lp=".config/amp",Vr=`${lp}/AGENTS.md`,Se=`${lp}/skills`,Jr=`${lp}/settings.json`,Kh=".agentsmesh/rules";});function Wh(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("amp")),n=e?.body.trim()??"",o=Rt(n,r);return o?[{path:Ie,content:o}]:[]}function Bh(t){return _t(t,jt)}function zh(t){return t.commands.map(e=>({path:`${jt}/${et(e.name)}/SKILL.md`,content:cr(e)}))}function Hh(t){return t.agents.map(e=>({path:`${jt}/${H(e.name)}/SKILL.md`,content:te(e)}))}var Vh=f(()=>{ft();he();at();Qt();Ro();s(Wh,"generateRules");s(Bh,"generateSkills");s(zh,"generateCommands");s(Hh,"generateAgents");});function rt(t,e,r){return t.startsWith(`${e}/`)&&!r.includes("codex-cli")?`.agents/skills/${t.slice(e.length+1)}`:null}var se=f(()=>{s(rt,"mirrorSkillsToAgents");});async function Ut(t,e,r){let n=join(t,e),i={...await Ux(n),...r};await O(dirname(n)),await S(n,JSON.stringify({mcpServers:i},null,2));}async function Ux(t){let e=await y(t);if(e===null)return {};let r;try{r=JSON.parse(e);}catch{return {}}if(!r||typeof r!="object"||Array.isArray(r))return {};let n=r.mcpServers;if(!n||typeof n!="object"||Array.isArray(n))return {};let o={};for(let[i,a]of Object.entries(n))!a||typeof a!="object"||Array.isArray(a)||(o[i]=a);return o}var Yr=f(()=>{w();s(Ut,"writeMcpWithMerge");s(Ux,"readExistingServers");});function Xr(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}function Ce(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 Fs(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function vs(t){return !t||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}var je=f(()=>{s(Xr,"toGlobsArray");s(Ce,"toToolsArray");s(Fs,"toStringArray");s(vs,"toStringRecord");});function Bx(t,e){return e.some(r=>t.endsWith(r))}async function nt(t){let r=(await T(t.srcDir)).filter(o=>Bx(o,t.extensions)),n=[];for(let o of r){let i=await y(o);if(!i)continue;let a=relative(t.srcDir,o).replace(/\\/g,"/"),l=await t.mapEntry({srcPath:o,relativePath:a,content:i,normalizeTo:s((c,m=i)=>t.normalize(m,o,c),"normalizeTo")});l&&(await O(dirname(l.destPath)),await S(l.destPath,l.content),n.push({fromTool:t.fromTool,fromPath:o,toPath:l.toPath,feature:l.feature}));}return n}var Ue=f(()=>{w();s(Bx,"matchesExtension");s(nt,"importFileDirectory");});function Jh(t){return typeof t=="string"?t:void 0}function zx(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}function mp(t,e){return e?e(t):t}function Hx(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=E(e.normalizeTo(r)),i=mp(n,t.frontmatterRemap),a=zx({root:false,description:Jh(i.description),globs:Array.isArray(i.globs)?i.globs:void 0,...i});return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await $(r,a,o)}}}function Vx(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=E(e.normalizeTo(r)),i=mp(n,t.frontmatterRemap),a=await tt(r,{hasDescription:true,description:Jh(i.description),hasAllowedTools:true,allowedTools:Fs(i["allowed-tools"])},o);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:a}}}function Jx(t){return async e=>{let r=join(e.destDir,e.relativePath),{frontmatter:n,body:o}=E(e.normalizeTo(r)),i=mp(n,t.frontmatterRemap);return {destPath:r,toPath:`${t.canonicalDir}/${e.relativePath}`,content:await Ot(r,i,o)}}}function Yh(t){if(t.map)return t.map;switch(t.preset){case "rule":return Hx(t);case "command":return Vx(t);case "agent":return Jx(t);default:throw new Error(`ImportFeatureSpec for ${t.feature} (mode: ${t.mode}) needs a \`preset\` or \`map\``)}}var Xh=f(()=>{v();Z();je();s(Jh,"pickString");s(zx,"pruneUndefined");s(mp,"applyRemap");s(Hx,"ruleMapper");s(Vx,"commandMapper");s(Jx,"agentMapper");s(Yh,"resolveMapper");});function pp(t,e){return t?t[e]??[]:[]}var Zh,qh=f(()=>{Zh=["rules","commands","agents","skills","mcp","hooks","permissions","ignore"];s(pp,"resolveScopedSources");});async function Zx(t,e,r,n,o){if(!t.canonicalRootFilename)throw new Error(`singleFile spec for ${t.feature} must set canonicalRootFilename`);let i=join(r,t.canonicalDir);for(let a of e){let l=join(r,a),c=await y(l);if(c===null)continue;await O(i);let m=join(i,t.canonicalRootFilename),p=s(R=>o(c,l,R),"normalizeTo");if(t.map){let R=await t.map({absolutePath:l,relativePath:a,content:c,destDir:i,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}=E(p(m)),g=t.frontmatterRemap?t.frontmatterRemap(u):u,h=t.markAsRoot?{...g,root:true}:g,C=await $(m,h,d);return await S(m,C),[{fromTool:n,fromPath:l,toPath:`${t.canonicalDir}/${t.canonicalRootFilename}`,feature:t.feature}]}return []}async function qx(t,e,r,n,o){let i=Yh(t),a=join(r,t.canonicalDir),l=[];for(let c of e){let m=join(r,c),p=await nt({srcDir:m,destDir:a,extensions:[...t.extensions??[".md"]],fromTool:n,normalize:o,mapEntry:s(async({srcPath:u,relativePath:d,content:g,normalizeTo:h})=>{let C=await i({absolutePath:u,relativePath:d,content:g,destDir:a,normalizeTo:s(R=>h(R),"normalizeTo")});return C?{destPath:C.destPath,toPath:C.toPath,feature:t.feature,content:C.content}:null},"mapEntry")});l.push(...p);}return l}function ty(t){let e=t.canonicalFilename;return e.includes("/")||e.includes("\\")?e:posix.join(t.canonicalDir,e)}async function Qx(t,e,r,n){if(!t.canonicalFilename)throw new Error(`flatFile spec for ${t.feature} must set canonicalFilename`);let o=ty(t);for(let i of e){let a=join(r,i),l=await y(a);if(l===null)continue;let c=join(r,o);return await O(dirname(c)),await S(c,l.trimEnd()),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}]}return []}function tT(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object")return {};let r=e.mcpServers;if(!r||typeof r!="object"||Array.isArray(r))return {};let n={};for(let[o,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i,l=typeof a.description=="string"?a.description:void 0;if(typeof a.command=="string"){n[o]={type:typeof a.type=="string"?a.type:"stdio",command:a.command,args:Fs(a.args),env:vs(a.env),description:l};continue}typeof a.url=="string"&&(n[o]={type:typeof a.type=="string"?a.type:"http",url:a.url,headers:vs(a.headers),env:vs(a.env),description:l});}return n}async function eT(t,e,r,n){if(!t.canonicalFilename)throw new Error(`mcpJson spec for ${t.feature} must set canonicalFilename`);let o=ty(t);for(let i of e){let a=join(r,i),l=await y(a);if(l===null)continue;let c=tT(l);return Object.keys(c).length===0?[]:(await Ut(r,o,c),[{fromTool:n,fromPath:a,toPath:o,feature:t.feature}])}return []}function Qh(t,e,r,n,o){switch(t.mode){case "singleFile":return Zx(t,e,r,n,o);case "directory":return qx(t,e,r,n,o);case "flatFile":return Qx(t,e,r,n);case "mcpJson":return eT(t,e,r,n)}}async function rT(t,e,r,n,o){let i=pp(t.source,e),a=pp(t.fallbacks,e);if(i.length===0&&a.length===0)return [];if(i.length>0){let l=await Qh(t,i,r,n,o);if(l.length>0)return l}return a.length>0?Qh(t,a,r,n,o):[]}function nT(t,e){let r=t[e];return r?Array.isArray(r)?r:[r]:[]}async function q(t,e,r,n){let o=t.importer;if(!o)return [];let i=n?.normalize??await B(t.id,e,r),a=[];for(let l of Zh)for(let c of nT(o,l))a.push(...await rT(c,r,e,t.id,i));return a}var Kt=f(()=>{gt();w();Yr();v();je();Z();Ue();Xh();qh();s(Zx,"runSingleFile");s(qx,"runDirectory");s(ty,"resolveCanonicalFilePath");s(Qx,"runFlatFile");s(tT,"parseMcpJson");s(eT,"runMcpJson");s(Qh,"dispatchSpec");s(rT,"runSpec");s(nT,"specsForFeature");s(q,"runDescriptorImport");});async function ry(t,e,r){let n=await y(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let i=o,a=i["amp.mcpServers"]??i.mcpServers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a))!m||typeof m!="object"||Array.isArray(m)||(l[c]=m);Object.keys(l).length!==0&&(await Ut(t,ey,l),r.push({fromTool:"amp",fromPath:e,toPath:ey,feature:"mcp"}));}var ey,ny=f(()=>{w();Yr();Ro();ey=".agentsmesh/mcp.json";s(ry,"importAmpMcp");});async function oy(t,e={}){let r=e.scope??"project",n=[],o=await B("amp",t,r);return n.push(...await q(wl,t,r,{normalize:o})),await dt(t,r==="global"?Se:jt,"amp",n,o),await ry(t,r==="global"?Jr:ur,n),n}var sy=f(()=>{gt();ft();Kt();ny();Ro();up();s(oy,"importFromAmp");});function sT(t,e){return ay(e).some(n=>iT(t,n))}function iy(t,e){return t.filter(r=>sT(r,e))}function ay(t){let e=t.match(/^(.+)\{([^}]+)\}(.*)$/);if(!e)return [t];let[,r,n,o]=e;if(!n)return [t];let i=n.split(",").map(l=>l.trim()),a=[];for(let l of i)for(let c of ay(r+l+o))a.push(c);return a}function iT(t,e){return aT(e).test(t)}function aT(t){let e=[],r=0;for(;r<t.length;){if(t.startsWith("**",r)){let i=t.slice(r+2);if(i.length===0&&e.length===0)e.push(".*");else if(e.push(i.startsWith("/")?"(?:[^/]+/)*":"(?:/[^/]+)*?"),i.startsWith("/")){r+=3;continue}r+=2;continue}if(t[r]==="*"){e.push("[^/]*"),r+=1;continue}if(t[r]==="?"){e.push("[^/]"),r+=1;continue}if(t[r]==="{"){e.push("(?:"),r+=1;continue}if(t[r]==="}"){e.push(")"),r+=1;continue}if(t[r]===","){e.push("|"),r+=1;continue}".^$+?()[]{}|\\".includes(t[r])?e.push("\\"+t[r]):e.push(t[r]),r+=1;}let n="^"+e.join("")+"$";return new RegExp(n)}var ly=f(()=>{s(sT,"globMatch");s(iy,"globFilter");s(ay,"expandBraces");s(iT,"matchOne");s(aT,"globToRegex");});function X(t,e,r,n={}){let o=[],{rules:i}=t;if(i.length===0)return [];if(i.some(l=>l.root)||o.push({level:"error",file:relative(e,i[0].source),message:"Rules exist but no root rule (_root.md or root: true). Add a root rule."}),n.checkGlobMatches===false)return o;for(let l of i){if(l.globs.length===0)continue;let c=false;for(let m of l.globs)if(iy(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 Nt=f(()=>{ly();s(X,"validateRules");});function my(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"amp"}))}var py=f(()=>{Nt();Ro();s(my,"lintRules");});function G(t,e,r){return {level:"warning",file:t,target:e,message:r}}function lT(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 Ms(t,e,r,n){let o=n?.unsupportedBy??e,i=lT(r);return G(".agentsmesh/hooks.yaml",e,`${t} is not supported by ${o}; only ${i} are projected.`)}var kt=f(()=>{s(G,"createWarning");s(lT,"formatOxfordComma");s(Ms,"createUnsupportedHookWarning");});function uy(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".agentsmesh/hooks.yaml","amp","Amp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function dy(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?[]:[G(".agentsmesh/permissions.yaml","amp","Amp permissions are managed via amp.permissions in settings.json; canonical permissions are not projected.")]}function fy(t){return t.ignore.length===0?[]:[G(".agentsmesh/ignore","amp","Amp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var gy=f(()=>{kt();s(uy,"lintHooks");s(dy,"lintPermissions");s(fy,"lintIgnore");});function L(t,e){return V(t).relative(t,e).replace(/\\/g,"/")}async function A(t,e){return T(V(t).join(t,e)).catch(()=>[])}function yy(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}function fT(t,e,r,n){let o=posix.dirname(e),i=posix.dirname(r);for(;o!==n&&o!==".";)yy(t,o,i),o=posix.dirname(o),i=posix.dirname(i);}function M(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,`${hy}/${u}/SKILL.md`);return}let[o,...i]=n.split("/"),a=i.join("/");if(!o||!a)return;let l=o.startsWith(bs)?bs:o.startsWith(Bi)?Bi:null;if(l&&a==="SKILL.md"){t.set(e,`${uT}/${o.slice(l.length)}.md`);return}let c=o.startsWith(xs)?xs:o.startsWith(zi)?zi:null;if(c&&a==="SKILL.md"){t.set(e,`${dT}/${o.slice(c.length)}.md`);return}let m=`${hy}/${o}`;a==="SKILL.md"&&yy(t,`${r}/${o}`,m);let p=`${m}/${a}`;t.set(e,p),a!=="SKILL.md"&&fT(t,e,p,`${r}/${o}`);}function gT(t){return t.split("/").filter(Boolean)[0]??""}async function hT(){if(dp!==void 0)return dp;let{BUILTIN_TARGETS:t}=await Promise.resolve().then(()=>(ct(),_y)),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=gT(n);o.startsWith(".")&&e.add(o);}return dp=e,e}function gp(t){return t.split("/").some(e=>e.startsWith("."))}async function yT(t){let e=[],r=await hT(),n=V(t);async function o(i){let a=n.join(t,i),l=await readdir(a,{withFileTypes:true}).catch(()=>[]);for(let c of l){let m=i?`${i}/${c.name}`:c.name;if(c.isDirectory()){if(r.has(c.name)||gp(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)||gp(m))continue;await o(m);continue}(c.name==="AGENTS.md"||c.name==="AGENTS.override.md")&&e.push(n.join(t,m));}}return s(o,"walk"),await o(""),e}async function Pl(t,e){let r=await yT(e);for(let n of r){let o=L(e,n),i=o.endsWith("/AGENTS.md")&&o!=="AGENTS.md"&&!o.endsWith("/AGENTS.override.md"),a=o.endsWith("/AGENTS.override.md")&&o!=="AGENTS.override.md";if(!i&&!a)continue;let l=posix.dirname(o);if(gp(l))continue;let c=l.replace(/\//g,"-");t.set(o,`${pT}/${c}.md`);}}var pT,uT,dT,hy,dp,bt=f(()=>{$t();w();Qt();at();pT=".agentsmesh/rules",uT=".agentsmesh/commands",dT=".agentsmesh/agents",hy=".agentsmesh/skills";s(L,"rel");s(A,"listFiles");s(yy,"addDirectoryMapping");s(fT,"addAncestorMappings");s(M,"addSimpleFileMapping");s(K,"addSkillLikeMapping");s(gT,"firstPathSegment");s(hT,"targetRootSegments");s(gp,"hasHiddenSegment");s(yT,"listScopedAgentsFiles");s(Pl,"addScopedAgentsMappings");});var x,Q,mt,Et=f(()=>{x=".agentsmesh/rules",Q=".agentsmesh/commands",mt=".agentsmesh/agents";});async function hp(t,e,r="project"){if(r==="global"){t.set(Vr,`${x}/_root.md`);for(let n of await A(e,Se))K(t,L(e,n),Se);t.set(Jr,".agentsmesh/mcp.json");return}t.set(Ie,`${x}/_root.md`);for(let n of await A(e,jt))K(t,L(e,n),jt);t.set(ur,".agentsmesh/mcp.json");}var Iy=f(()=>{bt();Ro();Et();s(hp,"buildAmpImportPaths");});var Oo,bl,dr,Ke,Zi,We,Zr,qi,fr,qr,Qi,$s,yp,ko,xl,Sy,Eo=f(()=>{Oo="antigravity",bl=".agents",dr=`${bl}/rules`,Ke=`${dr}/general.md`,Zi=`${dr}/_root.md`,We=`${bl}/skills`,Zr=`${bl}/workflows`,qi=`${bl}/antigravity/mcp_config.json`,fr=".gemini/antigravity/GEMINI.md",qr=".gemini/antigravity/skills",Qi=".gemini/antigravity/workflows",$s=".gemini/antigravity/mcp_config.json",yp=".agentsmesh/rules/_root.md",ko=".agentsmesh/rules",xl=".agentsmesh/commands",Sy=".agentsmesh/mcp.json";});async function _p(t,e,r="project"){if(r==="global"){t.set(fr,`${x}/_root.md`);for(let n of await A(e,qr))K(t,L(e,n),qr);t.set($s,".agentsmesh/mcp.json");return}t.set(Ke,`${x}/_root.md`),t.set(Zi,`${x}/_root.md`);for(let n of await A(e,dr)){let o=L(e,n);o===Ke||o===Zi||M(t,o,x,".md");}for(let n of await A(e,Zr))M(t,L(e,n),Q,".md");for(let n of await A(e,We))K(t,L(e,n),We);}var Cy=f(()=>{bt();Eo();Et();s(_p,"buildAntigravityImportPaths");});var Ry,Tn,Oy,ta,ea,ra,na,oa,Qr,Ip,sa,Gs,ia,aa,Tl,Nl,Sp,la,Cp,Lo,ky,tn=f(()=>{Ry="claude-code",Tn=".claude/CLAUDE.md",Oy="CLAUDE.md",ta=".claude/rules",ea=".claude/commands",ra=".claude/agents",na=".claude/skills",oa=".claude/settings.json",Qr=".claude/hooks.json",Ip=".claude/output-styles",sa=".claudeignore",Gs=".mcp.json",ia=".claude.json",aa=".agentsmesh/rules",Tl=".agentsmesh/commands",Nl=".agentsmesh/agents",Sp=".agentsmesh/skills",la=".agentsmesh/mcp.json",Cp=".agentsmesh/permissions.yaml",Lo=".agentsmesh/hooks.yaml",ky=".agentsmesh/ignore";});async function Rp(t,e,r="project"){if(t.set(".claude/CLAUDE.md",`${x}/_root.md`),t.set(Qr,Lo),r==="project"&&t.set("CLAUDE.md",`${x}/_root.md`),r==="global")for(let n of await A(e,".agents/skills"))K(t,L(e,n),".agents/skills");for(let n of await A(e,".claude/rules"))M(t,L(e,n),x,".md");for(let n of await A(e,".claude/commands"))M(t,L(e,n),Q,".md");for(let n of await A(e,".claude/agents"))M(t,L(e,n),mt,".md");for(let n of await A(e,".claude/skills"))K(t,L(e,n),".claude/skills");}var Ey=f(()=>{bt();tn();Et();s(Rp,"buildClaudeCodeImportPaths");});var Nn,en,Ao,rn,Ly,Dt,gr,Dn,wo,Po,bo,xo,Op,Fn,Dl,kp,Ep,Lp,Ay,Re=f(()=>{Nn="cline",en=".clinerules",Ao=".clineignore",rn=".cline/cline_mcp_settings.json",Ly=".cline/mcp_settings.json",Dt=".cline/skills",gr=".clinerules/workflows",Dn="AGENTS.md",wo=".clinerules/hooks",Po="Documents/Cline/Rules",bo="Documents/Cline/Workflows",xo="Documents/Cline/Hooks",Op=".agentsmesh/hooks.yaml",Fn=".agentsmesh/rules",Dl=".agentsmesh/commands",kp=".agentsmesh/ignore",Ep=".agentsmesh/mcp.json",Lp=".agentsmesh/agents",Ay=".agentsmesh/skills";});async function Ap(t,e,r="project"){if(r==="global"){for(let n of await A(e,Po))M(t,L(e,n),x,".md");for(let n of await A(e,bo))M(t,L(e,n),Q,".md");for(let n of await A(e,Dt))K(t,L(e,n),Dt);t.set(rn,".agentsmesh/mcp.json");return}t.set(".clinerules/_root.md",`${x}/_root.md`);for(let n of await A(e,".clinerules")){let o=L(e,n);!o.endsWith(".md")||o.includes("/workflows/")||basename(o)==="_root.md"||M(t,o,x,".md");}for(let n of await A(e,".clinerules/workflows"))M(t,L(e,n),Q,".md");for(let n of await A(e,".cline/skills"))K(t,L(e,n),".cline/skills");}var wy=f(()=>{bt();Re();Et();s(Ap,"buildClineImportPaths");});async function wp(t,e,r="project"){if(r==="global"?(t.set(".codex/AGENTS.md",`${x}/_root.md`),t.set(".codex/AGENTS.override.md",`${x}/_root.md`)):(t.set("AGENTS.md",`${x}/_root.md`),t.set("codex.md",`${x}/_root.md`),await Pl(t,e)),r==="project")for(let n of await A(e,".codex/instructions"))M(t,L(e,n),x,".md");for(let n of await A(e,".codex/rules")){let o=L(e,n);o.endsWith(".rules")?M(t,o,x,".rules"):o.endsWith(".md")&&M(t,o,x,".md");}for(let n of await A(e,".codex/agents"))M(t,L(e,n),mt,".toml");for(let n of await A(e,".agents/skills"))K(t,L(e,n),".agents/skills");}var Py=f(()=>{bt();Et();s(wp,"buildCodexCliImportPaths");});var js,Be,hr,Pp,Fl,nn,bp,ie,Us,ca,vl,Ml,xp,yr=f(()=>{js="continue",Be=".continue/rules",hr=".continue/prompts",Pp=".continue/mcpServers",Fl=`${Pp}/agentsmesh.json`,nn=`${Be}/general.md`,bp=`${Be}/_root.md`,ie=".continue/skills",Us=".continue/AGENTS.md",ca=".continue/config.yaml",vl=".agentsmesh/rules",Ml=".agentsmesh/commands",xp=".agentsmesh/mcp.json";});async function Tp(t,e,r="project"){t.set(nn,`${x}/_root.md`),t.set(bp,`${x}/_root.md`);for(let n of await A(e,".continue/rules")){let o=L(e,n);o===nn||o===bp||M(t,o,x,".md");}for(let n of await A(e,".continue/prompts"))t.set(L(e,n),`${Q}/${basename(n,".md")}.md`);for(let n of await A(e,".continue/skills"))K(t,L(e,n),".continue/skills");if(r==="global")for(let n of await A(e,".agents/skills"))K(t,L(e,n),".agents/skills");}var by=f(()=>{bt();yr();Et();s(Tp,"buildContinueImportPaths");});function ST(t,e){if(e.endsWith(".instructions.md")){t.set(e,`${x}/${basename(e,".instructions.md")}.md`);return}M(t,e,x,".md");}async function Np(t,e){t.set(".github/copilot-instructions.md",`${x}/_root.md`);for(let r of await A(e,".github/copilot"))t.set(L(e,r),`${x}/${basename(r,".instructions.md")}.md`);for(let r of await A(e,".github/instructions"))ST(t,L(e,r));for(let r of await A(e,".github/prompts"))t.set(L(e,r),`${Q}/${basename(r,".prompt.md")}.md`);for(let r of await A(e,".github/agents"))t.set(L(e,r),`${mt}/${basename(r,".agent.md")}.md`);for(let r of await A(e,".github/skills"))K(t,L(e,r),".github/skills");}var xy=f(()=>{bt();Et();s(ST,"addCopilotInstructionMapping");s(Np,"buildCopilotImportPaths");});var Ty,vn,Ny,Oe,on,ke,Ks,_r,Ir,Sr,Gl,ze,Dp,CT,Ws,He,ma,Mn,$n,Cr,Gn,jn,Dy,Bs,Fp,pa,vp,It=f(()=>{Ty="cursor",vn="AGENTS.md",Ny=".cursorrules",Oe=".cursor/rules",on=`${Oe}/general.mdc`,ke=".cursor/commands",Ks=".cursor/agents",_r=".cursor/skills",Ir=".cursor/mcp.json",Sr=".cursor/hooks.json",Gl=".cursor/settings.json",ze=".cursorignore",Dp=".cursorindexingignore",CT=".agentsmesh-exports/cursor",Ws=`${CT}/user-rules.md`,He=".cursor/AGENTS.md",ma=Ir,Mn=_r,$n=Ks,Cr=".agentsmesh/rules",Gn=".agentsmesh/commands",jn=".agentsmesh/agents",Dy=".agentsmesh/skills",Bs=".agentsmesh/mcp.json",Fp=".agentsmesh/permissions.yaml",pa=".agentsmesh/hooks.yaml",vp=".agentsmesh/ignore";});async function Mp(t,e,r="project"){if(r==="global"){t.set(Ir,".agentsmesh/mcp.json"),t.set(".cursor/AGENTS.md",`${x}/_root.md`);for(let n of await A(e,".cursor/rules"))M(t,L(e,n),x,".mdc");for(let n of await A(e,".cursor/commands"))M(t,L(e,n),Q,".md");for(let n of await A(e,".cursor/agents"))M(t,L(e,n),mt,".md");for(let n of await A(e,".cursor/skills"))K(t,L(e,n),".cursor/skills");return}t.set("AGENTS.md",`${x}/_root.md`);for(let n of await A(e,".cursor/rules"))M(t,L(e,n),x,".mdc");for(let n of await A(e,".cursor/commands"))M(t,L(e,n),Q,".md");for(let n of await A(e,".cursor/agents"))M(t,L(e,n),mt,".md");for(let n of await A(e,".cursor/skills"))K(t,L(e,n),".cursor/skills");}var Fy=f(()=>{bt();It();Et();s(Mp,"buildCursorImportPaths");});async function $p(t,e){for(let r of await A(e,".gemini/rules"))M(t,L(e,r),x,".md");for(let r of await A(e,".gemini/commands")){let n=L(e,r);if(!n.endsWith(".toml")&&!n.endsWith(".md"))continue;let o=n.replace(/\.(toml|md)$/i,""),i=".gemini/commands/",c=(o.startsWith(i)?o.slice(i.length):o).split("/").filter(Boolean).join(":");t.set(n,`${Q}/${c}.md`);}for(let r of await A(e,".gemini/agents"))M(t,L(e,r),mt,".md");for(let r of await A(e,".gemini/skills"))K(t,L(e,r),".gemini/skills");}var vy=f(()=>{bt();Et();s($p,"buildGeminiCliImportPaths");});var Rr,Ee,Vt,sn,My,an,To,Le,$y,Gy,zs=f(()=>{Rr="goose",Ee=".goosehints",Vt=".agents/skills",sn=".gooseignore",My=".config/goose",an=`${My}/.goosehints`,To=`${My}/.gooseignore`,Le=".agents/skills",$y=".agentsmesh/rules",Gy=".agentsmesh/ignore";});async function Gp(t,e,r="project"){if(r==="global"){t.set(an,`${x}/_root.md`);for(let n of await A(e,Le))K(t,L(e,n),Le);t.set(To,".agentsmesh/ignore");return}t.set(Ee,`${x}/_root.md`);for(let n of await A(e,Vt))K(t,L(e,n),Vt);t.set(sn,".agentsmesh/ignore");}var jy=f(()=>{bt();zs();Et();s(Gp,"buildGooseImportPaths");});var No,Un,jl,Uy,Or,Ky,RT,ua,Do,da,Hs,Vs,fa,ga,ha,ya,_a,OT,Ul,Fo,Wy,jp,Kl,By,zy,Hy,Vy,Js=f(()=>{No="junie",Un=".junie",jl=`${Un}/guidelines.md`,Uy=`${Un}/ci-guidelines.md`,Or=`${Un}/AGENTS.md`,Ky="AGENTS.md",RT=`${Un}/mcp`,ua=`${RT}/mcp.json`,Do=`${Un}/skills`,da=`${Un}/rules`,Hs=`${Un}/commands`,Vs=`${Un}/agents`,fa=".aiignore",ga=".junie",ha=`${ga}/skills`,ya=`${ga}/agents`,_a=`${ga}/commands`,OT=`${ga}/mcp`,Ul=`${OT}/mcp.json`,Fo=`${ga}/AGENTS.md`,Wy=".agents/skills",jp=".agentsmesh/rules/_root.md",Kl=".agentsmesh/rules",By=".agentsmesh/commands",zy=".agentsmesh/agents",Hy=".agentsmesh/mcp.json",Vy=".agentsmesh/ignore";});async function Up(t,e){t.set(jl,`${x}/_root.md`),t.set(Or,`${x}/_root.md`),t.set("AGENTS.md",`${x}/_root.md`);for(let r of await A(e,".junie/rules"))M(t,L(e,r),x,".md");for(let r of await A(e,".junie/commands"))M(t,L(e,r),Q,".md");for(let r of await A(e,".junie/agents"))M(t,L(e,r),mt,".md");for(let r of await A(e,".junie/skills"))K(t,L(e,r),".junie/skills");}var Jy=f(()=>{bt();Js();Et();s(Up,"buildJunieImportPaths");});var Jt,Ia,kr,ln,cn,mn,Ve,Kn,Ys,Wl,vo,Xs,Mo,Sa,Bl,Zs,Wn,$o,Go,jo,Bn,qs,zl,Yy,zn,Qs,Uo,Xy,Zy,Ko=f(()=>{Jt="kilo-code",Ia=".kilo",kr="AGENTS.md",ln=`${Ia}/rules`,cn=`${Ia}/commands`,mn=`${Ia}/agents`,Ve=`${Ia}/skills`,Kn=`${Ia}/mcp.json`,Ys=".kilocodeignore",Wl=".kilocode",vo=`${Wl}/rules`,Xs=`${Wl}/workflows`,Mo=`${Wl}/skills`,Sa=`${Wl}/mcp.json`,Bl=".kilocodemodes",Zs=".kilo",Wn=`${Zs}/AGENTS.md`,$o=`${Zs}/rules`,Go=`${Zs}/commands`,jo=`${Zs}/agents`,Bn=`${Zs}/skills`,qs=`${Zs}/mcp.json`,zl=".kilocodeignore",Yy=".agents/skills",zn=".agentsmesh/rules",Qs=".agentsmesh/commands",Uo=".agentsmesh/agents",Xy=".agentsmesh/mcp.json",Zy=".agentsmesh/ignore";});async function Kp(t,e,r="project"){if(r==="global"){t.set(Wn,`${x}/_root.md`);for(let n of await A(e,$o))M(t,L(e,n),x,".md");for(let n of await A(e,Go))M(t,L(e,n),Q,".md");for(let n of await A(e,jo))M(t,L(e,n),mt,".md");for(let n of await A(e,Bn))K(t,L(e,n),Bn);t.set(qs,".agentsmesh/mcp.json");return}t.set(kr,`${x}/_root.md`);for(let n of await A(e,ln))M(t,L(e,n),x,".md");for(let n of await A(e,cn))M(t,L(e,n),Q,".md");for(let n of await A(e,mn))M(t,L(e,n),mt,".md");for(let n of await A(e,Ve))K(t,L(e,n),Ve);t.set(Kn,".agentsmesh/mcp.json");for(let n of await A(e,vo)){let o=L(e,n);if(basename(o)==="00-root.md"){t.set(o,`${x}/_root.md`);continue}M(t,o,x,".md");}for(let n of await A(e,Xs))M(t,L(e,n),Q,".md");for(let n of await A(e,Mo))K(t,L(e,n),Mo);t.set(Sa,".agentsmesh/mcp.json");}var qy=f(()=>{bt();Ko();Et();s(Kp,"buildKiloCodeImportPaths");});var ae,Je,Ca,Ye,Yt,Xe,Hn,Qy,ti,ei,Wo,Ze,Vn,Bo,Ra,Oa,t_,Wp,Bp,e_,r_,zp,n_,ri=f(()=>{ae="kiro",Je="AGENTS.md",Ca=".kiro",Ye=`${Ca}/steering`,Yt=`${Ca}/skills`,Xe=`${Ca}/agents`,Hn=`${Ca}/hooks`,Qy=`${Ca}/settings`,ti=`${Qy}/mcp.json`,ei=".kiroignore",Wo=".kiro/steering",Ze=".kiro/steering/AGENTS.md",Vn=".kiro/skills",Bo=".kiro/agents",Ra=".kiro/settings/mcp.json",Oa=".kiro/settings/kiroignore",t_=".agents/skills",Wp=".agentsmesh/rules/_root.md",Bp=".agentsmesh/rules",e_=".agentsmesh/agents",r_=".agentsmesh/mcp.json",zp=".agentsmesh/hooks.yaml",n_=".agentsmesh/ignore";});async function Hp(t,e,r="project"){if(r==="global"){t.set(Ze,`${x}/_root.md`);for(let n of await A(e,Wo)){let o=L(e,n);o!==Ze&&M(t,o,x,".md");}for(let n of await A(e,Vn))K(t,L(e,n),Vn);for(let n of await A(e,Bo))M(t,L(e,n),mt,".md");return}t.set(Je,`${x}/_root.md`);for(let n of await A(e,Ye))M(t,L(e,n),x,".md");for(let n of await A(e,Yt))K(t,L(e,n),Yt);for(let n of await A(e,Xe))M(t,L(e,n),mt,".md");}var o_=f(()=>{bt();ri();Et();s(Hp,"buildKiroImportPaths");});var qe,Hl,Er,pn,un,dn,Qe,Lr,ni,Jn,zo,Ho,Vo,Yn,Xn,s_,ka,Vl,Jl,Vp,Jo=f(()=>{qe="opencode",Hl=".opencode",Er="AGENTS.md",pn=`${Hl}/rules`,un=`${Hl}/commands`,dn=`${Hl}/agents`,Qe=`${Hl}/skills`,Lr="opencode.json",ni=".config/opencode",Jn=`${ni}/AGENTS.md`,zo=`${ni}/rules`,Ho=`${ni}/commands`,Vo=`${ni}/agents`,Yn=`${ni}/skills`,Xn=`${ni}/opencode.json`,s_=".agents/skills",ka=".agentsmesh/rules",Vl=".agentsmesh/commands",Jl=".agentsmesh/agents",Vp=".agentsmesh/mcp.json";});async function Jp(t,e,r="project"){if(r==="global"){t.set(Jn,`${x}/_root.md`);for(let n of await A(e,zo))M(t,L(e,n),x,".md");for(let n of await A(e,Ho))M(t,L(e,n),Q,".md");for(let n of await A(e,Vo))M(t,L(e,n),mt,".md");for(let n of await A(e,Yn))K(t,L(e,n),Yn);t.set(Xn,".agentsmesh/mcp.json");return}t.set(Er,`${x}/_root.md`);for(let n of await A(e,pn))M(t,L(e,n),x,".md");for(let n of await A(e,un))M(t,L(e,n),Q,".md");for(let n of await A(e,dn))M(t,L(e,n),mt,".md");for(let n of await A(e,Qe))K(t,L(e,n),Qe);t.set(Lr,".agentsmesh/mcp.json");}var i_=f(()=>{bt();Jo();Et();s(Jp,"buildOpencodeImportPaths");});var Zn,Yo,tr,Ea,fn,gn,Ar,La,Aa,oi,wa,Yl,qn,Qn,hn,Xo,Pa,to,a_,Zo,Xl,l_,c_,qo=f(()=>{Zn="roo-code",Yo=".roo",tr=`${Yo}/rules/00-root.md`,Ea=".roorules",fn=`${Yo}/rules`,gn=`${Yo}/commands`,Ar=`${Yo}/skills`,La=`${Yo}/mcp.json`,Aa=".rooignore",oi=".roomodes",wa="settings/custom_modes.yaml",Yl=".roo",qn=`${Yl}/rules`,Qn=`${Yl}/commands`,hn=`${Yl}/skills`,Xo="mcp_settings.json",Pa=".rooignore",to=`${Yl}/AGENTS.md`,a_=".agents/skills",Zo=".agentsmesh/rules",Xl=".agentsmesh/commands",l_=".agentsmesh/mcp.json",c_=".agentsmesh/ignore";});async function Yp(t,e,r="project"){if(r==="global"){t.set(to,`${x}/_root.md`);for(let n of await A(e,qn))M(t,L(e,n),x,".md");for(let n of await A(e,Qn))M(t,L(e,n),Q,".md");for(let n of await A(e,hn))K(t,L(e,n),hn);t.set(Xo,".agentsmesh/mcp.json");return}t.set(tr,`${x}/_root.md`),t.set(Ea,`${x}/_root.md`);for(let n of await A(e,fn)){let o=L(e,n);o!==tr&&M(t,o,x,".md");}for(let n of await A(e,".roo")){let o=L(e,n);/^\.roo\/rules-[^/]+\/.+\.md$/.test(o)&&M(t,o,x,".md");}for(let n of await A(e,gn))M(t,L(e,n),Q,".md");for(let n of await A(e,Ar))K(t,L(e,n),Ar);}var m_=f(()=>{bt();qo();Et();s(Yp,"buildRooCodeImportPaths");});var wr,er,Xp,Wt,eo,ee,p_,si=f(()=>{wr="warp",er="AGENTS.md",Xp="WARP.md",Wt=".warp/skills",eo=".mcp.json",ee=".warp/skills",p_=".agentsmesh/rules";});async function Zp(t,e,r="project"){if(r==="global"){for(let n of await A(e,ee))K(t,L(e,n),ee);return}t.set(er,`${x}/_root.md`);for(let n of await A(e,Wt))K(t,L(e,n),Wt);t.set(eo,".agentsmesh/mcp.json");}var u_=f(()=>{bt();si();Et();s(Zp,"buildWarpImportPaths");});async function qp(t,e){t.set("AGENTS.md",`${x}/_root.md`),t.set(".windsurfrules",`${x}/_root.md`),await Pl(t,e);for(let r of await A(e,".windsurf/rules"))M(t,L(e,r),x,".md");for(let r of await A(e,".windsurf/workflows"))M(t,L(e,r),Q,".md");for(let r of await A(e,".windsurf/skills"))K(t,L(e,r),".windsurf/skills");}var d_=f(()=>{bt();Et();s(qp,"buildWindsurfImportPaths");});var rr,Pr,ET,br,f_,Qo=f(()=>{rr=".rules",Pr=".zed/settings.json",ET=".config/zed",br=`${ET}/settings.json`,f_=".agentsmesh/rules";});async function Qp(t,e,r="project"){if(r==="global"){t.set(br,".agentsmesh/mcp.json");return}t.set(rr,`${x}/_root.md`),t.set(Pr,".agentsmesh/mcp.json");}var g_=f(()=>{Qo();Et();s(Qp,"buildZedImportPaths");});var h_=f(()=>{Iy();Cy();Ey();wy();Py();by();xy();Fy();vy();jy();Jy();qy();o_();i_();m_();u_();d_();g_();});var Lt=f(()=>{h_();});function PT(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o["amp.mcpServers"]!==void 0&&(r["amp.mcpServers"]=o["amp.mcpServers"]),JSON.stringify(r,null,2)}var LT,AT,wT,y_,wl,up=f(()=>{Qt();at();Vh();se();sy();py();gy();Lt();Ro();LT={name:"amp",primaryRootInstructionPath:Ie,generateRules:Wh,generateCommands:zh,generateAgents:Hh,generateSkills:Bh,importFrom:oy},AT={rootInstructionPath:Ie,skillDir:jt,managedOutputs:{dirs:[jt],files:[Ie,ur]},paths:{rulePath(t){return Ie},commandPath(t){return `${jt}/${et(t)}/SKILL.md`},agentPath(t){return `${jt}/${H(t)}/SKILL.md`}}},wT={rootInstructionPath:Vr,skillDir:Se,managedOutputs:{dirs:[Se],files:[Vr,Jr]},rewriteGeneratedPath(t){return t===Ie?Vr:t===ur?Jr:t.startsWith(`${jt}/`)?t.replace(`${jt}/`,`${Se}/`):t},mirrorGlobalPath(t,e){return rt(t,Se,e)},paths:{rulePath(t){return Vr},commandPath(t){return `${Se}/${et(t)}/SKILL.md`},agentPath(t){return `${Se}/${H(t)}/SKILL.md`}}},y_={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(PT,"mergeAmpSettings");wl={id:"amp",generators:LT,capabilities:y_,emptyImportMessage:"No Amp config found (AGENTS.md, .agents/skills, or .amp/settings.json).",lintRules:my,lint:{hooks:uy,permissions:dy,ignore:fy},supportsConversion:{commands:true,agents:true},project:AT,globalSupport:{capabilities:y_,detectionPaths:[Vr,Jr],layout:wT},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ie],global:[Vr]},canonicalDir:Kh,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ur,content:JSON.stringify({"amp.mcpServers":t.mcp.mcpServers},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===ur||n===Jr?PT(t,r):null},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:hp,detectionPaths:[Ie,ur]};});function __(t){let e=t.rules.find(n=>n.root);if(!e)return [];let r=[{path:Ke,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:`${dr}/${o}.md`,content:n.body.trim()||""});}return r}function I_(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:`${Zr}/${e.name}.md`,content:o}})}function S_(t){return _t(t,We)}function C_(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:qi,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function R_(t){return t.agents.map(e=>({path:`${We}/${H(e.name)}/SKILL.md`,content:te(e)}))}function O_(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 Rt(e?.body.trim()??"",r)}var k_=f(()=>{ft();he();at();Eo();s(__,"generateRules");s(I_,"generateCommands");s(S_,"generateSkills");s(C_,"generateMcp");s(R_,"generateAgents");s(O_,"renderAntigravityGlobalInstructions");});function xT(t){let e=t.replace(/\\/g,"/");return !e.startsWith("rules/")||e.endsWith("/")||!e.endsWith(".md")?null:e}async function xr(t){let e=Nh(t.content),r=[];if(e.rules.length===0)return {rootContent:e.rootContent,results:r};await O(join(t.projectRoot,t.rulesDir));for(let n of e.rules){let o=xT(n.source);if(o===null||o==="rules/_root.md")continue;let i=join(t.projectRoot,".agentsmesh",o),a=t.normalize(n.body,t.sourcePath,i),{frontmatter:l,body:c}=E(a),m=await $(i,{...l,root:false,description:n.description||void 0,globs:n.globs.length>0?n.globs:void 0,targets:n.targets.length>0?n.targets:void 0},c);await S(i,m),r.push({fromTool:t.fromTool,fromPath:t.sourcePath,toPath:`.agentsmesh/${o}`,feature:"rules"});}return {rootContent:e.rootContent,results:r}}var ii=f(()=>{w();v();he();Z();s(xT,"canonicalRulePath");s(xr,"splitEmbeddedRulesToCanonical");});async function TT(t,e,r,n){let o=n==="global"?fr:Ke,i=n==="project"?[o,Zi]:[o];for(let a of i){let l=join(t,a),c=await y(l);if(c===null)continue;let m=join(t,yp),p=await xr({content:c,projectRoot:t,rulesDir:ko,sourcePath:l,fromTool:Oo,normalize:r});e.push(...p.results);let{body:u}=E(r(p.rootContent,l,m)),d=await $(m,{root:true},u);await O(join(t,ko)),await S(m,d),e.push({fromTool:Oo,fromPath:l,toPath:yp,feature:"rules"});return}}async function L_(t,e={}){let r=e.scope??"project",n=[],o=await B(Oo,t,r);return await TT(t,n,o,r),n.push(...await q(Zl,t,r,{normalize:o})),await dt(t,r==="global"?qr:We,Oo,n,o),n}var A_=f(()=>{gt();w();v();ft();Kt();Z();ii();Eo();eu();s(TT,"importRootRule");s(L_,"importFromAntigravity");});var b_,x_,T_=f(()=>{v();Z();Eo();b_=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(basename(t)==="general.md"||basename(t)==="_root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${ko}/${t}`,content:await $(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"nonRootRuleMapper"),x_=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${xl}/${t}`,content:await tt(n,{hasDescription:typeof o.description=="string",description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"workflowMapper");});function N_(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Oo}))}var D_=f(()=>{Nt();Eo();s(N_,"lintRules");});var NT,DT,FT,vT,Zl,eu=f(()=>{Co();at();k_();Eo();A_();T_();D_();Lt();NT={name:"antigravity",primaryRootInstructionPath:Ke,generateRules:__,generateCommands:I_,generateAgents:R_,generateSkills:S_,generateMcp:C_,importFrom:L_},DT={rootInstructionPath:Ke,skillDir:".agents/skills",rewriteGeneratedPath(t){return t===qi?null:t},paths:{rulePath(t,e){return `${dr}/${t}.md`},commandPath(t,e){return `${Zr}/${t}.md`},agentPath(t){return `${We}/${H(t)}/SKILL.md`}}},FT={rootInstructionPath:fr,renderPrimaryRootInstruction:O_,skillDir:qr,managedOutputs:{dirs:[qr,Qi],files:[fr,$s]},rewriteGeneratedPath(t){return t===Ke?fr:t.startsWith(`${dr}/`)?null:t.startsWith(".agents/skills/")?t.replace(".agents/skills",qr):t.startsWith(`${Zr}/`)?t.replace(Zr,Qi):t===qi?$s:t},paths:{rulePath(t,e){return fr},commandPath(t,e){return `${Qi}/${t}.md`},agentPath(t){return `${We}/${H(t)}/SKILL.md`}}},vT={rules:"native",additionalRules:"embedded",commands:$e("partial","workflows"),agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Zl={id:"antigravity",generators:NT,capabilities:{rules:"native",additionalRules:"native",commands:$e("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:N_,project:DT,globalSupport:{capabilities:vT,detectionPaths:[".gemini/antigravity/GEMINI.md",".gemini/antigravity/skills",".gemini/antigravity/workflows",".gemini/antigravity/mcp_config.json"],layout:FT},importer:{rules:{feature:"rules",mode:"directory",source:{project:[dr]},canonicalDir:ko,extensions:[".md"],map:b_},commands:{feature:"commands",mode:"directory",source:{project:[Zr],global:[Qi]},canonicalDir:xl,extensions:[".md"],map:x_},mcp:{feature:"mcp",mode:"flatFile",source:{global:[$s]},canonicalDir:".agentsmesh",canonicalFilename:Sy}},buildImportPaths:_p,detectionPaths:[".agents/rules/general.md",".agents/rules/",".agents/skills/",".agents/workflows/"]};});function F_(t){if(!t.hooks||Object.keys(t.hooks).length===0)return {};let e={};for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!lr(i))continue;let a=Ct(i),l=zt(i),c=i.type==="prompt"?l||a:a||l,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:c};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}var v_=f(()=>{Fe();s(F_,"buildClaudeHooksObjectFromCanonical");});function M_(t){let e=[],r=t.rules.find(o=>o.root);r&&e.push({path:Tn,content:r.body.trim()?r.body:""});let n=t.rules.filter(o=>!o.root&&(o.targets.length===0||o.targets.includes("claude-code")));for(let o of n){let i=basename(o.source,".md"),a={};o.description&&(a.description=o.description),o.globs.length>0&&(a.globs=o.globs);let l=N(a,o.body.trim()||"");e.push({path:`${ta}/${i}.md`,content:l});}return e}function $_(t){return t.commands.map(e=>{let r={description:e.description,"allowed-tools":e.allowedTools.length>0?e.allowedTools:void 0};r["allowed-tools"]===void 0&&delete r["allowed-tools"];let n=N(r,e.body.trim()||"");return {path:`${ea}/${e.name}.md`,content:n}})}function G_(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}`,
|
|
46
|
+
${n}`,i=N(r,o);return {path:`${ra}/${e.name}.md`,content:i}})}function j_(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Gs,content:e}]}function U_(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=r.body.trim()||"",i=!o||/^##\s*Purpose\b/m.test(o)?o:`## Purpose
|
|
47
47
|
|
|
48
|
-
${o}`,a=
|
|
49
|
-
`);return [{path:
|
|
48
|
+
${o}`,a=N(n,i);e.push({path:`${na}/${r.name}/SKILL.md`,content:a});for(let l of r.supportingFiles){let c=l.relativePath.replace(/\\/g,"/");e.push({path:`${na}/${r.name}/${c}`,content:l.content});}}return e}function K_(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:oa,content:o}]}function W_(t,e){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let r=F_(t);if(Object.keys(r).length===0)return [];if(e?.scope==="global")return [{path:Qr,content:JSON.stringify(r,null,2)}];let n=JSON.stringify({hooks:r},null,2);return [{path:oa,content:n}]}function B_(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
49
|
+
`);return [{path:sa,content:e}]}var z_=f(()=>{v();tn();v_();s(M_,"generateRules");s($_,"generateCommands");s(G_,"generateAgents");s(j_,"generateMcp");s(U_,"generateSkills");s(K_,"generatePermissions");s(W_,"generateHooks");s(B_,"generateIgnore");});function GT(t){let e=t.description.trim();return e||(basename(t.source)||"rule").replace(/\.md$/i,"")||"Rule"}function H_(t){let e=t.rules.find(o=>o.root),r=(e?.body??"").trim();return r?`# Global Instructions
|
|
50
50
|
|
|
51
|
-
## ${e?
|
|
51
|
+
## ${e?GT(e):"Guidance"}
|
|
52
52
|
|
|
53
53
|
${r}
|
|
54
|
-
`:""}var
|
|
54
|
+
`:""}var V_=f(()=>{s(GT,"ruleSectionTitle");s(H_,"renderClaudeGlobalPrimaryInstructions");});function Y_(t,e){return t===null?"created":t!==e?"updated":"unchanged"}async function X_(t,e,r,n){if(r!=="global")return [];let o=n.has("agents"),i=n.has("commands");if(!o&&!i)return [];let a=[];if(o)for(let l of t.agents){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=N(c,l.body.trim()),p=`${Ip}/${l.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:Y_(u,m)});}if(i)for(let l of t.commands){if(!l.outputStyle)continue;let c={name:l.name,description:l.description||void 0},m=N(c,l.body.trim()),p=`${Ip}/${l.name}.md`,u=await y(join(e,p));a.push({target:"claude-code",path:p,content:m,currentContent:u??void 0,status:Y_(u,m)});}return a}var Z_=f(()=>{w();v();tn();s(Y_,"computeStatus");s(X_,"generateClaudeGlobalExtras");});var q_,Q_,tI,eI=f(()=>{v();Z();je();tn();q_=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${aa}/${t}`,content:await $(n,{...o,root:false},i)}},"claudeRuleMapper"),Q_=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n)),a=Ce(o.allowedTools),l=a.length>0?a:Ce(o["allowed-tools"]);return {destPath:n,toPath:`${Tl}/${t}`,content:await tt(n,{description:typeof o.description=="string"?o.description:void 0,hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"claudeCommandMapper"),tI=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Nl}/${t}`,content:await Ot(n,o,i)}},"claudeAgentMapper");});function rI(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:Ry}))}var nI=f(()=>{Nt();tn();s(rI,"lintRules");});var jT,oI,UT,KT,ql,nu=f(()=>{z_();tn();se();V_();Z_();ou();eI();nI();Lt();jT={name:"claude-code",primaryRootInstructionPath:Tn,generateRules:M_,generateCommands:$_,generateAgents:G_,generateSkills:U_,generateMcp:j_,generatePermissions:K_,generateHooks:W_,generateIgnore:B_,importFrom:Ql},oI={rootInstructionPath:Tn,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`}}},UT={rootInstructionPath:Tn,skillDir:".claude/skills",renderPrimaryRootInstruction:H_,managedOutputs:{dirs:[".claude/agents",".claude/commands",".claude/rules",".claude/skills",".claude/output-styles",".agents/skills"],files:[".claude/CLAUDE.md",".claude/settings.json",ia,Qr,".claudeignore"]},rewriteGeneratedPath(t){return t===Gs?ia:t},mirrorGlobalPath(t,e){return rt(t,".claude/skills",e)},paths:oI.paths},KT={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"native"},ql={id:"claude-code",generators:jT,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:rI,project:oI,globalSupport:{capabilities:KT,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:UT,scopeExtras:X_},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Tn,Oy],global:[Tn]},canonicalDir:aa,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[ta],global:[ta]},canonicalDir:aa,extensions:[".md"],map:q_}],commands:{feature:"commands",mode:"directory",source:{project:[ea],global:[ea]},canonicalDir:Tl,extensions:[".md"],map:Q_},agents:{feature:"agents",mode:"directory",source:{project:[ra],global:[ra]},canonicalDir:Nl,extensions:[".md"],map:tI},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Gs],global:[ia]},canonicalDir:".agentsmesh",canonicalFilename:la},ignore:{feature:"ignore",mode:"flatFile",source:{project:[sa],global:[sa]},canonicalDir:".agentsmesh",canonicalFilename:ky}},buildImportPaths:Rp,detectionPaths:["CLAUDE.md",".claude/rules",".claude/commands"]};});function BT(t){let e=basename(t,".md");return e==="_root"?"root":e}function sI(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n=r.body.trim()?r.body:"";e.push({path:Dn,content:n});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("cline"))continue;let o=BT(n.source),i={description:n.description||void 0,paths:n.globs.length>0?n.globs:void 0};Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l];});let a=Object.keys(i).length>0?N(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${en}/${o}.md`,content:a});}return e}function iI(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:`${gr}/${e.name}.md`,content:o}})}function aI(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
57
|
+
`);return [{path:Ao,content:e}]}function lI(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:rn,content:e}]}function cI(t){return t.agents.map(e=>({path:`${Dt}/${H(e.name)}/SKILL.md`,content:te(e)}))}function zT(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function HT(t,e,r){return ["#!/usr/bin/env bash",`# agentsmesh-event: ${t}`,`# agentsmesh-matcher: ${r}`,`# agentsmesh-command: ${e}`,"set -e",e,""].join(`
|
|
58
|
+
`)}function mI(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.hooks)){if(!Array.isArray(n))continue;let o=0;for(let i of n)zr(i)&&(e.push({path:`${wo}/${zT(r)}-${o}.sh`,content:HT(r,i.command,i.matcher)}),o++);}return e}function pI(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=N(n,r.body.trim()||"");e.push({path:`${Dt}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Dt}/${r.name}/${a}`,content:i.content});}}return e}var uI=f(()=>{Fe();v();at();Re();s(BT,"ruleSlug");s(sI,"generateRules");s(iI,"generateCommands");s(aI,"generateIgnore");s(lI,"generateMcp");s(cI,"generateAgents");s(zT,"safeEventName");s(HT,"buildHookScript");s(mI,"generateHooks");s(pI,"generateSkills");});async function fI(t,e,r){if(t==="workflows"||t.startsWith("workflows/"))return null;let n=t.replace(/\\/g,"/");if(n==="_root.md")return null;let o=join(e,n),{frontmatter:i,body:a}=E(r(o)),l=Xr(i.paths??i.globs),c={root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${Fn}/${n}`,feature:"rules",content:await $(o,c,a)}}async function gI(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=E(r(n)),a=Object.prototype.hasOwnProperty.call(o,"description"),l=a&&typeof o.description=="string"?o.description:"",c=a,m=i;if(!c){let p=i.indexOf(`
|
|
59
59
|
|
|
60
|
-
`);if(p>0){let u=
|
|
61
|
-
`)&&(l=u,c=true,m=
|
|
62
|
-
`)),e.push({fromTool:"cline",fromPath:o,toPath:
|
|
60
|
+
`);if(p>0){let u=i.slice(0,p).trim();u&&!u.includes(`
|
|
61
|
+
`)&&(l=u,c=true,m=i.slice(p+2));}}return {destPath:n,toPath:`${Dl}/${t}`,feature:"commands",content:await tt(n,{description:l,hasDescription:c,allowedTools:[],hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},m)}}var su=f(()=>{v();Z();je();Re();s(fI,"mapClineRuleFile");s(gI,"mapClineWorkflowFile");});async function hI(t,e,r){let n=join(t,Fn),o=join(t,en),i=join(t,en),a=false;try{a=(await stat(i)).isFile();}catch{}if(a){let p=await y(i);if(p!==null){await O(n);let u=join(n,"_root.md"),{frontmatter:d,body:g}=E(r(p,i,u)),C=d.root===true?d:{...d,root:true},R=await $(u,C,g);await S(u,R),e.push({fromTool:"cline",fromPath:i,toPath:`${Fn}/_root.md`,feature:"rules"});}return a}let l=null,c=join(o,"_root.md"),m=await y(c);if(m===null){let p=join(t,Dn),u=await y(p);if(u!==null){l=p,await O(n);let d=join(n,"_root.md"),{frontmatter:g,body:h}=E(r(u,p,d)),R=g.root===true?g:{...g,root:true},I=await $(d,R,h);await S(d,I),e.push({fromTool:"cline",fromPath:p,toPath:`${Fn}/_root.md`,feature:"rules"});}else {let h=(await T(o)).filter(C=>C.endsWith(".md")&&!C.includes("/workflows/")).sort()[0];if(h){let C=await y(h);if(C!==null){l=h,await O(n);let R=join(n,"_root.md"),{frontmatter:I,body:k}=E(r(C,h,R)),P=I.root===true?I:{...I,root:true},b=await $(R,P,k);await S(R,b),e.push({fromTool:"cline",fromPath:h,toPath:`${Fn}/_root.md`,feature:"rules"});}}}}else {l=c,await O(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 $(p,h,d);await S(p,C),e.push({fromTool:"cline",fromPath:c,toPath:`${Fn}/_root.md`,feature:"rules"});}return e.push(...await nt({srcDir:o,destDir:n,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(async({srcPath:p,relativePath:u,normalizeTo:d})=>p===l?null:fI(u,n,d),"mapEntry")})),a}var yI=f(()=>{w();v();Z();Ue();su();Re();s(hI,"importClineRules");});function JT(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let n=typeof e.type=="string"?e.type:typeof e.transportType=="string"?e.transportType:"stdio",o=Array.isArray(e.args)?e.args.filter(c=>typeof c=="string"):[],i=e.env,a=i!==null&&typeof i=="object"&&!Array.isArray(i)?Object.fromEntries(Object.entries(i).filter(c=>typeof c[1]=="string")):{},l=typeof e.description=="string"?e.description:void 0;return {...l!==void 0&&{description:l},type:n,command:r,args:o,env:a}}async function _I(t,e){let r=[rn,Ly].map(c=>join(t,c)),n=null,o=null;for(let c of r){let m=await y(c);if(m!==null){n=c,o=m;break}}if(o===null)return;let i=n??r[0],a;try{a=JSON.parse(o);}catch{}let l=a?.mcpServers;if(l!==void 0&&typeof l=="object"&&l!==null&&Object.keys(l).length>0){let c={};for(let[m,p]of Object.entries(l)){let u=JT(p);u&&(c[m]=u);}Object.keys(c).length>0&&(await O(join(t,".agentsmesh")),await S(join(t,Ep),JSON.stringify({mcpServers:c},null,2)),e.push({fromTool:Nn,fromPath:i,toPath:Ep,feature:"mcp"}));}}var II=f(()=>{w();Re();s(JT,"mapClineServerToCanonical");s(_I,"importClineMcp");});function SI(t){return YT.some(e=>e.test(t))}var YT,CI=f(()=>{YT=[/^\./,/^_ab-agent-/,/^_ab-command-/,/\.fixture\./,/\.test\./];s(SI,"isReservedArtifactName");});async function ZT(t){let e=await T(t).catch(()=>[]),r=[];for(let n of e){let o=relative(t,n).replace(/\\/g,"/"),i=basename(o);if(SI(i))continue;let a=await y(n);a!==null&&r.push({absolutePath:n,relativePath:o,content:a});}return r}async function Tr(t,e,r){let n=await ZT(e),o=join(r.projectRoot,r.destCanonicalSkillsDir,t);for(let i of n){let a=join(o,i.relativePath);await O(dirname(a));let l=r.normalize(i.content,i.absolutePath,a);if(i.relativePath==="SKILL.md"){let{frontmatter:c,body:m}=E(l),p=await pr(a,{...c,name:t},m);await S(a,p);}else await S(a,l);r.results.push({fromTool:r.targetName,fromPath:i.absolutePath,toPath:`${r.destCanonicalSkillsDir}/${t}/${i.relativePath}`,feature:"skills"});}}async function OI(t,e,r,n){let o=join(n.projectRoot,n.destCanonicalSkillsDir,t);await O(o);let i=join(o,"SKILL.md"),a=n.normalize(r,e,i),{frontmatter:l,body:c}=E(a),m=await pr(i,{...l,name:t},c);await S(i,m),n.results.push({fromTool:n.targetName,fromPath:e,toPath:`${n.destCanonicalSkillsDir}/${t}/SKILL.md`,feature:"skills"});}async function ro(t){let e=new Map;try{let n=(await T(t)).filter(o=>basename(o)==="SKILL.md");for(let o of n){let i=dirname(o),a=basename(i);e.set(a,i);}}catch{}return e}var ai=f(()=>{w();v();Z();CI();s(ZT,"readNativeSkill");s(Tr,"importDirectorySkill");s(OI,"importFlatSkill");s(ro,"findDirectorySkills");});async function kI(t,e,r,n=Dt){let o=join(t,n),i=await ro(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:Ay,targetName:"cline",normalize:r,results:e};for(let[l,c]of i){let m=join(c,"SKILL.md"),p=await y(m);if(!p)continue;let u=E(p),d=mr(u.frontmatter,l);if(d){let g=join(t,Lp);await O(g);let h=join(g,`${d.name}.md`);await S(h,ge(d,r(u.body,m,h))),e.push({fromTool:"cline",fromPath:m,toPath:`${Lp}/${d.name}.md`,feature:"agents"});continue}await Tr(l,c,a);}}var EI=f(()=>{w();v();at();ai();Re();s(kI,"importClineSkills");});function lu(t,e){return t.match(new RegExp(`^# agentsmesh-${e}:\\s*(.+)$`,"m"))?.[1]?.trim()??null}async function LI(t,e){let n=(await T(t).catch(()=>[])).filter(o=>basename(o).endsWith(".sh")&&dirname(o)===t);for(let o of n){let i=await y(o);if(!i)continue;let a=lu(i,"event"),l=lu(i,"command");if(!a||!l)continue;let c=lu(i,"matcher")??"*";e[a]||(e[a]=[]),e[a].push({matcher:c,command:l});}}async function wI(t,e){let r={};if(await LI(join(t,wo),r),await LI(join(t,xo),r),Object.keys(r).length===0)return;let n=join(t,Op);await O(dirname(n)),await S(n,stringify(r)),e.push({fromTool:Nn,fromPath:join(t,xo),toPath:Op,feature:"hooks"});}var PI=f(()=>{w();Re();s(lu,"extractMeta");s(LI,"loadHooksFromDir");s(wI,"importClineHooks");});async function nc(t){let e=[],r=await B(Nn,t),n=await hI(t,e,r),o=join(t,Ao),i=await y(o);if(i!==null&&i.trim()){let l=i.split(/\r?\n/),c=[];for(let m of l){let p=m.trim();p&&!p.startsWith("#")&&c.push(p);}if(c.length>0){await O(join(t,".agentsmesh"));let m=join(t,kp);await S(m,c.join(`
|
|
62
|
+
`)),e.push({fromTool:"cline",fromPath:o,toPath:kp,feature:"ignore"});}}await _I(t,e);let a=join(t,Dl);return n||e.push(...await nt({srcDir:join(t,gr),destDir:a,extensions:[".md"],fromTool:"cline",normalize:r,mapEntry:s(({relativePath:l,normalizeTo:c})=>gI(l,a,c),"mapEntry")})),await kI(t,e,r),await wI(t,e),e}var cu=f(()=>{gt();w();Ue();su();yI();Re();II();EI();PI();s(nc,"importFromCline");});function bI(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:Nn}))}var xI=f(()=>{Nt();Re();s(bI,"lintRules");});function TI(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>G(e.source,"cline","cline workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function NI(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".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 DI=f(()=>{kt();s(TI,"lintCommands");s(NI,"lintHooks");});var tN,eN,rN,nN,FI,vI=f(()=>{uI();Co();Re();cu();xI();DI();Lt();Ps();at();tN={name:"cline",primaryRootInstructionPath:Dn,generateRules:sI,generateCommands:iI,generateAgents:cI,generateSkills:pI,generateMcp:lI,generateHooks:mI,generateIgnore:aI,importFrom:nc},eN={rootInstructionPath:Dn,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 `${en}/${t}.md`},commandPath(t,e){return `${gr}/${t}.md`},agentPath(t,e){return fe(e,"cline")?`.cline/skills/${H(t)}/SKILL.md`:null}}},rN={skillDir:Dt,managedOutputs:{dirs:[Po,bo,xo,Dt,".agents/skills"],files:[rn,Ao]},rewriteGeneratedPath(t){return t===Dn?null:t.startsWith(`${wo}/`)?`${xo}/${t.slice(wo.length+1)}`:t.startsWith(`${gr}/`)?`${bo}/${t.slice(gr.length+1)}`:t.startsWith(`${en}/`)?`${Po}/${t.slice(en.length+1)}`:t},mirrorGlobalPath(t,e){return t.startsWith(`${Dt}/`)?`.agents/skills/${t.slice(Dt.length+1)}`:null},paths:{rulePath(t,e){return `${Po}/${t}.md`},commandPath(t,e){return `${bo}/${t}.md`},agentPath(t,e){return fe(e,"cline")?`.cline/skills/${H(t)}/SKILL.md`:null}}},nN={rules:"native",additionalRules:"native",commands:$e("native","workflows"),agents:"embedded",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},FI={id:"cline",generators:tN,capabilities:{rules:"native",additionalRules:"native",commands:$e("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:bI,lint:{commands:TI,hooks:NI},project:eN,globalSupport:{capabilities:nN,detectionPaths:[Po,bo,xo,Dt,rn,Ao],layout:rN},buildImportPaths:Ap,detectionPaths:[".clinerules",".cline"]};});var Ft,MI,_n,ts,$I,nr,GI,oc,es,Nr,rs,In,mu,li,xa,pu,jI,uu,UI,KI,du,fu,gu,Bt=f(()=>{Ft="codex-cli",MI="codex.md",_n="AGENTS.md",ts=".codex/AGENTS.md",$I=".codex/AGENTS.override.md",nr=".agents/skills",GI=".codex/skills",oc=".codex/config.toml",es=".codex/instructions",Nr=".codex/rules",rs=".codex/agents",In=".agentsmesh/rules",mu=".agentsmesh/commands",li=".agentsmesh/agents",xa=".agentsmesh/skills",pu=".agentsmesh/mcp.json",jI="am-codex-rule:v1",uu="# am-json: ",UI="# am-body-b64-begin",KI="# am-body-b64-end",du="# am64:",fu="<!-- agentsmesh:codex-rule-index:start -->",gu="<!-- agentsmesh:codex-rule-index:end -->";});function hu(t){return basename(t,".md")}function Ta(t){return `${es}/${hu(t.source)}.md`}function WI(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];}),N(e,t.body.trim()||"")}function sN(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 \`${Nr}/${hu(t.source)}.rules\`.`),t.targets.length>0&&e.push(`Targeted to ${t.targets.map(r=>`\`${r}\``).join(", ")}.`),e.join(" ")}function BI(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||hu(a.source)}](${Ta(a)}): ${sN(a)}`),i=[fu,"## Additional Rule Files",...o,gu].join(`
|
|
63
63
|
`);return r?`${r}
|
|
64
64
|
|
|
65
|
-
${
|
|
66
|
-
`).trim()}var
|
|
65
|
+
${i}`:i}function zI(t){let e=fu.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=gu.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return t.replace(new RegExp(`\\n?${e}[\\s\\S]*?${r}\\n?`,"g"),`
|
|
66
|
+
`).trim()}var sc=f(()=>{v();Bt();s(hu,"ruleSlug");s(Ta,"codexInstructionMirrorPath");s(WI,"serializeCodexInstructionMirror");s(sN,"summarizeRule");s(BI,"appendCodexRuleIndex");s(zI,"stripCodexRuleIndex");});function aN(t){return /(^|\n)\s*[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(t)}function lN(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 cN(t){let e=t.trim();return e?aN(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.","#",...lN(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 yu(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:_n,content:BI(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:`${Nr}/${o}.rules`,content:cN(n.body)}),r.push({path:Ta(n),content:WI(n)}));}return r}function _u(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 Rt(e?.body.trim()??"",r)}var HI=f(()=>{he();Bt();sc();s(aN,"looksLikeCodexRulesDsl");s(lN,"toCodexRulesComments");s(cN,"toSafeCodexRulesContent");s(yu,"generateRules");s(_u,"renderCodexGlobalInstructions");});function Iu(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=N(n,r.body.trim()||"");e.push({path:`${nr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${nr}/${r.name}/${a}`,content:i.content});}}return e}function mN(t){return {path:`${nr}/${et(t.name)}/SKILL.md`,content:cr(t)}}function Su(t){return t.commands.map(mN)}var VI=f(()=>{v();Bt();Qt();s(Iu,"generateSkills");s(mN,"commandToSkillOutput");s(Su,"generateCommands");});function Cu(t){return t.agents.map(e=>({path:`${rs}/${e.name}.toml`,content:pN(e)}))}function pN(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 JI=f(()=>{Bt();s(Cu,"generateAgents");s(pN,"serializeAgentToCodexToml");});function ic(t){return "command"in t}function YI(t){return "url"in t}var ac=f(()=>{s(ic,"isStdioMcpServer");s(YI,"isUrlMcpServer");});function Ru(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=Object.fromEntries(Object.entries(t.mcp.mcpServers).flatMap(([n,o])=>ic(o)?[[n,o]]:[]));if(Object.keys(e).length===0)return [];let r=uN(e);return [{path:oc,content:r}]}function uN(t){let e=[];for(let[r,n]of Object.entries(t)){let o=XI(r)?`"${r}"`:r,i=[];i.push(`[mcp_servers.${o}]`),i.push(`command = ${JSON.stringify(n.command)}`);let a="["+n.args.map(c=>JSON.stringify(c)).join(", ")+"]";i.push(`args = ${a}`);let l=Object.entries(n.env);if(l.length>0){let c=l.map(([m,p])=>`${XI(m)?JSON.stringify(m):m} = ${JSON.stringify(p)}`).join(", ");i.push(`env = { ${c} }`);}e.push(i.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 XI(t){return !/^[A-Za-z0-9_-]+$/.test(t)}var ZI=f(()=>{ac();Bt();s(Ru,"generateMcp");s(uN,"serializeMcpToToml");s(XI,"needsTomlQuoting");});var qI=f(()=>{HI();VI();JI();ZI();});var QI=f(()=>{qI();});function gN(t){if(!t||typeof t!="object"||Array.isArray(t))return null;let e=t,r=typeof e.command=="string"?e.command:"";if(!r)return null;let n=Array.isArray(e.args)?e.args.filter(a=>typeof a=="string"):[],o=e.env,i=o!==null&&typeof o=="object"&&!Array.isArray(o)?Object.fromEntries(Object.entries(o).filter(a=>typeof a[1]=="string")):{};return {type:"stdio",command:r,args:n,env:i}}async function tS(t,e){let r=join(t,oc),n=await y(r);if(n===null)return;let o;try{o=parse$1(n);}catch{return}let i=o.mcp_servers;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).length===0)return;let a={};for(let[l,c]of Object.entries(i)){let m=gN(c);m&&(a[l]=m);}Object.keys(a).length!==0&&(await Ut(t,pu,a),e.push({fromTool:Ft,fromPath:r,toPath:pu,feature:"mcp"}));}var eS=f(()=>{w();Yr();Bt();s(gN,"mapTomlServerToCanonical");s(tS,"importMcp");});async function rS(t,e,r){let n={projectRoot:t,sourceSkillsDir:nr,destCanonicalSkillsDir:xa,targetName:Ft,normalize:r,results:e};for(let o of [nr,GI]){let i=join(t,o),a=await readdir(i,{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(i,c.name),p=join(m,"SKILL.md"),u=await y(p);if(!u)continue;l=true;let d=c.name,g=join(t,xa,d,"SKILL.md"),h=r(u,p,g),{frontmatter:C,body:R}=E(h),I=Rl(C,c.name);if(I){await ye(join(t,xa,d));let D=join(t,mu);await O(D);let P=join(D,`${I.name}.md`);await S(P,Ol(I,r(R,p,P))),e.push({fromTool:Ft,fromPath:p,toPath:`${mu}/${I.name}.md`,feature:"commands"});continue}let k=mr(C,c.name);if(k){await ye(join(t,xa,d));let D=join(t,li);await O(D);let P=join(D,`${k.name}.md`);await S(P,ge(k,r(R,p,P))),e.push({fromTool:Ft,fromPath:p,toPath:`${li}/${k.name}.md`,feature:"agents"});continue}await Tr(d,m,n);}if(l)return}}var nS=f(()=>{w();v();Qt();at();Ds();ai();Bt();s(rS,"importSkills");});async function oS(t,e,r){let n=join(t,rs),o=join(t,li);try{let a=(await T(n)).filter(l=>l.endsWith(".toml"));for(let l of a){let c=await y(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":"",R=Array.isArray(m.mcp_servers)?m.mcp_servers.filter(b=>typeof b=="string"):[];await O(o);let I=join(o,`${p}.md`),k=r(d,l,I),P=ge({name:p,description:u,tools:[],disallowedTools:[],model:g,permissionMode:C,maxTurns:0,mcpServers:R,hooks:{},skills:[],memory:""},k);await S(I,P),e.push({fromTool:Ft,fromPath:l,toPath:`${li}/${p}.md`,feature:"agents"});}}catch{}}var sS=f(()=>{w();at();Bt();s(oS,"importCodexAgentsFromToml");});function iS(t){if(!t.includes(jI))return null;let e=t.split(`
|
|
83
|
+
`).find(c=>c.startsWith(uu));if(!e)return null;let r;try{r=JSON.parse(e.slice(uu.length));}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=typeof n.description=="string"?n.description:"",i=Array.isArray(n.globs)?n.globs.filter(c=>typeof c=="string"):[],a=[],l=false;for(let c of t.split(`
|
|
84
|
+
`)){let m=c.trimEnd();if(m===UI){l=true;continue}if(m===KI){l=false;continue}l&&m.startsWith(du)&&a.push(m.slice(du.length));}if(a.length===0)return null;try{let c=Buffer.from(a.join(""),"base64").toString("utf8");return {meta:{description:o,globs:i},body:c}}catch{return null}}var aS=f(()=>{Bt();s(iS,"tryParseEmbeddedCanonicalFromCodexRules");});async function cS(t,e,r){let n=[],o=join(t,Nr);try{let i=await T(o),a=i.filter(c=>c.endsWith(".md"));for(let c of a){let m=await y(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 O(e);let h=d.root===!0?d:{...d,root:!1},C=await $(u,h,g);await S(u,C),n.push({fromTool:Ft,fromPath:c,toPath:`${In}/${p}`,feature:"rules"});}let l=i.filter(c=>c.endsWith(".rules"));for(let c of l){let m=await y(c);if(!m)continue;let p=relative(o,c).replace(/\\/g,"/").replace(/\.rules$/i,".md"),u=join(e,p);await O(e);let d=iS(m);if(d){let g=await $(u,{description:d.meta.description,globs:d.meta.globs,root:!1},r(d.body,c,u));await S(u,g);}else {let g=await $(u,{root:!1,description:"",globs:[],codex_emit:"execution"},r(m.trim(),c,u));await S(u,g);}n.push({fromTool:Ft,fromPath:c,toPath:`${In}/${p}`,feature:"rules"});}}catch{}return n}var mS=f(()=>{w();v();Z();Bt();aS();s(cS,"importCodexNonRootRuleFiles");});async function uS(t,e,r,n,o){let i=join(t,MI),a=join(t,_n),l=join(t,$I),c=join(t,ts),m=o==="global"?await y(l):null,p=o==="global"?await y(c):null,u=o==="project"?await y(a):null,d=o==="project"?await y(i):null,g=m!==null?l:p!==null?c:u!==null?a:i,h=join(t,In),C=m??p??u??d;if(C!==null){await O(h);let R=join(h,"_root.md"),I=g===a||g===c||g===l?zI(C):C,k=await xr({content:I,projectRoot:t,rulesDir:In,sourcePath:g,fromTool:"codex-cli",normalize:r});e.push(...k.results);let D=r(g===a||g===c||g===l?n(k.rootContent,g,R):k.rootContent,g,R),{frontmatter:P,body:b}=E(D),Y=P.root===true?P:{...P,root:true},U=await $(R,Y,b);await S(R,U),e.push({fromTool:"codex-cli",fromPath:g,toPath:`${In}/_root.md`,feature:"rules"});}await RN(t,h,e,r),e.push(...await cS(t,h,r)),o!=="global"&&e.push(...await nt({srcDir:t,destDir:h,extensions:["AGENTS.md","AGENTS.override.md"],fromTool:"codex-cli",normalize:r,mapEntry:s(async({srcPath:R,normalizeTo:I})=>{let k=relative(t,dirname(R)).replace(/\\/g,"/"),D=basename(R),P=D==="AGENTS.override.md";if(!k||k==="."||!P&&D!=="AGENTS.md")return null;let b=k.replace(/\//g,"-");if(!Al(k))return await ye(join(h,`${b}.md`)),null;let Y=join(h,`${b}.md`),{frontmatter:U,body:z}=E(I(Y));return {destPath:Y,toPath:`${In}/${b}.md`,feature:"rules",content:await $(Y,{...U,root:false,globs:[`${k}/**`],...P?{codex_instruction:"override"}:{}},z)}},"mapEntry")}));}async function RN(t,e,r,n){try{let i=(await T(join(t,es))).filter(l=>l.endsWith(".md")),a=join(t,es);for(let l of i){let c=relative(a,l).replace(/\\/g,"/");if(c==="_root.md")continue;let m=await y(l);if(!m)continue;let p=join(e,c),{frontmatter:u,body:d}=E(n(m,l,p));await O(e);let g=u.root===!0?u:{...u,root:!1},h=await $(p,g,d);await S(p,h),r.push({fromTool:Ft,fromPath:l,toPath:`${In}/${c}`,feature:"rules"});}}catch{}}var dS=f(()=>{w();v();Z();ii();Ue();Ds();Bt();mS();sc();s(uS,"importCodexRules");s(RN,"importInstructionMirrors");});async function lc(t,e){let r=e?.scope??"project",n=[],o=await B(Ft,t,r),i=await B("windsurf",t,r);return await uS(t,n,o,i,r),await rS(t,n,o),await oS(t,n,o),await tS(t,n),n}var Eu=f(()=>{gt();Bt();eS();nS();sS();dS();s(lc,"importFromCodex");});function fS(t,e,r){let{rules:n}=t;return n.length===0?[]:n.some(i=>i.root)?[]:[{level:"warning",file:relative(e,n[0].source),target:Ft,message:"Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."}]}var gS=f(()=>{Bt();s(fS,"lintRules");});function hS(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(G(".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(G(".agentsmesh/mcp.json","codex-cli",`MCP server "${r}" uses ${o} transport; codex-cli only generates stdio MCP servers.`));}return e}var yS=f(()=>{kt();s(hS,"lintMcp");});function _S(t){return Ta(t)}var IS=f(()=>{sc();s(_S,"codexAdvisoryInstructionPath");});var kN,EN,LN,AN,CS,RS=f(()=>{QI();Bt();Eu();gS();yS();Lt();Ps();IS();Qt();kN={name:"codex-cli",primaryRootInstructionPath:_n,generateRules:yu,generateCommands:Su,generateAgents:Cu,generateSkills:Iu,generateMcp:Ru,importFrom:lc},EN={rootInstructionPath:_n,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 _S(e)},commandPath(t,e){return ws(e,"codex-cli")?`${nr}/${et(t)}/SKILL.md`:null},agentPath(t,e){return `${rs}/${t}.toml`}}},LN={rootInstructionPath:ts,renderPrimaryRootInstruction:_u,extraRuleOutputPaths(t){if(t.root||t.codexEmit!=="execution")return [];let e=basename(t.source,".md");return [`${Nr}/${e}.rules`]},skillDir:nr,managedOutputs:{dirs:[".agents/skills",".codex/agents",".codex/rules"],files:[ts,".codex/config.toml"]},rewriteGeneratedPath(t){return t===_n?ts:t.startsWith(`${es}/`)?null:t},paths:{rulePath(t,e){return e.codexEmit==="execution"?`${Nr}/${t}.rules`:ts},commandPath(t,e){return ws(e,"codex-cli")?`${nr}/${et(t)}/SKILL.md`:null},agentPath(t,e){return `${rs}/${t}.toml`}}},AN={rules:"native",additionalRules:"embedded",commands:"embedded",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},CS={id:"codex-cli",generators:kN,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:fS,lint:{mcp:hS},project:EN,globalSupport:{capabilities:AN,detectionPaths:[".codex/AGENTS.md",".codex/AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules",".agents/skills"],layout:LN},buildImportPaths:wp,sharedArtifacts:{".agents/skills/":"owner"},detectionPaths:["codex.md","AGENTS.md","AGENTS.override.md",".codex/config.toml",".codex/agents",".codex/rules"]};});function PN(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 OS(t){return `${hr}/${t}.md`}function kS(t){let e={description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],N(e,t.body.trim()||"")}function ES(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:PN(t["x-agentsmesh-allowed-tools"])}}function LS(t,e){let r={description:t.description||void 0,"allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return r.description===void 0&&delete r.description,r["allowed-tools"]===void 0&&delete r["allowed-tools"],N(r,e.trim()||"")}var cc=f(()=>{v();yr();s(PN,"toStringArray");s(OS,"continueCommandRulePath");s(kS,"serializeCommandRule");s(ES,"parseCommandRuleFrontmatter");s(LS,"serializeImportedCommand");});function AS(t){let e=[],r=t.rules.find(n=>n.root);if(r){let n={};r.description&&(n.description=r.description),e.push({path:nn,content:N(n,r.body.trim()||"")});}for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("continue"))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs),e.push({path:`${Be}/${o}.md`,content:N(i,n.body.trim()||"")});}return e}function wS(t){return t.commands.map(e=>({path:`${hr}/${e.name}.md`,content:kS(e)}))}function PS(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Fl,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function bS(t){return t.agents.map(e=>({path:`${ie}/${H(e.name)}/SKILL.md`,content:te(e)}))}function xS(t){return _t(t,ie)}var TS=f(()=>{ft();at();v();cc();yr();s(AS,"generateRules");s(wS,"generateCommands");s(PS,"generateMcp");s(bS,"generateAgents");s(xS,"generateSkills");});function NN(t,e){let n=(e===".json"?JSON.parse(t):parse(t)??{}).mcpServers;if(!n||typeof n!="object"||Array.isArray(n))return {};let o={};for(let[i,a]of Object.entries(n)){if(!a||typeof a!="object"||Array.isArray(a))continue;let l=a;typeof l.command=="string"&&(o[i]={type:typeof l.type=="string"?l.type:"stdio",command:l.command,args:Fs(l.args),env:vs(l.env),description:typeof l.description=="string"?l.description:void 0});}return o}async function DN(t,e){let r=(await T(join(t,Pp))).filter(i=>[".json",".yaml",".yml"].includes(extname(i))),n={},o=[];for(let i of r){let a=await y(i);a&&(Object.assign(n,NN(a,extname(i))),o.push(i));}if(Object.keys(n).length!==0){await Ut(t,xp,n);for(let i of o)e.push({fromTool:js,fromPath:i,toPath:xp,feature:"mcp"});}}async function mc(t){let e=[],r=await B(js,t);return e.push(...await q(pc,t,"project",{normalize:r})),await dt(t,ie,js,e,r),await DN(t,e),e}var Lu=f(()=>{gt();w();ft();Kt();Yr();je();yr();Au();s(NN,"readMcpServers");s(DN,"importMcp");s(mc,"importFromContinue");});function FN(t){return t==="general.md"||t==="_root.md"}var DS,FS,vS=f(()=>{v();Z();cc();yr();s(FN,"isContinueRootRulePath");DS=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=FN(t),o=n?"_root.md":t,i=join(r,o),{frontmatter:a,body:l}=E(e(i)),c={description:typeof a.description=="string"?a.description:void 0,globs:Array.isArray(a.globs)?a.globs:void 0,root:n};return c.description===void 0&&delete c.description,c.globs===void 0&&delete c.globs,{destPath:i,toPath:`${vl}/${o}`,content:await $(i,c,l)}},"continueRuleMapper"),FS=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=join(n,e),{frontmatter:i,body:a}=E(r(o)),l=ES(i,t),c=l.name||e.replace(/\.md$/,"").replace(/^.*\//,""),m=e.includes("/")?e.slice(0,e.lastIndexOf("/")):"",p=m?`${m}/${c}.md`:`${c}.md`,u=join(n,p),d=await tt(u,{description:l.description,hasDescription:!!l.description,allowedTools:l.allowedTools,hasAllowedTools:l.allowedTools.length>0},E(LS(l,a)).body);return {destPath:u,toPath:`${Ml}/${p}`,content:d}},"continueCommandMapper");});function MS(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:js}))}var $S=f(()=>{Nt();yr();s(MS,"lintRules");});function GS(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>G(e.source,"continue","Continue invokable prompt rules do not natively enforce canonical allowed-tools metadata."))}var jS=f(()=>{kt();s(GS,"lintCommands");});function GN(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var US,KS=f(()=>{w();yr();s(GN,"computeStatus");US=s(async(t,e,r,n)=>{if(r!=="global")return [];let o=n.has("rules"),i=n.has("commands"),a=n.has("mcp");if(!(o&&t.rules.length>0||i&&t.commands.length>0||a&&t.mcp!==null&&Object.keys(t.mcp.mcpServers).length>0))return [];let c={name:"agentsmesh",version:1,schema:"v1"};if(o&&t.rules.length>0&&(c.rules=t.rules.map(u=>({name:u.description||basename(u.source,".md"),rule:u.body.trim()}))),i&&t.commands.length>0&&(c.prompts=t.commands.map(u=>{let 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 y(join(e,ca));return [{target:"continue",path:ca,content:m,currentContent:p??void 0,status:GN(p,m)}]},"generateContinueGlobalConfig");});function UN(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var WS,BS=f(()=>{w();yr();KS();s(UN,"computeStatus");WS=s(async(t,e,r,n)=>{let o=await US(t,e,r,n);if(r!=="global"||!n.has("rules"))return o;let i=t.rules.find(c=>c.root);if(!i)return o;let a=i.body.trim(),l=await y(join(e,Us));return [...o,{target:"continue",path:Us,content:a,currentContent:l??void 0,status:UN(l,a)}]},"generateContinueScopeExtras");});var KN,WN,BN,zN,pc,Au=f(()=>{at();TS();yr();Lu();vS();$S();jS();cc();Lt();BS();KN={name:"continue",primaryRootInstructionPath:nn,generateRules:AS,generateCommands:wS,generateAgents:bS,generateSkills:xS,generateMcp:PS,importFrom:mc},WN={rootInstructionPath:nn,skillDir:".continue/skills",managedOutputs:{dirs:[".continue/prompts",".continue/rules",".continue/skills"],files:[".continue/mcpServers/agentsmesh.json"]},paths:{rulePath(t,e){return `${Be}/${t}.md`},commandPath(t,e){return OS(t)},agentPath(t){return `${ie}/${H(t)}/SKILL.md`}}},BN={rootInstructionPath:nn,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Us]}],skillDir:ie,managedOutputs:{dirs:[Be,hr,ie,".agents/skills"],files:[Fl,Us,ca]},mirrorGlobalPath(t,e){return t.startsWith(`${ie}/`)?`.agents/skills/${t.slice(ie.length+1)}`:null},paths:{rulePath(t,e){return `${Be}/${t}.md`},commandPath(t,e){return `${hr}/${t}.md`},agentPath(t){return `${ie}/${H(t)}/SKILL.md`}}},zN={rules:"native",additionalRules:"native",commands:"native",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},pc={id:"continue",generators:KN,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:MS,lint:{commands:GS},project:WN,globalSupport:{capabilities:zN,detectionPaths:[Be,hr,".continue/mcpServers",ie],layout:BN,scopeExtras:WS},importer:{rules:{feature:"rules",mode:"directory",source:{project:[Be],global:[Be]},canonicalDir:vl,extensions:[".md"],map:DS},commands:{feature:"commands",mode:"directory",source:{project:[hr],global:[hr]},canonicalDir:Ml,extensions:[".md"],map:FS}},buildImportPaths:Tp,detectionPaths:[".continue/rules",".continue/skills",".continue/mcpServers"]};});var Sn,ns,zS,os,no,Fr,vr,ss,is,uc,dc,HS,Pu,VS,oo,ci,Cn,mi,as,bu,xu,Ae=f(()=>{Sn="copilot",ns=".github/copilot-instructions.md",zS=".github/copilot",os=".github/instructions",no=".github/prompts",Fr=".github/hooks",vr=".github/skills",ss=".github/agents",is=".agentsmesh/rules",uc=".agentsmesh/commands",dc=".agentsmesh/agents",HS=".agentsmesh/skills",Pu=".agentsmesh/hooks.yaml",VS=".github/copilot-hooks",oo=".copilot/copilot-instructions.md",ci=".copilot/agents",Cn=".copilot/skills",mi=".copilot/prompts",as=".copilot/AGENTS.md",bu=".claude/skills",xu=".agents/skills";});function JS(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 fc(t){return `${no}/${t}.prompt.md`}function YS(t){let e={agent:"agent",description:t.description||void 0,"x-agentsmesh-kind":"command","x-agentsmesh-name":t.name,"x-agentsmesh-allowed-tools":t.allowedTools.length>0?t.allowedTools:void 0};return e.description===void 0&&delete e.description,e["x-agentsmesh-allowed-tools"]===void 0&&delete e["x-agentsmesh-allowed-tools"],N(e,t.body.trim()||"")}function XS(t,e){let n=((typeof t["x-agentsmesh-name"]=="string"?t["x-agentsmesh-name"]:"")||basename(e,".prompt.md")).trim(),o=JS(t["x-agentsmesh-allowed-tools"]),i=o.length>0?o:JS(t.tools);return {name:n,description:typeof t.description=="string"?t.description:"",allowedTools:i}}var gc=f(()=>{v();Ae();s(JS,"toStringArray");s(fc,"commandPromptPath");s(YS,"serializeCommandPrompt");s(XS,"parseCommandPromptFrontmatter");});function hc(t){return zr(t)}var Tu=f(()=>{Fe();s(hc,"hasHookCommand");});function JN(t){let e=basename(t,".md");return e==="_root"?"root":e}function YN(t){switch(t){case "PreToolUse":return "preToolUse";case "PostToolUse":return "postToolUse";case "Notification":return "notification";case "UserPromptSubmit":return "userPromptSubmitted";default:return null}}function ZS(t){let e=[],r=t.rules.find(n=>n.root);r?.body.trim()&&e.push(r.body.trim());for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("copilot"))continue;let o=n.body.trim();if(!o)continue;let i=n.description?`## ${n.description}`:null;i?e.push(`${i}
|
|
85
85
|
|
|
86
86
|
${o}`):e.push(o);}return e.join(`
|
|
87
87
|
|
|
88
|
-
`)}function
|
|
89
|
-
`)}async function
|
|
88
|
+
`)}function qS(t){let e=t.rules.find(n=>n.root),r=[];e&&r.push({path:ns,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=JN(n.source),i={description:n.description||void 0,applyTo:n.globs.length===1?n.globs[0]:n.globs};Object.keys(i).forEach(l=>{i[l]===void 0&&delete i[l];});let a=N(i,n.body.trim()||"");r.push({path:`${os}/${o}.instructions.md`,content:a});}return r}function QS(t){return t.commands.map(e=>({path:fc(e.name),content:YS(e)}))}function tC(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=N(n,r.body.trim()||"");e.push({path:`${vr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${vr}/${r.name}/${a}`,content:i.content});}}return e}function eC(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=N(r,e.body.trim()||"");return {path:`${ss}/${e.name}.agent.md`,content:n}})}function rC(t){if(!t.hooks)return [];let e=Object.fromEntries(Object.entries(t.hooks).flatMap(([r,n])=>{let o=YN(r);if(!o||!Array.isArray(n))return [];let i=n.filter(a=>typeof a=="object"&&a!==null&&hc(a)).map((a,l)=>{let m={type:"command",bash:`./scripts/${r.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}-${l}.sh`,comment:`Matcher: ${a.matcher}`};return a.timeout!==void 0&&(m.timeoutSec=Math.ceil(a.timeout/1e3)),m});return i.length>0?[[o,i]]:[]}));return Object.keys(e).length===0?[]:[{path:`${Fr}/agentsmesh.json`,content:JSON.stringify({version:1,hooks:e},null,2)}]}var nC=f(()=>{v();Ae();gc();Tu();s(JN,"ruleSlug");s(YN,"mapHookEvent");s(ZS,"renderCopilotGlobalInstructions");s(qS,"generateRules");s(QS,"generateCommands");s(tC,"generateSkills");s(eC,"generateAgents");s(rC,"generateHooks");});function ZN(t){switch(t){case "preToolUse":return "PreToolUse";case "postToolUse":return "PostToolUse";case "notification":return "Notification";case "userPromptSubmitted":return "UserPromptSubmit";default:return null}}function qN(t){return typeof t!="string"?"*":t.match(/^Matcher:\s*(.+)$/)?.[1]?.trim()||"*"}function iC(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 aC(t,e){let r=join(t,Fr),o=(await T(r).catch(()=>[])).filter(p=>p.endsWith(".json")),i={};for(let p of o){let u=await y(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=ZN(g);if(!(!C||!Array.isArray(h)))for(let R of h){if(!R||typeof R!="object")continue;let I=R,k=typeof I.bash=="string"?I.bash:"";if(!k)continue;let D=join(r,k.replace(/^\.\//,"")),P=await y(D);if(!P)continue;let b=iC(P);b&&(i[C]||(i[C]=[]),i[C].push({matcher:qN(I.comment),command:b,type:"command"}));}}}let a=join(t,VS),c=(await T(a).catch(()=>[])).filter(p=>dirname(p)===a&&/^[^-]+-\d+\.sh$/i.test(basename(p)));for(let p of c){let u=await y(p);if(!u)continue;let d=basename(p,".sh"),g=d.lastIndexOf("-"),h=g>0?d.slice(0,g):d;i[h]||(i[h]=[]),i[h].push({matcher:"*",command:iC(u),type:"command"});}if(Object.keys(i).length===0)return;let m=join(t,Pu);await O(dirname(m)),await S(m,stringify(i)),e.push({fromTool:Sn,fromPath:join(t,Fr),toPath:Pu,feature:"hooks"});}var lC=f(()=>{w();Ae();s(ZN,"mapCopilotHookEvent");s(qN,"extractMatcher");s(iC,"extractWrapperCommand");s(aC,"importHooks");});async function cC(t,e,r,n=vr){let o=join(t,n),i=await ro(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:HS,targetName:Sn,normalize:r,results:e};for(let[l,c]of i)await Tr(l,c,a);}var mC=f(()=>{ai();Ae();s(cC,"importSkills");});async function yc(t,e={}){let r=e.scope??"project",n=[],o=await B(Sn,t,r);return n.push(...await q(_c,t,r,{normalize:o})),await cC(t,n,o,r==="global"?Cn:vr),r==="project"&&await aC(t,n),n}var Nu=f(()=>{gt();Kt();Ae();lC();mC();Du();s(yc,"importFromCopilot");});function pC(t){for(let e of Object.keys(t))t[e]===void 0&&delete t[e];return t}var uC,dC,fC,gC,hC=f(()=>{v();Z();je();gc();Ae();s(pC,"pruneUndefined");uC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.replace(/\.instructions\.md$/i,".md"),o=join(r,n),{frontmatter:i,body:a}=E(e(o)),l=Xr(i.globs),c=pC({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${is}/${n}`,content:await $(o,c,a)}},"copilotLegacyRuleMapper"),dC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=t.endsWith(".instructions.md")?t.replace(/\.instructions\.md$/i,".md"):t,o=join(r,n),{frontmatter:i,body:a}=E(e(o)),l=Xr(i.applyTo!==void 0?i.applyTo:i.globs),c=pC({root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0});return {destPath:o,toPath:`${is}/${n}`,content:await $(o,c,a)}},"copilotNewRuleMapper"),fC=s(async({absolutePath:t,relativePath:e,normalizeTo:r,destDir:n})=>{let o=e.replace(/\.prompt\.md$/i,".md"),i=join(n,o),{frontmatter:a,body:l}=E(r(i)),c=XS(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:`${uc}/${u}`,content:await tt(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"),gC=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(!t.endsWith(".agent.md"))return null;let n=t.replace(/\.agent\.md$/i,".md"),o=basename(n,".md"),i=join(r,n),{frontmatter:a,body:l}=E(e(i));return {destPath:i,toPath:`${dc}/${n}`,content:await Ot(i,{...a,name:typeof a.name=="string"?a.name:o},l)}},"copilotAgentMapper");});function yC(t,e,r,n){let i=X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(l=>({...l,target:Sn})),a=t.rules.filter(l=>!l.root&&l.globs.length===0);return [...i,...a.map(l=>({level:"warning",file:l.source,target:Sn,message:"Copilot path-specific instructions require applyTo globs; non-root rules without globs are not generated."}))]}var _C=f(()=>{Nt();Ae();s(yC,"lintRules");});function IC(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>G(e.source,"copilot","Copilot prompt files do not enforce canonical allowed-tools natively."))}function SC(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=["PreToolUse","PostToolUse","Notification","UserPromptSubmit"],r=new Set(e),n=Object.keys(t.hooks).filter(i=>!r.has(i)).map(i=>Ms(i,"copilot",e,{unsupportedBy:"Copilot hooks"}));return Object.values(t.hooks).some(i=>Array.isArray(i)&&i.length>0)&&n.push(G(".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 CC=f(()=>{kt();s(IC,"lintCommands");s(SC,"lintHooks");});function nD(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function oD(t,e){let r=relative(t,e).replace(/\\/g,"/");return !r||r.startsWith("../")?null:r}function sD(t,e){let r=t.match(RC);if(!r?.groups)return t;let n=r.groups.prefix??"",o=r.groups.suffix??"";return `${n}"$HOOK_DIR/${e}"${o}`}async function iD(t,e){let n=e.match(RC)?.groups?.path;if(!n)return null;let o=join(t,n),i=await y(o);if(i===null)return null;let a=oD(t,o);return a?{assetPath:`${Fr}/scripts/${a}`,content:i,rewrittenCommand:sD(e,a)}:null}function aD(t,e){return `${Fr}/scripts/${nD(t)}-${e}.sh`}function lD(t,e){return ["#!/usr/bin/env bash",`# agentsmesh-matcher: ${e}`,`# agentsmesh-command: ${t}`,"set -e",t,""].join(`
|
|
89
|
+
`)}async function OC(t,e,r){if(!e.hooks)return r;let n=[],o=new Map;for(let[i,a]of Object.entries(e.hooks)){if(!Array.isArray(a))continue;let l=0;for(let c of a){if(!hc(c))continue;let m=aD(i,l),p=c.command,u=await iD(t,c.command);u&&(p=u.rewrittenCommand,o.has(u.assetPath)||o.set(u.assetPath,{path:u.assetPath,content:u.content}));let d=lD(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 RC,kC=f(()=>{w();Ae();Tu();RC=/^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;s(nD,"safePhaseName");s(oD,"toRepoRelative");s(sD,"rewriteWrapperCommand");s(iD,"buildAssetOutput");s(aD,"wrapperPath");s(lD,"buildWrapper");s(OC,"addHookScriptAssets");});function mD(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var EC,LC=f(()=>{w();Ae();s(mD,"computeStatus");EC=s(async(t,e,r,n)=>{if(r!=="global"||!n.has("rules"))return [];let o=t.rules.find(l=>l.root);if(!o)return [];let i=o.body.trim(),a=await y(join(e,as));return [{target:"copilot",path:as,content:i,currentContent:a??void 0,status:mD(a,i)}]},"generateCopilotGlobalExtras");});var uD,dD,fD,gD,_c,Du=f(()=>{nC();Ae();Nu();hC();_C();Lt();gc();CC();kC();LC();uD={name:"copilot",primaryRootInstructionPath:ns,generateRules:qS,generateCommands:QS,generateAgents:eC,generateSkills:tC,generateHooks:rC,importFrom:yc},dD={rootInstructionPath:ns,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 [`${os}/${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 `${os}/${t}.instructions.md`},commandPath(t,e){return fc(t)},agentPath(t,e){return `${ss}/${t}.agent.md`}}},fD={rootInstructionPath:oo,renderPrimaryRootInstruction:ZS,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[as]}],skillDir:Cn,managedOutputs:{dirs:[ci,Cn,mi,xu,bu],files:[oo,as]},rewriteGeneratedPath(t){return t===ns?oo:t.startsWith(`${os}/`)?oo:t.startsWith(`${no}/`)?t.replace(`${no}/`,`${mi}/`):t.startsWith(`${ss}/`)?t.replace(`${ss}/`,`${ci}/`):t.startsWith(`${vr}/`)?t.replace(`${vr}/`,`${Cn}/`):t.startsWith(`${Fr}/`)?null:t},mirrorGlobalPath(t,e){if(t.startsWith(`${Cn}/`)&&!e.includes("codex-cli")){let r=t.slice(Cn.length+1);return [`.agents/skills/${r}`,`${bu}/${r}`]}return null},paths:{rulePath(t,e){return oo},commandPath(t,e){return `${mi}/${t}.prompt.md`},agentPath(t,e){return `${ci}/${t}.agent.md`}}},gD={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},_c={id:"copilot",generators:uD,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:yC,lint:{commands:IC,hooks:SC},postProcessHookOutputs:s(async(t,e,r)=>OC(t,e,[...r]),"postProcessHookOutputs"),project:dD,globalSupport:{capabilities:gD,detectionPaths:[oo,as,ci,Cn,mi,xu],layout:fD,scopeExtras:EC},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[ns],global:[oo]},canonicalDir:is,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[zS]},canonicalDir:is,extensions:[".instructions.md"],map:uC},{feature:"rules",mode:"directory",source:{project:[os]},canonicalDir:is,extensions:[".instructions.md",".md"],map:dC}],commands:{feature:"commands",mode:"directory",source:{project:[no],global:[mi]},canonicalDir:uc,extensions:[".prompt.md"],map:fC},agents:{feature:"agents",mode:"directory",source:{project:[ss],global:[ci]},canonicalDir:dc,extensions:[".agent.md"],map:gC}},buildImportPaths:Np,detectionPaths:[".github/copilot-instructions.md",".github/copilot",".github/instructions",".github/prompts",".github/skills",".github/agents",".github/hooks"]};});function Fu(t){let e=[],r=t.rules.find(i=>i.root);if(r){let i=r.body.trim()?r.body:"";e.push({path:vn,content:i});let a={alwaysApply:true};r.description&&(a.description=r.description);let l=N(a,i);e.push({path:on,content:l});}let n=t.rules.filter(i=>!i.root&&(i.targets.length===0||i.targets.includes("cursor")));for(let i of n){let a=basename(i.source,".md"),c={alwaysApply:i.trigger==="always_on"};i.description&&(c.description=i.description),i.globs.length>0&&(c.globs=i.globs);let m=N(c,i.body.trim()||"");e.push({path:`${Oe}/${a}.mdc`,content:m});}let o=AC(t);return o.trim()&&e.push({path:He,content:o}),e}function AC(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(Rt(e.body,r)):r.length>0&&n.push(Rt("",r)),n.filter(Boolean).join(`
|
|
93
93
|
|
|
94
|
-
`)}var
|
|
95
|
-
`);return [{path:
|
|
94
|
+
`)}var wC=f(()=>{v();he();It();s(Fu,"generateRules");s(AC,"renderCursorGlobalUserRules");});function vu(t){return t.commands.map(e=>({path:`${ke}/${e.name}.md`,content:e.body.trim()||""}))}var PC=f(()=>{It();s(vu,"generateCommands");});function Mu(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:Ir,content:e}]}var bC=f(()=>{It();s(Mu,"generateMcp");});function $u(t){let e=[];for(let r of t.skills){let n={name:r.name,description:r.description||void 0};n.description===void 0&&delete n.description;let o=N(n,r.body.trim()||"");e.push({path:`${_r}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${_r}/${r.name}/${a}`,content:i.content});}}return e}var xC=f(()=>{v();It();s($u,"generateSkills");});function Gu(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=N(r,e.body.trim()||"");return {path:`${Ks}/${e.name}.md`,content:n}})}var TC=f(()=>{v();It();s(Gu,"generateAgents");});function ju(t){return []}var NC=f(()=>{s(ju,"generatePermissions");});function yD(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!lr(i))continue;let a=Ct(i),l=zt(i),c=i.type==="prompt"?l||a:a||l,m={type:i.type==="prompt"?"prompt":"command",[i.type==="prompt"?"prompt":"command"]:c};i.timeout!==void 0&&(m.timeout=i.timeout),o.push({matcher:i.matcher,hooks:[m]});}o.length>0&&(e[r]=o);}return e}function Uu(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=yD(t.hooks);if(Object.keys(e).length===0)return [];let r=JSON.stringify({version:1,hooks:e},null,2);return [{path:Sr,content:r}]}var DC=f(()=>{Fe();It();s(yD,"toCursorHooks");s(Uu,"generateHooks");});function Ku(t){if(!t.ignore||t.ignore.length===0)return [];let e=t.ignore.join(`
|
|
95
|
+
`);return [{path:ze,content:e}]}var FC=f(()=>{It();s(Ku,"generateIgnore");});var vC=f(()=>{wC();PC();bC();xC();TC();NC();DC();FC();});var MC=f(()=>{vC();});async function Sc(t,e,r,n){let o=t.replace(/\.mdc$/i,".md"),i=join(e,o),l=E(r(i)).frontmatter.alwaysApply===true,c=l?join(e,"_root.md"):i,{frontmatter:m,body:p}=E(r(c));l&&n();let u={...m,root:l};if(delete u.alwaysApply,!l){let d=_D(m);d!==null&&(u.trigger=d);}return {destPath:c,toPath:`${Cr}/${l?"_root.md":o}`,feature:"rules",content:await $(c,u,p)}}function _D(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 $C(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=E(r(n)),a=Ce(o.allowedTools),l=a.length>0?a:Ce(o["allowed-tools"]);return {destPath:n,toPath:`${Gn}/${t}`,feature:"commands",content:await tt(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}}async function GC(t,e,r){let n=join(e,t),{frontmatter:o,body:i}=E(r(n));return {destPath:n,toPath:`${jn}/${t}`,feature:"agents",content:await Ot(n,o,i)}}var Wu=f(()=>{v();Z();je();It();s(Sc,"mapCursorRuleFile");s(_D,"deriveCursorTrigger");s($C,"mapCursorCommandFile");s(GC,"mapCursorAgentFile");});async function pi(t){let e=join(t.projectRoot,Cr);await O(e);let r=join(e,"_root.md"),n=await xr({content:t.content,projectRoot:t.projectRoot,rulesDir:Cr,sourcePath:t.sourcePath,fromTool:"cursor",normalize:t.normalize});t.results.push(...n.results);let o=t.normalize(n.rootContent,t.sourcePath,r);if(!o.trim()&&n.results.length>0)return true;let{frontmatter:i,body:a}=E(o),l=i.root===true?i:{...i,root:true},c=await $(r,l,a);return await S(r,c),t.results.push({fromTool:"cursor",fromPath:t.sourcePath,toPath:`${Cr}/_root.md`,feature:"rules"}),true}var Bu=f(()=>{w();v();ii();Z();It();s(pi,"importCursorRootFile");});async function UC(t,e,r){let n=join(t,Cr),o=false,i=join(t,Oe);if(e.push(...await nt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:"cursor",normalize:r,mapEntry:s(async({srcPath:a,relativePath:l,normalizeTo:c})=>{if(o){let m=await y(a);if(m!==null){let{frontmatter:p}=E(m);if(p.alwaysApply===true)return null}}return Sc(l,n,c,()=>{o=true;})},"mapEntry")})),!o){let a=join(t,vn),l=await y(a);l!==null&&(o=await pi({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r}));}if(!o){let a=join(t,Ny),l=await y(a);l!==null&&await pi({projectRoot:t,results:e,sourcePath:a,content:l,normalize:r});}}var KC=f(()=>{w();v();Ue();Wu();Bu();It();s(UC,"importCursorRules");});function WC(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!lr({...m,type:p}))continue;let u=p==="prompt"?zt(m)||Ct(m):Ct(m)||zt(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 Oc(t,e){let r=false,n=join(t,Sr),o=await y(n);if(o)try{let p=JSON.parse(o);if(p.hooks&&typeof p.hooks=="object"){let u=WC(p.hooks);if(Object.keys(u).length>0){let d=stringify(u),g=join(t,pa);await O(dirname(g)),await S(g,d),e.push({fromTool:"cursor",fromPath:n,toPath:pa,feature:"hooks"}),r=!0;}}}catch{}let i=join(t,Gl),a=await y(i);if(!a)return;let l;try{l=JSON.parse(a);}catch{return}let c=l.permissions;if(c&&typeof c=="object"&&!Array.isArray(c)){let p=c,u=Array.isArray(p.allow)?p.allow.filter(g=>typeof g=="string"):[],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,Fp);await O(dirname(h)),await S(h,g),e.push({fromTool:"cursor",fromPath:i,toPath:Fp,feature:"permissions"});}}let m=r?void 0:l.hooks;if(m&&typeof m=="object"&&!Array.isArray(m)){let p=WC(m);if(Object.keys(p).length>0){let u=stringify(p),d=join(t,pa);await O(dirname(d)),await S(d,u),e.push({fromTool:"cursor",fromPath:i,toPath:pa,feature:"hooks"});}}}async function kc(t,e){let r=[{path:join(t,ze),label:ze},{path:join(t,Dp),label:Dp}],n=[],o=[];for(let a of r){let l=await y(a.path);if(l!==null){o.push(a.label);for(let c of l.split(/\r?\n/)){let m=c.trim();m&&!n.includes(m)&&n.push(m);}}}if(n.length===0)return;let i=join(t,vp);await O(dirname(i)),await S(i,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:vp,feature:"ignore"});}var Hu=f(()=>{Fe();w();It();s(WC,"cursorHooksToCanonical");s(Oc,"importSettings");s(kc,"importIgnore");});async function Ec(t,e,r,n=_r){let o=join(t,n),i=await ro(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:Dy,targetName:"cursor",normalize:r,results:e};for(let[p,u]of i)await Tr(p,u,a);let l=await T(o).catch(()=>[]),c=l.filter(p=>p.endsWith(".md")),m=new Set(Array.from(i.values()).flatMap(p=>l.filter(u=>u.startsWith(p))));for(let p of c){if(m.has(p))continue;let u=await y(p);if(!u)continue;let d=basename(p,".md");await OI(d,p,u,a);}}var Vu=f(()=>{w();ai();It();s(Ec,"importSkills");});async function BC(t){if(await F(join(t,Oe)))return true;let e=[join(t,He),join(t,Ws),join(t,ma),join(t,Sr),join(t,ze),join(t,Mn),join(t,$n),join(t,ke)];for(let i of e){let a=await y(i);if(a!==null&&a.trim()!=="")return true}return !!((await T(join(t,Mn))).some(i=>i.endsWith(".md"))||(await T(join(t,$n))).some(i=>i.endsWith(".md"))||(await T(join(t,ke))).some(i=>i.endsWith(".md")))}async function zC(t,e,r){let n=join(t,Cr),o=false,i=join(t,Oe),a=await nt({srcDir:i,destDir:n,extensions:[".mdc"],fromTool:ui,normalize:r,mapEntry:s(async({srcPath:l,relativePath:c,normalizeTo:m})=>{if(o){let p=await y(l);if(p!==null){let{frontmatter:u}=E(p);if(u.alwaysApply===true)return null}}return Sc(c,n,m,()=>{o=true;})},"mapEntry")});return e.push(...a),o}async function HC(t,e,r){let n=join(t,Ws),o=await y(n);return o===null||o.trim()===""?false:pi({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function VC(t,e,r){let n=join(t,He),o=await y(n);return o===null||o.trim()===""?false:pi({projectRoot:t,results:e,sourcePath:n,content:o.trim(),normalize:r})}async function JC(t,e){let r=join(t,ma),n=await y(r);if(n===null||n.trim()==="")return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let i=join(t,Bs);await O(dirname(i)),await S(i,n),e.push({fromTool:ui,fromPath:r,toPath:Bs,feature:"mcp"});}async function YC(t,e,r){let n=join(t,$n),o=join(t,jn);e.push(...await nt({srcDir:n,destDir:o,extensions:[".md"],fromTool:ui,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>GC(i,o,a),"mapEntry")}));}async function XC(t,e,r){let n=join(t,ke),o=join(t,Gn);e.push(...await nt({srcDir:n,destDir:o,extensions:[".md"],fromTool:ui,normalize:r,mapEntry:s(({relativePath:i,normalizeTo:a})=>$C(i,o,a),"mapEntry")}));}var ui,ZC=f(()=>{w();v();Ue();It();Bu();Wu();ui="cursor";s(BC,"hasGlobalCursorArtifacts");s(zC,"importGlobalCursorRulesFromDir");s(HC,"importGlobalUserRules");s(VC,"importGlobalDotCursorAgents");s(JC,"importGlobalMcp");s(YC,"importGlobalAgents");s(XC,"importGlobalCommands");});async function qC(t){if(!await BC(t))return [];let e=[],r=await B(ui,t,"global"),n=await zC(t,e,r);return n||(n=await HC(t,e,r)),n||await VC(t,e,r),await JC(t,e),await Ec(t,e,r,Mn),await YC(t,e,r),await XC(t,e,r),await Oc(t,e),await kc(t,e),e}var QC=f(()=>{gt();It();Vu();Hu();ZC();s(qC,"importFromCursorGlobalExports");});async function OD(t,e){let r=join(t,Ir),n=await y(r);if(!n)return;let o;try{o=JSON.parse(n);}catch{return}if(!o||typeof o!="object"||!("mcpServers"in o))return;let i=o.mcpServers;await Ut(t,Bs,i),e.push({fromTool:"cursor",fromPath:r,toPath:Bs,feature:"mcp"});}async function Lc(t,e={}){if(e.scope==="global")return qC(t);let r=[],n=await B("cursor",t);return await UC(t,r,n),r.push(...await q(Ac,t,"project",{normalize:n})),await Ec(t,r,n),await OD(t,r),await Oc(t,r),await kc(t,r),r}var Ju=f(()=>{gt();w();Kt();Yr();KC();Hu();Vu();QC();It();Yu();s(OD,"importMcp");s(Lc,"importFromCursor");});var eR,rR,nR=f(()=>{v();Z();je();It();eR=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n)),a=Ce(o.allowedTools),l=a.length>0?a:Ce(o["allowed-tools"]);return {destPath:n,toPath:`${Gn}/${t}`,content:await tt(n,{description:typeof o.description=="string"?o.description:"",hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),allowedTools:l,hasAllowedTools:Object.prototype.hasOwnProperty.call(o,"allowedTools")||Object.prototype.hasOwnProperty.call(o,"allowed-tools")},i)}},"cursorCommandMapper"),rR=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${jn}/${t}`,content:await Ot(n,o,i)}},"cursorAgentMapper");});function oR(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:Ty}))}var sR=f(()=>{Nt();It();s(oR,"lintRules");});function iR(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>G(e.source,"cursor","Cursor command files are plain Markdown; command description and allowed-tools metadata are not projected."))}function aR(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers)){let o=n.env&&Object.keys(n.env).length>0,i="url"in n,a="headers"in n;(o||i||a)&&e.push(G(".agentsmesh/mcp.json","cursor",`MCP server "${r}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`));}return e}function lR(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?[G(".agentsmesh/permissions.yaml","cursor","Cursor permissions are partial; tool-level allow/deny may lose fidelity.")]:[]}var cR=f(()=>{kt();s(iR,"lintCommands");s(aR,"lintMcp");s(lR,"lintPermissions");});var kD,ED,LD,AD,Ac,Yu=f(()=>{MC();It();se();Ju();nR();sR();Lt();cR();kD={name:"cursor",primaryRootInstructionPath:on,generateRules:Fu,generateCommands:vu,generateAgents:Gu,generateSkills:$u,generateMcp:Mu,generatePermissions:ju,generateHooks:Uu,generateIgnore:Ku,importFrom:Lc},ED={rootInstructionPath:on,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[vn,He]}],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`}}},LD={rootInstructionPath:on,outputFamilies:[{id:"root-mirrors",kind:"additional",explicitPaths:[vn,He]}],skillDir:Mn,managedOutputs:{dirs:[Oe,ke,$n,Mn],files:[on,He,ma,Sr,ze,Ws]},rewriteGeneratedPath(t){return t===vn?null:t===He||t===on||t.startsWith(`${Oe}/`)||t.startsWith(`${ke}/`)||t.startsWith(`${Ks}/`)||t.startsWith(`${_r}/`)||t===Ir||t===Sr||t===ze?t:t===Gl?null:t},mirrorGlobalPath(t,e){return rt(t,_r,e)},paths:{rulePath(t,e){return `${Oe}/${t}.mdc`},commandPath(t,e){return `${ke}/${t}.md`},agentPath(t,e){return `${$n}/${t}.md`}}},AD={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"native",ignore:"native",permissions:"none"},Ac={id:"cursor",generators:kD,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:oR,lint:{commands:iR,mcp:aR,permissions:lR},project:ED,globalSupport:{capabilities:AD,detectionPaths:[on,He,Ir,Sr,ze,_r,$n,ke,Ws],layout:LD},importer:{commands:{feature:"commands",mode:"directory",source:{project:[ke]},canonicalDir:Gn,extensions:[".md"],map:eR},agents:{feature:"agents",mode:"directory",source:{project:[Ks]},canonicalDir:jn,extensions:[".md"],map:rR}},buildImportPaths:Mp,detectionPaths:[".cursor/rules",".cursor/mcp.json"],preservesManualActivation:true};});var so,we,Mr,mR,pR,le,wc,ls,Pc,Fa,io,uR,dR,ao,bc,va,Ma,Xu,Zu,di,qu,fi,gi,xc,hi,cs,$a,At=f(()=>{so="gemini-cli",we="GEMINI.md",Mr="AGENTS.md",mR=".gemini/rules",pR=".gemini/GEMINI.md",le=".gemini/commands",wc=".gemini/policies",ls=".gemini/settings.json",Pc=".geminiignore",Fa=".gemini/skills",io=".gemini/agents",uR=".gemini/system.md",dR=`${wc}/permissions.toml`,ao=".agentsmesh/rules",bc=".agentsmesh/commands",va=".agentsmesh/agents",Ma=".agentsmesh/skills",Xu=".agentsmesh/mcp.json",Zu=".agentsmesh/hooks.yaml",di=".agentsmesh/ignore",qu=".agentsmesh/permissions.yaml",fi=".gemini/GEMINI.md",gi=".gemini/AGENTS.md",xc=".gemini/settings.json",hi=".gemini/commands",cs=".gemini/skills",$a=".gemini/agents";});function Qu(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>!(i.root||i.targets.length>0&&!i.targets.includes("gemini-cli")));if(!e&&r.length===0)return [];let n=Rt(e?.body.trim()??"",r),o=[{path:we,content:n}];if(e){let i=e.body.trim().replace(/\.agentsmesh\/skills\//g,".agents/skills/");o.push({path:Mr,content:i});}return o}var fR=f(()=>{he();At();s(Qu,"generateRules");});function gR(t,e){let r=t.split(":").filter(Boolean),n=r.length>0?r.pop():t;return [e,...r,`${n}.toml`].join("/")}var hR=f(()=>{s(gR,"canonicalCommandNameToGeminiTomlPath");});function wD(t){let e=t.replace(/\r\n/g,`
|
|
98
98
|
`);return e.includes('"""')?JSON.stringify(e):`"""
|
|
99
99
|
${e}
|
|
100
|
-
"""`}function
|
|
100
|
+
"""`}function PD(t){return [`description = ${JSON.stringify(t.description||t.name)}`,`prompt = ${wD(t.body.trim()||"")}`].join(`
|
|
101
101
|
`)+`
|
|
102
|
-
`}function
|
|
103
|
-
`)}]}var
|
|
104
|
-
`)}function
|
|
105
|
-
`)}]}var
|
|
102
|
+
`}function td(t){return t.commands.map(e=>({path:gR(e.name,le),content:PD(e)}))}var yR=f(()=>{At();hR();s(wD,"serializeTomlMultilineLiteral");s(PD,"serializeGeminiCommand");s(td,"generateCommands");});function ed(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=N(r,e.body.trim()||"");return {path:`${io}/${e.name}.md`,content:n}})}var _R=f(()=>{v();At();s(ed,"generateAgents");});function rd(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=N(n,r.body.trim()||"");e.push({path:`${Fa}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles){let a=i.relativePath.replace(/\\/g,"/");e.push({path:`${Fa}/${r.name}/${a}`,content:i.content});}}return e}var IR=f(()=>{v();At();s(rd,"generateSkills");});function bD(t){switch(t){case "PreToolUse":return "BeforeTool";case "PostToolUse":return "AfterTool";case "Notification":return "Notification";default:return null}}function nd(t){let e={},r=false;if(t.mcp&&Object.keys(t.mcp.mcpServers).length>0&&(e.mcpServers=t.mcp.mcpServers,r=true),t.agents.length>0&&(e.experimental={enableAgents:true},r=true),t.hooks){let n=Object.entries(t.hooks).flatMap(([o,i])=>{let a=bD(o);if(!a||!Array.isArray(i))return [];let l=i.filter(c=>typeof c=="object"&&c!==null&&zr(c)).map((c,m)=>({matcher:c.matcher,hooks:[{name:`${a}-${m+1}`,type:"command",command:Ct(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:[we,Mr]}),Object.keys(e).length===0?[]:[{path:ls,content:JSON.stringify(e,null,2)}]}var od=f(()=>{Fe();At();s(bD,"mapHookEvent");s(nd,"generateGeminiSettingsFiles");});function sd(t){return !t.ignore||t.ignore.length===0?[]:[{path:Pc,content:t.ignore.join(`
|
|
103
|
+
`)}]}var SR=f(()=>{At();s(sd,"generateIgnore");});var CR=f(()=>{fR();yR();_R();IR();od();SR();});var RR=f(()=>{CR();});function ms(t){return JSON.stringify(t)}function xD(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function TD(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 Tc(t,e,r){return ["[[rule]]",`decision = ${ms(t)}`,`priority = ${e}`,...r,""].join(`
|
|
104
|
+
`)}function OR(t,e,r){let n=TD(t),o={Read:"read_file",Grep:"grep_search",LS:"list_directory",WebFetch:"web_fetch",Bash:"run_shell_command"};if(n.kind==="tool"){let i=o[n.tool]??n.tool;return Tc(e,r,[`toolName = ${ms(i)}`])}if(n.kind==="bash"){let i=n.prefix.replace(/:\*$/u,"").replace(/\*$/u,"").trim();return Tc(e,r,[`toolName = ${ms(o.Bash)}`,`commandPrefix = ${ms(i)}`])}return n.kind==="read"?Tc(e,r,[`toolName = ${ms(o.Read)}`,`argsPattern = ${ms(xD(n.path))}`]):Tc(e,r,[`toolName = ${ms(n.raw)}`])}function kR(t){if(!t.permissions)return [];let{allow:e,deny:r}=t.permissions;if(e.length+r.length===0)return [];let o=[];return e.forEach((i,a)=>{let l=OR(i,"allow",100+a);l&&o.push(l);}),r.forEach((i,a)=>{let l=OR(i,"deny",200+a);l&&o.push(l);}),o.length===0?[]:[{path:dR,content:o.join(`
|
|
105
|
+
`)}]}var ER=f(()=>{At();s(ms,"escapeTomlBasicString");s(xD,"escapeRegexLiteral");s(TD,"parsePermissionExpr");s(Tc,"ruleForDecision");s(OR,"permissionExprToGeminiRule");s(kR,"generateGeminiPermissionsPolicies");});function id(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 Nc(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(),i=t.slice(n+3).trim();return {frontmatter:o===""?{}:parse$1(o)??{},body:i}}catch{return {frontmatter:{},body:t.trim()}}}return {frontmatter:{},body:t.trim()}}var ad=f(()=>{v();s(id,"mapGeminiHookEvent");s(Nc,"parseFlexibleFrontmatter");});async function ld(t,e){let r=join(t,ls),n=await y(r);if(n===null)return;let o;try{o=JSON.parse(n);}catch{}if(!o)return;let i=o.mcpServers;if(i!==void 0&&typeof i=="object"&&i!==null&&Object.keys(i).length>0){let c=join(t,Xu);await O(join(t,".agentsmesh")),await S(c,JSON.stringify({mcpServers:i},null,2)),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Xu,feature:"mcp"});}let a=o.ignorePatterns;if(Array.isArray(a)&&a.length>0&&a.every(c=>typeof c=="string")){let c=join(t,di);await O(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:di,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=id(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"&&zr(h)).map(h=>({matcher:g.matcher,command:Ct(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"&&zr(h)).map(h=>({matcher:h.matcher,command:Ct(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,Zu);await O(join(t,".agentsmesh")),await S(p,stringify(m,{lineWidth:0}).trimEnd()),e.push({fromTool:"gemini-cli",fromPath:r,toPath:Zu,feature:"hooks"});}}}var LR=f(()=>{Fe();w();At();ad();s(ld,"importGeminiSettings");});async function AR(t,e){let r=join(t,Pc),n=await y(r);if(n!==null&&n.trim()){let o=n.split(/\r?\n/).map(i=>i.trim()).filter(i=>i&&!i.startsWith("#"));if(o.length>0){await O(join(t,".agentsmesh"));let i=join(t,di);await S(i,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:di,feature:"ignore"});}}}var md=f(()=>{w();At();ad();LR();s(AR,"importGeminiIgnore");});function MD(t){return t.replace(/\\(.)/g,"$1")}function $D(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 GD(t){return `Bash(${t}:*)`}function jD(t){return `Read(${MD(t)})`}async function wR(t){let e=[],r=join(t,wc),n;try{n=await T(r);}catch{return e}let o=n.filter(u=>u.endsWith(".toml"));if(o.length===0)return e;let i=[],a=[],l=new Set,c=new Set;for(let u of o){let d=await y(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 R=C,I=typeof R.toolName=="string"?R.toolName:null,k=typeof R.decision=="string"?R.decision:null;if(!I||!k)continue;let D=$D(I);if(!D)continue;let P=null;D==="Bash"?typeof R.commandPrefix=="string"&&R.commandPrefix.trim()&&(P=GD(R.commandPrefix.trim())):D==="Read"?typeof R.argsPattern=="string"&&R.argsPattern.trim()?P=jD(R.argsPattern.trim()):P="Read":P=D,P&&(k==="allow"?l.has(P)||(l.add(P),i.push(P)):k==="deny"&&(c.has(P)||(c.add(P),a.push(P))));}}if(i.length===0&&a.length===0)return e;await O(join(t,".agentsmesh"));let m=join(t,qu),p=stringify({allow:i,deny:a});return await S(m,p.trimEnd()+`
|
|
110
|
+
`),e.push({fromTool:so,fromPath:join(t,wc),toPath:qu,feature:"permissions"}),e}var PR=f(()=>{w();At();s(MD,"unescapeRegexLiteral");s($D,"toolNameToPermissionBase");s(GD,"commandPrefixToBashExpr");s(jD,"argsPatternToReadExpr");s(wR,"importGeminiPolicies");});function pd(t,e){let r=new Set([e,e.replace(/\\/g,"/"),e.replace(/\//g,"\\")]);try{r.add(realpathSync(e)),r.add(realpathSync.native(e));}catch{}return Array.from(r).reduce((o,i)=>{let a=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return o.replace(new RegExp(`${a}[/\\\\]\\.agentsmesh[/\\\\]`,"g"),".agentsmesh/").replaceAll(`${i}/.agentsmesh`,".agentsmesh").replaceAll(`${i}\\.agentsmesh`,".agentsmesh")},t).replace(/(?:[A-Za-z]:)?[^\s"'`()<>]+[/\\]\.agentsmesh[/\\]/g,".agentsmesh/")}var xR=f(()=>{s(pd,"stripProjectRootCanonicalPrefix");});async function NR(t,e,r){let n=join(t,Fa),i=(await T(n)).filter(l=>basename(l)==="SKILL.md");for(let l of i){let c=await y(l);if(!c)continue;let m=basename(l.slice(0,-9)),p=E(c),u=mr(p.frontmatter,m);if(u){let k=join(t,va);await O(k);let D=join(k,`${u.name}.md`);await S(D,ge(u,r(p.body,l,D))),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${va}/${u.name}.md`,feature:"agents"});continue}let d=join(t,Ma,m,"SKILL.md"),g=r(c,l,d),h=join(t,Ma,m);await O(h);let{frontmatter:C,body:R}=E(g);await S(d,await pr(d,{...C,name:m},R)),e.push({fromTool:"gemini-cli",fromPath:l,toPath:`${Ma}/${m}/SKILL.md`,feature:"skills"});let I=await T(dirname(l));for(let k of I){if(k===l)continue;let D=await y(k);if(D===null)continue;let P=relative(dirname(l),k).replace(/\\/g,"/"),b=join(h,P);await O(dirname(b)),await S(b,r(D,k,b)),e.push({fromTool:"gemini-cli",fromPath:k,toPath:`${Ma}/${m}/${P}`,feature:"skills"});}}let a=join(t,io);try{let c=(await T(a)).filter(m=>m.endsWith(".md"));for(let m of c){let p=await y(m);if(!p)continue;let{frontmatter:u,body:d}=E(p),h=relative(a,m).replace(/\\/g,"/").replace(/\.md$/i,".md"),C=join(t,va);await O(C);let R=join(C,h),I=r(d,m,R);await S(R,await Ot(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},I)),e.push({fromTool:"gemini-cli",fromPath:m,toPath:`${va}/${h}`,feature:"agents"});}}catch{}}var DR=f(()=>{w();v();Z();at();At();s(NR,"importGeminiSkillsAndAgents");});async function UD(t,e,r){let n=await B("codex-cli",t),o=join(t,ao),i=join(t,Mr),a=join(t,pR),l=[i,a,join(t,we),join(t,uR)],c=null,m=l[l.length-1];for(let P of l){let b=await y(P);if(b!==null){c=b,m=P;break}}if(c===null)return;await O(o);let p=join(o,"_root.md"),u=m===i||m===a?n(c,m,p):c,d=await xr({content:u,projectRoot:t,rulesDir:ao,sourcePath:m,fromTool:so,normalize:r});e.push(...d.results);let g=r(d.rootContent,m,p),h=pd(g.replace(/\.agents\/skills\//g,".agentsmesh/skills/").replace(/\.agents\\skills\\/g,".agentsmesh/skills/"),t),{frontmatter:C,body:R}=E(h),k=C.root===true?C:{...C,root:true},D=pd(await $(p,k,R),t);await S(p,D),e.push({fromTool:so,fromPath:m,toPath:`${ao}/_root.md`,feature:"rules"});}async function Fc(t){let e=[],r=await B(so,t);return await UD(t,e,r),e.push(...await q(vc,t,"project",{normalize:r})),await NR(t,e,r),await ld(t,e),await AR(t,e),e.push(...await wR(t)),e}var fd=f(()=>{gt();w();v();Z();ii();Kt();At();gd();md();PR();xR();DR();s(UD,"importRootRule");s(Fc,"importFromGemini");});async function vR(t,e,r){let n=t.replace(/\\/g,"/"),o=join(e,n),{frontmatter:i,body:a}=Nc(r(o)),l=Xr(i.globs),c={root:false,description:typeof i.description=="string"?i.description:void 0,globs:l.length>0?l:void 0};return Object.keys(c).forEach(m=>{c[m]===void 0&&delete c[m];}),{destPath:o,toPath:`${ao}/${n}`,feature:"rules",content:await $(o,c,a)}}async function MR(t,e,r){let n=t.replace(/\.(toml|md)$/i,".md").replace(/\\/g,"/"),o=join(e,n),i=r(o),{frontmatter:a,body:l}=t.endsWith(".toml")?WD(i):Nc(i),c=Ce(a.allowedTools),m=Ce(a["allowed-tools"]),p=c.length>0?c:m;return {destPath:o,toPath:`${bc}/${n}`,feature:"commands",content:await tt(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 WD(t){try{let e=parse$1(t);return {frontmatter:e,body:typeof e.prompt=="string"?e.prompt:""}}catch{return {frontmatter:{},body:t.trim()}}}var $R=f(()=>{Z();je();md();At();s(vR,"mapGeminiRuleFile");s(MR,"mapGeminiCommandFile");s(WD,"parseTomlCommand");});var GR,jR,UR=f(()=>{$R();GR=s(({relativePath:t,destDir:e,normalizeTo:r})=>vR(t,e,r),"geminiRuleMapper"),jR=s(({relativePath:t,destDir:e,normalizeTo:r})=>MR(t,e,r),"geminiCommandMapper");});function KR(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(i=>({...i,target:so}))}var WR=f(()=>{Nt();At();s(KR,"lintRules");});function BR(t){return t.commands.filter(e=>e.allowedTools.length>0).map(e=>G(e.source,"gemini-cli","Gemini TOML command files do not project canonical allowed-tools metadata."))}function zR(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=>Ms(n,"gemini-cli",e))}var HR=f(()=>{kt();s(BR,"lintCommands");s(zR,"lintHooks");});function VR(t,e){return e==="project"&&lo("gemini-cli",e)?.ignore.flavor!=="settings-embedded"?[]:nd(t)}var JR=f(()=>{ct();od();s(VR,"emitScopedGeminiSettings");});function XR(t){try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return {}}}function ZR(t,e){let r=XR(t),n=BD.parse(JSON.parse(e)),o={...r};n.permissions!==void 0&&(o.permissions=n.permissions),n.hooks!==void 0&&(o.hooks=n.hooks);let i=o.permissions;return i&&typeof i=="object"&&!Array.isArray(i)&&!("ask"in i)&&(i.ask=[]),JSON.stringify(o,null,2)}function qR(t,e){let r=XR(t),n=zD.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 YR,BD,zD,hd=f(()=>{YR=[".claude/settings.json",".gemini/settings.json"],BD=z.object({permissions:z.object({allow:z.array(z.string()).optional(),deny:z.array(z.string()).optional()}).passthrough().optional(),hooks:z.record(z.string(),z.unknown()).optional()}).passthrough(),zD=z.object({mcpServers:z.record(z.string(),z.unknown()).optional(),hooks:z.record(z.string(),z.unknown()).optional(),experimental:z.record(z.string(),z.unknown()).optional(),context:z.record(z.string(),z.unknown()).optional()}).passthrough();s(XR,"parseJsonObject");s(ZR,"mergeSettingsJson");s(qR,"mergeGeminiSettingsJson");});var HD,VD,JD,YD,vc,gd=f(()=>{RR();Co();ER();At();fd();UR();WR();Lt();Ps();at();HR();JR();se();hd();HD={name:"gemini-cli",primaryRootInstructionPath:we,generateRules:Qu,generateCommands:td,generateAgents:ed,generateSkills:rd,generateIgnore:sd,generatePermissions:kR,importFrom:Fc},VD={rootInstructionPath:we,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[Mr]}],extraRuleOutputPaths(){return [Mr]},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 rt(t,".gemini/skills",e)},paths:{rulePath(t,e){return we},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${le}/${r.join("/")}/${n}.toml`}return `${le}/${t}.toml`},agentPath(t,e){return fe(e,"gemini-cli")?`.gemini/skills/${H(t)}/SKILL.md`:`${io}/${t}.md`}}},JD={rootInstructionPath:fi,outputFamilies:[{id:"compat-agents",kind:"additional",explicitPaths:[gi]}],extraRuleOutputPaths(){return [gi]},skillDir:cs,managedOutputs:{dirs:[hi,cs,$a],files:[fi,gi,xc]},rewriteGeneratedPath(t){return t===we?fi:t===Mr?gi:t===ls?xc:t.startsWith(`${le}/`)?t.replace(`${le}/`,`${hi}/`):t.startsWith(".gemini/skills/")?t.replace(".gemini/skills/",`${cs}/`):t.startsWith(`${io}/`)?t.replace(`${io}/`,`${$a}/`):t.startsWith(".gemini/policies/")||t===".geminiignore"?null:t},mirrorGlobalPath(t,e){return rt(t,cs,e)},paths:{rulePath(t,e){return fi},commandPath(t,e){if(t.includes(":")){let r=t.split(":").filter(Boolean),n=r.pop()??t;return `${hi}/${r.join("/")}/${n}.toml`}return `${hi}/${t}.toml`},agentPath(t,e){return fe(e,"gemini-cli")?`${cs}/${H(t)}/SKILL.md`:`${$a}/${t}.md`}}},YD={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:"none",permissions:"none"},vc={id:"gemini-cli",generators:HD,capabilities:{rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"partial",ignore:$e("native","settings-embedded"),permissions:"partial"},emptyImportMessage:"No Gemini CLI config found (GEMINI.md or .gemini/rules, .gemini/commands, .gemini/settings.json).",lintRules:KR,lint:{commands:BR,hooks:zR},emitScopedSettings:VR,mergeGeneratedOutputContent(t,e,r,n){let o=e?.content??t;return o!==null&&n===ls?qR(o,r):null},project:VD,globalSupport:{capabilities:YD,detectionPaths:[fi,gi,xc,hi,cs,$a],layout:JD},importer:{rules:{feature:"rules",mode:"directory",source:{project:[mR]},canonicalDir:ao,extensions:[".md"],map:GR},commands:{feature:"commands",mode:"directory",source:{project:[le]},canonicalDir:bc,extensions:[".md",".toml"],map:jR}},buildImportPaths:$p,detectionPaths:["GEMINI.md",".gemini"]};});function QR(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(Rr)),n=e?.body.trim()??"",o=Rt(n,r);return o?[{path:Ee,content:o}]:[]}function tO(t){return _t(t,Vt)}function eO(t){return t.commands.map(e=>({path:`${Vt}/${et(e.name)}/SKILL.md`,content:cr(e)}))}function rO(t){return t.agents.map(e=>({path:`${Vt}/${H(e.name)}/SKILL.md`,content:te(e)}))}function nO(t){return t.ignore.length===0?[]:[{path:sn,content:t.ignore.join(`
|
|
111
|
+
`)}]}var oO=f(()=>{ft();he();at();Qt();zs();s(QR,"generateRules");s(tO,"generateSkills");s(eO,"generateCommands");s(rO,"generateAgents");s(nO,"generateIgnore");});async function sO(t,e={}){let r=e.scope??"project",n=[],o=await B(Rr,t,r);return n.push(...await q(Mc,t,r,{normalize:o})),await dt(t,r==="global"?Le:Vt,Rr,n,o),n}var iO=f(()=>{gt();ft();Kt();zs();yd();s(sO,"importFromGoose");});function aO(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Rr}))}var lO=f(()=>{Nt();zs();s(aO,"lintRules");});function cO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".agentsmesh/hooks.yaml","goose","Goose has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function mO(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?[]:[G(".agentsmesh/permissions.yaml","goose","Goose permissions are managed at runtime via permission.yaml in ~/.config/goose/; canonical permissions are not projected.")]}function pO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[G(".agentsmesh/mcp.json","goose","Goose MCP extensions are configured globally in ~/.config/goose/config.yaml; project-level MCP is not projected.")]}var uO=f(()=>{kt();s(cO,"lintHooks");s(mO,"lintPermissions");s(pO,"lintMcp");});var XD,ZD,qD,dO,Mc,yd=f(()=>{Qt();at();oO();se();iO();lO();uO();Lt();zs();XD={name:Rr,primaryRootInstructionPath:Ee,generateRules:QR,generateCommands:eO,generateAgents:rO,generateSkills:tO,generateIgnore:nO,importFrom:sO},ZD={rootInstructionPath:Ee,skillDir:Vt,managedOutputs:{dirs:[Vt],files:[Ee,sn]},paths:{rulePath(t){return Ee},commandPath(t){return `${Vt}/${et(t)}/SKILL.md`},agentPath(t){return `${Vt}/${H(t)}/SKILL.md`}}},qD={rootInstructionPath:an,skillDir:Le,managedOutputs:{dirs:[Le],files:[an,To]},rewriteGeneratedPath(t){return t===Ee?an:t===sn?To:(t.startsWith(`${Vt}/`),t)},mirrorGlobalPath(t,e){return rt(t,Le,e)},paths:{rulePath(t){return an},commandPath(t){return `${Le}/${et(t)}/SKILL.md`},agentPath(t){return `${Le}/${H(t)}/SKILL.md`}}},dO={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"native",permissions:"none"},Mc={id:Rr,generators:XD,capabilities:dO,emptyImportMessage:"No Goose config found (.goosehints, .agents/skills, or .gooseignore).",lintRules:aO,lint:{hooks:cO,permissions:mO,mcp:pO},supportsConversion:{commands:true,agents:true},project:ZD,globalSupport:{capabilities:dO,detectionPaths:[an,To,Le],layout:qD},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Ee],global:[an]},canonicalDir:$y,canonicalRootFilename:"_root.md",markAsRoot:true},ignore:{feature:"ignore",mode:"flatFile",source:{project:[sn],global:[To]},canonicalDir:".agentsmesh",canonicalFilename:Gy}},sharedArtifacts:{".agents/skills/":"consumer"},buildImportPaths:Gp,detectionPaths:[Ee,sn]};});function fO(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Or,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:`${da}/${o}.md`,content:n.body.trim()||""});}return e}function tF(t){let e={};return t.description&&(e.description=t.description),t.type!=="stdio"&&(e.type=t.type),ic(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 gO(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,tF(n)]));return [{path:ua,content:JSON.stringify({mcpServers:e},null,2)}]}function hO(t){return t.commands.map(e=>{let r={description:e.description||void 0};return r.description===void 0&&delete r.description,{path:`${Hs}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function yO(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:`${Vs}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function _O(t){return t.ignore.length===0?[]:[{path:fa,content:t.ignore.join(`
|
|
112
|
+
`)}]}function IO(t){return _t(t,Do)}function SO(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 Rt(e?.body.trim()??"",r)}var CO=f(()=>{ac();ft();he();v();Js();s(fO,"generateRules");s(tF,"toJunieMcpServer");s(gO,"generateMcp");s(hO,"generateCommands");s(yO,"generateAgents");s(_O,"generateIgnore");s(IO,"generateSkills");s(SO,"renderJunieGlobalInstructions");});async function eF(t,e,r){let n=[Or,jl,Uy,Ky],o=join(t,jp);for(let i of n){let a=join(t,i),l=await y(a);if(l===null)continue;let c=await xr({content:l,projectRoot:t,rulesDir:Kl,sourcePath:a,fromTool:No,normalize:r});e.push(...c.results);let{frontmatter:m,body:p}=E(r(c.rootContent,a,o)),u=await $(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:No,fromPath:a,toPath:jp,feature:"rules"});return}}async function $c(t){let e=[],r=await B(No,t);return await eF(t,e,r),e.push(...await q(Gc,t,"project",{normalize:r})),await dt(t,Do,No,e,r),e}var _d=f(()=>{gt();w();v();ft();ii();Z();Kt();Js();Id();s(eF,"importRootRule");s($c,"importFromJunie");});function OO(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:No}))}var kO=f(()=>{Nt();Js();s(OO,"lintRules");});function EO(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=[];for(let[r,n]of Object.entries(t.mcp.mcpServers))YI(n)&&e.push(G(".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(()=>{ac();kt();s(EO,"lintMcp");});var rF,nF,oF,sF,Gc,Id=f(()=>{CO();Js();se();_d();kO();LO();Lt();rF={name:"junie",primaryRootInstructionPath:Or,generateRules:fO,generateCommands:hO,generateAgents:yO,generateSkills:IO,generateMcp:gO,generateIgnore:_O,importFrom:$c},nF={rootInstructionPath:Or,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 `${da}/${t}.md`},commandPath(t,e){return `${Hs}/${t}.md`},agentPath(t,e){return `${Vs}/${t}.md`}}},oF={rootInstructionPath:Fo,renderPrimaryRootInstruction:SO,skillDir:ha,managedOutputs:{dirs:[ha,ya,_a,Wy],files:[Fo,Ul]},rewriteGeneratedPath(t){return t===Or?Fo:t.startsWith(`${da}/`)?Fo:t.startsWith(`${Do}/`)?t.replace(`${Do}/`,`${ha}/`):t.startsWith(`${Hs}/`)?t.replace(`${Hs}/`,`${_a}/`):t.startsWith(`${Vs}/`)?t.replace(`${Vs}/`,`${ya}/`):t===ua?Ul:t===fa?null:t},mirrorGlobalPath(t,e){return rt(t,".junie/skills",e)},paths:{rulePath(t,e){return Fo},commandPath(t,e){return `${_a}/${t}.md`},agentPath(t,e){return `${ya}/${t}.md`}}},sF={rules:"native",additionalRules:"embedded",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Gc={id:"junie",generators:rF,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:OO,lint:{mcp:EO},project:nF,globalSupport:{capabilities:sF,detectionPaths:[Fo,ha,ya,_a,Ul],layout:oF},importer:{rules:{feature:"rules",mode:"directory",source:{project:[".junie/rules"]},canonicalDir:Kl,extensions:[".md"],preset:"rule"},commands:{feature:"commands",mode:"directory",source:{project:[".junie/commands"]},canonicalDir:By,extensions:[".md"],preset:"command"},agents:{feature:"agents",mode:"directory",source:{project:[".junie/agents"]},canonicalDir:zy,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ua]},canonicalDir:".agentsmesh",canonicalFilename:Hy},ignore:{feature:"ignore",mode:"flatFile",source:{project:[fa]},canonicalDir:".agentsmesh",canonicalFilename:Vy}},buildImportPaths:Up,detectionPaths:[".junie/guidelines.md",".junie/AGENTS.md",".junie/skills",".junie/mcp/mcp.json",".aiignore"]};});function wO(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:kr,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Jt))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs);let a=Object.keys(i).length>0?N(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${ln}/${o}.md`,content:a});}return e}function PO(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${cn}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function bO(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:`${mn}/${r}.md`,content:N(n,e.body.trim()||"")}})}function xO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Kn,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function TO(t){return t.ignore.length===0?[]:[{path:Ys,content:t.ignore.join(`
|
|
113
|
+
`)}]}function NO(t){return _t(t,Ve)}var DO=f(()=>{ft();v();Ko();s(wO,"generateRules");s(PO,"generateCommands");s(bO,"generateAgents");s(xO,"generateMcp");s(TO,"generateIgnore");s(NO,"generateSkills");});var jc,Uc,FO,Cd=f(()=>{v();Z();Ko();jc=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${zn}/${t}`,content:await $(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"kiloNonRootRuleMapper"),Uc=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Qs}/${t}`,content:await tt(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"kiloCommandMapper"),FO=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Uo}/${t}`,content:await Ot(n,o,i)}},"kiloAgentMapper");});async function vO(t){try{return await stat(t),!0}catch{return false}}async function lF(t,e,r){let n=join(t,vo);if(!await vO(n))return;let o=join(t,zn),i=join(n,Od),l=e.some(c=>c.toPath===Rd)?null:await y(i);if(l!==null){let c=join(t,Rd),m=r(l,i,c),{body:p}=E(m),u=await $(c,{root:true},p);await S(c,u),e.push({feature:"rules",fromTool:Jt,fromPath:`${vo}/${Od}`,toPath:Rd});}e.push(...await nt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Jt,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let d=await jc({absolutePath:c,relativePath:m,content:p,destDir:o,normalizeTo:u});return m===Od||!d?null:{...d,feature:"rules"}},"mapEntry")}));}async function cF(t,e,r){let n=join(t,Xs);if(!await vO(n))return;let o=join(t,Qs);e.push(...await nt({srcDir:n,destDir:o,extensions:[".md"],fromTool:Jt,normalize:r,mapEntry:s(async({srcPath:i,relativePath:a,content:l,normalizeTo:c})=>{let m=await Uc({absolutePath:i,relativePath:a,content:l,destDir:o,normalizeTo:c});return m?{...m,feature:"commands"}:null},"mapEntry")}));}async function mF(t,e,r){let n=join(t,Bl),o=await y(n);if(o===null)return;let i;try{i=parse(o);}catch{return}if(!(!i||!Array.isArray(i.customModes)))for(let a of i.customModes){if(!a||typeof a!="object")continue;let l=a;if(typeof l.slug!="string"||l.slug.length===0)continue;let c=l.slug,m=join(t,Uo,`${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 oR(t){return qt(t,er)}function sR(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:us,content:stringify({customModes:e})}]}var iR=f(()=>{Bt();F();ao();i(tR,"generateRules");i(eR,"generateCommands");i(rR,"generateMcp");i(nR,"generateIgnore");i(oR,"generateSkills");i(sR,"generateAgents");});var Jl,lR,_u=f(()=>{F();Y();ao();Jl=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:s}=O(e(n));return {destPath:n,toPath:`${io}/${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"),lR=i(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:s}=O(e(n));return {destPath:n,toPath:`${Qa}/${t}`,content:await Z(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},s)}},"rooCommandMapper");});async function RT(t,e,r){let n=join(t,oo),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,io);for(let l of s)e.push(...await q({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:un,normalize:r,mapEntry:i(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let d=await Jl({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return d?{...d,feature:"rules"}:null},"mapEntry")}));}async function cR(t,e={}){let r=e.scope??"project",n=[],o=await V(un,t,r);return n.push(...await ct(Yl,t,r,{normalize:o})),await RT(t,n,o),await Wt(t,er,un,n,o),n}var mR=f(()=>{At();Bt();Re();ke();_u();ao();Cu();i(RT,"importPerModeRules");i(cR,"importFromRooCode");});function pR(t,e,r,n){return ot(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:un}))}var uR=f(()=>{te();ao();i(pR,"lintRules");});function LT(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var ET,AT,bT,xT,PT,Yl,Cu=f(()=>{E();iR();ao();Pr();mR();_u();uR();Mt();ET={name:"roo-code",primaryRootInstructionPath:Te,generateRules:tR,generateCommands:eR,generateSkills:oR,generateMcp:rR,generateIgnore:nR,generateAgents:sR,importFrom:cR},AT={rootInstructionPath:Te,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",us]},paths:{rulePath(t,e){return `${Lr}/${t}.md`},commandPath(t,e){return `${br}/${t}.md`},agentPath(t,e){return null}}};i(LT,"computeStatus");bT=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,Fi));return [{target:"roo-code",path:Fi,content:s,currentContent:a??void 0,status:LT(a,s)}]},"generateRooGlobalExtras"),xT={rootInstructionPath:gn,skillDir:xr,managedOutputs:{dirs:[dn,fn,xr,Gh],files:[gn,so,vi,Fi]},rewriteGeneratedPath(t){return t===Te?gn:t===us?null:t.startsWith(`${Lr}/`)?t.replace(`${Lr}/`,`${dn}/`):t.startsWith(`${br}/`)?t.replace(`${br}/`,`${fn}/`):t.startsWith(`${er}/`)?t.replace(`${er}/`,`${xr}/`):t===Ni?so:t===Di?vi:t},mirrorGlobalPath(t,e){return Ct(t,xr,e)},paths:{rulePath(t,e){return `${dn}/${t}.md`},commandPath(t,e){return `${fn}/${t}.md`},agentPath(t,e){return null}}},PT={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Yl={id:"roo-code",generators:ET,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:pR,project:AT,globalSupport:{capabilities:PT,detectionPaths:[dn,fn,xr,so,vi,gn,Fi],layout:xT,scopeExtras:bT},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Te,Ti],global:[gn,Te,Ti]},canonicalDir:io,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:[Lr],global:[dn]},canonicalDir:io,extensions:[".md"],map:Jl}],commands:{feature:"commands",mode:"directory",source:{project:[br],global:[fn]},canonicalDir:Qa,extensions:[".md"],map:lR},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Ni],global:[so]},canonicalDir:".agentsmesh",canonicalFilename:jh},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Di],global:[vi]},canonicalDir:".agentsmesh",canonicalFilename:Uh}},buildImportPaths:Hm,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",us]};});var lr,Ru,On,dR,ws,cr,Es,As,fR,wn,Fe,Ls,ku,Ou,wu,Eu,Au,Lu,bs,xs,Vi,Xl,Zl,ql,gR,Tt=f(()=>{lr="windsurf",Ru=".windsurfrules",On=".windsurf/rules",dR=".windsurfignore",ws=".codeiumignore",cr="AGENTS.md",Es=".windsurf/hooks.json",As=".windsurf/mcp_config.example.json",fR=".windsurf/mcp_config.json",wn=".windsurf/workflows",Fe=".windsurf/skills",Ls=".agentsmesh/rules",ku=".agentsmesh/commands",Ou=".agentsmesh/agents",wu=".agentsmesh/skills",Eu=".agentsmesh/ignore",Au=".agentsmesh/hooks.yaml",Lu=".agentsmesh/mcp.json",bs=".codeium/windsurf/memories/global_rules.md",xs=".codeium/windsurf/skills",Vi=".codeium/windsurf/global_workflows",Xl=".codeium/windsurf/hooks.json",Zl=".codeium/windsurf/mcp_config.json",ql=".codeium/.codeiumignore",gR=".agents/skills";});function NT(t){let e=basename(t,".md");return e==="_root"?"root":e}function DT(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 bu(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:cr,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=NT(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:`${On}/${o}.md`,content:l});let c=DT(n.globs);c&&(c!==o&&e.push({path:`${On}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var hR=f(()=>{F();Tt();i(NT,"ruleSlug");i(DT,"directoryScopedRuleDir");i(bu,"generateRules");});function xu(t){return !t.ignore||t.ignore.length===0?[]:[{path:ws,content:t.ignore.join(`
|
|
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;
|
|
122
|
-
`,e-1)+1,o=t.slice(n,e);if(!/^\s*\[[^\]\n]+\]:\s*<?\s*$/.test(o))return false;let
|
|
123
|
-
`||
|
|
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(
|
|
128
|
-
`);},table(t){if(t.length===0)return;let e=t[0].length,r=[];for(let o=0;o<e;o++){let
|
|
129
|
-
`);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>
|
|
117
|
+
${d}`:u,h={};p&&(h.description=p),typeof l.name=="string"&&l.name.length>0&&(h.name=l.name);let C=await Ot(m,h,g),R=r(C,n,m);await S(m,R),e.push({feature:"agents",fromTool:Jt,fromPath:n,toPath:`${Uo}/${c}.md`});}}async function Kc(t,e={}){let r=e.scope??"project",n=[],o=await B(Jt,t,r);return n.push(...await q(Wc,t,r,{normalize:o})),await dt(t,Ve,Jt,n,o),r==="project"&&(await lF(t,n,o),await cF(t,n,o),await mF(t,n,o),await dt(t,Mo,Jt,n,o)),n}var Rd,Od,kd=f(()=>{gt();ft();Ue();Kt();w();Z();v();Cd();Ko();Ed();Rd=`${zn}/_root.md`,Od="00-root.md";s(vO,"pathExists");s(lF,"importLegacyRules");s(cF,"importLegacyWorkflows");s(mF,"importLegacyModes");s(Kc,"importFromKiloCode");});function MO(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Jt}))}var $O=f(()=>{Nt();Ko();s(MO,"lintRules");});function GO(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".agentsmesh/hooks.yaml","kilo-code","kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected.")]:[]:[]}function jO(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?[]:[G(".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 UO=f(()=>{kt();s(GO,"lintHooks");s(jO,"lintPermissions");});var pF,uF,dF,KO,Wc,Ed=f(()=>{DO();Ko();se();kd();Cd();$O();UO();Lt();pF={name:Jt,primaryRootInstructionPath:kr,generateRules:wO,generateCommands:PO,generateAgents:bO,generateSkills:NO,generateMcp:xO,generateIgnore:TO,importFrom:Kc},uF={rootInstructionPath:kr,skillDir:Ve,managedOutputs:{dirs:[ln,cn,mn,Ve],files:[kr,Kn,Ys]},paths:{rulePath(t,e){return `${ln}/${t}.md`},commandPath(t,e){return `${cn}/${t}.md`},agentPath(t,e){return `${mn}/${t}.md`}}},dF={rootInstructionPath:Wn,skillDir:Bn,managedOutputs:{dirs:[$o,Go,jo,Bn,Yy],files:[Wn,qs,zl]},rewriteGeneratedPath(t){return t===kr?Wn:t},mirrorGlobalPath(t,e){return rt(t,Bn,e)},paths:{rulePath(t,e){return `${$o}/${t}.md`},commandPath(t,e){return `${Go}/${t}.md`},agentPath(t,e){return `${jo}/${t}.md`}}},KO={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Wc={id:Jt,generators:pF,capabilities:KO,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:GO,permissions:jO},project:uF,globalSupport:{capabilities:KO,detectionPaths:[Wn,$o,Go,jo,Bn,qs,zl],layout:dF},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[kr],global:[Wn]},canonicalDir:zn,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[ln],global:[$o]},canonicalDir:zn,extensions:[".md"],map:jc}],commands:{feature:"commands",mode:"directory",source:{project:[cn],global:[Go]},canonicalDir:Qs,extensions:[".md"],map:Uc},agents:{feature:"agents",mode:"directory",source:{project:[mn],global:[jo]},canonicalDir:Uo,extensions:[".md"],map:FO},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[Kn,Sa],global:[qs]},canonicalDir:".agentsmesh",canonicalFilename:Xy},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Ys],global:[zl]},canonicalDir:".agentsmesh",canonicalFilename:Zy}},buildImportPaths:Kp,detectionPaths:[ln,cn,mn,Ve,Kn,vo,Xs,Mo,Sa,Bl,Ys,"kilo.jsonc","kilo.json"]};});function WO(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function hF(t){return t.type==="prompt"?t.prompt:t.command}function yF(t,e){let r=BO[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 BO)||!Array.isArray(n))continue;let i=1;for(let a of n){let l=hF(a);if(!l)continue;let c={name:`${WO(r)} ${i}`,version:"1",when:yF(o,a.matcher),then:a.type==="prompt"?{type:"askAgent",prompt:l}:{type:"shellCommand",command:l}};e.push({name:`${WO(r)}-${i}.kiro.hook`,content:JSON.stringify(c,null,2)}),i+=1;}}return e}function _F(t){let e=gF.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 HO(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:_F(r)}function VO(t){return stringify(t).trimEnd()}var BO,gF,Ld=f(()=>{BO={UserPromptSubmit:"promptSubmit",SubagentStop:"agentStop",PreToolUse:"preToolUse",PostToolUse:"postToolUse"},gF=new Map([["promptSubmit","UserPromptSubmit"],["agentStop","SubagentStop"],["preToolUse","PreToolUse"],["postToolUse","PostToolUse"]]);s(WO,"toKebab");s(hF,"hookText");s(yF,"toWhen");s(zO,"generateKiroHooks");s(_F,"toCanonicalEntry");s(HO,"parseKiroHookFile");s(VO,"serializeCanonicalHooks");});function SF(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 JO(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Je,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(ae))continue;let o=basename(n.source,".md");e.push({path:`${Ye}/${o}.md`,content:N(SF(n),n.body.trim()||"")});}return e}function YO(t){return t.commands.map(e=>({path:`${Yt}/${et(e.name)}/SKILL.md`,content:cr(e)}))}function XO(t){return _t(t,Yt)}function ZO(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:ti,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:`${Hn}/${e.name}`,content:e.content}))}function QO(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=N(r,e.body.trim()||"");return {path:`${Xe}/${e.name}.md`,content:n}})}function tk(t){return t.ignore.length===0?[]:[{path:ei,content:t.ignore.join(`
|
|
118
|
+
`)}]}var ek=f(()=>{ft();Qt();v();Ld();ri();s(SF,"steeringFrontmatter");s(JO,"generateRules");s(YO,"generateCommands");s(XO,"generateSkills");s(ZO,"generateMcp");s(qO,"generateHooks");s(QO,"generateAgents");s(tk,"generateIgnore");});function RF(t){let e=typeof t.inclusion=="string"?t.inclusion:"",r={root:false,description:typeof t.description=="string"?t.description:void 0,globs:Xr(t.fileMatchPattern)};return e==="manual"&&(r.trigger="manual"),e==="auto"&&(r.trigger="model_decision"),e==="fileMatch"&&(r.trigger="glob"),r}async function OF(t,e,r,n){let o=n==="global"?[Ze,Je]:[Je,Ze];for(let i of o){let a=join(t,i),l=await y(a);if(l===null)continue;let c=join(t,Wp),{frontmatter:m,body:p}=E(r(l,a,c));await S(c,await $(c,{...m,root:true},p)),e.push({fromTool:ae,fromPath:a,toPath:Wp,feature:"rules"});return}}async function kF(t,e,r){let n=join(t,Bp);e.push(...await nt({srcDir:join(t,Ye),destDir:n,extensions:[".md"],fromTool:ae,normalize:r,mapEntry:s(async({relativePath:o,normalizeTo:i})=>{if(basename(o)==="AGENTS.md")return null;let a=join(n,o),{frontmatter:l,body:c}=E(i(a));return {destPath:a,toPath:`${Bp}/${o}`,feature:"rules",content:await $(a,RF(l),c)}},"mapEntry")}));}async function EF(t,e){let r={};for(let o of await T(join(t,Hn))){if(!o.endsWith(".kiro.hook"))continue;let i=HO(await y(o)??"");i&&(r[i.event]??=[],r[i.event].push(i.entry));}if(Object.keys(r).length===0)return;let n=join(t,zp);await O(join(t,".agentsmesh")),await S(n,VO(r)),e.push({fromTool:ae,fromPath:join(t,Hn),toPath:zp,feature:"hooks"});}async function Bc(t,e={}){let r=e.scope??"project",n=[],o=await B(ae,t,r);return await OF(t,n,o,r),await kF(t,n,o),n.push(...await q(zc,t,r,{normalize:o})),await dt(t,Yt,ae,n,o),r==="project"&&await EF(t,n),n}var Ad=f(()=>{gt();ft();Ue();Kt();Z();je();w();v();Ld();ri();wd();s(RF,"canonicalRuleMeta");s(OF,"importRoot");s(kF,"importNonRootRules");s(EF,"importHooks");s(Bc,"importFromKiro");});function rk(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:ae}))}var nk=f(()=>{Nt();ri();s(rk,"lintRules");});function ok(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=>Ms(n,"kiro",e,{unsupportedBy:"Kiro hooks"}))}var sk=f(()=>{kt();s(ok,"lintHooks");});var LF,AF,wF,PF,zc,wd=f(()=>{Qt();ek();se();Ad();nk();sk();Lt();ri();LF={name:ae,primaryRootInstructionPath:Je,generateRules:JO,generateCommands:YO,generateAgents:QO,generateSkills:XO,generateMcp:ZO,generateHooks:qO,generateIgnore:tk,importFrom:Bc},AF={rootInstructionPath:Je,skillDir:Yt,managedOutputs:{dirs:[".kiro/hooks",".kiro/skills",".kiro/steering",".kiro/agents"],files:["AGENTS.md",".kiro/settings/mcp.json",".kiroignore"]},paths:{rulePath(t,e){return `${Ye}/${t}.md`},commandPath(t){return `${Yt}/${et(t)}/SKILL.md`},agentPath(t,e){return `${Xe}/${t}.md`}}},wF={rootInstructionPath:Ze,skillDir:Vn,managedOutputs:{dirs:[Wo,Vn,Bo,t_],files:[Ze,Ra,Oa]},rewriteGeneratedPath(t){return t===Je?Ze:t.startsWith(`${Ye}/`)?t.replace(`${Ye}/`,`${Wo}/`):t.startsWith(`${Yt}/`)?t.replace(`${Yt}/`,`${Vn}/`):t.startsWith(`${Xe}/`)?t.replace(`${Xe}/`,`${Bo}/`):t===ti?Ra:t===ei?Oa:t.startsWith(`${Hn}/`)?null:t},mirrorGlobalPath(t,e){return rt(t,".kiro/skills",e)},paths:{rulePath(t,e){return `${Wo}/${t}.md`},commandPath(t){return `${Yt}/${et(t)}/SKILL.md`},agentPath(t,e){return `${Bo}/${t}.md`}}},PF={rules:"native",additionalRules:"native",commands:"none",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},zc={id:ae,generators:LF,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:rk,lint:{hooks:ok},project:AF,globalSupport:{capabilities:PF,detectionPaths:[Wo,Ze,Vn,Bo,Ra,Oa],layout:wF},importer:{agents:{feature:"agents",mode:"directory",source:{project:[Xe],global:[Xe]},canonicalDir:e_,extensions:[".md"],preset:"agent"},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[ti],global:[Ra]},canonicalDir:".agentsmesh",canonicalFilename:r_},ignore:{feature:"ignore",mode:"flatFile",source:{project:[ei],global:[Oa]},canonicalDir:".agentsmesh",canonicalFilename:n_}},buildImportPaths:Hp,detectionPaths:[Ye,Yt,Xe,Hn,ti,ei]};});function ak(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:Er,content:r.body.trim()?r.body:""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(qe))continue;let o=basename(n.source,".md"),i={};n.description&&(i.description=n.description),n.globs.length>0&&(i.globs=n.globs);let a=Object.keys(i).length>0?N(i,n.body.trim()||""):n.body.trim()||"";e.push({path:`${pn}/${o}.md`,content:a});}return e}function lk(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${un}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function ck(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:`${dn}/${r}.md`,content:N(n,e.body.trim()||"")}})}function bF(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 mk(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]=bF(n);return [{path:Lr,content:JSON.stringify({mcp:e},null,2)}]}function pk(t){return _t(t,Qe)}var uk=f(()=>{ft();v();Jo();s(ak,"generateRules");s(lk,"generateCommands");s(ck,"generateAgents");s(bF,"toOpenCodeMcpServer");s(mk,"generateMcp");s(pk,"generateSkills");});function Pd(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 TF(t){let e;try{e=JSON.parse(t);}catch{return {}}if(!e||typeof e!="object"||Array.isArray(e))return {};let r=e.mcp;if(!r||typeof r!="object"||Array.isArray(r))return {};let n={};for(let[o,i]of Object.entries(r)){if(!i||typeof i!="object"||Array.isArray(i))continue;let a=i;if(typeof a.url=="string"){n[o]={type:"url",url:a.url,headers:Pd(a.headers),env:Pd(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:Pd(a.environment),...typeof a.description=="string"?{description:a.description}:{}};}}return n}async function NF(t,e,r){let o=join(t,e==="global"?Xn:Lr),i=await y(o);if(i===null)return;let a=TF(i);Object.keys(a).length!==0&&(await Ut(t,Vp,a),r.push({feature:"mcp",fromTool:qe,fromPath:o,toPath:Vp}));}async function dk(t,e={}){let r=e.scope??"project",n=[],o=await B(qe,t,r);return n.push(...await q(Hc,t,r,{normalize:o})),await dt(t,Qe,qe,n,o),await NF(t,r,n),n}var fk=f(()=>{gt();ft();Kt();Yr();w();Jo();bd();s(Pd,"toStringRecord");s(TF,"parseOpenCodeMcp");s(NF,"importMcp");s(dk,"importFromOpenCode");});var gk,hk,yk,_k=f(()=>{v();Z();Jo();gk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${ka}/${t}`,content:await $(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"opencodeNonRootRuleMapper"),hk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Vl}/${t}`,content:await tt(n,{hasDescription:Object.prototype.hasOwnProperty.call(o,"description"),description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"opencodeCommandMapper"),yk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Jl}/${t}`,content:await Ot(n,o,i)}},"opencodeAgentMapper");});function Ik(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:qe}))}var Sk=f(()=>{Nt();Jo();s(Ik,"lintRules");});function Ck(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".agentsmesh/hooks.yaml","opencode","opencode hooks are plugin-based (TypeScript/JavaScript); canonical config hooks are not projected.")]:[]:[]}function Rk(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?[]:[G(".agentsmesh/permissions.yaml","opencode","opencode permissions live in opencode.json, which agentsmesh does not generate in v1; canonical permissions are not projected.")]}function Ok(t){return t.ignore.length===0?[]:[G(".agentsmesh/ignore","opencode","opencode has no dedicated ignore file; canonical ignore patterns are not projected. Configure watcher.ignore in opencode.json manually.")]}var kk=f(()=>{kt();s(Ck,"lintHooks");s(Rk,"lintPermissions");s(Ok,"lintIgnore");});var DF,FF,vF,Ek,Hc,bd=f(()=>{uk();Jo();se();fk();_k();Sk();kk();Lt();DF={name:qe,primaryRootInstructionPath:Er,generateRules:ak,generateCommands:lk,generateAgents:ck,generateSkills:pk,generateMcp:mk,importFrom:dk},FF={rootInstructionPath:Er,skillDir:Qe,managedOutputs:{dirs:[pn,un,dn,Qe],files:[Er,Lr]},paths:{rulePath(t){return `${pn}/${t}.md`},commandPath(t){return `${un}/${t}.md`},agentPath(t){return `${dn}/${t}.md`}}},vF={rootInstructionPath:Jn,skillDir:Yn,managedOutputs:{dirs:[zo,Ho,Vo,Yn,s_],files:[Jn,Xn]},rewriteGeneratedPath(t){return t===Er?Jn:t===Lr?Xn:t},mirrorGlobalPath(t,e){return rt(t,Yn,e)},paths:{rulePath(t){return `${zo}/${t}.md`},commandPath(t){return `${Ho}/${t}.md`},agentPath(t){return `${Vo}/${t}.md`}}},Ek={rules:"native",additionalRules:"native",commands:"native",agents:"native",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Hc={id:qe,generators:DF,capabilities:Ek,emptyImportMessage:"No OpenCode config found (AGENTS.md, .opencode/rules, .opencode/commands, .opencode/agents, .opencode/skills, or opencode.json).",lintRules:Ik,lint:{hooks:Ck,permissions:Rk,ignore:Ok},project:FF,globalSupport:{capabilities:Ek,detectionPaths:[Jn,zo,Ho,Vo,Yn,Xn],layout:vF},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[Er],global:[Jn]},canonicalDir:ka,canonicalRootFilename:"_root.md",markAsRoot:true},{feature:"rules",mode:"directory",source:{project:[pn],global:[zo]},canonicalDir:ka,extensions:[".md"],map:gk}],commands:{feature:"commands",mode:"directory",source:{project:[un],global:[Ho]},canonicalDir:Vl,extensions:[".md"],map:hk},agents:{feature:"agents",mode:"directory",source:{project:[dn],global:[Vo]},canonicalDir:Jl,extensions:[".md"],map:yk}},buildImportPaths:Jp,detectionPaths:[pn,un,dn,Qe,Lr,"opencode.jsonc"]};});function Ak(t){let e=[],r=t.rules.find(n=>n.root);r&&e.push({path:tr,content:r.body.trim()||""});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes(Zn))continue;let o=basename(n.source,".md");e.push({path:`${fn}/${o}.md`,content:n.body.trim()||""});}return e}function wk(t){return t.commands.map(e=>{let r={};return e.description&&(r.description=e.description),{path:`${gn}/${e.name}.md`,content:N(r,e.body.trim()||"")}})}function Pk(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:La,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}function bk(t){return t.ignore.length===0?[]:[{path:Aa,content:t.ignore.join(`
|
|
119
|
+
`)}]}function xk(t){return _t(t,Ar)}function Tk(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:oi,content:stringify({customModes:e})}]}var Nk=f(()=>{ft();v();qo();s(Ak,"generateRules");s(wk,"generateCommands");s(Pk,"generateMcp");s(bk,"generateIgnore");s(xk,"generateSkills");s(Tk,"generateAgents");});var Vc,Fk,Td=f(()=>{v();Z();qo();Vc=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{if(t==="00-root.md")return null;let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Zo}/${t}`,content:await $(n,{root:false,description:typeof o.description=="string"?o.description:void 0,globs:Array.isArray(o.globs)?o.globs:void 0},i)}},"rooNonRootRuleMapper"),Fk=s(async({relativePath:t,normalizeTo:e,destDir:r})=>{let n=join(r,t),{frontmatter:o,body:i}=E(e(n));return {destPath:n,toPath:`${Xl}/${t}`,content:await tt(n,{hasDescription:true,description:typeof o.description=="string"?o.description:void 0,hasAllowedTools:false,allowedTools:[]},i)}},"rooCommandMapper");});async function GF(t,e,r){let n=join(t,Yo),o;try{o=await readdir(n,{withFileTypes:!0});}catch{return}let i=o.filter(l=>l.isDirectory()&&l.name.startsWith("rules-")).map(l=>l.name),a=join(t,Zo);for(let l of i)e.push(...await nt({srcDir:join(n,l),destDir:a,extensions:[".md"],fromTool:Zn,normalize:r,mapEntry:s(async({srcPath:c,relativePath:m,content:p,normalizeTo:u})=>{let d=await Vc({absolutePath:c,relativePath:m,content:p,destDir:a,normalizeTo:u});return d?{...d,feature:"rules"}:null},"mapEntry")}));}async function vk(t,e={}){let r=e.scope??"project",n=[],o=await B(Zn,t,r);return n.push(...await q(Jc,t,r,{normalize:o})),await GF(t,n,o),await dt(t,Ar,Zn,n,o),n}var Mk=f(()=>{gt();ft();Ue();Kt();Td();qo();Dd();s(GF,"importPerModeRules");s(vk,"importFromRooCode");});function $k(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:Zn}))}var Gk=f(()=>{Nt();qo();s($k,"lintRules");});function zF(t,e){return t===null?"created":t!==e?"updated":"unchanged"}var WF,BF,HF,VF,JF,Jc,Dd=f(()=>{w();Nk();qo();se();Mk();Td();Gk();Lt();WF={name:"roo-code",primaryRootInstructionPath:tr,generateRules:Ak,generateCommands:wk,generateSkills:xk,generateMcp:Pk,generateIgnore:bk,generateAgents:Tk,importFrom:vk},BF={rootInstructionPath:tr,skillDir:".roo/skills",managedOutputs:{dirs:[".roo/rules",".roo/commands",".roo/skills"],files:[".roo/mcp.json",".rooignore",".roorules",oi]},paths:{rulePath(t,e){return `${fn}/${t}.md`},commandPath(t,e){return `${gn}/${t}.md`},agentPath(t,e){return null}}};s(zF,"computeStatus");HF=s(async(t,e,r,n)=>{if(r!=="global")return [];if(!n.has("agents")||t.agents.length===0)return [];let o=t.agents.map(l=>{let m={slug:basename(l.source,".md"),name:l.name};return l.description&&(m.description=l.description),l.body.trim()&&(m.roleDefinition=l.body.trim()),m}),i=stringify({customModes:o}),a=await y(join(e,wa));return [{target:"roo-code",path:wa,content:i,currentContent:a??void 0,status:zF(a,i)}]},"generateRooGlobalExtras"),VF={rootInstructionPath:to,skillDir:hn,managedOutputs:{dirs:[qn,Qn,hn,a_],files:[to,Xo,Pa,wa]},rewriteGeneratedPath(t){return t===tr?to:t===oi?null:t.startsWith(`${fn}/`)?t.replace(`${fn}/`,`${qn}/`):t.startsWith(`${gn}/`)?t.replace(`${gn}/`,`${Qn}/`):t.startsWith(`${Ar}/`)?t.replace(`${Ar}/`,`${hn}/`):t===La?Xo:t===Aa?Pa:t},mirrorGlobalPath(t,e){return rt(t,hn,e)},paths:{rulePath(t,e){return `${qn}/${t}.md`},commandPath(t,e){return `${Qn}/${t}.md`},agentPath(t,e){return null}}},JF={rules:"native",additionalRules:"native",commands:"native",agents:"partial",skills:"native",mcp:"native",hooks:"none",ignore:"native",permissions:"none"},Jc={id:"roo-code",generators:WF,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:$k,project:BF,globalSupport:{capabilities:JF,detectionPaths:[qn,Qn,hn,Xo,Pa,to,wa],layout:VF,scopeExtras:HF},importer:{rules:[{feature:"rules",mode:"singleFile",source:{project:[tr,Ea],global:[to,tr,Ea]},canonicalDir:Zo,canonicalRootFilename:"_root.md",markAsRoot:true,frontmatterRemap:s(({description:t,globs:e})=>({description:typeof t=="string"?t:void 0,globs:Array.isArray(e)?e:void 0}),"frontmatterRemap")},{feature:"rules",mode:"directory",source:{project:[fn],global:[qn]},canonicalDir:Zo,extensions:[".md"],map:Vc}],commands:{feature:"commands",mode:"directory",source:{project:[gn],global:[Qn]},canonicalDir:Xl,extensions:[".md"],map:Fk},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[La],global:[Xo]},canonicalDir:".agentsmesh",canonicalFilename:l_},ignore:{feature:"ignore",mode:"flatFile",source:{project:[Aa],global:[Pa]},canonicalDir:".agentsmesh",canonicalFilename:c_}},buildImportPaths:Yp,detectionPaths:[".roo/rules",".roo/commands",".roo/skills",".roo/mcp.json",".rooignore",".roorules",oi]};});function jk(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes(wr)),n=e?.body.trim()??"",o=Rt(n,r);return o?[{path:er,content:o}]:[]}function Uk(t){return _t(t,Wt)}function Kk(t){return t.commands.map(e=>({path:`${Wt}/${et(e.name)}/SKILL.md`,content:cr(e)}))}function Wk(t){return t.agents.map(e=>({path:`${Wt}/${H(e.name)}/SKILL.md`,content:te(e)}))}function Bk(t){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let e=JSON.stringify({mcpServers:t.mcp.mcpServers},null,2);return [{path:eo,content:e}]}var zk=f(()=>{ft();he();at();Qt();si();s(jk,"generateRules");s(Uk,"generateSkills");s(Kk,"generateCommands");s(Wk,"generateAgents");s(Bk,"generateMcp");});async function Hk(t,e={}){let r=e.scope??"project",n=[],o=await B(wr,t,r);return n.push(...await q(Yc,t,r,{normalize:o})),await dt(t,r==="global"?ee:Wt,wr,n,o),n}var Vk=f(()=>{gt();ft();Kt();si();Fd();s(Hk,"importFromWarp");});function Jk(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:wr}))}var Yk=f(()=>{Nt();si();s(Jk,"lintRules");});function Xk(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".agentsmesh/hooks.yaml","warp","Warp has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function Zk(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?[]:[G(".agentsmesh/permissions.yaml","warp","Warp permissions are UI-managed; canonical permissions are not projected.")]}function qk(t){return t.ignore.length===0?[]:[G(".agentsmesh/ignore","warp","Warp has no dedicated ignore file and relies on .gitignore; canonical ignore patterns are not projected.")]}var Qk=f(()=>{kt();s(Xk,"lintHooks");s(Zk,"lintPermissions");s(qk,"lintIgnore");});var YF,XF,ZF,qF,QF,Yc,Fd=f(()=>{Qt();at();zk();se();Vk();Yk();Qk();Lt();si();YF={name:wr,primaryRootInstructionPath:er,generateRules:jk,generateCommands:Kk,generateAgents:Wk,generateSkills:Uk,generateMcp:Bk,importFrom:Hk},XF={rootInstructionPath:er,skillDir:Wt,managedOutputs:{dirs:[Wt],files:[er,eo]},paths:{rulePath(t){return er},commandPath(t){return `${Wt}/${et(t)}/SKILL.md`},agentPath(t){return `${Wt}/${H(t)}/SKILL.md`}}},ZF={rootInstructionPath:void 0,skillDir:ee,managedOutputs:{dirs:[ee],files:[]},rewriteGeneratedPath(t){return t.startsWith(`${Wt}/`)?t.replace(`${Wt}/`,`${ee}/`):t},mirrorGlobalPath(t,e){return rt(t,ee,e)},paths:{rulePath(){return ee},commandPath(t){return `${ee}/${et(t)}/SKILL.md`},agentPath(t){return `${ee}/${H(t)}/SKILL.md`}}},qF={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"native",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},QF={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"native",mcp:"none",hooks:"none",ignore:"none",permissions:"none"},Yc={id:wr,generators:YF,capabilities:qF,emptyImportMessage:"No Warp config found (WARP.md, AGENTS.md, .warp/skills, or .mcp.json).",lintRules:Jk,lint:{hooks:Xk,permissions:Zk,ignore:qk},supportsConversion:{commands:true,agents:true},project:XF,globalSupport:{capabilities:QF,detectionPaths:[ee],layout:ZF},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[Xp,er]},canonicalDir:p_,canonicalRootFilename:"_root.md",markAsRoot:true},mcp:{feature:"mcp",mode:"mcpJson",source:{project:[eo]},canonicalDir:".agentsmesh",canonicalFilename:"mcp.json"}},buildImportPaths:Zp,detectionPaths:[er,Xp,eo]};});var $r,vd,mo,tE,_i,Gr,Ii,Si,eE,po,sr,Ci,Md,$d,Gd,jd,Ud,Kd,Ri,Oi,Ga,Xc,Zc,qc,rE,Xt=f(()=>{$r="windsurf",vd=".windsurfrules",mo=".windsurf/rules",tE=".windsurfignore",_i=".codeiumignore",Gr="AGENTS.md",Ii=".windsurf/hooks.json",Si=".windsurf/mcp_config.example.json",eE=".windsurf/mcp_config.json",po=".windsurf/workflows",sr=".windsurf/skills",Ci=".agentsmesh/rules",Md=".agentsmesh/commands",$d=".agentsmesh/agents",Gd=".agentsmesh/skills",jd=".agentsmesh/ignore",Ud=".agentsmesh/hooks.yaml",Kd=".agentsmesh/mcp.json",Ri=".codeium/windsurf/memories/global_rules.md",Oi=".codeium/windsurf/skills",Ga=".codeium/windsurf/global_workflows",Xc=".codeium/windsurf/hooks.json",Zc=".codeium/windsurf/mcp_config.json",qc=".codeium/.codeiumignore",rE=".agents/skills";});function ev(t){let e=basename(t,".md");return e==="_root"?"root":e}function rv(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 Wd(t){let e=[],r=t.rules.find(n=>n.root);if(!r)return [];e.push({path:Gr,content:r.body.trim()});for(let n of t.rules){if(n.root||n.targets.length>0&&!n.targets.includes("windsurf"))continue;let o=ev(n.source),i=n.trigger||(n.globs.length>0?"glob":void 0),a={description:n.description||void 0,trigger:i,glob:n.globs.length===1?n.globs[0]:void 0,globs:n.globs.length>1?n.globs:void 0};Object.keys(a).forEach(m=>{a[m]===void 0&&delete a[m];});let l=Object.keys(a).length>0?N(a,n.body.trim()||""):n.body.trim()||"";e.push({path:`${mo}/${o}.md`,content:l});let c=rv(n.globs);c&&(c!==o&&e.push({path:`${mo}/${c}.md`,content:l}),e.push({path:`${c}/AGENTS.md`,content:n.body.trim()||""}));}return e}var nE=f(()=>{v();Xt();s(ev,"ruleSlug");s(rv,"directoryScopedRuleDir");s(Wd,"generateRules");});function Bd(t){return !t.ignore||t.ignore.length===0?[]:[{path:_i,content:t.ignore.join(`
|
|
120
|
+
`)}]}var oE=f(()=>{Xt();s(Bd,"generateIgnore");});function zd(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?N(r,e.body.trim()||""):e.body.trim();return {path:`${po}/${e.name}.md`,content:n}})}var sE=f(()=>{v();Xt();s(zd,"generateCommands");});function Hd(t){return t.agents.map(e=>({path:`${sr}/${H(e.name)}/SKILL.md`,content:te(e)}))}var iE=f(()=>{at();Xt();s(Hd,"generateAgents");});function Vd(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[{path:Si,content:JSON.stringify({mcpServers:t.mcp.mcpServers},null,2)}]}var aE=f(()=>{Xt();s(Vd,"generateMcp");});function nv(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 ov(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!lr(i))continue;let a=Ct(i),l=zt(i),c=i.type==="prompt"?l||a:a||l;c&&o.push({command:c,show_output:true});}o.length>0&&(e[nv(r)]=o);}return e}function Jd(t){if(!t.hooks||Object.keys(t.hooks).length===0)return [];let e=ov(t.hooks);return Object.keys(e).length===0?[]:[{path:Ii,content:JSON.stringify({hooks:e},null,2)}]}var lE=f(()=>{Fe();Xt();s(nv,"windsurfEventName");s(ov,"toWindsurfHooks");s(Jd,"generateHooks");});function Yd(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?N(n,r.body.trim()||""):r.body.trim()||"";e.push({path:`${sr}/${r.name}/SKILL.md`,content:o});for(let i of r.supportingFiles)e.push({path:`${sr}/${r.name}/${i.relativePath}`,content:i.content});}return e}var cE=f(()=>{v();Xt();s(Yd,"generateSkills");});var mE=f(()=>{nE();oE();sE();iE();aE();lE();cE();});var pE=f(()=>{mE();});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):[]}async function dE(t,e,r){let n=join(t,po),i=(await T(n)).filter(l=>l.endsWith(".md")),a=join(t,Md);for(let l of i){let c=await y(l);if(!c)continue;let m=relative(n,l).replace(/\\/g,"/");await O(a);let p=join(a,m),u=r(c,l,p),{frontmatter:d,body:g}=E(u),h=await tt(p,{description:typeof d.description=="string"?d.description:"",hasDescription:Object.prototype.hasOwnProperty.call(d,"description"),allowedTools:(()=>{let C=uE(d.allowedTools);return C.length>0?C:uE(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:$r,fromPath:l,toPath:`${Md}/${m}`,feature:"commands"});}}var fE=f(()=>{w();v();Z();Xt();s(uE,"toStringArray");s(dE,"importWorkflows");});async function gE(t,e,r,n=sr){let o=join(t,n),i=await ro(o),a={projectRoot:t,sourceSkillsDir:n,destCanonicalSkillsDir:Gd,targetName:"windsurf",normalize:r,results:e};for(let[l,c]of i){let m=join(c,"SKILL.md"),p=await y(m);if(!p)continue;let u=E(p),d=mr(u.frontmatter,l);if(d){await ye(join(t,Gd,l));let g=join(t,$d);await O(g);let h=join(g,`${d.name}.md`);await S(h,ge(d,r(u.body,m,h))),e.push({fromTool:"windsurf",fromPath:m,toPath:`${$d}/${d.name}.md`,feature:"agents"});continue}await Tr(l,c,a);}}var hE=f(()=>{w();v();at();Ds();ai();Xt();s(gE,"importSkills");});async function _E(t,e){let r=join(t,Ii),n=await y(r);if(n)try{let o=JSON.parse(n);if(!o.hooks||typeof o.hooks!="object"||Array.isArray(o.hooks))return;let i=lv(o.hooks);if(Object.keys(i).length===0)return;let a=join(t,Ud);await O(dirname(a)),await S(a,stringify(i)),e.push({fromTool:$r,fromPath:r,toPath:Ud,feature:"hooks"});}catch{}}function av(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 lv(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=av(r),i=[];for(let a of n){if(!a||typeof a!="object")continue;let l=a;if(typeof l.command=="string"&&l.command.trim()){i.push({matcher:".*",type:"command",command:l.command});continue}let c=typeof l.matcher=="string"&&l.matcher.trim()?l.matcher:".*",m=Array.isArray(l.hooks)?l.hooks:[];for(let p of m){if(!p||typeof p!="object")continue;let u=p,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),i.push(g);}}i.length>0&&(e[o]=i);}return e}async function IE(t,e){let r=[Si,eE];for(let n of r){let o=join(t,n),i=await y(o);if(i)try{let a=JSON.parse(i);if(!a.mcpServers||typeof a.mcpServers!="object")continue;let l=join(t,Kd);await O(dirname(l)),await S(l,JSON.stringify({mcpServers:a.mcpServers},null,2)),e.push({fromTool:$r,fromPath:o,toPath:Kd,feature:"mcp"});return}catch{}}}var SE=f(()=>{w();Xt();s(_E,"importWindsurfHooks");s(av,"canonicalHookEventName");s(lv,"windsurfHooksToCanonical");s(IE,"importWindsurfMcp");});async function tm(t,e){let r=e?.scope??"project",n=[],o=await B($r,t),i=await B("codex-cli",t),a=join(t,Ci),l=join(t,vd),c=await y(l);if(c!==null){await O(a);let d=join(a,"_root.md"),g=o(c,l,d).trim(),h=await $(d,{root:true},g);await S(d,h),n.push({fromTool:"windsurf",fromPath:l,toPath:`${Ci}/_root.md`,feature:"rules"});}if(c===null){let d=join(t,Gr),g=await y(d);if(g!==null){await O(a);let h=join(a,"_root.md"),C=o(i(g,d,h),d,h).trim(),R=await $(h,{root:true},C);await S(h,R),n.push({fromTool:"windsurf",fromPath:d,toPath:`${Ci}/_root.md`,feature:"rules"});}}r!=="global"&&n.push(...await nt({srcDir:t,destDir:a,extensions:["AGENTS.md"],fromTool:"windsurf",normalize:o,mapEntry:s(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(!Al(h))return await ye(join(a,`${C}.md`)),null;let R=join(a,`${C}.md`);return {destPath:R,toPath:`${Ci}/${C}.md`,feature:"rules",content:await $(R,{root:false,globs:[`${h}/**`]},g(R))}},"mapEntry")}));let m=join(t,mo);n.push(...await nt({srcDir:m,destDir:a,extensions:[".md"],fromTool:"windsurf",normalize:o,mapEntry:s(async({relativePath:d,normalizeTo:g})=>{if(d==="_root.md"&&c!==null)return null;let h=join(a,d),{frontmatter:C,body:R}=E(g(h)),I={...C};return typeof I.glob=="string"&&I.glob.trim()&&(I.globs=[I.glob],delete I.glob),{destPath:h,toPath:`${Ci}/${d}`,feature:"rules",content:await $(h,{...I,root:false},R)}},"mapEntry")}));let p=join(t,tE),u=await y(p);if((u===null||!u.trim())&&(p=join(t,_i),u=await y(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 O(join(t,".agentsmesh"));let h=join(t,jd);await S(h,g.join(`
|
|
121
|
+
`)),n.push({fromTool:"windsurf",fromPath:p,toPath:jd,feature:"ignore"});}}return await dE(t,n,o),await gE(t,n,o),await _E(t,n),await IE(t,n),n}var Zd=f(()=>{gt();w();v();Z();Ue();Ds();Xt();fE();hE();SE();s(tm,"importFromWindsurf");});function CE(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:$r,message:"Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."}));let i=[];return t.permissions&&(t.permissions.allow.length>0||t.permissions.deny.length>0)&&i.push("permissions"),i.length>0&&n.push({level:"warning",file:".agentsmesh",target:$r,message:`Windsurf cannot project these features yet: ${i.join(", ")}.`}),n}var RE=f(()=>{Xt();s(CE,"lintRules");});function OE(t){return t.commands.filter(e=>e.description.length>0||e.allowedTools.length>0).map(e=>G(e.source,"windsurf","windsurf workflow files are plain Markdown; command description and allowed-tools metadata are not projected."))}function kE(t){return !t.mcp||Object.keys(t.mcp.mcpServers).length===0?[]:[G(".agentsmesh/mcp.json","windsurf","Windsurf MCP is partial; generated .windsurf/mcp_config.example.json is a reference artifact and may require manual setup.")]}var EE=f(()=>{kt();s(OE,"lintCommands");s(kE,"lintMcp");});function dv(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 fv,gv,hv,yv,LE,AE=f(()=>{pE();Co();Xt();se();Zd();RE();EE();Lt();Ps();at();s(dv,"directoryScopedRuleDir");fv={name:"windsurf",primaryRootInstructionPath:Gr,generateRules:Wd,generateCommands:zd,generateAgents:Hd,generateSkills:Yd,generateMcp:Vd,generateHooks:Jd,generateIgnore:Bd,importFrom:tm},gv={rootInstructionPath:Gr,extraRuleOutputPaths(t){if(t.root)return [Gr];let e=dv(t.globs);return e!==null?[`${e}/AGENTS.md`]:[]},skillDir:sr,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 `${mo}/${t}.md`},commandPath(t,e){return `${po}/${t}.md`},agentPath(t,e){return fe(e,"windsurf")?`.windsurf/skills/${H(t)}/SKILL.md`:null}}},hv={rootInstructionPath:Ri,skillDir:Oi,managedOutputs:{dirs:[Oi,Ga,rE],files:[Ri,Xc,Zc,qc]},rewriteGeneratedPath(t){return t===Gr?Ri:t.startsWith(`${mo}/`)||/\/AGENTS\.md$/.test(t)?null:t.startsWith(`${sr}/`)?t.replace(`${sr}/`,`${Oi}/`):t.startsWith(`${po}/`)?t.replace(`${po}/`,`${Ga}/`):t===Ii?Xc:t===Si?Zc:t===_i?qc:t},mirrorGlobalPath(t,e){return rt(t,".codeium/windsurf/skills",e)},paths:{rulePath(t,e){return Ri},commandPath(t,e){return `${Ga}/${t}.md`},agentPath(t,e){return fe(e,"windsurf")?`${Oi}/${H(t)}/SKILL.md`:null}}},yv={rules:"native",additionalRules:"partial",commands:$e("native","workflows"),agents:"embedded",skills:"native",mcp:"partial",hooks:"native",ignore:"native",permissions:"none"},LE={id:"windsurf",generators:fv,capabilities:{rules:"native",additionalRules:"native",commands:$e("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:CE,lint:{commands:OE,mcp:kE},project:gv,globalSupport:{capabilities:yv,detectionPaths:[Ri,Oi,Ga,Xc,Zc,qc],layout:hv},buildImportPaths:qp,detectionPaths:[".windsurfrules",".windsurf"]};});function wE(t){let e=t.rules.find(i=>i.root),r=t.rules.filter(i=>i.root?false:i.targets.length===0||i.targets.includes("zed")),n=e?.body.trim()??"",o=Rt(n,r);return o?[{path:rr,content:o}]:[]}var PE=f(()=>{he();Qo();s(wE,"generateRules");});async function xE(t,e,r){let n=await y(join(t,e));if(n===null)return;let o;try{o=JSON.parse(n);}catch{return}if(o===null||typeof o!="object"||Array.isArray(o))return;let a=o.context_servers;if(a==null||typeof a!="object"||Array.isArray(a)||Object.keys(a).length===0)return;let l={};for(let[c,m]of Object.entries(a)){if(!m||typeof m!="object"||Array.isArray(m))continue;let p={...m};delete p.source,l[c]=p;}Object.keys(l).length!==0&&(await Ut(t,bE,l),r.push({fromTool:"zed",fromPath:e,toPath:bE,feature:"mcp"}));}var bE,TE=f(()=>{w();Yr();Qo();bE=".agentsmesh/mcp.json";s(xE,"importZedMcp");});async function NE(t,e={}){let r=e.scope??"project",n=[],o=await B("zed",t,r);return n.push(...await q(em,t,r,{normalize:o})),await xE(t,r==="global"?br:Pr,n),n}var DE=f(()=>{gt();Kt();TE();Qo();qd();s(NE,"importFromZed");});function FE(t,e,r,n){return X(t,e,r,{checkGlobMatches:n?.scope!=="global"}).map(o=>({...o,target:"zed"}))}var vE=f(()=>{Nt();Qo();s(FE,"lintRules");});function ME(t){return t.hooks?Object.values(t.hooks).some(r=>Array.isArray(r)&&r.length>0)?[G(".agentsmesh/hooks.yaml","zed","Zed has no lifecycle hook system; canonical hooks are not projected.")]:[]:[]}function $E(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?[]:[G(".agentsmesh/permissions.yaml","zed","Zed permissions are managed via agent.tool_permissions in settings.json; canonical permissions are not projected.")]}function GE(t){return t.ignore.length===0?[]:[G(".agentsmesh/ignore","zed","Zed has no dedicated ignore file and relies on file_scan_exclusions in settings.json; canonical ignore patterns are not projected.")]}var jE=f(()=>{kt();s(ME,"lintHooks");s($E,"lintPermissions");s(GE,"lintIgnore");});function kv(t,e){if(t===null)return e;let r;try{let i=JSON.parse(t);r=i!==null&&typeof i=="object"&&!Array.isArray(i)?i:{};}catch{r={};}let n=JSON.parse(e);if(n===null||typeof n!="object"||Array.isArray(n))return t;let o=n;return o.context_servers!==void 0&&(r.context_servers=o.context_servers),JSON.stringify(r,null,2)}var Iv,Sv,Cv,Rv,Ov,em,qd=f(()=>{PE();DE();vE();jE();Lt();Qo();Iv={name:"zed",primaryRootInstructionPath:rr,generateRules:wE,importFrom:NE},Sv={rootInstructionPath:rr,managedOutputs:{dirs:[],files:[rr,Pr]},paths:{rulePath(t){return rr},commandPath(){return null},agentPath(){return null}}},Cv={rootInstructionPath:void 0,managedOutputs:{dirs:[],files:[br]},rewriteGeneratedPath(t){return t===Pr?br:t},paths:{rulePath(){return br},commandPath(){return null},agentPath(){return null}}},Rv={rules:"native",additionalRules:"embedded",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"},Ov={rules:"none",additionalRules:"none",commands:"none",agents:"none",skills:"none",mcp:"native",hooks:"none",ignore:"none",permissions:"none"};s(kv,"mergeZedSettings");em={id:"zed",generators:Iv,capabilities:Rv,emptyImportMessage:"No Zed config found (.rules or .zed/settings.json).",lintRules:FE,lint:{hooks:ME,permissions:$E,ignore:GE},project:Sv,globalSupport:{capabilities:Ov,detectionPaths:[br],layout:Cv},importer:{rules:{feature:"rules",mode:"singleFile",source:{project:[rr],global:[]},canonicalDir:f_,canonicalRootFilename:"_root.md",markAsRoot:true}},emitScopedSettings(t,e){if(!t.mcp||Object.keys(t.mcp.mcpServers).length===0)return [];let r={};for(let[n,o]of Object.entries(t.mcp.mcpServers))r[n]=o;return [{path:Pr,content:JSON.stringify({context_servers:r},null,2)}]},mergeGeneratedOutputContent(t,e,r,n){return n===Pr||n===br?kv(t,r):null},buildImportPaths:Qp,detectionPaths:[rr,Pr]};});var _y={};LP(_y,{BUILTIN_TARGETS:()=>Gt,TARGET_IDS:()=>xt,getBuiltinTargetDefinition:()=>Pe,getEffectiveTargetSupportLevel:()=>rm,getTargetCapabilities:()=>lo,getTargetDetectionPaths:()=>tf,getTargetLayout:()=>wt,getTargetManagedOutputs:()=>ef,getTargetPrimaryRootInstructionPath:()=>Lv,getTargetSkillDir:()=>Ua,isBuiltinTargetId:()=>bn,resolveTargetFeatureGenerator:()=>ki,rewriteGeneratedOutputPath:()=>rf});function Ev(){return Qd||(Ah(Gt),Qd=new Map(Gt.map(t=>[t.id,t]))),Qd}function Pe(t){return Ev().get(t)}function lo(t,e="project"){let r=Pe(t)??ot(t);if(!r)return;let n=e==="global"?r.globalSupport?.capabilities??r.capabilities:r.capabilities;return Eh(n)}function tf(t,e="project"){let r=Pe(t)??ot(t);return r?e==="global"?r.globalSupport?.detectionPaths??[]:r.detectionPaths:[]}function wt(t,e="project"){let r=Pe(t)??ot(t);if(r)return e==="global"?r.globalSupport?.layout:r.project}function Lv(t,e="project"){return wt(t,e)?.rootInstructionPath}function Ua(t,e="project"){return wt(t,e)?.skillDir}function ef(t,e="project"){return wt(t,e)?.managedOutputs}function rf(t,e,r="project"){let n=wt(t,r);return n?n.rewriteGeneratedPath?n.rewriteGeneratedPath(e):e:null}function UE(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?!ws(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?!fe(r,t.id,true,n):false}function Av(t,e,r,n){return !t||!r?false:e==="commands"&&t.supportsConversion?.commands?ws(r,t.id,true,n):e==="agents"&&t.supportsConversion?.agents?fe(r,t.id,true,n):false}function rm(t,e,r,n="project"){let o=lo(t,n)?.[e]?.level??"none",i=Pe(t)??ot(t);return o==="none"&&Av(i,e,r,n)?"embedded":o!=="embedded"?o:UE(i,e,r,n)?"none":o}function ki(t,e,r,n="project"){let o=Pe(t)??ot(t);if(!o?.generators||UE(o,e,r,n))return;let i=wv[e];return i===null?void 0:i(o.generators)}var Gt,Qd,wv,ct=f(()=>{Ps();Co();Ur();tp();Br();up();eu();nu();vI();RS();Au();Du();Yu();gd();yd();Id();Ed();wd();bd();Dd();Fd();AE();qd();Gt=[wl,Zl,ql,FI,CS,pc,_c,Ac,vc,Mc,Gc,Wc,zc,Hc,Jc,Yc,LE,em];s(Ev,"builtinTargetsMap");s(Pe,"getBuiltinTargetDefinition");s(lo,"getTargetCapabilities");s(tf,"getTargetDetectionPaths");s(wt,"getTargetLayout");s(Lv,"getTargetPrimaryRootInstructionPath");s(Ua,"getTargetSkillDir");s(ef,"getTargetManagedOutputs");s(rf,"rewriteGeneratedOutputPath");s(UE,"isFeatureSuppressedByConversion");s(Av,"isConversionUpgrading");s(rm,"getEffectiveTargetSupportLevel");wv={rules:s(t=>t.generateRules,"rules"),additionalRules:null,commands:s(t=>t.generateCommands,"commands"),agents:s(t=>t.generateAgents,"agents"),skills:s(t=>t.generateSkills,"skills"),mcp:s(t=>t.generateMcp,"mcp"),permissions:s(t=>t.generatePermissions,"permissions"),hooks:s(t=>t.generateHooks,"hooks"),ignore:s(t=>t.generateIgnore,"ignore")};s(ki,"resolveTargetFeatureGenerator");});function Fv(t){return typeof t=="string"?t:t.level}function KE(t){return Dv.includes(t)}function WE(t,e,r,n){for(let o of Nv){let i=Fv(e[o.feature]);if(i==="none")continue;let a=typeof t.generators[o.generator]=="function",l=KE(o.feature)&&typeof t.emitScopedSettings=="function";a||l||r.addIssue({code:"custom",path:[...n,o.feature],message:`Capability "${o.feature}" is "${i}" but generators.${o.generator}`+(KE(o.feature)?" or emitScopedSettings":"")+" is missing."});}}function nm(t){return Mv.parse(t)}var En,BE,Pv,bv,zE,xv,Tv,Nv,Dv,vv,Mv,nf=f(()=>{En=z.union([z.enum(["native","embedded","partial","none"]),z.object({level:z.enum(["native","embedded","partial","none"]),flavor:z.string().optional()})]),BE=z.object({rules:En,additionalRules:En,commands:En,agents:En,skills:En,mcp:En,hooks:En,ignore:En,permissions:En}),Pv=z.object({name:z.string(),generateRules:z.function(),importFrom:z.function(),generateCommands:z.function().optional(),generateAgents:z.function().optional(),generateSkills:z.function().optional(),generateMcp:z.function().optional(),generatePermissions:z.function().optional(),generateHooks:z.function().optional(),generateIgnore:z.function().optional(),lint:z.function().optional()}).passthrough(),bv=z.object({rulePath:z.function(),commandPath:z.function(),agentPath:z.function()}),zE=z.object({paths:bv}).passthrough(),xv=z.object({capabilities:BE,detectionPaths:z.array(z.string()),layout:zE,scopeExtras:z.function().optional()}).passthrough(),Tv=["global","globalCapabilities","globalDetectionPaths","generateScopeExtras"],Nv=[{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"}],Dv=["mcp","hooks","ignore","permissions"];s(Fv,"capabilityLevel");s(KE,"canUseScopedSettings");s(WE,"validateCapabilityImplementations");vv=z.object({id:z.string().regex(/^[a-z][a-z0-9-]*$/,"Target id must be lowercase with hyphens"),generators:Pv,capabilities:BE,emptyImportMessage:z.string(),lintRules:z.union([z.function(),z.null()]),project:zE,globalSupport:xv.optional(),buildImportPaths:z.function(),detectionPaths:z.array(z.string())}).passthrough(),Mv=vv.superRefine((t,e)=>{for(let r of Tv)r in t&&e.addIssue({code:"custom",path:[r],message:`Use globalSupport instead of legacy field "${r}".`});WE(t,t.capabilities,e,["capabilities"]),t.globalSupport!==void 0&&WE(t,t.globalSupport.capabilities,e,["globalSupport","capabilities"]);});s(nm,"validateDescriptor");});function $v(){return of||(of=new Map(Gt.map(t=>[t.id,t]))),of}function VE(t){let e=nm(t);HE.set(e.id,e);}function ot(t){return HE.get(t)??$v().get(t)}var HE,of,Ur=f(()=>{ct();nf();HE=new Map;s($v,"builtinDescriptors");s(VE,"registerTargetDescriptor");s(ot,"getDescriptor");});async function JE(t,e,r="project"){let n=new Map,o=ot(t);return o&&await o.buildImportPaths(n,e,r),n}var YE=f(()=>{Ur();s(JE,"buildImportReferenceMap");});function Uv(t){let e=[t.project,t.globalSupport?.layout].filter(o=>o!==void 0),r=[...t.detectionPaths,...e.flatMap(o=>o.managedOutputs?.dirs??[]),...e.flatMap(o=>o.managedOutputs?.files??[])],n=new Set;for(let o of r){let i=o.split("/")[0];i&&i.startsWith(".")&&i.length>1&&n.add(`${i}/`);}return n}function Kv(){let t=new Set([".agentsmesh/"]);for(let e of Gt)for(let r of Uv(e))t.add(r);return Array.from(t)}function Wv(){let t=new Set([...Kv(),...sf.rootRelativePrefixes]),e=new Set([...jv,...sf.meshRootSegments]);return {protectedSchemes:[...Gv,...sf.protectedSchemes],rootRelativePrefixes:Array.from(t),meshRootSegments:e}}function om(){return af||(af=Wv()),af}var Gv,jv,sf,af,XE=f(()=>{ct();Gv=[/\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],jv=new Set(["skills","rules","commands","agents","packs"]),sf={protectedSchemes:[],rootRelativePrefixes:[],meshRootSegments:[]};s(Uv,"topLevelDotfilePrefixes");s(Kv,"buildDefaultRootRelativePrefixes");s(Wv,"rebuild");s(om,"getLinkFormatRegistry");});function ir(t){let e=it(t);return om().rootRelativePrefixes.some(r=>e.startsWith(r))}function zv(t){let e=it(t).replace(/^\.\//,"");if(e.startsWith("../")||e.startsWith("/")||ve.test(e)||/^[a-zA-Z]:/.test(e)||ir(e))return false;let r=e.split("/").filter(n=>n.length>0)[0];return r!==void 0&&om().meshRootSegments.has(r)}function Ka(t,e,r){let n=V(e),o=j(e,e),i=j(e,r),a=it(t);if(ve.test(t)){let l=j(e,t);return n===win32||l.startsWith(`${o}${n.sep}`)?[l]:[l]}if(n.isAbsolute(t)){let l=j(e,t);return l.startsWith(o)||existsSync(t)?[l]:[j(e,n.join(e,t))]}if(a.startsWith("./")||a.startsWith("../")){let l=j(e,n.join(n.dirname(i),a)),c=Ch(a,o);return c&&c!==l?[l,c]:[l]}if(ir(a))return [j(e,n.join(o,a))];if(a.includes("/")){let l=j(e,n.join(o,".agentsmesh")),c=zv(a)?j(e,n.join(l,a)):null,m=j(e,n.join(o,a)),p=j(e,n.join(n.dirname(i),a));return c!==null?[c,m,p]:[m,p]}return Hv.has(a)?[]:a.includes(".")?[j(e,n.join(n.dirname(i),a))]:[]}function Wa(t,e){let r=[e];if(!Sh(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 tL(t,e,r){let n=e>0?t.at(e-1):"",o=r<t.length?t.at(r):"";return n==="*"||o==="*"}function sm(t){let e=[];for(let r of om().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(Vv))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(Jv))e.push([r.index??0,(r.index??0)+r[0].length]);for(let r of t.matchAll(Yv))e.push([r.index??0,(r.index??0)+r[0].length]);return e}var Hv,Vv,Jv,Yv,QE,Ei,uo=f(()=>{$t();XE();s(ir,"isRootRelativePathToken");s(zv,"isMeshRootRelativePathToken");Hv=new Set(["AGENTS.md","CLAUDE.md","GEMINI.md","codex.md",".windsurfrules",".cursorrules"]),Vv=/^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm,Jv=/<!-- agentsmesh:root-generation-contract:start -->[\s\S]*?<!-- agentsmesh:root-generation-contract:end -->/g,Yv=/<!-- agentsmesh:embedded-rules:start -->[\s\S]*?<!-- agentsmesh:embedded-rules:end -->/g,QE=/(?:\.\.[\\/]|\.\/|\.\\|\/[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,Ei=/(?::(\d+)){1,2}$/;s(Ka,"resolveProjectPath");s(Wa,"expandResolvedPaths");s(tL,"isGlobAdjacent");s(sm,"protectedRanges");});function Xv(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 eL(t){return Xv(t.tokenContext)}function lf(t,e){let r=V(t),n=j(t,t),o=j(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function rL(t){let e=V(t);return j(t,e.join(t,".agentsmesh"))}function ar(t,e){let r=V(t),n=rL(t),o=j(t,e);if(o===n)return true;let i=n.endsWith(r.sep)?n:`${n}${r.sep}`;return o.startsWith(i)}function nL(t,e,r){let n=V(t),o=rL(t),i=j(t,e);if(!ar(t,i))return null;let a=n.relative(o,i).replace(/\\/g,"/");return a.startsWith("..")||a.length===0?null:r&&!a.endsWith("/")?`${a}/`:a}function cf(t,e,r){let o=V(t).relative(j(t,t),j(t,e)).replace(/\\/g,"/");if(o.startsWith(".."))return null;let i=o.length>0?o:".";return r&&!i.endsWith("/")?`${i}/`:i}function Li(t,e,r){let n=cf(t,e,r);return n===null?null:{kind:"projectRoot",rest:n,text:n}}function mf(t,e,r,n,o){let i=V(t),a=j(t,t),l=j(t,e),c=j(t,r);if(!lf(t,c))return Li(t,c,n)?.text??null;let m=j(t,i.dirname(l));if(!lf(t,m)&&m!==a)return Li(t,c,n)?.text??null;let p=i.relative(m,c).replace(/\\/g,"/");if(i.isAbsolute(p)||ve.test(p))return cf(t,c,n);let u=j(t,i.join(m,p));return lf(t,u)?(p===""||p==="."?p=".":o.explicitCurrentDirLinks===true&&m!==a&&!p.startsWith("../")&&!p.startsWith("./")&&(p=`./${p}`),n&&!p.endsWith("/")?`${p}/`:p):cf(t,c,n)}var pf=f(()=>{$t();s(Xv,"isReadingContext");s(eL,"isReadingContextOptions");s(lf,"isUnderProjectRoot");s(rL,"agentsMeshRoot");s(ar,"isUnderAgentsMesh");s(nL,"toAgentsMeshRootRelative");s(cf,"toProjectRootRelative");s(Li,"toProjectRootReference");s(mf,"formatLinkPathForDestinationLegacy");});function oL(t,e,r,n,o={}){let i=o.scope??"project",a=j(t,r);if(eL(o)&&ar(t,e)&&ar(t,a)){let m=V(t),p=j(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 mf(t,e,r,n,o);if(i==="global"&&!ar(t,e))return Li(t,a,n)?.text??null;let l=(()=>{if(ar(t,a))return a;let m=o.logicalMeshSourceAbsolute;return m&&ar(t,j(t,m))?j(t,m):null})();if(!l)return Li(t,a,n)?.text??null;if(n||(o.pathIsDirectory?.(a)??false)){let m=nL(t,l,n);return m!==null?m:Li(t,l,n)?.text??null}return mf(t,e,r,n,o)}var sL=f(()=>{uo();$t();pf();pf();s(oL,"formatLinkPathForDestination");});function iL(t,e,r,n){let o=V(e),i=it(t);if(!ir(i))return null;let a=i.split("/").filter(m=>m.length>0);if(a.length<3)return null;let l=j(e,r),c=o.dirname(l);for(let m=1;m<=a.length-1;m++){let p=a.slice(m).join("/"),u=j(e,o.join(c,p));if(u!==l&&n(u))return u}return null}var aL=f(()=>{$t();uo();s(iL,"resolveByDestinationSuffixStrip");});function lL(t){let e=null,r=false,n=null,o=null,i=null;for(let c of Ka(t.candidate,t.projectRoot,t.sourceFile)){let m=null,p=null;for(let u of Wa(t.projectRoot,c)){let d=j(t.projectRoot,u),g=j(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,i=p),r)break}if(!r){let c=iL(t.candidate,t.projectRoot,t.destinationFile,t.pathExists);c!==null&&(e=c,r=true);}!r&&o!==null&&(e=o,i!==null&&(n=i),r=true);let a=it(t.destinationFile),l=a.includes("/.agentsmesh/")||a.startsWith(".agentsmesh/");return !r&&e!==null&&it(t.rawToken).startsWith(".agentsmesh/")&&l&&(r=true),{translatedPath:e,resolvedBeforeTranslate:n,matchedPath:r}}var cL=f(()=>{$t();uo();aL();s(lL,"resolveLinkTarget");});function mL(t,e,r){return e>=2&&t[e-2]==="~"&&t[e-1]==="/"?true:e>=1&&t[e-1]==="~"&&r.startsWith("/")}function pL(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 uL(t){let e=it(t);return e.startsWith("./")||e.startsWith("../")?true:e.startsWith("/")||ve.test(e)||ir(e)?false:e.includes("/")}var dL=f(()=>{$t();uo();s(mL,"isTildeHomeRelativePathToken");s(pL,"isMarkdownLinkDestinationToken");s(uL,"isRelativePathToken");});function Zv(t,e,r){let n=e+r.length;if(t[n]!=="]"||t[n+1]!=="(")return false;let o=n+2,i="";for(;o<t.length;){let a=t[o];if(a===")"||a==="#"||a==="?"||a===" "||a===" "||a===`
|
|
122
|
+
`)break;i+=a,o++;}return i===r}function fL(t,e,r){let n=t.lastIndexOf(`
|
|
123
|
+
`,e-1)+1,o=t.slice(n,e);if(!/^\s*\[[^\]\n]+\]:\s*<?\s*$/.test(o))return false;let i=r<t.length?t[r]:"";return i===""||i===`
|
|
124
|
+
`||i==="\r"||i===">"||i===" "||i===" "||i==='"'||i==="'"||i===":"||i==="#"||i==="?"}function gL(t,e,r){let n=e>0?t[e-1]:"",o=r<t.length?t[r]:"";return n==="`"&&o==="`"?{role:"inline-code"}:fL(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 hL(t,e,r,n,o){if(e<0||r>t.length)return false;let{candidate:i}=As(n),a=i.replace(Ei,""),l=it(a),c=e+a.length,m=t[e-1],p=t[r];return fL(t,e,c)||m==="'"&&p==="'"||m==='"'&&p==='"'||m==="`"&&p==="`"||m==="<"&&p===">"?true:m==="["&&p==="]"?!(!o&&!ir(l)&&Zv(t,e,n)):m==="@"?true:m==="("?p===")"||p==="#"||p==="?"||p===" "||p===" ":o?ir(l)?true:l.includes("/")||l.includes("\\")?l.startsWith("./")||l.startsWith("../")?true:(l.split(/[\\/]/).filter(Boolean).at(-1)??"").includes("."):false:false}var yL=f(()=>{$t();uo();s(Zv,"markdownBracketLabelDuplicatesDestination");s(fL,"isMarkdownReferenceDefinitionDestination");s(gL,"getTokenContext");s(hL,"shouldRewritePathToken");});function im(t){let e=new Set,r=sm(t.content);return {content:t.content.replace(QE,(o,i,a)=>{if(r.some(([Pt,oe])=>i>=Pt&&i<oe)||!hL(a,i,i+o.length,o,t.rewriteBarePathTokens===true)||mL(a,i,o)||tL(a,i,i+o.length))return o;let{candidate:l,suffix:c}=As(o);if(!l)return o;let m=Ei.exec(l),p=m?l.slice(0,m.index):l,u=m?m[0]:"";if(!p)return o;let d=gL(a,i,i+p.length);if(d.role!=="markdown-link-dest"&&ve.test(p))return o;let{translatedPath:g,resolvedBeforeTranslate:h,matchedPath:C}=lL({candidate:p,rawToken:l,projectRoot:t.projectRoot,sourceFile:t.sourceFile,destinationFile:t.destinationFile,translatePath:t.translatePath,pathExists:t.pathExists}),R=h;if(!C||!g)return g&&e.add(g),o;let I=it(p),k=p.endsWith("/")||t.pathIsDirectory?.(g)===true;if(k&&!I.includes("/")&&!I.includes("\\"))return o;if(R===null){let Pt=it(l);if(Pt.startsWith("agentsmesh/")&&(Pt=`.${Pt}`),Pt.startsWith(".agentsmesh/")||Pt.includes("/.agentsmesh/")){let oe=V(t.projectRoot),pl=j(t.projectRoot,t.projectRoot),ue=Pt.replace(/^\.\//,"");R=j(t.projectRoot,oe.join(pl,ue));}}let D=V(t.projectRoot);if(t.scope==="global"){let Pt=it(l),oe=Pt.startsWith(".agentsmesh/")||Pt.includes("/.agentsmesh/"),pl=ir(Pt)||uL(Pt),ue=R!==null&&ar(t.projectRoot,R),Cg=ar(t.projectRoot,g);if(R===g&&!Cg&&!ue&&!oe){let Rg=it(D.relative(t.projectRoot,j(t.projectRoot,t.sourceFile))).split("/").filter(Boolean)[0]??"",EP=(R!==null?it(D.relative(t.projectRoot,R)):"").split("/").filter(Boolean)[0]??"";if(Rg.length>0&&Rg===EP)return o}if(!pl&&!oe&&!ue&&!Cg)return o}let P=j(t.projectRoot,t.destinationFile),b=j(t.projectRoot,g),Y=it(D.relative(t.projectRoot,P)),U=it(D.relative(t.projectRoot,b)),z=Y.split("/").filter(Boolean)[0]??"",st=U.split("/").filter(Boolean)[0]??"",ne=!it(p).startsWith(".agentsmesh/")&&!k&&z.length>0&&z===st&&z.startsWith(".")&&z!==".agentsmesh"||d.role==="markdown-link-dest"||pL(a,i,p),ht=oL(t.projectRoot,t.destinationFile,g,p.endsWith("/"),{explicitCurrentDirLinks:t.explicitCurrentDirLinks===true||ne,scope:t.scope??"project",pathIsDirectory:t.pathIsDirectory,logicalMeshSourceAbsolute:k?null:R,forceRelative:ne,tokenContext:d,originalToken:p});return ht?`${ht}${u}${c}`:o}),missing:[...e]}}var uf=f(()=>{$t();uo();sL();cL();dL();yL();s(im,"rewriteFileLinks");});function IL(t,e){let r=[t.normalize(e)];if(!existsSync(e))return r;try{let n=[realpathSync(e),realpathSync.native(e)];for(let o of n){let i=t.normalize(o);r.includes(i)||r.push(i);}}catch{}return r}async function B(t,e,r="project"){let n=V(e),o=new Map,i=Array.from(new Set([t,...xt]));for(let c of i){let m=await JE(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 IL(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 IL(n,m))l.add(n.normalize(p));}return (c,m,p)=>im({content:c,projectRoot:e,sourceFile:m,destinationFile:p,translatePath:s(u=>a.get(u)??u,"translatePath"),pathExists:s(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:s(u=>{try{return statSync(u).isDirectory()}catch{return false}},"pathIsDirectory")}).content}var gt=f(()=>{$t();YE();uf();Br();s(IL,"pathVariants");s(B,"createImportReferenceNormalizer");});function CL(t){let e={};for(let[r,n]of Object.entries(t)){if(!Array.isArray(n))continue;let o=[];for(let i of n){if(!i||typeof i!="object")continue;let a=i,l=typeof a.matcher=="string"?a.matcher:"";if(!l)continue;let c=Array.isArray(a.hooks)?a.hooks:[];for(let m of c){let p=m.type==="prompt"?"prompt":"command";if(!lr({...m,type:p}))continue;let u=p==="prompt"?zt(m)||Ct(m):Ct(m)||zt(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 RL(t,e){let r=join(t,Qr),n=await y(r);if(n===null)return false;let o;try{o=JSON.parse(n);}catch{return false}if(!o||typeof o!="object"||Array.isArray(o))return false;let i=CL(o);if(Object.keys(i).length===0)return false;let a=stringify(i),l=join(t,Lo);return await O(dirname(l)),await S(l,a),e.push({fromTool:"claude-code",fromPath:r,toPath:Lo,feature:"hooks"}),true}async function OL(t,e){let r=e.some(m=>m.feature==="hooks"&&m.fromPath.replace(/\\/g,"/").endsWith(Qr)),n=join(t,oa),o=await y(n);if(!o)return;let i;try{i=JSON.parse(o);}catch{return}if(!e.some(m=>m.feature==="mcp")&&i.mcpServers&&typeof i.mcpServers=="object"){let m=i.mcpServers;await Ut(t,la,m),e.push({fromTool:"claude-code",fromPath:n,toPath:la,feature:"mcp"});}let l=i.permissions;if(l&&typeof l=="object"&&!Array.isArray(l)){let m=l,p=Array.isArray(m.allow)?m.allow.filter(g=>typeof g=="string"):[],u=Array.isArray(m.deny)?m.deny.filter(g=>typeof g=="string"):[],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,Cp);await O(dirname(h)),await S(h,g),e.push({fromTool:"claude-code",fromPath:n,toPath:Cp,feature:"permissions"});}}let c=i.hooks;if(!r&&c&&typeof c=="object"&&!Array.isArray(c)){let m=CL(c);if(Object.keys(m).length>0){let p=stringify(m),u=join(t,Lo);await O(dirname(u)),await S(u,p),e.push({fromTool:"claude-code",fromPath:n,toPath:Lo,feature:"hooks"});}}}var kL=f(()=>{Fe();w();Yr();tn();s(CL,"claudeHooksToCanonical");s(RL,"importClaudeHooksJson");s(OL,"importSettings");});async function LL(t,e,r){let n=join(t,na),o=join(t,Sp),a=(await T(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 T(c);for(let d of u){let g=await y(d);if(g===null)continue;let h=relative(c,d),C=join(p,h);await O(dirname(C));let R=r(g,d,C),I=h==="SKILL.md"?E(R):null;await S(C,h==="SKILL.md"?await pr(C,I?.frontmatter??{},I?.body??""):R);let k=`${Sp}/${m}/${h}`;e.push({fromTool:"claude-code",fromPath:d,toPath:k,feature:"skills"});}}}var AL=f(()=>{w();v();Z();tn();s(LL,"importClaudeSkills");});async function Ql(t,e={}){let r=e.scope??"project",n=[],o=await B("claude-code",t,r);return n.push(...await q(ql,t,r,{normalize:o})),await LL(t,n,o),await RL(t,n),await OL(t,n),n}var ou=f(()=>{gt();Kt();kL();AL();nu();s(Ql,"importFromClaudeCode");});function kg(t){let e=Object.keys(t);return {async route(r,n,o){let i=t[r];if(i){await i(n,o);return}throw new Error(`Unknown command "${r}". Available: ${e.join(", ")}`)},commands:s(()=>[...e],"commands")}}s(kg,"createRouter");var Is={green:"\x1B[32m",red:"\x1B[31m",yellow:"\x1B[33m",cyan:"\x1B[36m",reset:"\x1B[0m"};function AP(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}s(AP,"noColor");function vi(t,e){return AP()?e:`${t}${e}${Is.reset}`}s(vi,"c");function wP(t,e){let r=[...t].length;return t+" ".repeat(Math.max(0,e-r))}s(wP,"pad");var _={info(t){process.stdout.write(vi(Is.cyan,t)+`
|
|
125
|
+
`);},warn(t){process.stderr.write(vi(Is.yellow,"\u26A0 ")+t+`
|
|
126
|
+
`);},error(t){process.stderr.write(vi(Is.red,"\u2717 ")+t+`
|
|
127
|
+
`);},success(t){process.stdout.write(vi(Is.green,"\u2713 ")+t+`
|
|
128
|
+
`);},debug(t){process.env.AGENTSMESH_DEBUG==="1"&&process.stdout.write(vi(Is.cyan,"[debug] ")+t+`
|
|
129
|
+
`);},table(t){if(t.length===0)return;let e=t[0].length,r=[];for(let o=0;o<e;o++){let i=0;for(let a=0;a<t.length;a++){let l=[...t[a][o]].length;l>i&&(i=l);}r[o]=i;}let n="+"+r.map(o=>"-".repeat(o+2)).join("+")+"+";process.stdout.write(n+`
|
|
130
|
+
`);for(let o=0;o<t.length;o++){let a="| "+t[o].map((l,c)=>wP(l,r[c])).join(" | ")+" |";process.stdout.write(a+`
|
|
130
131
|
`);}process.stdout.write(n+`
|
|
131
|
-
`);}};var
|
|
132
|
-
`)}
|
|
132
|
+
`);}};var Eg=[{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"}],Lg=[{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 Ag(t,e=18){return t.length===0?" (no command-specific flags)":t.map(r=>` ${r.name.padEnd(e)}${r.description}`).join(`
|
|
133
|
+
`)}s(Ag,"formatFlags");function wg(){let t=Lg.map(e=>`- ${e.name.padEnd(8)} ${e.description}
|
|
133
134
|
Usage: ${e.usage}
|
|
134
|
-
${
|
|
135
|
+
${Ag(e.flags)}`).join(`
|
|
135
136
|
|
|
136
|
-
`);
|
|
137
|
+
`);_.info(`agentsmesh <command> [flags]
|
|
137
138
|
|
|
138
139
|
Global flags:
|
|
139
|
-
${
|
|
140
|
+
${Ag(Eg)}
|
|
140
141
|
|
|
141
142
|
Commands:
|
|
142
143
|
${t}
|
|
143
144
|
|
|
144
|
-
Tip: run "agentsmesh <command> --help" for this same command reference.`);}
|
|
145
|
-
`);}
|
|
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.`);}s(wg,"printHelp");var TP=createRequire(import.meta.url),Dm=dirname(fileURLToPath(import.meta.url)),NP=Dm.endsWith("dist")?join(Dm,"..","package.json"):join(Dm,"..","..","package.json"),bg=TP(NP);function Mi(){return bg.version}s(Mi,"getVersion");function xg(){process.stdout.write(`agentsmesh v${bg.version}
|
|
146
|
+
`);}s(xg,"printVersion");function Tg(t,e){e?.verbose&&t.stack?process.stderr.write(t.stack+`
|
|
147
|
+
`):_.error(t.message),process.exit(1);}s(Tg,"handleError");w();$i();Br();var $g=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],de=z.enum(xt),Cs=z.enum($g),Ui=z.object({skills:z.array(z.string()).optional(),commands:z.array(z.string()).optional(),rules:z.array(z.string()).optional(),agents:z.array(z.string()).optional()}).strict(),qP=z.object({name:z.string(),source:z.string(),version:z.string().optional(),target:de.optional(),features:z.array(Cs),path:z.string().optional(),pick:Ui.optional()}),QP=z.object({strategy:z.enum(["merge","lock","last-wins"]).default("merge"),lock_features:z.array(z.string()).default([])}),ji=z.union([z.boolean(),z.object({project:z.boolean().optional(),global:z.boolean().optional()}).strict()]),tb=z.object({commands_to_skills:z.object({"codex-cli":ji.optional()}).passthrough().optional(),agents_to_skills:z.object({"gemini-cli":ji.optional(),cline:ji.optional(),"codex-cli":ji.optional(),windsurf:ji.optional()}).passthrough().optional()}).strict().optional(),eb=z.object({id:z.string().regex(/^[a-z][a-z0-9-]*$/),source:z.string(),version:z.string().optional()}).strict(),Gm=z.object({version:z.literal(1),targets:z.array(de).default([...xt]),features:z.array(Cs).default([...$g]),extends:z.array(qP).default([]),overrides:z.record(z.string(),z.record(z.string(),z.unknown())).default({}),collaboration:QP.default({strategy:"merge",lock_features:[]}),conversions:tb,plugins:z.array(eb).default([]),pluginTargets:z.array(z.string().regex(/^[a-z][a-z0-9-]*$/)).default([])});var Um="agentsmesh.yaml",nb="agentsmesh.local.yaml";async function ob(t){let e=resolve(t);for(;;){let r=join(e,Um);if(await F(r))return r;let n=dirname(e);if(n===e)return null;e=n;}}s(ob,"findConfigPath");async function sb(t){let e=await y(t);if(e===null)throw new Pn(t);let r=parse(e),n=Gm.safeParse(r);if(!n.success){let o=n.error.issues.map(i=>i.message);throw new ul(t,o,{cause:n.error})}return n.data}s(sb,"loadConfig");function jm(t,e){let r={...t};for(let[n,o]of Object.entries(e)){if(o==null)continue;let i=r[n];typeof o=="object"&&!Array.isArray(o)&&o!==null&&typeof i=="object"&&i!==null&&!Array.isArray(i)?r[n]=jm(i,o):r[n]=o;}return r}s(jm,"deepMergeObjects");function ib(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=jm(r.overrides??{},e.overrides)),typeof e.conversions=="object"&&e.conversions!==null&&!Array.isArray(e.conversions)&&(r.conversions=jm(r.conversions??{},e.conversions)),Array.isArray(e.extends)&&e.extends.length>0&&(r.extends=[...t.extends??[],...e.extends]),r}s(ib,"mergeLocalConfig");async function Km(t){let e=join(t,Um),r=await sb(e),n=join(t,nb),o=await y(n);if(o!==null){let i=parse(o);if(typeof i=="object"&&i!==null&&!Array.isArray(i)){let a=ib(r,i),l=Gm.safeParse(a);if(l.success)r=l.data;else {let c=l.error.issues.map(m=>m.message).join("; ");_.warn(`Ignoring invalid agentsmesh.local.yaml at ${n}: ${c}. Using project config instead.`);}}}return {config:r,configDir:t}}s(Km,"loadConfigFromExactDir");async function Ug(t){let e=await ob(t);if(e===null)throw new Pn(join(t,Um));return Km(dirname(e))}s(Ug,"loadConfigFromDir");$i();function Ki(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}}s(Ki,"resolveScopeContext");async function yt(t,e="project"){if(e==="project"){let{config:n,configDir:o}=await Ug(t);return {config:n,context:{scope:e,rootBase:o,configDir:o,canonicalDir:join(o,".agentsmesh")}}}let r=Ki(t,e);try{let{config:n}=await Km(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}}s(yt,"loadScopedConfig");w();w();var db=promisify(execFile),Kg="repo";async function gl(t,e,r,n,o){let i="cloneUrl"in t?"gitlab":"git",a="cloneUrl"in t?`${t.namespace}/${t.project}`:t.url,l=t.ref??"HEAD",c=o(i,a,l),m=join(n,c),p=join(m,Kg),u=`${m}.tmp`,d=join(u,Kg);if(!r.refresh&&await Wg(p))return Hm(p);try{return await rm$1(u,{recursive:!0,force:!0}),await mkdir(u,{recursive:!0}),await gb(fb(t),d),t.ref&&await hb(d,t.ref),await rm$1(m,{recursive:!0,force:!0}),await rename(u,m),Hm(p)}catch(g){if(await rm$1(u,{recursive:true,force:true}),r.allowOfflineFallback!==false&&await Wg(p))return console.warn(`[agentsmesh] Remote fetch failed for ${e}; using cached version. Error: ${g instanceof Error?g.message:String(g)}`),Hm(p);throw g}}s(gl,"fetchGitRemoteExtend");async function Hm(t){return {resolvedPath:t,version:await yb(t)}}s(Hm,"readCachedRepo");async function Wg(t){return F(t)}s(Wg,"hasCachedRepo");function fb(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}s(fb,"resolveCloneUrl");async function gb(t,e){await Vm(["clone",t,e]);}s(gb,"cloneRepo");async function hb(t,e){await Vm(["checkout",e],t);}s(hb,"checkoutRef");async function yb(t){return Vm(["rev-parse","HEAD"],t)}s(yb,"getHeadSha");async function Vm(t,e){let{stdout:r}=await db("git",t,{cwd:e,env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return r.trim()}s(Vm,"runGit");w();async function Vg(t,e,r){let n=`https://api.github.com/repos/${t}/${e}/releases/latest`,o={Accept:"application/vnd.github+json"};r&&(o.Authorization=`Bearer ${r}`);let i=await globalThis.fetch(n,{headers:o});if(!i.ok)throw new Error(`Failed to resolve latest release for ${t}/${e}: ${i.status} ${i.statusText}`);let a=await i.json();if(!a.tag_name||typeof a.tag_name!="string")throw new Error(`No tag_name in releases/latest response for ${t}/${e}`);return a.tag_name}s(Vg,"resolveLatestTag");async function Jg(t,e,r,n,o,i=false){let a=r.token??process.env.AGENTSMESH_GITHUB_TOKEN,l=r.refresh===true,c=t.tag;if(c==="latest")try{c=await Vg(t.org,t.repo,a);}catch(I){if(!i)throw I;return Rb(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 I=await Jm(p);if(I)return {resolvedPath:join(p,I),version:c}}let u=`https://github.com/${t.org}/${t.repo}/tarball/${c}`,d={};a&&(d.Authorization=`Bearer ${a}`);let g;try{let I=await globalThis.fetch(u,{headers:d,redirect:"follow"});if(!I.ok)throw new Error(`HTTP ${I.status}: ${I.statusText}`);g=await I.arrayBuffer();}catch(I){if(r.allowOfflineFallback!==false&&await F(p)){let D=await Jm(p);if(D)return console.warn(`[agentsmesh] Network failed for ${e}; using cached version. Error: ${I instanceof Error?I.message:String(I)}`),{resolvedPath:join(p,D),version:c}}throw I}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:s((I,k)=>!(Cb(I)||k&&"type"in k&&(k.type==="Link"||k.type==="SymbolicLink")),"filter")});}finally{await rm$1(h,{force:true}).catch(()=>{});}let C=await Jm(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}}s(Jg,"fetchGithubRemoteExtend");async function Jm(t){let r=(await readdir(t,{withFileTypes:true})).filter(n=>n.isDirectory()&&!n.name.startsWith("."));return r.length===1?r[0].name:null}s(Jm,"findExtractTopDir");function zg(t,e,r){return r?`https://x-access-token:${encodeURIComponent(r)}@github.com/${t}/${e}.git`:`https://github.com/${t}/${e}.git`}s(zg,"buildGithubCloneUrl");function Cb(t){let e=t.replace(/\\/g,"/");return e.startsWith("/")||e.split("/").includes("..")}s(Cb,"isZipSlipPath");async function Rb(t,e,r,n,o,i){let a=i?[zg(t.org,t.repo,i)]:[zg(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 gl(m,e,r,n,o)}catch(p){l=p;}}throw l instanceof Error?l:new Error("Failed to clone GitHub default branch")}s(Rb,"fetchGithubDefaultBranch");function Yg(t,e,r){if(!t.startsWith(e))return null;let n=t.slice(e.length).trim();if(!n)return null;let o=n.lastIndexOf("@");if(o<0)return [n,r];let i=n.slice(0,o).trim(),a=n.slice(o+1).trim();return !i||!a?null:[i,a]}s(Yg,"splitSourceRef");function Xg(t){let e=Yg(t,"github:","latest");if(!e)return null;let[r,n]=e,o=r.indexOf("/");if(o<0)return null;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !i||!a||!n?null:{org:i,repo:a,tag:n}}s(Xg,"parseGithubSource");function Zg(t){let e=Yg(t,"gitlab:");if(!e)return null;let[r,n]=e,o=r.lastIndexOf("/");if(o<0)return null;let i=r.slice(0,o).trim(),a=r.slice(o+1).trim();return !i||!a?null:{namespace:i,project:a,ref:n,cloneUrl:`https://gitlab.com/${i}/${a}.git`}}s(Zg,"parseGitlabSource");function qg(t){if(!t.startsWith("git+"))return null;let e=t.slice(4).trim();if(!e)return null;let r=e.lastIndexOf("#"),n=(r<0?e:e.slice(0,r)).trim(),o=r<0?void 0:e.slice(r+1).trim();if(!n||r>=0&&!o)return null;let i;try{i=new URL(n);}catch{return null}return ["https:","http:","ssh:","file:"].includes(i.protocol)?{url:n,ref:o}:null}s(qg,"parseGitSource");function go(t){let e=Xg(t);if(e)return {kind:"github",...e};let r=Zg(t);if(r)return {kind:"gitlab",...r};let n=qg(t);return n?{kind:"git",...n}:null}s(go,"parseRemoteSource");function Ym(t){return go(t)!==null}s(Ym,"isSupportedRemoteSource");function Lb(t){let e=go(t);return e?e.kind==="github"?Rs("github",`${e.org}/${e.repo}`,e.tag):e.kind==="gitlab"?Rs("gitlab",`${e.namespace}/${e.project}`,e.ref??"HEAD"):Rs("git",e.url,e.ref??"HEAD"):null}s(Lb,"cacheKeyFromSource");async function eh(t,e){let r=Lb(t);if(!r)return;let n=e??qt(),o=join(n,r);await rm$1(o,{recursive:true,force:true});}s(eh,"cleanInstallCache");async function rh(t,e){let r=t??qt(),n=e??Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS??30)*864e5,o;try{o=await readdir(r);}catch{return}let i=Date.now();await Promise.all(o.map(async a=>{let l=join(r,a);try{let{mtimeMs:c}=await stat(l);i-c>n&&await rm$1(l,{recursive:!0,force:!0});}catch{}}));}s(rh,"sweepStaleCache");var nh=80;function Rs(t,e,r){let n=s(i=>i.replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/,"_"),"safe"),o;if(t==="github"){let[i,a]=e.split("/",2);i&&a?o=`${n(i)}--${n(a)}--${n(r)}`:o=`${n(t)}__${n(e)}__${n(r)}`;}else o=`${n(t)}__${n(e)}__${n(r)}`;if(o.length>nh){let i=createHash("sha256").update(o).digest("hex").slice(0,16);o=`${o.slice(0,nh-18)}--${i}`;}return o}s(Rs,"buildCacheKey");function qt(){let t=process.env.AGENTSMESH_CACHE;return t||join(homedir(),".agentsmesh","cache")}s(qt,"getCacheDir");async function Os(t,e,r={}){let n=go(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??qt();return rh(o).catch(()=>{}),n.kind==="github"?Jg(n,e,r,o,Rs,!t.includes("@")):gl(n,e,r,o,Rs)}s(Os,"fetchRemoteExtend");function Nb(t){return t.startsWith("http://")||t.startsWith("https://")}s(Nb,"isOtherRemoteSource");async function ks(t,e,r={}){if(t.extends.length===0)return [];if(r.refreshCache===true&&t.extends.some(o=>Ym(o.source))){let o=qt();await rm$1(o,{recursive:true,force:true}),await mkdir(o,{recursive:true});}let n=[];for(let o of t.extends){if(Nb(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(Ym(o.source)){let a=await Os(o.source,o.name,{cacheDir:qt(),refresh:r.refreshCache===true});n.push({name:o.name,resolvedPath:a.resolvedPath,features:[...o.features],target:o.target,version:a.version,path:o.path,pick:o.pick});continue}let i=resolve(e,o.source);if(!await F(i))throw new Error(`Extend "${o.name}": path does not exist: ${i}. Check extends.source in agentsmesh.yaml.`);n.push({name:o.name,resolvedPath:i,features:[...o.features],target:o.target,path:o.path,pick:o.pick});}return n}s(ks,"resolveExtendPaths");w();v();var vb=["always_on","model_decision","glob","manual"];function sh(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):typeof t=="string"?t?[t]:[]:[]}s(sh,"toStrArray");async function ho(t){let r=(await T(t)).filter(o=>{if(!o.endsWith(".md"))return false;let i=basename(o,".md");return i==="_root"||!i.startsWith("_")}),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:l}=E(i),m=basename(o,".md")==="_root",p=a.root===true,u=a.trigger,d=typeof u=="string"&&vb.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:sh(a.targets),description:typeof a.description=="string"?a.description:"",globs:sh(a.globs),body:l,...d!==void 0&&{trigger:d},...h!==void 0&&{codexEmit:h},...R!==void 0&&{codexInstructionVariant:R}});}return n}s(ho,"parseRules");w();v();function ah(t){return t===true||t==="true"||t===1||t==="1"}s(ah,"toBool");function lh(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):[]}s(lh,"toToolsArray");async function yo(t){let r=(await T(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:l}=E(i),c=basename(o,".md"),m=lh(a.allowedTools),p=lh(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:ah(a.outputStyle)||ah(a["output-style"]),body:l});}return n}s(yo,"parseCommands");w();v();function _o(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):[]}s(_o,"toStrArray");function mh(t){return t===true||t==="true"||t===1||t==="1"}s(mh,"toBool");function ph(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}s(ph,"toInt");function Mb(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:{}}s(Mb,"toHooks");async function Io(t){let r=(await T(t)).filter(o=>o.endsWith(".md")&&!basename(o).startsWith("_")),n=[];for(let o of r){let i=await y(o);if(!i)continue;let{frontmatter:a,body:l}=E(i),c=basename(o,".md"),m=_o(a.tools),p=_o(a.tools),u=m.length>0?m:p,d=_o(a.disallowedTools),g=_o(a["disallowed-tools"]),h=d.length>0?d:g,C=_o(a.mcpServers),R=_o(a["mcp-servers"]),I=C.length>0?C:R,k=_o(a.skills),D=ph(a.maxTurns),P=ph(a["max-turns"]),b=D>0?D:P>0?P: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:b,mcpServers:I,hooks:Mb(a.hooks),skills:k,memory:typeof a.memory=="string"?a.memory:"",outputStyle:mh(a.outputStyle)||mh(a["output-style"]),body:l});}return n}s(Io,"parseAgents");w();v();async function jb(t){return await y(t)??""}s(jb,"readContent");var hl="SKILL.md",Ub=[".git","node_modules"];function Kb(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Kb,"sanitizeSkillName");async function uh(t){let e=await T(t),r=[];for(let n of e){let i=n.slice(t.length+1).replace(/\\/g,"/");if(i===hl||i.endsWith(`/${hl}`))continue;let a=i.split("/")[0];if(Ub.some(c=>a===c)||i===".DS_Store"||i.endsWith("/.DS_Store"))continue;let l=await jb(n);r.push({relativePath:i,absolutePath:n,content:l});}return r.sort((n,o)=>n.relativePath.localeCompare(o.relativePath))}s(uh,"listSupportingFiles");async function dh(t){let e=join(t,hl),r=await y(e);if(!r)return null;let{frontmatter:n,body:o}=E(r),i=await uh(t),a=typeof n.name=="string"?Kb(n.name):"";return {source:e,name:a||basename(t),description:typeof n.description=="string"?n.description:"",body:o,supportingFiles:i}}s(dh,"parseSkillDirectory");async function Es(t){let e;try{e=await readdir(t,{withFileTypes:!0});}catch{return []}let r=[];for(let n of e){if(!n.isDirectory()||n.name.startsWith("_"))continue;let o=join(t,n.name),i=join(o,hl),a=await y(i);if(!a)continue;let{frontmatter:l,body:c}=E(a),m=await uh(o);r.push({source:i,name:n.name,description:typeof l.description=="string"?l.description:"",body:c,supportingFiles:m});}return r.sort((n,o)=>n.name.localeCompare(o.name))}s(Es,"parseSkills");w();function fh(t){return t===null||typeof t!="object"||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>typeof e[1]=="string"))}s(fh,"parseStringMap");function Wb(t){if(!t||typeof t!="object")return null;let e=t,r=typeof e.type=="string"?e.type:"stdio",n=fh(e.env),o=typeof e.description=="string"?e.description:void 0,i=typeof e.url=="string"?e.url:"";if(i)return {...o!==void 0&&{description:o},type:r,url:i,headers:fh(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}}s(Wb,"parseServer");async function yl(t){let e=await y(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[i,a]of Object.entries(n)){let l=Wb(a);l&&(o[i]=l);}return {mcpServers:o}}s(yl,"parseMcp");w();function Zm(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}s(Zm,"ensureStringArray");async function _l(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {allow:[],deny:[],ask:[]};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n=r,o=Zm(n.allow),i=Zm(n.deny),a=Zm(n.ask);return {allow:o,deny:i,ask:a}}s(_l,"parsePermissions");w();Fe();var Hb=["command","prompt"];function Vb(t){if(!t||typeof t!="object")return null;let e=t,r=e.matcher;if(typeof r!="string")return null;let n=qm(e);if(!n)return null;let o=typeof e.type=="string"&&Hb.includes(e.type)?e.type:void 0,i=typeof e.timeout=="number"&&Number.isFinite(e.timeout)?e.timeout:void 0,a=zt(e)||void 0;return {matcher:r,command:n,...i!==void 0&&{timeout:i},...o&&{type:o},...a&&{prompt:a}}}s(Vb,"toHookEntry");async function Il(t){let e=await y(t);if(e===null)return null;if(!e.trim())return {};let r;try{r=parse(e);}catch{return null}if(!r||typeof r!="object")return null;let n={},o=r;for(let[i,a]of Object.entries(o)){if(!Array.isArray(a))continue;let l=[];for(let c of a){let m=Vb(c);m&&l.push(m);}l.length>0&&(n[i]=l);}return n}s(Il,"parseHooks");w();async function Sl(t){let e=await y(t);if(e===null||!e.trim())return [];let r=e.split(/\r?\n/),n=[];for(let o of r){let i=o.trim();i===""||i.startsWith("#")||n.push(i);}return n}s(Sl,"parseIgnore");w();async function So(t){let e=join(t,".agentsmesh"),r=await F(e)?e:t,[n,o,i,a,l,c,m,p]=await Promise.all([ho(join(r,"rules")),yo(join(r,"commands")),Io(join(r,"agents")),Es(join(r,"skills")),yl(join(r,"mcp.json")),_l(join(r,"permissions.yaml")),Il(join(r,"hooks.yaml")),Sl(join(r,"ignore"))]);return {rules:n,commands:o,agents:i,skills:a,mcp:l,permissions:c,hooks:m,ignore:p}}s(So,"loadCanonicalFiles");function hh(t){return basename(t.source,".md")}s(hh,"ruleSlug");function Ls(t,e){let r=new Map(t.rules.map(p=>[hh(p),p]));for(let p of e.rules)r.set(hh(p),p);let n=new Map(t.commands.map(p=>[p.name,p]));for(let p of e.commands)n.set(p.name,p);let o=new Map(t.agents.map(p=>[p.name,p]));for(let p of e.agents)o.set(p.name,p);let i=new Map(t.skills.map(p=>[p.name,p]));for(let p of e.skills)i.set(p.name,p);let a=Yb(t.mcp,e.mcp),l=Xb(t.permissions,e.permissions),c=Zb(t.hooks,e.hooks),m=qb(t.ignore,e.ignore);return {rules:Array.from(r.values()),commands:Array.from(n.values()),agents:Array.from(o.values()),skills:Array.from(i.values()),mcp:a,permissions:l,hooks:c,ignore:m}}s(Ls,"mergeCanonicalFiles");function Yb(t,e){if(!t&&!e)return null;let r=t?.mcpServers??{},n=e?.mcpServers??{};return {mcpServers:{...r,...n}}}s(Yb,"mergeMcp");function Xb(t,e){if(!t&&!e)return null;let r=Qm(t?.allow??[],e?.allow??[]),n=Qm(t?.deny??[],e?.deny??[]),o=Qm(t?.ask??[],e?.ask??[]);return {allow:r,deny:n,ask:o}}s(Xb,"mergePermissions");function Qm(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}s(Qm,"mergeUniqueStrings");function Zb(t,e){if(!t&&!e)return null;let r={},n=new Set([...Object.keys(t??{}),...Object.keys(e??{})]);for(let o of n){let i=e?.[o],a=t?.[o];r[o]=i!==void 0&&i.length>0?i:a??[];}return r}s(Zb,"mergeHooks");function qb(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}s(qb,"mergeIgnore");w();var yh=[{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 Cl(t){let e=null,r=0;for(let n of yh){let o=0;for(let i of n.paths)await F(join(t,i))&&o++;o>r&&(r=o,e=n.target);}return r>0?e:null}s(Cl,"detectNativeFormat");var _h=yh.map(t=>t.paths[0]).filter(t=>t!==void 0);w();ou();Ju();Nu();fd();Eu();Zd();cu();Lu();_d();Ad();kd();var eM={"claude-code":Ql,cursor:Lc,copilot:yc,"gemini-cli":Fc,"codex-cli":lc,windsurf:tm,cline:nc,continue:mc,junie:$c,kiro:Bc,"kilo-code":Kc};async function za(t,e){let r=eM[e];if(!r)throw new Error(`No importer registered for native target: ${e}`);return r(t)}s(za,"importNativeToCanonical");w();var hf="SKILL.md";async function us(t){if(!await F(t))return false;if(await F(join(t,hf)))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,hf)))return !0}catch{return false}return false}s(us,"isSkillPackLayout");async function Ha(t){if(!await F(t))return [];if(await F(join(t,hf))){let e=await dh(t);return e?[e]:[]}return Es(t)}s(Ha,"loadSkillsAtExtendPath");w();function sM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(sM,"emptyCanonical");function iM(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}s(iM,"isCanonicalSliceEmpty");async function lm(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),i=basename(t).replace(/\.md$/i,"");if(n==="rules")return {sliceRoot:r,implicitPick:{rules:[i]}};if(n==="commands")return {sliceRoot:r,implicitPick:{commands:[i]}};if(n==="agents")return {sliceRoot:r,implicitPick:{agents:[i]}};throw new Error(`Single-file install only supports .md files under rules/, commands/, or agents/. Got: ${t}`)}s(lm,"normalizeSlicePath");async function aM(t){if(basename(t)==="rules")return ho(t);let r=join(t,"rules");return await F(r)?ho(r):[]}s(aM,"parseRulesAt");async function lM(t){if(basename(t)==="commands")return yo(t);let r=join(t,"commands");return await F(r)?yo(r):[]}s(lM,"parseCommandsAt");async function cM(t){if(basename(t)==="agents")return Io(t);let r=join(t,"agents");return await F(r)?Io(r):[]}s(cM,"parseAgentsAt");async function mM(t){if(await us(t))return Ha(t);let e=join(t,"skills");return await us(e)?Ha(e):[]}s(mM,"loadSkillsForPartialSlice");async function cm(t){let e=join(t,".agentsmesh");if(await F(e))return So(t);let r=sM();if(r.rules=await aM(t),r.commands=await lM(t),r.agents=await cM(t),r.skills=await mM(t),iM(r))throw new Error(`No installable resources at ${t}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`);return r}s(cm,"loadCanonicalSliceAtPath");function pM(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(pM,"emptyCanonical");async function wL(t){let e=t.resolvedPath;if(!t.path){let o=join(e,".agentsmesh");if(!await F(o)){if(await us(e)){let a=await Ha(e);return {...pM(),skills:a}}let i=t.target??await Cl(e);if(!i)throw new Error(`Extend "${t.name}": No supported agent configuration found in ${e}.
|
|
148
|
+
Expected one of: .agentsmesh/, ${_h.join(", ")}.`);_.info(`[agentsmesh] Extend "${t.name}": ${t.target?"specified":"detected"} ${i} format, importing to .agentsmesh/...`),await za(e,i);}return So(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)||(_.info(`[agentsmesh] Extend "${t.name}": path "${t.path}" with target "${t.target}" \u2014 importing at extend root, then loading canonical.`),await za(e,t.target)),So(e)}let{sliceRoot:n}=await lm(r);try{return await cm(n)}catch(o){let i=o instanceof Error?o.message:String(o),a=new Error(`Extend "${t.name}": ${i}`);throw o instanceof Error&&(a.cause=o),a}}s(wL,"loadCanonicalForExtend");function mm(t,e,r,n){if(!r)return t;let o={...t};if(r.skills?.length&&e.includes("skills")){let i=new Set(r.skills),a=o.skills;o={...o,skills:a.filter(l=>i.has(l.name))};for(let l of r.skills)a.some(c=>c.name===l)||_.warn(`[agentsmesh] pick name "${l}" not found in skills from extend "${n}".`);}if(r.commands?.length&&e.includes("commands")){let i=new Set(r.commands),a=o.commands;o={...o,commands:a.filter(l=>i.has(l.name))};for(let l of r.commands)a.some(c=>c.name===l)||_.warn(`[agentsmesh] pick name "${l}" not found in commands from extend "${n}".`);}if(r.agents?.length&&e.includes("agents")){let i=new Set(r.agents),a=o.agents;o={...o,agents:a.filter(l=>i.has(l.name))};for(let l of r.agents)a.some(c=>c.name===l)||_.warn(`[agentsmesh] pick name "${l}" not found in agents from extend "${n}".`);}if(r.rules?.length&&e.includes("rules")){let i=new Set(r.rules),a=o.rules,l=s(c=>basename(c).replace(/\.md$/i,""),"stem");o={...o,rules:a.filter(c=>i.has(l(c.source)))};for(let c of r.rules)a.some(m=>l(m.source)===c)||_.warn(`[agentsmesh] pick name "${c}" not found in rules from extend "${n}".`);}return o}s(mm,"applyExtendPick");w();var fM=["rules","commands","agents","skills"],Ai=z.enum(fM);var gM=z.enum(["github","gitlab","git","local"]),PL=z.object({name:z.string().min(1),source:z.string().min(1),version:z.string().optional(),source_kind:gM,installed_at:z.string(),updated_at:z.string(),features:z.array(Cs).min(1),pick:Ui.optional(),target:de.optional(),path:z.string().optional(),paths:z.array(z.string().min(1)).min(1).optional(),as:Ai.optional(),content_hash:z.string()});function bL(t){let e=go(t);return e?e.kind==="github"?`github:${e.org}/${e.repo}`:e.kind==="gitlab"?`gitlab:${e.namespace}/${e.project}`:`git+${e.url}`:t.trim()}s(bL,"sourceIdentity");function yM(t,e){return e?t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n]):true}s(yM,"sameFeatures");async function pm(t){let e=join(t,"pack.yaml"),r=await y(e);if(r===null)return null;try{let n=parse(r);return PL.parse(n)}catch{return null}}s(pm,"readPackMetadata");async function TL(t,e,r){if(!await F(t))return null;let n=bL(e),o;try{o=await readdir(t,{withFileTypes:!0});}catch{return null}for(let i of o){if(!i.isDirectory())continue;let a=join(t,i.name),l=await pm(a);if(l&&bL(l.source)===n&&l.target===r.target&&l.as===r.as&&yM(l.features,r.features))return {meta:l,packDir:a,name:l.name}}return null}s(TL,"findExistingPack");async function um(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),i=await pm(o);i&&r.push({meta:i,packDir:o,name:i.name});}return r}s(um,"listPacks");function NL(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(NL,"emptyCanonical");async function _M(t){let[e,r,n,o,i,a,l,c]=await Promise.all([ho(join(t,"rules")),yo(join(t,"commands")),Io(join(t,"agents")),Es(join(t,"skills")),yl(join(t,"mcp.json")),_l(join(t,"permissions.yaml")),Il(join(t,"hooks.yaml")),Sl(join(t,"ignore"))]);return {...NL(),rules:e,commands:r,agents:n,skills:o,mcp:i,permissions:a,hooks:l,ignore:c}}s(_M,"loadPackCanonical");async function DL(t){let e=join(t,"packs"),r=await um(e),n=NL();for(let{meta:o,packDir:i}of r){let a=await _M(i),l=If(a,o.features),c=mm(l,o.features,o.pick,o.name);n=Ls(n,c);}return n}s(DL,"loadPacksCanonical");var SM={rules:["rules"],commands:["commands"],agents:["agents"],skills:["skills"],mcp:["mcp"],permissions:["permissions"],hooks:["hooks"],ignore:["ignore"]};function If(t,e){if(e.length===0)return FL();let r=new Set(e.flatMap(n=>SM[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:[]}}s(If,"filterCanonicalByFeatures");function FL(){return {rules:[],commands:[],agents:[],skills:[],mcp:null,permissions:null,hooks:null,ignore:[]}}s(FL,"emptyCanonical");async function xe(t,e,r={},n=join(e,".agentsmesh")){let o=await ks(t,e,{refreshCache:r.refreshRemoteCache===true}),i=FL();for(let c of o){let m=await wL(c),p=If(m,c.features),u=mm(p,c.features,c.pick,c.name);i=Ls(i,u);}let a=await DL(n);i=Ls(i,a);let l=await So(n);return i=Ls(i,l),{canonical:i,resolvedExtends:o}}s(xe,"loadCanonicalWithExtends");w();function Ya(t){return createHash("sha256").update(t,"utf8").digest("hex")}s(Ya,"hashContent");async function dm(t){try{let e=await readFile(t,"utf8");return Ya(e)}catch(e){if(e instanceof Error&&"code"in e&&e.code==="ENOENT")return null;throw e}}s(dm,"hashFile");var Cf=".lock",LM=[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 AM(t){return t.startsWith("packs/")?false:LM.some(e=>e(t))}s(AM,"isCanonical");var wM={rules:s(t=>t.startsWith("rules/"),"rules"),commands:s(t=>t.startsWith("commands/"),"commands"),agents:s(t=>t.startsWith("agents/"),"agents"),skills:s(t=>/^skills\/[^/]+\/.+$/.test(t),"skills"),mcp:s(t=>t==="mcp.json","mcp"),permissions:s(t=>t==="permissions.yaml","permissions"),hooks:s(t=>t==="hooks.yaml","hooks"),ignore:s(t=>t==="ignore","ignore")};async function fm(t){let e=join(t,Cf),r=await y(e);if(r===null)return null;try{let n=parse(r);return !n||typeof n!="object"?null:{generatedAt:String(n.generated_at??""),generatedBy:String(n.generated_by??""),libVersion:String(n.lib_version??""),checksums:n.checksums&&typeof n.checksums=="object"?n.checksums:{},extends:n.extends&&typeof n.extends=="object"?n.extends:{},packs:n.packs&&typeof n.packs=="object"?n.packs:{}}}catch{return null}}s(fm,"readLock");async function Xa(t,e){let r=join(t,Cf),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);}
|
|
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);}s(Xa,"writeLock");async function An(t){if(!await F(t))return {};let e=await T(t),r={};for(let n of e){let o=relative(t,n).replace(/\\/g,"/");if(o===Cf||!AM(o))continue;let i=await dm(n);i!==null&&(r[o]=i.startsWith("sha256:")?i:`sha256:${i}`);}return r}s(An,"buildChecksums");function gm(t,e,r){if(r.length===0)return [];let n=r.map(a=>wM[a]).filter(a=>a!==void 0);if(n.length===0)return [];let o=new Set([...Object.keys(t),...Object.keys(e)]),i=[];for(let a of o)n.some(l=>l(a))&&t[a]!==e[a]&&i.push(a);return i}s(gm,"detectLockedFeatureViolations");async function Za(t){let e=await um(t),r={};for(let{meta:n}of e)r[n.name]=n.content_hash;return r}s(Za,"buildPackChecksums");async function ds(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 An(n),i=Object.keys(o).sort().map(c=>`${c}:${o[c]}`).join(`
|
|
152
|
+
`),a=Ya(i),l=a.startsWith("sha256:")?a:`sha256:${a}`;e[r.name]=`local:${l}`;}return e}s(ds,"buildExtendChecksums");ct();Ur();function PM(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(PM,"addDirectoryMapping");function vL(t,e,r){let n=posix.dirname(e),o=posix.dirname(r);for(;n!==".agentsmesh/skills"&&n!==".";)PM(t,n,o),n=posix.dirname(n),o=posix.dirname(o);}s(vL,"addSkillDirectoryMappings");ct();function ML(t,e,r="project"){let n=wt(t,r);if(!n)return null;if(e.root)return n.rootInstructionPath??null;if(e.targets.length>0&&!e.targets.includes(t))return null;let o=posix.basename(e.source.replace(/\\/g,"/"),".md");return n.paths.rulePath(o,e)}s(ML,"ruleTargetPath");function $L(t,e,r,n="project"){let o=wt(t,n);return o?o.paths.commandPath(e,r):null}s($L,"commandTargetPath");function GL(t,e,r,n="project"){let o=wt(t,n);return o?o.paths.agentPath(e,r):null}s(GL,"agentTargetPath");Bt();At();Xt();ct();function TM(t,e,r){t.set(e,r),t.set(`${e}/`,`${r}/`);}s(TM,"addDirectoryMapping");function qa(t,e,r,n="project"){let o=new Map;for(let a of e.rules){let l=ML(t,a,n);l&&o.set(`.agentsmesh/rules/${basename(a.source)}`,l);}for(let a of e.commands){let l=$L(t,a.name,r,n);l&&o.set(`.agentsmesh/commands/${a.name}.md`,l);}for(let a of e.agents){let l=GL(t,a.name,r,n);l&&o.set(`.agentsmesh/agents/${a.name}.md`,l);}let i=Ua(t,n);if(!i)return o;for(let a of e.skills){TM(o,`.agentsmesh/skills/${a.name}`,`${i}/${a.name}`),o.set(`.agentsmesh/skills/${a.name}/SKILL.md`,`${i}/${a.name}/SKILL.md`);for(let l of a.supportingFiles){let c=l.relativePath.replace(/\\/g,"/"),m=`.agentsmesh/skills/${a.name}/${c}`,p=`${i}/${a.name}/${c}`;o.set(m,p),vL(o,m,p);}}return o}s(qa,"buildReferenceMap");Br();var wn="AGENTS.md";function NM(t){return t.target===Gi&&t.path.endsWith(wn)}s(NM,"isCodexAgents");function jL(t){return t.target==="windsurf"&&t.path.endsWith(wn)}s(jL,"isWindsurfAgents");function UL(t){return t.target==="cline"&&t.path.endsWith(wn)}s(UL,"isClineAgents");function Rf(t){return t.target==="cursor"&&t.path.endsWith(wn)}s(Rf,"isCursorAgents");function Of(t){return t.target==="gemini-cli"&&t.path.endsWith(wn)}s(Of,"isGeminiAgents");function DM(t){return t.target==="kiro"&&t.path.endsWith(wn)}s(DM,"isKiroAgents");function FM(t){return t.target==="kilo-code"&&t.path.endsWith(wn)}s(FM,"isKiloCodeAgents");function KL(t){return t.target==="warp"&&t.path.endsWith(wn)}s(KL,"isWarpAgents");function vM(t){return Rf(t)||Of(t)}s(vM,"isCompatibilityAgents");function ym(t,e,r,n){let o=n.get(t);if(o)return o;let i=new Map;for(let[a,l]of qa(t,e,r))i.has(l)||i.set(l,a);return n.set(t,i),i}s(ym,"reverseReferenceMap");function _m(t,e){let r=[...e.entries()].sort(([o],[i])=>i.length-o.length),n=t;for(let[o,i]of r)n=n.split(o).join(i);return n}s(_m,"normalizeContent");function MM(t,e,r,n,o){let i=ym(t.target,r,n,o),a=ym(e.target,r,n,o);return _m(t.content,i)===_m(e.content,a)}s(MM,"hasEquivalentCanonicalContent");function $M(t,e,r,n,o){let i=ym(t.target,r,n,o),a=ym(e.target,r,n,o),l=_m(t.content,i).trim(),c=_m(e.content,a).trim();return l.length>c.length&&l.includes(c)}s($M,"hasCanonicalSupersetContent");function WL(t,e,r){let n=new Map;for(let a of t){if(!a.path.endsWith(wn))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)NM(a)&&o.set(a.path,a);let i=new Map;return t.filter(a=>{if(Rf(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"))return false}if(Of(a)){let c=n.get(a.path);if(c&&[...c].some(m=>m!=="cursor"&&m!=="gemini-cli"))return false}if(!jL(a)&&!UL(a)&&!Rf(a)&&!Of(a)&&!DM(a)&&!FM(a)&&!KL(a))return true;let l=o.get(a.path);return l?vM(a)||jL(a)||UL(a)||KL(a)?false:!(MM(l,a,e,r,i)||$M(l,a,e,r,i)):true})}s(WL,"preferEquivalentCodexAgents");$t();uf();$t();$t();ct();function zL(t,e,r,n){let o=n.normalize(e),i=n.normalize(r);t.set(o,i),t.set(`${o}/`,`${i}/`);}s(zL,"addPackAbsoluteDirMapping");function GM(t){let e=new Set;for(let{relativePath:r}of t){let n=r.replace(/\\/g,"/"),o=posix.dirname(n);for(;o!=="."&&o.length>0;){e.add(o);let i=posix.dirname(o);if(i===o)break;o=i;}}return [...e]}s(GM,"skillSupportingDirPrefixes");function HL(t,e,r,n,o){let i=Ua(e,o);if(!i)return;let a=V(n),l=a.join(n,".agentsmesh","packs");for(let c of r.skills){let m=a.dirname(c.source);if(!m.startsWith(l))continue;let p=a.normalize(a.join(n,i,c.name));zL(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 GM(c.supportingFiles))zL(t,a.join(m,u),a.join(p,u),a);}}s(HL,"addPackSkillArtifactMappings");$t();function jM(t){return `.agentsmesh/rules/${basename(t.source)}`}s(jM,"canonicalRulePath");function UM(t){return `.github/instructions/${basename(t.source,".md")}.instructions.md`}s(UM,"copilotInstructionsPath");function JL(t,e,r,n,o){if(t!=="copilot"||!n?.startsWith(".github/instructions/"))return;let i=V(r);for(let a of o.rules)a.root||a.globs.length===0||e.set(i.normalize(i.join(r,jM(a))),i.normalize(i.join(r,UM(a))));}s(JL,"applyCopilotInstructionArtifactRefs");ct();function Im(t){return t?(t.outputFamilies??[]).filter(e=>e.kind==="additional").flatMap(e=>[...e.explicitPaths??[]]):[]}s(Im,"getAdditionalRootDecorationPaths");function YL(t,e){for(let r of t?.outputFamilies??[])if(r.pathPrefix!==void 0&&e.startsWith(r.pathPrefix)||r.explicitPaths?.includes(e))return r.id;return "default"}s(YL,"resolveRewriteFamilyId");function kf(t,e){e!==void 0&&e.length>0&&!t.includes(e)&&t.push(e);}s(kf,"pushUnique");function XL(t,e,r,n){let o=[],i=r.get(`.agentsmesh/rules/${basename(e.source)}`);kf(o,i);let a=wt(t,n);if(e.root)for(let l of Im(a))kf(o,l);for(let l of a?.extraRuleOutputPaths?.(e,{refs:r,scope:n})??[])kf(o,l);return o}s(XL,"extraRuleOutputPaths");ct();function ZL(t,e,r,n,o,i){let a=wt(t,e);if(!a?.mirrorGlobalPath)return;let l=a.mirrorGlobalPath(r,i??[]),c=l===null?[]:Array.isArray(l)?l:[l];for(let m of c)m!==r&&o.set(m,n);}s(ZL,"addSkillMirrorSourceEntry");function WM(t){return `.agentsmesh/commands/${t.name}.md`}s(WM,"canonicalCommandPath");function BM(t){return `.agentsmesh/agents/${t.name}.md`}s(BM,"canonicalAgentPath");function zM(t){return `.agentsmesh/skills/${t.name}/SKILL.md`}s(zM,"canonicalSkillPath");function qL(t,e,r,n,o,i){let a=i?.scope??"project",l=V(n),c=new Map([...qa(t,e,r,a)].map(([m,p])=>[l.normalize(l.join(n,m)),l.normalize(l.join(n,p))]));return JL(t,c,n,o,e),HL(c,t,e,n,a),c}s(qL,"buildArtifactPathMap");function QL(t,e,r,n="project",o){let i=qa(t,e,r,n),a=new Map;for(let l of e.rules)for(let c of XL(t,l,i,n))a.set(c,l.source);for(let l of e.commands){let c=i.get(WM(l));c&&a.set(c,l.source);}for(let l of e.agents){let c=i.get(BM(l));c&&a.set(c,l.source);}for(let l of e.skills){let c=i.get(zM(l));c&&(a.set(c,l.source),ZL(t,n,c,l.source,a,o));for(let m of l.supportingFiles){let p=`.agentsmesh/skills/${l.name}/${m.relativePath.replace(/\\/g,"/")}`,u=i.get(p);u&&(a.set(u,m.absolutePath),ZL(t,n,u,m.absolutePath,a,o));}}return a}s(QL,"buildOutputSourceMap");ct();Ur();tp();function JM(t,e){if(!e)return null;for(let r of e){let n=ot(r);if(n?.sharedArtifacts){for(let[o,i]of Object.entries(n.sharedArtifacts))if(i==="owner"&&t.startsWith(o))return r}}return null}s(JM,"findSharedArtifactOwner");function tA(t,e,r){if(e==="global"){let n=JM(t.path,r);if(n)return n;let o=Lh(t.path);if(o)return o}return t.target}s(tA,"artifactMapTargetForResult");function YM(t,e){return `${t}\0${(e??[]).join(",")}`}s(YM,"sourceMapCacheKey");function Ef(t,e){let r=V(t),n=new Set;for(let o of e){let i=r.join(t,o.path);n.add(i);let a=r.dirname(i);for(;a.startsWith(t)&&!n.has(a)&&(n.add(a),a!==t);)a=r.dirname(a);}return n}s(Ef,"collectPlannedPaths");function XM(t,e,r){let n=wt(t.target,e),o=YL(n,t.path);if(o!=="default")return `${t.target}:${o}`;let i=tA(t,e,r);return i===t.target?t.target:`${t.target}~via~${i}`}s(XM,"artifactCacheKey");function eA(t,e,r,n,o="project",i){let a=Ef(n,t),l=new Map,c=new Map;return t.map(m=>{let p=YM(m.target,i),d=(c.get(p)??(()=>{let I=QL(m.target,e,r,o,i);return c.set(p,I),I})()).get(m.path);if(!d)return m;let g=tA(m,o,i),h=XM(m,o,i),C=l.get(h)??(()=>{let I=qL(g,e,r,n,m.path,{scope:o});return l.set(h,I),I})(),R=im({content:m.content,projectRoot:n,sourceFile:d,destinationFile:V(n).join(n,m.path),translatePath:s(I=>C.get(I)??I,"translatePath"),pathExists:s(I=>a.has(I)||existsSync(I),"pathExists"),explicitCurrentDirLinks:true,rewriteBarePathTokens:true,scope:o,pathIsDirectory:s(I=>{try{return statSync(I).isDirectory()}catch{return false}},"pathIsDirectory")});return R.content===m.content?m:{...m,content:R.content}})}s(eA,"rewriteGeneratedReferences");$t();uo();var qM=/!?\[[^\]]*\]\(([^)]+)\)/g,QM=/^\s*\[[^\]\n]+\]:\s*(?:<([^>\n]*)>|(\S+))/gm;function t$(t){return t.endsWith(".md")||t.endsWith(".mdc")}s(t$,"isMarkdownLikeOutput");function e$(t,e){return e.some(([r,n])=>t>=r&&t<n)}s(e$,"isOffsetInRanges");function r$(t){let e=t.trim(),r=/^(.*?)\s+(["'])([\s\S]*?)\2\s*$/.exec(e);return r?.[1]!==void 0&&(e=r[1].trim()),e.startsWith("<")&&e.endsWith(">")&&(e=e.slice(1,-1).trim()),e}s(r$,"parseMarkdownLinkDestination");function n$(t){let e=t.trim();return !e||e.startsWith("#")||/^https?:\/\//i.test(e)||/^mailto:/i.test(e)||/^data:/i.test(e)||/^javascript:/i.test(e)||/^ftp:/i.test(e)?true:/^[a-zA-Z]:[\\/]/.test(e)?false:!!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)}s(n$,"shouldSkipLocalValidation");function o$(t,e){if(e.has(t))return true;try{let r=statSync(t);return r.isFile()||r.isDirectory()}catch{return false}}s(o$,"pathExistsForGenerate");function s$(t,e,r){let o=r$(t).split("#")[0]??"",{candidate:i}=As(o),a=i,l=Ei.exec(a);l&&(a=a.slice(0,l.index));let c;try{c=decodeURIComponent(a);}catch{c=a;}if(n$(c))return [];let m=Ka(c,e,r);if(m.length===0){let u=V(e),d=j(e,r);m=[j(e,u.join(u.dirname(d),c)),j(e,u.join(e,c))];}let p=[];for(let u of m)for(let d of Wa(e,u)){let g=j(e,d);p.includes(g)||p.push(g);}return p}s(s$,"resolveMarkdownLinkTargets");function i$(t,e){let r=Ef(e,t),n=[];for(let o of t){if(!t$(o.path))continue;let i=j(e,V(e).join(e,o.path)),a=sm(o.content),l=s((c,m)=>{if(e$(m,a))return;let p=s$(c,e,i);p.length!==0&&(p.some(u=>o$(u,r))||n.push({generatePath:o.path,target:o.target,rawLink:c.trim(),checkedPaths:p}));},"visitDestination");for(let c of o.content.matchAll(qM)){let m=c[1];m!==void 0&&l(m,c.index??0);}for(let c of o.content.matchAll(QM)){let m=(c[1]??c[2]??"").trim();m&&l(m,c.index??0);}}return n}s(i$,"findBrokenMarkdownLinks");function rA(t,e){let r=i$(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
|
-
`)}
|
|
155
|
+
Fix canonical sources or generators so every local link targets an existing file or folder.`)}s(rA,"validateGeneratedMarkdownLinks");Br();var oA="AGENTS.md";function nA(t){switch(t){case "created":return 3;case "updated":return 2;case "unchanged":return 1;case "skipped":return 0}}s(nA,"statusRank");function a$(t,e){return nA(e.status)<=nA(t.status)?t:{...t,status:e.status,currentContent:e.currentContent??t.currentContent}}s(a$,"mergeDuplicateMetadata");function Sm(t){return t.trim()}s(Sm,"trimmedContent");function l$(t,e){if(!t.path.endsWith(oA)||t.path!==e.path)return null;let r=Sm(t.content),n=Sm(e.content);if(!r||!n)return null;let o=r.includes(n),i=n.includes(r);return o===i?null:o?t:e}s(l$,"richerAgentsResult");function c$(t,e){if(!t.path.endsWith(oA)||t.path!==e.path)return null;let r=t.target===Gi?t:e.target===Gi?e:null,n=r===t?e:t;if(!r)return null;let o=Sm(r.content).length,i=Sm(n.content).length;return o===i?null:o>i?r:n}s(c$,"richerCodexAgentsResult");function sA(t){let e=[];for(let r of t){let n=e.findIndex(i=>i.path===r.path);if(n===-1){e.push(r);continue}let o=e[n];if(o.content!==r.content){let i=l$(o,r);if(i){e[n]=i;continue}let a=c$(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]=a$(o,r);}return e}s(sA,"resolveOutputCollisions");function iA(t){let e=t.currentContent===void 0?"created":t.currentContent!==t.content?"updated":"unchanged";return t.status===e?t:{...t,status:e}}s(iA,"refreshResultStatus");w();ct();Ur();function lA(t,e){return t===null?"created":t!==e?"updated":"unchanged"}s(lA,"computeStatus");function m$(t,e,r){let n=rf(t,e,r);if(n!==null)return n;let o=ot(t);if(!o)return null;let i=r==="global"?o.globalSupport?.layout:o.project;return i?(n=i.rewriteGeneratedPath?i.rewriteGeneratedPath(e):e,n):null}s(m$,"resolveGeneratedOutputPath");async function Qa(t,e,r,n,o,i){let a=m$(e,r.path,o);if(a===null)return null;let l=await y(join(n,a)),c=t.findIndex(u=>u.path===a&&u.target===e),m=c>=0?t[c]:void 0,p=i?.mergeContent?.(l,m,r.content,a)??r.content;return c>=0&&t.splice(c,1),t.push({target:e,path:a,content:p,currentContent:l??void 0,status:lA(l,p)}),a}s(Qa,"emitGeneratedOutput");function Lf(t,e,r){return {capability:lo(t,r)?.[e]??{level:"none"},scope:r}}s(Lf,"featureContext");async function fs(t,e,r,n,o,i,a,l){if(o)for(let c of e){let m=l(c);if(!m)continue;let p=Lf(c,a,i);for(let u of m(r,p)){let d=await Qa(t,c,u,n,i);if(d===null)continue;let g=wt(c,i);if(g?.mirrorGlobalPath){let h=g.mirrorGlobalPath(d,e),C=h===null?[]:Array.isArray(h)?h:[h];for(let R of C){let I=await y(join(n,R));t.push({target:c,path:R,content:u.content,currentContent:I??void 0,status:lA(I,u.content)});}}}}}s(fs,"generateFeature");sp();ct();function p$(t){return t?.rootInstructionPath?[t.rootInstructionPath,...Im(t)]:[]}s(p$,"rootDecorationPaths");function cA(t,e,r="project"){return t.map(n=>{let o=wt(n.target,r);if(!o)return n;let i=p$(o);if(i.length===0||!i.includes(n.path))return n;let l=n.path===o.rootInstructionPath&&o.renderPrimaryRootInstruction?o.renderPrimaryRootInstruction(e):n.content,c=Fh(l);return c===n.content?n:{...n,content:c}})}s(cA,"decoratePrimaryRootInstructions");ct();Ur();hd();function Af(t,e,r,n,o){let a=(Pe(t)??ot(t))?.mergeGeneratedOutputContent?.(e,r,n,o);if(a!=null)return a;let l=r?.content??e;return l!==null&&YR.includes(o)?ZR(l,n):n}s(Af,"mergeOutputContent");async function mA(t,e,r,n,o){for(let i of e){let a=ki(i,"permissions",void 0,o)??ot(i)?.generators.generatePermissions;if(a)for(let l of a(r))await Qa(t,i,l,n,o,{mergeContent:s((c,m,p,u)=>Af(i,c,m,p,u),"mergeContent")});}}s(mA,"generatePermissionsFeature");async function pA(t,e,r,n,o,i){for(let a of e){let l=ki(a,"hooks",i,o)??ot(a)?.generators.generateHooks;if(!l)continue;let c=Lf(a,"hooks",o),m=[...l(r,c)],u=(Pe(a)??ot(a))?.postProcessHookOutputs;u&&(m=[...await u(n,r,m)]);for(let d of m)await Qa(t,a,d,n,o,{mergeContent:s((g,h,C,R)=>Af(a,g,h,C,R),"mergeContent")});}}s(pA,"generateHooksFeature");async function uA(t,e,r,n,o){for(let i of e){let l=(Pe(i)??ot(i))?.emitScopedSettings;if(!l)continue;let c=l(r,o);if(c.length!==0)for(let m of c)await Qa(t,i,m,n,o,{mergeContent:s((p,u,d,g)=>Af(i,p,u,d,g),"mergeContent")});}}s(uA,"generateScopedSettingsFeature");async function Cm(t){let{config:e,canonical:r,projectRoot:n,scope:o="project",targetFilter:i}=t,a=[...e.targets,...e.pluginTargets??[]],l=i?a.filter(b=>i.includes(b)):a;function c(b,Y){return ki(b,Y,e,o)}s(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"),I=[];await fs(I,l,r,n,m,o,"rules",b=>c(b,"rules")),await fs(I,l,r,n,p,o,"commands",b=>c(b,"commands")),await fs(I,l,r,n,u,o,"agents",b=>c(b,"agents")),await fs(I,l,r,n,d,o,"skills",b=>c(b,"skills")),await fs(I,l,r,n,g,o,"mcp",b=>c(b,"mcp")),h&&await mA(I,l,r,n,o),C&&await pA(I,l,r,n,o,e),await fs(I,l,r,n,R,o,"ignore",b=>c(b,"ignore"));let k=new Set(e.features);for(let b of l){let U=(Pe(b)??ot(b))?.globalSupport?.scopeExtras;if(U){let z=await U(r,n,o,k);I.push(...z);}}(g||R||C||u||h)&&await uA(I,l,r,n,o);let D=cA(I,r,o),P=eA(D,r,e,n,o,l);return rA(P,n),sA(WL(P.map(iA),r,e))}s(Cm,"generate");w();ct();async function dA(t,e=t){let r=await readdir(t,{withFileTypes:true}),n=[];for(let o of r){let i=join(t,o.name);if(o.isDirectory()){n.push(...await dA(i,e));continue}n.push(relative(e,i).replace(/\\/g,"/"));}return n}s(dA,"listFiles");async function g$(t,e,r){if(r.has(e))return;let n=join(t,e);await F(n)&&await rm$1(n,{recursive:true,force:true});}s(g$,"removeIfStale");async function fA(t){let e=new Set(t.expectedPaths),r=new Set,n=t.scope??"project";for(let o of t.targets){let i=ef(o,n);if(i){for(let a of i.files)r.add(a);for(let a of i.dirs){let l=join(t.projectRoot,a);if(await F(l))for(let c of await dA(l))r.add(`${a}/${c}`.replace(/\/+/g,"/"));}}}for(let o of r)await g$(t.projectRoot,o,e);}s(fA,"cleanupStaleGeneratedOutputs");w();$i();var R$=6e4,O$=30,k$=200,E$=2e3;async function Pf(t,e={}){let r=e.retries??O$,n=e.retryDelayMs??k$,o=e.staleMs??R$;await mkdir(dirname(t),{recursive:true});let i=0;for(;;){let a=await L$(t);if(a)return a;let l=await A$(t);if(l!=="young"&&w$(l,o)){await rm$1(t,{recursive:true,force:true}).catch(()=>{});continue}if(i>=r){let c=l==="young"?null:l;throw new dl(t,b$(c))}i++,await T$(n);}}s(Pf,"acquireProcessLock");async function L$(t){try{await mkdir(t,{recursive:!1});}catch(i){if(i.code==="EEXIST")return null;throw i}let e=join(t,"holder.json"),r={pid:process.pid,started:Date.now(),hostname:_A()};await writeFile(e,JSON.stringify(r),"utf-8");let n=false,o=s(()=>{if(!n){n=true;try{rmSync(t,{recursive:!0,force:!0});}catch{}}},"signalHandler");return process.once("SIGINT",o),process.once("SIGTERM",o),process.once("exit",o),async()=>{n||(n=true,process.off("SIGINT",o),process.off("SIGTERM",o),process.off("exit",o),await rm$1(t,{recursive:true,force:true}).catch(()=>{}));}}s(L$,"tryAcquire");async function A$(t){try{let e=await readFile(join(t,"holder.json"),"utf-8"),r=JSON.parse(e);return x$(r)?r:null}catch{try{let e=await stat(t);if(Date.now()-e.mtimeMs<E$)return "young"}catch{}return null}}s(A$,"inspectLock");function w$(t,e){return !t||Date.now()-t.started>e?true:t.hostname&&t.hostname!==_A()?false:!P$(t.pid)}s(w$,"isStale");function P$(t){if(!Number.isInteger(t)||t<=0)return false;try{return process.kill(t,0),!0}catch(e){return e.code==="EPERM"}}s(P$,"isProcessAlive");function b$(t){return t?`${t.hostname?`${t.hostname}:`:""}pid ${t.pid} (running ${Date.now()-t.started}ms)`:"unknown (unreadable lock metadata)"}s(b$,"describeHolder");function x$(t){if(typeof t!="object"||t===null)return false;let e=t;return typeof e.pid=="number"&&typeof e.started=="number"}s(x$,"isLockMetadata");function _A(){return hostname()}s(_A,"getHostname");function T$(t){return new Promise(e=>setTimeout(e,t))}s(T$,"sleep");nf();Ur();async function v$(t,e){let{source:r}=t,n;if(r.startsWith("file:")||r.startsWith("./")||r.startsWith("../")||r.startsWith("/")){let i=r.startsWith("file:")?fileURLToPath(r):r,a=resolve(e,i);n=pathToFileURL(a).href;}else n=r;return await import(n)}s(v$,"importPluginModule");function M$(t){return "descriptor"in t?[t.descriptor]:"descriptors"in t&&Array.isArray(t.descriptors)?t.descriptors:"default"in t?[t.default]:[]}s(M$,"extractDescriptors");async function Rm(t,e){let r;try{r=await v$(t,e);}catch(i){throw new Error(`Plugin '${t.source}' failed to import: ${i instanceof Error?i.message:String(i)}`,{cause:i})}let n=M$(r),o=[];for(let i of n)try{let a=nm(i);VE(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}}s(Rm,"loadPlugin");async function IA(t,e){let r=[];return await Promise.all(t.map(async n=>{try{let o=await Rm(n,e);r.push(o);}catch(o){_.warn(`Plugin '${n.source}' failed to load: ${o instanceof Error?o.message:String(o)}`);}})),r}s(IA,"loadAllPlugins");async function Te(t,e){t.plugins.length!==0&&await IA(t.plugins,e);}s(Te,"bootstrapPlugins");ct();function bf(t,e,r="project"){let n=[],o=[...t.targets,...t.pluginTargets??[]];for(let i of t.features){let a,l;switch(i){case "rules":l=e.rules.length,a="rules";break;case "commands":l=e.commands.length,a=l>0?`commands (${l})`:"commands";break;case "agents":l=e.agents.length,a=l>0?`agents (${l})`:"agents";break;case "skills":l=e.skills.length,a=l>0?`skills (${l})`:"skills";break;case "mcp":l=e.mcp?Object.keys(e.mcp.mcpServers).length:0,a=l>0?`mcp (${l} servers)`:"mcp";break;case "hooks":l=$$(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]=rm(m,i,t,r);if(n.push({feature:a,count:l,support:c}),i==="rules"){let m=e.rules.filter(p=>!p.root);if(m.length>0){let p={};for(let u of o)p[u]=rm(u,"additionalRules",t,r);n.push({feature:`additional rules (${m.length})`,count:m.length,support:p});}}}return n}s(bf,"buildCompatibilityMatrix");function $$(t){if(!t)return 0;let e=0;for(let r of Object.values(t))Array.isArray(r)&&(e+=r.length);return e}s($$,"countHooks");var G$={"claude-code":"Claude"};function SA(t){return G$[t]??t}s(SA,"matrixColumnLabel");Br();ct();var j$=["rules","additionalRules","commands","agents","skills","mcp","hooks","ignore","permissions"];function CA(t){return Object.fromEntries(j$.map(e=>[e,Object.fromEntries(xt.map(r=>{let o=lo(r,t)?.[e];return [r,o??{level:"none"}]}))]))}s(CA,"buildSupportMatrix");CA("project");CA("global");var xf={native:"\u2713",embedded:"\u25C6",partial:"\u25D0",none:"\u2013"},tl={green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",dim:"\x1B[2m",reset:"\x1B[0m"};function U$(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""}s(U$,"noColor");function K$(t,e){return U$()?e:`${t}${e}${tl.reset}`}s(K$,"colorize");var W$={native:tl.green,embedded:tl.blue,partial:tl.yellow,none:tl.dim};function RA(t){let e=xf[t];return K$(W$[t],e)}s(RA,"coloredSymbol");function Tf(t,e){let r=process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!=="",n={cyan:"\x1B[36m",magenta:"\x1B[35m",bold:"\x1B[1m",dim:"\x1B[2m",green:"\x1B[32m",blue:"\x1B[34m",yellow:"\x1B[33m",reset:"\x1B[0m"},o=s((U,z)=>r?z:`${U}${z}${n.reset}`,"c"),i=s(U=>U.replace(/\u001b\[[0-9;]*m/g,"").length,"visibleLength"),a=s((U,z)=>{let st=i(U),St=Math.max(0,z-st);return U+" ".repeat(St)},"padWithColor"),l=Math.max(12,...e.map(U=>U.length)),c=e.map(U=>SA(U)),m=Math.max(8,l),p=Math.max(12,...t.map(U=>U.feature.length)),u=s(U=>o(n.dim,"\u250C"+U.map(z=>"\u2500".repeat(z)).join("\u252C")+"\u2510"),"border"),d=s(U=>o(n.dim,"\u251C"+U.map(z=>"\u2500".repeat(z)).join("\u253C")+"\u2524"),"sep"),g=s(U=>o(n.dim,"\u2514"+U.map(z=>"\u2500".repeat(z)).join("\u2534")+"\u2518"),"bottom"),h=[p,...e.map(()=>m)],C=u(h),R=[a(o(n.bold+n.cyan,"Feature"),p),...c.map(U=>a(o(n.bold+n.magenta,U),m))],I=o(n.dim,"\u2502")+R.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502"),k=d(h),D=t.map(U=>{let z=[a(o(n.cyan,U.feature),p)];for(let st of e){let St=U.support[st]??"none",lt=r?xf[St]:RA(St);z.push(a(` ${lt} `,m));}return o(n.dim,"\u2502")+z.join(o(n.dim,"\u2502"))+o(n.dim,"\u2502")}),P=g(h),b=[C,I,k,...D,P];b.push("");let Y=[o(n.green,"\u2713")+" = native",o(n.blue,"\u25C6")+" = embedded",o(n.yellow,"\u25D0")+" = partial",o(n.dim,"\u2013")+" = not supported"];return b.push(o(n.bold,"Legend: ")+Y.join(" ")),b.join(`
|
|
156
|
+
`)}s(Tf,"formatMatrix");function Df(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
|
-
`}
|
|
160
|
-
`),t.verbose===true){let d=
|
|
161
|
-
`));}}
|
|
162
|
-
`),n=
|
|
160
|
+
`}s(Df,"formatVerboseDetails");async function gs(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(d=>d.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Te(a,r);let{canonical:c}=await xe(a,l.configDir,{},l.canonicalDir),m=i??[...a.targets,...a.pluginTargets??[]],p=bf(a,c,n);if(p.length===0){_.info("No features enabled. Enable features in agentsmesh.yaml.");return}let u=Tf(p,m);if(process.stdout.write(u),process.stdout.write(`
|
|
161
|
+
`),t.verbose===true){let d=Df(c);d&&(process.stdout.write(d),process.stdout.write(`
|
|
162
|
+
`));}}s(gs,"runMatrix");function kA(t,e,r){let n=resolve(t),o=resolve(t,e);if(o===n||o.startsWith(`${n}${sep}`))return o;throw new Error(`Unsafe generated output path for ${r}: ${e}`)}s(kA,"ensurePathInsideRoot");function Ff(t,e){return t==="global"?`~/${e}`:e}s(Ff,"formatDisplayPath");async function Pi(t,e,r={}){if(t.features!==void 0)throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");let n=e??process.cwd(),o=t.check===true,i=t["dry-run"]===true,a=t.force===true,l=t.global===true?"global":"project",c=t["refresh-cache"]===true||t["no-cache"]===true,m=t.targets,p=typeof m=="string"&&m?m.split(",").map(P=>P.trim()).filter(Boolean):void 0,{config:u,context:d}=await yt(n,l);await Te(u,n);let g=u.collaboration?.lock_features??[];if(u.collaboration?.strategy==="lock"&&!a&&g.length>0){let P=await fm(d.canonicalDir);if(P!==null){let b=await An(d.canonicalDir),Y=gm(P.checksums,b,g);if(Y.length>0){_.error("Locked feature violation (strategy: lock). Modified files:");for(let U of Y)_.error(` ${U}`);throw _.error("Run 'agentsmesh generate --force' to accept these changes."),new Error("Locked feature violation. Use --force to override.")}}}let{canonical:h,resolvedExtends:C}=await xe(u,d.configDir,{refreshRemoteCache:c},d.canonicalDir),R=[...u.targets,...u.pluginTargets??[]];if(p){let P=p.filter(b=>!R.includes(b));if(P.length>0)throw new Error(`Unknown target(s) in --targets: ${P.join(", ")}. Available: ${R.join(", ")}`)}let I=p?R.filter(P=>p.includes(P)):R,k=await Cm({config:u,canonical:h,projectRoot:d.rootBase,scope:l,targetFilter:p});if(k.length===0){if(_.info("No files to generate (no root rule or rules feature disabled)."),o)return _.success("Generated files are in sync."),0;if(!i){let P=await Pf(join(d.canonicalDir,".generate.lock"));try{let b=await An(d.canonicalDir),Y=C.length>0?await ds(C):{},U=await Za(join(d.canonicalDir,"packs")),z=process.env.USER??process.env.USERNAME??"unknown";await Xa(d.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:z,libVersion:Mi(),checksums:b,extends:Y,packs:U});try{await Mm(qt(),join(d.configDir,".agentsmeshcache"));}catch(st){_.warn(`Could not create .agentsmeshcache symlink: ${st instanceof Error?st.message:String(st)}`);}}finally{await P();}}return r.printMatrix!==false&&await gs(t,n),0}if(o){let P=k.filter(b=>b.status!=="unchanged");if(P.length===0)return _.success("Generated files are in sync."),0;for(let b of P)_.error(`[check] ${b.status} ${Ff(l,b.path)} (${b.target})`);return _.error("Generated files are out of sync. Run 'agentsmesh generate' to update them."),1}let D=i?null:await Pf(join(d.canonicalDir,".generate.lock"));try{for(let P of k)if(i)_.info(`[dry-run] ${P.status} ${Ff(l,P.path)} (${P.target})`);else if(P.status==="created"||P.status==="updated"){let b=kA(d.rootBase,P.path,P.target);await S(b,P.content),_.success(`${P.status} ${Ff(l,P.path)}`);}if(!i){let P=k.filter(lt=>lt.status==="created").length,b=k.filter(lt=>lt.status==="updated").length,Y=k.filter(lt=>lt.status==="unchanged").length;await fA({projectRoot:d.rootBase,targets:I,expectedPaths:k.map(lt=>lt.path),scope:l}),P>0||b>0?_.info(`Generated: ${P} created, ${b} updated, ${Y} unchanged`):_.info(`Nothing changed. (${Y} unchanged)`);let U=await An(d.canonicalDir),z=C.length>0?await ds(C):{},st=await Za(join(d.canonicalDir,"packs")),St=process.env.USER??process.env.USERNAME??"unknown";await Xa(d.canonicalDir,{generatedAt:new Date().toISOString(),generatedBy:St,libVersion:Mi(),checksums:U,extends:z,packs:st});try{await Mm(qt(),join(d.configDir,".agentsmeshcache"));}catch(lt){_.warn(`Could not create .agentsmeshcache symlink: ${lt instanceof Error?lt.message:String(lt)}`);}}}finally{D&&await D();}return r.printMatrix!==false&&await gs(t,n),0}s(Pi,"runGenerate");w();ct();Br();var z$=["codex-cli"];function EA(){return xt.filter(t=>!z$.includes(t))}s(EA,"starterInitTargetIds");var H$=["rules","commands","agents","skills","mcp","hooks","ignore","permissions"],V$=EA();function Om(t,e=V$){let r=(t.length>0?t:e).map(o=>` - ${o}`).join(`
|
|
163
|
+
`),n=H$.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
|
-
`}
|
|
170
|
+
`}s(Om,"buildConfig");var km=`---
|
|
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
|
+
`,vf=`---
|
|
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
|
+
`,Mf=`---
|
|
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
|
+
`,$f=`---
|
|
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
|
+
`,Gf=`---
|
|
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
|
+
`,jf=`{
|
|
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
|
+
`,Uf=`# 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
|
+
`,Kf=`# 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
|
+
`,Wf=`# 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
|
+
`,LA=`# 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
|
+
`;w();ct();function AA(t){let e=[];for(let r of Gt)for(let n of tf(r.id,t))e.push({target:r.id,path:n});return e}s(AA,"collectDetectionPaths");function wA(t){let e=new Map;for(let{target:r,path:n}of AA(t)){let o=e.get(r)??[];o.push(n),e.set(r,o);}return [...e.entries()].map(([r,n])=>({id:r,paths:n}))}s(wA,"toolIndicators");wA("project");async function PA(t,e="project"){let r=[];for(let{id:n,paths:o}of wA(e))for(let i of o){let a=join(t,i);if(await F(a)){r.push(n);break}}return [...new Set(r)]}s(PA,"detectExistingConfigs");w();function vt(t,e){return join(t,e)}s(vt,"ab");async function Bf(t){return await F(t)?(await readdir(t,{withFileTypes:true})).filter(r=>r.isFile()&&r.name.endsWith(".md")).length:0}s(Bf,"countMdFiles");async function Y$(t){let e=vt(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}s(Y$,"hasAnyImportedSkill");async function zf(t){let e=vt(t,"rules");await O(e),await S(join(e,"_root.md"),km),_.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),vf),_.success("Created .agentsmesh/rules/_example.md");let r=vt(t,"commands");await O(r),await S(join(r,"_example.md"),Mf),_.success("Created .agentsmesh/commands/_example.md");let n=vt(t,"agents");await O(n),await S(join(n,"_example.md"),$f),_.success("Created .agentsmesh/agents/_example.md");let o=vt(t,join("skills","_example"));await O(o),await S(join(o,"SKILL.md"),Gf),_.success("Created .agentsmesh/skills/_example/SKILL.md"),await S(vt(t,"mcp.json"),jf),_.success("Created .agentsmesh/mcp.json"),await S(vt(t,"hooks.yaml"),Uf),_.success("Created .agentsmesh/hooks.yaml"),await S(vt(t,"permissions.yaml"),Kf),_.success("Created .agentsmesh/permissions.yaml"),await S(vt(t,"ignore"),Wf),_.success("Created .agentsmesh/ignore");}s(zf,"writeScaffoldFull");async function xA(t){let e=vt(t,"rules"),r=await Bf(e),n=join(e,"_root.md"),o=await F(n);await O(e),r===0?(await S(n,km),_.success("Created .agentsmesh/rules/_root.md"),await S(join(e,"_example.md"),vf),_.success("Created .agentsmesh/rules/_example.md")):o||(await S(n,km),_.success("Created .agentsmesh/rules/_root.md"));let i=vt(t,"commands");await Bf(i)===0&&(await O(i),await S(join(i,"_example.md"),Mf),_.success("Created .agentsmesh/commands/_example.md"));let a=vt(t,"agents");if(await Bf(a)===0&&(await O(a),await S(join(a,"_example.md"),$f),_.success("Created .agentsmesh/agents/_example.md")),!await Y$(t)){let u=vt(t,join("skills","_example"));await O(u),await S(join(u,"SKILL.md"),Gf),_.success("Created .agentsmesh/skills/_example/SKILL.md");}let l=vt(t,"mcp.json");await F(l)||(await S(l,jf),_.success("Created .agentsmesh/mcp.json"));let c=vt(t,"hooks.yaml");await F(c)||(await S(c,Uf),_.success("Created .agentsmesh/hooks.yaml"));let m=vt(t,"permissions.yaml");await F(m)||(await S(m,Kf),_.success("Created .agentsmesh/permissions.yaml"));let p=vt(t,"ignore");await F(p)||(await S(p,Wf),_.success("Created .agentsmesh/ignore"));}s(xA,"writeScaffoldGapFill");var el="agentsmesh.yaml",TA="agentsmesh.local.yaml",Z$=["agentsmesh.local.yaml",".agentsmeshcache",".agentsmesh/.lock.tmp",".agentsmesh/packs/"],q$=Object.fromEntries(Gt.map(t=>[t.id,(e,r)=>t.generators.importFrom(e,{scope:r})])),NA=Gt.filter(t=>t.globalSupport!==void 0).map(t=>t.id);function Q$(t,e){if(e.has(t))return true;let r=t.replace(/\/$/,"");for(;r.includes("/")&&(r=r.slice(0,r.lastIndexOf("/")),r!=="");)if(e.has(r)||e.has(`${r}/`)||e.has(`${r}/**`))return true;return false}s(Q$,"isCoveredByExisting");async function tG(t){let e=join(t,".gitignore"),r=await y(e)??"",n=new Set(r.split(`
|
|
286
|
+
`).map(a=>a.trim()).filter(a=>a.length>0&&!a.startsWith("#"))),o=Z$.filter(a=>!Q$(a,n));if(o.length===0)return;let i=r.endsWith(`
|
|
286
287
|
`)||r===""?"":`
|
|
287
|
-
`;await S(e,r+
|
|
288
|
+
`;await S(e,r+i+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(
|
|
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
|
+
`);}s(tG,"appendToGitignore");async function DA(t,e={}){let r=e.global===true?"global":"project",n=Ki(t,r),o=join(n.configDir,el);if(await F(o))throw new Error(`Already initialized. ${el} exists. Remove it first to re-init.`);let i=await PA(n.rootBase,r),a=r==="global"?i.filter(m=>NA.includes(m)):i,l=r==="global"?NA:void 0;if(a.length>0)if(_.info(`Found existing configurations: ${a.join(", ")}`),e.yes){_.info("Auto-importing existing configurations (--yes)...");let m=0;for(let p of a){let u=q$[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("\\","/");_.success(` ${h} \u2192 ${C}`);}m+=d.length;}m>0&&_.info(`Imported ${m} file(s) from ${a.length} tool(s).`),await xA(n.canonicalDir),await S(o,Om(a,l)),_.success(`Created ${el} (targets: ${a.join(", ")})`);}else _.info("Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually."),await zf(n.canonicalDir),await S(o,Om([],l)),_.success(`Created ${el}`);else await zf(n.canonicalDir),await S(o,Om([],l)),_.success(`Created ${el}`);let c=join(n.configDir,TA);await S(c,LA),_.success(`Created ${TA}`),r==="project"&&(await tG(t),_.success("Updated .gitignore"));}s(DA,"runInit");ct();var eG=Object.fromEntries(Gt.map(t=>[t.id,{importFrom:t.generators.importFrom,emptyImportMessage:t.emptyImportMessage,lintRules:t.lintRules,lint:t.lint,capabilities:t.capabilities}]));function Em(t){let e=eG[t];if(!e)throw new Error(`Unknown target: ${t}`);return e}s(Em,"getTargetCatalogEntry");Ur();function FA(t,e,r){for(let n of t){let o=relative(e,n.fromPath);_.success(`${o} \u2192 ${n.toPath}`);}_.info(`Imported ${t.length} file(s). Run 'agentsmesh generate${r==="global"?" --global":""}' to sync to other tools.`);}s(FA,"formatImportResults");async function vA(t,e){let r=e??process.cwd(),n=t.from;if(typeof n!="string"||!n)throw new Error("--from is required. Example: agentsmesh import --from claude-code");let o=n.toLowerCase().trim(),i=t.global===true?"global":"project";if(bn(o)){let p=Ki(r,i),u=Em(o),d=await u.importFrom(p.rootBase,{scope:i});if(d.length===0){_.info(u.emptyImportMessage);return}FA(d,p.rootBase,i);return}let a,l;try{({config:a,context:l}=await yt(r,i));}catch{throw new Error(`Unknown --from "${n}" and no agentsmesh.yaml found. Run 'agentsmesh init' to enable plugin targets, or use a builtin: ${xt.join(", ")}.`)}await Te(a,r);let c=ot(o);if(!c)throw new Error(`Unknown --from "${n}". Supported: ${[...xt,...a.pluginTargets??[]].join(", ")}.`);let m=await c.generators.importFrom(l.rootBase,{scope:i});if(m.length===0){_.info(c.emptyImportMessage);return}FA(m,l.rootBase,i);}s(vA,"runImport");function $A(t){let e=[],r={new:0,updated:0,unchanged:0,deleted:0};for(let n of t){if(n.status==="unchanged"){r.unchanged++;continue}if(n.status==="created"){r.new++;let o=createTwoFilesPatch(`${n.path} (current)`,`${n.path} (generated)`,"",n.content,void 0,void 0,{context:3});e.push({path:n.path,patch:o});continue}if(n.status==="updated"&&n.currentContent!==void 0){r.updated++;let o=createTwoFilesPatch(`${n.path} (current)`,`${n.path} (generated)`,n.currentContent,n.content,void 0,void 0,{context:3});e.push({path:n.path,patch:o});continue}}return {diffs:e,summary:r}}s($A,"computeDiff");function GA(t){return `${t.new} files would be created, ${t.updated} updated, ${t.unchanged} unchanged, ${t.deleted} deleted`}s(GA,"formatDiffSummary");async function jA(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(d=>d.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Te(a,r);let{canonical:c}=await xe(a,l.configDir,{},l.canonicalDir),m=await Cm({config:a,canonical:c,projectRoot:l.rootBase,scope:n,targetFilter:i});if(m.length===0){_.info("No files to generate (no root rule or rules feature disabled).");return}let{diffs:p,summary:u}=$A(m);for(let d of p)process.stdout.write(d.patch);_.info(GA(u));}s(jA,"runDiff");w();Ur();Co();kt();var nG=[{canonicalKey:"permissions",capabilityKey:"permissions",featureFlag:"permissions",file:".agentsmesh/permissions.yaml",label:"permissions",hasContent:s(t=>{let e=t.permissions;if(!e)return false;let r=e.ask?.length??0;return e.allow.length+e.deny.length+r>0},"hasContent")},{canonicalKey:"hooks",capabilityKey:"hooks",featureFlag:"hooks",file:".agentsmesh/hooks.yaml",label:"hooks",hasContent:s(t=>{let e=t.hooks;return e?Object.values(e).some(r=>Array.isArray(r)&&r.length>0):false},"hasContent")},{canonicalKey:"mcp",capabilityKey:"mcp",featureFlag:"mcp",file:".agentsmesh/mcp.json",label:"MCP servers",hasContent:s(t=>{let e=t.mcp;return e?Object.keys(e.mcpServers).length>0:false},"hasContent")},{canonicalKey:"commands",capabilityKey:"commands",featureFlag:"commands",file:".agentsmesh/commands",label:"commands",hasContent:s(t=>t.commands.length>0,"hasContent")},{canonicalKey:"agents",capabilityKey:"agents",featureFlag:"agents",file:".agentsmesh/agents",label:"agents",hasContent:s(t=>t.agents.length>0,"hasContent")},{canonicalKey:"skills",capabilityKey:"skills",featureFlag:"skills",file:".agentsmesh/skills",label:"skills",hasContent:s(t=>t.skills.length>0,"hasContent")},{canonicalKey:"ignore",capabilityKey:"ignore",featureFlag:"ignore",file:".agentsmesh/ignore",label:"ignore patterns",hasContent:s(t=>t.ignore.length>0,"hasContent")}];function UA(t){let e=new Set(t.enabledFeatures),r=[];for(let n of nG)!e.has(n.featureFlag)||!n.hasContent(t.canonical)||Me(t.capabilities[n.capabilityKey]).level!=="none"||r.push(G(n.file,t.target,`${t.target} does not support ${n.label}; canonical entries are silently dropped during generation. Disable the feature for this target or remove the canonical content.`));return r}s(UA,"lintSilentFeatureDrops");kt();var oG=/^(?:\s*(?:bash|sh|zsh|pwsh|powershell)\s+)?["']?(?<path>(?:\.{1,2}\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?:\s|$)/;function sG(t){let r=t.match(oG)?.groups?.path;return typeof r=="string"?r:null}s(sG,"extractScriptToken");function KA(t){if(t.hasScriptProjection)return [];let e=t.canonical.hooks;if(!e)return [];let r=[];for(let n of Object.values(e))if(Array.isArray(n))for(let o of n){if(typeof o?.command!="string")continue;let i=sG(o.command);i&&r.push(G(".agentsmesh/hooks.yaml",t.target,`${t.target} hook command references script "${i}"; agentsmesh does not copy hook scripts into ${t.target} output, so the script must already exist relative to the hook execution directory or the generated config will fail.`));}return r}s(KA,"lintHookScriptReferences");kt();function WA(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(G(r.source,t.target,`Rule has trigger: 'manual' (Cursor-style "@-mention only" activation), but ${t.target} loads every rule unconditionally. The rule will become always-on for ${t.target} \u2014 restrict it with \`targets: [cursor]\`, convert it to a skill with manual invocation, or remove it.`)));return e}s(WA,"lintRuleScopeInversion");var iG=["node_modules",".git","dist","coverage",".agentsmesh"];async function aG(t){return (await T(t)).filter(n=>{let o=relative(t,n);return !iG.some(i=>o.includes(`/${i}/`)||o.startsWith(`${i}/`))}).map(n=>relative(t,n))}s(aG,"getProjectFiles");async function zA(t,e,r,n,o={}){let i=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=i==="global"?[]:await aG(r);for(let R of l){let I=ot(R),k=bn(R)?Em(R):I;k?.capabilities&&g.push(...UA({target:R,capabilities:k.capabilities,canonical:e,enabledFeatures:t.features})),d&&g.push(...KA({target:R,canonical:e,hasScriptProjection:I?.postProcessHookOutputs!==void 0})),c&&g.push(...WA({target:R,canonical:e,preservesManualActivation:I?.preservesManualActivation===true})),c&&k?.lintRules&&g.push(...k.lintRules(e,r,h,{scope:i})),I?.generators.lint&&g.push(...I.generators.lint(e));let D={scope:i};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(R=>R.level==="error");return {diagnostics:g,hasErrors:C}}s(zA,"runLint");async function HA(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",o=t.targets,i=typeof o=="string"&&o?o.split(",").map(C=>C.trim()).filter(Boolean):void 0,{config:a,context:l}=await yt(r,n);await Te(a,r);let{canonical:c}=await xe(a,l.configDir,{},l.canonicalDir),{diagnostics:m,hasErrors:p}=await zA(a,c,l.configDir,i,{scope:n});if(m.length===0)return _.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)_.error(`${C.file} (${C.target}): ${C.message}`);if(d.length>0)for(let C of d)_.warn(`${C.file} (${C.target}): ${C.message}`);let g=u.length,h=d.length;return _.info(`${g} error${g!==1?"s":""}, ${h} warning${h!==1?"s":""}`),p?1:0}s(HA,"runLintCmd");var mG=300;function pG(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(pG,"normalizeWatchPath");function uG(t,e,r){let n=pG(relative(t,e));return n===".lock"||n===".lock.tmp"||n===".generate.lock"||n.endsWith("/.lock")||n.endsWith("/.lock.tmp")||n.endsWith("/.generate.lock")||n.includes("/.generate.lock/")||n.startsWith(".generate.lock/")}s(uG,"shouldIgnoreWatchPath");function dG(t,e,r,n,o,i,a,l,c){return JSON.stringify({features:t,rulesCount:e,commandsCount:r,agentsCount:n,skillsCount:o,mcpServerCount:i,permissionsCount:a,hooksCount:l,ignoreCount:c})}s(dG,"featureFingerprint");async function JA(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{context:o}=await yt(r,n),i=[o.canonicalDir,join(o.configDir,"agentsmesh.yaml"),join(o.configDir,"agentsmesh.local.yaml")],a=null,l=null,c=false,m=null,u=s(async()=>{if(c)return;a=null;let{config:C,context:R}=await yt(r,n),{canonical:I}=await xe(C,R.configDir,{},R.canonicalDir),k=I.mcp?Object.keys(I.mcp.mcpServers).length:0,D=I.permissions?I.permissions.allow.length+I.permissions.deny.length:0,P=I.hooks?Object.values(I.hooks).reduce((z,st)=>z+(Array.isArray(st)?st.length:0),0):0,b=I.ignore.length,Y=dG(C.features,I.rules.length,I.commands.length,I.agents.length,I.skills.length,k,D,P,b),U=l!==null&&l!==Y;l=Y,!c&&(await Pi(t,r,{printMatrix:false}),!c&&(U?await gs(t,r):_.info("Regenerated.")));},"run"),d=s(()=>{let C=u().catch(R=>{if(!c){let I=R instanceof Error?R.message:String(R);_.error(I);}}).finally(()=>{m===C&&(m=null);});m=C;},"scheduleRun"),g=s(()=>{c||(a&&clearTimeout(a),a=setTimeout(d,mG));},"schedule"),h=cG.watch(i,{ignoreInitial:true,usePolling:process.platform==="win32"});return h.on("all",(C,R)=>{uG(o.canonicalDir,R)||g();}),await new Promise((C,R)=>{h.once("ready",C),h.once("error",R);}),_.info(n==="global"?"Watching ~/.agentsmesh/ and agentsmesh.yaml...":"Watching .agentsmesh/ and agentsmesh.yaml..."),m=u(),await m,m=null,{stop:s(async()=>{c=true,a&&(clearTimeout(a),a=null),await h.close(),m&&await m;},"stop")}}s(JA,"runWatch");async function YA(t){let{config:e,configDir:r,canonicalDir:n}=t,o=await fm(n);if(o===null)return {inSync:false,hasLock:false,modified:[],added:[],removed:[],extendsModified:[],lockedViolations:[]};let i=await An(n),a=await ks(e,r),l=a.length>0?await ds(a):{},c=new Set(Object.keys(o.checksums)),m=new Set(Object.keys(i)),p=[],u=[],d=[];for(let I of c){let k=i[I];k===void 0?d.push(I):k!==o.checksums[I]&&p.push(I);}for(let I of m)c.has(I)||u.push(I);let g=new Set([...Object.keys(o.extends),...Object.keys(l)]),h=[];for(let I of g)l[I]!==o.extends[I]&&h.push(I);let C=gm(o.checksums,i,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}}s(YA,"checkLockSync");async function XA(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n);await Te(o,r);let a=await YA({config:o,configDir:i.configDir,canonicalDir:i.canonicalDir});if(!a.hasLock)return _.error("Not initialized for collaboration. Run 'agentsmesh generate' first."),1;if(a.inSync)return _.success("Lock file is in sync."),0;let l=new Set(a.lockedViolations);_.error("Conflict detected:");for(let c of a.extendsModified)_.error(` extend "${c}" was modified`);for(let c of a.modified){let m=l.has(c)?" [LOCKED]":"";_.error(` ${c} was modified${m}`);}for(let c of a.added){let m=l.has(c)?" [LOCKED]":"";_.error(` ${c} was added${m}`);}for(let c of a.removed){let m=l.has(c)?" [LOCKED]":"";_.error(` ${c} was removed${m}`);}return _.info("Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state."),1}s(XA,"runCheck");w();var gG=".lock",hG="<<<<<<<";async function Vf(t){let e=join(t,gG),r=await y(e);return r===null?false:r.includes(hG)}s(Vf,"hasLockConflict");async function qA(t,e,r){if(!await Vf(t))throw new Error("No conflict to resolve.");let o=await An(t),i=dirname(t),a=r?await ks(r,i):[],l=a.length>0?await ds(a):{},c=await Za(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});}s(qA,"resolveLockConflict");async function QA(t,e){let r=e??process.cwd(),n=t.global===true?"global":"project",{config:o,context:i}=await yt(r,n),a=i.canonicalDir;if(!await Vf(a)){_.info("No conflicts to resolve.");return}await qA(a,Mi(),o),_.success("Lock file conflict resolved.");}s(QA,"runMerge");w();var IG=promisify(execFile);async function Jf(t){let{stdout:e}=await IG("git",t,{env:{...process.env,GIT_TERMINAL_PROMPT:"0"}});return e.trim()}s(Jf,"runGit");async function tw(){try{return await Jf(["--version"]),!0}catch{return false}}s(tw,"isGitAvailable");async function SG(t,e){let r=[e,`refs/heads/${e}`,`refs/tags/${e}`],n;for(let o of r)try{let a=(await Jf(["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(i){n=i;}throw new Error(`Could not resolve ref "${e}" for ${t}: ${n instanceof Error?n.message:String(n)}`)}s(SG,"gitLsRemoteResolve");async function ew(t,e){let r=t===""?"HEAD":t;if(/^[0-9a-f]{40}$/i.test(r))return r.toLowerCase();if(r==="HEAD"){let o=(await Jf(["ls-remote",e,"HEAD"])).split(`
|
|
292
|
+
`).find(a=>a.trim().length>0);if(!o)throw new Error(`Could not resolve HEAD for ${e}`);let i=o.split(/\s+/)[0];if(!i||!/^[0-9a-f]{40}$/i.test(i))throw new Error(`Invalid ls-remote HEAD line for ${e}`);return i.toLowerCase()}return SG(e,r)}s(ew,"resolveRemoteRefForInstall");async function rw(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 ew(t.rawRef||"HEAD",e);if(t.kind==="github"){let l=`github:${t.org}/${t.repo}@${r}`;return {resolvedPath:(await Os(l,"install",{cacheDir:qt(),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:qt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:l,version:r}}let n=r,i=`git+${(t.gitPlusBase??e).split("#")[0]}#${n}`;return {resolvedPath:(await Os(i,"install",{cacheDir:qt(),refresh:false,allowOfflineFallback:false})).resolvedPath,sourceForYaml:i,version:r}}s(rw,"fetchInstallSource");async function nw(t,e){if(t.kind==="local")return {resolvedPath:t.localRoot,sourceForYaml:t.localSourceForYaml};try{let r=await rw(t);return {resolvedPath:r.resolvedPath,sourceForYaml:r.sourceForYaml,version:r.version}}catch(r){let n=r instanceof Error?r.message:String(r),o=new Error(`Failed to fetch from ${e}: ${n}. Check your network connection and try again.`);throw r instanceof Error&&(o.cause=r),o}}s(nw,"resolveInstallResolvedPath");function Yf(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("tree");if(n<2||n+1>=r.length)return null;let o=r[0],i=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!i||!a?null:{org:o,repo:i,ref:a,path:l||""}}catch{return null}}s(Yf,"parseGithubTreeUrl");function Xf(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("blob");if(n<2||n+1>=r.length)return null;let o=r[0],i=r[1],a=r[n+1],l=r.slice(n+2).join("/");return !o||!i||!a||!l?null:{org:o,repo:i,ref:a,path:l}}catch{return null}}s(Xf,"parseGithubBlobUrl");function Zf(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("-");if(n<0||r[n+1]!=="tree")return null;let o=n+1;if(o+1>=r.length)return null;let i=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!i?null:{namespace:m,project:c,ref:i,path:a||""}}catch{return null}}s(Zf,"parseGitlabTreeUrl");function qf(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean),n=r.indexOf("-");if(n<0||r[n+1]!=="blob")return null;let o=n+1;if(o+1>=r.length)return null;let i=r[o+1],a=r.slice(o+2).join("/"),l=r.slice(0,n);if(l.length<2)return null;let c=l[l.length-1],m=l.slice(0,-1).join("/");return !m||!c||!i||!a?null:{namespace:m,project:c,ref:i,path:a}}catch{return null}}s(qf,"parseGitlabBlobUrl");var CG=new Set(["tree","blob","commit","releases","actions","issues","pulls","settings","wiki","discussions","security","projects","packages"]);function Qf(t){try{let e=new URL(t);if(e.hostname!=="github.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.length>2||CG.has(r[1]))return null;let n=r[0],o=r[1];return {org:n,repo:o}}catch{return null}}s(Qf,"parseGithubRepoUrl");function tg(t){try{let e=new URL(t);if(e.hostname!=="gitlab.com")return null;let r=e.pathname.split("/").filter(Boolean).map(i=>i.replace(/\.git$/i,""));if(r.length<2||r.includes("-"))return null;let n=r[r.length-1],o=r.slice(0,-1).join("/");return !o||!n?null:{namespace:o,project:n}}catch{return null}}s(tg,"parseGitlabRepoUrl");function eg(t){let e=t.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);return e?{org:e[1],repo:e[2].replace(/\.git$/i,"")}:null}s(eg,"parseGitSshGithub");function rg(t){let e=t.match(/^git@gitlab\.com:(.+?)(?:\.git)?$/i);if(!e)return null;let n=e[1].replace(/\.git$/i,"").split("/").filter(Boolean);if(n.length<2)return null;let o=n[n.length-1];return {namespace:n.slice(0,-1).join("/"),project:o}}s(rg,"parseGitSshGitlab");w();var kG=/^[A-Za-z]:[\\/]/,EG=/^[A-Za-z]:\//;function ow(...t){return t.some(e=>e.includes("\\")||kG.test(e))?win32:posix}s(ow,"pathApiFor");function nl(t){return t.replace(/\\/g,"/")}s(nl,"toPosixPath");function rl(t){return nl(t).replace(/^\/+|\/+$/g,"")}s(rl,"normalizeInstallPathField");function Lm(t){let e=nl(t);return e===""||e==="."||e==="./."?".":e.startsWith("./")||e.startsWith("../")||e.startsWith("/")||EG.test(e)?e:`./${e}`}s(Lm,"normalizeLocalSourceForYaml");function fo(t){return {...t,source:t.source_kind==="local"?Lm(t.source):t.source,...t.path!==void 0?{path:rl(t.path)}:{},...t.paths!==void 0?{paths:t.paths.map(e=>rl(e))}:{}}}s(fo,"normalizePersistedInstallPaths");function sw(t,e,r){let n=ow(t,e),o=n.normalize(t),i=n.normalize(e),a=rl(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=rl(u),g=nl(n.relative(i,p))||".";return {kind:"local",rawRef:"",pathInRepo:a||d.replace(/\.md$/i,"").replace(/\/$/,""),localRoot:p,localSourceForYaml:Lm(g)}}let m=nl(n.relative(i,o))||".";return {kind:"local",rawRef:"",pathInRepo:a,localRoot:o,localSourceForYaml:Lm(m)}}s(sw,"localParsedFromAbsPath");async function ng(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=Yf(n)??Xf(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=Qf(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=Zf(n)??qf(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=tg(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=eg(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=rg(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 i=n.match(/^github:([^/]+)\/(.+?)@([^/@]+)$/);if(i){let c=i[1],m=i[2];return {kind:"github",rawRef:i[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 sw(l,e,o)}s(ng,"parseInstallSource");w();w();var iw=z.object({name:z.string().min(1),source:z.string().min(1),version:z.string().optional(),source_kind:z.enum(["github","gitlab","git","local"]),features:z.array(Cs).min(1),pick:Ui.optional(),target:de.optional(),path:z.string().optional(),paths:z.array(z.string().min(1)).min(1).optional(),as:Ai.optional()}),bG=z.object({version:z.literal(1),installs:z.array(iw).default([])});function xG(t,e){return t.length===e.length&&[...t].sort().every((r,n)=>r===[...e].sort()[n])}s(xG,"sameFeatures");function TG(t,e){return t.source===e.source&&t.target===e.target&&t.as===e.as&&xG(t.features,e.features)}s(TG,"sameInstallIdentity");function aw(t){return join(t,"installs.yaml")}s(aw,"manifestPath");async function og(t){let e=await y(aw(t));if(e===null)return [];try{return bG.parse(parse(e)).installs.map(r=>fo(r))}catch{return []}}s(og,"readInstallManifest");async function lw(t,e){let r=fo(e),o=(await og(t)).filter(i=>i.name!==r.name&&!TG(i,r));o.push(r),await S(aw(t),stringify({version:1,installs:o.sort((i,a)=>i.name.localeCompare(a.name))}));}s(lw,"upsertInstallManifestEntry");function cw(t){return fo(iw.parse({name:t.name,source:t.source,version:t.version,source_kind:t.sourceKind,features:t.features,pick:t.pick,target:t.target,path:t.path,paths:t.paths,as:t.as}))}s(cw,"buildInstallManifestEntry");async function DG(t){let e=await og(t.canonicalDir);if(e.length===0){_.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){_.info("All recorded packs are already installed.");return}for(let n of r)await t.reinstall(n);_.success(`Reinstalled ${r.length} pack(s) from .agentsmesh/installs.yaml.`);}s(DG,"syncInstalledPacks");async function mw(t){return t.sync?(await DG({canonicalDir:t.canonicalDir,reinstall:t.reinstall}),true):false}s(mw,"maybeRunInstallSync");function pw(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"?Ai.parse(t.as.trim()):void 0,nameOverride:typeof t.name=="string"?t.name.trim():""}}s(pw,"readInstallFlags");function hs(t){let e=[];return t.skills.length&&e.push("skills"),t.rules.length&&e.push("rules"),t.commands.length&&e.push("commands"),t.agents.length&&e.push("agents"),t.mcp!==null&&e.push("mcp"),t.permissions!==null&&e.push("permissions"),t.hooks!==null&&e.push("hooks"),t.ignore.length&&e.push("ignore"),e}s(hs,"featuresFromCanonical");async function Am(t){let{sliceRoot:e,implicitPick:r}=await lm(t),n=await cm(e);return {canonical:n,features:hs(n),implicitPick:r}}s(Am,"discoverFromContentRoot");function uw(t){return t.description.trim()?{skill:t,ok:true}:{skill:t,ok:false,reason:"missing description in frontmatter"}}s(uw,"validateSkill");function dw(t){return t.description.trim()?{rule:t,ok:true}:{rule:t,ok:false,reason:"missing description in frontmatter"}}s(dw,"validateRule");function fw(t){return t.description.trim()?{command:t,ok:true}:{command:t,ok:false,reason:"missing description in frontmatter"}}s(fw,"validateCommand");function gw(t){return t.description.trim()?{agent:t,ok:true}:{agent:t,ok:false,reason:"missing description in frontmatter"}}s(gw,"validateAgent");function De(t){return basename(t.source).replace(/\.md$/i,"")}s(De,"ruleSlug");function vG(t){if(!t)return;let e=[];return t.skills!==void 0&&e.push("skills"),t.rules!==void 0&&e.push("rules"),t.commands!==void 0&&e.push("commands"),t.agents!==void 0&&e.push("agents"),e.length>0?e:void 0}s(vG,"featuresFromImplicitPick");function xi(t,e){let{implicitPick:r}=e,n=e.scopedFeatures??vG(r);if(!r&&!n)return t;let o=new Set(n??[]),i={...t,mcp:!n||o.has("mcp")?t.mcp:null,permissions:!n||o.has("permissions")?t.permissions:null,hooks:!n||o.has("hooks")?t.hooks:null,ignore:!n||o.has("ignore")?t.ignore:[]};if(r?.skills!==void 0){let a=new Set(r.skills);i={...i,skills:r.skills.length===0?[]:i.skills.filter(l=>a.has(l.name))};}else n&&!o.has("skills")&&(i={...i,skills:[]});if(r?.rules!==void 0){let a=new Set(r.rules);i={...i,rules:r.rules.length===0?[]:i.rules.filter(l=>a.has(De(l)))};}else n&&!o.has("rules")&&(i={...i,rules:[]});if(r?.commands!==void 0){let a=new Set(r.commands);i={...i,commands:r.commands.length===0?[]:i.commands.filter(l=>a.has(l.name))};}else n&&!o.has("commands")&&(i={...i,commands:[]});if(r?.agents!==void 0){let a=new Set(r.agents);i={...i,agents:r.agents.length===0?[]:i.agents.filter(l=>a.has(l.name))};}else n&&!o.has("agents")&&(i={...i,agents:[]});return i}s(xi,"narrowDiscoveredForInstallScope");w();w();v();var GG=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"]),jG=new Set([".git",".github",".gitlab","node_modules",".vscode",".idea"]);async function wm(t){let e=await y(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,"")}s(wm,"readSkillFrontmatterName");async function hw(t,e){await cp(t,e,{recursive:true,filter:s(r=>{let n=relative(t,r).replace(/\\/g,"/");if(n==="")return true;let o=n.split("/")[0];return !(jG.has(o)||!n.includes("/")&&GG.has(n))},"filter")});}s(hw,"cpFilteredSkill");async function zG(){let t=await mkdtemp(join(tmpdir(),"am-install-manual-")),e=join(t,"repo");return await O(join(e,".agentsmesh")),{discoveryRoot:e,cleanup:s(async()=>{await rm$1(t,{recursive:true,force:true});},"cleanup")}}s(zG,"createStageRoot");async function HG(t,e){if((await stat(t)).isFile()){if(!t.toLowerCase().endsWith(".md"))throw new Error(`Manual install only supports .md files for this collection: ${t}`);await O(e),await cp(t,join(e,basename(t)));return}let n=(await T(t)).filter(i=>i.toLowerCase().endsWith(".md"));if(n.length===0)throw new Error(`No .md files found under ${t} for manual install.`);let o=new Map;await O(e);for(let i of n){let a=basename(i),l=o.get(a);if(l)throw new Error(`Manual install found duplicate file name "${a}" under ${t} (${l} and ${i}).`);o.set(a,i),await cp(i,join(e,a));}}s(HG,"stageMarkdownCollection");async function yw(t,e,r){if(r.length===0)return false;let n=new Set(r),o=new Map;for(let i of await T(t)){if(!i.endsWith("/SKILL.md")&&!i.endsWith("\\SKILL.md"))continue;let a=dirname(i),l=basename(a);if(!n.has(l))continue;let c=o.get(l);if(c&&c!==a)throw new Error(`Manual skill replay found duplicate skill "${l}" under ${t} (${c} and ${a}).`);o.set(l,a);}if(o.size!==r.length)return false;await O(e);for(let i of r)await cp(o.get(i),join(e,i),{recursive:true});return true}s(yw,"stagePreferredSkills");async function VG(t,e,r={}){if((await stat(t)).isFile()){if(basename(t)!=="SKILL.md")throw new Error(`Manual skill install expects SKILL.md or a skill directory: ${t}`);let o=basename(dirname(t)),i=join(e,o);await O(i),await cp(dirname(t),i,{recursive:true});return}if(await us(t)){if((await stat(join(t,"SKILL.md")).catch(()=>null))?.isFile()){if(await yw(t,e,r.preferredSkillNames??[]))return;let l=await wm(join(t,"SKILL.md"))||basename(t),c=join(e,l);await O(e),await hw(t,c);return}if(await yw(t,e,r.preferredSkillNames??[]))return;await O(e);let o=await T(t),i=new Set;for(let a of o.filter(l=>l.endsWith("/SKILL.md")||l.endsWith("\\SKILL.md")))i.add(relative(t,dirname(a)).split(/[\\/]/)[0]);for(let a of i)await cp(join(t,a),join(e,a),{recursive:true});return}throw new Error(`Manual skill install expects a skill directory or skills collection at ${t}.`)}s(VG,"stageSkills");async function _w(t,e,r={}){let n=await zG();try{let o=join(n.discoveryRoot,".agentsmesh",e);return e==="skills"?await VG(t,o,r):await HG(t,o),n}catch(o){throw await n.cleanup(),o}}s(_w,"stageManualInstallScope");async function Iw(t,e,r,n){let o=await _w(t,e,{preferredSkillNames:e==="skills"?n?.skills:void 0}),{canonical:i}=await Am(o.discoveryRoot),a=xi(i,{scopedFeatures:[e]});return {prep:{yamlTarget:r,scopedFeatures:[e],cleanup:o.cleanup},narrowed:a,discoveredFeatures:hs(a)}}s(Iw,"resolveManualDiscoveredForInstall");w();var JG=[{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 YG(t){return t.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"")}s(YG,"norm");function bm(t){let e=YG(t),r=[...JG].sort((n,o)=>o.prefix.length-n.prefix.length);for(let{prefix:n,target:o}of r)if(e===n||e.startsWith(`${n}/`))return o}s(bm,"targetHintFromNativePath");function ig(t,e){return bm(t)===e}s(ig,"pathSupportsNativePick");function Sw(t,e){if(!t||!e)return;let r=bm(e);if(r&&r!==t)throw new Error(`--target "${t}" does not match the install path (native path suggests "${r}"). Omit --target to auto-detect, or point at a subtree for that target.`)}s(Sw,"validateTargetMatchesPath");function Cw(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)>0}s(Cw,"extendPickHasArrays");w();w();At();async function Ow(t,e){let r=join(t,...le.split("/")),n=join(t,...e.split("/")),o=await T(n),i=[];for(let a of o){if(!/\.(toml|md)$/i.test(a))continue;let l=relative(r,a).replace(/\\/g,"/");if(l.startsWith("..")||l==="")continue;let m=l.replace(/\.(toml|md)$/i,"").split("/").filter(Boolean).join(":");m&&i.push(m);}return [...new Set(i)].sort()}s(Ow,"inferGeminiCommandNamesFromFiles");At();Re();w();async function ys(t){let e=await T(t),r=new Set;for(let n of e){if(basename(n)==="SKILL.md"){r.add(basename(dirname(n)));continue}!relative(t,n).replace(/\\/g,"/").includes("/")&&n.toLowerCase().endsWith(".md")&&r.add(basename(n,".md"));}return [...r].filter(Boolean).sort()}s(ys,"skillNamesFromNativeSkillDir");w();Ae();async function kw(t,e){let r=join(t,...e.split("/"));if(e.startsWith(no)){let n=await T(r),o=[...new Set(n.filter(i=>i.toLowerCase().endsWith(".prompt.md")).map(i=>basename(i,".prompt.md")))].sort();return o.length?{commands:o}:{}}if(e.startsWith(".github/copilot")&&!e.includes("copilot-instructions.md")){let n=await T(r),o=[...new Set(n.filter(i=>i.includes(".instructions.md")).map(i=>basename(i).replace(/\.instructions\.md$/i,"")))].sort();return o.length?{rules:o}:{}}if(e.startsWith(".github/instructions")){let n=await T(r),o=new Set;for(let a of n){let l=basename(a);l.toLowerCase().endsWith(".instructions.md")?o.add(l.replace(/\.instructions\.md$/i,"")):l.toLowerCase().endsWith(".md")&&o.add(basename(a,".md"));}let i=[...o].sort();return i.length?{rules:i}:{}}if(e.startsWith(".github/skills")){let n=await ys(r);return n.length?{skills:n}:{}}if(e.startsWith(".github/agents")){let n=await T(r),o=[...new Set(n.filter(i=>i.toLowerCase().endsWith(".agent.md")).map(i=>basename(i,".agent.md")))].sort();return o.length?{agents:o}:{}}return {}}s(kw,"inferCopilotPickFromPath");async function pe(t,e){let r=await T(t),n=e.toLowerCase();return [...new Set(r.filter(o=>o.toLowerCase().endsWith(n)).map(o=>basename(o,e)))].sort()}s(pe,"mdNames");async function Lw(t,e,r){let n=e.replace(/\\/g,"/").replace(/^\/+|\/+$/g,""),o=join(t,...n.split("/"));if(r==="gemini-cli"){if(n===le||n.startsWith(`${le}/`)){let i=await Ow(t,n);return i.length?{commands:i}:{}}return {}}if(r==="claude-code"){if(n.startsWith(".claude/commands")){let i=await pe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".claude/rules")){let i=await pe(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".claude/agents")){let i=await pe(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".claude/skills/")){let a=n.replace(/^\.claude\/skills\/?/,"").split("/").filter(Boolean)[0];return a?{skills:[a]}:{}}return {}}if(r==="cursor"){if(n.startsWith(".cursor/rules")){let i=await pe(o,".mdc");return i.length?{rules:i}:{}}if(n.startsWith(".cursor/commands")){let i=await pe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".cursor/agents")){let i=await pe(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".cursor/skills")){let i=await ys(o);return i.length?{skills:i}:{}}return {}}if(r==="copilot")return kw(t,n);if(r==="windsurf"&&n.startsWith(".windsurf/rules")){let i=await pe(o,".md");return i.length?{rules:i}:{}}if(r==="cline"){if(n.startsWith(Dt)){let i=await ys(o);return i.length?{skills:i}:{}}if(n.startsWith(gr)){let i=await pe(o,".md");return i.length?{commands:i}:{}}return {}}if(r==="continue"){if(n.startsWith(".continue/rules")){let i=await pe(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".continue/prompts")){let i=await pe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".continue/skills")){let i=await ys(o);return i.length?{skills:i}:{}}return {}}if(r==="junie"){if(n.startsWith(".junie/commands")){let i=await pe(o,".md");return i.length?{commands:i}:{}}if(n.startsWith(".junie/rules")){let i=await pe(o,".md");return i.length?{rules:i}:{}}if(n.startsWith(".junie/agents")){let i=await pe(o,".md");return i.length?{agents:i}:{}}if(n.startsWith(".junie/skills")){let i=await ys(o);return i.length?{skills:i}:{}}return {}}if(r==="codex-cli"&&n.startsWith(".codex")){let i=await T(o),a=[...new Set(i.filter(l=>l.toLowerCase().endsWith(".md")).map(l=>basename(l,".md")))].sort();return a.length?{rules:a}:{}}return {}}s(Lw,"inferImplicitPickFromNativePath");function Aw(t){return (t.commands?.length??0)+(t.rules?.length??0)+(t.skills?.length??0)+(t.agents?.length??0)===0}s(Aw,"isImplicitPickEmpty");function il(t){return t.replace(/\\/g,"/").replace(/\/+$/,"")}s(il,"normalizePath");function sj(t,e){let r=il(t),n=il(e);return r===n||r.startsWith(`${n}/`)||n.startsWith(`${r}/`)}s(sj,"overlapsPath");function xm(t,e){let r=t??[];return r.includes(e)||r.push(e),r}s(xm,"addUnique");async function ij(t){let e=await mkdtemp(join(tmpdir(),"am-install-native-")),r=join(e,"repo"),n=s(async()=>{await rm$1(e,{recursive:true,force:true});},"cleanup");try{return await cp(t,r,{recursive:!0}),{stageRoot:r,cleanup:n}}catch(o){throw await n(),o}}s(ij,"makeStageRoot");function aj(t,e){let r;for(let o of t){if(o.feature==="rules"&&o.toPath.startsWith(".agentsmesh/rules/")){r={...r,rules:xm(r?.rules,basename(o.toPath,".md"))};continue}if(o.feature==="commands"&&o.toPath.startsWith(".agentsmesh/commands/")){let i=il(relative(join(e,".agentsmesh","commands"),join(e,o.toPath)));r={...r,commands:xm(r?.commands,i.replace(/\.md$/i,"").split("/").filter(Boolean).join(":"))};continue}if(o.feature==="agents"&&o.toPath.startsWith(".agentsmesh/agents/")){r={...r,agents:xm(r?.agents,basename(o.toPath,".md"))};continue}if(o.feature==="skills"&&o.toPath.startsWith(".agentsmesh/skills/")){let a=il(relative(join(e,".agentsmesh","skills"),join(e,o.toPath))).split("/")[0];a&&(r={...r,skills:xm(r?.skills,a)});}}return r&&(r.rules?.length??0)+(r.commands?.length??0)+(r.agents?.length??0)+(r.skills?.length??0)>0?r:void 0}s(aj,"buildPickFromResults");function lj(t,e,r,n){let o=join(e,...il(t).split("/")),i=r.filter(a=>sj(o,a.fromPath));if(i.length===0)throw new Error(`No installable native resources found under "${t}" for target "${n}".`);return {features:[...new Set(i.map(a=>a.feature))],pick:aj(i,e)}}s(lj,"scopeImportedResults");async function lg(t,e){let{stageRoot:r,cleanup:n}=await ij(t);try{let o=await za(r,e);return {stageRoot:r,results:o,cleanup:n}}catch(o){throw await n(),o}}s(lg,"stageImportedNativeRepo");async function cg(t,e,r){let n=await lg(t,r);try{return {stageRoot:n.stageRoot,cleanup:n.cleanup,...lj(e,n.stageRoot,n.results,r)}}catch(o){throw await n.cleanup(),o}}s(cg,"stageNativeInstallScope");async function xw(t,e,r,n){let o=n.explicitTarget?.trim();o&&de.parse(o);let i=r.replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");Sw(o,i);let a=join(t,".agentsmesh"),l=await F(a),c=i?bm(i):void 0,m=!l&&!o?await Cl(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=!!i&&!!p&&!i.startsWith(".agentsmesh");if(!l&&p){if(u){let k=await cg(t,i,p);return {discoveryRoot:k.stageRoot,implicitPick:k.pick,scopedFeatures:k.features,yamlTarget:p,importHappened:true,cleanup:k.cleanup}}let I=await lg(t,p);return {discoveryRoot:i?join(I.stageRoot,i):I.stageRoot,yamlTarget:p,importHappened:true,cleanup:I.cleanup}}let d;l?i?p&&ig(i,p)?d=t:d=e:d=t:d=e;let g,h,C;if(u&&p){let I=await cg(t,i,p);d=I.stageRoot,g=I.pick,h=I.features,C=I.cleanup;}else if(d===t&&i&&p&&ig(i,p)&&(g=await Lw(t,i,p),Aw(g)))throw new Error(`No installable native resources found under "${i}" for target "${p}".`);let R;return o?R=o:p&&(g&&Cw(g)||(h?.length??0)>0)&&(R=p),{discoveryRoot:d,implicitPick:g,scopedFeatures:h,yamlTarget:R,importHappened:C!==void 0,cleanup:C}}s(xw,"prepareInstallDiscovery");async function Tw(t,e,r,n){let o=await xw(t,e,r,{explicitTarget:n}),{canonical:i,implicitPick:a}=await Am(o.discoveryRoot),l=a??o.implicitPick,c=xi(i,{implicitPick:l,scopedFeatures:o.scopedFeatures}),m=hs(c);return {prep:o,discovered:i,implicitPick:l,narrowed:c,discoveredFeatures:m}}s(Tw,"resolveDiscoveredForInstall");async function Nw(t){return t.explicitAs?{implicitPick:void 0,...await Iw(t.contentRoot,t.explicitAs,t.explicitTarget,t.replayPick)}:Tw(t.resolvedPath,t.contentRoot,t.pathInRepo,t.explicitTarget)}s(Nw,"resolveInstallDiscovery");function Ni(t){return t==="."||t===""?void 0:t}s(Ni,"trimDot");function mj(t,e){let r=basename(e).replace(/\.md$/i,"");return t==="agents"?{agents:[r]}:t==="commands"?{commands:[r]}:{rules:[r]}}s(mj,"markdownPick");async function Fw(t){if(!t.as)return {pathInRepo:Ni(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:Ni(dirname(e)),pick:mj(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:Ni(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 wm(o);return {pathInRepo:Ni(dirname(n)),pick:{skills:[a||basename(n)]}}}}catch{return {pathInRepo:Ni(e)}}}}return {pathInRepo:Ni(e)}}s(Fw,"resolveManualInstallPersistence");async function Kr(t){return process.stdin.isTTY?new Promise(e=>{let r=vw.createInterface({input:process.stdin,output:process.stdout});r.question(`${t} (y/n) `,n=>{r.close();let o=n.trim().toLowerCase();e(o==="y"||o==="yes");});}):false}s(Kr,"confirm");function pj(t){return !!(t.skills.length||t.rules.length||t.commands.length||t.agents.length)}s(pj,"hasArrayResources");function Mw(t){return pj(t)||t.mcp!==null||t.permissions!==null||t.hooks!==null||t.ignore.length>0}s(Mw,"hasInstallableResources");async function $w(t,e,r,n){let o=t.skills.map(l=>uw(l)),i=o.filter(l=>l.ok).map(l=>l.skill),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Kr(`Include invalid skill "${l.skill.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.skill);else e&&(i=o.map(l=>l.skill));return r&&(i=o.filter(l=>l.ok).map(l=>l.skill)),i}s($w,"resolveSkillPool");async function Gw(t,e,r,n){let o=t.rules.map(l=>dw(l)),i=o.filter(l=>l.ok).map(l=>l.rule),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Kr(`Include invalid rule "${De(l.rule)}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.rule);else e&&(i=o.map(l=>l.rule));return r&&(i=o.filter(l=>l.ok).map(l=>l.rule)),i}s(Gw,"resolveRulePool");async function jw(t,e,r,n){let o=t.commands.map(l=>fw(l)),i=o.filter(l=>l.ok).map(l=>l.command),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Kr(`Include invalid command "${l.command.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.command);else e&&(i=o.map(l=>l.command));return r&&(i=o.filter(l=>l.ok).map(l=>l.command)),i}s(jw,"resolveCommandPool");async function Uw(t,e,r,n){let o=t.agents.map(l=>gw(l)),i=o.filter(l=>l.ok).map(l=>l.agent),a=o.filter(l=>!l.ok);if(!e&&!r&&n)for(let l of a)await Kr(`Include invalid agent "${l.agent.name}" anyway? (${l.reason}). You can fix it later.`)&&i.push(l.agent);else e&&(i=o.map(l=>l.agent));return r&&(i=o.filter(l=>l.ok).map(l=>l.agent)),i}s(Uw,"resolveAgentPool");async function Kw(t,e){let r=e.skills.map(a=>a.name),n=e.rules.map(a=>De(a)),o=e.commands.map(a=>a.name),i=e.agents.map(a=>a.name);for(let a of e.skills)t.skills.some(l=>l.name===a.name)&&(await Kr(`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 Kr(`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 Kr(`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 Kr(`Agent "${a.name}" already exists in merged config. Add extend anyway?`)||(i=i.filter(c=>c!==a.name)));return {skillNames:r,ruleSlugs:n,commandNames:o,agentNames:i}}s(Kw,"resolveInstallConflicts");function Ww(t,e){if(!t)return;let r={},n=t.skills?.filter(l=>e.skillNames.includes(l)),o=t.rules?.filter(l=>e.ruleSlugs.includes(l)),i=t.commands?.filter(l=>e.commandNames.includes(l)),a=t.agents?.filter(l=>e.agentNames.includes(l));return n&&n.length>0&&(r.skills=n),o&&o.length>0&&(r.rules=o),i&&i.length>0&&(r.commands=i),a&&a.length>0&&(r.agents=a),Object.keys(r).length>0?r:void 0}s(Ww,"pickForSelectedResources");function uj(t,e){let r=t.split("/").filter(Boolean);return r.length>0&&r[r.length-1]===e}s(uj,"pathEndsWithName");function Tm(t,e,r){return r!==1||e.length!==1?false:uj(t,e[0])}s(Tm,"inferSingleNamePick");function Bw(t){let{pathInRepo:e,implicitPick:r,preConflictCounts:n,selected:o}=t,i={},a=o.skillNames.length>0&&(!!r?.skills?.length||o.skillNames.length<n.skills||Tm(e,o.skillNames,n.skills)),l=o.ruleSlugs.length>0&&(!!r?.rules?.length||o.ruleSlugs.length<n.rules||Tm(e,o.ruleSlugs,n.rules)),c=o.commandNames.length>0&&(!!r?.commands?.length||o.commandNames.length<n.commands||Tm(e,o.commandNames,n.commands)),m=o.agentNames.length>0&&(!!r?.agents?.length||o.agentNames.length<n.agents||Tm(e,o.agentNames,n.agents));return a&&(i.skills=[...o.skillNames]),l&&(i.rules=[...o.ruleSlugs]),c&&(i.commands=[...o.commandNames]),m&&(i.agents=[...o.agentNames]),Object.keys(i).length?i:void 0}s(Bw,"buildInstallPick");function zw(t,e){let r=new Set(t);return e.skillNames.length===0&&r.delete("skills"),e.ruleSlugs.length===0&&r.delete("rules"),e.commandNames.length===0&&r.delete("commands"),e.agentNames.length===0&&r.delete("agents"),[...r]}s(zw,"deriveInstallFeatures");function dj(t){return t.skillNames.length===0&&t.ruleSlugs.length===0&&t.commandNames.length===0&&t.agentNames.length===0}s(dj,"isEmptyInstallSelection");function Hw(t){let{selected:e,discoveredFeatures:r,preConflict:n}=t,o=s(l=>r.includes(l),"had"),i=o("skills")&&e.skillNames.length===0&&n.skills>0&&"skills"||o("rules")&&e.ruleSlugs.length===0&&n.rules>0&&"rules"||o("commands")&&e.commandNames.length===0&&n.commands>0&&"commands"||o("agents")&&e.agentNames.length===0&&n.agents>0&&"agents";if(i)throw new Error(`No ${i} selected to install.`);let a=r.some(l=>["mcp","permissions","hooks","ignore"].includes(l));if(dj(e)&&!a)throw new Error("No resources selected to install.")}s(Hw,"ensureInstallSelection");function Vw(t,e){if(t.find(n=>n.name===e.name&&n.source!==e.source))throw new Error(`Extends entry "${e.name}" already exists with a different source. Use --name to provide a different name.`)}s(Vw,"assertExtendNameAvailable");function fj(t,e,r){if(r===void 0){if(!t)return;let o={...t};for(let i of ["skills","commands","rules","agents"])e.includes(i)&&delete o[i];return Object.keys(o).length?o:void 0}let n={...t};for(let o of ["skills","commands","rules","agents"]){if(!(o in r))continue;let i=r[o];if(i===void 0||i.length===0){delete n[o];continue}n[o]=[...new Set([...t?.[o]??[],...i])];}return Object.keys(n).length?n:void 0}s(fj,"mergePick");function Jw(t,e){let r=t.findIndex(a=>a.source===e.source);if(r<0)return [...t,{name:e.name,source:e.source,version:e.version,features:e.features,path:e.path,pick:e.pick,target:e.target}];let n=t[r],o=[...new Set([...n.features,...e.features])],i=fj(n.pick,e.features,e.pick);return t.map((a,l)=>l===r?{name:e.name,source:e.source,version:e.version??n.version,features:o,path:e.path!==void 0?e.path:n.path,pick:i,target:e.target??n.target}:a)}s(Jw,"mergeExtendList");w();async function Yw(t,e,r){let n=await y(t);if(n===null)throw new Error(`Missing config: ${t}`);let o=parse(n),i=Jw(e.extends,r);o.extends=i;let a=stringify(o,{indent:2,lineWidth:0});await S(t,a.endsWith(`
|
|
292
293
|
`)?a:`${a}
|
|
293
|
-
`);}
|
|
294
|
-
${JSON.stringify(
|
|
295
|
-
`);return `sha256:${
|
|
294
|
+
`);}s(Yw,"writeAgentsmeshWithNewExtend");async function Xw(t){let{configDir:e,config:r,entryArgs:n,dryRun:o}=t,i=_j(n);if(Vw(r.extends,i),o){_.info(`[dry-run] Would add extend:
|
|
295
|
+
${JSON.stringify(i,null,2)}`);return}let a=join(e,"agentsmesh.yaml");await Yw(a,r,i),_.success(`Wrote extends entry "${i.name}" to agentsmesh.yaml.`);}s(Xw,"writeInstallAsExtend");function _j(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?de.parse(t.yamlTarget):void 0}}s(_j,"toNewExtendEntry");w();w();var Sj="pack.yaml";async function Nm(t){let e=await T(t),r=[];for(let i of e.sort()){let a=relative(t,i).replace(/\\/g,"/");if(a===Sj)continue;let l=await dm(i);l!==null&&r.push(`${a}:${l}`);}let n=r.join(`
|
|
296
|
+
`);return `sha256:${Ya(n)}`}s(Nm,"hashPackContent");async function kj(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await O(r);for(let n of t.rules){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(kj,"writeRules");async function Ej(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await O(r);for(let n of t.commands){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(Ej,"writeCommands");async function Lj(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await O(r);for(let n of t.agents){let o=join(r,basename(n.source));await copyFile(n.source,o);}}s(Lj,"writeAgents");async function Aj(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await O(r);for(let n of t.skills){let o=join(r,n.name);await O(o),await copyFile(n.source,join(o,"SKILL.md"));for(let i of n.supportingFiles){let a=join(o,i.relativePath);await O(dirname(a)),await copyFile(i.absolutePath,a);}}}s(Aj,"writeSkills");async function wj(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
|
-
`);}
|
|
299
|
+
`);}s(wj,"writeSettings");function Pj(t){if(t.includes("/")||t.includes("\\")||t===".."||t==="."||t.includes("\0"))throw new Error(`Invalid pack name "${t}". Pack names must be a single directory segment without path separators.`)}s(Pj,"validatePackName");async function qw(t,e,r,n){Pj(e);let o=join(t,`${e}.tmp`),i=join(t,e);await F(o)&&await rm$1(o,{recursive:true,force:true}),await O(o),await kj(r,o),await Ej(r,o),await Lj(r,o),await Aj(r,o),await wj(r,o);let a=await Nm(o),l=fo({...n,content_hash:a});return await S(join(o,"pack.yaml"),stringify(l)),await F(i)&&await rm$1(i,{recursive:true,force:true}),await mkdir(t,{recursive:true}),await rename(o,i),l}s(qw,"materializePack");w();function fg(t,e){return [...new Set([...t,...e])]}s(fg,"union");function xj(t,e){if(t.path===void 0&&t.paths===void 0||e===void 0)return {path:void 0,paths:void 0};let n=fg(t.paths??(t.path?[t.path]:[]),[e]);return n.length===1?{path:n[0],paths:void 0}:{path:void 0,paths:n}}s(xj,"mergePathScope");function Tj(t,e,r){let n={...t};for(let i of e)r&&r[i]!==void 0?n[i]=fg(n[i]??[],r[i]):delete n[i];return (n.skills?.length??0)>0||(n.rules?.length??0)>0||(n.commands?.length??0)>0||(n.agents?.length??0)>0?n:void 0}s(Tj,"mergePick");async function Nj(t,e){if(t.rules.length===0)return;let r=join(e,"rules");await O(r);for(let n of t.rules)await copyFile(n.source,join(r,basename(n.source)));}s(Nj,"mergeRules");async function Dj(t,e){if(t.commands.length===0)return;let r=join(e,"commands");await O(r);for(let n of t.commands)await copyFile(n.source,join(r,basename(n.source)));}s(Dj,"mergeCommands");async function Fj(t,e){if(t.agents.length===0)return;let r=join(e,"agents");await O(r);for(let n of t.agents)await copyFile(n.source,join(r,basename(n.source)));}s(Fj,"mergeAgents");async function vj(t,e){if(t.skills.length===0)return;let r=join(e,"skills");await O(r);for(let n of t.skills){let o=join(r,n.name);await O(o),await copyFile(n.source,join(o,"SKILL.md"));for(let i of n.supportingFiles){let a=join(o,i.relativePath);await O(dirname(a)),await copyFile(i.absolutePath,a);}}}s(vj,"mergeSkills");async function Mj(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
|
-
`);}
|
|
302
|
-
`,o=parse(n)??{};if(o.plugins||(o.plugins=[]),o.plugins.some(a=>a.id===e.id))return;let
|
|
302
|
+
`);}s(Mj,"mergeSettings");async function Qw(t,e,r,n,o,i){await Nj(r,t),await Dj(r,t),await Fj(r,t),await vj(r,t),await Mj(r,t);let a=fg(e.features,n),l=Tj(e.pick,n,o),c=xj(e,i?.path),m=await Nm(t),p=new Date().toISOString(),u=fo({...e,source:i?.source??e.source,...i?.version!==void 0?{version:i.version}:e.version!==void 0?{version:e.version}:{},features:a,pick:l,...i?.target!==void 0?{target:i.target}:e.target!==void 0?{target:e.target}:{},...c,...i?.as!==void 0?{as:i.as}:e.as!==void 0?{as:e.as}:{},updated_at:p,content_hash:m});return await S(join(t,"pack.yaml"),stringify(u)),u}s(Qw,"mergeIntoPack");w();function Gj(t){return t?{path:t,paths:void 0}:{path:void 0,paths:void 0}}s(Gj,"pathScope");function jj(t,e){let r=new Set(e.skillNames),n=new Set(e.ruleSlugs),o=new Set(e.commandNames),i=new Set(e.agentNames);return {...t,skills:t.skills.filter(a=>r.has(a.name)),rules:t.rules.filter(a=>n.has(De(a))),commands:t.commands.filter(a=>o.has(a.name)),agents:t.agents.filter(a=>i.has(a.name))}}s(jj,"applySelection");async function tP(t){let{canonicalDir:e,packName:r,narrowed:n,selected:o,sourceForYaml:i,version:a,sourceKind:l,entryFeatures:c,pick:m,yamlTarget:p,pathInRepo:u,manualAs:d,renameExistingPack:g}=t,h=join(e,"packs"),C=jj(n,o),R=new Date().toISOString(),I=p!==void 0?de.parse(p):void 0,k=await TL(h,i,{target:I,as:d,features:c}),D=r,P=c,b=m,Y=u,U;if(k){let z=k.packDir,st=k.meta;if(g&&k.name!==r){let lt=join(h,r);if(await F(lt))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,lt),z=lt,st={...k.meta,name:r};}let St=await Qw(z,st,C,c,m,{source:i,...a!==void 0?{version:a}:{},...I!==void 0?{target:I}:{},...u?{path:u}:{},...d!==void 0?{as:d}:{}});D=St.name,P=St.features,b=St.pick,Y=St.path,U=St.paths,_.success(`Updated pack "${St.name}" in .agentsmesh/packs/.`);}else {if(await pm(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 qw(h,r,C,{name:r,source:i,...a!==void 0&&{version:a},source_kind:l,installed_at:R,updated_at:R,features:c,...m!==void 0&&{pick:m},...I!==void 0&&{target:I},...Gj(u),...d!==void 0&&{as:d}}),_.success(`Installed pack "${r}" to .agentsmesh/packs/.`);}await lw(e,cw({name:D,source:i,version:a,sourceKind:l,features:P,pick:b,target:I,path:Y,paths:U,as:d})),l!=="local"&&await eh(i);}s(tP,"installAsPack");function Kj(t){return t.toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}s(Kj,"sanitize");function Wj(t){try{let r=new URL(t.replace(/^git\+/,"https://").replace(/^ssh:\/\/git@/,"https://")).pathname.split("/").filter(Boolean);if(r.length===0)return "repo";let n=r[r.length-1].replace(/\.git$/i,"");return r.length>=2?`${r[r.length-2].replace(/\.git$/i,"")}-${n}`:n}catch{return "repo"}}s(Wj,"gitUrlLastSegments");function eP(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=Wj(t.gitRemoteUrl):n="extend";e.featureHint?n=`${n}-${e.featureHint}`:n=`${n}-pack`;let o=Kj(n)||"extend";if(!r.has(o))return o;let i=2;for(;r.has(`${o}-${i}`);)i++;return `${o}-${i}`}s(eP,"suggestExtendName");function rP(t){let{config:e,parsed:r,entryFeatures:n,nameOverride:o}=t,i=new Set(e.extends.map(a=>a.name));return o||eP(r,{featureHint:n.length===1?n[0]:void 0},i)}s(rP,"selectInstallEntryName");function nP(t,e,r){if(!r?.features&&!r?.pick)return {narrowed:t,discoveredFeatures:e};let n=xi(t,{scopedFeatures:r.features,implicitPick:r.pick});return {narrowed:n,discoveredFeatures:hs(n)}}s(nP,"applyReplayInstallScope");async function oP(t){let{scope:e,force:r,dryRun:n,tty:o,useExtends:i,nameOverride:a,explicitAs:l,config:c,context:m,parsed:p,sourceForYaml:u,version:d,pathInRepo:g,persisted:h,replay:C,prep:R,implicitPick:I,narrowed:k,discoveredFeatures:D}=t,{narrowed:P,discoveredFeatures:b}=nP(k,D,C);if(!Mw(P))throw new Error(I||R.scopedFeatures?"No resources match the install path or implicit selection (check pick names exist at that path).":"No supported resources found to install (skills, rules, commands, agents).");let Y=await $w(P,r,n,o),U=await Gw(P,r,n,o),z=await jw(P,r,n,o),st=await Uw(P,r,n,o),St={skills:Y.length,rules:U.length,commands:z.length,agents:st.length},{canonical:lt}=await xe(c,m.configDir,{},m.canonicalDir),ne=!r&&!n&&o?await Kw(lt,{skills:Y,rules:U,commands:z,agents:st}):{skillNames:Y.map(ue=>ue.name),ruleSlugs:U.map(ue=>De(ue)),commandNames:z.map(ue=>ue.name),agentNames:st.map(ue=>ue.name)};Hw({selected:ne,discoveredFeatures:b,preConflict:St});let ht=C?.features??zw(b,ne);if(ht.length===0)throw new Error("No features left to install after selection.");let Pt=Ww(C?.pick,ne)??h.pick??Bw({pathInRepo:h.pathInRepo??g,implicitPick:I,preConflictCounts:St,selected:ne}),oe=rP({config:c,parsed:p,entryFeatures:ht,nameOverride:a});if(i){if(await Xw({configDir:m.configDir,config:c,entryArgs:{name:oe,source:u,version:d,features:ht,path:h.pathInRepo,pick:Pt,yamlTarget:R.yamlTarget},dryRun:n}),n)return}else {if(n){_.info(`[dry-run] Would install pack "${oe}" to ${e==="global"?"~/.agentsmesh/packs/.":".agentsmesh/packs/."}`);return}await tP({canonicalDir:m.canonicalDir,packName:oe,narrowed:P,selected:ne,sourceForYaml:u,version:d,sourceKind:p.kind,entryFeatures:ht,pick:Pt,yamlTarget:R.yamlTarget,pathInRepo:h.pathInRepo,manualAs:l,renameExistingPack:a===""});}await Pi(e==="global"?{global:true}:{},m.rootBase)!==0&&_.warn(`Generate failed after install. Fix the issue and run agentsmesh generate${e==="global"?" --global":""}.`);}s(oP,"executeRunInstallPoolsAndWrite");async function hg(t,e,r,n){let{sync:o,dryRun:i,force:a,useExtends:l,explicitPath:c,explicitTarget:m,explicitAs:p,nameOverride:u}=pw(t),d=t.global===true?"global":"project",g=e[0]?.trim();if(o){let{context:ne}=await yt(r,d);if(await mw({sync:o,canonicalDir:ne.canonicalDir,reinstall:s(async ht=>{let Pt=ht.paths&&ht.paths.length>0?ht.paths:[ht.path];for(let oe of Pt)await hg({...a?{force:true}:{},...i?{"dry-run":true}:{},...d==="global"?{global:true}:{},name:ht.name,...ht.target?{target:ht.target}:{},...oe?{path:oe}:{},...ht.as?{as:ht.as}:{}},[ht.source],r,{features:ht.features,pick:ht.pick});},"reinstall")}))return}if(!g)throw new Error("Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]");let h=process.stdin.isTTY;if(!h&&!a&&!i)throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");let{config:C,context:R}=await yt(r,d),I=await ng(g,R.configDir,c);if(I.kind!=="local"&&!await tw())throw new Error("git is required for remote installs. Please install git and try again.");let{resolvedPath:k,sourceForYaml:D,version:P}=await nw(I,g),b=I.pathInRepo.replace(/^\/+|\/+$/g,"");if(b){let ne=normalize(b).replace(/\\/g,"/");if(ne===".."||ne.startsWith("../"))throw new Error(`Install --path "${I.pathInRepo}" escapes the source root. Path must stay within the source.`)}let Y=b?join(k,b):k;if(!await F(Y))throw new Error(`Install path does not exist: ${Y}`);let U=await Fw({as:p,contentRoot:Y,pathInRepo:b}),{prep:z,implicitPick:st,narrowed:St,discoveredFeatures:lt}=await Nw({resolvedPath:k,contentRoot:Y,pathInRepo:b,explicitTarget:m,explicitAs:p,replayPick:n?.pick});try{await oP({scope:d,force:a,dryRun:i,tty:h,useExtends:l,nameOverride:u,explicitAs:p,config:C,context:R,parsed:I,sourceForYaml:D,version:P,pathInRepo:b,persisted:U,replay:n,prep:z,implicitPick:st,narrowed:St,discoveredFeatures:lt});}finally{z.cleanup&&await z.cleanup();}}s(hg,"runInstall");async function sP(t,e,r){await hg(t,e,r);}s(sP,"runInstall");w();var Ig="agentsmesh.yaml";async function Sg(t){let e=join(t,Ig),r=await y(e);return r===null?{}:parse(r)??{}}s(Sg,"readScopedConfigRaw");async function aP(t,e){let r=join(t,Ig),n=await y(r)??`version: 1
|
|
303
|
+
`,o=parse(n)??{};if(o.plugins||(o.plugins=[]),o.plugins.some(a=>a.id===e.id))return;let i={id:e.id,source:e.source};e.version!==void 0&&(i.version=e.version),o.plugins.push(i),await S(r,stringify(o));}s(aP,"writePluginEntry");async function lP(t,e){let r=join(t,Ig),n=await y(r);if(n===null)return false;let o=parse(n)??{},i=(o.plugins??[]).length;o.plugins=(o.plugins??[]).filter(l=>l.id!==e),o.pluginTargets&&(o.pluginTargets=o.pluginTargets.filter(l=>l!==e));let a=o.plugins.length<i;return a&&await S(r,stringify(o)),a}s(lP,"removePluginEntry");async function mP(t,e,r){let n=e[0];if(n===void 0||n==="")return cP(),0;switch(n){case "add":return Hj(t,e.slice(1),r);case "list":return Vj(r);case "remove":return Jj(e.slice(1),r);case "info":return Yj(e.slice(1),r);default:return _.error(`Unknown plugin subcommand: ${n}`),cP(),2}}s(mP,"runPlugin");async function Hj(t,e,r){let n=e[0];if(!n)return _.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)??Xj(n);try{await aP(r,{id:a,source:n,version:o});}catch(l){return _.error(`Failed to update config: ${l instanceof Error?l.message:String(l)}`),1}return _.success(`Plugin '${a}' added to agentsmesh.yaml`),_.warn("Plugins load as trusted Node.js modules and run with full process privileges. Only install plugins from sources you trust."),_.info(`Next: npm install ${n}${o!==void 0?`@${o}`:"@latest"}`),_.info(`Then add '${a}' to pluginTargets in agentsmesh.yaml to enable it.`),0}s(Hj,"runPluginAdd");async function Vj(t){let e;try{e=await Sg(t);}catch(n){return _.error(`Failed to read config: ${n instanceof Error?n.message:String(n)}`),1}let r=e.plugins??[];if(r.length===0)return _.info("No plugins configured. Use: agentsmesh plugin add <source>"),0;_.info("Configured plugins:");for(let n of r){let o="\u2717",i="";try{let l=await Rm(n,t);o=l.descriptors.length>0?"\u2713":"\u2713 (0 descriptors)",i=l.descriptors.map(c=>c.id).join(", ");}catch{}let a=n.version!==void 0?`@${n.version}`:"";_.info(` ${n.id} | ${n.source}${a} | ${o} | ${i}`);}return 0}s(Vj,"runPluginList");async function Jj(t,e){let r=t[0];if(!r)return _.error("Usage: agentsmesh plugin remove <id>"),2;try{await lP(e,r)?_.success(`Plugin '${r}' removed from agentsmesh.yaml`):_.warn(`Plugin '${r}' was not found in agentsmesh.yaml`);}catch(n){return _.error(`Failed to update config: ${n instanceof Error?n.message:String(n)}`),1}return 0}s(Jj,"runPluginRemove");async function Yj(t,e){let r=t[0];if(!r)return _.error("Usage: agentsmesh plugin info <id>"),2;let n;try{n=await Sg(e);}catch(a){return _.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 _.error(`Plugin '${r}' not found in agentsmesh.yaml. Use: agentsmesh plugin add`),1;let i;try{i=await Rm(o,e);}catch(a){return _.error(`Failed to load plugin '${r}': ${a instanceof Error?a.message:String(a)}`),1}_.info(`Plugin: ${o.id}`),_.info(`Source: ${o.source}${o.version!==void 0?`@${o.version}`:""}`),_.info(`Descriptors: ${i.descriptors.length}`);for(let a of i.descriptors)_.info(` - ${a.id}: ${a.emptyImportMessage}`);return 0}s(Yj,"runPluginInfo");function Xj(t){let e=t;if(e.startsWith("@")){let n=e.indexOf("/");n!==-1&&(e=e.slice(n+1));}e.startsWith("agentsmesh-target-")&&(e=e.slice(18)),e.startsWith("file:")&&(e=e.slice(5));let r=e.replace(/\\/g,"/").split("/");return e=r[r.length-1]??e,e=e.replace(/\.(js|ts)$/,""),e=e.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),e||"plugin"}s(Xj,"derivePluginId");function cP(){_.info("Usage: agentsmesh plugin <subcommand> [args] [flags]"),_.info(""),_.info("Subcommands:"),_.info(" add <source> Register a plugin package in agentsmesh.yaml"),_.info(" list Show all configured plugins and load status"),_.info(" remove <id> Remove a plugin from agentsmesh.yaml"),_.info(" info <id> Show descriptor details for a configured plugin"),_.info(""),_.info("Flags (add):"),_.info(" --version <v> Pin plugin version"),_.info(" --id <id> Override derived plugin id"),_.info(""),_.info("Note: plugins load as trusted Node.js modules and run with full process privileges."),_.info(" Only install plugins from sources you trust.");}s(cP,"printPluginHelp");w();Br();function Fi(t){return t.toUpperCase().replace(/-/g,"_")}s(Fi,"toPrefix");function Di(t){return t.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}s(Di,"toPascal");function pP(t){let e=Fi(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
|
-
`}
|
|
316
|
+
`}s(pP,"TEMPLATE_CONSTANTS");function uP(t){let e=Fi(t.id),r=Di(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
|
-
`}
|
|
413
|
+
`}s(uP,"TEMPLATE_INDEX");function dP(t){let e=Fi(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 ${Di(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): ${Di(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
|
-
`}
|
|
427
|
+
`}s(dP,"TEMPLATE_GENERATOR");function fP(t){let e=Di(t.id),r=Fi(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
|
-
`}
|
|
439
|
+
`}s(fP,"TEMPLATE_IMPORTER");function gP(t){let e=Fi(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
|
-
`}
|
|
457
|
+
`}s(gP,"TEMPLATE_LINTER");function hP(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
|
-
`}
|
|
467
|
+
`}s(hP,"TEMPLATE_LINT_HOOKS");function yP(t){let e=Di(t.id),r=Fi(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
|
-
`}
|
|
479
|
+
`}s(yP,"TEMPLATE_IMPORT_MAP");function _P(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
|
-
`}
|
|
508
|
+
`}s(_P,"TEMPLATE_GENERATOR_TEST");function IP(t){let e=Di(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
|
-
`}
|
|
522
|
+
`}s(IP,"TEMPLATE_IMPORTER_TEST");function SP(t){return `# ${t.displayName} Workspace
|
|
522
523
|
|
|
523
524
|
Follow the ${t.displayName} configuration files and keep changes small.
|
|
524
|
-
`}
|
|
525
|
+
`}s(SP,"TEMPLATE_FIXTURE_ROOT_MD");var qj=/^[a-z][a-z0-9-]*$/;async function CP(t){let{id:e,projectRoot:r,force:n=false}=t,o=t.displayName??e,i={id:e,displayName:o};if(!qj.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(xt.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:pP(i)},{rel:`src/targets/${e}/index.ts`,content:uP(i)},{rel:`src/targets/${e}/generator.ts`,content:dP(i)},{rel:`src/targets/${e}/importer.ts`,content:fP(i)},{rel:`src/targets/${e}/linter.ts`,content:gP(i)},{rel:`src/targets/${e}/lint.ts`,content:hP(i)},{rel:`src/core/reference/import-maps/${e}.ts`,content:yP(i)},{rel:`tests/unit/targets/${e}/generator.test.ts`,content:_P(i)},{rel:`tests/unit/targets/${e}/importer.test.ts`,content:IP(i)},{rel:`tests/e2e/fixtures/${e}-project/AGENTS.md`,content:SP(i)}],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}}s(CP,"writeTargetScaffold");async function OP(t,e,r){let n=e[0];return n===void 0||n===""?(RP(),0):n==="scaffold"?Qj(t,e.slice(1),r):(_.error(`Unknown target subcommand: ${n}`),RP(),2)}s(OP,"runTarget");async function Qj(t,e,r){let n=e[0];if(!n)return _.error("Usage: agentsmesh target scaffold <id> [--name <displayName>] [--force]"),2;let o=typeof t.name=="string"?t.name:void 0,i=t.force===true,a;try{a=await CP({id:n,displayName:o,projectRoot:r,force:i});}catch(l){return _.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;_.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;_.warn(`skipped ${c.replaceAll("\\","/")} (already exists \u2014 use --force to overwrite)`);}if(a.written.length>0){_.info(""),_.info("Next steps:");for(let l of a.postSteps)_.info(` ${l}`);}return 0}s(Qj,"runScaffold");function RP(){_.info("Usage: agentsmesh target <subcommand> [args] [flags]"),_.info(""),_.info("Subcommands:"),_.info(" scaffold <id> Generate a new target skeleton (files, tests, fixture)"),_.info(""),_.info("Flags (scaffold):"),_.info(" --name <displayName> Human-readable name (defaults to id)"),_.info(" --force Overwrite existing files");}s(RP,"printTargetHelp");function rU(t){let e={},r=[],n="help";for(let o=0;o<t.length;o++){let i=t[o];if(n==="help"&&i==="--version")return {command:"version",flags:{},args:[]};if(n==="help"&&i==="--help")return {command:"help",flags:{},args:[]};if(i.startsWith("--")){let a=i.slice(2),l=t[o+1];l===void 0||l.startsWith("--")?e[a]=true:(e[a]=l,o++);continue}n==="help"?n=i:r.push(i);}return {command:n,flags:e,args:r}}s(rU,"parseArgs");var nU=["init","generate","import","diff","lint","watch","check","merge","matrix","install","plugin","target"];function oU(t){return async(e,r)=>{_.info(`Not implemented yet: ${t}`);}}s(oU,"stub");var sU={...Object.fromEntries(nU.map(t=>[t,oU(t)])),generate:s(async(t,e)=>{let r=await Pi(t);r!==0&&process.exit(r);},"generate"),init:s(async(t,e)=>{await DA(process.cwd(),{yes:t.yes===true,global:t.global===true});},"init"),import:s((t,e)=>vA(t),"import"),diff:s((t,e)=>jA(t),"diff"),lint:s(async(t,e)=>{let r=await HA(t);r!==0&&process.exit(r);},"lint"),check:s(async(t,e)=>{let r=await XA(t);r!==0&&process.exit(r);},"check"),merge:s((t,e)=>QA(t),"merge"),matrix:s((t,e)=>gs(t),"matrix"),watch:s(async(t,e)=>{let r=await JA(t),n=s(()=>{r.stop().then(()=>process.exit(0));},"stop");process.on("SIGINT",n),process.on("SIGTERM",n);},"watch"),install:s((t,e)=>sP(t,e,process.cwd()),"install"),plugin:s(async(t,e)=>{let r=await mP(t,e,process.cwd());r!==0&&process.exit(r);},"plugin"),target:s(async(t,e)=>{let r=await OP(t,e,process.cwd());r!==0&&process.exit(r);},"target")},iU=kg(sU);async function aU(t){let{command:e,flags:r,args:n}=t;if(e==="help"){wg();return}if(e==="version"){xg();return}await iU.route(e,r,n);}s(aU,"main");function lU(){let t=process.argv[1];if(!t)return false;let e=fileURLToPath(import.meta.url);try{let r=resolve(process.cwd(),t);return r===e||realpathSync(r)===realpathSync(e)}catch{return t.endsWith("cli.js")||t.includes("agentsmesh")}}s(lU,"isMainModule");if(lU()){let t=rU(process.argv.slice(2));aU(t).catch(e=>Tg(e instanceof Error?e:new Error(String(e)),{verbose:t.flags.verbose===true}));}export{rU as parseArgs};
|