@truenine/memory-sync-cli 2026.10302.10037 → 2026.10303.11058
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/CommandRegistryFactory-CY3bAciG.mjs +64 -0
- package/dist/CommandRegistryFactory-DRWte7G7.cjs +64 -0
- package/dist/commands-C8vskfc2.mjs +1 -0
- package/dist/commands-D4PBLoh0.cjs +1 -0
- package/dist/globals.d.cts +1 -1
- package/dist/globals.d.mts +1 -1
- package/dist/index.cjs +53 -114
- package/dist/index.mjs +53 -114
- package/dist/plugin-runtime.mjs +77 -75
- package/dist/tnmsc.schema.json +217 -18
- package/package.json +20 -11
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import t from"node:process";import*as n from"node:fs";import*as r from"node:path";import i from"node:path";import*as a from"node:os";import o from"node:os";import{z as s}from"zod/v3";let c=null;try{let n=e(import.meta.url),{platform:r,arch:i}=t,a={"win32-x64":[`napi-logger.win32-x64-msvc`,`win32-x64-msvc`],"linux-x64":[`napi-logger.linux-x64-gnu`,`linux-x64-gnu`],"linux-arm64":[`napi-logger.linux-arm64-gnu`,`linux-arm64-gnu`],"darwin-arm64":[`napi-logger.darwin-arm64`,`darwin-arm64`],"darwin-x64":[`napi-logger.darwin-x64`,`darwin-x64`]}[`${r}-${i}`];if(a!=null){let[e,t]=a;try{c=n(`./${e}.node`)}catch{try{c=n(`@truenine/memory-sync-cli-${t}`).logger}catch{}}}}catch{}const l={reset:`\x1B[0m`,red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,blue:`\x1B[34m`,green:`\x1B[32m`,white:`\x1B[37m`,dim:`\x1B[2m`,bgRed:`\x1B[41m`},u={red:e=>`${l.red}${e}${l.reset}`,yellow:e=>`${l.yellow}${e}${l.reset}`,cyan:e=>`${l.cyan}${e}${l.reset}`,magenta:e=>`${l.magenta}${e}${l.reset}`,gray:e=>`${l.gray}${e}${l.reset}`,blue:e=>`${l.blue}${e}${l.reset}`,green:e=>`${l.green}${e}${l.reset}`,white:e=>`${l.white}${e}${l.reset}`,dim:e=>`${l.dim}${e}${l.reset}`,bgRed:e=>`${l.bgRed}${e}${l.reset}`};let d;const ee={error:u.red,warn:u.yellow,info:u.cyan,debug:u.magenta,trace:u.gray,fatal:u.bgRed},f={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function te(e){if(e===null)return u.dim(`null`);if(e===void 0)return u.dim(`undefined`);if(typeof e==`boolean`)return u.yellow(String(e));if(typeof e==`number`)return u.blue(String(e));if(typeof e==`string`)return u.green(`"${e}"`);if(Array.isArray(e))return e.length===0?`[]`:`[${e.map(e=>te(e)).join(`,`)}]`;if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack};for(let n of Object.getOwnPropertyNames(e))n!==`name`&&n!==`message`&&n!==`stack`&&(t[n]=e[n]);return p(t)}return typeof e==`object`?p(e):String(e)}function p(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${u.magenta(`"${e}"`)}:${te(t)}`).join(`,`)}}`}function ne(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function m(e,t,n,r){let i=ne(),a=ee[e]??u.white,o=String(n),s=r!=null&&Object.keys(r).length>0,c=o===``,l={$:[i,a(e.toUpperCase()),t]},d=s?c?r:{[o]:r}:n,f=p({...l,_:d});e===`error`||e===`fatal`?console.error(f):e===`warn`?console.warn(f):e===`debug`||e===`trace`?console.debug(f):console.log(f)}function h(e,t,n){let r=f[e],i=f[n];return(n,...a)=>{r>i||(typeof n==`string`?m(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?m(e,t,``,n):m(e,t,n))}}function re(e,n){let r=n??d??t.env.LOG_LEVEL??`info`;return{error:h(`error`,e,r),warn:h(`warn`,e,r),info:h(`info`,e,r),debug:h(`debug`,e,r),trace:h(`trace`,e,r),fatal:h(`fatal`,e,r)}}function ie(e,t){if(typeof e!=`string`)return{msg:``,metaStr:JSON.stringify(e)};let n=t.length===1&&typeof t[0]==`object`&&t[0]!==null?t[0]:t.length>0?{args:t}:void 0;return{msg:e,metaStr:n==null?void 0:JSON.stringify(n)}}function ae(e){function t(e,t){return(n,...r)=>{let{msg:i,metaStr:a}=ie(n,r);a==null?e(i):t(i,a)}}return{error:t(t=>e.error(t),(t,n)=>e.errorWithMeta(t,n)),warn:t(t=>e.warn(t),(t,n)=>e.warnWithMeta(t,n)),info:t(t=>e.info(t),(t,n)=>e.infoWithMeta(t,n)),debug:t(t=>e.debug(t),(t,n)=>e.debugWithMeta(t,n)),trace:t(t=>e.trace(t),(t,n)=>e.traceWithMeta(t,n)),fatal:t(t=>e.fatal(t),(t,n)=>e.fatalWithMeta(t,n))}}function oe(e){d=e,c?.setGlobalLogLevel(e)}function g(e,t){return c==null?re(e,t):ae(c.createLogger(e,t))}var se=class{type;name;_log;get log(){return this._log??=g(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}};const ce={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`},le={},ue={AgentsOutput:`AgentsOutputPlugin`,GeminiCLIOutput:`GeminiCLIOutputPlugin`,CursorOutput:`CursorOutputPlugin`,WindsurfOutput:`WindsurfOutputPlugin`,ClaudeCodeCLIOutput:`ClaudeCodeCLIOutputPlugin`,KiroIDEOutput:`KiroCLIOutputPlugin`,OpencodeCLIOutput:`OpencodeCLIOutputPlugin`,OpenAICodexCLIOutput:`CodexCLIOutputPlugin`,DroidCLIOutput:`DroidCLIOutputPlugin`,WarpIDEOutput:`WarpIDEOutputPlugin`,TraeIDEOutput:`TraeIDEOutputPlugin`,TraeCNIDEOutput:`TraeCNIDEOutputPlugin`,QoderIDEOutput:`QoderIDEPluginOutputPlugin`,JetBrainsCodeStyleOutput:`JetBrainsIDECodeStyleConfigOutputPlugin`,JetBrainsAICodexOutput:`JetBrainsAIAssistantCodexOutputPlugin`,AgentSkillsCompactOutput:`GenericSkillsOutputPlugin`,GitExcludeOutput:`GitExcludeOutputPlugin`,ReadmeOutput:`ReadmeMdConfigFileOutputPlugin`,VSCodeOutput:`VisualStudioCodeIDEConfigOutputPlugin`,EditorConfigOutput:`EditorConfigOutputPlugin`,AntigravityOutput:`AntigravityOutputPlugin`};let _=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),de=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.Command=`Command`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e.Rule=`Rule`,e}({}),fe=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),pe=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),me=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});const v={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,RULES:`rules`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},y={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,WORKSPACE_MEMORY:`workspace.mdx`,WORKSPACE_MEMORY_SRC:`workspace.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`,AI_IGNORE:`.aiignore`,CODEIUM_IGNORE:`.codeiumignore`};v.SKILLS,v.COMMANDS,v.AGENTS,v.RULES,y.GLOBAL_MEMORY_SRC,y.WORKSPACE_MEMORY_SRC,v.SKILLS,v.COMMANDS,v.AGENTS,v.RULES,y.GLOBAL_MEMORY,y.WORKSPACE_MEMORY,v.APP,v.APP,v.IDEA,v.IDEA_CODE_STYLES,v.VSCODE,y.EDITOR_CONFIG,y.IDEA_GITIGNORE,y.IDEA_PROJECT_XML,y.IDEA_CODE_STYLE_CONFIG_XML,y.VSCODE_SETTINGS,y.VSCODE_EXTENSIONS,y.QODER_IGNORE,y.CURSOR_IGNORE,y.WARP_INDEX_IGNORE,y.AI_IGNORE,y.CODEIUM_IGNORE;const b=s.object({src:s.string(),dist:s.string()}),he=s.object({dir:s.string().default(`aindex`),skills:b,commands:b,subAgents:b,rules:b,globalPrompt:b,workspacePrompt:b,app:b,ext:b,arch:b}),ge=s.object({dir:s.string().default(`aindex`),skills:b,commands:b,subAgents:b,rules:b,globalPrompt:b,workspacePrompt:b,app:b,ext:b,arch:b}),_e=s.object({includeSeriesPrefix:s.boolean().optional(),seriesSeparator:s.string().optional()}),ve=s.object({includeSeriesPrefix:s.boolean().optional(),pluginOverrides:s.record(s.string(),_e).optional()}),ye=s.object({name:s.string().optional(),username:s.string().optional(),gender:s.string().optional(),birthday:s.string().optional()}).catchall(s.unknown()),x=s.object({version:s.string().optional(),workspaceDir:s.string().optional(),aindex:ge.optional(),shadowSourceProject:he.optional(),logLevel:s.enum([`trace`,`debug`,`info`,`warn`,`error`]).optional(),commandSeriesOptions:ve.optional(),profile:ye.optional()});function be(e){return e.aindex==null?e.shadowSourceProject==null?e:{...e,aindex:e.shadowSourceProject}:e}const xe=s.object({names:s.array(s.string()).optional()}),S=s.object({includeSeries:s.array(s.string()).optional(),subSeries:s.record(s.string(),s.array(s.string())).optional()});s.object({mcp:xe.optional(),includeSeries:s.array(s.string()).optional(),subSeries:s.record(s.string(),s.array(s.string())).optional(),rules:S.optional(),skills:S.optional(),subAgents:S.optional(),commands:S.optional()}),s.object({configFileName:s.string().optional(),searchPaths:s.array(s.string()).optional(),searchCwd:s.boolean().optional(),searchGlobal:s.boolean().optional()});var Se=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},Ce=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}};function we(e,t){let n=t==null?``:` in ${t}`,r=[],i=[];return(!(`name`in e)||e.name==null)&&r.push(`Missing required field "name"${n}`),!(`description`in e)||e.description==null?r.push(`Missing required field "description"${n}`):(typeof e.description!=`string`||e.description.trim().length===0)&&r.push(`Required field "description" cannot be empty${n}`),e.enabled??i.push(`Using default value for optional field "enabled": true${n}`),e.keywords??i.push(`Using default value for optional field "keywords": []${n}`),{valid:r.length===0,errors:r,warnings:i}}const Te={Readme:{src:`rdm.mdx`,out:`README.md`},CodeOfConduct:{src:`coc.mdx`,out:`CODE_OF_CONDUCT.md`},Security:{src:`security.mdx`,out:`SECURITY.md`}};async function C(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function w(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function T(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function E(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function D(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}let O=function(e){return e[e.Flags=0]=`Flags`,e[e.Unknown=1]=`Unknown`,e[e.Subcommand=2]=`Subcommand`,e}({});var k=class{factories=[];register(e){this.factories.push(e),this.factories.sort((e,t)=>e.priority-t.priority)}registerWithPriority(e,t){let n={priority:t,canHandle:t=>e.canHandle(t),createCommand:t=>e.createCommand(t)};this.factories.push(n),this.factories.sort((e,t)=>e.priority-t.priority)}registerAll(e){for(let t of e)this.factories.push(t);this.factories.sort((e,t)=>e.priority-t.priority)}resolve(e){for(let t of this.factories)if(t.priority<=O.Unknown&&t.canHandle(e))return t.createCommand(e);for(let t of this.factories)if(t.priority===O.Subcommand&&t.canHandle(e))return t.createCommand(e);for(let t of this.factories)if(t.canHandle(e))return t.createCommand(e);throw Error(`No command factory found for the given arguments`)}};function Ee(e){let n=t.env.XDG_DATA_HOME;return typeof n==`string`&&n.trim().length>0?n:i.join(e,`.local`,`share`)}function De(){let e=t.platform,n=o.homedir();if(e===`win32`)return t.env.LOCALAPPDATA??i.join(n,`AppData`,`Local`);if(e===`darwin`)return i.join(n,`Library`,`Application Support`);if(e===`linux`)return Ee(n);throw Error(`Unsupported platform: ${t.platform}`)}function Oe(e){try{return n.lstatSync(e).isSymbolicLink()}catch{return!1}}function ke(e){return n.lstatSync(e)}function A(e){n.mkdirSync(e,{recursive:!0})}function Ae(e){A(e)}function je(e,r,a=`dir`){if(Ae(i.dirname(r)),n.existsSync(r)){let e=n.lstatSync(r);e.isSymbolicLink()?t.platform===`win32`?n.rmSync(r,{recursive:!0,force:!0}):n.unlinkSync(r):e.isDirectory()?n.rmSync(r,{recursive:!0}):n.unlinkSync(r)}t.platform===`win32`&&a===`dir`?n.symlinkSync(e,r,`junction`):n.symlinkSync(e,r,a)}function Me(e){n.existsSync(e)&&n.lstatSync(e).isSymbolicLink()&&(t.platform===`win32`?n.rmSync(e,{recursive:!0,force:!0}):n.unlinkSync(e))}function Ne(e){if(!n.existsSync(e))return;let r=n.lstatSync(e);r.isSymbolicLink()?t.platform===`win32`?n.rmSync(e,{recursive:!0,force:!0}):n.unlinkSync(e):r.isDirectory()?n.rmSync(e,{recursive:!0,force:!0}):n.unlinkSync(e)}function Pe(e,t,r=`utf8`){A(i.dirname(e)),typeof t==`string`?n.writeFileSync(e,t,r):n.writeFileSync(e,t)}function Fe(e){let t=0,r=[];for(let i of e)try{n.existsSync(i)&&(Ne(i),t++)}catch(e){r.push({path:i,error:e})}return{deleted:t,errors:r}}function Ie(e){let t=0,r=[],i=[...e].sort((e,t)=>t.length-e.length);for(let e of i)try{n.existsSync(e)&&(n.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){r.push({path:e,error:t})}return{deleted:t,errors:r}}let j=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({});function Le(e,t,n){return{pathKind:j.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>i.join(t,e)}}function Re(e,t){let n=i.join(e.path,t);return{pathKind:j.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>i.join(e.basePath,n)}}async function M(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function N(e,t){let n=e.map(e=>r.isAbsolute(e)?e:r.resolve(e)),i=Fe(n);for(let e of n)i.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`file`,path:e});let a=i.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete file`,{path:e.path,error:n}),{path:e.path,type:`file`,error:e.error}});return{deleted:i.deleted,errors:a}}function P(e,t){let n=e.map(e=>r.isAbsolute(e)?e:r.resolve(e)),i=Ie(n);for(let e of n)i.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`directory`,path:e});let a=i.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete directory`,{path:e.path,error:n}),{path:e.path,type:`directory`,error:e.error}});return{deleted:i.deleted,errors:a}}async function F(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await C(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await M(e,await w(e,t),t),c=N(o,n),l=P(s,n);return i&&await T(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var I=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await F(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}},L=class{name=`dry-run-clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`dry-run-clean`,dryRun:!0});let i=r(!0),a=await C(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await M(n,await w(n,i),i);return this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),await T(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length}),{success:!0,filesAffected:o.length,dirsAffected:s.length,message:`Dry-run complete, no files were deleted`}}logDryRunFiles(e,t){for(let n of e){let e=r.isAbsolute(n)?n:r.resolve(n);t.info(`would delete file`,{path:e,dryRun:!0})}}logDryRunDirectories(e,t){let n=[...e].sort((e,t)=>t.length-e.length);for(let e of n){let n=r.isAbsolute(e)?e:r.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},R=class{canHandle(e){return e.subcommand===`clean`}createCommand(e){return e.dryRun?new L:new I}};const z=`.tnmsc.json`,B=`.aindex`;function V(){return r.join(a.homedir(),B,z)}function ze(){return{...le}}var H=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??z,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=g(`ConfigLoader`)}getSearchPaths(e=t.cwd()){let n=[];for(let e of this.customSearchPaths)n.push(this.resolveTilde(e));return this.searchCwd&&n.push(r.join(e,this.configFileName)),this.searchGlobal&&n.push(r.join(a.homedir(),B,this.configFileName)),n}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){let n=e instanceof Error?e.message:String(e);throw Error(`Failed to load config from ${t}: ${n}`)}}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)}if(r.length===0)throw Error(`No valid config file found. Searched: ${n.join(`, `)}`);return{config:this.mergeConfigs(r.map(e=>e.config)),sources:r.map(e=>e.source).filter(e=>e!==null),found:!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=x.safeParse(n);if(r.success)return be(r.data);let i=r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);throw Error(`Config validation failed in ${t}:\n${i.join(`
|
|
2
|
+
`)}`)}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);return{...e,...t,...n==null?{}:{aindex:n}}},{})}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}}}resolveTilde(e){return e.startsWith(`~`)?r.join(a.homedir(),e.slice(1)):e}};let U=null;function Be(e){return(e||!U)&&(U=new H(e)),U}function Ve(e){return Be().load(e)}function W(){let e=g(`ConfigLoader`),t=V();if(!n.existsSync(t)){let n=`Global config not found at ${t}. Please create it manually.`;return e.error(n),{valid:!1,exists:!1,errors:[n],shouldExit:!0}}let r;try{r=n.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),{valid:!1,exists:!0,errors:[`Failed to read config: ${r}`],shouldExit:!0}}let i;try{i=JSON.parse(r)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),{valid:!1,exists:!0,errors:[`Invalid JSON: ${r}`],shouldExit:!0}}if(typeof i!=`object`||!i||Array.isArray(i))return e.error(`global config must be a JSON object`,{path:t}),{valid:!1,exists:!0,errors:[`Config must be a JSON object`],shouldExit:!0};let a=x.safeParse(i);if(!a.success){let n=a.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);for(let r of n)e.error(`config validation error`,{path:t,error:r});return{valid:!1,exists:!0,errors:n,shouldExit:!0}}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function He(){return W()}const G=[`workspaceDir`,`aindex.skills.src`,`aindex.skills.dist`,`aindex.commands.src`,`aindex.commands.dist`,`aindex.subAgents.src`,`aindex.subAgents.dist`,`aindex.rules.src`,`aindex.rules.dist`,`aindex.globalPrompt.src`,`aindex.globalPrompt.dist`,`aindex.workspacePrompt.src`,`aindex.workspacePrompt.dist`,`aindex.app.src`,`aindex.app.dist`,`aindex.ext.src`,`aindex.ext.dist`,`aindex.arch.src`,`aindex.arch.dist`,`logLevel`];function Ue(e){return G.includes(e)}function We(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function K(){return r.join(a.homedir(),B,z)}function Ge(){let e=K();if(!n.existsSync(e))return{};try{let t=n.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function Ke(e){let t=K(),i=r.dirname(t);n.existsSync(i)||n.mkdirSync(i,{recursive:!0}),n.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}function qe(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e],n=i[t];(typeof n!=`object`||!n||Array.isArray(n))&&(i[t]={}),i=i[t]}i[r.at(-1)]=n}function Je(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r||Array.isArray(r))return;r=r[e]}return r}var q=class{name=`config`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc config key=value`),t.info(`Valid keys: ${G.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=Ge(),r=[],i=[];for(let[e,a]of this.options){if(!Ue(e)){r.push(`Invalid key: ${e} (valid keys: ${G.join(`, `)})`);continue}if(e===`logLevel`&&!We(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=Je(n,e);qe(n,e,a),o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&(Ke(n),t.info(`global config written`,{path:K()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},J=class{name=`config-show`;async execute(e){let{logger:n}=e,r=new H,i=r.load(),a=i.sources.map(e=>{let t=r.loadFromFile(e);return{path:e,layer:this.inferLayer(e),config:t.config}}),o={merged:i.config,sources:a};return t.stdout.write(`${JSON.stringify(o)}\n`),n.info(`config shown`,{sources:i.sources.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Configuration displayed (${a.length} source(s))`}}inferLayer(e){let n=t.cwd();return e.startsWith(n)?`cwd`:`global`}},Y=class{canHandle(e){return e.subcommand===`config`}createCommand(e){if(e.showFlag)return new J;let t=[];for(let n of e.positional){let e=n.indexOf(`=`);e>0&&t.push([n.slice(0,e),n.slice(e+1)])}return new q([...e.setOption,...t])}},Ye=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 E(n,i),o=await D(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),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});return 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`}}},Xe=class{canHandle(e){return e.subcommand===`dry-run`}createCommand(e){return new Ye}},Ze=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await F(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await E(n,o),c=await D(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}},Qe=class{canHandle(e){return!0}createCommand(e){return new Ze}};function X(){return`2026.10303.11058`}var $e=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${X()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const Z=`tnmsc`,et=`
|
|
3
|
+
${Z} v${X()} - Memory Sync CLI
|
|
4
|
+
|
|
5
|
+
Synchronize AI memory and configuration files across projects.
|
|
6
|
+
|
|
7
|
+
USAGE:
|
|
8
|
+
${Z} Run the sync pipeline (default)
|
|
9
|
+
${Z} help Show this help message
|
|
10
|
+
${Z} version Show version information
|
|
11
|
+
${Z} outdated Check for version updates
|
|
12
|
+
${Z} init Initialize directories and files
|
|
13
|
+
${Z} dry-run Preview what would be written
|
|
14
|
+
${Z} clean Remove all generated files
|
|
15
|
+
${Z} clean --dry-run Preview what would be cleaned
|
|
16
|
+
${Z} config key=value Set configuration value
|
|
17
|
+
|
|
18
|
+
SUBCOMMANDS:
|
|
19
|
+
help Show this help message
|
|
20
|
+
version Show version information
|
|
21
|
+
outdated Check if CLI version is outdated against npm registry
|
|
22
|
+
init Initialize directory structure based on configuration
|
|
23
|
+
dry-run Preview changes without writing files
|
|
24
|
+
clean Remove all generated output files and directories
|
|
25
|
+
config Set configuration values in global config file (~/.aindex/.tnmsc.json)
|
|
26
|
+
|
|
27
|
+
ALIASES:
|
|
28
|
+
${Z} --help, ${Z} -h Same as '${Z} help'
|
|
29
|
+
${Z} --version, ${Z} -v Same as '${Z} version'
|
|
30
|
+
${Z} clean -n Same as '${Z} clean --dry-run'
|
|
31
|
+
${Z} config key=value Set config value in global config file
|
|
32
|
+
|
|
33
|
+
LOG LEVEL OPTIONS:
|
|
34
|
+
--trace Most verbose output
|
|
35
|
+
--debug Debug information
|
|
36
|
+
--info Standard information (default)
|
|
37
|
+
--warn Warnings only
|
|
38
|
+
--error Errors only
|
|
39
|
+
|
|
40
|
+
CLEAN OPTIONS:
|
|
41
|
+
-n, --dry-run Preview cleanup without removing files
|
|
42
|
+
|
|
43
|
+
CONFIG OPTIONS:
|
|
44
|
+
key=value Set a configuration value in global config (~/.aindex/.tnmsc.json)
|
|
45
|
+
Valid keys: workspaceDir, logLevel,
|
|
46
|
+
aindex.skills.src, aindex.skills.dist,
|
|
47
|
+
aindex.commands.src, aindex.commands.dist,
|
|
48
|
+
aindex.subAgents.src, aindex.subAgents.dist,
|
|
49
|
+
aindex.rules.src, aindex.rules.dist,
|
|
50
|
+
aindex.globalPrompt.src, aindex.globalPrompt.dist,
|
|
51
|
+
aindex.workspacePrompt.src, aindex.workspacePrompt.dist,
|
|
52
|
+
aindex.app.src, aindex.app.dist,
|
|
53
|
+
aindex.ext.src, aindex.ext.dist,
|
|
54
|
+
aindex.arch.src, aindex.arch.dist
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
${Z} config workspaceDir=~/my-project
|
|
58
|
+
${Z} config aindex.skills.src=skills
|
|
59
|
+
${Z} config logLevel=debug
|
|
60
|
+
|
|
61
|
+
CONFIGURATION:
|
|
62
|
+
Configure via plugin.config.ts in your project root.
|
|
63
|
+
See documentation for detailed configuration options.
|
|
64
|
+
`.trim();var tt=class{name=`help`;async execute(e){return e.logger.info(et),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}},nt=class{priority=O.Flags;canHandle(e){return e.helpFlag||e.subcommand===`help`}createCommand(e){return new tt}};function rt(){return`@truenine/memory-sync-cli`}function it(){return`https://registry.npmjs.org/${rt()}/latest`}function at(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function ot(e,t){let n=at(e),r=at(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const st=3e3;async function ct(){let e=new AbortController,t=setTimeout(()=>e.abort(),st);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(it(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${st}ms`}:{error:e.message}:{error:`Unknown network error`}}}function lt(){return`2026.10303.11058`}async function ut(){let e=lt();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await ct();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=ot(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function dt(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${rt()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.warn(`Version check skipped: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function ft(){return new Date().getMinutes()%2==0}function pt(e){ft()&&ut().then(t=>{(t.status===`outdated`||t.error!=null)&&dt(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.warn(`Version check skipped: ${n}`)})}var Q=class{name=`outdated`;async execute(e){let t=await ut();return dt(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}},mt=class{canHandle(e){return e.subcommand===`outdated`}createCommand(e){return new Q}},ht=class{name=`plugins`;async execute(e){let{logger:n,outputPlugins:r,userConfigOptions:i}=e,a=i.plugins,o=[];for(let e of a)o.push({name:e.name,kind:e.type===_.Input?`Input`:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});let s=new Set(o.map(e=>e.name));for(let e of r)s.has(e.name)||o.push({name:e.name,kind:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});return t.stdout.write(`${JSON.stringify(o)}\n`),n.info(`plugins listed`,{count:o.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${o.length} plugin(s)`}}},gt=class{canHandle(e){return e.subcommand===`plugins`}createCommand(e){return new ht}},_t=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return e.logger.error(`unknown command`,{command:this.unknownCmd}),e.logger.info(`run "tnmsc help" for available commands`),{success:!1,filesAffected:0,dirsAffected:0,message:`Unknown command: ${this.unknownCmd}`}}},vt=class{priority=O.Unknown;canHandle(e){return e.unknownCommand!=null}createCommand(e){return new _t(e.unknownCommand)}},$=class{priority=O.Flags;canHandle(e){return e.versionFlag||e.subcommand===`version`}createCommand(e){return new $e}};function yt(){let e=new k;return e.register(new $),e.register(new nt),e.register(new vt),e.registerWithPriority(new mt,O.Subcommand),e.registerWithPriority(new Xe,O.Subcommand),e.registerWithPriority(new R,O.Subcommand),e.registerWithPriority(new gt,O.Subcommand),e.registerWithPriority(new Y,O.Subcommand),e.registerWithPriority(new Qe,O.Subcommand),e}export{pe as $,R as A,A as B,B as C,Ve as D,V as E,N as F,Pe as G,Oe as H,F as I,Te as J,k as K,Re as L,I as M,M as N,He as O,P,y as Q,Le as R,z as S,ze as T,ke as U,De as V,Me as W,Se as X,we as Y,Ce as Z,Ye as _,gt as a,ce as at,q as b,Q as c,oe as ct,tt as d,fe as et,$e as f,Xe as g,Ze as h,_t as i,ue as it,L as j,W as k,pt as l,Qe as m,$ as n,_ as nt,ht as o,se as ot,X as p,O as q,vt as r,de as rt,mt as s,g as st,yt as t,me as tt,nt as u,Y as v,Be as w,H as x,J as y,je as z};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let u=require(`node:process`);u=l(u);let d=require(`node:fs`);d=l(d);let f=require(`node:path`);f=l(f);let p=require(`node:os`);p=l(p);let ee=require(`node:module`),m=require(`zod/v3`),h=null;try{let e=(0,ee.createRequire)(e(`url`).pathToFileURL(__filename).href),{platform:t,arch:n}=u.default,r={"win32-x64":[`napi-logger.win32-x64-msvc`,`win32-x64-msvc`],"linux-x64":[`napi-logger.linux-x64-gnu`,`linux-x64-gnu`],"linux-arm64":[`napi-logger.linux-arm64-gnu`,`linux-arm64-gnu`],"darwin-arm64":[`napi-logger.darwin-arm64`,`darwin-arm64`],"darwin-x64":[`napi-logger.darwin-x64`,`darwin-x64`]}[`${t}-${n}`];if(r!=null){let[t,n]=r;try{h=e(`./${t}.node`)}catch{try{h=e(`@truenine/memory-sync-cli-${n}`).logger}catch{}}}}catch{}const g={reset:`\x1B[0m`,red:`\x1B[31m`,yellow:`\x1B[33m`,cyan:`\x1B[36m`,magenta:`\x1B[35m`,gray:`\x1B[90m`,blue:`\x1B[34m`,green:`\x1B[32m`,white:`\x1B[37m`,dim:`\x1B[2m`,bgRed:`\x1B[41m`},_={red:e=>`${g.red}${e}${g.reset}`,yellow:e=>`${g.yellow}${e}${g.reset}`,cyan:e=>`${g.cyan}${e}${g.reset}`,magenta:e=>`${g.magenta}${e}${g.reset}`,gray:e=>`${g.gray}${e}${g.reset}`,blue:e=>`${g.blue}${e}${g.reset}`,green:e=>`${g.green}${e}${g.reset}`,white:e=>`${g.white}${e}${g.reset}`,dim:e=>`${g.dim}${e}${g.reset}`,bgRed:e=>`${g.bgRed}${e}${g.reset}`};let te;const ne={error:_.red,warn:_.yellow,info:_.cyan,debug:_.magenta,trace:_.gray,fatal:_.bgRed},v={silent:0,fatal:1,error:2,warn:3,info:4,debug:5,trace:6};function y(e){if(e===null)return _.dim(`null`);if(e===void 0)return _.dim(`undefined`);if(typeof e==`boolean`)return _.yellow(String(e));if(typeof e==`number`)return _.blue(String(e));if(typeof e==`string`)return _.green(`"${e}"`);if(Array.isArray(e))return e.length===0?`[]`:`[${e.map(e=>y(e)).join(`,`)}]`;if(e instanceof Error){let t={name:e.name,message:e.message,stack:e.stack};for(let n of Object.getOwnPropertyNames(e))n!==`name`&&n!==`message`&&n!==`stack`&&(t[n]=e[n]);return b(t)}return typeof e==`object`?b(e):String(e)}function b(e){let t=Object.entries(e);return t.length===0?`{}`:`{${t.map(([e,t])=>`${_.magenta(`"${e}"`)}:${y(t)}`).join(`,`)}}`}function re(){let e=new Date;return`${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}:${String(e.getSeconds()).padStart(2,`0`)}.${String(e.getMilliseconds()).padStart(3,`0`)}`}function x(e,t,n,r){let i=re(),a=ne[e]??_.white,o=String(n),s=r!=null&&Object.keys(r).length>0,c=o===``,l={$:[i,a(e.toUpperCase()),t]},u=s?c?r:{[o]:r}:n,d=b({...l,_:u});e===`error`||e===`fatal`?console.error(d):e===`warn`?console.warn(d):e===`debug`||e===`trace`?console.debug(d):console.log(d)}function S(e,t,n){let r=v[e],i=v[n];return(n,...a)=>{r>i||(typeof n==`string`?x(e,t,n,a.length===1&&typeof a[0]==`object`&&a[0]!==null?a[0]:a.length>0?{args:a}:void 0):typeof n==`object`&&n?x(e,t,``,n):x(e,t,n))}}function ie(e,t){let n=t??te??u.default.env.LOG_LEVEL??`info`;return{error:S(`error`,e,n),warn:S(`warn`,e,n),info:S(`info`,e,n),debug:S(`debug`,e,n),trace:S(`trace`,e,n),fatal:S(`fatal`,e,n)}}function ae(e,t){if(typeof e!=`string`)return{msg:``,metaStr:JSON.stringify(e)};let n=t.length===1&&typeof t[0]==`object`&&t[0]!==null?t[0]:t.length>0?{args:t}:void 0;return{msg:e,metaStr:n==null?void 0:JSON.stringify(n)}}function oe(e){function t(e,t){return(n,...r)=>{let{msg:i,metaStr:a}=ae(n,r);a==null?e(i):t(i,a)}}return{error:t(t=>e.error(t),(t,n)=>e.errorWithMeta(t,n)),warn:t(t=>e.warn(t),(t,n)=>e.warnWithMeta(t,n)),info:t(t=>e.info(t),(t,n)=>e.infoWithMeta(t,n)),debug:t(t=>e.debug(t),(t,n)=>e.debugWithMeta(t,n)),trace:t(t=>e.trace(t),(t,n)=>e.traceWithMeta(t,n)),fatal:t(t=>e.fatal(t),(t,n)=>e.fatalWithMeta(t,n))}}function se(e){te=e,h?.setGlobalLogLevel(e)}function C(e,t){return h==null?ie(e,t):oe(h.createLogger(e,t))}var ce=class{type;name;_log;get log(){return this._log??=C(this.name),this._log}dependsOn;constructor(e,t,n){this.name=e,this.type=t,n!=null&&(this.dependsOn=n)}};const le={USER_HOME:`~`,WORKSPACE:`$WORKSPACE`},ue={},de={AgentsOutput:`AgentsOutputPlugin`,GeminiCLIOutput:`GeminiCLIOutputPlugin`,CursorOutput:`CursorOutputPlugin`,WindsurfOutput:`WindsurfOutputPlugin`,ClaudeCodeCLIOutput:`ClaudeCodeCLIOutputPlugin`,KiroIDEOutput:`KiroCLIOutputPlugin`,OpencodeCLIOutput:`OpencodeCLIOutputPlugin`,OpenAICodexCLIOutput:`CodexCLIOutputPlugin`,DroidCLIOutput:`DroidCLIOutputPlugin`,WarpIDEOutput:`WarpIDEOutputPlugin`,TraeIDEOutput:`TraeIDEOutputPlugin`,TraeCNIDEOutput:`TraeCNIDEOutputPlugin`,QoderIDEOutput:`QoderIDEPluginOutputPlugin`,JetBrainsCodeStyleOutput:`JetBrainsIDECodeStyleConfigOutputPlugin`,JetBrainsAICodexOutput:`JetBrainsAIAssistantCodexOutputPlugin`,AgentSkillsCompactOutput:`GenericSkillsOutputPlugin`,GitExcludeOutput:`GitExcludeOutputPlugin`,ReadmeOutput:`ReadmeMdConfigFileOutputPlugin`,VSCodeOutput:`VisualStudioCodeIDEConfigOutputPlugin`,EditorConfigOutput:`EditorConfigOutputPlugin`,AntigravityOutput:`AntigravityOutputPlugin`};let w=function(e){return e.Input=`Input`,e.Output=`Output`,e}({}),fe=function(e){return e.GlobalMemory=`GlobalMemory`,e.ProjectRootMemory=`ProjectRootMemory`,e.ProjectChildrenMemory=`ProjectChildrenMemory`,e.Command=`Command`,e.SubAgent=`SubAgent`,e.Skill=`Skill`,e.SkillChildDoc=`SkillChildDoc`,e.SkillResource=`SkillResource`,e.SkillMcpConfig=`SkillMcpConfig`,e.Readme=`Readme`,e.Rule=`Rule`,e}({}),pe=function(e){return e.UserHome=`UserHome`,e.External=`External`,e}({}),me=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({}),he=function(e){return e.VSCode=`VSCode`,e.IntellijIDEA=`IntellijIDEA`,e.Git=`Git`,e.EditorConfig=`EditorConfig`,e.Original=`Original`,e}({});const T={SRC:`src`,DIST:`dist`,SKILLS:`skills`,COMMANDS:`commands`,AGENTS:`agents`,RULES:`rules`,APP:`app`,IDEA:`.idea`,IDEA_CODE_STYLES:`.idea/codeStyles`,VSCODE:`.vscode`},E={GLOBAL_MEMORY:`global.mdx`,GLOBAL_MEMORY_SRC:`global.cn.mdx`,WORKSPACE_MEMORY:`workspace.mdx`,WORKSPACE_MEMORY_SRC:`workspace.cn.mdx`,EDITOR_CONFIG:`.editorconfig`,IDEA_GITIGNORE:`.idea/.gitignore`,IDEA_PROJECT_XML:`.idea/codeStyles/Project.xml`,IDEA_CODE_STYLE_CONFIG_XML:`.idea/codeStyles/codeStyleConfig.xml`,VSCODE_SETTINGS:`.vscode/settings.json`,VSCODE_EXTENSIONS:`.vscode/extensions.json`,QODER_IGNORE:`.qoderignore`,CURSOR_IGNORE:`.cursorignore`,WARP_INDEX_IGNORE:`.warpindexignore`,AI_IGNORE:`.aiignore`,CODEIUM_IGNORE:`.codeiumignore`};T.SKILLS,T.COMMANDS,T.AGENTS,T.RULES,E.GLOBAL_MEMORY_SRC,E.WORKSPACE_MEMORY_SRC,T.SKILLS,T.COMMANDS,T.AGENTS,T.RULES,E.GLOBAL_MEMORY,E.WORKSPACE_MEMORY,T.APP,T.APP,T.IDEA,T.IDEA_CODE_STYLES,T.VSCODE,E.EDITOR_CONFIG,E.IDEA_GITIGNORE,E.IDEA_PROJECT_XML,E.IDEA_CODE_STYLE_CONFIG_XML,E.VSCODE_SETTINGS,E.VSCODE_EXTENSIONS,E.QODER_IGNORE,E.CURSOR_IGNORE,E.WARP_INDEX_IGNORE,E.AI_IGNORE,E.CODEIUM_IGNORE;const D=m.z.object({src:m.z.string(),dist:m.z.string()}),ge=m.z.object({dir:m.z.string().default(`aindex`),skills:D,commands:D,subAgents:D,rules:D,globalPrompt:D,workspacePrompt:D,app:D,ext:D,arch:D}),_e=m.z.object({dir:m.z.string().default(`aindex`),skills:D,commands:D,subAgents:D,rules:D,globalPrompt:D,workspacePrompt:D,app:D,ext:D,arch:D}),ve=m.z.object({includeSeriesPrefix:m.z.boolean().optional(),seriesSeparator:m.z.string().optional()}),ye=m.z.object({includeSeriesPrefix:m.z.boolean().optional(),pluginOverrides:m.z.record(m.z.string(),ve).optional()}),be=m.z.object({name:m.z.string().optional(),username:m.z.string().optional(),gender:m.z.string().optional(),birthday:m.z.string().optional()}).catchall(m.z.unknown()),O=m.z.object({version:m.z.string().optional(),workspaceDir:m.z.string().optional(),aindex:_e.optional(),shadowSourceProject:ge.optional(),logLevel:m.z.enum([`trace`,`debug`,`info`,`warn`,`error`]).optional(),commandSeriesOptions:ye.optional(),profile:be.optional()});function xe(e){return e.aindex==null?e.shadowSourceProject==null?e:{...e,aindex:e.shadowSourceProject}:e}const Se=m.z.object({names:m.z.array(m.z.string()).optional()}),k=m.z.object({includeSeries:m.z.array(m.z.string()).optional(),subSeries:m.z.record(m.z.string(),m.z.array(m.z.string())).optional()});m.z.object({mcp:Se.optional(),includeSeries:m.z.array(m.z.string()).optional(),subSeries:m.z.record(m.z.string(),m.z.array(m.z.string())).optional(),rules:k.optional(),skills:k.optional(),subAgents:k.optional(),commands:k.optional()}),m.z.object({configFileName:m.z.string().optional(),searchPaths:m.z.array(m.z.string()).optional(),searchCwd:m.z.boolean().optional(),searchGlobal:m.z.boolean().optional()});var Ce=class extends Error{constructor(e){super(`Circular dependency detected: ${e.join(` -> `)}`),this.cycle=e,this.name=`CircularDependencyError`}},we=class extends Error{constructor(e,t){super(`Plugin "${e}" depends on non-existent plugin "${t}"`),this.pluginName=e,this.missingDependency=t,this.name=`MissingDependencyError`}};function Te(e,t){let n=t==null?``:` in ${t}`,r=[],i=[];return(!(`name`in e)||e.name==null)&&r.push(`Missing required field "name"${n}`),!(`description`in e)||e.description==null?r.push(`Missing required field "description"${n}`):(typeof e.description!=`string`||e.description.trim().length===0)&&r.push(`Required field "description" cannot be empty${n}`),e.enabled??i.push(`Using default value for optional field "enabled": true${n}`),e.keywords??i.push(`Using default value for optional field "keywords": []${n}`),{valid:r.length===0,errors:r,warnings:i}}const Ee={Readme:{src:`rdm.mdx`,out:`README.md`},CodeOfConduct:{src:`coc.mdx`,out:`CODE_OF_CONDUCT.md`},Security:{src:`security.mdx`,out:`SECURITY.md`}};async function A(e,t){let n=[],r=[],i=[],a=[];for(let o of e)o.registerProjectOutputDirs&&n.push(...await o.registerProjectOutputDirs(t)),o.registerProjectOutputFiles&&r.push(...await o.registerProjectOutputFiles(t)),o.registerGlobalOutputDirs&&i.push(...await o.registerGlobalOutputDirs(t)),o.registerGlobalOutputFiles&&a.push(...await o.registerGlobalOutputFiles(t));return{projectDirs:n,projectFiles:r,globalDirs:i,globalFiles:a}}async function De(e,t){let n=new Map;for(let r of e)n.set(r.name,{project:await r.canCleanProject?.(t)??!0,global:await r.canCleanGlobal?.(t)??!0});return n}async function Oe(e,t){for(let n of e)await n.onCleanComplete?.(t)}async function ke(e,t){let n=new Map;for(let r of e){let e=await r.canWrite?.(t)??!0;n.set(r.name,{project:e,global:e})}return n}async function j(e,t){let n=new Map;for(let r of e){let e=await r.writeProjectOutputs?.(t)??{files:[],dirs:[]},i=await r.writeGlobalOutputs?.(t)??{files:[],dirs:[]},a={files:[...e.files,...i.files],dirs:[...e.dirs,...i.dirs]};n.set(r.name,a),await r.onWriteComplete?.(t,a)}return n}let M=function(e){return e[e.Flags=0]=`Flags`,e[e.Unknown=1]=`Unknown`,e[e.Subcommand=2]=`Subcommand`,e}({});var N=class{factories=[];register(e){this.factories.push(e),this.factories.sort((e,t)=>e.priority-t.priority)}registerWithPriority(e,t){let n={priority:t,canHandle:t=>e.canHandle(t),createCommand:t=>e.createCommand(t)};this.factories.push(n),this.factories.sort((e,t)=>e.priority-t.priority)}registerAll(e){for(let t of e)this.factories.push(t);this.factories.sort((e,t)=>e.priority-t.priority)}resolve(e){for(let t of this.factories)if(t.priority<=M.Unknown&&t.canHandle(e))return t.createCommand(e);for(let t of this.factories)if(t.priority===M.Subcommand&&t.canHandle(e))return t.createCommand(e);for(let t of this.factories)if(t.canHandle(e))return t.createCommand(e);throw Error(`No command factory found for the given arguments`)}};function Ae(e){let t=u.default.env.XDG_DATA_HOME;return typeof t==`string`&&t.trim().length>0?t:f.default.join(e,`.local`,`share`)}function je(){let e=u.default.platform,t=p.default.homedir();if(e===`win32`)return u.default.env.LOCALAPPDATA??f.default.join(t,`AppData`,`Local`);if(e===`darwin`)return f.default.join(t,`Library`,`Application Support`);if(e===`linux`)return Ae(t);throw Error(`Unsupported platform: ${u.default.platform}`)}function Me(e){try{return d.lstatSync(e).isSymbolicLink()}catch{return!1}}function Ne(e){return d.lstatSync(e)}function P(e){d.mkdirSync(e,{recursive:!0})}function Pe(e){P(e)}function Fe(e,t,n=`dir`){if(Pe(f.default.dirname(t)),d.existsSync(t)){let e=d.lstatSync(t);e.isSymbolicLink()?u.default.platform===`win32`?d.rmSync(t,{recursive:!0,force:!0}):d.unlinkSync(t):e.isDirectory()?d.rmSync(t,{recursive:!0}):d.unlinkSync(t)}u.default.platform===`win32`&&n===`dir`?d.symlinkSync(e,t,`junction`):d.symlinkSync(e,t,n)}function Ie(e){d.existsSync(e)&&d.lstatSync(e).isSymbolicLink()&&(u.default.platform===`win32`?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e))}function Le(e){if(!d.existsSync(e))return;let t=d.lstatSync(e);t.isSymbolicLink()?u.default.platform===`win32`?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e):t.isDirectory()?d.rmSync(e,{recursive:!0,force:!0}):d.unlinkSync(e)}function Re(e,t,n=`utf8`){P(f.default.dirname(e)),typeof t==`string`?d.writeFileSync(e,t,n):d.writeFileSync(e,t)}function ze(e){let t=0,n=[];for(let r of e)try{d.existsSync(r)&&(Le(r),t++)}catch(e){n.push({path:r,error:e})}return{deleted:t,errors:n}}function Be(e){let t=0,n=[],r=[...e].sort((e,t)=>t.length-e.length);for(let e of r)try{d.existsSync(e)&&(d.rmSync(e,{recursive:!0,force:!0}),t++)}catch(t){n.push({path:e,error:t})}return{deleted:t,errors:n}}let F=function(e){return e.Relative=`Relative`,e.Absolute=`Absolute`,e.Root=`Root`,e}({});function Ve(e,t,n){return{pathKind:F.Relative,path:e,basePath:t,getDirectoryName:n,getAbsolutePath:()=>f.default.join(t,e)}}function He(e,t){let n=f.default.join(e.path,t);return{pathKind:F.Relative,path:n,basePath:e.basePath,getDirectoryName:()=>e.getDirectoryName(),getAbsolutePath:()=>f.default.join(e.basePath,n)}}async function I(e,t,n){let r=[],i=[];for(let a of e){let e=t.get(a.name);if(e?.project){let e=await a.registerProjectOutputFiles?.(n)??[],t=await a.registerProjectOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}if(e?.global){let e=await a.registerGlobalOutputFiles?.(n)??[],t=await a.registerGlobalOutputDirs?.(n)??[];r.push(...e.map(e=>e.getAbsolutePath())),i.push(...t.map(e=>e.getAbsolutePath()))}}return{filesToDelete:r,dirsToDelete:i}}function L(e,t){let n=e.map(e=>f.isAbsolute(e)?e:f.resolve(e)),r=ze(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`file`,path:e});let i=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete file`,{path:e.path,error:n}),{path:e.path,type:`file`,error:e.error}});return{deleted:r.deleted,errors:i}}function R(e,t){let n=e.map(e=>f.isAbsolute(e)?e:f.resolve(e)),r=Be(n);for(let e of n)r.errors.some(t=>t.path===e)||t.debug({action:`delete`,type:`directory`,path:e});let i=r.errors.map(e=>{let n=e.error instanceof Error?e.error.message:String(e.error);return t.warn(`failed to delete directory`,{path:e.path,error:n}),{path:e.path,type:`directory`,error:e.error}});return{deleted:r.deleted,errors:i}}async function z(e,t,n,r){let{executeHooks:i=!0}=r??{},a=await A(e,t);n.debug(`Collected outputs for cleanup`,{projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await I(e,await De(e,t),t),c=L(o,n),l=R(s,n);return i&&await Oe(e,t),{deletedFiles:c.deleted,deletedDirs:l.deleted,errors:[...c.errors,...l.errors]}}var B=class{name=`clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`clean`});let i=await z(n,r(!1),t);return t.info(`clean complete`,{deletedFiles:i.deletedFiles,deletedDirs:i.deletedDirs}),{success:!0,filesAffected:i.deletedFiles,dirsAffected:i.deletedDirs}}},V=class{name=`dry-run-clean`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r}=e;t.info(`running clean pipeline`,{command:`dry-run-clean`,dryRun:!0});let i=r(!0),a=await A(n,i);t.info(`collected outputs for cleanup`,{dryRun:!0,projectDirs:a.projectDirs.length,projectFiles:a.projectFiles.length,globalDirs:a.globalDirs.length,globalFiles:a.globalFiles.length});let{filesToDelete:o,dirsToDelete:s}=await I(n,await De(n,i),i);return this.logDryRunFiles(o,t),this.logDryRunDirectories(s,t),await Oe(n,i),t.info(`clean complete`,{dryRun:!0,filesAffected:o.length,dirsAffected:s.length}),{success:!0,filesAffected:o.length,dirsAffected:s.length,message:`Dry-run complete, no files were deleted`}}logDryRunFiles(e,t){for(let n of e){let e=f.isAbsolute(n)?n:f.resolve(n);t.info(`would delete file`,{path:e,dryRun:!0})}}logDryRunDirectories(e,t){let n=[...e].sort((e,t)=>t.length-e.length);for(let e of n){let n=f.isAbsolute(e)?e:f.resolve(e);t.info(`would delete directory`,{path:n,dryRun:!0})}}},H=class{canHandle(e){return e.subcommand===`clean`}createCommand(e){return e.dryRun?new V:new B}};const U=`.tnmsc.json`,W=`.aindex`;function G(){return f.join(p.homedir(),W,U)}function Ue(){return{...ue}}var K=class{configFileName;searchCwd;searchGlobal;customSearchPaths;logger;constructor(e={}){this.configFileName=e.configFileName??U,this.searchCwd=e.searchCwd??!0,this.searchGlobal=e.searchGlobal??!0,this.customSearchPaths=e.searchPaths??[],this.logger=C(`ConfigLoader`)}getSearchPaths(e=u.default.cwd()){let t=[];for(let e of this.customSearchPaths)t.push(this.resolveTilde(e));return this.searchCwd&&t.push(f.join(e,this.configFileName)),this.searchGlobal&&t.push(f.join(p.homedir(),W,this.configFileName)),t}loadFromFile(e){let t=this.resolveTilde(e);try{if(!d.existsSync(t))return{config:{},source:null,found:!1};let e=d.readFileSync(t,`utf8`),n=this.parseConfig(e,t);return this.logger.debug(`loaded`,{source:t}),{config:n,source:t,found:!0}}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`Failed to load config from ${t}: ${n}`)}}load(e=u.default.cwd()){let t=this.getSearchPaths(e),n=[];for(let e of t){let t=this.loadFromFile(e);t.found&&n.push(t)}if(n.length===0)throw Error(`No valid config file found. Searched: ${t.join(`, `)}`);return{config:this.mergeConfigs(n.map(e=>e.config)),sources:n.map(e=>e.source).filter(e=>e!==null),found:!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=O.safeParse(n);if(r.success)return xe(r.data);let i=r.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);throw Error(`Config validation failed in ${t}:\n${i.join(`
|
|
2
|
+
`)}`)}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);return{...e,...t,...n==null?{}:{aindex:n}}},{})}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}}}resolveTilde(e){return e.startsWith(`~`)?f.join(p.homedir(),e.slice(1)):e}};let q=null;function J(e){return(e||!q)&&(q=new K(e)),q}function We(e){return J().load(e)}function Ge(){let e=C(`ConfigLoader`),t=G();if(!d.existsSync(t)){let n=`Global config not found at ${t}. Please create it manually.`;return e.error(n),{valid:!1,exists:!1,errors:[n],shouldExit:!0}}let n;try{n=d.readFileSync(t,`utf8`)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`failed to read global config`,{path:t,error:r}),{valid:!1,exists:!0,errors:[`Failed to read config: ${r}`],shouldExit:!0}}let r;try{r=JSON.parse(n)}catch(n){let r=n instanceof Error?n.message:String(n);return e.error(`invalid JSON in global config`,{path:t,error:r}),{valid:!1,exists:!0,errors:[`Invalid JSON: ${r}`],shouldExit:!0}}if(typeof r!=`object`||!r||Array.isArray(r))return e.error(`global config must be a JSON object`,{path:t}),{valid:!1,exists:!0,errors:[`Config must be a JSON object`],shouldExit:!0};let i=O.safeParse(r);if(!i.success){let n=i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`);for(let r of n)e.error(`config validation error`,{path:t,error:r});return{valid:!1,exists:!0,errors:n,shouldExit:!0}}return{valid:!0,exists:!0,errors:[],shouldExit:!1}}function Ke(){return Ge()}const Y=[`workspaceDir`,`aindex.skills.src`,`aindex.skills.dist`,`aindex.commands.src`,`aindex.commands.dist`,`aindex.subAgents.src`,`aindex.subAgents.dist`,`aindex.rules.src`,`aindex.rules.dist`,`aindex.globalPrompt.src`,`aindex.globalPrompt.dist`,`aindex.workspacePrompt.src`,`aindex.workspacePrompt.dist`,`aindex.app.src`,`aindex.app.dist`,`aindex.ext.src`,`aindex.ext.dist`,`aindex.arch.src`,`aindex.arch.dist`,`logLevel`];function qe(e){return Y.includes(e)}function Je(e){return[`trace`,`debug`,`info`,`warn`,`error`].includes(e)}function X(){return f.join(p.homedir(),W,U)}function Ye(){let e=X();if(!d.existsSync(e))return{};try{let t=d.readFileSync(e,`utf8`);return JSON.parse(t)}catch{return{}}}function Xe(e){let t=X(),n=f.dirname(t);d.existsSync(n)||d.mkdirSync(n,{recursive:!0}),d.writeFileSync(t,`${JSON.stringify(e,null,2)}\n`,`utf8`)}function Ze(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e],n=i[t];(typeof n!=`object`||!n||Array.isArray(n))&&(i[t]={}),i=i[t]}i[r.at(-1)]=n}function Qe(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r||Array.isArray(r))return;r=r[e]}return r}var $e=class{name=`config`;constructor(e){this.options=e}async execute(e){let{logger:t}=e;if(this.options.length===0)return t.error(`No configuration key-value pairs provided`),t.info(`Usage: tnmsc config key=value`),t.info(`Valid keys: ${Y.join(`, `)}`),{success:!1,filesAffected:0,dirsAffected:0,message:`No options provided`};let n=Ye(),r=[],i=[];for(let[e,a]of this.options){if(!qe(e)){r.push(`Invalid key: ${e} (valid keys: ${Y.join(`, `)})`);continue}if(e===`logLevel`&&!Je(a)){r.push(`Invalid logLevel value: ${a} (must be: trace, debug, info, warn, or error)`);continue}let o=Qe(n,e);Ze(n,e,a),o!==a&&i.push(`${e}=${a}`),t.info(`configuration updated`,{key:e,value:a})}if(i.length>0&&(Xe(n),t.info(`global config written`,{path:X()})),r.length>0)for(let e of r)t.error(e);let a=r.length===0,o=a?`Configuration updated: ${i.join(`, `)}`:`Partial update: ${i.join(`, `)}. Errors: ${r.join(`, `)}`;return{success:a,filesAffected:i.length>0?1:0,dirsAffected:0,message:o}}},et=class{name=`config-show`;async execute(e){let{logger:t}=e,n=new K,r=n.load(),i=r.sources.map(e=>{let t=n.loadFromFile(e);return{path:e,layer:this.inferLayer(e),config:t.config}}),a={merged:r.config,sources:i};return u.default.stdout.write(`${JSON.stringify(a)}\n`),t.info(`config shown`,{sources:r.sources.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Configuration displayed (${i.length} source(s))`}}inferLayer(e){let t=u.default.cwd();return e.startsWith(t)?`cwd`:`global`}},tt=class{canHandle(e){return e.subcommand===`config`}createCommand(e){if(e.showFlag)return new et;let t=[];for(let n of e.positional){let e=n.indexOf(`=`);e>0&&t.push([n.slice(0,e),n.slice(e+1)])}return new $e([...e.setOption,...t])}},nt=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 ke(n,i),o=await j(n.filter(e=>!!(a.get(e.name)?.project??!0)),i),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});return 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`}}},rt=class{canHandle(e){return e.subcommand===`dry-run`}createCommand(e){return new nt}},it=class{name=`execute`;async execute(e){let{logger:t,outputPlugins:n,createCleanContext:r,createWriteContext:i}=e;t.info(`started`,{command:`execute`});let a=await z(n,r(!1),t,{executeHooks:!1});t.info(`cleanup complete`,{deletedFiles:a.deletedFiles,deletedDirs:a.deletedDirs});let o=i(!1),s=await ke(n,o),c=await j(n.filter(e=>s.get(e.name)?.project??!0),o),l=0,u=0;for(let e of c.values())l+=e.files.length,u+=e.dirs.length;return t.info(`complete`,{command:`execute`,pluginCount:c.size}),{success:!0,filesAffected:l,dirsAffected:u}}},at=class{canHandle(e){return!0}createCommand(e){return new it}};function Z(){return`2026.10303.11058`}var ot=class{name=`version`;async execute(e){return e.logger.error(`tnmsc v${Z()}`),{success:!0,filesAffected:0,dirsAffected:0,message:`Version displayed`}}};const Q=`tnmsc`,st=`
|
|
3
|
+
${Q} v${Z()} - Memory Sync CLI
|
|
4
|
+
|
|
5
|
+
Synchronize AI memory and configuration files across projects.
|
|
6
|
+
|
|
7
|
+
USAGE:
|
|
8
|
+
${Q} Run the sync pipeline (default)
|
|
9
|
+
${Q} help Show this help message
|
|
10
|
+
${Q} version Show version information
|
|
11
|
+
${Q} outdated Check for version updates
|
|
12
|
+
${Q} init Initialize directories and files
|
|
13
|
+
${Q} dry-run Preview what would be written
|
|
14
|
+
${Q} clean Remove all generated files
|
|
15
|
+
${Q} clean --dry-run Preview what would be cleaned
|
|
16
|
+
${Q} config key=value Set configuration value
|
|
17
|
+
|
|
18
|
+
SUBCOMMANDS:
|
|
19
|
+
help Show this help message
|
|
20
|
+
version Show version information
|
|
21
|
+
outdated Check if CLI version is outdated against npm registry
|
|
22
|
+
init Initialize directory structure based on configuration
|
|
23
|
+
dry-run Preview changes without writing files
|
|
24
|
+
clean Remove all generated output files and directories
|
|
25
|
+
config Set configuration values in global config file (~/.aindex/.tnmsc.json)
|
|
26
|
+
|
|
27
|
+
ALIASES:
|
|
28
|
+
${Q} --help, ${Q} -h Same as '${Q} help'
|
|
29
|
+
${Q} --version, ${Q} -v Same as '${Q} version'
|
|
30
|
+
${Q} clean -n Same as '${Q} clean --dry-run'
|
|
31
|
+
${Q} config key=value Set config value in global config file
|
|
32
|
+
|
|
33
|
+
LOG LEVEL OPTIONS:
|
|
34
|
+
--trace Most verbose output
|
|
35
|
+
--debug Debug information
|
|
36
|
+
--info Standard information (default)
|
|
37
|
+
--warn Warnings only
|
|
38
|
+
--error Errors only
|
|
39
|
+
|
|
40
|
+
CLEAN OPTIONS:
|
|
41
|
+
-n, --dry-run Preview cleanup without removing files
|
|
42
|
+
|
|
43
|
+
CONFIG OPTIONS:
|
|
44
|
+
key=value Set a configuration value in global config (~/.aindex/.tnmsc.json)
|
|
45
|
+
Valid keys: workspaceDir, logLevel,
|
|
46
|
+
aindex.skills.src, aindex.skills.dist,
|
|
47
|
+
aindex.commands.src, aindex.commands.dist,
|
|
48
|
+
aindex.subAgents.src, aindex.subAgents.dist,
|
|
49
|
+
aindex.rules.src, aindex.rules.dist,
|
|
50
|
+
aindex.globalPrompt.src, aindex.globalPrompt.dist,
|
|
51
|
+
aindex.workspacePrompt.src, aindex.workspacePrompt.dist,
|
|
52
|
+
aindex.app.src, aindex.app.dist,
|
|
53
|
+
aindex.ext.src, aindex.ext.dist,
|
|
54
|
+
aindex.arch.src, aindex.arch.dist
|
|
55
|
+
|
|
56
|
+
Examples:
|
|
57
|
+
${Q} config workspaceDir=~/my-project
|
|
58
|
+
${Q} config aindex.skills.src=skills
|
|
59
|
+
${Q} config logLevel=debug
|
|
60
|
+
|
|
61
|
+
CONFIGURATION:
|
|
62
|
+
Configure via plugin.config.ts in your project root.
|
|
63
|
+
See documentation for detailed configuration options.
|
|
64
|
+
`.trim();var ct=class{name=`help`;async execute(e){return e.logger.info(st),{success:!0,filesAffected:0,dirsAffected:0,message:`Help displayed`}}},lt=class{priority=M.Flags;canHandle(e){return e.helpFlag||e.subcommand===`help`}createCommand(e){return new ct}};function ut(){return`@truenine/memory-sync-cli`}function dt(){return`https://registry.npmjs.org/${ut()}/latest`}function ft(e){let t=e.replace(/^v/,``),n=/^(\d+)\.(\d+)\.(\d+)/.exec(t);return n==null?null:[Number.parseInt(n[1],10),Number.parseInt(n[2],10),Number.parseInt(n[3],10)]}function pt(e,t){let n=ft(e),r=ft(t);if(n==null||r==null)return 0;for(let e=0;e<3;e++){if(n[e]<r[e])return-1;if(n[e]>r[e])return 1}return 0}const $=3e3;async function mt(){let e=new AbortController,t=setTimeout(()=>e.abort(),$);typeof t==`object`&&`unref`in t&&t.unref();try{let n=await fetch(dt(),{headers:{Accept:`application/json`},signal:e.signal});if(clearTimeout(t),!n.ok)return{error:`HTTP ${n.status}: ${n.statusText}`};let r=await n.json();return r.version==null?{error:`Invalid response: missing version field`}:{version:r.version}}catch(e){return clearTimeout(t),e instanceof Error?e.name===`TimeoutError`||e.name===`AbortError`?{error:`Request timeout after ${$}ms`}:{error:e.message}:{error:`Unknown network error`}}}function ht(){return`2026.10303.11058`}async function gt(){let e=ht();if(e===`dev`)return{status:`development`,localVersion:e,remoteVersion:null};let t=await mt();if(`error`in t)return{status:`current`,localVersion:e,remoteVersion:null,error:t.error};let n=t.version,r=pt(e,n);return r<0?{status:`outdated`,localVersion:e,remoteVersion:n}:r>0?{status:`development`,localVersion:e,remoteVersion:n}:{status:`current`,localVersion:e,remoteVersion:n}}function _t(e,t){let{status:n,localVersion:r,remoteVersion:i}=e;switch(n){case`outdated`:t.warn(`Version outdated: ${r} → ${i}. Run 'npm i -g ${ut()}@latest' to update.`);break;case`current`:e.error==null?t.info(`Version ${r} is up to date.`):t.warn(`Version check skipped: ${e.error}`);break;case`development`:i==null?t.debug(`Running in development mode, version check skipped.`):t.info(`Development version detected: ${r} > ${i}. Thanks for contributing!`);break}}function vt(){return new Date().getMinutes()%2==0}function yt(e){vt()&>().then(t=>{(t.status===`outdated`||t.error!=null)&&_t(t,e)}).catch(t=>{let n=t instanceof Error?t.message:`Unknown error`;e.warn(`Version check skipped: ${n}`)})}var bt=class{name=`outdated`;async execute(e){let t=await gt();return _t(t,e.logger),{success:!0,filesAffected:0,dirsAffected:0,message:`Version status: ${t.status}`}}},xt=class{canHandle(e){return e.subcommand===`outdated`}createCommand(e){return new bt}},St=class{name=`plugins`;async execute(e){let{logger:t,outputPlugins:n,userConfigOptions:r}=e,i=r.plugins,a=[];for(let e of i)a.push({name:e.name,kind:e.type===w.Input?`Input`:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});let o=new Set(a.map(e=>e.name));for(let e of n)o.has(e.name)||a.push({name:e.name,kind:`Output`,description:e.name,dependencies:[...e.dependsOn??[]]});return u.default.stdout.write(`${JSON.stringify(a)}\n`),t.info(`plugins listed`,{count:a.length}),{success:!0,filesAffected:0,dirsAffected:0,message:`Listed ${a.length} plugin(s)`}}},Ct=class{canHandle(e){return e.subcommand===`plugins`}createCommand(e){return new St}},wt=class{name=`unknown`;constructor(e){this.unknownCmd=e}async execute(e){return e.logger.error(`unknown command`,{command:this.unknownCmd}),e.logger.info(`run "tnmsc help" for available commands`),{success:!1,filesAffected:0,dirsAffected:0,message:`Unknown command: ${this.unknownCmd}`}}},Tt=class{priority=M.Unknown;canHandle(e){return e.unknownCommand!=null}createCommand(e){return new wt(e.unknownCommand)}},Et=class{priority=M.Flags;canHandle(e){return e.versionFlag||e.subcommand===`version`}createCommand(e){return new ot}};function Dt(){let e=new N;return e.register(new Et),e.register(new lt),e.register(new Tt),e.registerWithPriority(new xt,M.Subcommand),e.registerWithPriority(new rt,M.Subcommand),e.registerWithPriority(new H,M.Subcommand),e.registerWithPriority(new Ct,M.Subcommand),e.registerWithPriority(new tt,M.Subcommand),e.registerWithPriority(new at,M.Subcommand),e}Object.defineProperty(exports,`$`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return H}}),Object.defineProperty(exports,`B`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return We}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`G`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`H`,{enumerable:!0,get:function(){return Me}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`J`,{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,`K`,{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`Q`,{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return Ue}}),Object.defineProperty(exports,`U`,{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(exports,`V`,{enumerable:!0,get:function(){return je}}),Object.defineProperty(exports,`W`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`X`,{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(exports,`Y`,{enumerable:!0,get:function(){return Te}}),Object.defineProperty(exports,`Z`,{enumerable:!0,get:function(){return we}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return nt}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(exports,`at`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return $e}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return bt}}),Object.defineProperty(exports,`ct`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return ct}}),Object.defineProperty(exports,`dt`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`et`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ot}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return rt}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return it}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return wt}}),Object.defineProperty(exports,`it`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return yt}}),Object.defineProperty(exports,`lt`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Et}}),Object.defineProperty(exports,`nt`,{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return St}}),Object.defineProperty(exports,`ot`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,`q`,{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(exports,`rt`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return xt}}),Object.defineProperty(exports,`st`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(exports,`tt`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return lt}}),Object.defineProperty(exports,`ut`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return et}}),Object.defineProperty(exports,`z`,{enumerable:!0,get:function(){return Fe}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./CommandRegistryFactory-CY3bAciG.mjs";import e from"node:process";var t=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(t){let r=await this.inner.execute(t),i=n(r);return e.stdout.write(`${JSON.stringify(i)}\n`),r}};function n(e){return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],errors:[]}}export{t as JsonOutputCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./CommandRegistryFactory-DRWte7G7.cjs`);let t=require(`node:process`);t=e.dt(t);var n=class{name;inner;constructor(e){this.inner=e,this.name=`json:${e.name}`}async execute(e){let n=await this.inner.execute(e),i=r(n);return t.default.stdout.write(`${JSON.stringify(i)}\n`),n}};function r(e){return{success:e.success,filesAffected:e.filesAffected,dirsAffected:e.dirsAffected,...e.message!=null&&{message:e.message},pluginResults:[],errors:[]}}exports.JsonOutputCommand=n;
|
package/dist/globals.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../libraries/md-compiler/dist/
|
|
1
|
+
//#region ../libraries/md-compiler/dist/index-BkGsJ49x.d.mts
|
|
2
2
|
//#region src/globals/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* // These types are available to users when writing MDX templates. // Global type declarations for MDX expression scope. // src/globals/index.ts
|
package/dist/globals.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../libraries/md-compiler/dist/
|
|
1
|
+
//#region ../libraries/md-compiler/dist/index-BkGsJ49x.d.mts
|
|
2
2
|
//#region src/globals/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* // These types are available to users when writing MDX templates. // Global type declarations for MDX expression scope. // src/globals/index.ts
|