@truenine/memory-sync-cli 2026.10323.10738 → 2026.10324.10325

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/index.mjs CHANGED
@@ -228,7 +228,7 @@ t.exports=r;let n=om();function r(e,t){let r,i,a,o=!0;Array.isArray(e)?(r=[],i=e
228
228
  `).toLowerCase();if(t.length!==0)return[`windows subsystem for linux has no installed distributions`,`windows subsystem for linux has not been enabled`,`the windows subsystem for linux optional component is not enabled`,`wsl is not installed`,`run 'wsl.exe --install'`,`run "wsl.exe --install"`,`wslregisterdistribution failed with error: 0x8007019e`].some(e=>t.includes(e))?t:void 0}async function NS(e,t){let n=await Promise.all(e.map(async e=>e.declareWslMirrorFiles==null?[]:e.declareWslMirrorFiles(t))),r=new Map;for(let e of n)for(let t of e)r.set(t.sourcePath,t);return[...r.values()]}function PS(e){return{platform:`win32`,isWsl:!1,nativeHomeDir:e,effectiveHomeDir:e,globalConfigCandidates:[],windowsUsersRoot:``,expandedEnv:{HOME:e,USERPROFILE:e}}}function FS(e,t){return{platform:`linux`,isWsl:!0,nativeHomeDir:t,effectiveHomeDir:e,globalConfigCandidates:[],windowsUsersRoot:``,expandedEnv:{HOME:e,USERPROFILE:e}}}function IS(e){return TS(e.split(/\r?\n/u).map(e=>e.replace(/^\*/u,``).trim()).filter(e=>e.length>0))}function LS(e,t){let n=yS(t)(`wsl.exe`,[`--list`,`--quiet`],{shell:!1,windowsHide:!0}),r=MS(n);if(r!=null)throw new _S(r);if(n.status!==0){let e=AS(n.stderr).trim();throw Error(`Failed to enumerate WSL instances. ${e.length>0?e:`wsl.exe returned a non-zero exit status.`}`)}let i=IS(AS(n.stdout));return e.info(`discovered wsl instances`,{instances:i}),i}function RS(e,t,n){let r=ES(e);return r.length>0?r:LS(t,n)}function zS(e,t,n){if(e.scope!==`global`)return;let r=wS(n).normalize(e.path),i;try{i=OS(r,t,n)}catch{return}let[a]=i;if(a?.startsWith(`.`))return{kind:`generated`,sourcePath:r,relativePathSegments:i}}function BS(e,t,n){if(e==null)return[];let r=new Map;for(let i of e.values())for(let e of i){let i=zS(e,t,n);i!=null&&r.set(i.sourcePath,i)}return[...r.values()]}function VS(e,t,n,r){let i=wS(r).normalize(ig(e.sourcePath,t));return{kind:`declared`,sourcePath:i,relativePathSegments:OS(i,n,r)}}function HS(e,t,n,r,i){let a=new Map,o=[];for(let t of e)try{let e=VS(t,n,r,i);a.set(e.sourcePath,e)}catch(e){o.push(e instanceof Error?e.message:String(e))}for(let e of t)a.set(e.sourcePath,e);return{sources:[...a.values()],errors:o}}function US(e,t,n){if(bS(n)!==`win32`)return[];let r=RS(e,t,n);if(r.length===0)return[];let i=vS(n),a=yS(n),o=[];for(let e of r){let n=a(`wsl.exe`,[`-d`,e,`sh`,`-lc`,`printf %s "$HOME"`],{shell:!1,windowsHide:!0}),r=MS(n);if(r!=null)throw new _S(r);if(n.status!==0){let t=AS(n.stderr).trim();throw Error(`Failed to probe WSL instance "${e}". ${t.length>0?t:`wsl.exe returned a non-zero exit status.`}`)}let s=AS(n.stdout).trim();if(s.length===0)throw Error(`WSL instance "${e}" returned an empty home directory.`);let c=DS(e,s);if(!i.existsSync(c))throw Error(`WSL instance "${e}" home directory is unavailable at "${c}".`);t.info(`resolved wsl instance home`,{instance:e,linuxHomeDir:s,windowsHomeDir:c}),o.push({instance:e,linuxHomeDir:s,windowsHomeDir:c})}return o}function WS(e,t,n){let r=vS(n),i=u.posix.normalize(SS(n)),a=0,o=[],s=[];for(let n of e){if(n.kind===`declared`&&!r.existsSync(n.sourcePath)){let e=`Skipping missing WSL mirror source file: ${n.sourcePath}`;o.push(e),t.logger.warn({code:`WSL_MIRROR_SOURCE_MISSING`,title:`WSL mirror source file is missing`,rootCause:[e],exactFix:[`Create the source file on the Windows host or remove the WSL mirror declaration before retrying tnmsc.`]});continue}let e=u.posix.join(i,...n.relativePathSegments);try{if(t.dryRun===!0)t.logger.info(`would mirror host config into wsl runtime home`,{sourcePath:n.sourcePath,targetPath:e,dryRun:!0});else{let i=r.readFileSync(n.sourcePath);r.mkdirSync(u.posix.dirname(e),{recursive:!0}),r.writeFileSync(e,i),t.logger.info(`mirrored host config into wsl runtime home`,{sourcePath:n.sourcePath,targetPath:e})}a+=1}catch(t){s.push(`Failed to mirror "${n.sourcePath}" into the current WSL home at "${e}": ${t instanceof Error?t.message:String(t)}`)}}return{mirroredFiles:a,warnings:o,errors:s}}async function GS(e,t,n,r){let i=bS(n),a=i===`linux`&&CS(n);if(i!==`win32`&&!a)return{mirroredFiles:0,warnings:[],errors:[]};let o=a?u.posix.normalize(xS(n)):u.win32.normalize(xS(n)),s=await NS(e,t),c=BS(r,o,i);if(s.length===0&&c.length===0)return{mirroredFiles:0,warnings:[],errors:[]};let l=t.pluginOptions??{},d=a?u.posix.normalize(SS(n)):void 0,f=HS(s,c,a?FS(o,d??o):PS(o),o,i);if(a){if(f.sources.length===0||d==null||o===d)return{mirroredFiles:0,warnings:[],errors:[...f.errors]};let e=WS(f.sources,t,n);return{mirroredFiles:e.mirroredFiles,warnings:[...e.warnings],errors:[...f.errors,...e.errors]}}let p;try{p=US(l,t.logger,n)}catch(e){return e instanceof _S?(t.logger.info(`wsl is unavailable, skipping WSL mirror sync`,{reason:e.message}),{mirroredFiles:0,warnings:[],errors:[]}):{mirroredFiles:0,warnings:[],errors:[e instanceof Error?e.message:String(e)]}}if(p.length===0||f.sources.length===0)return{mirroredFiles:0,warnings:[],errors:[...f.errors]};let m=vS(n),h=0,g=[],_=[...f.errors];for(let e of f.sources){if(e.kind===`declared`&&!m.existsSync(e.sourcePath)){let n=`Skipping missing WSL mirror source file: ${e.sourcePath}`;g.push(n),t.logger.warn({code:`WSL_MIRROR_SOURCE_MISSING`,title:`WSL mirror source file is missing`,rootCause:[n],exactFix:[`Create the source file on the Windows host or remove the WSL mirror declaration before retrying tnmsc.`]});continue}let{relativePathSegments:n,sourcePath:r}=e;for(let e of p){let i=u.win32.join(e.windowsHomeDir,...n);try{if(t.dryRun===!0)t.logger.info(`would mirror windows config into wsl`,{instance:e.instance,sourcePath:r,targetPath:i,dryRun:!0});else{let n=m.readFileSync(r);m.mkdirSync(u.win32.dirname(i),{recursive:!0}),m.writeFileSync(i,n),t.logger.info(`mirrored windows config into wsl`,{instance:e.instance,sourcePath:r,targetPath:i})}h+=1}catch(t){_.push(`Failed to mirror "${r}" into WSL instance "${e.instance}" at "${i}": ${t instanceof Error?t.message:String(t)}`)}}}return{mirroredFiles:h,warnings:g,errors:_}}var KS=class{name=`dry-run-output`;async execute(e){let{logger:t,outputPlugins:n,createWriteContext:r}=e;t.info(`started`,{command:`dry-run-output`,dryRun:!0});let i=r(!0),a=await Ub(n,i),o=await Wb(n,i,a),s=0,c=0;for(let[e,n]of o)s+=n.files.length,c+=n.dirs.length,t.info(`plugin result`,{plugin:e,files:n.files.length,dirs:n.dirs.length,dryRun:!0});let l=await GS(n,i,void 0,a);return l.errors.length>0?{success:!1,filesAffected:s,dirsAffected:c,message:l.errors.join(`
229
229
  `)}:(s+=l.mirroredFiles,t.info(`complete`,{command:`dry-run-output`,totalFiles:s,totalDirs:c,dryRun:!0}),{success:!0,filesAffected:s,dirsAffected:c,message:`Dry-run complete, no files were written`})}},qS=class{canHandle(e){return e.subcommand===`dry-run`}createCommand(e){return new KS}},JS=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=i(!1),o=await Ub(n,a),s=await Jx(n,r(!1),t,o);if(s.violations.length>0||s.conflicts.length>0)return{success:!1,filesAffected:0,dirsAffected:0,...s.message==null?{}:{message:s.message}};t.info(`cleanup complete`,{deletedFiles:s.deletedFiles,deletedDirs:s.deletedDirs});let c=await Wb(n,a,o),l=0,u=0,d=[];for(let e of c.values()){l+=e.files.length,u+=e.dirs.length;for(let t of e.files)t.success||d.push(t.error?.message??`Failed to write ${t.path}`)}if(d.length>0)return{success:!1,filesAffected:l,dirsAffected:u,message:d.join(`
230
230
  `)};let f=await GS(n,a,void 0,o);return f.errors.length>0?{success:!1,filesAffected:l,dirsAffected:u,message:f.errors.join(`
231
- `)}:(l+=f.mirroredFiles,t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u})}},YS=class{canHandle(e){return!0}createCommand(e){return new JS}};function XS(){return`2026.10323.10738`}var ZS=class{name=`version`;async execute(e){return e.logger.info(`tnmsc v${XS()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const QS=`tnmsc`,$S=`
231
+ `)}:(l+=f.mirroredFiles,t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u})}},YS=class{canHandle(e){return!0}createCommand(e){return new JS}};function XS(){return`2026.10324.10325`}var ZS=class{name=`version`;async execute(e){return e.logger.info(`tnmsc v${XS()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const QS=`tnmsc`,$S=`
232
232
  ${QS} v${XS()} - Memory Sync CLI
233
233
 
234
234
  Synchronize AI memory and configuration files across projects.
@@ -304,8 +304,8 @@ CONFIGURATION:
304
304
  `).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(`
305
305
  `)}};const sT=`AGENTS.md`;var cT=class extends Jb{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:`.factory`,outputFileName:sT,treatWorkspaceRootProjectAsProject:!0,commands:{transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{},cleanup:{delete:{project:{files:[sT],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:this.getSkillName(e),description:e.yamlFrontMatter.description};return this.buildMarkdownContent(e.content,n,t)}};const lT=`.editorconfig`;var uT=class extends Jb{constructor(){super(`EditorConfigOutputPlugin`,{cleanup:{delete:{project:{files:[lT]}}},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,lT),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 dT=`GEMINI.md`;var fT=class extends Jb{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:`.gemini`,outputFileName:dT,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{globs:[dT]},global:{files:[`.gemini/GEMINI.md`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}},pT=class extends Jb{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,...Ky(n)];for(let e of r){let n=Gy(e);if(n==null)continue;let r=u.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(`
306
306
  `)}sanitizeContent(e){return e.split(/\r?\n/).filter(e=>{let t=e.trim();return t.length===0?!0:!(t.startsWith(`#`)&&!t.startsWith(`\\#`))}).join(`
307
- `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const mT=`AGENTS.md`,hT=`prompts`,gT=`skills`,_T=`.aiassistant`;var vT=class extends Jb{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:mT,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:hT,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:gT},dependsOn:[Zb.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,o=this.getConcreteProjects(e),s=this.getProjectPromptOutputProjects(e),c=this.getJetBrainsCodexDirs(e),l=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(l.has(`project`))for(let n of s){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let i=u.join(r,_T,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:u.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:u.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=this.getSkillName(i),a=u.join(e,gT,r);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skill`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:u.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:u.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=u.join(r,_T,`codex`);if(f.selectedScope===`project`){let e=$(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:u.join(i,hT,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(i,`project`,$(p.items,n.projectConfig,`skills`))}if(c.length>0){if(n!=null&&l.has(`global`))for(let e of c)t.push({path:u.join(e,mT),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?$(f.items,d,`commands`):[],r=p.selectedScope===`global`?$(p.items,d,`skills`):[];for(let n of c){for(let r of e)t.push({path:u.join(n,hT,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 o){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:u.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`?_.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:u.join(e,mT),kind:`file`,scope:`global`},{path:u.join(e,hT),kind:`directory`,scope:`global`},{path:u.join(e,gT),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(this.getSkillName(e),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 yT=`.idea`;var bT=class extends Jb{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(e){let t=e.dir.path;if(e.type===sh.EditorConfig)return`.editorconfig`;if(e.type!==sh.IntellijIDEA)return this.basename(t);let n=t.indexOf(yT);return n===-1?this.joinPath(yT,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}};const xT=[`name`,`description`,`developer_instructions`],ST=[`scope`,`seriName`,`argumentHint`,`color`,`namingCase`,`model`];function CT(e,t){let n={...t};return n.name=e,Array.isArray(n.allowTools)&&n.allowTools.length>0&&(n.allowedTools=n.allowTools.join(`, `)),delete n.allowTools,n}const wT={globalConfigDir:`.codex`,outputFileName:`AGENTS.md`,commands:{subDir:`prompts`,scopeRemap:{project:`global`},transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},subagents:{subDir:`agents`,sourceScopes:[`project`],scopeRemap:{global:`project`},ext:`.toml`,artifactFormat:`toml`,bodyFieldName:`developer_instructions`,excludedFrontMatterFields:ST,transformFrontMatter:(e,t)=>CT(rb(e),t.sourceFrontMatter),fieldOrder:xT},cleanup:{delete:{project:{dirs:[`.codex/agents`]},global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},wslMirrors:[`~/.codex/config.toml`,`~/.codex/auth.json`],dependsOn:[Zb.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0}}};var TT=class extends Jb{constructor(){super(`CodexCLIOutputPlugin`,wT)}};const ET=`AGENTS.md`,DT=`commands`,OT=`agents`,kT=`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 jT=class extends Jb{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:ET,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:DT,transformFrontMatter:AT},subagents:{subDir:OT},skills:{subDir:kT},cleanup:{delete:{project:{files:[ET,`.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:[Zb.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,o=this.getGlobalConfigDir(),s=new Set(this.selectPromptScopes(e,[`project`,`global`])),c=this.getProjectPromptOutputProjects(e),l=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&&s.has(`global`)&&t.push({path:u.join(o,ET),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let i=vx(r,this.log);i.size!==0&&t.push({path:u.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:yx(i,xx)}})},g=(e,n,r)=>{for(let i of r){let r=this.validateAndNormalizeSkillName(this.getSkillName(i)),a=u.join(e,kT,r);if(t.push({path:u.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:u.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:u.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},_=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&s.has(`project`)&&t.push({path:u.join(r,ET),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null&&s.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=u.join(r,`.opencode`),a=$(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of a)t.push({path:u.join(i,DT,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let o=$(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of o)t.push({path:u.join(i,OT,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let s=$(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(i,`project`,s);let c=$(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(i,`project`,c)}if(d.selectedScope===`global`){let e=$(d.items,l,`commands`);for(let n of e)t.push({path:u.join(o,DT,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=$(f.items,l,`subAgents`);for(let n of e)t.push({path:u.join(o,OT,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(o,`global`,$(p.items,l,`skills`)),m.selectedScope===`global`&&h(o,`global`,$(m.items,l,`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`?_.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 MT=`rules`,NT=`commands`,PT=`skills`,FT=`glob`,IT=`glob`;function LT(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 RT=class extends Jb{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:NT,transformFrontMatter:LT},skills:{subDir:PT},rules:{subDir:MT,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:o}=e.collectedOutputContext,s=this.getGlobalConfigDir(),c=this.resolvePromptSourceProjectConfig(e),l=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`)),g=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=(e,n,r)=>{for(let i of r){let r=this.getSkillName(i),a=u.join(e,PT,r);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:u.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:u.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},v=(e,n,r)=>{for(let i of r){if(i.mcpConfig==null)continue;let r=u.join(e,PT,this.getSkillName(i));t.push({path:u.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=$(m.items,n.projectConfig,`commands`);for(let e of i)t.push({path:u.join(r,NT,this.transformCommandName(e,l)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=$(m.items,c,`commands`);for(let n of e)t.push({path:u.join(s,NT,this.transformCommandName(n,l)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&_(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`&&v(n,`project`,$(g.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&_(s,`global`,$(h.items,c,`skills`)),g.selectedScope===`global`&&v(s,`global`,$(g.items,c,`skills`))),n!=null&&f.has(`global`))for(let r of p){let i=this.resolveProjectConfigDir(e,r);i!=null&&t.push({path:u.join(i,MT,`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:u.join(r,MT,`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:u.join(r,MT,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=Wy($(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:u.join(r,MT,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:u.join(s,MT,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let y=this.getIgnoreOutputPath(),b=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(y!=null&&b!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:u.join(e.basePath,e.path,y),scope:`project`,source:{kind:`ignoreFile`,content:b.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`?_.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:FT,[IT]:r,type:`user_command`},t)}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:this.getSkillName(e),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:FT,[IT]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function zT(e){return Fb[e??`Readme`].out}var BT=class extends Jb{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=zT(e.fileKind),r=u.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 VT=`GLOBAL.md`,HT=`.trae`,UT=`commands`,WT=`skills`;var GT=class extends Jb{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:HT,outputFileName:VT,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:UT,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:WT},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 u.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,o=this.getConcreteProjects(e),s=this.getProjectPromptOutputProjects(e),c=this.resolvePromptSourceProjectConfig(e),l=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&&l.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),VT),scope:`global`,source:{kind:`globalMemory`,content:i.content}});for(let n of s){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&l.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(`
308
- `),{alwaysApply:!1,globs:a},e);t.push({path:u.join(r,HT,`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=$(d.items,n.projectConfig,`commands`);for(let e of i)t.push({path:u.join(r,UT,this.transformCommandName(e,p)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=this.getGlobalConfigDir(),n=$(d.items,c,`commands`);for(let r of n)t.push({path:u.join(e,UT,this.transformCommandName(r,p)),scope:`global`,source:{kind:`command`,command:r}})}let m=(e,n,r)=>{for(let i of r){let r=this.getSkillName(i),a=u.join(e,WT,r);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:u.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:u.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`,$(f.items,t.projectConfig,`skills`))}f.selectedScope===`global`&&m(this.getGlobalConfigDir(),`global`,$(f.items,c,`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 o){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:u.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`?_.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(`
309
- `)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const KT=`.vscode`;var qT=class extends Jb{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(e){let t=e.dir.path;if(e.type!==sh.VSCode)return this.basename(t);let n=t.indexOf(KT);return n===-1?this.joinPath(KT,this.basename(t)):t.slice(Math.max(0,n))}};const JT=`WARP.md`;var YT=class extends Jb{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:JT,treatWorkspaceRootProjectAsProject:!0,indexignore:`.warpindexignore`,cleanup:{delete:{project:{files:[JT]}}},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,Zb.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:u.join(i,JT),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:u.join(r,JT),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(),d=this.indexignore==null?void 0:r?.find(e=>e.fileName===this.indexignore);if(l!=null&&d!=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:d.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 XT=`.codeium/windsurf`,ZT=`global_workflows`,QT=`memories`,$T=`skills`,eE=`.windsurf`;var tE=class extends Jb{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:XT,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[Zb.AgentsOutput],indexignore:`.codeiumignore`,commands:{subDir:ZT,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:$T},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:o}=e.collectedOutputContext,s=this.resolvePromptSourceProjectConfig(e),c=this.getCodeiumWindsurfDir(),l=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&&l.has(`global`)&&t.push({path:u.join(c,QT,`global_rules.md`),scope:`global`,source:{kind:`globalMemory`,content:i.content}});let m=(e,n,r)=>{let i=this.getSkillName(r),a=u.join(e,$T,i);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:r}}),r.childDocs!=null)for(let e of r.childDocs)t.push({path:u.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:u.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:u.join(n,eE);if(r==null)continue;let i=$(f.items,t.projectConfig,`skills`);for(let e of i)m(r,`project`,e)}if(f.selectedScope===`global`){let e=$(f.items,s,`skills`);for(let t of e)m(c,`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:u.join(r,eE);if(i==null)continue;let a=$(d.items,n.projectConfig,`commands`);for(let e of a)t.push({path:u.join(i,`workflows`,this.transformCommandName(e,h)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=$(d.items,s,`commands`);for(let n of e)t.push({path:u.join(c,ZT,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:u.join(c,QT,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=Wy($(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:u.join(r,eE,`rules`,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rule`,rule:e}})}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of p){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:u.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`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`?_.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 u.join(this.getHomeDir(),XT)}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(`
307
+ `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const mT=`AGENTS.md`,hT=`prompts`,gT=`skills`,_T=`.aiassistant`;var vT=class extends Jb{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:mT,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:hT,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:gT},dependsOn:[Zb.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,o=this.getConcreteProjects(e),s=this.getProjectPromptOutputProjects(e),c=this.getJetBrainsCodexDirs(e),l=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(l.has(`project`))for(let n of s){let r=this.resolveProjectRootDir(e,n);if(r==null)continue;let i=u.join(r,_T,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:u.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:u.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=this.getSkillName(i),a=u.join(e,gT,r);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skill`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:u.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:u.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=u.join(r,_T,`codex`);if(f.selectedScope===`project`){let e=$(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:u.join(i,hT,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(i,`project`,$(p.items,n.projectConfig,`skills`))}if(c.length>0){if(n!=null&&l.has(`global`))for(let e of c)t.push({path:u.join(e,mT),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?$(f.items,d,`commands`):[],r=p.selectedScope===`global`?$(p.items,d,`skills`):[];for(let n of c){for(let r of e)t.push({path:u.join(n,hT,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 o){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:u.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`?_.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:u.join(e,mT),kind:`file`,scope:`global`},{path:u.join(e,hT),kind:`directory`,scope:`global`},{path:u.join(e,gT),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(this.getSkillName(e),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 yT=`.idea`;var bT=class extends Jb{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(e){let t=e.dir.path;if(e.type===sh.EditorConfig)return`.editorconfig`;if(e.type!==sh.IntellijIDEA)return this.basename(t);let n=t.indexOf(yT);return n===-1?this.joinPath(yT,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}};const xT=[`name`,`description`,`developer_instructions`],ST=[`scope`,`seriName`,`argumentHint`,`color`,`namingCase`,`model`];function CT(e){let t={...e};return delete t.allowTools,delete t.allowedTools,t}function wT(e,t){let n=CT(t);return n.name=e,n}const TT={globalConfigDir:`.codex`,outputFileName:`AGENTS.md`,commands:{subDir:`prompts`,scopeRemap:{project:`global`},transformFrontMatter:(e,t)=>CT(t.sourceFrontMatter)},subagents:{subDir:`agents`,sourceScopes:[`project`],scopeRemap:{global:`project`},ext:`.toml`,artifactFormat:`toml`,bodyFieldName:`developer_instructions`,excludedFrontMatterFields:ST,transformFrontMatter:(e,t)=>wT(rb(e),t.sourceFrontMatter),fieldOrder:xT},cleanup:{delete:{project:{dirs:[`.codex/agents`]},global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},wslMirrors:[`~/.codex/config.toml`,`~/.codex/auth.json`],dependsOn:[Zb.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0}}};var ET=class extends Jb{constructor(){super(`CodexCLIOutputPlugin`,TT)}};const DT=`AGENTS.md`,OT=`commands`,kT=`agents`,AT=`skills`;function jT(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 MT=class extends Jb{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:DT,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:OT,transformFrontMatter:jT},subagents:{subDir:kT},skills:{subDir:AT},cleanup:{delete:{project:{files:[DT,`.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:[Zb.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,o=this.getGlobalConfigDir(),s=new Set(this.selectPromptScopes(e,[`project`,`global`])),c=this.getProjectPromptOutputProjects(e),l=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&&s.has(`global`)&&t.push({path:u.join(o,DT),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let i=vx(r,this.log);i.size!==0&&t.push({path:u.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:yx(i,xx)}})},g=(e,n,r)=>{for(let i of r){let r=this.validateAndNormalizeSkillName(this.getSkillName(i)),a=u.join(e,AT,r);if(t.push({path:u.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:u.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:u.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},_=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&(n.rootMemoryPrompt!=null&&s.has(`project`)&&t.push({path:u.join(r,DT),scope:`project`,source:{kind:`projectRootMemory`,content:n.rootMemoryPrompt.content}}),n.childMemoryPrompts!=null&&s.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=u.join(r,`.opencode`),a=$(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of a)t.push({path:u.join(i,OT,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let o=$(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of o)t.push({path:u.join(i,kT,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let s=$(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(i,`project`,s);let c=$(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(i,`project`,c)}if(d.selectedScope===`global`){let e=$(d.items,l,`commands`);for(let n of e)t.push({path:u.join(o,OT,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=$(f.items,l,`subAgents`);for(let n of e)t.push({path:u.join(o,kT,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(o,`global`,$(p.items,l,`skills`)),m.selectedScope===`global`&&h(o,`global`,$(m.items,l,`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`?_.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 NT=`rules`,PT=`commands`,FT=`skills`,IT=`glob`,LT=`glob`;function RT(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 zT=class extends Jb{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:PT,transformFrontMatter:RT},skills:{subDir:FT},rules:{subDir:NT,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:o}=e.collectedOutputContext,s=this.getGlobalConfigDir(),c=this.resolvePromptSourceProjectConfig(e),l=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`)),g=i==null?{items:[]}:this.selectSingleScopeItems(i,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=(e,n,r)=>{for(let i of r){let r=this.getSkillName(i),a=u.join(e,FT,r);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:u.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:u.join(a,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},v=(e,n,r)=>{for(let i of r){if(i.mcpConfig==null)continue;let r=u.join(e,FT,this.getSkillName(i));t.push({path:u.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=$(m.items,n.projectConfig,`commands`);for(let e of i)t.push({path:u.join(r,PT,this.transformCommandName(e,l)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=$(m.items,c,`commands`);for(let n of e)t.push({path:u.join(s,PT,this.transformCommandName(n,l)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&_(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`&&v(n,`project`,$(g.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&_(s,`global`,$(h.items,c,`skills`)),g.selectedScope===`global`&&v(s,`global`,$(g.items,c,`skills`))),n!=null&&f.has(`global`))for(let r of p){let i=this.resolveProjectConfigDir(e,r);i!=null&&t.push({path:u.join(i,NT,`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:u.join(r,NT,`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:u.join(r,NT,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=Wy($(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:u.join(r,NT,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:u.join(s,NT,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let y=this.getIgnoreOutputPath(),b=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(y!=null&&b!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:u.join(e.basePath,e.path,y),scope:`project`,source:{kind:`ignoreFile`,content:b.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`?_.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:IT,[LT]:r,type:`user_command`},t)}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:this.getSkillName(e),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:IT,[LT]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function BT(e){return Fb[e??`Readme`].out}var VT=class extends Jb{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=BT(e.fileKind),r=u.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`,UT=`.trae`,WT=`commands`,GT=`skills`;var KT=class extends Jb{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:UT,outputFileName:HT,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:WT,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:GT},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 u.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,o=this.getConcreteProjects(e),s=this.getProjectPromptOutputProjects(e),c=this.resolvePromptSourceProjectConfig(e),l=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&&l.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),HT),scope:`global`,source:{kind:`globalMemory`,content:i.content}});for(let n of s){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&l.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(`
308
+ `),{alwaysApply:!1,globs:a},e);t.push({path:u.join(r,UT,`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=$(d.items,n.projectConfig,`commands`);for(let e of i)t.push({path:u.join(r,WT,this.transformCommandName(e,p)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=this.getGlobalConfigDir(),n=$(d.items,c,`commands`);for(let r of n)t.push({path:u.join(e,WT,this.transformCommandName(r,p)),scope:`global`,source:{kind:`command`,command:r}})}let m=(e,n,r)=>{for(let i of r){let r=this.getSkillName(i),a=u.join(e,GT,r);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:i}}),i.childDocs!=null)for(let e of i.childDocs)t.push({path:u.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:u.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`,$(f.items,t.projectConfig,`skills`))}f.selectedScope===`global`&&m(this.getGlobalConfigDir(),`global`,$(f.items,c,`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 o){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:u.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`?_.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(`
309
+ `)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const qT=`.vscode`;var JT=class extends Jb{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(e){let t=e.dir.path;if(e.type!==sh.VSCode)return this.basename(t);let n=t.indexOf(qT);return n===-1?this.joinPath(qT,this.basename(t)):t.slice(Math.max(0,n))}};const YT=`WARP.md`;var XT=class extends Jb{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:YT,treatWorkspaceRootProjectAsProject:!0,indexignore:`.warpindexignore`,cleanup:{delete:{project:{files:[YT]}}},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,Zb.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:u.join(i,YT),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:u.join(r,YT),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(),d=this.indexignore==null?void 0:r?.find(e=>e.fileName===this.indexignore);if(l!=null&&d!=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:d.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 ZT=`.codeium/windsurf`,QT=`global_workflows`,$T=`memories`,eE=`skills`,tE=`.windsurf`;var nE=class extends Jb{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:ZT,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[Zb.AgentsOutput],indexignore:`.codeiumignore`,commands:{subDir:QT,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:eE},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:o}=e.collectedOutputContext,s=this.resolvePromptSourceProjectConfig(e),c=this.getCodeiumWindsurfDir(),l=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&&l.has(`global`)&&t.push({path:u.join(c,$T,`global_rules.md`),scope:`global`,source:{kind:`globalMemory`,content:i.content}});let m=(e,n,r)=>{let i=this.getSkillName(r),a=u.join(e,eE,i);if(t.push({path:u.join(a,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:r}}),r.childDocs!=null)for(let e of r.childDocs)t.push({path:u.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:u.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:u.join(n,tE);if(r==null)continue;let i=$(f.items,t.projectConfig,`skills`);for(let e of i)m(r,`project`,e)}if(f.selectedScope===`global`){let e=$(f.items,s,`skills`);for(let t of e)m(c,`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:u.join(r,tE);if(i==null)continue;let a=$(d.items,n.projectConfig,`commands`);for(let e of a)t.push({path:u.join(i,`workflows`,this.transformCommandName(e,h)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=$(d.items,s,`commands`);for(let n of e)t.push({path:u.join(c,QT,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:u.join(c,$T,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=Wy($(a.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of i)t.push({path:u.join(r,tE,`rules`,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rule`,rule:e}})}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:o?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of p){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:u.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`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`?_.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 u.join(this.getHomeDir(),ZT)}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(`
310
310
  `).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(`
311
- `)}};const nE=`GLOBAL.md`;var rE=class extends Jb{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:nE,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(),nE),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}};async function iE(e=c.argv){return Ww({pipelineArgs:e,pluginOptions:{plugins:[new Yw,new Zw,new TT,new vT,new cT,new fT,new qw,new jT,new RT,new GT,new rE,new YT,new tE,new oT,new pT,new bT,new uT,new qT,new BT]}})}const aE=new Set([`help`,`version`,`unknown`]);function oE(e){return e.some(e=>e===`--json`||e===`-j`||/^-[^-]*j/.test(e))}function sE(e){let t=e instanceof Error?e.message:String(e);ye(`main`,`silent`).error(j(`main`,e)),c.stdout.write(`${JSON.stringify(Cx({success:!1,filesAffected:0,dirsAffected:0,message:t},ve()))}\n`)}function cE(e){throw Error(`${e} context is unavailable for lightweight commands`)}function lE(e){let t=c.cwd(),n=Pw({workspaceDir:t,...e==null?{}:{logLevel:e}});return{logger:ye(`PluginPipeline`,e),outputPlugins:[],collectedOutputContext:{workspace:{directory:{pathKind:oh.Absolute,path:t,getDirectoryName:()=>u.basename(t)},projects:[]}},userConfigOptions:n,createCleanContext:()=>cE(`cleanup`),createWriteContext:()=>cE(`write`)}}function uE(e){let t=gC(fC(e.filter(e=>e!=null))),n=bC(t);if(aE.has(n.name))return t.logLevel!=null&&ge(t.logLevel),t.jsonFlag&&(ge(`silent`),n=new Sx(n)),{command:n,context:lE(t.logLevel)}}async function dE(e=c.argv){try{let t=uE(e);if(t!=null)return(await t.command.execute(t.context)).success?0:1;let n=new TC(...e),r=await iE(e);return(await n.run(r)).success?0:1}catch(t){return oE(e)?(sE(t),1):(ye(`main`,`error`).error(j(`main`,t)),1)}}const fE=`.src.mdx`,pE=`.mdx`,mE=`skill`,hE=new Set([`project-memory`,`project-child-memory`]);function gE(e){return e.replaceAll(`\\`,`/`)}function _E(e,t){let n=gE(e).trim();if(n.length===0)throw Error(`${t} cannot be empty`);let r=n.split(`/`);for(let e of r)if(e.length===0||e===`.`||e===`..`)throw Error(`${t} contains an invalid path segment`);return r.join(`/`)}function vE(e){return!gE(e).includes(`/`)}function yE(e,t){let n=e;return n.includes(Yb.WORKSPACE)&&(n=n.replace(Yb.WORKSPACE,t)),ig(n)}function bE(e={}){let{cwd:t,loadUserConfig:n=!0,pluginOptions:r={}}=e,i={};if(n){let e=fS().load(t);e.found&&(i=Nw(e.config))}let a=Pw(i,r),o=yE(a.workspaceDir,``);return{options:a,workspaceDir:o,aindexDir:u.join(o,a.aindex.dir)}}function xE(e){return e.endsWith(fE)?`${e.slice(0,-8)}${pE}`:u.extname(e)===pE?e:`${e}${pE}`}function SE(e){return e.endsWith(fE)?e.slice(0,-8):e.endsWith(pE)?e.slice(0,-4):e}function CE(e,t){return i.existsSync(e)&&i.statSync(e).isDirectory()?Um.default.sync([...t],{cwd:e,dot:!0,onlyFiles:!0}).map(gE):[]}function wE(e){let t=u.join(e.aindexDir,e.options.aindex.globalPrompt.src);return{promptId:`global-memory`,kind:`global-memory`,logicalName:`global-memory`,paths:{zh:t,en:xE(t),dist:u.join(e.aindexDir,e.options.aindex.globalPrompt.dist)}}}function TE(e){let t=u.join(e.aindexDir,e.options.aindex.workspacePrompt.src);return{promptId:`workspace-memory`,kind:`workspace-memory`,logicalName:`workspace-memory`,paths:{zh:t,en:xE(t),dist:u.join(e.aindexDir,e.options.aindex.workspacePrompt.dist)}}}function EE(e,t,n){let r=_E(t,`projectName`);if(!vE(r))throw Error(`projectName must be a single path segment`);let i=n==null?``:_E(n,`relativeName`),a=i.length===0?u.join(e.aindexDir,e.options.aindex.app.src,r):u.join(e.aindexDir,e.options.aindex.app.src,r,i),o=i.length===0?u.join(e.aindexDir,e.options.aindex.app.dist,r):u.join(e.aindexDir,e.options.aindex.app.dist,r,i),s=u.join(a,`agt${pE}`),c=i.length===0?r:`${r}/${i}`;return{promptId:i.length===0?`project-memory:${r}`:`project-child-memory:${c}`,kind:i.length===0?`project-memory`:`project-child-memory`,logicalName:c,paths:{zh:u.join(a,`agt${fE}`),en:s,dist:u.join(o,`agt${pE}`)},legacyZhPath:s}}function DE(e,t){let n=_E(t,`skillName`);if(!vE(n))throw Error(`skillName must be a single path segment`);let r=u.join(e.aindexDir,e.options.aindex.skills.src,n),i=u.join(e.aindexDir,e.options.aindex.skills.dist,n);return{promptId:`skill:${n}`,kind:`skill`,logicalName:n,paths:{zh:u.join(r,`${mE}${fE}`),en:u.join(r,`${mE}${pE}`),dist:u.join(i,`${mE}${pE}`)}}}function OE(e,t,n){let r=_E(t,`skillName`),i=_E(n,`relativeName`);if(!vE(r))throw Error(`skillName must be a single path segment`);let a=u.join(e.aindexDir,e.options.aindex.skills.src,r),o=u.join(e.aindexDir,e.options.aindex.skills.dist,r);return{promptId:`skill-child-doc:${r}/${i}`,kind:`skill-child-doc`,logicalName:`${r}/${i}`,paths:{zh:u.join(a,`${i}${fE}`),en:u.join(a,`${i}${pE}`),dist:u.join(o,`${i}${pE}`)}}}function kE(e,t,n){let r=_E(n,`relativeName`),i=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.src):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.src):u.join(e.aindexDir,e.options.aindex.rules.src),a=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.dist):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.dist):u.join(e.aindexDir,e.options.aindex.rules.dist);return{promptId:`${t}:${r}`,kind:t,logicalName:r,paths:{zh:u.join(i,`${r}${fE}`),en:u.join(i,`${r}${pE}`),dist:u.join(a,`${r}${pE}`)}}}function AE(e){switch(e){case`global-memory`:return{kind:`global-memory`};case`workspace-memory`:return{kind:`workspace-memory`};default:break}let t=e.indexOf(`:`);if(t===-1)throw Error(`Unsupported promptId: ${e}`);let n=e.slice(0,t),r=_E(e.slice(t+1),`promptId`);switch(n){case`project-memory`:if(!vE(r))throw Error(`project-memory promptId must include a single project name`);return{kind:n,projectName:r};case`project-child-memory`:{let[e,...t]=r.split(`/`),i=t.join(`/`);if(e==null||i.length===0)throw Error(`project-child-memory promptId must include project and child path`);return{kind:n,projectName:e,relativeName:i}}case`skill`:if(!vE(r))throw Error(`skill promptId must include a single skill name`);return{kind:n,skillName:r};case`skill-child-doc`:{let[e,...t]=r.split(`/`),i=t.join(`/`);if(e==null||i.length===0)throw Error(`skill-child-doc promptId must include skill and child path`);return{kind:n,skillName:e,relativeName:i}}case`command`:case`subagent`:case`rule`:return{kind:n,relativeName:r};default:throw Error(`Unsupported promptId: ${e}`)}}function jE(e,t){let n=AE(e);switch(n.kind){case`global-memory`:return wE(t);case`workspace-memory`:return TE(t);case`project-memory`:if(n.projectName==null)throw Error(`project-memory promptId must include a project name`);return EE(t,n.projectName);case`project-child-memory`:if(n.projectName==null||n.relativeName==null)throw Error(`project-child-memory promptId must include project and child path`);return EE(t,n.projectName,n.relativeName);case`skill`:if(n.skillName==null)throw Error(`skill promptId must include a skill name`);return DE(t,n.skillName);case`skill-child-doc`:if(n.skillName==null||n.relativeName==null)throw Error(`skill-child-doc promptId must include skill and child path`);return OE(t,n.skillName,n.relativeName);case`command`:case`subagent`:case`rule`:if(n.relativeName==null)throw Error(`${n.kind} promptId must include a relative path`);return kE(t,n.kind,n.relativeName)}}function ME(e,t){let n=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.src):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.src):u.join(e.aindexDir,e.options.aindex.rules.src),r=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.dist):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.dist):u.join(e.aindexDir,e.options.aindex.rules.dist),i=new Set;for(let e of CE(n,[`**/*${fE}`,`**/*${pE}`]))i.add(SE(e));for(let e of CE(r,[`**/*${pE}`]))i.add(SE(e));return[...i].sort().map(e=>`${t}:${e}`)}function NE(e){let t=u.join(e.aindexDir,e.options.aindex.skills.src),n=u.join(e.aindexDir,e.options.aindex.skills.dist),r=new Set;if(i.existsSync(t)&&i.statSync(t).isDirectory())for(let e of i.readdirSync(t,{withFileTypes:!0}))e.isDirectory()&&r.add(e.name);if(i.existsSync(n)&&i.statSync(n).isDirectory())for(let e of i.readdirSync(n,{withFileTypes:!0}))e.isDirectory()&&r.add(e.name);let a=[];for(let e of[...r].sort()){a.push(`skill:${e}`);let r=u.join(t,e),i=u.join(n,e),o=new Set;for(let e of CE(r,[`**/*${fE}`,`**/*${pE}`])){let t=SE(e);t!==mE&&o.add(t)}for(let e of CE(i,[`**/*${pE}`])){let t=SE(e);t!==mE&&o.add(t)}for(let t of[...o].sort())a.push(`skill-child-doc:${e}/${t}`)}return a}function PE(e){let t=u.join(e.aindexDir,e.options.aindex.app.src),n=u.join(e.aindexDir,e.options.aindex.app.dist),r=new Set;for(let e of CE(t,[`**/agt${fE}`,`**/agt${pE}`])){let t=gE(u.posix.dirname(gE(e)));t!==`.`&&r.add(t)}for(let e of CE(n,[`**/agt${pE}`])){let t=gE(u.posix.dirname(gE(e)));t!==`.`&&r.add(t)}let i=[];for(let e of[...r].sort()){let[t,...n]=e.split(`/`),r=n.join(`/`);t==null||t.length===0||i.push(r.length===0?`project-memory:${t}`:`project-child-memory:${t}/${r}`)}return i}function FE(e){let t=new Set,n=wE(e),r=TE(e);(i.existsSync(n.paths.zh)||i.existsSync(n.paths.en)||i.existsSync(n.paths.dist))&&t.add(n.promptId),(i.existsSync(r.paths.zh)||i.existsSync(r.paths.en)||i.existsSync(r.paths.dist))&&t.add(r.promptId);for(let n of PE(e))t.add(n);for(let n of NE(e))t.add(n);for(let n of ME(e,`command`))t.add(n);for(let n of ME(e,`subagent`))t.add(n);for(let n of ME(e,`rule`))t.add(n);return[...t].sort()}function IE(e){try{return Cp(e).yamlFrontMatter}catch{return}}function LE(e,t,n=!1){if(!(i.existsSync(e)&&i.statSync(e).isFile()))return;let r=i.statSync(e),a=t?i.readFileSync(e,`utf8`):void 0,o={path:e,exists:!0,mtime:r.mtime.toISOString(),mtimeMs:r.mtimeMs,size:r.size,...n?{legacySource:!0}:{},...a==null?{}:{content:a}},s=a==null?void 0:IE(a);return s!=null&&Object.assign(o,{frontMatter:s}),o}function RE(e,t){return t==null?`missing`:e!=null&&t.mtimeMs<e.mtimeMs?`stale`:`ready`}function zE(e,t){let n=i.existsSync(e.paths.zh),{legacyZhPath:r}=e,a=!n&&r!=null&&i.existsSync(r),o=n?e.paths.zh:a?r:void 0,s=o==null?void 0:LE(o,t,a),c=n||r!==e.paths.en?LE(e.paths.en,t):void 0,l=LE(e.paths.dist,t);if(s==null&&c==null&&l==null)return null;let u=[s,c,l].filter(e=>e!=null).sort((e,t)=>t.mtimeMs-e.mtimeMs)[0]?.mtime,d={promptId:e.promptId,kind:e.kind,logicalName:e.logicalName,paths:e.paths,exists:{zh:s!=null,en:c!=null,dist:l!=null},enStatus:RE(s,c),distStatus:RE(s,l),...u==null?{}:{updatedAt:u},...s?.legacySource===!0?{legacyZhSource:!0}:{},src:{...s==null?{}:{zh:s},...c==null?{}:{en:c}}};l!=null&&Object.assign(d,{dist:l});let f=s?.frontMatter??c?.frontMatter??l?.frontMatter;return f!=null&&Object.assign(d,{frontMatter:f}),d}function BE(e,t){return t==null||t.length===0?!0:t.includes(e)}function VE(e,t){if(t==null||t.trim().length===0)return!0;let n=t.trim().toLowerCase();return e.promptId.toLowerCase().includes(n)||e.logicalName.toLowerCase().includes(n)}function HE(e){return{promptId:e.promptId,kind:e.kind,logicalName:e.logicalName,paths:e.paths,exists:e.exists,enStatus:e.enStatus,distStatus:e.distStatus,...e.updatedAt==null?{}:{updatedAt:e.updatedAt},...e.legacyZhSource===!0?{legacyZhSource:!0}:{}}}function UE(e){return hE.has(e.kind)}function WE(e,t){i.mkdirSync(u.dirname(e),{recursive:!0}),i.writeFileSync(e,t,`utf8`)}function GE(e){if(!UE(e)||i.existsSync(e.paths.zh)||e.legacyZhPath==null||!i.existsSync(e.legacyZhPath))return;let t=i.readFileSync(e.legacyZhPath,`utf8`);WE(e.paths.zh,t)}function KE(e){UE(e)&&(e.legacyZhPath==null||e.legacyZhPath===e.paths.zh||i.existsSync(e.legacyZhPath)&&i.rmSync(e.legacyZhPath,{force:!0}))}async function qE(e={}){let t=bE(e);return FE(t).map(e=>zE(jE(e,t),!1)).filter(e=>e!=null).map(HE).filter(t=>BE(t.kind,e.kinds)).filter(t=>BE(t.enStatus,e.enStatus)).filter(t=>BE(t.distStatus,e.distStatus)).filter(t=>VE(t,e.query)).sort((e,t)=>e.promptId.localeCompare(t.promptId))}async function JE(e,t={}){return zE(jE(e,bE(t)),!0)}async function YE(e){let t=bE(e),n=e.locale??`zh`,r=jE(e.promptId,t);n===`zh`?(WE(r.paths.zh,e.content),KE(r)):(GE(r),WE(r.paths.en,e.content));let i=zE(r,!0);if(i==null)throw Error(`Failed to load prompt after write: ${e.promptId}`);return i}async function XE(e){if(e.enContent==null&&e.distContent==null)throw Error(`writePromptArtifacts requires enContent or distContent`);let t=bE(e),n=jE(e.promptId,t);e.enContent!=null&&(GE(n),WE(n.paths.en,e.enContent)),e.distContent!=null&&WE(n.paths.dist,e.distContent);let r=zE(n,!0);if(r==null)throw Error(`Failed to load prompt after write: ${e.promptId}`);return r}async function ZE(e,t={}){return jE(e,bE(t)).paths}function QE(e=c.argv){let t=e[1];if(t==null||t.length===0||!a(t))return!1;try{return s(t)===s(l(import.meta.url))}catch{return!1}}QE()&&dE(c.argv).then(e=>c.exit(e));export{uS as ConfigLoader,sS as DEFAULT_CONFIG_FILE_NAME,cS as DEFAULT_GLOBAL_CONFIG_DIR,Xb as DEFAULT_USER_CONFIG,Yb as PathPlaceholders,TC as PluginPipeline,EC as checkVersionControl,iE as createDefaultPluginConfig,Ww as defineConfig,OC as generateAindex,fS as getConfigLoader,lS as getGlobalConfigPath,JE as getPrompt,oE as isJsonMode,qE as listPrompts,pS as loadUserConfig,Pw as mergeConfig,ZE as resolvePromptDefinition,dE as runCli,YE as upsertPromptSource,Nw as userConfigToPluginOptions,mS as validateGlobalConfig,XE as writePromptArtifacts};
311
+ `)}};const rE=`GLOBAL.md`;var iE=class extends Jb{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:rE,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(),rE),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}};async function aE(e=c.argv){return Ww({pipelineArgs:e,pluginOptions:{plugins:[new Yw,new Zw,new ET,new vT,new cT,new fT,new qw,new MT,new zT,new KT,new iE,new XT,new nE,new oT,new pT,new bT,new uT,new JT,new VT]}})}const oE=new Set([`help`,`version`,`unknown`]);function sE(e){return e.some(e=>e===`--json`||e===`-j`||/^-[^-]*j/.test(e))}function cE(e){let t=e instanceof Error?e.message:String(e);ye(`main`,`silent`).error(j(`main`,e)),c.stdout.write(`${JSON.stringify(Cx({success:!1,filesAffected:0,dirsAffected:0,message:t},ve()))}\n`)}function lE(e){throw Error(`${e} context is unavailable for lightweight commands`)}function uE(e){let t=c.cwd(),n=Pw({workspaceDir:t,...e==null?{}:{logLevel:e}});return{logger:ye(`PluginPipeline`,e),outputPlugins:[],collectedOutputContext:{workspace:{directory:{pathKind:oh.Absolute,path:t,getDirectoryName:()=>u.basename(t)},projects:[]}},userConfigOptions:n,createCleanContext:()=>lE(`cleanup`),createWriteContext:()=>lE(`write`)}}function dE(e){let t=gC(fC(e.filter(e=>e!=null))),n=bC(t);if(oE.has(n.name))return t.logLevel!=null&&ge(t.logLevel),t.jsonFlag&&(ge(`silent`),n=new Sx(n)),{command:n,context:uE(t.logLevel)}}async function fE(e=c.argv){try{let t=dE(e);if(t!=null)return(await t.command.execute(t.context)).success?0:1;let n=new TC(...e),r=await aE(e);return(await n.run(r)).success?0:1}catch(t){return sE(e)?(cE(t),1):(ye(`main`,`error`).error(j(`main`,t)),1)}}const pE=`.src.mdx`,mE=`.mdx`,hE=`skill`,gE=new Set([`project-memory`,`project-child-memory`]);function _E(e){return e.replaceAll(`\\`,`/`)}function vE(e,t){let n=_E(e).trim();if(n.length===0)throw Error(`${t} cannot be empty`);let r=n.split(`/`);for(let e of r)if(e.length===0||e===`.`||e===`..`)throw Error(`${t} contains an invalid path segment`);return r.join(`/`)}function yE(e){return!_E(e).includes(`/`)}function bE(e,t){let n=e;return n.includes(Yb.WORKSPACE)&&(n=n.replace(Yb.WORKSPACE,t)),ig(n)}function xE(e={}){let{cwd:t,loadUserConfig:n=!0,pluginOptions:r={}}=e,i={};if(n){let e=fS().load(t);e.found&&(i=Nw(e.config))}let a=Pw(i,r),o=bE(a.workspaceDir,``);return{options:a,workspaceDir:o,aindexDir:u.join(o,a.aindex.dir)}}function SE(e){return e.endsWith(pE)?`${e.slice(0,-8)}${mE}`:u.extname(e)===mE?e:`${e}${mE}`}function CE(e){return e.endsWith(pE)?e.slice(0,-8):e.endsWith(mE)?e.slice(0,-4):e}function wE(e,t){return i.existsSync(e)&&i.statSync(e).isDirectory()?Um.default.sync([...t],{cwd:e,dot:!0,onlyFiles:!0}).map(_E):[]}function TE(e){let t=u.join(e.aindexDir,e.options.aindex.globalPrompt.src);return{promptId:`global-memory`,kind:`global-memory`,logicalName:`global-memory`,paths:{zh:t,en:SE(t),dist:u.join(e.aindexDir,e.options.aindex.globalPrompt.dist)}}}function EE(e){let t=u.join(e.aindexDir,e.options.aindex.workspacePrompt.src);return{promptId:`workspace-memory`,kind:`workspace-memory`,logicalName:`workspace-memory`,paths:{zh:t,en:SE(t),dist:u.join(e.aindexDir,e.options.aindex.workspacePrompt.dist)}}}function DE(e,t,n){let r=vE(t,`projectName`);if(!yE(r))throw Error(`projectName must be a single path segment`);let i=n==null?``:vE(n,`relativeName`),a=i.length===0?u.join(e.aindexDir,e.options.aindex.app.src,r):u.join(e.aindexDir,e.options.aindex.app.src,r,i),o=i.length===0?u.join(e.aindexDir,e.options.aindex.app.dist,r):u.join(e.aindexDir,e.options.aindex.app.dist,r,i),s=u.join(a,`agt${mE}`),c=i.length===0?r:`${r}/${i}`;return{promptId:i.length===0?`project-memory:${r}`:`project-child-memory:${c}`,kind:i.length===0?`project-memory`:`project-child-memory`,logicalName:c,paths:{zh:u.join(a,`agt${pE}`),en:s,dist:u.join(o,`agt${mE}`)},legacyZhPath:s}}function OE(e,t){let n=vE(t,`skillName`);if(!yE(n))throw Error(`skillName must be a single path segment`);let r=u.join(e.aindexDir,e.options.aindex.skills.src,n),i=u.join(e.aindexDir,e.options.aindex.skills.dist,n);return{promptId:`skill:${n}`,kind:`skill`,logicalName:n,paths:{zh:u.join(r,`${hE}${pE}`),en:u.join(r,`${hE}${mE}`),dist:u.join(i,`${hE}${mE}`)}}}function kE(e,t,n){let r=vE(t,`skillName`),i=vE(n,`relativeName`);if(!yE(r))throw Error(`skillName must be a single path segment`);let a=u.join(e.aindexDir,e.options.aindex.skills.src,r),o=u.join(e.aindexDir,e.options.aindex.skills.dist,r);return{promptId:`skill-child-doc:${r}/${i}`,kind:`skill-child-doc`,logicalName:`${r}/${i}`,paths:{zh:u.join(a,`${i}${pE}`),en:u.join(a,`${i}${mE}`),dist:u.join(o,`${i}${mE}`)}}}function AE(e,t,n){let r=vE(n,`relativeName`),i=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.src):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.src):u.join(e.aindexDir,e.options.aindex.rules.src),a=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.dist):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.dist):u.join(e.aindexDir,e.options.aindex.rules.dist);return{promptId:`${t}:${r}`,kind:t,logicalName:r,paths:{zh:u.join(i,`${r}${pE}`),en:u.join(i,`${r}${mE}`),dist:u.join(a,`${r}${mE}`)}}}function jE(e){switch(e){case`global-memory`:return{kind:`global-memory`};case`workspace-memory`:return{kind:`workspace-memory`};default:break}let t=e.indexOf(`:`);if(t===-1)throw Error(`Unsupported promptId: ${e}`);let n=e.slice(0,t),r=vE(e.slice(t+1),`promptId`);switch(n){case`project-memory`:if(!yE(r))throw Error(`project-memory promptId must include a single project name`);return{kind:n,projectName:r};case`project-child-memory`:{let[e,...t]=r.split(`/`),i=t.join(`/`);if(e==null||i.length===0)throw Error(`project-child-memory promptId must include project and child path`);return{kind:n,projectName:e,relativeName:i}}case`skill`:if(!yE(r))throw Error(`skill promptId must include a single skill name`);return{kind:n,skillName:r};case`skill-child-doc`:{let[e,...t]=r.split(`/`),i=t.join(`/`);if(e==null||i.length===0)throw Error(`skill-child-doc promptId must include skill and child path`);return{kind:n,skillName:e,relativeName:i}}case`command`:case`subagent`:case`rule`:return{kind:n,relativeName:r};default:throw Error(`Unsupported promptId: ${e}`)}}function ME(e,t){let n=jE(e);switch(n.kind){case`global-memory`:return TE(t);case`workspace-memory`:return EE(t);case`project-memory`:if(n.projectName==null)throw Error(`project-memory promptId must include a project name`);return DE(t,n.projectName);case`project-child-memory`:if(n.projectName==null||n.relativeName==null)throw Error(`project-child-memory promptId must include project and child path`);return DE(t,n.projectName,n.relativeName);case`skill`:if(n.skillName==null)throw Error(`skill promptId must include a skill name`);return OE(t,n.skillName);case`skill-child-doc`:if(n.skillName==null||n.relativeName==null)throw Error(`skill-child-doc promptId must include skill and child path`);return kE(t,n.skillName,n.relativeName);case`command`:case`subagent`:case`rule`:if(n.relativeName==null)throw Error(`${n.kind} promptId must include a relative path`);return AE(t,n.kind,n.relativeName)}}function NE(e,t){let n=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.src):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.src):u.join(e.aindexDir,e.options.aindex.rules.src),r=t===`command`?u.join(e.aindexDir,e.options.aindex.commands.dist):t===`subagent`?u.join(e.aindexDir,e.options.aindex.subAgents.dist):u.join(e.aindexDir,e.options.aindex.rules.dist),i=new Set;for(let e of wE(n,[`**/*${pE}`,`**/*${mE}`]))i.add(CE(e));for(let e of wE(r,[`**/*${mE}`]))i.add(CE(e));return[...i].sort().map(e=>`${t}:${e}`)}function PE(e){let t=u.join(e.aindexDir,e.options.aindex.skills.src),n=u.join(e.aindexDir,e.options.aindex.skills.dist),r=new Set;if(i.existsSync(t)&&i.statSync(t).isDirectory())for(let e of i.readdirSync(t,{withFileTypes:!0}))e.isDirectory()&&r.add(e.name);if(i.existsSync(n)&&i.statSync(n).isDirectory())for(let e of i.readdirSync(n,{withFileTypes:!0}))e.isDirectory()&&r.add(e.name);let a=[];for(let e of[...r].sort()){a.push(`skill:${e}`);let r=u.join(t,e),i=u.join(n,e),o=new Set;for(let e of wE(r,[`**/*${pE}`,`**/*${mE}`])){let t=CE(e);t!==hE&&o.add(t)}for(let e of wE(i,[`**/*${mE}`])){let t=CE(e);t!==hE&&o.add(t)}for(let t of[...o].sort())a.push(`skill-child-doc:${e}/${t}`)}return a}function FE(e){let t=u.join(e.aindexDir,e.options.aindex.app.src),n=u.join(e.aindexDir,e.options.aindex.app.dist),r=new Set;for(let e of wE(t,[`**/agt${pE}`,`**/agt${mE}`])){let t=_E(u.posix.dirname(_E(e)));t!==`.`&&r.add(t)}for(let e of wE(n,[`**/agt${mE}`])){let t=_E(u.posix.dirname(_E(e)));t!==`.`&&r.add(t)}let i=[];for(let e of[...r].sort()){let[t,...n]=e.split(`/`),r=n.join(`/`);t==null||t.length===0||i.push(r.length===0?`project-memory:${t}`:`project-child-memory:${t}/${r}`)}return i}function IE(e){let t=new Set,n=TE(e),r=EE(e);(i.existsSync(n.paths.zh)||i.existsSync(n.paths.en)||i.existsSync(n.paths.dist))&&t.add(n.promptId),(i.existsSync(r.paths.zh)||i.existsSync(r.paths.en)||i.existsSync(r.paths.dist))&&t.add(r.promptId);for(let n of FE(e))t.add(n);for(let n of PE(e))t.add(n);for(let n of NE(e,`command`))t.add(n);for(let n of NE(e,`subagent`))t.add(n);for(let n of NE(e,`rule`))t.add(n);return[...t].sort()}function LE(e){try{return Cp(e).yamlFrontMatter}catch{return}}function RE(e,t,n=!1){if(!(i.existsSync(e)&&i.statSync(e).isFile()))return;let r=i.statSync(e),a=t?i.readFileSync(e,`utf8`):void 0,o={path:e,exists:!0,mtime:r.mtime.toISOString(),mtimeMs:r.mtimeMs,size:r.size,...n?{legacySource:!0}:{},...a==null?{}:{content:a}},s=a==null?void 0:LE(a);return s!=null&&Object.assign(o,{frontMatter:s}),o}function zE(e,t){return t==null?`missing`:e!=null&&t.mtimeMs<e.mtimeMs?`stale`:`ready`}function BE(e,t){let n=i.existsSync(e.paths.zh),{legacyZhPath:r}=e,a=!n&&r!=null&&i.existsSync(r),o=n?e.paths.zh:a?r:void 0,s=o==null?void 0:RE(o,t,a),c=n||r!==e.paths.en?RE(e.paths.en,t):void 0,l=RE(e.paths.dist,t);if(s==null&&c==null&&l==null)return null;let u=[s,c,l].filter(e=>e!=null).sort((e,t)=>t.mtimeMs-e.mtimeMs)[0]?.mtime,d={promptId:e.promptId,kind:e.kind,logicalName:e.logicalName,paths:e.paths,exists:{zh:s!=null,en:c!=null,dist:l!=null},enStatus:zE(s,c),distStatus:zE(s,l),...u==null?{}:{updatedAt:u},...s?.legacySource===!0?{legacyZhSource:!0}:{},src:{...s==null?{}:{zh:s},...c==null?{}:{en:c}}};l!=null&&Object.assign(d,{dist:l});let f=s?.frontMatter??c?.frontMatter??l?.frontMatter;return f!=null&&Object.assign(d,{frontMatter:f}),d}function VE(e,t){return t==null||t.length===0?!0:t.includes(e)}function HE(e,t){if(t==null||t.trim().length===0)return!0;let n=t.trim().toLowerCase();return e.promptId.toLowerCase().includes(n)||e.logicalName.toLowerCase().includes(n)}function UE(e){return{promptId:e.promptId,kind:e.kind,logicalName:e.logicalName,paths:e.paths,exists:e.exists,enStatus:e.enStatus,distStatus:e.distStatus,...e.updatedAt==null?{}:{updatedAt:e.updatedAt},...e.legacyZhSource===!0?{legacyZhSource:!0}:{}}}function WE(e){return gE.has(e.kind)}function GE(e,t){i.mkdirSync(u.dirname(e),{recursive:!0}),i.writeFileSync(e,t,`utf8`)}function KE(e){if(!WE(e)||i.existsSync(e.paths.zh)||e.legacyZhPath==null||!i.existsSync(e.legacyZhPath))return;let t=i.readFileSync(e.legacyZhPath,`utf8`);GE(e.paths.zh,t)}function qE(e){WE(e)&&(e.legacyZhPath==null||e.legacyZhPath===e.paths.zh||i.existsSync(e.legacyZhPath)&&i.rmSync(e.legacyZhPath,{force:!0}))}async function JE(e={}){let t=xE(e);return IE(t).map(e=>BE(ME(e,t),!1)).filter(e=>e!=null).map(UE).filter(t=>VE(t.kind,e.kinds)).filter(t=>VE(t.enStatus,e.enStatus)).filter(t=>VE(t.distStatus,e.distStatus)).filter(t=>HE(t,e.query)).sort((e,t)=>e.promptId.localeCompare(t.promptId))}async function YE(e,t={}){return BE(ME(e,xE(t)),!0)}async function XE(e){let t=xE(e),n=e.locale??`zh`,r=ME(e.promptId,t);n===`zh`?(GE(r.paths.zh,e.content),qE(r)):(KE(r),GE(r.paths.en,e.content));let i=BE(r,!0);if(i==null)throw Error(`Failed to load prompt after write: ${e.promptId}`);return i}async function ZE(e){if(e.enContent==null&&e.distContent==null)throw Error(`writePromptArtifacts requires enContent or distContent`);let t=xE(e),n=ME(e.promptId,t);e.enContent!=null&&(KE(n),GE(n.paths.en,e.enContent)),e.distContent!=null&&GE(n.paths.dist,e.distContent);let r=BE(n,!0);if(r==null)throw Error(`Failed to load prompt after write: ${e.promptId}`);return r}async function QE(e,t={}){return ME(e,xE(t)).paths}function $E(e=c.argv){let t=e[1];if(t==null||t.length===0||!a(t))return!1;try{return s(t)===s(l(import.meta.url))}catch{return!1}}$E()&&fE(c.argv).then(e=>c.exit(e));export{uS as ConfigLoader,sS as DEFAULT_CONFIG_FILE_NAME,cS as DEFAULT_GLOBAL_CONFIG_DIR,Xb as DEFAULT_USER_CONFIG,Yb as PathPlaceholders,TC as PluginPipeline,EC as checkVersionControl,aE as createDefaultPluginConfig,Ww as defineConfig,OC as generateAindex,fS as getConfigLoader,lS as getGlobalConfigPath,YE as getPrompt,sE as isJsonMode,JE as listPrompts,pS as loadUserConfig,Pw as mergeConfig,QE as resolvePromptDefinition,fE as runCli,XE as upsertPromptSource,Nw as userConfigToPluginOptions,mS as validateGlobalConfig,ZE as writePromptArtifacts};
@@ -230,36 +230,36 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
230
230
  `).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(`
231
231
  `)}};const ZS=`AGENTS.md`;var QS=class extends ix{constructor(){super(`DroidCLIOutputPlugin`,{globalConfigDir:`.factory`,outputFileName:ZS,treatWorkspaceRootProjectAsProject:!0,commands:{transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{},cleanup:{delete:{project:{files:[ZS],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:this.getSkillName(e),description:e.yamlFrontMatter.description};return this.buildMarkdownContent(e.content,n,t)}};const $S=`.editorconfig`;var eC=class extends ix{constructor(){super(`EditorConfigOutputPlugin`,{cleanup:{delete:{project:{files:[$S]}}},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,$S),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 tC=`GEMINI.md`;var nC=class extends ix{constructor(){super(`GeminiCLIOutputPlugin`,{globalConfigDir:`.gemini`,outputFileName:tC,treatWorkspaceRootProjectAsProject:!0,cleanup:{delete:{project:{globs:[tC]},global:{files:[`.gemini/GEMINI.md`]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}},rC=class extends ix{constructor(){super(`GitExcludeOutputPlugin`,{capabilities:{}})}async declareOutputFiles(e){let t=[],{workspace:n,globalGitIgnore:r,shadowGitExclude:a}=e.collectedOutputContext,o=this.buildManagedContent(r,a);if(o.length===0)return t;let s=this.normalizeContent(o),c=new Set,{projects:l}=n;for(let e of l){if(e.dirFromWorkspacePath==null)continue;let n=e.dirFromWorkspacePath.getAbsolutePath(),r=[n,...nb(n)];for(let e of r){let n=tb(e);if(n==null)continue;let r=i.join(n,`exclude`);c.has(r)||(c.add(r),t.push({path:r,scope:`project`,source:{content:s}}))}}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(`
232
232
  `)}sanitizeContent(e){return e.split(/\r?\n/).filter(e=>{let t=e.trim();return t.length===0?!0:!(t.startsWith(`#`)&&!t.startsWith(`\\#`))}).join(`
233
- `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const iC=`AGENTS.md`,aC=`prompts`,oC=`skills`,sC=`.aiassistant`;var cC=class extends ix{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:iC,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:aC,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:oC},dependsOn:[ox.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:a,aiAgentIgnoreConfigFiles:o}=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=a==null?{items:[]}:this.selectSingleScopeItems(a,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 a=i.join(r,sC,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:i.join(a,`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:i.join(a,this.buildChildRuleFileName(r)),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildGlobRuleContent(r,e)}})}let h=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,oC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skill`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,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 a=i.join(r,sC,`codex`);if(f.selectedScope===`project`){let e=$(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:i.join(a,aC,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(a,`project`,$(p.items,n.projectConfig,`skills`))}if(l.length>0){if(n!=null&&u.has(`global`))for(let e of l)t.push({path:i.join(e,iC),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?$(f.items,d,`commands`):[],r=p.selectedScope===`global`?$(p.items,d,`skills`):[];for(let n of l){for(let r of e)t.push({path:i.join(n,aC,this.transformCommandName(r,m)),scope:`global`,source:{kind:`command`,command:r}});h(n,`global`,r)}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:o?.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:i.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`?f.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:i.join(e,iC),kind:`file`,scope:`global`},{path:i.join(e,aC),kind:`directory`,scope:`global`},{path:i.join(e,oC),kind:`directory`,scope:`global`}]),a=t.delete??[];return{...t,delete:[...a,...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(this.getSkillName(e),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 lC=`.idea`;var uC=class extends ix{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(e){let t=e.dir.path;if(e.type===Zh.EditorConfig)return`.editorconfig`;if(e.type!==Zh.IntellijIDEA)return this.basename(t);let n=t.indexOf(lC);return n===-1?this.joinPath(lC,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}};const dC=[`name`,`description`,`developer_instructions`],fC=[`scope`,`seriName`,`argumentHint`,`color`,`namingCase`,`model`];function pC(e,t){let n={...t};return n.name=e,Array.isArray(n.allowTools)&&n.allowTools.length>0&&(n.allowedTools=n.allowTools.join(`, `)),delete n.allowTools,n}const mC={globalConfigDir:`.codex`,outputFileName:`AGENTS.md`,commands:{subDir:`prompts`,scopeRemap:{project:`global`},transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},subagents:{subDir:`agents`,sourceScopes:[`project`],scopeRemap:{global:`project`},ext:`.toml`,artifactFormat:`toml`,bodyFieldName:`developer_instructions`,excludedFrontMatterFields:fC,transformFrontMatter:(e,t)=>pC(pb(e),t.sourceFrontMatter),fieldOrder:dC},cleanup:{delete:{project:{dirs:[`.codex/agents`]},global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},wslMirrors:[`~/.codex/config.toml`,`~/.codex/auth.json`],dependsOn:[ox.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0}}};var hC=class extends ix{constructor(){super(`CodexCLIOutputPlugin`,mC)}};const gC=`AGENTS.md`,_C=`commands`,vC=`agents`,yC=`skills`;function bC(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 xC=class extends ix{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:gC,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:_C,transformFrontMatter:bC},subagents:{subDir:vC},skills:{subDir:yC},cleanup:{delete:{project:{files:[gC,`.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:[ox.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:a,skills:o}=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=a==null?{items:[]}:this.selectSingleScopeItems(a,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)),p=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`));n!=null&&c.has(`global`)&&t.push({path:i.join(s,gC),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let a=Dx(r,this.log);a.size!==0&&t.push({path:i.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:Ox(a,Ax)}})},g=(e,n,r)=>{for(let a of r){let r=this.validateAndNormalizeSkillName(this.getSkillName(a)),o=i.join(e,yC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a,normalizedSkillName:r}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,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:i.join(r,gC),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 a=i.join(r,`.opencode`),o=$(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of o)t.push({path:i.join(a,_C,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let s=$(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of s)t.push({path:i.join(a,vC,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let c=$(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(a,`project`,c);let l=$(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(a,`project`,l)}if(d.selectedScope===`global`){let e=$(d.items,u,`commands`);for(let n of e)t.push({path:i.join(s,_C,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=$(f.items,u,`subAgents`);for(let n of e)t.push({path:i.join(s,vC,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(s,`global`,$(p.items,u,`skills`)),m.selectedScope===`global`&&h(s,`global`,$(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`?f.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 SC=`rules`,CC=`commands`,wC=`skills`,TC=`glob`,EC=`glob`;function DC(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 OC=class extends ix{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:CC,transformFrontMatter:DC},skills:{subDir:wC},rules:{subDir:SC,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:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),d=new Set(o==null?[]:this.selectRuleScopes(e,o)),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=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),g=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,wC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},v=(e,n,r)=>{for(let a of r){if(a.mcpConfig==null)continue;let r=i.join(e,wC,this.getSkillName(a));t.push({path:i.join(r,`mcp.json`),scope:n,source:{kind:`skillMcpConfig`,rawContent:a.mcpConfig.rawContent}})}};if(m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(m.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,CC,this.transformCommandName(e,u)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=$(m.items,l,`commands`);for(let n of e)t.push({path:i.join(c,CC,this.transformCommandName(n,u)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&_(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`&&v(n,`project`,$(g.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&_(c,`global`,$(h.items,l,`skills`)),g.selectedScope===`global`&&v(c,`global`,$(g.items,l,`skills`))),n!=null&&f.has(`global`))for(let r of p){let a=this.resolveProjectConfigDir(e,r);a!=null&&t.push({path:i.join(a,SC,`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:i.join(r,SC,`always.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null))for(let a of n.childMemoryPrompts)t.push({path:i.join(r,SC,this.buildChildRuleFileName(a)),scope:`project`,source:{kind:`ruleContent`,content:this.buildGlobRuleContent(a,e)}})}if(o!=null&&o.length>0&&d.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=eb($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,SC,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rulePrompt`,rule:e}})}if(o!=null&&o.length>0&&d.has(`global`)){let e=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);for(let n of e)t.push({path:i.join(c,SC,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let y=this.getIgnoreOutputPath(),b=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(y!=null&&b!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:i.join(e.basePath,e.path,y),scope:`project`,source:{kind:`ignoreFile`,content:b.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`?f.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:TC,[EC]:r,type:`user_command`},t)}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:this.getSkillName(e),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:TC,[EC]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function kC(e){return Gb[e??`Readme`].out}var AC=class extends ix{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=kC(e.fileKind),r=i.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 jC=`GLOBAL.md`,MC=`.trae`,NC=`commands`,PC=`skills`;var FC=class extends ix{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:MC,outputFileName:jC,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:NC,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:PC},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 i.join(`.trae`,`.ignore`)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),`steering`)}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:a,aiAgentIgnoreConfigFiles:o}=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});a!=null&&u.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),jC),scope:`global`,source:{kind:`globalMemory`,content:a.content}});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&u.has(`project`))for(let a of n.childMemoryPrompts){let n=(a.workingChildDirectoryPath?.path??a.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),o=this.buildProjectRelativeGlobPattern(n),s=this.buildMarkdownContent([this.buildPathGuardHint(n),``,a.content].join(`
234
- `),{alwaysApply:!1,globs:o},e);t.push({path:i.join(r,MC,`rules`,this.buildSteeringFileName(a)),scope:`project`,source:{kind:`steeringRule`,content:s}})}}if(d.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(d.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,NC,this.transformCommandName(e,p)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=this.getGlobalConfigDir(),n=$(d.items,l,`commands`);for(let r of n)t.push({path:i.join(e,NC,this.transformCommandName(r,p)),scope:`global`,source:{kind:`command`,command:r}})}let m=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,PC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,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`,$(f.items,t.projectConfig,`skills`))}f.selectedScope===`global`&&m(this.getGlobalConfigDir(),`global`,$(f.items,l,`skills`));let h=this.getIgnoreOutputPath(),g=this.indexignore==null?void 0:o?.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:i.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`?f.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(`
235
- `)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const IC=`.vscode`;var LC=class extends ix{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(e){let t=e.dir.path;if(e.type!==Zh.VSCode)return this.basename(t);let n=t.indexOf(IC);return n===-1?this.joinPath(IC,this.basename(t)):t.slice(Math.max(0,n))}};const RC=`WARP.md`;var zC=class extends ix{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:RC,treatWorkspaceRootProjectAsProject:!0,indexignore:`.warpindexignore`,cleanup:{delete:{project:{files:[RC]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,aiAgentIgnoreConfigFiles:r}=e.collectedOutputContext,a=this.getConcreteProjects(e),o=this.getProjectPromptOutputProjects(e),s=this.shouldSkipDueToPlugin(e,ox.AgentsOutput),c=new Set(this.selectPromptScopes(e,[`project`,`global`])),l=this.extractGlobalMemoryContent(e);if(s){if(n!=null&&c.has(`global`))for(let r of o){let a=this.resolveProjectRootDir(e,r);a!=null&&t.push({path:i.join(a,RC),scope:`project`,source:{content:n.content}})}}else for(let n of o){let r=this.resolveProjectRootDir(e,n);if(r!=null){if(n.rootMemoryPrompt!=null&&c.has(`project`)){let e=this.combineGlobalWithContent(l,n.rootMemoryPrompt.content);t.push({path:i.join(r,RC),scope:`project`,source:{content:e}})}if(n.childMemoryPrompts!=null&&c.has(`project`))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{content:e.content}})}}let u=this.getIgnoreOutputPath(),d=this.indexignore==null?void 0:r?.find(e=>e.fileName===this.indexignore);if(u!=null&&d!=null)for(let e of a){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:this.resolvePath(n.basePath,n.path,u),scope:`project`,source:{content:d.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 BC=`.codeium/windsurf`,VC=`global_workflows`,HC=`memories`,UC=`skills`,WC=`.windsurf`;var GC=class extends ix{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:BC,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[ox.AgentsOutput],indexignore:`.codeiumignore`,commands:{subDir:VC,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:UC},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:a,rules:o,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);a!=null&&u.has(`global`)&&t.push({path:i.join(l,HC,`global_rules.md`),scope:`global`,source:{kind:`globalMemory`,content:a.content}});let m=(e,n,r)=>{let a=this.getSkillName(r),o=i.join(e,UC,a);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:r}}),r.childDocs!=null)for(let e of r.childDocs)t.push({path:i.join(o,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:i.join(o,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:i.join(n,WC);if(r==null)continue;let a=$(f.items,t.projectConfig,`skills`);for(let e of a)m(r,`project`,e)}if(f.selectedScope===`global`){let e=$(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),a=r==null?void 0:i.join(r,WC);if(a==null)continue;let o=$(d.items,n.projectConfig,`commands`);for(let e of o)t.push({path:i.join(a,`workflows`,this.transformCommandName(e,h)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=$(d.items,c,`commands`);for(let n of e)t.push({path:i.join(l,VC,this.transformCommandName(n,h)),scope:`global`,source:{kind:`command`,command:n}})}if(o!=null&&o.length>0){let n=new Set(this.selectRuleScopes(e,o)),r=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(n.has(`global`))for(let e of r)t.push({path:i.join(l,HC,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 a=eb($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,WC,`rules`,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rule`,rule:e}})}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of p){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.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`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`?f.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 i.join(this.getHomeDir(),BC)}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(`
233
+ `).trim()}normalizeContent(e){let t=e.trim();return t.length===0?``:`${t}\n`}};const iC=`AGENTS.md`,aC=`prompts`,oC=`skills`,sC=`.aiassistant`;var cC=class extends ix{constructor(){super(`JetBrainsAIAssistantCodexOutputPlugin`,{outputFileName:iC,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:aC,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:oC},dependsOn:[ox.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:a,aiAgentIgnoreConfigFiles:o}=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=a==null?{items:[]}:this.selectSingleScopeItems(a,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 a=i.join(r,sC,`rules`);if(n.rootMemoryPrompt!=null&&t.push({path:i.join(a,`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:i.join(a,this.buildChildRuleFileName(r)),scope:`project`,source:{kind:`projectRuleContent`,content:this.buildGlobRuleContent(r,e)}})}let h=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,oC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skill`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,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 a=i.join(r,sC,`codex`);if(f.selectedScope===`project`){let e=$(f.items,n.projectConfig,`commands`);for(let n of e)t.push({path:i.join(a,aC,this.transformCommandName(n,m)),scope:`project`,source:{kind:`command`,command:n}})}p.selectedScope===`project`&&h(a,`project`,$(p.items,n.projectConfig,`skills`))}if(l.length>0){if(n!=null&&u.has(`global`))for(let e of l)t.push({path:i.join(e,iC),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let e=f.selectedScope===`global`?$(f.items,d,`commands`):[],r=p.selectedScope===`global`?$(p.items,d,`skills`):[];for(let n of l){for(let r of e)t.push({path:i.join(n,aC,this.transformCommandName(r,m)),scope:`global`,source:{kind:`command`,command:r}});h(n,`global`,r)}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:o?.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:i.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`?f.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:i.join(e,iC),kind:`file`,scope:`global`},{path:i.join(e,aC),kind:`directory`,scope:`global`},{path:i.join(e,oC),kind:`directory`,scope:`global`}]),a=t.delete??[];return{...t,delete:[...a,...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(this.getSkillName(e),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 lC=`.idea`;var uC=class extends ix{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(e){let t=e.dir.path;if(e.type===Zh.EditorConfig)return`.editorconfig`;if(e.type!==Zh.IntellijIDEA)return this.basename(t);let n=t.indexOf(lC);return n===-1?this.joinPath(lC,`codeStyles`,this.basename(t)):t.slice(Math.max(0,n))}};const dC=[`name`,`description`,`developer_instructions`],fC=[`scope`,`seriName`,`argumentHint`,`color`,`namingCase`,`model`];function pC(e){let t={...e};return delete t.allowTools,delete t.allowedTools,t}function mC(e,t){let n=pC(t);return n.name=e,n}const hC={globalConfigDir:`.codex`,outputFileName:`AGENTS.md`,commands:{subDir:`prompts`,scopeRemap:{project:`global`},transformFrontMatter:(e,t)=>pC(t.sourceFrontMatter)},subagents:{subDir:`agents`,sourceScopes:[`project`],scopeRemap:{global:`project`},ext:`.toml`,artifactFormat:`toml`,bodyFieldName:`developer_instructions`,excludedFrontMatterFields:fC,transformFrontMatter:(e,t)=>mC(pb(e),t.sourceFrontMatter),fieldOrder:dC},cleanup:{delete:{project:{dirs:[`.codex/agents`]},global:{files:[`.codex/AGENTS.md`],dirs:[`.codex/prompts`]}},protect:{global:{dirs:[`.codex/skills/.system`]}}},wslMirrors:[`~/.codex/config.toml`,`~/.codex/auth.json`],dependsOn:[ox.AgentsOutput],capabilities:{prompt:{scopes:[`global`],singleScope:!1},commands:{scopes:[`global`],singleScope:!0},subagents:{scopes:[`project`],singleScope:!0}}};var gC=class extends ix{constructor(){super(`CodexCLIOutputPlugin`,hC)}};const _C=`AGENTS.md`,vC=`commands`,yC=`agents`,bC=`skills`;function xC(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 SC=class extends ix{constructor(){super(`OpencodeCLIOutputPlugin`,{globalConfigDir:`.config/opencode`,outputFileName:_C,treatWorkspaceRootProjectAsProject:!0,commands:{subDir:vC,transformFrontMatter:xC},subagents:{subDir:yC},skills:{subDir:bC},cleanup:{delete:{project:{files:[_C,`.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:[ox.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:a,skills:o}=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=a==null?{items:[]}:this.selectSingleScopeItems(a,this.subAgentsConfig.sourceScopes,e=>this.resolveSubAgentSourceScope(e),this.getTopicScopeOverride(e,`subagents`)),p=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),m=o==null?{items:[]}:this.selectSingleScopeItems(o,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`));n!=null&&c.has(`global`)&&t.push({path:i.join(s,_C),scope:`global`,source:{kind:`globalMemory`,content:n.content}});let h=(e,n,r)=>{if(r.length===0)return;let a=Dx(r,this.log);a.size!==0&&t.push({path:i.join(e,`opencode.json`),scope:n,source:{kind:`mcpConfig`,mcpServers:Ox(a,Ax)}})},g=(e,n,r)=>{for(let a of r){let r=this.validateAndNormalizeSkillName(this.getSkillName(a)),o=i.join(e,bC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a,normalizedSkillName:r}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.dir.path.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillReference`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,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:i.join(r,_C),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 a=i.join(r,`.opencode`),o=$(d.items,n.projectConfig,`commands`);if(d.selectedScope===`project`)for(let e of o)t.push({path:i.join(a,vC,this.transformCommandName(e,_)),scope:`project`,source:{kind:`command`,command:e}});let s=$(f.items,n.projectConfig,`subAgents`);if(f.selectedScope===`project`)for(let e of s)t.push({path:i.join(a,yC,this.transformSubAgentName(e)),scope:`project`,source:{kind:`subAgent`,agent:e}});let c=$(p.items,n.projectConfig,`skills`);p.selectedScope===`project`&&g(a,`project`,c);let l=$(m.items,n.projectConfig,`skills`);m.selectedScope===`project`&&h(a,`project`,l)}if(d.selectedScope===`global`){let e=$(d.items,u,`commands`);for(let n of e)t.push({path:i.join(s,vC,this.transformCommandName(n,_)),scope:`global`,source:{kind:`command`,command:n}})}if(f.selectedScope===`global`){let e=$(f.items,u,`subAgents`);for(let n of e)t.push({path:i.join(s,yC,this.transformSubAgentName(n)),scope:`global`,source:{kind:`subAgent`,agent:n}})}return p.selectedScope===`global`&&g(s,`global`,$(p.items,u,`skills`)),m.selectedScope===`global`&&h(s,`global`,$(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`?f.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 CC=`rules`,wC=`commands`,TC=`skills`,EC=`glob`,DC=`glob`;function OC(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 kC=class extends ix{constructor(){super(`QoderIDEPluginOutputPlugin`,{globalConfigDir:`.qoder`,treatWorkspaceRootProjectAsProject:!0,indexignore:`.qoderignore`,commands:{subDir:wC,transformFrontMatter:OC},skills:{subDir:TC},rules:{subDir:CC,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:a,rules:o,aiAgentIgnoreConfigFiles:s}=e.collectedOutputContext,c=this.getGlobalConfigDir(),l=this.resolvePromptSourceProjectConfig(e),u=this.getTransformOptionsFromContext(e,{includeSeriesPrefix:!0}),d=new Set(o==null?[]:this.selectRuleScopes(e,o)),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=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`skills`)),g=a==null?{items:[]}:this.selectSingleScopeItems(a,this.skillsConfig.sourceScopes,e=>this.resolveSkillSourceScope(e),this.getTopicScopeOverride(e,`mcp`)??this.getTopicScopeOverride(e,`skills`)),_=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,TC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,e.relativePath),scope:n,source:{kind:`skillResource`,content:e.content,encoding:e.encoding}})}},v=(e,n,r)=>{for(let a of r){if(a.mcpConfig==null)continue;let r=i.join(e,TC,this.getSkillName(a));t.push({path:i.join(r,`mcp.json`),scope:n,source:{kind:`skillMcpConfig`,rawContent:a.mcpConfig.rawContent}})}};if(m.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(m.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,wC,this.transformCommandName(e,u)),scope:`project`,source:{kind:`command`,command:e}})}if(m.selectedScope===`global`){let e=$(m.items,l,`commands`);for(let n of e)t.push({path:i.join(c,wC,this.transformCommandName(n,u)),scope:`global`,source:{kind:`command`,command:n}})}if(h.selectedScope===`project`||g.selectedScope===`project`)for(let t of this.getProjectOutputProjects(e)){let n=this.resolveProjectConfigDir(e,t);n!=null&&(h.selectedScope===`project`&&_(n,`project`,$(h.items,t.projectConfig,`skills`)),g.selectedScope===`project`&&v(n,`project`,$(g.items,t.projectConfig,`skills`)))}if((h.selectedScope===`global`||g.selectedScope===`global`)&&(h.selectedScope===`global`&&_(c,`global`,$(h.items,l,`skills`)),g.selectedScope===`global`&&v(c,`global`,$(g.items,l,`skills`))),n!=null&&f.has(`global`))for(let r of p){let a=this.resolveProjectConfigDir(e,r);a!=null&&t.push({path:i.join(a,CC,`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:i.join(r,CC,`always.md`),scope:`project`,source:{kind:`ruleContent`,content:this.buildAlwaysRuleContent(n.rootMemoryPrompt.content,e)}}),n.childMemoryPrompts!=null))for(let a of n.childMemoryPrompts)t.push({path:i.join(r,CC,this.buildChildRuleFileName(a)),scope:`project`,source:{kind:`ruleContent`,content:this.buildGlobRuleContent(a,e)}})}if(o!=null&&o.length>0&&d.has(`project`))for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=eb($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,CC,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rulePrompt`,rule:e}})}if(o!=null&&o.length>0&&d.has(`global`)){let e=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);for(let n of e)t.push({path:i.join(c,CC,this.buildRuleFileName(n)),scope:`global`,source:{kind:`rulePrompt`,rule:n}})}let y=this.getIgnoreOutputPath(),b=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(y!=null&&b!=null)for(let n of this.getConcreteProjects(e)){let e=n.dirFromWorkspacePath;e==null||n.isPromptSourceProject===!0||t.push({path:i.join(e.basePath,e.path,y),scope:`project`,source:{kind:`ignoreFile`,content:b.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`?f.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:EC,[DC]:r,type:`user_command`},t)}buildSkillFrontMatter(e){let t=e.yamlFrontMatter;return{name:this.getSkillName(e),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:EC,[DC]:e.globs.length>0?e.globs.join(`, `):`**/*`,type:`user_command`};return this.buildMarkdownContent(e.content,n,t)}normalizeRuleScope(e){return e.scope??`global`}};function AC(e){return Gb[e??`Readme`].out}var jC=class extends ix{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=AC(e.fileKind),r=i.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 MC=`GLOBAL.md`,NC=`.trae`,PC=`commands`,FC=`skills`;var IC=class extends ix{constructor(){super(`TraeIDEOutputPlugin`,{globalConfigDir:NC,outputFileName:MC,treatWorkspaceRootProjectAsProject:!0,indexignore:`.traeignore`,commands:{subDir:PC,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:FC},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 i.join(`.trae`,`.ignore`)}getGlobalSteeringDir(){return this.joinPath(this.getGlobalConfigDir(),`steering`)}async declareOutputFiles(e){let t=[],{commands:n,skills:r,globalMemory:a,aiAgentIgnoreConfigFiles:o}=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});a!=null&&u.has(`global`)&&t.push({path:this.joinPath(this.getGlobalSteeringDir(),MC),scope:`global`,source:{kind:`globalMemory`,content:a.content}});for(let n of c){let r=this.resolveProjectRootDir(e,n);if(r!=null&&n.childMemoryPrompts!=null&&u.has(`project`))for(let a of n.childMemoryPrompts){let n=(a.workingChildDirectoryPath?.path??a.dir.path).replaceAll(`\\`,`/`).replaceAll(/^\/+|\/+$/g,``),o=this.buildProjectRelativeGlobPattern(n),s=this.buildMarkdownContent([this.buildPathGuardHint(n),``,a.content].join(`
234
+ `),{alwaysApply:!1,globs:o},e);t.push({path:i.join(r,NC,`rules`,this.buildSteeringFileName(a)),scope:`project`,source:{kind:`steeringRule`,content:s}})}}if(d.selectedScope===`project`)for(let n of this.getProjectOutputProjects(e)){let r=this.resolveProjectConfigDir(e,n);if(r==null)continue;let a=$(d.items,n.projectConfig,`commands`);for(let e of a)t.push({path:i.join(r,PC,this.transformCommandName(e,p)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=this.getGlobalConfigDir(),n=$(d.items,l,`commands`);for(let r of n)t.push({path:i.join(e,PC,this.transformCommandName(r,p)),scope:`global`,source:{kind:`command`,command:r}})}let m=(e,n,r)=>{for(let a of r){let r=this.getSkillName(a),o=i.join(e,FC,r);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:a}}),a.childDocs!=null)for(let e of a.childDocs)t.push({path:i.join(o,e.relativePath.replace(/\.mdx$/,`.md`)),scope:n,source:{kind:`skillChildDoc`,content:e.content}});if(a.resources!=null)for(let e of a.resources)t.push({path:i.join(o,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`,$(f.items,t.projectConfig,`skills`))}f.selectedScope===`global`&&m(this.getGlobalConfigDir(),`global`,$(f.items,l,`skills`));let h=this.getIgnoreOutputPath(),g=this.indexignore==null?void 0:o?.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:i.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`?f.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(`
235
+ `)}buildProjectRelativeGlobPattern(e){return e.length===0?`**/*`:`${e}/**`}};const LC=`.vscode`;var RC=class extends ix{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(e){let t=e.dir.path;if(e.type!==Zh.VSCode)return this.basename(t);let n=t.indexOf(LC);return n===-1?this.joinPath(LC,this.basename(t)):t.slice(Math.max(0,n))}};const zC=`WARP.md`;var BC=class extends ix{constructor(){super(`WarpIDEOutputPlugin`,{outputFileName:zC,treatWorkspaceRootProjectAsProject:!0,indexignore:`.warpindexignore`,cleanup:{delete:{project:{files:[zC]}}},capabilities:{prompt:{scopes:[`project`,`global`],singleScope:!1}}})}async declareOutputFiles(e){let t=[],{globalMemory:n,aiAgentIgnoreConfigFiles:r}=e.collectedOutputContext,a=this.getConcreteProjects(e),o=this.getProjectPromptOutputProjects(e),s=this.shouldSkipDueToPlugin(e,ox.AgentsOutput),c=new Set(this.selectPromptScopes(e,[`project`,`global`])),l=this.extractGlobalMemoryContent(e);if(s){if(n!=null&&c.has(`global`))for(let r of o){let a=this.resolveProjectRootDir(e,r);a!=null&&t.push({path:i.join(a,zC),scope:`project`,source:{content:n.content}})}}else for(let n of o){let r=this.resolveProjectRootDir(e,n);if(r!=null){if(n.rootMemoryPrompt!=null&&c.has(`project`)){let e=this.combineGlobalWithContent(l,n.rootMemoryPrompt.content);t.push({path:i.join(r,zC),scope:`project`,source:{content:e}})}if(n.childMemoryPrompts!=null&&c.has(`project`))for(let e of n.childMemoryPrompts)t.push({path:this.resolveFullPath(e.dir),scope:`project`,source:{content:e.content}})}}let u=this.getIgnoreOutputPath(),d=this.indexignore==null?void 0:r?.find(e=>e.fileName===this.indexignore);if(u!=null&&d!=null)for(let e of a){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:this.resolvePath(n.basePath,n.path,u),scope:`project`,source:{content:d.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 VC=`.codeium/windsurf`,HC=`global_workflows`,UC=`memories`,WC=`skills`,GC=`.windsurf`;var KC=class extends ix{constructor(){super(`WindsurfOutputPlugin`,{globalConfigDir:VC,outputFileName:``,treatWorkspaceRootProjectAsProject:!0,dependsOn:[ox.AgentsOutput],indexignore:`.codeiumignore`,commands:{subDir:HC,transformFrontMatter:(e,t)=>t.sourceFrontMatter??{}},skills:{subDir:WC},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:a,rules:o,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);a!=null&&u.has(`global`)&&t.push({path:i.join(l,UC,`global_rules.md`),scope:`global`,source:{kind:`globalMemory`,content:a.content}});let m=(e,n,r)=>{let a=this.getSkillName(r),o=i.join(e,WC,a);if(t.push({path:i.join(o,`SKILL.md`),scope:n,source:{kind:`skillMain`,skill:r}}),r.childDocs!=null)for(let e of r.childDocs)t.push({path:i.join(o,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:i.join(o,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:i.join(n,GC);if(r==null)continue;let a=$(f.items,t.projectConfig,`skills`);for(let e of a)m(r,`project`,e)}if(f.selectedScope===`global`){let e=$(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),a=r==null?void 0:i.join(r,GC);if(a==null)continue;let o=$(d.items,n.projectConfig,`commands`);for(let e of o)t.push({path:i.join(a,`workflows`,this.transformCommandName(e,h)),scope:`project`,source:{kind:`command`,command:e}})}if(d.selectedScope===`global`){let e=$(d.items,c,`commands`);for(let n of e)t.push({path:i.join(l,HC,this.transformCommandName(n,h)),scope:`global`,source:{kind:`command`,command:n}})}if(o!=null&&o.length>0){let n=new Set(this.selectRuleScopes(e,o)),r=o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`global`);if(n.has(`global`))for(let e of r)t.push({path:i.join(l,UC,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 a=eb($(o.filter(e=>this.normalizeSourceScope(this.normalizeRuleScope(e))===`project`),n.projectConfig,`rules`),n.projectConfig);for(let e of a)t.push({path:i.join(r,GC,`rules`,this.buildRuleFileName(e)),scope:`project`,source:{kind:`rule`,rule:e}})}}let g=this.getIgnoreOutputPath(),_=this.indexignore==null?void 0:s?.find(e=>e.fileName===this.indexignore);if(g!=null&&_!=null)for(let e of p){let n=e.dirFromWorkspacePath;n==null||e.isPromptSourceProject===!0||t.push({path:i.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`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`?f.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 i.join(this.getHomeDir(),VC)}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(`
236
236
  `).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(`
237
- `)}};function KC(e,t){let r=i.join(e,`.git`),a=n.existsSync(r);return a?t?.info(`version control detected`,{path:r}):t?.warn(ft({code:`AINDEX_VERSION_CONTROL_MISSING`,title:`Aindex root is not under version control`,rootCause:z(`tnmsc did not find a .git directory under "${e}".`),exactFix:z(`Initialize git in "${e}" or place the aindex inside an existing git repository.`),possibleFixes:[z("Run `git init` in the aindex root if the directory should be versioned.")],details:{rootPath:e,gitPath:r}})),{hasGit:a,gitPath:r}}function qC(){return Jt()}var JC=class{logger;constructor(e={}){this.logger=wn(`ConfigLoader`)}getSearchPaths(e=t.cwd()){let n=Gt();if(!n.isWsl)return[Jt()];if(this.logger.info(`wsl environment detected`,{effectiveHomeDir:n.effectiveHomeDir}),n.selectedGlobalConfigPath==null)throw Error(`WSL host config file not found under "${n.windowsUsersRoot}/*/.aindex/.tnmsc.json".`);return this.logger.info(`using wsl host global config`,{path:n.selectedGlobalConfigPath}),[Jt()]}loadFromFile(e){let t=this.resolveTilde(e);try{if(!n.existsSync(t))return{config:{},source:null,found:!1};let e=n.readFileSync(t,`utf8`),r=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:r,source:t,found:!0}}catch(e){return this.logger.warn(B({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=t.cwd()){let n=this.getSearchPaths(e),r=[];for(let e of n){let t=this.loadFromFile(e);t.found&&r.push(t)}return{config:this.mergeConfigs(r.map(e=>e.config)),sources:r.map(e=>e.source).filter(e=>e!==null),found:r.length>0}}parseConfig(e,t){let n;try{n=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}let r=Fb.safeParse(n);if(r.success)return r.data;let i=r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);throw Error(`Config validation failed in ${t}:\n${i.join(`
238
- `)}`)}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),o=this.mergeWindowsOptions(e.windows,t.windows);return{...e,...t,...n==null?{}:{aindex:n},...r==null?{}:{outputScopes:r},...i==null?{}:{frontMatter:i},...a==null?{}:{cleanupProtection:a},...o==null?{}:{windows:o}}},{})}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??[]]}}mergeWindowsOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t,...e.wsl2!=null||t.wsl2!=null?{wsl2:{...e.wsl2,...t.wsl2}}:{}}}resolveTilde(e){return e.startsWith(`~`)?Yt(e):e}};let YC=null;function XC(e){return(e||!YC)&&(YC=new JC(e)),YC}var ZC=class extends Xg{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(B({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(B({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
237
+ `)}};function qC(e,t){let r=i.join(e,`.git`),a=n.existsSync(r);return a?t?.info(`version control detected`,{path:r}):t?.warn(ft({code:`AINDEX_VERSION_CONTROL_MISSING`,title:`Aindex root is not under version control`,rootCause:z(`tnmsc did not find a .git directory under "${e}".`),exactFix:z(`Initialize git in "${e}" or place the aindex inside an existing git repository.`),possibleFixes:[z("Run `git init` in the aindex root if the directory should be versioned.")],details:{rootPath:e,gitPath:r}})),{hasGit:a,gitPath:r}}function JC(){return Jt()}var YC=class{logger;constructor(e={}){this.logger=wn(`ConfigLoader`)}getSearchPaths(e=t.cwd()){let n=Gt();if(!n.isWsl)return[Jt()];if(this.logger.info(`wsl environment detected`,{effectiveHomeDir:n.effectiveHomeDir}),n.selectedGlobalConfigPath==null)throw Error(`WSL host config file not found under "${n.windowsUsersRoot}/*/.aindex/.tnmsc.json".`);return this.logger.info(`using wsl host global config`,{path:n.selectedGlobalConfigPath}),[Jt()]}loadFromFile(e){let t=this.resolveTilde(e);try{if(!n.existsSync(t))return{config:{},source:null,found:!1};let e=n.readFileSync(t,`utf8`),r=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:r,source:t,found:!0}}catch(e){return this.logger.warn(B({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=t.cwd()){let n=this.getSearchPaths(e),r=[];for(let e of n){let t=this.loadFromFile(e);t.found&&r.push(t)}return{config:this.mergeConfigs(r.map(e=>e.config)),sources:r.map(e=>e.source).filter(e=>e!==null),found:r.length>0}}parseConfig(e,t){let n;try{n=JSON.parse(e)}catch(e){throw e instanceof SyntaxError?Error(`Invalid JSON in ${t}: ${e.message}`):e}let r=Fb.safeParse(n);if(r.success)return r.data;let i=r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);throw Error(`Config validation failed in ${t}:\n${i.join(`
238
+ `)}`)}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),o=this.mergeWindowsOptions(e.windows,t.windows);return{...e,...t,...n==null?{}:{aindex:n},...r==null?{}:{outputScopes:r},...i==null?{}:{frontMatter:i},...a==null?{}:{cleanupProtection:a},...o==null?{}:{windows:o}}},{})}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??[]]}}mergeWindowsOptions(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t,...e.wsl2!=null||t.wsl2!=null?{wsl2:{...e.wsl2,...t.wsl2}}:{}}}resolveTilde(e){return e.startsWith(`~`)?Yt(e):e}};let XC=null;function ZC(e){return(e||!XC)&&(XC=new YC(e)),XC}var QC=class extends Xg{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(B({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(B({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
239
239
  `)?`\r
240
240
  `:`
241
- `}collect(e){return{}}};const QC=[`skills`,`commands`,`agents`,`app`];var $C=class extends Xg{constructor(){super(`OrphanFileCleanupEffectInputCapability`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}buildProtectedDeletionGuard(e){return Ug({workspaceDir:e.workspaceDir,aindexDir:e.aindexDir,rules:[...Bg(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 QC){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,s=n.join(r,`dist`);if(!t.existsSync(s))return i.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:s}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=a.aindex,l={skills:c?.skills?.src??`skills`,commands:c?.commands?.src??`commands`,agents:c?.subAgents?.src??`subagents`,app:c?.app?.src??`app`},u=this.buildDeletionPlan(e,s,l),d=this.buildProtectedDeletionGuard(e),f=qg(u.filesToDelete,d),p=qg(u.dirsToDelete,d),m=[...f.violations,...p.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath));if(m.length>0)return{success:!1,description:`Protected deletion guard blocked orphan cleanup for ${m.length} path(s)`,deletedFiles:[],deletedDirs:[],error:new hg(`orphan-file-cleanup`,m)};if(o)return{success:!0,description:`Would delete ${f.safePaths.length} files and ${p.safePaths.length} directories`,deletedFiles:[...f.safePaths],deletedDirs:[...p.safePaths].sort((e,t)=>t.length-e.length)};let h=[],g=[],_=[...u.errors];for(let e of f.safePaths)try{t.unlinkSync(e),h.push(e),i.debug({action:`orphan-cleanup`,deleted:e})}catch(t){_.push({path:e,error:t}),i.warn(B({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[...p.safePaths].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),g.push(e),i.debug({action:`orphan-cleanup`,deletedDir:e})}catch(t){_.push({path:e,error:t}),i.warn(B({code:`ORPHAN_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Orphan cleanup could not delete a directory`,operation:`delete`,targetKind:`orphan directory`,path:e,error:t}))}let v=_.length>0;return{success:!v,description:`Deleted ${h.length} files and ${g.length} directories`,deletedFiles:h,deletedDirs:g,...v&&{error:Error(`${_.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(B({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===``?[...ux.map(i=>e.join(t,r,n,`SKILL${i}`)),...ux.map(i=>e.join(t,r,n,`skill${i}`))]:ux.map(a=>e.join(t,r,n,o,`${i}${a}`))}case`commands`:case`agents`:case`app`:return a===`.`?ux.map(n=>e.join(t,r,`${i}${n}`)):ux.map(n=>e.join(t,r,a,`${i}${n}`));default:return[]}}collect(e){return{}}},ew=class extends Xg{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(B({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(B({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(B({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`)&&!fx(e)}collect(e){return{}}};const tw=/export\s+default\s*\{([\s\S]*?)\}/u,nw=/description\s*:\s*['"`]([^'"`]+)['"`]/u,rw=/name\s*:\s*['"`]([^'"`]+)['"`]/u,iw=/displayName\s*:\s*['"`]([^'"`]+)['"`]/u,aw=/keywords\s*:\s*\[([^\]]+)\]/u,ow=/author\s*:\s*['"`]([^'"`]+)['"`]/u,sw=/version\s*:\s*['"`]([^'"`]+)['"`]/u;function cw(e){let t={},n=tw.exec(e);if(n?.[1]==null)return t;let r=n[1],i=nw.exec(r);i?.[1]!=null&&(t.description=i[1]);let a=rw.exec(r);a?.[1]!=null&&(t.name=a[1]);let o=iw.exec(r);o?.[1]!=null&&(t.displayName=o[1]);let s=aw.exec(r);s?.[1]!=null&&(t.keywords=s[1].split(`,`).map(e=>e.trim().replaceAll(/['"]/gu,``)).filter(e=>e.length>0));let c=ow.exec(r);c?.[1]!=null&&(t.author=c[1]);let l=sw.exec(r);return l?.[1]!=null&&(t.version=l[1]),t}function lw(...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}function uw(e){let{logger:t,warnedDerivedNames:n,sourcePath:r,authoredName:i,skillName:a}=e;n?.has(r)!==!0&&(n?.add(r),t.warn(dt({code:`SKILL_NAME_IGNORED`,title:`Skill authored name is ignored`,reason:z(`tnmsc ignores the authored skill name "${i}" in favor of the directory-derived name "${a}".`),configPath:r,exactFix:z("Remove the `name` field from the skill front matter or exported metadata.",`Rename the skill directory if you need a different skill name.`),details:{authoredName:i,derivedName:a}})))}const dw={".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`},fw=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 pw(e){return fw.has(e.toLowerCase())}function mw(e){return dw[e.toLowerCase()]}function hw(...e){return i.join(...e).replaceAll(`\\`,`/`)}var gw=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`||fx(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`||fx(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=Mh(n),a=Nh((await xy(n,{globalScope:this.ctx.globalScope,extractMetadata:!0,basePath:i.dirname(t),filePath:t})).content);return bx(a,t),{type:Yh.SkillChildDoc,content:a,length:a.length,filePathKind:Xh.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},relativePath:e,dir:{pathKind:Xh.Relative,path:e,basePath:this.ctx.skillDir,getDirectoryName:()=>i.dirname(e),getAbsolutePath:()=>t}}}catch(n){throw this.ctx.logger.error(mt({code:`SKILL_CHILD_DOC_COMPILE_FAILED`,title:`Failed to compile skill child doc`,diagnosticText:Cx(n,{operation:`Failed to compile skill child doc.`,promptKind:`skill-child-doc`,logicalName:`${i.basename(this.ctx.skillDir)}/${e.replace(/\.mdx$/u,``)}`,distPath:t,srcPath:xx(i,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=i.extname(e);try{let{content:i,encoding:a,length:o}=this.readFileContent(n,r),s=mw(r);return{type:Yh.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(B({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(pw(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:f.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(B({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=hw(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 _w(e,t,n,r=``){let i=[],a=r===``?e:hw(e,r),o;try{o=t.readdirSync(a,{withFileTypes:!0})}catch(e){return n.warn(B({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(..._w(e,t,n,o));continue}!a.isFile()||!fx(a.name)||r===``&&a.name===`skill.src.mdx`||i.push(o.replace(/\.src\.mdx$/u,`.mdx`))}return i}function vw(e,t,n,r,a){if(r.existsSync(t))for(let o of _w(t,r,a)){let a=i.join(n,o);if(!r.existsSync(a))throw new gx({kind:`skill child doc`,name:`${e}/${o}`,sourcePath:i.join(t,o.replace(/\.mdx$/u,`.src.mdx`)),expectedDistPath:a})}}function yw(e,t,n){let r=i.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(pt({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(dt({code:`SKILL_MCP_CONFIG_INVALID`,title:`Skill MCP config is missing mcpServers`,reason:z(`The skill MCP config at "${r}" does not contain a top-level mcpServers object.`),configPath:r,exactFix:z("Add a top-level `mcpServers` object to mcp.json before retrying tnmsc."),details:{skillDir:e}}));return}return{type:Yh.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(dt({code:`SKILL_MCP_CONFIG_PARSE_FAILED`,title:`Failed to parse skill MCP config`,reason:z(`tnmsc could not parse the MCP config file at "${r}".`,`Underlying error: ${t instanceof Error?t.message:String(t)}`),configPath:r,exactFix:z(`Fix the JSON syntax in mcp.json and rerun tnmsc.`),details:{skillDir:e,errorMessage:t instanceof Error?t.message:String(t)}}));return}}}async function bw(e,t,n,r,a,o,s,c,l=[],u=[],d,f,p){let{logger:m,globalScope:h,fs:g}=s,_=i.join(a,`skill.mdx`),v=g.existsSync(i.join(o,`skill.src.mdx`))?i.join(o,`skill.src.mdx`):_,y=e,b,x;if(g.existsSync(_)){y=g.readFileSync(_,`utf8`),b=Mh(y);let t=await xy(y,{globalScope:h,extractMetadata:!0,basePath:a,filePath:_});e=Nh(t.content),bx(e,_),x=t.metadata.fields}let S=lw(cw(y),f,x),C=new Set,w=b?.yamlFrontMatter?.name;typeof w==`string`&&w.trim().length>0&&C.add(w);let T=S.name;typeof T==`string`&&T.trim().length>0&&C.add(T);for(let e of C)uw({logger:m,sourcePath:v,authoredName:e,skillName:n,...p!=null&&{warnedDerivedNames:p}});let E=b?.yamlFrontMatter?.description??S?.description;if(E==null||E.trim().length===0)throw m.error(st({code:`SKILL_VALIDATION_FAILED`,title:`Skill description is required`,rootCause:z(`The skill "${n}" does not provide a non-empty description in its compiled metadata or front matter.`),exactFix:z(`Add a non-empty description field to the skill front matter or exported metadata and rebuild the skill.`),possibleFixes:[z("Set `description` in `SKILL.md` front matter."),z(`If you export metadata from code, ensure the exported description is non-empty.`)],details:{skill:n,skillDir:r,yamlDescription:b?.yamlFrontMatter?.description,exportDescription:S?.description}})),Error(`Skill "${n}" validation failed: description is required and cannot be empty`);let ee={...S,...b?.yamlFrontMatter??{},name:n,description:E},D=Bb(ee,_);if(!D.valid)throw Error(D.errors.join(`
242
- `));return{type:Yh.Skill,content:e,length:e.length,filePathKind:Xh.Relative,skillName:n,yamlFrontMatter:ee,markdownAst:b?.markdownAst,markdownContents:b?.markdownContents??[],dir:{pathKind:Xh.Relative,path:n,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,n)},...b?.rawFrontMatter!=null&&{rawFrontMatter:b.rawFrontMatter},...c!=null&&{mcpConfig:c},...l!=null&&l.length>0&&{childDocs:l},...u!=null&&u.length>0&&{resources:u},...d!=null&&{seriName:d}}}var xw=class extends Xg{constructor(){super(`SkillInputCapability`)}readMcpConfig(e,t,n){return yw(e,t,n)}async scanSkillDirectory(e,t,n,r=``,i=`srcResources`,a,o){return new gw({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=Ex(r,i,n,a),d=new Set,f=new Map,p=async e=>{let t=f.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:[],d=r.existsSync(o)?(await this.scanSkillDirectory(o,r,n,``,`srcResources`,a)).resources:[],p=yw(o,r,n);vw(e,o,l,r,n);let m={childDocs:u,resources:d,...p!=null&&{mcpConfig:p}};return f.set(e,m),m},{prompts:m,errors:h}=await u.readDirectoryStructure(s,c,{kind:Yh.Skill,entryFileName:`skill`,localeExtensions:dx,isDirectoryStructure:!0,createPrompt:async(t,n,r,a)=>{let o=i.join(c,r),{childDocs:l,resources:u,mcpConfig:f}=await p(r);return bw(t,n,r,c,o,i.join(s,r),e,f,l,u,void 0,a,d)}});for(let e of h)n.warn(B({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(h.length>0)throw Error(h.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
243
- `));for(let e of m){let t=e.dist?.prompt;t!=null&&l.push(t)}return{skills:l}}},Sw=class e extends Xg{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 m.parse(n)}catch(n){o.warn(dt({code:`AINDEX_PROJECT_JSON5_INVALID`,title:`Failed to parse ${e.projectConfigFileName} for ${t}`,reason:z(`tnmsc could not parse the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:z(`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(dt({code:`AINDEX_PROJECT_JSON5_READ_FAILED`,title:`Failed to load ${e.projectConfigFileName} for ${t}`,reason:z(`tnmsc could not read the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:z(`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:Xh.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(B({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:Xh.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(B({code:`WORKSPACE_DIRECTORY_SCAN_FAILED`,title:`Failed to scan workspace directory`,operation:`scan`,targetKind:`workspace directory`,path:a,error:e}))}}return{workspace:{directory:{pathKind:Xh.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:l}}}},Cw=class extends Xg{constructor(){super(`CommandInputCapability`)}createCommandPrompt(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:Yh.Command,content:e,length:e.length,filePathKind:Xh.Relative,dir:{pathKind:Xh.Relative,path:h,basePath:r,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...f!=null&&{commandPrefix:f},commandName:p};if(g==null)return _;let v=Vb(g,m);if(!v.valid)throw Error(v.errors.join(`
241
+ `}collect(e){return{}}};const $C=[`skills`,`commands`,`agents`,`app`];var ew=class extends Xg{constructor(){super(`OrphanFileCleanupEffectInputCapability`),this.registerEffect(`orphan-file-cleanup`,this.cleanupOrphanFiles.bind(this),20)}buildProtectedDeletionGuard(e){return Ug({workspaceDir:e.workspaceDir,aindexDir:e.aindexDir,rules:[...Bg(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 $C){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,s=n.join(r,`dist`);if(!t.existsSync(s))return i.debug({action:`orphan-cleanup`,message:`dist/ directory does not exist, skipping`,distDir:s}),{success:!0,description:`dist/ directory does not exist, nothing to clean`,deletedFiles:[],deletedDirs:[]};let c=a.aindex,l={skills:c?.skills?.src??`skills`,commands:c?.commands?.src??`commands`,agents:c?.subAgents?.src??`subagents`,app:c?.app?.src??`app`},u=this.buildDeletionPlan(e,s,l),d=this.buildProtectedDeletionGuard(e),f=qg(u.filesToDelete,d),p=qg(u.dirsToDelete,d),m=[...f.violations,...p.violations].sort((e,t)=>e.targetPath.localeCompare(t.targetPath));if(m.length>0)return{success:!1,description:`Protected deletion guard blocked orphan cleanup for ${m.length} path(s)`,deletedFiles:[],deletedDirs:[],error:new hg(`orphan-file-cleanup`,m)};if(o)return{success:!0,description:`Would delete ${f.safePaths.length} files and ${p.safePaths.length} directories`,deletedFiles:[...f.safePaths],deletedDirs:[...p.safePaths].sort((e,t)=>t.length-e.length)};let h=[],g=[],_=[...u.errors];for(let e of f.safePaths)try{t.unlinkSync(e),h.push(e),i.debug({action:`orphan-cleanup`,deleted:e})}catch(t){_.push({path:e,error:t}),i.warn(B({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[...p.safePaths].sort((e,t)=>t.length-e.length))try{t.rmdirSync(e),g.push(e),i.debug({action:`orphan-cleanup`,deletedDir:e})}catch(t){_.push({path:e,error:t}),i.warn(B({code:`ORPHAN_CLEANUP_DIRECTORY_DELETE_FAILED`,title:`Orphan cleanup could not delete a directory`,operation:`delete`,targetKind:`orphan directory`,path:e,error:t}))}let v=_.length>0;return{success:!v,description:`Deleted ${h.length} files and ${g.length} directories`,deletedFiles:h,deletedDirs:g,...v&&{error:Error(`${_.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(B({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===``?[...ux.map(i=>e.join(t,r,n,`SKILL${i}`)),...ux.map(i=>e.join(t,r,n,`skill${i}`))]:ux.map(a=>e.join(t,r,n,o,`${i}${a}`))}case`commands`:case`agents`:case`app`:return a===`.`?ux.map(n=>e.join(t,r,`${i}${n}`)):ux.map(n=>e.join(t,r,a,`${i}${n}`));default:return[]}}collect(e){return{}}},tw=class extends Xg{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(B({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(B({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(B({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`)&&!fx(e)}collect(e){return{}}};const nw=/export\s+default\s*\{([\s\S]*?)\}/u,rw=/description\s*:\s*['"`]([^'"`]+)['"`]/u,iw=/name\s*:\s*['"`]([^'"`]+)['"`]/u,aw=/displayName\s*:\s*['"`]([^'"`]+)['"`]/u,ow=/keywords\s*:\s*\[([^\]]+)\]/u,sw=/author\s*:\s*['"`]([^'"`]+)['"`]/u,cw=/version\s*:\s*['"`]([^'"`]+)['"`]/u;function lw(e){let t={},n=nw.exec(e);if(n?.[1]==null)return t;let r=n[1],i=rw.exec(r);i?.[1]!=null&&(t.description=i[1]);let a=iw.exec(r);a?.[1]!=null&&(t.name=a[1]);let o=aw.exec(r);o?.[1]!=null&&(t.displayName=o[1]);let s=ow.exec(r);s?.[1]!=null&&(t.keywords=s[1].split(`,`).map(e=>e.trim().replaceAll(/['"]/gu,``)).filter(e=>e.length>0));let c=sw.exec(r);c?.[1]!=null&&(t.author=c[1]);let l=cw.exec(r);return l?.[1]!=null&&(t.version=l[1]),t}function uw(...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}function dw(e){let{logger:t,warnedDerivedNames:n,sourcePath:r,authoredName:i,skillName:a}=e;n?.has(r)!==!0&&(n?.add(r),t.warn(dt({code:`SKILL_NAME_IGNORED`,title:`Skill authored name is ignored`,reason:z(`tnmsc ignores the authored skill name "${i}" in favor of the directory-derived name "${a}".`),configPath:r,exactFix:z("Remove the `name` field from the skill front matter or exported metadata.",`Rename the skill directory if you need a different skill name.`),details:{authoredName:i,derivedName:a}})))}const fw={".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`},pw=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 mw(e){return pw.has(e.toLowerCase())}function hw(e){return fw[e.toLowerCase()]}function gw(...e){return i.join(...e).replaceAll(`\\`,`/`)}var _w=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`||fx(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`||fx(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=Mh(n),a=Nh((await xy(n,{globalScope:this.ctx.globalScope,extractMetadata:!0,basePath:i.dirname(t),filePath:t})).content);return bx(a,t),{type:Yh.SkillChildDoc,content:a,length:a.length,filePathKind:Xh.Relative,markdownAst:r.markdownAst,markdownContents:r.markdownContents,...r.rawFrontMatter!=null&&{rawFrontMatter:r.rawFrontMatter},relativePath:e,dir:{pathKind:Xh.Relative,path:e,basePath:this.ctx.skillDir,getDirectoryName:()=>i.dirname(e),getAbsolutePath:()=>t}}}catch(n){throw this.ctx.logger.error(mt({code:`SKILL_CHILD_DOC_COMPILE_FAILED`,title:`Failed to compile skill child doc`,diagnosticText:Cx(n,{operation:`Failed to compile skill child doc.`,promptKind:`skill-child-doc`,logicalName:`${i.basename(this.ctx.skillDir)}/${e.replace(/\.mdx$/u,``)}`,distPath:t,srcPath:xx(i,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=i.extname(e);try{let{content:i,encoding:a,length:o}=this.readFileContent(n,r),s=hw(r);return{type:Yh.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(B({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(mw(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:f.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(B({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=gw(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 vw(e,t,n,r=``){let i=[],a=r===``?e:gw(e,r),o;try{o=t.readdirSync(a,{withFileTypes:!0})}catch(e){return n.warn(B({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(...vw(e,t,n,o));continue}!a.isFile()||!fx(a.name)||r===``&&a.name===`skill.src.mdx`||i.push(o.replace(/\.src\.mdx$/u,`.mdx`))}return i}function yw(e,t,n,r,a){if(r.existsSync(t))for(let o of vw(t,r,a)){let a=i.join(n,o);if(!r.existsSync(a))throw new gx({kind:`skill child doc`,name:`${e}/${o}`,sourcePath:i.join(t,o.replace(/\.mdx$/u,`.src.mdx`)),expectedDistPath:a})}}function bw(e,t,n){let r=i.join(e,`mcp.json`);if(t.existsSync(r)){if(!t.statSync(r).isFile()){n.warn(pt({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(dt({code:`SKILL_MCP_CONFIG_INVALID`,title:`Skill MCP config is missing mcpServers`,reason:z(`The skill MCP config at "${r}" does not contain a top-level mcpServers object.`),configPath:r,exactFix:z("Add a top-level `mcpServers` object to mcp.json before retrying tnmsc."),details:{skillDir:e}}));return}return{type:Yh.SkillMcpConfig,mcpServers:a.mcpServers,rawContent:i}}catch(t){n.warn(dt({code:`SKILL_MCP_CONFIG_PARSE_FAILED`,title:`Failed to parse skill MCP config`,reason:z(`tnmsc could not parse the MCP config file at "${r}".`,`Underlying error: ${t instanceof Error?t.message:String(t)}`),configPath:r,exactFix:z(`Fix the JSON syntax in mcp.json and rerun tnmsc.`),details:{skillDir:e,errorMessage:t instanceof Error?t.message:String(t)}}));return}}}async function xw(e,t,n,r,a,o,s,c,l=[],u=[],d,f,p){let{logger:m,globalScope:h,fs:g}=s,_=i.join(a,`skill.mdx`),v=g.existsSync(i.join(o,`skill.src.mdx`))?i.join(o,`skill.src.mdx`):_,y=e,b,x;if(g.existsSync(_)){y=g.readFileSync(_,`utf8`),b=Mh(y);let t=await xy(y,{globalScope:h,extractMetadata:!0,basePath:a,filePath:_});e=Nh(t.content),bx(e,_),x=t.metadata.fields}let S=uw(lw(y),f,x),C=new Set,w=b?.yamlFrontMatter?.name;typeof w==`string`&&w.trim().length>0&&C.add(w);let T=S.name;typeof T==`string`&&T.trim().length>0&&C.add(T);for(let e of C)dw({logger:m,sourcePath:v,authoredName:e,skillName:n,...p!=null&&{warnedDerivedNames:p}});let E=b?.yamlFrontMatter?.description??S?.description;if(E==null||E.trim().length===0)throw m.error(st({code:`SKILL_VALIDATION_FAILED`,title:`Skill description is required`,rootCause:z(`The skill "${n}" does not provide a non-empty description in its compiled metadata or front matter.`),exactFix:z(`Add a non-empty description field to the skill front matter or exported metadata and rebuild the skill.`),possibleFixes:[z("Set `description` in `SKILL.md` front matter."),z(`If you export metadata from code, ensure the exported description is non-empty.`)],details:{skill:n,skillDir:r,yamlDescription:b?.yamlFrontMatter?.description,exportDescription:S?.description}})),Error(`Skill "${n}" validation failed: description is required and cannot be empty`);let ee={...S,...b?.yamlFrontMatter??{},name:n,description:E},D=Bb(ee,_);if(!D.valid)throw Error(D.errors.join(`
242
+ `));return{type:Yh.Skill,content:e,length:e.length,filePathKind:Xh.Relative,skillName:n,yamlFrontMatter:ee,markdownAst:b?.markdownAst,markdownContents:b?.markdownContents??[],dir:{pathKind:Xh.Relative,path:n,basePath:r,getDirectoryName:()=>n,getAbsolutePath:()=>i.join(r,n)},...b?.rawFrontMatter!=null&&{rawFrontMatter:b.rawFrontMatter},...c!=null&&{mcpConfig:c},...l!=null&&l.length>0&&{childDocs:l},...u!=null&&u.length>0&&{resources:u},...d!=null&&{seriName:d}}}var Sw=class extends Xg{constructor(){super(`SkillInputCapability`)}readMcpConfig(e,t,n){return bw(e,t,n)}async scanSkillDirectory(e,t,n,r=``,i=`srcResources`,a,o){return new _w({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=Ex(r,i,n,a),d=new Set,f=new Map,p=async e=>{let t=f.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:[],d=r.existsSync(o)?(await this.scanSkillDirectory(o,r,n,``,`srcResources`,a)).resources:[],p=bw(o,r,n);yw(e,o,l,r,n);let m={childDocs:u,resources:d,...p!=null&&{mcpConfig:p}};return f.set(e,m),m},{prompts:m,errors:h}=await u.readDirectoryStructure(s,c,{kind:Yh.Skill,entryFileName:`skill`,localeExtensions:dx,isDirectoryStructure:!0,createPrompt:async(t,n,r,a)=>{let o=i.join(c,r),{childDocs:l,resources:u,mcpConfig:f}=await p(r);return xw(t,n,r,c,o,i.join(s,r),e,f,l,u,void 0,a,d)}});for(let e of h)n.warn(B({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(h.length>0)throw Error(h.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
243
+ `));for(let e of m){let t=e.dist?.prompt;t!=null&&l.push(t)}return{skills:l}}},Cw=class e extends Xg{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 m.parse(n)}catch(n){o.warn(dt({code:`AINDEX_PROJECT_JSON5_INVALID`,title:`Failed to parse ${e.projectConfigFileName} for ${t}`,reason:z(`tnmsc could not parse the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:z(`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(dt({code:`AINDEX_PROJECT_JSON5_READ_FAILED`,title:`Failed to load ${e.projectConfigFileName} for ${t}`,reason:z(`tnmsc could not read the ${e.projectConfigFileName} file for "${t}".`,`Underlying error: ${n instanceof Error?n.message:String(n)}`),configPath:s,exactFix:z(`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:Xh.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(B({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:Xh.Relative,path:s.name,basePath:a,getDirectoryName:()=>s.name,getAbsolutePath:()=>i.resolve(a,s.name)}})}}catch(e){n.error(B({code:`WORKSPACE_DIRECTORY_SCAN_FAILED`,title:`Failed to scan workspace directory`,operation:`scan`,targetKind:`workspace directory`,path:a,error:e}))}}return{workspace:{directory:{pathKind:Xh.Absolute,path:a,getDirectoryName:()=>i.basename(a)},projects:l}}}},ww=class extends Xg{constructor(){super(`CommandInputCapability`)}createCommandPrompt(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:Yh.Command,content:e,length:e.length,filePathKind:Xh.Relative,dir:{pathKind:Xh.Relative,path:h,basePath:r,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...f!=null&&{commandPrefix:f},commandName:p};if(g==null)return _;let v=Vb(g,m);if(!v.valid)throw Error(v.errors.join(`
244
244
  `));return Object.assign(_,{yamlFrontMatter:g}),g.seriName!=null&&Object.assign(_,{seriName:g.seriName}),g.scope===`global`&&Object.assign(_,{globalOnly:!0}),_}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 Ex(i,r,n,a).readFlatFiles(s,c,{kind:Yh.Command,localeExtensions:dx,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(B({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(`
245
- `));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}}},ww=class extends Xg{constructor(){super(`EditorConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[],o=mg(Zh.EditorConfig,`.editorconfig`,i,n,{command:e.runtimeCommand,workspaceDir:r});return o!=null&&a.push(o),{editorConfigFiles:a}}},Tw=class extends Xg{constructor(){super(`GitExcludeInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=fg(n,tg,{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})}},Ew=class extends Xg{constructor(){super(`GitIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=fg(n,eg,{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})}},Dw=class extends Xg{constructor(){super(`GlobalMemoryInputCapability`)}async collect(e){let{userConfigOptions:n,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(n),s=qC(),c=Kt(),l=this.resolveAindexPath(n.aindex.globalPrompt.dist,o);if(!r.existsSync(l))return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_MISSING`,title:`Global memory prompt is missing`,path:l,expectedKind:`compiled global memory prompt file`,actualState:`path does not exist`})),{};if(!r.statSync(l).isFile())return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_NOT_FILE`,title:`Global memory prompt path is not a file`,path:l,expectedKind:`compiled global memory prompt file`,actualState:`path exists but is not a regular file`})),{};let u=r.readFileSync(l,`utf8`),d=Mh(u),f;try{f=(await xy(u,{...a!=null&&{globalScope:a},extractMetadata:!0,basePath:i.dirname(l),filePath:l})).content,bx(f,l)}catch(e){throw e instanceof a_&&(this.log.error(mt({code:`GLOBAL_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile global memory prompt`,diagnosticText:Cx(e,{operation:`Failed to compile global memory prompt.`,promptKind:`global-memory`,logicalName:`global-memory`,distPath:l}),details:{promptKind:`global-memory`,distPath:l}})),e instanceof s_&&this.log.error(dt({code:`GLOBAL_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Global memory prompt references missing config variables`,reason:z(`The global memory prompt uses scope variables that are not defined in "${s}".`),configPath:s,exactFix:z(`Add the missing variables to "${s}" and rerun tnmsc.`),possibleFixes:[z("If you reference `{profile.name}`, define `profile.name` in the config file.")],details:{promptPath:l,errorMessage:e.message}})),t.exit(1)),e}return this.log.debug({action:`collect`,path:l,contentLength:f.length}),{globalMemory:{type:Yh.GlobalMemory,content:f,length:f.length,filePathKind:Xh.Relative,...d.rawFrontMatter!=null&&{rawFrontMatter:d.rawFrontMatter},markdownAst:d.markdownAst,markdownContents:d.markdownContents,dir:{pathKind:Xh.Relative,path:i.basename(l),basePath:i.dirname(l),getDirectoryName:()=>i.basename(l),getAbsolutePath:()=>l},parentDirectoryPath:{type:Qh.UserHome,directory:{pathKind:Xh.Relative,path:``,basePath:c,getDirectoryName:()=>i.basename(c),getAbsolutePath:()=>c}}}}}},Ow=class extends Xg{constructor(){super(`JetBrainsConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`],o=[];for(let t of a){let a=mg(Zh.IntellijIDEA,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{jetbrainsConfigFiles:o}}};const kw=`agt.mdx`,Aw=[`node_modules`,`.git`];var jw=class extends Xg{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,n,r,i){let{fs:a,path:o,logger:s}=e;if(!(!a.existsSync(n)||!a.statSync(n).isFile()))try{let e=a.readFileSync(n,`utf8`),c=Mh(e),l;try{let{content:t}=await xy(e,{globalScope:r,extractMetadata:!0,basePath:o.dirname(n),filePath:n});l=t,bx(l,n)}catch(e){if(e instanceof a_){if(s.error(mt({code:`WORKSPACE_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile workspace root memory prompt`,diagnosticText:Cx(e,{operation:`Failed to compile workspace root memory prompt.`,promptKind:`workspace-root-memory`,logicalName:n,distPath:n}),details:{promptKind:`workspace-root-memory`,distPath:n}})),e instanceof s_){let t=qC();s.error(dt({code:`WORKSPACE_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Workspace root memory prompt references missing config variables`,reason:z(`The workspace root memory prompt uses scope variables that are not defined in "${t}".`),configPath:t,exactFix:z(`Define the missing variables in "${t}" and rerun tnmsc.`),details:{promptPath:n,errorMessage:e.message}}))}t.exit(1)}throw e}let u={type:Yh.ProjectRootMemory,content:l,length:l.length,filePathKind:Xh.Relative,...c.yamlFrontMatter!=null&&{yamlFrontMatter:c.yamlFrontMatter},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:Xh.Root,path:``,getDirectoryName:()=>``}};return{name:`__workspace__`,isWorkspaceRootProject:!0,...i!=null&&{projectConfig:i},rootMemoryPrompt:u}}catch(e){s.error(B({code:`WORKSPACE_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read workspace root memory prompt`,operation:`read`,targetKind:`workspace root memory prompt`,path:n,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,n,r){let{fs:i,path:a,logger:o}=e,s=a.join(n,kw);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=Mh(e),c;try{let{content:t}=await xy(e,{globalScope:r,extractMetadata:!0,basePath:n,filePath:s});c=t,bx(c,s)}catch(e){if(e instanceof a_){if(o.error(mt({code:`PROJECT_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project root memory prompt`,diagnosticText:Cx(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 s_){let t=qC();o.error(dt({code:`PROJECT_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project root memory prompt references missing config variables`,reason:z(`The project root memory prompt uses scope variables that are not defined in "${t}".`),configPath:t,exactFix:z(`Define the missing variables in "${t}" and rerun tnmsc.`),details:{promptPath:s,errorMessage:e.message}}))}t.exit(1)}throw e}return{type:Yh.ProjectRootMemory,content:c,length:c.length,filePathKind:Xh.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:Xh.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(B({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(B({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()||Aw.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,kw);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,n,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,kw);try{let e=o.readFileSync(l,`utf8`),u=Mh(e),d;try{let{content:t}=await xy(e,{globalScope:a,extractMetadata:!0,basePath:r,filePath:l});d=t,bx(d,l)}catch(e){if(e instanceof a_){if(c.error(mt({code:`PROJECT_CHILD_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project child memory prompt`,diagnosticText:Cx(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 s_){let t=qC();c.error(dt({code:`PROJECT_CHILD_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project child memory prompt references missing config variables`,reason:z(`The project child memory prompt uses scope variables that are not defined in "${t}".`),configPath:t,exactFix:z(`Define the missing variables in "${t}" and rerun tnmsc.`),details:{promptPath:l,errorMessage:e.message}}))}t.exit(1)}throw e}let f=s.relative(n,r),p=s.join(i,f),m=s.basename(r);return{type:Yh.ProjectChildrenMemory,content:d,length:d.length,filePathKind:Xh.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:Xh.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:Xh.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(B({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 Mw=Object.entries(Gb);var Nw=class extends Xg{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(B({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,n,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``;for(let[e,{src:f}]of Mw){let p=l.join(n,f);if(!(!c.existsSync(p)||!c.statSync(p).isFile()))try{let m=c.readFileSync(p,`utf8`),h;try{let{content:e}=await xy(m,{...s!=null&&{globalScope:s},extractMetadata:!0,basePath:n,filePath:p});h=e,bx(h,p)}catch(n){if(n instanceof a_){if(u.error(mt({code:`README_PROMPT_COMPILE_FAILED`,title:`Failed to compile readme-family prompt`,diagnosticText:Cx(n,{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}})),n instanceof s_){let e=qC();u.error(dt({code:`README_SCOPE_VARIABLES_MISSING`,title:`Readme-family prompt references missing config variables`,reason:z(`The readme-family prompt uses scope variables that are not defined in "${e}".`),configPath:e,exactFix:z(`Define the missing variables in "${e}" and rerun tnmsc.`),details:{promptPath:p,errorMessage:n.message}}))}t.exit(1)}throw n}let g=d?r:l.join(r,a),_={pathKind:Xh.Relative,path:g,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,g)},v={pathKind:Xh.Relative,path:l.dirname(p),basePath:i,getDirectoryName:()=>l.basename(l.dirname(p)),getAbsolutePath:()=>l.dirname(p)};o.push({type:Yh.Readme,content:h,length:h.length,filePathKind:Xh.Relative,projectName:r,targetDir:_,isRoot:d,fileKind:e,markdownContents:[],dir:v})}catch(t){u.warn(B({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 t=c.readdirSync(n,{withFileTypes:!0});for(let c of t)if(c.isDirectory()){let t=d?c.name:l.join(a,c.name),u=l.join(n,c.name);await this.collectReadmeFiles(e,u,r,i,t,o,s)}}catch(e){u.warn(B({code:`README_DIRECTORY_SCAN_FAILED`,title:`Failed to scan readme-family directory`,operation:`scan`,targetKind:`readme-family directory`,path:n,error:e}))}}},Pw=class extends Xg{constructor(){super(`RuleInputCapability`)}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.rules.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.rules.dist,o.aindexDir),{prompts:l,errors:u}=await Ex(i,r,n,a).readFlatFiles(s,c,{kind:Yh.Rule,localeExtensions:dx,isDirectoryStructure:!1,createPrompt:async(e,t,n,i)=>{let a=i,o=r.join(c,`${n}.mdx`);if(a!=null){let e=Ub(a,o);if(!e.valid)throw Error(e.errors.join(`
245
+ `));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}}},Tw=class extends Xg{constructor(){super(`EditorConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[],o=mg(Zh.EditorConfig,`.editorconfig`,i,n,{command:e.runtimeCommand,workspaceDir:r});return o!=null&&a.push(o),{editorConfigFiles:a}}},Ew=class extends Xg{constructor(){super(`GitExcludeInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=fg(n,tg,{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})}},Dw=class extends Xg{constructor(){super(`GitIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=fg(n,eg,{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})}},Ow=class extends Xg{constructor(){super(`GlobalMemoryInputCapability`)}async collect(e){let{userConfigOptions:n,fs:r,path:i,globalScope:a}=e,{aindexDir:o}=this.resolveBasePaths(n),s=JC(),c=Kt(),l=this.resolveAindexPath(n.aindex.globalPrompt.dist,o);if(!r.existsSync(l))return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_MISSING`,title:`Global memory prompt is missing`,path:l,expectedKind:`compiled global memory prompt file`,actualState:`path does not exist`})),{};if(!r.statSync(l).isFile())return this.log.warn(pt({code:`GLOBAL_MEMORY_PROMPT_NOT_FILE`,title:`Global memory prompt path is not a file`,path:l,expectedKind:`compiled global memory prompt file`,actualState:`path exists but is not a regular file`})),{};let u=r.readFileSync(l,`utf8`),d=Mh(u),f;try{f=(await xy(u,{...a!=null&&{globalScope:a},extractMetadata:!0,basePath:i.dirname(l),filePath:l})).content,bx(f,l)}catch(e){throw e instanceof a_&&(this.log.error(mt({code:`GLOBAL_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile global memory prompt`,diagnosticText:Cx(e,{operation:`Failed to compile global memory prompt.`,promptKind:`global-memory`,logicalName:`global-memory`,distPath:l}),details:{promptKind:`global-memory`,distPath:l}})),e instanceof s_&&this.log.error(dt({code:`GLOBAL_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Global memory prompt references missing config variables`,reason:z(`The global memory prompt uses scope variables that are not defined in "${s}".`),configPath:s,exactFix:z(`Add the missing variables to "${s}" and rerun tnmsc.`),possibleFixes:[z("If you reference `{profile.name}`, define `profile.name` in the config file.")],details:{promptPath:l,errorMessage:e.message}})),t.exit(1)),e}return this.log.debug({action:`collect`,path:l,contentLength:f.length}),{globalMemory:{type:Yh.GlobalMemory,content:f,length:f.length,filePathKind:Xh.Relative,...d.rawFrontMatter!=null&&{rawFrontMatter:d.rawFrontMatter},markdownAst:d.markdownAst,markdownContents:d.markdownContents,dir:{pathKind:Xh.Relative,path:i.basename(l),basePath:i.dirname(l),getDirectoryName:()=>i.basename(l),getAbsolutePath:()=>l},parentDirectoryPath:{type:Qh.UserHome,directory:{pathKind:Xh.Relative,path:``,basePath:c,getDirectoryName:()=>i.basename(c),getAbsolutePath:()=>c}}}}}},kw=class extends Xg{constructor(){super(`JetBrainsConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.idea/codeStyles/Project.xml`,`.idea/codeStyles/codeStyleConfig.xml`,`.idea/.gitignore`],o=[];for(let t of a){let a=mg(Zh.IntellijIDEA,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{jetbrainsConfigFiles:o}}};const Aw=`agt.mdx`,jw=[`node_modules`,`.git`];var Mw=class extends Xg{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,n,r,i){let{fs:a,path:o,logger:s}=e;if(!(!a.existsSync(n)||!a.statSync(n).isFile()))try{let e=a.readFileSync(n,`utf8`),c=Mh(e),l;try{let{content:t}=await xy(e,{globalScope:r,extractMetadata:!0,basePath:o.dirname(n),filePath:n});l=t,bx(l,n)}catch(e){if(e instanceof a_){if(s.error(mt({code:`WORKSPACE_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile workspace root memory prompt`,diagnosticText:Cx(e,{operation:`Failed to compile workspace root memory prompt.`,promptKind:`workspace-root-memory`,logicalName:n,distPath:n}),details:{promptKind:`workspace-root-memory`,distPath:n}})),e instanceof s_){let t=JC();s.error(dt({code:`WORKSPACE_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Workspace root memory prompt references missing config variables`,reason:z(`The workspace root memory prompt uses scope variables that are not defined in "${t}".`),configPath:t,exactFix:z(`Define the missing variables in "${t}" and rerun tnmsc.`),details:{promptPath:n,errorMessage:e.message}}))}t.exit(1)}throw e}let u={type:Yh.ProjectRootMemory,content:l,length:l.length,filePathKind:Xh.Relative,...c.yamlFrontMatter!=null&&{yamlFrontMatter:c.yamlFrontMatter},...c.rawFrontMatter!=null&&{rawFrontMatter:c.rawFrontMatter},markdownAst:c.markdownAst,markdownContents:c.markdownContents,dir:{pathKind:Xh.Root,path:``,getDirectoryName:()=>``}};return{name:`__workspace__`,isWorkspaceRootProject:!0,...i!=null&&{projectConfig:i},rootMemoryPrompt:u}}catch(e){s.error(B({code:`WORKSPACE_ROOT_MEMORY_PROMPT_READ_FAILED`,title:`Failed to read workspace root memory prompt`,operation:`read`,targetKind:`workspace root memory prompt`,path:n,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,n,r){let{fs:i,path:a,logger:o}=e,s=a.join(n,Aw);if(!(!i.existsSync(s)||!i.statSync(s).isFile()))try{let e=i.readFileSync(s,`utf8`),a=Mh(e),c;try{let{content:t}=await xy(e,{globalScope:r,extractMetadata:!0,basePath:n,filePath:s});c=t,bx(c,s)}catch(e){if(e instanceof a_){if(o.error(mt({code:`PROJECT_ROOT_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project root memory prompt`,diagnosticText:Cx(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 s_){let t=JC();o.error(dt({code:`PROJECT_ROOT_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project root memory prompt references missing config variables`,reason:z(`The project root memory prompt uses scope variables that are not defined in "${t}".`),configPath:t,exactFix:z(`Define the missing variables in "${t}" and rerun tnmsc.`),details:{promptPath:s,errorMessage:e.message}}))}t.exit(1)}throw e}return{type:Yh.ProjectRootMemory,content:c,length:c.length,filePathKind:Xh.Relative,...a.yamlFrontMatter!=null&&{yamlFrontMatter:a.yamlFrontMatter},...a.rawFrontMatter!=null&&{rawFrontMatter:a.rawFrontMatter},markdownAst:a.markdownAst,markdownContents:a.markdownContents,dir:{pathKind:Xh.Root,path:``,getDirectoryName:()=>``}}}catch(e){o.error(B({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(B({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()||jw.includes(l.name))continue;let c=s.join(n,l.name),u=s.join(c,Aw);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,n,r,i,a){let{fs:o,path:s,logger:c}=e,l=s.join(r,Aw);try{let e=o.readFileSync(l,`utf8`),u=Mh(e),d;try{let{content:t}=await xy(e,{globalScope:a,extractMetadata:!0,basePath:r,filePath:l});d=t,bx(d,l)}catch(e){if(e instanceof a_){if(c.error(mt({code:`PROJECT_CHILD_MEMORY_PROMPT_COMPILE_FAILED`,title:`Failed to compile project child memory prompt`,diagnosticText:Cx(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 s_){let t=JC();c.error(dt({code:`PROJECT_CHILD_MEMORY_SCOPE_VARIABLES_MISSING`,title:`Project child memory prompt references missing config variables`,reason:z(`The project child memory prompt uses scope variables that are not defined in "${t}".`),configPath:t,exactFix:z(`Define the missing variables in "${t}" and rerun tnmsc.`),details:{promptPath:l,errorMessage:e.message}}))}t.exit(1)}throw e}let f=s.relative(n,r),p=s.join(i,f),m=s.basename(r);return{type:Yh.ProjectChildrenMemory,content:d,length:d.length,filePathKind:Xh.Relative,...u.yamlFrontMatter!=null&&{yamlFrontMatter:u.yamlFrontMatter},...u.rawFrontMatter!=null&&{rawFrontMatter:u.rawFrontMatter},markdownAst:u.markdownAst,markdownContents:u.markdownContents,dir:{pathKind:Xh.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p},workingChildDirectoryPath:{pathKind:Xh.Relative,path:f,basePath:i,getDirectoryName:()=>m,getAbsolutePath:()=>p}}}catch(e){c.error(B({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 Nw=Object.entries(Gb);var Pw=class extends Xg{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(B({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,n,r,i,a,o,s){let{fs:c,path:l,logger:u}=e,d=a===``;for(let[e,{src:f}]of Nw){let p=l.join(n,f);if(!(!c.existsSync(p)||!c.statSync(p).isFile()))try{let m=c.readFileSync(p,`utf8`),h;try{let{content:e}=await xy(m,{...s!=null&&{globalScope:s},extractMetadata:!0,basePath:n,filePath:p});h=e,bx(h,p)}catch(n){if(n instanceof a_){if(u.error(mt({code:`README_PROMPT_COMPILE_FAILED`,title:`Failed to compile readme-family prompt`,diagnosticText:Cx(n,{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}})),n instanceof s_){let e=JC();u.error(dt({code:`README_SCOPE_VARIABLES_MISSING`,title:`Readme-family prompt references missing config variables`,reason:z(`The readme-family prompt uses scope variables that are not defined in "${e}".`),configPath:e,exactFix:z(`Define the missing variables in "${e}" and rerun tnmsc.`),details:{promptPath:p,errorMessage:n.message}}))}t.exit(1)}throw n}let g=d?r:l.join(r,a),_={pathKind:Xh.Relative,path:g,basePath:i,getDirectoryName:()=>d?r:l.basename(a),getAbsolutePath:()=>l.resolve(i,g)},v={pathKind:Xh.Relative,path:l.dirname(p),basePath:i,getDirectoryName:()=>l.basename(l.dirname(p)),getAbsolutePath:()=>l.dirname(p)};o.push({type:Yh.Readme,content:h,length:h.length,filePathKind:Xh.Relative,projectName:r,targetDir:_,isRoot:d,fileKind:e,markdownContents:[],dir:v})}catch(t){u.warn(B({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 t=c.readdirSync(n,{withFileTypes:!0});for(let c of t)if(c.isDirectory()){let t=d?c.name:l.join(a,c.name),u=l.join(n,c.name);await this.collectReadmeFiles(e,u,r,i,t,o,s)}}catch(e){u.warn(B({code:`README_DIRECTORY_SCAN_FAILED`,title:`Failed to scan readme-family directory`,operation:`scan`,targetKind:`readme-family directory`,path:n,error:e}))}}},Fw=class extends Xg{constructor(){super(`RuleInputCapability`)}async collect(e){let{userConfigOptions:t,logger:n,path:r,fs:i,globalScope:a}=e,o=this.resolveBasePaths(t),s=this.resolveAindexPath(t.aindex.rules.src,o.aindexDir),c=this.resolveAindexPath(t.aindex.rules.dist,o.aindexDir),{prompts:l,errors:u}=await Ex(i,r,n,a).readFlatFiles(s,c,{kind:Yh.Rule,localeExtensions:dx,isDirectoryStructure:!1,createPrompt:async(e,t,n,i)=>{let a=i,o=r.join(c,`${n}.mdx`);if(a!=null){let e=Ub(a,o);if(!e.valid)throw Error(e.errors.join(`
246
246
  `))}let s=a?.globs??[],l=a?.scope??`project`,u=a?.seriName,d=n.replaceAll(`\\`,`/`),f=d.includes(`/`)?d.split(`/`)[0]??``:``,p=d.split(`/`).pop()??d,m={type:Yh.Rule,content:e,length:e.length,filePathKind:Xh.Relative,dir:{pathKind:Xh.Relative,path:`${n}.mdx`,basePath:c,getDirectoryName:()=>p,getAbsolutePath:()=>o},prefix:f,ruleName:p,globs:s,scope:l,markdownContents:[]};return a!=null&&Object.assign(m,{yamlFrontMatter:a}),u!=null&&Object.assign(m,{seriName:u}),m}});for(let e of u)n.warn(B({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(u.length>0)throw Error(u.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
247
- `));return{rules:l.map(e=>e.dist?.prompt).filter(e=>e!=null)}}},Fw=class extends Xg{constructor(){super(`AIAgentIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=[];for(let i of ng){let a=fg(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}}},Iw=class extends Xg{constructor(){super(`SubAgentInputCapability`)}createSubAgentPrompt(e,t,n,r,i,a,o,s){let{fs:c,logger:l,path:u}=a,{agentPrefix:d,agentName:f,canonicalName:p}=db(n),m=u.join(i,`${n}.mdx`),h=`${n}.mdx`,g=c.existsSync(u.join(r,`${n}.src.mdx`))?u.join(r,`${n}.src.mdx`):m,_=o==null?void 0:(()=>{let e={...o},t=e.name;return typeof t==`string`&&t.trim().length>0&&s?.has(g)!==!0&&(s?.add(g),l.warn(dt({code:`SUBAGENT_NAME_IGNORED`,title:`Sub-agent authored name is ignored`,reason:z(`tnmsc ignores the authored sub-agent name "${t}" in favor of the derived path name "${p}".`),configPath:g,exactFix:z("Remove the `name` field from the sub-agent front matter or exported metadata.",`Rename the sub-agent directory or file if you need a different sub-agent name.`),details:{authoredName:t,derivedName:p,logicalName:n}}))),delete e.name,e})(),v={type:Yh.SubAgent,content:e,length:e.length,filePathKind:Xh.Relative,dir:{pathKind:Xh.Relative,path:h,basePath:i,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...d!=null&&{agentPrefix:d},agentName:f,canonicalName:p};if(_==null)return v;let y=Hb(_,m);if(!y.valid)throw Error(y.errors.join(`
247
+ `));return{rules:l.map(e=>e.dist?.prompt).filter(e=>e!=null)}}},Iw=class extends Xg{constructor(){super(`AIAgentIgnoreInputCapability`)}collect(e){let{workspaceDir:t,aindexDir:n}=this.resolveBasePaths(e.userConfigOptions),r=[];for(let i of ng){let a=fg(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}}},Lw=class extends Xg{constructor(){super(`SubAgentInputCapability`)}createSubAgentPrompt(e,t,n,r,i,a,o,s){let{fs:c,logger:l,path:u}=a,{agentPrefix:d,agentName:f,canonicalName:p}=db(n),m=u.join(i,`${n}.mdx`),h=`${n}.mdx`,g=c.existsSync(u.join(r,`${n}.src.mdx`))?u.join(r,`${n}.src.mdx`):m,_=o==null?void 0:(()=>{let e={...o},t=e.name;return typeof t==`string`&&t.trim().length>0&&s?.has(g)!==!0&&(s?.add(g),l.warn(dt({code:`SUBAGENT_NAME_IGNORED`,title:`Sub-agent authored name is ignored`,reason:z(`tnmsc ignores the authored sub-agent name "${t}" in favor of the derived path name "${p}".`),configPath:g,exactFix:z("Remove the `name` field from the sub-agent front matter or exported metadata.",`Rename the sub-agent directory or file if you need a different sub-agent name.`),details:{authoredName:t,derivedName:p,logicalName:n}}))),delete e.name,e})(),v={type:Yh.SubAgent,content:e,length:e.length,filePathKind:Xh.Relative,dir:{pathKind:Xh.Relative,path:h,basePath:i,getDirectoryName:()=>h.replace(/\.mdx$/,``),getAbsolutePath:()=>m},...d!=null&&{agentPrefix:d},agentName:f,canonicalName:p};if(_==null)return v;let y=Hb(_,m);if(!y.valid)throw Error(y.errors.join(`
248
248
  `));return Object.assign(v,{yamlFrontMatter:_}),_.seriName!=null&&Object.assign(v,{seriName:_.seriName}),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.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 l=Ex(i,r,n,a),u=new Set,{prompts:d,errors:f}=await l.readFlatFiles(s,c,{kind:Yh.SubAgent,localeExtensions:dx,isDirectoryStructure:!1,createPrompt:(t,n,r,i)=>this.createSubAgentPrompt(t,n,r,s,c,e,i,u)});n.debug(`SubAgentInputCapability read complete`,{subAgentCount:d.length,errorCount:f.length});for(let e of f)n.warn(B({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(f.length>0)throw Error(f.map(e=>e.error instanceof Error?e.error.message:String(e.error)).join(`
249
- `));let p=[];for(let e of d){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;p.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`SubAgentInputCapability flattened subAgents`,{count:p.length,agents:p.map(e=>e.canonicalName)}),{subAgents:p}}},Lw=class extends Xg{constructor(){super(`VSCodeConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let t of a){let a=mg(Zh.VSCode,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{vscodeConfigFiles:o}}},Rw=class extends Xg{constructor(){super(`WorkspaceInputCapability`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,aindexDir:r}=this.resolveBasePaths(t);return{workspace:{directory:{pathKind:Xh.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},aindexDir:r}}};function zw(){return`2026.10323.10738`}const Bw=`tnmsc`;`
250
- ${Bw} v${zw()} - Memory Sync CLI
249
+ `));let p=[];for(let e of d){let t=e.dist;if(t?.prompt==null)continue;let{prompt:n,rawMdx:r}=t;p.push(r==null?n:{...n,rawMdxContent:r})}return n.debug(`SubAgentInputCapability flattened subAgents`,{count:p.length,agents:p.map(e=>e.canonicalName)}),{subAgents:p}}},Rw=class extends Xg{constructor(){super(`VSCodeConfigInputCapability`)}collect(e){let{userConfigOptions:t,fs:n}=e,{workspaceDir:r,aindexDir:i}=this.resolveBasePaths(t),a=[`.vscode/settings.json`,`.vscode/extensions.json`],o=[];for(let t of a){let a=mg(Zh.VSCode,t,i,n,{command:e.runtimeCommand,workspaceDir:r});a!=null&&o.push(a)}return{vscodeConfigFiles:o}}},zw=class extends Xg{constructor(){super(`WorkspaceInputCapability`)}collect(e){let{userConfigOptions:t}=e,{workspaceDir:n,aindexDir:r}=this.resolveBasePaths(t);return{workspace:{directory:{pathKind:Xh.Absolute,path:n,getDirectoryName:()=>i.basename(n)},projects:[]},aindexDir:r}}};function Bw(){return`2026.10324.10325`}const Vw=`tnmsc`;`
250
+ ${Vw} v${Bw()} - Memory Sync CLI
251
251
 
252
252
  Synchronize AI memory and configuration files across projects.
253
253
 
254
254
  USAGE:
255
- ${Bw} Run the sync pipeline (default)
256
- ${Bw} help Show this help message
257
- ${Bw} version Show version information
258
- ${Bw} init Deprecated; no longer initializes aindex
259
- ${Bw} dry-run Preview what would be written
260
- ${Bw} clean Remove all generated files
261
- ${Bw} clean --dry-run Preview what would be cleaned
262
- ${Bw} config key=value Set configuration value
255
+ ${Vw} Run the sync pipeline (default)
256
+ ${Vw} help Show this help message
257
+ ${Vw} version Show version information
258
+ ${Vw} init Deprecated; no longer initializes aindex
259
+ ${Vw} dry-run Preview what would be written
260
+ ${Vw} clean Remove all generated files
261
+ ${Vw} clean --dry-run Preview what would be cleaned
262
+ ${Vw} config key=value Set configuration value
263
263
 
264
264
  SUBCOMMANDS:
265
265
  help Show this help message
@@ -270,10 +270,10 @@ SUBCOMMANDS:
270
270
  config Set configuration values in global config file (~/.aindex/.tnmsc.json)
271
271
 
272
272
  ALIASES:
273
- ${Bw} --help, ${Bw} -h Same as '${Bw} help'
274
- ${Bw} --version, ${Bw} -v Same as '${Bw} version'
275
- ${Bw} clean -n Same as '${Bw} clean --dry-run'
276
- ${Bw} config key=value Set config value in global config file
273
+ ${Vw} --help, ${Vw} -h Same as '${Vw} help'
274
+ ${Vw} --version, ${Vw} -v Same as '${Vw} version'
275
+ ${Vw} clean -n Same as '${Vw} clean --dry-run'
276
+ ${Vw} config key=value Set config value in global config file
277
277
 
278
278
  LOG LEVEL OPTIONS:
279
279
  --trace Most verbose output
@@ -299,11 +299,11 @@ CONFIG OPTIONS:
299
299
  aindex.arch.src, aindex.arch.dist
300
300
 
301
301
  Examples:
302
- ${Bw} config workspaceDir=~/my-project
303
- ${Bw} config aindex.skills.src=skills
304
- ${Bw} config logLevel=debug
302
+ ${Vw} config workspaceDir=~/my-project
303
+ ${Vw} config aindex.skills.src=skills
304
+ ${Vw} config logLevel=debug
305
305
 
306
306
  CONFIGURATION:
307
307
  Configure via plugin.config.ts in your project root.
308
308
  See documentation for detailed configuration options.
309
- `.trim();const Vw=new Set([`help`,`version`,`init`,`dry-run`,`clean`,`config`,`plugins`]),Hw=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),Uw=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function Ww(e){let t=[...e],n=t[0];n!=null&&Gw(n)&&t.shift();let r=t[0];return r!=null&&Kw(r)&&t.shift(),t}function Gw(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 Kw(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}function qw(e,t){if(e==null)return t;let n=Uw.get(e)??4;return(Uw.get(t)??4)<n?t:e}function Jw(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=Hw.get(a);if(o!=null){t.logLevel=qw(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,Vw.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}const Yw={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 Xw(e,t){return t==null?e??[]:e==null?t:[...e,...t]}function Zw(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 Qw(e,t){return t==null?e:e==null?t:Zw(e,t)}function $w(e,t,n){switch(n){case`concat`:return Xw(e,t);case`override`:return t??e;case`mergeProjects`:return Qw(e,t);default:return t??e}}function eT(e,t){let n={};for(let[r,i]of Object.entries(Yw)){let a=$w(i.getter(e),i.getter(t),i.strategy);a!=null&&(n[r]=a)}return n}function tT(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 nT(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.at(-1);if(e==null)return[...n];let t=a.indexOf(e);return a.slice(t)}i.clear(),a.length=0}return[...n]}function rT(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 nx(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();if(e==null)continue;let t=n.get(e);if(t==null)continue;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 rx(nT(e,r))}function iT(){return[new ew,new $C,new ZC]}function aT(){return[new Rw,new Sw,new Lw,new Ow,new ww,new xw,new Cw,new Iw,new Pw,new Dw,new jw,new Nw,new Ew,new Tw,new Fw]}function oT(e){if(e==null||e.length===0)return`execute`;let t=Jw(Ww(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 sT(e){let{pipelineArgs:t,userConfigOptions:r,userConfig:a,capabilities:o,includeBuiltinEffects:s=!0}=e,c=wn(`InputRuntime`,r.logLevel),l=oT(t),u={logger:c,userConfigOptions:r,fs:n,path:i,glob:it.default},d=rT([...s?iT():[],...o??aT()]),f=new ob({userConfig:a}).collect(),p=new cb;p.setGlobalScope(f),c.debug(`global scope collected`,{osInfo:{platform:f.os.platform,arch:f.os.arch,shellKind:f.os.shellKind},hasProfile:Object.keys(f.profile).length>0,hasTool:Object.keys(f.tool).length>0});let m=new Map,h={};for(let e of d){let t=tT(e,m,eT),n={...u,dependencyContext:t,...l==null?{}:{runtimeCommand:l},globalScope:f,scopeRegistry:p},r=e;r.executeEffects!=null&&await r.executeEffects(n,!1);let i=await e.collect(n);m.set(e.name,i),h=eT(h,i);let a=e;if(a.getRegisteredScopes!=null){let t=a.getRegisteredScopes();for(let{namespace:n,values:r}of t)p.register(n,r,sb.PluginRegistered),c.debug(`input capability scope registered`,{capability:e.name,namespace:n,keys:Object.keys(r)})}}return h}function cT(e){return`declarativeOutput`in e}function lT(e){return`collect`in e&&!cT(e)}const uT={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:`app/global.src.mdx`,dist:`dist/global.mdx`},workspacePrompt:{src:`app/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:{},windows:{},plugins:[]};function dT(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.windows==null?{}:{windows:e.windows},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function fT(...e){return e.reduce((e,t)=>pT(e,t),{...uT})}function pT(e,t){let n=t.plugins,r=t.commandSeriesOptions,i=t.outputScopes,a=t.frontMatter,o=t.cleanupProtection,s=t.windows;return{...e,...t,aindex:mT(e.aindex,t.aindex),plugins:[...e.plugins,...n??[]],commandSeriesOptions:hT(e.commandSeriesOptions,r),outputScopes:_T(e.outputScopes,i),frontMatter:vT(e.frontMatter,a),cleanupProtection:yT(e.cleanupProtection,o),windows:bT(e.windows,s)}}function mT(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 hT(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 gT(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}function _T(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=gT(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}function vT(e,t){return t==null?e:{...e,...t}}function yT(e,t){return t==null?e??{}:e==null?t:{rules:[...e.rules??[],...t.rules??[]]}}function bT(e,t){if(t==null)return e??{};if(e==null)return t;let n=e.wsl2,r=t.wsl2;return{...e,...t,...n!=null||r!=null?{wsl2:{...n,...r}}:{}}}function xT(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e||`cwd`in e||`pipelineArgs`in e}async function ST(e={}){let t,n,r,i,a;xT(e)?({pluginOptions:r={},cwd:n,configLoaderOptions:i,pipelineArgs:a}={pluginOptions:e.pluginOptions,cwd:e.cwd,configLoaderOptions:e.configLoaderOptions,pipelineArgs:e.pipelineArgs},t=e.loadUserConfig??!0):(r=e,t=!0,i=void 0,a=void 0);let o=Object.hasOwn(r,`plugins`),s=r.plugins,c={},l=!1,u=[],d;if(t)try{let e=XC(i).load(n);l=e.found,u=e.sources,e.found&&(c=dT(e.config),d=e.config)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to load user config: ${t}`)}let f=fT(c,r),{plugins:p=[],logLevel:m}=f,h=wn(`defineConfig`,m);l?h.info(`user config loaded`,{sources:u}):h.info(`no user config found, using defaults/programmatic options`,{workspaceDir:f.workspaceDir,aindexDir:f.aindex.dir,logLevel:f.logLevel});let g=p.filter(cT),_=p.filter(lT);Qb(g,f);let v=await sT({userConfigOptions:f,..._.length>0?{capabilities:_}:{},includeBuiltinEffects:!(_.length>0||o&&(s?.length??0)===0),...a==null?{}:{pipelineArgs:a},...d==null?{}:{userConfig:d}});if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y=Wb({workspace:v.workspace,...v.vscodeConfigFiles!=null&&{vscodeConfigFiles:v.vscodeConfigFiles},...v.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:v.jetbrainsConfigFiles},...v.editorConfigFiles!=null&&{editorConfigFiles:v.editorConfigFiles},...v.commands!=null&&{commands:v.commands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.rules!=null&&{rules:v.rules},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.aindexDir!=null&&{aindexDir:v.aindexDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}});return v.aindexDir!=null&&KC(v.aindexDir,h),{context:y,outputPlugins:g,userConfigOptions:f}}const CT=`GLOBAL.md`;var wT=class extends ix{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:CT,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(),CT),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}};async function TT(e=t.argv){return ST({pipelineArgs:e,pluginOptions:{plugins:[new zS,new VS,new hC,new cC,new QS,new nC,new LS,new xC,new OC,new FC,new wT,new zC,new GC,new XS,new rC,new uC,new eC,new LC,new AC]}})}function ET(e){let t=e.slice(2),n=`execute`,r=!1,i=!1;for(let e of t)e===`--json`||e===`-j`?r=!0:e===`--dry-run`||e===`-n`?i=!0:e.startsWith(`-`)||(n=e);return{subcommand:n,json:r,dryRun:i}}function DT(e,t){switch(e){case`execute`:return new DS;case`dry-run`:return new ES;case`clean`:return t?new Xx:new Yx;case`plugins`:return new AS;default:return new DS}}async function OT(){let{subcommand:e,json:n,dryRun:r}=ET(t.argv);n&&xn(`silent`);let i=await TT(t.argv),a=DT(e,r);n&&(new Set([`plugins`]).has(a.name)||(a=new OS(a)));let{context:o,outputPlugins:s,userConfigOptions:c}=i,l=wn(`PluginRuntime`),u=PS(l),d=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e}),f=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e,registeredPluginNames:Array.from(s,e=>e.name)}),p={logger:l,outputPlugins:[...s],collectedOutputContext:o,userConfigOptions:c,createCleanContext:d,createWriteContext:f};(await a.execute(p)).success||t.exit(1)}function kT(e){let n=e instanceof Error?e.message:String(e);wn(`plugin-runtime`,`silent`).error(gt(`plugin-runtime`,e)),t.stdout.write(`${JSON.stringify(kS({success:!1,filesAffected:0,dirsAffected:0,message:n},Cn()))}\n`)}OT().catch(e=>{let{json:n}=ET(t.argv);n&&(kT(e),t.exit(1)),wn(`plugin-runtime`,`error`).error(gt(`plugin-runtime`,e)),t.exit(1)});export{};
309
+ `.trim();const Hw=new Set([`help`,`version`,`init`,`dry-run`,`clean`,`config`,`plugins`]),Uw=new Map([[`--trace`,`trace`],[`--debug`,`debug`],[`--info`,`info`],[`--warn`,`warn`],[`--error`,`error`]]),Ww=new Map([[`trace`,0],[`debug`,1],[`info`,2],[`warn`,3],[`error`,4]]);function Gw(e){let t=[...e],n=t[0];n!=null&&Kw(n)&&t.shift();let r=t[0];return r!=null&&qw(r)&&t.shift(),t}function Kw(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 qw(e){return/\.(?:m?[jt]s|cjs)$/.test(e)||/[/\\]/.test(e)&&!e.startsWith(`-`)?!0:/^(?:@[\w-]+\/)?[\w-]+$/.test(e)&&!e.startsWith(`-`)}function Jw(e,t){if(e==null)return t;let n=Ww.get(e)??4;return(Ww.get(t)??4)<n?t:e}function Yw(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=Uw.get(a);if(o!=null){t.logLevel=Jw(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,Hw.has(i)?t.subcommand=i:t.unknownCommand=i;continue}t.positional.push(i)}}return t}const Xw={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 Zw(e,t){return t==null?e??[]:e==null?t:[...e,...t]}function Qw(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 $w(e,t){return t==null?e:e==null?t:Qw(e,t)}function eT(e,t,n){switch(n){case`concat`:return Zw(e,t);case`override`:return t??e;case`mergeProjects`:return $w(e,t);default:return t??e}}function tT(e,t){let n={};for(let[r,i]of Object.entries(Xw)){let a=eT(i.getter(e),i.getter(t),i.strategy);a!=null&&(n[r]=a)}return n}function nT(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 rT(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.at(-1);if(e==null)return[...n];let t=a.indexOf(e);return a.slice(t)}i.clear(),a.length=0}return[...n]}function iT(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 nx(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();if(e==null)continue;let t=n.get(e);if(t==null)continue;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 rx(rT(e,r))}function aT(){return[new tw,new ew,new QC]}function oT(){return[new zw,new Cw,new Rw,new kw,new Tw,new Sw,new ww,new Lw,new Fw,new Ow,new Mw,new Pw,new Dw,new Ew,new Iw]}function sT(e){if(e==null||e.length===0)return`execute`;let t=Yw(Gw(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 cT(e){let{pipelineArgs:t,userConfigOptions:r,userConfig:a,capabilities:o,includeBuiltinEffects:s=!0}=e,c=wn(`InputRuntime`,r.logLevel),l=sT(t),u={logger:c,userConfigOptions:r,fs:n,path:i,glob:it.default},d=iT([...s?aT():[],...o??oT()]),f=new ob({userConfig:a}).collect(),p=new cb;p.setGlobalScope(f),c.debug(`global scope collected`,{osInfo:{platform:f.os.platform,arch:f.os.arch,shellKind:f.os.shellKind},hasProfile:Object.keys(f.profile).length>0,hasTool:Object.keys(f.tool).length>0});let m=new Map,h={};for(let e of d){let t=nT(e,m,tT),n={...u,dependencyContext:t,...l==null?{}:{runtimeCommand:l},globalScope:f,scopeRegistry:p},r=e;r.executeEffects!=null&&await r.executeEffects(n,!1);let i=await e.collect(n);m.set(e.name,i),h=tT(h,i);let a=e;if(a.getRegisteredScopes!=null){let t=a.getRegisteredScopes();for(let{namespace:n,values:r}of t)p.register(n,r,sb.PluginRegistered),c.debug(`input capability scope registered`,{capability:e.name,namespace:n,keys:Object.keys(r)})}}return h}function lT(e){return`declarativeOutput`in e}function uT(e){return`collect`in e&&!lT(e)}const dT={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:`app/global.src.mdx`,dist:`dist/global.mdx`},workspacePrompt:{src:`app/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:{},windows:{},plugins:[]};function fT(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.windows==null?{}:{windows:e.windows},...e.logLevel==null?{}:{logLevel:e.logLevel}}}function pT(...e){return e.reduce((e,t)=>mT(e,t),{...dT})}function mT(e,t){let n=t.plugins,r=t.commandSeriesOptions,i=t.outputScopes,a=t.frontMatter,o=t.cleanupProtection,s=t.windows;return{...e,...t,aindex:hT(e.aindex,t.aindex),plugins:[...e.plugins,...n??[]],commandSeriesOptions:gT(e.commandSeriesOptions,r),outputScopes:vT(e.outputScopes,i),frontMatter:yT(e.frontMatter,a),cleanupProtection:bT(e.cleanupProtection,o),windows:xT(e.windows,s)}}function hT(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 gT(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 _T(e,t){if(!(e==null&&t==null))return e==null?t:t==null?e:{...e,...t}}function vT(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=_T(n[e],r);t!=null&&(n[e]=t)}return Object.keys(n).length===0?{}:{plugins:n}}function yT(e,t){return t==null?e:{...e,...t}}function bT(e,t){return t==null?e??{}:e==null?t:{rules:[...e.rules??[],...t.rules??[]]}}function xT(e,t){if(t==null)return e??{};if(e==null)return t;let n=e.wsl2,r=t.wsl2;return{...e,...t,...n!=null||r!=null?{wsl2:{...n,...r}}:{}}}function ST(e){return`pluginOptions`in e||`configLoaderOptions`in e||`loadUserConfig`in e||`cwd`in e||`pipelineArgs`in e}async function CT(e={}){let t,n,r,i,a;ST(e)?({pluginOptions:r={},cwd:n,configLoaderOptions:i,pipelineArgs:a}={pluginOptions:e.pluginOptions,cwd:e.cwd,configLoaderOptions:e.configLoaderOptions,pipelineArgs:e.pipelineArgs},t=e.loadUserConfig??!0):(r=e,t=!0,i=void 0,a=void 0);let o=Object.hasOwn(r,`plugins`),s=r.plugins,c={},l=!1,u=[],d;if(t)try{let e=ZC(i).load(n);l=e.found,u=e.sources,e.found&&(c=fT(e.config),d=e.config)}catch(e){let t=e instanceof Error?e.message:String(e);throw Error(`Failed to load user config: ${t}`)}let f=pT(c,r),{plugins:p=[],logLevel:m}=f,h=wn(`defineConfig`,m);l?h.info(`user config loaded`,{sources:u}):h.info(`no user config found, using defaults/programmatic options`,{workspaceDir:f.workspaceDir,aindexDir:f.aindex.dir,logLevel:f.logLevel});let g=p.filter(lT),_=p.filter(uT);Qb(g,f);let v=await cT({userConfigOptions:f,..._.length>0?{capabilities:_}:{},includeBuiltinEffects:!(_.length>0||o&&(s?.length??0)===0),...a==null?{}:{pipelineArgs:a},...d==null?{}:{userConfig:d}});if(v.workspace==null)throw Error(`Workspace not initialized by any plugin`);let y=Wb({workspace:v.workspace,...v.vscodeConfigFiles!=null&&{vscodeConfigFiles:v.vscodeConfigFiles},...v.jetbrainsConfigFiles!=null&&{jetbrainsConfigFiles:v.jetbrainsConfigFiles},...v.editorConfigFiles!=null&&{editorConfigFiles:v.editorConfigFiles},...v.commands!=null&&{commands:v.commands},...v.subAgents!=null&&{subAgents:v.subAgents},...v.skills!=null&&{skills:v.skills},...v.rules!=null&&{rules:v.rules},...v.globalMemory!=null&&{globalMemory:v.globalMemory},...v.aiAgentIgnoreConfigFiles!=null&&{aiAgentIgnoreConfigFiles:v.aiAgentIgnoreConfigFiles},...v.aindexDir!=null&&{aindexDir:v.aindexDir},...v.readmePrompts!=null&&{readmePrompts:v.readmePrompts},...v.globalGitIgnore!=null&&{globalGitIgnore:v.globalGitIgnore},...v.shadowGitExclude!=null&&{shadowGitExclude:v.shadowGitExclude}});return v.aindexDir!=null&&qC(v.aindexDir,h),{context:y,outputPlugins:g,userConfigOptions:f}}const wT=`GLOBAL.md`;var TT=class extends ix{constructor(){super(`TraeCNIDEOutputPlugin`,{globalConfigDir:`.trae-cn`,outputFileName:wT,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(),wT),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}};async function ET(e=t.argv){return CT({pipelineArgs:e,pluginOptions:{plugins:[new zS,new VS,new gC,new cC,new QS,new nC,new LS,new SC,new kC,new IC,new TT,new BC,new KC,new XS,new rC,new uC,new eC,new RC,new jC]}})}function DT(e){let t=e.slice(2),n=`execute`,r=!1,i=!1;for(let e of t)e===`--json`||e===`-j`?r=!0:e===`--dry-run`||e===`-n`?i=!0:e.startsWith(`-`)||(n=e);return{subcommand:n,json:r,dryRun:i}}function OT(e,t){switch(e){case`execute`:return new DS;case`dry-run`:return new ES;case`clean`:return t?new Xx:new Yx;case`plugins`:return new AS;default:return new DS}}async function kT(){let{subcommand:e,json:n,dryRun:r}=DT(t.argv);n&&xn(`silent`);let i=await ET(t.argv),a=OT(e,r);n&&(new Set([`plugins`]).has(a.name)||(a=new OS(a)));let{context:o,outputPlugins:s,userConfigOptions:c}=i,l=wn(`PluginRuntime`),u=PS(l),d=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e}),f=e=>({logger:l,collectedOutputContext:o,pluginOptions:c,runtimeTargets:u,dryRun:e,registeredPluginNames:Array.from(s,e=>e.name)}),p={logger:l,outputPlugins:[...s],collectedOutputContext:o,userConfigOptions:c,createCleanContext:d,createWriteContext:f};(await a.execute(p)).success||t.exit(1)}function AT(e){let n=e instanceof Error?e.message:String(e);wn(`plugin-runtime`,`silent`).error(gt(`plugin-runtime`,e)),t.stdout.write(`${JSON.stringify(kS({success:!1,filesAffected:0,dirsAffected:0,message:n},Cn()))}\n`)}kT().catch(e=>{let{json:n}=DT(t.argv);n&&(AT(e),t.exit(1)),wn(`plugin-runtime`,`error`).error(gt(`plugin-runtime`,e)),t.exit(1)});export{};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@truenine/memory-sync-cli",
3
3
  "type": "module",
4
- "version": "2026.10323.10738",
4
+ "version": "2026.10324.10325",
5
5
  "description": "TrueNine Memory Synchronization CLI",
6
6
  "author": "TrueNine",
7
7
  "license": "AGPL-3.0-only",
@@ -53,11 +53,11 @@
53
53
  "zod": "^4.3.6"
54
54
  },
55
55
  "optionalDependencies": {
56
- "@truenine/memory-sync-cli-darwin-arm64": "2026.10323.10738",
57
- "@truenine/memory-sync-cli-darwin-x64": "2026.10323.10738",
58
- "@truenine/memory-sync-cli-linux-arm64-gnu": "2026.10323.10738",
59
- "@truenine/memory-sync-cli-win32-x64-msvc": "2026.10323.10738",
60
- "@truenine/memory-sync-cli-linux-x64-gnu": "2026.10323.10738"
56
+ "@truenine/memory-sync-cli-darwin-arm64": "2026.10324.10325",
57
+ "@truenine/memory-sync-cli-darwin-x64": "2026.10324.10325",
58
+ "@truenine/memory-sync-cli-linux-arm64-gnu": "2026.10324.10325",
59
+ "@truenine/memory-sync-cli-win32-x64-msvc": "2026.10324.10325",
60
+ "@truenine/memory-sync-cli-linux-x64-gnu": "2026.10324.10325"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@clack/prompts": "^1.1.0",
@@ -73,9 +73,9 @@
73
73
  "tsx": "^4.21.0",
74
74
  "vitest": "^4.1.0",
75
75
  "zod-to-json-schema": "^3.25.1",
76
- "@truenine/logger": "2026.10323.10738",
77
- "@truenine/script-runtime": "2026.10323.10738",
78
- "@truenine/md-compiler": "2026.10323.10738"
76
+ "@truenine/logger": "2026.10324.10325",
77
+ "@truenine/script-runtime": "2026.10324.10325",
78
+ "@truenine/md-compiler": "2026.10324.10325"
79
79
  },
80
80
  "scripts": {
81
81
  "build": "run-s build:deps build:napi bundle finalize:bundle generate:schema check",