@truenine/memory-sync-cli 2026.10314.10813 → 2026.10317.12338
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/globals.d.cts +1 -1
- package/dist/globals.d.mts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/plugin-runtime.mjs +57 -48
- package/dist/plugin.config-94j_-y7H.mjs +188 -0
- package/dist/plugin.config-DZUQlXdU.mjs +81 -0
- package/dist/plugin.config-DshgEVJW.cjs +188 -0
- package/dist/tnmsc.schema.json +9 -12
- package/package.json +10 -10
- package/dist/plugin.config-CwTid43p.mjs +0 -171
- package/dist/plugin.config-M0Vfj7Yf.cjs +0 -171
- package/dist/plugin.config-PD_T1uuL.mjs +0 -73
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as x,V as S,W as C,X as ee,Y as te,Z as w,_ as T,a as E,at as D,b as O,c as ne,ct as re,d as ie,dt as k,et as A,f as ae,ft as oe,g as j,h as se,i as ce,it as le,j as ue,k as de,l as M,lt as N,m as P,n as fe,nt as F,o as I,ot as pe,p as me,pt as he,q as ge,r as _e,rt as ve,s as ye,st as L,t as be,tt as xe,u as Se,ut as Ce,v as we,w as Te,x as Ee,y as R,z}from"./plugin-runtime.mjs";import B from"node:process";import*as V from"node:fs";import*as H from"node:path";import*as U from"node:os";import{Buffer as W}from"node:buffer";import De from"json5";const G=`.agents/skills`,Oe=`SKILL.md`;var ke=class extends O{constructor(){super(`GenericSkillsOutputPlugin`,{outputFileName:Oe,treatWorkspaceRootProjectAsProject:!0,skills:{},cleanup:{delete:{project:{dirs:[G]},global:{dirs:[G]}}},capabilities:{skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{skills:n}=e.collectedOutputContext;if(n==null||n.length===0)return t;let r=this.selectSingleScopeItems(n,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),i=this.selectSingleScopeItems(n,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),a=(e,n,r)=>{for(let i of r){let r=i.yamlFrontMatter.name,a=this.joinPath(e,r);if(t.push({path:this.joinPath(a,Oe),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:this.joinPath(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:this.joinPath(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},s=(e,n,r)=>{for(let i of r)i.mcpConfig!=null&&t.push({path:this.joinPath(e,i.yamlFrontMatter.name,`mcp.json`),scope:n,source:{kind:`skillMcp`,rawContent:i.mcpConfig.rawContent}})};if(r.selectedScope===`project`||i.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectRootDir(e,t);if(n==null)continue;let c=o(r.items,t.projectConfig,`skills`),l=o(i.items,t.projectConfig,`skills`),u=this.joinPath(n,G);r.selectedScope===`project`&&c.length>0&&a(u,`project`,c),i.selectedScope===`project`&&s(u,`project`,l)}if(r.selectedScope!==`global`&&i.selectedScope!==`global`)return t;let c=this.joinPath(this.getHomeDir(),G),l=this.resolvePromptSourceProjectConfig(e);if(r.selectedScope===`global`){let e=o(r.items,l,`skills`);e.length>0&&a(c,`global`,e)}return i.selectedScope===`global`&&s(c,`global`,o(i.items,l,`skills`)),t}async convertContent(e,t){let n=e.source;switch(n.kind){case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcp`:return n.rawContent;case`skillChildDoc`:return n.content;case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}};const Ae=`AGENTS.md`;var je=class extends O{constructor(){super(`AgentsOutputPlugin`,{outputFileName:Ae,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{files:[Ae]}}},capabilities:{prompt:{scopes:[`project`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],n=this.getProjectPromptOutputProjects(e);if(!new Set(this.selectPromptScopes(e,[`project`])).has(`project`))return t;for(let[r,i]of n.entries()){let n=this.resolveProjectRootDir(e,i);if(i.rootMemoryPrompt!=null&&n!=null&&t.push({path:this.resolvePath(n,Ae),scope:`project`,source:{type:`projectRootMemory`,projectIndex:r}}),i.childMemoryPrompts!=null)for(let[e,n]of i.childMemoryPrompts.entries())t.push({path:this.resolveFullPath(n.dir),scope:`project`,source:{type:`projectChildMemory`,projectIndex:r,childIndex:e}})}return t}async convertContent(e,t){let n=this.getProjectPromptOutputProjects(t),r=e.source,i=r.projectIndex??-1;if(i<0||i>=n.length)throw Error(`Invalid project index in declaration for ${this.name}`);let a=n[i];if(a==null)throw Error(`Project not found for declaration in ${this.name}`);if(r.type===`projectRootMemory`){if(a.rootMemoryPrompt==null)throw Error(`Root memory prompt missing for project index ${i}`);return a.rootMemoryPrompt.content}if(r.type===`projectChildMemory`){let e=r.childIndex??-1,t=a.childMemoryPrompts?.[e];if(t==null)throw Error(`Child memory prompt missing for project ${i}, child ${e}`);return t.content}throw Error(`Unsupported declaration source for ${this.name}`)}};const Me=`CLAUDE.md`;var Ne=class extends O{constructor(){super(`ClaudeCodeCLIOutputPlugin`,{globalConfigDir:`.claude`,outputFileName:Me,treatWorkspaceRootProjectAsProject:!0,toolPreset:`claudeCode`,commands:{subDir:`commands`,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},subagents:{subDir:`agents`,sourceScopes:[`project`],includePrefix:!0,linkSymbol:`-`,ext:`.md`},skills:{subDir:`skills`},rules:{transformFrontMatter:e=>({paths:e.globs.map(xe)})},cleanup:{delete:{project:{files:[Me],dirs:[`.claude/rules`,`.claude/commands`,`.claude/agents`,`.claude/skills`]},global:{files:[`.claude/CLAUDE.md`],dirs:[`.claude/rules`,`.claude/commands`,`.claude/agents`,`.claude/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}};const Pe=Se.CURSOR,Fe=ae.MCP_CONFIG,Ie=me.COMMANDS,K=me.RULES,Le=ae.CURSOR_GLOBAL_RULE,q=me.CURSOR_SKILLS,Re=ae.SKILL,J=se.CURSOR;var ze=class extends O{constructor(){super(`CursorOutputPlugin`,{globalConfigDir:Pe,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[P.AgentsOutput],indexignore:ie.CURSOR,commands:{subDir:Ie,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:q},rules:{subDir:K,prefix:`rule`,sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{files:[`.cursor/mcp.json`],dirs:[`.cursor/commands`,`.cursor/rules`],globs:[`.cursor/skills-cursor/*`]},global:{files:[`.cursor/mcp.json`],dirs:[`.cursor/commands`,`.cursor/rules`],globs:[`.cursor/skills-cursor/*`]}},protect:{project:{dirs:[...J].map(e=>`.cursor/skills-cursor/${e}`)},global:{dirs:[...J].map(e=>`.cursor/skills-cursor/${e}`)}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareCleanupPaths(e){let t=await super.declareCleanupPaths(e);return{...t,delete:(t.delete??[]).map(e=>e.kind!==`glob`||!e.path.replaceAll(`\\`,`/`).endsWith(`/.cursor/${q}/*`)?e:{...e,excludeBasenames:[...J]})}}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:i,rules:a,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getConcreteProjects(e),d=this.getProjectPromptOutputProjects(e),f=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),p=new Set(this.selectPromptScopes(e,[`global`])),m=new Set(a==null?[]:this.selectRuleScopes(e,a)),h=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),_=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),v=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),y=(e,n,r)=>{for(let i of r){let r=i.yamlFrontMatter.name;if(this.isPreservedSkill(r))continue;let a=H.join(e,q,r);if(t.push({path:H.join(a,Re),scope:n,source:{kind:`skill`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:H.join(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:H.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},b=(e,n,r)=>{for(let i of r){if(i.mcpConfig==null)continue;let r=H.join(e,q,i.yamlFrontMatter.name);t.push({path:H.join(r,Fe),scope:n,source:{kind:`skillMcpConfig`,rawContent:i.mcpConfig.rawContent}})}},x=(e,n,r)=>{if(r.length===0)return;let i=be(r,this.log);i.size!==0&&t.push({path:H.join(e,Fe),scope:n,source:{kind:`mcpConfig`,mcpServers:ce(i,fe)}})};if(h.selectedScope===`project`||_.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);if(n!=null&&(h.selectedScope===`project`&&y(n,`project`,o(h.items,t.projectConfig,`skills`)),_.selectedScope===`project`)){let e=o(_.items,t.projectConfig,`skills`);b(n,`project`,e),x(n,`project`,e)}}if((h.selectedScope===`global`||_.selectedScope===`global`)&&(h.selectedScope===`global`&&y(c,`global`,o(h.items,l,`skills`)),_.selectedScope===`global`)){let e=o(_.items,l,`skills`);b(c,`global`,e),x(c,`global`,e)}if(v.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let i=o(v.items,n.projectConfig,`commands`);for(let e of i)t.push({path:H.join(r,Ie,this.transformCommandName(e,f)),scope:`project`,source:{kind:`command`,command:e}})}if(v.selectedScope===`global`){let e=o(v.items,l,`commands`);for(let n of e)t.push({path:H.join(c,Ie,this.transformCommandName(n,f)),scope:`global`,source:{kind:`command`,command:n}})}if(a!=null&&a.length>0){let n=a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(m.has(`global`))for(let e of n)t.push({path:H.join(c,K,this.buildRuleFileName(e)),scope:`global`,source:{kind:`ruleMdc`,rule:e}});if(m.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let i=g(o(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:H.join(r,K,this.buildRuleFileName(e)),scope:`project`,source:{kind:`ruleMdc`,rule:e}})}}if(n!=null&&p.has(`global`)){let r=this.buildGlobalRuleContent(n.content,e);for(let n of d){let i=this.resolveProjectConfigDir(e,n);i!=null&&t.push({path:H.join(i,K,Le),scope:`project`,source:{kind:`globalRuleContent`,content:r}})}}let S=this.getIgnoreOutputPath(),C=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(S!=null&&C!=null)for(let e of u){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:H.join(n.basePath,n.path,S),scope:`project`,source:{kind:`ignoreFile`,content:C.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`command`:return this.buildCommandContent(n.command,t);case`mcpConfig`:return JSON.stringify({mcpServers:n.mcpServers},null,2);case`skill`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcpConfig`:return n.rawContent;case`skillChildDoc`:case`globalRuleContent`:case`ignoreFile`:return n.content;case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;case`ruleMdc`:return this.buildRuleMdcContent(n.rule,t);default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildGlobalRuleContent(e,t){return this.buildMarkdownContent(e,{description:`Global prompt (synced)`,alwaysApply:!0},t)}isPreservedSkill(e){return J.has(e)}buildRuleMdcContent(e,t){let n={alwaysApply:!1,globs:e.globs.length>0?e.globs.join(`, `):``};return this.buildMarkdownContent(e.content,n,t).split(`
|
|
2
|
+
`).map(e=>{let t=/^(\s*globs:\s*)(['"])(.*)\2\s*$/.exec(e);if(t==null)return e;let n=t[1]??`globs: `,r=t[3]??``;return r.trim().length===0?e:`${n}${r}`}).join(`
|
|
3
|
+
`)}};const Be=`AGENTS.md`;var Ve=class extends O{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:`.factory`,outputFileName:Be,treatWorkspaceRootProjectAsProject:!0,commands:{transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{},cleanup:{delete:{project:{files:[Be],dirs:[`.factory/commands`,`.factory/skills`]},global:{files:[`.factory/AGENTS.md`],dirs:[`.factory/commands`,`.factory/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}buildSkillMainContent(e,t){let n=e.yamlFrontMatter==null?void 0:{name:e.yamlFrontMatter.name,description:e.yamlFrontMatter.description};return this.buildMarkdownContent(e.content,n,t)}};const He=`.editorconfig`;var Ue=class extends O{constructor(){super(`EditorConfigOutputPlugin`,{cleanup:{delete:{project:{files:[He]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{editorConfigFiles:r}=e.collectedOutputContext;if(r==null||r.length===0)return t;for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of r)t.push({path:this.resolvePath(n.basePath,n.path,He),scope:`project`,source:{content:e.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const We=`GEMINI.md`;var Ge=class extends O{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:`.gemini`,outputFileName:We,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{globs:[We]},global:{files:[`.gemini/GEMINI.md`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}},Ke=class extends O{constructor(){super(`GitExcludeOutputPlugin`,{capabilities:{}})}async declareOutputFiles(e){let t=[],{workspace:n,globalGitIgnore:r,shadowGitExclude:i}=e.collectedOutputContext,a=this.buildManagedContent(r,i);if(a.length===0)return t;let o=this.normalizeContent(a),s=new Set,{projects:c}=n;for(let e of c){if(e.dirFromWorkspacePath==null)continue;let n=e.dirFromWorkspacePath.getAbsolutePath(),r=[n,...l(n)];for(let e of r){let n=f(e);if(n==null)continue;let r=H.join(n,`exclude`);s.has(r)||(s.add(r),t.push({path:r,scope:`project`,source:{content:o}}))}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}buildManagedContent(e,t){let n=[];if(e!=null&&e.trim().length>0){let t=this.sanitizeContent(e);t.length>0&&n.push(t)}if(t!=null&&t.trim().length>0){let e=this.sanitizeContent(t);e.length>0&&n.push(e)}return n.length===0?``:n.join(`
|
|
4
|
+
`)}sanitizeContent(e){return e.split(/\r?\n/).filter(e=>{let t=e.trim();return t.length===0?!0:!(t.startsWith(`#`)&&!t.startsWith(`\\#`))}).join(`
|
|
5
|
+
`).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const qe=`AGENTS.md`,Y=`prompts`,Je=`skills`,Ye=`.aiassistant`;var Xe=class extends O{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:qe,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:Y,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:Je},dependsOn:[P.AgentsOutput],indexignore:`.aiignore`,cleanup:{delete:{project:{dirs:[`.aiassistant/rules`,`.aiassistant/codex/prompts`,`.aiassistant/codex/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:i,aiAgentIgnoreConfigFiles:a}=e.collectedOutputContext,s=this.getConcreteProjects(e),c=this.getProjectPromptOutputProjects(e),l=this.getJetBrainsCodexDirs(e),u=new Set(this.selectPromptScopes(e,[`project`,`global`])),d=this.resolvePromptSourceProjectConfig(e),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),p=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=this.getTransformOptionsFromContext(e);if(u.has(`project`))for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let i=H.join(r,Ye,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:H.join(i,`always.md`),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null)for(let r of n.childMemoryPrompts)t.push({path:H.join(i,this.buildChildRuleFileName(r)),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildGlobRuleContent(r,e)}})}let h=(e,n,r)=>{for(let i of r){let r=i.yamlFrontMatter?.name??i.dir.getDirectoryName(),a=H.join(e,Je,r);if(t.push({path:H.join(a,`SKILL.md`),scope:n,source:{kind:`skill`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:H.join(a,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:H.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}};if(f.selectedScope===`project`||p.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let i=H.join(r,Ye,`codex`);if(f.selectedScope===`project`){let e=o(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:H.join(i,Y,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(i,`project`,o(p.items,n.projectConfig,`skills`))}if(l.length>0){if(n!=null&&u.has(`global`))for(let e of l)t.push({path:H.join(e,qe),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?o(f.items,d,`commands`):[],r=p.selectedScope===`global`?o(p.items,d,`skills`):[];for(let n of l){for(let r of e)t.push({path:H.join(n,Y,this.transformCommandName(r,m)),scope:`global`,source:{kind:`command`,command:r}});h(n,`global`,r)}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:a?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of s){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:H.join(n.basePath,n.path,g),scope:`project`,source:{kind:`ignoreFile`,content:_.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`projectRuleContent`:case`globalMemory`:case`skillReference`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skill`:return this.buildCodexSkillContent(n.skill,t);case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}async declareCleanupPaths(e){let t=await super.declareCleanupPaths(e),n=this.getJetBrainsCodexDirs(e);if(n.length===0)return t;let r=n.flatMap(e=>[{path:H.join(e,qe),kind:`file`,scope:`global`},{path:H.join(e,Y),kind:`directory`,scope:`global`},{path:H.join(e,Je),kind:`directory`,scope:`global`}]),i=t.delete??[];return{...t,delete:[...i,...r]}}getJetBrainsCodexDirs(e){return e.runtimeTargets.jetbrainsCodexDirs}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildChildRulePattern(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``);return t.length===0?`**/*`:`${t}/**`}buildAlwaysRuleContent(e,t){return this.buildMarkdownContent(e,{apply:`始终`},t)}buildGlobRuleContent(e,t){let n={apply:`按文件模式`,模式:this.buildChildRulePattern(e)};return this.buildMarkdownContent(e.content,n,t)}buildCodexSkillContent(e,t){let n=e.yamlFrontMatter,r=this.normalizeSkillName(n.name,64),i=this.normalizeToSingleLine(n.description,1024),a={};n.displayName!=null&&(a[`short-description`]=n.displayName),n.version!=null&&(a.version=n.version),n.author!=null&&(a.author=n.author),n.keywords!=null&&n.keywords.length>0&&(a.keywords=[...n.keywords]);let o={name:r,description:i};return Object.keys(a).length>0&&(o.metadata=a),n.allowTools!=null&&n.allowTools.length>0&&(o[`allowed-tools`]=n.allowTools.join(` `)),this.buildMarkdownContent(e.content,o,t)}normalizeSkillName(e,t){let n=e.toLowerCase().replaceAll(/[^a-z0-9-]/g,`-`).replaceAll(/-+/g,`-`).replaceAll(/^-+|-+$/g,``);return n.length>t&&(n=n.slice(0,t).replace(/-+$/,``)),n}normalizeToSingleLine(e,t){let n=e.replaceAll(/[\r\n]+/g,` `).replaceAll(/\s+/g,` `).trim();return n.length>t?`${n.slice(0,t-3)}...`:n}};const Ze=`.idea`;var Qe=class extends O{constructor(){super(`JetBrainsIDECodeStyleConfigOutputPlugin`,{cleanup:{delete:{project:{files:[`.editorconfig`,`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{jetbrainsConfigFiles:r,editorConfigFiles:i}=e.collectedOutputContext,a=[...r??[],...i??[]];for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of a){let r=this.getTargetRelativePath(e);t.push({path:this.resolvePath(n.basePath,n.path,r),scope:`project`,source:{content:e.content}})}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}getTargetRelativePath(t){let n=t.dir.path;if(t.type===e.EditorConfig)return`.editorconfig`;if(t.type!==e.IntellijIDEA)return this.basename(n);let r=n.indexOf(Ze);return r===-1?this.joinPath(Ze,`codeStyles`,this.basename(n)):n.slice(Math.max(0,r))}};const $e=`AGENTS.md`,et=`prompts`;var tt=class extends O{constructor(){super(`CodexCLIOutputPlugin`,{globalConfigDir:`.codex`,outputFileName:$e,commands:{subDir:et,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},cleanup:{delete:{global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},dependsOn:[P.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let{globalMemory:t,commands:n}=e.collectedOutputContext,r=this.getGlobalConfigDir(),i=[],a=new Set(this.selectPromptScopes(e,[`global`]));if(t!=null&&a.has(`global`)&&i.push({path:H.join(r,$e),scope:`global`,source:{kind:`globalMemory`,content:t.content}}),n==null||n.length===0)return i;let s=this.resolvePromptSourceProjectConfig(e),c=this.getTransformOptionsFromContext(e),l=this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`));if(l.items.length===0)return i;let u=o(l.items,s,`commands`);for(let e of u){let t=this.transformCommandName(e,c);i.push({path:H.join(r,et,t),scope:`global`,source:{kind:`command`,command:e}})}return i}async convertContent(e,t){let n=e.source;if(n.kind===`globalMemory`)return n.content;if(n.kind===`command`)return this.buildCommandContent(n.command,t);throw Error(`Unsupported declaration source for ${this.name}`)}};const X=`AGENTS.md`,nt=`commands`,rt=`agents`,it=`skills`;function at(e,t){let n={},r=t.sourceFrontMatter;if(r?.description!=null&&(n.description=r.description),r?.agent!=null&&(n.agent=r.agent),r?.model!=null&&(n.model=r.model),r?.allowTools!=null&&Array.isArray(r.allowTools)){let e={};for(let t of r.allowTools)e[String(t)]=!0;n.tools=e}for(let[e,t]of Object.entries(r??{}))[`description`,`agent`,`model`,`allowTools`,`namingCase`,`argumentHint`].includes(e)||(n[e]=t);return n}var ot=class extends O{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:X,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:nt,transformFrontMatter:at},subagents:{subDir:rt},skills:{subDir:it},cleanup:{delete:{project:{files:[X,`.opencode/opencode.json`],dirs:[`.opencode/commands`,`.opencode/agents`,`.opencode/skills`]},global:{files:[`.config/opencode/AGENTS.md`,`.config/opencode/opencode.json`],dirs:[`.config/opencode/commands`,`.config/opencode/agents`,`.config/opencode/skills`]},xdgConfig:{files:[`opencode/AGENTS.md`,`opencode/opencode.json`],dirs:[`opencode/commands`,`opencode/agents`,`opencode/skills`]}}},dependsOn:[P.AgentsOutput],capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},subagents:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,subAgents:i,skills:a}=e.collectedOutputContext,s=this.getGlobalConfigDir(),c=new Set(this.selectPromptScopes(e,[`project`,`global`])),l=this.getProjectPromptOutputProjects(e),u=this.resolvePromptSourceProjectConfig(e),d=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=i==null?{items:[]}:this.selectSingleScopeItems(i,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)),p=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`));n!=null&&c.has(`global`)&&t.push({path:H.join(s,X),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let i=be(r,this.log);i.size!==0&&t.push({path:H.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:ce(i,_e)}})},g=(e,n,r)=>{for(let i of r){let r=this.validateAndNormalizeSkillName(i.yamlFrontMatter?.name??i.dir.getDirectoryName()),a=H.join(e,it,r);if(t.push({path:H.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i,normalizedSkillName:r}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:H.join(a,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:H.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},_=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let n of l){let r=this.resolveProjectRootDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&c.has(`project`)&&t.push({path:H.join(r,X),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null&&c.has(`project`)))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{kind:`projectChildMemory`,content:e.content}})}if(d.selectedScope===`project`||f.selectedScope===`project`||p.selectedScope===`project`||m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let i=H.join(r,`.opencode`),a=o(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of a)t.push({path:H.join(i,nt,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let s=o(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of s)t.push({path:H.join(i,rt,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let c=o(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(i,`project`,c);let l=o(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(i,`project`,l)}if(d.selectedScope===`global`){let e=o(d.items,u,`commands`);for(let n of e)t.push({path:H.join(s,nt,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=o(f.items,u,`subAgents`);for(let n of e)t.push({path:H.join(s,rt,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(s,`global`,o(p.items,u,`skills`)),m.selectedScope===`global`&&h(s,`global`,o(m.items,u,`skills`)),t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`projectRootMemory`:case`projectChildMemory`:case`skillReference`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`subAgent`:{let e=this.buildOpencodeAgentFrontMatter(n.agent);return this.buildMarkdownContent(n.agent.content,e,t)}case`skillMain`:{let e=this.buildOpencodeSkillFrontMatter(n.skill,n.normalizedSkillName);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;case`mcpConfig`:return JSON.stringify({$schema:`https://opencode.ai/config.json`,plugin:[`opencode-rules@latest`],mcp:n.mcpServers},null,2);default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildOpencodeAgentFrontMatter(e){let t={},n=e.yamlFrontMatter;if(n?.description!=null&&(t.description=n.description),t.mode=n?.mode??`subagent`,n?.model!=null&&(t.model=n.model),n?.temperature!=null&&(t.temperature=n.temperature),n?.maxSteps!=null&&(t.maxSteps=n.maxSteps),n?.hidden!=null&&(t.hidden=n.hidden),n?.allowTools!=null&&Array.isArray(n.allowTools)){let e={};for(let t of n.allowTools)e[String(t)]=!0;t.tools=e}n?.permission!=null&&typeof n.permission==`object`&&(t.permission=n.permission);for(let[e,r]of Object.entries(n??{}))[`description`,`mode`,`model`,`temperature`,`maxSteps`,`hidden`,`allowTools`,`permission`,`namingCase`,`name`,`color`].includes(e)||(t[e]=r);return t}buildOpencodeSkillFrontMatter(e,t){let n={},r=e.yamlFrontMatter;n.name=t,r?.description!=null&&(n.description=r.description),n.license=r?.license??`MIT`,n.compatibility=r?.compatibility??`opencode`;let i={};for(let e of[`author`,`version`,`keywords`,`category`,`repository`,`displayName`])r?.[e]!=null&&(i[e]=r[e]);let a=new Set([`name`,`description`,`license`,`compatibility`,`namingCase`,`allowTools`,`keywords`,`displayName`,`author`,`version`]);for(let[e,t]of Object.entries(r??{}))a.has(e)||(i[e]=t);return Object.keys(i).length>0&&(n.metadata=i),n}validateAndNormalizeSkillName(e){let t=e.toLowerCase();return t=t.replaceAll(/[^a-z0-9-]+/g,`-`),t=t.replaceAll(/-+/g,`-`),t=t.replaceAll(/^-|-$/g,``),t.length===0?t=`skill`:t.length>64&&(t=t.slice(0,64),t=t.replace(/-$/,``)),t}};const Z=`rules`,st=`commands`,ct=`skills`,lt=`glob`,ut=`glob`;function dt(e,t){let n=t.sourceFrontMatter,r={description:`Fast command`,type:`user_command`};return n?.description!=null&&(r.description=n.description),n?.argumentHint!=null&&(r.argumentHint=n.argumentHint),n?.allowTools!=null&&Array.isArray(n.allowTools)&&n.allowTools.length>0&&(r.allowTools=n.allowTools),r}var ft=class extends O{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:st,transformFrontMatter:dt},skills:{subDir:ct},rules:{subDir:Z,sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{dirs:[`.qoder/commands`,`.qoder/rules`,`.qoder/skills`]},global:{dirs:[`.qoder/commands`,`.qoder/rules`,`.qoder/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0},mcp:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,commands:r,skills:i,rules:a,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),d=new Set(a==null?[]:this.selectRuleScopes(e,a)),f=new Set(this.selectPromptScopes(e,[`project`,`global`])),p=this.getProjectPromptOutputProjects(e),m=r==null?{items:[]}:this.selectSingleScopeItems(r,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),h=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),_=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),v=(e,n,r)=>{for(let i of r){let r=i.yamlFrontMatter.name,a=H.join(e,ct,r);if(t.push({path:H.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:H.join(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:H.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},y=(e,n,r)=>{for(let i of r){if(i.mcpConfig==null)continue;let r=H.join(e,ct,i.yamlFrontMatter.name);t.push({path:H.join(r,`mcp.json`),scope:n,source:{kind:`skillMcpConfig`,rawContent:i.mcpConfig.rawContent}})}};if(m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let i=o(m.items,n.projectConfig,`commands`);for(let e of i)t.push({path:H.join(r,st,this.transformCommandName(e,u)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=o(m.items,l,`commands`);for(let n of e)t.push({path:H.join(c,st,this.transformCommandName(n,u)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||_.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&v(n,`project`,o(h.items,t.projectConfig,`skills`)),_.selectedScope===`project`&&y(n,`project`,o(_.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||_.selectedScope===`global`)&&(h.selectedScope===`global`&&v(c,`global`,o(h.items,l,`skills`)),_.selectedScope===`global`&&y(c,`global`,o(_.items,l,`skills`))),n!=null&&f.has(`global`))for(let r of p){let i=this.resolveProjectConfigDir(e,r);i!=null&&t.push({path:H.join(i,Z,`global.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.content,e)}})}if(f.has(`project`))for(let n of p){let r=this.resolveProjectConfigDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&t.push({path:H.join(r,Z,`always.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null))for(let i of n.childMemoryPrompts)t.push({path:H.join(r,Z,this.buildChildRuleFileName(i)),scope:`project`,source:{kind:`ruleContent`,content:this.buildGlobRuleContent(i,e)}})}if(a!=null&&a.length>0&&d.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let i=g(o(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:H.join(r,Z,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rulePrompt`,rule:e}})}if(a!=null&&a.length>0&&d.has(`global`)){let e=a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);for(let n of e)t.push({path:H.join(c,Z,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let b=this.getIgnoreOutputPath(),x=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(b!=null&&x!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:H.join(e.basePath,e.path,b),scope:`project`,source:{kind:`ignoreFile`,content:x.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`command`:return this.buildCommandContent(n.command,t);case`ruleContent`:return n.content;case`rulePrompt`:return this.buildRuleContent(n.rule,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillMcpConfig`:return n.rawContent;case`skillChildDoc`:case`ignoreFile`:return n.content;case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildChildRuleFileName(e){let t=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`);return`glob-${t.length>0?t:`root`}.md`}buildAlwaysRuleContent(e,t){return this.buildMarkdownContent(e,{trigger:`always_on`,type:`user_command`},t)}buildGlobRuleContent(e,t){let n=(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),r=n.length===0?`**/*`:`${n}/**`;return this.buildMarkdownContent(e.content,{trigger:lt,[ut]:r,type:`user_command`},t)}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:t.name,description:t.description,type:`user_command`,...t.displayName!=null&&{displayName:t.displayName},...t.keywords!=null&&t.keywords.length>0&&{keywords:t.keywords},...t.author!=null&&{author:t.author},...t.version!=null&&{version:t.version},...t.allowTools!=null&&t.allowTools.length>0&&{allowTools:t.allowTools}}}buildRuleFileName(e,t=`rule-`){return`${t}${e.prefix}-${e.ruleName}.md`}buildRuleContent(e,t){let n={trigger:lt,[ut]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function pt(e){return Te[e??`Readme`].out}var mt=class extends O{constructor(){super(`ReadmeMdConfigFileOutputPlugin`,{outputFileName:`README.md`,cleanup:{delete:{project:{files:[`README.md`,`CODE_OF_CONDUCT.md`,`SECURITY.md`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{readmePrompts:n}=e.collectedOutputContext;if(n==null||n.length===0)return t;for(let e of n){let n=pt(e.fileKind),r=H.join(e.targetDir.basePath,e.targetDir.path,n);t.push({path:r,scope:`project`,source:{content:e.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const ht=`GLOBAL.md`,gt=`.trae`,_t=`commands`,vt=`skills`;var yt=class extends O{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:gt,outputFileName:ht,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:_t,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:vt},cleanup:{delete:{project:{dirs:[`.trae/rules`,`.trae/commands`,`.trae/skills`]},global:{dirs:[`.trae/steering`,`.trae/commands`,`.trae/skills`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}getIgnoreOutputPath(){if(this.indexignore!=null)return H.join(`.trae`,`.ignore`)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),`steering`)}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:i,aiAgentIgnoreConfigFiles:a}=e.collectedOutputContext,s=this.getConcreteProjects(e),c=this.getProjectPromptOutputProjects(e),l=this.resolvePromptSourceProjectConfig(e),u=new Set(this.selectPromptScopes(e,[`project`,`global`])),d=n==null?{items:[]}:this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),p=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});i!=null&&u.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),ht),scope:`global`,source:{kind:`globalMemory`,content:i.content}});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&u.has(`project`))for(let i of n.childMemoryPrompts){let n=(i.workingChildDirectoryPath?.path??i.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),a=this.buildProjectRelativeGlobPattern(n),o=this.buildMarkdownContent([this.buildPathGuardHint(n),``,i.content].join(`
|
|
6
|
+
`),{alwaysApply:!1,globs:a},e);t.push({path:H.join(r,gt,`rules`,this.buildSteeringFileName(i)),scope:`project`,source:{kind:`steeringRule`,content:o}})}}if(d.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let i=o(d.items,n.projectConfig,`commands`);for(let e of i)t.push({path:H.join(r,_t,this.transformCommandName(e,p)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=this.getGlobalConfigDir(),n=o(d.items,l,`commands`);for(let r of n)t.push({path:H.join(e,_t,this.transformCommandName(r,p)),scope:`global`,source:{kind:`command`,command:r}})}let m=(e,n,r)=>{for(let i of r){let r=i.yamlFrontMatter.name,a=H.join(e,vt,r);if(t.push({path:H.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:H.join(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(i.resources!=null)for(let e of i.resources)t.push({path:H.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}};if(f.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&m(n,`project`,o(f.items,t.projectConfig,`skills`))}f.selectedScope===`global`&&m(this.getGlobalConfigDir(),`global`,o(f.items,l,`skills`));let h=this.getIgnoreOutputPath(),g=this.indexignore==null?void 0:a?.find(e=>e.fileName===this.indexignore);if(h!=null&&g!=null)for(let e of s){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:H.join(n.basePath,n.path,h),scope:`project`,source:{kind:`ignoreFile`,content:g.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`steeringRule`:case`skillChildDoc`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;default:throw Error(`Unsupported declaration source for ${this.name}`)}}buildSkillFrontMatter(e){let t={description:e.yamlFrontMatter.description??``};return e.yamlFrontMatter.displayName!=null&&(t.name=e.yamlFrontMatter.displayName),t}buildSteeringFileName(e){return`trae-${(e.workingChildDirectoryPath?.path??e.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``).replaceAll(`/`,`-`)}.md`}buildPathGuardHint(e){return e.length===0?`Scope guard: apply this rule to project source files only; do not apply to generated output directories (for example dist/, build/, out/, .next/, target/).`:[`Scope guard: this rule is for the project-root path "${e}/" only.`,`Do not apply this rule to generated output paths such as "dist/${e}/", "build/${e}/", "out/${e}/", ".next/${e}/", or "target/${e}/".`].join(`
|
|
7
|
+
`)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const bt=`.vscode`;var xt=class extends O{constructor(){super(`VisualStudioCodeIDEConfigOutputPlugin`,{cleanup:{delete:{project:{files:[`.vscode/settings.json`,`.vscode/extensions.json`]}}},capabilities:{}})}async declareOutputFiles(e){let t=[],{projects:n}=e.collectedOutputContext.workspace,{vscodeConfigFiles:r}=e.collectedOutputContext,i=r??[];for(let e of n){let n=e.dirFromWorkspacePath;if(n!=null)for(let e of i){let r=this.getTargetRelativePath(e);t.push({path:this.resolvePath(n.basePath,n.path,r),scope:`project`,source:{content:e.content}})}}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}getTargetRelativePath(t){let n=t.dir.path;if(t.type!==e.VSCode)return this.basename(n);let r=n.indexOf(bt);return r===-1?this.joinPath(bt,this.basename(n)):n.slice(Math.max(0,r))}};const Q=`WARP.md`;var St=class extends O{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:Q,treatWorkspaceRootProjectAsProject:!0,indexignore:`.warpindexignore`,cleanup:{delete:{project:{files:[Q]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,aiAgentIgnoreConfigFiles:r}=e.collectedOutputContext,i=this.getConcreteProjects(e),a=this.getProjectPromptOutputProjects(e),o=this.shouldSkipDueToPlugin(e,P.AgentsOutput),s=new Set(this.selectPromptScopes(e,[`project`,`global`])),c=this.extractGlobalMemoryContent(e);if(o){if(n!=null&&s.has(`global`))for(let r of a){let i=this.resolveProjectRootDir(e,r);i!=null&&t.push({path:H.join(i,Q),scope:`project`,source:{content:n.content}})}}else for(let n of a){let r=this.resolveProjectRootDir(e,n);if(r!=null){if(n.rootMemoryPrompt!=null&&s.has(`project`)){let e=this.combineGlobalWithContent(c,n.rootMemoryPrompt.content);t.push({path:H.join(r,Q),scope:`project`,source:{content:e}})}if(n.childMemoryPrompts!=null&&s.has(`project`))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{content:e.content}})}}let l=this.getIgnoreOutputPath(),u=this.indexignore==null?void 0:r?.find(e=>e.fileName===this.indexignore);if(l!=null&&u!=null)for(let e of i){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:this.resolvePath(n.basePath,n.path,l),scope:`project`,source:{content:u.content}})}return t}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}};const Ct=`.codeium/windsurf`,wt=`global_workflows`,Tt=`memories`,Et=`skills`,Dt=`.windsurf`;var Ot=class extends O{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:Ct,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[P.AgentsOutput],indexignore:`.codeiumignore`,commands:{subDir:wt,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:Et},rules:{sourceScopes:[`project`,`global`]},cleanup:{delete:{project:{dirs:[`.windsurf/rules`,`.windsurf/workflows`,`.windsurf/global_workflows`,`.windsurf/skills`,`.codeium/windsurf/global_workflows`,`.codeium/windsurf/skills`]},global:{dirs:[`.codeium/windsurf/global_workflows`,`.codeium/windsurf/memories`,`.codeium/windsurf/skills`]}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1},rules:{scopes:[`project`,`global`],singleScope:!1},commands:{scopes:[`project`,`global`],singleScope:!0},skills:{scopes:[`project`,`global`],singleScope:!0}}})}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:i,rules:a,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.resolvePromptSourceProjectConfig(e),l=this.getCodeiumWindsurfDir(),u=new Set(this.selectPromptScopes(e,[`global`])),d=n==null?{items:[]}:this.selectSingleScopeItems(n,this.commandsConfig.sourceScopes,e=>this.resolveCommandSourceScope(e),this.getTopicScopeOverride(e,`commands`)),f=r==null?{items:[]}:this.selectSingleScopeItems(r,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),p=this.getConcreteProjects(e);i!=null&&u.has(`global`)&&t.push({path:H.join(l,Tt,`global_rules.md`),scope:`global`,source:{kind:`globalMemory`,content:i.content}});let m=(e,n,r)=>{let i=r.yamlFrontMatter.name,a=H.join(e,Et,i);if(t.push({path:H.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:r}}),r.childDocs!=null)for(let e of r.childDocs)t.push({path:H.join(a,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(r.resources!=null)for(let e of r.resources)t.push({path:H.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})};if(f.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectRootDir(e,t),r=n==null?void 0:H.join(n,Dt);if(r==null)continue;let i=o(f.items,t.projectConfig,`skills`);for(let e of i)m(r,`project`,e)}if(f.selectedScope===`global`){let e=o(f.items,c,`skills`);for(let t of e)m(l,`global`,t)}let h=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});if(d.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n),i=r==null?void 0:H.join(r,Dt);if(i==null)continue;let a=o(d.items,n.projectConfig,`commands`);for(let e of a)t.push({path:H.join(i,`workflows`,this.transformCommandName(e,h)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=o(d.items,c,`commands`);for(let n of e)t.push({path:H.join(l,wt,this.transformCommandName(n,h)),scope:`global`,source:{kind:`command`,command:n}})}if(a!=null&&a.length>0){let n=new Set(this.selectRuleScopes(e,a)),r=a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(n.has(`global`))for(let e of r)t.push({path:H.join(l,Tt,this.buildRuleFileName(e)),scope:`global`,source:{kind:`rule`,rule:e}});if(n.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let i=g(o(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:H.join(r,Dt,`rules`,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rule`,rule:e}})}}let _=this.getIgnoreOutputPath(),v=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(_!=null&&v!=null)for(let e of p){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:H.join(n.basePath,n.path,_),scope:`project`,source:{kind:`ignoreFile`,content:v.content}})}return t}async convertContent(e,t){let n=e.source;switch(n.kind){case`globalMemory`:case`skillChildDoc`:case`ignoreFile`:return n.content;case`command`:return this.buildCommandContent(n.command,t);case`skillMain`:{let e=this.buildSkillFrontMatter(n.skill);return this.buildMarkdownContent(n.skill.content,e,t)}case`skillResource`:return n.encoding===`base64`?W.from(n.content,`base64`):n.content;case`rule`:return this.buildRuleContent(n.rule,t);default:throw Error(`Unsupported declaration source for ${this.name}`)}}getCodeiumWindsurfDir(){return H.join(this.getHomeDir(),Ct)}buildRuleFileName(e,t=`rule-`){return`${t}${e.prefix}-${e.ruleName}.md`}buildRuleContent(e,t){let n={trigger:`glob`,globs:e.globs.length>0?e.globs.join(`, `):``};return this.buildMarkdownContent(e.content,n,t).split(`
|
|
8
|
+
`).map(e=>{let t=/^(\s*globs:\s*)(['"])(.*)\2\s*$/.exec(e);if(t==null)return e;let n=t[1]??`globs: `,r=t[3]??``;return r.trim().length===0?e:`${n}${r}`}).join(`
|
|
9
|
+
`)}};function kt(e,t){let n=H.join(e,`.git`),r=V.existsSync(n);return r?t?.info(`version control detected`,{path:n}):t?.warn(Ce({code:`AINDEX_VERSION_CONTROL_MISSING`,title:`Aindex root is not under version control`,rootCause:k(`tnmsc did not find a .git directory under "${e}".`),exactFix:k(`Initialize git in "${e}" or place the aindex inside an existing git repository.`),possibleFixes:[k("Run `git init` in the aindex root if the directory should be versioned.")],details:{rootPath:e,gitPath:n}})),{hasGit:r,gitPath:n}}function At(){return H.join(U.homedir(),`.aindex`,`.tnmsc.json`)}var jt=class{logger;constructor(e={}){this.logger=le(`ConfigLoader`)}getSearchPaths(e=B.cwd()){return[At()]}loadFromFile(e){let t=this.resolveTilde(e);try{if(!V.existsSync(t))return{config:{},source:null,found:!1};let e=V.readFileSync(t,`utf8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){return this.logger.warn(L({code:`CONFIG_FILE_LOAD_FAILED`,title:`Failed to load config file`,operation:`read`,targetKind:`config file`,path:t,error:e})),{config:{},source:null,found:!1}}}load(e=B.cwd()){let t=this.getSearchPaths(e),n=[];for(let e of t){let t=this.loadFromFile(e);t.found&&n.push(t)}return{config:this.mergeConfigs(n.map(e=>e.config)),sources:n.map(e=>e.source).filter(e=>e!==null),found:n.length>0}}parseConfig(e,n){let r;try{r=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${n}: ${e.message}`):e}let i=t.safeParse(r);if(i.success)return i.data;let a=i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);throw Error(`Config validation failed in ${n}:\n${a.join(`
|
|
10
|
+
`)}`)}mergeConfigs(e){if(e.length===0)return{};let t=e[0];return e.length===1&&t!=null?t:[...e].reverse().reduce((e,t)=>{let n=this.mergeAindex(e.aindex,t.aindex),r=this.mergeOutputScopeOptions(e.outputScopes,t.outputScopes),i=this.mergeFrontMatterOptions(e.frontMatter,t.frontMatter),a=this.mergeCleanupProtectionOptions(e.cleanupProtection,t.cleanupProtection);return{...e,...t,...n==null?{}:{aindex:n},...r==null?{}:{outputScopes:r},...i==null?{}:{frontMatter:i},...a==null?{}:{cleanupProtection:a}}},{})}mergeAindex(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{dir:t.dir??e.dir,skills:{...e.skills,...t.skills},commands:{...e.commands,...t.commands},subAgents:{...e.subAgents,...t.subAgents},rules:{...e.rules,...t.rules},globalPrompt:{...e.globalPrompt,...t.globalPrompt},workspacePrompt:{...e.workspacePrompt,...t.workspacePrompt},app:{...e.app,...t.app},ext:{...e.ext,...t.ext},arch:{...e.arch,...t.arch}}}mergeOutputScopeTopics(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}mergeOutputScopeOptions(e,t){if(e==null&&t==null)return;if(e==null)return t;if(t==null)return e;let n={};for(let[t,r]of Object.entries(e.plugins??{}))r!=null&&(n[t]={...r});for(let[e,r]of Object.entries(t.plugins??{})){let t=this.mergeOutputScopeTopics(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}mergeFrontMatterOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}mergeCleanupProtectionOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{rules:[...e.rules??[],...t.rules??[]]}}resolveTilde(e){return e.startsWith(`~`)?H.join(U.homedir(),e.slice(1)):e}};let Mt=null;function Nt(e){return(e||!Mt)&&(Mt=new jt(e)),Mt}var Pt=he(oe(),1),Ft=class extends S{constructor(){super(`MarkdownWhitespaceCleanupEffectInputCapability`),this.registerEffect(`markdown-whitespace-cleanup`,this.cleanupWhitespace.bind(this),30)}async cleanupWhitespace(e){let{fs:t,path:n,aindexDir:r,dryRun:i,logger:a}=e,o=[],s=[],c=[],l=[n.join(r,`src`),n.join(r,`app`),n.join(r,`dist`)];for(let n of l){if(!t.existsSync(n)){a.debug({action:`whitespace-cleanup`,message:`Directory does not exist, skipping`,dir:n});continue}this.processDirectory(e,n,o,s,c,i??!1)}let u=c.length>0;return{success:!u,description:i?`Would modify ${o.length} files, skip ${s.length} files`:`Modified ${o.length} files, skipped ${s.length} files`,modifiedFiles:o,skippedFiles:s,...u&&{error:Error(`${c.length} errors occurred during cleanup`)}}}processDirectory(e,t,n,r,i,a){let{fs:o,path:s,logger:c}=e,l;try{l=o.readdirSync(t,{withFileTypes:!0})}catch(e){i.push({path:t,error:e}),c.warn(L({code:`WHITESPACE_CLEANUP_DIRECTORY_READ_FAILED`,title:`Whitespace cleanup could not read a directory`,operation:`read`,targetKind:`cleanup directory`,path:t,error:e}));return}for(let o of l){let c=s.join(t,o.name);o.isDirectory()?this.processDirectory(e,c,n,r,i,a):o.isFile()&&o.name.endsWith(`.md`)&&this.processMarkdownFile(e,c,n,r,i,a)}}processMarkdownFile(e,t,n,r,i,a){let{fs:o,logger:s}=e;try{let e=o.readFileSync(t,`utf8`),i=this.cleanMarkdownContent(e);if(e===i){r.push(t),s.debug({action:`whitespace-cleanup`,skipped:t,reason:`no changes needed`});return}a?(s.debug({action:`whitespace-cleanup`,dryRun:!0,wouldModify:t}),n.push(t)):(o.writeFileSync(t,i,`utf8`),n.push(t),s.debug({action:`whitespace-cleanup`,modified:t}))}catch(e){i.push({path:t,error:e}),s.warn(L({code:`WHITESPACE_CLEANUP_FILE_PROCESS_FAILED`,title:`Whitespace cleanup could not process a markdown file`,operation:`process`,targetKind:`markdown file`,path:t,error:e}))}}cleanMarkdownContent(e){let t=this.detectLineEnding(e),n=e.split(/\r?\n/).map(e=>e.replace(/[ \t]+$/,``)),r=[],i=0;for(let e of n)e===``?(i++,i<=2&&r.push(e)):(i=0,r.push(e));return r.join(t)}detectLineEnding(e){return e.includes(`\r
|
|
11
|
+
`)?`\r
|
|
12
|
+
`:`
|
|
13
|
+
`}collect(e){return{}}};const It=[`skills`,`commands`,`agents`,`app`];var Lt=class extends S{constructor(){super(`OrphanFileCleanupEffectInputCapability`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}buildProtectedDeletionGuard(e){return C({workspaceDir:e.workspaceDir,aindexDir:e.aindexDir,rules:[...x(e.userConfigOptions,e.aindexDir,{workspaceDir:e.workspaceDir}),...(e.userConfigOptions.cleanupProtection?.rules??[]).map(e=>({path:e.path,protectionMode:e.protectionMode,reason:e.reason??`configured cleanup protection rule`,source:`configured-cleanup-protection`,matcher:e.matcher??`path`}))]})}buildDeletionPlan(e,t,n){let r=[],i=[],a=[];for(let o of It){let s=e.path.join(t,o);e.fs.existsSync(s)&&e.fs.statSync(s).isDirectory()&&this.collectDirectoryPlan(e,s,o,n[o],r,i,a)}return{filesToDelete:r,dirsToDelete:i,errors:a}}async cleanupOrphanFiles(e){let{fs:t,path:n,aindexDir:r,logger:i,userConfigOptions:a,dryRun:o}=e,l=n.join(r,`dist`);if(!t.existsSync(l))return i.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:l}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let u=a.aindex,d={skills:u?.skills?.src??`skills`,commands:u?.commands?.src??`commands`,agents:u?.subAgents?.src??`subagents`,app:u?.app?.src??`app`},f=this.buildDeletionPlan(e,l,d),p=this.buildProtectedDeletionGuard(e),m=s(f.filesToDelete,p),h=s(f.dirsToDelete,p),g=[...m.violations,...h.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath));if(g.length>0)return{success:!1,description:`Protected deletion guard blocked orphan cleanup for ${g.length} path(s)`,deletedFiles:[],deletedDirs:[],error:new c(`orphan-file-cleanup`,g)};if(o)return{success:!0,description:`Would delete ${m.safePaths.length} files and ${h.safePaths.length} directories`,deletedFiles:[...m.safePaths],deletedDirs:[...h.safePaths].sort((e,t)=>t.length-e.length)};let _=[],v=[],y=[...f.errors];for(let e of m.safePaths)try{t.unlinkSync(e),_.push(e),i.debug({action:`orphan-cleanup`,deleted:e})}catch(t){y.push({path:e,error:t}),i.warn(L({code:`ORPHAN_CLEANUP_FILE_DELETE_FAILED`,title:`Orphan cleanup could not delete a file`,operation:`delete`,targetKind:`orphan file`,path:e,error:t}))}for(let e of[...h.safePaths].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),v.push(e),i.debug({action:`orphan-cleanup`,deletedDir:e})}catch(t){y.push({path:e,error:t}),i.warn(L({code:`ORPHAN_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Orphan cleanup could not delete a directory`,operation:`delete`,targetKind:`orphan directory`,path:e,error:t}))}let b=y.length>0;return{success:!b,description:`Deleted ${_.length} files and ${v.length} directories`,deletedFiles:_,deletedDirs:v,...b&&{error:Error(`${y.length} errors occurred during cleanup`)}}}collectDirectoryPlan(e,t,n,r,i,a,o){let{fs:s,path:c,aindexDir:l,logger:u}=e,d;try{d=s.readdirSync(t,{withFileTypes:!0})}catch(e){return o.push({path:t,error:e}),u.warn(L({code:`ORPHAN_CLEANUP_DIRECTORY_READ_FAILED`,title:`Orphan cleanup could not read a directory`,operation:`read`,targetKind:`dist cleanup directory`,path:t,error:e})),!1}let f=!1;for(let s of d){let u=c.join(t,s.name);if(s.isDirectory()){this.collectDirectoryPlan(e,u,n,r,i,a,o)?a.push(u):f=!0;continue}if(!s.isFile()){f=!0;continue}this.isOrphanFile(e,u,n,r,l)?i.push(u):f=!0}return!f}isOrphanFile(e,t,n,r,i){let{fs:a,path:o}=e,s=o.basename(t),c=s.endsWith(`.mdx`),l=o.join(i,`dist`,n),u=o.relative(l,t),d=o.dirname(u),f=s.replace(/\.mdx$/,``);return c?!this.getPossibleSourcePaths(o,i,n,r,f,d).some(e=>a.existsSync(e)):!a.existsSync(o.join(i,r,u))}getPossibleSourcePaths(e,t,n,r,i,a){switch(n){case`skills`:{let n=(a===`.`?[i]:a.split(e.sep))[0]??i,o=a===`.`?``:a.slice(n.length+1);return o===``?[...T.map(i=>e.join(t,r,n,`SKILL${i}`)),...T.map(i=>e.join(t,r,n,`skill${i}`))]:T.map(a=>e.join(t,r,n,o,`${i}${a}`))}case`commands`:case`agents`:case`app`:return a===`.`?T.map(n=>e.join(t,r,`${i}${n}`)):T.map(n=>e.join(t,r,a,`${i}${n}`));default:return[]}}collect(e){return{}}},Rt=class extends S{constructor(){super(`SkillDistCleanupEffectInputCapability`),this.registerEffect(`skill-dist-cleanup`,this.cleanupDistSkillArtifacts.bind(this),10)}async cleanupDistSkillArtifacts(e){let{fs:t,logger:n,userConfigOptions:r,aindexDir:i,dryRun:a}=e,o=this.resolveAindexPath(r.aindex.skills.src,i),s=this.resolveAindexPath(r.aindex.skills.dist,i);if(!t.existsSync(s))return n.debug({action:`skill-dist-cleanup`,message:`dist skills directory does not exist, skipping`,srcSkillsDir:o,distSkillsDir:s}),{success:!0,description:`dist skills directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=this.buildCleanupPlan(e,s);if(a)return{success:!0,description:`Would delete ${c.filesToDelete.length} files and ${c.dirsToDelete.length} directories`,deletedFiles:[...c.filesToDelete],deletedDirs:[...c.dirsToDelete].sort((e,t)=>t.length-e.length)};let l=[],u=[],d=[...c.errors];for(let e of c.filesToDelete)try{t.unlinkSync(e),l.push(e),n.debug({action:`skill-dist-cleanup`,deleted:e})}catch(t){d.push({path:e,error:t}),n.warn(L({code:`SKILL_DIST_CLEANUP_FILE_DELETE_FAILED`,title:`Skill dist cleanup could not delete a file`,operation:`delete`,targetKind:`skill dist file`,path:e,error:t}))}for(let e of[...c.dirsToDelete].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),u.push(e),n.debug({action:`skill-dist-cleanup`,deletedDir:e})}catch(t){d.push({path:e,error:t}),n.warn(L({code:`SKILL_DIST_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Skill dist cleanup could not delete a directory`,operation:`delete`,targetKind:`skill dist directory`,path:e,error:t}))}let f=d.length>0;return{success:!f,description:`Deleted ${l.length} files and ${u.length} directories`,deletedFiles:l,deletedDirs:u,...f&&{error:Error(`${d.length} errors occurred during cleanup`)}}}buildCleanupPlan(e,t){let n=[],r=[],i=[];return this.collectCleanupPlan(e,t,n,r,i),{filesToDelete:n,dirsToDelete:r,errors:i}}collectCleanupPlan(e,t,n,r,i){let{fs:a,path:o,logger:s}=e,c;try{c=a.readdirSync(t,{withFileTypes:!0})}catch(e){return i.push({path:t,error:e}),s.warn(L({code:`SKILL_DIST_CLEANUP_DIRECTORY_READ_FAILED`,title:`Skill dist cleanup could not read a directory`,operation:`read`,targetKind:`skill dist directory`,path:t,error:e})),!1}let l=!1;for(let a of c){let s=o.join(t,a.name);if(a.isDirectory()){this.collectCleanupPlan(e,s,n,r,i)?r.push(s):l=!0;continue}if(!a.isFile()){l=!0;continue}if(this.shouldRetainCompiledSkillFile(a.name)){l=!0;continue}n.push(s)}return!l}shouldRetainCompiledSkillFile(e){return e.endsWith(`.mdx`)&&!R(e)}collect(e){return{}}};const zt=/export\s+default\s*\{([\s\S]*?)\}/u,Bt=/description\s*:\s*['"`]([^'"`]+)['"`]/u,Vt=/name\s*:\s*['"`]([^'"`]+)['"`]/u,Ht=/displayName\s*:\s*['"`]([^'"`]+)['"`]/u,Ut=/keywords\s*:\s*\[([^\]]+)\]/u,Wt=/author\s*:\s*['"`]([^'"`]+)['"`]/u,Gt=/version\s*:\s*['"`]([^'"`]+)['"`]/u;function Kt(e){let t={},n=zt.exec(e);if(n?.[1]==null)return t;let r=n[1],i=Bt.exec(r);i?.[1]!=null&&(t.description=i[1]);let a=Vt.exec(r);a?.[1]!=null&&(t.name=a[1]);let o=Ht.exec(r);o?.[1]!=null&&(t.displayName=o[1]);let s=Ut.exec(r);s?.[1]!=null&&(t.keywords=s[1].split(`,`).map(e=>e.trim().replaceAll(/['"]/gu,``)).filter(e=>e.length>0));let c=Wt.exec(r);c?.[1]!=null&&(t.author=c[1]);let l=Gt.exec(r);return l?.[1]!=null&&(t.version=l[1]),t}function qt(...e){let t={};for(let n of e)if(n!=null)for(let[e,r]of Object.entries(n))r!==void 0&&(t[e]=r);return t}const Jt={".ts":`text/typescript`,".tsx":`text/typescript`,".js":`text/javascript`,".jsx":`text/javascript`,".json":`application/json`,".py":`text/x-python`,".java":`text/x-java`,".kt":`text/x-kotlin`,".go":`text/x-go`,".rs":`text/x-rust`,".c":`text/x-c`,".cpp":`text/x-c++`,".cs":`text/x-csharp`,".rb":`text/x-ruby`,".php":`text/x-php`,".swift":`text/x-swift`,".scala":`text/x-scala`,".sql":`application/sql`,".xml":`application/xml`,".yaml":`text/yaml`,".yml":`text/yaml`,".toml":`text/toml`,".csv":`text/csv`,".graphql":`application/graphql`,".txt":`text/plain`,".pdf":`application/pdf`,".docx":`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,".xlsx":`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,".html":`text/html`,".css":`text/css`,".svg":`image/svg+xml`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".gif":`image/gif`,".webp":`image/webp`,".ico":`image/x-icon`,".bmp":`image/bmp`},Yt=new Set(`.png,.jpg,.jpeg,.gif,.webp,.ico,.bmp,.tiff,.svg,.exe,.dll,.so,.dylib,.bin,.wasm,.class,.jar,.war,.pyd,.pyc,.pyo,.zip,.tar,.gz,.bz2,.7z,.rar,.ttf,.otf,.woff,.woff2,.eot,.db,.sqlite,.sqlite3,.pdf,.docx,.doc,.xlsx,.xls,.pptx,.ppt,.odt,.ods,.odp`.split(`,`));function Xt(e){return Yt.has(e.toLowerCase())}function Zt(e){return Jt[e.toLowerCase()]}function Qt(...e){return H.join(...e).replaceAll(`\\`,`/`)}var $t=class{ctx;constructor(e){this.ctx=e}async processDirectory(e,t,n){let r=t?`${t}/${e.name}`:e.name;return this.scanSkillDirectoryAsync(n,r)}async processFile(e,t,n){let r=t?`${t}/${e.name}`:e.name;if(this.ctx.scanMode===`distChildDocs`){if(t===``&&e.name===`skill.mdx`||R(e.name)||!e.name.endsWith(`.mdx`))return{childDocs:[],resources:[]};let i=await this.processChildDoc(r,n);return{childDocs:i?[i]:[],resources:[]}}if(t===``&&e.name===`mcp.json`||R(e.name)||e.name.endsWith(`.mdx`))return{childDocs:[],resources:[]};let i=this.processResourceFile(e.name,r,n);return{childDocs:[],resources:i?[i]:[]}}async processChildDoc(e,t){try{let n=this.ctx.fs.readFileSync(t,`utf8`),r=F(n),i=ve((await v(n,{globalScope:this.ctx.globalScope,extractMetadata:!0,basePath:H.dirname(t),filePath:t})).content);return M(i,t),{type:A.SkillChildDoc,content:i,length:i.length,filePathKind:w.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},relativePath:e,dir:{pathKind:w.Relative,path:e,basePath:this.ctx.skillDir,getDirectoryName:()=>H.dirname(e),getAbsolutePath:()=>t}}}catch(n){throw this.ctx.logger.error(N({code:`SKILL_CHILD_DOC_COMPILE_FAILED`,title:`Failed to compile skill child doc`,diagnosticText:I(n,{operation:`Failed to compile skill child doc.`,promptKind:`skill-child-doc`,logicalName:`${H.basename(this.ctx.skillDir)}/${e.replace(/\.mdx$/u,``)}`,distPath:t,srcPath:ye(H,t,{distRootDir:this.ctx.skillDir,srcRootDir:this.ctx.sourceSkillDir})}),details:{skillDir:this.ctx.skillDir,relativePath:e,filePath:t}})),n}}processResourceFile(e,t,n){let r=H.extname(e);try{let{content:i,encoding:a,length:o}=this.readFileContent(n,r),s=Zt(r);return{type:A.SkillResource,extension:r,fileName:e,relativePath:t,sourcePath:n,content:i,encoding:a,length:o,...s!=null&&{mimeType:s}}}catch(r){return this.ctx.logger.warn(L({code:`SKILL_RESOURCE_READ_FAILED`,title:`Failed to read skill resource file`,operation:`read`,targetKind:`skill resource file`,path:n,error:r,details:{relativePath:t,fileName:e,skillDir:this.ctx.skillDir}})),null}}readFileContent(e,t){if(Xt(t)){let t=this.ctx.fs.readFileSync(e);return{content:t.toString(`base64`),encoding:`base64`,length:t.length}}let n=this.ctx.fs.readFileSync(e,`utf8`);return{content:n,encoding:`text`,length:W.from(n,`utf8`).length}}async scanSkillDirectoryAsync(e,t=``){let n=[],r=[],i;try{i=this.ctx.fs.readdirSync(e,{withFileTypes:!0})}catch(t){return this.ctx.logger.warn(L({code:`SKILL_DIRECTORY_SCAN_FAILED`,title:`Failed to scan skill directory`,operation:`scan`,targetKind:`skill directory`,path:e,error:t,details:{skillDir:this.ctx.skillDir,scanMode:this.ctx.scanMode}})),{childDocs:n,resources:r}}for(let a of i){let i=Qt(e,a.name);if(a.isDirectory()){let e=await this.processDirectory(a,t,i);n.push(...e.childDocs),r.push(...e.resources);continue}if(!a.isFile())continue;let o=await this.processFile(a,t,i);n.push(...o.childDocs),r.push(...o.resources)}return{childDocs:n,resources:r}}};function en(e,t,n,r=``){let i=[],a=r===``?e:Qt(e,r),o;try{o=t.readdirSync(a,{withFileTypes:!0})}catch(e){return n.warn(L({code:`SKILL_SOURCE_CHILD_SCAN_FAILED`,title:`Failed to scan skill source child docs`,operation:`scan`,targetKind:`skill source child doc directory`,path:a,error:e})),i}for(let a of o){let o=r?`${r}/${a.name}`:a.name;if(a.isDirectory()){i.push(...en(e,t,n,o));continue}!a.isFile()||!R(a.name)||r===``&&a.name===`skill.src.mdx`||i.push(o.replace(/\.src\.mdx$/u,`.mdx`))}return i}function tn(e,t,n,r,i){if(r.existsSync(t))for(let a of en(t,r,i)){let i=H.join(n,a);if(!r.existsSync(i))throw new ne({kind:`skill child doc`,name:`${e}/${a}`,sourcePath:H.join(t,a.replace(/\.mdx$/u,`.src.mdx`)),expectedDistPath:i})}}function nn(e,t,n){let r=H.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(re({code:`SKILL_MCP_CONFIG_NOT_FILE`,title:`Skill MCP config path is not a file`,path:r,expectedKind:`mcp.json file`,actualState:`path exists but is not a regular file`,details:{skillDir:e}}));return}try{let i=t.readFileSync(r,`utf8`),a=JSON.parse(i);if(a.mcpServers==null||typeof a.mcpServers!=`object`){n.warn(D({code:`SKILL_MCP_CONFIG_INVALID`,title:`Skill MCP config is missing mcpServers`,reason:k(`The skill MCP config at "${r}" does not contain a top-level mcpServers object.`),configPath:r,exactFix:k("Add a top-level `mcpServers` object to mcp.json before retrying tnmsc."),details:{skillDir:e}}));return}return{type:A.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(D({code:`SKILL_MCP_CONFIG_PARSE_FAILED`,title:`Failed to parse skill MCP config`,reason:k(`tnmsc could not parse the MCP config file at "${r}".`,`Underlying error: ${t instanceof Error?t.message:String(t)}`),configPath:r,exactFix:k(`Fix the JSON syntax in mcp.json and rerun tnmsc.`),details:{skillDir:e,errorMessage:t instanceof Error?t.message:String(t)}}));return}}}async function rn(e,t,n,r,i,a,o,s=[],c=[],l,u){let{logger:d,globalScope:f,fs:p}=a,m=H.join(i,`skill.mdx`),g=e,_,y;if(p.existsSync(m)){g=p.readFileSync(m,`utf8`),_=F(g);let t=await v(g,{globalScope:f,extractMetadata:!0,basePath:i,filePath:m});e=ve(t.content),M(e,m),y=t.metadata.fields}let b=qt(Kt(g),u,y),x=_?.yamlFrontMatter?.description??b?.description;if(x==null||x.trim().length===0)throw d.error(pe({code:`SKILL_VALIDATION_FAILED`,title:`Skill description is required`,rootCause:k(`The skill "${n}" does not provide a non-empty description in its compiled metadata or front matter.`),exactFix:k(`Add a non-empty description field to the skill front matter or exported metadata and rebuild the skill.`),possibleFixes:[k("Set `description` in `SKILL.md` front matter."),k(`If you export metadata from code, ensure the exported description is non-empty.`)],details:{skill:n,skillDir:r,yamlDescription:_?.yamlFrontMatter?.description,exportDescription:b?.description}})),Error(`Skill "${n}" validation failed: description is required and cannot be empty`);let S={...b,..._?.yamlFrontMatter??{},name:n,description:x},C=h(S,m);if(!C.valid)throw Error(C.errors.join(`
|
|
14
|
+
`));return{type:A.Skill,content:e,length:e.length,filePathKind:w.Relative,yamlFrontMatter:S,markdownAst:_?.markdownAst,markdownContents:_?.markdownContents??[],dir:{pathKind:w.Relative,path:n,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>H.join(r,n)},..._?.rawFrontMatter!=null&&{rawFrontMatter:_.rawFrontMatter},...o!=null&&{mcpConfig:o},...s!=null&&s.length>0&&{childDocs:s},...c!=null&&c.length>0&&{resources:c},...l!=null&&{seriName:l}}}var an=class extends S{constructor(){super(`SkillInputCapability`)}readMcpConfig(e,t,n){return nn(e,t,n)}async scanSkillDirectory(e,t,n,r=``,i=`srcResources`,a,o){return new $t({fs:t,logger:n,skillDir:e,scanMode:i,...a!=null&&{globalScope:a},...o!=null&&{sourceSkillDir:o}}).scanSkillDirectoryAsync(e,r)}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.skills.src,o),c=this.resolveAindexPath(t.aindex.skills.dist,o),l=[],u=E(r,i,n,a),d=new Map,f=async e=>{let t=d.get(e);if(t!=null)return t;let o=i.join(s,e),l=i.join(c,e),u=r.existsSync(l)?(await this.scanSkillDirectory(l,r,n,``,`distChildDocs`,a,o)).childDocs:[],f=r.existsSync(o)?(await this.scanSkillDirectory(o,r,n,``,`srcResources`,a)).resources:[],p=nn(o,r,n);tn(e,o,l,r,n);let m={childDocs:u,resources:f,...p!=null&&{mcpConfig:p}};return d.set(e,m),m},{prompts:p,errors:m}=await u.readDirectoryStructure(s,c,{kind:A.Skill,entryFileName:`skill`,localeExtensions:j,isDirectoryStructure:!0,createPrompt:async(t,n,r,a)=>{let o=i.join(c,r),{childDocs:s,resources:l,mcpConfig:u}=await f(r);return rn(t,n,r,c,o,e,u,s,l,void 0,a)}});for(let e of m)n.warn(L({code:`SKILL_PROMPT_READ_FAILED`,title:`Failed to read skill prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`skill prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(m.length>0)throw Error(m.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
15
|
+
`));for(let e of p){let t=e.dist?.prompt;t!=null&&l.push(t)}return{skills:l}}},on=class e extends S{static projectConfigFileName=`project.json5`;constructor(){super(`AindexInputCapability`)}loadProjectConfig(t,n,r,i,a,o){let s=a.join(n,r,t,e.projectConfigFileName);if(i.existsSync(s))try{let n=i.readFileSync(s,`utf8`);try{return De.parse(n)}catch(n){o.warn(D({code:`AINDEX_PROJECT_JSON5_INVALID`,title:`Failed to parse ${e.projectConfigFileName} for ${t}`,reason:k(`tnmsc could not parse the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:k(`Fix the JSON5 syntax in ${e.projectConfigFileName} and rerun tnmsc.`),details:{projectName:t,errorMessage:n instanceof Error?n.message:String(n)}}));return}}catch(n){o.warn(D({code:`AINDEX_PROJECT_JSON5_READ_FAILED`,title:`Failed to load ${e.projectConfigFileName} for ${t}`,reason:k(`tnmsc could not read the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:k(`Ensure ${e.projectConfigFileName} exists, is readable, and contains valid JSON5.`),details:{projectName:t,errorMessage:n instanceof Error?n.message:String(n)}}));return}}collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i}=e,{workspaceDir:a,aindexDir:o}=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.app.dist,o),c=i.basename(o),l=[];if(r.existsSync(s)&&r.statSync(s).isDirectory())try{let e=r.readdirSync(s,{withFileTypes:!0});for(let s of e)if(s.isDirectory()){let e=s.name===c,u=this.loadProjectConfig(s.name,o,t.aindex.app.src,r,i,n);l.push({name:s.name,...e&&{isPromptSourceProject:!0},...u!=null&&{projectConfig:u},dirFromWorkspacePath:{pathKind:w.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(L({code:`AINDEX_PROJECT_DIRECTORY_SCAN_FAILED`,title:`Failed to scan aindex projects directory`,operation:`scan`,targetKind:`aindex projects directory`,path:s,error:e}))}if(l.length===0&&r.existsSync(a)&&r.statSync(a).isDirectory()){n.debug(`no projects in dist/app/, falling back to workspace scan`,{workspaceDir:a});try{let e=r.readdirSync(a,{withFileTypes:!0});for(let s of e)if(s.isDirectory()&&!s.name.startsWith(`.`)){let e=s.name===c,u=this.loadProjectConfig(s.name,o,t.aindex.app.src,r,i,n);l.push({name:s.name,...e&&{isPromptSourceProject:!0},...u!=null&&{projectConfig:u},dirFromWorkspacePath:{pathKind:w.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(L({code:`WORKSPACE_DIRECTORY_SCAN_FAILED`,title:`Failed to scan workspace directory`,operation:`scan`,targetKind:`workspace directory`,path:a,error:e}))}}return{workspace:{directory:{pathKind:w.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:l}}}},sn=class extends S{constructor(){super(`CommandInputCapability`)}createCommandPrompt(e,t,n,r,i,o){let{path:s}=i,c=n.replaceAll(`\\`,`/`),l=c.indexOf(`/`),u=l===-1?void 0:c.slice(0,l),d=(l===-1?c:c.slice(l+1)).replace(/\.mdx$/,``),f=d.indexOf(`_`),p=u??(f===-1?void 0:d.slice(0,Math.max(0,f))),m=u!=null||f===-1?d:d.slice(Math.max(0,f+1)),h=s.join(r,`${n}.mdx`),g=`${n}.mdx`,_=o,v={type:A.Command,content:e,length:e.length,filePathKind:w.Relative,dir:{pathKind:w.Relative,path:g,basePath:r,getDirectoryName:()=>g.replace(/\.mdx$/,``),getAbsolutePath:()=>h},...p!=null&&{commandPrefix:p},commandName:m};if(_==null)return v;let y=a(_,h);if(!y.valid)throw Error(y.errors.join(`
|
|
16
|
+
`));return Object.assign(v,{yamlFrontMatter:_}),_.seriName!=null&&Object.assign(v,{seriName:_.seriName}),_.scope===`global`&&Object.assign(v,{globalOnly:!0}),v}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.commands.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.commands.dist,o.aindexDir);n.debug(`CommandInputCapability collecting`,{srcDir:s,distDir:c,aindexDir:o.aindexDir});let{prompts:l,errors:u}=await E(i,r,n,a).readFlatFiles(s,c,{kind:A.Command,localeExtensions:j,isDirectoryStructure:!1,createPrompt:(t,n,r,i)=>this.createCommandPrompt(t,n,r,c,e,i)});n.debug(`CommandInputCapability read complete`,{commandCount:l.length,errorCount:u.length});for(let e of u)n.warn(L({code:`COMMAND_PROMPT_READ_FAILED`,title:`Failed to read command prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`command prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(u.length>0)throw Error(u.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
17
|
+
`));let d=[];for(let e of l){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;d.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`CommandInputCapability flattened commands`,{count:d.length,commands:d.map(e=>e.commandName)}),{commands:d}}},cn=class extends S{constructor(){super(`EditorConfigInputCapability`)}collect(t){let{userConfigOptions:n,fs:r}=t,{workspaceDir:i,aindexDir:a}=this.resolveBasePaths(n),o=[],s=te(e.EditorConfig,`.editorconfig`,a,r,{command:t.runtimeCommand,workspaceDir:i});return s!=null&&o.push(s),{editorConfigFiles:o}}},ln=class extends S{constructor(){super(`GitExcludeInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=ee(n,ge,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(r))return this.log.debug({action:`collect`,message:`File not found`,path:r}),{};let i=e.fs.readFileSync(r,`utf8`);return i.length===0?(this.log.debug({action:`collect`,message:`File is empty`,path:r}),{}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:r,length:i.length}),{shadowGitExclude:i})}},un=class extends S{constructor(){super(`GitIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=ee(n,u,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(r))return this.log.debug({action:`collect`,message:`File not found`,path:r}),{};let i=e.fs.readFileSync(r,`utf8`);return i.length===0?(this.log.debug({action:`collect`,message:`File is empty`,path:r}),{}):(this.log.debug({action:`collect`,message:`Loaded file content`,path:r,length:i.length}),{globalGitIgnore:i})}},dn=class extends S{constructor(){super(`GlobalMemoryInputCapability`)}async collect(e){let{userConfigOptions:t,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.globalPrompt.dist,o);if(!r.existsSync(s))return this.log.warn(re({code:`GLOBAL_MEMORY_PROMPT_MISSING`,title:`Global memory prompt is missing`,path:s,expectedKind:`compiled global memory prompt file`,actualState:`path does not exist`})),{};if(!r.statSync(s).isFile())return this.log.warn(re({code:`GLOBAL_MEMORY_PROMPT_NOT_FILE`,title:`Global memory prompt path is not a file`,path:s,expectedKind:`compiled global memory prompt file`,actualState:`path exists but is not a regular file`})),{};let c=r.readFileSync(s,`utf8`),l=F(c),u;try{u=(await v(c,{...a!=null&&{globalScope:a},extractMetadata:!0,basePath:i.dirname(s),filePath:s})).content,M(u,s)}catch(e){throw e instanceof z&&(this.log.error(N({code:`GLOBAL_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile global memory prompt`,diagnosticText:I(e,{operation:`Failed to compile global memory prompt.`,promptKind:`global-memory`,logicalName:`global-memory`,distPath:s}),details:{promptKind:`global-memory`,distPath:s}})),e instanceof n&&this.log.error(D({code:`GLOBAL_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Global memory prompt references missing config variables`,reason:k("The global memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:k("Add the missing variables to `~/.aindex/.tnmsc.json` and rerun tnmsc."),possibleFixes:[k("If you reference `{profile.name}`, define `profile.name` in the config file.")],details:{promptPath:s,errorMessage:e.message}})),B.exit(1)),e}return this.log.debug({action:`collect`,path:s,contentLength:u.length}),{globalMemory:{type:A.GlobalMemory,content:u,length:u.length,filePathKind:w.Relative,...l.rawFrontMatter!=null&&{rawFrontMatter:l.rawFrontMatter},markdownAst:l.markdownAst,markdownContents:l.markdownContents,dir:{pathKind:w.Relative,path:i.basename(s),basePath:i.dirname(s),getDirectoryName:()=>i.basename(s),getAbsolutePath:()=>s},parentDirectoryPath:{type:_.UserHome,directory:{pathKind:w.Relative,path:``,basePath:U.homedir(),getDirectoryName:()=>i.basename(U.homedir()),getAbsolutePath:()=>U.homedir()}}}}}},fn=class extends S{constructor(){super(`JetBrainsConfigInputCapability`)}collect(t){let{userConfigOptions:n,fs:r}=t,{workspaceDir:i,aindexDir:a}=this.resolveBasePaths(n),o=[`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`],s=[];for(let n of o){let o=te(e.IntellijIDEA,n,a,r,{command:t.runtimeCommand,workspaceDir:i});o!=null&&s.push(o)}return{jetbrainsConfigFiles:s}}};const pn=`agt.mdx`,mn=[`node_modules`,`.git`];var hn=class extends S{constructor(){super(`ProjectPromptInputCapability`,[`AindexInputCapability`])}async collect(e){let{dependencyContext:t,fs:n,userConfigOptions:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(r),s=this.resolveAindexPath(r.aindex.app.dist,o),c=this.resolveAindexPath(r.aindex.workspacePrompt.dist,o),l=t.workspace;if(l==null)return this.log.info(`No workspace found in dependency context, skipping project prompt enhancement`),{};let u=l.projects??[],d=await Promise.all(u.map(async t=>{let r=t.name;if(r==null||t.isWorkspaceRootProject===!0)return t;let o=i.join(s,r);if(!n.existsSync(o)||!n.statSync(o).isDirectory())return t;let c=t.dirFromWorkspacePath?.getAbsolutePath(),l=await this.readRootMemoryPrompt(e,o,a),u=c==null?[]:await this.scanChildMemoryPrompts(e,o,c,a);return{...t,...l!=null&&{rootMemoryPrompt:l},...u.length>0&&{childMemoryPrompts:u}}})),f=await this.readWorkspaceRootProjectPrompt(e,c,a,this.resolveWorkspaceRootProjectConfig(u));return{workspace:{directory:l.directory,projects:f==null?d:[...d,f]}}}async readWorkspaceRootProjectPrompt(e,t,r,i){let{fs:a,path:o,logger:s}=e;if(!(!a.existsSync(t)||!a.statSync(t).isFile()))try{let e=a.readFileSync(t,`utf8`),c=F(e),l;try{let{content:n}=await v(e,{globalScope:r,extractMetadata:!0,basePath:o.dirname(t),filePath:t});l=n,M(l,t)}catch(e){throw e instanceof z&&(s.error(N({code:`WORKSPACE_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile workspace root memory prompt`,diagnosticText:I(e,{operation:`Failed to compile workspace root memory prompt.`,promptKind:`workspace-root-memory`,logicalName:t,distPath:t}),details:{promptKind:`workspace-root-memory`,distPath:t}})),e instanceof n&&s.error(D({code:`WORKSPACE_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Workspace root memory prompt references missing config variables`,reason:k("The workspace root memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:k("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:t,errorMessage:e.message}})),B.exit(1)),e}let u={type:A.ProjectRootMemory,content:l,length:l.length,filePathKind:w.Relative,...c.yamlFrontMatter!=null&&{yamlFrontMatter:c.yamlFrontMatter},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:w.Root,path:``,getDirectoryName:()=>``}};return{name:we,isWorkspaceRootProject:!0,...i!=null&&{projectConfig:i},rootMemoryPrompt:u}}catch(e){s.error(L({code:`WORKSPACE_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read workspace root memory prompt`,operation:`read`,targetKind:`workspace root memory prompt`,path:t,error:e}));return}}resolveWorkspaceRootProjectConfig(e){let t=e.filter(e=>e.isWorkspaceRootProject!==!0);return t.find(e=>e.isPromptSourceProject===!0)?.projectConfig??t[0]?.projectConfig}async readRootMemoryPrompt(e,t,r){let{fs:i,path:a,logger:o}=e,s=a.join(t,pn);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=F(e),c;try{let{content:n}=await v(e,{globalScope:r,extractMetadata:!0,basePath:t,filePath:s});c=n,M(c,s)}catch(e){throw e instanceof z&&(o.error(N({code:`PROJECT_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project root memory prompt`,diagnosticText:I(e,{operation:`Failed to compile project root memory prompt.`,promptKind:`project-root-memory`,logicalName:s,distPath:s}),details:{promptKind:`project-root-memory`,distPath:s}})),e instanceof n&&o.error(D({code:`PROJECT_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project root memory prompt references missing config variables`,reason:k("The project root memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:k("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:s,errorMessage:e.message}})),B.exit(1)),e}return{type:A.ProjectRootMemory,content:c,length:c.length,filePathKind:w.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:w.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(L({code:`PROJECT_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read project root memory prompt`,operation:`read`,targetKind:`project root memory prompt`,path:s,error:e}));return}}async scanChildMemoryPrompts(e,t,n,r){let{logger:i}=e,a=[];try{await this.scanDirectoryRecursive(e,t,t,n,a,r)}catch(e){i.error(L({code:`PROJECT_CHILD_MEMORY_SCAN_FAILED`,title:`Failed to scan project child memory prompts`,operation:`scan`,targetKind:`project child memory prompt directory`,path:t,error:e}))}return a}async scanDirectoryRecursive(e,t,n,r,i,a){let{fs:o,path:s}=e,c=o.readdirSync(n,{withFileTypes:!0});for(let l of c){if(!l.isDirectory()||mn.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,pn);if(o.existsSync(u)&&o.statSync(u).isFile()){let n=await this.readChildMemoryPrompt(e,t,c,r,a);n!=null&&i.push(n)}await this.scanDirectoryRecursive(e,t,c,r,i,a)}}async readChildMemoryPrompt(e,t,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,pn);try{let e=o.readFileSync(l,`utf8`),u=F(e),d;try{let{content:t}=await v(e,{globalScope:a,extractMetadata:!0,basePath:r,filePath:l});d=t,M(d,l)}catch(e){throw e instanceof z&&(c.error(N({code:`PROJECT_CHILD_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project child memory prompt`,diagnosticText:I(e,{operation:`Failed to compile project child memory prompt.`,promptKind:`project-child-memory`,logicalName:l,distPath:l}),details:{promptKind:`project-child-memory`,distPath:l}})),e instanceof n&&c.error(D({code:`PROJECT_CHILD_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project child memory prompt references missing config variables`,reason:k("The project child memory prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:k("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:l,errorMessage:e.message}})),B.exit(1)),e}let f=s.relative(t,r),p=s.join(i,f),m=s.basename(r);return{type:A.ProjectChildrenMemory,content:d,length:d.length,filePathKind:w.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:w.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:w.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(L({code:`PROJECT_CHILD_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read project child memory prompt`,operation:`read`,targetKind:`project child memory prompt`,path:l,error:e}));return}}};const gn=Object.entries(Te);var _n=class extends S{constructor(){super(`ReadmeMdInputCapability`,[`AindexInputCapability`])}async collect(e){let{userConfigOptions:t,logger:n,fs:r,path:i,globalScope:a}=e,{workspaceDir:o,aindexDir:s}=this.resolveBasePaths(t),c=this.resolveAindexPath(t.aindex.app.dist,s),l=[];if(!r.existsSync(c)||!r.statSync(c).isDirectory())return n.debug(`aindex projects directory does not exist`,{path:c}),{readmePrompts:l};try{let t=r.readdirSync(c,{withFileTypes:!0});for(let n of t){if(!n.isDirectory())continue;let t=n.name,r=i.join(c,t);await this.collectReadmeFiles(e,r,t,o,``,l,a)}}catch(e){n.error(L({code:`README_PROJECT_SCAN_FAILED`,title:`Failed to scan aindex projects for readme prompts`,operation:`scan`,targetKind:`aindex project directory`,path:c,error:e}))}return{readmePrompts:l}}async collectReadmeFiles(e,t,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``;for(let[e,{src:f}]of gn){let p=l.join(t,f);if(!(!c.existsSync(p)||!c.statSync(p).isFile()))try{let m=c.readFileSync(p,`utf8`),h;try{let{content:e}=await v(m,{...s!=null&&{globalScope:s},extractMetadata:!0,basePath:t,filePath:p});h=e,M(h,p)}catch(t){throw t instanceof z&&(u.error(N({code:`README_PROMPT_COMPILE_FAILED`,title:`Failed to compile readme-family prompt`,diagnosticText:I(t,{operation:`Failed to compile readme-family prompt.`,promptKind:`readme-family`,logicalName:`${r}/${f}`,distPath:p}),details:{promptKind:`readme-family`,distPath:p,projectName:r,fileKind:e}})),t instanceof n&&u.error(D({code:`README_SCOPE_VARIABLES_MISSING`,title:`Readme-family prompt references missing config variables`,reason:k("The readme-family prompt uses scope variables that are not defined in `~/.aindex/.tnmsc.json`."),configPath:`~/.aindex/.tnmsc.json`,exactFix:k("Define the missing variables in `~/.aindex/.tnmsc.json` and rerun tnmsc."),details:{promptPath:p,errorMessage:t.message}})),B.exit(1)),t}let g=d?r:l.join(r,a),_={pathKind:w.Relative,path:g,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,g)},y={pathKind:w.Relative,path:l.dirname(p),basePath:i,getDirectoryName:()=>l.basename(l.dirname(p)),getAbsolutePath:()=>l.dirname(p)};o.push({type:A.Readme,content:h,length:h.length,filePathKind:w.Relative,projectName:r,targetDir:_,isRoot:d,fileKind:e,markdownContents:[],dir:y})}catch(t){u.warn(L({code:`README_PROMPT_READ_FAILED`,title:`Failed to read readme-family file`,operation:`read`,targetKind:`readme-family prompt file`,path:p,error:t,details:{fileKind:e}}))}}try{let n=c.readdirSync(t,{withFileTypes:!0});for(let c of n)if(c.isDirectory()){let n=d?c.name:l.join(a,c.name),u=l.join(t,c.name);await this.collectReadmeFiles(e,u,r,i,n,o,s)}}catch(e){u.warn(L({code:`README_DIRECTORY_SCAN_FAILED`,title:`Failed to scan readme-family directory`,operation:`scan`,targetKind:`readme-family directory`,path:t,error:e}))}}},vn=class extends S{constructor(){super(`RuleInputCapability`)}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:a,globalScope:o}=e,s=this.resolveBasePaths(t),c=this.resolveAindexPath(t.aindex.rules.src,s.aindexDir),l=this.resolveAindexPath(t.aindex.rules.dist,s.aindexDir),{prompts:u,errors:d}=await E(a,r,n,o).readFlatFiles(c,l,{kind:A.Rule,localeExtensions:j,isDirectoryStructure:!1,createPrompt:async(e,t,n,a)=>{let o=a,s=r.join(l,`${n}.mdx`);if(o!=null){let e=i(o,s);if(!e.valid)throw Error(e.errors.join(`
|
|
18
|
+
`))}let c=o?.globs??[],u=o?.scope??`project`,d=o?.seriName,f=n.replaceAll(`\\`,`/`),p=f.includes(`/`)?f.split(`/`)[0]??``:``,m=f.split(`/`).pop()??f,h={type:A.Rule,content:e,length:e.length,filePathKind:w.Relative,dir:{pathKind:w.Relative,path:`${n}.mdx`,basePath:l,getDirectoryName:()=>m,getAbsolutePath:()=>s},prefix:p,ruleName:m,globs:c,scope:u,markdownContents:[]};return o!=null&&Object.assign(h,{yamlFrontMatter:o}),d!=null&&Object.assign(h,{seriName:d}),h}});for(let e of d)n.warn(L({code:`RULE_PROMPT_READ_FAILED`,title:`Failed to read rule prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`rule prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(d.length>0)throw Error(d.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
19
|
+
`));return{rules:u.map(e=>e.dist?.prompt).filter(e=>e!=null)}}},yn=class extends S{constructor(){super(`AIAgentIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=[];for(let i of d){let a=ee(n,i,{command:e.runtimeCommand,workspaceDir:t});if(!e.fs.existsSync(a)){this.log.debug({action:`collect`,message:`Ignore file not found`,path:a});continue}let o=e.fs.readFileSync(a,`utf8`);if(o.length===0){this.log.debug({action:`collect`,message:`Ignore file is empty`,path:a});continue}r.push({fileName:i,content:o,sourcePath:a}),this.log.debug({action:`collect`,message:`Loaded ignore file`,path:a,fileName:i})}return r.length===0?{}:{aiAgentIgnoreConfigFiles:r}}},bn=class extends S{constructor(){super(`SubAgentInputCapability`)}createSubAgentPrompt(e,t,n,r,i,a){let{path:o}=i,s=n.replaceAll(`\\`,`/`),c=s.indexOf(`/`),l=c===-1?void 0:s.slice(0,c),u=(c===-1?s:s.slice(c+1)).replace(/\.mdx$/,``),d=u.indexOf(`_`),f=l??(d===-1?void 0:u.slice(0,Math.max(0,d))),p=l!=null||d===-1?u:u.slice(Math.max(0,d+1)),m=o.join(r,`${n}.mdx`),h=`${n}.mdx`,g=a,_={type:A.SubAgent,content:e,length:e.length,filePathKind:w.Relative,dir:{pathKind:w.Relative,path:h,basePath:r,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...f!=null&&{agentPrefix:f},agentName:p};if(g==null)return _;let v=de(g,m);if(!v.valid)throw Error(v.errors.join(`
|
|
20
|
+
`));return Object.assign(_,{yamlFrontMatter:g}),g.seriName!=null&&Object.assign(_,{seriName:g.seriName}),_}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.subAgents.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.subAgents.dist,o.aindexDir);n.debug(`SubAgentInputCapability collecting`,{srcDir:s,distDir:c,aindexDir:o.aindexDir});let{prompts:l,errors:u}=await E(i,r,n,a).readFlatFiles(s,c,{kind:A.SubAgent,localeExtensions:j,isDirectoryStructure:!1,createPrompt:(t,n,r,i)=>this.createSubAgentPrompt(t,n,r,c,e,i)});n.debug(`SubAgentInputCapability read complete`,{subAgentCount:l.length,errorCount:u.length});for(let e of u)n.warn(L({code:`SUBAGENT_PROMPT_READ_FAILED`,title:`Failed to read sub-agent prompt`,operation:e.phase===`scan`?`scan`:`read`,targetKind:`sub-agent prompt`,path:e.path,error:e.error,details:{phase:e.phase}}));if(u.length>0)throw Error(u.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
|
|
21
|
+
`));let d=[];for(let e of l){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;d.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`SubAgentInputCapability flattened subAgents`,{count:d.length,agents:d.map(e=>e.agentName)}),{subAgents:d}}},xn=class extends S{constructor(){super(`VSCodeConfigInputCapability`)}collect(t){let{userConfigOptions:n,fs:r}=t,{workspaceDir:i,aindexDir:a}=this.resolveBasePaths(n),o=[`.vscode/settings.json`,`.vscode/extensions.json`],s=[];for(let n of o){let o=te(e.VSCode,n,a,r,{command:t.runtimeCommand,workspaceDir:i});o!=null&&s.push(o)}return{vscodeConfigFiles:s}}},Sn=class extends S{constructor(){super(`WorkspaceInputCapability`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,aindexDir:r}=this.resolveBasePaths(t);return{workspace:{directory:{pathKind:w.Absolute,path:n,getDirectoryName:()=>H.basename(n)},projects:[]},aindexDir:r}}};function Cn(){return`2026.10317.12338`}const $=`tnmsc`;`
|
|
22
|
+
${$} v${Cn()} - Memory Sync CLI
|
|
23
|
+
|
|
24
|
+
Synchronize AI memory and configuration files across projects.
|
|
25
|
+
|
|
26
|
+
USAGE:
|
|
27
|
+
${$} Run the sync pipeline (default)
|
|
28
|
+
${$} help Show this help message
|
|
29
|
+
${$} version Show version information
|
|
30
|
+
${$} init Deprecated; no longer initializes aindex
|
|
31
|
+
${$} dry-run Preview what would be written
|
|
32
|
+
${$} clean Remove all generated files
|
|
33
|
+
${$} clean --dry-run Preview what would be cleaned
|
|
34
|
+
${$} config key=value Set configuration value
|
|
35
|
+
|
|
36
|
+
SUBCOMMANDS:
|
|
37
|
+
help Show this help message
|
|
38
|
+
version Show version information
|
|
39
|
+
init Deprecated; keep public target-relative definitions manually
|
|
40
|
+
dry-run Preview changes without writing files
|
|
41
|
+
clean Remove all generated output files and directories
|
|
42
|
+
config Set configuration values in global config file (~/.aindex/.tnmsc.json)
|
|
43
|
+
|
|
44
|
+
ALIASES:
|
|
45
|
+
${$} --help, ${$} -h Same as '${$} help'
|
|
46
|
+
${$} --version, ${$} -v Same as '${$} version'
|
|
47
|
+
${$} clean -n Same as '${$} clean --dry-run'
|
|
48
|
+
${$} config key=value Set config value in global config file
|
|
49
|
+
|
|
50
|
+
LOG LEVEL OPTIONS:
|
|
51
|
+
--trace Most verbose output
|
|
52
|
+
--debug Debug information
|
|
53
|
+
--info Standard information (default)
|
|
54
|
+
--warn Warnings only
|
|
55
|
+
--error Errors only
|
|
56
|
+
|
|
57
|
+
CLEAN OPTIONS:
|
|
58
|
+
-n, --dry-run Preview cleanup without removing files
|
|
59
|
+
|
|
60
|
+
CONFIG OPTIONS:
|
|
61
|
+
key=value Set a configuration value in global config (~/.aindex/.tnmsc.json)
|
|
62
|
+
Valid keys: workspaceDir, logLevel,
|
|
63
|
+
aindex.skills.src, aindex.skills.dist,
|
|
64
|
+
aindex.commands.src, aindex.commands.dist,
|
|
65
|
+
aindex.subAgents.src, aindex.subAgents.dist,
|
|
66
|
+
aindex.rules.src, aindex.rules.dist,
|
|
67
|
+
aindex.globalPrompt.src, aindex.globalPrompt.dist,
|
|
68
|
+
aindex.workspacePrompt.src, aindex.workspacePrompt.dist,
|
|
69
|
+
aindex.app.src, aindex.app.dist,
|
|
70
|
+
aindex.ext.src, aindex.ext.dist,
|
|
71
|
+
aindex.arch.src, aindex.arch.dist
|
|
72
|
+
|
|
73
|
+
Examples:
|
|
74
|
+
${$} config workspaceDir=~/my-project
|
|
75
|
+
${$} config aindex.skills.src=skills
|
|
76
|
+
${$} config logLevel=debug
|
|
77
|
+
|
|
78
|
+
CONFIGURATION:
|
|
79
|
+
Configure via plugin.config.ts in your project root.
|
|
80
|
+
See documentation for detailed configuration options.
|
|
81
|
+
`.trim();const wn=new Set([`help`,`version`,`init`,`dry-run`,`clean`,`config`,`plugins`]),Tn=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),En=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function Dn(e){let t=[...e],n=t[0];n!=null&&On(n)&&t.shift();let r=t[0];return r!=null&&kn(r)&&t.shift(),t}function On(e){let t=[`node`,`nodejs`,`bun`,`deno`,`tsx`,`ts-node`,`npx`,`pnpx`,`yarn`,`pnpm`],n=e.toLowerCase().replaceAll(`\\`,`/`);return t.some(e=>RegExp(`(?:^|/)${e}(?:\\.exe|\\.cmd|\\.ps1)?$`,`i`).test(n)||n===e)}function kn(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}function An(e,t){if(e==null)return t;let n=En.get(e)??4;return(En.get(t)??4)<n?t:e}function jn(e){let t={subcommand:void 0,helpFlag:!1,versionFlag:!1,dryRun:!1,jsonFlag:!1,showFlag:!1,logLevel:void 0,setOption:[],unknownCommand:void 0,positional:[],unknown:[]},n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(i!=null){if(i===`--`){t.positional.push(...e.slice(r+1).filter(e=>e!=null));break}if(i.startsWith(`--`)){let n=i.split(`=`),a=n[0]??``,o=Tn.get(a);if(o!=null){t.logLevel=An(t.logLevel,o);continue}switch(a){case`--help`:t.helpFlag=!0;break;case`--version`:t.versionFlag=!0;break;case`--dry-run`:t.dryRun=!0;break;case`--json`:t.jsonFlag=!0;break;case`--show`:t.showFlag=!0;break;case`--set`:if(n.length>1){let e=n.slice(1).join(`=`),r=e.indexOf(`=`);r>0&&t.setOption.push([e.slice(0,r),e.slice(r+1)])}else{let n=e[r+1];if(n!=null){let e=n.indexOf(`=`);e>0&&(t.setOption.push([n.slice(0,e),n.slice(e+1)]),r++)}}break;default:t.unknown.push(i)}continue}if(i.startsWith(`-`)&&i.length>1){let e=i.slice(1);for(let n of e)switch(n){case`h`:t.helpFlag=!0;break;case`v`:t.versionFlag=!0;break;case`n`:t.dryRun=!0;break;case`j`:t.jsonFlag=!0;break;default:t.unknown.push(`-${n}`)}continue}if(!n){n=!0,wn.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}const Mn={workspace:{strategy:`mergeProjects`,getter:e=>e.workspace},vscodeConfigFiles:{strategy:`concat`,getter:e=>e.vscodeConfigFiles},jetbrainsConfigFiles:{strategy:`concat`,getter:e=>e.jetbrainsConfigFiles},editorConfigFiles:{strategy:`concat`,getter:e=>e.editorConfigFiles},commands:{strategy:`concat`,getter:e=>e.commands},subAgents:{strategy:`concat`,getter:e=>e.subAgents},skills:{strategy:`concat`,getter:e=>e.skills},rules:{strategy:`concat`,getter:e=>e.rules},aiAgentIgnoreConfigFiles:{strategy:`concat`,getter:e=>e.aiAgentIgnoreConfigFiles},readmePrompts:{strategy:`concat`,getter:e=>e.readmePrompts},globalMemory:{strategy:`override`,getter:e=>e.globalMemory},aindexDir:{strategy:`override`,getter:e=>e.aindexDir},globalGitIgnore:{strategy:`override`,getter:e=>e.globalGitIgnore},shadowGitExclude:{strategy:`override`,getter:e=>e.shadowGitExclude}};function Nn(e,t){return t==null?e??[]:e==null?t:[...e,...t]}function Pn(e,t){let n=new Map;for(let t of e.projects)n.set(t.name,t);for(let e of t.projects)n.set(e.name,e);return{directory:t.directory??e.directory,projects:[...n.values()]}}function Fn(e,t){return t==null?e:e==null?t:Pn(e,t)}function In(e,t,n){switch(n){case`concat`:return Nn(e,t);case`override`:return t??e;case`mergeProjects`:return Fn(e,t);default:return t??e}}function Ln(e,t){let n={};for(let[r,i]of Object.entries(Mn)){let a=In(i.getter(e),i.getter(t),i.strategy);a!=null&&(n[r]=a)}return n}function Rn(e,t,n){let r=e.dependsOn??[];if(r.length===0)return{};let i=new Set,a={};for(let e of r){if(i.has(e))continue;i.add(e);let r=t.get(e);r!=null&&(a=n(a,r))}return a}function zn(e,t){let n=new Set;for(let[e,r]of t)r>0&&n.add(e);let r=new Map;for(let t of e)if(n.has(t.name)){let e=(t.dependsOn??[]).filter(e=>n.has(e));r.set(t.name,e)}let i=new Set,a=[],o=e=>{if(a.includes(e))return a.push(e),!0;if(i.has(e))return!1;i.add(e),a.push(e);for(let t of r.get(e)??[])if(o(t))return!0;return a.pop(),!1};for(let e of n){if(o(e)){let e=a.indexOf(a.at(-1));return a.slice(e)}i.clear(),a.length=0}return[...n]}function Bn(e){let t=new Set(e.map(e=>e.name));for(let n of e){let e=n.dependsOn??[];for(let r of e)if(!t.has(r))throw new y(n.name,r)}let n=new Map;for(let t of e)n.set(t.name,t);let r=new Map;for(let t of e)r.set(t.name,0);let i=new Map;for(let t of e)i.set(t.name,[]);for(let t of e){let e=t.dependsOn??[];for(let n of e){r.set(t.name,(r.get(t.name)??0)+1);let e=i.get(n)??[];e.push(t.name),i.set(n,e)}}let a=[];for(let t of e)r.get(t.name)===0&&a.push(t.name);let o=[],s=new Map;for(let t=0;t<e.length;t++){let n=e[t];n!=null&&s.set(n.name,t)}for(;a.length>0;){let e=a.shift(),t=n.get(e);o.push(t);let c=(i.get(e)??[]).sort((e,t)=>(s.get(e)??-1)-(s.get(t)??-1));for(let e of c){let t=(r.get(e)??0)-1;r.set(e,t),t===0&&a.push(e)}}if(o.length===e.length)return o;throw new Ee(zn(e,r))}function Vn(){return[new Rt,new Lt,new Ft]}function Hn(){return[new Sn,new on,new xn,new fn,new cn,new an,new sn,new bn,new vn,new dn,new hn,new _n,new un,new ln,new yn]}function Un(e){if(e==null||e.length===0)return`execute`;let t=jn(Dn(e.filter(e=>e!=null)));if(!(t.helpFlag||t.versionFlag||t.unknownCommand!=null)){if(t.subcommand===`clean`)return`clean`;if(t.subcommand===`plugins`)return`plugins`;if(t.subcommand===`dry-run`||t.dryRun)return`dry-run`;if(t.subcommand==null)return`execute`}}async function Wn(e){let{pipelineArgs:t,userConfigOptions:n,userConfig:r,capabilities:i,includeBuiltinEffects:a=!0}=e,o=le(`InputRuntime`,n.logLevel),s=Un(t),c={logger:o,userConfigOptions:n,fs:V,path:H,glob:Pt.default},l=Bn([...a?Vn():[],...i??Hn()]),u=new ue({userConfig:r}).collect(),d=new m;d.setGlobalScope(u),o.debug(`global scope collected`,{osInfo:{platform:u.os.platform,arch:u.os.arch,shellKind:u.os.shellKind},hasProfile:Object.keys(u.profile).length>0,hasTool:Object.keys(u.tool).length>0});let f=new Map,h={};for(let e of l){let t=Rn(e,f,Ln),n={...c,dependencyContext:t,...s==null?{}:{runtimeCommand:s},globalScope:u,scopeRegistry:d},r=e;r.executeEffects!=null&&await r.executeEffects(n,!1);let i=await e.collect(n);f.set(e.name,i),h=Ln(h,i);let a=e;if(a.getRegisteredScopes!=null){let t=a.getRegisteredScopes();for(let{namespace:n,values:r}of t)d.register(n,r,p.PluginRegistered),o.debug(`input capability scope registered`,{capability:e.name,namespace:n,keys:Object.keys(r)})}}return h}function Gn(e){return`declarativeOutput`in e}function Kn(e){return`collect`in e&&!Gn(e)}const qn={version:`0.0.0`,workspaceDir:`~/project`,logLevel:`info`,aindex:{dir:`aindex`,skills:{src:`skills`,dist:`dist/skills`},commands:{src:`commands`,dist:`dist/commands`},subAgents:{src:`subagents`,dist:`dist/subagents`},rules:{src:`rules`,dist:`dist/rules`},globalPrompt:{src:`global.src.mdx`,dist:`dist/global.mdx`},workspacePrompt:{src:`workspace.src.mdx`,dist:`dist/workspace.mdx`},app:{src:`app`,dist:`dist/app`},ext:{src:`ext`,dist:`dist/ext`},arch:{src:`arch`,dist:`dist/arch`}},commandSeriesOptions:{},outputScopes:{},frontMatter:{blankLineAfter:!0},cleanupProtection:{},plugins:[]};function Jn(e){return{...e.version==null?{}:{version:e.version},...e.workspaceDir==null?{}:{workspaceDir:e.workspaceDir},...e.aindex==null?{}:{aindex:e.aindex},...e.commandSeriesOptions==null?{}:{commandSeriesOptions:e.commandSeriesOptions},...e.outputScopes==null?{}:{outputScopes:e.outputScopes},...e.frontMatter==null?{}:{frontMatter:e.frontMatter},...e.cleanupProtection==null?{}:{cleanupProtection:e.cleanupProtection},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function Yn(...e){return e.reduce((e,t)=>Xn(e,t),{...qn})}function Xn(e,t){let n=t.plugins,r=t.commandSeriesOptions,i=t.outputScopes,a=t.frontMatter,o=t.cleanupProtection;return{...e,...t,aindex:Zn(e.aindex,t.aindex),plugins:[...e.plugins,...n??[]],commandSeriesOptions:Qn(e.commandSeriesOptions,r),outputScopes:er(e.outputScopes,i),frontMatter:tr(e.frontMatter,a),cleanupProtection:nr(e.cleanupProtection,o)}}function Zn(e,t){return t==null?e:{dir:t.dir??e.dir,skills:{...e.skills,...t.skills},commands:{...e.commands,...t.commands},subAgents:{...e.subAgents,...t.subAgents},rules:{...e.rules,...t.rules},globalPrompt:{...e.globalPrompt,...t.globalPrompt},workspacePrompt:{...e.workspacePrompt,...t.workspacePrompt},app:{...e.app,...t.app},ext:{...e.ext,...t.ext},arch:{...e.arch,...t.arch}}}function Qn(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.pluginOverrides!=null)for(let[t,r]of Object.entries(e.pluginOverrides))n[t]={...r};if(t.pluginOverrides!=null)for(let[e,r]of Object.entries(t.pluginOverrides))n[e]={...n[e],...r};let r=t.includeSeriesPrefix??e.includeSeriesPrefix,i=Object.keys(n).length>0;return r!=null&&i?{includeSeriesPrefix:r,pluginOverrides:n}:r==null?i?{pluginOverrides:n}:{}:{includeSeriesPrefix:r}}function $n(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}function er(e,t){if(t==null)return e??{};if(e==null)return t;let n={};if(e.plugins!=null)for(let[t,r]of Object.entries(e.plugins))r!=null&&(n[t]={...r});if(t.plugins!=null)for(let[e,r]of Object.entries(t.plugins)){let t=$n(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}function tr(e,t){return t==null?e:{...e,...t}}function nr(e,t){return t==null?e??{}:e==null?t:{rules:[...e.rules??[],...t.rules??[]]}}function rr(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e||`cwd`in e||`pipelineArgs`in e}async function ir(e={}){let t,n,i,a,o;rr(e)?({pluginOptions:i={},cwd:n,configLoaderOptions:a,pipelineArgs:o}={pluginOptions:e.pluginOptions,cwd:e.cwd,configLoaderOptions:e.configLoaderOptions,pipelineArgs:e.pipelineArgs},t=e.loadUserConfig??!0):(i=e,t=!0,a=void 0,o=void 0);let s=Object.hasOwn(i,`plugins`),c=i.plugins,l={},u=!1,d=[],f;if(t)try{let e=Nt(a).load(n);u=e.found,d=e.sources,e.found&&(l=Jn(e.config),f=e.config)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to load user config: ${t}`)}let p=Yn(l,i),{plugins:m=[],logLevel:h}=p,g=le(`defineConfig`,h);u?g.info(`user config loaded`,{sources:d}):g.info(`no user config found, using defaults/programmatic options`,{workspaceDir:p.workspaceDir,aindexDir:p.aindex.dir,logLevel:p.logLevel});let _=m.filter(Gn),v=m.filter(Kn);r(_,p);let y=await Wn({userConfigOptions:p,...v.length>0?{capabilities:v}:{},includeBuiltinEffects:!(v.length>0||s&&(c?.length??0)===0),...o==null?{}:{pipelineArgs:o},...f==null?{}:{userConfig:f}});if(y.workspace==null)throw Error(`Workspace not initialized by any plugin`);let x=b({workspace:y.workspace,...y.vscodeConfigFiles!=null&&{vscodeConfigFiles:y.vscodeConfigFiles},...y.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:y.jetbrainsConfigFiles},...y.editorConfigFiles!=null&&{editorConfigFiles:y.editorConfigFiles},...y.commands!=null&&{commands:y.commands},...y.subAgents!=null&&{subAgents:y.subAgents},...y.skills!=null&&{skills:y.skills},...y.rules!=null&&{rules:y.rules},...y.globalMemory!=null&&{globalMemory:y.globalMemory},...y.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:y.aiAgentIgnoreConfigFiles},...y.aindexDir!=null&&{aindexDir:y.aindexDir},...y.readmePrompts!=null&&{readmePrompts:y.readmePrompts},...y.globalGitIgnore!=null&&{globalGitIgnore:y.globalGitIgnore},...y.shadowGitExclude!=null&&{shadowGitExclude:y.shadowGitExclude}});return y.aindexDir!=null&&kt(y.aindexDir,g),{context:x,outputPlugins:_,userConfigOptions:p}}const ar=`GLOBAL.md`;var or=class extends O{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:ar,dependsOn:[`TraeIDEOutputPlugin`],cleanup:{delete:{global:{dirs:[`.trae-cn/user_rules`]}}},capabilities:{prompt:{scopes:[`global`],singleScope:!1}}})}getGlobalUserRulesDir(){return this.joinPath(this.getGlobalConfigDir(),`user_rules`)}async declareOutputFiles(e){if(!new Set(this.selectPromptScopes(e,[`global`])).has(`global`))return[];let{globalMemory:t}=e.collectedOutputContext;return t==null?[]:[{path:this.joinPath(this.getGlobalUserRulesDir(),ar),scope:`global`,source:{content:t.content}}]}async convertContent(e,t){let n=e.source;if(n.content==null)throw Error(`Unsupported declaration source for ${this.name}`);return n.content}},sr=ir({pipelineArgs:B.argv,pluginOptions:{plugins:[new je,new Ne,new tt,new Xe,new Ve,new Ge,new ke,new ot,new ft,new yt,new or,new St,new Ot,new ze,new Ke,new Qe,new Ue,new xt,new mt]}});export{sr as default};
|