@vpxa/aikit 0.1.273 → 0.1.274
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/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as e,f as t,i as n,m as r,p as i,s as a,u as o}from"./scaffold-
|
|
1
|
+
import{d as e,f as t,i as n,m as r,p as i,s as a,u as o}from"./scaffold-Cxjwg531.js";import{A as s,C as c,D as l,E as u,M as d,N as f,O as p,S as ee,T as m,_ as h,a as g,b as _,c as v,d as y,f as b,g as te,h as ne,i as x,j as S,k as C,l as w,m as T,n as re,o as ie,p as ae,r as oe,s as se,t as ce,u as E,v as D,w as O,x as le,y as ue}from"./templates-C92mODRl.js";import{copyFileSync as de,existsSync as k,mkdirSync as A,readFileSync as j,readdirSync as M,rmSync as fe,unlinkSync as pe,writeFileSync as N}from"node:fs";import{basename as me,dirname as P,join as F,posix as I,relative as he,resolve as L,win32 as R}from"node:path";import{fileURLToPath as ge}from"node:url";import{addToWorkset as _e,audit as ve,check as ye,checkpointLatest as be,checkpointList as xe,checkpointLoad as Se,checkpointSave as Ce,codemod as we,compact as Te,dataTransform as Ee,delegate as De,delegateListModels as Oe,deleteWorkset as ke,diffParse as Ae,evaluate as je,fileSummary as Me,find as Ne,findDeadSymbols as Pe,findExamples as Fe,getWorkset as Ie,gitContext as Le,graphQuery as Re,guide as ze,health as Be,laneCreate as Ve,laneDiff as He,laneDiscard as Ue,laneList as We,laneMerge as Ge,laneStatus as Ke,listWorksets as qe,parseOutput as Je,processList as Ye,processLogs as Xe,processStart as Ze,processStatus as Qe,processStop as $e,queueClear as et,queueCreate as tt,queueDelete as nt,queueDone as rt,queueFail as it,queueGet as at,queueList as ot,queueNext as st,queuePush as ct,removeFromWorkset as lt,rename as ut,replayClear as dt,replayList as ft,replayTrim as pt,saveWorkset as mt,scopeMap as ht,stashClear as gt,stashDelete as _t,stashGet as vt,stashList as yt,stashSet as bt,symbol as xt,testRun as St,trace as Ct,watchList as wt,watchStart as Tt,watchStop as Et}from"../../tools/dist/index.js";import{mkdir as Dt,readFile as z,rename as Ot,unlink as kt,writeFile as At}from"node:fs/promises";import{SqliteGraphStore as jt,createSqliteAdapter as Mt,createStore as Nt}from"../../store/dist/index.js";import{randomUUID as Pt}from"node:crypto";import{homedir as B}from"node:os";import{execFileSync as Ft,fork as It}from"node:child_process";import{AIKIT_PATHS as V,EMBEDDING_DEFAULTS as Lt,getGlobalDataDir as Rt,getPartitionDir as H,isUserInstalled as zt,registerWorkspace as Bt,saveRegistry as Vt}from"../../core/dist/index.js";import{initializeWasm as Ht}from"../../chunker/dist/index.js";import{OnnxEmbedder as Ut}from"../../embeddings/dist/index.js";import{IncrementalIndexer as Wt}from"../../indexer/dist/index.js";const Gt=[{name:`analyze`,description:`Run analyzer output for a path`,usage:`aikit analyze <type> <path>`,run:async e=>{let t=e.shift()?.trim()??``,n=e.shift()?.trim()??``;(!t||!n)&&(console.error(`Usage: aikit analyze <type> <path>`),console.error(`Types: structure, deps, symbols, patterns, entry-points, blast-radius, diagram`),process.exit(1));let{BlastRadiusAnalyzer:r,DependencyAnalyzer:i,DiagramGenerator:a,EntryPointAnalyzer:o,PatternAnalyzer:s,StructureAnalyzer:c,SymbolAnalyzer:l}=await import(`../../analyzers/dist/index.js`),u=L(n),d;switch(t){case`structure`:d=await new c().analyze(u,{format:`markdown`});break;case`deps`:case`dependencies`:d=await new i().analyze(u,{format:`markdown`});break;case`symbols`:d=await new l().analyze(u,{format:`markdown`});break;case`patterns`:d=await new s().analyze(u,{format:`markdown`});break;case`entry-points`:d=await new o().analyze(u,{format:`markdown`});break;case`blast-radius`:d=await new r().analyze(process.cwd(),{files:[n],format:`markdown`});break;case`diagram`:d=await new a().analyze(u,{diagramType:`architecture`});break;default:console.error(`Unknown analyze type: ${t}`),console.error(`Types: structure, deps, symbols, patterns, entry-points, blast-radius, diagram`),process.exit(1)}console.log(d.output)}},{name:`onboard`,description:`Run all analyses for first-time codebase onboarding`,usage:`aikit onboard <path> [--generate] [--out-dir <dir>]`,run:async e=>{let{onboard:t}=await import(`../../tools/dist/index.js`),{loadConfig:n}=await Promise.resolve().then(()=>Kn),r=``,i=`memory`,a;for(let t=0;t<e.length;t++){let n=e[t].trim();n===`--generate`?i=`generate`:n===`--out-dir`&&t+1<e.length?a=e[++t].trim():n.startsWith(`--`)||(r=n)}r||=process.cwd();let o=L(r),s=n();console.log(`Onboarding: ${o} (mode: ${i})`),console.log(`Running analyses...
|
|
2
2
|
`);let c=await t({path:o,mode:i,outDir:a??s.onboardDir});for(let e of c.steps){let t=e.status===`success`?`✓`:`✗`,n=e.status===`success`?`${e.durationMs}ms, ${e.output.length} chars`:e.error;console.log(` ${t} ${e.name} — ${n}`)}console.log(`\nTotal: ${c.totalDurationMs}ms`),c.outDir&&console.log(`Output written to: ${c.outDir}`)}}],Kt=[{name:`parse-output`,description:`Parse build or tool output from stdin`,usage:`aikit parse-output [--tool tsc|vitest|biome|git-status]`,run:async e=>{let t=y(e,`--tool`,``).trim()||void 0,n=await s();n.trim()||(console.error(`Usage: aikit parse-output [--tool tsc|vitest|biome|git-status]`),process.exit(1)),m(Je(n,t))}},{name:`git`,description:`Show git branch, status, recent commits, and optional diff stats`,usage:`aikit git [--cwd path] [--commit-count N] [--diff]`,run:async e=>{c(await Le({cwd:y(e,`--cwd`,``).trim()||void 0,commitCount:E(e,`--commit-count`,5),includeDiff:w(e,`--diff`)}))}},{name:`diff`,description:`Parse unified diff text from stdin into structured file changes`,usage:`git diff | aikit diff`,run:async()=>{let e=await s();e.trim()||(console.error(`Usage: git diff | aikit diff`),process.exit(1)),_(Ae({diff:e}))}},{name:`summarize`,description:`Show a structural summary of a file`,usage:`aikit summarize <path>`,run:async e=>{let t=e.shift()?.trim();t||(console.error(`Usage: aikit summarize <path>`),process.exit(1)),ee(await Me({path:L(t)}))}},{name:`checkpoint`,description:`Save and restore lightweight session checkpoints`,usage:`aikit checkpoint <save|load|list|latest> [label-or-id] [--data json] [--notes text]`,run:async e=>{let t=e.shift()?.trim();t||(console.error(`Usage: aikit checkpoint <save|load|list|latest> [label-or-id] [--data json] [--notes text]`),process.exit(1));let n=await v();switch(t){case`save`:{let t=e.shift()?.trim(),r=y(e,`--data`,``),i=y(e,`--notes`,``).trim()||void 0,a=r.trim()?``:await s();t||(console.error(`Usage: aikit checkpoint save <label> [--data json] [--notes text]`),process.exit(1)),D(Ce(n,t,te(r||a),{notes:i}));return}case`load`:{let t=e.shift()?.trim();t||(console.error(`Usage: aikit checkpoint load <id>`),process.exit(1));let r=Se(n,t);if(!r){console.log(`No checkpoint found: ${t}`);return}D(r);return}case`list`:{let e=xe(n);if(e.length===0){console.log(`No checkpoints saved.`);return}console.log(`Checkpoints (${e.length})`),console.log(`─`.repeat(60));for(let t of e)console.log(`${t.id}`),console.log(` Label: ${t.label}`),console.log(` Created: ${t.createdAt}`);return}case`latest`:{let e=be(n);if(!e){console.log(`No checkpoints saved.`);return}D(e);return}default:console.error(`Unknown checkpoint action: ${t}`),console.error(`Actions: save, load, list, latest`),process.exit(1)}}}];function qt(e){let t=``,n=0,r=e.length;for(;n<r;)if(e[n]===`"`){for(t+=`"`,n++;n<r&&e[n]!==`"`;)e[n]===`\\`&&(t+=e[n++]),n<r&&(t+=e[n++]);n<r&&(t+=e[n++])}else if(e[n]===`/`&&n+1<r&&e[n+1]===`/`)for(n+=2;n<r&&e[n]!==`
|
|
3
3
|
`;)n++;else if(e[n]===`/`&&n+1<r&&e[n+1]===`*`){for(n+=2;n+1<r&&!(e[n]===`*`&&e[n+1]===`/`);)n++;n+=2}else t+=e[n++];return t.replace(/,(\s*[}\]])/g,`$1`)}var U=class{isPlatformSupported(){return this.platforms.includes(process.platform)}async readConfig(e){let t=this.getConfigPath(e);if(!k(t))return{};let n=await z(t,`utf-8`);try{return JSON.parse(qt(n))}catch{throw Error(`Invalid JSON in ${t}. Please fix or remove the file before retrying.`)}}async writeConfig(e,t){let n=this.getConfigPath(t),r=P(n),i=F(r,`.aikit-tmp-${Pt()}.json`);await Dt(r,{recursive:!0});try{await At(i,`${JSON.stringify(e,null,2)}\n`,`utf-8`),await Ot(i,n)}catch(e){try{await kt(i)}catch{}throw e}}async registerMcp(e,t,n){let r=await this.readConfig(n);r[this.configKey]||(r[this.configKey]={}),r[this.configKey][e]=t,await this.writeConfig(r,n)}async unregisterMcp(e,t){let n=await this.readConfig(t);n[this.configKey]&&(delete n[this.configKey][e],await this.writeConfig(n,t))}getScaffoldRoot(e){return null}getInstructionsRoot(e){return null}getScaffoldPaths(e){return{agents:null,skills:null,prompts:null,flows:null,commands:null,instructions:null,manifest:null,hooks:null}}buildInstructionContent(e,t){return`${e}\n---\n\n${t}`}},Jt=class extends U{id=`claude-code`;name=`Claude Code`;family=`claude`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?k(this.getPathModule().resolve(B(),`.claude`)):!1}getConfigPath(){return this.getPathModule().resolve(B(),`.claude`,`mcp.json`)}getScaffoldRoot(){return this.getPathModule().resolve(B(),`.claude`)}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(B(),`.claude`);return{agents:e.resolve(t,`agents`),skills:e.resolve(t,`skills`),prompts:null,flows:e.resolve(t,`flows`),commands:e.resolve(t,`commands`),instructions:e.resolve(t,`CLAUDE.md`),manifest:e.resolve(t,`.aikit-scaffold.json`),hooks:null}}buildInstructionContent(e,t){return`${e}\n---\n\n${t}`}getPathModule(){return process.platform===`win32`?R:I}},Yt=class extends U{id=`codex-cli`;name=`Codex CLI`;family=`codex`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?k(this.getPathModule().resolve(B(),`.codex`)):!1}getConfigPath(){return this.getPathModule().resolve(B(),`.codex`,`config.json`)}getScaffoldRoot(){return this.getPathModule().resolve(B(),`.codex`)}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(B(),`.codex`);return{agents:e.resolve(t,`agents`),skills:e.resolve(t,`skills`),prompts:null,flows:e.resolve(t,`flows`),commands:null,instructions:e.resolve(t,`AGENTS.md`),manifest:e.resolve(t,`.aikit-scaffold.json`),hooks:null}}getPathModule(){return process.platform===`win32`?R:I}},W=class extends U{family=`copilot`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;hasInstructions=!1;async detect(){if(!this.isPlatformSupported())return!1;let e=this.getConfigDir();if(process.platform===`darwin`){let t=this.getMacAppPath();return k(e)||t!==null&&k(t)}return k(e)}getConfigPath(){return this.getPathModule().resolve(this.getConfigDir(),`mcp.json`)}getScaffoldRoot(){return this.getPathModule().resolve(B(),this.scaffoldBase)}getInstructionsRoot(){let e=this.getInstructionFilePath();return e?this.getPathModule().dirname(e):null}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(B(),this.scaffoldBase);return{agents:e.resolve(t,`agents`),skills:e.resolve(t,`skills`),prompts:e.resolve(this.getConfigDir(),`prompts`),flows:e.resolve(t,`flows`),hooks:e.resolve(t,`hooks`),commands:null,instructions:this.getInstructionFilePath(),manifest:e.resolve(t,`.aikit-scaffold.json`)}}getConfigDir(){let e=this.getPathModule(),t=B();if(process.platform===`win32`){let n=process.env.APPDATA??e.resolve(t,`AppData`,`Roaming`);return e.resolve(n,this.configDirName,`User`)}if(process.platform===`darwin`)return e.resolve(t,`Library`,`Application Support`,this.configDirName,`User`);let n=process.env.XDG_CONFIG_HOME??e.resolve(t,`.config`);return e.resolve(n,this.configDirName,`User`)}getMacAppPath(){return null}getInstructionFilePath(){return null}getPathModule(){return process.platform===`win32`?R:I}},Xt=class extends U{id=`copilot-cli`;name=`Copilot CLI`;family=`copilot`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?k(L(B(),`.copilot`)):!1}getConfigPath(){return L(B(),`.copilot`,`mcp-config.json`)}async registerMcp(e,t,n){let r={...t,tools:[`*`]},i=await this.readConfig(n);i[this.configKey]||(i[this.configKey]={}),i[this.configKey][e]=r,await this.writeConfig(i,n)}getScaffoldRoot(){return L(B(),`.copilot`)}getInstructionsRoot(){return null}getScaffoldPaths(){let e=L(B(),`.copilot`);return{agents:L(e,`agents`),skills:L(e,`skills`),prompts:null,flows:L(e,`flows`),hooks:L(e,`hooks`),commands:null,instructions:L(B(),`.github`,`copilot-instructions.md`),manifest:L(e,`.aikit-scaffold.json`)}}},Zt=class extends W{id=`cursor`;name=`Cursor`;configKey=`mcpServers`;configDirName=`Cursor`;scaffoldBase=`.cursor`;getMacAppPath(){return`/Applications/Cursor.app`}getInstructionFilePath(){return this.getPathModule().resolve(B(),this.scaffoldBase,`rules`,`aikit.mdc`)}},Qt=class extends W{id=`cursor-nightly`;name=`Cursor Nightly`;configKey=`mcpServers`;configDirName=`Cursor Nightly`;scaffoldBase=`.cursor`;getMacAppPath(){return`/Applications/Cursor Nightly.app`}getInstructionFilePath(){return this.getPathModule().resolve(B(),this.scaffoldBase,`rules`,`aikit.mdc`)}},$t=class e extends U{id=`intellij`;name=`IntelliJ IDEA`;family=`copilot`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`servers`;static PRODUCTS=[`IntelliJIdea`,`IdeaIC`,`WebStorm`,`PyCharm`,`PyCharmCE`,`GoLand`,`PhpStorm`,`CLion`,`Rider`,`RubyMine`,`RustRover`,`DataGrip`];async detect(){if(!this.isPlatformSupported())return!1;if(k(this.getCopilotConfigDir()))return!0;let t=this.getJetBrainsBaseDir();if(!k(t))return!1;try{return M(t,{withFileTypes:!0}).some(t=>t.isDirectory()&&e.PRODUCTS.some(e=>t.name.startsWith(e)))}catch{return!1}}getConfigPath(){return L(this.getCopilotConfigDir(),`mcp.json`)}async registerMcp(e,t,n){let r=this.getCopilotConfigDir();await Dt(r,{recursive:!0});let i=t.args??[],a=i.indexOf(`-e`),o;if(a!==-1&&a+1<i.length){let t=i[a+1],n=L(r,`${e}-launcher.js`);await At(n,t,`utf-8`),o=[...i.slice(0,a),n,...i.slice(a+2)]}else o=[...i];let s={type:`stdio`,...t,args:o};await super.registerMcp(e,s,n)}getScaffoldRoot(e){return null}getInstructionsRoot(e){return null}getScaffoldPaths(e){return{agents:null,skills:null,prompts:null,flows:null,commands:null,instructions:null,manifest:null,hooks:null}}buildInstructionContent(e,t){return t}getCopilotConfigDir(){let e=B();return process.platform===`win32`?L(process.env.LOCALAPPDATA??L(e,`AppData`,`Local`),`github-copilot`,`intellij`):process.platform===`darwin`?L(e,`Library`,`Application Support`,`github-copilot`,`intellij`):L(process.env.XDG_CONFIG_HOME??L(e,`.config`),`github-copilot`,`intellij`)}getJetBrainsBaseDir(){let e=B();return process.platform===`win32`?L(process.env.APPDATA??L(e,`AppData`,`Roaming`),`JetBrains`):process.platform===`darwin`?L(e,`Library`,`Application Support`,`JetBrains`):L(process.env.XDG_CONFIG_HOME??L(e,`.config`),`JetBrains`)}},en=class extends W{id=`trae`;name=`Trae`;configKey=`servers`;configDirName=`Trae`;scaffoldBase=`.trae`;getMacAppPath(){return`/Applications/Trae.app`}getInstructionFilePath(){return this.getPathModule().resolve(B(),this.scaffoldBase,`rules`,`aikit.md`)}},tn=class extends W{id=`vscode`;name=`VS Code`;configKey=`servers`;configDirName=`Code`;scaffoldBase=`.copilot`;hasInstructions=!0;getMacAppPath(){return`/Applications/Visual Studio Code.app`}getInstructionFilePath(){return this.hasInstructions?this.getPathModule().resolve(B(),this.scaffoldBase,`instructions`,`copilot-instructions.md`):null}buildInstructionContent(e,t){return`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`}},nn=class extends W{id=`vscode-insiders`;name=`VS Code Insiders`;configKey=`servers`;configDirName=`Code - Insiders`;scaffoldBase=`.copilot`;hasInstructions=!0;getMacAppPath(){return`/Applications/Visual Studio Code - Insiders.app`}getInstructionFilePath(){return this.hasInstructions?this.getPathModule().resolve(B(),this.scaffoldBase,`instructions`,`copilot-instructions.md`):null}buildInstructionContent(e,t){return`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`}},rn=class extends W{id=`vscodium`;name=`VSCodium`;configKey=`servers`;configDirName=`VSCodium`;scaffoldBase=`.copilot`;hasInstructions=!0;getMacAppPath(){return`/Applications/VSCodium.app`}getInstructionFilePath(){return this.hasInstructions?this.getPathModule().resolve(B(),this.scaffoldBase,`instructions`,`copilot-instructions.md`):null}buildInstructionContent(e,t){return`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`}},an=class extends W{id=`windsurf`;name=`Windsurf`;configKey=`servers`;configDirName=`Windsurf`;scaffoldBase=`.windsurf`;getMacAppPath(){return`/Applications/Windsurf.app`}getInstructionFilePath(){return this.getPathModule().resolve(B(),this.scaffoldBase,`rules`,`aikit.md`)}},on=class extends U{id=`gemini-cli`;name=`Gemini CLI`;family=`gemini`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`mcpServers`;async detect(){return this.isPlatformSupported()?k(this.getPathModule().resolve(B(),`.gemini`)):!1}getConfigPath(){return this.getPathModule().resolve(B(),`.gemini`,`settings.json`)}getScaffoldRoot(){return this.getPathModule().resolve(B(),`.gemini`)}getScaffoldPaths(){let e=this.getPathModule(),t=e.resolve(B(),`.gemini`);return{agents:e.resolve(t,`agents`),skills:e.resolve(t,`skills`),prompts:null,flows:e.resolve(t,`flows`),commands:null,instructions:e.resolve(t,`AGENTS.md`),manifest:e.resolve(t,`.aikit-scaffold.json`),hooks:null}}getPathModule(){return process.platform===`win32`?R:I}},sn=class extends U{id=`zed`;name=`Zed`;family=`zed`;platforms=[`win32`,`darwin`,`linux`];scope=`user`;configKey=`context_servers`;async detect(){return this.isPlatformSupported()?k(this.getConfigDir()):!1}getConfigPath(){return this.getPathModule().resolve(this.getConfigDir(),`settings.json`)}async registerMcp(e,t){let{type:n,...r}=t,i={...r,env:r.env??{}};await super.registerMcp(e,i)}getScaffoldRoot(){return this.getConfigDir()}getScaffoldPaths(){let e=this.getPathModule(),t=this.getConfigDir();return{agents:e.resolve(t,`prompts`),skills:null,prompts:e.resolve(t,`prompts`),flows:null,commands:null,instructions:null,manifest:e.resolve(t,`.aikit-scaffold.json`),hooks:null}}getConfigDir(){let e=this.getPathModule();return process.platform===`win32`?e.resolve(process.env.APPDATA||B(),`Zed`):e.resolve(B(),`.config`,`zed`)}getPathModule(){return process.platform===`win32`?R:I}};const cn=[new tn,new nn,new rn,new Zt,new Qt,new an,new en,new Xt,new $t,new Jt,new on,new Yt,new sn];async function ln(e){let t=e?.scope?cn.filter(t=>t.scope===e.scope):cn;return(await Promise.allSettled(t.map(async e=>await e.detect()?e:null))).flatMap(e=>e.status!==`fulfilled`||e.value===null?[]:[e.value])}const un={SessionStart:{copilot:`SessionStart`,claude:`PreToolCall`,copilotCli:`sessionStart`},PreToolUse:{copilot:`PreToolUse`,claude:`PreToolCall`,copilotCli:`preToolUse`},PostToolUse:{copilot:`PostToolUse`,claude:`PostToolCall`,copilotCli:`postToolUse`},SubagentStart:{copilot:`SubagentStart`,claude:`PreToolCall`,copilotCli:`subagentStart`},PreCompact:{copilot:`PreCompact`,claude:`PreToolCall`,copilotCli:`preCompact`},Stop:{copilot:`Stop`,claude:`PostToolCall`,copilotCli:`stop`}},dn={fileRead:{copilot:[`read_file`,`readFile`],claude:[`Read`],copilotCli:[`read_file`]},fileWrite:{copilot:[`editFiles`,`replace_string_in_file`,`create_file`],claude:[`Write`,`Edit`],copilotCli:[`editFiles`,`replace_string_in_file`]},fileSearch:{copilot:[`grep_search`,`semantic_search`,`find`],claude:[`Bash`],copilotCli:[`grep_search`]}},G={"privacy-guard":{id:`privacy-guard`,event:`PreToolUse`,tier:`safety`,description:`Blocks reads of secret-bearing env files, key material, SSH paths, and credential artifacts.`,script:`privacy-guard.mjs`,matcher:[`fileRead`],scope:`user`,patterns:[`.env`,`*.pem`,`*.key`,`id_rsa*`,`.ssh/*`,`*credentials*`,`*.secret`]},"scout-guard":{id:`scout-guard`,event:`PreToolUse`,tier:`safety`,description:`Blocks reads and searches inside generated, dependency, and git object directories.`,script:`scout-guard.mjs`,matcher:[`fileRead`,`fileSearch`],scope:`user`,patterns:[`node_modules/`,`dist/`,`.git/objects/`,`vendor/`,`build/`]},"subagent-context":{id:`subagent-context`,event:`SubagentStart`,tier:`efficiency`,description:`Injects compact project context into each subagent spawn to reduce repeated discovery.`,script:`subagent-context.mjs`,scope:`user`},"pre-compact-save":{id:`pre-compact-save`,event:`PreCompact`,tier:`efficiency`,description:`Persists critical state before context compaction truncates recent session history.`,script:`pre-compact-save.mjs`,scope:`user`},"post-edit-check":{id:`post-edit-check`,event:`PostToolUse`,tier:`nudge`,description:`After repeated file edits, injects a validation reminder so checks are not skipped.`,script:`post-edit-check.mjs`,matcher:[`fileWrite`],scope:`user`},"session-init":{id:`session-init`,event:`SessionStart`,tier:`nudge`,description:`Detects project stack and injects workspace metadata and environment context at startup.`,script:`session-init.mjs`,scope:`user`},"session-observer":{id:`session-observer`,event:`PostToolUse`,tier:`efficiency`,description:`Captures tool usage patterns for autonomous lesson extraction. Writes to session buffer.`,script:`session-observer.mjs`,scope:`user`},"session-learn":{id:`session-learn`,event:`Stop`,tier:`efficiency`,description:`Nudges final pattern analysis on buffered observations at session end.`,script:`session-learn.mjs`,scope:`user`}},fn={PreCompact:3e3,PostToolUse:3e3},pn={copilot:`hooks.json`,claude:`hooks-settings.json`,copilotCli:`hooks.json`};function mn(e,t){return(e.matcher||[]).flatMap(e=>{let n=dn[e];if(!n)throw Error(`Unknown hook matcher: ${e}`);return n[t]||[]})}function hn(e,t,n,r){let i=`${n}/${e.script}`;return mn(e,r),r===`copilot`?{event:t,steps:[{type:`command`,command:`node`,args:[i],timeout:fn[e.event]||5e3}]}:r===`claude`?{type:`command`,command:`node ${i}`}:{command:`node`,args:[i]}}function gn(e,t){if(e===`copilot`){let n=Object.values(G).map(n=>{let r=un[n.event]?.[e];if(!r)throw Error(`Unsupported hook event ${n.event} for ${e}`);return hn(n,r,t,e)});return[{path:pn[e],content:JSON.stringify({hooks:n},null,2)}]}let n={};for(let r of Object.values(G)){let i=un[r.event]?.[e];if(!i)throw Error(`Unsupported hook event ${r.event} for ${e}`);n[i]||=[],n[i].push(hn(r,i,t,e))}return[{path:pn[e],content:JSON.stringify({hooks:n},null,2)}]}function _n(){return[`_runtime.mjs`,...Object.values(G).map(e=>e.script)]}function vn(){let e={command:x.command,args:x.args?[...x.args]:void 0,type:x.type};if(process.platform!==`win32`){let t=process.env.PATH;t&&(e.env={PATH:t});try{let t=Ft(`which`,[`node`],{encoding:`utf-8`,timeout:3e3}).trim();t&&k(t)&&(e.command=t)}catch{}}return e}const yn=new Set([`VS Code`,`VS Code Insiders`,`VSCodium`]);function bn(e,t,n){let r=L(B(),`.copilot`,`instructions`,`copilot-instructions.md`);!k(r)||n.has(r)||(A(P(r),{recursive:!0}),N(r,`---\napplyTo: "**"\n---\n\n${e}\n---\n\n${t}`,`utf-8`),n.add(r))}function xn(e,t=!1){if(!yn.has(e.name))return;let n=L(P(e.getConfigPath()),`settings.json`),r={};if(k(n))try{let e=j(n,`utf-8`);r=JSON.parse(e)}catch{console.log(` ${e.name}: skipped settings.json (invalid JSON)`);return}let i=!1;for(let[e,n]of Object.entries(se))if(typeof n==`object`&&n){let t=typeof r[e]==`object`&&r[e]!==null?r[e]:{},a={...t,...n};JSON.stringify(a)!==JSON.stringify(t)&&(r[e]=a,i=!0)}else (t||!(e in r))&&(r[e]=n,i=!0);i&&(N(n,`${JSON.stringify(r,null,2)}\n`,`utf-8`),console.log(` ${e.name}: updated settings.json`))}async function Sn(r,i,s,c,l=!1){let u=new Map,d=new Set,f=re(`aikit`,s),p=ce(`aikit`,s);for(let e of i)e.getScaffoldRoot()!==null&&u.set(e.id,e);if(bn(f,p,d),u.size===0){d.size>0?console.log(` Instruction files: ${[...d].join(`, `)}`):console.log(` No IDEs with global scaffold support detected.`);return}let ee=await n(r,`copilot`),m=new Map;for(let e of ee){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t);if(n!==`agents`&&n!==`prompts`)continue;let r=m.get(n)??[];r.push({path:e.path.substring(t+1),content:e.content}),m.set(n,r)}let h=await n(r,`skills`),g=new Set;for(let e of h){let t=e.path.indexOf(`/`);t!==-1&&g.add(e.path.substring(0,t))}let _=await n(r,`flows`),v=new Set;for(let e of _){let t=e.path.indexOf(`/`);t!==-1&&v.add(e.path.substring(0,t))}let y=await n(r,`claude-code`),b=L(r,`scaffold`,`general`,`hooks`,`scripts`),te=k(b)?b:L(import.meta.dirname,`../../../../../scaffold/general/hooks/scripts`),ne=_n(),x=new Set,S=new Set,C=new Set,w=(n,r,i)=>{let s=m.get(i);if(!n||!r||!s||s.length===0)return;let u=`${i}:${r}:${n}`;if(x.has(u))return;x.add(u);let d=e(r)??o(c);d.version=c,a(s,n,d,i,l),t(r,d),C.add(P(r))},T=(n,r,i,s)=>{if(!n||!r||s.length===0)return;let u=`${i}:${r}:${n}`;if(x.has(u))return;if(x.add(u),i===`flows`&&!S.has(n)){for(let e of v){let t=L(n,e,`skills`);k(t)&&(fe(t,{recursive:!0,force:!0}),console.log(` ${P(r)}: migrated ${e} flow to steps/ layout`))}S.add(n)}let d=e(r)??o(c);d.version=c,a(s,n,d,i,l),t(r,d),C.add(P(r))},ie=(e,t,n)=>{!e||!t||T(e,t,`hooks`,[...gn(n,L(e,`scripts`).replace(/\\/g,`/`)),...ne.map(e=>({path:`scripts/${e}`,content:j(L(te,e),`utf-8`)}))])};for(let e of u.values()){let t=e.getScaffoldPaths();w(t.agents,t.manifest,`agents`),w(t.prompts,t.manifest,`prompts`),T(t.skills,t.manifest,`skills`,h),T(t.flows,t.manifest,`flows`,_),T(t.commands,t.manifest,`commands`,y),ie(t.hooks,t.manifest,e.family===`claude`?`claude`:`copilot`)}for(let e of C)console.log(` ${e}: scaffold updated (${g.size} skills)`);for(let e of u.values()){let t=e.getScaffoldPaths().instructions;!t||d.has(t)||(A(P(t),{recursive:!0}),N(t,e.buildInstructionContent(f,p),`utf-8`),d.add(t))}d.size>0&&console.log(` Instruction files: ${[...d].join(`, `)}`)}function Cn(e){let t=[];for(let n of e){let e=n.getScaffoldRoot();if(e)if(yn.has(n.name)){let r=n.getInstructionsRoot()??e;t.push(L(r,`kb.instructions.md`)),t.push(L(r,`aikit.instructions.md`))}else n.name===`Cursor`||n.name===`Cursor Nightly`?t.push(L(e,`rules`,`kb.mdc`)):n.name===`Windsurf`&&t.push(L(e,`rules`,`kb.md`))}for(let e of t)k(e)&&(pe(e),console.log(` Removed legacy file: ${e}`))}async function K(e){let t=g,n=ae(),r=JSON.parse(j(L(n,`package.json`),`utf-8`)).version;console.log(`Initializing @vpxa/aikit v${r}...\n`);let i=Rt();A(i,{recursive:!0}),console.log(` Global data store: ${i}`),Vt({version:1,workspaces:{}}),console.log(` Created registry.json`);let a=await ln({scope:`user`});if(a.length===0)console.log(`
|
|
4
4
|
No supported IDEs detected. You can manually add the MCP server config.`);else{console.log(`\n Detected ${a.length} IDE(s):`);let n=vn();for(let e of a)try{await e.registerMcp(t,n),console.log(` ${e.name}: configured ${t}`)}catch(t){console.log(` ${e.name}: failed to configure (${t.message})`)}for(let t of a)xn(t,e.force)}console.log(`
|
|
@@ -13,10 +13,10 @@ Issues found:`);for(let e of n.issues)console.log(` - ${e}`)}}}],Wn=[{name:`pro
|
|
|
13
13
|
Actions: stats, find-nodes, find-edges, neighbors, traverse, delete, clear`),process.exit(1));let{graphStore:n}=await Q(),r=y(e,`--type`,``),i=y(e,`--name`,``),a=y(e,`--node-id`,``),o=y(e,`--edge-type`,``),s=y(e,`--direction`,`both`),c=E(e,`--depth`,2),l=E(e,`--limit`,50),u=y(e,`--source-path`,``),d={stats:`stats`,"find-nodes":`find_nodes`,"find-edges":`find_edges`,neighbors:`neighbors`,traverse:`traverse`,delete:`delete`,clear:`clear`}[t];d||(console.error(`Unknown graph action: ${t}`),console.error(`Actions: stats, find-nodes, find-edges, neighbors, traverse, delete, clear`),process.exit(1));let f=await Re(n,{action:d,nodeType:r||void 0,namePattern:i||void 0,sourcePath:u||void 0,nodeId:a||void 0,edgeType:o||void 0,direction:s,maxDepth:c,limit:l});if(console.log(f.summary),f.nodes&&f.nodes.length>0){console.log(`
|
|
14
14
|
Nodes:`);for(let e of f.nodes){let t=Object.keys(e.properties).length>0?` ${JSON.stringify(e.properties)}`:``;console.log(` ${e.name} (${e.type}, id: ${e.id})${t}`)}}if(f.edges&&f.edges.length>0){console.log(`
|
|
15
15
|
Edges:`);for(let e of f.edges){let t=e.weight===1?``:` (weight: ${e.weight})`;console.log(` ${e.fromId} --[${e.type}]--> ${e.toId}${t}`)}}f.stats&&(console.log(`\nNode types: ${JSON.stringify(f.stats.nodeTypes)}`),console.log(`Edge types: ${JSON.stringify(f.stats.edgeTypes)}`)),f.deleted!==void 0&&console.log(`Deleted: ${f.deleted}`)}}],nr=[{name:`remember`,description:`Store curated knowledge`,usage:`aikit remember <title> --category <cat> [--tags tag1,tag2]`,run:async e=>{let t=y(e,`--category`,``).trim(),n=f(y(e,`--tags`,``)),r=e.shift()?.trim()??``,i=await s(),a=i.trim().length>0?i:e.join(` `).trim();(!r||!t||!a.trim())&&(console.error(`Usage: aikit remember <title> --category <cat> [--tags tag1,tag2]`),process.exit(1));let{curated:o}=await Q(),c=await o.remember(r,a,t,n);console.log(`Stored curated entry`),console.log(` Path: ${c.path}`),console.log(` Category: ${t}`),n.length>0&&console.log(` Tags: ${n.join(`, `)}`)}},{name:`forget`,description:`Remove a curated entry`,usage:`aikit forget <path> --reason <reason>`,run:async e=>{let t=y(e,`--reason`,``).trim(),n=e.shift()?.trim()??``;(!n||!t)&&(console.error(`Usage: aikit forget <path> --reason <reason>`),process.exit(1));let{curated:r}=await Q(),i=await r.forget(n,t);console.log(`Removed curated entry: ${i.path}`)}},{name:`read`,description:`Read a curated entry`,usage:`aikit read <path>`,run:async e=>{let t=e.shift()?.trim()??``;t||(console.error(`Usage: aikit read <path>`),process.exit(1));let{curated:n}=await Q(),r=await n.read(t);console.log(r.title),console.log(`─`.repeat(60)),console.log(`Path: ${r.path}`),console.log(`Category: ${r.category}`),console.log(`Version: ${r.version}`),console.log(`Tags: ${r.tags.length>0?r.tags.join(`, `):`None`}`),console.log(``),console.log(r.content)}},{name:`list`,description:`List curated entries`,usage:`aikit list [--category <cat>] [--tag <tag>]`,run:async e=>{let t=y(e,`--category`,``).trim()||void 0,n=y(e,`--tag`,``).trim()||void 0,{curated:r}=await Q(),i=await r.list({category:t,tag:n});if(i.length===0){console.log(`No curated entries found.`);return}console.log(`Curated entries (${i.length})`),console.log(`─`.repeat(60));for(let e of i){console.log(e.path),console.log(` ${e.title}`),console.log(` Category: ${e.category} | Version: ${e.version}`),console.log(` Tags: ${e.tags.length>0?e.tags.join(`, `):`None`}`);let t=e.contentPreview.replace(/\s+/g,` `).trim();t&&console.log(` Preview: ${t}`),console.log(``)}}},{name:`update`,description:`Update a curated entry`,usage:`aikit update <path> --reason <reason>`,run:async e=>{let t=y(e,`--reason`,``).trim(),n=e.shift()?.trim()??``,r=await s();(!n||!t||!r.trim())&&(console.error(`Usage: aikit update <path> --reason <reason>`),process.exit(1));let{curated:i}=await Q(),a=await i.update(n,r,t);console.log(`Updated curated entry`),console.log(` Path: ${a.path}`),console.log(` Version: ${a.version}`)}},{name:`compact`,description:`Compress text for context`,usage:`aikit compact <query> [--path <file>] [--max-chars N] [--segmentation paragraph|sentence|line]`,run:async e=>{let t=E(e,`--max-chars`,3e3),n=y(e,`--path`,``).trim()||void 0,r=y(e,`--segmentation`,`paragraph`),i=e.join(` `).trim(),a=n?void 0:await s();(!i||!n&&!a?.trim())&&(console.error(`Usage: aikit compact <query> --path <file> OR cat file | aikit compact <query>`),process.exit(1));let{embedder:o}=await Q(),c=n?await Te(o,{path:n,query:i,maxChars:t,segmentation:r}):await Te(o,{text:a??``,query:i,maxChars:t,segmentation:r});console.log(`Compressed ${c.originalChars} chars to ${c.compressedChars} chars`),console.log(`Ratio: ${(c.ratio*100).toFixed(1)}% | Segments: ${c.segmentsKept}/${c.segmentsTotal}`),console.log(``),console.log(c.text)}}],rr=[{name:`search`,description:`Search the AI Kit index`,usage:`aikit search <query> [--limit N] [--mode hybrid|semantic|keyword] [--graph-hops 0-3]`,run:async e=>{let t=E(e,`--limit`,5),n=y(e,`--mode`,`hybrid`),r=E(e,`--graph-hops`,0),i=e.join(` `).trim();i||(console.error(`Usage: aikit search <query>`),process.exit(1));let{embedder:a,store:o,graphStore:s}=await Q(),c=await a.embedQuery(i),l;if(n===`keyword`)l=await o.ftsSearch(i,{limit:t});else if(n===`semantic`)l=await o.search(c,{limit:t});else{let[e,n]=await Promise.all([o.search(c,{limit:t*2}),o.ftsSearch(i,{limit:t*2}).catch(()=>[])]);l=d(e,n).slice(0,t)}if(l.length===0){console.log(`No results found.`);return}for(let{record:e,score:t}of l){console.log(`\n${`─`.repeat(60)}`),console.log(`[${(t*100).toFixed(1)}%] ${e.sourcePath}:${e.startLine}-${e.endLine}`),console.log(` Type: ${e.contentType} | Origin: ${e.origin}`),e.tags.length>0&&console.log(` Tags: ${e.tags.join(`, `)}`),console.log(``);let n=e.content.length>500?`${e.content.slice(0,500)}...`:e.content;console.log(n)}if(console.log(`\n${`─`.repeat(60)}`),console.log(`${l.length} result(s) found.`),r>0&&l.length>0)try{let{graphAugmentSearch:e}=await import(`../../tools/dist/index.js`),t=(await e(s,l.map(e=>({recordId:e.record.id,score:e.score,sourcePath:e.record.sourcePath})),{hops:r,maxPerHit:5})).filter(e=>e.graphContext.nodes.length>0);if(t.length>0){console.log(`\nGraph context (${r} hop${r>1?`s`:``}):\n`);for(let e of t){console.log(` ${e.sourcePath}:`);for(let t of e.graphContext.nodes.slice(0,5))console.log(` → ${t.name} (${t.type})`);for(let t of e.graphContext.edges.slice(0,5))console.log(` → ${t.fromId} --[${t.type}]--> ${t.toId}`)}}}catch(e){console.error(`[graph] augmentation failed: ${e.message}`)}}},{name:`find`,description:`Run federated search across indexed content and files`,usage:`aikit find [query] [--glob <pattern>] [--pattern <regex>] [--limit N]`,run:async e=>{let t=E(e,`--limit`,10),n=y(e,`--glob`,``).trim()||void 0,r=y(e,`--pattern`,``).trim()||void 0,i=e.join(` `).trim()||void 0;!i&&!n&&!r&&(console.error(`Usage: aikit find [query] [--glob <pattern>] [--pattern <regex>] [--limit N]`),process.exit(1));let{embedder:a,store:o}=await Q(),s=await Ne(a,o,{query:i,glob:n,pattern:r,limit:t});if(s.results.length===0){console.log(`No matches found.`);return}console.log(`Strategies: ${s.strategies.join(`, `)}`),console.log(`Results: ${s.results.length} shown (${s.totalFound} total)`);for(let e of s.results){let t=e.lineRange?`:${e.lineRange.start}-${e.lineRange.end}`:``;console.log(`\n[${e.source}] ${e.path}${t}`),console.log(` Score: ${(e.score*100).toFixed(1)}%`),e.preview&&console.log(` ${e.preview.replace(/\s+/g,` `).trim()}`)}}},{name:`scope-map`,description:`Generate a reading plan for a task`,usage:`aikit scope-map <task> [--max-files N]`,run:async e=>{let t=E(e,`--max-files`,15),n=e.join(` `).trim();n||(console.error(`Usage: aikit scope-map <task> [--max-files N]`),process.exit(1));let{embedder:r,store:i}=await Q(),a=await ht(r,i,{task:n,maxFiles:t});console.log(`Task: ${a.task}`),console.log(`Files: ${a.files.length}`),console.log(`Estimated tokens: ${a.totalEstimatedTokens}`),console.log(``),console.log(`Reading order:`);for(let e of a.readingOrder)console.log(` ${e}`);for(let[e,t]of a.files.entries())console.log(`\n${e+1}. ${t.path}`),console.log(` Relevance: ${(t.relevance*100).toFixed(1)}% | Tokens: ${t.estimatedTokens}`),console.log(` Why: ${t.reason}`),t.focusRanges.length>0&&console.log(` Focus: ${b(t.focusRanges)}`)}},{name:`symbol`,description:`Resolve a symbol definition, imports, and references`,usage:`aikit symbol <name> [--limit N]`,run:async e=>{let t=E(e,`--limit`,20),n=e.join(` `).trim();n||(console.error(`Usage: aikit symbol <name> [--limit N]`),process.exit(1));let{embedder:r,store:i}=await Q();u(await xt(r,i,{name:n,limit:t}))}},{name:`trace`,description:`Trace forward/backward flow for a symbol or file location`,usage:`aikit trace <start> [--direction forward|backward|both] [--max-depth N]`,run:async e=>{let t=y(e,`--direction`,`both`).trim()||`both`,n=E(e,`--max-depth`,3),r=e.join(` `).trim();(!r||![`forward`,`backward`,`both`].includes(t))&&(console.error(`Usage: aikit trace <start> [--direction forward|backward|both] [--max-depth N]`),process.exit(1));let{embedder:i,store:a}=await Q();p(await Ct(i,a,{start:r,direction:t,maxDepth:n}))}},{name:`examples`,description:`Find real code examples of a symbol or pattern`,usage:`aikit examples <query> [--limit N] [--content-type type]`,run:async e=>{let t=E(e,`--limit`,5),n=y(e,`--content-type`,``).trim()||void 0,r=e.join(` `).trim();r||(console.error(`Usage: aikit examples <query> [--limit N] [--content-type type]`),process.exit(1));let{embedder:i,store:a}=await Q();le(await Fe(i,a,{query:r,limit:t,contentType:n}))}},{name:`dead-symbols`,description:`Find exported symbols that appear to be unused`,usage:`aikit dead-symbols [--limit N]`,run:async e=>{let t=E(e,`--limit`,100),{embedder:n,store:r}=await Q();ue(await Pe(n,r,{limit:t}))}},{name:`lookup`,description:`Look up indexed content by record ID or source path`,usage:`aikit lookup <id>`,run:async e=>{let t=e.join(` `).trim();t||(console.error(`Usage: aikit lookup <id>`),process.exit(1));let{store:n}=await Q(),r=await n.getById(t);if(r){console.log(r.id),console.log(`─`.repeat(60)),console.log(`Path: ${r.sourcePath}`),console.log(`Chunk: ${r.chunkIndex+1}/${r.totalChunks}`),console.log(`Lines: ${r.startLine}-${r.endLine}`),console.log(`Type: ${r.contentType} | Origin: ${r.origin}`),r.tags.length>0&&console.log(`Tags: ${r.tags.join(`, `)}`),console.log(``),console.log(r.content);return}let i=await n.getBySourcePath(t);if(i.length===0){console.log(`No indexed content found for: ${t}`);return}i.sort((e,t)=>e.chunkIndex-t.chunkIndex),console.log(t),console.log(`─`.repeat(60)),console.log(`Chunks: ${i.length} | Type: ${i[0].contentType}`);for(let e of i){let t=e.startLine?` (lines ${e.startLine}-${e.endLine})`:``;console.log(`\nChunk ${e.chunkIndex+1}/${e.totalChunks}${t}`),console.log(e.content)}}}],ir=[{name:`status`,description:`Show AI Kit index status and statistics`,run:async()=>{let{isUserInstalled:e,getGlobalDataDir:t,computePartitionKey:n,listWorkspaces:r}=await import(`../../core/dist/index.js`),{existsSync:i}=await import(`node:fs`),a=process.cwd(),o=e(),s=i(L(a,`.vscode`,`mcp.json`)),c,l;if(o&&s)c=`workspace (overrides user-level for this workspace)`,l=L(a,`.aikit-data`);else if(o){let e=n(a);c=i(L(a,`AGENTS.md`))?`user (workspace scaffolded)`:`user (workspace not scaffolded)`,l=L(t(),e)}else c=`workspace`,l=L(a,`.aikit-data`);if(console.log(`AI Kit Status`),console.log(`─`.repeat(40)),console.log(` Mode: ${c}`),console.log(` Data: ${l}`),o&&!s){let e=r();console.log(` Registry: ${e.length} workspace(s) enrolled`)}try{let{store:e}=await Q(),t=await e.getStats(),n=await e.listSourcePaths();console.log(` Records: ${t.totalRecords}`),console.log(` Files: ${t.totalFiles}`),console.log(` Indexed: ${t.lastIndexedAt??`Never`}`),console.log(` Backend: ${t.storeBackend}`),console.log(` Model: ${t.embeddingModel}`),console.log(``),console.log(`Content Types:`);for(let[e,n]of Object.entries(t.contentTypeBreakdown))console.log(` ${e}: ${n}`);if(n.length>0){console.log(``),console.log(`Files (${n.length} total):`);for(let e of n.slice(0,20))console.log(` ${e}`);n.length>20&&console.log(` ... and ${n.length-20} more`)}}catch{console.log(``),console.log(" Index not available — run `aikit reindex` to index this workspace.")}o&&!s&&!i(L(a,`AGENTS.md`))&&(console.log(``),console.log(" Action: Run `npx @vpxa/aikit init` to add AGENTS.md and copilot-instructions.md"))}},{name:`reindex`,description:`Re-index the AI Kit index from configured sources`,usage:`aikit reindex [--full]`,run:async e=>{let t=e.includes(`--full`),{store:n,indexer:r,curated:i,config:a}=await Q();console.log(`Indexing sources...`);let o=e=>{e.phase===`chunking`&&e.currentFile&&process.stdout.write(`\r [${e.filesProcessed+1}/${e.filesTotal}] ${e.currentFile}`),e.phase===`done`&&process.stdout.write(`
|
|
16
|
-
`)},s;t?(console.log(`Dropping existing index for full reindex...`),s=await r.reindexAll(a,o)):s=await r.index(a,o),console.log(`Done: ${s.filesProcessed} files, ${s.chunksCreated} chunks in ${(s.durationMs/1e3).toFixed(1)}s`),console.log(`Building FTS index...`),await n.createFtsIndex(),console.log(`Re-indexing curated entries...`);let c=await i.reindexAll();console.log(`Curated: ${c.indexed} entries restored`)}},{name:`serve`,description:`Start the MCP server (stdio or HTTP)`,usage:`aikit serve [--transport stdio|http] [--port N]`,run:async e=>{let t=S(),n=y(e,`--transport`,`stdio`),r=y(e,`--port`,`3210`);try{await Hn({silent:!0})}catch{}let i=It(t,[],{stdio:n===`stdio`?[`pipe`,`pipe`,`inherit`,`ipc`]:`inherit`,env:{...process.env,AIKIT_TRANSPORT:n,AIKIT_PORT:r}});n===`stdio`&&i.stdin&&i.stdout&&(process.stdin.pipe(i.stdin),i.stdout.pipe(process.stdout)),i.on(`exit`,e=>process.exit(e??0)),process.on(`SIGINT`,()=>i.kill(`SIGINT`)),process.on(`SIGTERM`,()=>i.kill(`SIGTERM`)),await new Promise(()=>{})}},{name:`init`,description:`Initialize AI Kit in the current directory`,usage:`aikit init [--workspace] [--smart] [--force] [--guide]`,run:async e=>{let t=e.includes(`--user`),n=e.includes(`--workspace`),r=e.includes(`--smart`),i=e.includes(`--guide`),a=e.includes(`--force`);if(t&&n&&(console.error(`Cannot use --user and --workspace together.`),process.exit(1)),i){let{guideProject:e}=await import(`./init-
|
|
16
|
+
`)},s;t?(console.log(`Dropping existing index for full reindex...`),s=await r.reindexAll(a,o)):s=await r.index(a,o),console.log(`Done: ${s.filesProcessed} files, ${s.chunksCreated} chunks in ${(s.durationMs/1e3).toFixed(1)}s`),console.log(`Building FTS index...`),await n.createFtsIndex(),console.log(`Re-indexing curated entries...`);let c=await i.reindexAll();console.log(`Curated: ${c.indexed} entries restored`)}},{name:`serve`,description:`Start the MCP server (stdio or HTTP)`,usage:`aikit serve [--transport stdio|http] [--port N]`,run:async e=>{let t=S(),n=y(e,`--transport`,`stdio`),r=y(e,`--port`,`3210`);try{await Hn({silent:!0})}catch{}let i=It(t,[],{stdio:n===`stdio`?[`pipe`,`pipe`,`inherit`,`ipc`]:`inherit`,env:{...process.env,AIKIT_TRANSPORT:n,AIKIT_PORT:r}});n===`stdio`&&i.stdin&&i.stdout&&(process.stdin.pipe(i.stdin),i.stdout.pipe(process.stdout)),i.on(`exit`,e=>process.exit(e??0)),process.on(`SIGINT`,()=>i.kill(`SIGINT`)),process.on(`SIGTERM`,()=>i.kill(`SIGTERM`)),await new Promise(()=>{})}},{name:`init`,description:`Initialize AI Kit in the current directory`,usage:`aikit init [--workspace] [--smart] [--force] [--guide]`,run:async e=>{let t=e.includes(`--user`),n=e.includes(`--workspace`),r=e.includes(`--smart`),i=e.includes(`--guide`),a=e.includes(`--force`);if(t&&n&&(console.error(`Cannot use --user and --workspace together.`),process.exit(1)),i){let{guideProject:e}=await import(`./init-BgelSos0.js`);await e();return}if(r){let{initSmart:e}=await import(`./init-BgelSos0.js`);await e({force:a})}else if(t)await K({force:a});else if(n){let{initProject:e}=await import(`./init-BgelSos0.js`);await e({force:a})}else await K({force:a})}},{name:`check`,description:`Run incremental typecheck and lint`,usage:`aikit check [--cwd <dir>] [--files f1,f2] [--skip-types] [--skip-lint] [--detail efficient|normal|full]`,run:async e=>{let t=y(e,`--cwd`,``).trim()||void 0,n=y(e,`--files`,``),r=y(e,`--detail`,`full`)||`full`,i=n.split(`,`).map(e=>e.trim()).filter(Boolean),a=!1;e.includes(`--skip-types`)&&(e.splice(e.indexOf(`--skip-types`),1),a=!0);let o=!1;e.includes(`--skip-lint`)&&(e.splice(e.indexOf(`--skip-lint`),1),o=!0);let s=await ye({cwd:t,files:i.length>0?i:void 0,skipTypes:a,skipLint:o,detail:r});h(s),s.passed||(process.exitCode=1)}},{name:`health`,description:`Run project health checks on the current directory`,usage:`aikit health [path]`,run:async e=>{let t=Be(e.shift());console.log(`Project Health: ${t.path}`),console.log(`─`.repeat(50));for(let e of t.checks){let t=e.status===`pass`?`+`:e.status===`warn`?`~`:`X`;console.log(` [${t}] ${e.name}: ${e.message}`)}console.log(`─`.repeat(50)),console.log(`Score: ${t.score}% — ${t.summary}`)}},{name:`prune`,description:`Clean up orphaned storage, legacy data, and stale partitions`,usage:`aikit prune [--dry-run] [--max-age-days=90] [--force]`,run:async e=>{let{prune:t,formatBytes:n,markPruneRun:r}=await import(`../../tools/dist/index.js`),i=e.includes(`--dry-run`),a=e.includes(`--force`),o=e.find(e=>e.startsWith(`--max-age-days=`)),s=o?Number.parseInt(o.split(`=`)[1]??``,10):90;if(!i&&!a){console.log(`⚠️ This will permanently delete data. Use --dry-run to preview, or --force to execute.`);return}console.log(i?`🔍 Dry run — no files will be deleted
|
|
17
17
|
`:`🧹 Pruning storage...
|
|
18
18
|
`);let c=await t({dryRun:i,maxAgeDays:s});console.log(`Results:`),console.log(` Forge-ground orphans: ${c.forgeGroundOrphans.count} dirs (${n(c.forgeGroundOrphans.bytesFreed)})`),console.log(` Legacy LanceDB: ${c.legacyLance.count} dirs (${n(c.legacyLance.bytesFreed)})`),console.log(` Empty ephemeral dirs: ${c.emptyEphemeral.count} dirs`),console.log(` Stale partitions: ${c.stalePartitions.count} dirs (${n(c.stalePartitions.bytesFreed)})`),console.log(` Browser profiles: ${c.browserProfiles.count} dirs (${n(c.browserProfiles.bytesFreed)})`),console.log(`\n Total freed: ${n(c.totalBytesFreed)}`),i||(r(),console.log(`
|
|
19
19
|
✅ Cleanup complete.`))}},{name:`audit`,description:`Run a unified project audit (structure, deps, patterns, health, dead symbols, check)`,usage:`aikit audit [path] [--checks structure,dependencies,patterns,health,dead_symbols,check,entry_points] [--detail efficient|normal|full]`,run:async e=>{let{store:t,embedder:n}=await Q(),r=y(e,`--detail`,`efficient`)||`efficient`,i=y(e,`--checks`,``),a=i?i.split(`,`).map(e=>e.trim()):void 0,o=await ve(t,n,{path:e.shift()||`.`,checks:a,detail:r});if(o.ok){if(console.log(o.summary),o.next&&o.next.length>0){console.log(`
|
|
20
|
-
Suggested next steps:`);for(let e of o.next)console.log(` → ${e.tool}: ${e.reason}`)}}else console.error(o.error?.message??`Audit failed`),process.exitCode=1}},{name:`guide`,description:`Tool discovery — recommend AI Kit tools for a given goal`,usage:`aikit guide <goal> [--max N]`,run:async e=>{let t=e.indexOf(`--max`),n=5;t!==-1&&t+1<e.length&&(n=Number.parseInt(e.splice(t,2)[1],10)||5);let r=e.join(` `).trim();r||(console.error(`Usage: aikit guide <goal> [--max N]`),console.error(`Example: aikit guide "audit this project"`),process.exit(1));let i=ze(r,n);console.log(`Workflow: ${i.workflow}`),console.log(` ${i.description}\n`),console.log(`Recommended tools:`);for(let e of i.tools){let t=e.suggestedArgs?` ${JSON.stringify(e.suggestedArgs)}`:``;console.log(` ${e.order}. ${e.tool} — ${e.reason}${t}`)}i.alternativeWorkflows.length>0&&console.log(`\nAlternatives: ${i.alternativeWorkflows.join(`, `)}`)}},{name:`replay`,description:`Show recent tool invocation audit trail`,usage:`aikit replay [--last N] [--tool <name>] [--source mcp|cli]`,run:async e=>{let t=ft({last:Number.parseInt(e[e.indexOf(`--last`)+1],10)||20,tool:e.includes(`--tool`)?e[e.indexOf(`--tool`)+1]:void 0,source:e.includes(`--source`)?e[e.indexOf(`--source`)+1]:void 0});if(t.length===0){console.log(`No replay entries. Activity is logged when tools are invoked.`);return}console.log(`Replay Log (${t.length} entries)\n`);for(let e of t){let t=e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts,n=e.status===`ok`?`✓`:`✗`;console.log(`${t} ${n} ${e.tool} (${e.durationMs}ms) [${e.source}]`),console.log(` in: ${e.input}`),console.log(` out: ${e.output}`)}pt().catch(()=>{})}},{name:`replay-clear`,description:`Clear the replay audit trail`,run:async()=>{dt(),console.log(`Replay log cleared.`)}},{name:`dashboard`,description:`Launch web dashboard for knowledge graph visualization`,usage:`aikit dashboard [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=S(),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),l=`http://localhost:${r}/_dashboard/`,u=`http://localhost:${r}/health`,d=!1;for(let e=0;e<30;e+=1){try{if((await fetch(u)).ok){d=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(d||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Dashboard: ${l}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,l],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[l],{stdio:`ignore`,detached:!0}).unref()}let f=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,f),process.on(`SIGTERM`,f),await new Promise(e=>{c.on(`exit`,()=>e())})}},{name:`settings`,description:`Launch web UI to manage AI Kit configuration and environment variables`,usage:`aikit settings [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=S(),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),l=`http://localhost:${r}/settings/`,u=`http://localhost:${r}/health`,d=!1;for(let e=0;e<30;e+=1){try{if((await fetch(u)).ok){d=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(d||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Settings: ${l}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,l],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[l],{stdio:`ignore`,detached:!0}).unref()}let f=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,f),process.on(`SIGTERM`,f),await new Promise(e=>{c.on(`exit`,()=>e())})}}],ar=[{name:`upgrade`,description:`Upgrade AI Kit agents, prompts, and skills to the latest version (user-level and workspace-level)`,usage:`aikit upgrade`,run:async()=>{await K({force:!0});let e=process.cwd();if(k(L(e,`.github`,`.aikit-scaffold.json`))){let{initScaffoldOnly:e}=await import(`./init-DCs4TWh6.js`);await e({force:!0})}if(k(L(e,`.github`,`skills`))){let{smartCopySkills:t}=await import(`./scaffold-BnhmnBfn.js`).then(e=>e.a),n=ae(),r=T();await t(e,n,[...ie],r,!0);let{smartCopyFlows:i}=await import(`./scaffold-BnhmnBfn.js`).then(e=>e.a);await i(e,n,[...oe],r,!0)}let{homedir:t}=await import(`node:os`),{rmSync:n}=await import(`node:fs`),r=F(t(),`.aikit`,`cache`,`wasm`);if(k(r))try{n(r,{recursive:!0,force:!0}),console.log(`✓ WASM cache cleared (will re-resolve on next start)`)}catch{console.warn(`⚠ Could not clear WASM cache at`,r)}}}],or=[{name:`workset`,description:`Manage saved file sets`,usage:`aikit workset <action> [name] [--files f1,f2] [--description desc]`,run:async e=>{let t=e.shift()?.trim(),n=f(y(e,`--files`,``)),r=y(e,`--description`,``).trim()||void 0,i=e.shift()?.trim();switch(t||(console.error(`Usage: aikit workset <action> [name] [--files f1,f2] [--description desc]`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)),t){case`save`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset save <name> --files f1,f2 [--description desc]`),process.exit(1));let e=mt(i,n,{description:r});console.log(`Saved workset: ${e.name}`),C(e);return}case`get`:{i||(console.error(`Usage: aikit workset get <name>`),process.exit(1));let e=Ie(i);if(!e){console.log(`No workset found: ${i}`);return}C(e);return}case`list`:{let e=qe();if(e.length===0){console.log(`No worksets saved.`);return}console.log(`Worksets (${e.length})`),console.log(`─`.repeat(60));for(let t of e)C(t),console.log(``);return}case`delete`:{i||(console.error(`Usage: aikit workset delete <name>`),process.exit(1));let e=ke(i);console.log(e?`Deleted workset: ${i}`:`No workset found: ${i}`);return}case`add`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset add <name> --files f1,f2`),process.exit(1));let e=_e(i,n);console.log(`Updated workset: ${e.name}`),C(e);return}case`remove`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset remove <name> --files f1,f2`),process.exit(1));let e=lt(i,n);if(!e){console.log(`No workset found: ${i}`);return}console.log(`Updated workset: ${e.name}`),C(e);return}default:console.error(`Unknown workset action: ${t}`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)}}},{name:`stash`,description:`Persist and retrieve named intermediate values`,usage:`aikit stash <set|get|list|delete|clear> [key] [value]`,run:async e=>{let t=e.shift()?.trim(),n=e.shift()?.trim();t||(console.error(`Usage: aikit stash <set|get|list|delete|clear> [key] [value]`),process.exit(1));let r=await v();switch(t){case`set`:{n||(console.error(`Usage: aikit stash set <key> <value>`),process.exit(1));let t=e.join(` `),i=t.trim()?``:await s(),a=bt(r,n,ne(t||i));console.log(`Stored stash entry: ${a.key}`),console.log(` Type: ${a.type}`),console.log(` Stored: ${a.storedAt}`);return}case`get`:{n||(console.error(`Usage: aikit stash get <key>`),process.exit(1));let e=vt(r,n);if(!e){console.log(`No stash entry found: ${n}`);return}console.log(JSON.stringify(e,null,2));return}case`list`:{let e=yt(r);if(e.length===0){console.log(`No stash entries saved.`);return}console.log(`Stash entries (${e.length})`),console.log(`─`.repeat(60));for(let t of e)console.log(`${t.key} (${t.type})`),console.log(` Stored: ${t.storedAt}`);return}case`delete`:{n||(console.error(`Usage: aikit stash delete <key>`),process.exit(1));let e=_t(r,n);console.log(e?`Deleted stash entry: ${n}`:`No stash entry found: ${n}`);return}case`clear`:{let e=gt(r);console.log(`Cleared ${e} stash entr${e===1?`y`:`ies`}.`);return}default:console.error(`Unknown stash action: ${t}`),console.error(`Actions: set, get, list, delete, clear`),process.exit(1)}}},{name:`lane`,description:`Manage verified lanes — isolated file copies for parallel exploration`,usage:`aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`,run:async e=>{let t=e.shift();if((!t||![`create`,`list`,`status`,`diff`,`merge`,`discard`].includes(t))&&(console.error(`Usage: aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`),process.exit(1)),t===`list`){let e=We();if(e.length===0){console.log(`No active lanes.`);return}for(let t of e)console.log(`${t.name} (${t.sourceFiles.length} files, created ${t.createdAt})`);return}let n=e.shift();switch(n||(console.error(`Lane name is required for "${t}".`),process.exit(1)),t){case`create`:{let t=y(e,`--files`,``);t||(console.error(`Usage: aikit lane create <name> --files file1.ts,file2.ts`),process.exit(1));let r=Ve(n,t.split(`,`).map(e=>e.trim()));console.log(`Lane "${r.name}" created with ${r.sourceFiles.length} files.`);break}case`status`:{let e=Ke(n);console.log(`Lane: ${e.name}`),console.log(`Modified: ${e.modified} | Added: ${e.added} | Deleted: ${e.deleted}`);for(let t of e.entries)console.log(` ${t.status.padEnd(10)} ${t.file}`);break}case`diff`:{let e=He(n);console.log(`Lane: ${e.name} — ${e.modified} modified, ${e.added} added, ${e.deleted} deleted`);for(let t of e.entries)t.diff&&(console.log(`\n--- ${t.file} (${t.status})`),console.log(t.diff));break}case`merge`:{let e=Ge(n);console.log(`Merged ${e.filesMerged} files from lane "${e.name}".`);for(let t of e.files)console.log(` ${t}`);break}case`discard`:{let e=Ue(n);console.log(e?`Lane "${n}" discarded.`:`Lane "${n}" not found.`);break}}}},{name:`queue`,description:`Manage task queues for sequential agent operations`,usage:`aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`,run:async e=>{let t=e.shift();if((!t||![`create`,`push`,`next`,`done`,`fail`,`get`,`list`,`clear`,`delete`].includes(t))&&(console.error(`Usage: aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`),process.exit(1)),t===`list`){let e=ot();if(e.length===0){console.log(`No queues.`);return}for(let t of e)console.log(`${t.name} pending:${t.pending} done:${t.done} failed:${t.failed} total:${t.total}`);return}let n=e.shift();switch(n||(console.error(`Queue name is required for "${t}".`),process.exit(1)),t){case`create`:{let e=tt(n);console.log(`Queue "${e.name}" created.`);break}case`push`:{let t=ct(n,e.join(` `)||`Untitled task`);console.log(`Pushed "${t.title}" (${t.id}) to queue "${n}".`);break}case`next`:{let e=st(n);console.log(e?`Next: ${e.title} (${e.id})`:`No pending items in queue "${n}".`);break}case`done`:{let t=e.shift();t||(console.error(`Usage: aikit queue done <name> <id>`),process.exit(1));let r=rt(n,t);console.log(`Marked "${r.item.title}" as done.`);break}case`fail`:{let t=e.shift(),r=e.join(` `)||`Unknown error`;t||(console.error(`Usage: aikit queue fail <name> <id> [error message]`),process.exit(1));let i=it(n,t,r);console.log(`Marked "${i.title}" as failed: ${r}`);break}case`get`:{let e=at(n);if(!e){console.log(`Queue "${n}" not found.`);return}console.log(`Queue: ${e.name} (${e.items.length} items)`);for(let t of e.items){let e=t.error?` — ${t.error}`:``;console.log(` ${t.status.padEnd(12)} ${t.id} ${t.title}${e}`)}break}case`clear`:{let e=et(n);console.log(`Cleared ${e} completed/failed items from queue "${n}".`);break}case`delete`:{let e=nt(n);console.log(e?`Queue "${n}" deleted.`:`Queue "${n}" not found.`);break}}}}],$=[...rr,...nr,...Gt,...tr,...ir,...Gn,...Kt,...or,...Wn,...ar,...$n,...Un];$.push({name:`help`,description:`Show available commands`,run:async()=>{cr()}});async function sr(e){let t=[...e],n=t.shift();if(!n||n===`--help`||n===`-h`){cr();return}if(n===`--version`||n===`-v`){let e=L(P(ge(import.meta.url)),`..`,`..`,`..`,`package.json`),t=JSON.parse(j(e,`utf-8`));console.log(t.version);return}if(n&&new Set([`--user`,`--workspace`,`--guide`,`--smart`]).has(n)){let e=$.find(e=>e.name===`init`);if(e){await e.run([n,...t]);return}}let r=$.find(e=>e.name===n);r||(console.error(`Unknown command: ${n}`),cr(),process.exit(1));try{await r.run(t)}finally{let e=er();e&&await e.store.close()}}function cr(){console.log(`@vpxa/aikit — Local-first AI developer toolkit
|
|
20
|
+
Suggested next steps:`);for(let e of o.next)console.log(` → ${e.tool}: ${e.reason}`)}}else console.error(o.error?.message??`Audit failed`),process.exitCode=1}},{name:`guide`,description:`Tool discovery — recommend AI Kit tools for a given goal`,usage:`aikit guide <goal> [--max N]`,run:async e=>{let t=e.indexOf(`--max`),n=5;t!==-1&&t+1<e.length&&(n=Number.parseInt(e.splice(t,2)[1],10)||5);let r=e.join(` `).trim();r||(console.error(`Usage: aikit guide <goal> [--max N]`),console.error(`Example: aikit guide "audit this project"`),process.exit(1));let i=ze(r,n);console.log(`Workflow: ${i.workflow}`),console.log(` ${i.description}\n`),console.log(`Recommended tools:`);for(let e of i.tools){let t=e.suggestedArgs?` ${JSON.stringify(e.suggestedArgs)}`:``;console.log(` ${e.order}. ${e.tool} — ${e.reason}${t}`)}i.alternativeWorkflows.length>0&&console.log(`\nAlternatives: ${i.alternativeWorkflows.join(`, `)}`)}},{name:`replay`,description:`Show recent tool invocation audit trail`,usage:`aikit replay [--last N] [--tool <name>] [--source mcp|cli]`,run:async e=>{let t=ft({last:Number.parseInt(e[e.indexOf(`--last`)+1],10)||20,tool:e.includes(`--tool`)?e[e.indexOf(`--tool`)+1]:void 0,source:e.includes(`--source`)?e[e.indexOf(`--source`)+1]:void 0});if(t.length===0){console.log(`No replay entries. Activity is logged when tools are invoked.`);return}console.log(`Replay Log (${t.length} entries)\n`);for(let e of t){let t=e.ts.split(`T`)[1]?.split(`.`)[0]??e.ts,n=e.status===`ok`?`✓`:`✗`;console.log(`${t} ${n} ${e.tool} (${e.durationMs}ms) [${e.source}]`),console.log(` in: ${e.input}`),console.log(` out: ${e.output}`)}pt().catch(()=>{})}},{name:`replay-clear`,description:`Clear the replay audit trail`,run:async()=>{dt(),console.log(`Replay log cleared.`)}},{name:`dashboard`,description:`Launch web dashboard for knowledge graph visualization`,usage:`aikit dashboard [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=S(),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),l=`http://localhost:${r}/_dashboard/`,u=`http://localhost:${r}/health`,d=!1;for(let e=0;e<30;e+=1){try{if((await fetch(u)).ok){d=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(d||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Dashboard: ${l}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,l],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[l],{stdio:`ignore`,detached:!0}).unref()}let f=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,f),process.on(`SIGTERM`,f),await new Promise(e=>{c.on(`exit`,()=>e())})}},{name:`settings`,description:`Launch web UI to manage AI Kit configuration and environment variables`,usage:`aikit settings [--port <port>] [--no-open]`,run:async e=>{let t=e.indexOf(`--port`),n=t!==-1&&e[t+1]?Number.parseInt(e[t+1],10):3210,r=Number.isFinite(n)?n:3210,i=e.includes(`--no-open`);console.log(`Starting AI Kit server on port ${r}...`);let{spawn:a}=await import(`node:child_process`),{platform:o}=await import(`node:os`),s=S(),c=a(process.execPath,[s,`--transport`,`http`,`--port`,String(r)],{stdio:[`ignore`,`pipe`,`pipe`],env:{...process.env,AIKIT_TRANSPORT:`http`,AIKIT_PORT:String(r)}}),l=`http://localhost:${r}/settings/`,u=`http://localhost:${r}/health`,d=!1;for(let e=0;e<30;e+=1){try{if((await fetch(u)).ok){d=!0;break}}catch{}await new Promise(e=>setTimeout(e,1e3))}if(d||(console.error(`Server failed to start within 30 seconds.`),c.kill(),process.exit(1)),console.log(`AI Kit Settings: ${l}`),console.log(`Press Ctrl+C to stop.`),!i){let e=o();e===`win32`?a(`cmd`,[`/c`,`start`,``,l],{stdio:`ignore`,detached:!0}).unref():a(e===`darwin`?`open`:`xdg-open`,[l],{stdio:`ignore`,detached:!0}).unref()}let f=()=>{c.kill(),process.exit(0)};process.on(`SIGINT`,f),process.on(`SIGTERM`,f),await new Promise(e=>{c.on(`exit`,()=>e())})}}],ar=[{name:`upgrade`,description:`Upgrade AI Kit agents, prompts, and skills to the latest version (user-level and workspace-level)`,usage:`aikit upgrade`,run:async()=>{await K({force:!0});let e=process.cwd();if(k(L(e,`.github`,`.aikit-scaffold.json`))){let{initScaffoldOnly:e}=await import(`./init-BgelSos0.js`);await e({force:!0})}if(k(L(e,`.github`,`skills`))){let{smartCopySkills:t}=await import(`./scaffold-Cxjwg531.js`).then(e=>e.a),n=ae(),r=T();await t(e,n,[...ie],r,!0);let{smartCopyFlows:i}=await import(`./scaffold-Cxjwg531.js`).then(e=>e.a);await i(e,n,[...oe],r,!0)}let{homedir:t}=await import(`node:os`),{rmSync:n}=await import(`node:fs`),r=F(t(),`.aikit`,`cache`,`wasm`);if(k(r))try{n(r,{recursive:!0,force:!0}),console.log(`✓ WASM cache cleared (will re-resolve on next start)`)}catch{console.warn(`⚠ Could not clear WASM cache at`,r)}}}],or=[{name:`workset`,description:`Manage saved file sets`,usage:`aikit workset <action> [name] [--files f1,f2] [--description desc]`,run:async e=>{let t=e.shift()?.trim(),n=f(y(e,`--files`,``)),r=y(e,`--description`,``).trim()||void 0,i=e.shift()?.trim();switch(t||(console.error(`Usage: aikit workset <action> [name] [--files f1,f2] [--description desc]`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)),t){case`save`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset save <name> --files f1,f2 [--description desc]`),process.exit(1));let e=mt(i,n,{description:r});console.log(`Saved workset: ${e.name}`),C(e);return}case`get`:{i||(console.error(`Usage: aikit workset get <name>`),process.exit(1));let e=Ie(i);if(!e){console.log(`No workset found: ${i}`);return}C(e);return}case`list`:{let e=qe();if(e.length===0){console.log(`No worksets saved.`);return}console.log(`Worksets (${e.length})`),console.log(`─`.repeat(60));for(let t of e)C(t),console.log(``);return}case`delete`:{i||(console.error(`Usage: aikit workset delete <name>`),process.exit(1));let e=ke(i);console.log(e?`Deleted workset: ${i}`:`No workset found: ${i}`);return}case`add`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset add <name> --files f1,f2`),process.exit(1));let e=_e(i,n);console.log(`Updated workset: ${e.name}`),C(e);return}case`remove`:{(!i||n.length===0)&&(console.error(`Usage: aikit workset remove <name> --files f1,f2`),process.exit(1));let e=lt(i,n);if(!e){console.log(`No workset found: ${i}`);return}console.log(`Updated workset: ${e.name}`),C(e);return}default:console.error(`Unknown workset action: ${t}`),console.error(`Actions: save, get, list, delete, add, remove`),process.exit(1)}}},{name:`stash`,description:`Persist and retrieve named intermediate values`,usage:`aikit stash <set|get|list|delete|clear> [key] [value]`,run:async e=>{let t=e.shift()?.trim(),n=e.shift()?.trim();t||(console.error(`Usage: aikit stash <set|get|list|delete|clear> [key] [value]`),process.exit(1));let r=await v();switch(t){case`set`:{n||(console.error(`Usage: aikit stash set <key> <value>`),process.exit(1));let t=e.join(` `),i=t.trim()?``:await s(),a=bt(r,n,ne(t||i));console.log(`Stored stash entry: ${a.key}`),console.log(` Type: ${a.type}`),console.log(` Stored: ${a.storedAt}`);return}case`get`:{n||(console.error(`Usage: aikit stash get <key>`),process.exit(1));let e=vt(r,n);if(!e){console.log(`No stash entry found: ${n}`);return}console.log(JSON.stringify(e,null,2));return}case`list`:{let e=yt(r);if(e.length===0){console.log(`No stash entries saved.`);return}console.log(`Stash entries (${e.length})`),console.log(`─`.repeat(60));for(let t of e)console.log(`${t.key} (${t.type})`),console.log(` Stored: ${t.storedAt}`);return}case`delete`:{n||(console.error(`Usage: aikit stash delete <key>`),process.exit(1));let e=_t(r,n);console.log(e?`Deleted stash entry: ${n}`:`No stash entry found: ${n}`);return}case`clear`:{let e=gt(r);console.log(`Cleared ${e} stash entr${e===1?`y`:`ies`}.`);return}default:console.error(`Unknown stash action: ${t}`),console.error(`Actions: set, get, list, delete, clear`),process.exit(1)}}},{name:`lane`,description:`Manage verified lanes — isolated file copies for parallel exploration`,usage:`aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`,run:async e=>{let t=e.shift();if((!t||![`create`,`list`,`status`,`diff`,`merge`,`discard`].includes(t))&&(console.error(`Usage: aikit lane <create|list|status|diff|merge|discard> [name] [--files f1,f2]`),process.exit(1)),t===`list`){let e=We();if(e.length===0){console.log(`No active lanes.`);return}for(let t of e)console.log(`${t.name} (${t.sourceFiles.length} files, created ${t.createdAt})`);return}let n=e.shift();switch(n||(console.error(`Lane name is required for "${t}".`),process.exit(1)),t){case`create`:{let t=y(e,`--files`,``);t||(console.error(`Usage: aikit lane create <name> --files file1.ts,file2.ts`),process.exit(1));let r=Ve(n,t.split(`,`).map(e=>e.trim()));console.log(`Lane "${r.name}" created with ${r.sourceFiles.length} files.`);break}case`status`:{let e=Ke(n);console.log(`Lane: ${e.name}`),console.log(`Modified: ${e.modified} | Added: ${e.added} | Deleted: ${e.deleted}`);for(let t of e.entries)console.log(` ${t.status.padEnd(10)} ${t.file}`);break}case`diff`:{let e=He(n);console.log(`Lane: ${e.name} — ${e.modified} modified, ${e.added} added, ${e.deleted} deleted`);for(let t of e.entries)t.diff&&(console.log(`\n--- ${t.file} (${t.status})`),console.log(t.diff));break}case`merge`:{let e=Ge(n);console.log(`Merged ${e.filesMerged} files from lane "${e.name}".`);for(let t of e.files)console.log(` ${t}`);break}case`discard`:{let e=Ue(n);console.log(e?`Lane "${n}" discarded.`:`Lane "${n}" not found.`);break}}}},{name:`queue`,description:`Manage task queues for sequential agent operations`,usage:`aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`,run:async e=>{let t=e.shift();if((!t||![`create`,`push`,`next`,`done`,`fail`,`get`,`list`,`clear`,`delete`].includes(t))&&(console.error(`Usage: aikit queue <create|push|next|done|fail|get|list|clear|delete> [name] [args]`),process.exit(1)),t===`list`){let e=ot();if(e.length===0){console.log(`No queues.`);return}for(let t of e)console.log(`${t.name} pending:${t.pending} done:${t.done} failed:${t.failed} total:${t.total}`);return}let n=e.shift();switch(n||(console.error(`Queue name is required for "${t}".`),process.exit(1)),t){case`create`:{let e=tt(n);console.log(`Queue "${e.name}" created.`);break}case`push`:{let t=ct(n,e.join(` `)||`Untitled task`);console.log(`Pushed "${t.title}" (${t.id}) to queue "${n}".`);break}case`next`:{let e=st(n);console.log(e?`Next: ${e.title} (${e.id})`:`No pending items in queue "${n}".`);break}case`done`:{let t=e.shift();t||(console.error(`Usage: aikit queue done <name> <id>`),process.exit(1));let r=rt(n,t);console.log(`Marked "${r.item.title}" as done.`);break}case`fail`:{let t=e.shift(),r=e.join(` `)||`Unknown error`;t||(console.error(`Usage: aikit queue fail <name> <id> [error message]`),process.exit(1));let i=it(n,t,r);console.log(`Marked "${i.title}" as failed: ${r}`);break}case`get`:{let e=at(n);if(!e){console.log(`Queue "${n}" not found.`);return}console.log(`Queue: ${e.name} (${e.items.length} items)`);for(let t of e.items){let e=t.error?` — ${t.error}`:``;console.log(` ${t.status.padEnd(12)} ${t.id} ${t.title}${e}`)}break}case`clear`:{let e=et(n);console.log(`Cleared ${e} completed/failed items from queue "${n}".`);break}case`delete`:{let e=nt(n);console.log(e?`Queue "${n}" deleted.`:`Queue "${n}" not found.`);break}}}}],$=[...rr,...nr,...Gt,...tr,...ir,...Gn,...Kt,...or,...Wn,...ar,...$n,...Un];$.push({name:`help`,description:`Show available commands`,run:async()=>{cr()}});async function sr(e){let t=[...e],n=t.shift();if(!n||n===`--help`||n===`-h`){cr();return}if(n===`--version`||n===`-v`){let e=L(P(ge(import.meta.url)),`..`,`..`,`..`,`package.json`),t=JSON.parse(j(e,`utf-8`));console.log(t.version);return}if(n&&new Set([`--user`,`--workspace`,`--guide`,`--smart`]).has(n)){let e=$.find(e=>e.name===`init`);if(e){await e.run([n,...t]);return}}let r=$.find(e=>e.name===n);r||(console.error(`Unknown command: ${n}`),cr(),process.exit(1));try{await r.run(t)}finally{let e=er();e&&await e.store.close()}}function cr(){console.log(`@vpxa/aikit — Local-first AI developer toolkit
|
|
21
21
|
`),console.log(`Usage: aikit <command> [options]
|
|
22
22
|
`),console.log(`Commands:`);let e=Math.max(...$.map(e=>e.name.length));for(let t of $)console.log(` ${t.name.padEnd(e+2)}${t.description}`);console.log(``),console.log(`Options:`),console.log(` --help, -h Show this help`),console.log(` --version, -v Show version`)}export{sr as run};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e,l as t,n,o as r,r as i,t as a}from"./scaffold-
|
|
1
|
+
import{c as e,l as t,n,o as r,r as i,t as a}from"./scaffold-Cxjwg531.js";import{a as o,i as s,n as c,o as l,p as u,r as d,t as f}from"./templates-C92mODRl.js";import{appendFileSync as p,existsSync as m,mkdirSync as h,readFileSync as g,unlinkSync as _,writeFileSync as v}from"node:fs";import{basename as y,resolve as b}from"node:path";import{AIKIT_PATHS as x,EMBEDDING_DEFAULTS as S,isUserInstalled as C}from"../../core/dist/index.js";function w(e){return m(b(e,`.cursor`))?`cursor`:m(b(e,`.claude`))?`claude-code`:m(b(e,`.windsurf`))?`windsurf`:m(b(e,`.zed`))?`zed`:m(b(e,`.idea`))?`intellij`:`copilot`}function T(e){let t=[];return m(b(e,`.cursor`))&&t.push(`cursor`),(m(b(e,`.claude`))||m(b(e,`CLAUDE.md`)))&&t.push(`claude-code`),m(b(e,`.windsurf`))&&t.push(`windsurf`),m(b(e,`.zed`))&&t.push(`zed`),m(b(e,`.idea`))&&t.push(`intellij`),m(b(e,`.gemini`))&&t.push(`gemini-cli`),(m(b(e,`.codex`))||m(b(e,`codex.md`)))&&t.push(`codex-cli`),t.push(`copilot`),[...new Set(t)]}function E(e){return{servers:{[e]:{...s}}}}function D(e){let{type:t,...n}=s;return{mcpServers:{[e]:n}}}function O(e){let{type:t,...n}=s;return{context_servers:{[e]:{...n}}}}const k={scaffoldDir:`general`,writeMcpConfig(e,t){let n=b(e,`.vscode`),r=b(n,`mcp.json`);m(r)||(h(n,{recursive:!0}),v(r,`${JSON.stringify(E(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json`))},writeInstructions(e,t){let n=b(e,`.github`),r=b(n,`copilot-instructions.md`);h(n,{recursive:!0}),v(r,c(y(e),t),`utf-8`),console.log(` Updated .github/copilot-instructions.md`)},writeAgentsMd(e,t){v(b(e,`AGENTS.md`),f(y(e),t),`utf-8`),console.log(` Updated AGENTS.md`)}},A={scaffoldDir:`general`,writeMcpConfig(e,t){let n=b(e,`.mcp.json`);m(n)||(v(n,`${JSON.stringify(D(t),null,2)}\n`,`utf-8`),console.log(` Created .mcp.json`))},writeInstructions(e,t){let n=b(e,`CLAUDE.md`),r=y(e);v(n,`${c(r,t)}\n---\n\n${f(r,t)}`,`utf-8`),console.log(` Updated CLAUDE.md`)},writeAgentsMd(e,t){}},j={scaffoldDir:`general`,writeMcpConfig(e,t){let n=b(e,`.cursor`),r=b(n,`mcp.json`);m(r)||(h(n,{recursive:!0}),v(r,`${JSON.stringify(D(t),null,2)}\n`,`utf-8`),console.log(` Created .cursor/mcp.json`))},writeInstructions(e,t){let n=b(e,`.cursor`,`rules`),r=b(n,`aikit.mdc`);h(n,{recursive:!0});let i=y(e);v(r,`${c(i,t)}\n---\n\n${f(i,t)}`,`utf-8`),console.log(` Updated .cursor/rules/aikit.mdc`);let a=b(n,`kb.mdc`);m(a)&&a!==r&&(_(a),console.log(` Removed legacy .cursor/rules/kb.mdc`))},writeAgentsMd(e,t){}},M={scaffoldDir:`general`,writeMcpConfig(e,t){let n=b(e,`.vscode`),r=b(n,`mcp.json`);m(r)||(h(n,{recursive:!0}),v(r,`${JSON.stringify(E(t),null,2)}\n`,`utf-8`),console.log(` Created .vscode/mcp.json (Windsurf-compatible)`))},writeInstructions(e,t){let n=b(e,`.windsurfrules`),r=y(e);v(n,`${c(r,t)}\n---\n\n${f(r,t)}`,`utf-8`),console.log(` Updated .windsurfrules`)},writeAgentsMd(e,t){}},N={scaffoldDir:`general`,writeMcpConfig(e,t){let n=b(e,`.zed`),r=b(n,`settings.json`);if(h(n,{recursive:!0}),!m(r))v(r,`${JSON.stringify(O(t),null,2)}\n`,`utf-8`),console.log(` Created .zed/settings.json`);else{let e;try{e=JSON.parse(g(r,`utf-8`))}catch{console.warn(` ⚠ .zed/settings.json contains invalid JSON — skipping MCP config merge`);return}e.context_servers?.[t]||(e.context_servers={...e.context_servers,...O(t).context_servers},v(r,`${JSON.stringify(e,null,2)}\n`,`utf-8`),console.log(` Updated .zed/settings.json with context_servers`))}},writeInstructions(e,t){let n=b(e,`.rules`),r=y(e);v(n,`${c(r,t)}\n---\n\n${f(r,t)}`,`utf-8`),console.log(` Updated .rules`)},writeAgentsMd(e,t){}},P={scaffoldDir:`general`,writeMcpConfig(e,t){let n=b(e,`mcp.json`);m(n)||(v(n,`${JSON.stringify(D(t),null,2)}\n`,`utf-8`),console.log(` Created mcp.json`))},writeInstructions(e,t){let n=b(e,`.aiassistant`,`rules`),r=b(n,`aikit.md`);h(n,{recursive:!0});let i=y(e);v(r,`${c(i,t)}\n---\n\n${f(i,t)}`,`utf-8`),console.log(` Updated .aiassistant/rules/aikit.md`)},writeAgentsMd(e,t){}};function F(e){switch(e){case`copilot`:return k;case`claude-code`:return A;case`cursor`:return j;case`windsurf`:return M;case`zed`:return N;case`intellij`:return P;case`gemini-cli`:case`codex-cli`:return k}}const I={serverName:o,sources:[{path:`.`,excludePatterns:[`**/node_modules/**`,`**/dist/**`,`**/build/**`,`**/.git/**`,`**/${x.data}/**`,`**/coverage/**`,`**/*.min.js`,`**/package-lock.json`,`**/pnpm-lock.yaml`]}],indexing:{chunkSize:1500,chunkOverlap:200,minChunkSize:100},embedding:{model:S.model,dimensions:S.dimensions},store:{backend:`sqlite-vec`,path:x.data},curated:{path:x.aiCurated}};function L(e,t){let n=b(e,`aikit.config.json`);return m(n)&&!t?(console.log(`aikit.config.json already exists. Use --force to overwrite.`),!1):(v(n,`${JSON.stringify(I,null,2)}\n`,`utf-8`),console.log(` Created aikit.config.json`),!0)}function R(e){let t=b(e,`.gitignore`),n=[{dir:`${x.data}/`,label:`AI Kit vector store`},{dir:`${x.state}/`,label:`AI Kit session state`},{dir:`${x.restorePoints}/`,label:`Restore points (codemod/rename undo snapshots)`},{dir:`${x.brainstorm}/`,label:`Brainstorming sessions`},{dir:`${x.handoffs}/`,label:`Handoff documents`}];if(m(t)){let e=g(t,`utf-8`),r=n.filter(t=>!e.includes(t.dir));r.length>0&&(p(t,`\n${r.map(e=>`# ${e.label}\n${e.dir}`).join(`
|
|
2
2
|
`)}\n`,`utf-8`),console.log(` Added ${r.map(e=>e.dir).join(`, `)} to .gitignore`))}else v(t,`${n.map(e=>`# ${e.label}\n${e.dir}`).join(`
|
|
3
3
|
`)}\n`,`utf-8`),console.log(` Created .gitignore with AI Kit entries`)}function z(){return I.serverName}const B=[`decisions`,`patterns`,`conventions`,`troubleshooting`];function V(e){let t=b(e,`.ai`,`curated`);m(t)||(h(t,{recursive:!0}),console.log(` Created .ai/curated/`));for(let e of B){let n=b(t,e);m(n)||h(n,{recursive:!0})}console.log(` Created .ai/curated/{${B.join(`,`)}}/`)}function H(e){switch(e){case`zed`:return`zed`;case`intellij`:return`intellij`;case`claude-code`:return`claude-code`;case`gemini-cli`:return`gemini`;case`codex-cli`:return`codex`;default:return`copilot`}}async function U(n){let i=process.cwd();if(!L(i,n.force))return;R(i);let a=z(),o=F(w(i));o.writeMcpConfig(i,a),o.writeInstructions(i,a),o.writeAgentsMd(i,a);let s=u(),c=JSON.parse(g(b(s,`package.json`),`utf-8`)).version;await t(i,s,[...l],c,n.force),await r(i,s,[...d],c,n.force);let f=T(i),p=new Set;for(let t of f){let r=H(t);p.has(r)||(p.add(r),await e(i,s,r,c,n.force))}V(i),console.log(`
|
|
4
4
|
AI Kit initialized! Next steps:`),console.log(` aikit reindex Index your codebase`),console.log(` aikit search Search indexed content`),console.log(` aikit serve Start MCP server for IDE integration`),C()&&console.log(`
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"node:module";import{existsSync as e,mkdirSync as t,readFileSync as n,rmSync as r,unlinkSync as i,writeFileSync as a}from"node:fs";import{dirname as o,resolve as s}from"node:path";import{pathToFileURL as c}from"node:url";import{createHash as l}from"node:crypto";var u=Object.defineProperty,d=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n};const f=[`inputs`,`outputs`,`requires`,`relatedSkills`],p=[`category`,`domain`,`applicability`],m=new Set([`__proto__`,`constructor`,`prototype`]);function h(e,t){return e.metadata[t]??e.fields[t]}function g(e,t){let n=h(e,t);return n?v(n):[]}function _(e){let t=Object.create(null),n=Object.create(null),r=[],i=e,a=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!a)return{fields:t,metadata:n,tools:r,body:i};let o=a[1];i=a[2];let s=!1;for(let e of o.split(/\r?\n/)){if(s){if(e.trim()===``)continue;let t=e.match(/^\s{2,}(\S+?):\s*(.*)$/);if(t){let[,e,r]=t;if(m.has(e))continue;n[e]=r;continue}s=!1}let i=e.match(/^(\S+?):\s*(.*)$/);if(!i)continue;let[,a,o]=i;if(a===`metadata`&&o.trim()===``){s=!0;continue}m.has(a)||(t[a]=o,a===`tools`&&(r=v(o)))}return{fields:t,metadata:n,tools:r,body:i}}function v(e){let t=e.trim();if(!t.startsWith(`[`)||!t.endsWith(`]`))return[];let n=t.slice(1,-1).trim();return n?n.split(`,`).map(e=>e.trim()).filter(Boolean):[]}function y(e){return`[${e.join(`, `)}]`}function b(e,t){let n=_(e),r=_(t),i={...n.fields},a={...n.metadata};for(let[e,t]of Object.entries(r.metadata))e in a||(a[e]=t);for(let e of p){let t=h(r,e);t&&(a[e]=t)}for(let e of[...p,...f])delete i[e];delete i.metadata;let o=n.tools,s=r.tools,c=new Set(o),l=s.filter(e=>!c.has(e)),u=[...o,...l];u.length>0&&(i.tools=y(u));for(let e of f){let t=g(n,e),i=g(r,e),o=new Set(t),s=i.filter(e=>!o.has(e)),c=[...t,...s];c.length>0?a[e]=y(c):delete a[e]}let d=[`---`],m=[`name`,`description`,`argument-hint`,`tools`,`model`],v=[`category`,`domain`,`applicability`,`inputs`,`outputs`,`requires`,`relatedSkills`],b=new Set;for(let e of m)e in i&&(d.push(`${e}: ${i[e]}`),b.add(e));for(let[e,t]of Object.entries(i))b.has(e)||d.push(`${e}: ${t}`);let x=[],S=new Set;for(let e of v){let t=a[e];t&&(x.push(` ${e}: ${t}`),S.add(e))}for(let[e,t]of Object.entries(a))!S.has(e)&&t&&x.push(` ${e}: ${t}`);return x.length>0&&(d.push(`metadata:`),d.push(...x)),d.push(`---`),`${d.join(`
|
|
2
|
+
`)}\n${n.body}`}function x(e){return l(`sha256`).update(e).digest(`hex`).slice(0,16)}function S(t){if(!e(t))return null;try{let e=n(t,`utf-8`),r=JSON.parse(e);return!r.version||!r.files?null:r}catch{return null}}function C(e,t){a(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function w(e){return e.endsWith(`.agent.md`)&&!e.startsWith(`_shared/`)&&!e.startsWith(`agents/_shared/`)&&!e.startsWith(`templates/`)||e.endsWith(`SKILL.md`)&&!e.startsWith(`_shared/`)&&!e.startsWith(`templates/`)?`merge-frontmatter`:e===`copilot-instructions.md`||e===`CLAUDE.md`?`regenerate`:`overwrite`}function T(e,t,n){if(!e)return`new`;let r=e.files[t];return r?r.sourceHash===x(n)?`current`:`outdated`:`new`}function E(e,t,n,r){e.files[t]={sourceHash:x(n),strategy:r??w(t),updatedAt:new Date().toISOString()}}function D(e){return{version:e,generatedAt:new Date().toISOString(),files:{}}}var O=d({guideFlows:()=>L,guideScaffold:()=>P,guideSkills:()=>F,loadAdapter:()=>k,smartCopyFlows:()=>I,smartCopyFromMemory:()=>A,smartCopyScaffold:()=>M,smartCopySkills:()=>N});async function k(e,t){let n=await import(c(s(e,`scaffold`,`dist`,`adapters`,`${t}.mjs`)).href),r=n[`generate${t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}`]??n.generate??n.default;if(typeof r!=`function`)throw Error(`Adapter ${t} does not export a generate function`);return r()}function A(r,i,c,l,u=!1){t(i,{recursive:!0});for(let d of r){let r=l?`${l}/${d.path}`:d.path,f=s(i,d.path);if(u){t(o(f),{recursive:!0}),a(f,d.content,`utf-8`),E(c,r,d.content);continue}let p=T(c,r,d.content);if(p===`current`)continue;let m=w(r);if(m===`regenerate`){t(o(f),{recursive:!0}),a(f,d.content,`utf-8`),E(c,r,d.content);continue}if(p===`new`&&!e(f)){t(o(f),{recursive:!0}),a(f,d.content,`utf-8`),E(c,r,d.content);continue}if(p===`new`&&e(f)){E(c,r,d.content);continue}if(m===`merge-frontmatter`&&e(f)){let e=n(f,`utf-8`);a(f,b(d.content,e),`utf-8`)}else t(o(f),{recursive:!0}),a(f,d.content,`utf-8`);E(c,r,d.content)}u&&j(i,c,l,new Set(r.map(e=>l?`${l}/${e.path}`:e.path)))}function j(t,n,r,a){let o=[];for(let c of Object.keys(n.files)){if(!c.startsWith(`${r}/`)||a.has(c))continue;let l=s(t,c.slice(r.length+1));e(l)&&(i(l),o.push(c)),delete n.files[c]}return o}async function M(e,t,n=`copilot`,r,i=!1){let a=await k(t,n),o=a.some(e=>e.path.startsWith(`.`)),c=o?e:s(e,`.github`),l=s(c,`.aikit-scaffold.json`),u=S(l)??D(r);u.version=r;let d=new Map;for(let e of a){let t=e.path.indexOf(`/`);if(t===-1){let t=d.get(``)??[];t.push({path:e.path,content:e.content}),d.set(``,t);continue}let n=e.path.substring(0,t),r=e.path.substring(t+1),i=d.get(n)??[];i.push({path:r,content:e.content}),d.set(n,i)}for(let[e,t]of d)A(t,e?s(c,e):c,u,o?`${n}/${e||`.`}`:e||`.`,i);C(l,u)}async function N(e,t,n,r,i=!1){let a=s(e,`.github`),o=s(a,`.aikit-scaffold.json`),c=S(o)??D(r);c.version=r;let l=await k(t,`skills`),u=new Map;for(let e of l){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t),r=e.path.substring(t+1),i=u.get(n)??[];i.push({path:r,content:e.content}),u.set(n,i)}for(let[e,t]of u)A(t,s(a,`skills`,e),c,`skills/${e}`,i);C(o,c)}async function P(t,r,i=`copilot`){let a=[],o=await k(r,i),c=o.some(e=>e.path.startsWith(`.`))?t:s(t,`.github`);for(let t of o){let r=s(c,t.path);if(!e(r))a.push({status:`new`,relativePath:t.path,sourcePath:``,content:t.content});else{let e=n(r,`utf-8`);t.content===e?a.push({status:`current`,relativePath:t.path,sourcePath:``}):a.push({status:`outdated`,relativePath:t.path,sourcePath:``,content:t.content})}}return a}async function F(t,r,i){let a=[],o=await k(r,`skills`),c=s(t,`.github`);for(let t of o){let r=`skills/${t.path}`,i=s(c,`skills`,t.path);if(!e(i))a.push({status:`new`,relativePath:r,sourcePath:``,content:t.content});else{let e=n(i,`utf-8`);t.content===e?a.push({status:`current`,relativePath:r,sourcePath:``}):a.push({status:`outdated`,relativePath:r,sourcePath:``,content:t.content})}}return a}async function I(t,n,i,a,o=!1){let c=s(t,`.github`),l=s(c,`.aikit-scaffold.json`),u=S(l)??D(a);u.version=a;let d=await k(n,`flows`),f=new Set,p=new Map;for(let e of d){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t);f.add(n);let r=e.path.substring(t+1),i=p.get(n)??[];i.push({path:r,content:e.content}),p.set(n,i)}for(let t of f){let n=s(c,`flows`,t,`skills`);e(n)&&r(n,{recursive:!0,force:!0})}for(let[e,t]of p)A(t,s(c,`flows`,e),u,`flows/${e}`,o);C(l,u)}async function L(t,r,i){let a=[],o=await k(r,`flows`),c=s(t,`.github`);for(let t of o){let r=`flows/${t.path}`,i=s(c,`flows`,t.path);if(!e(i))a.push({status:`new`,relativePath:r,sourcePath:``,content:t.content});else{let e=n(i,`utf-8`);t.content===e?a.push({status:`current`,relativePath:r,sourcePath:``}):a.push({status:`outdated`,relativePath:r,sourcePath:``,content:t.content})}}return a}export{O as a,M as c,S as d,C as f,k as i,N as l,d as m,P as n,I as o,_ as p,F as r,A as s,L as t,D as u};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import{AGENTS as e}from"../definitions/agents.mjs";import{AGENT_BODIES as t}from"../definitions/bodies.mjs";import{VARIANT_GROUPS as n,
|
|
2
|
-
`),
|
|
3
|
-
`);function
|
|
4
|
-
`)}`}function
|
|
5
|
-
`)}`:``,
|
|
6
|
-
description: '${
|
|
7
|
-
${r.argumentHint?`argument-hint: "${r.argumentHint}"\n`:``}tools: ${
|
|
1
|
+
import{AGENTS as e}from"../definitions/agents.mjs";import{AGENT_BODIES as t}from"../definitions/bodies.mjs";import{VARIANT_GROUPS as n,getPrimaryAgentModel as r}from"../definitions/models.mjs";import{PROMPTS as i}from"../definitions/prompts.mjs";import{AIKIT_INSTALL_HINT_SECTION as a,PLATFORM_OUTPUT_RULES_SECTION as o,PROTOCOLS as s,TEMPLATES as c}from"../definitions/protocols.mjs";import{IDE_CAPABILITIES as l}from"../definitions/tools.mjs";import{buildCompactAgentTable as u}from"./_shared.mjs";import{generateHooks as d,getHookScriptFiles as f}from"./hooks.mjs";const p={terminal:`execute/runInTerminal`,problems:`read/problems`,readFile:`read/readFile`,lastCommand:`read/terminalLastCommand`,subagent:`agent/runSubagent`,createFile:`edit/createFile`,editFiles:`edit/editFiles`,rename:`edit/rename`,createDirectory:`edit/createDirectory`,search:`search/changes, search/codebase, search/usages`,web:`web/fetch, web/githubRepo`,todo:`todo`,memory:`vscode/memory`,newWorkspace:`vscode/newWorkspace`,reviewPlan:`vscode/reviewPlan`,askQuestions:`vscode/askQuestions`,resolveMemoryFileUri:`vscode/resolveMemoryFileUri`,runCommand:`vscode/runCommand`,switchAgent:`vscode/switchAgent`,killTerminal:`execute/killTerminal`,createTask:`execute/createAndRunTask`,terminalSel:`read/terminalSelection`,fileSearch:`search/fileSearch`,listDir:`search/listDirectory`,textSearch:`search/textSearch`,searchSubagent:`search/searchSubagent`};function m(e){return`[${[...(l[e]||[]).map(e=>p[e]).filter(Boolean),`aikit/*`].join(`, `)}]`}function h(e){return r(`copilot`,e,`Auto (copilot)`)}const g=[`## Flows`,``,"This project uses aikit's pluggable flow system. Check flow status with the `flow` MCP tool.","If a flow is active, follow the current step's skill instructions. Advance with `flow({ action: 'step', advance: 'next' })`.","Use `flow({ action: 'list' })` to see available flows and `flow({ action: 'start', name, topic })` to begin one."].join(`
|
|
2
|
+
`),_=[`## Flows`,``,"This project uses aikit's pluggable flow system. Use `flow({ action: 'status' })` to check if a flow is active.",`If dispatched as part of a flow, your work contributes to the current step. Do NOT advance or manage the flow — the Orchestrator handles flow lifecycle.`].join(`
|
|
3
|
+
`);function v(){let t=[];for(let[i,a]of Object.entries(e))if(a.variants)for(let e of n[i]||[]){let n=`${i}-${e}`,o=r(`copilot`,n,`Unknown`),s=(a.variants[e]||{}).description||a.description;t.push(`| **${n}** | ${s} | ${o} | ${a.category} |`)}else{let e=r(`copilot`,i,`Unknown`);t.push(`| **${i}** | ${a.description} | ${e} | ${a.category} |`)}return`| Agent | Purpose | Model | Category |\n|-------|---------|-------|----------|\n${t.join(`
|
|
4
|
+
`)}`}function y(e,t,r){let i=`${e}-${t}`,a=r.variants[t]||{},o=h(i),c=a.description||r.description,l=a.identity||(t===n[e]?.[0]?`, the primary ${e} agent.`:`, a variant of ${e}. Same responsibilities, different model perspective.`),u=r.sharedBase&&s[r.sharedBase]?`\n\n${s[r.sharedBase]}`:``,d=r.extraBody?`\n\n${r.extraBody}`:``,f=a.bodyAddendum?`\n\n${a.bodyAddendum}`:``,p=(r.sharedProtocols||[]).map(e=>s[e]?`\n\n${s[e]}`:``).join(``),g=r.skills?.length?`\n\n## Skills (load on demand)\n\n| Skill | When to load |\n|-------|--------------|\n${r.skills.map(([e,t])=>`| ${e} | ${t} |`).join(`
|
|
5
|
+
`)}`:``,v=r.title||e;return`---
|
|
6
|
+
description: '${c}'
|
|
7
|
+
${r.argumentHint?`argument-hint: "${r.argumentHint}"\n`:``}tools: ${m(r.toolRole)}
|
|
8
8
|
model: ${o}
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
# ${i} - ${
|
|
11
|
+
# ${i} - ${v}
|
|
12
12
|
|
|
13
13
|
You are **${i}**${l}${d}
|
|
14
|
-
${u}${p}${f}${
|
|
14
|
+
${u}${p}${f}${g}
|
|
15
15
|
|
|
16
|
-
${
|
|
17
|
-
`}function
|
|
16
|
+
${_}
|
|
17
|
+
`}function b(n,r){let i=h(n),a=typeof t[n]==`function`?t[n](u(e)):t[n]||``,o=r.sharedBase&&s[r.sharedBase]?`\n\n${s[r.sharedBase]}`:``,c=(r.sharedProtocols||[]).map(e=>s[e]?`\n\n${s[e]}`:``).join(``),l=r.title||n,d=r.skills?.length?`\n## Skills (load on demand)\n\n| Skill | When to load |\n|-------|--------------|\n${r.skills.map(([e,t])=>`| ${e} | ${t} |`).join(`
|
|
18
18
|
`)}\n`:``;return`---
|
|
19
19
|
description: '${r.description}'
|
|
20
|
-
${r.argumentHint?`argument-hint: "${r.argumentHint}"\n`:``}tools: ${
|
|
20
|
+
${r.argumentHint?`argument-hint: "${r.argumentHint}"\n`:``}tools: ${m(r.toolRole)}
|
|
21
21
|
model: ${i}
|
|
22
22
|
---
|
|
23
23
|
|
|
@@ -25,22 +25,22 @@ model: ${i}
|
|
|
25
25
|
|
|
26
26
|
You are the **${n}**, ${r.description.toLowerCase().replace(/^./,e=>e.toLowerCase())}
|
|
27
27
|
|
|
28
|
-
${a}${o}${
|
|
28
|
+
${a}${o}${c}${d}
|
|
29
29
|
|
|
30
|
-
${n===`Orchestrator`?_
|
|
31
|
-
`}function
|
|
30
|
+
${n===`Orchestrator`?g:_}
|
|
31
|
+
`}function x(e,t){return`---
|
|
32
32
|
description: "${t.description}"
|
|
33
33
|
agent: "${t.agent}"
|
|
34
34
|
---
|
|
35
35
|
|
|
36
36
|
${t.content}
|
|
37
|
-
`}function
|
|
37
|
+
`}function S(){return`# Agents
|
|
38
38
|
|
|
39
39
|
This directory contains AI agent definitions generated by \`@vpxa/aikit init\`.
|
|
40
40
|
|
|
41
41
|
## Agent Roster
|
|
42
42
|
|
|
43
|
-
${
|
|
43
|
+
${v()}
|
|
44
44
|
|
|
45
45
|
## Multi-Model Pattern
|
|
46
46
|
|
|
@@ -73,5 +73,5 @@ To regenerate after changing models or agent definitions:
|
|
|
73
73
|
cd knowledge-base
|
|
74
74
|
node scaffold/generate.mjs
|
|
75
75
|
\`\`\`
|
|
76
|
-
`}function
|
|
77
|
-
`)}function
|
|
76
|
+
`}function C(){return[`# aikit — Copilot Instructions`,``,o,``,a,``].join(`
|
|
77
|
+
`)}function w(){let t=[];if(f().length===0)throw Error(`Executable hooks are not configured.`);t.push({path:`copilot-instructions.md`,content:C()});for(let[r,i]of Object.entries(e))if(i.variants)for(let e of n[r]||[])t.push({path:`agents/${r}-${e}.agent.md`,content:y(r,e,i)});else t.push({path:`agents/${r}.agent.md`,content:b(r,i)});for(let[e,n]of Object.entries(s))t.push({path:`agents/_shared/${e}.md`,content:`${n}\n`});for(let[e,n]of Object.entries(c))t.push({path:`agents/templates/${e}.md`,content:`${n}\n`});t.push({path:`agents/README.md`,content:S()});for(let[e,n]of Object.entries(i))t.push({path:`prompts/aikit-${e}.prompt.md`,content:x(e,n)});let r=d(`copilot`,`~/.copilot/hooks/scripts`);return t.push(...r.map(e=>({path:`hooks/${e.path}`,content:e.content}))),t}export{w as generateCopilot};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"node:module";import{existsSync as e,mkdirSync as t,readFileSync as n,rmSync as r,unlinkSync as i,writeFileSync as a}from"node:fs";import{dirname as o,resolve as s}from"node:path";import{pathToFileURL as c}from"node:url";import{createHash as l}from"node:crypto";var u=Object.defineProperty,d=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n};const f=[`inputs`,`outputs`,`requires`,`relatedSkills`],p=[`model`],m=[`category`,`domain`,`applicability`],h=new Set([`__proto__`,`constructor`,`prototype`]);function g(e,t){return e.metadata[t]??e.fields[t]}function _(e,t){let n=g(e,t);return n?y(n):[]}function v(e){let t=Object.create(null),n=Object.create(null),r=[],i=e,a=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);if(!a)return{fields:t,metadata:n,tools:r,body:i};let o=a[1];i=a[2];let s=!1;for(let e of o.split(/\r?\n/)){if(s){if(e.trim()===``)continue;let t=e.match(/^\s{2,}(\S+?):\s*(.*)$/);if(t){let[,e,r]=t;if(h.has(e))continue;n[e]=r;continue}s=!1}let i=e.match(/^(\S+?):\s*(.*)$/);if(!i)continue;let[,a,o]=i;if(a===`metadata`&&o.trim()===``){s=!0;continue}h.has(a)||(t[a]=o,a===`tools`&&(r=y(o)))}return{fields:t,metadata:n,tools:r,body:i}}function y(e){let t=e.trim();if(!t.startsWith(`[`)||!t.endsWith(`]`))return[];let n=t.slice(1,-1).trim();return n?n.split(`,`).map(e=>e.trim()).filter(Boolean):[]}function b(e){return`[${e.join(`, `)}]`}function x(e,t){let n=v(e),r=v(t),i={...n.fields},a={...n.metadata};for(let[e,t]of Object.entries(r.metadata))e in a||(a[e]=t);for(let e of p)r.fields[e]&&(i[e]=r.fields[e]);for(let e of m){let t=g(r,e);t&&(a[e]=t)}for(let e of[...m,...f])delete i[e];delete i.metadata;let o=n.tools,s=r.tools,c=new Set(o),l=s.filter(e=>!c.has(e)),u=[...o,...l];u.length>0&&(i.tools=b(u));for(let e of f){let t=_(n,e),i=_(r,e),o=new Set(t),s=i.filter(e=>!o.has(e)),c=[...t,...s];c.length>0?a[e]=b(c):delete a[e]}let d=[`---`],h=[`name`,`description`,`argument-hint`,`tools`,`model`],y=[`category`,`domain`,`applicability`,`inputs`,`outputs`,`requires`,`relatedSkills`],x=new Set;for(let e of h)e in i&&(d.push(`${e}: ${i[e]}`),x.add(e));for(let[e,t]of Object.entries(i))x.has(e)||d.push(`${e}: ${t}`);let S=[],C=new Set;for(let e of y){let t=a[e];t&&(S.push(` ${e}: ${t}`),C.add(e))}for(let[e,t]of Object.entries(a))!C.has(e)&&t&&S.push(` ${e}: ${t}`);return S.length>0&&(d.push(`metadata:`),d.push(...S)),d.push(`---`),`${d.join(`
|
|
2
|
-
`)}\n${n.body}`}function S(e){return l(`sha256`).update(e).digest(`hex`).slice(0,16)}function C(t){if(!e(t))return null;try{let e=n(t,`utf-8`),r=JSON.parse(e);return!r.version||!r.files?null:r}catch{return null}}function w(e,t){a(e,`${JSON.stringify(t,null,2)}\n`,`utf-8`)}function T(e){return e.endsWith(`.agent.md`)&&!e.startsWith(`_shared/`)&&!e.startsWith(`agents/_shared/`)&&!e.startsWith(`templates/`)||e.endsWith(`SKILL.md`)&&!e.startsWith(`_shared/`)&&!e.startsWith(`templates/`)?`merge-frontmatter`:e===`copilot-instructions.md`||e===`CLAUDE.md`?`regenerate`:`overwrite`}function E(e,t,n){if(!e)return`new`;let r=e.files[t];return r?r.sourceHash===S(n)?`current`:`outdated`:`new`}function D(e,t,n,r){e.files[t]={sourceHash:S(n),strategy:r??T(t),updatedAt:new Date().toISOString()}}function O(e){return{version:e,generatedAt:new Date().toISOString(),files:{}}}var k=d({guideFlows:()=>R,guideScaffold:()=>F,guideSkills:()=>I,loadAdapter:()=>A,smartCopyFlows:()=>L,smartCopyFromMemory:()=>j,smartCopyScaffold:()=>N,smartCopySkills:()=>P});async function A(e,t){let n=await import(c(s(e,`scaffold`,`dist`,`adapters`,`${t}.mjs`)).href),r=n[`generate${t.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}`]??n.generate??n.default;if(typeof r!=`function`)throw Error(`Adapter ${t} does not export a generate function`);return r()}function j(r,i,c,l,u=!1){t(i,{recursive:!0});for(let d of r){let r=l?`${l}/${d.path}`:d.path,f=s(i,d.path);if(u){t(o(f),{recursive:!0}),a(f,d.content,`utf-8`),D(c,r,d.content);continue}let p=E(c,r,d.content);if(p===`current`)continue;let m=T(r);if(m===`regenerate`){t(o(f),{recursive:!0}),a(f,d.content,`utf-8`),D(c,r,d.content);continue}if(p===`new`&&!e(f)){t(o(f),{recursive:!0}),a(f,d.content,`utf-8`),D(c,r,d.content);continue}if(p===`new`&&e(f)){D(c,r,d.content);continue}if(m===`merge-frontmatter`&&e(f)){let e=n(f,`utf-8`);a(f,x(d.content,e),`utf-8`)}else t(o(f),{recursive:!0}),a(f,d.content,`utf-8`);D(c,r,d.content)}u&&M(i,c,l,new Set(r.map(e=>l?`${l}/${e.path}`:e.path)))}function M(t,n,r,a){let o=[];for(let c of Object.keys(n.files)){if(!c.startsWith(`${r}/`)||a.has(c))continue;let l=s(t,c.slice(r.length+1));e(l)&&(i(l),o.push(c)),delete n.files[c]}return o}async function N(e,t,n=`copilot`,r,i=!1){let a=await A(t,n),o=a.some(e=>e.path.startsWith(`.`)),c=o?e:s(e,`.github`),l=s(c,`.aikit-scaffold.json`),u=C(l)??O(r);u.version=r;let d=new Map;for(let e of a){let t=e.path.indexOf(`/`);if(t===-1){let t=d.get(``)??[];t.push({path:e.path,content:e.content}),d.set(``,t);continue}let n=e.path.substring(0,t),r=e.path.substring(t+1),i=d.get(n)??[];i.push({path:r,content:e.content}),d.set(n,i)}for(let[e,t]of d)j(t,e?s(c,e):c,u,o?`${n}/${e||`.`}`:e||`.`,i);w(l,u)}async function P(e,t,n,r,i=!1){let a=s(e,`.github`),o=s(a,`.aikit-scaffold.json`),c=C(o)??O(r);c.version=r;let l=await A(t,`skills`),u=new Map;for(let e of l){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t),r=e.path.substring(t+1),i=u.get(n)??[];i.push({path:r,content:e.content}),u.set(n,i)}for(let[e,t]of u)j(t,s(a,`skills`,e),c,`skills/${e}`,i);w(o,c)}async function F(t,r,i=`copilot`){let a=[],o=await A(r,i),c=o.some(e=>e.path.startsWith(`.`))?t:s(t,`.github`);for(let t of o){let r=s(c,t.path);if(!e(r))a.push({status:`new`,relativePath:t.path,sourcePath:``,content:t.content});else{let e=n(r,`utf-8`);t.content===e?a.push({status:`current`,relativePath:t.path,sourcePath:``}):a.push({status:`outdated`,relativePath:t.path,sourcePath:``,content:t.content})}}return a}async function I(t,r,i){let a=[],o=await A(r,`skills`),c=s(t,`.github`);for(let t of o){let r=`skills/${t.path}`,i=s(c,`skills`,t.path);if(!e(i))a.push({status:`new`,relativePath:r,sourcePath:``,content:t.content});else{let e=n(i,`utf-8`);t.content===e?a.push({status:`current`,relativePath:r,sourcePath:``}):a.push({status:`outdated`,relativePath:r,sourcePath:``,content:t.content})}}return a}async function L(t,n,i,a,o=!1){let c=s(t,`.github`),l=s(c,`.aikit-scaffold.json`),u=C(l)??O(a);u.version=a;let d=await A(n,`flows`),f=new Set,p=new Map;for(let e of d){let t=e.path.indexOf(`/`);if(t===-1)continue;let n=e.path.substring(0,t);f.add(n);let r=e.path.substring(t+1),i=p.get(n)??[];i.push({path:r,content:e.content}),p.set(n,i)}for(let t of f){let n=s(c,`flows`,t,`skills`);e(n)&&r(n,{recursive:!0,force:!0})}for(let[e,t]of p)j(t,s(c,`flows`,e),u,`flows/${e}`,o);w(l,u)}async function R(t,r,i){let a=[],o=await A(r,`flows`),c=s(t,`.github`);for(let t of o){let r=`flows/${t.path}`,i=s(c,`flows`,t.path);if(!e(i))a.push({status:`new`,relativePath:r,sourcePath:``,content:t.content});else{let e=n(i,`utf-8`);t.content===e?a.push({status:`current`,relativePath:r,sourcePath:``}):a.push({status:`outdated`,relativePath:r,sourcePath:``,content:t.content})}}return a}export{k as a,N as c,C as d,w as f,A as i,P as l,d as m,F as n,L as o,v as p,I as r,j as s,R as t,O as u};
|